1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "oox/xls/sharedstringsbuffer.hxx"
25 
26 #include "oox/xls/biffinputstream.hxx"
27 
28 namespace oox {
29 namespace xls {
30 
31 // ============================================================================
32 
33 using namespace ::com::sun::star::text;
34 using namespace ::com::sun::star::uno;
35 
36 // ============================================================================
37 
SharedStringsBuffer(const WorkbookHelper & rHelper)38 SharedStringsBuffer::SharedStringsBuffer( const WorkbookHelper& rHelper ) :
39      WorkbookHelper( rHelper )
40 {
41 }
42 
createRichString()43 RichStringRef SharedStringsBuffer::createRichString()
44 {
45     RichStringRef xString( new RichString( *this ) );
46     maStrings.push_back( xString );
47     return xString;
48 }
49 
importSst(BiffInputStream & rStrm)50 void SharedStringsBuffer::importSst( BiffInputStream& rStrm )
51 {
52     rStrm.skip( 4 );
53     sal_Int32 nStringCount = rStrm.readInt32();
54     if( nStringCount > 0 )
55     {
56         maStrings.clear();
57         maStrings.reserve( static_cast< size_t >( nStringCount ) );
58         for( ; !rStrm.isEof() && (nStringCount > 0); --nStringCount )
59         {
60             RichStringRef xString( new RichString( *this ) );
61             maStrings.push_back( xString );
62             xString->importUniString( rStrm );
63         }
64     }
65 }
66 
finalizeImport()67 void SharedStringsBuffer::finalizeImport()
68 {
69     maStrings.forEachMem( &RichString::finalizeImport );
70 }
71 
getString(sal_Int32 nStringId) const72 RichStringRef SharedStringsBuffer::getString( sal_Int32 nStringId ) const
73 {
74     return maStrings.get( nStringId );
75 }
76 
77 // ============================================================================
78 
79 } // namespace xls
80 } // namespace oox
81