LibreOffice Module sc (master) 1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
oox::xls::UnitConverter Class Reference

Helper class that provides functions to convert values from and to different units. More...

#include <unitconverter.hxx>

Inheritance diagram for oox::xls::UnitConverter:
[legend]
Collaboration diagram for oox::xls::UnitConverter:
[legend]

Public Member Functions

 UnitConverter (const WorkbookHelper &rHelper)
 
void finalizeImport ()
 Final processing after import of all style settings. More...
 
void finalizeNullDate (const css::util::Date &rNullDate)
 Updates internal nulldate for date/serial conversion. More...
 
double scaleValue (double fValue, Unit eFromUnit, Unit eToUnit) const
 Converts the passed value between the passed units. More...
 
double calcSerialFromDateTime (const css::util::DateTime &rDateTime) const
 Returns the serial value of the passed datetime, based on current nulldate. More...
 
css::util::DateTime calcDateTimeFromSerial (double fSerial) const
 Returns the datetime of the passed serial value, based on current nulldate. More...
 
sal_uInt8 calcBiffErrorCode (const OUString &rErrorCode) const
 Returns a BIFF error code from the passed error string. More...
 
OUString calcErrorString (sal_uInt8 nErrorCode) const
 Returns an error string from the passed BIFF error code. More...
 
- Public Member Functions inherited from oox::xls::WorkbookHelper
 WorkbookHelper (WorkbookGlobals &rBookGlob)
 
virtual ~WorkbookHelper ()
 
 WorkbookHelper (WorkbookHelper const &)=default
 
 WorkbookHelper (WorkbookHelper &&)=default
 
WorkbookHelperoperator= (WorkbookHelper const &)=delete
 
WorkbookHelperoperator= (WorkbookHelper &&)=delete
 
::oox::core::FilterBasegetBaseFilter () const
 Returns the base filter object (base class of all filters). More...
 
SegmentProgressBargetProgressBar () const
 Returns the filter progress bar. More...
 
sal_Int16 getCurrentSheetIndex () const
 Returns the index of the current Calc sheet, if filter currently processes a sheet. More...
 
bool isGeneratorKnownGood () const
 Returns true when reading a file generated by a known good generator. More...
 
bool hasCalculatedFormulaCells () const
 Returns true if any formula cell is calculated. More...
 
void setCalculatedFormulaCells ()
 Set if any formula cell is calculated. More...
 
void setVbaProjectStorage (const StorageRef &rxVbaPrjStrg)
 Sets the VBA project storage used to import VBA source code and forms. More...
 
void setCurrentSheetIndex (SCTAB nSheet)
 Sets the index of the current Calc sheet, if filter currently processes a sheet. More...
 
void finalizeWorkbookImport ()
 Final conversion after importing the workbook. More...
 
void useInternalChartDataTable (bool bInternal)
 
ScDocumentgetScDocument ()
 
const ScDocumentgetScDocument () const
 
ScDocumentImportgetDocImport ()
 
const ScDocumentImportgetDocImport () const
 
ScEditEngineDefaultergetEditEngine () const
 
const css::uno::Reference< css::sheet::XSpreadsheetDocument > & getDocument () const
 Returns a reference to the source/target spreadsheet document model. More...
 
css::uno::Reference< css::sheet::XSpreadsheet > getSheetFromDoc (sal_Int32 nSheet) const
 Returns a reference to the specified spreadsheet in the document model. More...
 
css::uno::Reference< css::sheet::XSpreadsheet > getSheetFromDoc (const OUString &rSheet) const
 Returns a reference to the specified spreadsheet in the document model. More...
 
css::uno::Reference< css::table::XCellRange > getCellRangeFromDoc (const ScRange &rRange) const
 Returns the XCellRange interface for the passed cell range address. More...
 
css::uno::Reference< css::container::XNameContainer > getCellStyleFamily () const
 Returns the cell styles container from the Calc document. More...
 
css::uno::Reference< css::style::XStyle > getStyleObject (const OUString &rStyleName, bool bPageStyle) const
 Returns the specified cell or page style from the Calc document. More...
 
RangeDataRet createNamedRangeObject (OUString &orName, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden) const
 Creates and returns a defined name on-the-fly in the Calc document. More...
 
RangeDataRet createLocalNamedRangeObject (OUString &orName, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden) const
 Creates and returns a defined name on-the-fly in the sheet. More...
 
css::uno::Reference< css::sheet::XDatabaseRange > createDatabaseRangeObject (OUString &orName, const ScRange &rRangeAddr) const
 Creates and returns a database range on-the-fly in the Calc document. More...
 
css::uno::Reference< css::sheet::XDatabaseRange > createUnnamedDatabaseRangeObject (const ScRange &rRangeAddr) const
 Creates and returns an unnamed database range on-the-fly in the Calc document. More...
 
ScDBDatafindDatabaseRangeByIndex (sal_uInt16 nIndex) const
 Finds the (already existing) database range of the given formula token index. More...
 
css::uno::Reference< css::style::XStyle > createStyleObject (OUString &orStyleName, bool bPageStyle) const
 Creates and returns a com.sun.star.style.Style object for cells or pages. More...
 
FormulaBuffergetFormulaBuffer () const
 
WorkbookSettingsgetWorkbookSettings () const
 Returns the global workbook settings object. More...
 
ViewSettingsgetViewSettings () const
 Returns the workbook and sheet view settings object. More...
 
WorksheetBuffergetWorksheets () const
 Returns the worksheet buffer containing sheet names and properties. More...
 
ThemeBuffergetTheme () const
 Returns the office theme object read from the theme substorage. More...
 
StylesBuffergetStyles () const
 Returns all cell formatting objects read from the styles substream. More...
 
SharedStringsBuffergetSharedStrings () const
 Returns the shared strings read from the shared strings substream. More...
 
ExternalLinkBuffergetExternalLinks () const
 Returns the external links read from the external links substream. More...
 
DefinedNamesBuffergetDefinedNames () const
 Returns the defined names read from the workbook globals. More...
 
TableBuffergetTables () const
 Returns the tables collection (equivalent to Calc's database ranges). More...
 
ScenarioBuffergetScenarios () const
 Returns the scenarios collection. More...
 
ConnectionsBuffergetConnections () const
 Returns the collection of external data connections. More...
 
PivotCacheBuffergetPivotCaches () const
 Returns the collection of pivot caches. More...
 
PivotTableBuffergetPivotTables () const
 Returns the collection of pivot tables. More...
 
FormulaParsergetFormulaParser () const
 Returns a shared import formula parser (import filter only!). More...
 
FormulaParsercreateFormulaParser () const
 Returns an unshared import formula parser (import filter only!). More...
 
UnitConvertergetUnitConverter () const
 Returns the measurement unit converter. More...
 
AddressConvertergetAddressConverter () const
 Returns the converter for string to cell address/range conversion. More...
 
oox::drawingml::chart::ChartConvertergetChartConverter () const
 Returns the chart object converter. More...
 
PageSettingsConvertergetPageSettingsConverter () const
 Returns the page and print settings converter. More...
 
::oox::core::XmlFilterBasegetOoxFilter () const
 Returns the base OOXML/BIFF12 filter object. More...
 
bool importOoxFragment (const rtl::Reference< oox::core::FragmentHandler > &rxHandler)
 Imports a fragment using the passed fragment handler, which contains the full path to the fragment stream. More...
 
bool importOoxFragment (const rtl::Reference< oox::core::FragmentHandler > &rxHandler, oox::core::FastParser &rParser)
 
rtl_TextEncoding getTextEncoding () const
 Returns the text encoding used to import/export byte strings. More...
 

Private Member Functions

void addErrorCode (sal_uInt8 nErrorCode, const OUString &rErrorCode)
 Adds an error code to the internal maps. More...
 
double getCoefficient (Unit eUnit) const
 Returns the conversion coefficient for the passed unit. More...
 

Private Attributes

o3tl::enumarray< Unit, double > maCoeffs
 
std::map< OUString, sal_uInt8maOoxErrCodes
 Coefficients for unit conversion. More...
 
sal_Int32 mnNullDate
 Maps error code strings to BIFF error constants. More...
 

Additional Inherited Members

- Public Types inherited from oox::xls::WorkbookHelper
typedef std::pair< ScRangeData *, bool > RangeDataRet
 
- Static Public Member Functions inherited from oox::xls::WorkbookHelper
static WorkbookGlobalsRef constructGlobals (ExcelFilter &rFilter)
 

Detailed Description

Helper class that provides functions to convert values from and to different units.

Provides functions to calculate the width of certain characters of the default font of the imported/exported document. The default font is always the first font in the styles font list, and is always referenced by the default cell style ("Normal" style in Excel) which is used by all empty unformatted cells in the document. To be able to calculate the character width correctly, the default font must be known, which is the case after the finalizeImport() or finalizeExport() functions have been called. Caller must make sure to not call the character width conversion functions before.

Definition at line 57 of file unitconverter.hxx.

Constructor & Destructor Documentation

◆ UnitConverter()

oox::xls::UnitConverter::UnitConverter ( const WorkbookHelper rHelper)
explicit

Member Function Documentation

◆ addErrorCode()

void oox::xls::UnitConverter::addErrorCode ( sal_uInt8  nErrorCode,
const OUString &  rErrorCode 
)
private

Adds an error code to the internal maps.

Definition at line 216 of file unitconverter.cxx.

References maOoxErrCodes.

Referenced by UnitConverter().

◆ calcBiffErrorCode()

sal_uInt8 oox::xls::UnitConverter::calcBiffErrorCode ( const OUString &  rErrorCode) const

Returns a BIFF error code from the passed error string.

Definition at line 196 of file unitconverter.cxx.

References oox::xls::BIFF_ERR_NA, and maOoxErrCodes.

◆ calcDateTimeFromSerial()

util::DateTime oox::xls::UnitConverter::calcDateTimeFromSerial ( double  fSerial) const

Returns the datetime of the passed serial value, based on current nulldate.

Definition at line 164 of file unitconverter.cxx.

References mnNullDate.

Referenced by oox::xls::PivotCacheField::importPCDFRangePr().

◆ calcErrorString()

OUString oox::xls::UnitConverter::calcErrorString ( sal_uInt8  nErrorCode) const

Returns an error string from the passed BIFF error code.

Definition at line 202 of file unitconverter.cxx.

References oox::xls::BIFF_ERR_NA, and maOoxErrCodes.

Referenced by oox::xls::PivotCacheItem::readError().

◆ calcSerialFromDateTime()

double oox::xls::UnitConverter::calcSerialFromDateTime ( const css::util::DateTime &  rDateTime) const

Returns the serial value of the passed datetime, based on current nulldate.

Definition at line 156 of file unitconverter.cxx.

References mnNullDate.

Referenced by oox::xls::PivotCacheField::createDateGroupField(), oox::xls::SheetDataBuffer::setDateCell(), and oox::xls::SheetDataBuffer::setDateTimeCell().

◆ finalizeImport()

void oox::xls::UnitConverter::finalizeImport ( )

◆ finalizeNullDate()

void oox::xls::UnitConverter::finalizeNullDate ( const css::util::Date &  rNullDate)

Updates internal nulldate for date/serial conversion.

Definition at line 143 of file unitconverter.cxx.

References mnNullDate.

Referenced by oox::xls::WorkbookSettings::setDateMode().

◆ getCoefficient()

double oox::xls::UnitConverter::getCoefficient ( Unit  eUnit) const
private

Returns the conversion coefficient for the passed unit.

Definition at line 221 of file unitconverter.cxx.

References maCoeffs.

Referenced by scaleValue().

◆ scaleValue()

double oox::xls::UnitConverter::scaleValue ( double  fValue,
Unit  eFromUnit,
Unit  eToUnit 
) const

Converts the passed value between the passed units.

Definition at line 151 of file unitconverter.cxx.

References getCoefficient().

Referenced by oox::xls::ShapeAnchor::calcCellAnchorEmu(), oox::xls::Alignment::finalizeImport(), and oox::xls::WorksheetGlobals::setBaseColumnWidth().

Member Data Documentation

◆ maCoeffs

o3tl::enumarray<Unit, double> oox::xls::UnitConverter::maCoeffs
private

Definition at line 89 of file unitconverter.hxx.

Referenced by finalizeImport(), getCoefficient(), and UnitConverter().

◆ maOoxErrCodes

std::map<OUString, sal_uInt8> oox::xls::UnitConverter::maOoxErrCodes
private

Coefficients for unit conversion.

Definition at line 90 of file unitconverter.hxx.

Referenced by addErrorCode(), calcBiffErrorCode(), and calcErrorString().

◆ mnNullDate

sal_Int32 oox::xls::UnitConverter::mnNullDate
private

Maps error code strings to BIFF error constants.

Definition at line 91 of file unitconverter.hxx.

Referenced by calcDateTimeFromSerial(), calcSerialFromDateTime(), and finalizeNullDate().


The documentation for this class was generated from the following files: