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 "chartsheetfragment.hxx"
21 :
22 : #include "oox/helper/attributelist.hxx"
23 : #include "biffinputstream.hxx"
24 : #include "pagesettings.hxx"
25 : #include "viewsettings.hxx"
26 : #include "workbooksettings.hxx"
27 : #include "worksheetsettings.hxx"
28 :
29 : namespace oox {
30 : namespace xls {
31 :
32 : // ============================================================================
33 :
34 : using namespace ::oox::core;
35 :
36 : using ::rtl::OUString;
37 :
38 : // ============================================================================
39 :
40 0 : ChartsheetFragment::ChartsheetFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
41 0 : WorksheetFragmentBase( rHelper, rFragmentPath )
42 : {
43 0 : }
44 :
45 0 : ContextHandlerRef ChartsheetFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
46 : {
47 0 : switch( getCurrentElement() )
48 : {
49 : case XML_ROOT_CONTEXT:
50 0 : if( nElement == XLS_TOKEN( chartsheet ) ) return this;
51 0 : break;
52 :
53 : case XLS_TOKEN( chartsheet ):
54 0 : switch( nElement )
55 : {
56 0 : case XLS_TOKEN( sheetViews ): return this;
57 :
58 0 : case XLS_TOKEN( sheetPr ): getWorksheetSettings().importChartSheetPr( rAttribs ); break;
59 0 : case XLS_TOKEN( sheetProtection ): getWorksheetSettings().importChartProtection( rAttribs ); break;
60 0 : case XLS_TOKEN( pageMargins ): getPageSettings().importPageMargins( rAttribs ); break;
61 0 : case XLS_TOKEN( pageSetup ): getPageSettings().importChartPageSetup( getRelations(), rAttribs ); break;
62 0 : case XLS_TOKEN( headerFooter ): getPageSettings().importHeaderFooter( rAttribs ); return this;
63 0 : case XLS_TOKEN( picture ): getPageSettings().importPicture( getRelations(), rAttribs ); break;
64 0 : case XLS_TOKEN( drawing ): importDrawing( rAttribs ); break;
65 : }
66 0 : break;
67 :
68 : case XLS_TOKEN( sheetViews ):
69 0 : if( nElement == XLS_TOKEN( sheetView ) ) getSheetViewSettings().importChartSheetView( rAttribs );
70 0 : break;
71 :
72 : case XLS_TOKEN( headerFooter ):
73 0 : switch( nElement )
74 : {
75 : case XLS_TOKEN( firstHeader ):
76 : case XLS_TOKEN( firstFooter ):
77 : case XLS_TOKEN( oddHeader ):
78 : case XLS_TOKEN( oddFooter ):
79 : case XLS_TOKEN( evenHeader ):
80 0 : case XLS_TOKEN( evenFooter ): return this; // collect contents in onCharacters()
81 : }
82 0 : break;
83 : }
84 0 : return 0;
85 : }
86 :
87 0 : void ChartsheetFragment::onCharacters( const OUString& rChars )
88 : {
89 0 : switch( getCurrentElement() )
90 : {
91 : case XLS_TOKEN( firstHeader ):
92 : case XLS_TOKEN( firstFooter ):
93 : case XLS_TOKEN( oddHeader ):
94 : case XLS_TOKEN( oddFooter ):
95 : case XLS_TOKEN( evenHeader ):
96 : case XLS_TOKEN( evenFooter ):
97 0 : getPageSettings().importHeaderFooterCharacters( rChars, getCurrentElement() );
98 0 : break;
99 : }
100 0 : }
101 :
102 0 : ContextHandlerRef ChartsheetFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
103 : {
104 0 : switch( getCurrentElement() )
105 : {
106 : case XML_ROOT_CONTEXT:
107 0 : if( nRecId == BIFF12_ID_WORKSHEET ) return this;
108 0 : break;
109 :
110 : case BIFF12_ID_WORKSHEET:
111 0 : switch( nRecId )
112 : {
113 0 : case BIFF12_ID_CHARTSHEETVIEWS: return this;
114 :
115 0 : case BIFF12_ID_CHARTSHEETPR: getWorksheetSettings().importChartSheetPr( rStrm ); break;
116 0 : case BIFF12_ID_CHARTPROTECTION: getWorksheetSettings().importChartProtection( rStrm ); break;
117 0 : case BIFF12_ID_PAGEMARGINS: getPageSettings().importPageMargins( rStrm ); break;
118 0 : case BIFF12_ID_CHARTPAGESETUP: getPageSettings().importChartPageSetup( getRelations(), rStrm ); break;
119 0 : case BIFF12_ID_HEADERFOOTER: getPageSettings().importHeaderFooter( rStrm ); break;
120 0 : case BIFF12_ID_PICTURE: getPageSettings().importPicture( getRelations(), rStrm ); break;
121 0 : case BIFF12_ID_DRAWING: importDrawing( rStrm ); break;
122 : }
123 0 : break;
124 :
125 : case BIFF12_ID_CHARTSHEETVIEWS:
126 0 : if( nRecId == BIFF12_ID_CHARTSHEETVIEW ) getSheetViewSettings().importChartSheetView( rStrm );
127 0 : break;
128 : }
129 0 : return 0;
130 : }
131 :
132 0 : const RecordInfo* ChartsheetFragment::getRecordInfos() const
133 : {
134 : static const RecordInfo spRecInfos[] =
135 : {
136 : { BIFF12_ID_CHARTSHEETVIEW, BIFF12_ID_CHARTSHEETVIEW + 1 },
137 : { BIFF12_ID_CHARTSHEETVIEWS, BIFF12_ID_CHARTSHEETVIEWS + 1 },
138 : { BIFF12_ID_CUSTOMCHARTVIEW, BIFF12_ID_CUSTOMCHARTVIEW + 1 },
139 : { BIFF12_ID_CUSTOMCHARTVIEWS, BIFF12_ID_CUSTOMCHARTVIEWS + 1 },
140 : { BIFF12_ID_HEADERFOOTER, BIFF12_ID_HEADERFOOTER + 1 },
141 : { BIFF12_ID_WORKSHEET, BIFF12_ID_WORKSHEET + 1 },
142 : { -1, -1 }
143 : };
144 0 : return spRecInfos;
145 : }
146 :
147 0 : void ChartsheetFragment::initializeImport()
148 : {
149 : // initial processing in base class WorksheetHelper
150 0 : initializeWorksheetImport();
151 0 : }
152 :
153 0 : void ChartsheetFragment::finalizeImport()
154 : {
155 : // final processing in base class WorksheetHelper
156 0 : finalizeWorksheetImport();
157 0 : }
158 :
159 : // private --------------------------------------------------------------------
160 :
161 0 : void ChartsheetFragment::importDrawing( const AttributeList& rAttribs )
162 : {
163 0 : setDrawingPath( getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ) );
164 0 : }
165 :
166 0 : void ChartsheetFragment::importDrawing( SequenceInputStream& rStrm )
167 : {
168 0 : setDrawingPath( getFragmentPathFromRelId( BiffHelper::readString( rStrm ) ) );
169 0 : }
170 :
171 : } // namespace xls
172 9 : } // namespace oox
173 :
174 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|