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_SW_INC_EDITSH_HXX
20 : #define INCLUDED_SW_INC_EDITSH_HXX
21 :
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>
38 :
39 : #include <vector>
40 : #include <set>
41 : #include <swundo.hxx>
42 : #include <svtools/embedhlp.hxx>
43 : #include <boost/ptr_container/ptr_vector.hpp>
44 :
45 : namespace tools { class PolyPolygon; }
46 : class SwDoc;
47 : class DateTime;
48 : class CommandExtTextInputData;
49 :
50 : class SvNumberFormatter;
51 : class SfxPoolItem;
52 : class SfxItemSet;
53 : class SvxAutoCorrect;
54 :
55 : class SwField;
56 : class SwFieldType;
57 : class SwDDEFieldType;
58 : class SwDBManager;
59 :
60 : struct SwDocStat;
61 : class SwAutoCompleteWord;
62 :
63 : class SwFormatRefMark;
64 :
65 : class SwNumRule;
66 :
67 : class SwTextFormatColl;
68 : class SwGrfNode;
69 : class SwFlyFrameFormat;
70 :
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 : }}}}
101 :
102 : namespace svx{
103 : struct SpellPortion;
104 : typedef std::vector<SpellPortion> SpellPortions;
105 : }
106 :
107 : namespace sfx2{
108 : class LinkManager;
109 : }
110 :
111 : namespace sw {
112 : class UndoRedoContext;
113 : }
114 :
115 : #define GETSELTXT_PARABRK_TO_BLANK 0
116 : #define GETSELTXT_PARABRK_TO_ONLYCR 2
117 :
118 : /// For querying the INet-attributes for Navigator.
119 0 : struct SwGetINetAttr
120 : {
121 : OUString sText;
122 : const SwTextINetFormat& rINetAttr;
123 :
124 0 : SwGetINetAttr( const OUString& rText, const SwTextINetFormat& rAttr )
125 0 : : sText( rText ), rINetAttr( rAttr )
126 0 : {}
127 : };
128 : typedef boost::ptr_vector<SwGetINetAttr> SwGetINetAttrs;
129 :
130 : // Types of forms of content.
131 : #define CNT_TXT 0x0001
132 : #define CNT_GRF 0x0002
133 : #define CNT_OLE 0x0010
134 :
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)
139 :
140 : class SW_DLLPUBLIC SwEditShell : public SwCrsrShell
141 : {
142 : static SvxSwAutoFormatFlags* s_pAutoFormatFlags;
143 :
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;
150 :
151 : SAL_DLLPRIVATE SfxPoolItem& _GetChrFormat( SfxPoolItem& ) const;
152 :
153 : /** Returns pointer to a SwGrfNode
154 : that will be used by GetGraphic() and GetGraphicSize(). */
155 : SAL_DLLPRIVATE SwGrfNode *_GetGrfNode() const ;
156 :
157 : SAL_DLLPRIVATE void DeleteSel( SwPaM& rPam, bool* pUndo = 0 );
158 :
159 : SAL_DLLPRIVATE void _SetSectionAttr( SwSectionFormat& rSectFormat, const SfxItemSet& rSet );
160 :
161 : using SwViewShell::UpdateFields;
162 : using SwModify::GetInfo;
163 :
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 & );
169 :
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 );
176 :
177 : /** Delete content of all ranges.
178 : If whole nodes are selected, these nodes get deleted. */
179 : long Delete();
180 :
181 : /// Remove a complete paragraph.
182 : bool DelFullPara();
183 :
184 : /// Change text to Upper/Lower/Hiragana/Katagana/...
185 : void TransliterateText( sal_uInt32 nType );
186 :
187 : /// Count words in current selection.
188 : void CountWords( SwDocStat& rStat ) const;
189 :
190 : /// Replace fields by text - mailmerge support.
191 : bool ConvertFieldsToText();
192 :
193 : /// Set all numbering start points to a fixed value - mailmerge support.
194 : void SetNumberingRestart();
195 :
196 : /// Embedds all local links (ranges/graphics).
197 : sal_uInt16 GetLinkUpdMode(bool bDocSettings = false) const;
198 : void SetLinkUpdMode( sal_uInt16 nMode );
199 :
200 : /// Copy content of all ranges at current position of cursor to given Shell.
201 : bool Copy( SwEditShell* pDestShell = 0 );
202 :
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 );
208 :
209 : long SplitNode( bool bAutoFormat = false, bool bCheckTableStart = true );
210 : bool AppendTextNode();
211 : void AutoFormatBySplitNode();
212 :
213 : /** If cursor is in a INetAttribute it will be deleted completely
214 : including the descriptive text (needed at drag & drop). */
215 : bool DelINetAttrWithText();
216 :
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();
220 :
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 );
236 :
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 );
242 :
243 : /**
244 : * Get the paragraph format attribute(s) of the current selection.
245 : *
246 : * @see GetPaMParAttr()
247 : *
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.
251 : *
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.
254 : */
255 : bool GetCurParAttr( SfxItemSet& rSet ) const;
256 : /**
257 : * Get the paragraph format attribute(s) of the selection(s) described by a SwPaM.
258 : *
259 : * @param pPaM
260 : * input parameter - the selection where to look for the paragraph format.
261 : *
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.
265 : *
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.
268 : */
269 : bool GetPaMParAttr( SwPaM* pPaM, SfxItemSet& rSet ) const;
270 :
271 : /// Set attribute as new default attribute in document.
272 : void SetDefault( const SfxPoolItem& );
273 :
274 : /// Query default attribute of document.
275 : const SfxPoolItem& GetDefault( sal_uInt16 nFormatHint ) const;
276 :
277 : void ResetAttr( const std::set<sal_uInt16> &attrs = std::set<sal_uInt16>(), SwPaM* pCrsr = NULL );
278 : void GCAttr();
279 :
280 : /// @return the scripttpye of the selection.
281 : SvtScriptType GetScriptType() const;
282 :
283 : /// @return the language at current cursor position.
284 : sal_uInt16 GetCurLang() const;
285 :
286 : /// TABLE
287 : size_t GetTableFrameFormatCount( bool bUsed = false ) const;
288 : SwFrameFormat& GetTableFrameFormat(size_t nFormat, bool bUsed = false ) const;
289 : OUString GetUniqueTableName() const;
290 :
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;
298 :
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.
307 : */
308 :
309 : // TXT
310 : SwTextFormatColl& GetDfltTextFormatColl() const;
311 : sal_uInt16 GetTextFormatCollCount() const;
312 : SwTextFormatColl& GetTextFormatColl( sal_uInt16 nTextFormatColl) const;
313 : /**
314 : * Get the named paragraph format of the current selection.
315 : *
316 : * @see GetPaMTextFormatColl()
317 : *
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).
322 : */
323 : SwTextFormatColl* GetCurTextFormatColl() const;
324 : /**
325 : * Get the named paragraph format of the selection(s) described by a SwPaM.
326 : *
327 : * @param pPaM
328 : * input parameter - the selection where to look for the paragraph format.
329 : *
330 : * @return the named paragraph format of the first node that contains one.
331 : */
332 : SwTextFormatColl* GetPaMTextFormatColl( SwPaM* pPaM ) const;
333 :
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;
341 :
342 : /// @return "Auto-Collection" with given Id. If it does not exist create it.
343 : SwTextFormatColl* GetTextCollFromPool( sal_uInt16 nId );
344 :
345 : /// @return required automatic format base class.
346 : SwFormat* GetFormatFromPool( sal_uInt16 nId );
347 :
348 : /// @return required automatic page style.
349 : SwPageDesc* GetPageDescFromPool( sal_uInt16 nId );
350 :
351 : /// Query if the paragraph-/character-/frame-/page-style is used.
352 : bool IsUsed( const SwModify& ) const;
353 :
354 : /// @return required automatic format.
355 0 : SwFrameFormat* GetFrameFormatFromPool( sal_uInt16 nId )
356 0 : { return static_cast<SwFrameFormat*>(SwEditShell::GetFormatFromPool( nId )); }
357 0 : SwCharFormat* GetCharFormatFromPool( sal_uInt16 nId )
358 0 : { return static_cast<SwCharFormat*>(SwEditShell::GetFormatFromPool( nId )); }
359 :
360 : void Insert2(SwField&, const bool bForceExpandHints = false);
361 :
362 : void UpdateFields( SwField & ); ///< One single field.
363 :
364 : size_t GetFieldTypeCount(sal_uInt16 nResId = USHRT_MAX, bool bUsed = false) const;
365 : SwFieldType* GetFieldType(size_t nField, sal_uInt16 nResId = USHRT_MAX, bool bUsed = false) const;
366 : SwFieldType* GetFieldType(sal_uInt16 nResId, const OUString& rName) const;
367 :
368 : void RemoveFieldType(size_t nField, sal_uInt16 nResId = USHRT_MAX);
369 : void RemoveFieldType(sal_uInt16 nResId, const OUString& rName);
370 :
371 : void FieldToText( SwFieldType* pType );
372 :
373 : void ChangeAuthorityData(const SwAuthEntry* pNewData);
374 :
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 );
383 :
384 : bool IsAnyDatabaseFieldInDoc()const;
385 :
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 :
392 : SwFieldUpdateFlags GetFieldUpdateFlags(bool bDocSettings = false) const;
393 : void SetFieldUpdateFlags( SwFieldUpdateFlags eFlags );
394 :
395 : /// For evaluation of DB fields (new DB-manager).
396 : SwDBManager* GetDBManager() const;
397 :
398 : SwFieldType* InsertFieldType(const SwFieldType &);
399 :
400 : /// Changes in document?
401 : bool IsModified() const;
402 : void SetModified();
403 : void ResetModified();
404 : void SetUndoNoResetModified();
405 :
406 : /// Document - Statistics
407 : void UpdateDocStat();
408 : const SwDocStat &GetUpdatedDocStat();
409 :
410 : void Insert(const SwTOXMark& rMark);
411 :
412 : void DeleteTOXMark(SwTOXMark* pMark);
413 :
414 : /// Get all marks at current SPoint.
415 : sal_uInt16 GetCurTOXMarks(SwTOXMarks& rMarks) const ;
416 :
417 : /// Insert content table. Renew if required.
418 : void InsertTableOf(const SwTOXBase& rTOX,
419 : const SfxItemSet* pSet = 0);
420 : bool UpdateTableOf(const SwTOXBase& rTOX,
421 : const SfxItemSet* pSet = 0);
422 : const SwTOXBase* GetCurTOX() const;
423 : const SwTOXBase* GetDefaultTOXBase( TOXTypes eTyp, bool bCreate = false );
424 : void SetDefaultTOXBase(const SwTOXBase& rBase);
425 :
426 : static bool IsTOXBaseReadonly(const SwTOXBase& rTOXBase);
427 : void SetTOXBaseReadonly(const SwTOXBase& rTOXBase, bool bReadonly);
428 :
429 : sal_uInt16 GetTOXCount() const;
430 : const SwTOXBase* GetTOX( sal_uInt16 nPos ) const;
431 : bool DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes = false );
432 :
433 : /// After reading file update all content tables.
434 : void SetUpdateTOX( bool bFlag = true );
435 : bool IsUpdateTOX() const;
436 :
437 : /// Manage types of content tables.
438 : sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const;
439 : const SwTOXType* GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const;
440 : void InsertTOXType(const SwTOXType& rTyp);
441 :
442 : /// AutoMark file
443 : OUString GetTOIAutoMarkURL() const;
444 : void SetTOIAutoMarkURL(const OUString& rSet);
445 : void ApplyAutoMark();
446 :
447 : /// Key for managing index.
448 : sal_uInt16 GetTOIKeys( SwTOIKeyType eTyp, std::vector<OUString>& rArr ) const;
449 :
450 : void SetOutlineNumRule(const SwNumRule&);
451 : const SwNumRule* GetOutlineNumRule() const;
452 :
453 : bool OutlineUpDown( short nOffset = 1 );
454 :
455 : bool MoveOutlinePara( short nOffset = 1);
456 :
457 : bool IsProtectedOutlinePara() const;
458 :
459 : const SwNumRule* GetNumRuleAtCurrCrsrPos() const;
460 :
461 : /** Returns the numbering rule found at the paragraphs of the current selection,
462 : if all paragraphs of the current selection have the same or none numbering rule applied. */
463 : const SwNumRule* GetNumRuleAtCurrentSelection() const;
464 :
465 : /** Optional parameter <bResetIndentAttrs> (default value false).
466 : If <bResetIndentAttrs> equals true, the indent attributes "before text"
467 : and "first line indent" are additionally reset at the current selection,
468 : if the list style makes use of the new list level attributes.
469 : Parameters <bCreateNewList> and <sContinuedListId>
470 : <bCreateNewList> indicates, if a new list is created by applying the given list style.
471 : If <bCreateNewList> equals false, <sContinuedListId> may contain the
472 : list Id of a list, which has to be continued by applying the given list style */
473 : void SetCurNumRule( const SwNumRule&,
474 : const bool bCreateNewList /*= false*/,
475 : const OUString& sContinuedListId = OUString(),
476 : const bool bResetIndentAttrs = false );
477 :
478 : /// Paragraphs without enumeration but with indents.
479 : bool NoNum();
480 :
481 : /// Delete, split enumeration list.
482 : void DelNumRules();
483 :
484 : bool NumUpDown( bool bDown = true );
485 :
486 : bool MoveParagraph( long nOffset = 1);
487 : bool MoveNumParas( bool bUpperLower, bool bUpperLeft );
488 :
489 : /// Switch on/off of numbering via Delete/Backspace.
490 : bool NumOrNoNum(bool bDelete = false, bool bChkStart = true);
491 :
492 : // #i23726#
493 : // #i90078#
494 : /// Remove unused default parameter <nLevel> and <bRelative>.
495 : // Adjust method name and parameter name
496 : void ChangeIndentOfAllListLevels( short nDiff );
497 : // Adjust method name
498 : void SetIndent(short nIndent, const SwPosition & rPos);
499 : bool IsFirstOfNumRuleAtCrsrPos() const;
500 :
501 : bool IsNoNum( bool bChkStart = true ) const;
502 :
503 : /** @return Num-Level of the node in which point of cursor is.
504 : @return values can be: NO_NUMBERING,
505 : 0..MAXLEVEL-1, NO_NUMLEVEL .. NO_NUMLEVEL|MAXLEVEL-1 */
506 : sal_uInt8 GetNumLevel() const;
507 :
508 : /// Detect highest and lowest level to check moving of outline levels.
509 : void GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower );
510 :
511 : /// Get Outline level of current paragraph.
512 : int GetCurrentParaOutlineLevel( ) const;
513 :
514 : // i29560
515 : bool HasNumber() const;
516 : bool HasBullet() const;
517 :
518 : bool SelectionHasNumber() const;
519 : bool SelectionHasBullet() const;
520 :
521 : OUString GetUniqueNumRuleName( const OUString* pChkStr = 0, bool bAutoNum = true ) const;
522 : void ChgNumRuleFormats( const SwNumRule& rRule );
523 :
524 : /// Set (and query if) a numbering with StartFlag starts at current PointPos.
525 : void SetNumRuleStart( bool bFlag = true, SwPaM* pCrsr = NULL );
526 : bool IsNumRuleStart( SwPaM* pPaM = NULL ) const;
527 : void SetNodeNumStart( sal_uInt16 nStt, SwPaM* = NULL );
528 :
529 : sal_uInt16 GetNodeNumStart( SwPaM* pPaM = NULL ) const;
530 :
531 : bool ReplaceNumRule( const OUString& rOldRule, const OUString& rNewRule );
532 :
533 : /** Searches for a text node with a numbering rule.
534 : in case a list style is found, <sListId> holds the list id, to which the
535 : text node belongs, which applies the found list style. */
536 : const SwNumRule * SearchNumRule(const bool bForward,
537 : const bool bNum,
538 : const bool bOutline,
539 : int nNonEmptyAllowed,
540 : OUString& sListId );
541 :
542 : /** Undo.
543 : Maintain UndoHistory in Document.
544 : Reset UndoHistory at Save, SaveAs, Create ??? */
545 : void DoUndo( bool bOn = true );
546 : bool DoesUndo() const;
547 : void DoGroupUndo( bool bUn = true );
548 : bool DoesGroupUndo() const;
549 : void DelAllUndoObj();
550 :
551 : /// Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
552 : SwUndoId StartUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
553 :
554 : /// Closes parenthesis of nUndoId, not used by UI.
555 : SwUndoId EndUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
556 :
557 : bool GetLastUndoInfo(OUString *const o_pStr,
558 : SwUndoId *const o_pId) const;
559 : bool GetFirstRedoInfo(OUString *const o_pStr) const;
560 : SwUndoId GetRepeatInfo(OUString *const o_pStr) const;
561 :
562 : /// is it forbidden to modify cursors via API calls?
563 : bool CursorsLocked() const;
564 : /// set selections to those contained in the UndoRedoContext
565 : /// should only be called by sw::UndoManager!
566 : void HandleUndoRedoContext(::sw::UndoRedoContext & rContext);
567 :
568 : bool Undo(sal_uInt16 const nCount = 1);
569 : bool Redo(sal_uInt16 const nCount = 1);
570 : bool Repeat(sal_uInt16 const nCount);
571 :
572 : /// For all views of this document.
573 : void StartAllAction();
574 : void EndAllAction();
575 :
576 : /// To enable set up of StartActions and EndActions.
577 : virtual void CalcLayout() SAL_OVERRIDE;
578 :
579 : /// Determine form of content. Return Type at CurCrsr->SPoint.
580 : sal_uInt16 GetCntType() const;
581 :
582 : /// Are there frames, footnotes, etc.
583 : bool HasOtherCnt() const;
584 :
585 : /// Apply ViewOptions with Start-/EndAction.
586 : virtual void ApplyViewOptions( const SwViewOption &rOpt ) SAL_OVERRIDE;
587 :
588 : /** Query text within selection.
589 : @returns FALSE, if selected range is too large to be copied
590 : into string buffer or if other errors occur. */
591 : bool GetSelectedText( OUString &rBuf,
592 : int nHndlParaBreak = GETSELTXT_PARABRK_TO_BLANK );
593 :
594 : /** @return graphic, if CurCrsr->Point() points to a SwGrfNode
595 : (and mark is not set or points to the same graphic). */
596 :
597 : const Graphic* GetGraphic( bool bWait = true ) const;
598 : const GraphicObject* GetGraphicObj() const;
599 :
600 : bool IsGrfSwapOut( bool bOnlyLinked = false ) const;
601 : sal_uInt16 GetGraphicType() const;
602 :
603 : const tools::PolyPolygon *GetGraphicPolygon() const;
604 : void SetGraphicPolygon( const tools::PolyPolygon *pPoly );
605 :
606 : /** If there's an automatic, not manipulated polygon at the selected
607 : notxtnode, it has to be deleted, e.g. cause the object has changed. */
608 : void ClearAutomaticContour();
609 :
610 : /// @return the size of a graphic in Twips if cursor is in a graphic.
611 : bool GetGrfSize(Size&) const;
612 :
613 : /** @return name and filter of a graphic if the cursor is in a graphic,
614 : else give a rap on the knuckles!
615 : If a string-ptr != 0 return the respective name. */
616 : void GetGrfNms( OUString* pGrfName, OUString* pFltName,
617 : const SwFlyFrameFormat* = 0 ) const;
618 :
619 : /// Re-read if graphic is not ok. Current graphic is replaced by the new one.
620 : void ReRead( const OUString& rGrfName, const OUString& rFltName,
621 : const Graphic* pGraphic = 0,
622 : const GraphicObject* pGrafObj = 0 );
623 :
624 : /// Unique identification of object (for ImageMapDlg).
625 : void *GetIMapInventor() const;
626 :
627 : // #i73788#
628 : /// Remove default parameter, because method always called this default value.
629 : Graphic GetIMapGraphic() const; ///< @return a graphic for all Flys!
630 : const SwFlyFrameFormat* FindFlyByName( const OUString& rName, sal_uInt8 nNdTyp = 0 ) const;
631 :
632 : /** @return a ClientObject, if CurCrsr->Point() points to a SwOLENode
633 : (and mark is neither set not pointint to same ClientObject)
634 : else give rap on the knuckles. */
635 : svt::EmbeddedObjectRef& GetOLEObject() const;
636 :
637 : /// Is there an OLEObject with this name (SwFormat)?
638 : bool HasOLEObj( const OUString &rName ) const;
639 :
640 : /// @return pointer to the data of the chart in which Cursr is.
641 : void SetChartName( const OUString &rName );
642 :
643 : /// Update content of all charts for table with given name.
644 : void UpdateCharts( const OUString &rName );
645 :
646 : OUString GetCurWord();
647 :
648 : /** Glossary from glossary document in current document.
649 : Styles only if not already existent. */
650 : void InsertGlossary( SwTextBlocks& rGlossary, const OUString& );
651 :
652 : /** Make current selection glossary and insert into glossary document
653 : including styles. */
654 : sal_uInt16 MakeGlossary( SwTextBlocks& rToFill, const OUString& rName,
655 : const OUString& rShortName, bool bSaveRelFile = false,
656 : const OUString* pOnlyText=0 );
657 :
658 : /// Save complete content of doc as glossary.
659 : sal_uInt16 SaveGlossaryDoc( SwTextBlocks& rGlossary, const OUString& rName,
660 : const OUString& rShortName,
661 : bool bSaveRelFile = false,
662 : bool bOnlyText = false );
663 :
664 : // Linguistics...
665 : /// Save selections.
666 : void HyphStart( SwDocPositions eStart, SwDocPositions eEnd );
667 :
668 : /// restore selections.
669 : void HyphEnd();
670 : com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>
671 : HyphContinue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt );
672 :
673 : void HyphIgnore();
674 :
675 : /// For Inserting SoftHyphen. Position is offset within the syllabificated word.
676 : static void InsertSoftHyph( const sal_Int32 nHyphPos );
677 :
678 : const SwTable& InsertTable( const SwInsertTableOptions& rInsTableOpts, ///< ALL_TBL_INS_ATTR
679 : sal_uInt16 nRows, sal_uInt16 nCols,
680 : sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
681 : const SwTableAutoFormat* pTAFormat = 0 );
682 :
683 : void InsertDDETable( const SwInsertTableOptions& rInsTableOpts, ///< HEADLINE_NO_BORDER
684 : SwDDEFieldType* pDDEType,
685 : sal_uInt16 nRows, sal_uInt16 nCols,
686 : sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL );
687 :
688 : void UpdateTable();
689 : void SetTableName( SwFrameFormat& rTableFormat, const OUString &rNewName );
690 :
691 : SwFrameFormat *GetTableFormat();
692 : bool TextToTable( const SwInsertTableOptions& rInsTableOpts, ///< ALL_TBL_INS_ATTR
693 : sal_Unicode cCh,
694 : sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
695 : const SwTableAutoFormat* pTAFormat = 0 );
696 : bool TableToText( sal_Unicode cCh );
697 : bool IsTextToTableAvailable() const;
698 :
699 : bool GetTableBoxFormulaAttrs( SfxItemSet& rSet ) const;
700 : void SetTableBoxFormulaAttrs( const SfxItemSet& rSet );
701 :
702 : bool IsTableBoxTextFormat() const;
703 : OUString GetTableBoxText() const;
704 :
705 : TableChgMode GetTableChgMode() const;
706 : void SetTableChgMode( TableChgMode eMode );
707 :
708 : /// Split table at cursor position.
709 : bool SplitTable( sal_uInt16 eMode );
710 :
711 : /** Merge tables.
712 :
713 : Can Merge checks if Prev or Next are possible.
714 : If pointer pChkNxtPrv is passed possible direction is given. */
715 : bool CanMergeTable( bool bWithPrev = true, bool* pChkNxtPrv = 0 ) const;
716 : bool MergeTable( bool bWithPrev = true, sal_uInt16 nMode = 0 );
717 :
718 : /// Set up InsertDB as table Undo.
719 : void AppendUndoForInsertFromDB( bool bIsTable );
720 :
721 : /// Functions used for spell checking and text conversion.
722 :
723 : /// Save selections.
724 : void SpellStart( SwDocPositions eStart, SwDocPositions eEnd,
725 : SwDocPositions eCurr, SwConversionArgs *pConvArgs = 0 );
726 :
727 : /// Restore selections.
728 : void SpellEnd( SwConversionArgs *pConvArgs = 0, bool bRestoreSelection = true );
729 : ::com::sun::star::uno::Any SpellContinue(
730 : sal_uInt16* pPageCnt, sal_uInt16* pPageSt,
731 : SwConversionArgs *pConvArgs = 0 );
732 :
733 : /** Spells on a sentence basis - the SpellPortions are needed
734 : @return false if no error could be found. */
735 : bool SpellSentence(svx::SpellPortions& rToFill, bool bIsGrammarCheck );
736 :
737 : /// Make SpellIter start with the current sentence when called next time.
738 : static void PutSpellingToSentenceStart();
739 :
740 : /// Moves the continuation position to the end of the currently checked sentence.
741 : static void MoveContinuationPosToEndOfCheckedSentence();
742 :
743 : /// Applies a changed sentence.
744 : void ApplyChangedSentence(const svx::SpellPortions& rNewPortions, bool bRecheck);
745 :
746 : /// Check SwSpellIter data to see if the last sentence got grammar checked.
747 : static bool HasLastSentenceGotGrammarChecked();
748 :
749 : /// Is text conversion active somewhere else?
750 : static bool HasConvIter();
751 :
752 : /// Is hyphenation active somewhere else?
753 : static bool HasHyphIter();
754 :
755 : ::com::sun::star::uno::Reference<
756 : ::com::sun::star::linguistic2::XSpellAlternatives >
757 : GetCorrection( const Point* pPt, SwRect& rSelectRect );
758 :
759 : bool GetGrammarCorrection( ::com::sun::star::linguistic2::ProofreadingResult /*out*/ &rResult,
760 : sal_Int32 /*out*/ &rErrorPosInText,
761 : sal_Int32 /*out*/ &rErrorIndexInResult,
762 : ::com::sun::star::uno::Sequence< OUString > /*out*/ &rSuggestions,
763 : const Point* pPt, SwRect& rSelectRect );
764 :
765 : static void IgnoreGrammarErrorAt( SwPaM& rErrorPosition );
766 : void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnd );
767 :
768 : /// @return reference set in document according to given name.
769 : const SwFormatRefMark* GetRefMark( const OUString& rName ) const;
770 :
771 : /** @return names of all references set in document.
772 : If ArrayPointer == 0 then return only whether a RefMark is set in document. */
773 : sal_uInt16 GetRefMarks( std::vector<OUString>* = 0 ) const;
774 :
775 : /// Call AutoCorrect
776 : void AutoCorrect( SvxAutoCorrect& rACorr, bool bInsertMode = true,
777 : sal_Unicode cChar = ' ' );
778 : bool GetPrevAutoCorrWord( SvxAutoCorrect& rACorr, OUString& rWord );
779 :
780 : /// Set our styles according to the respective rules.
781 : void AutoFormat( const SvxSwAutoFormatFlags* pAFlags = 0 );
782 :
783 : static SvxSwAutoFormatFlags* GetAutoFormatFlags();
784 : static void SetAutoFormatFlags(SvxSwAutoFormatFlags *);
785 :
786 : /// Calculates selection.
787 : OUString Calculate();
788 :
789 : bool InsertURL( const SwFormatINetFormat& rFormat, const OUString& rStr,
790 : bool bKeepSelection = false );
791 : void GetINetAttrs( SwGetINetAttrs& rArr );
792 :
793 : OUString GetDropText( const sal_Int32 nChars ) const;
794 : void ReplaceDropText( const OUString &rStr, SwPaM* pPaM = NULL );
795 :
796 : /** May an outline be moved or copied?
797 : Check whether it's in text body, not in table, and not read-only (move). */
798 : bool IsOutlineMovable( sal_uInt16 nIdx ) const;
799 : bool IsOutlineCopyable( sal_uInt16 nIdx ) const;
800 :
801 : sal_uInt16 GetLineCount( bool bActPos = true );
802 :
803 : /// Query and set footnote-text/number. Set.. to current SSelection!
804 : bool GetCurFootnote( SwFormatFootnote* pToFillFootnote = 0 );
805 : bool SetCurFootnote( const SwFormatFootnote& rFillFootnote );
806 : bool HasFootnotes( bool bEndNotes = false ) const;
807 :
808 : size_t GetSeqFootnoteList( SwSeqFieldList& rList, bool bEndNotes = false );
809 : /// @return list of all footnotes and their first portions of text.
810 :
811 : SwSection const* InsertSection(
812 : SwSectionData & rNewData, SfxItemSet const*const = 0 );
813 : bool IsInsRegionAvailable() const;
814 : const SwSection* GetCurrSection() const;
815 :
816 : /** @return current range like Cet CurrSection(). But this function iterates
817 : also over frames and catches the range even if the cursor is positioned in
818 : a footnote the reference of which is in a columned range.
819 : If bOutOfTab is set, the range comprising the table is searched
820 : and not an inner one. */
821 : SwSection* GetAnySection( bool bOutOfTab = false, const Point* pPt = 0 );
822 :
823 : size_t GetSectionFormatCount() const;
824 : size_t GetSectionFormatPos(const SwSectionFormat&) const;
825 : const SwSectionFormat& GetSectionFormat(size_t nFormat) const;
826 : void DelSectionFormat( size_t nFormat);
827 : void UpdateSection( size_t const nSect, SwSectionData &,
828 : SfxItemSet const*const = 0);
829 : bool IsAnySectionInDoc( bool bChkReadOnly = false,
830 : bool bChkHidden = false,
831 : bool BChkTOX = false ) const;
832 :
833 : OUString GetUniqueSectionName( const OUString* pChkStr = 0 ) const;
834 :
835 : /// Set attributes.
836 : void SetSectionAttr(const SfxItemSet& rSet, SwSectionFormat* pSectFormat = 0);
837 :
838 : /** Search inside the cursor selection for full selected sections.
839 : if any part of section in the selection @return 0.
840 : if more than one in the selection return the count. */
841 : sal_uInt16 GetFullSelectedSectionCount() const;
842 :
843 : /** Special insert: Insert a new text node just before or after a section or
844 : table, if the cursor is positioned at the start/end of said
845 : section/table. The purpose of the method is to allow users to inert text
846 : at certain 'impossible' position, e.g. before a table at the document
847 : start or between to sections. */
848 : bool DoSpecialInsert();
849 : bool CanSpecialInsert() const;
850 :
851 : /// Optimizing UI.
852 : void SetNewDoc(bool bNew = true);
853 :
854 : sfx2::LinkManager& GetLinkManager();
855 : inline const sfx2::LinkManager& GetLinkManager() const;
856 :
857 : /** Adjust left margin via object bar (similar to adjustment of numerations).
858 : One can either change the margin "by" adding or subtracting a given
859 : offset or set it "to" this position @param (bModulus = true). */
860 : bool IsMoveLeftMargin( bool bRight = true, bool bModulus = true ) const;
861 : void MoveLeftMargin( bool bRight = true, bool bModulus = true );
862 :
863 : /// Query NumberFormater from document.
864 : SvNumberFormatter* GetNumberFormatter();
865 : const SvNumberFormatter* GetNumberFormatter() const
866 : { return const_cast<SwEditShell*>(this)->GetNumberFormatter(); }
867 :
868 : /// Interfaces for GlobalDocument.
869 : bool IsGlobalDoc() const;
870 : void SetGlblDocSaveLinks( bool bFlag = true );
871 : bool IsGlblDocSaveLinks() const;
872 : void GetGlobalDocContent( SwGlblDocContents& rArr ) const;
873 : bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
874 : SwSectionData & rNew );
875 : bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
876 : const SwTOXBase& rTOX );
877 : bool InsertGlobalDocContent( const SwGlblDocContent& rPos );
878 : bool DeleteGlobalDocContent( const SwGlblDocContents& rArr,
879 : size_t nPos );
880 : bool MoveGlobalDocContent( const SwGlblDocContents& rArr ,
881 : size_t nFromPos, size_t nToPos,
882 : size_t nNewPos );
883 : bool GotoGlobalDocContent( const SwGlblDocContent& rPos );
884 :
885 : /// For Redlining.
886 : sal_uInt16 GetRedlineMode() const;
887 : void SetRedlineMode( sal_uInt16 eMode );
888 : bool IsRedlineOn() const;
889 : sal_uInt16 GetRedlineCount() const;
890 : const SwRangeRedline& GetRedline( sal_uInt16 nPos ) const;
891 : bool AcceptRedline( sal_uInt16 nPos );
892 : bool RejectRedline( sal_uInt16 nPos );
893 : bool AcceptRedlinesInSelection();
894 : bool RejectRedlinesInSelection();
895 :
896 : /** Search Redline for this Data and @return position in array.
897 : If not found, return USHRT_MAX. */
898 : sal_uInt16 FindRedlineOfData( const SwRedlineData& ) const;
899 :
900 : /// Set comment to Redline at position.
901 : bool SetRedlineComment( const OUString& rS );
902 : const SwRangeRedline* GetCurrRedline() const;
903 :
904 : /// Redline attributes have been changed. Updated views.
905 : void UpdateRedlineAttr();
906 :
907 : /// Compare two documents.
908 : long CompareDoc( const SwDoc& rDoc );
909 :
910 : /// Merge two documents.
911 : long MergeDoc( const SwDoc& rDoc );
912 :
913 : /// Footnote attributes global to document.
914 : const SwFootnoteInfo& GetFootnoteInfo() const;
915 : void SetFootnoteInfo(const SwFootnoteInfo& rInfo);
916 : const SwEndNoteInfo& GetEndNoteInfo() const;
917 : void SetEndNoteInfo(const SwEndNoteInfo& rInfo);
918 :
919 : const SwLineNumberInfo &GetLineNumberInfo() const;
920 : void SetLineNumberInfo( const SwLineNumberInfo& rInfo);
921 :
922 : /// Labels: Synchronize ranges.
923 : void SetLabelDoc( bool bFlag = true );
924 : bool IsLabelDoc() const;
925 :
926 : /// Interface for TextInputData - (for input of Japanese/Chinese chars.)
927 : SwExtTextInput* CreateExtTextInput(LanguageType eInputLanguage);
928 : OUString DeleteExtTextInput( SwExtTextInput* pDel = 0, bool bInsText = true);
929 : void SetExtTextInputData( const CommandExtTextInputData& );
930 :
931 : /// Interface for access to AutoComplete-list.
932 : static SwAutoCompleteWord& GetAutoCompleteWords();
933 :
934 : /** @return a scaling factor of selected text. Used for the rotated
935 : character attribute dialog. */
936 : sal_uInt16 GetScalingOfSelectedText() const;
937 :
938 : /// Ctor/Dtor.
939 : SwEditShell( SwDoc&, vcl::Window*, const SwViewOption *pOpt = 0 );
940 :
941 : /// Copy-Constructor in disguise.
942 : SwEditShell( SwEditShell&, vcl::Window* );
943 : virtual ~SwEditShell();
944 :
945 : private:
946 : SwEditShell(const SwEditShell &) SAL_DELETED_FUNCTION;
947 : const SwEditShell &operator=(const SwEditShell &) SAL_DELETED_FUNCTION;
948 : };
949 :
950 : inline const sfx2::LinkManager& SwEditShell::GetLinkManager() const
951 : { return const_cast<SwEditShell*>(this)->GetLinkManager(); }
952 :
953 : /// Class for automated call of Start- and EndAction().
954 : class SwActContext {
955 : SwEditShell & m_rShell;
956 : public:
957 : SwActContext(SwEditShell *pShell);
958 : ~SwActContext();
959 : };
960 :
961 : /// Class for automated call of Start- and EndCrsrMove().
962 : class SwMvContext {
963 : SwEditShell & m_rShell;
964 : public:
965 : SwMvContext(SwEditShell *pShell);
966 : ~SwMvContext();
967 : };
968 :
969 : #endif
970 :
971 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|