summaryrefslogtreecommitdiff
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
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>
-rw-r--r--include/xmloff/xmlexp.hxx3
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx32
-rw-r--r--sc/source/filter/xml/xmlexprt.hxx2
-rw-r--r--sw/source/filter/xml/xmlexp.hxx2
-rw-r--r--sw/source/filter/xml/xmlfmte.cxx34
-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
11 files changed, 122 insertions, 24 deletions
diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx
index eeedd1bc09fa..2764516728e2 100644
--- a/include/xmloff/xmlexp.hxx
+++ b/include/xmloff/xmlexp.hxx
@@ -264,6 +264,7 @@ protected:
void SetDocHandler( const css::uno::Reference< css::xml::sax::XDocumentHandler > &rHandler );
+ bool mbAutoStylesCollected;
public:
SvXMLExport(
@@ -291,6 +292,8 @@ public:
virtual ~SvXMLExport() override;
+ virtual void collectAutoStyles();
+
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
static SvXMLExport* getImplementation( const css::uno::Reference< css::uno::XInterface >& ) throw();
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 4f8b61980106..27c94380fa5c 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2271,8 +2271,13 @@ static uno::Any lcl_GetEnumerated( uno::Reference<container::XEnumerationAccess>
return aRet;
}
-void ScXMLExport::ExportAutoStyles_()
+void ScXMLExport::collectAutoStyles()
{
+ SvXMLExport::collectAutoStyles();
+
+ if (mbAutoStylesCollected)
+ return;
+
if (!GetModel().is())
return;
@@ -2664,7 +2669,31 @@ void ScXMLExport::ExportAutoStyles_()
}
pChangeTrackingExportHelper->CollectAutoStyles();
+ }
+
+ if (getExportFlags() & SvXMLExportFlags::MASTERSTYLES)
+ GetPageExport()->collectAutoStyles(true);
+
+ mbAutoStylesCollected = true;
+}
+void ScXMLExport::ExportAutoStyles_()
+{
+ if (!GetModel().is())
+ return;
+
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY );
+ if (!xSpreadDoc.is())
+ return;
+
+ uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
+ if (!xIndex.is())
+ return;
+
+ collectAutoStyles();
+
+ if (getExportFlags() & SvXMLExportFlags::CONTENT)
+ {
GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN);
GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_ROW);
GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_TABLE);
@@ -2693,7 +2722,6 @@ void ScXMLExport::ExportAutoStyles_()
if (getExportFlags() & SvXMLExportFlags::MASTERSTYLES)
{
- GetPageExport()->collectAutoStyles(true);
GetPageExport()->exportAutoStyles();
}
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index e0eeea036dc7..c551fbe2e96f 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -236,6 +236,8 @@ public:
virtual ~ScXMLExport() override;
+ void collectAutoStyles() override;
+
static sal_Int16 GetMeasureUnit();
ScDocument* GetDocument() { return pDoc; }
const ScDocument* GetDocument() const { return pDoc; }
diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx
index 089521486998..211f50840da6 100644
--- a/sw/source/filter/xml/xmlexp.hxx
+++ b/sw/source/filter/xml/xmlexp.hxx
@@ -114,6 +114,8 @@ public:
virtual ~SwXMLExport() override;
+ void collectAutoStyles() override;
+
virtual ErrCode exportDoc( enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_TOKEN_INVALID ) override;
inline const SvXMLUnitConverter& GetTwipUnitConverter() const;
diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx
index 6c2d08571f14..d099a91c9e12 100644
--- a/sw/source/filter/xml/xmlfmte.cxx
+++ b/sw/source/filter/xml/xmlfmte.cxx
@@ -169,12 +169,16 @@ void SwXMLExport::ExportStyles_( bool bUsed )
GetPageExport()->exportDefaultStyle();
}
-void SwXMLExport::ExportAutoStyles_()
+void SwXMLExport::collectAutoStyles()
{
+ SvXMLExport::collectAutoStyles();
+
+ if (mbAutoStylesCollected)
+ return;
+
// The order in which styles are collected *MUST* be the same as
// the order in which they are exported. Otherwise, caching will
// fail.
-
if( getExportFlags() & (SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::CONTENT) )
{
if( !(getExportFlags() & SvXMLExportFlags::CONTENT) )
@@ -190,17 +194,10 @@ void SwXMLExport::ExportAutoStyles_()
if( getExportFlags() & SvXMLExportFlags::MASTERSTYLES )
GetPageExport()->collectAutoStyles( false );
- // if we don't export styles (i.e. in content stream only, but not
- // in single-stream case), then we can save ourselves a bit of
- // work and memory by not collecting field masters
- if( !(getExportFlags() & SvXMLExportFlags::STYLES) )
- GetTextParagraphExport()->exportUsedDeclarations();
// exported in ExportContent_
if( getExportFlags() & SvXMLExportFlags::CONTENT )
{
- GetTextParagraphExport()->exportTrackedChanges( true );
-
// collect form autostyle
// (do this before collectTextAutoStyles, 'cause the shapes need the results of the work
// done by examineForms)
@@ -215,6 +212,25 @@ void SwXMLExport::ExportAutoStyles_()
GetTextParagraphExport()->collectTextAutoStylesOptimized( m_bShowProgress );
}
+ mbAutoStylesCollected = true;
+}
+
+void SwXMLExport::ExportAutoStyles_()
+{
+ collectAutoStyles();
+
+ // if we don't export styles (i.e. in content stream only, but not
+ // in single-stream case), then we can save ourselves a bit of
+ // work and memory by not collecting field masters
+ if( !(getExportFlags() & SvXMLExportFlags::STYLES) )
+ GetTextParagraphExport()->exportUsedDeclarations();
+
+ // exported in ExportContent_
+ if( getExportFlags() & SvXMLExportFlags::CONTENT )
+ {
+ GetTextParagraphExport()->exportTrackedChanges( true );
+ }
+
GetTextParagraphExport()->exportTextAutoStyles();
GetShapeExport()->exportAutoStyles();
if( getExportFlags() & SvXMLExportFlags::MASTERSTYLES )
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;