Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SC_SOURCE_FILTER_XML_XMLCELLI_HXX
20 : #define INCLUDED_SC_SOURCE_FILTER_XML_XMLCELLI_HXX
21 :
22 : #include "XMLDetectiveContext.hxx"
23 : #include "XMLCellRangeSourceContext.hxx"
24 : #include "importcontext.hxx"
25 : #include <formula/grammar.hxx>
26 : #include <svl/itemset.hxx>
27 : #include <editeng/editdata.hxx>
28 : #include <editeng/flditem.hxx>
29 :
30 : #include <boost/optional.hpp>
31 : #include <boost/scoped_ptr.hpp>
32 : #include <boost/ptr_container/ptr_vector.hpp>
33 : #include <boost/noncopyable.hpp>
34 :
35 : class ScXMLImport;
36 : class ScFormulaCell;
37 : class ScEditEngineDefaulter;
38 : struct ScXMLAnnotationData;
39 :
40 : class ScXMLTableRowCellContext : public ScXMLImportContext
41 : {
42 392 : struct ParaFormat
43 : {
44 : SfxItemSet maItemSet;
45 : ESelection maSelection;
46 :
47 : ParaFormat(ScEditEngineDefaulter& rEditEngine);
48 : };
49 :
50 : struct Field : boost::noncopyable
51 : {
52 : SvxFieldData* mpData;
53 : ESelection maSelection;
54 :
55 : Field(SvxFieldData* pData);
56 : ~Field();
57 : };
58 :
59 : typedef boost::ptr_vector<ParaFormat> ParaFormatsType;
60 : typedef boost::ptr_vector<Field> FieldsType;
61 : typedef std::pair<OUString, OUString> FormulaWithNamespace;
62 :
63 : boost::optional<FormulaWithNamespace> maFormula; /// table:formula attribute
64 : boost::optional<OUString> maStringValue; /// office:string-value attribute
65 : boost::optional<OUString> maContentValidationName;
66 : boost::optional<OUString> maFirstParagraph; /// unformatted first paragraph, for better performance.
67 :
68 : ScEditEngineDefaulter* mpEditEngine;
69 : OUStringBuffer maParagraph;
70 : sal_Int32 mnCurParagraph;
71 :
72 : ParaFormatsType maFormats;
73 : FieldsType maFields;
74 :
75 : boost::scoped_ptr< ScXMLAnnotationData > mxAnnotationData;
76 : ScMyImpDetectiveObjVec* pDetectiveObjVec;
77 : ScMyImpCellRangeSource* pCellRangeSource;
78 : double fValue;
79 : SCROW nMergedRows, nMatrixRows, nRepeatedRows;
80 : SCCOL nMergedCols, nMatrixCols, nColsRepeated;
81 : ScXMLImport& rXMLImport;
82 : formula::FormulaGrammar::Grammar eGrammar;
83 : sal_Int16 nCellType;
84 : bool bIsMerged;
85 : bool bIsMatrix;
86 : bool bIsCovered;
87 : bool bIsEmpty;
88 : bool mbNewValueType;
89 : bool mbErrorValue;
90 : bool bIsFirstTextImport;
91 : bool bSolarMutexLocked;
92 : bool bFormulaTextResult;
93 : bool mbPossibleErrorCell;
94 : bool mbCheckWithCompilerForError;
95 : bool mbEditEngineHasText;
96 : bool mbHasFormatRuns;
97 : bool mbHasStyle;
98 :
99 : sal_Int16 GetCellType(const OUString& sOUValue) const;
100 :
101 : void DoMerge(const ScAddress& rScCellPos, const SCCOL nCols, const SCROW nRows);
102 :
103 : void SetContentValidation( const ScRange& rScRange );
104 : void SetContentValidation( const ScAddress& rScCellPos );
105 :
106 : void LockSolarMutex();
107 : void UnlockSolarMutex();
108 :
109 : bool HasSpecialContent() const;
110 : bool CellsAreRepeated() const;
111 :
112 : void SetFormulaCell ( ScFormulaCell* pFCell ) const;
113 : void PutTextCell ( const ScAddress& rScCurrentPos, const SCCOL nCurrentCol,
114 : const ::boost::optional< OUString >& pOUText );
115 : void PutValueCell ( const ScAddress& rScCurrentPos );
116 : void AddTextAndValueCell ( const ScAddress& rScCellPos,
117 : const ::boost::optional< OUString >& pOUText, ScAddress& rScCurrentPos );
118 : void AddNonFormulaCell ( const ScAddress& rScCellPos );
119 : void PutFormulaCell ( const ScAddress& rScCurrentPos );
120 : void AddFormulaCell ( const ScAddress& rScCellPos );
121 :
122 : void HasSpecialCaseFormulaText();
123 :
124 : bool IsPossibleErrorString() const;
125 :
126 : void PushParagraphField(SvxFieldData* pData, const OUString& rStyleName);
127 :
128 : void PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, const OUString& rStyleName);
129 :
130 : OUString GetFirstParagraph() const;
131 :
132 : public:
133 :
134 : ScXMLTableRowCellContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
135 : const OUString& rLName,
136 : const ::com::sun::star::uno::Reference<
137 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
138 : const bool bIsCovered, const sal_Int32 nRepeatedRows );
139 :
140 : virtual ~ScXMLTableRowCellContext();
141 :
142 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
143 : const OUString& rLocalName,
144 : const ::com::sun::star::uno::Reference<
145 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
146 :
147 : void PushParagraphSpan(const OUString& rSpan, const OUString& rStyleName);
148 : void PushParagraphFieldDate(const OUString& rStyleName);
149 : void PushParagraphFieldSheetName(const OUString& rStyleName);
150 : void PushParagraphFieldDocTitle(const OUString& rStyleName);
151 : void PushParagraphFieldURL(const OUString& rURL, const OUString& rRep, const OUString& rStyleName);
152 : void PushParagraphEnd();
153 :
154 : void SetAnnotation( const ScAddress& rPosition );
155 : void SetDetectiveObj( const ScAddress& rPosition );
156 : void SetCellRangeSource( const ScAddress& rPosition );
157 :
158 : virtual void EndElement() SAL_OVERRIDE;
159 : };
160 :
161 : #endif
162 :
163 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|