package/source/xstor/switchpersistencestream.cxx | 10 ++++- package/source/zipapi/ByteGrabber.cxx | 9 ++++ svx/source/inc/StylesPreviewWindow.hxx | 7 +-- svx/source/tbxctrls/StylesPreviewWindow.cxx | 44 +++++++---------------- 4 files changed, 35 insertions(+), 35 deletions(-)
New commits: commit 909488c67f5a8d50ad2b0ce7f90870776793013c Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Aug 14 19:45:58 2025 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Aug 15 22:25:49 2025 +0200 tdf#167956 crash opening a second document with tabbed notebookbar Revert commit 7359e9c742d35c999eb9add524052887805e7b26 Author: Noel Grandin <noelgran...@gmail.com> Date: Wed Jun 11 12:35:14 2025 +0200 tdf#166932 avoid O(n^2) loop in UpdateStylesList Rather surprising that the original patch worked at all, because SwStyleSheetIterator is returning a dummy SfxStyleSheetBase, which is updated on every call to SwStyleSheetIterator::Next and then freed when SwStyleSheetIterator destructs. Change-Id: I310731e659b5b1bf74f15918371fdd16934d4c3f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189634 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189725 diff --git a/svx/source/inc/StylesPreviewWindow.hxx b/svx/source/inc/StylesPreviewWindow.hxx index ced475e323af..0cbee0c31747 100644 --- a/svx/source/inc/StylesPreviewWindow.hxx +++ b/svx/source/inc/StylesPreviewWindow.hxx @@ -64,10 +64,10 @@ class StyleItemController public: StyleItemController(std::pair<OUString, OUString> aStyleName); - void Paint(vcl::RenderContext& rRenderContext, SfxStyleSheetBase* pStyleHint = nullptr); + void Paint(vcl::RenderContext& rRenderContext); private: - void DrawEntry(vcl::RenderContext& rRenderContext, SfxStyleSheetBase* pStyleHint); + void DrawEntry(vcl::RenderContext& rRenderContext); void DrawText(vcl::RenderContext& rRenderContext); void DrawHighlight(vcl::RenderContext& rRenderContext, Color aFontBack); static void DrawContentBackground(vcl::RenderContext& rRenderContext, @@ -123,8 +123,7 @@ public: void Select(const OUString& rStyleName); void RequestStylesListUpdate(); - static BitmapEx GetCachedPreview(const std::pair<OUString, OUString>& rStyle, - SfxStyleSheetBase* pStyleHint = nullptr); + static BitmapEx GetCachedPreview(const std::pair<OUString, OUString>& rStyle); static OString GetCachedPreviewJson(const std::pair<OUString, OUString>& rStyle); private: diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx b/svx/source/tbxctrls/StylesPreviewWindow.cxx index 922613331d05..f3684c13c743 100644 --- a/svx/source/tbxctrls/StylesPreviewWindow.cxx +++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx @@ -180,12 +180,12 @@ StyleItemController::StyleItemController(std::pair<OUString, OUString> aStyleNam { } -void StyleItemController::Paint(vcl::RenderContext& rRenderContext, SfxStyleSheetBase* pStyleHint) +void StyleItemController::Paint(vcl::RenderContext& rRenderContext) { rRenderContext.Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::FONT | vcl::PushFlags::TEXTCOLOR); - DrawEntry(rRenderContext, pStyleHint); + DrawEntry(rRenderContext); rRenderContext.Pop(); } @@ -304,29 +304,25 @@ static SvxFont GetFontFromItems(const SvxFontItem* pFontItem, Size aPixelFontSiz return aFont; } -void StyleItemController::DrawEntry(vcl::RenderContext& rRenderContext, - SfxStyleSheetBase* pStyleHint) +void StyleItemController::DrawEntry(vcl::RenderContext& rRenderContext) { SfxObjectShell* pShell = SfxObjectShell::Current(); if (!pShell) return; SfxStyleSheetBasePool* pPool = pShell->GetStyleSheetPool(); + SfxStyleSheetBase* pStyle = nullptr; + if (!pPool) return; - SfxStyleSheetBase* pStyle = nullptr; - if (pStyleHint) - pStyle = pStyleHint; - else - { - pStyle = pPool->First(m_eStyleFamily); - while (pStyle && pStyle->GetName() != m_aStyleName.first - && pStyle->GetName() != m_aStyleName.second) - pStyle = pPool->Next(); - if (!pStyle) - return; - } + pStyle = pPool->First(m_eStyleFamily); + while (pStyle && pStyle->GetName() != m_aStyleName.first + && pStyle->GetName() != m_aStyleName.second) + pStyle = pPool->Next(); + + if (!pStyle) + return; Size aSize(rRenderContext.GetOutputSizePixel()); tools::Rectangle aFullRect(Point(0, 0), aSize); @@ -581,8 +577,7 @@ IMPL_LINK(StylesPreviewWindow_Base, GetPreviewImage, const weld::encoded_image_q return true; } -BitmapEx StylesPreviewWindow_Base::GetCachedPreview(const std::pair<OUString, OUString>& rStyle, - SfxStyleSheetBase* pStyleHint) +BitmapEx StylesPreviewWindow_Base::GetCachedPreview(const std::pair<OUString, OUString>& rStyle) { auto aFound = StylePreviewCache::Get().find(rStyle.second); if (aFound != StylePreviewCache::Get().end()) @@ -594,7 +589,7 @@ BitmapEx StylesPreviewWindow_Base::GetCachedPreview(const std::pair<OUString, OU pImg->SetOutputSizePixel(aSize); StyleItemController aStyleController(rStyle); - aStyleController.Paint(*pImg, pStyleHint); + aStyleController.Paint(*pImg); BitmapEx aBitmap = pImg->GetBitmapEx(Point(0, 0), aSize); StylePreviewCache::Get()[rStyle.second] = aBitmap; @@ -620,8 +615,6 @@ void StylesPreviewWindow_Base::UpdateStylesList() SfxObjectShell* pDocShell = SfxObjectShell::Current(); SfxStyleSheetBasePool* pStyleSheetPool = nullptr; - // avoid O(n^2) loop when filling a very large style list - std::map<sal_Int32, SfxStyleSheetBase*> aStylesHint; if (pDocShell) pStyleSheetPool = pDocShell->GetStyleSheetPool(); @@ -636,7 +629,6 @@ void StylesPreviewWindow_Base::UpdateStylesList() while (pStyle) { OUString sName(pStyle->GetName()); - aStylesHint[m_aAllStyles.size()] = pStyle; m_aAllStyles.push_back(std::pair<OUString, OUString>(sName, sName)); pStyle = xIter->Next(); } @@ -647,21 +639,15 @@ void StylesPreviewWindow_Base::UpdateStylesList() // for online we can skip inserting the preview into the IconView and rely // on DoJsonProperty to provide the image to clients const bool bNeedInsertPreview = !comphelper::LibreOfficeKit::isActive(); - sal_Int32 nIndex = 0; for (const auto& rStyle : m_aAllStyles) { if (bNeedInsertPreview) { - SfxStyleSheetBase* pStyleHint = nullptr; - auto it = aStylesHint.find(nIndex); - if (it != aStylesHint.end()) - pStyleHint = it->second; - BitmapEx aPreview = GetCachedPreview(rStyle, pStyleHint); + BitmapEx aPreview = GetCachedPreview(rStyle); m_xStylesView->append(rStyle.first, rStyle.second, &aPreview); } else m_xStylesView->append(rStyle.first, rStyle.second, nullptr); - ++nIndex; } m_xStylesView->thaw(); } commit 80bf0371d375859adc7b2dc175190f9d62a20411 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Aug 15 11:44:08 2025 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Aug 15 22:25:37 2025 +0200 tdf#167936 crash when opening document from UNO pipe (2) second attempt at this, the first commit did not catch all the places regression from commit a6ad198d097fb4a503c8d5831d484ff46721134b Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Sat Aug 17 13:19:54 2024 +0200 tdf#158556 use more comphelper::ByteReader Change-Id: If3ab68f7cf147082ec296d6679d48f15ec0fdcb9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189669 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins (cherry picked from commit d0530c1627cab736cf4636b4983b7d2d1f6a8882) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189676 (cherry picked from commit 1ee8eb866bc7a4ae23107e76af97ac2ab4120e49) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189719 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/package/source/xstor/switchpersistencestream.cxx b/package/source/xstor/switchpersistencestream.cxx index 6613b8b046b1..8052ff9ecc63 100644 --- a/package/source/xstor/switchpersistencestream.cxx +++ b/package/source/xstor/switchpersistencestream.cxx @@ -256,7 +256,15 @@ uno::Reference< io::XOutputStream > SAL_CALL SwitchablePersistenceStream::getOut if ( !m_pStreamData->m_xOrigInStream.is() ) throw uno::RuntimeException(); - return m_pStreamData->m_pByteReader->readSomeBytes( aData, nBytesToRead ); + if (m_pStreamData->m_pByteReader) + return m_pStreamData->m_pByteReader->readSomeBytes( aData, nBytesToRead ); + else + { + css::uno::Sequence < sal_Int8 > aSequence; + sal_Int32 nBytesActuallyRead = m_pStreamData->m_xOrigInStream->readSomeBytes( aSequence, nBytesToRead ); + memcpy(aData, aSequence.getConstArray(), nBytesActuallyRead); + return nBytesActuallyRead; + } } void SAL_CALL SwitchablePersistenceStream::skipBytes( ::sal_Int32 nBytesToSkip ) diff --git a/package/source/zipapi/ByteGrabber.cxx b/package/source/zipapi/ByteGrabber.cxx index bc1206986c5c..23b157423df8 100644 --- a/package/source/zipapi/ByteGrabber.cxx +++ b/package/source/zipapi/ByteGrabber.cxx @@ -60,7 +60,14 @@ void ByteGrabber::setInputStream (const uno::Reference < io::XInputStream >& xNe sal_Int32 ByteGrabber::readBytes( sal_Int8* aData, sal_Int32 nBytesToRead ) { - return mpByteReader->readSomeBytes(aData, nBytesToRead ); + if (mpByteReader) + return mpByteReader->readSomeBytes(aData, nBytesToRead ); + else + { + sal_Int32 nBytesActuallyRead = xStream->readSomeBytes(aSequence, nBytesToRead); + memcpy(aData, aSequence.getConstArray(), nBytesActuallyRead); + return nBytesActuallyRead; + } } // XSeekable chained...