1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <svl/intitem.hxx>
31 #include <editeng/editeng.hxx>
32 #include <editeng/editview.hxx>
33 #include <editeng/editdata.hxx>
34 #include <editeng/eerdll.hxx>
35 #include <editeng/lrspitem.hxx>
36 #include <editeng/fhgtitem.hxx>
37 #include <svl/style.hxx>
38 #include <vcl/mapmod.hxx>
40 #include <editeng/forbiddencharacterstable.hxx>
44 #include <editeng/outliner.hxx>
45 #include <paralist.hxx>
46 #include <editeng/outlobj.hxx>
47 #include <outleeng.hxx>
48 #include <outlundo.hxx>
49 #include <editeng/eeitem.hxx>
50 #include <editeng/editstat.hxx>
54 using namespace ::com::sun::star::uno
;
55 using namespace ::com::sun::star::linguistic2
;
57 // ======================================================================
58 // ====================== Simple pass-through =======================
59 // ======================================================================
61 void Outliner::SetUpdateMode( sal_Bool bUpdate
)
63 DBG_CHKTHIS(Outliner
,0);
64 pEditEngine
->SetUpdateMode( bUpdate
);
68 sal_Bool
Outliner::GetUpdateMode() const
70 DBG_CHKTHIS(Outliner
,0);
71 return pEditEngine
->GetUpdateMode();
74 const SfxItemSet
& Outliner::GetEmptyItemSet() const
76 DBG_CHKTHIS(Outliner
,0);
77 return pEditEngine
->GetEmptyItemSet();
80 void Outliner::EnableUndo( sal_Bool bEnable
)
82 DBG_CHKTHIS(Outliner
,0);
83 pEditEngine
->EnableUndo( bEnable
);
86 sal_Bool
Outliner::IsUndoEnabled() const
88 DBG_CHKTHIS(Outliner
,0);
89 return pEditEngine
->IsUndoEnabled();
92 MapMode
Outliner::GetRefMapMode() const
94 DBG_CHKTHIS(Outliner
,0);
95 return pEditEngine
->GetRefMapMode();
98 void Outliner::SetRefMapMode( const MapMode
& rMMode
)
100 DBG_CHKTHIS(Outliner
,0);
101 pEditEngine
->SetRefMapMode( rMMode
);
104 void Outliner::SetBackgroundColor( const Color
& rColor
)
106 DBG_CHKTHIS(Outliner
,0);
107 pEditEngine
->SetBackgroundColor( rColor
);
110 Color
Outliner::GetBackgroundColor() const
112 DBG_CHKTHIS(Outliner
,0);
113 return pEditEngine
->GetBackgroundColor();
117 void Outliner::ClearModifyFlag()
119 DBG_CHKTHIS(Outliner
,0);
120 pEditEngine
->ClearModifyFlag();
123 sal_Bool
Outliner::IsModified() const
125 DBG_CHKTHIS(Outliner
,0);
126 return pEditEngine
->IsModified();
129 sal_uLong
Outliner::GetTextHeight() const
131 DBG_CHKTHIS(Outliner
,0);
132 return pEditEngine
->GetTextHeight();
135 void Outliner::SetModifyHdl( const Link
& rLink
)
137 DBG_CHKTHIS(Outliner
,0);
138 pEditEngine
->SetModifyHdl( rLink
);
141 Link
Outliner::GetModifyHdl() const
143 DBG_CHKTHIS(Outliner
,0);
144 return pEditEngine
->GetModifyHdl();
147 void Outliner::SetNotifyHdl( const Link
& rLink
)
149 DBG_CHKTHIS(Outliner
,0);
150 pEditEngine
->aOutlinerNotifyHdl
= rLink
;
153 pEditEngine
->SetNotifyHdl( LINK( this, Outliner
, EditEngineNotifyHdl
) );
155 pEditEngine
->SetNotifyHdl( Link() );
159 void Outliner::SetStatusEventHdl( const Link
& rLink
)
161 DBG_CHKTHIS(Outliner
,0);
162 pEditEngine
->SetStatusEventHdl( rLink
);
165 Link
Outliner::GetStatusEventHdl() const
167 DBG_CHKTHIS(Outliner
,0);
168 return pEditEngine
->GetStatusEventHdl();
171 void Outliner::SetDefTab( sal_uInt16 nTab
)
173 DBG_CHKTHIS(Outliner
,0);
174 pEditEngine
->SetDefTab( nTab
);
177 sal_Bool
Outliner::IsFlatMode() const
179 DBG_CHKTHIS(Outliner
,0);
180 return pEditEngine
->IsFlatMode();
183 sal_Bool
Outliner::UpdateFields()
185 DBG_CHKTHIS(Outliner
,0);
186 return pEditEngine
->UpdateFields();
189 void Outliner::RemoveFields( sal_Bool bKeepFieldText
, TypeId aType
)
191 DBG_CHKTHIS(Outliner
,0);
192 pEditEngine
->RemoveFields( bKeepFieldText
, aType
);
195 void Outliner::SetWordDelimiters( const String
& rDelimiters
)
197 DBG_CHKTHIS(Outliner
,0);
198 pEditEngine
->SetWordDelimiters( rDelimiters
);
201 String
Outliner::GetWordDelimiters() const
203 DBG_CHKTHIS(Outliner
,0);
204 return pEditEngine
->GetWordDelimiters();
207 String
Outliner::GetWord( sal_uInt16 nPara
, sal_uInt16 nIndex
)
209 DBG_CHKTHIS(Outliner
,0);
210 return pEditEngine
->GetWord( nPara
, nIndex
);
213 void Outliner::Draw( OutputDevice
* pOutDev
, const Rectangle
& rOutRect
)
215 DBG_CHKTHIS(Outliner
,0);
216 pEditEngine
->Draw( pOutDev
, rOutRect
);
219 void Outliner::Draw( OutputDevice
* pOutDev
, const Point
& rStartPos
, short nOrientation
)
221 DBG_CHKTHIS(Outliner
,0);
222 pEditEngine
->Draw( pOutDev
, rStartPos
, nOrientation
);
225 void Outliner::SetPaperSize( const Size
& rSize
)
227 DBG_CHKTHIS(Outliner
,0);
228 pEditEngine
->SetPaperSize( rSize
);
231 const Size
& Outliner::GetPaperSize() const
233 DBG_CHKTHIS(Outliner
,0);
234 return pEditEngine
->GetPaperSize();
237 void Outliner::SetPolygon( const basegfx::B2DPolyPolygon
& rPolyPolygon
)
239 DBG_CHKTHIS( Outliner
, 0 );
240 pEditEngine
->SetPolygon( rPolyPolygon
);
243 void Outliner::SetPolygon( const basegfx::B2DPolyPolygon
& rPolyPolygon
, const basegfx::B2DPolyPolygon
* pLinePolyPolygon
)
245 DBG_CHKTHIS( Outliner
, 0 );
246 pEditEngine
->SetPolygon( rPolyPolygon
, pLinePolyPolygon
);
249 void Outliner::ClearPolygon()
251 DBG_CHKTHIS( Outliner
, 0 );
252 pEditEngine
->ClearPolygon();
255 const Size
& Outliner::GetMinAutoPaperSize() const
257 DBG_CHKTHIS(Outliner
,0);
258 return pEditEngine
->GetMinAutoPaperSize();
261 void Outliner::SetMinAutoPaperSize( const Size
& rSz
)
263 DBG_CHKTHIS(Outliner
,0);
264 pEditEngine
->SetMinAutoPaperSize( rSz
);
267 const Size
& Outliner::GetMaxAutoPaperSize() const
269 DBG_CHKTHIS(Outliner
,0);
270 return pEditEngine
->GetMaxAutoPaperSize();
273 void Outliner::SetMaxAutoPaperSize( const Size
& rSz
)
275 DBG_CHKTHIS(Outliner
,0);
276 pEditEngine
->SetMaxAutoPaperSize( rSz
);
279 sal_Bool
Outliner::IsExpanded( Paragraph
* pPara
) const
281 DBG_CHKTHIS(Outliner
,0);
282 return pParaList
->HasVisibleChildren( pPara
);
285 Paragraph
* Outliner::GetParent( Paragraph
* pParagraph
) const
287 DBG_CHKTHIS(Outliner
,0);
288 return pParaList
->GetParent( pParagraph
);
291 sal_uLong
Outliner::GetChildCount( Paragraph
* pParent
) const
293 DBG_CHKTHIS(Outliner
,0);
294 return pParaList
->GetChildCount( pParent
);
297 Size
Outliner::CalcTextSize()
299 DBG_CHKTHIS(Outliner
,0);
300 return Size(pEditEngine
->CalcTextWidth(),pEditEngine
->GetTextHeight());
303 Size
Outliner::CalcTextSizeNTP()
305 DBG_CHKTHIS(Outliner
,0);
306 return Size(pEditEngine
->CalcTextWidth(),pEditEngine
->GetTextHeightNTP());
309 void Outliner::SetStyleSheetPool( SfxStyleSheetPool
* pSPool
)
311 DBG_CHKTHIS(Outliner
,0);
312 pEditEngine
->SetStyleSheetPool( pSPool
);
315 SfxStyleSheetPool
* Outliner::GetStyleSheetPool()
317 DBG_CHKTHIS(Outliner
,0);
318 return pEditEngine
->GetStyleSheetPool();
321 SfxStyleSheet
* Outliner::GetStyleSheet( sal_uLong nPara
)
323 DBG_CHKTHIS(Outliner
,0);
324 return pEditEngine
->GetStyleSheet( (sal_uInt16
)nPara
);
327 sal_Bool
Outliner::IsInSelectionMode() const
329 DBG_CHKTHIS(Outliner
,0);
330 return pEditEngine
->IsInSelectionMode();
333 void Outliner::SetControlWord( sal_uLong nWord
)
335 DBG_CHKTHIS(Outliner
,0);
336 pEditEngine
->SetControlWord( nWord
);
339 sal_uLong
Outliner::GetControlWord() const
341 DBG_CHKTHIS(Outliner
,0);
342 return pEditEngine
->GetControlWord();
345 void Outliner::SetAsianCompressionMode( sal_uInt16 n
)
347 DBG_CHKTHIS(Outliner
,0);
348 pEditEngine
->SetAsianCompressionMode( n
);
351 void Outliner::SetKernAsianPunctuation( sal_Bool b
)
353 DBG_CHKTHIS(Outliner
,0);
354 pEditEngine
->SetKernAsianPunctuation( b
);
357 void Outliner::SetAddExtLeading( sal_Bool bExtLeading
)
359 DBG_CHKTHIS(Outliner
,0);
360 pEditEngine
->SetAddExtLeading( bExtLeading
);
363 void Outliner::UndoActionStart( sal_uInt16 nId
)
365 DBG_CHKTHIS(Outliner
,0);
366 pEditEngine
->UndoActionStart( nId
);
369 void Outliner::UndoActionEnd( sal_uInt16 nId
)
371 DBG_CHKTHIS(Outliner
,0);
372 pEditEngine
->UndoActionEnd( nId
);
375 void Outliner::InsertUndo( EditUndo
* pUndo
)
377 DBG_CHKTHIS(Outliner
,0);
378 pEditEngine
->GetUndoManager().AddUndoAction( pUndo
, sal_False
);
381 sal_Bool
Outliner::IsInUndo()
383 DBG_CHKTHIS(Outliner
,0);
384 return pEditEngine
->IsInUndo();
387 sal_uLong
Outliner::GetLineCount( sal_uLong nParagraph
) const
389 DBG_CHKTHIS(Outliner
,0);
390 return pEditEngine
->GetLineCount( (sal_uInt16
)nParagraph
);
393 sal_uInt16
Outliner::GetLineLen( sal_uLong nParagraph
, sal_uInt16 nLine
) const
395 DBG_CHKTHIS(Outliner
,0);
396 return pEditEngine
->GetLineLen( (sal_uInt16
)nParagraph
, nLine
);
399 sal_uLong
Outliner::GetLineHeight( sal_uLong nParagraph
, sal_uLong nLine
)
401 DBG_CHKTHIS(Outliner
,0);
402 return pEditEngine
->GetLineHeight( (sal_uInt16
)nParagraph
, (sal_uInt16
)nLine
);
405 void Outliner::QuickRemoveCharAttribs( sal_uInt16 nPara
, sal_uInt16 nWhich
)
407 DBG_CHKTHIS(Outliner
,0);
408 pEditEngine
->QuickRemoveCharAttribs( nPara
, nWhich
);
411 EESpellState
Outliner::HasSpellErrors()
413 DBG_CHKTHIS(Outliner
,0);
414 return pEditEngine
->HasSpellErrors();
417 sal_Bool
Outliner::HasConvertibleTextPortion( LanguageType nLang
)
419 DBG_CHKTHIS(Outliner
,0);
420 return pEditEngine
->HasConvertibleTextPortion( nLang
);
423 sal_Bool
Outliner::ConvertNextDocument()
425 DBG_CHKTHIS(Outliner
,0);
429 void Outliner::SetDefaultLanguage( LanguageType eLang
)
431 DBG_CHKTHIS(Outliner
,0);
432 pEditEngine
->SetDefaultLanguage( eLang
);
435 LanguageType
Outliner::GetDefaultLanguage() const
437 DBG_CHKTHIS(Outliner
,0);
438 return pEditEngine
->GetDefaultLanguage();
441 void Outliner::CompleteOnlineSpelling()
443 DBG_CHKTHIS(Outliner
,0);
444 pEditEngine
->CompleteOnlineSpelling();
447 sal_Bool
Outliner::HasText( const SvxSearchItem
& rSearchItem
)
449 DBG_CHKTHIS(Outliner
,0);
450 return pEditEngine
->HasText( rSearchItem
);
453 void Outliner::SetEditTextObjectPool( SfxItemPool
* pPool
)
455 DBG_CHKTHIS(Outliner
,0);
456 pEditEngine
->SetEditTextObjectPool( pPool
);
459 SfxItemPool
* Outliner::GetEditTextObjectPool() const
461 DBG_CHKTHIS(Outliner
,0);
462 return pEditEngine
->GetEditTextObjectPool();
465 sal_Bool
Outliner::SpellNextDocument()
467 DBG_CHKTHIS(Outliner
,0);
472 void Outliner::SetSpeller( Reference
< XSpellChecker1
> &xSpeller
)
474 DBG_CHKTHIS(Outliner
,0);
475 pEditEngine
->SetSpeller( xSpeller
);
477 Reference
< XSpellChecker1
> Outliner::GetSpeller()
479 DBG_CHKTHIS(Outliner
,0);
480 return pEditEngine
->GetSpeller();
483 void Outliner::SetForbiddenCharsTable( rtl::Reference
<SvxForbiddenCharactersTable
> xForbiddenChars
)
485 DBG_CHKTHIS(Outliner
,0);
486 pEditEngine
->SetForbiddenCharsTable( xForbiddenChars
);
489 void Outliner::SetHyphenator( Reference
< XHyphenator
>& xHyph
)
491 DBG_CHKTHIS(Outliner
,0);
492 pEditEngine
->SetHyphenator( xHyph
);
495 OutputDevice
* Outliner::GetRefDevice() const
497 DBG_CHKTHIS(Outliner
,0);
498 return pEditEngine
->GetRefDevice();
501 sal_uLong
Outliner::GetTextHeight( sal_uLong nParagraph
) const
503 DBG_CHKTHIS(Outliner
,0);
504 return pEditEngine
->GetTextHeight((sal_uInt16
)nParagraph
);
507 Point
Outliner::GetDocPos( const Point
& rPaperPos
) const
509 DBG_CHKTHIS(Outliner
,0);
510 return pEditEngine
->GetDocPos( rPaperPos
);
513 Point
Outliner::GetDocPosTopLeft( sal_uLong nParagraph
)
515 DBG_CHKTHIS(Outliner
,0);
516 return pEditEngine
->GetDocPosTopLeft( (sal_uInt16
)nParagraph
);
519 sal_Bool
Outliner::IsTextPos( const Point
& rPaperPos
, sal_uInt16 nBorder
)
521 return IsTextPos( rPaperPos
, nBorder
, NULL
);
524 sal_Bool
Outliner::IsTextPos( const Point
& rPaperPos
, sal_uInt16 nBorder
, sal_Bool
* pbBullet
)
526 DBG_CHKTHIS(Outliner
,0);
528 *pbBullet
= sal_False
;
529 sal_Bool bTextPos
= pEditEngine
->IsTextPos( rPaperPos
, nBorder
);
532 Point aDocPos
= GetDocPos( rPaperPos
);
533 sal_uInt16 nPara
= pEditEngine
->FindParagraph( aDocPos
.Y() );
534 if ( ( nPara
!= EE_PARA_NOT_FOUND
) && ImplHasBullet( nPara
) )
536 Rectangle aBulArea
= ImpCalcBulletArea( nPara
, sal_True
, sal_True
);
537 if ( aBulArea
.IsInside( rPaperPos
) )
541 *pbBullet
= sal_True
;
549 void Outliner::QuickSetAttribs( const SfxItemSet
& rSet
, const ESelection
& rSel
)
551 DBG_CHKTHIS(Outliner
,0);
552 pEditEngine
->QuickSetAttribs( rSet
, rSel
);
555 void Outliner::QuickInsertText( const XubString
& rText
, const ESelection
& rSel
)
557 bFirstParaIsEmpty
= sal_False
;
558 pEditEngine
->QuickInsertText( rText
, rSel
);
561 void Outliner::QuickDelete( const ESelection
& rSel
)
563 bFirstParaIsEmpty
= sal_False
;
564 pEditEngine
->QuickDelete( rSel
);
567 void Outliner::QuickInsertField( const SvxFieldItem
& rFld
, const ESelection
& rSel
)
569 DBG_CHKTHIS(Outliner
,0);
570 bFirstParaIsEmpty
= sal_False
;
571 pEditEngine
->QuickInsertField( rFld
, rSel
);
574 void Outliner::QuickInsertLineBreak( const ESelection
& rSel
)
576 DBG_CHKTHIS(Outliner
,0);
577 bFirstParaIsEmpty
= sal_False
;
578 pEditEngine
->QuickInsertLineBreak( rSel
);
581 void Outliner::QuickFormatDoc( sal_Bool bFull
)
583 DBG_CHKTHIS(Outliner
,0);
584 pEditEngine
->QuickFormatDoc( bFull
);
587 void Outliner::SetGlobalCharStretching( sal_uInt16 nX
, sal_uInt16 nY
)
589 DBG_CHKTHIS(Outliner
,0);
592 sal_uInt16 nParagraphs
= (sal_uInt16
)pParaList
->GetParagraphCount();
593 for ( sal_uInt16 nPara
= 0; nPara
< nParagraphs
; nPara
++ )
595 Paragraph
* pPara
= pParaList
->GetParagraph( nPara
);
597 pPara
->aBulSize
.Width() = -1;
600 pEditEngine
->SetGlobalCharStretching( nX
, nY
);
603 void Outliner::GetGlobalCharStretching( sal_uInt16
& rX
, sal_uInt16
& rY
)
605 DBG_CHKTHIS(Outliner
,0);
606 pEditEngine
->GetGlobalCharStretching( rX
, rY
);
609 void Outliner::EraseVirtualDevice()
611 DBG_CHKTHIS(Outliner
,0);
612 pEditEngine
->EraseVirtualDevice();
615 sal_Bool
Outliner::ShouldCreateBigTextObject() const
617 DBG_CHKTHIS(Outliner
,0);
618 return pEditEngine
->ShouldCreateBigTextObject();
621 void Outliner::SetVertical( sal_Bool b
)
623 DBG_CHKTHIS(Outliner
,0);
624 pEditEngine
->SetVertical( b
);
627 sal_Bool
Outliner::IsVertical() const
629 DBG_CHKTHIS(Outliner
,0);
630 return pEditEngine
->IsVertical();
633 void Outliner::SetFixedCellHeight( sal_Bool bUseFixedCellHeight
)
635 DBG_CHKTHIS(Outliner
,0);
636 pEditEngine
->SetFixedCellHeight( bUseFixedCellHeight
);
639 void Outliner::SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir
)
641 DBG_CHKTHIS(Outliner
,0);
642 pEditEngine
->SetDefaultHorizontalTextDirection( eHTextDir
);
645 EEHorizontalTextDirection
Outliner::GetDefaultHorizontalTextDirection() const
647 return pEditEngine
->GetDefaultHorizontalTextDirection();
650 sal_uInt16
Outliner::GetScriptType( const ESelection
& rSelection
) const
652 DBG_CHKTHIS(Outliner
,0);
653 return pEditEngine
->GetScriptType( rSelection
);
656 LanguageType
Outliner::GetLanguage( sal_uInt16 nPara
, sal_uInt16 nPos
) const
658 DBG_CHKTHIS(Outliner
,0);
659 return pEditEngine
->GetLanguage( nPara
, nPos
);
662 void Outliner::RemoveAttribs( const ESelection
& rSelection
, sal_Bool bRemoveParaAttribs
, sal_uInt16 nWhich
)
664 DBG_CHKTHIS(Outliner
,0);
665 pEditEngine
->RemoveAttribs( rSelection
, bRemoveParaAttribs
, nWhich
);
668 void Outliner::EnableAutoColor( sal_Bool b
)
670 DBG_CHKTHIS(Outliner
,0);
671 pEditEngine
->EnableAutoColor( b
);
674 void Outliner::ForceAutoColor( sal_Bool b
)
676 DBG_CHKTHIS(Outliner
,0);
677 pEditEngine
->ForceAutoColor( b
);
680 sal_Bool
Outliner::IsForceAutoColor() const
682 DBG_CHKTHIS(Outliner
,0);
683 return pEditEngine
->IsForceAutoColor();
686 void Outliner::StartSpelling(EditView
& rEditView
, sal_Bool bMultipleDoc
)
688 pEditEngine
->StartSpelling(rEditView
, bMultipleDoc
);
691 bool Outliner::SpellSentence(EditView
& rEditView
, ::svx::SpellPortions
& rToFill
, bool bIsGrammarChecking
)
693 return pEditEngine
->SpellSentence(rEditView
, rToFill
, bIsGrammarChecking
);
696 void Outliner::PutSpellingToSentenceStart( EditView
& rEditView
)
698 pEditEngine
->PutSpellingToSentenceStart( rEditView
);
701 void Outliner::ApplyChangedSentence(EditView
& rEditView
, const ::svx::SpellPortions
& rNewPortions
, bool bRecheck
)
703 pEditEngine
->ApplyChangedSentence( rEditView
, rNewPortions
, bRecheck
);
706 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */