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 : sal_Bool SelectionHasNumber() const;
527 : sal_Bool SelectionHasBullet() const;
528 :
529 : String GetUniqueNumRuleName( const String* pChkStr = 0, bool bAutoNum = true ) const;
530 : void ChgNumRuleFmts( const SwNumRule& rRule );
531 :
532 : /// Set (and query if) a numbering with StartFlag starts at current PointPos.
533 : void SetNumRuleStart( sal_Bool bFlag = sal_True, SwPaM* pCrsr = NULL );
534 : sal_Bool IsNumRuleStart( SwPaM* pPaM = NULL ) const;
535 : void SetNodeNumStart( sal_uInt16 nStt, SwPaM* = NULL );
536 :
537 : sal_uInt16 GetNodeNumStart( SwPaM* pPaM = NULL ) const;
538 :
539 : bool ReplaceNumRule( const String& rOldRule, const String& rNewRule );
540 :
541 : /** Searches for a text node with a numbering rule.
542 : in case a list style is found, <sListId> holds the list id, to which the
543 : text node belongs, which applies the found list style. */
544 : const SwNumRule * SearchNumRule(const bool bForward,
545 : const bool bNum,
546 : const bool bOutline,
547 : int nNonEmptyAllowed,
548 : String& sListId );
549 :
550 : /** Undo.
551 : Maintain UndoHistory in Document.
552 : Reset UndoHistory at Save, SaveAs, Create ??? */
553 : void DoUndo( sal_Bool bOn = sal_True );
554 : sal_Bool DoesUndo() const;
555 : void DoGroupUndo( sal_Bool bUn = sal_True );
556 : sal_Bool DoesGroupUndo() const;
557 : void DelAllUndoObj();
558 :
559 : /// Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
560 : SwUndoId StartUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
561 :
562 : /// Closes parenthesis of nUndoId, not used by UI.
563 : SwUndoId EndUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
564 :
565 : bool GetLastUndoInfo(OUString *const o_pStr,
566 : SwUndoId *const o_pId) const;
567 : bool GetFirstRedoInfo(OUString *const o_pStr) const;
568 : SwUndoId GetRepeatInfo(OUString *const o_pStr) const;
569 :
570 : /// is it forbidden to modify cursors via API calls?
571 : bool CursorsLocked() const;
572 : /// set selections to those contained in the UndoRedoContext
573 : /// should only be called by sw::UndoManager!
574 : void HandleUndoRedoContext(::sw::UndoRedoContext & rContext);
575 :
576 : bool Undo(sal_uInt16 const nCount = 1);
577 : bool Redo(sal_uInt16 const nCount = 1);
578 : bool Repeat(sal_uInt16 const nCount);
579 :
580 :
581 : /// For all views of this document.
582 : void StartAllAction();
583 : void EndAllAction();
584 :
585 : /// To enable set up of StartActions and EndActions.
586 : void CalcLayout();
587 :
588 : /// Determine form of content. Return Type at CurCrsr->SPoint.
589 : sal_uInt16 GetCntType() const;
590 :
591 : /// Are there frames, footnotes, etc.
592 : sal_Bool HasOtherCnt() const;
593 :
594 : /// Apply ViewOptions with Start-/EndAction.
595 : virtual void ApplyViewOptions( const SwViewOption &rOpt );
596 :
597 : /** Query text within selection.
598 : @returns FALSE, if selected range is too large to be copied
599 : into string buffer or if other errors occur. */
600 : sal_Bool GetSelectedText( String &rBuf,
601 : int nHndlParaBreak = GETSELTXT_PARABRK_TO_BLANK );
602 :
603 : /** @return graphic, if CurCrsr->Point() points to a SwGrfNode
604 : (and mark is not set or points to the same graphic). */
605 :
606 : const Graphic* GetGraphic( sal_Bool bWait = sal_True ) const;
607 : const GraphicObject* GetGraphicObj() const;
608 :
609 : sal_Bool IsGrfSwapOut( sal_Bool bOnlyLinked = sal_False ) const;
610 : sal_uInt16 GetGraphicType() const;
611 :
612 : const PolyPolygon *GetGraphicPolygon() const;
613 : void SetGraphicPolygon( const PolyPolygon *pPoly );
614 :
615 : /** If there's an automatic, not manipulated polygon at the selected
616 : notxtnode, it has to be deleted, e.g. cause the object has changed. */
617 : void ClearAutomaticContour();
618 :
619 : /// @return the size of a graphic in Twips if cursor is in a graphic.
620 : sal_Bool GetGrfSize(Size&) const;
621 :
622 : /** @return name and filter of a graphic if the cursor is in a graphic,
623 : else give a rap on the knuckles!
624 : If a string-ptr != 0 return the respective name. */
625 : void GetGrfNms( String* pGrfName, String* pFltName,
626 : const SwFlyFrmFmt* = 0 ) const;
627 :
628 : /// Re-read if graphic is not ok. Current graphic is replaced by the new one.
629 : void ReRead( const String& rGrfName, const String& rFltName,
630 : const Graphic* pGraphic = 0,
631 : const GraphicObject* pGrafObj = 0 );
632 :
633 : /// Unique identification of object (for ImageMapDlg).
634 : void *GetIMapInventor() const;
635 :
636 : // #i73788#
637 : /// Remove default parameter, because method always called this default value.
638 : Graphic GetIMapGraphic() const; ///< @return a graphic for all Flys!
639 : const SwFlyFrmFmt* FindFlyByName( const String& rName, sal_uInt8 nNdTyp = 0 ) const;
640 :
641 : /** @return a ClientObject, if CurCrsr->Point() points to a SwOLENode
642 : (and mark is neither set not pointint to same ClientObject)
643 : else give rap on the knuckles. */
644 : svt::EmbeddedObjectRef& GetOLEObject() const;
645 :
646 : /// Is there an OLEObject with this name (SwFmt)?
647 : sal_Bool HasOLEObj( const String &rName ) const;
648 :
649 : /// @return pointer to the data of the chart in which Cursr is.
650 : void SetChartName( const String &rName );
651 :
652 : /// Update content of all charts for table with given name.
653 : void UpdateCharts( const String &rName );
654 :
655 : String GetCurWord();
656 :
657 : /** Glossary from glossary document in current document.
658 : Styles only if not already existent. */
659 : void InsertGlossary( SwTextBlocks& rGlossary, const String& );
660 :
661 : /** Make current selection glossary and insert into glossary document
662 : including styles. */
663 : sal_uInt16 MakeGlossary( SwTextBlocks& rToFill, const String& rName,
664 : const String& rShortName, sal_Bool bSaveRelFile = sal_False,
665 : const String* pOnlyTxt=0 );
666 :
667 : /// Save complete content of doc as glossary.
668 : sal_uInt16 SaveGlossaryDoc( SwTextBlocks& rGlossary, const String& rName,
669 : const String& rShortName,
670 : sal_Bool bSaveRelFile = sal_False,
671 : sal_Bool bOnlyTxt = sal_False );
672 :
673 : // Linguistics...
674 : /// Save selections.
675 : void HyphStart( SwDocPositions eStart, SwDocPositions eEnde );
676 :
677 : /// restore selections.
678 : void HyphEnd();
679 : com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>
680 : HyphContinue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt );
681 :
682 : void HyphIgnore();
683 :
684 : /// For Inserting SoftHyphen. Position is offset within the syllabificated word.
685 : void InsertSoftHyph( const xub_StrLen nHyphPos );
686 :
687 : const SwTable& InsertTable( const SwInsertTableOptions& rInsTblOpts, ///< ALL_TBL_INS_ATTR
688 : sal_uInt16 nRows, sal_uInt16 nCols,
689 : sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
690 : const SwTableAutoFmt* pTAFmt = 0 );
691 :
692 : void InsertDDETable( const SwInsertTableOptions& rInsTblOpts, ///< HEADLINE_NO_BORDER
693 : SwDDEFieldType* pDDEType,
694 : sal_uInt16 nRows, sal_uInt16 nCols,
695 : sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL );
696 :
697 : void UpdateTable();
698 : void SetTableName( SwFrmFmt& rTblFmt, const String &rNewName );
699 :
700 : SwFrmFmt *GetTableFmt();
701 : sal_Bool TextToTable( const SwInsertTableOptions& rInsTblOpts, ///< ALL_TBL_INS_ATTR
702 : sal_Unicode cCh,
703 : sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
704 : const SwTableAutoFmt* pTAFmt = 0 );
705 : sal_Bool TableToText( sal_Unicode cCh );
706 : sal_Bool IsTextToTableAvailable() const;
707 :
708 : sal_Bool GetTblBoxFormulaAttrs( SfxItemSet& rSet ) const;
709 : void SetTblBoxFormulaAttrs( const SfxItemSet& rSet );
710 :
711 : sal_Bool IsTableBoxTextFormat() const;
712 : String GetTableBoxText() const;
713 :
714 : TblChgMode GetTblChgMode() const;
715 : void SetTblChgMode( TblChgMode eMode );
716 :
717 : /// Split table at cursor position.
718 : sal_Bool SplitTable( sal_uInt16 eMode );
719 :
720 : /** Merge tables.
721 :
722 : Can Merge checks if Prev or Next are possible.
723 : If pointer pChkNxtPrv is passed possible direction is given. */
724 : sal_Bool CanMergeTable( sal_Bool bWithPrev = sal_True, sal_Bool* pChkNxtPrv = 0 ) const;
725 : sal_Bool MergeTable( sal_Bool bWithPrev = sal_True, sal_uInt16 nMode = 0 );
726 :
727 : /// Set up InsertDB as table Undo.
728 : void AppendUndoForInsertFromDB( sal_Bool bIsTable );
729 :
730 : /// Functions used for spell checking and text conversion.
731 :
732 : /// Save selections.
733 : void SpellStart( SwDocPositions eStart, SwDocPositions eEnde,
734 : SwDocPositions eCurr, SwConversionArgs *pConvArgs = 0 );
735 :
736 : /// Restore selections.
737 : void SpellEnd( SwConversionArgs *pConvArgs = 0, bool bRestoreSelection = true );
738 : ::com::sun::star::uno::Any SpellContinue(
739 : sal_uInt16* pPageCnt, sal_uInt16* pPageSt,
740 : SwConversionArgs *pConvArgs = 0 );
741 :
742 : /** Spells on a sentence basis - the SpellPortions are needed
743 : @return false if no error could be found. */
744 : bool SpellSentence(::svx::SpellPortions& rToFill, bool bIsGrammarCheck );
745 :
746 : /// Make SpellIter start with the current sentence when called next time.
747 : void PutSpellingToSentenceStart();
748 :
749 : /// Moves the continuation position to the end of the currently checked sentence.
750 : void MoveContinuationPosToEndOfCheckedSentence();
751 :
752 : /// Applies a changed sentence.
753 : void ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, bool bRecheck);
754 :
755 : /// Check SwSpellIter data to see if the last sentence got grammar checked.
756 : bool HasLastSentenceGotGrammarChecked() const;
757 :
758 : /// Is text conversion active somewhere else?
759 : sal_Bool HasConvIter() const;
760 :
761 : /// Is hyphenation active somewhere else?
762 : sal_Bool HasHyphIter() const;
763 :
764 : ::com::sun::star::uno::Reference<
765 : ::com::sun::star::linguistic2::XSpellAlternatives >
766 : GetCorrection( const Point* pPt, SwRect& rSelectRect );
767 :
768 :
769 : bool GetGrammarCorrection( ::com::sun::star::linguistic2::ProofreadingResult /*out*/ &rResult,
770 : sal_Int32 /*out*/ &rErrorPosInText,
771 : sal_Int32 /*out*/ &rErrorIndexInResult,
772 : ::com::sun::star::uno::Sequence< OUString > /*out*/ &rSuggestions,
773 : const Point* pPt, SwRect& rSelectRect );
774 :
775 : void IgnoreGrammarErrorAt( SwPaM& rErrorPosition );
776 : void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnde );
777 :
778 : /// @return reference set in document according to given name.
779 : const SwFmtRefMark* GetRefMark( const String& rName ) const;
780 :
781 : /** @return names of all references set in document.
782 : If ArrayPointer == 0 then return only whether a RefMark is set in document. */
783 : sal_uInt16 GetRefMarks( std::vector<OUString>* = 0 ) const;
784 :
785 : /// Call AutoCorrect
786 : void AutoCorrect( SvxAutoCorrect& rACorr, sal_Bool bInsertMode = sal_True,
787 : sal_Unicode cChar = ' ' );
788 : sal_Bool GetPrevAutoCorrWord( SvxAutoCorrect& rACorr, String& rWord );
789 :
790 : /// Set our styles according to the respective rules.
791 : void AutoFormat( const SvxSwAutoFmtFlags* pAFlags = 0 );
792 :
793 : static SvxSwAutoFmtFlags* GetAutoFmtFlags();
794 : static void SetAutoFmtFlags(SvxSwAutoFmtFlags *);
795 :
796 : /// Calculates selection.
797 : String Calculate();
798 :
799 : sal_Bool InsertURL( const SwFmtINetFmt& rFmt, const String& rStr,
800 : sal_Bool bKeepSelection = sal_False );
801 : sal_uInt16 GetINetAttrs( SwGetINetAttrs& rArr );
802 :
803 : String GetDropTxt( const sal_uInt16 nChars ) const;
804 : void ReplaceDropTxt( const String &rStr, SwPaM* pPaM = NULL );
805 :
806 : /** May an outline be moved or copied?
807 : Check whether it's in text body, not in table, and not read-only (move). */
808 : sal_Bool IsOutlineMovable( sal_uInt16 nIdx ) const;
809 : sal_Bool IsOutlineCopyable( sal_uInt16 nIdx ) const;
810 :
811 : sal_uInt16 GetLineCount( sal_Bool bActPos = sal_True );
812 :
813 : /// Query and set footnote-text/number. Set.. to current SSelection!
814 : sal_Bool GetCurFtn( SwFmtFtn* pToFillFtn = 0 );
815 : bool SetCurFtn( const SwFmtFtn& rFillFtn );
816 : bool HasFtns( bool bEndNotes = false ) const;
817 :
818 : sal_uInt16 GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes = false );
819 : /// @return list of all footnotes and their first portions of text.
820 :
821 : SwSection const* InsertSection(
822 : SwSectionData & rNewData, SfxItemSet const*const = 0 );
823 : sal_Bool IsInsRegionAvailable() const;
824 : const SwSection* GetCurrSection() const;
825 :
826 : /** @return current range like Cet CurrSection(). But this function iterates
827 : also over frames and catches the range even if the cursor is positioned in
828 : a footnote the reference of which is in a columned range.
829 : If bOutOfTab is set, the range comprising the table is searched
830 : and not an inner one. */
831 : const SwSection* GetAnySection( sal_Bool bOutOfTab = sal_False, const Point* pPt = 0 ) const;
832 :
833 : sal_uInt16 GetSectionFmtCount() const;
834 : sal_uInt16 GetSectionFmtPos( const SwSectionFmt& ) const;
835 : const SwSectionFmt& GetSectionFmt(sal_uInt16 nFmt) const;
836 : void DelSectionFmt( sal_uInt16 nFmt );
837 : void UpdateSection(sal_uInt16 const nSect, SwSectionData &,
838 : SfxItemSet const*const = 0);
839 : sal_Bool IsAnySectionInDoc( sal_Bool bChkReadOnly = sal_False,
840 : sal_Bool bChkHidden = sal_False,
841 : sal_Bool BChkTOX = sal_False ) const;
842 :
843 : String GetUniqueSectionName( const String* pChkStr = 0 ) const;
844 :
845 : /// Set attributes.
846 : void SetSectionAttr(const SfxItemSet& rSet, SwSectionFmt* pSectFmt = 0);
847 :
848 : /** Search inside the cursor selection for full selected sections.
849 : if any part of section in the selection @return 0.
850 : if more than one in the selection return the count. */
851 : sal_uInt16 GetFullSelectedSectionCount() const;
852 :
853 : /** Special insert: Insert a new text node just before or after a section or
854 : table, if the cursor is positioned at the start/end of said
855 : section/table. The purpose of the method is to allow users to inert text
856 : at certain 'impossible' position, e.g. before a table at the document
857 : start or between to sections. */
858 : bool DoSpecialInsert();
859 : bool CanSpecialInsert() const;
860 :
861 : /// Optimizing UI.
862 : void SetNewDoc(sal_Bool bNew = sal_True);
863 :
864 : sfx2::LinkManager& GetLinkManager();
865 : inline const sfx2::LinkManager& GetLinkManager() const;
866 :
867 : /** Adjust left margin via object bar (similar to adjustment of numerations).
868 : One can either change the margin "by" adding or substracting a given
869 : offset or set it "to" this position @param (bModulus = true). */
870 : bool IsMoveLeftMargin( bool bRight = true, bool bModulus = true ) const;
871 : void MoveLeftMargin( bool bRight = true, bool bModulus = true );
872 :
873 : /// Query NumberFormater from document.
874 : SvNumberFormatter* GetNumberFormatter();
875 : const SvNumberFormatter* GetNumberFormatter() const
876 : { return ((SwEditShell*)this)->GetNumberFormatter(); }
877 :
878 : /// Interfaces for GlobalDocument.
879 : sal_Bool IsGlobalDoc() const;
880 : void SetGlblDocSaveLinks( sal_Bool bFlag = sal_True );
881 : sal_Bool IsGlblDocSaveLinks() const;
882 : sal_uInt16 GetGlobalDocContent( SwGlblDocContents& rArr ) const;
883 : sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
884 : SwSectionData & rNew );
885 : sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
886 : const SwTOXBase& rTOX );
887 : sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos );
888 : sal_Bool DeleteGlobalDocContent( const SwGlblDocContents& rArr,
889 : sal_uInt16 nPos );
890 : sal_Bool MoveGlobalDocContent( const SwGlblDocContents& rArr ,
891 : sal_uInt16 nFromPos, sal_uInt16 nToPos,
892 : sal_uInt16 nNewPos );
893 : sal_Bool GotoGlobalDocContent( const SwGlblDocContent& rPos );
894 :
895 : /// For Redlining.
896 : sal_uInt16 GetRedlineMode() const;
897 : void SetRedlineMode( sal_uInt16 eMode );
898 : sal_Bool IsRedlineOn() const;
899 : sal_uInt16 GetRedlineCount() const;
900 : const SwRedline& GetRedline( sal_uInt16 nPos ) const;
901 : sal_Bool AcceptRedline( sal_uInt16 nPos );
902 : sal_Bool RejectRedline( sal_uInt16 nPos );
903 :
904 :
905 : /** Search Redline for this Data and @return position in array.
906 : If not found, return USHRT_MAX. */
907 : sal_uInt16 FindRedlineOfData( const SwRedlineData& ) const;
908 :
909 :
910 : /// Set comment to Redline at position.
911 : sal_Bool SetRedlineComment( const String& rS );
912 : const SwRedline* GetCurrRedline() const;
913 :
914 : /// Redline attributes have been changed. Updated views.
915 : void UpdateRedlineAttr();
916 :
917 : /// Compare two documents.
918 : long CompareDoc( const SwDoc& rDoc );
919 :
920 : /// Merge two documents.
921 : long MergeDoc( const SwDoc& rDoc );
922 :
923 : /// Footnote attributes global to document.
924 : const SwFtnInfo& GetFtnInfo() const;
925 : void SetFtnInfo(const SwFtnInfo& rInfo);
926 : const SwEndNoteInfo& GetEndNoteInfo() const;
927 : void SetEndNoteInfo(const SwEndNoteInfo& rInfo);
928 :
929 : const SwLineNumberInfo &GetLineNumberInfo() const;
930 : void SetLineNumberInfo( const SwLineNumberInfo& rInfo);
931 :
932 : /// Labels: Synchronize ranges.
933 : void SetLabelDoc( sal_Bool bFlag = sal_True );
934 : sal_Bool IsLabelDoc() const;
935 :
936 : /// Interface for TextInputData - (for input of Japanese/Chinese chars.)
937 : SwExtTextInput* CreateExtTextInput(LanguageType eInputLanguage);
938 : String DeleteExtTextInput( SwExtTextInput* pDel = 0, sal_Bool bInsText = sal_True);
939 : void SetExtTextInputData( const CommandExtTextInputData& );
940 :
941 : /// Interface for access to AutoComplete-list.
942 : static SwAutoCompleteWord& GetAutoCompleteWords();
943 :
944 : /** @return a scaling factor of selected text. Used for the rotated
945 : character attribut dialog. */
946 : sal_uInt16 GetScalingOfSelectedText() const;
947 :
948 : /// Ctor/Dtor.
949 : SwEditShell( SwDoc&, Window*, const SwViewOption *pOpt = 0 );
950 :
951 : /// Copy-Constructor in disguise.
952 : SwEditShell( SwEditShell&, Window* );
953 : virtual ~SwEditShell();
954 :
955 : private:
956 : /// For METWARE: no copying and no assignment.
957 : SwEditShell(const SwEditShell &);
958 : const SwEditShell &operator=(const SwEditShell &);
959 : };
960 :
961 : inline const sfx2::LinkManager& SwEditShell::GetLinkManager() const
962 : { return ((SwEditShell*)this)->GetLinkManager(); }
963 :
964 : /// Class for automated call of Start- and EndAction().
965 : class SwActContext {
966 : SwEditShell *pSh;
967 : public:
968 : SwActContext(SwEditShell *pShell);
969 : ~SwActContext();
970 : };
971 :
972 : /// Class for automated call of Start- and EndCrsrMove().
973 : class SwMvContext {
974 : SwEditShell *pSh;
975 : public:
976 : SwMvContext(SwEditShell *pShell);
977 : ~SwMvContext();
978 : };
979 :
980 :
981 : #endif
982 :
983 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|