src/OdsHandler.h
author František Kučera <franta-hg@frantovo.cz>
Fri, 07 Dec 2018 14:46:40 +0100
branchv_0
changeset 2 3e73d4ae8b49
parent 0 2f3c9e508827
child 8 0ba80e9b711f
permissions -rw-r--r--
first working version
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info)
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, either version 3 of the License, or
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 * (at your option) any later version.
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 *
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 * GNU General Public License for more details.
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 *
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
 */
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
#pragma once
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <string>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
#include <vector>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
#include <iostream>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
#include <sstream>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
#include <locale>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
#include <codecvt>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
#include <regex>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
#include <relpipe/reader/typedefs.h>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
#include <relpipe/reader/TypeId.h>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
#include <relpipe/reader/handlers/RelationalReaderStringHandler.h>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
#include <relpipe/reader/handlers/AttributeMetadata.h>
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
namespace relpipe {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
namespace out {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
namespace ods {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
using namespace relpipe::reader;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
class OdsHandler : public handlers::RelationalReaderStringHadler {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
private:
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
	std::wstring_convert<std::codecvt_utf8<wchar_t>> convertor; // XML output will be always in UTF-8
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    42
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    43
	// TODO: refactor and move common XML functions to relpipe-lib-xml
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    44
	const char* INDENT_1 = "\t";
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    45
	const char* INDENT_2 = "\t\t";
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    46
	const char* INDENT_3 = "\t\t\t";
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    47
	const char* INDENT_4 = "\t\t\t\t";
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    48
	const char* INDENT_5 = "\t\t\t\t\t";
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    49
	const char* INDENT_6 = "\t\t\t\t\t\t";
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
	std::ostream &output;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
	std::vector<TypeId> columnTypes;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
	std::vector<string_t> columnTypeCodes;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
	std::vector<string_t> columnNames;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
	integer_t valueCount = 0;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
	integer_t columnCount = 0;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
	integer_t relationCount = 0;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    60
	// TODO: refactor and move common XML functions to relpipe-lib-xml
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    61
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    62
	const std::string escapeXmlText(const string_t &value) {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    63
		std::wstringstream result;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    64
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    65
		for (auto & ch : value) {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    66
			switch (ch) {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    67
				case L'&': result << L"&amp;";
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    68
					break;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    69
				case L'<': result << L"&lt;";
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    70
					break;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    71
				case L'>': result << L"&gt;";
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    72
					break;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    73
				case L'\'': result << L"&apos;"; // TODO: escape ' and " only in attributes
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    74
					break;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    75
				case L'"': result << L"&quot;"; // TODO: escape ' and " only in attributes
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    76
					break;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    77
				default: result << ch;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    78
			}
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    79
		}
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    80
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    81
		return convertor.to_bytes(result.str());
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    82
	}
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    83
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    84
public:
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    85
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    86
	OdsHandler(std::ostream& output) : output(output) {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    87
	}
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    88
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    89
	void startRelation(string_t name, std::vector<handlers::AttributeMetadata> attributes) override {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    90
		// TODO: refactor and move common XML functions to relpipe-lib-xml
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    91
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    92
		valueCount = 0;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    93
		columnCount = 0;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    94
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    95
		if (relationCount == 0) {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    96
			output << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    97
			output << "<office:document" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    98
			output << INDENT_1 << "xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    99
			output << INDENT_1 << "xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\"" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   100
			output << INDENT_1 << "xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\"" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   101
			output << INDENT_1 << "office:mimetype=\"application/vnd.oasis.opendocument.spreadsheet\"" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   102
			output << INDENT_1 << "office:version=\"1.2\">" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   103
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   104
			output << INDENT_1 << "<office:body>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   105
			output << INDENT_2 << "<office:spreadsheet>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   106
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   107
		} else {
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   108
			output << INDENT_4 << "</table:table-row>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   109
			output << INDENT_3 << "</table:table>" << std::endl;
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   110
		}
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   111
		relationCount++;
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   112
		// TODO: rename relations with same names
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   113
		output << INDENT_3 << "<table:table table:name=\"" << escapeXmlText(name) << "\">" << std::endl;
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   114
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   115
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   116
		columnCount = attributes.size();
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   117
		columnTypes.resize(columnCount);
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   118
		columnTypeCodes.resize(columnCount);
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   119
		columnNames.resize(columnCount);
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   120
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   121
		output << INDENT_4 << "<table:table-row>" << std::endl;
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   122
		for (int i = 0; i < attributes.size(); i++) {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   123
			columnNames[i] = attributes[i].getAttributeName();
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   124
			columnTypes[i] = attributes[i].getTypeId();
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   125
			columnTypeCodes[i] = attributes[i].getTypeName();
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   126
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   127
			output << INDENT_5 << "<table:table-cell>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   128
			output << INDENT_6 << "<text:p>";
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   129
			output << escapeXmlText(columnNames[i]);
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   130
			output << "</text:p>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   131
			output << INDENT_5 << "</table:table-cell>" << std::endl;
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   132
		}
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   133
		output << INDENT_4 << "</table:table-row>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   134
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   135
	}
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   136
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   137
	void attribute(const string_t& value) override {
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   138
		integer_t i = valueCount % columnCount;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   139
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   140
		if (i == 0 && valueCount) output << INDENT_4 << "</table:table-row>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   141
		if (i == 0) output << INDENT_4 << "<table:table-row>" << std::endl;
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   142
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   143
		valueCount++;
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   144
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   145
		output << INDENT_5 << "<table:table-cell>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   146
		output << INDENT_6 << "<text:p>";
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   147
		output << escapeXmlText(value);
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   148
		output << "</text:p>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   149
		output << INDENT_5 << "</table:table-cell>" << std::endl;
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   150
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   151
	}
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   152
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   153
	void endOfPipe() {
2
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   154
		if (valueCount) output << INDENT_4 << "</table:table-row>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   155
		if (relationCount) output << INDENT_3 << "</table:table>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   156
		output << INDENT_2 << "</office:spreadsheet>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   157
		output << INDENT_1 << "</office:body>" << std::endl;
3e73d4ae8b49 first working version
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   158
		output << "</office:document>" << std::endl;
0
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   159
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   160
	}
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   161
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   162
};
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   163
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   164
}
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   165
}
2f3c9e508827 project skeleton: cmake, netbeans, code from relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   166
}