28#include <document.hxx>
46void lclFillAddress(
ScAddress& rScPos, sal_uInt16 nXclCol, sal_uInt32 nXclRow,
SCTAB nScTab )
66 bool bValid = bValidCol && bValidRow;
67 if( !bValid && bWarn )
82 lclFillAddress( rScPos, rXclPos.
mnCol, rXclPos.
mnRow, nScTab );
115 nXclCol2 = ::std::min( nXclCol2,
mnMaxCol );
116 nXclRow2 = ::std::min( nXclRow2,
mnMaxRow );
118 lclFillAddress( rScRange.
aEnd, nXclCol2, nXclRow2, nScTab2 );
129 for(
const auto& rXclRange : rXclRanges )
132 if(
ConvertRange( aScRange, rXclRange, nScTab, nScTab, bWarn ) )
141std::unique_ptr<EditTextObject> lclCreateTextObject(
const XclImpRoot& rRoot,
144 std::unique_ptr<EditTextObject> pTextObj;
148 bool bFirstEscaped = pFirstFont && pFirstFont->
HasEscapement();
150 if( rString.
IsRich() || bFirstEscaped )
164 XclFormatRunVec::const_iterator aIt = rFormats.begin();
165 XclFormatRunVec::const_iterator aEnd = rFormats.end();
172 sal_Int32 nLen = rString.
GetText().getLength();
173 for( sal_Int32 nChar = 0; nChar < nLen; ++nChar )
176 if( nChar >= aNextRun.
mnChar )
182 aItemSet.ClearItem();
197 if( rString.
GetText()[ nChar ] ==
'\n' )
227 if (rString.
GetText().isEmpty())
230 ::std::unique_ptr< EditTextObject > pTextObj( lclCreateTextObject( rRoot, rString,
XclFontItemType::Editeng, nXFIndex ) );
239 if (
aStr.indexOf(
'\n') != -1 ||
aStr.indexOf(
'\r') != -1)
292 OUStringBuffer aReadFont;
293 OUStringBuffer aReadStyle;
294 sal_uInt16 nReadHeight = 0;
298 enum XclHFParserState
355 if( (pNull -
pChar >= 2) && (*(
pChar + 1) ==
'&') && (*(
pChar + 2) ==
'F') )
391 aReadFont.setLength(0);
392 aReadStyle.setLength(0);
398 nReadHeight = *
pChar -
'0';
415 eState = xlPSFontStyle;
418 aReadFont.append(*
pChar);
431 if( !aReadFont.isEmpty() )
437 aReadStyle.append(*
pChar);
448 if( nReadHeight != 0xFFFF )
451 nReadHeight += (*
pChar -
'0');
452 if( nReadHeight > 1600 )
453 nReadHeight = 0xFFFF;
458 if( (nReadHeight != 0) && (nReadHeight != 0xFFFF) )
488 rItemSet.
Put( aHFItem );
501 sal_uInt16 nMaxHt =
maInfos[ ePortion ].mnMaxLineHt;
502 return (nMaxHt == 0) ?
mxFontData->mnHeight : nMaxHt;
507 sal_uInt16& rnMaxHt =
maInfos[ ePortion ].mnMaxLineHt;
508 rnMaxHt = ::std::max( rnMaxHt,
mxFontData->mnHeight );
546 OUString sString(
maCurrText.makeStringAndClear());
596void lclAppendUrlChar( OUString& rUrl,
sal_Unicode cChar )
601 case '#': rUrl +=
"%23";
break;
602 case '%': rUrl +=
"%25";
break;
603 default: rUrl += OUStringChar( cChar );
610 OUString& rUrl, OUString& rTabName,
bool& rbSameWb,
611 const XclImpRoot& rRoot,
const OUString& rEncodedUrl )
620 } eState = xlUrlInit;
622 bool bEncoded =
true;
627 if (!aDosBase.isEmpty() && aDosBase.match(
":\\", 1))
628 cCurrDrive = aDosBase[0];
648 eState = xlUrlSheetName;
652 eState = xlUrlFileName;
656 lclAppendUrlChar( rUrl, *
pChar );
677 lclAppendUrlChar( rUrl, *
pChar );
682 rUrl +=
"<NULL-DRIVE!>";
688 lclAppendUrlChar( rUrl, cCurrDrive );
708 sal_Int32 nLen = *++
pChar;
709 for( sal_Int32 nChar = 0; (nChar < nLen) && *(
pChar + 1); ++nChar )
710 lclAppendUrlChar( rUrl, *++
pChar );
716 eState = xlUrlFileName;
719 lclAppendUrlChar( rUrl, *
pChar );
730 case ']': eState = xlUrlSheetName;
break;
731 default: lclAppendUrlChar( rUrl, *
pChar );
739 rTabName += OUStringChar( *
pChar );
745 lclAppendUrlChar( rUrl, *
pChar );
754 OUString& rUrl,
bool& rbSameWb,
const XclImpRoot& rRoot,
const OUString& rEncodedUrl )
758 DecodeUrl( aUrl, aTabName, rbSameWb, rRoot, rEncodedUrl );
760 OSL_ENSURE( aTabName.isEmpty(),
"XclImpUrlHelper::DecodeUrl - sheet name ignored" );
766 if(
nPos != std::u16string_view::npos && (
nPos > 0) && (
nPos + 1 < aEncUrl.size()) )
768 rApplic = aEncUrl.substr( 0,
nPos );
769 rTopic = aEncUrl.substr(
nPos + 1 );
800 std::unique_ptr<ScTokenArray> pScTokArr =
rStrm.GetRoot().GetOldFmlaConverter().GetBoolErr(
807 OSL_FAIL(
"XclImpCachedValue::XclImpCachedValue - unknown data type" );
843 const size_t nMinRecordSize = 1;
844 const size_t nMaxRows =
rStrm.GetRecLeft() / (nMinRecordSize *
mnScCols);
847 SAL_WARN(
"sc",
"Parsing error: " << nMaxRows <<
848 " max possible rows, but " <<
mnScRows <<
" claimed, truncating");
868 XclImpValueList::const_iterator itValue =
maValueList.begin();
873 switch( (*itValue)->GetType() )
877 xScMatrix->PutEmpty( nScCol, nScRow );
880 xScMatrix->PutDouble( (*itValue)->GetValue(), nScCol, nScRow );
883 xScMatrix->PutString(rPool.
intern((*itValue)->GetString()), nScCol, nScRow);
886 xScMatrix->PutBoolean( (*itValue)->GetBool(), nScCol, nScRow );
889 xScMatrix->PutError( (*itValue)->GetScError(), nScCol, nScRow );
892 OSL_FAIL(
"XclImpCachedMatrix::CreateScMatrix - unknown value type" );
893 xScMatrix->PutEmpty( nScCol, nScRow );
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
std::unique_ptr< EditTextObject > CreateTextObject()
void SetText(const OUString &rStr)
void SetSingleLine(bool bValue)
void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)
const SfxItemSet & GetEmptyItemSet() const
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
void QuickInsertText(const OUString &rText, const ESelection &rSel)
OUString getFSysPath(FSysStyle eStyle, sal_Unicode *pDelimiter=nullptr) const
Accessor class to ScDocument.
void setEditCell(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
void setStringCell(const ScAddress &rPos, const OUString &rStr)
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Matrix data type that can store values of mixed types.
void SetLeftArea(const EditTextObject &rNew)
void SetCenterArea(const EditTextObject &rNew)
void SetRightArea(const EditTextObject &rNew)
void push_back(const ScRange &rRange)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SvStream & ReadDouble(double &rDouble)
Base class for import/export address converters.
sal_uInt32 mnMaxRow
Maximum column index, as 16-bit value.
sal_uInt16 mnMaxCol
Default maximum position.
ScAddress maMaxPos
Tracer for invalid addresses.
bool mbColTrunc
Maximum row index.
bool mbRowTrunc
Flag for "columns truncated" warning box.
bool ConvertRange(ScRange &rScRange, const XclRange &rXclRange, SCTAB nScTab1, SCTAB nScTab2, bool bWarn)
Converts the passed Excel cell range to a Calc cell range.
void ConvertRangeList(ScRangeList &rScRanges, const XclRangeList &rXclRanges, SCTAB nScTab, bool bWarn)
Converts the passed Excel cell range list to a Calc cell range list.
bool CheckAddress(const XclAddress &rXclPos, bool bWarn)
Checks if the passed Excel cell address is valid.
XclImpAddressConverter(const XclImpRoot &rRoot)
bool ConvertAddress(ScAddress &rScPos, const XclAddress &rXclPos, SCTAB nScTab, bool bWarn)
Converts the passed Excel cell address to a Calc cell address.
ScAddress CreateValidAddress(const XclAddress &rXclPos, SCTAB nScTab, bool bWarn)
Returns a valid cell address by moving it into allowed dimensions.
SCSIZE mnScRows
Number of cached columns.
SCSIZE mnScCols
List of cached cell values.
XclImpCachedMatrix(XclImpStream &rStrm)
XclImpValueList maValueList
ScMatrixRef CreateScMatrix(svl::SharedStringPool &rPool) const
Creates a new ScMatrix object and fills it with the contained values.
XclImpCachedValue(const XclImpCachedValue &)=delete
delete copy constructor
sal_uInt8 mnType
Boolean value or Excel error code.
sal_uInt8 mnBoolErr
Cached value is a formula or error code or Boolean.
ScTokenArrayPtr mxTokArr
Cached value is a double.
double mfValue
Cached value is a string.
FormulaError GetScError() const
Returns the cached Calc error code, if this value has Error type, else 0.
virtual ~XclImpCachedValue()
Stores the data of all fonts occurred in an Excel file.
void FillToItemSet(SfxItemSet &rItemSet, XclFontItemType eType, sal_uInt16 nFontIdx, bool bSkipPoolDefs=false) const
Fills all font properties from a FONT record to the item set.
Stores all data of an Excel font and provides import of FONT records.
const XclFontData & GetFontData() const
Returns read-only access to font data.
bool HasEscapement() const
Returns true, if the font contains superscript or subscript.
void FillToItemSet(SfxItemSet &rItemSet, XclFontItemType eType, bool bSkipPoolDefs=false) const
Fills all font properties to the item set.
void ParseString(const OUString &rHFString)
Parses the passed string and creates three new edit engine text objects.
void InsertLineBreak()
Inserts a line break and adjusts the current selection object.
void FillToItemSet(SfxItemSet &rItemSet, sal_uInt16 nWhichId) const
Creates a ScPageHFItem and inserts it into the passed item set.
XclImpHFConverter(const XclImpHFConverter &)=delete
delete copy constructor
sal_uInt16 GetMaxLineHeight(XclImpHFPortion ePortion) const
Returns the maximum line height of the specified portion.
void InsertField(const SvxFieldItem &rFieldItem)
Inserts the passed text field and adjusts the current selection object.
std::vector< XclImpHFPortionInfo > maInfos
The header/footer edit engine.
XclImpHFPortion meCurrObj
Font data of current text.
void ResetFontData()
Resets font data to application default font.
ESelection & GetCurrSel()
Returns the current selection.
void SetAttribs()
Sets the font attributes at the current selection.
XclFontDataPtr mxFontData
Current text to insert into edit engine.
void InsertText()
Inserts maCurrText into edit engine and adjusts the current selection object.
void CreateCurrObject()
Creates the edit engine text object of current portion from edit engine.
XclImpHFPortion
Enumerates the supported header/footer portions.
sal_Int32 GetTotalHeight() const
Returns the total height of the converted header or footer in twips.
XclImpHFPortionInfo::EditTextObjectRef & GetCurrObj()
Returns the current edit engine text object.
void UpdateCurrMaxLineHeight()
Updates the current maximum line height, using the current font size.
void UpdateMaxLineHeight(XclImpHFPortion ePortion)
Updates the maximum line height of the specified portion, using the current font size.
virtual ~XclImpHFConverter() override
void SetNewPortion(XclImpHFPortion eNew)
Changes current header/footer portion to eNew.
OUStringBuffer maCurrText
Edit engine text objects for all portions.
XclImpHFPortionInfo & GetCurrInfo()
Returns the current edit engine text object.
Access to global data from other classes.
XclImpXFBuffer & GetXFBuffer() const
Returns the cell formatting attributes buffer.
XclImpFontBuffer & GetFontBuffer() const
Returns the font buffer.
const XclImpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
This class is used to import record oriented streams.
static std::unique_ptr< EditTextObject > CreateTextObject(const XclImpRoot &rRoot, const XclImpString &rString)
Returns a new edit engine text object.
static void SetToDocument(ScDocumentImport &rDoc, const ScAddress &rPos, const XclImpRoot &rRoot, const XclImpString &rString, sal_uInt16 nXFIndex)
This class represents an unformatted or formatted string and provides importing from stream.
bool IsRich() const
Returns true, if the string contains formatting information.
const XclFormatRunVec & GetFormats() const
Returns the formatting run vector.
const OUString & GetText() const
Returns the pure text data of the string.
static void DecodeUrl(OUString &rUrl, OUString &rTabName, bool &rbSameWb, const XclImpRoot &rRoot, const OUString &rEncodedUrl)
Decodes an encoded external document URL with optional sheet name.
static bool DecodeLink(OUString &rApplic, OUString &rTopic, std::u16string_view aEncUrl)
Decodes the passed URL to OLE or DDE link components.
Contains all XF records occurred in the file.
sal_uInt16 GetFontIndex(sal_uInt16 nXFIndex) const
Returns the index to the Excel font used in the specified XF record.
XclImpXF * GetXF(sal_uInt16 nXFIndex)
Returns the object that stores all contents of an XF record.
const XclImpFont * GetFont(sal_uInt16 nXFIndex) const
Returns the Excel font used in the specified XF record.
Contains all data of a XF record and a Calc item set.
bool GetLineBreak() const
A 2D cell range address list with Excel column and row indexes.
ScHeaderEditEngine & GetHFEditEngine() const
Returns the edit engine for import/export of headers/footers.
const OUString & GetBasePath() const
Returns the base path of the imported/exported file.
ScEditEngineDefaulter & GetEditEngine() const
Returns the edit engine for import/export of rich strings etc.
void TraceInvalidAddress(const ScAddress &rPos, const ScAddress &rMaxPos)
SharedString intern(const OUString &rStr)
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
#define SAL_WARN(area, stream)
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
A 2D cell address struct with Excel column and row indexes.
This struct helps reading and writing Excel fonts.
XclImpHFPortionInfo()
Maximum font height for the current text line.
sal_uInt16 mnMaxLineHt
Height of previous lines in twips.
sal_Int32 mnHeight
Edit engine selection.
ESelection maSel
Edit engine text object.
A 2D cell range address struct with Excel column and row indexes.
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
const sal_Unicode EXC_URL_DRIVEROOT
DOS drive letter or UNC server name.
const sal_Unicode EXC_URLSTART_SELFENCODED
Reference to own workbook.
const sal_Unicode EXC_URL_RAW
Parent directory.
const sal_uInt8 EXC_CACHEDVAL_ERROR
const sal_Unicode EXC_URLSTART_ENCODED
const sal_uInt8 EXC_CACHEDVAL_STRING
const sal_Unicode EXC_URLSTART_SELF
Encoded URL.
const sal_Unicode EXC_URL_DOSDRIVE
Reference to own workbook (BIFF5/BIFF7).
const sal_uInt8 EXC_CACHEDVAL_EMPTY
const sal_uInt8 EXC_CACHEDVAL_BOOL
const sal_Unicode EXC_URL_SUBDIR
Root directory of current drive.
const sal_Unicode EXC_URL_PARENTDIR
Directory name delimiter.
const sal_uInt8 EXC_CACHEDVAL_DOUBLE
const sal_Unicode EXC_DDE_DELIM
Sheet name starts here (BIFF4).
::std::vector< XclFormatRun > XclFormatRunVec
A vector with all formatting runs for a rich-string.
const sal_uInt16 EXC_FONT_APP
XclFontItemType
Enumerates different types of Which-IDs for font items.
@ HeaderFooter
Use edit engine Which-IDs (EE_CHAR_*).
@ Editeng
Use Calc Which-IDs (ATTR_*).
const sal_uInt16 EXC_FONTESC_SUPER
const sal_uInt8 EXC_FONTUNDERL_SINGLE
const sal_uInt8 EXC_FONTUNDERL_DOUBLE
const sal_uInt16 EXC_FONTESC_NONE
const sal_uInt8 EXC_FONTUNDERL_NONE
const sal_uInt16 EXC_FONTESC_SUB