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