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{
117 std::unique_ptr<ScProgress> pProgress( new ScProgress( mpDoc->GetDocumentShell(),
118 ScResId( STR_LOAD_DOC ), mpParser->ListSize(), true ) );
119 sal_uLong nProgress = 0;
120
121 SCCOL nStartCol, nEndCol;
122 SCROW nStartRow, nEndRow;
123 SCTAB nTab;
124 SCROW nOverlapRowMax, nLastMergedRow;
125 SCCOL nMergeColAdd;
126 nStartCol = maRange.aStart.Col();
127 nStartRow = maRange.aStart.Row();
128 nTab = maRange.aStart.Tab();
129 nEndCol = maRange.aEnd.Col();
130 nEndRow = maRange.aEnd.Row();
131 nOverlapRowMax = 0;
132 nMergeColAdd = 0;
133 nLastMergedRow = SCROW_MAX;
134 bool bHasGraphics = false;
136 if (!pFormatter)
137 pFormatter = mpDoc->GetFormatTable();
138 bool bNumbersEnglishUS = false;
140 {
141 // Automatic language option selected. Check for the global 'use US English' option.
142 bNumbersEnglishUS = officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::get();
143 }
144 ScDocumentPool* pDocPool = mpDoc->GetPool();
145 ScRangeName* pRangeNames = mpDoc->GetRangeName();
146 for ( size_t i = 0, n = mpParser->ListSize(); i < n; ++i )
147 {
148 pE = mpParser->ListEntry( i );
149 SCROW nRow = nStartRow + pE->nRow;
150 if ( nRow != nLastMergedRow )
151 nMergeColAdd = 0;
152 SCCOL nCol = nStartCol + pE->nCol + nMergeColAdd;
153 // Determine RowMerge
154 // Pure ColMerge and ColMerge of the first MergeRow already done during parsing
155 if (nRow <= nOverlapRowMax && mpDoc->ValidCol(nCol))
156 {
157 while ( nCol <= mpDoc->MaxCol() && mpDoc->HasAttrib( nCol, nRow, nTab,
158 nCol, nRow, nTab, HasAttrFlags::Overlapped ) )
159 {
160 nCol++;
161 nMergeColAdd++;
162 }
163 nLastMergedRow = nRow;
164 }
165 // Add for second run
166 pE->nCol = nCol;
167 pE->nRow = nRow;
168 if ( mpDoc->ValidCol(nCol) && mpDoc->ValidRow(nRow) )
169 {
170 SfxItemSet aSet = mpEngine->GetAttribs( pE->aSel );
171 // Remove default: we set left/right ourselves depending on Text or
172 // Number
173 // EditView.GetAttribs always returns complete Set filled with
174 // defaults
175 const SfxPoolItem& rItem = aSet.Get( EE_PARA_JUST );
176 if ( static_cast<const SvxAdjustItem&>(rItem).GetAdjust() == SvxAdjust::Left )
177 aSet.ClearItem( EE_PARA_JUST );
178
179 // Test whether simple String without mixed attributes
180 bool bSimple = ( pE->aSel.nStartPara == pE->aSel.nEndPara );
181 for (sal_uInt16 nId = EE_CHAR_START; nId <= EE_CHAR_END && bSimple; nId++)
182 {
183 const SfxPoolItem* pItem = nullptr;
184 SfxItemState eState = aSet.GetItemState( nId, true, &pItem );
185 if (eState == SfxItemState::DONTCARE)
186 bSimple = false;
187 else if (eState == SfxItemState::SET)
188 {
189 if ( nId == EE_CHAR_ESCAPEMENT ) // Super-/Subscript always via EE
190 {
191 if ( static_cast<SvxEscapement>(static_cast<const SvxEscapementItem*>(pItem)->GetEnumValue())
192 != SvxEscapement::Off )
193 bSimple = false;
194 }
195 }
196 }
197 if ( bSimple )
198 { // Contains field commands?
199 SfxItemState eFieldState = aSet.GetItemState( EE_FEATURE_FIELD, false );
200 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
201 bSimple = false;
202 }
203
204 // HTML
205 OUString aValStr, aNumStr;
206 double fVal = 0.0;
207 sal_uInt32 nNumForm = 0;
208 LanguageType eNumLang = LANGUAGE_NONE;
209 if ( pE->pNumStr )
210 { // SDNUM needs to be if SDVAL
211 aNumStr = *pE->pNumStr;
212 if ( pE->pValStr )
213 aValStr = *pE->pValStr;
215 nNumForm, eNumLang, aValStr, aNumStr, *pFormatter );
216 }
217
218 // Set attributes
219 auto pAttr = std::make_unique<ScPatternAttr>( pDocPool );
220 pAttr->GetFromEditItemSet( &aSet );
221 SfxItemSet* pAttrItemSet = &pAttr->GetItemSet();
222 if (!aNumStr.isEmpty())
223 {
224 pAttrItemSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumForm ) );
225 pAttrItemSet->Put( SvxLanguageItem( eNumLang, ATTR_LANGUAGE_FORMAT ) );
226 }
227 const SfxItemSet& rESet = pE->aItemSet;
228 if ( rESet.Count() )
229 {
230 const SfxPoolItem* pItem;
231 if ( rESet.GetItemState( ATTR_BACKGROUND, false, &pItem) == SfxItemState::SET )
232 pAttrItemSet->Put( *pItem );
233 if ( rESet.GetItemState( ATTR_BORDER, false, &pItem) == SfxItemState::SET )
234 pAttrItemSet->Put( *pItem );
235 if ( rESet.GetItemState( ATTR_SHADOW, false, &pItem) == SfxItemState::SET )
236 pAttrItemSet->Put( *pItem );
237 // HTML
238 if ( rESet.GetItemState( ATTR_HOR_JUSTIFY, false, &pItem) == SfxItemState::SET )
239 pAttrItemSet->Put( *pItem );
240 if ( rESet.GetItemState( ATTR_VER_JUSTIFY, false, &pItem) == SfxItemState::SET )
241 pAttrItemSet->Put( *pItem );
242 if ( rESet.GetItemState( ATTR_LINEBREAK, false, &pItem) == SfxItemState::SET )
243 pAttrItemSet->Put( *pItem );
244 if ( rESet.GetItemState( ATTR_FONT_COLOR, false, &pItem) == SfxItemState::SET )
245 pAttrItemSet->Put( *pItem );
246 if ( rESet.GetItemState( ATTR_FONT_UNDERLINE, false, &pItem) == SfxItemState::SET )
247 pAttrItemSet->Put( *pItem );
248 // HTML LATIN/CJK/CTL script type dependent
249 const SfxPoolItem* pFont;
250 if ( rESet.GetItemState( ATTR_FONT, false, &pFont) != SfxItemState::SET )
251 pFont = nullptr;
252 const SfxPoolItem* pHeight;
253 if ( rESet.GetItemState( ATTR_FONT_HEIGHT, false, &pHeight) != SfxItemState::SET )
254 pHeight = nullptr;
255 const SfxPoolItem* pWeight;
256 if ( rESet.GetItemState( ATTR_FONT_WEIGHT, false, &pWeight) != SfxItemState::SET )
257 pWeight = nullptr;
258 const SfxPoolItem* pPosture;
259 if ( rESet.GetItemState( ATTR_FONT_POSTURE, false, &pPosture) != SfxItemState::SET )
260 pPosture = nullptr;
261 // Number format
262 const SfxPoolItem* pNumFmt = nullptr;
263 if ( rESet.GetItemState(ATTR_VALUE_FORMAT, false, &pNumFmt) == SfxItemState::SET )
264 pAttrItemSet->Put(*pNumFmt);
265 if ( pFont || pHeight || pWeight || pPosture )
266 {
267 OUString aStr( mpEngine->GetText( pE->aSel ) );
269 const SvtScriptType nScripts[3] = { SvtScriptType::LATIN,
270 SvtScriptType::ASIAN, SvtScriptType::COMPLEX };
271 for (SvtScriptType nScript : nScripts)
272 {
273 if ( nScriptType & nScript )
274 {
275 if ( pFont )
276 {
277 pAttrItemSet->Put( pFont->CloneSetWhich(
279 }
280 if ( pHeight )
281 {
282 pAttrItemSet->Put( pHeight->CloneSetWhich(
284 }
285 if ( pWeight )
286 {
287 pAttrItemSet->Put( pWeight->CloneSetWhich(
289 }
290 if ( pPosture )
291 {
292 pAttrItemSet->Put( pPosture->CloneSetWhich(
294 }
295 }
296 }
297 }
298 }
299 if ( pE->nColOverlap > 1 || pE->nRowOverlap > 1 )
300 { // Merged cells, with SfxItemSet.Put() is faster than
301 // with ScDocument.DoMerge() afterwards
302 ScMergeAttr aMerge( pE->nColOverlap, pE->nRowOverlap );
303 pAttrItemSet->Put( aMerge );
304 SCROW nRO = 0;
305 if ( pE->nColOverlap > 1 )
306 mpDoc->ApplyFlagsTab( nCol+1, nRow,
307 nCol + pE->nColOverlap - 1, nRow, nTab,
308 ScMF::Hor );
309 if ( pE->nRowOverlap > 1 )
310 {
311 nRO = nRow + pE->nRowOverlap - 1;
312 mpDoc->ApplyFlagsTab( nCol, nRow+1,
313 nCol, nRO , nTab,
314 ScMF::Ver );
315 if ( nRO > nOverlapRowMax )
316 nOverlapRowMax = nRO;
317 }
318 if ( pE->nColOverlap > 1 && pE->nRowOverlap > 1 )
319 mpDoc->ApplyFlagsTab( nCol+1, nRow+1,
320 nCol + pE->nColOverlap - 1, nRO, nTab,
322 }
323 const ScStyleSheet* pStyleSheet =
324 mpDoc->GetPattern( nCol, nRow, nTab )->GetStyleSheet();
325 pAttr->SetStyleSheet( const_cast<ScStyleSheet*>(pStyleSheet) );
326 auto rAttrItemSet2 = mpDoc->SetPattern( nCol, nRow, nTab, std::move(pAttr) )->GetItemSet();
327
328 // Add data
329 if (bSimple)
330 {
331 ScSetStringParam aParam;
332 aParam.mpNumFormatter = pFormatter;
333 aParam.mbDetectNumberFormat = true;
335 aParam.mbHandleApostrophe = false;
336 aParam.mbCheckLinkFormula = true;
337
338 if (!aValStr.isEmpty())
339 mpDoc->SetValue( nCol, nRow, nTab, fVal );
340 else if ( !pE->aSel.HasRange() )
341 {
342 // maybe ALT text of IMG or similar
343 mpDoc->SetString( nCol, nRow, nTab, pE->aAltText, &aParam );
344 // If SelRange is completely empty, the succeeding text can be in the same paragraph!
345 }
346 else
347 {
348 OUString aStr;
349 if( pE->bEntirePara )
350 {
351 aStr = mpEngine->GetText( pE->aSel.nStartPara );
352 }
353 else
354 {
355 aStr = comphelper::string::strip(mpEngine->GetText(pE->aSel), ' ');
356 }
357
358 bool bTextFormat = false;
359
360 if (const SfxUInt32Item* pNumFmt = rAttrItemSet2.GetItemIfSet(ATTR_VALUE_FORMAT, false))
361 {
362 sal_uInt32 nNumFmt = pNumFmt->GetValue();
363 SvNumFormatType nType = pFormatter->GetType(nNumFmt);
364 if (nType == SvNumFormatType::TEXT)
365 // Format is set to Text.
366 bTextFormat = true;
367 }
368
369 // TODO: RTF import should follow the language tag,
370 // currently this follows the HTML options for both, HTML
371 // and RTF.
372 if (bNumbersEnglishUS)
373 {
374 pFormatter->ChangeIntl( LANGUAGE_ENGLISH_US);
375 sal_uInt32 nIndex = pFormatter->GetStandardIndex( LANGUAGE_ENGLISH_US);
376 double fEnVal = 0.0;
377 if (pFormatter->IsNumberFormat( aStr, nIndex, fEnVal))
378 {
379 sal_uInt32 nNewIndex =
382 OSL_ENSURE( nNewIndex != nIndex, "ScEEImport::WriteToDocument: NumbersEnglishUS not a built-in format?");
383 pFormatter->GetInputLineString( fEnVal, nNewIndex, aStr);
384 }
385 else
386 bTextFormat = true;
387 pFormatter->ChangeIntl( LANGUAGE_SYSTEM);
388 }
389
390 // #105460#, #i4180# String cells can't contain tabs or linebreaks
391 // -> replace with spaces
392 aStr = aStr.replaceAll( "\t", " " );
393 aStr = aStr.replaceAll( "\n", " " );
394
395 if (bTextFormat)
396 {
397 aParam.mbDetectNumberFormat = false;
399 }
400 else
401 aParam.mbDetectNumberFormat = bConvertDate;
402
403 mpDoc->SetString(nCol, nRow, nTab, aStr, &aParam);
404 }
405 }
406 else if (std::unique_ptr<EditTextObject> pTextObject = IsValidSel(*mpEngine, pE->aSel) ? mpEngine->CreateTextObject(pE->aSel) : nullptr)
407 {
408 // The cell will own the text object instance.
409 mpDoc->SetEditText(ScAddress(nCol,nRow,nTab), std::move(pTextObject));
410 }
411 if ( !pE->maImageList.empty() )
412 bHasGraphics |= GraphicSize( nCol, nRow, pE );
413 if ( pE->pName )
414 { // Anchor Name => RangeName
415 if (!pRangeNames->findByUpperName(ScGlobal::getCharClass().uppercase(*pE->pName)))
416 {
417 ScRangeData* pData = new ScRangeData( *mpDoc, *pE->pName,
418 ScAddress( nCol, nRow, nTab ) );
419 pRangeNames->insert( pData );
420 }
421 }
422 }
423 pProgress->SetStateOnPercent( ++nProgress );
424 }
425 if ( bSizeColsRows )
426 {
427 // Column widths
428 ColWidthsMap& rColWidths = mpParser->GetColWidths();
429 if ( !rColWidths.empty() )
430 {
431 nProgress = 0;
432 pProgress->SetState( nProgress, nEndCol - nStartCol + 1 );
433 for ( SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ )
434 {
435 sal_uInt16 nWidth = 0;
436 ColWidthsMap::const_iterator it = rColWidths.find( nCol );
437 if ( it != rColWidths.end() )
438 nWidth = it->second;
439 if ( nWidth )
440 mpDoc->SetColWidth( nCol, nTab, nWidth );
441 pProgress->SetState( ++nProgress );
442 }
443 }
444 pProgress.reset(); // SetOptimalHeight has its own ProgressBar
445 // Adjust line height, base is 100% zoom
446 Fraction aZoom( 1, 1 );
447 // Factor is printer to display ratio
448 double nPPTX = ScGlobal::nScreenPPTX * static_cast<double>(aZoom) / nOutputFactor;
449 double nPPTY = ScGlobal::nScreenPPTY * static_cast<double>(aZoom);
451 sc::RowHeightContext aCxt(mpDoc->MaxRow(), nPPTX, nPPTY, aZoom, aZoom, pVirtDev);
453 mpDoc->SetOptimalHeight(aCxt, 0, nEndRow, 0, true);
454
455 if ( !maRowHeights.empty() )
456 {
457 for ( SCROW nRow = nStartRow; nRow <= nEndRow; nRow++ )
458 {
459 RowHeightMap::const_iterator it = maRowHeights.find( nRow );
460 sal_uInt16 nHeight = it == maRowHeights.end() ? 0 : it->second;
461 if ( nHeight > mpDoc->GetRowHeight( nRow, nTab ) )
462 mpDoc->SetRowHeight( nRow, nTab, nHeight );
463 }
464 }
465 }
466 if ( !bHasGraphics )
467 return;
468
469 // Insert graphics
470 for ( size_t i = 0, nListSize = mpParser->ListSize(); i < nListSize; ++i )
471 {
472 pE = mpParser->ListEntry( i );
473 if ( !pE->maImageList.empty() )
474 {
475 SCCOL nCol = pE->nCol;
476 SCROW nRow = pE->nRow;
477 if ( mpDoc->ValidCol(nCol) && mpDoc->ValidRow(nRow) )
478 InsertGraphic( nCol, nRow, nTab, pE );
479 }
480 }
481}
482
484{
485 if ( pE->maImageList.empty() )
486 return false;
487 bool bHasGraphics = false;
489 tools::Long nWidth, nHeight;
490 nWidth = nHeight = 0;
491 char nDir = nHorizontal;
492 for (const std::unique_ptr<ScHTMLImage> & pImage : pE->maImageList)
493 {
494 ScHTMLImage* pI = pImage.get();
495 if ( pI->oGraphic )
496 bHasGraphics = true;
497 Size aSizePix = pI->aSize;
498 aSizePix.AdjustWidth(2 * pI->aSpace.X() );
499 aSizePix.AdjustHeight(2 * pI->aSpace.Y() );
500 Size aLogicSize = pDefaultDev->PixelToLogic( aSizePix, MapMode( MapUnit::MapTwip ) );
501 if ( nDir & nHorizontal )
502 nWidth += aLogicSize.Width();
503 else if ( nWidth < aLogicSize.Width() )
504 nWidth = aLogicSize.Width();
505 if ( nDir & nVertical )
506 nHeight += aLogicSize.Height();
507 else if ( nHeight < aLogicSize.Height() )
508 nHeight = aLogicSize.Height();
509 nDir = pI->nDir;
510 }
511 // Column widths
512 ColWidthsMap& rColWidths = mpParser->GetColWidths();
513 tools::Long nThisWidth = 0;
514 ColWidthsMap::const_iterator it = rColWidths.find( nCol );
515 if ( it != rColWidths.end() )
516 nThisWidth = it->second;
517 tools::Long nColWidths = nThisWidth;
518 SCCOL nColSpanCol = nCol + pE->nColOverlap;
519 for ( SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ )
520 {
521 ColWidthsMap::const_iterator it2 = rColWidths.find( nC );
522 if ( it2 != rColWidths.end() )
523 nColWidths += it2->second;
524 }
525 if ( nWidth > nColWidths )
526 { // Only insert difference in first column
527 rColWidths[ nCol ] = nWidth - nColWidths + nThisWidth;
528 }
529 // Distribute line height difference between all affected lines
530 SCROW nRowSpan = pE->nRowOverlap;
531 nHeight /= nRowSpan;
532 if ( nHeight == 0 )
533 nHeight = 1; // For definite comparison
534 for ( SCROW nR = nRow; nR < nRow + nRowSpan; nR++ )
535 {
536 RowHeightMap::const_iterator it2 = maRowHeights.find( nR );
537 tools::Long nRowHeight = it2 == maRowHeights.end() ? 0 : it2->second;
538 if ( nHeight > nRowHeight )
539 {
540 maRowHeights[ nR ] = nHeight;
541 }
542 }
543 return bHasGraphics;
544}
545
547 ScEEParseEntry* pE )
548{
549 if ( pE->maImageList.empty() )
550 return ;
551 ScDrawLayer* pModel = mpDoc->GetDrawLayer();
552 if (!pModel)
553 {
555 pModel = mpDoc->GetDrawLayer();
556 }
557 SdrPage* pPage = pModel->GetPage( static_cast<sal_uInt16>(nTab) );
559
560 Point aCellInsertPos(
563
564 Point aInsertPos( aCellInsertPos );
565 Point aSpace;
566 Size aLogicSize;
567 char nDir = nHorizontal;
568 for (const std::unique_ptr<ScHTMLImage> & pImage : pE->maImageList)
569 {
570 ScHTMLImage* pI = pImage.get();
571 if ( nDir & nHorizontal )
572 { // Horizontal
573 aInsertPos.AdjustX(aLogicSize.Width() );
574 aInsertPos.AdjustX(aSpace.X() );
575 aInsertPos.setY( aCellInsertPos.Y() );
576 }
577 else
578 { // Vertical
579 aInsertPos.setX( aCellInsertPos.X() );
580 aInsertPos.AdjustY(aLogicSize.Height() );
581 aInsertPos.AdjustY(aSpace.Y() );
582 }
583 // Add offset of Spacing
584 aSpace = pDefaultDev->PixelToLogic( pI->aSpace, MapMode( MapUnit::Map100thMM ) );
585 aInsertPos += aSpace;
586
587 Size aSizePix = pI->aSize;
588 aLogicSize = pDefaultDev->PixelToLogic( aSizePix, MapMode( MapUnit::Map100thMM ) );
589
590 // Limit size
591 ::ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() );
592
593 if ( pI->oGraphic )
594 {
595 tools::Rectangle aRect ( aInsertPos, aLogicSize );
597 *pModel,
598 *pI->oGraphic,
599 aRect);
600
601 // calling SetGraphicLink here doesn't work
602 pObj->SetName( pI->aURL );
603
604 pPage->InsertObject( pObj.get() );
605
606 // SetGraphicLink has to be used after inserting the object,
607 // otherwise an empty graphic is swapped in and the contact stuff crashes.
608 // See #i37444#.
609 pObj->SetGraphicLink( pI->aURL );
610
611 pObj->SetLogicRect( aRect ); // Only after InsertObject!
612 }
613 nDir = pI->nDir;
614 }
615}
616
618 pEdit( pEditP ),
619 pPool( EditEngine::CreatePool() ),
620 pDocPool( new ScDocumentPool ),
621 nRtfLastToken(0),
622 nColCnt(0),
623 nRowCnt(0),
624 nColMax(0),
625 nRowMax(0)
626{
627 // pPool is foisted on SvxRTFParser at RtfImportState::Start later on
628 pPool->SetSecondaryPool( pDocPool.get() );
629 pPool->FreezeIdRanges();
630 NewActEntry( nullptr );
631}
632
634{
635 mxActEntry.reset();
636 maList.clear();
637
638 // Don't delete Pool until the lists have been deleted
639 pPool->SetSecondaryPool( nullptr );
640 pDocPool.clear();
641 pPool.clear();
642}
643
645{ // New free-flying mxActEntry
646 mxActEntry = std::make_shared<ScEEParseEntry>(pPool.get());
647 mxActEntry->aSel.nStartPara = (pE ? pE->aSel.nEndPara + 1 : 0);
648 mxActEntry->aSel.nStartPos = 0;
649}
650
651/* 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
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:3453
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4225
bool ValidRow(SCROW nRow) const
Definition: document.hxx:899
SC_DLLPUBLIC tools::Long GetColOffset(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4288
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
Definition: documen9.cxx:98
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:891
SC_DLLPUBLIC bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bApi)
Definition: document.cxx:4330
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6170
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:892
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5083
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:3422
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1082
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
Definition: document.cxx:5278
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
Definition: document.cxx:3517
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1081
SC_DLLPUBLIC void SetPattern(const ScAddress &, const ScPatternAttr &rAttr)
Definition: document.cxx:5125
bool ValidCol(SCCOL nCol) const
Definition: document.hxx:898
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:174
SC_DLLPUBLIC void SetRowHeight(SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight)
Definition: document.cxx:4159
SC_DLLPUBLIC void SetColWidth(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
Definition: document.cxx:4147
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4813
SC_DLLPUBLIC tools::Long GetRowOffset(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4296
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:483
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
virtual void WriteToDocument(bool bSizeColsRows=false, double nOutputFactor=1.0, SvNumberFormatter *pFormatter=nullptr, bool bConvertDate=true) override
Definition: eeimpars.cxx:115
ScDocument * mpDoc
Definition: eeimport.hxx:39
void InsertGraphic(SCCOL nCol, SCROW nRow, SCTAB nTab, ScEEParseEntry *)
Definition: eeimpars.cxx:546
virtual ~ScEEImport() override
Definition: eeimpars.cxx:72
std::unique_ptr< ScEEParser > mpParser
Definition: eeimport.hxx:43
ScEEParser(EditEngine *)
Definition: eeimpars.cxx:617
void NewActEntry(const ScEEParseEntry *)
Definition: eeimpars.cxx:644
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:633
rtl::Reference< SfxItemPool > pPool
Definition: eeparser.hxx:104
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
Definition: global.hxx:588
static SC_DLLPUBLIC double nScreenPPTY
Vertical pixel per twips factor.
Definition: global.hxx:590
static SC_DLLPUBLIC sal_uInt16 GetScriptedWhichID(SvtScriptType nScriptType, sal_uInt16 nWhich)
Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
Definition: global.cxx:913
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1062
static SC_DLLPUBLIC ::tools::Long nLastRowHeightExtra
Definition: global.hxx:597
const ScStyleSheet * GetStyleSheet() const
Definition: patattr.hxx:128
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:91
bool mbCheckLinkFormula
When true and the string results in a compiled formula, check the formula tokens for presence of func...
Definition: stringutil.hxx:100
bool mbDetectNumberFormat
When true, we try to detect special number format (dates etc) from the input string,...
Definition: stringutil.hxx:77
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:83
SvxEscapement
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
SvNumFormatType