(cherry picked from commit c2afeb1c3f11e8f420b59f3786eb8626c99ff595) Conflicts: sw/inc/IDocumentContentOperations.hxx sw/inc/crsrsh.hxx sw/inc/doc.hxx sw/inc/editsh.hxx sw/inc/expfld.hxx sw/inc/fldbas.hxx sw/inc/fmtfld.hxx sw/inc/hintids.hxx sw/inc/ndtxt.hxx sw/inc/txatbase.hxx sw/inc/txtfld.hxx sw/inc/txtrfmrk.hxx sw/inc/txttxmrk.hxx sw/inc/viscrs.hxx sw/source/core/bastyp/init.cxx sw/source/core/crsr/crsrsh.cxx sw/source/core/crsr/crstrvl.cxx sw/source/core/crsr/findattr.cxx sw/source/core/crsr/findtxt.cxx sw/source/core/crsr/swcrsr.cxx sw/source/core/crsr/viscrs.cxx sw/source/core/doc/dbgoutsw.cxx sw/source/core/doc/doc.cxx sw/source/core/doc/docfld.cxx sw/source/core/doc/docfmt.cxx sw/source/core/doc/docnum.cxx sw/source/core/doc/docredln.cxx sw/source/core/doc/docruby.cxx sw/source/core/doc/doctxm.cxx sw/source/core/doc/visiturl.cxx sw/source/core/docnode/nodes.cxx sw/source/core/edit/edatmisc.cxx sw/source/core/edit/edattr.cxx sw/source/core/edit/edfld.cxx sw/source/core/edit/edfldexp.cxx sw/source/core/edit/editsh.cxx sw/source/core/edit/edlingu.cxx sw/source/core/edit/ednumber.cxx sw/source/core/fields/expfld.cxx sw/source/core/fields/fldbas.cxx sw/source/core/fields/reffld.cxx sw/source/core/frmedt/fefly1.cxx sw/source/core/inc/docfld.hxx sw/source/core/inc/rolbck.hxx sw/source/core/inc/swfont.hxx sw/source/core/layout/flycnt.cxx sw/source/core/layout/laycache.cxx sw/source/core/layout/trvlfrm.cxx sw/source/core/text/atrhndl.hxx sw/source/core/text/atrstck.cxx sw/source/core/text/inftxt.cxx sw/source/core/text/porfld.cxx sw/source/core/text/porfld.hxx sw/source/core/text/txtfld.cxx sw/source/core/tox/tox.cxx sw/source/core/tox/txmsrt.cxx sw/source/core/txtnode/atrfld.cxx sw/source/core/txtnode/ndhints.cxx sw/source/core/txtnode/ndtxt.cxx sw/source/core/txtnode/thints.cxx sw/source/core/txtnode/txatbase.cxx sw/source/core/txtnode/txatritr.cxx sw/source/core/txtnode/txtedt.cxx sw/source/core/undo/SwUndoField.cxx sw/source/core/undo/rolbck.cxx sw/source/core/undo/unsect.cxx sw/source/core/undo/untbl.cxx sw/source/core/unocore/unocrsrhelper.cxx sw/source/core/unocore/unofield.cxx sw/source/core/unocore/unoframe.cxx sw/source/core/unocore/unorefmk.cxx sw/source/core/view/vprint.cxx sw/source/filter/ascii/ascatr.cxx sw/source/filter/html/htmlatr.cxx sw/source/filter/rtf/rtffly.cxx sw/source/filter/ww1/fltshell.cxx sw/source/filter/ww1/w1filter.cxx sw/source/filter/ww8/wrtw8esh.cxx sw/source/filter/ww8/wrtw8nds.cxx sw/source/filter/ww8/ww8atr.cxx sw/source/filter/ww8/ww8par.cxx sw/source/filter/ww8/ww8par3.cxx sw/source/filter/ww8/ww8par5.cxx sw/source/ui/app/applab.cxx sw/source/ui/docvw/edtwin.cxx sw/source/ui/docvw/edtwin2.cxx sw/source/ui/envelp/envfmt.cxx sw/source/ui/fldui/fldedt.cxx sw/source/ui/fldui/fldmgr.cxx sw/source/ui/inc/wrtsh.hxx sw/source/ui/lingu/hhcwrp.cxx sw/source/ui/shells/basesh.cxx sw/source/ui/shells/drwtxtex.cxx sw/source/ui/shells/grfsh.cxx sw/source/ui/shells/tabsh.cxx sw/source/ui/shells/textfld.cxx sw/source/ui/shells/textidx.cxx sw/source/ui/shells/textsh.cxx sw/source/ui/shells/textsh1.cxx sw/source/ui/shells/txtattr.cxx sw/source/ui/uiview/formatclipboard.cxx sw/source/ui/uiview/view.cxx sw/source/ui/uiview/view2.cxx sw/source/ui/uiview/viewsrch.cxx sw/source/ui/uiview/viewstat.cxx sw/source/ui/uiview/viewtab.cxx sw/source/ui/wrtsh/wrtsh1.cxx sw/source/ui/wrtsh/wrtsh2.cxx Change-Id: I6758d6719e1fd523797cc6ee2648ffcb47d52595
521 lines
16 KiB
C++
521 lines
16 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* 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 .
|
|
*/
|
|
|
|
#include <hintids.hxx>
|
|
|
|
#include <svx/svxids.hrc>
|
|
#include <editeng/langitem.hxx>
|
|
#include <fmtinfmt.hxx>
|
|
#include <txtatr.hxx>
|
|
#include <txtinet.hxx>
|
|
#include <editsh.hxx>
|
|
#include <doc.hxx>
|
|
#include <pam.hxx>
|
|
#include <ndtxt.hxx>
|
|
#include <acorrect.hxx>
|
|
#include <shellio.hxx>
|
|
#include <swundo.hxx>
|
|
#include <viscrs.hxx>
|
|
|
|
#include <editeng/acorrcfg.hxx>
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
class _PaMIntoCrsrShellRing
|
|
{
|
|
SwCrsrShell& rSh;
|
|
SwPaM &rDelPam, &rCrsr;
|
|
Ring *pPrevDelPam, *pPrevCrsr;
|
|
|
|
void RemoveFromRing( SwPaM& rPam, Ring* pPrev );
|
|
public:
|
|
_PaMIntoCrsrShellRing( SwCrsrShell& rSh, SwPaM& rCrsr, SwPaM& rPam );
|
|
~_PaMIntoCrsrShellRing();
|
|
};
|
|
|
|
_PaMIntoCrsrShellRing::_PaMIntoCrsrShellRing( SwCrsrShell& rCSh,
|
|
SwPaM& rShCrsr, SwPaM& rPam )
|
|
: rSh( rCSh ), rDelPam( rPam ), rCrsr( rShCrsr )
|
|
{
|
|
SwPaM* pShCrsr = rSh._GetCrsr();
|
|
|
|
pPrevDelPam = rDelPam.GetPrev();
|
|
pPrevCrsr = rCrsr.GetPrev();
|
|
|
|
rDelPam.MoveRingTo( pShCrsr );
|
|
rCrsr.MoveRingTo( pShCrsr );
|
|
}
|
|
|
|
_PaMIntoCrsrShellRing::~_PaMIntoCrsrShellRing()
|
|
{
|
|
// and take out the Pam again:
|
|
RemoveFromRing( rDelPam, pPrevDelPam );
|
|
RemoveFromRing( rCrsr, pPrevCrsr );
|
|
}
|
|
|
|
void _PaMIntoCrsrShellRing::RemoveFromRing( SwPaM& rPam, Ring* pPrev )
|
|
{
|
|
Ring *p, *pNext = (Ring*)&rPam;
|
|
do {
|
|
p = pNext;
|
|
pNext = p->GetNext();
|
|
p->MoveTo( &rPam );
|
|
} while( p != pPrev );
|
|
}
|
|
|
|
SwAutoCorrDoc::SwAutoCorrDoc( SwEditShell& rEditShell, SwPaM& rPam,
|
|
sal_Unicode cIns )
|
|
: rEditSh( rEditShell ), rCrsr( rPam ), pIdx( 0 )
|
|
, m_nEndUndoCounter(0)
|
|
, bUndoIdInitialized( cIns ? false : true )
|
|
{
|
|
}
|
|
|
|
SwAutoCorrDoc::~SwAutoCorrDoc()
|
|
{
|
|
for (int i = 0; i < m_nEndUndoCounter; ++i)
|
|
{
|
|
rEditSh.EndUndo();
|
|
}
|
|
delete pIdx;
|
|
}
|
|
|
|
void SwAutoCorrDoc::DeleteSel( SwPaM& rDelPam )
|
|
{
|
|
SwDoc* pDoc = rEditSh.GetDoc();
|
|
if( pDoc->IsAutoFmtRedline() )
|
|
{
|
|
// so that also the DelPam be moved, include it in the
|
|
// Shell-Cursr-Ring !!
|
|
_PaMIntoCrsrShellRing aTmp( rEditSh, rCrsr, rDelPam );
|
|
pDoc->DeleteAndJoin( rDelPam );
|
|
}
|
|
else
|
|
{
|
|
pDoc->DeleteRange( rDelPam );
|
|
}
|
|
}
|
|
|
|
sal_Bool SwAutoCorrDoc::Delete( xub_StrLen nStt, xub_StrLen nEnd )
|
|
{
|
|
const SwNodeIndex& rNd = rCrsr.GetPoint()->nNode;
|
|
SwPaM aSel( rNd, nStt, rNd, nEnd );
|
|
DeleteSel( aSel );
|
|
|
|
if( bUndoIdInitialized )
|
|
bUndoIdInitialized = true;
|
|
return sal_True;
|
|
}
|
|
|
|
sal_Bool SwAutoCorrDoc::Insert( xub_StrLen nPos, const OUString& rTxt )
|
|
{
|
|
SwPaM aPam( rCrsr.GetPoint()->nNode.GetNode(), nPos );
|
|
rEditSh.GetDoc()->InsertString( aPam, rTxt );
|
|
if( !bUndoIdInitialized )
|
|
{
|
|
bUndoIdInitialized = true;
|
|
if( 1 == rTxt.getLength() )
|
|
{
|
|
rEditSh.StartUndo( UNDO_AUTOCORRECT );
|
|
++m_nEndUndoCounter;
|
|
}
|
|
}
|
|
return sal_True;
|
|
}
|
|
|
|
sal_Bool SwAutoCorrDoc::Replace( xub_StrLen nPos, const OUString& rTxt )
|
|
{
|
|
return ReplaceRange( nPos, rTxt.getLength(), rTxt );
|
|
}
|
|
|
|
sal_Bool SwAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength, const OUString& rTxt )
|
|
{
|
|
SwPaM* pPam = &rCrsr;
|
|
if( pPam->GetPoint()->nContent.GetIndex() != nPos )
|
|
{
|
|
pPam = new SwPaM( *rCrsr.GetPoint() );
|
|
pPam->GetPoint()->nContent = nPos;
|
|
}
|
|
|
|
SwTxtNode * const pNd = pPam->GetNode()->GetTxtNode();
|
|
if ( !pNd )
|
|
{
|
|
return sal_False;
|
|
}
|
|
|
|
// text attributes with dummy characters must not be replaced!
|
|
bool bDoReplace = true;
|
|
sal_Int32 const nLen = rTxt.getLength();
|
|
for ( sal_Int32 n = 0; n < nLen; ++n )
|
|
{
|
|
sal_Unicode const Char = pNd->GetTxt()[n + nPos];
|
|
if ( ( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char )
|
|
&& pNd->GetTxtAttrForCharAt( n + nPos ) )
|
|
{
|
|
bDoReplace = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ( bDoReplace )
|
|
{
|
|
SwDoc* pDoc = rEditSh.GetDoc();
|
|
|
|
if( pDoc->IsAutoFmtRedline() )
|
|
{
|
|
if (nPos == pNd->GetTxt().getLength()) // at the End do an Insert
|
|
{
|
|
pDoc->InsertString( *pPam, rTxt );
|
|
}
|
|
else
|
|
{
|
|
_PaMIntoCrsrShellRing aTmp( rEditSh, rCrsr, *pPam );
|
|
|
|
pPam->SetMark();
|
|
pPam->GetPoint()->nContent = std::min<sal_Int32>(
|
|
pNd->GetTxt().getLength(), nPos + nSourceLength);
|
|
pDoc->ReplaceRange( *pPam, rTxt, false );
|
|
pPam->Exchange();
|
|
pPam->DeleteMark();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if( nSourceLength != rTxt.getLength() )
|
|
{
|
|
pPam->SetMark();
|
|
pPam->GetPoint()->nContent = std::min<sal_Int32>(
|
|
pNd->GetTxt().getLength(), nPos + nSourceLength);
|
|
pDoc->ReplaceRange( *pPam, rTxt, false );
|
|
pPam->Exchange();
|
|
pPam->DeleteMark();
|
|
}
|
|
else
|
|
pDoc->Overwrite( *pPam, rTxt );
|
|
}
|
|
|
|
if( bUndoIdInitialized )
|
|
{
|
|
bUndoIdInitialized = true;
|
|
if( 1 == rTxt.getLength() )
|
|
{
|
|
rEditSh.StartUndo( UNDO_AUTOCORRECT );
|
|
++m_nEndUndoCounter;
|
|
}
|
|
}
|
|
}
|
|
|
|
if( pPam != &rCrsr )
|
|
delete pPam;
|
|
|
|
return sal_True;
|
|
}
|
|
|
|
sal_Bool SwAutoCorrDoc::SetAttr( xub_StrLen nStt, xub_StrLen nEnd, sal_uInt16 nSlotId,
|
|
SfxPoolItem& rItem )
|
|
{
|
|
const SwNodeIndex& rNd = rCrsr.GetPoint()->nNode;
|
|
SwPaM aPam( rNd, nStt, rNd, nEnd );
|
|
|
|
SfxItemPool& rPool = rEditSh.GetDoc()->GetAttrPool();
|
|
sal_uInt16 nWhich = rPool.GetWhich( nSlotId, sal_False );
|
|
if( nWhich )
|
|
{
|
|
rItem.SetWhich( nWhich );
|
|
|
|
SfxItemSet aSet( rPool, aCharFmtSetRange );
|
|
SetAllScriptItem( aSet, rItem );
|
|
|
|
rEditSh.GetDoc()->SetFmtItemByAutoFmt( aPam, aSet );
|
|
|
|
if( bUndoIdInitialized )
|
|
bUndoIdInitialized = true;
|
|
}
|
|
return 0 != nWhich;
|
|
}
|
|
|
|
sal_Bool SwAutoCorrDoc::SetINetAttr( xub_StrLen nStt, xub_StrLen nEnd, const OUString& rURL )
|
|
{
|
|
const SwNodeIndex& rNd = rCrsr.GetPoint()->nNode;
|
|
SwPaM aPam( rNd, nStt, rNd, nEnd );
|
|
|
|
SfxItemSet aSet( rEditSh.GetDoc()->GetAttrPool(),
|
|
RES_TXTATR_INETFMT, RES_TXTATR_INETFMT );
|
|
aSet.Put( SwFmtINetFmt( rURL, OUString() ));
|
|
rEditSh.GetDoc()->SetFmtItemByAutoFmt( aPam, aSet );
|
|
if( bUndoIdInitialized )
|
|
bUndoIdInitialized = true;
|
|
return sal_True;
|
|
}
|
|
|
|
/** Return the text of a previous paragraph
|
|
*
|
|
* @param bAtNormalPos If <true> before the normal insert position; if <false> in which the
|
|
* corrected word was inserted. (Doesn't need to be the same paragraph!)
|
|
* @return text or 0, if previous paragraph does not exists or there are only blankness
|
|
*/
|
|
OUString SwAutoCorrDoc::GetPrevPara( sal_Bool bAtNormalPos )
|
|
{
|
|
OUString aStr;
|
|
|
|
if( bAtNormalPos || !pIdx )
|
|
pIdx = new SwNodeIndex( rCrsr.GetPoint()->nNode, -1 );
|
|
else
|
|
(*pIdx)--;
|
|
|
|
SwTxtNode* pTNd = pIdx->GetNode().GetTxtNode();
|
|
while (pTNd && !pTNd->GetTxt().getLength())
|
|
{
|
|
(*pIdx)--;
|
|
pTNd = pIdx->GetNode().GetTxtNode();
|
|
}
|
|
if( pTNd && 0 == pTNd->GetAttrOutlineLevel() )
|
|
aStr = pTNd->GetTxt();
|
|
|
|
if( bUndoIdInitialized )
|
|
bUndoIdInitialized = true;
|
|
return aStr;
|
|
}
|
|
|
|
bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
|
|
SvxAutoCorrect& rACorrect,
|
|
OUString* pPara )
|
|
{
|
|
if( bUndoIdInitialized )
|
|
bUndoIdInitialized = true;
|
|
|
|
// Found a beginning of a paragraph or a Blank,
|
|
// search for the word Kuerzel (Shortcut) in the Auto
|
|
SwTxtNode* pTxtNd = rCrsr.GetNode()->GetTxtNode();
|
|
OSL_ENSURE( pTxtNd, "where is the TextNode?" );
|
|
|
|
sal_Bool bRet = sal_False;
|
|
if( nEndPos == rSttPos )
|
|
return bRet;
|
|
|
|
LanguageType eLang = GetLanguage(nEndPos, sal_False);
|
|
if(LANGUAGE_SYSTEM == eLang)
|
|
eLang = GetAppLanguage();
|
|
LanguageTag aLanguageTag( eLang);
|
|
|
|
//JP 22.04.99: Bug 63883 - Special treatment for dots.
|
|
bool bLastCharIsPoint = nEndPos < pTxtNd->GetTxt().getLength() &&
|
|
('.' == pTxtNd->GetTxt()[nEndPos]);
|
|
|
|
const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList(
|
|
pTxtNd->GetTxt(), rSttPos, nEndPos, *this, aLanguageTag );
|
|
SwDoc* pDoc = rEditSh.GetDoc();
|
|
if( pFnd )
|
|
{
|
|
const SwNodeIndex& rNd = rCrsr.GetPoint()->nNode;
|
|
SwPaM aPam( rNd, rSttPos, rNd, nEndPos );
|
|
|
|
if( pFnd->IsTextOnly() )
|
|
{
|
|
//JP 22.04.99: Bug 63883 - Special treatment for dots.
|
|
if( !bLastCharIsPoint || pFnd->GetLong().isEmpty() ||
|
|
'.' != pFnd->GetLong()[ pFnd->GetLong().getLength() - 1 ] )
|
|
{
|
|
// replace the selection
|
|
pDoc->ReplaceRange( aPam, pFnd->GetLong(), false);
|
|
bRet = sal_True;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SwTextBlocks aTBlks( rACorrect.GetAutoCorrFileName( aLanguageTag, sal_False, sal_True ));
|
|
sal_uInt16 nPos = aTBlks.GetIndex( pFnd->GetShort() );
|
|
if( USHRT_MAX != nPos && aTBlks.BeginGetDoc( nPos ) )
|
|
{
|
|
DeleteSel( aPam );
|
|
pDoc->DontExpandFmt( *aPam.GetPoint() );
|
|
|
|
if( pPara )
|
|
{
|
|
OSL_ENSURE( !pIdx, "who has not deleted his Index?" );
|
|
pIdx = new SwNodeIndex( rCrsr.GetPoint()->nNode, -1 );
|
|
}
|
|
|
|
SwDoc* pAutoDoc = aTBlks.GetDoc();
|
|
SwNodeIndex aSttIdx( pAutoDoc->GetNodes().GetEndOfExtras(), 1 );
|
|
SwCntntNode* pCntntNd = pAutoDoc->GetNodes().GoNext( &aSttIdx );
|
|
SwPaM aCpyPam( aSttIdx );
|
|
|
|
const SwTableNode* pTblNd = pCntntNd->FindTableNode();
|
|
if( pTblNd )
|
|
{
|
|
aCpyPam.GetPoint()->nContent.Assign( 0, 0 );
|
|
aCpyPam.GetPoint()->nNode = *pTblNd;
|
|
}
|
|
aCpyPam.SetMark();
|
|
|
|
// then until the end of the Nodes Array
|
|
aCpyPam.GetPoint()->nNode.Assign( pAutoDoc->GetNodes().GetEndOfContent(), -1 );
|
|
pCntntNd = aCpyPam.GetCntntNode();
|
|
aCpyPam.GetPoint()->nContent.Assign( pCntntNd, pCntntNd->Len() );
|
|
|
|
SwDontExpandItem aExpItem;
|
|
aExpItem.SaveDontExpandItems( *aPam.GetPoint() );
|
|
|
|
pAutoDoc->CopyRange( aCpyPam, *aPam.GetPoint(), false );
|
|
|
|
aExpItem.RestoreDontExpandItems( *aPam.GetPoint() );
|
|
|
|
if( pPara )
|
|
{
|
|
++(*pIdx);
|
|
pTxtNd = pIdx->GetNode().GetTxtNode();
|
|
}
|
|
bRet = sal_True;
|
|
}
|
|
aTBlks.EndGetDoc();
|
|
}
|
|
}
|
|
|
|
if( bRet && pPara && pTxtNd )
|
|
*pPara = pTxtNd->GetTxt();
|
|
|
|
return bRet;
|
|
}
|
|
|
|
|
|
// Called by the functions:
|
|
// - FnCptlSttWrd
|
|
// - FnCptlSttSntnc
|
|
// after the exchange of characters. Then the words, if necessary, can be inserted
|
|
// into the exception list.
|
|
void SwAutoCorrDoc::SaveCpltSttWord( sal_uLong nFlag, xub_StrLen nPos,
|
|
const OUString& rExceptWord,
|
|
sal_Unicode cChar )
|
|
{
|
|
sal_uLong nNode = pIdx ? pIdx->GetIndex() : rCrsr.GetPoint()->nNode.GetIndex();
|
|
LanguageType eLang = GetLanguage(nPos, sal_False);
|
|
rEditSh.GetDoc()->SetAutoCorrExceptWord( new SwAutoCorrExceptWord( nFlag,
|
|
nNode, nPos, rExceptWord, cChar, eLang ));
|
|
}
|
|
|
|
LanguageType SwAutoCorrDoc::GetLanguage( xub_StrLen nPos, sal_Bool bPrevPara ) const
|
|
{
|
|
LanguageType eRet = LANGUAGE_SYSTEM;
|
|
|
|
SwTxtNode* pNd = (( bPrevPara && pIdx )
|
|
? *pIdx
|
|
: rCrsr.GetPoint()->nNode ).GetNode().GetTxtNode();
|
|
|
|
if( pNd )
|
|
eRet = pNd->GetLang( nPos, 0 );
|
|
if(LANGUAGE_SYSTEM == eRet)
|
|
eRet = GetAppLanguage();
|
|
return eRet;
|
|
}
|
|
|
|
void SwAutoCorrExceptWord::CheckChar( const SwPosition& rPos, sal_Unicode cChr )
|
|
{
|
|
// test only if this is a improvement.
|
|
// If yes, then add the word to the list.
|
|
if( cChar == cChr && rPos.nNode.GetIndex() == nNode &&
|
|
rPos.nContent.GetIndex() == nCntnt )
|
|
{
|
|
// get the current autocorrection:
|
|
SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
|
|
|
|
// then add to the list:
|
|
if( CptlSttWrd & nFlags )
|
|
pACorr->AddWrtSttException( sWord, eLanguage );
|
|
else if( CptlSttSntnc & nFlags )
|
|
pACorr->AddCplSttException( sWord, eLanguage );
|
|
}
|
|
}
|
|
|
|
sal_Bool SwAutoCorrExceptWord::CheckDelChar( const SwPosition& rPos )
|
|
{
|
|
sal_Bool bRet = sal_False;
|
|
if( !bDeleted && rPos.nNode.GetIndex() == nNode &&
|
|
rPos.nContent.GetIndex() == nCntnt )
|
|
bDeleted = bRet = sal_True;
|
|
return bRet;
|
|
}
|
|
|
|
SwDontExpandItem::~SwDontExpandItem()
|
|
{
|
|
delete pDontExpItems;
|
|
}
|
|
|
|
void SwDontExpandItem::SaveDontExpandItems( const SwPosition& rPos )
|
|
{
|
|
const SwTxtNode* pTxtNd = rPos.nNode.GetNode().GetTxtNode();
|
|
if( pTxtNd )
|
|
{
|
|
pDontExpItems = new SfxItemSet( ((SwDoc*)pTxtNd->GetDoc())->GetAttrPool(),
|
|
aCharFmtSetRange );
|
|
const sal_Int32 n = rPos.nContent.GetIndex();
|
|
if( !pTxtNd->GetAttr( *pDontExpItems, n, n,
|
|
n != pTxtNd->GetTxt().getLength() ))
|
|
delete pDontExpItems, pDontExpItems = 0;
|
|
}
|
|
}
|
|
|
|
void SwDontExpandItem::RestoreDontExpandItems( const SwPosition& rPos )
|
|
{
|
|
SwTxtNode* pTxtNd = rPos.nNode.GetNode().GetTxtNode();
|
|
if( pTxtNd )
|
|
{
|
|
const sal_Int32 nStart = rPos.nContent.GetIndex();
|
|
if( nStart == pTxtNd->GetTxt().getLength() )
|
|
pTxtNd->FmtToTxtAttr( pTxtNd );
|
|
|
|
if( pTxtNd->GetpSwpHints() && pTxtNd->GetpSwpHints()->Count() )
|
|
{
|
|
const sal_uInt16 nSize = pTxtNd->GetpSwpHints()->Count();
|
|
sal_uInt16 n;
|
|
sal_Int32 nAttrStart;
|
|
const sal_Int32* pAttrEnd;
|
|
|
|
for( n = 0; n < nSize; ++n )
|
|
{
|
|
SwTxtAttr* pHt = pTxtNd->GetpSwpHints()->GetTextHint( n );
|
|
nAttrStart = *pHt->GetStart();
|
|
if( nAttrStart > nStart ) // beyond the area
|
|
break;
|
|
|
|
if( 0 != ( pAttrEnd = pHt->End() ) &&
|
|
( ( nAttrStart < nStart &&
|
|
( pHt->DontExpand() ? nStart < *pAttrEnd
|
|
: nStart <= *pAttrEnd )) ||
|
|
( nStart == nAttrStart &&
|
|
( nAttrStart == *pAttrEnd || !nStart ))) )
|
|
{
|
|
const SfxPoolItem* pItem;
|
|
if( !pDontExpItems || SFX_ITEM_SET != pDontExpItems->
|
|
GetItemState( pHt->Which(), sal_False, &pItem ) ||
|
|
*pItem != pHt->GetAttr() )
|
|
{
|
|
// The attribute was not previously set in this form in the
|
|
// paragraph, so it can only be created through insert/copy
|
|
// Because of that it is a candidate for DontExpand
|
|
pHt->SetDontExpand( sal_True );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|