diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /sw/source/core/txtnode/justify.hxx | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/source/core/txtnode/justify.hxx')
-rw-r--r-- | sw/source/core/txtnode/justify.hxx | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/sw/source/core/txtnode/justify.hxx b/sw/source/core/txtnode/justify.hxx new file mode 100644 index 0000000000..454b6c2590 --- /dev/null +++ b/sw/source/core/txtnode/justify.hxx @@ -0,0 +1,65 @@ +/* -*- 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/. + */ + +#pragma once +#include <sal/types.h> + +namespace sw::Justify +{ +/// Get model position base on given kern array. +/// @param rKernArray text positions from OutDev::GetTextArray(). +/// @param nLen number of elements to process in rKernArray. +/// @param nX the visual position +SW_DLLPUBLIC sal_Int32 GetModelPosition(const KernArray& rKernArray, sal_Int32 nLen, + tools::Long nX); +/// Distribute space between words and letters. +/// @param[in,out] rKernArray text positions from OutDev::GetTextArray(). +/// @param aText string used to determine where space and kern are inserted. +/// @param nStt starting index of rText. +/// @param nLen number of elements to process in rKernArray and rText. +/// @param nSpaceAdd amount of space to insert for each CH_BLANK. +/// @param nKern amount of space to insert between letters. +/// @param bNoHalfSpace whether to split the space into two halves. +/// Split spaces are inserted before and after CH_BLANK. +/// Set to true in word line mode and for Arabic text to avoid splitting. +SW_DLLPUBLIC void SpaceDistribution(KernArray& rKernArray, std::u16string_view aText, + sal_Int32 nStt, sal_Int32 nLen, tools::Long nSpaceAdd, + tools::Long nKern, bool bNoHalfSpace); + +/// Snap ideographs to text grids: +/// a) Ideographic open brackets are aligned to the rightmost edge of spanned grids so that +// they can be closer to the next ideograph. +/// b) Ideographic close brackets, ideographic comma, and ideographic fullstop are aligned +/// to the leftmost edge of spanned grids so that they can be closer to the previous +/// ideograph. +/// c) Other ideographs are aligned to the center of the spanned grids. +/// @param[in,out] rKernArray text positions from OutDev::GetTextArray(). +/// @param aText string used to determine where space and kern are inserted. +/// @param nStt starting index of rText. +/// @param nLen number of elements to process in rKernArray and rText. +/// @param nGridWidth width of a text grid +/// @param bForceLeft for align to the left edge of the grid disregard of the punctuation type. +/// This is useful for calculate text width, line break, and conversion model position. +/// @return the delta offset of first glyph so text origin can be updated accordingly. +SW_DLLPUBLIC tools::Long SnapToGrid(KernArray& rKernArray, std::u16string_view aText, + sal_Int32 nStt, sal_Int32 nLen, tools::Long nGridWidth, + bool bForceLeft); + +/// Snap ideographs to text grids edge ( used when snap to char is off ): +/// space will be distributed ( in case that alignment is set to justify. ). +/// @param[in,out] rKernArray text positions from OutDev::GetTextArray(). +/// @param nLen number of elements to process in rKernArray and rText. +/// @param nGridWidth width of a text grid +/// @param nSpace amount of space distributed under justify text alignment mode. +/// @param nKern letter spacing. +SW_DLLPUBLIC void SnapToGridEdge(KernArray& rKernArray, sal_Int32 nLen, tools::Long nGridWidth, + tools::Long nSpace, tools::Long nKern); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |