summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/accessibility/AccessibleContextBase.cxx28
-rw-r--r--editeng/source/editeng/impedit2.cxx106
-rw-r--r--editeng/source/misc/svxacorr.cxx183
-rw-r--r--editeng/source/outliner/outliner.cxx76
-rw-r--r--editeng/source/uno/unoedprx.cxx36
-rw-r--r--editeng/source/uno/unonrule.cxx49
-rw-r--r--editeng/source/uno/unotext.cxx238
7 files changed, 355 insertions, 361 deletions
diff --git a/editeng/source/accessibility/AccessibleContextBase.cxx b/editeng/source/accessibility/AccessibleContextBase.cxx
index dd8f5e8d0686..ef09f28cde8c 100644
--- a/editeng/source/accessibility/AccessibleContextBase.cxx
+++ b/editeng/source/accessibility/AccessibleContextBase.cxx
@@ -210,22 +210,24 @@ sal_Int32 SAL_CALL
// Use a simple but slow solution for now. Optimize later.
// Iterate over all the parent's children and search for this object.
- if (mxParent.is())
+ if (!mxParent.is())
+ // Return -1 to indicate that this object's parent does not know about the
+ // object.
+ return -1;
+
+ uno::Reference<XAccessibleContext> xParentContext (
+ mxParent->getAccessibleContext());
+ if (xParentContext.is())
{
- uno::Reference<XAccessibleContext> xParentContext (
- mxParent->getAccessibleContext());
- if (xParentContext.is())
+ sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
+ for (sal_Int32 i=0; i<nChildCount; i++)
{
- sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
- for (sal_Int32 i=0; i<nChildCount; i++)
+ uno::Reference<XAccessible> xChild (xParentContext->getAccessibleChild (i));
+ if (xChild.is())
{
- uno::Reference<XAccessible> xChild (xParentContext->getAccessibleChild (i));
- if (xChild.is())
- {
- uno::Reference<XAccessibleContext> xChildContext = xChild->getAccessibleContext();
- if (xChildContext == static_cast<XAccessibleContext*>(this))
- return i;
- }
+ uno::Reference<XAccessibleContext> xChildContext = xChild->getAccessibleContext();
+ if (xChildContext == static_cast<XAccessibleContext*>(this))
+ return i;
}
}
}
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 8f3fb3f34eaa..b19d1b4a673a 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -302,32 +302,32 @@ bool ImpEditEngine::MouseButtonDown( const MouseEvent& rMEvt, EditView* pView )
GetSelEngine().SelMouseButtonDown( rMEvt );
// Special treatment
EditSelection aCurSel( pView->pImpEditView->GetEditSelection() );
- if ( !rMEvt.IsShift() )
+ if ( rMEvt.IsShift() )
+ return true;
+
+ if ( rMEvt.GetClicks() == 2 )
{
- if ( rMEvt.GetClicks() == 2 )
- {
- // So that the SelectionEngine knows about the anchor.
- aSelEngine.CursorPosChanging( true, false );
-
- EditSelection aNewSelection( SelectWord( aCurSel ) );
- pView->pImpEditView->DrawSelectionXOR();
- pView->pImpEditView->SetEditSelection( aNewSelection );
- pView->pImpEditView->DrawSelectionXOR();
- pView->ShowCursor();
- }
- else if ( rMEvt.GetClicks() == 3 )
- {
- // So that the SelectionEngine knows about the anchor.
- aSelEngine.CursorPosChanging( true, false );
-
- EditSelection aNewSelection( aCurSel );
- aNewSelection.Min().SetIndex( 0 );
- aNewSelection.Max().SetIndex( aCurSel.Min().GetNode()->Len() );
- pView->pImpEditView->DrawSelectionXOR();
- pView->pImpEditView->SetEditSelection( aNewSelection );
- pView->pImpEditView->DrawSelectionXOR();
- pView->ShowCursor();
- }
+ // So that the SelectionEngine knows about the anchor.
+ aSelEngine.CursorPosChanging( true, false );
+
+ EditSelection aNewSelection( SelectWord( aCurSel ) );
+ pView->pImpEditView->DrawSelectionXOR();
+ pView->pImpEditView->SetEditSelection( aNewSelection );
+ pView->pImpEditView->DrawSelectionXOR();
+ pView->ShowCursor();
+ }
+ else if ( rMEvt.GetClicks() == 3 )
+ {
+ // So that the SelectionEngine knows about the anchor.
+ aSelEngine.CursorPosChanging( true, false );
+
+ EditSelection aNewSelection( aCurSel );
+ aNewSelection.Min().SetIndex( 0 );
+ aNewSelection.Max().SetIndex( aCurSel.Min().GetNode()->Len() );
+ pView->pImpEditView->DrawSelectionXOR();
+ pView->pImpEditView->SetEditSelection( aNewSelection );
+ pView->pImpEditView->DrawSelectionXOR();
+ pView->ShowCursor();
}
return true;
}
@@ -603,36 +603,36 @@ bool ImpEditEngine::MouseButtonUp( const MouseEvent& rMEvt, EditView* pView )
// Special treatments
EditSelection aCurSel( pView->pImpEditView->GetEditSelection() );
- if ( !aCurSel.HasRange() )
+ if ( aCurSel.HasRange() )
+ return true;
+
+ if ( ( rMEvt.GetClicks() != 1 ) || !rMEvt.IsLeft() || rMEvt.IsMod2() )
+ return true;
+
+ const OutputDevice& rOutDev = pView->getEditViewCallbacks() ? pView->getEditViewCallbacks()->EditViewOutputDevice() : *pView->GetWindow()->GetOutDev();
+ Point aLogicClick = rOutDev.PixelToLogic(rMEvt.GetPosPixel());
+ const SvxFieldItem* pFld = pView->GetField(aLogicClick);
+ if (!pFld)
+ return true;
+
+ // tdf#121039 When in edit mode, editeng is responsible for opening the URL on mouse click
+ bool bUrlOpened = GetEditEnginePtr()->FieldClicked( *pFld );
+ if (bUrlOpened)
+ return true;
+
+ if (auto pUrlField = dynamic_cast<const SvxURLField*>(pFld->GetField()))
{
- if ( ( rMEvt.GetClicks() == 1 ) && rMEvt.IsLeft() && !rMEvt.IsMod2() )
+ bool bCtrlClickHappened = rMEvt.IsMod1();
+ bool bCtrlClickSecOption
+ = SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::CtrlClickHyperlink);
+ if ((bCtrlClickHappened && bCtrlClickSecOption)
+ || (!bCtrlClickHappened && !bCtrlClickSecOption))
{
- const OutputDevice& rOutDev = pView->getEditViewCallbacks() ? pView->getEditViewCallbacks()->EditViewOutputDevice() : *pView->GetWindow()->GetOutDev();
- Point aLogicClick = rOutDev.PixelToLogic(rMEvt.GetPosPixel());
- if (const SvxFieldItem* pFld = pView->GetField(aLogicClick))
- {
- bool bUrlOpened = GetEditEnginePtr()->FieldClicked( *pFld );
-
- // tdf#121039 When in edit mode, editeng is responsible for opening the URL on mouse click
- if (!bUrlOpened)
- {
- if (auto pUrlField = dynamic_cast<const SvxURLField*>(pFld->GetField()))
- {
- bool bCtrlClickHappened = rMEvt.IsMod1();
- bool bCtrlClickSecOption
- = SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::CtrlClickHyperlink);
- if ((bCtrlClickHappened && bCtrlClickSecOption)
- || (!bCtrlClickHappened && !bCtrlClickSecOption))
- {
- css::uno::Reference<css::system::XSystemShellExecute> exec(
- css::system::SystemShellExecute::create(
- comphelper::getProcessComponentContext()));
- exec->execute(pUrlField->GetURL(), OUString(),
- css::system::SystemShellExecuteFlags::DEFAULTS);
- }
- }
- }
- }
+ css::uno::Reference<css::system::XSystemShellExecute> exec(
+ css::system::SystemShellExecute::create(
+ comphelper::getProcessComponentContext()));
+ exec->execute(pUrlField->GetURL(), OUString(),
+ css::system::SystemShellExecuteFlags::DEFAULTS);
}
}
return true;
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 32ae3477a9d2..eec000787a6f 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -2942,107 +2942,106 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p
// direct replacement of keywords surrounded by colons (for example, ":name:")
bool bColonNameColon = rTxt.getLength() > nEndPos &&
rTxt[nEndPos] == ':' && rChk[0] == ':' && rChk.endsWith(":");
- if ( nEndPos + (bColonNameColon ? 1 : 0) >= rChk.getLength() - left_wildcard - right_wildcard )
- {
+ if ( nEndPos + (bColonNameColon ? 1 : 0) < rChk.getLength() - left_wildcard - right_wildcard )
+ return nullptr;
- bool bWasWordDelim = false;
- sal_Int32 nCalcStt = nEndPos - rChk.getLength() + left_wildcard;
- if (bColonNameColon)
- nCalcStt++;
- if( !right_wildcard && ( !nCalcStt || nCalcStt == rStt || left_wildcard || bColonNameColon ||
- ( nCalcStt < rStt &&
- IsWordDelim( rTxt[ nCalcStt - 1 ] ))) )
+ bool bWasWordDelim = false;
+ sal_Int32 nCalcStt = nEndPos - rChk.getLength() + left_wildcard;
+ if (bColonNameColon)
+ nCalcStt++;
+ if( !right_wildcard && ( !nCalcStt || nCalcStt == rStt || left_wildcard || bColonNameColon ||
+ ( nCalcStt < rStt &&
+ IsWordDelim( rTxt[ nCalcStt - 1 ] ))) )
+ {
+ TransliterationWrapper& rCmp = GetIgnoreTranslWrapper();
+ OUString sWord = rTxt.copy(nCalcStt, rChk.getLength() - left_wildcard);
+ if( (!left_wildcard && rCmp.isEqual( rChk, sWord )) || (left_wildcard && rCmp.isEqual( rChk.copy(left_wildcard), sWord) ))
{
- TransliterationWrapper& rCmp = GetIgnoreTranslWrapper();
- OUString sWord = rTxt.copy(nCalcStt, rChk.getLength() - left_wildcard);
- if( (!left_wildcard && rCmp.isEqual( rChk, sWord )) || (left_wildcard && rCmp.isEqual( rChk.copy(left_wildcard), sWord) ))
+ rStt = nCalcStt;
+ if (!left_wildcard)
{
- rStt = nCalcStt;
- if (!left_wildcard)
- {
- // fdo#33899 avoid "1/2", "1/3".. to be replaced by fractions in dates, eg. 1/2/14
- if (rTxt.getLength() > nEndPos && rTxt[nEndPos] == '/' && rChk.indexOf('/') != -1)
- return nullptr;
- return pFnd;
- }
- // get the first word delimiter position before the matching ".*word" pattern
- while( rStt && !(bWasWordDelim = IsWordDelim( rTxt[ --rStt ])))
- ;
- if (bWasWordDelim) rStt++;
- OUString left_pattern = rTxt.copy(rStt, nEndPos - rStt - rChk.getLength() + left_wildcard);
- // avoid double spaces before simple "word" replacement
- left_pattern += (left_pattern.getLength() == 0 && pFnd->GetLong()[0] == 0x20) ? pFnd->GetLong().copy(1) : pFnd->GetLong();
- if( const SvxAutocorrWord* pNew = Insert( SvxAutocorrWord(rTxt.copy(rStt, nEndPos - rStt), left_pattern) ) )
- return pNew;
+ // fdo#33899 avoid "1/2", "1/3".. to be replaced by fractions in dates, eg. 1/2/14
+ if (rTxt.getLength() > nEndPos && rTxt[nEndPos] == '/' && rChk.indexOf('/') != -1)
+ return nullptr;
+ return pFnd;
}
- } else
- // match "word.*" or ".*word.*" patterns, eg. "i18n.*", ".*---.*", TODO: add transliteration support
- if ( right_wildcard )
- {
+ // get the first word delimiter position before the matching ".*word" pattern
+ while( rStt && !(bWasWordDelim = IsWordDelim( rTxt[ --rStt ])))
+ ;
+ if (bWasWordDelim) rStt++;
+ OUString left_pattern = rTxt.copy(rStt, nEndPos - rStt - rChk.getLength() + left_wildcard);
+ // avoid double spaces before simple "word" replacement
+ left_pattern += (left_pattern.getLength() == 0 && pFnd->GetLong()[0] == 0x20) ? pFnd->GetLong().copy(1) : pFnd->GetLong();
+ if( const SvxAutocorrWord* pNew = Insert( SvxAutocorrWord(rTxt.copy(rStt, nEndPos - rStt), left_pattern) ) )
+ return pNew;
+ }
+ } else
+ // match "word.*" or ".*word.*" patterns, eg. "i18n.*", ".*---.*", TODO: add transliteration support
+ if ( right_wildcard )
+ {
- OUString sTmp( rChk.copy( left_wildcard, rChk.getLength() - left_wildcard - right_wildcard ) );
- // Get the last word delimiter position
- bool not_suffix;
+ OUString sTmp( rChk.copy( left_wildcard, rChk.getLength() - left_wildcard - right_wildcard ) );
+ // Get the last word delimiter position
+ bool not_suffix;
- while( nSttWdPos && !(bWasWordDelim = IsWordDelim( rTxt[ --nSttWdPos ])))
- ;
- // search the first occurrence (with a left word delimitation, if needed)
- sal_Int32 nFndPos = -1;
- do {
- nFndPos = rTxt.indexOf( sTmp, nFndPos + 1);
- if (nFndPos == -1)
- break;
- not_suffix = bWasWordDelim && (nSttWdPos >= (nFndPos + sTmp.getLength()));
- } while ( (!left_wildcard && nFndPos && !IsWordDelim( rTxt[ nFndPos - 1 ])) || not_suffix );
+ while( nSttWdPos && !(bWasWordDelim = IsWordDelim( rTxt[ --nSttWdPos ])))
+ ;
+ // search the first occurrence (with a left word delimitation, if needed)
+ sal_Int32 nFndPos = -1;
+ do {
+ nFndPos = rTxt.indexOf( sTmp, nFndPos + 1);
+ if (nFndPos == -1)
+ break;
+ not_suffix = bWasWordDelim && (nSttWdPos >= (nFndPos + sTmp.getLength()));
+ } while ( (!left_wildcard && nFndPos && !IsWordDelim( rTxt[ nFndPos - 1 ])) || not_suffix );
- if ( nFndPos != -1 )
- {
- sal_Int32 extra_repl = nFndPos + sTmp.getLength() > nEndPos ? 1: 0; // for patterns with terminating characters, eg. "a:"
+ if ( nFndPos != -1 )
+ {
+ sal_Int32 extra_repl = nFndPos + sTmp.getLength() > nEndPos ? 1: 0; // for patterns with terminating characters, eg. "a:"
- if ( left_wildcard )
- {
- // get the first word delimiter position before the matching ".*word.*" pattern
- while( nFndPos && !(bWasWordDelim = IsWordDelim( rTxt[ --nFndPos ])))
- ;
- if (bWasWordDelim) nFndPos++;
- }
- if (nEndPos + extra_repl <= nFndPos)
- {
- return nullptr;
- }
- // store matching pattern and its replacement as a new list item, eg. "i18ns" -> "internationalizations"
- OUString aShort = rTxt.copy(nFndPos, nEndPos - nFndPos + extra_repl);
+ if ( left_wildcard )
+ {
+ // get the first word delimiter position before the matching ".*word.*" pattern
+ while( nFndPos && !(bWasWordDelim = IsWordDelim( rTxt[ --nFndPos ])))
+ ;
+ if (bWasWordDelim) nFndPos++;
+ }
+ if (nEndPos + extra_repl <= nFndPos)
+ {
+ return nullptr;
+ }
+ // store matching pattern and its replacement as a new list item, eg. "i18ns" -> "internationalizations"
+ OUString aShort = rTxt.copy(nFndPos, nEndPos - nFndPos + extra_repl);
- OUString aLong;
- rStt = nFndPos;
- if ( !left_wildcard )
- {
- sal_Int32 siz = nEndPos - nFndPos - sTmp.getLength();
- aLong = pFnd->GetLong() + (siz > 0 ? rTxt.copy(nFndPos + sTmp.getLength(), siz) : "");
- } else {
- OUStringBuffer buf;
- do {
- nSttWdPos = rTxt.indexOf( sTmp, nFndPos);
- if (nSttWdPos != -1)
- {
- sal_Int32 nTmp(nFndPos);
- while (nTmp < nSttWdPos && !IsWordDelim(rTxt[nTmp]))
- nTmp++;
- if (nTmp < nSttWdPos)
- break; // word delimiter found
- buf.append(rTxt.subView(nFndPos, nSttWdPos - nFndPos)).append(pFnd->GetLong());
- nFndPos = nSttWdPos + sTmp.getLength();
- }
- } while (nSttWdPos != -1);
- if (nEndPos - nFndPos > extra_repl)
- buf.append(rTxt.subView(nFndPos, nEndPos - nFndPos));
- aLong = buf.makeStringAndClear();
- }
- if ( const SvxAutocorrWord* pNew = Insert( SvxAutocorrWord(aShort, aLong) ) )
- {
- if ( (rTxt.getLength() > nEndPos && IsWordDelim(rTxt[nEndPos])) || rTxt.getLength() == nEndPos )
- return pNew;
- }
+ OUString aLong;
+ rStt = nFndPos;
+ if ( !left_wildcard )
+ {
+ sal_Int32 siz = nEndPos - nFndPos - sTmp.getLength();
+ aLong = pFnd->GetLong() + (siz > 0 ? rTxt.copy(nFndPos + sTmp.getLength(), siz) : "");
+ } else {
+ OUStringBuffer buf;
+ do {
+ nSttWdPos = rTxt.indexOf( sTmp, nFndPos);
+ if (nSttWdPos != -1)
+ {
+ sal_Int32 nTmp(nFndPos);
+ while (nTmp < nSttWdPos && !IsWordDelim(rTxt[nTmp]))
+ nTmp++;
+ if (nTmp < nSttWdPos)
+ break; // word delimiter found
+ buf.append(rTxt.subView(nFndPos, nSttWdPos - nFndPos)).append(pFnd->GetLong());
+ nFndPos = nSttWdPos + sTmp.getLength();
+ }
+ } while (nSttWdPos != -1);
+ if (nEndPos - nFndPos > extra_repl)
+ buf.append(rTxt.subView(nFndPos, nEndPos - nFndPos));
+ aLong = buf.makeStringAndClear();
+ }
+ if ( const SvxAutocorrWord* pNew = Insert( SvxAutocorrWord(aShort, aLong) ) )
+ {
+ if ( (rTxt.getLength() > nEndPos && IsWordDelim(rTxt[nEndPos])) || rTxt.getLength() == nEndPos )
+ return pNew;
}
}
}
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index d50bdc9b3895..d5e6630cefe4 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -754,54 +754,52 @@ void Outliner::SetCharAttribs(sal_Int32 nPara, const SfxItemSet& rSet)
bool Outliner::Expand( Paragraph const * pPara )
{
- if ( pParaList->HasHiddenChildren( pPara ) )
+ if ( !pParaList->HasHiddenChildren( pPara ) )
+ return false;
+
+ std::unique_ptr<OLUndoExpand> pUndo;
+ bool bUndo = IsUndoEnabled() && !IsInUndo();
+ if( bUndo )
{
- std::unique_ptr<OLUndoExpand> pUndo;
- bool bUndo = IsUndoEnabled() && !IsInUndo();
- if( bUndo )
- {
- UndoActionStart( OLUNDO_EXPAND );
- pUndo.reset( new OLUndoExpand( this, OLUNDO_EXPAND ) );
- pUndo->nCount = pParaList->GetAbsPos( pPara );
- }
- pParaList->Expand( pPara );
- InvalidateBullet(pParaList->GetAbsPos(pPara));
- if( bUndo )
- {
- InsertUndo( std::move(pUndo) );
- UndoActionEnd();
- }
- return true;
+ UndoActionStart( OLUNDO_EXPAND );
+ pUndo.reset( new OLUndoExpand( this, OLUNDO_EXPAND ) );
+ pUndo->nCount = pParaList->GetAbsPos( pPara );
+ }
+ pParaList->Expand( pPara );
+ InvalidateBullet(pParaList->GetAbsPos(pPara));
+ if( bUndo )
+ {
+ InsertUndo( std::move(pUndo) );
+ UndoActionEnd();
}
- return false;
+ return true;
}
bool Outliner::Collapse( Paragraph const * pPara )
{
- if ( pParaList->HasVisibleChildren( pPara ) ) // expanded
- {
- std::unique_ptr<OLUndoExpand> pUndo;
- bool bUndo = false;
+ if ( !pParaList->HasVisibleChildren( pPara ) ) // collapsed
+ return false;
- if( !IsInUndo() && IsUndoEnabled() )
- bUndo = true;
- if( bUndo )
- {
- UndoActionStart( OLUNDO_COLLAPSE );
- pUndo.reset( new OLUndoExpand( this, OLUNDO_COLLAPSE ) );
- pUndo->nCount = pParaList->GetAbsPos( pPara );
- }
+ std::unique_ptr<OLUndoExpand> pUndo;
+ bool bUndo = false;
- pParaList->Collapse( pPara );
- InvalidateBullet(pParaList->GetAbsPos(pPara));
- if( bUndo )
- {
- InsertUndo( std::move(pUndo) );
- UndoActionEnd();
- }
- return true;
+ if( !IsInUndo() && IsUndoEnabled() )
+ bUndo = true;
+ if( bUndo )
+ {
+ UndoActionStart( OLUNDO_COLLAPSE );
+ pUndo.reset( new OLUndoExpand( this, OLUNDO_COLLAPSE ) );
+ pUndo->nCount = pParaList->GetAbsPos( pPara );
}
- return false;
+
+ pParaList->Collapse( pPara );
+ InvalidateBullet(pParaList->GetAbsPos(pPara));
+ if( bUndo )
+ {
+ InsertUndo( std::move(pUndo) );
+ UndoActionEnd();
+ }
+ return true;
}
diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx
index a0eb64a93224..91a4ac15b600 100644
--- a/editeng/source/uno/unoedprx.cxx
+++ b/editeng/source/uno/unoedprx.cxx
@@ -815,32 +815,30 @@ bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_Int32&
}
}
- if( aIndex.InField() )
- {
- OutputDevice* pOutDev = GetRefDevice();
+ if( !aIndex.InField() )
+ return true;
- DBG_ASSERT(pOutDev!=nullptr, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device");
+ OutputDevice* pOutDev = GetRefDevice();
- if( !pOutDev )
- return false;
+ DBG_ASSERT(pOutDev!=nullptr, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device");
- ESelection aSelection = MakeEESelection( aIndex );
- SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mpTextForwarder->GetAttribs( aSelection ) );
- AccessibleStringWrap aStringWrap( *pOutDev,
- aFont,
- mpTextForwarder->GetText( aSelection ) );
+ if( !pOutDev )
+ return false;
- tools::Rectangle aRect = mpTextForwarder->GetCharBounds( nPara, aIndex.GetEEIndex() );
- Point aPoint = rPoint;
- aPoint.Move( -aRect.Left(), -aRect.Top() );
+ ESelection aSelection = MakeEESelection( aIndex );
+ SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mpTextForwarder->GetAttribs( aSelection ) );
+ AccessibleStringWrap aStringWrap( *pOutDev,
+ aFont,
+ mpTextForwarder->GetText( aSelection ) );
- DBG_ASSERT(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) >= 0,
- "SvxAccessibleTextIndex::SetIndex: index value overflow");
+ tools::Rectangle aRect = mpTextForwarder->GetCharBounds( nPara, aIndex.GetEEIndex() );
+ Point aPoint = rPoint;
+ aPoint.Move( -aRect.Left(), -aRect.Top() );
- nIndex = (aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( aPoint ));
- return true;
- }
+ DBG_ASSERT(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) >= 0,
+ "SvxAccessibleTextIndex::SetIndex: index value overflow");
+ nIndex = (aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( aPoint ));
return true;
}
diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx
index 5ac7c4c1ba41..d850f70265f6 100644
--- a/editeng/source/uno/unonrule.cxx
+++ b/editeng/source/uno/unonrule.cxx
@@ -504,37 +504,34 @@ sal_Int16 SAL_CALL SvxUnoNumberingRulesCompare::compare( const Any& Any1, const
sal_Int16 SvxUnoNumberingRules::Compare( const Any& Any1, const Any& Any2 )
{
Reference< XIndexReplace > x1( Any1, UNO_QUERY ), x2( Any2, UNO_QUERY );
- if( x1.is() && x2.is() )
- {
- if( x1.get() == x2.get() )
- return 0;
+ if( !x1 || !x2 )
+ return -1;
- SvxUnoNumberingRules* pRule1 = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( x1 );
- if( pRule1 )
- {
- SvxUnoNumberingRules* pRule2 = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( x2 );
- if( pRule2 )
- {
- const SvxNumRule& rRule1 = pRule1->getNumRule();
- const SvxNumRule& rRule2 = pRule2->getNumRule();
+ if( x1.get() == x2.get() )
+ return 0;
- const sal_uInt16 nLevelCount1 = rRule1.GetLevelCount();
- const sal_uInt16 nLevelCount2 = rRule2.GetLevelCount();
+ SvxUnoNumberingRules* pRule1 = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( x1 );
+ if( !pRule1 )
+ return -1;
+ SvxUnoNumberingRules* pRule2 = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( x2 );
+ if( !pRule2 )
+ return -1;
- if( nLevelCount1 == 0 || nLevelCount2 == 0 )
- return -1;
+ const SvxNumRule& rRule1 = pRule1->getNumRule();
+ const SvxNumRule& rRule2 = pRule2->getNumRule();
- for( sal_uInt16 i = 0; (i < nLevelCount1) && (i < nLevelCount2); i++ )
- {
- if( rRule1.GetLevel(i) != rRule2.GetLevel(i) )
- return -1;
- }
- return 0;
- }
- }
- }
+ const sal_uInt16 nLevelCount1 = rRule1.GetLevelCount();
+ const sal_uInt16 nLevelCount2 = rRule2.GetLevelCount();
+
+ if( nLevelCount1 == 0 || nLevelCount2 == 0 )
+ return -1;
- return -1;
+ for( sal_uInt16 i = 0; (i < nLevelCount1) && (i < nLevelCount2); i++ )
+ {
+ if( rRule1.GetLevel(i) != rRule2.GetLevel(i) )
+ return -1;
+ }
+ return 0;
}
Reference< XAnyCompare > SvxCreateNumRuleCompare() noexcept
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 16ffaaa8bbfa..b8ad3d09e9ed 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -1064,122 +1064,121 @@ uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(co
bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const SfxItemPropertyMapEntry* pMap, beans::PropertyState& rState)
{
+ if(!pSet || !pMap)
+ return true;
+ SfxItemState eItemState = SfxItemState::DEFAULT;
+ bool bItemStateSet(false);
+
bool bUnknownPropertyFound = false;
- if(pSet && pMap)
+ switch( pMap->nWID )
{
- SfxItemState eItemState = SfxItemState::DEFAULT;
- bool bItemStateSet(false);
-
- switch( pMap->nWID )
- {
- case WID_FONTDESC:
+ case WID_FONTDESC:
+ {
+ const sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap;
+ while( *pWhichId )
{
- const sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap;
- while( *pWhichId )
+ const SfxItemState eTempItemState(pSet->GetItemState( *pWhichId ));
+
+ switch( eTempItemState )
{
- const SfxItemState eTempItemState(pSet->GetItemState( *pWhichId ));
+ case SfxItemState::DISABLED:
+ case SfxItemState::DONTCARE:
+ eItemState = SfxItemState::DONTCARE;
+ bItemStateSet = true;
+ break;
- switch( eTempItemState )
+ case SfxItemState::DEFAULT:
+ if( !bItemStateSet )
{
- case SfxItemState::DISABLED:
- case SfxItemState::DONTCARE:
- eItemState = SfxItemState::DONTCARE;
+ eItemState = SfxItemState::DEFAULT;
bItemStateSet = true;
- break;
-
- case SfxItemState::DEFAULT:
- if( !bItemStateSet )
- {
- eItemState = SfxItemState::DEFAULT;
- bItemStateSet = true;
- }
- break;
-
- case SfxItemState::SET:
- if( !bItemStateSet )
- {
- eItemState = SfxItemState::SET;
- bItemStateSet = true;
- }
- break;
- default:
- bUnknownPropertyFound = true;
- break;
}
+ break;
- pWhichId++;
+ case SfxItemState::SET:
+ if( !bItemStateSet )
+ {
+ eItemState = SfxItemState::SET;
+ bItemStateSet = true;
+ }
+ break;
+ default:
+ bUnknownPropertyFound = true;
+ break;
}
- }
- break;
- case WID_NUMLEVEL:
- case WID_NUMBERINGSTARTVALUE:
- case WID_PARAISNUMBERINGRESTART:
- eItemState = SfxItemState::SET;
- bItemStateSet = true;
- break;
-
- default:
- if(0 != pMap->nWID)
- {
- eItemState = pSet->GetItemState( pMap->nWID, false );
- bItemStateSet = true;
+ pWhichId++;
}
- break;
- }
+ }
+ break;
- if( bUnknownPropertyFound )
- return false;
+ case WID_NUMLEVEL:
+ case WID_NUMBERINGSTARTVALUE:
+ case WID_PARAISNUMBERINGRESTART:
+ eItemState = SfxItemState::SET;
+ bItemStateSet = true;
+ break;
- if(bItemStateSet)
- {
- if (pMap->nWID == EE_CHAR_COLOR)
+ default:
+ if(0 != pMap->nWID)
{
- // Theme & effects can be DEFAULT_VALUE, even if the same pool item has a color
- // which is a DIRECT_VALUE.
- const SvxColorItem* pColor = pSet->GetItem<SvxColorItem>(EE_CHAR_COLOR);
- switch (pMap->nMemberId)
- {
- case MID_COLOR_THEME_INDEX:
- if (pColor->GetThemeIndex() == -1)
- {
- eItemState = SfxItemState::DEFAULT;
- }
- break;
- case MID_COLOR_LUM_MOD:
- if (pColor->GetLumMod() == 10000)
- {
- eItemState = SfxItemState::DEFAULT;
- }
- break;
- case MID_COLOR_LUM_OFF:
- if (pColor->GetLumOff() == 0)
- {
- eItemState = SfxItemState::DEFAULT;
- }
- break;
- }
+ eItemState = pSet->GetItemState( pMap->nWID, false );
+ bItemStateSet = true;
}
+ break;
+ }
+
+ if( bUnknownPropertyFound )
+ return false;
- switch( eItemState )
+ if(bItemStateSet)
+ {
+ if (pMap->nWID == EE_CHAR_COLOR)
+ {
+ // Theme & effects can be DEFAULT_VALUE, even if the same pool item has a color
+ // which is a DIRECT_VALUE.
+ const SvxColorItem* pColor = pSet->GetItem<SvxColorItem>(EE_CHAR_COLOR);
+ switch (pMap->nMemberId)
{
- case SfxItemState::SET:
- rState = beans::PropertyState_DIRECT_VALUE;
+ case MID_COLOR_THEME_INDEX:
+ if (pColor->GetThemeIndex() == -1)
+ {
+ eItemState = SfxItemState::DEFAULT;
+ }
break;
- case SfxItemState::DEFAULT:
- rState = beans::PropertyState_DEFAULT_VALUE;
+ case MID_COLOR_LUM_MOD:
+ if (pColor->GetLumMod() == 10000)
+ {
+ eItemState = SfxItemState::DEFAULT;
+ }
+ break;
+ case MID_COLOR_LUM_OFF:
+ if (pColor->GetLumOff() == 0)
+ {
+ eItemState = SfxItemState::DEFAULT;
+ }
break;
-// case SfxItemState::DONTCARE:
-// case SfxItemState::DISABLED:
- default:
- rState = beans::PropertyState_AMBIGUOUS_VALUE;
}
}
- else
+
+ switch( eItemState )
{
- rState = beans::PropertyState_AMBIGUOUS_VALUE;
+ case SfxItemState::SET:
+ rState = beans::PropertyState_DIRECT_VALUE;
+ break;
+ case SfxItemState::DEFAULT:
+ rState = beans::PropertyState_DEFAULT_VALUE;
+ break;
+// case SfxItemState::DONTCARE:
+// case SfxItemState::DISABLED:
+ default:
+ rState = beans::PropertyState_AMBIGUOUS_VALUE;
}
}
+ else
+ {
+ rState = beans::PropertyState_AMBIGUOUS_VALUE;
+ }
return true;
}
@@ -1396,41 +1395,42 @@ bool SvxUnoTextRangeBase::GoLeft(sal_Int32 nCount, bool Expand) noexcept
bool SvxUnoTextRangeBase::GoRight(sal_Int32 nCount, bool Expand) noexcept
{
- SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
- if( pForwarder )
- {
- CheckSelection( maSelection, pForwarder );
+ if (!mpEditSource)
+ return false;
+ SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
+ if( !pForwarder )
+ return false;
- sal_Int32 nNewPos = maSelection.nEndPos + nCount;
- sal_Int32 nNewPar = maSelection.nEndPara;
+ CheckSelection( maSelection, pForwarder );
- bool bOk = true;
- sal_Int32 nParCount = pForwarder->GetParagraphCount();
- sal_Int32 nThisLen = pForwarder->GetTextLen( nNewPar );
- while ( nNewPos > nThisLen && bOk )
- {
- if ( nNewPar + 1 >= nParCount )
- bOk = false;
- else
- {
- nNewPos -= nThisLen+1;
- ++nNewPar;
- nThisLen = pForwarder->GetTextLen( nNewPar );
- }
- }
+ sal_Int32 nNewPos = maSelection.nEndPos + nCount;
+ sal_Int32 nNewPar = maSelection.nEndPara;
- if (bOk)
+ bool bOk = true;
+ sal_Int32 nParCount = pForwarder->GetParagraphCount();
+ sal_Int32 nThisLen = pForwarder->GetTextLen( nNewPar );
+ while ( nNewPos > nThisLen && bOk )
+ {
+ if ( nNewPar + 1 >= nParCount )
+ bOk = false;
+ else
{
- maSelection.nEndPara = nNewPar;
- maSelection.nEndPos = nNewPos;
+ nNewPos -= nThisLen+1;
+ ++nNewPar;
+ nThisLen = pForwarder->GetTextLen( nNewPar );
}
+ }
- if (!Expand)
- CollapseToEnd();
-
- return bOk;
+ if (bOk)
+ {
+ maSelection.nEndPara = nNewPar;
+ maSelection.nEndPos = nNewPos;
}
- return false;
+
+ if (!Expand)
+ CollapseToEnd();
+
+ return bOk;
}
void SvxUnoTextRangeBase::GotoStart(bool Expand) noexcept