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