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