merged tag ooo/OOO330_m14
[LibreOffice.git] / sc / source / filter / rtf / eeimpars.cxx
blob7fb3d16c6c8d75e3ee0be20f3bc4670a8df20e95
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
33 //------------------------------------------------------------------------
35 #include "scitems.hxx"
36 #include <editeng/eeitem.hxx>
39 #include <editeng/adjitem.hxx>
40 #include <editeng/editobj.hxx>
41 #include <editeng/editview.hxx>
42 #include <editeng/escpitem.hxx>
43 #include <editeng/langitem.hxx>
44 #include <svx/svdograf.hxx>
45 #include <svx/svdpage.hxx>
46 #include <editeng/scripttypeitem.hxx>
47 #include <svtools/htmlcfg.hxx>
48 #include <sfx2/sfxhtml.hxx>
49 #include <svtools/parhtml.hxx>
50 #include <svl/zforlist.hxx>
51 #include <vcl/virdev.hxx>
52 #include <vcl/svapp.hxx>
53 #include <unotools/syslocale.hxx>
54 #include <unotools/charclass.hxx>
56 #include "eeimport.hxx"
57 #include "global.hxx"
58 #include "document.hxx"
59 #include "editutil.hxx"
60 #include "stlsheet.hxx"
61 #include "docpool.hxx"
62 #include "attrib.hxx"
63 #include "patattr.hxx"
64 #include "cell.hxx"
65 #include "eeparser.hxx"
66 #include "drwlayer.hxx"
67 #include "rangenam.hxx"
68 #include "progress.hxx"
70 #include "globstr.hrc"
72 // in fuins1.cxx
73 extern void ScLimitSizeOnDrawPage( Size& rSize, Point& rPos, const Size& rPage );
75 //------------------------------------------------------------------------
77 ScEEImport::ScEEImport( ScDocument* pDocP, const ScRange& rRange ) :
78 maRange( rRange ),
79 mpDoc( pDocP ),
80 mpParser( NULL ),
81 mpRowHeights( new Table )
83 const ScPatternAttr* pPattern = mpDoc->GetPattern(
84 maRange.aStart.Col(), maRange.aStart.Row(), maRange.aStart.Tab() );
85 mpEngine = new ScTabEditEngine( *pPattern, mpDoc->GetEditPool() );
86 mpEngine->SetUpdateMode( FALSE );
87 mpEngine->EnableUndo( FALSE );
91 ScEEImport::~ScEEImport()
93 // Reihenfolge wichtig, sonst knallt's irgendwann irgendwo in irgendeinem Dtor!
94 // Ist gewaehrleistet, da ScEEImport Basisklasse ist
95 delete mpEngine; // nach Parser!
96 delete mpRowHeights;
100 ULONG ScEEImport::Read( SvStream& rStream, const String& rBaseURL )
102 ULONG nErr = mpParser->Read( rStream, rBaseURL );
104 SCCOL nEndCol;
105 SCROW nEndRow;
106 mpParser->GetDimensions( nEndCol, nEndRow );
107 if ( nEndCol != 0 )
109 nEndCol += maRange.aStart.Col() - 1;
110 if ( nEndCol > MAXCOL )
111 nEndCol = MAXCOL;
113 else
114 nEndCol = maRange.aStart.Col();
115 if ( nEndRow != 0 )
117 nEndRow += maRange.aStart.Row() - 1;
118 if ( nEndRow > MAXROW )
119 nEndRow = MAXROW;
121 else
122 nEndRow = maRange.aStart.Row();
123 maRange.aEnd.Set( nEndCol, nEndRow, maRange.aStart.Tab() );
125 return nErr;
129 void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate )
131 ScProgress* pProgress = new ScProgress( mpDoc->GetDocumentShell(),
132 ScGlobal::GetRscString( STR_LOAD_DOC ), mpParser->Count() );
133 ULONG nProgress = 0;
135 SCCOL nStartCol, nEndCol;
136 SCROW nStartRow, nEndRow;
137 SCTAB nTab;
138 SCROW nOverlapRowMax, nLastMergedRow;
139 SCCOL nMergeColAdd;
140 nStartCol = maRange.aStart.Col();
141 nStartRow = maRange.aStart.Row();
142 nTab = maRange.aStart.Tab();
143 nEndCol = maRange.aEnd.Col();
144 nEndRow = maRange.aEnd.Row();
145 nOverlapRowMax = 0;
146 nMergeColAdd = 0;
147 nLastMergedRow = SCROW_MAX;
148 BOOL bHasGraphics = FALSE;
149 ScEEParseEntry* pE;
150 if (!pFormatter)
151 pFormatter = mpDoc->GetFormatTable();
152 bool bNumbersEnglishUS = false;
153 if (pFormatter->GetLanguage() == LANGUAGE_SYSTEM)
155 // Automatic language option selected. Check for the global 'use US English' option.
156 SvxHtmlOptions aOpt;
157 bNumbersEnglishUS = aOpt.IsNumbersEnglishUS();
159 ScDocumentPool* pDocPool = mpDoc->GetPool();
160 ScRangeName* pRangeNames = mpDoc->GetRangeName();
161 for ( pE = mpParser->First(); pE; pE = mpParser->Next() )
163 SCROW nRow = nStartRow + pE->nRow;
164 if ( nRow != nLastMergedRow )
165 nMergeColAdd = 0;
166 SCCOL nCol = nStartCol + pE->nCol + nMergeColAdd;
167 // RowMerge feststellen, pures ColMerge und ColMerge der ersten
168 // MergeRow bereits beim parsen
169 if ( nRow <= nOverlapRowMax )
171 while ( nCol <= MAXCOL && mpDoc->HasAttrib( nCol, nRow, nTab,
172 nCol, nRow, nTab, HASATTR_OVERLAPPED ) )
174 nCol++;
175 nMergeColAdd++;
177 nLastMergedRow = nRow;
179 // fuer zweiten Durchlauf eintragen
180 pE->nCol = nCol;
181 pE->nRow = nRow;
182 if ( ValidCol(nCol) && ValidRow(nRow) )
184 SfxItemSet aSet = mpEngine->GetAttribs( pE->aSel );
185 // Default raus, wir setzen selber links/rechts je nachdem ob Text
186 // oder Zahl; EditView.GetAttribs liefert immer kompletten Set
187 // mit Defaults aufgefuellt
188 const SfxPoolItem& rItem = aSet.Get( EE_PARA_JUST );
189 if ( ((const SvxAdjustItem&)rItem).GetAdjust() == SVX_ADJUST_LEFT )
190 aSet.ClearItem( EE_PARA_JUST );
192 // Testen, ob einfacher String ohne gemischte Attribute
193 BOOL bSimple = ( pE->aSel.nStartPara == pE->aSel.nEndPara );
194 for (USHORT nId = EE_CHAR_START; nId <= EE_CHAR_END && bSimple; nId++)
196 const SfxPoolItem* pItem = 0;
197 SfxItemState eState = aSet.GetItemState( nId, TRUE, &pItem );
198 if (eState == SFX_ITEM_DONTCARE)
199 bSimple = FALSE;
200 else if (eState == SFX_ITEM_SET)
202 if ( nId == EE_CHAR_ESCAPEMENT ) // Hoch-/Tiefstellen immer ueber EE
204 if ( (SvxEscapement)((const SvxEscapementItem*)pItem)->GetEnumValue()
205 != SVX_ESCAPEMENT_OFF )
206 bSimple = FALSE;
210 if ( bSimple )
211 { // Feldbefehle enthalten?
212 SfxItemState eFieldState = aSet.GetItemState( EE_FEATURE_FIELD, FALSE );
213 if ( eFieldState == SFX_ITEM_DONTCARE || eFieldState == SFX_ITEM_SET )
214 bSimple = FALSE;
217 // HTML
218 String aValStr, aNumStr;
219 double fVal;
220 sal_uInt32 nNumForm = 0;
221 LanguageType eNumLang = LANGUAGE_NONE;
222 if ( pE->pNumStr )
223 { // SDNUM muss sein wenn SDVAL
224 aNumStr = *pE->pNumStr;
225 if ( pE->pValStr )
226 aValStr = *pE->pValStr;
227 fVal = SfxHTMLParser::GetTableDataOptionsValNum(
228 nNumForm, eNumLang, aValStr, aNumStr, *pFormatter );
231 // Attribute setzen
232 ScPatternAttr aAttr( pDocPool );
233 aAttr.GetFromEditItemSet( &aSet );
234 SfxItemSet& rSet = aAttr.GetItemSet();
235 if ( aNumStr.Len() )
237 rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumForm ) );
238 rSet.Put( SvxLanguageItem( eNumLang, ATTR_LANGUAGE_FORMAT ) );
240 const SfxItemSet& rESet = pE->aItemSet;
241 if ( rESet.Count() )
243 const SfxPoolItem* pItem;
244 if ( rESet.GetItemState( ATTR_BACKGROUND, FALSE, &pItem) == SFX_ITEM_SET )
245 rSet.Put( *pItem );
246 if ( rESet.GetItemState( ATTR_BORDER, FALSE, &pItem) == SFX_ITEM_SET )
247 rSet.Put( *pItem );
248 if ( rESet.GetItemState( ATTR_SHADOW, FALSE, &pItem) == SFX_ITEM_SET )
249 rSet.Put( *pItem );
250 // HTML
251 if ( rESet.GetItemState( ATTR_HOR_JUSTIFY, FALSE, &pItem) == SFX_ITEM_SET )
252 rSet.Put( *pItem );
253 if ( rESet.GetItemState( ATTR_VER_JUSTIFY, FALSE, &pItem) == SFX_ITEM_SET )
254 rSet.Put( *pItem );
255 if ( rESet.GetItemState( ATTR_LINEBREAK, FALSE, &pItem) == SFX_ITEM_SET )
256 rSet.Put( *pItem );
257 if ( rESet.GetItemState( ATTR_FONT_COLOR, FALSE, &pItem) == SFX_ITEM_SET )
258 rSet.Put( *pItem );
259 if ( rESet.GetItemState( ATTR_FONT_UNDERLINE, FALSE, &pItem) == SFX_ITEM_SET )
260 rSet.Put( *pItem );
261 // HTML LATIN/CJK/CTL script type dependent
262 const SfxPoolItem* pFont;
263 if ( rESet.GetItemState( ATTR_FONT, FALSE, &pFont) != SFX_ITEM_SET )
264 pFont = 0;
265 const SfxPoolItem* pHeight;
266 if ( rESet.GetItemState( ATTR_FONT_HEIGHT, FALSE, &pHeight) != SFX_ITEM_SET )
267 pHeight = 0;
268 const SfxPoolItem* pWeight;
269 if ( rESet.GetItemState( ATTR_FONT_WEIGHT, FALSE, &pWeight) != SFX_ITEM_SET )
270 pWeight = 0;
271 const SfxPoolItem* pPosture;
272 if ( rESet.GetItemState( ATTR_FONT_POSTURE, FALSE, &pPosture) != SFX_ITEM_SET )
273 pPosture = 0;
274 if ( pFont || pHeight || pWeight || pPosture )
276 String aStr( mpEngine->GetText( pE->aSel ) );
277 BYTE nScriptType = mpDoc->GetStringScriptType( aStr );
278 const BYTE nScripts[3] = { SCRIPTTYPE_LATIN,
279 SCRIPTTYPE_ASIAN, SCRIPTTYPE_COMPLEX };
280 for ( BYTE i=0; i<3; ++i )
282 if ( nScriptType & nScripts[i] )
284 if ( pFont )
285 rSet.Put( *pFont, ScGlobal::GetScriptedWhichID(
286 nScripts[i], ATTR_FONT ));
287 if ( pHeight )
288 rSet.Put( *pHeight, ScGlobal::GetScriptedWhichID(
289 nScripts[i], ATTR_FONT_HEIGHT ));
290 if ( pWeight )
291 rSet.Put( *pWeight, ScGlobal::GetScriptedWhichID(
292 nScripts[i], ATTR_FONT_WEIGHT ));
293 if ( pPosture )
294 rSet.Put( *pPosture, ScGlobal::GetScriptedWhichID(
295 nScripts[i], ATTR_FONT_POSTURE ));
300 if ( pE->nColOverlap > 1 || pE->nRowOverlap > 1 )
301 { // merged cells, mit SfxItemSet Put schneller als mit
302 // nachtraeglichem ScDocument DoMerge
303 ScMergeAttr aMerge( pE->nColOverlap, pE->nRowOverlap );
304 rSet.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 SC_MF_HOR );
310 if ( pE->nRowOverlap > 1 )
312 nRO = nRow + pE->nRowOverlap - 1;
313 mpDoc->ApplyFlagsTab( nCol, nRow+1,
314 nCol, nRO , nTab,
315 SC_MF_VER );
316 if ( nRO > nOverlapRowMax )
317 nOverlapRowMax = nRO;
319 if ( pE->nColOverlap > 1 && pE->nRowOverlap > 1 )
320 mpDoc->ApplyFlagsTab( nCol+1, nRow+1,
321 nCol + pE->nColOverlap - 1, nRO, nTab,
322 SC_MF_HOR | SC_MF_VER );
324 const ScStyleSheet* pStyleSheet =
325 mpDoc->GetPattern( nCol, nRow, nTab )->GetStyleSheet();
326 aAttr.SetStyleSheet( (ScStyleSheet*)pStyleSheet );
327 mpDoc->SetPattern( nCol, nRow, nTab, aAttr, TRUE );
329 // Daten eintragen
330 if (bSimple)
332 if ( aValStr.Len() )
333 mpDoc->SetValue( nCol, nRow, nTab, fVal );
334 else if ( !pE->aSel.HasRange() )
336 // maybe ALT text of IMG or similar
337 mpDoc->SetString( nCol, nRow, nTab, pE->aAltText, pFormatter );
338 // wenn SelRange komplett leer kann nachfolgender Text im gleichen Absatz liegen!
340 else
342 String aStr;
343 if( pE->bEntirePara )
345 aStr = mpEngine->GetText( pE->aSel.nStartPara );
347 else
349 aStr = mpEngine->GetText( pE->aSel );
350 aStr.EraseLeadingAndTrailingChars();
353 // TODO: RTF import should follow the language tag,
354 // currently this follows the HTML options for both, HTML
355 // and RTF.
356 bool bEnUsRecognized = false;
357 if (bNumbersEnglishUS)
359 pFormatter->ChangeIntl( LANGUAGE_ENGLISH_US);
360 sal_uInt32 nIndex = pFormatter->GetStandardIndex( LANGUAGE_ENGLISH_US);
361 double fEnVal = 0.0;
362 if (pFormatter->IsNumberFormat( aStr, nIndex, fEnVal))
364 bEnUsRecognized = true;
365 sal_uInt32 nNewIndex =
366 pFormatter->GetFormatForLanguageIfBuiltIn(
367 nIndex, LANGUAGE_SYSTEM);
368 DBG_ASSERT( nNewIndex != nIndex, "ScEEImport::WriteToDocument: NumbersEnglishUS not a built-in format?");
369 pFormatter->GetInputLineString( fEnVal, nNewIndex, aStr);
371 pFormatter->ChangeIntl( LANGUAGE_SYSTEM);
374 // #105460#, #i4180# String cells can't contain tabs or linebreaks
375 // -> replace with spaces
376 aStr.SearchAndReplaceAll( (sal_Unicode)'\t', (sal_Unicode)' ' );
377 aStr.SearchAndReplaceAll( (sal_Unicode)'\n', (sal_Unicode)' ' );
379 if (bNumbersEnglishUS && !bEnUsRecognized)
380 mpDoc->PutCell( nCol, nRow, nTab, new ScStringCell( aStr));
381 else
382 mpDoc->SetString( nCol, nRow, nTab, aStr, pFormatter, bConvertDate );
385 else
387 EditTextObject* pObject = mpEngine->CreateTextObject( pE->aSel );
388 mpDoc->PutCell( nCol, nRow, nTab, new ScEditCell( pObject,
389 mpDoc, mpEngine->GetEditTextObjectPool() ) );
390 delete pObject;
392 if ( pE->pImageList )
393 bHasGraphics |= GraphicSize( nCol, nRow, nTab, pE );
394 if ( pE->pName )
395 { // Anchor Name => RangeName
396 USHORT nIndex;
397 if ( !pRangeNames->SearchName( *pE->pName, nIndex ) )
399 ScRangeData* pData = new ScRangeData( mpDoc, *pE->pName,
400 ScAddress( nCol, nRow, nTab ) );
401 pRangeNames->Insert( pData );
405 pProgress->SetStateOnPercent( ++nProgress );
407 if ( bSizeColsRows )
409 // Spaltenbreiten
410 Table* pColWidths = mpParser->GetColWidths();
411 if ( pColWidths->Count() )
413 nProgress = 0;
414 pProgress->SetState( nProgress, nEndCol - nStartCol + 1 );
415 for ( SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ )
417 USHORT nWidth = (USHORT)(ULONG) pColWidths->Get( nCol );
418 if ( nWidth )
419 mpDoc->SetColWidth( nCol, nTab, nWidth );
420 pProgress->SetState( ++nProgress );
423 DELETEZ( pProgress ); // SetOptimalHeight hat seinen eigenen ProgressBar
424 // Zeilenhoehen anpassen, Basis 100% Zoom
425 Fraction aZoom( 1, 1 );
426 double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom
427 / nOutputFactor; // Faktor ist Drucker zu Bildschirm
428 double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom;
429 VirtualDevice aVirtDev;
430 mpDoc->SetOptimalHeight( 0, nEndRow, 0,
431 static_cast< USHORT >( ScGlobal::nLastRowHeightExtra ), &aVirtDev,
432 nPPTX, nPPTY, aZoom, aZoom, FALSE );
433 if ( mpRowHeights->Count() )
435 for ( SCROW nRow = nStartRow; nRow <= nEndRow; nRow++ )
437 USHORT nHeight = (USHORT)(ULONG) mpRowHeights->Get( nRow );
438 if ( nHeight > mpDoc->GetRowHeight( nRow, nTab ) )
439 mpDoc->SetRowHeight( nRow, nTab, nHeight );
443 if ( bHasGraphics )
444 { // Grafiken einfuegen
445 for ( pE = mpParser->First(); pE; pE = mpParser->Next() )
447 if ( pE->pImageList )
449 SCCOL nCol = pE->nCol;
450 SCROW nRow = pE->nRow;
451 if ( ValidCol(nCol) && ValidRow(nRow) )
452 InsertGraphic( nCol, nRow, nTab, pE );
456 if ( pProgress )
457 delete pProgress;
461 BOOL ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/,
462 ScEEParseEntry* pE )
464 ScHTMLImageList* pIL = pE->pImageList;
465 if ( !pIL || !pIL->Count() )
466 return FALSE;
467 BOOL bHasGraphics = FALSE;
468 OutputDevice* pDefaultDev = Application::GetDefaultDevice();
469 long nWidth, nHeight;
470 nWidth = nHeight = 0;
471 sal_Char nDir = nHorizontal;
472 for ( ScHTMLImage* pI = pIL->First(); pI; pI = pIL->Next() )
474 if ( pI->pGraphic )
475 bHasGraphics = TRUE;
476 Size aSizePix = pI->aSize;
477 aSizePix.Width() += 2 * pI->aSpace.X();
478 aSizePix.Height() += 2 * pI->aSpace.Y();
479 Size aLogicSize = pDefaultDev->PixelToLogic( aSizePix, MapMode( MAP_TWIP ) );
480 if ( nDir & nHorizontal )
481 nWidth += aLogicSize.Width();
482 else if ( nWidth < aLogicSize.Width() )
483 nWidth = aLogicSize.Width();
484 if ( nDir & nVertical )
485 nHeight += aLogicSize.Height();
486 else if ( nHeight < aLogicSize.Height() )
487 nHeight = aLogicSize.Height();
488 nDir = pI->nDir;
490 // Spaltenbreiten
491 Table* pColWidths = mpParser->GetColWidths();
492 long nThisWidth = (long) pColWidths->Get( nCol );
493 long nColWidths = nThisWidth;
494 SCCOL nColSpanCol = nCol + pE->nColOverlap;
495 for ( SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ )
497 nColWidths += (long) pColWidths->Get( nC );
499 if ( nWidth > nColWidths )
500 { // Differenz nur in der ersten Spalte eintragen
501 if ( nThisWidth )
502 pColWidths->Replace( nCol, (void*)(nWidth - nColWidths + nThisWidth) );
503 else
504 pColWidths->Insert( nCol, (void*)(nWidth - nColWidths) );
506 // Zeilenhoehen, Differenz auf alle betroffenen Zeilen verteilen
507 SCROW nRowSpan = pE->nRowOverlap;
508 nHeight /= nRowSpan;
509 if ( nHeight == 0 )
510 nHeight = 1; // fuer eindeutigen Vergleich
511 for ( SCROW nR = nRow; nR < nRow + nRowSpan; nR++ )
513 long nRowHeight = (long) mpRowHeights->Get( nR );
514 if ( nHeight > nRowHeight )
516 if ( nRowHeight )
517 mpRowHeights->Replace( nR, (void*)nHeight );
518 else
519 mpRowHeights->Insert( nR, (void*)nHeight );
522 return bHasGraphics;
526 void ScEEImport::InsertGraphic( SCCOL nCol, SCROW nRow, SCTAB nTab,
527 ScEEParseEntry* pE )
529 ScHTMLImageList* pIL = pE->pImageList;
530 if ( !pIL || !pIL->Count() )
531 return ;
532 ScDrawLayer* pModel = mpDoc->GetDrawLayer();
533 if (!pModel)
535 mpDoc->InitDrawLayer();
536 pModel = mpDoc->GetDrawLayer();
538 SdrPage* pPage = pModel->GetPage( static_cast<sal_uInt16>(nTab) );
539 OutputDevice* pDefaultDev = Application::GetDefaultDevice();
541 Point aCellInsertPos(
542 (long)((double) mpDoc->GetColOffset( nCol, nTab ) * HMM_PER_TWIPS),
543 (long)((double) mpDoc->GetRowOffset( nRow, nTab ) * HMM_PER_TWIPS) );
545 Point aInsertPos( aCellInsertPos );
546 Point aSpace;
547 Size aLogicSize;
548 sal_Char nDir = nHorizontal;
549 for ( ScHTMLImage* pI = pIL->First(); pI; pI = pIL->Next() )
551 if ( nDir & nHorizontal )
552 { // horizontal
553 aInsertPos.X() += aLogicSize.Width();
554 aInsertPos.X() += aSpace.X();
555 aInsertPos.Y() = aCellInsertPos.Y();
557 else
558 { // vertikal
559 aInsertPos.X() = aCellInsertPos.X();
560 aInsertPos.Y() += aLogicSize.Height();
561 aInsertPos.Y() += aSpace.Y();
563 // Offset des Spacings drauf
564 aSpace = pDefaultDev->PixelToLogic( pI->aSpace, MapMode( MAP_100TH_MM ) );
565 aInsertPos += aSpace;
567 Size aSizePix = pI->aSize;
568 aLogicSize = pDefaultDev->PixelToLogic( aSizePix, MapMode( MAP_100TH_MM ) );
569 // Groesse begrenzen
570 ::ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() );
572 if ( pI->pGraphic )
574 Rectangle aRect ( aInsertPos, aLogicSize );
575 SdrGrafObj* pObj = new SdrGrafObj( *pI->pGraphic, aRect );
576 // #118522# calling SetGraphicLink here doesn't work
577 pObj->SetName( pI->aURL );
579 pPage->InsertObject( pObj );
581 // #118522# SetGraphicLink has to be used after inserting the object,
582 // otherwise an empty graphic is swapped in and the contact stuff crashes.
583 // See #i37444#.
584 pObj->SetGraphicLink( pI->aURL, pI->aFilterName );
586 pObj->SetLogicRect( aRect ); // erst nach InsertObject !!!
588 nDir = pI->nDir;
593 ScEEParser::ScEEParser( EditEngine* pEditP ) :
594 pEdit( pEditP ),
595 pPool( EditEngine::CreatePool() ),
596 pDocPool( new ScDocumentPool ),
597 pList( new ScEEParseList ),
598 pColWidths( new Table ),
599 nLastToken(0),
600 nColCnt(0),
601 nRowCnt(0),
602 nColMax(0),
603 nRowMax(0)
605 // pPool wird spaeter bei RTFIMP_START dem SvxRTFParser untergejubelt
606 pPool->SetSecondaryPool( pDocPool );
607 pPool->FreezeIdRanges();
608 NewActEntry( NULL );
612 ScEEParser::~ScEEParser()
614 delete pActEntry;
615 delete pColWidths;
616 for ( ScEEParseEntry* pE = pList->First(); pE; pE = pList->Next() )
617 delete pE;
618 delete pList;
620 // Pool erst loeschen nachdem die Listen geloescht wurden
621 pPool->SetSecondaryPool( NULL );
622 SfxItemPool::Free(pDocPool);
623 SfxItemPool::Free(pPool);
627 void ScEEParser::NewActEntry( ScEEParseEntry* pE )
628 { // neuer freifliegender pActEntry
629 pActEntry = new ScEEParseEntry( pPool );
630 pActEntry->aSel.nStartPara = (pE ? pE->aSel.nEndPara + 1 : 0);
631 pActEntry->aSel.nStartPos = 0;