| 1366 | } |
| 1367 | |
| 1368 | void StringResourcePersistenceImpl::importBinary( const Sequence< ::sal_Int8 >& Data ) |
| 1369 | { |
| 1370 | // Init: Remove all locales |
| 1371 | sal_Int32 nOldLocaleCount = 0; |
| 1372 | do |
| 1373 | { |
| 1374 | Sequence< Locale > aLocaleSeq = getLocales(); |
| 1375 | nOldLocaleCount = aLocaleSeq.getLength(); |
| 1376 | if( nOldLocaleCount > 0 ) |
| 1377 | { |
| 1378 | Locale aLocale = aLocaleSeq[0]; |
| 1379 | removeLocale( aLocale ); |
| 1380 | } |
| 1381 | } |
| 1382 | while( nOldLocaleCount > 0 ); |
| 1383 | |
| 1384 | // Import data |
| 1385 | BinaryInput aIn( Data ); |
| 1386 | |
| 1387 | aIn.readInt16(); // version |
| 1388 | sal_Int32 nLocaleCount = aIn.readInt16(); |
| 1389 | sal_Int32 iDefault = aIn.readInt16(); |
| 1390 | |
| 1391 | std::unique_ptr<sal_Int32[]> pPositions( new sal_Int32[nLocaleCount + 1] ); |
| 1392 | for( sal_Int32 i = 0; i < nLocaleCount + 1; i++ ) |
| 1393 | pPositions[i] = aIn.readInt32(); |
| 1394 | |
| 1395 | // Import locales |
| 1396 | LocaleItem* pUseAsDefaultItem = nullptr; |
| 1397 | for( sal_Int32 i = 0; i < nLocaleCount; i++ ) |
| 1398 | { |
| 1399 | sal_Int32 nPos = pPositions[i]; |
| 1400 | aIn.seek( nPos ); |
| 1401 | |
| 1402 | Locale aLocale; |
| 1403 | aLocale.Language = aIn.readString(); |
| 1404 | aLocale.Country = aIn.readString(); |
| 1405 | aLocale.Variant = aIn.readString(); |
| 1406 | |
| 1407 | sal_Int32 nAfterStringPos = aIn.getPosition(); |
| 1408 | sal_Int32 nSize = pPositions[i+1] - nAfterStringPos; |
| 1409 | Reference< io::XInputStream > xInput = aIn.getInputStreamForSection( nSize ); |
| 1410 | if( xInput.is() ) |
| 1411 | { |
| 1412 | LocaleItem* pLocaleItem = new LocaleItem( std::move(aLocale) ); |
| 1413 | if( iDefault == i ) |
| 1414 | pUseAsDefaultItem = pLocaleItem; |
| 1415 | m_aLocaleItemVector.emplace_back( pLocaleItem ); |
| 1416 | implReadPropertiesFile( pLocaleItem, xInput ); |
| 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | if( pUseAsDefaultItem != nullptr ) |
| 1421 | setDefaultLocale( pUseAsDefaultItem->m_locale ); |
| 1422 | } |
| 1423 | |
| 1424 | |
| 1425 | // Private helper methods |
no test coverage detected