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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XLROOT_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XLROOT_HXX
22 
23 #include <i18nlangtag/lang.h>
24 #include <tools/ref.hxx>
25 #include <tools/long.hxx>
26 #include "xlconst.hxx"
27 #include <memory>
28 
29 namespace com::sun::star::beans { struct NamedValue; }
30 namespace comphelper { class IDocPasswordVerifier; }
31 
32 // Forward declarations of objects in public use ==============================
33 
34 class DateTime;
35 class SotStorage;
36 class SotStorageStream;
37 
38 // Global data ================================================================
39 
40 #ifdef DBG_UTIL
41 
43 {
44  sal_Int32 mnObjCnt;
45  explicit XclDebugObjCounter() : mnObjCnt( 0 ) {}
47 };
48 #endif
49 
50 class SfxMedium;
52 class ScHeaderEditEngine;
53 class EditEngine;
54 class ScExtDocOptions;
56 class XclChPropSetHelper;
57 class XclTracer;
58 
59 struct RootData;
60 
63 #ifdef DBG_UTIL
64  : public XclDebugObjCounter
65 #endif
66 {
67  typedef std::shared_ptr< ScEditEngineDefaulter > ScEEDefaulterRef;
68  typedef std::shared_ptr< ScHeaderEditEngine > ScHeaderEERef;
69  typedef std::shared_ptr< EditEngine > EditEngineRef;
70  typedef std::shared_ptr< XclFontPropSetHelper > XclFontPropSetHlpRef;
71  typedef std::shared_ptr< XclChPropSetHelper > XclChPropSetHlpRef;
72  typedef std::shared_ptr< ScExtDocOptions > ScExtDocOptRef;
73  typedef std::shared_ptr< XclTracer > XclTracerRef;
74  typedef std::shared_ptr< RootData > RootDataRef;
75 
81  OUString maDocUrl;
82  OUString maBasePath;
83  OUString maUserName;
84  static constexpr OUStringLiteral gaDefPassword = u"VelvetSweatshop";
85  rtl_TextEncoding meTextEnc;
89  sal_Int16 mnDefApiScript;
93 
94  ScEEDefaulterRef mxEditEngine;
95  ScHeaderEERef mxHFEditEngine;
96  EditEngineRef mxDrawEditEng;
97 
98  XclFontPropSetHlpRef mxFontPropSetHlp;
99  XclChPropSetHlpRef mxChPropSetHlp;
100 
101  ScExtDocOptRef mxExtDocOpt;
102  XclTracerRef mxTracer;
103  RootDataRef mxRD;
104 
105  double mfScreenPixelX;
106  double mfScreenPixelY;
109  const bool mbExport;
110 
111  explicit XclRootData( XclBiff eBiff, SfxMedium& rMedium,
112  tools::SvRef<SotStorage> const & xRootStrg, ScDocument& rDoc,
113  rtl_TextEncoding eTextEnc, bool bExport );
114  virtual ~XclRootData();
115 };
116 
117 class SfxObjectShell;
118 class ScModelObj;
119 class OutputDevice;
120 class SvNumberFormatter;
121 class SdrPage;
122 class ScStyleSheetPool;
123 class ScRangeName;
124 struct XclFontData;
125 
127 class XclRoot
128 {
129 public:
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; }
159  bool IsInGlobals() const { return mrData.mnScTab == SCTAB_GLOBAL; }
161  SCTAB GetCurrScTab() const { return mrData.mnScTab; }
162 
164  sal_Int32 GetHmmFromPixelX( double fPixelX ) const;
166  sal_Int32 GetHmmFromPixelY( double fPixelY ) const;
167 
169  SfxMedium& GetMedium() const { return mrData.mrMedium; }
171  const OUString& GetDocUrl() const { return mrData.maDocUrl; }
173  const OUString& GetBasePath() const { return mrData.maBasePath; }
175  const OUString& GetUserName() const { return mrData.maUserName; }
176 
178  static OUString GetDefaultPassword() { return XclRootData::gaDefPassword; }
180  css::uno::Sequence< css::beans::NamedValue >
182 
187  bool HasVbaStorage() const;
188 
190  tools::SvRef<SotStorage> OpenStorage( tools::SvRef<SotStorage> const & xStrg, const OUString& rStrgName ) const;
192  tools::SvRef<SotStorage> OpenStorage( const OUString& rStrgName ) const;
194  tools::SvRef<SotStorageStream> OpenStream( tools::SvRef<SotStorage> const & xStrg, const OUString& rStrmName ) const;
196  tools::SvRef<SotStorageStream> OpenStream( const OUString& rStrmName ) const;
197 
199  ScDocument& GetDoc() const;
200 
202  SfxObjectShell* GetDocShell() const;
204  ScModelObj* GetDocModelObj() const;
206  OutputDevice* GetPrinter() const;
210  ScRangeName& GetNamedRanges() const;
212  SdrPage* GetSdrPage( SCTAB nScTab ) const;
213 
217  DateTime GetNullDate() const;
219  sal_uInt16 GetBaseYear() const;
221  double GetDoubleFromDateTime( const DateTime& rDateTime ) const;
223  DateTime GetDateTimeFromDouble( double fValue ) const;
224 
230  EditEngine& GetDrawEditEngine() const;
231 
236 
240  XclTracer& GetTracer() const;
241 
243  const ScAddress& GetScMaxPos() const { return mrData.maScMaxPos; }
245  const ScAddress& GetXclMaxPos() const { return mrData.maXclMaxPos; }
247  const ScAddress& GetMaxPos() const { return mrData.maMaxPos; }
248 
250  void SetDocLanguage( LanguageType eLang ) { mrData.meDocLang = eLang; }
252  void SetUILanguage( LanguageType eLang ) { mrData.meUILang = eLang; }
254  void SetTextEncoding( rtl_TextEncoding eTextEnc );
257  void SetCharWidth( const XclFontData& rFontData );
259  void SetCurrScTab( SCTAB nScTab ) { mrData.mnScTab = nScTab; }
262 
263 private:
265 };
266 
267 #endif
268 
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XclFontPropSetHelper & GetFontPropSetHelper() const
Returns the property set helper for fonts.
Definition: xlroot.cxx:409
sal_Int32 mnObjCnt
Definition: xlroot.hxx:44
EditEngine & GetDrawEditEngine() const
Returns the edit engine for import/export of drawing text boxes.
Definition: xlroot.cxx:395
static OUString GetDefaultPassword()
Returns the default password used for stream encryption.
Definition: xlroot.hxx:178
rtl_TextEncoding GetTextEncoding() const
Returns the text encoding to import/export byte strings.
Definition: xlroot.hxx:147
XclBiff
An enumeration for all Excel file format types (BIFF types).
Definition: xlconst.hxx:30
const bool mbExport
Current Calc sheet index.
Definition: xlroot.hxx:109
LanguageType GetDocLanguage() const
Returns the document language.
Definition: xlroot.hxx:151
ScRangeName & GetNamedRanges() const
Returns the defined names container of the Calc document.
Definition: xlroot.cxx:302
This class wraps an MSFilterTracer to create trace logs for import/export filters.
Definition: xltracer.hxx:51
std::shared_ptr< XclTracer > XclTracerRef
Definition: xlroot.hxx:73
void SetCharWidth(const XclFontData &rFontData)
Sets the width of the '0' character (default font) for the current printer (twips).
Definition: xlroot.cxx:205
XclRootData(XclBiff eBiff, SfxMedium &rMedium, tools::SvRef< SotStorage > const &xRootStrg, ScDocument &rDoc, rtl_TextEncoding eTextEnc, bool bExport)
false = Import, true = Export.
Definition: xlroot.cxx:82
long Long
This struct helps reading and writing Excel fonts.
Definition: xlstyle.hxx:286
virtual ~XclRootData()
Definition: xlroot.cxx:161
XclFontPropSetHlpRef mxFontPropSetHlp
Edit engine for text boxes.
Definition: xlroot.hxx:98
OUString maDocUrl
The source or destination document.
Definition: xlroot.hxx:81
Stores global buffers and data needed elsewhere in the Excel filters.
Definition: xlroot.hxx:62
std::shared_ptr< ScEditEngineDefaulter > ScEEDefaulterRef
Definition: xlroot.hxx:67
LanguageType meUILang
Document language (import: from file, export: from system).
Definition: xlroot.hxx:88
Extended options held by an ScDocument containing additional settings for filters.
Definition: scextopt.hxx:77
sal_Int32 GetHmmFromPixelX(double fPixelX) const
Calculates the width of the passed number of pixels in 1/100 mm.
Definition: xlroot.cxx:229
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:276
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
Definition: xlroot.cxx:313
RootData & GetOldRoot() const
Returns old RootData struct.
Definition: xlroot.hxx:138
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:252
ScHeaderEERef mxHFEditEngine
Edit engine for rich strings etc.
Definition: xlroot.hxx:95
std::shared_ptr< XclFontPropSetHelper > XclFontPropSetHlpRef
Definition: xlroot.hxx:70
LanguageType meSysLang
Text encoding to import/export byte strings.
Definition: xlroot.hxx:86
XclChPropSetHlpRef mxChPropSetHlp
Property set helper for fonts.
Definition: xlroot.hxx:99
Counts the number of created root objects.
Definition: xlroot.hxx:42
Helper class for usage of property sets.
Definition: xlstyle.hxx:403
DateTime GetNullDate() const
Returns the null date of the current number formatter.
Definition: xlroot.cxx:318
XclChPropSetHelper & GetChartPropSetHelper() const
Returns the property set helper for the chart filters.
Definition: xlroot.cxx:414
std::shared_ptr< RootData > RootDataRef
Definition: xlroot.hxx:74
ScStyleSheetPool & GetStyleSheetPool() const
Returns the style sheet pool of the Calc document.
Definition: xlroot.cxx:297
const OUString & GetDocUrl() const
Returns the document URL of the imported/exported file.
Definition: xlroot.hxx:171
const OUString & GetUserName() const
Returns the current user name.
Definition: xlroot.hxx:175
LanguageType GetUILanguage() const
Returns the UI language.
Definition: xlroot.hxx:153
sal_Int16 mnDefApiScript
UI language (import: from file, export: from system).
Definition: xlroot.hxx:89
const SCTAB SCTAB_GLOBAL
An invalid Calc sheet index, for common use.
Definition: xlconst.hxx:75
const tools::SvRef< SotStorage > & GetRootStorage() const
Returns the OLE2 root storage of the imported/exported file.
Definition: xlroot.hxx:185
ScHeaderEditEngine & GetHFEditEngine() const
Returns the edit engine for import/export of headers/footers.
Definition: xlroot.cxx:371
LanguageType GetSysLanguage() const
Returns the system language, i.e.
Definition: xlroot.hxx:149
ScAddress maXclMaxPos
Highest Calc cell position.
Definition: xlroot.hxx:91
XclOutput GetOutput() const
Returns the current output format of the importer/exporter.
Definition: xlroot.hxx:143
const ScAddress & GetMaxPos() const
Returns the highest possible cell address valid in Calc and Excel (using current BIFF version)...
Definition: xlroot.hxx:247
DateTime GetDateTimeFromDouble(double fValue) const
Converts a floating-point value to a date/time value.
Definition: xlroot.cxx:343
ScExtDocOptions & GetExtDocOptions() const
Returns the extended document options.
Definition: xlroot.cxx:419
ScDocument & mrDoc
The root OLE storage of imported/exported file.
Definition: xlroot.hxx:80
RootDataRef mxRD
Filter tracer.
Definition: xlroot.hxx:103
double GetDoubleFromDateTime(const DateTime &rDateTime) const
Converts a date/time value to a floating-point value.
Definition: xlroot.cxx:332
ScModelObj * GetDocModelObj() const
Returns the object model of the Calc document.
Definition: xlroot.cxx:286
rtl_TextEncoding meTextEnc
The default password used for stream encryption.
Definition: xlroot.hxx:85
bool HasVbaStorage() const
Returns true, if the document contains a VBA storage.
Definition: xlroot.cxx:246
sal_uInt16 GetBaseYear() const
Returns the base year depending on the current null date (1900 or 1904).
Definition: xlroot.cxx:323
double mfScreenPixelY
Width of a screen pixel (1/100 mm).
Definition: xlroot.hxx:106
void SetUILanguage(LanguageType eLang)
Sets the UI language, i.e.
Definition: xlroot.hxx:252
void SetDocLanguage(LanguageType eLang)
Sets the document language.
Definition: xlroot.hxx:250
float u
sal_Int32 GetHmmFromPixelY(double fPixelY) const
Calculates the height of the passed number of pixels in 1/100 mm.
Definition: xlroot.cxx:234
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:239
Helper class for usage of property sets.
Definition: xlchart.hxx:1310
XclRoot(XclRootData &rRootData)
Definition: xlroot.cxx:165
SCTAB mnScTab
Width of '0' in default font (twips).
Definition: xlroot.hxx:108
void SetTextEncoding(rtl_TextEncoding eTextEnc)
Sets the text encoding to import/export byte strings.
Definition: xlroot.cxx:199
OutputDevice * GetPrinter() const
Returns pointer to the printer of the Calc document.
Definition: xlroot.cxx:292
XclTracerRef mxTracer
Extended document options.
Definition: xlroot.hxx:102
std::shared_ptr< ScHeaderEditEngine > ScHeaderEERef
Definition: xlroot.hxx:68
sal_Int16 GetDefApiScript() const
Returns the default script type, e.g.
Definition: xlroot.hxx:155
XclTracer & GetTracer() const
Returns the filter tracer.
Definition: xlroot.cxx:424
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:161
void SetCurrScTab(SCTAB nScTab)
Sets the current Calc sheet index.
Definition: xlroot.hxx:259
SfxMedium & mrMedium
Current Output format.
Definition: xlroot.hxx:78
XclRootData & mrData
Definition: xlroot.hxx:264
ScEditEngineDefaulter & GetEditEngine() const
Returns the edit engine for import/export of rich strings etc.
Definition: xlroot.cxx:356
std::shared_ptr< EditEngine > EditEngineRef
Definition: xlroot.hxx:69
XclOutput
An enumeration for all Excel output format types.
Definition: xlconst.hxx:41
ScEEDefaulterRef mxEditEngine
Highest position valid in Calc and Excel.
Definition: xlroot.hxx:94
void IncCurrScTab()
Increases the current Calc sheet index by 1.
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:245
tools::Long mnCharWidth
Height of a screen pixel (1/100 mm).
Definition: xlroot.hxx:107
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
Definition: xlroot.hxx:141
ScAddress maMaxPos
Highest Excel cell position.
Definition: xlroot.hxx:92
std::shared_ptr< XclChPropSetHelper > XclChPropSetHlpRef
Definition: xlroot.hxx:71
LanguageType meDocLang
System language.
Definition: xlroot.hxx:87
const ScAddress & GetScMaxPos() const
Returns the highest possible cell address in a Calc document.
Definition: xlroot.hxx:243
virtual ~XclRoot()
Definition: xlroot.cxx:184
XclOutput meOutput
Current BIFF version.
Definition: xlroot.hxx:77
bool IsImport() const
Returns true, if currently a document is imported.
Definition: xlroot.hxx:145
const OUString & GetBasePath() const
Returns the base path of the imported/exported file.
Definition: xlroot.hxx:173
OUString maBasePath
Document URL of imported/exported file.
Definition: xlroot.hxx:82
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
Definition: xlroot.cxx:281
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:264
bool IsInGlobals() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:159
XclRoot & operator=(const XclRoot &rRoot)
Definition: xlroot.cxx:191
tools::Long GetCharWidth() const
Returns the width of the '0' character (default font) for the current printer (twips).
Definition: xlroot.hxx:157
XclBiff meBiff
Definition: xlroot.hxx:76
Access to global data for a filter object (imported or exported document) from other classes...
Definition: xlroot.hxx:127
tools::SvRef< SotStorage > mxRootStrg
The medium to import from.
Definition: xlroot.hxx:79
EditEngineRef mxDrawEditEng
Edit engine for header/footer.
Definition: xlroot.hxx:96
static constexpr OUStringLiteral gaDefPassword
Current user name.
Definition: xlroot.hxx:84
ScAddress maScMaxPos
Default script type for blank cells (API constant).
Definition: xlroot.hxx:90
SfxMedium & GetMedium() const
Returns the medium to import from.
Definition: xlroot.hxx:169
std::shared_ptr< ScExtDocOptions > ScExtDocOptRef
Definition: xlroot.hxx:72
OUString maUserName
Base path of imported/exported file (path of maDocUrl).
Definition: xlroot.hxx:83
SdrPage * GetSdrPage(SCTAB nScTab) const
Returns the drawing layer page of the passed sheet, if present.
Definition: xlroot.cxx:307
sal_Int16 SCTAB
Definition: types.hxx:23
double mfScreenPixelX
Old RootData struct. Will be removed.
Definition: xlroot.hxx:105
ScExtDocOptRef mxExtDocOpt
Property set helper for chart filter.
Definition: xlroot.hxx:101