34#include <libxml/xmlwriter.h>
74 double fFontScaleX,
double fFontScaleY,
75 double fSpacingScaleX,
double fSpacingScaleY)
77 , mfFontScaleX(fFontScaleX)
78 , mfFontScaleY(fFontScaleY)
79 , mfSpacingScaleX(fSpacingScaleX)
80 , mfSpacingScaleY(fSpacingScaleY)
87 maList.push_back(std::unique_ptr<XParaPortion>(
p));
104 aStyle(rCopyFrom.aStyle),
105 eFamily(rCopyFrom.eFamily),
106 aParaAttribs(rPoolToUse)
148 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"ContentInfo"));
149 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"style"), BAD_CAST(
aStyle.toUtf8().getStr()));
150 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"text"));
153 (void)xmlTextWriterWriteString(pWriter, BAD_CAST(aText.replaceAll(
"\x01",
"").toUtf8().getStr()));
154 (void)xmlTextWriterEndElement(pWriter);
158 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"attribs"));
159 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"start"),
"%" SAL_PRIdINT32, rCharAttribs.GetStart());
160 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"end"),
"%" SAL_PRIdINT32, rCharAttribs.GetEnd());
161 rCharAttribs.GetItem()->dumpAsXml(pWriter);
162 (void)xmlTextWriterEndElement(pWriter);
164 (void)xmlTextWriterEndElement(pWriter);
190void ContentInfo::Dump()
const
192 cout <<
"--" <<
endl;
193 cout <<
"text: '" << OUString(
const_cast<rtl_uString*
>(
maText.
getData())) <<
"'" <<
endl;
196 for (
auto const& attrib : aAttribs)
198 cout <<
"attribute: " <<
endl;
199 cout <<
" span: [begin=" << attrib.GetStart() <<
", end=" << attrib.GetEnd() <<
"]" <<
endl;
200 cout <<
" feature: " << (attrib.IsFeature() ?
"yes":
"no") << endl;
216 return std::make_unique<EditTextObjectImpl>(*
this);
229 pWriter = xmlNewTextWriterFilename(
"editTextObject.xml", 0);
230 xmlTextWriterSetIndent(pWriter,1);
231 (void)xmlTextWriterSetIndentString(pWriter, BAD_CAST(
" "));
232 (void)xmlTextWriterStartDocument(pWriter,
nullptr,
nullptr,
nullptr);
236 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"EditTextObject"));
242 (void)xmlTextWriterEndElement(pWriter);
246 (void)xmlTextWriterEndDocument(pWriter);
247 xmlFreeTextWriter(pWriter);
252void EditTextObjectImpl::Dump()
const
271 pRetval->SetDefaultMetric(eDefaultMetric);
279 , meScriptType(eScriptType)
280 , meRotation(eRotation)
281 , meMetric(eDefaultMetric)
282 , mbVertical(bVertical)
288 , meUserType(r.meUserType)
289 , meScriptType(r.meScriptType)
290 , meRotation(r.meRotation)
291 , meMetric(r.meMetric)
292 , mbVertical(r.mbVertical)
327 std::vector<svl::SharedString> aSSs;
399 SAL_WARN(
"editeng",
"EditTextObjectImpl::GetParagraphCount - overflow " << nSize);
402 return static_cast<sal_Int32
>(nSize);
422 if ( content->GetWrongList() && !content->GetWrongList()->empty() )
438 rLst.push_back(aEEAttr);
452 if (rC.
GetText().getLength() == 1)
455 for (
size_t nAttr = nAttribs; nAttr; )
502 for (
size_t nPara = 0; nPara < nParagraphs; ++nPara)
506 for (
size_t nAttr = 0; nAttr < nAttrs; ++nAttr)
512 if (
nType == text::textfield::Type::UNSPECIFIED)
532 bool bChanged =
false;
534 for (
size_t nPara =
maContents.size(); nPara; )
541 if ( !_nWhich || (rAttr.
GetItem()->
Which() == _nWhich) )
562 explicit FindByParagraph(sal_Int32 nPara) : mnPara(nPara) {}
569class FindBySectionStart
574 FindBySectionStart(sal_Int32 nPara, sal_Int32 nStart) : mnPara(nPara),
mnStart(nStart) {}
585 std::vector<editeng::Section> aAttrs;
587 std::vector<size_t> aBorders;
589 for (
size_t nPara = 0; nPara <
maContents.size(); ++nPara)
593 aBorders.push_back(0);
594 aBorders.push_back(rC.
GetText().getLength());
601 aBorders.push_back(rAttr.
GetStart());
602 aBorders.push_back(rAttr.
GetEnd());
606 std::sort(aBorders.begin(), aBorders.end());
607 auto itUniqueEnd = std::unique(aBorders.begin(), aBorders.end());
608 aBorders.erase(itUniqueEnd, aBorders.end());
614 if (aBorders.size() == 1 && aBorders[0] == 0)
617 aAttrs.emplace_back(nPara, 0, 0);
621 auto itBorder = aBorders.begin(), itBorderEnd = aBorders.end();
622 size_t nPrev = *itBorder;
624 for (++itBorder; itBorder != itBorderEnd; ++itBorder, nPrev = nCur)
627 aAttrs.emplace_back(nPara, nPrev, nCur);
635 std::vector<editeng::Section>::iterator itAttr = aAttrs.begin();
636 for (sal_Int32 nPara = 0; nPara < static_cast<sal_Int32>(
maContents.size()); ++nPara)
640 itAttr = std::find_if(itAttr, aAttrs.end(), FindByParagraph(nPara));
641 if (itAttr == aAttrs.end())
657 std::vector<editeng::Section>::iterator itCurAttr = std::find_if(itAttr, aAttrs.end(), FindBySectionStart(nPara, nStart));
658 if (itCurAttr == aAttrs.end())
665 for (; itCurAttr != aAttrs.end() && itCurAttr->mnParagraph == nPara && itCurAttr->mnEnd <= nEnd; ++itCurAttr)
671 { return pIt->Which() == pItem->Which(); }))
677 SAL_WARN(
"editeng",
"GetAllSections(): duplicate attribute suppressed");
711 bool bChanges =
false;
713 for (
size_t nPara = 0; nPara < nParagraphs; ++nPara)
741 std::u16string_view rOldName,
const OUString& rNewName )
753 if(
this == &rCompare )
766 [bComparePool](
const auto& c1,
const auto& c2) { return c1->Equals(*c2, bComparePool); });
775 [](
const auto& c1,
const auto& c2) { return c1->isWrongListEqual(*c2); });
ContentInfo(SfxItemPool &rPool)
void NormalizeString(svl::SharedStringPool &rPool)
bool Equals(const ContentInfo &rCompare, bool bComparePool) const
const svl::SharedString & GetSharedString() const
SfxStyleFamily GetFamily() const
const SfxItemSet & GetParaAttribs() const
SfxItemSetFixed< EE_PARA_START, EE_CHAR_END > aParaAttribs
std::unique_ptr< WrongList > mpWrongs
void SetStyle(const OUString &rStyle)
const WrongList * GetWrongList() const
void SetFamily(const SfxStyleFamily &rFamily)
std::vector< XEditAttribute > maCharAttribs
void SetText(const OUString &rStr)
void SetWrongList(WrongList *p)
void dumpAsXml(xmlTextWriterPtr pWriter) const
const OUString & GetStyle() const
bool isWrongListEqual(const ContentInfo &rCompare) const
static rtl::Reference< SfxItemPool > CreatePool()
bool ImpChangeStyleSheets(std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString &rNewName, SfxStyleFamily eNewFamily)
virtual bool isWrongListEqual(const EditTextObject &rCompare) const override
virtual bool IsTopToBottom() const override
virtual bool RemoveCharAttribs(sal_uInt16 nWhich) override
std::unique_ptr< XParaPortionList > mpPortionInfo
virtual OUString GetText(sal_Int32 nParagraph) const override
virtual void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString &rNewName) override
virtual ~EditTextObjectImpl() override
virtual void NormalizeString(svl::SharedStringPool &rPool) override
Set paragraph strings to the shared string pool.
virtual const SvxFieldItem * GetField() const override
virtual bool GetVertical() const override
virtual TextRotation GetRotation() const override
virtual std::vector< svl::SharedString > GetSharedStrings() const override
SvtScriptType meScriptType
virtual void GetStyleSheet(sal_Int32 nPara, OUString &rName, SfxStyleFamily &eFamily) const override
virtual bool IsEffectivelyVertical() const override
EditTextObjectImpl(SfxItemPool *pPool, MapUnit eDefaultMetric, bool bVertical, TextRotation eRotation, SvtScriptType eScriptType)
virtual const SvxFieldData * GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const override
virtual bool operator==(const EditTextObject &rCompare) const override
ContentInfosType maContents
virtual sal_Int32 GetParagraphCount() const override
virtual void ClearPortionInfo() override
ContentInfo * CreateAndInsertContent()
virtual std::unique_ptr< EditTextObject > Clone() const override
virtual bool HasField(sal_Int32 nType=css::text::textfield::Type::UNSPECIFIED) const override
virtual void SetVertical(bool bVert) override
rtl::Reference< SfxItemPool > mpPool
virtual void GetAllSections(std::vector< editeng::Section > &rAttrs) const override
Get all text sections in this content.
void DestroyAttrib(const XEditAttribute &rAttr)
virtual bool ChangeStyleSheets(std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString &rNewName, SfxStyleFamily eNewFamily) override
virtual void SetStyleSheet(sal_Int32 nPara, const OUString &rName, const SfxStyleFamily &eFamily) override
virtual const SfxItemSet & GetParaAttribs(sal_Int32 nPara) const override
virtual void SetUserType(OutlinerMode n) override
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
XEditAttribute CreateAttrib(const SfxPoolItem &rItem, sal_Int32 nStart, sal_Int32 nEnd)
virtual bool IsFieldObject() const override
bool Equals(const EditTextObjectImpl &rCompare, bool bComparePool) const
virtual void SetRotation(TextRotation nRotation) override
virtual void GetCharAttribs(sal_Int32 nPara, std::vector< EECharAttrib > &rLst) const override
virtual bool HasOnlineSpellErrors() const override
bool Equals(const EditTextObject &rCompare) const
Compare, ignoring SfxItemPool pointer.
virtual ~EditTextObject()
SfxItemPool * GetSecondaryPool() const
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
void Remove(const SfxPoolItem &)
SfxItemPool * GetPool() const
void dumpAsXml(xmlTextWriterPtr pWriter) const
bool Set(const SfxItemSet &, bool bDeep=true)
bool Equals(const SfxItemSet &, bool bComparePool) const
virtual sal_Int32 GetClassId() const
This item stores a field (SvxFieldData).
const SvxFieldData * GetField() const
Keeps track of misspelled ranges in paragraph.
WrongList * Clone() const
const SfxPoolItem * pItem
const SfxPoolItem * GetItem() const
XEditAttribute(const SfxPoolItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
void SetItem(const SfxPoolItem &rNew)
void push_back(XParaPortion *p)
XParaPortionList(OutputDevice *pRefDev, sal_uInt32 nPW, double fFontScaleX, double fFontScaleY, double fSpacingScaleX, double fSpacingScaleY)
const XParaPortion & operator[](size_t i) const
SharedString intern(const OUString &rStr)
#define EE_PARA_MAX_COUNT
EditTextObjectImpl & toImpl(EditTextObject &rObj)
static XEditAttribute MakeXEditAttribute(SfxItemPool &rPool, const SfxPoolItem &rItem, sal_Int32 nStart, sal_Int32 nEnd)
static rtl::Reference< SfxItemPool > getEditEngineItemPool(SfxItemPool *pPool, MapUnit eDefaultMetric)
constexpr sal_uInt16 EE_FEATURE_END(EE_FEATURE_FIELD+0)
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
constexpr sal_uInt16 EE_FEATURE_START(EE_CHAR_END+1)
struct _xmlTextWriter * xmlTextWriterPtr
#define SAL_WARN(area, stream)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
TOOLS_DLLPUBLIC SvStream & endl(SvStream &rStr)
std::vector< const SfxPoolItem * > maAttributes