Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / documentimport.hxx
blob1a8b1cbd514f412699981e56e7ed742060afd452
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_SC_INC_DOCUMENTIMPORT_HXX
11 #define INCLUDED_SC_INC_DOCUMENTIMPORT_HXX
13 #include "scdllapi.h"
14 #include "address.hxx"
16 #include <rtl/ustring.hxx>
18 #include <memory>
19 #include <vector>
21 class EditTextObject;
22 class ScDocument;
23 class ScColumn;
24 struct ScAttrEntry;
25 class ScTokenArray;
26 class ScFormulaCell;
27 class ScStyleSheet;
28 struct ScSetStringParam;
29 struct ScTabOpParam;
30 struct ScDocumentImportImpl;
31 enum class SvtScriptType;
33 /**
34 * Accessor class to ScDocument. Its purpose is to allow import filter to
35 * fill the document model and nothing but that. Filling the document via
36 * this class does not trigger any kind of broadcasting, drawing object
37 * position calculation, or anything else that requires expensive
38 * computation which are unnecessary and undesirable during import.
40 class SC_DLLPUBLIC ScDocumentImport
42 std::unique_ptr<ScDocumentImportImpl> mpImpl;
44 public:
46 struct SC_DLLPUBLIC Attrs
48 std::vector<ScAttrEntry> mvData;
50 bool mbLatinNumFmtOnly;
52 Attrs();
53 ~Attrs();
54 Attrs& operator=( Attrs const & ) = delete; // MSVC2015 workaround
55 Attrs( Attrs const & ) = delete; // MSVC2015 workaround
58 ScDocumentImport() = delete;
59 ScDocumentImport(ScDocument& rDoc);
60 ScDocumentImport(const ScDocumentImport&) = delete;
61 const ScDocumentImport& operator=(const ScDocumentImport&) = delete;
62 ~ScDocumentImport();
64 ScDocument& getDoc();
65 const ScDocument& getDoc() const;
67 /**
68 * Initialize the storage for all sheets after all the sheet instances
69 * have been created in the document.
71 void initForSheets();
73 void setDefaultNumericScript(SvtScriptType nScript);
75 /**
76 * Apply specified cell style to an entire sheet.
78 void setCellStyleToSheet(SCTAB nTab, const ScStyleSheet& rStyle);
80 /**
81 * @param rName sheet name.
83 * @return 0-based sheet index, or -1 in case no sheet is found by
84 * specified name.
86 SCTAB getSheetIndex(const OUString& rName) const;
87 SCTAB getSheetCount() const;
88 bool appendSheet(const OUString& rName);
89 void setSheetName(SCTAB nTab, const OUString& rName);
91 void setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, sal_uInt16 nDay);
93 void setAutoInput(const ScAddress& rPos, const OUString& rStr,
94 const ScSetStringParam* pStringParam = nullptr);
95 void setNumericCell(const ScAddress& rPos, double fVal);
96 void setStringCell(const ScAddress& rPos, const OUString& rStr);
97 void setEditCell(const ScAddress& rPos, std::unique_ptr<EditTextObject> pEditText);
99 void setFormulaCell(
100 const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar,
101 const double* pResult = nullptr );
103 void setFormulaCell(
104 const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar,
105 const OUString& rResult );
107 void setFormulaCell(const ScAddress& rPos, ScTokenArray* pArray);
108 void setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCell);
110 void setMatrixCells(
111 const ScRange& rRange, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGrammar);
113 void setTableOpCells(const ScRange& rRange, const ScTabOpParam& rParam);
116 * Set an array of cell attributes to specified column. This call
117 * transfers the ownership of the ScAttrEntry array from the caller to the
118 * column.
120 void setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs&& rAttrs );
122 void setRowsVisible(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, bool bVisible);
124 void setMergedCells(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
126 void finalize();
128 /** Broadcast all formula cells that are marked with
129 FormulaTokenArray::IsRecalcModeMustAfterImport() for a subsequent
130 ScDocument::CalcFormulaTree().
132 void broadcastRecalcAfterImport();
134 private:
135 void initColumn(ScColumn& rCol);
136 void broadcastRecalcAfterImportColumn(ScColumn& rCol);
139 #endif
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */