desktop/inc/app.hxx | 1 desktop/source/app/app.cxx | 5 - sw/inc/TextCursorHelper.hxx | 5 - sw/inc/ndtxt.hxx | 2 sw/inc/unotextcursor.hxx | 2 sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 86 +++++-------------- 6 files changed, 34 insertions(+), 67 deletions(-)
New commits: commit e7ea91a4af1242fcfa5f5ba5f04bbc6662453e28 Author: Justin Luth <[email protected]> AuthorDate: Wed May 1 11:04:39 2024 -0400 Commit: Miklos Vajna <[email protected]> CommitDate: Tue May 7 08:46:49 2024 +0200 tdf#160814 writerfilter: insert comment after other comments #2 Since writerfilter moved into sw in 24.8, this section can be seriously optimized. Change-Id: I6a228b1a910181c38ba5c8faf9566954fffc47fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166988 Reviewed-by: Miklos Vajna <[email protected]> Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins diff --git a/sw/inc/TextCursorHelper.hxx b/sw/inc/TextCursorHelper.hxx index 3eff663c3d08..41a91ed47626 100644 --- a/sw/inc/TextCursorHelper.hxx +++ b/sw/inc/TextCursorHelper.hxx @@ -17,12 +17,15 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #pragma once + +#include "swdllapi.h" + #include <cppuhelper/implbase1.hxx> class SwDoc; class SwPaM; -class SAL_LOPLUGIN_ANNOTATE("crosscast") OTextCursorHelper +class SW_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") OTextCursorHelper { public: diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 2350d69edcdb..ee998a33eed6 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -445,7 +445,7 @@ public: */ SwTextAttr* GetTextAttrForEndCharAt(sal_Int32 nIndex, sal_uInt16 nWhich) const; - SwTextField* GetFieldTextAttrAt( + SW_DLLPUBLIC SwTextField* GetFieldTextAttrAt( const sal_Int32 nIndex, ::sw::GetTextAttrMode const eMode = ::sw::GetTextAttrMode::Expand) const; diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx index b45cc0899540..397d142dbb36 100644 --- a/sw/inc/unotextcursor.hxx +++ b/sw/inc/unotextcursor.hxx @@ -65,7 +65,7 @@ typedef ::cppu::WeakImplHelper , css::text::XMarkingAccess > SwXTextCursor_Base; -class SwXTextCursor final +class SW_DLLPUBLIC SwXTextCursor final : public SwXTextCursor_Base , public OTextCursorHelper { diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index ebb636e1ab36..bdf05bee33a5 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -129,8 +129,12 @@ #include <o3tl/string_view.hxx> #include <com/sun/star/drawing/FillStyle.hpp> +#include <docufld.hxx> +#include <txtfld.hxx> +#include <ndtxt.hxx> #include <unicode/errorcode.h> #include <unicode/regex.h> +#include <unotextcursor.hxx> #include <unotxdoc.hxx> #include <SwXDocumentSettings.hxx> #include <SwXTextDefaults.hxx> @@ -144,9 +148,6 @@ #include <unofootnote.hxx> #include <unoport.hxx> -#define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100 -#define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200 - using namespace ::com::sun::star; using namespace oox; namespace writerfilter::dmapper{ @@ -4550,69 +4551,28 @@ void DomainMapper_Impl::PopAnnotation() // immediately at the end of the range it spans. // If multiple comments have the same end-point, we need to expand the range so that // this later comment doesn't insert itself before any earlier ones. - const uno::Reference<frame::XModel> xModel(static_cast<SfxBaseModel*>(m_xTextDocument.get())); - const uno::Reference<text::XTextFieldsSupplier> xTFS(xModel, uno::UNO_QUERY); - if (xTFS.is()) + auto pSwCursor = dynamic_cast<const SwXTextCursor*>(xCursor.get()); + const SwPaM* pPaM = pSwCursor ? pSwCursor->GetPaM() : nullptr; + SwTextNode* pTNd = pPaM ? pPaM->GetPointNode().GetTextNode() : nullptr; + if (pTNd) { - // sadly, the enumeration is not correctly sorted, which really complicates things. - const uno::Reference<container::XEnumerationAccess> xFieldEA(xTFS->getTextFields()); - bool bRetry(false); - // keep track of the relevant (unsorted) fields that might have the same end point - std::vector<uno::Reference<text::XTextRange>> xRetryFields; - - uno::Reference<container::XEnumeration> xEnum = xFieldEA->createEnumeration(); - // Although the primary interest is other comments, the same principle - // probably applies to any kind of field. - while (xEnum->hasMoreElements()) - { - try - { - // IMPORTANT: nextElement() MUST run before any possible exception... - const uno::Reference<text::XTextField> xField(xEnum->nextElement(), - uno::UNO_QUERY_THROW); - if (xTextRangeCompare->compareRegionStarts(xCursor->getEnd(), - xField->getAnchor()) == 1) - { - // Not interesting: our comment-to-insert ends before this field begins - continue; - } - - const sal_Int32 nCompare = xTextRangeCompare->compareRegionEnds( - xCursor->getEnd(), xField->getAnchor()); - if (nCompare == 0) // both end at the same spot - { - bRetry = xCursor->goRight(1, true); - } - else if (nCompare == 1) // this field ends later than our comment-to-insert - { - // current implementation of SwModify::Add is basically in reverse order - // so placing at the front of the list should effectively sort them. - xRetryFields.emplace(xRetryFields.begin(), xField->getAnchor()); - } - } - catch (uno::Exception&) - { - } - } - // if the comment range expanded, retry with cached relevant fields - while (bRetry && xRetryFields.size()) + const sal_Int32 nPos = pPaM->End()->GetContentIndex(); + sal_Int32 nShift = 0; + do { - bRetry = false; - auto iter = xRetryFields.cbegin(); - while (iter != xRetryFields.cend()) - { - const sal_Int32 nCompare - = xTextRangeCompare->compareRegionEnds(xCursor->getEnd(), *iter); - if (nCompare == 1) // this field still ends later than our comment - ++iter; - else - { - iter = xRetryFields.erase(iter); - if (nCompare == 0) // both end at the same spot - bRetry = xCursor->goRight(1, true); - } - } + const SwTextField* pAttr = pTNd->GetFieldTextAttrAt( + nPos + nShift, ::sw::GetTextAttrMode::Default); + auto pPostit = dynamic_cast<const SwPostItField*>( + pAttr ? pAttr->GetFormatField().GetField() : nullptr); + if (pPostit) + ++nShift; + else + break; } + while (true); + + if (nShift) + xCursor->goRight(nShift, /*Select=*/true); } uno::Reference<text::XTextRange> const xTextRange(xCursor, uno::UNO_QUERY_THROW); commit 7d1242b01d3ad9be1cfcf2bd3fbee9ce63dddddf Author: Noel Grandin <[email protected]> AuthorDate: Fri May 3 20:16:52 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue May 7 08:46:47 2024 +0200 move opencl check at startup inside its own thread shaves 30% off the startup time for me. Change-Id: Ibabb2a6b283243aaaaafb8257e99e82e2ef112c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167100 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 0c96240f1b0d..7a789b59b55a 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -169,6 +169,7 @@ class Desktop final : public Application std::unique_ptr<Lockfile> m_xLockfile; Timer m_firstRunTimer; std::thread m_aUpdateThread; + std::thread m_aOpenCLCheckThread; }; OUString GetURL_Impl( diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 0e529e071427..158f02909fa8 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1576,7 +1576,7 @@ int Desktop::Main() // FIXME: move this somewhere sensible. #if HAVE_FEATURE_OPENCL - CheckOpenCLCompute(xDesktop); + m_aOpenCLCheckThread = std::thread(CheckOpenCLCompute, xDesktop); #endif #if !defined(EMSCRIPTEN) @@ -1633,6 +1633,9 @@ int Desktop::doShutdown() if (m_aUpdateThread.joinable()) m_aUpdateThread.join(); + if (m_aOpenCLCheckThread.joinable()) + m_aOpenCLCheckThread.join(); + if (pExecGlobals->xJVMloadThread.is()) { pExecGlobals->xJVMloadThread->join();
