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

Generated by: LCOV version 1.10