1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "oox/xls/connectionsbuffer.hxx" 29 30 #include "oox/helper/attributelist.hxx" 31 #include "oox/xls/biffinputstream.hxx" 32 33 namespace oox { 34 namespace xls { 35 36 // ============================================================================ 37 38 using namespace ::com::sun::star::uno; 39 40 using ::rtl::OUString; 41 using ::rtl::OUStringBuffer; 42 43 // ============================================================================ 44 45 namespace { 46 47 const sal_Int32 BIFF12_RECONNECT_AS_REQUIRED = 1; 48 const sal_Int32 BIFF12_RECONNECT_ALWAYS = 2; 49 const sal_Int32 BIFF12_RECONNECT_NEVER = 3; 50 51 const sal_uInt8 BIFF12_CONNECTION_SAVEPASSWORD_ON = 1; 52 const sal_uInt8 BIFF12_CONNECTION_SAVEPASSWORD_OFF = 2; 53 54 const sal_uInt16 BIFF12_CONNECTION_KEEPALIVE = 0x0001; 55 const sal_uInt16 BIFF12_CONNECTION_NEW = 0x0002; 56 const sal_uInt16 BIFF12_CONNECTION_DELETED = 0x0004; 57 const sal_uInt16 BIFF12_CONNECTION_ONLYUSECONNFILE = 0x0008; 58 const sal_uInt16 BIFF12_CONNECTION_BACKGROUND = 0x0010; 59 const sal_uInt16 BIFF12_CONNECTION_REFRESHONLOAD = 0x0020; 60 const sal_uInt16 BIFF12_CONNECTION_SAVEDATA = 0x0040; 61 62 const sal_uInt16 BIFF12_CONNECTION_HAS_SOURCEFILE = 0x0001; 63 const sal_uInt16 BIFF12_CONNECTION_HAS_SOURCECONNFILE = 0x0002; 64 const sal_uInt16 BIFF12_CONNECTION_HAS_DESCRIPTION = 0x0004; 65 const sal_uInt16 BIFF12_CONNECTION_HAS_NAME = 0x0008; 66 const sal_uInt16 BIFF12_CONNECTION_HAS_SSOID = 0x0010; 67 68 const sal_uInt32 BIFF12_WEBPR_XML = 0x00000100; 69 const sal_uInt32 BIFF12_WEBPR_SOURCEDATA = 0x00000200; 70 const sal_uInt32 BIFF12_WEBPR_PARSEPRE = 0x00000400; 71 const sal_uInt32 BIFF12_WEBPR_CONSECUTIVE = 0x00000800; 72 const sal_uInt32 BIFF12_WEBPR_FIRSTROW = 0x00001000; 73 const sal_uInt32 BIFF12_WEBPR_XL97CREATED = 0x00002000; 74 const sal_uInt32 BIFF12_WEBPR_TEXTDATES = 0x00004000; 75 const sal_uInt32 BIFF12_WEBPR_XL2000REFRESHED = 0x00008000; 76 const sal_uInt32 BIFF12_WEBPR_HTMLTABLES = 0x00010000; 77 78 const sal_uInt8 BIFF12_WEBPR_HAS_POSTMETHOD = 0x01; 79 const sal_uInt8 BIFF12_WEBPR_HAS_EDITPAGE = 0x02; 80 const sal_uInt8 BIFF12_WEBPR_HAS_URL = 0x04; 81 82 const sal_uInt16 BIFF_DBQUERY_ODBC = 0x0008; 83 const sal_uInt16 BIFF_DBQUERY_SQLQUERY = 0x0010; 84 const sal_uInt16 BIFF_DBQUERY_SERVERBASEDSQL = 0x0020; 85 const sal_uInt16 BIFF_DBQUERY_HTML = 0x0040; 86 const sal_uInt16 BIFF_DBQUERY_SAVEPASSWORD = 0x0080; 87 const sal_uInt16 BIFF_DBQUERY_HTMLTABLES = 0x0100; 88 89 const sal_uInt16 BIFF_QTSETTINGS_KEEPALIVE = 0x0001; 90 const sal_uInt16 BIFF_QTSETTINGS_NEW = 0x0002; 91 const sal_uInt16 BIFF_QTSETTINGS_SOURCEDATA = 0x0004; 92 const sal_uInt16 BIFF_QTSETTINGS_WEBBASEDPROV = 0x0008; 93 const sal_uInt16 BIFF_QTSETTINGS_REINITLIST = 0x0010; 94 const sal_uInt16 BIFF_QTSETTINGS_XML = 0x0080; 95 96 const sal_uInt16 BIFF_QTSETTINGS_PARSEPRE = 0x0001; 97 const sal_uInt16 BIFF_QTSETTINGS_CONSECUTIVE = 0x0002; 98 const sal_uInt16 BIFF_QTSETTINGS_FIRSTROW = 0x0004; 99 const sal_uInt16 BIFF_QTSETTINGS_XL97CREATED = 0x0008; 100 const sal_uInt16 BIFF_QTSETTINGS_TEXTDATES = 0x0010; 101 const sal_uInt16 BIFF_QTSETTINGS_XL2000REFRESHED = 0x0020; 102 103 const sal_uInt16 BIFF_QTSETTINGS_TEXTQUERY = 0x0001; 104 const sal_uInt16 BIFF_QTSETTINGS_TABLENAMES = 0x0002; 105 106 // ---------------------------------------------------------------------------- 107 108 OUString lclReadQueryString( BiffInputStream& rStrm, sal_uInt16 nCount ) 109 { 110 bool bValidRec = true; 111 OUStringBuffer aBuffer; 112 for( sal_uInt16 nIndex = 0; bValidRec && (nIndex < nCount); ++nIndex ) 113 { 114 bValidRec = (rStrm.getNextRecId() == BIFF_ID_PCITEM_STRING) && rStrm.startNextRecord(); 115 if( bValidRec ) 116 aBuffer.append( rStrm.readUniString() ); 117 } 118 OSL_ENSURE( bValidRec, "lclReadQueryString - missing PCITEM_STRING records" ); 119 return aBuffer.makeStringAndClear(); 120 } 121 122 void lclParseTables( WebPrModel::TablesVector& rTables, const OUString& rTableNames ) 123 { 124 rTables.clear(); 125 OUString aTableNames = rTableNames.trim(); 126 while( aTableNames.getLength() > 0 ) 127 { 128 sal_Int32 nSep = -1; 129 // table names are enclosed in double quotes 130 if( aTableNames[ 0 ] == '"' ) 131 { 132 // search closing quote character 133 sal_Int32 nEndQuote = aTableNames.indexOf( '"', 1 ); 134 OSL_ENSURE( nEndQuote >= 1, "lclParseTables - invalid syntax" ); 135 if( nEndQuote < 0 ) 136 nEndQuote = aTableNames.getLength(); 137 else 138 nSep = aTableNames.indexOf( ',', nEndQuote + 1 ); 139 // extract text between quote characters 140 OUString aTableName = aTableNames.copy( 1, nEndQuote - 1 ).trim(); 141 if( aTableName.getLength() > 0 ) 142 rTables.push_back( Any( aTableName ) ); 143 else 144 rTables.push_back( Any() ); 145 } 146 else 147 { 148 nSep = aTableNames.indexOf( ',' ); 149 if( nSep < 0 ) 150 nSep = aTableNames.getLength(); 151 OUString aTableIndex = aTableNames.copy( 0, nSep ).trim(); 152 if( (aTableIndex.getLength() > 0) && (aTableIndex[ 0 ] >= '1') && (aTableIndex[ 0 ] <= '9') ) 153 rTables.push_back( Any( aTableIndex.toInt32() ) ); 154 else 155 rTables.push_back( Any() ); 156 } 157 158 // remove processed item from aTableNames 159 if( (nSep < 0) || (nSep >= aTableNames.getLength()) ) 160 aTableNames = OUString(); 161 else 162 aTableNames = aTableNames.copy( nSep + 1 ).trim(); 163 } 164 } 165 166 } // namespace 167 168 // ============================================================================ 169 170 WebPrModel::WebPrModel() : 171 mnHtmlFormat( XML_none ), 172 mbXml( false ), 173 mbSourceData( false ), 174 mbParsePre( false ), 175 mbConsecutive( false ), 176 mbFirstRow( false ), 177 mbXl97Created( false ), 178 mbTextDates( false ), 179 mbXl2000Refreshed( false ), 180 mbHtmlTables( false ) 181 { 182 } 183 184 // ---------------------------------------------------------------------------- 185 186 ConnectionModel::ConnectionModel() : 187 mnId( -1 ), 188 mnType( BIFF12_CONNECTION_UNKNOWN ), 189 mnReconnectMethod( BIFF12_RECONNECT_AS_REQUIRED ), 190 mnCredentials( XML_integrated ), 191 mnInterval( 0 ), 192 mbKeepAlive( false ), 193 mbNew( false ), 194 mbDeleted( false ), 195 mbOnlyUseConnFile( false ), 196 mbBackground( false ), 197 mbRefreshOnLoad( false ), 198 mbSaveData( false ), 199 mbSavePassword( false ) 200 { 201 } 202 203 WebPrModel& ConnectionModel::createWebPr() 204 { 205 OSL_ENSURE( !mxWebPr.get(), "ConnectionModel::createWebPr - multiple call" ); 206 mxWebPr.reset( new WebPrModel ); 207 return *mxWebPr; 208 } 209 210 // ---------------------------------------------------------------------------- 211 212 Connection::Connection( const WorkbookHelper& rHelper, sal_Int32 nConnId ) : 213 WorkbookHelper( rHelper ) 214 { 215 maModel.mnId = nConnId; 216 } 217 218 void Connection::importConnection( const AttributeList& rAttribs ) 219 { 220 maModel.maName = rAttribs.getXString( XML_name, OUString() ); 221 maModel.maDescription = rAttribs.getXString( XML_description, OUString() ); 222 maModel.maSourceFile = rAttribs.getXString( XML_sourceFile, OUString() ); 223 maModel.maSourceConnFile = rAttribs.getXString( XML_odcFile, OUString() ); 224 maModel.maSsoId = rAttribs.getXString( XML_singleSignOnId, OUString() ); 225 maModel.mnId = rAttribs.getInteger( XML_id, -1 ); 226 // type and reconnectionMethod are using the BIFF12 constants instead of XML tokens 227 maModel.mnType = rAttribs.getInteger( XML_type, BIFF12_CONNECTION_UNKNOWN ); 228 maModel.mnReconnectMethod = rAttribs.getInteger( XML_reconnectionMethod, BIFF12_RECONNECT_AS_REQUIRED ); 229 maModel.mnCredentials = rAttribs.getToken( XML_credentials, XML_integrated ); 230 maModel.mnInterval = rAttribs.getInteger( XML_interval, 0 ); 231 maModel.mbKeepAlive = rAttribs.getBool( XML_keepAlive, false ); 232 maModel.mbNew = rAttribs.getBool( XML_new, false ); 233 maModel.mbDeleted = rAttribs.getBool( XML_deleted, false ); 234 maModel.mbOnlyUseConnFile = rAttribs.getBool( XML_onlyUseConnectionFile, false ); 235 maModel.mbBackground = rAttribs.getBool( XML_background, false ); 236 maModel.mbRefreshOnLoad = rAttribs.getBool( XML_refreshOnLoad, false ); 237 maModel.mbSaveData = rAttribs.getBool( XML_saveData, false ); 238 maModel.mbSavePassword = rAttribs.getBool( XML_savePassword, false ); 239 } 240 241 void Connection::importWebPr( const AttributeList& rAttribs ) 242 { 243 WebPrModel& rWebPr = maModel.createWebPr(); 244 245 rWebPr.maUrl = rAttribs.getXString( XML_url, OUString() ); 246 rWebPr.maPostMethod = rAttribs.getXString( XML_post, OUString() ); 247 rWebPr.maEditPage = rAttribs.getXString( XML_editPage, OUString() ); 248 rWebPr.mnHtmlFormat = rAttribs.getToken( XML_htmlFormat, XML_none ); 249 rWebPr.mbXml = rAttribs.getBool( XML_xml, false ); 250 rWebPr.mbSourceData = rAttribs.getBool( XML_sourceData, false ); 251 rWebPr.mbParsePre = rAttribs.getBool( XML_parsePre, false ); 252 rWebPr.mbConsecutive = rAttribs.getBool( XML_consecutive, false ); 253 rWebPr.mbFirstRow = rAttribs.getBool( XML_firstRow, false ); 254 rWebPr.mbXl97Created = rAttribs.getBool( XML_xl97, false ); 255 rWebPr.mbTextDates = rAttribs.getBool( XML_textDates, false ); 256 rWebPr.mbXl2000Refreshed = rAttribs.getBool( XML_xl2000, false ); 257 rWebPr.mbHtmlTables = rAttribs.getBool( XML_htmlTables, false ); 258 } 259 260 void Connection::importTables( const AttributeList& /*rAttribs*/ ) 261 { 262 if( maModel.mxWebPr.get() ) 263 { 264 OSL_ENSURE( maModel.mxWebPr->maTables.empty(), "Connection::importTables - multiple calls" ); 265 maModel.mxWebPr->maTables.clear(); 266 } 267 } 268 269 void Connection::importTable( const AttributeList& rAttribs, sal_Int32 nElement ) 270 { 271 if( maModel.mxWebPr.get() ) 272 { 273 Any aTableAny; 274 switch( nElement ) 275 { 276 case XLS_TOKEN( m ): break; 277 case XLS_TOKEN( s ): aTableAny <<= rAttribs.getXString( XML_v, OUString() ); break; 278 case XLS_TOKEN( x ): aTableAny <<= rAttribs.getInteger( XML_v, -1 ); break; 279 default: 280 OSL_ENSURE( false, "Connection::importTable - unexpected element" ); 281 return; 282 } 283 maModel.mxWebPr->maTables.push_back( aTableAny ); 284 } 285 } 286 287 void Connection::importConnection( SequenceInputStream& rStrm ) 288 { 289 sal_uInt16 nFlags, nStrFlags; 290 sal_uInt8 nSavePassword, nCredentials; 291 rStrm.skip( 2 ); 292 rStrm >> nSavePassword; 293 rStrm.skip( 1 ); 294 maModel.mnInterval = rStrm.readuInt16(); 295 rStrm >> nFlags >> nStrFlags >> maModel.mnType >> maModel.mnReconnectMethod >> maModel.mnId >> nCredentials; 296 297 if( getFlag( nStrFlags, BIFF12_CONNECTION_HAS_SOURCEFILE ) ) 298 rStrm >> maModel.maSourceFile; 299 if( getFlag( nStrFlags, BIFF12_CONNECTION_HAS_SOURCECONNFILE ) ) 300 rStrm >> maModel.maSourceConnFile; 301 if( getFlag( nStrFlags, BIFF12_CONNECTION_HAS_DESCRIPTION ) ) 302 rStrm >> maModel.maDescription; 303 if( getFlag( nStrFlags, BIFF12_CONNECTION_HAS_NAME ) ) 304 rStrm >> maModel.maName; 305 if( getFlag( nStrFlags, BIFF12_CONNECTION_HAS_SSOID ) ) 306 rStrm >> maModel.maSsoId; 307 308 static const sal_Int32 spnCredentials[] = { XML_integrated, XML_none, XML_stored, XML_prompt }; 309 maModel.mnCredentials = STATIC_ARRAY_SELECT( spnCredentials, nCredentials, XML_integrated ); 310 311 maModel.mbKeepAlive = getFlag( nFlags, BIFF12_CONNECTION_KEEPALIVE ); 312 maModel.mbNew = getFlag( nFlags, BIFF12_CONNECTION_NEW ); 313 maModel.mbDeleted = getFlag( nFlags, BIFF12_CONNECTION_DELETED ); 314 maModel.mbOnlyUseConnFile = getFlag( nFlags, BIFF12_CONNECTION_ONLYUSECONNFILE ); 315 maModel.mbBackground = getFlag( nFlags, BIFF12_CONNECTION_BACKGROUND ); 316 maModel.mbRefreshOnLoad = getFlag( nFlags, BIFF12_CONNECTION_REFRESHONLOAD ); 317 maModel.mbSaveData = getFlag( nFlags, BIFF12_CONNECTION_SAVEDATA ); 318 maModel.mbSavePassword = nSavePassword == BIFF12_CONNECTION_SAVEPASSWORD_ON; 319 } 320 321 void Connection::importWebPr( SequenceInputStream& rStrm ) 322 { 323 WebPrModel& rWebPr = maModel.createWebPr(); 324 325 sal_uInt32 nFlags; 326 sal_uInt8 nStrFlags; 327 rStrm >> nFlags >> nStrFlags; 328 329 if( getFlag( nStrFlags, BIFF12_WEBPR_HAS_URL ) ) 330 rStrm >> rWebPr.maUrl; 331 if( getFlag( nStrFlags, BIFF12_WEBPR_HAS_POSTMETHOD ) ) 332 rStrm >> rWebPr.maPostMethod; 333 if( getFlag( nStrFlags, BIFF12_WEBPR_HAS_EDITPAGE ) ) 334 rStrm >> rWebPr.maEditPage; 335 336 static const sal_Int32 spnHmlFormats[] = { XML_none, XML_rtf, XML_all }; 337 rWebPr.mnHtmlFormat = STATIC_ARRAY_SELECT( spnHmlFormats, extractValue< sal_uInt8 >( nFlags, 0, 8 ), XML_none ); 338 339 rWebPr.mbXml = getFlag( nFlags, BIFF12_WEBPR_XML ); 340 rWebPr.mbSourceData = getFlag( nFlags, BIFF12_WEBPR_SOURCEDATA ); 341 rWebPr.mbParsePre = getFlag( nFlags, BIFF12_WEBPR_PARSEPRE ); 342 rWebPr.mbConsecutive = getFlag( nFlags, BIFF12_WEBPR_CONSECUTIVE ); 343 rWebPr.mbFirstRow = getFlag( nFlags, BIFF12_WEBPR_FIRSTROW ); 344 rWebPr.mbXl97Created = getFlag( nFlags, BIFF12_WEBPR_XL97CREATED ); 345 rWebPr.mbTextDates = getFlag( nFlags, BIFF12_WEBPR_TEXTDATES ); 346 rWebPr.mbXl2000Refreshed = getFlag( nFlags, BIFF12_WEBPR_XL2000REFRESHED ); 347 rWebPr.mbHtmlTables = getFlag( nFlags, BIFF12_WEBPR_HTMLTABLES ); 348 } 349 350 void Connection::importWebPrTables( SequenceInputStream& /*rStrm*/ ) 351 { 352 if( maModel.mxWebPr.get() ) 353 { 354 OSL_ENSURE( maModel.mxWebPr->maTables.empty(), "Connection::importWebPrTables - multiple calls" ); 355 maModel.mxWebPr->maTables.clear(); 356 } 357 } 358 359 void Connection::importWebPrTable( SequenceInputStream& rStrm, sal_Int32 nRecId ) 360 { 361 if( maModel.mxWebPr.get() ) 362 { 363 Any aTableAny; 364 switch( nRecId ) 365 { 366 case BIFF12_ID_PCITEM_MISSING: break; 367 case BIFF12_ID_PCITEM_STRING: aTableAny <<= BiffHelper::readString( rStrm ); break; 368 case BIFF12_ID_PCITEM_INDEX: aTableAny <<= rStrm.readInt32(); break; 369 default: 370 OSL_ENSURE( false, "Connection::importWebPrTable - unexpected record" ); 371 return; 372 } 373 maModel.mxWebPr->maTables.push_back( aTableAny ); 374 } 375 } 376 377 void Connection::importDbQuery( BiffInputStream& rStrm ) 378 { 379 sal_uInt16 nFlags, nSqlParamCount, nCommandCount, nPostMethodCount, nServerSqlCount, nOdbcConnCount; 380 rStrm >> nFlags >> nSqlParamCount >> nCommandCount >> nPostMethodCount >> nServerSqlCount >> nOdbcConnCount; 381 382 // same type constants in all BIFF versions 383 maModel.mnType = extractValue< sal_Int32 >( nFlags, 0, 3 ); 384 maModel.mbSavePassword = getFlag( nFlags, BIFF_DBQUERY_SAVEPASSWORD ); 385 386 OSL_ENSURE( getFlag( nFlags, BIFF_DBQUERY_ODBC ) == (maModel.mnType == BIFF12_CONNECTION_ODBC), "Connection::importDbQuery - wrong ODBC flag" ); 387 OSL_ENSURE( getFlag( nFlags, BIFF_DBQUERY_SQLQUERY ) != (maModel.mnType == BIFF12_CONNECTION_HTML), "Connection::importDbQuery - wrong SQL query flag" ); 388 OSL_ENSURE( getFlag( nFlags, BIFF_DBQUERY_HTML ) == (maModel.mnType == BIFF12_CONNECTION_HTML), "Connection::importDbQuery - wrong HTML flag" ); 389 390 if( (maModel.mnType == BIFF12_CONNECTION_HTML) && getFlag( nFlags, BIFF_DBQUERY_HTML ) ) 391 { 392 WebPrModel& rWebPr = maModel.createWebPr(); 393 rWebPr.mbHtmlTables = getFlag( nFlags, BIFF_DBQUERY_HTMLTABLES ); 394 395 // read HTML query URL and post method 396 rWebPr.maUrl = lclReadQueryString( rStrm, nCommandCount ); 397 rWebPr.maPostMethod = lclReadQueryString( rStrm, nPostMethodCount ); 398 } 399 } 400 401 void Connection::importQueryTableSettings( BiffInputStream& rStrm ) 402 { 403 rStrm.skip( 4 ); 404 // source data type, again 405 sal_uInt16 nType = rStrm.readuInt16(); 406 OSL_ENSURE( nType == maModel.mnType, "Connection::importQueryTableSettings - source data type mismatch" ); 407 if( nType == maModel.mnType ) 408 { 409 sal_uInt16 nFlags1, nFlags2, nFlags3, nHtmlFormat; 410 rStrm >> nFlags1 >> nFlags2 >> nFlags3; 411 rStrm.skip( 10 ); 412 maModel.mnInterval = rStrm.readuInt16(); 413 rStrm >> nHtmlFormat; 414 415 // first flags field: generic connection flags 416 maModel.mbKeepAlive = getFlag( nFlags1, BIFF_QTSETTINGS_KEEPALIVE ); 417 maModel.mbNew = getFlag( nFlags1, BIFF_QTSETTINGS_NEW ); 418 419 // meaning of second flags field is dependent on source data type 420 if( (maModel.mnType == BIFF12_CONNECTION_HTML) && maModel.mxWebPr.get() ) 421 { 422 WebPrModel& rWebPr = *maModel.mxWebPr; 423 424 // HTML format is one-based in BIFF8 (but zero-based in BIFF12) 425 static const sal_Int32 spnHmlFormats[] = { XML_none, XML_none, XML_rtf, XML_all }; 426 rWebPr.mnHtmlFormat = STATIC_ARRAY_SELECT( spnHmlFormats, nHtmlFormat, XML_none ); 427 428 rWebPr.mbXml = getFlag( nFlags1, BIFF_QTSETTINGS_XML ); 429 rWebPr.mbSourceData = getFlag( nFlags1, BIFF_QTSETTINGS_SOURCEDATA ); 430 rWebPr.mbParsePre = getFlag( nFlags2, BIFF_QTSETTINGS_PARSEPRE ); 431 rWebPr.mbConsecutive = getFlag( nFlags2, BIFF_QTSETTINGS_CONSECUTIVE ); 432 rWebPr.mbFirstRow = getFlag( nFlags2, BIFF_QTSETTINGS_FIRSTROW ); 433 rWebPr.mbXl97Created = getFlag( nFlags2, BIFF_QTSETTINGS_XL97CREATED ); 434 rWebPr.mbTextDates = getFlag( nFlags2, BIFF_QTSETTINGS_TEXTDATES ); 435 rWebPr.mbXl2000Refreshed = getFlag( nFlags2, BIFF_QTSETTINGS_XL2000REFRESHED ); 436 437 // list of HTML table names or indexes 438 if( getFlag( nFlags3, BIFF_QTSETTINGS_TABLENAMES ) ) 439 { 440 // a QUERYTABLESTRING record containing the table names must follow 441 bool bHasQTString = (rStrm.getNextRecId() == BIFF_ID_QUERYTABLESTRING) && rStrm.startNextRecord(); 442 OSL_ENSURE( bHasQTString, "Connection::importQueryTableSettings - missing QUERYTABLESTRING record" ); 443 if( bHasQTString ) 444 { 445 rStrm.skip( 4 ); 446 lclParseTables( rWebPr.maTables, rStrm.readUniString() ); 447 } 448 } 449 } 450 } 451 } 452 453 // ============================================================================ 454 455 ConnectionsBuffer::ConnectionsBuffer( const WorkbookHelper& rHelper ) : 456 WorkbookHelper( rHelper ), 457 mnUnusedId( 1 ) 458 { 459 } 460 461 Connection& ConnectionsBuffer::createConnection() 462 { 463 ConnectionRef xConnection( new Connection( *this ) ); 464 maConnections.push_back( xConnection ); 465 return *xConnection; 466 } 467 468 Connection& ConnectionsBuffer::createConnectionWithId() 469 { 470 ConnectionRef xConnection( new Connection( *this, mnUnusedId ) ); 471 maConnections.push_back( xConnection ); 472 insertConnectionToMap( xConnection ); 473 return *xConnection; 474 } 475 476 void ConnectionsBuffer::finalizeImport() 477 { 478 for( ConnectionVector::iterator aIt = maConnections.begin(), aEnd = maConnections.end(); aIt != aEnd; ++aIt ) 479 insertConnectionToMap( *aIt ); 480 } 481 482 ConnectionRef ConnectionsBuffer::getConnection( sal_Int32 nConnId ) const 483 { 484 return maConnectionsById.get( nConnId ); 485 } 486 487 void ConnectionsBuffer::insertConnectionToMap( const ConnectionRef& rxConnection ) 488 { 489 sal_Int32 nConnId = rxConnection->getConnectionId(); 490 if( nConnId > 0 ) 491 { 492 OSL_ENSURE( !maConnectionsById.has( nConnId ), "ConnectionsBuffer::insertConnectionToMap - multiple connection identifier" ); 493 maConnectionsById[ nConnId ] = rxConnection; 494 mnUnusedId = ::std::max< sal_Int32 >( mnUnusedId, nConnId + 1 ); 495 } 496 } 497 498 // ============================================================================ 499 500 } // namespace xls 501 } // namespace oox 502