Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "sharedstringsfragment.hxx"
21 :
22 : #include "richstringcontext.hxx"
23 : #include "sharedstringsbuffer.hxx"
24 :
25 : namespace oox {
26 : namespace xls {
27 :
28 : // ============================================================================
29 :
30 : using namespace ::oox::core;
31 :
32 : using ::rtl::OUString;
33 :
34 : // ============================================================================
35 :
36 9 : SharedStringsFragment::SharedStringsFragment(
37 : const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
38 9 : WorkbookFragmentBase( rHelper, rFragmentPath )
39 : {
40 9 : }
41 :
42 81 : ContextHandlerRef SharedStringsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& )
43 : {
44 81 : switch( getCurrentElement() )
45 : {
46 : case XML_ROOT_CONTEXT:
47 9 : if( nElement == XLS_TOKEN( sst ) )
48 9 : return this;
49 0 : break;
50 :
51 : case XLS_TOKEN( sst ):
52 72 : if( nElement == XLS_TOKEN( si ) )
53 72 : return new RichStringContext( *this, getSharedStrings().createRichString() );
54 0 : break;
55 : }
56 0 : return 0;
57 : }
58 :
59 0 : ContextHandlerRef SharedStringsFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
60 : {
61 0 : switch( getCurrentElement() )
62 : {
63 : case XML_ROOT_CONTEXT:
64 0 : if( nRecId == BIFF12_ID_SST )
65 0 : return this;
66 0 : break;
67 :
68 : case BIFF12_ID_SST:
69 0 : if( nRecId == BIFF12_ID_SI )
70 0 : getSharedStrings().createRichString()->importString( rStrm, true );
71 0 : break;
72 : }
73 0 : return 0;
74 : }
75 :
76 0 : const RecordInfo* SharedStringsFragment::getRecordInfos() const
77 : {
78 : static const RecordInfo spRecInfos[] =
79 : {
80 : { BIFF12_ID_SST, BIFF12_ID_SST + 1 },
81 : { -1, -1 }
82 : };
83 0 : return spRecInfos;
84 : }
85 :
86 9 : void SharedStringsFragment::finalizeImport()
87 : {
88 9 : getSharedStrings().finalizeImport();
89 9 : }
90 :
91 : // ============================================================================
92 :
93 : } // namespace xls
94 9 : } // namespace oox
95 :
96 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|