Get the style color and number just once
[LibreOffice.git] / editeng / source / outliner / outlin2.cxx
blob18bf47edfe3ffa003c913cedecb8ddacff1d816e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <editeng/editeng.hxx>
22 #include <editeng/editview.hxx>
23 #include <editeng/editdata.hxx>
24 #include <editeng/editund2.hxx>
26 #include <svl/style.hxx>
27 #include <vcl/mapmod.hxx>
29 #include <editeng/forbiddencharacterstable.hxx>
31 #include <editeng/outliner.hxx>
32 #include "paralist.hxx"
33 #include <outleeng.hxx>
34 #include <editeng/editstat.hxx>
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::linguistic2;
41 // ====================== Simple pass-through =======================
44 bool Outliner::SetUpdateLayout( bool bUpdate )
46 return pEditEngine->SetUpdateLayout( bUpdate );
50 bool Outliner::IsUpdateLayout() const
52 return pEditEngine->IsUpdateLayout();
55 const SfxItemSet& Outliner::GetEmptyItemSet() const
57 return pEditEngine->GetEmptyItemSet();
60 void Outliner::EnableUndo( bool bEnable )
62 pEditEngine->EnableUndo( bEnable );
65 bool Outliner::IsUndoEnabled() const
67 return pEditEngine->IsUndoEnabled();
70 MapMode const & Outliner::GetRefMapMode() const
72 return pEditEngine->GetRefMapMode();
75 void Outliner::SetRefMapMode( const MapMode& rMMode )
77 pEditEngine->SetRefMapMode( rMMode );
80 void Outliner::SetBackgroundColor( const Color& rColor )
82 pEditEngine->SetBackgroundColor( rColor );
85 Color const & Outliner::GetBackgroundColor() const
87 return pEditEngine->GetBackgroundColor();
91 void Outliner::ClearModifyFlag()
93 pEditEngine->ClearModifyFlag();
96 bool Outliner::IsModified() const
98 return pEditEngine->IsModified();
101 sal_uInt32 Outliner::GetTextHeight() const
103 return pEditEngine->GetTextHeight();
106 void Outliner::SetModifyHdl( const Link<LinkParamNone*,void>& rLink )
108 pEditEngine->SetModifyHdl( rLink );
111 void Outliner::SetNotifyHdl( const Link<EENotify&,void>& rLink )
113 pEditEngine->aOutlinerNotifyHdl = rLink;
115 if ( rLink.IsSet() )
116 pEditEngine->SetNotifyHdl( LINK( this, Outliner, EditEngineNotifyHdl ) );
117 else
118 pEditEngine->SetNotifyHdl( Link<EENotify&,void>() );
121 void Outliner::SetStatusEventHdl( const Link<EditStatus&, void>& rLink )
123 pEditEngine->SetStatusEventHdl( rLink );
126 Link<EditStatus&, void> const & Outliner::GetStatusEventHdl() const
128 return pEditEngine->GetStatusEventHdl();
131 void Outliner::SetDefTab( sal_uInt16 nTab )
133 pEditEngine->SetDefTab( nTab );
136 bool Outliner::IsFlatMode() const
138 return pEditEngine->IsFlatMode();
141 bool Outliner::UpdateFields()
143 return pEditEngine->UpdateFields();
146 void Outliner::RemoveFields( const std::function<bool ( const SvxFieldData* )>& isFieldData )
148 pEditEngine->RemoveFields( isFieldData );
151 void Outliner::SetWordDelimiters( const OUString& rDelimiters )
153 pEditEngine->SetWordDelimiters( rDelimiters );
156 OUString const & Outliner::GetWordDelimiters() const
158 return pEditEngine->GetWordDelimiters();
161 OUString Outliner::GetWord(const EPaM& rPos)
163 return pEditEngine->GetWord(rPos);
166 void Outliner::Draw( OutputDevice& rOutDev, const tools::Rectangle& rOutRect )
168 pEditEngine->Draw( rOutDev, rOutRect );
171 void Outliner::Draw( OutputDevice& rOutDev, const Point& rStartPos )
173 pEditEngine->Draw( rOutDev, rStartPos );
176 void Outliner::SetPaperSize( const Size& rSize )
178 pEditEngine->SetPaperSize( rSize );
181 const Size& Outliner::GetPaperSize() const
183 return pEditEngine->GetPaperSize();
186 void Outliner::SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon )
188 pEditEngine->SetPolygon( rPolyPolygon );
191 void Outliner::SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DPolyPolygon* pLinePolyPolygon)
193 pEditEngine->SetPolygon( rPolyPolygon, pLinePolyPolygon);
196 void Outliner::ClearPolygon()
198 pEditEngine->ClearPolygon();
201 const Size& Outliner::GetMinAutoPaperSize() const
203 return pEditEngine->GetMinAutoPaperSize();
206 void Outliner::SetMinAutoPaperSize( const Size& rSz )
208 pEditEngine->SetMinAutoPaperSize( rSz );
211 const Size& Outliner::GetMaxAutoPaperSize() const
213 return pEditEngine->GetMaxAutoPaperSize();
216 void Outliner::SetMaxAutoPaperSize( const Size& rSz )
218 pEditEngine->SetMaxAutoPaperSize( rSz );
221 void Outliner::SetMinColumnWrapHeight(tools::Long nVal)
223 pEditEngine->SetMinColumnWrapHeight(nVal);
226 bool Outliner::IsExpanded( Paragraph const * pPara ) const
228 return pParaList->HasVisibleChildren( pPara );
231 Paragraph* Outliner::GetParent( Paragraph const * pParagraph ) const
233 return pParaList->GetParent( pParagraph );
236 sal_Int32 Outliner::GetChildCount( Paragraph const * pParent ) const
238 return pParaList->GetChildCount( pParent );
241 Size Outliner::CalcTextSize()
243 return Size(pEditEngine->CalcTextWidth(),pEditEngine->GetTextHeight());
246 void Outliner::SetStyleSheetPool( SfxStyleSheetPool* pSPool )
248 pEditEngine->SetStyleSheetPool( pSPool );
251 SfxStyleSheetPool* Outliner::GetStyleSheetPool()
253 return pEditEngine->GetStyleSheetPool();
256 SfxStyleSheet* Outliner::GetStyleSheet( sal_Int32 nPara )
258 return pEditEngine->GetStyleSheet( nPara );
261 bool Outliner::IsInSelectionMode() const
263 return pEditEngine->IsInSelectionMode();
266 void Outliner::SetControlWord( EEControlBits nWord )
268 pEditEngine->SetControlWord( nWord );
271 EEControlBits Outliner::GetControlWord() const
273 return pEditEngine->GetControlWord();
276 void Outliner::SetAsianCompressionMode( CharCompressType n )
278 pEditEngine->SetAsianCompressionMode( n );
281 void Outliner::SetKernAsianPunctuation( bool b )
283 pEditEngine->SetKernAsianPunctuation( b );
286 void Outliner::SetAddExtLeading( bool bExtLeading )
288 pEditEngine->SetAddExtLeading( bExtLeading );
291 void Outliner::UndoActionStart( sal_uInt16 nId )
293 pEditEngine->UndoActionStart( nId );
296 void Outliner::UndoActionEnd()
298 pEditEngine->UndoActionEnd();
301 void Outliner::InsertUndo( std::unique_ptr<EditUndo> pUndo )
303 pEditEngine->GetUndoManager().AddUndoAction( std::move(pUndo) );
306 bool Outliner::IsInUndo() const
308 return pEditEngine->IsInUndo();
311 sal_Int32 Outliner::GetLineCount( sal_Int32 nParagraph ) const
313 return pEditEngine->GetLineCount( nParagraph );
316 sal_Int32 Outliner::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const
318 return pEditEngine->GetLineLen( nParagraph, nLine );
321 sal_uInt32 Outliner::GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine )
323 return pEditEngine->GetLineHeight( nParagraph, nLine );
326 void Outliner::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich )
328 pEditEngine->RemoveCharAttribs( nPara, nWhich );
331 EESpellState Outliner::HasSpellErrors()
333 return pEditEngine->HasSpellErrors();
336 bool Outliner::HasConvertibleTextPortion( LanguageType nLang )
338 return pEditEngine->HasConvertibleTextPortion( nLang );
341 bool Outliner::ConvertNextDocument()
343 return false;
346 void Outliner::SetDefaultLanguage( LanguageType eLang )
348 pEditEngine->SetDefaultLanguage( eLang );
351 void Outliner::CompleteOnlineSpelling()
353 pEditEngine->CompleteOnlineSpelling();
356 bool Outliner::HasText( const SvxSearchItem& rSearchItem )
358 return pEditEngine->HasText( rSearchItem );
361 void Outliner::SetEditTextObjectPool( SfxItemPool* pPool )
363 pEditEngine->SetEditTextObjectPool( pPool );
366 SfxItemPool* Outliner::GetEditTextObjectPool() const
368 return pEditEngine->GetEditTextObjectPool();
371 bool Outliner::SpellNextDocument()
373 return false;
377 void Outliner::SetSpeller( Reference< XSpellChecker1 > const &xSpeller )
379 pEditEngine->SetSpeller( xSpeller );
382 Reference< XSpellChecker1 > const & Outliner::GetSpeller()
384 return pEditEngine->GetSpeller();
387 void Outliner::SetForbiddenCharsTable(const std::shared_ptr<SvxForbiddenCharactersTable>& xForbiddenChars)
389 EditEngine::SetForbiddenCharsTable(xForbiddenChars);
392 void Outliner::SetHyphenator( Reference< XHyphenator > const & xHyph )
394 pEditEngine->SetHyphenator( xHyph );
397 OutputDevice* Outliner::GetRefDevice() const
399 return pEditEngine->GetRefDevice();
402 tools::Rectangle Outliner::GetParaBounds( sal_Int32 nParagraph ) const
404 return pEditEngine->GetParaBounds(nParagraph );
407 Point Outliner::GetDocPos( const Point& rPaperPos ) const
409 return pEditEngine->GetDocPos( rPaperPos );
412 bool Outliner::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder )
414 return IsTextPos( rPaperPos, nBorder, nullptr );
417 bool Outliner::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder, bool* pbBullet )
419 if ( pbBullet)
420 *pbBullet = false;
421 bool bTextPos = pEditEngine->IsTextPos( rPaperPos, nBorder );
422 if ( !bTextPos )
424 Point aDocPos = GetDocPos( rPaperPos );
425 sal_Int32 nPara = pEditEngine->FindParagraph( aDocPos.Y() );
426 if ((nPara != EE_PARA_MAX) && ImplHasNumberFormat(nPara))
428 tools::Rectangle aBulArea = ImpCalcBulletArea( nPara, true, true );
429 if ( aBulArea.Contains( rPaperPos ) )
431 bTextPos = true;
432 if ( pbBullet)
433 *pbBullet = true;
438 return bTextPos;
441 void Outliner::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel )
443 pEditEngine->QuickSetAttribs( rSet, rSel );
446 void Outliner::QuickInsertText( const OUString& rText, const ESelection& rSel )
448 bFirstParaIsEmpty = false;
449 pEditEngine->QuickInsertText( rText, rSel );
452 void Outliner::QuickDelete( const ESelection& rSel )
454 bFirstParaIsEmpty = false;
455 pEditEngine->QuickDelete( rSel );
458 void Outliner::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel )
460 bFirstParaIsEmpty = false;
461 pEditEngine->QuickInsertField( rFld, rSel );
464 void Outliner::QuickInsertLineBreak( const ESelection& rSel )
466 bFirstParaIsEmpty = false;
467 pEditEngine->QuickInsertLineBreak( rSel );
470 void Outliner::QuickFormatDoc()
472 pEditEngine->QuickFormatDoc();
475 const ScalingParameters & Outliner::getScalingParameters() const
477 return pEditEngine->getScalingParameters();
480 void Outliner::setScalingParameters(ScalingParameters const& rScalingParameters)
482 // reset bullet size
483 sal_Int32 nParagraphs = pParaList->GetParagraphCount();
484 for ( sal_Int32 nPara = 0; nPara < nParagraphs; nPara++ )
486 Paragraph* pPara = pParaList->GetParagraph( nPara );
487 if ( pPara )
488 pPara->aBulSize.setWidth( -1 );
491 pEditEngine->setScalingParameters(rScalingParameters);
494 void Outliner::setRoundFontSizeToPt(bool bRound) const
496 pEditEngine->setRoundFontSizeToPt(bRound);
499 void Outliner::EraseVirtualDevice()
501 pEditEngine->EraseVirtualDevice();
504 bool Outliner::ShouldCreateBigTextObject() const
506 return pEditEngine->ShouldCreateBigTextObject();
509 const EditEngine& Outliner::GetEditEngine() const
511 return *pEditEngine;
514 void Outliner::SetVertical(bool bVertical)
516 pEditEngine->SetVertical(bVertical);
519 void Outliner::SetRotation(TextRotation nRotation)
521 pEditEngine->SetRotation(nRotation);
524 bool Outliner::IsVertical() const
526 return pEditEngine->IsEffectivelyVertical();
529 bool Outliner::IsTopToBottom() const
531 return pEditEngine->IsTopToBottom();
534 void Outliner::SetTextColumns(sal_Int16 nColumns, sal_Int32 nSpacing)
536 pEditEngine->SetTextColumns(nColumns, nSpacing);
539 void Outliner::SetFixedCellHeight( bool bUseFixedCellHeight )
541 pEditEngine->SetFixedCellHeight( bUseFixedCellHeight );
544 void Outliner::SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir )
546 pEditEngine->SetDefaultHorizontalTextDirection( eHTextDir );
549 EEHorizontalTextDirection Outliner::GetDefaultHorizontalTextDirection() const
551 return pEditEngine->GetDefaultHorizontalTextDirection();
554 LanguageType Outliner::GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const
556 return pEditEngine->GetLanguage( nPara, nPos ).nLang;
559 void Outliner::RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich )
561 pEditEngine->RemoveAttribs( rSelection, bRemoveParaAttribs, nWhich );
564 void Outliner::EnableAutoColor( bool b )
566 pEditEngine->EnableAutoColor( b );
569 void Outliner::ForceAutoColor( bool b )
571 pEditEngine->ForceAutoColor( b );
574 bool Outliner::IsForceAutoColor() const
576 return pEditEngine->IsForceAutoColor();
579 bool Outliner::SpellSentence(EditView const & rEditView, svx::SpellPortions& rToFill )
581 return pEditEngine->SpellSentence(rEditView, rToFill );
584 void Outliner::PutSpellingToSentenceStart( EditView const & rEditView )
586 pEditEngine->PutSpellingToSentenceStart( rEditView );
589 void Outliner::ApplyChangedSentence(EditView const & rEditView, const svx::SpellPortions& rNewPortions, bool bRecheck )
591 pEditEngine->ApplyChangedSentence( rEditView, rNewPortions, bRecheck );
594 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */