summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2024-09-19 19:11:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-09-20 07:51:54 +0200
commit1442dc4ee12251eed04e51eb324a34dc4b7973c3 (patch)
treeae87deda89be6e55567b9ef42a04bb7e13e03478 /sw/source
parentf0baab027df46d4e74b7808ff5d976b8efb1ea33 (diff)
dont use GetItemSurrogates for gathering SvXMLAttrContainerItem
which is very expensive these days Change-Id: Idf133fc0532f12d297c0f44a3aad48b6eaa2206a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173680 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/bastyp/init.cxx2
-rw-r--r--sw/source/core/doc/doc.cxx27
-rw-r--r--sw/source/filter/xml/xmlexp.cxx19
3 files changed, 44 insertions, 4 deletions
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index 0920842909e4..b5b409705f1a 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -344,7 +344,7 @@ ItemInfoPackage& getItemInfoPackageSwAttributes()
{ RES_TXTATR_CHARFMT, new SwFormatCharFormat( nullptr ), 0, SFX_ITEMINFOFLAG_NONE },
{ RES_TXTATR_CJK_RUBY, new SwFormatRuby( OUString() ), SID_ATTR_CHAR_CJK_RUBY, SFX_ITEMINFOFLAG_NONE },
- { RES_TXTATR_UNKNOWN_CONTAINER, new SvXMLAttrContainerItem( RES_TXTATR_UNKNOWN_CONTAINER ), 0, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE },
+ { RES_TXTATR_UNKNOWN_CONTAINER, new SvXMLAttrContainerItem( RES_TXTATR_UNKNOWN_CONTAINER ), 0, SFX_ITEMINFOFLAG_NONE },
{ RES_TXTATR_INPUTFIELD, createSwFormatFieldForItemInfoPackage( RES_TXTATR_INPUTFIELD ), 0, SFX_ITEMINFOFLAG_NONE },
{ RES_TXTATR_CONTENTCONTROL, new SwFormatContentControl( RES_TXTATR_CONTENTCONTROL ), 0, SFX_ITEMINFOFLAG_NONE },
{ RES_TXTATR_FIELD, createSwFormatFieldForItemInfoPackage( RES_TXTATR_FIELD ), 0, SFX_ITEMINFOFLAG_NONE },
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 58bb026e1c7e..2be295986df3 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -53,6 +53,7 @@
#include <editeng/pbinitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/colritem.hxx>
+#include <editeng/xmlcnitm.hxx>
#include <unotools/localedatawrapper.hxx>
#include <officecfg/Office/Writer.hxx>
@@ -1494,6 +1495,32 @@ void SwDoc::ForEachCharacterBrushItem( const std::function<bool(const SvxBrushIt
}
}
+/// Iterate over all RES_TXTATR_UNKNOWN_CONTAINER SvXMLAttrContainerItem, if the function returns false, iteration is stopped
+void SwDoc::ForEachTxtAtrContainerItem(const std::function<bool(const SvXMLAttrContainerItem&)>& rFunc ) const
+{
+ SwNodeOffset nCount = GetNodes().Count();
+ for (SwNodeOffset i(0); i < nCount; ++i)
+ {
+ SwNode* pNode = GetNodes()[i];
+ if (!pNode->IsTextNode())
+ continue;
+ SwTextNode* pTextNode = pNode->GetTextNode();
+ if (!pTextNode->HasHints())
+ continue;
+ SwpHints& rHints = pTextNode->GetSwpHints();
+ for (size_t j = 0; j < rHints.Count(); ++j)
+ {
+ const SwTextAttr* pTextAttr = rHints.Get(j);
+ if (pTextAttr->Which() != RES_TXTATR_AUTOFMT)
+ continue;
+ const SwFormatAutoFormat& rFmt = pTextAttr->GetAutoFormat();
+ if (const SvXMLAttrContainerItem* pItem = rFmt.GetStyleHandle()->GetItemIfSet(RES_TXTATR_UNKNOWN_CONTAINER))
+ if (!rFunc(*pItem))
+ return;
+ }
+ }
+}
+
void SwDoc::Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress)
{
const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds();
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 07bc30f98939..0d9e89979bdf 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -135,14 +135,27 @@ ErrCode SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
GetTextParagraphExport()->SetBlockMode( m_bBlock );
+ pDoc->ForEachTxtAtrContainerItem([this](const SvXMLAttrContainerItem& rUnknown) -> bool {
+ if( rUnknown.GetAttrCount() > 0 )
+ {
+ sal_uInt16 nIdx = rUnknown.GetFirstNamespaceIndex();
+ while( USHRT_MAX != nIdx )
+ {
+ GetNamespaceMap_().Add( rUnknown.GetPrefix( nIdx ),
+ rUnknown.GetNamespace( nIdx ) );
+ nIdx = rUnknown.GetNextNamespaceIndex( nIdx );
+ }
+ }
+ return true;
+ });
+
const SfxItemPool& rPool = pDoc->GetAttrPool();
- sal_uInt16 aWhichIds[5] = { RES_UNKNOWNATR_CONTAINER,
- RES_TXTATR_UNKNOWN_CONTAINER,
+ sal_uInt16 aWhichIds[4] = { RES_UNKNOWNATR_CONTAINER,
SDRATTR_XMLATTRIBUTES,
EE_PARA_XMLATTRIBS,
EE_CHAR_XMLATTRIBS };
- const int nWhichIds = rPool.GetSecondaryPool() ? 5 : 2;
+ const int nWhichIds = rPool.GetSecondaryPool() ? 4 : 1;
for( int j=0; j < nWhichIds; ++j )
{
const sal_uInt16 nWhichId = aWhichIds[j];