Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_EDITENG_OUTLINER_HXX
20 : #define INCLUDED_EDITENG_OUTLINER_HXX
21 :
22 : #include <editeng/editdata.hxx>
23 : #include <editeng/editstat.hxx>
24 : #include <editeng/numitem.hxx>
25 : #include <i18nlangtag/lang.h>
26 : #include <rtl/ustring.hxx>
27 : #include <svl/SfxBroadcaster.hxx>
28 : #include <svl/languageoptions.hxx>
29 : #include <tools/gen.hxx>
30 : #include <tools/color.hxx>
31 : #include <tools/contnr.hxx>
32 : #include <vcl/graph.hxx>
33 : #include <vcl/outdev.hxx>
34 : #include <tools/link.hxx>
35 : #include <rsc/rscsfx.hxx>
36 : #include <editeng/editengdllapi.h>
37 : #include <com/sun/star/lang/Locale.hpp>
38 :
39 : #include <svtools/grfmgr.hxx>
40 :
41 : #include <tools/rtti.hxx>
42 : #define LOK_USE_UNSTABLE_API
43 : #include <LibreOfficeKit/LibreOfficeKitTypes.h>
44 : #include <vector>
45 :
46 : class OutlinerEditEng;
47 : class Outliner;
48 : class EditView;
49 : class EditUndo;
50 : class ParagraphList;
51 : class OutlinerParaObject;
52 : class SvStream;
53 : class SvxBulletItem;
54 : class SvxFont;
55 : class SvxSearchItem;
56 : class SvxFieldItem;
57 : namespace vcl { class Window; }
58 : class KeyEvent;
59 : class MouseEvent;
60 : class Pointer;
61 : class CommandEvent;
62 : class MapMode;
63 : class OutputDevice;
64 : namespace tools { class PolyPolygon; }
65 : class SfxStyleSheetPool;
66 : class SfxStyleSheet;
67 : class SfxItemPool;
68 : class SfxItemSet;
69 : class SvxNumBulletItem;
70 : class SvxNumberFormat;
71 : class SvxLRSpaceItem;
72 : class EditEngine;
73 : class SvKeyValueIterator;
74 : class SvxForbiddenCharactersTable;
75 :
76 : namespace svl
77 : {
78 : class IUndoManager;
79 : }
80 :
81 : #include <com/sun/star/uno/Reference.h>
82 :
83 : #include <rtl/ref.hxx>
84 : #include <editeng/svxfont.hxx>
85 : #include <editeng/eedata.hxx>
86 : #include <editeng/paragraphdata.hxx>
87 : #include <o3tl/typed_flags_set.hxx>
88 :
89 : class SvxFieldData;
90 :
91 :
92 : namespace com { namespace sun { namespace star { namespace linguistic2 {
93 : class XSpellChecker1;
94 : class XHyphenator;
95 : }}}}
96 : namespace svx{
97 : struct SpellPortion;
98 : typedef std::vector<SpellPortion> SpellPortions;
99 : }
100 :
101 : namespace basegfx { class B2DPolyPolygon; }
102 :
103 : // internal use only!
104 : enum class ParaFlag
105 : {
106 : NONE = 0x0000,
107 : HOLDDEPTH = 0x4000,
108 : SETBULLETTEXT = 0x8000,
109 : ISPAGE = 0x0100,
110 : };
111 : namespace o3tl
112 : {
113 : template<> struct typed_flags<ParaFlag> : is_typed_flags<ParaFlag, 0xc100> {};
114 : }
115 :
116 : // Undo-Action-Ids
117 : #define OLUNDO_DEPTH EDITUNDO_USER
118 : // #define OLUNDO_HEIGHT EDITUNDO_USER+1
119 : #define OLUNDO_EXPAND EDITUNDO_USER+2
120 : #define OLUNDO_COLLAPSE EDITUNDO_USER+3
121 : // #define OLUNDO_REMOVE EDITUNDO_USER+4
122 : #define OLUNDO_ATTR EDITUNDO_USER+5
123 : #define OLUNDO_INSERT EDITUNDO_USER+6
124 : // #define OLUNDO_MOVEPARAGRAPHS EDITUNDO_USER+7
125 :
126 : class Paragraph : protected ParagraphData
127 : {
128 : private:
129 : friend class Outliner;
130 : friend class ParagraphList;
131 : friend class OutlinerView;
132 : friend class OutlinerParaObject;
133 : friend class OutlinerEditEng;
134 : friend class OutlinerUndoCheckPara;
135 : friend class OutlinerUndoChangeParaFlags;
136 :
137 : Paragraph& operator=(const Paragraph& rPara ) SAL_DELETED_FUNCTION;
138 :
139 : ParaFlag nFlags;
140 : OUString aBulText;
141 : Size aBulSize;
142 : bool bVisible;
143 :
144 786 : bool IsVisible() const { return bVisible; }
145 9901 : void SetText( const OUString& rText ) { aBulText = rText; aBulSize.Width() = -1; }
146 1079971 : void Invalidate() { aBulSize.Width() = -1; }
147 1433356 : void SetDepth( sal_Int16 nNewDepth ) { nDepth = nNewDepth; aBulSize.Width() = -1; }
148 1779118 : const OUString& GetText() const { return aBulText; }
149 :
150 : Paragraph( sal_Int16 nDepth );
151 : Paragraph( const Paragraph& ) SAL_DELETED_FUNCTION;
152 : Paragraph( const ParagraphData& );
153 : ~Paragraph();
154 :
155 3410558 : sal_Int16 GetDepth() const { return nDepth; }
156 :
157 665 : sal_Int16 GetNumberingStartValue() const { return mnNumberingStartValue; }
158 : void SetNumberingStartValue( sal_Int16 nNumberingStartValue );
159 :
160 673 : bool IsParaIsNumberingRestart() const { return mbParaIsNumberingRestart; }
161 : void SetParaIsNumberingRestart( bool bParaIsNumberingRestart );
162 :
163 0 : void SetFlag( ParaFlag nFlag ) { nFlags |= nFlag; }
164 0 : void RemoveFlag( ParaFlag nFlag ) { nFlags &= ~nFlag; }
165 291 : bool HasFlag( ParaFlag nFlag ) const { return bool(nFlags & nFlag); }
166 : };
167 :
168 : struct ParaRange
169 : {
170 : sal_Int32 nStartPara;
171 : sal_Int32 nEndPara;
172 :
173 181 : ParaRange( sal_Int32 nS, sal_Int32 nE ) { nStartPara = nS, nEndPara = nE; }
174 :
175 : void Adjust();
176 : sal_Int32 Len() const { return 1 + ( ( nEndPara > nStartPara ) ? (nEndPara-nStartPara) : (nStartPara-nEndPara) ); }
177 : };
178 :
179 181 : inline void ParaRange::Adjust()
180 : {
181 181 : if ( nStartPara > nEndPara )
182 : {
183 0 : sal_Int32 nTmp = nStartPara;
184 0 : nStartPara = nEndPara;
185 0 : nEndPara = nTmp;
186 : }
187 181 : }
188 :
189 : class EDITENG_DLLPUBLIC OutlinerView
190 : {
191 : friend class Outliner;
192 :
193 : private:
194 :
195 : Outliner* pOwner;
196 : EditView* pEditView;
197 :
198 : enum class MouseTarget {
199 : Text = 0,
200 : Bullet = 1,
201 : Hypertext = 2, // Outside OutputArea
202 : Outside = 3, // Outside OutputArea
203 : DontKnow = 4
204 : };
205 :
206 : EDITENG_DLLPRIVATE void ImplExpandOrCollaps( sal_Int32 nStartPara, sal_Int32 nEndPara, bool bExpand );
207 :
208 : EDITENG_DLLPRIVATE sal_Int32 ImpCheckMousePos( const Point& rPosPixel, MouseTarget& reTarget);
209 : EDITENG_DLLPRIVATE void ImpToggleExpand( Paragraph* pParentPara );
210 : EDITENG_DLLPRIVATE ParaRange ImpGetSelectedParagraphs( bool bIncludeHiddenChildren );
211 :
212 : EDITENG_DLLPRIVATE sal_Int32 ImpInitPaste( sal_Int32& rStart );
213 : EDITENG_DLLPRIVATE void ImpPasted( sal_Int32 nStart, sal_Int32 nPrevParaCount, sal_Int32 nSize);
214 : EDITENG_DLLPRIVATE sal_Int32 ImpCalcSelectedPages( bool bIncludeFirstSelected );
215 :
216 : public:
217 : OutlinerView( Outliner* pOut, vcl::Window* pWindow );
218 : virtual ~OutlinerView();
219 :
220 179 : EditView& GetEditView() const { return *pEditView; }
221 :
222 : void Scroll( long nHorzScroll, long nVertScroll );
223 :
224 : void Paint( const Rectangle& rRect, OutputDevice* pTargetDevice = 0 );
225 : bool PostKeyEvent( const KeyEvent& rKEvt, vcl::Window* pFrameWin = NULL );
226 : bool MouseButtonDown( const MouseEvent& );
227 : bool MouseButtonUp( const MouseEvent& );
228 : void ReleaseMouse();
229 : bool MouseMove( const MouseEvent& );
230 :
231 : void ShowCursor( bool bGotoCursor = true );
232 : void HideCursor();
233 :
234 2 : Outliner* GetOutliner() const { return pOwner; }
235 :
236 : void SetWindow( vcl::Window* pWindow );
237 : vcl::Window* GetWindow() const;
238 :
239 : void SetReadOnly( bool bReadOnly );
240 : bool IsReadOnly() const;
241 :
242 : void SetOutputArea( const Rectangle& rRect );
243 : Rectangle GetOutputArea() const;
244 :
245 : Rectangle GetVisArea() const;
246 :
247 : void CreateSelectionList (std::vector<Paragraph*> &aSelList) ;
248 :
249 : // Retruns the number of selected paragraphs
250 : sal_Int32 Select( Paragraph* pParagraph,
251 : bool bSelect = true,
252 : bool bWChildren = true);
253 :
254 : OUString GetSelected() const;
255 : void SelectRange( sal_Int32 nFirst, sal_Int32 nCount );
256 : void SetAttribs( const SfxItemSet& );
257 : void Indent( short nDiff );
258 : void AdjustDepth( short nDX ); // Later replace with Indent!
259 :
260 : bool AdjustHeight( long nDY );
261 :
262 : sal_uLong Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, bool bSelect = false, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );
263 :
264 : void InsertText( const OUString& rNew, bool bSelect = false );
265 : void InsertText( const OutlinerParaObject& rParaObj );
266 : void Expand();
267 : void Collapse();
268 : void ExpandAll();
269 : void CollapseAll();
270 :
271 : void SetBackgroundColor( const Color& rColor );
272 : Color GetBackgroundColor();
273 :
274 : /// Set if we are doing tiled rendering.
275 : void setTiledRendering(bool bTiledRendering);
276 : /// @see vcl::ITiledRenderable::registerCallback().
277 : void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
278 :
279 : SfxItemSet GetAttribs();
280 :
281 : void Cut();
282 : void Copy();
283 : void Paste();
284 : void PasteSpecial();
285 :
286 : const SfxStyleSheet* GetStyleSheet() const;
287 : SfxStyleSheet* GetStyleSheet();
288 :
289 : void SetControlWord( EVControlBits nWord );
290 : EVControlBits GetControlWord() const;
291 :
292 : void SetAnchorMode( EVAnchorMode eMode );
293 : EVAnchorMode GetAnchorMode() const;
294 :
295 : Pointer GetPointer( const Point& rPosPixel );
296 : void Command( const CommandEvent& rCEvt );
297 :
298 : EESpellState StartSpeller( bool bMultipleDoc = false );
299 : EESpellState StartThesaurus();
300 : sal_Int32 StartSearchAndReplace( const SvxSearchItem& rSearchItem );
301 :
302 : // for text conversion
303 : void StartTextConversion( LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc );
304 :
305 : void TransliterateText( sal_Int32 nTransliterationMode );
306 :
307 : ESelection GetSelection();
308 :
309 : SvtScriptType GetSelectedScriptType() const;
310 :
311 : void SetVisArea( const Rectangle& rRect );
312 : void SetSelection( const ESelection& );
313 :
314 : void RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0, bool bKeepLanguages = false );
315 : void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs );
316 : bool HasSelection() const;
317 :
318 : void InsertField( const SvxFieldItem& rFld );
319 : const SvxFieldItem* GetFieldUnderMousePointer() const;
320 : const SvxFieldItem* GetFieldAtSelection() const;
321 :
322 : /** enables bullets for the selected paragraphs if the bullets/numbering of the first paragraph is off
323 : or disables bullets/numbering for the selected paragraphs if the bullets/numbering of the first paragraph is on
324 : */
325 : void ToggleBullets();
326 :
327 : void ToggleBulletsNumbering(
328 : const bool bToggle,
329 : const bool bHandleBullets,
330 : const SvxNumRule* pNumRule = NULL );
331 :
332 : /** apply bullets/numbering for paragraphs
333 :
334 : @param boolean bHandleBullets
335 : true: handle bullets
336 : false: handle numbering
337 :
338 : @param pNewNumRule
339 : numbering rule which needs to be applied. can be 0.
340 :
341 : @param boolean bAtSelection
342 : true: apply bullets/numbering at selected paragraphs
343 : false: apply bullets/numbering at all paragraphs
344 : */
345 : void ApplyBulletsNumbering(
346 : const bool bHandleBullets,
347 : const SvxNumRule* pNewNumRule,
348 : const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule,
349 : const bool bAtSelection = false );
350 :
351 : /** switch off bullets/numbering for paragraphs
352 :
353 : @param boolean bAtSelection
354 : true: switch off bullets/numbering at selected paragraphs
355 : false: switch off bullets/numbering at all paragraphs
356 : */
357 : void SwitchOffBulletsNumbering(
358 : const bool bAtSelection = false );
359 :
360 : /** enables numbering for the selected paragraphs that are not enabled and ignore all selected
361 : paragraphs that already have numbering enabled.
362 : */
363 : void EnableBullets();
364 :
365 : bool IsCursorAtWrongSpelledWord( bool bMarkIfWrong = false );
366 : bool IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong = false );
367 : void ExecuteSpellPopup( const Point& rPosPixel, Link<>* pCallBack = 0 );
368 :
369 : void SetInvalidateMore( sal_uInt16 nPixel );
370 : sal_uInt16 GetInvalidateMore() const;
371 :
372 : OUString GetSurroundingText() const;
373 : Selection GetSurroundingTextSelection() const;
374 : };
375 :
376 :
377 : // some thesaurus functionality to avoid code duplication in different projects...
378 : bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext( OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView );
379 : void EDITENG_DLLPUBLIC ReplaceTextWithSynonym( EditView &rEditView, const OUString &rSynonmText );
380 :
381 : typedef ::std::vector< OutlinerView* > ViewList;
382 :
383 23789 : class EDITENG_DLLPUBLIC DrawPortionInfo
384 : {
385 : public:
386 : const Point& mrStartPos;
387 : const OUString maText;
388 : sal_Int32 mnTextStart;
389 : sal_Int32 mnTextLen;
390 : sal_Int32 mnPara;
391 : sal_Int32 mnIndex;
392 : const SvxFont& mrFont;
393 : const long* mpDXArray;
394 :
395 : const EEngineData::WrongSpellVector* mpWrongSpellVector;
396 : const SvxFieldData* mpFieldData;
397 : const ::com::sun::star::lang::Locale* mpLocale;
398 : const Color maOverlineColor;
399 : const Color maTextLineColor;
400 :
401 : sal_uInt8 mnBiDiLevel;
402 :
403 : bool mbFilled;
404 : long mnWidthToFill;
405 :
406 : // bitfield
407 : bool mbEndOfLine : 1;
408 : bool mbEndOfParagraph : 1;
409 : bool mbEndOfBullet : 1;
410 :
411 : sal_uInt8 GetBiDiLevel() const { return mnBiDiLevel; }
412 22987 : bool IsRTL() const { return mnBiDiLevel % 2 == 1; }
413 :
414 23789 : DrawPortionInfo(
415 : const Point& rPos,
416 : const OUString& rTxt,
417 : sal_Int32 nTxtStart,
418 : sal_Int32 nTxtLen,
419 : const SvxFont& rFnt,
420 : sal_Int32 nPar,
421 : sal_Int32 nIdx,
422 : const long* pDXArr,
423 : const EEngineData::WrongSpellVector* pWrongSpellVector,
424 : const SvxFieldData* pFieldData,
425 : const ::com::sun::star::lang::Locale* pLocale,
426 : const Color& rOverlineColor,
427 : const Color& rTextLineColor,
428 : sal_uInt8 nBiDiLevel,
429 : bool bFilled,
430 : long nWidthToFill,
431 : bool bEndOfLine,
432 : bool bEndOfParagraph,
433 : bool bEndOfBullet)
434 : : mrStartPos(rPos),
435 : maText(rTxt),
436 : mnTextStart(nTxtStart),
437 : mnTextLen(nTxtLen),
438 : mnPara(nPar),
439 : mnIndex(nIdx),
440 : mrFont(rFnt),
441 : mpDXArray(pDXArr),
442 : mpWrongSpellVector(pWrongSpellVector),
443 : mpFieldData(pFieldData),
444 : mpLocale(pLocale),
445 : maOverlineColor(rOverlineColor),
446 : maTextLineColor(rTextLineColor),
447 : mnBiDiLevel(nBiDiLevel),
448 : mbFilled( bFilled ),
449 : mnWidthToFill( nWidthToFill ),
450 : mbEndOfLine(bEndOfLine),
451 : mbEndOfParagraph(bEndOfParagraph),
452 23789 : mbEndOfBullet(bEndOfBullet)
453 23789 : {}
454 : };
455 :
456 0 : class EDITENG_DLLPUBLIC DrawBulletInfo
457 : {
458 : public:
459 : const GraphicObject maBulletGraphicObject;
460 : Point maBulletPosition;
461 : Size maBulletSize;
462 :
463 0 : DrawBulletInfo(
464 : const GraphicObject& rBulletGraphicObject,
465 : const Point& rBulletPosition,
466 : const Size& rBulletSize)
467 : : maBulletGraphicObject(rBulletGraphicObject),
468 : maBulletPosition(rBulletPosition),
469 0 : maBulletSize(rBulletSize)
470 0 : {}
471 : };
472 :
473 0 : struct EDITENG_DLLPUBLIC PaintFirstLineInfo
474 : {
475 : sal_Int32 mnPara;
476 : const Point& mrStartPos;
477 : long mnBaseLineY;
478 : const Point& mrOrigin;
479 : short mnOrientation;
480 : VclPtr<OutputDevice> mpOutDev;
481 :
482 0 : PaintFirstLineInfo( sal_Int32 nPara, const Point& rStartPos, long nBaseLineY, const Point& rOrigin, short nOrientation, OutputDevice* pOutDev )
483 0 : : mnPara( nPara ), mrStartPos( rStartPos ), mnBaseLineY( nBaseLineY ), mrOrigin( rOrigin ), mnOrientation( nOrientation ), mpOutDev( pOutDev )
484 0 : {}
485 : };
486 :
487 : class SdrPage;
488 :
489 : class EditFieldInfo
490 : {
491 : private:
492 : Outliner* pOutliner;
493 : const SvxFieldItem& rFldItem;
494 :
495 : Color* pTxtColor;
496 : Color* pFldColor;
497 :
498 : OUString aRepresentation;
499 :
500 : sal_Int32 nPara;
501 : sal_Int32 nPos;
502 : bool bSimpleClick;
503 :
504 : EditFieldInfo( const EditFieldInfo& ) SAL_DELETED_FUNCTION;
505 :
506 : SdrPage* mpSdrPage;
507 :
508 : public:
509 8647 : EditFieldInfo( Outliner* pOutl, const SvxFieldItem& rFItem, sal_Int32 nPa, sal_Int32 nPo )
510 8647 : : rFldItem( rFItem )
511 : {
512 8647 : pOutliner = pOutl;
513 8647 : nPara = nPa; nPos = nPo;
514 8647 : pTxtColor = 0; pFldColor = 0; bSimpleClick = false;
515 8647 : mpSdrPage = 0;
516 8647 : }
517 8647 : ~EditFieldInfo()
518 8647 : {
519 8647 : delete pTxtColor;
520 8647 : delete pFldColor;
521 8647 : }
522 :
523 17284 : Outliner* GetOutliner() const { return pOutliner; }
524 :
525 8647 : const SvxFieldItem& GetField() const { return rFldItem; }
526 :
527 8652 : Color* GetTextColor() const { return pTxtColor; }
528 5 : void SetTextColor( const Color& rColor )
529 5 : { delete pTxtColor; pTxtColor = new Color( rColor ); }
530 :
531 8779 : Color* GetFieldColor() const { return pFldColor; }
532 132 : void SetFieldColor( const Color& rColor )
533 132 : { delete pFldColor; pFldColor = new Color( rColor ); }
534 0 : void ClearFieldColor()
535 0 : { delete pFldColor; pFldColor = 0; }
536 :
537 53 : sal_Int32 GetPara() const { return nPara; }
538 53 : sal_Int32 GetPos() const { return nPos; }
539 :
540 : bool IsSimpleClick() const { return bSimpleClick; }
541 0 : void SetSimpleClick( bool bSimple ) { bSimpleClick = bSimple; }
542 :
543 : const OUString& GetRepresentation() const { return aRepresentation; }
544 8647 : OUString& GetRepresentation() { return aRepresentation; }
545 8647 : void SetRepresentation( const OUString& rStr ){ aRepresentation = rStr; }
546 :
547 0 : void SetSdrPage( SdrPage* pPage ) { mpSdrPage = pPage; }
548 8589 : SdrPage* GetSdrPage() const { return mpSdrPage; }
549 : };
550 :
551 979 : struct EBulletInfo
552 : {
553 : bool bVisible;
554 : sal_uInt16 nType; // see SvxNumberType
555 : OUString aText;
556 : SvxFont aFont;
557 : Graphic aGraphic;
558 : sal_Int32 nParagraph;
559 : Rectangle aBounds;
560 :
561 979 : EBulletInfo() : bVisible( false ), nType( 0 ), nParagraph( EE_PARA_NOT_FOUND ) {}
562 : };
563 :
564 : #define OUTLINERMODE_DONTKNOW 0x0000
565 : #define OUTLINERMODE_TEXTOBJECT 0x0001
566 : #define OUTLINERMODE_TITLEOBJECT 0x0002
567 : #define OUTLINERMODE_OUTLINEOBJECT 0x0003
568 : #define OUTLINERMODE_OUTLINEVIEW 0x0004
569 :
570 : #define OUTLINERMODE_USERMASK 0x00FF
571 :
572 : #define OUTLINERMODE_SUBTITLE (0x0100|OUTLINERMODE_TEXTOBJECT)
573 : #define OUTLINERMODE_NOTE (0x0200|OUTLINERMODE_TEXTOBJECT)
574 :
575 : class EDITENG_DLLPUBLIC Outliner : public SfxBroadcaster
576 : {
577 : friend class OutlinerView;
578 : friend class OutlinerEditEng;
579 : friend class OutlinerParaObject;
580 : friend class OLUndoExpand;
581 : friend class OutlinerUndoChangeDepth;
582 : friend class OutlinerUndoCheckPara;
583 : friend class OutlinerUndoChangeParaFlags;
584 :
585 : OutlinerEditEng* pEditEngine;
586 :
587 : ParagraphList* pParaList;
588 : ViewList aViewList;
589 :
590 : Paragraph* pHdlParagraph;
591 : sal_Int32 mnFirstSelPage;
592 : Link<> aDrawPortionHdl;
593 : Link<> aDrawBulletHdl;
594 : Link<> aExpandHdl;
595 : Link<> aParaInsertedHdl;
596 : Link<> aParaRemovingHdl;
597 : Link<> aDepthChangedHdl;
598 : Link<> aWidthArrReqHdl;
599 : Link<> aBeginMovingHdl;
600 : Link<> aEndMovingHdl;
601 : Link<> aIndentingPagesHdl;
602 : Link<> aRemovingPagesHdl;
603 : Link<> aFieldClickedHdl;
604 : Link<> aCalcFieldValueHdl;
605 : Link<> maPaintFirstLineHdl;
606 : Link<> maBeginPasteOrDropHdl;
607 : Link<> maEndPasteOrDropHdl;
608 :
609 : sal_Int32 nDepthChangedHdlPrevDepth;
610 : ParaFlag mnDepthChangeHdlPrevFlags;
611 : sal_Int16 nMaxDepth;
612 : const sal_Int16 nMinDepth;
613 : sal_Int32 nFirstPage;
614 :
615 : sal_uInt16 nOutlinerMode;
616 :
617 : bool bIsExpanding; // Only valid in Expand/Collaps-Hdl, reset
618 : bool bFirstParaIsEmpty;
619 : sal_uInt8 nBlockInsCallback;
620 : bool bStrippingPortions;
621 : bool bPasting;
622 :
623 : sal_uLong nDummy;
624 :
625 : DECL_LINK( ParaVisibleStateChangedHdl, Paragraph* );
626 : DECL_LINK( BeginMovingParagraphsHdl, void* );
627 : DECL_LINK( EndMovingParagraphsHdl, MoveParagraphsInfo* );
628 : DECL_LINK( BeginPasteOrDropHdl, PasteOrDropInfos* );
629 : DECL_LINK( EndPasteOrDropHdl, PasteOrDropInfos* );
630 : DECL_LINK( EditEngineNotifyHdl, EENotify* );
631 : void ImplCheckParagraphs( sal_Int32 nStart, sal_Int32 nEnd );
632 : bool ImplHasNumberFormat( sal_Int32 nPara ) const;
633 : Size ImplGetBulletSize( sal_Int32 nPara );
634 : sal_uInt16 ImplGetNumbering( sal_Int32 nPara, const SvxNumberFormat* pParaFmt );
635 : void ImplCalcBulletText( sal_Int32 nPara, bool bRecalcLevel, bool bRecalcChildren );
636 : OUString ImplGetBulletText( sal_Int32 nPara );
637 : void ImplCheckNumBulletItem( sal_Int32 nPara );
638 : void ImplInitDepth( sal_Int32 nPara, sal_Int16 nDepth, bool bCreateUndo, bool bUndoAction = false );
639 : void ImplSetLevelDependendStyleSheet( sal_Int32 nPara, SfxStyleSheet* pLevelStyle = NULL );
640 :
641 : void ImplBlockInsertionCallbacks( bool b );
642 :
643 : void ImplCheckStyleSheet( sal_Int32 nPara, bool bReplaceExistingStyle );
644 : void ImpRecalcBulletIndent( sal_Int32 nPara );
645 :
646 : const SvxBulletItem& ImpGetBullet( sal_Int32 nPara, sal_uInt16& );
647 : void ImpFilterIndents( sal_Int32 nFirstPara, sal_Int32 nLastPara );
648 : bool ImpConvertEdtToOut( sal_Int32 nPara, EditView* pView = 0 );
649 :
650 : void ImpTextPasted( sal_Int32 nStartPara, sal_Int32 nCount );
651 : long ImpCalcMaxBulletWidth( sal_Int32 nPara, const SvxBulletItem& rBullet );
652 : vcl::Font ImpCalcBulletFont( sal_Int32 nPara ) const;
653 : Rectangle ImpCalcBulletArea( sal_Int32 nPara, bool bAdjust, bool bReturnPaperPos );
654 : long ImpGetTextIndent( sal_Int32 nPara );
655 : bool ImpCanIndentSelectedPages( OutlinerView* pCurView );
656 : bool ImpCanDeleteSelectedPages( OutlinerView* pCurView );
657 : bool ImpCanDeleteSelectedPages( OutlinerView* pCurView, sal_Int32 nFirstPage, sal_Int32 nPages );
658 :
659 808122 : sal_uInt16 ImplGetOutlinerMode() const { return nOutlinerMode & OUTLINERMODE_USERMASK; }
660 : void ImplCheckDepth( sal_Int16& rnDepth ) const;
661 :
662 : protected:
663 : void ParagraphInserted( sal_Int32 nParagraph );
664 : void ParagraphDeleted( sal_Int32 nParagraph );
665 : void ParaAttribsChanged( sal_Int32 nParagraph );
666 :
667 : void StyleSheetChanged( SfxStyleSheet* pStyle );
668 :
669 : void InvalidateBullet(sal_Int32 nPara);
670 : void PaintBullet( sal_Int32 nPara, const Point& rStartPos,
671 : const Point& rOrigin, short nOrientation,
672 : OutputDevice* pOutDev );
673 :
674 : // used by OutlinerEditEng. Allows Outliner objects to provide
675 : // bullet access to the EditEngine.
676 : const SvxNumberFormat* GetNumberFormat( sal_Int32 nPara ) const;
677 :
678 : public:
679 :
680 : Outliner( SfxItemPool* pPool, sal_uInt16 nOutlinerMode );
681 : virtual ~Outliner();
682 :
683 : void Init( sal_uInt16 nOutlinerMode );
684 122306 : sal_uInt16 GetMode() const { return nOutlinerMode; }
685 :
686 : void SetVertical( bool bVertical );
687 : bool IsVertical() const;
688 :
689 : void SetFixedCellHeight( bool bUseFixedCellHeight );
690 :
691 : void SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir );
692 : EEHorizontalTextDirection GetDefaultHorizontalTextDirection() const;
693 :
694 : SvtScriptType GetScriptType( const ESelection& rSelection ) const;
695 : LanguageType GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const;
696 :
697 : void SetAsianCompressionMode( sal_uInt16 nCompressionMode );
698 :
699 : void SetKernAsianPunctuation( bool bEnabled );
700 :
701 : void SetAddExtLeading( bool b );
702 :
703 : size_t InsertView( OutlinerView* pView, size_t nIndex = size_t(-1) );
704 : OutlinerView* RemoveView( OutlinerView* pView );
705 : OutlinerView* RemoveView( size_t nIndex );
706 : OutlinerView* GetView( size_t nIndex ) const;
707 : size_t GetViewCount() const;
708 :
709 : Paragraph* Insert( const OUString& rText, sal_Int32 nAbsPos = EE_PARA_APPEND, sal_Int16 nDepth = 0 );
710 : void SetText( const OutlinerParaObject& );
711 : void AddText( const OutlinerParaObject& );
712 : void SetText( const OUString& rText, Paragraph* pParagraph );
713 : OUString GetText( Paragraph* pPara, sal_Int32 nParaCount=1 ) const;
714 :
715 : OutlinerParaObject* CreateParaObject( sal_Int32 nStartPara = 0, sal_Int32 nParaCount = EE_PARA_ALL ) const;
716 :
717 : const SfxItemSet& GetEmptyItemSet() const;
718 :
719 : void SetRefMapMode( const MapMode& );
720 : MapMode GetRefMapMode() const;
721 :
722 : void SetBackgroundColor( const Color& rColor );
723 : Color GetBackgroundColor() const;
724 :
725 : void SetMaxDepth( sal_Int16 nDepth, bool bCheckParas = false );
726 0 : sal_Int16 GetMaxDepth() const { return nMaxDepth; }
727 :
728 : void SetUpdateMode( bool bUpdate );
729 : bool GetUpdateMode() const;
730 :
731 : void Clear();
732 :
733 : void RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich );
734 :
735 : sal_Int32 GetParagraphCount() const;
736 : Paragraph* GetParagraph( sal_Int32 nAbsPos ) const;
737 :
738 : bool HasParent( Paragraph* pParagraph ) const;
739 : bool HasChildren( Paragraph* pParagraph ) const;
740 : sal_Int32 GetChildCount( Paragraph* pParent ) const;
741 : bool IsExpanded( Paragraph* pPara ) const;
742 : Paragraph* GetParent( Paragraph* pParagraph ) const;
743 : sal_Int32 GetAbsPos( Paragraph* pPara );
744 :
745 : sal_Int16 GetDepth( sal_Int32 nPara ) const;
746 : void SetDepth( Paragraph* pParagraph, sal_Int16 nNewDepth );
747 :
748 : static bool IsVisible( Paragraph* pPara ) { return pPara->IsVisible(); }
749 :
750 : void EnableUndo( bool bEnable );
751 : bool IsUndoEnabled() const;
752 : void UndoActionStart( sal_uInt16 nId );
753 : void UndoActionEnd( sal_uInt16 nId );
754 : void InsertUndo( EditUndo* pUndo );
755 : bool IsInUndo();
756 :
757 : void ClearModifyFlag();
758 : bool IsModified() const;
759 :
760 0 : Paragraph* GetHdlParagraph() const { return pHdlParagraph; }
761 : bool IsExpanding() const { return bIsExpanding; }
762 :
763 : void ExpandHdl();
764 : void SetExpandHdl( const Link<>& rLink ) { aExpandHdl = rLink; }
765 : Link<> GetExpandHdl() const { return aExpandHdl; }
766 :
767 : void ParagraphInsertedHdl();
768 7 : void SetParaInsertedHdl(const Link<>& rLink){aParaInsertedHdl=rLink;}
769 0 : Link<> GetParaInsertedHdl() const { return aParaInsertedHdl; }
770 :
771 : void ParagraphRemovingHdl();
772 7 : void SetParaRemovingHdl(const Link<>& rLink){aParaRemovingHdl=rLink;}
773 0 : Link<> GetParaRemovingHdl() const { return aParaRemovingHdl; }
774 :
775 : void DepthChangedHdl();
776 0 : void SetDepthChangedHdl(const Link<>& rLink){aDepthChangedHdl=rLink;}
777 0 : Link<> GetDepthChangedHdl() const { return aDepthChangedHdl; }
778 0 : sal_Int16 GetPrevDepth() const { return static_cast<sal_Int16>(nDepthChangedHdlPrevDepth); }
779 0 : ParaFlag GetPrevFlags() const { return mnDepthChangeHdlPrevFlags; }
780 :
781 : bool RemovingPagesHdl( OutlinerView* );
782 0 : void SetRemovingPagesHdl(const Link<>& rLink){aRemovingPagesHdl=rLink;}
783 : Link<> GetRemovingPagesHdl() const { return aRemovingPagesHdl; }
784 : long IndentingPagesHdl( OutlinerView* );
785 0 : void SetIndentingPagesHdl(const Link<>& rLink){aIndentingPagesHdl=rLink;}
786 : Link<> GetIndentingPagesHdl() const { return aIndentingPagesHdl; }
787 : // valid only in the two upper handlers
788 0 : sal_Int32 GetSelPageCount() const { return nDepthChangedHdlPrevDepth; }
789 :
790 : // valid only in the two upper handlers
791 : sal_Int32 GetFirstSelPage() const { return mnFirstSelPage; }
792 :
793 30351 : void SetCalcFieldValueHdl(const Link<>& rLink ) { aCalcFieldValueHdl= rLink; }
794 22219 : Link<> GetCalcFieldValueHdl() const { return aCalcFieldValueHdl; }
795 :
796 : void SetFieldClickedHdl(const Link<>& rLink ) { aFieldClickedHdl= rLink; }
797 : Link<> GetFieldClickedHdl() const { return aFieldClickedHdl; }
798 :
799 34966 : void SetDrawPortionHdl(const Link<>& rLink){aDrawPortionHdl=rLink;}
800 : Link<> GetDrawPortionHdl() const { return aDrawPortionHdl; }
801 :
802 34966 : void SetDrawBulletHdl(const Link<>& rLink){aDrawBulletHdl=rLink;}
803 : Link<> GetDrawBulletHdl() const { return aDrawBulletHdl; }
804 :
805 0 : void SetPaintFirstLineHdl(const Link<>& rLink) { maPaintFirstLineHdl = rLink; }
806 : Link<> GetPaintFirstLineHdl() const { return maPaintFirstLineHdl; }
807 :
808 : void SetModifyHdl( const Link<>& rLink );
809 : Link<> GetModifyHdl() const;
810 :
811 : void SetNotifyHdl( const Link<>& rLink );
812 :
813 : void SetStatusEventHdl( const Link<>& rLink );
814 : Link<> GetStatusEventHdl() const;
815 :
816 : void Draw( OutputDevice* pOutDev, const Rectangle& rOutRect );
817 : void Draw( OutputDevice* pOutDev, const Point& rStartPos, short nOrientation = 0 );
818 :
819 : const Size& GetPaperSize() const;
820 : void SetPaperSize( const Size& rSize );
821 :
822 0 : void SetFirstPageNumber( sal_Int32 n ) { nFirstPage = n; }
823 : sal_Int32 GetFirstPageNumber() const { return nFirstPage; }
824 :
825 : void SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon );
826 : void SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DPolyPolygon* pLinePolyPolygon);
827 : void ClearPolygon();
828 :
829 : const Size& GetMinAutoPaperSize() const;
830 : void SetMinAutoPaperSize( const Size& rSz );
831 :
832 : const Size& GetMaxAutoPaperSize() const;
833 : void SetMaxAutoPaperSize( const Size& rSz );
834 :
835 : void SetDefTab( sal_uInt16 nTab );
836 :
837 : bool IsFlatMode() const;
838 : void SetFlatMode( bool bFlat );
839 :
840 : void EnableAutoColor( bool b );
841 :
842 : void ForceAutoColor( bool b );
843 : bool IsForceAutoColor() const;
844 :
845 : EBulletInfo GetBulletInfo( sal_Int32 nPara );
846 :
847 : void SetWordDelimiters( const OUString& rDelimiters );
848 : OUString GetWordDelimiters() const;
849 : OUString GetWord( sal_Int32 nPara, sal_Int32 nIndex );
850 :
851 : void StripPortions();
852 :
853 : void DrawingText( const Point& rStartPos, const OUString& rText,
854 : sal_Int32 nTextStart, sal_Int32 nTextLen,
855 : const long* pDXArray, const SvxFont& rFont,
856 : sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
857 : const EEngineData::WrongSpellVector* pWrongSpellVector,
858 : const SvxFieldData* pFieldData,
859 : bool bEndOfLine,
860 : bool bEndOfParagraph,
861 : bool bEndOfBullet,
862 : const ::com::sun::star::lang::Locale* pLocale,
863 : const Color& rOverlineColor,
864 : const Color& rTextLineColor);
865 :
866 : void DrawingTab( const Point& rStartPos, long nWidth, const OUString& rChar,
867 : const SvxFont& rFont, sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
868 : bool bEndOfLine,
869 : bool bEndOfParagraph,
870 : const Color& rOverlineColor,
871 : const Color& rTextLineColor);
872 :
873 : Size CalcTextSize();
874 : Size CalcTextSizeNTP();
875 :
876 : void SetStyleSheetPool( SfxStyleSheetPool* pSPool );
877 : SfxStyleSheetPool* GetStyleSheetPool();
878 :
879 : bool IsInSelectionMode() const;
880 :
881 : void SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle );
882 : SfxStyleSheet* GetStyleSheet( sal_Int32 nPara );
883 :
884 : void SetParaAttribs( sal_Int32 nPara, const SfxItemSet& );
885 : SfxItemSet GetParaAttribs( sal_Int32 nPara );
886 :
887 : void Remove( Paragraph* pPara, sal_Int32 nParaCount );
888 : bool Expand( Paragraph* );
889 : bool Collapse( Paragraph* );
890 :
891 : void SetParaFlag( Paragraph* pPara, ParaFlag nFlag );
892 : static bool HasParaFlag( const Paragraph* pPara, ParaFlag nFlag );
893 :
894 : // Returns an array containing the widths of the Bullet Indentations
895 : // Last value must be -1. Is deleted by the outliner.
896 : Link<> GetWidthArrReqHdl() const{ return aWidthArrReqHdl; }
897 : void SetWidthArrReqHdl(const Link<>& rLink){aWidthArrReqHdl=rLink; }
898 :
899 : void SetControlWord( EEControlBits nWord );
900 : EEControlBits GetControlWord() const;
901 :
902 0 : Link<> GetBeginMovingHdl() const { return aBeginMovingHdl; }
903 0 : void SetBeginMovingHdl(const Link<>& rLink) {aBeginMovingHdl=rLink;}
904 0 : Link<> GetEndMovingHdl() const {return aEndMovingHdl;}
905 0 : void SetEndMovingHdl( const Link<>& rLink){aEndMovingHdl=rLink;}
906 :
907 : sal_uLong GetLineCount( sal_Int32 nParagraph ) const;
908 : sal_Int32 GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const;
909 : sal_uLong GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine = 0 );
910 :
911 : sal_uLong Read( SvStream& rInput, const OUString& rBaseURL, sal_uInt16, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );
912 :
913 : ::svl::IUndoManager& GetUndoManager();
914 : ::svl::IUndoManager* SetUndoManager(::svl::IUndoManager* pNew);
915 :
916 : void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel );
917 : void QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel );
918 : void QuickInsertLineBreak( const ESelection& rSel );
919 :
920 : // Only for EditEngine mode
921 : void QuickInsertText( const OUString& rText, const ESelection& rSel );
922 : void QuickDelete( const ESelection& rSel );
923 : void RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich = 0 );
924 : void QuickFormatDoc( bool bFull = false );
925 :
926 : bool UpdateFields();
927 : void RemoveFields( bool bKeepFieldText, TypeId aType = NULL );
928 :
929 : void FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );
930 : void FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );
931 : virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor );
932 :
933 : void SetSpeller( ::com::sun::star::uno::Reference<
934 : ::com::sun::star::linguistic2::XSpellChecker1 > &xSpeller );
935 : ::com::sun::star::uno::Reference<
936 : ::com::sun::star::linguistic2::XSpellChecker1 >
937 : GetSpeller();
938 : void SetHyphenator( ::com::sun::star::uno::Reference<
939 : ::com::sun::star::linguistic2::XHyphenator >& xHyph );
940 :
941 : static void SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars );
942 :
943 : // Deprecated
944 : void SetDefaultLanguage( LanguageType eLang );
945 : LanguageType GetDefaultLanguage() const;
946 :
947 : void CompleteOnlineSpelling();
948 :
949 : EESpellState HasSpellErrors();
950 : bool HasText( const SvxSearchItem& rSearchItem );
951 : virtual bool SpellNextDocument();
952 :
953 : // for text conversion
954 : bool HasConvertibleTextPortion( LanguageType nLang );
955 : virtual bool ConvertNextDocument();
956 :
957 : void SetEditTextObjectPool( SfxItemPool* pPool );
958 : SfxItemPool* GetEditTextObjectPool() const;
959 :
960 : void SetRefDevice( OutputDevice* pRefDev );
961 : OutputDevice* GetRefDevice() const;
962 :
963 : sal_uLong GetTextHeight() const;
964 : sal_uLong GetTextHeight( sal_Int32 nParagraph ) const;
965 : Point GetDocPosTopLeft( sal_Int32 nParagraph );
966 : Point GetDocPos( const Point& rPaperPos ) const;
967 : bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder = 0 );
968 : bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder, bool* pbBulletPos );
969 :
970 : void SetGlobalCharStretching( sal_uInt16 nX = 100, sal_uInt16 nY = 100 );
971 : void GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const;
972 : void EraseVirtualDevice();
973 :
974 : bool ShouldCreateBigTextObject() const;
975 :
976 : const EditEngine& GetEditEngine() const;
977 :
978 : // this is needed for StarOffice Api
979 : void SetLevelDependendStyleSheet( sal_Int32 nPara );
980 :
981 26996 : sal_uInt16 GetOutlinerMode() const { return nOutlinerMode & OUTLINERMODE_USERMASK; }
982 :
983 : void StartSpelling(EditView& rEditView, bool bMultipleDoc);
984 : // spell and return a sentence
985 : bool SpellSentence(EditView& rEditView, svx::SpellPortions& rToFill, bool bIsGrammarChecking );
986 : // put spell position to start of current sentence
987 : void PutSpellingToSentenceStart( EditView& rEditView );
988 : // applies a changed sentence
989 : void ApplyChangedSentence(EditView& rEditView, const svx::SpellPortions& rNewPortions, bool bRecheck );
990 :
991 : /** sets a link that is called at the beginning of a drag operation at an edit view */
992 : void SetBeginDropHdl( const Link<>& rLink );
993 :
994 : /** sets a link that is called at the end of a drag operation at an edit view */
995 : void SetEndDropHdl( const Link<>& rLink );
996 :
997 : /** sets a link that is called before a drop or paste operation. */
998 : void SetBeginPasteOrDropHdl( const Link<>& rLink );
999 : Link<> GetBeginPasteOrDropHdl() const { return maBeginPasteOrDropHdl; }
1000 :
1001 : /** sets a link that is called after a drop or paste operation. */
1002 : void SetEndPasteOrDropHdl( const Link<>& rLink );
1003 : Link<> GetEndPasteOrDropHdl() const { return maEndPasteOrDropHdl; }
1004 :
1005 : sal_Int16 GetNumberingStartValue( sal_Int32 nPara );
1006 : void SetNumberingStartValue( sal_Int32 nPara, sal_Int16 nNumberingStartValue );
1007 :
1008 : bool IsParaIsNumberingRestart( sal_Int32 nPara );
1009 : void SetParaIsNumberingRestart( sal_Int32 nPara, bool bParaIsNumberingRestart );
1010 :
1011 : /** determine the bullets/numbering status of the given paragraphs
1012 :
1013 : @param nParaStart
1014 : index of paragraph at which the check starts
1015 :
1016 : @param nParaEnd
1017 : index of paragraph at which the check ends
1018 :
1019 : @returns
1020 : 0 : all paragraphs have bullets
1021 : 1 : all paragraphs have numbering
1022 : 2 : otherwise
1023 : */
1024 : sal_Int32 GetBulletsNumberingStatus(
1025 : const sal_Int32 nParaStart,
1026 : const sal_Int32 nParaEnd ) const;
1027 :
1028 : // convenient method to determine the bullets/numbering status for all paragraphs
1029 : sal_Int32 GetBulletsNumberingStatus() const;
1030 : };
1031 :
1032 : #endif
1033 :
1034 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|