fix brain malfunction

in
    commit 01a3cc1e55
    Author: Noel Grandin <noel.grandin@collabora.co.uk>
    Date:   Tue Nov 29 16:09:10 2022 +0200
    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.

where I apparently wrote the code at the beginning of the call-chain
to collect autostyle prop names, and I wrote the code at the end of the
call-chain to filter on those names, but I never hooked it up in
the middle.

(which just means that the initial commit had no effect at all)

Unfortunately, fixing the middle part results in
unit test failures, so for now, just revert it.

Change-Id: Ia1d655f70d2f5a1656e910d45817c3c4627b85fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150531
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2023-04-18 12:21:36 +02:00
parent 2424fa9c60
commit aff9ea4c77
15 changed files with 33 additions and 98 deletions
+2 -4
View File
@@ -223,8 +223,7 @@ public:
// This method collects all automatic styles for the given XShape
void collectShapeAutoStyles(
const css::uno::Reference < css::drawing::XShape >& xShape,
const css::uno::Sequence<OUString>& rAutoStylePropNames);
const css::uno::Reference < css::drawing::XShape >& xShape);
// This method exports the given XShape
void exportShape(
@@ -236,8 +235,7 @@ public:
// This method collects all automatic styles for the shapes inside the given XShapes collection
void collectShapesAutoStyles(
const css::uno::Reference < css::drawing::XShapes >& xShapes,
const css::uno::Sequence<OUString>& rAutoStylePropNames);
const css::uno::Reference < css::drawing::XShapes >& xShapes);
// This method exports all XShape inside the given XShapes collection
void exportShapes(
-3
View File
@@ -110,9 +110,6 @@ public:
css::uno::Sequence<sal_Int32> const & aFamilies,
css::uno::Sequence<OUString> const & aNames );
/// retrieve the names of the properties used in the styles
css::uno::Sequence<OUString> GetPropertyNames();
/// Add an item set to the pool and return its generated name.
OUString Add( XmlStyleFamily nFamily, ::std::vector< XMLPropertyState >&& rProperties );
OUString Add( XmlStyleFamily nFamily, const OUString& rParent, ::std::vector< XMLPropertyState >&& rProperties, bool bDontSeek = false );
+2 -9
View File
@@ -23,10 +23,8 @@
#include <sal/config.h>
#include <xmloff/dllapi.h>
#include <salhelper/simplereferenceobject.hxx>
#include <o3tl/sorted_vector.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <rtl/ustring.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <memory>
#include <vector>
@@ -68,8 +66,7 @@ protected:
std::vector<XMLPropertyState> Filter_(
SvXMLExport const& rExport,
const css::uno::Reference<css::beans::XPropertySet>& rPropSet,
bool bDefault, bool bDisableFoFontFamily,
const css::uno::Sequence<OUString>* pOnlyTheseProps ) const;
bool bDefault, bool bDisableFoFontFamily ) const;
/** Application-specific filter. By default do nothing. */
virtual void ContextFilter(
@@ -119,9 +116,7 @@ public:
filter-processes. */
std::vector<XMLPropertyState> Filter(
SvXMLExport const& rExport,
const css::uno::Reference<css::beans::XPropertySet>& rPropSet,
bool bEnableFoFontFamily = false,
const css::uno::Sequence<OUString>* pOnlyTheseProps = nullptr ) const;
const css::uno::Reference<css::beans::XPropertySet>& rPropSet, bool bEnableFoFontFamily = false ) const;
/** Like Filter(), except that:
* - only properties that have the map flag MID_FLAG_DEFAULT_ITEM_EXPORT
@@ -180,8 +175,6 @@ public:
void SetStyleName( const OUString& rStyleName );
const OUString& GetStyleName() const;
void GetEntryAPINames(o3tl::sorted_vector<OUString>& rNames) const;
};
#endif // INCLUDED_XMLOFF_XMLEXPPR_HXX
-3
View File
@@ -26,7 +26,6 @@
#include <salhelper/simplereferenceobject.hxx>
#include <memory>
#include <o3tl/sorted_vector.hxx>
namespace rtl { template <class reference_type> class Reference; }
@@ -122,8 +121,6 @@ public:
/** Remove an entry */
void RemoveEntry( sal_Int32 nIndex );
void GetEntryAPINames(o3tl::sorted_vector<OUString>& rNames) const;
};
#endif // INCLUDED_XMLOFF_XMLPRMAP_HXX
+1 -2
View File
@@ -658,8 +658,7 @@ void ORptExport::exportReportComponentAutoStyles(const Reference<XSection>& _xPr
rtl::Reference< XMLShapeExport > xShapeExport = GetShapeExport();
xShapeExport->seekShapes(_xProp);
SolarMutexGuard aGuard;
css::uno::Sequence<OUString> aAutoStylePropNames = GetAutoStylePool()->GetPropertyNames();
xShapeExport->collectShapeAutoStyles(xShape, aAutoStylePropNames);
xShapeExport->collectShapeAutoStyles(xShape);
}
else
{
+3 -4
View File
@@ -583,7 +583,6 @@ void ScXMLExport::CollectShapesAutoStyles(SCTAB nTableCount)
}
if (pSharedData->HasDrawPage())
{
css::uno::Sequence<OUString> aAutoStylePropNames = GetAutoStylePool()->GetPropertyNames();
for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
{
uno::Reference<drawing::XDrawPage> xDrawPage(pSharedData->GetDrawPage(nTable));
@@ -602,7 +601,7 @@ void ScXMLExport::CollectShapesAutoStyles(SCTAB nTableCount)
{
for (const auto& rxShape : (*pTableShapes)[nTable])
{
GetShapeExport()->collectShapeAutoStyles(rxShape, aAutoStylePropNames);
GetShapeExport()->collectShapeAutoStyles(rxShape);
IncrementProgressBar(false);
}
}
@@ -611,7 +610,7 @@ void ScXMLExport::CollectShapesAutoStyles(SCTAB nTableCount)
ScMyShapeList::const_iterator aEndItr(pShapeList->end());
while ( aShapeItr != aEndItr && ( aShapeItr->aAddress.Tab() == nTable ) )
{
GetShapeExport()->collectShapeAutoStyles(aShapeItr->xShape, aAutoStylePropNames);
GetShapeExport()->collectShapeAutoStyles(aShapeItr->xShape);
IncrementProgressBar(false);
++aShapeItr;
}
@@ -622,7 +621,7 @@ void ScXMLExport::CollectShapesAutoStyles(SCTAB nTableCount)
for (const auto& rNoteShape : rNoteShapes)
{
if ( rNoteShape.aPos.Tab() == nTable )
GetShapeExport()->collectShapeAutoStyles(rNoteShape.xShape, aAutoStylePropNames);
GetShapeExport()->collectShapeAutoStyles(rNoteShape.xShape);
}
}
}
+1 -2
View File
@@ -1589,7 +1589,6 @@ 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++ )
@@ -1599,7 +1598,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
if( ! xShape.is())
continue;
rShapeExport->collectShapeAutoStyles( xShape, aAutoStylePropNames );
rShapeExport->collectShapeAutoStyles( xShape );
}
}
}
+5 -7
View File
@@ -2029,8 +2029,6 @@ void SdXMLExport::collectAutoStyles()
if (mbAutoStylesCollected)
return;
css::uno::Sequence<OUString> aAutoStylePropNames = GetAutoStylePool()->GetPropertyNames();
Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
if( xInfoSet.is() )
{
@@ -2070,7 +2068,7 @@ void SdXMLExport::collectAutoStyles()
{
Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
if( xHandoutPage.is() && xHandoutPage->getCount())
GetShapeExport()->collectShapesAutoStyles( xHandoutPage, aAutoStylePropNames );
GetShapeExport()->collectShapesAutoStyles( xHandoutPage );
}
}
@@ -2098,7 +2096,7 @@ void SdXMLExport::collectAutoStyles()
GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix );
if(xMasterPage.is() && xMasterPage->getCount())
GetShapeExport()->collectShapesAutoStyles( xMasterPage, aAutoStylePropNames );
GetShapeExport()->collectShapesAutoStyles( xMasterPage );
if(IsImpress())
{
@@ -2112,7 +2110,7 @@ void SdXMLExport::collectAutoStyles()
GetFormExport()->examineForms( xNotesPage );
if(xNotesPage->getCount())
GetShapeExport()->collectShapesAutoStyles( xNotesPage, aAutoStylePropNames );
GetShapeExport()->collectShapesAutoStyles( xNotesPage );
}
}
}
@@ -2163,7 +2161,7 @@ void SdXMLExport::collectAutoStyles()
// prepare object infos
if(xDrawPage.is() && xDrawPage->getCount())
GetShapeExport()->collectShapesAutoStyles( xDrawPage, aAutoStylePropNames );
GetShapeExport()->collectShapesAutoStyles( xDrawPage );
// prepare presentation notes page object infos (ONLY if presentation)
if(IsImpress())
@@ -2178,7 +2176,7 @@ void SdXMLExport::collectAutoStyles()
GetFormExport()->examineForms( xNotesPage );
if(xNotesPage->getCount())
GetShapeExport()->collectShapesAutoStyles( xNotesPage, aAutoStylePropNames );
GetShapeExport()->collectShapesAutoStyles( xNotesPage );
}
}
}
+4 -7
View File
@@ -261,8 +261,7 @@ 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,
const css::uno::Sequence<OUString>& rAutoStylePropNames )
void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShape >& xShape )
{
if( maCurrentShapesIter == maShapesInfos.end() )
{
@@ -542,7 +541,7 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap
uno::Reference< drawing::XShapes > xShapes( xCollection, uno::UNO_QUERY );
if( xShapes.is() )
{
collectShapesAutoStyles( xShapes,rAutoStylePropNames );
collectShapesAutoStyles( xShapes );
}
}
}
@@ -968,9 +967,7 @@ 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,
const css::uno::Sequence<OUString>& rAutoStylePropNames)
void XMLShapeExport::collectShapesAutoStyles( const uno::Reference < drawing::XShapes >& xShapes )
{
ShapesInfos::iterator aOldCurrentShapesIter = maCurrentShapesIter;
seekShapes( xShapes );
@@ -984,7 +981,7 @@ void XMLShapeExport::collectShapesAutoStyles(
if(!xShape.is())
continue;
collectShapeAutoStyles( xShape, rAutoStylePropNames );
collectShapeAutoStyles( xShape );
}
maCurrentShapesIter = aOldCurrentShapesIter;
+1 -14
View File
@@ -20,7 +20,6 @@
#include <memory>
#include <algorithm>
#include <comphelper/sequence.hxx>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <tools/solar.h>
@@ -434,19 +433,7 @@ 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 ( std::vector< XMLPropertyState > ) to list
// Adds an array of XMLPropertyState ( vector< XMLPropertyState > ) to list
// if not added, yet.
bool SvXMLAutoStylePoolP_Impl::Add(
-3
View File
@@ -151,9 +151,6 @@ 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,
-6
View File
@@ -328,12 +328,6 @@ 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 m_pImpl->GetPropertyNames();
}
OUString SvXMLAutoStylePoolP::Add( XmlStyleFamily nFamily,
std::vector< XMLPropertyState >&& rProperties )
{
+13 -26
View File
@@ -169,8 +169,7 @@ public:
std::vector< XMLPropertyState >& rPropStates,
const Reference< XPropertySet >& xPropSet,
const rtl::Reference< XMLPropertySetMapper >& maPropMapper,
const bool bDefault,
const uno::Sequence<OUString>* pOnlyTheseProps);
const bool bDefault);
sal_uInt32 GetPropertyCount() const { return aPropInfos.size(); }
};
@@ -249,22 +248,18 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
std::vector< XMLPropertyState >& rPropStates,
const Reference< XPropertySet >& rPropSet,
const rtl::Reference< XMLPropertySetMapper >& rPropMapper,
const bool bDefault,
const uno::Sequence<OUString>* pOnlyTheseProps )
const bool bDefault )
{
XMLPropertyStates_Impl aPropStates;
const uno::Sequence<OUString>* pApiNames = pOnlyTheseProps;
if (!pApiNames)
pApiNames = &GetApiNames();
const uno::Sequence<OUString>& rApiNames = GetApiNames();
Reference < XTolerantMultiPropertySet > xTolPropSet( rPropSet, UNO_QUERY );
if (xTolPropSet.is())
{
if (!bDefault)
{
Sequence < beans::GetDirectPropertyTolerantResult > aResults(xTolPropSet->getDirectPropertyValuesTolerant(*pApiNames));
Sequence < beans::GetDirectPropertyTolerantResult > aResults(xTolPropSet->getDirectPropertyValuesTolerant(rApiNames));
sal_Int32 nResultCount(aResults.getLength());
if (nResultCount > 0)
{
@@ -292,8 +287,8 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
}
else
{
const Sequence < beans::GetPropertyTolerantResult > aResults(xTolPropSet->getPropertyValuesTolerant(*pApiNames));
OSL_ENSURE( pApiNames->getLength() == aResults.getLength(), "wrong implemented XTolerantMultiPropertySet" );
const Sequence < beans::GetPropertyTolerantResult > aResults(xTolPropSet->getPropertyValuesTolerant(rApiNames));
OSL_ENSURE( rApiNames.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??" );
@@ -322,7 +317,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
Reference< XPropertyState > xPropState( rPropSet, UNO_QUERY );
if( xPropState.is() )
{
aStates = xPropState->getPropertyStates( *pApiNames );
aStates = xPropState->getPropertyStates( rApiNames );
pStates = aStates.getConstArray();
}
@@ -392,7 +387,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
}
else
{
aValues = xMultiPropSet->getPropertyValues( *pApiNames );
aValues = xMultiPropSet->getPropertyValues( rApiNames );
const Any *pValues = aValues.getConstArray();
FilterPropertyInfoList_Impl::iterator aItr = aPropInfos.begin();
@@ -517,24 +512,21 @@ void SvXMLExportPropertyMapper::ChainExportMapper(
std::vector<XMLPropertyState> SvXMLExportPropertyMapper::Filter(
SvXMLExport const& rExport,
const uno::Reference<beans::XPropertySet>& rPropSet,
bool bEnableFoFontFamily,
const uno::Sequence<OUString>* pOnlyTheseProps ) const
const uno::Reference<beans::XPropertySet>& rPropSet, bool bEnableFoFontFamily ) const
{
return Filter_(rExport, rPropSet, false, bEnableFoFontFamily, pOnlyTheseProps);
return Filter_(rExport, rPropSet, false, bEnableFoFontFamily);
}
std::vector<XMLPropertyState> SvXMLExportPropertyMapper::FilterDefaults(
SvXMLExport const& rExport,
const uno::Reference<beans::XPropertySet>& rPropSet ) const
{
return Filter_(rExport, rPropSet, true, false/*bEnableFoFontFamily*/, nullptr);
return Filter_(rExport, rPropSet, true, false/*bEnableFoFontFamily*/);
}
std::vector<XMLPropertyState> SvXMLExportPropertyMapper::Filter_(
SvXMLExport const& rExport,
const Reference<XPropertySet>& xPropSet, bool bDefault, bool bEnableFoFontFamily,
const uno::Sequence<OUString>* pOnlyTheseProps ) const
const Reference<XPropertySet>& xPropSet, bool bDefault, bool bEnableFoFontFamily ) const
{
std::vector< XMLPropertyState > aPropStateArray;
@@ -647,7 +639,7 @@ std::vector<XMLPropertyState> SvXMLExportPropertyMapper::Filter_(
try
{
pFilterInfo->FillPropertyStateArray(
aPropStateArray, xPropSet, mpImpl->mxPropMapper, bDefault, pOnlyTheseProps);
aPropStateArray, xPropSet, mpImpl->mxPropMapper, bDefault);
}
catch( UnknownPropertyException& )
{
@@ -1134,9 +1126,4 @@ 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: */
-6
View File
@@ -355,10 +355,4 @@ 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: */
+1 -2
View File
@@ -3085,8 +3085,7 @@ void XMLTextParagraphExport::exportAnyTextFrame(
comphelper::ScopeGuard const g([this, xShape]() {
maShapeRecurseGuard.erase(xShape);
});
css::uno::Sequence<OUString> aAutoStylePropNames = GetAutoStylePool().GetPropertyNames();
GetExport().GetShapeExport()->collectShapeAutoStyles( xShape, aAutoStylePropNames );
GetExport().GetShapeExport()->collectShapeAutoStyles( xShape );
}
}
break;