Branch libreoffice-5-0-4
[LibreOffice.git] / sw / inc / editsh.hxx
blob6a7d718b5ce4a500f0189d5791f1c83f78792110
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_SW_INC_EDITSH_HXX
20 #define INCLUDED_SW_INC_EDITSH_HXX
22 #include <com/sun/star/text/HoriOrientation.hpp>
23 #include <com/sun/star/embed/XEmbeddedObject.hpp>
24 #include <vcl/font.hxx>
25 #include <editeng/swafopt.hxx>
26 #include "swdllapi.h"
27 #include <crsrsh.hxx>
28 #include <itabenum.hxx>
29 #include <swdbdata.hxx>
30 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
31 #include <com/sun/star/linguistic2/ProofreadingResult.hpp>
32 #include <fldupde.hxx>
33 #include <tblenum.hxx>
34 #include <IMark.hxx>
35 #include <tox.hxx>
36 #include <frmfmt.hxx>
37 #include <charfmt.hxx>
39 #include <vector>
40 #include <set>
41 #include <swundo.hxx>
42 #include <svtools/embedhlp.hxx>
43 #include <boost/ptr_container/ptr_vector.hpp>
45 namespace tools { class PolyPolygon; }
46 class SwDoc;
47 class DateTime;
48 class CommandExtTextInputData;
50 class SvNumberFormatter;
51 class SfxPoolItem;
52 class SfxItemSet;
53 class SvxAutoCorrect;
55 class SwField;
56 class SwFieldType;
57 class SwDDEFieldType;
58 class SwDBManager;
60 struct SwDocStat;
61 class SwAutoCompleteWord;
63 class SwFormatRefMark;
65 class SwNumRule;
67 class SwTextFormatColl;
68 class SwGrfNode;
69 class SwFlyFrameFormat;
71 class SwFrameFormat;
72 class SwCharFormat;
73 class SwExtTextInput;
74 class Graphic;
75 class GraphicObject;
76 class SwFormatINetFormat;
77 class SwTable;
78 class SwTextBlocks;
79 class SwFormatFootnote;
80 class SwSection;
81 class SwSectionData;
82 class SwSectionFormat;
83 class SwTableAutoFormat;
84 class SwPageDesc;
85 class SwTextINetFormat;
86 class SwSeqFieldList;
87 class SwGlblDocContent;
88 class SwGlblDocContents;
89 class SwRangeRedline;
90 class SwRedlineData;
91 class SwFootnoteInfo;
92 class SwEndNoteInfo;
93 class SwLineNumberInfo;
94 class SwAuthEntry;
95 class SwRewriter;
96 struct SwConversionArgs;
97 enum class SvtScriptType;
98 namespace com { namespace sun { namespace star { namespace uno {
99 template < class > class Sequence;
100 }}}}
102 namespace svx{
103 struct SpellPortion;
104 typedef std::vector<SpellPortion> SpellPortions;
107 namespace sfx2{
108 class LinkManager;
111 namespace sw {
112 class UndoRedoContext;
115 #define GETSELTXT_PARABRK_TO_BLANK 0
116 #define GETSELTXT_PARABRK_TO_ONLYCR 2
118 /// For querying the INet-attributes for Navigator.
119 struct SwGetINetAttr
121 OUString sText;
122 const SwTextINetFormat& rINetAttr;
124 SwGetINetAttr( const OUString& rText, const SwTextINetFormat& rAttr )
125 : sText( rText ), rINetAttr( rAttr )
128 typedef boost::ptr_vector<SwGetINetAttr> SwGetINetAttrs;
130 // Types of forms of content.
131 #define CNT_TXT 0x0001
132 #define CNT_GRF 0x0002
133 #define CNT_OLE 0x0010
135 // Test USHORT for a defined form of content.
136 #define CNT_HasText(USH) ((USH)&CNT_TXT)
137 #define CNT_HasGrf(USH) ((USH)&CNT_GRF)
138 #define CNT_HasOLE(USH) ((USH)&CNT_OLE)
140 class SW_DLLPUBLIC SwEditShell : public SwCrsrShell
142 static SvxSwAutoFormatFlags* s_pAutoFormatFlags;
144 /// For the private methods DelRange and those of AutoCorrect.
145 friend class SwAutoFormat;
146 friend void _InitCore();
147 friend void _FinitCore();
148 /// For the PamCorrAbs/-Rel methods.
149 friend class SwUndo;
151 SAL_DLLPRIVATE SfxPoolItem& _GetChrFormat( SfxPoolItem& ) const;
153 /** Returns pointer to a SwGrfNode
154 that will be used by GetGraphic() and GetGraphicSize(). */
155 SAL_DLLPRIVATE SwGrfNode *_GetGrfNode() const ;
157 SAL_DLLPRIVATE void DeleteSel( SwPaM& rPam, bool* pUndo = 0 );
159 SAL_DLLPRIVATE void _SetSectionAttr( SwSectionFormat& rSectFormat, const SfxItemSet& rSet );
161 using SwViewShell::UpdateFields;
162 using SwModify::GetInfo;
164 public:
165 /// Edit (all selected ranges).
166 void Insert( sal_Unicode, bool bOnlyCurrCrsr = false );
167 void Insert2( const OUString &, const bool bForceExpandHints = false );
168 void Overwrite( const OUString & );
170 /** Replace a selected range in a TextNode by given string.
171 Meant for Search & Replace.
172 bRegExpRplc - replace tabs (\\t) and insert found string (not \&).
173 E.g.: Fnd: "zzz", Repl: "xx\t\\t..&..\&"
174 --> "xx\t<Tab>..zzz..&" */
175 bool Replace( const OUString& rNewStr, bool bRegExpRplc = false );
177 /** Delete content of all ranges.
178 If whole nodes are selected, these nodes get deleted. */
179 long Delete();
181 /// Remove a complete paragraph.
182 bool DelFullPara();
184 /// Change text to Upper/Lower/Hiragana/Katagana/...
185 void TransliterateText( sal_uInt32 nType );
187 /// Count words in current selection.
188 void CountWords( SwDocStat& rStat ) const;
190 /// Replace fields by text - mailmerge support.
191 bool ConvertFieldsToText();
193 /// Set all numbering start points to a fixed value - mailmerge support.
194 void SetNumberingRestart();
196 /// Embedds all local links (ranges/graphics).
197 sal_uInt16 GetLinkUpdMode(bool bDocSettings = false) const;
198 void SetLinkUpdMode( sal_uInt16 nMode );
200 /// Copy content of all ranges at current position of cursor to given Shell.
201 bool Copy( SwEditShell* pDestShell = 0 );
203 /** For copying via ClipBoard:
204 If table is copied into table, move all cursors away from it.
205 Copy and Paste must be in FEShell because of FlyFrames!
206 Copy all selections to the document. */
207 bool _CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pNdInsPos = 0 );
209 long SplitNode( bool bAutoFormat = false, bool bCheckTableStart = true );
210 bool AppendTextNode();
211 void AutoFormatBySplitNode();
213 /** If cursor is in a INetAttribute it will be deleted completely
214 including the descriptive text (needed at drag & drop). */
215 bool DelINetAttrWithText();
217 /** If Cursor is at the end of a character style in which the DontExpand-flag
218 is not yet set, the latter will be set (==> return TRUE). */
219 bool DontExpandFormat();
221 /** Apply / remove attributes.
222 @return attributes in required AttributeSet.
223 When not unambiguous the set has a DONT_CARE !!
224 2nd optional parameter <bMergeIndentValuesOfNumRule>.
225 If <bMergeIndentValuesOfNumRule> == true, the indent attributes of
226 the corresponding list level of an applied list style is merged into
227 the requested item set as a LR-SPACE item, if corresponding node has not
228 its own indent attributes and the position-and-space mode of the list
229 level is SvxNumberFormat::LABEL_ALIGNMENT. */
230 bool GetPaMAttr( SwPaM* pPaM, SfxItemSet& ,
231 const bool bMergeIndentValuesOfNumRule = false ) const;
232 bool GetCurAttr( SfxItemSet& ,
233 const bool bMergeIndentValuesOfNumRule = false ) const;
234 void SetAttrItem( const SfxPoolItem&, SetAttrMode nFlags = SetAttrMode::DEFAULT );
235 void SetAttrSet( const SfxItemSet&, SetAttrMode nFlags = SetAttrMode::DEFAULT, SwPaM* pCrsr = NULL );
237 /** Get RES_CHRATR_* items of one type in the current selection.
238 * @param nWhich WhichId of the collected items.
239 * If parts of the selection have different scripttypes, the items with corresponding WhichIds are also collected.
240 * @return a vector of pairs. The pair contains a SfxPoolItem and a SwPaM, in which the item is valid and can be changed. */
241 std::vector<std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM>>> GetItemWithPaM( sal_uInt16 nWhich );
244 * Get the paragraph format attribute(s) of the current selection.
246 * @see GetPaMParAttr()
248 * @param rSet
249 * output parameter - the SfxItemSet where the automatic paragraph format attribute(s) will be store.
250 * The attributes aren't invalidated or cleared if the function reach the getMaxLookup limite.
252 * @return true if the function inspect all the nodes point by the pPaM parameter,
253 * false if the function reach the limit of getMaxLookup number of nodes inspected.
255 bool GetCurParAttr( SfxItemSet& rSet ) const;
257 * Get the paragraph format attribute(s) of the selection(s) described by a SwPaM.
259 * @param pPaM
260 * input parameter - the selection where to look for the paragraph format.
262 * @param rSet
263 * output parameter - the SfxItemSet where the automatic paragraph format attribute(s) will be store.
264 * The attributes aren't invalidated or cleared if the function reaches the getMaxLookup limit.
266 * @return true if the function inspects all the nodes point by the pPaM parameter,
267 * false if the function reaches the limit of getMaxLookup number of nodes inspected.
269 bool GetPaMParAttr( SwPaM* pPaM, SfxItemSet& rSet ) const;
271 /// Set attribute as new default attribute in document.
272 void SetDefault( const SfxPoolItem& );
274 /// Query default attribute of document.
275 const SfxPoolItem& GetDefault( sal_uInt16 nFormatHint ) const;
277 void ResetAttr( const std::set<sal_uInt16> &attrs = std::set<sal_uInt16>(), SwPaM* pCrsr = NULL );
278 void GCAttr();
280 /// @return the scripttpye of the selection.
281 SvtScriptType GetScriptType() const;
283 /// @return the language at current cursor position.
284 sal_uInt16 GetCurLang() const;
286 /// TABLE
287 size_t GetTableFrameFormatCount( bool bUsed = false ) const;
288 SwFrameFormat& GetTableFrameFormat(size_t nFormat, bool bUsed = false ) const;
289 OUString GetUniqueTableName() const;
291 /// CHAR
292 sal_uInt16 GetCharFormatCount() const;
293 SwCharFormat& GetCharFormat(sal_uInt16 nFormat) const;
294 SwCharFormat* GetCurCharFormat() const;
295 void FillByEx(SwCharFormat*, bool bReset = false);
296 SwCharFormat* MakeCharFormat( const OUString& rName, SwCharFormat* pDerivedFrom = 0 );
297 SwCharFormat* FindCharFormatByName( const OUString& rName ) const;
299 /* FormatCollections (new) - Explaining the general naming pattern:
300 * GetXXXCount() returns the count of xxx in the document.
301 * GetXXX(i) returns i-th xxx (ERR_RAISE if beyond range!).
302 * DelXXX(i) deletes i-th xxx (ERR_RAISE if beyond range!).
303 * GetCurXXX() returns xxx that is valid at cursor or in ranges.
304 * returns 0, if not unanimuous.
305 * SetXXX() sets xxx at cursor or in ranges.
306 * MakeXXX() makes a xxx, derived from pDerivedFrom.
309 // TXT
310 SwTextFormatColl& GetDfltTextFormatColl() const;
311 sal_uInt16 GetTextFormatCollCount() const;
312 SwTextFormatColl& GetTextFormatColl( sal_uInt16 nTextFormatColl) const;
314 * Get the named paragraph format of the current selection.
316 * @see GetPaMTextFormatColl()
318 * @return the named paragraph format of the first node that contains one.
319 * Nodes are sort by order of appearance in the selections ;
320 * selections are sort by their order of creation
321 * (last created selection first, oldest selection at last).
323 SwTextFormatColl* GetCurTextFormatColl() const;
325 * Get the named paragraph format of the selection(s) described by a SwPaM.
327 * @param pPaM
328 * input parameter - the selection where to look for the paragraph format.
330 * @return the named paragraph format of the first node that contains one.
332 SwTextFormatColl* GetPaMTextFormatColl( SwPaM* pPaM ) const;
334 // #i62675#
335 /// Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTextFormatColl(..)>
336 void SetTextFormatColl(SwTextFormatColl*, const bool bResetListAttrs = false);
337 SwTextFormatColl *MakeTextFormatColl(const OUString &rFormatCollName,
338 SwTextFormatColl *pDerivedFrom = 0);
339 void FillByEx(SwTextFormatColl*, bool bReset = false);
340 SwTextFormatColl* FindTextFormatCollByName( const OUString& rName ) const;
342 /// @return "Auto-Collection" with given Id. If it does not exist create it.
343 SwTextFormatColl* GetTextCollFromPool( sal_uInt16 nId );
345 /// @return required automatic format base class.
346 SwFormat* GetFormatFromPool( sal_uInt16 nId );
348 /// @return required automatic page style.
349 SwPageDesc* GetPageDescFromPool( sal_uInt16 nId );
351 /// Query if the paragraph-/character-/frame-/page-style is used.
352 bool IsUsed( const SwModify& ) const;
354 /// @return required automatic format.
355 SwFrameFormat* GetFrameFormatFromPool( sal_uInt16 nId )
356 { return static_cast<SwFrameFormat*>(SwEditShell::GetFormatFromPool( nId )); }
357 SwCharFormat* GetCharFormatFromPool( sal_uInt16 nId )
358 { return static_cast<SwCharFormat*>(SwEditShell::GetFormatFromPool( nId )); }
360 void Insert2(SwField&, const bool bForceExpandHints = false);
362 void UpdateFields( SwField & ); ///< One single field.
364 sal_uInt16 GetFieldTypeCount(sal_uInt16 nResId = USHRT_MAX, bool bUsed = false) const;
365 SwFieldType* GetFieldType(sal_uInt16 nId, sal_uInt16 nResId = USHRT_MAX, bool bUsed = false) const;
366 SwFieldType* GetFieldType(sal_uInt16 nResId, const OUString& rName) const;
368 void RemoveFieldType(sal_uInt16 nId, sal_uInt16 nResId = USHRT_MAX);
369 void RemoveFieldType(sal_uInt16 nResId, const OUString& rName);
371 void FieldToText( SwFieldType* pType );
373 void ChangeAuthorityData(const SwAuthEntry* pNewData);
375 /// Database information.
376 SwDBData GetDBData() const;
377 const SwDBData& GetDBDesc() const;
378 void ChgDBData(const SwDBData& SwDBData);
379 void ChangeDBFields( const std::vector<OUString>& rOldNames,
380 const OUString& rNewName );
381 void GetAllUsedDB( std::vector<OUString>& rDBNameList,
382 std::vector<OUString>* pAllDBNames = 0 );
384 bool IsAnyDatabaseFieldInDoc()const;
386 /// Check whether DB fields point to an available data source and returns it.
387 bool IsFieldDataSourceAvailable(OUString& rUsedDataSource) const;
388 void UpdateExpFields(bool bCloseDB = false);///< only every expression fields update
389 void LockExpFields();
390 void UnlockExpFields();
391 bool IsExpFieldsLocked() const;
393 SwFieldUpdateFlags GetFieldUpdateFlags(bool bDocSettings = false) const;
394 void SetFieldUpdateFlags( SwFieldUpdateFlags eFlags );
396 /// For evaluation of DB fields (new DB-manager).
397 SwDBManager* GetDBManager() const;
399 SwFieldType* InsertFieldType(const SwFieldType &);
401 /// Changes in document?
402 bool IsModified() const;
403 void SetModified();
404 void ResetModified();
405 void SetUndoNoResetModified();
407 /// Document - Statistics
408 void UpdateDocStat();
409 const SwDocStat &GetUpdatedDocStat();
411 void Insert(const SwTOXMark& rMark);
413 void DeleteTOXMark(SwTOXMark* pMark);
415 /// Get all marks at current SPoint.
416 sal_uInt16 GetCurTOXMarks(SwTOXMarks& rMarks) const ;
418 /// Insert content table. Renew if required.
419 void InsertTableOf(const SwTOXBase& rTOX,
420 const SfxItemSet* pSet = 0);
421 bool UpdateTableOf(const SwTOXBase& rTOX,
422 const SfxItemSet* pSet = 0);
423 const SwTOXBase* GetCurTOX() const;
424 const SwTOXBase* GetDefaultTOXBase( TOXTypes eTyp, bool bCreate = false );
425 void SetDefaultTOXBase(const SwTOXBase& rBase);
427 static bool IsTOXBaseReadonly(const SwTOXBase& rTOXBase);
428 void SetTOXBaseReadonly(const SwTOXBase& rTOXBase, bool bReadonly);
430 sal_uInt16 GetTOXCount() const;
431 const SwTOXBase* GetTOX( sal_uInt16 nPos ) const;
432 bool DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes = false );
434 /// After reading file update all content tables.
435 void SetUpdateTOX( bool bFlag = true );
436 bool IsUpdateTOX() const;
438 /// Manage types of content tables.
439 sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const;
440 const SwTOXType* GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const;
441 void InsertTOXType(const SwTOXType& rTyp);
443 /// AutoMark file
444 OUString GetTOIAutoMarkURL() const;
445 void SetTOIAutoMarkURL(const OUString& rSet);
446 void ApplyAutoMark();
448 /// Key for managing index.
449 sal_uInt16 GetTOIKeys( SwTOIKeyType eTyp, std::vector<OUString>& rArr ) const;
451 void SetOutlineNumRule(const SwNumRule&);
452 const SwNumRule* GetOutlineNumRule() const;
454 bool OutlineUpDown( short nOffset = 1 );
456 bool MoveOutlinePara( short nOffset = 1);
458 bool IsProtectedOutlinePara() const;
460 const SwNumRule* GetNumRuleAtCurrCrsrPos() const;
462 /** Returns the numbering rule found at the paragraphs of the current selection,
463 if all paragraphs of the current selection have the same or none numbering rule applied. */
464 const SwNumRule* GetNumRuleAtCurrentSelection() const;
466 /** Optional parameter <bResetIndentAttrs> (default value false).
467 If <bResetIndentAttrs> equals true, the indent attributes "before text"
468 and "first line indent" are additionally reset at the current selection,
469 if the list style makes use of the new list level attributes.
470 Parameters <bCreateNewList> and <sContinuedListId>
471 <bCreateNewList> indicates, if a new list is created by applying the given list style.
472 If <bCreateNewList> equals false, <sContinuedListId> may contain the
473 list Id of a list, which has to be continued by applying the given list style */
474 void SetCurNumRule( const SwNumRule&,
475 const bool bCreateNewList /*= false*/,
476 const OUString& sContinuedListId = OUString(),
477 const bool bResetIndentAttrs = false );
479 /// Paragraphs without enumeration but with indents.
480 bool NoNum();
482 /// Delete, split enumeration list.
483 void DelNumRules();
485 bool NumUpDown( bool bDown = true );
487 bool MoveParagraph( long nOffset = 1);
488 bool MoveNumParas( bool bUpperLower, bool bUpperLeft );
490 /// Switch on/off of numbering via Delete/Backspace.
491 bool NumOrNoNum(bool bDelete = false, bool bChkStart = true);
493 // #i23726#
494 // #i90078#
495 /// Remove unused default parameter <nLevel> and <bRelative>.
496 // Adjust method name and parameter name
497 void ChangeIndentOfAllListLevels( short nDiff );
498 // Adjust method name
499 void SetIndent(short nIndent, const SwPosition & rPos);
500 bool IsFirstOfNumRuleAtCrsrPos() const;
502 bool IsNoNum( bool bChkStart = true ) const;
504 /** @return Num-Level of the node in which point of cursor is.
505 @return values can be: NO_NUMBERING,
506 0..MAXLEVEL-1, NO_NUMLEVEL .. NO_NUMLEVEL|MAXLEVEL-1 */
507 sal_uInt8 GetNumLevel() const;
509 /// Detect highest and lowest level to check moving of outline levels.
510 void GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower );
512 /// Get Outline level of current paragraph.
513 int GetCurrentParaOutlineLevel( ) const;
515 // i29560
516 bool HasNumber() const;
517 bool HasBullet() const;
519 bool SelectionHasNumber() const;
520 bool SelectionHasBullet() const;
522 OUString GetUniqueNumRuleName( const OUString* pChkStr = 0, bool bAutoNum = true ) const;
523 void ChgNumRuleFormats( const SwNumRule& rRule );
525 /// Set (and query if) a numbering with StartFlag starts at current PointPos.
526 void SetNumRuleStart( bool bFlag = true, SwPaM* pCrsr = NULL );
527 bool IsNumRuleStart( SwPaM* pPaM = NULL ) const;
528 void SetNodeNumStart( sal_uInt16 nStt, SwPaM* = NULL );
530 sal_uInt16 GetNodeNumStart( SwPaM* pPaM = NULL ) const;
532 bool ReplaceNumRule( const OUString& rOldRule, const OUString& rNewRule );
534 /** Searches for a text node with a numbering rule.
535 in case a list style is found, <sListId> holds the list id, to which the
536 text node belongs, which applies the found list style. */
537 const SwNumRule * SearchNumRule(const bool bForward,
538 const bool bNum,
539 const bool bOutline,
540 int nNonEmptyAllowed,
541 OUString& sListId );
543 /** Undo.
544 Maintain UndoHistory in Document.
545 Reset UndoHistory at Save, SaveAs, Create ??? */
546 void DoUndo( bool bOn = true );
547 bool DoesUndo() const;
548 void DoGroupUndo( bool bUn = true );
549 bool DoesGroupUndo() const;
550 void DelAllUndoObj();
552 /// Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
553 SwUndoId StartUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
555 /// Closes parenthesis of nUndoId, not used by UI.
556 SwUndoId EndUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
558 bool GetLastUndoInfo(OUString *const o_pStr,
559 SwUndoId *const o_pId) const;
560 bool GetFirstRedoInfo(OUString *const o_pStr) const;
561 SwUndoId GetRepeatInfo(OUString *const o_pStr) const;
563 /// is it forbidden to modify cursors via API calls?
564 bool CursorsLocked() const;
565 /// set selections to those contained in the UndoRedoContext
566 /// should only be called by sw::UndoManager!
567 void HandleUndoRedoContext(::sw::UndoRedoContext & rContext);
569 bool Undo(sal_uInt16 const nCount = 1);
570 bool Redo(sal_uInt16 const nCount = 1);
571 bool Repeat(sal_uInt16 const nCount);
573 /// For all views of this document.
574 void StartAllAction();
575 void EndAllAction();
577 /// To enable set up of StartActions and EndActions.
578 virtual void CalcLayout() SAL_OVERRIDE;
580 /// Determine form of content. Return Type at CurCrsr->SPoint.
581 sal_uInt16 GetCntType() const;
583 /// Are there frames, footnotes, etc.
584 bool HasOtherCnt() const;
586 /// Apply ViewOptions with Start-/EndAction.
587 virtual void ApplyViewOptions( const SwViewOption &rOpt ) SAL_OVERRIDE;
589 /** Query text within selection.
590 @returns FALSE, if selected range is too large to be copied
591 into string buffer or if other errors occur. */
592 bool GetSelectedText( OUString &rBuf,
593 int nHndlParaBreak = GETSELTXT_PARABRK_TO_BLANK );
595 /** @return graphic, if CurCrsr->Point() points to a SwGrfNode
596 (and mark is not set or points to the same graphic). */
598 const Graphic* GetGraphic( bool bWait = true ) const;
599 const GraphicObject* GetGraphicObj() const;
601 bool IsGrfSwapOut( bool bOnlyLinked = false ) const;
602 sal_uInt16 GetGraphicType() const;
604 const tools::PolyPolygon *GetGraphicPolygon() const;
605 void SetGraphicPolygon( const tools::PolyPolygon *pPoly );
607 /** If there's an automatic, not manipulated polygon at the selected
608 notxtnode, it has to be deleted, e.g. cause the object has changed. */
609 void ClearAutomaticContour();
611 /// @return the size of a graphic in Twips if cursor is in a graphic.
612 bool GetGrfSize(Size&) const;
614 /** @return name and filter of a graphic if the cursor is in a graphic,
615 else give a rap on the knuckles!
616 If a string-ptr != 0 return the respective name. */
617 void GetGrfNms( OUString* pGrfName, OUString* pFltName,
618 const SwFlyFrameFormat* = 0 ) const;
620 /// Re-read if graphic is not ok. Current graphic is replaced by the new one.
621 void ReRead( const OUString& rGrfName, const OUString& rFltName,
622 const Graphic* pGraphic = 0,
623 const GraphicObject* pGrafObj = 0 );
625 /// Unique identification of object (for ImageMapDlg).
626 void *GetIMapInventor() const;
628 // #i73788#
629 /// Remove default parameter, because method always called this default value.
630 Graphic GetIMapGraphic() const; ///< @return a graphic for all Flys!
631 const SwFlyFrameFormat* FindFlyByName( const OUString& rName, sal_uInt8 nNdTyp = 0 ) const;
633 /** @return a ClientObject, if CurCrsr->Point() points to a SwOLENode
634 (and mark is neither set not pointint to same ClientObject)
635 else give rap on the knuckles. */
636 svt::EmbeddedObjectRef& GetOLEObject() const;
638 /// Is there an OLEObject with this name (SwFormat)?
639 bool HasOLEObj( const OUString &rName ) const;
641 /// @return pointer to the data of the chart in which Cursr is.
642 void SetChartName( const OUString &rName );
644 /// Update content of all charts for table with given name.
645 void UpdateCharts( const OUString &rName );
647 OUString GetCurWord();
649 /** Glossary from glossary document in current document.
650 Styles only if not already existent. */
651 void InsertGlossary( SwTextBlocks& rGlossary, const OUString& );
653 /** Make current selection glossary and insert into glossary document
654 including styles. */
655 sal_uInt16 MakeGlossary( SwTextBlocks& rToFill, const OUString& rName,
656 const OUString& rShortName, bool bSaveRelFile = false,
657 const OUString* pOnlyText=0 );
659 /// Save complete content of doc as glossary.
660 sal_uInt16 SaveGlossaryDoc( SwTextBlocks& rGlossary, const OUString& rName,
661 const OUString& rShortName,
662 bool bSaveRelFile = false,
663 bool bOnlyText = false );
665 // Linguistics...
666 /// Save selections.
667 void HyphStart( SwDocPositions eStart, SwDocPositions eEnd );
669 /// restore selections.
670 void HyphEnd();
671 com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>
672 HyphContinue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt );
674 void HyphIgnore();
676 /// For Inserting SoftHyphen. Position is offset within the syllabificated word.
677 static void InsertSoftHyph( const sal_Int32 nHyphPos );
679 const SwTable& InsertTable( const SwInsertTableOptions& rInsTableOpts, ///< ALL_TBL_INS_ATTR
680 sal_uInt16 nRows, sal_uInt16 nCols,
681 sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
682 const SwTableAutoFormat* pTAFormat = 0 );
684 void InsertDDETable( const SwInsertTableOptions& rInsTableOpts, ///< HEADLINE_NO_BORDER
685 SwDDEFieldType* pDDEType,
686 sal_uInt16 nRows, sal_uInt16 nCols,
687 sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL );
689 void UpdateTable();
690 void SetTableName( SwFrameFormat& rTableFormat, const OUString &rNewName );
692 SwFrameFormat *GetTableFormat();
693 bool TextToTable( const SwInsertTableOptions& rInsTableOpts, ///< ALL_TBL_INS_ATTR
694 sal_Unicode cCh,
695 sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
696 const SwTableAutoFormat* pTAFormat = 0 );
697 bool TableToText( sal_Unicode cCh );
698 bool IsTextToTableAvailable() const;
700 bool GetTableBoxFormulaAttrs( SfxItemSet& rSet ) const;
701 void SetTableBoxFormulaAttrs( const SfxItemSet& rSet );
703 bool IsTableBoxTextFormat() const;
704 OUString GetTableBoxText() const;
706 TableChgMode GetTableChgMode() const;
707 void SetTableChgMode( TableChgMode eMode );
709 /// Split table at cursor position.
710 bool SplitTable( sal_uInt16 eMode );
712 /** Merge tables.
714 Can Merge checks if Prev or Next are possible.
715 If pointer pChkNxtPrv is passed possible direction is given. */
716 bool CanMergeTable( bool bWithPrev = true, bool* pChkNxtPrv = 0 ) const;
717 bool MergeTable( bool bWithPrev = true, sal_uInt16 nMode = 0 );
719 /// Set up InsertDB as table Undo.
720 void AppendUndoForInsertFromDB( bool bIsTable );
722 /// Functions used for spell checking and text conversion.
724 /// Save selections.
725 void SpellStart( SwDocPositions eStart, SwDocPositions eEnd,
726 SwDocPositions eCurr, SwConversionArgs *pConvArgs = 0 );
728 /// Restore selections.
729 void SpellEnd( SwConversionArgs *pConvArgs = 0, bool bRestoreSelection = true );
730 ::com::sun::star::uno::Any SpellContinue(
731 sal_uInt16* pPageCnt, sal_uInt16* pPageSt,
732 SwConversionArgs *pConvArgs = 0 );
734 /** Spells on a sentence basis - the SpellPortions are needed
735 @return false if no error could be found. */
736 bool SpellSentence(svx::SpellPortions& rToFill, bool bIsGrammarCheck );
738 /// Make SpellIter start with the current sentence when called next time.
739 static void PutSpellingToSentenceStart();
741 /// Moves the continuation position to the end of the currently checked sentence.
742 static void MoveContinuationPosToEndOfCheckedSentence();
744 /// Applies a changed sentence.
745 void ApplyChangedSentence(const svx::SpellPortions& rNewPortions, bool bRecheck);
747 /// Check SwSpellIter data to see if the last sentence got grammar checked.
748 static bool HasLastSentenceGotGrammarChecked();
750 /// Is text conversion active somewhere else?
751 static bool HasConvIter();
753 /// Is hyphenation active somewhere else?
754 static bool HasHyphIter();
756 ::com::sun::star::uno::Reference<
757 ::com::sun::star::linguistic2::XSpellAlternatives >
758 GetCorrection( const Point* pPt, SwRect& rSelectRect );
760 bool GetGrammarCorrection( ::com::sun::star::linguistic2::ProofreadingResult /*out*/ &rResult,
761 sal_Int32 /*out*/ &rErrorPosInText,
762 sal_Int32 /*out*/ &rErrorIndexInResult,
763 ::com::sun::star::uno::Sequence< OUString > /*out*/ &rSuggestions,
764 const Point* pPt, SwRect& rSelectRect );
766 static void IgnoreGrammarErrorAt( SwPaM& rErrorPosition );
767 void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnd );
769 /// @return reference set in document according to given name.
770 const SwFormatRefMark* GetRefMark( const OUString& rName ) const;
772 /** @return names of all references set in document.
773 If ArrayPointer == 0 then return only whether a RefMark is set in document. */
774 sal_uInt16 GetRefMarks( std::vector<OUString>* = 0 ) const;
776 /// Call AutoCorrect
777 void AutoCorrect( SvxAutoCorrect& rACorr, bool bInsertMode = true,
778 sal_Unicode cChar = ' ' );
779 bool GetPrevAutoCorrWord( SvxAutoCorrect& rACorr, OUString& rWord );
781 /// Set our styles according to the respective rules.
782 void AutoFormat( const SvxSwAutoFormatFlags* pAFlags = 0 );
784 static SvxSwAutoFormatFlags* GetAutoFormatFlags();
785 static void SetAutoFormatFlags(SvxSwAutoFormatFlags *);
787 /// Calculates selection.
788 OUString Calculate();
790 bool InsertURL( const SwFormatINetFormat& rFormat, const OUString& rStr,
791 bool bKeepSelection = false );
792 void GetINetAttrs( SwGetINetAttrs& rArr );
794 OUString GetDropText( const sal_Int32 nChars ) const;
795 void ReplaceDropText( const OUString &rStr, SwPaM* pPaM = NULL );
797 /** May an outline be moved or copied?
798 Check whether it's in text body, not in table, and not read-only (move). */
799 bool IsOutlineMovable( sal_uInt16 nIdx ) const;
800 bool IsOutlineCopyable( sal_uInt16 nIdx ) const;
802 sal_uInt16 GetLineCount( bool bActPos = true );
804 /// Query and set footnote-text/number. Set.. to current SSelection!
805 bool GetCurFootnote( SwFormatFootnote* pToFillFootnote = 0 );
806 bool SetCurFootnote( const SwFormatFootnote& rFillFootnote );
807 bool HasFootnotes( bool bEndNotes = false ) const;
809 size_t GetSeqFootnoteList( SwSeqFieldList& rList, bool bEndNotes = false );
810 /// @return list of all footnotes and their first portions of text.
812 SwSection const* InsertSection(
813 SwSectionData & rNewData, SfxItemSet const*const = 0 );
814 bool IsInsRegionAvailable() const;
815 const SwSection* GetCurrSection() const;
817 /** @return current range like Cet CurrSection(). But this function iterates
818 also over frames and catches the range even if the cursor is positioned in
819 a footnote the reference of which is in a columned range.
820 If bOutOfTab is set, the range comprising the table is searched
821 and not an inner one. */
822 SwSection* GetAnySection( bool bOutOfTab = false, const Point* pPt = 0 );
824 size_t GetSectionFormatCount() const;
825 size_t GetSectionFormatPos(const SwSectionFormat&) const;
826 const SwSectionFormat& GetSectionFormat(size_t nFormat) const;
827 void DelSectionFormat( size_t nFormat);
828 void UpdateSection( size_t const nSect, SwSectionData &,
829 SfxItemSet const*const = 0);
830 bool IsAnySectionInDoc( bool bChkReadOnly = false,
831 bool bChkHidden = false,
832 bool BChkTOX = false ) const;
834 OUString GetUniqueSectionName( const OUString* pChkStr = 0 ) const;
836 /// Set attributes.
837 void SetSectionAttr(const SfxItemSet& rSet, SwSectionFormat* pSectFormat = 0);
839 /** Search inside the cursor selection for full selected sections.
840 if any part of section in the selection @return 0.
841 if more than one in the selection return the count. */
842 sal_uInt16 GetFullSelectedSectionCount() const;
844 /** Special insert: Insert a new text node just before or after a section or
845 table, if the cursor is positioned at the start/end of said
846 section/table. The purpose of the method is to allow users to inert text
847 at certain 'impossible' position, e.g. before a table at the document
848 start or between to sections. */
849 bool DoSpecialInsert();
850 bool CanSpecialInsert() const;
852 /// Optimizing UI.
853 void SetNewDoc(bool bNew = true);
855 sfx2::LinkManager& GetLinkManager();
856 inline const sfx2::LinkManager& GetLinkManager() const;
858 /** Adjust left margin via object bar (similar to adjustment of numerations).
859 One can either change the margin "by" adding or subtracting a given
860 offset or set it "to" this position @param (bModulus = true). */
861 bool IsMoveLeftMargin( bool bRight = true, bool bModulus = true ) const;
862 void MoveLeftMargin( bool bRight = true, bool bModulus = true );
864 /// Query NumberFormater from document.
865 SvNumberFormatter* GetNumberFormatter();
866 const SvNumberFormatter* GetNumberFormatter() const
867 { return const_cast<SwEditShell*>(this)->GetNumberFormatter(); }
869 /// Interfaces for GlobalDocument.
870 bool IsGlobalDoc() const;
871 void SetGlblDocSaveLinks( bool bFlag = true );
872 bool IsGlblDocSaveLinks() const;
873 void GetGlobalDocContent( SwGlblDocContents& rArr ) const;
874 bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
875 SwSectionData & rNew );
876 bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
877 const SwTOXBase& rTOX );
878 bool InsertGlobalDocContent( const SwGlblDocContent& rPos );
879 bool DeleteGlobalDocContent( const SwGlblDocContents& rArr,
880 size_t nPos );
881 bool MoveGlobalDocContent( const SwGlblDocContents& rArr ,
882 size_t nFromPos, size_t nToPos,
883 size_t nNewPos );
884 bool GotoGlobalDocContent( const SwGlblDocContent& rPos );
886 /// For Redlining.
887 sal_uInt16 GetRedlineMode() const;
888 void SetRedlineMode( sal_uInt16 eMode );
889 bool IsRedlineOn() const;
890 sal_uInt16 GetRedlineCount() const;
891 const SwRangeRedline& GetRedline( sal_uInt16 nPos ) const;
892 bool AcceptRedline( sal_uInt16 nPos );
893 bool RejectRedline( sal_uInt16 nPos );
894 bool AcceptRedlinesInSelection();
895 bool RejectRedlinesInSelection();
897 /** Search Redline for this Data and @return position in array.
898 If not found, return USHRT_MAX. */
899 sal_uInt16 FindRedlineOfData( const SwRedlineData& ) const;
901 /// Set comment to Redline at position.
902 bool SetRedlineComment( const OUString& rS );
903 const SwRangeRedline* GetCurrRedline() const;
905 /// Redline attributes have been changed. Updated views.
906 void UpdateRedlineAttr();
908 /// Compare two documents.
909 long CompareDoc( const SwDoc& rDoc );
911 /// Merge two documents.
912 long MergeDoc( const SwDoc& rDoc );
914 /// Footnote attributes global to document.
915 const SwFootnoteInfo& GetFootnoteInfo() const;
916 void SetFootnoteInfo(const SwFootnoteInfo& rInfo);
917 const SwEndNoteInfo& GetEndNoteInfo() const;
918 void SetEndNoteInfo(const SwEndNoteInfo& rInfo);
920 const SwLineNumberInfo &GetLineNumberInfo() const;
921 void SetLineNumberInfo( const SwLineNumberInfo& rInfo);
923 /// Labels: Synchronize ranges.
924 void SetLabelDoc( bool bFlag = true );
925 bool IsLabelDoc() const;
927 /// Interface for TextInputData - (for input of Japanese/Chinese chars.)
928 SwExtTextInput* CreateExtTextInput(LanguageType eInputLanguage);
929 OUString DeleteExtTextInput( SwExtTextInput* pDel = 0, bool bInsText = true);
930 void SetExtTextInputData( const CommandExtTextInputData& );
932 /// Interface for access to AutoComplete-list.
933 static SwAutoCompleteWord& GetAutoCompleteWords();
935 /** @return a scaling factor of selected text. Used for the rotated
936 character attribute dialog. */
937 sal_uInt16 GetScalingOfSelectedText() const;
939 /// Ctor/Dtor.
940 SwEditShell( SwDoc&, vcl::Window*, const SwViewOption *pOpt = 0 );
942 /// Copy-Constructor in disguise.
943 SwEditShell( SwEditShell&, vcl::Window* );
944 virtual ~SwEditShell();
946 private:
947 SwEditShell(const SwEditShell &) SAL_DELETED_FUNCTION;
948 const SwEditShell &operator=(const SwEditShell &) SAL_DELETED_FUNCTION;
951 inline const sfx2::LinkManager& SwEditShell::GetLinkManager() const
952 { return const_cast<SwEditShell*>(this)->GetLinkManager(); }
954 /// Class for automated call of Start- and EndAction().
955 class SwActContext {
956 SwEditShell & m_rShell;
957 public:
958 SwActContext(SwEditShell *pShell);
959 ~SwActContext();
962 /// Class for automated call of Start- and EndCrsrMove().
963 class SwMvContext {
964 SwEditShell & m_rShell;
965 public:
966 SwMvContext(SwEditShell *pShell);
967 ~SwMvContext();
970 #endif
972 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */