xref: /aoo4110/main/sc/source/filter/xml/xmlcelli.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef SC_XMLCELLI_HXX
24 #define SC_XMLCELLI_HXX
25 
26 #include <memory>
27 #include "XMLDetectiveContext.hxx"
28 #include "XMLCellRangeSourceContext.hxx"
29 #include <xmloff/xmlictxt.hxx>
30 #include <xmloff/xmlimp.hxx>
31 #include <com/sun/star/table/XCell.hpp>
32 #include <tools/time.hxx>
33 #include <com/sun/star/util/DateTime.hpp>
34 #include <com/sun/star/table/XCellRange.hpp>
35 #include <com/sun/star/table/CellRangeAddress.hpp>
36 #include <com/sun/star/table/CellAddress.hpp>
37 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
38 #include <com/sun/star/document/XActionLockable.hpp>
39 
40 #include "formula/grammar.hxx"
41 #include <boost/optional.hpp>
42 
43 class ScXMLImport;
44 struct ScXMLAnnotationData;
45 
46 class ScXMLTableRowCellContext : public SvXMLImportContext
47 {
48     typedef ::std::pair< ::rtl::OUString, ::rtl::OUString > FormulaWithNamespace;
49 	com::sun::star::uno::Reference<com::sun::star::table::XCell> xBaseCell;
50 	com::sun::star::uno::Reference<com::sun::star::document::XActionLockable> xLockable;
51 	::boost::optional< rtl::OUString > pOUTextValue;
52 	::boost::optional< rtl::OUString > pOUTextContent;
53     ::boost::optional< FormulaWithNamespace > pOUFormula;
54 	rtl::OUString* pContentValidationName;
55     ::std::auto_ptr< ScXMLAnnotationData > mxAnnotationData;
56 	ScMyImpDetectiveObjVec*	pDetectiveObjVec;
57 	ScMyImpCellRangeSource*	pCellRangeSource;
58 	double		fValue;
59 	sal_Int32	nMergedRows, nMergedCols;
60 	sal_Int32	nMatrixRows, nMatrixCols;
61 	sal_Int32	nRepeatedRows;
62 	sal_Int32	nCellsRepeated;
63 	ScXMLImport& rXMLImport;
64     formula::FormulaGrammar::Grammar  eGrammar;
65 	sal_Int16	nCellType;
66 	sal_Bool	bIsMerged;
67 	sal_Bool	bIsMatrix;
68 	sal_Bool	bHasSubTable;
69 	sal_Bool	bIsCovered;
70 	sal_Bool	bIsEmpty;
71 	sal_Bool	bHasTextImport;
72 	sal_Bool	bIsFirstTextImport;
73 	sal_Bool	bSolarMutexLocked;
74 	sal_Bool	bFormulaTextResult;
75 
GetScImport() const76 	const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()77 	ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
78 
79 	sal_Int16 GetCellType(const rtl::OUString& sOUValue) const;
80 
81 	sal_Bool IsMerged (const com::sun::star::uno::Reference <com::sun::star::table::XCellRange>& xCellRange,
82 				const sal_Int32 nCol, const sal_Int32 nRow,
83 				com::sun::star::table::CellRangeAddress& aCellAddress) const;
84 	void DoMerge(const com::sun::star::table::CellAddress& aCellPos,
85 	 			const sal_Int32 nCols, const sal_Int32 nRows);
86 
87 	void SetContentValidation(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& xPropSet);
88 	void SetCellProperties(const com::sun::star::uno::Reference<com::sun::star::table::XCellRange>& xCellRange,
89 												const com::sun::star::table::CellAddress& aCellAddress);
90 	void SetCellProperties(const com::sun::star::uno::Reference<com::sun::star::table::XCell>& xCell);
91 
92 	void LockSolarMutex();
93 	void UnlockSolarMutex();
94 
CellExists(const com::sun::star::table::CellAddress & aCellPos) const95     sal_Bool CellExists(const com::sun::star::table::CellAddress& aCellPos) const
96     {
97         return (aCellPos.Column <= MAXCOL && aCellPos.Row <= MAXROW);
98     }
99 
100 public:
101 
102 	ScXMLTableRowCellContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
103 					   const ::rtl::OUString& rLName,
104 					   const ::com::sun::star::uno::Reference<
105 										::com::sun::star::xml::sax::XAttributeList>& xAttrList,
106 										const sal_Bool bIsCovered, const sal_Int32 nRepeatedRows );
107 
108 	virtual ~ScXMLTableRowCellContext();
109 
110 	virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
111 									 const ::rtl::OUString& rLocalName,
112 									 const ::com::sun::star::uno::Reference<
113 									  	::com::sun::star::xml::sax::XAttributeList>& xAttrList );
114 
SetString(const rtl::OUString & rOUTempText)115 	inline void SetString(const rtl::OUString& rOUTempText) { pOUTextContent.reset(rOUTempText); }
116 	void SetCursorOnTextImport(const rtl::OUString& rOUTempText);
117 
118 	void SetAnnotation(const ::com::sun::star::table::CellAddress& rPosition );
119 	void SetDetectiveObj( const ::com::sun::star::table::CellAddress& rPosition );
120 	void SetCellRangeSource( const ::com::sun::star::table::CellAddress& rPosition );
121 
122 	virtual void EndElement();
123 };
124 
125 #endif
126 
127