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_XMLEXTERNALTABI_HXX
25 #define SC_XMLEXTERNALTABI_HXX
26 
27 #include <xmloff/xmlictxt.hxx>
28 #include "rtl/ustrbuf.hxx"
29 
30 class ScXMLImport;
31 struct ScXMLExternalTabData;
32 
33 class ScXMLExternalRefTabSourceContext : public SvXMLImportContext
34 {
35 public:
36     ScXMLExternalRefTabSourceContext( ScXMLImport& rImport, sal_uInt16 nPrefix,
37                         const ::rtl::OUString& rLName,
38                         const ::com::sun::star::uno::Reference<
39                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
40                         ScXMLExternalTabData& rRefInfo );
41 
42     virtual ~ScXMLExternalRefTabSourceContext();
43 
44     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
45                                      const ::rtl::OUString& rLocalName,
46                                      const ::com::sun::star::uno::Reference<
47                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
48 
49     virtual void EndElement();
50 private:
51     ScXMLImport&            mrScImport;
52     ScXMLExternalTabData&   mrExternalRefInfo;
53 
54     ::rtl::OUString         maRelativeUrl;
55     ::rtl::OUString         maTableName;
56     ::rtl::OUString         maFilterName;
57     ::rtl::OUString         maFilterOptions;
58 };
59 
60 // ============================================================================
61 
62 class ScXMLExternalRefRowsContext : public SvXMLImportContext
63 {
64 public:
65     ScXMLExternalRefRowsContext( ScXMLImport& rImport, sal_uInt16 nPrefix,
66                         const ::rtl::OUString& rLName,
67                         const ::com::sun::star::uno::Reference<
68                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
69                         ScXMLExternalTabData& rRefInfo );
70 
71     virtual ~ScXMLExternalRefRowsContext();
72 
73     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
74                                      const ::rtl::OUString& rLocalName,
75                                      const ::com::sun::star::uno::Reference<
76                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
77 
78     virtual void EndElement();
79 private:
80     ScXMLImport&            mrScImport;
81     ScXMLExternalTabData&   mrExternalRefInfo;
82 };
83 
84 // ============================================================================
85 
86 class ScXMLExternalRefRowContext : public SvXMLImportContext
87 {
88 public:
89     ScXMLExternalRefRowContext( ScXMLImport& rImport, sal_uInt16 nPrefix,
90                         const ::rtl::OUString& rLName,
91                         const ::com::sun::star::uno::Reference<
92                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
93                         ScXMLExternalTabData& rRefInfo );
94 
95     virtual ~ScXMLExternalRefRowContext();
96 
97     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
98                                      const ::rtl::OUString& rLocalName,
99                                      const ::com::sun::star::uno::Reference<
100                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
101 
102     virtual void EndElement();
103 private:
104     ScXMLImport&            mrScImport;
105     ScXMLExternalTabData&   mrExternalRefInfo;
106     sal_Int32               mnRepeatRowCount;
107 };
108 
109 // ============================================================================
110 
111 class ScXMLExternalRefCellContext : public SvXMLImportContext
112 {
113 public:
114     ScXMLExternalRefCellContext( ScXMLImport& rImport, sal_uInt16 nPrefix,
115                         const ::rtl::OUString& rLName,
116                         const ::com::sun::star::uno::Reference<
117                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
118                         ScXMLExternalTabData& rRefInfo );
119 
120     virtual ~ScXMLExternalRefCellContext();
121 
122     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
123                                      const ::rtl::OUString& rLocalName,
124                                      const ::com::sun::star::uno::Reference<
125                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
126 
127     virtual void EndElement();
128 
129     void SetCellString(const ::rtl::OUString& rStr);
130 
131 private:
132     ScXMLImport&            mrScImport;
133     ScXMLExternalTabData&   mrExternalRefInfo;
134     ::rtl::OUString         maCellString;
135     double                  mfCellValue;
136     sal_Int32               mnRepeatCount;
137     sal_Int32               mnNumberFormat;
138     sal_Int16               mnCellType;
139     bool                    mbIsNumeric;
140     bool                    mbIsEmpty;
141 };
142 
143 // ============================================================================
144 
145 class ScXMLExternalRefCellTextContext : public SvXMLImportContext
146 {
147 public:
148     ScXMLExternalRefCellTextContext( ScXMLImport& rImport, sal_uInt16 nPrefix,
149                         const ::rtl::OUString& rLName,
150                         const ::com::sun::star::uno::Reference<
151                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
152                         ScXMLExternalRefCellContext& rParent );
153 
154     virtual ~ScXMLExternalRefCellTextContext();
155 
156     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
157                                      const ::rtl::OUString& rLocalName,
158                                      const ::com::sun::star::uno::Reference<
159                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
160 
161     virtual void Characters(const ::rtl::OUString& rChar);
162 
163     virtual void EndElement();
164 
165 private:
166     ScXMLImport&            mrScImport;
167     ScXMLExternalRefCellContext& mrParent;
168 
169     ::rtl::OUStringBuffer   maCellStrBuf;
170 };
171 
172 #endif
173