diff options
author | dante <dante19031999@gmail.com> | 2020-11-21 01:14:00 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-23 07:30:19 +0100 |
commit | d767d0c968d243a891999df5685e177d8777fe7c (patch) | |
tree | 9c6537a1afd365f593d352738bd9c0a5c7de959e /starmath | |
parent | 607935650fab97092c960df54830e20b4f6b93a7 (diff) |
clang-formated rest of the mathml files on starmath
Change-Id: I1aedf909f7371f259b122364368c157fd615ae06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106298
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/mathmlexport.cxx | 975 | ||||
-rw-r--r-- | starmath/source/mathmlexport.hxx | 123 | ||||
-rw-r--r-- | starmath/source/mathmlimport.cxx | 1333 | ||||
-rw-r--r-- | starmath/source/mathmlimport.hxx | 81 |
4 files changed, 1229 insertions, 1283 deletions
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index 0956269d1b40..b20c5acd935a 100644 --- a/starmath/source/mathmlexport.cxx +++ b/starmath/source/mathmlexport.cxx @@ -73,38 +73,35 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star; using namespace ::xmloff::token; -namespace { - -bool IsInPrivateUseArea( sal_Unicode cChar ) { return 0xE000 <= cChar && cChar <= 0xF8FF; } +namespace +{ +bool IsInPrivateUseArea(sal_Unicode cChar) { return 0xE000 <= cChar && cChar <= 0xF8FF; } -sal_Unicode ConvertMathToMathML( sal_Unicode cChar ) +sal_Unicode ConvertMathToMathML(sal_Unicode cChar) { sal_Unicode cRes = cChar; - if (IsInPrivateUseArea( cChar )) + if (IsInPrivateUseArea(cChar)) { - SAL_WARN("starmath", "Error: private use area characters should no longer be in use!" ); + SAL_WARN("starmath", "Error: private use area characters should no longer be in use!"); cRes = u'@'; // just some character that should easily be notice as odd in the context } return cRes; } - } -bool SmXMLExportWrapper::Export(SfxMedium &rMedium) +bool SmXMLExportWrapper::Export(SfxMedium& rMedium) { - bool bRet=true; + bool bRet = true; uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext()); //Get model - uno::Reference< lang::XComponent > xModelComp = xModel; + uno::Reference<lang::XComponent> xModelComp = xModel; bool bEmbedded = false; - SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); + SmModel* pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); - SmDocShell *pDocShell = pModel ? - static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr; - if ( pDocShell && - SfxObjectCreateMode::EMBEDDED == pDocShell->GetCreateMode() ) + SmDocShell* pDocShell = pModel ? static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr; + if (pDocShell && SfxObjectCreateMode::EMBEDDED == pDocShell->GetCreateMode()) bEmbedded = true; uno::Reference<task::XStatusIndicator> xStatusIndicator; @@ -112,14 +109,13 @@ bool SmXMLExportWrapper::Export(SfxMedium &rMedium) { if (pDocShell /*&& pDocShell->GetMedium()*/) { - OSL_ENSURE( pDocShell->GetMedium() == &rMedium, - "different SfxMedium found" ); + OSL_ENSURE(pDocShell->GetMedium() == &rMedium, "different SfxMedium found"); SfxItemSet* pSet = rMedium.GetItemSet(); if (pSet) { const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>( - pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) ); + pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL)); if (pItem) pItem->GetValue() >>= xStatusIndicator; } @@ -129,111 +125,97 @@ bool SmXMLExportWrapper::Export(SfxMedium &rMedium) if (xStatusIndicator.is()) { sal_Int32 nProgressRange = bFlat ? 1 : 3; - xStatusIndicator->start(SmResId(STR_STATSTR_WRITING), - nProgressRange); + xStatusIndicator->start(SmResId(STR_STATSTR_WRITING), nProgressRange); } } - // create XPropertySet with three properties for status indicator - comphelper::PropertyMapEntry aInfoMap[] = - { - { OUString("UsePrettyPrinting"), 0, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::MAYBEVOID, 0}, - { OUString("BaseURI"), 0, - ::cppu::UnoType<OUString>::get(), + comphelper::PropertyMapEntry aInfoMap[] + = { { OUString("UsePrettyPrinting"), 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString("StreamRelPath"), 0, - ::cppu::UnoType<OUString>::get(), + { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString("StreamName"), 0, - ::cppu::UnoType<OUString>::get(), + { OUString("StreamRelPath"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString(), 0, css::uno::Type(), 0, 0 } - }; - uno::Reference< beans::XPropertySet > xInfoSet( - comphelper::GenericPropertySet_CreateInstance( - new comphelper::PropertySetInfo( aInfoMap ) ) ); + { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { OUString(), 0, css::uno::Type(), 0, 0 } }; + uno::Reference<beans::XPropertySet> xInfoSet( + comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(aInfoMap))); SvtSaveOptions aSaveOpt; - bool bUsePrettyPrinting( bFlat || aSaveOpt.IsPrettyPrinting() ); - xInfoSet->setPropertyValue( "UsePrettyPrinting", Any(bUsePrettyPrinting) ); + bool bUsePrettyPrinting(bFlat || aSaveOpt.IsPrettyPrinting()); + xInfoSet->setPropertyValue("UsePrettyPrinting", Any(bUsePrettyPrinting)); // Set base URI - OUString sPropName( "BaseURI" ); - xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL( true ) ) ); + OUString sPropName("BaseURI"); + xInfoSet->setPropertyValue(sPropName, makeAny(rMedium.GetBaseURL(true))); - sal_Int32 nSteps=0; + sal_Int32 nSteps = 0; if (xStatusIndicator.is()) - xStatusIndicator->setValue(nSteps++); + xStatusIndicator->setValue(nSteps++); if (!bFlat) //Storage (Package) of Stream { - uno::Reference < embed::XStorage > xStg = rMedium.GetOutputStorage(); - bool bOASIS = ( SotStorage::GetVersion( xStg ) > SOFFICE_FILEFORMAT_60 ); + uno::Reference<embed::XStorage> xStg = rMedium.GetOutputStorage(); + bool bOASIS = (SotStorage::GetVersion(xStg) > SOFFICE_FILEFORMAT_60); // TODO/LATER: handle the case of embedded links gracefully - if ( bEmbedded ) //&& !pStg->IsRoot() ) + if (bEmbedded) //&& !pStg->IsRoot() ) { OUString aName; - if ( rMedium.GetItemSet() ) + if (rMedium.GetItemSet()) { const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>( - rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) ); - if ( pDocHierarchItem ) + rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME)); + if (pDocHierarchItem) aName = pDocHierarchItem->GetValue(); } - if ( !aName.isEmpty() ) + if (!aName.isEmpty()) { sPropName = "StreamRelPath"; - xInfoSet->setPropertyValue( sPropName, makeAny( aName ) ); + xInfoSet->setPropertyValue(sPropName, makeAny(aName)); } } - if ( !bEmbedded ) + if (!bEmbedded) { if (xStatusIndicator.is()) xStatusIndicator->setValue(nSteps++); - bRet = WriteThroughComponent( - xStg, xModelComp, "meta.xml", xContext, xInfoSet, - (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaExporter" - : "com.sun.star.comp.Math.XMLMetaExporter")); + bRet = WriteThroughComponent(xStg, xModelComp, "meta.xml", xContext, xInfoSet, + (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaExporter" + : "com.sun.star.comp.Math.XMLMetaExporter")); } - if ( bRet ) + if (bRet) { if (xStatusIndicator.is()) xStatusIndicator->setValue(nSteps++); - bRet = WriteThroughComponent( - xStg, xModelComp, "content.xml", xContext, xInfoSet, - "com.sun.star.comp.Math.XMLContentExporter"); + bRet = WriteThroughComponent(xStg, xModelComp, "content.xml", xContext, xInfoSet, + "com.sun.star.comp.Math.XMLContentExporter"); } - if ( bRet ) + if (bRet) { if (xStatusIndicator.is()) xStatusIndicator->setValue(nSteps++); - bRet = WriteThroughComponent( - xStg, xModelComp, "settings.xml", xContext, xInfoSet, - (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsExporter" - : "com.sun.star.comp.Math.XMLSettingsExporter") ); + bRet = WriteThroughComponent(xStg, xModelComp, "settings.xml", xContext, xInfoSet, + (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsExporter" + : "com.sun.star.comp.Math.XMLSettingsExporter")); } } else { - SvStream *pStream = rMedium.GetOutStream(); - uno::Reference<io::XOutputStream> xOut( - new utl::OOutputStreamWrapper(*pStream) ); + SvStream* pStream = rMedium.GetOutStream(); + uno::Reference<io::XOutputStream> xOut(new utl::OOutputStreamWrapper(*pStream)); if (xStatusIndicator.is()) xStatusIndicator->setValue(nSteps++); - bRet = WriteThroughComponent( - xOut, xModelComp, xContext, xInfoSet, - "com.sun.star.comp.Math.XMLContentExporter"); + bRet = WriteThroughComponent(xOut, xModelComp, xContext, xInfoSet, + "com.sun.star.comp.Math.XMLContentExporter"); } if (xStatusIndicator.is()) @@ -242,179 +224,183 @@ bool SmXMLExportWrapper::Export(SfxMedium &rMedium) return bRet; } - /// export through an XML exporter component (output stream version) -bool SmXMLExportWrapper::WriteThroughComponent( - const Reference<io::XOutputStream>& xOutputStream, - const Reference<XComponent>& xComponent, - Reference<uno::XComponentContext> const & rxContext, - Reference<beans::XPropertySet> const & rPropSet, - const char* pComponentName ) +bool SmXMLExportWrapper::WriteThroughComponent(const Reference<io::XOutputStream>& xOutputStream, + const Reference<XComponent>& xComponent, + Reference<uno::XComponentContext> const& rxContext, + Reference<beans::XPropertySet> const& rPropSet, + const char* pComponentName) { OSL_ENSURE(xOutputStream.is(), "I really need an output stream!"); OSL_ENSURE(xComponent.is(), "Need component!"); OSL_ENSURE(nullptr != pComponentName, "Need component name!"); // get component - Reference< xml::sax::XWriter > xSaxWriter = xml::sax::Writer::create(rxContext ); + Reference<xml::sax::XWriter> xSaxWriter = xml::sax::Writer::create(rxContext); // connect XML writer to output stream - xSaxWriter->setOutputStream( xOutputStream ); + xSaxWriter->setOutputStream(xOutputStream); // prepare arguments (prepend doc handler to given arguments) - Sequence<Any> aArgs( 2 ); + Sequence<Any> aArgs(2); aArgs[0] <<= xSaxWriter; aArgs[1] <<= rPropSet; // get filter component - Reference< document::XExporter > xExporter( - rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(OUString::createFromAscii(pComponentName), aArgs, rxContext), + Reference<document::XExporter> xExporter( + rxContext->getServiceManager()->createInstanceWithArgumentsAndContext( + OUString::createFromAscii(pComponentName), aArgs, rxContext), UNO_QUERY); - OSL_ENSURE( xExporter.is(), - "can't instantiate export filter component" ); - if ( !xExporter.is() ) + OSL_ENSURE(xExporter.is(), "can't instantiate export filter component"); + if (!xExporter.is()) return false; - // connect model and filter - xExporter->setSourceDocument( xComponent ); + xExporter->setSourceDocument(xComponent); // filter! - Reference < XFilter > xFilter( xExporter, UNO_QUERY ); - uno::Sequence< PropertyValue > aProps(0); - xFilter->filter( aProps ); + Reference<XFilter> xFilter(xExporter, UNO_QUERY); + uno::Sequence<PropertyValue> aProps(0); + xFilter->filter(aProps); auto pFilter = comphelper::getUnoTunnelImplementation<SmXMLExport>(xFilter); return pFilter == nullptr || pFilter->GetSuccess(); } - /// export through an XML exporter component (storage version) -bool SmXMLExportWrapper::WriteThroughComponent( - const Reference < embed::XStorage >& xStorage, - const Reference<XComponent>& xComponent, - const char* pStreamName, - Reference<uno::XComponentContext> const & rxContext, - Reference<beans::XPropertySet> const & rPropSet, - const char* pComponentName - ) +bool SmXMLExportWrapper::WriteThroughComponent(const Reference<embed::XStorage>& xStorage, + const Reference<XComponent>& xComponent, + const char* pStreamName, + Reference<uno::XComponentContext> const& rxContext, + Reference<beans::XPropertySet> const& rPropSet, + const char* pComponentName) { OSL_ENSURE(xStorage.is(), "Need storage!"); OSL_ENSURE(nullptr != pStreamName, "Need stream name!"); // open stream - Reference < io::XStream > xStream; + Reference<io::XStream> xStream; OUString sStreamName = OUString::createFromAscii(pStreamName); try { - xStream = xStorage->openStreamElement( sStreamName, - embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ); + xStream = xStorage->openStreamElement(sStreamName, embed::ElementModes::READWRITE + | embed::ElementModes::TRUNCATE); } - catch ( const uno::Exception& ) + catch (const uno::Exception&) { - DBG_UNHANDLED_EXCEPTION("starmath", "Can't create output stream in package" ); + DBG_UNHANDLED_EXCEPTION("starmath", "Can't create output stream in package"); return false; } - uno::Reference < beans::XPropertySet > xSet( xStream, uno::UNO_QUERY ); - xSet->setPropertyValue( "MediaType", Any(OUString( "text/xml" )) ); + uno::Reference<beans::XPropertySet> xSet(xStream, uno::UNO_QUERY); + xSet->setPropertyValue("MediaType", Any(OUString("text/xml"))); // all streams must be encrypted in encrypted document - xSet->setPropertyValue( "UseCommonStoragePasswordEncryption", Any(true) ); + xSet->setPropertyValue("UseCommonStoragePasswordEncryption", Any(true)); // set Base URL - if ( rPropSet.is() ) + if (rPropSet.is()) { - rPropSet->setPropertyValue( "StreamName", makeAny( sStreamName ) ); + rPropSet->setPropertyValue("StreamName", makeAny(sStreamName)); } // write the stuff - bool bRet = WriteThroughComponent( xStream->getOutputStream(), xComponent, rxContext, - rPropSet, pComponentName ); + bool bRet = WriteThroughComponent(xStream->getOutputStream(), xComponent, rxContext, rPropSet, + pComponentName); return bRet; } -SmXMLExport::SmXMLExport( - const css::uno::Reference< css::uno::XComponentContext >& rContext, - OUString const & implementationName, SvXMLExportFlags nExportFlags) - : SvXMLExport(rContext, implementationName, util::MeasureUnit::INCH, XML_MATH, - nExportFlags) +SmXMLExport::SmXMLExport(const css::uno::Reference<css::uno::XComponentContext>& rContext, + OUString const& implementationName, SvXMLExportFlags nExportFlags) + : SvXMLExport(rContext, implementationName, util::MeasureUnit::INCH, XML_MATH, nExportFlags) , pTree(nullptr) , bSuccess(false) { } -sal_Int64 SAL_CALL SmXMLExport::getSomething( - const uno::Sequence< sal_Int8 >& rId ) +sal_Int64 SAL_CALL SmXMLExport::getSomething(const uno::Sequence<sal_Int8>& rId) { - if ( isUnoTunnelId<SmXMLExport>(rId) ) - return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this)); + if (isUnoTunnelId<SmXMLExport>(rId)) + return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this)); - return SvXMLExport::getSomething( rId ); + return SvXMLExport::getSomething(rId); } namespace { - class theSmXMLExportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSmXMLExportUnoTunnelId> {}; +class theSmXMLExportUnoTunnelId : public rtl::Static<UnoTunnelIdInit, theSmXMLExportUnoTunnelId> +{ +}; } -const uno::Sequence< sal_Int8 > & SmXMLExport::getUnoTunnelId() throw() +const uno::Sequence<sal_Int8>& SmXMLExport::getUnoTunnelId() throw() { return theSmXMLExportUnoTunnelId::get().getSeq(); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -Math_XMLExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &) +Math_XMLExporter_get_implementation(css::uno::XComponentContext* context, + css::uno::Sequence<css::uno::Any> const&) { - return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLExporter", SvXMLExportFlags::OASIS|SvXMLExportFlags::ALL)); + return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLExporter", + SvXMLExportFlags::OASIS | SvXMLExportFlags::ALL)); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -Math_XMLMetaExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &) +Math_XMLMetaExporter_get_implementation(css::uno::XComponentContext* context, + css::uno::Sequence<css::uno::Any> const&) { - return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLMetaExporter", SvXMLExportFlags::META)); + return cppu::acquire( + new SmXMLExport(context, "com.sun.star.comp.Math.XMLMetaExporter", SvXMLExportFlags::META)); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -Math_XMLOasisMetaExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &) +Math_XMLOasisMetaExporter_get_implementation(css::uno::XComponentContext* context, + css::uno::Sequence<css::uno::Any> const&) { - return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLOasisMetaExporter", SvXMLExportFlags::OASIS|SvXMLExportFlags::META)); + return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLOasisMetaExporter", + SvXMLExportFlags::OASIS | SvXMLExportFlags::META)); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -Math_XMLSettingsExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &) +Math_XMLSettingsExporter_get_implementation(css::uno::XComponentContext* context, + css::uno::Sequence<css::uno::Any> const&) { - return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLSettingsExporter", SvXMLExportFlags::SETTINGS)); + return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLSettingsExporter", + SvXMLExportFlags::SETTINGS)); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -Math_XMLOasisSettingsExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &) +Math_XMLOasisSettingsExporter_get_implementation(css::uno::XComponentContext* context, + css::uno::Sequence<css::uno::Any> const&) { - return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLOasisSettingsExporter", SvXMLExportFlags::OASIS|SvXMLExportFlags::SETTINGS)); + return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLOasisSettingsExporter", + SvXMLExportFlags::OASIS | SvXMLExportFlags::SETTINGS)); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -Math_XMLContentExporter_get_implementation(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &) +Math_XMLContentExporter_get_implementation(css::uno::XComponentContext* context, + css::uno::Sequence<css::uno::Any> const&) { - return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLContentExporter", SvXMLExportFlags::OASIS|SvXMLExportFlags::CONTENT)); + return cppu::acquire(new SmXMLExport(context, "com.sun.star.comp.Math.XMLContentExporter", + SvXMLExportFlags::OASIS | SvXMLExportFlags::CONTENT)); } ErrCode SmXMLExport::exportDoc(enum XMLTokenEnum eClass) { - if ( !(getExportFlags() & SvXMLExportFlags::CONTENT) ) + if (!(getExportFlags() & SvXMLExportFlags::CONTENT)) { - SvXMLExport::exportDoc( eClass ); + SvXMLExport::exportDoc(eClass); } else { - uno::Reference <frame::XModel> xModel = GetModel(); - SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); + uno::Reference<frame::XModel> xModel = GetModel(); + SmModel* pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); if (pModel) { - SmDocShell *pDocShell = - static_cast<SmDocShell*>(pModel->GetObjectShell()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); pTree = pDocShell->GetFormulaTree(); aText = pDocShell->GetText(); } @@ -424,31 +410,30 @@ ErrCode SmXMLExport::exportDoc(enum XMLTokenEnum eClass) addChaffWhenEncryptedStorage(); /*Add xmlns line*/ - SvXMLAttributeList &rList = GetAttrList(); + SvXMLAttributeList& rList = GetAttrList(); // make use of a default namespace - ResetNamespaceMap(); // Math doesn't need namespaces from xmloff, since it now uses default namespaces (because that is common with current MathML usage in the web) - GetNamespaceMap_().Add( OUString(), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH ); + ResetNamespaceMap(); // Math doesn't need namespaces from xmloff, since it now uses default namespaces (because that is common with current MathML usage in the web) + GetNamespaceMap_().Add(OUString(), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH); rList.AddAttribute(GetNamespaceMap().GetAttrNameByKey(XML_NAMESPACE_MATH), - GetNamespaceMap().GetNameByKey( XML_NAMESPACE_MATH)); + GetNamespaceMap().GetNameByKey(XML_NAMESPACE_MATH)); //I think we need something like ImplExportEntities(); ExportContent_(); GetDocHandler()->endDocument(); } - bSuccess=true; + bSuccess = true; return ERRCODE_NONE; } void SmXMLExport::ExportContent_() { - uno::Reference <frame::XModel> xModel = GetModel(); - SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); - SmDocShell *pDocShell = pModel ? - static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr; - OSL_ENSURE( pDocShell, "doc shell missing" ); + uno::Reference<frame::XModel> xModel = GetModel(); + SmModel* pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); + SmDocShell* pDocShell = pModel ? static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr; + OSL_ENSURE(pDocShell, "doc shell missing"); if (pDocShell && !pDocShell->GetFormat().IsTextmode()) { @@ -462,8 +447,8 @@ void SmXMLExport::ExportContent_() if (!aText.isEmpty()) { - pSemantics.reset( new SvXMLElementExport(*this, XML_NAMESPACE_MATH, - XML_SEMANTICS, true, true) ); + pSemantics.reset( + new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_SEMANTICS, true, true)); } ExportNodes(pTree, 0); @@ -474,43 +459,40 @@ void SmXMLExport::ExportContent_() // Convert symbol names if (pDocShell) { - SmParser &rParser = pDocShell->GetParser(); + SmParser& rParser = pDocShell->GetParser(); bool bVal = rParser.IsExportSymbolNames(); - rParser.SetExportSymbolNames( true ); - auto pTmpTree = rParser.Parse( aText ); + rParser.SetExportSymbolNames(true); + auto pTmpTree = rParser.Parse(aText); aText = rParser.GetText(); pTmpTree.reset(); - rParser.SetExportSymbolNames( bVal ); + 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 ); + 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) +void SmXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps) { - uno::Reference <frame::XModel> xModel = GetModel(); - if ( !xModel.is() ) + uno::Reference<frame::XModel> xModel = GetModel(); + if (!xModel.is()) return; - SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); + SmModel* pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); - if ( !pModel ) + if (!pModel) return; - SmDocShell *pDocShell = - static_cast<SmDocShell*>(pModel->GetObjectShell()); - if ( !pDocShell ) + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + if (!pDocShell) return; - aProps.realloc( 4 ); - PropertyValue *pValue = aProps.getArray(); + aProps.realloc(4); + PropertyValue* pValue = aProps.getArray(); sal_Int32 nIndex = 0; - tools::Rectangle aRect( pDocShell->GetVisArea() ); + tools::Rectangle aRect(pDocShell->GetVisArea()); pValue[nIndex].Name = "ViewAreaTop"; pValue[nIndex++].Value <<= aRect.Top(); @@ -525,17 +507,17 @@ void SmXMLExport::GetViewSettings( Sequence < PropertyValue >& aProps) pValue[nIndex++].Value <<= aRect.GetHeight(); } -void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps) +void SmXMLExport::GetConfigurationSettings(Sequence<PropertyValue>& rProps) { - Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY ); - if ( !xProps.is() ) + Reference<XPropertySet> xProps(GetModel(), UNO_QUERY); + if (!xProps.is()) return; - Reference< XPropertySetInfo > xPropertySetInfo = xProps->getPropertySetInfo(); + Reference<XPropertySetInfo> xPropertySetInfo = xProps->getPropertySetInfo(); if (!xPropertySetInfo.is()) return; - Sequence< Property > aProps = xPropertySetInfo->getProperties(); + Sequence<Property> aProps = xPropertySetInfo->getProperties(); const sal_Int32 nCount = aProps.getLength(); if (!nCount) return; @@ -548,8 +530,7 @@ void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps) [bUsedSymbolsOnly, &xProps](Property& prop) { PropertyValue aRet; if (prop.Name != "Formula" && prop.Name != "BasicLibraries" - && prop.Name != "DialogLibraries" - && prop.Name != "RuntimeUID") + && prop.Name != "DialogLibraries" && prop.Name != "RuntimeUID") { aRet.Name = prop.Name; OUString aActualName(prop.Name); @@ -562,12 +543,9 @@ void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps) }); } -void SmXMLExport::ExportLine(const SmNode *pNode, int nLevel) -{ - ExportExpression(pNode, nLevel); -} +void SmXMLExport::ExportLine(const SmNode* pNode, int nLevel) { ExportExpression(pNode, nLevel); } -void SmXMLExport::ExportBinaryHorizontal(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportBinaryHorizontal(const SmNode* pNode, int nLevel) { TG nGroup = pNode->GetToken().nGroup; @@ -581,15 +559,15 @@ void SmXMLExport::ExportBinaryHorizontal(const SmNode *pNode, int nLevel) // a*b*c*d+e*f*g*h+i*j*k*l = a*b*c*d+e*f*g*h+i*j*k*l" // See https://www.libreoffice.org/bugzilla/show_bug.cgi?id=66081 - ::std::stack< const SmNode* > s; + ::std::stack<const SmNode*> s; s.push(pNode); while (!s.empty()) { - const SmNode *node = s.top(); + const SmNode* node = s.top(); s.pop(); if (node->GetType() != SmNodeType::BinHor || node->GetToken().nGroup != nGroup) { - ExportNodes(node, nLevel+1); + ExportNodes(node, nLevel + 1); continue; } const SmBinHorNode* binNode = static_cast<const SmBinHorNode*>(node); @@ -599,54 +577,53 @@ void SmXMLExport::ExportBinaryHorizontal(const SmNode *pNode, int nLevel) } } -void SmXMLExport::ExportUnaryHorizontal(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportUnaryHorizontal(const SmNode* pNode, int nLevel) { ExportExpression(pNode, nLevel); } -void SmXMLExport::ExportExpression(const SmNode *pNode, int nLevel, +void SmXMLExport::ExportExpression(const SmNode* pNode, int nLevel, bool bNoMrowContainer /*=false*/) { std::unique_ptr<SvXMLElementExport> pRow; size_t nSize = pNode->GetNumSubNodes(); // #i115443: nodes of type expression always need to be grouped with mrow statement - if (!bNoMrowContainer && - (nSize > 1 || pNode->GetType() == SmNodeType::Expression)) + if (!bNoMrowContainer && (nSize > 1 || pNode->GetType() == SmNodeType::Expression)) pRow.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW, true, true)); for (size_t i = 0; i < nSize; ++i) { - if (const SmNode *pTemp = pNode->GetSubNode(i)) - ExportNodes(pTemp, nLevel+1); + if (const SmNode* pTemp = pNode->GetSubNode(i)) + ExportNodes(pTemp, nLevel + 1); } } -void SmXMLExport::ExportBinaryVertical(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportBinaryVertical(const SmNode* pNode, int nLevel) { assert(pNode->GetNumSubNodes() == 3); - const SmNode *pNum = pNode->GetSubNode(0); - const SmNode *pDenom = pNode->GetSubNode(2); + const SmNode* pNum = pNode->GetSubNode(0); + const SmNode* pDenom = pNode->GetSubNode(2); if (pNum->GetType() == SmNodeType::Align && pNum->GetToken().eType != TALIGNC) { // A left or right alignment is specified on the numerator: // attach the corresponding numalign attribute. AddAttribute(XML_NAMESPACE_MATH, XML_NUMALIGN, - pNum->GetToken().eType == TALIGNL ? XML_LEFT : XML_RIGHT); + pNum->GetToken().eType == TALIGNL ? XML_LEFT : XML_RIGHT); } if (pDenom->GetType() == SmNodeType::Align && pDenom->GetToken().eType != TALIGNC) { // A left or right alignment is specified on the denominator: // attach the corresponding denomalign attribute. AddAttribute(XML_NAMESPACE_MATH, XML_DENOMALIGN, - pDenom->GetToken().eType == TALIGNL ? XML_LEFT : XML_RIGHT); + pDenom->GetToken().eType == TALIGNL ? XML_LEFT : XML_RIGHT); } SvXMLElementExport aFraction(*this, XML_NAMESPACE_MATH, XML_MFRAC, true, true); ExportNodes(pNum, nLevel); ExportNodes(pDenom, nLevel); } -void SmXMLExport::ExportBinaryDiagonal(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportBinaryDiagonal(const SmNode* pNode, int nLevel) { assert(pNode->GetNumSubNodes() == 3); @@ -655,8 +632,7 @@ void SmXMLExport::ExportBinaryDiagonal(const SmNode *pNode, int nLevel) // wideslash // export the node as <mfrac bevelled="true"> AddAttribute(XML_NAMESPACE_MATH, XML_BEVELLED, XML_TRUE); - SvXMLElementExport aFraction(*this, XML_NAMESPACE_MATH, XML_MFRAC, - true, true); + SvXMLElementExport aFraction(*this, XML_NAMESPACE_MATH, XML_MFRAC, true, true); ExportNodes(pNode->GetSubNode(0), nLevel); ExportNodes(pNode->GetSubNode(1), nLevel); } @@ -669,17 +645,16 @@ void SmXMLExport::ExportBinaryDiagonal(const SmNode *pNode, int nLevel) ExportNodes(pNode->GetSubNode(0), nLevel); { // Scoping for <mo> creation - SvXMLElementExport aMo(*this, XML_NAMESPACE_MATH, XML_MO, - true, true); - sal_Unicode const nArse[2] = {MS_BACKSLASH,0x00}; - GetDocHandler()->characters(nArse); + SvXMLElementExport aMo(*this, XML_NAMESPACE_MATH, XML_MO, true, true); + sal_Unicode const nArse[2] = { MS_BACKSLASH, 0x00 }; + GetDocHandler()->characters(nArse); } ExportNodes(pNode->GetSubNode(1), nLevel); } } -void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportTable(const SmNode* pNode, int nLevel) { std::unique_ptr<SvXMLElementExport> pTable; @@ -691,21 +666,21 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel) //table if (nSize >= 1) { - const SmNode *pLine = pNode->GetSubNode(nSize-1); - if (pLine->GetType() == SmNodeType::Line && pLine->GetNumSubNodes() == 1 && - pLine->GetSubNode(0) != nullptr && - pLine->GetSubNode(0)->GetToken().eType == TNEWLINE) + const SmNode* pLine = pNode->GetSubNode(nSize - 1); + if (pLine->GetType() == SmNodeType::Line && pLine->GetNumSubNodes() == 1 + && pLine->GetSubNode(0) != nullptr + && pLine->GetSubNode(0)->GetToken().eType == TNEWLINE) --nSize; } // try to avoid creating a mtable element when the formula consists only // of a single output line - if (nLevel || (nSize >1)) + if (nLevel || (nSize > 1)) pTable.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTABLE, true, true)); for (size_t i = 0; i < nSize; ++i) { - if (const SmNode *pTemp = pNode->GetSubNode(i)) + if (const SmNode* pTemp = pNode->GetSubNode(i)) { std::unique_ptr<SvXMLElementExport> pRow; std::unique_ptr<SvXMLElementExport> pCell; @@ -721,10 +696,9 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel) // stack{alignl ... ## alignr ... ## ...} eAlign = pTemp->GetToken().eType; } - else if (pTemp->GetType() == SmNodeType::Line && - pTemp->GetNumSubNodes() == 1 && - pTemp->GetSubNode(0) && - pTemp->GetSubNode(0)->GetType() == SmNodeType::Align) + else if (pTemp->GetType() == SmNodeType::Line && pTemp->GetNumSubNodes() == 1 + && pTemp->GetSubNode(0) + && pTemp->GetSubNode(0)->GetType() == SmNodeType::Align) { // For the Table() construction, the SmNodeType::Align node is a child // of an SmNodeType::Line node. @@ -736,18 +710,18 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel) // If a left or right alignment is specified on this line, // attach the corresponding columnalign attribute. AddAttribute(XML_NAMESPACE_MATH, XML_COLUMNALIGN, - eAlign == TALIGNL ? XML_LEFT : XML_RIGHT); + eAlign == TALIGNL ? XML_LEFT : XML_RIGHT); } pCell.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTD, true, true)); } - ExportNodes(pTemp, nLevel+1); + ExportNodes(pTemp, nLevel + 1); } } } -void SmXMLExport::ExportMath(const SmNode *pNode) +void SmXMLExport::ExportMath(const SmNode* pNode) { - const SmTextNode *pTemp = static_cast<const SmTextNode *>(pNode); + const SmTextNode* pTemp = static_cast<const SmTextNode*>(pNode); std::unique_ptr<SvXMLElementExport> pMath; if (pNode->GetType() == SmNodeType::Math || pNode->GetType() == SmNodeType::GlyphSpecial) @@ -776,17 +750,17 @@ void SmXMLExport::ExportMath(const SmNode *pNode) pMath.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI, true, false)); } sal_Unicode nArse = pTemp->GetText()[0]; - sal_Unicode cTmp = ConvertMathToMathML( nArse ); + sal_Unicode cTmp = ConvertMathToMathML(nArse); if (cTmp != 0) nArse = cTmp; - OSL_ENSURE(nArse != 0xffff,"Non existent symbol"); + OSL_ENSURE(nArse != 0xffff, "Non existent symbol"); GetDocHandler()->characters(OUString(nArse)); } -void SmXMLExport::ExportText(const SmNode *pNode) +void SmXMLExport::ExportText(const SmNode* pNode) { std::unique_ptr<SvXMLElementExport> pText; - const SmTextNode *pTemp = static_cast<const SmTextNode *>(pNode); + const SmTextNode* pTemp = static_cast<const SmTextNode*>(pNode); switch (pNode->GetToken().eType) { default: @@ -794,7 +768,7 @@ void SmXMLExport::ExportText(const SmNode *pNode) { //Note that we change the fontstyle to italic for strings that //are italic and longer than a single character. - bool bIsItalic = IsItalic( pTemp->GetFont() ); + bool bIsItalic = IsItalic(pTemp->GetFont()); if ((pTemp->GetText().getLength() > 1) && bIsItalic) AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_ITALIC); else if ((pTemp->GetText().getLength() == 1) && !bIsItalic) @@ -808,13 +782,13 @@ void SmXMLExport::ExportText(const SmNode *pNode) case TTEXT: pText.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTEXT, true, false)); break; - } + } GetDocHandler()->characters(pTemp->GetText()); } -void SmXMLExport::ExportBlank(const SmNode *pNode) +void SmXMLExport::ExportBlank(const SmNode* pNode) { - const SmBlankNode *pTemp = static_cast<const SmBlankNode *>(pNode); + const SmBlankNode* pTemp = static_cast<const SmBlankNode*>(pNode); //!! exports an <mspace> element. Note that for example "~_~" is allowed in //!! Math (so it has no sense at all) but must not result in an empty //!! <msub> tag in MathML !! @@ -830,20 +804,19 @@ void SmXMLExport::ExportBlank(const SmNode *pNode) AddAttribute(XML_NAMESPACE_MATH, XML_WIDTH, sStrBuf.makeStringAndClear()); } - SvXMLElementExport aTextExport(*this, XML_NAMESPACE_MATH, XML_MSPACE, - true, false); + SvXMLElementExport aTextExport(*this, XML_NAMESPACE_MATH, XML_MSPACE, true, false); - GetDocHandler()->characters( OUString() ); + GetDocHandler()->characters(OUString()); } -void SmXMLExport::ExportSubSupScript(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportSubSupScript(const SmNode* pNode, int nLevel) { - const SmNode *pSub = nullptr; - const SmNode *pSup = nullptr; - const SmNode *pCSub = nullptr; - const SmNode *pCSup = nullptr; - const SmNode *pLSub = nullptr; - const SmNode *pLSup = nullptr; + const SmNode* pSub = nullptr; + const SmNode* pSup = nullptr; + const SmNode* pCSub = nullptr; + const SmNode* pCSup = nullptr; + const SmNode* pLSub = nullptr; + const SmNode* pLSup = nullptr; std::unique_ptr<SvXMLElementExport> pThing2; //if we have prescripts at all then we must use the tensor notation @@ -851,51 +824,48 @@ void SmXMLExport::ExportSubSupScript(const SmNode *pNode, int nLevel) //This is one of those excellent locations where scope is vital to //arrange the construction and destruction of the element helper //classes correctly - pLSub = pNode->GetSubNode(LSUB+1); - pLSup = pNode->GetSubNode(LSUP+1); + pLSub = pNode->GetSubNode(LSUB + 1); + pLSup = pNode->GetSubNode(LSUP + 1); if (pLSub || pLSup) { - SvXMLElementExport aMultiScripts(*this, XML_NAMESPACE_MATH, - XML_MMULTISCRIPTS, true, true); + SvXMLElementExport aMultiScripts(*this, XML_NAMESPACE_MATH, XML_MMULTISCRIPTS, true, true); - - if (nullptr != (pCSub = pNode->GetSubNode(CSUB+1)) - && nullptr != (pCSup = pNode->GetSubNode(CSUP+1))) + if (nullptr != (pCSub = pNode->GetSubNode(CSUB + 1)) + && nullptr != (pCSup = pNode->GetSubNode(CSUP + 1))) { - pThing2.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, - XML_MUNDEROVER, true, true)); + pThing2.reset( + new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MUNDEROVER, true, true)); } - else if (nullptr != (pCSub = pNode->GetSubNode(CSUB+1))) + else if (nullptr != (pCSub = pNode->GetSubNode(CSUB + 1))) { - pThing2.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, - XML_MUNDER, true, true)); + pThing2.reset( + new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MUNDER, true, true)); } - else if (nullptr != (pCSup = pNode->GetSubNode(CSUP+1))) + else if (nullptr != (pCSup = pNode->GetSubNode(CSUP + 1))) { - pThing2.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, - XML_MOVER, true, true)); + pThing2.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MOVER, true, true)); } - ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term + ExportNodes(pNode->GetSubNode(0), nLevel + 1); //Main Term if (pCSub) - ExportNodes(pCSub, nLevel+1); + ExportNodes(pCSub, nLevel + 1); if (pCSup) - ExportNodes(pCSup, nLevel+1); + ExportNodes(pCSup, nLevel + 1); pThing2.reset(); - pSub = pNode->GetSubNode(RSUB+1); - pSup = pNode->GetSubNode(RSUP+1); + pSub = pNode->GetSubNode(RSUB + 1); + pSup = pNode->GetSubNode(RSUP + 1); if (pSub || pSup) { if (pSub) - ExportNodes(pSub, nLevel+1); + ExportNodes(pSub, nLevel + 1); else { SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE, true, true); } if (pSup) - ExportNodes(pSup, nLevel+1); + ExportNodes(pSup, nLevel + 1); else { SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE, true, true); @@ -904,84 +874,76 @@ void SmXMLExport::ExportSubSupScript(const SmNode *pNode, int nLevel) //Separator element between suffix and prefix sub/sup pairs { - SvXMLElementExport aPrescripts(*this, XML_NAMESPACE_MATH, - XML_MPRESCRIPTS, true, true); + SvXMLElementExport aPrescripts(*this, XML_NAMESPACE_MATH, XML_MPRESCRIPTS, true, true); } if (pLSub) - ExportNodes(pLSub, nLevel+1); + ExportNodes(pLSub, nLevel + 1); else { - SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE, - true, true); - + SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE, true, true); } if (pLSup) - ExportNodes(pLSup, nLevel+1); + ExportNodes(pLSup, nLevel + 1); else { - SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE, - true, true); - + SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE, true, true); } } else { std::unique_ptr<SvXMLElementExport> pThing; - if (nullptr != (pSub = pNode->GetSubNode(RSUB+1)) && - nullptr != (pSup = pNode->GetSubNode(RSUP+1))) + if (nullptr != (pSub = pNode->GetSubNode(RSUB + 1)) + && nullptr != (pSup = pNode->GetSubNode(RSUP + 1))) { - pThing.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, - XML_MSUBSUP, true, true)); + pThing.reset( + new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUBSUP, true, true)); } - else if (nullptr != (pSub = pNode->GetSubNode(RSUB+1))) + else if (nullptr != (pSub = pNode->GetSubNode(RSUB + 1))) { - pThing.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUB, - true, true)); + pThing.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUB, true, true)); } - else if (nullptr != (pSup = pNode->GetSubNode(RSUP+1))) + else if (nullptr != (pSup = pNode->GetSubNode(RSUP + 1))) { - pThing.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUP, - true, true)); + pThing.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUP, true, true)); } - if (nullptr != (pCSub = pNode->GetSubNode(CSUB+1)) - && nullptr != (pCSup=pNode->GetSubNode(CSUP+1))) + if (nullptr != (pCSub = pNode->GetSubNode(CSUB + 1)) + && nullptr != (pCSup = pNode->GetSubNode(CSUP + 1))) { - pThing2.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, - XML_MUNDEROVER, true, true)); + pThing2.reset( + new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MUNDEROVER, true, true)); } - else if (nullptr != (pCSub = pNode->GetSubNode(CSUB+1))) + else if (nullptr != (pCSub = pNode->GetSubNode(CSUB + 1))) { - pThing2.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, - XML_MUNDER, true, true)); + pThing2.reset( + new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MUNDER, true, true)); } - else if (nullptr != (pCSup = pNode->GetSubNode(CSUP+1))) + else if (nullptr != (pCSup = pNode->GetSubNode(CSUP + 1))) { - pThing2.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, - XML_MOVER, true, true)); + pThing2.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MOVER, true, true)); } - ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term + ExportNodes(pNode->GetSubNode(0), nLevel + 1); //Main Term if (pCSub) - ExportNodes(pCSub, nLevel+1); + ExportNodes(pCSub, nLevel + 1); if (pCSup) - ExportNodes(pCSup, nLevel+1); + ExportNodes(pCSup, nLevel + 1); pThing2.reset(); if (pSub) - ExportNodes(pSub, nLevel+1); + ExportNodes(pSub, nLevel + 1); if (pSup) - ExportNodes(pSup, nLevel+1); + ExportNodes(pSup, nLevel + 1); pThing.reset(); } } -void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportBrace(const SmNode* pNode, int nLevel) { - const SmNode *pTemp; - const SmNode *pLeft=pNode->GetSubNode(0); - const SmNode *pRight=pNode->GetSubNode(2); + const SmNode* pTemp; + const SmNode* pLeft = pNode->GetSubNode(0); + const SmNode* pRight = pNode->GetSubNode(2); // This used to generate <mfenced> or <mrow>+<mo> elements according to // the stretchiness of fences. The MathML recommendation defines an @@ -992,8 +954,7 @@ void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel) // See #fdo 66282. // <mrow> - SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW, - true, true); + SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW, true, true); // <mo fence="true"> opening-fence </mo> if (pLeft && (pLeft->GetToken().eType != TNONE)) @@ -1004,15 +965,14 @@ void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel) AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE); else AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE); - ExportNodes(pLeft, nLevel+1); + ExportNodes(pLeft, nLevel + 1); } if (nullptr != (pTemp = pNode->GetSubNode(1))) { // <mrow> - SvXMLElementExport aRowExport(*this, XML_NAMESPACE_MATH, XML_MROW, - true, true); - ExportNodes(pTemp, nLevel+1); + SvXMLElementExport aRowExport(*this, XML_NAMESPACE_MATH, XML_MROW, true, true); + ExportNodes(pTemp, nLevel + 1); // </mrow> } @@ -1025,120 +985,108 @@ void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel) AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE); else AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE); - ExportNodes(pRight, nLevel+1); + ExportNodes(pRight, nLevel + 1); } // </mrow> } -void SmXMLExport::ExportRoot(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportRoot(const SmNode* pNode, int nLevel) { if (pNode->GetSubNode(0)) { - SvXMLElementExport aRoot(*this, XML_NAMESPACE_MATH, XML_MROOT, true, - true); - ExportNodes(pNode->GetSubNode(2), nLevel+1); - ExportNodes(pNode->GetSubNode(0), nLevel+1); + SvXMLElementExport aRoot(*this, XML_NAMESPACE_MATH, XML_MROOT, true, true); + ExportNodes(pNode->GetSubNode(2), nLevel + 1); + ExportNodes(pNode->GetSubNode(0), nLevel + 1); } else { - SvXMLElementExport aSqrt(*this, XML_NAMESPACE_MATH, XML_MSQRT, true, - true); - ExportNodes(pNode->GetSubNode(2), nLevel+1); + SvXMLElementExport aSqrt(*this, XML_NAMESPACE_MATH, XML_MSQRT, true, true); + ExportNodes(pNode->GetSubNode(2), nLevel + 1); } } -void SmXMLExport::ExportOperator(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportOperator(const SmNode* pNode, int nLevel) { /*we need to either use content or font and size attributes *here*/ - SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW, - true, true); - ExportNodes(pNode->GetSubNode(0), nLevel+1); - ExportNodes(pNode->GetSubNode(1), nLevel+1); + SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW, true, true); + ExportNodes(pNode->GetSubNode(0), nLevel + 1); + ExportNodes(pNode->GetSubNode(1), nLevel + 1); } -void SmXMLExport::ExportAttributes(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportAttributes(const SmNode* pNode, int nLevel) { std::unique_ptr<SvXMLElementExport> pElement; if (pNode->GetToken().eType == TUNDERLINE) { - AddAttribute(XML_NAMESPACE_MATH, XML_ACCENTUNDER, - XML_TRUE); - pElement.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MUNDER, - true, true)); + AddAttribute(XML_NAMESPACE_MATH, XML_ACCENTUNDER, XML_TRUE); + pElement.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MUNDER, true, true)); } else if (pNode->GetToken().eType == TOVERSTRIKE) { // export as <menclose notation="horizontalstrike"> AddAttribute(XML_NAMESPACE_MATH, XML_NOTATION, XML_HORIZONTALSTRIKE); - pElement.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, - XML_MENCLOSE, true, true)); + pElement.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MENCLOSE, true, true)); } else { - AddAttribute(XML_NAMESPACE_MATH, XML_ACCENT, - XML_TRUE); - pElement.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MOVER, - true, true)); + AddAttribute(XML_NAMESPACE_MATH, XML_ACCENT, XML_TRUE); + pElement.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MOVER, true, true)); } - ExportNodes(pNode->GetSubNode(1), nLevel+1); + ExportNodes(pNode->GetSubNode(1), nLevel + 1); switch (pNode->GetToken().eType) { case TOVERLINE: - { + { //proper entity support required - SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, - true, true); - sal_Unicode const nArse[2] = {0xAF,0x00}; + SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, true, true); + sal_Unicode const nArse[2] = { 0xAF, 0x00 }; GetDocHandler()->characters(nArse); - } - break; + } + break; case TUNDERLINE: - { + { //proper entity support required - SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, - true, true); - sal_Unicode const nArse[2] = {0x0332,0x00}; + SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, true, true); + sal_Unicode const nArse[2] = { 0x0332, 0x00 }; GetDocHandler()->characters(nArse); - } - break; + } + break; case TOVERSTRIKE: break; case TWIDETILDE: case TWIDEHAT: case TWIDEVEC: case TWIDEHARPOON: - { + { // make these wide accents stretchy AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE); - ExportNodes(pNode->GetSubNode(0), nLevel+1); - } - break; + ExportNodes(pNode->GetSubNode(0), nLevel + 1); + } + break; default: - ExportNodes(pNode->GetSubNode(0), nLevel+1); + ExportNodes(pNode->GetSubNode(0), nLevel + 1); break; } } -static bool lcl_HasEffectOnMathvariant( const SmTokenType eType ) +static bool lcl_HasEffectOnMathvariant(const SmTokenType eType) { - return eType == TBOLD || eType == TNBOLD || - eType == TITALIC || eType == TNITALIC || - eType == TSANS || eType == TSERIF || eType == TFIXED; + return eType == TBOLD || eType == TNBOLD || eType == TITALIC || eType == TNITALIC + || eType == TSANS || eType == TSERIF || eType == TFIXED; } -void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportFont(const SmNode* pNode, int nLevel) { - // gather the mathvariant attribute relevant data from all // successively following SmFontNodes... - int nBold = -1; // for the following variables: -1 = yet undefined; 0 = false; 1 = true; - int nItalic = -1; // for the following variables: -1 = yet undefined; 0 = false; 1 = true; - int nSansSerifFixed = -1; + int nBold = -1; // for the following variables: -1 = yet undefined; 0 = false; 1 = true; + int nItalic = -1; // for the following variables: -1 = yet undefined; 0 = false; 1 = true; + int nSansSerifFixed = -1; SmTokenType eNodeType = TUNKNOWN; for (;;) @@ -1148,21 +1096,35 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel) break; switch (eNodeType) { - case TBOLD : nBold = 1; break; - case TNBOLD : nBold = 0; break; - case TITALIC : nItalic = 1; break; - case TNITALIC : nItalic = 0; break; - case TSANS : nSansSerifFixed = 0; break; - case TSERIF : nSansSerifFixed = 1; break; - case TFIXED : nSansSerifFixed = 2; break; + case TBOLD: + nBold = 1; + break; + case TNBOLD: + nBold = 0; + break; + case TITALIC: + nItalic = 1; + break; + case TNITALIC: + nItalic = 0; + break; + case TSANS: + nSansSerifFixed = 0; + break; + case TSERIF: + nSansSerifFixed = 1; + break; + case TFIXED: + nSansSerifFixed = 2; + break; default: SAL_WARN("starmath", "unexpected case"); } // According to the parser every node that is to be evaluated here // has a single non-zero subnode at index 1!! Thus we only need to check // that single node for follow-up nodes that have an effect on the attribute. - if (pNode->GetNumSubNodes() > 1 && pNode->GetSubNode(1) && - lcl_HasEffectOnMathvariant( pNode->GetSubNode(1)->GetToken().eType)) + if (pNode->GetNumSubNodes() > 1 && pNode->GetSubNode(1) + && lcl_HasEffectOnMathvariant(pNode->GetSubNode(1)->GetToken().eType)) { pNode = pNode->GetSubNode(1); } @@ -1184,7 +1146,7 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel) OUString sssStr = OUString::createFromAscii(aSmColorTokenTableEntry->cIdent); AddAttribute(XML_NAMESPACE_MATH, XML_MATHCOLOR, sssStr); } - break; + break; case TRGB: case TRGBA: case THEX: @@ -1200,59 +1162,57 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel) OUString ssStr(sStrBuf.makeStringAndClear()); AddAttribute(XML_NAMESPACE_MATH, XML_MATHCOLOR, ssStr); } - break; + break; case TSIZE: - { - const SmFontNode *pFontNode = static_cast<const SmFontNode *>(pNode); - const Fraction &aFrac = pFontNode->GetSizeParameter(); + { + const SmFontNode* pFontNode = static_cast<const SmFontNode*>(pNode); + const Fraction& aFrac = pFontNode->GetSizeParameter(); - OUStringBuffer sStrBuf; - switch(pFontNode->GetSizeType()) + OUStringBuffer sStrBuf; + switch (pFontNode->GetSizeType()) + { + case FontSizeType::MULTIPLY: + ::sax::Converter::convertDouble(sStrBuf, + static_cast<double>(aFrac * Fraction(100.00))); + sStrBuf.append('%'); + break; + case FontSizeType::DIVIDE: + ::sax::Converter::convertDouble(sStrBuf, + static_cast<double>(Fraction(100.00) / aFrac)); + sStrBuf.append('%'); + break; + case FontSizeType::ABSOLUT: + ::sax::Converter::convertDouble(sStrBuf, static_cast<double>(aFrac)); + sStrBuf.append(GetXMLToken(XML_UNIT_PT)); + break; + default: { - case FontSizeType::MULTIPLY: - ::sax::Converter::convertDouble(sStrBuf, - static_cast<double>(aFrac*Fraction(100.00))); - sStrBuf.append('%'); - break; - case FontSizeType::DIVIDE: - ::sax::Converter::convertDouble(sStrBuf, - static_cast<double>(Fraction(100.00)/aFrac)); - sStrBuf.append('%'); - break; - case FontSizeType::ABSOLUT: - ::sax::Converter::convertDouble(sStrBuf, - static_cast<double>(aFrac)); - sStrBuf.append( - GetXMLToken(XML_UNIT_PT)); - break; - default: - { - //The problem here is that the wheels fall off because - //font size is stored in 100th's of a mm not pts, and - //rounding errors take their toll on the original - //value specified in points. - - //Must fix StarMath to retain the original pt values - Fraction aTemp = Sm100th_mmToPts(pFontNode->GetFont().GetFontSize().Height()); - - if (pFontNode->GetSizeType() == FontSizeType::MINUS) - aTemp-=aFrac; - else - aTemp+=aFrac; - - double mytest = static_cast<double>(aTemp); - - mytest = ::rtl::math::round(mytest,1); - ::sax::Converter::convertDouble(sStrBuf,mytest); - sStrBuf.append(GetXMLToken(XML_UNIT_PT)); - } - break; - } + //The problem here is that the wheels fall off because + //font size is stored in 100th's of a mm not pts, and + //rounding errors take their toll on the original + //value specified in points. + + //Must fix StarMath to retain the original pt values + Fraction aTemp = Sm100th_mmToPts(pFontNode->GetFont().GetFontSize().Height()); + + if (pFontNode->GetSizeType() == FontSizeType::MINUS) + aTemp -= aFrac; + else + aTemp += aFrac; - OUString sStr(sStrBuf.makeStringAndClear()); - AddAttribute(XML_NAMESPACE_MATH, XML_MATHSIZE, sStr); + double mytest = static_cast<double>(aTemp); + + mytest = ::rtl::math::round(mytest, 1); + ::sax::Converter::convertDouble(sStrBuf, mytest); + sStrBuf.append(GetXMLToken(XML_UNIT_PT)); + } + break; } - break; + + OUString sStr(sStrBuf.makeStringAndClear()); + AddAttribute(XML_NAMESPACE_MATH, XML_MATHSIZE, sStr); + } + break; case TBOLD: case TITALIC: case TNBOLD: @@ -1260,57 +1220,55 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel) case TFIXED: case TSANS: case TSERIF: + { + // nBold: -1 = yet undefined; 0 = false; 1 = true; + // nItalic: -1 = yet undefined; 0 = false; 1 = true; + // nSansSerifFixed: -1 = undefined; 0 = sans; 1 = serif; 2 = fixed; + const char* pText = "normal"; + if (nSansSerifFixed == -1 || nSansSerifFixed == 1) { - // nBold: -1 = yet undefined; 0 = false; 1 = true; - // nItalic: -1 = yet undefined; 0 = false; 1 = true; - // nSansSerifFixed: -1 = undefined; 0 = sans; 1 = serif; 2 = fixed; - const char *pText = "normal"; - if (nSansSerifFixed == -1 || nSansSerifFixed == 1) - { - pText = "normal"; - if (nBold == 1 && nItalic != 1) - pText = "bold"; - else if (nBold != 1 && nItalic == 1) - pText = "italic"; - else if (nBold == 1 && nItalic == 1) - pText = "bold-italic"; - } - else if (nSansSerifFixed == 0) - { - pText = "sans-serif"; - if (nBold == 1 && nItalic != 1) - pText = "bold-sans-serif"; - else if (nBold != 1 && nItalic == 1) - pText = "sans-serif-italic"; - else if (nBold == 1 && nItalic == 1) - pText = "sans-serif-bold-italic"; - } - else if (nSansSerifFixed == 2) - pText = "monospace"; // no modifiers allowed for monospace ... - else - { - SAL_WARN("starmath", "unexpected case"); - } - AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, OUString::createFromAscii( pText )); + pText = "normal"; + if (nBold == 1 && nItalic != 1) + pText = "bold"; + else if (nBold != 1 && nItalic == 1) + pText = "italic"; + else if (nBold == 1 && nItalic == 1) + pText = "bold-italic"; } - break; + else if (nSansSerifFixed == 0) + { + pText = "sans-serif"; + if (nBold == 1 && nItalic != 1) + pText = "bold-sans-serif"; + else if (nBold != 1 && nItalic == 1) + pText = "sans-serif-italic"; + else if (nBold == 1 && nItalic == 1) + pText = "sans-serif-bold-italic"; + } + else if (nSansSerifFixed == 2) + pText = "monospace"; // no modifiers allowed for monospace ... + else + { + SAL_WARN("starmath", "unexpected case"); + } + AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, OUString::createFromAscii(pText)); + } + break; default: break; - } { // Wrap everything in an <mphantom> or <mstyle> element. These elements // are mrow-like, so ExportExpression doesn't need to add an explicit // <mrow> element. See #fdo 66283. SvXMLElementExport aElement(*this, XML_NAMESPACE_MATH, - pNode->GetToken().eType == TPHANTOM ? XML_MPHANTOM : XML_MSTYLE, - true, true); + pNode->GetToken().eType == TPHANTOM ? XML_MPHANTOM : XML_MSTYLE, + true, true); ExportExpression(pNode, nLevel, true); } } - -void SmXMLExport::ExportVerticalBrace(const SmVerticalBraceNode *pNode, int nLevel) +void SmXMLExport::ExportVerticalBrace(const SmVerticalBraceNode* pNode, int nLevel) { // "[body] overbrace [script]" @@ -1336,12 +1294,12 @@ void SmXMLExport::ExportVerticalBrace(const SmVerticalBraceNode *pNode, int nLev break; } - SvXMLElementExport aOver1(*this, XML_NAMESPACE_MATH,which, true, true); - {//Scoping + SvXMLElementExport aOver1(*this, XML_NAMESPACE_MATH, which, true, true); + { //Scoping // using accents will draw the over-/underbraces too close to the base // see http://www.w3.org/TR/MathML2/chapter3.html#id.3.4.5.2 // also XML_ACCENT is illegal with XML_MUNDER. Thus no XML_ACCENT attribute here! - SvXMLElementExport aOver2(*this, XML_NAMESPACE_MATH,which, true, true); + SvXMLElementExport aOver2(*this, XML_NAMESPACE_MATH, which, true, true); ExportNodes(pNode->Body(), nLevel); AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE); ExportNodes(pNode->Brace(), nLevel); @@ -1349,39 +1307,37 @@ void SmXMLExport::ExportVerticalBrace(const SmVerticalBraceNode *pNode, int nLev ExportNodes(pNode->Script(), nLevel); } -void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportMatrix(const SmNode* pNode, int nLevel) { SvXMLElementExport aTable(*this, XML_NAMESPACE_MATH, XML_MTABLE, true, true); - const SmMatrixNode *pMatrix = static_cast<const SmMatrixNode *>(pNode); + const SmMatrixNode* pMatrix = static_cast<const SmMatrixNode*>(pNode); size_t i = 0; for (sal_uInt16 y = 0; y < pMatrix->GetNumRows(); y++) { SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MTR, true, true); for (sal_uInt16 x = 0; x < pMatrix->GetNumCols(); x++) { - if (const SmNode *pTemp = pNode->GetSubNode(i++)) + if (const SmNode* pTemp = pNode->GetSubNode(i++)) { - if (pTemp->GetType() == SmNodeType::Align && - pTemp->GetToken().eType != TALIGNC) + if (pTemp->GetType() == SmNodeType::Align && pTemp->GetToken().eType != TALIGNC) { // A left or right alignment is specified on this cell, // attach the corresponding columnalign attribute. AddAttribute(XML_NAMESPACE_MATH, XML_COLUMNALIGN, - pTemp->GetToken().eType == TALIGNL ? - XML_LEFT : XML_RIGHT); + pTemp->GetToken().eType == TALIGNL ? XML_LEFT : XML_RIGHT); } SvXMLElementExport aCell(*this, XML_NAMESPACE_MATH, XML_MTD, true, true); - ExportNodes(pTemp, nLevel+1); + ExportNodes(pTemp, nLevel + 1); } } } } -void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel) +void SmXMLExport::ExportNodes(const SmNode* pNode, int nLevel) { if (!pNode) return; - switch(pNode->GetType()) + switch (pNode->GetType()) { case SmNodeType::Table: ExportTable(pNode, nLevel); @@ -1399,54 +1355,54 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel) break; case SmNodeType::GlyphSpecial: case SmNodeType::Math: + { + sal_Unicode cTmp = 0; + const SmTextNode* pTemp = static_cast<const SmTextNode*>(pNode); + if (!pTemp->GetText().isEmpty()) + cTmp = ConvertMathToMathML(pTemp->GetText()[0]); + if (cTmp == 0) { - sal_Unicode cTmp = 0; - const SmTextNode *pTemp = static_cast< const SmTextNode * >(pNode); - if (!pTemp->GetText().isEmpty()) - cTmp = ConvertMathToMathML( pTemp->GetText()[0] ); - if (cTmp == 0) + // no conversion to MathML implemented -> export it as text + // thus at least it will not vanish into nothing + ExportText(pNode); + } + else + { + switch (pNode->GetToken().eType) { - // no conversion to MathML implemented -> export it as text - // thus at least it will not vanish into nothing - ExportText(pNode); + case TINTD: + AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE); + break; + default: + break; } - else + //To fully handle generic MathML we need to implement the full + //operator dictionary, we will generate MathML with explicit + //stretchiness for now. + sal_Int16 nLength = GetAttrList().getLength(); + bool bAddStretch = true; + for (sal_Int16 i = 0; i < nLength; i++) { - switch (pNode->GetToken().eType) - { - case TINTD: - AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE); - break; - default: - break; - } - //To fully handle generic MathML we need to implement the full - //operator dictionary, we will generate MathML with explicit - //stretchiness for now. - sal_Int16 nLength = GetAttrList().getLength(); - bool bAddStretch=true; - for ( sal_Int16 i = 0; i < nLength; i++ ) - { - OUString sLocalName; - sal_uInt16 nPrefix = GetNamespaceMap().GetKeyByAttrName( - GetAttrList().getNameByIndex(i), &sLocalName ); - - if ( ( XML_NAMESPACE_MATH == nPrefix ) && - IsXMLToken(sLocalName, XML_STRETCHY) ) - { - bAddStretch = false; - break; - } - } - if (bAddStretch) + OUString sLocalName; + sal_uInt16 nPrefix = GetNamespaceMap().GetKeyByAttrName( + GetAttrList().getNameByIndex(i), &sLocalName); + + if ((XML_NAMESPACE_MATH == nPrefix) && IsXMLToken(sLocalName, XML_STRETCHY)) { - AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE); + bAddStretch = false; + break; } - ExportMath(pNode); } + if (bAddStretch) + { + AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE); + } + ExportMath(pNode); } - break; - case SmNodeType::Special: //SmNodeType::Special requires some sort of Entity preservation in the XML engine. + } + break; + case SmNodeType:: + Special: //SmNodeType::Special requires some sort of Entity preservation in the XML engine. case SmNodeType::MathIdent: case SmNodeType::Place: ExportMath(pNode); @@ -1482,7 +1438,7 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel) ExportFont(pNode, nLevel); break; case SmNodeType::VerticalBrace: - ExportVerticalBrace(static_cast<const SmVerticalBraceNode *>(pNode), nLevel); + ExportVerticalBrace(static_cast<const SmVerticalBraceNode*>(pNode), nLevel); break; case SmNodeType::Matrix: ExportMatrix(pNode, nLevel); @@ -1490,10 +1446,9 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel) case SmNodeType::Blank: ExportBlank(pNode); break; - default: + default: SAL_WARN("starmath", "Warning: failed to export a node?"); break; - } } diff --git a/starmath/source/mathmlexport.hxx b/starmath/source/mathmlexport.hxx index 376365842640..32afe9f9aff1 100644 --- a/starmath/source/mathmlexport.hxx +++ b/starmath/source/mathmlexport.hxx @@ -26,91 +26,94 @@ class SfxMedium; class SmNode; class SmVerticalBraceNode; -namespace com::sun::star { - namespace io { - class XOutputStream; } - namespace beans { - class XPropertySet; } +namespace com::sun::star +{ +namespace io +{ +class XOutputStream; +} +namespace beans +{ +class XPropertySet; +} } - class SmXMLExportWrapper { css::uno::Reference<css::frame::XModel> xModel; - bool bFlat; //set true for export to flat .mml, set false for - //export to a .sxm (or whatever) package + bool bFlat; //set true for export to flat .mml, set false for + //export to a .sxm (or whatever) package public: - explicit SmXMLExportWrapper(css::uno::Reference<css::frame::XModel> const &rRef) - : xModel(rRef), bFlat(true) {} - - bool Export(SfxMedium &rMedium); - void SetFlat(bool bIn) {bFlat = bIn;} - - static bool WriteThroughComponent( - const css::uno::Reference< css::io::XOutputStream >& xOutputStream, - const css::uno::Reference< css::lang::XComponent >& xComponent, - css::uno::Reference< css::uno::XComponentContext > const & rxContext, - css::uno::Reference< css::beans::XPropertySet > const & rPropSet, - const char* pComponentName ); + explicit SmXMLExportWrapper(css::uno::Reference<css::frame::XModel> const& rRef) + : xModel(rRef) + , bFlat(true) + { + } + + bool Export(SfxMedium& rMedium); + void SetFlat(bool bIn) { bFlat = bIn; } + + static bool + WriteThroughComponent(const css::uno::Reference<css::io::XOutputStream>& xOutputStream, + const css::uno::Reference<css::lang::XComponent>& xComponent, + css::uno::Reference<css::uno::XComponentContext> const& rxContext, + css::uno::Reference<css::beans::XPropertySet> const& rPropSet, + const char* pComponentName); static bool WriteThroughComponent( - const css::uno::Reference< css::embed::XStorage >& xStor, - const css::uno::Reference< css::lang::XComponent >& xComponent, - const char* pStreamName, - css::uno::Reference< css::uno::XComponentContext > const & rxContext, - css::uno::Reference< css::beans::XPropertySet > const & rPropSet, - const char* pComponentName ); + const css::uno::Reference<css::embed::XStorage>& xStor, + const css::uno::Reference<css::lang::XComponent>& xComponent, const char* pStreamName, + css::uno::Reference<css::uno::XComponentContext> const& rxContext, + css::uno::Reference<css::beans::XPropertySet> const& rPropSet, const char* pComponentName); }; - class SmXMLExport final : public SvXMLExport { - const SmNode * pTree; - OUString aText; - bool bSuccess; - - void ExportNodes(const SmNode *pNode, int nLevel); - void ExportTable(const SmNode *pNode, int nLevel); - void ExportLine(const SmNode *pNode, int nLevel); - void ExportExpression(const SmNode *pNode, int nLevel, - bool bNoMrowContainer = false); - void ExportText(const SmNode *pNode); - void ExportMath(const SmNode *pNode); - void ExportBinaryHorizontal(const SmNode *pNode, int nLevel); - void ExportUnaryHorizontal(const SmNode *pNode, int nLevel); - void ExportBrace(const SmNode *pNode, int nLevel); - void ExportBinaryVertical(const SmNode *pNode, int nLevel); - void ExportBinaryDiagonal(const SmNode *pNode, int nLevel); - void ExportSubSupScript(const SmNode *pNode, int nLevel); - void ExportRoot(const SmNode *pNode, int nLevel); - void ExportOperator(const SmNode *pNode, int nLevel); - void ExportAttributes(const SmNode *pNode, int nLevel); - void ExportFont(const SmNode *pNode, int nLevel); - void ExportVerticalBrace(const SmVerticalBraceNode *pNode, int nLevel); - void ExportMatrix(const SmNode *pNode, int nLevel); - void ExportBlank(const SmNode *pNode); + const SmNode* pTree; + OUString aText; + bool bSuccess; + + void ExportNodes(const SmNode* pNode, int nLevel); + void ExportTable(const SmNode* pNode, int nLevel); + void ExportLine(const SmNode* pNode, int nLevel); + void ExportExpression(const SmNode* pNode, int nLevel, bool bNoMrowContainer = false); + void ExportText(const SmNode* pNode); + void ExportMath(const SmNode* pNode); + void ExportBinaryHorizontal(const SmNode* pNode, int nLevel); + void ExportUnaryHorizontal(const SmNode* pNode, int nLevel); + void ExportBrace(const SmNode* pNode, int nLevel); + void ExportBinaryVertical(const SmNode* pNode, int nLevel); + void ExportBinaryDiagonal(const SmNode* pNode, int nLevel); + void ExportSubSupScript(const SmNode* pNode, int nLevel); + void ExportRoot(const SmNode* pNode, int nLevel); + void ExportOperator(const SmNode* pNode, int nLevel); + void ExportAttributes(const SmNode* pNode, int nLevel); + void ExportFont(const SmNode* pNode, int nLevel); + void ExportVerticalBrace(const SmVerticalBraceNode* pNode, int nLevel); + void ExportMatrix(const SmNode* pNode, int nLevel); + void ExportBlank(const SmNode* pNode); public: - SmXMLExport( - const css::uno::Reference< css::uno::XComponentContext >& rContext, - OUString const & implementationName, SvXMLExportFlags nExportFlags); + SmXMLExport(const css::uno::Reference<css::uno::XComponentContext>& rContext, + OUString const& implementationName, SvXMLExportFlags nExportFlags); // XUnoTunnel - sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; - static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw(); + sal_Int64 SAL_CALL getSomething(const css::uno::Sequence<sal_Int8>& rId) override; + static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() throw(); void ExportAutoStyles_() override {} void ExportMasterStyles_() override {} void ExportContent_() override; - ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_TOKEN_INVALID) override; + ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum eClass + = ::xmloff::token::XML_TOKEN_INVALID) override; virtual void GetViewSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps) override; - virtual void GetConfigurationSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps) override; + virtual void + GetConfigurationSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps) override; - bool GetSuccess() const {return bSuccess;} + bool GetSuccess() const { return bSuccess; } }; - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index 543a8d02fcb2..9db1a3c4b4ed 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - /*todo: Change characters and tcharacters to accumulate the characters together into one string, xml parser hands them to us line by line rather than all in one go*/ @@ -82,8 +81,8 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star; using namespace ::xmloff::token; -namespace { - +namespace +{ std::unique_ptr<SmNode> popOrZero(SmNodeStack& rStack) { if (rStack.empty()) @@ -92,64 +91,54 @@ std::unique_ptr<SmNode> popOrZero(SmNodeStack& rStack) rStack.pop_front(); return pTmp; } - } -ErrCode SmXMLImportWrapper::Import(SfxMedium &rMedium) +ErrCode SmXMLImportWrapper::Import(SfxMedium& rMedium) { ErrCode nError = ERRCODE_SFX_DOLOADFAILED; - uno::Reference<uno::XComponentContext> xContext( comphelper::getProcessComponentContext() ); + 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" ); + uno::Reference<lang::XComponent> xModelComp = xModel; + OSL_ENSURE(xModelComp.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::getUnoTunnelImplementation<SmModel>(xModel); + SmModel* pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); - SmDocShell *pDocShell = pModel ? - static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr; + SmDocShell* pDocShell = pModel ? static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr; if (pDocShell) { - OSL_ENSURE( pDocShell->GetMedium() == &rMedium, - "different SfxMedium found" ); + OSL_ENSURE(pDocShell->GetMedium() == &rMedium, "different SfxMedium found"); SfxItemSet* pSet = rMedium.GetItemSet(); if (pSet) { - const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>( - pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) ); + const SfxUnoAnyItem* pItem + = static_cast<const SfxUnoAnyItem*>(pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL)); if (pItem) pItem->GetValue() >>= xStatusIndicator; } - if ( SfxObjectCreateMode::EMBEDDED == pDocShell->GetCreateMode() ) + if (SfxObjectCreateMode::EMBEDDED == pDocShell->GetCreateMode()) bEmbedded = true; } - comphelper::PropertyMapEntry aInfoMap[] = - { - { OUString("PrivateData"), 0, - cppu::UnoType<XInterface>::get(), + comphelper::PropertyMapEntry aInfoMap[] + = { { OUString("PrivateData"), 0, cppu::UnoType<XInterface>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString("BaseURI"), 0, - ::cppu::UnoType<OUString>::get(), + { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString("StreamRelPath"), 0, - ::cppu::UnoType<OUString>::get(), + { OUString("StreamRelPath"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString("StreamName"), 0, - ::cppu::UnoType<OUString>::get(), + { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString(), 0, css::uno::Type(), 0, 0 } - }; - uno::Reference< beans::XPropertySet > xInfoSet( - comphelper::GenericPropertySet_CreateInstance( - new comphelper::PropertySetInfo( aInfoMap ) ) ); + { OUString(), 0, css::uno::Type(), 0, 0 } }; + uno::Reference<beans::XPropertySet> xInfoSet( + comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(aInfoMap))); // Set base URI OUString const baseURI(rMedium.GetBaseURL()); @@ -158,8 +147,8 @@ ErrCode SmXMLImportWrapper::Import(SfxMedium &rMedium) SAL_INFO_IF(baseURI.isEmpty(), "starmath", "SmXMLImportWrapper: no base URL"); xInfoSet->setPropertyValue("BaseURI", makeAny(baseURI)); - sal_Int32 nSteps=3; - if ( !(rMedium.IsStorage())) + sal_Int32 nSteps = 3; + if (!(rMedium.IsStorage())) nSteps = 1; sal_Int32 nProgressRange(nSteps); @@ -168,59 +157,57 @@ ErrCode SmXMLImportWrapper::Import(SfxMedium &rMedium) xStatusIndicator->start(SvxResId(RID_SVXSTR_DOC_LOAD), nProgressRange); } - nSteps=0; + nSteps = 0; if (xStatusIndicator.is()) xStatusIndicator->setValue(nSteps++); - if ( rMedium.IsStorage()) + if (rMedium.IsStorage()) { // TODO/LATER: handle the case of embedded links gracefully - if ( bEmbedded ) // && !rMedium.GetStorage()->IsRoot() ) + if (bEmbedded) // && !rMedium.GetStorage()->IsRoot() ) { - OUString aName( "dummyObjName" ); - if ( rMedium.GetItemSet() ) + OUString aName("dummyObjName"); + if (rMedium.GetItemSet()) { const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>( - rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) ); - if ( pDocHierarchItem ) + rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME)); + if (pDocHierarchItem) aName = pDocHierarchItem->GetValue(); } - if ( !aName.isEmpty() ) + if (!aName.isEmpty()) { xInfoSet->setPropertyValue("StreamRelPath", makeAny(aName)); } } - bool bOASIS = ( SotStorage::GetVersion( rMedium.GetStorage() ) > SOFFICE_FILEFORMAT_60 ); + bool bOASIS = (SotStorage::GetVersion(rMedium.GetStorage()) > SOFFICE_FILEFORMAT_60); if (xStatusIndicator.is()) xStatusIndicator->setValue(nSteps++); - auto nWarn = ReadThroughComponent( - rMedium.GetStorage(), xModelComp, "meta.xml", - xContext, xInfoSet, - (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaImporter" - : "com.sun.star.comp.Math.XMLMetaImporter") ); + auto nWarn + = ReadThroughComponent(rMedium.GetStorage(), xModelComp, "meta.xml", xContext, xInfoSet, + (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaImporter" + : "com.sun.star.comp.Math.XMLMetaImporter")); - if ( nWarn != ERRCODE_IO_BROKENPACKAGE ) + if (nWarn != ERRCODE_IO_BROKENPACKAGE) { if (xStatusIndicator.is()) xStatusIndicator->setValue(nSteps++); - nWarn = ReadThroughComponent( - rMedium.GetStorage(), xModelComp, "settings.xml", - xContext, xInfoSet, - (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsImporter" - : "com.sun.star.comp.Math.XMLSettingsImporter" ) ); + nWarn = ReadThroughComponent(rMedium.GetStorage(), xModelComp, "settings.xml", xContext, + xInfoSet, + (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsImporter" + : "com.sun.star.comp.Math.XMLSettingsImporter")); - if ( nWarn != ERRCODE_IO_BROKENPACKAGE ) + if (nWarn != ERRCODE_IO_BROKENPACKAGE) { if (xStatusIndicator.is()) xStatusIndicator->setValue(nSteps++); - nError = ReadThroughComponent( - rMedium.GetStorage(), xModelComp, "content.xml", - xContext, xInfoSet, "com.sun.star.comp.Math.XMLImporter" ); + nError = ReadThroughComponent(rMedium.GetStorage(), xModelComp, "content.xml", + xContext, xInfoSet, + "com.sun.star.comp.Math.XMLImporter"); } else nError = ERRCODE_IO_BROKENPACKAGE; @@ -230,14 +217,14 @@ ErrCode SmXMLImportWrapper::Import(SfxMedium &rMedium) } else { - Reference<io::XInputStream> xInputStream = - new utl::OInputStreamWrapper(rMedium.GetInStream()); + Reference<io::XInputStream> xInputStream + = new utl::OInputStreamWrapper(rMedium.GetInStream()); if (xStatusIndicator.is()) xStatusIndicator->setValue(nSteps++); - nError = ReadThroughComponent( xInputStream, xModelComp, - xContext, xInfoSet, "com.sun.star.comp.Math.XMLImporter", false ); + nError = ReadThroughComponent(xInputStream, xModelComp, xContext, xInfoSet, + "com.sun.star.comp.Math.XMLImporter", false); } if (xStatusIndicator.is()) @@ -245,40 +232,37 @@ ErrCode SmXMLImportWrapper::Import(SfxMedium &rMedium) return nError; } - /// read a component (file + filter version) -ErrCode SmXMLImportWrapper::ReadThroughComponent( - const Reference<io::XInputStream>& xInputStream, - const Reference<XComponent>& xModelComponent, - Reference<uno::XComponentContext> const & rxContext, - Reference<beans::XPropertySet> const & rPropSet, - const char* pFilterName, - bool bEncrypted ) +ErrCode SmXMLImportWrapper::ReadThroughComponent(const Reference<io::XInputStream>& xInputStream, + const Reference<XComponent>& xModelComponent, + Reference<uno::XComponentContext> const& rxContext, + Reference<beans::XPropertySet> const& rPropSet, + const char* pFilterName, bool bEncrypted) { ErrCode nError = ERRCODE_SFX_DOLOADFAILED; OSL_ENSURE(xInputStream.is(), "input stream missing"); OSL_ENSURE(xModelComponent.is(), "document missing"); OSL_ENSURE(rxContext.is(), "factory missing"); - OSL_ENSURE(nullptr != pFilterName,"I need a service name for the component!"); + OSL_ENSURE(nullptr != pFilterName, "I need a service name for the component!"); // prepare ParserInputSource xml::sax::InputSource aParserInput; aParserInput.aInputStream = xInputStream; - Sequence<Any> aArgs( 1 ); + Sequence<Any> aArgs(1); aArgs[0] <<= rPropSet; // get filter - Reference< XInterface > xFilter = - rxContext->getServiceManager()->createInstanceWithArgumentsAndContext( + Reference<XInterface> xFilter + = rxContext->getServiceManager()->createInstanceWithArgumentsAndContext( OUString::createFromAscii(pFilterName), aArgs, rxContext); - SAL_WARN_IF( !xFilter, "starmath", "Can't instantiate filter component " << pFilterName ); - if ( !xFilter.is() ) + SAL_WARN_IF(!xFilter, "starmath", "Can't instantiate filter component " << pFilterName); + if (!xFilter.is()) return nError; // connect model and filter - Reference < XImporter > xImporter( xFilter, UNO_QUERY ); - xImporter->setTargetDocument( xModelComponent ); + Reference<XImporter> xImporter(xFilter, UNO_QUERY); + xImporter->setTargetDocument(xModelComponent); // finally, parser the stream try @@ -286,12 +270,13 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent( Reference<css::xml::sax::XFastParser> xFastParser(xFilter, UNO_QUERY); Reference<css::xml::sax::XFastDocumentHandler> xFastDocHandler(xFilter, UNO_QUERY); if (xFastParser) - xFastParser->parseStream( aParserInput ); + xFastParser->parseStream(aParserInput); else if (xFastDocHandler) { - Reference<css::xml::sax::XFastParser> xParser = css::xml::sax::FastParser::create(rxContext); + Reference<css::xml::sax::XFastParser> xParser + = css::xml::sax::FastParser::create(rxContext); xParser->setFastDocumentHandler(xFastDocHandler); - xParser->parseStream( aParserInput ); + xParser->parseStream(aParserInput); } else { @@ -299,11 +284,11 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent( assert(xDocHandler); Reference<css::xml::sax::XParser> xParser = css::xml::sax::Parser::create(rxContext); xParser->setDocumentHandler(xDocHandler); - xParser->parseStream( aParserInput ); + xParser->parseStream(aParserInput); } auto pFilter = comphelper::getUnoTunnelImplementation<SmXMLImport>(xFilter); - if ( pFilter && pFilter->GetSuccess() ) + if (pFilter && pFilter->GetSuccess()) nError = ERRCODE_NONE; } catch (const xml::sax::SAXParseException& r) @@ -313,29 +298,29 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent( xml::sax::SAXException aSaxEx = *static_cast<const xml::sax::SAXException*>(&r); bool bTryChild = true; - while( bTryChild ) + while (bTryChild) { xml::sax::SAXException aTmp; - if ( aSaxEx.WrappedException >>= aTmp ) + if (aSaxEx.WrappedException >>= aTmp) aSaxEx = aTmp; else bTryChild = false; } packages::zip::ZipIOException aBrokenPackage; - if ( aSaxEx.WrappedException >>= aBrokenPackage ) + if (aSaxEx.WrappedException >>= aBrokenPackage) return ERRCODE_IO_BROKENPACKAGE; - if ( bEncrypted ) + if (bEncrypted) nError = ERRCODE_SFX_WRONGPASSWORD; } catch (const xml::sax::SAXException& r) { packages::zip::ZipIOException aBrokenPackage; - if ( r.WrappedException >>= aBrokenPackage ) + if (r.WrappedException >>= aBrokenPackage) return ERRCODE_IO_BROKENPACKAGE; - if ( bEncrypted ) + if (bEncrypted) nError = ERRCODE_SFX_WRONGPASSWORD; } catch (const packages::zip::ZipIOException&) @@ -352,14 +337,12 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent( return nError; } - -ErrCode SmXMLImportWrapper::ReadThroughComponent( - const uno::Reference< embed::XStorage >& xStorage, - const Reference<XComponent>& xModelComponent, - const char* pStreamName, - Reference<uno::XComponentContext> const & rxContext, - Reference<beans::XPropertySet> const & rPropSet, - const char* pFilterName ) +ErrCode SmXMLImportWrapper::ReadThroughComponent(const uno::Reference<embed::XStorage>& xStorage, + const Reference<XComponent>& xModelComponent, + const char* pStreamName, + Reference<uno::XComponentContext> const& rxContext, + Reference<beans::XPropertySet> const& rPropSet, + const char* pFilterName) { OSL_ENSURE(xStorage.is(), "Need storage!"); OSL_ENSURE(nullptr != pStreamName, "Please, please, give me a name!"); @@ -370,56 +353,57 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent( // get input stream try { - uno::Reference < io::XStream > xEventsStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ ); + uno::Reference<io::XStream> xEventsStream + = xStorage->openStreamElement(sStreamName, embed::ElementModes::READ); // determine if stream is encrypted or not - uno::Reference < beans::XPropertySet > xProps( xEventsStream, uno::UNO_QUERY ); - Any aAny = xProps->getPropertyValue( "Encrypted" ); + uno::Reference<beans::XPropertySet> xProps(xEventsStream, uno::UNO_QUERY); + Any aAny = xProps->getPropertyValue("Encrypted"); bool bEncrypted = false; - if ( aAny.getValueType() == cppu::UnoType<bool>::get() ) + if (aAny.getValueType() == cppu::UnoType<bool>::get()) aAny >>= bEncrypted; // set Base URL - if ( rPropSet.is() ) + if (rPropSet.is()) { - rPropSet->setPropertyValue( "StreamName", makeAny( sStreamName ) ); + rPropSet->setPropertyValue("StreamName", makeAny(sStreamName)); } - - Reference < io::XInputStream > xStream = xEventsStream->getInputStream(); - return ReadThroughComponent( xStream, xModelComponent, rxContext, rPropSet, pFilterName, bEncrypted ); + Reference<io::XInputStream> xStream = xEventsStream->getInputStream(); + return ReadThroughComponent(xStream, xModelComponent, rxContext, rPropSet, pFilterName, + bEncrypted); } - catch ( packages::WrongPasswordException& ) + catch (packages::WrongPasswordException&) { return ERRCODE_SFX_WRONGPASSWORD; } - catch( packages::zip::ZipIOException& ) + catch (packages::zip::ZipIOException&) { return ERRCODE_IO_BROKENPACKAGE; } - catch ( uno::Exception& ) + catch (uno::Exception&) { } return ERRCODE_SFX_DOLOADFAILED; } - -SmXMLImport::SmXMLImport( - const css::uno::Reference< css::uno::XComponentContext >& rContext, - OUString const & implementationName, SvXMLImportFlags nImportFlags) -: SvXMLImport(rContext, implementationName, nImportFlags), - bSuccess(false), - nParseDepth(0) +SmXMLImport::SmXMLImport(const css::uno::Reference<css::uno::XComponentContext>& rContext, + OUString const& implementationName, SvXMLImportFlags nImportFlags) + : SvXMLImport(rContext, implementationName, nImportFlags) + , bSuccess(false) + , nParseDepth(0) { } namespace { - class theSmXMLImportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSmXMLImportUnoTunnelId> {}; +class theSmXMLImportUnoTunnelId : public rtl::Static<UnoTunnelIdInit, theSmXMLImportUnoTunnelId> +{ +}; } -const uno::Sequence< sal_Int8 > & SmXMLImport::getUnoTunnelId() throw() +const uno::Sequence<sal_Int8>& SmXMLImport::getUnoTunnelId() throw() { return theSmXMLImportUnoTunnelId::get().getSeq(); } @@ -448,13 +432,12 @@ Math_XMLOasisSettingsImporter_get_implementation(uno::XComponentContext* pCtx, SvXMLImportFlags::SETTINGS)); } -sal_Int64 SAL_CALL SmXMLImport::getSomething( - const uno::Sequence< sal_Int8 >&rId ) +sal_Int64 SAL_CALL SmXMLImport::getSomething(const uno::Sequence<sal_Int8>& rId) { - if ( isUnoTunnelId<SmXMLImport>(rId) ) - return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this)); + if (isUnoTunnelId<SmXMLImport>(rId)) + return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this)); - return SvXMLImport::getSomething( rId ); + return SvXMLImport::getSomething(rId); } void SmXMLImport::endDocument() @@ -463,32 +446,32 @@ void SmXMLImport::endDocument() std::unique_ptr<SmNode> pTree = popOrZero(aNodeStack); if (pTree && pTree->GetType() == SmNodeType::Table) { - uno::Reference <frame::XModel> xModel = GetModel(); - SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); + uno::Reference<frame::XModel> xModel = GetModel(); + SmModel* pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); if (pModel) { - SmDocShell *pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); auto pTreeTmp = pTree.get(); - pDocShell->SetFormulaTree(static_cast<SmTableNode *>(pTree.release())); - if (aText.isEmpty()) //If we picked up no annotation text + pDocShell->SetFormulaTree(static_cast<SmTableNode*>(pTree.release())); + if (aText.isEmpty()) //If we picked up no annotation text { // Get text from imported formula - SmNodeToTextVisitor tmpvisitor( pTreeTmp, aText ); + SmNodeToTextVisitor tmpvisitor(pTreeTmp, aText); } // Convert symbol names - SmParser &rParser = pDocShell->GetParser(); + SmParser& rParser = pDocShell->GetParser(); bool bVal = rParser.IsImportSymbolNames(); - rParser.SetImportSymbolNames( true ); - auto pTmpTree = rParser.Parse( aText ); + rParser.SetImportSymbolNames(true); + auto pTmpTree = rParser.Parse(aText); aText = rParser.GetText(); pTmpTree.reset(); - rParser.SetImportSymbolNames( bVal ); + rParser.SetImportSymbolNames(bVal); - pDocShell->SetText( aText ); + pDocShell->SetText(aText); } - OSL_ENSURE(pModel,"So there *was* a UNO problem after all"); + OSL_ENSURE(pModel, "So there *was* a UNO problem after all"); bSuccess = true; } @@ -496,43 +479,36 @@ void SmXMLImport::endDocument() SvXMLImport::endDocument(); } -namespace { - -class SmXMLImportContext: public SvXMLImportContext +namespace +{ +class SmXMLImportContext : public SvXMLImportContext { public: - SmXMLImportContext( SmXMLImport &rImport) + SmXMLImportContext(SmXMLImport& rImport) : SvXMLImportContext(rImport) { GetSmImport().IncParseDepth(); } - virtual ~SmXMLImportContext() override - { - GetSmImport().DecParseDepth(); - } + virtual ~SmXMLImportContext() override { GetSmImport().DecParseDepth(); } - SmXMLImport& GetSmImport() - { - return static_cast<SmXMLImport&>(GetImport()); - } + SmXMLImport& GetSmImport() { return static_cast<SmXMLImport&>(GetImport()); } - virtual void TCharacters(const OUString & /*rChars*/); - virtual void SAL_CALL characters(const OUString &rChars) override; - virtual void SAL_CALL startFastElement(sal_Int32 /*nElement*/, const css::uno::Reference<css::xml::sax::XFastAttributeList>& /*rAttrList*/) override + virtual void TCharacters(const OUString& /*rChars*/); + virtual void SAL_CALL characters(const OUString& rChars) override; + virtual void SAL_CALL startFastElement( + sal_Int32 /*nElement*/, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& /*rAttrList*/) override { if (GetSmImport().TooDeep()) throw std::range_error("too deep"); } }; - } -void SmXMLImportContext::TCharacters(const OUString & /*rChars*/) -{ -} +void SmXMLImportContext::TCharacters(const OUString& /*rChars*/) {} -void SmXMLImportContext::characters(const OUString &rChars) +void SmXMLImportContext::characters(const OUString& rChars) { /* Whitespace occurring within the content of token elements is "trimmed" @@ -541,13 +517,13 @@ void SmXMLImportContext::characters(const OUString &rChars) 1 or more whitespace characters is replaced with one blank character). */ //collapsing not done yet! - const OUString &rChars2 = rChars.trim(); + const OUString& rChars2 = rChars.trim(); if (!rChars2.isEmpty()) - TCharacters(rChars2/*.collapse()*/); + TCharacters(rChars2 /*.collapse()*/); } -namespace { - +namespace +{ struct SmXMLContext_Helper { sal_Int8 nIsBold; @@ -556,40 +532,37 @@ struct SmXMLContext_Helper OUString sFontFamily; OUString sColor; - SmXMLImportContext & rContext; + SmXMLImportContext& rContext; - explicit SmXMLContext_Helper(SmXMLImportContext &rImport) - : nIsBold( -1 ) - , nIsItalic( -1 ) - , nFontSize( 0.0 ) - , rContext( rImport ) - {} + explicit SmXMLContext_Helper(SmXMLImportContext& rImport) + : nIsBold(-1) + , nIsItalic(-1) + , nFontSize(0.0) + , rContext(rImport) + { + } bool IsFontNodeNeeded() const; - void RetrieveAttrs(const uno::Reference< xml::sax::XFastAttributeList > &xAttrList ); + void RetrieveAttrs(const uno::Reference<xml::sax::XFastAttributeList>& xAttrList); void ApplyAttrs(); }; - } bool SmXMLContext_Helper::IsFontNodeNeeded() const { - return nIsBold != -1 || - nIsItalic != -1 || - nFontSize != 0.0 || - !sFontFamily.isEmpty() || - !sColor.isEmpty(); + return nIsBold != -1 || nIsItalic != -1 || nFontSize != 0.0 || !sFontFamily.isEmpty() + || !sColor.isEmpty(); } -void SmXMLContext_Helper::RetrieveAttrs(const uno::Reference< - xml::sax::XFastAttributeList > & xAttrList ) +void SmXMLContext_Helper::RetrieveAttrs( + const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { bool bMvFound = false; - for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) + for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { OUString sValue = aIter.toString(); // sometimes they have namespace, sometimes not? - switch(aIter.getToken() & TOKEN_MASK) + switch (aIter.getToken() & TOKEN_MASK) { case XML_FONTWEIGHT: nIsBold = sal_Int8(sValue == GetXMLToken(XML_BOLD)); @@ -600,16 +573,16 @@ void SmXMLContext_Helper::RetrieveAttrs(const uno::Reference< case XML_FONTSIZE: case XML_MATHSIZE: ::sax::Converter::convertDouble(nFontSize, sValue); - rContext.GetSmImport().GetMM100UnitConverter(). - SetXMLMeasureUnit(util::MeasureUnit::POINT); + rContext.GetSmImport().GetMM100UnitConverter().SetXMLMeasureUnit( + util::MeasureUnit::POINT); if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT))) { if (-1 == sValue.indexOf('%')) - nFontSize=0.0; + nFontSize = 0.0; else { - rContext.GetSmImport().GetMM100UnitConverter(). - SetXMLMeasureUnit(util::MeasureUnit::PERCENT); + rContext.GetSmImport().GetMM100UnitConverter().SetXMLMeasureUnit( + util::MeasureUnit::PERCENT); } } break; @@ -644,7 +617,7 @@ void SmXMLContext_Helper::RetrieveAttrs(const uno::Reference< void SmXMLContext_Helper::ApplyAttrs() { - SmNodeStack &rNodeStack = rContext.GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = rContext.GetSmImport().GetNodeStack(); if (!IsFontNodeNeeded()) return; @@ -670,7 +643,7 @@ void SmXMLContext_Helper::ApplyAttrs() else aToken.eType = TNITALIC; std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken)); - pFontNode->SetSubNodes(nullptr,popOrZero(rNodeStack)); + pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack)); rNodeStack.push_front(std::move(pFontNode)); } if (nFontSize != 0.0) @@ -678,18 +651,16 @@ void SmXMLContext_Helper::ApplyAttrs() aToken.eType = TSIZE; std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken)); - if (util::MeasureUnit::PERCENT == rContext.GetSmImport() - .GetMM100UnitConverter().GetXMLMeasureUnit()) + if (util::MeasureUnit::PERCENT + == rContext.GetSmImport().GetMM100UnitConverter().GetXMLMeasureUnit()) { if (nFontSize < 100.00) - pFontNode->SetSizeParameter(Fraction(100.00/nFontSize), - FontSizeType::DIVIDE); + pFontNode->SetSizeParameter(Fraction(100.00 / nFontSize), FontSizeType::DIVIDE); else - pFontNode->SetSizeParameter(Fraction(nFontSize/100.00), - FontSizeType::MULTIPLY); + pFontNode->SetSizeParameter(Fraction(nFontSize / 100.00), FontSizeType::MULTIPLY); } else - pFontNode->SetSizeParameter(Fraction(nFontSize),FontSizeType::ABSOLUT); + pFontNode->SetSizeParameter(Fraction(nFontSize), FontSizeType::ABSOLUT); pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack)); rNodeStack.push_front(std::move(pFontNode)); @@ -697,10 +668,11 @@ void SmXMLContext_Helper::ApplyAttrs() if (!sColor.isEmpty()) { std::unique_ptr<SmColorTokenTableEntry> aSmColorTokenTableEntry; - aSmColorTokenTableEntry = starmathdatabase::Identify_ColorName_HTML( sColor ); - if( aSmColorTokenTableEntry->eType == TRGB ) - aSmColorTokenTableEntry = starmathdatabase::Identify_Color_Parser( sal_uInt32(aSmColorTokenTableEntry->cColor) ); - if( aSmColorTokenTableEntry->eType != TERROR ) + aSmColorTokenTableEntry = starmathdatabase::Identify_ColorName_HTML(sColor); + if (aSmColorTokenTableEntry->eType == TRGB) + aSmColorTokenTableEntry = starmathdatabase::Identify_Color_Parser( + sal_uInt32(aSmColorTokenTableEntry->cColor)); + if (aSmColorTokenTableEntry->eType != TERROR) { aToken = aSmColorTokenTableEntry; std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken)); @@ -728,8 +700,8 @@ void SmXMLContext_Helper::ApplyAttrs() } } -namespace { - +namespace +{ class SmXMLTokenAttrHelper { SmXMLImportContext& mrContext; @@ -741,20 +713,21 @@ public: : mrContext(rContext) , meMv(MathMLMathvariantValue::Normal) , mbMvFound(false) - {} + { + } void RetrieveAttrs(const uno::Reference<xml::sax::XFastAttributeList>& xAttrList); void ApplyAttrs(MathMLMathvariantValue eDefaultMv); }; - } -void SmXMLTokenAttrHelper::RetrieveAttrs(const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) +void SmXMLTokenAttrHelper::RetrieveAttrs( + const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { - for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) + for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { OUString sValue = aIter.toString(); - switch(aIter.getToken()) + switch (aIter.getToken()) { case XML_MATHVARIANT: if (!GetMathMLMathvariantValue(sValue, meMv)) @@ -770,12 +743,12 @@ void SmXMLTokenAttrHelper::RetrieveAttrs(const uno::Reference<xml::sax::XFastAtt void SmXMLTokenAttrHelper::ApplyAttrs(MathMLMathvariantValue eDefaultMv) { - assert( eDefaultMv == MathMLMathvariantValue::Normal || - eDefaultMv == MathMLMathvariantValue::Italic ); + assert(eDefaultMv == MathMLMathvariantValue::Normal + || eDefaultMv == MathMLMathvariantValue::Italic); std::vector<SmTokenType> vVariant; MathMLMathvariantValue eMv = mbMvFound ? meMv : eDefaultMv; - switch(eMv) + switch (eMv) { case MathMLMathvariantValue::Normal: vVariant.push_back(TNITALIC); @@ -835,7 +808,7 @@ void SmXMLTokenAttrHelper::ApplyAttrs(MathMLMathvariantValue eDefaultMv) } if (vVariant.empty()) return; - SmNodeStack &rNodeStack = mrContext.GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = mrContext.GetSmImport().GetNodeStack(); for (auto eType : vVariant) { SmToken aToken; @@ -848,21 +821,22 @@ void SmXMLTokenAttrHelper::ApplyAttrs(MathMLMathvariantValue eDefaultMv) } } -namespace { - +namespace +{ class SmXMLDocContext_Impl : public SmXMLImportContext { public: - SmXMLDocContext_Impl( SmXMLImport &rImport) - : SmXMLImportContext(rImport) {} + SmXMLDocContext_Impl(SmXMLImport& rImport) + : SmXMLImportContext(rImport) + { + } - virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( - sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) override; + virtual uno::Reference<xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - /*avert the gaze from the originator*/ class SmXMLRowContext_Impl : public SmXMLDocContext_Impl { @@ -870,16 +844,16 @@ protected: size_t nElementCount; public: - SmXMLRowContext_Impl(SmXMLImport &rImport) + SmXMLRowContext_Impl(SmXMLImport& rImport) : SmXMLDocContext_Impl(rImport) , nElementCount(GetSmImport().GetNodeStack().size()) { } - virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( - sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) override; + virtual uno::Reference<xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; - uno::Reference< xml::sax::XFastContextHandler > StrictCreateChildContext(sal_Int32 nElement); + uno::Reference<xml::sax::XFastContextHandler> StrictCreateChildContext(sal_Int32 nElement); virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; }; @@ -889,12 +863,13 @@ class SmXMLEncloseContext_Impl : public SmXMLRowContext_Impl public: // TODO/LATER: convert <menclose notation="horizontalstrike"> into // "overstrike{}" and extend the Math syntax to support more notations - SmXMLEncloseContext_Impl(SmXMLImport &rImport) - : SmXMLRowContext_Impl(rImport) {} + SmXMLEncloseContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } void SmXMLEncloseContext_Impl::endFastElement(sal_Int32 nElement) @@ -905,42 +880,45 @@ void SmXMLEncloseContext_Impl::endFastElement(sal_Int32 nElement) arguments */ if (GetSmImport().GetNodeStack().size() - nElementCount != 1) - SmXMLRowContext_Impl::endFastElement( nElement ); + SmXMLRowContext_Impl::endFastElement(nElement); } -namespace { - +namespace +{ class SmXMLFracContext_Impl : public SmXMLRowContext_Impl { public: // TODO/LATER: convert <mfrac bevelled="true"> into "wideslash{}{}" - SmXMLFracContext_Impl(SmXMLImport &rImport) - : SmXMLRowContext_Impl(rImport) {} + SmXMLFracContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - class SmXMLSqrtContext_Impl : public SmXMLRowContext_Impl { public: - SmXMLSqrtContext_Impl(SmXMLImport &rImport) - : SmXMLRowContext_Impl(rImport) {} + SmXMLSqrtContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - class SmXMLRootContext_Impl : public SmXMLRowContext_Impl { public: - SmXMLRootContext_Impl(SmXMLImport &rImport) - : SmXMLRowContext_Impl(rImport) {} + SmXMLRootContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - class SmXMLStyleContext_Impl : public SmXMLRowContext_Impl { protected: @@ -948,22 +926,24 @@ protected: public: /*Right now the style tag is completely ignored*/ - SmXMLStyleContext_Impl(SmXMLImport &rImport) : SmXMLRowContext_Impl(rImport), - aStyleHelper(*this) {} + SmXMLStyleContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + , aStyleHelper(*this) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; - void SAL_CALL startFastElement(sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList > &xAttrList ) override; + void SAL_CALL startFastElement( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; }; - } -void SmXMLStyleContext_Impl::startFastElement( sal_Int32 /*nElement*/, const uno::Reference< - xml::sax::XFastAttributeList > & xAttrList ) +void SmXMLStyleContext_Impl::startFastElement( + sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { aStyleHelper.RetrieveAttrs(xAttrList); } - void SmXMLStyleContext_Impl::endFastElement(sal_Int32 nElement) { /* @@ -971,24 +951,25 @@ void SmXMLStyleContext_Impl::endFastElement(sal_Int32 nElement) contents are treated as a single "inferred <mrow>" containing its arguments */ - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); if (rNodeStack.size() - nElementCount != 1) SmXMLRowContext_Impl::endFastElement(nElement); aStyleHelper.ApplyAttrs(); } -namespace { - +namespace +{ class SmXMLPaddedContext_Impl : public SmXMLRowContext_Impl { public: /*Right now the style tag is completely ignored*/ - SmXMLPaddedContext_Impl(SmXMLImport &rImport) - : SmXMLRowContext_Impl(rImport) {} + SmXMLPaddedContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } void SmXMLPaddedContext_Impl::endFastElement(sal_Int32 nElement) @@ -1002,18 +983,19 @@ void SmXMLPaddedContext_Impl::endFastElement(sal_Int32 nElement) SmXMLRowContext_Impl::endFastElement(nElement); } -namespace { - +namespace +{ class SmXMLPhantomContext_Impl : public SmXMLRowContext_Impl { public: /*Right now the style tag is completely ignored*/ - SmXMLPhantomContext_Impl(SmXMLImport &rImport) - : SmXMLRowContext_Impl(rImport) {} + SmXMLPhantomContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } void SmXMLPhantomContext_Impl::endFastElement(sal_Int32 nElement) @@ -1032,13 +1014,13 @@ void SmXMLPhantomContext_Impl::endFastElement(sal_Int32 nElement) aToken.eType = TPHANTOM; std::unique_ptr<SmFontNode> pPhantom(new SmFontNode(aToken)); - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); pPhantom->SetSubNodes(nullptr, popOrZero(rNodeStack)); rNodeStack.push_front(std::move(pPhantom)); } -namespace { - +namespace +{ class SmXMLFencedContext_Impl : public SmXMLRowContext_Impl { protected: @@ -1047,24 +1029,27 @@ protected: bool bIsStretchy; public: - SmXMLFencedContext_Impl(SmXMLImport &rImport) + SmXMLFencedContext_Impl(SmXMLImport& rImport) : SmXMLRowContext_Impl(rImport) - , cBegin('('), cEnd(')') - , bIsStretchy(false) {} + , cBegin('(') + , cEnd(')') + , bIsStretchy(false) + { + } - void SAL_CALL startFastElement(sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ) override; + void SAL_CALL startFastElement( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } -void SmXMLFencedContext_Impl::startFastElement(sal_Int32 /*nElement*/, const uno::Reference< - xml::sax::XFastAttributeList > & xAttrList ) +void SmXMLFencedContext_Impl::startFastElement( + sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { - for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) + for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { OUString sValue = aIter.toString(); - switch(aIter.getToken()) + switch (aIter.getToken()) { //temp, starmath cannot handle multichar brackets (I think) case XML_OPEN: @@ -1084,7 +1069,6 @@ void SmXMLFencedContext_Impl::startFastElement(sal_Int32 /*nElement*/, const uno } } - void SmXMLFencedContext_Impl::endFastElement(sal_Int32 /*nElement*/) { SmToken aToken; @@ -1093,17 +1077,23 @@ void SmXMLFencedContext_Impl::endFastElement(sal_Int32 /*nElement*/) aToken.nLevel = 5; std::unique_ptr<SmStructureNode> pSNode(new SmBraceNode(aToken)); - if( bIsStretchy ) aToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl( cBegin ); - else aToken = starmathdatabase::Identify_Prefix_SmXMLOperatorContext_Impl( cBegin ); - if( aToken.eType == TERROR ) aToken = SmToken( TLPARENT, MS_LPARENT, "(", TG::LBrace, 5 ); + if (bIsStretchy) + aToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl(cBegin); + else + aToken = starmathdatabase::Identify_Prefix_SmXMLOperatorContext_Impl(cBegin); + if (aToken.eType == TERROR) + aToken = SmToken(TLPARENT, MS_LPARENT, "(", TG::LBrace, 5); std::unique_ptr<SmNode> pLeft(new SmMathSymbolNode(aToken)); - if( bIsStretchy ) aToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl( cEnd ); - else aToken = starmathdatabase::Identify_Postfix_SmXMLOperatorContext_Impl( cEnd ); - if( aToken.eType == TERROR ) aToken = SmToken( TRPARENT, MS_RPARENT, ")", TG::LBrace, 5 ); + if (bIsStretchy) + aToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl(cEnd); + else + aToken = starmathdatabase::Identify_Postfix_SmXMLOperatorContext_Impl(cEnd); + if (aToken.eType == TERROR) + aToken = SmToken(TRPARENT, MS_RPARENT, ")", TG::LBrace, 5); std::unique_ptr<SmNode> pRight(new SmMathSymbolNode(aToken)); SmNodeArray aRelationArray; - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); aToken.cMathChar = '\0'; aToken.eType = TIDENT; @@ -1124,7 +1114,6 @@ void SmXMLFencedContext_Impl::endFastElement(sal_Int32 /*nElement*/) std::unique_ptr<SmStructureNode> pBody(new SmExpressionNode(aDummy)); pBody->SetSubNodes(std::move(aRelationArray)); - pSNode->SetSubNodes(std::move(pLeft), std::move(pBody), std::move(pRight)); // mfenced is always scalable. Stretchy keyword is not official, but in case of been in there // can be used as a hint. @@ -1132,17 +1121,18 @@ void SmXMLFencedContext_Impl::endFastElement(sal_Int32 /*nElement*/) GetSmImport().GetNodeStack().push_front(std::move(pSNode)); } -namespace { - +namespace +{ class SmXMLErrorContext_Impl : public SmXMLRowContext_Impl { public: - SmXMLErrorContext_Impl(SmXMLImport &rImport) - : SmXMLRowContext_Impl(rImport) {} + SmXMLErrorContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } void SmXMLErrorContext_Impl::endFastElement(sal_Int32 /*nElement*/) @@ -1154,22 +1144,22 @@ void SmXMLErrorContext_Impl::endFastElement(sal_Int32 /*nElement*/) the markup inside the merror with a big red colour of something. For now just throw them all away. */ - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); while (rNodeStack.size() > nElementCount) { rNodeStack.pop_front(); } } -namespace { - +namespace +{ class SmXMLNumberContext_Impl : public SmXMLImportContext { protected: SmToken aToken; public: - SmXMLNumberContext_Impl(SmXMLImport &rImport) + SmXMLNumberContext_Impl(SmXMLImport& rImport) : SmXMLImportContext(rImport) { aToken.cMathChar = '\0'; @@ -1177,51 +1167,50 @@ public: aToken.eType = TNUMBER; } - virtual void TCharacters(const OUString &rChars) override; + virtual void TCharacters(const OUString& rChars) override; void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } -void SmXMLNumberContext_Impl::TCharacters(const OUString &rChars) -{ - aToken.aText = rChars; -} +void SmXMLNumberContext_Impl::TCharacters(const OUString& rChars) { aToken.aText = rChars; } -void SmXMLNumberContext_Impl::endFastElement(sal_Int32 ) +void SmXMLNumberContext_Impl::endFastElement(sal_Int32) { - GetSmImport().GetNodeStack().push_front(std::make_unique<SmTextNode>(aToken,FNT_NUMBER)); + GetSmImport().GetNodeStack().push_front(std::make_unique<SmTextNode>(aToken, FNT_NUMBER)); } -namespace { - +namespace +{ class SmXMLAnnotationContext_Impl : public SmXMLImportContext { bool bIsStarMath; public: - SmXMLAnnotationContext_Impl(SmXMLImport &rImport) - : SmXMLImportContext(rImport), bIsStarMath(false) {} + SmXMLAnnotationContext_Impl(SmXMLImport& rImport) + : SmXMLImportContext(rImport) + , bIsStarMath(false) + { + } - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL characters(const OUString& rChars) override; - void SAL_CALL startFastElement(sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList > & xAttrList ) override; + void SAL_CALL startFastElement( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; }; - } -void SmXMLAnnotationContext_Impl::startFastElement(sal_Int32 /*nElement*/, const uno::Reference< - xml::sax::XFastAttributeList > & xAttrList ) +void SmXMLAnnotationContext_Impl::startFastElement( + sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { - for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) + for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { OUString sValue = aIter.toString(); // sometimes they have namespace, sometimes not? - switch(aIter.getToken() & TOKEN_MASK) + switch (aIter.getToken() & TOKEN_MASK) { case XML_ENCODING: - bIsStarMath= sValue == "StarMath 5.0"; + bIsStarMath = sValue == "StarMath 5.0"; break; default: XMLOFF_WARN_UNKNOWN("starmath", aIter); @@ -1230,21 +1219,21 @@ void SmXMLAnnotationContext_Impl::startFastElement(sal_Int32 /*nElement*/, const } } -void SmXMLAnnotationContext_Impl::characters(const OUString &rChars) +void SmXMLAnnotationContext_Impl::characters(const OUString& rChars) { if (bIsStarMath) - GetSmImport().SetText( GetSmImport().GetText() + rChars ); + GetSmImport().SetText(GetSmImport().GetText() + rChars); } -namespace { - +namespace +{ class SmXMLTextContext_Impl : public SmXMLImportContext { protected: SmToken aToken; public: - SmXMLTextContext_Impl(SmXMLImport &rImport) + SmXMLTextContext_Impl(SmXMLImport& rImport) : SmXMLImportContext(rImport) { aToken.cMathChar = '\0'; @@ -1252,32 +1241,28 @@ public: aToken.eType = TTEXT; } - virtual void TCharacters(const OUString &rChars) override; + virtual void TCharacters(const OUString& rChars) override; void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } -void SmXMLTextContext_Impl::TCharacters(const OUString &rChars) -{ - aToken.aText = rChars; -} +void SmXMLTextContext_Impl::TCharacters(const OUString& rChars) { aToken.aText = rChars; } -void SmXMLTextContext_Impl::endFastElement(sal_Int32 ) +void SmXMLTextContext_Impl::endFastElement(sal_Int32) { - GetSmImport().GetNodeStack().push_front(std::make_unique<SmTextNode>(aToken,FNT_TEXT)); + GetSmImport().GetNodeStack().push_front(std::make_unique<SmTextNode>(aToken, FNT_TEXT)); } -namespace { - +namespace +{ class SmXMLStringContext_Impl : public SmXMLImportContext { protected: SmToken aToken; public: - SmXMLStringContext_Impl(SmXMLImport &rImport) + SmXMLStringContext_Impl(SmXMLImport& rImport) : SmXMLImportContext(rImport) { aToken.cMathChar = '\0'; @@ -1285,14 +1270,13 @@ public: aToken.eType = TTEXT; } - virtual void TCharacters(const OUString &rChars) override; + virtual void TCharacters(const OUString& rChars) override; void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } -void SmXMLStringContext_Impl::TCharacters(const OUString &rChars) +void SmXMLStringContext_Impl::TCharacters(const OUString& rChars) { /* The content of <ms> elements should be rendered with visible "escaping" of @@ -1307,13 +1291,13 @@ void SmXMLStringContext_Impl::TCharacters(const OUString &rChars) aToken.aText = "\"" + rChars + "\""; } -void SmXMLStringContext_Impl::endFastElement(sal_Int32 ) +void SmXMLStringContext_Impl::endFastElement(sal_Int32) { - GetSmImport().GetNodeStack().push_front(std::make_unique<SmTextNode>(aToken,FNT_FIXED)); + GetSmImport().GetNodeStack().push_front(std::make_unique<SmTextNode>(aToken, FNT_FIXED)); } -namespace { - +namespace +{ class SmXMLIdentifierContext_Impl : public SmXMLImportContext { SmXMLTokenAttrHelper maTokenAttrHelper; @@ -1321,7 +1305,7 @@ class SmXMLIdentifierContext_Impl : public SmXMLImportContext SmToken aToken; public: - SmXMLIdentifierContext_Impl(SmXMLImport &rImport) + SmXMLIdentifierContext_Impl(SmXMLImport& rImport) : SmXMLImportContext(rImport) , maTokenAttrHelper(*this) , aStyleHelper(*this) @@ -1331,18 +1315,19 @@ public: aToken.eType = TIDENT; } - void TCharacters(const OUString &rChars) override; - void SAL_CALL startFastElement(sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList > & xAttrList ) override + void TCharacters(const OUString& rChars) override; + void SAL_CALL + startFastElement(sal_Int32 /*nElement*/, + const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override { maTokenAttrHelper.RetrieveAttrs(xAttrList); aStyleHelper.RetrieveAttrs(xAttrList); }; void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } -void SmXMLIdentifierContext_Impl::endFastElement(sal_Int32 ) +void SmXMLIdentifierContext_Impl::endFastElement(sal_Int32) { std::unique_ptr<SmTextNode> pNode; //we will handle identifier italic/normal here instead of with a standalone @@ -1350,12 +1335,12 @@ void SmXMLIdentifierContext_Impl::endFastElement(sal_Int32 ) if (((aStyleHelper.nIsItalic == -1) && (aToken.aText.getLength() > 1)) || ((aStyleHelper.nIsItalic == 0) && (aToken.aText.getLength() == 1))) { - pNode.reset(new SmTextNode(aToken,FNT_FUNCTION)); + pNode.reset(new SmTextNode(aToken, FNT_FUNCTION)); pNode->GetFont().SetItalic(ITALIC_NONE); aStyleHelper.nIsItalic = -1; } else - pNode.reset(new SmTextNode(aToken,FNT_VARIABLE)); + pNode.reset(new SmTextNode(aToken, FNT_VARIABLE)); if (aStyleHelper.nIsItalic != -1) { if (aStyleHelper.nIsItalic) @@ -1367,18 +1352,14 @@ void SmXMLIdentifierContext_Impl::endFastElement(sal_Int32 ) GetSmImport().GetNodeStack().push_front(std::move(pNode)); aStyleHelper.ApplyAttrs(); - maTokenAttrHelper.ApplyAttrs( (aToken.aText.getLength() == 1) - ? MathMLMathvariantValue::Italic - : MathMLMathvariantValue::Normal ); -} - -void SmXMLIdentifierContext_Impl::TCharacters(const OUString &rChars) -{ - aToken.aText = rChars; + maTokenAttrHelper.ApplyAttrs((aToken.aText.getLength() == 1) ? MathMLMathvariantValue::Italic + : MathMLMathvariantValue::Normal); } -namespace { +void SmXMLIdentifierContext_Impl::TCharacters(const OUString& rChars) { aToken.aText = rChars; } +namespace +{ class SmXMLOperatorContext_Impl : public SmXMLImportContext { SmXMLTokenAttrHelper maTokenAttrHelper; @@ -1390,7 +1371,7 @@ class SmXMLOperatorContext_Impl : public SmXMLImportContext SmToken aToken; public: - SmXMLOperatorContext_Impl(SmXMLImport &rImport) + SmXMLOperatorContext_Impl(SmXMLImport& rImport) : SmXMLImportContext(rImport) , maTokenAttrHelper(*this) , bIsStretchy(false) @@ -1403,38 +1384,56 @@ public: aToken.nLevel = 5; } - void TCharacters(const OUString &rChars) override; - void SAL_CALL startFastElement(sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList > &xAttrList ) override; + void TCharacters(const OUString& rChars) override; + void SAL_CALL startFastElement( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } -void SmXMLOperatorContext_Impl::TCharacters(const OUString &rChars) +void SmXMLOperatorContext_Impl::TCharacters(const OUString& rChars) { aToken.cMathChar = rChars[0]; SmToken bToken; - if( bIsFenced ){ - if( bIsStretchy ) + if (bIsFenced) + { + if (bIsStretchy) { - if( isPrefix ) bToken = starmathdatabase::Identify_Prefix_SmXMLOperatorContext_Impl( aToken.cMathChar ); - else if( isInfix ) bToken = SmToken( TMLINE, MS_VERTLINE, "mline", TG::NONE, 0 ); - else if( isPostfix ) bToken = starmathdatabase::Identify_Postfix_SmXMLOperatorContext_Impl( aToken.cMathChar ); - else bToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl( aToken.cMathChar ); + if (isPrefix) + bToken + = starmathdatabase::Identify_Prefix_SmXMLOperatorContext_Impl(aToken.cMathChar); + else if (isInfix) + bToken = SmToken(TMLINE, MS_VERTLINE, "mline", TG::NONE, 0); + else if (isPostfix) + bToken = starmathdatabase::Identify_Postfix_SmXMLOperatorContext_Impl( + aToken.cMathChar); + else + bToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl( + aToken.cMathChar); } else { - if( isPrefix ) bToken = starmathdatabase::Identify_Prefix_SmXMLOperatorContext_Impl( aToken.cMathChar ); - else if( isInfix ) bToken = SmToken( TMLINE, MS_VERTLINE, "mline", TG::NONE, 0 ); - else if( isPostfix ) bToken = starmathdatabase::Identify_Postfix_SmXMLOperatorContext_Impl( aToken.cMathChar ); - else bToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl( aToken.cMathChar ); + if (isPrefix) + bToken + = starmathdatabase::Identify_Prefix_SmXMLOperatorContext_Impl(aToken.cMathChar); + else if (isInfix) + bToken = SmToken(TMLINE, MS_VERTLINE, "mline", TG::NONE, 0); + else if (isPostfix) + bToken = starmathdatabase::Identify_Postfix_SmXMLOperatorContext_Impl( + aToken.cMathChar); + else + bToken = starmathdatabase::Identify_PrefixPostfix_SmXMLOperatorContext_Impl( + aToken.cMathChar); } } - else bToken = starmathdatabase::Identify_SmXMLOperatorContext_Impl( aToken.cMathChar, bIsStretchy ); - if( bToken.eType != TERROR ) aToken = bToken; + else + bToken + = starmathdatabase::Identify_SmXMLOperatorContext_Impl(aToken.cMathChar, bIsStretchy); + if (bToken.eType != TERROR) + aToken = bToken; } -void SmXMLOperatorContext_Impl::endFastElement(sal_Int32 ) +void SmXMLOperatorContext_Impl::endFastElement(sal_Int32) { std::unique_ptr<SmMathSymbolNode> pNode(new SmMathSymbolNode(aToken)); //For stretchy scaling the scaling must be retrieved from this node @@ -1449,27 +1448,26 @@ void SmXMLOperatorContext_Impl::endFastElement(sal_Int32 ) maTokenAttrHelper.ApplyAttrs(MathMLMathvariantValue::Normal); } - -void SmXMLOperatorContext_Impl::startFastElement(sal_Int32 /*nElement*/, const uno::Reference< - xml::sax::XFastAttributeList > & xAttrList ) +void SmXMLOperatorContext_Impl::startFastElement( + sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { maTokenAttrHelper.RetrieveAttrs(xAttrList); - for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) + for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { OUString sValue = aIter.toString(); - switch(aIter.getToken()) + switch (aIter.getToken()) { case XML_STRETCHY: bIsStretchy = sValue == GetXMLToken(XML_TRUE); break; case XML_FENCE: - bIsFenced = sValue == GetXMLToken(XML_TRUE); + bIsFenced = sValue == GetXMLToken(XML_TRUE); break; case XML_FORM: - isPrefix = sValue == GetXMLToken(XML_PREFIX); // < - isInfix = sValue == GetXMLToken(XML_INFIX); // | - isPostfix = sValue == GetXMLToken(XML_POSTFIX); // > + isPrefix = sValue == GetXMLToken(XML_PREFIX); // < + isInfix = sValue == GetXMLToken(XML_INFIX); // | + isPostfix = sValue == GetXMLToken(XML_POSTFIX); // > break; default: XMLOFF_WARN_UNKNOWN("starmath", aIter); @@ -1478,19 +1476,21 @@ void SmXMLOperatorContext_Impl::startFastElement(sal_Int32 /*nElement*/, const u } } -namespace { - +namespace +{ class SmXMLSpaceContext_Impl : public SmXMLImportContext { public: - SmXMLSpaceContext_Impl(SmXMLImport &rImport) - : SmXMLImportContext(rImport) {} + SmXMLSpaceContext_Impl(SmXMLImport& rImport) + : SmXMLImportContext(rImport) + { + } - void SAL_CALL startFastElement(sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) override; + void SAL_CALL startFastElement( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; }; -bool lcl_CountBlanks(const MathMLAttributeLengthValue &rLV, - sal_Int32 *pWide, sal_Int32 *pNarrow) +bool lcl_CountBlanks(const MathMLAttributeLengthValue& rLV, sal_Int32* pWide, sal_Int32* pNarrow) { assert(pWide); assert(pNarrow); @@ -1518,24 +1518,23 @@ bool lcl_CountBlanks(const MathMLAttributeLengthValue &rLV, *pNarrow = nNarrow; return true; } - } -void SmXMLSpaceContext_Impl::startFastElement(sal_Int32 /*nElement*/, - const uno::Reference<xml::sax::XFastAttributeList > & xAttrList ) +void SmXMLSpaceContext_Impl::startFastElement( + sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { // There is no syntax in Math to specify blank nodes of arbitrary size yet. MathMLAttributeLengthValue aLV; sal_Int32 nWide = 0, nNarrow = 0; - for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) + for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { OUString sValue = aIter.toString(); switch (aIter.getToken()) { case XML_WIDTH: - if ( ParseMathMLAttributeLengthValue(sValue.trim(), aLV) <= 0 || - !lcl_CountBlanks(aLV, &nWide, &nNarrow) ) + if (ParseMathMLAttributeLengthValue(sValue.trim(), aLV) <= 0 + || !lcl_CountBlanks(aLV, &nWide, &nNarrow)) SAL_WARN("starmath", "ignore mspace's width: " << sValue); break; default: @@ -1559,30 +1558,28 @@ void SmXMLSpaceContext_Impl::startFastElement(sal_Int32 /*nElement*/, GetSmImport().GetNodeStack().push_front(std::move(pBlank)); } -namespace { - +namespace +{ class SmXMLSubContext_Impl : public SmXMLRowContext_Impl { protected: - void GenericEndElement(SmTokenType eType,SmSubSup aSubSup); + void GenericEndElement(SmTokenType eType, SmSubSup aSubSup); public: - SmXMLSubContext_Impl(SmXMLImport &rImport) - : SmXMLRowContext_Impl(rImport) {} - - void SAL_CALL endFastElement(sal_Int32 ) override + SmXMLSubContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) { - GenericEndElement(TRSUB,RSUB); } -}; + void SAL_CALL endFastElement(sal_Int32) override { GenericEndElement(TRSUB, RSUB); } +}; } void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup) { /*The <msub> element requires exactly 2 arguments.*/ const bool bNodeCheck = GetSmImport().GetNodeStack().size() - nElementCount == 2; - OSL_ENSURE( bNodeCheck, "Sub has not two arguments" ); + OSL_ENSURE(bNodeCheck, "Sub has not two arguments"); if (!bNodeCheck) return; @@ -1590,58 +1587,53 @@ void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup aToken.cMathChar = '\0'; aToken.eType = eType; std::unique_ptr<SmSubSupNode> pNode(new SmSubSupNode(aToken)); - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); // initialize subnodes array - SmNodeArray aSubNodes; + SmNodeArray aSubNodes; aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES); - for (size_t i = 1; i < aSubNodes.size(); i++) + for (size_t i = 1; i < aSubNodes.size(); i++) aSubNodes[i] = nullptr; - aSubNodes[eSubSup+1] = popOrZero(rNodeStack).release(); + aSubNodes[eSubSup + 1] = popOrZero(rNodeStack).release(); aSubNodes[0] = popOrZero(rNodeStack).release(); pNode->SetSubNodes(std::move(aSubNodes)); rNodeStack.push_front(std::move(pNode)); } -namespace { - +namespace +{ class SmXMLSupContext_Impl : public SmXMLSubContext_Impl { public: - SmXMLSupContext_Impl(SmXMLImport &rImport) - : SmXMLSubContext_Impl(rImport) {} - - void SAL_CALL endFastElement(sal_Int32 ) override + SmXMLSupContext_Impl(SmXMLImport& rImport) + : SmXMLSubContext_Impl(rImport) { - GenericEndElement(TRSUP,RSUP); } -}; + void SAL_CALL endFastElement(sal_Int32) override { GenericEndElement(TRSUP, RSUP); } +}; class SmXMLSubSupContext_Impl : public SmXMLRowContext_Impl { protected: - void GenericEndElement(SmTokenType eType, SmSubSup aSub,SmSubSup aSup); + void GenericEndElement(SmTokenType eType, SmSubSup aSub, SmSubSup aSup); public: - SmXMLSubSupContext_Impl(SmXMLImport &rImport) - : SmXMLRowContext_Impl(rImport) {} - - void SAL_CALL endFastElement(sal_Int32 ) override + SmXMLSubSupContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) { - GenericEndElement(TRSUB,RSUB,RSUP); } -}; + void SAL_CALL endFastElement(sal_Int32) override { GenericEndElement(TRSUB, RSUB, RSUP); } +}; } -void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType, - SmSubSup aSub,SmSubSup aSup) +void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup aSub, SmSubSup aSup) { /*The <msub> element requires exactly 3 arguments.*/ const bool bNodeCheck = GetSmImport().GetNodeStack().size() - nElementCount == 3; - OSL_ENSURE( bNodeCheck, "SubSup has not three arguments" ); + OSL_ENSURE(bNodeCheck, "SubSup has not three arguments"); if (!bNodeCheck) return; @@ -1649,58 +1641,59 @@ void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType, aToken.cMathChar = '\0'; aToken.eType = eType; std::unique_ptr<SmSubSupNode> pNode(new SmSubSupNode(aToken)); - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); // initialize subnodes array - SmNodeArray aSubNodes; + SmNodeArray aSubNodes; aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES); - for (size_t i = 1; i < aSubNodes.size(); i++) + for (size_t i = 1; i < aSubNodes.size(); i++) aSubNodes[i] = nullptr; - aSubNodes[aSup+1] = popOrZero(rNodeStack).release(); - aSubNodes[aSub+1] = popOrZero(rNodeStack).release(); - aSubNodes[0] = popOrZero(rNodeStack).release(); + aSubNodes[aSup + 1] = popOrZero(rNodeStack).release(); + aSubNodes[aSub + 1] = popOrZero(rNodeStack).release(); + aSubNodes[0] = popOrZero(rNodeStack).release(); pNode->SetSubNodes(std::move(aSubNodes)); rNodeStack.push_front(std::move(pNode)); } -namespace { - +namespace +{ class SmXMLUnderContext_Impl : public SmXMLSubContext_Impl { protected: sal_Int16 nAttrCount; public: - SmXMLUnderContext_Impl(SmXMLImport &rImport) + SmXMLUnderContext_Impl(SmXMLImport& rImport) : SmXMLSubContext_Impl(rImport) - , nAttrCount( 0 ) - {} + , nAttrCount(0) + { + } - void SAL_CALL startFastElement(sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList > &xAttrList ) override; + void SAL_CALL startFastElement( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; void SAL_CALL endFastElement(sal_Int32 nElement) override; void HandleAccent(); }; - } -void SmXMLUnderContext_Impl::startFastElement(sal_Int32 /*nElement*/, const uno::Reference< - xml::sax::XFastAttributeList > & xAttrList ) +void SmXMLUnderContext_Impl::startFastElement( + sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { - sax_fastparser::FastAttributeList& rAttribList = - sax_fastparser::castToFastAttributeList( xAttrList ); + sax_fastparser::FastAttributeList& rAttribList + = sax_fastparser::castToFastAttributeList(xAttrList); nAttrCount = rAttribList.getFastAttributeTokens().size(); } void SmXMLUnderContext_Impl::HandleAccent() { const bool bNodeCheck = GetSmImport().GetNodeStack().size() - nElementCount == 2; - OSL_ENSURE( bNodeCheck, "Sub has not two arguments" ); + OSL_ENSURE(bNodeCheck, "Sub has not two arguments"); if (!bNodeCheck) return; /*Just one special case for the underline thing*/ - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); std::unique_ptr<SmNode> pTest = popOrZero(rNodeStack); SmToken aToken; aToken.cMathChar = '\0'; @@ -1721,55 +1714,55 @@ void SmXMLUnderContext_Impl::HandleAccent() rNodeStack.push_front(std::move(pNode)); } - -void SmXMLUnderContext_Impl::endFastElement(sal_Int32 ) +void SmXMLUnderContext_Impl::endFastElement(sal_Int32) { if (!nAttrCount) - GenericEndElement(TCSUB,CSUB); + GenericEndElement(TCSUB, CSUB); else HandleAccent(); } -namespace { - +namespace +{ class SmXMLOverContext_Impl : public SmXMLSubContext_Impl { protected: sal_Int16 nAttrCount; public: - SmXMLOverContext_Impl(SmXMLImport &rImport) - : SmXMLSubContext_Impl(rImport), nAttrCount(0) {} + SmXMLOverContext_Impl(SmXMLImport& rImport) + : SmXMLSubContext_Impl(rImport) + , nAttrCount(0) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; - void SAL_CALL startFastElement(sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList > &xAttrList ) override; + void SAL_CALL startFastElement( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; void HandleAccent(); }; - } -void SmXMLOverContext_Impl::startFastElement(sal_Int32 /*nElement*/, const uno::Reference< - xml::sax::XFastAttributeList > & xAttrList ) +void SmXMLOverContext_Impl::startFastElement( + sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { - sax_fastparser::FastAttributeList& rAttribList = - sax_fastparser::castToFastAttributeList( xAttrList ); + sax_fastparser::FastAttributeList& rAttribList + = sax_fastparser::castToFastAttributeList(xAttrList); nAttrCount = rAttribList.getFastAttributeTokens().size(); } - -void SmXMLOverContext_Impl::endFastElement(sal_Int32 ) +void SmXMLOverContext_Impl::endFastElement(sal_Int32) { if (!nAttrCount) - GenericEndElement(TCSUP,CSUP); + GenericEndElement(TCSUP, CSUP); else HandleAccent(); } - void SmXMLOverContext_Impl::HandleAccent() { const bool bNodeCheck = GetSmImport().GetNodeStack().size() - nElementCount == 2; - OSL_ENSURE (bNodeCheck, "Sub has not two arguments"); + OSL_ENSURE(bNodeCheck, "Sub has not two arguments"); if (!bNodeCheck) return; @@ -1778,30 +1771,27 @@ void SmXMLOverContext_Impl::HandleAccent() aToken.eType = TACUTE; std::unique_ptr<SmAttributNode> pNode(new SmAttributNode(aToken)); - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); std::unique_ptr<SmNode> pFirst = popOrZero(rNodeStack); std::unique_ptr<SmNode> pSecond = popOrZero(rNodeStack); pNode->SetSubNodes(std::move(pFirst), std::move(pSecond)); pNode->SetScaleMode(SmScaleMode::Width); rNodeStack.push_front(std::move(pNode)); - } -namespace { - +namespace +{ class SmXMLUnderOverContext_Impl : public SmXMLSubSupContext_Impl { public: - SmXMLUnderOverContext_Impl(SmXMLImport &rImport) - : SmXMLSubSupContext_Impl(rImport) {} - - void SAL_CALL endFastElement(sal_Int32 ) override + SmXMLUnderOverContext_Impl(SmXMLImport& rImport) + : SmXMLSubSupContext_Impl(rImport) { - GenericEndElement(TCSUB,CSUB,CSUP); } -}; + void SAL_CALL endFastElement(sal_Int32) override { GenericEndElement(TCSUB, CSUB, CSUP); } +}; class SmXMLMultiScriptsContext_Impl : public SmXMLSubSupContext_Impl { @@ -1810,183 +1800,186 @@ class SmXMLMultiScriptsContext_Impl : public SmXMLSubSupContext_Impl void ProcessSubSupPairs(bool bIsPrescript); public: - SmXMLMultiScriptsContext_Impl(SmXMLImport &rImport) : - SmXMLSubSupContext_Impl(rImport), - bHasPrescripts(false) {} + SmXMLMultiScriptsContext_Impl(SmXMLImport& rImport) + : SmXMLSubSupContext_Impl(rImport) + , bHasPrescripts(false) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; - virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( - sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) override; + virtual uno::Reference<xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; }; - class SmXMLNoneContext_Impl : public SmXMLImportContext { public: - SmXMLNoneContext_Impl(SmXMLImport &rImport) - : SmXMLImportContext(rImport) {} + SmXMLNoneContext_Impl(SmXMLImport& rImport) + : SmXMLImportContext(rImport) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - } -void SmXMLNoneContext_Impl::endFastElement(sal_Int32 ) +void SmXMLNoneContext_Impl::endFastElement(sal_Int32) { SmToken aToken; aToken.cMathChar = '\0'; aToken.aText.clear(); aToken.nLevel = 5; aToken.eType = TIDENT; - GetSmImport().GetNodeStack().push_front( - std::make_unique<SmTextNode>(aToken,FNT_VARIABLE)); + GetSmImport().GetNodeStack().push_front(std::make_unique<SmTextNode>(aToken, FNT_VARIABLE)); } -namespace { - +namespace +{ class SmXMLPrescriptsContext_Impl : public SmXMLImportContext { public: - SmXMLPrescriptsContext_Impl(SmXMLImport &rImport) - : SmXMLImportContext(rImport) {} + SmXMLPrescriptsContext_Impl(SmXMLImport& rImport) + : SmXMLImportContext(rImport) + { + } }; - class SmXMLTableRowContext_Impl : public SmXMLRowContext_Impl { public: - SmXMLTableRowContext_Impl(SmXMLImport &rImport) : - SmXMLRowContext_Impl(rImport) - {} + SmXMLTableRowContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + { + } - virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( - sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) override; + virtual uno::Reference<xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; }; - class SmXMLTableContext_Impl : public SmXMLTableRowContext_Impl { public: - SmXMLTableContext_Impl(SmXMLImport &rImport) : - SmXMLTableRowContext_Impl(rImport) - {} + SmXMLTableContext_Impl(SmXMLImport& rImport) + : SmXMLTableRowContext_Impl(rImport) + { + } void SAL_CALL endFastElement(sal_Int32 nElement) override; - virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( - sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) override; + virtual uno::Reference<xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; }; - class SmXMLTableCellContext_Impl : public SmXMLRowContext_Impl { public: - SmXMLTableCellContext_Impl(SmXMLImport &rImport) : - SmXMLRowContext_Impl(rImport) - {} + SmXMLTableCellContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + { + } }; - class SmXMLAlignGroupContext_Impl : public SmXMLRowContext_Impl { public: - SmXMLAlignGroupContext_Impl(SmXMLImport &rImport) : - SmXMLRowContext_Impl(rImport) - {} + SmXMLAlignGroupContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + { + } /*Don't do anything with alignment for now*/ }; - class SmXMLActionContext_Impl : public SmXMLRowContext_Impl { size_t mnSelection; // 1-based public: - SmXMLActionContext_Impl(SmXMLImport &rImport) : - SmXMLRowContext_Impl(rImport) - , mnSelection(1) - {} + SmXMLActionContext_Impl(SmXMLImport& rImport) + : SmXMLRowContext_Impl(rImport) + , mnSelection(1) + { + } - void SAL_CALL startFastElement(sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList> &xAttrList) override; + void SAL_CALL startFastElement( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) override; void SAL_CALL endFastElement(sal_Int32 nElement) override; }; - // NB: virtually inherit so we can multiply inherit properly // in SmXMLFlatDocContext_Impl class SmXMLOfficeContext_Impl : public virtual SvXMLImportContext { public: - SmXMLOfficeContext_Impl( SmXMLImport &rImport ) - : SvXMLImportContext(rImport) {} + SmXMLOfficeContext_Impl(SmXMLImport& rImport) + : SvXMLImportContext(rImport) + { + } - virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( - sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; + virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override; }; - } -uno::Reference< xml::sax::XFastContextHandler > SmXMLOfficeContext_Impl::createFastChildContext(sal_Int32 nElement, - const uno::Reference< xml::sax::XFastAttributeList > &/*xAttrList*/) +uno::Reference<xml::sax::XFastContextHandler> SmXMLOfficeContext_Impl::createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& /*xAttrList*/) { - if ( nElement == XML_ELEMENT(OFFICE, XML_META) ) + if (nElement == XML_ELEMENT(OFFICE, XML_META)) { - SAL_WARN("starmath", "XML_TOK_DOC_META: should not have come here, maybe document is invalid?"); + SAL_WARN("starmath", + "XML_TOK_DOC_META: should not have come here, maybe document is invalid?"); } - else if ( nElement == XML_ELEMENT(OFFICE, XML_SETTINGS) ) + else if (nElement == XML_ELEMENT(OFFICE, XML_SETTINGS)) { - return new XMLDocumentSettingsContext( GetImport() ); + return new XMLDocumentSettingsContext(GetImport()); } return nullptr; } -namespace { - +namespace +{ // context for flat file xml format -class SmXMLFlatDocContext_Impl - : public SmXMLOfficeContext_Impl, public SvXMLMetaDocumentContext +class SmXMLFlatDocContext_Impl : public SmXMLOfficeContext_Impl, public SvXMLMetaDocumentContext { public: - SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport, - const uno::Reference<document::XDocumentProperties>& i_xDocProps); + SmXMLFlatDocContext_Impl(SmXMLImport& i_rImport, + const uno::Reference<document::XDocumentProperties>& i_xDocProps); - virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( - sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; + virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override; }; - } -SmXMLFlatDocContext_Impl::SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport, - const uno::Reference<document::XDocumentProperties>& i_xDocProps) : - SvXMLImportContext(i_rImport), - SmXMLOfficeContext_Impl(i_rImport), - SvXMLMetaDocumentContext(i_rImport, i_xDocProps) +SmXMLFlatDocContext_Impl::SmXMLFlatDocContext_Impl( + SmXMLImport& i_rImport, const uno::Reference<document::XDocumentProperties>& i_xDocProps) + : SvXMLImportContext(i_rImport) + , SmXMLOfficeContext_Impl(i_rImport) + , SvXMLMetaDocumentContext(i_rImport, i_xDocProps) { } -uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SmXMLFlatDocContext_Impl::createFastChildContext( - sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) +uno::Reference<xml::sax::XFastContextHandler> + SAL_CALL SmXMLFlatDocContext_Impl::createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { // behave like meta base class iff we encounter office:meta - if ( nElement == XML_ELEMENT(OFFICE, XML_META) ) + if (nElement == XML_ELEMENT(OFFICE, XML_META)) { - return SvXMLMetaDocumentContext::createFastChildContext( - nElement, xAttrList ); + return SvXMLMetaDocumentContext::createFastChildContext(nElement, xAttrList); } else { - return SmXMLOfficeContext_Impl::createFastChildContext( - nElement, xAttrList ); + return SmXMLOfficeContext_Impl::createFastChildContext(nElement, xAttrList); } } -uno::Reference< xml::sax::XFastContextHandler > SmXMLDocContext_Impl::createFastChildContext( - sal_Int32 nElement, - const uno::Reference<xml::sax::XFastAttributeList>& /*xAttrList*/) +uno::Reference<xml::sax::XFastContextHandler> SmXMLDocContext_Impl::createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& /*xAttrList*/) { - uno::Reference< xml::sax::XFastContextHandler > xContext; + uno::Reference<xml::sax::XFastContextHandler> xContext; - switch(nElement) + switch (nElement) { //Consider semantics a dummy except for any starmath annotations case XML_ELEMENT(MATH, XML_SEMANTICS): @@ -2055,7 +2048,8 @@ uno::Reference< xml::sax::XFastContextHandler > SmXMLDocContext_Impl::createFast /*Basically there's an implicit mrow around certain bare *elements, use a RowContext to see if this is one of *those ones*/ - rtl::Reference<SmXMLRowContext_Impl> aTempContext(new SmXMLRowContext_Impl(GetSmImport())); + rtl::Reference<SmXMLRowContext_Impl> aTempContext( + new SmXMLRowContext_Impl(GetSmImport())); xContext = aTempContext->StrictCreateChildContext(nElement); break; @@ -2065,7 +2059,7 @@ uno::Reference< xml::sax::XFastContextHandler > SmXMLDocContext_Impl::createFast void SmXMLDocContext_Impl::endFastElement(sal_Int32) { - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); std::unique_ptr<SmNode> pContextNode = popOrZero(rNodeStack); @@ -2074,7 +2068,7 @@ void SmXMLDocContext_Impl::endFastElement(sal_Int32) pSNode->SetSubNodes(std::move(pContextNode), nullptr); rNodeStack.push_front(std::move(pSNode)); - SmNodeArray LineArray; + SmNodeArray LineArray; auto n = rNodeStack.size(); LineArray.resize(n); for (size_t j = 0; j < n; j++) @@ -2088,11 +2082,11 @@ void SmXMLDocContext_Impl::endFastElement(sal_Int32) rNodeStack.push_front(std::move(pSNode2)); } -void SmXMLFracContext_Impl::endFastElement(sal_Int32 ) +void SmXMLFracContext_Impl::endFastElement(sal_Int32) { - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); const bool bNodeCheck = rNodeStack.size() - nElementCount == 2; - OSL_ENSURE( bNodeCheck, "Fraction (mfrac) tag is missing component" ); + OSL_ENSURE(bNodeCheck, "Fraction (mfrac) tag is missing component"); if (!bNodeCheck) return; @@ -2107,20 +2101,20 @@ void SmXMLFracContext_Impl::endFastElement(sal_Int32 ) rNodeStack.push_front(std::move(pSNode)); } -void SmXMLRootContext_Impl::endFastElement(sal_Int32 ) +void SmXMLRootContext_Impl::endFastElement(sal_Int32) { /*The <mroot> element requires exactly 2 arguments.*/ const bool bNodeCheck = GetSmImport().GetNodeStack().size() - nElementCount == 2; - OSL_ENSURE( bNodeCheck, "Root tag is missing component"); + OSL_ENSURE(bNodeCheck, "Root tag is missing component"); if (!bNodeCheck) return; SmToken aToken; - aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font + aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font aToken.eType = TNROOT; std::unique_ptr<SmStructureNode> pSNode(new SmRootNode(aToken)); std::unique_ptr<SmNode> pOper(new SmRootSymbolNode(aToken)); - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); std::unique_ptr<SmNode> pIndex = popOrZero(rNodeStack); std::unique_ptr<SmNode> pBase = popOrZero(rNodeStack); pSNode->SetSubNodes(std::move(pIndex), std::move(pOper), std::move(pBase)); @@ -2138,30 +2132,30 @@ void SmXMLSqrtContext_Impl::endFastElement(sal_Int32 nElement) SmXMLRowContext_Impl::endFastElement(nElement); SmToken aToken; - aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font + aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font aToken.eType = TSQRT; std::unique_ptr<SmStructureNode> pSNode(new SmRootNode(aToken)); std::unique_ptr<SmNode> pOper(new SmRootSymbolNode(aToken)); - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); pSNode->SetSubNodes(nullptr, std::move(pOper), popOrZero(rNodeStack)); rNodeStack.push_front(std::move(pSNode)); } -void SmXMLRowContext_Impl::endFastElement(sal_Int32 ) +void SmXMLRowContext_Impl::endFastElement(sal_Int32) { SmNodeArray aRelationArray; - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); if (rNodeStack.size() > nElementCount) { auto nSize = rNodeStack.size() - nElementCount; aRelationArray.resize(nSize); - for (auto j=nSize;j > 0;j--) + for (auto j = nSize; j > 0; j--) { auto pNode = std::move(rNodeStack.front()); rNodeStack.pop_front(); - aRelationArray[j-1] = pNode.release(); + aRelationArray[j - 1] = pNode.release(); } //If the first or last element is an operator with stretchyness @@ -2170,20 +2164,20 @@ void SmXMLRowContext_Impl::endFastElement(sal_Int32 ) //ourselves, and creating the appropriate dummy StarMath none bracket //to balance the arrangement if (((aRelationArray[0]->GetScaleMode() == SmScaleMode::Height) - && (aRelationArray[0]->GetType() == SmNodeType::Math)) - || ((aRelationArray[nSize-1]->GetScaleMode() == SmScaleMode::Height) - && (aRelationArray[nSize-1]->GetType() == SmNodeType::Math))) + && (aRelationArray[0]->GetType() == SmNodeType::Math)) + || ((aRelationArray[nSize - 1]->GetScaleMode() == SmScaleMode::Height) + && (aRelationArray[nSize - 1]->GetType() == SmNodeType::Math))) { SmToken aToken; aToken.cMathChar = '\0'; aToken.nLevel = 5; - int nLeft=0,nRight=0; + int nLeft = 0, nRight = 0; if ((aRelationArray[0]->GetScaleMode() == SmScaleMode::Height) && (aRelationArray[0]->GetType() == SmNodeType::Math)) { aToken = aRelationArray[0]->GetToken(); - nLeft=1; + nLeft = 1; } else aToken.cMathChar = '\0'; @@ -2191,11 +2185,11 @@ void SmXMLRowContext_Impl::endFastElement(sal_Int32 ) aToken.eType = TLPARENT; std::unique_ptr<SmNode> pLeft(new SmMathSymbolNode(aToken)); - if ((aRelationArray[nSize-1]->GetScaleMode() == SmScaleMode::Height) - && (aRelationArray[nSize-1]->GetType() == SmNodeType::Math)) + if ((aRelationArray[nSize - 1]->GetScaleMode() == SmScaleMode::Height) + && (aRelationArray[nSize - 1]->GetType() == SmNodeType::Math)) { - aToken = aRelationArray[nSize-1]->GetToken(); - nRight=1; + aToken = aRelationArray[nSize - 1]->GetToken(); + nRight = 1; } else aToken.cMathChar = '\0'; @@ -2206,14 +2200,14 @@ void SmXMLRowContext_Impl::endFastElement(sal_Int32 ) SmNodeArray aRelationArray2; //!! nSize-nLeft-nRight may be < 0 !! - int nRelArrSize = nSize-nLeft-nRight; + int nRelArrSize = nSize - nLeft - nRight; if (nRelArrSize > 0) { aRelationArray2.resize(nRelArrSize); - for (int i=0;i < nRelArrSize;i++) + for (int i = 0; i < nRelArrSize; i++) { - aRelationArray2[i] = aRelationArray[i+nLeft]; - aRelationArray[i+nLeft] = nullptr; + aRelationArray2[i] = aRelationArray[i + nLeft]; + aRelationArray[i + nLeft] = nullptr; } } @@ -2261,12 +2255,12 @@ void SmXMLRowContext_Impl::endFastElement(sal_Int32 ) rNodeStack.push_front(std::move(pSNode)); } -uno::Reference< xml::sax::XFastContextHandler > SmXMLRowContext_Impl::StrictCreateChildContext( - sal_Int32 nElement) +uno::Reference<xml::sax::XFastContextHandler> +SmXMLRowContext_Impl::StrictCreateChildContext(sal_Int32 nElement) { - uno::Reference< xml::sax::XFastContextHandler > pContext; + uno::Reference<xml::sax::XFastContextHandler> pContext; - switch(nElement) + switch (nElement) { /*Note that these should accept malignmark subelements, but do not*/ case XML_ELEMENT(MATH, XML_MN): @@ -2304,12 +2298,10 @@ uno::Reference< xml::sax::XFastContextHandler > SmXMLRowContext_Impl::StrictCrea return pContext; } - -uno::Reference< xml::sax::XFastContextHandler > SmXMLRowContext_Impl::createFastChildContext( - sal_Int32 nElement, - const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) +uno::Reference<xml::sax::XFastContextHandler> SmXMLRowContext_Impl::createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { - uno::Reference< xml::sax::XFastContextHandler > xContext = StrictCreateChildContext(nElement); + uno::Reference<xml::sax::XFastContextHandler> xContext = StrictCreateChildContext(nElement); if (!xContext) { @@ -2320,13 +2312,12 @@ uno::Reference< xml::sax::XFastContextHandler > SmXMLRowContext_Impl::createFast return xContext; } -uno::Reference< xml::sax::XFastContextHandler > SmXMLMultiScriptsContext_Impl::createFastChildContext( - sal_Int32 nElement, - const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) +uno::Reference<xml::sax::XFastContextHandler> SmXMLMultiScriptsContext_Impl::createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { - uno::Reference< xml::sax::XFastContextHandler > xContext; + uno::Reference<xml::sax::XFastContextHandler> xContext; - switch(nElement) + switch (nElement) { case XML_ELEMENT(MATH, XML_MPRESCRIPTS): bHasPrescripts = true; @@ -2337,7 +2328,7 @@ uno::Reference< xml::sax::XFastContextHandler > SmXMLMultiScriptsContext_Impl::c xContext = new SmXMLNoneContext_Impl(GetSmImport()); break; default: - xContext = SmXMLRowContext_Impl::createFastChildContext(nElement,xAttrList); + xContext = SmXMLRowContext_Impl::createFastChildContext(nElement, xAttrList); break; } return xContext; @@ -2345,7 +2336,7 @@ uno::Reference< xml::sax::XFastContextHandler > SmXMLMultiScriptsContext_Impl::c void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript) { - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); if (rNodeStack.size() <= nElementCount) return; @@ -2385,13 +2376,15 @@ void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript) std::unique_ptr<SmNode> pScriptNode = popOrZero(aReverseStack); - if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) || - (!pScriptNode->GetToken().aText.isEmpty()))) - aSubNodes[eSub+1] = pScriptNode.release(); + if (pScriptNode + && ((pScriptNode->GetToken().eType != TIDENT) + || (!pScriptNode->GetToken().aText.isEmpty()))) + aSubNodes[eSub + 1] = pScriptNode.release(); pScriptNode = popOrZero(aReverseStack); - if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) || - (!pScriptNode->GetToken().aText.isEmpty()))) - aSubNodes[eSup+1] = pScriptNode.release(); + if (pScriptNode + && ((pScriptNode->GetToken().eType != TIDENT) + || (!pScriptNode->GetToken().aText.isEmpty()))) + aSubNodes[eSup + 1] = pScriptNode.release(); pNode->SetSubNodes(std::move(aSubNodes)); aReverseStack.push_front(std::move(pNode)); @@ -2411,15 +2404,14 @@ void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript) } } - -void SmXMLTableContext_Impl::endFastElement(sal_Int32 ) +void SmXMLTableContext_Impl::endFastElement(sal_Int32) { SmNodeArray aExpressionArray; - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); SmNodeStack aReverseStack; - aExpressionArray.resize(rNodeStack.size()-nElementCount); + aExpressionArray.resize(rNodeStack.size() - nElementCount); - size_t nRows = rNodeStack.size()-nElementCount; + size_t nRows = rNodeStack.size() - nElementCount; size_t nCols = 0; for (size_t i = nRows; i > 0; --i) @@ -2452,9 +2444,9 @@ void SmXMLTableContext_Impl::endFastElement(sal_Int32 ) throw std::range_error("column limit"); if (nRows > SAL_MAX_UINT16) throw std::range_error("row limit"); - aExpressionArray.resize(nCols*nRows); - size_t j=0; - for (auto & elem : aReverseStack) + aExpressionArray.resize(nCols * nRows); + size_t j = 0; + for (auto& elem : aReverseStack) { std::unique_ptr<SmStructureNode> xArray(static_cast<SmStructureNode*>(elem.release())); for (size_t i = 0; i < xArray->GetNumSubNodes(); ++i) @@ -2472,31 +2464,29 @@ void SmXMLTableContext_Impl::endFastElement(sal_Int32 ) rNodeStack.push_front(std::move(pSNode)); } -uno::Reference< xml::sax::XFastContextHandler > SmXMLTableRowContext_Impl::createFastChildContext( - sal_Int32 nElement, - const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) +uno::Reference<xml::sax::XFastContextHandler> SmXMLTableRowContext_Impl::createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { - uno::Reference< xml::sax::XFastContextHandler > xContext; + uno::Reference<xml::sax::XFastContextHandler> xContext; - switch(nElement) + switch (nElement) { case XML_ELEMENT(MATH, XML_MTD): xContext = new SmXMLTableCellContext_Impl(GetSmImport()); break; default: - xContext = SmXMLRowContext_Impl::createFastChildContext(nElement,xAttrList); + xContext = SmXMLRowContext_Impl::createFastChildContext(nElement, xAttrList); break; } return xContext; } -uno::Reference< xml::sax::XFastContextHandler > SmXMLTableContext_Impl::createFastChildContext( - sal_Int32 nElement, - const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) +uno::Reference<xml::sax::XFastContextHandler> SmXMLTableContext_Impl::createFastChildContext( + sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { - uno::Reference< xml::sax::XFastContextHandler > xContext; + uno::Reference<xml::sax::XFastContextHandler> xContext; - switch(nElement) + switch (nElement) { case XML_ELEMENT(MATH, XML_MTR): xContext = new SmXMLTableRowContext_Impl(GetSmImport()); @@ -2508,24 +2498,26 @@ uno::Reference< xml::sax::XFastContextHandler > SmXMLTableContext_Impl::createFa return xContext; } -void SmXMLMultiScriptsContext_Impl::endFastElement(sal_Int32 ) +void SmXMLMultiScriptsContext_Impl::endFastElement(sal_Int32) { ProcessSubSupPairs(bHasPrescripts); } -void SmXMLActionContext_Impl::startFastElement(sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList> & xAttrList) +void SmXMLActionContext_Impl::startFastElement( + sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) { - for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) + for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) { OUString sValue = aIter.toString(); - switch(aIter.getToken()) + switch (aIter.getToken()) { case XML_SELECTION: - { - sal_uInt32 n = sValue.toUInt32(); - if (n > 0) mnSelection = static_cast<size_t>(n); - } - break; + { + sal_uInt32 n = sValue.toUInt32(); + if (n > 0) + mnSelection = static_cast<size_t>(n); + } + break; default: XMLOFF_WARN_UNKNOWN("starmath", aIter); break; @@ -2533,52 +2525,53 @@ void SmXMLActionContext_Impl::startFastElement(sal_Int32 /*nElement*/, const uno } } -void SmXMLActionContext_Impl::endFastElement(sal_Int32 ) +void SmXMLActionContext_Impl::endFastElement(sal_Int32) { - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack& rNodeStack = GetSmImport().GetNodeStack(); auto nSize = rNodeStack.size(); - if (nSize <= nElementCount) { + if (nSize <= nElementCount) + { // not compliant to maction's specification, e.g., no subexpressions return; } assert(mnSelection > 0); - if (nSize < nElementCount + mnSelection) { + if (nSize < nElementCount + mnSelection) + { // No selected subexpression exists, which is a MathML error; // fallback to selecting the first mnSelection = 1; } assert(nSize >= nElementCount + mnSelection); - for (auto i=nSize-(nElementCount+mnSelection); i > 0; i--) + for (auto i = nSize - (nElementCount + mnSelection); i > 0; i--) { rNodeStack.pop_front(); } auto pSelected = std::move(rNodeStack.front()); rNodeStack.pop_front(); - for (auto i=rNodeStack.size()-nElementCount; i > 0; i--) + for (auto i = rNodeStack.size() - nElementCount; i > 0; i--) { rNodeStack.pop_front(); } rNodeStack.push_front(std::move(pSelected)); } -SvXMLImportContext *SmXMLImport::CreateFastContext(sal_Int32 nElement, - const uno::Reference <xml::sax::XFastAttributeList> & /*xAttrList*/) +SvXMLImportContext* +SmXMLImport::CreateFastContext(sal_Int32 nElement, + const uno::Reference<xml::sax::XFastAttributeList>& /*xAttrList*/) { - SvXMLImportContext *pContext = nullptr; + SvXMLImportContext* pContext = nullptr; switch (nElement) { - case XML_ELEMENT( OFFICE, XML_DOCUMENT ): - case XML_ELEMENT( OFFICE, XML_DOCUMENT_META ): + case XML_ELEMENT(OFFICE, XML_DOCUMENT): + case XML_ELEMENT(OFFICE, XML_DOCUMENT_META): { - uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - GetModel(), uno::UNO_QUERY_THROW); - pContext = ( (nElement & TOKEN_MASK) == XML_DOCUMENT_META ) - ? new SvXMLMetaDocumentContext( *this, - xDPS->getDocumentProperties() ) - // flat OpenDocument file format -- this has not been tested... - : new SmXMLFlatDocContext_Impl( *this, - xDPS->getDocumentProperties() ); + uno::Reference<document::XDocumentPropertiesSupplier> xDPS(GetModel(), + uno::UNO_QUERY_THROW); + pContext = ((nElement & TOKEN_MASK) == XML_DOCUMENT_META) + ? new SvXMLMetaDocumentContext(*this, xDPS->getDocumentProperties()) + // flat OpenDocument file format -- this has not been tested... + : new SmXMLFlatDocContext_Impl(*this, xDPS->getDocumentProperties()); } break; default: @@ -2590,87 +2583,82 @@ SvXMLImportContext *SmXMLImport::CreateFastContext(sal_Int32 nElement, return pContext; } -SmXMLImport::~SmXMLImport() throw () -{ - cleanup(); -} +SmXMLImport::~SmXMLImport() throw() { cleanup(); } void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps) { - uno::Reference <frame::XModel> xModel = GetModel(); - if ( !xModel.is() ) + uno::Reference<frame::XModel> xModel = GetModel(); + if (!xModel.is()) return; - SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); + SmModel* pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel); - if ( !pModel ) + if (!pModel) return; - SmDocShell *pDocShell = - static_cast<SmDocShell*>(pModel->GetObjectShell()); - if ( !pDocShell ) + SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell()); + if (!pDocShell) return; - tools::Rectangle aRect( pDocShell->GetVisArea() ); + tools::Rectangle aRect(pDocShell->GetVisArea()); tools::Long nTmp = 0; for (const PropertyValue& rValue : aViewProps) { - if (rValue.Name == "ViewAreaTop" ) + if (rValue.Name == "ViewAreaTop") { rValue.Value >>= nTmp; aRect.SaturatingSetY(nTmp); } - else if (rValue.Name == "ViewAreaLeft" ) + else if (rValue.Name == "ViewAreaLeft") { rValue.Value >>= nTmp; aRect.SaturatingSetX(nTmp); } - else if (rValue.Name == "ViewAreaWidth" ) + else if (rValue.Name == "ViewAreaWidth") { rValue.Value >>= nTmp; - Size aSize( aRect.GetSize() ); - aSize.setWidth( nTmp ); + Size aSize(aRect.GetSize()); + aSize.setWidth(nTmp); aRect.SaturatingSetSize(aSize); } - else if (rValue.Name == "ViewAreaHeight" ) + else if (rValue.Name == "ViewAreaHeight") { rValue.Value >>= nTmp; - Size aSize( aRect.GetSize() ); - aSize.setHeight( nTmp ); + Size aSize(aRect.GetSize()); + aSize.setHeight(nTmp); aRect.SaturatingSetSize(aSize); } } - pDocShell->SetVisArea ( aRect ); + pDocShell->SetVisArea(aRect); } void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfProps) { - uno::Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY ); - if ( !xProps.is() ) + uno::Reference<XPropertySet> xProps(GetModel(), UNO_QUERY); + if (!xProps.is()) return; - Reference < XPropertySetInfo > xInfo ( xProps->getPropertySetInfo() ); - if (!xInfo.is() ) + Reference<XPropertySetInfo> xInfo(xProps->getPropertySetInfo()); + if (!xInfo.is()) return; - const OUString sFormula ( "Formula" ); - const OUString sBasicLibraries ( "BasicLibraries" ); - const OUString sDialogLibraries ( "DialogLibraries" ); - for ( const PropertyValue& rValue : aConfProps ) + const OUString sFormula("Formula"); + const OUString sBasicLibraries("BasicLibraries"); + const OUString sDialogLibraries("DialogLibraries"); + for (const PropertyValue& rValue : aConfProps) { - if (rValue.Name != sFormula && - rValue.Name != sBasicLibraries && - rValue.Name != sDialogLibraries) + if (rValue.Name != sFormula && rValue.Name != sBasicLibraries + && rValue.Name != sDialogLibraries) { try { - if ( xInfo->hasPropertyByName( rValue.Name ) ) - xProps->setPropertyValue( rValue.Name, rValue.Value ); + if (xInfo->hasPropertyByName(rValue.Name)) + xProps->setPropertyValue(rValue.Name, rValue.Value); } - catch (const beans::PropertyVetoException &) + catch (const beans::PropertyVetoException&) { // dealing with read-only properties here. Nothing to do... } @@ -2682,7 +2670,7 @@ void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfP } } -extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportMML(SvStream &rStream) +extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportMML(SvStream& rStream) { SmGlobals::ensure(); @@ -2704,7 +2692,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportMML(SvStream &rStream) try { - nRet = SmXMLImportWrapper::ReadThroughComponent(xStream, xModel, xContext, xInfoSet, "com.sun.star.comp.Math.XMLImporter", false); + nRet = SmXMLImportWrapper::ReadThroughComponent( + xStream, xModel, xContext, xInfoSet, "com.sun.star.comp.Math.XMLImporter", false); } catch (...) { diff --git a/starmath/source/mathmlimport.hxx b/starmath/source/mathmlimport.hxx index c57219fd0d8a..f390483e9be0 100644 --- a/starmath/source/mathmlimport.hxx +++ b/starmath/source/mathmlimport.hxx @@ -28,11 +28,13 @@ class SmNode; class SfxMedium; -namespace com::sun::star { - namespace beans { - class XPropertySet; } +namespace com::sun::star +{ +namespace beans +{ +class XPropertySet; +} } - typedef std::deque<std::unique_ptr<SmNode>> SmNodeStack; @@ -41,68 +43,65 @@ class SmXMLImportWrapper css::uno::Reference<css::frame::XModel> xModel; public: - explicit SmXMLImportWrapper(css::uno::Reference<css::frame::XModel> const &rRef) - : xModel(rRef) {} + explicit SmXMLImportWrapper(css::uno::Reference<css::frame::XModel> const& rRef) + : xModel(rRef) + { + } - ErrCode Import(SfxMedium &rMedium); + ErrCode Import(SfxMedium& rMedium); - static ErrCode ReadThroughComponent( - const css::uno::Reference< css::io::XInputStream >& xInputStream, - const css::uno::Reference< css::lang::XComponent >& xModelComponent, - css::uno::Reference< css::uno::XComponentContext > const & rxContext, - css::uno::Reference< css::beans::XPropertySet > const & rPropSet, - const char* pFilterName, - bool bEncrypted ); + static ErrCode + ReadThroughComponent(const css::uno::Reference<css::io::XInputStream>& xInputStream, + const css::uno::Reference<css::lang::XComponent>& xModelComponent, + css::uno::Reference<css::uno::XComponentContext> const& rxContext, + css::uno::Reference<css::beans::XPropertySet> const& rPropSet, + const char* pFilterName, bool bEncrypted); static ErrCode ReadThroughComponent( - const css::uno::Reference< css::embed::XStorage >& xStorage, - const css::uno::Reference< css::lang::XComponent >& xModelComponent, - const char* pStreamName, - css::uno::Reference< css::uno::XComponentContext > const & rxContext, - css::uno::Reference< css::beans::XPropertySet > const & rPropSet, - const char* pFilterName ); + const css::uno::Reference<css::embed::XStorage>& xStorage, + const css::uno::Reference<css::lang::XComponent>& xModelComponent, const char* pStreamName, + css::uno::Reference<css::uno::XComponentContext> const& rxContext, + css::uno::Reference<css::beans::XPropertySet> const& rPropSet, const char* pFilterName); }; - class SmXMLImport : public SvXMLImport { - SmNodeStack aNodeStack; - bool bSuccess; - int nParseDepth; - OUString aText; + SmNodeStack aNodeStack; + bool bSuccess; + int nParseDepth; + OUString aText; public: - SmXMLImport( - const css::uno::Reference< css::uno::XComponentContext >& rContext, - OUString const & implementationName, SvXMLImportFlags nImportFlags); - virtual ~SmXMLImport() throw () override; + SmXMLImport(const css::uno::Reference<css::uno::XComponentContext>& rContext, + OUString const& implementationName, SvXMLImportFlags nImportFlags); + virtual ~SmXMLImport() throw() override; // XUnoTunnel - sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; - static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw(); + sal_Int64 SAL_CALL getSomething(const css::uno::Sequence<sal_Int8>& rId) override; + static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() throw(); void SAL_CALL endDocument() override; - SvXMLImportContext *CreateFastContext( sal_Int32 nElement, - const css::uno::Reference< - css::xml::sax::XFastAttributeList >& xAttrList ) override; + SvXMLImportContext* CreateFastContext( + sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override; - SmNodeStack & GetNodeStack() { return aNodeStack; } + SmNodeStack& GetNodeStack() { return aNodeStack; } - bool GetSuccess() const { return bSuccess; } + bool GetSuccess() const { return bSuccess; } [[nodiscard]] const OUString& GetText() const { return aText; } - void SetText(const OUString &rStr) { aText = rStr; } + void SetText(const OUString& rStr) { aText = rStr; } - virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override; - virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override; + virtual void + SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override; + virtual void SetConfigurationSettings( + const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override; void IncParseDepth() { ++nParseDepth; } bool TooDeep() const { return nParseDepth >= 2048; } void DecParseDepth() { --nParseDepth; } }; - - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |