oox/source/core/filterbase.cxx                     |    7 +++++--
 sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx |   14 ++++++++++----
 sw/source/writerfilter/ooxml/OOXMLDocumentImpl.hxx |    5 ++++-
 3 files changed, 19 insertions(+), 7 deletions(-)

New commits:
commit be2e9bf77e14fbfb4fdab32f6af61778b9e64843
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Feb 12 13:10:13 2026 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Feb 13 19:49:56 2026 +0100

    tdf#170595 reduce the number of times we open and parse the zip..
    
    file container from 851 to 8.
    
    This shaves 30% off the opening time.
    
    This requires that we
    
    (a) share the same instance of ShapeFilterBase in the child OODocumentImpl 
objects we create
    
    (b) and re-use the mxPackage in the FilterBase class,
    instead of re-opening the stream with a new OStorage object.
    
    Change-Id: I058bddd04e93e7200bf446f00b5a1c24201b9041
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199269
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit eb318cfcc1c9c5bbad22c53af41fff615c984cca)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199266
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index d5e77333ba30..5542b7de26fa 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -464,7 +464,8 @@ sal_Bool SAL_CALL FilterBase::filter( const Sequence< 
PropertyValue >& rMediaDes
         throw RuntimeException();
 
     bool bRet = false;
-    setMediaDescriptor( rMediaDescSeq );
+    if (!mxImpl->mxStorage)
+        setMediaDescriptor( rMediaDescSeq );
     DocumentOpenedGuard aOpenedGuard( mxImpl->maFileUrl );
     if( aOpenedGuard.isValid() || mxImpl->maFileUrl.isEmpty() )
     {
@@ -479,7 +480,9 @@ sal_Bool SAL_CALL FilterBase::filter( const Sequence< 
PropertyValue >& rMediaDes
             case FilterDirection::Unknown:
             break;
             case FilterDirection::Import:
-                if( mxImpl->mxInStream.is() )
+                if (mxImpl->mxStorage)
+                    bRet = true;
+                else if( mxImpl->mxInStream.is() )
                 {
                     mxImpl->mxStorage = implCreateStorage( mxImpl->mxInStream 
);
                     bRet = mxImpl->mxStorage && importDocument();
diff --git a/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx 
b/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx
index eb1d4eff5ac5..58e729f1a4eb 100644
--- a/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx
+++ b/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx
@@ -53,7 +53,11 @@ using namespace ::com::sun::star;
 namespace writerfilter::ooxml
 {
 
-OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, 
uno::Reference<task::XStatusIndicator> xStatusIndicator, bool bSkipImages, 
const uno::Sequence<beans::PropertyValue>& rDescriptor)
+OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream,
+                                     uno::Reference<task::XStatusIndicator> 
xStatusIndicator,
+                                     bool bSkipImages,
+                                     const 
uno::Sequence<beans::PropertyValue>& rDescriptor,
+                                     const 
rtl::Reference<oox::shape::ShapeFilterBase>& rxShapeFilterBase)
     : mpStream(std::move(pStream))
     , mxStatusIndicator(std::move(xStatusIndicator))
     , mnXNoteId(0)
@@ -66,6 +70,7 @@ OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t 
pStream, uno::Refere
     , 
m_rBaseURL(comphelper::SequenceAsHashMap(rDescriptor).getUnpackedValueOrDefault(u"DocumentBaseURL"_ustr,
 OUString()))
     , maMediaDescriptor(rDescriptor)
     , mxGraphicMapper(graphic::GraphicMapper::create(mpStream->getContext()))
+    , mxShapeFilterBase(rxShapeFilterBase)
 {
     pushShapeContext();
 }
@@ -247,7 +252,8 @@ OOXMLDocumentImpl::getSubStream(const OUString & rId)
     OOXMLDocumentImpl * pTemp;
     // Do not pass status indicator to sub-streams: they are typically 
marginal in size, so we just track the main document for now.
     writerfilter::Reference<Stream>::Pointer_t pRet( pTemp =
-            new OOXMLDocumentImpl(std::move(pStream), 
uno::Reference<task::XStatusIndicator>(), mbSkipImages, maMediaDescriptor));
+            new OOXMLDocumentImpl(std::move(pStream), 
uno::Reference<task::XStatusIndicator>(),
+                                  mbSkipImages, maMediaDescriptor, 
getShapeFilterBase()));
     pTemp->setModel(mxModel);
     pTemp->setDrawPage(mxDrawPage);
     pTemp->mbIsSubstream = true;
@@ -259,7 +265,7 @@ OOXMLDocumentImpl::getXNoteStream(OOXMLStream::StreamType_t 
nType, const sal_Int
 {
     // See above, no status indicator for the note stream, either.
     OOXMLDocumentImpl * pDocument = new 
OOXMLDocumentImpl(OOXMLDocumentFactory::createStream(mpStream, nType),
-            uno::Reference<task::XStatusIndicator>(), mbSkipImages, 
maMediaDescriptor);
+            uno::Reference<task::XStatusIndicator>(), mbSkipImages, 
maMediaDescriptor, nullptr);
     pDocument->setXNoteId(nId);
     pDocument->setModel(getModel());
     pDocument->setDrawPage(getDrawPage());
@@ -918,7 +924,7 @@ OOXMLDocumentFactory::createDocument
  const uno::Reference<task::XStatusIndicator>& xStatusIndicator,
  bool mbSkipImages, const uno::Sequence<beans::PropertyValue>& rDescriptor)
 {
-    return new OOXMLDocumentImpl(pStream, xStatusIndicator, mbSkipImages, 
rDescriptor);
+    return new OOXMLDocumentImpl(pStream, xStatusIndicator, mbSkipImages, 
rDescriptor, nullptr);
 }
 
 }
diff --git a/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.hxx 
b/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.hxx
index 602432ddcf51..1bc9ced84ae2 100644
--- a/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.hxx
+++ b/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.hxx
@@ -104,7 +104,10 @@ private:
     void resolveCommentsExtendedStream(Stream & rStream);
 
 public:
-    OOXMLDocumentImpl(OOXMLStream::Pointer_t  pStream, 
css::uno::Reference<css::task::XStatusIndicator> xStatusIndicator, bool 
bSkipImages, const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor);
+    OOXMLDocumentImpl(OOXMLStream::Pointer_t  pStream,
+                      css::uno::Reference<css::task::XStatusIndicator> 
xStatusIndicator,
+                      bool bSkipImages, const 
css::uno::Sequence<css::beans::PropertyValue>& rDescriptor,
+                      const rtl::Reference<oox::shape::ShapeFilterBase>& 
rxShapeFilterBase);
     virtual ~OOXMLDocumentImpl() override;
 
     virtual void resolve(Stream & rStream) override;

Reply via email to