summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-07-12 16:37:18 +0200
committerTomaž Vajngerl <quikee@gmail.com>2018-07-12 21:08:03 +0200
commit1a8435a23e84f3ceeee580eb9d4404a738d98888 (patch)
tree4f69a838844886417bd491f9cfd4dfc5b074151a /xmloff
parent68d3a44bc96041982cb38c140c0f9628dc8547c5 (diff)
tdf#65353 separate autostyle collection and export
To be able to look which fonts are in use, we need to collect the autostyles which contains all styles that are used in a document. Previously the autostyles were collected in the same process as they were expoted, so with this commit we separate collaction and export. First we collacte the auto styles, then e can use them in embedded fonts export, the last we export the auto styles themselves. Change-Id: Ib939f1119f4af00a1e5d66fcd2e04b9d2add6881 Reviewed-on: https://gerrit.libreoffice.org/57348 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/SchXMLExport.hxx1
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx25
-rw-r--r--xmloff/source/core/xmlexp.cxx13
-rw-r--r--xmloff/source/draw/sdxmlexp.cxx30
-rw-r--r--xmloff/source/draw/sdxmlexp_impl.hxx2
-rw-r--r--xmloff/source/style/XMLFontAutoStylePool.cxx2
6 files changed, 60 insertions, 13 deletions
diff --git a/xmloff/inc/SchXMLExport.hxx b/xmloff/inc/SchXMLExport.hxx
index cc0835d400f7..eacdfca75419 100644
--- a/xmloff/inc/SchXMLExport.hxx
+++ b/xmloff/inc/SchXMLExport.hxx
@@ -54,6 +54,7 @@ public:
SvXMLExportFlags nExportFlags );
virtual ~SchXMLExport() override;
+ void collectAutoStyles() override;
rtl::Reference< XMLPropertySetMapper > const & GetPropertySetMapper() const;
};
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index db0cc741013f..20a6847f1d5e 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -3531,8 +3531,13 @@ void SchXMLExport::ExportMasterStyles_()
SAL_INFO("xmloff.chart", "Master Style Export requested. Not available for Chart" );
}
-void SchXMLExport::ExportAutoStyles_()
+void SchXMLExport::collectAutoStyles()
{
+ SvXMLExport::collectAutoStyles();
+
+ if (mbAutoStylesCollected)
+ return;
+
// there are no styles that require their own autostyles
if( getExportFlags() & SvXMLExportFlags::CONTENT )
{
@@ -3540,6 +3545,24 @@ void SchXMLExport::ExportAutoStyles_()
if( xChartDoc.is())
{
maExportHelper->m_pImpl->collectAutoStyles( xChartDoc );
+ }
+ else
+ {
+ SAL_WARN("xmloff.chart", "Couldn't export chart due to wrong XModel (must be XChartDocument)" );
+ }
+ }
+ mbAutoStylesCollected = true;
+}
+
+void SchXMLExport::ExportAutoStyles_()
+{
+ collectAutoStyles();
+
+ if( getExportFlags() & SvXMLExportFlags::CONTENT )
+ {
+ Reference< chart::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
+ if( xChartDoc.is())
+ {
maExportHelper->m_pImpl->exportAutoStyles();
}
else
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 57780431d090..28074c4724a1 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -448,7 +448,8 @@ SvXMLExport::SvXMLExport(
mnExportFlags( nExportFlags ),
mnErrorFlags( SvXMLErrorFlags::NO ),
msWS( GetXMLToken(XML_WS) ),
- mbSaveLinkedSections(true)
+ mbSaveLinkedSections(true),
+ mbAutoStylesCollected(false)
{
SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" );
InitCtor_();
@@ -477,7 +478,8 @@ SvXMLExport::SvXMLExport(
mnExportFlags( SvXMLExportFlags::NONE ),
mnErrorFlags( SvXMLErrorFlags::NO ),
msWS( GetXMLToken(XML_WS) ),
- mbSaveLinkedSections(true)
+ mbSaveLinkedSections(true),
+ mbAutoStylesCollected(false)
{
SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" );
mpImpl->SetSchemeOf( msOrigFileName );
@@ -516,7 +518,8 @@ SvXMLExport::SvXMLExport(
mnExportFlags( nExportFlag ),
mnErrorFlags( SvXMLErrorFlags::NO ),
msWS( GetXMLToken(XML_WS) ),
- mbSaveLinkedSections(true)
+ mbSaveLinkedSections(true),
+ mbAutoStylesCollected(false)
{
SAL_WARN_IF(!xContext.is(), "xmloff.core", "got no service manager" );
mpImpl->SetSchemeOf( msOrigFileName );
@@ -1753,6 +1756,10 @@ SvXMLAutoStylePoolP* SvXMLExport::CreateAutoStylePool()
return new SvXMLAutoStylePoolP(*this);
}
+void SvXMLExport::collectAutoStyles()
+{
+}
+
XMLPageExport* SvXMLExport::CreatePageExport()
{
return new XMLPageExport( *this );
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 5e6694179778..29ce8b730135 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -2085,8 +2085,12 @@ void SdXMLExport::ExportStyles_(bool bUsed)
}
}
-void SdXMLExport::ExportAutoStyles_()
+void SdXMLExport::collectAutoStyles()
{
+ SvXMLExport::collectAutoStyles();
+ if (mbAutoStylesCollected)
+ return;
+
Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
if( xInfoSet.is() )
{
@@ -2106,9 +2110,6 @@ void SdXMLExport::ExportAutoStyles_()
// prepare page-master infos
ImpPrepPageMasterInfos();
- // write page-master infos
- ImpWritePageMasterInfos();
-
// prepare draw:style-name for master page export
ImpPrepMasterPageInfos();
}
@@ -2119,9 +2120,6 @@ void SdXMLExport::ExportAutoStyles_()
ImpPrepDrawPageInfos();
}
- // export draw-page styles
- GetAutoStylePool()->exportXML( XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID );
-
if( getExportFlags() & SvXMLExportFlags::STYLES )
{
// create auto style infos for shapes on master handout page
@@ -2256,13 +2254,29 @@ void SdXMLExport::ExportAutoStyles_()
collectAnnotationAutoStyles( xDrawPage );
}
}
- if(IsImpress())
+ if (IsImpress())
{
rtl::Reference< XMLAnimationsExporter > xAnimExport;
GetShapeExport()->setAnimationsExporter( xAnimExport );
}
}
+ mbAutoStylesCollected = true;
+}
+
+void SdXMLExport::ExportAutoStyles_()
+{
+ collectAutoStyles();
+
+ if( getExportFlags() & SvXMLExportFlags::STYLES )
+ {
+ // write page-master infos
+ ImpWritePageMasterInfos();
+ }
+
+ // export draw-page styles
+ GetAutoStylePool()->exportXML( XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID );
+
exportAutoDataStyles();
GetShapeExport()->exportAutoStyles();
diff --git a/xmloff/source/draw/sdxmlexp_impl.hxx b/xmloff/source/draw/sdxmlexp_impl.hxx
index f583c0ee9e2e..3b2a43bd3545 100644
--- a/xmloff/source/draw/sdxmlexp_impl.hxx
+++ b/xmloff/source/draw/sdxmlexp_impl.hxx
@@ -161,6 +161,8 @@ public:
bool bIsDraw, SvXMLExportFlags nExportFlags );
virtual ~SdXMLExport() override;
+ void collectAutoStyles() override;
+
// XExporter
virtual void SAL_CALL setSourceDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx
index 029db3c3b421..b0515a1bbea9 100644
--- a/xmloff/source/style/XMLFontAutoStylePool.cxx
+++ b/xmloff/source/style/XMLFontAutoStylePool.cxx
@@ -356,7 +356,7 @@ std::unordered_set<OUString> XMLFontAutoStylePool::getUsedFontList()
}
// make sure auto-styles are collected
- GetExport().GetTextParagraphExport()->collectTextAutoStylesOptimized(false);
+ GetExport().collectAutoStyles();
// Check auto-styles for fonts
std::vector<xmloff::AutoStyleEntry> aAutoStyleEntries;