EdtAutoCorrDoc no longer a friend of ImpEditEngine.

This commit is contained in:
Kohei Yoshida
2012-04-16 16:52:03 -04:00
parent e1520a9d6a
commit 29e7777de5
7 changed files with 60 additions and 43 deletions

View File

@@ -144,7 +144,6 @@ private:
EDITENG_DLLPRIVATE const ParaPortion* FindParaPortion(ContentNode* pNode) const;
EDITENG_DLLPRIVATE const ParaPortion* GetPrevVisPortion(const ParaPortion* pCurPortion) const;
EDITENG_DLLPRIVATE const ParaPortion* GetNextVisPortion(const ParaPortion* pCurPortion) const;
EDITENG_DLLPRIVATE sal_uInt16 GetScriptType(const EditSelection& rSel) const;
EDITENG_DLLPRIVATE com::sun::star::uno::Reference<
com::sun::star::datatransfer::XTransferable>
@@ -228,6 +227,7 @@ public:
EEHorizontalTextDirection GetDefaultHorizontalTextDirection() const;
sal_uInt16 GetScriptType( const ESelection& rSelection ) const;
LanguageType GetLanguage(const EditPaM& rPaM) const;
LanguageType GetLanguage( sal_uInt16 nPara, sal_uInt16 nPos ) const;
void TransliterateText( const ESelection& rSelection, sal_Int32 nTransliterationMode );
@@ -310,6 +310,7 @@ public:
::svl::IUndoManager&
GetUndoManager();
void UndoActionStart( sal_uInt16 nId );
void UndoActionStart(sal_uInt16 nId, const ESelection& rSel);
void UndoActionEnd( sal_uInt16 nId );
sal_Bool IsInUndo();
@@ -542,6 +543,10 @@ public:
const SfxItemSet& GetBaseParaAttribs(sal_uInt16 nPara) const;
void SetParaAttribsOnly(sal_uInt16 nPara, const SfxItemSet& rSet);
void SetAttribs(const EditSelection& rSel, const SfxItemSet& rSet, sal_uInt8 nSpecial = 0);
String GetSelected(const EditSelection& rSel, const LineEnd eParaSep = LINEEND_LF) const;
sal_uInt16 GetScriptType(const EditSelection& rSel) const;
};
#endif // _MyEDITENG_HXX

View File

@@ -153,6 +153,11 @@ void EditEngine::UndoActionStart( sal_uInt16 nId )
pImpEditEngine->UndoActionStart( nId );
}
void EditEngine::UndoActionStart(sal_uInt16 nId, const ESelection& rSel)
{
pImpEditEngine->UndoActionStart(nId, rSel);
}
void EditEngine::UndoActionEnd( sal_uInt16 nId )
{
DBG_CHKTHIS( EditEngine, 0 );
@@ -509,6 +514,11 @@ sal_uInt16 EditEngine::GetScriptType( const ESelection& rSelection ) const
return pImpEditEngine->GetScriptType( aSel );
}
LanguageType EditEngine::GetLanguage(const EditPaM& rPaM) const
{
return pImpEditEngine->GetLanguage(rPaM);
}
LanguageType EditEngine::GetLanguage( sal_uInt16 nPara, sal_uInt16 nPos ) const
{
DBG_CHKTHIS( EditEngine, 0 );
@@ -859,6 +869,11 @@ void EditEngine::SetAttribs(const EditSelection& rSel, const SfxItemSet& rSet, s
pImpEditEngine->SetAttribs(rSel, rSet, nSpecial);
}
String EditEngine::GetSelected(const EditSelection& rSel, const LineEnd eParaSep) const
{
return pImpEditEngine->GetSelected(rSel, eParaSep);
}
void EditEngine::HandleBeginPasteOrDrop(PasteOrDropInfos& rInfos)
{
pImpEditEngine->aBeginPasteOrDropHdl.Call(&rInfos);

View File

@@ -574,27 +574,24 @@ sal_Bool WrongList::DbgIsBuggy() const
//////////////////////////////////////////////////////////////////////
EdtAutoCorrDoc::EdtAutoCorrDoc( ImpEditEngine* pE, ContentNode* pN,
sal_uInt16 nCrsr, xub_Unicode cIns )
{
pImpEE = pE;
pCurNode = pN;
nCursor = nCrsr;
bUndoAction = sal_False;
bAllowUndoAction = cIns ? sal_True : sal_False;
}
EdtAutoCorrDoc::EdtAutoCorrDoc(
EditEngine* pE, ContentNode* pN, sal_uInt16 nCrsr, sal_Unicode cIns) :
mpEditEngine(pE),
pCurNode(pN),
nCursor(nCrsr),
bAllowUndoAction(cIns != 0),
bUndoAction(false) {}
EdtAutoCorrDoc::~EdtAutoCorrDoc()
{
if ( bUndoAction )
pImpEE->UndoActionEnd( EDITUNDO_INSERT );
mpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
}
sal_Bool EdtAutoCorrDoc::Delete( sal_uInt16 nStt, sal_uInt16 nEnd )
{
EditSelection aSel( EditPaM( pCurNode, nStt ), EditPaM( pCurNode, nEnd ) );
pImpEE->ImpDeleteSelection( aSel );
mpEditEngine->DeleteSelection(aSel);
SAL_WARN_IF(nCursor < nEnd, "editeng",
"Cursor in the heart of the action?!");
nCursor -= ( nEnd-nStt );
@@ -605,7 +602,7 @@ sal_Bool EdtAutoCorrDoc::Delete( sal_uInt16 nStt, sal_uInt16 nEnd )
sal_Bool EdtAutoCorrDoc::Insert( sal_uInt16 nPos, const String& rTxt )
{
EditSelection aSel = EditPaM( pCurNode, nPos );
pImpEE->ImpInsertText( aSel, rTxt );
mpEditEngine->InsertText(aSel, rTxt);
SAL_WARN_IF(nCursor < nPos, "editeng",
"Cursor in the heart of the action?!");
nCursor = nCursor + rTxt.Len();
@@ -630,8 +627,9 @@ sal_Bool EdtAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength
nEnd = pCurNode->Len();
// #i5925# First insert new text behind to be deleted text, for keeping attributes.
pImpEE->ImpInsertText( EditSelection( EditPaM( pCurNode, nEnd ) ), rTxt );
pImpEE->ImpDeleteSelection( EditSelection( EditPaM( pCurNode, nPos ), EditPaM( pCurNode, nEnd ) ) );
mpEditEngine->InsertText(EditSelection(EditPaM(pCurNode, nEnd)), rTxt);
mpEditEngine->DeleteSelection(
EditSelection(EditPaM(pCurNode, nPos), EditPaM(pCurNode, nEnd)));
if ( nPos == nCursor )
nCursor = nCursor + rTxt.Len();
@@ -647,7 +645,7 @@ sal_Bool EdtAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength
sal_Bool EdtAutoCorrDoc::SetAttr( sal_uInt16 nStt, sal_uInt16 nEnd,
sal_uInt16 nSlotId, SfxPoolItem& rItem )
{
SfxItemPool* pPool = &pImpEE->GetEditDoc().GetItemPool();
SfxItemPool* pPool = &mpEditEngine->GetEditDoc().GetItemPool();
while ( pPool->GetSecondaryPool() &&
!pPool->GetName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("EditEngineItemPool")) )
{
@@ -659,13 +657,13 @@ sal_Bool EdtAutoCorrDoc::SetAttr( sal_uInt16 nStt, sal_uInt16 nEnd,
{
rItem.SetWhich( nWhich );
SfxItemSet aSet( pImpEE->GetEmptyItemSet() );
SfxItemSet aSet = mpEditEngine->GetEmptyItemSet();
aSet.Put( rItem );
EditSelection aSel( EditPaM( pCurNode, nStt ), EditPaM( pCurNode, nEnd ) );
aSel.Max().SetIndex( nEnd ); // ???
pImpEE->SetAttribs( aSel, aSet, ATTRSPECIAL_EDGE );
bAllowUndoAction = sal_False;
mpEditEngine->SetAttribs( aSel, aSet, ATTRSPECIAL_EDGE );
bAllowUndoAction = false;
}
return sal_True;
}
@@ -675,23 +673,23 @@ sal_Bool EdtAutoCorrDoc::SetINetAttr( sal_uInt16 nStt, sal_uInt16 nEnd,
{
// Turn the Text into a command field ...
EditSelection aSel( EditPaM( pCurNode, nStt ), EditPaM( pCurNode, nEnd ) );
String aText = pImpEE->GetSelected( aSel );
aSel = pImpEE->ImpDeleteSelection( aSel );
String aText = mpEditEngine->GetSelected(aSel);
aSel = mpEditEngine->DeleteSelection(aSel);
SAL_WARN_IF(nCursor < nEnd, "editeng",
"Cursor in the heart of the action?!");
nCursor -= ( nEnd-nStt );
SvxFieldItem aField( SvxURLField( rURL, aText, SVXURLFORMAT_REPR ),
EE_FEATURE_FIELD );
pImpEE->InsertField( aSel, aField );
mpEditEngine->InsertField(aSel, aField);
nCursor++;
pImpEE->UpdateFields();
bAllowUndoAction = sal_False;
mpEditEngine->UpdateFieldsOnly();
bAllowUndoAction = false;
return sal_True;
}
sal_Bool EdtAutoCorrDoc::HasSymbolChars( sal_uInt16 nStt, sal_uInt16 nEnd )
{
sal_uInt16 nScriptType = pImpEE->GetScriptType( EditPaM( pCurNode, nStt ) );
sal_uInt16 nScriptType = mpEditEngine->GetScriptType( EditPaM( pCurNode, nStt ) );
sal_uInt16 nScriptFontInfoItemId = GetScriptItemId( EE_CHAR_FONTINFO, nScriptType );
const CharAttribList::AttribsType& rAttribs = pCurNode->GetCharAttribs().GetAttribs();
@@ -720,18 +718,18 @@ const String* EdtAutoCorrDoc::GetPrevPara( sal_Bool )
bAllowUndoAction = sal_False; // Not anymore ...
EditDoc& rNodes = pImpEE->GetEditDoc();
EditDoc& rNodes = mpEditEngine->GetEditDoc();
sal_uInt16 nPos = rNodes.GetPos( pCurNode );
// Special case: Bullet => Paragraph start => simply return NULL...
const SfxBoolItem& rBulletState = (const SfxBoolItem&)
pImpEE->GetParaAttrib( nPos, EE_PARA_BULLETSTATE );
mpEditEngine->GetParaAttrib( nPos, EE_PARA_BULLETSTATE );
sal_Bool bBullet = rBulletState.GetValue() ? sal_True : sal_False;
if ( !bBullet && ( pImpEE->aStatus.GetControlWord() & EE_CNTRL_OUTLINER ) )
if ( !bBullet && (mpEditEngine->GetControlWord() & EE_CNTRL_OUTLINER) )
{
// The Outliner has still a Bullet at Level 0.
const SfxInt16Item& rLevel = (const SfxInt16Item&)
pImpEE->GetParaAttrib( nPos, EE_PARA_OUTLLEVEL );
mpEditEngine->GetParaAttrib( nPos, EE_PARA_OUTLLEVEL );
if ( rLevel.GetValue() == 0 )
bBullet = sal_True;
}
@@ -763,18 +761,18 @@ sal_Bool EdtAutoCorrDoc::ChgAutoCorrWord( sal_uInt16& rSttPos,
if( !aShort.Len() )
return bRet;
LanguageType eLang = pImpEE->GetLanguage( EditPaM( pCurNode, rSttPos+1 ) );
LanguageType eLang = mpEditEngine->GetLanguage( EditPaM( pCurNode, rSttPos+1 ) );
const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList(pCurNode->GetString(), rSttPos, nEndPos, *this, eLang);
if( pFnd && pFnd->IsTextOnly() )
{
// then replace
EditSelection aSel( EditPaM( pCurNode, rSttPos ),
EditPaM( pCurNode, nEndPos ) );
aSel = pImpEE->ImpDeleteSelection( aSel );
aSel = mpEditEngine->DeleteSelection(aSel);
SAL_WARN_IF(nCursor < nEndPos, "editeng",
"Cursor in the heart of the action?!");
nCursor -= ( nEndPos-rSttPos );
pImpEE->ImpInsertText( aSel, pFnd->GetLong() );
mpEditEngine->InsertText(aSel, pFnd->GetLong());
nCursor = nCursor + pFnd->GetLong().Len();
if( ppPara )
*ppPara = &pCurNode->GetString();
@@ -786,14 +784,14 @@ sal_Bool EdtAutoCorrDoc::ChgAutoCorrWord( sal_uInt16& rSttPos,
LanguageType EdtAutoCorrDoc::GetLanguage( sal_uInt16 nPos, sal_Bool ) const
{
return pImpEE->GetLanguage( EditPaM( pCurNode, nPos+1 ) );
return mpEditEngine->GetLanguage( EditPaM( pCurNode, nPos+1 ) );
}
void EdtAutoCorrDoc::ImplStartUndoAction()
{
sal_uInt16 nPara = pImpEE->GetEditDoc().GetPos( pCurNode );
sal_uInt16 nPara = mpEditEngine->GetEditDoc().GetPos( pCurNode );
ESelection aSel( nPara, nCursor, nPara, nCursor );
pImpEE->UndoActionStart( EDITUNDO_INSERT, aSel );
mpEditEngine->UndoActionStart( EDITUNDO_INSERT, aSel );
bUndoAction = sal_True;
bAllowUndoAction = sal_False;
}

View File

@@ -42,7 +42,7 @@ namespace com { namespace sun { namespace star { namespace linguistic2 {
class EditView;
class ImpEditEngine;
class EditEngine;
class ContentNode;
class EditSpellWrapper : public SvxSpellWrapper
@@ -136,7 +136,7 @@ public:
class EdtAutoCorrDoc : public SvxAutoCorrDoc
{
ImpEditEngine* pImpEE;
EditEngine* mpEditEngine;
ContentNode* pCurNode;
sal_uInt16 nCursor;
@@ -147,8 +147,8 @@ protected:
void ImplStartUndoAction();
public:
EdtAutoCorrDoc( ImpEditEngine* pImpEE, ContentNode* pCurNode, sal_uInt16 nCrsr, xub_Unicode cIns );
~EdtAutoCorrDoc();
EdtAutoCorrDoc(EditEngine* pE, ContentNode* pCurNode, sal_uInt16 nCrsr, sal_Unicode cIns);
~EdtAutoCorrDoc();
virtual sal_Bool Delete( sal_uInt16 nStt, sal_uInt16 nEnd );
virtual sal_Bool Insert( sal_uInt16 nPos, const String& rTxt );

View File

@@ -86,7 +86,7 @@ EditHTMLParser::~EditHTMLParser()
SvParserState EditHTMLParser::CallParser(EditEngine* pEE, const EditPaM& rPaM)
{
DBG_ASSERT( pImpEE, "CallParser: ImpEditEngine ?!" );
DBG_ASSERT(pEE, "CallParser: ImpEditEngine ?!");
mpEditEngine = pEE;
SvParserState _eState = SVPAR_NOTSTARTED;
if ( mpEditEngine )

View File

@@ -391,7 +391,6 @@ class ImpEditEngine : public SfxListener, boost::noncopyable
friend class EditUndoMoveParagraphs;
friend class EditEngine; // For access to Imp-Methods
friend class EdtAutoCorrDoc; // For access to Imp-Methods
friend class EditDbg; // Debug Routines
public:

View File

@@ -2573,7 +2573,7 @@ EditPaM ImpEditEngine::AutoCorrect( const EditSelection& rCurSel, xub_Unicode c,
ContentNode* pNode = aSel.Max().GetNode();
sal_uInt16 nIndex = aSel.Max().GetIndex();
EdtAutoCorrDoc aAuto( this, pNode, nIndex, c );
EdtAutoCorrDoc aAuto(pEditEngine, pNode, nIndex, c);
pAutoCorrect->AutoCorrect(
aAuto, pNode->GetString(), nIndex, c, !bOverwrite, pFrameWin );
aSel.Max().SetIndex( aAuto.GetCursor() );