android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / txtnode / txatbase.cxx
blob9fdd1212543fa2cb56be84c433247a8c1925c628
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <optional>
21 #include <libxml/xmlwriter.h>
22 #include <svl/itempool.hxx>
23 #include <txatbase.hxx>
24 #include <fmtfld.hxx>
26 SwTextAttr::SwTextAttr( SfxPoolItem& rAttr, sal_Int32 nStart )
27 : m_pAttr( &rAttr )
28 , m_nStart( 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 )
36 , m_bNesting( 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
50 return nullptr;
53 void SwTextAttr::SetEnd(sal_Int32 )
55 assert(false);
58 void SwTextAttr::Destroy( SwTextAttr * pToDestroy, SfxItemPool& rPool )
60 if (!pToDestroy) return;
61 SfxPoolItem * const pAttr = pToDestroy->m_pAttr;
62 delete pToDestroy;
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
79 return & m_nEnd;
82 void SwTextAttrEnd::SetEnd(sal_Int32 n)
84 m_nEnd = n;
85 if (m_pHints)
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()));
99 if (End())
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;
105 switch (Which())
107 case RES_TXTATR_AUTOFMT:
108 pWhich = "autofmt";
109 break;
110 case RES_TXTATR_ANNOTATION:
111 pWhich = "annotation";
112 break;
113 case RES_TXTATR_FLYCNT:
114 pWhich = "fly content";
115 break;
116 case RES_TXTATR_INETFMT:
118 pWhich = "inet format";
119 const SwFormatINetFormat& rFormat = GetINetFormat();
120 oValue = OString("url: " + rFormat.GetValue().toUtf8());
121 break;
123 case RES_TXTATR_CJK_RUBY:
125 pWhich = "ruby";
126 const SwFormatRuby& rFormat = GetRuby();
127 oValue = OString("rubytext: " + rFormat.GetText().toUtf8());
128 break;
130 case RES_TXTATR_META:
132 pWhich = "meta";
133 break;
135 case RES_TXTATR_FIELD:
137 pWhich = "field";
138 break;
140 default:
141 break;
143 if (pWhich)
144 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("which"), BAD_CAST(pWhich));
145 if (oValue)
146 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(oValue->getStr()));
147 switch (Which())
149 case RES_TXTATR_AUTOFMT:
150 GetAutoFormat().dumpAsXml(pWriter);
151 break;
152 case RES_TXTATR_FIELD:
153 case RES_TXTATR_INPUTFIELD:
154 GetFormatField().dumpAsXml(pWriter);
155 break;
156 case RES_TXTATR_FTN:
157 GetFootnote().dumpAsXml(pWriter);
158 break;
159 case RES_TXTATR_LINEBREAK:
160 GetLineBreak().dumpAsXml(pWriter);
161 break;
162 case RES_TXTATR_META:
163 break;
164 case RES_TXTATR_CONTENTCONTROL:
165 GetContentControl().dumpAsXml(pWriter);
166 break;
167 case RES_TXTATR_FLYCNT:
168 GetFlyCnt().dumpAsXml(pWriter);
169 break;
170 case RES_TXTATR_CHARFMT:
171 GetCharFormat().dumpAsXml(pWriter);
172 break;
173 case RES_TXTATR_REFMARK:
174 GetRefMark().dumpAsXml(pWriter);
175 break;
176 default:
177 SAL_WARN("sw.core", "Unhandled TXTATR");
178 break;
181 (void)xmlTextWriterEndElement(pWriter);
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */