Update git submodules
[LibreOffice.git] / sc / source / filter / oox / chartsheetfragment.cxx
blob10fde32051e02ea99ac152dcba7ad823d3250a88
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <chartsheetfragment.hxx>
22 #include <oox/helper/attributelist.hxx>
23 #include <oox/token/namespaces.hxx>
24 #include <pagesettings.hxx>
25 #include <viewsettings.hxx>
26 #include <worksheetsettings.hxx>
27 #include <biffhelper.hxx>
29 namespace oox::xls {
31 using namespace ::oox::core;
33 ChartsheetFragment::ChartsheetFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
34 WorksheetFragmentBase( rHelper, rFragmentPath )
38 ContextHandlerRef ChartsheetFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
40 switch( getCurrentElement() )
42 case XML_ROOT_CONTEXT:
43 if( nElement == XLS_TOKEN( chartsheet ) ) return this;
44 break;
46 case XLS_TOKEN( chartsheet ):
47 switch( nElement )
49 case XLS_TOKEN( sheetViews ): return this;
51 case XLS_TOKEN( sheetPr ): getWorksheetSettings().importChartSheetPr( rAttribs ); return this;
52 case XLS_TOKEN( sheetProtection ): getWorksheetSettings().importChartProtection( rAttribs ); break;
53 case XLS_TOKEN( pageMargins ): getPageSettings().importPageMargins( rAttribs ); break;
54 case XLS_TOKEN( pageSetup ): getPageSettings().importChartPageSetup( getRelations(), rAttribs ); break;
55 case XLS_TOKEN( headerFooter ): getPageSettings().importHeaderFooter( rAttribs ); return this;
56 case XLS_TOKEN( picture ): getPageSettings().importPicture( getRelations(), rAttribs ); break;
57 case XLS_TOKEN( drawing ): importDrawing( rAttribs ); break;
59 break;
61 case XLS_TOKEN( sheetViews ):
62 if( nElement == XLS_TOKEN( sheetView ) ) getSheetViewSettings().importChartSheetView( rAttribs );
63 break;
65 case XLS_TOKEN( headerFooter ):
66 switch( nElement )
68 case XLS_TOKEN( firstHeader ):
69 case XLS_TOKEN( firstFooter ):
70 case XLS_TOKEN( oddHeader ):
71 case XLS_TOKEN( oddFooter ):
72 case XLS_TOKEN( evenHeader ):
73 case XLS_TOKEN( evenFooter ): return this; // collect contents in onCharacters()
75 break;
77 case XLS_TOKEN( sheetPr ):
78 switch( nElement )
80 case XLS_TOKEN( tabColor ): getWorksheetSettings().importTabColor( rAttribs ); break;
82 break;
85 return nullptr;
88 void ChartsheetFragment::onCharacters( const OUString& rChars )
90 switch( getCurrentElement() )
92 case XLS_TOKEN( firstHeader ):
93 case XLS_TOKEN( firstFooter ):
94 case XLS_TOKEN( oddHeader ):
95 case XLS_TOKEN( oddFooter ):
96 case XLS_TOKEN( evenHeader ):
97 case XLS_TOKEN( evenFooter ):
98 getPageSettings().importHeaderFooterCharacters( rChars, getCurrentElement() );
99 break;
103 ContextHandlerRef ChartsheetFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
105 switch( getCurrentElement() )
107 case XML_ROOT_CONTEXT:
108 if( nRecId == BIFF12_ID_WORKSHEET ) return this;
109 break;
111 case BIFF12_ID_WORKSHEET:
112 switch( nRecId )
114 case BIFF12_ID_CHARTSHEETVIEWS: return this;
116 case BIFF12_ID_CHARTSHEETPR: getWorksheetSettings().importChartSheetPr( rStrm ); break;
117 case BIFF12_ID_CHARTPROTECTION: getWorksheetSettings().importChartProtection( rStrm ); break;
118 case BIFF12_ID_PAGEMARGINS: getPageSettings().importPageMargins( rStrm ); break;
119 case BIFF12_ID_CHARTPAGESETUP: getPageSettings().importChartPageSetup( getRelations(), rStrm ); break;
120 case BIFF12_ID_HEADERFOOTER: getPageSettings().importHeaderFooter( rStrm ); break;
121 case BIFF12_ID_PICTURE: getPageSettings().importPicture( getRelations(), rStrm ); break;
122 case BIFF12_ID_DRAWING: importDrawing( rStrm ); break;
124 break;
126 case BIFF12_ID_CHARTSHEETVIEWS:
127 if( nRecId == BIFF12_ID_CHARTSHEETVIEW ) getSheetViewSettings().importChartSheetView( rStrm );
128 break;
130 return nullptr;
133 const RecordInfo* ChartsheetFragment::getRecordInfos() const
135 static const RecordInfo spRecInfos[] =
137 { BIFF12_ID_CHARTSHEETVIEW, BIFF12_ID_CHARTSHEETVIEW + 1 },
138 { BIFF12_ID_CHARTSHEETVIEWS, BIFF12_ID_CHARTSHEETVIEWS + 1 },
139 { BIFF12_ID_CUSTOMCHARTVIEW, BIFF12_ID_CUSTOMCHARTVIEW + 1 },
140 { BIFF12_ID_CUSTOMCHARTVIEWS, BIFF12_ID_CUSTOMCHARTVIEWS + 1 },
141 { BIFF12_ID_HEADERFOOTER, BIFF12_ID_HEADERFOOTER + 1 },
142 { BIFF12_ID_WORKSHEET, BIFF12_ID_WORKSHEET + 1 },
143 { -1, -1 }
145 return spRecInfos;
148 void ChartsheetFragment::initializeImport()
150 // initial processing in base class WorksheetHelper
151 initializeWorksheetImport();
154 void ChartsheetFragment::finalizeImport()
156 // final processing in base class WorksheetHelper
157 finalizeWorksheetImport();
160 // private --------------------------------------------------------------------
162 void ChartsheetFragment::importDrawing( const AttributeList& rAttribs )
164 setDrawingPath( getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ) );
167 void ChartsheetFragment::importDrawing( SequenceInputStream& rStrm )
169 setDrawingPath( getFragmentPathFromRelId( BiffHelper::readString( rStrm ) ) );
172 } // namespace oox::xls
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */