summaryrefslogtreecommitdiff
path: root/editeng/source/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-14 15:58:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-14 20:45:59 +0200
commitd72f963c0de0c2e48f1dc999cd8687e13a1f676f (patch)
tree9f5e314e1f9e504706cc18675f9408fe3c8db8ea /editeng/source/editeng
parent1c3929a0a1645e802ee18f9c3d3d380375500c72 (diff)
loplugin:flatten in editeng
Change-Id: I5c83183d1f9d2d8f5a25b976ead1a7598a75c641 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92197 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng/source/editeng')
-rw-r--r--editeng/source/editeng/editdoc.cxx22
-rw-r--r--editeng/source/editeng/editeng.cxx150
-rw-r--r--editeng/source/editeng/editobj.cxx40
-rw-r--r--editeng/source/editeng/editview.cxx550
-rw-r--r--editeng/source/editeng/eehtml.cxx66
-rw-r--r--editeng/source/editeng/impedit.cxx649
-rw-r--r--editeng/source/editeng/impedit2.cxx354
-rw-r--r--editeng/source/editeng/impedit3.cxx256
-rw-r--r--editeng/source/editeng/impedit4.cxx355
-rw-r--r--editeng/source/editeng/impedit5.cxx68
10 files changed, 1254 insertions, 1256 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 9e9eb17e6177..6fa39bbddaf4 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1825,18 +1825,18 @@ void ContentAttribs::SetStyleSheet( SfxStyleSheet* pS )
bool bStyleChanged = ( pStyle != pS );
pStyle = pS;
// Only when other style sheet, not when current style sheet modified
- if ( pStyle && bStyleChanged )
+ if ( !(pStyle && bStyleChanged) )
+ return;
+
+ // Selectively remove the attributes from the paragraph formatting
+ // which are specified in the style, so that the attributes of the
+ // style can have an affect.
+ const SfxItemSet& rStyleAttribs = pStyle->GetItemSet();
+ for ( sal_uInt16 nWhich = EE_PARA_START; nWhich <= EE_CHAR_END; nWhich++ )
{
- // Selectively remove the attributes from the paragraph formatting
- // which are specified in the style, so that the attributes of the
- // style can have an affect.
- const SfxItemSet& rStyleAttribs = pStyle->GetItemSet();
- for ( sal_uInt16 nWhich = EE_PARA_START; nWhich <= EE_CHAR_END; nWhich++ )
- {
- // Don't change bullet on/off
- if ( ( nWhich != EE_PARA_BULLETSTATE ) && ( rStyleAttribs.GetItemState( nWhich ) == SfxItemState::SET ) )
- aAttribSet.ClearItem( nWhich );
- }
+ // Don't change bullet on/off
+ if ( ( nWhich != EE_PARA_BULLETSTATE ) && ( rStyleAttribs.GetItemState( nWhich ) == SfxItemState::SET ) )
+ aAttribSet.ClearItem( nWhich );
}
}
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 5a6aee022a80..1b76d967b3ba 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -385,31 +385,31 @@ void EditEngine::SetPaperSize( const Size& rNewSize )
Size aNewSize( pImpEditEngine->GetPaperSize() );
bool bAutoPageSize = pImpEditEngine->GetStatus().AutoPageSize();
- if ( bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() ) )
+ if ( !(bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() )) )
+ return;
+
+ for (EditView* pView : pImpEditEngine->aEditViews)
{
- for (EditView* pView : pImpEditEngine->aEditViews)
+ if ( bAutoPageSize )
+ pView->pImpEditView->RecalcOutputArea();
+ else if ( pView->pImpEditView->DoAutoSize() )
{
- if ( bAutoPageSize )
- pView->pImpEditView->RecalcOutputArea();
- else if ( pView->pImpEditView->DoAutoSize() )
- {
- pView->pImpEditView->ResetOutputArea( tools::Rectangle(
- pView->pImpEditView->GetOutputArea().TopLeft(), aNewSize ) );
- }
+ pView->pImpEditView->ResetOutputArea( tools::Rectangle(
+ pView->pImpEditView->GetOutputArea().TopLeft(), aNewSize ) );
}
+ }
- if ( bAutoPageSize || pImpEditEngine->IsFormatted() )
- {
- // Changing the width has no effect for AutoPageSize, as this is
- // determined by the text width.
- // Optimization first after Vobis delivery was enabled ...
- pImpEditEngine->FormatFullDoc();
+ if ( bAutoPageSize || pImpEditEngine->IsFormatted() )
+ {
+ // Changing the width has no effect for AutoPageSize, as this is
+ // determined by the text width.
+ // Optimization first after Vobis delivery was enabled ...
+ pImpEditEngine->FormatFullDoc();
- pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
+ pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
- if ( pImpEditEngine->GetUpdateMode() && pImpEditEngine->GetActiveView() )
- pImpEditEngine->pActiveView->ShowCursor( false, false );
- }
+ if ( pImpEditEngine->GetUpdateMode() && pImpEditEngine->GetActiveView() )
+ pImpEditEngine->pActiveView->ShowCursor( false, false );
}
}
@@ -1843,72 +1843,72 @@ bool EditEngine::IsFlatMode() const
void EditEngine::SetControlWord( EEControlBits nWord )
{
- if ( nWord != pImpEditEngine->aStatus.GetControlWord() )
- {
- EEControlBits nPrev = pImpEditEngine->aStatus.GetControlWord();
- pImpEditEngine->aStatus.GetControlWord() = nWord;
+ if ( nWord == pImpEditEngine->aStatus.GetControlWord() )
+ return;
- EEControlBits nChanges = nPrev ^ nWord;
- if ( pImpEditEngine->IsFormatted() )
+ EEControlBits nPrev = pImpEditEngine->aStatus.GetControlWord();
+ pImpEditEngine->aStatus.GetControlWord() = nWord;
+
+ EEControlBits nChanges = nPrev ^ nWord;
+ if ( pImpEditEngine->IsFormatted() )
+ {
+ // possibly reformat:
+ if ( ( nChanges & EEControlBits::USECHARATTRIBS ) ||
+ ( nChanges & EEControlBits::ONECHARPERLINE ) ||
+ ( nChanges & EEControlBits::STRETCHING ) ||
+ ( nChanges & EEControlBits::OUTLINER ) ||
+ ( nChanges & EEControlBits::NOCOLORS ) ||
+ ( nChanges & EEControlBits::OUTLINER2 ) )
{
- // possibly reformat:
- if ( ( nChanges & EEControlBits::USECHARATTRIBS ) ||
- ( nChanges & EEControlBits::ONECHARPERLINE ) ||
- ( nChanges & EEControlBits::STRETCHING ) ||
- ( nChanges & EEControlBits::OUTLINER ) ||
- ( nChanges & EEControlBits::NOCOLORS ) ||
- ( nChanges & EEControlBits::OUTLINER2 ) )
+ if ( nChanges & EEControlBits::USECHARATTRIBS )
{
- if ( nChanges & EEControlBits::USECHARATTRIBS )
- {
- pImpEditEngine->GetEditDoc().CreateDefFont( true );
- }
-
- pImpEditEngine->FormatFullDoc();
- pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
+ pImpEditEngine->GetEditDoc().CreateDefFont( true );
}
+
+ pImpEditEngine->FormatFullDoc();
+ pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
}
+ }
- bool bSpellingChanged = bool(nChanges & EEControlBits::ONLINESPELLING);
+ bool bSpellingChanged = bool(nChanges & EEControlBits::ONLINESPELLING);
+
+ if ( !bSpellingChanged )
+ return;
- if ( bSpellingChanged )
+ pImpEditEngine->StopOnlineSpellTimer();
+ if (nWord & EEControlBits::ONLINESPELLING)
+ {
+ // Create WrongList, start timer...
+ sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
+ for ( sal_Int32 n = 0; n < nNodes; n++ )
{
- pImpEditEngine->StopOnlineSpellTimer();
- if (nWord & EEControlBits::ONLINESPELLING)
- {
- // Create WrongList, start timer...
- sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
- for ( sal_Int32 n = 0; n < nNodes; n++ )
- {
- ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
- pNode->CreateWrongList();
- }
- if (pImpEditEngine->IsFormatted())
- pImpEditEngine->StartOnlineSpellTimer();
- }
- else
+ ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
+ pNode->CreateWrongList();
+ }
+ if (pImpEditEngine->IsFormatted())
+ pImpEditEngine->StartOnlineSpellTimer();
+ }
+ else
+ {
+ long nY = 0;
+ sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
+ for ( sal_Int32 n = 0; n < nNodes; n++ )
+ {
+ ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
+ const ParaPortion* pPortion = pImpEditEngine->GetParaPortions()[n];
+ bool bWrongs = false;
+ if (pNode->GetWrongList() != nullptr)
+ bWrongs = !pNode->GetWrongList()->empty();
+ pNode->DestroyWrongList();
+ if ( bWrongs )
{
- long nY = 0;
- sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
- for ( sal_Int32 n = 0; n < nNodes; n++ )
- {
- ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
- const ParaPortion* pPortion = pImpEditEngine->GetParaPortions()[n];
- bool bWrongs = false;
- if (pNode->GetWrongList() != nullptr)
- bWrongs = !pNode->GetWrongList()->empty();
- pNode->DestroyWrongList();
- if ( bWrongs )
- {
- pImpEditEngine->aInvalidRect.SetLeft( 0 );
- pImpEditEngine->aInvalidRect.SetRight( pImpEditEngine->GetPaperSize().Width() );
- pImpEditEngine->aInvalidRect.SetTop( nY+1 );
- pImpEditEngine->aInvalidRect.SetBottom( nY+pPortion->GetHeight()-1 );
- pImpEditEngine->UpdateViews( pImpEditEngine->pActiveView );
- }
- nY += pPortion->GetHeight();
- }
+ pImpEditEngine->aInvalidRect.SetLeft( 0 );
+ pImpEditEngine->aInvalidRect.SetRight( pImpEditEngine->GetPaperSize().Width() );
+ pImpEditEngine->aInvalidRect.SetTop( nY+1 );
+ pImpEditEngine->aInvalidRect.SetBottom( nY+pPortion->GetHeight()-1 );
+ pImpEditEngine->UpdateViews( pImpEditEngine->pActiveView );
}
+ nY += pPortion->GetHeight();
}
}
}
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index ec4e964f83fd..f93d4a6205ad 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -444,26 +444,26 @@ void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const
// from SfxItemPoolUser
void EditTextObjectImpl::ObjectInDestruction(const SfxItemPool& rSfxItemPool)
{
- if(!bOwnerOfPool && pPool == &rSfxItemPool)
- {
- // The pool we are based on gets destructed; get owner of pool by creating own one.
- // No need to call RemoveSfxItemPoolUser(), this is done from the pool's destructor
- // Base new pool on EditEnginePool; it would also be possible to clone the used
- // pool if needed, but only text attributes should be used.
- SfxItemPool* pNewPool = EditEngine::CreatePool();
-
- pNewPool->SetDefaultMetric(pPool->GetMetric(DEF_METRIC));
-
- ContentInfosType aReplaced;
- aReplaced.reserve(aContents.size());
- for (auto const& content : aContents)
- aReplaced.push_back(std::unique_ptr<ContentInfo>(new ContentInfo(*content, *pNewPool)));
- aReplaced.swap(aContents);
-
- // set local variables
- pPool = pNewPool;
- bOwnerOfPool = true;
- }
+ if(!(!bOwnerOfPool && pPool == &rSfxItemPool))
+ return;
+
+ // The pool we are based on gets destructed; get owner of pool by creating own one.
+ // No need to call RemoveSfxItemPoolUser(), this is done from the pool's destructor
+ // Base new pool on EditEnginePool; it would also be possible to clone the used
+ // pool if needed, but only text attributes should be used.
+ SfxItemPool* pNewPool = EditEngine::CreatePool();
+
+ pNewPool->SetDefaultMetric(pPool->GetMetric(DEF_METRIC));
+
+ ContentInfosType aReplaced;
+ aReplaced.reserve(aContents.size());
+ for (auto const& content : aContents)
+ aReplaced.push_back(std::unique_ptr<ContentInfo>(new ContentInfo(*content, *pNewPool)));
+ aReplaced.swap(aContents);
+
+ // set local variables
+ pPool = pNewPool;
+ bOwnerOfPool = true;
}
#if DEBUG_EDIT_ENGINE
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 71f13298f511..531fad3e12c2 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -472,23 +472,23 @@ void EditView::Command( const CommandEvent& rCEvt )
void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bActivate )
{
- if ( pImpEditView->pEditEngine->HasView( this ) )
- {
- // The control word is more important:
- if ( !pImpEditView->DoAutoScroll() )
- bGotoCursor = false;
- pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor );
+ if ( !pImpEditView->pEditEngine->HasView( this ) )
+ return;
- if (pImpEditView->mpViewShell && !bActivate)
- {
- VclPtr<vcl::Window> pParent = pImpEditView->pOutWin->GetParentWithLOKNotifier();
- if (pParent && pParent->GetLOKWindowId() != 0)
- return;
+ // The control word is more important:
+ if ( !pImpEditView->DoAutoScroll() )
+ bGotoCursor = false;
+ pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor );
- static const OString aPayload = OString::boolean(true);
- pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
- pImpEditView->mpViewShell->NotifyOtherViews(LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
- }
+ if (pImpEditView->mpViewShell && !bActivate)
+ {
+ VclPtr<vcl::Window> pParent = pImpEditView->pOutWin->GetParentWithLOKNotifier();
+ if (pParent && pParent->GetLOKWindowId() != 0)
+ return;
+
+ static const OString aPayload = OString::boolean(true);
+ pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
+ pImpEditView->mpViewShell->NotifyOtherViews(LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
}
}
@@ -893,308 +893,308 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aPos, false);
Reference< linguistic2::XSpellChecker1 > xSpeller( pImpEditView->pEditEngine->pImpEditEngine->GetSpeller() );
ESelection aOldSel = GetSelection();
- if ( xSpeller.is() && pImpEditView->IsWrongSpelledWord( aPaM, true ) )
+ if ( !(xSpeller.is() && pImpEditView->IsWrongSpelledWord( aPaM, true )) )
+ return;
+
+ VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "editeng/ui/spellmenu.ui", "");
+ VclPtr<PopupMenu> aPopupMenu(aBuilder.get_menu("menu"));
+ const sal_uInt16 nAutoCorrId = aPopupMenu->GetItemId("autocorrect");
+ PopupMenu *pAutoMenu = aPopupMenu->GetPopupMenu(nAutoCorrId);
+ const sal_uInt16 nInsertId = aPopupMenu->GetItemId("insert");
+ PopupMenu *pInsertMenu = aPopupMenu->GetPopupMenu(nInsertId); // add word to user-dictionaries
+ pInsertMenu->SetMenuFlags( MenuFlags::NoAutoMnemonics ); //! necessary to retrieve the correct dictionary names later
+ const sal_uInt16 nAddId = aPopupMenu->GetItemId("add");
+ const sal_uInt16 nIgnoreId = aPopupMenu->GetItemId("ignore");
+ const sal_uInt16 nCheckId = aPopupMenu->GetItemId("check");
+ const sal_uInt16 nAutoCorrectDlgId = aPopupMenu->GetItemId("autocorrectdlg");
+
+ EditPaM aPaM2( aPaM );
+ aPaM2.SetIndex( aPaM2.GetIndex()+1 );
+
+ // Are there any replace suggestions?
+ OUString aSelected( GetSelected() );
+
+ // restrict the maximal number of suggestions displayed
+ // in the context menu.
+ // Note: That could of course be done by clipping the
+ // resulting sequence but the current third party
+ // implementations result differs greatly if the number of
+ // suggestions to be returned gets changed. Statistically
+ // it gets much better if told to return e.g. only 7 strings
+ // than returning e.g. 16 suggestions and using only the
+ // first 7. Thus we hand down the value to use to that
+ // implementation here by providing an additional parameter.
+ Sequence< PropertyValue > aPropVals(1);
+ PropertyValue &rVal = aPropVals.getArray()[0];
+ rVal.Name = UPN_MAX_NUMBER_OF_SUGGESTIONS;
+ rVal.Value <<= sal_Int16(7);
+
+ // Are there any replace suggestions?
+ Reference< linguistic2::XSpellAlternatives > xSpellAlt =
+ xSpeller->spell( aSelected, static_cast<sal_uInt16>(pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 )), aPropVals );
+
+ Reference< linguistic2::XLanguageGuessing > xLangGuesser( EditDLL::Get().GetGlobalData()->GetLanguageGuesser() );
+
+ // check if text might belong to a different language...
+ LanguageType nGuessLangWord = LANGUAGE_NONE;
+ LanguageType nGuessLangPara = LANGUAGE_NONE;
+ if (xSpellAlt.is() && xLangGuesser.is())
{
- VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "editeng/ui/spellmenu.ui", "");
- VclPtr<PopupMenu> aPopupMenu(aBuilder.get_menu("menu"));
- const sal_uInt16 nAutoCorrId = aPopupMenu->GetItemId("autocorrect");
- PopupMenu *pAutoMenu = aPopupMenu->GetPopupMenu(nAutoCorrId);
- const sal_uInt16 nInsertId = aPopupMenu->GetItemId("insert");
- PopupMenu *pInsertMenu = aPopupMenu->GetPopupMenu(nInsertId); // add word to user-dictionaries
- pInsertMenu->SetMenuFlags( MenuFlags::NoAutoMnemonics ); //! necessary to retrieve the correct dictionary names later
- const sal_uInt16 nAddId = aPopupMenu->GetItemId("add");
- const sal_uInt16 nIgnoreId = aPopupMenu->GetItemId("ignore");
- const sal_uInt16 nCheckId = aPopupMenu->GetItemId("check");
- const sal_uInt16 nAutoCorrectDlgId = aPopupMenu->GetItemId("autocorrectdlg");
-
- EditPaM aPaM2( aPaM );
- aPaM2.SetIndex( aPaM2.GetIndex()+1 );
-
- // Are there any replace suggestions?
- OUString aSelected( GetSelected() );
-
- // restrict the maximal number of suggestions displayed
- // in the context menu.
- // Note: That could of course be done by clipping the
- // resulting sequence but the current third party
- // implementations result differs greatly if the number of
- // suggestions to be returned gets changed. Statistically
- // it gets much better if told to return e.g. only 7 strings
- // than returning e.g. 16 suggestions and using only the
- // first 7. Thus we hand down the value to use to that
- // implementation here by providing an additional parameter.
- Sequence< PropertyValue > aPropVals(1);
- PropertyValue &rVal = aPropVals.getArray()[0];
- rVal.Name = UPN_MAX_NUMBER_OF_SUGGESTIONS;
- rVal.Value <<= sal_Int16(7);
-
- // Are there any replace suggestions?
- Reference< linguistic2::XSpellAlternatives > xSpellAlt =
- xSpeller->spell( aSelected, static_cast<sal_uInt16>(pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 )), aPropVals );
-
- Reference< linguistic2::XLanguageGuessing > xLangGuesser( EditDLL::Get().GetGlobalData()->GetLanguageGuesser() );
-
- // check if text might belong to a different language...
- LanguageType nGuessLangWord = LANGUAGE_NONE;
- LanguageType nGuessLangPara = LANGUAGE_NONE;
- if (xSpellAlt.is() && xLangGuesser.is())
+ OUString aParaText;
+ ContentNode *pNode = aPaM.GetNode();
+ if (pNode)
{
- OUString aParaText;
- ContentNode *pNode = aPaM.GetNode();
- if (pNode)
- {
- aParaText = pNode->GetString();
- }
- else
- {
- OSL_FAIL( "content node is NULL" );
- }
-
- nGuessLangWord = CheckLanguage( xSpellAlt->getWord(), xSpeller, xLangGuesser, false );
- nGuessLangPara = CheckLanguage( aParaText, xSpeller, xLangGuesser, true );
+ aParaText = pNode->GetString();
}
- if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
+ else
{
- // make sure LANGUAGE_NONE gets not used as menu entry
- if (nGuessLangWord == LANGUAGE_NONE)
- nGuessLangWord = nGuessLangPara;
- if (nGuessLangPara == LANGUAGE_NONE)
- nGuessLangPara = nGuessLangWord;
-
- aPopupMenu->InsertSeparator();
- OUString aTmpWord( SvtLanguageTable::GetLanguageString( nGuessLangWord ) );
- OUString aTmpPara( SvtLanguageTable::GetLanguageString( nGuessLangPara ) );
- OUString aWordStr( EditResId( RID_STR_WORD ) );
- aWordStr = aWordStr.replaceFirst( "%x", aTmpWord );
- OUString aParaStr( EditResId( RID_STR_PARAGRAPH ) );
- aParaStr = aParaStr.replaceFirst( "%x", aTmpPara );
- aPopupMenu->InsertItem( MN_WORDLANGUAGE, aWordStr );
- aPopupMenu->SetHelpId( MN_WORDLANGUAGE, HID_EDITENG_SPELLER_WORDLANGUAGE );
- aPopupMenu->InsertItem( MN_PARALANGUAGE, aParaStr );
- aPopupMenu->SetHelpId( MN_PARALANGUAGE, HID_EDITENG_SPELLER_PARALANGUAGE );
+ OSL_FAIL( "content node is NULL" );
}
- // ## Create mnemonics here
- aPopupMenu->CreateAutoMnemonics();
- aPopupMenu->SetMenuFlags(aPopupMenu->GetMenuFlags() | MenuFlags::NoAutoMnemonics);
-
- // Replace suggestions...
- Sequence< OUString > aAlt;
- if (xSpellAlt.is())
- aAlt = xSpellAlt->getAlternatives();
- const OUString *pAlt = aAlt.getConstArray();
- sal_uInt16 nWords = static_cast<sal_uInt16>(aAlt.getLength());
- if ( nWords )
+ nGuessLangWord = CheckLanguage( xSpellAlt->getWord(), xSpeller, xLangGuesser, false );
+ nGuessLangPara = CheckLanguage( aParaText, xSpeller, xLangGuesser, true );
+ }
+ if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
+ {
+ // make sure LANGUAGE_NONE gets not used as menu entry
+ if (nGuessLangWord == LANGUAGE_NONE)
+ nGuessLangWord = nGuessLangPara;
+ if (nGuessLangPara == LANGUAGE_NONE)
+ nGuessLangPara = nGuessLangWord;
+
+ aPopupMenu->InsertSeparator();
+ OUString aTmpWord( SvtLanguageTable::GetLanguageString( nGuessLangWord ) );
+ OUString aTmpPara( SvtLanguageTable::GetLanguageString( nGuessLangPara ) );
+ OUString aWordStr( EditResId( RID_STR_WORD ) );
+ aWordStr = aWordStr.replaceFirst( "%x", aTmpWord );
+ OUString aParaStr( EditResId( RID_STR_PARAGRAPH ) );
+ aParaStr = aParaStr.replaceFirst( "%x", aTmpPara );
+ aPopupMenu->InsertItem( MN_WORDLANGUAGE, aWordStr );
+ aPopupMenu->SetHelpId( MN_WORDLANGUAGE, HID_EDITENG_SPELLER_WORDLANGUAGE );
+ aPopupMenu->InsertItem( MN_PARALANGUAGE, aParaStr );
+ aPopupMenu->SetHelpId( MN_PARALANGUAGE, HID_EDITENG_SPELLER_PARALANGUAGE );
+ }
+
+ // ## Create mnemonics here
+ aPopupMenu->CreateAutoMnemonics();
+ aPopupMenu->SetMenuFlags(aPopupMenu->GetMenuFlags() | MenuFlags::NoAutoMnemonics);
+
+ // Replace suggestions...
+ Sequence< OUString > aAlt;
+ if (xSpellAlt.is())
+ aAlt = xSpellAlt->getAlternatives();
+ const OUString *pAlt = aAlt.getConstArray();
+ sal_uInt16 nWords = static_cast<sal_uInt16>(aAlt.getLength());
+ if ( nWords )
+ {
+ for ( sal_uInt16 nW = 0; nW < nWords; nW++ )
{
- for ( sal_uInt16 nW = 0; nW < nWords; nW++ )
- {
- OUString aAlternate( pAlt[nW] );
- aPopupMenu->InsertItem( MN_ALTSTART+nW, aAlternate, MenuItemBits::NONE, OString(), nW );
- pAutoMenu->InsertItem( MN_AUTOSTART+nW, aAlternate, MenuItemBits::NONE, OString(), nW );
- }
- aPopupMenu->InsertSeparator(OString(), nWords);
+ OUString aAlternate( pAlt[nW] );
+ aPopupMenu->InsertItem( MN_ALTSTART+nW, aAlternate, MenuItemBits::NONE, OString(), nW );
+ pAutoMenu->InsertItem( MN_AUTOSTART+nW, aAlternate, MenuItemBits::NONE, OString(), nW );
}
- else
- aPopupMenu->RemoveItem(nAutoCorrId); // delete?
+ aPopupMenu->InsertSeparator(OString(), nWords);
+ }
+ else
+ aPopupMenu->RemoveItem(nAutoCorrId); // delete?
- SvtLinguConfig aCfg;
+ SvtLinguConfig aCfg;
- Reference< linguistic2::XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
- Sequence< Reference< linguistic2::XDictionary > > aDics;
- if (xDicList.is())
+ Reference< linguistic2::XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
+ Sequence< Reference< linguistic2::XDictionary > > aDics;
+ if (xDicList.is())
+ {
+ const Reference< linguistic2::XDictionary > *pDic = nullptr;
+ // add the default positive dictionary to dic-list (if not already done).
+ // This is to ensure that there is at least one dictionary to which
+ // words could be added.
+ uno::Reference< linguistic2::XDictionary > xDic( LinguMgr::GetStandardDic() );
+ if (xDic.is())
+ xDic->setActive( true );
+
+ aDics = xDicList->getDictionaries();
+ pDic = aDics.getConstArray();
+ LanguageType nCheckedLanguage = pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 );
+ sal_uInt16 nDicCount = static_cast<sal_uInt16>(aDics.getLength());
+ for (sal_uInt16 i = 0; i < nDicCount; i++)
{
- const Reference< linguistic2::XDictionary > *pDic = nullptr;
- // add the default positive dictionary to dic-list (if not already done).
- // This is to ensure that there is at least one dictionary to which
- // words could be added.
- uno::Reference< linguistic2::XDictionary > xDic( LinguMgr::GetStandardDic() );
- if (xDic.is())
- xDic->setActive( true );
-
- aDics = xDicList->getDictionaries();
- pDic = aDics.getConstArray();
- LanguageType nCheckedLanguage = pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 );
- sal_uInt16 nDicCount = static_cast<sal_uInt16>(aDics.getLength());
- for (sal_uInt16 i = 0; i < nDicCount; i++)
+ uno::Reference< linguistic2::XDictionary > xDicTmp = pDic[i];
+ if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp)
+ continue;
+
+ uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
+ LanguageType nActLanguage = LanguageTag( xDicTmp->getLocale() ).getLanguageType();
+ if( xDicTmp->isActive()
+ && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
+ && (nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
+ && (!xStor.is() || !xStor->isReadonly()) )
{
- uno::Reference< linguistic2::XDictionary > xDicTmp = pDic[i];
- if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp)
- continue;
-
- uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
- LanguageType nActLanguage = LanguageTag( xDicTmp->getLocale() ).getLanguageType();
- if( xDicTmp->isActive()
- && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
- && (nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
- && (!xStor.is() || !xStor->isReadonly()) )
+ // the extra 1 is because of the (possible) external
+ // linguistic entry above
+ sal_uInt16 nPos = MN_DICTSTART + i;
+ pInsertMenu->InsertItem( nPos, xDicTmp->getName() );
+ aDicNameSingle = xDicTmp->getName();
+
+ uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
+ if (xSvcInfo.is())
{
- // the extra 1 is because of the (possible) external
- // linguistic entry above
- sal_uInt16 nPos = MN_DICTSTART + i;
- pInsertMenu->InsertItem( nPos, xDicTmp->getName() );
- aDicNameSingle = xDicTmp->getName();
-
- uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
- if (xSvcInfo.is())
+ OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
+ xSvcInfo->getImplementationName()) );
+ if (!aDictionaryImageUrl.isEmpty() )
{
- OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
- xSvcInfo->getImplementationName()) );
- if (!aDictionaryImageUrl.isEmpty() )
- {
- Image aImage( aDictionaryImageUrl );
- pInsertMenu->SetItemImage( nPos, aImage );
- }
+ Image aImage( aDictionaryImageUrl );
+ pInsertMenu->SetItemImage( nPos, aImage );
}
}
}
}
+ }
- if (pInsertMenu->GetItemCount() != 1)
- aPopupMenu->EnableItem(nAddId, false);
- if (pInsertMenu->GetItemCount() < 2)
- aPopupMenu->EnableItem(nInsertId, false);
+ if (pInsertMenu->GetItemCount() != 1)
+ aPopupMenu->EnableItem(nAddId, false);
+ if (pInsertMenu->GetItemCount() < 2)
+ aPopupMenu->EnableItem(nInsertId, false);
- aPopupMenu->RemoveDisabledEntries( true, true );
+ aPopupMenu->RemoveDisabledEntries( true, true );
- tools::Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly );
- Point aScreenPos = pImpEditView->GetWindowPos( aTempRect.TopLeft() );
- aScreenPos = pImpEditView->GetWindow()->OutputToScreenPixel( aScreenPos );
- aTempRect = pImpEditView->GetWindow()->LogicToPixel( tools::Rectangle(aScreenPos, aTempRect.GetSize() ));
+ tools::Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly );
+ Point aScreenPos = pImpEditView->GetWindowPos( aTempRect.TopLeft() );
+ aScreenPos = pImpEditView->GetWindow()->OutputToScreenPixel( aScreenPos );
+ aTempRect = pImpEditView->GetWindow()->LogicToPixel( tools::Rectangle(aScreenPos, aTempRect.GetSize() ));
- //tdf#106123 store and restore the EditPaM around the menu Execute
- //because the loss of focus in the current editeng causes writer
- //annotations to save their contents, making the pContent of the
- //current EditPams invalid
- EPaM aP = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM);
- EPaM aP2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM2);
+ //tdf#106123 store and restore the EditPaM around the menu Execute
+ //because the loss of focus in the current editeng causes writer
+ //annotations to save their contents, making the pContent of the
+ //current EditPams invalid
+ EPaM aP = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM);
+ EPaM aP2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM2);
- if (comphelper::LibreOfficeKit::isActive())
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ // For mobile phones, send the context menu structure
+ if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
{
- // For mobile phones, send the context menu structure
- if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
- {
- LOKSendSpellPopupMenu(aPopupMenu, nGuessLangWord, nGuessLangPara, nWords);
- return;
- }
- else // For desktop and tablets, we use the tunneled dialog
- aPopupMenu->SetLOKNotifier(SfxViewShell::Current());
+ LOKSendSpellPopupMenu(aPopupMenu, nGuessLangWord, nGuessLangPara, nWords);
+ return;
}
- sal_uInt16 nId = aPopupMenu->Execute(pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose);
+ else // For desktop and tablets, we use the tunneled dialog
+ aPopupMenu->SetLOKNotifier(SfxViewShell::Current());
+ }
+ sal_uInt16 nId = aPopupMenu->Execute(pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose);
- aPaM2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP2);
- aPaM = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP);
+ aPaM2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP2);
+ aPaM = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP);
- if (nId == nIgnoreId)
- {
- OUString aWord = pImpEditView->SpellIgnoreWord();
- if ( pCallBack )
- {
- SpellCallbackInfo aInf( SpellCallbackCommand::IGNOREWORD, aWord );
- pCallBack->Call( aInf );
- }
- SetSelection( aOldSel );
- }
- else if ( ( nId == MN_WORDLANGUAGE ) || ( nId == MN_PARALANGUAGE ) )
+ if (nId == nIgnoreId)
+ {
+ OUString aWord = pImpEditView->SpellIgnoreWord();
+ if ( pCallBack )
{
- LanguageType nLangToUse = (nId == MN_WORDLANGUAGE) ? nGuessLangWord : nGuessLangPara;
- SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse );
-
- SfxItemSet aAttrs = GetEditEngine()->GetEmptyItemSet();
- if (nScriptType == SvtScriptType::LATIN)
- aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
- if (nScriptType == SvtScriptType::COMPLEX)
- aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
- if (nScriptType == SvtScriptType::ASIAN)
- aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
- if ( nId == MN_PARALANGUAGE )
- {
- ESelection aSel = GetSelection();
- aSel.nStartPos = 0;
- aSel.nEndPos = EE_TEXTPOS_ALL;
- SetSelection( aSel );
- }
- SetAttribs( aAttrs );
- pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
-
- if ( pCallBack )
- {
- SpellCallbackInfo aInf( ( nId == MN_WORDLANGUAGE ) ? SpellCallbackCommand::WORDLANGUAGE : SpellCallbackCommand::PARALANGUAGE );
- pCallBack->Call( aInf );
- }
- SetSelection( aOldSel );
+ SpellCallbackInfo aInf( SpellCallbackCommand::IGNOREWORD, aWord );
+ pCallBack->Call( aInf );
}
- else if (nId == nCheckId)
+ SetSelection( aOldSel );
+ }
+ else if ( ( nId == MN_WORDLANGUAGE ) || ( nId == MN_PARALANGUAGE ) )
+ {
+ LanguageType nLangToUse = (nId == MN_WORDLANGUAGE) ? nGuessLangWord : nGuessLangPara;
+ SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse );
+
+ SfxItemSet aAttrs = GetEditEngine()->GetEmptyItemSet();
+ if (nScriptType == SvtScriptType::LATIN)
+ aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
+ if (nScriptType == SvtScriptType::COMPLEX)
+ aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
+ if (nScriptType == SvtScriptType::ASIAN)
+ aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
+ if ( nId == MN_PARALANGUAGE )
{
- if ( !pCallBack )
- {
- // Set Cursor before word...
- EditPaM aCursor = pImpEditView->GetEditSelection().Min();
- pImpEditView->DrawSelectionXOR();
- pImpEditView->SetEditSelection( EditSelection( aCursor, aCursor ) );
- pImpEditView->DrawSelectionXOR();
- // Crashes when no SfxApp
- pImpEditView->pEditEngine->pImpEditEngine->Spell( this, false );
- }
- else
- {
- SpellCallbackInfo aInf( SpellCallbackCommand::STARTSPELLDLG, OUString() );
- pCallBack->Call( aInf );
- }
+ ESelection aSel = GetSelection();
+ aSel.nStartPos = 0;
+ aSel.nEndPos = EE_TEXTPOS_ALL;
+ SetSelection( aSel );
}
- else if (nId == nAutoCorrectDlgId && pCallBack)
+ SetAttribs( aAttrs );
+ pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
+
+ if ( pCallBack )
{
- SpellCallbackInfo aInf( SpellCallbackCommand::AUTOCORRECT_OPTIONS, OUString() );
+ SpellCallbackInfo aInf( ( nId == MN_WORDLANGUAGE ) ? SpellCallbackCommand::WORDLANGUAGE : SpellCallbackCommand::PARALANGUAGE );
pCallBack->Call( aInf );
}
- else if ( nId >= MN_DICTSTART || nId == nAddId)
- {
- OUString aDicName;
- if (nId >= MN_DICTSTART)
- aDicName = pInsertMenu->GetItemText(nId);
- else
- aDicName = aDicNameSingle;
-
- uno::Reference< linguistic2::XDictionary > xDic;
- if (xDicList.is())
- xDic = xDicList->getDictionaryByName( aDicName );
-
- if (xDic.is())
- xDic->add( aSelected, false, OUString() );
- // save modified user-dictionary if it is persistent
- Reference< frame::XStorable > xSavDic( xDic, UNO_QUERY );
- if (xSavDic.is())
- xSavDic->store();
-
- aPaM.GetNode()->GetWrongList()->ResetInvalidRange(0, aPaM.GetNode()->Len());
- pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
-
- if ( pCallBack )
- {
- SpellCallbackInfo aInf( SpellCallbackCommand::ADDTODICTIONARY, aSelected );
- pCallBack->Call( aInf );
- }
- SetSelection( aOldSel );
- }
- else if ( nId >= MN_AUTOSTART )
+ SetSelection( aOldSel );
+ }
+ else if (nId == nCheckId)
+ {
+ if ( !pCallBack )
{
- DBG_ASSERT(nId - MN_AUTOSTART < aAlt.getLength(), "index out of range");
- OUString aWord = pAlt[nId - MN_AUTOSTART];
- SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
- if ( pAutoCorrect )
- pAutoCorrect->PutText( aSelected, aWord, pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 ) );
- InsertText( aWord );
+ // Set Cursor before word...
+ EditPaM aCursor = pImpEditView->GetEditSelection().Min();
+ pImpEditView->DrawSelectionXOR();
+ pImpEditView->SetEditSelection( EditSelection( aCursor, aCursor ) );
+ pImpEditView->DrawSelectionXOR();
+ // Crashes when no SfxApp
+ pImpEditView->pEditEngine->pImpEditEngine->Spell( this, false );
}
- else if ( nId >= MN_ALTSTART ) // Replace
+ else
{
- DBG_ASSERT(nId - MN_ALTSTART < aAlt.getLength(), "index out of range");
- OUString aWord = pAlt[nId - MN_ALTSTART];
- InsertText( aWord );
+ SpellCallbackInfo aInf( SpellCallbackCommand::STARTSPELLDLG, OUString() );
+ pCallBack->Call( aInf );
}
+ }
+ else if (nId == nAutoCorrectDlgId && pCallBack)
+ {
+ SpellCallbackInfo aInf( SpellCallbackCommand::AUTOCORRECT_OPTIONS, OUString() );
+ pCallBack->Call( aInf );
+ }
+ else if ( nId >= MN_DICTSTART || nId == nAddId)
+ {
+ OUString aDicName;
+ if (nId >= MN_DICTSTART)
+ aDicName = pInsertMenu->GetItemText(nId);
else
+ aDicName = aDicNameSingle;
+
+ uno::Reference< linguistic2::XDictionary > xDic;
+ if (xDicList.is())
+ xDic = xDicList->getDictionaryByName( aDicName );
+
+ if (xDic.is())
+ xDic->add( aSelected, false, OUString() );
+ // save modified user-dictionary if it is persistent
+ Reference< frame::XStorable > xSavDic( xDic, UNO_QUERY );
+ if (xSavDic.is())
+ xSavDic->store();
+
+ aPaM.GetNode()->GetWrongList()->ResetInvalidRange(0, aPaM.GetNode()->Len());
+ pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
+
+ if ( pCallBack )
{
- SetSelection( aOldSel );
+ SpellCallbackInfo aInf( SpellCallbackCommand::ADDTODICTIONARY, aSelected );
+ pCallBack->Call( aInf );
}
+ SetSelection( aOldSel );
+ }
+ else if ( nId >= MN_AUTOSTART )
+ {
+ DBG_ASSERT(nId - MN_AUTOSTART < aAlt.getLength(), "index out of range");
+ OUString aWord = pAlt[nId - MN_AUTOSTART];
+ SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
+ if ( pAutoCorrect )
+ pAutoCorrect->PutText( aSelected, aWord, pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 ) );
+ InsertText( aWord );
+ }
+ else if ( nId >= MN_ALTSTART ) // Replace
+ {
+ DBG_ASSERT(nId - MN_ALTSTART < aAlt.getLength(), "index out of range");
+ OUString aWord = pAlt[nId - MN_ALTSTART];
+ InsertText( aWord );
+ }
+ else
+ {
+ SetSelection( aOldSel );
}
}
diff --git a/editeng/source/editeng/eehtml.cxx b/editeng/source/editeng/eehtml.cxx
index 39fbbb7aa221..ff84bfe4a260 100644
--- a/editeng/source/editeng/eehtml.cxx
+++ b/editeng/source/editeng/eehtml.cxx
@@ -742,48 +742,48 @@ bool EditHTMLParser::HasTextInCurrentPara()
void EditHTMLParser::AnchorStart()
{
// ignore anchor in anchor
- if ( !pCurAnchor )
+ if ( pCurAnchor )
+ return;
+
+ const HTMLOptions& aOptions = GetOptions();
+ OUString aRef;
+
+ for (const auto & aOption : aOptions)
{
- const HTMLOptions& aOptions = GetOptions();
- OUString aRef;
+ if( aOption.GetToken() == HtmlOptionId::HREF)
+ aRef = aOption.GetString();
+ }
- for (const auto & aOption : aOptions)
- {
- if( aOption.GetToken() == HtmlOptionId::HREF)
- aRef = aOption.GetString();
- }
+ if ( aRef.isEmpty() )
+ return;
- if ( !aRef.isEmpty() )
- {
- OUString aURL = aRef;
- if ( !aURL.isEmpty() && ( aURL[ 0 ] != '#' ) )
- {
- INetURLObject aTargetURL;
- INetURLObject aRootURL( aBaseURL );
- aRootURL.GetNewAbsURL( aRef, &aTargetURL );
- aURL = aTargetURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri );
- }
- pCurAnchor.reset( new AnchorInfo );
- pCurAnchor->aHRef = aURL;
- }
+ OUString aURL = aRef;
+ if ( !aURL.isEmpty() && ( aURL[ 0 ] != '#' ) )
+ {
+ INetURLObject aTargetURL;
+ INetURLObject aRootURL( aBaseURL );
+ aRootURL.GetNewAbsURL( aRef, &aTargetURL );
+ aURL = aTargetURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri );
}
+ pCurAnchor.reset( new AnchorInfo );
+ pCurAnchor->aHRef = aURL;
}
void EditHTMLParser::AnchorEnd()
{
- if ( pCurAnchor )
- {
- // Insert as URL-Field...
- SvxFieldItem aFld( SvxURLField( pCurAnchor->aHRef, pCurAnchor->aText, SvxURLFormat::Repr ), EE_FEATURE_FIELD );
- aCurSel = mpEditEngine->InsertField(aCurSel, aFld);
- bFieldsInserted = true;
- pCurAnchor.reset();
+ if ( !pCurAnchor )
+ return;
- if (mpEditEngine->IsHtmlImportHandlerSet())
- {
- HtmlImportInfo aImportInfo(HtmlImportState::InsertField, this, mpEditEngine->CreateESelection(aCurSel));
- mpEditEngine->CallHtmlImportHandler(aImportInfo);
- }
+ // Insert as URL-Field...
+ SvxFieldItem aFld( SvxURLField( pCurAnchor->aHRef, pCurAnchor->aText, SvxURLFormat::Repr ), EE_FEATURE_FIELD );
+ aCurSel = mpEditEngine->InsertField(aCurSel, aFld);
+ bFieldsInserted = true;
+ pCurAnchor.reset();
+
+ if (mpEditEngine->IsHtmlImportHandlerSet())
+ {
+ HtmlImportInfo aImportInfo(HtmlImportState::InsertField, this, mpEditEngine->CreateESelection(aCurSel));
+ mpEditEngine->CallHtmlImportHandler(aImportInfo);
}
}
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 7616a6dc9ae7..e0ee7a52b24d 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -160,26 +160,26 @@ static void lcl_translateTwips(vcl::Window const & rParent, vcl::Window& rChild)
// This prevents multiple translate calls that negate
// one another.
const Point aOrigin = rChild.GetMapMode().GetOrigin();
- if (aOrigin.getX() == 0 && aOrigin.getY() == 0)
+ if (!(aOrigin.getX() == 0 && aOrigin.getY() == 0))
+ return;
+
+ // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones.
+ Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
+ if (!rChild.IsMapModeEnabled())
{
- // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones.
- Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
- if (!rChild.IsMapModeEnabled())
- {
- MapMode aMapMode(rChild.GetMapMode());
- aMapMode.SetMapUnit(MapUnit::MapTwip);
- aMapMode.SetScaleX(rParent.GetMapMode().GetScaleX());
- aMapMode.SetScaleY(rParent.GetMapMode().GetScaleY());
- rChild.SetMapMode(aMapMode);
- rChild.EnableMapMode();
- }
- aOffset = rChild.PixelToLogic(aOffset);
MapMode aMapMode(rChild.GetMapMode());
- aMapMode.SetOrigin(aOffset);
- aMapMode.SetMapUnit(rParent.GetMapMode().GetMapUnit());
+ aMapMode.SetMapUnit(MapUnit::MapTwip);
+ aMapMode.SetScaleX(rParent.GetMapMode().GetScaleX());
+ aMapMode.SetScaleY(rParent.GetMapMode().GetScaleY());
rChild.SetMapMode(aMapMode);
- rChild.EnableMapMode(false);
- }
+ rChild.EnableMapMode();
+ }
+ aOffset = rChild.PixelToLogic(aOffset);
+ MapMode aMapMode(rChild.GetMapMode());
+ aMapMode.SetOrigin(aOffset);
+ aMapMode.SetMapUnit(rParent.GetMapMode().GetMapUnit());
+ rChild.SetMapMode(aMapMode);
+ rChild.EnableMapMode(false);
}
// EditView never had a central/secure place to react on SelectionChange since
@@ -524,51 +524,51 @@ void ImpEditView::GetSelectionRectangles(EditSelection aTmpSel, std::vector<tool
void ImpEditView::ImplDrawHighlightRect( OutputDevice* _pTarget, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, tools::PolyPolygon* pPolyPoly )
{
- if ( rDocPosTopLeft.X() != rDocPosBottomRight.X() )
- {
- bool bPixelMode = _pTarget->GetMapMode().GetMapUnit() == MapUnit::MapPixel;
+ if ( rDocPosTopLeft.X() == rDocPosBottomRight.X() )
+ return;
- Point aPnt1( GetWindowPos( rDocPosTopLeft ) );
- Point aPnt2( GetWindowPos( rDocPosBottomRight ) );
+ bool bPixelMode = _pTarget->GetMapMode().GetMapUnit() == MapUnit::MapPixel;
- if ( !IsVertical() )
- {
- lcl_AllignToPixel( aPnt1, _pTarget, +1, 0 );
- lcl_AllignToPixel( aPnt2, _pTarget, 0, ( bPixelMode ? 0 : -1 ) );
- }
- else
- {
- lcl_AllignToPixel( aPnt1, _pTarget, 0, +1 );
- lcl_AllignToPixel( aPnt2, _pTarget, ( bPixelMode ? 0 : +1 ), 0 );
- }
+ Point aPnt1( GetWindowPos( rDocPosTopLeft ) );
+ Point aPnt2( GetWindowPos( rDocPosBottomRight ) );
+
+ if ( !IsVertical() )
+ {
+ lcl_AllignToPixel( aPnt1, _pTarget, +1, 0 );
+ lcl_AllignToPixel( aPnt2, _pTarget, 0, ( bPixelMode ? 0 : -1 ) );
+ }
+ else
+ {
+ lcl_AllignToPixel( aPnt1, _pTarget, 0, +1 );
+ lcl_AllignToPixel( aPnt2, _pTarget, ( bPixelMode ? 0 : +1 ), 0 );
+ }
- tools::Rectangle aRect( aPnt1, aPnt2 );
- if ( pPolyPoly )
+ tools::Rectangle aRect( aPnt1, aPnt2 );
+ if ( pPolyPoly )
+ {
+ tools::Polygon aTmpPoly( 4 );
+ aTmpPoly[0] = aRect.TopLeft();
+ aTmpPoly[1] = aRect.TopRight();
+ aTmpPoly[2] = aRect.BottomRight();
+ aTmpPoly[3] = aRect.BottomLeft();
+ pPolyPoly->Insert( aTmpPoly );
+ }
+ else
+ {
+ vcl::Window* pWindow = dynamic_cast< vcl::Window* >(_pTarget);
+
+ if(pWindow)
{
- tools::Polygon aTmpPoly( 4 );
- aTmpPoly[0] = aRect.TopLeft();
- aTmpPoly[1] = aRect.TopRight();
- aTmpPoly[2] = aRect.BottomRight();
- aTmpPoly[3] = aRect.BottomLeft();
- pPolyPoly->Insert( aTmpPoly );
+ pWindow->Invert( aRect );
}
else
{
- vcl::Window* pWindow = dynamic_cast< vcl::Window* >(_pTarget);
-
- if(pWindow)
- {
- pWindow->Invert( aRect );
- }
- else
- {
- _pTarget->Push(PushFlags::LINECOLOR|PushFlags::FILLCOLOR|PushFlags::RASTEROP);
- _pTarget->SetLineColor();
- _pTarget->SetFillColor(COL_BLACK);
- _pTarget->SetRasterOp(RasterOp::Invert);
- _pTarget->DrawRect(aRect);
- _pTarget->Pop();
- }
+ _pTarget->Push(PushFlags::LINECOLOR|PushFlags::FILLCOLOR|PushFlags::RASTEROP);
+ _pTarget->SetLineColor();
+ _pTarget->SetFillColor(COL_BLACK);
+ _pTarget->SetRasterOp(RasterOp::Invert);
+ _pTarget->DrawRect(aRect);
+ _pTarget->Pop();
}
}
}
@@ -713,54 +713,54 @@ void ImpEditView::ResetOutputArea( const tools::Rectangle& rRect )
SetOutputArea(rRect);
// invalidate surrounding areas if update is true
- if(!aOldArea.IsEmpty() && pEditEngine->pImpEditEngine->GetUpdateMode())
- {
- // #i119885# use grown area if needed; do when getting bigger OR smaller
- const sal_Int32 nMore(DoInvalidateMore() ? GetWindow()->PixelToLogic(Size(nInvMore, 0)).Width() : 0);
+ if(!(!aOldArea.IsEmpty() && pEditEngine->pImpEditEngine->GetUpdateMode()))
+ return;
- if(aOldArea.Left() > aOutArea.Left())
- {
- const tools::Rectangle aRect(aOutArea.Left() - nMore, aOldArea.Top() - nMore, aOldArea.Left(), aOldArea.Bottom() + nMore);
- InvalidateAtWindow(aRect);
- }
- else if(aOldArea.Left() < aOutArea.Left())
- {
- const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Top() - nMore, aOutArea.Left(), aOldArea.Bottom() + nMore);
- InvalidateAtWindow(aRect);
- }
+ // #i119885# use grown area if needed; do when getting bigger OR smaller
+ const sal_Int32 nMore(DoInvalidateMore() ? GetWindow()->PixelToLogic(Size(nInvMore, 0)).Width() : 0);
- if(aOldArea.Right() > aOutArea.Right())
- {
- const tools::Rectangle aRect(aOutArea.Right(), aOldArea.Top() - nMore, aOldArea.Right() + nMore, aOldArea.Bottom() + nMore);
- InvalidateAtWindow(aRect);
- }
- else if(aOldArea.Right() < aOutArea.Right())
- {
- const tools::Rectangle aRect(aOldArea.Right(), aOldArea.Top() - nMore, aOutArea.Right() + nMore, aOldArea.Bottom() + nMore);
- InvalidateAtWindow(aRect);
- }
+ if(aOldArea.Left() > aOutArea.Left())
+ {
+ const tools::Rectangle aRect(aOutArea.Left() - nMore, aOldArea.Top() - nMore, aOldArea.Left(), aOldArea.Bottom() + nMore);
+ InvalidateAtWindow(aRect);
+ }
+ else if(aOldArea.Left() < aOutArea.Left())
+ {
+ const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Top() - nMore, aOutArea.Left(), aOldArea.Bottom() + nMore);
+ InvalidateAtWindow(aRect);
+ }
- if(aOldArea.Top() > aOutArea.Top())
- {
- const tools::Rectangle aRect(aOldArea.Left() - nMore, aOutArea.Top() - nMore, aOldArea.Right() + nMore, aOldArea.Top());
- InvalidateAtWindow(aRect);
- }
- else if(aOldArea.Top() < aOutArea.Top())
- {
- const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Top() - nMore, aOldArea.Right() + nMore, aOutArea.Top());
- InvalidateAtWindow(aRect);
- }
+ if(aOldArea.Right() > aOutArea.Right())
+ {
+ const tools::Rectangle aRect(aOutArea.Right(), aOldArea.Top() - nMore, aOldArea.Right() + nMore, aOldArea.Bottom() + nMore);
+ InvalidateAtWindow(aRect);
+ }
+ else if(aOldArea.Right() < aOutArea.Right())
+ {
+ const tools::Rectangle aRect(aOldArea.Right(), aOldArea.Top() - nMore, aOutArea.Right() + nMore, aOldArea.Bottom() + nMore);
+ InvalidateAtWindow(aRect);
+ }
- if(aOldArea.Bottom() > aOutArea.Bottom())
- {
- const tools::Rectangle aRect(aOldArea.Left() - nMore, aOutArea.Bottom(), aOldArea.Right() + nMore, aOldArea.Bottom() + nMore);
- InvalidateAtWindow(aRect);
- }
- else if(aOldArea.Bottom() < aOutArea.Bottom())
- {
- const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Bottom(), aOldArea.Right() + nMore, aOutArea.Bottom() + nMore);
- InvalidateAtWindow(aRect);
- }
+ if(aOldArea.Top() > aOutArea.Top())
+ {
+ const tools::Rectangle aRect(aOldArea.Left() - nMore, aOutArea.Top() - nMore, aOldArea.Right() + nMore, aOldArea.Top());
+ InvalidateAtWindow(aRect);
+ }
+ else if(aOldArea.Top() < aOutArea.Top())
+ {
+ const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Top() - nMore, aOldArea.Right() + nMore, aOutArea.Top());
+ InvalidateAtWindow(aRect);
+ }
+
+ if(aOldArea.Bottom() > aOutArea.Bottom())
+ {
+ const tools::Rectangle aRect(aOldArea.Left() - nMore, aOutArea.Bottom(), aOldArea.Right() + nMore, aOldArea.Bottom() + nMore);
+ InvalidateAtWindow(aRect);
+ }
+ else if(aOldArea.Bottom() < aOutArea.Bottom())
+ {
+ const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Bottom(), aOldArea.Right() + nMore, aOutArea.Bottom() + nMore);
+ InvalidateAtWindow(aRect);
}
}
@@ -1619,34 +1619,34 @@ bool ImpEditView::IsBulletArea( const Point& rPos, sal_Int32* pPara )
void ImpEditView::CutCopy( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard, bool bCut )
{
- if ( rxClipboard.is() && HasSelection() )
- {
- uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable( GetEditSelection() );
+ if ( !(rxClipboard.is() && HasSelection()) )
+ return;
- {
- SolarMutexReleaser aReleaser;
+ uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable( GetEditSelection() );
- try
- {
- rxClipboard->setContents( xData, nullptr );
+ {
+ SolarMutexReleaser aReleaser;
- // #87756# FlushClipboard, but it would be better to become a TerminateListener to the Desktop and flush on demand...
- uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY );
- if( xFlushableClipboard.is() )
- xFlushableClipboard->flushClipboard();
- }
- catch( const css::uno::Exception& )
- {
- }
+ try
+ {
+ rxClipboard->setContents( xData, nullptr );
- }
+ // #87756# FlushClipboard, but it would be better to become a TerminateListener to the Desktop and flush on demand...
+ uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY );
+ if( xFlushableClipboard.is() )
+ xFlushableClipboard->flushClipboard();
+ }
+ catch( const css::uno::Exception& )
+ {
+ }
- if (bCut)
- {
- pEditEngine->pImpEditEngine->UndoActionStart(EDITUNDO_CUT);
- DeleteSelected();
- pEditEngine->pImpEditEngine->UndoActionEnd();
- }
+ }
+
+ if (bCut)
+ {
+ pEditEngine->pImpEditEngine->UndoActionStart(EDITUNDO_CUT);
+ DeleteSelected();
+ pEditEngine->pImpEditEngine->UndoActionEnd();
}
}
@@ -1870,56 +1870,56 @@ void ImpEditView::HideDDCursor()
void ImpEditView::ShowDDCursor( const tools::Rectangle& rRect )
{
- if ( pDragAndDropInfo && !pDragAndDropInfo->bVisCursor )
- {
- if (pOutWin && pOutWin->GetCursor())
- pOutWin->GetCursor()->Hide();
+ if ( !(pDragAndDropInfo && !pDragAndDropInfo->bVisCursor) )
+ return;
- OutputDevice& rOutDev = getEditViewCallbacks() ? getEditViewCallbacks()->EditViewOutputDevice() : *GetWindow();
- Color aOldFillColor = rOutDev.GetFillColor();
- rOutDev.SetFillColor( Color(4210752) ); // GRAY BRUSH_50, OLDSV, change to DDCursor!
+ if (pOutWin && pOutWin->GetCursor())
+ pOutWin->GetCursor()->Hide();
+
+ OutputDevice& rOutDev = getEditViewCallbacks() ? getEditViewCallbacks()->EditViewOutputDevice() : *GetWindow();
+ Color aOldFillColor = rOutDev.GetFillColor();
+ rOutDev.SetFillColor( Color(4210752) ); // GRAY BRUSH_50, OLDSV, change to DDCursor!
- // Save background ...
- tools::Rectangle aSaveRect( rOutDev.LogicToPixel( rRect ) );
- // prefer to save some more ...
- aSaveRect.AdjustRight(1 );
- aSaveRect.AdjustBottom(1 );
+ // Save background ...
+ tools::Rectangle aSaveRect( rOutDev.LogicToPixel( rRect ) );
+ // prefer to save some more ...
+ aSaveRect.AdjustRight(1 );
+ aSaveRect.AdjustBottom(1 );
#ifdef DBG_UTIL
- Size aNewSzPx( aSaveRect.GetSize() );
+ Size aNewSzPx( aSaveRect.GetSize() );
#endif
- if ( !pDragAndDropInfo->pBackground )
- {
- pDragAndDropInfo->pBackground = VclPtr<VirtualDevice>::Create(rOutDev);
- MapMode aMapMode( rOutDev.GetMapMode() );
- aMapMode.SetOrigin( Point( 0, 0 ) );
- pDragAndDropInfo->pBackground->SetMapMode( aMapMode );
+ if ( !pDragAndDropInfo->pBackground )
+ {
+ pDragAndDropInfo->pBackground = VclPtr<VirtualDevice>::Create(rOutDev);
+ MapMode aMapMode( rOutDev.GetMapMode() );
+ aMapMode.SetOrigin( Point( 0, 0 ) );
+ pDragAndDropInfo->pBackground->SetMapMode( aMapMode );
- }
+ }
#ifdef DBG_UTIL
- Size aCurSzPx( pDragAndDropInfo->pBackground->GetOutputSizePixel() );
- if ( ( aCurSzPx.Width() < aNewSzPx.Width() ) ||( aCurSzPx.Height() < aNewSzPx.Height() ) )
- {
- bool bDone = pDragAndDropInfo->pBackground->SetOutputSizePixel( aNewSzPx );
- DBG_ASSERT( bDone, "Virtual Device broken?" );
- }
+ Size aCurSzPx( pDragAndDropInfo->pBackground->GetOutputSizePixel() );
+ if ( ( aCurSzPx.Width() < aNewSzPx.Width() ) ||( aCurSzPx.Height() < aNewSzPx.Height() ) )
+ {
+ bool bDone = pDragAndDropInfo->pBackground->SetOutputSizePixel( aNewSzPx );
+ DBG_ASSERT( bDone, "Virtual Device broken?" );
+ }
#endif
- aSaveRect = rOutDev.PixelToLogic( aSaveRect );
+ aSaveRect = rOutDev.PixelToLogic( aSaveRect );
- pDragAndDropInfo->pBackground->DrawOutDev( Point(0,0), aSaveRect.GetSize(),
- aSaveRect.TopLeft(), aSaveRect.GetSize(), rOutDev );
- pDragAndDropInfo->aCurSavedCursor = aSaveRect;
+ pDragAndDropInfo->pBackground->DrawOutDev( Point(0,0), aSaveRect.GetSize(),
+ aSaveRect.TopLeft(), aSaveRect.GetSize(), rOutDev );
+ pDragAndDropInfo->aCurSavedCursor = aSaveRect;
- // Draw Cursor...
- rOutDev.DrawRect( rRect );
+ // Draw Cursor...
+ rOutDev.DrawRect( rRect );
- pDragAndDropInfo->bVisCursor = true;
- pDragAndDropInfo->aCurCursor = rRect;
+ pDragAndDropInfo->bVisCursor = true;
+ pDragAndDropInfo->aCurCursor = rRect;
- rOutDev.SetFillColor( aOldFillColor );
- }
+ rOutDev.SetFillColor( aOldFillColor );
}
void ImpEditView::dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent& rDGE)
@@ -1981,27 +1981,26 @@ void ImpEditView::dragGestureRecognized(const css::datatransfer::dnd::DragGestur
}
}
- if ( pDragAndDropInfo )
- {
+ if ( !pDragAndDropInfo )
+ return;
- pDragAndDropInfo->bStarterOfDD = true;
- // Sensitive area to be scrolled.
- Size aSz( 5, 0 );
- aSz = GetWindow()->PixelToLogic( aSz );
- pDragAndDropInfo->nSensibleRange = static_cast<sal_uInt16>(aSz.Width());
- pDragAndDropInfo->nCursorWidth = static_cast<sal_uInt16>(aSz.Width()) / 2;
- pDragAndDropInfo->aBeginDragSel = pEditEngine->pImpEditEngine->CreateESel( aCopySel );
+ pDragAndDropInfo->bStarterOfDD = true;
- uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable(aCopySel);
+ // Sensitive area to be scrolled.
+ Size aSz( 5, 0 );
+ aSz = GetWindow()->PixelToLogic( aSz );
+ pDragAndDropInfo->nSensibleRange = static_cast<sal_uInt16>(aSz.Width());
+ pDragAndDropInfo->nCursorWidth = static_cast<sal_uInt16>(aSz.Width()) / 2;
+ pDragAndDropInfo->aBeginDragSel = pEditEngine->pImpEditEngine->CreateESel( aCopySel );
- sal_Int8 nActions = bReadOnly ? datatransfer::dnd::DNDConstants::ACTION_COPY : datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE;
+ uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable(aCopySel);
- rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, xData, mxDnDListener );
- // If Drag&Move in an Engine, then Copy&Del has to be optional!
- GetCursor()->Hide();
+ sal_Int8 nActions = bReadOnly ? datatransfer::dnd::DNDConstants::ACTION_COPY : datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE;
- }
+ rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, xData, mxDnDListener );
+ // If Drag&Move in an Engine, then Copy&Del has to be optional!
+ GetCursor()->Hide();
}
void ImpEditView::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& rDSDE )
@@ -2011,89 +2010,89 @@ void ImpEditView::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent
DBG_ASSERT( pDragAndDropInfo, "ImpEditView::dragDropEnd: pDragAndDropInfo is NULL!" );
// #123688# Shouldn't happen, but seems to happen...
- if ( pDragAndDropInfo )
+ if ( !pDragAndDropInfo )
+ return;
+
+ if ( !bReadOnly && rDSDE.DropSuccess && !pDragAndDropInfo->bOutlinerMode && ( rDSDE.DropAction & datatransfer::dnd::DNDConstants::ACTION_MOVE ) )
{
- if ( !bReadOnly && rDSDE.DropSuccess && !pDragAndDropInfo->bOutlinerMode && ( rDSDE.DropAction & datatransfer::dnd::DNDConstants::ACTION_MOVE ) )
+ if ( pDragAndDropInfo->bStarterOfDD && pDragAndDropInfo->bDroppedInMe )
{
- if ( pDragAndDropInfo->bStarterOfDD && pDragAndDropInfo->bDroppedInMe )
+ // DropPos: Where was it dropped, irrespective of length.
+ ESelection aDropPos( pDragAndDropInfo->aDropSel.nStartPara, pDragAndDropInfo->aDropSel.nStartPos, pDragAndDropInfo->aDropSel.nStartPara, pDragAndDropInfo->aDropSel.nStartPos );
+ ESelection aToBeDelSel = pDragAndDropInfo->aBeginDragSel;
+ ESelection aNewSel( pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos,
+ pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos );
+ bool bBeforeSelection = aDropPos < pDragAndDropInfo->aBeginDragSel;
+ sal_Int32 nParaDiff = pDragAndDropInfo->aBeginDragSel.nEndPara - pDragAndDropInfo->aBeginDragSel.nStartPara;
+ if ( bBeforeSelection )
{
- // DropPos: Where was it dropped, irrespective of length.
- ESelection aDropPos( pDragAndDropInfo->aDropSel.nStartPara, pDragAndDropInfo->aDropSel.nStartPos, pDragAndDropInfo->aDropSel.nStartPara, pDragAndDropInfo->aDropSel.nStartPos );
- ESelection aToBeDelSel = pDragAndDropInfo->aBeginDragSel;
- ESelection aNewSel( pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos,
- pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos );
- bool bBeforeSelection = aDropPos < pDragAndDropInfo->aBeginDragSel;
- sal_Int32 nParaDiff = pDragAndDropInfo->aBeginDragSel.nEndPara - pDragAndDropInfo->aBeginDragSel.nStartPara;
- if ( bBeforeSelection )
- {
- // Adjust aToBeDelSel.
- DBG_ASSERT( pDragAndDropInfo->aBeginDragSel.nStartPara >= pDragAndDropInfo->aDropSel.nStartPara, "But not before? ");
- aToBeDelSel.nStartPara = aToBeDelSel.nStartPara + nParaDiff;
- aToBeDelSel.nEndPara = aToBeDelSel.nEndPara + nParaDiff;
- // To correct the character?
- if ( aToBeDelSel.nStartPara == pDragAndDropInfo->aDropSel.nEndPara )
- {
- sal_uInt16 nMoreChars;
- if ( pDragAndDropInfo->aDropSel.nStartPara == pDragAndDropInfo->aDropSel.nEndPara )
- nMoreChars = pDragAndDropInfo->aDropSel.nEndPos - pDragAndDropInfo->aDropSel.nStartPos;
- else
- nMoreChars = pDragAndDropInfo->aDropSel.nEndPos;
- aToBeDelSel.nStartPos =
- aToBeDelSel.nStartPos + nMoreChars;
- if ( aToBeDelSel.nStartPara == aToBeDelSel.nEndPara )
- aToBeDelSel.nEndPos =
- aToBeDelSel.nEndPos + nMoreChars;
- }
- }
- else
+ // Adjust aToBeDelSel.
+ DBG_ASSERT( pDragAndDropInfo->aBeginDragSel.nStartPara >= pDragAndDropInfo->aDropSel.nStartPara, "But not before? ");
+ aToBeDelSel.nStartPara = aToBeDelSel.nStartPara + nParaDiff;
+ aToBeDelSel.nEndPara = aToBeDelSel.nEndPara + nParaDiff;
+ // To correct the character?
+ if ( aToBeDelSel.nStartPara == pDragAndDropInfo->aDropSel.nEndPara )
{
- // aToBeDelSel is ok, but the selection of the View
- // has to be adapted, if it was deleted before!
- DBG_ASSERT( pDragAndDropInfo->aBeginDragSel.nStartPara <= pDragAndDropInfo->aDropSel.nStartPara, "But not before? ");
- aNewSel.nStartPara = aNewSel.nStartPara - nParaDiff;
- aNewSel.nEndPara = aNewSel.nEndPara - nParaDiff;
- // To correct the character?
- if ( pDragAndDropInfo->aBeginDragSel.nEndPara == pDragAndDropInfo->aDropSel.nStartPara )
- {
- sal_uInt16 nLessChars;
- if ( pDragAndDropInfo->aBeginDragSel.nStartPara == pDragAndDropInfo->aBeginDragSel.nEndPara )
- nLessChars = pDragAndDropInfo->aBeginDragSel.nEndPos - pDragAndDropInfo->aBeginDragSel.nStartPos;
- else
- nLessChars = pDragAndDropInfo->aBeginDragSel.nEndPos;
- aNewSel.nStartPos = aNewSel.nStartPos - nLessChars;
- if ( aNewSel.nStartPara == aNewSel.nEndPara )
- aNewSel.nEndPos = aNewSel.nEndPos - nLessChars;
- }
+ sal_uInt16 nMoreChars;
+ if ( pDragAndDropInfo->aDropSel.nStartPara == pDragAndDropInfo->aDropSel.nEndPara )
+ nMoreChars = pDragAndDropInfo->aDropSel.nEndPos - pDragAndDropInfo->aDropSel.nStartPos;
+ else
+ nMoreChars = pDragAndDropInfo->aDropSel.nEndPos;
+ aToBeDelSel.nStartPos =
+ aToBeDelSel.nStartPos + nMoreChars;
+ if ( aToBeDelSel.nStartPara == aToBeDelSel.nEndPara )
+ aToBeDelSel.nEndPos =
+ aToBeDelSel.nEndPos + nMoreChars;
}
-
- DrawSelectionXOR();
- EditSelection aDelSel( pEditEngine->pImpEditEngine->CreateSel( aToBeDelSel ) );
- DBG_ASSERT( !aDelSel.DbgIsBuggy( pEditEngine->GetEditDoc() ), "ToBeDel is buggy!" );
- pEditEngine->DeleteSelection(aDelSel);
- if ( !bBeforeSelection )
+ }
+ else
+ {
+ // aToBeDelSel is ok, but the selection of the View
+ // has to be adapted, if it was deleted before!
+ DBG_ASSERT( pDragAndDropInfo->aBeginDragSel.nStartPara <= pDragAndDropInfo->aDropSel.nStartPara, "But not before? ");
+ aNewSel.nStartPara = aNewSel.nStartPara - nParaDiff;
+ aNewSel.nEndPara = aNewSel.nEndPara - nParaDiff;
+ // To correct the character?
+ if ( pDragAndDropInfo->aBeginDragSel.nEndPara == pDragAndDropInfo->aDropSel.nStartPara )
{
- DBG_ASSERT( !pEditEngine->pImpEditEngine->CreateSel( aNewSel ).DbgIsBuggy(pEditEngine->GetEditDoc()), "Bad" );
- SetEditSelection( pEditEngine->pImpEditEngine->CreateSel( aNewSel ) );
+ sal_uInt16 nLessChars;
+ if ( pDragAndDropInfo->aBeginDragSel.nStartPara == pDragAndDropInfo->aBeginDragSel.nEndPara )
+ nLessChars = pDragAndDropInfo->aBeginDragSel.nEndPos - pDragAndDropInfo->aBeginDragSel.nStartPos;
+ else
+ nLessChars = pDragAndDropInfo->aBeginDragSel.nEndPos;
+ aNewSel.nStartPos = aNewSel.nStartPos - nLessChars;
+ if ( aNewSel.nStartPara == aNewSel.nEndPara )
+ aNewSel.nEndPos = aNewSel.nEndPos - nLessChars;
}
- pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
- DrawSelectionXOR();
}
- else
+
+ DrawSelectionXOR();
+ EditSelection aDelSel( pEditEngine->pImpEditEngine->CreateSel( aToBeDelSel ) );
+ DBG_ASSERT( !aDelSel.DbgIsBuggy( pEditEngine->GetEditDoc() ), "ToBeDel is buggy!" );
+ pEditEngine->DeleteSelection(aDelSel);
+ if ( !bBeforeSelection )
{
- // other EditEngine ...
- if (pEditEngine->HasText()) // #88630# SC is removing the content when switching the task
- DeleteSelected();
+ DBG_ASSERT( !pEditEngine->pImpEditEngine->CreateSel( aNewSel ).DbgIsBuggy(pEditEngine->GetEditDoc()), "Bad" );
+ SetEditSelection( pEditEngine->pImpEditEngine->CreateSel( aNewSel ) );
}
+ pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
+ DrawSelectionXOR();
+ }
+ else
+ {
+ // other EditEngine ...
+ if (pEditEngine->HasText()) // #88630# SC is removing the content when switching the task
+ DeleteSelected();
}
+ }
- if ( pDragAndDropInfo->bUndoAction )
- pEditEngine->pImpEditEngine->UndoActionEnd();
+ if ( pDragAndDropInfo->bUndoAction )
+ pEditEngine->pImpEditEngine->UndoActionEnd();
- HideDDCursor();
- ShowCursor( DoAutoScroll(), true );
- pDragAndDropInfo.reset();
- pEditEngine->GetEndDropHdl().Call(GetEditViewPtr());
- }
+ HideDDCursor();
+ ShowCursor( DoAutoScroll(), true );
+ pDragAndDropInfo.reset();
+ pEditEngine->GetEndDropHdl().Call(GetEditViewPtr());
}
void ImpEditView::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE )
@@ -2102,70 +2101,70 @@ void ImpEditView::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE
DBG_ASSERT( pDragAndDropInfo, "Drop - No Drag&Drop info?!" );
- if ( pDragAndDropInfo && pDragAndDropInfo->bDragAccepted )
- {
- pEditEngine->GetBeginDropHdl().Call(GetEditViewPtr());
- bool bChanges = false;
+ if ( !(pDragAndDropInfo && pDragAndDropInfo->bDragAccepted) )
+ return;
- HideDDCursor();
+ pEditEngine->GetBeginDropHdl().Call(GetEditViewPtr());
+ bool bChanges = false;
- if ( pDragAndDropInfo->bStarterOfDD )
- {
- pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_DRAGANDDROP );
- pDragAndDropInfo->bUndoAction = true;
- }
+ HideDDCursor();
+
+ if ( pDragAndDropInfo->bStarterOfDD )
+ {
+ pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_DRAGANDDROP );
+ pDragAndDropInfo->bUndoAction = true;
+ }
- if ( pDragAndDropInfo->bOutlinerMode )
+ if ( pDragAndDropInfo->bOutlinerMode )
+ {
+ bChanges = true;
+ GetEditViewPtr()->MoveParagraphs( Range( pDragAndDropInfo->aBeginDragSel.nStartPara, pDragAndDropInfo->aBeginDragSel.nEndPara ), pDragAndDropInfo->nOutlinerDropDest );
+ }
+ else
+ {
+ uno::Reference< datatransfer::XTransferable > xDataObj = rDTDE.Transferable;
+ if ( xDataObj.is() )
{
bChanges = true;
- GetEditViewPtr()->MoveParagraphs( Range( pDragAndDropInfo->aBeginDragSel.nStartPara, pDragAndDropInfo->aBeginDragSel.nEndPara ), pDragAndDropInfo->nOutlinerDropDest );
- }
- else
- {
- uno::Reference< datatransfer::XTransferable > xDataObj = rDTDE.Transferable;
- if ( xDataObj.is() )
- {
- bChanges = true;
- // remove Selection ...
- DrawSelectionXOR();
- EditPaM aPaM( pDragAndDropInfo->aDropDest );
+ // remove Selection ...
+ DrawSelectionXOR();
+ EditPaM aPaM( pDragAndDropInfo->aDropDest );
- PasteOrDropInfos aPasteOrDropInfos;
- aPasteOrDropInfos.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
- pEditEngine->HandleBeginPasteOrDrop(aPasteOrDropInfos);
+ PasteOrDropInfos aPasteOrDropInfos;
+ aPasteOrDropInfos.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
+ pEditEngine->HandleBeginPasteOrDrop(aPasteOrDropInfos);
- EditSelection aNewSel = pEditEngine->InsertText(
- xDataObj, OUString(), aPaM, pEditEngine->GetInternalEditStatus().AllowPasteSpecial());
+ EditSelection aNewSel = pEditEngine->InsertText(
+ xDataObj, OUString(), aPaM, pEditEngine->GetInternalEditStatus().AllowPasteSpecial());
- aPasteOrDropInfos.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() );
- pEditEngine->HandleEndPasteOrDrop(aPasteOrDropInfos);
+ aPasteOrDropInfos.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() );
+ pEditEngine->HandleEndPasteOrDrop(aPasteOrDropInfos);
- SetEditSelection( aNewSel );
- pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
- if ( pDragAndDropInfo->bStarterOfDD )
- {
- // Only set if the same engine!
- pDragAndDropInfo->aDropSel.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
- pDragAndDropInfo->aDropSel.nStartPos = aPaM.GetIndex();
- pDragAndDropInfo->aDropSel.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() );
- pDragAndDropInfo->aDropSel.nEndPos = aNewSel.Max().GetIndex();
- pDragAndDropInfo->bDroppedInMe = true;
- }
+ SetEditSelection( aNewSel );
+ pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
+ if ( pDragAndDropInfo->bStarterOfDD )
+ {
+ // Only set if the same engine!
+ pDragAndDropInfo->aDropSel.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
+ pDragAndDropInfo->aDropSel.nStartPos = aPaM.GetIndex();
+ pDragAndDropInfo->aDropSel.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() );
+ pDragAndDropInfo->aDropSel.nEndPos = aNewSel.Max().GetIndex();
+ pDragAndDropInfo->bDroppedInMe = true;
}
}
+ }
- if ( bChanges )
- {
- rDTDE.Context->acceptDrop( rDTDE.DropAction );
- }
-
- if ( !pDragAndDropInfo->bStarterOfDD )
- {
- pDragAndDropInfo.reset();
- }
+ if ( bChanges )
+ {
+ rDTDE.Context->acceptDrop( rDTDE.DropAction );
+ }
- rDTDE.Context->dropComplete( bChanges );
+ if ( !pDragAndDropInfo->bStarterOfDD )
+ {
+ pDragAndDropInfo.reset();
}
+
+ rDTDE.Context->dropComplete( bChanges );
}
void ImpEditView::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& rDTDEE )
@@ -2369,25 +2368,25 @@ void ImpEditView::AddDragAndDropListeners()
else if (GetWindow())
xDropTarget = GetWindow()->GetDropTarget();
- if (xDropTarget.is())
- {
- vcl::unohelper::DragAndDropWrapper* pDnDWrapper = new vcl::unohelper::DragAndDropWrapper(this);
- mxDnDListener = pDnDWrapper;
-
- css::uno::Reference<css::datatransfer::dnd::XDragGestureRecognizer> xDragGestureRecognizer(xDropTarget, uno::UNO_QUERY);
- if (xDragGestureRecognizer.is())
- {
- uno::Reference<datatransfer::dnd::XDragGestureListener> xDGL(mxDnDListener, uno::UNO_QUERY);
- xDragGestureRecognizer->addDragGestureListener(xDGL);
- }
+ if (!xDropTarget.is())
+ return;
- uno::Reference<datatransfer::dnd::XDropTargetListener> xDTL(mxDnDListener, uno::UNO_QUERY);
- xDropTarget->addDropTargetListener(xDTL);
- xDropTarget->setActive(true);
- xDropTarget->setDefaultActions(datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE);
+ vcl::unohelper::DragAndDropWrapper* pDnDWrapper = new vcl::unohelper::DragAndDropWrapper(this);
+ mxDnDListener = pDnDWrapper;
- bActiveDragAndDropListener = true;
+ css::uno::Reference<css::datatransfer::dnd::XDragGestureRecognizer> xDragGestureRecognizer(xDropTarget, uno::UNO_QUERY);
+ if (xDragGestureRecognizer.is())
+ {
+ uno::Reference<datatransfer::dnd::XDragGestureListener> xDGL(mxDnDListener, uno::UNO_QUERY);
+ xDragGestureRecognizer->addDragGestureListener(xDGL);
}
+
+ uno::Reference<datatransfer::dnd::XDropTargetListener> xDTL(mxDnDListener, uno::UNO_QUERY);
+ xDropTarget->addDropTargetListener(xDTL);
+ xDropTarget->setActive(true);
+ xDropTarget->setDefaultActions(datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE);
+
+ bActiveDragAndDropListener = true;
}
void ImpEditView::RemoveDragAndDropListeners()
@@ -2401,26 +2400,26 @@ void ImpEditView::RemoveDragAndDropListeners()
else if (GetWindow())
xDropTarget = GetWindow()->GetDropTarget();
- if (xDropTarget.is())
- {
- css::uno::Reference<css::datatransfer::dnd::XDragGestureRecognizer> xDragGestureRecognizer(xDropTarget, uno::UNO_QUERY);
- if (xDragGestureRecognizer.is())
- {
- uno::Reference<datatransfer::dnd::XDragGestureListener> xDGL(mxDnDListener, uno::UNO_QUERY);
- xDragGestureRecognizer->removeDragGestureListener(xDGL);
- }
+ if (!xDropTarget.is())
+ return;
- uno::Reference<datatransfer::dnd::XDropTargetListener> xDTL(mxDnDListener, uno::UNO_QUERY);
- xDropTarget->removeDropTargetListener(xDTL);
+ css::uno::Reference<css::datatransfer::dnd::XDragGestureRecognizer> xDragGestureRecognizer(xDropTarget, uno::UNO_QUERY);
+ if (xDragGestureRecognizer.is())
+ {
+ uno::Reference<datatransfer::dnd::XDragGestureListener> xDGL(mxDnDListener, uno::UNO_QUERY);
+ xDragGestureRecognizer->removeDragGestureListener(xDGL);
+ }
- if ( mxDnDListener.is() )
- {
- mxDnDListener->disposing( lang::EventObject() ); // #95154# Empty Source means it's the Client
- mxDnDListener.clear();
- }
+ uno::Reference<datatransfer::dnd::XDropTargetListener> xDTL(mxDnDListener, uno::UNO_QUERY);
+ xDropTarget->removeDropTargetListener(xDTL);
- bActiveDragAndDropListener = false;
+ if ( mxDnDListener.is() )
+ {
+ mxDnDListener->disposing( lang::EventObject() ); // #95154# Empty Source means it's the Client
+ mxDnDListener.clear();
}
+
+ bActiveDragAndDropListener = false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 9c04370d9f08..ffa93a144efd 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -1613,131 +1613,131 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
rTypes.clear();
ContentNode* pNode = pParaPortion->GetNode();
- if ( pNode->Len() )
- {
- uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() );
+ if ( !pNode->Len() )
+ return;
- OUString aText = pNode->GetString();
+ uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() );
+
+ OUString aText = pNode->GetString();
- // To handle fields put the character from the field in the string,
- // because endOfScript( ... ) will skip the CH_FEATURE, because this is WEAK
- const EditCharAttrib* pField = pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, 0 );
- while ( pField )
+ // To handle fields put the character from the field in the string,
+ // because endOfScript( ... ) will skip the CH_FEATURE, because this is WEAK
+ const EditCharAttrib* pField = pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, 0 );
+ while ( pField )
+ {
+ const OUString aFldText = static_cast<const EditCharAttribField*>(pField)->GetFieldValue();
+ if ( !aFldText.isEmpty() )
{
- const OUString aFldText = static_cast<const EditCharAttribField*>(pField)->GetFieldValue();
- if ( !aFldText.isEmpty() )
+ aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(0,1) );
+ short nFldScriptType = _xBI->getScriptType( aFldText, 0 );
+
+ for ( sal_Int32 nCharInField = 1; nCharInField < aFldText.getLength(); nCharInField++ )
{
- aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(0,1) );
- short nFldScriptType = _xBI->getScriptType( aFldText, 0 );
+ short nTmpType = _xBI->getScriptType( aFldText, nCharInField );
- for ( sal_Int32 nCharInField = 1; nCharInField < aFldText.getLength(); nCharInField++ )
+ // First char from field wins...
+ if ( nFldScriptType == i18n::ScriptType::WEAK )
{
- short nTmpType = _xBI->getScriptType( aFldText, nCharInField );
-
- // First char from field wins...
- if ( nFldScriptType == i18n::ScriptType::WEAK )
- {
- nFldScriptType = nTmpType;
- aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(nCharInField,1) );
- }
+ nFldScriptType = nTmpType;
+ aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(nCharInField,1) );
+ }
- // ... but if the first one is LATIN, and there are CJK or CTL chars too,
- // we prefer that ScriptType because we need another font.
- if ( ( nTmpType == i18n::ScriptType::ASIAN ) || ( nTmpType == i18n::ScriptType::COMPLEX ) )
- {
- aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(nCharInField,1) );
- break;
- }
+ // ... but if the first one is LATIN, and there are CJK or CTL chars too,
+ // we prefer that ScriptType because we need another font.
+ if ( ( nTmpType == i18n::ScriptType::ASIAN ) || ( nTmpType == i18n::ScriptType::COMPLEX ) )
+ {
+ aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(nCharInField,1) );
+ break;
}
}
- // #112831# Last Field might go from 0xffff to 0x0000
- pField = pField->GetEnd() ? pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, pField->GetEnd() ) : nullptr;
}
+ // #112831# Last Field might go from 0xffff to 0x0000
+ pField = pField->GetEnd() ? pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, pField->GetEnd() ) : nullptr;
+ }
- sal_Int32 nTextLen = aText.getLength();
+ sal_Int32 nTextLen = aText.getLength();
- sal_Int32 nPos = 0;
- short nScriptType = _xBI->getScriptType( aText, nPos );
- rTypes.emplace_back( nScriptType, nPos, nTextLen );
- nPos = _xBI->endOfScript( aText, nPos, nScriptType );
- while ( ( nPos != -1 ) && ( nPos < nTextLen ) )
- {
- rTypes.back().nEndPos = nPos;
+ sal_Int32 nPos = 0;
+ short nScriptType = _xBI->getScriptType( aText, nPos );
+ rTypes.emplace_back( nScriptType, nPos, nTextLen );
+ nPos = _xBI->endOfScript( aText, nPos, nScriptType );
+ while ( ( nPos != -1 ) && ( nPos < nTextLen ) )
+ {
+ rTypes.back().nEndPos = nPos;
- nScriptType = _xBI->getScriptType( aText, nPos );
- long nEndPos = _xBI->endOfScript( aText, nPos, nScriptType );
+ nScriptType = _xBI->getScriptType( aText, nPos );
+ long nEndPos = _xBI->endOfScript( aText, nPos, nScriptType );
- if ( ( nScriptType == i18n::ScriptType::WEAK ) || ( nScriptType == rTypes.back().nScriptType ) )
- {
- // Expand last ScriptTypePosInfo, don't create weak or unnecessary portions
- rTypes.back().nEndPos = nEndPos;
- }
- else
+ if ( ( nScriptType == i18n::ScriptType::WEAK ) || ( nScriptType == rTypes.back().nScriptType ) )
+ {
+ // Expand last ScriptTypePosInfo, don't create weak or unnecessary portions
+ rTypes.back().nEndPos = nEndPos;
+ }
+ else
+ {
+ if ( _xBI->getScriptType( aText, nPos - 1 ) == i18n::ScriptType::WEAK )
{
- if ( _xBI->getScriptType( aText, nPos - 1 ) == i18n::ScriptType::WEAK )
- {
- switch ( u_charType(aText.iterateCodePoints(&nPos, 0) ) ) {
- case U_NON_SPACING_MARK:
- case U_ENCLOSING_MARK:
- case U_COMBINING_SPACING_MARK:
- --nPos;
- rTypes.back().nEndPos--;
- break;
- }
+ switch ( u_charType(aText.iterateCodePoints(&nPos, 0) ) ) {
+ case U_NON_SPACING_MARK:
+ case U_ENCLOSING_MARK:
+ case U_COMBINING_SPACING_MARK:
+ --nPos;
+ rTypes.back().nEndPos--;
+ break;
}
- rTypes.emplace_back( nScriptType, nPos, nTextLen );
}
-
- nPos = nEndPos;
+ rTypes.emplace_back( nScriptType, nPos, nTextLen );
}
- if ( rTypes[0].nScriptType == i18n::ScriptType::WEAK )
- rTypes[0].nScriptType = ( rTypes.size() > 1 ) ? rTypes[1].nScriptType : SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetDefaultLanguage() );
+ nPos = nEndPos;
+ }
- // create writing direction information:
- if ( pParaPortion->aWritingDirectionInfos.empty() )
- InitWritingDirections( nPara );
+ if ( rTypes[0].nScriptType == i18n::ScriptType::WEAK )
+ rTypes[0].nScriptType = ( rTypes.size() > 1 ) ? rTypes[1].nScriptType : SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetDefaultLanguage() );
- // i89825: Use CTL font for numbers embedded into an RTL run:
- WritingDirectionInfos& rDirInfos = pParaPortion->aWritingDirectionInfos;
- for (const WritingDirectionInfo & rDirInfo : rDirInfos)
- {
- const sal_Int32 nStart = rDirInfo.nStartPos;
- const sal_Int32 nEnd = rDirInfo.nEndPos;
- const sal_uInt8 nCurrDirType = rDirInfo.nType;
+ // create writing direction information:
+ if ( pParaPortion->aWritingDirectionInfos.empty() )
+ InitWritingDirections( nPara );
- if ( nCurrDirType % 2 == UBIDI_RTL || // text in RTL run
- ( nCurrDirType > UBIDI_LTR && !lcl_HasStrongLTR( aText, nStart, nEnd ) ) ) // non-strong text in embedded LTR run
- {
- size_t nIdx = 0;
+ // i89825: Use CTL font for numbers embedded into an RTL run:
+ WritingDirectionInfos& rDirInfos = pParaPortion->aWritingDirectionInfos;
+ for (const WritingDirectionInfo & rDirInfo : rDirInfos)
+ {
+ const sal_Int32 nStart = rDirInfo.nStartPos;
+ const sal_Int32 nEnd = rDirInfo.nEndPos;
+ const sal_uInt8 nCurrDirType = rDirInfo.nType;
+
+ if ( nCurrDirType % 2 == UBIDI_RTL || // text in RTL run
+ ( nCurrDirType > UBIDI_LTR && !lcl_HasStrongLTR( aText, nStart, nEnd ) ) ) // non-strong text in embedded LTR run
+ {
+ size_t nIdx = 0;
- // Skip entries in ScriptArray which are not inside the RTL run:
- while ( nIdx < rTypes.size() && rTypes[nIdx].nStartPos < nStart )
- ++nIdx;
+ // Skip entries in ScriptArray which are not inside the RTL run:
+ while ( nIdx < rTypes.size() && rTypes[nIdx].nStartPos < nStart )
+ ++nIdx;
- // Remove any entries *inside* the current run:
- while (nIdx < rTypes.size() && rTypes[nIdx].nEndPos <= nEnd)
- {
- // coverity[use_iterator] - we're protected from a bad iterator by the above condition
- rTypes.erase(rTypes.begin() + nIdx);
- }
+ // Remove any entries *inside* the current run:
+ while (nIdx < rTypes.size() && rTypes[nIdx].nEndPos <= nEnd)
+ {
+ // coverity[use_iterator] - we're protected from a bad iterator by the above condition
+ rTypes.erase(rTypes.begin() + nIdx);
+ }
- // special case:
- if(nIdx < rTypes.size() && rTypes[nIdx].nStartPos < nStart && rTypes[nIdx].nEndPos > nEnd)
- {
- rTypes.insert( rTypes.begin()+nIdx, ScriptTypePosInfo( rTypes[nIdx].nScriptType, nEnd, rTypes[nIdx].nEndPos ) );
- rTypes[nIdx].nEndPos = nStart;
- }
+ // special case:
+ if(nIdx < rTypes.size() && rTypes[nIdx].nStartPos < nStart && rTypes[nIdx].nEndPos > nEnd)
+ {
+ rTypes.insert( rTypes.begin()+nIdx, ScriptTypePosInfo( rTypes[nIdx].nScriptType, nEnd, rTypes[nIdx].nEndPos ) );
+ rTypes[nIdx].nEndPos = nStart;
+ }
- if( nIdx )
- rTypes[nIdx - 1].nEndPos = nStart;
+ if( nIdx )
+ rTypes[nIdx - 1].nEndPos = nStart;
- rTypes.insert( rTypes.begin()+nIdx, ScriptTypePosInfo( i18n::ScriptType::COMPLEX, nStart, nEnd) );
- ++nIdx;
+ rTypes.insert( rTypes.begin()+nIdx, ScriptTypePosInfo( i18n::ScriptType::COMPLEX, nStart, nEnd) );
+ ++nIdx;
- if( nIdx < rTypes.size() )
- rTypes[nIdx].nStartPos = nEnd;
- }
+ if( nIdx < rTypes.size() )
+ rTypes[nIdx].nStartPos = nEnd;
}
}
}
@@ -4091,97 +4091,97 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
pPortion->nHeight = 0;
pPortion->nFirstLineOffset = 0;
- if ( pPortion->IsVisible() )
+ if ( !pPortion->IsVisible() )
+ return;
+
+ OSL_ENSURE( pPortion->GetLines().Count(), "Paragraph with no lines in ParaPortion::CalcHeight" );
+ for (sal_Int32 nLine = 0; nLine < pPortion->GetLines().Count(); ++nLine)
+ pPortion->nHeight += pPortion->GetLines()[nLine].GetHeight();
+
+ if ( aStatus.IsOutliner() )
+ return;
+
+ const SvxULSpaceItem& rULItem = pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE );
+ const SvxLineSpacingItem& rLSItem = pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL );
+ sal_Int32 nSBL = ( rLSItem.GetInterLineSpaceRule() == SvxInterLineSpaceRule::Fix ) ? GetYValue( rLSItem.GetInterLineSpace() ) : 0;
+
+ if ( nSBL )
{
- OSL_ENSURE( pPortion->GetLines().Count(), "Paragraph with no lines in ParaPortion::CalcHeight" );
- for (sal_Int32 nLine = 0; nLine < pPortion->GetLines().Count(); ++nLine)
- pPortion->nHeight += pPortion->GetLines()[nLine].GetHeight();
+ if ( pPortion->GetLines().Count() > 1 )
+ pPortion->nHeight += ( pPortion->GetLines().Count() - 1 ) * nSBL;
+ if ( aStatus.ULSpaceSummation() )
+ pPortion->nHeight += nSBL;
+ }
- if ( !aStatus.IsOutliner() )
- {
- const SvxULSpaceItem& rULItem = pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE );
- const SvxLineSpacingItem& rLSItem = pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL );
- sal_Int32 nSBL = ( rLSItem.GetInterLineSpaceRule() == SvxInterLineSpaceRule::Fix ) ? GetYValue( rLSItem.GetInterLineSpace() ) : 0;
+ sal_Int32 nPortion = GetParaPortions().GetPos( pPortion );
+ if ( nPortion )
+ {
+ sal_uInt16 nUpper = GetYValue( rULItem.GetUpper() );
+ pPortion->nHeight += nUpper;
+ pPortion->nFirstLineOffset = nUpper;
+ }
- if ( nSBL )
- {
- if ( pPortion->GetLines().Count() > 1 )
- pPortion->nHeight += ( pPortion->GetLines().Count() - 1 ) * nSBL;
- if ( aStatus.ULSpaceSummation() )
- pPortion->nHeight += nSBL;
- }
+ if ( nPortion != (GetParaPortions().Count()-1) )
+ {
+ pPortion->nHeight += GetYValue( rULItem.GetLower() ); // not in the last
+ }
- sal_Int32 nPortion = GetParaPortions().GetPos( pPortion );
- if ( nPortion )
- {
- sal_uInt16 nUpper = GetYValue( rULItem.GetUpper() );
- pPortion->nHeight += nUpper;
- pPortion->nFirstLineOffset = nUpper;
- }
- if ( nPortion != (GetParaPortions().Count()-1) )
- {
- pPortion->nHeight += GetYValue( rULItem.GetLower() ); // not in the last
- }
+ if ( !(nPortion && !aStatus.ULSpaceSummation()) )
+ return;
+ ParaPortion* pPrev = GetParaPortions().SafeGetObject( nPortion-1 );
+ if (!pPrev)
+ return;
- if ( nPortion && !aStatus.ULSpaceSummation() )
- {
- ParaPortion* pPrev = GetParaPortions().SafeGetObject( nPortion-1 );
- if (pPrev)
- {
- const SvxULSpaceItem& rPrevULItem = pPrev->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE );
- const SvxLineSpacingItem& rPrevLSItem = pPrev->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL );
+ const SvxULSpaceItem& rPrevULItem = pPrev->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE );
+ const SvxLineSpacingItem& rPrevLSItem = pPrev->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL );
- // In relation between WinWord6/Writer3:
- // With a proportional line spacing the paragraph spacing is
- // also manipulated.
- // Only Writer3: Do not add up, but minimum distance.
+ // In relation between WinWord6/Writer3:
+ // With a proportional line spacing the paragraph spacing is
+ // also manipulated.
+ // Only Writer3: Do not add up, but minimum distance.
- // check if distance by LineSpacing > Upper:
- sal_uInt16 nExtraSpace = GetYValue( lcl_CalcExtraSpace( rLSItem ) );
- if ( nExtraSpace > pPortion->nFirstLineOffset )
- {
- // Paragraph becomes 'bigger':
- pPortion->nHeight += ( nExtraSpace - pPortion->nFirstLineOffset );
- pPortion->nFirstLineOffset = nExtraSpace;
- }
+ // check if distance by LineSpacing > Upper:
+ sal_uInt16 nExtraSpace = GetYValue( lcl_CalcExtraSpace( rLSItem ) );
+ if ( nExtraSpace > pPortion->nFirstLineOffset )
+ {
+ // Paragraph becomes 'bigger':
+ pPortion->nHeight += ( nExtraSpace - pPortion->nFirstLineOffset );
+ pPortion->nFirstLineOffset = nExtraSpace;
+ }
- // Determine nFirstLineOffset now f(pNode) => now f(pNode, pPrev):
- sal_uInt16 nPrevLower = GetYValue( rPrevULItem.GetLower() );
+ // Determine nFirstLineOffset now f(pNode) => now f(pNode, pPrev):
+ sal_uInt16 nPrevLower = GetYValue( rPrevULItem.GetLower() );
- // This PrevLower is still in the height of PrevPortion ...
- if ( nPrevLower > pPortion->nFirstLineOffset )
- {
- // Paragraph is 'small':
- pPortion->nHeight -= pPortion->nFirstLineOffset;
- pPortion->nFirstLineOffset = 0;
- }
- else if ( nPrevLower )
- {
- // Paragraph becomes 'somewhat smaller':
- pPortion->nHeight -= nPrevLower;
- pPortion->nFirstLineOffset =
- pPortion->nFirstLineOffset - nPrevLower;
- }
- // I find it not so good, but Writer3 feature:
- // Check if distance by LineSpacing > Lower: this value is not
- // stuck in the height of PrevPortion.
- if ( !pPrev->IsInvalid() )
- {
- nExtraSpace = GetYValue( lcl_CalcExtraSpace( rPrevLSItem ) );
- if ( nExtraSpace > nPrevLower )
- {
- sal_uInt16 nMoreLower = nExtraSpace - nPrevLower;
- // Paragraph becomes 'bigger', 'grows' downwards:
- if ( nMoreLower > pPortion->nFirstLineOffset )
- {
- pPortion->nHeight += ( nMoreLower - pPortion->nFirstLineOffset );
- pPortion->nFirstLineOffset = nMoreLower;
- }
- }
- }
- }
+ // This PrevLower is still in the height of PrevPortion ...
+ if ( nPrevLower > pPortion->nFirstLineOffset )
+ {
+ // Paragraph is 'small':
+ pPortion->nHeight -= pPortion->nFirstLineOffset;
+ pPortion->nFirstLineOffset = 0;
+ }
+ else if ( nPrevLower )
+ {
+ // Paragraph becomes 'somewhat smaller':
+ pPortion->nHeight -= nPrevLower;
+ pPortion->nFirstLineOffset =
+ pPortion->nFirstLineOffset - nPrevLower;
+ }
+ // I find it not so good, but Writer3 feature:
+ // Check if distance by LineSpacing > Lower: this value is not
+ // stuck in the height of PrevPortion.
+ if ( !pPrev->IsInvalid() )
+ {
+ nExtraSpace = GetYValue( lcl_CalcExtraSpace( rPrevLSItem ) );
+ if ( nExtraSpace > nPrevLower )
+ {
+ sal_uInt16 nMoreLower = nExtraSpace - nPrevLower;
+ // Paragraph becomes 'bigger', 'grows' downwards:
+ if ( nMoreLower > pPortion->nFirstLineOffset )
+ {
+ pPortion->nHeight += ( nMoreLower - pPortion->nFirstLineOffset );
+ pPortion->nFirstLineOffset = nMoreLower;
}
}
}
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index b9a33ceec64d..0d00c5197184 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -512,46 +512,46 @@ void ImpEditEngine::CheckAutoPageSize()
SetValidPaperSize( aPaperSize ); // consider Min, Max
- if ( aPaperSize != aPrevPaperSize )
+ if ( aPaperSize == aPrevPaperSize )
+ return;
+
+ if ( ( !IsVertical() && ( aPaperSize.Width() != aPrevPaperSize.Width() ) )
+ || ( IsVertical() && ( aPaperSize.Height() != aPrevPaperSize.Height() ) ) )
{
- if ( ( !IsVertical() && ( aPaperSize.Width() != aPrevPaperSize.Width() ) )
- || ( IsVertical() && ( aPaperSize.Height() != aPrevPaperSize.Height() ) ) )
+ // If ahead is centered / right or tabs...
+ aStatus.GetStatusWord() |= !IsVertical() ? EditStatusFlags::TEXTWIDTHCHANGED : EditStatusFlags::TextHeightChanged;
+ for ( sal_Int32 nPara = 0; nPara < GetParaPortions().Count(); nPara++ )
{
- // If ahead is centered / right or tabs...
- aStatus.GetStatusWord() |= !IsVertical() ? EditStatusFlags::TEXTWIDTHCHANGED : EditStatusFlags::TextHeightChanged;
- for ( sal_Int32 nPara = 0; nPara < GetParaPortions().Count(); nPara++ )
+ // Only paragraphs which are not aligned to the left need to be
+ // reformatted, the height can not be changed here anymore.
+ ParaPortion* pParaPortion = GetParaPortions()[nPara];
+ SvxAdjust eJustification = GetJustification( nPara );
+ if ( eJustification != SvxAdjust::Left )
{
- // Only paragraphs which are not aligned to the left need to be
- // reformatted, the height can not be changed here anymore.
- ParaPortion* pParaPortion = GetParaPortions()[nPara];
- SvxAdjust eJustification = GetJustification( nPara );
- if ( eJustification != SvxAdjust::Left )
- {
- pParaPortion->MarkSelectionInvalid( 0 );
- CreateLines( nPara, 0 ); // 0: For AutoPageSize no TextRange!
- }
+ pParaPortion->MarkSelectionInvalid( 0 );
+ CreateLines( nPara, 0 ); // 0: For AutoPageSize no TextRange!
}
}
+ }
- Size aInvSize = aPaperSize;
- if ( aPaperSize.Width() < aPrevPaperSize.Width() )
- aInvSize.setWidth( aPrevPaperSize.Width() );
- if ( aPaperSize.Height() < aPrevPaperSize.Height() )
- aInvSize.setHeight( aPrevPaperSize.Height() );
+ Size aInvSize = aPaperSize;
+ if ( aPaperSize.Width() < aPrevPaperSize.Width() )
+ aInvSize.setWidth( aPrevPaperSize.Width() );
+ if ( aPaperSize.Height() < aPrevPaperSize.Height() )
+ aInvSize.setHeight( aPrevPaperSize.Height() );
- Size aSz( aInvSize );
- if ( IsVertical() )
- {
- aSz.setWidth( aInvSize.Height() );
- aSz.setHeight( aInvSize.Width() );
- }
- aInvalidRect = tools::Rectangle( Point(), aSz );
+ Size aSz( aInvSize );
+ if ( IsVertical() )
+ {
+ aSz.setWidth( aInvSize.Height() );
+ aSz.setHeight( aInvSize.Width() );
+ }
+ aInvalidRect = tools::Rectangle( Point(), aSz );
- for (EditView* pView : aEditViews)
- {
- pView->pImpEditView->RecalcOutputArea();
- }
+ for (EditView* pView : aEditViews)
+ {
+ pView->pImpEditView->RecalcOutputArea();
}
}
@@ -2846,35 +2846,35 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo
}
}
- if ( mpIMEInfos && mpIMEInfos->pAttribs && ( mpIMEInfos->aPos.GetNode() == pNode ) &&
- ( nPos > mpIMEInfos->aPos.GetIndex() ) && ( nPos <= ( mpIMEInfos->aPos.GetIndex() + mpIMEInfos->nLen ) ) )
+ if ( !(mpIMEInfos && mpIMEInfos->pAttribs && ( mpIMEInfos->aPos.GetNode() == pNode ) &&
+ ( nPos > mpIMEInfos->aPos.GetIndex() ) && ( nPos <= ( mpIMEInfos->aPos.GetIndex() + mpIMEInfos->nLen ) )) )
+ return;
+
+ ExtTextInputAttr nAttr = mpIMEInfos->pAttribs[ nPos - mpIMEInfos->aPos.GetIndex() - 1 ];
+ if ( nAttr & ExtTextInputAttr::Underline )
+ rFont.SetUnderline( LINESTYLE_SINGLE );
+ else if ( nAttr & ExtTextInputAttr::BoldUnderline )
+ rFont.SetUnderline( LINESTYLE_BOLD );
+ else if ( nAttr & ExtTextInputAttr::DottedUnderline )
+ rFont.SetUnderline( LINESTYLE_DOTTED );
+ else if ( nAttr & ExtTextInputAttr::DashDotUnderline )
+ rFont.SetUnderline( LINESTYLE_DOTTED );
+ else if ( nAttr & ExtTextInputAttr::RedText )
+ rFont.SetColor( COL_RED );
+ else if ( nAttr & ExtTextInputAttr::HalfToneText )
+ rFont.SetColor( COL_LIGHTGRAY );
+ if ( nAttr & ExtTextInputAttr::Highlight )
{
- ExtTextInputAttr nAttr = mpIMEInfos->pAttribs[ nPos - mpIMEInfos->aPos.GetIndex() - 1 ];
- if ( nAttr & ExtTextInputAttr::Underline )
- rFont.SetUnderline( LINESTYLE_SINGLE );
- else if ( nAttr & ExtTextInputAttr::BoldUnderline )
- rFont.SetUnderline( LINESTYLE_BOLD );
- else if ( nAttr & ExtTextInputAttr::DottedUnderline )
- rFont.SetUnderline( LINESTYLE_DOTTED );
- else if ( nAttr & ExtTextInputAttr::DashDotUnderline )
- rFont.SetUnderline( LINESTYLE_DOTTED );
- else if ( nAttr & ExtTextInputAttr::RedText )
- rFont.SetColor( COL_RED );
- else if ( nAttr & ExtTextInputAttr::HalfToneText )
- rFont.SetColor( COL_LIGHTGRAY );
- if ( nAttr & ExtTextInputAttr::Highlight )
- {
- const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
- rFont.SetColor( rStyleSettings.GetHighlightTextColor() );
- rFont.SetFillColor( rStyleSettings.GetHighlightColor() );
- rFont.SetTransparent( false );
- }
- else if ( nAttr & ExtTextInputAttr::GrayWaveline )
- {
- rFont.SetUnderline( LINESTYLE_WAVE );
- if( pOut )
- pOut->SetTextLineColor( COL_LIGHTGRAY );
- }
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ rFont.SetColor( rStyleSettings.GetHighlightTextColor() );
+ rFont.SetFillColor( rStyleSettings.GetHighlightColor() );
+ rFont.SetTransparent( false );
+ }
+ else if ( nAttr & ExtTextInputAttr::GrayWaveline )
+ {
+ rFont.SetUnderline( LINESTYLE_WAVE );
+ if( pOut )
+ pOut->SetTextLineColor( COL_LIGHTGRAY );
}
}
@@ -2924,23 +2924,23 @@ void ImpEditEngine::RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics
if ( nDescent > rCurMetrics.nMaxDescent )
rCurMetrics.nMaxDescent= nDescent;
// Special treatment of high/low:
- if ( rFont.GetEscapement() )
+ if ( !rFont.GetEscapement() )
+ return;
+
+ // Now in consideration of Escape/Propr
+ // possibly enlarge Ascent or Descent
+ short nDiff = static_cast<short>(rFont.GetFontSize().Height()*rFont.GetEscapement()/100);
+ if ( rFont.GetEscapement() > 0 )
{
- // Now in consideration of Escape/Propr
- // possibly enlarge Ascent or Descent
- short nDiff = static_cast<short>(rFont.GetFontSize().Height()*rFont.GetEscapement()/100);
- if ( rFont.GetEscapement() > 0 )
- {
- nAscent = static_cast<sal_uInt16>(static_cast<long>(nAscent)*nPropr/100 + nDiff);
- if ( nAscent > rCurMetrics.nMaxAscent )
- rCurMetrics.nMaxAscent = nAscent;
- }
- else // has to be < 0
- {
- nDescent = static_cast<sal_uInt16>(static_cast<long>(nDescent)*nPropr/100 - nDiff);
- if ( nDescent > rCurMetrics.nMaxDescent )
- rCurMetrics.nMaxDescent= nDescent;
- }
+ nAscent = static_cast<sal_uInt16>(static_cast<long>(nAscent)*nPropr/100 + nDiff);
+ if ( nAscent > rCurMetrics.nMaxAscent )
+ rCurMetrics.nMaxAscent = nAscent;
+ }
+ else // has to be < 0
+ {
+ nDescent = static_cast<sal_uInt16>(static_cast<long>(nDescent)*nPropr/100 - nDiff);
+ if ( nDescent > rCurMetrics.nMaxDescent )
+ rCurMetrics.nMaxDescent= nDescent;
}
}
@@ -3956,48 +3956,48 @@ void ImpEditEngine::ShowParagraph( sal_Int32 nParagraph, bool bShow )
{
ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph );
DBG_ASSERT( pPPortion, "ShowParagraph: Paragraph does not exist! ");
- if ( pPPortion && ( pPPortion->IsVisible() != bShow ) )
- {
- pPPortion->SetVisible( bShow );
+ if ( !(pPPortion && ( pPPortion->IsVisible() != bShow )) )
+ return;
- if ( !bShow )
- {
- // Mark as deleted, so that no selection will end or begin at
- // this paragraph...
- aDeletedNodes.push_back(std::make_unique<DeletedNodeInfo>( pPPortion->GetNode(), nParagraph ));
- UpdateSelections();
- // The region below will not be invalidated if UpdateMode = sal_False!
- // If anyway, then save as sal_False before SetVisible !
- }
+ pPPortion->SetVisible( bShow );
+
+ if ( !bShow )
+ {
+ // Mark as deleted, so that no selection will end or begin at
+ // this paragraph...
+ aDeletedNodes.push_back(std::make_unique<DeletedNodeInfo>( pPPortion->GetNode(), nParagraph ));
+ UpdateSelections();
+ // The region below will not be invalidated if UpdateMode = sal_False!
+ // If anyway, then save as sal_False before SetVisible !
+ }
- if ( bShow && ( pPPortion->IsInvalid() || !pPPortion->nHeight ) )
+ if ( bShow && ( pPPortion->IsInvalid() || !pPPortion->nHeight ) )
+ {
+ if ( !GetTextRanger() )
{
- if ( !GetTextRanger() )
+ if ( pPPortion->IsInvalid() )
{
- if ( pPPortion->IsInvalid() )
- {
- CreateLines( nParagraph, 0 ); // 0: No TextRanger
- }
- else
- {
- CalcHeight( pPPortion );
- }
- nCurTextHeight += pPPortion->GetHeight();
+ CreateLines( nParagraph, 0 ); // 0: No TextRanger
}
else
{
- nCurTextHeight = 0x7fffffff;
+ CalcHeight( pPPortion );
}
+ nCurTextHeight += pPPortion->GetHeight();
}
-
- pPPortion->SetMustRepaint( true );
- if ( GetUpdateMode() && !IsInUndo() && !GetTextRanger() )
+ else
{
- aInvalidRect = tools::Rectangle( Point( 0, GetParaPortions().GetYOffset( pPPortion ) ),
- Point( GetPaperSize().Width(), nCurTextHeight ) );
- UpdateViews( GetActiveView() );
+ nCurTextHeight = 0x7fffffff;
}
}
+
+ pPPortion->SetMustRepaint( true );
+ if ( GetUpdateMode() && !IsInUndo() && !GetTextRanger() )
+ {
+ aInvalidRect = tools::Rectangle( Point( 0, GetParaPortions().GetYOffset( pPPortion ) ),
+ Point( GetPaperSize().Width(), nCurTextHeight ) );
+ UpdateViews( GetActiveView() );
+ }
}
EditSelection ImpEditEngine::MoveParagraphs( Range aOldPositions, sal_Int32 nNewPos, EditView* pCurView )
@@ -4601,32 +4601,32 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion*
pTP = ( nPortion > pLine->GetStartPortion() ) ? &pParaPortion->GetTextPortions()[ --nPortion ] : nullptr;
}
- if ( bFoundCompressedPortion )
+ if ( !bFoundCompressedPortion )
+ return;
+
+ long nCompressPercent = 0;
+ if ( nCompressed > nRemainingWidth )
{
- long nCompressPercent = 0;
- if ( nCompressed > nRemainingWidth )
- {
- nCompressPercent = nCompressed - nRemainingWidth;
- DBG_ASSERT( nCompressPercent < 200000, "ImplExpandCompressedPortions - Overflow!" );
- nCompressPercent *= 10000;
- nCompressPercent /= nCompressed;
- }
+ nCompressPercent = nCompressed - nRemainingWidth;
+ DBG_ASSERT( nCompressPercent < 200000, "ImplExpandCompressedPortions - Overflow!" );
+ nCompressPercent *= 10000;
+ nCompressPercent /= nCompressed;
+ }
- for (TextPortion* pTP2 : aCompressedPortions)
+ for (TextPortion* pTP2 : aCompressedPortions)
+ {
+ pTP = pTP2;
+ pTP->GetExtraInfos()->bCompressed = false;
+ pTP->GetSize().setWidth( pTP->GetExtraInfos()->nOrgWidth );
+ if ( nCompressPercent )
{
- pTP = pTP2;
- pTP->GetExtraInfos()->bCompressed = false;
- pTP->GetSize().setWidth( pTP->GetExtraInfos()->nOrgWidth );
- if ( nCompressPercent )
- {
- sal_Int32 nTxtPortion = pParaPortion->GetTextPortions().GetPos( pTP );
- sal_Int32 nTxtPortionStart = pParaPortion->GetTextPortions().GetStartPos( nTxtPortion );
- DBG_ASSERT( nTxtPortionStart >= pLine->GetStart(), "Portion doesn't belong to the line!!!" );
- long* pDXArray = pLine->GetCharPosArray().data() + (nTxtPortionStart - pLine->GetStart());
- if ( pTP->GetExtraInfos()->pOrgDXArray )
- memcpy( pDXArray, pTP->GetExtraInfos()->pOrgDXArray.get(), (pTP->GetLen()-1)*sizeof(sal_Int32) );
- ImplCalcAsianCompression( pParaPortion->GetNode(), pTP, nTxtPortionStart, pDXArray, static_cast<sal_uInt16>(nCompressPercent), true );
- }
+ sal_Int32 nTxtPortion = pParaPortion->GetTextPortions().GetPos( pTP );
+ sal_Int32 nTxtPortionStart = pParaPortion->GetTextPortions().GetStartPos( nTxtPortion );
+ DBG_ASSERT( nTxtPortionStart >= pLine->GetStart(), "Portion doesn't belong to the line!!!" );
+ long* pDXArray = pLine->GetCharPosArray().data() + (nTxtPortionStart - pLine->GetStart());
+ if ( pTP->GetExtraInfos()->pOrgDXArray )
+ memcpy( pDXArray, pTP->GetExtraInfos()->pOrgDXArray.get(), (pTP->GetLen()-1)*sizeof(sal_Int32) );
+ ImplCalcAsianCompression( pParaPortion->GetNode(), pTP, nTxtPortionStart, pDXArray, static_cast<sal_uInt16>(nCompressPercent), true );
}
}
}
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 050eed8667f4..00a999a5abac 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -185,20 +185,20 @@ void ImpEditEngine::Write(SvStream& rOutput, EETextFormat eFormat, const EditSel
if ( !rOutput.IsWritable() )
rOutput.SetError( SVSTREAM_WRITE_ERROR );
- if ( !rOutput.GetError() )
+ if ( rOutput.GetError() )
+ return;
+
+ if ( eFormat == EETextFormat::Text )
+ WriteText( rOutput, rSel );
+ else if ( eFormat == EETextFormat::Rtf )
+ WriteRTF( rOutput, rSel );
+ else if ( eFormat == EETextFormat::Xml )
+ WriteXML( rOutput, rSel );
+ else if ( eFormat == EETextFormat::Html )
+ ;
+ else
{
- if ( eFormat == EETextFormat::Text )
- WriteText( rOutput, rSel );
- else if ( eFormat == EETextFormat::Rtf )
- WriteRTF( rOutput, rSel );
- else if ( eFormat == EETextFormat::Xml )
- WriteXML( rOutput, rSel );
- else if ( eFormat == EETextFormat::Html )
- ;
- else
- {
- OSL_FAIL( "Write: Unknown Format" );
- }
+ OSL_FAIL( "Write: Unknown Format" );
}
}
@@ -1976,20 +1976,19 @@ void ImpEditEngine::AddPortion(
svx::SpellPortions& rToFill,
bool bIsField)
{
- if(rSel.HasRange())
- {
- svx::SpellPortion aPortion;
- aPortion.sText = GetSelected( rSel );
- aPortion.eLanguage = GetLanguage( rSel.Min() );
- aPortion.xAlternatives = xAlt;
- aPortion.bIsField = bIsField;
- rToFill.push_back(aPortion);
+ if(!rSel.HasRange())
+ return;
- //save the spelled portions for later use
- pSpellInfo->aLastSpellPortions.push_back(aPortion);
- pSpellInfo->aLastSpellContentSelections.push_back(rSel);
+ svx::SpellPortion aPortion;
+ aPortion.sText = GetSelected( rSel );
+ aPortion.eLanguage = GetLanguage( rSel.Min() );
+ aPortion.xAlternatives = xAlt;
+ aPortion.bIsField = bIsField;
+ rToFill.push_back(aPortion);
- }
+ //save the spelled portions for later use
+ pSpellInfo->aLastSpellPortions.push_back(aPortion);
+ pSpellInfo->aLastSpellContentSelections.push_back(rSel);
}
// Adds one or more portions of text to the SpellPortions depending on language changes
@@ -1999,65 +1998,65 @@ void ImpEditEngine::AddPortionIterated(
const Reference< XSpellAlternatives >& xAlt,
svx::SpellPortions& rToFill)
{
- if (rSel.HasRange())
+ if (!rSel.HasRange())
+ return;
+
+ if(xAlt.is())
{
- if(xAlt.is())
- {
- AddPortion(rSel, xAlt, rToFill, false);
- }
- else
+ AddPortion(rSel, xAlt, rToFill, false);
+ }
+ else
+ {
+ //iterate and search for language attribute changes
+ //save the start and end positions
+ bool bTest = rSel.Min().GetIndex() <= rSel.Max().GetIndex();
+ EditPaM aStart(bTest ? rSel.Min() : rSel.Max());
+ EditPaM aEnd(bTest ? rSel.Max() : rSel.Min());
+ //iterate over the text to find changes in language
+ //set the mark equal to the point
+ EditPaM aCursor(aStart);
+ rEditView.pImpEditView->SetEditSelection( aCursor );
+ LanguageType eStartLanguage = GetLanguage( aCursor );
+ //search for a field attribute at the beginning - only the end position
+ //of this field is kept to end a portion at that position
+ const EditCharAttrib* pFieldAttr = aCursor.GetNode()->GetCharAttribs().
+ FindFeature( aCursor.GetIndex() );
+ bool bIsField = pFieldAttr &&
+ pFieldAttr->GetStart() == aCursor.GetIndex() &&
+ pFieldAttr->GetStart() != pFieldAttr->GetEnd() &&
+ pFieldAttr->Which() == EE_FEATURE_FIELD;
+ sal_Int32 nEndField = bIsField ? pFieldAttr->GetEnd() : -1;
+ do
{
- //iterate and search for language attribute changes
- //save the start and end positions
- bool bTest = rSel.Min().GetIndex() <= rSel.Max().GetIndex();
- EditPaM aStart(bTest ? rSel.Min() : rSel.Max());
- EditPaM aEnd(bTest ? rSel.Max() : rSel.Min());
- //iterate over the text to find changes in language
- //set the mark equal to the point
- EditPaM aCursor(aStart);
- rEditView.pImpEditView->SetEditSelection( aCursor );
- LanguageType eStartLanguage = GetLanguage( aCursor );
- //search for a field attribute at the beginning - only the end position
- //of this field is kept to end a portion at that position
- const EditCharAttrib* pFieldAttr = aCursor.GetNode()->GetCharAttribs().
+ aCursor = CursorRight( aCursor);
+ //determine whether a field and has been reached
+ bool bIsEndField = nEndField == aCursor.GetIndex();
+ //search for a new field attribute
+ const EditCharAttrib* _pFieldAttr = aCursor.GetNode()->GetCharAttribs().
FindFeature( aCursor.GetIndex() );
- bool bIsField = pFieldAttr &&
- pFieldAttr->GetStart() == aCursor.GetIndex() &&
- pFieldAttr->GetStart() != pFieldAttr->GetEnd() &&
- pFieldAttr->Which() == EE_FEATURE_FIELD;
- sal_Int32 nEndField = bIsField ? pFieldAttr->GetEnd() : -1;
- do
+ bIsField = _pFieldAttr &&
+ _pFieldAttr->GetStart() == aCursor.GetIndex() &&
+ _pFieldAttr->GetStart() != _pFieldAttr->GetEnd() &&
+ _pFieldAttr->Which() == EE_FEATURE_FIELD;
+ //on every new field move the end position
+ if (bIsField)
+ nEndField = _pFieldAttr->GetEnd();
+
+ LanguageType eCurLanguage = GetLanguage( aCursor );
+ if(eCurLanguage != eStartLanguage || bIsField || bIsEndField)
{
- aCursor = CursorRight( aCursor);
- //determine whether a field and has been reached
- bool bIsEndField = nEndField == aCursor.GetIndex();
- //search for a new field attribute
- const EditCharAttrib* _pFieldAttr = aCursor.GetNode()->GetCharAttribs().
- FindFeature( aCursor.GetIndex() );
- bIsField = _pFieldAttr &&
- _pFieldAttr->GetStart() == aCursor.GetIndex() &&
- _pFieldAttr->GetStart() != _pFieldAttr->GetEnd() &&
- _pFieldAttr->Which() == EE_FEATURE_FIELD;
- //on every new field move the end position
- if (bIsField)
- nEndField = _pFieldAttr->GetEnd();
-
- LanguageType eCurLanguage = GetLanguage( aCursor );
- if(eCurLanguage != eStartLanguage || bIsField || bIsEndField)
- {
- eStartLanguage = eCurLanguage;
- //go one step back - the cursor currently selects the first character
- //with a different language
- //create a selection from start to the current Cursor
- EditSelection aSelection(aStart, aCursor);
- AddPortion(aSelection, xAlt, rToFill, bIsEndField);
- aStart = aCursor;
- }
+ eStartLanguage = eCurLanguage;
+ //go one step back - the cursor currently selects the first character
+ //with a different language
+ //create a selection from start to the current Cursor
+ EditSelection aSelection(aStart, aCursor);
+ AddPortion(aSelection, xAlt, rToFill, bIsEndField);
+ aStart = aCursor;
}
- while(aCursor.GetIndex() < aEnd.GetIndex());
- EditSelection aSelection(aStart, aCursor);
- AddPortion(aSelection, xAlt, rToFill, bIsField);
}
+ while(aCursor.GetIndex() < aEnd.GetIndex());
+ EditSelection aSelection(aStart, aCursor);
+ AddPortion(aSelection, xAlt, rToFill, bIsField);
}
}
@@ -2069,41 +2068,87 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView,
// sentence got removed in the dialog
DBG_ASSERT(pSpellInfo, "pSpellInfo not initialized");
- if (pSpellInfo &&
- !pSpellInfo->aLastSpellPortions.empty()) // no portions -> no text to be changed
+ if (!(pSpellInfo &&
+ !pSpellInfo->aLastSpellPortions.empty())) // no portions -> no text to be changed
+ return;
+
+ // get current paragraph length to calculate later on how the sentence length changed,
+ // in order to place the cursor at the end of the sentence again
+ EditSelection aOldSel( rEditView.pImpEditView->GetEditSelection() );
+ sal_Int32 nOldLen = aOldSel.Max().GetNode()->Len();
+
+ UndoActionStart( EDITUNDO_INSERT );
+ if(pSpellInfo->aLastSpellPortions.size() == rNewPortions.size())
{
- // get current paragraph length to calculate later on how the sentence length changed,
- // in order to place the cursor at the end of the sentence again
- EditSelection aOldSel( rEditView.pImpEditView->GetEditSelection() );
- sal_Int32 nOldLen = aOldSel.Max().GetNode()->Len();
-
- UndoActionStart( EDITUNDO_INSERT );
- if(pSpellInfo->aLastSpellPortions.size() == rNewPortions.size())
- {
- DBG_ASSERT( !rNewPortions.empty(), "rNewPortions should not be empty here" );
- DBG_ASSERT( pSpellInfo->aLastSpellPortions.size() == pSpellInfo->aLastSpellContentSelections.size(),
- "aLastSpellPortions and aLastSpellContentSelections size mismatch" );
-
- //the simple case: the same number of elements on both sides
- //each changed element has to be applied to the corresponding source element
- svx::SpellPortions::const_iterator aCurrentNewPortion = rNewPortions.end();
- svx::SpellPortions::const_iterator aCurrentOldPortion = pSpellInfo->aLastSpellPortions.end();
- SpellContentSelections::const_iterator aCurrentOldPosition = pSpellInfo->aLastSpellContentSelections.end();
- bool bSetToEnd = false;
- do
+ DBG_ASSERT( !rNewPortions.empty(), "rNewPortions should not be empty here" );
+ DBG_ASSERT( pSpellInfo->aLastSpellPortions.size() == pSpellInfo->aLastSpellContentSelections.size(),
+ "aLastSpellPortions and aLastSpellContentSelections size mismatch" );
+
+ //the simple case: the same number of elements on both sides
+ //each changed element has to be applied to the corresponding source element
+ svx::SpellPortions::const_iterator aCurrentNewPortion = rNewPortions.end();
+ svx::SpellPortions::const_iterator aCurrentOldPortion = pSpellInfo->aLastSpellPortions.end();
+ SpellContentSelections::const_iterator aCurrentOldPosition = pSpellInfo->aLastSpellContentSelections.end();
+ bool bSetToEnd = false;
+ do
+ {
+ --aCurrentNewPortion;
+ --aCurrentOldPortion;
+ --aCurrentOldPosition;
+ //set the cursor to the end of the sentence - necessary to
+ //resume there at the next step
+ if(!bSetToEnd)
{
- --aCurrentNewPortion;
- --aCurrentOldPortion;
- --aCurrentOldPosition;
- //set the cursor to the end of the sentence - necessary to
- //resume there at the next step
- if(!bSetToEnd)
- {
- bSetToEnd = true;
- rEditView.pImpEditView->SetEditSelection( aCurrentOldPosition->Max() );
- }
+ bSetToEnd = true;
+ rEditView.pImpEditView->SetEditSelection( aCurrentOldPosition->Max() );
+ }
- SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( aCurrentNewPortion->eLanguage );
+ SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( aCurrentNewPortion->eLanguage );
+ sal_uInt16 nLangWhichId = EE_CHAR_LANGUAGE;
+ switch(nScriptType)
+ {
+ case SvtScriptType::ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
+ case SvtScriptType::COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
+ default: break;
+ }
+ if(aCurrentNewPortion->sText != aCurrentOldPortion->sText)
+ {
+ //change text and apply language
+ SfxItemSet aSet( aEditDoc.GetItemPool(), {{nLangWhichId, nLangWhichId}});
+ aSet.Put(SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId));
+ SetAttribs( *aCurrentOldPosition, aSet );
+ ImpInsertText( *aCurrentOldPosition, aCurrentNewPortion->sText );
+ }
+ else if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage)
+ {
+ //apply language
+ SfxItemSet aSet( aEditDoc.GetItemPool(), {{nLangWhichId, nLangWhichId}});
+ aSet.Put(SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId));
+ SetAttribs( *aCurrentOldPosition, aSet );
+ }
+ }
+ while(aCurrentNewPortion != rNewPortions.begin());
+ }
+ else
+ {
+ DBG_ASSERT( !pSpellInfo->aLastSpellContentSelections.empty(), "aLastSpellContentSelections should not be empty here" );
+
+ //select the complete sentence
+ SpellContentSelections::const_iterator aCurrentEndPosition = pSpellInfo->aLastSpellContentSelections.end();
+ --aCurrentEndPosition;
+ SpellContentSelections::const_iterator aCurrentStartPosition = pSpellInfo->aLastSpellContentSelections.begin();
+ EditSelection aAllSentence(aCurrentStartPosition->Min(), aCurrentEndPosition->Max());
+
+ //delete the sentence completely
+ ImpDeleteSelection( aAllSentence );
+ EditPaM aCurrentPaM = aAllSentence.Min();
+ for(const auto& rCurrentNewPortion : rNewPortions)
+ {
+ //set the language attribute
+ LanguageType eCurLanguage = GetLanguage( aCurrentPaM );
+ if(eCurLanguage != rCurrentNewPortion.eLanguage)
+ {
+ SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( rCurrentNewPortion.eLanguage );
sal_uInt16 nLangWhichId = EE_CHAR_LANGUAGE;
switch(nScriptType)
{
@@ -2111,78 +2156,32 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView,
case SvtScriptType::COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
default: break;
}
- if(aCurrentNewPortion->sText != aCurrentOldPortion->sText)
- {
- //change text and apply language
- SfxItemSet aSet( aEditDoc.GetItemPool(), {{nLangWhichId, nLangWhichId}});
- aSet.Put(SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId));
- SetAttribs( *aCurrentOldPosition, aSet );
- ImpInsertText( *aCurrentOldPosition, aCurrentNewPortion->sText );
- }
- else if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage)
- {
- //apply language
- SfxItemSet aSet( aEditDoc.GetItemPool(), {{nLangWhichId, nLangWhichId}});
- aSet.Put(SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId));
- SetAttribs( *aCurrentOldPosition, aSet );
- }
- }
- while(aCurrentNewPortion != rNewPortions.begin());
- }
- else
- {
- DBG_ASSERT( !pSpellInfo->aLastSpellContentSelections.empty(), "aLastSpellContentSelections should not be empty here" );
-
- //select the complete sentence
- SpellContentSelections::const_iterator aCurrentEndPosition = pSpellInfo->aLastSpellContentSelections.end();
- --aCurrentEndPosition;
- SpellContentSelections::const_iterator aCurrentStartPosition = pSpellInfo->aLastSpellContentSelections.begin();
- EditSelection aAllSentence(aCurrentStartPosition->Min(), aCurrentEndPosition->Max());
-
- //delete the sentence completely
- ImpDeleteSelection( aAllSentence );
- EditPaM aCurrentPaM = aAllSentence.Min();
- for(const auto& rCurrentNewPortion : rNewPortions)
- {
- //set the language attribute
- LanguageType eCurLanguage = GetLanguage( aCurrentPaM );
- if(eCurLanguage != rCurrentNewPortion.eLanguage)
- {
- SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( rCurrentNewPortion.eLanguage );
- sal_uInt16 nLangWhichId = EE_CHAR_LANGUAGE;
- switch(nScriptType)
- {
- case SvtScriptType::ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
- case SvtScriptType::COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
- default: break;
- }
- SfxItemSet aSet( aEditDoc.GetItemPool(), {{nLangWhichId, nLangWhichId}});
- aSet.Put(SvxLanguageItem(rCurrentNewPortion.eLanguage, nLangWhichId));
- SetAttribs( aCurrentPaM, aSet );
- }
- //insert the new string and set the cursor to the end of the inserted string
- aCurrentPaM = ImpInsertText( aCurrentPaM , rCurrentNewPortion.sText );
+ SfxItemSet aSet( aEditDoc.GetItemPool(), {{nLangWhichId, nLangWhichId}});
+ aSet.Put(SvxLanguageItem(rCurrentNewPortion.eLanguage, nLangWhichId));
+ SetAttribs( aCurrentPaM, aSet );
}
+ //insert the new string and set the cursor to the end of the inserted string
+ aCurrentPaM = ImpInsertText( aCurrentPaM , rCurrentNewPortion.sText );
}
- UndoActionEnd();
-
- EditPaM aNext;
- if (bRecheck)
- aNext = pSpellInfo->aCurSentenceStart;
- else
- {
- // restore cursor position to the end of the modified sentence.
- // (This will define the continuation position for spell/grammar checking)
- // First: check if the sentence/para length changed
- const sal_Int32 nDelta = rEditView.pImpEditView->GetEditSelection().Max().GetNode()->Len() - nOldLen;
- const sal_Int32 nEndOfSentence = aOldSel.Max().GetIndex() + nDelta;
- aNext = EditPaM( aOldSel.Max().GetNode(), nEndOfSentence );
- }
- rEditView.pImpEditView->SetEditSelection( aNext );
+ }
+ UndoActionEnd();
- FormatAndUpdate();
- aEditDoc.SetModified(true);
+ EditPaM aNext;
+ if (bRecheck)
+ aNext = pSpellInfo->aCurSentenceStart;
+ else
+ {
+ // restore cursor position to the end of the modified sentence.
+ // (This will define the continuation position for spell/grammar checking)
+ // First: check if the sentence/para length changed
+ const sal_Int32 nDelta = rEditView.pImpEditView->GetEditSelection().Max().GetNode()->Len() - nOldLen;
+ const sal_Int32 nEndOfSentence = aOldSel.Max().GetIndex() + nDelta;
+ aNext = EditPaM( aOldSel.Max().GetNode(), nEndOfSentence );
}
+ rEditView.pImpEditView->SetEditSelection( aNext );
+
+ FormatAndUpdate();
+ aEditDoc.SetModified(true);
}
void ImpEditEngine::PutSpellingToSentenceStart( EditView const & rEditView )
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index 0e6b6af722fa..0e5a294e0149 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -680,36 +680,36 @@ void ImpEditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
if ( !pNode )
return;
- if ( !( pNode->GetContentAttribs().GetItems() == rSet ) )
+ if ( pNode->GetContentAttribs().GetItems() == rSet )
+ return;
+
+ if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() )
{
- if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() )
+ if ( rSet.GetPool() != &aEditDoc.GetItemPool() )
{
- if ( rSet.GetPool() != &aEditDoc.GetItemPool() )
- {
- SfxItemSet aTmpSet( GetEmptyItemSet() );
- aTmpSet.Put( rSet );
- InsertUndo(std::make_unique<EditUndoSetParaAttribs>(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), aTmpSet));
- }
- else
- {
- InsertUndo(std::make_unique<EditUndoSetParaAttribs>(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), rSet));
- }
+ SfxItemSet aTmpSet( GetEmptyItemSet() );
+ aTmpSet.Put( rSet );
+ InsertUndo(std::make_unique<EditUndoSetParaAttribs>(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), aTmpSet));
+ }
+ else
+ {
+ InsertUndo(std::make_unique<EditUndoSetParaAttribs>(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), rSet));
}
+ }
- bool bCheckLanguage = ( rSet.GetItemState( EE_CHAR_LANGUAGE ) == SfxItemState::SET ) ||
- ( rSet.GetItemState( EE_CHAR_LANGUAGE_CJK ) == SfxItemState::SET ) ||
- ( rSet.GetItemState( EE_CHAR_LANGUAGE_CTL ) == SfxItemState::SET );
+ bool bCheckLanguage = ( rSet.GetItemState( EE_CHAR_LANGUAGE ) == SfxItemState::SET ) ||
+ ( rSet.GetItemState( EE_CHAR_LANGUAGE_CJK ) == SfxItemState::SET ) ||
+ ( rSet.GetItemState( EE_CHAR_LANGUAGE_CTL ) == SfxItemState::SET );
- pNode->GetContentAttribs().GetItems().Set( rSet );
+ pNode->GetContentAttribs().GetItems().Set( rSet );
- if ( bCheckLanguage && pNode->GetWrongList() )
- pNode->GetWrongList()->ResetInvalidRange(0, pNode->Len());
+ if ( bCheckLanguage && pNode->GetWrongList() )
+ pNode->GetWrongList()->ResetInvalidRange(0, pNode->Len());
- if ( aStatus.UseCharAttribs() )
- pNode->CreateDefFont();
+ if ( aStatus.UseCharAttribs() )
+ pNode->CreateDefFont();
- ParaAttribsChanged( pNode );
- }
+ ParaAttribsChanged( pNode );
}
const SfxItemSet& ImpEditEngine::GetParaAttribs( sal_Int32 nPara ) const
@@ -737,19 +737,19 @@ void ImpEditEngine::GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>&
{
rLst.clear();
const ContentNode* pNode = aEditDoc.GetObject( nPara );
- if ( pNode )
+ if ( !pNode )
+ return;
+
+ rLst.reserve(pNode->GetCharAttribs().Count());
+ const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
+ for (const auto & i : rAttrs)
{
- rLst.reserve(pNode->GetCharAttribs().Count());
- const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
- for (const auto & i : rAttrs)
- {
- const EditCharAttrib& rAttr = *i;
- EECharAttrib aEEAttr;
- aEEAttr.pAttr = rAttr.GetItem();
- aEEAttr.nStart = rAttr.GetStart();
- aEEAttr.nEnd = rAttr.GetEnd();
- rLst.push_back(aEEAttr);
- }
+ const EditCharAttrib& rAttr = *i;
+ EECharAttrib aEEAttr;
+ aEEAttr.pAttr = rAttr.GetItem();
+ aEEAttr.nStart = rAttr.GetStart();
+ aEEAttr.nEnd = rAttr.GetEnd();
+ rLst.push_back(aEEAttr);
}
}