LCOV - code coverage report
Current view: top level - editeng/source/editeng - editeng.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 820 1357 60.4 %
Date: 2015-06-13 12:38:46 Functions: 184 281 65.5 %
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 <vcl/wrkwin.hxx>
      21             : #include <vcl/dialog.hxx>
      22             : #include <vcl/msgbox.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : 
      25             : #include <svtools/ctrltool.hxx>
      26             : 
      27             : #include <editeng/svxfont.hxx>
      28             : #include <impedit.hxx>
      29             : #include <editeng/editeng.hxx>
      30             : #include <editeng/editview.hxx>
      31             : #include <editeng/editstat.hxx>
      32             : #include <editdbg.hxx>
      33             : #include <eerdll2.hxx>
      34             : #include <editeng/eerdll.hxx>
      35             : #include <editeng.hrc>
      36             : #include <editeng/acorrcfg.hxx>
      37             : #include <editeng/flditem.hxx>
      38             : #include <editeng/txtrange.hxx>
      39             : #include <editeng/cmapitem.hxx>
      40             : #include <vcl/graph.hxx>
      41             : 
      42             : #include <editeng/autokernitem.hxx>
      43             : #include <editeng/contouritem.hxx>
      44             : #include <editeng/colritem.hxx>
      45             : #include <editeng/crossedoutitem.hxx>
      46             : #include <editeng/escapementitem.hxx>
      47             : #include <editeng/fhgtitem.hxx>
      48             : #include <editeng/fontitem.hxx>
      49             : #include <editeng/kernitem.hxx>
      50             : #include <editeng/lrspitem.hxx>
      51             : #include <editeng/postitem.hxx>
      52             : #include <editeng/shdditem.hxx>
      53             : #include <editeng/udlnitem.hxx>
      54             : #include <editeng/wghtitem.hxx>
      55             : #include <editeng/wrlmitem.hxx>
      56             : #include <editeng/brushitem.hxx>
      57             : #include <editeng/charsetcoloritem.hxx>
      58             : #include <editeng/langitem.hxx>
      59             : #include <editeng/emphasismarkitem.hxx>
      60             : #include <editeng/charscaleitem.hxx>
      61             : #include <editeng/charreliefitem.hxx>
      62             : 
      63             : #include <sot/exchange.hxx>
      64             : #include <sot/formats.hxx>
      65             : 
      66             : #include <editeng/numitem.hxx>
      67             : #include <editeng/bulletitem.hxx>
      68             : #include <editeng/unolingu.hxx>
      69             : #include <linguistic/lngprops.hxx>
      70             : #include <i18nlangtag/mslangid.hxx>
      71             : #include <rtl/strbuf.hxx>
      72             : #include <vcl/help.hxx>
      73             : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
      74             : #include <com/sun/star/i18n/InputSequenceCheckMode.hpp>
      75             : 
      76             : #include <svl/srchdefs.hxx>
      77             : 
      78             : #if OSL_DEBUG_LEVEL > 1
      79             : #include <editeng/frmdiritem.hxx>
      80             : #endif
      81             : #include <basegfx/polygon/b2dpolygon.hxx>
      82             : 
      83             : using namespace ::com::sun::star;
      84             : using namespace ::com::sun::star::uno;
      85             : using namespace ::com::sun::star::linguistic2;
      86             : 
      87             : 
      88             : #if (OSL_DEBUG_LEVEL > 1) || defined ( DBG_UTIL )
      89             : static bool bDebugPaint = false;
      90             : #endif
      91             : 
      92             : static SfxItemPool* pGlobalPool=0;
      93             : 
      94       42102 : EditEngine::EditEngine( SfxItemPool* pItemPool )
      95             : {
      96       42102 :     pImpEditEngine = new ImpEditEngine( this, pItemPool );
      97       42102 : }
      98             : 
      99       39823 : EditEngine::~EditEngine()
     100             : {
     101       39771 :     delete pImpEditEngine;
     102       39823 : }
     103             : 
     104     1805017 : void EditEngine::EnableUndo( bool bEnable )
     105             : {
     106     1805017 :     pImpEditEngine->EnableUndo( bEnable );
     107     1805017 : }
     108             : 
     109     2547272 : bool EditEngine::IsUndoEnabled()
     110             : {
     111     2547272 :     return pImpEditEngine->IsUndoEnabled();
     112             : }
     113             : 
     114     2975528 : bool EditEngine::IsInUndo()
     115             : {
     116     2975528 :     return pImpEditEngine->IsInUndo();
     117             : }
     118             : 
     119      686754 : ::svl::IUndoManager& EditEngine::GetUndoManager()
     120             : {
     121      686754 :     return pImpEditEngine->GetUndoManager();
     122             : }
     123             : 
     124          18 : ::svl::IUndoManager* EditEngine::SetUndoManager(::svl::IUndoManager* pNew)
     125             : {
     126          18 :     return pImpEditEngine->SetUndoManager(pNew);
     127             : }
     128             : 
     129      101499 : void EditEngine::UndoActionStart( sal_uInt16 nId )
     130             : {
     131             :     DBG_ASSERT( !pImpEditEngine->IsInUndo(), "Calling UndoActionStart in Undomode!" );
     132      101499 :     if ( !pImpEditEngine->IsInUndo() )
     133      101499 :         pImpEditEngine->UndoActionStart( nId );
     134      101499 : }
     135             : 
     136           0 : void EditEngine::UndoActionStart(sal_uInt16 nId, const ESelection& rSel)
     137             : {
     138           0 :     pImpEditEngine->UndoActionStart(nId, rSel);
     139           0 : }
     140             : 
     141      101499 : void EditEngine::UndoActionEnd( sal_uInt16 nId )
     142             : {
     143             :     DBG_ASSERT( !pImpEditEngine->IsInUndo(), "Calling UndoActionEnd in Undomode!" );
     144      101499 :     if ( !pImpEditEngine->IsInUndo() )
     145      101499 :         pImpEditEngine->UndoActionEnd( nId );
     146      101499 : }
     147             : 
     148           0 : bool EditEngine::HasTriedMergeOnLastAddUndo() const
     149             : {
     150           0 :     return pImpEditEngine->mbLastTryMerge;
     151             : }
     152             : 
     153       39407 : void EditEngine::SetRefDevice( OutputDevice* pRefDev )
     154             : {
     155       39407 :     pImpEditEngine->SetRefDevice( pRefDev );
     156       39407 : }
     157             : 
     158        3681 : OutputDevice* EditEngine::GetRefDevice() const
     159             : {
     160        3681 :     return pImpEditEngine->GetRefDevice();
     161             : }
     162             : 
     163       30660 : void EditEngine::SetRefMapMode( const MapMode& rMapMode )
     164             : {
     165       30660 :     pImpEditEngine->SetRefMapMode( rMapMode );
     166       30660 : }
     167             : 
     168         205 : MapMode EditEngine::GetRefMapMode()
     169             : {
     170         205 :     return pImpEditEngine->GetRefMapMode();
     171             : }
     172             : 
     173       58947 : void EditEngine::SetBackgroundColor( const Color& rColor )
     174             : {
     175       58947 :     pImpEditEngine->SetBackgroundColor( rColor );
     176       58947 : }
     177             : 
     178      141662 : Color EditEngine::GetBackgroundColor() const
     179             : {
     180      141662 :     return pImpEditEngine->GetBackgroundColor();
     181             : }
     182             : 
     183        3362 : Color EditEngine::GetAutoColor() const
     184             : {
     185        3362 :     return pImpEditEngine->GetAutoColor();
     186             : }
     187             : 
     188        6960 : void EditEngine::EnableAutoColor( bool b )
     189             : {
     190        6960 :     pImpEditEngine->EnableAutoColor( b );
     191        6960 : }
     192             : 
     193           9 : void EditEngine::ForceAutoColor( bool b )
     194             : {
     195           9 :     pImpEditEngine->ForceAutoColor( b );
     196           9 : }
     197             : 
     198         214 : bool EditEngine::IsForceAutoColor() const
     199             : {
     200         214 :     return pImpEditEngine->IsForceAutoColor();
     201             : }
     202             : 
     203       21097 : const SfxItemSet& EditEngine::GetEmptyItemSet()
     204             : {
     205       21097 :     return pImpEditEngine->GetEmptyItemSet();
     206             : }
     207             : 
     208           0 : void EditEngine::Draw( OutputDevice* pOutDev, const Rectangle& rOutRect )
     209             : {
     210           0 :     Draw( pOutDev, rOutRect, Point( 0, 0 ) );
     211           0 : }
     212             : 
     213        1211 : void EditEngine::Draw( OutputDevice* pOutDev, const Point& rStartPos, short nOrientation )
     214             : {
     215             :     // Create with 2 points, as with positive points it will end up with
     216             :     // LONGMAX as Size, Bottom and Right in the range > LONGMAX.
     217        1211 :     Rectangle aBigRect( -0x3FFFFFFF, -0x3FFFFFFF, 0x3FFFFFFF, 0x3FFFFFFF );
     218        1211 :     if( pOutDev->GetConnectMetaFile() )
     219           0 :         pOutDev->Push();
     220        1211 :     Point aStartPos( rStartPos );
     221        1211 :     if ( IsVertical() )
     222             :     {
     223           0 :         aStartPos.X() += GetPaperSize().Width();
     224           0 :         aStartPos = Rotate( aStartPos, nOrientation, rStartPos );
     225             :     }
     226        1211 :     pImpEditEngine->Paint( pOutDev, aBigRect, aStartPos, false, nOrientation );
     227        1211 :     if( pOutDev->GetConnectMetaFile() )
     228           0 :         pOutDev->Pop();
     229        1211 : }
     230             : 
     231           0 : void EditEngine::Draw( OutputDevice* pOutDev, const Rectangle& rOutRect, const Point& rStartDocPos )
     232             : {
     233           0 :     Draw( pOutDev, rOutRect, rStartDocPos, true );
     234           0 : }
     235             : 
     236         133 : void EditEngine::Draw( OutputDevice* pOutDev, const Rectangle& rOutRect, const Point& rStartDocPos, bool bClip )
     237             : {
     238             : #if defined( DBG_UTIL ) || (OSL_DEBUG_LEVEL > 1)
     239             :     if ( bDebugPaint )
     240             :         EditDbg::ShowEditEngineData( this, false );
     241             : #endif
     242             : 
     243             :     // Align to the pixel boundary, so that it becomes exactly the same
     244             :     // as Paint ()
     245         133 :     Rectangle aOutRect( pOutDev->LogicToPixel( rOutRect ) );
     246         133 :     aOutRect = pOutDev->PixelToLogic( aOutRect );
     247             : 
     248         133 :     Point aStartPos;
     249         133 :     if ( !IsVertical() )
     250             :     {
     251         133 :         aStartPos.X() = aOutRect.Left() - rStartDocPos.X();
     252         133 :         aStartPos.Y() = aOutRect.Top() - rStartDocPos.Y();
     253             :     }
     254             :     else
     255             :     {
     256           0 :         aStartPos.X() = aOutRect.Right() + rStartDocPos.Y();
     257           0 :         aStartPos.Y() = aOutRect.Top() - rStartDocPos.X();
     258             :     }
     259             : 
     260         133 :     bool bClipRegion = pOutDev->IsClipRegion();
     261         133 :     bool bMetafile = pOutDev->GetConnectMetaFile();
     262         133 :     vcl::Region aOldRegion = pOutDev->GetClipRegion();
     263             : 
     264             :     // If one existed => intersection!
     265             :     // Use Push/pop for creating the Meta file
     266         133 :     if ( bMetafile )
     267           0 :         pOutDev->Push();
     268             : 
     269             :     // Always use the Intersect method, it is a must for Metafile!
     270         133 :     if ( bClip )
     271             :     {
     272             :         // Clip only if necessary...
     273         532 :         if ( !rStartDocPos.X() && !rStartDocPos.Y() &&
     274         399 :              ( rOutRect.GetHeight() >= (long)GetTextHeight() ) &&
     275         133 :              ( rOutRect.GetWidth() >= (long)CalcTextWidth() ) )
     276             :         {
     277         133 :             bClip = false;
     278             :         }
     279             :         else
     280             :         {
     281             :             // Some printer drivers cause problems if characters graze the
     282             :             // ClipRegion, therefore rather add a pixel more ...
     283           0 :             Rectangle aClipRect( aOutRect );
     284           0 :             if ( pOutDev->GetOutDevType() == OUTDEV_PRINTER )
     285             :             {
     286           0 :                 Size aPixSz( 1, 0 );
     287           0 :                 aPixSz = pOutDev->PixelToLogic( aPixSz );
     288           0 :                 aClipRect.Right() += aPixSz.Width();
     289           0 :                 aClipRect.Bottom() += aPixSz.Width();
     290             :             }
     291           0 :             pOutDev->IntersectClipRegion( aClipRect );
     292             :         }
     293             :     }
     294             : 
     295         133 :     pImpEditEngine->Paint( pOutDev, aOutRect, aStartPos );
     296             : 
     297         133 :     if ( bMetafile )
     298           0 :         pOutDev->Pop();
     299         133 :     else if ( bClipRegion )
     300         133 :         pOutDev->SetClipRegion( aOldRegion );
     301             :     else
     302           0 :         pOutDev->SetClipRegion();
     303         133 : }
     304             : 
     305         379 : void EditEngine::InsertView(EditView* pEditView, size_t nIndex)
     306             : {
     307             : 
     308         379 :     if ( nIndex > pImpEditEngine->GetEditViews().size() )
     309         370 :         nIndex = pImpEditEngine->GetEditViews().size();
     310             : 
     311         379 :     ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
     312         379 :     rViews.insert(rViews.begin()+nIndex, pEditView);
     313             : 
     314         379 :     EditSelection aStartSel;
     315         379 :     aStartSel = pImpEditEngine->GetEditDoc().GetStartPaM();
     316         379 :     pEditView->pImpEditView->SetEditSelection( aStartSel );
     317         379 :     if ( !pImpEditEngine->GetActiveView() )
     318         375 :         pImpEditEngine->SetActiveView( pEditView );
     319             : 
     320         379 :     pEditView->pImpEditView->AddDragAndDropListeners();
     321         379 : }
     322             : 
     323          56 : EditView* EditEngine::RemoveView( EditView* pView )
     324             : {
     325             : 
     326          56 :     pView->HideCursor();
     327          56 :     EditView* pRemoved = NULL;
     328          56 :     ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
     329          56 :     ImpEditEngine::ViewsType::iterator it = std::find(rViews.begin(), rViews.end(), pView);
     330             : 
     331             :     DBG_ASSERT( it != rViews.end(), "RemoveView with invalid index" );
     332          56 :     if (it != rViews.end())
     333             :     {
     334          56 :         pRemoved = *it;
     335          56 :         rViews.erase(it);
     336          56 :         if ( pImpEditEngine->GetActiveView() == pView )
     337             :         {
     338          52 :             pImpEditEngine->SetActiveView( 0 );
     339          52 :             pImpEditEngine->GetSelEngine().SetCurView( 0 );
     340             :         }
     341          56 :         pView->pImpEditView->RemoveDragAndDropListeners();
     342             : 
     343             :     }
     344          56 :     return pRemoved;
     345             : }
     346             : 
     347          10 : EditView* EditEngine::RemoveView(size_t nIndex)
     348             : {
     349          10 :     ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
     350          10 :     if (nIndex >= rViews.size())
     351           0 :         return NULL;
     352             : 
     353          10 :     EditView* pView = rViews[nIndex];
     354          10 :     if ( pView )
     355          10 :         return RemoveView( pView );
     356           0 :     return NULL;
     357             : }
     358             : 
     359         134 : EditView* EditEngine::GetView(size_t nIndex) const
     360             : {
     361         134 :     return pImpEditEngine->GetEditViews()[nIndex];
     362             : }
     363             : 
     364         313 : size_t EditEngine::GetViewCount() const
     365             : {
     366         313 :     return pImpEditEngine->GetEditViews().size();
     367             : }
     368             : 
     369        2368 : bool EditEngine::HasView( EditView* pView ) const
     370             : {
     371        2368 :     ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
     372        2368 :     return std::find(rViews.begin(), rViews.end(), pView) != rViews.end();
     373             : }
     374             : 
     375        2187 : EditView* EditEngine::GetActiveView() const
     376             : {
     377        2187 :     return pImpEditEngine->GetActiveView();
     378             : }
     379             : 
     380           0 : void EditEngine::SetActiveView(EditView* pView)
     381             : {
     382           0 :     pImpEditEngine->SetActiveView(pView);
     383           0 : }
     384             : 
     385       39947 : void EditEngine::SetDefTab( sal_uInt16 nDefTab )
     386             : {
     387       39947 :     pImpEditEngine->GetEditDoc().SetDefTab( nDefTab );
     388       39947 :     if ( pImpEditEngine->IsFormatted() )
     389             :     {
     390       39911 :         pImpEditEngine->FormatFullDoc();
     391       39911 :         pImpEditEngine->UpdateViews( nullptr );
     392             :     }
     393       39947 : }
     394             : 
     395      597762 : void EditEngine::SetPaperSize( const Size& rNewSize )
     396             : {
     397             : 
     398      597762 :     Size aOldSize( pImpEditEngine->GetPaperSize() );
     399      597762 :     pImpEditEngine->SetValidPaperSize( rNewSize );
     400      597762 :     Size aNewSize( pImpEditEngine->GetPaperSize() );
     401             : 
     402      597762 :     bool bAutoPageSize = pImpEditEngine->GetStatus().AutoPageSize();
     403      597762 :     if ( bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() ) )
     404             :     {
     405      225197 :         for (size_t nView = 0; nView < pImpEditEngine->aEditViews.size(); ++nView)
     406             :         {
     407         326 :             EditView* pView = pImpEditEngine->aEditViews[nView];
     408         326 :             if ( bAutoPageSize )
     409           0 :                 pView->pImpEditView->RecalcOutputArea();
     410         326 :             else if ( pView->pImpEditView->DoAutoSize() )
     411             :             {
     412             :                 pView->pImpEditView->ResetOutputArea( Rectangle(
     413           0 :                     pView->pImpEditView->GetOutputArea().TopLeft(), aNewSize ) );
     414             :             }
     415             :         }
     416             : 
     417      224871 :         if ( bAutoPageSize || pImpEditEngine->IsFormatted() )
     418             :         {
     419             :             // Changing the width has no effect for AutoPageSize, as this is
     420             :             // determined by the text width.
     421             :             // Optimization first after Vobis delivery was enabled ...
     422       72273 :             pImpEditEngine->FormatFullDoc();
     423             : 
     424       72273 :             pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
     425             : 
     426       72273 :             if ( pImpEditEngine->GetUpdateMode() && pImpEditEngine->GetActiveView() )
     427         323 :                 pImpEditEngine->pActiveView->ShowCursor( false, false );
     428             :         }
     429             :     }
     430      597762 : }
     431             : 
     432       23510 : const Size& EditEngine::GetPaperSize() const
     433             : {
     434       23510 :     return pImpEditEngine->GetPaperSize();
     435             : }
     436             : 
     437       16739 : void EditEngine::SetVertical( bool bVertical )
     438             : {
     439       16739 :     pImpEditEngine->SetVertical( bVertical );
     440       16739 : }
     441             : 
     442      231270 : bool EditEngine::IsVertical() const
     443             : {
     444      231270 :     return pImpEditEngine->IsVertical();
     445             : }
     446             : 
     447      123334 : void EditEngine::SetFixedCellHeight( bool bUseFixedCellHeight )
     448             : {
     449      123334 :     pImpEditEngine->SetFixedCellHeight( bUseFixedCellHeight );
     450      123334 : }
     451             : 
     452       43658 : void EditEngine::SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir )
     453             : {
     454       43658 :     pImpEditEngine->SetDefaultHorizontalTextDirection( eHTextDir );
     455       43658 : }
     456             : 
     457       18572 : EEHorizontalTextDirection EditEngine::GetDefaultHorizontalTextDirection() const
     458             : {
     459       18572 :     return pImpEditEngine->GetDefaultHorizontalTextDirection();
     460             : }
     461             : 
     462        3576 : SvtScriptType EditEngine::GetScriptType( const ESelection& rSelection ) const
     463             : {
     464        3576 :     EditSelection aSel( pImpEditEngine->CreateSel( rSelection ) );
     465        3576 :     return pImpEditEngine->GetItemScriptType( aSel );
     466             : }
     467             : 
     468           0 : LanguageType EditEngine::GetLanguage(const EditPaM& rPaM) const
     469             : {
     470           0 :     return pImpEditEngine->GetLanguage(rPaM);
     471             : }
     472             : 
     473          56 : LanguageType EditEngine::GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const
     474             : {
     475          56 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
     476             :     DBG_ASSERT( pNode, "GetLanguage - nPara is invalid!" );
     477          56 :     return pNode ? pImpEditEngine->GetLanguage( EditPaM( pNode, nPos ) ) : LANGUAGE_DONTKNOW;
     478             : }
     479             : 
     480             : 
     481           0 : void EditEngine::TransliterateText( const ESelection& rSelection, sal_Int32 nTransliterationMode )
     482             : {
     483           0 :     pImpEditEngine->TransliterateText( pImpEditEngine->CreateSel( rSelection ), nTransliterationMode );
     484           0 : }
     485             : 
     486           0 : EditSelection EditEngine::TransliterateText(const EditSelection& rSelection, sal_Int32 nTransliterationMode)
     487             : {
     488           0 :     return pImpEditEngine->TransliterateText(rSelection, nTransliterationMode);
     489             : }
     490             : 
     491       68911 : void EditEngine::SetAsianCompressionMode( sal_uInt16 n )
     492             : {
     493       68911 :     pImpEditEngine->SetAsianCompressionMode( n );
     494       68911 : }
     495             : 
     496       68911 : void EditEngine::SetKernAsianPunctuation( bool b )
     497             : {
     498       68911 :     pImpEditEngine->SetKernAsianPunctuation( b );
     499       68911 : }
     500             : 
     501       67066 : void EditEngine::SetAddExtLeading( bool b )
     502             : {
     503       67066 :     pImpEditEngine->SetAddExtLeading( b );
     504       67066 : }
     505             : 
     506           0 : void EditEngine::SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon )
     507             : {
     508           0 :     SetPolygon( rPolyPolygon, 0L );
     509           0 : }
     510             : 
     511           0 : void EditEngine::SetPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DPolyPolygon* pLinePolyPolygon)
     512             : {
     513           0 :     bool bSimple(false);
     514             : 
     515           0 :     if(pLinePolyPolygon && 1L == rPolyPolygon.count())
     516             :     {
     517           0 :         if(rPolyPolygon.getB2DPolygon(0L).isClosed())
     518             :         {
     519             :             // open polygon
     520           0 :             bSimple = true;
     521             :         }
     522             :     }
     523             : 
     524           0 :     TextRanger* pRanger = new TextRanger( rPolyPolygon, pLinePolyPolygon, 30, 2, 2, bSimple, true );
     525           0 :     pImpEditEngine->SetTextRanger( pRanger );
     526           0 :     pImpEditEngine->SetPaperSize( pRanger->GetBoundRect().GetSize() );
     527           0 : }
     528             : 
     529      429767 : void EditEngine::ClearPolygon()
     530             : {
     531      429767 :     pImpEditEngine->SetTextRanger( 0 );
     532      429767 : }
     533             : 
     534           0 : const Size& EditEngine::GetMinAutoPaperSize() const
     535             : {
     536           0 :     return pImpEditEngine->GetMinAutoPaperSize();
     537             : }
     538             : 
     539      451745 : void EditEngine::SetMinAutoPaperSize( const Size& rSz )
     540             : {
     541      451745 :     pImpEditEngine->SetMinAutoPaperSize( rSz );
     542      451745 : }
     543             : 
     544           0 : const Size& EditEngine::GetMaxAutoPaperSize() const
     545             : {
     546           0 :     return pImpEditEngine->GetMaxAutoPaperSize();
     547             : }
     548             : 
     549      464661 : void EditEngine::SetMaxAutoPaperSize( const Size& rSz )
     550             : {
     551      464661 :     pImpEditEngine->SetMaxAutoPaperSize( rSz );
     552      464661 : }
     553             : 
     554        1303 : OUString EditEngine::GetText( LineEnd eEnd ) const
     555             : {
     556        1303 :     return pImpEditEngine->GetEditDoc().GetText( eEnd );
     557             : }
     558             : 
     559        4650 : OUString EditEngine::GetText( const ESelection& rESelection, const LineEnd eEnd ) const
     560             : {
     561        4650 :     EditSelection aSel( pImpEditEngine->CreateSel( rESelection ) );
     562        4650 :     return pImpEditEngine->GetSelected( aSel, eEnd );
     563             : }
     564             : 
     565          42 : sal_uInt32 EditEngine::GetTextLen() const
     566             : {
     567          42 :     return pImpEditEngine->GetEditDoc().GetTextLen();
     568             : }
     569             : 
     570      211009 : sal_Int32 EditEngine::GetParagraphCount() const
     571             : {
     572      211009 :     return pImpEditEngine->aEditDoc.Count();
     573             : }
     574             : 
     575           8 : sal_Int32 EditEngine::GetLineCount( sal_Int32 nParagraph ) const
     576             : {
     577           8 :     if ( !pImpEditEngine->IsFormatted() )
     578           0 :         pImpEditEngine->FormatDoc();
     579           8 :     return pImpEditEngine->GetLineCount( nParagraph );
     580             : }
     581             : 
     582           8 : sal_Int32 EditEngine::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const
     583             : {
     584           8 :     if ( !pImpEditEngine->IsFormatted() )
     585           0 :         pImpEditEngine->FormatDoc();
     586           8 :     return pImpEditEngine->GetLineLen( nParagraph, nLine );
     587             : }
     588             : 
     589           0 : void EditEngine::GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const
     590             : {
     591           0 :     if ( !pImpEditEngine->IsFormatted() )
     592           0 :         pImpEditEngine->FormatDoc();
     593           0 :     return pImpEditEngine->GetLineBoundaries( rStart, rEnd, nParagraph, nLine );
     594             : }
     595             : 
     596           0 : sal_Int32 EditEngine::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const
     597             : {
     598           0 :     if ( !pImpEditEngine->IsFormatted() )
     599           0 :         pImpEditEngine->FormatDoc();
     600           0 :     return pImpEditEngine->GetLineNumberAtIndex( nPara, nIndex );
     601             : }
     602             : 
     603           0 : sal_uInt32 EditEngine::GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine )
     604             : {
     605             :     // If someone calls GetLineHeight() with an empty Engine.
     606           0 :     if ( !pImpEditEngine->IsFormatted() )
     607           0 :         pImpEditEngine->FormatDoc();
     608           0 :     return pImpEditEngine->GetLineHeight( nParagraph, nLine );
     609             : }
     610             : 
     611         130 : sal_uInt32 EditEngine::GetTextHeight( sal_Int32 nParagraph ) const
     612             : {
     613             : 
     614         130 :     if ( !pImpEditEngine->IsFormatted() )
     615           0 :         pImpEditEngine->FormatDoc();
     616             : 
     617         130 :     sal_uInt32 nHeight = pImpEditEngine->GetParaHeight( nParagraph );
     618         130 :      return nHeight;
     619             : }
     620             : 
     621           0 : OUString EditEngine::GetWord( sal_Int32 nPara, sal_Int32 nIndex )
     622             : {
     623           0 :     ESelection aESel( nPara, nIndex, nPara, nIndex );
     624           0 :     EditSelection aSel( pImpEditEngine->CreateSel( aESel ) );
     625           0 :     aSel = pImpEditEngine->SelectWord( aSel );
     626           0 :     return pImpEditEngine->GetSelected( aSel );
     627             : }
     628             : 
     629           0 : ESelection EditEngine::GetWord( const ESelection& rSelection, sal_uInt16 nWordType  ) const
     630             : {
     631             :     // ImpEditEngine-Iteration-Methods should be const!
     632           0 :     EditEngine* pE = const_cast<EditEngine*>(this);
     633             : 
     634           0 :     EditSelection aSel( pE->pImpEditEngine->CreateSel( rSelection ) );
     635           0 :     aSel = pE->pImpEditEngine->SelectWord( aSel, nWordType );
     636           0 :     return pE->pImpEditEngine->CreateESel( aSel );
     637             : }
     638             : 
     639         216 : void EditEngine::CursorMoved(ContentNode* pPrevNode)
     640             : {
     641         216 :     pImpEditEngine->CursorMoved(pPrevNode);
     642         216 : }
     643             : 
     644        2943 : void EditEngine::CheckIdleFormatter()
     645             : {
     646        2943 :     pImpEditEngine->CheckIdleFormatter();
     647        2943 : }
     648             : 
     649           0 : bool EditEngine::IsIdleFormatterActive() const
     650             : {
     651           0 :     return pImpEditEngine->aIdleFormatter.IsActive();
     652             : }
     653             : 
     654         432 : ParaPortion* EditEngine::FindParaPortion(ContentNode* pNode)
     655             : {
     656         432 :     return pImpEditEngine->FindParaPortion(pNode);
     657             : }
     658             : 
     659           0 : const ParaPortion* EditEngine::FindParaPortion(ContentNode* pNode) const
     660             : {
     661           0 :     return pImpEditEngine->FindParaPortion(pNode);
     662             : }
     663             : 
     664           0 : const ParaPortion* EditEngine::GetPrevVisPortion(const ParaPortion* pCurPortion) const
     665             : {
     666           0 :     return pImpEditEngine->GetPrevVisPortion(pCurPortion);
     667             : }
     668             : 
     669           0 : SvtScriptType EditEngine::GetScriptType(const EditSelection& rSel) const
     670             : {
     671           0 :     return pImpEditEngine->GetItemScriptType(rSel);
     672             : }
     673             : 
     674           0 : void EditEngine::RemoveParaPortion(sal_Int32 nNode)
     675             : {
     676           0 :     pImpEditEngine->GetParaPortions().Remove(nNode);
     677           0 : }
     678             : 
     679           0 : void EditEngine::SetCallParaInsertedOrDeleted(bool b)
     680             : {
     681           0 :     pImpEditEngine->SetCallParaInsertedOrDeleted(b);
     682           0 : }
     683             : 
     684           0 : bool EditEngine::IsCallParaInsertedOrDeleted() const
     685             : {
     686           0 :     return pImpEditEngine->IsCallParaInsertedOrDeleted();
     687             : }
     688             : 
     689           0 : void EditEngine::AppendDeletedNodeInfo(DeletedNodeInfo* pInfo)
     690             : {
     691           0 :     pImpEditEngine->aDeletedNodes.push_back(pInfo);
     692           0 : }
     693             : 
     694           0 : void EditEngine::UpdateSelections()
     695             : {
     696           0 :     pImpEditEngine->UpdateSelections();
     697           0 : }
     698             : 
     699           0 : void EditEngine::InsertContent(ContentNode* pNode, sal_Int32 nPos)
     700             : {
     701           0 :     pImpEditEngine->InsertContent(pNode, nPos);
     702           0 : }
     703             : 
     704           0 : EditPaM EditEngine::SplitContent(sal_Int32 nNode, sal_Int32 nSepPos)
     705             : {
     706           0 :     return pImpEditEngine->SplitContent(nNode, nSepPos);
     707             : }
     708             : 
     709           0 : EditPaM EditEngine::ConnectContents(sal_Int32 nLeftNode, bool bBackward)
     710             : {
     711           0 :     return pImpEditEngine->ConnectContents(nLeftNode, bBackward);
     712             : }
     713             : 
     714           0 : EditPaM EditEngine::InsertFeature(const EditSelection& rEditSelection, const SfxPoolItem& rItem)
     715             : {
     716           0 :     return pImpEditEngine->ImpInsertFeature(rEditSelection, rItem);
     717             : }
     718             : 
     719           0 : EditSelection EditEngine::MoveParagraphs(const Range& rParagraphs, sal_Int32 nNewPos, EditView* pCurView)
     720             : {
     721           0 :     return pImpEditEngine->MoveParagraphs(rParagraphs, nNewPos, pCurView);
     722             : }
     723             : 
     724      142559 : void EditEngine::RemoveCharAttribs(sal_Int32 nPara, sal_uInt16 nWhich, bool bRemoveFeatures)
     725             : {
     726      142559 :     pImpEditEngine->RemoveCharAttribs(nPara, nWhich, bRemoveFeatures);
     727      142559 : }
     728             : 
     729           0 : void EditEngine::RemoveCharAttribs(const EditSelection& rSel, bool bRemoveParaAttribs, sal_uInt16 nWhich)
     730             : {
     731           0 :     pImpEditEngine->RemoveCharAttribs(rSel, bRemoveParaAttribs, nWhich);
     732           0 : }
     733             : 
     734           0 : EditEngine::ViewsType& EditEngine::GetEditViews()
     735             : {
     736           0 :     return pImpEditEngine->GetEditViews();
     737             : }
     738             : 
     739           0 : const EditEngine::ViewsType& EditEngine::GetEditViews() const
     740             : {
     741           0 :     return pImpEditEngine->GetEditViews();
     742             : }
     743             : 
     744           6 : void EditEngine::SetUndoMode(bool b)
     745             : {
     746           6 :     pImpEditEngine->SetUndoMode(b);
     747           6 : }
     748             : 
     749         200 : void EditEngine::FormatAndUpdate(EditView* pCurView)
     750             : {
     751         200 :     pImpEditEngine->FormatAndUpdate(pCurView);
     752         200 : }
     753             : 
     754           0 : bool EditEngine::Undo(EditView* pView)
     755             : {
     756           0 :     return pImpEditEngine->Undo(pView);
     757             : }
     758             : 
     759           0 : bool EditEngine::Redo(EditView* pView)
     760             : {
     761           0 :     return pImpEditEngine->Redo(pView);
     762             : }
     763             : 
     764           0 : uno::Reference<datatransfer::XTransferable> EditEngine::CreateTransferable(const EditSelection& rSelection)
     765             : {
     766           0 :     return pImpEditEngine->CreateTransferable(rSelection);
     767             : }
     768             : 
     769           0 : void EditEngine::ParaAttribsToCharAttribs(ContentNode* pNode)
     770             : {
     771           0 :     pImpEditEngine->ParaAttribsToCharAttribs(pNode);
     772           0 : }
     773             : 
     774           4 : EditPaM EditEngine::CreateEditPaM(const EPaM& rEPaM)
     775             : {
     776           4 :     return pImpEditEngine->CreateEditPaM(rEPaM);
     777             : }
     778             : 
     779           0 : EditPaM EditEngine::ConnectParagraphs(
     780             :         ContentNode* pLeft, ContentNode* pRight, bool bBackward)
     781             : {
     782           0 :     return pImpEditEngine->ImpConnectParagraphs(pLeft, pRight, bBackward);
     783             : }
     784             : 
     785           1 : EditPaM EditEngine::InsertField(const EditSelection& rEditSelection, const SvxFieldItem& rFld)
     786             : {
     787           1 :     return pImpEditEngine->InsertField(rEditSelection, rFld);
     788             : }
     789             : 
     790          31 : EditPaM EditEngine::InsertText(const EditSelection& aCurEditSelection, const OUString& rStr)
     791             : {
     792          31 :     return pImpEditEngine->InsertText(aCurEditSelection, rStr);
     793             : }
     794             : 
     795           0 : EditSelection EditEngine::InsertText(const EditTextObject& rTextObject, const EditSelection& rSel)
     796             : {
     797           0 :     return pImpEditEngine->InsertText(rTextObject, rSel);
     798             : }
     799             : 
     800           0 : EditSelection EditEngine::InsertText(
     801             :     uno::Reference<datatransfer::XTransferable >& rxDataObj,
     802             :     const OUString& rBaseURL, const EditPaM& rPaM, bool bUseSpecial)
     803             : {
     804           0 :     return pImpEditEngine->InsertText(rxDataObj, rBaseURL, rPaM, bUseSpecial);
     805             : }
     806             : 
     807           0 : EditPaM EditEngine::EndOfWord(const EditPaM& rPaM, sal_Int16 nWordType)
     808             : {
     809           0 :     return pImpEditEngine->EndOfWord(rPaM, nWordType);
     810             : }
     811             : 
     812           5 : EditPaM EditEngine::GetPaM(const Point& aDocPos, bool bSmart)
     813             : {
     814           5 :     return pImpEditEngine->GetPaM(aDocPos, bSmart);
     815             : }
     816             : 
     817           0 : EditSelection EditEngine::SelectWord(
     818             :         const EditSelection& rCurSelection, sal_Int16 nWordType, bool bAcceptStartOfWord)
     819             : {
     820           0 :     return pImpEditEngine->SelectWord(rCurSelection, nWordType, bAcceptStartOfWord);
     821             : }
     822             : 
     823          44 : long EditEngine::GetXPos(
     824             :         const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart) const
     825             : {
     826          44 :     return pImpEditEngine->GetXPos(pParaPortion, pLine, nIndex, bPreferPortionStart);
     827             : }
     828             : 
     829           9 : Range EditEngine::GetLineXPosStartEnd(
     830             :         const ParaPortion* pParaPortion, const EditLine* pLine) const
     831             : {
     832           9 :     return pImpEditEngine->GetLineXPosStartEnd(pParaPortion, pLine);
     833             : }
     834             : 
     835        2725 : bool EditEngine::IsFormatted() const
     836             : {
     837        2725 :     return pImpEditEngine->IsFormatted();
     838             : }
     839             : 
     840           0 : EditPaM EditEngine::CursorLeft(const EditPaM& rPaM, sal_uInt16 nCharacterIteratorMode)
     841             : {
     842           0 :     return pImpEditEngine->CursorLeft(rPaM, nCharacterIteratorMode);
     843             : }
     844             : 
     845           0 : EditPaM EditEngine::CursorRight(const EditPaM& rPaM, sal_uInt16 nCharacterIteratorMode)
     846             : {
     847           0 :     return pImpEditEngine->CursorRight(rPaM, nCharacterIteratorMode);
     848             : }
     849             : 
     850          52 : sal_uInt16 EditEngine::GetOnePixelInRef() const
     851             : {
     852          52 :     return pImpEditEngine->nOnePixelInRef;
     853             : }
     854             : 
     855          80 : InternalEditStatus& EditEngine::GetInternalEditStatus()
     856             : {
     857          80 :     return pImpEditEngine->GetStatus();
     858             : }
     859             : 
     860        4265 : EditDoc& EditEngine::GetEditDoc()
     861             : {
     862        4265 :     return pImpEditEngine->GetEditDoc();
     863             : }
     864             : 
     865           0 : const EditDoc& EditEngine::GetEditDoc() const
     866             : {
     867           0 :     return pImpEditEngine->GetEditDoc();
     868             : }
     869             : 
     870        2237 : ParaPortionList& EditEngine::GetParaPortions()
     871             : {
     872        2237 :     return pImpEditEngine->GetParaPortions();
     873             : }
     874             : 
     875           0 : const ParaPortionList& EditEngine::GetParaPortions() const
     876             : {
     877           0 :     return pImpEditEngine->GetParaPortions();
     878             : }
     879             : 
     880        2117 : void EditEngine::SeekCursor(
     881             :         ContentNode* pNode, sal_Int32 nPos, SvxFont& rFont, OutputDevice* pOut, sal_uInt16 nIgnoreWhich)
     882             : {
     883        2117 :     pImpEditEngine->SeekCursor(pNode, nPos, rFont, pOut, nIgnoreWhich);
     884        2117 : }
     885             : 
     886           2 : EditPaM EditEngine::DeleteSelection(const EditSelection& rSel)
     887             : {
     888           2 :     return pImpEditEngine->ImpDeleteSelection(rSel);
     889             : }
     890             : 
     891          55 : ESelection EditEngine::CreateESelection(const EditSelection& rSel)
     892             : {
     893          55 :     return pImpEditEngine->CreateESel(rSel);
     894             : }
     895             : 
     896           0 : EditSelection EditEngine::CreateSelection(const ESelection& rSel)
     897             : {
     898           0 :     return pImpEditEngine->CreateSel(rSel);
     899             : }
     900             : 
     901           0 : const SfxItemSet& EditEngine::GetBaseParaAttribs(sal_Int32 nPara) const
     902             : {
     903           0 :     return pImpEditEngine->GetParaAttribs(nPara);
     904             : }
     905             : 
     906           1 : void EditEngine::SetParaAttribsOnly(sal_Int32 nPara, const SfxItemSet& rSet)
     907             : {
     908           1 :     pImpEditEngine->SetParaAttribs(nPara, rSet);
     909           1 : }
     910             : 
     911         181 : void EditEngine::SetAttribs(const EditSelection& rSel, const SfxItemSet& rSet, sal_uInt8 nSpecial)
     912             : {
     913         181 :     pImpEditEngine->SetAttribs(rSel, rSet, nSpecial);
     914         181 : }
     915             : 
     916           0 : OUString EditEngine::GetSelected(const EditSelection& rSel, const LineEnd eParaSep) const
     917             : {
     918           0 :     return pImpEditEngine->GetSelected(rSel, eParaSep);
     919             : }
     920             : 
     921           0 : EditPaM EditEngine::DeleteSelected(const EditSelection& rSel)
     922             : {
     923           0 :     return pImpEditEngine->DeleteSelected(rSel);
     924             : }
     925             : 
     926           0 : void EditEngine::HandleBeginPasteOrDrop(PasteOrDropInfos& rInfos)
     927             : {
     928           0 :     pImpEditEngine->aBeginPasteOrDropHdl.Call(&rInfos);
     929           0 : }
     930             : 
     931           0 : void EditEngine::HandleEndPasteOrDrop(PasteOrDropInfos& rInfos)
     932             : {
     933           0 :     pImpEditEngine->aEndPasteOrDropHdl.Call(&rInfos);
     934           0 : }
     935             : 
     936           0 : bool EditEngine::HasText() const
     937             : {
     938           0 :     return pImpEditEngine->ImplHasText();
     939             : }
     940             : 
     941           1 : const EditSelectionEngine& EditEngine::GetSelectionEngine() const
     942             : {
     943           1 :     return pImpEditEngine->aSelEngine;
     944             : }
     945             : 
     946          53 : void EditEngine::SetInSelectionMode(bool b)
     947             : {
     948          53 :     pImpEditEngine->bInSelection = b;
     949          53 : }
     950             : 
     951           3 : bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, vcl::Window* pFrameWin )
     952             : {
     953             :     DBG_ASSERT( pEditView, "no View - no cookie !" );
     954             : 
     955           3 :     bool bDone = true;
     956             : 
     957           3 :     bool bModified  = false;
     958           3 :     bool bMoved     = false;
     959           3 :     bool bAllowIdle = true;
     960           3 :     bool bReadOnly  = pEditView->IsReadOnly();
     961             : 
     962           3 :     sal_uInt16 nNewCursorFlags = 0;
     963           3 :     bool bSetCursorFlags = true;
     964             : 
     965           3 :     EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() );
     966             :     DBG_ASSERT( !aCurSel.IsInvalid(), "Blinde Selection in EditEngine::PostKeyEvent" );
     967             : 
     968           3 :     OUString aAutoText( pImpEditEngine->GetAutoCompleteText() );
     969           3 :     if (!pImpEditEngine->GetAutoCompleteText().isEmpty())
     970           0 :         pImpEditEngine->SetAutoCompleteText(OUString(), true);
     971             : 
     972           3 :     sal_uInt16 nCode = rKeyEvent.GetKeyCode().GetCode();
     973           3 :     KeyFuncType eFunc = rKeyEvent.GetKeyCode().GetFunction();
     974           3 :     if ( eFunc != KeyFuncType::DONTKNOW )
     975             :     {
     976           0 :         switch ( eFunc )
     977             :         {
     978             :             case KeyFuncType::UNDO:
     979             :             {
     980           0 :                 if ( !bReadOnly )
     981           0 :                     pEditView->Undo();
     982           0 :                 return true;
     983             :             }
     984             :             case KeyFuncType::REDO:
     985             :             {
     986           0 :                 if ( !bReadOnly )
     987           0 :                     pEditView->Redo();
     988           0 :                 return true;
     989             :             }
     990             : 
     991             :             default:    // is then possible edited below.
     992           0 :                         eFunc = KeyFuncType::DONTKNOW;
     993             :         }
     994             :     }
     995             : 
     996           3 :     pImpEditEngine->EnterBlockNotifications();
     997             : 
     998           3 :     if ( GetNotifyHdl().IsSet() )
     999             :     {
    1000           0 :         EENotify aNotify( EE_NOTIFY_INPUT_START );
    1001           0 :         aNotify.pEditEngine = this;
    1002           0 :         pImpEditEngine->CallNotify( aNotify );
    1003             :     }
    1004             : 
    1005           3 :     if ( eFunc == KeyFuncType::DONTKNOW )
    1006             :     {
    1007           3 :         switch ( nCode )
    1008             :         {
    1009             :            #if defined( DBG_UTIL ) || (OSL_DEBUG_LEVEL > 1)
    1010             :             case KEY_F1:
    1011             :             {
    1012             :                 if ( rKeyEvent.GetKeyCode().IsMod1() && rKeyEvent.GetKeyCode().IsMod2() )
    1013             :                 {
    1014             :                     sal_Int32 nParas = GetParagraphCount();
    1015             :                     Point aPos;
    1016             :                     Point aViewStart( pEditView->GetOutputArea().TopLeft() );
    1017             :                     long n20 = 40 * pImpEditEngine->nOnePixelInRef;
    1018             :                     for ( sal_Int32 n = 0; n < nParas; n++ )
    1019             :                     {
    1020             :                         long nH = GetTextHeight( n );
    1021             :                         Point P1( aViewStart.X() + n20 + n20*(n%2), aViewStart.Y() + aPos.Y() );
    1022             :                         Point P2( P1 );
    1023             :                         P2.X() += n20;
    1024             :                         P2.Y() += nH;
    1025             :                         pEditView->GetWindow()->SetLineColor();
    1026             :                         pEditView->GetWindow()->SetFillColor( Color( (n%2) ? COL_YELLOW : COL_LIGHTGREEN ) );
    1027             :                         pEditView->GetWindow()->DrawRect( Rectangle( P1, P2 ) );
    1028             :                         aPos.Y() += nH;
    1029             :                     }
    1030             :                 }
    1031             :                 bDone = false;
    1032             :             }
    1033             :             break;
    1034             :             case KEY_F11:
    1035             :             {
    1036             :                 if ( rKeyEvent.GetKeyCode().IsMod1() && rKeyEvent.GetKeyCode().IsMod2() )
    1037             :                 {
    1038             :                     bDebugPaint = !bDebugPaint;
    1039             :                     OStringBuffer aInfo("DebugPaint: ");
    1040             :                     aInfo.append(bDebugPaint ? "On" : "Off");
    1041             :                     ScopedVclPtr<InfoBox>::Create(nullptr, OStringToOUString(aInfo.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US))->Execute();
    1042             :                 }
    1043             :                 bDone = false;
    1044             :             }
    1045             :             break;
    1046             :             case KEY_F12:
    1047             :             {
    1048             :                 if ( rKeyEvent.GetKeyCode().IsMod1() && rKeyEvent.GetKeyCode().IsMod2() )
    1049             :                 {
    1050             :                     EditDbg::ShowEditEngineData( this );
    1051             :                 }
    1052             :                 bDone = false;
    1053             :             }
    1054             :             break;
    1055             :            #endif
    1056             :             case KEY_UP:
    1057             :             case KEY_DOWN:
    1058             :             case KEY_LEFT:
    1059             :             case KEY_RIGHT:
    1060             :             case KEY_HOME:
    1061             :             case KEY_END:
    1062             :             case KEY_PAGEUP:
    1063             :             case KEY_PAGEDOWN:
    1064             :             case com::sun::star::awt::Key::MOVE_WORD_FORWARD:
    1065             :             case com::sun::star::awt::Key::SELECT_WORD_FORWARD:
    1066             :             case com::sun::star::awt::Key::MOVE_WORD_BACKWARD:
    1067             :             case com::sun::star::awt::Key::SELECT_WORD_BACKWARD:
    1068             :             case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_LINE:
    1069             :             case com::sun::star::awt::Key::MOVE_TO_END_OF_LINE:
    1070             :             case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_LINE:
    1071             :             case com::sun::star::awt::Key::SELECT_TO_END_OF_LINE:
    1072             :             case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
    1073             :             case com::sun::star::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
    1074             :             case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
    1075             :             case com::sun::star::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
    1076             :             case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
    1077             :             case com::sun::star::awt::Key::MOVE_TO_END_OF_DOCUMENT:
    1078             :             case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
    1079             :             case com::sun::star::awt::Key::SELECT_TO_END_OF_DOCUMENT:
    1080             :             {
    1081           0 :                 if ( !rKeyEvent.GetKeyCode().IsMod2() || ( nCode == KEY_LEFT ) || ( nCode == KEY_RIGHT ) )
    1082             :                 {
    1083           0 :                     if ( pImpEditEngine->DoVisualCursorTraveling( aCurSel.Max().GetNode() ) && ( ( nCode == KEY_LEFT ) || ( nCode == KEY_RIGHT ) /* || ( nCode == KEY_HOME ) || ( nCode == KEY_END ) */ ) )
    1084           0 :                         bSetCursorFlags = false;    // Will be manipulated within visual cursor move
    1085             : 
    1086           0 :                     aCurSel = pImpEditEngine->MoveCursor( rKeyEvent, pEditView );
    1087             : 
    1088           0 :                     if ( aCurSel.HasRange() ) {
    1089           0 :                         Reference<com::sun::star::datatransfer::clipboard::XClipboard> aSelection(pEditView->GetWindow()->GetPrimarySelection());
    1090           0 :                         pEditView->pImpEditView->CutCopy( aSelection, false );
    1091             :                     }
    1092             : 
    1093           0 :                     bMoved = true;
    1094           0 :                     if ( nCode == KEY_HOME )
    1095           0 :                         nNewCursorFlags |= GETCRSR_STARTOFLINE;
    1096           0 :                     else if ( nCode == KEY_END )
    1097           0 :                         nNewCursorFlags |= GETCRSR_ENDOFLINE;
    1098             : 
    1099             :                 }
    1100             : #if OSL_DEBUG_LEVEL > 1
    1101             :                 GetLanguage( pImpEditEngine->GetEditDoc().GetPos( aCurSel.Max().GetNode() ), aCurSel.Max().GetIndex() );
    1102             : #endif
    1103             :             }
    1104           0 :             break;
    1105             :             case KEY_BACKSPACE:
    1106             :             case KEY_DELETE:
    1107             :             case com::sun::star::awt::Key::DELETE_WORD_BACKWARD:
    1108             :             case com::sun::star::awt::Key::DELETE_WORD_FORWARD:
    1109             :             case com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_PARAGRAPH:
    1110             :             case com::sun::star::awt::Key::DELETE_TO_END_OF_PARAGRAPH:
    1111             :             {
    1112           0 :                 if ( !bReadOnly && !rKeyEvent.GetKeyCode().IsMod2() )
    1113             :                 {
    1114             :                     // check if we are behind a bullet and using the backspace key
    1115           0 :                     ContentNode *pNode = aCurSel.Min().GetNode();
    1116           0 :                     const SvxNumberFormat *pFmt = pImpEditEngine->GetNumberFormat( pNode );
    1117           0 :                     if (pFmt && nCode == KEY_BACKSPACE &&
    1118           0 :                         !aCurSel.HasRange() && aCurSel.Min().GetIndex() == 0)
    1119             :                     {
    1120             :                         // if the bullet is still visible just do not paint it from
    1121             :                         // now on and that will be all. Otherwise continue as usual.
    1122             : 
    1123             : 
    1124           0 :                         sal_Int32 nPara = pImpEditEngine->GetEditDoc().GetPos( pNode );
    1125           0 :                         SfxBoolItem aBulletState( static_cast<const SfxBoolItem&>( pImpEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE ) ) );
    1126           0 :                         bool bBulletIsVisible = aBulletState.GetValue();
    1127             : 
    1128             :                         // just toggling EE_PARA_BULLETSTATE should be fine for both cases...
    1129           0 :                         aBulletState.SetValue( !bBulletIsVisible );
    1130           0 :                         SfxItemSet aSet( pImpEditEngine->GetParaAttribs( nPara ) );
    1131           0 :                         aSet.Put( aBulletState );
    1132           0 :                         pImpEditEngine->SetParaAttribs( nPara, aSet );
    1133             : 
    1134             :                         // have this and the following paragraphs formatted and repainted.
    1135             :                         // (not painting a numbering in the list may cause the following
    1136             :                         // numberings to have different numbers than before and thus the
    1137             :                         // length may have changed as well )
    1138           0 :                         pImpEditEngine->FormatAndUpdate( pImpEditEngine->GetActiveView() );
    1139             : 
    1140           0 :                         if (bBulletIsVisible)   // bullet just turned invisible...
    1141           0 :                             break;
    1142             :                     }
    1143             : 
    1144           0 :                     sal_uInt8 nDel = 0, nMode = 0;
    1145           0 :                     switch( nCode )
    1146             :                     {
    1147             :                     case com::sun::star::awt::Key::DELETE_WORD_BACKWARD:
    1148           0 :                         nMode = DELMODE_RESTOFWORD;
    1149           0 :                         nDel = DEL_LEFT;
    1150           0 :                         break;
    1151             :                     case com::sun::star::awt::Key::DELETE_WORD_FORWARD:
    1152           0 :                         nMode = DELMODE_RESTOFWORD;
    1153           0 :                         nDel = DEL_RIGHT;
    1154           0 :                         break;
    1155             :                     case com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_PARAGRAPH:
    1156           0 :                         nMode = DELMODE_RESTOFCONTENT;
    1157           0 :                         nDel = DEL_LEFT;
    1158           0 :                         break;
    1159             :                     case com::sun::star::awt::Key::DELETE_TO_END_OF_PARAGRAPH:
    1160           0 :                         nMode = DELMODE_RESTOFCONTENT;
    1161           0 :                         nDel = DEL_RIGHT;
    1162           0 :                         break;
    1163             :                     default:
    1164           0 :                         nDel = ( nCode == KEY_DELETE ) ? DEL_RIGHT : DEL_LEFT;
    1165           0 :                         nMode = rKeyEvent.GetKeyCode().IsMod1() ? DELMODE_RESTOFWORD : DELMODE_SIMPLE;
    1166           0 :                         if ( ( nMode == DELMODE_RESTOFWORD ) && rKeyEvent.GetKeyCode().IsShift() )
    1167           0 :                             nMode = DELMODE_RESTOFCONTENT;
    1168           0 :                         break;
    1169             :                     }
    1170             : 
    1171           0 :                     pEditView->pImpEditView->DrawSelection();
    1172           0 :                     pImpEditEngine->UndoActionStart( EDITUNDO_DELETE );
    1173           0 :                     aCurSel = pImpEditEngine->DeleteLeftOrRight( aCurSel, nDel, nMode );
    1174           0 :                     pImpEditEngine->UndoActionEnd( EDITUNDO_DELETE );
    1175           0 :                     bModified = true;
    1176           0 :                     bAllowIdle = false;
    1177             :                 }
    1178             :             }
    1179           0 :             break;
    1180             :             case KEY_TAB:
    1181             :             {
    1182           0 :                 if ( !bReadOnly && !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
    1183             :                 {
    1184           0 :                     bool bShift = rKeyEvent.GetKeyCode().IsShift();
    1185           0 :                     if ( pImpEditEngine->GetStatus().DoTabIndenting() &&
    1186           0 :                         ( aCurSel.Min().GetNode() != aCurSel.Max().GetNode() ) )
    1187             :                     {
    1188           0 :                         pImpEditEngine->IndentBlock( pEditView, !bShift );
    1189             :                     }
    1190           0 :                     else if ( !bShift )
    1191             :                     {
    1192           0 :                         bool bSel = pEditView->HasSelection();
    1193           0 :                         if ( bSel )
    1194           0 :                             pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
    1195           0 :                         if ( pImpEditEngine->GetStatus().DoAutoCorrect() )
    1196           0 :                             aCurSel = pImpEditEngine->AutoCorrect( aCurSel, 0, !pEditView->IsInsertMode(), pFrameWin );
    1197           0 :                         aCurSel = pImpEditEngine->InsertTab( aCurSel );
    1198           0 :                         if ( bSel )
    1199           0 :                             pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
    1200           0 :                         bModified = true;
    1201             :                     }
    1202             :                 }
    1203             :                 else
    1204           0 :                     bDone = false;
    1205             :             }
    1206           0 :             break;
    1207             :             case KEY_RETURN:
    1208             :             {
    1209           0 :                 if ( !bReadOnly )
    1210             :                 {
    1211           0 :                     pEditView->pImpEditView->DrawSelection();
    1212           0 :                     if ( !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
    1213             :                     {
    1214           0 :                         pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
    1215           0 :                         if ( rKeyEvent.GetKeyCode().IsShift() )
    1216             :                         {
    1217           0 :                             aCurSel = pImpEditEngine->AutoCorrect( aCurSel, 0, !pEditView->IsInsertMode(), pFrameWin );
    1218           0 :                             aCurSel = pImpEditEngine->InsertLineBreak( aCurSel );
    1219             :                         }
    1220             :                         else
    1221             :                         {
    1222           0 :                             if (aAutoText.isEmpty())
    1223             :                             {
    1224           0 :                                 if ( pImpEditEngine->GetStatus().DoAutoCorrect() )
    1225           0 :                                     aCurSel = pImpEditEngine->AutoCorrect( aCurSel, 0, !pEditView->IsInsertMode(), pFrameWin );
    1226           0 :                                 aCurSel = pImpEditEngine->InsertParaBreak( aCurSel );
    1227             :                             }
    1228             :                             else
    1229             :                             {
    1230             :                                 DBG_ASSERT( !aCurSel.HasRange(), "Selektion bei Complete?!" );
    1231           0 :                                 EditPaM aStart( pImpEditEngine->WordLeft( aCurSel.Max() ) );
    1232           0 :                                 aCurSel = pImpEditEngine->InsertText(
    1233           0 :                                                 EditSelection( aStart, aCurSel.Max() ), aAutoText );
    1234           0 :                                 pImpEditEngine->SetAutoCompleteText( OUString(), true );
    1235             :                             }
    1236             :                         }
    1237           0 :                         pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
    1238           0 :                         bModified = true;
    1239             :                     }
    1240             :                 }
    1241             :             }
    1242           0 :             break;
    1243             :             case KEY_INSERT:
    1244             :             {
    1245           0 :                 if ( !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
    1246           0 :                     pEditView->SetInsertMode( !pEditView->IsInsertMode() );
    1247             :             }
    1248           0 :             break;
    1249             :             default:
    1250             :             {
    1251             :                 #if (OSL_DEBUG_LEVEL > 1) && defined(DBG_UTIL)
    1252             :                     if ( ( nCode == KEY_W ) && rKeyEvent.GetKeyCode().IsMod1() && rKeyEvent.GetKeyCode().IsMod2() )
    1253             :                     {
    1254             :                         SfxItemSet aAttribs = pEditView->GetAttribs();
    1255             :                         const SvxFrameDirectionItem& rCurrentWritingMode = (const SvxFrameDirectionItem&)aAttribs.Get( EE_PARA_WRITINGDIR );
    1256             :                         SvxFrameDirectionItem aNewItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR );
    1257             :                         if ( rCurrentWritingMode.GetValue() != FRMDIR_HORI_RIGHT_TOP )
    1258             :                             aNewItem.SetValue( FRMDIR_HORI_RIGHT_TOP );
    1259             :                         aAttribs.Put( aNewItem );
    1260             :                         pEditView->SetAttribs( aAttribs );
    1261             :                     }
    1262             :                 #endif
    1263           3 :                 if ( !bReadOnly && IsSimpleCharInput( rKeyEvent ) )
    1264             :                 {
    1265           3 :                     sal_Unicode nCharCode = rKeyEvent.GetCharCode();
    1266           3 :                     pEditView->pImpEditView->DrawSelection();
    1267             :                     // Autocorrection?
    1268           3 :                     SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
    1269           6 :                     if ( ( pImpEditEngine->GetStatus().DoAutoCorrect() ) &&
    1270           6 :                         ( SvxAutoCorrect::IsAutoCorrectChar( nCharCode ) ||
    1271           3 :                           pAutoCorrect->HasRunNext() ) )
    1272             :                     {
    1273           0 :                         aCurSel = pImpEditEngine->AutoCorrect(
    1274           0 :                             aCurSel, nCharCode, !pEditView->IsInsertMode(), pFrameWin );
    1275             :                     }
    1276             :                     else
    1277             :                     {
    1278           3 :                         aCurSel = pImpEditEngine->InsertText( (const EditSelection&)aCurSel, nCharCode, !pEditView->IsInsertMode(), true );
    1279             :                     }
    1280             :                     // AutoComplete ???
    1281           3 :                     if ( pImpEditEngine->GetStatus().DoAutoComplete() && ( nCharCode != ' ' ) )
    1282             :                     {
    1283             :                         // Only at end of word...
    1284           0 :                         sal_Int32 nIndex = aCurSel.Max().GetIndex();
    1285           0 :                         if ( ( nIndex >= aCurSel.Max().GetNode()->Len() ) ||
    1286           0 :                              ( pImpEditEngine->aWordDelimiters.indexOf( aCurSel.Max().GetNode()->GetChar( nIndex ) ) != -1 ) )
    1287             :                         {
    1288           0 :                             EditPaM aStart( pImpEditEngine->WordLeft( aCurSel.Max() ) );
    1289           0 :                             OUString aWord = pImpEditEngine->GetSelected( EditSelection( aStart, aCurSel.Max() ) );
    1290           0 :                             if ( aWord.getLength() >= 3 )
    1291             :                             {
    1292           0 :                                 OUString aComplete;
    1293             : 
    1294           0 :                                 LanguageType eLang = pImpEditEngine->GetLanguage( EditPaM( aStart.GetNode(), aStart.GetIndex()+1));
    1295           0 :                                 LanguageTag aLanguageTag( eLang);
    1296             : 
    1297           0 :                                 if (!pImpEditEngine->xLocaleDataWrapper.isInitialized())
    1298           0 :                                     pImpEditEngine->xLocaleDataWrapper.init( SvtSysLocale().GetLocaleData().getComponentContext(), aLanguageTag);
    1299             :                                 else
    1300           0 :                                     pImpEditEngine->xLocaleDataWrapper.changeLocale( aLanguageTag);
    1301             : 
    1302           0 :                                 if (!pImpEditEngine->xTransliterationWrapper.isInitialized())
    1303           0 :                                     pImpEditEngine->xTransliterationWrapper.init( SvtSysLocale().GetLocaleData().getComponentContext(), eLang, i18n::TransliterationModules_IGNORE_CASE);
    1304             :                                 else
    1305           0 :                                     pImpEditEngine->xTransliterationWrapper.changeLocale( eLang);
    1306             : 
    1307           0 :                                 const ::utl::TransliterationWrapper* pTransliteration = pImpEditEngine->xTransliterationWrapper.get();
    1308           0 :                                 Sequence< i18n::CalendarItem2 > xItem = pImpEditEngine->xLocaleDataWrapper->getDefaultCalendarDays();
    1309           0 :                                 sal_Int32 nCount = xItem.getLength();
    1310           0 :                                 const i18n::CalendarItem2* pArr = xItem.getArray();
    1311           0 :                                 for( sal_Int32 n = 0; n <= nCount; ++n )
    1312             :                                 {
    1313           0 :                                     const OUString& rDay = pArr[n].FullName;
    1314           0 :                                     if( pTransliteration->isMatch( aWord, rDay) )
    1315             :                                     {
    1316           0 :                                         aComplete = rDay;
    1317           0 :                                         break;
    1318             :                                     }
    1319             :                                 }
    1320             : 
    1321           0 :                                 if ( aComplete.isEmpty() )
    1322             :                                 {
    1323           0 :                                     xItem = pImpEditEngine->xLocaleDataWrapper->getDefaultCalendarMonths();
    1324           0 :                                     sal_Int32 nMonthCount = xItem.getLength();
    1325           0 :                                     const i18n::CalendarItem2* pMonthArr = xItem.getArray();
    1326           0 :                                     for( sal_Int32 n = 0; n <= nMonthCount; ++n )
    1327             :                                     {
    1328           0 :                                         const OUString& rMon = pMonthArr[n].FullName;
    1329           0 :                                         if( pTransliteration->isMatch( aWord, rMon) )
    1330             :                                         {
    1331           0 :                                             aComplete = rMon;
    1332           0 :                                             break;
    1333             :                                         }
    1334             :                                     }
    1335             :                                 }
    1336             : 
    1337           0 :                                 if( !aComplete.isEmpty() && ( ( aWord.getLength() + 1 ) < aComplete.getLength() ) )
    1338             :                                 {
    1339           0 :                                     pImpEditEngine->SetAutoCompleteText( aComplete, false );
    1340           0 :                                     Point aPos = pImpEditEngine->PaMtoEditCursor( aCurSel.Max() ).TopLeft();
    1341           0 :                                     aPos = pEditView->pImpEditView->GetWindowPos( aPos );
    1342           0 :                                     aPos = pEditView->pImpEditView->GetWindow()->LogicToPixel( aPos );
    1343           0 :                                     aPos = pEditView->GetWindow()->OutputToScreenPixel( aPos );
    1344           0 :                                     aPos.Y() -= 3;
    1345           0 :                                     Help::ShowQuickHelp( pEditView->GetWindow(), Rectangle( aPos, Size( 1, 1 ) ), aComplete, QuickHelpFlags::Bottom|QuickHelpFlags::Left );
    1346           0 :                                 }
    1347           0 :                             }
    1348             :                         }
    1349             :                     }
    1350           3 :                     bModified = true;
    1351             :                 }
    1352             :                 else
    1353           0 :                     bDone = false;
    1354             :             }
    1355             :         }
    1356             :     }
    1357             : 
    1358           3 :     pEditView->pImpEditView->SetEditSelection( aCurSel );
    1359           3 :     pImpEditEngine->UpdateSelections();
    1360             : 
    1361           6 :     if ( ( !IsVertical() && ( nCode != KEY_UP ) && ( nCode != KEY_DOWN ) ) ||
    1362           0 :          ( IsVertical() && ( nCode != KEY_LEFT ) && ( nCode != KEY_RIGHT ) ))
    1363             :     {
    1364           3 :         pEditView->pImpEditView->nTravelXPos = TRAVEL_X_DONTKNOW;
    1365             :     }
    1366             : 
    1367           3 :     if ( /* ( nCode != KEY_HOME ) && ( nCode != KEY_END ) && */
    1368           6 :         ( !IsVertical() && ( nCode != KEY_LEFT ) && ( nCode != KEY_RIGHT ) ) ||
    1369           0 :          ( IsVertical() && ( nCode != KEY_UP ) && ( nCode != KEY_DOWN ) ))
    1370             :     {
    1371           3 :         pEditView->pImpEditView->SetCursorBidiLevel( CURSOR_BIDILEVEL_DONTKNOW );
    1372             :     }
    1373             : 
    1374           3 :     if ( bSetCursorFlags )
    1375           3 :         pEditView->pImpEditView->nExtraCursorFlags = nNewCursorFlags;
    1376             : 
    1377           3 :     if ( bModified )
    1378             :     {
    1379             :         DBG_ASSERT( !bReadOnly, "ReadOnly but modified???" );
    1380             :         // Idle-Formatter only when AnyInput.
    1381           6 :         if ( bAllowIdle && pImpEditEngine->GetStatus().UseIdleFormatter()
    1382           6 :                 && Application::AnyInput( VclInputFlags::KEYBOARD) )
    1383           0 :             pImpEditEngine->IdleFormatAndUpdate( pEditView );
    1384             :         else
    1385           3 :             pImpEditEngine->FormatAndUpdate( pEditView );
    1386             :     }
    1387           0 :     else if ( bMoved )
    1388             :     {
    1389           0 :         bool bGotoCursor = pEditView->pImpEditView->DoAutoScroll();
    1390           0 :         pEditView->pImpEditView->ShowCursor( bGotoCursor, true );
    1391           0 :         pImpEditEngine->CallStatusHdl();
    1392             :     }
    1393             : 
    1394           3 :     if ( GetNotifyHdl().IsSet() )
    1395             :     {
    1396           0 :         EENotify aNotify( EE_NOTIFY_INPUT_END );
    1397           0 :         aNotify.pEditEngine = this;
    1398           0 :         pImpEditEngine->CallNotify( aNotify );
    1399             :     }
    1400             : 
    1401           3 :     pImpEditEngine->LeaveBlockNotifications();
    1402             : 
    1403           3 :     return bDone;
    1404             : }
    1405             : 
    1406      145128 : sal_uInt32 EditEngine::GetTextHeight() const
    1407             : {
    1408             : 
    1409      145128 :     if ( !pImpEditEngine->IsFormatted() )
    1410           7 :         pImpEditEngine->FormatDoc();
    1411             : 
    1412      145128 :     sal_uInt32 nHeight = !IsVertical() ? pImpEditEngine->GetTextHeight() : pImpEditEngine->CalcTextWidth( true );
    1413      145128 :     return nHeight;
    1414             : }
    1415             : 
    1416         148 : sal_uInt32 EditEngine::GetTextHeightNTP() const
    1417             : {
    1418             : 
    1419         148 :     if ( !pImpEditEngine->IsFormatted() )
    1420           2 :         pImpEditEngine->FormatDoc();
    1421             : 
    1422         148 :     if ( IsVertical() )
    1423           0 :         return pImpEditEngine->CalcTextWidth( true );
    1424             : 
    1425         148 :     return pImpEditEngine->GetTextHeightNTP();
    1426             : }
    1427             : 
    1428       61620 : sal_uInt32 EditEngine::CalcTextWidth()
    1429             : {
    1430             : 
    1431       61620 :     if ( !pImpEditEngine->IsFormatted() )
    1432           2 :         pImpEditEngine->FormatDoc();
    1433             : 
    1434       61620 :     sal_uInt32 nWidth = !IsVertical() ? pImpEditEngine->CalcTextWidth( true ) : pImpEditEngine->GetTextHeight();
    1435       61620 :      return nWidth;
    1436             : }
    1437             : 
    1438     2560429 : void EditEngine::SetUpdateMode( bool bUpdate )
    1439             : {
    1440     2560429 :     pImpEditEngine->SetUpdateMode( bUpdate );
    1441     2560429 :     if ( pImpEditEngine->pActiveView )
    1442         892 :         pImpEditEngine->pActiveView->ShowCursor( false, false );
    1443     2560429 : }
    1444             : 
    1445      995645 : bool EditEngine::GetUpdateMode() const
    1446             : {
    1447      995645 :     return pImpEditEngine->GetUpdateMode();
    1448             : }
    1449             : 
    1450      217859 : void EditEngine::Clear()
    1451             : {
    1452      217859 :     pImpEditEngine->Clear();
    1453      217859 : }
    1454             : 
    1455       13977 : void EditEngine::SetText( const OUString& rText )
    1456             : {
    1457       13977 :     pImpEditEngine->SetText( rText );
    1458       13977 :     if ( !rText.isEmpty() )
    1459        5503 :         pImpEditEngine->FormatAndUpdate();
    1460       13977 : }
    1461             : 
    1462           1 : sal_uLong EditEngine::Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs /* = NULL */ )
    1463             : {
    1464           1 :     bool bUndoEnabled = pImpEditEngine->IsUndoEnabled();
    1465           1 :     pImpEditEngine->EnableUndo( false );
    1466           1 :     pImpEditEngine->SetText( OUString() );
    1467           1 :     EditPaM aPaM( pImpEditEngine->GetEditDoc().GetStartPaM() );
    1468           1 :     pImpEditEngine->Read( rInput, rBaseURL, eFormat, EditSelection( aPaM, aPaM ), pHTTPHeaderAttrs );
    1469           1 :     pImpEditEngine->EnableUndo( bUndoEnabled );
    1470           1 :     return rInput.GetError();
    1471             : }
    1472             : 
    1473           0 : sal_uLong EditEngine::Write( SvStream& rOutput, EETextFormat eFormat )
    1474             : {
    1475           0 :     EditPaM aStartPaM( pImpEditEngine->GetEditDoc().GetStartPaM() );
    1476           0 :     EditPaM aEndPaM( pImpEditEngine->GetEditDoc().GetEndPaM() );
    1477           0 :     pImpEditEngine->Write( rOutput, eFormat, EditSelection( aStartPaM, aEndPaM ) );
    1478           0 :     return rOutput.GetError();
    1479             : }
    1480             : 
    1481       15248 : EditTextObject* EditEngine::CreateTextObject()
    1482             : {
    1483       15248 :     return pImpEditEngine->CreateTextObject();
    1484             : }
    1485             : 
    1486           0 : EditTextObject* EditEngine::CreateTextObject( const ESelection& rESelection )
    1487             : {
    1488           0 :     EditSelection aSel( pImpEditEngine->CreateSel( rESelection ) );
    1489           0 :     return pImpEditEngine->CreateTextObject( aSel );
    1490             : }
    1491             : 
    1492      213458 : void EditEngine::SetText( const EditTextObject& rTextObject )
    1493             : {
    1494      213458 :     pImpEditEngine->EnterBlockNotifications();
    1495      213458 :     pImpEditEngine->SetText( rTextObject );
    1496      213458 :     pImpEditEngine->FormatAndUpdate();
    1497      213458 :     pImpEditEngine->LeaveBlockNotifications();
    1498      213458 : }
    1499             : 
    1500           0 : void EditEngine::ShowParagraph( sal_Int32 nParagraph, bool bShow )
    1501             : {
    1502           0 :     pImpEditEngine->ShowParagraph( nParagraph, bShow );
    1503           0 : }
    1504             : 
    1505        9444 : void EditEngine::SetNotifyHdl( const Link<>& rLink )
    1506             : {
    1507        9444 :     pImpEditEngine->SetNotifyHdl( rLink );
    1508        9444 : }
    1509             : 
    1510     1237262 : Link<> EditEngine::GetNotifyHdl() const
    1511             : {
    1512     1237262 :     return pImpEditEngine->GetNotifyHdl();
    1513             : }
    1514             : 
    1515        1229 : void EditEngine::SetStatusEventHdl( const Link<>& rLink )
    1516             : {
    1517        1229 :     pImpEditEngine->SetStatusEventHdl( rLink );
    1518        1229 : }
    1519             : 
    1520         229 : Link<> EditEngine::GetStatusEventHdl() const
    1521             : {
    1522         229 :     return pImpEditEngine->GetStatusEventHdl();
    1523             : }
    1524             : 
    1525           2 : void EditEngine::SetImportHdl( const Link<>& rLink )
    1526             : {
    1527           2 :     pImpEditEngine->aImportHdl = rLink;
    1528           2 : }
    1529             : 
    1530           1 : Link<> EditEngine::GetImportHdl() const
    1531             : {
    1532           1 :     return pImpEditEngine->aImportHdl;
    1533             : }
    1534             : 
    1535       30948 : void EditEngine::SetBeginMovingParagraphsHdl( const Link<>& rLink )
    1536             : {
    1537       30948 :     pImpEditEngine->aBeginMovingParagraphsHdl = rLink;
    1538       30948 : }
    1539             : 
    1540       30948 : void EditEngine::SetEndMovingParagraphsHdl( const Link<>& rLink )
    1541             : {
    1542       30948 :     pImpEditEngine->aEndMovingParagraphsHdl = rLink;
    1543       30948 : }
    1544             : 
    1545       30948 : void EditEngine::SetBeginPasteOrDropHdl( const Link<>& rLink )
    1546             : {
    1547             : 
    1548       30948 :     pImpEditEngine->aBeginPasteOrDropHdl = rLink;
    1549       30948 : }
    1550             : 
    1551       30948 : void EditEngine::SetEndPasteOrDropHdl( const Link<>& rLink )
    1552             : {
    1553       30948 :     pImpEditEngine->aEndPasteOrDropHdl = rLink;
    1554       30948 : }
    1555             : 
    1556      111087 : EditTextObject* EditEngine::CreateTextObject( sal_Int32 nPara, sal_Int32 nParas )
    1557             : {
    1558             :     DBG_ASSERT( 0 <= nPara && nPara < pImpEditEngine->GetEditDoc().Count(), "CreateTextObject: Startpara out of Range" );
    1559             :     DBG_ASSERT( nParas <= pImpEditEngine->GetEditDoc().Count() - nPara, "CreateTextObject: Endpara out of Range" );
    1560             : 
    1561      111087 :     ContentNode* pStartNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    1562      111087 :     ContentNode* pEndNode = pImpEditEngine->GetEditDoc().GetObject( nPara+nParas-1 );
    1563             :     DBG_ASSERT( pStartNode, "Start-Paragraph does not exist: CreateTextObject" );
    1564             :     DBG_ASSERT( pEndNode, "End-Paragraph does not exist: CreateTextObject" );
    1565             : 
    1566      111087 :     if ( pStartNode && pEndNode )
    1567             :     {
    1568      111087 :         EditSelection aTmpSel;
    1569      111087 :         aTmpSel.Min() = EditPaM( pStartNode, 0 );
    1570      111087 :         aTmpSel.Max() = EditPaM( pEndNode, pEndNode->Len() );
    1571      111087 :         return pImpEditEngine->CreateTextObject( aTmpSel );
    1572             :     }
    1573           0 :     return 0;
    1574             : }
    1575             : 
    1576           0 : void EditEngine::RemoveParagraph( sal_Int32 nPara )
    1577             : {
    1578             :     DBG_ASSERT( pImpEditEngine->GetEditDoc().Count() > 1, "The first paragraph should not be deleted!" );
    1579           0 :     if( pImpEditEngine->GetEditDoc().Count() <= 1 )
    1580           0 :         return;
    1581             : 
    1582           0 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    1583           0 :     const ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara );
    1584             :     DBG_ASSERT( pPortion && pNode, "Paragraph not found: RemoveParagraph" );
    1585           0 :     if ( pNode && pPortion )
    1586             :     {
    1587             :         // No Undo encapsulation needed.
    1588           0 :         pImpEditEngine->ImpRemoveParagraph( nPara );
    1589           0 :         pImpEditEngine->InvalidateFromParagraph( nPara );
    1590           0 :         pImpEditEngine->UpdateSelections();
    1591           0 :         pImpEditEngine->FormatAndUpdate();
    1592             :     }
    1593             : }
    1594             : 
    1595     1311825 : sal_Int32 EditEngine::GetTextLen( sal_Int32 nPara ) const
    1596             : {
    1597     1311825 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    1598             :     DBG_ASSERT( pNode, "Paragraph not found: GetTextLen" );
    1599     1311825 :     if ( pNode )
    1600     1311825 :         return pNode->Len();
    1601           0 :     return 0;
    1602             : }
    1603             : 
    1604       29446 : OUString EditEngine::GetText( sal_Int32 nPara ) const
    1605             : {
    1606       29446 :     OUString aStr;
    1607       29446 :     if ( 0 <= nPara && nPara < pImpEditEngine->GetEditDoc().Count() )
    1608       29446 :         aStr = pImpEditEngine->GetEditDoc().GetParaAsString( nPara );
    1609       29446 :     return aStr;
    1610             : }
    1611             : 
    1612        1112 : void EditEngine::SetModifyHdl( const Link<>& rLink )
    1613             : {
    1614        1112 :     pImpEditEngine->SetModifyHdl( rLink );
    1615        1112 : }
    1616             : 
    1617          84 : Link<> EditEngine::GetModifyHdl() const
    1618             : {
    1619          84 :     return pImpEditEngine->GetModifyHdl();
    1620             : }
    1621             : 
    1622             : 
    1623         172 : void EditEngine::ClearModifyFlag()
    1624             : {
    1625         172 :     pImpEditEngine->SetModifyFlag( false );
    1626         172 : }
    1627             : 
    1628           4 : void EditEngine::SetModified()
    1629             : {
    1630           4 :     pImpEditEngine->SetModifyFlag( true );
    1631           4 : }
    1632             : 
    1633          43 : bool EditEngine::IsModified() const
    1634             : {
    1635          43 :     return pImpEditEngine->IsModified();
    1636             : }
    1637             : 
    1638          15 : bool EditEngine::IsInSelectionMode() const
    1639             : {
    1640          30 :     return ( pImpEditEngine->IsInSelectionMode() ||
    1641          30 :                 pImpEditEngine->GetSelEngine().IsInSelection() );
    1642             : }
    1643             : 
    1644           0 : void EditEngine::InsertParagraph( sal_Int32 nPara, const EditTextObject& rTxtObj )
    1645             : {
    1646           0 :     if ( nPara > GetParagraphCount() )
    1647             :     {
    1648             :         DBG_ASSERTWARNING( nPara == EE_PARA_APPEND, "Paragraph number too large, but not EE_PARA_APPEND!" );
    1649           0 :         nPara = GetParagraphCount();
    1650             :     }
    1651             : 
    1652           0 :     pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
    1653             : 
    1654             :     // No Undo componding needed.
    1655           0 :     EditPaM aPaM( pImpEditEngine->InsertParagraph( nPara ) );
    1656             :     // When InsertParagraph from the outside, no hard attributes
    1657             :     // should be taken over!
    1658           0 :     pImpEditEngine->RemoveCharAttribs( nPara );
    1659           0 :     pImpEditEngine->InsertText( rTxtObj, EditSelection( aPaM, aPaM ) );
    1660             : 
    1661           0 :     pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
    1662             : 
    1663           0 :     pImpEditEngine->FormatAndUpdate();
    1664           0 : }
    1665             : 
    1666        2344 : void EditEngine::InsertParagraph(sal_Int32 nPara, const OUString& rTxt)
    1667             : {
    1668        2344 :     if ( nPara > GetParagraphCount() )
    1669             :     {
    1670             :         DBG_ASSERTWARNING( nPara == EE_PARA_APPEND, "Paragraph number too large, but not EE_PARA_APPEND!" );
    1671           0 :         nPara = GetParagraphCount();
    1672             :     }
    1673             : 
    1674        2344 :     pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
    1675        2344 :     EditPaM aPaM( pImpEditEngine->InsertParagraph( nPara ) );
    1676             :     // When InsertParagraph from the outside, no hard attributes
    1677             :     // should be taken over!
    1678        2344 :     pImpEditEngine->RemoveCharAttribs( nPara );
    1679        2344 :     pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
    1680        2344 :     pImpEditEngine->ImpInsertText( EditSelection( aPaM, aPaM ), rTxt );
    1681        2344 :     pImpEditEngine->FormatAndUpdate();
    1682        2344 : }
    1683             : 
    1684       30549 : void EditEngine::SetText(sal_Int32 nPara, const OUString& rTxt)
    1685             : {
    1686       30549 :     EditSelection* pSel = pImpEditEngine->SelectParagraph( nPara );
    1687       30549 :     if ( pSel )
    1688             :     {
    1689       30549 :         pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
    1690       30549 :         pImpEditEngine->ImpInsertText( *pSel, rTxt );
    1691       30549 :         pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
    1692       30549 :         pImpEditEngine->FormatAndUpdate();
    1693       30549 :         delete pSel;
    1694             :     }
    1695       30549 : }
    1696             : 
    1697      834656 : void EditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
    1698             : {
    1699      834656 :     pImpEditEngine->SetParaAttribs( nPara, rSet );
    1700      834656 :     pImpEditEngine->FormatAndUpdate();
    1701      834656 : }
    1702             : 
    1703      885932 : const SfxItemSet& EditEngine::GetParaAttribs( sal_Int32 nPara ) const
    1704             : {
    1705      885932 :     return pImpEditEngine->GetParaAttribs( nPara );
    1706             : }
    1707             : 
    1708       14405 : bool EditEngine::HasParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const
    1709             : {
    1710       14405 :     return pImpEditEngine->HasParaAttrib( nPara, nWhich );
    1711             : }
    1712             : 
    1713      102169 : const SfxPoolItem& EditEngine::GetParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich )
    1714             : {
    1715      102169 :     return pImpEditEngine->GetParaAttrib( nPara, nWhich );
    1716             : }
    1717             : 
    1718        2053 : void EditEngine::GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const
    1719             : {
    1720        2053 :     pImpEditEngine->GetCharAttribs( nPara, rLst );
    1721        2053 : }
    1722             : 
    1723        4379 : SfxItemSet EditEngine::GetAttribs( const ESelection& rSel, EditEngineAttribs nOnlyHardAttrib )
    1724             : {
    1725             :     EditSelection aSel( pImpEditEngine->
    1726        4379 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    1727        4379 :     return pImpEditEngine->GetAttribs( aSel, nOnlyHardAttrib );
    1728             : }
    1729             : 
    1730       26701 : SfxItemSet EditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags ) const
    1731             : {
    1732       26701 :     return pImpEditEngine->GetAttribs( nPara, nStart, nEnd, nFlags );
    1733             : }
    1734             : 
    1735         969 : void EditEngine::RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich )
    1736             : {
    1737             : 
    1738         969 :     pImpEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS );
    1739         969 :     EditSelection aSel( pImpEditEngine->ConvertSelection( rSelection.nStartPara, rSelection.nStartPos, rSelection.nEndPara, rSelection.nEndPos ) );
    1740         969 :     pImpEditEngine->RemoveCharAttribs( aSel, bRemoveParaAttribs, nWhich  );
    1741         969 :     pImpEditEngine->UndoActionEnd( EDITUNDO_RESETATTRIBS );
    1742         969 :     pImpEditEngine->FormatAndUpdate();
    1743         969 : }
    1744             : 
    1745           0 : vcl::Font EditEngine::GetStandardFont( sal_Int32 nPara )
    1746             : {
    1747           0 :     return GetStandardSvxFont( nPara );
    1748             : }
    1749             : 
    1750           0 : SvxFont EditEngine::GetStandardSvxFont( sal_Int32 nPara )
    1751             : {
    1752           0 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    1753           0 :     return pNode->GetCharAttribs().GetDefFont();
    1754             : }
    1755             : 
    1756       17483 : void EditEngine::StripPortions()
    1757             : {
    1758       17483 :     ScopedVclPtrInstance< VirtualDevice > aTmpDev;
    1759       17483 :     Rectangle aBigRect( Point( 0, 0 ), Size( 0x7FFFFFFF, 0x7FFFFFFF ) );
    1760       17483 :     if ( IsVertical() )
    1761             :     {
    1762           2 :         aBigRect.Right() = 0;
    1763           2 :         aBigRect.Left() = -0x7FFFFFFF;
    1764             :     }
    1765       17483 :     pImpEditEngine->Paint( aTmpDev.get(), aBigRect, Point(), true );
    1766       17483 : }
    1767             : 
    1768        2930 : void EditEngine::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList )
    1769             : {
    1770        2930 :     if ( !pImpEditEngine->IsFormatted() )
    1771          10 :         pImpEditEngine->FormatFullDoc();
    1772             : 
    1773        2930 :     const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara );
    1774        2930 :     if ( pParaPortion )
    1775             :     {
    1776        2930 :         sal_Int32 nEnd = 0;
    1777        2930 :         sal_Int32 nTextPortions = pParaPortion->GetTextPortions().Count();
    1778        6678 :         for ( sal_Int32 n = 0; n < nTextPortions; n++ )
    1779             :         {
    1780        3748 :             nEnd = nEnd + pParaPortion->GetTextPortions()[n]->GetLen();
    1781        3748 :             rList.push_back( nEnd );
    1782             :         }
    1783             :     }
    1784        2930 : }
    1785             : 
    1786           0 : void EditEngine::SetFlatMode( bool bFlat)
    1787             : {
    1788           0 :     pImpEditEngine->SetFlatMode( bFlat );
    1789           0 : }
    1790             : 
    1791        7152 : bool EditEngine::IsFlatMode() const
    1792             : {
    1793        7152 :     return !( pImpEditEngine->aStatus.UseCharAttribs() );
    1794             : }
    1795             : 
    1796     1158946 : void EditEngine::SetControlWord( EEControlBits nWord )
    1797             : {
    1798             : 
    1799     1158946 :     if ( nWord != pImpEditEngine->aStatus.GetControlWord() )
    1800             :     {
    1801       75099 :         EEControlBits nPrev = pImpEditEngine->aStatus.GetControlWord();
    1802       75099 :         pImpEditEngine->aStatus.GetControlWord() = nWord;
    1803             : 
    1804       75099 :         EEControlBits nChanges = nPrev ^ nWord;
    1805       75099 :         if ( pImpEditEngine->IsFormatted() )
    1806             :         {
    1807             :             // possibly reformat:
    1808      169575 :             if ( ( nChanges & EEControlBits::USECHARATTRIBS ) ||
    1809      203490 :                  ( nChanges & EEControlBits::USEPARAATTRIBS ) ||
    1810      169575 :                  ( nChanges & EEControlBits::ONECHARPERLINE ) ||
    1811      169575 :                  ( nChanges & EEControlBits::STRETCHING ) ||
    1812      169575 :                  ( nChanges & EEControlBits::OUTLINER ) ||
    1813      271320 :                  ( nChanges & EEControlBits::NOCOLORS ) ||
    1814      101745 :                  ( nChanges & EEControlBits::OUTLINER2 ) )
    1815             :             {
    1816       69020 :                 if ( ( nChanges & EEControlBits::USECHARATTRIBS ) ||
    1817       55216 :                      ( nChanges & EEControlBits::USEPARAATTRIBS ) )
    1818             :                 {
    1819           0 :                     bool bUseCharAttribs = bool( nWord & EEControlBits::USECHARATTRIBS );
    1820           0 :                     pImpEditEngine->GetEditDoc().CreateDefFont( bUseCharAttribs );
    1821             :                 }
    1822             : 
    1823       13804 :                 pImpEditEngine->FormatFullDoc();
    1824       13804 :                 pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
    1825             :             }
    1826             :         }
    1827             : 
    1828       75099 :         bool bSpellingChanged = bool(nChanges & EEControlBits::ONLINESPELLING);
    1829             : 
    1830       75099 :         if ( bSpellingChanged )
    1831             :         {
    1832        2201 :             pImpEditEngine->StopOnlineSpellTimer();
    1833        2201 :             if (nWord & EEControlBits::ONLINESPELLING)
    1834             :             {
    1835             :                 // Create WrongList, start timer...
    1836        1972 :                 sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
    1837        3944 :                 for ( sal_Int32 n = 0; n < nNodes; n++ )
    1838             :                 {
    1839        1972 :                     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
    1840        1972 :                     pNode->CreateWrongList();
    1841             :                 }
    1842        1972 :                 if (pImpEditEngine->IsFormatted())
    1843        1324 :                     pImpEditEngine->StartOnlineSpellTimer();
    1844             :             }
    1845             :             else
    1846             :             {
    1847         229 :                 long nY = 0;
    1848         229 :                 sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
    1849         458 :                 for ( sal_Int32 n = 0; n < nNodes; n++ )
    1850             :                 {
    1851         229 :                     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
    1852         229 :                     const ParaPortion* pPortion = pImpEditEngine->GetParaPortions()[n];
    1853         229 :                     bool bWrongs = false;
    1854         229 :                     if (pNode->GetWrongList() != NULL)
    1855         229 :                         bWrongs = !pNode->GetWrongList()->empty();
    1856         229 :                     pNode->DestroyWrongList();
    1857         229 :                     if ( bWrongs )
    1858             :                     {
    1859           0 :                         pImpEditEngine->aInvalidRect.Left() = 0;
    1860           0 :                         pImpEditEngine->aInvalidRect.Right() = pImpEditEngine->GetPaperSize().Width();
    1861           0 :                         pImpEditEngine->aInvalidRect.Top() = nY+1;
    1862           0 :                         pImpEditEngine->aInvalidRect.Bottom() = nY+pPortion->GetHeight()-1;
    1863           0 :                         pImpEditEngine->UpdateViews( pImpEditEngine->pActiveView );
    1864             :                     }
    1865         229 :                     nY += pPortion->GetHeight();
    1866             :                 }
    1867             :             }
    1868             :         }
    1869             :     }
    1870     1158946 : }
    1871             : 
    1872     1199748 : EEControlBits EditEngine::GetControlWord() const
    1873             : {
    1874     1199748 :     return pImpEditEngine->aStatus.GetControlWord();
    1875             : }
    1876             : 
    1877           0 : long EditEngine::GetFirstLineStartX( sal_Int32 nParagraph )
    1878             : {
    1879             : 
    1880           0 :     long nX = 0;
    1881           0 :     const ParaPortion* pPPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nParagraph );
    1882           0 :     if ( pPPortion )
    1883             :     {
    1884             :         DBG_ASSERT( pImpEditEngine->IsFormatted() || !pImpEditEngine->IsFormatting(), "GetFirstLineStartX: Doc not formatted - unable to format!" );
    1885           0 :         if ( !pImpEditEngine->IsFormatted() )
    1886           0 :             pImpEditEngine->FormatDoc();
    1887           0 :         const EditLine* pFirstLine = pPPortion->GetLines()[0];
    1888           0 :         nX = pFirstLine->GetStartPosX();
    1889             :     }
    1890           0 :     return nX;
    1891             : }
    1892             : 
    1893          11 : Point EditEngine::GetDocPos( const Point& rPaperPos ) const
    1894             : {
    1895          11 :     Point aDocPos( rPaperPos );
    1896          11 :     if ( IsVertical() )
    1897             :     {
    1898           0 :         aDocPos.X() = rPaperPos.Y();
    1899           0 :         aDocPos.Y() = GetPaperSize().Width() - rPaperPos.X();
    1900             :     }
    1901          11 :     return aDocPos;
    1902             : }
    1903             : 
    1904         130 : Point EditEngine::GetDocPosTopLeft( sal_Int32 nParagraph )
    1905             : {
    1906         130 :     const ParaPortion* pPPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nParagraph );
    1907             :     DBG_ASSERT( pPPortion, "Paragraph not found: GetWindowPosTopLeft" );
    1908         130 :     Point aPoint;
    1909         130 :     if ( pPPortion )
    1910             :     {
    1911             : 
    1912             :         // If someone calls GetLineHeight() with an empty Engine.
    1913             :         DBG_ASSERT( pImpEditEngine->IsFormatted() || !pImpEditEngine->IsFormatting(), "GetDocPosTopLeft: Doc not formatted - unable to format!" );
    1914         130 :         if ( !pImpEditEngine->IsFormatted() )
    1915           6 :             pImpEditEngine->FormatAndUpdate();
    1916         130 :         if ( pPPortion->GetLines().Count() )
    1917             :         {
    1918             :             // Correct it if large Bullet.
    1919         130 :             const EditLine* pFirstLine = pPPortion->GetLines()[0];
    1920         130 :             aPoint.X() = pFirstLine->GetStartPosX();
    1921             :         }
    1922             :         else
    1923             :         {
    1924           0 :             const SvxLRSpaceItem& rLRItem = pImpEditEngine->GetLRSpaceItem( pPPortion->GetNode() );
    1925             : // TL_NF_LR         aPoint.X() = pImpEditEngine->GetXValue( (short)(rLRItem.GetTextLeft() + rLRItem.GetTextFirstLineOfst()) );
    1926           0 :             sal_Int32 nSpaceBefore = 0;
    1927           0 :             pImpEditEngine->GetSpaceBeforeAndMinLabelWidth( pPPortion->GetNode(), &nSpaceBefore );
    1928           0 :             short nX = (short)(rLRItem.GetTextLeft()
    1929           0 :                             + rLRItem.GetTextFirstLineOfst()
    1930           0 :                             + nSpaceBefore);
    1931           0 :             aPoint.X() = pImpEditEngine->GetXValue( nX
    1932           0 :                              );
    1933             :         }
    1934         130 :         aPoint.Y() = pImpEditEngine->GetParaPortions().GetYOffset( pPPortion );
    1935             :     }
    1936         130 :     return aPoint;
    1937             : }
    1938             : 
    1939       26310 : const SvxNumberFormat* EditEngine::GetNumberFormat( sal_Int32 nPara ) const
    1940             : {
    1941             :     // derived objects may override this function to give access to
    1942             :     // bullet information (see Outliner)
    1943             :     (void) nPara;
    1944       26310 :     return 0;
    1945             : }
    1946             : 
    1947        3905 : bool EditEngine::IsRightToLeft( sal_Int32 nPara ) const
    1948             : {
    1949        3905 :     return pImpEditEngine->IsRightToLeft( nPara );
    1950             : }
    1951             : 
    1952           8 : bool EditEngine::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder )
    1953             : {
    1954             : 
    1955           8 :     if ( !pImpEditEngine->IsFormatted() )
    1956           0 :         pImpEditEngine->FormatDoc();
    1957             : 
    1958           8 :     bool bTextPos = false;
    1959             :     // take unrotated positions for calculation here
    1960           8 :     Point aDocPos = GetDocPos( rPaperPos );
    1961             : 
    1962           8 :     if ( ( aDocPos.Y() > 0  ) && ( aDocPos.Y() < (long)pImpEditEngine->GetTextHeight() ) )
    1963             :     {
    1964           8 :         EditPaM aPaM = pImpEditEngine->GetPaM( aDocPos, false );
    1965           8 :         if ( aPaM.GetNode() )
    1966             :         {
    1967           8 :             const ParaPortion* pParaPortion = pImpEditEngine->FindParaPortion( aPaM.GetNode() );
    1968             :             DBG_ASSERT( pParaPortion, "ParaPortion?" );
    1969             : 
    1970           8 :             sal_Int32 nLine = pParaPortion->GetLineNumber( aPaM.GetIndex() );
    1971           8 :             const EditLine* pLine = pParaPortion->GetLines()[nLine];
    1972           8 :             Range aLineXPosStartEnd = pImpEditEngine->GetLineXPosStartEnd( pParaPortion, pLine );
    1973          13 :             if ( ( aDocPos.X() >= aLineXPosStartEnd.Min() - nBorder ) &&
    1974           5 :                  ( aDocPos.X() <= aLineXPosStartEnd.Max() + nBorder ) )
    1975             :             {
    1976           5 :                  bTextPos = true;
    1977             :             }
    1978             :         }
    1979             :     }
    1980           8 :     return bTextPos;
    1981             : }
    1982             : 
    1983       40676 : void EditEngine::SetEditTextObjectPool( SfxItemPool* pPool )
    1984             : {
    1985       40676 :     pImpEditEngine->SetEditTextObjectPool( pPool );
    1986       40676 : }
    1987             : 
    1988        1115 : SfxItemPool* EditEngine::GetEditTextObjectPool() const
    1989             : {
    1990        1115 :     return pImpEditEngine->GetEditTextObjectPool();
    1991             : }
    1992             : 
    1993       11164 : void EditEngine::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel )
    1994             : {
    1995             : 
    1996             :     EditSelection aSel( pImpEditEngine->
    1997       11164 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    1998             : 
    1999       11164 :     pImpEditEngine->SetAttribs( aSel, rSet );
    2000       11164 : }
    2001             : 
    2002           0 : void EditEngine::QuickMarkInvalid( const ESelection& rSel )
    2003             : {
    2004             :     DBG_ASSERT( rSel.nStartPara < pImpEditEngine->GetEditDoc().Count(), "MarkInvalid: Start out of Range!" );
    2005             :     DBG_ASSERT( rSel.nEndPara < pImpEditEngine->GetEditDoc().Count(), "MarkInvalid: End out of Range!" );
    2006           0 :     for ( sal_Int32 nPara = rSel.nStartPara; nPara <= rSel.nEndPara; nPara++ )
    2007             :     {
    2008           0 :         ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara );
    2009           0 :         if ( pPortion )
    2010           0 :             pPortion->MarkSelectionInvalid( 0, pPortion->GetNode()->Len() );
    2011             :     }
    2012           0 : }
    2013             : 
    2014       32220 : void EditEngine::QuickInsertText(const OUString& rText, const ESelection& rSel)
    2015             : {
    2016             : 
    2017             :     EditSelection aSel( pImpEditEngine->
    2018       32220 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    2019             : 
    2020       32220 :     pImpEditEngine->ImpInsertText( aSel, rText );
    2021       32220 : }
    2022             : 
    2023        2534 : void EditEngine::QuickDelete( const ESelection& rSel )
    2024             : {
    2025             : 
    2026             :     EditSelection aSel( pImpEditEngine->
    2027        2534 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    2028             : 
    2029        2534 :     pImpEditEngine->ImpDeleteSelection( aSel );
    2030        2534 : }
    2031             : 
    2032           0 : void EditEngine::QuickMarkToBeRepainted( sal_Int32 nPara )
    2033             : {
    2034           0 :     ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara );
    2035           0 :     if ( pPortion )
    2036           0 :         pPortion->SetMustRepaint( true );
    2037           0 : }
    2038             : 
    2039          44 : void EditEngine::QuickInsertLineBreak( const ESelection& rSel )
    2040             : {
    2041             : 
    2042             :     EditSelection aSel( pImpEditEngine->
    2043          44 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    2044             : 
    2045          44 :     pImpEditEngine->InsertLineBreak( aSel );
    2046          44 : }
    2047             : 
    2048        9368 : void EditEngine::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel )
    2049             : {
    2050             : 
    2051             :     EditSelection aSel( pImpEditEngine->
    2052        9368 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    2053             : 
    2054        9368 :     pImpEditEngine->ImpInsertFeature( aSel, rFld );
    2055        9368 : }
    2056             : 
    2057          16 : void EditEngine::QuickFormatDoc( bool bFull )
    2058             : {
    2059          16 :     if ( bFull )
    2060           0 :         pImpEditEngine->FormatFullDoc();
    2061             :     else
    2062          16 :         pImpEditEngine->FormatDoc();
    2063             : 
    2064             :     // Don't pass active view, maybe selection is not updated yet...
    2065          16 :     pImpEditEngine->UpdateViews( NULL );
    2066          16 : }
    2067             : 
    2068           0 : void EditEngine::SetStyleSheet(const EditSelection& aSel, SfxStyleSheet* pStyle)
    2069             : {
    2070           0 :     pImpEditEngine->SetStyleSheet(aSel, pStyle);
    2071           0 : }
    2072             : 
    2073       32239 : void EditEngine::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle )
    2074             : {
    2075       32239 :     pImpEditEngine->SetStyleSheet( nPara, pStyle );
    2076       32239 : }
    2077             : 
    2078           0 : const SfxStyleSheet* EditEngine::GetStyleSheet( sal_Int32 nPara ) const
    2079             : {
    2080           0 :     return pImpEditEngine->GetStyleSheet( nPara );
    2081             : }
    2082             : 
    2083       29997 : SfxStyleSheet* EditEngine::GetStyleSheet( sal_Int32 nPara )
    2084             : {
    2085       29997 :     return pImpEditEngine->GetStyleSheet( nPara );
    2086             : }
    2087             : 
    2088       34085 : void EditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool )
    2089             : {
    2090       34085 :     pImpEditEngine->SetStyleSheetPool( pSPool );
    2091       34085 : }
    2092             : 
    2093         306 : SfxStyleSheetPool* EditEngine::GetStyleSheetPool()
    2094             : {
    2095         306 :     return pImpEditEngine->GetStyleSheetPool();
    2096             : }
    2097             : 
    2098        1595 : void EditEngine::SetWordDelimiters( const OUString& rDelimiters )
    2099             : {
    2100        1595 :     pImpEditEngine->aWordDelimiters = rDelimiters;
    2101        1595 :     if (pImpEditEngine->aWordDelimiters.indexOf(CH_FEATURE) == -1)
    2102        1595 :         pImpEditEngine->aWordDelimiters += OUString(CH_FEATURE);
    2103        1595 : }
    2104             : 
    2105        1570 : OUString EditEngine::GetWordDelimiters() const
    2106             : {
    2107        1570 :     return pImpEditEngine->aWordDelimiters;
    2108             : }
    2109             : 
    2110        8321 : void EditEngine::EraseVirtualDevice()
    2111             : {
    2112        8321 :     pImpEditEngine->EraseVirtualDevice();
    2113        8321 : }
    2114             : 
    2115        5074 : void EditEngine::SetSpeller( Reference< XSpellChecker1 >  &xSpeller )
    2116             : {
    2117        5074 :     pImpEditEngine->SetSpeller( xSpeller );
    2118        5074 : }
    2119             : 
    2120           0 : Reference< XSpellChecker1 >  EditEngine::GetSpeller()
    2121             : {
    2122           0 :     return pImpEditEngine->GetSpeller();
    2123             : }
    2124             : 
    2125       38775 : void EditEngine::SetHyphenator( Reference< XHyphenator > & xHyph )
    2126             : {
    2127       38775 :     pImpEditEngine->SetHyphenator( xHyph );
    2128       38775 : }
    2129             : 
    2130           5 : void EditEngine::GetAllMisspellRanges( std::vector<editeng::MisspellRanges>& rRanges ) const
    2131             : {
    2132           5 :     pImpEditEngine->GetAllMisspellRanges(rRanges);
    2133           5 : }
    2134             : 
    2135         146 : void EditEngine::SetAllMisspellRanges( const std::vector<editeng::MisspellRanges>& rRanges )
    2136             : {
    2137         146 :     pImpEditEngine->SetAllMisspellRanges(rRanges);
    2138         146 : }
    2139             : 
    2140       69079 : void EditEngine::SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars )
    2141             : {
    2142       69079 :     ImpEditEngine::SetForbiddenCharsTable( xForbiddenChars );
    2143       69079 : }
    2144             : 
    2145       16494 : void EditEngine::SetDefaultLanguage( LanguageType eLang )
    2146             : {
    2147       16494 :     pImpEditEngine->SetDefaultLanguage( eLang );
    2148       16494 : }
    2149             : 
    2150           0 : LanguageType EditEngine::GetDefaultLanguage() const
    2151             : {
    2152           0 :     return pImpEditEngine->GetDefaultLanguage();
    2153             : }
    2154             : 
    2155           0 : bool EditEngine::SpellNextDocument()
    2156             : {
    2157           0 :     return false;
    2158             : }
    2159             : 
    2160           0 : EESpellState EditEngine::HasSpellErrors()
    2161             : {
    2162           0 :     if ( !pImpEditEngine->GetSpeller().is()  )
    2163           0 :         return EE_SPELL_NOSPELLER;
    2164             : 
    2165           0 :     return pImpEditEngine->HasSpellErrors();
    2166             : }
    2167             : 
    2168           0 : void EditEngine::ClearSpellErrors()
    2169             : {
    2170           0 :     pImpEditEngine->ClearSpellErrors();
    2171           0 : }
    2172             : 
    2173           0 : void EditEngine::StartSpelling(EditView& rEditView, bool bMultipleDoc)
    2174             : {
    2175           0 :     pImpEditEngine->StartSpelling(rEditView, bMultipleDoc);
    2176           0 : }
    2177             : 
    2178           0 : bool EditEngine::SpellSentence(EditView& rView, svx::SpellPortions& rToFill, bool bIsGrammarChecking )
    2179             : {
    2180           0 :     return pImpEditEngine->SpellSentence( rView, rToFill, bIsGrammarChecking );
    2181             : }
    2182             : 
    2183           0 : void EditEngine::PutSpellingToSentenceStart( EditView& rEditView )
    2184             : {
    2185           0 :     pImpEditEngine->PutSpellingToSentenceStart( rEditView );
    2186           0 : }
    2187             : 
    2188           0 : void EditEngine::ApplyChangedSentence(EditView& rEditView, const svx::SpellPortions& rNewPortions, bool bRecheck )
    2189             : {
    2190           0 :     pImpEditEngine->ApplyChangedSentence( rEditView, rNewPortions, bRecheck  );
    2191           0 : }
    2192             : 
    2193           0 : bool EditEngine::HasConvertibleTextPortion( LanguageType nLang )
    2194             : {
    2195           0 :     return pImpEditEngine->HasConvertibleTextPortion( nLang );
    2196             : }
    2197             : 
    2198           0 : bool EditEngine::ConvertNextDocument()
    2199             : {
    2200           0 :     return false;
    2201             : }
    2202             : 
    2203          32 : bool EditEngine::HasText( const SvxSearchItem& rSearchItem )
    2204             : {
    2205          32 :     return pImpEditEngine->HasText( rSearchItem );
    2206             : }
    2207             : 
    2208      429841 : void EditEngine::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY )
    2209             : {
    2210      429841 :     pImpEditEngine->SetCharStretching( nX, nY );
    2211      429841 : }
    2212             : 
    2213        4666 : void EditEngine::GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const
    2214             : {
    2215        4666 :     pImpEditEngine->GetCharStretching( rX, rY );
    2216        4666 : }
    2217             : 
    2218           8 : bool EditEngine::ShouldCreateBigTextObject() const
    2219             : {
    2220           8 :     sal_Int32 nTextPortions = 0;
    2221           8 :     sal_Int32 nParas = pImpEditEngine->GetEditDoc().Count();
    2222          16 :     for ( sal_Int32 nPara = 0; nPara < nParas; nPara++  )
    2223             :     {
    2224           8 :         ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions()[nPara];
    2225           8 :         nTextPortions = nTextPortions + pParaPortion->GetTextPortions().Count();
    2226             :     }
    2227           8 :     return nTextPortions >= pImpEditEngine->GetBigTextObjectStart();
    2228             : }
    2229             : 
    2230         477 : sal_uInt16 EditEngine::GetFieldCount( sal_Int32 nPara ) const
    2231             : {
    2232         477 :     sal_uInt16 nFields = 0;
    2233         477 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    2234         477 :     if ( pNode )
    2235             :     {
    2236         477 :         const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
    2237         477 :         CharAttribList::AttribsType::const_iterator it = rAttrs.begin(), itEnd = rAttrs.end();
    2238         507 :         for (; it != itEnd; ++it)
    2239             :         {
    2240          30 :             if (it->Which() == EE_FEATURE_FIELD)
    2241          30 :                 ++nFields;
    2242             :         }
    2243             :     }
    2244             : 
    2245         477 :     return nFields;
    2246             : }
    2247             : 
    2248          30 : EFieldInfo EditEngine::GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const
    2249             : {
    2250          30 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    2251          30 :     if ( pNode )
    2252             :     {
    2253          30 :         sal_uInt16 nCurrentField = 0;
    2254          30 :         const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
    2255          30 :         CharAttribList::AttribsType::const_iterator it = rAttrs.begin(), itEnd = rAttrs.end();
    2256          30 :         for (; it != itEnd; ++it)
    2257             :         {
    2258          30 :             const EditCharAttrib& rAttr = *it;
    2259          30 :             if (rAttr.Which() == EE_FEATURE_FIELD)
    2260             :             {
    2261          30 :                 if ( nCurrentField == nField )
    2262             :                 {
    2263          30 :                     const SvxFieldItem* p = static_cast<const SvxFieldItem*>(rAttr.GetItem());
    2264          30 :                     EFieldInfo aInfo(*p, nPara, rAttr.GetStart());
    2265          30 :                     aInfo.aCurrentText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue();
    2266          30 :                     return aInfo;
    2267             :                 }
    2268             : 
    2269           0 :                 ++nCurrentField;
    2270             :             }
    2271             :         }
    2272             :     }
    2273           0 :     return EFieldInfo();
    2274             : }
    2275             : 
    2276             : 
    2277         147 : bool EditEngine::UpdateFields()
    2278             : {
    2279         147 :     bool bChanges = pImpEditEngine->UpdateFields();
    2280         147 :     if ( bChanges )
    2281           1 :         pImpEditEngine->FormatAndUpdate();
    2282         147 :     return bChanges;
    2283             : }
    2284             : 
    2285           0 : bool EditEngine::UpdateFieldsOnly()
    2286             : {
    2287           0 :     return pImpEditEngine->UpdateFields();
    2288             : }
    2289             : 
    2290           0 : void EditEngine::RemoveFields( bool bKeepFieldText, TypeId aType )
    2291             : {
    2292             : 
    2293           0 :     if ( bKeepFieldText )
    2294           0 :         pImpEditEngine->UpdateFields();
    2295             : 
    2296           0 :     sal_Int32 nParas = pImpEditEngine->GetEditDoc().Count();
    2297           0 :     for ( sal_Int32 nPara = 0; nPara < nParas; nPara++  )
    2298             :     {
    2299           0 :         ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    2300           0 :         const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
    2301           0 :         for (size_t nAttr = rAttrs.size(); nAttr; )
    2302             :         {
    2303           0 :             const EditCharAttrib& rAttr = rAttrs[--nAttr];
    2304           0 :             if (rAttr.Which() == EE_FEATURE_FIELD)
    2305             :             {
    2306           0 :                 const SvxFieldData* pFldData = static_cast<const SvxFieldItem*>(rAttr.GetItem())->GetField();
    2307           0 :                 if ( pFldData && ( !aType || ( pFldData->IsA( aType ) ) ) )
    2308             :                 {
    2309             :                     DBG_ASSERT( dynamic_cast<const SvxFieldItem*>(rAttr.GetItem()), "no field item..." );
    2310           0 :                     EditSelection aSel( EditPaM(pNode, rAttr.GetStart()), EditPaM(pNode, rAttr.GetEnd()) );
    2311           0 :                     OUString aFieldText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue();
    2312           0 :                     pImpEditEngine->ImpInsertText( aSel, aFieldText );
    2313             :                 }
    2314             :             }
    2315             :         }
    2316             :     }
    2317           0 : }
    2318             : 
    2319         510 : bool EditEngine::HasOnlineSpellErrors() const
    2320             : {
    2321         510 :     sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
    2322        1020 :     for ( sal_Int32 n = 0; n < nNodes; n++ )
    2323             :     {
    2324         510 :         ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
    2325         510 :         if ( pNode->GetWrongList() && !pNode->GetWrongList()->empty() )
    2326           0 :             return true;
    2327             :     }
    2328         510 :     return false;
    2329             : }
    2330             : 
    2331        1494 : void EditEngine::CompleteOnlineSpelling()
    2332             : {
    2333        1494 :     if ( pImpEditEngine->GetStatus().DoOnlineSpelling() )
    2334             :     {
    2335         984 :         if( !pImpEditEngine->IsFormatted() )
    2336           0 :             pImpEditEngine->FormatAndUpdate();
    2337             : 
    2338         984 :         pImpEditEngine->StopOnlineSpellTimer();
    2339         984 :         pImpEditEngine->DoOnlineSpelling( 0, true, false );
    2340             :     }
    2341        1494 : }
    2342             : 
    2343           3 : sal_Int32 EditEngine::FindParagraph( long nDocPosY )
    2344             : {
    2345           3 :     return pImpEditEngine->GetParaPortions().FindParagraph( nDocPosY );
    2346             : }
    2347             : 
    2348          11 : EPosition EditEngine::FindDocPosition( const Point& rDocPos ) const
    2349             : {
    2350          11 :     EPosition aPos;
    2351             :     // From the point of the API, this is const....
    2352          11 :     EditPaM aPaM = const_cast<EditEngine*>(this)->pImpEditEngine->GetPaM( rDocPos, false );
    2353          11 :     if ( aPaM.GetNode() )
    2354             :     {
    2355          11 :         aPos.nPara = pImpEditEngine->aEditDoc.GetPos( aPaM.GetNode() );
    2356          11 :         aPos.nIndex = aPaM.GetIndex();
    2357             :     }
    2358          11 :     return aPos;
    2359             : }
    2360             : 
    2361          21 : Rectangle EditEngine::GetCharacterBounds( const EPosition& rPos ) const
    2362             : {
    2363          21 :     Rectangle aBounds;
    2364          21 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( rPos.nPara );
    2365             : 
    2366             :     // Check against index, not paragraph
    2367          21 :     if ( pNode && ( rPos.nIndex < pNode->Len() ) )
    2368             :     {
    2369          21 :         aBounds = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex ), GETCRSR_TXTONLY );
    2370          21 :         Rectangle aR2 = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex+1 ), GETCRSR_TXTONLY|GETCRSR_ENDOFLINE );
    2371          21 :         if ( aR2.Right() > aBounds.Right() )
    2372          21 :             aBounds.Right() = aR2.Right();
    2373             :     }
    2374          21 :     return aBounds;
    2375             : }
    2376             : 
    2377        5326 : ParagraphInfos EditEngine::GetParagraphInfos( sal_Int32 nPara )
    2378             : {
    2379             : 
    2380             :     // This only works if not already in the format ...
    2381        5326 :     if ( !pImpEditEngine->IsFormatted() )
    2382        3415 :         pImpEditEngine->FormatDoc();
    2383             : 
    2384        5326 :     ParagraphInfos aInfos;
    2385        5326 :     aInfos.bValid = pImpEditEngine->IsFormatted();
    2386        5326 :     if ( pImpEditEngine->IsFormatted() )
    2387             :     {
    2388        1911 :         const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions()[nPara];
    2389        1911 :         const EditLine* pLine = (pParaPortion && pParaPortion->GetLines().Count()) ?
    2390        3822 :                 pParaPortion->GetLines()[0] : NULL;
    2391             :         DBG_ASSERT( pParaPortion && pLine, "GetParagraphInfos - Paragraph out of range" );
    2392        1911 :         if ( pParaPortion && pLine )
    2393             :         {
    2394        1911 :             aInfos.nParaHeight = (sal_uInt16)pParaPortion->GetHeight();
    2395        1911 :             aInfos.nLines = pParaPortion->GetLines().Count();
    2396        1911 :             aInfos.nFirstLineStartX = pLine->GetStartPosX();
    2397        1911 :             aInfos.nFirstLineOffset = pParaPortion->GetFirstLineOffset();
    2398        1911 :             aInfos.nFirstLineHeight = pLine->GetHeight();
    2399        1911 :             aInfos.nFirstLineTextHeight = pLine->GetTxtHeight();
    2400        1911 :             aInfos.nFirstLineMaxAscent = pLine->GetMaxAscent();
    2401             :         }
    2402             :     }
    2403        5326 :     return aInfos;
    2404             : }
    2405             : 
    2406             : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >
    2407           0 :                     EditEngine::CreateTransferable( const ESelection& rSelection ) const
    2408             : {
    2409           0 :     EditSelection aSel( pImpEditEngine->CreateSel( rSelection ) );
    2410           0 :     return pImpEditEngine->CreateTransferable( aSel );
    2411             : }
    2412             : 
    2413             : 
    2414             : // ======================    Virtual Methods    ========================
    2415             : 
    2416           0 : void EditEngine::DrawingText( const Point&, const OUString&, sal_Int32, sal_Int32,
    2417             :                               const long*, const SvxFont&, sal_Int32, sal_Int32, sal_uInt8,
    2418             :                               const EEngineData::WrongSpellVector*, const SvxFieldData*, bool, bool, bool,
    2419             :                               const ::com::sun::star::lang::Locale*, const Color&, const Color&)
    2420             : 
    2421             : {
    2422           0 : }
    2423             : 
    2424           0 : void EditEngine::DrawingTab( const Point& /*rStartPos*/, long /*nWidth*/,
    2425             :                              const OUString& /*rChar*/, const SvxFont& /*rFont*/,
    2426             :                              sal_Int32 /*nPara*/, sal_Int32 /*nIndex*/,
    2427             :                              sal_uInt8 /*nRightToLeft*/, bool /*bEndOfLine*/,
    2428             :                              bool /*bEndOfParagraph*/, const Color& /*rOverlineColor*/,
    2429             :                              const Color& /*rTextLineColor*/)
    2430             : {
    2431           0 : }
    2432             : 
    2433        2220 : void EditEngine::PaintingFirstLine( sal_Int32, const Point&, long, const Point&, short, OutputDevice* )
    2434             : {
    2435        2220 : }
    2436             : 
    2437      464149 : void EditEngine::ParagraphInserted( sal_Int32 nPara )
    2438             : {
    2439             : 
    2440      464149 :     if ( GetNotifyHdl().IsSet() )
    2441             :     {
    2442         166 :         EENotify aNotify( EE_NOTIFY_PARAGRAPHINSERTED );
    2443         166 :         aNotify.pEditEngine = this;
    2444         166 :         aNotify.nParagraph = nPara;
    2445         166 :         pImpEditEngine->CallNotify( aNotify );
    2446             :     }
    2447      464149 : }
    2448             : 
    2449      447740 : void EditEngine::ParagraphDeleted( sal_Int32 nPara )
    2450             : {
    2451             : 
    2452      447740 :     if ( GetNotifyHdl().IsSet() )
    2453             :     {
    2454         166 :         EENotify aNotify( EE_NOTIFY_PARAGRAPHREMOVED );
    2455         166 :         aNotify.pEditEngine = this;
    2456         166 :         aNotify.nParagraph = nPara;
    2457         166 :         pImpEditEngine->CallNotify( aNotify );
    2458             :     }
    2459      447740 : }
    2460         909 : void EditEngine::ParagraphConnected( sal_Int32 /*nLeftParagraph*/, sal_Int32 /*nRightParagraph*/ )
    2461             : {
    2462         909 : }
    2463             : 
    2464       27702 : void EditEngine::ParaAttribsChanged( sal_Int32 /* nParagraph */ )
    2465             : {
    2466       27702 : }
    2467             : 
    2468           0 : void EditEngine::StyleSheetChanged( SfxStyleSheet* /* pStyle */ )
    2469             : {
    2470           0 : }
    2471             : 
    2472      325367 : void EditEngine::ParagraphHeightChanged( sal_Int32 nPara )
    2473             : {
    2474             : 
    2475      325367 :     if ( GetNotifyHdl().IsSet() )
    2476             :     {
    2477         170 :         EENotify aNotify( EE_NOTIFY_TEXTHEIGHTCHANGED );
    2478         170 :         aNotify.pEditEngine = this;
    2479         170 :         aNotify.nParagraph = nPara;
    2480         170 :         pImpEditEngine->CallNotify( aNotify );
    2481             :     }
    2482      325367 : }
    2483             : 
    2484      159389 : OUString EditEngine::GetUndoComment( sal_uInt16 nId ) const
    2485             : {
    2486      159389 :     OUString aComment;
    2487      159389 :     switch ( nId )
    2488             :     {
    2489             :         case EDITUNDO_REMOVECHARS:
    2490             :         case EDITUNDO_CONNECTPARAS:
    2491             :         case EDITUNDO_REMOVEFEATURE:
    2492             :         case EDITUNDO_DELCONTENT:
    2493             :         case EDITUNDO_DELETE:
    2494             :         case EDITUNDO_CUT:
    2495        1075 :             aComment = EE_RESSTR(RID_EDITUNDO_DEL);
    2496        1075 :         break;
    2497             :         case EDITUNDO_MOVEPARAGRAPHS:
    2498             :         case EDITUNDO_MOVEPARAS:
    2499             :         case EDITUNDO_DRAGANDDROP:
    2500           0 :             aComment = EE_RESSTR(RID_EDITUNDO_MOVE);
    2501           0 :         break;
    2502             :         case EDITUNDO_INSERTFEATURE:
    2503             :         case EDITUNDO_SPLITPARA:
    2504             :         case EDITUNDO_INSERTCHARS:
    2505             :         case EDITUNDO_PASTE:
    2506             :         case EDITUNDO_INSERT:
    2507             :         case EDITUNDO_READ:
    2508      106574 :             aComment = EE_RESSTR(RID_EDITUNDO_INSERT);
    2509      106574 :         break;
    2510             :         case EDITUNDO_SRCHANDREPL:
    2511             :         case EDITUNDO_REPLACEALL:
    2512           0 :             aComment = EE_RESSTR(RID_EDITUNDO_REPLACE);
    2513           0 :         break;
    2514             :         case EDITUNDO_ATTRIBS:
    2515             :         case EDITUNDO_PARAATTRIBS:
    2516             :         case EDITUNDO_STRETCH:
    2517       42340 :             aComment = EE_RESSTR(RID_EDITUNDO_SETATTRIBS);
    2518       42340 :         break;
    2519             :         case EDITUNDO_RESETATTRIBS:
    2520         969 :             aComment = EE_RESSTR(RID_EDITUNDO_RESETATTRIBS);
    2521         969 :         break;
    2522             :         case EDITUNDO_STYLESHEET:
    2523        8431 :             aComment = EE_RESSTR(RID_EDITUNDO_SETSTYLE);
    2524        8431 :         break;
    2525             :         case EDITUNDO_TRANSLITERATE:
    2526           0 :             aComment = EE_RESSTR(RID_EDITUNDO_TRANSLITERATE);
    2527           0 :         break;
    2528             :         case EDITUNDO_INDENTBLOCK:
    2529             :         case EDITUNDO_UNINDENTBLOCK:
    2530           0 :             aComment = EE_RESSTR(RID_EDITUNDO_INDENT);
    2531           0 :         break;
    2532             :     }
    2533      159389 :     return aComment;
    2534             : }
    2535             : 
    2536       23646 : Rectangle EditEngine::GetBulletArea( sal_Int32 )
    2537             : {
    2538       23646 :     return Rectangle( Point(), Point() );
    2539             : }
    2540             : 
    2541        1149 : OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, Color*&, Color*& )
    2542             : {
    2543        1149 :     return OUString(' ');
    2544             : }
    2545             : 
    2546           0 : void EditEngine::FieldClicked( const SvxFieldItem&, sal_Int32, sal_Int32 )
    2547             : {
    2548           0 : }
    2549             : 
    2550           0 : void EditEngine::FieldSelected( const SvxFieldItem&, sal_Int32, sal_Int32 )
    2551             : {
    2552           0 : }
    2553             : 
    2554             : 
    2555             : // ======================     Static Methods     =======================
    2556             : 
    2557       56107 : SfxItemPool* EditEngine::CreatePool( bool bPersistentRefCounts )
    2558             : {
    2559       56107 :     SfxItemPool* pPool = new EditEngineItemPool( bPersistentRefCounts );
    2560       56107 :     return pPool;
    2561             : }
    2562             : 
    2563         102 : SfxItemPool& EditEngine::GetGlobalItemPool()
    2564             : {
    2565         102 :     if ( !pGlobalPool )
    2566          70 :         pGlobalPool = CreatePool();
    2567         102 :     return *pGlobalPool;
    2568             : }
    2569             : 
    2570         239 : void EditEngine::SetFontInfoInItemSet( SfxItemSet& rSet, const vcl::Font& rFont )
    2571             : {
    2572         239 :     SvxFont aSvxFont( rFont );
    2573         239 :     SetFontInfoInItemSet( rSet, aSvxFont );
    2574             : 
    2575         239 : }
    2576             : 
    2577         239 : void EditEngine::SetFontInfoInItemSet( SfxItemSet& rSet, const SvxFont& rFont )
    2578             : {
    2579         239 :     rSet.Put( SvxLanguageItem( rFont.GetLanguage(), EE_CHAR_LANGUAGE ) );
    2580         239 :     rSet.Put( SvxFontItem( rFont.GetFamily(), rFont.GetName(), OUString(), rFont.GetPitch(), rFont.GetCharSet(), EE_CHAR_FONTINFO ) );
    2581         239 :     rSet.Put( SvxFontHeightItem( rFont.GetSize().Height(), 100, EE_CHAR_FONTHEIGHT )  );
    2582         239 :     rSet.Put( SvxCharScaleWidthItem( 100, EE_CHAR_FONTWIDTH ) );
    2583         239 :     rSet.Put( SvxShadowedItem( rFont.IsShadow(), EE_CHAR_SHADOW )  );
    2584         239 :     rSet.Put( SvxEscapementItem( rFont.GetEscapement(), rFont.GetPropr(), EE_CHAR_ESCAPEMENT )  );
    2585         239 :     rSet.Put( SvxWeightItem( rFont.GetWeight(), EE_CHAR_WEIGHT )  );
    2586         239 :     rSet.Put( SvxColorItem( rFont.GetColor(), EE_CHAR_COLOR )  );
    2587         239 :     rSet.Put( SvxBackgroundColorItem( rFont.GetFillColor(), EE_CHAR_BKGCOLOR )  );
    2588         239 :     rSet.Put( SvxUnderlineItem( rFont.GetUnderline(), EE_CHAR_UNDERLINE )  );
    2589         239 :     rSet.Put( SvxOverlineItem( rFont.GetOverline(), EE_CHAR_OVERLINE )  );
    2590         239 :     rSet.Put( SvxCrossedOutItem( rFont.GetStrikeout(), EE_CHAR_STRIKEOUT )  );
    2591         239 :     rSet.Put( SvxCaseMapItem( rFont.GetCaseMap(), EE_CHAR_CASEMAP )  );
    2592         239 :     rSet.Put( SvxPostureItem( rFont.GetItalic(), EE_CHAR_ITALIC )  );
    2593         239 :     rSet.Put( SvxContourItem( rFont.IsOutline(), EE_CHAR_OUTLINE )  );
    2594         239 :     rSet.Put( SvxAutoKernItem( rFont.IsKerning(), EE_CHAR_PAIRKERNING ) );
    2595         239 :     rSet.Put( SvxKerningItem( rFont.GetFixKerning(), EE_CHAR_KERNING ) );
    2596         239 :     rSet.Put( SvxWordLineModeItem( rFont.IsWordLineMode(), EE_CHAR_WLM ) );
    2597         239 :     rSet.Put( SvxEmphasisMarkItem( rFont.GetEmphasisMark(), EE_CHAR_EMPHASISMARK ) );
    2598         239 :     rSet.Put( SvxCharReliefItem( rFont.GetRelief(), EE_CHAR_RELIEF ) );
    2599         239 : }
    2600             : 
    2601        3576 : vcl::Font EditEngine::CreateFontFromItemSet( const SfxItemSet& rItemSet, SvtScriptType nScriptType )
    2602             : {
    2603        3576 :     SvxFont aFont;
    2604        3576 :     CreateFont( aFont, rItemSet, true, nScriptType );
    2605        3576 :     return aFont;
    2606             : }
    2607             : 
    2608           0 : SvxFont EditEngine::CreateSvxFontFromItemSet( const SfxItemSet& rItemSet )
    2609             : {
    2610           0 :     SvxFont aFont;
    2611           0 :     CreateFont( aFont, rItemSet );
    2612           0 :     return aFont;
    2613             : }
    2614             : 
    2615           0 : bool EditEngine::DoesKeyMoveCursor( const KeyEvent& rKeyEvent )
    2616             : {
    2617           0 :     bool bDoesMove = false;
    2618             : 
    2619           0 :     switch ( rKeyEvent.GetKeyCode().GetCode() )
    2620             :     {
    2621             :         case KEY_UP:
    2622             :         case KEY_DOWN:
    2623             :         case KEY_LEFT:
    2624             :         case KEY_RIGHT:
    2625             :         case KEY_HOME:
    2626             :         case KEY_END:
    2627             :         case KEY_PAGEUP:
    2628             :         case KEY_PAGEDOWN:
    2629             :         {
    2630           0 :             if ( !rKeyEvent.GetKeyCode().IsMod2() )
    2631           0 :                 bDoesMove = true;
    2632             :         }
    2633           0 :         break;
    2634             :     }
    2635           0 :     return bDoesMove;
    2636             : }
    2637             : 
    2638           0 : bool EditEngine::DoesKeyChangeText( const KeyEvent& rKeyEvent )
    2639             : {
    2640           0 :     bool bDoesChange = false;
    2641             : 
    2642           0 :     KeyFuncType eFunc = rKeyEvent.GetKeyCode().GetFunction();
    2643           0 :     if ( eFunc != KeyFuncType::DONTKNOW )
    2644             :     {
    2645           0 :         switch ( eFunc )
    2646             :         {
    2647             :             case KeyFuncType::UNDO:
    2648             :             case KeyFuncType::REDO:
    2649             :             case KeyFuncType::CUT:
    2650           0 :             case KeyFuncType::PASTE: bDoesChange = true;
    2651           0 :             break;
    2652             :             default:    // is then possibly edited below.
    2653           0 :                         eFunc = KeyFuncType::DONTKNOW;
    2654             :         }
    2655             :     }
    2656           0 :     if ( eFunc == KeyFuncType::DONTKNOW )
    2657             :     {
    2658           0 :         switch ( rKeyEvent.GetKeyCode().GetCode() )
    2659             :         {
    2660             :             case KEY_DELETE:
    2661           0 :             case KEY_BACKSPACE: bDoesChange = true;
    2662           0 :             break;
    2663             :             case KEY_RETURN:
    2664             :             case KEY_TAB:
    2665             :             {
    2666           0 :                 if ( !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
    2667           0 :                     bDoesChange = true;
    2668             :             }
    2669           0 :             break;
    2670             :             default:
    2671             :             {
    2672           0 :                 bDoesChange = IsSimpleCharInput( rKeyEvent );
    2673             :             }
    2674             :         }
    2675             :     }
    2676           0 :     return bDoesChange;
    2677             : }
    2678             : 
    2679           3 : bool EditEngine::IsSimpleCharInput( const KeyEvent& rKeyEvent )
    2680             : {
    2681           9 :     if( EditEngine::IsPrintable( rKeyEvent.GetCharCode() ) &&
    2682           6 :         ( KEY_MOD2 != (rKeyEvent.GetKeyCode().GetModifier() & ~KEY_SHIFT ) ) &&
    2683           3 :         ( KEY_MOD1 != (rKeyEvent.GetKeyCode().GetModifier() & ~KEY_SHIFT ) ) )
    2684             :     {
    2685           3 :         return true;
    2686             :     }
    2687           0 :     return false;
    2688             : }
    2689             : 
    2690           0 : bool EditEngine::HasValidData( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rTransferable )
    2691             : {
    2692           0 :     bool bValidData = false;
    2693             : 
    2694           0 :     if ( rTransferable.is() )
    2695             :     {
    2696             :         // Every application that copies rtf or any other text format also copies plain text into the clipboard....
    2697           0 :         datatransfer::DataFlavor aFlavor;
    2698           0 :         SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor );
    2699           0 :         bValidData = rTransferable->isDataFlavorSupported( aFlavor );
    2700             :     }
    2701             : 
    2702           0 :     return bValidData;
    2703             : }
    2704             : 
    2705             : /** sets a link that is called at the beginning of a drag operation at an edit view */
    2706           0 : void EditEngine::SetBeginDropHdl( const Link<>& rLink )
    2707             : {
    2708           0 :     pImpEditEngine->SetBeginDropHdl( rLink );
    2709           0 : }
    2710             : 
    2711           0 : Link<> EditEngine::GetBeginDropHdl() const
    2712             : {
    2713           0 :     return pImpEditEngine->GetBeginDropHdl();
    2714             : }
    2715             : 
    2716             : /** sets a link that is called at the end of a drag operation at an edit view */
    2717           0 : void EditEngine::SetEndDropHdl( const Link<>& rLink )
    2718             : {
    2719           0 :     pImpEditEngine->SetEndDropHdl( rLink );
    2720           0 : }
    2721             : 
    2722           0 : Link<> EditEngine::GetEndDropHdl() const
    2723             : {
    2724           0 :     return pImpEditEngine->GetEndDropHdl();
    2725             : }
    2726             : 
    2727           0 : void EditEngine::SetFirstWordCapitalization( bool bCapitalize )
    2728             : {
    2729           0 :     pImpEditEngine->SetFirstWordCapitalization( bCapitalize );
    2730           0 : }
    2731             : 
    2732          55 : bool EditEngine::IsImportHandlerSet() const
    2733             : {
    2734          55 :     return pImpEditEngine->aImportHdl.IsSet();
    2735             : }
    2736             : 
    2737           0 : bool EditEngine::IsImportRTFStyleSheetsSet() const
    2738             : {
    2739           0 :     return pImpEditEngine->GetStatus().DoImportRTFStyleSheets();
    2740             : }
    2741             : 
    2742          55 : void EditEngine::CallImportHandler(ImportInfo& rInfo)
    2743             : {
    2744          55 :     pImpEditEngine->aImportHdl.Call(&rInfo);
    2745          55 : }
    2746             : 
    2747           6 : EditPaM EditEngine::InsertParaBreak(
    2748             :         const EditSelection& rEditSelection, bool bKeepEndingAttribs)
    2749             : {
    2750           6 :     return pImpEditEngine->ImpInsertParaBreak(rEditSelection, bKeepEndingAttribs);
    2751             : }
    2752             : 
    2753           0 : EditPaM EditEngine::InsertLineBreak(const EditSelection& rEditSelection)
    2754             : {
    2755           0 :     return pImpEditEngine->InsertLineBreak(rEditSelection);
    2756             : }
    2757             : 
    2758          16 : EFieldInfo::EFieldInfo()
    2759             : {
    2760          16 :     pFieldItem = NULL;
    2761          16 : }
    2762             : 
    2763             : 
    2764          30 : EFieldInfo::EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos ) : aPosition( nPara, nPos )
    2765             : {
    2766          30 :     pFieldItem = new SvxFieldItem( rFieldItem );
    2767          30 : }
    2768             : 
    2769         152 : EFieldInfo::~EFieldInfo()
    2770             : {
    2771          76 :     delete pFieldItem;
    2772          76 : }
    2773             : 
    2774          30 : EFieldInfo::EFieldInfo( const EFieldInfo& rFldInfo )
    2775          30 :     : pFieldItem(0)
    2776             : {
    2777          30 :     *this = rFldInfo;
    2778          30 : }
    2779             : 
    2780          30 : EFieldInfo& EFieldInfo::operator= ( const EFieldInfo& rFldInfo )
    2781             : {
    2782          30 :     if( this == &rFldInfo )
    2783           0 :         return *this;
    2784             : 
    2785          30 :     pFieldItem = rFldInfo.pFieldItem ? new SvxFieldItem( *rFldInfo.pFieldItem ) : 0;
    2786          30 :     aCurrentText = rFldInfo.aCurrentText;
    2787          30 :     aPosition = rFldInfo.aPosition;
    2788             : 
    2789          30 :     return *this;
    2790             : }
    2791             : 
    2792             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11