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 
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;
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; }
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 
203  SfxObjectShell* GetDocShell() const;
205  ScModelObj* GetDocModelObj() const;
207  OutputDevice* GetPrinter() const;
211  ScRangeName& GetNamedRanges() 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 
231  EditEngine& GetDrawEditEngine() const;
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 
265 private:
267 };
268 
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XclFontPropSetHelper & GetFontPropSetHelper() const
Returns the property set helper for fonts.
Definition: xlroot.cxx:419
tools::Long mnSpaceWidth
Width of '0' in default font (twips).
Definition: xlroot.hxx:107
sal_Int32 mnObjCnt
Definition: xlroot.hxx:43
EditEngine & GetDrawEditEngine() const
Returns the edit engine for import/export of drawing text boxes.
Definition: xlroot.cxx:405
static OUString GetDefaultPassword()
Returns the default password used for stream encryption.
Definition: xlroot.hxx:179
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:29
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:312
This class wraps an MSFilterTracer to create trace logs for import/export filters.
Definition: xltracer.hxx:50
std::shared_ptr< XclTracer > XclTracerRef
Definition: xlroot.hxx:72
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
XclRootData(XclBiff eBiff, SfxMedium &rMedium, tools::SvRef< SotStorage > const &xRootStrg, ScDocument &rDoc, rtl_TextEncoding eTextEnc, bool bExport)
false = Import, true = Export.
Definition: xlroot.cxx:83
long Long
This struct helps reading and writing Excel fonts.
Definition: xlstyle.hxx:285
virtual ~XclRootData()
Definition: xlroot.cxx:163
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:76
sal_Int32 GetHmmFromPixelX(double fPixelX) const
Calculates the width of the passed number of pixels in 1/100 mm.
Definition: xlroot.cxx:239
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:286
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
Definition: xlroot.cxx:323
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:262
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
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:402
DateTime GetNullDate() const
Returns the null date of the current number formatter.
Definition: xlroot.cxx:328
XclChPropSetHelper & GetChartPropSetHelper() const
Returns the property set helper for the chart filters.
Definition: xlroot.cxx:424
std::shared_ptr< RootData > RootDataRef
Definition: xlroot.hxx:73
ScStyleSheetPool & GetStyleSheetPool() const
Returns the style sheet pool of the Calc document.
Definition: xlroot.cxx:307
const OUString & GetDocUrl() const
Returns the document URL of the imported/exported file.
Definition: xlroot.hxx:172
const OUString & GetUserName() const
Returns the current user name.
Definition: xlroot.hxx:176
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:88
const SCTAB SCTAB_GLOBAL
An invalid Calc sheet index, for common use.
Definition: xlconst.hxx:74
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:381
LanguageType GetSysLanguage() const
Returns the system language, i.e.
Definition: xlroot.hxx:149
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:143
const ScAddress & GetMaxPos() const
Returns the highest possible cell address valid in Calc and Excel (using current BIFF version)...
Definition: xlroot.hxx:248
DateTime GetDateTimeFromDouble(double fValue) const
Converts a floating-point value to a date/time value.
Definition: xlroot.cxx:353
ScExtDocOptions & GetExtDocOptions() const
Returns the extended document options.
Definition: xlroot.cxx:429
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:342
ScModelObj * GetDocModelObj() const
Returns the object model of the Calc document.
Definition: xlroot.cxx:296
rtl_TextEncoding meTextEnc
The default password used for stream encryption.
Definition: xlroot.hxx:84
tools::Long GetSpaceWidth() const
Definition: xlroot.hxx:158
bool HasVbaStorage() const
Returns true, if the document contains a VBA storage.
Definition: xlroot.cxx:256
sal_uInt16 GetBaseYear() const
Returns the base year depending on the current null date (1900 or 1904).
Definition: xlroot.cxx:333
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:253
void SetDocLanguage(LanguageType eLang)
Sets the document language.
Definition: xlroot.hxx:251
float u
sal_Int32 GetHmmFromPixelY(double fPixelY) const
Calculates the height of the passed number of pixels in 1/100 mm.
Definition: xlroot.cxx:244
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
Helper class for usage of property sets.
Definition: xlchart.hxx:1309
XclRoot(XclRootData &rRootData)
Definition: xlroot.cxx:167
SCTAB mnScTab
Width of space char ' ' using default font.
Definition: xlroot.hxx:108
void SetTextEncoding(rtl_TextEncoding eTextEnc)
Sets the text encoding to import/export byte strings.
Definition: xlroot.cxx:201
OutputDevice * GetPrinter() const
Returns pointer to the printer of the Calc document.
Definition: xlroot.cxx:302
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:155
XclTracer & GetTracer() const
Returns the filter tracer.
Definition: xlroot.cxx:434
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:162
void SetCurrScTab(SCTAB nScTab)
Sets the current Calc sheet index.
Definition: xlroot.hxx:261
SfxMedium & mrMedium
Current Output format.
Definition: xlroot.hxx:77
XclRootData & mrData
Definition: xlroot.hxx:266
ScEditEngineDefaulter & GetEditEngine() const
Returns the edit engine for import/export of rich strings etc.
Definition: xlroot.cxx:366
std::shared_ptr< EditEngine > EditEngineRef
Definition: xlroot.hxx:68
XclOutput
An enumeration for all Excel output format types.
Definition: xlconst.hxx:40
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:263
const ScAddress & GetXclMaxPos() const
Returns the highest possible cell address in an Excel document (using current BIFF version)...
Definition: xlroot.hxx:246
tools::Long mnCharWidth
Height of a screen pixel (1/100 mm).
Definition: xlroot.hxx:106
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: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:244
virtual ~XclRoot()
Definition: xlroot.cxx:186
XclOutput meOutput
Current BIFF version.
Definition: xlroot.hxx:76
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:174
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:291
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:274
bool IsInGlobals() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:160
XclRoot & operator=(const XclRoot &rRoot)
Definition: xlroot.cxx:193
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:75
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: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:170
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:317
sal_Int16 SCTAB
Definition: types.hxx:22
double mfScreenPixelX
Old RootData struct. Will be removed.
Definition: xlroot.hxx:104
ScExtDocOptRef mxExtDocOpt
Property set helper for chart filter.
Definition: xlroot.hxx:100