38#include <osl/diagnose.h>
39#include <officecfg/Office/Common.hxx>
43#include <document.hxx>
51#include <progress.hxx>
54#include <fuinsert.hxx>
84 mpParser->GetDimensions( nEndCol, nEndRow );
116 bool bConvertScientific )
122 SCCOL nStartCol, nEndCol;
123 SCROW nStartRow, nEndRow;
125 SCROW nOverlapRowMax, nLastMergedRow;
135 bool bHasGraphics =
false;
139 bool bNumbersEnglishUS =
false;
143 bNumbersEnglishUS = officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::get();
150 SCROW nRow = nStartRow +
pE->nRow;
151 if ( nRow != nLastMergedRow )
153 SCCOL nCol = nStartCol +
pE->nCol + nMergeColAdd;
156 if (nRow <= nOverlapRowMax && mpDoc->
ValidCol(nCol))
158 while ( nCol <= mpDoc->MaxCol() &&
mpDoc->
HasAttrib( nCol, nRow, nTab,
164 nLastMergedRow = nRow;
177 if (
static_cast<const SvxAdjustItem&
>(rItem).GetAdjust() == SvxAdjust::Left )
181 bool bSimple = (
pE->aSel.nStartPara ==
pE->aSel.nEndPara );
186 if (eState == SfxItemState::DONTCARE)
188 else if (eState == SfxItemState::SET)
193 != SvxEscapement::Off )
201 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
206 OUString aValStr, aNumStr;
208 sal_uInt32 nNumForm = 0;
212 aNumStr = *
pE->pNumStr;
214 aValStr = *
pE->pValStr;
216 nNumForm, eNumLang, aValStr, aNumStr, *pFormatter );
220 auto pAttr = std::make_unique<ScPatternAttr>( pDocPool );
221 pAttr->GetFromEditItemSet( &aSet );
222 SfxItemSet* pAttrItemSet = &pAttr->GetItemSet();
223 if (!aNumStr.isEmpty())
233 pAttrItemSet->
Put( *pItem );
235 pAttrItemSet->
Put( *pItem );
237 pAttrItemSet->
Put( *pItem );
240 pAttrItemSet->
Put( *pItem );
242 pAttrItemSet->
Put( *pItem );
244 pAttrItemSet->
Put( *pItem );
246 pAttrItemSet->
Put( *pItem );
248 pAttrItemSet->
Put( *pItem );
265 pAttrItemSet->
Put(*pNumFmt);
266 if ( pFont || pHeight || pWeight || pPosture )
271 SvtScriptType::ASIAN, SvtScriptType::COMPLEX };
274 if ( nScriptType & nScript )
300 if (
pE->nColOverlap > 1 ||
pE->nRowOverlap > 1 )
304 pAttrItemSet->
Put( aMerge );
306 if (
pE->nColOverlap > 1 )
308 nCol +
pE->nColOverlap - 1, nRow, nTab,
310 if (
pE->nRowOverlap > 1 )
312 nRO = nRow +
pE->nRowOverlap - 1;
316 if ( nRO > nOverlapRowMax )
317 nOverlapRowMax = nRO;
319 if (
pE->nColOverlap > 1 &&
pE->nRowOverlap > 1 )
321 nCol +
pE->nColOverlap - 1, nRO, nTab,
326 pAttr->SetStyleSheet(
const_cast<ScStyleSheet*
>(pStyleSheet) );
327 auto rAttrItemSet2 =
mpDoc->
SetPattern( nCol, nRow, nTab, std::move(pAttr) )->GetItemSet();
339 if (!aValStr.isEmpty())
341 else if ( !
pE->aSel.HasRange() )
350 if(
pE->bEntirePara )
359 bool bTextFormat =
false;
363 sal_uInt32 nNumFmt = pNumFmt->GetValue();
365 if (
nType == SvNumFormatType::TEXT)
373 if (bNumbersEnglishUS)
380 sal_uInt32 nNewIndex =
383 OSL_ENSURE( nNewIndex !=
nIndex,
"ScEEImport::WriteToDocument: NumbersEnglishUS not a built-in format?");
393 aStr =
aStr.replaceAll(
"\t",
" " );
394 aStr =
aStr.replaceAll(
"\n",
" " );
411 else if (std::unique_ptr<EditTextObject> pTextObject = IsValidSel(*
mpEngine,
pE->aSel) ?
mpEngine->CreateTextObject(
pE->aSel) :
nullptr)
416 if ( !
pE->maImageList.empty() )
428 pProgress->SetStateOnPercent( ++nProgress );
434 if ( !rColWidths.empty() )
437 pProgress->SetState( nProgress, nEndCol - nStartCol + 1 );
438 for (
SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ )
440 sal_uInt16 nWidth = 0;
441 ColWidthsMap::const_iterator it = rColWidths.find( nCol );
442 if ( it != rColWidths.end() )
446 pProgress->SetState( ++nProgress );
462 for (
SCROW nRow = nStartRow; nRow <= nEndRow; nRow++ )
464 RowHeightMap::const_iterator it =
maRowHeights.find( nRow );
465 sal_uInt16 nHeight = it ==
maRowHeights.end() ? 0 : it->second;
475 for (
size_t i = 0, nListSize =
mpParser->ListSize();
i < nListSize; ++
i )
478 if ( !
pE->maImageList.empty() )
490 if (
pE->maImageList.empty() )
492 bool bHasGraphics =
false;
495 nWidth = nHeight = 0;
497 for (
const std::unique_ptr<ScHTMLImage> & pImage :
pE->maImageList)
507 nWidth += aLogicSize.
Width();
508 else if ( nWidth < aLogicSize.
Width() )
509 nWidth = aLogicSize.
Width();
511 nHeight += aLogicSize.
Height();
512 else if ( nHeight < aLogicSize.
Height() )
513 nHeight = aLogicSize.
Height();
519 ColWidthsMap::const_iterator it = rColWidths.find( nCol );
520 if ( it != rColWidths.end() )
521 nThisWidth = it->second;
523 SCCOL nColSpanCol = nCol +
pE->nColOverlap;
524 for (
SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ )
526 ColWidthsMap::const_iterator it2 = rColWidths.find( nC );
527 if ( it2 != rColWidths.end() )
528 nColWidths += it2->second;
530 if ( nWidth > nColWidths )
532 rColWidths[ nCol ] = nWidth - nColWidths + nThisWidth;
535 SCROW nRowSpan =
pE->nRowOverlap;
537 assert(nRowSpan != 0);
545 for (
SCROW nR = nRow; nR < nRow + nRowSpan; nR++ )
547 RowHeightMap::const_iterator it2 =
maRowHeights.find( nR );
549 if ( nHeight > nRowHeight )
560 if (
pE->maImageList.empty() )
568 SdrPage* pPage = pModel->
GetPage(
static_cast<sal_uInt16
>(nTab) );
571 Point aCellInsertPos(
575 Point aInsertPos( aCellInsertPos );
579 for (
const std::unique_ptr<ScHTMLImage> & pImage :
pE->maImageList)
586 aInsertPos.
setY( aCellInsertPos.
Y() );
590 aInsertPos.
setX( aCellInsertPos.
X() );
596 aInsertPos += aSpace;
613 pObj->SetName( pI->
aURL );
620 pObj->SetGraphicLink( pI->
aURL );
622 pObj->SetLogicRect( aRect );
640 pPool->FreezeIdRanges();
650 pPool->SetSecondaryPool(
nullptr );
bool ValidCol(SCCOL nCol, SCCOL nMaxCol)
static OutputDevice * GetDefaultDevice()
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
sal_Int32 GetParagraphCount() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
SC_DLLPUBLIC bool SetEditText(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
This method manages the lifecycle of the passed edit text object.
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
bool ValidRow(SCROW nRow) const
SC_DLLPUBLIC tools::Long GetColOffset(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bApi)
SC_DLLPUBLIC ScDocumentPool * GetPool()
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
SfxObjectShell * GetDocumentShell() const
SC_DLLPUBLIC void SetPattern(const ScAddress &, const ScPatternAttr &rAttr)
bool ValidCol(SCCOL nCol) const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
SC_DLLPUBLIC void SetRowHeight(SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight)
SC_DLLPUBLIC void SetColWidth(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC tools::Long GetRowOffset(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
ScEEImport(ScDocument *pDoc, const ScRange &rRange)
bool GraphicSize(SCCOL nCol, SCROW nRow, ScEEParseEntry *)
virtual void WriteToDocument(bool bSizeColsRows=false, double nOutputFactor=1.0, SvNumberFormatter *pFormatter=nullptr, bool bConvertDate=true, bool bConvertScientific=true) override
RowHeightMap maRowHeights
virtual ErrCode Read(SvStream &rStream, const OUString &rBaseURL) override
std::unique_ptr< ScTabEditEngine > mpEngine
void InsertGraphic(SCCOL nCol, SCROW nRow, SCTAB nTab, ScEEParseEntry *)
virtual ~ScEEImport() override
std::unique_ptr< ScEEParser > mpParser
void NewActEntry(const ScEEParseEntry *)
std::vector< std::shared_ptr< ScEEParseEntry > > maList
std::shared_ptr< ScEEParseEntry > mxActEntry
rtl::Reference< SfxItemPool > pDocPool
rtl::Reference< SfxItemPool > pPool
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
static SC_DLLPUBLIC double nScreenPPTY
Vertical pixel per twips factor.
static SC_DLLPUBLIC sal_uInt16 GetScriptedWhichID(SvtScriptType nScriptType, sal_uInt16 nWhich)
Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
static SC_DLLPUBLIC const CharClass & getCharClass()
static SC_DLLPUBLIC ::tools::Long nLastRowHeightExtra
const ScStyleSheet * GetStyleSheet() const
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
static double GetTableDataOptionsValNum(sal_uInt32 &nNumForm, LanguageType &eNumLang, const OUString &aValStr, std::u16string_view aNumStr, SvNumberFormatter &rFormatter)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
std::unique_ptr< SfxPoolItem > CloneSetWhich(sal_uInt16 nNewWhich) const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
tools::Long AdjustWidth(tools::Long n)
constexpr tools::Long Width() const
void setExtraHeight(sal_uInt16 nH)
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
constexpr sal_uInt16 EE_CHAR_START(EE_PARA_END+1)
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
constexpr sal_uInt16 EE_CHAR_END(EE_CHAR_START+32)
std::map< SCCOL, sal_uInt16 > ColWidthsMap
void ScLimitSizeOnDrawPage(Size &rSize, Point &rPos, const Size &rPage)
#define LANGUAGE_ENGLISH_US
std::unique_ptr< sal_Int32[]> pData
OString strip(const OString &rIn, char c)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
constexpr TypedWhichId< SvxShadowItem > ATTR_SHADOW(152)
constexpr TypedWhichId< SvxLanguageItem > ATTR_LANGUAGE_FORMAT(147)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< SvxVerJustifyItem > ATTR_VER_JUSTIFY(132)
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
constexpr TypedWhichId< ScLineBreakCell > ATTR_LINEBREAK(139)
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
std::optional< Graphic > oGraphic
Store parameters used in the ScDocument::SetString() method.
bool mbHandleApostrophe
When true, treat input with a leading apostrophe as an escape character for all content,...
bool mbCheckLinkFormula
When true and the string results in a compiled formula, check the formula tokens for presence of func...
bool mbDetectScientificNumberFormat
bool mbDetectNumberFormat
Specify which number formats are detected: mbDetectNumberFormat=true && mbDetectScientificNumberForma...
SvNumberFormatter * mpNumFormatter
Stores the pointer to the number formatter instance to be used during number format detection.
@ Always
Set Text number format if the input string can be parsed as a number or formula text.
@ SpecialNumberOnly
Set Text number format only when the input string is considered a special number but we only want to ...
TextFormatPolicy meSetTextNumFormat
Determine when to set the 'Text' number format to the cell where the input string is being set.