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

Generated by: LCOV version 1.10