diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-12-24 22:45:54 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-12-30 14:16:59 +0100 |
commit | 9a62dcf59af3513a82fb5640314021d064d8b9b7 (patch) | |
tree | 0ad0ca5f2cdbea316429601a1ac7511055810649 /editeng | |
parent | 72fde57386eb7b53f4b1a0954a1595e36cf17e5f (diff) |
editeng: move impl. of EditLine methods to own cxx sourcefile
Change-Id: I9856302967de59368dc60b3e01f4a36fdb97e00e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161359
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/Library_editeng.mk | 1 | ||||
-rw-r--r-- | editeng/inc/EditLine.hxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/EditLine.cxx | 90 | ||||
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 66 |
4 files changed, 95 insertions, 66 deletions
diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk index e0834b96f983..49225b910d14 100644 --- a/editeng/Library_editeng.mk +++ b/editeng/Library_editeng.mk @@ -56,6 +56,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\ editeng/source/editeng/editdbg \ editeng/source/editeng/editdoc \ editeng/source/editeng/editeng \ + editeng/source/editeng/EditLine \ editeng/source/editeng/editobj \ editeng/source/editeng/editsel \ editeng/source/editeng/editundo \ diff --git a/editeng/inc/EditLine.hxx b/editeng/inc/EditLine.hxx index df1dec9f0ae2..165f3fcf0a59 100644 --- a/editeng/inc/EditLine.hxx +++ b/editeng/inc/EditLine.hxx @@ -19,6 +19,10 @@ #pragma once +#include <vector> +#include <sal/types.h> +#include <tools/gen.hxx> + class ParaPortion; class EditLine diff --git a/editeng/source/editeng/EditLine.cxx b/editeng/source/editeng/EditLine.cxx new file mode 100644 index 000000000000..7724f8f12a79 --- /dev/null +++ b/editeng/source/editeng/EditLine.cxx @@ -0,0 +1,90 @@ +/* -*- 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 . + */ + + +#include <EditLine.hxx> +#include <editdoc.hxx> + +EditLine* EditLine::Clone() const +{ + EditLine* pL = new EditLine; + pL->aPositions = aPositions; + pL->nStartPosX = nStartPosX; + pL->nStart = nStart; + pL->nEnd = nEnd; + pL->nStartPortion = nStartPortion; + pL->nEndPortion = nEndPortion; + pL->nHeight = nHeight; + pL->nTxtWidth = nTxtWidth; + pL->nTxtHeight = nTxtHeight; + pL->nMaxAscent = nMaxAscent; + + return pL; +} + +Size EditLine::CalcTextSize( ParaPortion& rParaPortion ) +{ + Size aSz; + Size aTmpSz; + + DBG_ASSERT( rParaPortion.GetTextPortions().Count(), "GetTextSize before CreatePortions !" ); + + for ( sal_Int32 n = nStartPortion; n <= nEndPortion; n++ ) + { + TextPortion& rPortion = rParaPortion.GetTextPortions()[n]; + switch ( rPortion.GetKind() ) + { + case PortionKind::TEXT: + case PortionKind::FIELD: + case PortionKind::HYPHENATOR: + { + aTmpSz = rPortion.GetSize(); + aSz.AdjustWidth(aTmpSz.Width() ); + if ( aSz.Height() < aTmpSz.Height() ) + aSz.setHeight( aTmpSz.Height() ); + } + break; + case PortionKind::TAB: + { + aSz.AdjustWidth(rPortion.GetSize().Width() ); + } + break; + case PortionKind::LINEBREAK: break; + } + } + + SetHeight( static_cast<sal_uInt16>(aSz.Height()) ); + return aSz; +} + +void EditLine::SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH ) +{ + nHeight = nH; + nTxtHeight = ( nTxtH ? nTxtH : nH ); +} + +void EditLine::SetStartPosX( sal_Int32 start ) +{ + if (start > 0) + nStartPosX = start; + else + nStartPosX = 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 313648d24277..e37bc47a7fa3 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -890,72 +890,6 @@ void ConvertAndPutItems( SfxItemSet& rDest, const SfxItemSet& rSource, const Map } } -EditLine* EditLine::Clone() const -{ - EditLine* pL = new EditLine; - pL->aPositions = aPositions; - pL->nStartPosX = nStartPosX; - pL->nStart = nStart; - pL->nEnd = nEnd; - pL->nStartPortion = nStartPortion; - pL->nEndPortion = nEndPortion; - pL->nHeight = nHeight; - pL->nTxtWidth = nTxtWidth; - pL->nTxtHeight = nTxtHeight; - pL->nMaxAscent = nMaxAscent; - - return pL; -} - -void EditLine::SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH ) -{ - nHeight = nH; - nTxtHeight = ( nTxtH ? nTxtH : nH ); -} - -void EditLine::SetStartPosX( sal_Int32 start ) -{ - if (start > 0) - nStartPosX = start; - else - nStartPosX = 0; -} - -Size EditLine::CalcTextSize( ParaPortion& rParaPortion ) -{ - Size aSz; - Size aTmpSz; - - DBG_ASSERT( rParaPortion.GetTextPortions().Count(), "GetTextSize before CreatePortions !" ); - - for ( sal_Int32 n = nStartPortion; n <= nEndPortion; n++ ) - { - TextPortion& rPortion = rParaPortion.GetTextPortions()[n]; - switch ( rPortion.GetKind() ) - { - case PortionKind::TEXT: - case PortionKind::FIELD: - case PortionKind::HYPHENATOR: - { - aTmpSz = rPortion.GetSize(); - aSz.AdjustWidth(aTmpSz.Width() ); - if ( aSz.Height() < aTmpSz.Height() ) - aSz.setHeight( aTmpSz.Height() ); - } - break; - case PortionKind::TAB: - { - aSz.AdjustWidth(rPortion.GetSize().Width() ); - } - break; - case PortionKind::LINEBREAK: break; - } - } - - SetHeight( static_cast<sal_uInt16>(aSz.Height()) ); - return aSz; -} - EditLineList::EditLineList() { } |