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( const SfxPoolItemHolder
& 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 )
42 assert(!m_aAttr
.getItem()->isStaticDefault());
45 SwTextAttr::~SwTextAttr() COVERITY_NOEXCEPT_FALSE
49 const sal_Int32
* SwTextAttr::GetEnd() const
54 void SwTextAttr::SetEnd(sal_Int32
)
59 void SwTextAttr::Destroy( SwTextAttr
* pToDestroy
)
61 if (!pToDestroy
) return;
65 bool SwTextAttr::operator==( const SwTextAttr
& rAttr
) const
67 return GetAttr() == rAttr
.GetAttr();
70 SwTextAttrEnd::SwTextAttrEnd(
71 const SfxPoolItemHolder
& rAttr
,
74 SwTextAttr( rAttr
, nStart
), m_nEnd( nEnd
)
78 const sal_Int32
* SwTextAttrEnd::GetEnd() const
83 void SwTextAttrEnd::SetEnd(sal_Int32 n
)
87 sal_Int32 nOldEndPos
= m_nEnd
;
90 m_pHints
->EndPosChanged(Which(), GetStart(), nOldEndPos
, m_nEnd
);
94 void SwTextAttr::dumpAsXml(xmlTextWriterPtr pWriter
) const
96 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SwTextAttr"));
97 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("ptr"), "%p", this);
98 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("symbol"), "%s",
99 BAD_CAST(typeid(*this).name()));
101 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("start"), BAD_CAST(OString::number(m_nStart
).getStr()));
102 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("dont-expand"),
103 BAD_CAST(OString::boolean(m_bDontExpand
).getStr()));
105 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("end"), BAD_CAST(OString::number(*End()).getStr()));
106 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
107 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("attr-item"), "%p", m_aAttr
.getItem());
108 const char* pWhich
= nullptr;
109 std::optional
<OString
> oValue
;
112 case RES_TXTATR_AUTOFMT
:
115 case RES_TXTATR_ANNOTATION
:
116 pWhich
= "annotation";
118 case RES_TXTATR_FLYCNT
:
119 pWhich
= "fly content";
121 case RES_TXTATR_CJK_RUBY
:
124 const SwFormatRuby
& rFormat
= GetRuby();
125 oValue
= OString("rubytext: " + rFormat
.GetText().toUtf8());
128 case RES_TXTATR_META
:
133 case RES_TXTATR_FIELD
:
142 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("which"), BAD_CAST(pWhich
));
144 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(oValue
->getStr()));
147 case RES_TXTATR_AUTOFMT
:
148 GetAutoFormat().dumpAsXml(pWriter
);
150 case RES_TXTATR_FIELD
:
151 case RES_TXTATR_ANNOTATION
:
152 case RES_TXTATR_INPUTFIELD
:
153 GetFormatField().dumpAsXml(pWriter
);
156 GetFootnote().dumpAsXml(pWriter
);
158 case RES_TXTATR_LINEBREAK
:
159 GetLineBreak().dumpAsXml(pWriter
);
161 case RES_TXTATR_META
:
163 case RES_TXTATR_CONTENTCONTROL
:
164 GetContentControl().dumpAsXml(pWriter
);
166 case RES_TXTATR_FLYCNT
:
167 GetFlyCnt().dumpAsXml(pWriter
);
169 case RES_TXTATR_CHARFMT
:
170 GetCharFormat().dumpAsXml(pWriter
);
172 case RES_TXTATR_REFMARK
:
173 GetRefMark().dumpAsXml(pWriter
);
175 case RES_TXTATR_INETFMT
:
176 GetINetFormat().dumpAsXml(pWriter
);
178 case RES_TXTATR_CJK_RUBY
:
179 GetRuby().dumpAsXml(pWriter
);
182 SAL_WARN("sw.core", "Unhandled TXTATR: " << Which());
186 (void)xmlTextWriterEndElement(pWriter
);
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */