crashtesting: exception during dtor
Change-Id: I9874778ba79540cfde32bf59c3a63ebb72889dc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141215 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
@@ -50,6 +50,9 @@ public:
|
||||
|
||||
~FastSerializerHelper();
|
||||
|
||||
void startDocument();
|
||||
void endDocument();
|
||||
|
||||
/// Start an element. After the first argument there can be a number of (attribute, value) pairs.
|
||||
template<typename... Args>
|
||||
void startElement(sal_Int32 elementTokenId, sal_Int32 attribute, const char* value, Args &&... args)
|
||||
|
@@ -697,6 +697,8 @@ writeCoreProperties( XmlFilterBase& rSelf, const Reference< XDocumentProperties
|
||||
}
|
||||
|
||||
pCoreProps->endElementNS( XML_cp, XML_coreProperties );
|
||||
|
||||
pCoreProps->endDocument();
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -819,6 +821,8 @@ writeAppProperties( XmlFilterBase& rSelf, const Reference< XDocumentProperties >
|
||||
}
|
||||
|
||||
pAppProps->endElement( XML_Properties );
|
||||
|
||||
pAppProps->endDocument();
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -937,6 +941,8 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie
|
||||
++nIndex;
|
||||
}
|
||||
pAppProps->endElement( XML_Properties );
|
||||
|
||||
pAppProps->endDocument();
|
||||
}
|
||||
|
||||
void XmlFilterBase::exportDocumentProperties( const Reference< XDocumentProperties >& xProperties, bool bSecurityOptOpenReadOnly )
|
||||
|
@@ -874,6 +874,8 @@ void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nI
|
||||
|
||||
SetFS( pChart );
|
||||
ExportContent();
|
||||
SetFS( pFS );
|
||||
pChart->endDocument();
|
||||
}
|
||||
|
||||
void ChartExport::InitRangeSegmentationProperties( const Reference< chart2::XChartDocument > & xChartDoc )
|
||||
@@ -1115,6 +1117,7 @@ void ChartExport::exportAdditionalShapes( const Reference< css::chart::XChartDoc
|
||||
pDrawing->endElement(FSNS(XML_cdr, XML_relSizeAnchor));
|
||||
}
|
||||
pDrawing->endElement(FSNS(XML_c, XML_userShapes));
|
||||
pDrawing->endDocument();
|
||||
}
|
||||
}
|
||||
catch (const uno::Exception&)
|
||||
|
@@ -17,6 +17,7 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include <sal/log.hxx>
|
||||
#include <sax/fshelper.hxx>
|
||||
#include "fastserializer.hxx"
|
||||
|
||||
@@ -29,12 +30,27 @@ FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >&
|
||||
mpSerializer(new FastSaxSerializer(xOutputStream))
|
||||
{
|
||||
if( bWriteHeader )
|
||||
mpSerializer->startDocument();
|
||||
startDocument();
|
||||
}
|
||||
|
||||
void FastSerializerHelper::startDocument()
|
||||
{
|
||||
mpSerializer->startDocument();
|
||||
}
|
||||
|
||||
void FastSerializerHelper::endDocument()
|
||||
{
|
||||
std::unique_ptr<FastSaxSerializer> xSerializer(std::move(mpSerializer));
|
||||
xSerializer->endDocument();
|
||||
}
|
||||
|
||||
FastSerializerHelper::~FastSerializerHelper()
|
||||
{
|
||||
mpSerializer->endDocument();
|
||||
if (mpSerializer)
|
||||
{
|
||||
assert(false && "call endDocument explicitly before dtor to avoid potential exceptions during dtor");
|
||||
endDocument();
|
||||
}
|
||||
}
|
||||
|
||||
void FastSerializerHelper::startElement(sal_Int32 elementTokenId)
|
||||
|
@@ -1113,6 +1113,12 @@ bool XclExpXmlStream::exportDocument()
|
||||
|
||||
PopStream();
|
||||
// Free all FSHelperPtr, to flush data before committing storage
|
||||
for (auto& entry : maOpenedStreamMap)
|
||||
{
|
||||
if (!entry.second.second)
|
||||
continue;
|
||||
entry.second.second->endDocument();
|
||||
}
|
||||
maOpenedStreamMap.clear();
|
||||
|
||||
commitStorage();
|
||||
|
@@ -499,8 +499,15 @@ bool PowerPointExport::exportDocument()
|
||||
WriteModifyVerifier();
|
||||
|
||||
mPresentationFS->endElementNS(XML_p, XML_presentation);
|
||||
mPresentationFS->endDocument();
|
||||
mPresentationFS.reset();
|
||||
// Free all FSHelperPtr, to flush data before committing storage
|
||||
for (auto& serializer : mpSlidesFSArray)
|
||||
{
|
||||
if (!serializer)
|
||||
continue;
|
||||
serializer->endDocument();
|
||||
}
|
||||
mpSlidesFSArray.clear();
|
||||
|
||||
commitStorage();
|
||||
@@ -1087,6 +1094,8 @@ void PowerPointExport::WriteAuthors()
|
||||
}
|
||||
|
||||
pFS->endElementNS(XML_p, XML_cmAuthorLst);
|
||||
|
||||
pFS->endDocument();
|
||||
}
|
||||
|
||||
sal_Int32 PowerPointExport::GetAuthorIdAndLastIndex(const OUString& sAuthor, sal_Int32& nLastIndex)
|
||||
@@ -1178,6 +1187,8 @@ void PowerPointExport::WritePresentationProps()
|
||||
pFS->endElementNS(XML_p, XML_showPr);
|
||||
|
||||
pFS->endElementNS(XML_p, XML_presentationPr);
|
||||
|
||||
pFS->endDocument();
|
||||
}
|
||||
|
||||
bool PowerPointExport::WriteComments(sal_uInt32 nPageNum)
|
||||
@@ -1229,6 +1240,8 @@ bool PowerPointExport::WriteComments(sal_uInt32 nPageNum)
|
||||
|
||||
pFS->endElementNS(XML_p, XML_cmLst);
|
||||
|
||||
pFS->endDocument();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1454,6 +1467,8 @@ void PowerPointExport::ImplWriteNotes(sal_uInt32 nPageNum)
|
||||
u"../notesMasters/notesMaster1.xml");
|
||||
|
||||
SAL_INFO("sd.eppt", "-----------------");
|
||||
|
||||
pFS->endDocument();
|
||||
}
|
||||
|
||||
void PowerPointExport::AddLayoutIdAndRelation(const FSHelperPtr& pFS, sal_Int32 nLayoutFileId)
|
||||
@@ -1554,6 +1569,8 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 nPageNum, Reference< XPro
|
||||
pFS->endElementNS(XML_p, XML_sldMaster);
|
||||
|
||||
SAL_INFO("sd.eppt", "----------------");
|
||||
|
||||
pFS->endDocument();
|
||||
}
|
||||
|
||||
sal_Int32 PowerPointExport::GetLayoutFileId(sal_Int32 nOffset, sal_uInt32 nMasterNum)
|
||||
@@ -1623,6 +1640,8 @@ void PowerPointExport::ImplWritePPTXLayout(sal_Int32 nOffset, sal_uInt32 nMaster
|
||||
mnLayoutFileIdMax ++;
|
||||
|
||||
xDrawPages->remove(xSlide);
|
||||
|
||||
pFS->endDocument();
|
||||
}
|
||||
|
||||
void PowerPointExport::WriteShapeTree(const FSHelperPtr& pFS, PageType ePageType, bool bMaster)
|
||||
@@ -2303,6 +2322,8 @@ void PowerPointExport::WriteTheme(sal_Int32 nThemeNum, svx::Theme* pTheme)
|
||||
|
||||
pFS->endElementNS(XML_a, XML_themeElements);
|
||||
pFS->endElementNS(XML_a, XML_theme);
|
||||
|
||||
pFS->endDocument();
|
||||
}
|
||||
|
||||
bool PowerPointExport::ImplCreateDocument()
|
||||
@@ -2381,6 +2402,8 @@ void PowerPointExport::WriteNotesMaster()
|
||||
pFS->endElementNS(XML_p, XML_notesMaster);
|
||||
|
||||
SAL_INFO("sd.eppt", "----------------");
|
||||
|
||||
pFS->endDocument();
|
||||
}
|
||||
|
||||
void PowerPointExport::embedEffectAudio(const FSHelperPtr& pFS, const OUString& sUrl, OUString& sRelId, OUString& sName)
|
||||
|
@@ -401,6 +401,7 @@ OString DocxExport::OutputChart( uno::Reference< frame::XModel > const & xModel,
|
||||
#else
|
||||
(void)xModel;
|
||||
#endif
|
||||
pChartFS->endDocument();
|
||||
return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
|
||||
}
|
||||
|
||||
@@ -497,6 +498,8 @@ std::pair<OString, OString> DocxExport::WriteActiveXObject(const uno::Reference<
|
||||
sXMLFileName.subView(sBinaryFileName.indexOf("/") + 1)),
|
||||
RTL_TEXTENCODING_UTF8);
|
||||
|
||||
pActiveXFS->endDocument();
|
||||
|
||||
return std::pair<OString, OString>(sXMLId, sName);
|
||||
}
|
||||
|
||||
@@ -673,6 +676,8 @@ void DocxExport::InitStyles()
|
||||
|
||||
// switch the serializer back
|
||||
m_pAttrOutput->SetSerializer( m_pDocumentFS );
|
||||
|
||||
pStylesFS->endDocument();
|
||||
}
|
||||
|
||||
void DocxExport::WriteFootnotesEndnotes()
|
||||
@@ -702,6 +707,8 @@ void DocxExport::WriteFootnotesEndnotes()
|
||||
m_pVMLExport->SetFS(m_pDocumentFS);
|
||||
m_pSdrExport->setSerializer( m_pDocumentFS );
|
||||
m_pAttrOutput->SetSerializer( m_pDocumentFS );
|
||||
|
||||
pFootnotesFS->endDocument();
|
||||
}
|
||||
|
||||
if ( !m_pAttrOutput->HasEndnotes() )
|
||||
@@ -730,6 +737,8 @@ void DocxExport::WriteFootnotesEndnotes()
|
||||
m_pVMLExport->SetFS(m_pDocumentFS);
|
||||
m_pSdrExport->setSerializer( m_pDocumentFS );
|
||||
m_pAttrOutput->SetSerializer( m_pDocumentFS );
|
||||
|
||||
pEndnotesFS->endDocument();
|
||||
}
|
||||
|
||||
void DocxExport::WritePostitFields()
|
||||
@@ -750,6 +759,7 @@ void DocxExport::WritePostitFields()
|
||||
const auto eHasResolved = m_pAttrOutput->WritePostitFields();
|
||||
m_pAttrOutput->SetSerializer( m_pDocumentFS );
|
||||
pPostitFS->endElementNS( XML_w, XML_comments );
|
||||
pPostitFS->endDocument();
|
||||
|
||||
if (eHasResolved != DocxAttributeOutput::hasResolved::yes)
|
||||
return;
|
||||
@@ -770,6 +780,7 @@ void DocxExport::WritePostitFields()
|
||||
m_pAttrOutput->WritePostItFieldsResolved();
|
||||
m_pAttrOutput->SetSerializer(m_pDocumentFS);
|
||||
pPostitFS->endElementNS(XML_w15, XML_commentsEx);
|
||||
pPostitFS->endDocument();
|
||||
}
|
||||
|
||||
void DocxExport::WriteNumbering()
|
||||
@@ -808,6 +819,8 @@ void DocxExport::WriteNumbering()
|
||||
// switch the serializer back
|
||||
m_pDrawingML->SetFS( m_pDocumentFS );
|
||||
m_pAttrOutput->SetSerializer( m_pDocumentFS );
|
||||
|
||||
pNumberingFS->endDocument();
|
||||
}
|
||||
|
||||
void DocxExport::WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const char* pType )
|
||||
@@ -880,6 +893,8 @@ void DocxExport::WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const
|
||||
m_pDocumentFS->singleElementNS( XML_w, nReference,
|
||||
FSNS( XML_w, XML_type ), pType,
|
||||
FSNS( XML_r, XML_id ), aRelId );
|
||||
|
||||
pFS->endDocument();
|
||||
}
|
||||
|
||||
void DocxExport::WriteFonts()
|
||||
@@ -906,6 +921,8 @@ void DocxExport::WriteFonts()
|
||||
m_pAttrOutput->SetSerializer( m_pDocumentFS );
|
||||
|
||||
pFS->endElementNS( XML_w, XML_fonts );
|
||||
|
||||
pFS->endDocument();
|
||||
}
|
||||
|
||||
void DocxExport::WriteProperties( )
|
||||
@@ -1431,6 +1448,8 @@ void DocxExport::WriteSettings()
|
||||
|
||||
// finish settings.xml
|
||||
pFS->endElementNS( XML_w, XML_settings );
|
||||
|
||||
pFS->endDocument();
|
||||
}
|
||||
|
||||
void DocxExport::WriteTheme()
|
||||
@@ -2102,6 +2121,7 @@ DocxExport::DocxExport(DocxExportFilter& rFilter, SwDoc& rDocument,
|
||||
|
||||
DocxExport::~DocxExport()
|
||||
{
|
||||
m_pDocumentFS->endDocument();
|
||||
}
|
||||
|
||||
DocxSettingsData::DocxSettingsData()
|
||||
|
Reference in New Issue
Block a user