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