1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <com/sun/star/text/HoriOrientation.hpp>
23 #include <com/sun/star/embed/XEmbeddedObject.hpp>
24 #include <tools/string.hxx>
25 #include <vcl/font.hxx>
26 #include <editeng/swafopt.hxx>
28 #include <crsrsh.hxx> // For base class.
29 #include <itabenum.hxx>
30 #include <swdbdata.hxx>
31 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
32 #include <com/sun/star/linguistic2/ProofreadingResult.hpp>
33 #include <fldupde.hxx>
34 #include <tblenum.hxx>
40 #include <svtools/embedhlp.hxx>
41 #include <boost/ptr_container/ptr_vector.hpp>
46 class CommandExtTextInputData
;
48 class SvNumberFormatter
;
59 class SwAutoCompleteWord
;
69 class SwFrmFmt
; ///< For GetTxtNodeFmts().
72 class SwRootFrm
; ///< For CTOR.
75 class SwFmtINetFmt
; ///< InsertURL.
77 class SwTextBlocks
; ///< For GlossaryRW.
89 class SwGlblDocContent
;
90 class SwGlblDocContents
;
95 class SwLineNumberInfo
;
98 struct SwConversionArgs
;
101 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{
102 template < class > class Sequence
;
107 typedef std::vector
<SpellPortion
> SpellPortions
;
115 class UndoRedoContext
;
118 #define GETSELTXT_PARABRK_TO_BLANK 0
119 #define GETSELTXT_PARABRK_KEEP 1
120 #define GETSELTXT_PARABRK_TO_ONLYCR 2
123 /// For querying the INet-attributes for Navigator.
127 const SwTxtINetFmt
& rINetAttr
;
129 SwGetINetAttr( const String
& rTxt
, const SwTxtINetFmt
& rAttr
)
130 : sText( rTxt
), rINetAttr( rAttr
)
133 typedef boost::ptr_vector
<SwGetINetAttr
> SwGetINetAttrs
;
135 // Types of forms of content.
136 #define CNT_TXT 0x0001
137 #define CNT_GRF 0x0002
138 #define CNT_OLE 0x0010
140 // Test USHORT for a defined form of content.
141 #define CNT_HasTxt(USH) ((USH)&CNT_TXT)
142 #define CNT_HasGrf(USH) ((USH)&CNT_GRF)
143 #define CNT_HasOLE(USH) ((USH)&CNT_OLE)
145 class SW_DLLPUBLIC SwEditShell
: public SwCrsrShell
147 static SvxSwAutoFmtFlags
* pAutoFmtFlags
;
149 /// For the private methods DelRange and those of AutoCorrect.
150 friend class SwAutoFormat
;
151 friend void _InitCore();
152 friend void _FinitCore();
153 /// For the PamCorrAbs/-Rel methods.
156 SW_DLLPRIVATE SfxPoolItem
& _GetChrFmt( SfxPoolItem
& ) const;
158 /** Returns pointer to a SwGrfNode
159 that will be used by GetGraphic() and GetGraphicSize(). */
160 SW_DLLPRIVATE SwGrfNode
*_GetGrfNode() const ;
162 SW_DLLPRIVATE
void DeleteSel( SwPaM
& rPam
, sal_Bool
* pUndo
= 0 );
164 SW_DLLPRIVATE
void _SetSectionAttr( SwSectionFmt
& rSectFmt
, const SfxItemSet
& rSet
);
166 using ViewShell::UpdateFlds
;
167 using SwModify::GetInfo
;
170 /// Edit (all selected ranges).
171 void Insert( sal_Unicode
, sal_Bool bOnlyCurrCrsr
= sal_False
);
172 void Insert2( const String
&, const bool bForceExpandHints
= false );
173 void Overwrite( const String
& );
175 /** Replace a selected range in a TextNode by given string.
176 Meant for Search & Replace.
177 bRegExpRplc - replace tabs (\\t) and insert found string (not \&).
178 E.g.: Fnd: "zzz", Repl: "xx\t\\t..&..\&"
179 --> "xx\t<Tab>..zzz..&" */
180 sal_Bool
Replace( const String
& rNewStr
, sal_Bool bRegExpRplc
= sal_False
);
182 /** Delete content of all ranges.
183 If whole nodes are selected, these nodes get deleted. */
186 /// Remove a complete paragraph.
187 sal_Bool
DelFullPara();
189 /// Change text to Upper/Lower/Hiragana/Katagana/...
190 void TransliterateText( sal_uInt32 nType
);
192 /// Count words in current selection.
193 void CountWords( SwDocStat
& rStat
) const;
195 /** Delete non-visible content in the document.
196 E.g. hidden ranges, hidden paragraphs. */
197 sal_Bool
RemoveInvisibleContent();
199 /// Replace fields by text - mailmerge support.
200 bool ConvertFieldsToText();
202 /// Set all numbering start points to a fixed value - mailmerge support.
203 void SetNumberingRestart();
205 /// Embedds all local links (ranges/graphics).
206 sal_uInt16
GetLinkUpdMode(sal_Bool bDocSettings
= sal_False
) const;
207 void SetLinkUpdMode( sal_uInt16 nMode
);
209 /// Copy content of all ranges at current position of cursor to given Shell.
210 long Copy( SwEditShell
* pDestShell
= 0 );
212 /** For copying via ClipBoard:
213 If table is copied into table, move all cursors away from it.
214 Copy and Paste must be in FEShell because of FlyFrames!
215 Copy all selections and the document. */
216 sal_Bool
_CopySelToDoc( SwDoc
* pInsDoc
, SwNodeIndex
* pNdInsPos
= 0 );
218 long SplitNode( sal_Bool bAutoFormat
= sal_False
, sal_Bool bCheckTableStart
= sal_True
);
219 sal_Bool
AppendTxtNode();
220 void AutoFmtBySplitNode();
222 /** If cursor is in a INetAttribute it will be deleted completely
223 including the descriptive text (needed at drag & drop). */
224 sal_Bool
DelINetAttrWithText();
226 /** If Cursor is at the end of a character style in which the DontExpand-flag
227 is not yet set, the latter will be set (==> return TRUE). */
228 bool DontExpandFmt();
230 /** Apply / remove attributes.
231 @return attributs in required AttributeSet.
232 When not unambiguous the set has a DONT_CARE !!
233 2nd optional parameter <bMergeIndentValuesOfNumRule>.
234 If <bMergeIndentValuesOfNumRule> == sal_True, the indent attributes of
235 the corresponding list level of an applied list style is merged into
236 the requested item set as a LR-SPACE item, if corresponding node has not
237 its own indent attributes and the position-and-space mode of the list
238 level is SvxNumberFormat::LABEL_ALIGNMENT. */
239 sal_Bool
GetPaMAttr( SwPaM
* pPaM
, SfxItemSet
& ,
240 const bool bMergeIndentValuesOfNumRule
= false ) const;
241 sal_Bool
GetCurAttr( SfxItemSet
& ,
242 const bool bMergeIndentValuesOfNumRule
= false ) const;
243 void SetAttr( const SfxPoolItem
&, sal_uInt16 nFlags
= 0 );
244 void SetAttr( const SfxItemSet
&, sal_uInt16 nFlags
= 0, SwPaM
* pCrsr
= NULL
);
247 * Get the paragraph format attribute(s) of the current selection.
249 * @see GetPaMParAttr()
252 * output parameter - the SfxItemSet where the automatic paragraph format attribut(s) will be store.
253 * The attributes aren't invalidated or cleared if the function reach the getMaxLookup limite.
255 * @return true if the function inspect all the nodes point by the pPaM parameter,
256 * false if the function reach the limit of getMaxLookup number of nodes inspected.
258 sal_Bool
GetCurParAttr( SfxItemSet
& rSet
) const;
260 * Get the paragraph format attribute(s) of the selection(s) described by a SwPaM.
263 * input parameter - the selection where to look for the paragraph format.
266 * output parameter - the SfxItemSet where the automatic paragraph format attribute(s) will be store.
267 * The attributes aren't invalidated or cleared if the function reaches the getMaxLookup limit.
269 * @return true if the function inspects all the nodes point by the pPaM parameter,
270 * false if the function reaches the limit of getMaxLookup number of nodes inspected.
272 sal_Bool
GetPaMParAttr( SwPaM
* pPaM
, SfxItemSet
& rSet
) const;
274 /// Set attribute as new default attribute in document.
275 void SetDefault( const SfxPoolItem
& );
277 /// Query default attribute of document.
278 const SfxPoolItem
& GetDefault( sal_uInt16 nFmtHint
) const;
280 void ResetAttr( const std::set
<sal_uInt16
> &attrs
= std::set
<sal_uInt16
>(), SwPaM
* pCrsr
= NULL
);
283 /// @return the scripttpye of the selection.
284 sal_uInt16
GetScriptType() const;
286 /// @return the language at current cursor position.
287 sal_uInt16
GetCurLang() const;
290 sal_uInt16
GetTblFrmFmtCount( bool bUsed
= false ) const;
291 SwFrmFmt
& GetTblFrmFmt(sal_uInt16 nFmt
, bool bUsed
= false ) const;
292 String
GetUniqueTblName() const;
295 sal_uInt16
GetCharFmtCount() const;
296 SwCharFmt
& GetCharFmt(sal_uInt16 nFmt
) const;
297 SwCharFmt
* GetCurCharFmt() const;
298 void FillByEx(SwCharFmt
*, sal_Bool bReset
= sal_False
);
299 SwCharFmt
* MakeCharFmt( const String
& rName
, SwCharFmt
* pDerivedFrom
= 0 );
300 SwCharFmt
* FindCharFmtByName( const String
& rName
) const;
303 /* FormatCollections (new) - Explaining the general naming pattern:
304 * GetXXXCount() returns the count of xxx in the document.
305 * GetXXX(i) returns i-th xxx (ERR_RAISE if beyond range!).
306 * DelXXX(i) deletes i-th xxx (ERR_RAISE if beyond range!).
307 * GetCurXXX() returns xxx that is valid at cursor or in ranges.
308 * returns 0, if not unanimuous.
309 * SetXXX() sets xxx at cursor or in ranges.
310 * MakeXXX() makes a xxx, derived from pDerivedFrom.
314 SwTxtFmtColl
& GetDfltTxtFmtColl() const;
315 sal_uInt16
GetTxtFmtCollCount() const;
316 SwTxtFmtColl
& GetTxtFmtColl( sal_uInt16 nTxtFmtColl
) const;
318 * Get the named paragraph format of the current selection.
320 * @see GetPaMTxtFmtColl()
322 * @return the named paragraph format of the first node that contains one.
323 * Nodes are sort by order of appearance in the selections ;
324 * selections are sort by their order of creation
325 * (last created selection first, oldest selection at last).
327 SwTxtFmtColl
* GetCurTxtFmtColl() const;
329 * Get the named paragraph format of the selection(s) described by a SwPaM.
332 * input parameter - the selection where to look for the paragraph format.
334 * @return the named paragraph format of the first node that contains one.
336 SwTxtFmtColl
* GetPaMTxtFmtColl( SwPaM
* pPaM
) const;
339 /// Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTxtFmtColl(..)>
340 void SetTxtFmtColl( SwTxtFmtColl
*,
341 bool bResetListAttrs
= false );
342 SwTxtFmtColl
*MakeTxtFmtColl(const String
&rFmtCollName
,
343 SwTxtFmtColl
*pDerivedFrom
= 0);
344 void FillByEx(SwTxtFmtColl
*, sal_Bool bReset
= sal_False
);
345 SwTxtFmtColl
* FindTxtFmtCollByName( const String
& rName
) const;
347 /// @return "Auto-Collection" with given Id. If it does not exist create it.
348 SwTxtFmtColl
* GetTxtCollFromPool( sal_uInt16 nId
);
350 /// @return required automatic format base class.
351 SwFmt
* GetFmtFromPool( sal_uInt16 nId
);
353 /// @return required automatic page style.
354 SwPageDesc
* GetPageDescFromPool( sal_uInt16 nId
);
356 /// Query if the paragraph-/character-/frame-/page-style is used.
357 bool IsUsed( const SwModify
& ) const;
359 /// @return required automatic format.
360 SwFrmFmt
* GetFrmFmtFromPool( sal_uInt16 nId
)
361 { return (SwFrmFmt
*)SwEditShell::GetFmtFromPool( nId
); }
362 SwCharFmt
* GetCharFmtFromPool( sal_uInt16 nId
)
363 { return (SwCharFmt
*)SwEditShell::GetFmtFromPool( nId
); }
365 void Insert2(SwField
&, const bool bForceExpandHints
= false);
366 SwField
* GetCurFld() const;
368 void UpdateFlds( SwField
& ); ///< One single field.
370 sal_uInt16
GetFldTypeCount(sal_uInt16 nResId
= USHRT_MAX
, sal_Bool bUsed
= sal_False
) const;
371 SwFieldType
* GetFldType(sal_uInt16 nId
, sal_uInt16 nResId
= USHRT_MAX
, sal_Bool bUsed
= sal_False
) const;
372 SwFieldType
* GetFldType(sal_uInt16 nResId
, const String
& rName
) const;
374 void RemoveFldType(sal_uInt16 nId
, sal_uInt16 nResId
= USHRT_MAX
);
375 void RemoveFldType(sal_uInt16 nResId
, const String
& rName
);
377 void FieldToText( SwFieldType
* pType
);
379 void ChangeAuthorityData(const SwAuthEntry
* pNewData
);
381 /// Database information.
382 SwDBData
GetDBData() const;
383 const SwDBData
& GetDBDesc() const;
384 void ChgDBData(const SwDBData
& SwDBData
);
385 void ChangeDBFields( const std::vector
<String
>& rOldNames
,
386 const String
& rNewName
);
387 void GetAllUsedDB( std::vector
<String
>& rDBNameList
,
388 std::vector
<String
>* pAllDBNames
= 0 );
390 sal_Bool
IsAnyDatabaseFieldInDoc()const;
392 /// Check whether DB fields point to an available data source and returns it.
393 sal_Bool
IsFieldDataSourceAvailable(String
& rUsedDataSource
) const;
394 void UpdateExpFlds(sal_Bool bCloseDB
= sal_False
);///< only every expression fields update
396 void UnlockExpFlds();
398 SwFldUpdateFlags
GetFldUpdateFlags(sal_Bool bDocSettings
= sal_False
) const;
399 void SetFldUpdateFlags( SwFldUpdateFlags eFlags
);
401 /// For evaluation of DB fields (new DB-manager).
402 SwNewDBMgr
* GetNewDBMgr() const;
404 SwFieldType
* InsertFldType(const SwFieldType
&);
406 /// Changes in document?
407 sal_Bool
IsModified() const;
409 void ResetModified();
410 void SetUndoNoResetModified();
412 /// Document - Statistics
413 void UpdateDocStat();
414 const SwDocStat
&GetUpdatedDocStat();
416 void Insert(const SwTOXMark
& rMark
);
418 void DeleteTOXMark(SwTOXMark
* pMark
);
420 /// Get all marks at current SPoint.
421 sal_uInt16
GetCurTOXMarks(SwTOXMarks
& rMarks
) const ;
423 /// Insert content table. Renew if required.
424 void InsertTableOf(const SwTOXBase
& rTOX
,
425 const SfxItemSet
* pSet
= 0);
426 sal_Bool
UpdateTableOf(const SwTOXBase
& rTOX
,
427 const SfxItemSet
* pSet
= 0);
428 const SwTOXBase
* GetCurTOX() const;
429 const SwTOXBase
* GetDefaultTOXBase( TOXTypes eTyp
, bool bCreate
= false );
430 void SetDefaultTOXBase(const SwTOXBase
& rBase
);
432 sal_Bool
IsTOXBaseReadonly(const SwTOXBase
& rTOXBase
) const;
433 void SetTOXBaseReadonly(const SwTOXBase
& rTOXBase
, sal_Bool bReadonly
);
435 sal_uInt16
GetTOXCount() const;
436 const SwTOXBase
* GetTOX( sal_uInt16 nPos
) const;
437 bool DeleteTOX( const SwTOXBase
& rTOXBase
, bool bDelNodes
= false );
439 /// After reading file update all content tables.
440 void SetUpdateTOX( sal_Bool bFlag
= sal_True
);
441 sal_Bool
IsUpdateTOX() const;
443 /// Manage types of content tables.
444 sal_uInt16
GetTOXTypeCount(TOXTypes eTyp
) const;
445 const SwTOXType
* GetTOXType(TOXTypes eTyp
, sal_uInt16 nId
) const;
446 void InsertTOXType(const SwTOXType
& rTyp
);
449 const String
& GetTOIAutoMarkURL() const;
450 void SetTOIAutoMarkURL(const String
& rSet
);
451 void ApplyAutoMark();
453 /// Key for managing index.
454 sal_uInt16
GetTOIKeys( SwTOIKeyType eTyp
, std::vector
<String
>& rArr
) const;
456 void SetOutlineNumRule(const SwNumRule
&);
457 const SwNumRule
* GetOutlineNumRule() const;
459 bool OutlineUpDown( short nOffset
= 1 );
461 bool MoveOutlinePara( short nOffset
= 1);
463 sal_Bool
IsProtectedOutlinePara() const;
465 /// @return numbering rulse pf current enumeration list (else FALSE).
466 const SwNumRule
* GetCurNumRule() const;
468 /** If there is not already a numbering, set one, else change.
469 Works with old and new rules. Update only differences.
470 Add optional parameter @param <bResetIndentAttrs> (default value sal_False).
471 If @param <bResetIndentAttrs> equals true, the indent attributes "before text"
472 and "first line indent" are additionally reset at the current selection,
473 if the list style makes use of the new list level attributes.
474 introduce parameters @param <bCreateNewList> and @param <sContinuedListId>
475 @param <bCreateNewList> indicates, if a new list is created by applying the
477 If @param <bCreateNewList> equals sal_False, @param <sContinuedListId> may contain the
478 list Id of a list, which has to be continued by applying the given list style. */
479 void SetCurNumRule( const SwNumRule
&,
480 const bool bCreateNewList
/*= false*/,
481 const String sContinuedListId
= String(),
482 const bool bResetIndentAttrs
= false );
484 /// Paragraphs without enumeration but with indents.
487 /// Delete, split enumeration list.
490 bool NumUpDown( bool bDown
= true );
492 bool MoveParagraph( long nOffset
= 1);
493 bool MoveNumParas( bool bUpperLower
, bool bUpperLeft
);
495 /// Switch on/off of numbering via Delete/Backspace.
496 bool NumOrNoNum( sal_Bool bDelete
= sal_False
, bool bChkStart
= true);
500 /// Remove unused default parameter <nLevel> and <bRelative>.
501 // Adjust method name and parameter name
502 void ChangeIndentOfAllListLevels( short nDiff
);
503 // Adjust method name
504 void SetIndent(short nIndent
, const SwPosition
& rPos
);
505 bool IsFirstOfNumRule() const;
506 bool IsFirstOfNumRule(const SwPaM
& rPaM
) const;
508 sal_Bool
IsNoNum( sal_Bool bChkStart
= sal_True
) const;
510 /** @return Num-Level of the node in which point of cursor is.
511 @return values can be: NO_NUMBERING,
512 0..MAXLEVEL-1, NO_NUMLEVEL .. NO_NUMLEVEL|MAXLEVEL-1 */
513 sal_uInt8
GetNumLevel() const;
515 /// Detect highest and lowest level to check moving of outline levels.
516 void GetCurrentOutlineLevels( sal_uInt8
& rUpper
, sal_uInt8
& rLower
);
519 /// Get Outline level of current paragraph.
520 int GetCurrentParaOutlineLevel( ) const;// #outlinelevel add by zhaojianwei
523 sal_Bool
HasNumber() const;
524 sal_Bool
HasBullet() const;
526 sal_Bool
SelectionHasNumber() const;
527 sal_Bool
SelectionHasBullet() const;
529 String
GetUniqueNumRuleName( const String
* pChkStr
= 0, bool bAutoNum
= true ) const;
530 void ChgNumRuleFmts( const SwNumRule
& rRule
);
532 /// Set (and query if) a numbering with StartFlag starts at current PointPos.
533 void SetNumRuleStart( sal_Bool bFlag
= sal_True
, SwPaM
* pCrsr
= NULL
);
534 sal_Bool
IsNumRuleStart( SwPaM
* pPaM
= NULL
) const;
535 void SetNodeNumStart( sal_uInt16 nStt
, SwPaM
* = NULL
);
537 sal_uInt16
GetNodeNumStart( SwPaM
* pPaM
= NULL
) const;
539 bool ReplaceNumRule( const String
& rOldRule
, const String
& rNewRule
);
541 /** Searches for a text node with a numbering rule.
542 in case a list style is found, <sListId> holds the list id, to which the
543 text node belongs, which applies the found list style. */
544 const SwNumRule
* SearchNumRule(const bool bForward
,
547 int nNonEmptyAllowed
,
551 Maintain UndoHistory in Document.
552 Reset UndoHistory at Save, SaveAs, Create ??? */
553 void DoUndo( sal_Bool bOn
= sal_True
);
554 sal_Bool
DoesUndo() const;
555 void DoGroupUndo( sal_Bool bUn
= sal_True
);
556 sal_Bool
DoesGroupUndo() const;
557 void DelAllUndoObj();
559 /// Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
560 SwUndoId
StartUndo( SwUndoId eUndoId
= UNDO_EMPTY
, const SwRewriter
* pRewriter
= 0 );
562 /// Closes parenthesis of nUndoId, not used by UI.
563 SwUndoId
EndUndo( SwUndoId eUndoId
= UNDO_EMPTY
, const SwRewriter
* pRewriter
= 0 );
565 bool GetLastUndoInfo(OUString
*const o_pStr
,
566 SwUndoId
*const o_pId
) const;
567 bool GetFirstRedoInfo(OUString
*const o_pStr
) const;
568 SwUndoId
GetRepeatInfo(OUString
*const o_pStr
) const;
570 /// is it forbidden to modify cursors via API calls?
571 bool CursorsLocked() const;
572 /// set selections to those contained in the UndoRedoContext
573 /// should only be called by sw::UndoManager!
574 void HandleUndoRedoContext(::sw::UndoRedoContext
& rContext
);
576 bool Undo(sal_uInt16
const nCount
= 1);
577 bool Redo(sal_uInt16
const nCount
= 1);
578 bool Repeat(sal_uInt16
const nCount
);
581 /// For all views of this document.
582 void StartAllAction();
585 /// To enable set up of StartActions and EndActions.
588 /// Determine form of content. Return Type at CurCrsr->SPoint.
589 sal_uInt16
GetCntType() const;
591 /// Are there frames, footnotes, etc.
592 sal_Bool
HasOtherCnt() const;
594 /// Apply ViewOptions with Start-/EndAction.
595 virtual void ApplyViewOptions( const SwViewOption
&rOpt
);
597 /** Query text within selection.
598 @returns FALSE, if selected range is too large to be copied
599 into string buffer or if other errors occur. */
600 sal_Bool
GetSelectedText( String
&rBuf
,
601 int nHndlParaBreak
= GETSELTXT_PARABRK_TO_BLANK
);
603 /** @return graphic, if CurCrsr->Point() points to a SwGrfNode
604 (and mark is not set or points to the same graphic). */
606 const Graphic
* GetGraphic( sal_Bool bWait
= sal_True
) const;
607 const GraphicObject
* GetGraphicObj() const;
609 sal_Bool
IsGrfSwapOut( sal_Bool bOnlyLinked
= sal_False
) const;
610 sal_uInt16
GetGraphicType() const;
612 const PolyPolygon
*GetGraphicPolygon() const;
613 void SetGraphicPolygon( const PolyPolygon
*pPoly
);
615 /** If there's an automatic, not manipulated polygon at the selected
616 notxtnode, it has to be deleted, e.g. cause the object has changed. */
617 void ClearAutomaticContour();
619 /// @return the size of a graphic in Twips if cursor is in a graphic.
620 sal_Bool
GetGrfSize(Size
&) const;
622 /** @return name and filter of a graphic if the cursor is in a graphic,
623 else give a rap on the knuckles!
624 If a string-ptr != 0 return the respective name. */
625 void GetGrfNms( String
* pGrfName
, String
* pFltName
,
626 const SwFlyFrmFmt
* = 0 ) const;
628 /// Re-read if graphic is not ok. Current graphic is replaced by the new one.
629 void ReRead( const String
& rGrfName
, const String
& rFltName
,
630 const Graphic
* pGraphic
= 0,
631 const GraphicObject
* pGrafObj
= 0 );
633 /// Unique identification of object (for ImageMapDlg).
634 void *GetIMapInventor() const;
637 /// Remove default parameter, because method always called this default value.
638 Graphic
GetIMapGraphic() const; ///< @return a graphic for all Flys!
639 const SwFlyFrmFmt
* FindFlyByName( const String
& rName
, sal_uInt8 nNdTyp
= 0 ) const;
641 /** @return a ClientObject, if CurCrsr->Point() points to a SwOLENode
642 (and mark is neither set not pointint to same ClientObject)
643 else give rap on the knuckles. */
644 svt::EmbeddedObjectRef
& GetOLEObject() const;
646 /// Is there an OLEObject with this name (SwFmt)?
647 sal_Bool
HasOLEObj( const String
&rName
) const;
649 /// @return pointer to the data of the chart in which Cursr is.
650 void SetChartName( const String
&rName
);
652 /// Update content of all charts for table with given name.
653 void UpdateCharts( const String
&rName
);
657 /** Glossary from glossary document in current document.
658 Styles only if not already existent. */
659 void InsertGlossary( SwTextBlocks
& rGlossary
, const String
& );
661 /** Make current selection glossary and insert into glossary document
663 sal_uInt16
MakeGlossary( SwTextBlocks
& rToFill
, const String
& rName
,
664 const String
& rShortName
, sal_Bool bSaveRelFile
= sal_False
,
665 const String
* pOnlyTxt
=0 );
667 /// Save complete content of doc as glossary.
668 sal_uInt16
SaveGlossaryDoc( SwTextBlocks
& rGlossary
, const String
& rName
,
669 const String
& rShortName
,
670 sal_Bool bSaveRelFile
= sal_False
,
671 sal_Bool bOnlyTxt
= sal_False
);
675 void HyphStart( SwDocPositions eStart
, SwDocPositions eEnde
);
677 /// restore selections.
679 com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
680 HyphContinue( sal_uInt16
* pPageCnt
, sal_uInt16
* pPageSt
);
684 /// For Inserting SoftHyphen. Position is offset within the syllabificated word.
685 void InsertSoftHyph( const xub_StrLen nHyphPos
);
687 const SwTable
& InsertTable( const SwInsertTableOptions
& rInsTblOpts
, ///< ALL_TBL_INS_ATTR
688 sal_uInt16 nRows
, sal_uInt16 nCols
,
689 sal_Int16 eAdj
= com::sun::star::text::HoriOrientation::FULL
,
690 const SwTableAutoFmt
* pTAFmt
= 0 );
692 void InsertDDETable( const SwInsertTableOptions
& rInsTblOpts
, ///< HEADLINE_NO_BORDER
693 SwDDEFieldType
* pDDEType
,
694 sal_uInt16 nRows
, sal_uInt16 nCols
,
695 sal_Int16 eAdj
= com::sun::star::text::HoriOrientation::FULL
);
698 void SetTableName( SwFrmFmt
& rTblFmt
, const String
&rNewName
);
700 SwFrmFmt
*GetTableFmt();
701 sal_Bool
TextToTable( const SwInsertTableOptions
& rInsTblOpts
, ///< ALL_TBL_INS_ATTR
703 sal_Int16 eAdj
= com::sun::star::text::HoriOrientation::FULL
,
704 const SwTableAutoFmt
* pTAFmt
= 0 );
705 sal_Bool
TableToText( sal_Unicode cCh
);
706 sal_Bool
IsTextToTableAvailable() const;
708 sal_Bool
GetTblBoxFormulaAttrs( SfxItemSet
& rSet
) const;
709 void SetTblBoxFormulaAttrs( const SfxItemSet
& rSet
);
711 sal_Bool
IsTableBoxTextFormat() const;
712 String
GetTableBoxText() const;
714 TblChgMode
GetTblChgMode() const;
715 void SetTblChgMode( TblChgMode eMode
);
717 /// Split table at cursor position.
718 sal_Bool
SplitTable( sal_uInt16 eMode
);
722 Can Merge checks if Prev or Next are possible.
723 If pointer pChkNxtPrv is passed possible direction is given. */
724 sal_Bool
CanMergeTable( sal_Bool bWithPrev
= sal_True
, sal_Bool
* pChkNxtPrv
= 0 ) const;
725 sal_Bool
MergeTable( sal_Bool bWithPrev
= sal_True
, sal_uInt16 nMode
= 0 );
727 /// Set up InsertDB as table Undo.
728 void AppendUndoForInsertFromDB( sal_Bool bIsTable
);
730 /// Functions used for spell checking and text conversion.
733 void SpellStart( SwDocPositions eStart
, SwDocPositions eEnde
,
734 SwDocPositions eCurr
, SwConversionArgs
*pConvArgs
= 0 );
736 /// Restore selections.
737 void SpellEnd( SwConversionArgs
*pConvArgs
= 0, bool bRestoreSelection
= true );
738 ::com::sun::star::uno::Any
SpellContinue(
739 sal_uInt16
* pPageCnt
, sal_uInt16
* pPageSt
,
740 SwConversionArgs
*pConvArgs
= 0 );
742 /** Spells on a sentence basis - the SpellPortions are needed
743 @return false if no error could be found. */
744 bool SpellSentence(::svx::SpellPortions
& rToFill
, bool bIsGrammarCheck
);
746 /// Make SpellIter start with the current sentence when called next time.
747 void PutSpellingToSentenceStart();
749 /// Moves the continuation position to the end of the currently checked sentence.
750 void MoveContinuationPosToEndOfCheckedSentence();
752 /// Applies a changed sentence.
753 void ApplyChangedSentence(const ::svx::SpellPortions
& rNewPortions
, bool bRecheck
);
755 /// Check SwSpellIter data to see if the last sentence got grammar checked.
756 bool HasLastSentenceGotGrammarChecked() const;
758 /// Is text conversion active somewhere else?
759 sal_Bool
HasConvIter() const;
761 /// Is hyphenation active somewhere else?
762 sal_Bool
HasHyphIter() const;
764 ::com::sun::star::uno::Reference
<
765 ::com::sun::star::linguistic2::XSpellAlternatives
>
766 GetCorrection( const Point
* pPt
, SwRect
& rSelectRect
);
769 bool GetGrammarCorrection( ::com::sun::star::linguistic2::ProofreadingResult
/*out*/ &rResult
,
770 sal_Int32
/*out*/ &rErrorPosInText
,
771 sal_Int32
/*out*/ &rErrorIndexInResult
,
772 ::com::sun::star::uno::Sequence
< OUString
> /*out*/ &rSuggestions
,
773 const Point
* pPt
, SwRect
& rSelectRect
);
775 void IgnoreGrammarErrorAt( SwPaM
& rErrorPosition
);
776 void SetLinguRange( SwDocPositions eStart
, SwDocPositions eEnde
);
778 /// @return reference set in document according to given name.
779 const SwFmtRefMark
* GetRefMark( const String
& rName
) const;
781 /** @return names of all references set in document.
782 If ArrayPointer == 0 then return only whether a RefMark is set in document. */
783 sal_uInt16
GetRefMarks( std::vector
<OUString
>* = 0 ) const;
786 void AutoCorrect( SvxAutoCorrect
& rACorr
, sal_Bool bInsertMode
= sal_True
,
787 sal_Unicode cChar
= ' ' );
788 sal_Bool
GetPrevAutoCorrWord( SvxAutoCorrect
& rACorr
, String
& rWord
);
790 /// Set our styles according to the respective rules.
791 void AutoFormat( const SvxSwAutoFmtFlags
* pAFlags
= 0 );
793 static SvxSwAutoFmtFlags
* GetAutoFmtFlags();
794 static void SetAutoFmtFlags(SvxSwAutoFmtFlags
*);
796 /// Calculates selection.
799 sal_Bool
InsertURL( const SwFmtINetFmt
& rFmt
, const String
& rStr
,
800 sal_Bool bKeepSelection
= sal_False
);
801 sal_uInt16
GetINetAttrs( SwGetINetAttrs
& rArr
);
803 String
GetDropTxt( const sal_uInt16 nChars
) const;
804 void ReplaceDropTxt( const String
&rStr
, SwPaM
* pPaM
= NULL
);
806 /** May an outline be moved or copied?
807 Check whether it's in text body, not in table, and not read-only (move). */
808 sal_Bool
IsOutlineMovable( sal_uInt16 nIdx
) const;
809 sal_Bool
IsOutlineCopyable( sal_uInt16 nIdx
) const;
811 sal_uInt16
GetLineCount( sal_Bool bActPos
= sal_True
);
813 /// Query and set footnote-text/number. Set.. to current SSelection!
814 sal_Bool
GetCurFtn( SwFmtFtn
* pToFillFtn
= 0 );
815 bool SetCurFtn( const SwFmtFtn
& rFillFtn
);
816 bool HasFtns( bool bEndNotes
= false ) const;
818 sal_uInt16
GetSeqFtnList( SwSeqFldList
& rList
, bool bEndNotes
= false );
819 /// @return list of all footnotes and their first portions of text.
821 SwSection
const* InsertSection(
822 SwSectionData
& rNewData
, SfxItemSet
const*const = 0 );
823 sal_Bool
IsInsRegionAvailable() const;
824 const SwSection
* GetCurrSection() const;
826 /** @return current range like Cet CurrSection(). But this function iterates
827 also over frames and catches the range even if the cursor is positioned in
828 a footnote the reference of which is in a columned range.
829 If bOutOfTab is set, the range comprising the table is searched
830 and not an inner one. */
831 const SwSection
* GetAnySection( sal_Bool bOutOfTab
= sal_False
, const Point
* pPt
= 0 ) const;
833 sal_uInt16
GetSectionFmtCount() const;
834 sal_uInt16
GetSectionFmtPos( const SwSectionFmt
& ) const;
835 const SwSectionFmt
& GetSectionFmt(sal_uInt16 nFmt
) const;
836 void DelSectionFmt( sal_uInt16 nFmt
);
837 void UpdateSection(sal_uInt16
const nSect
, SwSectionData
&,
838 SfxItemSet
const*const = 0);
839 sal_Bool
IsAnySectionInDoc( sal_Bool bChkReadOnly
= sal_False
,
840 sal_Bool bChkHidden
= sal_False
,
841 sal_Bool BChkTOX
= sal_False
) const;
843 String
GetUniqueSectionName( const String
* pChkStr
= 0 ) const;
846 void SetSectionAttr(const SfxItemSet
& rSet
, SwSectionFmt
* pSectFmt
= 0);
848 /** Search inside the cursor selection for full selected sections.
849 if any part of section in the selection @return 0.
850 if more than one in the selection return the count. */
851 sal_uInt16
GetFullSelectedSectionCount() const;
853 /** Special insert: Insert a new text node just before or after a section or
854 table, if the cursor is positioned at the start/end of said
855 section/table. The purpose of the method is to allow users to inert text
856 at certain 'impossible' position, e.g. before a table at the document
857 start or between to sections. */
858 bool DoSpecialInsert();
859 bool CanSpecialInsert() const;
862 void SetNewDoc(sal_Bool bNew
= sal_True
);
864 sfx2::LinkManager
& GetLinkManager();
865 inline const sfx2::LinkManager
& GetLinkManager() const;
867 /** Adjust left margin via object bar (similar to adjustment of numerations).
868 One can either change the margin "by" adding or substracting a given
869 offset or set it "to" this position @param (bModulus = true). */
870 bool IsMoveLeftMargin( bool bRight
= true, bool bModulus
= true ) const;
871 void MoveLeftMargin( bool bRight
= true, bool bModulus
= true );
873 /// Query NumberFormater from document.
874 SvNumberFormatter
* GetNumberFormatter();
875 const SvNumberFormatter
* GetNumberFormatter() const
876 { return ((SwEditShell
*)this)->GetNumberFormatter(); }
878 /// Interfaces for GlobalDocument.
879 sal_Bool
IsGlobalDoc() const;
880 void SetGlblDocSaveLinks( sal_Bool bFlag
= sal_True
);
881 sal_Bool
IsGlblDocSaveLinks() const;
882 sal_uInt16
GetGlobalDocContent( SwGlblDocContents
& rArr
) const;
883 sal_Bool
InsertGlobalDocContent( const SwGlblDocContent
& rPos
,
884 SwSectionData
& rNew
);
885 sal_Bool
InsertGlobalDocContent( const SwGlblDocContent
& rPos
,
886 const SwTOXBase
& rTOX
);
887 sal_Bool
InsertGlobalDocContent( const SwGlblDocContent
& rPos
);
888 sal_Bool
DeleteGlobalDocContent( const SwGlblDocContents
& rArr
,
890 sal_Bool
MoveGlobalDocContent( const SwGlblDocContents
& rArr
,
891 sal_uInt16 nFromPos
, sal_uInt16 nToPos
,
892 sal_uInt16 nNewPos
);
893 sal_Bool
GotoGlobalDocContent( const SwGlblDocContent
& rPos
);
896 sal_uInt16
GetRedlineMode() const;
897 void SetRedlineMode( sal_uInt16 eMode
);
898 sal_Bool
IsRedlineOn() const;
899 sal_uInt16
GetRedlineCount() const;
900 const SwRedline
& GetRedline( sal_uInt16 nPos
) const;
901 sal_Bool
AcceptRedline( sal_uInt16 nPos
);
902 sal_Bool
RejectRedline( sal_uInt16 nPos
);
905 /** Search Redline for this Data and @return position in array.
906 If not found, return USHRT_MAX. */
907 sal_uInt16
FindRedlineOfData( const SwRedlineData
& ) const;
910 /// Set comment to Redline at position.
911 sal_Bool
SetRedlineComment( const String
& rS
);
912 const SwRedline
* GetCurrRedline() const;
914 /// Redline attributes have been changed. Updated views.
915 void UpdateRedlineAttr();
917 /// Compare two documents.
918 long CompareDoc( const SwDoc
& rDoc
);
920 /// Merge two documents.
921 long MergeDoc( const SwDoc
& rDoc
);
923 /// Footnote attributes global to document.
924 const SwFtnInfo
& GetFtnInfo() const;
925 void SetFtnInfo(const SwFtnInfo
& rInfo
);
926 const SwEndNoteInfo
& GetEndNoteInfo() const;
927 void SetEndNoteInfo(const SwEndNoteInfo
& rInfo
);
929 const SwLineNumberInfo
&GetLineNumberInfo() const;
930 void SetLineNumberInfo( const SwLineNumberInfo
& rInfo
);
932 /// Labels: Synchronize ranges.
933 void SetLabelDoc( sal_Bool bFlag
= sal_True
);
934 sal_Bool
IsLabelDoc() const;
936 /// Interface for TextInputData - (for input of Japanese/Chinese chars.)
937 SwExtTextInput
* CreateExtTextInput(LanguageType eInputLanguage
);
938 String
DeleteExtTextInput( SwExtTextInput
* pDel
= 0, sal_Bool bInsText
= sal_True
);
939 void SetExtTextInputData( const CommandExtTextInputData
& );
941 /// Interface for access to AutoComplete-list.
942 static SwAutoCompleteWord
& GetAutoCompleteWords();
944 /** @return a scaling factor of selected text. Used for the rotated
945 character attribut dialog. */
946 sal_uInt16
GetScalingOfSelectedText() const;
949 SwEditShell( SwDoc
&, Window
*, const SwViewOption
*pOpt
= 0 );
951 /// Copy-Constructor in disguise.
952 SwEditShell( SwEditShell
&, Window
* );
953 virtual ~SwEditShell();
956 /// For METWARE: no copying and no assignment.
957 SwEditShell(const SwEditShell
&);
958 const SwEditShell
&operator=(const SwEditShell
&);
961 inline const sfx2::LinkManager
& SwEditShell::GetLinkManager() const
962 { return ((SwEditShell
*)this)->GetLinkManager(); }
964 /// Class for automated call of Start- and EndAction().
968 SwActContext(SwEditShell
*pShell
);
972 /// Class for automated call of Start- and EndCrsrMove().
976 SwMvContext(SwEditShell
*pShell
);
983 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */