summaryrefslogtreecommitdiff
path: root/starmath/source/mathml
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-01-22 21:24:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-01-23 06:33:50 +0000
commita6339b4a281675164034e10a05ca1b62aad89c67 (patch)
tree9e714fb9273a95be8acca5403ea60dd00e43202a /starmath/source/mathml
parentd47c23cb1a4448a16283555e4d7034c7e1fcd1a7 (diff)
use more concrete SmModel type
Change-Id: I7804e7201e64f419383e37b916b212ac9c129ef6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145984 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath/source/mathml')
-rw-r--r--starmath/source/mathml/export.cxx24
-rw-r--r--starmath/source/mathml/import.cxx38
-rw-r--r--starmath/source/mathml/mathmlimport.cxx18
3 files changed, 30 insertions, 50 deletions
diff --git a/starmath/source/mathml/export.cxx b/starmath/source/mathml/export.cxx
index c9b7bbf6d41a..bafdd7c431a8 100644
--- a/starmath/source/mathml/export.cxx
+++ b/starmath/source/mathml/export.cxx
@@ -76,16 +76,8 @@ bool SmMLExportWrapper::Export(SfxMedium& rMedium)
if (m_xModel == nullptr || xContext == nullptr)
return false;
- //Get model
- uno::Reference<lang::XComponent> xModelComp = m_xModel;
- SAL_WARN_IF(xModelComp == nullptr, "starmath", "Missing model component");
- SmModel* pModel = comphelper::getFromUnoTunnel<SmModel>(m_xModel);
- SAL_WARN_IF(pModel == nullptr, "starmath", "Failed to get threw uno tunnel");
- if (xModelComp == nullptr || pModel == nullptr)
- return false;
-
// Get doc shell
- SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
+ SmDocShell* pDocShell = static_cast<SmDocShell*>(m_xModel->GetObjectShell());
if (pDocShell == nullptr)
{
SAL_WARN("starmath", "Failed to fetch sm document");
@@ -175,7 +167,7 @@ bool SmMLExportWrapper::Export(SfxMedium& rMedium)
if (xStatusIndicator.is())
xStatusIndicator->setValue(1);
- bRet = WriteThroughComponentS(xStg, xModelComp, u"meta.xml", xContext, xInfoSet,
+ bRet = WriteThroughComponentS(xStg, m_xModel, u"meta.xml", xContext, xInfoSet,
u"com.sun.star.comp.Math.MLOasisMetaExporter", 6);
}
@@ -187,10 +179,10 @@ bool SmMLExportWrapper::Export(SfxMedium& rMedium)
xStatusIndicator->setValue(2);
if (pDocShell->GetSmSyntaxVersion() == 5)
- bRet = WriteThroughComponentS(xStg, xModelComp, u"content.xml", xContext, xInfoSet,
+ bRet = WriteThroughComponentS(xStg, m_xModel, u"content.xml", xContext, xInfoSet,
u"com.sun.star.comp.Math.XMLContentExporter", 5);
else
- bRet = WriteThroughComponentS(xStg, xModelComp, u"content.xml", xContext, xInfoSet,
+ bRet = WriteThroughComponentS(xStg, m_xModel, u"content.xml", xContext, xInfoSet,
u"com.sun.star.comp.Math.MLContentExporter", 6);
}
@@ -201,7 +193,7 @@ bool SmMLExportWrapper::Export(SfxMedium& rMedium)
if (xStatusIndicator.is())
xStatusIndicator->setValue(3);
- bRet = WriteThroughComponentS(xStg, xModelComp, u"settings.xml", xContext, xInfoSet,
+ bRet = WriteThroughComponentS(xStg, m_xModel, u"settings.xml", xContext, xInfoSet,
u"com.sun.star.comp.Math.MLOasisSettingsExporter", 6);
}
}
@@ -222,10 +214,10 @@ bool SmMLExportWrapper::Export(SfxMedium& rMedium)
// Write everything in the same place
// Note: export through an XML exporter component (output stream version)
if (pDocShell->GetSmSyntaxVersion() == 5)
- bRet = WriteThroughComponentOS(xOut, xModelComp, xContext, xInfoSet,
+ bRet = WriteThroughComponentOS(xOut, m_xModel, xContext, xInfoSet,
u"com.sun.star.comp.Math.XMLContentExporter", 5);
else
- bRet = WriteThroughComponentOS(xOut, xModelComp, xContext, xInfoSet,
+ bRet = WriteThroughComponentOS(xOut, m_xModel, xContext, xInfoSet,
u"com.sun.star.comp.Math.MLContentExporter", 6);
}
@@ -248,7 +240,7 @@ OUString SmMLExportWrapper::Export(SmMlElement* pElementTree)
//Get model
uno::Reference<lang::XComponent> xModelComp = m_xModel;
SAL_WARN_IF(xModelComp == nullptr, "starmath", "Missing model component");
- SmModel* pModel = comphelper::getFromUnoTunnel<SmModel>(m_xModel);
+ SmModel* pModel = m_xModel.get();
SAL_WARN_IF(pModel == nullptr, "starmath", "Failed to get threw uno tunnel");
if (xModelComp == nullptr || pModel == nullptr)
return u"";
diff --git a/starmath/source/mathml/import.cxx b/starmath/source/mathml/import.cxx
index 62cd455ad069..8a0463283286 100644
--- a/starmath/source/mathml/import.cxx
+++ b/starmath/source/mathml/import.cxx
@@ -90,19 +90,11 @@ ErrCode SmMLImportWrapper::Import(SfxMedium& rMedium)
return ERRCODE_SFX_DOLOADFAILED;
}
- // Make a model component from our SmModel
- uno::Reference<lang::XComponent> xModelComp = m_xModel;
- if (!xModelComp.is())
- {
- SAL_WARN("starmath", "Failed to make model while file input");
- return ERRCODE_SFX_DOLOADFAILED;
- }
-
// Try to get an XStatusIndicator from the Medium
uno::Reference<task::XStatusIndicator> xStatusIndicator;
// Get model via uno
- SmModel* pModel = comphelper::getFromUnoTunnel<SmModel>(m_xModel);
+ SmModel* pModel = m_xModel.get();
if (pModel == nullptr)
{
SAL_WARN("starmath", "Failed to fetch sm model while file input");
@@ -197,12 +189,12 @@ ErrCode SmMLImportWrapper::Import(SfxMedium& rMedium)
if (!bEmbedded)
{
if (bOASIS)
- nWarn = ReadThroughComponentS(rMedium.GetStorage(), xModelComp, u"meta.xml",
- xContext, xInfoSet,
+ nWarn = ReadThroughComponentS(rMedium.GetStorage(), m_xModel, u"meta.xml", xContext,
+ xInfoSet,
u"com.sun.star.comp.Math.MLOasisMetaImporter", 6);
else
nWarn
- = ReadThroughComponentS(rMedium.GetStorage(), xModelComp, u"meta.xml", xContext,
+ = ReadThroughComponentS(rMedium.GetStorage(), m_xModel, u"meta.xml", xContext,
xInfoSet, u"com.sun.star.comp.Math.XMLMetaImporter", 5);
}
@@ -222,12 +214,12 @@ ErrCode SmMLImportWrapper::Import(SfxMedium& rMedium)
// Read settings
// read a component from storage
if (bOASIS)
- nWarn = ReadThroughComponentS(rMedium.GetStorage(), xModelComp, u"settings.xml",
- xContext, xInfoSet,
+ nWarn = ReadThroughComponentS(rMedium.GetStorage(), m_xModel, u"settings.xml", xContext,
+ xInfoSet,
u"com.sun.star.comp.Math.MLOasisSettingsImporter", 6);
else
nWarn
- = ReadThroughComponentS(rMedium.GetStorage(), xModelComp, u"settings.xml", xContext,
+ = ReadThroughComponentS(rMedium.GetStorage(), m_xModel, u"settings.xml", xContext,
xInfoSet, u"com.sun.star.comp.Math.XMLSettingsImporter", 5);
// Check if successful
@@ -246,13 +238,11 @@ ErrCode SmMLImportWrapper::Import(SfxMedium& rMedium)
// Read document
// read a component from storage
if (m_pDocShell->GetSmSyntaxVersion() == 5)
- nWarn
- = ReadThroughComponentS(rMedium.GetStorage(), xModelComp, u"content.xml", xContext,
- xInfoSet, u"com.sun.star.comp.Math.XMLImporter", 5);
+ nWarn = ReadThroughComponentS(rMedium.GetStorage(), m_xModel, u"content.xml", xContext,
+ xInfoSet, u"com.sun.star.comp.Math.XMLImporter", 5);
else
- nWarn
- = ReadThroughComponentS(rMedium.GetStorage(), xModelComp, u"content.xml", xContext,
- xInfoSet, u"com.sun.star.comp.Math.MLImporter", 6);
+ nWarn = ReadThroughComponentS(rMedium.GetStorage(), m_xModel, u"content.xml", xContext,
+ xInfoSet, u"com.sun.star.comp.Math.MLImporter", 6);
// Check if successful
if (nWarn != ERRCODE_NONE)
{
@@ -281,10 +271,10 @@ ErrCode SmMLImportWrapper::Import(SfxMedium& rMedium)
// read a component from input stream
ErrCode nError = ERRCODE_NONE;
if (m_pDocShell->GetSmSyntaxVersion() == 5)
- nError = ReadThroughComponentIS(xInputStream, xModelComp, xContext, xInfoSet,
+ nError = ReadThroughComponentIS(xInputStream, m_xModel, xContext, xInfoSet,
u"com.sun.star.comp.Math.XMLImporter", false, 5);
else
- nError = ReadThroughComponentIS(xInputStream, xModelComp, xContext, xInfoSet,
+ nError = ReadThroughComponentIS(xInputStream, m_xModel, xContext, xInfoSet,
u"com.sun.star.comp.Math.MLImporter", false, 6);
// Finish
@@ -325,7 +315,7 @@ ErrCode SmMLImportWrapper::Import(std::u16string_view aSource)
}
// Get model via uno
- SmModel* pModel = comphelper::getFromUnoTunnel<SmModel>(m_xModel);
+ SmModel* pModel = m_xModel.get();
if (pModel == nullptr)
{
SAL_WARN("starmath", "Failed to fetch sm model while file input");
diff --git a/starmath/source/mathml/mathmlimport.cxx b/starmath/source/mathml/mathmlimport.cxx
index f31383d076ea..a33a4015846f 100644
--- a/starmath/source/mathml/mathmlimport.cxx
+++ b/starmath/source/mathml/mathmlimport.cxx
@@ -99,15 +99,13 @@ ErrCode SmXMLImportWrapper::Import(SfxMedium& rMedium)
uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
- //Make a model component from our SmModel
- uno::Reference<lang::XComponent> xModelComp = xModel;
- OSL_ENSURE(xModelComp.is(), "XMLReader::Read: got no model");
+ OSL_ENSURE(m_xModel.is(), "XMLReader::Read: got no model");
// try to get an XStatusIndicator from the Medium
uno::Reference<task::XStatusIndicator> xStatusIndicator;
bool bEmbedded = false;
- SmModel* pModel = comphelper::getFromUnoTunnel<SmModel>(xModel);
+ SmModel* pModel = m_xModel.get();
SmDocShell* pDocShell = pModel ? static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr;
if (pDocShell)
@@ -184,7 +182,7 @@ ErrCode SmXMLImportWrapper::Import(SfxMedium& rMedium)
xStatusIndicator->setValue(nSteps++);
auto nWarn
- = ReadThroughComponent(rMedium.GetStorage(), xModelComp, "meta.xml", xContext, xInfoSet,
+ = ReadThroughComponent(rMedium.GetStorage(), m_xModel, "meta.xml", xContext, xInfoSet,
(bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaImporter"
: "com.sun.star.comp.Math.XMLMetaImporter"),
m_bUseHTMLMLEntities);
@@ -194,7 +192,7 @@ ErrCode SmXMLImportWrapper::Import(SfxMedium& rMedium)
if (xStatusIndicator.is())
xStatusIndicator->setValue(nSteps++);
- nWarn = ReadThroughComponent(rMedium.GetStorage(), xModelComp, "settings.xml", xContext,
+ nWarn = ReadThroughComponent(rMedium.GetStorage(), m_xModel, "settings.xml", xContext,
xInfoSet,
(bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsImporter"
: "com.sun.star.comp.Math.XMLSettingsImporter"),
@@ -206,7 +204,7 @@ ErrCode SmXMLImportWrapper::Import(SfxMedium& rMedium)
xStatusIndicator->setValue(nSteps++);
nError = ReadThroughComponent(
- rMedium.GetStorage(), xModelComp, "content.xml", xContext, xInfoSet,
+ rMedium.GetStorage(), m_xModel, "content.xml", xContext, xInfoSet,
"com.sun.star.comp.Math.XMLImporter", m_bUseHTMLMLEntities);
}
else
@@ -223,7 +221,7 @@ ErrCode SmXMLImportWrapper::Import(SfxMedium& rMedium)
if (xStatusIndicator.is())
xStatusIndicator->setValue(nSteps++);
- nError = ReadThroughComponent(xInputStream, xModelComp, xContext, xInfoSet,
+ nError = ReadThroughComponent(xInputStream, m_xModel, xContext, xInfoSet,
"com.sun.star.comp.Math.XMLImporter", false,
m_bUseHTMLMLEntities);
}
@@ -435,7 +433,7 @@ void SmXMLImport::endDocument()
if (pTree && pTree->GetType() == SmNodeType::Table)
{
uno::Reference<frame::XModel> xModel = GetModel();
- SmModel* pModel = comphelper::getFromUnoTunnel<SmModel>(xModel);
+ SmModel* pModel = dynamic_cast<SmModel*>(xModel.get());
if (pModel)
{
@@ -2565,7 +2563,7 @@ void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps)
if (!xModel.is())
return;
- SmModel* pModel = comphelper::getFromUnoTunnel<SmModel>(xModel);
+ SmModel* pModel = dynamic_cast<SmModel*>(xModel.get());
if (!pModel)
return;