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 SC_XMLCELLI_HXX
20 : #define SC_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 16 : 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 :
67 : ScEditEngineDefaulter* mpEditEngine;
68 : OUStringBuffer maParagraph;
69 : sal_Int32 mnCurParagraph;
70 :
71 : ParaFormatsType maFormats;
72 : FieldsType maFields;
73 :
74 : boost::scoped_ptr< ScXMLAnnotationData > mxAnnotationData;
75 : ScMyImpDetectiveObjVec* pDetectiveObjVec;
76 : ScMyImpCellRangeSource* pCellRangeSource;
77 : double fValue;
78 : SCROW nMergedRows, nMatrixRows, nRepeatedRows;
79 : SCCOL nMergedCols, nMatrixCols, nColsRepeated;
80 : ScXMLImport& rXMLImport;
81 : formula::FormulaGrammar::Grammar eGrammar;
82 : sal_Int16 nCellType;
83 : bool bIsMerged;
84 : bool bIsMatrix;
85 : bool bIsCovered;
86 : bool bIsEmpty;
87 : bool mbNewValueType;
88 : bool mbErrorValue;
89 : bool bIsFirstTextImport;
90 : bool bSolarMutexLocked;
91 : bool bFormulaTextResult;
92 : bool mbPossibleErrorCell;
93 : bool mbCheckWithCompilerForError;
94 : bool mbEditEngineHasText;
95 :
96 : sal_Int16 GetCellType(const OUString& sOUValue) const;
97 :
98 : void DoMerge(const ScAddress& rScCellPos, const SCCOL nCols, const SCROW nRows);
99 :
100 : void SetContentValidation( const ScRange& rScRange );
101 : void SetContentValidation( const ScAddress& rScCellPos );
102 :
103 : void LockSolarMutex();
104 : void UnlockSolarMutex();
105 :
106 : bool HasSpecialContent() const;
107 : bool CellsAreRepeated() const;
108 :
109 : void SetFormulaCell ( ScFormulaCell* pFCell ) const;
110 : void PutTextCell ( const ScAddress& rScCurrentPos, const SCCOL nCurrentCol,
111 : const ::boost::optional< OUString >& pOUText );
112 : void PutValueCell ( const ScAddress& rScCurrentPos );
113 : void AddTextAndValueCell ( const ScAddress& rScCellPos,
114 : const ::boost::optional< OUString >& pOUText, ScAddress& rScCurrentPos );
115 : void AddNonFormulaCell ( const ScAddress& rScCellPos );
116 : void PutFormulaCell ( const ScAddress& rScCurrentPos );
117 : void AddFormulaCell ( const ScAddress& rScCellPos );
118 :
119 : void HasSpecialCaseFormulaText();
120 :
121 : bool IsPossibleErrorString() const;
122 :
123 : void PushParagraphField(SvxFieldData* pData, const OUString& rStyleName);
124 :
125 : void PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, const OUString& rStyleName);
126 :
127 : public:
128 :
129 : ScXMLTableRowCellContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
130 : const OUString& rLName,
131 : const ::com::sun::star::uno::Reference<
132 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
133 : const bool bIsCovered, const sal_Int32 nRepeatedRows );
134 :
135 : virtual ~ScXMLTableRowCellContext();
136 :
137 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
138 : const OUString& rLocalName,
139 : const ::com::sun::star::uno::Reference<
140 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
141 :
142 : void PushParagraphSpan(const OUString& rSpan, const OUString& rStyleName);
143 : void PushParagraphFieldDate(const OUString& rStyleName);
144 : void PushParagraphFieldSheetName(const OUString& rStyleName);
145 : void PushParagraphFieldDocTitle(const OUString& rStyleName);
146 : void PushParagraphFieldURL(const OUString& rURL, const OUString& rRep, const OUString& rStyleName);
147 : void PushParagraphEnd();
148 :
149 : void SetAnnotation( const ScAddress& rPosition );
150 : void SetDetectiveObj( const ScAddress& rPosition );
151 : void SetCellRangeSource( const ScAddress& rPosition );
152 :
153 : virtual void EndElement();
154 : };
155 :
156 : #endif
157 :
158 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|