LibreOffice Module sc (master) 1
eeimpars.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
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 http://mozilla.org/MPL/2.0/.
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 http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <scitems.hxx>
21#include <editeng/eeitem.hxx>
22
24#include <editeng/editobj.hxx>
26#include <editeng/langitem.hxx>
28#include <svx/svdograf.hxx>
29#include <svx/svdpage.hxx>
30#include <sfx2/sfxhtml.hxx>
31#include <svl/numformat.hxx>
32#include <svl/zforlist.hxx>
33#include <vcl/virdev.hxx>
34#include <vcl/svapp.hxx>
37#include <comphelper/string.hxx>
38#include <osl/diagnose.h>
39#include <officecfg/Office/Common.hxx>
40
41#include <eeimport.hxx>
42#include <global.hxx>
43#include <document.hxx>
44#include <editutil.hxx>
45#include <docpool.hxx>
46#include <attrib.hxx>
47#include <patattr.hxx>
48#include <eeparser.hxx>
49#include <drwlayer.hxx>
50#include <rangenam.hxx>
51#include <progress.hxx>
52#include <stringutil.hxx>
53#include <rowheightcontext.hxx>
54#include <fuinsert.hxx>
55
56#include <globstr.hrc>
57#include <scresid.hxx>
58
59#include <memory>
60
61ScEEImport::ScEEImport( ScDocument* pDocP, const ScRange& rRange ) :
62 maRange( rRange ),
63 mpDoc( pDocP )
64{
65 const ScPatternAttr* pPattern = mpDoc->GetPattern(
67 mpEngine.reset( new ScTabEditEngine(*pPattern, mpDoc->GetEditPool(), mpDoc, mpDoc->GetEditPool()) );
68 mpEngine->SetUpdateLayout( false );
69 mpEngine->EnableUndo( false );
70}
71
73{
74 // Sequence important, or else we crash in some dtor!
75 // Is guaranteed as ScEEImport is base class
76}
77
78ErrCode ScEEImport::Read( SvStream& rStream, const OUString& rBaseURL )
79{
80 ErrCode nErr = mpParser->Read( rStream, rBaseURL );
81
82 SCCOL nEndCol;
83 SCROW nEndRow;
84 mpParser->GetDimensions( nEndCol, nEndRow );
85 if ( nEndCol != 0 )
86 {
87 nEndCol += maRange.aStart.Col() - 1;
88 if ( nEndCol > mpDoc->MaxCol() )
89 nEndCol = mpDoc->MaxCol();
90 }
91 else
92 nEndCol = maRange.aStart.Col();
93 if ( nEndRow != 0 )
94 {
95 nEndRow += maRange.aStart.Row() - 1;
96 if ( nEndRow > mpDoc->MaxRow() )
97 nEndRow = mpDoc->MaxRow();
98 }
99 else
100 nEndRow = maRange.aStart.Row();
101 maRange.aEnd.Set( nEndCol, nEndRow, maRange.aStart.Tab() );
102
103 return nErr;
104}
105
106namespace
107{
108 bool IsValidSel(const ScTabEditEngine& rEngine, const ESelection& rSel)
109 {
110 const auto nParaCount = rEngine.GetParagraphCount();
111 return rSel.nStartPara < nParaCount && rSel.nEndPara < nParaCount;
112 }
113}
114
115void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate,
116 bool bConvertScientific )
117{
118 std::unique_ptr<ScProgress> pProgress( new ScProgress( mpDoc->GetDocumentShell(),
119 ScResId( STR_LOAD_DOC ), mpParser->ListSize(), true ) );
120 sal_uLong nProgress = 0;
121
122 SCCOL nStartCol, nEndCol;
123 SCROW nStartRow, nEndRow;
124 SCTAB nTab;
125 SCROW nOverlapRowMax, nLastMergedRow;
126 SCCOL nMergeColAdd;
127 nStartCol = maRange.aStart.Col();
128 nStartRow = maRange.aStart.Row();
129 nTab = maRange.aStart.Tab();
130 nEndCol = maRange.aEnd.Col();
131 nEndRow = maRange.aEnd.Row();
132 nOverlapRowMax = 0;
133 nMergeColAdd = 0;
134 nLastMergedRow = SCROW_MAX;
135 bool bHasGraphics = false;
137 if (!pFormatter)
138 pFormatter = mpDoc->GetFormatTable();
139 bool bNumbersEnglishUS = false;
141 {
142 // Automatic language option selected. Check for the global 'use US English' option.
143 bNumbersEnglishUS = officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::get();
144 }
145 ScDocumentPool* pDocPool = mpDoc->GetPool();
146 ScRangeName* pRangeNames = mpDoc->GetRangeName();
147 for ( size_t i = 0, n = mpParser->ListSize(); i < n; ++i )
148 {
149 pE = mpParser->ListEntry( i );
150 SCROW nRow = nStartRow + pE->nRow;
151 if ( nRow != nLastMergedRow )
152 nMergeColAdd = 0;
153 SCCOL nCol = nStartCol + pE->nCol + nMergeColAdd;
154 // Determine RowMerge
155 // Pure ColMerge and ColMerge of the first MergeRow already done during parsing
156 if (nRow <= nOverlapRowMax && mpDoc->ValidCol(nCol))
157 {
158 while ( nCol <= mpDoc->MaxCol() && mpDoc->HasAttrib( nCol, nRow, nTab,
159 nCol, nRow, nTab, HasAttrFlags::Overlapped ) )
160 {
161 nCol++;
162 nMergeColAdd++;
163 }
164 nLastMergedRow = nRow;
165 }
166 // Add for second run
167 pE->nCol = nCol;
168 pE->nRow = nRow;
169 if ( mpDoc->ValidCol(nCol) && mpDoc->ValidRow(nRow) )
170 {
171 SfxItemSet aSet = mpEngine->GetAttribs( pE->aSel );
172 // Remove default: we set left/right ourselves depending on Text or
173 // Number
174 // EditView.GetAttribs always returns complete Set filled with
175 // defaults
176 const SfxPoolItem& rItem = aSet.Get( EE_PARA_JUST );
177 if ( static_cast<const SvxAdjustItem&>(rItem).GetAdjust() == SvxAdjust::Left )
178 aSet.ClearItem( EE_PARA_JUST );
179
180 // Test whether simple String without mixed attributes
181 bool bSimple = ( pE->aSel.nStartPara == pE->aSel.nEndPara );
182 for (sal_uInt16 nId = EE_CHAR_START; nId <= EE_CHAR_END && bSimple; nId++)
183 {
184 const SfxPoolItem* pItem = nullptr;
185 SfxItemState eState = aSet.GetItemState( nId, true, &pItem );
186 if (eState == SfxItemState::DONTCARE)
187 bSimple = false;
188 else if (eState == SfxItemState::SET)
189 {
190 if ( nId == EE_CHAR_ESCAPEMENT ) // Super-/Subscript always via EE
191 {
192 if ( static_cast<SvxEscapement>(static_cast<const SvxEscapementItem*>(pItem)->GetEnumValue())
193 != SvxEscapement::Off )
194 bSimple = false;
195 }
196 }
197 }
198 if ( bSimple )
199 { // Contains field commands?
200 SfxItemState eFieldState = aSet.GetItemState( EE_FEATURE_FIELD, false );
201 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
202 bSimple = false;
203 }
204
205 // HTML
206 OUString aValStr, aNumStr;
207 double fVal = 0.0;
208 sal_uInt32 nNumForm = 0;
209 LanguageType eNumLang = LANGUAGE_NONE;
210 if ( pE->pNumStr )
211 { // SDNUM needs to be if SDVAL
212 aNumStr = *pE->pNumStr;
213 if ( pE->pValStr )
214 aValStr = *pE->pValStr;
216 nNumForm, eNumLang, aValStr, aNumStr, *pFormatter );
217 }
218
219 // Set attributes
220 auto pAttr = std::make_unique<ScPatternAttr>( pDocPool );
221 pAttr->GetFromEditItemSet( &aSet );
222 SfxItemSet* pAttrItemSet = &pAttr->GetItemSet();
223 if (!aNumStr.isEmpty())
224 {
225 pAttrItemSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumForm ) );
226 pAttrItemSet->Put( SvxLanguageItem( eNumLang, ATTR_LANGUAGE_FORMAT ) );
227 }
228 const SfxItemSet& rESet = pE->aItemSet;
229 if ( rESet.Count() )
230 {
231 const SfxPoolItem* pItem;
232 if ( rESet.GetItemState( ATTR_BACKGROUND, false, &pItem) == SfxItemState::SET )
233 pAttrItemSet->Put( *pItem );
234 if ( rESet.GetItemState( ATTR_BORDER, false, &pItem) == SfxItemState::SET )
235 pAttrItemSet->Put( *pItem );
236 if ( rESet.GetItemState( ATTR_SHADOW, false, &pItem) == SfxItemState::SET )
237 pAttrItemSet->Put( *pItem );
238 // HTML
239 if ( rESet.GetItemState( ATTR_HOR_JUSTIFY, false, &pItem) == SfxItemState::SET )
240 pAttrItemSet->Put( *pItem );
241 if ( rESet.GetItemState( ATTR_VER_JUSTIFY, false, &pItem) == SfxItemState::SET )
242 pAttrItemSet->Put( *pItem );
243 if ( rESet.GetItemState( ATTR_LINEBREAK, false, &pItem) == SfxItemState::SET )
244 pAttrItemSet->Put( *pItem );
245 if ( rESet.GetItemState( ATTR_FONT_COLOR, false, &pItem) == SfxItemState::SET )
246 pAttrItemSet->Put( *pItem );
247 if ( rESet.GetItemState( ATTR_FONT_UNDERLINE, false, &pItem) == SfxItemState::SET )
248 pAttrItemSet->Put( *pItem );
249 // HTML LATIN/CJK/CTL script type dependent
250 const SfxPoolItem* pFont;
251 if ( rESet.GetItemState( ATTR_FONT, false, &pFont) != SfxItemState::SET )
252 pFont = nullptr;
253 const SfxPoolItem* pHeight;
254 if ( rESet.GetItemState( ATTR_FONT_HEIGHT, false, &pHeight) != SfxItemState::SET )
255 pHeight = nullptr;
256 const SfxPoolItem* pWeight;
257 if ( rESet.GetItemState( ATTR_FONT_WEIGHT, false, &pWeight) != SfxItemState::SET )
258 pWeight = nullptr;
259 const SfxPoolItem* pPosture;
260 if ( rESet.GetItemState( ATTR_FONT_POSTURE, false, &pPosture) != SfxItemState::SET )
261 pPosture = nullptr;
262 // Number format
263 const SfxPoolItem* pNumFmt = nullptr;
264 if ( rESet.GetItemState(ATTR_VALUE_FORMAT, false, &pNumFmt) == SfxItemState::SET )
265 pAttrItemSet->Put(*pNumFmt);
266 if ( pFont || pHeight || pWeight || pPosture )
267 {
268 OUString aStr( mpEngine->GetText( pE->aSel ) );
270 const SvtScriptType nScripts[3] = { SvtScriptType::LATIN,
271 SvtScriptType::ASIAN, SvtScriptType::COMPLEX };
272 for (SvtScriptType nScript : nScripts)
273 {
274 if ( nScriptType & nScript )
275 {
276 if ( pFont )
277 {
278 pAttrItemSet->Put( pFont->CloneSetWhich(
280 }
281 if ( pHeight )
282 {
283 pAttrItemSet->Put( pHeight->CloneSetWhich(
285 }
286 if ( pWeight )
287 {
288 pAttrItemSet->Put( pWeight->CloneSetWhich(
290 }
291 if ( pPosture )
292 {
293 pAttrItemSet->Put( pPosture->CloneSetWhich(
295 }
296 }
297 }
298 }
299 }
300 if ( pE->nColOverlap > 1 || pE->nRowOverlap > 1 )
301 { // Merged cells, with SfxItemSet.Put() is faster than
302 // with ScDocument.DoMerge() afterwards
303 ScMergeAttr aMerge( pE->nColOverlap, pE->nRowOverlap );
304 pAttrItemSet->Put( aMerge );
305 SCROW nRO = 0;
306 if ( pE->nColOverlap > 1 )
307 mpDoc->ApplyFlagsTab( nCol+1, nRow,
308 nCol + pE->nColOverlap - 1, nRow, nTab,
309 ScMF::Hor );
310 if ( pE->nRowOverlap > 1 )
311 {
312 nRO = nRow + pE->nRowOverlap - 1;
313 mpDoc->ApplyFlagsTab( nCol, nRow+1,
314 nCol, nRO , nTab,
315 ScMF::Ver );
316 if ( nRO > nOverlapRowMax )
317 nOverlapRowMax = nRO;
318 }
319 if ( pE->nColOverlap > 1 && pE->nRowOverlap > 1 )
320 mpDoc->ApplyFlagsTab( nCol+1, nRow+1,
321 nCol + pE->nColOverlap - 1, nRO, nTab,
323 }
324 const ScStyleSheet* pStyleSheet =
325 mpDoc->GetPattern( nCol, nRow, nTab )->GetStyleSheet();
326 pAttr->SetStyleSheet( const_cast<ScStyleSheet*>(pStyleSheet) );
327 auto rAttrItemSet2 = mpDoc->SetPattern( nCol, nRow, nTab, std::move(pAttr) )->GetItemSet();
328
329 // Add data
330 if (bSimple)
331 {
332 ScSetStringParam aParam;
333 aParam.mpNumFormatter = pFormatter;
334 aParam.mbDetectNumberFormat = true;
336 aParam.mbHandleApostrophe = false;
337 aParam.mbCheckLinkFormula = true;
338
339 if (!aValStr.isEmpty())
340 mpDoc->SetValue( nCol, nRow, nTab, fVal );
341 else if ( !pE->aSel.HasRange() )
342 {
343 // maybe ALT text of IMG or similar
344 mpDoc->SetString( nCol, nRow, nTab, pE->aAltText, &aParam );
345 // If SelRange is completely empty, the succeeding text can be in the same paragraph!
346 }
347 else
348 {
349 OUString aStr;
350 if( pE->bEntirePara )
351 {
352 aStr = mpEngine->GetText( pE->aSel.nStartPara );
353 }
354 else
355 {
356 aStr = comphelper::string::strip(mpEngine->GetText(pE->aSel), ' ');
357 }
358
359 bool bTextFormat = false;
360
361 if (const SfxUInt32Item* pNumFmt = rAttrItemSet2.GetItemIfSet(ATTR_VALUE_FORMAT, false))
362 {
363 sal_uInt32 nNumFmt = pNumFmt->GetValue();
364 SvNumFormatType nType = pFormatter->GetType(nNumFmt);
365 if (nType == SvNumFormatType::TEXT)
366 // Format is set to Text.
367 bTextFormat = true;
368 }
369
370 // TODO: RTF import should follow the language tag,
371 // currently this follows the HTML options for both, HTML
372 // and RTF.
373 if (bNumbersEnglishUS)
374 {
375 pFormatter->ChangeIntl( LANGUAGE_ENGLISH_US);
376 sal_uInt32 nIndex = pFormatter->GetStandardIndex( LANGUAGE_ENGLISH_US);
377 double fEnVal = 0.0;
378 if (pFormatter->IsNumberFormat( aStr, nIndex, fEnVal))
379 {
380 sal_uInt32 nNewIndex =
383 OSL_ENSURE( nNewIndex != nIndex, "ScEEImport::WriteToDocument: NumbersEnglishUS not a built-in format?");
384 pFormatter->GetInputLineString( fEnVal, nNewIndex, aStr);
385 }
386 else
387 bTextFormat = true;
388 pFormatter->ChangeIntl( LANGUAGE_SYSTEM);
389 }
390
391 // #105460#, #i4180# String cells can't contain tabs or linebreaks
392 // -> replace with spaces
393 aStr = aStr.replaceAll( "\t", " " );
394 aStr = aStr.replaceAll( "\n", " " );
395
396 if (bTextFormat)
397 {
398 aParam.mbDetectNumberFormat = false;
399 aParam.mbDetectScientificNumberFormat = bConvertScientific;
401 }
402 else
403 {
404 aParam.mbDetectNumberFormat = bConvertDate;
405 aParam.mbDetectScientificNumberFormat = bConvertScientific;
406 }
407
408 mpDoc->SetString(nCol, nRow, nTab, aStr, &aParam);
409 }
410 }
411 else if (std::unique_ptr<EditTextObject> pTextObject = IsValidSel(*mpEngine, pE->aSel) ? mpEngine->CreateTextObject(pE->aSel) : nullptr)
412 {
413 // The cell will own the text object instance.
414 mpDoc->SetEditText(ScAddress(nCol,nRow,nTab), std::move(pTextObject));
415 }
416 if ( !pE->maImageList.empty() )
417 bHasGraphics |= GraphicSize( nCol, nRow, pE );
418 if ( pE->pName )
419 { // Anchor Name => RangeName
420 if (!pRangeNames->findByUpperName(ScGlobal::getCharClass().uppercase(*pE->pName)))
421 {
422 ScRangeData* pData = new ScRangeData( *mpDoc, *pE->pName,
423 ScAddress( nCol, nRow, nTab ) );
424 pRangeNames->insert( pData );
425 }
426 }
427 }
428 pProgress->SetStateOnPercent( ++nProgress );
429 }
430 if ( bSizeColsRows )
431 {
432 // Column widths
433 ColWidthsMap& rColWidths = mpParser->GetColWidths();
434 if ( !rColWidths.empty() )
435 {
436 nProgress = 0;
437 pProgress->SetState( nProgress, nEndCol - nStartCol + 1 );
438 for ( SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ )
439 {
440 sal_uInt16 nWidth = 0;
441 ColWidthsMap::const_iterator it = rColWidths.find( nCol );
442 if ( it != rColWidths.end() )
443 nWidth = it->second;
444 if ( nWidth )
445 mpDoc->SetColWidth( nCol, nTab, nWidth );
446 pProgress->SetState( ++nProgress );
447 }
448 }
449 pProgress.reset(); // SetOptimalHeight has its own ProgressBar
450 // Adjust line height, base is 100% zoom
451 Fraction aZoom( 1, 1 );
452 // Factor is printer to display ratio
453 double nPPTX = ScGlobal::nScreenPPTX * static_cast<double>(aZoom) / nOutputFactor;
454 double nPPTY = ScGlobal::nScreenPPTY * static_cast<double>(aZoom);
456 sc::RowHeightContext aCxt(mpDoc->MaxRow(), nPPTX, nPPTY, aZoom, aZoom, pVirtDev);
458 mpDoc->SetOptimalHeight(aCxt, 0, nEndRow, 0, true);
459
460 if ( !maRowHeights.empty() )
461 {
462 for ( SCROW nRow = nStartRow; nRow <= nEndRow; nRow++ )
463 {
464 RowHeightMap::const_iterator it = maRowHeights.find( nRow );
465 sal_uInt16 nHeight = it == maRowHeights.end() ? 0 : it->second;
466 if ( nHeight > mpDoc->GetRowHeight( nRow, nTab ) )
467 mpDoc->SetRowHeight( nRow, nTab, nHeight );
468 }
469 }
470 }
471 if ( !bHasGraphics )
472 return;
473
474 // Insert graphics
475 for ( size_t i = 0, nListSize = mpParser->ListSize(); i < nListSize; ++i )
476 {
477 pE = mpParser->ListEntry( i );
478 if ( !pE->maImageList.empty() )
479 {
480 SCCOL nCol = pE->nCol;
481 SCROW nRow = pE->nRow;
482 if ( mpDoc->ValidCol(nCol) && mpDoc->ValidRow(nRow) )
483 InsertGraphic( nCol, nRow, nTab, pE );
484 }
485 }
486}
487
489{
490 if ( pE->maImageList.empty() )
491 return false;
492 bool bHasGraphics = false;
494 tools::Long nWidth, nHeight;
495 nWidth = nHeight = 0;
496 char nDir = nHorizontal;
497 for (const std::unique_ptr<ScHTMLImage> & pImage : pE->maImageList)
498 {
499 ScHTMLImage* pI = pImage.get();
500 if ( pI->oGraphic )
501 bHasGraphics = true;
502 Size aSizePix = pI->aSize;
503 aSizePix.AdjustWidth(2 * pI->aSpace.X() );
504 aSizePix.AdjustHeight(2 * pI->aSpace.Y() );
505 Size aLogicSize = pDefaultDev->PixelToLogic( aSizePix, MapMode( MapUnit::MapTwip ) );
506 if ( nDir & nHorizontal )
507 nWidth += aLogicSize.Width();
508 else if ( nWidth < aLogicSize.Width() )
509 nWidth = aLogicSize.Width();
510 if ( nDir & nVertical )
511 nHeight += aLogicSize.Height();
512 else if ( nHeight < aLogicSize.Height() )
513 nHeight = aLogicSize.Height();
514 nDir = pI->nDir;
515 }
516 // Column widths
517 ColWidthsMap& rColWidths = mpParser->GetColWidths();
518 tools::Long nThisWidth = 0;
519 ColWidthsMap::const_iterator it = rColWidths.find( nCol );
520 if ( it != rColWidths.end() )
521 nThisWidth = it->second;
522 tools::Long nColWidths = nThisWidth;
523 SCCOL nColSpanCol = nCol + pE->nColOverlap;
524 for ( SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ )
525 {
526 ColWidthsMap::const_iterator it2 = rColWidths.find( nC );
527 if ( it2 != rColWidths.end() )
528 nColWidths += it2->second;
529 }
530 if ( nWidth > nColWidths )
531 { // Only insert difference in first column
532 rColWidths[ nCol ] = nWidth - nColWidths + nThisWidth;
533 }
534 // Distribute line height difference between all affected lines
535 SCROW nRowSpan = pE->nRowOverlap;
536
537 assert(nRowSpan != 0);
538 if ( nRowSpan == 0 )
539 return bHasGraphics;
540
541 nHeight /= nRowSpan;
542
543 if ( nHeight == 0 )
544 nHeight = 1; // For definite comparison
545 for ( SCROW nR = nRow; nR < nRow + nRowSpan; nR++ )
546 {
547 RowHeightMap::const_iterator it2 = maRowHeights.find( nR );
548 tools::Long nRowHeight = it2 == maRowHeights.end() ? 0 : it2->second;
549 if ( nHeight > nRowHeight )
550 {
551 maRowHeights[ nR ] = nHeight;
552 }
553 }
554 return bHasGraphics;
555}
556
558 ScEEParseEntry* pE )
559{
560 if ( pE->maImageList.empty() )
561 return ;
562 ScDrawLayer* pModel = mpDoc->GetDrawLayer();
563 if (!pModel)
564 {
566 pModel = mpDoc->GetDrawLayer();
567 }
568 SdrPage* pPage = pModel->GetPage( static_cast<sal_uInt16>(nTab) );
570
571 Point aCellInsertPos(
574
575 Point aInsertPos( aCellInsertPos );
576 Point aSpace;
577 Size aLogicSize;
578 char nDir = nHorizontal;
579 for (const std::unique_ptr<ScHTMLImage> & pImage : pE->maImageList)
580 {
581 ScHTMLImage* pI = pImage.get();
582 if ( nDir & nHorizontal )
583 { // Horizontal
584 aInsertPos.AdjustX(aLogicSize.Width() );
585 aInsertPos.AdjustX(aSpace.X() );
586 aInsertPos.setY( aCellInsertPos.Y() );
587 }
588 else
589 { // Vertical
590 aInsertPos.setX( aCellInsertPos.X() );
591 aInsertPos.AdjustY(aLogicSize.Height() );
592 aInsertPos.AdjustY(aSpace.Y() );
593 }
594 // Add offset of Spacing
595 aSpace = pDefaultDev->PixelToLogic( pI->aSpace, MapMode( MapUnit::Map100thMM ) );
596 aInsertPos += aSpace;
597
598 Size aSizePix = pI->aSize;
599 aLogicSize = pDefaultDev->PixelToLogic( aSizePix, MapMode( MapUnit::Map100thMM ) );
600
601 // Limit size
602 ::ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() );
603
604 if ( pI->oGraphic )
605 {
606 tools::Rectangle aRect ( aInsertPos, aLogicSize );
608 *pModel,
609 *pI->oGraphic,
610 aRect);
611
612 // calling SetGraphicLink here doesn't work
613 pObj->SetName( pI->aURL );
614
615 pPage->InsertObject( pObj.get() );
616
617 // SetGraphicLink has to be used after inserting the object,
618 // otherwise an empty graphic is swapped in and the contact stuff crashes.
619 // See #i37444#.
620 pObj->SetGraphicLink( pI->aURL );
621
622 pObj->SetLogicRect( aRect ); // Only after InsertObject!
623 }
624 nDir = pI->nDir;
625 }
626}
627
629 pEdit( pEditP ),
630 pPool( EditEngine::CreatePool() ),
631 pDocPool( new ScDocumentPool ),
632 nRtfLastToken(0),
633 nColCnt(0),
634 nRowCnt(0),
635 nColMax(0),
636 nRowMax(0)
637{
638 // pPool is foisted on SvxRTFParser at RtfImportState::Start later on
639 pPool->SetSecondaryPool( pDocPool.get() );
640 pPool->FreezeIdRanges();
641 NewActEntry( nullptr );
642}
643
645{
646 mxActEntry.reset();
647 maList.clear();
648
649 // Don't delete Pool until the lists have been deleted
650 pPool->SetSecondaryPool( nullptr );
651 pDocPool.clear();
652 pPool.clear();
653}
654
656{ // New free-flying mxActEntry
657 mxActEntry = std::make_shared<ScEEParseEntry>(pPool.get());
658 mxActEntry->aSel.nStartPara = (pE ? pE->aSel.nEndPara + 1 : 0);
659 mxActEntry->aSel.nStartPos = 0;
660}
661
662/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SCROW SCROW_MAX
Definition: address.hxx:55
bool ValidCol(SCCOL nCol, SCCOL nMaxCol)
Definition: address.hxx:99
B2DRange maRange
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
SCTAB Tab() const
Definition: address.hxx:283
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: address.hxx:403
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
SC_DLLPUBLIC bool SetEditText(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
This method manages the lifecycle of the passed edit text object.
Definition: document.cxx:3422
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4161
bool ValidRow(SCROW nRow) const
Definition: document.hxx:900
SC_DLLPUBLIC tools::Long GetColOffset(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4224
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
Definition: documen9.cxx:105
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
SC_DLLPUBLIC bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bApi)
Definition: document.cxx:4267
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6050
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:4970
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
Definition: documen6.cxx:76
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
Definition: documen2.cxx:473
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
Definition: document.cxx:3391
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1084
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
Definition: document.cxx:5161
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
Definition: document.cxx:3477
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1083
SC_DLLPUBLIC void SetPattern(const ScAddress &, const ScPatternAttr &rAttr)
Definition: document.cxx:5008
bool ValidCol(SCCOL nCol) const
Definition: document.hxx:899
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:171
SC_DLLPUBLIC void SetRowHeight(SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight)
Definition: document.cxx:4098
SC_DLLPUBLIC void SetColWidth(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
Definition: document.cxx:4086
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4719
SC_DLLPUBLIC tools::Long GetRowOffset(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4232
ScRange maRange
Definition: eeimport.hxx:38
ScEEImport(ScDocument *pDoc, const ScRange &rRange)
Definition: eeimpars.cxx:61
bool GraphicSize(SCCOL nCol, SCROW nRow, ScEEParseEntry *)
Definition: eeimpars.cxx:488
virtual void WriteToDocument(bool bSizeColsRows=false, double nOutputFactor=1.0, SvNumberFormatter *pFormatter=nullptr, bool bConvertDate=true, bool bConvertScientific=true) override
Definition: eeimpars.cxx:115
RowHeightMap maRowHeights
Definition: eeimport.hxx:44
virtual ErrCode Read(SvStream &rStream, const OUString &rBaseURL) override
Definition: eeimpars.cxx:78
std::unique_ptr< ScTabEditEngine > mpEngine
Definition: eeimport.hxx:41
ScDocument * mpDoc
Definition: eeimport.hxx:39
void InsertGraphic(SCCOL nCol, SCROW nRow, SCTAB nTab, ScEEParseEntry *)
Definition: eeimpars.cxx:557
virtual ~ScEEImport() override
Definition: eeimpars.cxx:72
std::unique_ptr< ScEEParser > mpParser
Definition: eeimport.hxx:43
ScEEParser(EditEngine *)
Definition: eeimpars.cxx:628
void NewActEntry(const ScEEParseEntry *)
Definition: eeimpars.cxx:655
std::vector< std::shared_ptr< ScEEParseEntry > > maList
Definition: eeparser.hxx:106
std::shared_ptr< ScEEParseEntry > mxActEntry
Definition: eeparser.hxx:107
rtl::Reference< SfxItemPool > pDocPool
Definition: eeparser.hxx:105
virtual ~ScEEParser()
Definition: eeimpars.cxx:644
rtl::Reference< SfxItemPool > pPool
Definition: eeparser.hxx:104
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
Definition: global.hxx:589
static SC_DLLPUBLIC double nScreenPPTY
Vertical pixel per twips factor.
Definition: global.hxx:591
static SC_DLLPUBLIC sal_uInt16 GetScriptedWhichID(SvtScriptType nScriptType, sal_uInt16 nWhich)
Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
Definition: global.cxx:915
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1064
static SC_DLLPUBLIC ::tools::Long nLastRowHeightExtra
Definition: global.hxx:598
const ScStyleSheet * GetStyleSheet() const
Definition: patattr.hxx:165
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
Definition: rangenam.cxx:704
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
Definition: rangenam.cxx:802
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Size GetSize() const
static double GetTableDataOptionsValNum(sal_uInt32 &nNumForm, LanguageType &eNumLang, const OUString &aValStr, std::u16string_view aNumStr, SvNumberFormatter &rFormatter)
sal_uInt16 Count() const
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
sal_uInt32 GetStandardIndex(LanguageType eLnge=LANGUAGE_DONTKNOW)
void GetInputLineString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &rOutString, bool bFiltering=false, bool bForceSystemLocale=false)
void ChangeIntl(LanguageType eLnge)
SvNumFormatType GetType(sal_uInt32 nFIndex) const
sal_uInt32 GetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat, LanguageType eLnge=LANGUAGE_DONTKNOW)
LanguageType GetLanguage() const
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
void setExtraHeight(sal_uInt16 nH)
static bool IsFuzzing()
FormulaCommand pE
constexpr double nPPTX
constexpr double nPPTY
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)
const char nHorizontal
Definition: eeparser.hxx:35
const char nVertical
Definition: eeparser.hxx:36
std::map< SCCOL, sal_uInt16 > ColWidthsMap
Definition: eeparser.hxx:96
void ScLimitSizeOnDrawPage(Size &rSize, Point &rPos, const Size &rPage)
Definition: fuins1.cxx:62
sal_Int32 nIndex
sal_Int64 n
#define LANGUAGE_SYSTEM
#define LANGUAGE_NONE
#define LANGUAGE_ENGLISH_US
SvtScriptType
aStr
std::unique_ptr< sal_Int32[]> pData
OString strip(const OString &rIn, char c)
int i
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
long Long
sal_Int16 nId
SfxItemState
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
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)
sal_uIntPtr sal_uLong
sal_Int32 nStartPara
sal_Int32 nEndPara
Point aSpace
Definition: eeparser.hxx:42
OUString aURL
Definition: eeparser.hxx:40
Size aSize
Definition: eeparser.hxx:41
std::optional< Graphic > oGraphic
Definition: eeparser.hxx:45
Store parameters used in the ScDocument::SetString() method.
Definition: stringutil.hxx:35
bool mbHandleApostrophe
When true, treat input with a leading apostrophe as an escape character for all content,...
Definition: stringutil.hxx:94
bool mbCheckLinkFormula
When true and the string results in a compiled formula, check the formula tokens for presence of func...
Definition: stringutil.hxx:103
bool mbDetectScientificNumberFormat
Definition: stringutil.hxx:80
bool mbDetectNumberFormat
Specify which number formats are detected: mbDetectNumberFormat=true && mbDetectScientificNumberForma...
Definition: stringutil.hxx:79
SvNumberFormatter * mpNumFormatter
Stores the pointer to the number formatter instance to be used during number format detection.
Definition: stringutil.hxx:70
@ Always
Set Text number format if the input string can be parsed as a number or formula text.
Definition: stringutil.hxx:45
@ SpecialNumberOnly
Set Text number format only when the input string is considered a special number but we only want to ...
Definition: stringutil.hxx:51
TextFormatPolicy meSetTextNumFormat
Determine when to set the 'Text' number format to the cell where the input string is being set.
Definition: stringutil.hxx:86
SvxEscapement
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
SvNumFormatType