39 #include <document.hxx>
47 #include <progress.hxx>
50 #include <fuinsert.hxx>
52 #include <globstr.hrc>
80 mpParser->GetDimensions( nEndCol, nEndRow );
117 SCCOL nStartCol, nEndCol;
118 SCROW nStartRow, nEndRow;
120 SCROW nOverlapRowMax, nLastMergedRow;
130 bool bHasGraphics =
false;
134 bool bNumbersEnglishUS =
false;
147 if ( nRow != nLastMergedRow )
149 SCCOL nCol = nStartCol + pE->
nCol + nMergeColAdd;
152 if (nRow <= nOverlapRowMax && mpDoc->
ValidCol(nCol))
154 while ( nCol <= mpDoc->MaxCol() &&
mpDoc->
HasAttrib( nCol, nRow, nTab,
160 nLastMergedRow = nRow;
173 if ( static_cast<const SvxAdjustItem&>(rItem).GetAdjust() == SvxAdjust::Left )
182 if (eState == SfxItemState::DONTCARE)
184 else if (eState == SfxItemState::SET)
188 if ( static_cast<SvxEscapement>(static_cast<const SvxEscapementItem*>(pItem)->GetEnumValue())
189 != SvxEscapement::Off )
197 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
202 OUString aValStr, aNumStr;
204 sal_uInt32 nNumForm = 0;
212 nNumForm, eNumLang, aValStr, aNumStr, *pFormatter );
216 auto pAttr = std::make_unique<ScPatternAttr>( pDocPool );
217 pAttr->GetFromEditItemSet( &aSet );
218 SfxItemSet* pAttrItemSet = &pAttr->GetItemSet();
219 if (!aNumStr.isEmpty())
229 pAttrItemSet->
Put( *pItem );
231 pAttrItemSet->
Put( *pItem );
233 pAttrItemSet->
Put( *pItem );
236 pAttrItemSet->
Put( *pItem );
238 pAttrItemSet->
Put( *pItem );
240 pAttrItemSet->
Put( *pItem );
242 pAttrItemSet->
Put( *pItem );
244 pAttrItemSet->
Put( *pItem );
261 pAttrItemSet->
Put(*pNumFmt);
262 if ( pFont || pHeight || pWeight || pPosture )
267 SvtScriptType::ASIAN, SvtScriptType::COMPLEX };
270 if ( nScriptType & nScript )
300 pAttrItemSet->
Put( aMerge );
312 if ( nRO > nOverlapRowMax )
313 nOverlapRowMax = nRO;
322 pAttr->SetStyleSheet( const_cast<ScStyleSheet*>(pStyleSheet) );
323 auto rAttrItemSet2 =
mpDoc->
SetPattern( nCol, nRow, nTab, std::move(pAttr) )->GetItemSet();
335 if (!aValStr.isEmpty())
355 bool bTextFormat =
false;
358 if (rAttrItemSet2.GetItemState(
ATTR_VALUE_FORMAT,
false, &pNumFmt) == SfxItemState::SET)
362 if (nType == SvNumFormatType::TEXT)
370 if (bNumbersEnglishUS)
377 sal_uInt32 nNewIndex =
380 OSL_ENSURE( nNewIndex != nIndex,
"ScEEImport::WriteToDocument: NumbersEnglishUS not a built-in format?");
390 aStr = aStr.replaceAll(
"\t",
" " );
391 aStr = aStr.replaceAll(
"\n",
" " );
404 else if (std::unique_ptr<EditTextObject> pTextObject = IsValidSel(*
mpEngine, pE->
aSel) ?
mpEngine->CreateTextObject(pE->
aSel) :
nullptr)
417 pRangeNames->
insert( pData );
421 pProgress->SetStateOnPercent( ++nProgress );
427 if ( !rColWidths.empty() )
430 pProgress->SetState( nProgress, nEndCol - nStartCol + 1 );
431 for (
SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ )
433 sal_uInt16 nWidth = 0;
434 ColWidthsMap::const_iterator it = rColWidths.find( nCol );
435 if ( it != rColWidths.end() )
439 pProgress->SetState( ++nProgress );
455 for (
SCROW nRow = nStartRow; nRow <= nEndRow; nRow++ )
457 RowHeightMap::const_iterator it =
maRowHeights.find( nRow );
458 sal_uInt16 nHeight = it ==
maRowHeights.end() ? 0 : it->second;
468 for (
size_t i = 0, nListSize =
mpParser->ListSize();
i < nListSize; ++
i )
485 bool bHasGraphics =
false;
488 nWidth = nHeight = 0;
490 for (
const std::unique_ptr<ScHTMLImage> & pImage : pE->
maImageList)
500 nWidth += aLogicSize.
Width();
501 else if ( nWidth < aLogicSize.
Width() )
502 nWidth = aLogicSize.
Width();
504 nHeight += aLogicSize.
Height();
505 else if ( nHeight < aLogicSize.
Height() )
506 nHeight = aLogicSize.
Height();
512 ColWidthsMap::const_iterator it = rColWidths.find( nCol );
513 if ( it != rColWidths.end() )
514 nThisWidth = it->second;
517 for (
SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ )
519 ColWidthsMap::const_iterator it2 = rColWidths.find( nC );
520 if ( it2 != rColWidths.end() )
521 nColWidths += it2->second;
523 if ( nWidth > nColWidths )
525 rColWidths[ nCol ] = nWidth - nColWidths + nThisWidth;
532 for (
SCROW nR = nRow; nR < nRow + nRowSpan; nR++ )
534 RowHeightMap::const_iterator it2 =
maRowHeights.find( nR );
536 if ( nHeight > nRowHeight )
555 SdrPage* pPage = pModel->
GetPage( static_cast<sal_uInt16>(nTab) );
558 Point aCellInsertPos(
562 Point aInsertPos( aCellInsertPos );
566 for (
const std::unique_ptr<ScHTMLImage> & pImage : pE->
maImageList)
571 aInsertPos.AdjustX(aLogicSize.
Width() );
572 aInsertPos.AdjustX(aSpace.X() );
573 aInsertPos.setY( aCellInsertPos.Y() );
577 aInsertPos.setX( aCellInsertPos.X() );
578 aInsertPos.AdjustY(aLogicSize.
Height() );
579 aInsertPos.AdjustY(aSpace.Y() );
583 aInsertPos += aSpace;
void setExtraHeight(sal_uInt16 nH)
bool GraphicSize(SCCOL nCol, SCROW nRow, ScEEParseEntry *)
std::vector< std::unique_ptr< ScHTMLImage > > maImageList
Store parameters used in the ScDocument::SetString() method.
constexpr TypedWhichId< SvxLanguageItem > ATTR_LANGUAGE_FORMAT(147)
bool mbHandleApostrophe
When true, treat input with a leading apostrophe as an escape character for a numeric value content...
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
#define LANGUAGE_ENGLISH_US
SvNumberFormatter * mpNumFormatter
Stores the pointer to the number formatter instance to be used during number format detection...
std::unique_ptr< ContentProperties > pData
void SetName(const OUString &rStr, const bool bSetChanged=true)
void NewActEntry(const ScEEParseEntry *)
bool mbCheckLinkFormula
When true and the string results in a compiled formula, check the formula tokens for presence of func...
std::map< SCCOL, sal_uInt16 > ColWidthsMap
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+15)
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
for(size_t a(0);a< count;a++)
constexpr TypedWhichId< ScLineBreakCell > ATTR_LINEBREAK(139)
std::unique_ptr< ScTabEditEngine > mpEngine
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
TextFormatPolicy meSetTextNumFormat
Determine when to set the 'Text' number format to the cell where the input string is being set...
SC_DLLPUBLIC ScDocumentPool * GetPool()
static OutputDevice * GetDefaultDevice()
SC_DLLPUBLIC SCROW MaxRow() const
constexpr TypedWhichId< SvxShadowItem > ATTR_SHADOW(152)
SC_DLLPUBLIC void SetColWidth(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
static SC_DLLPUBLIC sal_uInt16 GetScriptedWhichID(SvtScriptType nScriptType, sal_uInt16 nWhich)
Map ATTR_((CJK|CTL)_)?FONT_...
ScEEImport(ScDocument *pDoc, const ScRange &rRange)
bool IsNumbersEnglishUS() const
std::unique_ptr< Graphic > pGraphic
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
std::optional< OUString > pValStr
SC_DLLPUBLIC bool SetEditText(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
This method manages the lifecycle of the passed edit text object.
bool ValidCol(SCCOL nCol, SCCOL nMaxCol)
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
SC_DLLPUBLIC SCCOL MaxCol() const
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
SC_DLLPUBLIC void SetPattern(const ScAddress &, const ScPatternAttr &rAttr)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
std::vector< std::shared_ptr< ScEEParseEntry > > maList
bool ValidCol(SCCOL nCol) const
constexpr TypedWhichId< SvxVerJustifyItem > ATTR_VER_JUSTIFY(132)
static SC_DLLPUBLIC double nScreenPPTY
Vertical pixel per twips factor.
Set Text number format only when the input string is considered a special number but we only want to ...
void ScLimitSizeOnDrawPage(Size &rSize, Point &rPos, const Size &rPage)
SC_DLLPUBLIC bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
const ScStyleSheet * GetStyleSheet() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
std::unique_ptr< ScEEParser > mpParser
RowHeightMap maRowHeights
tools::Long Width() const
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
constexpr sal_uInt16 EE_CHAR_START(EE_PARA_END+1)
static double GetTableDataOptionsValNum(sal_uInt32 &nNumForm, LanguageType &eNumLang, const OUString &aValStr, const OUString &aNumStr, SvNumberFormatter &rFormatter)
OUString ScResId(const char *pId)
SC_DLLPUBLIC void SetRowHeight(SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
virtual void SetLogicRect(const tools::Rectangle &rRect)
constexpr sal_uInt16 EE_CHAR_END(EE_CHAR_START+32)
std::unique_ptr< SfxPoolItem > CloneSetWhich(sal_uInt16 nNewWhich) const
std::optional< OUString > pNumStr
void SetGraphicLink(const OUString &rFileName)
sal_Int32 GetParagraphCount() const
Point PixelToLogic(const Point &rDevicePt) const
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
std::shared_ptr< ScEEParseEntry > mxActEntry
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void InsertGraphic(SCCOL nCol, SCROW nRow, SCTAB nTab, ScEEParseEntry *)
static void Free(SfxItemPool *pPool)
bool ValidRow(SCROW nRow) const
bool mbDetectNumberFormat
When true, we try to detect special number format (dates etc) from the input string, when false, we only try to detect a basic decimal number format.
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
OString strip(const OString &rIn, char c)
tools::Long AdjustWidth(tools::Long n)
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
tools::Long Height() const
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
virtual void WriteToDocument(bool bSizeColsRows=false, double nOutputFactor=1.0, SvNumberFormatter *pFormatter=nullptr, bool bConvertDate=true) override
Set Text number format if the input string can be parsed as a number or formula text.
tools::Long AdjustHeight(tools::Long n)
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
SfxObjectShell * GetDocumentShell() const
virtual ~ScEEImport() override
constexpr sal_uInt16 EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
static SC_DLLPUBLIC::tools::Long nLastRowHeightExtra
std::optional< OUString > pName
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
virtual ErrCode Read(SvStream &rStream, const OUString &rBaseURL) override
SC_DLLPUBLIC sal_uLong GetColOffset(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
void SetSecondaryPool(SfxItemPool *pPool)
SC_DLLPUBLIC sal_uLong GetRowOffset(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const