merge the formfield patch from ooo-build
[ooovba.git] / oox / source / xls / sharedstringsbuffer.cxx
blobf122046ac73a8e4479b61abc90bb243baa2fa0ae
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sharedstringsbuffer.cxx,v $
10 * $Revision: 1.3.22.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/xls/sharedstringsbuffer.hxx"
32 #include "oox/xls/biffinputstream.hxx"
34 using ::com::sun::star::uno::Reference;
35 using ::com::sun::star::text::XText;
37 namespace oox {
38 namespace xls {
40 // ============================================================================
42 SharedStringsBuffer::SharedStringsBuffer( const WorkbookHelper& rHelper ) :
43 WorkbookHelper( rHelper )
47 RichStringRef SharedStringsBuffer::createRichString()
49 RichStringRef xString( new RichString( *this ) );
50 maStrings.push_back( xString );
51 return xString;
54 void SharedStringsBuffer::importSst( BiffInputStream& rStrm )
56 rStrm.skip( 4 );
57 sal_Int32 nStringCount = rStrm.readInt32();
58 if( nStringCount > 0 )
60 maStrings.clear();
61 maStrings.reserve( static_cast< size_t >( nStringCount ) );
62 for( ; !rStrm.isEof() && (nStringCount > 0); --nStringCount )
64 RichStringRef xString( new RichString( *this ) );
65 maStrings.push_back( xString );
66 xString->importUniString( rStrm );
71 void SharedStringsBuffer::finalizeImport()
73 maStrings.forEachMem( &RichString::finalizeImport );
76 void SharedStringsBuffer::convertString( const Reference< XText >& rxText, sal_Int32 nStringId, sal_Int32 nXfId ) const
78 if( rxText.is() )
79 if( const RichString* pString = maStrings.get( nStringId ).get() )
80 pString->convert( rxText, nXfId );
83 // ============================================================================
85 } // namespace xls
86 } // namespace oox