solenv/clang-format/excludelist | 2 + vcl/Library_vcl.mk | 1 vcl/source/edit/IdleFormatter.cxx | 71 ++++++++++++++++++++++++++++++++++++++ vcl/source/edit/IdleFormatter.hxx | 47 +++++++++++++++++++++++++ vcl/source/edit/textdat2.hxx | 20 +--------- vcl/source/edit/textdata.cxx | 41 --------------------- vcl/source/edit/texteng.cxx | 1 7 files changed, 124 insertions(+), 59 deletions(-)
New commits: commit 77bfb60031e38bd3aa5b7e910e3b625681aea98f Author: Christopher Sherlock <chris.sherloc...@gmail.com> AuthorDate: Fri Jan 3 19:43:35 2025 +1100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 17 10:52:28 2025 +0200 vcl: split off IdleFormatter to own source files Change-Id: I9f463ed77fbabd6158ce3eb2b045e12fdb0705c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179712 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 0e2303562cbd..76cb39ca577c 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -14589,6 +14589,8 @@ vcl/source/control/tabctrl.cxx vcl/source/control/throbber.cxx vcl/source/control/wizardmachine.cxx vcl/source/control/wizimpldata.hxx +vcl/source/edit/IdleFormatter.cxx +vcl/source/edit/IdleFormatter.hxx vcl/source/edit/TextLine.hxx vcl/source/edit/textdat2.hxx vcl/source/edit/textdata.cxx diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index db63b6e6ba9d..8edfc3e21f8e 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -263,6 +263,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/control/tabctrl \ vcl/source/control/throbber \ vcl/source/control/wizardmachine \ + vcl/source/edit/IdleFormatter \ vcl/source/edit/vclmedit \ vcl/source/edit/textdata \ vcl/source/edit/textdoc \ diff --git a/vcl/source/edit/IdleFormatter.cxx b/vcl/source/edit/IdleFormatter.cxx new file mode 100644 index 000000000000..5f9255be0923 --- /dev/null +++ b/vcl/source/edit/IdleFormatter.cxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <vcl/weld.hxx> + +#include "IdleFormatter.hxx" +#include "TextLine.hxx" + +#include <cstddef> +#include <utility> + +IdleFormatter::IdleFormatter() + : Idle("vcl::TextEngine mpIdleFormatter") + , mpView(nullptr) + , mnRestarts(0) +{ + SetPriority(TaskPriority::HIGH_IDLE); +} + +IdleFormatter::~IdleFormatter() +{ + mpView = nullptr; +} + +void IdleFormatter::DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts ) +{ + mpView = pV; + + if ( IsActive() ) + mnRestarts++; + + if ( mnRestarts > nMaxRestarts ) + { + mnRestarts = 0; + Invoke(); + } + else + { + Start(); + } +} + +void IdleFormatter::ForceTimeout() +{ + if ( IsActive() ) + { + Stop(); + mnRestarts = 0; + Invoke(); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/edit/IdleFormatter.hxx b/vcl/source/edit/IdleFormatter.hxx new file mode 100644 index 000000000000..fc276f8eb0b7 --- /dev/null +++ b/vcl/source/edit/IdleFormatter.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <cstddef> +#include <limits> +#include <vector> + +#include <vcl/idle.hxx> + +class TextLine; +class TextNode; +class TextView; + +class IdleFormatter : public Idle +{ +private: + TextView* mpView; + sal_uInt16 mnRestarts; + +public: + IdleFormatter(); + virtual ~IdleFormatter() override; + + void DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts ); + void ForceTimeout(); + TextView* GetView() { return mpView; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/edit/textdat2.hxx b/vcl/source/edit/textdat2.hxx index e811fee53182..e29364f80a00 100644 --- a/vcl/source/edit/textdat2.hxx +++ b/vcl/source/edit/textdat2.hxx @@ -19,10 +19,9 @@ #pragma once -#include <vcl/seleng.hxx> +#include <tools/long.hxx> + #include <vcl/cursor.hxx> -#include <vcl/idle.hxx> -#include <vcl/textdata.hxx> #include <cstddef> #include <limits> @@ -188,21 +187,6 @@ public: virtual void DestroyAnchor() override; }; -class IdleFormatter : public Idle -{ -private: - TextView* mpView; - sal_uInt16 mnRestarts; - -public: - IdleFormatter(); - virtual ~IdleFormatter() override; - - void DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts ); - void ForceTimeout(); - TextView* GetView() { return mpView; } -}; - struct TextDDInfo { vcl::Cursor maCursor; diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx index a78cc3488806..7cee5a566612 100644 --- a/vcl/source/edit/textdata.cxx +++ b/vcl/source/edit/textdata.cxx @@ -269,47 +269,6 @@ TEParaPortions::~TEParaPortions() { } -IdleFormatter::IdleFormatter() - : Idle("vcl::TextEngine mpIdleFormatter") - , mpView(nullptr) - , mnRestarts(0) -{ - SetPriority(TaskPriority::HIGH_IDLE); -} - -IdleFormatter::~IdleFormatter() -{ - mpView = nullptr; -} - -void IdleFormatter::DoIdleFormat( TextView* pV, sal_uInt16 nMaxRestarts ) -{ - mpView = pV; - - if ( IsActive() ) - mnRestarts++; - - if ( mnRestarts > nMaxRestarts ) - { - mnRestarts = 0; - Invoke(); - } - else - { - Start(); - } -} - -void IdleFormatter::ForceTimeout() -{ - if ( IsActive() ) - { - Stop(); - mnRestarts = 0; - Invoke(); - } -} - TextHint::TextHint( SfxHintId Id ) : SfxHint( Id ), mnValue(0) { } diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 2dd9d841eac3..9d60921ac082 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -36,6 +36,7 @@ #include <osl/diagnose.h> #include "TextLine.hxx" +#include "IdleFormatter.hxx" #include <com/sun/star/i18n/XBreakIterator.hpp>