Update ooo320-m1
[ooovba.git] / sc / source / filter / rtf / eeimpars.cxx
blobb25ad37846d204c6b49bf9709912d6e0318e157e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: eeimpars.cxx,v $
10 * $Revision: 1.19 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 //------------------------------------------------------------------------
38 #include "scitems.hxx"
39 #include <svx/eeitem.hxx>
42 #include <svx/adjitem.hxx>
43 #include <svx/editobj.hxx>
44 #include <svx/editview.hxx>
45 #include <svx/escpitem.hxx>
46 #include <svx/langitem.hxx>
47 #include <svx/svdograf.hxx>
48 #include <svx/svdpage.hxx>
49 #include <svx/scripttypeitem.hxx>
50 #include <svx/htmlcfg.hxx>
51 #include <sfx2/sfxhtml.hxx>
52 #include <svtools/parhtml.hxx>
53 #include <svtools/zforlist.hxx>
54 #include <vcl/virdev.hxx>
55 #include <vcl/svapp.hxx>
56 #include <svtools/syslocale.hxx>
57 #include <unotools/charclass.hxx>
59 #include "eeimport.hxx"
60 #include "global.hxx"
61 #include "document.hxx"
62 #include "editutil.hxx"
63 #include "stlsheet.hxx"
64 #include "docpool.hxx"
65 #include "attrib.hxx"
66 #include "patattr.hxx"
67 #include "cell.hxx"
68 #include "eeparser.hxx"
69 #include "drwlayer.hxx"
70 #include "rangenam.hxx"
71 #include "progress.hxx"
72 #include "stringutil.hxx"
74 #include "globstr.hrc"
76 // in fuins1.cxx
77 extern void ScLimitSizeOnDrawPage( Size& rSize, Point& rPos, const Size& rPage );
79 //------------------------------------------------------------------------
81 ScEEImport::ScEEImport( ScDocument* pDocP, const ScRange& rRange ) :
82 maRange( rRange ),
83 mpDoc( pDocP ),
84 mpParser( NULL ),
85 mpRowHeights( new Table )
87 const ScPatternAttr* pPattern = mpDoc->GetPattern(
88 maRange.aStart.Col(), maRange.aStart.Row(), maRange.aStart.Tab() );
89 mpEngine = new ScTabEditEngine( *pPattern, mpDoc->GetEditPool() );
90 mpEngine->SetUpdateMode( FALSE );
91 mpEngine->EnableUndo( FALSE );
95 ScEEImport::~ScEEImport()
97 // Reihenfolge wichtig, sonst knallt's irgendwann irgendwo in irgendeinem Dtor!
98 // Ist gewaehrleistet, da ScEEImport Basisklasse ist
99 delete mpEngine; // nach Parser!
100 delete mpRowHeights;
104 ULONG ScEEImport::Read( SvStream& rStream, const String& rBaseURL )
106 ULONG nErr = mpParser->Read( rStream, rBaseURL );
108 SCCOL nEndCol;
109 SCROW nEndRow;
110 mpParser->GetDimensions( nEndCol, nEndRow );
111 if ( nEndCol != 0 )
113 nEndCol += maRange.aStart.Col() - 1;
114 if ( nEndCol > MAXCOL )
115 nEndCol = MAXCOL;
117 else
118 nEndCol = maRange.aStart.Col();
119 if ( nEndRow != 0 )
121 nEndRow += maRange.aStart.Row() - 1;
122 if ( nEndRow > MAXROW )
123 nEndRow = MAXROW;
125 else
126 nEndRow = maRange.aStart.Row();
127 maRange.aEnd.Set( nEndCol, nEndRow, maRange.aStart.Tab() );
129 return nErr;
133 void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate )
135 ScProgress* pProgress = new ScProgress( mpDoc->GetDocumentShell(),
136 ScGlobal::GetRscString( STR_LOAD_DOC ), mpParser->Count() );
137 ULONG nProgress = 0;
139 SCCOL nStartCol, nEndCol;
140 SCROW nStartRow, nEndRow;
141 SCTAB nTab;
142 SCROW nOverlapRowMax, nLastMergedRow;
143 SCCOL nMergeColAdd;
144 nStartCol = maRange.aStart.Col();
145 nStartRow = maRange.aStart.Row();
146 nTab = maRange.aStart.Tab();
147 nEndCol = maRange.aEnd.Col();
148 nEndRow = maRange.aEnd.Row();
149 nOverlapRowMax = 0;
150 nMergeColAdd = 0;
151 nLastMergedRow = SCROW_MAX;
152 BOOL bHasGraphics = FALSE;
153 ScEEParseEntry* pE;
154 if (!pFormatter)
155 pFormatter = mpDoc->GetFormatTable();
156 bool bNumbersEnglishUS = (pFormatter->GetLanguage() != LANGUAGE_ENGLISH_US);
157 if (bNumbersEnglishUS)
159 SvxHtmlOptions aOpt;
160 bNumbersEnglishUS = aOpt.IsNumbersEnglishUS();
162 ScDocumentPool* pDocPool = mpDoc->GetPool();
163 ScRangeName* pRangeNames = mpDoc->GetRangeName();
164 for ( pE = mpParser->First(); pE; pE = mpParser->Next() )
166 SCROW nRow = nStartRow + pE->nRow;
167 if ( nRow != nLastMergedRow )
168 nMergeColAdd = 0;
169 SCCOL nCol = nStartCol + pE->nCol + nMergeColAdd;
170 // RowMerge feststellen, pures ColMerge und ColMerge der ersten
171 // MergeRow bereits beim parsen
172 if ( nRow <= nOverlapRowMax )
174 while ( nCol <= MAXCOL && mpDoc->HasAttrib( nCol, nRow, nTab,
175 nCol, nRow, nTab, HASATTR_OVERLAPPED ) )
177 nCol++;
178 nMergeColAdd++;
180 nLastMergedRow = nRow;
182 // fuer zweiten Durchlauf eintragen
183 pE->nCol = nCol;
184 pE->nRow = nRow;
185 if ( ValidCol(nCol) && ValidRow(nRow) )
187 SfxItemSet aSet = mpEngine->GetAttribs( pE->aSel );
188 // Default raus, wir setzen selber links/rechts je nachdem ob Text
189 // oder Zahl; EditView.GetAttribs liefert immer kompletten Set
190 // mit Defaults aufgefuellt
191 const SfxPoolItem& rItem = aSet.Get( EE_PARA_JUST );
192 if ( ((const SvxAdjustItem&)rItem).GetAdjust() == SVX_ADJUST_LEFT )
193 aSet.ClearItem( EE_PARA_JUST );
195 // Testen, ob einfacher String ohne gemischte Attribute
196 BOOL bSimple = ( pE->aSel.nStartPara == pE->aSel.nEndPara );
197 for (USHORT nId = EE_CHAR_START; nId <= EE_CHAR_END && bSimple; nId++)
199 const SfxPoolItem* pItem = 0;
200 SfxItemState eState = aSet.GetItemState( nId, TRUE, &pItem );
201 if (eState == SFX_ITEM_DONTCARE)
202 bSimple = FALSE;
203 else if (eState == SFX_ITEM_SET)
205 if ( nId == EE_CHAR_ESCAPEMENT ) // Hoch-/Tiefstellen immer ueber EE
207 if ( (SvxEscapement)((const SvxEscapementItem*)pItem)->GetEnumValue()
208 != SVX_ESCAPEMENT_OFF )
209 bSimple = FALSE;
213 if ( bSimple )
214 { // Feldbefehle enthalten?
215 SfxItemState eFieldState = aSet.GetItemState( EE_FEATURE_FIELD, FALSE );
216 if ( eFieldState == SFX_ITEM_DONTCARE || eFieldState == SFX_ITEM_SET )
217 bSimple = FALSE;
220 // HTML
221 String aValStr, aNumStr;
222 double fVal;
223 sal_uInt32 nNumForm = 0;
224 LanguageType eNumLang = LANGUAGE_NONE;
225 if ( pE->pNumStr )
226 { // SDNUM muss sein wenn SDVAL
227 aNumStr = *pE->pNumStr;
228 if ( pE->pValStr )
229 aValStr = *pE->pValStr;
230 fVal = SfxHTMLParser::GetTableDataOptionsValNum(
231 nNumForm, eNumLang, aValStr, aNumStr, *pFormatter );
234 // Attribute setzen
235 ScPatternAttr aAttr( pDocPool );
236 aAttr.GetFromEditItemSet( &aSet );
237 SfxItemSet& rSet = aAttr.GetItemSet();
238 if ( aNumStr.Len() )
240 rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumForm ) );
241 rSet.Put( SvxLanguageItem( eNumLang, ATTR_LANGUAGE_FORMAT ) );
243 const SfxItemSet& rESet = pE->aItemSet;
244 if ( rESet.Count() )
246 const SfxPoolItem* pItem;
247 if ( rESet.GetItemState( ATTR_BACKGROUND, FALSE, &pItem) == SFX_ITEM_SET )
248 rSet.Put( *pItem );
249 if ( rESet.GetItemState( ATTR_BORDER, FALSE, &pItem) == SFX_ITEM_SET )
250 rSet.Put( *pItem );
251 if ( rESet.GetItemState( ATTR_SHADOW, FALSE, &pItem) == SFX_ITEM_SET )
252 rSet.Put( *pItem );
253 // HTML
254 if ( rESet.GetItemState( ATTR_HOR_JUSTIFY, FALSE, &pItem) == SFX_ITEM_SET )
255 rSet.Put( *pItem );
256 if ( rESet.GetItemState( ATTR_VER_JUSTIFY, FALSE, &pItem) == SFX_ITEM_SET )
257 rSet.Put( *pItem );
258 if ( rESet.GetItemState( ATTR_LINEBREAK, FALSE, &pItem) == SFX_ITEM_SET )
259 rSet.Put( *pItem );
260 if ( rESet.GetItemState( ATTR_FONT_COLOR, FALSE, &pItem) == SFX_ITEM_SET )
261 rSet.Put( *pItem );
262 if ( rESet.GetItemState( ATTR_FONT_UNDERLINE, FALSE, &pItem) == SFX_ITEM_SET )
263 rSet.Put( *pItem );
264 // HTML LATIN/CJK/CTL script type dependent
265 const SfxPoolItem* pFont;
266 if ( rESet.GetItemState( ATTR_FONT, FALSE, &pFont) != SFX_ITEM_SET )
267 pFont = 0;
268 const SfxPoolItem* pHeight;
269 if ( rESet.GetItemState( ATTR_FONT_HEIGHT, FALSE, &pHeight) != SFX_ITEM_SET )
270 pHeight = 0;
271 const SfxPoolItem* pWeight;
272 if ( rESet.GetItemState( ATTR_FONT_WEIGHT, FALSE, &pWeight) != SFX_ITEM_SET )
273 pWeight = 0;
274 const SfxPoolItem* pPosture;
275 if ( rESet.GetItemState( ATTR_FONT_POSTURE, FALSE, &pPosture) != SFX_ITEM_SET )
276 pPosture = 0;
277 if ( pFont || pHeight || pWeight || pPosture )
279 String aStr( mpEngine->GetText( pE->aSel ) );
280 BYTE nScriptType = mpDoc->GetStringScriptType( aStr );
281 const BYTE nScripts[3] = { SCRIPTTYPE_LATIN,
282 SCRIPTTYPE_ASIAN, SCRIPTTYPE_COMPLEX };
283 for ( BYTE i=0; i<3; ++i )
285 if ( nScriptType & nScripts[i] )
287 if ( pFont )
288 rSet.Put( *pFont, ScGlobal::GetScriptedWhichID(
289 nScripts[i], ATTR_FONT ));
290 if ( pHeight )
291 rSet.Put( *pHeight, ScGlobal::GetScriptedWhichID(
292 nScripts[i], ATTR_FONT_HEIGHT ));
293 if ( pWeight )
294 rSet.Put( *pWeight, ScGlobal::GetScriptedWhichID(
295 nScripts[i], ATTR_FONT_WEIGHT ));
296 if ( pPosture )
297 rSet.Put( *pPosture, ScGlobal::GetScriptedWhichID(
298 nScripts[i], ATTR_FONT_POSTURE ));
303 if ( pE->nColOverlap > 1 || pE->nRowOverlap > 1 )
304 { // merged cells, mit SfxItemSet Put schneller als mit
305 // nachtraeglichem ScDocument DoMerge
306 ScMergeAttr aMerge( pE->nColOverlap, pE->nRowOverlap );
307 rSet.Put( aMerge );
308 SCROW nRO = 0;
309 if ( pE->nColOverlap > 1 )
310 mpDoc->ApplyFlagsTab( nCol+1, nRow,
311 nCol + pE->nColOverlap - 1, nRow, nTab,
312 SC_MF_HOR );
313 if ( pE->nRowOverlap > 1 )
315 nRO = nRow + pE->nRowOverlap - 1;
316 mpDoc->ApplyFlagsTab( nCol, nRow+1,
317 nCol, nRO , nTab,
318 SC_MF_VER );
319 if ( nRO > nOverlapRowMax )
320 nOverlapRowMax = nRO;
322 if ( pE->nColOverlap > 1 && pE->nRowOverlap > 1 )
323 mpDoc->ApplyFlagsTab( nCol+1, nRow+1,
324 nCol + pE->nColOverlap - 1, nRO, nTab,
325 SC_MF_HOR | SC_MF_VER );
327 const ScStyleSheet* pStyleSheet =
328 mpDoc->GetPattern( nCol, nRow, nTab )->GetStyleSheet();
329 aAttr.SetStyleSheet( (ScStyleSheet*)pStyleSheet );
330 mpDoc->SetPattern( nCol, nRow, nTab, aAttr, TRUE );
332 // Daten eintragen
333 if (bSimple)
335 ScSetStringParam aParam;
336 aParam.mpNumFormatter = pFormatter;
337 aParam.mbDetectNumberFormat = true;
338 aParam.mbSetTextCellFormat = true;
340 if ( aValStr.Len() )
341 mpDoc->SetValue( nCol, nRow, nTab, fVal );
342 else if ( !pE->aSel.HasRange() )
344 // maybe ALT text of IMG or similar
345 mpDoc->SetString( nCol, nRow, nTab, pE->aAltText, &aParam );
346 // wenn SelRange komplett leer kann nachfolgender Text im gleichen Absatz liegen!
348 else
350 String aStr;
351 if( pE->bEntirePara )
353 aStr = mpEngine->GetText( pE->aSel.nStartPara );
355 else
357 aStr = mpEngine->GetText( pE->aSel );
358 aStr.EraseLeadingAndTrailingChars();
361 // TODO: RTF import should follow the language tag,
362 // currently this follows the HTML options for both, HTML
363 // and RTF.
364 bool bEnUsRecognized = false;
365 if (bNumbersEnglishUS)
367 pFormatter->ChangeIntl( LANGUAGE_ENGLISH_US);
368 sal_uInt32 nIndex = pFormatter->GetStandardIndex( LANGUAGE_ENGLISH_US);
369 double fEnVal = 0.0;
370 if (pFormatter->IsNumberFormat( aStr, nIndex, fEnVal))
372 bEnUsRecognized = true;
373 sal_uInt32 nNewIndex =
374 pFormatter->GetFormatForLanguageIfBuiltIn(
375 nIndex, LANGUAGE_SYSTEM);
376 DBG_ASSERT( nNewIndex != nIndex, "ScEEImport::WriteToDocument: NumbersEnglishUS not a built-in format?");
377 pFormatter->GetInputLineString( fEnVal, nNewIndex, aStr);
379 pFormatter->ChangeIntl( LANGUAGE_SYSTEM);
382 // #105460#, #i4180# String cells can't contain tabs or linebreaks
383 // -> replace with spaces
384 aStr.SearchAndReplaceAll( (sal_Unicode)'\t', (sal_Unicode)' ' );
385 aStr.SearchAndReplaceAll( (sal_Unicode)'\n', (sal_Unicode)' ' );
387 if (bNumbersEnglishUS && !bEnUsRecognized)
388 mpDoc->PutCell( nCol, nRow, nTab, new ScStringCell( aStr));
389 else
391 aParam.mbDetectNumberFormat = bConvertDate;
392 mpDoc->SetString( nCol, nRow, nTab, aStr, &aParam );
396 else
398 EditTextObject* pObject = mpEngine->CreateTextObject( pE->aSel );
399 mpDoc->PutCell( nCol, nRow, nTab, new ScEditCell( pObject,
400 mpDoc, mpEngine->GetEditTextObjectPool() ) );
401 delete pObject;
403 if ( pE->pImageList )
404 bHasGraphics |= GraphicSize( nCol, nRow, nTab, pE );
405 if ( pE->pName )
406 { // Anchor Name => RangeName
407 USHORT nIndex;
408 if ( !pRangeNames->SearchName( *pE->pName, nIndex ) )
410 ScRangeData* pData = new ScRangeData( mpDoc, *pE->pName,
411 ScAddress( nCol, nRow, nTab ) );
412 pRangeNames->Insert( pData );
416 pProgress->SetStateOnPercent( ++nProgress );
418 if ( bSizeColsRows )
420 // Spaltenbreiten
421 Table* pColWidths = mpParser->GetColWidths();
422 if ( pColWidths->Count() )
424 nProgress = 0;
425 pProgress->SetState( nProgress, nEndCol - nStartCol + 1 );
426 for ( SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ )
428 USHORT nWidth = (USHORT)(ULONG) pColWidths->Get( nCol );
429 if ( nWidth )
430 mpDoc->SetColWidth( nCol, nTab, nWidth );
431 pProgress->SetState( ++nProgress );
434 DELETEZ( pProgress ); // SetOptimalHeight hat seinen eigenen ProgressBar
435 // Zeilenhoehen anpassen, Basis 100% Zoom
436 Fraction aZoom( 1, 1 );
437 double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom
438 / nOutputFactor; // Faktor ist Drucker zu Bildschirm
439 double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom;
440 VirtualDevice aVirtDev;
441 mpDoc->SetOptimalHeight( 0, nEndRow, 0,
442 static_cast< USHORT >( ScGlobal::nLastRowHeightExtra ), &aVirtDev,
443 nPPTX, nPPTY, aZoom, aZoom, FALSE );
444 if ( mpRowHeights->Count() )
446 for ( SCROW nRow = nStartRow; nRow <= nEndRow; nRow++ )
448 USHORT nHeight = (USHORT)(ULONG) mpRowHeights->Get( nRow );
449 if ( nHeight > mpDoc->FastGetRowHeight( nRow, nTab ) )
450 mpDoc->SetRowHeight( nRow, nTab, nHeight );
454 if ( bHasGraphics )
455 { // Grafiken einfuegen
456 for ( pE = mpParser->First(); pE; pE = mpParser->Next() )
458 if ( pE->pImageList )
460 SCCOL nCol = pE->nCol;
461 SCROW nRow = pE->nRow;
462 if ( ValidCol(nCol) && ValidRow(nRow) )
463 InsertGraphic( nCol, nRow, nTab, pE );
467 if ( pProgress )
468 delete pProgress;
472 BOOL ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/,
473 ScEEParseEntry* pE )
475 ScHTMLImageList* pIL = pE->pImageList;
476 if ( !pIL || !pIL->Count() )
477 return FALSE;
478 BOOL bHasGraphics = FALSE;
479 OutputDevice* pDefaultDev = Application::GetDefaultDevice();
480 long nWidth, nHeight;
481 nWidth = nHeight = 0;
482 sal_Char nDir = nHorizontal;
483 for ( ScHTMLImage* pI = pIL->First(); pI; pI = pIL->Next() )
485 if ( pI->pGraphic )
486 bHasGraphics = TRUE;
487 Size aSizePix = pI->aSize;
488 aSizePix.Width() += 2 * pI->aSpace.X();
489 aSizePix.Height() += 2 * pI->aSpace.Y();
490 Size aLogicSize = pDefaultDev->PixelToLogic( aSizePix, MapMode( MAP_TWIP ) );
491 if ( nDir & nHorizontal )
492 nWidth += aLogicSize.Width();
493 else if ( nWidth < aLogicSize.Width() )
494 nWidth = aLogicSize.Width();
495 if ( nDir & nVertical )
496 nHeight += aLogicSize.Height();
497 else if ( nHeight < aLogicSize.Height() )
498 nHeight = aLogicSize.Height();
499 nDir = pI->nDir;
501 // Spaltenbreiten
502 Table* pColWidths = mpParser->GetColWidths();
503 long nThisWidth = (long) pColWidths->Get( nCol );
504 long nColWidths = nThisWidth;
505 SCCOL nColSpanCol = nCol + pE->nColOverlap;
506 for ( SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ )
508 nColWidths += (long) pColWidths->Get( nC );
510 if ( nWidth > nColWidths )
511 { // Differenz nur in der ersten Spalte eintragen
512 if ( nThisWidth )
513 pColWidths->Replace( nCol, (void*)(nWidth - nColWidths + nThisWidth) );
514 else
515 pColWidths->Insert( nCol, (void*)(nWidth - nColWidths) );
517 // Zeilenhoehen, Differenz auf alle betroffenen Zeilen verteilen
518 SCROW nRowSpan = pE->nRowOverlap;
519 nHeight /= nRowSpan;
520 if ( nHeight == 0 )
521 nHeight = 1; // fuer eindeutigen Vergleich
522 for ( SCROW nR = nRow; nR < nRow + nRowSpan; nR++ )
524 long nRowHeight = (long) mpRowHeights->Get( nR );
525 if ( nHeight > nRowHeight )
527 if ( nRowHeight )
528 mpRowHeights->Replace( nR, (void*)nHeight );
529 else
530 mpRowHeights->Insert( nR, (void*)nHeight );
533 return bHasGraphics;
537 void ScEEImport::InsertGraphic( SCCOL nCol, SCROW nRow, SCTAB nTab,
538 ScEEParseEntry* pE )
540 ScHTMLImageList* pIL = pE->pImageList;
541 if ( !pIL || !pIL->Count() )
542 return ;
543 ScDrawLayer* pModel = mpDoc->GetDrawLayer();
544 if (!pModel)
546 mpDoc->InitDrawLayer();
547 pModel = mpDoc->GetDrawLayer();
549 SdrPage* pPage = pModel->GetPage( static_cast<sal_uInt16>(nTab) );
550 OutputDevice* pDefaultDev = Application::GetDefaultDevice();
552 Point aCellInsertPos(
553 (long)((double) mpDoc->GetColOffset( nCol, nTab ) * HMM_PER_TWIPS),
554 (long)((double) mpDoc->GetRowOffset( nRow, nTab ) * HMM_PER_TWIPS) );
556 Point aInsertPos( aCellInsertPos );
557 Point aSpace;
558 Size aLogicSize;
559 sal_Char nDir = nHorizontal;
560 for ( ScHTMLImage* pI = pIL->First(); pI; pI = pIL->Next() )
562 if ( nDir & nHorizontal )
563 { // horizontal
564 aInsertPos.X() += aLogicSize.Width();
565 aInsertPos.X() += aSpace.X();
566 aInsertPos.Y() = aCellInsertPos.Y();
568 else
569 { // vertikal
570 aInsertPos.X() = aCellInsertPos.X();
571 aInsertPos.Y() += aLogicSize.Height();
572 aInsertPos.Y() += aSpace.Y();
574 // Offset des Spacings drauf
575 aSpace = pDefaultDev->PixelToLogic( pI->aSpace, MapMode( MAP_100TH_MM ) );
576 aInsertPos += aSpace;
578 Size aSizePix = pI->aSize;
579 aLogicSize = pDefaultDev->PixelToLogic( aSizePix, MapMode( MAP_100TH_MM ) );
580 // Groesse begrenzen
581 ::ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() );
583 if ( pI->pGraphic )
585 Rectangle aRect ( aInsertPos, aLogicSize );
586 SdrGrafObj* pObj = new SdrGrafObj( *pI->pGraphic, aRect );
587 // #118522# calling SetGraphicLink here doesn't work
588 pObj->SetName( pI->aURL );
590 pPage->InsertObject( pObj );
592 // #118522# SetGraphicLink has to be used after inserting the object,
593 // otherwise an empty graphic is swapped in and the contact stuff crashes.
594 // See #i37444#.
595 pObj->SetGraphicLink( pI->aURL, pI->aFilterName );
597 pObj->SetLogicRect( aRect ); // erst nach InsertObject !!!
599 nDir = pI->nDir;
604 ScEEParser::ScEEParser( EditEngine* pEditP ) :
605 pEdit( pEditP ),
606 pPool( EditEngine::CreatePool() ),
607 pDocPool( new ScDocumentPool ),
608 pList( new ScEEParseList ),
609 pColWidths( new Table ),
610 nLastToken(0),
611 nColCnt(0),
612 nRowCnt(0),
613 nColMax(0),
614 nRowMax(0)
616 // pPool wird spaeter bei RTFIMP_START dem SvxRTFParser untergejubelt
617 pPool->SetSecondaryPool( pDocPool );
618 pPool->FreezeIdRanges();
619 NewActEntry( NULL );
623 ScEEParser::~ScEEParser()
625 delete pActEntry;
626 delete pColWidths;
627 for ( ScEEParseEntry* pE = pList->First(); pE; pE = pList->Next() )
628 delete pE;
629 delete pList;
631 // Pool erst loeschen nachdem die Listen geloescht wurden
632 pPool->SetSecondaryPool( NULL );
633 SfxItemPool::Free(pDocPool);
634 SfxItemPool::Free(pPool);
638 void ScEEParser::NewActEntry( ScEEParseEntry* pE )
639 { // neuer freifliegender pActEntry
640 pActEntry = new ScEEParseEntry( pPool );
641 pActEntry->aSel.nStartPara = (pE ? pE->aSel.nEndPara + 1 : 0);
642 pActEntry->aSel.nStartPos = 0;