blob: b52c9b85bbe84ce8d33ca3640e182689e0a24826 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_ORCUS_PYTHON_DOCUMENT_HPP
#define INCLUDED_ORCUS_PYTHON_DOCUMENT_HPP
#include "orcus/spreadsheet/document.hpp"
#include "memory.hpp"
namespace orcus { namespace python {
/** non-python part of the document object. */
struct document_data
{
std::unique_ptr<spreadsheet::document> m_doc;
~document_data();
};
document_data* get_document_data(PyObject* self);
struct stream_with_formulas
{
py_unique_ptr stream;
bool recalc_formula_cells = false;
spreadsheet::formula_error_policy_t error_policy = spreadsheet::formula_error_policy_t::fail;
};
/**
* Extract a python object representing the byte stream from the arguments
* passed to the python orcus.<file format>.read() function, as well as
* several parameters related to formula calculation settings.
*
* This function handles the following python arguments: stream, recalc, and
* error_policy.
*
* @param args positional argument object.
* @param kwargs keyword argument object.
*
* @return object representing the bytes as well as formula calculation
* settings.
*/
stream_with_formulas read_stream_and_formula_params_from_args(PyObject* args, PyObject* kwargs);
/**
* This one is similar to the function above, except that it only handles
* one argument called 'stream'.
*
* @return object representing the bytes.
*/
py_unique_ptr read_stream_from_args(PyObject* args, PyObject* kwargs);
/**
* Import a document from a python object containing the byte stream, and
* create a python object of class orcus.Document.
*
* @param obj_bytes python object containing the byte stream.
* @param app filter instance to use to load the document.
* @param doc orcus document instance which will be stored within the python
* document object.
*
* @return python document object.
*/
PyObject* import_from_stream_into_document(
PyObject* obj_bytes, iface::import_filter& app, std::unique_ptr<spreadsheet::document>&& doc);
PyObject* create_document(std::unique_ptr<spreadsheet::document>&& doc);
/**
* Get the definition of the python class Document.
*/
PyTypeObject* get_document_type();
}}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|