2023-12-24 01:46:16 -06:00
|
|
|
/* -*- 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
|
|
|
|
|
2023-12-24 07:45:54 -06:00
|
|
|
#include <vector>
|
|
|
|
#include <sal/types.h>
|
|
|
|
#include <tools/gen.hxx>
|
|
|
|
|
2023-12-24 01:46:16 -06:00
|
|
|
class ParaPortion;
|
|
|
|
|
|
|
|
class EditLine
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef std::vector<sal_Int32> CharPosArrayType;
|
|
|
|
|
|
|
|
private:
|
2024-03-20 00:15:23 -05:00
|
|
|
CharPosArrayType maPositions;
|
|
|
|
std::vector<sal_Bool> maKashidaPositions;
|
|
|
|
sal_Int32 mnTextWidth = 0;
|
|
|
|
sal_Int32 mnStartPosX = 0;
|
|
|
|
sal_Int32 mnNextLinePosXDiff = 0;
|
|
|
|
sal_Int32 mnStart = 0; // could be replaced by nStartPortion
|
|
|
|
sal_Int32 mnEnd = 0; // could be replaced by nEndPortion
|
|
|
|
sal_Int32 mnStartPortion = 0;
|
|
|
|
sal_Int32 mnEndPortion = 0;
|
|
|
|
sal_uInt16 mnHeight = 0; // Total height of the line
|
|
|
|
sal_uInt16 mnTextHeight = 0; // Pure Text height
|
|
|
|
sal_uInt16 mnMaxAscent = 0;
|
|
|
|
bool mbHangingPunctuation : 1 = false;
|
|
|
|
bool mbInvalid : 1 = true; // for skillful formatting
|
2023-12-24 01:46:16 -06:00
|
|
|
|
|
|
|
public:
|
2023-12-24 07:34:40 -06:00
|
|
|
EditLine() = default;
|
|
|
|
EditLine(const EditLine& rEditLine)
|
2024-03-20 00:15:23 -05:00
|
|
|
: mnStart(rEditLine.mnStart)
|
|
|
|
, mnEnd(rEditLine.mnEnd)
|
|
|
|
, mnStartPortion(rEditLine.mnStartPortion)
|
|
|
|
, mnEndPortion(rEditLine.mnEndPortion)
|
|
|
|
, mbHangingPunctuation(rEditLine.mbHangingPunctuation)
|
2023-12-24 07:34:40 -06:00
|
|
|
{
|
|
|
|
}
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
bool IsIn(sal_Int32 nIndex) const { return nIndex >= mnStart && nIndex < mnEnd; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
bool IsIn(sal_Int32 nIndex, bool bIncludeEnd) const
|
2023-12-24 01:46:16 -06:00
|
|
|
{
|
2024-03-20 00:15:23 -05:00
|
|
|
return nIndex >= mnStart && (bIncludeEnd ? nIndex <= mnEnd : nIndex < mnEnd);
|
2023-12-24 01:46:16 -06:00
|
|
|
}
|
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
void SetStart(sal_Int32 nStart) { mnStart = nStart; }
|
|
|
|
sal_Int32 GetStart() const { return mnStart; }
|
|
|
|
sal_Int32& GetStart() { return mnStart; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
void SetEnd(sal_Int32 nEnd) { mnEnd = nEnd; }
|
|
|
|
sal_Int32 GetEnd() const { return mnEnd; }
|
|
|
|
sal_Int32& GetEnd() { return mnEnd; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
void SetStartPortion(sal_Int32 nStartPortion) { mnStartPortion = nStartPortion; }
|
|
|
|
sal_Int32 GetStartPortion() const { return mnStartPortion; }
|
|
|
|
sal_Int32& GetStartPortion() { return mnStartPortion; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
void SetEndPortion(sal_Int32 nEndPortion) { mnEndPortion = nEndPortion; }
|
|
|
|
sal_Int32 GetEndPortion() const { return mnEndPortion; }
|
|
|
|
sal_Int32& GetEndPortion() { return mnEndPortion; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
void SetHeight(sal_uInt16 nHeight, sal_uInt16 nTextHeight = 0);
|
|
|
|
sal_uInt16 GetHeight() const { return mnHeight; }
|
|
|
|
sal_uInt16 GetTxtHeight() const { return mnTextHeight; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
void SetTextWidth(sal_Int32 nTextWidth) { mnTextWidth = nTextWidth; }
|
|
|
|
sal_Int32 GetTextWidth() const { return mnTextWidth; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
void SetMaxAscent(sal_uInt16 nMaxAscent) { mnMaxAscent = nMaxAscent; }
|
|
|
|
sal_uInt16 GetMaxAscent() const { return mnMaxAscent; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
void SetHangingPunctuation(bool bHangingPunctuation)
|
|
|
|
{
|
|
|
|
mbHangingPunctuation = bHangingPunctuation;
|
|
|
|
}
|
|
|
|
bool IsHangingPunctuation() const { return mbHangingPunctuation; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
sal_Int32 GetLen() const { return mnEnd - mnStart; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
sal_Int32 GetStartPosX() const { return mnStartPosX; }
|
|
|
|
void SetStartPosX(sal_Int32 nStart);
|
|
|
|
sal_Int32 GetNextLinePosXDiff() const { return mnNextLinePosXDiff; }
|
|
|
|
void SetNextLinePosXDiff(sal_Int32 nDiff) { mnNextLinePosXDiff = nDiff; }
|
2023-12-24 01:46:16 -06:00
|
|
|
Size CalcTextSize(ParaPortion& rParaPortion);
|
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
bool IsInvalid() const { return mbInvalid; }
|
|
|
|
bool IsValid() const { return !mbInvalid; }
|
|
|
|
void SetInvalid() { mbInvalid = true; }
|
|
|
|
void SetValid() { mbInvalid = false; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
bool IsEmpty() const { return mnEnd <= mnStart; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
CharPosArrayType& GetCharPosArray() { return maPositions; }
|
|
|
|
const CharPosArrayType& GetCharPosArray() const { return maPositions; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
2024-03-20 00:15:23 -05:00
|
|
|
std::vector<sal_Bool>& GetKashidaArray() { return maKashidaPositions; }
|
|
|
|
const std::vector<sal_Bool>& GetKashidaArray() const { return maKashidaPositions; }
|
2023-12-24 01:46:16 -06:00
|
|
|
|
|
|
|
EditLine* Clone() const;
|
|
|
|
|
2023-12-24 07:34:40 -06:00
|
|
|
EditLine& operator=(const EditLine& rLine)
|
|
|
|
{
|
2024-03-20 00:15:23 -05:00
|
|
|
mnEnd = rLine.mnEnd;
|
|
|
|
mnStart = rLine.mnStart;
|
|
|
|
mnEndPortion = rLine.mnEndPortion;
|
|
|
|
mnStartPortion = rLine.mnStartPortion;
|
2023-12-24 07:34:40 -06:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const EditLine& rLine) const
|
|
|
|
{
|
2024-03-20 00:15:23 -05:00
|
|
|
return mnStart == rLine.mnStart && mnEnd == rLine.mnEnd
|
|
|
|
&& mnStartPortion == rLine.mnStartPortion && mnEndPortion == rLine.mnEndPortion;
|
2023-12-24 07:34:40 -06:00
|
|
|
}
|
2023-12-24 01:46:16 -06:00
|
|
|
};
|
|
|
|
|
2023-12-24 07:34:40 -06:00
|
|
|
template <typename charT, typename traits>
|
|
|
|
inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream,
|
|
|
|
EditLine const& rLine)
|
|
|
|
{
|
|
|
|
return stream << "EditLine(" << rLine.GetStart() << ", " << rLine.GetEnd() << ")";
|
|
|
|
}
|
|
|
|
|
2023-12-24 01:46:16 -06:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|