summaryrefslogtreecommitdiff
path: root/starmath/source/document.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-01-29 11:35:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-31 10:41:34 +0100
commit8a722c086deb751054d02f9f73e92d045cd73e1f (patch)
tree22f1bc523ab0019850a014ce94dbf69eb4ce075d /starmath/source/document.cxx
parent07ec9edc26f675646f04721acb3f1f0334a34530 (diff)
loplugin:flatten in starmath
Change-Id: Iaadd8af404e3eee5ebd49846a02a33735e9c18ba Reviewed-on: https://gerrit.libreoffice.org/67170 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath/source/document.cxx')
-rw-r--r--starmath/source/document.cxx143
1 files changed, 72 insertions, 71 deletions
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 1d2f41210154..99fc8174c24f 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -130,53 +130,53 @@ const OUString SmDocShell::GetComment() const
void SmDocShell::SetText(const OUString& rBuffer)
{
- if (rBuffer != maText)
- {
- bool bIsEnabled = IsEnableSetModified();
- if( bIsEnabled )
- EnableSetModified( false );
+ if (rBuffer == maText)
+ return;
- maText = rBuffer;
- SetFormulaArranged( false );
+ bool bIsEnabled = IsEnableSetModified();
+ if( bIsEnabled )
+ EnableSetModified( false );
- Parse();
+ maText = rBuffer;
+ SetFormulaArranged( false );
+
+ Parse();
- SmViewShell *pViewSh = SmGetActiveView();
- if( pViewSh )
+ SmViewShell *pViewSh = SmGetActiveView();
+ if( pViewSh )
+ {
+ pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_TEXT);
+ if ( SfxObjectCreateMode::EMBEDDED == GetCreateMode() )
{
- pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_TEXT);
- if ( SfxObjectCreateMode::EMBEDDED == GetCreateMode() )
- {
- // have SwOleClient::FormatChanged() to align the modified formula properly
- // even if the visible area does not change (e.g. when formula text changes from
- // "{a over b + c} over d" to "d over {a over b + c}"
- SfxGetpApp()->NotifyEvent(SfxEventHint( SfxEventHintId::VisAreaChanged, GlobalEventConfig::GetEventName(GlobalEventId::VISAREACHANGED), this));
+ // have SwOleClient::FormatChanged() to align the modified formula properly
+ // even if the visible area does not change (e.g. when formula text changes from
+ // "{a over b + c} over d" to "d over {a over b + c}"
+ SfxGetpApp()->NotifyEvent(SfxEventHint( SfxEventHintId::VisAreaChanged, GlobalEventConfig::GetEventName(GlobalEventId::VISAREACHANGED), this));
- Repaint();
- }
- else
- pViewSh->GetGraphicWindow().Invalidate();
+ Repaint();
}
+ else
+ pViewSh->GetGraphicWindow().Invalidate();
+ }
- if ( bIsEnabled )
- EnableSetModified( bIsEnabled );
- SetModified();
+ if ( bIsEnabled )
+ EnableSetModified( bIsEnabled );
+ SetModified();
- // launch accessible event if necessary
- SmGraphicAccessible *pAcc = pViewSh ? pViewSh->GetGraphicWindow().GetAccessible_Impl() : nullptr;
- if (pAcc)
+ // launch accessible event if necessary
+ SmGraphicAccessible *pAcc = pViewSh ? pViewSh->GetGraphicWindow().GetAccessible_Impl() : nullptr;
+ if (pAcc)
+ {
+ Any aOldValue, aNewValue;
+ if ( comphelper::OCommonAccessibleText::implInitTextChangedEvent( maText, rBuffer, aOldValue, aNewValue ) )
{
- Any aOldValue, aNewValue;
- if ( comphelper::OCommonAccessibleText::implInitTextChangedEvent( maText, rBuffer, aOldValue, aNewValue ) )
- {
- pAcc->LaunchEvent( AccessibleEventId::TEXT_CHANGED,
- aOldValue, aNewValue );
- }
+ pAcc->LaunchEvent( AccessibleEventId::TEXT_CHANGED,
+ aOldValue, aNewValue );
}
-
- if ( GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
- OnDocumentPrinterChanged(nullptr);
}
+
+ if ( GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
+ OnDocumentPrinterChanged(nullptr);
}
void SmDocShell::SetFormat(SmFormat const & rFormat)
@@ -495,30 +495,31 @@ SmPrinterAccess::SmPrinterAccess( SmDocShell &rDocShell )
}
}
}
- if ( (pRefDev = rDocShell.GetRefDev()) && pPrinter.get() != pRefDev.get() )
- {
- pRefDev->Push( PushFlags::MAPMODE );
- if ( SfxObjectCreateMode::EMBEDDED == rDocShell.GetCreateMode() )
- {
- // if it is an embedded object (without its own printer)
- // we change the MapMode temporarily.
- //!If it is a document with its own printer the MapMode should
- //!be set correct (once) elsewhere(!), in order to avoid numerous
- //!superfluous pushing and popping of the MapMode when using
- //!this class.
+ pRefDev = rDocShell.GetRefDev();
+ if ( !pRefDev || pPrinter.get() == pRefDev.get() )
+ return;
- const MapUnit eOld = pRefDev->GetMapMode().GetMapUnit();
- if ( MapUnit::Map100thMM != eOld )
- {
- MapMode aMap( pRefDev->GetMapMode() );
- aMap.SetMapUnit( MapUnit::Map100thMM );
- Point aTmp( aMap.GetOrigin() );
- aTmp.setX( OutputDevice::LogicToLogic( aTmp.X(), eOld, MapUnit::Map100thMM ) );
- aTmp.setY( OutputDevice::LogicToLogic( aTmp.Y(), eOld, MapUnit::Map100thMM ) );
- aMap.SetOrigin( aTmp );
- pRefDev->SetMapMode( aMap );
- }
- }
+ pRefDev->Push( PushFlags::MAPMODE );
+ if ( SfxObjectCreateMode::EMBEDDED != rDocShell.GetCreateMode() )
+ return;
+
+ // if it is an embedded object (without its own printer)
+ // we change the MapMode temporarily.
+ //!If it is a document with its own printer the MapMode should
+ //!be set correct (once) elsewhere(!), in order to avoid numerous
+ //!superfluous pushing and popping of the MapMode when using
+ //!this class.
+
+ const MapUnit eOld = pRefDev->GetMapMode().GetMapUnit();
+ if ( MapUnit::Map100thMM != eOld )
+ {
+ MapMode aMap( pRefDev->GetMapMode() );
+ aMap.SetMapUnit( MapUnit::Map100thMM );
+ Point aTmp( aMap.GetOrigin() );
+ aTmp.setX( OutputDevice::LogicToLogic( aTmp.X(), eOld, MapUnit::Map100thMM ) );
+ aTmp.setY( OutputDevice::LogicToLogic( aTmp.Y(), eOld, MapUnit::Map100thMM ) );
+ aMap.SetOrigin( aTmp );
+ pRefDev->SetMapMode( aMap );
}
}
@@ -773,22 +774,22 @@ void SmDocShell::ReplaceBadChars()
{
bool bReplace = false;
- if (mpEditEngine)
- {
- OUStringBuffer aBuf( mpEditEngine->GetText() );
+ if (!mpEditEngine)
+ return;
+
+ OUStringBuffer aBuf( mpEditEngine->GetText() );
- for (sal_Int32 i = 0; i < aBuf.getLength(); ++i)
+ for (sal_Int32 i = 0; i < aBuf.getLength(); ++i)
+ {
+ if (aBuf[i] < ' ' && aBuf[i] != '\r' && aBuf[i] != '\n' && aBuf[i] != '\t')
{
- if (aBuf[i] < ' ' && aBuf[i] != '\r' && aBuf[i] != '\n' && aBuf[i] != '\t')
- {
- aBuf[i] = ' ';
- bReplace = true;
- }
+ aBuf[i] = ' ';
+ bReplace = true;
}
-
- if (bReplace)
- maText = aBuf.makeStringAndClear();
}
+
+ if (bReplace)
+ maText = aBuf.makeStringAndClear();
}