LCOV - code coverage report
Current view: top level - editeng/source/outliner - outlvw.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 65 763 8.5 %
Date: 2014-11-03 Functions: 19 88 21.6 %
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 <com/sun/star/i18n/WordType.hpp>
      21             : 
      22             : #include <svl/intitem.hxx>
      23             : #include <svl/itempool.hxx>
      24             : #include <editeng/editeng.hxx>
      25             : #include <editeng/editview.hxx>
      26             : #include <editeng/editdata.hxx>
      27             : #include <editeng/eerdll.hxx>
      28             : #include <editeng/lrspitem.hxx>
      29             : #include <editeng/fhgtitem.hxx>
      30             : 
      31             : #include <svl/style.hxx>
      32             : #include <svl/languageoptions.hxx>
      33             : #include <i18nlangtag/languagetag.hxx>
      34             : 
      35             : #include <editeng/outliner.hxx>
      36             : #include <outleeng.hxx>
      37             : #include <paralist.hxx>
      38             : #include <outlundo.hxx>
      39             : #include <editeng/outlobj.hxx>
      40             : #include <editeng/flditem.hxx>
      41             : #include <editeng/eeitem.hxx>
      42             : #include <editeng/numitem.hxx>
      43             : #include <vcl/window.hxx>
      44             : #include <svl/itemset.hxx>
      45             : #include <svl/eitem.hxx>
      46             : #include <editeng/editstat.hxx>
      47             : 
      48             : using namespace ::com::sun::star;
      49             : 
      50             : 
      51             : 
      52         130 : OutlinerView::OutlinerView( Outliner* pOut, vcl::Window* pWin )
      53             : {
      54         130 :     pOwner                      = pOut;
      55             : 
      56         130 :     pEditView = new EditView( pOut->pEditEngine, pWin );
      57         130 :     pEditView->SetSelectionMode( EE_SELMODE_TXTONLY );
      58         130 : }
      59             : 
      60         260 : OutlinerView::~OutlinerView()
      61             : {
      62         130 :     delete pEditView;
      63         260 : }
      64             : 
      65           0 : void OutlinerView::Paint( const Rectangle& rRect, OutputDevice* pTargetDevice )
      66             : {
      67             :     // For the first Paint/KeyInput/Drop an emty Outliner is turned into
      68             :     // an Outliner with exactly one paragraph.
      69           0 :     if( pOwner->bFirstParaIsEmpty )
      70           0 :         pOwner->Insert( OUString() );
      71             : 
      72           0 :     pEditView->Paint( rRect, pTargetDevice );
      73           0 : }
      74             : 
      75           0 : bool OutlinerView::PostKeyEvent( const KeyEvent& rKEvt, vcl::Window* pFrameWin )
      76             : {
      77             :     // For the first Paint/KeyInput/Drop an emty Outliner is turned into
      78             :     // an Outliner with exactly one paragraph.
      79           0 :     if( pOwner->bFirstParaIsEmpty )
      80           0 :         pOwner->Insert( OUString() );
      81             : 
      82           0 :     bool bKeyProcessed = false;
      83           0 :     ESelection aSel( pEditView->GetSelection() );
      84           0 :     bool bSelection = aSel.HasRange();
      85           0 :     vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
      86           0 :     KeyFuncType eFunc = aKeyCode.GetFunction();
      87           0 :     sal_uInt16 nCode = aKeyCode.GetCode();
      88           0 :     bool bReadOnly = IsReadOnly();
      89             : 
      90           0 :     if( bSelection && ( nCode != KEY_TAB ) && EditEngine::DoesKeyChangeText( rKEvt ) )
      91             :     {
      92           0 :         if ( ImpCalcSelectedPages( false ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
      93           0 :             return true;
      94             :     }
      95             : 
      96           0 :     if ( eFunc != KeyFuncType::DONTKNOW )
      97             :     {
      98           0 :         switch ( eFunc )
      99             :         {
     100             :             case KeyFuncType::CUT:
     101             :             {
     102           0 :                 if ( !bReadOnly )
     103             :                 {
     104           0 :                     Cut();
     105           0 :                     bKeyProcessed = true;
     106             :                 }
     107             :             }
     108           0 :             break;
     109             :             case KeyFuncType::COPY:
     110             :             {
     111           0 :                 Copy();
     112           0 :                 bKeyProcessed = true;
     113             :             }
     114           0 :             break;
     115             :             case KeyFuncType::PASTE:
     116             :             {
     117           0 :                 if ( !bReadOnly )
     118             :                 {
     119           0 :                     PasteSpecial();
     120           0 :                     bKeyProcessed = true;
     121             :                 }
     122             :             }
     123           0 :             break;
     124             :             case KeyFuncType::DELETE:
     125             :             {
     126           0 :                 if( !bReadOnly && !bSelection && ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) )
     127             :                 {
     128           0 :                     if( aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
     129             :                     {
     130           0 :                         Paragraph* pNext = pOwner->pParaList->GetParagraph( aSel.nEndPara+1 );
     131           0 :                         if( pNext && pNext->HasFlag(PARAFLAG_ISPAGE) )
     132             :                         {
     133           0 :                             if( !pOwner->ImpCanDeleteSelectedPages( this, aSel.nEndPara, 1 ) )
     134           0 :                                 return false;
     135             :                         }
     136             :                     }
     137             :                 }
     138             :             }
     139           0 :             break;
     140             :             default:    // is then possibly edited below.
     141           0 :                         eFunc = KeyFuncType::DONTKNOW;
     142             :         }
     143             :     }
     144           0 :     if ( eFunc == KeyFuncType::DONTKNOW )
     145             :     {
     146           0 :         switch ( nCode )
     147             :         {
     148             :             case KEY_TAB:
     149             :             {
     150           0 :                 if ( !bReadOnly && !aKeyCode.IsMod1() && !aKeyCode.IsMod2() )
     151             :                 {
     152           0 :                     if ( ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) &&
     153           0 :                          ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TITLEOBJECT ) &&
     154           0 :                          ( bSelection || !aSel.nStartPos ) )
     155             :                     {
     156           0 :                         Indent( aKeyCode.IsShift() ? (-1) : (+1) );
     157           0 :                         bKeyProcessed = true;
     158             :                     }
     159           0 :                     else if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) &&
     160           0 :                               !bSelection && !aSel.nEndPos && pOwner->ImplHasNumberFormat( aSel.nEndPara ) )
     161             :                     {
     162           0 :                         Indent( aKeyCode.IsShift() ? (-1) : (+1) );
     163           0 :                         bKeyProcessed = true;
     164             :                     }
     165             :                 }
     166             :             }
     167           0 :             break;
     168             :             case KEY_BACKSPACE:
     169             :             {
     170           0 :                 if( !bReadOnly && !bSelection && aSel.nEndPara && !aSel.nEndPos )
     171             :                 {
     172           0 :                     Paragraph* pPara = pOwner->pParaList->GetParagraph( aSel.nEndPara );
     173           0 :                     Paragraph* pPrev = pOwner->pParaList->GetParagraph( aSel.nEndPara-1 );
     174           0 :                     if( !pPrev->IsVisible()  )
     175           0 :                         return true;
     176           0 :                     if( !pPara->GetDepth() )
     177             :                     {
     178           0 :                         if(!pOwner->ImpCanDeleteSelectedPages(this, aSel.nEndPara , 1 ) )
     179           0 :                             return true;
     180             :                     }
     181             :                 }
     182             :             }
     183           0 :             break;
     184             :             case KEY_RETURN:
     185             :             {
     186           0 :                 if ( !bReadOnly )
     187             :                 {
     188             :                     // Special treatment: hard return at the end of a paragraph,
     189             :                     // which has collapsed subparagraphs.
     190           0 :                     Paragraph* pPara = pOwner->pParaList->GetParagraph( aSel.nEndPara );
     191             : 
     192           0 :                     if( !aKeyCode.IsShift() )
     193             :                     {
     194             :                         // ImpGetCursor again???
     195           0 :                         if( !bSelection &&
     196           0 :                                 aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
     197             :                         {
     198           0 :                             sal_Int32 nChildren = pOwner->pParaList->GetChildCount(pPara);
     199           0 :                             if( nChildren && !pOwner->pParaList->HasVisibleChildren(pPara))
     200             :                             {
     201           0 :                                 pOwner->UndoActionStart( OLUNDO_INSERT );
     202           0 :                                 sal_Int32 nTemp = aSel.nEndPara;
     203           0 :                                 nTemp += nChildren;
     204           0 :                                 nTemp++; // insert above next Non-Child
     205             :                                 SAL_WARN_IF( nTemp < 0, "editeng", "OutlinerView::PostKeyEvent - overflow");
     206           0 :                                 if (nTemp >= 0)
     207             :                                 {
     208           0 :                                     pOwner->Insert( OUString(),nTemp,pPara->GetDepth());
     209             :                                     // Position the cursor
     210           0 :                                     ESelection aTmpSel(nTemp,0,nTemp,0);
     211           0 :                                     pEditView->SetSelection( aTmpSel );
     212             :                                 }
     213           0 :                                 pEditView->ShowCursor( true, true );
     214           0 :                                 pOwner->UndoActionEnd( OLUNDO_INSERT );
     215           0 :                                 bKeyProcessed = true;
     216             :                             }
     217             :                         }
     218             :                     }
     219           0 :                     if( !bKeyProcessed && !bSelection &&
     220           0 :                                 !aKeyCode.IsShift() && aKeyCode.IsMod1() &&
     221           0 :                             ( aSel.nEndPos == pOwner->pEditEngine->GetTextLen(aSel.nEndPara) ) )
     222             :                     {
     223           0 :                         pOwner->UndoActionStart( OLUNDO_INSERT );
     224           0 :                         sal_Int32 nTemp = aSel.nEndPara;
     225           0 :                         nTemp++;
     226           0 :                         pOwner->Insert( OUString(), nTemp, pPara->GetDepth()+1 );
     227             : 
     228             :                         // Position the cursor
     229           0 :                         ESelection aTmpSel(nTemp,0,nTemp,0);
     230           0 :                         pEditView->SetSelection( aTmpSel );
     231           0 :                         pEditView->ShowCursor( true, true );
     232           0 :                         pOwner->UndoActionEnd( OLUNDO_INSERT );
     233           0 :                         bKeyProcessed = true;
     234             :                     }
     235             :                 }
     236             :             }
     237           0 :             break;
     238             :         }
     239             :     }
     240             : 
     241           0 :     return bKeyProcessed || pEditView->PostKeyEvent( rKEvt, pFrameWin );
     242             : }
     243             : 
     244           0 : sal_Int32 OutlinerView::ImpCheckMousePos(const Point& rPosPix, MouseTarget& reTarget)
     245             : {
     246           0 :     sal_Int32 nPara = EE_PARA_NOT_FOUND;
     247             : 
     248           0 :     Point aMousePosWin = pEditView->GetWindow()->PixelToLogic( rPosPix );
     249           0 :     if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
     250             :     {
     251           0 :         reTarget = MouseOutside;
     252             :     }
     253             :     else
     254             :     {
     255           0 :         reTarget = MouseText;
     256             : 
     257           0 :         Point aPaperPos( aMousePosWin );
     258           0 :         Rectangle aOutArea = pEditView->GetOutputArea();
     259           0 :         Rectangle aVisArea = pEditView->GetVisArea();
     260           0 :         aPaperPos.X() -= aOutArea.Left();
     261           0 :         aPaperPos.X() += aVisArea.Left();
     262           0 :         aPaperPos.Y() -= aOutArea.Top();
     263           0 :         aPaperPos.Y() += aVisArea.Top();
     264             : 
     265             :         bool bBullet;
     266           0 :         if ( pOwner->IsTextPos( aPaperPos, 0, &bBullet ) )
     267             :         {
     268           0 :             Point aDocPos = pOwner->GetDocPos( aPaperPos );
     269           0 :             nPara = pOwner->pEditEngine->FindParagraph( aDocPos.Y() );
     270             : 
     271           0 :             if ( bBullet )
     272             :             {
     273           0 :                 reTarget = MouseBullet;
     274             :             }
     275             :             else
     276             :             {
     277             :                 // Check for hyperlink
     278           0 :                 const SvxFieldItem* pFieldItem = pEditView->GetField( aMousePosWin );
     279           0 :                 if ( pFieldItem && pFieldItem->GetField() && pFieldItem->GetField()->ISA( SvxURLField ) )
     280           0 :                     reTarget = MouseHypertext;
     281             :             }
     282             :         }
     283             :     }
     284           0 :     return nPara;
     285             : }
     286             : 
     287           0 : bool OutlinerView::MouseMove( const MouseEvent& rMEvt )
     288             : {
     289           0 :     if( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode())
     290           0 :         return pEditView->MouseMove( rMEvt );
     291             : 
     292           0 :     Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
     293           0 :     if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
     294           0 :         return false;
     295             : 
     296           0 :     Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
     297           0 :     pEditView->GetWindow()->SetPointer( aPointer );
     298           0 :     return pEditView->MouseMove( rMEvt );
     299             : }
     300             : 
     301             : 
     302           0 : bool OutlinerView::MouseButtonDown( const MouseEvent& rMEvt )
     303             : {
     304           0 :     if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode() )
     305           0 :         return pEditView->MouseButtonDown( rMEvt );
     306             : 
     307           0 :     Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
     308           0 :     if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
     309           0 :         return false;
     310             : 
     311           0 :     Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
     312           0 :     pEditView->GetWindow()->SetPointer( aPointer );
     313             : 
     314             :     MouseTarget eTarget;
     315           0 :     sal_Int32 nPara = ImpCheckMousePos( rMEvt.GetPosPixel(), eTarget );
     316           0 :     if ( eTarget == MouseBullet )
     317             :     {
     318           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
     319           0 :         bool bHasChildren = (pPara && pOwner->pParaList->HasChildren(pPara));
     320           0 :         if( rMEvt.GetClicks() == 1 )
     321             :         {
     322           0 :             sal_Int32 nEndPara = nPara;
     323           0 :             if ( bHasChildren && pOwner->pParaList->HasVisibleChildren(pPara) )
     324           0 :                 nEndPara += pOwner->pParaList->GetChildCount( pPara );
     325             :             // The selection is inverted, so that EditEngine does not scroll
     326           0 :             ESelection aSel(nEndPara, EE_TEXTPOS_ALL, nPara, 0 );
     327           0 :             pEditView->SetSelection( aSel );
     328             :         }
     329           0 :         else if( rMEvt.GetClicks() == 2 && bHasChildren )
     330           0 :             ImpToggleExpand( pPara );
     331             : 
     332           0 :         return true;
     333             :     }
     334             : 
     335             :     // special case for outliner view in impress, check if double click hits the page icon for toggle
     336           0 :     if( (nPara == EE_PARA_NOT_FOUND) && (pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEVIEW) && (eTarget == MouseText) && (rMEvt.GetClicks() == 2) )
     337             :     {
     338           0 :         ESelection aSel( pEditView->GetSelection() );
     339           0 :         nPara = aSel.nStartPara;
     340           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
     341           0 :         if( (pPara && pOwner->pParaList->HasChildren(pPara)) && pPara->HasFlag(PARAFLAG_ISPAGE) )
     342             :         {
     343           0 :             ImpToggleExpand( pPara );
     344             :         }
     345             :     }
     346           0 :     return pEditView->MouseButtonDown( rMEvt );
     347             : }
     348             : 
     349             : 
     350           0 : bool OutlinerView::MouseButtonUp( const MouseEvent& rMEvt )
     351             : {
     352           0 :     if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode() )
     353           0 :         return pEditView->MouseButtonUp( rMEvt );
     354             : 
     355           0 :     Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
     356           0 :     if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
     357           0 :         return false;
     358             : 
     359           0 :     Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
     360           0 :     pEditView->GetWindow()->SetPointer( aPointer );
     361             : 
     362           0 :     return pEditView->MouseButtonUp( rMEvt );
     363             : }
     364             : 
     365           0 : void OutlinerView::ReleaseMouse()
     366             : {
     367           0 :     pEditView->ReleaseMouse();
     368           0 : }
     369             : 
     370           0 : void OutlinerView::ImpToggleExpand( Paragraph* pPara )
     371             : {
     372           0 :     sal_Int32 nPara = pOwner->pParaList->GetAbsPos( pPara );
     373           0 :     pEditView->SetSelection( ESelection( nPara, 0, nPara, 0 ) );
     374           0 :     ImplExpandOrCollaps( nPara, nPara, !pOwner->pParaList->HasVisibleChildren( pPara ) );
     375           0 :     pEditView->ShowCursor();
     376           0 : }
     377             : 
     378           0 : sal_Int32 OutlinerView::Select( Paragraph* pParagraph, bool bSelect,
     379             :     bool bWithChildren )
     380             : {
     381           0 :     sal_Int32 nPara = pOwner->pParaList->GetAbsPos( pParagraph );
     382           0 :     sal_Int32 nEnd = 0;
     383           0 :     if ( bSelect )
     384           0 :         nEnd = SAL_MAX_INT32;
     385             : 
     386           0 :     sal_Int32 nChildCount = 0;
     387           0 :     if ( bWithChildren )
     388           0 :         nChildCount = pOwner->pParaList->GetChildCount( pParagraph );
     389             : 
     390           0 :     ESelection aSel( nPara, 0, nPara + nChildCount, nEnd );
     391           0 :     pEditView->SetSelection( aSel );
     392           0 :     return nChildCount+1;
     393             : }
     394             : 
     395             : 
     396         282 : void OutlinerView::SetAttribs( const SfxItemSet& rAttrs )
     397             : {
     398         282 :     bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
     399         282 :     pOwner->pEditEngine->SetUpdateMode( false );
     400             : 
     401         282 :     if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
     402         260 :         pOwner->UndoActionStart( OLUNDO_ATTR );
     403             : 
     404         282 :     ParaRange aSel = ImpGetSelectedParagraphs( false );
     405             : 
     406         282 :     pEditView->SetAttribs( rAttrs );
     407             : 
     408             :     // Update Bullet text
     409         564 :     for( sal_Int32 nPara= aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
     410             :     {
     411         282 :         pOwner->ImplCheckNumBulletItem( nPara );
     412         282 :         pOwner->ImplCalcBulletText( nPara, false, false );
     413             : 
     414         282 :         if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
     415         260 :             pOwner->InsertUndo( new OutlinerUndoCheckPara( pOwner, nPara ) );
     416             :     }
     417             : 
     418         282 :     if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
     419         260 :         pOwner->UndoActionEnd( OLUNDO_ATTR );
     420             : 
     421         282 :     pEditView->SetEditEngineUpdateMode( bUpdate );
     422         282 : }
     423             : 
     424         282 : ParaRange OutlinerView::ImpGetSelectedParagraphs( bool bIncludeHiddenChildren )
     425             : {
     426         282 :     ESelection aSel = pEditView->GetSelection();
     427         282 :     ParaRange aParas( aSel.nStartPara, aSel.nEndPara );
     428         282 :     aParas.Adjust();
     429             : 
     430             :     // Record the  invisible Children of the last Parents in the selection
     431         282 :     if ( bIncludeHiddenChildren )
     432             :     {
     433           0 :         Paragraph* pLast = pOwner->pParaList->GetParagraph( aParas.nEndPara );
     434           0 :         if ( pOwner->pParaList->HasHiddenChildren( pLast ) )
     435           0 :             aParas.nEndPara = aParas.nEndPara + pOwner->pParaList->GetChildCount( pLast );
     436             :     }
     437         282 :     return aParas;
     438             : }
     439             : 
     440             : // TODO: Name should be changed!
     441           0 : void OutlinerView::AdjustDepth( short nDX )
     442             : {
     443           0 :     Indent( nDX );
     444           0 : }
     445             : 
     446           0 : void OutlinerView::Indent( short nDiff )
     447             : {
     448           0 :     if( !nDiff || ( ( nDiff > 0 ) && ImpCalcSelectedPages( true ) && !pOwner->ImpCanIndentSelectedPages( this ) ) )
     449           0 :         return;
     450             : 
     451           0 :     const bool bOutlinerView = pOwner->pEditEngine->GetControlWord() & EE_CNTRL_OUTLINER;
     452           0 :     bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
     453           0 :     pOwner->pEditEngine->SetUpdateMode( false );
     454             : 
     455           0 :     bool bUndo = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
     456             : 
     457           0 :     if( bUndo )
     458           0 :         pOwner->UndoActionStart( OLUNDO_DEPTH );
     459             : 
     460           0 :     sal_Int16 nMinDepth = -1;   // Optimization: Not to recalculate to manny parargaphs when not really needed.
     461             : 
     462           0 :     ParaRange aSel = ImpGetSelectedParagraphs( true );
     463           0 :     for ( sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
     464             :     {
     465           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
     466             : 
     467           0 :         sal_Int16 nOldDepth = pPara->GetDepth();
     468           0 :         sal_Int16 nNewDepth = nOldDepth + nDiff;
     469             : 
     470           0 :         if( bOutlinerView && nPara )
     471             :         {
     472           0 :             const bool bPage = pPara->HasFlag(PARAFLAG_ISPAGE);
     473           0 :             if( (bPage && (nDiff == +1)) || (!bPage && (nDiff == -1) && (nOldDepth <= 0))  )
     474             :             {
     475             :                             // Notify App
     476           0 :                 pOwner->nDepthChangedHdlPrevDepth = nOldDepth;
     477           0 :                 pOwner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
     478           0 :                 pOwner->pHdlParagraph = pPara;
     479             : 
     480           0 :                 if( bPage )
     481           0 :                     pPara->RemoveFlag( PARAFLAG_ISPAGE );
     482             :                 else
     483           0 :                     pPara->SetFlag( PARAFLAG_ISPAGE );
     484             : 
     485           0 :                 pOwner->DepthChangedHdl();
     486           0 :                 pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
     487             : 
     488           0 :                 if( bUndo )
     489           0 :                     pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nPara, pOwner->mnDepthChangeHdlPrevFlags, pPara->nFlags ) );
     490             : 
     491           0 :                 continue;
     492             :             }
     493             :         }
     494             : 
     495             :         // do not switch off numeration with tab
     496           0 :         if( (nOldDepth == 0) && (nNewDepth == -1) )
     497           0 :             continue;
     498             : 
     499             :         // do not indent if there is no numeration enabled
     500           0 :         if( nOldDepth == -1 )
     501           0 :             continue;
     502             : 
     503           0 :         if ( nNewDepth < pOwner->nMinDepth )
     504           0 :             nNewDepth = pOwner->nMinDepth;
     505           0 :         if ( nNewDepth > pOwner->nMaxDepth )
     506           0 :             nNewDepth = pOwner->nMaxDepth;
     507             : 
     508           0 :         if( nOldDepth < nMinDepth )
     509           0 :             nMinDepth = nOldDepth;
     510           0 :         if( nNewDepth < nMinDepth )
     511           0 :             nMinDepth = nNewDepth;
     512             : 
     513           0 :         if( nOldDepth != nNewDepth )
     514             :         {
     515           0 :             if ( ( nPara == aSel.nStartPara ) && aSel.nStartPara && ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ))
     516             :             {
     517             :                 // Special case: the predecessor of an indented paragraph is
     518             :                 // invisible and is now on the same level as the visible
     519             :                 // paragraph. In this case, the next visible paragraph is
     520             :                 // searched for and fluffed.
     521             : #ifdef DBG_UTIL
     522             :                 Paragraph* _pPara = pOwner->pParaList->GetParagraph( aSel.nStartPara );
     523             :                 DBG_ASSERT(_pPara->IsVisible(),"Selected Paragraph invisible ?!");
     524             : #endif
     525           0 :                 Paragraph* pPrev= pOwner->pParaList->GetParagraph( aSel.nStartPara-1 );
     526             : 
     527           0 :                 if( !pPrev->IsVisible() && ( pPrev->GetDepth() == nNewDepth ) )
     528             :                 {
     529             :                     // Predecessor is collapsed and is on the same level
     530             :                     // => find next visible paragraph and expand it
     531           0 :                     pPrev = pOwner->pParaList->GetParent( pPrev );
     532           0 :                     while( !pPrev->IsVisible() )
     533           0 :                         pPrev = pOwner->pParaList->GetParent( pPrev );
     534             : 
     535           0 :                     pOwner->Expand( pPrev );
     536           0 :                     pOwner->InvalidateBullet(pOwner->pParaList->GetAbsPos(pPrev));
     537             :                 }
     538             :             }
     539             : 
     540           0 :             pOwner->nDepthChangedHdlPrevDepth = nOldDepth;
     541           0 :             pOwner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
     542           0 :             pOwner->pHdlParagraph = pPara;
     543             : 
     544           0 :             pOwner->ImplInitDepth( nPara, nNewDepth, true, false );
     545           0 :             pOwner->ImplCalcBulletText( nPara, false, false );
     546             : 
     547           0 :             if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
     548           0 :                 pOwner->ImplSetLevelDependendStyleSheet( nPara );
     549             : 
     550             :             // Notify App
     551           0 :             pOwner->DepthChangedHdl();
     552             :         }
     553             :         else
     554             :         {
     555             :             // Needs at least a repaint...
     556           0 :             pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
     557             :         }
     558             :     }
     559             : 
     560           0 :     sal_Int32 nParas = pOwner->pParaList->GetParagraphCount();
     561           0 :     for ( sal_Int32 n = aSel.nEndPara+1; n < nParas; n++ )
     562             :     {
     563           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph( n );
     564           0 :         if ( pPara->GetDepth() < nMinDepth )
     565           0 :             break;
     566           0 :         pOwner->ImplCalcBulletText( n, false, false );
     567             :     }
     568             : 
     569           0 :     if ( bUpdate )
     570             :     {
     571           0 :         pEditView->SetEditEngineUpdateMode( true );
     572           0 :         pEditView->ShowCursor();
     573             :     }
     574             : 
     575           0 :     if( bUndo )
     576           0 :         pOwner->UndoActionEnd( OLUNDO_DEPTH );
     577             : }
     578             : 
     579           0 : bool OutlinerView::AdjustHeight( long nDY )
     580             : {
     581           0 :     pEditView->MoveParagraphs( nDY );
     582           0 :     return true;    // remove return value...
     583             : }
     584             : 
     585         208 : Rectangle OutlinerView::GetVisArea() const
     586             : {
     587         208 :     return pEditView->GetVisArea();
     588             : }
     589             : 
     590           0 : void OutlinerView::Expand()
     591             : {
     592           0 :     ParaRange aParas = ImpGetSelectedParagraphs( false );
     593           0 :     ImplExpandOrCollaps( aParas.nStartPara, aParas.nEndPara, true );
     594           0 : }
     595             : 
     596             : 
     597           0 : void OutlinerView::Collapse()
     598             : {
     599           0 :     ParaRange aParas = ImpGetSelectedParagraphs( false );
     600           0 :     ImplExpandOrCollaps( aParas.nStartPara, aParas.nEndPara, false );
     601           0 : }
     602             : 
     603             : 
     604           0 : void OutlinerView::ExpandAll()
     605             : {
     606           0 :     ImplExpandOrCollaps( 0, pOwner->pParaList->GetParagraphCount()-1, true );
     607           0 : }
     608             : 
     609             : 
     610           0 : void OutlinerView::CollapseAll()
     611             : {
     612           0 :     ImplExpandOrCollaps( 0, pOwner->pParaList->GetParagraphCount()-1, false );
     613           0 : }
     614             : 
     615           0 : void OutlinerView::ImplExpandOrCollaps( sal_Int32 nStartPara, sal_Int32 nEndPara, bool bExpand )
     616             : {
     617           0 :     bool bUpdate = pOwner->GetUpdateMode();
     618           0 :     pOwner->SetUpdateMode( false );
     619             : 
     620           0 :     bool bUndo = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
     621           0 :     if( bUndo )
     622           0 :         pOwner->UndoActionStart( bExpand ? OLUNDO_EXPAND : OLUNDO_COLLAPSE );
     623             : 
     624           0 :     for ( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
     625             :     {
     626           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
     627           0 :         bool bDone = bExpand ? pOwner->Expand( pPara ) : pOwner->Collapse( pPara );
     628           0 :         if( bDone )
     629             :         {
     630             :             // The line under the paragraph should disappear ...
     631           0 :             pOwner->pEditEngine->QuickMarkToBeRepainted( nPara );
     632             :         }
     633             :     }
     634             : 
     635           0 :     if( bUndo )
     636           0 :         pOwner->UndoActionEnd( bExpand ? OLUNDO_EXPAND : OLUNDO_COLLAPSE );
     637             : 
     638           0 :     if ( bUpdate )
     639             :     {
     640           0 :         pOwner->SetUpdateMode( true );
     641           0 :         pEditView->ShowCursor();
     642             :     }
     643           0 : }
     644             : 
     645           0 : void OutlinerView::InsertText( const OutlinerParaObject& rParaObj )
     646             : {
     647             :     // Like Paste, only EditView::Insert, instead of EditView::Paste.
     648             :     // Actually not quite true that possible indentations must be corrected,
     649             :     // but that comes later by a universal import. The indentation level is
     650             :     // then determined right in the Inserted method.
     651             :     // Possible structure:
     652             :     // pImportInfo with DestPara, DestPos, nFormat, pParaObj...
     653             :     // Possibly problematic:
     654             :     // EditEngine, RTF => Splitting the area, later join together.
     655             : 
     656           0 :     if ( ImpCalcSelectedPages( false ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
     657           0 :         return;
     658             : 
     659           0 :     pOwner->UndoActionStart( OLUNDO_INSERT );
     660             : 
     661           0 :     pOwner->pEditEngine->SetUpdateMode( false );
     662             :     sal_Int32 nStart, nParaCount;
     663           0 :     nParaCount = pOwner->pEditEngine->GetParagraphCount();
     664           0 :     sal_uInt16 nSize = ImpInitPaste( nStart );
     665           0 :     pEditView->InsertText( rParaObj.GetTextObject() );
     666           0 :     ImpPasted( nStart, nParaCount, nSize);
     667           0 :     pEditView->SetEditEngineUpdateMode( true );
     668             : 
     669           0 :     pOwner->UndoActionEnd( OLUNDO_INSERT );
     670             : 
     671           0 :     pEditView->ShowCursor( true, true );
     672             : }
     673             : 
     674             : 
     675             : 
     676           0 : void OutlinerView::Cut()
     677             : {
     678           0 :     if ( !ImpCalcSelectedPages( false ) || pOwner->ImpCanDeleteSelectedPages( this ) )
     679           0 :         pEditView->Cut();
     680           0 : }
     681             : 
     682           0 : void OutlinerView::Paste()
     683             : {
     684           0 :     PasteSpecial(); // HACK(SD does not call PasteSpecial)
     685           0 : }
     686             : 
     687           0 : void OutlinerView::PasteSpecial()
     688             : {
     689           0 :     if ( !ImpCalcSelectedPages( false ) || pOwner->ImpCanDeleteSelectedPages( this ) )
     690             :     {
     691           0 :         pOwner->UndoActionStart( OLUNDO_INSERT );
     692             : 
     693           0 :         pOwner->pEditEngine->SetUpdateMode( false );
     694           0 :         pOwner->bPasting = true;
     695           0 :         pEditView->PasteSpecial();
     696             : 
     697           0 :         if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
     698             :         {
     699           0 :             const sal_Int32 nParaCount = pOwner->pEditEngine->GetParagraphCount();
     700             : 
     701           0 :             for( sal_Int32 nPara = 0; nPara < nParaCount; nPara++ )
     702           0 :                 pOwner->ImplSetLevelDependendStyleSheet( nPara );
     703             :         }
     704             : 
     705           0 :         pEditView->SetEditEngineUpdateMode( true );
     706           0 :         pOwner->UndoActionEnd( OLUNDO_INSERT );
     707           0 :         pEditView->ShowCursor( true, true );
     708             :     }
     709           0 : }
     710             : 
     711           0 : void OutlinerView::CreateSelectionList (std::vector<Paragraph*> &aSelList)
     712             : {
     713           0 :     ParaRange aParas = ImpGetSelectedParagraphs( true );
     714             : 
     715           0 :     for ( sal_Int32 nPara = aParas.nStartPara; nPara <= aParas.nEndPara; nPara++ )
     716             :     {
     717           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
     718           0 :         aSelList.push_back(pPara);
     719             :     }
     720           0 : }
     721             : 
     722           0 : const SfxStyleSheet* OutlinerView::GetStyleSheet() const
     723             : {
     724           0 :     return pEditView->GetStyleSheet();
     725             : }
     726             : 
     727           0 : SfxStyleSheet* OutlinerView::GetStyleSheet()
     728             : {
     729           0 :     return pEditView->GetStyleSheet();
     730             : }
     731             : 
     732           0 : Pointer OutlinerView::GetPointer( const Point& rPosPixel )
     733             : {
     734             :     MouseTarget eTarget;
     735           0 :     ImpCheckMousePos( rPosPixel, eTarget );
     736             : 
     737           0 :     PointerStyle ePointerStyle = POINTER_ARROW;
     738           0 :     if ( eTarget == MouseText )
     739             :     {
     740           0 :         ePointerStyle = GetOutliner()->IsVertical() ? POINTER_TEXT_VERTICAL : POINTER_TEXT;
     741             :     }
     742           0 :     else if ( eTarget == MouseHypertext )
     743             :     {
     744           0 :         ePointerStyle = POINTER_REFHAND;
     745             :     }
     746           0 :     else if ( eTarget == MouseBullet )
     747             :     {
     748           0 :         ePointerStyle = POINTER_MOVE;
     749             :     }
     750             : 
     751           0 :     return Pointer( ePointerStyle );
     752             : }
     753             : 
     754             : 
     755           0 : sal_Int32 OutlinerView::ImpInitPaste( sal_Int32& rStart )
     756             : {
     757           0 :     pOwner->bPasting = true;
     758           0 :     ESelection aSelection( pEditView->GetSelection() );
     759           0 :     aSelection.Adjust();
     760           0 :     rStart = aSelection.nStartPara;
     761           0 :     sal_Int32 nSize = aSelection.nEndPara - aSelection.nStartPara + 1;
     762           0 :     return nSize;
     763             : }
     764             : 
     765             : 
     766           0 : void OutlinerView::ImpPasted( sal_Int32 nStart, sal_Int32 nPrevParaCount, sal_Int32 nSize)
     767             : {
     768           0 :     pOwner->bPasting = false;
     769           0 :     sal_Int32 nCurParaCount = pOwner->pEditEngine->GetParagraphCount();
     770           0 :     if( nCurParaCount < nPrevParaCount )
     771           0 :         nSize = nSize - ( nPrevParaCount - nCurParaCount );
     772             :     else
     773           0 :         nSize = nSize + ( nCurParaCount - nPrevParaCount );
     774           0 :     pOwner->ImpTextPasted( nStart, nSize );
     775           0 : }
     776             : 
     777             : 
     778           0 : void OutlinerView::Command( const CommandEvent& rCEvt )
     779             : {
     780           0 :     pEditView->Command( rCEvt );
     781           0 : }
     782             : 
     783             : 
     784           0 : void OutlinerView::SelectRange( sal_Int32 nFirst, sal_Int32 nCount )
     785             : {
     786           0 :     sal_Int32 nLast = nFirst+nCount;
     787           0 :     nCount = pOwner->pParaList->GetParagraphCount();
     788           0 :     if( nLast <= nCount )
     789           0 :         nLast = nCount - 1;
     790           0 :     ESelection aSel( nFirst, 0, nLast, EE_TEXTPOS_ALL );
     791           0 :     pEditView->SetSelection( aSel );
     792           0 : }
     793             : 
     794             : 
     795           0 : sal_Int32 OutlinerView::ImpCalcSelectedPages( bool bIncludeFirstSelected )
     796             : {
     797           0 :     ESelection aSel( pEditView->GetSelection() );
     798           0 :     aSel.Adjust();
     799             : 
     800           0 :     sal_Int32 nPages = 0;
     801           0 :     sal_Int32 nFirstPage = EE_PARA_MAX_COUNT;
     802           0 :     sal_Int32 nStartPara = aSel.nStartPara;
     803           0 :     if ( !bIncludeFirstSelected )
     804           0 :         nStartPara++;   // All paragraphs after StartPara will be deleted
     805           0 :     for ( sal_Int32 nPara = nStartPara; nPara <= aSel.nEndPara; nPara++ )
     806             :     {
     807           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
     808             :         DBG_ASSERT(pPara, "ImpCalcSelectedPages: invalid Selection? ");
     809           0 :         if( pPara->HasFlag(PARAFLAG_ISPAGE) )
     810             :         {
     811           0 :             nPages++;
     812           0 :             if( nFirstPage == EE_PARA_MAX_COUNT )
     813           0 :                 nFirstPage = nPara;
     814             :         }
     815             :     }
     816             : 
     817           0 :     if( nPages )
     818             :     {
     819           0 :         pOwner->nDepthChangedHdlPrevDepth = nPages;
     820           0 :         pOwner->pHdlParagraph = 0;
     821           0 :         pOwner->mnFirstSelPage = nFirstPage;
     822             :     }
     823             : 
     824           0 :     return nPages;
     825             : }
     826             : 
     827             : 
     828           0 : void OutlinerView::ToggleBullets()
     829             : {
     830           0 :     pOwner->UndoActionStart( OLUNDO_DEPTH );
     831             : 
     832           0 :     ESelection aSel( pEditView->GetSelection() );
     833           0 :     aSel.Adjust();
     834             : 
     835           0 :     const bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
     836           0 :     pOwner->pEditEngine->SetUpdateMode( false );
     837             : 
     838           0 :     sal_Int16 nNewDepth = -2;
     839           0 :     const SvxNumRule* pDefaultBulletNumRule = 0;
     840             : 
     841           0 :     for ( sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
     842             :     {
     843           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
     844             :         DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?");
     845             : 
     846           0 :         if( pPara )
     847             :         {
     848           0 :             if( nNewDepth == -2 )
     849             :             {
     850           0 :                 nNewDepth = (pOwner->GetDepth(nPara) == -1) ? 0 : -1;
     851           0 :                 if ( nNewDepth == 0 )
     852             :                 {
     853             :                     // determine default numbering rule for bullets
     854           0 :                     const ESelection aSelection(nPara, 0);
     855           0 :                     const SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection));
     856           0 :                     const SfxPoolItem& rPoolItem = aTmpSet.GetPool()->GetDefaultItem( EE_PARA_NUMBULLET );
     857           0 :                     const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(&rPoolItem);
     858           0 :                     pDefaultBulletNumRule =  pNumBulletItem ? pNumBulletItem->GetNumRule() : 0;
     859             :                 }
     860             :             }
     861             : 
     862           0 :             pOwner->SetDepth( pPara, nNewDepth );
     863             : 
     864           0 :             if( nNewDepth == -1 )
     865             :             {
     866           0 :                 const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara );
     867           0 :                 if ( rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SfxItemState::SET )
     868             :                 {
     869           0 :                     SfxItemSet aAttrs(rAttrs);
     870           0 :                     aAttrs.ClearItem( EE_PARA_BULLETSTATE );
     871           0 :                     pOwner->SetParaAttribs( nPara, aAttrs );
     872           0 :                 }
     873             :             }
     874             :             else
     875             :             {
     876           0 :                 if ( pDefaultBulletNumRule )
     877             :                 {
     878           0 :                     const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat( nPara );
     879           0 :                     if ( !pFmt
     880           0 :                          || ( pFmt->GetNumberingType() != SVX_NUM_BITMAP
     881           0 :                               && pFmt->GetNumberingType() != SVX_NUM_CHAR_SPECIAL ) )
     882             :                     {
     883           0 :                         SfxItemSet aAttrs( pOwner->GetParaAttribs( nPara ) );
     884           0 :                         SvxNumRule aNewNumRule( *pDefaultBulletNumRule );
     885           0 :                         aAttrs.Put( SvxNumBulletItem( aNewNumRule ), EE_PARA_NUMBULLET );
     886           0 :                         pOwner->SetParaAttribs( nPara, aAttrs );
     887             :                     }
     888             :                 }
     889             :             }
     890             :         }
     891             :     }
     892             : 
     893           0 :     const sal_Int32 nParaCount = pOwner->pParaList->GetParagraphCount();
     894           0 :     pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount );
     895             : 
     896           0 :     sal_Int32 nEndPara = (nParaCount > 0) ? nParaCount-1 : nParaCount;
     897           0 :     pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nEndPara, 0 ) );
     898             : 
     899           0 :     pOwner->pEditEngine->SetUpdateMode( bUpdate );
     900             : 
     901           0 :     pOwner->UndoActionEnd( OLUNDO_DEPTH );
     902           0 : }
     903             : 
     904             : 
     905           0 : void OutlinerView::ToggleBulletsNumbering(
     906             :     const bool bToggle,
     907             :     const bool bHandleBullets,
     908             :     const SvxNumRule* pNumRule )
     909             : {
     910           0 :     ESelection aSel( pEditView->GetSelection() );
     911           0 :     aSel.Adjust();
     912             : 
     913           0 :     bool bToggleOn = true;
     914           0 :     if ( bToggle )
     915             :     {
     916           0 :         bToggleOn = false;
     917           0 :         const sal_Int16 nBulletNumberingStatus( pOwner->GetBulletsNumberingStatus( aSel.nStartPara, aSel.nEndPara ) );
     918           0 :         if ( nBulletNumberingStatus != 0 && bHandleBullets )
     919             :         {
     920             :             // not all paragraphs have bullets and method called to toggle bullets --> bullets on
     921           0 :             bToggleOn = true;
     922             :         }
     923           0 :         else if ( nBulletNumberingStatus != 1 && !bHandleBullets )
     924             :         {
     925             :             // not all paragraphs have numbering and method called to toggle numberings --> numberings on
     926           0 :             bToggleOn = true;
     927             :         }
     928             :     }
     929           0 :     if ( bToggleOn )
     930             :     {
     931             :         // apply bullets/numbering for selected paragraphs
     932           0 :         ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle, true );
     933             :     }
     934             :     else
     935             :     {
     936             :         // switch off bullets/numbering for selected paragraphs
     937           0 :         SwitchOffBulletsNumbering( true );
     938             :     }
     939             : 
     940           0 :     return;
     941             : }
     942             : 
     943             : 
     944           0 : void OutlinerView::EnableBullets()
     945             : {
     946           0 :     pOwner->UndoActionStart( OLUNDO_DEPTH );
     947             : 
     948           0 :     ESelection aSel( pEditView->GetSelection() );
     949           0 :     aSel.Adjust();
     950             : 
     951           0 :     const bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
     952           0 :     pOwner->pEditEngine->SetUpdateMode( false );
     953             : 
     954           0 :     for ( sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
     955             :     {
     956           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
     957             :         DBG_ASSERT(pPara, "OutlinerView::EnableBullets(), illegal selection?");
     958             : 
     959           0 :         if( pPara && (pOwner->GetDepth(nPara) == -1) )
     960             :         {
     961           0 :             pOwner->SetDepth( pPara, 0 );
     962             :         }
     963             :     }
     964             : 
     965           0 :     sal_Int32 nParaCount = pOwner->pParaList->GetParagraphCount();
     966           0 :     pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount );
     967             : 
     968           0 :     sal_Int32 nEndPara = (nParaCount > 0) ? nParaCount-1 : nParaCount;
     969           0 :     pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nEndPara, 0 ) );
     970             : 
     971           0 :     pOwner->pEditEngine->SetUpdateMode( bUpdate );
     972             : 
     973           0 :     pOwner->UndoActionEnd( OLUNDO_DEPTH );
     974           0 : }
     975             : 
     976             : 
     977           0 : void OutlinerView::ApplyBulletsNumbering(
     978             :     const bool bHandleBullets,
     979             :     const SvxNumRule* pNewNumRule,
     980             :     const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule,
     981             :     const bool bAtSelection )
     982             : {
     983           0 :     if (!pOwner || !pOwner->pEditEngine || !pOwner->pParaList)
     984             :     {
     985           0 :         return;
     986             :     }
     987             : 
     988           0 :     pOwner->UndoActionStart(OLUNDO_DEPTH);
     989           0 :     const bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
     990           0 :     pOwner->pEditEngine->SetUpdateMode(false);
     991             : 
     992           0 :     sal_Int32 nStartPara = 0;
     993           0 :     sal_Int32 nEndPara = 0;
     994           0 :     if ( bAtSelection )
     995             :     {
     996           0 :         ESelection aSel( pEditView->GetSelection() );
     997           0 :         aSel.Adjust();
     998           0 :         nStartPara = aSel.nStartPara;
     999           0 :         nEndPara = aSel.nEndPara;
    1000             :     }
    1001             :     else
    1002             :     {
    1003           0 :         nStartPara = 0;
    1004           0 :         nEndPara = pOwner->pParaList->GetParagraphCount() - 1;
    1005             :     }
    1006             : 
    1007           0 :     for (sal_Int32 nPara = nStartPara; nPara <= nEndPara; ++nPara)
    1008             :     {
    1009           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph(nPara);
    1010             :         DBG_ASSERT(pPara, "OutlinerView::ApplyBulletsNumbering(..), illegal selection?");
    1011             : 
    1012           0 :         if (pPara)
    1013             :         {
    1014           0 :             const sal_Int16 nDepth = pOwner->GetDepth(nPara);
    1015           0 :             if ( nDepth == -1 )
    1016             :             {
    1017           0 :                 pOwner->SetDepth( pPara, 0 );
    1018             :             }
    1019             : 
    1020           0 :             const SfxItemSet& rAttrs = pOwner->GetParaAttribs(nPara);
    1021           0 :             SfxItemSet aAttrs(rAttrs);
    1022           0 :             aAttrs.Put(SfxBoolItem(EE_PARA_BULLETSTATE, true));
    1023             : 
    1024             :             // apply new numbering rule
    1025           0 :             if ( pNewNumRule )
    1026             :             {
    1027           0 :                 bool bApplyNumRule = false;
    1028           0 :                 if ( !bCheckCurrentNumRuleBeforeApplyingNewNumRule )
    1029             :                 {
    1030           0 :                     bApplyNumRule = true;
    1031             :                 }
    1032             :                 else
    1033             :                 {
    1034           0 :                     const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat(nPara);
    1035           0 :                     if (!pFmt)
    1036             :                     {
    1037           0 :                         bApplyNumRule = true;
    1038             :                     }
    1039             :                     else
    1040             :                     {
    1041           0 :                         sal_Int16 nNumType = pFmt->GetNumberingType();
    1042           0 :                         if ( bHandleBullets
    1043           0 :                              && nNumType != SVX_NUM_BITMAP && nNumType != SVX_NUM_CHAR_SPECIAL)
    1044             :                         {
    1045             :                             // Set to Normal bullet, old bullet type is Numbering bullet.
    1046           0 :                             bApplyNumRule = true;
    1047             :                         }
    1048           0 :                         else if ( !bHandleBullets
    1049           0 :                                   && (nNumType == SVX_NUM_BITMAP || nNumType == SVX_NUM_CHAR_SPECIAL))
    1050             :                         {
    1051             :                             // Set to Numbering bullet, old bullet type is Normal bullet.
    1052           0 :                             bApplyNumRule = true;
    1053             :                         }
    1054             :                     }
    1055             :                 }
    1056             : 
    1057           0 :                 if ( bApplyNumRule )
    1058             :                 {
    1059           0 :                     SvxNumRule aNewRule(*pNewNumRule);
    1060             : 
    1061             :                     // Get old bullet space.
    1062             :                     {
    1063           0 :                         const SfxPoolItem* pPoolItem=NULL;
    1064           0 :                         SfxItemState eState = rAttrs.GetItemState(EE_PARA_NUMBULLET, false, &pPoolItem);
    1065           0 :                         if (eState != SfxItemState::SET)
    1066             :                         {
    1067             :                             // Use default value when has not contain bullet item.
    1068           0 :                             ESelection aSelection(nPara, 0);
    1069           0 :                             SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection));
    1070           0 :                             pPoolItem = aTmpSet.GetItem(EE_PARA_NUMBULLET);
    1071             :                         }
    1072             : 
    1073           0 :                         const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(pPoolItem);
    1074           0 :                         if (pNumBulletItem)
    1075             :                         {
    1076           0 :                             const sal_uInt16 nLevelCnt = std::min(pNumBulletItem->GetNumRule()->GetLevelCount(), aNewRule.GetLevelCount());
    1077           0 :                             for ( sal_uInt16 nLevel = 0; nLevel < nLevelCnt; ++nLevel )
    1078             :                             {
    1079           0 :                                 const SvxNumberFormat* pOldFmt = pNumBulletItem->GetNumRule()->Get(nLevel);
    1080           0 :                                 const SvxNumberFormat* pNewFmt = aNewRule.Get(nLevel);
    1081           0 :                                 if (pOldFmt && pNewFmt && (pOldFmt->GetFirstLineOffset() != pNewFmt->GetFirstLineOffset() || pOldFmt->GetAbsLSpace() != pNewFmt->GetAbsLSpace()))
    1082             :                                 {
    1083           0 :                                     SvxNumberFormat* pNewFmtClone = new SvxNumberFormat(*pNewFmt);
    1084           0 :                                     pNewFmtClone->SetFirstLineOffset(pOldFmt->GetFirstLineOffset());
    1085           0 :                                     pNewFmtClone->SetAbsLSpace(pOldFmt->GetAbsLSpace());
    1086           0 :                                     aNewRule.SetLevel(nLevel, pNewFmtClone);
    1087           0 :                                     delete pNewFmtClone;
    1088             :                                 }
    1089             :                             }
    1090             :                         }
    1091             :                     }
    1092             : 
    1093           0 :                     aAttrs.Put(SvxNumBulletItem(aNewRule), EE_PARA_NUMBULLET);
    1094             :                 }
    1095             :             }
    1096           0 :             pOwner->SetParaAttribs(nPara, aAttrs);
    1097             :         }
    1098             :     }
    1099             : 
    1100           0 :     const sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount());
    1101           0 :     pOwner->ImplCheckParagraphs( nStartPara, nParaCount );
    1102           0 :     pOwner->pEditEngine->QuickMarkInvalid( ESelection( nStartPara, 0, nParaCount, 0 ) );
    1103             : 
    1104           0 :     pOwner->pEditEngine->SetUpdateMode( bUpdate );
    1105             : 
    1106           0 :     pOwner->UndoActionEnd( OLUNDO_DEPTH );
    1107             : 
    1108           0 :     return;
    1109             : }
    1110             : 
    1111             : 
    1112           0 : void OutlinerView::SwitchOffBulletsNumbering(
    1113             :     const bool bAtSelection )
    1114             : {
    1115           0 :     sal_Int32 nStartPara = 0;
    1116           0 :     sal_Int32 nEndPara = 0;
    1117           0 :     if ( bAtSelection )
    1118             :     {
    1119           0 :         ESelection aSel( pEditView->GetSelection() );
    1120           0 :         aSel.Adjust();
    1121           0 :         nStartPara = aSel.nStartPara;
    1122           0 :         nEndPara = aSel.nEndPara;
    1123             :     }
    1124             :     else
    1125             :     {
    1126           0 :         nStartPara = 0;
    1127           0 :         nEndPara = pOwner->pParaList->GetParagraphCount() - 1;
    1128             :     }
    1129             : 
    1130           0 :     pOwner->UndoActionStart( OLUNDO_DEPTH );
    1131           0 :     const bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
    1132           0 :     pOwner->pEditEngine->SetUpdateMode( false );
    1133             : 
    1134           0 :     for ( sal_Int32 nPara = nStartPara; nPara <= nEndPara; ++nPara )
    1135             :     {
    1136           0 :         Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
    1137             :         DBG_ASSERT(pPara, "OutlinerView::SwitchOffBulletsNumbering(...), illegal paragraph index?");
    1138             : 
    1139           0 :         if( pPara )
    1140             :         {
    1141           0 :             pOwner->SetDepth( pPara, -1 );
    1142             : 
    1143           0 :             const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara );
    1144           0 :             if (rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SfxItemState::SET)
    1145             :             {
    1146           0 :                 SfxItemSet aAttrs(rAttrs);
    1147           0 :                 aAttrs.ClearItem( EE_PARA_BULLETSTATE );
    1148           0 :                 pOwner->SetParaAttribs( nPara, aAttrs );
    1149           0 :             }
    1150             :         }
    1151             :     }
    1152             : 
    1153           0 :     const sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount());
    1154           0 :     pOwner->ImplCheckParagraphs( nStartPara, nParaCount );
    1155           0 :     pOwner->pEditEngine->QuickMarkInvalid( ESelection( nStartPara, 0, nParaCount, 0 ) );
    1156             : 
    1157           0 :     pOwner->pEditEngine->SetUpdateMode( bUpdate );
    1158           0 :     pOwner->UndoActionEnd( OLUNDO_DEPTH );
    1159           0 : }
    1160             : 
    1161             : 
    1162           0 : void OutlinerView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs )
    1163             : {
    1164           0 :     RemoveAttribs( bRemoveParaAttribs, 0, true /*keep language attribs*/ );
    1165           0 : }
    1166             : 
    1167           0 : void OutlinerView::RemoveAttribs( bool bRemoveParaAttribs, sal_uInt16 nWhich, bool bKeepLanguages )
    1168             : {
    1169           0 :     bool bUpdate = pOwner->GetUpdateMode();
    1170           0 :     pOwner->SetUpdateMode( false );
    1171           0 :     pOwner->UndoActionStart( OLUNDO_ATTR );
    1172           0 :     if (bKeepLanguages)
    1173           0 :         pEditView->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
    1174             :     else
    1175           0 :         pEditView->RemoveAttribs( bRemoveParaAttribs, nWhich );
    1176           0 :     if ( bRemoveParaAttribs )
    1177             :     {
    1178             :         // Loop through all paragraphs and set indentation and level
    1179           0 :         ESelection aSel = pEditView->GetSelection();
    1180           0 :         aSel.Adjust();
    1181           0 :         for ( sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
    1182             :         {
    1183           0 :             Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
    1184           0 :             pOwner->ImplInitDepth( nPara, pPara->GetDepth(), false, false );
    1185             :         }
    1186             :     }
    1187           0 :     pOwner->UndoActionEnd( OLUNDO_ATTR );
    1188           0 :     pOwner->SetUpdateMode( bUpdate );
    1189           0 : }
    1190             : 
    1191             : 
    1192             : 
    1193             : 
    1194             : // ======================   Simple pass-through   =======================
    1195             : 
    1196             : 
    1197             : 
    1198          22 : void OutlinerView::InsertText( const OUString& rNew, bool bSelect )
    1199             : {
    1200          22 :     if( pOwner->bFirstParaIsEmpty )
    1201          22 :         pOwner->Insert( OUString() );
    1202          22 :     pEditView->InsertText( rNew, bSelect );
    1203          22 : }
    1204             : 
    1205         208 : void OutlinerView::SetVisArea( const Rectangle& rRect )
    1206             : {
    1207         208 :     pEditView->SetVisArea( rRect );
    1208         208 : }
    1209             : 
    1210             : 
    1211         260 : void OutlinerView::SetSelection( const ESelection& rSel )
    1212             : {
    1213         260 :     pEditView->SetSelection( rSel );
    1214         260 : }
    1215             : 
    1216         130 : void OutlinerView::SetReadOnly( bool bReadOnly )
    1217             : {
    1218         130 :     pEditView->SetReadOnly( bReadOnly );
    1219         130 : }
    1220             : 
    1221           0 : bool OutlinerView::IsReadOnly() const
    1222             : {
    1223           0 :     return pEditView->IsReadOnly();
    1224             : }
    1225             : 
    1226           0 : bool OutlinerView::HasSelection() const
    1227             : {
    1228           0 :     return pEditView->HasSelection();
    1229             : }
    1230             : 
    1231         130 : void OutlinerView::ShowCursor( bool bGotoCursor )
    1232             : {
    1233         130 :     pEditView->ShowCursor( bGotoCursor );
    1234         130 : }
    1235             : 
    1236           0 : void OutlinerView::HideCursor()
    1237             : {
    1238           0 :     pEditView->HideCursor();
    1239           0 : }
    1240             : 
    1241         130 : void OutlinerView::SetWindow( vcl::Window* pWin )
    1242             : {
    1243         130 :     pEditView->SetWindow( pWin );
    1244         130 : }
    1245             : 
    1246           0 : vcl::Window* OutlinerView::GetWindow() const
    1247             : {
    1248           0 :     return pEditView->GetWindow();
    1249             : }
    1250             : 
    1251         338 : void OutlinerView::SetOutputArea( const Rectangle& rRect )
    1252             : {
    1253         338 :     pEditView->SetOutputArea( rRect );
    1254         338 : }
    1255             : 
    1256           0 : Rectangle OutlinerView::GetOutputArea() const
    1257             : {
    1258           0 :     return pEditView->GetOutputArea();
    1259             : }
    1260             : 
    1261           0 : OUString OutlinerView::GetSelected() const
    1262             : {
    1263           0 :     return pEditView->GetSelected();
    1264             : }
    1265             : 
    1266         130 : EESpellState OutlinerView::StartSpeller( bool bMultiDoc )
    1267             : {
    1268         130 :     return pEditView->StartSpeller( bMultiDoc );
    1269             : }
    1270             : 
    1271           0 : EESpellState OutlinerView::StartThesaurus()
    1272             : {
    1273           0 :     return pEditView->StartThesaurus();
    1274             : }
    1275             : 
    1276           0 : void OutlinerView::StartTextConversion(
    1277             :     LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont,
    1278             :     sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc )
    1279             : {
    1280           0 :     if (
    1281           0 :         (LANGUAGE_KOREAN == nSrcLang && LANGUAGE_KOREAN == nDestLang) ||
    1282           0 :         (LANGUAGE_CHINESE_SIMPLIFIED  == nSrcLang && LANGUAGE_CHINESE_TRADITIONAL == nDestLang) ||
    1283           0 :         (LANGUAGE_CHINESE_TRADITIONAL == nSrcLang && LANGUAGE_CHINESE_SIMPLIFIED  == nDestLang)
    1284             :        )
    1285             :     {
    1286           0 :         pEditView->StartTextConversion( nSrcLang, nDestLang, pDestFont, nOptions, bIsInteractive, bMultipleDoc );
    1287             :     }
    1288             :     else
    1289             :     {
    1290             :         OSL_FAIL( "unexpected language" );
    1291             :     }
    1292           0 : }
    1293             : 
    1294             : 
    1295           0 : sal_Int32 OutlinerView::StartSearchAndReplace( const SvxSearchItem& rSearchItem )
    1296             : {
    1297           0 :     return pEditView->StartSearchAndReplace( rSearchItem );
    1298             : }
    1299             : 
    1300           0 : void OutlinerView::TransliterateText( sal_Int32 nTransliterationMode )
    1301             : {
    1302           0 :     pEditView->TransliterateText( nTransliterationMode );
    1303           0 : }
    1304             : 
    1305         130 : ESelection OutlinerView::GetSelection()
    1306             : {
    1307         130 :     return pEditView->GetSelection();
    1308             : }
    1309             : 
    1310             : 
    1311           0 : void OutlinerView::Scroll( long nHorzScroll, long nVertScroll )
    1312             : {
    1313           0 :     pEditView->Scroll( nHorzScroll, nVertScroll );
    1314           0 : }
    1315             : 
    1316           0 : void OutlinerView::SetControlWord( sal_uLong nWord )
    1317             : {
    1318           0 :     pEditView->SetControlWord( nWord );
    1319           0 : }
    1320             : 
    1321           0 : sal_uLong OutlinerView::GetControlWord() const
    1322             : {
    1323           0 :     return pEditView->GetControlWord();
    1324             : }
    1325             : 
    1326           0 : void OutlinerView::SetAnchorMode( EVAnchorMode eMode )
    1327             : {
    1328           0 :     pEditView->SetAnchorMode( eMode );
    1329           0 : }
    1330             : 
    1331           0 : EVAnchorMode OutlinerView::GetAnchorMode() const
    1332             : {
    1333           0 :     return pEditView->GetAnchorMode();
    1334             : }
    1335             : 
    1336           0 : void OutlinerView::Copy()
    1337             : {
    1338           0 :     pEditView->Copy();
    1339           0 : }
    1340             : 
    1341           0 : void OutlinerView::InsertField( const SvxFieldItem& rFld )
    1342             : {
    1343           0 :     pEditView->InsertField( rFld );
    1344           0 : }
    1345             : 
    1346           0 : const SvxFieldItem* OutlinerView::GetFieldUnderMousePointer() const
    1347             : {
    1348           0 :     return pEditView->GetFieldUnderMousePointer();
    1349             : }
    1350             : 
    1351           0 : const SvxFieldItem* OutlinerView::GetFieldAtSelection() const
    1352             : {
    1353           0 :     return pEditView->GetFieldAtSelection();
    1354             : }
    1355             : 
    1356           0 : void OutlinerView::SetInvalidateMore( sal_uInt16 nPixel )
    1357             : {
    1358           0 :     pEditView->SetInvalidateMore( nPixel );
    1359           0 : }
    1360             : 
    1361             : 
    1362           0 : sal_uInt16 OutlinerView::GetInvalidateMore() const
    1363             : {
    1364           0 :     return pEditView->GetInvalidateMore();
    1365             : }
    1366             : 
    1367             : 
    1368           0 : bool OutlinerView::IsCursorAtWrongSpelledWord( bool bMarkIfWrong )
    1369             : {
    1370           0 :     return pEditView->IsCursorAtWrongSpelledWord( bMarkIfWrong );
    1371             : }
    1372             : 
    1373             : 
    1374           0 : bool OutlinerView::IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong )
    1375             : {
    1376           0 :     return pEditView->IsWrongSpelledWordAtPos( rPosPixel, bMarkIfWrong );
    1377             : }
    1378             : 
    1379           0 : void OutlinerView::ExecuteSpellPopup( const Point& rPosPixel, Link* pStartDlg )
    1380             : {
    1381           0 :     pEditView->ExecuteSpellPopup( rPosPixel, pStartDlg );
    1382           0 : }
    1383             : 
    1384           0 : sal_uLong OutlinerView::Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, bool bSelect, SvKeyValueIterator* pHTTPHeaderAttrs )
    1385             : {
    1386           0 :     sal_Int32 nOldParaCount = pEditView->GetEditEngine()->GetParagraphCount();
    1387           0 :     ESelection aOldSel = pEditView->GetSelection();
    1388           0 :     aOldSel.Adjust();
    1389             : 
    1390           0 :     sal_uLong nRet = pEditView->Read( rInput, rBaseURL, eFormat, bSelect, pHTTPHeaderAttrs );
    1391             : 
    1392           0 :     long nParaDiff = pEditView->GetEditEngine()->GetParagraphCount() - nOldParaCount;
    1393           0 :     sal_Int32 nChangesStart = aOldSel.nStartPara;
    1394           0 :     sal_Int32 nChangesEnd = nChangesStart + nParaDiff + (aOldSel.nEndPara-aOldSel.nStartPara);
    1395             : 
    1396           0 :     for ( sal_Int32 n = nChangesStart; n <= nChangesEnd; n++ )
    1397             :     {
    1398           0 :         if ( eFormat == EE_FORMAT_BIN )
    1399             :         {
    1400           0 :             const SfxItemSet& rAttrs = pOwner->GetParaAttribs( n );
    1401           0 :             const SfxInt16Item& rLevel = static_cast<const SfxInt16Item&>( rAttrs.Get( EE_PARA_OUTLLEVEL ) );
    1402           0 :             sal_uInt16 nDepth = rLevel.GetValue();
    1403           0 :             pOwner->ImplInitDepth( n, nDepth, false );
    1404             :         }
    1405             : 
    1406           0 :         if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
    1407           0 :             pOwner->ImplSetLevelDependendStyleSheet( n );
    1408             :     }
    1409             : 
    1410           0 :     if ( eFormat != EE_FORMAT_BIN )
    1411             :     {
    1412           0 :         pOwner->ImpFilterIndents( nChangesStart, nChangesEnd );
    1413             :     }
    1414             : 
    1415           0 :     return nRet;
    1416             : }
    1417             : 
    1418         130 : void OutlinerView::SetBackgroundColor( const Color& rColor )
    1419             : {
    1420         130 :     pEditView->SetBackgroundColor( rColor );
    1421         130 : }
    1422             : 
    1423             : 
    1424           0 : Color OutlinerView::GetBackgroundColor()
    1425             : {
    1426           0 :     return pEditView->GetBackgroundColor();
    1427             : }
    1428             : 
    1429         130 : SfxItemSet OutlinerView::GetAttribs()
    1430             : {
    1431         130 :     return pEditView->GetAttribs();
    1432             : }
    1433             : 
    1434           0 : sal_uInt16 OutlinerView::GetSelectedScriptType() const
    1435             : {
    1436           0 :     return pEditView->GetSelectedScriptType();
    1437             : }
    1438             : 
    1439           0 : OUString OutlinerView::GetSurroundingText() const
    1440             : {
    1441           0 :     return pEditView->GetSurroundingText();
    1442             : }
    1443             : 
    1444           0 : Selection OutlinerView::GetSurroundingTextSelection() const
    1445             : {
    1446           0 :     return pEditView->GetSurroundingTextSelection();
    1447             : }
    1448             : 
    1449             : 
    1450             : 
    1451             : // ===== some code for thesaurus sub menu within context menu
    1452             : 
    1453             : 
    1454             : namespace {
    1455             : 
    1456           0 : bool isSingleScriptType( sal_uInt16 nScriptType )
    1457             : {
    1458           0 :     sal_uInt8 nScriptCount = 0;
    1459             : 
    1460           0 :     if (nScriptType & SCRIPTTYPE_LATIN)
    1461           0 :         ++nScriptCount;
    1462           0 :     if (nScriptType & SCRIPTTYPE_ASIAN)
    1463           0 :         ++nScriptCount;
    1464           0 :     if (nScriptType & SCRIPTTYPE_COMPLEX)
    1465           0 :         ++nScriptCount;
    1466             : 
    1467           0 :     return nScriptCount == 1;
    1468             : }
    1469             : 
    1470             : }
    1471             : 
    1472             : // returns: true if a word for thesaurus look-up was found at the current cursor position.
    1473             : // The status string will be word + iso language string (e.g. "light#en-US")
    1474           0 : bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext(
    1475             :     OUString &rStatusVal,
    1476             :     LanguageType &rLang,
    1477             :     const EditView &rEditView )
    1478             : {
    1479             :     // get text and locale for thesaurus look up
    1480           0 :     OUString aText;
    1481           0 :     EditEngine *pEditEngine = rEditView.GetEditEngine();
    1482           0 :     ESelection aTextSel( rEditView.GetSelection() );
    1483           0 :     if (!aTextSel.HasRange())
    1484           0 :         aTextSel = pEditEngine->GetWord( aTextSel, i18n::WordType::DICTIONARY_WORD );
    1485           0 :     aText = pEditEngine->GetText( aTextSel );
    1486           0 :     aTextSel.Adjust();
    1487             : 
    1488           0 :     if (!isSingleScriptType(pEditEngine->GetScriptType(aTextSel)))
    1489           0 :         return false;
    1490             : 
    1491           0 :     LanguageType nLang = pEditEngine->GetLanguage( aTextSel.nStartPara, aTextSel.nStartPos );
    1492           0 :     OUString aLangText( LanguageTag::convertToBcp47( nLang ) );
    1493             : 
    1494             :     // set word and locale to look up as status value
    1495           0 :     rStatusVal  = aText + "#" + aLangText;
    1496           0 :     rLang       = nLang;
    1497             : 
    1498           0 :     return aText.getLength() > 0;
    1499             : }
    1500             : 
    1501             : 
    1502           0 : void EDITENG_DLLPUBLIC ReplaceTextWithSynonym( EditView &rEditView, const OUString &rSynonmText )
    1503             : {
    1504             :     // get selection to use
    1505           0 :     ESelection aCurSel( rEditView.GetSelection() );
    1506           0 :     if (!rEditView.HasSelection())
    1507             :     {
    1508             :         // select the same word that was used in GetStatusValueForThesaurusFromContext by calling GetWord.
    1509             :         // (In the end both functions will call ImpEditEngine::SelectWord)
    1510           0 :         rEditView.SelectCurrentWord( i18n::WordType::DICTIONARY_WORD );
    1511           0 :         aCurSel = rEditView.GetSelection();
    1512             :     }
    1513             : 
    1514             :     // replace word ...
    1515           0 :     rEditView.InsertText( rSynonmText );
    1516           0 :     rEditView.ShowCursor( true, false );
    1517         669 : }
    1518             : 
    1519             : 
    1520             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10