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