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