LibreOffice Module sc (master) 1
worksheetfragment.hxx
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
20#pragma once
21
22#include <memory>
23#include "excelhandlers.hxx"
24
25namespace oox::xls {
26
28{
29public:
30 void SetSqref( const OUString& rChars ) { maSqref = rChars; }
31 void SetFormula1( const OUString& rChars ) { maFormula1 = rChars; }
32 void SetFormula2( const OUString& rChars ) { maFormula2 = rChars; }
33 void SetValidation( WorksheetHelper& rTarget );
35 void importDataValidation( const AttributeList& rAttribs );
37 static void importDataValidation( SequenceInputStream& rStrm, WorksheetHelper& rTarget );
38 bool isFormula1Set() const { return !maFormula1.isEmpty(); }
39 bool isFormula2Set() const { return !maFormula2.isEmpty(); }
40
41private:
42 std::unique_ptr< ValidationModel > mxValModel;
43
44 OUString maSqref;
45 OUString maFormula1;
46 OUString maFormula2;
47};
48
49// For following types of validations:
50//
51// <dataValidations count="1">
52// <dataValidation allowBlank="true" operator="equal" showDropDown="false" showErrorMessage="true" showInputMessage="false" sqref="C1:C5" type="list">
53// <formula1>Sheet1!$A$1:$A$5</formula1>
54// <formula2>0</formula2>
55// </dataValidation>
56// </dataValidations>
57//
58// or
59//
60// <dataValidations count="1">
61// <dataValidation type="list" operator="equal" allowBlank="1" showErrorMessage="1" sqref="A1">
62// <mc:AlternateContent xmlns:x12ac="http://schemas.microsoft.com/office/spreadsheetml/2011/1/ac" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
63// <mc:Choice Requires="x12ac">
64// <x12ac:list>1,"2,3",4</x12ac:list>
65// </mc:Choice>
66// <mc:Fallback>
67// <formula1>"1,2,3,4"</formula1>
68// </mc:Fallback>
69// </mc:AlternateContent>
70// </dataValidation>
71// </dataValidations>
72
74{
75public:
76 explicit DataValidationsContext( WorksheetFragmentBase& rFragment );
77
78protected:
79 virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
80 virtual void onCharacters( const OUString& rChars ) override;
81 virtual void onEndElement() override;
82
83 virtual ::oox::core::ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
84};
85
86// For following types of validations:
87//
88// <extLst>
89// <ext uri="{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main">
90// <x14:dataValidations count="1" xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
91// <x14:dataValidation type="list" allowBlank="1" showInputMessage="1" showErrorMessage="1">
92// <x14:formula1>
93// <xm:f>Sheet1!$A$2:$A$272</xm:f>
94// </x14:formula1>
95// <xm:sqref>A6:A22</xm:sqref>
96// </x14:dataValidation>
97// </x14:dataValidations>
98// </ext>
99// </extLst>
100
102{
103public:
104 explicit ExtDataValidationsContext( WorksheetContextBase& rFragment );
105
106protected:
107 virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
108 virtual void onCharacters( const OUString& rChars ) override;
109 virtual void onEndElement() override;
110private:
111 sal_Int32 mCurrFormula;
112};
113
115{
116public:
117 explicit WorksheetFragment(
118 const WorksheetHelper& rHelper,
119 const OUString& rFragmentPath );
120
121protected:
122 virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override;
123 virtual void onCharacters( const OUString& rChars ) override;
124
125 virtual ::oox::core::ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
126
127 virtual const ::oox::core::RecordInfo* getRecordInfos() const override;
128 virtual void initializeImport() override;
129 virtual void finalizeImport() override;
130
131private:
133 void importPageSetUpPr( const AttributeList& rAttribs );
135 void importDimension( const AttributeList& rAttribs );
137 void importSheetFormatPr( const AttributeList& rAttribs );
139 void importCol( const AttributeList& rAttribs );
141 void importMergeCell( const AttributeList& rAttribs );
143 void importHyperlink( const AttributeList& rAttribs );
145 void importBrk( const AttributeList& rAttribs, bool bRowBreak );
147 void importDrawing( const AttributeList& rAttribs );
149 void importLegacyDrawing( const AttributeList& rAttribs );
151 void importOleObject( const AttributeList& rAttribs );
153 void importControl( const AttributeList& rAttribs );
154
166 void importBrk( SequenceInputStream& rStrm, bool bRowBreak );
175
177 void importEmbeddedOleData( StreamDataSequence& orEmbeddedData, const OUString& rRelId );
178};
179
180} // namespace oox::xls
181
182/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< ValidationModel > mxValModel
void importDataValidation(const AttributeList &rAttribs)
Imports the dataValidation element containing data validation settings.
void SetFormula1(const OUString &rChars)
void SetFormula2(const OUString &rChars)
void SetValidation(WorksheetHelper &rTarget)
void SetSqref(const OUString &rChars)
virtual void onCharacters(const OUString &rChars) override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual void onEndElement() override
DataValidationsContext(WorksheetFragmentBase &rFragment)
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
ExtDataValidationsContext(WorksheetContextBase &rFragment)
virtual void onCharacters(const OUString &rChars) override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Context handler derived from the WorksheetHelper helper class.
Fragment handler derived from the WorksheetHelper helper class.
virtual const ::oox::core::RecordInfo * getRecordInfos() const override
virtual void onCharacters(const OUString &rChars) override
void importCol(const AttributeList &rAttribs)
Imports column settings from a col element.
void importOleObject(const AttributeList &rAttribs)
Imports additional data for an OLE object.
virtual void finalizeImport() override
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
void importLegacyDrawing(const AttributeList &rAttribs)
Imports the relation identifier for the legacy VML drawing part.
void importDimension(const AttributeList &rAttribs)
Imports the dimension element containing the used area of the sheet.
void importSheetFormatPr(const AttributeList &rAttribs)
Imports sheet format properties from a sheetFormatPr element.
virtual void initializeImport() override
void importDrawing(const AttributeList &rAttribs)
Imports the relation identifier for the DrawingML part.
WorksheetFragment(const WorksheetHelper &rHelper, const OUString &rFragmentPath)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
void importBrk(const AttributeList &rAttribs, bool bRowBreak)
Imports individual break that is either within row or column break context.
void importHyperlink(const AttributeList &rAttribs)
Imports the hyperlink element containing a hyperlink for a cell range.
void importMergeCell(const AttributeList &rAttribs)
Imports a merged cell range from a mergeCell element.
void importPageSetUpPr(const AttributeList &rAttribs)
Imports page settings from a pageSetUpPr element.
void importEmbeddedOleData(StreamDataSequence &orEmbeddedData, const OUString &rRelId)
Imports the binary data of an embedded OLE object from the fragment with the passed ID.
void importControl(const AttributeList &rAttribs)
Imports additional data for an OCX form control.
void SvStream & rStrm
css::uno::Sequence< sal_Int8 > StreamDataSequence