MCPcopy Create free account
hub / github.com/LibreOffice/core / exportBinary

Method exportBinary

scripting/source/stringresource/stringresource.cxx:1168–1225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1166// pos3 Properties file written by implWritePropertiesFile
1167
1168Sequence< sal_Int8 > StringResourcePersistenceImpl::exportBinary( )
1169{
1170 BinaryOutput aOut;
1171
1172 sal_Int32 nLocaleCount = m_aLocaleItemVector.size();
1173 std::vector<Sequence< sal_Int8 >> aLocaleDataSeq(nLocaleCount);
1174
1175 sal_Int32 iLocale = 0;
1176 sal_Int32 iDefault = 0;
1177 for( auto& pLocaleItem : m_aLocaleItemVector )
1178 {
1179 if( pLocaleItem != nullptr && loadLocale( pLocaleItem.get() ) )
1180 {
1181 if( m_pDefaultLocaleItem == pLocaleItem.get() )
1182 iDefault = iLocale;
1183
1184 BinaryOutput aLocaleOut;
1185 implWriteLocaleBinary( pLocaleItem.get(), aLocaleOut );
1186
1187 aLocaleDataSeq[iLocale] = aLocaleOut.closeAndGetData();
1188 }
1189 ++iLocale;
1190 }
1191
1192 // Write header
1193 sal_Int16 nLocaleCount16 = static_cast<sal_Int16>(nLocaleCount);
1194 sal_Int16 iDefault16 = static_cast<sal_Int16>(iDefault);
1195 aOut.writeInt16( 0 ); // nVersion
1196 aOut.writeInt16( nLocaleCount16 );
1197 aOut.writeInt16( iDefault16 );
1198
1199 // Write data positions
1200 sal_Int32 nDataPos = 6 + 4 * (nLocaleCount + 1);
1201 for( iLocale = 0; iLocale < nLocaleCount; iLocale++ )
1202 {
1203 aOut.writeInt32( nDataPos );
1204
1205 Sequence< sal_Int8 >& rSeq = aLocaleDataSeq[iLocale];
1206 sal_Int32 nSeqLen = rSeq.getLength();
1207 nDataPos += nSeqLen;
1208 }
1209 // Write final position
1210 aOut.writeInt32( nDataPos );
1211
1212 // Write data
1213 Reference< io::XOutputStream > xOutputStream = aOut.getOutputStream();
1214 if( xOutputStream.is() )
1215 {
1216 for( iLocale = 0; iLocale < nLocaleCount; iLocale++ )
1217 {
1218 Sequence< sal_Int8 >& rSeq = aLocaleDataSeq[iLocale];
1219 xOutputStream->writeBytes( rSeq );
1220 }
1221 }
1222
1223 Sequence< sal_Int8 > aRetSeq = aOut.closeAndGetData();
1224 return aRetSeq;
1225}

Callers 1

CopyMethod · 0.80

Calls 9

closeAndGetDataMethod · 0.80
writeInt16Method · 0.80
writeInt32Method · 0.80
getMethod · 0.65
sizeMethod · 0.45
getLengthMethod · 0.45
getOutputStreamMethod · 0.45
isMethod · 0.45
writeBytesMethod · 0.45

Tested by

no test coverage detected