xref: /AOO41X/main/sc/source/filter/xml/XMLDetectiveContext.hxx (revision 38d50f7b14e1cf975d8c6468d9633894cd59b523)
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 
24 #ifndef SC_XMLDETECTIVECONTEXT_HXX
25 #define SC_XMLDETECTIVECONTEXT_HXX
26 
27 #include <xmloff/xmlimp.hxx>
28 #include <com/sun/star/table/CellRangeAddress.hpp>
29 #include "detfunc.hxx"
30 #include "detdata.hxx"
31 
32 #include <list>
33 
34 class ScXMLImport;
35 
36 
37 //___________________________________________________________________
38 
39 struct ScMyImpDetectiveObj
40 {
41     ScRange                     aSourceRange;
42     ScDetectiveObjType          eObjType;
43     sal_Bool                    bHasError;
44 
45                                 ScMyImpDetectiveObj();
46 };
47 
48 typedef ::std::vector< ScMyImpDetectiveObj > ScMyImpDetectiveObjVec;
49 
50 
51 //___________________________________________________________________
52 
53 struct ScMyImpDetectiveOp
54 {
55     ScAddress                   aPosition;
56     ScDetOpType                 eOpType;
57     sal_Int32                   nIndex;
58 
ScMyImpDetectiveOpScMyImpDetectiveOp59     inline                      ScMyImpDetectiveOp() : nIndex( -1 ) {}
60     sal_Bool                    operator<(const ScMyImpDetectiveOp& rDetOp) const;
61 };
62 
63 typedef ::std::list< ScMyImpDetectiveOp > ScMyImpDetectiveOpList;
64 
65 class ScMyImpDetectiveOpArray
66 {
67 private:
68     ScMyImpDetectiveOpList      aDetectiveOpList;
69 
70 public:
ScMyImpDetectiveOpArray()71     inline                      ScMyImpDetectiveOpArray() :
72                                     aDetectiveOpList()  {}
73 
AddDetectiveOp(const ScMyImpDetectiveOp & rDetOp)74     inline void                 AddDetectiveOp( const ScMyImpDetectiveOp& rDetOp )
75                                     { aDetectiveOpList.push_back( rDetOp ); }
76 
77     void                        Sort();
78     sal_Bool                    GetFirstOp( ScMyImpDetectiveOp& rDetOp );
79 };
80 
81 
82 //___________________________________________________________________
83 
84 class ScXMLDetectiveContext : public SvXMLImportContext
85 {
86 private:
87     ScMyImpDetectiveObjVec*     pDetectiveObjVec;
88 
GetScImport() const89     const ScXMLImport&          GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()90     ScXMLImport&                GetScImport()       { return (ScXMLImport&)GetImport(); }
91 
92 public:
93                                 ScXMLDetectiveContext(
94                                     ScXMLImport& rImport,
95                                     sal_uInt16 nPrfx,
96                                     const ::rtl::OUString& rLName,
97                                     ScMyImpDetectiveObjVec* pNewDetectiveObjVec
98                                     );
99     virtual                     ~ScXMLDetectiveContext();
100 
101     virtual SvXMLImportContext* CreateChildContext(
102                                     sal_uInt16 nPrefix,
103                                     const ::rtl::OUString& rLocalName,
104                                     const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList
105                                     );
106     virtual void                EndElement();
107 };
108 
109 
110 //___________________________________________________________________
111 
112 class ScXMLDetectiveHighlightedContext : public SvXMLImportContext
113 {
114 private:
115     ScMyImpDetectiveObjVec*     pDetectiveObjVec;
116     ScMyImpDetectiveObj         aDetectiveObj;
117     sal_Bool                    bValid;
118 
GetScImport() const119     const ScXMLImport&          GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()120     ScXMLImport&                GetScImport()       { return (ScXMLImport&)GetImport(); }
121 
122 public:
123                                 ScXMLDetectiveHighlightedContext(
124                                     ScXMLImport& rImport,
125                                     sal_uInt16 nPrfx,
126                                     const ::rtl::OUString& rLName,
127                                     const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList,
128                                     ScMyImpDetectiveObjVec* pNewDetectiveObjVec
129                                     );
130     virtual                     ~ScXMLDetectiveHighlightedContext();
131 
132     virtual SvXMLImportContext* CreateChildContext(
133                                     sal_uInt16 nPrefix,
134                                     const ::rtl::OUString& rLocalName,
135                                     const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList
136                                     );
137     virtual void                EndElement();
138 };
139 
140 
141 //___________________________________________________________________
142 
143 class ScXMLDetectiveOperationContext : public SvXMLImportContext
144 {
145 private:
146     ScMyImpDetectiveOp          aDetectiveOp;
147     sal_Bool                    bHasType;
148 
GetScImport() const149     const ScXMLImport&          GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()150     ScXMLImport&                GetScImport()       { return (ScXMLImport&)GetImport(); }
151 
152 public:
153                                 ScXMLDetectiveOperationContext(
154                                     ScXMLImport& rImport,
155                                     sal_uInt16 nPrfx,
156                                     const ::rtl::OUString& rLName,
157                                     const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList
158                                     );
159     virtual                     ~ScXMLDetectiveOperationContext();
160 
161     virtual SvXMLImportContext* CreateChildContext(
162                                     sal_uInt16 nPrefix,
163                                     const ::rtl::OUString& rLocalName,
164                                     const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList
165                                     );
166     virtual void                EndElement();
167 };
168 
169 
170 #endif
171 
172