1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <libxml/xmlwriter.h>
22 #include <svl/itempool.hxx>
23 #include <txatbase.hxx>
26 SwTextAttr::SwTextAttr( SfxPoolItem
& rAttr
, sal_Int32 nStart
)
29 , m_bDontExpand( false )
30 , m_bLockExpandFlag( false )
31 , m_bDontMoveAttr( false )
32 , m_bCharFormatAttr( false )
33 , m_bOverlapAllowedAttr( false )
34 , m_bPriorityAttr( false )
35 , m_bDontExpandStart( false )
37 , m_bHasDummyChar( false )
38 , m_bFormatIgnoreStart(false)
39 , m_bFormatIgnoreEnd(false)
40 , m_bHasContent( false )
44 SwTextAttr::~SwTextAttr() COVERITY_NOEXCEPT_FALSE
48 const sal_Int32
* SwTextAttr::GetEnd() const
53 void SwTextAttr::SetEnd(sal_Int32
)
58 void SwTextAttr::Destroy( SwTextAttr
* pToDestroy
, SfxItemPool
& rPool
)
60 if (!pToDestroy
) return;
61 SfxPoolItem
* const pAttr
= pToDestroy
->m_pAttr
;
63 rPool
.Remove( *pAttr
);
66 bool SwTextAttr::operator==( const SwTextAttr
& rAttr
) const
68 return GetAttr() == rAttr
.GetAttr();
71 SwTextAttrEnd::SwTextAttrEnd( SfxPoolItem
& rAttr
,
72 sal_Int32 nStart
, sal_Int32 nEnd
) :
73 SwTextAttr( rAttr
, nStart
), m_nEnd( nEnd
)
77 const sal_Int32
* SwTextAttrEnd::GetEnd() const
82 void SwTextAttrEnd::SetEnd(sal_Int32 n
)
86 m_pHints
->EndPosChanged();
89 void SwTextAttr::dumpAsXml(xmlTextWriterPtr pWriter
) const
91 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SwTextAttr"));
92 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("ptr"), "%p", this);
93 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("symbol"), "%s",
94 BAD_CAST(typeid(*this).name()));
96 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("start"), BAD_CAST(OString::number(m_nStart
).getStr()));
97 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("dont-expand"),
98 BAD_CAST(OString::boolean(m_bDontExpand
).getStr()));
100 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("end"), BAD_CAST(OString::number(*End()).getStr()));
101 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
102 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("m_pAttr"), "%p", m_pAttr
);
103 const char* pWhich
= nullptr;
104 std::optional
<OString
> oValue
;
107 case RES_TXTATR_AUTOFMT
:
110 case RES_TXTATR_ANNOTATION
:
111 pWhich
= "annotation";
113 case RES_TXTATR_FLYCNT
:
114 pWhich
= "fly content";
116 case RES_TXTATR_INETFMT
:
118 pWhich
= "inet format";
119 const SwFormatINetFormat
& rFormat
= GetINetFormat();
120 oValue
= OString("url: " + rFormat
.GetValue().toUtf8());
123 case RES_TXTATR_CJK_RUBY
:
126 const SwFormatRuby
& rFormat
= GetRuby();
127 oValue
= OString("rubytext: " + rFormat
.GetText().toUtf8());
130 case RES_TXTATR_META
:
135 case RES_TXTATR_FIELD
:
144 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("which"), BAD_CAST(pWhich
));
146 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(oValue
->getStr()));
149 case RES_TXTATR_AUTOFMT
:
150 GetAutoFormat().dumpAsXml(pWriter
);
152 case RES_TXTATR_FIELD
:
153 case RES_TXTATR_INPUTFIELD
:
154 GetFormatField().dumpAsXml(pWriter
);
157 GetFootnote().dumpAsXml(pWriter
);
159 case RES_TXTATR_LINEBREAK
:
160 GetLineBreak().dumpAsXml(pWriter
);
162 case RES_TXTATR_META
:
164 case RES_TXTATR_CONTENTCONTROL
:
165 GetContentControl().dumpAsXml(pWriter
);
167 case RES_TXTATR_FLYCNT
:
168 GetFlyCnt().dumpAsXml(pWriter
);
170 case RES_TXTATR_CHARFMT
:
171 GetCharFormat().dumpAsXml(pWriter
);
173 case RES_TXTATR_REFMARK
:
174 GetRefMark().dumpAsXml(pWriter
);
177 SAL_WARN("sw.core", "Unhandled TXTATR");
181 (void)xmlTextWriterEndElement(pWriter
);
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */