2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#include <vcl/window.hxx>
|
2010-11-25 14:31:08 +01:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <editsh.hxx>
|
|
|
|
#include <doc.hxx>
|
2010-11-25 14:31:08 +01:00
|
|
|
#include <IDocumentUndoRedo.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <pam.hxx>
|
|
|
|
#include <docary.hxx>
|
|
|
|
#include <acorrect.hxx>
|
|
|
|
#include <swtable.hxx>
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
#include <swundo.hxx>
|
2004-05-18 13:03:33 +00:00
|
|
|
#include <SwRewriter.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
// masqueraded copy constructor
|
2007-09-27 07:47:16 +00:00
|
|
|
SwEditShell::SwEditShell( SwEditShell& rEdSH, Window *pWindow )
|
|
|
|
: SwCrsrShell( rEdSH, pWindow )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-09-27 07:47:16 +00:00
|
|
|
SwEditShell::SwEditShell( SwDoc& rDoc, Window *pWindow, const SwViewOption *pOptions )
|
|
|
|
: SwCrsrShell( rDoc, pWindow, pOptions )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-11-25 14:31:08 +01:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().DoUndo(true);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwEditShell::~SwEditShell() // USED
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SwEditShell::IsModified() const
|
|
|
|
{
|
|
|
|
return GetDoc()->IsModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::SetModified()
|
|
|
|
{
|
|
|
|
GetDoc()->SetModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::ResetModified()
|
|
|
|
{
|
|
|
|
GetDoc()->ResetModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::SetUndoNoResetModified()
|
|
|
|
{
|
|
|
|
GetDoc()->SetModified();
|
2010-11-25 14:31:08 +01:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().SetUndoNoResetModified();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::StartAllAction()
|
|
|
|
{
|
2013-10-26 19:50:13 +02:00
|
|
|
SwViewShell *pSh = this;
|
2000-09-18 23:08:29 +00:00
|
|
|
do {
|
|
|
|
if( pSh->IsA( TYPE( SwEditShell ) ) )
|
|
|
|
((SwEditShell*)pSh)->StartAction();
|
|
|
|
else
|
|
|
|
pSh->StartAction();
|
2013-10-26 19:50:13 +02:00
|
|
|
pSh = (SwViewShell *)pSh->GetNext();
|
2000-09-18 23:08:29 +00:00
|
|
|
} while(pSh != this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::EndAllAction()
|
|
|
|
{
|
2013-10-26 19:50:13 +02:00
|
|
|
SwViewShell *pSh = this;
|
2000-09-18 23:08:29 +00:00
|
|
|
do {
|
|
|
|
if( pSh->IsA( TYPE( SwEditShell ) ) )
|
|
|
|
((SwEditShell*)pSh)->EndAction();
|
|
|
|
else
|
|
|
|
pSh->EndAction();
|
2013-10-26 19:50:13 +02:00
|
|
|
pSh = (SwViewShell *)pSh->GetNext();
|
2000-09-18 23:08:29 +00:00
|
|
|
} while(pSh != this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::CalcLayout()
|
|
|
|
{
|
|
|
|
StartAllAction();
|
2013-10-26 19:50:13 +02:00
|
|
|
SwViewShell::CalcLayout();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-10-26 19:50:13 +02:00
|
|
|
SwViewShell *pSh = this;
|
2000-09-18 23:08:29 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( pSh->GetWin() )
|
|
|
|
pSh->GetWin()->Invalidate();
|
2013-10-26 19:50:13 +02:00
|
|
|
pSh = (SwViewShell*)pSh->GetNext();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
} while ( pSh != this );
|
|
|
|
|
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
/** Get the content type of a shell
|
|
|
|
*
|
|
|
|
* @todo Is this called for every attribute?
|
|
|
|
*/
|
2000-09-18 23:08:29 +00:00
|
|
|
sal_uInt16 SwEditShell::GetCntType() const
|
|
|
|
{
|
|
|
|
sal_uInt16 nRet = 0;
|
|
|
|
if( IsTableMode() )
|
|
|
|
nRet = CNT_TXT;
|
|
|
|
else
|
|
|
|
switch( GetCrsr()->GetNode()->GetNodeType() )
|
|
|
|
{
|
|
|
|
case ND_TEXTNODE: nRet = CNT_TXT; break;
|
|
|
|
case ND_GRFNODE: nRet = CNT_GRF; break;
|
|
|
|
case ND_OLENODE: nRet = CNT_OLE; break;
|
|
|
|
}
|
|
|
|
|
2011-02-20 17:58:46 +01:00
|
|
|
OSL_ASSERT( nRet );
|
2000-09-18 23:08:29 +00:00
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SwEditShell::HasOtherCnt() const
|
2008-02-19 12:42:17 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-06-20 16:36:51 +02:00
|
|
|
if ( !GetDoc()->GetSpzFrmFmts()->empty() )
|
2009-08-27 15:54:55 +00:00
|
|
|
return sal_True;
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwNodes &rNds = GetDoc()->GetNodes();
|
|
|
|
const SwNode *pNd;
|
2009-08-27 15:54:55 +00:00
|
|
|
|
|
|
|
pNd = &rNds.GetEndOfInserts();
|
|
|
|
if ( 1 != (pNd->GetIndex() - pNd->StartOfSectionIndex()) )
|
|
|
|
return sal_True;
|
|
|
|
|
|
|
|
pNd = &rNds.GetEndOfAutotext();
|
|
|
|
if ( 1 != (pNd->GetIndex() - pNd->StartOfSectionIndex()) )
|
|
|
|
return sal_True;
|
|
|
|
|
|
|
|
return sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
// access controll functions for file name handling
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-09-02 16:05:21 +04:00
|
|
|
SwActContext::SwActContext(SwEditShell *pShell)
|
2000-09-18 23:08:29 +00:00
|
|
|
: pSh(pShell)
|
|
|
|
{
|
|
|
|
pSh->StartAction();
|
|
|
|
}
|
|
|
|
|
2012-09-02 16:05:21 +04:00
|
|
|
SwActContext::~SwActContext()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
pSh->EndAction();
|
|
|
|
}
|
|
|
|
|
2012-09-02 16:05:21 +04:00
|
|
|
SwMvContext::SwMvContext(SwEditShell *pShell)
|
|
|
|
: pSh(pShell)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
pSh->SttCrsrMove();
|
|
|
|
}
|
|
|
|
|
2012-09-02 16:05:21 +04:00
|
|
|
SwMvContext::~SwMvContext()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
pSh->EndCrsrMove();
|
|
|
|
}
|
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
SwFrmFmt *SwEditShell::GetTableFmt() // fastest test on a table
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwTableNode* pTblNd = IsCrsrInTbl();
|
|
|
|
return pTblNd ? (SwFrmFmt*)pTblNd->GetTable().GetFrmFmt() : 0;
|
|
|
|
}
|
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
// TODO: Why is this called 3x for a new document?
|
2000-09-18 23:08:29 +00:00
|
|
|
sal_uInt16 SwEditShell::GetTOXTypeCount(TOXTypes eTyp) const
|
|
|
|
{
|
2013-02-23 12:33:14 +01:00
|
|
|
return mpDoc->GetTOXTypeCount(eTyp);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::InsertTOXType(const SwTOXType& rTyp)
|
|
|
|
{
|
2013-02-23 12:33:14 +01:00
|
|
|
mpDoc->InsertTOXType(rTyp);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::DoUndo( sal_Bool bOn )
|
2010-11-25 14:31:08 +01:00
|
|
|
{ GetDoc()->GetIDocumentUndoRedo().DoUndo( bOn ); }
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
sal_Bool SwEditShell::DoesUndo() const
|
2010-11-25 14:31:08 +01:00
|
|
|
{ return GetDoc()->GetIDocumentUndoRedo().DoesUndo(); }
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SwEditShell::DoGroupUndo( sal_Bool bOn )
|
2010-11-25 14:31:08 +01:00
|
|
|
{ GetDoc()->GetIDocumentUndoRedo().DoGroupUndo( bOn ); }
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
sal_Bool SwEditShell::DoesGroupUndo() const
|
2010-11-25 14:31:08 +01:00
|
|
|
{ return GetDoc()->GetIDocumentUndoRedo().DoesGroupUndo(); }
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SwEditShell::DelAllUndoObj()
|
|
|
|
{
|
2010-11-25 14:31:08 +01:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
// Combine continuous calls of Insert/Delete/Overwrite on characters. Default: sdbcx::Group-Undo.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
/** open undo container
|
|
|
|
*
|
|
|
|
* @return nUndoId ID of the container
|
|
|
|
*/
|
2007-09-27 07:47:16 +00:00
|
|
|
SwUndoId SwEditShell::StartUndo( SwUndoId eUndoId,
|
2004-05-18 13:03:33 +00:00
|
|
|
const SwRewriter *pRewriter )
|
2010-11-25 14:31:08 +01:00
|
|
|
{ return GetDoc()->GetIDocumentUndoRedo().StartUndo( eUndoId, pRewriter ); }
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
/** close undo container
|
|
|
|
*
|
|
|
|
* not used by UI
|
|
|
|
*
|
|
|
|
* @param eUndoId ID of the undo container
|
|
|
|
* @param pRewriter ?
|
|
|
|
*/
|
2013-06-09 00:46:42 +02:00
|
|
|
SwUndoId SwEditShell::EndUndo(SwUndoId eUndoId, const SwRewriter *pRewriter)
|
2010-11-25 14:31:08 +01:00
|
|
|
{ return GetDoc()->GetIDocumentUndoRedo().EndUndo(eUndoId, pRewriter); }
|
2004-05-18 13:03:33 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
bool SwEditShell::GetLastUndoInfo(OUString *const o_pStr,
|
2010-12-15 09:14:08 +01:00
|
|
|
SwUndoId *const o_pId) const
|
|
|
|
{ return GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(o_pStr, o_pId); }
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
bool SwEditShell::GetFirstRedoInfo(OUString *const o_pStr) const
|
2010-12-15 09:14:02 +01:00
|
|
|
{ return GetDoc()->GetIDocumentUndoRedo().GetFirstRedoInfo(o_pStr); }
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
SwUndoId SwEditShell::GetRepeatInfo(OUString *const o_pStr) const
|
2010-12-15 09:14:02 +01:00
|
|
|
{ return GetDoc()->GetIDocumentUndoRedo().GetRepeatInfo(o_pStr); }
|
2004-05-18 13:03:33 +00:00
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
/** Auto correction */
|
2000-09-18 23:08:29 +00:00
|
|
|
void SwEditShell::AutoCorrect( SvxAutoCorrect& rACorr, sal_Bool bInsert,
|
|
|
|
sal_Unicode cChar )
|
|
|
|
{
|
|
|
|
SET_CURR_SHELL( this );
|
|
|
|
|
|
|
|
StartAllAction();
|
|
|
|
|
2007-11-22 14:34:01 +00:00
|
|
|
SwPaM* pCrsr = getShellCrsr( true );
|
2000-09-18 23:08:29 +00:00
|
|
|
SwTxtNode* pTNd = pCrsr->GetNode()->GetTxtNode();
|
|
|
|
|
|
|
|
SwAutoCorrDoc aSwAutoCorrDoc( *this, *pCrsr, cChar );
|
2013-06-06 20:51:05 +02:00
|
|
|
// FIXME: this _must_ be called with reference to the actual node text!
|
2013-09-18 13:51:35 +01:00
|
|
|
OUString const& rNodeText(pTNd->GetTxt());
|
2013-06-06 20:51:05 +02:00
|
|
|
rACorr.DoAutoCorrect( aSwAutoCorrDoc,
|
|
|
|
rNodeText, pCrsr->GetPoint()->nContent.GetIndex(),
|
2010-09-29 16:13:16 -04:00
|
|
|
cChar, bInsert, GetWin() );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( cChar )
|
|
|
|
SaveTblBoxCntnt( pCrsr->GetPoint() );
|
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::SetNewDoc(sal_Bool bNew)
|
|
|
|
{
|
|
|
|
GetDoc()->SetNewDoc(bNew);
|
|
|
|
}
|
|
|
|
|
2013-09-20 08:17:02 +02:00
|
|
|
sal_Bool SwEditShell::GetPrevAutoCorrWord( SvxAutoCorrect& rACorr, OUString& rWord )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SET_CURR_SHELL( this );
|
|
|
|
|
|
|
|
sal_Bool bRet;
|
2007-11-22 14:34:01 +00:00
|
|
|
SwPaM* pCrsr = getShellCrsr( true );
|
2013-11-12 00:46:22 +01:00
|
|
|
const sal_Int32 nPos = pCrsr->GetPoint()->nContent.GetIndex();
|
2000-09-18 23:08:29 +00:00
|
|
|
SwTxtNode* pTNd = pCrsr->GetNode()->GetTxtNode();
|
|
|
|
if( pTNd && nPos )
|
|
|
|
{
|
|
|
|
SwAutoCorrDoc aSwAutoCorrDoc( *this, *pCrsr, 0 );
|
|
|
|
bRet = rACorr.GetPrevAutoCorrWord( aSwAutoCorrDoc,
|
|
|
|
pTNd->GetTxt(), nPos, rWord );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bRet = sal_False;
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwAutoCompleteWord& SwEditShell::GetAutoCompleteWords()
|
|
|
|
{
|
|
|
|
return SwDoc::GetAutoCompleteWords();
|
|
|
|
}
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|