LibreOffice Module sc (master) 1
xlroot.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 <i18nlangtag/lang.h>
23#include <tools/ref.hxx>
24#include <tools/long.hxx>
25#include "xlconst.hxx"
26#include <memory>
27
28namespace com::sun::star::beans { struct NamedValue; }
29namespace comphelper { class IDocPasswordVerifier; }
30
31// Forward declarations of objects in public use ==============================
32
33class DateTime;
34class SotStorage;
36
37// Global data ================================================================
38
39#ifdef DBG_UTIL
42{
43 sal_Int32 mnObjCnt;
44 explicit XclDebugObjCounter() : mnObjCnt( 0 ) {}
46};
47#endif
48
49class SfxMedium;
52class EditEngine;
53class ScExtDocOptions;
56class XclTracer;
57
58struct RootData;
59
62#ifdef DBG_UTIL
63 : public XclDebugObjCounter
64#endif
65{
66 typedef std::shared_ptr< ScEditEngineDefaulter > ScEEDefaulterRef;
67 typedef std::shared_ptr< ScHeaderEditEngine > ScHeaderEERef;
68 typedef std::shared_ptr< EditEngine > EditEngineRef;
69 typedef std::shared_ptr< XclFontPropSetHelper > XclFontPropSetHlpRef;
70 typedef std::shared_ptr< XclChPropSetHelper > XclChPropSetHlpRef;
71 typedef std::shared_ptr< ScExtDocOptions > ScExtDocOptRef;
72 typedef std::shared_ptr< XclTracer > XclTracerRef;
73 typedef std::shared_ptr< RootData > RootDataRef;
74
80 OUString maDocUrl;
81 OUString maBasePath;
82 OUString maUserName;
83 static constexpr OUStringLiteral gaDefPassword = u"VelvetSweatshop";
84 rtl_TextEncoding meTextEnc;
88 sal_Int16 mnDefApiScript;
92
96
99
103
109 const bool mbExport;
110
111 explicit XclRootData( XclBiff eBiff, SfxMedium& rMedium,
112 tools::SvRef<SotStorage> xRootStrg, ScDocument& rDoc,
113 rtl_TextEncoding eTextEnc, bool bExport );
114 virtual ~XclRootData();
115};
116
117class SfxObjectShell;
118class ScModelObj;
119class OutputDevice;
121class SdrPage;
122class ScStyleSheetPool;
123class ScRangeName;
124struct XclFontData;
125
128{
129public:
130 explicit XclRoot( XclRootData& rRootData );
131 XclRoot( const XclRoot& rRoot );
132
133 virtual ~XclRoot();
134
135 XclRoot& operator=( const XclRoot& rRoot );
136
138 RootData& GetOldRoot() const { return *mrData.mxRD; }
139
141 XclBiff GetBiff() const { return mrData.meBiff; }
143 XclOutput GetOutput() const { return mrData.meOutput; }
145 bool IsImport() const { return !mrData.mbExport; }
147 rtl_TextEncoding GetTextEncoding() const { return mrData.meTextEnc; }
155 sal_Int16 GetDefApiScript() const { return mrData.mnDefApiScript; }
160 bool IsInGlobals() const { return mrData.mnScTab == SCTAB_GLOBAL; }
162 SCTAB GetCurrScTab() const { return mrData.mnScTab; }
163
165 sal_Int32 GetHmmFromPixelX( double fPixelX ) const;
167 sal_Int32 GetHmmFromPixelY( double fPixelY ) const;
168
170 SfxMedium& GetMedium() const { return mrData.mrMedium; }
172 const OUString& GetDocUrl() const { return mrData.maDocUrl; }
174 const OUString& GetBasePath() const { return mrData.maBasePath; }
176 const OUString& GetUserName() const { return mrData.maUserName; }
177
179 static OUString GetDefaultPassword() { return XclRootData::gaDefPassword; }
181 css::uno::Sequence< css::beans::NamedValue >
183
188 bool HasVbaStorage() const;
189
191 tools::SvRef<SotStorage> OpenStorage( tools::SvRef<SotStorage> const & xStrg, const OUString& rStrgName ) const;
193 tools::SvRef<SotStorage> OpenStorage( const OUString& rStrgName ) const;
195 tools::SvRef<SotStorageStream> OpenStream( tools::SvRef<SotStorage> const & xStrg, const OUString& rStrmName ) const;
197 tools::SvRef<SotStorageStream> OpenStream( const OUString& rStrmName ) const;
198
200 ScDocument& GetDoc() const;
201
205 ScModelObj* GetDocModelObj() const;
207 OutputDevice* GetPrinter() const;
213 SdrPage* GetSdrPage( SCTAB nScTab ) const;
214
218 DateTime GetNullDate() const;
220 sal_uInt16 GetBaseYear() const;
222 double GetDoubleFromDateTime( const DateTime& rDateTime ) const;
224 DateTime GetDateTimeFromDouble( double fValue ) const;
225
232
237
241 XclTracer& GetTracer() const;
242
244 const ScAddress& GetScMaxPos() const { return mrData.maScMaxPos; }
246 const ScAddress& GetXclMaxPos() const { return mrData.maXclMaxPos; }
248 const ScAddress& GetMaxPos() const { return mrData.maMaxPos; }
249
251 void SetDocLanguage( LanguageType eLang ) { mrData.meDocLang = eLang; }
253 void SetUILanguage( LanguageType eLang ) { mrData.meUILang = eLang; }
255 void SetTextEncoding( rtl_TextEncoding eTextEnc );
259 void SetCharWidth( const XclFontData& rFontData );
261 void SetCurrScTab( SCTAB nScTab ) { mrData.mnScTab = nScTab; }
264
265private:
267};
268
269/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Extended options held by an ScDocument containing additional settings for filters.
Definition: scextopt.hxx:77
Helper class for usage of property sets.
Definition: xlchart.hxx:1312
Helper class for usage of property sets.
Definition: xlstyle.hxx:403
Access to global data for a filter object (imported or exported document) from other classes.
Definition: xlroot.hxx:128
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
Definition: xlroot.cxx:290
LanguageType GetDocLanguage() const
Returns the document language.
Definition: xlroot.hxx:151
ScModelObj * GetDocModelObj() const
Returns the object model of the Calc document.
Definition: xlroot.cxx:295
tools::SvRef< SotStorage > OpenStorage(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrgName) const
Tries to open a storage as child of the specified storage for reading or writing.
Definition: xlroot.cxx:261
const tools::SvRef< SotStorage > & GetRootStorage() const
Returns the OLE2 root storage of the imported/exported file.
Definition: xlroot.hxx:186
ScHeaderEditEngine & GetHFEditEngine() const
Returns the edit engine for import/export of headers/footers.
Definition: xlroot.cxx:380
XclOutput GetOutput() const
Returns the current output format of the importer/exporter.
Definition: xlroot.hxx:143
const OUString & GetDocUrl() const
Returns the document URL of the imported/exported file.
Definition: xlroot.hxx:172
const OUString & GetBasePath() const
Returns the base path of the imported/exported file.
Definition: xlroot.hxx:174
virtual ~XclRoot()
Definition: xlroot.cxx:186
ScExtDocOptions & GetExtDocOptions() const
Returns the extended document options.
Definition: xlroot.cxx:429
static OUString GetDefaultPassword()
Returns the default password used for stream encryption.
Definition: xlroot.hxx:179
const ScAddress & GetScMaxPos() const
Returns the highest possible cell address in a Calc document.
Definition: xlroot.hxx:244
rtl_TextEncoding GetTextEncoding() const
Returns the text encoding to import/export byte strings.
Definition: xlroot.hxx:147
void SetDocLanguage(LanguageType eLang)
Sets the document language.
Definition: xlroot.hxx:251
XclRoot(XclRootData &rRootData)
Definition: xlroot.cxx:167
OutputDevice * GetPrinter() const
Returns pointer to the printer of the Calc document.
Definition: xlroot.cxx:301
tools::Long GetCharWidth() const
Returns the width of the '0' character (default font) for the current printer (twips).
Definition: xlroot.hxx:157
bool IsImport() const
Returns true, if currently a document is imported.
Definition: xlroot.hxx:145
css::uno::Sequence< css::beans::NamedValue > RequestEncryptionData(::comphelper::IDocPasswordVerifier &rVerifier) const
Requests and verifies a password from the medium or the user.
Definition: xlroot.cxx:249
SfxMedium & GetMedium() const
Returns the medium to import from.
Definition: xlroot.hxx:170
void SetTextEncoding(rtl_TextEncoding eTextEnc)
Sets the text encoding to import/export byte strings.
Definition: xlroot.cxx:201
DateTime GetNullDate() const
Returns the null date of the current number formatter.
Definition: xlroot.cxx:327
XclTracer & GetTracer() const
Returns the filter tracer.
Definition: xlroot.cxx:434
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
Definition: xlroot.cxx:322
tools::SvRef< SotStorageStream > OpenStream(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrmName) const
Tries to open a new stream in the specified storage for reading or writing.
Definition: xlroot.cxx:273
sal_Int32 GetHmmFromPixelX(double fPixelX) const
Calculates the width of the passed number of pixels in 1/100 mm.
Definition: xlroot.cxx:239
bool IsInGlobals() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:160
ScEditEngineDefaulter & GetEditEngine() const
Returns the edit engine for import/export of rich strings etc.
Definition: xlroot.cxx:365
XclRootData & mrData
Definition: xlroot.hxx:266
const ScAddress & GetMaxPos() const
Returns the highest possible cell address valid in Calc and Excel (using current BIFF version).
Definition: xlroot.hxx:248
sal_Int16 GetDefApiScript() const
Returns the default script type, e.g.
Definition: xlroot.hxx:155
void SetUILanguage(LanguageType eLang)
Sets the UI language, i.e.
Definition: xlroot.hxx:253
LanguageType GetUILanguage() const
Returns the UI language.
Definition: xlroot.hxx:153
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:162
tools::Long GetSpaceWidth() const
Definition: xlroot.hxx:158
EditEngine & GetDrawEditEngine() const
Returns the edit engine for import/export of drawing text boxes.
Definition: xlroot.cxx:404
void SetCharWidth(const XclFontData &rFontData)
Sets the width of the '0' - '9' digit character as well as the ' ' space char (using the default font...
Definition: xlroot.cxx:207
LanguageType GetSysLanguage() const
Returns the system language, i.e.
Definition: xlroot.hxx:149
XclChPropSetHelper & GetChartPropSetHelper() const
Returns the property set helper for the chart filters.
Definition: xlroot.cxx:424
const OUString & GetUserName() const
Returns the current user name.
Definition: xlroot.hxx:176
bool HasVbaStorage() const
Returns true, if the document contains a VBA storage.
Definition: xlroot.cxx:255
ScStyleSheetPool & GetStyleSheetPool() const
Returns the style sheet pool of the Calc document.
Definition: xlroot.cxx:306
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
Definition: xlroot.hxx:141
RootData & GetOldRoot() const
Returns old RootData struct.
Definition: xlroot.hxx:138
sal_Int32 GetHmmFromPixelY(double fPixelY) const
Calculates the height of the passed number of pixels in 1/100 mm.
Definition: xlroot.cxx:244
DateTime GetDateTimeFromDouble(double fValue) const
Converts a floating-point value to a date/time value.
Definition: xlroot.cxx:352
ScRangeName & GetNamedRanges() const
Returns the defined names container of the Calc document.
Definition: xlroot.cxx:311
XclRoot & operator=(const XclRoot &rRoot)
Definition: xlroot.cxx:193
double GetDoubleFromDateTime(const DateTime &rDateTime) const
Converts a date/time value to a floating-point value.
Definition: xlroot.cxx:341
void IncCurrScTab()
Increases the current Calc sheet index by 1.
Definition: xlroot.hxx:263
sal_uInt16 GetBaseYear() const
Returns the base year depending on the current null date (1900 or 1904).
Definition: xlroot.cxx:332
void SetCurrScTab(SCTAB nScTab)
Sets the current Calc sheet index.
Definition: xlroot.hxx:261
const ScAddress & GetXclMaxPos() const
Returns the highest possible cell address in an Excel document (using current BIFF version).
Definition: xlroot.hxx:246
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:285
SdrPage * GetSdrPage(SCTAB nScTab) const
Returns the drawing layer page of the passed sheet, if present.
Definition: xlroot.cxx:316
XclFontPropSetHelper & GetFontPropSetHelper() const
Returns the property set helper for fonts.
Definition: xlroot.cxx:419
This class wraps an MSFilterTracer to create trace logs for import/export filters.
Definition: xltracer.hxx:51
float u
long Long
Counts the number of created root objects.
Definition: xlroot.hxx:42
sal_Int32 mnObjCnt
Definition: xlroot.hxx:43
This struct helps reading and writing Excel fonts.
Definition: xlstyle.hxx:285
Stores global buffers and data needed elsewhere in the Excel filters.
Definition: xlroot.hxx:65
XclChPropSetHlpRef mxChPropSetHlp
Property set helper for fonts.
Definition: xlroot.hxx:98
std::shared_ptr< ScEditEngineDefaulter > ScEEDefaulterRef
Definition: xlroot.hxx:66
XclBiff meBiff
Definition: xlroot.hxx:75
std::shared_ptr< ScExtDocOptions > ScExtDocOptRef
Definition: xlroot.hxx:71
LanguageType meDocLang
System language.
Definition: xlroot.hxx:86
tools::SvRef< SotStorage > mxRootStrg
The medium to import from.
Definition: xlroot.hxx:78
rtl_TextEncoding meTextEnc
The default password used for stream encryption.
Definition: xlroot.hxx:84
XclFontPropSetHlpRef mxFontPropSetHlp
Edit engine for text boxes.
Definition: xlroot.hxx:97
ScAddress maMaxPos
Highest Excel cell position.
Definition: xlroot.hxx:91
ScAddress maScMaxPos
Default script type for blank cells (API constant).
Definition: xlroot.hxx:89
virtual ~XclRootData()
Definition: xlroot.cxx:163
std::shared_ptr< ScHeaderEditEngine > ScHeaderEERef
Definition: xlroot.hxx:67
ScAddress maXclMaxPos
Highest Calc cell position.
Definition: xlroot.hxx:90
const bool mbExport
Current Calc sheet index.
Definition: xlroot.hxx:109
XclOutput meOutput
Current BIFF version.
Definition: xlroot.hxx:76
double mfScreenPixelX
Old RootData struct. Will be removed.
Definition: xlroot.hxx:104
SfxMedium & mrMedium
Current Output format.
Definition: xlroot.hxx:77
tools::Long mnCharWidth
Height of a screen pixel (1/100 mm).
Definition: xlroot.hxx:106
EditEngineRef mxDrawEditEng
Edit engine for header/footer.
Definition: xlroot.hxx:95
std::shared_ptr< RootData > RootDataRef
Definition: xlroot.hxx:73
std::shared_ptr< XclFontPropSetHelper > XclFontPropSetHlpRef
Definition: xlroot.hxx:69
OUString maBasePath
Document URL of imported/exported file.
Definition: xlroot.hxx:81
LanguageType meSysLang
Text encoding to import/export byte strings.
Definition: xlroot.hxx:85
static constexpr OUStringLiteral gaDefPassword
Current user name.
Definition: xlroot.hxx:83
RootDataRef mxRD
Filter tracer.
Definition: xlroot.hxx:102
OUString maDocUrl
The source or destination document.
Definition: xlroot.hxx:80
LanguageType meUILang
Document language (import: from file, export: from system).
Definition: xlroot.hxx:87
SCTAB mnScTab
Width of space char ' ' using default font.
Definition: xlroot.hxx:108
ScExtDocOptRef mxExtDocOpt
Property set helper for chart filter.
Definition: xlroot.hxx:100
ScHeaderEERef mxHFEditEngine
Edit engine for rich strings etc.
Definition: xlroot.hxx:94
OUString maUserName
Base path of imported/exported file (path of maDocUrl).
Definition: xlroot.hxx:82
sal_Int16 mnDefApiScript
UI language (import: from file, export: from system).
Definition: xlroot.hxx:88
XclTracerRef mxTracer
Extended document options.
Definition: xlroot.hxx:101
std::shared_ptr< EditEngine > EditEngineRef
Definition: xlroot.hxx:68
ScDocument & mrDoc
The root OLE storage of imported/exported file.
Definition: xlroot.hxx:79
tools::Long mnSpaceWidth
Width of '0' in default font (twips).
Definition: xlroot.hxx:107
std::shared_ptr< XclTracer > XclTracerRef
Definition: xlroot.hxx:72
ScEEDefaulterRef mxEditEngine
Highest position valid in Calc and Excel.
Definition: xlroot.hxx:93
std::shared_ptr< XclChPropSetHelper > XclChPropSetHlpRef
Definition: xlroot.hxx:70
double mfScreenPixelY
Width of a screen pixel (1/100 mm).
Definition: xlroot.hxx:105
XclRootData(XclBiff eBiff, SfxMedium &rMedium, tools::SvRef< SotStorage > xRootStrg, ScDocument &rDoc, rtl_TextEncoding eTextEnc, bool bExport)
false = Import, true = Export.
Definition: xlroot.cxx:84
sal_Int16 SCTAB
Definition: types.hxx:22
const SCTAB SCTAB_GLOBAL
An invalid Calc sheet index, for common use.
Definition: xlconst.hxx:74
XclBiff
An enumeration for all Excel file format types (BIFF types).
Definition: xlconst.hxx:30
XclOutput
An enumeration for all Excel output format types.
Definition: xlconst.hxx:41