1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "oox/xls/sharedstringsfragment.hxx"
29 
30 #include "oox/xls/richstringcontext.hxx"
31 #include "oox/xls/sharedstringsbuffer.hxx"
32 
33 namespace oox {
34 namespace xls {
35 
36 // ============================================================================
37 
38 using namespace ::oox::core;
39 
40 using ::rtl::OUString;
41 
42 // ============================================================================
43 
44 SharedStringsFragment::SharedStringsFragment(
45         const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
46     WorkbookFragmentBase( rHelper, rFragmentPath )
47 {
48 }
49 
50 ContextHandlerRef SharedStringsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& )
51 {
52     switch( getCurrentElement() )
53     {
54         case XML_ROOT_CONTEXT:
55             if( nElement == XLS_TOKEN( sst ) )
56                 return this;
57         break;
58 
59         case XLS_TOKEN( sst ):
60             if( nElement == XLS_TOKEN( si ) )
61                 return new RichStringContext( *this, getSharedStrings().createRichString() );
62         break;
63     }
64     return 0;
65 }
66 
67 ContextHandlerRef SharedStringsFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
68 {
69     switch( getCurrentElement() )
70     {
71         case XML_ROOT_CONTEXT:
72             if( nRecId == BIFF12_ID_SST )
73                 return this;
74         break;
75 
76         case BIFF12_ID_SST:
77             if( nRecId == BIFF12_ID_SI )
78                 getSharedStrings().createRichString()->importString( rStrm, true );
79         break;
80     }
81     return 0;
82 }
83 
84 const RecordInfo* SharedStringsFragment::getRecordInfos() const
85 {
86     static const RecordInfo spRecInfos[] =
87     {
88         { BIFF12_ID_SST,    BIFF12_ID_SST + 1   },
89         { -1,               -1                  }
90     };
91     return spRecInfos;
92 }
93 
94 void SharedStringsFragment::finalizeImport()
95 {
96     getSharedStrings().finalizeImport();
97 }
98 
99 // ============================================================================
100 
101 } // namespace xls
102 } // namespace oox
103