2000-09-18 16:07:07 +00:00
/*************************************************************************
*
2008-04-11 01:18:32 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2000-09-18 16:07:07 +00:00
*
2008-04-11 01:18:32 +00:00
* Copyright 2008 by Sun Microsystems , Inc .
2000-09-18 16:07:07 +00:00
*
2008-04-11 01:18:32 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2000-09-18 16:07:07 +00:00
*
2008-04-11 01:18:32 +00:00
* $ RCSfile : outliner . cxx , v $
2009-01-05 17:49:45 +00:00
* $ Revision : 1.75 .20 .2 $
2000-09-18 16:07:07 +00:00
*
2008-04-11 01:18:32 +00:00
* This file is part of OpenOffice . org .
2000-09-18 16:07:07 +00:00
*
2008-04-11 01:18:32 +00:00
* OpenOffice . org is free software : you can redistribute it and / or modify
* it under the terms of the GNU Lesser General Public License version 3
* only , as published by the Free Software Foundation .
2000-09-18 16:07:07 +00:00
*
2008-04-11 01:18:32 +00:00
* OpenOffice . org is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Lesser General Public License version 3 for more details
* ( a copy is included in the LICENSE file that accompanied this code ) .
2000-09-18 16:07:07 +00:00
*
2008-04-11 01:18:32 +00:00
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice . org . If not , see
* < http : //www.openoffice.org/license.html>
* for a copy of the LGPLv3 License .
2000-09-18 16:07:07 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-09-17 04:31:00 +00:00
// MARKER(update_precomp.py): autogen include statement, do not remove
# include "precompiled_svx.hxx"
2000-09-18 16:07:07 +00:00
# include <outl_pch.hxx>
# include <math.h>
# include <svtools/style.hxx>
# include <vcl/wrkwin.hxx>
# define _OUTLINER_CXX
2007-06-27 17:41:40 +00:00
# include <svx/outliner.hxx>
2000-09-18 16:07:07 +00:00
# include <paralist.hxx>
2007-06-27 17:41:40 +00:00
# include <svx/outlobj.hxx>
2000-09-18 16:07:07 +00:00
# include <outleeng.hxx>
# include <outlundo.hxx>
2007-06-27 17:41:40 +00:00
# include <svx/eeitem.hxx>
2000-09-18 16:07:07 +00:00
# include <editstat.hxx>
2007-06-27 17:41:40 +00:00
# include <svx/scripttypeitem.hxx>
# include <svx/editobj.hxx>
2000-09-18 16:07:07 +00:00
# include <svtools/itemset.hxx>
# include <svtools/whiter.hxx>
# include <vcl/metric.hxx>
2007-06-27 17:41:40 +00:00
# include <svx/numitem.hxx>
# include <svx/adjitem.hxx>
2000-09-18 16:07:07 +00:00
# include <vcl/graph.hxx>
2004-11-26 17:13:51 +00:00
# include <vcl/gdimtf.hxx>
# include <vcl/metaact.hxx>
2000-10-19 10:11:17 +00:00
# include <goodies/grfmgr.hxx>
2007-06-27 17:41:40 +00:00
# include <svx/svxfont.hxx>
# include <svx/brshitem.hxx>
2001-08-01 09:34:48 +00:00
# include <svtools/itempool.hxx>
2002-08-01 13:48:55 +00:00
// #101498# calculate if it's RTL or not
# include <unicode/ubidi.h>
2000-09-18 16:07:07 +00:00
# define DEFAULT_SCALE 75
static const USHORT nDefStyles = 3 ; // Sonderbehandlung fuer die ersten 3 Ebenen
static const USHORT nDefBulletIndent = 800 ;
static const USHORT nDefBulletWidth = 700 ;
static const USHORT pDefBulletIndents [ nDefStyles ] = { 1400 , 800 , 800 } ;
static const USHORT pDefBulletWidths [ nDefStyles ] = { 1000 , 850 , 700 } ;
2008-06-06 11:30:58 +00:00
USHORT lcl_ImplGetDefBulletWidth ( sal_Int16 nDepth )
2000-09-18 16:07:07 +00:00
{
return ( nDepth < nDefStyles ) ? pDefBulletWidths [ nDepth ] : nDefBulletWidth ;
}
2008-06-06 11:30:58 +00:00
USHORT lcl_ImplGetDefBulletIndent ( sal_Int16 nDepth )
2000-09-18 16:07:07 +00:00
{
USHORT nI = 0 ;
2008-06-06 11:30:58 +00:00
if ( nDepth > = 0 )
{
for ( sal_Int16 n = 0 ; n < = nDepth ; n + + )
nI = nI +
( ( n < nDefStyles ) ? pDefBulletIndents [ n ] : nDefBulletIndent ) ;
}
2000-09-18 16:07:07 +00:00
return nI ;
}
2008-06-06 11:30:58 +00:00
// ----------------------------------------------------------------------
2000-09-18 16:07:07 +00:00
// Outliner
// ----------------------------------------------------------------------
DBG_NAME ( Outliner ) ;
2008-06-06 11:30:58 +00:00
void Outliner : : ImplCheckDepth ( sal_Int16 & rnDepth ) const
2001-05-30 16:23:37 +00:00
{
if ( rnDepth < nMinDepth )
rnDepth = nMinDepth ;
else if ( rnDepth > nMaxDepth )
rnDepth = nMaxDepth ;
}
2008-06-06 11:30:58 +00:00
Paragraph * Outliner : : Insert ( const XubString & rText , ULONG nAbsPos , sal_Int16 nDepth )
2000-09-18 16:07:07 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
DBG_ASSERT ( pParaList - > GetParagraphCount ( ) , " Insert:No Paras " ) ;
Paragraph * pPara ;
2001-05-30 16:23:37 +00:00
ImplCheckDepth ( nDepth ) ;
2000-09-18 16:07:07 +00:00
ULONG nParagraphCount = pParaList - > GetParagraphCount ( ) ;
if ( nAbsPos > nParagraphCount )
nAbsPos = nParagraphCount ;
if ( bFirstParaIsEmpty )
{
pPara = pParaList - > GetParagraph ( 0 ) ;
if ( pPara - > GetDepth ( ) ! = nDepth )
{
nDepthChangedHdlPrevDepth = pPara - > GetDepth ( ) ;
2008-06-06 11:30:58 +00:00
mnDepthChangeHdlPrevFlags = pPara - > nFlags ;
2000-09-18 16:07:07 +00:00
pPara - > SetDepth ( nDepth ) ;
pHdlParagraph = pPara ;
DepthChangedHdl ( ) ;
}
pPara - > nFlags | = PARAFLAG_HOLDDEPTH ;
SetText ( rText , pPara ) ;
}
else
{
BOOL bUpdate = pEditEngine - > GetUpdateMode ( ) ;
pEditEngine - > SetUpdateMode ( FALSE ) ;
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( TRUE ) ;
2000-09-18 16:07:07 +00:00
pPara = new Paragraph ( nDepth ) ;
pParaList - > Insert ( pPara , nAbsPos ) ;
pEditEngine - > InsertParagraph ( ( USHORT ) nAbsPos , String ( ) ) ;
DBG_ASSERT ( pPara = = pParaList - > GetParagraph ( nAbsPos ) , " Insert:Failed " ) ;
ImplInitDepth ( ( USHORT ) nAbsPos , nDepth , FALSE ) ;
pHdlParagraph = pPara ;
ParagraphInsertedHdl ( ) ;
pPara - > nFlags | = PARAFLAG_HOLDDEPTH ;
SetText ( rText , pPara ) ;
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( FALSE ) ;
2000-09-18 16:07:07 +00:00
pEditEngine - > SetUpdateMode ( bUpdate ) ;
}
bFirstParaIsEmpty = FALSE ;
2008-11-10 15:06:12 +00:00
DBG_ASSERT ( pEditEngine - > GetParagraphCount ( ) = = pParaList - > GetParagraphCount ( ) , " SetText failed " ) ;
2000-09-18 16:07:07 +00:00
return pPara ;
}
void Outliner : : ParagraphInserted ( USHORT nPara )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
if ( bBlockInsCallback )
return ;
if ( bPasting | | pEditEngine - > IsInUndo ( ) )
{
2008-06-06 11:30:58 +00:00
Paragraph * pPara = new Paragraph ( - 1 ) ;
2000-09-18 16:07:07 +00:00
pParaList - > Insert ( pPara , nPara ) ;
if ( pEditEngine - > IsInUndo ( ) )
{
pPara - > nFlags = PARAFLAG_SETBULLETTEXT ;
pPara - > bVisible = TRUE ;
2008-06-06 11:30:58 +00:00
const SfxInt16Item & rLevel = ( const SfxInt16Item & ) pEditEngine - > GetParaAttrib ( nPara , EE_PARA_OUTLLEVEL ) ;
2000-09-18 16:07:07 +00:00
pPara - > SetDepth ( rLevel . GetValue ( ) ) ;
}
}
else
{
2008-06-06 11:30:58 +00:00
sal_Int16 nDepth = - 1 ;
2008-07-22 06:42:36 +00:00
Paragraph * pParaBefore = pParaList - > GetParagraph ( nPara - 1 ) ;
if ( pParaBefore )
nDepth = pParaBefore - > GetDepth ( ) ;
2000-09-18 16:07:07 +00:00
Paragraph * pPara = new Paragraph ( nDepth ) ;
pParaList - > Insert ( pPara , nPara ) ;
if ( ! pEditEngine - > IsInUndo ( ) )
{
ImplCalcBulletText ( nPara , TRUE , FALSE ) ;
pHdlParagraph = pPara ;
ParagraphInsertedHdl ( ) ;
}
}
}
void Outliner : : ParagraphDeleted ( USHORT nPara )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
if ( bBlockInsCallback | | ( nPara = = EE_PARA_ALL ) )
return ;
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-07-22 06:42:36 +00:00
if ( ! pPara )
return ;
2008-06-06 11:30:58 +00:00
sal_Int16 nDepth = pPara - > GetDepth ( ) ;
2000-09-18 16:07:07 +00:00
if ( ! pEditEngine - > IsInUndo ( ) )
{
pHdlParagraph = pPara ;
ParagraphRemovingHdl ( ) ;
}
pParaList - > Remove ( nPara ) ;
delete pPara ;
2001-01-31 11:58:15 +00:00
if ( ! pEditEngine - > IsInUndo ( ) & & ! bPasting )
2000-09-18 16:07:07 +00:00
{
pPara = pParaList - > GetParagraph ( nPara ) ;
if ( pPara & & ( pPara - > GetDepth ( ) > nDepth ) )
{
ImplCalcBulletText ( nPara , TRUE , FALSE ) ;
// naechsten auf gleicher Ebene suchen...
while ( pPara & & pPara - > GetDepth ( ) > nDepth )
pPara = pParaList - > GetParagraph ( + + nPara ) ;
}
if ( pPara & & ( pPara - > GetDepth ( ) = = nDepth ) )
ImplCalcBulletText ( nPara , TRUE , FALSE ) ;
}
}
void Outliner : : Init ( USHORT nMode )
{
nOutlinerMode = nMode ;
Clear ( ) ;
ULONG nCtrl = pEditEngine - > GetControlWord ( ) ;
nCtrl & = ~ ( EE_CNTRL_OUTLINER | EE_CNTRL_OUTLINER2 ) ;
2008-06-06 11:30:58 +00:00
SetMaxDepth ( 9 ) ;
2000-09-18 16:07:07 +00:00
switch ( ImplGetOutlinerMode ( ) )
{
case OUTLINERMODE_TEXTOBJECT :
case OUTLINERMODE_TITLEOBJECT :
2008-06-06 11:30:58 +00:00
break ;
2000-09-18 16:07:07 +00:00
case OUTLINERMODE_OUTLINEOBJECT :
nCtrl | = EE_CNTRL_OUTLINER2 ;
2008-06-06 11:30:58 +00:00
break ;
2000-09-18 16:07:07 +00:00
case OUTLINERMODE_OUTLINEVIEW :
nCtrl | = EE_CNTRL_OUTLINER ;
2008-06-06 11:30:58 +00:00
break ;
2000-09-18 16:07:07 +00:00
default : DBG_ERROR ( " Outliner::Init - Invalid Mode! " ) ;
}
pEditEngine - > SetControlWord ( nCtrl ) ;
ImplInitDepth ( 0 , GetMinDepth ( ) , FALSE ) ;
2001-02-01 14:17:25 +00:00
GetUndoManager ( ) . Clear ( ) ;
2000-09-18 16:07:07 +00:00
}
2008-06-06 11:30:58 +00:00
void Outliner : : SetMaxDepth ( sal_Int16 nDepth , BOOL bCheckParagraphs )
2000-09-18 16:07:07 +00:00
{
if ( nMaxDepth ! = nDepth )
{
2008-06-06 11:30:58 +00:00
nMaxDepth = Min ( nDepth , ( sal_Int16 ) ( SVX_MAX_NUM - 1 ) ) ;
2000-09-18 16:07:07 +00:00
if ( bCheckParagraphs )
{
USHORT nParagraphs = ( USHORT ) pParaList - > GetParagraphCount ( ) ;
for ( USHORT nPara = 0 ; nPara < nParagraphs ; nPara + + )
{
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-07-22 06:42:36 +00:00
if ( pPara & & pPara - > GetDepth ( ) > nMaxDepth )
2000-09-18 16:07:07 +00:00
{
SetDepth ( pPara , nMaxDepth ) ;
}
}
}
}
}
2008-06-06 11:30:58 +00:00
sal_Int16 Outliner : : GetDepth ( ULONG nPara ) const
2000-09-18 16:07:07 +00:00
{
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
DBG_ASSERT ( pPara , " Outliner::GetDepth - Paragraph not found! " ) ;
2008-06-06 11:30:58 +00:00
return pPara ? pPara - > GetDepth ( ) : - 1 ;
2000-09-18 16:07:07 +00:00
}
2008-06-06 11:30:58 +00:00
void Outliner : : SetDepth ( Paragraph * pPara , sal_Int16 nNewDepth )
2000-09-18 16:07:07 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2001-05-30 16:23:37 +00:00
ImplCheckDepth ( nNewDepth ) ;
2000-09-18 16:07:07 +00:00
if ( nNewDepth ! = pPara - > GetDepth ( ) )
{
nDepthChangedHdlPrevDepth = pPara - > GetDepth ( ) ;
2008-06-06 11:30:58 +00:00
mnDepthChangeHdlPrevFlags = pPara - > nFlags ;
2000-09-18 16:07:07 +00:00
pHdlParagraph = pPara ;
2008-06-06 11:30:58 +00:00
USHORT nPara = ( USHORT ) GetAbsPos ( pPara ) ;
ImplInitDepth ( nPara , nNewDepth , TRUE ) ;
ImplCalcBulletText ( nPara , FALSE , FALSE ) ;
if ( ImplGetOutlinerMode ( ) = = OUTLINERMODE_OUTLINEOBJECT )
ImplSetLevelDependendStyleSheet ( nPara ) ;
2000-09-18 16:07:07 +00:00
DepthChangedHdl ( ) ;
}
}
2008-06-06 11:30:58 +00:00
sal_Int16 Outliner : : GetNumberingStartValue ( sal_uInt16 nPara )
{
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
DBG_ASSERT ( pPara , " Outliner::GetNumberingStartValue - Paragraph not found! " ) ;
return pPara ? pPara - > GetNumberingStartValue ( ) : - 1 ;
}
void Outliner : : SetNumberingStartValue ( sal_uInt16 nPara , sal_Int16 nNumberingStartValue )
{
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
DBG_ASSERT ( pPara , " Outliner::GetNumberingStartValue - Paragraph not found! " ) ;
if ( pPara & & pPara - > GetNumberingStartValue ( ) ! = nNumberingStartValue )
{
if ( IsUndoEnabled ( ) & & ! IsInUndo ( ) )
InsertUndo ( new OutlinerUndoChangeParaNumberingRestart ( this , nPara ,
pPara - > GetNumberingStartValue ( ) , nNumberingStartValue ,
pPara - > IsParaIsNumberingRestart ( ) , pPara - > IsParaIsNumberingRestart ( ) ) ) ;
pPara - > SetNumberingStartValue ( nNumberingStartValue ) ;
ImplCheckParagraphs ( nPara , ( USHORT ) ( pParaList - > GetParagraphCount ( ) - 1 ) ) ;
pEditEngine - > SetModified ( ) ;
}
}
sal_Bool Outliner : : IsParaIsNumberingRestart ( sal_uInt16 nPara )
{
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
DBG_ASSERT ( pPara , " Outliner::IsParaIsNumberingRestart - Paragraph not found! " ) ;
return pPara ? pPara - > IsParaIsNumberingRestart ( ) : sal_False ;
}
void Outliner : : SetParaIsNumberingRestart ( sal_uInt16 nPara , sal_Bool bParaIsNumberingRestart )
{
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
DBG_ASSERT ( pPara , " Outliner::SetParaIsNumberingRestart - Paragraph not found! " ) ;
if ( pPara & & ( pPara - > IsParaIsNumberingRestart ( ) ! = bParaIsNumberingRestart ) )
{
if ( IsUndoEnabled ( ) & & ! IsInUndo ( ) )
InsertUndo ( new OutlinerUndoChangeParaNumberingRestart ( this , nPara ,
pPara - > GetNumberingStartValue ( ) , pPara - > GetNumberingStartValue ( ) ,
pPara - > IsParaIsNumberingRestart ( ) , bParaIsNumberingRestart ) ) ;
pPara - > SetParaIsNumberingRestart ( bParaIsNumberingRestart ) ;
ImplCheckParagraphs ( nPara , ( USHORT ) ( pParaList - > GetParagraphCount ( ) - 1 ) ) ;
pEditEngine - > SetModified ( ) ;
}
}
2000-09-18 16:07:07 +00:00
OutlinerParaObject * Outliner : : CreateParaObject ( USHORT nStartPara , USHORT nCount ) const
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2006-10-12 12:02:06 +00:00
if ( sal : : static_int_cast < ULONG > ( nStartPara + nCount ) >
pParaList - > GetParagraphCount ( ) )
nCount = sal : : static_int_cast < USHORT > (
pParaList - > GetParagraphCount ( ) - nStartPara ) ;
2000-09-18 16:07:07 +00:00
2006-01-24 15:50:45 +00:00
// When a new OutlinerParaObject is created because a paragraph is just beeing deleted,
// it can happen that the ParaList is not updated yet...
2005-11-08 15:35:13 +00:00
if ( ( nStartPara + nCount ) > pEditEngine - > GetParagraphCount ( ) )
nCount = pEditEngine - > GetParagraphCount ( ) - nStartPara ;
2000-09-18 16:07:07 +00:00
if ( ! nCount )
return NULL ;
OutlinerParaObject * pPObj = new OutlinerParaObject ( nCount ) ;
pPObj - > pText = pEditEngine - > CreateTextObject ( nStartPara , nCount ) ;
pPObj - > SetOutlinerMode ( GetMode ( ) ) ;
pPObj - > bIsEditDoc = ( ImplGetOutlinerMode ( ) = = OUTLINERMODE_TEXTOBJECT ) ? TRUE : FALSE ;
USHORT nLastPara = nStartPara + nCount - 1 ;
for ( USHORT nPara = nStartPara ; nPara < = nLastPara ; nPara + + )
2008-10-01 06:50:54 +00:00
pPObj - > pParagraphDataArr [ nPara - nStartPara ] = * GetParagraph ( nPara ) ;
2000-09-18 16:07:07 +00:00
return pPObj ;
}
void Outliner : : SetText ( const XubString & rText , Paragraph * pPara )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2008-11-10 15:06:12 +00:00
DBG_ASSERT ( pPara , " SetText:No Para " ) ;
2000-09-18 16:07:07 +00:00
BOOL bUpdate = pEditEngine - > GetUpdateMode ( ) ;
pEditEngine - > SetUpdateMode ( FALSE ) ;
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( TRUE ) ;
2000-09-18 16:07:07 +00:00
USHORT nPara = ( USHORT ) pParaList - > GetAbsPos ( pPara ) ;
if ( ! rText . Len ( ) )
{
pEditEngine - > SetText ( nPara , rText ) ;
ImplInitDepth ( nPara , pPara - > GetDepth ( ) , FALSE ) ;
}
else
{
XubString aText ( rText ) ;
aText . ConvertLineEnd ( LINEEND_LF ) ;
if ( aText . GetChar ( aText . Len ( ) - 1 ) = = ' \x0A ' )
aText . Erase ( aText . Len ( ) - 1 , 1 ) ; // letzten Umbruch loeschen
USHORT nCount = aText . GetTokenCount ( ' \x0A ' ) ;
USHORT nPos = 0 ;
USHORT nInsPos = nPara + 1 ;
while ( nCount > nPos )
{
XubString aStr = aText . GetToken ( nPos , ' \x0A ' ) ;
2008-06-06 11:30:58 +00:00
sal_Int16 nCurDepth ;
2000-09-18 16:07:07 +00:00
if ( nPos )
{
2008-06-06 11:30:58 +00:00
pPara = new Paragraph ( - 1 ) ;
nCurDepth = - 1 ;
2000-09-18 16:07:07 +00:00
}
else
nCurDepth = pPara - > GetDepth ( ) ;
// Im Outliner-Modus die Tabulatoren filtern und die
// Einrueckung ueber ein LRSpaceItem einstellen
// Im EditEngine-Modus ueber Maltes Tabulatoren einruecken
if ( ( ImplGetOutlinerMode ( ) = = OUTLINERMODE_OUTLINEOBJECT ) | |
( ImplGetOutlinerMode ( ) = = OUTLINERMODE_OUTLINEVIEW ) )
{
// Tabs raus
USHORT nTabs = 0 ;
while ( ( nTabs < aStr . Len ( ) ) & & ( aStr . GetChar ( nTabs ) = = ' \t ' ) )
nTabs + + ;
if ( nTabs )
aStr . Erase ( 0 , nTabs ) ;
// Tiefe beibehalten ? (siehe Outliner::Insert)
if ( ! ( pPara - > nFlags & PARAFLAG_HOLDDEPTH ) )
{
2008-06-06 11:30:58 +00:00
nCurDepth = nTabs - 1 ;
2001-05-30 16:23:37 +00:00
ImplCheckDepth ( nCurDepth ) ;
2000-09-18 16:07:07 +00:00
pPara - > SetDepth ( nCurDepth ) ;
pPara - > nFlags & = ( ~ PARAFLAG_HOLDDEPTH ) ;
}
}
if ( nPos ) // nicht mit dem ersten Absatz
{
pParaList - > Insert ( pPara , nInsPos ) ;
pEditEngine - > InsertParagraph ( nInsPos , aStr ) ;
pHdlParagraph = pPara ;
ParagraphInsertedHdl ( ) ;
}
else
{
nInsPos - - ;
pEditEngine - > SetText ( nInsPos , aStr ) ;
}
ImplInitDepth ( nInsPos , nCurDepth , FALSE ) ;
nInsPos + + ;
nPos + + ;
}
}
2008-11-10 15:06:12 +00:00
DBG_ASSERT ( pParaList - > GetParagraphCount ( ) = = pEditEngine - > GetParagraphCount ( ) , " SetText failed! " ) ;
2000-09-18 16:07:07 +00:00
bFirstParaIsEmpty = FALSE ;
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( FALSE ) ;
2000-09-18 16:07:07 +00:00
pEditEngine - > SetUpdateMode ( bUpdate ) ;
}
// pView == 0 -> Tabulatoren nicht beachten
2008-06-06 11:30:58 +00:00
bool Outliner : : ImpConvertEdtToOut ( sal_uInt32 nPara , EditView * pView )
2000-09-18 16:07:07 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2008-06-06 11:30:58 +00:00
bool bConverted = false ;
2000-09-18 16:07:07 +00:00
USHORT nTabs = 0 ;
ESelection aDelSel ;
2008-06-06 11:30:58 +00:00
// const SfxItemSet& rAttrs = pEditEngine->GetParaAttribs( (sal_uInt16)nPara );
// bool bAlreadyOutliner = rAttrs.GetItemState( EE_PARA_OUTLLRSPACE ) == SFX_ITEM_ON ? true : false;
2000-09-18 16:07:07 +00:00
XubString aName ;
2005-06-28 14:38:05 +00:00
XubString aHeading_US ( RTL_CONSTASCII_USTRINGPARAM ( " heading " ) ) ;
XubString aNumber_US ( RTL_CONSTASCII_USTRINGPARAM ( " Numbering " ) ) ;
2000-09-18 16:07:07 +00:00
XubString aStr ( pEditEngine - > GetText ( ( USHORT ) nPara ) ) ;
xub_Unicode * pPtr = ( xub_Unicode * ) aStr . GetBuffer ( ) ;
USHORT nHeadingNumberStart = 0 ;
USHORT nNumberingNumberStart = 0 ;
SfxStyleSheet * pStyle = pEditEngine - > GetStyleSheet ( ( USHORT ) nPara ) ;
if ( pStyle )
{
aName = pStyle - > GetName ( ) ;
USHORT nSearch ;
if ( ( nSearch = aName . Search ( aHeading_US ) ) ! = STRING_NOTFOUND )
nHeadingNumberStart = nSearch + aHeading_US . Len ( ) ;
2005-06-28 14:38:05 +00:00
else if ( ( nSearch = aName . Search ( aNumber_US ) ) ! = STRING_NOTFOUND )
nNumberingNumberStart = nSearch + aNumber_US . Len ( ) ;
2000-09-18 16:07:07 +00:00
}
if ( nHeadingNumberStart | | nNumberingNumberStart )
{
// PowerPoint-Import ?
if ( nHeadingNumberStart & & ( aStr . Len ( ) > = 2 ) & &
( pPtr [ 0 ] ! = ' \t ' ) & & ( pPtr [ 1 ] = = ' \t ' ) )
{
// Bullet & Tab raus
aDelSel = ESelection ( ( USHORT ) nPara , 0 , ( USHORT ) nPara , 2 ) ;
}
USHORT nPos = nHeadingNumberStart ? nHeadingNumberStart : nNumberingNumberStart ;
String aLevel = aName . Copy ( nPos ) ;
aLevel . EraseLeadingChars ( ' ' ) ;
2006-10-12 12:02:06 +00:00
nTabs = sal : : static_int_cast < USHORT > ( aLevel . ToInt32 ( ) ) ;
2000-09-18 16:07:07 +00:00
if ( nTabs )
nTabs - - ; // ebene 0 = "heading 1"
bConverted = TRUE ;
}
else
{
// Fuehrende Tabulatoren filtern
while ( * pPtr = = ' \t ' )
{
pPtr + + ;
nTabs + + ;
}
// Tabulatoren aus dem Text entfernen
if ( nTabs )
aDelSel = ESelection ( ( USHORT ) nPara , 0 , ( USHORT ) nPara , nTabs ) ;
}
if ( aDelSel . HasRange ( ) )
{
if ( pView )
{
pView - > SetSelection ( aDelSel ) ;
pView - > DeleteSelected ( ) ;
}
else
pEditEngine - > QuickDelete ( aDelSel ) ;
}
2008-06-06 11:30:58 +00:00
const SfxInt16Item & rLevel = ( const SfxInt16Item & ) pEditEngine - > GetParaAttrib ( sal : : static_int_cast < sal_uInt16 > ( nPara ) , EE_PARA_OUTLLEVEL ) ;
sal_Int16 nOutlLevel = rLevel . GetValue ( ) ;
2002-01-16 09:35:41 +00:00
2008-06-06 11:30:58 +00:00
ImplCheckDepth ( nOutlLevel ) ;
ImplInitDepth ( sal : : static_int_cast < sal_uInt16 > ( nPara ) , nOutlLevel , FALSE ) ;
2000-09-18 16:07:07 +00:00
return bConverted ;
}
void Outliner : : SetText ( const OutlinerParaObject & rPObj )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
BOOL bUpdate = pEditEngine - > GetUpdateMode ( ) ;
pEditEngine - > SetUpdateMode ( FALSE ) ;
BOOL bUndo = pEditEngine - > IsUndoEnabled ( ) ;
EnableUndo ( FALSE ) ;
Init ( rPObj . GetOutlinerMode ( ) ) ;
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( TRUE ) ;
2000-09-18 16:07:07 +00:00
pEditEngine - > SetText ( * ( rPObj . pText ) ) ;
2006-10-12 12:02:06 +00:00
if ( rPObj . nCount ! = pEditEngine - > GetParagraphCount ( ) )
{
int nop = 0 ; nop + + ;
}
2000-09-18 16:07:07 +00:00
bFirstParaIsEmpty = FALSE ;
pParaList - > Clear ( TRUE ) ;
for ( USHORT nCurPara = 0 ; nCurPara < rPObj . nCount ; nCurPara + + )
{
2008-10-01 06:50:54 +00:00
Paragraph * pPara = new Paragraph ( rPObj . pParagraphDataArr [ nCurPara ] ) ;
ImplCheckDepth ( pPara - > nDepth ) ;
2000-09-18 16:07:07 +00:00
pParaList - > Insert ( pPara , LIST_APPEND ) ;
ImplCheckNumBulletItem ( nCurPara ) ;
}
ImplCheckParagraphs ( 0 , ( USHORT ) ( pParaList - > GetParagraphCount ( ) - 1 ) ) ;
EnableUndo ( bUndo ) ;
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( FALSE ) ;
2000-09-18 16:07:07 +00:00
pEditEngine - > SetUpdateMode ( bUpdate ) ;
2008-11-10 15:06:12 +00:00
DBG_ASSERT ( pParaList - > GetParagraphCount ( ) = = rPObj . Count ( ) , " SetText failed " ) ;
DBG_ASSERT ( pEditEngine - > GetParagraphCount ( ) = = rPObj . Count ( ) , " SetText failed " ) ;
2000-09-18 16:07:07 +00:00
}
void Outliner : : AddText ( const OutlinerParaObject & rPObj )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
Paragraph * pPara ;
BOOL bUpdate = pEditEngine - > GetUpdateMode ( ) ;
pEditEngine - > SetUpdateMode ( FALSE ) ;
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( TRUE ) ;
2000-09-18 16:07:07 +00:00
ULONG nPara ;
if ( bFirstParaIsEmpty )
{
pParaList - > Clear ( TRUE ) ;
pEditEngine - > SetText ( * ( rPObj . pText ) ) ;
nPara = 0 ;
}
else
{
nPara = pParaList - > GetParagraphCount ( ) ;
pEditEngine - > InsertParagraph ( EE_PARA_APPEND , * ( rPObj . pText ) ) ;
}
bFirstParaIsEmpty = FALSE ;
for ( USHORT n = 0 ; n < rPObj . nCount ; n + + )
{
2008-10-01 06:50:54 +00:00
pPara = new Paragraph ( rPObj . pParagraphDataArr [ n ] ) ;
2000-09-18 16:07:07 +00:00
pParaList - > Insert ( pPara , LIST_APPEND ) ;
2006-10-12 12:02:06 +00:00
USHORT nP = sal : : static_int_cast < USHORT > ( nPara + n ) ;
2008-11-10 15:06:12 +00:00
DBG_ASSERT ( pParaList - > GetAbsPos ( pPara ) = = nP , " AddText:Out of sync " ) ;
2000-09-18 16:07:07 +00:00
ImplInitDepth ( nP , pPara - > GetDepth ( ) , FALSE ) ;
}
DBG_ASSERT ( pEditEngine - > GetParagraphCount ( ) = = pParaList - > GetParagraphCount ( ) , " SetText: OutOfSync " ) ;
ImplCheckParagraphs ( ( USHORT ) nPara , ( USHORT ) ( pParaList - > GetParagraphCount ( ) - 1 ) ) ;
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( FALSE ) ;
2000-09-18 16:07:07 +00:00
pEditEngine - > SetUpdateMode ( bUpdate ) ;
}
void __EXPORT Outliner : : FieldClicked ( const SvxFieldItem & rField , USHORT nPara , USHORT nPos )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
if ( aFieldClickedHdl . IsSet ( ) )
{
EditFieldInfo aFldInfo ( this , rField , nPara , nPos ) ;
aFldInfo . SetSimpleClick ( TRUE ) ;
aFieldClickedHdl . Call ( & aFldInfo ) ;
}
}
void __EXPORT Outliner : : FieldSelected ( const SvxFieldItem & rField , USHORT nPara , USHORT nPos )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
if ( ! aFieldClickedHdl . IsSet ( ) )
return ;
EditFieldInfo aFldInfo ( this , rField , nPara , nPos ) ;
aFldInfo . SetSimpleClick ( FALSE ) ;
aFieldClickedHdl . Call ( & aFldInfo ) ;
}
XubString __EXPORT Outliner : : CalcFieldValue ( const SvxFieldItem & rField , USHORT nPara , USHORT nPos , Color * & rpTxtColor , Color * & rpFldColor )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
if ( ! aCalcFieldValueHdl . IsSet ( ) )
return String ( ' ' ) ;
EditFieldInfo aFldInfo ( this , rField , nPara , nPos ) ;
// Die FldColor ist mit COL_LIGHTGRAY voreingestellt.
if ( rpFldColor )
aFldInfo . SetFldColor ( * rpFldColor ) ;
aCalcFieldValueHdl . Call ( & aFldInfo ) ;
if ( aFldInfo . GetTxtColor ( ) )
{
delete rpTxtColor ;
rpTxtColor = new Color ( * aFldInfo . GetTxtColor ( ) ) ;
}
delete rpFldColor ;
rpFldColor = aFldInfo . GetFldColor ( ) ? new Color ( * aFldInfo . GetFldColor ( ) ) : 0 ;
return aFldInfo . GetRepresentation ( ) ;
}
void Outliner : : SetStyleSheet ( ULONG nPara , SfxStyleSheet * pStyle )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-07-22 06:42:36 +00:00
if ( pPara )
{
pEditEngine - > SetStyleSheet ( ( USHORT ) nPara , pStyle ) ;
pPara - > nFlags | = PARAFLAG_SETBULLETTEXT ;
ImplCheckNumBulletItem ( ( USHORT ) nPara ) ;
}
2000-09-18 16:07:07 +00:00
}
void Outliner : : SetVisible ( Paragraph * pPara , BOOL bVisible )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
DBG_ASSERT ( pPara , " SetVisible: pPara = NULL " ) ;
2008-07-22 06:42:36 +00:00
if ( pPara )
{
pPara - > bVisible = bVisible ;
ULONG nPara = pParaList - > GetAbsPos ( pPara ) ;
pEditEngine - > ShowParagraph ( ( USHORT ) nPara , bVisible ) ;
}
2000-09-18 16:07:07 +00:00
}
void Outliner : : ImplCheckNumBulletItem ( USHORT nPara )
{
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-07-22 06:42:36 +00:00
if ( pPara )
pPara - > aBulSize . Width ( ) = - 1 ;
2000-09-18 16:07:07 +00:00
}
2001-11-14 10:01:23 +00:00
void Outliner : : ImplSetLevelDependendStyleSheet ( USHORT nPara , SfxStyleSheet * pLevelStyle )
2000-09-18 16:07:07 +00:00
{
2001-11-14 10:01:23 +00:00
DBG_CHKTHIS ( Outliner , 0 ) ;
DBG_ASSERT ( ( ImplGetOutlinerMode ( ) = = OUTLINERMODE_OUTLINEOBJECT ) | | ( ImplGetOutlinerMode ( ) = = OUTLINERMODE_OUTLINEVIEW ) , " SetLevelDependendStyleSheet: Wrong Mode! " ) ;
SfxStyleSheet * pStyle = pLevelStyle ;
if ( ! pStyle )
pStyle = GetStyleSheet ( nPara ) ;
2000-09-18 16:07:07 +00:00
2001-11-14 10:01:23 +00:00
if ( pStyle )
2000-09-18 16:07:07 +00:00
{
2008-06-06 11:30:58 +00:00
sal_Int16 nDepth = GetDepth ( nPara ) ;
if ( nDepth < 0 )
nDepth = 0 ;
2001-11-14 10:01:23 +00:00
String aNewStyleSheetName ( pStyle - > GetName ( ) ) ;
2000-09-18 16:07:07 +00:00
aNewStyleSheetName . Erase ( aNewStyleSheetName . Len ( ) - 1 , 1 ) ;
2008-06-06 11:30:58 +00:00
aNewStyleSheetName + = String : : CreateFromInt32 ( nDepth + 1 ) ;
2001-11-14 10:01:23 +00:00
SfxStyleSheet * pNewStyle = ( SfxStyleSheet * ) GetStyleSheetPool ( ) - > Find ( aNewStyleSheetName , pStyle - > GetFamily ( ) ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( pNewStyle , " AutoStyleSheetName - Style not found! " ) ;
2001-11-14 10:01:23 +00:00
if ( pNewStyle & & ( pNewStyle ! = GetStyleSheet ( nPara ) ) )
2000-10-11 11:59:46 +00:00
{
2001-11-14 10:01:23 +00:00
SfxItemSet aOldAttrs ( GetParaAttribs ( nPara ) ) ;
2000-09-18 16:07:07 +00:00
SetStyleSheet ( nPara , pNewStyle ) ;
2000-10-11 11:59:46 +00:00
if ( aOldAttrs . GetItemState ( EE_PARA_NUMBULLET ) = = SFX_ITEM_ON )
{
2001-11-14 10:01:23 +00:00
SfxItemSet aAttrs ( GetParaAttribs ( nPara ) ) ;
2000-10-11 11:59:46 +00:00
aAttrs . Put ( aOldAttrs . Get ( EE_PARA_NUMBULLET ) ) ;
2001-11-14 10:01:23 +00:00
SetParaAttribs ( nPara , aAttrs ) ;
2000-10-11 11:59:46 +00:00
}
}
2000-09-18 16:07:07 +00:00
}
}
2008-06-06 11:30:58 +00:00
void Outliner : : ImplInitDepth ( USHORT nPara , sal_Int16 nDepth , BOOL bCreateUndo , BOOL bUndoAction )
2000-09-18 16:07:07 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2001-05-30 16:23:37 +00:00
DBG_ASSERT ( ( nDepth > = nMinDepth ) & & ( nDepth < = nMaxDepth ) , " ImplInitDepth - Depth is invalid! " ) ;
2000-09-18 16:07:07 +00:00
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-07-22 06:42:36 +00:00
if ( ! pPara )
return ;
2008-06-06 11:30:58 +00:00
sal_Int16 nOldDepth = pPara - > GetDepth ( ) ;
2000-09-18 16:07:07 +00:00
pPara - > SetDepth ( nDepth ) ;
// Bei IsInUndo brauchen Attribute und Style nicht eingestellt werden,
// dort werden die alten Werte durch die EditEngine restauriert.
if ( ! IsInUndo ( ) )
{
BOOL bUpdate = pEditEngine - > GetUpdateMode ( ) ;
pEditEngine - > SetUpdateMode ( FALSE ) ;
BOOL bUndo = bCreateUndo & & IsUndoEnabled ( ) ;
if ( bUndo & & bUndoAction )
UndoActionStart ( OLUNDO_DEPTH ) ;
SfxItemSet aAttrs ( pEditEngine - > GetParaAttribs ( nPara ) ) ;
2008-06-06 11:30:58 +00:00
aAttrs . Put ( SfxInt16Item ( EE_PARA_OUTLLEVEL , nDepth ) ) ;
2000-09-18 16:07:07 +00:00
pEditEngine - > SetParaAttribs ( nPara , aAttrs ) ;
ImplCheckNumBulletItem ( nPara ) ;
ImplCalcBulletText ( nPara , FALSE , FALSE ) ;
if ( bUndo )
{
InsertUndo ( new OutlinerUndoChangeDepth ( this , nPara , nOldDepth , nDepth ) ) ;
if ( bUndoAction )
UndoActionEnd ( OLUNDO_DEPTH ) ;
}
pEditEngine - > SetUpdateMode ( bUpdate ) ;
}
}
2008-06-06 11:30:58 +00:00
void Outliner : : SetParaAttribs ( USHORT nPara , const SfxItemSet & rSet )
2000-09-18 16:07:07 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2008-06-06 11:30:58 +00:00
pEditEngine - > SetParaAttribs ( nPara , rSet ) ;
2000-09-18 16:07:07 +00:00
}
BOOL Outliner : : Expand ( Paragraph * pPara )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
if ( pParaList - > HasHiddenChilds ( pPara ) )
{
2006-10-12 12:02:06 +00:00
OLUndoExpand * pUndo = 0 ;
2000-09-18 16:07:07 +00:00
BOOL bUndo = IsUndoEnabled ( ) & & ! IsInUndo ( ) ;
if ( bUndo )
{
UndoActionStart ( OLUNDO_EXPAND ) ;
pUndo = new OLUndoExpand ( this , OLUNDO_EXPAND ) ;
pUndo - > pParas = 0 ;
pUndo - > nCount = ( USHORT ) pParaList - > GetAbsPos ( pPara ) ;
}
pHdlParagraph = pPara ;
bIsExpanding = TRUE ;
pParaList - > Expand ( pPara ) ;
ExpandHdl ( ) ;
InvalidateBullet ( pPara , pParaList - > GetAbsPos ( pPara ) ) ;
if ( bUndo )
{
InsertUndo ( pUndo ) ;
UndoActionEnd ( OLUNDO_EXPAND ) ;
}
return TRUE ;
}
return FALSE ;
}
BOOL Outliner : : Collapse ( Paragraph * pPara )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
if ( pParaList - > HasVisibleChilds ( pPara ) ) // expandiert
{
2006-10-12 12:02:06 +00:00
OLUndoExpand * pUndo = 0 ;
2000-09-18 16:07:07 +00:00
BOOL bUndo = FALSE ;
2006-10-12 12:02:06 +00:00
2000-09-18 16:07:07 +00:00
if ( ! IsInUndo ( ) & & IsUndoEnabled ( ) )
bUndo = TRUE ;
if ( bUndo )
{
UndoActionStart ( OLUNDO_COLLAPSE ) ;
pUndo = new OLUndoExpand ( this , OLUNDO_COLLAPSE ) ;
pUndo - > pParas = 0 ;
pUndo - > nCount = ( USHORT ) pParaList - > GetAbsPos ( pPara ) ;
}
2006-10-12 12:02:06 +00:00
2000-09-18 16:07:07 +00:00
pHdlParagraph = pPara ;
bIsExpanding = FALSE ;
pParaList - > Collapse ( pPara ) ;
ExpandHdl ( ) ;
InvalidateBullet ( pPara , pParaList - > GetAbsPos ( pPara ) ) ;
if ( bUndo )
{
InsertUndo ( pUndo ) ;
UndoActionEnd ( OLUNDO_COLLAPSE ) ;
}
return TRUE ;
}
return FALSE ;
}
Font Outliner : : ImpCalcBulletFont ( USHORT nPara ) const
{
2008-06-06 11:30:58 +00:00
const SvxNumberFormat * pFmt = GetNumberFormat ( nPara ) ;
2001-03-29 14:12:06 +00:00
DBG_ASSERT ( pFmt & & ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_BITMAP ) & & ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_NUMBER_NONE ) , " ImpCalcBulletFont: Missing or BitmapBullet! " ) ;
2000-09-18 16:07:07 +00:00
2003-04-17 14:58:29 +00:00
Font aStdFont ; //#107508#
if ( ! pEditEngine - > IsFlatMode ( ) )
{
ESelection aSel ( nPara , 0 , nPara , 0 ) ;
aStdFont = EditEngine : : CreateFontFromItemSet ( pEditEngine - > GetAttribs ( aSel ) , GetScriptType ( aSel ) ) ;
}
else
{
aStdFont = pEditEngine - > GetStandardFont ( nPara ) ;
}
2000-09-18 16:07:07 +00:00
2000-10-19 10:11:17 +00:00
Font aBulletFont ;
2001-02-23 11:29:54 +00:00
if ( pFmt - > GetNumberingType ( ) = = SVX_NUM_CHAR_SPECIAL )
2001-11-28 10:24:50 +00:00
{
2000-10-19 10:11:17 +00:00
aBulletFont = * pFmt - > GetBulletFont ( ) ;
2001-11-28 10:24:50 +00:00
}
2000-10-19 10:11:17 +00:00
else
2001-11-28 10:24:50 +00:00
{
aBulletFont = aStdFont ;
aBulletFont . SetUnderline ( UNDERLINE_NONE ) ;
2009-01-05 17:49:45 +00:00
aBulletFont . SetOverline ( UNDERLINE_NONE ) ;
2001-11-28 10:24:50 +00:00
aBulletFont . SetStrikeout ( STRIKEOUT_NONE ) ;
aBulletFont . SetEmphasisMark ( EMPHASISMARK_NONE ) ;
aBulletFont . SetRelief ( RELIEF_NONE ) ;
}
2003-04-17 14:58:29 +00:00
// #107508# Use original scale...
USHORT nScale = /* pEditEngine->IsFlatMode() ? DEFAULT_SCALE : */ pFmt - > GetBulletRelSize ( ) ;
2001-11-28 10:24:50 +00:00
ULONG nScaledLineHeight = aStdFont . GetSize ( ) . Height ( ) ;
nScaledLineHeight * = nScale * 10 ;
nScaledLineHeight / = 1000 ;
2000-10-19 10:11:17 +00:00
2000-09-18 16:07:07 +00:00
aBulletFont . SetAlign ( ALIGN_BOTTOM ) ;
aBulletFont . SetSize ( Size ( 0 , nScaledLineHeight ) ) ;
2000-11-24 10:30:28 +00:00
BOOL bVertical = IsVertical ( ) ;
aBulletFont . SetVertical ( bVertical ) ;
aBulletFont . SetOrientation ( bVertical ? 2700 : 0 ) ;
2000-11-20 11:17:53 +00:00
2002-08-05 13:52:26 +00:00
Color aColor ( COL_AUTO ) ;
2000-11-20 11:17:53 +00:00
if ( ! pEditEngine - > IsFlatMode ( ) & & ! ( pEditEngine - > GetControlWord ( ) & EE_CNTRL_NOCOLORS ) )
2002-02-25 15:10:51 +00:00
{
2000-11-20 11:17:53 +00:00
aColor = pFmt - > GetBulletColor ( ) ;
2002-02-25 15:10:51 +00:00
}
2002-08-05 13:52:26 +00:00
if ( ( aColor = = COL_AUTO ) | | ( IsForceAutoColor ( ) ) )
aColor = pEditEngine - > GetAutoColor ( ) ;
2000-11-20 11:17:53 +00:00
aBulletFont . SetColor ( aColor ) ;
2000-09-18 16:07:07 +00:00
return aBulletFont ;
}
void Outliner : : PaintBullet ( USHORT nPara , const Point & rStartPos ,
const Point & rOrigin , short nOrientation , OutputDevice * pOutDev )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2008-06-06 11:30:58 +00:00
bool bDrawBullet = false ;
if ( pEditEngine )
{
const SfxBoolItem & rBulletState = ( const SfxBoolItem & ) pEditEngine - > GetParaAttrib ( nPara , EE_PARA_BULLETSTATE ) ;
bDrawBullet = rBulletState . GetValue ( ) ? true : false ;
}
if ( ImplHasBullet ( nPara ) & & bDrawBullet )
2000-09-18 16:07:07 +00:00
{
2000-11-24 10:30:28 +00:00
BOOL bVertical = IsVertical ( ) ;
2002-07-24 12:18:20 +00:00
BOOL bRightToLeftPara = pEditEngine - > IsRightToLeft ( nPara ) ;
Rectangle aBulletArea ( ImpCalcBulletArea ( nPara , TRUE , FALSE ) ) ;
2000-09-18 16:07:07 +00:00
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-06-06 11:30:58 +00:00
const SvxNumberFormat * pFmt = GetNumberFormat ( nPara ) ;
2001-04-11 12:12:05 +00:00
if ( pFmt & & ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_NUMBER_NONE ) )
2000-09-18 16:07:07 +00:00
{
2001-02-23 11:29:54 +00:00
if ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_BITMAP )
2000-09-18 16:07:07 +00:00
{
Font aBulletFont ( ImpCalcBulletFont ( nPara ) ) ;
2003-03-27 14:06:05 +00:00
// #2338# Use base line
BOOL bSymbol = pFmt - > GetNumberingType ( ) = = SVX_NUM_CHAR_SPECIAL ;
aBulletFont . SetAlign ( bSymbol ? ALIGN_BOTTOM : ALIGN_BASELINE ) ;
2000-09-18 16:07:07 +00:00
Font aOldFont = pOutDev - > GetFont ( ) ;
pOutDev - > SetFont ( aBulletFont ) ;
2003-03-27 14:06:05 +00:00
ParagraphInfos aParaInfos = pEditEngine - > GetParagraphInfos ( nPara ) ;
2000-11-24 10:30:28 +00:00
Point aTextPos ;
if ( ! bVertical )
2001-07-31 12:31:16 +00:00
{
2003-03-27 14:06:05 +00:00
// aTextPos.Y() = rStartPos.Y() + aBulletArea.Bottom();
aTextPos . Y ( ) = rStartPos . Y ( ) + ( bSymbol ? aBulletArea . Bottom ( ) : aParaInfos . nFirstLineMaxAscent ) ;
2002-07-24 12:18:20 +00:00
if ( ! bRightToLeftPara )
aTextPos . X ( ) = rStartPos . X ( ) + aBulletArea . Left ( ) ;
else
2003-03-27 14:06:05 +00:00
aTextPos . X ( ) = rStartPos . X ( ) + GetPaperSize ( ) . Width ( ) - aBulletArea . Left ( ) ;
2001-07-31 12:31:16 +00:00
}
2000-11-24 10:30:28 +00:00
else
{
2003-03-27 14:06:05 +00:00
// aTextPos.X() = rStartPos.X() - aBulletArea.Bottom();
aTextPos . X ( ) = rStartPos . X ( ) - ( bSymbol ? aBulletArea . Bottom ( ) : aParaInfos . nFirstLineMaxAscent ) ;
2001-07-31 12:31:16 +00:00
aTextPos . Y ( ) = rStartPos . Y ( ) + aBulletArea . Left ( ) ;
2000-11-24 10:30:28 +00:00
}
2000-09-18 16:07:07 +00:00
2008-08-19 22:02:20 +00:00
if ( nOrientation )
2000-09-18 16:07:07 +00:00
{
2008-08-19 22:02:20 +00:00
// Sowohl TopLeft als auch BottomLeft nicht ganz richtig, da
// in EditEngine BaseLine...
double nRealOrientation = nOrientation * F_PI1800 ;
double nCos = cos ( nRealOrientation ) ;
double nSin = sin ( nRealOrientation ) ;
Point aRotatedPos ;
// Translation...
aTextPos - = rOrigin ;
// Rotation...
aRotatedPos . X ( ) = ( long ) ( nCos * aTextPos . X ( ) + nSin * aTextPos . Y ( ) ) ;
aRotatedPos . Y ( ) = ( long ) - ( nSin * aTextPos . X ( ) - nCos * aTextPos . Y ( ) ) ;
aTextPos = aRotatedPos ;
// Translation...
aTextPos + = rOrigin ;
Font aRotatedFont ( aBulletFont ) ;
aRotatedFont . SetOrientation ( nOrientation ) ;
pOutDev - > SetFont ( aRotatedFont ) ;
}
2000-09-18 16:07:07 +00:00
2008-08-19 22:02:20 +00:00
// #105803# VCL will care for brackets and so on...
ULONG nLayoutMode = pOutDev - > GetLayoutMode ( ) ;
nLayoutMode & = ~ ( TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_COMPLEX_DISABLED | TEXT_LAYOUT_BIDI_STRONG ) ;
if ( bRightToLeftPara )
nLayoutMode | = TEXT_LAYOUT_BIDI_RTL ;
pOutDev - > SetLayoutMode ( nLayoutMode ) ;
2003-04-17 14:58:29 +00:00
2008-08-19 22:02:20 +00:00
if ( bStrippingPortions )
2000-09-18 16:07:07 +00:00
{
2008-08-19 22:02:20 +00:00
const Font aSvxFont ( pOutDev - > GetFont ( ) ) ;
2006-04-19 12:51:03 +00:00
sal_Int32 * pBuf = new sal_Int32 [ pPara - > GetText ( ) . Len ( ) ] ;
2000-09-18 16:07:07 +00:00
pOutDev - > GetTextArray ( pPara - > GetText ( ) , pBuf ) ;
2002-08-01 13:48:55 +00:00
2008-08-19 22:02:20 +00:00
if ( bSymbol )
{
// aTextPos is Bottom, go to Baseline
FontMetric aMetric ( pOutDev - > GetFontMetric ( ) ) ;
aTextPos . Y ( ) - = aMetric . GetDescent ( ) ;
}
DrawingText ( aTextPos , pPara - > GetText ( ) , 0 , pPara - > GetText ( ) . Len ( ) , pBuf ,
2009-01-05 17:49:45 +00:00
aSvxFont , nPara , 0xFFFF , 0xFF , 0 , 0 , false , false , true , 0 , Color ( ) , Color ( ) ) ;
2002-08-01 13:48:55 +00:00
2002-07-17 09:24:35 +00:00
delete [ ] pBuf ;
2000-09-18 16:07:07 +00:00
}
2008-08-19 22:02:20 +00:00
else
{
pOutDev - > DrawText ( aTextPos , pPara - > GetText ( ) ) ;
}
2000-09-18 16:07:07 +00:00
pOutDev - > SetFont ( aOldFont ) ;
}
else
{
2008-08-19 22:02:20 +00:00
if ( pFmt - > GetBrush ( ) - > GetGraphicObject ( ) )
2000-09-18 16:07:07 +00:00
{
2008-08-19 22:02:20 +00:00
Point aBulletPos ;
if ( ! bVertical )
2001-07-31 12:31:16 +00:00
{
2008-08-19 22:02:20 +00:00
aBulletPos . Y ( ) = rStartPos . Y ( ) + aBulletArea . Top ( ) ;
if ( ! bRightToLeftPara )
aBulletPos . X ( ) = rStartPos . X ( ) + aBulletArea . Left ( ) ;
2001-07-31 12:31:16 +00:00
else
2008-08-19 22:02:20 +00:00
aBulletPos . X ( ) = rStartPos . X ( ) + GetPaperSize ( ) . Width ( ) - aBulletArea . Right ( ) ;
}
else
{
aBulletPos . X ( ) = rStartPos . X ( ) - aBulletArea . Bottom ( ) ;
aBulletPos . Y ( ) = rStartPos . Y ( ) + aBulletArea . Left ( ) ;
}
if ( bStrippingPortions )
{
if ( aDrawBulletHdl . IsSet ( ) )
2001-07-31 12:52:07 +00:00
{
2008-08-19 22:02:20 +00:00
// call something analog to aDrawPortionHdl (if set) and feed it something
// analog to DrawPortionInfo...
// created aDrawBulletHdl, Set/GetDrawBulletHdl.
// created DrawBulletInfo and added handling to sdrtextdecomposition.cxx
DrawBulletInfo aDrawBulletInfo (
* pFmt - > GetBrush ( ) - > GetGraphicObject ( ) ,
aBulletPos ,
pPara - > aBulSize ) ;
aDrawBulletHdl . Call ( & aDrawBulletInfo ) ;
2001-07-31 12:52:07 +00:00
}
2008-08-19 22:02:20 +00:00
}
else
{
2001-07-31 12:31:16 +00:00
// MT: Remove CAST when KA made the Draw-Method const
( ( GraphicObject * ) pFmt - > GetBrush ( ) - > GetGraphicObject ( ) ) - > Draw ( pOutDev , aBulletPos , pPara - > aBulSize ) ;
}
2000-09-18 16:07:07 +00:00
}
}
}
// Bei zusammengeklappten Absaetzen einen Strich vor den Text malen.
if ( pParaList - > HasChilds ( pPara ) & & ! pParaList - > HasVisibleChilds ( pPara ) & &
! bStrippingPortions & & ! nOrientation )
{
2001-07-31 12:52:07 +00:00
long nWidth = pOutDev - > PixelToLogic ( Size ( 10 , 0 ) ) . Width ( ) ;
Point aStartPos , aEndPos ;
if ( ! bVertical )
{
aStartPos . Y ( ) = rStartPos . Y ( ) + aBulletArea . Bottom ( ) ;
2002-07-24 12:18:20 +00:00
if ( ! bRightToLeftPara )
aStartPos . X ( ) = rStartPos . X ( ) + aBulletArea . Right ( ) ;
else
aStartPos . X ( ) = rStartPos . X ( ) + GetPaperSize ( ) . Width ( ) - aBulletArea . Left ( ) ;
2001-07-31 12:52:07 +00:00
aEndPos = aStartPos ;
aEndPos . X ( ) + = nWidth ;
}
else
{
aStartPos . X ( ) = rStartPos . X ( ) - aBulletArea . Bottom ( ) ;
aStartPos . Y ( ) = rStartPos . Y ( ) + aBulletArea . Right ( ) ;
aEndPos = aStartPos ;
aEndPos . Y ( ) + = nWidth ;
}
2000-09-18 16:07:07 +00:00
const Color & rOldLineColor = pOutDev - > GetLineColor ( ) ;
pOutDev - > SetLineColor ( Color ( COL_BLACK ) ) ;
2001-07-31 12:52:07 +00:00
pOutDev - > DrawLine ( aStartPos , aEndPos ) ;
2000-09-18 16:07:07 +00:00
pOutDev - > SetLineColor ( rOldLineColor ) ;
}
}
}
2006-10-12 12:02:06 +00:00
void Outliner : : InvalidateBullet ( Paragraph * /*pPara*/ , ULONG nPara )
2000-09-18 16:07:07 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
long nLineHeight = ( long ) pEditEngine - > GetLineHeight ( ( USHORT ) nPara ) ;
OutlinerView * pView = aViewList . First ( ) ;
while ( pView )
{
Point aPos ( pView - > pEditView - > GetWindowPosTopLeft ( ( USHORT ) nPara ) ) ;
Rectangle aRect ( pView - > GetOutputArea ( ) ) ;
aRect . Right ( ) = aPos . X ( ) ;
aRect . Top ( ) = aPos . Y ( ) ;
aRect . Bottom ( ) = aPos . Y ( ) ;
aRect . Bottom ( ) + = nLineHeight ;
pView - > GetWindow ( ) - > Invalidate ( aRect ) ;
pView = aViewList . Next ( ) ;
}
}
2005-01-11 12:02:09 +00:00
ULONG Outliner : : Read ( SvStream & rInput , const String & rBaseURL , USHORT eFormat , SvKeyValueIterator * pHTTPHeaderAttrs )
2000-09-18 16:07:07 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
BOOL bOldUndo = pEditEngine - > IsUndoEnabled ( ) ;
EnableUndo ( FALSE ) ;
BOOL bUpdate = pEditEngine - > GetUpdateMode ( ) ;
pEditEngine - > SetUpdateMode ( FALSE ) ;
Clear ( ) ;
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( TRUE ) ;
2005-01-11 12:02:09 +00:00
ULONG nRet = pEditEngine - > Read ( rInput , rBaseURL , ( EETextFormat ) eFormat , pHTTPHeaderAttrs ) ;
2000-09-18 16:07:07 +00:00
bFirstParaIsEmpty = FALSE ;
USHORT nParas = pEditEngine - > GetParagraphCount ( ) ;
pParaList - > Clear ( TRUE ) ;
USHORT n ;
for ( n = 0 ; n < nParas ; n + + )
{
Paragraph * pPara = new Paragraph ( 0 ) ;
pParaList - > Insert ( pPara , LIST_APPEND ) ;
if ( eFormat = = EE_FORMAT_BIN )
{
const SfxItemSet & rAttrs = pEditEngine - > GetParaAttribs ( n ) ;
2008-06-06 11:30:58 +00:00
const SfxInt16Item & rLevel = ( const SfxInt16Item & ) rAttrs . Get ( EE_PARA_OUTLLEVEL ) ;
sal_Int16 nDepth = rLevel . GetValue ( ) ;
2000-09-18 16:07:07 +00:00
ImplInitDepth ( n , nDepth , FALSE ) ;
}
}
if ( eFormat ! = EE_FORMAT_BIN )
{
ImpFilterIndents ( 0 , nParas - 1 ) ;
}
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( FALSE ) ;
2000-09-18 16:07:07 +00:00
pEditEngine - > SetUpdateMode ( bUpdate ) ;
EnableUndo ( bOldUndo ) ;
return nRet ;
}
void Outliner : : ImpFilterIndents ( ULONG nFirstPara , ULONG nLastPara )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
BOOL bUpdate = pEditEngine - > GetUpdateMode ( ) ;
pEditEngine - > SetUpdateMode ( FALSE ) ;
Paragraph * pLastConverted = NULL ;
for ( ULONG nPara = nFirstPara ; nPara < = nLastPara ; nPara + + )
{
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-07-22 06:42:36 +00:00
if ( pPara )
{
if ( ImpConvertEdtToOut ( nPara ) )
{
pLastConverted = pPara ;
}
else if ( pLastConverted )
{
// Normale Absaetze unter der Ueberschrift anordnen...
pPara - > SetDepth ( pLastConverted - > GetDepth ( ) ) ;
}
2000-09-18 16:07:07 +00:00
2008-07-22 06:42:36 +00:00
ImplInitDepth ( ( USHORT ) nPara , pPara - > GetDepth ( ) , FALSE ) ;
}
2000-09-18 16:07:07 +00:00
}
pEditEngine - > SetUpdateMode ( bUpdate ) ;
}
SfxUndoManager & Outliner : : GetUndoManager ( )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
return pEditEngine - > GetUndoManager ( ) ;
}
void Outliner : : ImpTextPasted ( ULONG nStartPara , USHORT nCount )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
BOOL bUpdate = pEditEngine - > GetUpdateMode ( ) ;
pEditEngine - > SetUpdateMode ( FALSE ) ;
const ULONG nStart = nStartPara ;
Paragraph * pPara = pParaList - > GetParagraph ( nStartPara ) ;
2008-06-06 11:30:58 +00:00
// Paragraph* pLastConverted = NULL;
// bool bFirst = true;
2000-09-18 16:07:07 +00:00
while ( nCount & & pPara )
{
if ( ImplGetOutlinerMode ( ) ! = OUTLINERMODE_TEXTOBJECT )
{
2008-06-06 11:30:58 +00:00
nDepthChangedHdlPrevDepth = pPara - > GetDepth ( ) ;
mnDepthChangeHdlPrevFlags = pPara - > nFlags ;
2000-09-18 16:07:07 +00:00
2008-06-06 11:30:58 +00:00
ImpConvertEdtToOut ( nStartPara ) ;
pHdlParagraph = pPara ;
if ( nStartPara = = nStart )
2001-08-01 10:40:44 +00:00
{
2008-06-06 11:30:58 +00:00
// the existing paragraph has changed depth or flags
if ( ( pPara - > GetDepth ( ) ! = nDepthChangedHdlPrevDepth ) | | ( pPara - > nFlags ! = mnDepthChangeHdlPrevFlags ) )
DepthChangedHdl ( ) ;
2001-08-01 10:40:44 +00:00
}
2000-09-18 16:07:07 +00:00
}
else // EditEngine-Modus
{
2008-06-06 11:30:58 +00:00
sal_Int16 nDepth = - 1 ;
2000-09-18 16:07:07 +00:00
const SfxItemSet & rAttrs = pEditEngine - > GetParaAttribs ( ( USHORT ) nStartPara ) ;
if ( rAttrs . GetItemState ( EE_PARA_OUTLLEVEL ) = = SFX_ITEM_ON )
{
2008-06-06 11:30:58 +00:00
const SfxInt16Item & rLevel = ( const SfxInt16Item & ) rAttrs . Get ( EE_PARA_OUTLLEVEL ) ;
2000-09-18 16:07:07 +00:00
nDepth = rLevel . GetValue ( ) ;
}
2001-01-31 11:58:15 +00:00
if ( nDepth ! = GetDepth ( nStartPara ) )
ImplInitDepth ( ( USHORT ) nStartPara , nDepth , FALSE ) ;
2000-09-18 16:07:07 +00:00
}
nCount - - ;
nStartPara + + ;
pPara = pParaList - > GetParagraph ( nStartPara ) ;
}
pEditEngine - > SetUpdateMode ( bUpdate ) ;
DBG_ASSERT ( pParaList - > GetParagraphCount ( ) = = pEditEngine - > GetParagraphCount ( ) , " ImpTextPasted failed " ) ;
}
long Outliner : : IndentingPagesHdl ( OutlinerView * pView )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
if ( ! aIndentingPagesHdl . IsSet ( ) )
return 1 ;
return aIndentingPagesHdl . Call ( pView ) ;
}
BOOL Outliner : : ImpCanIndentSelectedPages ( OutlinerView * pCurView )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
// Die selektierten Seiten muessen vorher durch ImpCalcSelectedPages
// schon eingestellt sein
// Wenn der erste Absatz auf Ebene 0 liegt darf er auf keinen Fall
// eingerueckt werden, evtl folgen aber weitere auf Ebene 0.
2006-10-12 12:02:06 +00:00
if ( ( mnFirstSelPage = = 0 ) & & ( ImplGetOutlinerMode ( ) ! = OUTLINERMODE_TEXTOBJECT ) )
2000-09-18 16:07:07 +00:00
{
if ( nDepthChangedHdlPrevDepth = = 1 ) // ist die einzige Seite
return FALSE ;
else
pCurView - > ImpCalcSelectedPages ( FALSE ) ; // ohne die erste
}
return ( BOOL ) IndentingPagesHdl ( pCurView ) ;
}
BOOL Outliner : : ImpCanDeleteSelectedPages ( OutlinerView * pCurView )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
// Die selektierten Seiten muessen vorher durch ImpCalcSelectedPages
// schon eingestellt sein
return ( BOOL ) RemovingPagesHdl ( pCurView ) ;
}
Outliner : : Outliner ( SfxItemPool * pPool , USHORT nMode )
2008-06-06 11:30:58 +00:00
: nMinDepth ( - 1 )
2000-09-18 16:07:07 +00:00
{
DBG_CTOR ( Outliner , 0 ) ;
bStrippingPortions = FALSE ;
bPasting = FALSE ;
nFirstPage = 1 ;
bBlockInsCallback = FALSE ;
nMaxDepth = 9 ;
pParaList = new ParagraphList ;
pParaList - > SetVisibleStateChangedHdl ( LINK ( this , Outliner , ParaVisibleStateChangedHdl ) ) ;
Paragraph * pPara = new Paragraph ( 0 ) ;
pParaList - > Insert ( pPara , LIST_APPEND ) ;
bFirstParaIsEmpty = TRUE ;
pEditEngine = new OutlinerEditEng ( this , pPool ) ;
2001-08-17 09:54:10 +00:00
pEditEngine - > SetBeginMovingParagraphsHdl ( LINK ( this , Outliner , BeginMovingParagraphsHdl ) ) ;
pEditEngine - > SetEndMovingParagraphsHdl ( LINK ( this , Outliner , EndMovingParagraphsHdl ) ) ;
2001-11-14 10:01:23 +00:00
pEditEngine - > SetBeginPasteOrDropHdl ( LINK ( this , Outliner , BeginPasteOrDropHdl ) ) ;
pEditEngine - > SetEndPasteOrDropHdl ( LINK ( this , Outliner , EndPasteOrDropHdl ) ) ;
2000-09-18 16:07:07 +00:00
Init ( nMode ) ;
}
Outliner : : ~ Outliner ( )
{
DBG_DTOR ( Outliner , 0 ) ;
pParaList - > Clear ( TRUE ) ;
delete pParaList ;
delete pEditEngine ;
}
ULONG Outliner : : InsertView ( OutlinerView * pView , ULONG nIndex )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
aViewList . Insert ( pView , nIndex ) ;
pEditEngine - > InsertView ( pView - > pEditView , ( USHORT ) nIndex ) ;
return aViewList . GetPos ( pView ) ;
}
OutlinerView * Outliner : : RemoveView ( OutlinerView * pView )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
ULONG nPos = aViewList . GetPos ( pView ) ;
if ( nPos ! = LIST_ENTRY_NOTFOUND )
{
pView - > pEditView - > HideCursor ( ) ; // HACK wg. BugId 10006
pEditEngine - > RemoveView ( pView - > pEditView ) ;
aViewList . Remove ( nPos ) ;
}
return NULL ; // MT: return ueberfluessig
}
OutlinerView * Outliner : : RemoveView ( ULONG nIndex )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
EditView * pEditView = pEditEngine - > GetView ( ( USHORT ) nIndex ) ;
pEditView - > HideCursor ( ) ; // HACK wg. BugId 10006
pEditEngine - > RemoveView ( ( USHORT ) nIndex ) ;
aViewList . Remove ( nIndex ) ;
return NULL ; // MT: return ueberfluessig
}
OutlinerView * Outliner : : GetView ( ULONG nIndex ) const
{
DBG_CHKTHIS ( Outliner , 0 ) ;
return aViewList . GetObject ( nIndex ) ;
}
ULONG Outliner : : GetViewCount ( ) const
{
DBG_CHKTHIS ( Outliner , 0 ) ;
return aViewList . Count ( ) ;
}
void Outliner : : ParagraphInsertedHdl ( )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2006-01-10 13:48:19 +00:00
if ( ! IsInUndo ( ) )
aParaInsertedHdl . Call ( this ) ;
2000-09-18 16:07:07 +00:00
}
void Outliner : : ParagraphRemovingHdl ( )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2006-01-10 13:48:19 +00:00
if ( ! IsInUndo ( ) )
aParaRemovingHdl . Call ( this ) ;
2000-09-18 16:07:07 +00:00
}
void Outliner : : DepthChangedHdl ( )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2006-01-10 13:48:19 +00:00
if ( ! IsInUndo ( ) )
aDepthChangedHdl . Call ( this ) ;
2000-09-18 16:07:07 +00:00
}
ULONG Outliner : : GetAbsPos ( Paragraph * pPara )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2008-11-10 15:06:12 +00:00
DBG_ASSERT ( pPara , " GetAbsPos:No Para " ) ;
2000-09-18 16:07:07 +00:00
return pParaList - > GetAbsPos ( pPara ) ;
}
ULONG Outliner : : GetParagraphCount ( ) const
{
DBG_CHKTHIS ( Outliner , 0 ) ;
return pParaList - > GetParagraphCount ( ) ;
}
Paragraph * Outliner : : GetParagraph ( ULONG nAbsPos ) const
{
DBG_CHKTHIS ( Outliner , 0 ) ;
return pParaList - > GetParagraph ( nAbsPos ) ;
}
BOOL Outliner : : HasChilds ( Paragraph * pParagraph ) const
{
DBG_CHKTHIS ( Outliner , 0 ) ;
return pParaList - > HasChilds ( pParagraph ) ;
}
BOOL Outliner : : ImplHasBullet ( USHORT nPara ) const
{
2008-06-06 11:30:58 +00:00
return GetNumberFormat ( nPara ) ! = 0 ;
2000-09-18 16:07:07 +00:00
}
2008-06-06 11:30:58 +00:00
const SvxNumberFormat * Outliner : : GetNumberFormat ( USHORT nPara ) const
2001-08-01 09:34:48 +00:00
{
2001-08-23 13:39:24 +00:00
const SvxNumberFormat * pFmt = NULL ;
2008-06-06 11:30:58 +00:00
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-07-25 06:21:06 +00:00
if ( pPara = = NULL )
return NULL ;
2008-07-22 06:42:36 +00:00
sal_Int16 nDepth = pPara ? pPara - > GetDepth ( ) : - 1 ;
2001-08-01 09:34:48 +00:00
2008-06-06 11:30:58 +00:00
if ( nDepth > = 0 )
2001-08-23 13:39:24 +00:00
{
const SvxNumBulletItem & rNumBullet = ( const SvxNumBulletItem & ) pEditEngine - > GetParaAttrib ( nPara , EE_PARA_NUMBULLET ) ;
if ( rNumBullet . GetNumRule ( ) - > GetLevelCount ( ) > nDepth )
pFmt = rNumBullet . GetNumRule ( ) - > Get ( nDepth ) ;
2001-08-01 09:34:48 +00:00
}
2001-08-23 13:39:24 +00:00
return pFmt ;
2001-08-01 09:34:48 +00:00
}
2000-09-18 16:07:07 +00:00
Size Outliner : : ImplGetBulletSize ( USHORT nPara )
{
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-07-22 06:42:36 +00:00
if ( ! pPara )
return Size ( ) ;
2000-09-18 16:07:07 +00:00
if ( pPara - > aBulSize . Width ( ) = = - 1 )
{
2008-06-06 11:30:58 +00:00
const SvxNumberFormat * pFmt = GetNumberFormat ( nPara ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( pFmt , " ImplGetBulletSize - no Bullet! " ) ;
2001-04-11 12:12:05 +00:00
if ( pFmt - > GetNumberingType ( ) = = SVX_NUM_NUMBER_NONE )
{
pPara - > aBulSize = Size ( 0 , 0 ) ;
}
else if ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_BITMAP )
2000-09-18 16:07:07 +00:00
{
String aBulletText = ImplGetBulletText ( nPara ) ;
OutputDevice * pRefDev = pEditEngine - > GetRefDevice ( ) ;
Font aBulletFont ( ImpCalcBulletFont ( nPara ) ) ;
Font aRefFont ( pRefDev - > GetFont ( ) ) ;
pRefDev - > SetFont ( aBulletFont ) ;
pPara - > aBulSize . Width ( ) = pRefDev - > GetTextWidth ( aBulletText ) ;
pPara - > aBulSize . Height ( ) = pRefDev - > GetTextHeight ( ) ;
pRefDev - > SetFont ( aRefFont ) ;
}
else
{
pPara - > aBulSize = OutputDevice : : LogicToLogic ( pFmt - > GetGraphicSize ( ) , MAP_100TH_MM , pEditEngine - > GetRefDevice ( ) - > GetMapMode ( ) ) ;
}
}
return pPara - > aBulSize ;
}
void Outliner : : ImplCheckParagraphs ( USHORT nStart , USHORT nEnd )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
for ( USHORT n = nStart ; n < = nEnd ; n + + )
{
Paragraph * pPara = pParaList - > GetParagraph ( n ) ;
2008-07-22 06:42:36 +00:00
if ( pPara )
{
pPara - > Invalidate ( ) ;
ImplCalcBulletText ( n , FALSE , FALSE ) ;
}
2000-09-18 16:07:07 +00:00
}
}
void Outliner : : SetRefDevice ( OutputDevice * pRefDev )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
pEditEngine - > SetRefDevice ( pRefDev ) ;
for ( USHORT n = ( USHORT ) pParaList - > GetParagraphCount ( ) ; n ; )
{
Paragraph * pPara = pParaList - > GetParagraph ( - - n ) ;
pPara - > Invalidate ( ) ;
}
}
void Outliner : : ParaAttribsChanged ( USHORT nPara )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
// Der Outliner hat kein eigenes Undo, wenn Absaetz getrennt/verschmolzen werden.
// Beim ParagraphInserted ist das Attribut EE_PARA_OUTLLEVEL
// ggf. noch nicht eingestellt, dies wird aber benoetigt um die Tiefe
// des Absatzes zu bestimmen.
if ( pEditEngine - > IsInUndo ( ) )
{
if ( pParaList - > GetParagraphCount ( ) = = pEditEngine - > GetParagraphCount ( ) )
{
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-06-06 11:30:58 +00:00
const SfxInt16Item & rLevel = ( const SfxInt16Item & ) pEditEngine - > GetParaAttrib ( nPara , EE_PARA_OUTLLEVEL ) ;
2008-07-22 06:42:36 +00:00
if ( pPara & & pPara - > GetDepth ( ) ! = rLevel . GetValue ( ) )
2000-09-18 16:07:07 +00:00
{
pPara - > SetDepth ( rLevel . GetValue ( ) ) ;
ImplCalcBulletText ( nPara , TRUE , TRUE ) ;
}
}
}
}
void Outliner : : StyleSheetChanged ( SfxStyleSheet * pStyle )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
// Die EditEngine ruft StyleSheetChanged auch fuer abgeleitete Styles.
// MT: Hier wurde frueher alle Absaetze durch ein ImpRecalcParaAttribs
// gejagt, die die besagte Vorlage haben, warum?
// => Eigentlich kann sich nur die Bullet-Repraesentation aendern...
USHORT nParas = ( USHORT ) pParaList - > GetParagraphCount ( ) ;
for ( USHORT nPara = 0 ; nPara < nParas ; nPara + + )
{
if ( pEditEngine - > GetStyleSheet ( nPara ) = = pStyle )
{
ImplCheckNumBulletItem ( nPara ) ;
ImplCalcBulletText ( nPara , FALSE , FALSE ) ;
2003-03-27 14:06:05 +00:00
// #97333# EditEngine formats changed paragraphs before calling this method,
// so they are not reformatted now and use wrong bullet indent
pEditEngine - > QuickMarkInvalid ( ESelection ( nPara , 0 , nPara , 0 ) ) ;
2000-09-18 16:07:07 +00:00
}
}
}
2002-07-24 12:18:20 +00:00
Rectangle Outliner : : ImpCalcBulletArea ( USHORT nPara , BOOL bAdjust , BOOL bReturnPaperPos )
2000-09-18 16:07:07 +00:00
{
// Bullet-Bereich innerhalb des Absatzes...
Rectangle aBulletArea ;
2008-06-06 11:30:58 +00:00
const SvxNumberFormat * pFmt = GetNumberFormat ( nPara ) ;
2000-09-18 16:07:07 +00:00
if ( pFmt )
{
Point aTopLeft ;
Size aBulletSize ( ImplGetBulletSize ( nPara ) ) ;
2001-08-21 10:04:46 +00:00
BOOL bOutlineMode = ( pEditEngine - > GetControlWord ( ) & EE_CNTRL_OUTLINER ) ! = 0 ;
2008-06-06 11:30:58 +00:00
// the ODF attribut text:space-before which holds the spacing to add to the left of the label
const short nSpaceBefore = pFmt - > GetAbsLSpace ( ) + pFmt - > GetFirstLineOffset ( ) ;
2000-09-18 16:07:07 +00:00
2008-06-06 11:30:58 +00:00
const SvxLRSpaceItem & rLR = ( const SvxLRSpaceItem & ) pEditEngine - > GetParaAttrib ( nPara , bOutlineMode ? EE_PARA_OUTLLRSPACE : EE_PARA_LRSPACE ) ;
aTopLeft . X ( ) = rLR . GetTxtLeft ( ) + rLR . GetTxtFirstLineOfst ( ) + nSpaceBefore ;
2000-09-18 16:07:07 +00:00
long nBulletWidth = Max ( ( long ) - rLR . GetTxtFirstLineOfst ( ) , ( long ) ( ( - pFmt - > GetFirstLineOffset ( ) ) + pFmt - > GetCharTextDistance ( ) ) ) ;
if ( nBulletWidth < aBulletSize . Width ( ) ) // Bullet macht sich Platz
nBulletWidth = aBulletSize . Width ( ) ;
2001-08-21 10:04:46 +00:00
if ( bAdjust & & ! bOutlineMode )
2000-09-18 16:07:07 +00:00
{
// Bei zentriert/rechtsbuendig anpassen
const SvxAdjustItem & rItem = ( const SvxAdjustItem & ) pEditEngine - > GetParaAttrib ( nPara , EE_PARA_JUST ) ;
2003-06-12 07:24:00 +00:00
if ( ( ! pEditEngine - > IsRightToLeft ( nPara ) & & ( rItem . GetAdjust ( ) ! = SVX_ADJUST_LEFT ) ) | |
( pEditEngine - > IsRightToLeft ( nPara ) & & ( rItem . GetAdjust ( ) ! = SVX_ADJUST_RIGHT ) ) )
{
2000-09-18 16:07:07 +00:00
aTopLeft . X ( ) = pEditEngine - > GetFirstLineStartX ( nPara ) - nBulletWidth ;
2003-06-12 07:24:00 +00:00
}
2000-09-18 16:07:07 +00:00
}
// Vertikal:
ParagraphInfos aInfos = pEditEngine - > GetParagraphInfos ( nPara ) ;
if ( aInfos . bValid )
{
2001-08-15 14:52:50 +00:00
aTopLeft . Y ( ) = /* aInfos.nFirstLineOffset + */ // #91076# nFirstLineOffset is already added to the StartPos (PaintBullet) from the EditEngine
aInfos . nFirstLineHeight - aInfos . nFirstLineTextHeight
2000-10-11 10:58:13 +00:00
+ aInfos . nFirstLineTextHeight / 2
- aBulletSize . Height ( ) / 2 ;
2000-09-18 16:07:07 +00:00
// ggf. lieber auf der Baseline ausgeben...
2001-04-11 12:12:05 +00:00
if ( ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_NUMBER_NONE ) & & ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_BITMAP ) & & ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_CHAR_SPECIAL ) )
2000-09-18 16:07:07 +00:00
{
Font aBulletFont ( ImpCalcBulletFont ( nPara ) ) ;
if ( aBulletFont . GetCharSet ( ) ! = RTL_TEXTENCODING_SYMBOL )
{
OutputDevice * pRefDev = pEditEngine - > GetRefDevice ( ) ;
Font aOldFont = pRefDev - > GetFont ( ) ;
pRefDev - > SetFont ( aBulletFont ) ;
FontMetric aMetric ( pRefDev - > GetFontMetric ( ) ) ;
// Leading der ersten Zeile...
2001-08-15 14:52:50 +00:00
aTopLeft . Y ( ) = /* aInfos.nFirstLineOffset + */ aInfos . nFirstLineMaxAscent ;
2000-09-18 16:07:07 +00:00
aTopLeft . Y ( ) - = aMetric . GetAscent ( ) ;
pRefDev - > SetFont ( aOldFont ) ;
}
}
}
// Horizontal:
if ( pFmt - > GetNumAdjust ( ) = = SVX_ADJUST_RIGHT )
{
aTopLeft . X ( ) + = nBulletWidth - aBulletSize . Width ( ) ;
}
else if ( pFmt - > GetNumAdjust ( ) = = SVX_ADJUST_CENTER )
{
aTopLeft . X ( ) + = ( nBulletWidth - aBulletSize . Width ( ) ) / 2 ;
}
if ( aTopLeft . X ( ) < 0 ) // dann draengeln
aTopLeft . X ( ) = 0 ;
aBulletArea = Rectangle ( aTopLeft , aBulletSize ) ;
}
2002-07-24 12:18:20 +00:00
if ( bReturnPaperPos )
{
Size aBulletSize ( aBulletArea . GetSize ( ) ) ;
Point aBulletDocPos ( aBulletArea . TopLeft ( ) ) ;
aBulletDocPos . Y ( ) + = pEditEngine - > GetDocPosTopLeft ( nPara ) . Y ( ) ;
Point aBulletPos ( aBulletDocPos ) ;
if ( IsVertical ( ) )
{
aBulletPos . Y ( ) = aBulletDocPos . X ( ) ;
aBulletPos . X ( ) = GetPaperSize ( ) . Width ( ) - aBulletDocPos . Y ( ) ;
// Rotate:
aBulletPos . X ( ) - = aBulletSize . Height ( ) ;
Size aSz ( aBulletSize ) ;
aBulletSize . Width ( ) = aSz . Height ( ) ;
aBulletSize . Height ( ) = aSz . Width ( ) ;
}
else if ( pEditEngine - > IsRightToLeft ( nPara ) )
{
aBulletPos . X ( ) = GetPaperSize ( ) . Width ( ) - aBulletDocPos . X ( ) - aBulletSize . Width ( ) ;
}
aBulletArea = Rectangle ( aBulletPos , aBulletSize ) ;
}
2000-09-18 16:07:07 +00:00
return aBulletArea ;
}
void Outliner : : ExpandHdl ( )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
aExpandHdl . Call ( this ) ;
}
2002-02-28 17:51:59 +00:00
EBulletInfo Outliner : : GetBulletInfo ( USHORT nPara )
{
EBulletInfo aInfo ;
aInfo . nParagraph = nPara ;
aInfo . bVisible = ImplHasBullet ( nPara ) ;
2008-06-06 11:30:58 +00:00
const SvxNumberFormat * pFmt = GetNumberFormat ( nPara ) ;
2002-02-28 17:51:59 +00:00
aInfo . nType = pFmt ? pFmt - > GetNumberingType ( ) : 0 ;
2002-04-25 09:19:06 +00:00
if ( pFmt )
2002-02-28 17:51:59 +00:00
{
2002-04-25 09:19:06 +00:00
if ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_BITMAP )
{
aInfo . aText = ImplGetBulletText ( nPara ) ;
2002-04-26 09:31:41 +00:00
if ( pFmt - > GetBulletFont ( ) )
aInfo . aFont = * pFmt - > GetBulletFont ( ) ;
2002-04-25 09:19:06 +00:00
}
else if ( pFmt - > GetBrush ( ) - > GetGraphicObject ( ) )
{
aInfo . aGraphic = pFmt - > GetBrush ( ) - > GetGraphicObject ( ) - > GetGraphic ( ) ;
}
2002-02-28 17:51:59 +00:00
}
if ( aInfo . bVisible )
{
2002-07-24 12:18:20 +00:00
aInfo . aBounds = ImpCalcBulletArea ( nPara , TRUE , TRUE ) ;
2002-02-28 17:51:59 +00:00
}
return aInfo ;
}
2000-09-18 16:07:07 +00:00
XubString Outliner : : GetText ( Paragraph * pParagraph , ULONG nCount ) const
{
DBG_CHKTHIS ( Outliner , 0 ) ;
XubString aText ;
USHORT nStartPara = ( USHORT ) pParaList - > GetAbsPos ( pParagraph ) ;
for ( USHORT n = 0 ; n < nCount ; n + + )
{
aText + = pEditEngine - > GetText ( nStartPara + n ) ;
if ( ( n + 1 ) < ( USHORT ) nCount )
aText + = ' \n ' ;
}
return aText ;
}
void Outliner : : Remove ( Paragraph * pPara , ULONG nParaCount )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
ULONG nPos = pParaList - > GetAbsPos ( pPara ) ;
if ( ! nPos & & ( nParaCount > = pParaList - > GetParagraphCount ( ) ) )
{
Clear ( ) ;
}
else
{
for ( USHORT n = 0 ; n < ( USHORT ) nParaCount ; n + + )
pEditEngine - > RemoveParagraph ( ( USHORT ) nPos ) ;
}
}
void Outliner : : StripPortions ( )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
bStrippingPortions = TRUE ;
pEditEngine - > StripPortions ( ) ;
bStrippingPortions = FALSE ;
}
2002-08-01 13:48:55 +00:00
// #101498#
2008-08-19 22:02:20 +00:00
void Outliner : : DrawingText ( const Point & rStartPos , const XubString & rText , USHORT nTextStart , USHORT nTextLen , const sal_Int32 * pDXArray , const SvxFont & rFont ,
USHORT nPara , USHORT nIndex , BYTE nRightToLeft ,
const EEngineData : : WrongSpellVector * pWrongSpellVector ,
const SvxFieldData * pFieldData ,
bool bEndOfLine ,
bool bEndOfParagraph ,
bool bEndOfBullet ,
const : : com : : sun : : star : : lang : : Locale * pLocale ,
2009-01-05 17:49:45 +00:00
const Color & rOverlineColor ,
2008-08-19 22:02:20 +00:00
const Color & rTextLineColor )
2002-05-03 11:42:09 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2002-08-01 13:48:55 +00:00
2008-08-19 22:02:20 +00:00
if ( aDrawPortionHdl . IsSet ( ) )
{
// #101498#
DrawPortionInfo aInfo ( rStartPos , rText , nTextStart , nTextLen , rFont , nPara , nIndex , pDXArray , pWrongSpellVector ,
2009-01-05 17:49:45 +00:00
pFieldData , pLocale , rOverlineColor , rTextLineColor , nRightToLeft , bEndOfLine , bEndOfParagraph , bEndOfBullet ) ;
2002-08-01 13:48:55 +00:00
2008-08-19 22:02:20 +00:00
aDrawPortionHdl . Call ( & aInfo ) ;
}
2002-05-03 11:42:09 +00:00
}
2000-09-18 16:07:07 +00:00
long Outliner : : RemovingPagesHdl ( OutlinerView * pView )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
return aRemovingPagesHdl . IsSet ( ) ? aRemovingPagesHdl . Call ( pView ) : TRUE ;
}
2006-10-12 12:02:06 +00:00
BOOL Outliner : : ImpCanDeleteSelectedPages ( OutlinerView * pCurView , USHORT _nFirstPage , USHORT nPages )
2000-09-18 16:07:07 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
nDepthChangedHdlPrevDepth = nPages ;
2006-10-12 12:02:06 +00:00
mnFirstSelPage = _nFirstPage ;
pHdlParagraph = 0 ;
2000-09-18 16:07:07 +00:00
return ( BOOL ) RemovingPagesHdl ( pCurView ) ;
}
2008-06-06 11:30:58 +00:00
SfxItemSet Outliner : : GetParaAttribs ( USHORT nPara )
2000-09-18 16:07:07 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2008-06-06 11:30:58 +00:00
return pEditEngine - > GetParaAttribs ( nPara ) ;
2000-09-18 16:07:07 +00:00
}
IMPL_LINK ( Outliner , ParaVisibleStateChangedHdl , Paragraph * , pPara )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
ULONG nPara = pParaList - > GetAbsPos ( pPara ) ;
pEditEngine - > ShowParagraph ( ( USHORT ) nPara , pPara - > IsVisible ( ) ) ;
return 0 ;
}
2006-10-12 12:02:06 +00:00
IMPL_LINK ( Outliner , BeginMovingParagraphsHdl , MoveParagraphsInfo * , EMPTYARG )
2001-08-17 09:54:10 +00:00
{
DBG_CHKTHIS ( Outliner , 0 ) ;
2006-01-10 13:48:19 +00:00
if ( ! IsInUndo ( ) )
GetBeginMovingHdl ( ) . Call ( this ) ;
2001-08-17 09:54:10 +00:00
return 0 ;
}
2001-11-14 10:01:23 +00:00
IMPL_LINK ( Outliner , BeginPasteOrDropHdl , PasteOrDropInfos * , pInfos )
{
2008-06-06 11:30:58 +00:00
UndoActionStart ( EDITUNDO_DRAGANDDROP ) ;
maBeginPasteOrDropHdl . Call ( pInfos ) ;
2001-11-14 10:01:23 +00:00
return 0 ;
}
IMPL_LINK ( Outliner , EndPasteOrDropHdl , PasteOrDropInfos * , pInfos )
{
2008-06-06 11:30:58 +00:00
bPasting = FALSE ;
ImpTextPasted ( pInfos - > nStartPara , pInfos - > nEndPara - pInfos - > nStartPara + 1 ) ;
maEndPasteOrDropHdl . Call ( pInfos ) ;
UndoActionEnd ( EDITUNDO_DRAGANDDROP ) ;
2001-11-14 10:01:23 +00:00
return 0 ;
}
2001-08-17 09:54:10 +00:00
IMPL_LINK ( Outliner , EndMovingParagraphsHdl , MoveParagraphsInfo * , pInfos )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
pParaList - > MoveParagraphs ( pInfos - > nStartPara , pInfos - > nDestPara , pInfos - > nEndPara - pInfos - > nStartPara + 1 ) ;
USHORT nChangesStart = Min ( pInfos - > nStartPara , pInfos - > nDestPara ) ;
USHORT nParas = ( USHORT ) pParaList - > GetParagraphCount ( ) ;
for ( USHORT n = nChangesStart ; n < nParas ; n + + )
ImplCalcBulletText ( n , FALSE , FALSE ) ;
2006-01-10 13:48:19 +00:00
if ( ! IsInUndo ( ) )
aEndMovingHdl . Call ( this ) ;
2001-08-17 09:54:10 +00:00
return 0 ;
}
2008-06-06 11:30:58 +00:00
sal_uInt16 Outliner : : ImplGetNumbering ( USHORT nPara , const SvxNumberFormat * pParaFmt )
{
sal_uInt16 nNumber = pParaFmt - > GetStart ( ) - 1 ;
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
const sal_Int16 nParaDepth = pPara - > GetDepth ( ) ;
do
{
pPara = pParaList - > GetParagraph ( nPara ) ;
const sal_Int16 nDepth = pPara - > GetDepth ( ) ;
// ignore paragraphs that are below our paragraph
if ( nDepth > nParaDepth )
continue ;
// stop on paragraphs that are above our paragraph
if ( nDepth < nParaDepth )
break ;
const SvxNumberFormat * pFmt = GetNumberFormat ( nPara ) ;
if ( pFmt = = 0 | | ( * pFmt ! = * pParaFmt ) )
break ; // change in number format, stop here
const SfxBoolItem & rBulletState = ( const SfxBoolItem & ) pEditEngine - > GetParaAttrib ( nPara , EE_PARA_BULLETSTATE ) ;
if ( rBulletState . GetValue ( ) )
nNumber + = 1 ;
// same depth, same number format, check for restart
const sal_Int16 nNumberingStartValue = pPara - > GetNumberingStartValue ( ) ;
if ( ( nNumberingStartValue ! = - 1 ) | | pPara - > IsParaIsNumberingRestart ( ) )
{
if ( nNumberingStartValue ! = - 1 )
nNumber + = nNumberingStartValue - 1 ;
break ;
}
}
while ( nPara - - ) ;
return nNumber ;
}
2000-09-18 16:07:07 +00:00
void Outliner : : ImplCalcBulletText ( USHORT nPara , BOOL bRecalcLevel , BOOL bRecalcChilds )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
USHORT nRelPos = 0xFFFF ;
while ( pPara )
{
XubString aBulletText ;
2008-06-06 11:30:58 +00:00
const SvxNumberFormat * pFmt = GetNumberFormat ( nPara ) ;
2001-02-23 11:29:54 +00:00
if ( pFmt & & ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_BITMAP ) )
2000-09-18 16:07:07 +00:00
{
aBulletText + = pFmt - > GetPrefix ( ) ;
2001-03-29 14:12:06 +00:00
if ( pFmt - > GetNumberingType ( ) = = SVX_NUM_CHAR_SPECIAL )
{
aBulletText + = pFmt - > GetBulletChar ( ) ;
}
else if ( pFmt - > GetNumberingType ( ) ! = SVX_NUM_NUMBER_NONE )
2000-09-18 16:07:07 +00:00
{
2008-06-06 11:30:58 +00:00
aBulletText + = pFmt - > GetNumStr ( ImplGetNumbering ( nPara , pFmt ) ) ;
2000-09-18 16:07:07 +00:00
}
aBulletText + = pFmt - > GetSuffix ( ) ;
}
if ( aBulletText ! = pPara - > GetText ( ) )
pPara - > SetText ( aBulletText ) ;
pPara - > nFlags & = ( ~ PARAFLAG_SETBULLETTEXT ) ;
if ( bRecalcLevel )
{
if ( nRelPos ! = 0xFFFF )
nRelPos + + ;
2008-06-06 11:30:58 +00:00
sal_Int16 nDepth = pPara - > GetDepth ( ) ;
2000-09-18 16:07:07 +00:00
pPara = pParaList - > GetParagraph ( + + nPara ) ;
if ( ! bRecalcChilds )
{
while ( pPara & & ( pPara - > GetDepth ( ) > nDepth ) )
pPara = pParaList - > GetParagraph ( + + nPara ) ;
}
if ( pPara & & ( pPara - > GetDepth ( ) < nDepth ) )
pPara = NULL ;
}
else
{
pPara = NULL ;
}
}
}
void Outliner : : Clear ( )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
if ( ! bFirstParaIsEmpty )
{
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( TRUE ) ;
2000-09-18 16:07:07 +00:00
pEditEngine - > Clear ( ) ;
pParaList - > Clear ( TRUE ) ;
pParaList - > Insert ( new Paragraph ( nMinDepth ) , LIST_APPEND ) ;
bFirstParaIsEmpty = TRUE ;
2002-05-27 13:37:37 +00:00
ImplBlockInsertionCallbacks ( FALSE ) ;
2000-09-18 16:07:07 +00:00
}
else
{
2008-07-22 06:42:36 +00:00
Paragraph * pPara = pParaList - > GetParagraph ( 0 ) ;
if ( pPara )
pPara - > SetDepth ( nMinDepth ) ;
2000-09-18 16:07:07 +00:00
}
}
void Outliner : : SetFlatMode ( BOOL bFlat )
{
DBG_CHKTHIS ( Outliner , 0 ) ;
if ( bFlat ! = pEditEngine - > IsFlatMode ( ) )
{
for ( USHORT nPara = ( USHORT ) pParaList - > GetParagraphCount ( ) ; nPara ; )
pParaList - > GetParagraph ( - - nPara ) - > aBulSize . Width ( ) = - 1 ;
pEditEngine - > SetFlatMode ( bFlat ) ;
}
}
String Outliner : : ImplGetBulletText ( USHORT nPara )
{
2008-07-22 06:42:36 +00:00
String aRes ;
2000-09-18 16:07:07 +00:00
Paragraph * pPara = pParaList - > GetParagraph ( nPara ) ;
2008-07-22 06:42:36 +00:00
if ( pPara )
{
2000-09-18 16:07:07 +00:00
// MT: Optimierung mal wieder aktivieren...
// if( pPara->nFlags & PARAFLAG_SETBULLETTEXT )
ImplCalcBulletText ( nPara , FALSE , FALSE ) ;
2008-07-22 06:42:36 +00:00
aRes = pPara - > GetText ( ) ;
}
return aRes ;
2000-09-18 16:07:07 +00:00
}
2001-01-16 17:59:02 +00:00
// this is needed for StarOffice Api
void Outliner : : SetLevelDependendStyleSheet ( USHORT nPara )
{
2001-09-25 09:11:38 +00:00
SfxItemSet aOldAttrs ( pEditEngine - > GetParaAttribs ( nPara ) ) ;
2001-01-16 17:59:02 +00:00
ImplSetLevelDependendStyleSheet ( nPara ) ;
2001-09-25 09:11:38 +00:00
pEditEngine - > SetParaAttribs ( nPara , aOldAttrs ) ;
2001-02-23 11:29:54 +00:00
}
2002-05-27 13:37:37 +00:00
2002-05-28 14:14:18 +00:00
SV_IMPL_PTRARR ( NotifyList , EENotifyPtr ) ;
2002-05-27 13:37:37 +00:00
void Outliner : : ImplBlockInsertionCallbacks ( BOOL b )
{
2002-07-09 09:17:20 +00:00
if ( b )
2002-05-27 13:37:37 +00:00
{
2002-07-09 09:17:20 +00:00
bBlockInsCallback + + ;
}
else
{
DBG_ASSERT ( bBlockInsCallback , " ImplBlockInsertionCallbacks ?! " ) ;
bBlockInsCallback - - ;
2002-05-27 13:37:37 +00:00
if ( ! bBlockInsCallback )
{
// Call blocked notify events...
2002-06-10 15:47:28 +00:00
while ( pEditEngine - > aNotifyCache . Count ( ) )
2002-05-27 13:37:37 +00:00
{
2002-06-10 15:47:28 +00:00
EENotify * pNotify = pEditEngine - > aNotifyCache [ 0 ] ;
// Remove from list before calling, maybe we enter LeaveBlockNotifications while calling the handler...
pEditEngine - > aNotifyCache . Remove ( 0 ) ;
pEditEngine - > aOutlinerNotifyHdl . Call ( pNotify ) ;
delete pNotify ;
2002-05-27 13:37:37 +00:00
}
}
}
}
IMPL_LINK ( Outliner , EditEngineNotifyHdl , EENotify * , pNotify )
{
if ( ! bBlockInsCallback )
{
pEditEngine - > aOutlinerNotifyHdl . Call ( pNotify ) ;
}
else
{
EENotify * pNewNotify = new EENotify ( * pNotify ) ;
pEditEngine - > aNotifyCache . Insert ( pNewNotify , pEditEngine - > aNotifyCache . Count ( ) ) ;
}
return 0 ;
}
2006-02-01 11:58:29 +00:00
/** sets a link that is called at the beginning of a drag operation at an edit view */
void Outliner : : SetBeginDropHdl ( const Link & rLink )
{
pEditEngine - > SetBeginDropHdl ( rLink ) ;
}
Link Outliner : : GetBeginDropHdl ( ) const
{
return pEditEngine - > GetBeginDropHdl ( ) ;
}
/** sets a link that is called at the end of a drag operation at an edit view */
void Outliner : : SetEndDropHdl ( const Link & rLink )
{
pEditEngine - > SetEndDropHdl ( rLink ) ;
}
Link Outliner : : GetEndDropHdl ( ) const
{
return pEditEngine - > GetEndDropHdl ( ) ;
}
2008-06-06 11:30:58 +00:00
/** sets a link that is called before a drop or paste operation. */
void Outliner : : SetBeginPasteOrDropHdl ( const Link & rLink )
{
maBeginPasteOrDropHdl = rLink ;
}
/** sets a link that is called after a drop or paste operation. */
void Outliner : : SetEndPasteOrDropHdl ( const Link & rLink )
{
maEndPasteOrDropHdl = rLink ;
}
2008-07-30 13:17:16 +00:00
void Outliner : : SetParaFlag ( Paragraph * pPara , sal_uInt16 nFlag )
{
if ( pPara & & ! pPara - > HasFlag ( nFlag ) )
{
if ( IsUndoEnabled ( ) & & ! IsInUndo ( ) )
InsertUndo ( new OutlinerUndoChangeParaFlags ( this , ( sal_uInt16 ) GetAbsPos ( pPara ) , pPara - > nFlags , pPara - > nFlags | nFlag ) ) ;
pPara - > SetFlag ( nFlag ) ;
}
}
void Outliner : : RemoveParaFlag ( Paragraph * pPara , sal_uInt16 nFlag )
{
if ( pPara & & pPara - > HasFlag ( nFlag ) )
{
if ( IsUndoEnabled ( ) & & ! IsInUndo ( ) )
InsertUndo ( new OutlinerUndoChangeParaFlags ( this , ( sal_uInt16 ) GetAbsPos ( pPara ) , pPara - > nFlags , pPara - > nFlags & ~ nFlag ) ) ;
pPara - > RemoveFlag ( nFlag ) ;
}
}
bool Outliner : : HasParaFlag ( const Paragraph * pPara , sal_uInt16 nFlag ) const
{
return pPara & & pPara - > HasFlag ( nFlag ) ;
}
2002-08-01 13:48:55 +00:00
sal_Bool DrawPortionInfo : : IsRTL ( ) const
{
if ( 0xFF = = mnBiDiLevel )
{
// Use Bidi functions from icu 2.0 to calculate if this portion
// is RTL or not.
UErrorCode nError ( U_ZERO_ERROR ) ;
2008-08-19 22:02:20 +00:00
UBiDi * pBidi = ubidi_openSized ( mrText . Len ( ) , 0 , & nError ) ;
2002-08-01 13:48:55 +00:00
nError = U_ZERO_ERROR ;
// I do not have this info here. Is it necessary? I'll have to ask MT.
const BYTE nDefaultDir = UBIDI_LTR ; //IsRightToLeft( nPara ) ? UBIDI_RTL : UBIDI_LTR;
2009-01-20 16:36:21 +00:00
ubidi_setPara ( pBidi , reinterpret_cast < const UChar * > ( mrText . GetBuffer ( ) ) , mrText . Len ( ) , nDefaultDir , NULL , & nError ) ; // UChar != sal_Unicode in MinGW
2002-08-01 13:48:55 +00:00
nError = U_ZERO_ERROR ;
2006-10-12 12:02:06 +00:00
// sal_Int32 nCount(ubidi_countRuns(pBidi, &nError));
2002-08-01 13:48:55 +00:00
2003-11-07 14:07:28 +00:00
int32_t nStart ( 0 ) ;
int32_t nEnd ;
2002-08-01 13:48:55 +00:00
UBiDiLevel nCurrDir ;
ubidi_getLogicalRun ( pBidi , nStart , & nEnd , & nCurrDir ) ;
ubidi_close ( pBidi ) ;
// remember on-demand calculated state
( ( DrawPortionInfo * ) this ) - > mnBiDiLevel = nCurrDir ;
}
return ( 1 = = ( mnBiDiLevel % 2 ) ) ;
}
2002-05-27 13:37:37 +00:00
2008-08-19 22:02:20 +00:00
// eof