+
+QString ExportASCII::ensureEmptyLines(QString &text, int n)
+{
+ // Ensure at least n empty lines at the end of text
+
+ // First count trailing line breaks
+ int j = 0;
+ int i = text.count() - 1;
+ while (i > -1 && text.at(i) == "\n") {
+ i--;
+ j++;
+ }
+
+ while (j < n + 1) {
+ text = text + "\n";
+ j++;
+ }
+
+ return text;
+}
+
+QString ExportASCII::ensureNewLine(QString &text)
+{
+ // Add one line break, if not already there yet e.g. from empty line
+ if (!text.endsWith("\n"))
+ text += "\n";
+ return text;
+}