1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "XMLDetectiveContext.hxx"
22 #include "importcontext.hxx"
23 #include <formula/grammar.hxx>
24 #include <svl/itemset.hxx>
25 #include <editeng/editdata.hxx>
33 class ScEditEngineDefaulter
;
35 struct ScXMLAnnotationData
;
36 struct ScMyImpCellRangeSource
;
38 class ScXMLTableRowCellContext
: public ScXMLImportContext
43 ESelection maSelection
;
45 explicit ParaFormat(const ScEditEngineDefaulter
& rEditEngine
);
50 std::unique_ptr
<SvxFieldData
> mpData
;
51 ESelection maSelection
;
53 Field(const Field
&) = delete;
54 const Field
& operator=(const Field
&) = delete;
56 explicit Field(std::unique_ptr
<SvxFieldData
> pData
);
60 typedef std::vector
<std::unique_ptr
<Field
> > FieldsType
;
61 typedef std::pair
<OUString
, OUString
> FormulaWithNamespace
;
63 std::optional
<FormulaWithNamespace
> maFormula
; /// table:formula attribute
64 std::optional
<OUString
> maStringValue
; /// office:string-value attribute
65 std::optional
<OUString
> maContentValidationName
;
66 std::optional
<OUString
> maFirstParagraph
; /// unformatted first paragraph, for better performance.
68 ScEditEngineDefaulter
* mpEditEngine
;
69 OUStringBuffer maParagraph
{32};
70 sal_Int32 mnCurParagraph
;
72 std::vector
<std::unique_ptr
<ParaFormat
> > maFormats
;
75 std::unique_ptr
< ScXMLAnnotationData
> mxAnnotationData
;
76 std::unique_ptr
< ScMyImpDetectiveObjVec
> pDetectiveObjVec
;
77 std::unique_ptr
< ScMyImpCellRangeSource
> pCellRangeSource
;
79 SCROW nMergedRows
, nMatrixRows
, nRepeatedRows
;
80 SCCOL nMergedCols
, nMatrixCols
, nColsRepeated
;
81 ScXMLImport
& rXMLImport
;
82 formula::FormulaGrammar::Grammar eGrammar
;
90 bool bSolarMutexLocked
;
91 bool bFormulaTextResult
;
92 bool mbPossibleErrorCell
;
93 bool mbCheckWithCompilerForError
;
94 bool mbEditEngineHasText
;
97 bool mbPossibleEmptyDisplay
;
99 void DoMerge(const ScAddress
& rScCellPos
, const SCCOL nCols
, const SCROW nRows
);
101 void SetContentValidation( const ScRange
& rScRange
);
102 void SetContentValidation( const ScAddress
& rScCellPos
);
104 void LockSolarMutex();
106 bool CellsAreRepeated() const;
108 void SetFormulaCell ( ScFormulaCell
* pFCell
) const;
109 void PutTextCell ( const ScAddress
& rScCurrentPos
, const SCCOL nCurrentCol
,
110 const ::std::optional
< OUString
>& pOUText
);
111 void PutValueCell ( const ScAddress
& rScCurrentPos
);
112 void AddTextAndValueCell ( const ScAddress
& rScCellPos
,
113 const ::std::optional
< OUString
>& pOUText
, ScAddress
& rScCurrentPos
);
114 void AddNonFormulaCell ( const ScAddress
& rScCellPos
);
115 void PutFormulaCell ( const ScAddress
& rScCurrentPos
);
116 void AddFormulaCell ( const ScAddress
& rScCellPos
);
118 void HasSpecialCaseFormulaText();
120 bool IsPossibleErrorString() const;
122 void PushParagraphField(std::unique_ptr
<SvxFieldData
> pData
, const OUString
& rStyleName
);
124 void PushFormat(sal_Int32 nBegin
, sal_Int32 nEnd
, const OUString
& rStyleName
);
126 OUString
GetFirstParagraph() const;
130 ScXMLTableRowCellContext( ScXMLImport
& rImport
,
131 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
132 const bool bIsCovered
, const sal_Int32 nRepeatedRows
);
134 virtual ~ScXMLTableRowCellContext() override
;
136 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
137 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
139 void PushParagraphSpan(std::u16string_view rSpan
, const OUString
& rStyleName
);
140 void PushParagraphFieldDate(const OUString
& rStyleName
);
141 void PushParagraphFieldSheetName(const OUString
& rStyleName
);
142 void PushParagraphFieldDocTitle(const OUString
& rStyleName
);
143 void PushParagraphFieldURL(const OUString
& rURL
, const OUString
& rRep
, const OUString
& rStyleName
, const OUString
& rTargetFrame
);
144 void PushParagraphEnd();
146 void SetAnnotation( const ScAddress
& rPosition
);
147 void SetDetectiveObj( const ScAddress
& rPosition
);
148 void SetCellRangeSource( const ScAddress
& rPosition
);
150 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */