summaryrefslogtreecommitdiff
path: root/starmath
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
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')
-rw-r--r--starmath/source/ElementsDockingWindow.cxx30
-rw-r--r--starmath/source/accessibility.cxx24
-rw-r--r--starmath/source/cfgitem.cxx350
-rw-r--r--starmath/source/dialog.cxx38
-rw-r--r--starmath/source/document.cxx143
-rw-r--r--starmath/source/edit.cxx278
-rw-r--r--starmath/source/mathmlexport.cxx99
-rw-r--r--starmath/source/mathmlimport.cxx203
-rw-r--r--starmath/source/mathtype.cxx32
-rw-r--r--starmath/source/node.cxx44
-rw-r--r--starmath/source/symbol.cxx34
-rw-r--r--starmath/source/unomodel.cxx124
-rw-r--r--starmath/source/view.cxx123
-rw-r--r--starmath/source/visitors.cxx49
14 files changed, 787 insertions, 784 deletions
diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx
index 93735cff80e9..a6e7ada2d02a 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -378,22 +378,22 @@ void SmElementsControl::LayoutOrPaintContents(vcl::RenderContext *pContext)
}
}
- if (!pContext)
- {
- sal_Int32 nTotalControlHeight = y + boxY + mxScroll->GetThumbPos();
+ if (pContext)
+ return;
- if (nTotalControlHeight > GetOutputSizePixel().Height())
- {
- mxScroll->SetRangeMax(nTotalControlHeight);
- mxScroll->SetPosSizePixel(Point(nControlWidth, 0), Size(nScrollbarWidth, nControlHeight));
- mxScroll->SetVisibleSize(nControlHeight);
- mxScroll->Show();
- }
- else
- {
- mxScroll->SetThumbPos(0);
- mxScroll->Hide();
- }
+ sal_Int32 nTotalControlHeight = y + boxY + mxScroll->GetThumbPos();
+
+ if (nTotalControlHeight > GetOutputSizePixel().Height())
+ {
+ mxScroll->SetRangeMax(nTotalControlHeight);
+ mxScroll->SetPosSizePixel(Point(nControlWidth, 0), Size(nScrollbarWidth, nControlHeight));
+ mxScroll->SetVisibleSize(nControlHeight);
+ mxScroll->Show();
+ }
+ else
+ {
+ mxScroll->SetThumbPos(0);
+ mxScroll->Hide();
}
}
diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index 0440bd216f19..71a8fd0ae887 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -391,19 +391,19 @@ void SAL_CALL SmGraphicAccessible::addAccessibleEventListener(
void SAL_CALL SmGraphicAccessible::removeAccessibleEventListener(
const Reference< XAccessibleEventListener >& xListener )
{
- if (xListener.is() && nClientId)
+ if (!(xListener.is() && nClientId))
+ return;
+
+ SolarMutexGuard aGuard;
+ sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( nClientId, xListener );
+ if ( !nListenerCount )
{
- SolarMutexGuard aGuard;
- sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( nClientId, xListener );
- if ( !nListenerCount )
- {
- // no listeners anymore
- // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
- // and at least to us not firing any events anymore, in case somebody calls
- // NotifyAccessibleEvent, again
- comphelper::AccessibleEventNotifier::revokeClient( nClientId );
- nClientId = 0;
- }
+ // no listeners anymore
+ // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+ // and at least to us not firing any events anymore, in case somebody calls
+ // NotifyAccessibleEvent, again
+ comphelper::AccessibleEventNotifier::revokeClient( nClientId );
+ nClientId = 0;
}
}
diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx
index b53beef83bd0..48760e0f046e 100644
--- a/starmath/source/cfgitem.cxx
+++ b/starmath/source/cfgitem.cxx
@@ -385,70 +385,70 @@ void SmMathConfig::ReadSymbol( SmSym &rSymbol,
const Sequence< Any > aValues = const_cast<SmMathConfig*>(this)->GetProperties(aNames);
- if (nProps && aValues.getLength() == nProps)
- {
- const Any * pValue = aValues.getConstArray();
- vcl::Font aFont;
- sal_UCS4 cChar = '\0';
- OUString aSet;
- bool bPredefined = false;
-
- OUString aTmpStr;
- sal_Int32 nTmp32 = 0;
- bool bTmp = false;
-
- bool bOK = true;
- if (pValue->hasValue() && (*pValue >>= nTmp32))
- cChar = static_cast< sal_UCS4 >( nTmp32 );
- else
- bOK = false;
- ++pValue;
- if (pValue->hasValue() && (*pValue >>= aTmpStr))
- aSet = aTmpStr;
- else
- bOK = false;
- ++pValue;
- if (pValue->hasValue() && (*pValue >>= bTmp))
- bPredefined = bTmp;
- else
- bOK = false;
- ++pValue;
- if (pValue->hasValue() && (*pValue >>= aTmpStr))
- {
- const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr );
- OSL_ENSURE( pFntFmt, "unknown FontFormat" );
- if (pFntFmt)
- aFont = pFntFmt->GetFont();
- }
- else
- bOK = false;
- ++pValue;
+ if (!(nProps && aValues.getLength() == nProps))
+ return;
- if (bOK)
- {
- OUString aUiName( rSymbolName );
- OUString aUiSetName( aSet );
- if (bPredefined)
- {
- OUString aTmp;
- aTmp = SmLocalizedSymbolData::GetUiSymbolName( rSymbolName );
- OSL_ENSURE( !aTmp.isEmpty(), "localized symbol-name not found" );
- if (!aTmp.isEmpty())
- aUiName = aTmp;
- aTmp = SmLocalizedSymbolData::GetUiSymbolSetName( aSet );
- OSL_ENSURE( !aTmp.isEmpty(), "localized symbolset-name not found" );
- if (!aTmp.isEmpty())
- aUiSetName = aTmp;
- }
+ const Any * pValue = aValues.getConstArray();
+ vcl::Font aFont;
+ sal_UCS4 cChar = '\0';
+ OUString aSet;
+ bool bPredefined = false;
- rSymbol = SmSym( aUiName, aFont, cChar, aUiSetName, bPredefined );
- if (aUiName != rSymbolName)
- rSymbol.SetExportName( rSymbolName );
- }
- else
+ OUString aTmpStr;
+ sal_Int32 nTmp32 = 0;
+ bool bTmp = false;
+
+ bool bOK = true;
+ if (pValue->hasValue() && (*pValue >>= nTmp32))
+ cChar = static_cast< sal_UCS4 >( nTmp32 );
+ else
+ bOK = false;
+ ++pValue;
+ if (pValue->hasValue() && (*pValue >>= aTmpStr))
+ aSet = aTmpStr;
+ else
+ bOK = false;
+ ++pValue;
+ if (pValue->hasValue() && (*pValue >>= bTmp))
+ bPredefined = bTmp;
+ else
+ bOK = false;
+ ++pValue;
+ if (pValue->hasValue() && (*pValue >>= aTmpStr))
+ {
+ const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr );
+ OSL_ENSURE( pFntFmt, "unknown FontFormat" );
+ if (pFntFmt)
+ aFont = pFntFmt->GetFont();
+ }
+ else
+ bOK = false;
+ ++pValue;
+
+ if (bOK)
+ {
+ OUString aUiName( rSymbolName );
+ OUString aUiSetName( aSet );
+ if (bPredefined)
{
- SAL_WARN("starmath", "symbol read error");
+ OUString aTmp;
+ aTmp = SmLocalizedSymbolData::GetUiSymbolName( rSymbolName );
+ OSL_ENSURE( !aTmp.isEmpty(), "localized symbol-name not found" );
+ if (!aTmp.isEmpty())
+ aUiName = aTmp;
+ aTmp = SmLocalizedSymbolData::GetUiSymbolSetName( aSet );
+ OSL_ENSURE( !aTmp.isEmpty(), "localized symbolset-name not found" );
+ if (!aTmp.isEmpty())
+ aUiSetName = aTmp;
}
+
+ rSymbol = SmSym( aUiName, aFont, cChar, aUiSetName, bPredefined );
+ if (aUiName != rSymbolName)
+ rSymbol.SetExportName( rSymbolName );
+ }
+ else
+ {
+ SAL_WARN("starmath", "symbol read error");
}
}
@@ -602,47 +602,47 @@ void SmMathConfig::ReadFontFormat( SmFontFormat &rFontFormat,
const Sequence< Any > aValues = const_cast<SmMathConfig*>(this)->GetProperties(aNames);
- if (nProps && aValues.getLength() == nProps)
- {
- const Any * pValue = aValues.getConstArray();
-
- OUString aTmpStr;
- sal_Int16 nTmp16 = 0;
-
- bool bOK = true;
- if (pValue->hasValue() && (*pValue >>= aTmpStr))
- rFontFormat.aName = aTmpStr;
- else
- bOK = false;
- ++pValue;
- if (pValue->hasValue() && (*pValue >>= nTmp16))
- rFontFormat.nCharSet = nTmp16; // 6.0 file-format GetSOLoadTextEncoding not needed
- else
- bOK = false;
- ++pValue;
- if (pValue->hasValue() && (*pValue >>= nTmp16))
- rFontFormat.nFamily = nTmp16;
- else
- bOK = false;
- ++pValue;
- if (pValue->hasValue() && (*pValue >>= nTmp16))
- rFontFormat.nPitch = nTmp16;
- else
- bOK = false;
- ++pValue;
- if (pValue->hasValue() && (*pValue >>= nTmp16))
- rFontFormat.nWeight = nTmp16;
- else
- bOK = false;
- ++pValue;
- if (pValue->hasValue() && (*pValue >>= nTmp16))
- rFontFormat.nItalic = nTmp16;
- else
- bOK = false;
- ++pValue;
-
- OSL_ENSURE( bOK, "read FontFormat failed" );
- }
+ if (!(nProps && aValues.getLength() == nProps))
+ return;
+
+ const Any * pValue = aValues.getConstArray();
+
+ OUString aTmpStr;
+ sal_Int16 nTmp16 = 0;
+
+ bool bOK = true;
+ if (pValue->hasValue() && (*pValue >>= aTmpStr))
+ rFontFormat.aName = aTmpStr;
+ else
+ bOK = false;
+ ++pValue;
+ if (pValue->hasValue() && (*pValue >>= nTmp16))
+ rFontFormat.nCharSet = nTmp16; // 6.0 file-format GetSOLoadTextEncoding not needed
+ else
+ bOK = false;
+ ++pValue;
+ if (pValue->hasValue() && (*pValue >>= nTmp16))
+ rFontFormat.nFamily = nTmp16;
+ else
+ bOK = false;
+ ++pValue;
+ if (pValue->hasValue() && (*pValue >>= nTmp16))
+ rFontFormat.nPitch = nTmp16;
+ else
+ bOK = false;
+ ++pValue;
+ if (pValue->hasValue() && (*pValue >>= nTmp16))
+ rFontFormat.nWeight = nTmp16;
+ else
+ bOK = false;
+ ++pValue;
+ if (pValue->hasValue() && (*pValue >>= nTmp16))
+ rFontFormat.nItalic = nTmp16;
+ else
+ bOK = false;
+ ++pValue;
+
+ OSL_ENSURE( bOK, "read FontFormat failed" );
}
@@ -874,81 +874,81 @@ void SmMathConfig::LoadFormat()
sal_Int32 nProps = aNames.getLength();
Sequence< Any > aValues( GetProperties( aNames ) );
- if (nProps && aValues.getLength() == nProps)
- {
- const Any *pValues = aValues.getConstArray();
- const Any *pVal = pValues;
+ if (!(nProps && aValues.getLength() == nProps))
+ return;
- OUString aTmpStr;
- sal_Int16 nTmp16 = 0;
- bool bTmp = false;
+ const Any *pValues = aValues.getConstArray();
+ const Any *pVal = pValues;
- // StandardFormat/Textmode
- if (pVal->hasValue() && (*pVal >>= bTmp))
- pFormat->SetTextmode( bTmp );
- ++pVal;
- // StandardFormat/GreekCharStyle
- if (pVal->hasValue() && (*pVal >>= nTmp16))
- pFormat->SetGreekCharStyle( nTmp16 );
- ++pVal;
- // StandardFormat/ScaleNormalBracket
- if (pVal->hasValue() && (*pVal >>= bTmp))
- pFormat->SetScaleNormalBrackets( bTmp );
- ++pVal;
- // StandardFormat/HorizontalAlignment
+ OUString aTmpStr;
+ sal_Int16 nTmp16 = 0;
+ bool bTmp = false;
+
+ // StandardFormat/Textmode
+ if (pVal->hasValue() && (*pVal >>= bTmp))
+ pFormat->SetTextmode( bTmp );
+ ++pVal;
+ // StandardFormat/GreekCharStyle
+ if (pVal->hasValue() && (*pVal >>= nTmp16))
+ pFormat->SetGreekCharStyle( nTmp16 );
+ ++pVal;
+ // StandardFormat/ScaleNormalBracket
+ if (pVal->hasValue() && (*pVal >>= bTmp))
+ pFormat->SetScaleNormalBrackets( bTmp );
+ ++pVal;
+ // StandardFormat/HorizontalAlignment
+ if (pVal->hasValue() && (*pVal >>= nTmp16))
+ pFormat->SetHorAlign( static_cast<SmHorAlign>(nTmp16) );
+ ++pVal;
+ // StandardFormat/BaseSize
+ if (pVal->hasValue() && (*pVal >>= nTmp16))
+ pFormat->SetBaseSize( Size(0, SmPtsTo100th_mm( nTmp16 )) );
+ ++pVal;
+
+ sal_uInt16 i;
+ for (i = SIZ_BEGIN; i <= SIZ_END; ++i)
+ {
if (pVal->hasValue() && (*pVal >>= nTmp16))
- pFormat->SetHorAlign( static_cast<SmHorAlign>(nTmp16) );
+ pFormat->SetRelSize( i, nTmp16 );
++pVal;
- // StandardFormat/BaseSize
+ }
+
+ for (i = DIS_BEGIN; i <= DIS_END; ++i)
+ {
if (pVal->hasValue() && (*pVal >>= nTmp16))
- pFormat->SetBaseSize( Size(0, SmPtsTo100th_mm( nTmp16 )) );
+ pFormat->SetDistance( i, nTmp16 );
++pVal;
+ }
- sal_uInt16 i;
- for (i = SIZ_BEGIN; i <= SIZ_END; ++i)
- {
- if (pVal->hasValue() && (*pVal >>= nTmp16))
- pFormat->SetRelSize( i, nTmp16 );
- ++pVal;
- }
-
- for (i = DIS_BEGIN; i <= DIS_END; ++i)
- {
- if (pVal->hasValue() && (*pVal >>= nTmp16))
- pFormat->SetDistance( i, nTmp16 );
- ++pVal;
- }
-
- LanguageType nLang = Application::GetSettings().GetUILanguageTag().getLanguageType();
- for (i = FNT_BEGIN; i < FNT_END; ++i)
+ LanguageType nLang = Application::GetSettings().GetUILanguageTag().getLanguageType();
+ for (i = FNT_BEGIN; i < FNT_END; ++i)
+ {
+ vcl::Font aFnt;
+ bool bUseDefaultFont = true;
+ if (pVal->hasValue() && (*pVal >>= aTmpStr))
{
- vcl::Font aFnt;
- bool bUseDefaultFont = true;
- if (pVal->hasValue() && (*pVal >>= aTmpStr))
+ bUseDefaultFont = aTmpStr.isEmpty();
+ if (bUseDefaultFont)
{
- bUseDefaultFont = aTmpStr.isEmpty();
- if (bUseDefaultFont)
- {
- aFnt = pFormat->GetFont( i );
- aFnt.SetFamilyName( lcl_GetDefaultFontName( nLang, i ) );
- }
- else
- {
- const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr );
- OSL_ENSURE( pFntFmt, "unknown FontFormat" );
- if (pFntFmt)
- aFnt = pFntFmt->GetFont();
- }
+ aFnt = pFormat->GetFont( i );
+ aFnt.SetFamilyName( lcl_GetDefaultFontName( nLang, i ) );
+ }
+ else
+ {
+ const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr );
+ OSL_ENSURE( pFntFmt, "unknown FontFormat" );
+ if (pFntFmt)
+ aFnt = pFntFmt->GetFont();
}
- ++pVal;
-
- aFnt.SetFontSize( pFormat->GetBaseSize() );
- pFormat->SetFont( i, aFnt, bUseDefaultFont );
}
+ ++pVal;
- OSL_ENSURE( pVal - pValues == nProps, "property mismatch" );
- SetFormatModified( false );
+ aFnt.SetFontSize( pFormat->GetBaseSize() );
+ pFormat->SetFont( i, aFnt, bUseDefaultFont );
}
+
+ OSL_ENSURE( pVal - pValues == nProps, "property mismatch" );
+ SetFormatModified( false );
}
@@ -1016,19 +1016,19 @@ void SmMathConfig::SetStandardFormat( const SmFormat &rFormat, bool bSaveFontFor
{
if (!pFormat)
LoadFormat();
- if (rFormat != *pFormat)
- {
- *pFormat = rFormat;
- SetFormatModified( true );
- SaveFormat();
+ if (rFormat == *pFormat)
+ return;
- if (bSaveFontFormatList)
- {
- // needed for SmFontTypeDialog's DefaultButtonClickHdl
- if (pFontFormatList)
- pFontFormatList->SetModified( true );
- SaveFontFormatList();
- }
+ *pFormat = rFormat;
+ SetFormatModified( true );
+ SaveFormat();
+
+ if (bSaveFontFormatList)
+ {
+ // needed for SmFontTypeDialog's DefaultButtonClickHdl
+ if (pFontFormatList)
+ pFontFormatList->SetModified( true );
+ SaveFontFormatList();
}
}
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 973bfc716e28..d75a66267f0f 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -597,25 +597,25 @@ SmCategoryDesc::~SmCategoryDesc()
IMPL_LINK( SmDistanceDialog, GetFocusHdl, weld::Widget&, rControl, void )
{
- if (m_xCategories[nActiveCategory])
- {
- sal_uInt16 i;
-
- if (&rControl == &m_xMetricField1->get_widget())
- i = 0;
- else if (&rControl == &m_xMetricField2->get_widget())
- i = 1;
- else if (&rControl == &m_xMetricField3->get_widget())
- i = 2;
- else if (&rControl == &m_xMetricField4->get_widget())
- i = 3;
- else
- return;
- if (m_pCurrentImage)
- m_pCurrentImage->hide();
- m_pCurrentImage = m_xCategories[nActiveCategory]->GetGraphic(i);
- m_pCurrentImage->show();
- }
+ if (!m_xCategories[nActiveCategory])
+ return;
+
+ sal_uInt16 i;
+
+ if (&rControl == &m_xMetricField1->get_widget())
+ i = 0;
+ else if (&rControl == &m_xMetricField2->get_widget())
+ i = 1;
+ else if (&rControl == &m_xMetricField3->get_widget())
+ i = 2;
+ else if (&rControl == &m_xMetricField4->get_widget())
+ i = 3;
+ else
+ return;
+ if (m_pCurrentImage)
+ m_pCurrentImage->hide();
+ m_pCurrentImage = m_xCategories[nActiveCategory]->GetGraphic(i);
+ m_pCurrentImage->show();
}
IMPL_LINK(SmDistanceDialog, MenuSelectHdl, const OString&, rId, void)
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();
}
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 7e0d5c8b88a5..d4ee00cd7a37 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -502,35 +502,35 @@ void SmEditWindow::CreateEditView()
//! pEditEngine and pEditView may be 0.
//! For example when the program is used by the document-converter
- if (!pEditView && pEditEngine)
- {
- pEditView.reset(new EditView(pEditEngine, this));
- pEditEngine->InsertView( pEditView.get() );
-
- if (!pVScrollBar)
- pVScrollBar = VclPtr<ScrollBar>::Create(this, WinBits(WB_VSCROLL));
- if (!pHScrollBar)
- pHScrollBar = VclPtr<ScrollBar>::Create(this, WinBits(WB_HSCROLL));
- if (!pScrollBox)
- pScrollBox = VclPtr<ScrollBarBox>::Create(this);
- pVScrollBar->SetScrollHdl(LINK(this, SmEditWindow, ScrollHdl));
- pHScrollBar->SetScrollHdl(LINK(this, SmEditWindow, ScrollHdl));
- pVScrollBar->EnableDrag();
- pHScrollBar->EnableDrag();
+ if (pEditView || !pEditEngine)
+ return;
- pEditView->SetOutputArea(AdjustScrollBars());
+ pEditView.reset(new EditView(pEditEngine, this));
+ pEditEngine->InsertView( pEditView.get() );
- ESelection eSelection;
+ if (!pVScrollBar)
+ pVScrollBar = VclPtr<ScrollBar>::Create(this, WinBits(WB_VSCROLL));
+ if (!pHScrollBar)
+ pHScrollBar = VclPtr<ScrollBar>::Create(this, WinBits(WB_HSCROLL));
+ if (!pScrollBox)
+ pScrollBox = VclPtr<ScrollBarBox>::Create(this);
+ pVScrollBar->SetScrollHdl(LINK(this, SmEditWindow, ScrollHdl));
+ pHScrollBar->SetScrollHdl(LINK(this, SmEditWindow, ScrollHdl));
+ pVScrollBar->EnableDrag();
+ pHScrollBar->EnableDrag();
- pEditView->SetSelection(eSelection);
- Update();
- pEditView->ShowCursor();
+ pEditView->SetOutputArea(AdjustScrollBars());
- pEditEngine->SetStatusEventHdl( LINK(this, SmEditWindow, EditStatusHdl) );
- SetPointer(pEditView->GetPointer());
+ ESelection eSelection;
- SetScrollBarRanges();
- }
+ pEditView->SetSelection(eSelection);
+ Update();
+ pEditView->ShowCursor();
+
+ pEditEngine->SetStatusEventHdl( LINK(this, SmEditWindow, EditStatusHdl) );
+ SetPointer(pEditView->GetPointer());
+
+ SetScrollBarRanges();
}
@@ -594,23 +594,23 @@ void SmEditWindow::SetScrollBarRanges()
void SmEditWindow::InitScrollBars()
{
- if (pVScrollBar && pHScrollBar && pScrollBox && pEditView)
- {
- const Size aOut( pEditView->GetOutputArea().GetSize() );
- pVScrollBar->SetVisibleSize(aOut.Height());
- pVScrollBar->SetPageSize(aOut.Height() * 8 / 10);
- pVScrollBar->SetLineSize(aOut.Height() * 2 / 10);
+ if (!(pVScrollBar && pHScrollBar && pScrollBox && pEditView))
+ return;
- pHScrollBar->SetVisibleSize(aOut.Width());
- pHScrollBar->SetPageSize(aOut.Width() * 8 / 10);
- pHScrollBar->SetLineSize(SCROLL_LINE );
+ const Size aOut( pEditView->GetOutputArea().GetSize() );
+ pVScrollBar->SetVisibleSize(aOut.Height());
+ pVScrollBar->SetPageSize(aOut.Height() * 8 / 10);
+ pVScrollBar->SetLineSize(aOut.Height() * 2 / 10);
- SetScrollBarRanges();
+ pHScrollBar->SetVisibleSize(aOut.Width());
+ pHScrollBar->SetPageSize(aOut.Width() * 8 / 10);
+ pHScrollBar->SetLineSize(SCROLL_LINE );
- pVScrollBar->Show();
- pHScrollBar->Show();
- pScrollBox->Show();
- }
+ SetScrollBarRanges();
+
+ pVScrollBar->Show();
+ pHScrollBar->Show();
+ pScrollBox->Show();
}
@@ -629,22 +629,22 @@ void SmEditWindow::SetText(const OUString& rText)
{
EditEngine *pEditEngine = GetEditEngine();
OSL_ENSURE( pEditEngine, "EditEngine missing" );
- if (pEditEngine && !pEditEngine->IsModified())
- {
- if (!pEditView)
- CreateEditView();
+ if (!pEditEngine || pEditEngine->IsModified())
+ return;
- ESelection eSelection = pEditView->GetSelection();
+ if (!pEditView)
+ CreateEditView();
- pEditEngine->SetText(rText);
- pEditEngine->ClearModifyFlag();
+ ESelection eSelection = pEditView->GetSelection();
- // Restarting the timer here, prevents calling the handlers for other (currently inactive)
- // math tasks
- aModifyIdle.Start();
+ pEditEngine->SetText(rText);
+ pEditEngine->ClearModifyFlag();
- pEditView->SetSelection(eSelection);
- }
+ // Restarting the timer here, prevents calling the handlers for other (currently inactive)
+ // math tasks
+ aModifyIdle.Start();
+
+ pEditView->SetSelection(eSelection);
}
@@ -742,26 +742,26 @@ void SmEditWindow::SelNextMark()
EditEngine *pEditEngine = GetEditEngine();
OSL_ENSURE( pEditView, "NULL pointer" );
OSL_ENSURE( pEditEngine, "NULL pointer" );
- if (pEditEngine && pEditView)
- {
- ESelection eSelection = pEditView->GetSelection();
- sal_Int32 nPos = eSelection.nEndPos;
- sal_Int32 nCounts = pEditEngine->GetParagraphCount();
+ if (!pEditEngine || !pEditView)
+ return;
- while (eSelection.nEndPara < nCounts)
- {
- OUString aText = pEditEngine->GetText(eSelection.nEndPara);
- nPos = aText.indexOf("<?>", nPos);
- if (nPos != -1)
- {
- pEditView->SetSelection(ESelection(
- eSelection.nEndPara, nPos, eSelection.nEndPara, nPos + 3));
- break;
- }
+ ESelection eSelection = pEditView->GetSelection();
+ sal_Int32 nPos = eSelection.nEndPos;
+ sal_Int32 nCounts = pEditEngine->GetParagraphCount();
- nPos = 0;
- eSelection.nEndPara++;
+ while (eSelection.nEndPara < nCounts)
+ {
+ OUString aText = pEditEngine->GetText(eSelection.nEndPara);
+ nPos = aText.indexOf("<?>", nPos);
+ if (nPos != -1)
+ {
+ pEditView->SetSelection(ESelection(
+ eSelection.nEndPara, nPos, eSelection.nEndPara, nPos + 3));
+ break;
}
+
+ nPos = 0;
+ eSelection.nEndPara++;
}
}
@@ -770,24 +770,24 @@ void SmEditWindow::SelPrevMark()
EditEngine *pEditEngine = GetEditEngine();
OSL_ENSURE( pEditEngine, "NULL pointer" );
OSL_ENSURE( pEditView, "NULL pointer" );
- if (pEditEngine && pEditView)
+ if (!(pEditEngine && pEditView))
+ return;
+
+ ESelection eSelection = pEditView->GetSelection();
+ sal_Int32 nPara = eSelection.nStartPara;
+ sal_Int32 nMax = eSelection.nStartPos;
+ OUString aText(pEditEngine->GetText(nPara));
+ const OUString aMark("<?>");
+ sal_Int32 nPos;
+
+ while ( (nPos = aText.lastIndexOf(aMark, nMax)) < 0 )
{
- ESelection eSelection = pEditView->GetSelection();
- sal_Int32 nPara = eSelection.nStartPara;
- sal_Int32 nMax = eSelection.nStartPos;
- OUString aText(pEditEngine->GetText(nPara));
- const OUString aMark("<?>");
- sal_Int32 nPos;
-
- while ( (nPos = aText.lastIndexOf(aMark, nMax)) < 0 )
- {
- if (--nPara < 0)
- return;
- aText = pEditEngine->GetText(nPara);
- nMax = aText.getLength();
- }
- pEditView->SetSelection(ESelection(nPara, nPos, nPara, nPos + 3));
+ if (--nPara < 0)
+ return;
+ aText = pEditEngine->GetText(nPara);
+ nMax = aText.getLength();
}
+ pEditView->SetSelection(ESelection(nPara, nPos, nPara, nPos + 3));
}
bool SmEditWindow::HasMark(const OUString& rText)
@@ -893,64 +893,64 @@ void SmEditWindow::Delete()
void SmEditWindow::InsertText(const OUString& rText)
{
OSL_ENSURE( pEditView, "EditView missing" );
- if (pEditView)
- {
- // Note: Insertion of a space in front of commands is done here and
- // in SmEditWindow::InsertCommand.
- ESelection aSelection = pEditView->GetSelection();
- OUString aCurrentFormula = pEditView->GetEditEngine()->GetText();
- sal_Int32 nStartIndex = 0;
-
- // get the start position (when we get a multi line formula)
- for (sal_Int32 nParaPos = 0; nParaPos < aSelection.nStartPara; nParaPos++)
- nStartIndex = aCurrentFormula.indexOf("\n", nStartIndex) + 1;
-
- nStartIndex += aSelection.nStartPos;
-
- // TODO: unify this function with the InsertCommand: The do the same thing for different
- // callers
- OUString string(rText);
-
- OUString selected(pEditView->GetSelected());
- // if we have text selected, use it in the first placeholder
- if (!selected.isEmpty())
- string = string.replaceFirst("<?>", selected);
-
- // put a space before a new command if not in the beginning of a line
- if (aSelection.nStartPos > 0 && aCurrentFormula[nStartIndex - 1] != ' ')
- string = " " + string;
-
- /*
- fdo#65588 - Elements Dock: Scrollbar moves into input window
- This change "solves" the visual problem. But I don't think so
- this is the best solution.
- */
- pVScrollBar->Hide();
- pHScrollBar->Hide();
- pEditView->InsertText(string);
- AdjustScrollBars();
- pVScrollBar->Show();
- pHScrollBar->Show();
-
- // Remember start of the selection and move the cursor there afterwards.
- aSelection.nEndPara = aSelection.nStartPara;
- if (HasMark(string))
- {
- aSelection.nEndPos = aSelection.nStartPos;
- pEditView->SetSelection(aSelection);
- SelNextMark();
- }
- else
- { // set selection after inserted text
- aSelection.nEndPos = aSelection.nStartPos + string.getLength();
- aSelection.nStartPos = aSelection.nEndPos;
- pEditView->SetSelection(aSelection);
- }
+ if (!pEditView)
+ return;
- aModifyIdle.Start();
- StartCursorMove();
- GrabFocus();
+ // Note: Insertion of a space in front of commands is done here and
+ // in SmEditWindow::InsertCommand.
+ ESelection aSelection = pEditView->GetSelection();
+ OUString aCurrentFormula = pEditView->GetEditEngine()->GetText();
+ sal_Int32 nStartIndex = 0;
+
+ // get the start position (when we get a multi line formula)
+ for (sal_Int32 nParaPos = 0; nParaPos < aSelection.nStartPara; nParaPos++)
+ nStartIndex = aCurrentFormula.indexOf("\n", nStartIndex) + 1;
+
+ nStartIndex += aSelection.nStartPos;
+
+ // TODO: unify this function with the InsertCommand: The do the same thing for different
+ // callers
+ OUString string(rText);
+
+ OUString selected(pEditView->GetSelected());
+ // if we have text selected, use it in the first placeholder
+ if (!selected.isEmpty())
+ string = string.replaceFirst("<?>", selected);
+
+ // put a space before a new command if not in the beginning of a line
+ if (aSelection.nStartPos > 0 && aCurrentFormula[nStartIndex - 1] != ' ')
+ string = " " + string;
+
+ /*
+ fdo#65588 - Elements Dock: Scrollbar moves into input window
+ This change "solves" the visual problem. But I don't think so
+ this is the best solution.
+ */
+ pVScrollBar->Hide();
+ pHScrollBar->Hide();
+ pEditView->InsertText(string);
+ AdjustScrollBars();
+ pVScrollBar->Show();
+ pHScrollBar->Show();
+
+ // Remember start of the selection and move the cursor there afterwards.
+ aSelection.nEndPara = aSelection.nStartPara;
+ if (HasMark(string))
+ {
+ aSelection.nEndPos = aSelection.nStartPos;
+ pEditView->SetSelection(aSelection);
+ SelNextMark();
+ }
+ else
+ { // set selection after inserted text
+ aSelection.nEndPos = aSelection.nStartPos + string.getLength();
+ aSelection.nStartPos = aSelection.nEndPos;
+ pEditView->SetSelection(aSelection);
}
+
+ aModifyIdle.Start();
+ StartCursorMove();
+ GrabFocus();
}
void SmEditWindow::Flush()
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index cec8022bb0d6..9e15844cd347 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -479,26 +479,26 @@ void SmXMLExport::ExportContent_()
ExportNodes(pTree, 0);
- if (!aText.isEmpty())
- {
- // Convert symbol names
- if (pDocShell)
- {
- SmParser &rParser = pDocShell->GetParser();
- bool bVal = rParser.IsExportSymbolNames();
- rParser.SetExportSymbolNames( true );
- auto pTmpTree = rParser.Parse( aText );
- aText = rParser.GetText();
- pTmpTree.reset();
- rParser.SetExportSymbolNames( bVal );
- }
+ if (aText.isEmpty())
+ return;
- AddAttribute(XML_NAMESPACE_MATH, XML_ENCODING,
- OUString("StarMath 5.0"));
- SvXMLElementExport aAnnotation(*this, XML_NAMESPACE_MATH,
- XML_ANNOTATION, true, false);
- GetDocHandler()->characters( aText );
+ // Convert symbol names
+ if (pDocShell)
+ {
+ SmParser &rParser = pDocShell->GetParser();
+ bool bVal = rParser.IsExportSymbolNames();
+ rParser.SetExportSymbolNames( true );
+ auto pTmpTree = rParser.Parse( aText );
+ aText = rParser.GetText();
+ pTmpTree.reset();
+ rParser.SetExportSymbolNames( bVal );
}
+
+ AddAttribute(XML_NAMESPACE_MATH, XML_ENCODING,
+ OUString("StarMath 5.0"));
+ SvXMLElementExport aAnnotation(*this, XML_NAMESPACE_MATH,
+ XML_ANNOTATION, true, false);
+ GetDocHandler()->characters( aText );
}
void SmXMLExport::GetViewSettings( Sequence < PropertyValue >& aProps)
@@ -541,37 +541,38 @@ void SmXMLExport::GetViewSettings( Sequence < PropertyValue >& aProps)
void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps)
{
Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY );
- if ( xProps.is() )
- {
- Reference< XPropertySetInfo > xPropertySetInfo = xProps->getPropertySetInfo();
- if (xPropertySetInfo.is())
- {
- Sequence< Property > aProps = xPropertySetInfo->getProperties();
- if (const sal_Int32 nCount = aProps.getLength())
- {
- rProps.realloc(nCount);
- SmMathConfig* pConfig = SM_MOD()->GetConfig();
- const bool bUsedSymbolsOnly = pConfig && pConfig->IsSaveOnlyUsedSymbols();
-
- std::transform(aProps.begin(), aProps.end(), rProps.begin(),
- [bUsedSymbolsOnly, &xProps](Property& prop) {
- PropertyValue aRet;
- if (prop.Name != "Formula" && prop.Name != "BasicLibraries"
- && prop.Name != "DialogLibraries"
- && prop.Name != "RuntimeUID")
- {
- aRet.Name = prop.Name;
- OUString aActualName(prop.Name);
- // handle 'save used symbols only'
- if (bUsedSymbolsOnly && prop.Name == "Symbols")
- aActualName = "UserDefinedSymbolsInUse";
- aRet.Value = xProps->getPropertyValue(aActualName);
- }
- return aRet;
- });
- }
- }
- }
+ if ( !xProps.is() )
+ return;
+
+ Reference< XPropertySetInfo > xPropertySetInfo = xProps->getPropertySetInfo();
+ if (!xPropertySetInfo.is())
+ return;
+
+ Sequence< Property > aProps = xPropertySetInfo->getProperties();
+ const sal_Int32 nCount = aProps.getLength();
+ if (!nCount)
+ return;
+
+ rProps.realloc(nCount);
+ SmMathConfig* pConfig = SM_MOD()->GetConfig();
+ const bool bUsedSymbolsOnly = pConfig && pConfig->IsSaveOnlyUsedSymbols();
+
+ std::transform(aProps.begin(), aProps.end(), rProps.begin(),
+ [bUsedSymbolsOnly, &xProps](Property& prop) {
+ PropertyValue aRet;
+ if (prop.Name != "Formula" && prop.Name != "BasicLibraries"
+ && prop.Name != "DialogLibraries"
+ && prop.Name != "RuntimeUID")
+ {
+ aRet.Name = prop.Name;
+ OUString aActualName(prop.Name);
+ // handle 'save used symbols only'
+ if (bUsedSymbolsOnly && prop.Name == "Symbols")
+ aActualName = "UserDefinedSymbolsInUse";
+ aRet.Value = xProps->getPropertyValue(aActualName);
+ }
+ return aRet;
+ });
}
void SmXMLExport::ExportLine(const SmNode *pNode, int nLevel)
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 674a3116c8d3..c702333b8ea0 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -671,86 +671,85 @@ void SmXMLContext_Helper::ApplyAttrs()
{
SmNodeStack &rNodeStack = rContext.GetSmImport().GetNodeStack();
- if (IsFontNodeNeeded())
+ if (!IsFontNodeNeeded())
+ return;
+
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nLevel = 5;
+
+ if (nIsBold != -1)
{
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nLevel = 5;
+ if (nIsBold)
+ aToken.eType = TBOLD;
+ else
+ aToken.eType = TNBOLD;
+ std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken));
+ pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack));
+ rNodeStack.push_front(std::move(pFontNode));
+ }
+ if (nIsItalic != -1)
+ {
+ if (nIsItalic)
+ aToken.eType = TITALIC;
+ else
+ aToken.eType = TNITALIC;
+ std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken));
+ pFontNode->SetSubNodes(nullptr,popOrZero(rNodeStack));
+ rNodeStack.push_front(std::move(pFontNode));
+ }
+ if (nFontSize != 0.0)
+ {
+ aToken.eType = TSIZE;
+ std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken));
- if (nIsBold != -1)
+ if (util::MeasureUnit::PERCENT == rContext.GetSmImport()
+ .GetMM100UnitConverter().GetXMLMeasureUnit())
{
- if (nIsBold)
- aToken.eType = TBOLD;
+ if (nFontSize < 100.00)
+ pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
+ FontSizeType::DIVIDE);
else
- aToken.eType = TNBOLD;
- std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken));
- pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack));
- rNodeStack.push_front(std::move(pFontNode));
+ pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
+ FontSizeType::MULTIPLY);
}
- if (nIsItalic != -1)
- {
- if (nIsItalic)
- aToken.eType = TITALIC;
- else
- aToken.eType = TNITALIC;
- std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken));
- pFontNode->SetSubNodes(nullptr,popOrZero(rNodeStack));
- rNodeStack.push_front(std::move(pFontNode));
- }
- if (nFontSize != 0.0)
- {
- aToken.eType = TSIZE;
- std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken));
+ else
+ pFontNode->SetSizeParameter(Fraction(nFontSize),FontSizeType::ABSOLUT);
- if (util::MeasureUnit::PERCENT == rContext.GetSmImport()
- .GetMM100UnitConverter().GetXMLMeasureUnit())
- {
- if (nFontSize < 100.00)
- pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
- FontSizeType::DIVIDE);
- else
- pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
- FontSizeType::MULTIPLY);
- }
- else
- pFontNode->SetSizeParameter(Fraction(nFontSize),FontSizeType::ABSOLUT);
+ pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack));
+ rNodeStack.push_front(std::move(pFontNode));
+ }
+ if (!sFontFamily.isEmpty())
+ {
+ if (sFontFamily.equalsIgnoreAsciiCase(GetXMLToken(XML_FIXED)))
+ aToken.eType = TFIXED;
+ else if (sFontFamily.equalsIgnoreAsciiCase("sans"))
+ aToken.eType = TSANS;
+ else if (sFontFamily.equalsIgnoreAsciiCase("serif"))
+ aToken.eType = TSERIF;
+ else //Just give up, we need to extend our font mechanism to be
+ //more general
+ return;
- pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack));
- rNodeStack.push_front(std::move(pFontNode));
- }
- if (!sFontFamily.isEmpty())
- {
- if (sFontFamily.equalsIgnoreAsciiCase(GetXMLToken(XML_FIXED)))
- aToken.eType = TFIXED;
- else if (sFontFamily.equalsIgnoreAsciiCase("sans"))
- aToken.eType = TSANS;
- else if (sFontFamily.equalsIgnoreAsciiCase("serif"))
- aToken.eType = TSERIF;
- else //Just give up, we need to extend our font mechanism to be
- //more general
- return;
-
- aToken.aText = sFontFamily;
- std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken));
- pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack));
- rNodeStack.push_front(std::move(pFontNode));
- }
- if (!sColor.isEmpty())
- {
- //Again we can only handle a small set of colours in
- //StarMath for now.
- const SvXMLTokenMap& rTokenMap =
- rContext.GetSmImport().GetColorTokenMap();
- sal_uInt16 tok = rTokenMap.Get(XML_NAMESPACE_MATH, sColor);
- if (tok != XML_TOK_UNKNOWN)
- {
- aToken.eType = static_cast<SmTokenType>(tok);
- std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken));
- pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack));
- rNodeStack.push_front(std::move(pFontNode));
- }
- }
+ aToken.aText = sFontFamily;
+ std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken));
+ pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack));
+ rNodeStack.push_front(std::move(pFontNode));
+ }
+ if (sColor.isEmpty())
+ return;
+ //Again we can only handle a small set of colours in
+ //StarMath for now.
+ const SvXMLTokenMap& rTokenMap =
+ rContext.GetSmImport().GetColorTokenMap();
+ sal_uInt16 tok = rTokenMap.Get(XML_NAMESPACE_MATH, sColor);
+ if (tok != XML_TOK_UNKNOWN)
+ {
+ aToken.eType = static_cast<SmTokenType>(tok);
+ std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken));
+ pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack));
+ rNodeStack.push_front(std::move(pFontNode));
}
}
@@ -3122,41 +3121,41 @@ void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps)
void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfProps)
{
uno::Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY );
- if ( xProps.is() )
+ if ( !xProps.is() )
+ return;
+
+ Reference < XPropertySetInfo > xInfo ( xProps->getPropertySetInfo() );
+ if (!xInfo.is() )
+ return;
+
+ sal_Int32 nCount = aConfProps.getLength();
+ const PropertyValue* pValues = aConfProps.getConstArray();
+
+ const OUString sFormula ( "Formula" );
+ const OUString sBasicLibraries ( "BasicLibraries" );
+ const OUString sDialogLibraries ( "DialogLibraries" );
+ while ( nCount-- )
{
- Reference < XPropertySetInfo > xInfo ( xProps->getPropertySetInfo() );
- if (xInfo.is() )
+ if (pValues->Name != sFormula &&
+ pValues->Name != sBasicLibraries &&
+ pValues->Name != sDialogLibraries)
{
- sal_Int32 nCount = aConfProps.getLength();
- const PropertyValue* pValues = aConfProps.getConstArray();
-
- const OUString sFormula ( "Formula" );
- const OUString sBasicLibraries ( "BasicLibraries" );
- const OUString sDialogLibraries ( "DialogLibraries" );
- while ( nCount-- )
+ try
{
- if (pValues->Name != sFormula &&
- pValues->Name != sBasicLibraries &&
- pValues->Name != sDialogLibraries)
- {
- try
- {
- if ( xInfo->hasPropertyByName( pValues->Name ) )
- xProps->setPropertyValue( pValues->Name, pValues->Value );
- }
- catch (const beans::PropertyVetoException &)
- {
- // dealing with read-only properties here. Nothing to do...
- }
- catch (const Exception&)
- {
- DBG_UNHANDLED_EXCEPTION("starmath");
- }
- }
-
- pValues++;
+ if ( xInfo->hasPropertyByName( pValues->Name ) )
+ xProps->setPropertyValue( pValues->Name, pValues->Value );
+ }
+ catch (const beans::PropertyVetoException &)
+ {
+ // dealing with read-only properties here. Nothing to do...
+ }
+ catch (const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("starmath");
}
}
+
+ pValues++;
}
}
diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx
index 63ff86fe9ef4..1a0bb30885a9 100644
--- a/starmath/source/mathtype.cxx
+++ b/starmath/source/mathtype.cxx
@@ -1744,26 +1744,26 @@ bool MathType::HandleRecords(int nLevel, sal_uInt8 nSelector,
void MathType::HandleMatrixSeparator(int nMatrixRows,int nMatrixCols,
int &rCurCol,int &rCurRow)
{
- if (nMatrixRows!=0)
+ if (nMatrixRows==0)
+ return;
+
+ if (rCurCol == nMatrixCols-1)
{
- if (rCurCol == nMatrixCols-1)
+ if (rCurRow != nMatrixRows-1)
+ rRet.append(" {} ##\n");
+ if (nMatrixRows!=-1)
{
- if (rCurRow != nMatrixRows-1)
- rRet.append(" {} ##\n");
- if (nMatrixRows!=-1)
- {
- rCurCol=0;
- rCurRow++;
- }
+ rCurCol=0;
+ rCurRow++;
}
+ }
+ else
+ {
+ rRet.append(" {} # ");
+ if (nMatrixRows!=-1)
+ rCurCol++;
else
- {
- rRet.append(" {} # ");
- if (nMatrixRows!=-1)
- rCurCol++;
- else
- rRet.append("\n");
- }
+ rRet.append("\n");
}
}
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index ebbb57f3d7b7..97d97582826d 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -2630,32 +2630,32 @@ void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell
Flags() |= FontChangeMask::Face;
- if (mbIsFromGreekSymbolSet)
+ if (!mbIsFromGreekSymbolSet)
+ return;
+
+ OSL_ENSURE( GetText().getLength() == 1, "a symbol should only consist of 1 char!" );
+ bool bItalic = false;
+ sal_Int16 nStyle = rFormat.GetGreekCharStyle();
+ OSL_ENSURE( nStyle >= 0 && nStyle <= 2, "unexpected value for GreekCharStyle" );
+ if (nStyle == 1)
+ bItalic = true;
+ else if (nStyle == 2)
{
- OSL_ENSURE( GetText().getLength() == 1, "a symbol should only consist of 1 char!" );
- bool bItalic = false;
- sal_Int16 nStyle = rFormat.GetGreekCharStyle();
- OSL_ENSURE( nStyle >= 0 && nStyle <= 2, "unexpected value for GreekCharStyle" );
- if (nStyle == 1)
- bItalic = true;
- else if (nStyle == 2)
+ const OUString& rTmp(GetText());
+ if (!rTmp.isEmpty())
{
- const OUString& rTmp(GetText());
- if (!rTmp.isEmpty())
- {
- static const sal_Unicode cUppercaseAlpha = 0x0391;
- static const sal_Unicode cUppercaseOmega = 0x03A9;
- sal_Unicode cChar = rTmp[0];
- // uppercase letters should be straight and lowercase letters italic
- bItalic = !(cUppercaseAlpha <= cChar && cChar <= cUppercaseOmega);
- }
+ static const sal_Unicode cUppercaseAlpha = 0x0391;
+ static const sal_Unicode cUppercaseOmega = 0x03A9;
+ sal_Unicode cChar = rTmp[0];
+ // uppercase letters should be straight and lowercase letters italic
+ bItalic = !(cUppercaseAlpha <= cChar && cChar <= cUppercaseOmega);
}
-
- if (bItalic)
- Attributes() |= FontAttribute::Italic;
- else
- Attributes() &= ~FontAttribute::Italic;
}
+
+ if (bItalic)
+ Attributes() |= FontAttribute::Italic;
+ else
+ Attributes() &= ~FontAttribute::Italic;
};
diff --git a/starmath/source/symbol.cxx b/starmath/source/symbol.cxx
index 404b1de01599..e2b2bf3abc49 100644
--- a/starmath/source/symbol.cxx
+++ b/starmath/source/symbol.cxx
@@ -249,27 +249,27 @@ void SmSymbolManager::Load()
void SmSymbolManager::Save()
{
- if (m_bModified)
- {
- SmMathConfig &rCfg = *SM_MOD()->GetConfig();
+ if (!m_bModified)
+ return;
- // prepare to skip symbols from iGreek on saving
- OUString aSymbolSetName('i');
- aSymbolSetName += SmLocalizedSymbolData::GetUiSymbolSetName("Greek");
+ SmMathConfig &rCfg = *SM_MOD()->GetConfig();
- SymbolPtrVec_t aTmp( GetSymbols() );
- std::vector< SmSym > aSymbols;
- for (const SmSym* i : aTmp)
- {
- // skip symbols from iGreek set since those symbols always get added
- // by computational means in SmSymbolManager::Load
- if (i->GetSymbolSetName() != aSymbolSetName)
- aSymbols.push_back( *i );
- }
- rCfg.SetSymbols( aSymbols );
+ // prepare to skip symbols from iGreek on saving
+ OUString aSymbolSetName('i');
+ aSymbolSetName += SmLocalizedSymbolData::GetUiSymbolSetName("Greek");
- m_bModified = false;
+ SymbolPtrVec_t aTmp( GetSymbols() );
+ std::vector< SmSym > aSymbols;
+ for (const SmSym* i : aTmp)
+ {
+ // skip symbols from iGreek set since those symbols always get added
+ // by computational means in SmSymbolManager::Load
+ if (i->GetSymbolSetName() != aSymbolSetName)
+ aSymbols.push_back( *i );
}
+ rCfg.SetSymbols( aSymbols );
+
+ m_bModified = false;
}
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 8f47001fe79c..f87ff05fb696 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -991,78 +991,78 @@ void SAL_CALL SmModel::render(
rxOptions[i].Value >>= xRenderDevice;
}
- if (xRenderDevice.is())
- {
- VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
- VclPtr< OutputDevice> pOut = pDevice ? pDevice->GetOutputDevice()
- : VclPtr< OutputDevice >();
- if (!pOut)
- throw RuntimeException();
+ if (!xRenderDevice.is())
+ return;
- pOut->SetMapMode(MapMode(MapUnit::Map100thMM));
+ VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
+ VclPtr< OutputDevice> pOut = pDevice ? pDevice->GetOutputDevice()
+ : VclPtr< OutputDevice >();
+ if (!pOut)
+ throw RuntimeException();
- uno::Reference< frame::XModel > xModel;
- rSelection >>= xModel;
- if (xModel == pDocSh->GetModel())
- {
- //!! when called via API we may not have an active view
- //!! thus we go and look for a view that can be used.
- SfxViewShell* pViewSh = SfxViewShell::GetFirst( false /* search non-visible views as well*/, checkSfxViewShell<SmViewShell> );
- while (pViewSh && pViewSh->GetObjectShell() != pDocSh)
- pViewSh = SfxViewShell::GetNext( *pViewSh, false /* search non-visible views as well*/, checkSfxViewShell<SmViewShell> );
- SmViewShell *pView = dynamic_cast< SmViewShell *>( pViewSh );
- SAL_WARN_IF( !pView, "starmath", "SmModel::render : no SmViewShell found" );
-
- if (pView)
- {
- SmPrinterAccess aPrinterAccess( *pDocSh );
- Printer *pPrinter = aPrinterAccess.GetPrinter();
+ pOut->SetMapMode(MapMode(MapUnit::Map100thMM));
- Size aPrtPaperSize ( pPrinter->GetPaperSize() );
- Size aOutputSize ( pPrinter->GetOutputSize() );
- Point aPrtPageOffset( pPrinter->GetPageOffset() );
+ uno::Reference< frame::XModel > xModel;
+ rSelection >>= xModel;
+ if (xModel != pDocSh->GetModel())
+ return;
- // no real printer ??
- if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
- {
- aPrtPaperSize = lcl_GuessPaperSize();
- // factors from Windows DIN A4
- aOutputSize = Size( static_cast<long>(aPrtPaperSize.Width() * 0.941),
- static_cast<long>(aPrtPaperSize.Height() * 0.961));
- aPrtPageOffset = Point( static_cast<long>(aPrtPaperSize.Width() * 0.0250),
- static_cast<long>(aPrtPaperSize.Height() * 0.0214));
- }
- tools::Rectangle OutputRect( Point(), aOutputSize );
+ //!! when called via API we may not have an active view
+ //!! thus we go and look for a view that can be used.
+ SfxViewShell* pViewSh = SfxViewShell::GetFirst( false /* search non-visible views as well*/, checkSfxViewShell<SmViewShell> );
+ while (pViewSh && pViewSh->GetObjectShell() != pDocSh)
+ pViewSh = SfxViewShell::GetNext( *pViewSh, false /* search non-visible views as well*/, checkSfxViewShell<SmViewShell> );
+ SmViewShell *pView = dynamic_cast< SmViewShell *>( pViewSh );
+ SAL_WARN_IF( !pView, "starmath", "SmModel::render : no SmViewShell found" );
+ if (!pView)
+ return;
- // set minimum top and bottom border
- if (aPrtPageOffset.Y() < 2000)
- OutputRect.AdjustTop(2000 - aPrtPageOffset.Y() );
- if ((aPrtPaperSize.Height() - (aPrtPageOffset.Y() + OutputRect.Bottom())) < 2000)
- OutputRect.AdjustBottom( -(2000 - (aPrtPaperSize.Height() -
- (aPrtPageOffset.Y() + OutputRect.Bottom()))) );
+ SmPrinterAccess aPrinterAccess( *pDocSh );
+ Printer *pPrinter = aPrinterAccess.GetPrinter();
- // set minimum left and right border
- if (aPrtPageOffset.X() < 2500)
- OutputRect.AdjustLeft(2500 - aPrtPageOffset.X() );
- if ((aPrtPaperSize.Width() - (aPrtPageOffset.X() + OutputRect.Right())) < 1500)
- OutputRect.AdjustRight( -(1500 - (aPrtPaperSize.Width() -
- (aPrtPageOffset.X() + OutputRect.Right()))) );
+ Size aPrtPaperSize ( pPrinter->GetPaperSize() );
+ Size aOutputSize ( pPrinter->GetOutputSize() );
+ Point aPrtPageOffset( pPrinter->GetPageOffset() );
- if (!m_pPrintUIOptions)
- m_pPrintUIOptions.reset(new SmPrintUIOptions);
- m_pPrintUIOptions->processProperties( rxOptions );
+ // no real printer ??
+ if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
+ {
+ aPrtPaperSize = lcl_GuessPaperSize();
+ // factors from Windows DIN A4
+ aOutputSize = Size( static_cast<long>(aPrtPaperSize.Width() * 0.941),
+ static_cast<long>(aPrtPaperSize.Height() * 0.961));
+ aPrtPageOffset = Point( static_cast<long>(aPrtPaperSize.Width() * 0.0250),
+ static_cast<long>(aPrtPaperSize.Height() * 0.0214));
+ }
+ tools::Rectangle OutputRect( Point(), aOutputSize );
- pView->Impl_Print( *pOut, *m_pPrintUIOptions, OutputRect );
- // release SmPrintUIOptions when everything is done.
- // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
- if (m_pPrintUIOptions->getBoolValue( "IsLastPage" ))
- {
- m_pPrintUIOptions.reset();
- }
- }
- }
+ // set minimum top and bottom border
+ if (aPrtPageOffset.Y() < 2000)
+ OutputRect.AdjustTop(2000 - aPrtPageOffset.Y() );
+ if ((aPrtPaperSize.Height() - (aPrtPageOffset.Y() + OutputRect.Bottom())) < 2000)
+ OutputRect.AdjustBottom( -(2000 - (aPrtPaperSize.Height() -
+ (aPrtPageOffset.Y() + OutputRect.Bottom()))) );
+
+ // set minimum left and right border
+ if (aPrtPageOffset.X() < 2500)
+ OutputRect.AdjustLeft(2500 - aPrtPageOffset.X() );
+ if ((aPrtPaperSize.Width() - (aPrtPageOffset.X() + OutputRect.Right())) < 1500)
+ OutputRect.AdjustRight( -(1500 - (aPrtPaperSize.Width() -
+ (aPrtPageOffset.X() + OutputRect.Right()))) );
+
+ if (!m_pPrintUIOptions)
+ m_pPrintUIOptions.reset(new SmPrintUIOptions);
+ m_pPrintUIOptions->processProperties( rxOptions );
+
+ pView->Impl_Print( *pOut, *m_pPrintUIOptions, OutputRect );
+
+ // release SmPrintUIOptions when everything is done.
+ // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
+ if (m_pPrintUIOptions->getBoolValue( "IsLastPage" ))
+ {
+ m_pPrintUIOptions.reset();
}
}
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index c506d0715b1b..4c47d9203678 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -151,45 +151,46 @@ void SmGraphicWindow::MouseButtonDown(const MouseEvent& rMEvt)
// position clicked at
SAL_WARN_IF( rMEvt.GetClicks() == 0, "starmath", "0 clicks" );
- if ( rMEvt.IsLeft() )
- {
- // get click position relative to formula
- Point aPos (PixelToLogic(rMEvt.GetPosPixel())
- - GetFormulaDrawPos());
+ if ( !rMEvt.IsLeft() )
+ return;
- const SmNode *pTree = pViewShell->GetDoc()->GetFormulaTree();
- if (!pTree)
- return;
+ // get click position relative to formula
+ Point aPos (PixelToLogic(rMEvt.GetPosPixel())
+ - GetFormulaDrawPos());
- if (IsInlineEditEnabled()) {
- pViewShell->GetDoc()->GetCursor().MoveTo(this, aPos, !rMEvt.IsShift());
- return;
- }
- const SmNode *pNode = nullptr;
- // if it was clicked inside the formula then get the appropriate node
- if (pTree->OrientedDist(aPos) <= 0)
- pNode = pTree->FindRectClosestTo(aPos);
+ const SmNode *pTree = pViewShell->GetDoc()->GetFormulaTree();
+ if (!pTree)
+ return;
+
+ if (IsInlineEditEnabled()) {
+ pViewShell->GetDoc()->GetCursor().MoveTo(this, aPos, !rMEvt.IsShift());
+ return;
+ }
+ const SmNode *pNode = nullptr;
+ // if it was clicked inside the formula then get the appropriate node
+ if (pTree->OrientedDist(aPos) <= 0)
+ pNode = pTree->FindRectClosestTo(aPos);
- if (pNode)
- { SmEditWindow *pEdit = pViewShell->GetEditWindow();
- if (!pEdit)
- return;
- const SmToken aToken (pNode->GetToken());
+ if (!pNode)
+ return;
- // set selection to the beginning of the token
- ESelection aSel (aToken.nRow - 1, aToken.nCol - 1);
+ SmEditWindow *pEdit = pViewShell->GetEditWindow();
+ if (!pEdit)
+ return;
+ const SmToken aToken (pNode->GetToken());
- if (rMEvt.GetClicks() != 1 || aToken.eType == TPLACE)
- aSel.nEndPos = aSel.nEndPos + sal::static_int_cast< sal_uInt16 >(aToken.aText.getLength());
+ // set selection to the beginning of the token
+ ESelection aSel (aToken.nRow - 1, aToken.nCol - 1);
- pEdit->SetSelection(aSel);
- SetCursor(pNode);
+ if (rMEvt.GetClicks() != 1 || aToken.eType == TPLACE)
+ aSel.nEndPos = aSel.nEndPos + sal::static_int_cast< sal_uInt16 >(aToken.aText.getLength());
- // allow for immediate editing and
- //! implicitly synchronize the cursor position mark in this window
- pEdit->GrabFocus();
- }
- }
+ pEdit->SetSelection(aSel);
+ SetCursor(pNode);
+
+ // allow for immediate editing and
+ //! implicitly synchronize the cursor position mark in this window
+ pEdit->GrabFocus();
}
void SmGraphicWindow::MouseMove(const MouseEvent &rMEvt)
@@ -1341,24 +1342,24 @@ void SmViewShell::Insert( SfxMedium& rMedium )
}
}
- if (bRet)
+ if (!bRet)
+ return;
+
+ OUString aText = pDoc->GetText();
+ SmEditWindow *pEditWin = GetEditWindow();
+ if (pEditWin)
+ pEditWin->InsertText( aText );
+ else
{
- OUString aText = pDoc->GetText();
- SmEditWindow *pEditWin = GetEditWindow();
- if (pEditWin)
- pEditWin->InsertText( aText );
- else
- {
- SAL_WARN( "starmath", "EditWindow missing" );
- }
+ SAL_WARN( "starmath", "EditWindow missing" );
+ }
- pDoc->Parse();
- pDoc->SetModified();
+ pDoc->Parse();
+ pDoc->SetModified();
- SfxBindings &rBnd = GetViewFrame()->GetBindings();
- rBnd.Invalidate(SID_GAPHIC_SM);
- rBnd.Invalidate(SID_TEXT);
- }
+ SfxBindings &rBnd = GetViewFrame()->GetBindings();
+ rBnd.Invalidate(SID_GAPHIC_SM);
+ rBnd.Invalidate(SID_TEXT);
}
void SmViewShell::InsertFrom(SfxMedium &rMedium)
@@ -1378,22 +1379,22 @@ void SmViewShell::InsertFrom(SfxMedium &rMedium)
}
}
- if (bSuccess)
- {
- OUString aText = pDoc->GetText();
- SmEditWindow *pEditWin = GetEditWindow();
- if (pEditWin)
- pEditWin->InsertText(aText);
- else
- SAL_WARN( "starmath", "EditWindow missing" );
+ if (!bSuccess)
+ return;
+
+ OUString aText = pDoc->GetText();
+ SmEditWindow *pEditWin = GetEditWindow();
+ if (pEditWin)
+ pEditWin->InsertText(aText);
+ else
+ SAL_WARN( "starmath", "EditWindow missing" );
- pDoc->Parse();
- pDoc->SetModified();
+ pDoc->Parse();
+ pDoc->SetModified();
- SfxBindings& rBnd = GetViewFrame()->GetBindings();
- rBnd.Invalidate(SID_GAPHIC_SM);
- rBnd.Invalidate(SID_TEXT);
- }
+ SfxBindings& rBnd = GetViewFrame()->GetBindings();
+ rBnd.Invalidate(SID_GAPHIC_SM);
+ rBnd.Invalidate(SID_TEXT);
}
void SmViewShell::Execute(SfxRequest& rReq)
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index c2808b4ff186..1d063a7b7e0d 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -1853,21 +1853,21 @@ SmSelectionDrawingVisitor::SmSelectionDrawingVisitor( OutputDevice& rDevice, SmN
pTree->Accept( this );
//Draw selection if there's any
- if( mbHasSelectionArea ){
- maSelectionArea.Move( rOffset.X( ), rOffset.Y( ) );
+ if( !mbHasSelectionArea ) return;
- //Save device state
- mrDev.Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
- //Change colors
- mrDev.SetLineColor( );
- mrDev.SetFillColor( COL_LIGHTGRAY );
+ maSelectionArea.Move( rOffset.X( ), rOffset.Y( ) );
- //Draw rectangle
- mrDev.DrawRect( maSelectionArea );
+ //Save device state
+ mrDev.Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
+ //Change colors
+ mrDev.SetLineColor( );
+ mrDev.SetFillColor( COL_LIGHTGRAY );
- //Restore device state
- mrDev.Pop( );
- }
+ //Draw rectangle
+ mrDev.DrawRect( maSelectionArea );
+
+ //Restore device state
+ mrDev.Pop( );
}
void SmSelectionDrawingVisitor::ExtendSelectionArea(const tools::Rectangle& rArea)
@@ -1900,21 +1900,22 @@ void SmSelectionDrawingVisitor::VisitChildren( SmNode* pNode )
void SmSelectionDrawingVisitor::Visit( SmTextNode* pNode )
{
- if( pNode->IsSelected( ) ){
- mrDev.Push( PushFlags::TEXTCOLOR | PushFlags::FONT );
+ if( !pNode->IsSelected())
+ return;
- mrDev.SetFont( pNode->GetFont( ) );
- Point Position = pNode->GetTopLeft( );
- long left = Position.getX( ) + mrDev.GetTextWidth( pNode->GetText( ), 0, pNode->GetSelectionStart( ) );
- long right = Position.getX( ) + mrDev.GetTextWidth( pNode->GetText( ), 0, pNode->GetSelectionEnd( ) );
- long top = Position.getY( );
- long bottom = top + pNode->GetHeight( );
- tools::Rectangle rect( left, top, right, bottom );
+ mrDev.Push( PushFlags::TEXTCOLOR | PushFlags::FONT );
- ExtendSelectionArea( rect );
+ mrDev.SetFont( pNode->GetFont( ) );
+ Point Position = pNode->GetTopLeft( );
+ long left = Position.getX( ) + mrDev.GetTextWidth( pNode->GetText( ), 0, pNode->GetSelectionStart( ) );
+ long right = Position.getX( ) + mrDev.GetTextWidth( pNode->GetText( ), 0, pNode->GetSelectionEnd( ) );
+ long top = Position.getY( );
+ long bottom = top + pNode->GetHeight( );
+ tools::Rectangle rect( left, top, right, bottom );
- mrDev.Pop( );
- }
+ ExtendSelectionArea( rect );
+
+ mrDev.Pop( );
}
// SmNodeToTextVisitor