summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 15:21:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 17:13:30 +0100
commitf19599c929ac6ae2708b19b9eff62ff70b44ee75 (patch)
tree6ed489ee28db5b89c6f26ddc068197bf0fd94b6d
parente519d7465f38367205b37bc80f0244029e352306 (diff)
loplugin:flatten in editeng..extensions
Change-Id: Ica8f0a6e3d30dba3b5a083e3c04522073de8303f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127233 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-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
-rw-r--r--embeddedobj/source/general/docholder.cxx130
-rw-r--r--emfio/source/reader/mtftools.cxx102
-rw-r--r--extensions/source/bibliography/general.cxx32
-rw-r--r--extensions/source/scanner/grid.cxx46
-rw-r--r--extensions/source/scanner/sanedlg.cxx76
12 files changed, 546 insertions, 556 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
diff --git a/embeddedobj/source/general/docholder.cxx b/embeddedobj/source/general/docholder.cxx
index 13e40cf92516..78f73b88a5a6 100644
--- a/embeddedobj/source/general/docholder.cxx
+++ b/embeddedobj/source/general/docholder.cxx
@@ -464,30 +464,28 @@ bool DocumentHolder::ShowInplace( const uno::Reference< awt::XWindowPeer >& xPar
// TODO: some listeners to the frame and the window ( resize for example )
}
- if ( m_xComponent.is() )
- {
- if ( !LoadDocToFrame( true ) )
- {
- CloseFrame();
- return false;
- }
+ if ( !m_xComponent )
+ return false;
- uno::Reference< frame::XControllerBorder > xControllerBorder( m_xFrame->getController(), uno::UNO_QUERY );
- if ( xControllerBorder.is() )
- {
- m_aBorderWidths = xControllerBorder->getBorder();
- xControllerBorder->addBorderResizeListener( static_cast<frame::XBorderResizeListener*>(this) );
- }
+ if ( !LoadDocToFrame( true ) )
+ {
+ CloseFrame();
+ return false;
+ }
- PlaceFrame( aRectangleToShow );
+ uno::Reference< frame::XControllerBorder > xControllerBorder( m_xFrame->getController(), uno::UNO_QUERY );
+ if ( xControllerBorder.is() )
+ {
+ m_aBorderWidths = xControllerBorder->getBorder();
+ xControllerBorder->addBorderResizeListener( static_cast<frame::XBorderResizeListener*>(this) );
+ }
- if ( m_xHatchWindow.is() )
- m_xHatchWindow->setVisible( true );
+ PlaceFrame( aRectangleToShow );
- return true;
- }
+ if ( m_xHatchWindow.is() )
+ m_xHatchWindow->setVisible( true );
- return false;
+ return true;
}
@@ -934,60 +932,60 @@ void DocumentHolder::SetComponent( const uno::Reference< util::XCloseable >& xDo
bool DocumentHolder::LoadDocToFrame( bool bInPlace )
{
- if ( m_xFrame.is() && m_xComponent.is() )
+ if ( !m_xFrame || !m_xComponent )
+ return true;
+
+ uno::Reference < frame::XModel > xDoc( m_xComponent, uno::UNO_QUERY );
+ if ( xDoc.is() )
{
- uno::Reference < frame::XModel > xDoc( m_xComponent, uno::UNO_QUERY );
- if ( xDoc.is() )
- {
- // load new document into the frame
- uno::Reference< frame::XComponentLoader > xComponentLoader( m_xFrame, uno::UNO_QUERY_THROW );
+ // load new document into the frame
+ uno::Reference< frame::XComponentLoader > xComponentLoader( m_xFrame, uno::UNO_QUERY_THROW );
- ::comphelper::NamedValueCollection aArgs;
- aArgs.put( "Model", m_xComponent );
- aArgs.put( "ReadOnly", m_bReadOnly );
+ ::comphelper::NamedValueCollection aArgs;
+ aArgs.put( "Model", m_xComponent );
+ aArgs.put( "ReadOnly", m_bReadOnly );
- // set document title to show in the title bar
- css::uno::Reference< css::frame::XTitle > xModelTitle( xDoc, css::uno::UNO_QUERY );
- if( xModelTitle.is() && m_pEmbedObj && !m_pEmbedObj->getContainerName().isEmpty() )
- {
- std::locale aResLoc = Translate::Create("sfx");
- OUString sEmbedded = Translate::get(STR_EMBEDDED_TITLE, aResLoc);
- xModelTitle->setTitle( m_pEmbedObj->getContainerName() + sEmbedded );
- m_aContainerName = m_pEmbedObj->getContainerName();
- // TODO: get real m_aDocumentNamePart
- m_aDocumentNamePart = sEmbedded;
- }
+ // set document title to show in the title bar
+ css::uno::Reference< css::frame::XTitle > xModelTitle( xDoc, css::uno::UNO_QUERY );
+ if( xModelTitle.is() && m_pEmbedObj && !m_pEmbedObj->getContainerName().isEmpty() )
+ {
+ std::locale aResLoc = Translate::Create("sfx");
+ OUString sEmbedded = Translate::get(STR_EMBEDDED_TITLE, aResLoc);
+ xModelTitle->setTitle( m_pEmbedObj->getContainerName() + sEmbedded );
+ m_aContainerName = m_pEmbedObj->getContainerName();
+ // TODO: get real m_aDocumentNamePart
+ m_aDocumentNamePart = sEmbedded;
+ }
- if ( bInPlace )
- aArgs.put( "PluginMode", sal_Int16(1) );
- OUString sUrl;
- uno::Reference< lang::XServiceInfo> xServiceInfo(xDoc,uno::UNO_QUERY);
- if ( xServiceInfo.is()
- && xServiceInfo->supportsService("com.sun.star.report.ReportDefinition") )
- {
- sUrl = ".component:DB/ReportDesign";
- }
- else if( xServiceInfo.is()
- && xServiceInfo->supportsService("com.sun.star.chart2.ChartDocument"))
- sUrl = "private:factory/schart";
- else
- sUrl = "private:object";
+ if ( bInPlace )
+ aArgs.put( "PluginMode", sal_Int16(1) );
+ OUString sUrl;
+ uno::Reference< lang::XServiceInfo> xServiceInfo(xDoc,uno::UNO_QUERY);
+ if ( xServiceInfo.is()
+ && xServiceInfo->supportsService("com.sun.star.report.ReportDefinition") )
+ {
+ sUrl = ".component:DB/ReportDesign";
+ }
+ else if( xServiceInfo.is()
+ && xServiceInfo->supportsService("com.sun.star.chart2.ChartDocument"))
+ sUrl = "private:factory/schart";
+ else
+ sUrl = "private:object";
- xComponentLoader->loadComponentFromURL( sUrl,
- "_self",
- 0,
- aArgs.getPropertyValues() );
+ xComponentLoader->loadComponentFromURL( sUrl,
+ "_self",
+ 0,
+ aArgs.getPropertyValues() );
- return true;
- }
+ return true;
+ }
+ else
+ {
+ uno::Reference < frame::XSynchronousFrameLoader > xLoader( m_xComponent, uno::UNO_QUERY );
+ if ( xLoader.is() )
+ return xLoader->load( uno::Sequence < beans::PropertyValue >(), m_xFrame );
else
- {
- uno::Reference < frame::XSynchronousFrameLoader > xLoader( m_xComponent, uno::UNO_QUERY );
- if ( xLoader.is() )
- return xLoader->load( uno::Sequence < beans::PropertyValue >(), m_xFrame );
- else
- return false;
- }
+ return false;
}
return true;
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 8e38e4e5b286..e12c98c66372 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -388,61 +388,61 @@ namespace emfio
nMeasuredTextLength = nImportedTextLength;
// compare expected and imported TextLengths
- if (nImportedTextLength != nMeasuredTextLength)
- {
- const double fFactorText(static_cast<double>(nImportedTextLength) / static_cast<double>(nMeasuredTextLength));
- const double fFactorTextPercent(fabs(1.0 - fFactorText) * 100.0);
+ if (nImportedTextLength == nMeasuredTextLength)
+ return;
- // if we assume that loaded file was written on old linux, we have to
- // back-convert the scale value depending on which system we run
+ const double fFactorText(static_cast<double>(nImportedTextLength) / static_cast<double>(nMeasuredTextLength));
+ const double fFactorTextPercent(fabs(1.0 - fFactorText) * 100.0);
+
+ // if we assume that loaded file was written on old linux, we have to
+ // back-convert the scale value depending on which system we run
#ifdef _WIN32
- // When running on Windows the value was not adapted at font import (see WinMtfFontStyle
- // constructor), so it is still NormedFontScaling and we need to convert to Windows-style
- // scaling
+ // When running on Windows the value was not adapted at font import (see WinMtfFontStyle
+ // constructor), so it is still NormedFontScaling and we need to convert to Windows-style
+ // scaling
#else
- // When running on unx (non-Windows) the value was already adapted at font import (see WinMtfFontStyle
- // constructor). It was wrongly assumed to be Windows-style FontScaling, so we need to revert that
- // to get back to the needed unx-style FontScale
+ // When running on unx (non-Windows) the value was already adapted at font import (see WinMtfFontStyle
+ // constructor). It was wrongly assumed to be Windows-style FontScaling, so we need to revert that
+ // to get back to the needed unx-style FontScale
#endif
- // Interestingly this leads to the *same* correction, so no need to make this
- // system-dependent (!)
- const tools::Long nUnscaledAverageFontWidth(rFontCandidate.GetOrCalculateAverageFontWidth());
- const tools::Long nScaledAverageFontWidth(rFontCandidate.GetAverageFontWidth());
- const double fScaleFactor(static_cast<double>(nUnscaledAverageFontWidth) / static_cast<double>(rFontCandidate.GetFontHeight()));
- const double fCorrectedAverageFontWidth(static_cast<double>(nScaledAverageFontWidth) * fScaleFactor);
- tools::Long nCorrectedTextLength(0);
-
- { // do in own scope, only need nUnscaledAverageFontWidth
- vcl::Font rFontCandidate2(rFontCandidate);
- rFontCandidate2.SetAverageFontWidth(static_cast<tools::Long>(fCorrectedAverageFontWidth));
- pTempVirtualDevice->SetFont(rFontCandidate2);
- nCorrectedTextLength = pTempVirtualDevice->GetTextWidth(rText);
- // on failure, use original length
- if (!nCorrectedTextLength)
- nCorrectedTextLength = nImportedTextLength;
- }
-
- const double fFactorCorrectedText(static_cast<double>(nImportedTextLength) / static_cast<double>(nCorrectedTextLength));
- const double fFactorCorrectedTextPercent(fabs(1.0 - fFactorCorrectedText) * 100.0);
-
- // If FactorCorrectedText fits better than FactorText this is probably
- // an import of an old EMF/WMF written by LibreOffice on a non-Windows (unx) system
- // and should be corrected.
- // Usually in tested cases this lies inside 5% of range, so detecting this just using
- // fFactorTextPercent inside 5% -> no old file
- // fFactorCorrectedTextPercent inside 5% -> is old file
- // works not too bad, but there are some strange not so often used fonts where that
- // values do deviate, so better just compare if old corrected would fit better than
- // the uncorrected case, that is usually safe.
- if(fFactorCorrectedTextPercent < fFactorTextPercent)
- {
- maAlternativeFontScales.push_back(fCorrectedAverageFontWidth);
- }
- else
- {
- // also push, but negative to remember non-fitting case
- maAlternativeFontScales.push_back(-fCorrectedAverageFontWidth);
- }
+ // Interestingly this leads to the *same* correction, so no need to make this
+ // system-dependent (!)
+ const tools::Long nUnscaledAverageFontWidth(rFontCandidate.GetOrCalculateAverageFontWidth());
+ const tools::Long nScaledAverageFontWidth(rFontCandidate.GetAverageFontWidth());
+ const double fScaleFactor(static_cast<double>(nUnscaledAverageFontWidth) / static_cast<double>(rFontCandidate.GetFontHeight()));
+ const double fCorrectedAverageFontWidth(static_cast<double>(nScaledAverageFontWidth) * fScaleFactor);
+ tools::Long nCorrectedTextLength(0);
+
+ { // do in own scope, only need nUnscaledAverageFontWidth
+ vcl::Font rFontCandidate2(rFontCandidate);
+ rFontCandidate2.SetAverageFontWidth(static_cast<tools::Long>(fCorrectedAverageFontWidth));
+ pTempVirtualDevice->SetFont(rFontCandidate2);
+ nCorrectedTextLength = pTempVirtualDevice->GetTextWidth(rText);
+ // on failure, use original length
+ if (!nCorrectedTextLength)
+ nCorrectedTextLength = nImportedTextLength;
+ }
+
+ const double fFactorCorrectedText(static_cast<double>(nImportedTextLength) / static_cast<double>(nCorrectedTextLength));
+ const double fFactorCorrectedTextPercent(fabs(1.0 - fFactorCorrectedText) * 100.0);
+
+ // If FactorCorrectedText fits better than FactorText this is probably
+ // an import of an old EMF/WMF written by LibreOffice on a non-Windows (unx) system
+ // and should be corrected.
+ // Usually in tested cases this lies inside 5% of range, so detecting this just using
+ // fFactorTextPercent inside 5% -> no old file
+ // fFactorCorrectedTextPercent inside 5% -> is old file
+ // works not too bad, but there are some strange not so often used fonts where that
+ // values do deviate, so better just compare if old corrected would fit better than
+ // the uncorrected case, that is usually safe.
+ if(fFactorCorrectedTextPercent < fFactorTextPercent)
+ {
+ maAlternativeFontScales.push_back(fCorrectedAverageFontWidth);
+ }
+ else
+ {
+ // also push, but negative to remember non-fitting case
+ maAlternativeFontScales.push_back(-fCorrectedAverageFontWidth);
}
}
diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx
index 4307d9f206d2..b5447af165ec 100644
--- a/extensions/source/bibliography/general.cxx
+++ b/extensions/source/bibliography/general.cxx
@@ -454,27 +454,25 @@ IMPL_LINK(BibGeneralPage, LastElementKeyInputHdl, const KeyEvent&, rKeyEvent, bo
bool bShift = rKeyEvent.GetKeyCode().IsShift();
bool bCtrl = rKeyEvent.GetKeyCode().IsMod1();
bool bAlt = rKeyEvent.GetKeyCode().IsMod2();
- if (KEY_TAB == nCode && !bShift && !bCtrl && !bAlt)
+ if (KEY_TAB != nCode || bShift || bCtrl || bAlt)
+ return false;
+ SaveChanges();
+ uno::Reference<sdbc::XRowSet> xRowSet(pDatMan->getForm(), UNO_QUERY);
+ if (xRowSet.is())
{
- SaveChanges();
- uno::Reference<sdbc::XRowSet> xRowSet(pDatMan->getForm(), UNO_QUERY);
- if (xRowSet.is())
+ if (xRowSet->isLast())
{
- if (xRowSet->isLast())
- {
- uno::Reference<sdbc::XResultSetUpdate> xUpdateCursor(xRowSet, UNO_QUERY);
- if (xUpdateCursor.is())
- xUpdateCursor->moveToInsertRow();
- }
- else
- (void)xRowSet->next();
+ uno::Reference<sdbc::XResultSetUpdate> xUpdateCursor(xRowSet, UNO_QUERY);
+ if (xUpdateCursor.is())
+ xUpdateCursor->moveToInsertRow();
}
- xIdentifierED->grab_focus();
- xIdentifierED->select_region(0, -1);
- GainFocusHdl(*xIdentifierED);
- return true;
+ else
+ (void)xRowSet->next();
}
- return false;
+ xIdentifierED->grab_focus();
+ xIdentifierED->select_region(0, -1);
+ GainFocusHdl(*xIdentifierED);
+ return true;
}
BibGeneralPage::~BibGeneralPage()
diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx
index 85f22fb017e7..110779c55080 100644
--- a/extensions/source/scanner/grid.cxx
+++ b/extensions/source/scanner/grid.cxx
@@ -523,32 +523,32 @@ void GridWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangl
bool GridWindow::MouseMove( const MouseEvent& rEvt )
{
- if( rEvt.GetButtons() == MOUSE_LEFT && m_nDragIndex != npos )
- {
- Point aPoint( rEvt.GetPosPixel() );
+ if( rEvt.GetButtons() != MOUSE_LEFT || m_nDragIndex == npos )
+ return false;
- if( m_nDragIndex == 0 || m_nDragIndex == m_aHandles.size() - 1)
- {
- aPoint.setX( m_aHandles[m_nDragIndex].maPos.X() );
- }
- else
- {
- if(aPoint.X() < m_aGridArea.Left())
- aPoint.setX( m_aGridArea.Left() );
- else if(aPoint.X() > m_aGridArea.Right())
- aPoint.setX( m_aGridArea.Right() );
- }
+ Point aPoint( rEvt.GetPosPixel() );
+
+ if( m_nDragIndex == 0 || m_nDragIndex == m_aHandles.size() - 1)
+ {
+ aPoint.setX( m_aHandles[m_nDragIndex].maPos.X() );
+ }
+ else
+ {
+ if(aPoint.X() < m_aGridArea.Left())
+ aPoint.setX( m_aGridArea.Left() );
+ else if(aPoint.X() > m_aGridArea.Right())
+ aPoint.setX( m_aGridArea.Right() );
+ }
- if( aPoint.Y() < m_aGridArea.Top() )
- aPoint.setY( m_aGridArea.Top() );
- else if( aPoint.Y() > m_aGridArea.Bottom() )
- aPoint.setY( m_aGridArea.Bottom() );
+ if( aPoint.Y() < m_aGridArea.Top() )
+ aPoint.setY( m_aGridArea.Top() );
+ else if( aPoint.Y() > m_aGridArea.Bottom() )
+ aPoint.setY( m_aGridArea.Bottom() );
- if( aPoint != m_aHandles[m_nDragIndex].maPos )
- {
- m_aHandles[m_nDragIndex].maPos = aPoint;
- Invalidate( m_aGridArea );
- }
+ if( aPoint != m_aHandles[m_nDragIndex].maPos )
+ {
+ m_aHandles[m_nDragIndex].maPos = aPoint;
+ Invalidate( m_aGridArea );
}
return false;
diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx
index e76575cd9bc9..8486195c93e6 100644
--- a/extensions/source/scanner/sanedlg.cxx
+++ b/extensions/source/scanner/sanedlg.cxx
@@ -1052,46 +1052,46 @@ void SaneDlg::EstablishButtonOption()
bool ScanPreview::MouseMove(const MouseEvent& rMEvt)
{
- if( mbIsDragging )
+ if( !mbIsDragging )
+ return false;
+
+ Point aMousePos = rMEvt.GetPosPixel();
+ // move into valid area
+ Point aLogicPos = GetLogicPos( aMousePos );
+ aMousePos = GetPixelPos( aLogicPos );
+ switch( meDragDirection )
{
- Point aMousePos = rMEvt.GetPosPixel();
- // move into valid area
- Point aLogicPos = GetLogicPos( aMousePos );
- aMousePos = GetPixelPos( aLogicPos );
- switch( meDragDirection )
- {
- case TopLeft: maTopLeft = aMousePos; break;
- case Top: maTopLeft.setY( aMousePos.Y() ); break;
- case TopRight:
- maTopLeft.setY( aMousePos.Y() );
- maBottomRight.setX( aMousePos.X() );
- break;
- case Right: maBottomRight.setX( aMousePos.X() ); break;
- case BottomRight: maBottomRight = aMousePos; break;
- case Bottom: maBottomRight.setY( aMousePos.Y() ); break;
- case BottomLeft:
- maTopLeft.setX( aMousePos.X() );
- maBottomRight.setY( aMousePos.Y() );
- break;
- case Left: maTopLeft.setX( aMousePos.X() ); break;
- default: break;
- }
- int nSwap;
- if( maTopLeft.X() > maBottomRight.X() )
- {
- nSwap = maTopLeft.X();
- maTopLeft.setX( maBottomRight.X() );
- maBottomRight.setX( nSwap );
- }
- if( maTopLeft.Y() > maBottomRight.Y() )
- {
- nSwap = maTopLeft.Y();
- maTopLeft.setY( maBottomRight.Y() );
- maBottomRight.setY( nSwap );
- }
- Invalidate();
- mpParentDialog->UpdateScanArea(false);
+ case TopLeft: maTopLeft = aMousePos; break;
+ case Top: maTopLeft.setY( aMousePos.Y() ); break;
+ case TopRight:
+ maTopLeft.setY( aMousePos.Y() );
+ maBottomRight.setX( aMousePos.X() );
+ break;
+ case Right: maBottomRight.setX( aMousePos.X() ); break;
+ case BottomRight: maBottomRight = aMousePos; break;
+ case Bottom: maBottomRight.setY( aMousePos.Y() ); break;
+ case BottomLeft:
+ maTopLeft.setX( aMousePos.X() );
+ maBottomRight.setY( aMousePos.Y() );
+ break;
+ case Left: maTopLeft.setX( aMousePos.X() ); break;
+ default: break;
+ }
+ int nSwap;
+ if( maTopLeft.X() > maBottomRight.X() )
+ {
+ nSwap = maTopLeft.X();
+ maTopLeft.setX( maBottomRight.X() );
+ maBottomRight.setX( nSwap );
+ }
+ if( maTopLeft.Y() > maBottomRight.Y() )
+ {
+ nSwap = maTopLeft.Y();
+ maTopLeft.setY( maBottomRight.Y() );
+ maBottomRight.setY( nSwap );
}
+ Invalidate();
+ mpParentDialog->UpdateScanArea(false);
return false;
}