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