Extract SwTxtAttr::dumpAsXml() from SwTxtNode
Change-Id: I20914ec147b2af096bd40ec0e4da7567a44abaaa
This commit is contained in:
parent
463f7be3f7
commit
a4dbfa82fd
@ -119,6 +119,7 @@ public:
|
||||
inline const SwFmtRuby &GetRuby() const;
|
||||
inline const SwFmtMeta &GetMeta() const;
|
||||
|
||||
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
|
||||
};
|
||||
|
||||
class SwTxtAttrEnd : public virtual SwTxtAttr
|
||||
|
@ -283,49 +283,7 @@ void SwTxtNode::dumpAsXml( xmlTextWriterPtr w ) const
|
||||
writer.startElement("hints");
|
||||
const SwpHints& rHints = GetSwpHints();
|
||||
for (size_t i = 0; i < rHints.Count(); ++i)
|
||||
{
|
||||
writer.startElement("hint");
|
||||
const SwTxtAttr* pHint = rHints.GetTextHint(i);
|
||||
|
||||
if (pHint->GetStart())
|
||||
writer.writeFormatAttribute("start", TMP_FORMAT, pHint->GetStart());
|
||||
if (pHint->End())
|
||||
writer.writeFormatAttribute("end", TMP_FORMAT, *pHint->End());
|
||||
writer.writeFormatAttribute("whichId", TMP_FORMAT, pHint->Which());
|
||||
|
||||
const char* pWhich = 0;
|
||||
boost::optional<OString> oValue;
|
||||
switch (pHint->Which())
|
||||
{
|
||||
case RES_TXTATR_AUTOFMT:
|
||||
pWhich = "autofmt";
|
||||
break;
|
||||
case RES_TXTATR_ANNOTATION:
|
||||
pWhich = "annotation";
|
||||
break;
|
||||
case RES_TXTATR_FLYCNT:
|
||||
pWhich = "fly content";
|
||||
break;
|
||||
case RES_TXTATR_CHARFMT:
|
||||
{
|
||||
pWhich = "character format";
|
||||
if (SwCharFmt* pCharFmt = pHint->GetCharFmt().GetCharFmt())
|
||||
oValue = "name: " + OUStringToOString(pCharFmt->GetName(), RTL_TEXTENCODING_UTF8);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (pWhich)
|
||||
writer.writeFormatAttribute("which", "%s", BAD_CAST(pWhich));
|
||||
if (oValue)
|
||||
writer.writeFormatAttribute("value", "%s", BAD_CAST(oValue->getStr()));
|
||||
|
||||
if (pHint->Which() == RES_TXTATR_AUTOFMT)
|
||||
pHint->GetAutoFmt().dumpAsXml(writer);
|
||||
|
||||
writer.endElement();
|
||||
}
|
||||
rHints.GetTextHint(i)->dumpAsXml(w);
|
||||
writer.endElement();
|
||||
}
|
||||
if (GetNumRule())
|
||||
|
@ -17,6 +17,8 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <libxml/xmlwriter.h>
|
||||
#include <svl/itempool.hxx>
|
||||
#include <txatbase.hxx>
|
||||
#include <fmtfld.hxx>
|
||||
@ -73,4 +75,45 @@ sal_Int32* SwTxtAttrEnd::GetEnd()
|
||||
return & m_nEnd;
|
||||
}
|
||||
|
||||
void SwTxtAttr::dumpAsXml(xmlTextWriterPtr pWriter) const
|
||||
{
|
||||
xmlTextWriterStartElement(pWriter, BAD_CAST("swTxtAttr"));
|
||||
|
||||
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("start"), BAD_CAST(OString::number(m_nStart).getStr()));
|
||||
if (End())
|
||||
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("end"), BAD_CAST(OString::number(*End()).getStr()));
|
||||
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
|
||||
const char* pWhich = 0;
|
||||
boost::optional<OString> oValue;
|
||||
switch (Which())
|
||||
{
|
||||
case RES_TXTATR_AUTOFMT:
|
||||
pWhich = "autofmt";
|
||||
break;
|
||||
case RES_TXTATR_ANNOTATION:
|
||||
pWhich = "annotation";
|
||||
break;
|
||||
case RES_TXTATR_FLYCNT:
|
||||
pWhich = "fly content";
|
||||
break;
|
||||
case RES_TXTATR_CHARFMT:
|
||||
{
|
||||
pWhich = "character format";
|
||||
if (SwCharFmt* pCharFmt = GetCharFmt().GetCharFmt())
|
||||
oValue = "name: " + OUStringToOString(pCharFmt->GetName(), RTL_TEXTENCODING_UTF8);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (pWhich)
|
||||
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(pWhich));
|
||||
if (oValue)
|
||||
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(oValue->getStr()));
|
||||
if (Which() == RES_TXTATR_AUTOFMT)
|
||||
GetAutoFmt().dumpAsXml(pWriter);
|
||||
|
||||
xmlTextWriterEndElement(pWriter);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
Loading…
x
Reference in New Issue
Block a user