Files
odfstudio/include/editeng/editobj.hxx
T
Noel Grandin fcf0bcc0f9 Hold EditTextObject by value in OutlinerParaObjData, not by pointer
OutlinerParaObjData is already ref-counted data, no need
for further indirection.

Unfortunately, this sets off a larger chain of changes
than I would have preferred, but we end up storing
EditTextObject on the stack much more than before, so
that worked out well.

Change-Id: Ie7d0ccfbfeec4e6935f2ed6b8ad48aadfe1bac20
Signed-off-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10973
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit fbf7d1bc7142d3f0e4e5f959983dea065afc5ea3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210927
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-14 16:27:02 +02:00

185 lines
6.4 KiB
C++

/* -*- 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 .
*/
#ifndef INCLUDED_EDITENG_EDITOBJ_HXX
#define INCLUDED_EDITENG_EDITOBJ_HXX
#include <svl/style.hxx>
#include <editeng/editengdllapi.h>
#include <editeng/macros.hxx>
#include <svl/itempool.hxx>
#include <svl/languageoptions.hxx>
#include <tools/lineend.hxx>
#include <tools/mapunit.hxx>
#include <com/sun/star/text/textfield/Type.hpp>
#include <vector>
#include <memory>
class SfxItemPool;
class SfxItemSet;
class SvxFieldItem;
class SvxFieldData;
enum class OutlinerMode;
struct EECharAttrib;
typedef struct _xmlTextWriter* xmlTextWriterPtr;
class ContentInfo;
class XParaPortionList;
namespace editeng {
class FieldUpdater;
struct Section;
}
namespace svl {
class SharedString;
class SharedStringPool;
}
enum class TextRotation { NONE, TOPTOBOTTOM, BOTTOMTOTOP };
class EDITENG_DLLPUBLIC EditTextObject final
{
public:
typedef std::vector<std::unique_ptr<ContentInfo> > ContentInfosType;
EditTextObject(SfxItemPool* pPool, MapUnit eDefaultMetric, bool bVertical,
TextRotation eRotation, SvtScriptType eScriptType);
EditTextObject( const EditTextObject& r );
EditTextObject( EditTextObject&& r ) noexcept;
~EditTextObject();
EditTextObject& operator=(EditTextObject&&);
/**
* Set paragraph strings to the shared string pool.
*
* @param rPool shared string pool.
*/
void NormalizeString( svl::SharedStringPool& rPool );
std::vector<svl::SharedString> GetSharedStrings() const;
const SfxItemPool* GetPool() const { return mpPool.get(); }
SfxItemPool* GetPool() { return mpPool.get(); }
OutlinerMode GetUserType() const { return meUserType;} // For OutlinerMode, it can however not save in compatible format
void SetUserType( OutlinerMode n );
bool IsEffectivelyVertical() const;
bool GetVertical() const;
bool IsTopToBottom() const;
void SetVertical( bool bVertical );
void SetRotation( TextRotation nRotation );
TextRotation GetRotation() const;
SvtScriptType GetScriptType() const { return meScriptType;}
sal_Int32 GetParagraphCount() const;
OUString GetText(sal_Int32 nPara) const;
OUString GetText(LineEnd eEnd = LINEEND_LF) const;
sal_Int32 GetTextLen(sal_Int32 nPara) const;
bool HasText(sal_Int32 nPara) const { return GetTextLen(nPara) > 0; }
XParaPortionList* GetPortionInfo() const { return mpPortionInfo.get(); }
void SetPortionInfo( std::unique_ptr<XParaPortionList> pP );
void ClearPortionInfo();
sal_Int16 GetNumberingDepth(sal_Int32 nPara) const;
void SetNumberingDepth(sal_Int32 nPara, sal_Int16 nDepth);
sal_Int16 GetNumberingStartValue(sal_Int32 nPara) const;
void SetNumberingStartValue(sal_Int32 nPara, sal_Int16 nStartValue);
bool IsNumberingRestart(sal_Int32 nPara) const;
void SetNumberingRestart(sal_Int32 nPara, bool bRestart);
bool HasOnlineSpellErrors() const;
void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const;
bool RemoveCharAttribs( sal_uInt16 nWhich );
/**
* Get all text sections in this content. Sections are non-overlapping
* segments of text split either by paragraph boundaries or format
* boundaries. Each section object contains all applied formats and/or a
* field item.
*/
void GetAllSections( std::vector<editeng::Section>& rAttrs ) const;
bool IsFieldObject() const;
const SvxFieldItem* GetField() const;
const SvxFieldData* GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const;
bool HasField( sal_Int32 nType = css::text::textfield::Type::UNSPECIFIED ) const;
const SfxItemSet& GetParaAttribs(sal_Int32 nPara) const;
void GetStyleSheet(sal_Int32 nPara, OUString& rName, SfxStyleFamily& eFamily) const;
void SetStyleSheet(sal_Int32 nPara, const OUString& rName, const SfxStyleFamily& eFamily);
bool ChangeStyleSheets(
std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily);
void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString& rNewName);
editeng::FieldUpdater GetFieldUpdater();
bool operator==( const EditTextObject& rCompare ) const;
/** Compare, ignoring SfxItemPool pointer.
*/
bool Equals( const EditTextObject& rCompare ) const;
bool Equals( const EditTextObject& rCompare, bool bComparePool ) const;
// #i102062#
bool isWrongListEqual(const EditTextObject& rCompare) const;
ContentInfo* CreateAndInsertContent();
ContentInfosType& GetContents() { return maContents;}
const ContentInfosType& GetContents() const { return maContents;}
bool HasMetric() const { return meMetric != MapUnit::LASTENUMDUMMY; }
MapUnit GetMetric() const { return meMetric; }
#if DEBUG_EDIT_ENGINE
void Dump() const;
#endif
void dumpAsXml(xmlTextWriterPtr pWriter) const;
private:
bool ImpChangeStyleSheets( std::u16string_view rOldName, SfxStyleFamily eOldFamily,
const OUString& rNewName, SfxStyleFamily eNewFamily );
ContentInfosType maContents;
rtl::Reference<SfxItemPool> mpPool;
std::unique_ptr<XParaPortionList> mpPortionInfo;
OutlinerMode meUserType;
SvtScriptType meScriptType;
TextRotation meRotation;
MapUnit meMetric;
bool mbVertical;
};
#endif // INCLUDED_EDITENG_EDITOBJ_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */