[Libreoffice-commits] core.git: sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Sat Jan 24 11:12:12 PST 2015
sw/source/core/doc/docbm.cxx | 73 ++++++++++++++++++++++++++++++
sw/source/core/docnode/nodedump.cxx | 85 ------------------------------------
sw/source/core/inc/MarkManager.hxx | 2
3 files changed, 74 insertions(+), 86 deletions(-)
New commits:
commit 904c9dde9178cfeb05467924fcdaec911a542655
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Sat Jan 24 17:33:59 2015 +0100
Move sw::mark::MarkManager::dumpAsXml() out of docnode
It has nothing to do with SwTxtNode. There is still some code
duplication, but at least now the implementation is next to the rest of
the sw::mark code.
Change-Id: I119a253b8e3fd024dcfc088259f7516a4a8060b8
Reviewed-on: https://gerrit.libreoffice.org/14156
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index bc55a9b..fd3f601 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -55,6 +55,7 @@
#include <edimp.hxx>
#include <stdio.h>
#include <tools/datetimeutils.hxx>
+#include <comphelper/anytostring.hxx>
using namespace ::boost;
using namespace ::sw::mark;
@@ -1138,6 +1139,78 @@ namespace sw { namespace mark
return (m_aMarkNamesSet.find(rName) != m_aMarkNamesSet.end());
}
+void MarkManager::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+ xmlTextWriterStartElement(pWriter, BAD_CAST("markManager"));
+ if (!m_vBookmarks.empty())
+ {
+ xmlTextWriterStartElement(pWriter, BAD_CAST("bookmarks"));
+ for (const_iterator_t it = m_vBookmarks.begin(); it != m_vBookmarks.end(); ++it)
+ {
+ pMark_t pMark = *it;
+ xmlTextWriterStartElement(pWriter, BAD_CAST("bookmark"));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("startNode"), BAD_CAST(OString::number(pMark->GetMarkStart().nNode.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("startOffset"), BAD_CAST(OString::number(pMark->GetMarkStart().nContent.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("endNode"), BAD_CAST(OString::number(pMark->GetMarkEnd().nNode.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("endOffset"), BAD_CAST(OString::number(pMark->GetMarkEnd().nContent.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(pMark->GetName().toUtf8().getStr()));
+ xmlTextWriterEndElement(pWriter);
+ }
+ xmlTextWriterEndElement(pWriter);
+ }
+
+ if (!m_vFieldmarks.empty())
+ {
+ xmlTextWriterStartElement(pWriter, BAD_CAST("fieldmarks"));
+ for (const_iterator_t it = m_vFieldmarks.begin(); it != m_vFieldmarks.end(); ++it)
+ {
+ pMark_t pMark = *it;
+ xmlTextWriterStartElement(pWriter, BAD_CAST("fieldmark"));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("startNode"), BAD_CAST(OString::number(pMark->GetMarkStart().nNode.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("startOffset"), BAD_CAST(OString::number(pMark->GetMarkStart().nContent.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("endNode"), BAD_CAST(OString::number(pMark->GetMarkEnd().nNode.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("endOffset"), BAD_CAST(OString::number(pMark->GetMarkEnd().nContent.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(pMark->GetName().toUtf8().getStr()));
+ if (sw::mark::IFieldmark* pFieldmark = dynamic_cast<sw::mark::IFieldmark*>(pMark.get()))
+ {
+ sw::mark::IFieldmark::parameter_map_t* pParameters = pFieldmark->GetParameters();
+ if (pParameters)
+ {
+ xmlTextWriterStartElement(pWriter, BAD_CAST("parameters"));
+ for (sw::mark::IFieldmark::parameter_map_t::iterator parameter = pParameters->begin(); parameter != pParameters->end(); ++parameter)
+ {
+ xmlTextWriterStartElement(pWriter, BAD_CAST("parameter"));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(parameter->first.toUtf8().getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(comphelper::anyToString(parameter->second).toUtf8().getStr()));
+ xmlTextWriterEndElement(pWriter);
+ }
+ xmlTextWriterEndElement(pWriter);
+ }
+ }
+ xmlTextWriterEndElement(pWriter);
+ }
+ xmlTextWriterEndElement(pWriter);
+ }
+
+ if (!m_vAnnotationMarks.empty())
+ {
+ xmlTextWriterStartElement(pWriter, BAD_CAST("annotationmarks"));
+ for (const_iterator_t it = m_vAnnotationMarks.begin(); it != m_vAnnotationMarks.end(); ++it)
+ {
+ pMark_t pMark = *it;
+ xmlTextWriterStartElement(pWriter, BAD_CAST("annotationmark"));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("startNode"), BAD_CAST(OString::number(pMark->GetMarkStart().nNode.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("startOffset"), BAD_CAST(OString::number(pMark->GetMarkStart().nContent.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("endNode"), BAD_CAST(OString::number(pMark->GetMarkEnd().nNode.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("endOffset"), BAD_CAST(OString::number(pMark->GetMarkEnd().nContent.GetIndex()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(pMark->GetName().toUtf8().getStr()));
+ xmlTextWriterEndElement(pWriter);
+ }
+ xmlTextWriterEndElement(pWriter);
+ }
+ xmlTextWriterEndElement(pWriter);
+}
+
}} // namespace ::sw::mark
namespace
diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx
index ccd2e4e..67ea050 100644
--- a/sw/source/core/docnode/nodedump.cxx
+++ b/sw/source/core/docnode/nodedump.cxx
@@ -24,7 +24,6 @@
#include <tools/datetimeutils.hxx>
#include <libxml/xmlwriter.h>
-#include <comphelper/anytostring.hxx>
using namespace com::sun::star;
@@ -129,90 +128,6 @@ void SwDoc::dumpAsXml( xmlTextWriterPtr w ) const
writer.endElement();
}
-namespace sw {
-namespace mark {
-void MarkManager::dumpAsXml( xmlTextWriterPtr w ) const
-{
- WriterHelper writer(w);
- writer.startElement("markManager");
- if (!m_vBookmarks.empty())
- {
- writer.startElement("bookmarks");
- for (const_iterator_t it = m_vBookmarks.begin(); it != m_vBookmarks.end(); ++it)
- {
- pMark_t pMark = *it;
- writer.startElement("bookmark");
- writer.writeFormatAttribute("startNode", TMP_FORMAT, pMark->GetMarkStart().nNode.GetIndex());
- writer.writeFormatAttribute("startOffset", TMP_FORMAT_I32, pMark->GetMarkStart().nContent.GetIndex());
- writer.writeFormatAttribute("endNode", TMP_FORMAT, pMark->GetMarkEnd().nNode.GetIndex());
- writer.writeFormatAttribute("endOffset", TMP_FORMAT_I32, pMark->GetMarkEnd().nContent.GetIndex());
- OString txt8 = OUStringToOString(pMark->GetName(), RTL_TEXTENCODING_UTF8);
- writer.writeFormatAttribute("name", "%s", BAD_CAST( txt8.getStr()));
- writer.endElement();
- }
- writer.endElement();
- }
-
- if (!m_vFieldmarks.empty())
- {
- writer.startElement("fieldmarks");
- for (const_iterator_t it = m_vFieldmarks.begin(); it != m_vFieldmarks.end(); ++it)
- {
- pMark_t pMark = *it;
- writer.startElement("fieldmark");
- writer.writeFormatAttribute("startNode", TMP_FORMAT, pMark->GetMarkStart().nNode.GetIndex());
- writer.writeFormatAttribute("startOffset", TMP_FORMAT_I32, pMark->GetMarkStart().nContent.GetIndex());
- writer.writeFormatAttribute("endNode", TMP_FORMAT, pMark->GetMarkEnd().nNode.GetIndex());
- writer.writeFormatAttribute("endOffset", TMP_FORMAT_I32, pMark->GetMarkEnd().nContent.GetIndex());
- OString txt8 = OUStringToOString(pMark->GetName(), RTL_TEXTENCODING_UTF8);
- writer.writeFormatAttribute("name", "%s", BAD_CAST( txt8.getStr()));
-
- if (sw::mark::IFieldmark* pFieldmark = dynamic_cast<sw::mark::IFieldmark*>(pMark.get()))
- {
- sw::mark::IFieldmark::parameter_map_t* pParameters = pFieldmark->GetParameters();
- if (pParameters)
- {
- writer.startElement("parameters");
- for (sw::mark::IFieldmark::parameter_map_t::iterator parameter = pParameters->begin(); parameter != pParameters->end(); ++parameter)
- {
- writer.startElement("parameter");
- OString aName = OUStringToOString(parameter->first, RTL_TEXTENCODING_UTF8);
- writer.writeFormatAttribute("name", "%s", BAD_CAST(aName.getStr()));
- OString aValue = OUStringToOString(comphelper::anyToString(parameter->second), RTL_TEXTENCODING_UTF8);
- writer.writeFormatAttribute("value", "%s", BAD_CAST(aValue.getStr()));
- writer.endElement();
- }
- writer.endElement();
- }
- }
-
- writer.endElement();
- }
- writer.endElement();
- }
-
- if (!m_vAnnotationMarks.empty())
- {
- writer.startElement("annotationmarks");
- for (const_iterator_t it = m_vAnnotationMarks.begin(); it != m_vAnnotationMarks.end(); ++it)
- {
- pMark_t pMark = *it;
- writer.startElement("annotationmark");
- writer.writeFormatAttribute("startNode", TMP_FORMAT, pMark->GetMarkStart().nNode.GetIndex());
- writer.writeFormatAttribute("startOffset", TMP_FORMAT_I32, pMark->GetMarkStart().nContent.GetIndex());
- writer.writeFormatAttribute("endNode", TMP_FORMAT, pMark->GetMarkEnd().nNode.GetIndex());
- writer.writeFormatAttribute("endOffset", TMP_FORMAT_I32, pMark->GetMarkEnd().nContent.GetIndex());
- OString txt8 = OUStringToOString(pMark->GetName(), RTL_TEXTENCODING_UTF8);
- writer.writeFormatAttribute("name", "%s", BAD_CAST( txt8.getStr()));
- writer.endElement();
- }
- writer.endElement();
- }
- writer.endElement();
-}
-} // namespace mark
-} // namespace sw
-
void SwFldTypes::dumpAsXml( xmlTextWriterPtr w ) const
{
WriterHelper writer(w);
diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx
index bd25253..87a4c50 100644
--- a/sw/source/core/inc/MarkManager.hxx
+++ b/sw/source/core/inc/MarkManager.hxx
@@ -84,7 +84,7 @@ namespace sw {
virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition &rPos) const SAL_OVERRIDE;
virtual std::vector< ::sw::mark::IFieldmark* > getDropDownsFor(const SwPaM &rPaM) const SAL_OVERRIDE;
- void dumpAsXml(xmlTextWriterPtr w) const;
+ void dumpAsXml(struct _xmlTextWriter* pWriter) const;
// Annotation Marks
virtual const_iterator_t getAnnotationMarksBegin() const SAL_OVERRIDE;
More information about the Libreoffice-commits
mailing list