LCOV - code coverage report
Current view: top level - editeng/source/outliner - outliner.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 575 1075 53.5 %
Date: 2014-04-11 Functions: 52 99 52.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <comphelper/string.hxx>
      21             : #include <svl/intitem.hxx>
      22             : #include <editeng/editeng.hxx>
      23             : #include <editeng/editview.hxx>
      24             : #include <editeng/editdata.hxx>
      25             : #include <editeng/eerdll.hxx>
      26             : #include <editeng/lrspitem.hxx>
      27             : #include <editeng/fhgtitem.hxx>
      28             : 
      29             : #include <math.h>
      30             : #include <svl/style.hxx>
      31             : #include <vcl/wrkwin.hxx>
      32             : #include <editeng/outliner.hxx>
      33             : #include <paralist.hxx>
      34             : #include <editeng/outlobj.hxx>
      35             : #include <outleeng.hxx>
      36             : #include <outlundo.hxx>
      37             : #include <editeng/eeitem.hxx>
      38             : #include <editeng/editstat.hxx>
      39             : #include <editeng/scripttypeitem.hxx>
      40             : #include <editeng/editobj.hxx>
      41             : #include <svl/itemset.hxx>
      42             : #include <svl/whiter.hxx>
      43             : #include <vcl/metric.hxx>
      44             : #include <editeng/numitem.hxx>
      45             : #include <editeng/adjustitem.hxx>
      46             : #include <vcl/graph.hxx>
      47             : #include <vcl/gdimtf.hxx>
      48             : #include <vcl/metaact.hxx>
      49             : #include <svtools/grfmgr.hxx>
      50             : #include <editeng/svxfont.hxx>
      51             : #include <editeng/brushitem.hxx>
      52             : #include <svl/itempool.hxx>
      53             : 
      54             : // calculate if it's RTL or not
      55             : #include <unicode/ubidi.h>
      56             : #include <cassert>
      57             : #include <boost/scoped_array.hpp>
      58             : using ::std::advance;
      59             : 
      60             : 
      61             : // Outliner
      62             : 
      63             : 
      64      166651 : void Outliner::ImplCheckDepth( sal_Int16& rnDepth ) const
      65             : {
      66      166651 :     if( rnDepth < nMinDepth )
      67           0 :         rnDepth = nMinDepth;
      68      166651 :     else if( rnDepth > nMaxDepth )
      69           0 :         rnDepth = nMaxDepth;
      70      166651 : }
      71             : 
      72         849 : Paragraph* Outliner::Insert(const OUString& rText, sal_Int32 nAbsPos, sal_Int16 nDepth)
      73             : {
      74             :     DBG_ASSERT(pParaList->GetParagraphCount(),"Insert:No Paras");
      75             : 
      76             :     Paragraph* pPara;
      77             : 
      78         849 :     ImplCheckDepth( nDepth );
      79             : 
      80         849 :     sal_Int32 nParagraphCount = pParaList->GetParagraphCount();
      81         849 :     if( nAbsPos > nParagraphCount )
      82           1 :         nAbsPos = nParagraphCount;
      83             : 
      84         849 :     if( bFirstParaIsEmpty )
      85             :     {
      86         630 :         pPara = pParaList->GetParagraph( 0 );
      87         630 :         if( pPara->GetDepth() != nDepth )
      88             :         {
      89         630 :             nDepthChangedHdlPrevDepth = pPara->GetDepth();
      90         630 :             mnDepthChangeHdlPrevFlags = pPara->nFlags;
      91         630 :             pPara->SetDepth( nDepth );
      92         630 :             pHdlParagraph = pPara;
      93         630 :             DepthChangedHdl();
      94             :         }
      95         630 :         pPara->nFlags |= PARAFLAG_HOLDDEPTH;
      96         630 :         SetText( rText, pPara );
      97             :     }
      98             :     else
      99             :     {
     100         219 :         bool bUpdate = pEditEngine->GetUpdateMode();
     101         219 :         pEditEngine->SetUpdateMode( false );
     102         219 :         ImplBlockInsertionCallbacks( true );
     103         219 :         pPara = new Paragraph( nDepth );
     104         219 :         pParaList->Insert( pPara, nAbsPos );
     105         219 :         pEditEngine->InsertParagraph( nAbsPos, OUString() );
     106             :         DBG_ASSERT(pPara==pParaList->GetParagraph(nAbsPos),"Insert:Failed");
     107         219 :         ImplInitDepth( nAbsPos, nDepth, false );
     108         219 :         pHdlParagraph = pPara;
     109         219 :         ParagraphInsertedHdl();
     110         219 :         pPara->nFlags |= PARAFLAG_HOLDDEPTH;
     111         219 :         SetText( rText, pPara );
     112         219 :         ImplBlockInsertionCallbacks( false );
     113         219 :         pEditEngine->SetUpdateMode( bUpdate );
     114             :     }
     115         849 :     bFirstParaIsEmpty = false;
     116             :     DBG_ASSERT(pEditEngine->GetParagraphCount()==pParaList->GetParagraphCount(),"SetText failed");
     117         849 :     return pPara;
     118             : }
     119             : 
     120             : 
     121      328473 : void Outliner::ParagraphInserted( sal_Int32 nPara )
     122             : {
     123             : 
     124      328473 :     if ( nBlockInsCallback )
     125      656043 :         return;
     126             : 
     127         903 :     if( bPasting || pEditEngine->IsInUndo() )
     128             :     {
     129           0 :         Paragraph* pPara = new Paragraph( -1 );
     130           0 :         pParaList->Insert( pPara, nPara );
     131           0 :         if( pEditEngine->IsInUndo() )
     132             :         {
     133           0 :             pPara->nFlags = PARAFLAG_SETBULLETTEXT;
     134           0 :             pPara->bVisible = true;
     135           0 :             const SfxInt16Item& rLevel = (const SfxInt16Item&) pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL );
     136           0 :             pPara->SetDepth( rLevel.GetValue() );
     137             :         }
     138             :     }
     139             :     else
     140             :     {
     141         903 :         sal_Int16 nDepth = -1;
     142         903 :         Paragraph* pParaBefore = pParaList->GetParagraph( nPara-1 );
     143         903 :         if ( pParaBefore )
     144         903 :             nDepth = pParaBefore->GetDepth();
     145             : 
     146         903 :         Paragraph* pPara = new Paragraph( nDepth );
     147         903 :         pParaList->Insert( pPara, nPara );
     148             : 
     149         903 :         if( !pEditEngine->IsInUndo() )
     150             :         {
     151         903 :             ImplCalcBulletText( nPara, true, false );
     152         903 :             pHdlParagraph = pPara;
     153         903 :             ParagraphInsertedHdl();
     154             :         }
     155             :     }
     156             : }
     157             : 
     158      320150 : void Outliner::ParagraphDeleted( sal_Int32 nPara )
     159             : {
     160             : 
     161      320150 :     if ( nBlockInsCallback || ( nPara == EE_PARA_ALL ) )
     162      319637 :         return;
     163             : 
     164         513 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
     165         513 :         if (!pPara)
     166           0 :             return;
     167             : 
     168         513 :     sal_Int16 nDepth = pPara->GetDepth();
     169             : 
     170         513 :     if( !pEditEngine->IsInUndo() )
     171             :     {
     172         513 :         pHdlParagraph = pPara;
     173         513 :         ParagraphRemovingHdl();
     174             :     }
     175             : 
     176         513 :     pParaList->Remove( nPara );
     177         513 :     delete pPara;
     178             : 
     179         513 :     if( !pEditEngine->IsInUndo() && !bPasting )
     180             :     {
     181         513 :         pPara = pParaList->GetParagraph( nPara );
     182         513 :         if ( pPara && ( pPara->GetDepth() > nDepth ) )
     183             :         {
     184           0 :             ImplCalcBulletText( nPara, true, false );
     185             :             // Search for next on the this level ...
     186           0 :             while ( pPara && pPara->GetDepth() > nDepth )
     187           0 :                 pPara = pParaList->GetParagraph( ++nPara );
     188             :         }
     189             : 
     190         513 :         if ( pPara && ( pPara->GetDepth() == nDepth ) )
     191          10 :             ImplCalcBulletText( nPara, true, false );
     192             :     }
     193             : }
     194             : 
     195      516298 : void Outliner::Init( sal_uInt16 nMode )
     196             : {
     197      516298 :     nOutlinerMode = nMode;
     198             : 
     199      516298 :     Clear();
     200             : 
     201      516298 :     sal_uLong nCtrl = pEditEngine->GetControlWord();
     202      516298 :     nCtrl &= ~(EE_CNTRL_OUTLINER|EE_CNTRL_OUTLINER2);
     203             : 
     204      516298 :     SetMaxDepth( 9 );
     205             : 
     206      516298 :     switch ( ImplGetOutlinerMode() )
     207             :     {
     208             :         case OUTLINERMODE_TEXTOBJECT:
     209             :         case OUTLINERMODE_TITLEOBJECT:
     210      507806 :             break;
     211             : 
     212             :         case OUTLINERMODE_OUTLINEOBJECT:
     213        8492 :             nCtrl |= EE_CNTRL_OUTLINER2;
     214        8492 :             break;
     215             :         case OUTLINERMODE_OUTLINEVIEW:
     216           0 :             nCtrl |= EE_CNTRL_OUTLINER;
     217           0 :             break;
     218             : 
     219             :         default: OSL_FAIL( "Outliner::Init - Invalid Mode!" );
     220             :     }
     221             : 
     222      516298 :     pEditEngine->SetControlWord( nCtrl );
     223             : 
     224      516298 :     const bool bWasUndoEnabled(IsUndoEnabled());
     225      516298 :     EnableUndo(false);
     226      516298 :     ImplInitDepth( 0, GetMinDepth(), false );
     227      516298 :     GetUndoManager().Clear();
     228      516298 :     EnableUndo(bWasUndoEnabled);
     229      516298 : }
     230             : 
     231      516298 : void Outliner::SetMaxDepth( sal_Int16 nDepth, bool bCheckParagraphs )
     232             : {
     233      516298 :     if( nMaxDepth != nDepth )
     234             :     {
     235           0 :         nMaxDepth = std::min( nDepth, (sal_Int16)(SVX_MAX_NUM-1) );
     236             : 
     237           0 :         if( bCheckParagraphs )
     238             :         {
     239           0 :             sal_Int32 nParagraphs = pParaList->GetParagraphCount();
     240           0 :             for ( sal_Int32 nPara = 0; nPara < nParagraphs; nPara++ )
     241             :             {
     242           0 :                 Paragraph* pPara = pParaList->GetParagraph( nPara );
     243           0 :                 if( pPara && pPara->GetDepth() > nMaxDepth )
     244             :                 {
     245           0 :                     SetDepth( pPara, nMaxDepth );
     246             :                 }
     247             :             }
     248             :         }
     249             :     }
     250      516298 : }
     251             : 
     252        1153 : sal_Int16 Outliner::GetDepth( sal_Int32 nPara ) const
     253             : {
     254        1153 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
     255             :     DBG_ASSERT( pPara, "Outliner::GetDepth - Paragraph not found!" );
     256        1153 :     return pPara ? pPara->GetDepth() : -1;
     257             : }
     258             : 
     259        1254 : void Outliner::SetDepth( Paragraph* pPara, sal_Int16 nNewDepth )
     260             : {
     261             : 
     262        1254 :     ImplCheckDepth( nNewDepth );
     263             : 
     264        1254 :     if ( nNewDepth != pPara->GetDepth() )
     265             :     {
     266        1065 :         nDepthChangedHdlPrevDepth = pPara->GetDepth();
     267        1065 :         mnDepthChangeHdlPrevFlags = pPara->nFlags;
     268        1065 :         pHdlParagraph = pPara;
     269             : 
     270        1065 :         sal_Int32 nPara = GetAbsPos( pPara );
     271        1065 :         ImplInitDepth( nPara, nNewDepth, true );
     272        1065 :         ImplCalcBulletText( nPara, false, false );
     273             : 
     274        1065 :         if ( ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
     275          57 :             ImplSetLevelDependendStyleSheet( nPara );
     276             : 
     277        1065 :         DepthChangedHdl();
     278             :     }
     279        1254 : }
     280             : 
     281           2 : sal_Int16 Outliner::GetNumberingStartValue( sal_Int32 nPara )
     282             : {
     283           2 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
     284             :     DBG_ASSERT( pPara, "Outliner::GetNumberingStartValue - Paragraph not found!" );
     285           2 :     return pPara ? pPara->GetNumberingStartValue() : -1;
     286             : }
     287             : 
     288           0 : void Outliner::SetNumberingStartValue( sal_Int32 nPara, sal_Int16 nNumberingStartValue )
     289             : {
     290           0 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
     291             :     DBG_ASSERT( pPara, "Outliner::GetNumberingStartValue - Paragraph not found!" );
     292           0 :     if( pPara && pPara->GetNumberingStartValue() != nNumberingStartValue )
     293             :     {
     294           0 :         if( IsUndoEnabled() && !IsInUndo() )
     295             :             InsertUndo( new OutlinerUndoChangeParaNumberingRestart( this, nPara,
     296           0 :                 pPara->GetNumberingStartValue(), nNumberingStartValue,
     297           0 :                 pPara->IsParaIsNumberingRestart(), pPara->IsParaIsNumberingRestart() ) );
     298             : 
     299           0 :         pPara->SetNumberingStartValue( nNumberingStartValue );
     300           0 :         ImplCheckParagraphs( nPara, pParaList->GetParagraphCount() );
     301           0 :         pEditEngine->SetModified();
     302             :     }
     303           0 : }
     304             : 
     305          10 : bool Outliner::IsParaIsNumberingRestart( sal_Int32 nPara )
     306             : {
     307          10 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
     308             :     DBG_ASSERT( pPara, "Outliner::IsParaIsNumberingRestart - Paragraph not found!" );
     309          10 :     return pPara ? pPara->IsParaIsNumberingRestart() : false;
     310             : }
     311             : 
     312           4 : void Outliner::SetParaIsNumberingRestart( sal_Int32 nPara, bool bParaIsNumberingRestart )
     313             : {
     314           4 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
     315             :     DBG_ASSERT( pPara, "Outliner::SetParaIsNumberingRestart - Paragraph not found!" );
     316           4 :     if( pPara && (pPara->IsParaIsNumberingRestart() != bParaIsNumberingRestart) )
     317             :     {
     318           4 :         if( IsUndoEnabled() && !IsInUndo() )
     319             :             InsertUndo( new OutlinerUndoChangeParaNumberingRestart( this, nPara,
     320           8 :                 pPara->GetNumberingStartValue(), pPara->GetNumberingStartValue(),
     321           8 :                 pPara->IsParaIsNumberingRestart(), bParaIsNumberingRestart ) );
     322             : 
     323           4 :         pPara->SetParaIsNumberingRestart( bParaIsNumberingRestart );
     324           4 :         ImplCheckParagraphs( nPara, pParaList->GetParagraphCount() );
     325           4 :         pEditEngine->SetModified();
     326             :     }
     327           4 : }
     328             : 
     329           0 : sal_Int32 Outliner::GetBulletsNumberingStatus(
     330             :     const sal_Int32 nParaStart,
     331             :     const sal_Int32 nParaEnd ) const
     332             : {
     333           0 :     if ( nParaStart > nParaEnd
     334           0 :          || nParaEnd >= pParaList->GetParagraphCount() )
     335             :     {
     336             :         DBG_ASSERT( false,"<Outliner::GetBulletsNumberingStatus> - unexpected parameter values" );
     337           0 :         return 2;
     338             :     }
     339             : 
     340           0 :     sal_Int32 nBulletsCount = 0;
     341           0 :     sal_Int32 nNumberingCount = 0;
     342           0 :     for (sal_Int32 nPara = nParaStart; nPara <= nParaEnd; ++nPara)
     343             :     {
     344           0 :         if ( !pParaList->GetParagraph(nPara) )
     345             :         {
     346           0 :             break;
     347             :         }
     348           0 :         const SvxNumberFormat* pFmt = GetNumberFormat(nPara);
     349           0 :         if (!pFmt)
     350             :         {
     351             :             // At least, exists one paragraph that has no Bullets/Numbering.
     352           0 :             break;
     353             :         }
     354           0 :         else if ((pFmt->GetNumberingType() == SVX_NUM_BITMAP) || (pFmt->GetNumberingType() == SVX_NUM_CHAR_SPECIAL))
     355             :         {
     356             :             // Having Bullets in this paragraph.
     357           0 :             nBulletsCount++;
     358             :         }
     359             :         else
     360             :         {
     361             :             // Having Numbering in this paragraph.
     362           0 :             nNumberingCount++;
     363             :         }
     364             :     }
     365             : 
     366           0 :     const sal_Int32 nParaCount = nParaEnd - nParaStart + 1;
     367           0 :     if ( nBulletsCount == nParaCount )
     368             :     {
     369           0 :         return 0;
     370             :     }
     371           0 :     else if ( nNumberingCount == nParaCount )
     372             :     {
     373           0 :         return 1;
     374             :     }
     375           0 :     return 2;
     376             : }
     377             : 
     378           0 : sal_Int32 Outliner::GetBulletsNumberingStatus() const
     379             : {
     380           0 :     return pParaList->GetParagraphCount() > 0
     381           0 :            ? GetBulletsNumberingStatus( 0, pParaList->GetParagraphCount()-1 )
     382           0 :            : 2;
     383             : }
     384             : 
     385       65441 : OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 nCount ) const
     386             : {
     387             : 
     388      130882 :     if ( static_cast<sal_uLong>(nStartPara) + nCount >
     389       65441 :             static_cast<sal_uLong>(pParaList->GetParagraphCount()) )
     390       20620 :         nCount = pParaList->GetParagraphCount() - nStartPara;
     391             : 
     392             :     // When a new OutlinerParaObject is created because a paragraph is just beeing deleted,
     393             :     // it can happen that the ParaList is not updated yet...
     394       65441 :     if ( ( nStartPara + nCount ) > pEditEngine->GetParagraphCount() )
     395           0 :         nCount = pEditEngine->GetParagraphCount() - nStartPara;
     396             : 
     397       65441 :     if( !nCount )
     398           0 :         return NULL;
     399             : 
     400       65441 :     EditTextObject* pText = pEditEngine->CreateTextObject( nStartPara, nCount );
     401       65441 :     const bool bIsEditDoc(OUTLINERMODE_TEXTOBJECT == ImplGetOutlinerMode());
     402       65441 :     ParagraphDataVector aParagraphDataVector(nCount);
     403       65441 :     const sal_Int32 nLastPara(nStartPara + nCount - 1);
     404             : 
     405      135722 :     for(sal_Int32 nPara(nStartPara); nPara <= nLastPara; nPara++)
     406             :     {
     407       70281 :         aParagraphDataVector[nPara-nStartPara] = *GetParagraph(nPara);
     408             :     }
     409             : 
     410       65441 :     OutlinerParaObject* pPObj = new OutlinerParaObject(*pText, aParagraphDataVector, bIsEditDoc);
     411       65441 :     pPObj->SetOutlinerMode(GetMode());
     412       65441 :     delete pText;
     413             : 
     414       65441 :     return pPObj;
     415             : }
     416             : 
     417       17673 : void Outliner::SetText( const OUString& rText, Paragraph* pPara )
     418             : {
     419             :     DBG_ASSERT(pPara,"SetText:No Para");
     420             : 
     421       17673 :     bool bUpdate = pEditEngine->GetUpdateMode();
     422       17673 :     pEditEngine->SetUpdateMode( false );
     423       17673 :     ImplBlockInsertionCallbacks( true );
     424             : 
     425       17673 :     sal_Int32 nPara = pParaList->GetAbsPos( pPara );
     426             : 
     427       17673 :     if (rText.isEmpty())
     428             :     {
     429       16598 :         pEditEngine->SetText( nPara, rText );
     430       16598 :         ImplInitDepth( nPara, pPara->GetDepth(), false );
     431             :     }
     432             :     else
     433             :     {
     434        1075 :         OUString aText(convertLineEnd(rText, LINEEND_LF));
     435             : 
     436        1075 :         if (aText.endsWith("\x0A"))
     437           0 :             aText = aText.copy(0, aText.getLength()-1); // Delete the last break
     438             : 
     439        1075 :         sal_Int32 nCount = comphelper::string::getTokenCount(aText, '\x0A');
     440        1075 :         sal_Int32 nPos = 0;
     441        1075 :         sal_Int32 nInsPos = nPara+1;
     442        3837 :         while( nCount > nPos )
     443             :         {
     444        1687 :             OUString aStr = aText.getToken( nPos, '\x0A' );
     445             : 
     446             :             sal_Int16 nCurDepth;
     447        1687 :             if( nPos )
     448             :             {
     449         612 :                 pPara = new Paragraph( -1 );
     450         612 :                 nCurDepth = -1;
     451             :             }
     452             :             else
     453        1075 :                 nCurDepth = pPara->GetDepth();
     454             : 
     455             :             // In the outliner mode, filter the tabs and set the indentation
     456             :             // about a LRSpaceItem. In EditEngine mode intend over old tabs
     457        2565 :             if( ( ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT ) ||
     458         878 :                 ( ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEVIEW ) )
     459             :             {
     460             :                 // Extract Tabs
     461         809 :                 sal_uInt16 nTabs = 0;
     462        4569 :                 while ( ( nTabs < aStr.getLength() ) && ( aStr[nTabs] == '\t' ) )
     463        2951 :                     nTabs++;
     464         809 :                 if ( nTabs )
     465         809 :                     aStr = aStr.copy(nTabs);
     466             : 
     467             :                 // Keep depth?  (see Outliner::Insert)
     468         809 :                 if( !(pPara->nFlags & PARAFLAG_HOLDDEPTH) )
     469             :                 {
     470         809 :                     nCurDepth = nTabs-1;
     471         809 :                     ImplCheckDepth( nCurDepth );
     472         809 :                     pPara->SetDepth( nCurDepth );
     473         809 :                     pPara->nFlags &= (~PARAFLAG_HOLDDEPTH);
     474             :                 }
     475             :             }
     476        1687 :             if( nPos ) // not with the first paragraph
     477             :             {
     478         612 :                 pParaList->Insert( pPara, nInsPos );
     479         612 :                 pEditEngine->InsertParagraph( nInsPos, aStr );
     480         612 :                 pHdlParagraph = pPara;
     481         612 :                 ParagraphInsertedHdl();
     482             :             }
     483             :             else
     484             :             {
     485        1075 :                 nInsPos--;
     486        1075 :                 pEditEngine->SetText( nInsPos, aStr );
     487             :             }
     488        1687 :             ImplInitDepth( nInsPos, nCurDepth, false );
     489        1687 :             nInsPos++;
     490        1687 :             nPos++;
     491        2762 :         }
     492             :     }
     493             : 
     494             :     DBG_ASSERT(pParaList->GetParagraphCount()==pEditEngine->GetParagraphCount(),"SetText failed!");
     495       17673 :     bFirstParaIsEmpty = false;
     496       17673 :     ImplBlockInsertionCallbacks( false );
     497       17673 :     pEditEngine->SetUpdateMode( bUpdate );
     498       17673 : }
     499             : 
     500             : // pView == 0 -> Ignore tabs
     501             : 
     502           0 : bool Outliner::ImpConvertEdtToOut( sal_Int32 nPara,EditView* pView)
     503             : {
     504             : 
     505           0 :     bool bConverted = false;
     506           0 :     sal_Int32 nTabs = 0;
     507           0 :     ESelection aDelSel;
     508             : 
     509           0 :     OUString aName;
     510           0 :     OUString aHeading_US( "heading" );
     511           0 :     OUString aNumber_US( "Numbering" );
     512             : 
     513           0 :     OUString aStr( pEditEngine->GetText( nPara ) );
     514           0 :     const sal_Unicode* pPtr = aStr.getStr();
     515             : 
     516           0 :     sal_Int32 nHeadingNumberStart = 0;
     517           0 :     sal_Int32 nNumberingNumberStart = 0;
     518           0 :     SfxStyleSheet* pStyle= pEditEngine->GetStyleSheet( nPara );
     519           0 :     if( pStyle )
     520             :     {
     521           0 :         aName = pStyle->GetName();
     522             :         sal_Int32 nSearch;
     523           0 :         if ( ( nSearch = aName.indexOf( aHeading_US ) ) != -1 )
     524           0 :             nHeadingNumberStart = nSearch + aHeading_US.getLength();
     525           0 :         else if ( ( nSearch = aName.indexOf( aNumber_US ) ) != -1 )
     526           0 :             nNumberingNumberStart = nSearch + aNumber_US.getLength();
     527             :     }
     528             : 
     529           0 :     if ( nHeadingNumberStart || nNumberingNumberStart )
     530             :     {
     531             :         // PowerPoint import ?
     532           0 :         if( nHeadingNumberStart && ( aStr.getLength() >= 2 ) &&
     533           0 :                 ( pPtr[0] != '\t' ) && ( pPtr[1] == '\t' ) )
     534             :         {
     535             :             // Extract Bullet and Tab
     536           0 :             aDelSel = ESelection( nPara, 0, nPara, 2 );
     537             :         }
     538             : 
     539           0 :         sal_Int32 nPos = nHeadingNumberStart ? nHeadingNumberStart : nNumberingNumberStart;
     540           0 :         OUString aLevel = comphelper::string::stripStart(aName.copy(nPos), ' ');
     541           0 :         nTabs = aLevel.toInt32();
     542           0 :         if( nTabs )
     543           0 :             nTabs--; // Level 0 = "heading 1"
     544           0 :         bConverted = true;
     545             :     }
     546             :     else
     547             :     {
     548             :         // filter leading tabs
     549           0 :         while( *pPtr == '\t' )
     550             :         {
     551           0 :             pPtr++;
     552           0 :             nTabs++;
     553             :         }
     554             :         // Remove tabs from the text
     555           0 :         if( nTabs )
     556           0 :             aDelSel = ESelection( nPara, 0, nPara, nTabs );
     557             :     }
     558             : 
     559           0 :     if ( aDelSel.HasRange() )
     560             :     {
     561           0 :         if ( pView )
     562             :         {
     563           0 :             pView->SetSelection( aDelSel );
     564           0 :             pView->DeleteSelected();
     565             :         }
     566             :         else
     567           0 :             pEditEngine->QuickDelete( aDelSel );
     568             :     }
     569             : 
     570           0 :     const SfxInt16Item& rLevel = (const SfxInt16Item&) pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL );
     571           0 :     sal_Int16 nOutlLevel = rLevel.GetValue();
     572             : 
     573           0 :     ImplCheckDepth( nOutlLevel );
     574           0 :     ImplInitDepth( nPara, nOutlLevel, false );
     575             : 
     576           0 :     return bConverted;
     577             : }
     578             : 
     579      156637 : void Outliner::SetText( const OutlinerParaObject& rPObj )
     580             : {
     581             : 
     582      156637 :     bool bUpdate = pEditEngine->GetUpdateMode();
     583      156637 :     pEditEngine->SetUpdateMode( false );
     584             : 
     585      156637 :     bool bUndo = pEditEngine->IsUndoEnabled();
     586      156637 :     EnableUndo( false );
     587             : 
     588      156637 :     Init( rPObj.GetOutlinerMode() );
     589             : 
     590      156637 :     ImplBlockInsertionCallbacks( true );
     591      156637 :     pEditEngine->SetText(rPObj.GetTextObject());
     592             : 
     593      156637 :     bFirstParaIsEmpty = false;
     594             : 
     595      156637 :     pParaList->Clear( true );
     596      320376 :     for( sal_Int32 nCurPara = 0; nCurPara < rPObj.Count(); nCurPara++ )
     597             :     {
     598      163739 :         Paragraph* pPara = new Paragraph( rPObj.GetParagraphData(nCurPara));
     599      163739 :         ImplCheckDepth( pPara->nDepth );
     600             : 
     601      163739 :         pParaList->Append(pPara);
     602      163739 :         ImplCheckNumBulletItem( nCurPara );
     603             :     }
     604             : 
     605      156637 :     ImplCheckParagraphs( 0, pParaList->GetParagraphCount() );
     606             : 
     607      156637 :     EnableUndo( bUndo );
     608      156637 :     ImplBlockInsertionCallbacks( false );
     609      156637 :     pEditEngine->SetUpdateMode( bUpdate );
     610             : 
     611             :     DBG_ASSERT( pParaList->GetParagraphCount()==rPObj.Count(),"SetText failed");
     612             :     DBG_ASSERT( pEditEngine->GetParagraphCount()==rPObj.Count(),"SetText failed");
     613      156637 : }
     614             : 
     615           0 : void Outliner::AddText( const OutlinerParaObject& rPObj )
     616             : {
     617             :     Paragraph* pPara;
     618             : 
     619           0 :     bool bUpdate = pEditEngine->GetUpdateMode();
     620           0 :     pEditEngine->SetUpdateMode( false );
     621             : 
     622           0 :     ImplBlockInsertionCallbacks( true );
     623             :     sal_Int32 nPara;
     624           0 :     if( bFirstParaIsEmpty )
     625             :     {
     626           0 :         pParaList->Clear( true );
     627           0 :         pEditEngine->SetText(rPObj.GetTextObject());
     628           0 :         nPara = 0;
     629             :     }
     630             :     else
     631             :     {
     632           0 :         nPara = pParaList->GetParagraphCount();
     633           0 :         pEditEngine->InsertParagraph( EE_PARA_APPEND, rPObj.GetTextObject() );
     634             :     }
     635           0 :     bFirstParaIsEmpty = false;
     636             : 
     637           0 :     for( sal_Int32 n = 0; n < rPObj.Count(); n++ )
     638             :     {
     639           0 :         pPara = new Paragraph( rPObj.GetParagraphData(n) );
     640           0 :         pParaList->Append(pPara);
     641           0 :         sal_Int32 nP = nPara+n;
     642             :         DBG_ASSERT(pParaList->GetAbsPos(pPara)==nP,"AddText:Out of sync");
     643           0 :         ImplInitDepth( nP, pPara->GetDepth(), false );
     644             :     }
     645             :     DBG_ASSERT( pEditEngine->GetParagraphCount()==pParaList->GetParagraphCount(), "SetText: OutOfSync" );
     646             : 
     647           0 :     ImplCheckParagraphs( nPara, pParaList->GetParagraphCount() );
     648             : 
     649           0 :     ImplBlockInsertionCallbacks( false );
     650           0 :     pEditEngine->SetUpdateMode( bUpdate );
     651           0 : }
     652             : 
     653           0 : void Outliner::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
     654             : {
     655             : 
     656           0 :     if ( aFieldClickedHdl.IsSet() )
     657             :     {
     658           0 :         EditFieldInfo aFldInfo( this, rField, nPara, nPos );
     659           0 :         aFldInfo.SetSimpleClick( true );
     660           0 :         aFieldClickedHdl.Call( &aFldInfo );
     661             :     }
     662           0 : }
     663             : 
     664             : 
     665           0 : void Outliner::FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
     666             : {
     667           0 :     if ( !aFieldClickedHdl.IsSet() )
     668           0 :         return;
     669             : 
     670           0 :     EditFieldInfo aFldInfo( this, rField, nPara, nPos );
     671           0 :     aFldInfo.SetSimpleClick( false );
     672           0 :     aFieldClickedHdl.Call( &aFldInfo );
     673             : }
     674             : 
     675             : 
     676        3452 : OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
     677             : {
     678        3452 :     if ( !aCalcFieldValueHdl.IsSet() )
     679           0 :         return OUString( ' ' );
     680             : 
     681        3452 :     EditFieldInfo aFldInfo( this, rField, nPara, nPos );
     682             :     // The FldColor is preset with COL_LIGHTGRAY.
     683        3452 :     if ( rpFldColor )
     684          94 :         aFldInfo.SetFldColor( *rpFldColor );
     685             : 
     686        3452 :     aCalcFieldValueHdl.Call( &aFldInfo );
     687        3452 :     if ( aFldInfo.GetTxtColor() )
     688             :     {
     689           3 :         delete rpTxtColor;
     690           3 :         rpTxtColor = new Color( *aFldInfo.GetTxtColor() );
     691             :     }
     692             : 
     693        3452 :     delete rpFldColor;
     694        3452 :     rpFldColor = aFldInfo.GetFldColor() ? new Color( *aFldInfo.GetFldColor() ) : 0;
     695             : 
     696        3452 :     return aFldInfo.GetRepresentation();
     697             : }
     698             : 
     699       11918 : void Outliner::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle )
     700             : {
     701       11918 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
     702       11918 :         if (pPara)
     703             :         {
     704       11918 :             pEditEngine->SetStyleSheet( nPara, pStyle );
     705       11918 :             pPara->nFlags |= PARAFLAG_SETBULLETTEXT;
     706       11918 :             ImplCheckNumBulletItem(  nPara );
     707             :         }
     708       11918 : }
     709             : 
     710     1299632 : void Outliner::ImplCheckNumBulletItem( sal_Int32 nPara )
     711             : {
     712     1299632 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
     713     1299632 :         if (pPara)
     714     1299632 :             pPara->aBulSize.Width() = -1;
     715     1299632 : }
     716             : 
     717         116 : void Outliner::ImplSetLevelDependendStyleSheet( sal_Int32 nPara, SfxStyleSheet* pLevelStyle )
     718             : {
     719             : 
     720             :     DBG_ASSERT( ( ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT ) || ( ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEVIEW ), "SetLevelDependendStyleSheet: Wrong Mode!" );
     721             : 
     722         116 :     SfxStyleSheet* pStyle = pLevelStyle;
     723         116 :     if ( !pStyle )
     724         116 :         pStyle = GetStyleSheet( nPara );
     725             : 
     726         116 :     if ( pStyle )
     727             :     {
     728         116 :         sal_Int16 nDepth = GetDepth( nPara );
     729         116 :         if( nDepth < 0 )
     730          26 :             nDepth = 0;
     731             : 
     732         116 :         OUString aNewStyleSheetName( pStyle->GetName() );
     733         116 :         aNewStyleSheetName = aNewStyleSheetName.copy( 0, aNewStyleSheetName.getLength()-1 );
     734         116 :         aNewStyleSheetName += OUString::number( nDepth+1 );
     735         116 :         SfxStyleSheet* pNewStyle = (SfxStyleSheet*)GetStyleSheetPool()->Find( aNewStyleSheetName, pStyle->GetFamily() );
     736             :         DBG_ASSERT( pNewStyle, "AutoStyleSheetName - Style not found!" );
     737         116 :         if ( pNewStyle && ( pNewStyle != GetStyleSheet( nPara ) ) )
     738             :         {
     739          32 :             SfxItemSet aOldAttrs( GetParaAttribs( nPara ) );
     740          32 :             SetStyleSheet( nPara, pNewStyle );
     741          32 :             if ( aOldAttrs.GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON )
     742             :             {
     743          26 :                 SfxItemSet aAttrs( GetParaAttribs( nPara ) );
     744          26 :                 aAttrs.Put( aOldAttrs.Get( EE_PARA_NUMBULLET ) );
     745          26 :                 SetParaAttribs( nPara, aAttrs );
     746          32 :             }
     747         116 :         }
     748             :     }
     749         116 : }
     750             : 
     751      535867 : void Outliner::ImplInitDepth( sal_Int32 nPara, sal_Int16 nDepth, bool bCreateUndo, bool bUndoAction )
     752             : {
     753             : 
     754             :     DBG_ASSERT( ( nDepth >= nMinDepth ) && ( nDepth <= nMaxDepth ), "ImplInitDepth - Depth is invalid!" );
     755             : 
     756      535867 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
     757      535867 :         if (!pPara)
     758      535867 :             return;
     759      535867 :     sal_Int16 nOldDepth = pPara->GetDepth();
     760      535867 :     pPara->SetDepth( nDepth );
     761             : 
     762             :     // For IsInUndo attributes and style do not have to be set, there
     763             :     // the old values are restored by the EditEngine.
     764      535867 :     if( !IsInUndo() )
     765             :     {
     766      535867 :         bool bUpdate = pEditEngine->GetUpdateMode();
     767      535867 :         pEditEngine->SetUpdateMode( false );
     768             : 
     769      535867 :         bool bUndo = bCreateUndo && IsUndoEnabled();
     770      535867 :         if ( bUndo && bUndoAction )
     771           0 :             UndoActionStart( OLUNDO_DEPTH );
     772             : 
     773      535867 :         SfxItemSet aAttrs( pEditEngine->GetParaAttribs( nPara ) );
     774      535867 :         aAttrs.Put( SfxInt16Item( EE_PARA_OUTLLEVEL, nDepth ) );
     775      535867 :         pEditEngine->SetParaAttribs( nPara, aAttrs );
     776      535867 :         ImplCheckNumBulletItem( nPara );
     777      535867 :         ImplCalcBulletText( nPara, false, false );
     778             : 
     779      535867 :         if ( bUndo )
     780             :         {
     781           4 :             InsertUndo( new OutlinerUndoChangeDepth( this, nPara, nOldDepth, nDepth ) );
     782           4 :             if ( bUndoAction )
     783           0 :                 UndoActionEnd( OLUNDO_DEPTH );
     784             :         }
     785             : 
     786      535867 :         pEditEngine->SetUpdateMode( bUpdate );
     787             :     }
     788             : }
     789             : 
     790       52085 : void Outliner::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
     791             : {
     792             : 
     793       52085 :     pEditEngine->SetParaAttribs( nPara, rSet );
     794       52085 : }
     795             : 
     796           0 : bool Outliner::Expand( Paragraph* pPara )
     797             : {
     798             : 
     799           0 :     if ( pParaList->HasHiddenChildren( pPara ) )
     800             :     {
     801           0 :         OLUndoExpand* pUndo = 0;
     802           0 :         bool bUndo = IsUndoEnabled() && !IsInUndo();
     803           0 :         if( bUndo )
     804             :         {
     805           0 :             UndoActionStart( OLUNDO_EXPAND );
     806           0 :             pUndo = new OLUndoExpand( this, OLUNDO_EXPAND );
     807           0 :             pUndo->pParas = 0;
     808           0 :             pUndo->nCount = pParaList->GetAbsPos( pPara );
     809             :         }
     810           0 :         pHdlParagraph = pPara;
     811           0 :         bIsExpanding = true;
     812           0 :         pParaList->Expand( pPara );
     813           0 :         ExpandHdl();
     814           0 :         InvalidateBullet( pPara, pParaList->GetAbsPos(pPara) );
     815           0 :         if( bUndo )
     816             :         {
     817           0 :             InsertUndo( pUndo );
     818           0 :             UndoActionEnd( OLUNDO_EXPAND );
     819             :         }
     820           0 :         return true;
     821             :     }
     822           0 :     return false;
     823             : }
     824             : 
     825             : 
     826           0 : bool Outliner::Collapse( Paragraph* pPara )
     827             : {
     828           0 :     if ( pParaList->HasVisibleChildren( pPara ) ) // expanded
     829             :     {
     830           0 :         OLUndoExpand* pUndo = 0;
     831           0 :         bool bUndo = false;
     832             : 
     833           0 :         if( !IsInUndo() && IsUndoEnabled() )
     834           0 :             bUndo = true;
     835           0 :         if( bUndo )
     836             :         {
     837           0 :             UndoActionStart( OLUNDO_COLLAPSE );
     838           0 :             pUndo = new OLUndoExpand( this, OLUNDO_COLLAPSE );
     839           0 :             pUndo->pParas = 0;
     840           0 :             pUndo->nCount = pParaList->GetAbsPos( pPara );
     841             :         }
     842             : 
     843           0 :         pHdlParagraph = pPara;
     844           0 :         bIsExpanding = false;
     845           0 :         pParaList->Collapse( pPara );
     846           0 :         ExpandHdl();
     847           0 :         InvalidateBullet( pPara, pParaList->GetAbsPos(pPara) );
     848           0 :         if( bUndo )
     849             :         {
     850           0 :             InsertUndo( pUndo );
     851           0 :             UndoActionEnd( OLUNDO_COLLAPSE );
     852             :         }
     853           0 :         return true;
     854             :     }
     855           0 :     return false;
     856             : }
     857             : 
     858             : 
     859        1398 : Font Outliner::ImpCalcBulletFont( sal_Int32 nPara ) const
     860             : {
     861        1398 :     const SvxNumberFormat* pFmt = GetNumberFormat( nPara );
     862             :     DBG_ASSERT( pFmt && ( pFmt->GetNumberingType() != SVX_NUM_BITMAP ) && ( pFmt->GetNumberingType() != SVX_NUM_NUMBER_NONE ), "ImpCalcBulletFont: Missing or BitmapBullet!" );
     863             : 
     864        1398 :     Font aStdFont;
     865        1398 :     if ( !pEditEngine->IsFlatMode() )
     866             :     {
     867        1398 :         ESelection aSel( nPara, 0, nPara, 0 );
     868        1398 :         aStdFont = EditEngine::CreateFontFromItemSet( pEditEngine->GetAttribs( aSel ), GetScriptType( aSel ) );
     869             :     }
     870             :     else
     871             :     {
     872           0 :         aStdFont = pEditEngine->GetStandardFont( nPara );
     873             :     }
     874             : 
     875        1398 :     Font aBulletFont;
     876        1398 :     const Font *pSourceFont = 0;
     877        1398 :     if ( pFmt->GetNumberingType() == SVX_NUM_CHAR_SPECIAL )
     878             :     {
     879        1398 :         pSourceFont = pFmt->GetBulletFont();
     880             :     }
     881             : 
     882        1398 :     if (pSourceFont)
     883             :     {
     884        1344 :         aBulletFont = *pSourceFont;
     885             :     }
     886             :     else
     887             :     {
     888          54 :         aBulletFont = aStdFont;
     889          54 :         aBulletFont.SetUnderline( UNDERLINE_NONE );
     890          54 :         aBulletFont.SetOverline( UNDERLINE_NONE );
     891          54 :         aBulletFont.SetStrikeout( STRIKEOUT_NONE );
     892          54 :         aBulletFont.SetEmphasisMark( EMPHASISMARK_NONE );
     893          54 :         aBulletFont.SetRelief( RELIEF_NONE );
     894             :     }
     895             : 
     896             :     // Use original scale...
     897             :     sal_uInt16 nStretchX, nStretchY;
     898        1398 :     GetGlobalCharStretching(nStretchX, nStretchY);
     899             : 
     900        1398 :     sal_uInt16 nScale = pFmt->GetBulletRelSize() * nStretchY / 100;
     901        1398 :     sal_uLong nScaledLineHeight = aStdFont.GetSize().Height();
     902        1398 :     nScaledLineHeight *= nScale*10;
     903        1398 :     nScaledLineHeight /= 1000;
     904             : 
     905        1398 :     aBulletFont.SetAlign( ALIGN_BOTTOM );
     906        1398 :     aBulletFont.SetSize( Size( 0, nScaledLineHeight ) );
     907        1398 :     bool bVertical = IsVertical();
     908        1398 :     aBulletFont.SetVertical( bVertical );
     909        1398 :     aBulletFont.SetOrientation( bVertical ? 2700 : 0 );
     910             : 
     911        1398 :     Color aColor( COL_AUTO );
     912        1398 :     if( !pEditEngine->IsFlatMode() && !( pEditEngine->GetControlWord() & EE_CNTRL_NOCOLORS ) )
     913             :     {
     914        1398 :         aColor = pFmt->GetBulletColor();
     915             :     }
     916             : 
     917        1398 :     if ( ( aColor == COL_AUTO ) || ( IsForceAutoColor() ) )
     918        1307 :         aColor = pEditEngine->GetAutoColor();
     919             : 
     920        1398 :     aBulletFont.SetColor( aColor );
     921        1398 :     return aBulletFont;
     922             : }
     923             : 
     924       11033 : void Outliner::PaintBullet( sal_Int32 nPara, const Point& rStartPos,
     925             :     const Point& rOrigin, short nOrientation, OutputDevice* pOutDev )
     926             : {
     927             : 
     928       11033 :     bool bDrawBullet = false;
     929       11033 :     if (pEditEngine)
     930             :     {
     931       11033 :         const SfxBoolItem& rBulletState = (const SfxBoolItem&) pEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE );
     932       11033 :         bDrawBullet = rBulletState.GetValue() ? true : false;
     933             :     }
     934             : 
     935       11033 :     if ( ImplHasNumberFormat( nPara ) && bDrawBullet)
     936             :     {
     937         431 :         bool bVertical = IsVertical();
     938             : 
     939         431 :         bool bRightToLeftPara = pEditEngine->IsRightToLeft( nPara );
     940             : 
     941         431 :         Rectangle aBulletArea( ImpCalcBulletArea( nPara, true, false ) );
     942             :         sal_uInt16 nStretchX, nStretchY;
     943         431 :         GetGlobalCharStretching(nStretchX, nStretchY);
     944         431 :         aBulletArea = Rectangle( Point(aBulletArea.Left()*nStretchX/100,
     945         431 :                                        aBulletArea.Top()),
     946         431 :                                  Size(aBulletArea.GetWidth()*nStretchX/100,
     947        1724 :                                       aBulletArea.GetHeight()) );
     948             : 
     949         431 :         Paragraph* pPara = pParaList->GetParagraph( nPara );
     950         431 :         const SvxNumberFormat* pFmt = GetNumberFormat( nPara );
     951         431 :         if ( pFmt && ( pFmt->GetNumberingType() != SVX_NUM_NUMBER_NONE ) )
     952             :         {
     953         431 :             if( pFmt->GetNumberingType() != SVX_NUM_BITMAP )
     954             :             {
     955         431 :                 Font aBulletFont( ImpCalcBulletFont( nPara ) );
     956             :                 // Use baseline
     957         431 :                 bool bSymbol = pFmt->GetNumberingType() == SVX_NUM_CHAR_SPECIAL;
     958         431 :                 aBulletFont.SetAlign( bSymbol ? ALIGN_BOTTOM : ALIGN_BASELINE );
     959         862 :                 Font aOldFont = pOutDev->GetFont();
     960         431 :                 pOutDev->SetFont( aBulletFont );
     961             : 
     962         431 :                 ParagraphInfos  aParaInfos = pEditEngine->GetParagraphInfos( nPara );
     963         431 :                 Point aTextPos;
     964         431 :                 if ( !bVertical )
     965             :                 {
     966             : //                  aTextPos.Y() = rStartPos.Y() + aBulletArea.Bottom();
     967         431 :                     aTextPos.Y() = rStartPos.Y() + ( bSymbol ? aBulletArea.Bottom() : aParaInfos.nFirstLineMaxAscent );
     968         431 :                     if ( !bRightToLeftPara )
     969         431 :                         aTextPos.X() = rStartPos.X() + aBulletArea.Left();
     970             :                     else
     971           0 :                         aTextPos.X() = rStartPos.X() + GetPaperSize().Width() - aBulletArea.Right();
     972             :                 }
     973             :                 else
     974             :                 {
     975             : //                  aTextPos.X() = rStartPos.X() - aBulletArea.Bottom();
     976           0 :                     aTextPos.X() = rStartPos.X() - ( bSymbol ? aBulletArea.Bottom() : aParaInfos.nFirstLineMaxAscent );
     977           0 :                     aTextPos.Y() = rStartPos.Y() + aBulletArea.Left();
     978             :                 }
     979             : 
     980         431 :                 if ( nOrientation )
     981             :                 {
     982             :                     // Both TopLeft and bottom left is not quite correct,
     983             :                     // since in EditEngine baseline ...
     984           0 :                     double nRealOrientation = nOrientation*F_PI1800;
     985           0 :                     double nCos = cos( nRealOrientation );
     986           0 :                     double nSin = sin( nRealOrientation );
     987           0 :                     Point aRotatedPos;
     988             :                     // Translation...
     989           0 :                     aTextPos -= rOrigin;
     990             :                     // Rotation...
     991           0 :                     aRotatedPos.X()=(long)   (nCos*aTextPos.X() + nSin*aTextPos.Y());
     992           0 :                     aRotatedPos.Y()=(long) - (nSin*aTextPos.X() - nCos*aTextPos.Y());
     993           0 :                     aTextPos = aRotatedPos;
     994             :                     // Translation...
     995           0 :                     aTextPos += rOrigin;
     996           0 :                     Font aRotatedFont( aBulletFont );
     997           0 :                     aRotatedFont.SetOrientation( nOrientation );
     998           0 :                     pOutDev->SetFont( aRotatedFont );
     999             :                 }
    1000             : 
    1001             :                 // VCL will take care of brackets and so on...
    1002         431 :                 sal_uLong nLayoutMode = pOutDev->GetLayoutMode();
    1003         431 :                 nLayoutMode &= ~(TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_COMPLEX_DISABLED|TEXT_LAYOUT_BIDI_STRONG);
    1004         431 :                 if ( bRightToLeftPara )
    1005           0 :                     nLayoutMode |= TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT | TEXT_LAYOUT_BIDI_STRONG;
    1006         431 :                 pOutDev->SetLayoutMode( nLayoutMode );
    1007             : 
    1008         431 :                 if(bStrippingPortions)
    1009             :                 {
    1010         431 :                     const Font aSvxFont(pOutDev->GetFont());
    1011         862 :                     boost::scoped_array<sal_Int32> pBuf(new sal_Int32[ pPara->GetText().getLength() ]);
    1012         431 :                     pOutDev->GetTextArray( pPara->GetText(), pBuf.get() );
    1013             : 
    1014         431 :                     if(bSymbol)
    1015             :                     {
    1016             :                         // aTextPos is Bottom, go to Baseline
    1017         431 :                         FontMetric aMetric(pOutDev->GetFontMetric());
    1018         431 :                         aTextPos.Y() -= aMetric.GetDescent();
    1019             :                     }
    1020             : 
    1021         862 :                     DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), pBuf.get(),
    1022        1724 :                         aSvxFont, nPara, -1, bRightToLeftPara, 0, 0, false, false, true, 0, Color(), Color());
    1023             :                 }
    1024             :                 else
    1025             :                 {
    1026           0 :                     pOutDev->DrawText( aTextPos, pPara->GetText() );
    1027             :                 }
    1028             : 
    1029         862 :                 pOutDev->SetFont( aOldFont );
    1030             :             }
    1031             :             else
    1032             :             {
    1033           0 :                 if ( pFmt->GetBrush()->GetGraphicObject() )
    1034             :                 {
    1035           0 :                     Point aBulletPos;
    1036           0 :                     if ( !bVertical )
    1037             :                     {
    1038           0 :                         aBulletPos.Y() = rStartPos.Y() + aBulletArea.Top();
    1039           0 :                         if ( !bRightToLeftPara )
    1040           0 :                             aBulletPos.X() = rStartPos.X() + aBulletArea.Left();
    1041             :                         else
    1042           0 :                             aBulletPos.X() = rStartPos.X() + GetPaperSize().Width() - aBulletArea.Right();
    1043             :                     }
    1044             :                     else
    1045             :                     {
    1046           0 :                         aBulletPos.X() = rStartPos.X() - aBulletArea.Bottom();
    1047           0 :                         aBulletPos.Y() = rStartPos.Y() + aBulletArea.Left();
    1048             :                     }
    1049             : 
    1050           0 :                     if(bStrippingPortions)
    1051             :                     {
    1052           0 :                         if(aDrawBulletHdl.IsSet())
    1053             :                         {
    1054             :                             // call something analog to aDrawPortionHdl (if set) and feed it something
    1055             :                             // analog to DrawPortionInfo...
    1056             :                             // created aDrawBulletHdl, Set/GetDrawBulletHdl.
    1057             :                             // created DrawBulletInfo and added handling to sdrtextdecomposition.cxx
    1058             :                             DrawBulletInfo aDrawBulletInfo(
    1059           0 :                                 *pFmt->GetBrush()->GetGraphicObject(),
    1060             :                                 aBulletPos,
    1061           0 :                                 pPara->aBulSize);
    1062             : 
    1063           0 :                             aDrawBulletHdl.Call(&aDrawBulletInfo);
    1064             :                         }
    1065             :                     }
    1066             :                     else
    1067             :                     {
    1068             :                         // Remove CAST when KA made the Draw-Method const
    1069           0 :                         ((GraphicObject*)pFmt->GetBrush()->GetGraphicObject())->Draw( pOutDev, aBulletPos, pPara->aBulSize );
    1070             :                     }
    1071             :                 }
    1072             :             }
    1073             :         }
    1074             : 
    1075             :         // In case of collapsed subparagraphs paint a line before the text.
    1076        1216 :         if( pParaList->HasChildren(pPara) && !pParaList->HasVisibleChildren(pPara) &&
    1077         431 :                 !bStrippingPortions && !nOrientation )
    1078             :         {
    1079           0 :             long nWidth = pOutDev->PixelToLogic( Size( 10, 0 ) ).Width();
    1080             : 
    1081           0 :             Point aStartPos, aEndPos;
    1082           0 :             if ( !bVertical )
    1083             :             {
    1084           0 :                 aStartPos.Y() = rStartPos.Y() + aBulletArea.Bottom();
    1085           0 :                 if ( !bRightToLeftPara )
    1086           0 :                     aStartPos.X() = rStartPos.X() + aBulletArea.Right();
    1087             :                 else
    1088           0 :                     aStartPos.X() = rStartPos.X() + GetPaperSize().Width() - aBulletArea.Left();
    1089           0 :                 aEndPos = aStartPos;
    1090           0 :                 aEndPos.X() += nWidth;
    1091             :             }
    1092             :             else
    1093             :             {
    1094           0 :                 aStartPos.X() = rStartPos.X() - aBulletArea.Bottom();
    1095           0 :                 aStartPos.Y() = rStartPos.Y() + aBulletArea.Right();
    1096           0 :                 aEndPos = aStartPos;
    1097           0 :                 aEndPos.Y() += nWidth;
    1098             :             }
    1099             : 
    1100           0 :             const Color& rOldLineColor = pOutDev->GetLineColor();
    1101           0 :             pOutDev->SetLineColor( Color( COL_BLACK ) );
    1102           0 :             pOutDev->DrawLine( aStartPos, aEndPos );
    1103           0 :             pOutDev->SetLineColor( rOldLineColor );
    1104             :         }
    1105             :     }
    1106       11033 : }
    1107             : 
    1108           0 : void Outliner::InvalidateBullet( Paragraph* /*pPara*/, sal_Int32 nPara )
    1109             : {
    1110             : 
    1111           0 :     long nLineHeight = (long)pEditEngine->GetLineHeight(nPara );
    1112           0 :     for ( size_t i = 0, n = aViewList.size(); i < n; ++i )
    1113             :     {
    1114           0 :         OutlinerView* pView = aViewList[ i ];
    1115           0 :         Point aPos( pView->pEditView->GetWindowPosTopLeft(nPara ) );
    1116           0 :         Rectangle aRect( pView->GetOutputArea() );
    1117           0 :         aRect.Right() = aPos.X();
    1118           0 :         aRect.Top() = aPos.Y();
    1119           0 :         aRect.Bottom() = aPos.Y();
    1120           0 :         aRect.Bottom() += nLineHeight;
    1121             : 
    1122           0 :         pView->GetWindow()->Invalidate( aRect );
    1123             :     }
    1124           0 : }
    1125             : 
    1126           0 : sal_uLong Outliner::Read( SvStream& rInput, const OUString& rBaseURL, sal_uInt16 eFormat, SvKeyValueIterator* pHTTPHeaderAttrs )
    1127             : {
    1128             : 
    1129           0 :     bool bOldUndo = pEditEngine->IsUndoEnabled();
    1130           0 :     EnableUndo( false );
    1131             : 
    1132           0 :     bool bUpdate = pEditEngine->GetUpdateMode();
    1133           0 :     pEditEngine->SetUpdateMode( false );
    1134             : 
    1135           0 :     Clear();
    1136             : 
    1137           0 :     ImplBlockInsertionCallbacks( true );
    1138           0 :     sal_uLong nRet = pEditEngine->Read( rInput, rBaseURL, (EETextFormat)eFormat, pHTTPHeaderAttrs );
    1139             : 
    1140           0 :     bFirstParaIsEmpty = false;
    1141             : 
    1142           0 :     sal_Int32 nParas = pEditEngine->GetParagraphCount();
    1143           0 :      pParaList->Clear( true );
    1144           0 :     for ( sal_Int32 n = 0; n < nParas; n++ )
    1145             :     {
    1146           0 :         Paragraph* pPara = new Paragraph( 0 );
    1147           0 :         pParaList->Append(pPara);
    1148             : 
    1149           0 :         if ( eFormat == EE_FORMAT_BIN )
    1150             :         {
    1151           0 :             const SfxItemSet& rAttrs = pEditEngine->GetParaAttribs( n );
    1152           0 :             const SfxInt16Item& rLevel = (const SfxInt16Item&) rAttrs.Get( EE_PARA_OUTLLEVEL );
    1153           0 :             sal_Int16 nDepth = rLevel.GetValue();
    1154           0 :             ImplInitDepth( n, nDepth, false );
    1155             :         }
    1156             :     }
    1157             : 
    1158           0 :     if ( eFormat != EE_FORMAT_BIN )
    1159             :     {
    1160           0 :         ImpFilterIndents( 0, nParas-1 );
    1161             :     }
    1162             : 
    1163           0 :     ImplBlockInsertionCallbacks( false );
    1164           0 :     pEditEngine->SetUpdateMode( bUpdate );
    1165           0 :     EnableUndo( bOldUndo );
    1166             : 
    1167           0 :     return nRet;
    1168             : }
    1169             : 
    1170             : 
    1171           0 : void Outliner::ImpFilterIndents( sal_Int32 nFirstPara, sal_Int32 nLastPara )
    1172             : {
    1173             : 
    1174           0 :     bool bUpdate = pEditEngine->GetUpdateMode();
    1175           0 :     pEditEngine->SetUpdateMode( false );
    1176             : 
    1177           0 :     Paragraph* pLastConverted = NULL;
    1178           0 :     for( sal_Int32 nPara = nFirstPara; nPara <= nLastPara; nPara++ )
    1179             :     {
    1180           0 :         Paragraph* pPara = pParaList->GetParagraph( nPara );
    1181           0 :                 if (pPara)
    1182             :                 {
    1183           0 :                     if( ImpConvertEdtToOut( nPara ) )
    1184             :                     {
    1185           0 :                             pLastConverted = pPara;
    1186             :                     }
    1187           0 :                     else if ( pLastConverted )
    1188             :                     {
    1189             :                             // Arrange normal paragraphs below the heading ...
    1190           0 :                             pPara->SetDepth( pLastConverted->GetDepth() );
    1191             :                     }
    1192             : 
    1193           0 :                     ImplInitDepth( nPara, pPara->GetDepth(), false );
    1194             :         }
    1195             :     }
    1196             : 
    1197           0 :     pEditEngine->SetUpdateMode( bUpdate );
    1198           0 : }
    1199             : 
    1200      516346 : ::svl::IUndoManager& Outliner::GetUndoManager()
    1201             : {
    1202      516346 :     return pEditEngine->GetUndoManager();
    1203             : }
    1204             : 
    1205           0 : ::svl::IUndoManager* Outliner::SetUndoManager(::svl::IUndoManager* pNew)
    1206             : {
    1207           0 :     return pEditEngine->SetUndoManager(pNew);
    1208             : }
    1209             : 
    1210           0 : void Outliner::ImpTextPasted( sal_Int32 nStartPara, sal_Int32 nCount )
    1211             : {
    1212             : 
    1213           0 :     bool bUpdate = pEditEngine->GetUpdateMode();
    1214           0 :     pEditEngine->SetUpdateMode( false );
    1215             : 
    1216           0 :     const sal_Int32 nStart = nStartPara;
    1217             : 
    1218           0 :     Paragraph* pPara = pParaList->GetParagraph( nStartPara );
    1219             : 
    1220           0 :     while( nCount && pPara )
    1221             :     {
    1222           0 :         if( ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT )
    1223             :         {
    1224           0 :             nDepthChangedHdlPrevDepth = pPara->GetDepth();
    1225           0 :             mnDepthChangeHdlPrevFlags = pPara->nFlags;
    1226             : 
    1227           0 :             ImpConvertEdtToOut( nStartPara );
    1228             : 
    1229           0 :             pHdlParagraph = pPara;
    1230             : 
    1231           0 :             if( nStartPara == nStart )
    1232             :             {
    1233             :                 // the existing paragraph has changed depth or flags
    1234           0 :                 if( (pPara->GetDepth() != nDepthChangedHdlPrevDepth) || (pPara->nFlags != mnDepthChangeHdlPrevFlags) )
    1235           0 :                     DepthChangedHdl();
    1236             :             }
    1237             :         }
    1238             :         else // EditEngine mode
    1239             :         {
    1240           0 :             sal_Int16 nDepth = -1;
    1241           0 :             const SfxItemSet& rAttrs = pEditEngine->GetParaAttribs( nStartPara );
    1242           0 :             if ( rAttrs.GetItemState( EE_PARA_OUTLLEVEL ) == SFX_ITEM_ON )
    1243             :             {
    1244           0 :                 const SfxInt16Item& rLevel = (const SfxInt16Item&) rAttrs.Get( EE_PARA_OUTLLEVEL );
    1245           0 :                 nDepth = rLevel.GetValue();
    1246             :             }
    1247           0 :             if ( nDepth != GetDepth( nStartPara ) )
    1248           0 :                 ImplInitDepth( nStartPara, nDepth, false );
    1249             :         }
    1250             : 
    1251           0 :         nCount--;
    1252           0 :         nStartPara++;
    1253           0 :         pPara = pParaList->GetParagraph( nStartPara );
    1254             :     }
    1255             : 
    1256           0 :     pEditEngine->SetUpdateMode( bUpdate );
    1257             : 
    1258             :     DBG_ASSERT(pParaList->GetParagraphCount()==pEditEngine->GetParagraphCount(),"ImpTextPasted failed");
    1259           0 : }
    1260             : 
    1261           0 : long Outliner::IndentingPagesHdl( OutlinerView* pView )
    1262             : {
    1263           0 :     if( !aIndentingPagesHdl.IsSet() )
    1264           0 :         return 1;
    1265           0 :     return aIndentingPagesHdl.Call( pView );
    1266             : }
    1267             : 
    1268           0 : bool Outliner::ImpCanIndentSelectedPages( OutlinerView* pCurView )
    1269             : {
    1270             :     // The selected pages must already be set in advance through
    1271             :     // ImpCalcSelectedPages
    1272             : 
    1273             :     // If the first paragraph is on level 0 it can not indented in any case,
    1274             :     // possible there might be indentations in the following on the 0 level.
    1275           0 :     if ( ( mnFirstSelPage == 0 ) && ( ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) )
    1276             :     {
    1277           0 :         if ( nDepthChangedHdlPrevDepth == 1 )   // is the only page
    1278           0 :             return false;
    1279             :         else
    1280           0 :             pCurView->ImpCalcSelectedPages( false );  // without the first
    1281             :     }
    1282           0 :     return IndentingPagesHdl( pCurView );
    1283             : }
    1284             : 
    1285             : 
    1286           0 : bool Outliner::ImpCanDeleteSelectedPages( OutlinerView* pCurView )
    1287             : {
    1288             :     // The selected pages must already be set in advance through
    1289             :     // ImpCalcSelectedPages
    1290           0 :     return RemovingPagesHdl( pCurView );
    1291             : }
    1292             : 
    1293       18940 : Outliner::Outliner( SfxItemPool* pPool, sal_uInt16 nMode )
    1294       18940 : : nMinDepth( -1 )
    1295             : {
    1296             : 
    1297       18940 :     bStrippingPortions  = false;
    1298       18940 :     bPasting            = false;
    1299             : 
    1300       18940 :     nFirstPage          = 1;
    1301       18940 :     nBlockInsCallback   = 0;
    1302             : 
    1303       18940 :     nMaxDepth           = 9;
    1304             : 
    1305       18940 :     pParaList = new ParagraphList;
    1306       18940 :     pParaList->SetVisibleStateChangedHdl( LINK( this, Outliner, ParaVisibleStateChangedHdl ) );
    1307       18940 :     Paragraph* pPara = new Paragraph( 0 );
    1308       18940 :     pParaList->Append(pPara);
    1309       18940 :     bFirstParaIsEmpty = true;
    1310             : 
    1311       18940 :     pEditEngine = new OutlinerEditEng( this, pPool );
    1312       18940 :     pEditEngine->SetBeginMovingParagraphsHdl( LINK( this, Outliner, BeginMovingParagraphsHdl ) );
    1313       18940 :     pEditEngine->SetEndMovingParagraphsHdl( LINK( this, Outliner, EndMovingParagraphsHdl ) );
    1314       18940 :     pEditEngine->SetBeginPasteOrDropHdl( LINK( this, Outliner, BeginPasteOrDropHdl ) );
    1315       18940 :     pEditEngine->SetEndPasteOrDropHdl( LINK( this, Outliner, EndPasteOrDropHdl ) );
    1316             : 
    1317       18940 :     Init( nMode );
    1318       18940 : }
    1319             : 
    1320       34613 : Outliner::~Outliner()
    1321             : {
    1322             : 
    1323       17253 :     pParaList->Clear( true );
    1324       17253 :     delete pParaList;
    1325       17253 :     delete pEditEngine;
    1326       17360 : }
    1327             : 
    1328          48 : size_t Outliner::InsertView( OutlinerView* pView, size_t nIndex )
    1329             : {
    1330             :     size_t ActualIndex;
    1331             : 
    1332          48 :     if ( nIndex >= aViewList.size() )
    1333             :     {
    1334          48 :         aViewList.push_back( pView );
    1335          48 :         ActualIndex = aViewList.size() - 1;
    1336             :     }
    1337             :     else
    1338             :     {
    1339           0 :         ViewList::iterator it = aViewList.begin();
    1340           0 :         advance( it, nIndex );
    1341           0 :         ActualIndex = nIndex;
    1342             :     }
    1343          48 :     pEditEngine->InsertView(  pView->pEditView, nIndex );
    1344          48 :     return ActualIndex;
    1345             : }
    1346             : 
    1347           0 : OutlinerView* Outliner::RemoveView( OutlinerView* pView )
    1348             : {
    1349             : 
    1350           0 :     for ( ViewList::iterator it = aViewList.begin(); it != aViewList.end(); ++it )
    1351             :     {
    1352           0 :         if ( *it == pView )
    1353             :         {
    1354           0 :             pView->pEditView->HideCursor(); // HACK
    1355           0 :             pEditEngine->RemoveView(  pView->pEditView );
    1356           0 :             aViewList.erase( it );
    1357           0 :             break;
    1358             :         }
    1359             :     }
    1360           0 :     return NULL;    // return superfluous
    1361             : }
    1362             : 
    1363           0 : OutlinerView* Outliner::RemoveView( size_t nIndex )
    1364             : {
    1365             : 
    1366           0 :     EditView* pEditView = pEditEngine->GetView( nIndex );
    1367           0 :     pEditView->HideCursor(); // HACK
    1368             : 
    1369           0 :     pEditEngine->RemoveView( nIndex );
    1370             : 
    1371             :     {
    1372           0 :         ViewList::iterator it = aViewList.begin();
    1373           0 :         advance( it, nIndex );
    1374           0 :         aViewList.erase( it );
    1375             :     }
    1376             : 
    1377           0 :     return NULL;    // return superfluous
    1378             : }
    1379             : 
    1380             : 
    1381           0 : OutlinerView* Outliner::GetView( size_t nIndex ) const
    1382             : {
    1383           0 :     return ( nIndex >= aViewList.size() ) ? NULL : aViewList[ nIndex ];
    1384             : }
    1385             : 
    1386           0 : size_t Outliner::GetViewCount() const
    1387             : {
    1388           0 :     return aViewList.size();
    1389             : }
    1390             : 
    1391        1734 : void Outliner::ParagraphInsertedHdl()
    1392             : {
    1393        1734 :     if( !IsInUndo() )
    1394        1734 :         aParaInsertedHdl.Call( this );
    1395        1734 : }
    1396             : 
    1397             : 
    1398         513 : void Outliner::ParagraphRemovingHdl()
    1399             : {
    1400         513 :     if( !IsInUndo() )
    1401         513 :         aParaRemovingHdl.Call( this );
    1402         513 : }
    1403             : 
    1404             : 
    1405        1695 : void Outliner::DepthChangedHdl()
    1406             : {
    1407        1695 :     if( !IsInUndo() )
    1408        1695 :         aDepthChangedHdl.Call( this );
    1409        1695 : }
    1410             : 
    1411             : 
    1412        1065 : sal_Int32 Outliner::GetAbsPos( Paragraph* pPara )
    1413             : {
    1414             :     DBG_ASSERT(pPara,"GetAbsPos:No Para");
    1415        1065 :     return pParaList->GetAbsPos( pPara );
    1416             : }
    1417             : 
    1418      240295 : sal_Int32 Outliner::GetParagraphCount() const
    1419             : {
    1420      240295 :     return pParaList->GetParagraphCount();
    1421             : }
    1422             : 
    1423      105134 : Paragraph* Outliner::GetParagraph( sal_Int32 nAbsPos ) const
    1424             : {
    1425      105134 :     return pParaList->GetParagraph( nAbsPos );
    1426             : }
    1427             : 
    1428           0 : bool Outliner::HasChildren( Paragraph* pParagraph ) const
    1429             : {
    1430           0 :     return pParaList->HasChildren( pParagraph );
    1431             : }
    1432             : 
    1433      343149 : bool Outliner::ImplHasNumberFormat( sal_Int32 nPara ) const
    1434             : {
    1435      343149 :     return GetNumberFormat(nPara) != 0;
    1436             : #if 0 // The below code is obviously unreachable
    1437             :     if ( GetNumberFormat(nPara) )
    1438             :     {
    1439             :         const SfxBoolItem& rBulletState = (const SfxBoolItem&) pEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE );
    1440             :         return rBulletState.GetValue();
    1441             :     }
    1442             :     else
    1443             :         return false;
    1444             : #endif
    1445             : }
    1446             : 
    1447     2074332 : const SvxNumberFormat* Outliner::GetNumberFormat( sal_Int32 nPara ) const
    1448             : {
    1449     2074332 :     const SvxNumberFormat* pFmt = NULL;
    1450             : 
    1451     2074332 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
    1452     2074332 :     if (!pPara)
    1453           0 :         return NULL;
    1454             : 
    1455     2074332 :     sal_Int16 nDepth = pPara->GetDepth();
    1456             : 
    1457     2074332 :     if( nDepth >= 0 )
    1458             :     {
    1459       36306 :         const SvxNumBulletItem& rNumBullet = (const SvxNumBulletItem&) pEditEngine->GetParaAttrib( nPara, EE_PARA_NUMBULLET );
    1460       36306 :         if ( rNumBullet.GetNumRule()->GetLevelCount() > nDepth )
    1461       36306 :             pFmt = rNumBullet.GetNumRule()->Get( nDepth );
    1462             :     }
    1463             : 
    1464     2074332 :     return pFmt;
    1465             : }
    1466             : 
    1467        4186 : Size Outliner::ImplGetBulletSize( sal_Int32 nPara )
    1468             : {
    1469        4186 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
    1470        4186 :         if (!pPara)
    1471           0 :             return Size();
    1472             : 
    1473        4186 :     if( pPara->aBulSize.Width() == -1 )
    1474             :     {
    1475        3965 :         const SvxNumberFormat* pFmt = GetNumberFormat( nPara );
    1476             :         DBG_ASSERT( pFmt, "ImplGetBulletSize - no Bullet!" );
    1477             : 
    1478        3965 :         if ( pFmt->GetNumberingType() == SVX_NUM_NUMBER_NONE )
    1479             :         {
    1480        2998 :             pPara->aBulSize = Size( 0, 0 );
    1481             :         }
    1482         967 :         else if( pFmt->GetNumberingType() != SVX_NUM_BITMAP )
    1483             :         {
    1484         967 :             OUString aBulletText = ImplGetBulletText( nPara );
    1485         967 :             OutputDevice* pRefDev = pEditEngine->GetRefDevice();
    1486        1934 :             Font aBulletFont( ImpCalcBulletFont( nPara ) );
    1487        1934 :             Font aRefFont( pRefDev->GetFont());
    1488         967 :             pRefDev->SetFont( aBulletFont );
    1489         967 :             pPara->aBulSize.Width() = pRefDev->GetTextWidth( aBulletText );
    1490         967 :             pPara->aBulSize.Height() = pRefDev->GetTextHeight();
    1491        1934 :             pRefDev->SetFont( aRefFont );
    1492             :         }
    1493             :         else
    1494             :         {
    1495           0 :             pPara->aBulSize = OutputDevice::LogicToLogic( pFmt->GetGraphicSize(), MAP_100TH_MM, pEditEngine->GetRefDevice()->GetMapMode() );
    1496             :         }
    1497             :     }
    1498             : 
    1499        4186 :     return pPara->aBulSize;
    1500             : }
    1501             : 
    1502      744652 : void Outliner::ImplCheckParagraphs( sal_Int32 nStart, sal_Int32 nEnd )
    1503             : {
    1504             : 
    1505     1499637 :     for ( sal_Int32 n = nStart; n < nEnd; n++ )
    1506             :     {
    1507      754985 :         Paragraph* pPara = pParaList->GetParagraph( n );
    1508      754985 :         if (pPara)
    1509             :         {
    1510      754985 :             pPara->Invalidate();
    1511      754985 :             ImplCalcBulletText( n, false, false );
    1512             :         }
    1513             :     }
    1514      744652 : }
    1515             : 
    1516       22047 : void Outliner::SetRefDevice( OutputDevice* pRefDev )
    1517             : {
    1518       22047 :     pEditEngine->SetRefDevice( pRefDev );
    1519       66141 :     for ( sal_Int32 n = pParaList->GetParagraphCount(); n; )
    1520             :     {
    1521       22047 :         Paragraph* pPara = pParaList->GetParagraph( --n );
    1522       22047 :         pPara->Invalidate();
    1523             :     }
    1524       22047 : }
    1525             : 
    1526      404231 : void Outliner::ParaAttribsChanged( sal_Int32 nPara )
    1527             : {
    1528             : 
    1529             :     // The Outliner does not have an undo of its own, when paragraphs are
    1530             :     // separated/merged. When ParagraphInserted the attribute EE_PARA_OUTLLEVEL
    1531             :     // may not be set, this is however needed when the depth of the paragraph
    1532             :     // is to be determined.
    1533      404231 :     if( pEditEngine->IsInUndo() )
    1534             :     {
    1535           0 :         if ( pParaList->GetParagraphCount() == pEditEngine->GetParagraphCount() )
    1536             :         {
    1537           0 :             Paragraph* pPara = pParaList->GetParagraph( nPara );
    1538           0 :             const SfxInt16Item& rLevel = (const SfxInt16Item&) pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL );
    1539           0 :             if ( pPara && pPara->GetDepth() != rLevel.GetValue() )
    1540             :             {
    1541           0 :                 pPara->SetDepth( rLevel.GetValue() );
    1542           0 :                 ImplCalcBulletText( nPara, true, true );
    1543             :             }
    1544             :         }
    1545             :     }
    1546      404231 : }
    1547             : 
    1548           0 : void Outliner::StyleSheetChanged( SfxStyleSheet* pStyle )
    1549             : {
    1550             : 
    1551             :     // The EditEngine calls StyleSheetChanged also for derived styles.
    1552             :     // Here all the paragraphs, which had the said template, used to be
    1553             :     // hunted by a ImpRecalcParaAttribs, why?
    1554             :     // => only the Bullet-representation can really change...
    1555           0 :     sal_Int32 nParas = pParaList->GetParagraphCount();
    1556           0 :     for( sal_Int32 nPara = 0; nPara < nParas; nPara++ )
    1557             :     {
    1558           0 :         if ( pEditEngine->GetStyleSheet( nPara ) == pStyle )
    1559             :         {
    1560           0 :             ImplCheckNumBulletItem( nPara );
    1561           0 :             ImplCalcBulletText( nPara, false, false );
    1562             :             // EditEngine formats changed paragraphs before calling this method,
    1563             :             // so they are not reformatted now and use wrong bullet indent
    1564           0 :             pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
    1565             :         }
    1566             :     }
    1567           0 : }
    1568             : 
    1569        4186 : Rectangle Outliner::ImpCalcBulletArea( sal_Int32 nPara, bool bAdjust, bool bReturnPaperPos )
    1570             : {
    1571             :     // Bullet area within the paragraph ...
    1572        4186 :     Rectangle aBulletArea;
    1573             : 
    1574        4186 :     const SvxNumberFormat* pFmt = GetNumberFormat( nPara );
    1575        4186 :     if ( pFmt )
    1576             :     {
    1577        4186 :         Point aTopLeft;
    1578        4186 :         Size aBulletSize( ImplGetBulletSize( nPara ) );
    1579             : 
    1580        4186 :         bool bOutlineMode = ( pEditEngine->GetControlWord() & EE_CNTRL_OUTLINER ) != 0;
    1581             : 
    1582             :         // the ODF attribut text:space-before which holds the spacing to add to the left of the label
    1583        4186 :         const short nSpaceBefore = pFmt->GetAbsLSpace() + pFmt->GetFirstLineOffset();
    1584             : 
    1585        4186 :         const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&) pEditEngine->GetParaAttrib( nPara, bOutlineMode ? EE_PARA_OUTLLRSPACE : EE_PARA_LRSPACE );
    1586        4186 :         aTopLeft.X() = rLR.GetTxtLeft() + rLR.GetTxtFirstLineOfst() + nSpaceBefore;
    1587             : 
    1588        4186 :         long nBulletWidth = std::max( (long) -rLR.GetTxtFirstLineOfst(), (long) ((-pFmt->GetFirstLineOffset()) + pFmt->GetCharTextDistance()) );
    1589        4186 :         if ( nBulletWidth < aBulletSize.Width() )   // The Bullet creates its space
    1590          33 :             nBulletWidth = aBulletSize.Width();
    1591             : 
    1592        4186 :         if ( bAdjust && !bOutlineMode )
    1593             :         {
    1594             :             // Adjust when centered or align right
    1595         431 :             const SvxAdjustItem& rItem = (const SvxAdjustItem&)pEditEngine->GetParaAttrib( nPara, EE_PARA_JUST );
    1596         862 :             if ( ( !pEditEngine->IsRightToLeft( nPara ) && ( rItem.GetAdjust() != SVX_ADJUST_LEFT ) ) ||
    1597         431 :                  ( pEditEngine->IsRightToLeft( nPara ) && ( rItem.GetAdjust() != SVX_ADJUST_RIGHT ) ) )
    1598             :             {
    1599           0 :                 aTopLeft.X() = pEditEngine->GetFirstLineStartX( nPara ) - nBulletWidth;
    1600             :             }
    1601             :         }
    1602             : 
    1603             :         // Vertical:
    1604        4186 :         ParagraphInfos aInfos = pEditEngine->GetParagraphInfos( nPara );
    1605        4186 :         if ( aInfos.bValid )
    1606             :         {
    1607         431 :             aTopLeft.Y() = /* aInfos.nFirstLineOffset + */ // nFirstLineOffset is already added to the StartPos (PaintBullet) from the EditEngine
    1608         431 :                             aInfos.nFirstLineHeight - aInfos.nFirstLineTextHeight
    1609         431 :                             + aInfos.nFirstLineTextHeight / 2
    1610         431 :                             - aBulletSize.Height() / 2;
    1611             :             // may prefer to print out on the baseline ...
    1612         431 :             if( ( pFmt->GetNumberingType() != SVX_NUM_NUMBER_NONE ) && ( pFmt->GetNumberingType() != SVX_NUM_BITMAP ) && ( pFmt->GetNumberingType() != SVX_NUM_CHAR_SPECIAL ) )
    1613             :             {
    1614           0 :                 Font aBulletFont( ImpCalcBulletFont( nPara ) );
    1615           0 :                 if ( aBulletFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL )
    1616             :                 {
    1617           0 :                     OutputDevice* pRefDev = pEditEngine->GetRefDevice();
    1618           0 :                     Font aOldFont = pRefDev->GetFont();
    1619           0 :                     pRefDev->SetFont( aBulletFont );
    1620           0 :                     FontMetric aMetric( pRefDev->GetFontMetric() );
    1621             :                     // Leading on the first line ...
    1622           0 :                     aTopLeft.Y() = /* aInfos.nFirstLineOffset + */ aInfos.nFirstLineMaxAscent;
    1623           0 :                     aTopLeft.Y() -= aMetric.GetAscent();
    1624           0 :                     pRefDev->SetFont( aOldFont );
    1625           0 :                 }
    1626             :             }
    1627             :         }
    1628             : 
    1629             :         // Horizontal:
    1630        4186 :         if( pFmt->GetNumAdjust() == SVX_ADJUST_RIGHT )
    1631             :         {
    1632           0 :             aTopLeft.X() += nBulletWidth - aBulletSize.Width();
    1633             :         }
    1634        4186 :         else if( pFmt->GetNumAdjust() == SVX_ADJUST_CENTER )
    1635             :         {
    1636           0 :             aTopLeft.X() += ( nBulletWidth - aBulletSize.Width() ) / 2;
    1637             :         }
    1638             : 
    1639        4186 :         if ( aTopLeft.X() < 0 )     // then push
    1640           0 :             aTopLeft.X() = 0;
    1641             : 
    1642        4186 :         aBulletArea = Rectangle( aTopLeft, aBulletSize );
    1643             :     }
    1644        4186 :     if ( bReturnPaperPos )
    1645             :     {
    1646           0 :         Size aBulletSize( aBulletArea.GetSize() );
    1647           0 :         Point aBulletDocPos( aBulletArea.TopLeft() );
    1648           0 :         aBulletDocPos.Y() += pEditEngine->GetDocPosTopLeft( nPara ).Y();
    1649           0 :         Point aBulletPos( aBulletDocPos );
    1650             : 
    1651           0 :         if ( IsVertical() )
    1652             :         {
    1653           0 :             aBulletPos.Y() = aBulletDocPos.X();
    1654           0 :             aBulletPos.X() = GetPaperSize().Width() - aBulletDocPos.Y();
    1655             :             // Rotate:
    1656           0 :             aBulletPos.X() -= aBulletSize.Height();
    1657           0 :             Size aSz( aBulletSize );
    1658           0 :             aBulletSize.Width() = aSz.Height();
    1659           0 :             aBulletSize.Height() = aSz.Width();
    1660             :         }
    1661           0 :         else if ( pEditEngine->IsRightToLeft( nPara ) )
    1662             :         {
    1663           0 :             aBulletPos.X() = GetPaperSize().Width() - aBulletDocPos.X() - aBulletSize.Width();
    1664             :         }
    1665             : 
    1666           0 :         aBulletArea = Rectangle( aBulletPos, aBulletSize );
    1667             :     }
    1668        4186 :     return aBulletArea;
    1669             : }
    1670             : 
    1671           0 : void Outliner::ExpandHdl()
    1672             : {
    1673           0 :     aExpandHdl.Call( this );
    1674           0 : }
    1675             : 
    1676           0 : EBulletInfo Outliner::GetBulletInfo( sal_Int32 nPara )
    1677             : {
    1678           0 :     EBulletInfo aInfo;
    1679             : 
    1680           0 :     aInfo.nParagraph = nPara;
    1681           0 :     aInfo.bVisible = ImplHasNumberFormat( nPara );
    1682             : 
    1683           0 :     const SvxNumberFormat* pFmt = GetNumberFormat( nPara );
    1684           0 :     aInfo.nType = pFmt ? pFmt->GetNumberingType() : 0;
    1685             : 
    1686           0 :     if( pFmt )
    1687             :     {
    1688           0 :         if( pFmt->GetNumberingType() != SVX_NUM_BITMAP )
    1689             :         {
    1690           0 :             aInfo.aText = ImplGetBulletText( nPara );
    1691             : 
    1692           0 :             if( pFmt->GetBulletFont() )
    1693           0 :                 aInfo.aFont = *pFmt->GetBulletFont();
    1694             :         }
    1695           0 :         else if ( pFmt->GetBrush()->GetGraphicObject() )
    1696             :         {
    1697           0 :             aInfo.aGraphic = pFmt->GetBrush()->GetGraphicObject()->GetGraphic();
    1698             :         }
    1699             :     }
    1700             : 
    1701           0 :     if ( aInfo.bVisible )
    1702             :     {
    1703           0 :         aInfo.aBounds = ImpCalcBulletArea( nPara, true, true );
    1704             :     }
    1705             : 
    1706           0 :     return aInfo;
    1707             : }
    1708             : 
    1709       16327 : OUString Outliner::GetText( Paragraph* pParagraph, sal_Int32 nCount ) const
    1710             : {
    1711             : 
    1712       16327 :     OUString aText;
    1713       16327 :     sal_Int32 nStartPara = pParaList->GetAbsPos( pParagraph );
    1714       32654 :     for ( sal_Int32 n = 0; n < nCount; n++ )
    1715             :     {
    1716       16327 :         aText += pEditEngine->GetText( nStartPara + n );
    1717       16327 :         if ( (n+1) < nCount )
    1718           0 :             aText += "\n";
    1719             :     }
    1720       16327 :     return aText;
    1721             : }
    1722             : 
    1723           0 : void Outliner::Remove( Paragraph* pPara, sal_Int32 nParaCount )
    1724             : {
    1725             : 
    1726           0 :     sal_Int32 nPos = pParaList->GetAbsPos( pPara );
    1727           0 :     if( !nPos && ( nParaCount >= pParaList->GetParagraphCount() ) )
    1728             :     {
    1729           0 :         Clear();
    1730             :     }
    1731             :     else
    1732             :     {
    1733           0 :         for( sal_Int32 n = 0; n < nParaCount; n++ )
    1734           0 :             pEditEngine->RemoveParagraph( nPos );
    1735             :     }
    1736           0 : }
    1737             : 
    1738        9255 : void Outliner::StripPortions()
    1739             : {
    1740        9255 :     bStrippingPortions = true;
    1741        9255 :     pEditEngine->StripPortions();
    1742        9255 :     bStrippingPortions = false;
    1743        9255 : }
    1744             : 
    1745       13756 : void Outliner::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen, const sal_Int32* pDXArray,const SvxFont& rFont,
    1746             :     sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
    1747             :     const EEngineData::WrongSpellVector* pWrongSpellVector,
    1748             :     const SvxFieldData* pFieldData,
    1749             :     bool bEndOfLine,
    1750             :     bool bEndOfParagraph,
    1751             :     bool bEndOfBullet,
    1752             :     const ::com::sun::star::lang::Locale* pLocale,
    1753             :     const Color& rOverlineColor,
    1754             :     const Color& rTextLineColor)
    1755             : {
    1756             : 
    1757       13756 :     if(aDrawPortionHdl.IsSet())
    1758             :     {
    1759             :         DrawPortionInfo aInfo( rStartPos, rText, nTextStart, nTextLen, rFont, nPara, nIndex, pDXArray, pWrongSpellVector,
    1760       13756 :             pFieldData, pLocale, rOverlineColor, rTextLineColor, nRightToLeft, false, 0, bEndOfLine, bEndOfParagraph, bEndOfBullet);
    1761             : 
    1762       13756 :         aDrawPortionHdl.Call( &aInfo );
    1763             :     }
    1764       13756 : }
    1765             : 
    1766           0 : void Outliner::DrawingTab( const Point& rStartPos, long nWidth, const OUString& rChar, const SvxFont& rFont,
    1767             :     sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft, bool bEndOfLine, bool bEndOfParagraph,
    1768             :     const Color& rOverlineColor, const Color& rTextLineColor)
    1769             : {
    1770           0 :     if(aDrawPortionHdl.IsSet())
    1771             :     {
    1772             :         DrawPortionInfo aInfo( rStartPos, rChar, 0, rChar.getLength(), rFont, nPara, nIndex, NULL, NULL,
    1773           0 :             NULL, NULL, rOverlineColor, rTextLineColor, nRightToLeft, true, nWidth, bEndOfLine, bEndOfParagraph, false);
    1774             : 
    1775           0 :         aDrawPortionHdl.Call( &aInfo );
    1776             :     }
    1777           0 : }
    1778             : 
    1779           0 : long Outliner::RemovingPagesHdl( OutlinerView* pView )
    1780             : {
    1781           0 :     return aRemovingPagesHdl.IsSet() ? aRemovingPagesHdl.Call( pView ) : sal_True;
    1782             : }
    1783             : 
    1784           0 : bool Outliner::ImpCanDeleteSelectedPages( OutlinerView* pCurView, sal_Int32 _nFirstPage, sal_Int32 nPages )
    1785             : {
    1786             : 
    1787           0 :     nDepthChangedHdlPrevDepth = nPages;
    1788           0 :     mnFirstSelPage = _nFirstPage;
    1789           0 :     pHdlParagraph = 0;
    1790           0 :     return RemovingPagesHdl( pCurView );
    1791             : }
    1792             : 
    1793       91985 : SfxItemSet Outliner::GetParaAttribs( sal_Int32 nPara )
    1794             : {
    1795       91985 :     return pEditEngine->GetParaAttribs( nPara );
    1796             : }
    1797             : 
    1798           0 : IMPL_LINK( Outliner, ParaVisibleStateChangedHdl, Paragraph*, pPara )
    1799             : {
    1800             : 
    1801           0 :     sal_Int32 nPara = pParaList->GetAbsPos( pPara );
    1802           0 :     pEditEngine->ShowParagraph( nPara, pPara->IsVisible() );
    1803             : 
    1804           0 :     return 0;
    1805             : }
    1806             : 
    1807           0 : IMPL_LINK_NOARG(Outliner, BeginMovingParagraphsHdl)
    1808             : {
    1809             : 
    1810           0 :     if( !IsInUndo() )
    1811           0 :         GetBeginMovingHdl().Call( this );
    1812             : 
    1813           0 :     return 0;
    1814             : }
    1815             : 
    1816           0 : IMPL_LINK( Outliner, BeginPasteOrDropHdl, PasteOrDropInfos*, pInfos )
    1817             : {
    1818           0 :     UndoActionStart( EDITUNDO_DRAGANDDROP );
    1819           0 :     maBeginPasteOrDropHdl.Call(pInfos);
    1820           0 :     return 0;
    1821             : }
    1822             : 
    1823           0 : IMPL_LINK( Outliner, EndPasteOrDropHdl, PasteOrDropInfos*, pInfos )
    1824             : {
    1825           0 :     bPasting = false;
    1826           0 :     ImpTextPasted( pInfos->nStartPara, pInfos->nEndPara - pInfos->nStartPara + 1 );
    1827           0 :     maEndPasteOrDropHdl.Call( pInfos );
    1828           0 :     UndoActionEnd( EDITUNDO_DRAGANDDROP );
    1829           0 :     return 0;
    1830             : }
    1831             : 
    1832           0 : IMPL_LINK( Outliner, EndMovingParagraphsHdl, MoveParagraphsInfo*, pInfos )
    1833             : {
    1834             : 
    1835           0 :     pParaList->MoveParagraphs( pInfos->nStartPara, pInfos->nDestPara, pInfos->nEndPara - pInfos->nStartPara + 1 );
    1836           0 :     sal_Int32 nChangesStart = std::min( pInfos->nStartPara, pInfos->nDestPara );
    1837           0 :     sal_Int32 nParas = pParaList->GetParagraphCount();
    1838           0 :     for ( sal_Int32 n = nChangesStart; n < nParas; n++ )
    1839           0 :         ImplCalcBulletText( n, false, false );
    1840             : 
    1841           0 :     if( !IsInUndo() )
    1842           0 :         aEndMovingHdl.Call( this );
    1843             : 
    1844           0 :     return 0;
    1845             : }
    1846             : 
    1847         192 : static bool isSameNumbering( const SvxNumberFormat& rN1, const SvxNumberFormat& rN2 )
    1848             : {
    1849         192 :     if( rN1.GetNumberingType() != rN2.GetNumberingType() )
    1850           0 :         return false;
    1851             : 
    1852         192 :     if( rN1.GetNumStr(1) != rN2.GetNumStr(1) )
    1853           0 :         return false;
    1854             : 
    1855         192 :     if( (rN1.GetPrefix() != rN2.GetPrefix()) || (rN1.GetSuffix() != rN2.GetSuffix()) )
    1856           0 :         return false;
    1857             : 
    1858         192 :     return true;
    1859             : }
    1860             : 
    1861         192 : sal_uInt16 Outliner::ImplGetNumbering( sal_Int32 nPara, const SvxNumberFormat* pParaFmt )
    1862             : {
    1863         192 :     sal_uInt16 nNumber = pParaFmt->GetStart() - 1;
    1864             : 
    1865         192 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
    1866         192 :     const sal_Int16 nParaDepth = pPara->GetDepth();
    1867             : 
    1868         708 :     do
    1869             :     {
    1870         708 :         pPara = pParaList->GetParagraph( nPara );
    1871         708 :         const sal_Int16 nDepth = pPara->GetDepth();
    1872             : 
    1873             :         // ignore paragraphs that are below our paragraph or have no numbering
    1874         708 :         if( (nDepth > nParaDepth) || (nDepth == -1) )
    1875         516 :             continue;
    1876             : 
    1877             :         // stop on paragraphs that are above our paragraph
    1878         192 :         if( nDepth < nParaDepth )
    1879           0 :             break;
    1880             : 
    1881         192 :         const SvxNumberFormat* pFmt = GetNumberFormat( nPara );
    1882             : 
    1883         192 :         if( pFmt == 0 )
    1884           0 :             continue; // ignore paragraphs without bullets
    1885             : 
    1886             :         // check if numbering less than or equal to pParaFmt
    1887         192 :         if( !isSameNumbering( *pFmt, *pParaFmt ) || ( pFmt->GetStart() < pParaFmt->GetStart() ) )
    1888           0 :             break;
    1889             : 
    1890         192 :         if (  pFmt->GetStart() > pParaFmt->GetStart() )
    1891             :         {
    1892           0 :            nNumber += pFmt->GetStart() - pParaFmt->GetStart();
    1893           0 :            pParaFmt = pFmt;
    1894             :         }
    1895             : 
    1896         192 :         const SfxBoolItem& rBulletState = (const SfxBoolItem&) pEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE );
    1897             : 
    1898         192 :         if( rBulletState.GetValue() )
    1899         192 :             nNumber += 1;
    1900             : 
    1901             :         // same depth, same number format, check for restart
    1902         192 :         const sal_Int16 nNumberingStartValue = pPara->GetNumberingStartValue();
    1903         192 :         if( (nNumberingStartValue != -1) || pPara->IsParaIsNumberingRestart() )
    1904             :         {
    1905           0 :             if( nNumberingStartValue != -1 )
    1906           0 :                 nNumber += nNumberingStartValue - 1;
    1907           0 :             break;
    1908             :         }
    1909             :     }
    1910             :     while( nPara-- );
    1911             : 
    1912         192 :     return nNumber;
    1913             : }
    1914             : 
    1915     1293894 : void Outliner::ImplCalcBulletText( sal_Int32 nPara, bool bRecalcLevel, bool bRecalcChildren )
    1916             : {
    1917             : 
    1918     1293894 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
    1919             : 
    1920     3881695 :     while ( pPara )
    1921             :     {
    1922     1293907 :         OUString aBulletText;
    1923     1293907 :         const SvxNumberFormat* pFmt = GetNumberFormat( nPara );
    1924     1293907 :         if( pFmt && ( pFmt->GetNumberingType() != SVX_NUM_BITMAP ) )
    1925             :         {
    1926       16181 :             aBulletText += pFmt->GetPrefix();
    1927       16181 :             if( pFmt->GetNumberingType() == SVX_NUM_CHAR_SPECIAL )
    1928             :             {
    1929        7142 :                 aBulletText += OUString(pFmt->GetBulletChar());
    1930             :             }
    1931        9039 :             else if( pFmt->GetNumberingType() != SVX_NUM_NUMBER_NONE )
    1932             :             {
    1933         192 :                 aBulletText += pFmt->GetNumStr( ImplGetNumbering( nPara, pFmt ) );
    1934             :             }
    1935       16181 :             aBulletText += pFmt->GetSuffix();
    1936             :         }
    1937             : 
    1938     1293907 :         if (!pPara->GetText().equals(aBulletText))
    1939        3311 :             pPara->SetText( aBulletText );
    1940             : 
    1941     1293907 :         pPara->nFlags &= (~PARAFLAG_SETBULLETTEXT);
    1942             : 
    1943     1293907 :         if ( bRecalcLevel )
    1944             :         {
    1945         926 :             sal_Int16 nDepth = pPara->GetDepth();
    1946         926 :             pPara = pParaList->GetParagraph( ++nPara );
    1947         926 :             if ( !bRecalcChildren )
    1948             :             {
    1949        1852 :                 while ( pPara && ( pPara->GetDepth() > nDepth ) )
    1950           0 :                     pPara = pParaList->GetParagraph( ++nPara );
    1951             :             }
    1952             : 
    1953         926 :             if ( pPara && ( pPara->GetDepth() < nDepth ) )
    1954           0 :                 pPara = NULL;
    1955             :         }
    1956             :         else
    1957             :         {
    1958     1292981 :             pPara = NULL;
    1959             :         }
    1960     1293907 :     }
    1961     1293894 : }
    1962             : 
    1963      736313 : void Outliner::Clear()
    1964             : {
    1965             : 
    1966      736313 :     if( !bFirstParaIsEmpty )
    1967             :     {
    1968      163000 :         ImplBlockInsertionCallbacks( true );
    1969      163000 :         pEditEngine->Clear();
    1970      163000 :         pParaList->Clear( true );
    1971      163000 :         pParaList->Append( new Paragraph( nMinDepth ));
    1972      163000 :         bFirstParaIsEmpty = true;
    1973      163000 :         ImplBlockInsertionCallbacks( false );
    1974             :     }
    1975             :     else
    1976             :     {
    1977      573313 :             Paragraph* pPara = pParaList->GetParagraph( 0 );
    1978      573313 :             if(pPara)
    1979      573313 :                 pPara->SetDepth( nMinDepth );
    1980             :     }
    1981      736313 : }
    1982             : 
    1983           0 : void Outliner::SetFlatMode( bool bFlat )
    1984             : {
    1985             : 
    1986           0 :     if( bFlat != pEditEngine->IsFlatMode() )
    1987             :     {
    1988           0 :         for ( sal_Int32 nPara = pParaList->GetParagraphCount(); nPara; )
    1989           0 :             pParaList->GetParagraph( --nPara )->aBulSize.Width() = -1;
    1990             : 
    1991           0 :         pEditEngine->SetFlatMode( bFlat );
    1992             :     }
    1993           0 : }
    1994             : 
    1995         967 : OUString Outliner::ImplGetBulletText( sal_Int32 nPara )
    1996             : {
    1997         967 :     OUString aRes;
    1998         967 :     Paragraph* pPara = pParaList->GetParagraph( nPara );
    1999         967 :     if (pPara)
    2000             :     {
    2001             :     // Enable optimization again ...
    2002             : //  if( pPara->nFlags & PARAFLAG_SETBULLETTEXT )
    2003         967 :         ImplCalcBulletText( nPara, false, false );
    2004         967 :         aRes = pPara->GetText();
    2005             :     }
    2006         967 :     return aRes;
    2007             : }
    2008             : 
    2009             : // this is needed for StarOffice Api
    2010          59 : void Outliner::SetLevelDependendStyleSheet( sal_Int32 nPara )
    2011             : {
    2012          59 :     SfxItemSet aOldAttrs( pEditEngine->GetParaAttribs( nPara ) );
    2013          59 :     ImplSetLevelDependendStyleSheet( nPara );
    2014          59 :     pEditEngine->SetParaAttribs( nPara, aOldAttrs );
    2015          59 : }
    2016             : 
    2017      675058 : void Outliner::ImplBlockInsertionCallbacks( bool b )
    2018             : {
    2019      675058 :     if ( b )
    2020             :     {
    2021      337529 :         nBlockInsCallback++;
    2022             :     }
    2023             :     else
    2024             :     {
    2025             :         DBG_ASSERT( nBlockInsCallback, "ImplBlockInsertionCallbacks ?!" );
    2026      337529 :         nBlockInsCallback--;
    2027      337529 :         if ( !nBlockInsCallback )
    2028             :         {
    2029             :             // Call blocked notify events...
    2030      674620 :             while(!pEditEngine->aNotifyCache.empty())
    2031             :             {
    2032           0 :                 EENotify aNotify(pEditEngine->aNotifyCache.front());
    2033             :                 // Remove from list before calling, maybe we enter LeaveBlockNotifications while calling the handler...
    2034           0 :                 pEditEngine->aNotifyCache.erase(pEditEngine->aNotifyCache.begin());
    2035           0 :                 pEditEngine->aOutlinerNotifyHdl.Call( &aNotify );
    2036             :             }
    2037             :         }
    2038             :     }
    2039      675058 : }
    2040             : 
    2041           0 : IMPL_LINK( Outliner, EditEngineNotifyHdl, EENotify*, pNotify )
    2042             : {
    2043           0 :     if ( !nBlockInsCallback )
    2044           0 :         pEditEngine->aOutlinerNotifyHdl.Call( pNotify );
    2045             :     else
    2046           0 :         pEditEngine->aNotifyCache.push_back(*pNotify);
    2047             : 
    2048           0 :     return 0;
    2049             : }
    2050             : 
    2051             : /** sets a link that is called at the beginning of a drag operation at an edit view */
    2052           0 : void Outliner::SetBeginDropHdl( const Link& rLink )
    2053             : {
    2054           0 :     pEditEngine->SetBeginDropHdl( rLink );
    2055           0 : }
    2056             : 
    2057             : /** sets a link that is called at the end of a drag operation at an edit view */
    2058           0 : void Outliner::SetEndDropHdl( const Link& rLink )
    2059             : {
    2060           0 :     pEditEngine->SetEndDropHdl( rLink );
    2061           0 : }
    2062             : 
    2063             : /** sets a link that is called before a drop or paste operation. */
    2064           0 : void Outliner::SetBeginPasteOrDropHdl( const Link& rLink )
    2065             : {
    2066           0 :     maBeginPasteOrDropHdl = rLink;
    2067           0 : }
    2068             : 
    2069             : /** sets a link that is called after a drop or paste operation. */
    2070           0 : void Outliner::SetEndPasteOrDropHdl( const Link& rLink )
    2071             : {
    2072           0 :     maEndPasteOrDropHdl = rLink;
    2073           0 : }
    2074             : 
    2075           0 : void Outliner::SetParaFlag( Paragraph* pPara,  sal_uInt16 nFlag )
    2076             : {
    2077           0 :     if( pPara && !pPara->HasFlag( nFlag ) )
    2078             :     {
    2079           0 :         if( IsUndoEnabled() && !IsInUndo() )
    2080           0 :             InsertUndo( new OutlinerUndoChangeParaFlags( this, GetAbsPos( pPara ), pPara->nFlags, pPara->nFlags|nFlag ) );
    2081             : 
    2082           0 :         pPara->SetFlag( nFlag );
    2083             :     }
    2084           0 : }
    2085             : 
    2086         220 : bool Outliner::HasParaFlag( const Paragraph* pPara, sal_uInt16 nFlag ) const
    2087             : {
    2088         220 :     return pPara && pPara->HasFlag( nFlag );
    2089             : }
    2090             : 
    2091             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10