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