LibreOffice Module sc (master) 1
chartsheetfragment.cxx
Go to the documentation of this file.
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
21
23#include <oox/token/namespaces.hxx>
24#include <pagesettings.hxx>
25#include <viewsettings.hxx>
26#include <worksheetsettings.hxx>
27#include <biffhelper.hxx>
28
29namespace oox::xls {
30
31using namespace ::oox::core;
32
33ChartsheetFragment::ChartsheetFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
34 WorksheetFragmentBase( rHelper, rFragmentPath )
35{
36}
37
39{
40 switch( getCurrentElement() )
41 {
43 if( nElement == XLS_TOKEN( chartsheet ) ) return this;
44 break;
45
46 case XLS_TOKEN( chartsheet ):
47 switch( nElement )
48 {
49 case XLS_TOKEN( sheetViews ): return this;
50
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;
58 }
59 break;
60
61 case XLS_TOKEN( sheetViews ):
62 if( nElement == XLS_TOKEN( sheetView ) ) getSheetViewSettings().importChartSheetView( rAttribs );
63 break;
64
65 case XLS_TOKEN( headerFooter ):
66 switch( nElement )
67 {
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()
74 }
75 break;
76
77 case XLS_TOKEN( sheetPr ):
78 switch( nElement )
79 {
80 case XLS_TOKEN( tabColor ): getWorksheetSettings().importTabColor( rAttribs ); break;
81 }
82 break;
83
84 }
85 return nullptr;
86}
87
88void ChartsheetFragment::onCharacters( const OUString& rChars )
89{
90 switch( getCurrentElement() )
91 {
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;
100 }
101}
102
104{
105 switch( getCurrentElement() )
106 {
107 case XML_ROOT_CONTEXT:
108 if( nRecId == BIFF12_ID_WORKSHEET ) return this;
109 break;
110
112 switch( nRecId )
113 {
114 case BIFF12_ID_CHARTSHEETVIEWS: return this;
115
119 case BIFF12_ID_CHARTPAGESETUP: getPageSettings().importChartPageSetup( getRelations(), rStrm ); break;
121 case BIFF12_ID_PICTURE: getPageSettings().importPicture( getRelations(), rStrm ); break;
122 case BIFF12_ID_DRAWING: importDrawing( rStrm ); break;
123 }
124 break;
125
128 break;
129 }
130 return nullptr;
131}
132
133const RecordInfo* ChartsheetFragment::getRecordInfos() const
134{
135 static const RecordInfo spRecInfos[] =
136 {
143 { -1, -1 }
144 };
145 return spRecInfos;
146}
147
149{
150 // initial processing in base class WorksheetHelper
152}
153
155{
156 // final processing in base class WorksheetHelper
158}
159
160// private --------------------------------------------------------------------
161
163{
164 setDrawingPath( getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ) );
165}
166
168{
169 setDrawingPath( getFragmentPathFromRelId( BiffHelper::readString( rStrm ) ) );
170}
171
172} // namespace oox::xls
173
174/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::optional< OUString > getString(sal_Int32 nAttrToken) const
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
Definition: biffhelper.cxx:79
virtual void onCharacters(const OUString &rChars) override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
ChartsheetFragment(const WorksheetHelper &rHelper, const OUString &rFragmentPath)
void importDrawing(const AttributeList &rAttribs)
Imports the relation identifier for the DrawingML part.
virtual void initializeImport() override
virtual const ::oox::core::RecordInfo * getRecordInfos() const override
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual void finalizeImport() override
void importChartPageSetup(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports pageSetup element for chart sheets.
void importPicture(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports the picture element.
void importHeaderFooterCharacters(std::u16string_view rChars, sal_Int32 nElement)
Imports header/footer characters from a headerFooter element.
void importPageMargins(const AttributeList &rAttribs)
Imports pageMarings element containing page margins.
void importHeaderFooter(const AttributeList &rAttribs)
Imports header and footer settings from a headerFooter element.
void importChartSheetView(const AttributeList &rAttribs)
Imports the sheetView element containing view settings of a chart sheet.
Fragment handler derived from the WorksheetHelper helper class.
PageSettings & getPageSettings() const
Returns the page/print settings for this sheet.
WorksheetSettings & getWorksheetSettings() const
Returns the worksheet settings object.
void setDrawingPath(const OUString &rDrawingPath)
Sets the path to the DrawingML fragment of this sheet.
void finalizeWorksheetImport()
Final conversion after importing the worksheet.
SheetViewSettings & getSheetViewSettings() const
Returns the view settings for this sheet.
void initializeWorksheetImport()
Initial conversion before importing the worksheet.
void importChartSheetPr(const AttributeList &rAttribs)
Imports chart sheet settings from the sheetPr element.
void importTabColor(const AttributeList &rAttribs)
Imports the sheet tab color from the tabColor element.
void importChartProtection(const AttributeList &rAttribs)
Imports protection settings from the sheetProtection element of a chart sheet.
@ picture
void SvStream & rStrm
const sal_Int32 XML_ROOT_CONTEXT
const sal_Int32 BIFF12_ID_WORKSHEET
Definition: biffhelper.hxx:241
const sal_Int32 BIFF12_ID_PAGEMARGINS
Definition: biffhelper.hxx:152
const sal_Int32 BIFF12_ID_CHARTPROTECTION
Definition: biffhelper.hxx:56
const sal_Int32 BIFF12_ID_CUSTOMCHARTVIEW
Definition: biffhelper.hxx:77
const sal_Int32 BIFF12_ID_CHARTSHEETVIEW
Definition: biffhelper.hxx:58
const sal_Int32 BIFF12_ID_PICTURE
Definition: biffhelper.hxx:183
const sal_Int32 BIFF12_ID_CHARTPAGESETUP
Definition: biffhelper.hxx:55
const sal_Int32 BIFF12_ID_CHARTSHEETPR
Definition: biffhelper.hxx:57
const sal_Int32 BIFF12_ID_CHARTSHEETVIEWS
Definition: biffhelper.hxx:59
const sal_Int32 BIFF12_ID_CUSTOMCHARTVIEWS
Definition: biffhelper.hxx:78
const sal_Int32 BIFF12_ID_DRAWING
Definition: biffhelper.hxx:97
const sal_Int32 BIFF12_ID_HEADERFOOTER
Definition: biffhelper.hxx:130