summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-12-08 22:46:54 +0100
committerMichael Stahl <mstahl@redhat.com>2016-12-09 11:41:38 +0100
commitff3d175eef06d67133ba686ff8b2ea9261de2c2b (patch)
treeb2d6e97ba96adbf1b57986a0623bb673de7365f5 /xmloff
parenta547b2559c9dd25e03ab78a22eb9c06a38e9b574 (diff)
xmloff: XMLChangeImportContext: replace boolean pair with proper enum
Change-Id: I82ec75058a2309b8bcf0f8e78d8ef0db367014b0
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/text/XMLChangeImportContext.cxx25
-rw-r--r--xmloff/source/text/XMLChangeImportContext.hxx16
-rw-r--r--xmloff/source/text/txtimp.cxx7
-rw-r--r--xmloff/source/text/txtparai.cxx7
4 files changed, 28 insertions, 27 deletions
diff --git a/xmloff/source/text/XMLChangeImportContext.cxx b/xmloff/source/text/XMLChangeImportContext.cxx
index f8b863a952b2..54c8bea9db53 100644
--- a/xmloff/source/text/XMLChangeImportContext.cxx
+++ b/xmloff/source/text/XMLChangeImportContext.cxx
@@ -34,15 +34,12 @@ XMLChangeImportContext::XMLChangeImportContext(
SvXMLImport& rImport,
sal_Int16 nPrefix,
const OUString& rLocalName,
- bool bStart,
- bool bEnd,
- bool bOutsideOfParagraph) :
- SvXMLImportContext(rImport, nPrefix, rLocalName),
- bIsStart(bStart),
- bIsEnd(bEnd),
- bIsOutsideOfParagraph(bOutsideOfParagraph)
+ Element const eElement,
+ bool bOutsideOfParagraph)
+ : SvXMLImportContext(rImport, nPrefix, rLocalName)
+ , m_Element(eElement)
+ , m_bIsOutsideOfParagraph(bOutsideOfParagraph)
{
- DBG_ASSERT(bStart || bEnd, "Must be either start, end, or both!");
}
XMLChangeImportContext::~XMLChangeImportContext()
@@ -69,14 +66,14 @@ void XMLChangeImportContext::StartElement(
GetImport().GetTextImport();
OUString sID = xAttrList->getValueByIndex(nAttr);
- // call for bStart and bEnd (may both be true)
- if (bIsStart)
- rHelper->RedlineSetCursor(sID, true, bIsOutsideOfParagraph);
- if (bIsEnd)
- rHelper->RedlineSetCursor(sID, false, bIsOutsideOfParagraph);
+ // <text:change> is both start and end
+ if (Element::START == m_Element || Element::POINT == m_Element)
+ rHelper->RedlineSetCursor(sID, true, m_bIsOutsideOfParagraph);
+ if (Element::END == m_Element || Element::POINT == m_Element)
+ rHelper->RedlineSetCursor(sID, false, m_bIsOutsideOfParagraph);
// outside of paragraph and still open? set open redline ID
- if (bIsOutsideOfParagraph)
+ if (m_bIsOutsideOfParagraph)
{
rHelper->SetOpenRedlineId(sID);
}
diff --git a/xmloff/source/text/XMLChangeImportContext.hxx b/xmloff/source/text/XMLChangeImportContext.hxx
index fbab1b14aa20..a2e88e809ae7 100644
--- a/xmloff/source/text/XMLChangeImportContext.hxx
+++ b/xmloff/source/text/XMLChangeImportContext.hxx
@@ -38,26 +38,20 @@ namespace com { namespace sun { namespace star {
*/
class XMLChangeImportContext : public SvXMLImportContext
{
- bool bIsStart;
- bool bIsEnd;
- bool bIsOutsideOfParagraph;
-
public:
-
+ enum class Element { START, END, POINT };
/**
* import a change mark
* (<text:change>, <text:change-start>, <text:change-end>)
* Note: a <text:change> mark denotes start and end of a change
- * simultaniously, so both bIsStart and bIsEnd parameters would
- * be set true.
+ * simultaneously, as in Element::POINT.
*/
XMLChangeImportContext(
SvXMLImport& rImport,
sal_Int16 nPrefix,
const OUString& rLocalName,
- bool bIsStart, /// mark start of a change
- bool bIsEnd, /// mark end of a change
+ Element eElement,
/// true if change mark is encountered outside of a paragraph
/// (usually before a section or table)
bool bIsOutsideOfParagraph);
@@ -66,6 +60,10 @@ public:
virtual void StartElement(
const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;
+
+private:
+ Element m_Element;
+ bool m_bIsOutsideOfParagraph;
};
#endif
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index f4b66c854518..06da069564ea 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -2294,8 +2294,11 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext(
case XML_TOK_TEXT_CHANGE_END:
pContext = new XMLChangeImportContext(
rImport, nPrefix, rLocalName,
- (XML_TOK_TEXT_CHANGE_END != nToken),
- (XML_TOK_TEXT_CHANGE_START != nToken),
+ ((nToken == XML_TOK_TEXTP_CHANGE_END)
+ ? XMLChangeImportContext::Element::END
+ : (nToken == XML_TOK_TEXTP_CHANGE_START)
+ ? XMLChangeImportContext::Element::START
+ : XMLChangeImportContext::Element::POINT),
true);
break;
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 58c201e7ab70..d35a05224448 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -1683,8 +1683,11 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
case XML_TOK_TEXTP_CHANGE:
pContext = new XMLChangeImportContext(
rImport, nPrefix, rLocalName,
- (nToken != XML_TOK_TEXTP_CHANGE_END),
- (nToken != XML_TOK_TEXTP_CHANGE_START),
+ ((nToken == XML_TOK_TEXTP_CHANGE_END)
+ ? XMLChangeImportContext::Element::END
+ : (nToken == XML_TOK_TEXTP_CHANGE_START)
+ ? XMLChangeImportContext::Element::START
+ : XMLChangeImportContext::Element::POINT),
false);
break;