summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-02-24 09:03:24 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-02-24 09:05:29 +0100
commit44009b9a9d09c2574b4740881a848556eea2859d (patch)
tree097e89a58ab0d1b1c7701ed74b34044e283f3149 /sw
parentb09c594fdd6bf5624da42a96a0fc00e727698f4a (diff)
Add SwPaM::dumpAsXml()
To avoid code duplication in SwRangeRedline::dumpAsXml() and SwFrm::dumpAsXml(). Change-Id: Ic473cd77e960041b035b147dd31c16b141cc7cbe
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/pam.hxx2
-rw-r--r--sw/source/core/crsr/pam.cxx18
-rw-r--r--sw/source/core/doc/docredln.cxx7
-rw-r--r--sw/source/core/text/xmldump.cxx12
4 files changed, 23 insertions, 16 deletions
diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 616a45a6061a..30a19c313a10 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -315,6 +315,8 @@ public:
{ return GetPrevInRing(); }
bool IsMultiSelection() const
{ return !unique(); }
+
+ void dumpAsXml(struct _xmlTextWriter* pWriter) const;
};
std::ostream &operator <<(std::ostream& s, const SwPaM& pam);
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index b8dc0a6c3ee0..16f107c40ac6 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -1098,6 +1098,24 @@ void SwPaM::InvalidatePaM()
}
}
+void SwPaM::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+ xmlTextWriterStartElement(pWriter, BAD_CAST("swPaM"));
+
+ xmlTextWriterStartElement(pWriter, BAD_CAST("point"));
+ GetPoint()->dumpAsXml(pWriter);
+ xmlTextWriterEndElement(pWriter);
+
+ if (HasMark())
+ {
+ xmlTextWriterStartElement(pWriter, BAD_CAST("mark"));
+ GetMark()->dumpAsXml(pWriter);
+ xmlTextWriterEndElement(pWriter);
+ }
+
+ xmlTextWriterEndElement(pWriter);
+}
+
std::ostream &operator <<(std::ostream& s, const SwPaM& pam)
{
if( pam.HasMark())
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 82ce470da54d..ba755ab43a82 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1640,12 +1640,7 @@ void SwRangeRedline::dumpAsXml(xmlTextWriterPtr pWriter) const
}
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), BAD_CAST(sRedlineType.getStr()));
- xmlTextWriterStartElement(pWriter, BAD_CAST("point"));
- GetPoint()->dumpAsXml(pWriter);
- xmlTextWriterEndElement(pWriter);
- xmlTextWriterStartElement(pWriter, BAD_CAST("mark"));
- GetMark()->dumpAsXml(pWriter);
- xmlTextWriterEndElement(pWriter);
+ SwPaM::dumpAsXml(pWriter);
const SwRedlineExtraData* pExtraRedlineData = GetExtraData();
xmlTextWriterStartElement(pWriter, BAD_CAST("swRedlineExtraData"));
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index a21f56efe93e..d32219987adc 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -299,16 +299,8 @@ void SwFrm::dumpAsXml( xmlTextWriterPtr writer ) const
const SwRootFrm* const pRootFrm = static_cast<const SwRootFrm* const>(this);
SwEditShell* pEditShell = pRootFrm->GetCurrShell()->GetDoc()->GetEditShell();
xmlTextWriterStartElement(writer, BAD_CAST("shellCrsr"));
- for(SwPaM& rPaM : pEditShell->getShellCrsr(false)->GetRingContainer())
- {
- xmlTextWriterStartElement(writer, BAD_CAST("swpam"));
- xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("pointNodeIndex"), "%ld", rPaM.GetPoint()->nNode.GetIndex());
- xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("pointContentIndex"), "%" SAL_PRIdINT32, rPaM.GetPoint()->nContent.GetIndex());
-
- xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("markNodeIndex"), "%ld", rPaM.GetMark()->nNode.GetIndex());
- xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("markContentIndex"), "%" SAL_PRIdINT32, rPaM.GetMark()->nContent.GetIndex());
- xmlTextWriterEndElement(writer);
- }
+ for (SwPaM& rPaM : pEditShell->getShellCrsr(false)->GetRingContainer())
+ rPaM.dumpAsXml(writer);
xmlTextWriterEndElement(writer);
}