Author: craig
Date: Fri Mar 18 22:07:29 2022
New Revision: 25040

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25040
Log:
Code cleanup

Modified:
    trunk/Scribus/scribus/desaxe/saxXML.cpp
    trunk/Scribus/scribus/desaxe/saxXML.h

Modified: trunk/Scribus/scribus/desaxe/saxXML.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=25040&path=/trunk/Scribus/scribus/desaxe/saxXML.cpp
==============================================================================
--- trunk/Scribus/scribus/desaxe/saxXML.cpp     (original)
+++ trunk/Scribus/scribus/desaxe/saxXML.cpp     Fri Mar 18 22:07:29 2022
@@ -13,11 +13,16 @@
 
 using namespace std;
 
-SaxXML::SaxXML(std::ostream& file, bool pretty) : m_stream(file), 
-     m_pretty(pretty), m_indentLevel(0), m_manyAttributes(false), 
m_pendingEmptyTag(false) {} 
+SaxXML::SaxXML(std::ostream& file, bool pretty) :
+       m_stream(file),
+       m_pretty(pretty)
+{}
 
-SaxXML::SaxXML(const char* filename, bool pretty) : m_file(filename, ios::out 
| ios::binary), m_stream(m_file), 
-     m_pretty(pretty), m_indentLevel(0), m_manyAttributes(false), 
m_pendingEmptyTag(false) {}
+SaxXML::SaxXML(const char* filename, bool pretty) :
+       m_file(filename, ios::out | ios::binary),
+       m_stream(m_file),
+       m_pretty(pretty)
+{}
 
 SaxXML::~SaxXML() { m_stream.flush(); m_file.close(); }
 
@@ -30,47 +35,49 @@
 void SaxXML::endDoc()
 {
        m_stream << "\n";
-       m_stream.flush(); m_file.close();
+       m_stream.flush();
+       m_file.close();
 }
 
 
 void SaxXML::finalizePendingEmptyTag()
 {
-       if (m_pendingEmptyTag) {
-               if (m_pretty && m_manyAttributes)
-               {
-                       m_stream << "\n";
-                       for (int k=0; k < m_indentLevel*4; ++k)
-                               m_stream << " ";
-                       m_stream << ">";
-               }
-               else
-                       m_stream << " >";
-               m_pendingEmptyTag = false;
+       if (!m_pendingEmptyTag)
+               return;
+       if (m_pretty && m_manyAttributes)
+       {
+               m_stream << "\n";
+               for (int i = 0; i < m_indentLevel * 4; ++i)
+                       m_stream << " ";
+               m_stream << ">";
        }
+       else
+               m_stream << " >";
+       m_pendingEmptyTag = false;
 }
 
 void SaxXML::begin(const Xml_string& tag, Xml_attr attr)
 {
        finalizePendingEmptyTag();
-       assert( !tag.isNull() );
+       assert(!tag.isNull());
        if (m_pretty)
        {
                // indent tag
                m_stream << "\n";
-               for (int k=0; k < m_indentLevel*4; ++k)
+               for (int i = 0; i  < m_indentLevel * 4; ++i)
                        m_stream << " ";
        }
        m_stream << "<" << fromXMLString(tag);
        Xml_attr::iterator it;
        m_manyAttributes = false;
        uint i = 0;
-       for (it=attr.begin(); it != attr.end(); ++it) {
+       for (it=attr.begin(); it != attr.end(); ++it)
+       {
                // newline and indent every 4 attributes
-               if (i > 0 && (i%4)==0 && m_pretty)
+               if (i > 0 && (i % 4) == 0 && m_pretty)
                {
                        m_stream << "\n";
-                       for (int k=0; k < m_indentLevel*4 + 1 + tag.length(); 
++k)
+                       for (int j = 0; j  < m_indentLevel * 4 + 1 + 
tag.length(); ++j)
                                m_stream << " ";
                        m_manyAttributes = true;
                }
@@ -95,21 +102,23 @@
 void SaxXML::end(const Xml_string& tag)
 {
        --m_indentLevel;
-       if (m_pendingEmptyTag) {
+       if (m_pendingEmptyTag)
+       {
                if (m_pretty && m_manyAttributes)
                {
                        m_stream << "\n";
-                       for (int k=0; k < m_indentLevel*4; ++k)
+                       for (int i = 0; i  < m_indentLevel * 4; ++i)
                                m_stream << " ";
                }
                m_stream << " />"; 
                m_pendingEmptyTag = false;
        }
-       else {
+       else
+       {
                if (m_pretty)
                {
                        m_stream << "\n";
-                       for (int k=0; k < m_indentLevel*4; ++k)
+                       for (int i = 0; i  < m_indentLevel * 4; ++i)
                                m_stream << " ";
                }
                m_stream << "</" << fromXMLString(tag) << ">";

Modified: trunk/Scribus/scribus/desaxe/saxXML.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=25040&path=/trunk/Scribus/scribus/desaxe/saxXML.h
==============================================================================
--- trunk/Scribus/scribus/desaxe/saxXML.h       (original)
+++ trunk/Scribus/scribus/desaxe/saxXML.h       Fri Mar 18 22:07:29 2022
@@ -7,8 +7,6 @@
  *
  */
 
-
-
 #ifndef SAXXML_H
 #define SAXXML_H
 
@@ -16,26 +14,27 @@
 #include "saxhandler.h"
 #include "scribusapi.h"
 
-class SCRIBUS_API SaxXML : public SaxHandler {
-public:
-       SaxXML(std::ostream& file, bool pretty=false);
-       SaxXML(const char* filename, bool pretty=false);
-       ~SaxXML();
+class SCRIBUS_API SaxXML : public SaxHandler
+{
+       public:
+               SaxXML(std::ostream& file, bool pretty=false);
+               SaxXML(const char* filename, bool pretty=false);
+               ~SaxXML();
 
-       void beginDoc();
-       void endDoc();
-       void begin(const Xml_string& tag, Xml_attr attr);
-       void end(const Xml_string& tag);
-       void chars(const Xml_string& text);
+               void beginDoc();
+               void endDoc();
+               void begin(const Xml_string& tag, Xml_attr attr);
+               void end(const Xml_string& tag);
+               void chars(const Xml_string& text);
 
-private:
-       std::ofstream m_file;
-       std::ostream& m_stream;
-       bool m_pretty;
-       int m_indentLevel;
-       bool m_manyAttributes;
-       bool m_pendingEmptyTag;
-       void finalizePendingEmptyTag();
+       private:
+               std::ofstream m_file;
+               std::ostream& m_stream;
+               bool m_pretty { false };
+               int m_indentLevel { 0 };
+               bool m_manyAttributes { false };
+               bool m_pendingEmptyTag { false };
+               void finalizePendingEmptyTag();
 };
 
 #endif


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to