summaryrefslogtreecommitdiff
path: root/sc/inc/documentimport.hxx
blob: e90be0b331e66cffd512e3a22469f1b83c07f3d1 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * 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_SC_INC_DOCUMENTIMPORT_HXX
#define INCLUDED_SC_INC_DOCUMENTIMPORT_HXX

#include "scdllapi.h"
#include "address.hxx"

#include <rtl/ustring.hxx>

#include <boost/noncopyable.hpp>
#include <memory>

class EditTextObject;
class ScDocument;
class ScColumn;
class ScAddress;
struct ScAttrEntry;
class ScTokenArray;
class ScFormulaCell;
class ScStyleSheet;
struct ScSetStringParam;
struct ScTabOpParam;
struct ScDocumentImportImpl;
enum class SvtScriptType;

/**
 * Accessor class to ScDocument.  Its purpose is to allow import filter to
 * fill the document model and nothing but that.  Filling the document via
 * this class does not trigger any kind of broadcasting, drawing object
 * position calculation, or anything else that requires expensive
 * computation which are unnecessary and undesirable during import.
 */
class SC_DLLPUBLIC ScDocumentImport : private boost::noncopyable
{
    std::unique_ptr<ScDocumentImportImpl> mpImpl;

    ScDocumentImport(); // disabled
    ScDocumentImport& operator=(const ScDocumentImport&); //disabled

public:

    struct SC_DLLPUBLIC Attrs
    {
        ScAttrEntry* mpData;
        size_t mnSize;

        bool mbLatinNumFmtOnly;

        Attrs();
    };

    ScDocumentImport(ScDocument& rDoc);
    ~ScDocumentImport();

    ScDocument& getDoc();
    const ScDocument& getDoc() const;

    void setDefaultNumericScript(SvtScriptType nScript);

    /**
     * Apply specified cell style to an entire sheet.
     */
    void setCellStyleToSheet(SCTAB nTab, const ScStyleSheet& rStyle);

    /**
     * @param rName sheet name.
     *
     * @return 0-based sheet index, or -1 in case no sheet is found by
     *         specified name.
     */
    SCTAB getSheetIndex(const OUString& rName) const;
    SCTAB getSheetCount() const;
    bool appendSheet(const OUString& rName);

    void setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, sal_uInt16 nDay);

    void setAutoInput(const ScAddress& rPos, const OUString& rStr,
            ScSetStringParam* pStringParam = nullptr);
    void setNumericCell(const ScAddress& rPos, double fVal);
    void setStringCell(const ScAddress& rPos, const OUString& rStr);
    void setEditCell(const ScAddress& rPos, EditTextObject* pEditText);
    void setFormulaCell(const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar);
    void setFormulaCell(const ScAddress& rPos, ScTokenArray* pArray);
    void setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCell);

    void setMatrixCells(
        const ScRange& rRange, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGrammar);

    void setTableOpCells(const ScRange& rRange, const ScTabOpParam& rParam);

    /**
     * Set an array of cell attributes to specified column.  This call
     * transfers the ownership of the ScAttrEntry array from the caller to the
     * column.
     */
    void setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs );

    void setRowsVisible(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, bool bVisible);

    void finalize();

private:
    void initColumn(ScColumn& rCol);
};

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */