LibreOffice Module sc (master)  1
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
XclTools Class Reference

This class contains static helper methods for the Excel import and export filters. More...

#include <xltools.hxx>

Collaboration diagram for XclTools:
[legend]

Public Member Functions

 XclTools (const XclTools &)=delete
 
const XclToolsoperator= (const XclTools &)=delete
 
 XclTools ()=delete
 We don't want anybody to instantiate this class, since it is just a collection of static items. More...
 

Static Public Member Functions

static double GetDoubleFromRK (sal_Int32 nRKValue)
 GUID of file moniker (HLINK record). More...
 
static bool GetRKFromDouble (sal_Int32 &rnRKValue, double fValue)
 Calculates an RK value (encoded integer or double) from a double value. More...
 
static sal_Int32 GetScRotation (sal_uInt16 nXclRot, sal_Int32 nRotForStacked)
 Calculates an angle (in 1/100 of degrees) from an Excel angle value. More...
 
static sal_uInt8 GetXclRotation (sal_Int32 nScRot)
 Calculates the Excel angle value from an angle in 1/100 of degrees. More...
 
static sal_uInt8 GetXclRotFromOrient (sal_uInt8 nXclOrient)
 Calculates BIFF8 rotation angle from BIFF2-BIFF5 text orientation. More...
 
static sal_uInt8 GetXclOrientFromRot (sal_uInt16 nXclRot)
 Calculates BIFF2-BIFF5 text orientation from BIFF8 rotation angle. More...
 
static sal_uInt8 GetXclErrorCode (FormulaError nScError)
 Converts a Calc error code to an Excel error code. More...
 
static FormulaError GetScErrorCode (sal_uInt8 nXclError)
 Converts an Excel error code to a Calc error code. More...
 
static double ErrorToDouble (sal_uInt8 nXclError)
 Converts the passed BIFF error to a double containing the respective Calc error code. More...
 
static XclBoolError ErrorToEnum (double &rfDblValue, bool bErrOrBool, sal_uInt8 nValue)
 Gets a translated error code or Boolean value from Excel error codes. More...
 
static sal_uInt16 GetTwipsFromInch (double fInches)
 Returns the length in twips calculated from a length in inches. More...
 
static sal_uInt16 GetTwipsFromHmm (sal_Int32 nHmm)
 Returns the length in twips calculated from a length in 1/100 mm. More...
 
static double GetInchFromTwips (sal_Int32 nTwips)
 Returns the length in inches calculated from a length in twips. More...
 
static double GetInchFromHmm (sal_Int32 nHmm)
 Returns the length in inches calculated from a length in 1/100 mm. More...
 
static sal_Int32 GetHmmFromInch (double fInches)
 Returns the length in 1/100 mm calculated from a length in inches. More...
 
static sal_Int32 GetHmmFromTwips (sal_Int32 nTwips)
 Returns the length in 1/100 mm calculated from a length in twips. More...
 
static sal_uInt16 GetScColumnWidth (sal_uInt16 nXclWidth, long nScCharWidth)
 Returns the Calc column width (twips) for the passed Excel width. More...
 
static sal_uInt16 GetXclColumnWidth (sal_uInt16 nScWidth, long nScCharWidth)
 Returns the Excel column width for the passed Calc width (twips). More...
 
static double GetXclDefColWidthCorrection (long nXclDefFontHeight)
 Returns a correction value to convert column widths from/to default column widths. More...
 
static Color GetPatternColor (const Color &rPattColor, const Color &rBackColor, sal_uInt16 nXclPattern)
 Returns the best fitting color for an Excel pattern area format. More...
 
static rtl_TextEncoding GetTextEncoding (sal_uInt16 nCodePage)
 Returns a text encoding from an Excel code page. More...
 
static sal_uInt16 GetXclCodePage (rtl_TextEncoding eTextEnc)
 Returns an Excel code page from a text encoding. More...
 
static OUString GetXclFontName (const OUString &rFontName)
 Returns the matching Excel font name for a passed Calc font name. More...
 
static OUString GetXclBuiltInDefName (sal_Unicode cBuiltIn)
 Returns the raw English UI representation of a built-in defined name used in NAME records. More...
 
static OUString GetBuiltInDefName (sal_Unicode cBuiltIn)
 Returns the Calc UI representation of a built-in defined name used in NAME records. More...
 
static OUString GetBuiltInDefNameXml (sal_Unicode cBuiltIn)
 Returns the Excel built-in name with OOXML prefix Adds the "_xlnm." prefix to the representation returned by GetXclBuiltInDefName() More...
 
static sal_Unicode GetBuiltInDefNameIndex (const OUString &rDefName)
 Returns the Excel built-in name index of the passed defined name from Calc. More...
 
static OUString GetBuiltInStyleName (sal_uInt8 nStyleId, const OUString &rName, sal_uInt8 nLevel)
 Returns the specified built-in cell style name. More...
 
static bool IsBuiltInStyleName (const OUString &rStyleName, sal_uInt8 *pnStyleId=nullptr, sal_Int32 *pnNextChar=nullptr)
 Returns true, if the passed string is a name of an Excel built-in style. More...
 
static bool GetBuiltInStyleId (sal_uInt8 &rnStyleId, sal_uInt8 &rnLevel, const OUString &rStyleName)
 Returns the Excel built-in style identifier of a passed style name. More...
 
static OUString GetCondFormatStyleName (SCTAB nScTab, sal_Int32 nFormat, sal_uInt16 nCondition)
 Returns the style name for a single condition of a conditional formatting. More...
 
static bool IsCondFormatStyleName (const OUString &rStyleName)
 Returns true, if the passed string is a name of a conditional format style created by Excel import. More...
 
static void SkipSubStream (XclImpStream &rStrm)
 Skips a substream (BOF/EOF record block). More...
 
static OUString GetSbMacroUrl (const OUString &rMacroName, SfxObjectShell *pDocShell)
 Returns the full StarBasic macro URL from an Excel macro name. More...
 
static OUString GetXclMacroName (const OUString &rSbMacroUrl)
 Returns the Excel macro name from a full StarBasic macro URL. More...
 

Static Public Attributes

static const XclGuid maGuidStdLink
 
static const XclGuid maGuidUrlMoniker
 GUID of StdLink (HLINK record). More...
 
static const XclGuid maGuidFileMoniker
 GUID of URL moniker (HLINK record). More...
 

Detailed Description

This class contains static helper methods for the Excel import and export filters.

Definition at line 79 of file xltools.hxx.

Constructor & Destructor Documentation

XclTools::XclTools ( const XclTools )
delete
XclTools::XclTools ( )
delete

We don't want anybody to instantiate this class, since it is just a collection of static items.

Member Function Documentation

double XclTools::ErrorToDouble ( sal_uInt8  nXclError)
static

Converts the passed BIFF error to a double containing the respective Calc error code.

Definition at line 241 of file xltools.cxx.

References CreateDoubleError(), and GetScErrorCode().

XclBoolError XclTools::ErrorToEnum ( double &  rfDblValue,
bool  bErrOrBool,
sal_uInt8  nValue 
)
static

Gets a translated error code or Boolean value from Excel error codes.

Parameters
rfDblValueReturns 0.0 for error codes or the value of a Boolean (0.0 or 1.0).
bErrorOrBoolfalse = nError is a Boolean value; true = is an error value.
nValueThe error code or Boolean value.

Definition at line 246 of file xltools.cxx.

References eType, EXC_ERR_DIV0, EXC_ERR_NA, EXC_ERR_NAME, EXC_ERR_NULL, EXC_ERR_NUM, EXC_ERR_REF, EXC_ERR_VALUE, xlErrDiv0, xlErrFalse, xlErrNA, xlErrName, xlErrNull, xlErrNum, xlErrRef, xlErrTrue, xlErrUnknown, and xlErrValue.

Referenced by ImportExcel::ErrorToFormula(), XclImpPCItem::WriteToSource(), and XclImpCachedValue::XclImpCachedValue().

OUString XclTools::GetBuiltInDefName ( sal_Unicode  cBuiltIn)
static

Returns the Calc UI representation of a built-in defined name used in NAME records.

Adds a prefix to the representation returned by GetXclBuiltInDefName().

Parameters
cBuiltInExcel index of the built-in name.

Definition at line 493 of file xltools.cxx.

References aBuf, GetXclBuiltInDefName(), and maDefNamePrefix.

Referenced by XclImpName::XclImpName().

sal_Unicode XclTools::GetBuiltInDefNameIndex ( const OUString &  rDefName)
static

Returns the Excel built-in name index of the passed defined name from Calc.

Ignores any characters following a valid representation of a built-in name.

Parameters
rDefNameraw English UI representation of a built-in defined name used in NAME records.
Returns
the index of the built-in name, or EXC_BUILTIN_UNKNOWN if it is not a built-in name.

Definition at line 507 of file xltools.cxx.

References EXC_BUILTIN_UNKNOWN, GetXclBuiltInDefName(), maDefNamePrefix, and maDefNamePrefixXml.

Referenced by XclExpNameManagerImpl::FindBuiltInNameIdx().

OUString XclTools::GetBuiltInDefNameXml ( sal_Unicode  cBuiltIn)
static

Returns the Excel built-in name with OOXML prefix Adds the "_xlnm." prefix to the representation returned by GetXclBuiltInDefName()

Parameters
cBuiltInExcel index of the built in name.

Definition at line 500 of file xltools.cxx.

References aBuf, GetXclBuiltInDefName(), and maDefNamePrefixXml.

bool XclTools::GetBuiltInStyleId ( sal_uInt8 rnStyleId,
sal_uInt8 rnLevel,
const OUString &  rStyleName 
)
static

Returns the Excel built-in style identifier of a passed style name.

Parameters
rnStyleIdThe style identifier is returned here.
rnLevelThe zero-based outline level for RowLevel and ColLevel styles is returned here.
rStyleNameThe style name to examine.
Returns
true = passed string is a built-in style name, false = user style.

Definition at line 627 of file xltools.cxx.

References EXC_STYLE_COLLEVEL, EXC_STYLE_LEVELCOUNT, EXC_STYLE_NOLEVEL, EXC_STYLE_ROWLEVEL, EXC_STYLE_USERDEF, and IsBuiltInStyleName().

Referenced by XclExpXFBuffer::InsertStyleXF(), and XclExpStyle::XclExpStyle().

OUString XclTools::GetBuiltInStyleName ( sal_uInt8  nStyleId,
const OUString &  rName,
sal_uInt8  nLevel 
)
static

Returns the specified built-in cell style name.

Parameters
nStyleIdThe identifier of the built-in style.
rNameDefault name for unknown styles.
nLevelThe zero-based outline level for RowLevel and ColLevel styles.
Returns
The style name or an empty string, if the parameters are not valid.

Definition at line 552 of file xltools.cxx.

References aBuf, EXC_STYLE_COLLEVEL, EXC_STYLE_NORMAL, EXC_STYLE_ROWLEVEL, maStyleNamePrefix1, ppcStyleNames, SAL_N_ELEMENTS, and ScResId().

Referenced by XclImpXFBuffer::CreateUserStyles().

OUString XclTools::GetCondFormatStyleName ( SCTAB  nScTab,
sal_Int32  nFormat,
sal_uInt16  nCondition 
)
static

Returns the style name for a single condition of a conditional formatting.

Prefix for cond. formatting style names from OOX filter.

Parameters
nScTabThe current Calc sheet index.
nFormatThe zero-based index of the conditional formatting.
nConditionThe zero-based index of the condition.
Returns
A style sheet name in the form "Excel_CondFormat_<sheet>_<format>_<condition>".

Definition at line 663 of file xltools.cxx.

References maCFStyleNamePrefix1.

Referenced by XclImpCondFormat::ReadCF().

double XclTools::GetDoubleFromRK ( sal_Int32  nRKValue)
static

GUID of file moniker (HLINK record).

Calculates the double value from an RK value (encoded integer or double).

Definition at line 97 of file xltools.cxx.

References EXC_RK_100FLAG, EXC_RK_INTFLAG, EXC_RK_VALUEMASK, and get_flag().

Referenced by ImportExcel::Mulrk(), XclImpAutoFilterData::ReadAutoFilter(), XclImpChangeTrack::ReadCell(), ImportExcel::ReadRk(), and XclExpRkCell::WriteXmlContents().

sal_Int32 XclTools::GetHmmFromInch ( double  fInches)
static

Returns the length in 1/100 mm calculated from a length in inches.

Definition at line 295 of file xltools.cxx.

References CM_PER_INCH.

Referenced by XclImpChartObj::FinalizeTabChart(), and GetHmmFromTwips().

sal_Int32 XclTools::GetHmmFromTwips ( sal_Int32  nTwips)
static

Returns the length in 1/100 mm calculated from a length in twips.

Definition at line 300 of file xltools.cxx.

References GetHmmFromInch(), and GetInchFromTwips().

Referenced by XclImpChartObj::FinalizeTabChart(), XclChPropSetHelper::WriteMarkerProperties(), and XclExpTbxControlObj::WriteSubRecs().

double XclTools::GetInchFromHmm ( sal_Int32  nHmm)
static

Returns the length in inches calculated from a length in 1/100 mm.

Definition at line 290 of file xltools.cxx.

References GetInchFromTwips(), and GetTwipsFromHmm().

Referenced by XclPageData::SetDefaults().

double XclTools::GetInchFromTwips ( sal_Int32  nTwips)
static

Returns the length in inches calculated from a length in twips.

Definition at line 285 of file xltools.cxx.

References EXC_TWIPS_PER_INCH.

Referenced by XclImpPageSettings::Finalize(), GetHmmFromTwips(), GetInchFromHmm(), and XclExpPageSettings::XclExpPageSettings().

Color XclTools::GetPatternColor ( const Color rPattColor,
const Color rBackColor,
sal_uInt16  nXclPattern 
)
static

Returns the best fitting color for an Excel pattern area format.

Definition at line 348 of file xltools.cxx.

References ScfTools::GetMixedColor(), and SAL_N_ELEMENTS.

Referenced by XclImpCellArea::FillToItemSet(), XclImpDrawObjBase::GetSolidFillColor(), and XclChPropSetHelper::WriteAreaProperties().

bool XclTools::GetRKFromDouble ( sal_Int32 &  rnRKValue,
double  fValue 
)
static

Calculates an RK value (encoded integer or double) from a double value.

Parameters
rnRKValueReturns the calculated RK value.
fValueThe double value.
Returns
true = An RK value could be created.

Definition at line 123 of file xltools.cxx.

References EXC_RK_INT, and EXC_RK_INT100.

Referenced by XclExpChTrCellContent::GetCellData(), and XclExpCellTable::XclExpCellTable().

OUString XclTools::GetSbMacroUrl ( const OUString &  rMacroName,
SfxObjectShell pDocShell 
)
static

Returns the full StarBasic macro URL from an Excel macro name.

Suffix for StarBasic macros.

Definition at line 703 of file xltools.cxx.

Referenced by XclControlHelper::FillMacroDescriptor(), and XclImpDrawObjBase::PreProcessSdrObject().

sal_uInt16 XclTools::GetScColumnWidth ( sal_uInt16  nXclWidth,
long  nScCharWidth 
)
static

Returns the Calc column width (twips) for the passed Excel width.

Excel Column width is stored as 1/256th of a character.

Parameters
nScCharWidthWidth of the '0' character in Calc (twips).

Definition at line 305 of file xltools.cxx.

References limit_cast().

Referenced by ImportExcel::Colinfo(), ImportExcel::Colwidth(), ImportExcel::DefColWidth(), and ImportExcel::Standardwidth().

FormulaError XclTools::GetScErrorCode ( sal_uInt8  nXclError)
static

Converts an Excel error code to a Calc error code.

Definition at line 225 of file xltools.cxx.

References EXC_ERR_DIV0, EXC_ERR_NA, EXC_ERR_NAME, EXC_ERR_NULL, EXC_ERR_NUM, EXC_ERR_REF, and EXC_ERR_VALUE.

Referenced by ErrorToDouble(), XclImpCachedValue::GetScError(), XclImpExtName::MOper::MOper(), and ExcelToSc::ReadExtensionArray().

sal_Int32 XclTools::GetScRotation ( sal_uInt16  nXclRot,
sal_Int32  nRotForStacked 
)
static

Calculates an angle (in 1/100 of degrees) from an Excel angle value.

Parameters
nRotForStackedThis value will be returned, if nXclRot contains 'stacked'.

Definition at line 153 of file xltools.cxx.

References EXC_ROT_STACKED.

Referenced by XclImpChText::ConvertTitlePosition(), XclImpCellAlign::FillToItemSet(), and XclChPropSetHelper::WriteRotationProperties().

rtl_TextEncoding XclTools::GetTextEncoding ( sal_uInt16  nCodePage)
static

Returns a text encoding from an Excel code page.

Returns
The corresponding text encoding or RTL_TEXTENCODING_DONTKNOW.

Definition at line 428 of file xltools.cxx.

References SAL_WARN.

Referenced by XclImpRoot::SetCodePage().

sal_uInt16 XclTools::GetTwipsFromHmm ( sal_Int32  nHmm)
static

Returns the length in twips calculated from a length in 1/100 mm.

Definition at line 280 of file xltools.cxx.

References CM_PER_INCH, and GetTwipsFromInch().

Referenced by GetInchFromHmm(), and XclChPropSetHelper::ReadMarkerProperties().

sal_uInt16 XclTools::GetTwipsFromInch ( double  fInches)
static

Returns the length in twips calculated from a length in inches.

Definition at line 274 of file xltools.cxx.

References EXC_TWIPS_PER_INCH.

Referenced by XclImpPageSettings::Finalize(), and GetTwipsFromHmm().

OUString XclTools::GetXclBuiltInDefName ( sal_Unicode  cBuiltIn)
static

Returns the raw English UI representation of a built-in defined name used in NAME records.

Parameters
cBuiltInExcel index of the built-in name.

Definition at line 482 of file xltools.cxx.

References EXC_BUILTIN_UNKNOWN, ppcDefNames, and SAL_N_ELEMENTS.

Referenced by GetBuiltInDefName(), GetBuiltInDefNameIndex(), GetBuiltInDefNameXml(), and XclImpName::XclImpName().

sal_uInt16 XclTools::GetXclCodePage ( rtl_TextEncoding  eTextEnc)
static

Returns an Excel code page from a text encoding.

Definition at line 439 of file xltools.cxx.

References SAL_WARN.

Referenced by ExcTable::FillAsHeaderBinary().

sal_uInt16 XclTools::GetXclColumnWidth ( sal_uInt16  nScWidth,
long  nScCharWidth 
)
static

Returns the Excel column width for the passed Calc width (twips).

Parameters
nScCharWidthWidth of the '0' character in Calc (twips).

Definition at line 311 of file xltools.cxx.

References limit_cast().

Referenced by XclExpColinfo::XclExpColinfo().

double XclTools::GetXclDefColWidthCorrection ( long  nXclDefFontHeight)
static

Returns a correction value to convert column widths from/to default column widths.

Parameters
nXclDefFontHeightExcel height of application default font.

Definition at line 319 of file xltools.cxx.

Referenced by ImportExcel::DefColWidth().

sal_uInt8 XclTools::GetXclErrorCode ( FormulaError  nScError)
static
OUString XclTools::GetXclFontName ( const OUString &  rFontName)
static

Returns the matching Excel font name for a passed Calc font name.

Definition at line 453 of file xltools.cxx.

References GetSubsFontName().

Referenced by XclExpHFConverter::AppendPortion(), XclFontData::FillFromVclFont(), and XclExpDxfFont::SaveXml().

OUString XclTools::GetXclMacroName ( const OUString &  rSbMacroUrl)
static

Returns the Excel macro name from a full StarBasic macro URL.

Definition at line 712 of file xltools.cxx.

References maSbMacroPrefix, and maSbMacroSuffix.

Referenced by XclControlHelper::ExtractFromMacroDescriptor(), and XclExpShapeObj::XclExpShapeObj().

sal_uInt8 XclTools::GetXclOrientFromRot ( sal_uInt16  nXclRot)
static

Calculates BIFF2-BIFF5 text orientation from BIFF8 rotation angle.

Definition at line 188 of file xltools.cxx.

References EXC_ORIENT_90CCW, EXC_ORIENT_90CW, EXC_ORIENT_NONE, EXC_ORIENT_STACKED, and EXC_ROT_STACKED.

Referenced by XclExpCellAlign::FillFromItemSet(), XclExpChText::SetRotation(), and XclExpChTick::SetRotation().

sal_uInt8 XclTools::GetXclRotation ( sal_Int32  nScRot)
static

Calculates the Excel angle value from an angle in 1/100 of degrees.

Definition at line 161 of file xltools.cxx.

Referenced by XclExpCellAlign::FillFromItemSet(), and XclChPropSetHelper::ReadRotationProperties().

sal_uInt8 XclTools::GetXclRotFromOrient ( sal_uInt8  nXclOrient)
static

Calculates BIFF8 rotation angle from BIFF2-BIFF5 text orientation.

Definition at line 175 of file xltools.cxx.

References EXC_ORIENT_90CCW, EXC_ORIENT_90CW, EXC_ORIENT_NONE, EXC_ORIENT_STACKED, EXC_ROT_90CCW, EXC_ROT_90CW, EXC_ROT_NONE, and EXC_ROT_STACKED.

Referenced by XclImpCellAlign::FillToItemSet(), XclImpChTick::ReadChTick(), and XclImpChText::ReadHeaderRecord().

bool XclTools::IsBuiltInStyleName ( const OUString &  rStyleName,
sal_uInt8 pnStyleId = nullptr,
sal_Int32 *  pnNextChar = nullptr 
)
static

Returns true, if the passed string is a name of an Excel built-in style.

Parameters
pnStyleIdIf not 0, the found style identifier will be returned here.
pnNextCharIf not 0, the index of the char after the evaluated substring will be returned here.

Definition at line 579 of file xltools.cxx.

References EXC_STYLE_NORMAL, EXC_STYLE_USERDEF, maStyleNamePrefix1, maStyleNamePrefix2, nId, ppcStyleNames, SAL_N_ELEMENTS, and ScResId().

Referenced by GetBuiltInStyleId().

bool XclTools::IsCondFormatStyleName ( const OUString &  rStyleName)
static

Returns true, if the passed string is a name of a conditional format style created by Excel import.

Parameters
pnNextCharIf not 0, the index of the char after the evaluated substring will be returned here.

Definition at line 673 of file xltools.cxx.

References maCFStyleNamePrefix1, and maCFStyleNamePrefix2.

const XclTools& XclTools::operator= ( const XclTools )
delete
void XclTools::SkipSubStream ( XclImpStream rStrm)
static

Skips a substream (BOF/EOF record block).

Includes all embedded substreams.

Definition at line 686 of file xltools.cxx.

References EXC_ID2_BOF, EXC_ID3_BOF, EXC_ID4_BOF, EXC_ID5_BOF, EXC_ID_EOF, XclImpStream::GetRecId(), and XclImpStream::StartNextRecord().

Referenced by ImportExcel8::Read(), ImportExcel::Read(), and XclImpChart::ReadChartSubStream().

Member Data Documentation

const XclGuid XclTools::maGuidFileMoniker
static

GUID of URL moniker (HLINK record).

Definition at line 95 of file xltools.hxx.

Referenced by XclImpHyperlink::ReadEmbeddedData(), and XclExpHyperlink::XclExpHyperlink().

const XclGuid XclTools::maGuidStdLink
static
const XclGuid XclTools::maGuidUrlMoniker
static

GUID of StdLink (HLINK record).

Definition at line 94 of file xltools.hxx.

Referenced by XclImpHyperlink::ReadEmbeddedData(), and XclExpHyperlink::XclExpHyperlink().


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