xref: /trunk/main/sw/inc/editsh.hxx (revision 28f5a95a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _EDITSH_HXX
24 #define _EDITSH_HXX
25 
26 #include <com/sun/star/text/HoriOrientation.hpp>
27 #include <com/sun/star/embed/XEmbeddedObject.hpp>
28 #include <tools/string.hxx>
29 #include <svl/svarray.hxx>
30 #include <vcl/font.hxx>
31 #include <editeng/swafopt.hxx>
32 #include "swdllapi.h"
33 #include <crsrsh.hxx>	// fuer Basisklasse
34 #include <itabenum.hxx>
35 #include <swdbdata.hxx>
36 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
37 #include <com/sun/star/linguistic2/ProofreadingResult.hpp>
38 #include <fldupde.hxx>
39 #include <tblenum.hxx>
40 #include <IMark.hxx>
41 
42 #include <vector>
43 #include <swundo.hxx>
44 #include <svtools/embedhlp.hxx>
45 
46 class PolyPolygon;
47 class SwDoc;
48 class DateTime;
49 class CommandExtTextInputData;
50 
51 class SvUShortsSort;
52 class SvNumberFormatter;
53 class SfxPoolItem;
54 class SfxItemSet;
55 class SvxAutoCorrect;
56 
57 class SwField;
58 class SwFieldType;
59 class SwDDEFieldType;
60 class SwNewDBMgr;
61 
62 struct SwDocStat;
63 class SvStringsDtor;
64 class SvStringsSort;
65 class SwAutoCompleteWord;
66 
67 class SwFmtRefMark;
68 
69 class SwNumRule;        // Numerierung
70 //class SwNodeNum;		// Numerierung
71 
72 class SwTxtFmtColl;
73 class SwGrfNode;
74 class SwFlyFrmFmt;
75 
76 class SwFrmFmt;			// fuer GetTxtNodeFmts()
77 class SwCharFmt;
78 class SwExtTextInput;
79 class SwRootFrm;        // fuer CTOR
80 class Graphic;			// fuer GetGraphic
81 class GraphicObject;	// fuer GetGraphicObj
82 class SwFmtINetFmt; 	// InsertURL
83 class SwTable;
84 class SwTextBlocks; 	// fuer GlossaryRW
85 class SwFmtFtn;
86 class SwSection;
87 class SwSectionData;
88 class SwSectionFmt;
89 class SwTOXMarks;
90 class SwTOXBase;
91 class SwTOXType;
92 class SwTableAutoFmt;
93 class SwPageDesc;
94 class SwTxtINetFmt;
95 class SwSeqFldList;
96 class SwGlblDocContent;
97 class SwGlblDocContents;
98 class SwRedline;
99 class SwRedlineData;
100 class SwFtnInfo;
101 class SwEndNoteInfo;
102 class SwLineNumberInfo;
103 class SwAuthEntry;
104 class SwRewriter;
105 struct SwConversionArgs;
106 
107 
108 namespace com { namespace sun { namespace star { namespace uno {
109 	template < class > class Sequence;
110 }}}}
111 
112 namespace svx{
113 struct SpellPortion;
114 typedef std::vector<SpellPortion> SpellPortions;
115 }
116 
117 namespace sfx2{
118 class LinkManager;
119 }
120 
121 namespace sw {
122     class UndoRedoContext;
123 }
124 
125 #define GETSELTXT_PARABRK_TO_BLANK      0
126 #define GETSELTXT_PARABRK_KEEP			1
127 #define GETSELTXT_PARABRK_TO_ONLYCR 	2
128 
129 /****************************************************************
130  *	zum Abfragen der INet-Attribute fuer den Navigator
131  ****************************************************************/
132 struct SwGetINetAttr
133 {
134 	String sText;
135 	const SwTxtINetFmt& rINetAttr;
136 
SwGetINetAttrSwGetINetAttr137 	SwGetINetAttr( const String& rTxt, const SwTxtINetFmt& rAttr )
138 		: sText( rTxt ), rINetAttr( rAttr )
139 	{}
140 };
141 SV_DECL_PTRARR_DEL( SwGetINetAttrs, SwGetINetAttr*, 0, 5 )
142 
143 /****************************************************************
144  *	Typen der Inhaltsformen
145  ****************************************************************/
146 #define CNT_TXT	0x0001
147 #define CNT_GRF	0x0002
148 #define CNT_OLE	0x0010
149 /* Teste einen sal_uInt16 auf eine bestimmte Inhaltsform */
150 #define CNT_HasTxt(USH)	((USH)&CNT_TXT)
151 #define CNT_HasGrf(USH)	((USH)&CNT_GRF)
152 #define CNT_HasOLE(USH)	((USH)&CNT_OLE)
153 
154 class SW_DLLPUBLIC SwEditShell: public SwCrsrShell
155 {
156 	static SvxSwAutoFmtFlags* pAutoFmtFlags;
157 
158 	// fuer die privaten Methoden DelRange und die vom AutoCorrect
159 	friend class SwAutoFormat;
160 	friend void _InitCore();
161 	friend void _FinitCore();
162 	// fuer die PamCorrAbs/-Rel Methoden
163 	friend class SwUndo;
164 
165 	SW_DLLPRIVATE SfxPoolItem& _GetChrFmt( SfxPoolItem& ) const;
166 
167 	/*
168 	 * liefert einen Pointer auf einen SwGrfNode; dieser wird von
169 	 * GetGraphic() und GetGraphicSize() verwendet.
170 	 */
171 	SW_DLLPRIVATE SwGrfNode *_GetGrfNode() const ;
172 
173 	SW_DLLPRIVATE void DeleteSel( SwPaM& rPam, sal_Bool* pUndo = 0 );
174 
175 	SW_DLLPRIVATE void _SetSectionAttr( SwSectionFmt& rSectFmt, const SfxItemSet& rSet );
176 
177     using ViewShell::UpdateFlds;
178     using SwModify::GetInfo;
179 
180 public:
181 	// Editieren (immer auf allen selektierten Bereichen)
182 	void Insert( sal_Unicode, sal_Bool bOnlyCurrCrsr = sal_False );
183     void Insert2( const String &, const bool bForceExpandHints = false );
184 	void Overwrite( const String & );
185 
186 	// Ersetz einen selektierten Bereich in einem TextNode mit dem
187 	// String. Ist fuers Suchen&Ersetzen gedacht.
188 	// bRegExpRplc - ersetze Tabs (\\t) und setze den gefundenen String
189 	//				 ein ( nicht \& )
190 	// 				z.B.: Fnd: "zzz", Repl: "xx\t\\t..&..\&"
191 	//						--> "xx\t<Tab>..zzz..&"
192 	sal_Bool Replace( const String& rNewStr, sal_Bool bRegExpRplc = sal_False );
193 
194 	// loescht den Inhalt aller Bereiche;
195 	// werden ganze Nodes selektiert, werden die Nodes geloescht
196 	long Delete();
197 
198 	// remove a complete paragraph
199 	sal_Bool DelFullPara();
200 
201 	// change text to Upper/Lower/Hiragana/Katagana/...
202 	void TransliterateText( sal_uInt32 nType );
203 
204     // count words in current selection
205     void CountWords( SwDocStat& rStat ) const;
206 
207 	// loesche den nicht sichtbaren Content aus dem Document, wie z.B.:
208 	// versteckte Bereiche, versteckte Absaetze
209 	sal_Bool RemoveInvisibleContent();
210 
211     // replace fields by text - mailmerge support
212     sal_Bool ConvertFieldsToText();
213     // set all numbering start points to a fixed value - mailmerge support
214     void SetNumberingRestart();
215 
216 	// embedded alle lokalen Links (Bereiche/Grafiken)
217 	sal_uInt16 GetLinkUpdMode(sal_Bool bDocSettings = sal_False) const;
218 	void SetLinkUpdMode( sal_uInt16 nMode );
219 
220 	// kopiere den Inhalt aller Bereiche an die akt. Cursor-Position
221 	// in die angegebene Shell
222 	long Copy( SwEditShell* pDestShell = 0 );
223 
224 	// fuers Kopieren uebers ClipBoard:
225 	// 	wird Tabelle in Tabelle kopiert, verschiebe aus dieser dann
226 	//	alle Cursor. Copy und Paste muss aufgrund der FlyFrames in
227 	// 	der FEShell stehen!
228 	// kopiere alle Selectionen und das Doc
229 	//JP 21.10.96: und fuer die SVX-Autokorrektur
230 	sal_Bool _CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pNdInsPos = 0 );
231 
232 	long SplitNode( sal_Bool bAutoFormat = sal_False, sal_Bool bCheckTableStart = sal_True );
233     sal_Bool AppendTxtNode();
234     void AutoFmtBySplitNode();
235 
236 	// ist der Cursor in einem INetAttribut, dann wird das komplett
237 	// geloescht; inclusive des Hinweistextes (wird beim Drag&Drop gebraucht)
238 	sal_Bool DelINetAttrWithText();
239 
240 	// ist der Cursor am Ende einer Zeichenvorlage, an der das DontExpand-Flag
241 	// noch nicht gesetzt ist, wird dies gesetzt ( => return sal_True; )
242 	sal_Bool DontExpandFmt();
243 
244 	// Anwenden / Entfernen von Attributen
245 	// liefert Attribute im angeforderten AttributSet. Wenn nicht eindeutig
246 	// steht im Set ein DONT_CARE !!
247     // --> OD 2008-01-16 #newlistlevelattrs#
248     // Renaming method to <GetCurAttr(..)> indicating that the attributes at
249     // the current cursors are retrieved.
250     // Introduce 2nd optional parameter <bMergeIndentValuesOfNumRule>.
251     // If <bMergeIndentValuesOfNumRule> == sal_True, the indent attributes of
252     // the corresponding list level of an applied list style is merged into
253     // the requested item set as a LR-SPACE item, if corresponding node has not
254     // its own indent attributes and the position-and-space mode of the list
255     // level is SvxNumberFormat::LABEL_ALIGNMENT.
256     sal_Bool GetCurAttr( SfxItemSet& ,
257                      const bool bMergeIndentValuesOfNumRule = false ) const;
258     // <--
259 	void SetAttrItem( const SfxPoolItem&, sal_uInt16 nFlags = 0 );
260 	void SetAttrSet( const SfxItemSet&, sal_uInt16 nFlags = 0 );
261 
262 	// Setze das Attribut als neues default Attribut im Dokument.
263 	void SetDefault( const SfxPoolItem& );
264 
265 	// Erfrage das Default Attribut vom Dokument.
266 	const SfxPoolItem& GetDefault( sal_uInt16 nFmtHint ) const;
267 
268     void ResetAttr( const SvUShortsSort* pAttrs = 0 );
269 	void GCAttr();
270 
271 	// returns the scripttpye of the selection
272     sal_uInt16 GetScriptType() const;
273 
274 	// returns the language at current cursor position
275 	sal_uInt16 GetCurLang() const;
276 
277 	// TABLE
278 	sal_uInt16 GetTblFrmFmtCount( sal_Bool bUsed = sal_False ) const;
279 	SwFrmFmt& GetTblFrmFmt(sal_uInt16 nFmt, sal_Bool bUsed = sal_False ) const;
280 	String GetUniqueTblName() const;
281 
282 	// CHAR
283 	sal_uInt16 GetCharFmtCount() const;
284 	SwCharFmt& GetCharFmt(sal_uInt16 nFmt) const;
285 	SwCharFmt* GetCurCharFmt() const;
286 	void FillByEx(SwCharFmt*, sal_Bool bReset = sal_False);
287 	SwCharFmt* MakeCharFmt( const String& rName, SwCharFmt* pDerivedFrom = 0 );
288 	SwCharFmt* FindCharFmtByName( const String& rName ) const;
289 
290 
291 	/* Formatcollections, neu */
292 	/* GetXXXCount() liefert die Anzahl der im Dokument vorhandenen XXX
293 	 * GetXXX(i)	 liefert das i-te XXX (ERR_RAISE bei Ueberindizierung!)
294 	 * DelXXX(i)	 loescht das i-te XXX (ERR_RAISE bei Ueberindizierung!)
295 	 * GetCurXXX()	 liefert das am Cursor oder in den Bereichen
296 	 *				 geltende XXX (0, wenn nicht eindeutig!)
297 	 * SetXXX() 	 setzt am Cursor oder in den Bereichen das XXX
298 	 * MakeXXX()	 macht ein XXX, abgeleitet vom pDerivedFrom
299 	 */
300 
301 	// TXT
302 	SwTxtFmtColl& GetDfltTxtFmtColl() const;
303 	sal_uInt16 GetTxtFmtCollCount() const;
304 	SwTxtFmtColl& GetTxtFmtColl( sal_uInt16 nTxtFmtColl) const;
305 	SwTxtFmtColl* GetCurTxtFmtColl() const;
306 
307     // Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTxtFmtColl(..)>
308     void SetTxtFmtColl( SwTxtFmtColl*,
309                         const bool bResetListAttrs = false );
310 
311 	SwTxtFmtColl *MakeTxtFmtColl(const String &rFmtCollName,
312 		SwTxtFmtColl *pDerivedFrom = 0);
313 	void FillByEx(SwTxtFmtColl*, sal_Bool bReset = sal_False);
314 	SwTxtFmtColl* FindTxtFmtCollByName( const String& rName ) const;
315 
316 		// Gebe die "Auto-Collection" mit der Id zurueck. Existiert
317 		// sie noch nicht, dann erzuege sie
318 	SwTxtFmtColl* GetTxtCollFromPool( sal_uInt16 nId );
319 		// return das geforderte automatische  Format - Basis-Klasse !
320 	SwFmt* GetFmtFromPool( sal_uInt16 nId );
321 		// returne die geforderte automatische Seiten-Vorlage
322 	SwPageDesc* GetPageDescFromPool( sal_uInt16 nId );
323 
324 	// erfrage ob die Absatz-/Zeichen-/Rahmen-/Seiten - Vorlage benutzt wird
325 	sal_Bool IsUsed( const SwModify& ) const;
326 
327 		// returne das geforderte automatische Format
GetFrmFmtFromPool(sal_uInt16 nId)328 	SwFrmFmt* GetFrmFmtFromPool( sal_uInt16 nId )
329 		{ return (SwFrmFmt*)SwEditShell::GetFmtFromPool( nId ); }
GetCharFmtFromPool(sal_uInt16 nId)330 	SwCharFmt* GetCharFmtFromPool( sal_uInt16 nId )
331 		{ return (SwCharFmt*)SwEditShell::GetFmtFromPool( nId ); }
332 
333 	// Felder
334     void Insert2(SwField&, const bool bForceExpandHints = false);
335 
336 	void UpdateFlds( SwField & );		// ein einzelnes Feld
337 
338 	sal_uInt16 GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX, sal_Bool bUsed = sal_False) const;
339 	SwFieldType* GetFldType(sal_uInt16 nId, sal_uInt16 nResId = USHRT_MAX, sal_Bool bUsed = sal_False) const;
340 	SwFieldType* GetFldType(sal_uInt16 nResId, const String& rName) const;
341 
342 	void RemoveFldType(sal_uInt16 nId, sal_uInt16 nResId = USHRT_MAX);
343 	void RemoveFldType(sal_uInt16 nResId, const String& rName);
344 
345 	void FieldToText( SwFieldType* pType );
346 
347 	void ChangeAuthorityData(const SwAuthEntry* pNewData);
348 
349 	// Datenbankinfo
350 	SwDBData GetDBData() const;
351 	const SwDBData& GetDBDesc() const;
352 	void ChgDBData(const SwDBData& SwDBData);
353 	void ChangeDBFields( const SvStringsDtor& rOldNames,
354 						 const String& rNewName );
355 	void GetAllUsedDB( SvStringsDtor& rDBNameList,
356 						SvStringsDtor* pAllDBNames = 0 );
357 
358     sal_Bool IsAnyDatabaseFieldInDoc()const;
359     //check whether DB fields point to an available data source and returns it
360     sal_Bool IsFieldDataSourceAvailable(String& rUsedDataSource) const;
361 	void UpdateExpFlds(sal_Bool bCloseDB = sal_False);// nur alle ExpressionFelder updaten
362 	void SetFixFields( sal_Bool bOnlyTimeDate = sal_False,
363 						const DateTime* pNewDateTime = 0 );
364 	void LockExpFlds();
365 	void UnlockExpFlds();
366 
367     SwFldUpdateFlags GetFldUpdateFlags(sal_Bool bDocSettings = sal_False) const;
368     void SetFldUpdateFlags( SwFldUpdateFlags eFlags );
369 
370 	// fuer die Evaluierung der DBFelder (neuer DB-Manager)
371 	SwNewDBMgr* GetNewDBMgr() const;
372 
373 	SwFieldType* InsertFldType(const SwFieldType &);
374 
375 	// Aenderungen am Dokument?
376 	sal_Bool IsModified() const;
377 	void SetModified();
378 	void ResetModified();
379 	void SetUndoNoResetModified();
380 
381 	// Dokument - Statistics
382 	void UpdateDocStat( SwDocStat& rStat );
383 
384 	// Verzeichnismarke einfuegen loeschen
385 	void 	Insert(const SwTOXMark& rMark);
386 	void	DeleteTOXMark(SwTOXMark* pMark);
387 
388 	// Alle Markierungen am aktuellen SPoint ermitteln
389 	sal_uInt16	GetCurTOXMarks(SwTOXMarks& rMarks) const ;
390 
391 	// Verzeichnis einfuegen, und bei Bedarf erneuern
392 	void				InsertTableOf(const SwTOXBase& rTOX,
393 										const SfxItemSet* pSet = 0);
394 	sal_Bool				UpdateTableOf(const SwTOXBase& rTOX,
395 										const SfxItemSet* pSet = 0);
396 	const SwTOXBase* 	GetCurTOX() const;
397 	const SwTOXBase* 	GetDefaultTOXBase( TOXTypes eTyp, sal_Bool bCreate = sal_False );
398 	void				SetDefaultTOXBase(const SwTOXBase& rBase);
399 
400 	sal_Bool 				IsTOXBaseReadonly(const SwTOXBase& rTOXBase) const;
401 	void 				SetTOXBaseReadonly(const SwTOXBase& rTOXBase, sal_Bool bReadonly);
402 
403 	sal_uInt16				GetTOXCount() const;
404 	const SwTOXBase*	GetTOX(	sal_uInt16 nPos ) const;
405 	sal_Bool 				DeleteTOX( const SwTOXBase& rTOXBase, sal_Bool bDelNodes = sal_False );
406 
407 	// nach einlesen einer Datei alle Verzeichnisse updaten
408 	void SetUpdateTOX( sal_Bool bFlag = sal_True );
409 	sal_Bool IsUpdateTOX() const;
410 
411 	// Verzeichnis-Typen verwalten
412 	sal_uInt16				GetTOXTypeCount(TOXTypes eTyp) const;
413 	const SwTOXType* 	GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const;
414 	void			 	InsertTOXType(const SwTOXType& rTyp);
415 
416 	//AutoMark file
417 	const String&	GetTOIAutoMarkURL() const;
418 	void			SetTOIAutoMarkURL(const String& rSet);
419 	void 			ApplyAutoMark();
420 
421 	// Schluessel fuer die Indexverwaltung
422 	sal_uInt16 GetTOIKeys( SwTOIKeyType eTyp, SvStringsSort& rArr ) const;
423 
424 	void SetOutlineNumRule(const SwNumRule&);
425 	const SwNumRule* GetOutlineNumRule() const;
426 	// Gliederung - hoch-/runterstufen
427 	sal_Bool OutlineUpDown( short nOffset = 1 );
428 	// Gliederung - hoch-/runtermoven
429 	sal_Bool MoveOutlinePara( short nOffset = 1);
430 	// Outlines and SubOutline are protected ?
431 	sal_Bool IsProtectedOutlinePara() const;
432 
433 
434     const SwNumRule* GetNumRuleAtCurrCrsrPos() const;
435 
436     // Returns the numbering rule found at the paragraphs of the current selection,
437     // if all paragraphs of the current selection have the same or none numbering rule applied.
438     const SwNumRule* GetNumRuleAtCurrentSelection() const;
439 
440     // Optional parameter <bResetIndentAttrs> (default value sal_False).
441     //  If <bResetIndentAttrs> equals true, the indent attributes "before text"
442     //  and "first line indent" are additionally reset at the current selection,
443     //  if the list style makes use of the new list level attributes.
444     // Parameters <bCreateNewList> and <sContinuedListId>
445     //  <bCreateNewList> indicates, if a new list is created by applying the given list style.
446     //  If <bCreateNewList> equals false, <sContinuedListId> may contain the
447     //  list Id of a list, which has to be continued by applying the given list style
448     void SetCurNumRule( const SwNumRule&,
449                         const bool bCreateNewList /*= false*/,
450                         const String sContinuedListId = String(),
451                         const bool bResetIndentAttrs = false );
452 
453     // Absaetze ohne Numerierung, aber mit Einzuegen
454     sal_Bool NoNum();
455     // Loeschen, Splitten der Aufzaehlungsliste
456     void DelNumRules();
457     // Hoch-/Runterstufen
458     sal_Bool NumUpDown( sal_Bool bDown = sal_True );
459     // Hoch-/Runtermoven sowohl innerhalb als auch ausserhalb von Numerierungen
460     sal_Bool MoveParagraph( long nOffset = 1 );
461     sal_Bool MoveNumParas( sal_Bool bUpperLower, sal_Bool bUpperLeft );
462     // No-/Numerierung ueber Delete/Backspace ein/abschalten #115901#
463     sal_Bool NumOrNoNum( sal_Bool bDelete = sal_False, sal_Bool bChkStart = sal_True );
464     // -> #i23726#
465 
466     void ChangeIndentOfAllListLevels( const short nDiff );
467     void SetIndent(short nIndent, const SwPosition & rPos);
468     bool IsFirstOfNumRuleAtCrsrPos() const;
469 
470     sal_Bool IsNoNum( sal_Bool bChkStart = sal_True ) const;
471 	// returne den Num-Level des Nodes, in dem sich der Point vom
472 	// Cursor befindet. Return kann sein :
473 	// - NO_NUMBERING, 0..MAXLEVEL-1, NO_NUMLEVEL .. NO_NUMLEVEL|MAXLEVEL-1
474     sal_uInt8 GetNumLevel() const;
475 
476     // detect highest and lowest level to check moving of outline levels
477     void GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower );
478 
479 
480 	// get Outline level of current paragraph
481 	int GetCurrentParaOutlineLevel( ) const;// #outlinelevel add by zhaojianwei
482 
483     // -> i29560
484     sal_Bool HasNumber() const;
485     sal_Bool HasBullet() const;
486     // <- i29560
487 
488     sal_Bool SelectionHasNumber() const;
489     sal_Bool SelectionHasBullet() const;
490 
491 	String GetUniqueNumRuleName( const String* pChkStr = 0, sal_Bool bAutoNum = sal_True ) const;
492 	void ChgNumRuleFmts( const SwNumRule& rRule );
493 	// setze und erfrage, ob an aktueller PointPos eine Numerierung mit
494 	// dem StartFlag startet
495 	void SetNumRuleStart( sal_Bool bFlag = sal_True );
496 	sal_Bool IsNumRuleStart() const;
497     void SetNodeNumStart( sal_uInt16 nStt );
498     // --> OD 2008-02-29 #refactorlists#
499     sal_uInt16 GetNodeNumStart() const;
500     // <--
501 	sal_Bool ReplaceNumRule( const String& rOldRule, const String& rNewRule );
502     // Searches for a text node with a numbering rule.
503     // --> OD 2008-03-18 #refactorlists# - add output parameter <sListId>
504     // in case a list style is found, <sListId> holds the list id, to which the
505     // text node belongs, which applies the found list style.
506     const SwNumRule * SearchNumRule(const bool bForward,
507                                     const bool bNum,
508                                     const bool bOutline,
509                                     int nNonEmptyAllowed,
510                                     String& sListId );
511     // <--
512 
513 	// Undo
514 	// UndoHistory am Dokument pflegen
515 	// bei Save, SaveAs, Create wird UndoHistory zurueckgesetzt ???
516 	void DoUndo( sal_Bool bOn = sal_True );
517 	sal_Bool DoesUndo() const;
518 	void DoGroupUndo( sal_Bool bUn = sal_True );
519 	sal_Bool DoesGroupUndo() const;
520 	void DelAllUndoObj();
521 
522 	// macht rueckgaengig:
523 	// setzt Undoklammerung auf, liefert nUndoId der Klammerung
524     SwUndoId StartUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
525 	// schliesst Klammerung der nUndoId, nicht vom UI benutzt
526     SwUndoId EndUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
527 
528     bool     GetLastUndoInfo(::rtl::OUString *const o_pStr,
529                              SwUndoId *const o_pId) const;
530     bool     GetFirstRedoInfo(::rtl::OUString *const o_pStr) const;
531     SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const;
532 
533     /// is it forbidden to modify cursors via API calls?
534     bool CursorsLocked() const;
535     /// set selections to those contained in the UndoRedoContext
536     /// should only be called by sw::UndoManager!
537     void HandleUndoRedoContext(::sw::UndoRedoContext & rContext);
538 
539     bool Undo(sal_uInt16 const nCount = 1);
540     bool Redo(sal_uInt16 const nCount = 1);
541     bool Repeat(sal_uInt16 const nCount);
542 
543 	// fuer alle Sichten auf dieses Dokument
544 	void StartAllAction();
545 	void EndAllAction();
546 
547 	//Damit Start-/EndActions aufgesetzt werden koennen.
548 	void CalcLayout();
549 
550 	// Inhaltsform bestimmen, holen, liefert Type am CurCrsr->SPoint
551 	sal_uInt16 GetCntType() const;
552 	sal_Bool HasOtherCnt() const; // gibt es Rahmen, Fussnoten, ...
553 
554 	/* Anwenden der ViewOptions mit Start-/EndAction */
555 	virtual void ApplyViewOptions( const SwViewOption &rOpt );
556 
557 	// Text innerhalb der Selektion erfragen
558 	// Returnwert liefert sal_False, wenn der selektierte Bereich
559 	// zu gross ist, um in den Stringpuffer kopiert zu werden
560 	// oder andere Fehler auftreten
561 	sal_Bool GetSelectedText( String &rBuf,
562 						int nHndlParaBreak = GETSELTXT_PARABRK_TO_BLANK );
563 
564 	/*
565 	 * liefert eine Graphic, wenn CurCrsr->Point() auf einen
566 	 * SwGrfNode zeigt (und Mark nicht gesetzt ist oder auf die
567 	 * gleiche Graphic zeigt), sonst gibt's was auf die Finger
568 	 */
569     // --> OD 2005-02-09 #119353# - robust
570     const Graphic* GetGraphic( sal_Bool bWait = sal_True ) const;
571     const GraphicObject* GetGraphicObj() const;
572     // <--
573 	sal_Bool IsGrfSwapOut( sal_Bool bOnlyLinked = sal_False ) const;
574 	sal_uInt16 GetGraphicType() const;
575 
576 	const PolyPolygon *GetGraphicPolygon() const;
577 	void SetGraphicPolygon( const PolyPolygon *pPoly );
578 
579     // If there's an automatic, not manipulated polygon at the selected
580     // notxtnode, it has to be deleted, e.g. cause the object has changed.
581     void ClearAutomaticContour();
582 
583 	/*
584 	 * liefert die Groesse einer Graphic in Twips, wenn der Cursor
585 	 * auf einer Graphic steht; sal_Bool liefert sal_False, wenn s.o.
586 	 */
587 	sal_Bool GetGrfSize(Size&) const;
588 	/*
589 	 * liefert den Namen und den Filter einer Graphic, wenn der Cursor
590 	 * auf einer Graphic steht, sonst gibt's was auf die Finger!
591 	 * Ist ein String-Ptr != 0 dann returne den entsp. Namen
592 	 */
593 	void GetGrfNms( String* pGrfName, String* pFltName,
594 					const SwFlyFrmFmt* = 0 ) const;
595 	/*
596 	 * erneutes Einlesen, falls Graphic nicht Ok ist. Die
597 	 * aktuelle wird durch die neue ersetzt.
598 	 */
599 	void ReRead( const String& rGrfName, const String& rFltName,
600 				  const Graphic* pGraphic = 0,
601 				  const GraphicObject* pGrafObj = 0 );
602 
603 //    // alternativen Text einer Grafik/OLe-Objectes abfragen/setzen
604 //    const String& GetAlternateText() const;
605 //    void SetAlternateText( const String& rTxt );
606 
607 	//eindeutige Identifikation des Objektes (fuer ImageMapDlg)
608 	void    *GetIMapInventor() const;
609     // --> OD 2007-03-01 #i73788#
610     // remove default parameter, because method always called this default value
611     Graphic GetIMapGraphic() const; //liefert eine Graphic fuer alle Flys!
612     // <--
613 	const SwFlyFrmFmt* FindFlyByName( const String& rName, sal_uInt8 nNdTyp = 0 ) const;
614 
615 	//liefert ein ClientObject, wenn CurCrsr->Point() auf einen
616 	//SwOLENode zeigt (und Mark nicht gesetzt ist oder auf das
617 	//gleiche ClientObject zeigt), sonst gibt's was auf die
618 	//Finger.
619     svt::EmbeddedObjectRef&  GetOLEObject() const;
620 	//Gibt es ein OleObject mit diesem Namen (SwFmt)?
621 	sal_Bool HasOLEObj( const String &rName ) const;
622 
623 	//Liefert den Pointer auf die Daten des Chart, indem sich der Crsr
624 	//befindet.
625 	void SetChartName( const String &rName );
626 
627 	//Updaten der Inhalte aller Charts zu der Tabelle mit dem angegeben Namen
628 	void UpdateCharts( const String &rName );
629 
630 	//	aktuelles Wort erfragen
631 	String GetCurWord();
632 
633 	// Textbaustein aus dem Textbausteindokument in
634 	// das aktuelle Dokument, Vorlagen nur wenn es nicht schon gibt
635 	void InsertGlossary( SwTextBlocks& rGlossary, const String& );
636 	// aktuelle Selektion zum Textbaustein machen und ins
637 	// Textbausteindokument einfuegen, einschliesslich Vorlagen
638 	sal_uInt16 MakeGlossary( SwTextBlocks& rToFill, const String& rName,
639 						 const String& rShortName, sal_Bool bSaveRelFile = sal_False,
640                          const String* pOnlyTxt=0 );
641 	// speicher den gesamten Inhalt des Docs als Textbaustein
642 	sal_uInt16 SaveGlossaryDoc( SwTextBlocks& rGlossary, const String& rName,
643 							const String& rShortName,
644 							sal_Bool bSaveRelFile = sal_False,
645                             sal_Bool bOnlyTxt = sal_False );
646 
647 	// Linguistik
648 	// Selektionen sichern
649 	void HyphStart( SwDocPositions eStart, SwDocPositions eEnde );
650 	// Selektionen wiederherstellen
651 	void HyphEnd();
652     com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>
653 				HyphContinue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt );
654 	// zu trennendes Wort ignorieren
655 	void HyphIgnore();
656 
657 	// zum Einfuegen des SoftHyphens, Position ist der Offset
658 	// innerhalb des getrennten Wortes.
659 	void InsertSoftHyph( const xub_StrLen nHyphPos );
660 
661 	//Tabelle
662     const SwTable& InsertTable( const SwInsertTableOptions& rInsTblOpts,  // ALL_TBL_INS_ATTR
663                                 sal_uInt16 nRows, sal_uInt16 nCols,
664                                 sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
665                                 const SwTableAutoFmt* pTAFmt = 0 );
666 
667     void InsertDDETable( const SwInsertTableOptions& rInsTblOpts,  // HEADLINE_NO_BORDER
668                          SwDDEFieldType* pDDEType,
669                          sal_uInt16 nRows, sal_uInt16 nCols,
670                          sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL );
671 
672     void UpdateTable();
673 	void SetTableName( SwFrmFmt& rTblFmt, const String &rNewName );
674 
675 	SwFrmFmt *GetTableFmt();
676     sal_Bool TextToTable( const SwInsertTableOptions& rInsTblOpts,  //ALL_TBL_INS_ATTR
677                       sal_Unicode cCh,
678                       sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
679                       const SwTableAutoFmt* pTAFmt = 0 );
680 	sal_Bool TableToText( sal_Unicode cCh );
681 	sal_Bool IsTextToTableAvailable() const;
682 
683 	sal_Bool GetTblBoxFormulaAttrs( SfxItemSet& rSet ) const;
684 	void SetTblBoxFormulaAttrs( const SfxItemSet& rSet );
685 
686 	sal_Bool IsTableBoxTextFormat() const;
687 	String GetTableBoxText() const;
688 
689 	// Change Modus erfragen/setzen
690     TblChgMode GetTblChgMode() const;
691     void SetTblChgMode( TblChgMode eMode );
692 
693 	// Tabelle an der Cursor Position aufsplitten
694 	sal_Bool SplitTable( sal_uInt16 eMode );
695 	// Tabellen verbinden
696 	// CanMerge kann feststellen, ob Prev oder Next moeglich ist. Wird
697 	// der Pointer pChkNxtPrv uebergeben, wird festgestellt in welche
698 	// Richtung es moeglich ist.
699 	sal_Bool CanMergeTable( sal_Bool bWithPrev = sal_True, sal_Bool* pChkNxtPrv = 0 ) const;
700 	sal_Bool MergeTable( sal_Bool bWithPrev = sal_True, sal_uInt16 nMode = 0 );
701 		// setze das InsertDB als Tabelle Undo auf:
702 	void AppendUndoForInsertFromDB( sal_Bool bIsTable );
703 
704     /*
705         functions used for spell checking and text conversion
706     */
707 
708 	// Selektionen sichern
709 	void SpellStart( SwDocPositions eStart, SwDocPositions eEnde,
710                      SwDocPositions eCurr, SwConversionArgs *pConvArgs = 0 );
711     // Selektionen wiederherstellen
712     void SpellEnd( SwConversionArgs *pConvArgs = 0, bool bRestoreSelection = true );
713     ::com::sun::star::uno::Any SpellContinue(
714                     sal_uInt16* pPageCnt, sal_uInt16* pPageSt,
715                     SwConversionArgs *pConvArgs = 0 );
716 
717     // spells on a sentence basis - the SpellPortions are needed
718     // returns false if no error could be found
719     bool SpellSentence(::svx::SpellPortions& rToFill, bool bIsGrammarCheck );
720     // make SpellIter start with the current sentence when called next time
721     void PutSpellingToSentenceStart();
722     // moves the continuation position to the end of the currently checked sentence
723     void MoveContinuationPosToEndOfCheckedSentence();
724     //applies a changed sentence
725     void ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, bool bRecheck);
726 
727 
728     // check SwSpellIter data to see if the last sentence got grammar checked
729     bool HasLastSentenceGotGrammarChecked() const;
730     // Is text conversion active somewhere else?
731     sal_Bool HasConvIter() const;
732 	// Is hyphenation active somewhere else?
733 	sal_Bool HasHyphIter() const;
734 
735 	::com::sun::star::uno::Reference<
736 		::com::sun::star::linguistic2::XSpellAlternatives >
737             GetCorrection( const Point* pPt, SwRect& rSelectRect );
738 
739 
740     bool GetGrammarCorrection( ::com::sun::star::linguistic2::ProofreadingResult /*out*/ &rResult,
741             sal_Int32 /*out*/ &rErrorPosInText,
742             sal_Int32 /*out*/ &rErrorIndexInResult,
743             ::com::sun::star::uno::Sequence< rtl::OUString > /*out*/ &rSuggestions,
744             const Point* pPt, SwRect& rSelectRect );
745 
746     void IgnoreGrammarErrorAt( SwPaM& rErrorPosition );
747     void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnde );
748 
749 	// returne zum Namen die im Doc gesetzte Referenz
750 	const SwFmtRefMark* GetRefMark( const String& rName ) const;
751 	// returne die Namen aller im Doc gesetzten Referenzen
752 	// 	Ist der ArrayPointer 0 dann returne nur, ob im Doc. eine RefMark
753 	//	gesetzt ist
754 	sal_uInt16 GetRefMarks( SvStringsDtor* = 0 ) const;
755 
756 	// rufe die Autokorrektur auf
757 	void AutoCorrect( SvxAutoCorrect& rACorr, sal_Bool bInsertMode = sal_True,
758 						sal_Unicode cChar = ' ' );
759 	sal_Bool GetPrevAutoCorrWord( SvxAutoCorrect& rACorr, String& rWord );
760 
761 	// dann setze nach entsprechenden Regeln unsere Vorlagen
762 	void AutoFormat( const SvxSwAutoFmtFlags* pAFlags = 0 );
763 
764 	static SvxSwAutoFmtFlags* GetAutoFmtFlags();
765 	static void SetAutoFmtFlags(SvxSwAutoFmtFlags *);
766 
767 	// errechnet die Selektion
768 	String Calculate();
769 
770 	sal_Bool InsertURL( const SwFmtINetFmt& rFmt, const String& rStr,
771 					sal_Bool bKeepSelection = sal_False );
772 	sal_uInt16 GetINetAttrs( SwGetINetAttrs& rArr );
773 
774 	//SS Fuer holen/ersetzen DropCap-Inhalt
775 	String GetDropTxt( const sal_uInt16 nChars ) const;
776 	void   ReplaceDropTxt( const String &rStr );
777 
778     // may an outline be moved or copied?
779     // Check whether it's in text body, not in table, and not read-only (move)
780 	sal_Bool IsOutlineMovable( sal_uInt16 nIdx ) const;
781 	sal_Bool IsOutlineCopyable( sal_uInt16 nIdx ) const;
782 
783 	sal_uInt16 GetLineCount( sal_Bool bActPos = sal_True );
784 
785 	// erfrage und setze den Fussnoten-Text/Nummer. Set.. auf akt. SSelection!
786 	sal_Bool GetCurFtn( SwFmtFtn* pToFillFtn = 0 );
787     bool SetCurFtn( const SwFmtFtn& rFillFtn );
788     bool HasFtns( bool bEndNotes = false ) const;
789 //z.Zt nicht benoetigt	sal_uInt16 GetFtnCnt( sal_Bool bEndNotes = sal_False ) const;
790 		// gebe Liste aller Fussnoten und deren Anfangstexte
791     sal_uInt16 GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes = false );
792 
793     SwSection const* InsertSection(
794             SwSectionData & rNewData, SfxItemSet const*const = 0 );
795 	sal_Bool IsInsRegionAvailable() const;
796 	const SwSection* GetCurrSection() const;
797 	// liefert wie GetCurrSection() den aktuellen Bereich, allerdings geht diese Funktion
798 	// ueber die Frames und erwischt dabei auch den Bereich, wenn der Cursor in einer
799 	// Fussnote steht, deren Referenz in einem spaltigen Bereich steckt.
800 	// Wenn man bOutOfTab setzt, wird der Bereich gesucht,
801 	// der die Tabelle umfasst, nicht etwa ein innerer.
802     const SwSection* GetAnySection( sal_Bool bOutOfTab = sal_False, const Point* pPt = 0 ) const;
803 
804 	sal_uInt16 GetSectionFmtCount() const;
805 	sal_uInt16 GetSectionFmtPos( const SwSectionFmt& ) const;
806 	const SwSectionFmt& GetSectionFmt(sal_uInt16 nFmt) const;
807 	void DelSectionFmt( sal_uInt16 nFmt );
808     void UpdateSection(sal_uInt16 const nSect, SwSectionData &,
809             SfxItemSet const*const  = 0);
810 	sal_Bool IsAnySectionInDoc( sal_Bool bChkReadOnly = sal_False,
811 							sal_Bool bChkHidden = sal_False,
812 							sal_Bool BChkTOX = sal_False ) const;
813 
814 	String GetUniqueSectionName( const String* pChkStr = 0 ) const;
815 
816 	//Attribute setzen
817 	void SetSectionAttr(const SfxItemSet& rSet, SwSectionFmt* pSectFmt = 0);
818 
819 	// search inside the cursor selection for full selected sections.
820 	// if any part of section in the selection return 0.
821 	// if more than one in the selection return the count
822 	sal_uInt16 GetFullSelectedSectionCount() const;
823 
824     // special insert: Insert a new text node just before or after a section or
825     // table, if the cursor is positioned at the start/end of said
826     // section/table. The purpose of the method is to allow users to inert text
827     // at certain 'impossible' position, e.g. before a table at the document
828     // start or between to sections.
829 	bool DoSpecialInsert();
830 	bool CanSpecialInsert() const;
831 
832 	// Optimierung UI
833 	void SetNewDoc(sal_Bool bNew = sal_True);
834 
835     sfx2::LinkManager& GetLinkManager();
836 	inline const sfx2::LinkManager& GetLinkManager() const;
837 
838 	// linken Rand ueber Objectleiste einstellen (aenhlich dem Stufen von
839 	// Numerierungen), optional kann man "um" den Offset stufen oder "auf"
840 	// die Position gestuft werden (bModulus = sal_True)
841 	sal_Bool IsMoveLeftMargin( sal_Bool bRight = sal_True, sal_Bool bModulus = sal_True ) const;
842 	void MoveLeftMargin( sal_Bool bRight = sal_True, sal_Bool bModulus = sal_True );
843 
844 	// Numberformatter vom Doc erfragen
845 		  SvNumberFormatter* GetNumberFormatter();
GetNumberFormatter() const846 	const SvNumberFormatter* GetNumberFormatter() const
847 	{	return ((SwEditShell*)this)->GetNumberFormatter(); 	}
848 
849 	// Schnitstellen fuers GlobalDokument
850 	sal_Bool IsGlobalDoc() const;
851 	void SetGlblDocSaveLinks( sal_Bool bFlag = sal_True );
852 	sal_Bool IsGlblDocSaveLinks() const;
853 	sal_uInt16 GetGlobalDocContent( SwGlblDocContents& rArr ) const;
854 	sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
855                                  SwSectionData & rNew );
856 	sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
857 								 const SwTOXBase& rTOX );
858 	sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos );
859 	sal_Bool DeleteGlobalDocContent( const SwGlblDocContents& rArr,
860 								sal_uInt16 nPos );
861 	sal_Bool MoveGlobalDocContent( const SwGlblDocContents& rArr ,
862 								sal_uInt16 nFromPos, sal_uInt16 nToPos,
863 								sal_uInt16 nNewPos );
864 	sal_Bool GotoGlobalDocContent( const SwGlblDocContent& rPos );
865 
866 	// alles fuers Redlining
867 	sal_uInt16 GetRedlineMode() const;
868 	void SetRedlineMode( sal_uInt16 eMode );
869 	sal_Bool IsRedlineOn() const;
870 	sal_uInt16 GetRedlineCount() const;
871 	const SwRedline& GetRedline( sal_uInt16 nPos ) const;
872 	sal_Bool AcceptRedline( sal_uInt16 nPos );
873 	sal_Bool RejectRedline( sal_uInt16 nPos );
874 	// suche das Redline zu diesem Data und returne die Pos im Array
875 	// USHRT_MAX wird returnt, falls nicht vorhanden
876 	sal_uInt16 FindRedlineOfData( const SwRedlineData& ) const;
877 
878 	// Kommentar am Redline an der Position setzen
879 	sal_Bool SetRedlineComment( const String& rS );
880 	const SwRedline* GetCurrRedline() const;
881 
882 	// Redline Anzeigeattribute wurden geaendert, Views updaten
883 	void UpdateRedlineAttr();
884 
885 	//  vergleiche zwei Dokument mit einander
886 	long CompareDoc( const SwDoc& rDoc );
887 	// merge zweier Dokumente
888 	long MergeDoc( const SwDoc& rDoc );
889 
890 	// Dokumentglobale Fussnoteneigenschaften
891 	const SwFtnInfo& GetFtnInfo() const;
892 	void  SetFtnInfo(const SwFtnInfo& rInfo);
893 	const SwEndNoteInfo& GetEndNoteInfo() const;
894 	void  SetEndNoteInfo(const SwEndNoteInfo& rInfo);
895 
896 	//Einstellungen fuer Zeilennummierung
897 	const SwLineNumberInfo &GetLineNumberInfo() const;
898 	void  SetLineNumberInfo( const SwLineNumberInfo& rInfo);
899 
900 	// Etiketten: Bereiche synchronisieren
901 	void SetLabelDoc( sal_Bool bFlag = sal_True );
902 	sal_Bool IsLabelDoc() const;
903 
904 	// Schnittstelle fuer die TextInputDaten - ( fuer die Texteingabe
905 	// von japanischen/chinesischen Zeichen)
906     SwExtTextInput* CreateExtTextInput(LanguageType eInputLanguage);
907     String DeleteExtTextInput( SwExtTextInput* pDel = 0, sal_Bool bInsText = sal_True);
908 //	SwExtTextInput* GetExtTextInput() const;
909 	void SetExtTextInputData( const CommandExtTextInputData& );
910 
911 	// Schnistelle fuer den Zugriff auf die AutoComplete-Liste
912 	static SwAutoCompleteWord& GetAutoCompleteWords();
913 
914 	// returns a scaling factor of selected text. Used for the rotated
915 	// character attribut dialog.
916 	sal_uInt16 GetScalingOfSelectedText() const;
917 
918 	// ctor/dtor
919     SwEditShell( SwDoc&, Window*, const SwViewOption *pOpt = 0 );
920 	// verkleideter Copy-Constructor
921 	SwEditShell( SwEditShell&, Window* );
922 	virtual ~SwEditShell();
923 
924 private:
925 	// fuer METWARE:
926 	// es wird nicht kopiert und nicht zugewiesen
927 	SwEditShell(const SwEditShell &);
928 	const SwEditShell &operator=(const SwEditShell &);
929 };
930 
GetLinkManager() const931 inline const sfx2::LinkManager& SwEditShell::GetLinkManager() const
932 {	return ((SwEditShell*)this)->GetLinkManager();	}
933 
934 /*
935  * Klasse fuer den automatisierten Aufruf von Start- und
936  * EndAction();
937  */
938 class SwActKontext {
939 	SwEditShell *pSh;
940 public:
941 	SwActKontext(SwEditShell *pShell);
942 	~SwActKontext();
943 };
944 
945 #define ACT_KONTEXT(x)	SwActKontext _aActKontext_(x)
946 
947 /*
948  * Klasse fuer den automatisierten Aufruf von Start- und
949  * EndCrsrMove();
950  */
951 class SwMvKontext {
952 	SwEditShell *pSh;
953 public:
954 	SwMvKontext(SwEditShell *pShell );
955 	~SwMvKontext();
956 };
957 
958 #define MV_KONTEXT(x)	SwMvKontext _aMvKontext_(x)
959 
960 
961 
962 #endif
963