LCOV - code coverage report
Current view: top level - editeng/source/editeng - editeng.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 713 1360 52.4 %
Date: 2014-04-11 Functions: 169 283 59.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <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       25815 : EditEngine::EditEngine( SfxItemPool* pItemPool )
      97             : {
      98       25815 :     pImpEditEngine = new ImpEditEngine( this, pItemPool );
      99       25815 : }
     100             : 
     101       24133 : EditEngine::~EditEngine()
     102             : {
     103       24100 :     delete pImpEditEngine;
     104       24133 : }
     105             : 
     106     1362126 : void EditEngine::EnableUndo( bool bEnable )
     107             : {
     108     1362126 :     pImpEditEngine->EnableUndo( bEnable );
     109     1362126 : }
     110             : 
     111     1860962 : bool EditEngine::IsUndoEnabled()
     112             : {
     113     1860962 :     return pImpEditEngine->IsUndoEnabled();
     114             : }
     115             : 
     116     2123409 : bool EditEngine::IsInUndo()
     117             : {
     118     2123409 :     return pImpEditEngine->IsInUndo();
     119             : }
     120             : 
     121      516474 : ::svl::IUndoManager& EditEngine::GetUndoManager()
     122             : {
     123      516474 :     return pImpEditEngine->GetUndoManager();
     124             : }
     125             : 
     126           0 : ::svl::IUndoManager* EditEngine::SetUndoManager(::svl::IUndoManager* pNew)
     127             : {
     128           0 :     return pImpEditEngine->SetUndoManager(pNew);
     129             : }
     130             : 
     131       61966 : void EditEngine::UndoActionStart( sal_uInt16 nId )
     132             : {
     133             :     DBG_ASSERT( !pImpEditEngine->IsInUndo(), "Calling UndoActionStart in Undomode!" );
     134       61966 :     if ( !pImpEditEngine->IsInUndo() )
     135       61966 :         pImpEditEngine->UndoActionStart( nId );
     136       61966 : }
     137             : 
     138           0 : void EditEngine::UndoActionStart(sal_uInt16 nId, const ESelection& rSel)
     139             : {
     140           0 :     pImpEditEngine->UndoActionStart(nId, rSel);
     141           0 : }
     142             : 
     143       61966 : void EditEngine::UndoActionEnd( sal_uInt16 nId )
     144             : {
     145             :     DBG_ASSERT( !pImpEditEngine->IsInUndo(), "Calling UndoActionEnd in Undomode!" );
     146       61966 :     if ( !pImpEditEngine->IsInUndo() )
     147       61966 :         pImpEditEngine->UndoActionEnd( nId );
     148       61966 : }
     149             : 
     150           0 : bool EditEngine::HasTriedMergeOnLastAddUndo() const
     151             : {
     152           0 :     return pImpEditEngine->mbLastTryMerge;
     153             : }
     154             : 
     155       23520 : void EditEngine::SetRefDevice( OutputDevice* pRefDev )
     156             : {
     157       23520 :     pImpEditEngine->SetRefDevice( pRefDev );
     158       23520 : }
     159             : 
     160        1676 : OutputDevice* EditEngine::GetRefDevice() const
     161             : {
     162        1676 :     return pImpEditEngine->GetRefDevice();
     163             : }
     164             : 
     165       18294 : void EditEngine::SetRefMapMode( const MapMode& rMapMode )
     166             : {
     167       18294 :     pImpEditEngine->SetRefMapMode( rMapMode );
     168       18294 : }
     169             : 
     170         207 : MapMode EditEngine::GetRefMapMode()
     171             : {
     172         207 :     return pImpEditEngine->GetRefMapMode();
     173             : }
     174             : 
     175       39125 : void EditEngine::SetBackgroundColor( const Color& rColor )
     176             : {
     177       39125 :     pImpEditEngine->SetBackgroundColor( rColor );
     178       39125 : }
     179             : 
     180       78611 : Color EditEngine::GetBackgroundColor() const
     181             : {
     182       78611 :     return pImpEditEngine->GetBackgroundColor();
     183             : }
     184             : 
     185        1307 : Color EditEngine::GetAutoColor() const
     186             : {
     187        1307 :     return pImpEditEngine->GetAutoColor();
     188             : }
     189             : 
     190        3887 : void EditEngine::EnableAutoColor( bool b )
     191             : {
     192        3887 :     pImpEditEngine->EnableAutoColor( b );
     193        3887 : }
     194             : 
     195           0 : void EditEngine::ForceAutoColor( bool b )
     196             : {
     197           0 :     pImpEditEngine->ForceAutoColor( b );
     198           0 : }
     199             : 
     200          91 : bool EditEngine::IsForceAutoColor() const
     201             : {
     202          91 :     return pImpEditEngine->IsForceAutoColor();
     203             : }
     204             : 
     205       10889 : const SfxItemSet& EditEngine::GetEmptyItemSet()
     206             : {
     207       10889 :     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         771 : 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         771 :     Rectangle aBigRect( -0x3FFFFFFF, -0x3FFFFFFF, 0x3FFFFFFF, 0x3FFFFFFF );
     220         771 :     if( pOutDev->GetConnectMetaFile() )
     221           0 :         pOutDev->Push();
     222         771 :     Point aStartPos( rStartPos );
     223         771 :     if ( IsVertical() )
     224             :     {
     225           0 :         aStartPos.X() += GetPaperSize().Width();
     226           0 :         aStartPos = Rotate( aStartPos, nOrientation, rStartPos );
     227             :     }
     228         771 :     pImpEditEngine->Paint( pOutDev, aBigRect, aStartPos, sal_False, nOrientation );
     229         771 :     if( pOutDev->GetConnectMetaFile() )
     230           0 :         pOutDev->Pop();
     231         771 : }
     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          64 : 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, sal_False );
     244             : #endif
     245             : 
     246             :     // Align to the pixel boundary, so that it becomes exactly the same
     247             :     // as Paint ()
     248          64 :     Rectangle aOutRect( pOutDev->LogicToPixel( rOutRect ) );
     249          64 :     aOutRect = pOutDev->PixelToLogic( aOutRect );
     250             : 
     251          64 :     Point aStartPos;
     252          64 :     if ( !IsVertical() )
     253             :     {
     254          64 :         aStartPos.X() = aOutRect.Left() - rStartDocPos.X();
     255          64 :         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          64 :     bool bClipRegion = pOutDev->IsClipRegion();
     264          64 :     bool bMetafile = pOutDev->GetConnectMetaFile();
     265          64 :     Region aOldRegion = pOutDev->GetClipRegion();
     266             : 
     267             :     // If one existed => intersection!
     268             :     // Use Push/pop for creating the Meta file
     269          64 :     if ( bMetafile )
     270           0 :         pOutDev->Push();
     271             : 
     272             :     // Always use the Intersect method, it is a must for Metafile!
     273          64 :     if ( bClip )
     274             :     {
     275             :         // Clip only if neccesary...
     276         256 :         if ( !rStartDocPos.X() && !rStartDocPos.Y() &&
     277         192 :              ( rOutRect.GetHeight() >= (long)GetTextHeight() ) &&
     278          64 :              ( rOutRect.GetWidth() >= (long)CalcTextWidth() ) )
     279             :         {
     280          64 :             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          64 :     pImpEditEngine->Paint( pOutDev, aOutRect, aStartPos );
     299             : 
     300          64 :     if ( bMetafile )
     301           0 :         pOutDev->Pop();
     302          64 :     else if ( bClipRegion )
     303          64 :         pOutDev->SetClipRegion( aOldRegion );
     304             :     else
     305           0 :         pOutDev->SetClipRegion();
     306          64 : }
     307             : 
     308         301 : void EditEngine::InsertView(EditView* pEditView, size_t nIndex)
     309             : {
     310             : 
     311         301 :     if ( nIndex > pImpEditEngine->GetEditViews().size() )
     312         301 :         nIndex = pImpEditEngine->GetEditViews().size();
     313             : 
     314         301 :     ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
     315         301 :     rViews.insert(rViews.begin()+nIndex, pEditView);
     316             : 
     317         301 :     EditSelection aStartSel;
     318         301 :     aStartSel = pImpEditEngine->GetEditDoc().GetStartPaM();
     319         301 :     pEditView->pImpEditView->SetEditSelection( aStartSel );
     320         301 :     if ( !pImpEditEngine->GetActiveView() )
     321         297 :         pImpEditEngine->SetActiveView( pEditView );
     322             : 
     323         301 :     pEditView->pImpEditView->AddDragAndDropListeners();
     324         301 : }
     325             : 
     326          45 : EditView* EditEngine::RemoveView( EditView* pView )
     327             : {
     328             : 
     329          45 :     pView->HideCursor();
     330          45 :     EditView* pRemoved = NULL;
     331          45 :     ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
     332          45 :     ImpEditEngine::ViewsType::iterator it = std::find(rViews.begin(), rViews.end(), pView);
     333             : 
     334             :     DBG_ASSERT( it != rViews.end(), "RemoveView with invalid index" );
     335          45 :     if (it != rViews.end())
     336             :     {
     337          45 :         pRemoved = *it;
     338          45 :         rViews.erase(it);
     339          45 :         if ( pImpEditEngine->GetActiveView() == pView )
     340             :         {
     341          41 :             pImpEditEngine->SetActiveView( 0 );
     342          41 :             pImpEditEngine->GetSelEngine().SetCurView( 0 );
     343             :         }
     344          45 :         pView->pImpEditView->RemoveDragAndDropListeners();
     345             : 
     346             :     }
     347          45 :     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         120 : EditView* EditEngine::GetView(size_t nIndex) const
     363             : {
     364         120 :     return pImpEditEngine->GetEditViews()[nIndex];
     365             : }
     366             : 
     367         303 : size_t EditEngine::GetViewCount() const
     368             : {
     369         303 :     return pImpEditEngine->GetEditViews().size();
     370             : }
     371             : 
     372        1517 : bool EditEngine::HasView( EditView* pView ) const
     373             : {
     374        1517 :     ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
     375        1517 :     return std::find(rViews.begin(), rViews.end(), pView) != rViews.end();
     376             : }
     377             : 
     378          19 : EditView* EditEngine::GetActiveView() const
     379             : {
     380          19 :     return pImpEditEngine->GetActiveView();
     381             : }
     382             : 
     383           0 : void EditEngine::SetActiveView(EditView* pView)
     384             : {
     385           0 :     pImpEditEngine->SetActiveView(pView);
     386           0 : }
     387             : 
     388       24313 : void EditEngine::SetDefTab( sal_uInt16 nDefTab )
     389             : {
     390       24313 :     pImpEditEngine->GetEditDoc().SetDefTab( nDefTab );
     391       24313 :     if ( pImpEditEngine->IsFormatted() )
     392             :     {
     393       24284 :         pImpEditEngine->FormatFullDoc();
     394       24284 :         pImpEditEngine->UpdateViews( (EditView*) 0 );
     395             :     }
     396       24313 : }
     397             : 
     398      509465 : void EditEngine::SetPaperSize( const Size& rNewSize )
     399             : {
     400             : 
     401      509465 :     Size aOldSize( pImpEditEngine->GetPaperSize() );
     402      509465 :     pImpEditEngine->SetValidPaperSize( rNewSize );
     403      509465 :     Size aNewSize( pImpEditEngine->GetPaperSize() );
     404             : 
     405      509465 :     bool bAutoPageSize = pImpEditEngine->GetStatus().AutoPageSize();
     406      509465 :     if ( bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() ) )
     407             :     {
     408      218985 :         for (size_t nView = 0; nView < pImpEditEngine->aEditViews.size(); ++nView)
     409             :         {
     410         256 :             EditView* pView = pImpEditEngine->aEditViews[nView];
     411         256 :             if ( bAutoPageSize )
     412           0 :                 pView->pImpEditView->RecalcOutputArea();
     413         256 :             else if ( pView->pImpEditView->DoAutoSize() )
     414             :             {
     415             :                 pView->pImpEditView->ResetOutputArea( Rectangle(
     416           0 :                     pView->pImpEditView->GetOutputArea().TopLeft(), aNewSize ) );
     417             :             }
     418             :         }
     419             : 
     420      218729 :         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      127060 :             pImpEditEngine->FormatFullDoc();
     426             : 
     427      127060 :             pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
     428             : 
     429      127060 :             if ( pImpEditEngine->GetUpdateMode() && pImpEditEngine->GetActiveView() )
     430         256 :                 pImpEditEngine->pActiveView->ShowCursor( false, false );
     431             :         }
     432             :     }
     433      509465 : }
     434             : 
     435       11340 : const Size& EditEngine::GetPaperSize() const
     436             : {
     437       11340 :     return pImpEditEngine->GetPaperSize();
     438             : }
     439             : 
     440        8382 : void EditEngine::SetVertical( bool bVertical )
     441             : {
     442        8382 :     pImpEditEngine->SetVertical( bVertical );
     443        8382 : }
     444             : 
     445      254298 : bool EditEngine::IsVertical() const
     446             : {
     447      254298 :     return pImpEditEngine->IsVertical();
     448             : }
     449             : 
     450      105982 : void EditEngine::SetFixedCellHeight( bool bUseFixedCellHeight )
     451             : {
     452      105982 :     pImpEditEngine->SetFixedCellHeight( bUseFixedCellHeight );
     453      105982 : }
     454             : 
     455       30783 : void EditEngine::SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir )
     456             : {
     457       30783 :     pImpEditEngine->SetDefaultHorizontalTextDirection( eHTextDir );
     458       30783 : }
     459             : 
     460       13622 : EEHorizontalTextDirection EditEngine::GetDefaultHorizontalTextDirection() const
     461             : {
     462       13622 :     return pImpEditEngine->GetDefaultHorizontalTextDirection();
     463             : }
     464             : 
     465        1398 : sal_uInt16 EditEngine::GetScriptType( const ESelection& rSelection ) const
     466             : {
     467        1398 :     EditSelection aSel( pImpEditEngine->CreateSel( rSelection ) );
     468        1398 :     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          16 : LanguageType EditEngine::GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const
     477             : {
     478          16 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
     479             :     DBG_ASSERT( pNode, "GetLanguage - nPara is invalid!" );
     480          16 :     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       41578 : void EditEngine::SetAsianCompressionMode( sal_uInt16 n )
     495             : {
     496       41578 :     pImpEditEngine->SetAsianCompressionMode( n );
     497       41578 : }
     498             : 
     499       41578 : void EditEngine::SetKernAsianPunctuation( bool b )
     500             : {
     501       41578 :     pImpEditEngine->SetKernAsianPunctuation( b );
     502       41578 : }
     503             : 
     504       40364 : void EditEngine::SetAddExtLeading( bool b )
     505             : {
     506       40364 :     pImpEditEngine->SetAddExtLeading( b );
     507       40364 : }
     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      333504 : void EditEngine::ClearPolygon()
     533             : {
     534      333504 :     pImpEditEngine->SetTextRanger( 0 );
     535      333504 : }
     536             : 
     537           0 : const Size& EditEngine::GetMinAutoPaperSize() const
     538             : {
     539           0 :     return pImpEditEngine->GetMinAutoPaperSize();
     540             : }
     541             : 
     542      345224 : void EditEngine::SetMinAutoPaperSize( const Size& rSz )
     543             : {
     544      345224 :     pImpEditEngine->SetMinAutoPaperSize( rSz );
     545      345224 : }
     546             : 
     547           0 : const Size& EditEngine::GetMaxAutoPaperSize() const
     548             : {
     549           0 :     return pImpEditEngine->GetMaxAutoPaperSize();
     550             : }
     551             : 
     552      352006 : void EditEngine::SetMaxAutoPaperSize( const Size& rSz )
     553             : {
     554      352006 :     pImpEditEngine->SetMaxAutoPaperSize( rSz );
     555      352006 : }
     556             : 
     557        1133 : OUString EditEngine::GetText( LineEnd eEnd ) const
     558             : {
     559        1133 :     return pImpEditEngine->GetEditDoc().GetText( eEnd );
     560             : }
     561             : 
     562        2249 : OUString EditEngine::GetText( const ESelection& rESelection, const LineEnd eEnd ) const
     563             : {
     564        2249 :     EditSelection aSel( pImpEditEngine->CreateSel( rESelection ) );
     565        2249 :     return pImpEditEngine->GetSelected( aSel, eEnd );
     566             : }
     567             : 
     568          36 : sal_uInt32 EditEngine::GetTextLen() const
     569             : {
     570          36 :     return pImpEditEngine->GetEditDoc().GetTextLen();
     571             : }
     572             : 
     573      133942 : sal_Int32 EditEngine::GetParagraphCount() const
     574             : {
     575      133942 :     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         132 : sal_uInt32 EditEngine::GetTextHeight( sal_Int32 nParagraph ) const
     615             : {
     616             : 
     617         132 :     if ( !pImpEditEngine->IsFormatted() )
     618           0 :         pImpEditEngine->FormatDoc();
     619             : 
     620         132 :     sal_uInt32 nHeight = pImpEditEngine->GetParaHeight( nParagraph );
     621         132 :      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         134 : void EditEngine::CursorMoved(ContentNode* pPrevNode)
     643             : {
     644         134 :     pImpEditEngine->CursorMoved(pPrevNode);
     645         134 : }
     646             : 
     647        1912 : void EditEngine::CheckIdleFormatter()
     648             : {
     649        1912 :     pImpEditEngine->CheckIdleFormatter();
     650        1912 : }
     651             : 
     652           0 : bool EditEngine::IsIdleFormatterActive() const
     653             : {
     654           0 :     return pImpEditEngine->aIdleFormatter.IsActive();
     655             : }
     656             : 
     657         270 : ParaPortion* EditEngine::FindParaPortion(ContentNode* pNode)
     658             : {
     659         270 :     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           0 : void EditEngine::RemoveCharAttribs(sal_Int32 nPara, sal_uInt16 nWhich, bool bRemoveFeatures)
     728             : {
     729           0 :     pImpEditEngine->RemoveCharAttribs(nPara, nWhich, bRemoveFeatures);
     730           0 : }
     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           6 : void EditEngine::SetUndoMode(bool b)
     748             : {
     749           6 :     pImpEditEngine->SetUndoMode(b);
     750           6 : }
     751             : 
     752         104 : void EditEngine::FormatAndUpdate(EditView* pCurView)
     753             : {
     754         104 :     pImpEditEngine->FormatAndUpdate(pCurView);
     755         104 : }
     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           4 : EditPaM EditEngine::CreateEditPaM(const EPaM& rEPaM)
     778             : {
     779           4 :     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           0 : EditPaM EditEngine::InsertField(const EditSelection& rEditSelection, const SvxFieldItem& rFld)
     789             : {
     790           0 :     return pImpEditEngine->InsertField(rEditSelection, rFld);
     791             : }
     792             : 
     793          19 : EditPaM EditEngine::InsertText(const EditSelection& aCurEditSelection, const OUString& rStr)
     794             : {
     795          19 :     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          16 : long EditEngine::GetXPos(
     827             :         const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart) const
     828             : {
     829          16 :     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        1777 : bool EditEngine::IsFormatted() const
     839             : {
     840        1777 :     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           4 : sal_uInt16 EditEngine::GetOnePixelInRef() const
     854             : {
     855           4 :     return pImpEditEngine->nOnePixelInRef;
     856             : }
     857             : 
     858           6 : InternalEditStatus& EditEngine::GetInternalEditStatus()
     859             : {
     860           6 :     return pImpEditEngine->GetStatus();
     861             : }
     862             : 
     863        2802 : EditDoc& EditEngine::GetEditDoc()
     864             : {
     865        2802 :     return pImpEditEngine->GetEditDoc();
     866             : }
     867             : 
     868           0 : const EditDoc& EditEngine::GetEditDoc() const
     869             : {
     870           0 :     return pImpEditEngine->GetEditDoc();
     871             : }
     872             : 
     873        1433 : ParaPortionList& EditEngine::GetParaPortions()
     874             : {
     875        1433 :     return pImpEditEngine->GetParaPortions();
     876             : }
     877             : 
     878           0 : const ParaPortionList& EditEngine::GetParaPortions() const
     879             : {
     880           0 :     return pImpEditEngine->GetParaPortions();
     881             : }
     882             : 
     883        1417 : void EditEngine::SeekCursor(
     884             :         ContentNode* pNode, sal_Int32 nPos, SvxFont& rFont, OutputDevice* pOut, sal_uInt16 nIgnoreWhich)
     885             : {
     886        1417 :     pImpEditEngine->SeekCursor(pNode, nPos, rFont, pOut, nIgnoreWhich);
     887        1417 : }
     888             : 
     889           2 : EditPaM EditEngine::DeleteSelection(const EditSelection& rSel)
     890             : {
     891           2 :     return pImpEditEngine->ImpDeleteSelection(rSel);
     892             : }
     893             : 
     894          55 : ESelection EditEngine::CreateESelection(const EditSelection& rSel)
     895             : {
     896          55 :     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           1 : void EditEngine::SetParaAttribsOnly(sal_Int32 nPara, const SfxItemSet& rSet)
     910             : {
     911           1 :     pImpEditEngine->SetParaAttribs(nPara, rSet);
     912           1 : }
     913             : 
     914          97 : void EditEngine::SetAttribs(const EditSelection& rSel, const SfxItemSet& rSet, sal_uInt8 nSpecial)
     915             : {
     916          97 :     pImpEditEngine->SetAttribs(rSel, rSet, nSpecial);
     917          97 : }
     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, 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 != KEYFUNC_DONTKNOW )
     978             :     {
     979           0 :         switch ( eFunc )
     980             :         {
     981             :             case KEYFUNC_UNDO:
     982             :             {
     983           0 :                 if ( !bReadOnly )
     984           0 :                     pEditView->Undo();
     985           0 :                 return true;
     986             :             }
     987             :             // break;
     988             :             case KEYFUNC_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 = KEYFUNC_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 == KEYFUNC_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, sal_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( (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(), sal_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, sal_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      167063 : sal_uInt32 EditEngine::GetTextHeight() const
    1412             : {
    1413             : 
    1414      167063 :     if ( !pImpEditEngine->IsFormatted() )
    1415           1 :         pImpEditEngine->FormatDoc();
    1416             : 
    1417      167063 :     sal_uInt32 nHeight = !IsVertical() ? pImpEditEngine->GetTextHeight() : pImpEditEngine->CalcTextWidth( sal_True );
    1418      167063 :     return nHeight;
    1419             : }
    1420             : 
    1421          60 : sal_uInt32 EditEngine::GetTextHeightNTP() const
    1422             : {
    1423             : 
    1424          60 :     if ( !pImpEditEngine->IsFormatted() )
    1425           0 :         pImpEditEngine->FormatDoc();
    1426             : 
    1427          60 :     if ( IsVertical() )
    1428           0 :         return pImpEditEngine->CalcTextWidth( sal_True );
    1429             : 
    1430          60 :     return pImpEditEngine->GetTextHeightNTP();
    1431             : }
    1432             : 
    1433       74510 : sal_uInt32 EditEngine::CalcTextWidth()
    1434             : {
    1435             : 
    1436       74510 :     if ( !pImpEditEngine->IsFormatted() )
    1437           0 :         pImpEditEngine->FormatDoc();
    1438             : 
    1439       74510 :     sal_uInt32 nWidth = !IsVertical() ? pImpEditEngine->CalcTextWidth( sal_True ) : pImpEditEngine->GetTextHeight();
    1440       74510 :      return nWidth;
    1441             : }
    1442             : 
    1443     1962531 : void EditEngine::SetUpdateMode( bool bUpdate )
    1444             : {
    1445     1962531 :     pImpEditEngine->SetUpdateMode( bUpdate );
    1446     1962531 :     if ( pImpEditEngine->pActiveView )
    1447         521 :         pImpEditEngine->pActiveView->ShowCursor( false, false );
    1448     1962531 : }
    1449             : 
    1450      735529 : bool EditEngine::GetUpdateMode() const
    1451             : {
    1452      735529 :     return pImpEditEngine->GetUpdateMode();
    1453             : }
    1454             : 
    1455      163646 : void EditEngine::Clear()
    1456             : {
    1457      163646 :     pImpEditEngine->Clear();
    1458      163646 : }
    1459             : 
    1460        8167 : void EditEngine::SetText( const OUString& rText )
    1461             : {
    1462        8167 :     pImpEditEngine->SetText( rText );
    1463        8167 :     if ( !rText.isEmpty() )
    1464        3322 :         pImpEditEngine->FormatAndUpdate();
    1465        8167 : }
    1466             : 
    1467           1 : sal_uLong EditEngine::Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs /* = NULL */ )
    1468             : {
    1469           1 :     bool bUndoEnabled = pImpEditEngine->IsUndoEnabled();
    1470           1 :     pImpEditEngine->EnableUndo( false );
    1471           1 :     pImpEditEngine->SetText( OUString() );
    1472           1 :     EditPaM aPaM( pImpEditEngine->GetEditDoc().GetStartPaM() );
    1473           1 :     pImpEditEngine->Read( rInput, rBaseURL, eFormat, EditSelection( aPaM, aPaM ), pHTTPHeaderAttrs );
    1474           1 :     pImpEditEngine->EnableUndo( bUndoEnabled );
    1475           1 :     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        9526 : EditTextObject* EditEngine::CreateTextObject()
    1487             : {
    1488        9526 :     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      163806 : void EditEngine::SetText( const EditTextObject& rTextObject )
    1498             : {
    1499      163806 :     pImpEditEngine->EnterBlockNotifications();
    1500      163806 :     pImpEditEngine->SetText( rTextObject );
    1501      163806 :     pImpEditEngine->FormatAndUpdate();
    1502      163806 :     pImpEditEngine->LeaveBlockNotifications();
    1503      163806 : }
    1504             : 
    1505           0 : void EditEngine::ShowParagraph( sal_Int32 nParagraph, bool bShow )
    1506             : {
    1507           0 :     pImpEditEngine->ShowParagraph( nParagraph, bShow );
    1508           0 : }
    1509             : 
    1510        5315 : void EditEngine::SetNotifyHdl( const Link& rLink )
    1511             : {
    1512        5315 :     pImpEditEngine->SetNotifyHdl( rLink );
    1513        5315 : }
    1514             : 
    1515      949360 : Link EditEngine::GetNotifyHdl() const
    1516             : {
    1517      949360 :     return pImpEditEngine->GetNotifyHdl();
    1518             : }
    1519             : 
    1520         966 : void EditEngine::SetStatusEventHdl( const Link& rLink )
    1521             : {
    1522         966 :     pImpEditEngine->SetStatusEventHdl( rLink );
    1523         966 : }
    1524             : 
    1525         214 : Link EditEngine::GetStatusEventHdl() const
    1526             : {
    1527         214 :     return pImpEditEngine->GetStatusEventHdl();
    1528             : }
    1529             : 
    1530           2 : void EditEngine::SetImportHdl( const Link& rLink )
    1531             : {
    1532           2 :     pImpEditEngine->aImportHdl = rLink;
    1533           2 : }
    1534             : 
    1535           1 : Link EditEngine::GetImportHdl() const
    1536             : {
    1537           1 :     return pImpEditEngine->aImportHdl;
    1538             : }
    1539             : 
    1540       18940 : void EditEngine::SetBeginMovingParagraphsHdl( const Link& rLink )
    1541             : {
    1542       18940 :     pImpEditEngine->aBeginMovingParagraphsHdl = rLink;
    1543       18940 : }
    1544             : 
    1545       18940 : void EditEngine::SetEndMovingParagraphsHdl( const Link& rLink )
    1546             : {
    1547       18940 :     pImpEditEngine->aEndMovingParagraphsHdl = rLink;
    1548       18940 : }
    1549             : 
    1550       18940 : void EditEngine::SetBeginPasteOrDropHdl( const Link& rLink )
    1551             : {
    1552             : 
    1553       18940 :     pImpEditEngine->aBeginPasteOrDropHdl = rLink;
    1554       18940 : }
    1555             : 
    1556       18940 : void EditEngine::SetEndPasteOrDropHdl( const Link& rLink )
    1557             : {
    1558       18940 :     pImpEditEngine->aEndPasteOrDropHdl = rLink;
    1559       18940 : }
    1560             : 
    1561       65441 : 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       65441 :     ContentNode* pStartNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    1567       65441 :     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       65441 :     if ( pStartNode && pEndNode )
    1572             :     {
    1573       65441 :         EditSelection aTmpSel;
    1574       65441 :         aTmpSel.Min() = EditPaM( pStartNode, 0 );
    1575       65441 :         aTmpSel.Max() = EditPaM( pEndNode, pEndNode->Len() );
    1576       65441 :         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      523122 : sal_Int32 EditEngine::GetTextLen( sal_Int32 nPara ) const
    1601             : {
    1602      523122 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    1603             :     DBG_ASSERT( pNode, "Paragraph not found: GetTextLen" );
    1604      523122 :     if ( pNode )
    1605      523122 :         return pNode->Len();
    1606           0 :     return 0;
    1607             : }
    1608             : 
    1609       17443 : OUString EditEngine::GetText( sal_Int32 nPara ) const
    1610             : {
    1611       17443 :     OUString aStr;
    1612       17443 :     if ( 0 <= nPara && nPara < pImpEditEngine->GetEditDoc().Count() )
    1613       17443 :         aStr = pImpEditEngine->GetEditDoc().GetParaAsString( nPara );
    1614       17443 :     return aStr;
    1615             : }
    1616             : 
    1617         777 : void EditEngine::SetModifyHdl( const Link& rLink )
    1618             : {
    1619         777 :     pImpEditEngine->SetModifyHdl( rLink );
    1620         777 : }
    1621             : 
    1622          48 : Link EditEngine::GetModifyHdl() const
    1623             : {
    1624          48 :     return pImpEditEngine->GetModifyHdl();
    1625             : }
    1626             : 
    1627             : 
    1628          85 : void EditEngine::ClearModifyFlag()
    1629             : {
    1630          85 :     pImpEditEngine->SetModifyFlag( sal_False );
    1631          85 : }
    1632             : 
    1633           4 : void EditEngine::SetModified()
    1634             : {
    1635           4 :     pImpEditEngine->SetModifyFlag( sal_True );
    1636           4 : }
    1637             : 
    1638          25 : bool EditEngine::IsModified() const
    1639             : {
    1640          25 :     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         873 : void EditEngine::InsertParagraph(sal_Int32 nPara, const OUString& rTxt)
    1672             : {
    1673         873 :     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         873 :     pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
    1680         873 :     EditPaM aPaM( pImpEditEngine->InsertParagraph( nPara ) );
    1681             :     // When InsertParagraph from the outside, no hard attributes
    1682             :     // should be taken over!
    1683         873 :     pImpEditEngine->RemoveCharAttribs( nPara );
    1684         873 :     pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
    1685         873 :     pImpEditEngine->ImpInsertText( EditSelection( aPaM, aPaM ), rTxt );
    1686         873 :     pImpEditEngine->FormatAndUpdate();
    1687         873 : }
    1688             : 
    1689       17677 : void EditEngine::SetText(sal_Int32 nPara, const OUString& rTxt)
    1690             : {
    1691       17677 :     EditSelection* pSel = pImpEditEngine->SelectParagraph( nPara );
    1692       17677 :     if ( pSel )
    1693             :     {
    1694       17677 :         pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
    1695       17677 :         pImpEditEngine->ImpInsertText( *pSel, rTxt );
    1696       17677 :         pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
    1697       17677 :         pImpEditEngine->FormatAndUpdate();
    1698       17677 :         delete pSel;
    1699             :     }
    1700       17677 : }
    1701             : 
    1702      598870 : void EditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
    1703             : {
    1704      598870 :     pImpEditEngine->SetParaAttribs( nPara, rSet );
    1705      598870 :     pImpEditEngine->FormatAndUpdate();
    1706      598870 : }
    1707             : 
    1708      630342 : const SfxItemSet& EditEngine::GetParaAttribs( sal_Int32 nPara ) const
    1709             : {
    1710      630342 :     return pImpEditEngine->GetParaAttribs( nPara );
    1711             : }
    1712             : 
    1713        9731 : bool EditEngine::HasParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const
    1714             : {
    1715        9731 :     return pImpEditEngine->HasParaAttrib( nPara, nWhich );
    1716             : }
    1717             : 
    1718       64817 : const SfxPoolItem& EditEngine::GetParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich )
    1719             : {
    1720       64817 :     return pImpEditEngine->GetParaAttrib( nPara, nWhich );
    1721             : }
    1722             : 
    1723         237 : void EditEngine::GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const
    1724             : {
    1725         237 :     pImpEditEngine->GetCharAttribs( nPara, rLst );
    1726         237 : }
    1727             : 
    1728        2031 : SfxItemSet EditEngine::GetAttribs( const ESelection& rSel, EditEngineAttribs nOnlyHardAttrib )
    1729             : {
    1730             :     EditSelection aSel( pImpEditEngine->
    1731        2031 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    1732        2031 :     return pImpEditEngine->GetAttribs( aSel, nOnlyHardAttrib );
    1733             : }
    1734             : 
    1735       14363 : SfxItemSet EditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt8 nFlags ) const
    1736             : {
    1737       14363 :     return pImpEditEngine->GetAttribs( nPara, nStart, nEnd, nFlags );
    1738             : }
    1739             : 
    1740         561 : void EditEngine::RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich )
    1741             : {
    1742             : 
    1743         561 :     pImpEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS );
    1744         561 :     EditSelection aSel( pImpEditEngine->ConvertSelection( rSelection.nStartPara, rSelection.nStartPos, rSelection.nEndPara, rSelection.nEndPos ) );
    1745         561 :     pImpEditEngine->RemoveCharAttribs( aSel, bRemoveParaAttribs, nWhich  );
    1746         561 :     pImpEditEngine->UndoActionEnd( EDITUNDO_RESETATTRIBS );
    1747         561 :     pImpEditEngine->FormatAndUpdate();
    1748         561 : }
    1749             : 
    1750           0 : 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        9255 : void EditEngine::StripPortions()
    1762             : {
    1763        9255 :     VirtualDevice aTmpDev;
    1764        9255 :     Rectangle aBigRect( Point( 0, 0 ), Size( 0x7FFFFFFF, 0x7FFFFFFF ) );
    1765        9255 :     if ( IsVertical() )
    1766             :     {
    1767           2 :         aBigRect.Right() = 0;
    1768           2 :         aBigRect.Left() = -0x7FFFFFFF;
    1769             :     }
    1770        9255 :     pImpEditEngine->Paint( &aTmpDev, aBigRect, Point(), sal_True );
    1771        9255 : }
    1772             : 
    1773         928 : void EditEngine::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList )
    1774             : {
    1775         928 :     if ( !pImpEditEngine->IsFormatted() )
    1776           6 :         pImpEditEngine->FormatFullDoc();
    1777             : 
    1778         928 :     const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara );
    1779         928 :     if ( pParaPortion )
    1780             :     {
    1781         928 :         sal_Int32 nEnd = 0;
    1782         928 :         sal_Int32 nTextPortions = pParaPortion->GetTextPortions().Count();
    1783        2199 :         for ( sal_Int32 n = 0; n < nTextPortions; n++ )
    1784             :         {
    1785        1271 :             nEnd = nEnd + pParaPortion->GetTextPortions()[n]->GetLen();
    1786        1271 :             rList.push_back( nEnd );
    1787             :         }
    1788             :     }
    1789         928 : }
    1790             : 
    1791           0 : void EditEngine::SetFlatMode( bool bFlat)
    1792             : {
    1793           0 :     pImpEditEngine->SetFlatMode( bFlat );
    1794           0 : }
    1795             : 
    1796        2796 : bool EditEngine::IsFlatMode() const
    1797             : {
    1798        2796 :     return !( pImpEditEngine->aStatus.UseCharAttribs() );
    1799             : }
    1800             : 
    1801      873261 : void EditEngine::SetControlWord( sal_uInt32 nWord )
    1802             : {
    1803             : 
    1804      873261 :     if ( nWord != pImpEditEngine->aStatus.GetControlWord() )
    1805             :     {
    1806       32725 :         sal_uInt32 nPrev = pImpEditEngine->aStatus.GetControlWord();
    1807       32725 :         pImpEditEngine->aStatus.GetControlWord() = nWord;
    1808             : 
    1809       32725 :         sal_uInt32 nChanges = nPrev ^ nWord;
    1810       32725 :         if ( pImpEditEngine->IsFormatted() )
    1811             :         {
    1812             :             // possibly reformat:
    1813       30970 :             if ( ( nChanges & EE_CNTRL_USECHARATTRIBS ) ||
    1814       30970 :                  ( nChanges & EE_CNTRL_USEPARAATTRIBS ) ||
    1815       30970 :                  ( nChanges & EE_CNTRL_ONECHARPERLINE ) ||
    1816       30970 :                  ( nChanges & EE_CNTRL_STRETCHING ) ||
    1817       30970 :                  ( nChanges & EE_CNTRL_OUTLINER ) ||
    1818       30970 :                  ( nChanges & EE_CNTRL_NOCOLORS ) ||
    1819       15485 :                  ( nChanges & EE_CNTRL_OUTLINER2 ) )
    1820             :             {
    1821        9060 :                 if ( ( nChanges & EE_CNTRL_USECHARATTRIBS ) ||
    1822        4530 :                      ( nChanges & EE_CNTRL_USEPARAATTRIBS ) )
    1823             :                 {
    1824           0 :                     bool bUseCharAttribs = ( nWord & EE_CNTRL_USECHARATTRIBS );
    1825           0 :                     pImpEditEngine->GetEditDoc().CreateDefFont( bUseCharAttribs );
    1826             :                 }
    1827             : 
    1828        4530 :                 pImpEditEngine->FormatFullDoc();
    1829        4530 :                 pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
    1830             :             }
    1831             :         }
    1832             : 
    1833       32725 :         bool bSpellingChanged = nChanges & EE_CNTRL_ONLINESPELLING;
    1834             : 
    1835       32725 :         if ( bSpellingChanged )
    1836             :         {
    1837        1330 :             pImpEditEngine->StopOnlineSpellTimer();
    1838        1330 :             if (nWord & EE_CNTRL_ONLINESPELLING)
    1839             :             {
    1840             :                 // Create WrongList, start timer...
    1841        1148 :                 sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
    1842        2296 :                 for ( sal_Int32 n = 0; n < nNodes; n++ )
    1843             :                 {
    1844        1148 :                     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
    1845        1148 :                     pNode->CreateWrongList();
    1846             :                 }
    1847        1148 :                 if (pImpEditEngine->IsFormatted())
    1848         756 :                     pImpEditEngine->StartOnlineSpellTimer();
    1849             :             }
    1850             :             else
    1851             :             {
    1852         182 :                 long nY = 0;
    1853         182 :                 sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
    1854         364 :                 for ( sal_Int32 n = 0; n < nNodes; n++ )
    1855             :                 {
    1856         182 :                     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
    1857         182 :                     const ParaPortion* pPortion = pImpEditEngine->GetParaPortions()[n];
    1858         182 :                     bool bWrongs = false;
    1859         182 :                     if (pNode->GetWrongList() != NULL)
    1860         182 :                         bWrongs = !pNode->GetWrongList()->empty();
    1861         182 :                     pNode->DestroyWrongList();
    1862         182 :                     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         182 :                     nY += pPortion->GetHeight();
    1871             :                 }
    1872             :             }
    1873             :         }
    1874             :     }
    1875      873261 : }
    1876             : 
    1877      896742 : sal_uInt32 EditEngine::GetControlWord() const
    1878             : {
    1879      896742 :     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         132 : Point EditEngine::GetDocPosTopLeft( sal_Int32 nParagraph )
    1910             : {
    1911         132 :     const ParaPortion* pPPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nParagraph );
    1912             :     DBG_ASSERT( pPPortion, "Paragraph not found: GetWindowPosTopLeft" );
    1913         132 :     Point aPoint;
    1914         132 :     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         132 :         if ( !pImpEditEngine->IsFormatted() )
    1920           6 :             pImpEditEngine->FormatAndUpdate();
    1921         132 :         if ( pPPortion->GetLines().Count() )
    1922             :         {
    1923             :             // Correct it if large Bullet.
    1924         132 :             const EditLine* pFirstLine = pPPortion->GetLines()[0];
    1925         132 :             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         132 :         aPoint.Y() = pImpEditEngine->GetParaPortions().GetYOffset( pPPortion );
    1940             :     }
    1941         132 :     return aPoint;
    1942             : }
    1943             : 
    1944       16852 : 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       16852 :     return 0;
    1950             : }
    1951             : 
    1952        1866 : bool EditEngine::IsRightToLeft( sal_Int32 nPara ) const
    1953             : {
    1954        1866 :     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, sal_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       24848 : void EditEngine::SetEditTextObjectPool( SfxItemPool* pPool )
    1989             : {
    1990       24848 :     pImpEditEngine->SetEditTextObjectPool( pPool );
    1991       24848 : }
    1992             : 
    1993         683 : SfxItemPool* EditEngine::GetEditTextObjectPool() const
    1994             : {
    1995         683 :     return pImpEditEngine->GetEditTextObjectPool();
    1996             : }
    1997             : 
    1998        5893 : void EditEngine::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel )
    1999             : {
    2000             : 
    2001             :     EditSelection aSel( pImpEditEngine->
    2002        5893 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    2003             : 
    2004        5893 :     pImpEditEngine->SetAttribs( aSel, rSet );
    2005        5893 : }
    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       18288 : void EditEngine::QuickInsertText(const OUString& rText, const ESelection& rSel)
    2020             : {
    2021             : 
    2022             :     EditSelection aSel( pImpEditEngine->
    2023       18288 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    2024             : 
    2025       18288 :     pImpEditEngine->ImpInsertText( aSel, rText );
    2026       18288 : }
    2027             : 
    2028         698 : void EditEngine::QuickDelete( const ESelection& rSel )
    2029             : {
    2030             : 
    2031             :     EditSelection aSel( pImpEditEngine->
    2032         698 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    2033             : 
    2034         698 :     pImpEditEngine->ImpDeleteSelection( aSel );
    2035         698 : }
    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( sal_True );
    2042           0 : }
    2043             : 
    2044          22 : void EditEngine::QuickInsertLineBreak( const ESelection& rSel )
    2045             : {
    2046             : 
    2047             :     EditSelection aSel( pImpEditEngine->
    2048          22 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    2049             : 
    2050          22 :     pImpEditEngine->InsertLineBreak( aSel );
    2051          22 : }
    2052             : 
    2053        5163 : void EditEngine::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel )
    2054             : {
    2055             : 
    2056             :     EditSelection aSel( pImpEditEngine->
    2057        5163 :         ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
    2058             : 
    2059        5163 :     pImpEditEngine->ImpInsertFeature( aSel, rFld );
    2060        5163 : }
    2061             : 
    2062          16 : void EditEngine::QuickFormatDoc( bool bFull )
    2063             : {
    2064          16 :     if ( bFull )
    2065           0 :         pImpEditEngine->FormatFullDoc();
    2066             :     else
    2067          16 :         pImpEditEngine->FormatDoc();
    2068             : 
    2069             :     // Don't pass active view, maybe selection is not updated yet...
    2070          16 :     pImpEditEngine->UpdateViews( NULL );
    2071          16 : }
    2072             : 
    2073       39570 : void EditEngine::QuickRemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich )
    2074             : {
    2075       39570 :     pImpEditEngine->RemoveCharAttribs( nPara, nWhich );
    2076       39570 : }
    2077             : 
    2078           0 : void EditEngine::SetStyleSheet(const EditSelection& aSel, SfxStyleSheet* pStyle)
    2079             : {
    2080           0 :     pImpEditEngine->SetStyleSheet(aSel, pStyle);
    2081           0 : }
    2082             : 
    2083       11918 : void EditEngine::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle )
    2084             : {
    2085       11918 :     pImpEditEngine->SetStyleSheet( nPara, pStyle );
    2086       11918 : }
    2087             : 
    2088           0 : const SfxStyleSheet* EditEngine::GetStyleSheet( sal_Int32 nPara ) const
    2089             : {
    2090           0 :     return pImpEditEngine->GetStyleSheet( nPara );
    2091             : }
    2092             : 
    2093        9300 : SfxStyleSheet* EditEngine::GetStyleSheet( sal_Int32 nPara )
    2094             : {
    2095        9300 :     return pImpEditEngine->GetStyleSheet( nPara );
    2096             : }
    2097             : 
    2098       20115 : void EditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool )
    2099             : {
    2100       20115 :     pImpEditEngine->SetStyleSheetPool( pSPool );
    2101       20115 : }
    2102             : 
    2103         116 : SfxStyleSheetPool* EditEngine::GetStyleSheetPool()
    2104             : {
    2105         116 :     return pImpEditEngine->GetStyleSheetPool();
    2106             : }
    2107             : 
    2108        1113 : void EditEngine::SetWordDelimiters( const OUString& rDelimiters )
    2109             : {
    2110        1113 :     pImpEditEngine->aWordDelimiters = rDelimiters;
    2111        1113 :     if (pImpEditEngine->aWordDelimiters.indexOf(CH_FEATURE) == -1)
    2112        1113 :         pImpEditEngine->aWordDelimiters += OUString(CH_FEATURE);
    2113        1113 : }
    2114             : 
    2115        1088 : OUString EditEngine::GetWordDelimiters() const
    2116             : {
    2117        1088 :     return pImpEditEngine->aWordDelimiters;
    2118             : }
    2119             : 
    2120        4987 : void EditEngine::EraseVirtualDevice()
    2121             : {
    2122        4987 :     pImpEditEngine->EraseVirtualDevice();
    2123        4987 : }
    2124             : 
    2125        3007 : void EditEngine::SetSpeller( Reference< XSpellChecker1 >  &xSpeller )
    2126             : {
    2127        3007 :     pImpEditEngine->SetSpeller( xSpeller );
    2128        3007 : }
    2129             : 
    2130           0 : Reference< XSpellChecker1 >  EditEngine::GetSpeller()
    2131             : {
    2132           0 :     return pImpEditEngine->GetSpeller();
    2133             : }
    2134             : 
    2135       19832 : void EditEngine::SetHyphenator( Reference< XHyphenator > & xHyph )
    2136             : {
    2137       19832 :     pImpEditEngine->SetHyphenator( xHyph );
    2138       19832 : }
    2139             : 
    2140           4 : void EditEngine::GetAllMisspellRanges( std::vector<editeng::MisspellRanges>& rRanges ) const
    2141             : {
    2142           4 :     pImpEditEngine->GetAllMisspellRanges(rRanges);
    2143           4 : }
    2144             : 
    2145         107 : void EditEngine::SetAllMisspellRanges( const std::vector<editeng::MisspellRanges>& rRanges )
    2146             : {
    2147         107 :     pImpEditEngine->SetAllMisspellRanges(rRanges);
    2148         107 : }
    2149             : 
    2150       41685 : void EditEngine::SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars )
    2151             : {
    2152       41685 :     pImpEditEngine->SetForbiddenCharsTable( xForbiddenChars );
    2153       41685 : }
    2154             : 
    2155        9896 : void EditEngine::SetDefaultLanguage( LanguageType eLang )
    2156             : {
    2157        9896 :     pImpEditEngine->SetDefaultLanguage( eLang );
    2158        9896 : }
    2159             : 
    2160           0 : LanguageType EditEngine::GetDefaultLanguage() const
    2161             : {
    2162           0 :     return pImpEditEngine->GetDefaultLanguage();
    2163             : }
    2164             : 
    2165           0 : bool EditEngine::SpellNextDocument()
    2166             : {
    2167           0 :     return false;
    2168             : }
    2169             : 
    2170           0 : EESpellState EditEngine::HasSpellErrors()
    2171             : {
    2172           0 :     if ( !pImpEditEngine->GetSpeller().is()  )
    2173           0 :         return EE_SPELL_NOSPELLER;
    2174             : 
    2175           0 :     return pImpEditEngine->HasSpellErrors();
    2176             : }
    2177             : 
    2178           0 : void EditEngine::ClearSpellErrors()
    2179             : {
    2180           0 :     pImpEditEngine->ClearSpellErrors();
    2181           0 : }
    2182             : 
    2183           0 : void EditEngine::StartSpelling(EditView& rEditView, bool bMultipleDoc)
    2184             : {
    2185           0 :     pImpEditEngine->StartSpelling(rEditView, bMultipleDoc);
    2186           0 : }
    2187             : 
    2188           0 : bool EditEngine::SpellSentence(EditView& rView, ::svx::SpellPortions& rToFill, bool bIsGrammarChecking )
    2189             : {
    2190           0 :     return pImpEditEngine->SpellSentence( rView, rToFill, bIsGrammarChecking );
    2191             : }
    2192             : 
    2193           0 : void EditEngine::PutSpellingToSentenceStart( EditView& rEditView )
    2194             : {
    2195           0 :     pImpEditEngine->PutSpellingToSentenceStart( rEditView );
    2196           0 : }
    2197             : 
    2198           0 : void EditEngine::ApplyChangedSentence(EditView& rEditView, const ::svx::SpellPortions& rNewPortions, bool bRecheck )
    2199             : {
    2200           0 :     pImpEditEngine->ApplyChangedSentence( rEditView, rNewPortions, bRecheck  );
    2201           0 : }
    2202             : 
    2203           0 : bool EditEngine::HasConvertibleTextPortion( LanguageType nLang )
    2204             : {
    2205           0 :     return pImpEditEngine->HasConvertibleTextPortion( nLang );
    2206             : }
    2207             : 
    2208           0 : bool EditEngine::ConvertNextDocument()
    2209             : {
    2210           0 :     return false;
    2211             : }
    2212             : 
    2213           0 : bool EditEngine::HasText( const SvxSearchItem& rSearchItem )
    2214             : {
    2215           0 :     return pImpEditEngine->HasText( rSearchItem );
    2216             : }
    2217             : 
    2218      333534 : void EditEngine::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY )
    2219             : {
    2220      333534 :     pImpEditEngine->SetCharStretching( nX, nY );
    2221      333534 : }
    2222             : 
    2223        1889 : void EditEngine::GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const
    2224             : {
    2225        1889 :     pImpEditEngine->GetCharStretching( rX, rY );
    2226        1889 : }
    2227             : 
    2228           0 : bool EditEngine::ShouldCreateBigTextObject() const
    2229             : {
    2230           0 :     sal_Int32 nTextPortions = 0;
    2231           0 :     sal_Int32 nParas = pImpEditEngine->GetEditDoc().Count();
    2232           0 :     for ( sal_Int32 nPara = 0; nPara < nParas; nPara++  )
    2233             :     {
    2234           0 :         ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions()[nPara];
    2235           0 :         nTextPortions = nTextPortions + pParaPortion->GetTextPortions().Count();
    2236             :     }
    2237           0 :     return nTextPortions >= pImpEditEngine->GetBigTextObjectStart();
    2238             : }
    2239             : 
    2240         477 : sal_uInt16 EditEngine::GetFieldCount( sal_Int32 nPara ) const
    2241             : {
    2242         477 :     sal_uInt16 nFields = 0;
    2243         477 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    2244         477 :     if ( pNode )
    2245             :     {
    2246         477 :         const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
    2247         477 :         CharAttribList::AttribsType::const_iterator it = rAttrs.begin(), itEnd = rAttrs.end();
    2248         507 :         for (; it != itEnd; ++it)
    2249             :         {
    2250          30 :             if (it->Which() == EE_FEATURE_FIELD)
    2251          30 :                 ++nFields;
    2252             :         }
    2253             :     }
    2254             : 
    2255         477 :     return nFields;
    2256             : }
    2257             : 
    2258          30 : EFieldInfo EditEngine::GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const
    2259             : {
    2260          30 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    2261          30 :     if ( pNode )
    2262             :     {
    2263          30 :         sal_uInt16 nCurrentField = 0;
    2264          30 :         const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
    2265          30 :         CharAttribList::AttribsType::const_iterator it = rAttrs.begin(), itEnd = rAttrs.end();
    2266          30 :         for (; it != itEnd; ++it)
    2267             :         {
    2268          30 :             const EditCharAttrib& rAttr = *it;
    2269          30 :             if (rAttr.Which() == EE_FEATURE_FIELD)
    2270             :             {
    2271          30 :                 if ( nCurrentField == nField )
    2272             :                 {
    2273          30 :                     const SvxFieldItem* p = static_cast<const SvxFieldItem*>(rAttr.GetItem());
    2274          30 :                     EFieldInfo aInfo(*p, nPara, rAttr.GetStart());
    2275          30 :                     aInfo.aCurrentText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue();
    2276          30 :                     return aInfo;
    2277             :                 }
    2278             : 
    2279           0 :                 ++nCurrentField;
    2280             :             }
    2281             :         }
    2282             :     }
    2283           0 :     return EFieldInfo();
    2284             : }
    2285             : 
    2286             : 
    2287          93 : bool EditEngine::UpdateFields()
    2288             : {
    2289          93 :     bool bChanges = pImpEditEngine->UpdateFields();
    2290          93 :     if ( bChanges )
    2291           0 :         pImpEditEngine->FormatAndUpdate();
    2292          93 :     return bChanges;
    2293             : }
    2294             : 
    2295           0 : bool EditEngine::UpdateFieldsOnly()
    2296             : {
    2297           0 :     return pImpEditEngine->UpdateFields();
    2298             : }
    2299             : 
    2300           0 : void EditEngine::RemoveFields( bool bKeepFieldText, TypeId aType )
    2301             : {
    2302             : 
    2303           0 :     if ( bKeepFieldText )
    2304           0 :         pImpEditEngine->UpdateFields();
    2305             : 
    2306           0 :     sal_Int32 nParas = pImpEditEngine->GetEditDoc().Count();
    2307           0 :     for ( sal_Int32 nPara = 0; nPara < nParas; nPara++  )
    2308             :     {
    2309           0 :         ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    2310           0 :         const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
    2311           0 :         for (size_t nAttr = rAttrs.size(); nAttr; )
    2312             :         {
    2313           0 :             const EditCharAttrib& rAttr = rAttrs[--nAttr];
    2314           0 :             if (rAttr.Which() == EE_FEATURE_FIELD)
    2315             :             {
    2316           0 :                 const SvxFieldData* pFldData = static_cast<const SvxFieldItem*>(rAttr.GetItem())->GetField();
    2317           0 :                 if ( pFldData && ( !aType || ( pFldData->IsA( aType ) ) ) )
    2318             :                 {
    2319             :                     DBG_ASSERT( dynamic_cast<const SvxFieldItem*>(rAttr.GetItem()), "no field item..." );
    2320           0 :                     EditSelection aSel( EditPaM(pNode, rAttr.GetStart()), EditPaM(pNode, rAttr.GetEnd()) );
    2321           0 :                     OUString aFieldText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue();
    2322           0 :                     pImpEditEngine->ImpInsertText( aSel, aFieldText );
    2323             :                 }
    2324             :             }
    2325             :         }
    2326             :     }
    2327           0 : }
    2328             : 
    2329         321 : bool EditEngine::HasOnlineSpellErrors() const
    2330             : {
    2331         321 :     sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
    2332         642 :     for ( sal_Int32 n = 0; n < nNodes; n++ )
    2333             :     {
    2334         321 :         ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
    2335         321 :         if ( pNode->GetWrongList() && !pNode->GetWrongList()->empty() )
    2336           0 :             return true;
    2337             :     }
    2338         321 :     return false;
    2339             : }
    2340             : 
    2341         995 : void EditEngine::CompleteOnlineSpelling()
    2342             : {
    2343         995 :     if ( pImpEditEngine->GetStatus().DoOnlineSpelling() )
    2344             :     {
    2345         674 :         if( !pImpEditEngine->IsFormatted() )
    2346           0 :             pImpEditEngine->FormatAndUpdate();
    2347             : 
    2348         674 :         pImpEditEngine->StopOnlineSpellTimer();
    2349         674 :         pImpEditEngine->DoOnlineSpelling( 0, true, false );
    2350             :     }
    2351         995 : }
    2352             : 
    2353           0 : sal_Int32 EditEngine::FindParagraph( long nDocPosY )
    2354             : {
    2355           0 :     return pImpEditEngine->GetParaPortions().FindParagraph( nDocPosY );
    2356             : }
    2357             : 
    2358          11 : EPosition EditEngine::FindDocPosition( const Point& rDocPos ) const
    2359             : {
    2360          11 :     EPosition aPos;
    2361             :     // From the point of the API, this is const....
    2362          11 :     EditPaM aPaM = ((EditEngine*)this)->pImpEditEngine->GetPaM( rDocPos, sal_False );
    2363          11 :     if ( aPaM.GetNode() )
    2364             :     {
    2365          11 :         aPos.nPara = pImpEditEngine->aEditDoc.GetPos( aPaM.GetNode() );
    2366          11 :         aPos.nIndex = aPaM.GetIndex();
    2367             :     }
    2368          11 :     return aPos;
    2369             : }
    2370             : 
    2371          21 : Rectangle EditEngine::GetCharacterBounds( const EPosition& rPos ) const
    2372             : {
    2373          21 :     Rectangle aBounds;
    2374          21 :     ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( rPos.nPara );
    2375             : 
    2376             :     // Check against index, not paragraph
    2377          21 :     if ( pNode && ( rPos.nIndex < pNode->Len() ) )
    2378             :     {
    2379          21 :         aBounds = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex ), GETCRSR_TXTONLY );
    2380          21 :         Rectangle aR2 = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex+1 ), GETCRSR_TXTONLY|GETCRSR_ENDOFLINE );
    2381          21 :         if ( aR2.Right() > aBounds.Right() )
    2382          21 :             aBounds.Right() = aR2.Right();
    2383             :     }
    2384          21 :     return aBounds;
    2385             : }
    2386             : 
    2387        4617 : ParagraphInfos EditEngine::GetParagraphInfos( sal_Int32 nPara )
    2388             : {
    2389             : 
    2390             :     // This only works if not already in the format ...
    2391        4617 :     if ( !pImpEditEngine->IsFormatted() )
    2392        3755 :         pImpEditEngine->FormatDoc();
    2393             : 
    2394        4617 :     ParagraphInfos aInfos;
    2395        4617 :     aInfos.bValid = pImpEditEngine->IsFormatted();
    2396        4617 :     if ( pImpEditEngine->IsFormatted() )
    2397             :     {
    2398         862 :         const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions()[nPara];
    2399         862 :         const EditLine* pLine = (pParaPortion && pParaPortion->GetLines().Count()) ?
    2400        1724 :                 pParaPortion->GetLines()[0] : NULL;
    2401             :         DBG_ASSERT( pParaPortion && pLine, "GetParagraphInfos - Paragraph out of range" );
    2402         862 :         if ( pParaPortion && pLine )
    2403             :         {
    2404         862 :             aInfos.nParaHeight = (sal_uInt16)pParaPortion->GetHeight();
    2405         862 :             aInfos.nLines = pParaPortion->GetLines().Count();
    2406         862 :             aInfos.nFirstLineStartX = pLine->GetStartPosX();
    2407         862 :             aInfos.nFirstLineOffset = pParaPortion->GetFirstLineOffset();
    2408         862 :             aInfos.nFirstLineHeight = pLine->GetHeight();
    2409         862 :             aInfos.nFirstLineTextHeight = pLine->GetTxtHeight();
    2410         862 :             aInfos.nFirstLineMaxAscent = pLine->GetMaxAscent();
    2411             :         }
    2412             :     }
    2413        4617 :     return aInfos;
    2414             : }
    2415             : 
    2416             : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >
    2417           0 :                     EditEngine::CreateTransferable( const ESelection& rSelection ) const
    2418             : {
    2419           0 :     EditSelection aSel( pImpEditEngine->CreateSel( rSelection ) );
    2420           0 :     return pImpEditEngine->CreateTransferable( aSel );
    2421             : }
    2422             : 
    2423             : 
    2424             : // ======================    Virtual Methods    ========================
    2425             : 
    2426           0 : void EditEngine::DrawingText( const Point&, const OUString&, sal_Int32, sal_Int32,
    2427             :     const sal_Int32*, const SvxFont&, sal_Int32, sal_Int32, sal_uInt8,
    2428             :     const EEngineData::WrongSpellVector*, const SvxFieldData*, bool, bool, bool,
    2429             :     const ::com::sun::star::lang::Locale*, const Color&, const Color&)
    2430             : 
    2431             : {
    2432           0 : }
    2433             : 
    2434           0 : void EditEngine::DrawingTab( const Point& /*rStartPos*/, long /*nWidth*/,
    2435             :                                       const OUString& /*rChar*/, const SvxFont& /*rFont*/,
    2436             :                                       sal_Int32 /*nPara*/, sal_Int32 /*nIndex*/,
    2437             :                                       sal_uInt8 /*nRightToLeft*/, bool /*bEndOfLine*/,
    2438             :                                       bool /*bEndOfParagraph*/, const Color& /*rOverlineColor*/,
    2439             :                                       const Color& /*rTextLineColor*/)
    2440             : {
    2441           0 : }
    2442             : 
    2443        1636 : void EditEngine::PaintingFirstLine( sal_Int32, const Point&, long, const Point&, short, OutputDevice* )
    2444             : {
    2445        1636 : }
    2446             : 
    2447      345289 : void EditEngine::ParagraphInserted( sal_Int32 nPara )
    2448             : {
    2449             : 
    2450      345289 :     if ( GetNotifyHdl().IsSet() )
    2451             :     {
    2452         117 :         EENotify aNotify( EE_NOTIFY_PARAGRAPHINSERTED );
    2453         117 :         aNotify.pEditEngine = this;
    2454         117 :         aNotify.nParagraph = nPara;
    2455         117 :         pImpEditEngine->CallNotify( aNotify );
    2456             :     }
    2457      345289 : }
    2458             : 
    2459      336726 : void EditEngine::ParagraphDeleted( sal_Int32 nPara )
    2460             : {
    2461             : 
    2462      336726 :     if ( GetNotifyHdl().IsSet() )
    2463             :     {
    2464         117 :         EENotify aNotify( EE_NOTIFY_PARAGRAPHREMOVED );
    2465         117 :         aNotify.pEditEngine = this;
    2466         117 :         aNotify.nParagraph = nPara;
    2467         117 :         pImpEditEngine->CallNotify( aNotify );
    2468             :     }
    2469      336726 : }
    2470         593 : void EditEngine::ParagraphConnected( sal_Int32 /*nLeftParagraph*/, sal_Int32 /*nRightParagraph*/ )
    2471             : {
    2472         593 : }
    2473             : 
    2474      347120 : bool EditEngine::FormattingParagraph( sal_Int32 )
    2475             : {
    2476             :     // return true, if the Attribute was changed ...
    2477      347120 :     return false;
    2478             : }
    2479             : 
    2480       19093 : void EditEngine::ParaAttribsChanged( sal_Int32 /* nParagraph */ )
    2481             : {
    2482       19093 : }
    2483             : 
    2484           0 : void EditEngine::StyleSheetChanged( SfxStyleSheet* /* pStyle */ )
    2485             : {
    2486           0 : }
    2487             : 
    2488      267345 : void EditEngine::ParagraphHeightChanged( sal_Int32 nPara )
    2489             : {
    2490             : 
    2491      267345 :     if ( GetNotifyHdl().IsSet() )
    2492             :     {
    2493         121 :         EENotify aNotify( EE_NOTIFY_TEXTHEIGHTCHANGED );
    2494         121 :         aNotify.pEditEngine = this;
    2495         121 :         aNotify.nParagraph = nPara;
    2496         121 :         pImpEditEngine->CallNotify( aNotify );
    2497             :     }
    2498      267345 : }
    2499             : 
    2500       97708 : OUString EditEngine::GetUndoComment( sal_uInt16 nId ) const
    2501             : {
    2502       97708 :     OUString aComment;
    2503       97708 :     switch ( nId )
    2504             :     {
    2505             :         case EDITUNDO_REMOVECHARS:
    2506             :         case EDITUNDO_CONNECTPARAS:
    2507             :         case EDITUNDO_REMOVEFEATURE:
    2508             :         case EDITUNDO_DELCONTENT:
    2509             :         case EDITUNDO_DELETE:
    2510             :         case EDITUNDO_CUT:
    2511         786 :             aComment = EE_RESSTR(RID_EDITUNDO_DEL);
    2512         786 :         break;
    2513             :         case EDITUNDO_MOVEPARAGRAPHS:
    2514             :         case EDITUNDO_MOVEPARAS:
    2515             :         case EDITUNDO_DRAGANDDROP:
    2516           0 :             aComment = EE_RESSTR(RID_EDITUNDO_MOVE);
    2517           0 :         break;
    2518             :         case EDITUNDO_INSERTFEATURE:
    2519             :         case EDITUNDO_SPLITPARA:
    2520             :         case EDITUNDO_INSERTCHARS:
    2521             :         case EDITUNDO_PASTE:
    2522             :         case EDITUNDO_INSERT:
    2523             :         case EDITUNDO_READ:
    2524       66853 :             aComment = EE_RESSTR(RID_EDITUNDO_INSERT);
    2525       66853 :         break;
    2526             :         case EDITUNDO_SRCHANDREPL:
    2527             :         case EDITUNDO_REPLACEALL:
    2528           0 :             aComment = EE_RESSTR(RID_EDITUNDO_REPLACE);
    2529           0 :         break;
    2530             :         case EDITUNDO_ATTRIBS:
    2531             :         case EDITUNDO_PARAATTRIBS:
    2532             :         case EDITUNDO_STRETCH:
    2533       26452 :             aComment = EE_RESSTR(RID_EDITUNDO_SETATTRIBS);
    2534       26452 :         break;
    2535             :         case EDITUNDO_RESETATTRIBS:
    2536         561 :             aComment = EE_RESSTR(RID_EDITUNDO_RESETATTRIBS);
    2537         561 :         break;
    2538             :         case EDITUNDO_STYLESHEET:
    2539        3056 :             aComment = EE_RESSTR(RID_EDITUNDO_SETSTYLE);
    2540        3056 :         break;
    2541             :         case EDITUNDO_TRANSLITERATE:
    2542           0 :             aComment = EE_RESSTR(RID_EDITUNDO_TRANSLITERATE);
    2543           0 :         break;
    2544             :         case EDITUNDO_INDENTBLOCK:
    2545             :         case EDITUNDO_UNINDENTBLOCK:
    2546           0 :             aComment = EE_RESSTR(RID_EDITUNDO_INDENT);
    2547           0 :         break;
    2548             :     }
    2549       97708 :     return aComment;
    2550             : }
    2551             : 
    2552       15430 : Rectangle EditEngine::GetBulletArea( sal_Int32 )
    2553             : {
    2554       15430 :     return Rectangle( Point(), Point() );
    2555             : }
    2556             : 
    2557         764 : OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, Color*&, Color*& )
    2558             : {
    2559         764 :     return OUString(' ');
    2560             : }
    2561             : 
    2562           0 : void EditEngine::FieldClicked( const SvxFieldItem&, sal_Int32, sal_Int32 )
    2563             : {
    2564           0 : }
    2565             : 
    2566           0 : void EditEngine::FieldSelected( const SvxFieldItem&, sal_Int32, sal_Int32 )
    2567             : {
    2568           0 : }
    2569             : 
    2570             : 
    2571             : // ======================     Static Methods     =======================
    2572             : 
    2573       33677 : SfxItemPool* EditEngine::CreatePool( bool bPersistentRefCounts )
    2574             : {
    2575       33677 :     SfxItemPool* pPool = new EditEngineItemPool( bPersistentRefCounts );
    2576       33677 :     return pPool;
    2577             : }
    2578             : 
    2579          57 : SfxItemPool& EditEngine::GetGlobalItemPool()
    2580             : {
    2581          57 :     if ( !pGlobalPool )
    2582          39 :         pGlobalPool = CreatePool();
    2583          57 :     return *pGlobalPool;
    2584             : }
    2585             : 
    2586         208 : void EditEngine::SetFontInfoInItemSet( SfxItemSet& rSet, const Font& rFont )
    2587             : {
    2588         208 :     SvxFont aSvxFont( rFont );
    2589         208 :     SetFontInfoInItemSet( rSet, aSvxFont );
    2590             : 
    2591         208 : }
    2592             : 
    2593         208 : void EditEngine::SetFontInfoInItemSet( SfxItemSet& rSet, const SvxFont& rFont )
    2594             : {
    2595         208 :     rSet.Put( SvxLanguageItem( rFont.GetLanguage(), EE_CHAR_LANGUAGE ) );
    2596         208 :     rSet.Put( SvxFontItem( rFont.GetFamily(), rFont.GetName(), OUString(), rFont.GetPitch(), rFont.GetCharSet(), EE_CHAR_FONTINFO ) );
    2597         208 :     rSet.Put( SvxFontHeightItem( rFont.GetSize().Height(), 100, EE_CHAR_FONTHEIGHT )  );
    2598         208 :     rSet.Put( SvxCharScaleWidthItem( 100, EE_CHAR_FONTWIDTH ) );
    2599         208 :     rSet.Put( SvxShadowedItem( rFont.IsShadow(), EE_CHAR_SHADOW )  );
    2600         208 :     rSet.Put( SvxEscapementItem( rFont.GetEscapement(), rFont.GetPropr(), EE_CHAR_ESCAPEMENT )  );
    2601         208 :     rSet.Put( SvxWeightItem( rFont.GetWeight(), EE_CHAR_WEIGHT )  );
    2602         208 :     rSet.Put( SvxColorItem( rFont.GetColor(), EE_CHAR_COLOR )  );
    2603         208 :     rSet.Put( SvxUnderlineItem( rFont.GetUnderline(), EE_CHAR_UNDERLINE )  );
    2604         208 :     rSet.Put( SvxOverlineItem( rFont.GetOverline(), EE_CHAR_OVERLINE )  );
    2605         208 :     rSet.Put( SvxCrossedOutItem( rFont.GetStrikeout(), EE_CHAR_STRIKEOUT )  );
    2606         208 :     rSet.Put( SvxCaseMapItem( rFont.GetCaseMap(), EE_CHAR_CASEMAP )  );
    2607         208 :     rSet.Put( SvxPostureItem( rFont.GetItalic(), EE_CHAR_ITALIC )  );
    2608         208 :     rSet.Put( SvxContourItem( rFont.IsOutline(), EE_CHAR_OUTLINE )  );
    2609         208 :     rSet.Put( SvxAutoKernItem( rFont.IsKerning(), EE_CHAR_PAIRKERNING ) );
    2610         208 :     rSet.Put( SvxKerningItem( rFont.GetFixKerning(), EE_CHAR_KERNING ) );
    2611         208 :     rSet.Put( SvxWordLineModeItem( rFont.IsWordLineMode(), EE_CHAR_WLM ) );
    2612         208 :     rSet.Put( SvxEmphasisMarkItem( rFont.GetEmphasisMark(), EE_CHAR_EMPHASISMARK ) );
    2613         208 :     rSet.Put( SvxCharReliefItem( rFont.GetRelief(), EE_CHAR_RELIEF ) );
    2614         208 : }
    2615             : 
    2616        1398 : Font EditEngine::CreateFontFromItemSet( const SfxItemSet& rItemSet, sal_uInt16 nScriptType )
    2617             : {
    2618        1398 :     SvxFont aFont;
    2619        1398 :     CreateFont( aFont, rItemSet, true, nScriptType );
    2620        1398 :     return aFont;
    2621             : }
    2622             : 
    2623           0 : SvxFont EditEngine::CreateSvxFontFromItemSet( const SfxItemSet& rItemSet )
    2624             : {
    2625           0 :     SvxFont aFont;
    2626           0 :     CreateFont( aFont, rItemSet );
    2627           0 :     return aFont;
    2628             : }
    2629             : 
    2630           0 : bool EditEngine::DoesKeyMoveCursor( const KeyEvent& rKeyEvent )
    2631             : {
    2632           0 :     bool bDoesMove = false;
    2633             : 
    2634           0 :     switch ( rKeyEvent.GetKeyCode().GetCode() )
    2635             :     {
    2636             :         case KEY_UP:
    2637             :         case KEY_DOWN:
    2638             :         case KEY_LEFT:
    2639             :         case KEY_RIGHT:
    2640             :         case KEY_HOME:
    2641             :         case KEY_END:
    2642             :         case KEY_PAGEUP:
    2643             :         case KEY_PAGEDOWN:
    2644             :         {
    2645           0 :             if ( !rKeyEvent.GetKeyCode().IsMod2() )
    2646           0 :                 bDoesMove = true;
    2647             :         }
    2648           0 :         break;
    2649             :     }
    2650           0 :     return bDoesMove;
    2651             : }
    2652             : 
    2653           0 : bool EditEngine::DoesKeyChangeText( const KeyEvent& rKeyEvent )
    2654             : {
    2655           0 :     bool bDoesChange = false;
    2656             : 
    2657           0 :     KeyFuncType eFunc = rKeyEvent.GetKeyCode().GetFunction();
    2658           0 :     if ( eFunc != KEYFUNC_DONTKNOW )
    2659             :     {
    2660           0 :         switch ( eFunc )
    2661             :         {
    2662             :             case KEYFUNC_UNDO:
    2663             :             case KEYFUNC_REDO:
    2664             :             case KEYFUNC_CUT:
    2665           0 :             case KEYFUNC_PASTE: bDoesChange = true;
    2666           0 :             break;
    2667             :             default:    // is then possibly edited below.
    2668           0 :                         eFunc = KEYFUNC_DONTKNOW;
    2669             :         }
    2670             :     }
    2671           0 :     if ( eFunc == KEYFUNC_DONTKNOW )
    2672             :     {
    2673           0 :         switch ( rKeyEvent.GetKeyCode().GetCode() )
    2674             :         {
    2675             :             case KEY_DELETE:
    2676           0 :             case KEY_BACKSPACE: bDoesChange = true;
    2677           0 :             break;
    2678             :             case KEY_RETURN:
    2679             :             case KEY_TAB:
    2680             :             {
    2681           0 :                 if ( !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
    2682           0 :                     bDoesChange = true;
    2683             :             }
    2684           0 :             break;
    2685             :             default:
    2686             :             {
    2687           0 :                 bDoesChange = IsSimpleCharInput( rKeyEvent );
    2688             :             }
    2689             :         }
    2690             :     }
    2691           0 :     return bDoesChange;
    2692             : }
    2693             : 
    2694           0 : bool EditEngine::IsSimpleCharInput( const KeyEvent& rKeyEvent )
    2695             : {
    2696           0 :     if( EditEngine::IsPrintable( rKeyEvent.GetCharCode() ) &&
    2697           0 :         ( KEY_MOD2 != (rKeyEvent.GetKeyCode().GetModifier() & ~KEY_SHIFT ) ) &&
    2698           0 :         ( KEY_MOD1 != (rKeyEvent.GetKeyCode().GetModifier() & ~KEY_SHIFT ) ) )
    2699             :     {
    2700           0 :         return true;
    2701             :     }
    2702           0 :     return false;
    2703             : }
    2704             : 
    2705           0 : bool EditEngine::HasValidData( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rTransferable )
    2706             : {
    2707           0 :     bool bValidData = false;
    2708             : 
    2709           0 :     if ( rTransferable.is() )
    2710             :     {
    2711             :         // Every application that copies rtf or any other text format also copies plain text into the clipboard....
    2712           0 :         datatransfer::DataFlavor aFlavor;
    2713           0 :         SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
    2714           0 :         bValidData = rTransferable->isDataFlavorSupported( aFlavor );
    2715             :     }
    2716             : 
    2717           0 :     return bValidData;
    2718             : }
    2719             : 
    2720             : /** sets a link that is called at the beginning of a drag operation at an edit view */
    2721           0 : void EditEngine::SetBeginDropHdl( const Link& rLink )
    2722             : {
    2723           0 :     pImpEditEngine->SetBeginDropHdl( rLink );
    2724           0 : }
    2725             : 
    2726           0 : Link EditEngine::GetBeginDropHdl() const
    2727             : {
    2728           0 :     return pImpEditEngine->GetBeginDropHdl();
    2729             : }
    2730             : 
    2731             : /** sets a link that is called at the end of a drag operation at an edit view */
    2732           0 : void EditEngine::SetEndDropHdl( const Link& rLink )
    2733             : {
    2734           0 :     pImpEditEngine->SetEndDropHdl( rLink );
    2735           0 : }
    2736             : 
    2737           0 : Link EditEngine::GetEndDropHdl() const
    2738             : {
    2739           0 :     return pImpEditEngine->GetEndDropHdl();
    2740             : }
    2741             : 
    2742           0 : void EditEngine::SetFirstWordCapitalization( bool bCapitalize )
    2743             : {
    2744           0 :     pImpEditEngine->SetFirstWordCapitalization( bCapitalize );
    2745           0 : }
    2746             : 
    2747          55 : bool EditEngine::IsImportHandlerSet() const
    2748             : {
    2749          55 :     return pImpEditEngine->aImportHdl.IsSet();
    2750             : }
    2751             : 
    2752           0 : bool EditEngine::IsImportRTFStyleSheetsSet() const
    2753             : {
    2754           0 :     return pImpEditEngine->GetStatus().DoImportRTFStyleSheets();
    2755             : }
    2756             : 
    2757          55 : void EditEngine::CallImportHandler(ImportInfo& rInfo)
    2758             : {
    2759          55 :     pImpEditEngine->aImportHdl.Call(&rInfo);
    2760          55 : }
    2761             : 
    2762           6 : EditPaM EditEngine::InsertParaBreak(
    2763             :         const EditSelection& rEditSelection, bool bKeepEndingAttribs)
    2764             : {
    2765           6 :     return pImpEditEngine->ImpInsertParaBreak(rEditSelection, bKeepEndingAttribs);
    2766             : }
    2767             : 
    2768           0 : EditPaM EditEngine::InsertLineBreak(const EditSelection& rEditSelection)
    2769             : {
    2770           0 :     return pImpEditEngine->InsertLineBreak(rEditSelection);
    2771             : }
    2772             : 
    2773          16 : EFieldInfo::EFieldInfo()
    2774             : {
    2775          16 :     pFieldItem = NULL;
    2776          16 : }
    2777             : 
    2778             : 
    2779          30 : EFieldInfo::EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos ) : aPosition( nPara, nPos )
    2780             : {
    2781          30 :     pFieldItem = new SvxFieldItem( rFieldItem );
    2782          30 : }
    2783             : 
    2784         152 : EFieldInfo::~EFieldInfo()
    2785             : {
    2786          76 :     delete pFieldItem;
    2787          76 : }
    2788             : 
    2789          30 : EFieldInfo::EFieldInfo( const EFieldInfo& rFldInfo )
    2790             : {
    2791          30 :     *this = rFldInfo;
    2792          30 : }
    2793             : 
    2794          30 : EFieldInfo& EFieldInfo::operator= ( const EFieldInfo& rFldInfo )
    2795             : {
    2796          30 :     if( this == &rFldInfo )
    2797           0 :         return *this;
    2798             : 
    2799          30 :     pFieldItem = rFldInfo.pFieldItem ? new SvxFieldItem( *rFldInfo.pFieldItem ) : 0;
    2800          30 :     aCurrentText = rFldInfo.aCurrentText;
    2801          30 :     aPosition = rFldInfo.aPosition;
    2802             : 
    2803          30 :     return *this;
    2804             : }
    2805             : 
    2806             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10