Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / editeng / outliner.hxx
blob7622138271ee381bd952bee78d271fe48fe0f765
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 <editeng/overflowingtxt.hxx>
25 #include <i18nlangtag/lang.h>
26 #include <rtl/ustring.hxx>
27 #include <svl/SfxBroadcaster.hxx>
28 #include <svl/languageoptions.hxx>
29 #include <svl/undo.hxx>
30 #include <tools/gen.hxx>
31 #include <tools/color.hxx>
32 #include <utility>
33 #include <vcl/outdev.hxx>
34 #include <comphelper/errcode.hxx>
35 #include <tools/link.hxx>
36 #include <editeng/editengdllapi.h>
38 #include <vcl/GraphicObject.hxx>
40 #include <editeng/svxfont.hxx>
41 #include <editeng/eedata.hxx>
42 #include <editeng/paragraphdata.hxx>
43 #include <o3tl/typed_flags_set.hxx>
45 #include <optional>
46 #include <functional>
47 #include <memory>
48 #include <vector>
50 class OutlinerEditEng;
51 class Outliner;
52 class EditView;
53 class EditUndo;
54 class ParagraphList;
55 class OutlinerParaObject;
56 class SvStream;
57 class SvxSearchItem;
58 class SvxFieldItem;
59 namespace vcl { class Window; }
60 namespace weld { class Widget; }
61 class KeyEvent;
62 class MouseEvent;
63 class CommandEvent;
64 class MapMode;
65 class SfxStyleSheetPool;
66 class SfxStyleSheet;
67 class SfxItemPool;
68 class SfxItemSet;
69 class SvxNumberFormat;
70 class EditEngine;
71 class SvKeyValueIterator;
72 class SvxForbiddenCharactersTable;
73 class OutlinerViewShell;
74 enum class CharCompressType;
75 enum class TransliterationFlags;
76 class SvxFieldData;
77 enum class PointerStyle;
78 class SvxNumRule;
79 enum class TextRotation;
80 enum class SdrCompatibilityFlag;
82 namespace com::sun::star::linguistic2 {
83 class XSpellChecker1;
84 class XHyphenator;
86 namespace svx{
87 struct SpellPortion;
88 typedef std::vector<SpellPortion> SpellPortions;
90 namespace basegfx { class B2DPolyPolygon; }
91 namespace com::sun::star::lang { struct Locale; }
95 // internal use only!
96 enum class ParaFlag
98 NONE = 0x0000,
99 HOLDDEPTH = 0x4000,
100 ISPAGE = 0x0100,
102 namespace o3tl
104 template<> struct typed_flags<ParaFlag> : is_typed_flags<ParaFlag, 0xc100> {};
107 // Undo-Action-Ids
108 #define OLUNDO_DEPTH EDITUNDO_USER
109 // #define OLUNDO_HEIGHT EDITUNDO_USER+1
110 #define OLUNDO_EXPAND EDITUNDO_USER+2
111 #define OLUNDO_COLLAPSE EDITUNDO_USER+3
112 // #define OLUNDO_REMOVE EDITUNDO_USER+4
113 #define OLUNDO_ATTR EDITUNDO_USER+5
114 #define OLUNDO_INSERT EDITUNDO_USER+6
115 // #define OLUNDO_MOVEPARAGRAPHS EDITUNDO_USER+7
117 class Paragraph : protected ParagraphData
119 private:
120 friend class Outliner;
121 friend class ParagraphList;
122 friend class OutlinerView;
123 friend class OutlinerParaObject;
124 friend class OutlinerEditEng;
125 friend class OutlinerUndoCheckPara;
126 friend class OutlinerUndoChangeParaFlags;
128 Paragraph& operator=(const Paragraph& rPara ) = delete;
130 OUString aBulText;
131 Size aBulSize;
132 ParaFlag nFlags;
133 bool bVisible;
135 bool IsVisible() const { return bVisible; }
136 void SetText( const OUString& rText ) { aBulText = rText; aBulSize.setWidth(-1); }
137 void Invalidate() { aBulSize.setWidth(-1); }
138 void SetDepth( sal_Int16 nNewDepth ) { nDepth = nNewDepth; aBulSize.setWidth(-1); }
139 const OUString& GetText() const { return aBulText; }
141 Paragraph( sal_Int16 nDepth );
142 Paragraph( const Paragraph& ) = delete;
143 Paragraph( const ParagraphData& );
145 sal_Int16 GetDepth() const { return nDepth; }
147 sal_Int16 GetNumberingStartValue() const { return mnNumberingStartValue; }
148 void SetNumberingStartValue( sal_Int16 nNumberingStartValue );
150 bool IsParaIsNumberingRestart() const { return mbParaIsNumberingRestart; }
151 void SetParaIsNumberingRestart( bool bParaIsNumberingRestart );
153 void SetFlag( ParaFlag nFlag ) { nFlags |= nFlag; }
154 void RemoveFlag( ParaFlag nFlag ) { nFlags &= ~nFlag; }
155 bool HasFlag( ParaFlag nFlag ) const { return bool(nFlags & nFlag); }
156 public:
157 ~Paragraph();
158 void dumpAsXml(xmlTextWriterPtr pWriter) const;
161 struct ParaRange
163 sal_Int32 nStartPara;
164 sal_Int32 nEndPara;
166 ParaRange( sal_Int32 nS, sal_Int32 nE ) : nStartPara(nS), nEndPara(nE) {}
168 void Adjust();
171 inline void ParaRange::Adjust()
173 if ( nStartPara > nEndPara )
175 std::swap(nStartPara, nEndPara);
179 class EDITENG_DLLPUBLIC OutlinerView final
181 friend class Outliner;
183 Outliner* pOwner;
184 std::unique_ptr<EditView> pEditView;
186 enum class MouseTarget {
187 Text = 0,
188 Bullet = 1,
189 Hypertext = 2, // Outside OutputArea
190 Outside = 3 // Outside OutputArea
193 EDITENG_DLLPRIVATE void ImplExpandOrCollaps( sal_Int32 nStartPara, sal_Int32 nEndPara, bool bExpand );
195 EDITENG_DLLPRIVATE sal_Int32 ImpCheckMousePos( const Point& rPosPixel, MouseTarget& reTarget);
196 EDITENG_DLLPRIVATE void ImpToggleExpand( Paragraph const * pParentPara );
197 EDITENG_DLLPRIVATE ParaRange ImpGetSelectedParagraphs( bool bIncludeHiddenChildren );
199 EDITENG_DLLPRIVATE sal_Int32 ImpInitPaste( sal_Int32& rStart );
200 EDITENG_DLLPRIVATE void ImpPasted( sal_Int32 nStart, sal_Int32 nPrevParaCount, sal_Int32 nSize);
201 EDITENG_DLLPRIVATE sal_Int32 ImpCalcSelectedPages( bool bIncludeFirstSelected );
203 Link<LinkParamNone*,void> aEndCutPasteLink;
205 public:
206 OutlinerView( Outliner* pOut, vcl::Window* pWindow );
207 ~OutlinerView();
209 EditView& GetEditView() const { return *pEditView; }
211 void Scroll( tools::Long nHorzScroll, tools::Long nVertScroll );
213 void Paint( const tools::Rectangle& rRect, OutputDevice* pTargetDevice = nullptr );
214 bool PostKeyEvent( const KeyEvent& rKEvt, vcl::Window const * pFrameWin = nullptr );
215 bool MouseButtonDown( const MouseEvent& );
216 bool MouseButtonUp( const MouseEvent& );
217 void ReleaseMouse();
218 bool MouseMove( const MouseEvent& );
220 void ShowCursor( bool bGotoCursor = true, bool bActivate = false );
221 void HideCursor( bool bDeactivate = false );
223 Outliner* GetOutliner() const { return pOwner; }
225 void SetWindow( vcl::Window* pWindow );
226 vcl::Window* GetWindow() const;
228 void SetReadOnly( bool bReadOnly );
229 bool IsReadOnly() const;
231 void SetOutputArea( const tools::Rectangle& rRect );
232 tools::Rectangle const & GetOutputArea() const;
234 tools::Rectangle GetVisArea() const;
236 void CreateSelectionList (std::vector<Paragraph*> &aSelList) ;
238 void Select( Paragraph const * pParagraph, bool bSelect = true);
240 OUString GetSelected() const;
241 void SelectRange( sal_Int32 nFirst, sal_Int32 nCount );
242 void SetAttribs( const SfxItemSet& );
243 void Indent( short nDiff );
244 void AdjustDepth( short nDX ); // Later replace with Indent!
246 void AdjustHeight( tools::Long nDY );
248 void Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs );
250 void InsertText( const OUString& rNew, bool bSelect = false );
251 void InsertText( const OutlinerParaObject& rParaObj );
252 void Expand();
253 void Collapse();
254 void ExpandAll();
255 void CollapseAll();
257 void SetBackgroundColor( const Color& rColor );
258 Color const & GetBackgroundColor() const;
260 /// Informs this edit view about which view shell contains it.
261 void RegisterViewShell(OutlinerViewShell* pViewShell);
263 SfxItemSet GetAttribs();
265 void Cut();
266 void Copy();
267 void Paste( bool bUseSpecial = false );
268 void PasteSpecial();
270 const SfxStyleSheet* GetStyleSheet() const;
271 SfxStyleSheet* GetStyleSheet();
273 void SetControlWord( EVControlBits nWord );
274 EVControlBits GetControlWord() const;
276 void SetAnchorMode( EEAnchorMode eMode );
277 EEAnchorMode GetAnchorMode() const;
279 PointerStyle GetPointer( const Point& rPosPixel );
280 bool Command(const CommandEvent& rCEvt);
282 void StartSpeller(weld::Widget* pDialogParent);
283 EESpellState StartThesaurus(weld::Widget* pDialogParent);
284 sal_Int32 StartSearchAndReplace( const SvxSearchItem& rSearchItem );
286 // for text conversion
287 void StartTextConversion(weld::Widget* pDialogParent, LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc);
289 void TransliterateText( TransliterationFlags nTransliterationMode );
291 ESelection GetSelection() const;
293 SvtScriptType GetSelectedScriptType() const;
295 void SetVisArea( const tools::Rectangle& rRect );
296 void SetSelection( const ESelection& );
297 void GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects) const;
299 void RemoveAttribs( bool bRemoveParaAttribs, bool bKeepLanguages = false );
300 void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs );
301 bool HasSelection() const;
303 void InsertField( const SvxFieldItem& rFld );
304 const SvxFieldItem* GetFieldUnderMousePointer() const;
305 const SvxFieldItem* GetFieldAtSelection() const;
306 /// Return the field at the current cursor position or nullptr if no field found
307 const SvxFieldData* GetFieldAtCursor() const;
308 /// Select the field at the current cursor position
309 void SelectFieldAtCursor();
311 /** enables bullets for the selected paragraphs if the bullets/numbering of the first paragraph is off
312 or disables bullets/numbering for the selected paragraphs if the bullets/numbering of the first paragraph is on
314 void ToggleBullets();
316 void ToggleBulletsNumbering(
317 const bool bToggle,
318 const bool bHandleBullets,
319 const SvxNumRule* pNumRule );
321 /** apply bullets/numbering for paragraphs
323 @param boolean bHandleBullets
324 true: handle bullets
325 false: handle numbering
327 @param pNewNumRule
328 numbering rule which needs to be applied. can be 0.
330 @param boolean bAtSelection
331 true: apply bullets/numbering at selected paragraphs
332 false: apply bullets/numbering at all paragraphs
334 void ApplyBulletsNumbering(
335 const bool bHandleBullets,
336 const SvxNumRule* pNewNumRule,
337 const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule,
338 const bool bAtSelection = false );
340 /** switch off bullets/numbering for paragraphs
342 @param boolean bAtSelection
343 true: switch off bullets/numbering at selected paragraphs
344 false: switch off bullets/numbering at all paragraphs
346 void SwitchOffBulletsNumbering(
347 const bool bAtSelection = false );
349 /** enables numbering for the selected paragraphs that are not enabled and ignore all selected
350 paragraphs that already have numbering enabled.
352 void EnsureNumberingIsOn();
354 bool IsCursorAtWrongSpelledWord();
355 bool IsWrongSpelledWordAtPos( const Point& rPosPixel );
356 void ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbackInfo&,void>& rCallBack);
358 void SetInvalidateMore( sal_uInt16 nPixel );
359 sal_uInt16 GetInvalidateMore() const;
361 OUString GetSurroundingText() const;
362 Selection GetSurroundingTextSelection() const;
363 bool DeleteSurroundingText(const Selection& rRange);
365 void SetEndCutPasteLinkHdl(const Link<LinkParamNone*,void> &rLink) { aEndCutPasteLink = rLink; }
368 /// Interface class to not depend on SfxViewShell in editeng.
369 class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI OutlinerViewShell
371 public:
372 virtual void libreOfficeKitViewCallback(int nType, const OString& pPayload) const = 0;
373 virtual void libreOfficeKitViewCallbackWithViewId(int nType, const OString& pPayload, int nViewId) const = 0;
374 virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart, int nMode) const = 0;
375 virtual void libreOfficeKitViewUpdatedCallback(int nType) const = 0;
376 virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) const = 0;
377 virtual void libreOfficeKitViewAddPendingInvalidateTiles() = 0;
378 virtual ViewShellId GetViewShellId() const = 0;
379 virtual ViewShellDocId GetDocId() const = 0;
380 /// Wrapper around SfxLokHelper::notifyOtherViews().
381 virtual void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) = 0;
382 /// Wrapper around SfxLokHelper::notifyOtherView().
383 virtual void NotifyOtherView(OutlinerViewShell* pOtherShell, int nType, const OString& rKey, const OString& rPayload) = 0;
384 virtual vcl::Window* GetEditWindowForActiveOLEObj() const = 0;
386 protected:
387 ~OutlinerViewShell() noexcept {}
390 // some thesaurus functionality to avoid code duplication in different projects...
391 bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext( OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView );
392 void EDITENG_DLLPUBLIC ReplaceTextWithSynonym( EditView &rEditView, const OUString &rSynonmText );
394 typedef ::std::vector< OutlinerView* > ViewList;
396 class EDITENG_DLLPUBLIC DrawPortionInfo
398 public:
399 const Point& mrStartPos;
400 const OUString maText;
401 sal_Int32 mnTextStart;
402 sal_Int32 mnTextLen;
403 sal_Int32 mnPara;
404 const SvxFont& mrFont;
405 o3tl::span<const sal_Int32> mpDXArray;
406 o3tl::span<const sal_Bool> mpKashidaArray;
408 const EEngineData::WrongSpellVector* mpWrongSpellVector;
409 const SvxFieldData* mpFieldData;
410 const css::lang::Locale* mpLocale;
411 const Color maOverlineColor;
412 const Color maTextLineColor;
414 sal_uInt8 mnBiDiLevel;
416 bool mbFilled;
417 tools::Long mnWidthToFill;
419 bool mbEndOfLine : 1;
420 bool mbEndOfParagraph : 1;
421 bool mbEndOfBullet : 1;
423 bool IsRTL() const { return mnBiDiLevel % 2 == 1; }
425 DrawPortionInfo(
426 const Point& rPos,
427 OUString aTxt,
428 sal_Int32 nTxtStart,
429 sal_Int32 nTxtLen,
430 const SvxFont& rFnt,
431 sal_Int32 nPar,
432 o3tl::span<const sal_Int32> pDXArr,
433 o3tl::span<const sal_Bool> pKashidaArr,
434 const EEngineData::WrongSpellVector* pWrongSpellVector,
435 const SvxFieldData* pFieldData,
436 const css::lang::Locale* pLocale,
437 const Color& rOverlineColor,
438 const Color& rTextLineColor,
439 sal_uInt8 nBiDiLevel,
440 bool bFilled,
441 tools::Long nWidthToFill,
442 bool bEndOfLine,
443 bool bEndOfParagraph,
444 bool bEndOfBullet)
445 : mrStartPos(rPos),
446 maText(std::move(aTxt)),
447 mnTextStart(nTxtStart),
448 mnTextLen(nTxtLen),
449 mnPara(nPar),
450 mrFont(rFnt),
451 mpDXArray(pDXArr),
452 mpKashidaArray(pKashidaArr),
453 mpWrongSpellVector(pWrongSpellVector),
454 mpFieldData(pFieldData),
455 mpLocale(pLocale),
456 maOverlineColor(rOverlineColor),
457 maTextLineColor(rTextLineColor),
458 mnBiDiLevel(nBiDiLevel),
459 mbFilled( bFilled ),
460 mnWidthToFill( nWidthToFill ),
461 mbEndOfLine(bEndOfLine),
462 mbEndOfParagraph(bEndOfParagraph),
463 mbEndOfBullet(bEndOfBullet)
467 class EDITENG_DLLPUBLIC DrawBulletInfo
469 public:
470 const GraphicObject maBulletGraphicObject;
471 Point maBulletPosition;
472 Size maBulletSize;
474 DrawBulletInfo(
475 const GraphicObject& rBulletGraphicObject,
476 const Point& rBulletPosition,
477 const Size& rBulletSize)
478 : maBulletGraphicObject(rBulletGraphicObject),
479 maBulletPosition(rBulletPosition),
480 maBulletSize(rBulletSize)
484 struct EDITENG_DLLPUBLIC PaintFirstLineInfo
486 sal_Int32 mnPara;
487 const Point& mrStartPos;
488 VclPtr<OutputDevice> mpOutDev;
490 PaintFirstLineInfo( sal_Int32 nPara, const Point& rStartPos, OutputDevice* pOutDev )
491 : mnPara( nPara ), mrStartPos( rStartPos ), mpOutDev( pOutDev )
495 class SdrPage;
497 class EditFieldInfo
499 private:
500 Outliner* pOutliner;
501 const SvxFieldItem& rFldItem;
503 std::optional<Color> mxTxtColor;
504 std::optional<Color> mxFldColor;
505 std::optional<FontLineStyle> mxFldLineStyle;
507 OUString aRepresentation;
509 sal_Int32 nPara;
510 sal_Int32 nPos;
512 EditFieldInfo( const EditFieldInfo& ) = delete;
514 SdrPage* mpSdrPage;
516 public:
517 EditFieldInfo( Outliner* pOutl, const SvxFieldItem& rFItem, sal_Int32 nPa, sal_Int32 nPo )
518 : rFldItem( rFItem )
520 pOutliner = pOutl;
521 nPara = nPa; nPos = nPo;
522 mpSdrPage = nullptr;
525 Outliner* GetOutliner() const { return pOutliner; }
527 const SvxFieldItem& GetField() const { return rFldItem; }
529 std::optional<Color> const & GetTextColor() const { return mxTxtColor; }
530 void SetTextColor( std::optional<Color> xCol ) { mxTxtColor = xCol; }
532 std::optional<Color> const & GetFieldColor() const { return mxFldColor; }
533 void SetFieldColor( std::optional<Color> xCol ) { mxFldColor = xCol; }
535 std::optional<FontLineStyle> const& GetFontLineStyle() const { return mxFldLineStyle; }
536 void SetFontLineStyle( std::optional<FontLineStyle> xLineStyle ) { mxFldLineStyle = xLineStyle; }
538 sal_Int32 GetPara() const { return nPara; }
539 sal_Int32 GetPos() const { return nPos; }
541 const OUString& GetRepresentation() const { return aRepresentation; }
542 OUString& GetRepresentation() { return aRepresentation; }
543 void SetRepresentation( const OUString& rStr ){ aRepresentation = rStr; }
545 void SetSdrPage( SdrPage* pPage ) { mpSdrPage = pPage; }
546 SdrPage* GetSdrPage() const { return mpSdrPage; }
549 struct EBulletInfo
551 SvxFont aFont;
552 tools::Rectangle aBounds;
553 OUString aText;
554 sal_Int32 nParagraph;
555 sal_uInt16 nType; // see SvxNumberType
556 bool bVisible;
558 EBulletInfo() : nParagraph( EE_PARA_NOT_FOUND ), nType( 0 ), bVisible( false ) {}
561 enum class OutlinerMode {
562 DontKnow = 0x0000,
563 TextObject = 0x0001,
564 TitleObject = 0x0002,
565 OutlineObject = 0x0003,
566 OutlineView = 0x0004
569 class EDITENG_DLLPUBLIC Outliner : public SfxBroadcaster
571 public:
572 struct ParagraphHdlParam { Outliner* pOutliner; Paragraph* pPara; };
573 struct DepthChangeHdlParam { Outliner* pOutliner; Paragraph* pPara; ParaFlag nPrevFlags; };
574 private:
575 friend class OutlinerView;
576 friend class OutlinerEditEng;
577 friend class OutlinerParaObject;
578 friend class OLUndoExpand;
579 friend class OutlinerUndoChangeDepth;
580 friend class OutlinerUndoCheckPara;
581 friend class OutlinerUndoChangeParaFlags;
583 friend class TextChainingUtils;
585 std::unique_ptr<OutlinerEditEng> pEditEngine;
587 std::unique_ptr<ParagraphList> pParaList;
588 ViewList aViewList;
590 sal_Int32 mnFirstSelPage;
591 Link<DrawPortionInfo*,void> aDrawPortionHdl;
592 Link<DrawBulletInfo*,void> aDrawBulletHdl;
593 Link<ParagraphHdlParam,void> aParaInsertedHdl;
594 Link<ParagraphHdlParam,void> aParaRemovingHdl;
595 Link<DepthChangeHdlParam,void> aDepthChangedHdl;
596 Link<Outliner*,void> aBeginMovingHdl;
597 Link<Outliner*,void> aEndMovingHdl;
598 Link<OutlinerView*,bool> aIndentingPagesHdl;
599 Link<OutlinerView*,bool> aRemovingPagesHdl;
600 Link<EditFieldInfo*,void> aCalcFieldValueHdl;
601 Link<PaintFirstLineInfo*,void> maPaintFirstLineHdl;
602 Link<PasteOrDropInfos*,void> maBeginPasteOrDropHdl;
603 Link<PasteOrDropInfos*,void> maEndPasteOrDropHdl;
605 sal_Int32 nDepthChangedHdlPrevDepth;
606 sal_Int16 nMaxDepth;
607 static constexpr sal_Int16 gnMinDepth = -1;
609 OutlinerMode nOutlinerMode;
611 bool bFirstParaIsEmpty;
612 sal_uInt8 nBlockInsCallback;
613 bool bStrippingPortions;
614 bool bPasting;
616 DECL_DLLPRIVATE_LINK( ParaVisibleStateChangedHdl, Paragraph&, void );
617 DECL_DLLPRIVATE_LINK( BeginMovingParagraphsHdl, MoveParagraphsInfo&, void );
618 DECL_DLLPRIVATE_LINK( EndMovingParagraphsHdl, MoveParagraphsInfo&, void );
619 DECL_DLLPRIVATE_LINK( BeginPasteOrDropHdl, PasteOrDropInfos&, void );
620 DECL_DLLPRIVATE_LINK( EndPasteOrDropHdl, PasteOrDropInfos&, void );
621 DECL_DLLPRIVATE_LINK( EditEngineNotifyHdl, EENotify&, void );
622 void ImplCheckParagraphs( sal_Int32 nStart, sal_Int32 nEnd );
623 bool ImplHasNumberFormat( sal_Int32 nPara ) const;
624 Size ImplGetBulletSize( sal_Int32 nPara );
625 sal_uInt16 ImplGetNumbering( sal_Int32 nPara, const SvxNumberFormat* pParaFmt );
626 void ImplCalcBulletText( sal_Int32 nPara, bool bRecalcLevel, bool bRecalcChildren );
627 OUString ImplGetBulletText( sal_Int32 nPara );
628 void ImplCheckNumBulletItem( sal_Int32 nPara );
629 void ImplInitDepth( sal_Int32 nPara, sal_Int16 nDepth, bool bCreateUndo );
630 void ImplSetLevelDependentStyleSheet( sal_Int32 nPara );
632 void ImplBlockInsertionCallbacks( bool b );
634 void ImpFilterIndents( sal_Int32 nFirstPara, sal_Int32 nLastPara );
635 bool ImpConvertEdtToOut( sal_Int32 nPara );
637 void ImpTextPasted( sal_Int32 nStartPara, sal_Int32 nCount );
638 vcl::Font ImpCalcBulletFont( sal_Int32 nPara ) const;
639 tools::Rectangle ImpCalcBulletArea( sal_Int32 nPara, bool bAdjust, bool bReturnPaperPos );
640 bool ImpCanIndentSelectedPages( OutlinerView* pCurView );
641 bool ImpCanDeleteSelectedPages( OutlinerView* pCurView );
642 bool ImpCanDeleteSelectedPages( OutlinerView* pCurView, sal_Int32 nFirstPage, sal_Int32 nPages );
644 void ImplCheckDepth( sal_Int16& rnDepth ) const;
646 protected:
647 void ParagraphInserted( sal_Int32 nParagraph );
648 void ParagraphDeleted( sal_Int32 nParagraph );
649 void ParaAttribsChanged( sal_Int32 nParagraph );
651 void StyleSheetChanged( SfxStyleSheet const * pStyle );
653 void InvalidateBullet(sal_Int32 nPara);
654 void PaintBullet(sal_Int32 nPara, const Point& rStartPos,
655 const Point& rOrigin, Degree10 nOrientation,
656 OutputDevice& rOutDev);
658 // used by OutlinerEditEng. Allows Outliner objects to provide
659 // bullet access to the EditEngine.
660 const SvxNumberFormat* GetNumberFormat( sal_Int32 nPara ) const;
662 public:
664 Outliner( SfxItemPool* pPool, OutlinerMode nMode );
665 virtual ~Outliner() override;
667 void dumpAsXml(xmlTextWriterPtr pWriter) const;
669 void Init( OutlinerMode nMode );
671 void SetVertical( bool bVertical);
672 void SetRotation(TextRotation nRotation);
673 bool IsVertical() const;
674 bool IsTopToBottom() const;
676 void SetTextColumns(sal_Int16 nColumns, sal_Int32 nSpacing);
678 void SetFixedCellHeight( bool bUseFixedCellHeight );
680 void SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir );
681 EEHorizontalTextDirection GetDefaultHorizontalTextDirection() const;
683 LanguageType GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const;
685 void SetAsianCompressionMode( CharCompressType nCompressionMode );
687 void SetKernAsianPunctuation( bool bEnabled );
689 void SetAddExtLeading( bool b );
691 size_t InsertView( OutlinerView* pView, size_t nIndex = size_t(-1) );
692 void RemoveView( OutlinerView const * pView );
693 void RemoveView( size_t nIndex );
694 OutlinerView* GetView( size_t nIndex ) const;
695 size_t GetViewCount() const;
697 Paragraph* Insert( const OUString& rText, sal_Int32 nAbsPos = EE_PARA_APPEND, sal_Int16 nDepth = 0 );
698 void SetText( const OutlinerParaObject& );
699 void AddText( const OutlinerParaObject&, bool bAppend = false );
700 void SetText( const OUString& rText, Paragraph* pParagraph );
701 OUString GetText( Paragraph const * pPara, sal_Int32 nParaCount=1 ) const;
703 void SetToEmptyText();
705 std::optional<OutlinerParaObject> CreateParaObject( sal_Int32 nStartPara = 0, sal_Int32 nParaCount = EE_PARA_ALL ) const;
707 const SfxItemSet& GetEmptyItemSet() const;
709 void SetRefMapMode( const MapMode& );
710 MapMode const & GetRefMapMode() const;
712 void SetBackgroundColor( const Color& rColor );
713 Color const & GetBackgroundColor() const;
715 void SetMaxDepth( sal_Int16 nDepth );
716 sal_Int16 GetMaxDepth() const { return nMaxDepth; }
718 /// @return previous value of bUpdateLayout state
719 bool SetUpdateLayout( bool bUpdate );
720 bool IsUpdateLayout() const;
722 void Clear();
724 void RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich );
726 sal_Int32 GetParagraphCount() const;
727 Paragraph* GetParagraph( sal_Int32 nAbsPos ) const;
729 bool HasChildren( Paragraph const * pParagraph ) const;
730 sal_Int32 GetChildCount( Paragraph const * pParent ) const;
731 bool IsExpanded( Paragraph const * pPara ) const;
732 Paragraph* GetParent( Paragraph const * pParagraph ) const;
733 sal_Int32 GetAbsPos( Paragraph const * pPara ) const;
735 sal_Int16 GetDepth( sal_Int32 nPara ) const;
736 void SetDepth( Paragraph* pParagraph, sal_Int16 nNewDepth );
738 void EnableUndo( bool bEnable );
739 bool IsUndoEnabled() const;
740 void UndoActionStart( sal_uInt16 nId );
741 void UndoActionEnd();
742 void InsertUndo( std::unique_ptr<EditUndo> pUndo );
743 bool IsInUndo() const;
745 void ClearModifyFlag();
746 bool IsModified() const;
748 void ParagraphInsertedHdl(Paragraph*);
749 void SetParaInsertedHdl(const Link<ParagraphHdlParam,void>& rLink){aParaInsertedHdl=rLink;}
750 const Link<ParagraphHdlParam,void>& GetParaInsertedHdl() const { return aParaInsertedHdl; }
752 void SetParaRemovingHdl(const Link<ParagraphHdlParam,void>& rLink){aParaRemovingHdl=rLink;}
753 const Link<ParagraphHdlParam,void>& GetParaRemovingHdl() const { return aParaRemovingHdl; }
755 std::optional<NonOverflowingText> GetNonOverflowingText() const;
756 std::optional<OverflowingText> GetOverflowingText() const;
757 void ClearOverflowingParaNum();
758 bool IsPageOverflow();
760 OutlinerParaObject GetEmptyParaObject() const;
763 void DepthChangedHdl(Paragraph*, ParaFlag nPrevFlags);
764 void SetDepthChangedHdl(const Link<DepthChangeHdlParam,void>& rLink){aDepthChangedHdl=rLink;}
765 const Link<DepthChangeHdlParam,void>& GetDepthChangedHdl() const { return aDepthChangedHdl; }
766 sal_Int16 GetPrevDepth() const { return static_cast<sal_Int16>(nDepthChangedHdlPrevDepth); }
768 bool RemovingPagesHdl( OutlinerView* );
769 void SetRemovingPagesHdl(const Link<OutlinerView*,bool>& rLink){aRemovingPagesHdl=rLink;}
770 bool IndentingPagesHdl( OutlinerView* );
771 void SetIndentingPagesHdl(const Link<OutlinerView*,bool>& rLink){aIndentingPagesHdl=rLink;}
772 // valid only in the two upper handlers
773 sal_Int32 GetSelPageCount() const { return nDepthChangedHdlPrevDepth; }
775 void SetCalcFieldValueHdl(const Link<EditFieldInfo*,void>& rLink ) { aCalcFieldValueHdl= rLink; }
776 const Link<EditFieldInfo*,void>& GetCalcFieldValueHdl() const { return aCalcFieldValueHdl; }
778 void SetDrawPortionHdl(const Link<DrawPortionInfo*,void>& rLink){aDrawPortionHdl=rLink;}
780 void SetDrawBulletHdl(const Link<DrawBulletInfo*,void>& rLink){aDrawBulletHdl=rLink;}
782 void SetPaintFirstLineHdl(const Link<PaintFirstLineInfo*,void>& rLink) { maPaintFirstLineHdl = rLink; }
784 void SetModifyHdl( const Link<LinkParamNone*,void>& rLink );
785 Link<LinkParamNone*,void> const & GetModifyHdl() const;
787 void SetNotifyHdl( const Link<EENotify&,void>& rLink );
789 void SetStatusEventHdl( const Link<EditStatus&, void>& rLink );
790 Link<EditStatus&, void> const & GetStatusEventHdl() const;
792 void Draw( OutputDevice& rOutDev, const tools::Rectangle& rOutRect );
793 void Draw( OutputDevice& rOutDev, const Point& rStartPos );
795 const Size& GetPaperSize() const;
796 void SetPaperSize( const Size& rSize );
798 void SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon );
799 void SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DPolyPolygon* pLinePolyPolygon);
800 void ClearPolygon();
802 const Size& GetMinAutoPaperSize() const;
803 void SetMinAutoPaperSize( const Size& rSz );
805 const Size& GetMaxAutoPaperSize() const;
806 void SetMaxAutoPaperSize( const Size& rSz );
808 void SetMinColumnWrapHeight(tools::Long nVal);
810 void SetDefTab( sal_uInt16 nTab );
812 bool IsFlatMode() const;
813 void SetFlatMode( bool bFlat );
815 void EnableAutoColor( bool b );
817 void ForceAutoColor( bool b );
818 bool IsForceAutoColor() const;
820 EBulletInfo GetBulletInfo( sal_Int32 nPara );
822 void SetWordDelimiters( const OUString& rDelimiters );
823 OUString const & GetWordDelimiters() const;
824 OUString GetWord( sal_Int32 nPara, sal_Int32 nIndex );
826 void StripPortions();
828 void DrawingText( const Point& rStartPos, const OUString& rText,
829 sal_Int32 nTextStart, sal_Int32 nTextLen,
830 o3tl::span<const sal_Int32> pDXArray,
831 o3tl::span<const sal_Bool> pKashidaArray,
832 const SvxFont& rFont,
833 sal_Int32 nPara, sal_uInt8 nRightToLeft,
834 const EEngineData::WrongSpellVector* pWrongSpellVector,
835 const SvxFieldData* pFieldData,
836 bool bEndOfLine,
837 bool bEndOfParagraph,
838 bool bEndOfBullet,
839 const css::lang::Locale* pLocale,
840 const Color& rOverlineColor,
841 const Color& rTextLineColor);
843 void DrawingTab( const Point& rStartPos, tools::Long nWidth, const OUString& rChar,
844 const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft,
845 bool bEndOfLine,
846 bool bEndOfParagraph,
847 const Color& rOverlineColor,
848 const Color& rTextLineColor);
850 Size CalcTextSize();
851 Size CalcTextSizeNTP();
853 void SetStyleSheetPool( SfxStyleSheetPool* pSPool );
854 SfxStyleSheetPool* GetStyleSheetPool();
856 bool IsInSelectionMode() const;
858 void SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle );
859 SfxStyleSheet* GetStyleSheet( sal_Int32 nPara );
861 void SetParaAttribs( sal_Int32 nPara, const SfxItemSet& );
862 SfxItemSet const & GetParaAttribs( sal_Int32 nPara ) const;
864 void Remove( Paragraph const * pPara, sal_Int32 nParaCount );
865 bool Expand( Paragraph const * );
866 bool Collapse( Paragraph const * );
868 void SetParaFlag( Paragraph* pPara, ParaFlag nFlag );
869 static bool HasParaFlag( const Paragraph* pPara, ParaFlag nFlag );
872 void SetControlWord( EEControlBits nWord );
873 EEControlBits GetControlWord() const;
875 const Link<Outliner*,void>& GetBeginMovingHdl() const { return aBeginMovingHdl; }
876 void SetBeginMovingHdl(const Link<Outliner*,void>& rLink) {aBeginMovingHdl=rLink;}
877 const Link<Outliner*,void>& GetEndMovingHdl() const {return aEndMovingHdl;}
878 void SetEndMovingHdl( const Link<Outliner*,void>& rLink){aEndMovingHdl=rLink;}
880 sal_uInt32 GetLineCount( sal_Int32 nParagraph ) const;
881 sal_Int32 GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const;
882 sal_uInt32 GetLineHeight( sal_Int32 nParagraph );
884 ErrCode Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat, SvKeyValueIterator* pHTTPHeaderAttrs = nullptr );
886 SfxUndoManager& GetUndoManager();
887 SfxUndoManager* SetUndoManager(SfxUndoManager* pNew);
889 void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel );
890 void QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel );
891 void QuickInsertLineBreak( const ESelection& rSel );
893 // Only for EditEngine mode
894 void QuickInsertText( const OUString& rText, const ESelection& rSel );
895 void QuickDelete( const ESelection& rSel );
896 /// Set attributes from rSet an all characters of nPara.
897 void SetCharAttribs(sal_Int32 nPara, const SfxItemSet& rSet);
898 void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich = 0 );
899 void QuickFormatDoc();
901 bool UpdateFields();
902 void RemoveFields( const std::function<bool ( const SvxFieldData* )>& isFieldData = [] (const SvxFieldData* ){return true;} );
904 virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor, std::optional<FontLineStyle>& rFldLineStyle );
906 void SetSpeller( css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpeller );
907 css::uno::Reference< css::linguistic2::XSpellChecker1 > const &
908 GetSpeller();
909 void SetHyphenator( css::uno::Reference< css::linguistic2::XHyphenator > const & xHyph );
911 static void SetForbiddenCharsTable(const std::shared_ptr<SvxForbiddenCharactersTable>& xForbiddenChars);
913 // Deprecated
914 void SetDefaultLanguage( LanguageType eLang );
916 void CompleteOnlineSpelling();
918 EESpellState HasSpellErrors();
919 bool HasText( const SvxSearchItem& rSearchItem );
920 virtual bool SpellNextDocument();
922 // for text conversion
923 bool HasConvertibleTextPortion( LanguageType nLang );
924 virtual bool ConvertNextDocument();
926 void SetEditTextObjectPool( SfxItemPool* pPool );
927 SfxItemPool* GetEditTextObjectPool() const;
929 void SetRefDevice( OutputDevice* pRefDev );
930 OutputDevice* GetRefDevice() const;
932 sal_uInt32 GetTextHeight() const;
933 tools::Rectangle GetParaBounds( sal_Int32 nParagraph ) const;
934 Point GetDocPos( const Point& rPaperPos ) const;
935 bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder );
936 bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder, bool* pbBulletPos );
938 void setGlobalScale(double rFontX = 100.0, double rFontY = 100.0, double rSpacingX = 100.0, double rSpacingY = 100.0);
939 void getGlobalScale(double& rFontX, double& rFontY, double& rSpacingX, double& rSpacingY) const;
940 void setRoundFontSizeToPt(bool bRound) const;
942 void EraseVirtualDevice();
944 bool ShouldCreateBigTextObject() const;
946 const EditEngine& GetEditEngine() const;
948 // this is needed for StarOffice Api
949 void SetLevelDependentStyleSheet( sal_Int32 nPara );
951 OutlinerMode GetOutlinerMode() const { return nOutlinerMode; }
953 // spell and return a sentence
954 bool SpellSentence(EditView const & rEditView, svx::SpellPortions& rToFill );
955 // put spell position to start of current sentence
956 void PutSpellingToSentenceStart( EditView const & rEditView );
957 // applies a changed sentence
958 void ApplyChangedSentence(EditView const & rEditView, const svx::SpellPortions& rNewPortions, bool bRecheck );
960 /** sets a link that is called at the beginning of a drag operation at an edit view */
961 void SetBeginDropHdl( const Link<EditView*,void>& rLink );
963 /** sets a link that is called at the end of a drag operation at an edit view */
964 void SetEndDropHdl( const Link<EditView*,void>& rLink );
966 /** sets a link that is called before a drop or paste operation. */
967 void SetBeginPasteOrDropHdl( const Link<PasteOrDropInfos*,void>& rLink );
969 /** sets a link that is called after a drop or paste operation. */
970 void SetEndPasteOrDropHdl( const Link<PasteOrDropInfos*,void>& rLink );
972 sal_Int16 GetNumberingStartValue( sal_Int32 nPara ) const;
973 void SetNumberingStartValue( sal_Int32 nPara, sal_Int16 nNumberingStartValue );
975 bool IsParaIsNumberingRestart( sal_Int32 nPara ) const;
976 void SetParaIsNumberingRestart( sal_Int32 nPara, bool bParaIsNumberingRestart );
978 /** determine the bullets/numbering status of the given paragraphs
980 @param nParaStart
981 index of paragraph at which the check starts
983 @param nParaEnd
984 index of paragraph at which the check ends
986 @returns
987 0 : all paragraphs have bullets
988 1 : all paragraphs have numbering
989 2 : otherwise
991 sal_Int32 GetBulletsNumberingStatus(
992 const sal_Int32 nParaStart,
993 const sal_Int32 nParaEnd ) const;
995 // convenient method to determine the bullets/numbering status for all paragraphs
996 sal_Int32 GetBulletsNumberingStatus() const;
998 // overridden in SdrOutliner
999 virtual std::optional<bool> GetCompatFlag(SdrCompatibilityFlag /*eFlag*/) const { return {}; };
1002 #endif
1004 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */