tdf#48459 sw inline heading: don't apply inside frames or over 120 chars
[LibreOffice.git] / sc / inc / documentimport.hxx
blob2ffc75d67b82c0e1571aff3cb2ce61964d1c0c1f
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 #pragma once
12 #include "scdllapi.h"
13 #include "address.hxx"
14 #include "attarray.hxx"
16 #include <rtl/ustring.hxx>
18 #include <memory>
19 #include <vector>
21 class EditTextObject;
22 class ScDocument;
23 class ScColumn;
24 class ScPatternAttr;
25 class ScTokenArray;
26 class ScFormulaCell;
27 class ScStyleSheet;
28 struct ScSetStringParam;
29 struct ScTabOpParam;
30 struct ScDocumentImportImpl;
31 enum class SvtScriptType : sal_uInt8;
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
56 bool operator==(const Attrs& other) const
58 return mvData == other.mvData && mbLatinNumFmtOnly == other.mbLatinNumFmtOnly;
60 Attrs& operator=( Attrs&& attrs ) = default;
63 ScDocumentImport() = delete;
64 ScDocumentImport(ScDocument& rDoc);
65 ScDocumentImport(const ScDocumentImport&) = delete;
66 const ScDocumentImport& operator=(const ScDocumentImport&) = delete;
67 ~ScDocumentImport();
69 ScDocument& getDoc();
70 const ScDocument& getDoc() const;
72 /**
73 * Initialize the storage for all sheets after all the sheet instances
74 * have been created in the document.
76 void initForSheets();
78 void setDefaultNumericScript(SvtScriptType nScript);
80 /**
81 * Apply specified cell style to an entire sheet.
83 void setCellStyleToSheet(SCTAB nTab, const ScStyleSheet& rStyle);
85 /**
86 * @param rName sheet name.
88 * @return 0-based sheet index, or -1 in case no sheet is found by
89 * specified name.
91 SCTAB getSheetIndex(const OUString& rName) const;
92 SCTAB getSheetCount() const;
93 bool appendSheet(const OUString& rName);
94 void setSheetName(SCTAB nTab, const OUString& rName);
96 void setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, sal_uInt16 nDay);
98 void setAutoInput(const ScAddress& rPos, const OUString& rStr,
99 const ScSetStringParam* pStringParam = nullptr);
100 void setNumericCell(const ScAddress& rPos, double fVal);
101 void setStringCell(const ScAddress& rPos, const OUString& rStr);
102 void setEditCell(const ScAddress& rPos, std::unique_ptr<EditTextObject> pEditText);
104 void setFormulaCell(
105 const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar,
106 const double* pResult = nullptr );
108 void setFormulaCell(
109 const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar,
110 const OUString& rResult );
112 void setFormulaCell(const ScAddress& rPos, std::unique_ptr<ScTokenArray> pArray);
113 void setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCell);
115 void setMatrixCells(
116 const ScRange& rRange, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGrammar);
118 void setTableOpCells(const ScRange& rRange, const ScTabOpParam& rParam);
120 void fillDownCells(const ScAddress& rPos, SCROW nFillSize);
123 * Set an array of cell attributes to specified range of columns. This call
124 * transfers the ownership of the ScAttrEntry array from the caller to the
125 * column.
127 void setAttrEntries( SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, Attrs&& rAttrs );
129 void setRowsVisible(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, bool bVisible);
131 void setMergedCells(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
133 void invalidateBlockPositionSet(SCTAB nTab);
135 void finalize();
137 /** Broadcast all formula cells that are marked with
138 FormulaTokenArray::IsRecalcModeMustAfterImport() for a subsequent
139 ScDocument::CalcFormulaTree().
141 void broadcastRecalcAfterImport();
143 /** small cache for hot call during import */
144 bool isLatinScript(sal_uInt32 nFormat);
145 bool isLatinScript(const ScPatternAttr&);
147 private:
148 void initColumn(ScColumn& rCol);
149 static void broadcastRecalcAfterImportColumn(ScColumn& rCol);
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */