1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: edws.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
37 #include <vcl/window.hxx>
42 #include <acorrect.hxx>
43 #include <swtable.hxx>
46 #include <SwRewriter.hxx>
48 /********************************************************
50 ********************************************************/
51 // verkleideter Copy-Constructor
54 SwEditShell::SwEditShell( SwEditShell
& rEdSH
, Window
*pWindow
)
55 : SwCrsrShell( rEdSH
, pWindow
)
62 SwEditShell::SwEditShell( SwDoc
& rDoc
, Window
*pWindow
, const SwViewOption
*pOptions
)
63 : SwCrsrShell( rDoc
, pWindow
, pOptions
)
65 GetDoc()->DoUndo(true);
69 SwEditShell::~SwEditShell() // USED
73 /******************************************************************************
74 * sal_Bool SwEditShell::IsModified() const
75 ******************************************************************************/
78 sal_Bool
SwEditShell::IsModified() const
80 return GetDoc()->IsModified();
82 /******************************************************************************
83 * void SwEditShell::SetModified()
84 ******************************************************************************/
87 void SwEditShell::SetModified()
89 GetDoc()->SetModified();
91 /******************************************************************************
92 * void SwEditShell::ResetModified()
93 ******************************************************************************/
96 void SwEditShell::ResetModified()
98 GetDoc()->ResetModified();
101 void SwEditShell::SetUndoNoResetModified()
103 GetDoc()->SetModified();
104 GetDoc()->SetUndoNoResetModified();
107 /******************************************************************************
108 * void SwEditShell::StartAllAction()
109 ******************************************************************************/
112 void SwEditShell::StartAllAction()
114 ViewShell
*pSh
= this;
116 if( pSh
->IsA( TYPE( SwEditShell
) ) )
117 ((SwEditShell
*)pSh
)->StartAction();
120 pSh
= (ViewShell
*)pSh
->GetNext();
121 } while(pSh
!= this);
123 /******************************************************************************
124 * void SwEditShell::EndAllAction()
125 ******************************************************************************/
128 void SwEditShell::EndAllAction()
130 ViewShell
*pSh
= this;
132 if( pSh
->IsA( TYPE( SwEditShell
) ) )
133 ((SwEditShell
*)pSh
)->EndAction();
136 pSh
= (ViewShell
*)pSh
->GetNext();
137 } while(pSh
!= this);
140 /******************************************************************************
141 * void SwEditShell::CalcLayout()
142 ******************************************************************************/
145 void SwEditShell::CalcLayout()
148 ViewShell::CalcLayout();
150 ViewShell
*pSh
= this;
154 pSh
->GetWin()->Invalidate();
155 pSh
= (ViewShell
*)pSh
->GetNext();
157 } while ( pSh
!= this );
162 /******************************************************************************
163 * Inhaltsform bestimmen, holen
164 ******************************************************************************/
165 // OPT: wird fuer jedes Attribut gerufen?
168 sal_uInt16
SwEditShell::GetCntType() const
170 // nur noch am SPoint ist der Inhalt interessant
175 switch( GetCrsr()->GetNode()->GetNodeType() )
177 case ND_TEXTNODE
: nRet
= CNT_TXT
; break;
178 case ND_GRFNODE
: nRet
= CNT_GRF
; break;
179 case ND_OLENODE
: nRet
= CNT_OLE
; break;
182 ASSERT( nRet
, ERR_OUTOFSCOPE
);
186 //------------------------------------------------------------------------------
189 sal_Bool
SwEditShell::HasOtherCnt() const
192 if ( GetDoc()->GetSpzFrmFmts()->Count() )
195 const SwNodes
&rNds
= GetDoc()->GetNodes();
198 pNd
= &rNds
.GetEndOfInserts();
199 if ( 1 != (pNd
->GetIndex() - pNd
->StartOfSectionIndex()) )
202 pNd
= &rNds
.GetEndOfAutotext();
203 if ( 1 != (pNd
->GetIndex() - pNd
->StartOfSectionIndex()) )
209 /******************************************************************************
210 * Zugriffsfunktionen fuer Filename-Behandlung
211 ******************************************************************************/
214 SwActKontext::SwActKontext(SwEditShell
*pShell
)
221 SwActKontext::~SwActKontext()
226 /******************************************************************************
227 * Klasse fuer den automatisierten Aufruf von Start- und
229 ******************************************************************************/
232 SwMvKontext::SwMvKontext(SwEditShell
*pShell
) : pSh(pShell
)
238 SwMvKontext::~SwMvKontext()
244 SwFrmFmt
*SwEditShell::GetTableFmt() // OPT: schnellster Test auf Tabelle?
246 const SwTableNode
* pTblNd
= IsCrsrInTbl();
247 return pTblNd
? (SwFrmFmt
*)pTblNd
->GetTable().GetFrmFmt() : 0;
250 // OPT: wieso 3x beim neuen Dokument
253 sal_uInt16
SwEditShell::GetTOXTypeCount(TOXTypes eTyp
) const
255 return pDoc
->GetTOXTypeCount(eTyp
);
259 void SwEditShell::InsertTOXType(const SwTOXType
& rTyp
)
261 pDoc
->InsertTOXType(rTyp
);
266 void SwEditShell::DoUndo( sal_Bool bOn
)
267 { GetDoc()->DoUndo( bOn
); }
270 sal_Bool
SwEditShell::DoesUndo() const
271 { return GetDoc()->DoesUndo(); }
274 void SwEditShell::DoGroupUndo( sal_Bool bOn
)
275 { GetDoc()->DoGroupUndo( bOn
); }
278 sal_Bool
SwEditShell::DoesGroupUndo() const
279 { return GetDoc()->DoesGroupUndo(); }
282 void SwEditShell::DelAllUndoObj()
284 GetDoc()->DelAllUndoObj();
287 // Zusammenfassen von Kontinuierlichen Insert/Delete/Overwrite von
288 // Charaktern. Default ist sdbcx::Group-Undo.
290 // setzt Undoklammerung auf, liefert nUndoId der Klammerung
293 SwUndoId
SwEditShell::StartUndo( SwUndoId eUndoId
,
294 const SwRewriter
*pRewriter
)
295 { return GetDoc()->StartUndo( eUndoId
, pRewriter
); }
297 // schliesst Klammerung der nUndoId, nicht vom UI benutzt
300 SwUndoId
SwEditShell::EndUndo(SwUndoId eUndoId
,
301 const SwRewriter
*pRewriter
)
302 { return GetDoc()->EndUndo(eUndoId
, pRewriter
); }
304 // liefert die Id der letzten undofaehigen Aktion zurueck
305 // fuellt ggf. VARARR mit sdbcx::User-UndoIds
308 SwUndoId
SwEditShell::GetUndoIds(String
* pStr
,SwUndoIds
*pUndoIds
) const
309 { return GetDoc()->GetUndoIds(pStr
,pUndoIds
); }
311 String
SwEditShell::GetUndoIdsStr(String
* pStr
,SwUndoIds
*pUndoIds
) const
312 { return GetDoc()->GetUndoIdsStr(pStr
,pUndoIds
); }
314 // liefert die Id der letzten Redofaehigen Aktion zurueck
315 // fuellt ggf. VARARR mit RedoIds
318 SwUndoId
SwEditShell::GetRedoIds(String
* pStr
,SwUndoIds
*pRedoIds
) const
319 { return GetDoc()->GetRedoIds(pStr
,pRedoIds
); }
321 String
SwEditShell::GetRedoIdsStr(String
* pStr
,SwUndoIds
*pRedoIds
) const
322 { return GetDoc()->GetRedoIdsStr(pStr
,pRedoIds
); }
324 // liefert die Id der letzten Repeatfaehigen Aktion zurueck
325 // fuellt ggf. VARARR mit RedoIds
328 SwUndoId
SwEditShell::GetRepeatIds(String
* pStr
, SwUndoIds
*pRedoIds
) const
329 { return GetDoc()->GetRepeatIds(pStr
,pRedoIds
); }
331 String
SwEditShell::GetRepeatIdsStr(String
* pStr
, SwUndoIds
*pRedoIds
) const
332 { return GetDoc()->GetRepeatIdsStr(pStr
,pRedoIds
); }
336 // AutoKorrektur - JP 27.01.94
337 void SwEditShell::AutoCorrect( SvxAutoCorrect
& rACorr
, sal_Bool bInsert
,
340 SET_CURR_SHELL( this );
344 SwPaM
* pCrsr
= getShellCrsr( true );
345 SwTxtNode
* pTNd
= pCrsr
->GetNode()->GetTxtNode();
347 SwAutoCorrDoc
aSwAutoCorrDoc( *this, *pCrsr
, cChar
);
348 rACorr
.AutoCorrect( aSwAutoCorrDoc
,
349 pTNd
->GetTxt(), pCrsr
->GetPoint()->nContent
.GetIndex(),
350 cChar
, bInsert
, GetWin() );
352 SaveTblBoxCntnt( pCrsr
->GetPoint() );
357 void SwEditShell::SetNewDoc(sal_Bool bNew
)
359 GetDoc()->SetNewDoc(bNew
);
363 sal_Bool
SwEditShell::GetPrevAutoCorrWord( SvxAutoCorrect
& rACorr
, String
& rWord
)
365 SET_CURR_SHELL( this );
368 SwPaM
* pCrsr
= getShellCrsr( true );
369 xub_StrLen nPos
= pCrsr
->GetPoint()->nContent
.GetIndex();
370 SwTxtNode
* pTNd
= pCrsr
->GetNode()->GetTxtNode();
373 SwAutoCorrDoc
aSwAutoCorrDoc( *this, *pCrsr
, 0 );
374 bRet
= rACorr
.GetPrevAutoCorrWord( aSwAutoCorrDoc
,
375 pTNd
->GetTxt(), nPos
, rWord
);
382 SwAutoCompleteWord
& SwEditShell::GetAutoCompleteWords()
384 return SwDoc::GetAutoCompleteWords();