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