Lines 1137-1228
String XclExpUrlHelper::EncodeDde( const
Link Here
|
1137 |
|
1137 |
|
1138 |
// Cached Value Lists ========================================================= |
1138 |
// Cached Value Lists ========================================================= |
1139 |
|
1139 |
|
1140 |
XclExpCachedValue::~XclExpCachedValue() |
1140 |
XclExpCachedMatrix::XclExpCachedMatrix( const ScMatrix& rMatrix ) |
|
|
1141 |
: mrMatrix( rMatrix ) |
1141 |
{ |
1142 |
{ |
|
|
1143 |
const_cast<ScMatrix &>(mrMatrix).IncRef(); |
1142 |
} |
1144 |
} |
1143 |
|
1145 |
XclExpCachedMatrix::~XclExpCachedMatrix() |
1144 |
// ---------------------------------------------------------------------------- |
|
|
1145 |
|
1146 |
void XclExpCachedDouble::Save( XclExpStream& rStrm ) const |
1147 |
{ |
1146 |
{ |
1148 |
rStrm.SetSliceSize( 9 ); |
1147 |
const_cast<ScMatrix &>(mrMatrix).DecRef(); |
1149 |
rStrm << EXC_CACHEDVAL_DOUBLE << mfVal; |
|
|
1150 |
} |
1148 |
} |
1151 |
|
1149 |
|
1152 |
// ---------------------------------------------------------------------------- |
1150 |
void XclExpCachedMatrix::GetDimensions( SCSIZE & nCols, SCSIZE & nRows ) const |
1153 |
|
|
|
1154 |
XclExpCachedString::XclExpCachedString( const String& rStr, XclStrFlags nFlags ) : |
1155 |
maStr( rStr, nFlags ) |
1156 |
{ |
1151 |
{ |
|
|
1152 |
mrMatrix.GetDimensions( nCols, nRows ); |
1153 |
|
1154 |
DBG_ASSERT( nCols && mnRows, "XclExpCachedMatrix::GetDimensions - empty matrix" ); |
1155 |
DBG_ASSERT( nCols <= 256, "XclExpCachedMatrix::GetDimensions - too many columns" ); |
1157 |
} |
1156 |
} |
1158 |
|
1157 |
|
1159 |
void XclExpCachedString::Save( XclExpStream& rStrm ) const |
1158 |
sal_Size XclExpCachedMatrix::GetSize() const |
1160 |
{ |
1159 |
{ |
1161 |
rStrm.SetSliceSize( 6 ); |
1160 |
SCSIZE nCols, nRows; |
1162 |
rStrm << EXC_CACHEDVAL_STRING << maStr; |
|
|
1163 |
} |
1164 |
|
1161 |
|
1165 |
// ---------------------------------------------------------------------------- |
1162 |
GetDimensions( nCols, nRows ); |
1166 |
|
1163 |
|
1167 |
XclExpCachedError::XclExpCachedError( USHORT nScError ) : |
1164 |
/* The returned size may be wrong if the matrix contains strings. The only |
1168 |
mnError( XclTools::GetXclErrorCode( nScError ) ) |
1165 |
effect is that the export stream has to update a wrong record size which is |
1169 |
{ |
1166 |
faster than to iterate through all cached values and calculate their sizes. */ |
|
|
1167 |
return 3 + 9 * (nCols * nRows); |
1170 |
} |
1168 |
} |
1171 |
|
1169 |
|
1172 |
void XclExpCachedError::Save( XclExpStream& rStrm ) const |
1170 |
void XclExpCachedMatrix::Save( XclExpStream& rStrm ) const |
1173 |
{ |
1171 |
{ |
1174 |
rStrm.SetSliceSize( 9 ); |
1172 |
SCSIZE nCols, nRows; |
1175 |
rStrm << EXC_CACHEDVAL_ERROR << mnError; |
|
|
1176 |
rStrm.WriteZeroBytes( 7 ); |
1177 |
} |
1178 |
|
1173 |
|
1179 |
// ---------------------------------------------------------------------------- |
1174 |
GetDimensions( nCols, nRows ); |
1180 |
|
1175 |
|
1181 |
XclExpCachedMatrix::XclExpCachedMatrix( const ScMatrix& rMatrix, XclStrFlags nFlags ) |
1176 |
if( rStrm.GetRoot().GetBiff() <= EXC_BIFF5 ) |
1182 |
{ |
1177 |
// in BIFF2-BIFF7: 256 columns represented by 0 columns |
1183 |
rMatrix.GetDimensions( mnScCols, mnScRows ); |
1178 |
rStrm << static_cast< sal_uInt8 >( nCols ) << static_cast< sal_uInt16 >( nRows ); |
1184 |
DBG_ASSERT( mnScCols && mnScRows, "XclExpCachedMatrix::XclExpCachedMatrix - empty matrix" ); |
1179 |
else |
1185 |
DBG_ASSERT( mnScCols <= 256, "XclExpCachedMatrix::XclExpCachedMatrix - too many columns" ); |
1180 |
// in BIFF8: columns and rows decreaed by 1 |
|
|
1181 |
rStrm << static_cast< sal_uInt8 >( nCols - 1 ) << static_cast< sal_uInt16 >( nRows - 1 ); |
1186 |
|
1182 |
|
1187 |
for( SCSIZE nScRow = 0; nScRow < mnScRows; ++nScRow ) |
1183 |
for( SCSIZE nRow = 0; nRow < nRows; ++nRow ) |
1188 |
{ |
1184 |
{ |
1189 |
for( SCSIZE nScCol = 0; nScCol < mnScCols; ++nScCol ) |
1185 |
for( SCSIZE nCol = 0; nCol < nCols; ++nCol ) |
1190 |
{ |
1186 |
{ |
1191 |
XclExpCachedValue* pNewVal = 0; |
|
|
1192 |
ScMatValType nMatValType = SC_MATVAL_VALUE; |
1187 |
ScMatValType nMatValType = SC_MATVAL_VALUE; |
1193 |
const ScMatrixValue* pMatVal = rMatrix.Get( nScCol, nScRow, nMatValType ); |
1188 |
const ScMatrixValue* pMatVal = mrMatrix.Get( nCol, nRow, nMatValType ); |
1194 |
if( !pMatVal ) |
1189 |
|
1195 |
pNewVal = new XclExpCachedString( EMPTY_STRING, nFlags ); |
1190 |
if( !pMatVal || SC_MATVAL_EMPTY == nMatValType ) |
1196 |
else if( ScMatrix::IsStringType( nMatValType ) ) |
1191 |
{ |
1197 |
pNewVal = new XclExpCachedString( pMatVal->GetString(), nFlags ); |
1192 |
rStrm.SetSliceSize( 9 ); |
1198 |
else if( USHORT nScError = pMatVal->GetError() ) |
1193 |
rStrm << EXC_CACHEDVAL_EMPTY; |
1199 |
pNewVal = new XclExpCachedError( nScError ); |
1194 |
rStrm.WriteZeroBytes( 8 ); |
1200 |
else |
|
|
1201 |
pNewVal = new XclExpCachedDouble( pMatVal->fVal ); |
1202 |
maValueList.Append( pNewVal ); |
1203 |
} |
1204 |
} |
1195 |
} |
|
|
1196 |
else if( ScMatrix::IsStringType( nMatValType ) ) |
1197 |
{ |
1198 |
XclExpString aStr( pMatVal->GetString(), EXC_STR_DEFAULT ); |
1199 |
rStrm.SetSliceSize( 6 ); |
1200 |
rStrm << EXC_CACHEDVAL_STRING << aStr; |
1205 |
} |
1201 |
} |
1206 |
|
1202 |
else if( SC_MATVAL_BOOLEAN == nMatValType ) |
1207 |
sal_Size XclExpCachedMatrix::GetSize() const |
|
|
1208 |
{ |
1203 |
{ |
1209 |
/* The returned size may be wrong if the matrix contains strings. The only |
1204 |
sal_Int8 nBool = pMatVal->GetBoolean(); |
1210 |
effect is that the export stream has to update a wrong record size which is |
1205 |
rStrm.SetSliceSize( 9 ); |
1211 |
faster than to iterate through all cached values and calculate their sizes. */ |
1206 |
rStrm << EXC_CACHEDVAL_BOOL << nBool; |
1212 |
return 3 + 9 * maValueList.Count(); |
1207 |
rStrm.WriteZeroBytes( 7 ); |
1213 |
} |
1208 |
} |
1214 |
|
1209 |
else if( USHORT nScError = pMatVal->GetError() ) |
1215 |
void XclExpCachedMatrix::Save( XclExpStream& rStrm ) const |
|
|
1216 |
{ |
1210 |
{ |
1217 |
if( rStrm.GetRoot().GetBiff() <= EXC_BIFF5 ) |
1211 |
sal_Int8 nError ( XclTools::GetXclErrorCode( nScError ) ); |
1218 |
// in BIFF2-BIFF7: 256 columns represented by 0 columns |
1212 |
rStrm.SetSliceSize( 9 ); |
1219 |
rStrm << static_cast< sal_uInt8 >( mnScCols ) << static_cast< sal_uInt16 >( mnScRows ); |
1213 |
rStrm << EXC_CACHEDVAL_ERROR << nError; |
|
|
1214 |
rStrm.WriteZeroBytes( 7 ); |
1215 |
} |
1220 |
else |
1216 |
else |
1221 |
// in BIFF8: columns and rows decreaed by 1 |
1217 |
{ |
1222 |
rStrm << static_cast< sal_uInt8 >( mnScCols - 1 ) << static_cast< sal_uInt16 >( mnScRows - 1 ); |
1218 |
rStrm.SetSliceSize( 9 ); |
1223 |
|
1219 |
rStrm << EXC_CACHEDVAL_DOUBLE << pMatVal->fVal; |
1224 |
for( const XclExpCachedValue* pValue = maValueList.First(); pValue; pValue = maValueList.Next() ) |
1220 |
} |
1225 |
pValue->Save( rStrm ); |
1221 |
} |
|
|
1222 |
} |
1226 |
} |
1223 |
} |
1227 |
|
1224 |
|
1228 |
// ============================================================================ |
1225 |
// ============================================================================ |