summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-11-29 16:09:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-11-30 08:38:57 +0100
commit01a3cc1e55034f7703219d4bbb209de7c37bf07b (patch)
tree42a5f54b8f9bc3083fb7e6796a1721afe820e983 /xmloff
parent79553e784c6d4587814bc2a577d7251c458df8d4 (diff)
tdf#133343 collect autostyle prop names
before scanning for autostyles. That way we can collect only the property state we are interested in, instead of all properties. Change-Id: I8da4d61401d904631cbf9dc1828266950fe98421 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143466 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx3
-rw-r--r--xmloff/source/draw/sdxmlexp.cxx12
-rw-r--r--xmloff/source/draw/shapeexport.cxx11
-rw-r--r--xmloff/source/style/impastpl.cxx13
-rw-r--r--xmloff/source/style/impastpl.hxx3
-rw-r--r--xmloff/source/style/xmlaustp.cxx6
-rw-r--r--xmloff/source/style/xmlexppr.cxx39
-rw-r--r--xmloff/source/style/xmlprmap.cxx6
-rw-r--r--xmloff/source/text/txtparae.cxx3
9 files changed, 72 insertions, 24 deletions
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index e07fb6a77693..bd8de071eb20 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -1589,6 +1589,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
// not the XShapes object used here. Thus the shapes have to be
// exported one by one
rtl::Reference< XMLShapeExport > rShapeExport = mrExport.GetShapeExport();
+ css::uno::Sequence<OUString> aAutoStylePropNames = mrAutoStylePool.GetPropertyNames();
Reference< drawing::XShape > xShape;
const sal_Int32 nShapeCount( mxAdditionalShapes->getCount());
for( sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++ )
@@ -1598,7 +1599,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
if( ! xShape.is())
continue;
- rShapeExport->collectShapeAutoStyles( xShape );
+ rShapeExport->collectShapeAutoStyles( xShape, aAutoStylePropNames );
}
}
}
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 5448f8fc2a61..7c336989496b 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -2031,6 +2031,8 @@ void SdXMLExport::collectAutoStyles()
if (mbAutoStylesCollected)
return;
+ css::uno::Sequence<OUString> aAutoStylePropNames = GetAutoStylePool()->GetPropertyNames();
+
Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
if( xInfoSet.is() )
{
@@ -2070,7 +2072,7 @@ void SdXMLExport::collectAutoStyles()
{
Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
if( xHandoutPage.is() && xHandoutPage->getCount())
- GetShapeExport()->collectShapesAutoStyles( xHandoutPage );
+ GetShapeExport()->collectShapesAutoStyles( xHandoutPage, aAutoStylePropNames );
}
}
@@ -2098,7 +2100,7 @@ void SdXMLExport::collectAutoStyles()
GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix );
if(xMasterPage.is() && xMasterPage->getCount())
- GetShapeExport()->collectShapesAutoStyles( xMasterPage );
+ GetShapeExport()->collectShapesAutoStyles( xMasterPage, aAutoStylePropNames );
if(IsImpress())
{
@@ -2112,7 +2114,7 @@ void SdXMLExport::collectAutoStyles()
GetFormExport()->examineForms( xNotesPage );
if(xNotesPage->getCount())
- GetShapeExport()->collectShapesAutoStyles( xNotesPage );
+ GetShapeExport()->collectShapesAutoStyles( xNotesPage, aAutoStylePropNames );
}
}
}
@@ -2163,7 +2165,7 @@ void SdXMLExport::collectAutoStyles()
// prepare object infos
if(xDrawPage.is() && xDrawPage->getCount())
- GetShapeExport()->collectShapesAutoStyles( xDrawPage );
+ GetShapeExport()->collectShapesAutoStyles( xDrawPage, aAutoStylePropNames );
// prepare presentation notes page object infos (ONLY if presentation)
if(IsImpress())
@@ -2178,7 +2180,7 @@ void SdXMLExport::collectAutoStyles()
GetFormExport()->examineForms( xNotesPage );
if(xNotesPage->getCount())
- GetShapeExport()->collectShapesAutoStyles( xNotesPage );
+ GetShapeExport()->collectShapesAutoStyles( xNotesPage, aAutoStylePropNames );
}
}
}
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 13c6a88cb737..51ee4c894250 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -261,7 +261,8 @@ uno::Reference< drawing::XShape > XMLShapeExport::checkForCustomShapeReplacement
}
// This method collects all automatic styles for the given XShape
-void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShape >& xShape )
+void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShape >& xShape,
+ const css::uno::Sequence<OUString>& rAutoStylePropNames )
{
if( maCurrentShapesIter == maShapesInfos.end() )
{
@@ -529,7 +530,7 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap
uno::Reference< drawing::XShapes > xShapes( xCollection, uno::UNO_QUERY );
if( xShapes.is() )
{
- collectShapesAutoStyles( xShapes );
+ collectShapesAutoStyles( xShapes,rAutoStylePropNames );
}
}
}
@@ -955,7 +956,9 @@ void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape
}
// This method collects all automatic styles for the shapes inside the given XShapes collection
-void XMLShapeExport::collectShapesAutoStyles( const uno::Reference < drawing::XShapes >& xShapes )
+void XMLShapeExport::collectShapesAutoStyles(
+ const uno::Reference < drawing::XShapes >& xShapes,
+ const css::uno::Sequence<OUString>& rAutoStylePropNames)
{
ShapesInfos::iterator aOldCurrentShapesIter = maCurrentShapesIter;
seekShapes( xShapes );
@@ -969,7 +972,7 @@ void XMLShapeExport::collectShapesAutoStyles( const uno::Reference < drawing::XS
if(!xShape.is())
continue;
- collectShapeAutoStyles( xShape );
+ collectShapeAutoStyles( xShape, rAutoStylePropNames );
}
maCurrentShapesIter = aOldCurrentShapesIter;
diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx
index e103fc1c372a..179c402dc246 100644
--- a/xmloff/source/style/impastpl.cxx
+++ b/xmloff/source/style/impastpl.cxx
@@ -20,6 +20,7 @@
#include <memory>
#include <algorithm>
+#include <comphelper/sequence.hxx>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <tools/solar.h>
@@ -443,6 +444,18 @@ void SvXMLAutoStylePoolP_Impl::GetRegisteredNames(
std::copy( aNames.begin(), aNames.end(), rNames.getArray() );
}
+/// retrieve the names of the properties used in the styles
+uno::Sequence<OUString> SvXMLAutoStylePoolP_Impl::GetPropertyNames()
+{
+ o3tl::sorted_vector<OUString> aNames;
+ // iterate over families
+ for (XMLAutoStyleFamily const & rFamily : m_FamilySet)
+ {
+ rFamily.mxMapper->GetEntryAPINames(aNames);
+ }
+ return comphelper::containerToSequence(aNames);
+}
+
// Adds an array of XMLPropertyState ( vector< XMLPropertyState > ) to list
// if not added, yet.
diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx
index 7cbb89817132..b8eb34bbc9d1 100644
--- a/xmloff/source/style/impastpl.hxx
+++ b/xmloff/source/style/impastpl.hxx
@@ -151,6 +151,9 @@ public:
css::uno::Sequence<sal_Int32>& aFamilies,
css::uno::Sequence<OUString>& aNames );
+ /// retrieve the names of the properties used in the styles
+ css::uno::Sequence<OUString> GetPropertyNames();
+
bool Add(
OUString& rName, XmlStyleFamily nFamily,
const OUString& rParentName,
diff --git a/xmloff/source/style/xmlaustp.cxx b/xmloff/source/style/xmlaustp.cxx
index 47a36932f028..0aca31aabdf3 100644
--- a/xmloff/source/style/xmlaustp.cxx
+++ b/xmloff/source/style/xmlaustp.cxx
@@ -330,6 +330,12 @@ void SvXMLAutoStylePoolP::RegisterNames(
RegisterName( static_cast<XmlStyleFamily>(pFamilies[n]), pNames[n] );
}
+/// retrieve the names of the properties used in the styles
+css::uno::Sequence<OUString> SvXMLAutoStylePoolP::GetPropertyNames( )
+{
+ return pImpl->GetPropertyNames();
+}
+
OUString SvXMLAutoStylePoolP::Add( XmlStyleFamily nFamily,
vector< XMLPropertyState >&& rProperties )
{
diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx
index d2088cfea601..e81758bdce7c 100644
--- a/xmloff/source/style/xmlexppr.cxx
+++ b/xmloff/source/style/xmlexppr.cxx
@@ -171,7 +171,8 @@ public:
vector< XMLPropertyState >& rPropStates,
const Reference< XPropertySet >& xPropSet,
const rtl::Reference< XMLPropertySetMapper >& maPropMapper,
- const bool bDefault);
+ const bool bDefault,
+ const uno::Sequence<OUString>* pOnlyTheseProps);
sal_uInt32 GetPropertyCount() const { return aPropInfos.size(); }
};
@@ -250,18 +251,22 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
vector< XMLPropertyState >& rPropStates,
const Reference< XPropertySet >& rPropSet,
const rtl::Reference< XMLPropertySetMapper >& rPropMapper,
- const bool bDefault )
+ const bool bDefault,
+ const uno::Sequence<OUString>* pOnlyTheseProps )
{
+
XMLPropertyStates_Impl aPropStates;
- const uno::Sequence<OUString>& rApiNames = GetApiNames();
+ const uno::Sequence<OUString>* pApiNames = pOnlyTheseProps;
+ if (!pApiNames)
+ pApiNames = &GetApiNames();
Reference < XTolerantMultiPropertySet > xTolPropSet( rPropSet, UNO_QUERY );
if (xTolPropSet.is())
{
if (!bDefault)
{
- Sequence < beans::GetDirectPropertyTolerantResult > aResults(xTolPropSet->getDirectPropertyValuesTolerant(rApiNames));
+ Sequence < beans::GetDirectPropertyTolerantResult > aResults(xTolPropSet->getDirectPropertyValuesTolerant(*pApiNames));
sal_Int32 nResultCount(aResults.getLength());
if (nResultCount > 0)
{
@@ -289,8 +294,8 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
}
else
{
- const Sequence < beans::GetPropertyTolerantResult > aResults(xTolPropSet->getPropertyValuesTolerant(rApiNames));
- OSL_ENSURE( rApiNames.getLength() == aResults.getLength(), "wrong implemented XTolerantMultiPropertySet" );
+ const Sequence < beans::GetPropertyTolerantResult > aResults(xTolPropSet->getPropertyValuesTolerant(*pApiNames));
+ OSL_ENSURE( pApiNames->getLength() == aResults.getLength(), "wrong implemented XTolerantMultiPropertySet" );
FilterPropertyInfoList_Impl::iterator aPropIter(aPropInfos.begin());
XMLPropertyState aNewProperty( -1 );
OSL_ENSURE( aPropInfos.size() == static_cast<sal_uInt32>(aResults.getLength()), "wrong implemented XTolerantMultiPropertySet??" );
@@ -319,7 +324,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
Reference< XPropertyState > xPropState( rPropSet, UNO_QUERY );
if( xPropState.is() )
{
- aStates = xPropState->getPropertyStates( rApiNames );
+ aStates = xPropState->getPropertyStates( *pApiNames );
pStates = aStates.getConstArray();
}
@@ -389,7 +394,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
}
else
{
- aValues = xMultiPropSet->getPropertyValues( rApiNames );
+ aValues = xMultiPropSet->getPropertyValues( *pApiNames );
const Any *pValues = aValues.getConstArray();
FilterPropertyInfoList_Impl::iterator aItr = aPropInfos.begin();
@@ -514,21 +519,24 @@ void SvXMLExportPropertyMapper::ChainExportMapper(
std::vector<XMLPropertyState> SvXMLExportPropertyMapper::Filter(
SvXMLExport const& rExport,
- const uno::Reference<beans::XPropertySet>& rPropSet, bool bEnableFoFontFamily ) const
+ const uno::Reference<beans::XPropertySet>& rPropSet,
+ bool bEnableFoFontFamily,
+ const uno::Sequence<OUString>* pOnlyTheseProps ) const
{
- return Filter_(rExport, rPropSet, false, bEnableFoFontFamily);
+ return Filter_(rExport, rPropSet, false, bEnableFoFontFamily, pOnlyTheseProps);
}
std::vector<XMLPropertyState> SvXMLExportPropertyMapper::FilterDefaults(
SvXMLExport const& rExport,
const uno::Reference<beans::XPropertySet>& rPropSet ) const
{
- return Filter_(rExport, rPropSet, true, false/*bEnableFoFontFamily*/);
+ return Filter_(rExport, rPropSet, true, false/*bEnableFoFontFamily*/, nullptr);
}
vector<XMLPropertyState> SvXMLExportPropertyMapper::Filter_(
SvXMLExport const& rExport,
- const Reference<XPropertySet>& xPropSet, bool bDefault, bool bEnableFoFontFamily ) const
+ const Reference<XPropertySet>& xPropSet, bool bDefault, bool bEnableFoFontFamily,
+ const uno::Sequence<OUString>* pOnlyTheseProps ) const
{
vector< XMLPropertyState > aPropStateArray;
@@ -641,7 +649,7 @@ vector<XMLPropertyState> SvXMLExportPropertyMapper::Filter_(
try
{
pFilterInfo->FillPropertyStateArray(
- aPropStateArray, xPropSet, mpImpl->mxPropMapper, bDefault);
+ aPropStateArray, xPropSet, mpImpl->mxPropMapper, bDefault, pOnlyTheseProps);
}
catch( UnknownPropertyException& )
{
@@ -1128,4 +1136,9 @@ const OUString& SvXMLExportPropertyMapper::GetStyleName() const
return mpImpl->maStyleName;
}
+void SvXMLExportPropertyMapper::GetEntryAPINames(o3tl::sorted_vector<OUString>& rNames) const
+{
+ mpImpl->mxPropMapper->GetEntryAPINames(rNames);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/style/xmlprmap.cxx b/xmloff/source/style/xmlprmap.cxx
index afeec00fd024..f7145161e3b8 100644
--- a/xmloff/source/style/xmlprmap.cxx
+++ b/xmloff/source/style/xmlprmap.cxx
@@ -357,4 +357,10 @@ void XMLPropertySetMapper::RemoveEntry( sal_Int32 nIndex )
mpImpl->maMapEntries.erase( aEIter );
}
+void XMLPropertySetMapper::GetEntryAPINames( o3tl::sorted_vector<OUString>& rNames) const
+{
+ for (const XMLPropertySetMapperEntry_Impl& rMapEntry : mpImpl->maMapEntries)
+ rNames.insert(rMapEntry.sAPIPropertyName);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index b52a66249a1b..6a3e7c667c0b 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -3047,7 +3047,8 @@ void XMLTextParagraphExport::exportAnyTextFrame(
case FrameType::Shape:
{
Reference < XShape > xShape( rTxtCntnt, UNO_QUERY );
- GetExport().GetShapeExport()->collectShapeAutoStyles( xShape );
+ css::uno::Sequence<OUString> aAutoStylePropNames = GetAutoStylePool().GetPropertyNames();
+ GetExport().GetShapeExport()->collectShapeAutoStyles( xShape, aAutoStylePropNames );
}
break;
default: