LibreOffice Module sc (master) 1
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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 .
18 */
20#pragma once
22#include <types.hxx>
23#include "ftools.hxx"
25#include <tools/long.hxx>
26#include <tools/degree.hxx>
28class SfxObjectShell;
29enum class FormulaError : sal_uInt16;
31// BIFF versions ==============================================================
33#define DBG_ERROR_BIFF() OSL_FAIL( "Unknown BIFF type!" )
34#define OSL_ENSURE_BIFF( c ) OSL_ENSURE( c, "Unknown BIFF type!" )
36// Enumerations ===============================================================
53// GUID import/export =========================================================
55class XclImpStream;
56class XclExpStream;
59struct XclGuid
63 explicit XclGuid();
64 explicit XclGuid(
65 sal_uInt32 nData1,
66 sal_uInt16 nData2, sal_uInt16 nData3,
67 sal_uInt8 nData41, sal_uInt8 nData42,
68 sal_uInt8 nData43, sal_uInt8 nData44,
69 sal_uInt8 nData45, sal_uInt8 nData46,
70 sal_uInt8 nData47, sal_uInt8 nData48 );
73bool operator==( const XclGuid& rCmp1, const XclGuid& rCmp2 );
76XclExpStream& operator<<( XclExpStream& rStrm, const XclGuid& rGuid );
78// Excel Tools ================================================================
84 // noncopyable nonconstructable -------------------------------------------
86 XclTools(const XclTools&) = delete;
87 const XclTools& operator=(const XclTools&) = delete;
90 XclTools() = delete;
93 // GUID's -----------------------------------------------------------------
95 static const XclGuid maGuidStdLink;
99 // numeric conversion -----------------------------------------------------
102 static double GetDoubleFromRK( sal_Int32 nRKValue );
107 static bool GetRKFromDouble( sal_Int32& rnRKValue, double fValue );
111 static Degree100 GetScRotation( sal_uInt16 nXclRot, Degree100 nRotForStacked );
113 static sal_uInt8 GetXclRotation( Degree100 nScRot );
116 static sal_uInt8 GetXclRotFromOrient( sal_uInt8 nXclOrient );
118 static sal_uInt8 GetXclOrientFromRot( sal_uInt16 nXclRot );
121 static sal_uInt8 GetXclErrorCode( FormulaError nScError );
123 static FormulaError GetScErrorCode( sal_uInt8 nXclError );
126 static double ErrorToDouble( sal_uInt8 nXclError );
131 static XclBoolError ErrorToEnum( double& rfDblValue, bool bErrOrBool, sal_uInt8 nValue );
134 static sal_uInt16 GetTwipsFromInch( double fInches );
136 static sal_uInt16 GetTwipsFromHmm( sal_Int32 nHmm );
139 static double GetInchFromTwips( sal_Int32 nTwips );
141 static double GetInchFromHmm( sal_Int32 nHmm );
144 static sal_Int32 GetHmmFromInch( double fInches );
146 static sal_Int32 GetHmmFromTwips( sal_Int32 nTwips );
151 static sal_uInt16 GetScColumnWidth( sal_uInt16 nXclWidth, tools::Long nScCharWidth );
154 static sal_uInt16 GetXclColumnWidth( sal_uInt16 nScWidth, tools::Long nScCharWidth );
158 static double GetXclDefColWidthCorrection( tools::Long nXclDefFontHeight );
160 // formatting -------------------------------------------------------------
163 static Color GetPatternColor( const Color& rPattColor, const Color& rBackColor, sal_uInt16 nXclPattern );
165 // text encoding ----------------------------------------------------------
169 static rtl_TextEncoding GetTextEncoding( sal_uInt16 nCodePage );
172 static sal_uInt16 GetXclCodePage( rtl_TextEncoding eTextEnc );
174 // font names -------------------------------------------------------------
177 static OUString GetXclFontName( const OUString& rFontName );
179 // built-in defined names -------------------------------------------------
183 static OUString GetXclBuiltInDefName( sal_Unicode cBuiltIn );
187 static OUString GetBuiltInDefName( sal_Unicode cBuiltIn );
191 static OUString GetBuiltInDefNameXml( sal_Unicode cBuiltIn );
196 static sal_Unicode GetBuiltInDefNameIndex( const OUString& rDefName );
198 // built-in style names ---------------------------------------------------
205 static OUString GetBuiltInStyleName( sal_uInt8 nStyleId, std::u16string_view rName, sal_uInt8 nLevel );
210 static bool IsBuiltInStyleName( const OUString& rStyleName, sal_uInt8* pnStyleId = nullptr, sal_Int32* pnNextChar = nullptr );
216 static bool GetBuiltInStyleId(
217 sal_uInt8& rnStyleId, sal_uInt8& rnLevel,
218 const OUString& rStyleName );
220 // conditional formatting style names -------------------------------------
227 static OUString GetCondFormatStyleName( SCTAB nScTab, sal_Int32 nFormat, sal_uInt16 nCondition );
230 static bool IsCondFormatStyleName( const OUString& rStyleName );
232 // stream handling --------------------------------------------------------
235 static void SkipSubStream( XclImpStream& rStrm );
237 // Basic macro names ------------------------------------------------------
240 static OUString GetSbMacroUrl( const OUString& rMacroName, SfxObjectShell* pDocShell );
242 static OUString GetXclMacroName( const OUString& rSbMacroUrl );
246// read/write colors ----------------------------------------------------------
250XclImpStream& operator>>( XclImpStream& rStrm, Color& rColor );
254XclExpStream& operator<<( XclExpStream& rStrm, const Color& rColor );
256/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class is used to export Excel record streams.
Definition: xestream.hxx:73
This class is used to import record oriented streams.
Definition: xistream.hxx:278
This class contains static helper methods for the Excel import and export filters.
Definition: xltools.hxx:82
static void SkipSubStream(XclImpStream &rStrm)
Skips a substream (BOF/EOF record block).
Definition: xltools.cxx:688
We don't want anybody to instantiate this class, since it is just a collection of static items.
static Color GetPatternColor(const Color &rPattColor, const Color &rBackColor, sal_uInt16 nXclPattern)
Returns the best fitting color for an Excel pattern area format.
Definition: xltools.cxx:350
static const XclGuid maGuidStdLink
Definition: xltools.hxx:95
static double GetDoubleFromRK(sal_Int32 nRKValue)
GUID of file moniker (HLINK record).
Definition: xltools.cxx:98
static sal_uInt8 GetXclOrientFromRot(sal_uInt16 nXclRot)
Calculates BIFF2-BIFF5 text orientation from BIFF8 rotation angle.
Definition: xltools.cxx:189
static sal_uInt8 GetXclErrorCode(FormulaError nScError)
Converts a Calc error code to an Excel error code.
Definition: xltools.cxx:201
static OUString GetBuiltInDefNameXml(sal_Unicode cBuiltIn)
Returns the Excel built-in name with OOXML prefix @descr Adds the "_xlnm." prefix to the representati...
Definition: xltools.cxx:500
static sal_uInt8 GetXclRotFromOrient(sal_uInt8 nXclOrient)
Calculates BIFF8 rotation angle from BIFF2-BIFF5 text orientation.
Definition: xltools.cxx:176
static sal_uInt16 GetXclColumnWidth(sal_uInt16 nScWidth, tools::Long nScCharWidth)
Returns the Excel column width for the passed Calc width (twips).
Definition: xltools.cxx:313
static XclBoolError ErrorToEnum(double &rfDblValue, bool bErrOrBool, sal_uInt8 nValue)
Gets a translated error code or Boolean value from Excel error codes.
Definition: xltools.cxx:247
static double GetInchFromTwips(sal_Int32 nTwips)
Returns the length in inches calculated from a length in twips.
Definition: xltools.cxx:287
static FormulaError GetScErrorCode(sal_uInt8 nXclError)
Converts an Excel error code to a Calc error code.
Definition: xltools.cxx:226
static rtl_TextEncoding GetTextEncoding(sal_uInt16 nCodePage)
Returns a text encoding from an Excel code page.
Definition: xltools.cxx:430
static double ErrorToDouble(sal_uInt8 nXclError)
Converts the passed BIFF error to a double containing the respective Calc error code.
Definition: xltools.cxx:242
static OUString GetXclBuiltInDefName(sal_Unicode cBuiltIn)
Returns the raw English UI representation of a built-in defined name used in NAME records.
Definition: xltools.cxx:484
static double GetXclDefColWidthCorrection(tools::Long nXclDefFontHeight)
Returns a correction value to convert column widths from/to default column widths.
Definition: xltools.cxx:321
static sal_Int32 GetHmmFromTwips(sal_Int32 nTwips)
Returns the length in 1/100 mm calculated from a length in twips.
Definition: xltools.cxx:302
static Degree100 GetScRotation(sal_uInt16 nXclRot, Degree100 nRotForStacked)
Calculates an angle (in 1/100 of degrees) from an Excel angle value.
Definition: xltools.cxx:154
static sal_uInt16 GetTwipsFromInch(double fInches)
Returns the length in twips calculated from a length in inches.
Definition: xltools.cxx:277
static OUString GetCondFormatStyleName(SCTAB nScTab, sal_Int32 nFormat, sal_uInt16 nCondition)
Returns the style name for a single condition of a conditional formatting.
Definition: xltools.cxx:662
static sal_uInt16 GetScColumnWidth(sal_uInt16 nXclWidth, tools::Long nScCharWidth)
Returns the Calc column width (twips) for the passed Excel width.
Definition: xltools.cxx:307
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.
Definition: xltools.cxx:577
static sal_uInt8 GetXclRotation(Degree100 nScRot)
Calculates the Excel angle value from an angle in 1/100 of degrees.
Definition: xltools.cxx:162
static OUString GetSbMacroUrl(const OUString &rMacroName, SfxObjectShell *pDocShell)
Returns the full StarBasic macro URL from an Excel macro name.
Definition: xltools.cxx:705
static double GetInchFromHmm(sal_Int32 nHmm)
Returns the length in inches calculated from a length in 1/100 mm.
Definition: xltools.cxx:292
static const XclGuid maGuidFileMoniker
GUID of URL moniker (HLINK record).
Definition: xltools.hxx:97
static bool GetBuiltInStyleId(sal_uInt8 &rnStyleId, sal_uInt8 &rnLevel, const OUString &rStyleName)
Returns the Excel built-in style identifier of a passed style name.
Definition: xltools.cxx:625
static const XclGuid maGuidUrlMoniker
GUID of StdLink (HLINK record).
Definition: xltools.hxx:96
XclTools(const XclTools &)=delete
static OUString GetBuiltInStyleName(sal_uInt8 nStyleId, std::u16string_view rName, sal_uInt8 nLevel)
Returns the specified built-in cell style name.
Definition: xltools.cxx:550
static sal_uInt16 GetTwipsFromHmm(sal_Int32 nHmm)
Returns the length in twips calculated from a length in 1/100 mm.
Definition: xltools.cxx:282
static sal_uInt16 GetXclCodePage(rtl_TextEncoding eTextEnc)
Returns an Excel code page from a text encoding.
Definition: xltools.cxx:441
static bool IsCondFormatStyleName(const OUString &rStyleName)
Returns true, if the passed string is a name of a conditional format style created by Excel import.
Definition: xltools.cxx:672
static OUString GetXclFontName(const OUString &rFontName)
Returns the matching Excel font name for a passed Calc font name.
Definition: xltools.cxx:455
static OUString GetBuiltInDefName(sal_Unicode cBuiltIn)
Returns the Calc UI representation of a built-in defined name used in NAME records.
Definition: xltools.cxx:495
static bool GetRKFromDouble(sal_Int32 &rnRKValue, double fValue)
Calculates an RK value (encoded integer or double) from a double value.
Definition: xltools.cxx:124
static sal_Unicode GetBuiltInDefNameIndex(const OUString &rDefName)
Returns the Excel built-in name index of the passed defined name from Calc.
Definition: xltools.cxx:505
const XclTools & operator=(const XclTools &)=delete
static OUString GetXclMacroName(const OUString &rSbMacroUrl)
Returns the Excel macro name from a full StarBasic macro URL.
Definition: xltools.cxx:714
static sal_Int32 GetHmmFromInch(double fInches)
Returns the length in 1/100 mm calculated from a length in inches.
Definition: xltools.cxx:297
long Long
This struct stores a GUID (class ID) and supports reading, writing and comparison.
Definition: xltools.hxx:60
Stores GUID always in little endian.
Definition: xltools.cxx:43
sal_uInt8 mpnData[16]
Definition: xltools.hxx:61
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
sal_Int16 SCTAB
Definition: types.hxx:22
An enumeration for all Excel error codes and the values true and false.
Definition: xltools.hxx:40
@ xlErrDiv0
The error code NULL!
Definition: xltools.hxx:42
@ xlErrValue
The error code #DIV/0!
Definition: xltools.hxx:43
@ xlErrNA
The error code #NUM!
Definition: xltools.hxx:47
@ xlErrNull
Definition: xltools.hxx:41
@ xlErrUnknown
The Boolean value false.
Definition: xltools.hxx:50
@ xlErrName
The error code #REF!
Definition: xltools.hxx:45
@ xlErrNum
The error code #NAME?
Definition: xltools.hxx:46
@ xlErrFalse
The Boolean value true.
Definition: xltools.hxx:49
@ xlErrTrue
The error code N/A!
Definition: xltools.hxx:48
@ xlErrRef
The error code #VALUE!
Definition: xltools.hxx:44
XclImpStream & operator>>(XclImpStream &rStrm, XclGuid &rGuid)
Definition: xltools.cxx:72
bool operator==(const XclGuid &rCmp1, const XclGuid &rCmp2)
Definition: xltools.cxx:67
XclExpStream & operator<<(XclExpStream &rStrm, const XclGuid &rGuid)
Definition: xltools.cxx:78