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 :
36 : #include <vector>
37 : #include <set>
38 : #include <swundo.hxx>
39 : #include <svtools/embedhlp.hxx>
40 : #include <boost/ptr_container/ptr_vector.hpp>
41 :
42 : class PolyPolygon;
43 : class SwDoc;
44 : class DateTime;
45 : class CommandExtTextInputData;
46 :
47 : class SvNumberFormatter;
48 : class SfxPoolItem;
49 : class SfxItemSet;
50 : class SvxAutoCorrect;
51 :
52 : class SwField;
53 : class SwFieldType;
54 : class SwDDEFieldType;
55 : class SwNewDBMgr;
56 :
57 : struct SwDocStat;
58 : class SwAutoCompleteWord;
59 :
60 : class SwFmtRefMark;
61 :
62 : class SwNumRule;
63 :
64 : class SwTxtFmtColl;
65 : class SwGrfNode;
66 : class SwFlyFrmFmt;
67 :
68 : class SwFrmFmt;
69 : class SwCharFmt;
70 : class SwExtTextInput;
71 : class Graphic;
72 : class GraphicObject;
73 : class SwFmtINetFmt;
74 : class SwTable;
75 : class SwTextBlocks;
76 : class SwFmtFtn;
77 : class SwSection;
78 : class SwSectionData;
79 : class SwSectionFmt;
80 : class SwTOXMarks;
81 : class SwTOXBase;
82 : class SwTOXType;
83 : class SwTableAutoFmt;
84 : class SwPageDesc;
85 : class SwTxtINetFmt;
86 : class SwSeqFldList;
87 : class SwGlblDocContent;
88 : class SwGlblDocContents;
89 : class SwRangeRedline;
90 : class SwRedlineData;
91 : class SwFtnInfo;
92 : class SwEndNoteInfo;
93 : class SwLineNumberInfo;
94 : class SwAuthEntry;
95 : class SwRewriter;
96 : struct SwConversionArgs;
97 :
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_KEEP 1
117 : #define GETSELTXT_PARABRK_TO_ONLYCR 2
118 :
119 : /// For querying the INet-attributes for Navigator.
120 0 : struct SwGetINetAttr
121 : {
122 : OUString sText;
123 : const SwTxtINetFmt& rINetAttr;
124 :
125 0 : SwGetINetAttr( const OUString& rTxt, const SwTxtINetFmt& rAttr )
126 0 : : sText( rTxt ), rINetAttr( rAttr )
127 0 : {}
128 : };
129 : typedef boost::ptr_vector<SwGetINetAttr> SwGetINetAttrs;
130 :
131 : // Types of forms of content.
132 : #define CNT_TXT 0x0001
133 : #define CNT_GRF 0x0002
134 : #define CNT_OLE 0x0010
135 :
136 : // Test USHORT for a defined form of content.
137 : #define CNT_HasTxt(USH) ((USH)&CNT_TXT)
138 : #define CNT_HasGrf(USH) ((USH)&CNT_GRF)
139 : #define CNT_HasOLE(USH) ((USH)&CNT_OLE)
140 :
141 : class SW_DLLPUBLIC SwEditShell: public SwCrsrShell
142 : {
143 : static SvxSwAutoFmtFlags* pAutoFmtFlags;
144 :
145 : /// For the private methods DelRange and those of AutoCorrect.
146 : friend class SwAutoFormat;
147 : friend void _InitCore();
148 : friend void _FinitCore();
149 : /// For the PamCorrAbs/-Rel methods.
150 : friend class SwUndo;
151 :
152 : SAL_DLLPRIVATE SfxPoolItem& _GetChrFmt( SfxPoolItem& ) const;
153 :
154 : /** Returns pointer to a SwGrfNode
155 : that will be used by GetGraphic() and GetGraphicSize(). */
156 : SAL_DLLPRIVATE SwGrfNode *_GetGrfNode() const ;
157 :
158 : SAL_DLLPRIVATE void DeleteSel( SwPaM& rPam, sal_Bool* pUndo = 0 );
159 :
160 : SAL_DLLPRIVATE void _SetSectionAttr( SwSectionFmt& rSectFmt, const SfxItemSet& rSet );
161 :
162 : using SwViewShell::UpdateFlds;
163 : using SwModify::GetInfo;
164 :
165 : public:
166 : /// Edit (all selected ranges).
167 : void Insert( sal_Unicode, sal_Bool bOnlyCurrCrsr = sal_False );
168 : void Insert2( const OUString &, const bool bForceExpandHints = false );
169 : void Overwrite( const OUString & );
170 :
171 : /** Replace a selected range in a TextNode by given string.
172 : Meant for Search & Replace.
173 : bRegExpRplc - replace tabs (\\t) and insert found string (not \&).
174 : E.g.: Fnd: "zzz", Repl: "xx\t\\t..&..\&"
175 : --> "xx\t<Tab>..zzz..&" */
176 : sal_Bool Replace( const OUString& rNewStr, sal_Bool bRegExpRplc = sal_False );
177 :
178 : /** Delete content of all ranges.
179 : If whole nodes are selected, these nodes get deleted. */
180 : long Delete();
181 :
182 : /// Remove a complete paragraph.
183 : sal_Bool DelFullPara();
184 :
185 : /// Change text to Upper/Lower/Hiragana/Katagana/...
186 : void TransliterateText( sal_uInt32 nType );
187 :
188 : /// Count words in current selection.
189 : void CountWords( SwDocStat& rStat ) const;
190 :
191 : /** Delete non-visible content in the document.
192 : E.g. hidden ranges, hidden paragraphs. */
193 : sal_Bool RemoveInvisibleContent();
194 :
195 : /// Replace fields by text - mailmerge support.
196 : bool ConvertFieldsToText();
197 :
198 : /// Set all numbering start points to a fixed value - mailmerge support.
199 : void SetNumberingRestart();
200 :
201 : /// Embedds all local links (ranges/graphics).
202 : sal_uInt16 GetLinkUpdMode(sal_Bool bDocSettings = sal_False) const;
203 : void SetLinkUpdMode( sal_uInt16 nMode );
204 :
205 : /// Copy content of all ranges at current position of cursor to given Shell.
206 : long Copy( SwEditShell* pDestShell = 0 );
207 :
208 : /** For copying via ClipBoard:
209 : If table is copied into table, move all cursors away from it.
210 : Copy and Paste must be in FEShell because of FlyFrames!
211 : Copy all selections to the document. */
212 : sal_Bool _CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pNdInsPos = 0 );
213 :
214 : long SplitNode( sal_Bool bAutoFormat = sal_False, sal_Bool bCheckTableStart = sal_True );
215 : sal_Bool AppendTxtNode();
216 : void AutoFmtBySplitNode();
217 :
218 : /** If cursor is in a INetAttribute it will be deleted completely
219 : including the descriptive text (needed at drag & drop). */
220 : sal_Bool DelINetAttrWithText();
221 :
222 : /** If Cursor is at the end of a character style in which the DontExpand-flag
223 : is not yet set, the latter will be set (==> return TRUE). */
224 : bool DontExpandFmt();
225 :
226 : /** Apply / remove attributes.
227 : @return attributs in required AttributeSet.
228 : When not unambiguous the set has a DONT_CARE !!
229 : 2nd optional parameter <bMergeIndentValuesOfNumRule>.
230 : If <bMergeIndentValuesOfNumRule> == sal_True, the indent attributes of
231 : the corresponding list level of an applied list style is merged into
232 : the requested item set as a LR-SPACE item, if corresponding node has not
233 : its own indent attributes and the position-and-space mode of the list
234 : level is SvxNumberFormat::LABEL_ALIGNMENT. */
235 : sal_Bool GetPaMAttr( SwPaM* pPaM, SfxItemSet& ,
236 : const bool bMergeIndentValuesOfNumRule = false ) const;
237 : sal_Bool GetCurAttr( SfxItemSet& ,
238 : const bool bMergeIndentValuesOfNumRule = false ) const;
239 : void SetAttrItem( const SfxPoolItem&, sal_uInt16 nFlags = 0 );
240 : void SetAttrSet( const SfxItemSet&, sal_uInt16 nFlags = 0, SwPaM* pCrsr = NULL );
241 :
242 : /**
243 : * Get the paragraph format attribute(s) of the current selection.
244 : *
245 : * @see GetPaMParAttr()
246 : *
247 : * @param rSet
248 : * output parameter - the SfxItemSet where the automatic paragraph format attribut(s) will be store.
249 : * The attributes aren't invalidated or cleared if the function reach the getMaxLookup limite.
250 : *
251 : * @return true if the function inspect all the nodes point by the pPaM parameter,
252 : * false if the function reach the limit of getMaxLookup number of nodes inspected.
253 : */
254 : sal_Bool GetCurParAttr( SfxItemSet& rSet ) const;
255 : /**
256 : * Get the paragraph format attribute(s) of the selection(s) described by a SwPaM.
257 : *
258 : * @param pPaM
259 : * input parameter - the selection where to look for the paragraph format.
260 : *
261 : * @param rSet
262 : * output parameter - the SfxItemSet where the automatic paragraph format attribute(s) will be store.
263 : * The attributes aren't invalidated or cleared if the function reaches the getMaxLookup limit.
264 : *
265 : * @return true if the function inspects all the nodes point by the pPaM parameter,
266 : * false if the function reaches the limit of getMaxLookup number of nodes inspected.
267 : */
268 : sal_Bool GetPaMParAttr( SwPaM* pPaM, SfxItemSet& rSet ) const;
269 :
270 : /// Set attribute as new default attribute in document.
271 : void SetDefault( const SfxPoolItem& );
272 :
273 : /// Query default attribute of document.
274 : const SfxPoolItem& GetDefault( sal_uInt16 nFmtHint ) const;
275 :
276 : void ResetAttr( const std::set<sal_uInt16> &attrs = std::set<sal_uInt16>(), SwPaM* pCrsr = NULL );
277 : void GCAttr();
278 :
279 : /// @return the scripttpye of the selection.
280 : sal_uInt16 GetScriptType() const;
281 :
282 : /// @return the language at current cursor position.
283 : sal_uInt16 GetCurLang() const;
284 :
285 : /// TABLE
286 : sal_uInt16 GetTblFrmFmtCount( bool bUsed = false ) const;
287 : SwFrmFmt& GetTblFrmFmt(sal_uInt16 nFmt, bool bUsed = false ) const;
288 : OUString GetUniqueTblName() const;
289 :
290 : /// CHAR
291 : sal_uInt16 GetCharFmtCount() const;
292 : SwCharFmt& GetCharFmt(sal_uInt16 nFmt) const;
293 : SwCharFmt* GetCurCharFmt() const;
294 : void FillByEx(SwCharFmt*, sal_Bool bReset = sal_False);
295 : SwCharFmt* MakeCharFmt( const OUString& rName, SwCharFmt* pDerivedFrom = 0 );
296 : SwCharFmt* FindCharFmtByName( const OUString& rName ) const;
297 :
298 : /* FormatCollections (new) - Explaining the general naming pattern:
299 : * GetXXXCount() returns the count of xxx in the document.
300 : * GetXXX(i) returns i-th xxx (ERR_RAISE if beyond range!).
301 : * DelXXX(i) deletes i-th xxx (ERR_RAISE if beyond range!).
302 : * GetCurXXX() returns xxx that is valid at cursor or in ranges.
303 : * returns 0, if not unanimuous.
304 : * SetXXX() sets xxx at cursor or in ranges.
305 : * MakeXXX() makes a xxx, derived from pDerivedFrom.
306 : */
307 :
308 : // TXT
309 : SwTxtFmtColl& GetDfltTxtFmtColl() const;
310 : sal_uInt16 GetTxtFmtCollCount() const;
311 : SwTxtFmtColl& GetTxtFmtColl( sal_uInt16 nTxtFmtColl) const;
312 : /**
313 : * Get the named paragraph format of the current selection.
314 : *
315 : * @see GetPaMTxtFmtColl()
316 : *
317 : * @return the named paragraph format of the first node that contains one.
318 : * Nodes are sort by order of appearance in the selections ;
319 : * selections are sort by their order of creation
320 : * (last created selection first, oldest selection at last).
321 : */
322 : SwTxtFmtColl* GetCurTxtFmtColl() const;
323 : /**
324 : * Get the named paragraph format of the selection(s) described by a SwPaM.
325 : *
326 : * @param pPaM
327 : * input parameter - the selection where to look for the paragraph format.
328 : *
329 : * @return the named paragraph format of the first node that contains one.
330 : */
331 : SwTxtFmtColl* GetPaMTxtFmtColl( SwPaM* pPaM ) const;
332 :
333 : // #i62675#
334 : /// Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTxtFmtColl(..)>
335 : void SetTxtFmtColl( SwTxtFmtColl*,
336 : bool bResetListAttrs = false );
337 : SwTxtFmtColl *MakeTxtFmtColl(const OUString &rFmtCollName,
338 : SwTxtFmtColl *pDerivedFrom = 0);
339 : void FillByEx(SwTxtFmtColl*, sal_Bool bReset = sal_False);
340 : SwTxtFmtColl* FindTxtFmtCollByName( const OUString& rName ) const;
341 :
342 : /// @return "Auto-Collection" with given Id. If it does not exist create it.
343 : SwTxtFmtColl* GetTxtCollFromPool( sal_uInt16 nId );
344 :
345 : /// @return required automatic format base class.
346 : SwFmt* GetFmtFromPool( 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 : SwFrmFmt* GetFrmFmtFromPool( sal_uInt16 nId )
356 0 : { return (SwFrmFmt*)SwEditShell::GetFmtFromPool( nId ); }
357 0 : SwCharFmt* GetCharFmtFromPool( sal_uInt16 nId )
358 0 : { return (SwCharFmt*)SwEditShell::GetFmtFromPool( nId ); }
359 :
360 : void Insert2(SwField&, const bool bForceExpandHints = false);
361 :
362 : void UpdateFlds( SwField & ); ///< One single field.
363 :
364 : sal_uInt16 GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX, sal_Bool bUsed = sal_False) const;
365 : SwFieldType* GetFldType(sal_uInt16 nId, sal_uInt16 nResId = USHRT_MAX, sal_Bool bUsed = sal_False) const;
366 : SwFieldType* GetFldType(sal_uInt16 nResId, const OUString& rName) const;
367 :
368 : void RemoveFldType(sal_uInt16 nId, sal_uInt16 nResId = USHRT_MAX);
369 : void RemoveFldType(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 : sal_Bool IsAnyDatabaseFieldInDoc()const;
385 :
386 : /// Check whether DB fields point to an available data source and returns it.
387 : sal_Bool IsFieldDataSourceAvailable(OUString& rUsedDataSource) const;
388 : void UpdateExpFlds(sal_Bool bCloseDB = sal_False);///< only every expression fields update
389 : void LockExpFlds();
390 : void UnlockExpFlds();
391 :
392 : SwFldUpdateFlags GetFldUpdateFlags(sal_Bool bDocSettings = sal_False) const;
393 : void SetFldUpdateFlags( SwFldUpdateFlags eFlags );
394 :
395 : /// For evaluation of DB fields (new DB-manager).
396 : SwNewDBMgr* GetNewDBMgr() const;
397 :
398 : SwFieldType* InsertFldType(const SwFieldType &);
399 :
400 : /// Changes in document?
401 : sal_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 : sal_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 : sal_Bool IsTOXBaseReadonly(const SwTOXBase& rTOXBase) const;
427 : void SetTOXBaseReadonly(const SwTOXBase& rTOXBase, sal_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( sal_Bool bFlag = sal_True );
435 : sal_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 : sal_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 sal_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 : sal_Bool IsNoNum( sal_Bool bChkStart = sal_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 : sal_Bool HasNumber() const;
516 : sal_Bool HasBullet() const;
517 :
518 : sal_Bool SelectionHasNumber() const;
519 : sal_Bool SelectionHasBullet() const;
520 :
521 : OUString GetUniqueNumRuleName( const OUString* pChkStr = 0, bool bAutoNum = true ) const;
522 : void ChgNumRuleFmts( const SwNumRule& rRule );
523 :
524 : /// Set (and query if) a numbering with StartFlag starts at current PointPos.
525 : void SetNumRuleStart( sal_Bool bFlag = sal_True, SwPaM* pCrsr = NULL );
526 : sal_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( sal_Bool bOn = sal_True );
546 : sal_Bool DoesUndo() const;
547 : void DoGroupUndo( sal_Bool bUn = sal_True );
548 : sal_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 : void CalcLayout();
578 :
579 : /// Determine form of content. Return Type at CurCrsr->SPoint.
580 : sal_uInt16 GetCntType() const;
581 :
582 : /// Are there frames, footnotes, etc.
583 : sal_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 : sal_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( sal_Bool bWait = sal_True ) const;
598 : const GraphicObject* GetGraphicObj() const;
599 :
600 : sal_Bool IsGrfSwapOut( sal_Bool bOnlyLinked = sal_False ) const;
601 : sal_uInt16 GetGraphicType() const;
602 :
603 : const PolyPolygon *GetGraphicPolygon() const;
604 : void SetGraphicPolygon( const 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 : sal_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 SwFlyFrmFmt* = 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 SwFlyFrmFmt* 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 (SwFmt)?
638 : sal_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, sal_Bool bSaveRelFile = sal_False,
656 : const OUString* pOnlyTxt=0 );
657 :
658 : /// Save complete content of doc as glossary.
659 : sal_uInt16 SaveGlossaryDoc( SwTextBlocks& rGlossary, const OUString& rName,
660 : const OUString& rShortName,
661 : sal_Bool bSaveRelFile = sal_False,
662 : sal_Bool bOnlyTxt = sal_False );
663 :
664 : // Linguistics...
665 : /// Save selections.
666 : void HyphStart( SwDocPositions eStart, SwDocPositions eEnde );
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 : void InsertSoftHyph( const sal_Int32 nHyphPos );
677 :
678 : const SwTable& InsertTable( const SwInsertTableOptions& rInsTblOpts, ///< ALL_TBL_INS_ATTR
679 : sal_uInt16 nRows, sal_uInt16 nCols,
680 : sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
681 : const SwTableAutoFmt* pTAFmt = 0 );
682 :
683 : void InsertDDETable( const SwInsertTableOptions& rInsTblOpts, ///< 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( SwFrmFmt& rTblFmt, const OUString &rNewName );
690 :
691 : SwFrmFmt *GetTableFmt();
692 : sal_Bool TextToTable( const SwInsertTableOptions& rInsTblOpts, ///< ALL_TBL_INS_ATTR
693 : sal_Unicode cCh,
694 : sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
695 : const SwTableAutoFmt* pTAFmt = 0 );
696 : sal_Bool TableToText( sal_Unicode cCh );
697 : sal_Bool IsTextToTableAvailable() const;
698 :
699 : sal_Bool GetTblBoxFormulaAttrs( SfxItemSet& rSet ) const;
700 : void SetTblBoxFormulaAttrs( const SfxItemSet& rSet );
701 :
702 : sal_Bool IsTableBoxTextFormat() const;
703 : OUString GetTableBoxText() const;
704 :
705 : TblChgMode GetTblChgMode() const;
706 : void SetTblChgMode( TblChgMode eMode );
707 :
708 : /// Split table at cursor position.
709 : sal_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 : sal_Bool CanMergeTable( sal_Bool bWithPrev = sal_True, sal_Bool* pChkNxtPrv = 0 ) const;
716 : sal_Bool MergeTable( sal_Bool bWithPrev = sal_True, sal_uInt16 nMode = 0 );
717 :
718 : /// Set up InsertDB as table Undo.
719 : void AppendUndoForInsertFromDB( sal_Bool bIsTable );
720 :
721 : /// Functions used for spell checking and text conversion.
722 :
723 : /// Save selections.
724 : void SpellStart( SwDocPositions eStart, SwDocPositions eEnde,
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 : void PutSpellingToSentenceStart();
739 :
740 : /// Moves the continuation position to the end of the currently checked sentence.
741 : 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 : bool HasLastSentenceGotGrammarChecked() const;
748 :
749 : /// Is text conversion active somewhere else?
750 : sal_Bool HasConvIter() const;
751 :
752 : /// Is hyphenation active somewhere else?
753 : sal_Bool HasHyphIter() const;
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 : void IgnoreGrammarErrorAt( SwPaM& rErrorPosition );
766 : void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnde );
767 :
768 : /// @return reference set in document according to given name.
769 : const SwFmtRefMark* 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, sal_Bool bInsertMode = sal_True,
777 : sal_Unicode cChar = ' ' );
778 : sal_Bool GetPrevAutoCorrWord( SvxAutoCorrect& rACorr, OUString& rWord );
779 :
780 : /// Set our styles according to the respective rules.
781 : void AutoFormat( const SvxSwAutoFmtFlags* pAFlags = 0 );
782 :
783 : static SvxSwAutoFmtFlags* GetAutoFmtFlags();
784 : static void SetAutoFmtFlags(SvxSwAutoFmtFlags *);
785 :
786 : /// Calculates selection.
787 : OUString Calculate();
788 :
789 : sal_Bool InsertURL( const SwFmtINetFmt& rFmt, const OUString& rStr,
790 : sal_Bool bKeepSelection = sal_False );
791 : sal_uInt16 GetINetAttrs( SwGetINetAttrs& rArr );
792 :
793 : OUString GetDropTxt( const sal_uInt16 nChars ) const;
794 : void ReplaceDropTxt( 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 : sal_Bool IsOutlineMovable( sal_uInt16 nIdx ) const;
799 : sal_Bool IsOutlineCopyable( sal_uInt16 nIdx ) const;
800 :
801 : sal_uInt16 GetLineCount( sal_Bool bActPos = sal_True );
802 :
803 : /// Query and set footnote-text/number. Set.. to current SSelection!
804 : sal_Bool GetCurFtn( SwFmtFtn* pToFillFtn = 0 );
805 : bool SetCurFtn( const SwFmtFtn& rFillFtn );
806 : bool HasFtns( bool bEndNotes = false ) const;
807 :
808 : sal_uInt16 GetSeqFtnList( SwSeqFldList& 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 : sal_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 : const SwSection* GetAnySection( sal_Bool bOutOfTab = sal_False, const Point* pPt = 0 ) const;
822 :
823 : sal_uInt16 GetSectionFmtCount() const;
824 : sal_uInt16 GetSectionFmtPos( const SwSectionFmt& ) const;
825 : const SwSectionFmt& GetSectionFmt(sal_uInt16 nFmt) const;
826 : void DelSectionFmt( sal_uInt16 nFmt );
827 : void UpdateSection(sal_uInt16 const nSect, SwSectionData &,
828 : SfxItemSet const*const = 0);
829 : sal_Bool IsAnySectionInDoc( sal_Bool bChkReadOnly = sal_False,
830 : sal_Bool bChkHidden = sal_False,
831 : sal_Bool BChkTOX = sal_False ) const;
832 :
833 : OUString GetUniqueSectionName( const OUString* pChkStr = 0 ) const;
834 :
835 : /// Set attributes.
836 : void SetSectionAttr(const SfxItemSet& rSet, SwSectionFmt* pSectFmt = 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(sal_Bool bNew = sal_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 substracting 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 ((SwEditShell*)this)->GetNumberFormatter(); }
867 :
868 : /// Interfaces for GlobalDocument.
869 : sal_Bool IsGlobalDoc() const;
870 : void SetGlblDocSaveLinks( sal_Bool bFlag = sal_True );
871 : sal_Bool IsGlblDocSaveLinks() const;
872 : sal_uInt16 GetGlobalDocContent( SwGlblDocContents& rArr ) const;
873 : sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
874 : SwSectionData & rNew );
875 : sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
876 : const SwTOXBase& rTOX );
877 : sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos );
878 : sal_Bool DeleteGlobalDocContent( const SwGlblDocContents& rArr,
879 : size_t nPos );
880 : sal_Bool MoveGlobalDocContent( const SwGlblDocContents& rArr ,
881 : size_t nFromPos, size_t nToPos,
882 : size_t nNewPos );
883 : sal_Bool GotoGlobalDocContent( const SwGlblDocContent& rPos );
884 :
885 : /// For Redlining.
886 : sal_uInt16 GetRedlineMode() const;
887 : void SetRedlineMode( sal_uInt16 eMode );
888 : sal_Bool IsRedlineOn() const;
889 : sal_uInt16 GetRedlineCount() const;
890 : const SwRangeRedline& GetRedline( sal_uInt16 nPos ) const;
891 : sal_Bool AcceptRedline( sal_uInt16 nPos );
892 : sal_Bool RejectRedline( sal_uInt16 nPos );
893 :
894 : /** Search Redline for this Data and @return position in array.
895 : If not found, return USHRT_MAX. */
896 : sal_uInt16 FindRedlineOfData( const SwRedlineData& ) const;
897 :
898 : /// Set comment to Redline at position.
899 : sal_Bool SetRedlineComment( const OUString& rS );
900 : const SwRangeRedline* GetCurrRedline() const;
901 :
902 : /// Redline attributes have been changed. Updated views.
903 : void UpdateRedlineAttr();
904 :
905 : /// Compare two documents.
906 : long CompareDoc( const SwDoc& rDoc );
907 :
908 : /// Merge two documents.
909 : long MergeDoc( const SwDoc& rDoc );
910 :
911 : /// Footnote attributes global to document.
912 : const SwFtnInfo& GetFtnInfo() const;
913 : void SetFtnInfo(const SwFtnInfo& rInfo);
914 : const SwEndNoteInfo& GetEndNoteInfo() const;
915 : void SetEndNoteInfo(const SwEndNoteInfo& rInfo);
916 :
917 : const SwLineNumberInfo &GetLineNumberInfo() const;
918 : void SetLineNumberInfo( const SwLineNumberInfo& rInfo);
919 :
920 : /// Labels: Synchronize ranges.
921 : void SetLabelDoc( sal_Bool bFlag = sal_True );
922 : sal_Bool IsLabelDoc() const;
923 :
924 : /// Interface for TextInputData - (for input of Japanese/Chinese chars.)
925 : SwExtTextInput* CreateExtTextInput(LanguageType eInputLanguage);
926 : OUString DeleteExtTextInput( SwExtTextInput* pDel = 0, sal_Bool bInsText = sal_True);
927 : void SetExtTextInputData( const CommandExtTextInputData& );
928 :
929 : /// Interface for access to AutoComplete-list.
930 : static SwAutoCompleteWord& GetAutoCompleteWords();
931 :
932 : /** @return a scaling factor of selected text. Used for the rotated
933 : character attribut dialog. */
934 : sal_uInt16 GetScalingOfSelectedText() const;
935 :
936 : /// Ctor/Dtor.
937 : SwEditShell( SwDoc&, Window*, const SwViewOption *pOpt = 0 );
938 :
939 : /// Copy-Constructor in disguise.
940 : SwEditShell( SwEditShell&, Window* );
941 : virtual ~SwEditShell();
942 :
943 : private:
944 : /// For METWARE: no copying and no assignment.
945 : SwEditShell(const SwEditShell &);
946 : const SwEditShell &operator=(const SwEditShell &);
947 : };
948 :
949 : inline const sfx2::LinkManager& SwEditShell::GetLinkManager() const
950 : { return ((SwEditShell*)this)->GetLinkManager(); }
951 :
952 : /// Class for automated call of Start- and EndAction().
953 : class SwActContext {
954 : SwEditShell *pSh;
955 : public:
956 : SwActContext(SwEditShell *pShell);
957 : ~SwActContext();
958 : };
959 :
960 : /// Class for automated call of Start- and EndCrsrMove().
961 : class SwMvContext {
962 : SwEditShell *pSh;
963 : public:
964 : SwMvContext(SwEditShell *pShell);
965 : ~SwMvContext();
966 : };
967 :
968 : #endif
969 :
970 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|