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/sharedstringsfragment.hxx"
25 
26 #include "oox/xls/richstringcontext.hxx"
27 #include "oox/xls/sharedstringsbuffer.hxx"
28 
29 namespace oox {
30 namespace xls {
31 
32 // ============================================================================
33 
34 using namespace ::oox::core;
35 
36 using ::rtl::OUString;
37 
38 // ============================================================================
39 
SharedStringsFragment(const WorkbookHelper & rHelper,const OUString & rFragmentPath)40 SharedStringsFragment::SharedStringsFragment(
41         const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
42     WorkbookFragmentBase( rHelper, rFragmentPath )
43 {
44 }
45 
onCreateContext(sal_Int32 nElement,const AttributeList &)46 ContextHandlerRef SharedStringsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& )
47 {
48     switch( getCurrentElement() )
49     {
50         case XML_ROOT_CONTEXT:
51             if( nElement == XLS_TOKEN( sst ) )
52                 return this;
53         break;
54 
55         case XLS_TOKEN( sst ):
56             if( nElement == XLS_TOKEN( si ) )
57                 return new RichStringContext( *this, getSharedStrings().createRichString() );
58         break;
59     }
60     return 0;
61 }
62 
onCreateRecordContext(sal_Int32 nRecId,SequenceInputStream & rStrm)63 ContextHandlerRef SharedStringsFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
64 {
65     switch( getCurrentElement() )
66     {
67         case XML_ROOT_CONTEXT:
68             if( nRecId == BIFF12_ID_SST )
69                 return this;
70         break;
71 
72         case BIFF12_ID_SST:
73             if( nRecId == BIFF12_ID_SI )
74                 getSharedStrings().createRichString()->importString( rStrm, true );
75         break;
76     }
77     return 0;
78 }
79 
getRecordInfos() const80 const RecordInfo* SharedStringsFragment::getRecordInfos() const
81 {
82     static const RecordInfo spRecInfos[] =
83     {
84         { BIFF12_ID_SST,    BIFF12_ID_SST + 1   },
85         { -1,               -1                  }
86     };
87     return spRecInfos;
88 }
89 
finalizeImport()90 void SharedStringsFragment::finalizeImport()
91 {
92     getSharedStrings().finalizeImport();
93 }
94 
95 // ============================================================================
96 
97 } // namespace xls
98 } // namespace oox
99