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