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 SCH_XML_TRANSPORTTYPES_HXX_
24 #define SCH_XML_TRANSPORTTYPES_HXX_
25 
26 #include <com/sun/star/chart2/XDataSeries.hpp>
27 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
28 
29 #include <vector>
30 #include <map>
31 
32 enum SchXMLCellType
33 {
34 	SCH_CELL_TYPE_UNKNOWN,
35 	SCH_CELL_TYPE_FLOAT,
36 	SCH_CELL_TYPE_STRING,
37     SCH_CELL_TYPE_COMPLEX_STRING
38 };
39 
40 struct SchXMLCell
41 {
42 	rtl::OUString aString;
43     ::com::sun::star::uno::Sequence< rtl::OUString >* pComplexString;
44 	double fValue;
45 	SchXMLCellType eType;
46     rtl::OUString aRangeId;
47 
SchXMLCellSchXMLCell48 	SchXMLCell() : pComplexString(0), fValue( 0.0 ), eType( SCH_CELL_TYPE_UNKNOWN )
49     {}
50 
SchXMLCellSchXMLCell51     SchXMLCell( const SchXMLCell& rOther )
52         : aString( rOther.aString )
53         , pComplexString( rOther.pComplexString ? new ::com::sun::star::uno::Sequence< rtl::OUString >( *rOther.pComplexString ) : 0 )
54         , fValue( rOther.fValue )
55         , eType( rOther.eType )
56         , aRangeId( rOther.aRangeId )
57     {}
58 
~SchXMLCellSchXMLCell59     ~SchXMLCell()
60     {
61         if(pComplexString)
62         {
63             delete pComplexString;
64             pComplexString=0;
65         }
66     }
67 };
68 
69 struct SchXMLTable
70 {
71 	std::vector< std::vector< SchXMLCell > > aData;		/// an array of rows containing the table contents
72 
73 	sal_Int32 nRowIndex;								/// reflects the index of the row currently parsed
74 	sal_Int32 nColumnIndex;								/// reflects the index of the column currently parsed
75 	sal_Int32 nMaxColumnIndex;							/// the greatest number of columns detected
76 
77 	sal_Int32 nNumberOfColsEstimate;					/// parsing column-elements may yield an estimate
78 
79     bool bHasHeaderRow;
80     bool bHasHeaderColumn;
81 
82     ::rtl::OUString aTableNameOfFile;                   /// the table name read at the table:table element
83 
84     ::std::vector< sal_Int32 > aHiddenColumns;
85 
86     bool bProtected;
87 
SchXMLTableSchXMLTable88 	SchXMLTable() : nRowIndex( -1 ),
89 					nColumnIndex( -1 ),
90 					nMaxColumnIndex( -1 ),
91 					nNumberOfColsEstimate( 0 ),
92                     bHasHeaderRow( false ),
93                     bHasHeaderColumn( false ),
94                     bProtected( false )
95     {}
96 };
97 
98 typedef sal_Int32 tSchXMLIndex;
99 #define SCH_XML_CATEGORIES_INDEX (static_cast<tSchXMLIndex>(-1))
100 enum SchXMLLabeledSequencePart
101 {
102     SCH_XML_PART_LABEL,
103     SCH_XML_PART_VALUES,
104     SCH_XML_PART_ERROR_BARS
105 };
106 typedef ::std::pair< tSchXMLIndex, SchXMLLabeledSequencePart > tSchXMLIndexWithPart;
107 typedef ::std::multimap< tSchXMLIndexWithPart,
108         ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > >
109     tSchXMLLSequencesPerIndex;
110 
111 bool operator < ( const tSchXMLIndexWithPart & rFirst, const tSchXMLIndexWithPart & rSecond );
112 
113 // ----------------------------------------
114 
115 struct SchNumericCellRangeAddress
116 {
117 	sal_Int32 nRow1, nRow2;
118 	sal_Int32 nCol1, nCol2;
119 
SchNumericCellRangeAddressSchNumericCellRangeAddress120 	SchNumericCellRangeAddress() :
121 			nRow1( -1 ), nRow2( -1 ),
122 			nCol1( -1 ), nCol2( -1 )
123 		{}
124 
SchNumericCellRangeAddressSchNumericCellRangeAddress125 	SchNumericCellRangeAddress( const SchNumericCellRangeAddress& aOther )
126 		{
127 			nRow1 = aOther.nRow1; nRow2 = aOther.nRow2;
128 			nCol1 = aOther.nCol1; nCol2 = aOther.nCol2;
129 		}
130 };
131 
132 // ----------------------------------------
133 
134 enum SchXMLAxisDimension
135 {
136 	SCH_XML_AXIS_X = 0,
137 	SCH_XML_AXIS_Y,
138 	SCH_XML_AXIS_Z,
139 	SCH_XML_AXIS_UNDEF
140 };
141 
142 struct SchXMLAxis
143 {
144 	enum SchXMLAxisDimension eDimension;
145 	sal_Int8 nAxisIndex;//0->primary axis; 1->secondary axis
146 	rtl::OUString aName;
147 	rtl::OUString aTitle;
148     bool bHasCategories;
149 
SchXMLAxisSchXMLAxis150 	SchXMLAxis() : eDimension( SCH_XML_AXIS_UNDEF ), nAxisIndex( 0 ), bHasCategories( false ) {}
151 };
152 
153 // ----------------------------------------
154 
155 struct GlobalSeriesImportInfo
156 {
GlobalSeriesImportInfoGlobalSeriesImportInfo157     GlobalSeriesImportInfo( sal_Bool& rAllRangeAddressesAvailable )
158         : rbAllRangeAddressesAvailable( rAllRangeAddressesAvailable )
159         , nCurrentDataIndex( 0 )
160         , nFirstFirstDomainIndex( -1 )
161         , nFirstSecondDomainIndex( -1 )
162     {}
163 
164     sal_Bool& rbAllRangeAddressesAvailable;
165 
166     sal_Int32 nCurrentDataIndex;
167 
168     ::rtl::OUString aFirstFirstDomainAddress;
169     sal_Int32 nFirstFirstDomainIndex;
170 
171     ::rtl::OUString aFirstSecondDomainAddress;
172     sal_Int32 nFirstSecondDomainIndex;
173 };
174 
175 struct DataRowPointStyle
176 {
177     enum StyleType
178     {
179         DATA_POINT,
180         DATA_SERIES,
181         MEAN_VALUE,
182         REGRESSION,
183         ERROR_INDICATOR
184     };
185 
186     StyleType meType;
187     ::com::sun::star::uno::Reference<
188                 ::com::sun::star::chart2::XDataSeries > m_xSeries;
189     ::com::sun::star::uno::Reference<
190                 ::com::sun::star::beans::XPropertySet > m_xOldAPISeries;
191     ::com::sun::star::uno::Reference<
192                 ::com::sun::star::beans::XPropertySet > m_xEquationProperties;
193 	sal_Int32 m_nPointIndex;
194 	sal_Int32 m_nPointRepeat;
195 	::rtl::OUString msStyleName;
196     ::rtl::OUString msSeriesStyleNameForDonuts;
197 	sal_Int32 mnAttachedAxis;
198     bool mbSymbolSizeForSeriesIsMissingInFile;
199 
DataRowPointStyleDataRowPointStyle200 	DataRowPointStyle( StyleType eType
201                        , const ::com::sun::star::uno::Reference<
202                           ::com::sun::star::chart2::XDataSeries >& xSeries
203                         , sal_Int32 nPointIndex
204                         , sal_Int32 nPointRepeat
205                         , ::rtl::OUString sStyleName
206                         , sal_Int32 nAttachedAxis = 0 ) :
207             meType( eType ),
208             m_xSeries( xSeries ),
209             m_xOldAPISeries( 0 ),
210 			m_nPointIndex( nPointIndex ),
211 			m_nPointRepeat( nPointRepeat ),
212 			msStyleName( sStyleName ),
213 			mnAttachedAxis( nAttachedAxis ),
214             mbSymbolSizeForSeriesIsMissingInFile( false )
215 		{}
216 };
217 
218 typedef ::std::multimap< ::rtl::OUString, ::com::sun::star::uno::Reference<
219         ::com::sun::star::chart2::data::XDataSequence > > tSchXMLRangeSequenceMap;
220 
221 #endif	// SCH_XML_TRANSPORTTYPES_HXX_
222