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