Update ooo320-m1
[ooovba.git] / oox / source / xls / sharedstringsfragment.cxx
blob6d982402c3ef513ec0c00f8f5789003faad9dc04
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: sharedstringsfragment.cxx,v $
10 * $Revision: 1.4 $
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/sharedstringsfragment.hxx"
32 #include "oox/xls/sharedstringsbuffer.hxx"
33 #include "oox/xls/richstringcontext.hxx"
35 using ::rtl::OUString;
36 using ::oox::core::ContextHandlerRef;
37 using ::oox::core::RecordInfo;
39 namespace oox {
40 namespace xls {
42 // ============================================================================
44 OoxSharedStringsFragment::OoxSharedStringsFragment(
45 const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
46 OoxWorkbookFragmentBase( rHelper, rFragmentPath )
50 // oox.core.ContextHandler2Helper interface -----------------------------------
52 ContextHandlerRef OoxSharedStringsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& )
54 switch( getCurrentElement() )
56 case XML_ROOT_CONTEXT:
57 if( nElement == XLS_TOKEN( sst ) )
58 return this;
59 break;
61 case XLS_TOKEN( sst ):
62 if( nElement == XLS_TOKEN( si ) )
63 return new OoxRichStringContext( *this, getSharedStrings().createRichString() );
64 break;
66 return 0;
69 ContextHandlerRef OoxSharedStringsFragment::onCreateRecordContext( sal_Int32 nRecId, RecordInputStream& rStrm )
71 switch( getCurrentElement() )
73 case XML_ROOT_CONTEXT:
74 if( nRecId == OOBIN_ID_SST )
75 return this;
76 break;
78 case OOBIN_ID_SST:
79 if( nRecId == OOBIN_ID_SI )
80 getSharedStrings().createRichString()->importString( rStrm, true );
81 break;
83 return 0;
86 // oox.core.FragmentHandler2 interface ----------------------------------------
88 const RecordInfo* OoxSharedStringsFragment::getRecordInfos() const
90 static const RecordInfo spRecInfos[] =
92 { OOBIN_ID_SST, OOBIN_ID_SST + 1 },
93 { -1, -1 }
95 return spRecInfos;
98 void OoxSharedStringsFragment::finalizeImport()
100 getSharedStrings().finalizeImport();
103 // ============================================================================
105 } // namespace xls
106 } // namespace oox