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