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 "xlconst.hxx"
26 #include <memory>
27 
28 namespace com::sun::star::beans { struct NamedValue; }
29 namespace comphelper { class IDocPasswordVerifier; }
30 
31 // Forward declarations of objects in public use ==============================
32 
33 class DateTime;
34 class SotStorage;
35 class SotStorageStream;
36 
37 // Global data ================================================================
38 
39 #ifdef DBG_UTIL
40 
42 {
43  sal_Int32 mnObjCnt;
44  explicit XclDebugObjCounter() : mnObjCnt( 0 ) {}
46 };
47 #endif
48 
49 class SfxMedium;
51 class ScHeaderEditEngine;
52 class EditEngine;
53 class ScExtDocOptions;
55 class XclChPropSetHelper;
56 class XclTracer;
57 
58 struct 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 
93  ScEEDefaulterRef mxEditEngine;
94  ScHeaderEERef mxHFEditEngine;
95  EditEngineRef mxDrawEditEng;
96 
97  XclFontPropSetHlpRef mxFontPropSetHlp;
98  XclChPropSetHlpRef mxChPropSetHlp;
99 
100  ScExtDocOptRef mxExtDocOpt;
101  XclTracerRef mxTracer;
102  RootDataRef mxRD;
103 
104  double mfScreenPixelX;
105  double mfScreenPixelY;
106  long mnCharWidth;
108  const bool mbExport;
109 
110  explicit XclRootData( XclBiff eBiff, SfxMedium& rMedium,
111  tools::SvRef<SotStorage> const & xRootStrg, ScDocument& rDoc,
112  rtl_TextEncoding eTextEnc, bool bExport );
113  virtual ~XclRootData();
114 };
115 
116 class SfxObjectShell;
117 class ScModelObj;
118 class OutputDevice;
119 class SvNumberFormatter;
120 class SdrPage;
121 class ScStyleSheetPool;
122 class ScRangeName;
123 struct XclFontData;
124 
126 class XclRoot
127 {
128 public:
129  explicit XclRoot( XclRootData& rRootData );
130  XclRoot( const XclRoot& rRoot );
131 
132  virtual ~XclRoot();
133 
134  XclRoot& operator=( const XclRoot& rRoot );
135 
137  RootData& GetOldRoot() const { return *mrData.mxRD; }
138 
140  XclBiff GetBiff() const { return mrData.meBiff; }
142  XclOutput GetOutput() const { return mrData.meOutput; }
144  bool IsImport() const { return !mrData.mbExport; }
146  rtl_TextEncoding GetTextEncoding() const { return mrData.meTextEnc; }
154  sal_Int16 GetDefApiScript() const { return mrData.mnDefApiScript; }
156  long GetCharWidth() const { return mrData.mnCharWidth; }
158  bool IsInGlobals() const { return mrData.mnScTab == SCTAB_GLOBAL; }
160  SCTAB GetCurrScTab() const { return mrData.mnScTab; }
161 
163  sal_Int32 GetHmmFromPixelX( double fPixelX ) const;
165  sal_Int32 GetHmmFromPixelY( double fPixelY ) const;
166 
168  SfxMedium& GetMedium() const { return mrData.mrMedium; }
170  const OUString& GetDocUrl() const { return mrData.maDocUrl; }
172  const OUString& GetBasePath() const { return mrData.maBasePath; }
174  const OUString& GetUserName() const { return mrData.maUserName; }
175 
177  static OUString GetDefaultPassword() { return XclRootData::gaDefPassword; }
179  css::uno::Sequence< css::beans::NamedValue >
181 
186  bool HasVbaStorage() const;
187 
189  tools::SvRef<SotStorage> OpenStorage( tools::SvRef<SotStorage> const & xStrg, const OUString& rStrgName ) const;
191  tools::SvRef<SotStorage> OpenStorage( const OUString& rStrgName ) const;
193  tools::SvRef<SotStorageStream> OpenStream( tools::SvRef<SotStorage> const & xStrg, const OUString& rStrmName ) const;
195  tools::SvRef<SotStorageStream> OpenStream( const OUString& rStrmName ) const;
196 
198  ScDocument& GetDoc() const;
199 
201  SfxObjectShell* GetDocShell() const;
203  ScModelObj* GetDocModelObj() const;
205  OutputDevice* GetPrinter() const;
209  ScRangeName& GetNamedRanges() const;
211  SdrPage* GetSdrPage( SCTAB nScTab ) const;
212 
216  DateTime GetNullDate() const;
218  sal_uInt16 GetBaseYear() const;
220  double GetDoubleFromDateTime( const DateTime& rDateTime ) const;
222  DateTime GetDateTimeFromDouble( double fValue ) const;
223 
229  EditEngine& GetDrawEditEngine() const;
230 
235 
239  XclTracer& GetTracer() const;
240 
242  const ScAddress& GetScMaxPos() const { return mrData.maScMaxPos; }
244  const ScAddress& GetXclMaxPos() const { return mrData.maXclMaxPos; }
246  const ScAddress& GetMaxPos() const { return mrData.maMaxPos; }
247 
249  void SetDocLanguage( LanguageType eLang ) { mrData.meDocLang = eLang; }
251  void SetUILanguage( LanguageType eLang ) { mrData.meUILang = eLang; }
253  void SetTextEncoding( rtl_TextEncoding eTextEnc );
256  void SetCharWidth( const XclFontData& rFontData );
258  void SetCurrScTab( SCTAB nScTab ) { mrData.mnScTab = nScTab; }
261 
262 private:
264 };
265 
266 #endif
267 
268 /* 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:43
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:177
rtl_TextEncoding GetTextEncoding() const
Returns the text encoding to import/export byte strings.
Definition: xlroot.hxx:146
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:108
LanguageType GetDocLanguage() const
Returns the document language.
Definition: xlroot.hxx:150
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:72
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
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:97
OUString maDocUrl
The source or destination document.
Definition: xlroot.hxx:80
Stores global buffers and data needed elsewhere in the Excel filters.
Definition: xlroot.hxx:61
std::shared_ptr< ScEditEngineDefaulter > ScEEDefaulterRef
Definition: xlroot.hxx:66
LanguageType meUILang
Document language (import: from file, export: from system).
Definition: xlroot.hxx:87
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:137
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:94
std::shared_ptr< XclFontPropSetHelper > XclFontPropSetHlpRef
Definition: xlroot.hxx:69
LanguageType meSysLang
Text encoding to import/export byte strings.
Definition: xlroot.hxx:85
long mnCharWidth
Height of a screen pixel (1/100 mm).
Definition: xlroot.hxx:106
XclChPropSetHlpRef mxChPropSetHlp
Property set helper for fonts.
Definition: xlroot.hxx:98
Counts the number of created root objects.
Definition: xlroot.hxx:41
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:73
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:170
const OUString & GetUserName() const
Returns the current user name.
Definition: xlroot.hxx:174
LanguageType GetUILanguage() const
Returns the UI language.
Definition: xlroot.hxx:152
sal_Int16 mnDefApiScript
UI language (import: from file, export: from system).
Definition: xlroot.hxx:88
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:184
long GetCharWidth() const
Returns the width of the '0' character (default font) for the current printer (twips).
Definition: xlroot.hxx:156
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:148
ScAddress maXclMaxPos
Highest Calc cell position.
Definition: xlroot.hxx:90
XclOutput GetOutput() const
Returns the current output format of the importer/exporter.
Definition: xlroot.hxx:142
const ScAddress & GetMaxPos() const
Returns the highest possible cell address valid in Calc and Excel (using current BIFF version)...
Definition: xlroot.hxx:246
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:79
RootDataRef mxRD
Filter tracer.
Definition: xlroot.hxx:102
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:84
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:105
void SetUILanguage(LanguageType eLang)
Sets the UI language, i.e.
Definition: xlroot.hxx:251
void SetDocLanguage(LanguageType eLang)
Sets the document language.
Definition: xlroot.hxx:249
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:107
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:101
std::shared_ptr< ScHeaderEditEngine > ScHeaderEERef
Definition: xlroot.hxx:67
sal_Int16 GetDefApiScript() const
Returns the default script type, e.g.
Definition: xlroot.hxx:154
XclTracer & GetTracer() const
Returns the filter tracer.
Definition: xlroot.cxx:424
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:160
void SetCurrScTab(SCTAB nScTab)
Sets the current Calc sheet index.
Definition: xlroot.hxx:258
SfxMedium & mrMedium
Current Output format.
Definition: xlroot.hxx:77
XclRootData & mrData
Definition: xlroot.hxx:263
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:68
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:93
void IncCurrScTab()
Increases the current Calc sheet index by 1.
Definition: xlroot.hxx:260
const ScAddress & GetXclMaxPos() const
Returns the highest possible cell address in an Excel document (using current BIFF version)...
Definition: xlroot.hxx:244
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
Definition: xlroot.hxx:140
ScAddress maMaxPos
Highest Excel cell position.
Definition: xlroot.hxx:91
std::shared_ptr< XclChPropSetHelper > XclChPropSetHlpRef
Definition: xlroot.hxx:70
LanguageType meDocLang
System language.
Definition: xlroot.hxx:86
const ScAddress & GetScMaxPos() const
Returns the highest possible cell address in a Calc document.
Definition: xlroot.hxx:242
virtual ~XclRoot()
Definition: xlroot.cxx:184
XclOutput meOutput
Current BIFF version.
Definition: xlroot.hxx:76
bool IsImport() const
Returns true, if currently a document is imported.
Definition: xlroot.hxx:144
const OUString & GetBasePath() const
Returns the base path of the imported/exported file.
Definition: xlroot.hxx:172
OUString maBasePath
Document URL of imported/exported file.
Definition: xlroot.hxx:81
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:158
XclRoot & operator=(const XclRoot &rRoot)
Definition: xlroot.cxx:191
XclBiff meBiff
Definition: xlroot.hxx:75
Access to global data for a filter object (imported or exported document) from other classes...
Definition: xlroot.hxx:126
tools::SvRef< SotStorage > mxRootStrg
The medium to import from.
Definition: xlroot.hxx:78
EditEngineRef mxDrawEditEng
Edit engine for header/footer.
Definition: xlroot.hxx:95
static constexpr OUStringLiteral gaDefPassword
Current user name.
Definition: xlroot.hxx:83
ScAddress maScMaxPos
Default script type for blank cells (API constant).
Definition: xlroot.hxx:89
SfxMedium & GetMedium() const
Returns the medium to import from.
Definition: xlroot.hxx:168
std::shared_ptr< ScExtDocOptions > ScExtDocOptRef
Definition: xlroot.hxx:71
OUString maUserName
Base path of imported/exported file (path of maDocUrl).
Definition: xlroot.hxx:82
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:104
ScExtDocOptRef mxExtDocOpt
Property set helper for chart filter.
Definition: xlroot.hxx:100