LCOV - code coverage report
Current view: top level - editeng/source/outliner - outliner.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 550 1057 52.0 %
Date: 2012-08-25 Functions: 52 97 53.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 438 1326 33.0 %

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

Generated by: LCOV version 1.10