diff options
Diffstat (limited to 'editeng/source/editeng/impedit5.cxx')
-rw-r--r-- | editeng/source/editeng/impedit5.cxx | 270 |
1 files changed, 125 insertions, 145 deletions
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index c9d7563e2ffe..396e529c514d 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -22,33 +22,32 @@ #include <editeng/editeng.hxx> #include <svl/hint.hxx> #include <sfx2/app.hxx> +#include <utility> void ImpEditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool ) { - if ( pStylePool != pSPool ) - { - pStylePool = pSPool; - } + if (mpStylePool != pSPool) + mpStylePool = pSPool; } const SfxStyleSheet* ImpEditEngine::GetStyleSheet( sal_Int32 nPara ) const { - const ContentNode* pNode = aEditDoc.GetObject( nPara ); + const ContentNode* pNode = maEditDoc.GetObject( nPara ); return pNode ? pNode->GetContentAttribs().GetStyleSheet() : nullptr; } SfxStyleSheet* ImpEditEngine::GetStyleSheet( sal_Int32 nPara ) { - ContentNode* pNode = aEditDoc.GetObject( nPara ); + ContentNode* pNode = maEditDoc.GetObject( nPara ); return pNode ? pNode->GetContentAttribs().GetStyleSheet() : nullptr; } void ImpEditEngine::SetStyleSheet( EditSelection aSel, SfxStyleSheet* pStyle ) { - aSel.Adjust( aEditDoc ); + aSel.Adjust( maEditDoc ); - sal_Int32 nStartPara = aEditDoc.GetPos( aSel.Min().GetNode() ); - sal_Int32 nEndPara = aEditDoc.GetPos( aSel.Max().GetNode() ); + sal_Int32 nStartPara = maEditDoc.GetPos( aSel.Min().GetNode() ); + sal_Int32 nEndPara = maEditDoc.GetPos( aSel.Max().GetNode() ); bool _bUpdate = SetUpdateLayout( false ); @@ -61,11 +60,11 @@ void ImpEditEngine::SetStyleSheet( EditSelection aSel, SfxStyleSheet* pStyle ) void ImpEditEngine::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle ) { DBG_ASSERT( GetStyleSheetPool() || !pStyle, "SetStyleSheet: No StyleSheetPool registered!" ); - ContentNode* pNode = aEditDoc.GetObject( nPara ); + ContentNode* pNode = maEditDoc.GetObject( nPara ); SfxStyleSheet* pCurStyle = pNode->GetStyleSheet(); if ( pStyle != pCurStyle ) { - if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() ) + if ( IsUndoEnabled() && !IsInUndo() && maStatus.DoUndoAttribs() ) { OUString aPrevStyleName; if ( pCurStyle ) @@ -76,16 +75,19 @@ void ImpEditEngine::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle ) aNewStyleName = pStyle->GetName(); InsertUndo( - std::make_unique<EditUndoSetStyleSheet>(pEditEngine, aEditDoc.GetPos( pNode ), + std::make_unique<EditUndoSetStyleSheet>(mpEditEngine, maEditDoc.GetPos( pNode ), aPrevStyleName, pCurStyle ? pCurStyle->GetFamily() : SfxStyleFamily::Para, aNewStyleName, pStyle ? pStyle->GetFamily() : SfxStyleFamily::Para, pNode->GetContentAttribs().GetItems() ) ); } if ( pCurStyle ) EndListening( *pCurStyle ); - pNode->SetStyleSheet( pStyle, aStatus.UseCharAttribs() ); + pNode->SetStyleSheet( pStyle, maStatus.UseCharAttribs() ); if ( pStyle ) - StartListening(*pStyle, DuplicateHandling::Prevent); + StartListening(*pStyle, DuplicateHandling::Allow); + + if (pNode->GetWrongList()) + pNode->GetWrongList()->ResetInvalidRange(0, pNode->Len()); ParaAttribsChanged( pNode ); } if (IsUpdateLayout()) @@ -98,17 +100,19 @@ void ImpEditEngine::UpdateParagraphsWithStyleSheet( SfxStyleSheet* pStyle ) CreateFont( aFontFromStyle, pStyle->GetItemSet() ); bool bUsed = false; - for ( sal_Int32 nNode = 0; nNode < aEditDoc.Count(); nNode++ ) + for ( sal_Int32 nNode = 0; nNode < maEditDoc.Count(); nNode++ ) { - ContentNode* pNode = aEditDoc.GetObject( nNode ); + ContentNode* pNode = maEditDoc.GetObject( nNode ); if ( pNode->GetStyleSheet() == pStyle ) { bUsed = true; - if ( aStatus.UseCharAttribs() ) + if (maStatus.UseCharAttribs()) pNode->SetStyleSheet( pStyle, aFontFromStyle ); else pNode->SetStyleSheet( pStyle, false ); + if (pNode->GetWrongList()) + pNode->GetWrongList()->ResetInvalidRange(0, pNode->Len()); ParaAttribsChanged( pNode ); } } @@ -122,9 +126,9 @@ void ImpEditEngine::UpdateParagraphsWithStyleSheet( SfxStyleSheet* pStyle ) void ImpEditEngine::RemoveStyleFromParagraphs( SfxStyleSheet const * pStyle ) { - for ( sal_Int32 nNode = 0; nNode < aEditDoc.Count(); nNode++ ) + for ( sal_Int32 nNode = 0; nNode < maEditDoc.Count(); nNode++ ) { - ContentNode* pNode = aEditDoc.GetObject(nNode); + ContentNode* pNode = maEditDoc.GetObject(nNode); if ( pNode->GetStyleSheet() == pStyle ) { pNode->SetStyleSheet( nullptr ); @@ -138,72 +142,67 @@ void ImpEditEngine::RemoveStyleFromParagraphs( SfxStyleSheet const * pStyle ) void ImpEditEngine::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { // So that not a lot of unnecessary formatting is done when destructing: - if ( !bDowning ) + if (!mbDowning) { - - const SfxStyleSheetHint* pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint); - if ( pStyleSheetHint ) + SfxHintId nId = rHint.GetId(); + if ( ( nId == SfxHintId::StyleSheetInDestruction ) || + ( nId == SfxHintId::StyleSheetErased ) ) { - DBG_ASSERT( dynamic_cast< const SfxStyleSheet* >(pStyleSheetHint->GetStyleSheet()) != nullptr, "No SfxStyleSheet!" ); + const SfxStyleSheetHint* pStyleSheetHint = static_cast<const SfxStyleSheetHint*>(&rHint); SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>( pStyleSheetHint->GetStyleSheet() ); - SfxHintId nId = pStyleSheetHint->GetId(); - if ( ( nId == SfxHintId::StyleSheetInDestruction ) || - ( nId == SfxHintId::StyleSheetErased ) ) - { - RemoveStyleFromParagraphs( pStyle ); - } - else if ( nId == SfxHintId::StyleSheetModified ) - { - UpdateParagraphsWithStyleSheet( pStyle ); - } + RemoveStyleFromParagraphs( pStyle ); } - else if ( auto pStyle = dynamic_cast< SfxStyleSheet* >(&rBC) ) + else if ( nId == SfxHintId::StyleSheetModified || nId == SfxHintId::StyleSheetModifiedExtended ) { - SfxHintId nId = rHint.GetId(); - if ( nId == SfxHintId::Dying ) - { - RemoveStyleFromParagraphs( pStyle ); - } - else if ( nId == SfxHintId::DataChanged ) - { - UpdateParagraphsWithStyleSheet( pStyle ); - } + const SfxStyleSheetHint* pStyleSheetHint = static_cast<const SfxStyleSheetHint*>(&rHint); + SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>( pStyleSheetHint->GetStyleSheet() ); + UpdateParagraphsWithStyleSheet( pStyle ); + } + else if ( nId == SfxHintId::Dying && rBC.IsSfxStyleSheet() ) + { + auto pStyle = static_cast< SfxStyleSheet* >(&rBC); + RemoveStyleFromParagraphs( pStyle ); + } + else if ( nId == SfxHintId::DataChanged && rBC.IsSfxStyleSheet()) + { + auto pStyle = static_cast< SfxStyleSheet* >(&rBC); + UpdateParagraphsWithStyleSheet( pStyle ); } } - if(dynamic_cast<const SfxApplication*>(&rBC) != nullptr && rHint.GetId() == SfxHintId::Dying) + if (rHint.GetId() == SfxHintId::Dying && dynamic_cast<const SfxApplication*>(&rBC)) Dispose(); } std::unique_ptr<EditUndoSetAttribs> ImpEditEngine::CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet ) { - DBG_ASSERT( !aSel.DbgIsBuggy( aEditDoc ), "CreateAttribUndo: Incorrect selection "); - aSel.Adjust( aEditDoc ); + DBG_ASSERT( !aSel.DbgIsBuggy( maEditDoc ), "CreateAttribUndo: Incorrect selection "); + aSel.Adjust( maEditDoc ); ESelection aESel( CreateESel( aSel ) ); - sal_Int32 nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); - sal_Int32 nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); + sal_Int32 nStartNode = maEditDoc.GetPos( aSel.Min().GetNode() ); + sal_Int32 nEndNode = maEditDoc.GetPos( aSel.Max().GetNode() ); DBG_ASSERT( nStartNode <= nEndNode, "CreateAttribUndo: Start > End ?!" ); std::unique_ptr<EditUndoSetAttribs> pUndo; - if ( rSet.GetPool() != &aEditDoc.GetItemPool() ) + if ( rSet.GetPool() != &maEditDoc.GetItemPool() ) { SfxItemSet aTmpSet( GetEmptyItemSet() ); aTmpSet.Put( rSet ); - pUndo.reset( new EditUndoSetAttribs(pEditEngine, aESel, aTmpSet) ); + pUndo.reset( new EditUndoSetAttribs(mpEditEngine, aESel, std::move(aTmpSet)) ); } else { - pUndo.reset( new EditUndoSetAttribs(pEditEngine, aESel, rSet) ); + pUndo.reset( new EditUndoSetAttribs(mpEditEngine, aESel, rSet) ); } SfxItemPool* pPool = pUndo->GetNewAttribs().GetPool(); for ( sal_Int32 nPara = nStartNode; nPara <= nEndNode; nPara++ ) { - ContentNode* pNode = aEditDoc.GetObject( nPara ); - DBG_ASSERT( aEditDoc.GetObject( nPara ), "Node not found: CreateAttribUndo" ); + ContentNode* pNode = maEditDoc.GetObject( nPara ); + DBG_ASSERT( maEditDoc.GetObject( nPara ), "Node not found: CreateAttribUndo" ); ContentAttribsInfo* pInf = new ContentAttribsInfo( pNode->GetContentAttribs().GetItems() ); pUndo->AppendContentInfo(pInf); @@ -224,8 +223,8 @@ ViewShellId ImpEditEngine::CreateViewShellId() { ViewShellId nRet(-1); - const EditView* pEditView = pEditEngine ? pEditEngine->GetActiveView() : nullptr; - const OutlinerViewShell* pViewShell = pEditView ? pEditView->GetImpEditView()->GetViewShell() : nullptr; + const EditView* pEditView = mpEditEngine ? mpEditEngine->GetActiveView() : nullptr; + const OutlinerViewShell* pViewShell = pEditView ? pEditView->getImpl().GetViewShell() : nullptr; if (pViewShell) nRet = pViewShell->GetViewShellId(); @@ -237,8 +236,8 @@ void ImpEditEngine::UndoActionStart( sal_uInt16 nId, const ESelection& aSel ) if ( IsUndoEnabled() && !IsInUndo() ) { GetUndoManager().EnterListAction( GetEditEnginePtr()->GetUndoComment( nId ), OUString(), nId, CreateViewShellId() ); - DBG_ASSERT( !pUndoMarkSelection, "UndoAction SelectionMarker?" ); - pUndoMarkSelection.reset(new ESelection( aSel )); + DBG_ASSERT( !moUndoMarkSelection, "UndoAction SelectionMarker?" ); + moUndoMarkSelection = aSel; } } @@ -247,7 +246,7 @@ void ImpEditEngine::UndoActionStart( sal_uInt16 nId ) if ( IsUndoEnabled() && !IsInUndo() ) { GetUndoManager().EnterListAction( GetEditEnginePtr()->GetUndoComment( nId ), OUString(), nId, CreateViewShellId() ); - DBG_ASSERT( !pUndoMarkSelection, "UndoAction SelectionMarker?" ); + DBG_ASSERT( !moUndoMarkSelection, "UndoAction SelectionMarker?" ); } } @@ -256,17 +255,17 @@ void ImpEditEngine::UndoActionEnd() if ( IsUndoEnabled() && !IsInUndo() ) { GetUndoManager().LeaveListAction(); - pUndoMarkSelection.reset(); + moUndoMarkSelection.reset(); } } void ImpEditEngine::InsertUndo( std::unique_ptr<EditUndo> pUndo, bool bTryMerge ) { DBG_ASSERT( !IsInUndo(), "InsertUndo in Undo mode!" ); - if ( pUndoMarkSelection ) + if ( moUndoMarkSelection ) { - GetUndoManager().AddUndoAction( std::make_unique<EditUndoMarkSelection>(pEditEngine, *pUndoMarkSelection) ); - pUndoMarkSelection.reset(); + GetUndoManager().AddUndoAction( std::make_unique<EditUndoMarkSelection>(mpEditEngine, *moUndoMarkSelection) ); + moUndoMarkSelection.reset(); } GetUndoManager().AddUndoAction( std::move(pUndo), bTryMerge ); @@ -285,7 +284,7 @@ void ImpEditEngine::EnableUndo( bool bEnable ) if ( bEnable != IsUndoEnabled() ) ResetUndoManager(); - bUndoEnabled = bEnable; + mbUndoEnabled = bEnable; } void ImpEditEngine::Undo( EditView* pView ) @@ -309,18 +308,18 @@ void ImpEditEngine::Redo( EditView* pView ) SfxItemSet ImpEditEngine::GetAttribs( EditSelection aSel, EditEngineAttribs nOnlyHardAttrib ) { - aSel.Adjust( aEditDoc ); + aSel.Adjust( maEditDoc ); SfxItemSet aCurSet( GetEmptyItemSet() ); - sal_Int32 nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); - sal_Int32 nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); + sal_Int32 nStartNode = maEditDoc.GetPos( aSel.Min().GetNode() ); + sal_Int32 nEndNode = maEditDoc.GetPos( aSel.Max().GetNode() ); // iterate over the paragraphs ... for ( sal_Int32 nNode = nStartNode; nNode <= nEndNode; nNode++ ) { - ContentNode* pNode = aEditDoc.GetObject( nNode ); - DBG_ASSERT( aEditDoc.GetObject( nNode ), "Node not found: GetAttrib" ); + ContentNode* pNode = maEditDoc.GetObject( nNode ); + assert( pNode && "Node not found: GetAttrib" ); const sal_Int32 nStartPos = nNode==nStartNode ? aSel.Min().GetIndex() : 0; const sal_Int32 nEndPos = nNode==nEndNode ? aSel.Max().GetIndex() : pNode->Len(); // Can also be == nStart! @@ -331,7 +330,8 @@ SfxItemSet ImpEditEngine::GetAttribs( EditSelection aSel, EditEngineAttribs nOnl // 2) Examine Style and paragraph attributes only when OFF... // First the very hard formatting... - EditDoc::FindAttribs( pNode, nStartPos, nEndPos, aCurSet ); + if (pNode) + EditDoc::FindAttribs( pNode, nStartPos, nEndPos, aCurSet ); if( nOnlyHardAttrib != EditEngineAttribs::OnlyHard ) { @@ -386,7 +386,7 @@ SfxItemSet ImpEditEngine::GetAttribs( EditSelection aSel, EditEngineAttribs nOnl { if ( aCurSet.GetItemState( nWhich ) == SfxItemState::DEFAULT ) { - aCurSet.Put( aEditDoc.GetItemPool().GetDefaultItem( nWhich ) ); + aCurSet.Put( maEditDoc.GetItemPool().GetUserOrPoolDefaultItem( nWhich ) ); } } } @@ -400,7 +400,7 @@ SfxItemSet ImpEditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int // If this works, change GetAttribs( EditSelection ) to use this for each paragraph and merge the results! - ContentNode* pNode = const_cast<ContentNode*>(aEditDoc.GetObject(nPara)); + ContentNode* pNode = const_cast<ContentNode*>(maEditDoc.GetObject(nPara)); DBG_ASSERT( pNode, "GetAttribs - unknown paragraph!" ); DBG_ASSERT( nStart <= nEnd, "getAttribs: Start > End not supported!" ); @@ -427,8 +427,7 @@ SfxItemSet ImpEditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int if ( nFlags & GetAttribsFlags::CHARATTRIBS ) { // Make testing easier... - const SfxItemPool& rPool = GetEditDoc().GetItemPool(); - pNode->GetCharAttribs().OptimizeRanges(const_cast<SfxItemPool&>(rPool)); + pNode->GetCharAttribs().OptimizeRanges(); const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs(); for (const auto & nAttr : rAttrs) @@ -487,17 +486,17 @@ SfxItemSet ImpEditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetAttribsMode nSpecial, bool bSetSelection ) { - aSel.Adjust( aEditDoc ); + aSel.Adjust( maEditDoc ); // When no selection => use the Attribute on the word. // ( the RTF-parser should actually never call the Method without a Range ) if ( nSpecial == SetAttribsMode::WholeWord && !aSel.HasRange() ) aSel = SelectWord( aSel, css::i18n::WordType::ANYWORD_IGNOREWHITESPACES, false ); - sal_Int32 nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); - sal_Int32 nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); + sal_Int32 nStartNode = maEditDoc.GetPos( aSel.Min().GetNode() ); + sal_Int32 nEndNode = maEditDoc.GetPos( aSel.Max().GetNode() ); - if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() ) + if (IsUndoEnabled() && !IsInUndo() && maStatus.DoUndoAttribs()) { std::unique_ptr<EditUndoSetAttribs> pUndo = CreateAttribUndo( aSel, rSet ); pUndo->SetSpecial( nSpecial ); @@ -519,11 +518,14 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetA bool bParaAttribFound = false; bool bCharAttribFound = false; - DBG_ASSERT( aEditDoc.GetObject( nNode ), "Node not found: SetAttribs" ); - DBG_ASSERT( GetParaPortions().SafeGetObject( nNode ), "Portion not found: SetAttribs" ); + DBG_ASSERT( maEditDoc.GetObject( nNode ), "Node not found: SetAttribs" ); + DBG_ASSERT(GetParaPortions().exists(nNode), "Portion not found: SetAttribs"); - ContentNode* pNode = aEditDoc.GetObject( nNode ); - ParaPortion& rPortion = GetParaPortions()[nNode]; + if (!GetParaPortions().exists(nNode)) + continue; + + ContentNode* pNode = maEditDoc.GetObject(nNode); + ParaPortion& rPortion = GetParaPortions().getRef(nNode); const sal_Int32 nStartPos = nNode==nStartNode ? aSel.Min().GetIndex() : 0; const sal_Int32 nEndPos = nNode==nEndNode ? aSel.Max().GetIndex() : pNode->Len(); // can also be == nStart! @@ -541,7 +543,7 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetA } else { - aEditDoc.InsertAttrib( pNode, nStartPos, nEndPos, rItem ); + maEditDoc.InsertAttrib( pNode, nStartPos, nEndPos, rItem ); bCharAttribFound = true; if ( nSpecial == SetAttribsMode::Edge ) { @@ -565,14 +567,14 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetA if ( bParaAttribFound ) { - ParaAttribsChanged( rPortion.GetNode() ); + ParaAttribsChanged(rPortion.GetNode()); } else if ( bCharAttribFound ) { - bFormatted = false; + mbFormatted = false; if ( !pNode->Len() || ( nStartPos != nEndPos ) ) { - rPortion.MarkSelectionInvalid( nStartPos ); + rPortion.MarkSelectionInvalid(nStartPos); if ( bCheckLanguage ) pNode->GetWrongList()->SetInvalidRange(nStartPos, nEndPos); } @@ -582,14 +584,14 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetA void ImpEditEngine::RemoveCharAttribs( EditSelection aSel, EERemoveParaAttribsMode eMode, sal_uInt16 nWhich ) { - aSel.Adjust( aEditDoc ); + aSel.Adjust( maEditDoc ); - sal_Int32 nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); - sal_Int32 nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); + sal_Int32 nStartNode = maEditDoc.GetPos( aSel.Min().GetNode() ); + sal_Int32 nEndNode = maEditDoc.GetPos( aSel.Max().GetNode() ); bool bRemoveParaAttribs = eMode == EERemoveParaAttribsMode::RemoveAll; const SfxItemSet* _pEmptyItemSet = bRemoveParaAttribs ? &GetEmptyItemSet() : nullptr; - if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() ) + if (IsUndoEnabled() && !IsInUndo() && maStatus.DoUndoAttribs()) { // Possibly a special Undo, or itemset* std::unique_ptr<EditUndoSetAttribs> pUndo = CreateAttribUndo( aSel, GetEmptyItemSet() ); @@ -602,17 +604,21 @@ void ImpEditEngine::RemoveCharAttribs( EditSelection aSel, EERemoveParaAttribsMo // iterate over the paragraphs ... for ( sal_Int32 nNode = nStartNode; nNode <= nEndNode; nNode++ ) { - ContentNode* pNode = aEditDoc.GetObject( nNode ); - ParaPortion& rPortion = GetParaPortions()[nNode]; + ContentNode* pNode = maEditDoc.GetObject( nNode ); + + DBG_ASSERT( maEditDoc.GetObject( nNode ), "Node not found: SetAttribs" ); + DBG_ASSERT(GetParaPortions().exists(nNode), "Portion not found: SetAttribs"); - DBG_ASSERT( aEditDoc.GetObject( nNode ), "Node not found: SetAttribs" ); - DBG_ASSERT( GetParaPortions().SafeGetObject( nNode ), "Portion not found: SetAttribs" ); + if (!GetParaPortions().exists(nNode)) + continue; + + ParaPortion& rPortion = GetParaPortions().getRef(nNode); const sal_Int32 nStartPos = nNode==nStartNode ? aSel.Min().GetIndex() : 0; const sal_Int32 nEndPos = nNode==nEndNode ? aSel.Max().GetIndex() : pNode->Len(); // can also be == nStart! // Optimize: If whole paragraph, then RemoveCharAttribs (nPara)? - bool bChanged = aEditDoc.RemoveAttribs( pNode, nStartPos, nEndPos, nWhich ); + bool bChanged = maEditDoc.RemoveAttribs( pNode, nStartPos, nEndPos, nWhich ); if ( bRemoveParaAttribs ) { SetParaAttribs( nNode, *_pEmptyItemSet ); // Invalidated @@ -636,15 +642,15 @@ void ImpEditEngine::RemoveCharAttribs( EditSelection aSel, EERemoveParaAttribsMo if ( bChanged && !bRemoveParaAttribs ) { - bFormatted = false; - rPortion.MarkSelectionInvalid( nStartPos ); + mbFormatted = false; + rPortion.MarkSelectionInvalid(nStartPos); } } } void ImpEditEngine::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich, bool bRemoveFeatures ) { - ContentNode* pNode = aEditDoc.GetObject( nPara ); + ContentNode* pNode = maEditDoc.GetObject( nPara ); ParaPortion* pPortion = GetParaPortions().SafeGetObject( nPara ); DBG_ASSERT( pNode, "Node not found: RemoveCharAttribs" ); @@ -677,7 +683,7 @@ void ImpEditEngine::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich, bool void ImpEditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet ) { - ContentNode* pNode = aEditDoc.GetObject( nPara ); + ContentNode* pNode = maEditDoc.GetObject( nPara ); if ( !pNode ) return; @@ -685,17 +691,17 @@ void ImpEditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet ) if ( pNode->GetContentAttribs().GetItems() == rSet ) return; - if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() ) + if (IsUndoEnabled() && !IsInUndo() && maStatus.DoUndoAttribs()) { - if ( rSet.GetPool() != &aEditDoc.GetItemPool() ) + if ( rSet.GetPool() != &maEditDoc.GetItemPool() ) { SfxItemSet aTmpSet( GetEmptyItemSet() ); aTmpSet.Put( rSet ); - InsertUndo(std::make_unique<EditUndoSetParaAttribs>(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), aTmpSet)); + InsertUndo(std::make_unique<EditUndoSetParaAttribs>(mpEditEngine, nPara, pNode->GetContentAttribs().GetItems(), aTmpSet)); } else { - InsertUndo(std::make_unique<EditUndoSetParaAttribs>(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), rSet)); + InsertUndo(std::make_unique<EditUndoSetParaAttribs>(mpEditEngine, nPara, pNode->GetContentAttribs().GetItems(), rSet)); } } @@ -708,7 +714,7 @@ void ImpEditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet ) if ( bCheckLanguage && pNode->GetWrongList() ) pNode->GetWrongList()->ResetInvalidRange(0, pNode->Len()); - if ( aStatus.UseCharAttribs() ) + if (maStatus.UseCharAttribs()) pNode->CreateDefFont(); ParaAttribsChanged( pNode ); @@ -716,21 +722,21 @@ void ImpEditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet ) const SfxItemSet& ImpEditEngine::GetParaAttribs( sal_Int32 nPara ) const { - const ContentNode* pNode = aEditDoc.GetObject( nPara ); + const ContentNode* pNode = maEditDoc.GetObject( nPara ); assert(pNode && "Node not found: GetParaAttribs"); return pNode->GetContentAttribs().GetItems(); } bool ImpEditEngine::HasParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const { - const ContentNode* pNode = aEditDoc.GetObject( nPara ); + const ContentNode* pNode = maEditDoc.GetObject( nPara ); assert(pNode && "Node not found: HasParaAttrib"); return pNode->GetContentAttribs().HasItem( nWhich ); } const SfxPoolItem& ImpEditEngine::GetParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const { - const ContentNode* pNode = aEditDoc.GetObject(nPara); + const ContentNode* pNode = maEditDoc.GetObject(nPara); assert(pNode && "Node not found: GetParaAttrib"); return pNode->GetContentAttribs().GetItem(nWhich); } @@ -738,7 +744,7 @@ const SfxPoolItem& ImpEditEngine::GetParaAttrib( sal_Int32 nPara, sal_uInt16 nWh void ImpEditEngine::GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const { rLst.clear(); - const ContentNode* pNode = aEditDoc.GetObject( nPara ); + const ContentNode* pNode = maEditDoc.GetObject( nPara ); if ( !pNode ) return; @@ -754,7 +760,7 @@ void ImpEditEngine::GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& void ImpEditEngine::ParaAttribsToCharAttribs( ContentNode* pNode ) { - pNode->GetCharAttribs().DeleteEmptyAttribs( GetEditDoc().GetItemPool() ); + pNode->GetCharAttribs().DeleteEmptyAttribs(); sal_Int32 nEndPos = pNode->Len(); for ( sal_uInt16 nWhich = EE_CHAR_START; nWhich <= EE_CHAR_END; nWhich++ ) { @@ -768,40 +774,38 @@ void ImpEditEngine::ParaAttribsToCharAttribs( ContentNode* pNode ) { nLastEnd = pAttr->GetEnd(); if ( pAttr->GetStart() > nLastEnd ) - aEditDoc.InsertAttrib( pNode, nLastEnd, pAttr->GetStart(), rItem ); + maEditDoc.InsertAttrib( pNode, nLastEnd, pAttr->GetStart(), rItem ); // #112831# Last Attr might go from 0xffff to 0x0000 pAttr = nLastEnd ? pNode->GetCharAttribs().FindNextAttrib( nWhich, nLastEnd ) : nullptr; } // And the Rest: if ( nLastEnd < nEndPos ) - aEditDoc.InsertAttrib( pNode, nLastEnd, nEndPos, rItem ); + maEditDoc.InsertAttrib( pNode, nLastEnd, nEndPos, rItem ); } } - bFormatted = false; + mbFormatted = false; // Portion does not need to be invalidated here, happens elsewhere. } IdleFormattter::IdleFormattter() : Idle("editeng::ImpEditEngine aIdleFormatter") { - pView = nullptr; - nRestarts = 0; } IdleFormattter::~IdleFormattter() { - pView = nullptr; + mpView = nullptr; } -void IdleFormattter::DoIdleFormat( EditView* pV ) +void IdleFormattter::DoIdleFormat(EditView* pView) { - pView = pV; + mpView = pView; - if ( IsActive() ) - nRestarts++; + if (IsActive()) + mnRestarts++; - if ( nRestarts > 4 ) + if (mnRestarts > 4) ForceTimeout(); else Start(); @@ -809,36 +813,12 @@ void IdleFormattter::DoIdleFormat( EditView* pV ) void IdleFormattter::ForceTimeout() { - if ( IsActive() ) + if (IsActive()) { Stop(); Invoke(); } } -ImplIMEInfos::ImplIMEInfos( const EditPaM& rPos, const OUString& rOldTextAfterStartPos ) - : aOldTextAfterStartPos( rOldTextAfterStartPos ), - aPos(rPos), - nLen(0), - bWasCursorOverwrite(false) - { - } - -ImplIMEInfos::~ImplIMEInfos() -{ -} - -void ImplIMEInfos::CopyAttribs( const ExtTextInputAttr* pA, sal_uInt16 nL ) -{ - nLen = nL; - pAttribs.reset( new ExtTextInputAttr[ nL ] ); - memcpy( pAttribs.get(), pA, nL*sizeof(ExtTextInputAttr) ); -} - -void ImplIMEInfos::DestroyAttribs() -{ - pAttribs.reset(); - nLen = 0; -} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |