This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push:
new 51be0a98fe Fix exception specification in a few places where they were
missing, and causing AOO to crash when compiled with Clang.
51be0a98fe is described below
commit 51be0a98fead28b15570c923f30b8423deec75ce
Author: Damjan Jovanovic <[email protected]>
AuthorDate: Sun Jul 7 20:14:26 2024 +0200
Fix exception specification in a few places where they were missing,
and causing AOO to crash when compiled with Clang.
Also fix formatting of some writerfilter code.
Partially fixes: https://bz.apache.org/ooo/show_bug.cgi?id=127252
Patch by: me
(cherry picked from commit ab0bad1672c1433536a0fd2143f31efcc5754d80)
---
main/oox/source/docprop/ooxmldocpropimport.cxx | 2 +-
main/writerfilter/source/filter/ImportFilter.cxx | 74 ++++++++++++----------
main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx | 5 +-
main/writerfilter/source/ooxml/OOXMLStreamImpl.hxx | 13 ++--
4 files changed, 55 insertions(+), 39 deletions(-)
diff --git a/main/oox/source/docprop/ooxmldocpropimport.cxx
b/main/oox/source/docprop/ooxmldocpropimport.cxx
index b2814e48c9..ddc8fc1f6d 100644
--- a/main/oox/source/docprop/ooxmldocpropimport.cxx
+++ b/main/oox/source/docprop/ooxmldocpropimport.cxx
@@ -72,7 +72,7 @@ Reference< XInterface > SAL_CALL
DocumentPropertiesImport_createInstance( const
namespace {
-Sequence< InputSource > lclGetRelatedStreams( const Reference< XStorage >&
rxStorage, const OUString& rStreamType ) throw (RuntimeException)
+Sequence< InputSource > lclGetRelatedStreams( const Reference< XStorage >&
rxStorage, const OUString& rStreamType ) throw (RuntimeException, Exception)
{
Reference< XRelationshipAccess > xRelation( rxStorage, UNO_QUERY_THROW );
Reference< XHierarchicalStorageAccess > xHierarchy( rxStorage,
UNO_QUERY_THROW );
diff --git a/main/writerfilter/source/filter/ImportFilter.cxx
b/main/writerfilter/source/filter/ImportFilter.cxx
index eb7c3a833a..0197f9e75a 100644
--- a/main/writerfilter/source/filter/ImportFilter.cxx
+++ b/main/writerfilter/source/filter/ImportFilter.cxx
@@ -97,44 +97,52 @@ sal_Bool WriterFilter::filter( const uno::Sequence<
beans::PropertyValue >& aDes
dmapperLogger->startDocument();
#endif
- writerfilter::dmapper::SourceDocumentType eType =
- (m_sFilterName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM (
"writer_MS_Word_2007" ) ) ||
- m_sFilterName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM (
"writer_MS_Word_2007_Template" ) )) ?
- writerfilter::dmapper::DOCUMENT_OOXML :
writerfilter::dmapper::DOCUMENT_DOC;
- writerfilter::Stream::Pointer_t pStream(new
writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc,
eType));
- //create the tokenizer and domain mapper
- if( eType == writerfilter::dmapper::DOCUMENT_OOXML )
- {
- writerfilter::ooxml::OOXMLStream::Pointer_t pDocStream =
writerfilter::ooxml::OOXMLDocumentFactory::createStream(m_xContext,
xInputStream);
- writerfilter::ooxml::OOXMLDocument::Pointer_t
pDocument(writerfilter::ooxml::OOXMLDocumentFactory::createDocument(pDocStream));
-
- uno::Reference<frame::XModel> xModel(m_xDstDoc, uno::UNO_QUERY_THROW);
- pDocument->setModel(xModel);
-
- uno::Reference<drawing::XDrawPageSupplier> xDrawings
- (m_xDstDoc, uno::UNO_QUERY_THROW);
- uno::Reference<drawing::XDrawPage> xDrawPage
- (xDrawings->getDrawPage(), uno::UNO_SET_THROW);
- pDocument->setDrawPage(xDrawPage);
-
- pDocument->resolve(*pStream);
- }
- else
- {
- writerfilter::doctok::WW8Stream::Pointer_t pDocStream =
writerfilter::doctok::WW8DocumentFactory::createStream(m_xContext,
xInputStream);
- writerfilter::doctok::WW8Document::Pointer_t
pDocument(writerfilter::doctok::WW8DocumentFactory::createDocument(pDocStream));
+ writerfilter::dmapper::SourceDocumentType eType =
+ (m_sFilterName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM (
"writer_MS_Word_2007" ) ) ||
+ m_sFilterName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM (
"writer_MS_Word_2007_Template" ) )) ?
+ writerfilter::dmapper::DOCUMENT_OOXML :
writerfilter::dmapper::DOCUMENT_DOC;
+ writerfilter::Stream::Pointer_t pStream(new
writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc,
eType));
+ //create the tokenizer and domain mapper
+ if( eType == writerfilter::dmapper::DOCUMENT_OOXML )
+ {
+ writerfilter::ooxml::OOXMLStream::Pointer_t pDocStream;
+ try
+ {
+ pDocStream =
writerfilter::ooxml::OOXMLDocumentFactory::createStream(m_xContext,
xInputStream);
+ }
+ catch (uno::Exception &e)
+ {
+ throw uno::RuntimeException(e.Message, uno::Reference<
uno::XInterface >());
+ }
+ writerfilter::ooxml::OOXMLDocument::Pointer_t
pDocument(writerfilter::ooxml::OOXMLDocumentFactory::createDocument(pDocStream));
+
+ uno::Reference<frame::XModel> xModel(m_xDstDoc,
uno::UNO_QUERY_THROW);
+ pDocument->setModel(xModel);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDrawings
+ (m_xDstDoc, uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage
+ (xDrawings->getDrawPage(), uno::UNO_SET_THROW);
+ pDocument->setDrawPage(xDrawPage);
+
+ pDocument->resolve(*pStream);
+ }
+ else
+ {
+ writerfilter::doctok::WW8Stream::Pointer_t pDocStream =
writerfilter::doctok::WW8DocumentFactory::createStream(m_xContext,
xInputStream);
+ writerfilter::doctok::WW8Document::Pointer_t
pDocument(writerfilter::doctok::WW8DocumentFactory::createDocument(pDocStream));
- pDocument->resolve(*pStream);
- }
+ pDocument->resolve(*pStream);
+ }
#ifdef DEBUG_IMPORT
- writerfilter::TagLogger::dump("DOMAINMAPPER");
- dmapperLogger->endDocument();
- writerfilter::TagLogger::dump("DEBUG");
- debugLogger->endDocument();
+ writerfilter::TagLogger::dump("DOMAINMAPPER");
+ dmapperLogger->endDocument();
+ writerfilter::TagLogger::dump("DEBUG");
+ debugLogger->endDocument();
#endif
- return sal_True;
+ return sal_True;
}
return sal_False;
}
diff --git a/main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
b/main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
index a3d39cf61e..a73975b9c7 100644
--- a/main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
+++ b/main/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
@@ -41,6 +41,7 @@ using namespace ::std;
OOXMLStreamImpl::OOXMLStreamImpl
(uno::Reference<uno::XComponentContext> xContext,
uno::Reference<io::XInputStream> xStorageStream, StreamType_t nType)
+throw (uno::Exception)
: mxContext(xContext), mxStorageStream(xStorageStream), mnStreamType(nType)
{
mxStorage.set
@@ -53,6 +54,7 @@ OOXMLStreamImpl::OOXMLStreamImpl
OOXMLStreamImpl::OOXMLStreamImpl
(OOXMLStreamImpl & rOOXMLStream, StreamType_t nStreamType)
+throw (uno::Exception)
: mxContext(rOOXMLStream.mxContext),
mxStorageStream(rOOXMLStream.mxStorageStream),
mxStorage(rOOXMLStream.mxStorage),
@@ -66,6 +68,7 @@ OOXMLStreamImpl::OOXMLStreamImpl
OOXMLStreamImpl::OOXMLStreamImpl
(OOXMLStreamImpl & rOOXMLStream, const rtl::OUString & rId)
+throw (uno::Exception)
: mxContext(rOOXMLStream.mxContext),
mxStorageStream(rOOXMLStream.mxStorageStream),
mxStorage(rOOXMLStream.mxStorage),
@@ -244,7 +247,7 @@ bool
OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
return ::rtl::OUString();
}
-void OOXMLStreamImpl::init()
+void OOXMLStreamImpl::init() throw (uno::Exception)
{
bool bFound = lcl_getTarget(mxRelationshipAccess,
mnStreamType, msId, msTarget);
diff --git a/main/writerfilter/source/ooxml/OOXMLStreamImpl.hxx
b/main/writerfilter/source/ooxml/OOXMLStreamImpl.hxx
index 133b0b0920..b7335d49ed 100644
--- a/main/writerfilter/source/ooxml/OOXMLStreamImpl.hxx
+++ b/main/writerfilter/source/ooxml/OOXMLStreamImpl.hxx
@@ -36,7 +36,7 @@ using namespace com::sun::star;
class OOXMLStreamImpl : public OOXMLStream
{
- void init();
+ void init() throw (uno::Exception);
uno::Reference<uno::XComponentContext> mxContext;
uno::Reference<io::XInputStream> mxStorageStream;
@@ -61,12 +61,17 @@ public:
typedef boost::shared_ptr<OOXMLStreamImpl> Pointer_t;
OOXMLStreamImpl
- (OOXMLStreamImpl & rStream, StreamType_t nType);
+ (OOXMLStreamImpl & rStream, StreamType_t nType)
+ throw (uno::Exception);
+
OOXMLStreamImpl
(uno::Reference<uno::XComponentContext> xContext,
uno::Reference<io::XInputStream> xStorageStream,
- StreamType_t nType);
- OOXMLStreamImpl(OOXMLStreamImpl & rStream, const rtl::OUString & rId);
+ StreamType_t nType)
+ throw (uno::Exception);
+
+ OOXMLStreamImpl(OOXMLStreamImpl & rStream, const rtl::OUString & rId)
+ throw (uno::Exception);
virtual ~OOXMLStreamImpl();