nss: upgrade to release 3.73
[LibreOffice.git] / include / editeng / outliner.hxx
bloba6bc9fbd7ff2fc401a92ef1f3e7046ddb0bebcbf
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 .
19 #ifndef INCLUDED_EDITENG_OUTLINER_HXX
20 #define INCLUDED_EDITENG_OUTLINER_HXX
22 #include <editeng/editdata.hxx>
23 #include <editeng/editstat.hxx>
24 #include <i18nlangtag/lang.h>
25 #include <rtl/ustring.hxx>
26 #include <svl/SfxBroadcaster.hxx>
27 #include <svl/languageoptions.hxx>
28 #include <svl/undo.hxx>
29 #include <tools/gen.hxx>
30 #include <tools/color.hxx>
31 #include <vcl/outdev.hxx>
32 #include <vcl/errcode.hxx>
33 #include <tools/link.hxx>
34 #include <editeng/editengdllapi.h>
36 #include <vcl/GraphicObject.hxx>
38 #include <editeng/svxfont.hxx>
39 #include <editeng/eedata.hxx>
40 #include <editeng/paragraphdata.hxx>
41 #include <o3tl/typed_flags_set.hxx>
43 #include <optional>
44 #include <functional>
45 #include <memory>
46 #include <vector>
48 class OutlinerEditEng;
49 class Outliner;
50 class EditView;
51 class EditUndo;
52 class ParagraphList;
53 class OutlinerParaObject;
54 class SvStream;
55 class SvxSearchItem;
56 class SvxFieldItem;
57 namespace vcl { class Window; }
58 class KeyEvent;
59 class MouseEvent;
60 class CommandEvent;
61 class MapMode;
62 class SfxStyleSheetPool;
63 class SfxStyleSheet;
64 class SfxItemPool;
65 class SfxItemSet;
66 class SvxNumberFormat;
67 class EditEngine;
68 class SvKeyValueIterator;
69 class SvxForbiddenCharactersTable;
70 class OverflowingText;
71 class NonOverflowingText;
72 class OutlinerViewShell;
73 enum class CharCompressType;
74 enum class TransliterationFlags;
75 class SvxFieldData;
76 enum class PointerStyle;
77 class SvxNumRule;
78 enum class TextRotation;
80 namespace com::sun::star::linguistic2 {
81 class XSpellChecker1;
82 class XHyphenator;
84 namespace svx{
85 struct SpellPortion;
86 typedef std::vector<SpellPortion> SpellPortions;
88 namespace basegfx { class B2DPolyPolygon; }
89 namespace com::sun::star::lang { struct Locale; }
93 // internal use only!
94 enum class ParaFlag
96 NONE = 0x0000,
97 HOLDDEPTH = 0x4000,
98 SETBULLETTEXT = 0x8000,
99 ISPAGE = 0x0100,
101 namespace o3tl
103 template<> struct typed_flags<ParaFlag> : is_typed_flags<ParaFlag, 0xc100> {};
106 // Undo-Action-Ids
107 #define OLUNDO_DEPTH EDITUNDO_USER
108 // #define OLUNDO_HEIGHT EDITUNDO_USER+1
109 #define OLUNDO_EXPAND EDITUNDO_USER+2
110 #define OLUNDO_COLLAPSE EDITUNDO_USER+3
111 // #define OLUNDO_REMOVE EDITUNDO_USER+4
112 #define OLUNDO_ATTR EDITUNDO_USER+5
113 #define OLUNDO_INSERT EDITUNDO_USER+6
114 // #define OLUNDO_MOVEPARAGRAPHS EDITUNDO_USER+7
116 class Paragraph : protected ParagraphData
118 private:
119 friend class Outliner;
120 friend class ParagraphList;
121 friend class OutlinerView;
122 friend class OutlinerParaObject;
123 friend class OutlinerEditEng;
124 friend class OutlinerUndoCheckPara;
125 friend class OutlinerUndoChangeParaFlags;
127 Paragraph& operator=(const Paragraph& rPara ) = delete;
129 OUString aBulText;
130 Size aBulSize;
131 ParaFlag nFlags;
132 bool bVisible;
134 bool IsVisible() const { return bVisible; }
135 void SetText( const OUString& rText ) { aBulText = rText; aBulSize.setWidth(-1); }
136 void Invalidate() { aBulSize.setWidth(-1); }
137 void SetDepth( sal_Int16 nNewDepth ) { nDepth = nNewDepth; aBulSize.setWidth(-1); }
138 const OUString& GetText() const { return aBulText; }
140 Paragraph( sal_Int16 nDepth );
141 Paragraph( const Paragraph& ) = delete;
142 Paragraph( const ParagraphData& );
144 sal_Int16 GetDepth() const { return nDepth; }
146 sal_Int16 GetNumberingStartValue() const { return mnNumberingStartValue; }
147 void SetNumberingStartValue( sal_Int16 nNumberingStartValue );
149 bool IsParaIsNumberingRestart() const { return mbParaIsNumberingRestart; }
150 void SetParaIsNumberingRestart( bool bParaIsNumberingRestart );
152 void SetFlag( ParaFlag nFlag ) { nFlags |= nFlag; }
153 void RemoveFlag( ParaFlag nFlag ) { nFlags &= ~nFlag; }
154 bool HasFlag( ParaFlag nFlag ) const { return bool(nFlags & nFlag); }
155 public:
156 ~Paragraph();
157 void dumpAsXml(xmlTextWriterPtr pWriter) const;
160 struct ParaRange
162 sal_Int32 nStartPara;
163 sal_Int32 nEndPara;
165 ParaRange( sal_Int32 nS, sal_Int32 nE ) : nStartPara(nS), nEndPara(nE) {}
167 void Adjust();
170 inline void ParaRange::Adjust()
172 if ( nStartPara > nEndPara )
174 std::swap(nStartPara, nEndPara);
178 class EDITENG_DLLPUBLIC OutlinerView final
180 friend class Outliner;
182 Outliner* pOwner;
183 std::unique_ptr<EditView> pEditView;
185 enum class MouseTarget {
186 Text = 0,
187 Bullet = 1,
188 Hypertext = 2, // Outside OutputArea
189 Outside = 3 // Outside OutputArea
192 EDITENG_DLLPRIVATE void ImplExpandOrCollaps( sal_Int32 nStartPara, sal_Int32 nEndPara, bool bExpand );
194 EDITENG_DLLPRIVATE sal_Int32 ImpCheckMousePos( const Point& rPosPixel, MouseTarget& reTarget);
195 EDITENG_DLLPRIVATE void ImpToggleExpand( Paragraph const * pParentPara );
196 EDITENG_DLLPRIVATE ParaRange ImpGetSelectedParagraphs( bool bIncludeHiddenChildren );
198 EDITENG_DLLPRIVATE sal_Int32 ImpInitPaste( sal_Int32& rStart );
199 EDITENG_DLLPRIVATE void ImpPasted( sal_Int32 nStart, sal_Int32 nPrevParaCount, sal_Int32 nSize);
200 EDITENG_DLLPRIVATE sal_Int32 ImpCalcSelectedPages( bool bIncludeFirstSelected );
202 Link<LinkParamNone*,void> aEndCutPasteLink;
204 public:
205 OutlinerView( Outliner* pOut, vcl::Window* pWindow );
206 ~OutlinerView();
208 EditView& GetEditView() const { return *pEditView; }
210 void Scroll( tools::Long nHorzScroll, tools::Long nVertScroll );
212 void Paint( const tools::Rectangle& rRect, OutputDevice* pTargetDevice = nullptr );
213 bool PostKeyEvent( const KeyEvent& rKEvt, vcl::Window const * pFrameWin = nullptr );
214 bool MouseButtonDown( const MouseEvent& );
215 bool MouseButtonUp( const MouseEvent& );
216 void ReleaseMouse();
217 bool MouseMove( const MouseEvent& );
219 void ShowCursor( bool bGotoCursor = true, bool bActivate = false );
220 void HideCursor( bool bDeactivate = false );
222 Outliner* GetOutliner() const { return pOwner; }
224 void SetWindow( vcl::Window* pWindow );
225 vcl::Window* GetWindow() const;
227 void SetReadOnly( bool bReadOnly );
228 bool IsReadOnly() const;
230 void SetOutputArea( const tools::Rectangle& rRect );
231 tools::Rectangle const & GetOutputArea() const;
233 tools::Rectangle const & GetVisArea() const;
235 void CreateSelectionList (std::vector<Paragraph*> &aSelList) ;
237 void Select( Paragraph const * pParagraph, bool bSelect = true);
239 OUString GetSelected() const;
240 void SelectRange( sal_Int32 nFirst, sal_Int32 nCount );
241 void SetAttribs( const SfxItemSet& );
242 void Indent( short nDiff );
243 void AdjustDepth( short nDX ); // Later replace with Indent!
245 void AdjustHeight( tools::Long nDY );
247 void Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs );
249 void InsertText( const OUString& rNew, bool bSelect = false );
250 void InsertText( const OutlinerParaObject& rParaObj );
251 void Expand();
252 void Collapse();
253 void ExpandAll();
254 void CollapseAll();
256 void SetBackgroundColor( const Color& rColor );
257 Color const & GetBackgroundColor() const;
259 /// Informs this edit view about which view shell contains it.
260 void RegisterViewShell(OutlinerViewShell* pViewShell);
262 SfxItemSet GetAttribs();
264 void Cut();
265 void Copy();
266 void Paste( bool bUseSpecial = false );
267 void PasteSpecial();
269 const SfxStyleSheet* GetStyleSheet() const;
270 SfxStyleSheet* GetStyleSheet();
272 void SetControlWord( EVControlBits nWord );
273 EVControlBits GetControlWord() const;
275 void SetAnchorMode( EEAnchorMode eMode );
276 EEAnchorMode GetAnchorMode() const;
278 PointerStyle GetPointer( const Point& rPosPixel );
279 void Command( const CommandEvent& rCEvt );
281 void StartSpeller();
282 EESpellState StartThesaurus();
283 sal_Int32 StartSearchAndReplace( const SvxSearchItem& rSearchItem );
285 // for text conversion
286 void StartTextConversion( LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc );
288 void TransliterateText( TransliterationFlags nTransliterationMode );
290 ESelection GetSelection() const;
292 SvtScriptType GetSelectedScriptType() const;
294 void SetVisArea( const tools::Rectangle& rRect );
295 void SetSelection( const ESelection& );
296 void GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects) const;
298 void RemoveAttribs( bool bRemoveParaAttribs, bool bKeepLanguages = false );
299 void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs );
300 bool HasSelection() const;
302 void InsertField( const SvxFieldItem& rFld );
303 const SvxFieldItem* GetFieldUnderMousePointer() const;
304 const SvxFieldItem* GetFieldAtSelection() const;
305 /// Return the field at the current cursor position or nullptr if no field found
306 const SvxFieldData* GetFieldAtCursor() const;
307 /// Select the field at the current cursor position
308 void SelectFieldAtCursor();
310 /** enables bullets for the selected paragraphs if the bullets/numbering of the first paragraph is off
311 or disables bullets/numbering for the selected paragraphs if the bullets/numbering of the first paragraph is on
313 void ToggleBullets();
315 void ToggleBulletsNumbering(
316 const bool bToggle,
317 const bool bHandleBullets,
318 const SvxNumRule* pNumRule );
320 /** apply bullets/numbering for paragraphs
322 @param boolean bHandleBullets
323 true: handle bullets
324 false: handle numbering
326 @param pNewNumRule
327 numbering rule which needs to be applied. can be 0.
329 @param boolean bAtSelection
330 true: apply bullets/numbering at selected paragraphs
331 false: apply bullets/numbering at all paragraphs
333 void ApplyBulletsNumbering(
334 const bool bHandleBullets,
335 const SvxNumRule* pNewNumRule,
336 const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule,
337 const bool bAtSelection = false );
339 /** switch off bullets/numbering for paragraphs
341 @param boolean bAtSelection
342 true: switch off bullets/numbering at selected paragraphs
343 false: switch off bullets/numbering at all paragraphs
345 void SwitchOffBulletsNumbering(
346 const bool bAtSelection = false );
348 bool IsCursorAtWrongSpelledWord();
349 bool IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong = false );
350 void ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo&,void> const * pCallBack );
352 void SetInvalidateMore( sal_uInt16 nPixel );
353 sal_uInt16 GetInvalidateMore() const;
355 OUString GetSurroundingText() const;
356 Selection GetSurroundingTextSelection() const;
357 bool DeleteSurroundingText(const Selection& rRange);
359 void SetEndCutPasteLinkHdl(const Link<LinkParamNone*,void> &rLink) { aEndCutPasteLink = rLink; }
362 /// Interface class to not depend on SfxViewShell in editeng.
363 class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI OutlinerViewShell
365 public:
366 virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const = 0;
367 virtual ViewShellId GetViewShellId() const = 0;
368 virtual ViewShellDocId GetDocId() const = 0;
369 /// Wrapper around SfxLokHelper::notifyOtherViews().
370 virtual void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) = 0;
371 /// Wrapper around SfxLokHelper::notifyOtherView().
372 virtual void NotifyOtherView(OutlinerViewShell* pOtherShell, int nType, const OString& rKey, const OString& rPayload) = 0;
373 virtual vcl::Window* GetEditWindowForActiveOLEObj() const = 0;
375 protected:
376 ~OutlinerViewShell() throw () {}
379 // some thesaurus functionality to avoid code duplication in different projects...
380 bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext( OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView );
381 void EDITENG_DLLPUBLIC ReplaceTextWithSynonym( EditView &rEditView, const OUString &rSynonmText );
383 typedef ::std::vector< OutlinerView* > ViewList;
385 class EDITENG_DLLPUBLIC DrawPortionInfo
387 public:
388 const Point& mrStartPos;
389 const OUString maText;
390 sal_Int32 mnTextStart;
391 sal_Int32 mnTextLen;
392 sal_Int32 mnPara;
393 const SvxFont& mrFont;
394 const tools::Long* mpDXArray;
396 const EEngineData::WrongSpellVector* mpWrongSpellVector;
397 const SvxFieldData* mpFieldData;
398 const css::lang::Locale* mpLocale;
399 const Color maOverlineColor;
400 const Color maTextLineColor;
402 sal_uInt8 mnBiDiLevel;
404 bool mbFilled;
405 tools::Long mnWidthToFill;
407 bool mbEndOfLine : 1;
408 bool mbEndOfParagraph : 1;
409 bool mbEndOfBullet : 1;
411 bool IsRTL() const { return mnBiDiLevel % 2 == 1; }
413 DrawPortionInfo(
414 const Point& rPos,
415 const OUString& rTxt,
416 sal_Int32 nTxtStart,
417 sal_Int32 nTxtLen,
418 const SvxFont& rFnt,
419 sal_Int32 nPar,
420 const tools::Long* pDXArr,
421 const EEngineData::WrongSpellVector* pWrongSpellVector,
422 const SvxFieldData* pFieldData,
423 const css::lang::Locale* pLocale,
424 const Color& rOverlineColor,
425 const Color& rTextLineColor,
426 sal_uInt8 nBiDiLevel,
427 bool bFilled,
428 tools::Long nWidthToFill,
429 bool bEndOfLine,
430 bool bEndOfParagraph,
431 bool bEndOfBullet)
432 : mrStartPos(rPos),
433 maText(rTxt),
434 mnTextStart(nTxtStart),
435 mnTextLen(nTxtLen),
436 mnPara(nPar),
437 mrFont(rFnt),
438 mpDXArray(pDXArr),
439 mpWrongSpellVector(pWrongSpellVector),
440 mpFieldData(pFieldData),
441 mpLocale(pLocale),
442 maOverlineColor(rOverlineColor),
443 maTextLineColor(rTextLineColor),
444 mnBiDiLevel(nBiDiLevel),
445 mbFilled( bFilled ),
446 mnWidthToFill( nWidthToFill ),
447 mbEndOfLine(bEndOfLine),
448 mbEndOfParagraph(bEndOfParagraph),
449 mbEndOfBullet(bEndOfBullet)
453 class EDITENG_DLLPUBLIC DrawBulletInfo
455 public:
456 const GraphicObject maBulletGraphicObject;
457 Point maBulletPosition;
458 Size maBulletSize;
460 DrawBulletInfo(
461 const GraphicObject& rBulletGraphicObject,
462 const Point& rBulletPosition,
463 const Size& rBulletSize)
464 : maBulletGraphicObject(rBulletGraphicObject),
465 maBulletPosition(rBulletPosition),
466 maBulletSize(rBulletSize)
470 struct EDITENG_DLLPUBLIC PaintFirstLineInfo
472 sal_Int32 mnPara;
473 const Point& mrStartPos;
474 VclPtr<OutputDevice> mpOutDev;
476 PaintFirstLineInfo( sal_Int32 nPara, const Point& rStartPos, OutputDevice* pOutDev )
477 : mnPara( nPara ), mrStartPos( rStartPos ), mpOutDev( pOutDev )
481 class SdrPage;
483 class EditFieldInfo
485 private:
486 Outliner* pOutliner;
487 const SvxFieldItem& rFldItem;
489 std::optional<Color> mxTxtColor;
490 std::optional<Color> mxFldColor;
492 OUString aRepresentation;
494 sal_Int32 nPara;
495 sal_Int32 nPos;
497 EditFieldInfo( const EditFieldInfo& ) = delete;
499 SdrPage* mpSdrPage;
501 public:
502 EditFieldInfo( Outliner* pOutl, const SvxFieldItem& rFItem, sal_Int32 nPa, sal_Int32 nPo )
503 : rFldItem( rFItem )
505 pOutliner = pOutl;
506 nPara = nPa; nPos = nPo;
507 mpSdrPage = nullptr;
510 Outliner* GetOutliner() const { return pOutliner; }
512 const SvxFieldItem& GetField() const { return rFldItem; }
514 std::optional<Color> const & GetTextColor() const { return mxTxtColor; }
515 void SetTextColor( std::optional<Color> xCol ) { mxTxtColor = xCol; }
517 std::optional<Color> const & GetFieldColor() const { return mxFldColor; }
518 void SetFieldColor( std::optional<Color> xCol ) { mxFldColor = xCol; }
520 sal_Int32 GetPara() const { return nPara; }
521 sal_Int32 GetPos() const { return nPos; }
523 const OUString& GetRepresentation() const { return aRepresentation; }
524 OUString& GetRepresentation() { return aRepresentation; }
525 void SetRepresentation( const OUString& rStr ){ aRepresentation = rStr; }
527 void SetSdrPage( SdrPage* pPage ) { mpSdrPage = pPage; }
528 SdrPage* GetSdrPage() const { return mpSdrPage; }
531 struct EBulletInfo
533 SvxFont aFont;
534 tools::Rectangle aBounds;
535 OUString aText;
536 sal_Int32 nParagraph;
537 sal_uInt16 nType; // see SvxNumberType
538 bool bVisible;
540 EBulletInfo() : nParagraph( EE_PARA_NOT_FOUND ), nType( 0 ), bVisible( false ) {}
543 enum class OutlinerMode {
544 DontKnow = 0x0000,
545 TextObject = 0x0001,
546 TitleObject = 0x0002,
547 OutlineObject = 0x0003,
548 OutlineView = 0x0004
551 class EDITENG_DLLPUBLIC Outliner : public SfxBroadcaster
553 public:
554 struct ParagraphHdlParam { Outliner* pOutliner; Paragraph* pPara; };
555 struct DepthChangeHdlParam { Outliner* pOutliner; Paragraph* pPara; ParaFlag nPrevFlags; };
556 private:
557 friend class OutlinerView;
558 friend class OutlinerEditEng;
559 friend class OutlinerParaObject;
560 friend class OLUndoExpand;
561 friend class OutlinerUndoChangeDepth;
562 friend class OutlinerUndoCheckPara;
563 friend class OutlinerUndoChangeParaFlags;
565 friend class TextChainingUtils;
567 std::unique_ptr<OutlinerEditEng> pEditEngine;
569 std::unique_ptr<ParagraphList> pParaList;
570 ViewList aViewList;
572 sal_Int32 mnFirstSelPage;
573 Link<DrawPortionInfo*,void> aDrawPortionHdl;
574 Link<DrawBulletInfo*,void> aDrawBulletHdl;
575 Link<ParagraphHdlParam,void> aParaInsertedHdl;
576 Link<ParagraphHdlParam,void> aParaRemovingHdl;
577 Link<DepthChangeHdlParam,void> aDepthChangedHdl;
578 Link<Outliner*,void> aBeginMovingHdl;
579 Link<Outliner*,void> aEndMovingHdl;
580 Link<OutlinerView*,bool> aIndentingPagesHdl;
581 Link<OutlinerView*,bool> aRemovingPagesHdl;
582 Link<EditFieldInfo*,void> aCalcFieldValueHdl;
583 Link<PaintFirstLineInfo*,void> maPaintFirstLineHdl;
584 Link<PasteOrDropInfos*,void> maBeginPasteOrDropHdl;
585 Link<PasteOrDropInfos*,void> maEndPasteOrDropHdl;
587 sal_Int32 nDepthChangedHdlPrevDepth;
588 sal_Int16 nMaxDepth;
589 static constexpr sal_Int16 gnMinDepth = -1;
591 OutlinerMode nOutlinerMode;
593 bool bFirstParaIsEmpty;
594 sal_uInt8 nBlockInsCallback;
595 bool bStrippingPortions;
596 bool bPasting;
598 DECL_LINK( ParaVisibleStateChangedHdl, Paragraph&, void );
599 DECL_LINK( BeginMovingParagraphsHdl, MoveParagraphsInfo&, void );
600 DECL_LINK( EndMovingParagraphsHdl, MoveParagraphsInfo&, void );
601 DECL_LINK( BeginPasteOrDropHdl, PasteOrDropInfos&, void );
602 DECL_LINK( EndPasteOrDropHdl, PasteOrDropInfos&, void );
603 DECL_LINK( EditEngineNotifyHdl, EENotify&, void );
604 void ImplCheckParagraphs( sal_Int32 nStart, sal_Int32 nEnd );
605 bool ImplHasNumberFormat( sal_Int32 nPara ) const;
606 Size ImplGetBulletSize( sal_Int32 nPara );
607 sal_uInt16 ImplGetNumbering( sal_Int32 nPara, const SvxNumberFormat* pParaFmt );
608 void ImplCalcBulletText( sal_Int32 nPara, bool bRecalcLevel, bool bRecalcChildren );
609 OUString ImplGetBulletText( sal_Int32 nPara );
610 void ImplCheckNumBulletItem( sal_Int32 nPara );
611 void ImplInitDepth( sal_Int32 nPara, sal_Int16 nDepth, bool bCreateUndo );
612 void ImplSetLevelDependentStyleSheet( sal_Int32 nPara );
614 void ImplBlockInsertionCallbacks( bool b );
616 void ImpFilterIndents( sal_Int32 nFirstPara, sal_Int32 nLastPara );
617 bool ImpConvertEdtToOut( sal_Int32 nPara );
619 void ImpTextPasted( sal_Int32 nStartPara, sal_Int32 nCount );
620 vcl::Font ImpCalcBulletFont( sal_Int32 nPara ) const;
621 tools::Rectangle ImpCalcBulletArea( sal_Int32 nPara, bool bAdjust, bool bReturnPaperPos );
622 bool ImpCanIndentSelectedPages( OutlinerView* pCurView );
623 bool ImpCanDeleteSelectedPages( OutlinerView* pCurView );
624 bool ImpCanDeleteSelectedPages( OutlinerView* pCurView, sal_Int32 nFirstPage, sal_Int32 nPages );
626 OutlinerMode ImplGetOutlinerMode() const { return nOutlinerMode; }
627 void ImplCheckDepth( sal_Int16& rnDepth ) const;
629 protected:
630 void ParagraphInserted( sal_Int32 nParagraph );
631 void ParagraphDeleted( sal_Int32 nParagraph );
632 void ParaAttribsChanged( sal_Int32 nParagraph );
634 void StyleSheetChanged( SfxStyleSheet const * pStyle );
636 void InvalidateBullet(sal_Int32 nPara);
637 void PaintBullet( sal_Int32 nPara, const Point& rStartPos,
638 const Point& rOrigin, Degree10 nOrientation,
639 OutputDevice* pOutDev );
641 // used by OutlinerEditEng. Allows Outliner objects to provide
642 // bullet access to the EditEngine.
643 const SvxNumberFormat* GetNumberFormat( sal_Int32 nPara ) const;
645 public:
647 Outliner( SfxItemPool* pPool, OutlinerMode nOutlinerMode );
648 virtual ~Outliner() override;
650 void dumpAsXml(xmlTextWriterPtr pWriter) const;
652 void Init( OutlinerMode nOutlinerMode );
653 OutlinerMode GetMode() const { return nOutlinerMode; }
655 void SetVertical( bool bVertical);
656 void SetRotation(TextRotation nRotation);
657 bool IsVertical() const;
658 bool IsTopToBottom() const;
660 void SetFixedCellHeight( bool bUseFixedCellHeight );
662 void SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir );
663 EEHorizontalTextDirection GetDefaultHorizontalTextDirection() const;
665 LanguageType GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const;
667 void SetAsianCompressionMode( CharCompressType nCompressionMode );
669 void SetKernAsianPunctuation( bool bEnabled );
671 void SetAddExtLeading( bool b );
673 size_t InsertView( OutlinerView* pView, size_t nIndex = size_t(-1) );
674 void RemoveView( OutlinerView const * pView );
675 void RemoveView( size_t nIndex );
676 OutlinerView* GetView( size_t nIndex ) const;
677 size_t GetViewCount() const;
679 Paragraph* Insert( const OUString& rText, sal_Int32 nAbsPos = EE_PARA_APPEND, sal_Int16 nDepth = 0 );
680 void SetText( const OutlinerParaObject& );
681 void AddText( const OutlinerParaObject&, bool bAppend = false );
682 void SetText( const OUString& rText, Paragraph* pParagraph );
683 OUString GetText( Paragraph const * pPara, sal_Int32 nParaCount=1 ) const;
685 void SetToEmptyText();
687 std::unique_ptr<OutlinerParaObject> CreateParaObject( sal_Int32 nStartPara = 0, sal_Int32 nParaCount = EE_PARA_ALL ) const;
689 const SfxItemSet& GetEmptyItemSet() const;
691 void SetRefMapMode( const MapMode& );
692 MapMode const & GetRefMapMode() const;
694 void SetBackgroundColor( const Color& rColor );
695 Color const & GetBackgroundColor() const;
697 void SetMaxDepth( sal_Int16 nDepth );
698 sal_Int16 GetMaxDepth() const { return nMaxDepth; }
700 void SetUpdateMode( bool bUpdate );
701 bool GetUpdateMode() const;
703 void Clear();
705 void RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich );
707 sal_Int32 GetParagraphCount() const;
708 Paragraph* GetParagraph( sal_Int32 nAbsPos ) const;
710 bool HasChildren( Paragraph const * pParagraph ) const;
711 sal_Int32 GetChildCount( Paragraph const * pParent ) const;
712 bool IsExpanded( Paragraph const * pPara ) const;
713 Paragraph* GetParent( Paragraph const * pParagraph ) const;
714 sal_Int32 GetAbsPos( Paragraph const * pPara );
716 sal_Int16 GetDepth( sal_Int32 nPara ) const;
717 void SetDepth( Paragraph* pParagraph, sal_Int16 nNewDepth );
719 void EnableUndo( bool bEnable );
720 bool IsUndoEnabled() const;
721 void UndoActionStart( sal_uInt16 nId );
722 void UndoActionEnd();
723 void InsertUndo( std::unique_ptr<EditUndo> pUndo );
724 bool IsInUndo() const;
726 void ClearModifyFlag();
727 bool IsModified() const;
729 void ParagraphInsertedHdl(Paragraph*);
730 void SetParaInsertedHdl(const Link<ParagraphHdlParam,void>& rLink){aParaInsertedHdl=rLink;}
731 const Link<ParagraphHdlParam,void>& GetParaInsertedHdl() const { return aParaInsertedHdl; }
733 void SetParaRemovingHdl(const Link<ParagraphHdlParam,void>& rLink){aParaRemovingHdl=rLink;}
734 const Link<ParagraphHdlParam,void>& GetParaRemovingHdl() const { return aParaRemovingHdl; }
736 std::unique_ptr<NonOverflowingText> GetNonOverflowingText() const;
737 std::unique_ptr<OverflowingText> GetOverflowingText() const;
738 void ClearOverflowingParaNum();
739 bool IsPageOverflow();
741 std::unique_ptr<OutlinerParaObject> GetEmptyParaObject() const;
744 void DepthChangedHdl(Paragraph*, ParaFlag nPrevFlags);
745 void SetDepthChangedHdl(const Link<DepthChangeHdlParam,void>& rLink){aDepthChangedHdl=rLink;}
746 const Link<DepthChangeHdlParam,void>& GetDepthChangedHdl() const { return aDepthChangedHdl; }
747 sal_Int16 GetPrevDepth() const { return static_cast<sal_Int16>(nDepthChangedHdlPrevDepth); }
749 bool RemovingPagesHdl( OutlinerView* );
750 void SetRemovingPagesHdl(const Link<OutlinerView*,bool>& rLink){aRemovingPagesHdl=rLink;}
751 bool IndentingPagesHdl( OutlinerView* );
752 void SetIndentingPagesHdl(const Link<OutlinerView*,bool>& rLink){aIndentingPagesHdl=rLink;}
753 // valid only in the two upper handlers
754 sal_Int32 GetSelPageCount() const { return nDepthChangedHdlPrevDepth; }
756 void SetCalcFieldValueHdl(const Link<EditFieldInfo*,void>& rLink ) { aCalcFieldValueHdl= rLink; }
757 const Link<EditFieldInfo*,void>& GetCalcFieldValueHdl() const { return aCalcFieldValueHdl; }
759 void SetDrawPortionHdl(const Link<DrawPortionInfo*,void>& rLink){aDrawPortionHdl=rLink;}
761 void SetDrawBulletHdl(const Link<DrawBulletInfo*,void>& rLink){aDrawBulletHdl=rLink;}
763 void SetPaintFirstLineHdl(const Link<PaintFirstLineInfo*,void>& rLink) { maPaintFirstLineHdl = rLink; }
765 void SetModifyHdl( const Link<LinkParamNone*,void>& rLink );
766 Link<LinkParamNone*,void> const & GetModifyHdl() const;
768 void SetNotifyHdl( const Link<EENotify&,void>& rLink );
770 void SetStatusEventHdl( const Link<EditStatus&, void>& rLink );
771 Link<EditStatus&, void> const & GetStatusEventHdl() const;
773 void Draw( OutputDevice* pOutDev, const tools::Rectangle& rOutRect );
774 void Draw( OutputDevice* pOutDev, const Point& rStartPos );
776 const Size& GetPaperSize() const;
777 void SetPaperSize( const Size& rSize );
779 void SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon );
780 void SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DPolyPolygon* pLinePolyPolygon);
781 void ClearPolygon();
783 const Size& GetMinAutoPaperSize() const;
784 void SetMinAutoPaperSize( const Size& rSz );
786 const Size& GetMaxAutoPaperSize() const;
787 void SetMaxAutoPaperSize( const Size& rSz );
789 void SetDefTab( sal_uInt16 nTab );
791 bool IsFlatMode() const;
792 void SetFlatMode( bool bFlat );
794 void EnableAutoColor( bool b );
796 void ForceAutoColor( bool b );
797 bool IsForceAutoColor() const;
799 EBulletInfo GetBulletInfo( sal_Int32 nPara );
801 void SetWordDelimiters( const OUString& rDelimiters );
802 OUString const & GetWordDelimiters() const;
803 OUString GetWord( sal_Int32 nPara, sal_Int32 nIndex );
805 void StripPortions();
807 void DrawingText( const Point& rStartPos, const OUString& rText,
808 sal_Int32 nTextStart, sal_Int32 nTextLen,
809 const tools::Long* pDXArray, const SvxFont& rFont,
810 sal_Int32 nPara, sal_uInt8 nRightToLeft,
811 const EEngineData::WrongSpellVector* pWrongSpellVector,
812 const SvxFieldData* pFieldData,
813 bool bEndOfLine,
814 bool bEndOfParagraph,
815 bool bEndOfBullet,
816 const css::lang::Locale* pLocale,
817 const Color& rOverlineColor,
818 const Color& rTextLineColor);
820 void DrawingTab( const Point& rStartPos, tools::Long nWidth, const OUString& rChar,
821 const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft,
822 bool bEndOfLine,
823 bool bEndOfParagraph,
824 const Color& rOverlineColor,
825 const Color& rTextLineColor);
827 Size CalcTextSize();
828 Size CalcTextSizeNTP();
830 void SetStyleSheetPool( SfxStyleSheetPool* pSPool );
831 SfxStyleSheetPool* GetStyleSheetPool();
833 bool IsInSelectionMode() const;
835 void SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle );
836 SfxStyleSheet* GetStyleSheet( sal_Int32 nPara );
838 void SetParaAttribs( sal_Int32 nPara, const SfxItemSet& );
839 SfxItemSet const & GetParaAttribs( sal_Int32 nPara );
841 void Remove( Paragraph const * pPara, sal_Int32 nParaCount );
842 bool Expand( Paragraph const * );
843 bool Collapse( Paragraph const * );
845 void SetParaFlag( Paragraph* pPara, ParaFlag nFlag );
846 static bool HasParaFlag( const Paragraph* pPara, ParaFlag nFlag );
849 void SetControlWord( EEControlBits nWord );
850 EEControlBits GetControlWord() const;
852 const Link<Outliner*,void>& GetBeginMovingHdl() const { return aBeginMovingHdl; }
853 void SetBeginMovingHdl(const Link<Outliner*,void>& rLink) {aBeginMovingHdl=rLink;}
854 const Link<Outliner*,void>& GetEndMovingHdl() const {return aEndMovingHdl;}
855 void SetEndMovingHdl( const Link<Outliner*,void>& rLink){aEndMovingHdl=rLink;}
857 sal_uLong GetLineCount( sal_Int32 nParagraph ) const;
858 sal_Int32 GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const;
859 sal_uLong GetLineHeight( sal_Int32 nParagraph );
861 ErrCode Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat, SvKeyValueIterator* pHTTPHeaderAttrs = nullptr );
863 SfxUndoManager& GetUndoManager();
864 SfxUndoManager* SetUndoManager(SfxUndoManager* pNew);
866 void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel );
867 void QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel );
868 void QuickInsertLineBreak( const ESelection& rSel );
870 // Only for EditEngine mode
871 void QuickInsertText( const OUString& rText, const ESelection& rSel );
872 void QuickDelete( const ESelection& rSel );
873 /// Set attributes from rSet an all characters of nPara.
874 void SetCharAttribs(sal_Int32 nPara, const SfxItemSet& rSet);
875 void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich = 0 );
876 void QuickFormatDoc();
878 bool UpdateFields();
879 void RemoveFields( const std::function<bool ( const SvxFieldData* )>& isFieldData = [] (const SvxFieldData* ){return true;} );
881 virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor );
883 void SetSpeller( css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpeller );
884 css::uno::Reference< css::linguistic2::XSpellChecker1 > const &
885 GetSpeller();
886 void SetHyphenator( css::uno::Reference< css::linguistic2::XHyphenator > const & xHyph );
888 static void SetForbiddenCharsTable(const std::shared_ptr<SvxForbiddenCharactersTable>& xForbiddenChars);
890 // Deprecated
891 void SetDefaultLanguage( LanguageType eLang );
893 void CompleteOnlineSpelling();
895 EESpellState HasSpellErrors();
896 bool HasText( const SvxSearchItem& rSearchItem );
897 virtual bool SpellNextDocument();
899 // for text conversion
900 bool HasConvertibleTextPortion( LanguageType nLang );
901 virtual bool ConvertNextDocument();
903 void SetEditTextObjectPool( SfxItemPool* pPool );
904 SfxItemPool* GetEditTextObjectPool() const;
906 void SetRefDevice( OutputDevice* pRefDev );
907 OutputDevice* GetRefDevice() const;
909 sal_uLong GetTextHeight() const;
910 tools::Rectangle GetParaBounds( sal_Int32 nParagraph ) const;
911 Point GetDocPos( const Point& rPaperPos ) const;
912 bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder );
913 bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder, bool* pbBulletPos );
915 void SetGlobalCharStretching( sal_uInt16 nX = 100, sal_uInt16 nY = 100 );
916 void GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const;
917 void EraseVirtualDevice();
919 bool ShouldCreateBigTextObject() const;
921 const EditEngine& GetEditEngine() const;
923 // this is needed for StarOffice Api
924 void SetLevelDependentStyleSheet( sal_Int32 nPara );
926 OutlinerMode GetOutlinerMode() const { return nOutlinerMode; }
928 // spell and return a sentence
929 bool SpellSentence(EditView const & rEditView, svx::SpellPortions& rToFill );
930 // put spell position to start of current sentence
931 void PutSpellingToSentenceStart( EditView const & rEditView );
932 // applies a changed sentence
933 void ApplyChangedSentence(EditView const & rEditView, const svx::SpellPortions& rNewPortions, bool bRecheck );
935 /** sets a link that is called at the beginning of a drag operation at an edit view */
936 void SetBeginDropHdl( const Link<EditView*,void>& rLink );
938 /** sets a link that is called at the end of a drag operation at an edit view */
939 void SetEndDropHdl( const Link<EditView*,void>& rLink );
941 /** sets a link that is called before a drop or paste operation. */
942 void SetBeginPasteOrDropHdl( const Link<PasteOrDropInfos*,void>& rLink );
944 /** sets a link that is called after a drop or paste operation. */
945 void SetEndPasteOrDropHdl( const Link<PasteOrDropInfos*,void>& rLink );
947 sal_Int16 GetNumberingStartValue( sal_Int32 nPara );
948 void SetNumberingStartValue( sal_Int32 nPara, sal_Int16 nNumberingStartValue );
950 bool IsParaIsNumberingRestart( sal_Int32 nPara );
951 void SetParaIsNumberingRestart( sal_Int32 nPara, bool bParaIsNumberingRestart );
953 /** determine the bullets/numbering status of the given paragraphs
955 @param nParaStart
956 index of paragraph at which the check starts
958 @param nParaEnd
959 index of paragraph at which the check ends
961 @returns
962 0 : all paragraphs have bullets
963 1 : all paragraphs have numbering
964 2 : otherwise
966 sal_Int32 GetBulletsNumberingStatus(
967 const sal_Int32 nParaStart,
968 const sal_Int32 nParaEnd ) const;
970 // convenient method to determine the bullets/numbering status for all paragraphs
971 sal_Int32 GetBulletsNumberingStatus() const;
974 #endif
976 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */