diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-12-24 16:46:16 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-12-30 03:09:49 +0100 |
commit | 2ffe4a6580a17d178794fabeba6916c1ff4c744c (patch) | |
tree | cd46e7a55af09849ee63db5e76d724c279801add /editeng | |
parent | 4871de96cb5e31e5ab06cf97e02e09e0e04a4de8 (diff) |
editeng: move EditLine in its own header file
Change-Id: I21cac4a8899f96da420428c4eb110078c740615a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161357
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/inc/EditLine.hxx | 110 | ||||
-rw-r--r-- | editeng/inc/editdoc.hxx | 92 |
2 files changed, 111 insertions, 91 deletions
diff --git a/editeng/inc/EditLine.hxx b/editeng/inc/EditLine.hxx new file mode 100644 index 000000000000..2b6bc2a71efb --- /dev/null +++ b/editeng/inc/EditLine.hxx @@ -0,0 +1,110 @@ +/* -*- 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 + +class ParaPortion; + +class EditLine +{ +public: + typedef std::vector<sal_Int32> CharPosArrayType; + +private: + CharPosArrayType aPositions; + std::vector<sal_Bool> aKashidaPositions; + sal_Int32 nTxtWidth; + sal_Int32 nStartPosX; + sal_Int32 nStart; // could be replaced by nStartPortion + sal_Int32 nEnd; // could be replaced by nEndPortion + sal_Int32 nStartPortion; + sal_Int32 nEndPortion; + sal_uInt16 nHeight; // Total height of the line + sal_uInt16 nTxtHeight; // Pure Text height + sal_uInt16 nMaxAscent; + bool bHangingPunctuation : 1; + bool bInvalid : 1; // for skillful formatting + +public: + EditLine(); + EditLine(const EditLine&); + ~EditLine(); + + bool IsIn(sal_Int32 nIndex) const { return ((nIndex >= nStart) && (nIndex < nEnd)); } + + bool IsIn(sal_Int32 nIndex, bool bInclEnd) const + { + return ((nIndex >= nStart) && (bInclEnd ? (nIndex <= nEnd) : (nIndex < nEnd))); + } + + void SetStart(sal_Int32 n) { nStart = n; } + sal_Int32 GetStart() const { return nStart; } + sal_Int32& GetStart() { return nStart; } + + void SetEnd(sal_Int32 n) { nEnd = n; } + sal_Int32 GetEnd() const { return nEnd; } + sal_Int32& GetEnd() { return nEnd; } + + void SetStartPortion(sal_Int32 n) { nStartPortion = n; } + sal_Int32 GetStartPortion() const { return nStartPortion; } + sal_Int32& GetStartPortion() { return nStartPortion; } + + void SetEndPortion(sal_Int32 n) { nEndPortion = n; } + sal_Int32 GetEndPortion() const { return nEndPortion; } + sal_Int32& GetEndPortion() { return nEndPortion; } + + void SetHeight(sal_uInt16 nH, sal_uInt16 nTxtH = 0); + sal_uInt16 GetHeight() const { return nHeight; } + sal_uInt16 GetTxtHeight() const { return nTxtHeight; } + + void SetTextWidth(sal_Int32 n) { nTxtWidth = n; } + sal_Int32 GetTextWidth() const { return nTxtWidth; } + + void SetMaxAscent(sal_uInt16 n) { nMaxAscent = n; } + sal_uInt16 GetMaxAscent() const { return nMaxAscent; } + + void SetHangingPunctuation(bool b) { bHangingPunctuation = b; } + bool IsHangingPunctuation() const { return bHangingPunctuation; } + + sal_Int32 GetLen() const { return nEnd - nStart; } + + sal_Int32 GetStartPosX() const { return nStartPosX; } + void SetStartPosX(sal_Int32 start); + Size CalcTextSize(ParaPortion& rParaPortion); + + bool IsInvalid() const { return bInvalid; } + bool IsValid() const { return !bInvalid; } + void SetInvalid() { bInvalid = true; } + void SetValid() { bInvalid = false; } + + bool IsEmpty() const { return nEnd <= nStart; } + + CharPosArrayType& GetCharPosArray() { return aPositions; } + const CharPosArrayType& GetCharPosArray() const { return aPositions; } + + std::vector<sal_Bool>& GetKashidaArray() { return aKashidaPositions; } + const std::vector<sal_Bool>& GetKashidaArray() const { return aKashidaPositions; } + + EditLine* Clone() const; + + EditLine& operator=(const EditLine& rLine); + friend bool operator==(const EditLine& r1, const EditLine& r2); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 9840d1ff8337..c53abc62949c 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -33,6 +33,7 @@ #include "TextPortion.hxx" #include "ItemList.hxx" #include "ContentNode.hxx" +#include "EditLine.hxx" #include <cstddef> #include <memory> @@ -158,97 +159,6 @@ public: sal_Int32 GetPos(const TextPortion* p) const; }; -class ParaPortion; - - - -class EditLine -{ -public: - typedef std::vector<sal_Int32> CharPosArrayType; - -private: - CharPosArrayType aPositions; - std::vector<sal_Bool> aKashidaPositions; - sal_Int32 nTxtWidth; - sal_Int32 nStartPosX; - sal_Int32 nStart; // could be replaced by nStartPortion - sal_Int32 nEnd; // could be replaced by nEndPortion - sal_Int32 nStartPortion; - sal_Int32 nEndPortion; - sal_uInt16 nHeight; // Total height of the line - sal_uInt16 nTxtHeight; // Pure Text height - sal_uInt16 nMaxAscent; - bool bHangingPunctuation:1; - bool bInvalid:1; // for skillful formatting - -public: - EditLine(); - EditLine( const EditLine& ); - ~EditLine(); - - bool IsIn( sal_Int32 nIndex ) const - { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); } - - bool IsIn( sal_Int32 nIndex, bool bInclEnd ) const - { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); } - - void SetStart( sal_Int32 n ) { nStart = n; } - sal_Int32 GetStart() const { return nStart; } - sal_Int32& GetStart() { return nStart; } - - void SetEnd( sal_Int32 n ) { nEnd = n; } - sal_Int32 GetEnd() const { return nEnd; } - sal_Int32& GetEnd() { return nEnd; } - - void SetStartPortion( sal_Int32 n ) { nStartPortion = n; } - sal_Int32 GetStartPortion() const { return nStartPortion; } - sal_Int32& GetStartPortion() { return nStartPortion; } - - void SetEndPortion( sal_Int32 n ) { nEndPortion = n; } - sal_Int32 GetEndPortion() const { return nEndPortion; } - sal_Int32& GetEndPortion() { return nEndPortion; } - - void SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH = 0 ); - sal_uInt16 GetHeight() const { return nHeight; } - sal_uInt16 GetTxtHeight() const { return nTxtHeight; } - - void SetTextWidth( sal_Int32 n ) { nTxtWidth = n; } - sal_Int32 GetTextWidth() const { return nTxtWidth; } - - void SetMaxAscent( sal_uInt16 n ) { nMaxAscent = n; } - sal_uInt16 GetMaxAscent() const { return nMaxAscent; } - - void SetHangingPunctuation( bool b ) { bHangingPunctuation = b; } - bool IsHangingPunctuation() const { return bHangingPunctuation; } - - sal_Int32 GetLen() const { return nEnd - nStart; } - - sal_Int32 GetStartPosX() const { return nStartPosX; } - void SetStartPosX( sal_Int32 start ); - Size CalcTextSize( ParaPortion& rParaPortion ); - - bool IsInvalid() const { return bInvalid; } - bool IsValid() const { return !bInvalid; } - void SetInvalid() { bInvalid = true; } - void SetValid() { bInvalid = false; } - - bool IsEmpty() const { return nEnd <= nStart; } - - CharPosArrayType& GetCharPosArray() { return aPositions;} - const CharPosArrayType& GetCharPosArray() const { return aPositions;} - - std::vector<sal_Bool>& GetKashidaArray() { return aKashidaPositions; } - const std::vector<sal_Bool>& GetKashidaArray() const { return aKashidaPositions; } - - EditLine* Clone() const; - - EditLine& operator = ( const EditLine& rLine ); - friend bool operator == ( const EditLine& r1, const EditLine& r2 ); -}; - - - class EditLineList { typedef std::vector<std::unique_ptr<EditLine> > LinesType; |