Kaydet (Commit) 1a8435a2 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

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: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 68d3a44b
......@@ -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();
......
......@@ -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();
}
......
......@@ -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; }
......
......@@ -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;
......
......@@ -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 )
......
......@@ -54,6 +54,7 @@ public:
SvXMLExportFlags nExportFlags );
virtual ~SchXMLExport() override;
void collectAutoStyles() override;
rtl::Reference< XMLPropertySetMapper > const & GetPropertySetMapper() const;
};
......
......@@ -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
......
......@@ -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 );
......
......@@ -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();
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment