xref: /trunk/main/sw/inc/editsh.hxx (revision 1d2dbeb0)
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;			// fuer Felder
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 
137 	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 SetAttr( const SfxPoolItem&, sal_uInt16 nFlags = 0 );
260 	void SetAttr( 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     // --> OD 2007-11-06 #i62675#
307     // Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTxtFmtColl(..)>
308     void SetTxtFmtColl( SwTxtFmtColl*,
309                         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
328 	SwFrmFmt* GetFrmFmtFromPool( sal_uInt16 nId )
329 		{ return (SwFrmFmt*)SwEditShell::GetFmtFromPool( 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 	SwField* GetCurFld() const;
336 
337 	void UpdateFlds( SwField & );		// ein einzelnes Feld
338 
339 	sal_uInt16 GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX, sal_Bool bUsed = sal_False) const;
340 	SwFieldType* GetFldType(sal_uInt16 nId, sal_uInt16 nResId = USHRT_MAX, sal_Bool bUsed = sal_False) const;
341 	SwFieldType* GetFldType(sal_uInt16 nResId, const String& rName) const;
342 
343 	void RemoveFldType(sal_uInt16 nId, sal_uInt16 nResId = USHRT_MAX);
344 	void RemoveFldType(sal_uInt16 nResId, const String& rName);
345 
346 	void FieldToText( SwFieldType* pType );
347 
348 	void ChangeAuthorityData(const SwAuthEntry* pNewData);
349 
350 	// Datenbankinfo
351 	SwDBData GetDBData() const;
352 	const SwDBData& GetDBDesc() const;
353 	void ChgDBData(const SwDBData& SwDBData);
354 	void ChangeDBFields( const SvStringsDtor& rOldNames,
355 						 const String& rNewName );
356 	void GetAllUsedDB( SvStringsDtor& rDBNameList,
357 						SvStringsDtor* pAllDBNames = 0 );
358 
359     sal_Bool IsAnyDatabaseFieldInDoc()const;
360     //check whether DB fields point to an available data source and returns it
361     sal_Bool IsFieldDataSourceAvailable(String& rUsedDataSource) const;
362 	void UpdateExpFlds(sal_Bool bCloseDB = sal_False);// nur alle ExpressionFelder updaten
363 	void SetFixFields( sal_Bool bOnlyTimeDate = sal_False,
364 						const DateTime* pNewDateTime = 0 );
365 	void LockExpFlds();
366 	void UnlockExpFlds();
367 
368     SwFldUpdateFlags GetFldUpdateFlags(sal_Bool bDocSettings = sal_False) const;
369     void SetFldUpdateFlags( SwFldUpdateFlags eFlags );
370 
371 	// fuer die Evaluierung der DBFelder (neuer DB-Manager)
372 	SwNewDBMgr* GetNewDBMgr() const;
373 
374 	SwFieldType* InsertFldType(const SwFieldType &);
375 
376 	// Aenderungen am Dokument?
377 	sal_Bool IsModified() const;
378 	void SetModified();
379 	void ResetModified();
380 	void SetUndoNoResetModified();
381 
382 	// Dokument - Statistics
383 	void UpdateDocStat( SwDocStat& rStat );
384 
385 	// Verzeichnismarke einfuegen loeschen
386 	void 	Insert(const SwTOXMark& rMark);
387 	void	DeleteTOXMark(SwTOXMark* pMark);
388 
389 	// Alle Markierungen am aktuellen SPoint ermitteln
390 	sal_uInt16	GetCurTOXMarks(SwTOXMarks& rMarks) const ;
391 
392 	// Verzeichnis einfuegen, und bei Bedarf erneuern
393 	void				InsertTableOf(const SwTOXBase& rTOX,
394 										const SfxItemSet* pSet = 0);
395 	sal_Bool				UpdateTableOf(const SwTOXBase& rTOX,
396 										const SfxItemSet* pSet = 0);
397 	const SwTOXBase* 	GetCurTOX() const;
398 	const SwTOXBase* 	GetDefaultTOXBase( TOXTypes eTyp, sal_Bool bCreate = sal_False );
399 	void				SetDefaultTOXBase(const SwTOXBase& rBase);
400 
401 	sal_Bool 				IsTOXBaseReadonly(const SwTOXBase& rTOXBase) const;
402 	void 				SetTOXBaseReadonly(const SwTOXBase& rTOXBase, sal_Bool bReadonly);
403 
404 	sal_uInt16				GetTOXCount() const;
405 	const SwTOXBase*	GetTOX(	sal_uInt16 nPos ) const;
406 	sal_Bool 				DeleteTOX( const SwTOXBase& rTOXBase, sal_Bool bDelNodes = sal_False );
407 
408 	// nach einlesen einer Datei alle Verzeichnisse updaten
409 	void SetUpdateTOX( sal_Bool bFlag = sal_True );
410 	sal_Bool IsUpdateTOX() const;
411 
412 	// Verzeichnis-Typen verwalten
413 	sal_uInt16				GetTOXTypeCount(TOXTypes eTyp) const;
414 	const SwTOXType* 	GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const;
415 	void			 	InsertTOXType(const SwTOXType& rTyp);
416 
417 	//AutoMark file
418 	const String&	GetTOIAutoMarkURL() const;
419 	void			SetTOIAutoMarkURL(const String& rSet);
420 	void 			ApplyAutoMark();
421 
422 	// Schluessel fuer die Indexverwaltung
423 	sal_uInt16 GetTOIKeys( SwTOIKeyType eTyp, SvStringsSort& rArr ) const;
424 
425 	void SetOutlineNumRule(const SwNumRule&);
426 	const SwNumRule* GetOutlineNumRule() const;
427 	// Gliederung - hoch-/runterstufen
428 	sal_Bool OutlineUpDown( short nOffset = 1 );
429 	// Gliederung - hoch-/runtermoven
430 	sal_Bool MoveOutlinePara( short nOffset = 1);
431 	// Outlines and SubOutline are protected ?
432 	sal_Bool IsProtectedOutlinePara() const;
433 
434 	// Numerierung Aufzaehlunglisten
435 	// liefert Regelwerk der aktuellen Aufzaehlung (sal_False sonst)
436 	const SwNumRule* GetCurNumRule() const;
437 
438 	// setzt, wenn noch keine Numerierung, sonst wird geaendert
439 	// arbeitet mit alten und neuen Regeln, nur Differenzen aktualisieren
440     // --> OD 2008-02-08 #newlistlevelattrs#
441     // Add optional parameter <bResetIndentAttrs> (default value sal_False).
442     // If <bResetIndentAttrs> equals true, the indent attributes "before text"
443     // and "first line indent" are additionally reset at the current selection,
444     // if the list style makes use of the new list level attributes.
445     // --> OD 2008-03-17 #refactorlists#
446     // introduce parameters <bCreateNewList> and <sContinuedListId>
447     // <bCreateNewList> indicates, if a new list is created by applying the
448     // given list style.
449     // If <bCreateNewList> equals sal_False, <sContinuedListId> may contain the
450     // list Id of a list, which has to be continued by applying the given list style
451     void SetCurNumRule( const SwNumRule&,
452                         const bool bCreateNewList /*= false*/,
453                         const String sContinuedListId = String(),
454                         const bool bResetIndentAttrs = false );
455     // <--
456 	// Absaetze ohne Numerierung, aber mit Einzuegen
457 	sal_Bool NoNum();
458 	// Loeschen, Splitten der Aufzaehlungsliste
459     void DelNumRules();
460 	// Hoch-/Runterstufen
461 	sal_Bool NumUpDown( sal_Bool bDown = sal_True );
462 	// Hoch-/Runtermoven sowohl innerhalb als auch ausserhalb von Numerierungen
463 	sal_Bool MoveParagraph( long nOffset = 1);
464 	sal_Bool MoveNumParas( sal_Bool bUpperLower, sal_Bool bUpperLeft );
465 	// No-/Numerierung ueber Delete/Backspace ein/abschalten #115901#
466 	sal_Bool NumOrNoNum( sal_Bool bDelete = sal_False, sal_Bool bChkStart = sal_True);
467     // -> #i23726#
468     // --> OD 2008-06-09 #i90078#
469     // Remove unused default parameter <nLevel> and <bRelative>.
470     // Adjust method name and parameter name
471     void ChangeIndentOfAllListLevels( short nDiff );
472     // Adjust method name
473     void SetIndent(short nIndent, const SwPosition & rPos);
474     // <--
475     sal_Bool IsFirstOfNumRule() const;
476     sal_Bool IsFirstOfNumRule(const SwPaM & rPaM) const;
477     // <- #i23726#
478 
479     sal_Bool IsNoNum( sal_Bool bChkStart = sal_True ) const;
480 	// returne den Num-Level des Nodes, in dem sich der Point vom
481 	// Cursor befindet. Return kann sein :
482 	// - NO_NUMBERING, 0..MAXLEVEL-1, NO_NUMLEVEL .. NO_NUMLEVEL|MAXLEVEL-1
483     // --> OD 2008-02-29 #refactorlists# - removed <pHasChilds>
484 //    sal_uInt8 GetNumLevel( sal_Bool* pHasChilds = 0 ) const;
485     sal_uInt8 GetNumLevel() const;
486     // <--
487     // detect highest and lowest level to check moving of outline levels
488     void GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower );
489 
490 
491 	// get Outline level of current paragraph
492 	int GetCurrentParaOutlineLevel( ) const;// #outlinelevel add by zhaojianwei
493 
494     // -> i29560
495     sal_Bool HasNumber() const;
496     sal_Bool HasBullet() const;
497     // <- i29560
498 
499 	String GetUniqueNumRuleName( const String* pChkStr = 0, sal_Bool bAutoNum = sal_True ) const;
500 	void ChgNumRuleFmts( const SwNumRule& rRule );
501 	// setze und erfrage, ob an aktueller PointPos eine Numerierung mit
502 	// dem StartFlag startet
503 	void SetNumRuleStart( sal_Bool bFlag = sal_True );
504 	sal_Bool IsNumRuleStart() const;
505     void SetNodeNumStart( sal_uInt16 nStt );
506     // --> OD 2008-02-29 #refactorlists#
507     sal_uInt16 GetNodeNumStart() const;
508     // <--
509 	sal_Bool ReplaceNumRule( const String& rOldRule, const String& rNewRule );
510     // Searches for a text node with a numbering rule.
511     // --> OD 2008-03-18 #refactorlists# - add output parameter <sListId>
512     // in case a list style is found, <sListId> holds the list id, to which the
513     // text node belongs, which applies the found list style.
514     const SwNumRule * SearchNumRule(const bool bForward,
515                                     const bool bNum,
516                                     const bool bOutline,
517                                     int nNonEmptyAllowed,
518                                     String& sListId );
519     // <--
520 
521 	// Undo
522 	// UndoHistory am Dokument pflegen
523 	// bei Save, SaveAs, Create wird UndoHistory zurueckgesetzt ???
524 	void DoUndo( sal_Bool bOn = sal_True );
525 	sal_Bool DoesUndo() const;
526 	void DoGroupUndo( sal_Bool bUn = sal_True );
527 	sal_Bool DoesGroupUndo() const;
528 	void DelAllUndoObj();
529 
530 	// macht rueckgaengig:
531 	// setzt Undoklammerung auf, liefert nUndoId der Klammerung
532     SwUndoId StartUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
533 	// schliesst Klammerung der nUndoId, nicht vom UI benutzt
534     SwUndoId EndUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
535 
536     bool     GetLastUndoInfo(::rtl::OUString *const o_pStr,
537                              SwUndoId *const o_pId) const;
538     bool     GetFirstRedoInfo(::rtl::OUString *const o_pStr) const;
539     SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const;
540 
541     /// is it forbidden to modify cursors via API calls?
542     bool CursorsLocked() const;
543     /// set selections to those contained in the UndoRedoContext
544     /// should only be called by sw::UndoManager!
545     void HandleUndoRedoContext(::sw::UndoRedoContext & rContext);
546 
547     bool Undo(sal_uInt16 const nCount = 1);
548     bool Redo(sal_uInt16 const nCount = 1);
549     bool Repeat(sal_uInt16 const nCount);
550 
551 	// fuer alle Sichten auf dieses Dokument
552 	void StartAllAction();
553 	void EndAllAction();
554 
555 	//Damit Start-/EndActions aufgesetzt werden koennen.
556 	void CalcLayout();
557 
558 	// Inhaltsform bestimmen, holen, liefert Type am CurCrsr->SPoint
559 	sal_uInt16 GetCntType() const;
560 	sal_Bool HasOtherCnt() const; // gibt es Rahmen, Fussnoten, ...
561 
562 	/* Anwenden der ViewOptions mit Start-/EndAction */
563 	virtual void ApplyViewOptions( const SwViewOption &rOpt );
564 
565 	// Text innerhalb der Selektion erfragen
566 	// Returnwert liefert sal_False, wenn der selektierte Bereich
567 	// zu gross ist, um in den Stringpuffer kopiert zu werden
568 	// oder andere Fehler auftreten
569 	sal_Bool GetSelectedText( String &rBuf,
570 						int nHndlParaBreak = GETSELTXT_PARABRK_TO_BLANK );
571 
572 	/*
573 	 * liefert eine Graphic, wenn CurCrsr->Point() auf einen
574 	 * SwGrfNode zeigt (und Mark nicht gesetzt ist oder auf die
575 	 * gleiche Graphic zeigt), sonst gibt's was auf die Finger
576 	 */
577     // --> OD 2005-02-09 #119353# - robust
578     const Graphic* GetGraphic( sal_Bool bWait = sal_True ) const;
579     const GraphicObject* GetGraphicObj() const;
580     // <--
581 	sal_Bool IsGrfSwapOut( sal_Bool bOnlyLinked = sal_False ) const;
582 	sal_uInt16 GetGraphicType() const;
583 
584 	const PolyPolygon *GetGraphicPolygon() const;
585 	void SetGraphicPolygon( const PolyPolygon *pPoly );
586 
587     // If there's an automatic, not manipulated polygon at the selected
588     // notxtnode, it has to be deleted, e.g. cause the object has changed.
589     void ClearAutomaticContour();
590 
591 	/*
592 	 * liefert die Groesse einer Graphic in Twips, wenn der Cursor
593 	 * auf einer Graphic steht; sal_Bool liefert sal_False, wenn s.o.
594 	 */
595 	sal_Bool GetGrfSize(Size&) const;
596 	/*
597 	 * liefert den Namen und den Filter einer Graphic, wenn der Cursor
598 	 * auf einer Graphic steht, sonst gibt's was auf die Finger!
599 	 * Ist ein String-Ptr != 0 dann returne den entsp. Namen
600 	 */
601 	void GetGrfNms( String* pGrfName, String* pFltName,
602 					const SwFlyFrmFmt* = 0 ) const;
603 	/*
604 	 * erneutes Einlesen, falls Graphic nicht Ok ist. Die
605 	 * aktuelle wird durch die neue ersetzt.
606 	 */
607 	void ReRead( const String& rGrfName, const String& rFltName,
608 				  const Graphic* pGraphic = 0,
609 				  const GraphicObject* pGrafObj = 0 );
610 
611 //    // alternativen Text einer Grafik/OLe-Objectes abfragen/setzen
612 //    const String& GetAlternateText() const;
613 //    void SetAlternateText( const String& rTxt );
614 
615 	//eindeutige Identifikation des Objektes (fuer ImageMapDlg)
616 	void    *GetIMapInventor() const;
617     // --> OD 2007-03-01 #i73788#
618     // remove default parameter, because method always called this default value
619     Graphic GetIMapGraphic() const; //liefert eine Graphic fuer alle Flys!
620     // <--
621 	const SwFlyFrmFmt* FindFlyByName( const String& rName, sal_uInt8 nNdTyp = 0 ) const;
622 
623 	//liefert ein ClientObject, wenn CurCrsr->Point() auf einen
624 	//SwOLENode zeigt (und Mark nicht gesetzt ist oder auf das
625 	//gleiche ClientObject zeigt), sonst gibt's was auf die
626 	//Finger.
627     svt::EmbeddedObjectRef&  GetOLEObject() const;
628 	//Gibt es ein OleObject mit diesem Namen (SwFmt)?
629 	sal_Bool HasOLEObj( const String &rName ) const;
630 
631 	//Liefert den Pointer auf die Daten des Chart, indem sich der Crsr
632 	//befindet.
633 	void SetChartName( const String &rName );
634 
635 	//Updaten der Inhalte aller Charts zu der Tabelle mit dem angegeben Namen
636 	void UpdateCharts( const String &rName );
637 
638 	//	aktuelles Wort erfragen
639 	String GetCurWord();
640 
641 	// Textbaustein aus dem Textbausteindokument in
642 	// das aktuelle Dokument, Vorlagen nur wenn es nicht schon gibt
643 	void InsertGlossary( SwTextBlocks& rGlossary, const String& );
644 	// aktuelle Selektion zum Textbaustein machen und ins
645 	// Textbausteindokument einfuegen, einschliesslich Vorlagen
646 	sal_uInt16 MakeGlossary( SwTextBlocks& rToFill, const String& rName,
647 						 const String& rShortName, sal_Bool bSaveRelFile = sal_False,
648                          const String* pOnlyTxt=0 );
649 	// speicher den gesamten Inhalt des Docs als Textbaustein
650 	sal_uInt16 SaveGlossaryDoc( SwTextBlocks& rGlossary, const String& rName,
651 							const String& rShortName,
652 							sal_Bool bSaveRelFile = sal_False,
653                             sal_Bool bOnlyTxt = sal_False );
654 
655 	// Linguistik
656 	// Selektionen sichern
657 	void HyphStart( SwDocPositions eStart, SwDocPositions eEnde );
658 	// Selektionen wiederherstellen
659 	void HyphEnd();
660     com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>
661 				HyphContinue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt );
662 	// zu trennendes Wort ignorieren
663 	void HyphIgnore();
664 
665 	// zum Einfuegen des SoftHyphens, Position ist der Offset
666 	// innerhalb des getrennten Wortes.
667 	void InsertSoftHyph( const xub_StrLen nHyphPos );
668 
669 	//Tabelle
670     const SwTable& InsertTable( const SwInsertTableOptions& rInsTblOpts,  // ALL_TBL_INS_ATTR
671                                 sal_uInt16 nRows, sal_uInt16 nCols,
672                                 sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
673                                 const SwTableAutoFmt* pTAFmt = 0 );
674 
675     void InsertDDETable( const SwInsertTableOptions& rInsTblOpts,  // HEADLINE_NO_BORDER
676                          SwDDEFieldType* pDDEType,
677                          sal_uInt16 nRows, sal_uInt16 nCols,
678                          sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL );
679 
680     void UpdateTable();
681 	void SetTableName( SwFrmFmt& rTblFmt, const String &rNewName );
682 
683 	SwFrmFmt *GetTableFmt();
684     sal_Bool TextToTable( const SwInsertTableOptions& rInsTblOpts,  //ALL_TBL_INS_ATTR
685                       sal_Unicode cCh,
686                       sal_Int16 eAdj = com::sun::star::text::HoriOrientation::FULL,
687                       const SwTableAutoFmt* pTAFmt = 0 );
688 	sal_Bool TableToText( sal_Unicode cCh );
689 	sal_Bool IsTextToTableAvailable() const;
690 
691 	sal_Bool GetTblBoxFormulaAttrs( SfxItemSet& rSet ) const;
692 	void SetTblBoxFormulaAttrs( const SfxItemSet& rSet );
693 
694 	sal_Bool IsTableBoxTextFormat() const;
695 	String GetTableBoxText() const;
696 
697 	// Change Modus erfragen/setzen
698     TblChgMode GetTblChgMode() const;
699     void SetTblChgMode( TblChgMode eMode );
700 
701 	// Tabelle an der Cursor Position aufsplitten
702 	sal_Bool SplitTable( sal_uInt16 eMode );
703 	// Tabellen verbinden
704 	// CanMerge kann feststellen, ob Prev oder Next moeglich ist. Wird
705 	// der Pointer pChkNxtPrv uebergeben, wird festgestellt in welche
706 	// Richtung es moeglich ist.
707 	sal_Bool CanMergeTable( sal_Bool bWithPrev = sal_True, sal_Bool* pChkNxtPrv = 0 ) const;
708 	sal_Bool MergeTable( sal_Bool bWithPrev = sal_True, sal_uInt16 nMode = 0 );
709 		// setze das InsertDB als Tabelle Undo auf:
710 	void AppendUndoForInsertFromDB( sal_Bool bIsTable );
711 
712     /*
713         functions used for spell checking and text conversion
714     */
715 
716 	// Selektionen sichern
717 	void SpellStart( SwDocPositions eStart, SwDocPositions eEnde,
718                      SwDocPositions eCurr, SwConversionArgs *pConvArgs = 0 );
719     // Selektionen wiederherstellen
720     void SpellEnd( SwConversionArgs *pConvArgs = 0, bool bRestoreSelection = true );
721     ::com::sun::star::uno::Any SpellContinue(
722                     sal_uInt16* pPageCnt, sal_uInt16* pPageSt,
723                     SwConversionArgs *pConvArgs = 0 );
724 
725     // spells on a sentence basis - the SpellPortions are needed
726     // returns false if no error could be found
727     bool SpellSentence(::svx::SpellPortions& rToFill, bool bIsGrammarCheck );
728     // make SpellIter start with the current sentence when called next time
729     void PutSpellingToSentenceStart();
730     // moves the continuation position to the end of the currently checked sentence
731     void MoveContinuationPosToEndOfCheckedSentence();
732     //applies a changed sentence
733     void ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, bool bRecheck);
734 
735 
736     // check SwSpellIter data to see if the last sentence got grammar checked
737     bool HasLastSentenceGotGrammarChecked() const;
738     // Is text conversion active somewhere else?
739     sal_Bool HasConvIter() const;
740 	// Is hyphenation active somewhere else?
741 	sal_Bool HasHyphIter() const;
742 
743 	::com::sun::star::uno::Reference<
744 		::com::sun::star::linguistic2::XSpellAlternatives >
745             GetCorrection( const Point* pPt, SwRect& rSelectRect );
746 
747 
748     bool GetGrammarCorrection( ::com::sun::star::linguistic2::ProofreadingResult /*out*/ &rResult,
749             sal_Int32 /*out*/ &rErrorPosInText,
750             sal_Int32 /*out*/ &rErrorIndexInResult,
751             ::com::sun::star::uno::Sequence< rtl::OUString > /*out*/ &rSuggestions,
752             const Point* pPt, SwRect& rSelectRect );
753 
754     void IgnoreGrammarErrorAt( SwPaM& rErrorPosition );
755     void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnde );
756 
757 	// returne zum Namen die im Doc gesetzte Referenz
758 	const SwFmtRefMark* GetRefMark( const String& rName ) const;
759 	// returne die Namen aller im Doc gesetzten Referenzen
760 	// 	Ist der ArrayPointer 0 dann returne nur, ob im Doc. eine RefMark
761 	//	gesetzt ist
762 	sal_uInt16 GetRefMarks( SvStringsDtor* = 0 ) const;
763 
764 	// rufe die Autokorrektur auf
765 	void AutoCorrect( SvxAutoCorrect& rACorr, sal_Bool bInsertMode = sal_True,
766 						sal_Unicode cChar = ' ' );
767 	sal_Bool GetPrevAutoCorrWord( SvxAutoCorrect& rACorr, String& rWord );
768 
769 	// dann setze nach entsprechenden Regeln unsere Vorlagen
770 	void AutoFormat( const SvxSwAutoFmtFlags* pAFlags = 0 );
771 
772 	static SvxSwAutoFmtFlags* GetAutoFmtFlags();
773 	static void SetAutoFmtFlags(SvxSwAutoFmtFlags *);
774 
775 	// errechnet die Selektion
776 	String Calculate();
777 
778 	sal_Bool InsertURL( const SwFmtINetFmt& rFmt, const String& rStr,
779 					sal_Bool bKeepSelection = sal_False );
780 	sal_uInt16 GetINetAttrs( SwGetINetAttrs& rArr );
781 
782 	//SS Fuer holen/ersetzen DropCap-Inhalt
783 	String GetDropTxt( const sal_uInt16 nChars ) const;
784 	void   ReplaceDropTxt( const String &rStr );
785 
786     // may an outline be moved or copied?
787     // Check whether it's in text body, not in table, and not read-only (move)
788 	sal_Bool IsOutlineMovable( sal_uInt16 nIdx ) const;
789 	sal_Bool IsOutlineCopyable( sal_uInt16 nIdx ) const;
790 
791 	sal_uInt16 GetLineCount( sal_Bool bActPos = sal_True );
792 
793 	// erfrage und setze den Fussnoten-Text/Nummer. Set.. auf akt. SSelection!
794 	sal_Bool GetCurFtn( SwFmtFtn* pToFillFtn = 0 );
795     bool SetCurFtn( const SwFmtFtn& rFillFtn );
796     bool HasFtns( bool bEndNotes = false ) const;
797 //z.Zt nicht benoetigt	sal_uInt16 GetFtnCnt( sal_Bool bEndNotes = sal_False ) const;
798 		// gebe Liste aller Fussnoten und deren Anfangstexte
799     sal_uInt16 GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes = false );
800 
801     SwSection const* InsertSection(
802             SwSectionData & rNewData, SfxItemSet const*const = 0 );
803 	sal_Bool IsInsRegionAvailable() const;
804 	const SwSection* GetCurrSection() const;
805 	// liefert wie GetCurrSection() den aktuellen Bereich, allerdings geht diese Funktion
806 	// ueber die Frames und erwischt dabei auch den Bereich, wenn der Cursor in einer
807 	// Fussnote steht, deren Referenz in einem spaltigen Bereich steckt.
808 	// Wenn man bOutOfTab setzt, wird der Bereich gesucht,
809 	// der die Tabelle umfasst, nicht etwa ein innerer.
810     const SwSection* GetAnySection( sal_Bool bOutOfTab = sal_False, const Point* pPt = 0 ) const;
811 
812 	sal_uInt16 GetSectionFmtCount() const;
813 	sal_uInt16 GetSectionFmtPos( const SwSectionFmt& ) const;
814 	const SwSectionFmt& GetSectionFmt(sal_uInt16 nFmt) const;
815 	void DelSectionFmt( sal_uInt16 nFmt );
816     void UpdateSection(sal_uInt16 const nSect, SwSectionData &,
817             SfxItemSet const*const  = 0);
818 	sal_Bool IsAnySectionInDoc( sal_Bool bChkReadOnly = sal_False,
819 							sal_Bool bChkHidden = sal_False,
820 							sal_Bool BChkTOX = sal_False ) const;
821 
822 	String GetUniqueSectionName( const String* pChkStr = 0 ) const;
823 
824 	//Attribute setzen
825 	void SetSectionAttr(const SfxItemSet& rSet, SwSectionFmt* pSectFmt = 0);
826 
827 	// search inside the cursor selection for full selected sections.
828 	// if any part of section in the selection return 0.
829 	// if more than one in the selection return the count
830 	sal_uInt16 GetFullSelectedSectionCount() const;
831 
832     // special insert: Insert a new text node just before or after a section or
833     // table, if the cursor is positioned at the start/end of said
834     // section/table. The purpose of the method is to allow users to inert text
835     // at certain 'impossible' position, e.g. before a table at the document
836     // start or between to sections.
837 	bool DoSpecialInsert();
838 	bool CanSpecialInsert() const;
839 
840 	// Optimierung UI
841 	void SetNewDoc(sal_Bool bNew = sal_True);
842 
843     sfx2::LinkManager& GetLinkManager();
844 	inline const sfx2::LinkManager& GetLinkManager() const;
845 
846 	// linken Rand ueber Objectleiste einstellen (aenhlich dem Stufen von
847 	// Numerierungen), optional kann man "um" den Offset stufen oder "auf"
848 	// die Position gestuft werden (bModulus = sal_True)
849 	sal_Bool IsMoveLeftMargin( sal_Bool bRight = sal_True, sal_Bool bModulus = sal_True ) const;
850 	void MoveLeftMargin( sal_Bool bRight = sal_True, sal_Bool bModulus = sal_True );
851 
852 	// Numberformatter vom Doc erfragen
853 		  SvNumberFormatter* GetNumberFormatter();
854 	const SvNumberFormatter* GetNumberFormatter() const
855 	{	return ((SwEditShell*)this)->GetNumberFormatter(); 	}
856 
857 	// Schnitstellen fuers GlobalDokument
858 	sal_Bool IsGlobalDoc() const;
859 	void SetGlblDocSaveLinks( sal_Bool bFlag = sal_True );
860 	sal_Bool IsGlblDocSaveLinks() const;
861 	sal_uInt16 GetGlobalDocContent( SwGlblDocContents& rArr ) const;
862 	sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
863                                  SwSectionData & rNew );
864 	sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
865 								 const SwTOXBase& rTOX );
866 	sal_Bool InsertGlobalDocContent( const SwGlblDocContent& rPos );
867 	sal_Bool DeleteGlobalDocContent( const SwGlblDocContents& rArr,
868 								sal_uInt16 nPos );
869 	sal_Bool MoveGlobalDocContent( const SwGlblDocContents& rArr ,
870 								sal_uInt16 nFromPos, sal_uInt16 nToPos,
871 								sal_uInt16 nNewPos );
872 	sal_Bool GotoGlobalDocContent( const SwGlblDocContent& rPos );
873 
874 	// alles fuers Redlining
875 	sal_uInt16 GetRedlineMode() const;
876 	void SetRedlineMode( sal_uInt16 eMode );
877 	sal_Bool IsRedlineOn() const;
878 	sal_uInt16 GetRedlineCount() const;
879 	const SwRedline& GetRedline( sal_uInt16 nPos ) const;
880 	sal_Bool AcceptRedline( sal_uInt16 nPos );
881 	sal_Bool RejectRedline( sal_uInt16 nPos );
882 	// suche das Redline zu diesem Data und returne die Pos im Array
883 	// USHRT_MAX wird returnt, falls nicht vorhanden
884 	sal_uInt16 FindRedlineOfData( const SwRedlineData& ) const;
885 
886 	// Kommentar am Redline an der Position setzen
887 	sal_Bool SetRedlineComment( const String& rS );
888 	const SwRedline* GetCurrRedline() const;
889 
890 	// Redline Anzeigeattribute wurden geaendert, Views updaten
891 	void UpdateRedlineAttr();
892 
893 	//  vergleiche zwei Dokument mit einander
894 	long CompareDoc( const SwDoc& rDoc );
895 	// merge zweier Dokumente
896 	long MergeDoc( const SwDoc& rDoc );
897 
898 	// Dokumentglobale Fussnoteneigenschaften
899 	const SwFtnInfo& GetFtnInfo() const;
900 	void  SetFtnInfo(const SwFtnInfo& rInfo);
901 	const SwEndNoteInfo& GetEndNoteInfo() const;
902 	void  SetEndNoteInfo(const SwEndNoteInfo& rInfo);
903 
904 	//Einstellungen fuer Zeilennummierung
905 	const SwLineNumberInfo &GetLineNumberInfo() const;
906 	void  SetLineNumberInfo( const SwLineNumberInfo& rInfo);
907 
908 	// Etiketten: Bereiche synchronisieren
909 	void SetLabelDoc( sal_Bool bFlag = sal_True );
910 	sal_Bool IsLabelDoc() const;
911 
912 	// Schnittstelle fuer die TextInputDaten - ( fuer die Texteingabe
913 	// von japanischen/chinesischen Zeichen)
914     SwExtTextInput* CreateExtTextInput(LanguageType eInputLanguage);
915     String DeleteExtTextInput( SwExtTextInput* pDel = 0, sal_Bool bInsText = sal_True);
916 //	SwExtTextInput* GetExtTextInput() const;
917 	void SetExtTextInputData( const CommandExtTextInputData& );
918 
919 	// Schnistelle fuer den Zugriff auf die AutoComplete-Liste
920 	static SwAutoCompleteWord& GetAutoCompleteWords();
921 
922 	// returns a scaling factor of selected text. Used for the rotated
923 	// character attribut dialog.
924 	sal_uInt16 GetScalingOfSelectedText() const;
925 
926 	// ctor/dtor
927     SwEditShell( SwDoc&, Window*, const SwViewOption *pOpt = 0 );
928 	// verkleideter Copy-Constructor
929 	SwEditShell( SwEditShell&, Window* );
930 	virtual ~SwEditShell();
931 
932 private:
933 	// fuer METWARE:
934 	// es wird nicht kopiert und nicht zugewiesen
935 	SwEditShell(const SwEditShell &);
936 	const SwEditShell &operator=(const SwEditShell &);
937 };
938 
939 inline const sfx2::LinkManager& SwEditShell::GetLinkManager() const
940 {	return ((SwEditShell*)this)->GetLinkManager();	}
941 
942 /*
943  * Klasse fuer den automatisierten Aufruf von Start- und
944  * EndAction();
945  */
946 class SwActKontext {
947 	SwEditShell *pSh;
948 public:
949 	SwActKontext(SwEditShell *pShell);
950 	~SwActKontext();
951 };
952 
953 #define ACT_KONTEXT(x)	SwActKontext _aActKontext_(x)
954 
955 /*
956  * Klasse fuer den automatisierten Aufruf von Start- und
957  * EndCrsrMove();
958  */
959 class SwMvKontext {
960 	SwEditShell *pSh;
961 public:
962 	SwMvKontext(SwEditShell *pShell );
963 	~SwMvKontext();
964 };
965 
966 #define MV_KONTEXT(x)	SwMvKontext _aMvKontext_(x)
967 
968 
969 
970 #endif
971