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 );
121 SCCOL nStartCol, nEndCol;
122 SCROW nStartRow, nEndRow;
124 SCROW nOverlapRowMax, nLastMergedRow;
134 bool bHasGraphics =
false;
138 bool bNumbersEnglishUS =
false;
142 bNumbersEnglishUS = officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::get();
149 SCROW nRow = nStartRow +
pE->nRow;
150 if ( nRow != nLastMergedRow )
152 SCCOL nCol = nStartCol +
pE->nCol + nMergeColAdd;
155 if (nRow <= nOverlapRowMax && mpDoc->
ValidCol(nCol))
157 while ( nCol <= mpDoc->MaxCol() &&
mpDoc->
HasAttrib( nCol, nRow, nTab,
163 nLastMergedRow = nRow;
176 if (
static_cast<const SvxAdjustItem&
>(rItem).GetAdjust() == SvxAdjust::Left )
180 bool bSimple = (
pE->aSel.nStartPara ==
pE->aSel.nEndPara );
185 if (eState == SfxItemState::DONTCARE)
187 else if (eState == SfxItemState::SET)
192 != SvxEscapement::Off )
200 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
205 OUString aValStr, aNumStr;
207 sal_uInt32 nNumForm = 0;
211 aNumStr = *
pE->pNumStr;
213 aValStr = *
pE->pValStr;
215 nNumForm, eNumLang, aValStr, aNumStr, *pFormatter );
219 auto pAttr = std::make_unique<ScPatternAttr>( pDocPool );
220 pAttr->GetFromEditItemSet( &aSet );
221 SfxItemSet* pAttrItemSet = &pAttr->GetItemSet();
222 if (!aNumStr.isEmpty())
232 pAttrItemSet->
Put( *pItem );
234 pAttrItemSet->
Put( *pItem );
236 pAttrItemSet->
Put( *pItem );
239 pAttrItemSet->
Put( *pItem );
241 pAttrItemSet->
Put( *pItem );
243 pAttrItemSet->
Put( *pItem );
245 pAttrItemSet->
Put( *pItem );
247 pAttrItemSet->
Put( *pItem );
264 pAttrItemSet->
Put(*pNumFmt);
265 if ( pFont || pHeight || pWeight || pPosture )
270 SvtScriptType::ASIAN, SvtScriptType::COMPLEX };
273 if ( nScriptType & nScript )
299 if (
pE->nColOverlap > 1 ||
pE->nRowOverlap > 1 )
303 pAttrItemSet->
Put( aMerge );
305 if (
pE->nColOverlap > 1 )
307 nCol +
pE->nColOverlap - 1, nRow, nTab,
309 if (
pE->nRowOverlap > 1 )
311 nRO = nRow +
pE->nRowOverlap - 1;
315 if ( nRO > nOverlapRowMax )
316 nOverlapRowMax = nRO;
318 if (
pE->nColOverlap > 1 &&
pE->nRowOverlap > 1 )
320 nCol +
pE->nColOverlap - 1, nRO, nTab,
325 pAttr->SetStyleSheet(
const_cast<ScStyleSheet*
>(pStyleSheet) );
326 auto rAttrItemSet2 =
mpDoc->
SetPattern( nCol, nRow, nTab, std::move(pAttr) )->GetItemSet();
338 if (!aValStr.isEmpty())
340 else if ( !
pE->aSel.HasRange() )
349 if(
pE->bEntirePara )
358 bool bTextFormat =
false;
362 sal_uInt32 nNumFmt = pNumFmt->GetValue();
364 if (
nType == SvNumFormatType::TEXT)
372 if (bNumbersEnglishUS)
379 sal_uInt32 nNewIndex =
382 OSL_ENSURE( nNewIndex !=
nIndex,
"ScEEImport::WriteToDocument: NumbersEnglishUS not a built-in format?");
392 aStr =
aStr.replaceAll(
"\t",
" " );
393 aStr =
aStr.replaceAll(
"\n",
" " );
406 else if (std::unique_ptr<EditTextObject> pTextObject = IsValidSel(*
mpEngine,
pE->aSel) ?
mpEngine->CreateTextObject(
pE->aSel) :
nullptr)
411 if ( !
pE->maImageList.empty() )
423 pProgress->SetStateOnPercent( ++nProgress );
429 if ( !rColWidths.empty() )
432 pProgress->SetState( nProgress, nEndCol - nStartCol + 1 );
433 for (
SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ )
435 sal_uInt16 nWidth = 0;
436 ColWidthsMap::const_iterator it = rColWidths.find( nCol );
437 if ( it != rColWidths.end() )
441 pProgress->SetState( ++nProgress );
457 for (
SCROW nRow = nStartRow; nRow <= nEndRow; nRow++ )
459 RowHeightMap::const_iterator it =
maRowHeights.find( nRow );
460 sal_uInt16 nHeight = it ==
maRowHeights.end() ? 0 : it->second;
470 for (
size_t i = 0, nListSize =
mpParser->ListSize();
i < nListSize; ++
i )
473 if ( !
pE->maImageList.empty() )
485 if (
pE->maImageList.empty() )
487 bool bHasGraphics =
false;
490 nWidth = nHeight = 0;
492 for (
const std::unique_ptr<ScHTMLImage> & pImage :
pE->maImageList)
502 nWidth += aLogicSize.
Width();
503 else if ( nWidth < aLogicSize.
Width() )
504 nWidth = aLogicSize.
Width();
506 nHeight += aLogicSize.
Height();
507 else if ( nHeight < aLogicSize.
Height() )
508 nHeight = aLogicSize.
Height();
514 ColWidthsMap::const_iterator it = rColWidths.find( nCol );
515 if ( it != rColWidths.end() )
516 nThisWidth = it->second;
518 SCCOL nColSpanCol = nCol +
pE->nColOverlap;
519 for (
SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ )
521 ColWidthsMap::const_iterator it2 = rColWidths.find( nC );
522 if ( it2 != rColWidths.end() )
523 nColWidths += it2->second;
525 if ( nWidth > nColWidths )
527 rColWidths[ nCol ] = nWidth - nColWidths + nThisWidth;
530 SCROW nRowSpan =
pE->nRowOverlap;
532 assert(nRowSpan != 0);
540 for (
SCROW nR = nRow; nR < nRow + nRowSpan; nR++ )
542 RowHeightMap::const_iterator it2 =
maRowHeights.find( nR );
544 if ( nHeight > nRowHeight )
555 if (
pE->maImageList.empty() )
563 SdrPage* pPage = pModel->
GetPage(
static_cast<sal_uInt16
>(nTab) );
566 Point aCellInsertPos(
570 Point aInsertPos( aCellInsertPos );
574 for (
const std::unique_ptr<ScHTMLImage> & pImage :
pE->maImageList)
579 aInsertPos.AdjustX(aLogicSize.
Width() );
580 aInsertPos.AdjustX(aSpace.X() );
581 aInsertPos.setY( aCellInsertPos.Y() );
585 aInsertPos.setX( aCellInsertPos.X() );
586 aInsertPos.AdjustY(aLogicSize.
Height() );
587 aInsertPos.AdjustY(aSpace.Y() );
591 aInsertPos += aSpace;
608 pObj->SetName( pI->
aURL );
615 pObj->SetGraphicLink( pI->
aURL );
617 pObj->SetLogicRect( aRect );
635 pPool->FreezeIdRanges();
645 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
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 *)
RowHeightMap maRowHeights
virtual ErrCode Read(SvStream &rStream, const OUString &rBaseURL) override
std::unique_ptr< ScTabEditEngine > mpEngine
virtual void WriteToDocument(bool bSizeColsRows=false, double nOutputFactor=1.0, SvNumberFormatter *pFormatter=nullptr, bool bConvertDate=true) override
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 mbDetectNumberFormat
When true, we try to detect special number format (dates etc) from the input string,...
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.