include/editeng/EPaM.hxx | 44 ++++++++++++------------------------- include/editeng/EPosition.hxx | 49 ++++++++++++++++++++++++++++++++++++++++++ include/editeng/editdata.hxx | 26 ---------------------- 3 files changed, 65 insertions(+), 54 deletions(-)
New commits: commit ecc154cd2a4574a8b9754c0ee7c8eeee9afc56e7 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Fri Dec 8 15:42:01 2023 +0900 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Thu Dec 28 08:06:04 2023 +0100 editeng: move EPosition in its own header file Change-Id: I6362bfdde31e276c006be3799839e9c1ff4f82f6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161344 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/include/editeng/EPosition.hxx b/include/editeng/EPosition.hxx new file mode 100644 index 000000000000..ca6a3e13bee0 --- /dev/null +++ b/include/editeng/EPosition.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 + +#define EE_INDEX_NOT_FOUND SAL_MAX_INT32 +#define EE_PARA_NOT_FOUND SAL_MAX_INT32 + +struct EPosition +{ + sal_Int32 nPara; + sal_Int32 nIndex; + + EPosition() + : nPara(EE_PARA_NOT_FOUND) + , nIndex(EE_INDEX_NOT_FOUND) + { + } + + EPosition(sal_Int32 nPara_, sal_Int32 nPos_) + : nPara(nPara_) + , nIndex(nPos_) + { + } +}; + +template <typename charT, typename traits> +inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, + EPosition const& pos) +{ + return stream << "EPosition(" << pos.nPara << ',' << pos.nIndex << ")"; +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/editdata.hxx b/include/editeng/editdata.hxx index c31fc7eb7bd1..da789675d1b6 100644 --- a/include/editeng/editdata.hxx +++ b/include/editeng/editdata.hxx @@ -25,6 +25,7 @@ #include <editeng/editengdllapi.h> #include <i18nlangtag/lang.h> #include <editeng/ESelection.hxx> +#include <editeng/EPosition.hxx> #include <memory> #include <ostream> @@ -46,12 +47,10 @@ enum class EEAnchorMode { enum class EERemoveParaAttribsMode { RemoveAll, RemoveCharItems, RemoveNone }; -#define EE_PARA_NOT_FOUND SAL_MAX_INT32 #define EE_PARA_APPEND SAL_MAX_INT32 #define EE_PARA_ALL SAL_MAX_INT32 #define EE_PARA_MAX_COUNT SAL_MAX_INT32 -#define EE_INDEX_NOT_FOUND SAL_MAX_INT32 #define EE_TEXTPOS_ALL SAL_MAX_INT32 #define EE_TEXTPOS_MAX_COUNT SAL_MAX_INT32 @@ -86,29 +85,6 @@ EDITENG_DLLPUBLIC extern const size_t EE_APPEND; #define EDITUNDO_USER 200 -struct EPosition -{ - sal_Int32 nPara; - sal_Int32 nIndex; - - EPosition() - : nPara( EE_PARA_NOT_FOUND ) - , nIndex( EE_INDEX_NOT_FOUND ) - { } - - EPosition( sal_Int32 nPara_, sal_Int32 nPos_ ) - : nPara( nPara_ ) - , nIndex( nPos_ ) - { } -}; - -template<typename charT, typename traits> -inline std::basic_ostream<charT, traits> & operator <<( - std::basic_ostream<charT, traits> & stream, EPosition const& pos) -{ - return stream << "EPosition(" << pos.nPara << ',' << pos.nIndex << ")"; -} - struct EDITENG_DLLPUBLIC EFieldInfo { std::unique_ptr<SvxFieldItem> pFieldItem; commit aa2376eb12b02ae88399412495b035f1ddce3b72 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Tue Dec 5 23:18:38 2023 +0900 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Thu Dec 28 08:05:55 2023 +0100 editeng: simplify and clean-up EPaM Remove copy/assign operator as they are not needed because they are the same as default. Change-Id: I1a71e5de8024680307a65e8b5540b250178f0a97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161343 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/include/editeng/EPaM.hxx b/include/editeng/EPaM.hxx index 85ad4bd2b6ee..d474dfe18235 100644 --- a/include/editeng/EPaM.hxx +++ b/include/editeng/EPaM.hxx @@ -21,44 +21,30 @@ struct EPaM { - sal_Int32 nPara; - sal_Int32 nIndex; + sal_Int32 nPara = 0; + sal_Int32 nIndex = 0; - EPaM() - : nPara(0) - , nIndex(0) - { - } - EPaM(sal_Int32 nP, sal_Int32 nI) - : nPara(nP) - , nIndex(nI) + EPaM() = default; + + EPaM(sal_Int32 _nParagraph, sal_Int32 _nIndex) + : nPara(_nParagraph) + , nIndex(_nIndex) { } - EPaM(const EPaM& r) - : nPara(r.nPara) - , nIndex(r.nIndex) + + bool operator==(const EPaM& rInstance) const { + return nPara == rInstance.nPara && nIndex == rInstance.nIndex; } - EPaM& operator=(const EPaM& r) + + bool operator!=(const EPaM& rSelection) const = default; + + bool operator<(const EPaM& rInstance) const { - nPara = r.nPara; - nIndex = r.nIndex; - return *this; + return (nPara < rInstance.nPara) || (nPara == rInstance.nPara && nIndex < rInstance.nIndex); } - inline bool operator==(const EPaM& r) const; - inline bool operator<(const EPaM& r) const; }; -inline bool EPaM::operator<(const EPaM& r) const -{ - return (nPara < r.nPara) || ((nPara == r.nPara) && nIndex < r.nIndex); -} - -inline bool EPaM::operator==(const EPaM& r) const -{ - return (nPara == r.nPara) && (nIndex == r.nIndex); -} - template <typename charT, typename traits> inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, EPaM const& aPaM)
