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