1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_filter.hxx" 26 #include <osl/endian.h> 27 #include <vcl/svapp.hxx> 28 #include <unotools/tempfile.hxx> 29 #include <math.h> 30 #include <editeng/eeitem.hxx> 31 #include <sot/storage.hxx> 32 #include <sot/storinfo.hxx> 33 #include <sot/stg.hxx> 34 #include <com/sun/star/embed/Aspects.hpp> 35 #include <com/sun/star/office/XAnnotation.hpp> 36 #include <com/sun/star/office/XAnnotationAccess.hpp> 37 #include <com/sun/star/text/XText.hpp> 38 #include <com/sun/star/geometry/RealPoint2D.hpp> 39 #include <com/sun/star/util/DateTime.hpp> 40 #include <com/sun/star/drawing/BitmapMode.hpp> 41 #include <unotools/streamwrap.hxx> 42 #include <filter/msfilter/svdfppt.hxx> 43 #include <svx/xpoly.hxx> 44 #include <svx/svdtrans.hxx> 45 #include <svx/svdmodel.hxx> 46 #include <svx/svdpage.hxx> 47 #include <svx/svdobj.hxx> 48 #include <svx/svdogrp.hxx> 49 #include <svx/svdorect.hxx> 50 #include <svx/svdopage.hxx> 51 #include <svx/svdograf.hxx> 52 #include <svx/svdopath.hxx> 53 #include <svx/svdocirc.hxx> 54 #include <svx/svdocapt.hxx> 55 #include <svx/svdotable.hxx> 56 #include <editeng/outlobj.hxx> 57 #include <svx/svdattr.hxx> 58 #include "svx/xattr.hxx" 59 #include "svx/svditext.hxx" 60 #include <svx/svdetc.hxx> 61 #include <editeng/bulitem.hxx> 62 #include <svx/polysc3d.hxx> 63 #include <svx/extrud3d.hxx> 64 #include <svx/svdoashp.hxx> 65 #include <editeng/tstpitem.hxx> 66 #include <editeng/unoprnms.hxx> 67 #include <editeng/editids.hrc> 68 69 #if defined(JOEENV) && defined(JOEDEBUG) 70 #include "impinccv.h" // etwas Testkram 71 #endif 72 73 #if defined(DBG_EXTRACTOLEOBJECTS) || defined(DBG_EXTRACTFONTMETRICS) 74 #include <tools/urlobj.hxx> 75 #include <unotools/localfilehelper.hxx> 76 #endif 77 78 #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue() 79 #include <editeng/adjitem.hxx> 80 #include <editeng/escpitem.hxx> 81 #include <editeng/colritem.hxx> 82 #include <editeng/fhgtitem.hxx> 83 #include <editeng/wghtitem.hxx> 84 #include <editeng/postitem.hxx> 85 #include <editeng/udlnitem.hxx> 86 #include <editeng/crsditem.hxx> 87 #include <editeng/shdditem.hxx> 88 #include <editeng/charreliefitem.hxx> 89 #include <editeng/fontitem.hxx> 90 #include <svx/svdoutl.hxx> 91 #include <editeng/editeng.hxx> 92 #include <editeng/lspcitem.hxx> 93 #include <editeng/ulspitem.hxx> 94 #include <editeng/lrspitem.hxx> 95 #include <vcl/metric.hxx> 96 #include <vcl/bmpacc.hxx> 97 #include <svx/svditer.hxx> 98 #include <svx/svdoedge.hxx> 99 #include <svx/sxekitm.hxx> 100 #include <editeng/flditem.hxx> 101 #include <svtools/sychconv.hxx> 102 #include <tools/zcodec.hxx> 103 #include <filter/msfilter/svxmsbas.hxx> 104 #include <sfx2/objsh.hxx> 105 #include <editeng/brshitem.hxx> 106 #include <editeng/langitem.hxx> 107 #include <svx/svdoole2.hxx> 108 #include <svx/unoapi.hxx> 109 #include <toolkit/unohlp.hxx> 110 #include <com/sun/star/container/XIndexContainer.hpp> 111 #include <com/sun/star/drawing/XShapes.hpp> 112 #include <com/sun/star/drawing/XControlShape.hpp> 113 #include <com/sun/star/form/XFormComponent.hpp> 114 #include <com/sun/star/beans/XPropertySet.hpp> 115 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 116 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> 117 #include <com/sun/star/drawing/XDrawPageSupplier.hpp> 118 #include <com/sun/star/awt/Size.hpp> 119 #include <com/sun/star/awt/Point.hpp> 120 #include <com/sun/star/drawing/FillStyle.hpp> 121 #include <com/sun/star/drawing/TextVerticalAdjust.hpp> 122 #include <editeng/writingmodeitem.hxx> 123 #include <vcl/print.hxx> 124 #include <editeng/svxfont.hxx> 125 #include <editeng/frmdiritem.hxx> 126 #include <svx/sdtfchim.hxx> 127 #include <unotools/ucbstreamhelper.hxx> 128 #include <editeng/scripttypeitem.hxx> 129 #include "com/sun/star/awt/Gradient.hpp" 130 #include <com/sun/star/table/XMergeableCellRange.hpp> 131 #include <com/sun/star/table/BorderLine.hpp> 132 #include <vcl/virdev.hxx> 133 #include <algorithm> 134 #include <set> 135 136 //////////////////////////////////////////////////////////////////////////////////////////////////// 137 138 // PPT ColorScheme Slots 139 #define PPT_COLSCHEME (0x08000000) 140 #define PPT_COLSCHEME_HINTERGRUND (0x08000000) 141 #define PPT_COLSCHEME_TEXT_UND_ZEILEN (0x08000001) 142 #define PPT_COLSCHEME_SCHATTEN (0x08000002) 143 #define PPT_COLSCHEME_TITELTEXT (0x08000003) 144 #define PPT_COLSCHEME_FUELLBEREICHE (0x08000004) 145 #define PPT_COLSCHEME_AKZENT (0x08000005) 146 #define PPT_COLSCHEME_A_UND_HYPERLINK (0x08000006) 147 #define PPT_COLSCHEME_A_H_GESICHERT (0x08000007) 148 149 //////////////////////////////////////////////////////////////////////////////////////////////////// 150 151 #define ANSI_CHARSET 0 152 #define DEFAULT_CHARSET 1 153 #define SYMBOL_CHARSET 2 154 #define SHIFTJIS_CHARSET 128 155 #define HANGEUL_CHARSET 129 156 #define CHINESEBIG5_CHARSET 136 157 #define OEM_CHARSET 255 158 159 //////////////////////////////////////////////////////////////////////////////////////////////////// 160 161 /* Font Families */ 162 #define FF_DONTCARE 0x00 163 #define FF_ROMAN 0x10 164 #define FF_SWISS 0x20 165 #define FF_MODERN 0x30 166 #define FF_SCRIPT 0x40 167 #define FF_DECORATIVE 0x50 168 169 //////////////////////////////////////////////////////////////////////////////////////////////////// 170 171 #define DEFAULT_PITCH 0x00 172 #define FIXED_PITCH 0x01 173 #define VARIABLE_PITCH 0x02 174 175 using namespace ::com::sun::star ; 176 using namespace uno ; 177 using namespace beans ; 178 using namespace drawing ; 179 using namespace container ; 180 using namespace table ; 181 182 //////////////////////////////////////////////////////////////////////////////////////////////////// 183 184 PowerPointImportParam::PowerPointImportParam( SvStream& rDocStrm, sal_uInt32 nFlags, MSFilterTracer* pT ) : 185 rDocStream ( rDocStrm ), 186 nImportFlags ( nFlags ), 187 pTracer ( pT ) 188 { 189 } 190 191 //////////////////////////////////////////////////////////////////////////////////////////////////// 192 193 SvStream& operator>>( SvStream& rIn, PptCurrentUserAtom& rAtom ) 194 { 195 DffRecordHeader aHd; 196 rIn >> aHd; 197 if ( aHd.nRecType == PPT_PST_CurrentUserAtom ) 198 { 199 sal_uInt32 nLen; 200 sal_uInt16 nUserNameLen, nPad; 201 rIn >> nLen 202 >> rAtom.nMagic 203 >> rAtom.nCurrentUserEdit 204 >> nUserNameLen 205 >> rAtom.nDocFileVersion 206 >> rAtom.nMajorVersion 207 >> rAtom.nMinorVersion 208 >> nPad; 209 SvxMSDffManager::MSDFFReadZString( rIn, rAtom.aCurrentUser, nUserNameLen, sal_True ); 210 } 211 aHd.SeekToEndOfRecord( rIn ); 212 return rIn; 213 } 214 215 void PptSlidePersistAtom::Clear() 216 { 217 nReserved = nPsrReference = nFlags = nNumberTexts = nSlideId = 0; 218 } 219 220 SvStream& operator>>( SvStream& rIn, PptSlidePersistAtom& rAtom ) 221 { 222 DffRecordHeader aHd; 223 rIn >> aHd 224 >> rAtom.nPsrReference 225 >> rAtom.nFlags 226 >> rAtom.nNumberTexts 227 >> rAtom.nSlideId; 228 // >> rAtom.nReserved; 229 aHd.SeekToEndOfRecord( rIn ); 230 return rIn; 231 } 232 233 SV_IMPL_PTRARR(_PptSlidePersistList,PptSlidePersistEntry*); 234 235 sal_uInt16 PptSlidePersistList::FindPage(sal_uInt32 nId) const 236 { 237 for ( sal_uInt16 i=0; i < Count(); i++ ) 238 { 239 if (operator[](i)->GetSlideId()==nId) return i; 240 } 241 return PPTSLIDEPERSIST_ENTRY_NOTFOUND; 242 } 243 244 //////////////////////////////////////////////////////////////////////////////////////////////////// 245 246 SvStream& operator>>( SvStream& rIn, PptInteractiveInfoAtom& rAtom ) 247 { 248 rIn >> rAtom.nSoundRef 249 >> rAtom.nExHyperlinkId 250 >> rAtom.nAction 251 >> rAtom.nOleVerb 252 >> rAtom.nJump 253 >> rAtom.nFlags 254 >> rAtom.nHyperlinkType 255 >> rAtom.nUnknown1 256 >> rAtom.nUnknown2 257 >> rAtom.nUnknown3; 258 return rIn; 259 } 260 261 SvStream& operator>>( SvStream& rIn, PptExOleObjAtom& rAtom ) 262 { 263 rIn >> rAtom.nAspect 264 >> rAtom.nDummy1 265 >> rAtom.nId 266 >> rAtom.nDummy2 267 >> rAtom.nPersistPtr 268 >> rAtom.nDummy4; 269 return rIn; 270 } 271 272 Size PptDocumentAtom::GetPageSize(const Size& rSiz) const 273 { 274 return rSiz; 275 /* 276 Size aRet; 277 switch ( eSlidesPageFormat ) 278 { 279 // Wenn man in Powerpoint als Seitenformat "Bildschirmgroesse" 280 // einstellt, dann zeigt dieser Dialog zwar 24x18cm an, die 281 // angezeigte Seite ist aber anders. Das sieht man, wenn man 282 // ein Rechteck seitenfuellend aufzieht und sich dessen Groesse 283 // ansieht. Die importierten Abmessungen sind auf jeden Fall 284 // die, die auch im Ppt-File stehen. Ich denke, das es sich 285 // hier eher um ein Bug in PowerPoint handelt, das im 286 // Seitenformat-Dialog bei "Bildschirmgroesse" falsche Masse 287 // angezeigt werden (vielleicht ja auch bildschirmabhaengig?). 288 // case PPTPF_SCREEN : aRet.Width()=4082; aRet.Height()=5443; break; 289 case PPTPF_USLETTER: aRet.Width()=4896; aRet.Height()=6336; break; 290 case PPTPF_A4 : aRet.Width()=4762; aRet.Height()=6735; break; 291 // case PPTPF_35MMDIA : aRet.Width()=4082; aRet.Height()=6123; break; 292 // case PPTPF_OVERHEAD: aRet.Width()=4082; aRet.Height()=5443; break; 293 } 294 if ( aRet.Width() ) 295 { 296 if ( rSiz.Width() > rSiz.Height() ) 297 { // Querformat 298 long nMerk = aRet.Width(); 299 aRet.Width() = aRet.Height(); 300 aRet.Height() = nMerk; 301 } 302 } 303 else // CustomFormat oder Unbekannt oder Screen,Dia,Overhead 304 aRet = rSiz; 305 return aRet; 306 */ 307 } 308 309 SvStream& operator>>(SvStream& rIn, PptDocumentAtom& rAtom) 310 { 311 // Tatsaechliches Format: 312 // 00 aSlidePageSizeXY 8 313 // 08 aNotesPageSizeXY 8 314 // 16 aZoomRatio (OLE) 8 315 // 24 nNotesMasterPersist 4 316 // 28 nHandoutMasterPersist 4 317 // 32 n1stPageNumber 2 318 // 34 ePageFormat 2 319 // 36 bEmbeddedTrueType 1 320 // 37 bOmitTitlePlace 1 321 // 38 bRightToLeft 1 322 // 39 bShowComments 1 323 324 DffRecordHeader aHd; 325 sal_Int32 nSlideX,nSlideY, nNoticeX, nNoticeY, nDummy; 326 sal_uInt16 nSlidePageFormat; 327 sal_Int8 nEmbeddedTrueType, nTitlePlaceHoldersOmitted, nRightToLeft, nShowComments; 328 329 rIn >> aHd 330 >> nSlideX >> nSlideY 331 >> nNoticeX >> nNoticeY 332 >> nDummy >> nDummy // ZoomRation ueberspringen 333 >> rAtom.nNotesMasterPersist 334 >> rAtom.nHandoutMasterPersist 335 >> rAtom.n1stPageNumber 336 >> nSlidePageFormat 337 >> nEmbeddedTrueType 338 >> nTitlePlaceHoldersOmitted 339 >> nRightToLeft 340 >> nShowComments; 341 rAtom.aSlidesPageSize.Width() = nSlideX; 342 rAtom.aSlidesPageSize.Height() = nSlideY; 343 rAtom.aNotesPageSize.Width() = nNoticeX; 344 rAtom.aNotesPageSize.Height() = nNoticeY; 345 rAtom.eSlidesPageFormat = (PptPageFormat)nSlidePageFormat; 346 rAtom.bEmbeddedTrueType = nEmbeddedTrueType; 347 rAtom.bTitlePlaceholdersOmitted = nTitlePlaceHoldersOmitted; 348 rAtom.bRightToLeft = nRightToLeft; 349 rAtom.bShowComments = nShowComments; 350 aHd.SeekToEndOfRecord( rIn ); 351 return rIn; 352 } 353 354 //////////////////////////////////////////////////////////////////////////////////////////////////// 355 356 void PptSlideLayoutAtom::Clear() 357 { 358 eLayout = 0; 359 for ( sal_uInt16 i = 0; i < 8; i++ ) 360 { 361 aPlaceholderId[ i ] = 0; 362 aPlacementId[ i ] = 0; 363 } 364 } 365 366 SvStream& operator>>( SvStream& rIn, PptSlideLayoutAtom& rAtom ) 367 { 368 rIn >> rAtom.eLayout; 369 rIn.Read( rAtom.aPlaceholderId, 8 ); 370 return rIn; 371 } 372 373 //////////////////////////////////////////////////////////////////////////////////////////////////// 374 375 SvStream& operator>>( SvStream& rIn, PptSlideAtom& rAtom ) 376 { 377 DffRecordHeader aHd; 378 rIn >> aHd 379 >> rAtom.aLayout 380 >> rAtom.nMasterId 381 >> rAtom.nNotesId 382 >> rAtom.nFlags; 383 aHd.SeekToEndOfRecord( rIn ); 384 return rIn; 385 } 386 387 void PptSlideAtom::Clear() 388 { 389 nMasterId = nNotesId = 0; 390 nFlags = 0; 391 } 392 393 //////////////////////////////////////////////////////////////////////////////////////////////////// 394 395 SvStream& operator>>( SvStream& rIn, PptNotesAtom& rAtom ) 396 { 397 DffRecordHeader aHd; 398 rIn >> aHd 399 >> rAtom.nSlideId 400 >> rAtom.nFlags; 401 aHd.SeekToEndOfRecord( rIn ); 402 return rIn; 403 } 404 405 void PptNotesAtom::Clear() 406 { 407 nSlideId = 0; 408 nFlags = 0; 409 } 410 411 //////////////////////////////////////////////////////////////////////////////////////////////////// 412 413 void PptColorSchemeAtom::Clear() 414 { 415 memset(&aData[0], 0, 32); 416 } 417 418 Color PptColorSchemeAtom::GetColor( sal_uInt16 nNum ) const 419 { 420 Color aRetval; 421 if ( nNum < 8 ) 422 { 423 nNum <<= 2; 424 aRetval.SetRed( aData[ nNum++ ] ); 425 aRetval.SetGreen( aData[ nNum++ ] ); 426 aRetval.SetBlue( aData[ nNum++ ] ); 427 } 428 return aRetval; 429 } 430 431 SvStream& operator>>( SvStream& rIn, PptColorSchemeAtom& rAtom ) 432 { 433 DffRecordHeader aHd; 434 rIn >> aHd; 435 rIn.Read( rAtom.aData, 32 ); 436 aHd.SeekToEndOfRecord( rIn ); 437 return rIn; 438 } 439 440 //////////////////////////////////////////////////////////////////////////////////////////////////// 441 442 SvStream& operator>>( SvStream& rIn, PptFontEntityAtom& rAtom ) 443 { 444 DffRecordHeader aHd; 445 rIn >> aHd; 446 sal_Unicode nTemp, cData[ 32 ]; 447 rIn.Read( cData, 64 ); 448 449 sal_uInt8 lfCharset, lfPitchAndFamily; 450 451 rIn >> lfCharset 452 >> rAtom.lfClipPrecision 453 >> rAtom.lfQuality 454 >> lfPitchAndFamily; 455 456 switch( lfCharset ) 457 { 458 case SYMBOL_CHARSET : 459 rAtom.eCharSet = RTL_TEXTENCODING_SYMBOL; 460 break; 461 case ANSI_CHARSET : 462 rAtom.eCharSet = RTL_TEXTENCODING_MS_1252; 463 break; 464 465 // case DEFAULT_CHARSET : 466 // case SHIFTJIS_CHARSET : 467 // case HANGEUL_CHARSET : 468 // case CHINESEBIG5_CHARSET : 469 // case OEM_CHARSET : 470 default : 471 rAtom.eCharSet = gsl_getSystemTextEncoding(); 472 } 473 switch ( lfPitchAndFamily & 0xf0 ) 474 { 475 case FF_ROMAN: 476 rAtom.eFamily = FAMILY_ROMAN; 477 break; 478 479 case FF_SWISS: 480 rAtom.eFamily = FAMILY_SWISS; 481 break; 482 483 case FF_MODERN: 484 rAtom.eFamily = FAMILY_MODERN; 485 break; 486 487 case FF_SCRIPT: 488 rAtom.eFamily = FAMILY_SCRIPT; 489 break; 490 491 case FF_DECORATIVE: 492 rAtom.eFamily = FAMILY_DECORATIVE; 493 break; 494 495 default: 496 rAtom.eFamily = FAMILY_DONTKNOW; 497 break; 498 } 499 500 switch ( lfPitchAndFamily & 0x0f ) 501 { 502 case FIXED_PITCH: 503 rAtom.ePitch = PITCH_FIXED; 504 break; 505 506 case DEFAULT_PITCH: 507 case VARIABLE_PITCH: 508 default: 509 rAtom.ePitch = PITCH_VARIABLE; 510 break; 511 } 512 sal_uInt16 i; 513 for ( i = 0; i < 32; i++ ) 514 { 515 nTemp = cData[ i ]; 516 if ( !nTemp ) 517 break; 518 #ifdef OSL_BIGENDIAN 519 cData[ i ] = ( nTemp >> 8 ) | ( nTemp << 8 ); 520 #endif 521 } 522 rAtom.aName = String( cData, i ); 523 OutputDevice* pDev = (OutputDevice*)Application::GetDefaultDevice(); 524 rAtom.bAvailable = pDev->IsFontAvailable( rAtom.aName ); 525 aHd.SeekToEndOfRecord( rIn ); 526 return rIn; 527 } 528 529 SV_DECL_PTRARR_DEL( PptFontEntityAtomList, PptFontEntityAtom*, 16, 16 ) 530 SV_IMPL_PTRARR( PptFontEntityAtomList, PptFontEntityAtom* ); 531 532 class PptFontCollection: public PptFontEntityAtomList { 533 }; 534 535 //////////////////////////////////////////////////////////////////////////////////////////////////// 536 537 SvStream& operator>>( SvStream& rIn, PptUserEditAtom& rAtom ) 538 { 539 rIn >> rAtom.aHd 540 >> rAtom.nLastSlideID 541 >> rAtom.nVersion 542 >> rAtom.nOffsetLastEdit 543 >> rAtom.nOffsetPersistDirectory 544 >> rAtom.nDocumentRef 545 >> rAtom.nMaxPersistWritten 546 >> rAtom.eLastViewType; 547 rAtom.aHd.SeekToEndOfRecord(rIn); 548 return rIn; 549 } 550 551 //////////////////////////////////////////////////////////////////////////////////////////////////// 552 553 void PptOEPlaceholderAtom::Clear() 554 { 555 nPlacementId = 0; 556 nPlaceholderSize = nPlaceholderId = 0; 557 } 558 559 SvStream& operator>>( SvStream& rIn, PptOEPlaceholderAtom& rAtom ) 560 { 561 rIn >> rAtom.nPlacementId 562 >> rAtom.nPlaceholderId 563 >> rAtom.nPlaceholderSize; 564 return rIn; 565 } 566 567 //////////////////////////////////////////////////////////////////////////////////////////////////// 568 569 PptSlidePersistEntry::PptSlidePersistEntry() : 570 pStyleSheet ( NULL ), 571 pHeaderFooterEntry ( NULL ), 572 pSolverContainer ( NULL ), 573 nSlidePersistStartOffset( 0 ), 574 nSlidePersistEndOffset ( 0 ), 575 nBackgroundOffset ( 0 ), 576 nDrawingDgId ( 0xffffffff ), 577 pPresentationObjects ( NULL ), 578 pBObj ( NULL ), 579 bBObjIsTemporary ( sal_True ), 580 ePageKind ( PPT_MASTERPAGE ), 581 bNotesMaster ( sal_False ), 582 bHandoutMaster ( sal_False ), 583 bStarDrawFiller ( sal_False ) 584 { 585 HeaderFooterOfs[ 0 ] = HeaderFooterOfs[ 1 ] = HeaderFooterOfs[ 2 ] = HeaderFooterOfs[ 3 ] = 0; 586 } 587 588 589 PptSlidePersistEntry::~PptSlidePersistEntry() 590 { 591 delete pStyleSheet; 592 delete pHeaderFooterEntry; 593 delete pSolverContainer; 594 delete[] pPresentationObjects; 595 }; 596 597 //////////////////////////////////////////////////////////////////////////////////////////////////// 598 //////////////////////////////////////////////////////////////////////////////////////////////////// 599 //////////////////////////////////////////////////////////////////////////////////////////////////// 600 601 SdrEscherImport::SdrEscherImport( PowerPointImportParam& rParam, const String& rBaseURL ) : 602 SvxMSDffManager ( rParam.rDocStream, rBaseURL, rParam.pTracer ), 603 pFonts ( NULL ), 604 nStreamLen ( 0 ), 605 nTextStylesIndex ( 0xffff ), 606 eCharSetSystem ( gsl_getSystemTextEncoding() ), 607 bWingdingsChecked ( sal_False ), 608 bWingdingsAvailable ( sal_False ), 609 bMonotypeSortsChecked ( sal_False ), 610 bMonotypeSortsAvailable ( sal_False ), 611 bTimesNewRomanChecked ( sal_False ), 612 bTimesNewRomanAvailable ( sal_False ), 613 rImportParam ( rParam ) 614 { 615 } 616 617 SdrEscherImport::~SdrEscherImport() 618 { 619 void* pPtr; 620 for ( pPtr = aOleObjectList.First(); pPtr; pPtr = aOleObjectList.Next() ) 621 delete (PPTOleEntry*)pPtr; 622 delete pFonts; 623 } 624 625 const PptSlideLayoutAtom* SdrEscherImport::GetSlideLayoutAtom() const 626 { 627 return NULL; 628 } 629 630 sal_Bool SdrEscherImport::ReadString( String& rStr ) const 631 { 632 sal_Bool bRet = sal_False; 633 DffRecordHeader aStrHd; 634 rStCtrl >> aStrHd; 635 if (aStrHd.nRecType == PPT_PST_TextBytesAtom 636 || aStrHd.nRecType == PPT_PST_TextCharsAtom 637 || aStrHd.nRecType == PPT_PST_CString) 638 { 639 sal_Bool bUniCode = 640 (aStrHd.nRecType == PPT_PST_TextCharsAtom 641 || aStrHd.nRecType == PPT_PST_CString); 642 bRet=sal_True; 643 sal_uLong nBytes = aStrHd.nRecLen; 644 MSDFFReadZString( rStCtrl, rStr, nBytes, bUniCode ); 645 aStrHd.SeekToEndOfRecord( rStCtrl ); 646 } 647 else 648 aStrHd.SeekToBegOfRecord( rStCtrl ); 649 return bRet; 650 } 651 652 FASTBOOL SdrEscherImport::GetColorFromPalette(sal_uInt16 /*nNum*/, Color& /*rColor*/) const 653 { 654 return sal_False; 655 } 656 657 sal_Bool SdrEscherImport::SeekToShape( SvStream& /*rSt*/, void* /*pClientData*/, sal_uInt32 /*nId*/) const 658 { 659 return sal_False; 660 } 661 662 PptFontEntityAtom* SdrEscherImport::GetFontEnityAtom( sal_uInt32 nNum ) const 663 { 664 PptFontEntityAtom* pRetValue = NULL; 665 if ( pFonts && ( nNum < pFonts->Count() ) ) 666 pRetValue = (*pFonts)[ (sal_uInt16)nNum ]; 667 return pRetValue; 668 } 669 670 CharSet SdrEscherImport::GetCharSet( sal_uInt32 nNum ) const 671 { 672 CharSet eRetValue( eCharSetSystem ); 673 if ( pFonts && ( nNum < pFonts->Count() ) ) 674 eRetValue = (*pFonts)[ (sal_uInt16)nNum ]->eCharSet; 675 return eRetValue; 676 } 677 678 sal_Bool SdrEscherImport::IsFontAvailable( sal_uInt32 nNum ) const 679 { 680 sal_Bool bRetValue = sal_False; 681 if ( pFonts && ( nNum < pFonts->Count() ) ) 682 bRetValue = (*pFonts)[ (sal_uInt16)nNum ]->bAvailable; 683 return bRetValue; 684 } 685 686 SdrObject* SdrEscherImport::ReadObjText( PPTTextObj* /*pTextObj*/, SdrObject* pObj, SdPage* /*pPage*/) const 687 { 688 return pObj; 689 } 690 691 void SdrEscherImport::ProcessClientAnchor2( SvStream& rSt, DffRecordHeader& rHd, void* /*pData*/, DffObjData& rObj ) 692 { 693 sal_Int32 l, t, r, b; 694 if ( rHd.nRecLen == 16 ) 695 { 696 rSt >> l >> t >> r >> b; 697 } 698 else 699 { 700 sal_Int16 ls, ts, rs, bs; 701 rSt >> ts >> ls >> rs >> bs; // etwas seltsame Koordinatenreihenfolge ... 702 l = ls, t = ts, r = rs, b = bs; 703 } 704 Scale( l ); 705 Scale( t ); 706 Scale( r ); 707 Scale( b ); 708 rObj.aChildAnchor = Rectangle( l, t, r, b ); 709 rObj.bChildAnchor = sal_True; 710 return; 711 }; 712 713 void SdrEscherImport::RecolorGraphic( SvStream& rSt, sal_uInt32 nRecLen, Graphic& rGraphic ) 714 { 715 if ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE ) 716 { 717 sal_uInt16 nX, nGlobalColorsCount, nFillColorsCount; 718 719 rSt >> nX 720 >> nGlobalColorsCount 721 >> nFillColorsCount 722 >> nX 723 >> nX 724 >> nX; 725 726 if ( ( nGlobalColorsCount <= 64 ) && ( nFillColorsCount <= 64 ) ) 727 { 728 if ( (sal_uInt32)( ( nGlobalColorsCount + nFillColorsCount ) * 44 + 12 ) == nRecLen ) 729 { 730 sal_uInt32 OriginalGlobalColors[ 64 ]; 731 sal_uInt32 NewGlobalColors[ 64 ]; 732 sal_uInt32 OriginalFillColors[ 64 ]; 733 sal_uInt32 NewFillColors[ 64 ]; 734 735 sal_uInt32 i, j, nGlobalColorsChanged, nFillColorsChanged; 736 nGlobalColorsChanged = nFillColorsChanged = 0; 737 738 sal_uInt32* pCurrentOriginal = OriginalGlobalColors; 739 sal_uInt32* pCurrentNew = NewGlobalColors; 740 sal_uInt32* pCount = &nGlobalColorsChanged; 741 i = nGlobalColorsCount; 742 743 for ( j = 0; j < 2; j++ ) 744 { 745 for ( ; i > 0; i-- ) 746 { 747 sal_uInt32 nIndex, nPos = rSt.Tell(); 748 sal_uInt8 nDummy, nRed, nGreen, nBlue; 749 sal_uInt16 nChanged; 750 rSt >> nChanged; 751 if ( nChanged & 1 ) 752 { 753 sal_uInt32 nColor = 0; 754 rSt >> nDummy 755 >> nRed 756 >> nDummy 757 >> nGreen 758 >> nDummy 759 >> nBlue 760 >> nIndex; 761 762 if ( nIndex < 8 ) 763 { 764 Color aColor = MSO_CLR_ToColor( nIndex << 24 ); 765 nRed = aColor.GetRed(); 766 nGreen = aColor.GetGreen(); 767 nBlue = aColor.GetBlue(); 768 } 769 nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 ); 770 *pCurrentNew++ = nColor; 771 rSt >> nDummy 772 >> nRed 773 >> nDummy 774 >> nGreen 775 >> nDummy 776 >> nBlue; 777 nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 ); 778 *pCurrentOriginal++ = nColor; 779 (*pCount)++; 780 } 781 rSt.Seek( nPos + 44 ); 782 } 783 pCurrentOriginal = OriginalFillColors; 784 pCurrentNew = NewFillColors; 785 pCount = &nFillColorsChanged; 786 i = nFillColorsCount; 787 } 788 if ( nGlobalColorsChanged || nFillColorsChanged ) 789 { 790 Color* pSearchColors = new Color[ nGlobalColorsChanged ]; 791 Color* pReplaceColors = new Color[ nGlobalColorsChanged ]; 792 793 for ( j = 0; j < nGlobalColorsChanged; j++ ) 794 { 795 sal_uInt32 nSearch = OriginalGlobalColors[ j ]; 796 sal_uInt32 nReplace = NewGlobalColors[ j ]; 797 798 pSearchColors[ j ].SetRed( (sal_uInt8)nSearch ); 799 pSearchColors[ j ].SetGreen( (sal_uInt8)( nSearch >> 8 ) ); 800 pSearchColors[ j ].SetBlue( (sal_uInt8)( nSearch >> 16 ) ); 801 802 pReplaceColors[ j ].SetRed( (sal_uInt8)nReplace ); 803 pReplaceColors[ j ].SetGreen( (sal_uInt8)( nReplace >> 8 ) ); 804 pReplaceColors[ j ].SetBlue( (sal_uInt8)( nReplace >> 16 ) ); 805 } 806 GDIMetaFile aGdiMetaFile( rGraphic.GetGDIMetaFile() ); 807 aGdiMetaFile.ReplaceColors( pSearchColors, pReplaceColors, 808 nGlobalColorsChanged, NULL ); 809 rGraphic = aGdiMetaFile; 810 811 delete[] pSearchColors; 812 delete[] pReplaceColors; 813 } 814 } 815 } 816 } 817 } 818 819 /* ProcessObject is called from ImplSdPPTImport::ProcessObj to hanlde all application specific things, 820 such as the import of text, animation effects, header footer and placeholder. 821 822 The parameter pOriginalObj is the object as it was imported by our general escher import, it must either 823 be deleted or it can be returned to be inserted into the sdr page. 824 */ 825 SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, void* pData, Rectangle& rTextRect, SdrObject* pOriginalObj ) 826 { 827 if ( pOriginalObj && pOriginalObj->ISA( SdrObjCustomShape ) ) 828 pOriginalObj->SetMergedItem( SdrTextFixedCellHeightItem( sal_True ) ); 829 830 // we are initializing our return value with the object that was imported by our escher import 831 SdrObject* pRet = pOriginalObj; 832 833 ProcessData& rData = *((ProcessData*)pData); 834 PptSlidePersistEntry& rPersistEntry = rData.rPersistEntry; 835 836 if ( ! ( rObjData.nSpFlags & SP_FGROUP ) ) // sj: #114758# ... 837 { 838 PptOEPlaceholderAtom aPlaceholderAtom; 839 sal_Int16 nHeaderFooterInstance = -1; 840 841 if ( maShapeRecords.SeekToContent( rSt, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) ) 842 { 843 DffRecordHeader aClientDataHd; 844 while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < maShapeRecords.Current()->GetRecEndFilePos() ) ) 845 { 846 rSt >> aClientDataHd; 847 switch ( aClientDataHd.nRecType ) 848 { 849 // importing header/footer object from master page 850 case PPT_PST_OEPlaceholderAtom : 851 { 852 rSt >> aPlaceholderAtom; 853 if ( nHeaderFooterInstance == -1 ) 854 { 855 switch ( aPlaceholderAtom.nPlaceholderId ) 856 { 857 case PPT_PLACEHOLDER_MASTERSLIDENUMBER : nHeaderFooterInstance++; 858 case PPT_PLACEHOLDER_MASTERFOOTER : nHeaderFooterInstance++; 859 case PPT_PLACEHOLDER_MASTERHEADER : nHeaderFooterInstance++; 860 case PPT_PLACEHOLDER_MASTERDATE : nHeaderFooterInstance++; break; 861 } 862 if ( ! ( nHeaderFooterInstance & 0xfffc ) ) // is this a valid instance ( 0->3 ) 863 rPersistEntry.HeaderFooterOfs[ nHeaderFooterInstance ] = rObjData.rSpHd.GetRecBegFilePos(); 864 } 865 } 866 break; 867 868 case PPT_PST_RecolorInfoAtom : 869 { 870 if ( pRet && ( pRet->ISA( SdrGrafObj ) && ((SdrGrafObj*)pRet)->HasGDIMetaFile() ) ) 871 { 872 Graphic aGraphic( ((SdrGrafObj*)pRet)->GetGraphic() ); 873 RecolorGraphic( rSt, aClientDataHd.nRecLen, aGraphic ); 874 ((SdrGrafObj*)pRet)->SetGraphic( aGraphic ); 875 } 876 } 877 break; 878 } 879 aClientDataHd.SeekToEndOfRecord( rSt ); 880 } 881 } 882 if ( ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_NOTESSLIDEIMAGE ) && ( rPersistEntry.bNotesMaster == sal_False ) ) 883 { 884 sal_uInt16 nPageNum = pSdrModel->GetPageCount(); 885 if ( nPageNum > 0 ) 886 nPageNum--; 887 888 // replacing the object which we will return with a SdrPageObj 889 SdrObject::Free( pRet ); 890 pRet = new SdrPageObj( rObjData.aBoundRect, pSdrModel->GetPage( nPageNum - 1 ) ); 891 } 892 else 893 { 894 // try to load some ppt text 895 PPTTextObj aTextObj( rSt, (SdrPowerPointImport&)*this, rPersistEntry, &rObjData ); 896 if ( ( aTextObj.Count() || aTextObj.GetOEPlaceHolderAtom() ) ) 897 { 898 sal_Bool bVerticalText = sal_False; 899 // and if the text object is not empty, it must be applied to pRet, the object we 900 // initially got from our escher import 901 sal_Int32 nTextRotationAngle = 0; 902 if ( IsProperty( DFF_Prop_txflTextFlow ) ) 903 { 904 MSO_TextFlow eTextFlow = (MSO_TextFlow)( GetPropertyValue( DFF_Prop_txflTextFlow ) & 0xFFFF ); 905 switch( eTextFlow ) 906 { 907 case mso_txflBtoT : // Bottom to Top non-@, unten -> oben 908 nTextRotationAngle += 9000; 909 break; 910 case mso_txflTtoBA : /* #68110# */ // Top to Bottom @-font, oben -> unten 911 case mso_txflTtoBN : // Top to Bottom non-@, oben -> unten 912 case mso_txflVertN : // Vertical, non-@, oben -> unten 913 bVerticalText = !bVerticalText; // nTextRotationAngle += 27000; 914 break; 915 // case mso_txflHorzN : // Horizontal non-@, normal 916 // case mso_txflHorzA : // Horizontal @-font, normal 917 default: break; 918 } 919 } 920 sal_Int32 nFontDirection = GetPropertyValue( DFF_Prop_cdirFont, mso_cdir0 ); 921 nTextRotationAngle -= nFontDirection * 9000; 922 if ( ( nFontDirection == 1 ) || ( nFontDirection == 3 ) ) // #104546# 923 { 924 bVerticalText = !bVerticalText; 925 /* 926 sal_Int32 nHalfWidth = ( rTextRect.GetWidth() + 1 ) >> 1; 927 sal_Int32 nHalfHeight = ( rTextRect.GetHeight() + 1 ) >> 1; 928 Point aTopLeft( rTextRect.Left() + nHalfWidth - nHalfHeight, 929 rTextRect.Top() + nHalfHeight - nHalfWidth ); 930 Size aNewSize( rTextRect.GetHeight(), rTextRect.GetWidth() ); 931 Rectangle aNewRect( aTopLeft, aNewSize ); 932 rTextRect = aNewRect; 933 */ 934 } 935 aTextObj.SetVertical( bVerticalText ); 936 if ( pRet ) 937 { 938 sal_Bool bDeleteSource = aTextObj.GetOEPlaceHolderAtom() != 0; 939 if ( bDeleteSource && ( pRet->ISA( SdrGrafObj ) == sal_False ) // we are not allowed to get 940 && ( pRet->ISA( SdrObjGroup ) == sal_False ) // grouped placeholder objects 941 && ( pRet->ISA( SdrOle2Obj ) == sal_False ) ) 942 SdrObject::Free( pRet ); 943 } 944 sal_uInt32 nTextFlags = aTextObj.GetTextFlags(); 945 sal_Int32 nTextLeft = GetPropertyValue( DFF_Prop_dxTextLeft, 25 * 3600 ); // 0.25 cm (emu) 946 sal_Int32 nTextRight = GetPropertyValue( DFF_Prop_dxTextRight, 25 * 3600 ); // 0.25 cm (emu) 947 sal_Int32 nTextTop = GetPropertyValue( DFF_Prop_dyTextTop, 13 * 3600 ); // 0.13 cm (emu) 948 sal_Int32 nTextBottom = GetPropertyValue( DFF_Prop_dyTextBottom, 13 * 3600 ); 949 ScaleEmu( nTextLeft ); 950 ScaleEmu( nTextRight ); 951 ScaleEmu( nTextTop ); 952 ScaleEmu( nTextBottom ); 953 954 sal_Int32 nMinFrameWidth = 0; 955 sal_Int32 nMinFrameHeight = 0; 956 sal_Bool bAutoGrowWidth, bAutoGrowHeight; 957 958 SdrTextVertAdjust eTVA; 959 SdrTextHorzAdjust eTHA; 960 961 nTextFlags &= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT 962 | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK; 963 964 if ( bVerticalText ) 965 { 966 eTVA = SDRTEXTVERTADJUST_BLOCK; 967 eTHA = SDRTEXTHORZADJUST_CENTER; 968 969 // Textverankerung lesen 970 MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop ); 971 972 switch( eTextAnchor ) 973 { 974 case mso_anchorTop: 975 case mso_anchorTopCentered: 976 case mso_anchorTopBaseline: 977 case mso_anchorTopCenteredBaseline: 978 eTHA = SDRTEXTHORZADJUST_RIGHT; 979 break; 980 981 case mso_anchorMiddle : 982 case mso_anchorMiddleCentered: 983 eTHA = SDRTEXTHORZADJUST_CENTER; 984 break; 985 986 case mso_anchorBottom: 987 case mso_anchorBottomCentered: 988 case mso_anchorBottomBaseline: 989 case mso_anchorBottomCenteredBaseline: 990 eTHA = SDRTEXTHORZADJUST_LEFT; 991 break; 992 } 993 // if there is a 100% use of following attributes, the textbox can been aligned also in vertical direction 994 switch ( eTextAnchor ) 995 { 996 case mso_anchorTopCentered : 997 case mso_anchorMiddleCentered : 998 case mso_anchorBottomCentered : 999 case mso_anchorTopCenteredBaseline: 1000 case mso_anchorBottomCenteredBaseline: 1001 { 1002 // check if it is sensible to use the centered alignment 1003 sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; 1004 if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs 1005 eTVA = SDRTEXTVERTADJUST_CENTER; // the text has to be displayed using the full width; 1006 } 1007 break; 1008 1009 default : 1010 { 1011 if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT ) 1012 eTVA = SDRTEXTVERTADJUST_TOP; 1013 else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT ) 1014 eTVA = SDRTEXTVERTADJUST_BOTTOM; 1015 } 1016 break; 1017 } 1018 nMinFrameWidth = rTextRect.GetWidth() - ( nTextLeft + nTextRight ); 1019 } 1020 else 1021 { 1022 eTVA = SDRTEXTVERTADJUST_CENTER; 1023 eTHA = SDRTEXTHORZADJUST_BLOCK; 1024 1025 // Textverankerung lesen 1026 MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop ); 1027 1028 switch( eTextAnchor ) 1029 { 1030 case mso_anchorTop: 1031 case mso_anchorTopCentered: 1032 case mso_anchorTopBaseline: 1033 case mso_anchorTopCenteredBaseline: 1034 eTVA = SDRTEXTVERTADJUST_TOP; 1035 break; 1036 1037 case mso_anchorMiddle : 1038 case mso_anchorMiddleCentered: 1039 eTVA = SDRTEXTVERTADJUST_CENTER; 1040 break; 1041 1042 case mso_anchorBottom: 1043 case mso_anchorBottomCentered: 1044 case mso_anchorBottomBaseline: 1045 case mso_anchorBottomCenteredBaseline: 1046 eTVA = SDRTEXTVERTADJUST_BOTTOM; 1047 break; 1048 } 1049 // if there is a 100% usage of following attributes, the textbox can be aligned also in horizontal direction 1050 switch ( eTextAnchor ) 1051 { 1052 case mso_anchorTopCentered : 1053 case mso_anchorMiddleCentered : 1054 case mso_anchorBottomCentered : 1055 case mso_anchorTopCenteredBaseline: 1056 case mso_anchorBottomCenteredBaseline: 1057 { 1058 // check if it is sensible to use the centered alignment 1059 sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; 1060 if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs 1061 eTHA = SDRTEXTHORZADJUST_CENTER; // the text has to be displayed using the full width; 1062 } 1063 break; 1064 1065 default : 1066 { 1067 if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT ) 1068 eTHA = SDRTEXTHORZADJUST_LEFT; 1069 else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT ) 1070 eTHA = SDRTEXTHORZADJUST_RIGHT; 1071 } 1072 break; 1073 } 1074 nMinFrameHeight = rTextRect.GetHeight() - ( nTextTop + nTextBottom ); 1075 } 1076 1077 SdrObjKind eTextKind = OBJ_RECT; 1078 if ( ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_NOTESSLIDEIMAGE ) 1079 || ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_MASTERNOTESSLIDEIMAGE ) ) 1080 { 1081 aTextObj.SetInstance( 2 ); 1082 eTextKind = OBJ_TITLETEXT; 1083 } 1084 else if ( ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_MASTERNOTESBODYIMAGE ) 1085 || ( aPlaceholderAtom.nPlaceholderId == PPT_PLACEHOLDER_NOTESBODY ) ) 1086 { 1087 aTextObj.SetInstance( 2 ); 1088 eTextKind = OBJ_TEXT; 1089 } 1090 1091 sal_uInt32 nDestinationInstance = aTextObj.GetInstance(); 1092 if ( rPersistEntry.ePageKind == PPT_MASTERPAGE ) 1093 { 1094 if ( !rPersistEntry.pPresentationObjects ) 1095 { 1096 rPersistEntry.pPresentationObjects = new sal_uInt32[ PPT_STYLESHEETENTRYS ]; 1097 memset( rPersistEntry.pPresentationObjects, 0, PPT_STYLESHEETENTRYS * 4 ); 1098 } 1099 if ( !rPersistEntry.pPresentationObjects[ nDestinationInstance ] ) 1100 rPersistEntry.pPresentationObjects[ nDestinationInstance ] = rObjData.rSpHd.GetRecBegFilePos(); 1101 } 1102 switch ( nDestinationInstance ) 1103 { 1104 case TSS_TYPE_PAGETITLE : 1105 case TSS_TYPE_TITLE : 1106 { 1107 if ( GetSlideLayoutAtom()->eLayout == PPT_LAYOUT_TITLEMASTERSLIDE ) 1108 nDestinationInstance = TSS_TYPE_TITLE; 1109 else 1110 nDestinationInstance = TSS_TYPE_PAGETITLE; 1111 } 1112 break; 1113 case TSS_TYPE_BODY : 1114 // case TSS_TYPE_SUBTITLE : 1115 case TSS_TYPE_HALFBODY : 1116 case TSS_TYPE_QUARTERBODY : 1117 nDestinationInstance = TSS_TYPE_BODY; 1118 break; 1119 } 1120 aTextObj.SetDestinationInstance( (sal_uInt16)nDestinationInstance ); 1121 1122 switch ( aTextObj.GetInstance() ) 1123 { 1124 case TSS_TYPE_PAGETITLE : 1125 case TSS_TYPE_TITLE : eTextKind = OBJ_TITLETEXT; break; 1126 case TSS_TYPE_SUBTITLE : eTextKind = OBJ_TEXT; break; 1127 case TSS_TYPE_BODY : 1128 case TSS_TYPE_HALFBODY : 1129 case TSS_TYPE_QUARTERBODY : eTextKind = OBJ_OUTLINETEXT; break; 1130 } 1131 if ( aTextObj.GetDestinationInstance() != TSS_TYPE_TEXT_IN_SHAPE ) 1132 { 1133 if ( !aTextObj.GetOEPlaceHolderAtom() || !aTextObj.GetOEPlaceHolderAtom()->nPlaceholderId ) 1134 { 1135 aTextObj.SetDestinationInstance( TSS_TYPE_TEXT_IN_SHAPE ); 1136 eTextKind = OBJ_RECT; 1137 } 1138 } 1139 SdrObject* pTObj = NULL; 1140 sal_Bool bWordWrap = (MSO_WrapMode)GetPropertyValue( DFF_Prop_WrapText, mso_wrapSquare ) != mso_wrapNone; 1141 sal_Bool bFitShapeToText = ( GetPropertyValue( DFF_Prop_FitTextToShape ) & 2 ) != 0; 1142 1143 if ( pRet && pRet->ISA( SdrObjCustomShape ) && ( eTextKind == OBJ_RECT ) ) 1144 { 1145 bAutoGrowHeight = bFitShapeToText; 1146 if ( bWordWrap ) 1147 bAutoGrowWidth = sal_False; 1148 else 1149 bAutoGrowWidth = sal_True; 1150 pTObj = pRet; 1151 pRet = NULL; 1152 } 1153 else 1154 { 1155 if ( pRet && pRet->ISA( SdrObjCustomShape ) ) 1156 { 1157 SdrObject::Free( pRet ); 1158 pRet = NULL; 1159 } 1160 pTObj = new SdrRectObj( eTextKind != OBJ_RECT ? eTextKind : OBJ_TEXT ); 1161 pTObj->SetModel( pSdrModel ); 1162 SfxItemSet aSet( pSdrModel->GetItemPool() ); 1163 if ( !pRet ) 1164 ((SdrEscherImport*)this)->ApplyAttributes( rSt, aSet, rObjData ); 1165 pTObj->SetMergedItemSet( aSet ); 1166 if ( pRet ) 1167 { 1168 pTObj->SetMergedItem( XLineStyleItem( XLINE_NONE ) ); 1169 pTObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) ); 1170 } 1171 if ( bVerticalText ) 1172 { 1173 bAutoGrowWidth = bFitShapeToText; 1174 bAutoGrowHeight = sal_False; 1175 } 1176 else 1177 { 1178 bAutoGrowWidth = sal_False; 1179 1180 // #119885# re-activationg bFitShapeToText here, could not find deeper explanations 1181 // for it (it was from 2005). Keeping the old commeht here for reference 1182 // old comment: // bFitShapeToText; can't be used, because we cut the text if it is too height, 1183 bAutoGrowHeight = bFitShapeToText; 1184 } 1185 } 1186 pTObj->SetMergedItem( SvxFrameDirectionItem( bVerticalText ? FRMDIR_VERT_TOP_RIGHT : FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) ); 1187 1188 if ( !pTObj->ISA( SdrObjCustomShape ) ) 1189 { 1190 pTObj->SetMergedItem( SdrTextAutoGrowWidthItem( bAutoGrowWidth ) ); 1191 pTObj->SetMergedItem( SdrTextAutoGrowHeightItem( bAutoGrowHeight ) ); 1192 } 1193 else 1194 { 1195 pTObj->SetMergedItem( SdrTextWordWrapItem( bWordWrap ) ); 1196 pTObj->SetMergedItem( SdrTextAutoGrowHeightItem( bFitShapeToText ) ); 1197 } 1198 1199 pTObj->SetMergedItem( SdrTextVertAdjustItem( eTVA ) ); 1200 pTObj->SetMergedItem( SdrTextHorzAdjustItem( eTHA ) ); 1201 1202 if ( nMinFrameHeight < 0 ) 1203 nMinFrameHeight = 0; 1204 if ( !pTObj->ISA( SdrObjCustomShape ) ) 1205 pTObj->SetMergedItem( SdrTextMinFrameHeightItem( nMinFrameHeight ) ); 1206 1207 if ( nMinFrameWidth < 0 ) 1208 nMinFrameWidth = 0; 1209 if ( !pTObj->ISA( SdrObjCustomShape ) ) 1210 pTObj->SetMergedItem( SdrTextMinFrameWidthItem( nMinFrameWidth ) ); 1211 1212 // Abstaende an den Raendern der Textbox setzen 1213 pTObj->SetMergedItem( SdrTextLeftDistItem( nTextLeft ) ); 1214 pTObj->SetMergedItem( SdrTextRightDistItem( nTextRight ) ); 1215 pTObj->SetMergedItem( SdrTextUpperDistItem( nTextTop ) ); 1216 pTObj->SetMergedItem( SdrTextLowerDistItem( nTextBottom ) ); 1217 pTObj->SetMergedItem( SdrTextFixedCellHeightItem( sal_True ) ); 1218 1219 if ( !pTObj->ISA( SdrObjCustomShape ) ) 1220 pTObj->SetSnapRect( rTextRect ); 1221 pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage ); 1222 if ( pTObj ) 1223 { 1224 /* check if our new snaprect makes trouble, 1225 because we do not display the ADJUST_BLOCK 1226 properly if the textsize is bigger than the 1227 snaprect of the object. Then we will use 1228 ADJUST_CENTER instead of ADJUST_BLOCK. 1229 */ 1230 if ( !pTObj->ISA( SdrObjCustomShape ) && !bFitShapeToText && !bWordWrap ) 1231 { 1232 SdrTextObj* pText = PTR_CAST( SdrTextObj, pTObj ); 1233 if ( pText ) 1234 { 1235 if ( bVerticalText ) 1236 { 1237 if ( eTVA == SDRTEXTVERTADJUST_BLOCK ) 1238 { 1239 Size aTextSize( pText->GetTextSize() ); 1240 aTextSize.Width() += nTextLeft + nTextRight; 1241 aTextSize.Height() += nTextTop + nTextBottom; 1242 if ( rTextRect.GetHeight() < aTextSize.Height() ) 1243 pTObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) ); 1244 } 1245 } 1246 else 1247 { 1248 if ( eTHA == SDRTEXTHORZADJUST_BLOCK ) 1249 { 1250 Size aTextSize( pText->GetTextSize() ); 1251 aTextSize.Width() += nTextLeft + nTextRight; 1252 aTextSize.Height() += nTextTop + nTextBottom; 1253 if ( rTextRect.GetWidth() < aTextSize.Width() ) 1254 pTObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_CENTER ) ); 1255 } 1256 } 1257 } 1258 } 1259 // rotate text with shape ? 1260 sal_Int32 nAngle = ( rObjData.nSpFlags & SP_FFLIPV ) ? -mnFix16Angle : mnFix16Angle; // #72116# vertical flip -> rotate by using the other way 1261 nAngle += nTextRotationAngle; 1262 1263 if ( pTObj->ISA( SdrObjCustomShape ) ) 1264 { 1265 /* 1266 if ( nTextRotationAngle ) 1267 { 1268 double fTextRotateAngle = (double)nTextRotationAngle / 100.0; 1269 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)((SdrObjCustomShape*)pTObj)->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); 1270 const rtl::OUString sTextRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "TextRotateAngle" ) ); 1271 PropertyValue aPropValue; 1272 aPropValue.Name = sTextRotateAngle; 1273 aPropValue.Value <<= fTextRotateAngle; 1274 aGeometryItem.SetPropertyValue( aPropValue ); 1275 ((SdrObjCustomShape*)pTObj)->SetMergedItem( aGeometryItem ); 1276 } 1277 */ 1278 } 1279 else 1280 { 1281 if ( rObjData.nSpFlags & SP_FFLIPV ) 1282 { 1283 double a = 18000 * nPi180; 1284 pTObj->Rotate( rTextRect.Center(), 18000, sin( a ), cos( a ) ); 1285 } 1286 if ( rObjData.nSpFlags & SP_FFLIPH ) 1287 nAngle = 36000 - nAngle; 1288 if ( nAngle ) 1289 { 1290 double a = nAngle * nPi180; 1291 pTObj->NbcRotate( rObjData.aBoundRect.Center(), nAngle, sin( a ), cos( a ) ); 1292 } 1293 } 1294 if ( pRet ) 1295 { 1296 SdrObject* pGroup = new SdrObjGroup; 1297 pGroup->GetSubList()->NbcInsertObject( pRet ); 1298 pGroup->GetSubList()->NbcInsertObject( pTObj ); 1299 pRet = pGroup; 1300 } 1301 else 1302 pRet = pTObj; 1303 } 1304 } 1305 } 1306 } 1307 else 1308 { 1309 if ( maShapeRecords.SeekToContent( rSt, DFF_msofbtUDefProp, SEEK_FROM_CURRENT_AND_RESTART ) ) 1310 { 1311 maShapeRecords.Current()->SeekToBegOfRecord( rSt ); 1312 DffPropertyReader aSecPropSet( *this ); 1313 aSecPropSet.ReadPropSet( rSt, (ProcessData*)pData ); 1314 sal_Int32 nTableProperties = aSecPropSet.GetPropertyValue( DFF_Prop_tableProperties, 0 ); 1315 if ( nTableProperties & 3 ) 1316 { 1317 if ( aSecPropSet.SeekToContent( DFF_Prop_tableRowProperties, rSt ) ) 1318 { 1319 sal_Int16 i, nRowCount = 0; 1320 rSt >> nRowCount >> i >> i; 1321 if ( nRowCount ) 1322 { 1323 sal_uInt32* pTableArry = new sal_uInt32[ nRowCount + 2 ]; 1324 pTableArry[ 0 ] = nTableProperties; 1325 pTableArry[ 1 ] = nRowCount; 1326 for ( i = 0; i < nRowCount; i++ ) 1327 rSt >> pTableArry[ i + 2 ]; 1328 rData.pTableRowProperties = pTableArry; 1329 } 1330 } 1331 } 1332 } 1333 } 1334 if ( pRet ) // sj: #i38501#, and and taking care of connections to group objects 1335 { 1336 if ( rObjData.nSpFlags & SP_FBACKGROUND ) 1337 { 1338 pRet->NbcSetSnapRect( Rectangle( Point(), ((SdrPage*)rData.pPage)->GetSize() ) ); // Groesse setzen 1339 } 1340 if ( rPersistEntry.pSolverContainer ) 1341 { 1342 for ( SvxMSDffConnectorRule* pPtr = (SvxMSDffConnectorRule*)rPersistEntry.pSolverContainer->aCList.First(); 1343 pPtr; pPtr = (SvxMSDffConnectorRule*)rPersistEntry.pSolverContainer->aCList.Next() ) 1344 { 1345 if ( rObjData.nShapeId == pPtr->nShapeC ) 1346 pPtr->pCObj = pRet; 1347 else 1348 { 1349 SdrObject* pConnectObj = pRet; 1350 if ( pOriginalObj && pRet->ISA( SdrObjGroup ) ) 1351 { /* check if the original object from the escherimport is part of the group object, 1352 if this is the case, we will use the original object to connect to */ 1353 SdrObjListIter aIter( *pRet, IM_DEEPWITHGROUPS ); 1354 while( aIter.IsMore() ) 1355 { 1356 SdrObject* pPartObj = aIter.Next(); 1357 if ( pPartObj == pOriginalObj ) 1358 { 1359 pConnectObj = pPartObj; 1360 break; 1361 } 1362 } 1363 } 1364 if ( rObjData.nShapeId == pPtr->nShapeA ) 1365 { 1366 pPtr->pAObj = pConnectObj; 1367 pPtr->nSpFlagsA = rObjData.nSpFlags; 1368 } 1369 if ( rObjData.nShapeId == pPtr->nShapeB ) 1370 { 1371 pPtr->pBObj = pConnectObj; 1372 pPtr->nSpFlagsB = rObjData.nSpFlags; 1373 } 1374 } 1375 } 1376 } 1377 if ( rPersistEntry.ePageKind == PPT_MASTERPAGE ) 1378 { // maybe the escher clusterlist is not correct, but we have to got the right page by using the 1379 // spMaster property, so we are patching the table 1380 if ( rPersistEntry.nDrawingDgId != 0xffffffff ) 1381 { 1382 sal_uInt32 nSec = ( rObjData.nShapeId >> 10 ) - 1; 1383 if ( mpFidcls && ( nSec < mnIdClusters ) ) 1384 mpFidcls[ nSec ].dgid = rPersistEntry.nDrawingDgId; // insert the correct drawing id; 1385 } 1386 } 1387 if ( GetPropertyValue( DFF_Prop_fNoFillHitTest ) & 0x10 ) 1388 { 1389 if ( (MSO_FillType)GetPropertyValue( DFF_Prop_fillType, mso_fillSolid ) == mso_fillBackground ) 1390 { 1391 if ( !rData.pBackgroundColoredObjects ) 1392 rData.pBackgroundColoredObjects = new List; 1393 rData.pBackgroundColoredObjects->Insert( pRet, LIST_APPEND ); 1394 } 1395 } 1396 } 1397 return pRet; 1398 } 1399 1400 //////////////////////////////////////////////////////////////////////////////////////////////////// 1401 1402 void SdrEscherImport::CheckWingdings() const 1403 { 1404 OutputDevice* pDev = (OutputDevice*)Application::GetDefaultDevice(); 1405 ((SdrEscherImport*)this)->bWingdingsAvailable = pDev->IsFontAvailable( String( RTL_CONSTASCII_USTRINGPARAM( "WINGDINGS" ) ) ); 1406 ((SdrEscherImport*)this)->bWingdingsChecked = sal_True; 1407 } 1408 1409 void SdrEscherImport::CheckMonotypeSorts() const 1410 { 1411 OutputDevice* pDev = (OutputDevice*)Application::GetDefaultDevice(); 1412 ((SdrEscherImport*)this)->bMonotypeSortsAvailable = pDev->IsFontAvailable( String( RTL_CONSTASCII_USTRINGPARAM( "MONOTYPE SORTS" ) ) ); 1413 ((SdrEscherImport*)this)->bMonotypeSortsChecked = sal_True; 1414 } 1415 1416 void SdrEscherImport::CheckTimesNewRoman() const 1417 { 1418 OutputDevice* pDev = (OutputDevice*)Application::GetDefaultDevice(); 1419 ((SdrEscherImport*)this)->bTimesNewRomanAvailable = pDev->IsFontAvailable( String( RTL_CONSTASCII_USTRINGPARAM( "TIMES NEW ROMAN" ) ) ); 1420 ((SdrEscherImport*)this)->bTimesNewRomanChecked = sal_True; 1421 } 1422 1423 //////////////////////////////////////////////////////////////////////////////////////////////////// 1424 //////////////////////////////////////////////////////////////////////////////////////////////////// 1425 //////////////////////////////////////////////////////////////////////////////////////////////////// 1426 1427 SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const String& rBaseURL ) : 1428 SdrEscherImport ( rParam, rBaseURL ), 1429 bOk ( rStCtrl.GetErrorCode() == SVSTREAM_OK ), 1430 pPersistPtr ( NULL ), 1431 nPersistPtrAnz ( 0 ), 1432 pDefaultSheet ( NULL ), 1433 pMasterPages ( NULL ), 1434 pSlidePages ( NULL ), 1435 pNotePages ( NULL ), 1436 nAktPageNum ( 0 ), 1437 nDocStreamPos ( 0 ), 1438 nPageColorsNum ( 0xFFFF ), 1439 ePageColorsKind ( PPT_MASTERPAGE ), 1440 eAktPageKind ( PPT_MASTERPAGE ) 1441 { 1442 DffRecordHeader* pHd; 1443 if ( bOk ) 1444 { 1445 rStCtrl.Seek( STREAM_SEEK_TO_END ); 1446 nStreamLen = rStCtrl.Tell(); 1447 1448 // try to allocate the UserEditAtom via CurrentUserAtom 1449 sal_uInt32 nCurrentUserEdit = rParam.aCurrentUserAtom.nCurrentUserEdit; 1450 if ( nCurrentUserEdit ) 1451 { 1452 rStCtrl.Seek( nCurrentUserEdit ); 1453 rStCtrl >> aUserEditAtom; 1454 } 1455 if ( !aUserEditAtom.nOffsetPersistDirectory ) 1456 { // if there is no UserEditAtom try to search the last one 1457 1458 rStCtrl.Seek( 0 ); 1459 DffRecordManager aPptRecManager; // contains all first level container and atoms 1460 aPptRecManager.Consume( rStCtrl, sal_False, nStreamLen ); 1461 for ( pHd = aPptRecManager.Last(); pHd; pHd = aPptRecManager.Prev() ) 1462 { 1463 if ( pHd->nRecType == PPT_PST_UserEditAtom ) 1464 { 1465 pHd->SeekToBegOfRecord( rStCtrl ); 1466 rStCtrl >> aUserEditAtom; 1467 break; 1468 } 1469 } 1470 if ( !pHd ) 1471 bOk = sal_False; 1472 } 1473 } 1474 if ( rStCtrl.GetError() != 0 ) 1475 bOk = sal_False; 1476 1477 if ( bOk ) 1478 { 1479 nPersistPtrAnz = aUserEditAtom.nMaxPersistWritten + 1; 1480 if ( ( nPersistPtrAnz >> 2 ) > nStreamLen ) // sj: at least nPersistPtrAnz is not allowed to be greater than filesize 1481 bOk = sal_False; // (it should not be greater than the PPT_PST_PersistPtrIncrementalBlock, but 1482 // we are reading this block later, so we do not have access yet) 1483 1484 if ( bOk && ( nPersistPtrAnz < ( SAL_MAX_UINT32 / sizeof( sal_uInt32 ) ) ) ) 1485 pPersistPtr = new (std::nothrow) sal_uInt32[ nPersistPtrAnz ]; 1486 if ( !pPersistPtr ) 1487 bOk = sal_False; 1488 if ( bOk ) 1489 { 1490 memset( pPersistPtr, 0x00, nPersistPtrAnz * 4 ); 1491 1492 // SJ: new search mechanism from bottom to top (Issue 21122) 1493 PptUserEditAtom aCurrentEditAtom( aUserEditAtom ); 1494 sal_uInt32 nCurrentEditAtomStrmPos = aCurrentEditAtom.aHd.GetRecEndFilePos(); 1495 while( nCurrentEditAtomStrmPos ) 1496 { 1497 sal_uInt32 nPersistIncPos = aCurrentEditAtom.nOffsetPersistDirectory; 1498 if ( nPersistIncPos ) 1499 { 1500 rStCtrl.Seek( nPersistIncPos ); 1501 DffRecordHeader aPersistHd; 1502 rStCtrl >> aPersistHd; 1503 if ( aPersistHd.nRecType == PPT_PST_PersistPtrIncrementalBlock ) 1504 { 1505 sal_uLong nPibLen = aPersistHd.GetRecEndFilePos(); 1506 while ( bOk && ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nPibLen ) ) 1507 { 1508 sal_uInt32 nOfs, nAnz; 1509 rStCtrl >> nOfs; 1510 nAnz = nOfs; 1511 nOfs &= 0x000FFFFF; 1512 nAnz >>= 20; 1513 while ( bOk && ( rStCtrl.GetError() == 0 ) && ( nAnz > 0 ) && ( nOfs <= nPersistPtrAnz ) ) 1514 { 1515 sal_uInt32 nPt; 1516 rStCtrl >> nPt; 1517 if ( !pPersistPtr[ nOfs ] ) 1518 { 1519 pPersistPtr[ nOfs ] = nPt; 1520 if ( pPersistPtr[ nOfs ] > nStreamLen ) 1521 { 1522 bOk = sal_False; 1523 DBG_ERROR("SdrPowerPointImport::Ctor(): Ungueltiger Eintrag im Persist-Directory!"); 1524 } 1525 } 1526 nAnz--; 1527 nOfs++; 1528 } 1529 if ( bOk && nAnz > 0 ) 1530 { 1531 DBG_ERROR("SdrPowerPointImport::Ctor(): Nicht alle Persist-Directory Entraege gelesen!"); 1532 bOk = sal_False; 1533 } 1534 } 1535 } 1536 } 1537 nCurrentEditAtomStrmPos = aCurrentEditAtom.nOffsetLastEdit < nCurrentEditAtomStrmPos ? aCurrentEditAtom.nOffsetLastEdit : 0; 1538 if ( nCurrentEditAtomStrmPos ) 1539 { 1540 rStCtrl.Seek( nCurrentEditAtomStrmPos ); 1541 rStCtrl >> aCurrentEditAtom; 1542 } 1543 } 1544 } 1545 } 1546 if ( rStCtrl.GetError() != 0 ) 1547 bOk = sal_False; 1548 if ( bOk ) 1549 { // Document PersistEntry checken 1550 nDocStreamPos = aUserEditAtom.nDocumentRef; 1551 if ( nDocStreamPos > nPersistPtrAnz ) 1552 { 1553 DBG_ERROR("SdrPowerPointImport::Ctor(): aUserEditAtom.nDocumentRef ungueltig!"); 1554 bOk = sal_False; 1555 } 1556 } 1557 if ( bOk ) 1558 { // Document FilePos checken 1559 nDocStreamPos = pPersistPtr[ nDocStreamPos ]; 1560 if ( nDocStreamPos >= nStreamLen ) 1561 { 1562 DBG_ERROR("SdrPowerPointImport::Ctor(): nDocStreamPos >= nStreamLen!"); 1563 bOk = sal_False; 1564 } 1565 } 1566 if ( bOk ) 1567 { 1568 rStCtrl.Seek( nDocStreamPos ); 1569 aDocRecManager.Consume( rStCtrl ); 1570 1571 DffRecordHeader aDocHd; 1572 rStCtrl >> aDocHd; 1573 // DocumentAtom lesen 1574 DffRecordHeader aDocAtomHd; 1575 rStCtrl >> aDocAtomHd; 1576 if ( aDocHd.nRecType == PPT_PST_Document && aDocAtomHd.nRecType == PPT_PST_DocumentAtom ) 1577 { 1578 aDocAtomHd.SeekToBegOfRecord( rStCtrl ); 1579 rStCtrl >> aDocAtom; 1580 } 1581 else 1582 bOk = sal_False; 1583 1584 if ( bOk ) 1585 { 1586 if ( !pFonts ) 1587 ReadFontCollection(); 1588 1589 // reading TxPF, TxSI 1590 PPTTextCharacterStyleAtomInterpreter aTxCFStyle; // SJ: ToDo, this atom needs to be interpreted, it contains character default styles for standard objects (instance4) 1591 PPTTextParagraphStyleAtomInterpreter aTxPFStyle; 1592 PPTTextSpecInfoAtomInterpreter aTxSIStyle; // styles (default language setting ... ) 1593 1594 DffRecordHeader* pEnvHd = aDocRecManager.GetRecordHeader( PPT_PST_Environment ); 1595 if ( pEnvHd ) 1596 { 1597 pEnvHd->SeekToContent( rStCtrl ); 1598 DffRecordHeader aTxPFStyleRecHd; 1599 if ( SeekToRec( rStCtrl, PPT_PST_TxPFStyleAtom, pEnvHd->GetRecEndFilePos(), &aTxPFStyleRecHd ) ) 1600 aTxPFStyle.Read( rStCtrl, aTxPFStyleRecHd ); 1601 1602 pEnvHd->SeekToContent( rStCtrl ); 1603 DffRecordHeader aTxSIStyleRecHd; 1604 if ( SeekToRec( rStCtrl, PPT_PST_TxSIStyleAtom, pEnvHd->GetRecEndFilePos(), &aTxSIStyleRecHd ) ) 1605 { 1606 aTxSIStyle.Read( rStCtrl, aTxSIStyleRecHd, PPT_PST_TxSIStyleAtom ); 1607 #ifdef DBG_UTIL 1608 if ( !aTxSIStyle.bValid ) 1609 { 1610 if (!(rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT )) 1611 { 1612 DBG_ERROR( "SdrTextSpecInfoAtomInterpreter::Ctor(): parsing error, this document needs to be analysed (SJ)" ); 1613 } 1614 } 1615 #endif 1616 } 1617 } 1618 1619 // todo:: PPT_PST_TxPFStyleAtom 1620 1621 // SlidePersists Lesen 1622 pMasterPages=new PptSlidePersistList; 1623 pSlidePages =new PptSlidePersistList; 1624 pNotePages =new PptSlidePersistList; 1625 1626 // now always creating the handout page, it will be the first in our masterpage list 1627 PptSlidePersistEntry* pE = new PptSlidePersistEntry; 1628 pE->aPersistAtom.nPsrReference = aDocAtom.nHandoutMasterPersist; 1629 pE->bHandoutMaster = sal_True; 1630 if ( !aDocAtom.nHandoutMasterPersist ) 1631 pE->bStarDrawFiller = sal_True; // this is a dummy master page 1632 pMasterPages->C40_INSERT( PptSlidePersistEntry, pE, 0 ); 1633 1634 sal_uInt16 nPageListNum = 0; 1635 DffRecordHeader* pSlideListWithTextHd = aDocRecManager.GetRecordHeader( PPT_PST_SlideListWithText ); 1636 PptSlidePersistEntry* pPreviousPersist = NULL; 1637 while ( pSlideListWithTextHd && ( nPageListNum < 3 ) ) 1638 { 1639 pSlideListWithTextHd->SeekToContent( rStCtrl ); 1640 PptSlidePersistList* pPageList = GetPageList( PptPageKind( nPageListNum ) ); 1641 sal_uInt32 nSlideListWithTextHdEndOffset = pSlideListWithTextHd->GetRecEndFilePos(); 1642 while ( SeekToRec( rStCtrl, PPT_PST_SlidePersistAtom, nSlideListWithTextHdEndOffset ) ) 1643 { 1644 if ( pPreviousPersist ) 1645 pPreviousPersist->nSlidePersistEndOffset = rStCtrl.Tell(); 1646 PptSlidePersistEntry* pE2 = new PptSlidePersistEntry; 1647 rStCtrl >> pE2->aPersistAtom; 1648 pE2->nSlidePersistStartOffset = rStCtrl.Tell(); 1649 pE2->ePageKind = PptPageKind( nPageListNum ); 1650 pPageList->C40_INSERT( PptSlidePersistEntry, pE2, pPageList->Count() ); 1651 pPreviousPersist = pE2; 1652 } 1653 if ( pPreviousPersist ) 1654 pPreviousPersist->nSlidePersistEndOffset = nSlideListWithTextHdEndOffset; 1655 pSlideListWithTextHd = aDocRecManager.GetRecordHeader( PPT_PST_SlideListWithText, SEEK_FROM_CURRENT ); 1656 nPageListNum++; 1657 } 1658 1659 // we will ensure that there is at least one master page 1660 if ( pMasterPages->Count() == 1 ) // -> there is only a handout page available 1661 { 1662 PptSlidePersistEntry* pE2 = new PptSlidePersistEntry; 1663 pE2->bStarDrawFiller = sal_True; // this is a dummy master page 1664 pMasterPages->C40_INSERT( PptSlidePersistEntry, pE2, 1 ); 1665 } 1666 1667 // now we will insert at least one notes master for each master page 1668 sal_uInt16 nMasterPage; 1669 sal_uInt16 nMasterPages = pMasterPages->Count() - 1; 1670 for ( nMasterPage = 0; nMasterPage < nMasterPages; nMasterPage++ ) 1671 { 1672 PptSlidePersistEntry* pE2 = new PptSlidePersistEntry; 1673 pE2->bNotesMaster = sal_True; 1674 pE2->bStarDrawFiller = sal_True; // this is a dummy master page 1675 if ( !nMasterPage && aDocAtom.nNotesMasterPersist ) 1676 { // special treatment for the first notes master 1677 pE2->aPersistAtom.nPsrReference = aDocAtom.nNotesMasterPersist; 1678 pE2->bStarDrawFiller = sal_False; // this is a dummy master page 1679 } 1680 pMasterPages->C40_INSERT( PptSlidePersistEntry, pE2, ( nMasterPage + 1 ) << 1 ); 1681 } 1682 1683 // Zu jeder Page noch das SlideAtom bzw. NotesAtom lesen, soweit vorhanden 1684 nPageListNum = 0; 1685 for ( nPageListNum = 0; nPageListNum < 3; nPageListNum++ ) 1686 { 1687 PptSlidePersistList* pPageList = GetPageList( PptPageKind( nPageListNum ) ); 1688 for ( sal_uInt16 nPageNum = 0; nPageNum < pPageList->Count(); nPageNum++ ) 1689 { 1690 PptSlidePersistEntry* pE2 = (*pPageList)[ nPageNum ]; 1691 sal_uLong nPersist = pE2->aPersistAtom.nPsrReference; 1692 if ( ( nPersist > 0 ) && ( nPersist < nPersistPtrAnz ) ) 1693 { 1694 sal_uLong nFPos = pPersistPtr[ nPersist ]; 1695 if ( nFPos < nStreamLen ) 1696 { 1697 rStCtrl.Seek( nFPos ); 1698 DffRecordHeader aSlideHd; 1699 rStCtrl >> aSlideHd; 1700 if ( SeekToRec( rStCtrl, PPT_PST_SlideAtom, aSlideHd.GetRecEndFilePos() ) ) 1701 rStCtrl >> pE2->aSlideAtom; 1702 else if ( SeekToRec( rStCtrl, PPT_PST_NotesAtom, aSlideHd.GetRecEndFilePos() ) ) 1703 rStCtrl >> pE2->aNotesAtom; 1704 aSlideHd.SeekToContent( rStCtrl ); 1705 1706 DffRecordHeader aPPTDrawingHd; 1707 if ( SeekToRec( rStCtrl, PPT_PST_PPDrawing, aSlideHd.GetRecEndFilePos(), &aPPTDrawingHd ) ) 1708 { 1709 DffRecordHeader aPPTDgContainer; 1710 if ( SeekToRec( rStCtrl, DFF_msofbtDgContainer, aPPTDrawingHd.GetRecEndFilePos(), &aPPTDgContainer ) ) 1711 { 1712 if ( SeekToRec( rStCtrl, DFF_msofbtDg, aPPTDrawingHd.GetRecEndFilePos() ) ) 1713 { 1714 DffRecordHeader aDgRecordHeader; 1715 rStCtrl >> aDgRecordHeader; 1716 pE2->nDrawingDgId = aDgRecordHeader.nRecInstance; 1717 aDgRecordHeader.SeekToEndOfRecord( rStCtrl ); 1718 } 1719 if ( SeekToRec( rStCtrl, DFF_msofbtSolverContainer, aPPTDgContainer.GetRecEndFilePos() ) ) 1720 { 1721 pE2->pSolverContainer = new SvxMSDffSolverContainer; 1722 rStCtrl >> *( pE2->pSolverContainer ); 1723 } 1724 aPPTDgContainer.SeekToBegOfRecord( rStCtrl ); 1725 SetDgContainer( rStCtrl ); // set this, so that the escherimport is knowing of our drawings 1726 } 1727 } 1728 // office xp is supporting more than one stylesheet 1729 if ( ( pE2->ePageKind == PPT_MASTERPAGE ) && ( pE2->aSlideAtom.nMasterId == 0 ) && ( pE2->bNotesMaster == 0 ) ) 1730 { 1731 PPTTextSpecInfo aTxSI( 0 ); 1732 if ( aTxSIStyle.bValid && aTxSIStyle.aList.Count() ) 1733 aTxSI = *( ( (PPTTextSpecInfo*)aTxSIStyle.aList.GetObject( 0 ) ) ); 1734 1735 pE2->pStyleSheet = new PPTStyleSheet( aSlideHd, rStCtrl, *this, aTxCFStyle, aTxPFStyle, aTxSI ); 1736 pDefaultSheet = pE2->pStyleSheet; 1737 } 1738 if ( SeekToRec( rStCtrl, PPT_PST_ColorSchemeAtom, aSlideHd.GetRecEndFilePos() ) ) 1739 rStCtrl >> pE2->aColorScheme; 1740 else 1741 { 1742 DBG_ERROR( "SdrPowerPointImport::Ctor(): could not get SlideColorScheme! (SJ)" ); 1743 } 1744 } 1745 else 1746 { 1747 DBG_ERROR("SdrPowerPointImport::Ctor(): Persist-Eintrag fehlerhaft! (SJ)"); 1748 } 1749 } 1750 } 1751 } 1752 DffRecordHeader* pHeadersFootersHd = aDocRecManager.GetRecordHeader( PPT_PST_HeadersFooters, SEEK_FROM_BEGINNING ); 1753 if ( pHeadersFootersHd ) 1754 { 1755 HeaderFooterEntry aNormalMaster, aNotesMaster; 1756 for ( ; pHeadersFootersHd; pHeadersFootersHd = aDocRecManager.GetRecordHeader( PPT_PST_HeadersFooters, SEEK_FROM_CURRENT ) ) 1757 { 1758 if ( pHeadersFootersHd->nRecInstance == 3 ) // normal master 1759 ImportHeaderFooterContainer( *pHeadersFootersHd, aNormalMaster ); 1760 else if ( pHeadersFootersHd->nRecInstance == 4 ) // notes master 1761 ImportHeaderFooterContainer( *pHeadersFootersHd, aNotesMaster ); 1762 } 1763 for ( sal_uInt16 i = 0; i < pMasterPages->Count(); i++ ) 1764 { 1765 if ( (*pMasterPages)[ i ]->bNotesMaster ) 1766 (*pMasterPages)[ i ]->pHeaderFooterEntry = new HeaderFooterEntry( aNotesMaster ); 1767 else 1768 (*pMasterPages)[ i ]->pHeaderFooterEntry = new HeaderFooterEntry( aNormalMaster ); 1769 } 1770 } 1771 } 1772 } 1773 if ( ( rStCtrl.GetError() != 0 ) || ( pDefaultSheet == NULL ) ) 1774 bOk = sal_False; 1775 pPPTStyleSheet = pDefaultSheet; 1776 rStCtrl.Seek( 0 ); 1777 } 1778 1779 SdrPowerPointImport::~SdrPowerPointImport() 1780 { 1781 for ( void* pPtr = aHyperList.First(); pPtr; pPtr = aHyperList.Next() ) 1782 delete (SdHyperlinkEntry*)pPtr; 1783 delete pMasterPages; 1784 delete pSlidePages; 1785 delete pNotePages; 1786 delete[] pPersistPtr; 1787 } 1788 1789 sal_Bool PPTConvertOCXControls::InsertControl( 1790 const com::sun::star::uno::Reference< 1791 com::sun::star::form::XFormComponent > &rFComp, 1792 const com::sun::star::awt::Size& rSize, 1793 com::sun::star::uno::Reference< 1794 com::sun::star::drawing::XShape > *pShape, 1795 sal_Bool /*bFloatingCtrl*/) 1796 { 1797 sal_Bool bRetValue = sal_False; 1798 try 1799 { 1800 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape; 1801 1802 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > & rFormComps = 1803 GetFormComps(); 1804 1805 ::com::sun::star::uno::Any aTmp( &rFComp, ::getCppuType((const ::com::sun::star::uno::Reference< 1806 com::sun::star::form::XFormComponent >*)0) ); 1807 1808 rFormComps->insertByIndex( rFormComps->getCount(), aTmp ); 1809 1810 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceFactory = 1811 GetServiceFactory(); 1812 if( rServiceFactory.is() ) 1813 { 1814 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xCreate = rServiceFactory 1815 ->createInstance(String( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.ControlShape" ) ) ); 1816 if( xCreate.is() ) 1817 { 1818 xShape = ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >(xCreate, ::com::sun::star::uno::UNO_QUERY); 1819 if ( xShape.is() ) 1820 { 1821 xShape->setSize(rSize); 1822 // GetShapes()->add( xShape ); 1823 // Das Control-Model am Control-Shape setzen 1824 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XControlShape > xControlShape( xShape, 1825 ::com::sun::star::uno::UNO_QUERY ); 1826 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > xControlModel( rFComp, 1827 ::com::sun::star::uno::UNO_QUERY ); 1828 if ( xControlShape.is() && xControlModel.is() ) 1829 { 1830 xControlShape->setControl( xControlModel ); 1831 if (pShape) 1832 *pShape = xShape; 1833 bRetValue = sal_True; 1834 } 1835 } 1836 } 1837 } 1838 } 1839 catch( ... ) 1840 { 1841 bRetValue = sal_False; 1842 } 1843 return bRetValue; 1844 }; 1845 1846 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& PPTConvertOCXControls::GetDrawPage() 1847 { 1848 if( !xDrawPage.is() && pDocSh ) 1849 { 1850 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel( pDocSh->GetModel() ); 1851 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPages > xDrawPages; 1852 switch( ePageKind ) 1853 { 1854 case PPT_SLIDEPAGE : 1855 case PPT_NOTEPAGE : 1856 { 1857 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPagesSupplier > 1858 xDrawPagesSupplier( xModel, ::com::sun::star::uno::UNO_QUERY); 1859 if ( xDrawPagesSupplier.is() ) 1860 xDrawPages = xDrawPagesSupplier->getDrawPages(); 1861 } 1862 break; 1863 1864 case PPT_MASTERPAGE : 1865 { 1866 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPagesSupplier > 1867 xMasterPagesSupplier( xModel, ::com::sun::star::uno::UNO_QUERY); 1868 if ( xMasterPagesSupplier.is() ) 1869 xDrawPages = xMasterPagesSupplier->getMasterPages(); 1870 } 1871 break; 1872 } 1873 if ( xDrawPages.is() && xDrawPages->getCount() ) 1874 { 1875 xDrawPages->getCount(); 1876 ::com::sun::star::uno::Any aAny( xDrawPages->getByIndex( xDrawPages->getCount() - 1 ) ); 1877 aAny >>= xDrawPage; 1878 } 1879 } 1880 return xDrawPage; 1881 } 1882 1883 sal_Bool SdrPowerPointOLEDecompress( SvStream& rOutput, SvStream& rInput, sal_uInt32 nInputSize ) 1884 { 1885 sal_uInt32 nOldPos = rInput.Tell(); 1886 char* pBuf = new char[ nInputSize ]; 1887 rInput.Read( pBuf, nInputSize ); 1888 ZCodec aZCodec( 0x8000, 0x8000 ); 1889 aZCodec.BeginCompression(); 1890 SvMemoryStream aSource( pBuf, nInputSize, STREAM_READ ); 1891 aZCodec.Decompress( aSource, rOutput ); 1892 const sal_Bool bSuccess(0L != aZCodec.EndCompression()); 1893 delete[] pBuf; 1894 rInput.Seek( nOldPos ); 1895 return bSuccess; 1896 } 1897 1898 // --> OD 2004-12-14 #i32596# - add new parameter <_nCalledByGroup> 1899 SdrObject* SdrPowerPointImport::ImportOLE( long nOLEId, 1900 const Graphic& rGraf, 1901 const Rectangle& rBoundRect, 1902 const Rectangle& rVisArea, 1903 const int /*_nCalledByGroup*/, 1904 sal_Int64 /*nAspect*/ ) const 1905 // <-- 1906 { 1907 SdrObject* pRet = NULL; 1908 1909 sal_uInt32 nOldPos = rStCtrl.Tell(); 1910 1911 Graphic aGraphic( rGraf ); 1912 1913 if ( ((SdrPowerPointImport*)this)->maShapeRecords.SeekToContent( rStCtrl, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) ) 1914 { 1915 DffRecordHeader aPlaceHd; 1916 while ( ( rStCtrl.GetError() == 0 ) 1917 && ( rStCtrl.Tell() < ((SdrPowerPointImport*)this)->maShapeRecords.Current()->GetRecEndFilePos() ) ) 1918 { 1919 rStCtrl >> aPlaceHd; 1920 if ( aPlaceHd.nRecType == PPT_PST_RecolorInfoAtom ) 1921 { 1922 ((SdrPowerPointImport*)this)->RecolorGraphic( rStCtrl, aPlaceHd.nRecLen, aGraphic ); 1923 break; 1924 } 1925 else 1926 aPlaceHd.SeekToEndOfRecord( rStCtrl ); 1927 } 1928 } 1929 1930 PPTOleEntry* pOe; 1931 for ( pOe = (PPTOleEntry*)((SdrPowerPointImport*)this)->aOleObjectList.First(); pOe; 1932 pOe = (PPTOleEntry*)((SdrPowerPointImport*)this)->aOleObjectList.Next() ) 1933 { 1934 if ( pOe->nId != (sal_uInt32)nOLEId ) 1935 continue; 1936 1937 rStCtrl.Seek( pOe->nRecHdOfs ); 1938 1939 DffRecordHeader aHd; 1940 rStCtrl >> aHd; 1941 1942 sal_uInt32 nLen = aHd.nRecLen - 4; 1943 if ( (sal_Int32)nLen > 0 ) 1944 { 1945 sal_Bool bSuccess = sal_False; 1946 1947 rStCtrl.SeekRel( 4 ); 1948 1949 ::utl::TempFile aTmpFile; 1950 aTmpFile.EnableKillingFile( sal_True ); 1951 1952 if ( aTmpFile.IsValid() ) 1953 { 1954 SvStream* pDest = ::utl::UcbStreamHelper::CreateStream( aTmpFile.GetURL(), STREAM_TRUNC | STREAM_WRITE ); 1955 if ( pDest ) 1956 bSuccess = SdrPowerPointOLEDecompress( *pDest, rStCtrl, nLen ); 1957 delete pDest; 1958 } 1959 if ( bSuccess ) 1960 { 1961 SvStream* pDest = ::utl::UcbStreamHelper::CreateStream( aTmpFile.GetURL(), STREAM_READ ); 1962 Storage* pObjStor = pDest ? new Storage( *pDest, sal_True ) : NULL; 1963 if ( pObjStor ) 1964 { 1965 SotStorageRef xObjStor( new SotStorage( pObjStor ) ); 1966 if ( xObjStor.Is() && !xObjStor->GetError() ) 1967 { 1968 if ( xObjStor->GetClassName() == SvGlobalName() ) 1969 { 1970 ClsId aId( pObjStor->GetClassId() ); 1971 xObjStor->SetClass( SvGlobalName( aId.n1, aId.n2, aId.n3, aId.n4, aId.n5, aId.n6, aId.n7, aId.n8, aId.n9, aId.n10, aId.n11 ), 1972 pObjStor->GetFormat(), pObjStor->GetUserName() ); 1973 } 1974 SotStorageStreamRef xSrcTst = xObjStor->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "\1Ole" ) ) ); 1975 if ( xSrcTst.Is() ) 1976 { 1977 sal_uInt8 aTestA[ 10 ]; 1978 sal_Bool bGetItAsOle = ( sizeof( aTestA ) == xSrcTst->Read( aTestA, sizeof( aTestA ) ) ); 1979 if ( !bGetItAsOle ) 1980 { // maybe there is a contentsstream in here 1981 xSrcTst = xObjStor->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "Contents" ) ), STREAM_READWRITE | STREAM_NOCREATE ); 1982 bGetItAsOle = ( xSrcTst.Is() && sizeof( aTestA ) == xSrcTst->Read( aTestA, sizeof( aTestA ) ) ); 1983 } 1984 if ( bGetItAsOle ) 1985 { 1986 ::rtl::OUString aNm; 1987 // if ( nSvxMSDffOLEConvFlags ) 1988 { 1989 uno::Reference < embed::XStorage > xDestStorage( pOe->pShell->GetStorage() ); 1990 uno::Reference < embed::XEmbeddedObject > xObj = 1991 CheckForConvertToSOObj( nSvxMSDffOLEConvFlags, *xObjStor, xDestStorage, rGraf, rVisArea ); 1992 if( xObj.is() ) 1993 { 1994 pOe->pShell->getEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aNm ); 1995 1996 svt::EmbeddedObjectRef aObj( xObj, pOe->nAspect ); 1997 1998 // TODO/LATER: need MediaType for Graphic 1999 aObj.SetGraphic( rGraf, ::rtl::OUString() ); 2000 pRet = new SdrOle2Obj( aObj, aNm, rBoundRect, sal_False ); 2001 } 2002 } 2003 if ( !pRet && ( pOe->nType == PPT_PST_ExControl ) ) 2004 { 2005 PPTConvertOCXControls aPPTConvertOCXControls( pOe->pShell, eAktPageKind ); 2006 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape; 2007 if ( aPPTConvertOCXControls.ReadOCXStream( xObjStor, &xShape, sal_False ) ) 2008 pRet = GetSdrObjectFromXShape( xShape ); 2009 } 2010 if ( !pRet ) 2011 { 2012 aNm = pOe->pShell->getEmbeddedObjectContainer().CreateUniqueObjectName(); 2013 ErrCode aErrCode = 0; 2014 2015 // object is not an own object 2016 SotStorageRef xTarget = SotStorage::OpenOLEStorage( pOe->pShell->GetStorage(), aNm, STREAM_READWRITE ); 2017 if ( xObjStor.Is() && xTarget.Is() ) 2018 { 2019 xObjStor->CopyTo( xTarget ); 2020 if( !xTarget->GetError() ) 2021 xTarget->Commit(); 2022 if( xTarget->GetError() ) 2023 aErrCode = xTarget->GetError(); 2024 } 2025 xTarget.Clear(); 2026 2027 uno::Reference < embed::XEmbeddedObject > xObj = 2028 pOe->pShell->getEmbeddedObjectContainer().GetEmbeddedObject( aNm ); 2029 if ( xObj.is() ) 2030 { 2031 if ( pOe->nAspect != embed::Aspects::MSOLE_ICON ) 2032 { 2033 //TODO/LATER: keep on hacking?! 2034 // modifiziert wollen wir nicht werden 2035 //xInplaceObj->EnableSetModified( sal_False ); 2036 if ( rVisArea.IsEmpty() ) 2037 { 2038 MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( pOe->nAspect ) ); 2039 Size aSize( OutputDevice::LogicToLogic( aGraphic.GetPrefSize(), 2040 aGraphic.GetPrefMapMode(), MapMode( aMapUnit ) ) ); 2041 2042 awt::Size aSz; 2043 aSz.Width = aSize.Width(); 2044 aSz.Height = aSize.Height(); 2045 xObj->setVisualAreaSize( pOe->nAspect, aSz ); 2046 } 2047 else 2048 { 2049 awt::Size aSize( rVisArea.GetSize().Width(), rVisArea.GetSize().Height() ); 2050 xObj->setVisualAreaSize( pOe->nAspect, aSize ); 2051 } 2052 //xInplaceObj->EnableSetModified( sal_True ); 2053 } 2054 2055 svt::EmbeddedObjectRef aObj( xObj, pOe->nAspect ); 2056 2057 // TODO/LATER: need MediaType for Graphic 2058 aObj.SetGraphic( aGraphic, ::rtl::OUString() ); 2059 2060 pRet = new SdrOle2Obj( aObj, aNm, rBoundRect, sal_False ); 2061 } 2062 } 2063 } 2064 } 2065 } 2066 } 2067 delete pDest; 2068 } 2069 } 2070 } 2071 rStCtrl.Seek( nOldPos ); 2072 2073 return pRet; 2074 } 2075 2076 SvMemoryStream* SdrPowerPointImport::ImportExOleObjStg( sal_uInt32 nPersistPtr, sal_uInt32& nOleId ) const 2077 { 2078 SvMemoryStream* pRet = NULL; 2079 if ( nPersistPtr && ( nPersistPtr < nPersistPtrAnz ) ) 2080 { 2081 sal_uInt32 nOldPos, nOfs = pPersistPtr[ nPersistPtr ]; 2082 nOldPos = rStCtrl.Tell(); 2083 rStCtrl.Seek( nOfs ); 2084 DffRecordHeader aHd; 2085 rStCtrl >> aHd; 2086 if ( aHd.nRecType == DFF_PST_ExOleObjStg ) 2087 { 2088 sal_uInt32 nLen = aHd.nRecLen - 4; 2089 if ( (sal_Int32)nLen > 0 ) 2090 { 2091 rStCtrl >> nOleId; 2092 pRet = new SvMemoryStream; 2093 ZCodec aZCodec( 0x8000, 0x8000 ); 2094 aZCodec.BeginCompression(); 2095 aZCodec.Decompress( rStCtrl, *pRet ); 2096 if ( !aZCodec.EndCompression() ) 2097 delete pRet, pRet = NULL; 2098 } 2099 } 2100 rStCtrl.Seek( nOldPos ); 2101 } 2102 return pRet; 2103 } 2104 2105 void SdrPowerPointImport::SeekOle( SfxObjectShell* pShell, sal_uInt32 nFilterOptions ) 2106 { 2107 if ( pShell ) 2108 { 2109 DffRecordHeader* pHd; 2110 2111 sal_uInt32 nOldPos = rStCtrl.Tell(); 2112 if ( nFilterOptions & 1 ) 2113 { 2114 pHd = aDocRecManager.GetRecordHeader( PPT_PST_List, SEEK_FROM_BEGINNING ); 2115 if ( pHd ) 2116 { 2117 // we try to locate the basic atom 2118 pHd->SeekToContent( rStCtrl ); 2119 if ( SeekToRec( rStCtrl, PPT_PST_VBAInfo, pHd->GetRecEndFilePos(), pHd ) ) 2120 { 2121 if ( SeekToRec( rStCtrl, PPT_PST_VBAInfoAtom, pHd->GetRecEndFilePos(), pHd ) ) 2122 { 2123 sal_uInt32 nPersistPtr, nIDoNotKnow1, nIDoNotKnow2; 2124 rStCtrl >> nPersistPtr 2125 >> nIDoNotKnow1 2126 >> nIDoNotKnow2; 2127 2128 sal_uInt32 nOleId; 2129 SvMemoryStream* pBas = ImportExOleObjStg( nPersistPtr, nOleId ); 2130 if ( pBas ) 2131 { 2132 SotStorageRef xSource( new SotStorage( pBas, sal_True ) ); 2133 SotStorageRef xDest( new SotStorage( new SvMemoryStream(), sal_True ) ); 2134 if ( xSource.Is() && xDest.Is() ) 2135 { 2136 // is this a visual basic storage ? 2137 SotStorageRef xSubStorage = xSource->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "VBA" ) ), 2138 STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYALL ); 2139 if( xSubStorage.Is() && ( SVSTREAM_OK == xSubStorage->GetError() ) ) 2140 { 2141 SotStorageRef xMacros = xDest->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "MACROS" ) ) ); 2142 if ( xMacros.Is() ) 2143 { 2144 SvStorageInfoList aList; 2145 xSource->FillInfoList( &aList ); 2146 sal_uInt32 i; 2147 2148 sal_Bool bCopied = sal_True; 2149 for ( i = 0; i < aList.Count(); i++ ) // copy all entrys 2150 { 2151 const SvStorageInfo& rInfo = aList[ i ]; 2152 if ( !xSource->CopyTo( rInfo.GetName(), xMacros, rInfo.GetName() ) ) 2153 bCopied = sal_False; 2154 } 2155 if ( i && bCopied ) 2156 { 2157 SvxImportMSVBasic aMSVBas( *pShell, *xDest, sal_True, sal_False ); 2158 //int nSuccess = aMSVBas.Import( String( RTL_CONSTASCII_USTRINGPARAM( "MACROS" ) ), 2159 // String( RTL_CONSTASCII_USTRINGPARAM( "VBA" ) ), TRUE, FALSE ); 2160 2161 uno::Reference < embed::XStorage > xDoc( pShell->GetStorage() ); 2162 if ( xDoc.is() ) 2163 { 2164 SotStorageRef xVBA = SotStorage::OpenOLEStorage( xDoc, String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Macros" ) ) ); 2165 if ( xVBA.Is() && ( xVBA->GetError() == SVSTREAM_OK ) ) 2166 { 2167 SotStorageRef xSubVBA = xVBA->OpenSotStorage( String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Overhead" ) ) ); 2168 if ( xSubVBA.Is() && ( xSubVBA->GetError() == SVSTREAM_OK ) ) 2169 { 2170 SotStorageStreamRef xOriginal = xSubVBA->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "_MS_VBA_Overhead2" ) ) ); 2171 if ( xOriginal.Is() && ( xOriginal->GetError() == SVSTREAM_OK ) ) 2172 { 2173 if ( nPersistPtr && ( nPersistPtr < nPersistPtrAnz ) ) 2174 { 2175 rStCtrl.Seek( pPersistPtr[ nPersistPtr ] ); 2176 rStCtrl >> *pHd; 2177 2178 *xOriginal << nIDoNotKnow1 2179 << nIDoNotKnow2; 2180 2181 sal_uInt32 nSource, nToCopy, nBufSize; 2182 nSource = rStCtrl.Tell(); 2183 nToCopy = pHd->nRecLen; 2184 sal_uInt8* pBuf = new sal_uInt8[ 0x40000 ]; // 256KB Buffer 2185 if ( pBuf ) 2186 { 2187 while ( nToCopy ) 2188 { 2189 nBufSize = ( nToCopy >= 0x40000 ) ? 0x40000 : nToCopy; 2190 rStCtrl.Read( pBuf, nBufSize ); 2191 xOriginal->Write( pBuf, nBufSize ); 2192 nToCopy -= nBufSize; 2193 } 2194 delete[] pBuf; 2195 } 2196 } 2197 } 2198 } 2199 } 2200 } 2201 } 2202 } 2203 } 2204 } 2205 } 2206 } 2207 } 2208 } 2209 } 2210 pHd = aDocRecManager.GetRecordHeader( PPT_PST_ExObjList, SEEK_FROM_BEGINNING ); 2211 if ( pHd ) 2212 { 2213 DffRecordManager* pExObjListManager = NULL; 2214 DffRecordHeader* pExEmbed = NULL; 2215 2216 pHd->SeekToBegOfRecord( rStCtrl ); 2217 pExObjListManager = new DffRecordManager( rStCtrl ); 2218 sal_uInt16 i, nRecType(PPT_PST_ExEmbed); 2219 2220 for ( i = 0; i < 2; i++ ) 2221 { 2222 switch ( i ) 2223 { 2224 case 0 : nRecType = PPT_PST_ExEmbed; break; 2225 case 1 : nRecType = PPT_PST_ExControl; break; 2226 } 2227 for ( pExEmbed = pExObjListManager->GetRecordHeader( nRecType, SEEK_FROM_BEGINNING ); 2228 pExEmbed; pExEmbed = pExObjListManager->GetRecordHeader( nRecType, SEEK_FROM_CURRENT ) ) 2229 { 2230 pExEmbed->SeekToContent( rStCtrl ); 2231 2232 DffRecordHeader aExOleAtHd; 2233 if ( SeekToRec( rStCtrl, PPT_PST_ExOleObjAtom, pExEmbed->GetRecEndFilePos(), &aExOleAtHd ) ) 2234 { 2235 PptExOleObjAtom aAt; 2236 rStCtrl >> aAt; 2237 2238 if ( aAt.nPersistPtr && ( aAt.nPersistPtr < nPersistPtrAnz ) ) 2239 { 2240 sal_uInt32 nId; 2241 rStCtrl.Seek( pPersistPtr[ aAt.nPersistPtr ] ); 2242 DffRecordHeader aHd; 2243 rStCtrl >> aHd; 2244 if ( aHd.nRecType == DFF_PST_ExOleObjStg ) 2245 { 2246 rStCtrl >> nId; 2247 aOleObjectList.Insert( 2248 new PPTOleEntry( aAt.nId, aHd.nFilePos, pShell, nRecType, aAt.nAspect ) ); 2249 } 2250 } 2251 } 2252 } 2253 } 2254 delete pExObjListManager; 2255 } 2256 rStCtrl.Seek( nOldPos ); 2257 } 2258 } 2259 2260 sal_Bool SdrPowerPointImport::ReadFontCollection() 2261 { 2262 sal_Bool bRet = sal_False; 2263 DffRecordHeader* pEnvHd = aDocRecManager.GetRecordHeader( PPT_PST_Environment ); 2264 if ( pEnvHd ) 2265 { 2266 sal_uLong nFPosMerk = rStCtrl.Tell(); // FilePos merken fuer spaetere Restauration 2267 pEnvHd->SeekToContent( rStCtrl ); 2268 DffRecordHeader aListHd; 2269 if ( SeekToRec( rStCtrl, PPT_PST_FontCollection, pEnvHd->GetRecEndFilePos(), &aListHd ) ) 2270 { 2271 sal_uInt16 nCount2 = 0; 2272 VirtualDevice* pVDev = NULL; 2273 while ( SeekToRec( rStCtrl, PPT_PST_FontEntityAtom, aListHd.GetRecEndFilePos() ) ) 2274 { 2275 bRet = sal_True; 2276 if ( !pFonts ) 2277 pFonts = new PptFontCollection; 2278 PptFontEntityAtom* pFont = new PptFontEntityAtom; 2279 rStCtrl >> *pFont; 2280 2281 Font aFont; 2282 aFont.SetCharSet( pFont->eCharSet ); 2283 aFont.SetName( pFont->aName ); 2284 aFont.SetFamily( pFont->eFamily ); 2285 aFont.SetPitch( pFont->ePitch ); 2286 aFont.SetHeight( 100 ); 2287 2288 if ( mbTracing && !pFont->bAvailable ) 2289 mpTracer->Trace( rtl::OUString::createFromAscii( "sd1000" ), pFont->aName ); 2290 2291 #ifdef DBG_EXTRACTFONTMETRICS 2292 2293 SvxFont aTmpFont( aFont ); 2294 2295 if ( !pVDev ) 2296 pVDev = new VirtualDevice; 2297 aTmpFont.SetPhysFont( pVDev ); 2298 FontMetric aMetric( pVDev->GetFontMetric() ); 2299 sal_uInt16 nTxtHeight = (sal_uInt16)aMetric.GetAscent() + (sal_uInt16)aMetric.GetDescent(); 2300 2301 String aFileURLStr; 2302 if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( Application::GetAppFileName(), aFileURLStr ) ) 2303 { 2304 INetURLObject aURL( aFileURLStr ); 2305 aURL.SetName( String( RTL_CONSTASCII_STRINGPARAM( "dbgfontmetrics.txt" ) ) ); 2306 2307 SvStream* pDbgOut = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE ); 2308 if( pDbgOut ) 2309 { 2310 pDbgOut->Seek( STREAM_SEEK_TO_END ); 2311 2312 Printer* pPrinter = NULL; 2313 if ( pSdrModel->GetRefDevice() && pSdrModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER ) 2314 pPrinter = (Printer*)pSdrModel->GetRefDevice(); 2315 if ( pPrinter ) 2316 { 2317 Font aOldFont( pPrinter->GetFont() ); 2318 aFont.SetKerning( sal_True ); 2319 pPrinter->SetFont( aFont ); 2320 aMetric = pPrinter->GetFontMetric(); 2321 pPrinter->SetFont( aOldFont ); 2322 } 2323 2324 if ( ( pPrinter == NULL ) || ( aMetric.GetIntLeading() == 0 ) ) 2325 { 2326 VirtualDevice aVirDev( 1 ); 2327 aVirDev.SetFont( aFont ); 2328 aMetric = aVirDev.GetFontMetric(); 2329 } 2330 ByteString aFontName( aFont.GetName(), RTL_TEXTENCODING_UTF8 ); 2331 ByteString aHeight( ByteString::CreateFromInt32( aMetric.GetLineHeight() ) ); 2332 ByteString aAscent( ByteString::CreateFromInt32( aMetric.GetAscent() ) ); 2333 ByteString aDescent( ByteString::CreateFromInt32( aMetric.GetDescent() ) ); 2334 ByteString aLeading( ByteString::CreateFromInt32( aMetric.GetIntLeading() ) ); 2335 ByteString aPhysHeight( ByteString::CreateFromInt32( nTxtHeight ) ); 2336 2337 *pDbgOut << (sal_uInt8)0xa 2338 << "FontName : " << aFontName.GetBuffer() << (sal_uInt8)0xa 2339 << " Height: " << aHeight.GetBuffer() << (sal_uInt8)0xa 2340 << " Ascent: " << aAscent.GetBuffer() << (sal_uInt8)0xa 2341 << " Descent:" << aDescent.GetBuffer() << (sal_uInt8)0xa 2342 << " Leading:" << aLeading.GetBuffer() << (sal_uInt8)0xa 2343 << "PhysHeight :" << aPhysHeight.GetBuffer()<< (sal_uInt8)0xa; 2344 } 2345 delete pDbgOut; 2346 } 2347 #endif 2348 // following block is necessary, because our old PowerPoint export did not set the 2349 // correct charset 2350 if ( pFont->aName.EqualsIgnoreCaseAscii( "Wingdings" ) || 2351 pFont->aName.EqualsIgnoreCaseAscii( "Wingdings 2" ) || 2352 pFont->aName.EqualsIgnoreCaseAscii( "Wingdings 3" ) || 2353 pFont->aName.EqualsIgnoreCaseAscii( "Monotype Sorts" ) || 2354 pFont->aName.EqualsIgnoreCaseAscii( "Monotype Sorts 2" ) || 2355 pFont->aName.EqualsIgnoreCaseAscii( "Webdings" ) || 2356 pFont->aName.EqualsIgnoreCaseAscii( "StarBats" ) || 2357 pFont->aName.EqualsIgnoreCaseAscii( "StarMath" ) || 2358 pFont->aName.EqualsIgnoreCaseAscii( "ZapfDingbats" ) ) 2359 { 2360 pFont->eCharSet = RTL_TEXTENCODING_SYMBOL; 2361 }; 2362 pFonts->C40_INSERT( PptFontEntityAtom, pFont, nCount2++ ); 2363 } 2364 delete pVDev; 2365 } 2366 rStCtrl.Seek( nFPosMerk ); // FilePos restaurieren 2367 } 2368 return bRet; 2369 } 2370 2371 PptSlidePersistList* SdrPowerPointImport::GetPageList(PptPageKind ePageKind) const 2372 { 2373 if ( ePageKind == PPT_MASTERPAGE ) 2374 return pMasterPages; 2375 if ( ePageKind == PPT_SLIDEPAGE ) 2376 return pSlidePages; 2377 if ( ePageKind == PPT_NOTEPAGE ) 2378 return pNotePages; 2379 return NULL; 2380 } 2381 2382 SdrOutliner* SdrPowerPointImport::GetDrawOutliner( SdrTextObj* pSdrText ) const 2383 { 2384 if ( !pSdrText ) 2385 return NULL; 2386 else 2387 return &pSdrText->ImpGetDrawOutliner(); 2388 } 2389 2390 2391 SdrObject* SdrPowerPointImport::ReadObjText( PPTTextObj* pTextObj, SdrObject* pSdrObj, SdPage* pPage ) const 2392 { 2393 SdrTextObj* pText = PTR_CAST( SdrTextObj, pSdrObj ); 2394 if ( pText ) 2395 { 2396 if ( !ApplyTextObj( pTextObj, pText, pPage, NULL, NULL ) ) 2397 pSdrObj = NULL; 2398 } 2399 return pSdrObj; 2400 } 2401 2402 2403 SdrObject* SdrPowerPointImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* pSdrText, SdPage* /*pPage*/, 2404 SfxStyleSheet* pSheet, SfxStyleSheet** ppStyleSheetAry ) const 2405 { 2406 SdrTextObj* pText = pSdrText; 2407 if ( pTextObj->Count() ) 2408 { 2409 sal_uInt32 nDestinationInstance = pTextObj->GetDestinationInstance() ; 2410 SdrOutliner& rOutliner = pText->ImpGetDrawOutliner(); 2411 if ( ( pText->GetObjInventor() == SdrInventor ) && ( pText->GetObjIdentifier() == OBJ_TITLETEXT ) ) // Outliner-Style fuer Titel-Textobjekt?!? (->von DL) 2412 rOutliner.Init( OUTLINERMODE_TITLEOBJECT ); // Outliner reset 2413 2414 sal_Bool bOldUpdateMode = rOutliner.GetUpdateMode(); 2415 rOutliner.SetUpdateMode( sal_False ); 2416 if ( pSheet ) 2417 { 2418 if ( rOutliner.GetStyleSheet( 0 ) != pSheet ) 2419 rOutliner.SetStyleSheet( 0, pSheet ); 2420 } 2421 rOutliner.SetVertical( pTextObj->GetVertical() ); 2422 const PPTParagraphObj* pPreviousParagraph = NULL; 2423 for ( PPTParagraphObj* pPara = pTextObj->First(); pPara; pPara = pTextObj->Next() ) 2424 { 2425 sal_uInt32 nTextSize = pPara->GetTextSize(); 2426 if ( ! ( nTextSize & 0xffff0000 ) ) 2427 { 2428 PPTPortionObj* pPortion; 2429 sal_Unicode* pParaText = new sal_Unicode[ nTextSize ]; 2430 sal_uInt32 nCurrentIndex = 0; 2431 for ( pPortion = pPara->First(); pPortion; pPortion = pPara->Next() ) 2432 { 2433 if ( pPortion->mpFieldItem ) 2434 pParaText[ nCurrentIndex++ ] = ' '; 2435 else 2436 { 2437 sal_uInt32 nCharacters = pPortion->Count(); 2438 const sal_Unicode* pSource = pPortion->maString.GetBuffer(); 2439 sal_Unicode* pDest = pParaText + nCurrentIndex; 2440 2441 sal_uInt32 nFont; 2442 pPortion->GetAttrib( PPT_CharAttr_Font, nFont, pTextObj->GetInstance() ); 2443 PptFontEntityAtom* pFontEnityAtom = GetFontEnityAtom( nFont ); 2444 if ( pFontEnityAtom && ( pFontEnityAtom->eCharSet == RTL_TEXTENCODING_SYMBOL ) ) 2445 { 2446 sal_uInt32 i; 2447 sal_Unicode nUnicode; 2448 for ( i = 0; i < nCharacters; i++ ) 2449 { 2450 nUnicode = pSource[ i ]; 2451 if ( ! ( nUnicode & 0xff00 ) ) 2452 nUnicode |= 0xf000; 2453 pDest[ i ] = nUnicode; 2454 } 2455 } 2456 else 2457 memcpy( pDest, pSource, nCharacters << 1 ); 2458 nCurrentIndex += nCharacters; 2459 } 2460 } 2461 sal_uInt16 nParaIndex = (sal_uInt16)pTextObj->GetCurrentIndex(); 2462 SfxStyleSheet* pS = ( ppStyleSheetAry ) ? ppStyleSheetAry[ pPara->pParaSet->mnDepth ] : pSheet; 2463 2464 ESelection aSelection( nParaIndex, 0, nParaIndex, 0 ); 2465 rOutliner.Insert( String(), nParaIndex, pPara->pParaSet->mnDepth ); 2466 rOutliner.QuickInsertText( String( pParaText, (sal_uInt16)nCurrentIndex ), aSelection ); 2467 rOutliner.SetParaAttribs( nParaIndex, rOutliner.GetEmptyItemSet() ); 2468 if ( pS ) 2469 rOutliner.SetStyleSheet( nParaIndex, pS ); 2470 2471 for ( pPortion = pPara->First(); pPortion; pPortion = pPara->Next() ) 2472 { 2473 SfxItemSet aPortionAttribs( rOutliner.GetEmptyItemSet() ); 2474 SvxFieldItem* pFieldItem = pPortion->GetTextField(); 2475 if ( pFieldItem ) 2476 { 2477 rOutliner.QuickInsertField( *pFieldItem, ESelection( nParaIndex, aSelection.nEndPos, nParaIndex, aSelection.nEndPos + 1 ) ); 2478 aSelection.nEndPos++; 2479 delete pFieldItem; 2480 } 2481 else 2482 { 2483 const sal_Unicode *pF, *pPtr = pPortion->maString.GetBuffer(); 2484 const sal_Unicode *pMax = pPtr + pPortion->maString.Len(); 2485 sal_Int32 nLen; 2486 for ( pF = pPtr; pPtr < pMax; pPtr++ ) 2487 { 2488 if ( *pPtr == 0xb ) 2489 { 2490 nLen = pPtr - pF; 2491 if ( nLen ) 2492 aSelection.nEndPos = 2493 sal::static_int_cast< sal_uInt16 >( 2494 aSelection.nEndPos + nLen ); 2495 pF = pPtr + 1; 2496 rOutliner.QuickInsertLineBreak( ESelection( nParaIndex, aSelection.nEndPos, nParaIndex, aSelection.nEndPos + 1 ) ); 2497 aSelection.nEndPos++; 2498 } 2499 } 2500 nLen = pPtr - pF; 2501 if ( nLen ) 2502 aSelection.nEndPos = sal::static_int_cast< sal_uInt16 >( 2503 aSelection.nEndPos + nLen ); 2504 } 2505 pPortion->ApplyTo( aPortionAttribs, (SdrPowerPointImport&)*this, nDestinationInstance, pTextObj ); 2506 rOutliner.QuickSetAttribs( aPortionAttribs, aSelection ); 2507 aSelection.nStartPos = aSelection.nEndPos; 2508 } 2509 boost::optional< sal_Int16 > oStartNumbering; 2510 SfxItemSet aParagraphAttribs( rOutliner.GetEmptyItemSet() ); 2511 pPara->ApplyTo( aParagraphAttribs, oStartNumbering, (SdrPowerPointImport&)*this, nDestinationInstance, pPreviousParagraph ); 2512 2513 sal_uInt32 nIsBullet2 = 0; //, nInstance = nDestinationInstance != 0xffffffff ? nDestinationInstance : pTextObj->GetInstance(); 2514 pPara->GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet2, nDestinationInstance ); 2515 if ( !nIsBullet2 ) 2516 aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, sal_False ) ); 2517 2518 2519 pPreviousParagraph = pPara; 2520 if ( !aSelection.nStartPos ) // in PPT empty paragraphs never gets a bullet 2521 { 2522 aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, sal_False ) ); 2523 // rOutliner.SetDepth( rOutliner.GetParagraph( nParaIndex ), -1 ); 2524 } 2525 aSelection.nStartPos = 0; 2526 rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection ); 2527 delete[] pParaText; 2528 } 2529 } 2530 OutlinerParaObject* pNewText = rOutliner.CreateParaObject(); 2531 rOutliner.Clear(); 2532 rOutliner.SetUpdateMode( bOldUpdateMode ); 2533 pText->SetOutlinerParaObject( pNewText ); 2534 } 2535 return pText; 2536 } 2537 2538 sal_Bool SdrPowerPointImport::SeekToDocument( DffRecordHeader* pRecHd ) const 2539 { 2540 sal_Bool bRet; 2541 sal_uLong nFPosMerk = rStCtrl.Tell(); // FilePos merken fuer ggf. spaetere Restauration 2542 rStCtrl.Seek( nDocStreamPos ); 2543 DffRecordHeader aDocHd; 2544 rStCtrl >> aDocHd; 2545 bRet = aDocHd.nRecType == PPT_PST_Document; 2546 if ( bRet ) 2547 { 2548 if ( pRecHd ) 2549 *pRecHd = aDocHd; 2550 else 2551 aDocHd.SeekToBegOfRecord( rStCtrl ); 2552 } 2553 if ( !bRet ) 2554 rStCtrl.Seek( nFPosMerk ); // FilePos restaurieren 2555 return bRet; 2556 } 2557 2558 sal_Bool SdrPowerPointImport::SeekToContentOfProgTag( sal_Int32 nVersion, SvStream& rSt, 2559 const DffRecordHeader& rSourceHd, DffRecordHeader& rContentHd ) 2560 { 2561 sal_Bool bRetValue = sal_False; 2562 sal_uInt32 nOldPos = rSt.Tell(); 2563 2564 DffRecordHeader aProgTagsHd, aProgTagBinaryDataHd; 2565 rSourceHd.SeekToContent( rSt ); 2566 sal_Bool bFound = rSourceHd.nRecType == PPT_PST_ProgTags; 2567 if ( !bFound ) 2568 bFound = SeekToRec( rSt, PPT_PST_ProgTags, rSourceHd.GetRecEndFilePos(), &aProgTagsHd ); 2569 if ( bFound ) 2570 { 2571 while( SeekToRec( rSt, PPT_PST_ProgBinaryTag, aProgTagsHd.GetRecEndFilePos(), &aProgTagBinaryDataHd ) ) 2572 { 2573 rSt >> rContentHd; 2574 if ( rContentHd.nRecType == PPT_PST_CString ) 2575 { 2576 sal_uInt16 n = 6; 2577 sal_uInt32 i = rContentHd.nRecLen >> 1; 2578 if ( i > n ) 2579 { 2580 String aPre, aSuf; 2581 sal_Unicode *pTmp = aPre.AllocBuffer( n ); 2582 while ( n-- ) 2583 rSt >> *pTmp++; 2584 n = (sal_uInt16)( i - 6 ); 2585 pTmp = aSuf.AllocBuffer( n ); 2586 while ( n-- ) 2587 rSt >> *pTmp++; 2588 sal_Int32 nV = aSuf.ToInt32(); 2589 if ( ( nV == nVersion ) && ( aPre == String( RTL_CONSTASCII_USTRINGPARAM( "___PPT" ) ) ) ) 2590 { 2591 rContentHd.SeekToEndOfRecord( rSt ); 2592 rSt >> rContentHd; 2593 if ( rContentHd.nRecType == PPT_PST_BinaryTagData ) 2594 { 2595 bRetValue = sal_True; 2596 break; 2597 } 2598 } 2599 } 2600 } 2601 aProgTagBinaryDataHd.SeekToEndOfRecord( rSt ); 2602 } 2603 } 2604 if ( !bRetValue ) 2605 rSt.Seek( nOldPos ); 2606 return bRetValue; 2607 } 2608 2609 sal_uInt32 SdrPowerPointImport::GetAktPageId() 2610 { 2611 PptSlidePersistList* pList = GetPageList( eAktPageKind ); 2612 if ( pList && nAktPageNum < pList->Count() ) 2613 return (*pList)[ (sal_uInt16)nAktPageNum ]->aPersistAtom.nSlideId; 2614 return 0; 2615 } 2616 2617 sal_Bool SdrPowerPointImport::SeekToAktPage( DffRecordHeader* pRecHd ) const 2618 { 2619 sal_Bool bRet = sal_False; 2620 PptSlidePersistList* pList = GetPageList( eAktPageKind ); 2621 if ( pList && ( nAktPageNum < pList->Count() ) ) 2622 { 2623 sal_uLong nPersist = (*pList)[ (sal_uInt16)nAktPageNum ]->aPersistAtom.nPsrReference; 2624 if ( nPersist > 0 && nPersist < nPersistPtrAnz ) 2625 { 2626 sal_uLong nFPos = 0; 2627 nFPos = pPersistPtr[ nPersist ]; 2628 if ( nFPos < nStreamLen ) 2629 { 2630 rStCtrl.Seek( nFPos ); 2631 if ( pRecHd ) 2632 rStCtrl >> *pRecHd; 2633 bRet = sal_True; 2634 } 2635 } 2636 } 2637 return bRet; 2638 } 2639 2640 sal_uInt16 SdrPowerPointImport::GetPageCount( PptPageKind ePageKind ) const 2641 { 2642 PptSlidePersistList* pList = GetPageList( ePageKind ); 2643 if ( pList ) 2644 return pList->Count(); 2645 return 0; 2646 } 2647 2648 void SdrPowerPointImport::SetPageNum( sal_uInt16 nPageNum, PptPageKind eKind ) 2649 { 2650 eAktPageKind = eKind; 2651 nAktPageNum = nPageNum; 2652 2653 pPPTStyleSheet = NULL; 2654 2655 sal_Bool bHasMasterPage = sal_True; 2656 sal_uInt16 nMasterIndex = 0; 2657 2658 if ( eKind == PPT_MASTERPAGE ) 2659 nMasterIndex = nPageNum; 2660 else 2661 { 2662 if ( HasMasterPage( nPageNum, eKind ) ) 2663 nMasterIndex = GetMasterPageIndex( nPageNum, eKind ); 2664 else 2665 bHasMasterPage = sal_False; 2666 } 2667 if ( bHasMasterPage ) 2668 { 2669 PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE ); 2670 if ( pPageList && nMasterIndex < pPageList->Count() ) 2671 { 2672 PptSlidePersistEntry* pMasterPersist = (*pPageList)[ nMasterIndex ]; 2673 if ( ( pMasterPersist->pStyleSheet == NULL ) && pMasterPersist->aSlideAtom.nMasterId ) 2674 { 2675 nMasterIndex = pMasterPages->FindPage( pMasterPersist->aSlideAtom.nMasterId ); 2676 if ( nMasterIndex != PPTSLIDEPERSIST_ENTRY_NOTFOUND ) 2677 pMasterPersist = (*pPageList)[ nMasterIndex ]; 2678 } 2679 pPPTStyleSheet = pMasterPersist->pStyleSheet; 2680 } 2681 } 2682 if ( !pPPTStyleSheet ) 2683 pPPTStyleSheet = pDefaultSheet; 2684 } 2685 2686 Size SdrPowerPointImport::GetPageSize() const 2687 { 2688 Size aRet( IsNoteOrHandout( nAktPageNum, eAktPageKind ) ? aDocAtom.GetNotesPageSize() : aDocAtom.GetSlidesPageSize() ); 2689 Scale( aRet ); 2690 // PPT arbeitet nur mit Einheiten zu 576DPI. Um Ungenauigkeiten zu 2691 // vermeiden runde ich die letzte Nachkommastelle metrisch weg. 2692 if ( nMapMul > 2 * nMapDiv ) 2693 { 2694 MapUnit eMap = pSdrModel->GetScaleUnit(); 2695 bool bInch = IsInch( eMap ); 2696 long nInchMul = 1, nInchDiv = 1; 2697 if ( bInch ) 2698 { // Size temporaer (zum runden) in nach metric konvertieren 2699 Fraction aFact(GetMapFactor(eMap,MAP_100TH_MM).X()); 2700 nInchMul = aFact.GetNumerator(); 2701 nInchDiv = aFact.GetDenominator(); 2702 aRet.Width() = BigMulDiv( aRet.Width(), nInchMul, nInchDiv ); 2703 aRet.Height() = BigMulDiv( aRet.Height(), nInchMul, nInchDiv ); 2704 } 2705 aRet.Width() += 5; aRet.Width() /= 10; aRet.Width()*=10; 2706 aRet.Height() += 5; aRet.Height() /= 10; aRet.Height()*=10; 2707 if ( bInch ) 2708 { 2709 aRet.Width() = BigMulDiv( aRet.Width(), nInchDiv, nInchMul ); 2710 aRet.Height() = BigMulDiv( aRet.Height(), nInchDiv, nInchMul ); 2711 } 2712 } 2713 return aRet; 2714 } 2715 2716 FASTBOOL SdrPowerPointImport::GetColorFromPalette( sal_uInt16 nNum, Color& rColor ) const 2717 { 2718 if ( nPageColorsNum != nAktPageNum || ePageColorsKind != eAktPageKind ) 2719 { 2720 sal_uInt16 nSlideFlags = 0; 2721 PptSlidePersistList* pPageList = GetPageList( eAktPageKind ); 2722 if ( pPageList && ( nAktPageNum < pPageList->Count() ) ) 2723 { 2724 PptSlidePersistEntry* pE = (*pPageList)[ nAktPageNum ]; 2725 if ( pE ) 2726 nSlideFlags = pE->aSlideAtom.nFlags; 2727 if ( ! ( nSlideFlags & 2 ) ) 2728 ((SdrPowerPointImport*)this)->aPageColors = pE->aColorScheme; 2729 } 2730 if ( nSlideFlags & 2 ) // follow master colorscheme ? 2731 { 2732 PptSlidePersistList* pPageList2 = GetPageList( PPT_MASTERPAGE ); 2733 if ( pPageList2 ) 2734 { 2735 PptSlidePersistEntry* pMasterPersist = NULL; 2736 if ( eAktPageKind == PPT_MASTERPAGE ) 2737 pMasterPersist = (*pPageList2)[ nAktPageNum ]; 2738 else 2739 { 2740 if ( HasMasterPage( nAktPageNum, eAktPageKind ) ) 2741 { 2742 sal_uInt16 nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind ); 2743 if ( nMasterNum < pPageList2->Count() ) 2744 pMasterPersist = (*pPageList2)[ nMasterNum ]; 2745 } 2746 } 2747 if ( pMasterPersist ) 2748 { 2749 while( ( pMasterPersist && pMasterPersist->aSlideAtom.nFlags & 2 ) // it is possible that a masterpage 2750 && pMasterPersist->aSlideAtom.nMasterId ) // itself is following a master colorscheme 2751 { 2752 sal_uInt16 nNextMaster = pMasterPages->FindPage( pMasterPersist->aSlideAtom.nMasterId ); 2753 if ( nNextMaster == PPTSLIDEPERSIST_ENTRY_NOTFOUND ) 2754 break; 2755 else 2756 pMasterPersist = (*pPageList2)[ nNextMaster ]; 2757 } 2758 ((SdrPowerPointImport*)this)->aPageColors = pMasterPersist->aColorScheme; 2759 } 2760 } 2761 } 2762 // momentanes Farbschema eintragen 2763 ((SdrPowerPointImport*)this)->nPageColorsNum = nAktPageNum; 2764 ((SdrPowerPointImport*)this)->ePageColorsKind = eAktPageKind; 2765 } 2766 rColor = aPageColors.GetColor( nNum ); 2767 return sal_True; 2768 } 2769 2770 sal_Bool SdrPowerPointImport::SeekToShape( SvStream& rSt, void* pClientData, sal_uInt32 nId ) const 2771 { 2772 sal_Bool bRet = SvxMSDffManager::SeekToShape( rSt, pClientData, nId ); 2773 if ( !bRet ) 2774 { 2775 ProcessData& rData = *( (ProcessData*)pClientData ); 2776 PptSlidePersistEntry& rPersistEntry = rData.rPersistEntry; 2777 if ( rPersistEntry.ePageKind == PPT_SLIDEPAGE ) 2778 { 2779 if ( HasMasterPage( nAktPageNum, eAktPageKind ) ) 2780 { 2781 sal_uInt16 nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind ); 2782 PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE ); 2783 if ( pPageList && ( nMasterNum < pPageList->Count() ) ) 2784 { 2785 PptSlidePersistEntry* pPersist = (*pPageList)[ nMasterNum ]; // get the masterpage's persistentry 2786 if ( pPersist && pPersist->pPresentationObjects ) 2787 { 2788 sal_uInt32 nCurrent(0L); 2789 DffRecordList* pCList = maShapeRecords.pCList; // we got a backup of the current position 2790 if ( pCList ) 2791 nCurrent = pCList->nCurrent; 2792 if ( ((SdrEscherImport*)this )->maShapeRecords.SeekToContent( rSt, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) ) 2793 { 2794 sal_uInt32 nStreamPos = rSt.Tell(); 2795 PPTTextObj aTextObj( rSt, (SdrPowerPointImport&)*this, rPersistEntry, NULL ); 2796 if ( aTextObj.Count() || aTextObj.GetOEPlaceHolderAtom() ) 2797 { 2798 sal_uInt32 nShapePos = 0; 2799 switch ( aTextObj.GetInstance() ) 2800 { 2801 case TSS_TYPE_TITLE : 2802 nShapePos = pPersist->pPresentationObjects[ TSS_TYPE_PAGETITLE ]; 2803 break; 2804 case TSS_TYPE_PAGETITLE : 2805 nShapePos = pPersist->pPresentationObjects[ TSS_TYPE_PAGETITLE ]; 2806 break; 2807 case TSS_TYPE_SUBTITLE : 2808 case TSS_TYPE_HALFBODY : 2809 case TSS_TYPE_QUARTERBODY : 2810 case TSS_TYPE_BODY : 2811 nShapePos = pPersist->pPresentationObjects[ TSS_TYPE_BODY ]; 2812 break; 2813 // case TSS_TYPE_NOTES : 2814 // case TSS_TYPE_UNUSED : 2815 // case TSS_TYPE_TEXT_IN_SHAPE : 2816 } 2817 if ( nShapePos ) 2818 { 2819 rSt.Seek( nShapePos ); 2820 bRet = sal_True; 2821 } 2822 } 2823 if ( !bRet ) 2824 rSt.Seek( nStreamPos ); 2825 } 2826 if ( pCList ) // restoring 2827 pCList->nCurrent = nCurrent; 2828 ((SdrEscherImport*)this )->maShapeRecords.pCList = pCList; 2829 } 2830 } 2831 } 2832 } 2833 } 2834 return bRet; 2835 } 2836 2837 SdrPage* SdrPowerPointImport::MakeBlancPage( sal_Bool bMaster ) const 2838 { 2839 SdrPage* pRet = pSdrModel->AllocPage( bMaster ); 2840 pRet->SetSize( GetPageSize() ); 2841 2842 /* 2843 SJ (21.08.00) : since bug #77576# i decided not to set a border size. 2844 2845 Size aPageSize( aDocAtom.GetSlidesPageSize() ); // PageSize in 576DPI-Units 2846 long nHMarg = aPageSize.Width() - aDocAtom.aSlidesPageSize.Width(); 2847 long nVMarg = aPageSize.Height() - aDocAtom.aSlidesPageSize.Height(); 2848 if ( nHMarg > 0 ) 2849 { 2850 Scale( nHMarg ); 2851 pRet->SetLftBorder( nHMarg / 2 ); 2852 pRet->SetRgtBorder( nHMarg - nHMarg / 2 ); 2853 } 2854 if ( nVMarg > 0 ) 2855 { 2856 Scale( nVMarg ); 2857 pRet->SetUppBorder( nVMarg / 2 ); 2858 pRet->SetLwrBorder( nVMarg - nVMarg / 2 ); 2859 } 2860 */ 2861 return pRet; 2862 } 2863 2864 void ImportComment10( SvxMSDffManager& rMan, SvStream& rStCtrl, SdrPage* pPage, DffRecordHeader& rComment10Hd ) 2865 { 2866 rtl::OUString sAuthor; 2867 rtl::OUString sText; 2868 rtl::OUString sInitials; 2869 2870 sal_Int32 nIndex = 0; 2871 util::DateTime aDateTime; 2872 sal_Int32 nPosX = 0; 2873 sal_Int32 nPosY = 0; 2874 2875 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < rComment10Hd.GetRecEndFilePos() ) ) 2876 { 2877 DffRecordHeader aCommentHd; 2878 rStCtrl >> aCommentHd; 2879 switch( aCommentHd.nRecType ) 2880 { 2881 case PPT_PST_CString : 2882 { 2883 String aString; 2884 SvxMSDffManager::MSDFFReadZString( rStCtrl, aString, aCommentHd.nRecLen, sal_True ); 2885 switch ( aCommentHd.nRecInstance ) 2886 { 2887 case 0 : sAuthor = aString; break; 2888 case 1 : sText = aString; break; 2889 case 2 : sInitials = aString; break; 2890 } 2891 } 2892 break; 2893 2894 case PPT_PST_CommentAtom10 : 2895 { 2896 rStCtrl >> nIndex 2897 >> aDateTime.Year 2898 >> aDateTime.Month 2899 >> aDateTime.Day // DayOfWeek 2900 >> aDateTime.Day 2901 >> aDateTime.Hours 2902 >> aDateTime.Minutes 2903 >> aDateTime.Seconds 2904 >> aDateTime.HundredthSeconds 2905 >> nPosX 2906 >> nPosY; 2907 2908 aDateTime.HundredthSeconds /= 10; 2909 } 2910 break; 2911 } 2912 aCommentHd.SeekToEndOfRecord( rStCtrl ); 2913 } 2914 Point aPosition( nPosX, nPosY ); 2915 rMan.Scale( aPosition ); 2916 2917 try 2918 { 2919 uno::Reference< office::XAnnotationAccess > xAnnotationAccess( pPage->getUnoPage(), UNO_QUERY_THROW ); 2920 uno::Reference< office::XAnnotation > xAnnotation( xAnnotationAccess->createAndInsertAnnotation() ); 2921 xAnnotation->setPosition( geometry::RealPoint2D( aPosition.X() / 100.0, aPosition.Y() / 100.0 ) ); 2922 xAnnotation->setAuthor( sAuthor ); 2923 xAnnotation->setDateTime( aDateTime ); 2924 uno::Reference< text::XText > xText( xAnnotation->getTextRange() ); 2925 xText->setString( sText ); 2926 } 2927 catch( uno::Exception& ) 2928 { 2929 2930 } 2931 } 2932 2933 2934 // be sure not to import masterpages with this method 2935 // be sure not to import masterpages with this method 2936 void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry* pMasterPersist ) 2937 { 2938 sal_uInt32 nMerk = rStCtrl.Tell(); 2939 PptSlidePersistList* pList = GetPageList( eAktPageKind ); 2940 if ( ( !pList ) || ( pList->Count() <= nAktPageNum ) ) 2941 return; 2942 PptSlidePersistEntry& rSlidePersist = *(*pList)[ nAktPageNum ]; 2943 if ( rSlidePersist.bStarDrawFiller ) 2944 return; 2945 2946 DffRecordHeader aPageHd; 2947 if ( SeekToAktPage( &aPageHd ) ) 2948 { 2949 if ( mbTracing ) 2950 mpTracer->AddAttribute( eAktPageKind == PPT_SLIDEPAGE 2951 ? rtl::OUString::createFromAscii( "Page" ) 2952 : rtl::OUString::createFromAscii( "NotesPage" ), 2953 rtl::OUString::valueOf( (sal_Int32)nAktPageNum + 1 ) ); 2954 2955 rSlidePersist.pHeaderFooterEntry = new HeaderFooterEntry( pMasterPersist ); 2956 ProcessData aProcessData( rSlidePersist, (SdPage*)pRet ); 2957 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPageHd.GetRecEndFilePos() ) ) 2958 { 2959 DffRecordHeader aHd; 2960 rStCtrl >> aHd; 2961 switch ( aHd.nRecType ) 2962 { 2963 case PPT_PST_HeadersFooters : 2964 { 2965 ImportHeaderFooterContainer( aHd, *rSlidePersist.pHeaderFooterEntry ); 2966 } 2967 break; 2968 2969 case PPT_PST_ProgTags : 2970 { 2971 DffRecordHeader aContentDataHd; 2972 if ( SeekToContentOfProgTag( 10, rStCtrl, aHd, aContentDataHd ) ) 2973 { 2974 DffRecordHeader aComment10Hd; 2975 while( ( rStCtrl.GetError() == 0 ) && SeekToRec( rStCtrl, PPT_PST_Comment10, aContentDataHd.GetRecEndFilePos(), &aComment10Hd ) ) 2976 { 2977 ImportComment10( *this, rStCtrl, pRet, aComment10Hd ); 2978 aComment10Hd.SeekToEndOfRecord( rStCtrl ); 2979 } 2980 } 2981 } 2982 break; 2983 2984 case PPT_PST_PPDrawing : 2985 { 2986 DffRecordHeader aPPDrawHd; 2987 if ( SeekToRec( rStCtrl, DFF_msofbtDgContainer, aHd.GetRecEndFilePos(), &aPPDrawHd ) ) 2988 { 2989 sal_uInt32 nPPDrawOfs = rStCtrl.Tell(); 2990 2991 // importing the background object before importing the page 2992 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPPDrawHd.GetRecEndFilePos() ) ) 2993 { 2994 DffRecordHeader aEscherObjListHd; 2995 rStCtrl >> aEscherObjListHd; 2996 switch ( aEscherObjListHd.nRecType ) 2997 { 2998 case DFF_msofbtSpContainer : 2999 { 3000 Rectangle aPageSize( Point(), pRet->GetSize() ); 3001 if ( rSlidePersist.aSlideAtom.nFlags & 4 ) // follow master background ? 3002 { 3003 if ( HasMasterPage( nAktPageNum, eAktPageKind ) ) 3004 { 3005 sal_uInt16 nMasterNum = GetMasterPageIndex( nAktPageNum, eAktPageKind ); 3006 PptSlidePersistList* pPageList = GetPageList( PPT_MASTERPAGE ); 3007 PptSlidePersistEntry* pE = (*pPageList)[ nMasterNum ]; 3008 while( ( pE->aSlideAtom.nFlags & 4 ) && pE->aSlideAtom.nMasterId ) 3009 { 3010 sal_uInt16 nNextMaster = pMasterPages->FindPage( pE->aSlideAtom.nMasterId ); 3011 if ( nNextMaster == PPTSLIDEPERSIST_ENTRY_NOTFOUND ) 3012 break; 3013 else 3014 pE = (*pPageList)[ nNextMaster ]; 3015 } 3016 if ( pE->nBackgroundOffset ) 3017 { 3018 // do not follow master colorscheme ? 3019 sal_Bool bTemporary = ( rSlidePersist.aSlideAtom.nFlags & 2 ) != 0; 3020 sal_uInt32 nPos = rStCtrl.Tell(); 3021 rStCtrl.Seek( pE->nBackgroundOffset ); 3022 rSlidePersist.pBObj = ImportObj( rStCtrl, (void*)&aProcessData, aPageSize, aPageSize ); 3023 rSlidePersist.bBObjIsTemporary = bTemporary; 3024 rStCtrl.Seek( nPos ); 3025 } 3026 } 3027 } 3028 else 3029 { 3030 DffRecordHeader aShapeHd; 3031 rStCtrl >> aShapeHd; 3032 if ( aShapeHd.nRecType == DFF_msofbtSp ) 3033 { 3034 sal_uInt32 nSpFlags; 3035 rStCtrl >> nSpFlags >> nSpFlags; 3036 if ( nSpFlags & SP_FBACKGROUND ) 3037 { 3038 aEscherObjListHd.SeekToBegOfRecord( rStCtrl ); 3039 rSlidePersist.pBObj = ImportObj( rStCtrl, (void*)&aProcessData, aPageSize, aPageSize ); 3040 rSlidePersist.bBObjIsTemporary = sal_False; 3041 } 3042 } 3043 } 3044 } 3045 break; 3046 } 3047 if ( aEscherObjListHd.nRecType == DFF_msofbtSpContainer ) 3048 break; 3049 aEscherObjListHd.SeekToEndOfRecord( rStCtrl ); 3050 } 3051 3052 // now importing page 3053 rStCtrl.Seek( nPPDrawOfs ); 3054 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPPDrawHd.GetRecEndFilePos() ) ) 3055 { 3056 DffRecordHeader aEscherObjListHd; 3057 rStCtrl >> aEscherObjListHd; 3058 switch ( aEscherObjListHd.nRecType ) 3059 { 3060 case DFF_msofbtSpgrContainer : 3061 { 3062 DffRecordHeader aShapeHd; 3063 if ( SeekToRec( rStCtrl, DFF_msofbtSpContainer, aEscherObjListHd.GetRecEndFilePos(), &aShapeHd ) ) 3064 { 3065 aShapeHd.SeekToEndOfRecord( rStCtrl ); 3066 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aEscherObjListHd.GetRecEndFilePos() ) ) 3067 { 3068 rStCtrl >> aShapeHd; 3069 if ( ( aShapeHd.nRecType == DFF_msofbtSpContainer ) || ( aShapeHd.nRecType == DFF_msofbtSpgrContainer ) ) 3070 { 3071 Rectangle aEmpty; 3072 aShapeHd.SeekToBegOfRecord( rStCtrl ); 3073 sal_Int32 nShapeId; 3074 aProcessData.pTableRowProperties = NULL; 3075 SdrObject* pObj = ImportObj( rStCtrl, (void*)&aProcessData, aEmpty, aEmpty, 0, &nShapeId ); 3076 if ( pObj ) 3077 { 3078 if ( aProcessData.pTableRowProperties ) 3079 pObj = CreateTable( pObj, aProcessData.pTableRowProperties, aProcessData.rPersistEntry.pSolverContainer ); 3080 3081 pRet->NbcInsertObject( pObj ); 3082 3083 if( nShapeId ) 3084 insertShapeId( nShapeId, pObj ); 3085 } 3086 } 3087 aShapeHd.SeekToEndOfRecord( rStCtrl ); 3088 } 3089 } 3090 } 3091 break; 3092 } 3093 if ( aEscherObjListHd.nRecType == DFF_msofbtSpgrContainer ) 3094 break; 3095 aEscherObjListHd.SeekToEndOfRecord( rStCtrl ); 3096 } 3097 3098 /* There are a lot of Shapes who are dependent to 3099 the current background color */ 3100 if ( rSlidePersist.ePageKind == PPT_SLIDEPAGE ) 3101 { 3102 List* pList2 = aProcessData.pBackgroundColoredObjects; 3103 if ( pList2 ) 3104 { 3105 if ( rSlidePersist.pBObj ) 3106 { 3107 void* pPtr; 3108 const SfxPoolItem* pPoolItem = NULL; 3109 const SfxItemSet& rObjectItemSet = rSlidePersist.pBObj->GetMergedItemSet(); 3110 3111 //SfxItemState eState = rObjectItemSet.GetItemState( XATTR_FILLCOLOR, sal_False, &pPoolItem ); 3112 if ( pPoolItem ) 3113 { 3114 SfxItemSet aNewSet(*rObjectItemSet.GetPool()); 3115 aNewSet.Put(*pPoolItem); 3116 aNewSet.Put(XFillStyleItem( XFILL_SOLID )); 3117 3118 for ( pPtr = pList2->First(); pPtr; pPtr = pList2->Next() ) 3119 { 3120 ((SdrObject*)pPtr)->SetMergedItemSet(aNewSet); 3121 } 3122 } 3123 } 3124 } 3125 } 3126 if ( rSlidePersist.pBObj ) 3127 { 3128 // #i99386# transfer the attributes from the temporary BackgroundObject 3129 // to the Page and delete it. Maybe rSlidePersist.bBObjIsTemporary is 3130 // obsolete here, too. 3131 pRet->getSdrPageProperties().ClearItem(); 3132 pRet->getSdrPageProperties().PutItemSet(rSlidePersist.pBObj->GetMergedItemSet()); 3133 SdrObject::Free( rSlidePersist.pBObj ); 3134 } 3135 } 3136 } 3137 break; 3138 } 3139 aHd.SeekToEndOfRecord( rStCtrl ); 3140 } 3141 if ( rSlidePersist.pSolverContainer ) 3142 SolveSolver( *rSlidePersist.pSolverContainer ); 3143 if ( mbTracing ) 3144 mpTracer->RemoveAttribute( eAktPageKind == PPT_SLIDEPAGE 3145 ? rtl::OUString::createFromAscii( "Page" ) 3146 : rtl::OUString::createFromAscii( "NotesPage" ) ); 3147 } 3148 rStCtrl.Seek( nMerk ); 3149 } 3150 3151 const PptSlideLayoutAtom* SdrPowerPointImport::GetSlideLayoutAtom() const 3152 { 3153 PptSlidePersistList* pPageList = GetPageList( eAktPageKind ); 3154 if ( pPageList && nAktPageNum < pPageList->Count() ) 3155 { 3156 PptSlidePersistEntry* pE = (*pPageList)[ nAktPageNum ]; 3157 if ( pE ) 3158 return &pE->aSlideAtom.aLayout; 3159 } 3160 return NULL; 3161 } 3162 3163 sal_Bool SdrPowerPointImport::IsNoteOrHandout( sal_uInt16 nPageNum, PptPageKind /*ePageKind*/) const 3164 { 3165 sal_Bool bNote = eAktPageKind == PPT_NOTEPAGE; 3166 if ( eAktPageKind == PPT_MASTERPAGE ) 3167 bNote = ( nPageNum & 1 ) == 0; 3168 return bNote; 3169 } 3170 3171 sal_uInt32 SdrPowerPointImport::GetMasterPageId( sal_uInt16 nPageNum, PptPageKind ePageKind ) const 3172 { 3173 PptSlidePersistList* pPageList = GetPageList( ePageKind ); 3174 if ( pPageList && nPageNum < pPageList->Count() ) 3175 return (*pPageList)[ nPageNum ]->aSlideAtom.nMasterId; 3176 return 0; 3177 } 3178 3179 sal_uInt32 SdrPowerPointImport::GetNotesPageId( sal_uInt16 nPageNum ) const 3180 { 3181 PptSlidePersistList* pPageList=GetPageList( PPT_SLIDEPAGE ); 3182 if ( pPageList && nPageNum < pPageList->Count() ) 3183 return (*pPageList)[ nPageNum ]->aSlideAtom.nNotesId; 3184 return 0; 3185 } 3186 3187 sal_Bool SdrPowerPointImport::HasMasterPage( sal_uInt16 nPageNum, PptPageKind ePageKind ) const 3188 { 3189 if ( ePageKind == PPT_NOTEPAGE ) 3190 return aDocAtom.nNotesMasterPersist != 0; 3191 if ( ePageKind == PPT_MASTERPAGE ) 3192 return sal_False; 3193 return GetMasterPageId( nPageNum, ePageKind ) != 0; 3194 } 3195 3196 sal_uInt16 SdrPowerPointImport::GetMasterPageIndex( sal_uInt16 nPageNum, PptPageKind ePageKind ) const 3197 { 3198 sal_uInt16 nIdx = 0; 3199 if ( ePageKind == PPT_NOTEPAGE ) 3200 return 2; 3201 sal_uInt32 nId = GetMasterPageId( nPageNum, ePageKind ); 3202 if ( nId && pMasterPages ) 3203 { 3204 nIdx = pMasterPages->FindPage( nId ); 3205 if ( nIdx == PPTSLIDEPERSIST_ENTRY_NOTFOUND ) 3206 nIdx = 0; 3207 } 3208 return nIdx; 3209 } 3210 3211 SdrObject* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage, sal_uInt32& nBgFileOffset, sal_Bool bForce ) 3212 { 3213 SdrObject* pRet = NULL; 3214 sal_Bool bCreateObj = bForce; 3215 SfxItemSet* pSet = NULL; 3216 sal_uLong nFPosMerk = rStCtrl.Tell(); // FilePos merken fuer spaetere Restauration 3217 DffRecordHeader aPageHd; 3218 if ( SeekToAktPage( &aPageHd ) ) 3219 { // und nun die Hintergrundattribute der Page suchen 3220 sal_uLong nPageRecEnd = aPageHd.GetRecEndFilePos(); 3221 DffRecordHeader aPPDrawHd; 3222 if ( SeekToRec( rStCtrl, PPT_PST_PPDrawing, nPageRecEnd, &aPPDrawHd ) ) 3223 { 3224 sal_uLong nPPDrawEnd = aPPDrawHd.GetRecEndFilePos(); 3225 DffRecordHeader aEscherF002Hd; 3226 if ( SeekToRec( rStCtrl, DFF_msofbtDgContainer, nPPDrawEnd, &aEscherF002Hd ) ) 3227 { 3228 sal_uLong nEscherF002End = aEscherF002Hd.GetRecEndFilePos(); 3229 DffRecordHeader aEscherObjectHd; 3230 if ( SeekToRec( rStCtrl, DFF_msofbtSpContainer, nEscherF002End, &aEscherObjectHd ) ) 3231 { 3232 nBgFileOffset = aEscherObjectHd.GetRecBegFilePos(); 3233 //sal_uLong nEscherObjectEnd = aEscherObjectHd.GetRecEndFilePos(); 3234 //DffRecordHeader aEscherPropertiesHd; 3235 if ( SeekToRec( rStCtrl, DFF_msofbtOPT,nEscherF002End ) ) 3236 { 3237 rStCtrl >> (DffPropertyReader&)*this; 3238 mnFix16Angle = Fix16ToAngle( GetPropertyValue( DFF_Prop_Rotation, 0 ) ); 3239 sal_uInt32 nColor = GetPropertyValue( DFF_Prop_fillColor, 0xffffff ); 3240 pSet = new SfxItemSet( pSdrModel->GetItemPool() ); 3241 DffObjData aObjData( aEscherObjectHd, Rectangle( 0, 0, 28000, 21000 ), 0 ); 3242 ApplyAttributes( rStCtrl, *pSet, aObjData ); 3243 Color aColor( MSO_CLR_ToColor( nColor ) ); 3244 pSet->Put( XFillColorItem( String(), aColor ) ); 3245 } 3246 } 3247 } 3248 } 3249 } 3250 rStCtrl.Seek( nFPosMerk ); // FilePos restaurieren 3251 if ( bCreateObj ) 3252 { 3253 if ( !pSet ) 3254 { 3255 pSet = new SfxItemSet( pSdrModel->GetItemPool() ); 3256 pSet->Put( XFillStyleItem( XFILL_NONE ) ); 3257 } 3258 pSet->Put( XLineStyleItem( XLINE_NONE ) ); 3259 Rectangle aRect( rPage.GetLftBorder(), rPage.GetUppBorder(), rPage.GetWdt()-rPage.GetRgtBorder(), rPage.GetHgt()-rPage.GetLwrBorder() ); 3260 pRet = new SdrRectObj( aRect ); 3261 pRet->SetModel( pSdrModel ); 3262 3263 pRet->SetMergedItemSet(*pSet); 3264 3265 pRet->SetMarkProtect( sal_True ); 3266 pRet->SetMoveProtect( sal_True ); 3267 pRet->SetResizeProtect( sal_True ); 3268 } 3269 delete pSet; 3270 return pRet; 3271 } 3272 3273 //////////////////////////////////////////////////////////////////////////////////////////////////// 3274 3275 HeaderFooterEntry::HeaderFooterEntry( const PptSlidePersistEntry* pMPE ) : 3276 pMasterPersist ( pMPE ), 3277 nAtom ( 0 ) 3278 { 3279 if ( pMPE ) 3280 { 3281 HeaderFooterEntry* pMHFE = pMPE->pHeaderFooterEntry; 3282 if ( pMHFE ) 3283 { 3284 nAtom = pMPE->pHeaderFooterEntry->nAtom; 3285 pPlaceholder[ 0 ] = pMHFE->pPlaceholder[ 0 ]; 3286 pPlaceholder[ 1 ] = pMHFE->pPlaceholder[ 1 ]; 3287 pPlaceholder[ 2 ] = pMHFE->pPlaceholder[ 2 ]; 3288 pPlaceholder[ 3 ] = pMHFE->pPlaceholder[ 3 ]; 3289 } 3290 } 3291 } 3292 3293 HeaderFooterEntry::~HeaderFooterEntry() 3294 { 3295 } 3296 3297 sal_uInt32 HeaderFooterEntry::GetMaskForInstance( sal_uInt32 nInstance ) 3298 { 3299 sal_uInt32 nRet = 0; 3300 switch ( nInstance ) 3301 { 3302 case 0 : nRet = 0x07ffff; break; 3303 case 1 : nRet = 0x100000; break; 3304 case 2 : nRet = 0x200000; break; 3305 case 3 : nRet = 0x080000; break; 3306 } 3307 return nRet; 3308 } 3309 3310 sal_uInt32 HeaderFooterEntry::IsToDisplay( sal_uInt32 nInstance ) 3311 { 3312 sal_uInt32 nMask = 0; 3313 switch ( nInstance ) 3314 { 3315 case 0 : nMask = 0x010000; break; 3316 case 1 : nMask = 0x100000; break; 3317 case 2 : nMask = 0x200000; break; 3318 case 3 : nMask = 0x080000; break; 3319 } 3320 return ( nAtom & nMask ); 3321 } 3322 3323 // The following method checks if the slide is using a different colorscheme than 3324 // its master, if this is the fact, then the HeaderFooter must probably be 3325 // imported as real sdrobject. In this case, the return value is the offset to the 3326 // master header footer object, so it can be re-loaded with a different color set 3327 sal_uInt32 HeaderFooterEntry::NeedToImportInstance( const sal_uInt32 nInstance, const PptSlidePersistEntry& rSlidePersist ) 3328 { 3329 sal_uInt32 nRet = 0; 3330 if ( pMasterPersist ) 3331 { 3332 if ( !( rSlidePersist.aSlideAtom.nFlags & 2 ) ) 3333 { // not following the master persist, so we have to check if the colors are changed 3334 if ( memcmp( &rSlidePersist.aColorScheme, &pMasterPersist->aColorScheme, 32 ) ) 3335 { 3336 nRet = pMasterPersist->HeaderFooterOfs[ nInstance ]; 3337 } 3338 } 3339 } 3340 return nRet; 3341 } 3342 3343 void SdrEscherImport::ImportHeaderFooterContainer( DffRecordHeader& rHd, HeaderFooterEntry& rE ) 3344 { 3345 rHd.SeekToContent( rStCtrl ); 3346 while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < rHd.GetRecEndFilePos() ) ) 3347 { 3348 DffRecordHeader aHd; 3349 rStCtrl >> aHd; 3350 switch ( aHd.nRecType ) 3351 { 3352 case PPT_PST_HeadersFootersAtom : 3353 rStCtrl >> rE.nAtom; 3354 break; 3355 3356 case PPT_PST_CString : 3357 { 3358 if ( aHd.nRecInstance < 4 ) 3359 MSDFFReadZString( rStCtrl, rE.pPlaceholder[ aHd.nRecInstance ], aHd.nRecLen, sal_True ); 3360 } 3361 break; 3362 } 3363 aHd.SeekToEndOfRecord( rStCtrl ); 3364 } 3365 } 3366 3367 //static sal_Unicode PPTExportMapper( sal_Unicode nUni, sal_Bool& bNeedsStarBats ) 3368 //{ 3369 // bNeedsStarBats = sal_False; 3370 // 3371 // sal_Unicode cLo, cReplace; 3372 // cLo = cReplace = 0; 3373 // switch ( nUni ) 3374 // { 3375 // case 132 : cLo = 175; break; 3376 // case 147 : cLo = 174; break; 3377 // // Currency 3378 // case 0x00A2: cReplace = 224; break; 3379 // case 0x00A4: cReplace = 225; break; 3380 // case 0x00A5: cReplace = 226; break; 3381 // case 0x20A1: cReplace = 228; break; 3382 // case 0x20A2: cReplace = 229; break; 3383 // case 0x20A3: cReplace = 230; break; 3384 // case 0x20A4: cReplace = 231; break; 3385 // case 0x20A7: cReplace = 227; break; 3386 // case 0x20A8: cReplace = 234; break; 3387 // case 0x20A9: cReplace = 232; break; 3388 // case 0x20AB: cReplace = 233; break; 3389 // case 0x20AC: cReplace = 128; break; 3390 // // Punctuation and other 3391 // case 0x201A: cReplace = 130; break; // SINGLE LOW-9 QUOTATION MARK 3392 // case 0x0192: cReplace = 131; break; // LATIN SMALL LETTER F WITH HOOK 3393 // case 0x201E: // DOUBLE LOW-9 QUOTATION MARK 3394 // case 0x301F: // LOW DOUBLE PRIME QUOTATION MARK 3395 // cReplace = 132; break; 3396 // case 0x2026: cReplace = 133; break; // HORIZONTAL ELLIPSES 3397 // case 0x2020: cReplace = 134; break; // DAGGER 3398 // case 0x2021: cReplace = 135; break; // DOUBLE DAGGER 3399 // case 0x02C6: cReplace = 136; break; // MODIFIER LETTER CIRCUMFLEX ACCENT 3400 // case 0x2030: cReplace = 137; break; // PER MILLE SIGN 3401 // case 0x0160: cReplace = 138; break; // LATIN CAPITAL LETTER S WITH CARON 3402 // case 0x2039: cReplace = 139; break; // SINGLE LEFT-POINTING ANGLE QUOTATION MARK 3403 // case 0x0152: cReplace = 140; break; // LATIN CAPITAL LIGATURE OE 3404 // case 0x017D: cReplace = 142; break; // LATIN CAPITAL LETTER Z WITH CARON 3405 // case 0x2018: // LEFT SINGLE QUOTATION MARK 3406 // case 0x02BB: // MODIFIER LETTER TURNED COMMA 3407 // cReplace = 145; break; 3408 // case 0x2019: // RIGHT SINGLE QUOTATION MARK 3409 // case 0x02BC: // MODIFIER LETTER APOSTROPHE 3410 // cReplace = 146; break; 3411 // case 0x201C: // LEFT DOUBLE QUOTATION MARK 3412 // case 0x301D: // REVERSED DOUBLE PRIME QUOTATION MARK 3413 // cReplace = 147; break; 3414 // case 0x201D: // RIGHT DOUBLE QUOTATION MARK 3415 // case 0x301E: // REVERSED DOUBLE PRIME QUOTATION MARK 3416 // cReplace = 148; break; 3417 // case 0x2022: cReplace = 149; break; // BULLET 3418 // case 0x2013: cReplace = 150; break; // EN DASH 3419 // case 0x2014: cReplace = 151; break; // EM DASH 3420 // case 0x02DC: cReplace = 152; break; // SMALL TILDE 3421 // case 0x2122: cReplace = 153; break; // TRADE MARK SIGN 3422 // case 0x0161: cReplace = 154; break; // LATIN SMALL LETTER S WITH CARON 3423 // case 0x203A: cReplace = 155; break; // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK 3424 // case 0x0153: cReplace = 156; break; // LATIN SMALL LIGATURE OE 3425 // case 0x017E: cReplace = 158; break; // LATIN SMALL LETTER Z WITH CARON 3426 // case 0x0178: cReplace = 159; break; // LATIN CAPITAL LETTER Y WITH DIAERESIS 3427 // case 0x00B6: cReplace = 222; break; // PILCROW SIGN / PARAGRAPH SIGN 3428 // } 3429 // if ( cReplace ) 3430 // { 3431 // bNeedsStarBats = sal_True; 3432 // return cReplace; 3433 // } 3434 // else 3435 // return cLo; 3436 //} 3437 3438 // no longer needed 3439 sal_Unicode SdrPowerPointImport::PPTSubstitute( sal_uInt16 /*nFont*/, sal_Unicode /*nChar*/, 3440 sal_uInt32& /*nMappedFontId*/, Font& /*rFont*/, char /*nDefault*/) const 3441 { 3442 return 0; 3443 } 3444 3445 //////////////////////////////////////////////////////////////////////////////////////////////////// 3446 3447 PPTBuGraEntry::PPTBuGraEntry( Graphic& rGraphic, sal_uInt32 nInst ) : 3448 nInstance ( nInst ), 3449 aBuGra ( rGraphic ) {} 3450 3451 PPTExtParaLevel::PPTExtParaLevel() 3452 : mnExtParagraphMask( 0 ) 3453 , mnBuBlip( 0xffff ) 3454 , mnHasAnm( 0 ) 3455 , mnAnmScheme( 0 ) 3456 , mpfPP10Ext( 0 ) 3457 , mnExtCharacterMask( 0 ) 3458 , mcfPP10Ext( 0 ) 3459 , mbSet( sal_False ) 3460 {} 3461 3462 SvStream& operator>>( SvStream& rIn, PPTExtParaLevel& rLevel ) 3463 { 3464 rLevel.mbSet = sal_True; 3465 rIn >> rLevel.mnExtParagraphMask; 3466 if ( rLevel.mnExtParagraphMask & 0x00800000 ) 3467 rIn >> rLevel.mnBuBlip; 3468 if ( rLevel.mnExtParagraphMask & 0x02000000 ) 3469 rIn >> rLevel.mnHasAnm; 3470 if ( rLevel.mnExtParagraphMask & 0x01000000 ) 3471 rIn >> rLevel.mnAnmScheme; 3472 if ( rLevel.mnExtParagraphMask & 0x04000000 ) 3473 rIn >> rLevel.mpfPP10Ext; 3474 rIn >> rLevel.mnExtCharacterMask; 3475 if ( rLevel.mnExtCharacterMask & 0x100000 ) 3476 rIn >> rLevel.mcfPP10Ext; 3477 return rIn; 3478 } 3479 3480 sal_Bool PPTExtParaProv::GetGraphic( sal_uInt32 nInstance, Graphic& rGraph ) const 3481 { 3482 sal_Bool bRetValue = sal_False; 3483 PPTBuGraEntry* pPtr = NULL; 3484 if ( nInstance < aBuGraList.Count() ) 3485 { 3486 pPtr = (PPTBuGraEntry*)aBuGraList.GetObject( nInstance ); 3487 if ( pPtr->nInstance == nInstance ) 3488 bRetValue = sal_True; 3489 } 3490 if ( !bRetValue ) 3491 { 3492 sal_uInt32 i; 3493 for ( i = 0; i < aBuGraList.Count(); i++ ) 3494 { 3495 pPtr = (PPTBuGraEntry*)aBuGraList.GetObject( i ); 3496 if ( pPtr->nInstance == nInstance ) 3497 { 3498 bRetValue = sal_True; 3499 break; 3500 } 3501 } 3502 } 3503 if ( bRetValue ) 3504 rGraph = pPtr->aBuGra; 3505 return bRetValue; 3506 } 3507 3508 PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const DffRecordHeader* pHd ) : 3509 bStyles ( sal_False ), 3510 bGraphics ( sal_False ) 3511 { 3512 sal_uInt32 nOldPos = rSt.Tell(); 3513 3514 // here we have to get the graphical bullets... 3515 3516 DffRecordHeader aHd; 3517 DffRecordHeader aContentDataHd; 3518 3519 const DffRecordHeader* pListHd = rMan.aDocRecManager.GetRecordHeader( PPT_PST_List, SEEK_FROM_BEGINNING ); 3520 while( pListHd ) 3521 { 3522 pListHd->SeekToContent( rSt ); 3523 if ( !rMan.SeekToContentOfProgTag( 9, rSt, *pListHd, aContentDataHd ) ) 3524 break; 3525 while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aContentDataHd.GetRecEndFilePos() ) ) 3526 { 3527 rSt >> aHd; 3528 switch ( aHd.nRecType ) 3529 { 3530 case PPT_PST_ExtendedBuGraContainer : 3531 { 3532 while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aHd.GetRecEndFilePos() ) ) 3533 { 3534 sal_uInt16 nType; 3535 DffRecordHeader aBuGraAtomHd; 3536 rSt >> aBuGraAtomHd; 3537 if ( aBuGraAtomHd.nRecType == PPT_PST_ExtendedBuGraAtom ) 3538 { 3539 rSt >> nType; 3540 Graphic aGraphic; 3541 if ( rMan.GetBLIPDirect( rSt, aGraphic, NULL ) ) 3542 { 3543 sal_uInt32 nInstance = aBuGraAtomHd.nRecInstance; 3544 PPTBuGraEntry* pBuGra = new PPTBuGraEntry( aGraphic, nInstance ); 3545 sal_uInt32 n = 0; 3546 sal_uInt32 nBuGraCount = aBuGraList.Count(); 3547 if ( nBuGraCount ) 3548 { 3549 if ( ( (PPTBuGraEntry*)aBuGraList.GetObject( nBuGraCount - 1 ) )->nInstance < nInstance ) 3550 n = nBuGraCount; 3551 else 3552 { // maybe the instances are not sorted, we sort it 3553 for ( n = 0; n < nBuGraCount; n++ ) 3554 { // sorting fields ( hi >> lo ) 3555 if ( ( (PPTBuGraEntry*)aBuGraList.GetObject( n ) )->nInstance < nInstance ) 3556 break; 3557 } 3558 } 3559 } 3560 aBuGraList.Insert( pBuGra, (sal_uInt32)n ); 3561 } 3562 #ifdef DBG_UTIL 3563 else DBG_ERROR( "PPTExParaProv::PPTExParaProv - bullet graphic is not valid (SJ)" ); 3564 #endif 3565 } 3566 #ifdef DBG_UTIL 3567 else DBG_ERROR( "PPTExParaProv::PPTExParaProv - unknown atom interpreting the PPT_PST_ExtendedBuGraContainer (SJ)" ); 3568 #endif 3569 aBuGraAtomHd.SeekToEndOfRecord( rSt ); 3570 } 3571 if ( aBuGraList.Count() ) 3572 bGraphics = sal_True; 3573 } 3574 break; 3575 3576 case PPT_PST_ExtendedPresRuleContainer : 3577 aExtendedPresRules.Consume( rSt, sal_False, aHd.GetRecEndFilePos() ); 3578 break; 3579 #ifdef DBG_UTIL 3580 default : 3581 DBG_ERROR( "PPTExParaProv::PPTExParaProv - unknown atom reading ppt2000 num rules (SJ)" ); 3582 case PPT_PST_MasterText : // first seen in: ms-tt02.ppt 3583 case PPT_PST_SrKinsoku : 3584 case PPT_PST_NewlyAddedAtom4016 : 3585 case PPT_PST_NewlyAddedAtomByPPT2000_6010 : 3586 case PPT_PST_NewlyAddedAtomByPPT2000_6011 : 3587 case PPT_PST_NewlyAddedAtomByXP1037 : 3588 case PPT_PST_NewlyAddedAtomByXP12004 : 3589 case PPT_PST_NewlyAddedAtomByXP14001 : 3590 break; 3591 #endif 3592 } 3593 aHd.SeekToEndOfRecord( rSt ); 3594 } 3595 break; 3596 } 3597 3598 while( pHd ) 3599 { // get the extended paragraph styles on mainmaster ( graphical bullets, num ruling ... ) 3600 if ( !rMan.SeekToContentOfProgTag( 9, rSt, *pHd, aContentDataHd ) ) 3601 break; 3602 while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aContentDataHd.GetRecEndFilePos() ) ) 3603 { 3604 rSt >> aHd; 3605 switch ( aHd.nRecType ) 3606 { 3607 case PPT_PST_ExtendedParagraphMasterAtom : 3608 { 3609 if ( aHd.nRecInstance < PPT_STYLESHEETENTRYS ) 3610 { 3611 sal_uInt16 nDepth, i = 0; 3612 rSt >> nDepth; 3613 if ( i <= 5 ) 3614 { 3615 3616 while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < aHd.GetRecEndFilePos() ) && ( i < nDepth ) ) 3617 { 3618 bStyles = sal_True; 3619 rSt >> aExtParaSheet[ aHd.nRecInstance ].aExtParaLevel[ i++ ]; 3620 } 3621 #ifdef DBG_UTIL 3622 if ( rSt.Tell() != aHd.GetRecEndFilePos() ) 3623 DBG_ERROR( "PPTExParaProv::PPTExParaProv - error reading PPT_PST_ExtendedParagraphMasterAtom (SJ)" ); 3624 #endif 3625 } 3626 #ifdef DBG_UTIL 3627 else DBG_ERROR( "PPTExParaProv::PPTExParaProv - depth is greater than 5 (SJ)" ); 3628 #endif 3629 } 3630 #ifdef DBG_UTIL 3631 else DBG_ERROR( "PPTExParaProv::PPTExParaProv - instance out of range (SJ)" ); 3632 #endif 3633 } 3634 break; 3635 default : 3636 DBG_ERROR( "PPTExParaProv::PPTExParaProv - unknown atom, assuming PPT_PST_ExtendedParagraphMasterAtom (SJ)" ); 3637 case PPT_PST_NewlyAddedAtomByXP11008 : 3638 case PPT_PST_NewlyAddedAtomByXP11010 : 3639 case PPT_PST_NewlyAddedAtomByXP12010 : 3640 case PPT_PST_NewlyAddedAtomByXP12011 : 3641 case 0xf144 : 3642 break; 3643 } 3644 aHd.SeekToEndOfRecord( rSt ); 3645 } 3646 break; 3647 } 3648 rSt.Seek( nOldPos ); 3649 } 3650 3651 PPTExtParaProv::~PPTExtParaProv() 3652 { 3653 void* pPtr; 3654 for ( pPtr = aBuGraList.First(); pPtr; pPtr = aBuGraList.Next() ) 3655 delete (PPTBuGraEntry*)pPtr; 3656 } 3657 3658 //////////////////////////////////////////////////////////////////////////////////////////////////// 3659 3660 PPTNumberFormatCreator::PPTNumberFormatCreator( PPTExtParaProv* pParaProv ) : 3661 pExtParaProv ( pParaProv ) 3662 { 3663 } 3664 3665 PPTNumberFormatCreator::~PPTNumberFormatCreator() 3666 { 3667 delete pExtParaProv; 3668 } 3669 3670 sal_Bool PPTNumberFormatCreator::ImplGetExtNumberFormat( SdrPowerPointImport& rManager, 3671 SvxNumberFormat& rNumberFormat, sal_uInt32 nLevel, sal_uInt32 nInstance, sal_uInt32 nDestinationInstance, 3672 boost::optional< sal_Int16 >& rStartNumbering, sal_uInt32 nFontHeight, PPTParagraphObj* pPara ) 3673 { 3674 sal_Bool bHardAttribute = ( nDestinationInstance == 0xffffffff ); 3675 3676 sal_uInt32 nBuFlags = 0; 3677 sal_uInt16 nHasAnm = 0; 3678 sal_uInt32 nAnmScheme = 0x10003; 3679 sal_uInt16 nBuBlip = 0xffff; 3680 3681 const PPTExtParaProv* pParaProv = pExtParaProv; 3682 if ( !pExtParaProv ) 3683 pParaProv = ( pPara ) ? pPara->mrStyleSheet.pExtParaProv 3684 : rManager.pPPTStyleSheet->pExtParaProv; 3685 if ( pPara ) 3686 { 3687 nBuFlags = pPara->pParaSet->mnExtParagraphMask; 3688 if ( nBuFlags ) 3689 { 3690 if ( nBuFlags & 0x00800000 ) 3691 nBuBlip = pPara->pParaSet->mnBuBlip; 3692 if ( nBuFlags & 0x01000000 ) 3693 nAnmScheme = pPara->pParaSet->mnAnmScheme; 3694 if ( nBuFlags & 0x02000000 ) 3695 nHasAnm = pPara->pParaSet->mnHasAnm; 3696 bHardAttribute = sal_True; 3697 } 3698 } 3699 3700 if ( ( nBuFlags & 0x03800000 ) != 0x03800000 ) // merge style sheet 3701 { // we have to read the master attributes 3702 if ( pParaProv && ( nLevel < 5 ) ) 3703 { 3704 if ( pParaProv->bStyles ) 3705 { 3706 const PPTExtParaLevel& rLev = pParaProv->aExtParaSheet[ nInstance ].aExtParaLevel[ nLevel ]; 3707 if ( rLev.mbSet ) 3708 { 3709 sal_uInt32 nMaBuFlags = rLev.mnExtParagraphMask; 3710 3711 if ( (!( nBuFlags & 0x00800000)) && ( nMaBuFlags & 0x00800000 ) ) 3712 { 3713 if (!( nBuFlags & 0x02000000)) // if there is a BuStart without BuInstance, 3714 nBuBlip = rLev.mnBuBlip; // then there is no graphical Bullet possible 3715 } 3716 if ( (!( nBuFlags & 0x01000000)) && ( nMaBuFlags & 0x01000000 ) ) 3717 nAnmScheme = rLev.mnAnmScheme; 3718 if ( (!( nBuFlags & 0x02000000)) && ( nMaBuFlags & 0x02000000 ) ) 3719 nHasAnm = rLev.mnHasAnm; 3720 nBuFlags |= nMaBuFlags; 3721 } 3722 } 3723 } 3724 } 3725 if ( nBuBlip != 0xffff ) // set graphical bullet 3726 { 3727 Graphic aGraphic; 3728 if ( pParaProv->GetGraphic( nBuBlip, aGraphic ) ) 3729 { 3730 SvxBrushItem aBrush( aGraphic, GPOS_MM, SID_ATTR_BRUSH ); 3731 rNumberFormat.SetGraphicBrush( &aBrush ); 3732 sal_uInt32 nHeight = (sal_uInt32)( (double)nFontHeight * 0.2540 * nBulletHeight + 0.5 ); 3733 Size aPrefSize( aGraphic.GetPrefSize() ); 3734 sal_uInt32 nWidth = ( nHeight * aPrefSize.Width() ) / aPrefSize.Height(); 3735 rNumberFormat.SetGraphicSize( Size( nWidth, nHeight ) ); 3736 rNumberFormat.SetNumberingType ( SVX_NUM_BITMAP ); 3737 } 3738 } 3739 else if ( nHasAnm ) 3740 { 3741 switch( static_cast< sal_uInt16 >( nAnmScheme ) ) 3742 { 3743 default : 3744 case 0 : 3745 { 3746 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER ); 3747 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ); 3748 } 3749 break; 3750 case 1 : 3751 { 3752 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER ); 3753 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ); 3754 } 3755 break; 3756 case 2 : 3757 { 3758 rNumberFormat.SetNumberingType( SVX_NUM_ARABIC ); 3759 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) ); 3760 } 3761 break; 3762 case 3 : 3763 { 3764 rNumberFormat.SetNumberingType( SVX_NUM_ARABIC ); 3765 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ); 3766 } 3767 break; 3768 case 4 : 3769 { 3770 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_LOWER ); 3771 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) ); 3772 rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) ); 3773 } 3774 break; 3775 case 5 : 3776 { 3777 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_LOWER ); 3778 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) ); 3779 } 3780 break; 3781 case 6 : 3782 { 3783 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_LOWER ); 3784 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ); 3785 } 3786 break; 3787 case 7 : 3788 { 3789 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_UPPER ); 3790 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ); 3791 } 3792 break; 3793 case 8 : 3794 { 3795 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER ); 3796 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) ); 3797 rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) ); 3798 } 3799 break; 3800 case 9 : 3801 { 3802 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_LOWER_LETTER ); 3803 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) ); 3804 } 3805 break; 3806 case 10 : 3807 { 3808 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER ); 3809 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) ); 3810 rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) ); 3811 } 3812 break; 3813 case 11 : 3814 { 3815 rNumberFormat.SetNumberingType( SVX_NUM_CHARS_UPPER_LETTER ); 3816 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) ); 3817 } 3818 break; 3819 case 12 : 3820 { 3821 rNumberFormat.SetNumberingType( SVX_NUM_ARABIC ); 3822 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) ); 3823 rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) ); 3824 } 3825 break; 3826 case 13 : 3827 { 3828 rNumberFormat.SetNumberingType( SVX_NUM_ARABIC ); 3829 } 3830 break; 3831 case 14 : 3832 { 3833 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_UPPER ); 3834 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) ); 3835 rNumberFormat.SetPrefix( String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) ); 3836 } 3837 break; 3838 case 15 : 3839 { 3840 rNumberFormat.SetNumberingType( SVX_NUM_ROMAN_UPPER ); 3841 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) ); 3842 } 3843 break; 3844 case 16: // Simplified Chinese. 3845 { 3846 rNumberFormat.SetNumberingType( SVX_NUM_NUMBER_UPPER_ZH ); 3847 } 3848 break; 3849 case 17: // Simplified Chinese with single-byte period. 3850 { 3851 rNumberFormat.SetNumberingType( SVX_NUM_NUMBER_UPPER_ZH ); 3852 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ); 3853 } 3854 break; 3855 case 18: // Double byte circle numbers. 3856 case 19: // Wingdings white circle numbers. 3857 case 20: // Wingdings black circle numbers. 3858 { 3859 rNumberFormat.SetNumberingType( SVX_NUM_CIRCLE_NUMBER ); 3860 } 3861 break; 3862 case 21: // Traditional Chinese. 3863 { 3864 rNumberFormat.SetNumberingType( SVX_NUM_NUMBER_UPPER_ZH_TW ); 3865 } 3866 break; 3867 case 22: // Traditional Chinese with single-byte period. 3868 { 3869 rNumberFormat.SetNumberingType( SVX_NUM_NUMBER_UPPER_ZH_TW ); 3870 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ); 3871 } 3872 break; 3873 case 26: // Japanese/Korean. 3874 { 3875 rNumberFormat.SetNumberingType( SVX_NUM_NUMBER_LOWER_ZH ); 3876 } 3877 break; 3878 case 27: // Japanese/Korean with single-byte period. 3879 { 3880 rNumberFormat.SetNumberingType( SVX_NUM_NUMBER_LOWER_ZH ); 3881 rNumberFormat.SetSuffix( String( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ); 3882 } 3883 break; 3884 case 28: // Double-byte Arabic numbers. 3885 { 3886 rNumberFormat.SetNumberingType( SVX_NUM_FULL_WIDTH_ARABIC ); 3887 } 3888 break; 3889 case 29: // Double-byte Arabic numbers with double-byte period. 3890 { 3891 rNumberFormat.SetNumberingType( SVX_NUM_FULL_WIDTH_ARABIC ); 3892 rNumberFormat.SetSuffix( String( sal_Unicode(0xff0e) ) ); 3893 } 3894 break; 3895 case 38: // Japanese with double-byte period. 3896 { 3897 rNumberFormat.SetNumberingType( SVX_NUM_NUMBER_LOWER_ZH ); // No such type. Instead with Lower Chinese Number 3898 rNumberFormat.SetSuffix( String( sal_Unicode(0xff0e) ) ); 3899 } 3900 break; 3901 } 3902 rStartNumbering = boost::optional< sal_Int16 >( nAnmScheme >> 16 ); 3903 sal_Int16 nBuStart = *rStartNumbering; 3904 //The Seventh bit of nBuFlags that specifies whether fBulletHasAutoNumber exists, 3905 //and fBulletHasAutoNumber that specifies whether this paragraph has an automatic numbering scheme. 3906 if ( ( nBuFlags & 0x02000000 ) && ( nBuStart != 1 )) 3907 { 3908 rNumberFormat.SetStart( static_cast<sal_uInt16>(nBuStart) ); 3909 } 3910 } 3911 return bHardAttribute; 3912 } 3913 3914 void PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport& rManager, SvxNumberFormat& rNumberFormat, sal_uInt32 nLevel, const PPTParaLevel& rParaLevel, const PPTCharLevel& rCharLevel, sal_uInt32 nInstance ) 3915 { 3916 nIsBullet = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BulletOn ) ) != 0 ? 1 : 0; 3917 nBulletChar = rParaLevel.mnBulletChar; 3918 3919 sal_Bool bBuHardFont; 3920 bBuHardFont = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardFont ) ) != 0; 3921 if ( bBuHardFont ) 3922 nBulletFont = rParaLevel.mnBulletFont; 3923 else 3924 nBulletFont = rCharLevel.mnFont; 3925 nBulletHeight = rParaLevel.mnBulletHeight; 3926 nBulletColor = rParaLevel.mnBulletColor; 3927 nTextOfs = rParaLevel.mnTextOfs; 3928 nBulletOfs = rParaLevel.mnBulletOfs; 3929 3930 boost::optional< sal_Int16 > oStartNumbering; 3931 ImplGetExtNumberFormat( rManager, rNumberFormat, nLevel, nInstance, 0xffffffff, oStartNumbering, rCharLevel.mnFontHeight, NULL ); 3932 if ( ( rNumberFormat.GetNumberingType() != SVX_NUM_BITMAP ) && ( nBulletHeight > 0x7fff ) ) 3933 nBulletHeight = rCharLevel.mnFontHeight ? ((-((sal_Int16)nBulletHeight)) * 100 ) / rCharLevel.mnFontHeight : 100; 3934 ImplGetNumberFormat( rManager, rNumberFormat, nLevel ); 3935 switch ( rNumberFormat.GetNumberingType() ) 3936 { 3937 case SVX_NUM_CHARS_UPPER_LETTER : 3938 case SVX_NUM_CHARS_LOWER_LETTER : 3939 case SVX_NUM_ROMAN_UPPER : 3940 case SVX_NUM_ROMAN_LOWER : 3941 case SVX_NUM_ARABIC : 3942 case SVX_NUM_CHARS_UPPER_LETTER_N : 3943 case SVX_NUM_CHARS_LOWER_LETTER_N : 3944 { 3945 sal_uInt32 nFont = rCharLevel.mnFont; 3946 PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nFont ); 3947 if ( pFontEnityAtom ) 3948 { 3949 Font aFont; 3950 aFont.SetCharSet( pFontEnityAtom->eCharSet ); 3951 aFont.SetName( pFontEnityAtom->aName ); 3952 aFont.SetFamily( pFontEnityAtom->eFamily ); 3953 aFont.SetPitch( pFontEnityAtom->ePitch ); 3954 rNumberFormat.SetBulletFont( &aFont ); 3955 } 3956 } 3957 break; 3958 } 3959 } 3960 3961 sal_Bool PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport& rManager, SvxNumberFormat& rNumberFormat, PPTParagraphObj* pParaObj, 3962 sal_uInt32 nDestinationInstance, boost::optional< sal_Int16 >& rStartNumbering ) 3963 { 3964 sal_uInt32 nHardCount = 0; 3965 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet, nDestinationInstance ); 3966 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletChar, nBulletChar, nDestinationInstance ); 3967 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletFont, nBulletFont, nDestinationInstance ); 3968 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletHeight, nBulletHeight, nDestinationInstance ); 3969 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletColor, nBulletColor, nDestinationInstance ); 3970 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_TextOfs, nTextOfs, nDestinationInstance ); 3971 nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletOfs, nBulletOfs, nDestinationInstance ); 3972 3973 if ( nIsBullet ) 3974 rNumberFormat.SetNumberingType( SVX_NUM_CHAR_SPECIAL ); 3975 3976 sal_uInt32 nFontHeight = 24; 3977 PPTPortionObj* pPtr = pParaObj->First(); 3978 if ( pPtr ) 3979 pPtr->GetAttrib( PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance ); 3980 if ( nIsBullet ) 3981 nHardCount += ImplGetExtNumberFormat( rManager, rNumberFormat, pParaObj->pParaSet->mnDepth, 3982 pParaObj->mnInstance, nDestinationInstance, rStartNumbering, nFontHeight, pParaObj ); 3983 3984 if ( rNumberFormat.GetNumberingType() != SVX_NUM_BITMAP ) 3985 pParaObj->UpdateBulletRelSize( nBulletHeight ); 3986 if ( nHardCount ) 3987 ImplGetNumberFormat( rManager, rNumberFormat, pParaObj->pParaSet->mnDepth ); 3988 3989 if ( nHardCount ) 3990 { 3991 switch ( rNumberFormat.GetNumberingType() ) 3992 { 3993 case SVX_NUM_CHARS_UPPER_LETTER : 3994 case SVX_NUM_CHARS_LOWER_LETTER : 3995 case SVX_NUM_ROMAN_UPPER : 3996 case SVX_NUM_ROMAN_LOWER : 3997 case SVX_NUM_ARABIC : 3998 case SVX_NUM_CHARS_UPPER_LETTER_N : 3999 case SVX_NUM_CHARS_LOWER_LETTER_N : 4000 { 4001 if ( pPtr ) 4002 { 4003 sal_uInt32 nFont; 4004 pPtr->GetAttrib( PPT_CharAttr_Font, nFont, nDestinationInstance ); 4005 PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nFont ); 4006 if ( pFontEnityAtom ) 4007 { 4008 Font aFont; 4009 aFont.SetCharSet( pFontEnityAtom->eCharSet ); 4010 aFont.SetName( pFontEnityAtom->aName ); 4011 aFont.SetFamily( pFontEnityAtom->eFamily ); 4012 aFont.SetPitch( pFontEnityAtom->ePitch ); 4013 rNumberFormat.SetBulletFont( &aFont ); 4014 } 4015 } 4016 } 4017 break; 4018 } 4019 } 4020 return ( nHardCount ) ? sal_True : sal_False; 4021 } 4022 4023 void PPTNumberFormatCreator::ImplGetNumberFormat( SdrPowerPointImport& rManager, SvxNumberFormat& rNumberFormat, sal_uInt32 /*nLevel*/) 4024 { 4025 Font aFont; 4026 PptFontEntityAtom* pAtom = rManager.GetFontEnityAtom( nBulletFont ); 4027 if ( pAtom ) 4028 { 4029 CharSet eCharSet( pAtom->eCharSet ); 4030 aFont.SetName( pAtom->aName ); 4031 aFont.SetCharSet( eCharSet ); 4032 aFont.SetFamily( pAtom->eFamily ); 4033 aFont.SetPitch( pAtom->ePitch ); 4034 } 4035 Color aCol( rManager.MSO_TEXT_CLR_ToColor( nBulletColor ) ); 4036 aFont.SetColor( aCol ); 4037 4038 sal_uInt16 nBuChar = (sal_uInt16)nBulletChar; 4039 if ( aFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) 4040 { 4041 nBuChar &= 0x00ff; 4042 nBuChar |= 0xf000; 4043 } 4044 rNumberFormat.SetBulletFont( &aFont ); 4045 rNumberFormat.SetBulletChar( nBuChar ); 4046 rNumberFormat.SetBulletRelSize( (sal_uInt16)nBulletHeight ); 4047 rNumberFormat.SetBulletColor( aCol ); 4048 sal_uInt16 nAbsLSpace = (sal_uInt16)( ( (sal_uInt32)nTextOfs * 2540 ) / 576 ); 4049 sal_uInt16 nFirstLineOffset = nAbsLSpace - (sal_uInt16)( ( (sal_uInt32)nBulletOfs * 2540 ) / 576 ); 4050 rNumberFormat.SetAbsLSpace( nAbsLSpace ); 4051 rNumberFormat.SetFirstLineOffset( -nFirstLineOffset ); 4052 } 4053 4054 //////////////////////////////////////////////////////////////////////////////////////////////////// 4055 4056 PPTCharSheet::PPTCharSheet( sal_uInt32 nInstance ) 4057 { 4058 sal_uInt32 nColor = PPT_COLSCHEME_TEXT_UND_ZEILEN; 4059 sal_uInt16 nFontHeight(0); 4060 switch ( nInstance ) 4061 { 4062 case TSS_TYPE_PAGETITLE : 4063 case TSS_TYPE_TITLE : 4064 { 4065 nColor = PPT_COLSCHEME_TITELTEXT; 4066 nFontHeight = 44; 4067 } 4068 break; 4069 case TSS_TYPE_BODY : 4070 case TSS_TYPE_SUBTITLE : 4071 case TSS_TYPE_HALFBODY : 4072 case TSS_TYPE_QUARTERBODY : 4073 nFontHeight = 32; 4074 break; 4075 case TSS_TYPE_NOTES : 4076 nFontHeight = 12; 4077 break; 4078 case TSS_TYPE_UNUSED : 4079 case TSS_TYPE_TEXT_IN_SHAPE : 4080 nFontHeight = 24; 4081 break; 4082 } 4083 for ( sal_uInt32 nDepth = 0; nDepth < 5; nDepth++ ) 4084 { 4085 maCharLevel[ nDepth ].mnFlags = 0; 4086 maCharLevel[ nDepth ].mnFont = 0; 4087 maCharLevel[ nDepth ].mnAsianOrComplexFont = 0xffff; 4088 maCharLevel[ nDepth ].mnFontHeight = nFontHeight; 4089 maCharLevel[ nDepth ].mnFontColor = nColor; 4090 maCharLevel[ nDepth ].mnFontColorInStyleSheet = Color( (sal_uInt8)nColor, (sal_uInt8)( nColor >> 8 ), (sal_uInt8)( nColor >> 16 ) ); 4091 maCharLevel[ nDepth ].mnEscapement = 0; 4092 } 4093 } 4094 4095 PPTCharSheet::PPTCharSheet( const PPTCharSheet& rAttr ) 4096 { 4097 *this = rAttr; 4098 } 4099 4100 void PPTCharSheet::Read( SvStream& rIn, sal_Bool /*bMasterStyle*/, sal_uInt32 nLevel, sal_Bool /*bFirst*/) 4101 { 4102 // Zeichenattribute 4103 sal_uInt32 nCMask; 4104 sal_uInt16 nVal16; 4105 rIn >> nCMask; 4106 4107 if ( nCMask & 0x0000FFFF ) 4108 { 4109 sal_uInt16 nBitAttr; 4110 maCharLevel[ nLevel ].mnFlags &= ~( (sal_uInt16)nCMask ); 4111 rIn >> nBitAttr; // Bit-Attribute (Fett, Unterstrichen, ...) 4112 maCharLevel[ nLevel ].mnFlags |= nBitAttr; 4113 } 4114 if ( nCMask & ( 1 << PPT_CharAttr_Font ) ) // 0x00010000 4115 rIn >> maCharLevel[ nLevel ].mnFont; 4116 if ( nCMask & ( 1 << PPT_CharAttr_AsianOrComplexFont ) ) // 0x00200000 4117 rIn >> maCharLevel[ nLevel ].mnAsianOrComplexFont; 4118 if ( nCMask & ( 1 << PPT_CharAttr_ANSITypeface ) ) // 0x00400000 4119 rIn >> nVal16; 4120 if ( nCMask & ( 1 << PPT_CharAttr_Symbol ) ) // 0x00800000 4121 rIn >> nVal16; 4122 if ( nCMask & ( 1 << PPT_CharAttr_FontHeight ) ) // 0x00020000 4123 rIn >> maCharLevel[ nLevel ].mnFontHeight; 4124 if ( nCMask & ( 1 << PPT_CharAttr_FontColor ) ) // 0x00040000 4125 { 4126 rIn >> maCharLevel[ nLevel ].mnFontColor; 4127 if( ! (maCharLevel[ nLevel ].mnFontColor & 0xff000000 ) ) 4128 maCharLevel[ nLevel ].mnFontColor = PPT_COLSCHEME_HINTERGRUND; 4129 } 4130 if ( nCMask & ( 1 << PPT_CharAttr_Escapement ) ) // 0x00080000 4131 rIn >> maCharLevel[ nLevel ].mnEscapement; 4132 if ( nCMask & 0x00100000 ) // 0x00100000 4133 rIn >> nVal16; 4134 4135 nCMask >>= 24; 4136 while( nCMask ) 4137 { 4138 if ( nCMask & 1 ) 4139 { 4140 DBG_ERROR( "PPTCharSheet::Read - unknown attribute, send me this document (SJ)" ); 4141 rIn >> nVal16; 4142 } 4143 nCMask >>= 1; 4144 } 4145 } 4146 4147 PPTParaSheet::PPTParaSheet( sal_uInt32 nInstance ) 4148 { 4149 sal_uInt16 nBuFlags = 0; 4150 sal_uInt32 nBulletColor = 0x8000000; 4151 sal_uInt16 nUpperDist = 0; 4152 4153 switch ( nInstance ) 4154 { 4155 case TSS_TYPE_PAGETITLE : 4156 case TSS_TYPE_TITLE : 4157 nBulletColor = PPT_COLSCHEME_TITELTEXT; 4158 break; 4159 case TSS_TYPE_BODY : 4160 case TSS_TYPE_SUBTITLE : 4161 case TSS_TYPE_HALFBODY : 4162 case TSS_TYPE_QUARTERBODY : 4163 { 4164 nBuFlags = 1; 4165 nUpperDist = 0x14; 4166 } 4167 break; 4168 case TSS_TYPE_NOTES : 4169 nUpperDist = 0x1e; 4170 break; 4171 /* 4172 default : 4173 case TSS_TYPE_UNUSED : 4174 case TSS_TYPE_TEXT_IN_SHAPE : 4175 break; 4176 */ 4177 } 4178 for ( sal_uInt32 i = 0; i < 5; i++ ) 4179 { 4180 maParaLevel[ i ].mnBuFlags = nBuFlags; 4181 maParaLevel[ i ].mnBulletChar = 0x2022; 4182 maParaLevel[ i ].mnBulletFont = 0; 4183 maParaLevel[ i ].mnBulletHeight = 100; 4184 maParaLevel[ i ].mnBulletColor = nBulletColor; 4185 maParaLevel[ i ].mnAdjust = 0; 4186 maParaLevel[ i ].mnLineFeed = 100; 4187 maParaLevel[ i ].mnLowerDist = 0; 4188 maParaLevel[ i ].mnUpperDist = nUpperDist; 4189 maParaLevel[ i ].mnTextOfs = 0; 4190 maParaLevel[ i ].mnBulletOfs = 0; 4191 maParaLevel[ i ].mnDefaultTab = 0x240; 4192 maParaLevel[ i ].mnAsianLineBreak = 0; 4193 maParaLevel[ i ].mnBiDi = 0; 4194 } 4195 } 4196 4197 PPTParaSheet::PPTParaSheet( const PPTParaSheet& rSheet ) 4198 { 4199 *this = rSheet; 4200 } 4201 4202 void PPTParaSheet::Read( SdrPowerPointImport& 4203 #ifdef DBG_UTIL 4204 rManager 4205 #endif 4206 , SvStream& rIn, sal_Bool /*bMasterStyle*/, 4207 sal_uInt32 nLevel, sal_Bool bFirst ) 4208 { 4209 // Absatzattribute 4210 sal_uInt16 nVal16, i, nMask16; 4211 sal_uInt32 nVal32, nPMask; 4212 rIn >> nPMask; 4213 4214 nMask16 = (sal_uInt16)nPMask & 0xf; 4215 if ( nMask16 ) 4216 { 4217 rIn >> nVal16; 4218 maParaLevel[ nLevel ].mnBuFlags &=~ nMask16; 4219 nVal16 &= nMask16; 4220 maParaLevel[ nLevel ].mnBuFlags |= nVal16; 4221 } 4222 if ( nPMask & 0x0080 ) 4223 rIn >> maParaLevel[ nLevel ].mnBulletChar; 4224 if ( nPMask & 0x0010 ) 4225 rIn >> maParaLevel[ nLevel ].mnBulletFont; 4226 if ( nPMask & 0x0040 ) 4227 { 4228 rIn >> nVal16; 4229 maParaLevel[ nLevel ].mnBulletHeight = nVal16; 4230 } 4231 if ( nPMask & 0x0020 ) 4232 { 4233 rIn >> nVal32; 4234 maParaLevel[ nLevel ].mnBulletColor = nVal32; 4235 } 4236 if ( bFirst ) 4237 { 4238 if ( nPMask & 0xF00 ) 4239 { // AbsJust! 4240 rIn >> nVal16; 4241 maParaLevel[ nLevel ].mnAdjust = nVal16 & 3; 4242 } 4243 if ( nPMask & 0x1000 ) 4244 rIn >> maParaLevel[ nLevel ].mnLineFeed; 4245 if ( nPMask & 0x2000 ) 4246 rIn >> maParaLevel[ nLevel ].mnUpperDist; 4247 if ( nPMask & 0x4000 ) 4248 rIn >> maParaLevel[ nLevel ].mnLowerDist; 4249 if ( nPMask & 0x8000 ) 4250 rIn >> maParaLevel[ nLevel ].mnTextOfs; 4251 if ( nPMask & 0x10000 ) 4252 rIn >> maParaLevel[ nLevel ].mnBulletOfs; 4253 if ( nPMask & 0x20000 ) 4254 rIn >> maParaLevel[ nLevel ].mnDefaultTab; 4255 if ( nPMask & 0x200000 ) 4256 { 4257 // number of tabulators 4258 rIn >> nVal16; 4259 for ( i = 0; i < nVal16; i++ ) 4260 rIn >> nVal32; // reading the tabulators 4261 } 4262 if ( nPMask & 0x40000 ) 4263 rIn >> nVal16; 4264 if ( nPMask & 0x80000 ) 4265 rIn >> maParaLevel[ nLevel ].mnAsianLineBreak; 4266 if ( nPMask & 0x100000 ) 4267 rIn >> maParaLevel[ nLevel ].mnBiDi; 4268 } 4269 else 4270 { 4271 if ( nPMask & 0x800 ) 4272 { 4273 rIn >> nVal16; 4274 maParaLevel[ nLevel ].mnAdjust = nVal16 & 3; 4275 } 4276 if ( nPMask & 0x1000 ) 4277 rIn >> maParaLevel[ nLevel ].mnLineFeed; 4278 if ( nPMask & 0x2000 ) 4279 rIn >> maParaLevel[ nLevel ].mnUpperDist; 4280 if ( nPMask & 0x4000 ) 4281 rIn >> maParaLevel[ nLevel ].mnLowerDist; 4282 if ( nPMask & 0x8000 ) 4283 rIn >> nVal16; 4284 if ( nPMask & 0x100 ) 4285 rIn >> maParaLevel[ nLevel ].mnTextOfs; 4286 if ( nPMask & 0x200 ) 4287 rIn >> nVal16; 4288 if ( nPMask & 0x400 ) 4289 rIn >> maParaLevel[ nLevel ].mnBulletOfs; 4290 if ( nPMask & 0x10000 ) 4291 rIn >> nVal16; 4292 if ( nPMask & 0xe0000 ) 4293 { 4294 sal_uInt16 nFlagsToModifyMask = (sal_uInt16)( ( nPMask >> 17 ) & 7 ); 4295 rIn >> nVal16; 4296 // bits that are not involved to zero 4297 nVal16 &= nFlagsToModifyMask; 4298 // bits that are to change to zero 4299 maParaLevel[ nLevel ].mnAsianLineBreak &=~nFlagsToModifyMask; 4300 // now set the corresponding bits 4301 maParaLevel[ nLevel ].mnAsianLineBreak |= nVal16; 4302 } 4303 if ( nPMask & 0x100000 ) 4304 { 4305 // number of tabulators 4306 rIn >> nVal16; 4307 for ( i = 0; i < nVal16; i++ ) 4308 rIn >> nVal32; // reading the tabulators 4309 } 4310 if ( nPMask & 0x200000 ) 4311 rIn >> maParaLevel[ nLevel ].mnBiDi; // #88602# 4312 } 4313 4314 nPMask >>= 22; 4315 while( nPMask ) 4316 { 4317 if ( nPMask & 1 ) 4318 { 4319 #ifdef DBG_UTIL 4320 if (!(rManager.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT)) 4321 { 4322 DBG_ERROR( "PPTParaSheet::Read - unknown attribute, send me this document (SJ)" ); 4323 } 4324 #endif 4325 rIn >> nVal16; 4326 } 4327 nPMask >>= 1; 4328 } 4329 } 4330 4331 void PPTParaSheet::UpdateBulletRelSize( sal_uInt32 nLevel, sal_uInt16 nFontHeight ) 4332 { 4333 if ( maParaLevel[ nLevel ].mnBulletHeight > 0x7fff ) // a negative value is the absolute bullet height 4334 { 4335 sal_Int16 nBulletRelSize = ( sal_Int16 )maParaLevel[ nLevel ].mnBulletHeight; 4336 nBulletRelSize = nFontHeight ? ((-nBulletRelSize) * 100 ) / nFontHeight : 100; 4337 if ( nBulletRelSize < 0 ) //bullet size over flow 4338 nBulletRelSize = 100; 4339 maParaLevel[ nLevel ].mnBulletHeight = nBulletRelSize; 4340 } 4341 } 4342 4343 PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, SdrPowerPointImport& rManager, 4344 const PPTTextCharacterStyleAtomInterpreter& /*rTxCFStyle*/, const PPTTextParagraphStyleAtomInterpreter& rTxPFStyle, 4345 const PPTTextSpecInfo& rTextSpecInfo ) : 4346 4347 PPTNumberFormatCreator ( new PPTExtParaProv( rManager, rIn, &rSlideHd ) ), 4348 maTxSI ( rTextSpecInfo ) 4349 { 4350 sal_uInt32 i; 4351 sal_uInt32 nOldFilePos = rIn.Tell(); 4352 4353 // default stylesheets 4354 mpCharSheet[ TSS_TYPE_PAGETITLE ] = new PPTCharSheet( TSS_TYPE_PAGETITLE ); 4355 mpCharSheet[ TSS_TYPE_BODY ] = new PPTCharSheet( TSS_TYPE_BODY ); 4356 mpCharSheet[ TSS_TYPE_NOTES ] = new PPTCharSheet( TSS_TYPE_NOTES ); 4357 mpCharSheet[ TSS_TYPE_UNUSED ] = new PPTCharSheet( TSS_TYPE_UNUSED ); // this entry is not used by ppt 4358 mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ] = new PPTCharSheet( TSS_TYPE_TEXT_IN_SHAPE ); 4359 mpParaSheet[ TSS_TYPE_PAGETITLE ] = new PPTParaSheet( TSS_TYPE_PAGETITLE ); 4360 mpParaSheet[ TSS_TYPE_BODY ] = new PPTParaSheet( TSS_TYPE_BODY ); 4361 mpParaSheet[ TSS_TYPE_NOTES ] = new PPTParaSheet( TSS_TYPE_NOTES ); 4362 mpParaSheet[ TSS_TYPE_UNUSED ] = new PPTParaSheet( TSS_TYPE_UNUSED ); 4363 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ] = new PPTParaSheet( TSS_TYPE_TEXT_IN_SHAPE ); 4364 mpCharSheet[ TSS_TYPE_QUARTERBODY ] = mpCharSheet[ TSS_TYPE_HALFBODY ] = mpCharSheet[ TSS_TYPE_TITLE ] = mpCharSheet[ TSS_TYPE_SUBTITLE ] = NULL; 4365 mpParaSheet[ TSS_TYPE_QUARTERBODY ] = mpParaSheet[ TSS_TYPE_HALFBODY ] = mpParaSheet[ TSS_TYPE_TITLE ] = mpParaSheet[ TSS_TYPE_SUBTITLE ] = NULL; 4366 4367 /* SJ: try to locate the txMasterStyleAtom in the Environment 4368 4369 it seems that the environment TextStyle is having a higher priority 4370 than the TextStyle that can be found within the master page 4371 */ 4372 sal_Bool bFoundTxMasterStyleAtom04 = sal_False; 4373 DffRecordHeader* pEnvHeader = rManager.aDocRecManager.GetRecordHeader( PPT_PST_Environment ); 4374 if ( pEnvHeader ) 4375 { 4376 pEnvHeader->SeekToContent( rIn ); 4377 DffRecordHeader aTxMasterStyleHd; 4378 while ( rIn.Tell() < pEnvHeader->GetRecEndFilePos() ) 4379 { 4380 rIn >> aTxMasterStyleHd; 4381 if ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom ) 4382 { 4383 sal_uInt16 nLevelAnz; 4384 rIn >> nLevelAnz; 4385 4386 sal_uInt16 nLev = 0; 4387 sal_Bool bFirst = sal_True; 4388 bFoundTxMasterStyleAtom04 = sal_True; 4389 while ( rIn.GetError() == 0 && rIn.Tell() < aTxMasterStyleHd.GetRecEndFilePos() && nLev < nLevelAnz ) 4390 { 4391 if ( nLev ) 4392 { 4393 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev ] = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev - 1 ]; 4394 mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev ] = mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev - 1 ]; 4395 } 4396 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rManager, rIn, sal_True, nLev, bFirst ); 4397 if ( !nLev ) 4398 { 4399 // set paragraph defaults for instance 4 (TSS_TYPE_TEXT_IN_SHAPE) 4400 if ( rTxPFStyle.bValid ) 4401 { 4402 PPTParaLevel& rParaLevel = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ 0 ]; 4403 rParaLevel.mnAsianLineBreak = 0; 4404 if ( rTxPFStyle.bForbiddenRules ) 4405 rParaLevel.mnAsianLineBreak |= 1; 4406 if ( !rTxPFStyle.bLatinTextWrap ) 4407 rParaLevel.mnAsianLineBreak |= 2; 4408 if ( rTxPFStyle.bHangingPunctuation ) 4409 rParaLevel.mnAsianLineBreak |= 4; 4410 } 4411 } 4412 mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rIn, sal_True, nLev, bFirst ); 4413 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->UpdateBulletRelSize( nLev, mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev ].mnFontHeight ); 4414 bFirst = sal_False; 4415 nLev++; 4416 } 4417 break; 4418 } 4419 else 4420 aTxMasterStyleHd.SeekToEndOfRecord( rIn ); 4421 } 4422 } 4423 4424 rSlideHd.SeekToContent( rIn ); 4425 DffRecordHeader aTxMasterStyleHd; 4426 while ( rIn.Tell() < rSlideHd.GetRecEndFilePos() ) 4427 { 4428 rIn >> aTxMasterStyleHd; 4429 if ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom ) 4430 break; 4431 else 4432 aTxMasterStyleHd.SeekToEndOfRecord( rIn ); 4433 } 4434 while ( ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom ) && ( rIn.Tell() < rSlideHd.GetRecEndFilePos() ) ) //TODO: aTxMasterStyleHd may be used without having been properly initialized 4435 { 4436 sal_uInt32 nInstance = aTxMasterStyleHd.nRecInstance; 4437 if ( ( nInstance < PPT_STYLESHEETENTRYS ) && 4438 ( ( nInstance != TSS_TYPE_TEXT_IN_SHAPE ) || ( bFoundTxMasterStyleAtom04 == sal_False ) ) ) 4439 { 4440 if ( nInstance > 4 ) 4441 { 4442 delete mpCharSheet[ nInstance ]; // be sure to delete the old one if this instance comes twice 4443 delete mpParaSheet[ nInstance ]; 4444 4445 switch ( nInstance ) 4446 { 4447 case TSS_TYPE_SUBTITLE : 4448 { 4449 mpCharSheet[ TSS_TYPE_SUBTITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) ); 4450 mpParaSheet[ TSS_TYPE_SUBTITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) ); 4451 } 4452 break; 4453 case TSS_TYPE_TITLE : 4454 { 4455 mpCharSheet[ TSS_TYPE_TITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_PAGETITLE ] ) ); 4456 mpParaSheet[ TSS_TYPE_TITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_PAGETITLE ] ) ); 4457 } 4458 break; 4459 case TSS_TYPE_HALFBODY : 4460 { 4461 mpCharSheet[ TSS_TYPE_HALFBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) ); 4462 mpParaSheet[ TSS_TYPE_HALFBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) ); 4463 } 4464 break; 4465 4466 case TSS_TYPE_QUARTERBODY : 4467 { 4468 mpCharSheet[ TSS_TYPE_QUARTERBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) ); 4469 mpParaSheet[ TSS_TYPE_QUARTERBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) ); 4470 } 4471 break; 4472 } 4473 } 4474 sal_uInt16 nLevelAnz; 4475 rIn >> nLevelAnz; 4476 if ( nLevelAnz > 5 ) 4477 { 4478 DBG_ERROR( "PPTStyleSheet::Ppt-TextStylesheet hat mehr als 5 Ebenen! (SJ)" ); 4479 nLevelAnz = 5; 4480 } 4481 sal_uInt16 nLev = 0; 4482 sal_Bool bFirst = sal_True; 4483 4484 while ( rIn.GetError() == 0 && rIn.Tell() < aTxMasterStyleHd.GetRecEndFilePos() && nLev < nLevelAnz ) 4485 { 4486 if ( nLev && ( nInstance < 5 ) ) 4487 { 4488 mpParaSheet[ nInstance ]->maParaLevel[ nLev ] = mpParaSheet[ nInstance ]->maParaLevel[ nLev - 1 ]; 4489 mpCharSheet[ nInstance ]->maCharLevel[ nLev ] = mpCharSheet[ nInstance ]->maCharLevel[ nLev - 1 ]; 4490 } 4491 4492 // Ausnahme: Vorlage 5, 6 (MasterTitle Titel und SubTitel) 4493 if ( nInstance >= TSS_TYPE_SUBTITLE ) 4494 { 4495 bFirst = sal_False; 4496 4497 sal_uInt16 nDontKnow; 4498 rIn >> nDontKnow; 4499 } 4500 mpParaSheet[ nInstance ]->Read( rManager, rIn, sal_True, nLev, bFirst ); 4501 mpCharSheet[ nInstance ]->Read( rIn, sal_True, nLev, bFirst ); 4502 mpParaSheet[ nInstance ]->UpdateBulletRelSize( nLev, mpCharSheet[ nInstance ]->maCharLevel[ nLev ].mnFontHeight ); 4503 bFirst = sal_False; 4504 nLev++; 4505 } 4506 #ifdef DBG_UTIL 4507 if (!(rManager.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT)) 4508 { 4509 if ( rIn.GetError() == 0 ) 4510 { 4511 ByteString aMsg; 4512 if ( rIn.Tell() > aTxMasterStyleHd.GetRecEndFilePos() ) 4513 { 4514 aMsg += "\n "; 4515 aMsg += "reading too many bytes:"; 4516 aMsg += ByteString::CreateFromInt32( rIn.Tell() - aTxMasterStyleHd.GetRecEndFilePos() ); 4517 } 4518 if ( rIn.Tell() < aTxMasterStyleHd.GetRecEndFilePos() ) 4519 { 4520 aMsg += "\n "; 4521 aMsg += "reading too less bytes:"; 4522 aMsg += ByteString::CreateFromInt32( aTxMasterStyleHd.GetRecEndFilePos() - rIn.Tell() ); 4523 } 4524 if ( aMsg.Len() != 0 ) 4525 { 4526 aMsg.Insert( "]:", 0 ); 4527 aMsg.Insert( "PptStyleSheet::operator>>[", 0 ); 4528 DBG_ERROR(aMsg.GetBuffer()); 4529 } 4530 } 4531 if ( rIn.Tell() != aTxMasterStyleHd.GetRecEndFilePos() ) 4532 DBG_ASSERT(0, "SJ: Falsche Anzahl von Bytes gelesen beim Import der PPT-Formatvorlagen"); 4533 } 4534 #endif 4535 } 4536 aTxMasterStyleHd.SeekToEndOfRecord( rIn ); 4537 rIn >> aTxMasterStyleHd; 4538 } 4539 if ( !mpCharSheet[ TSS_TYPE_SUBTITLE ] ) 4540 { 4541 mpCharSheet[ TSS_TYPE_SUBTITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) ); 4542 mpParaSheet[ TSS_TYPE_SUBTITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) ); 4543 } 4544 if ( !mpCharSheet[ TSS_TYPE_TITLE ] ) 4545 { 4546 mpCharSheet[ TSS_TYPE_TITLE ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_PAGETITLE ] ) ); 4547 mpParaSheet[ TSS_TYPE_TITLE ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_PAGETITLE ] ) ); 4548 } 4549 if ( !mpCharSheet[ TSS_TYPE_HALFBODY ] ) 4550 { 4551 mpCharSheet[ TSS_TYPE_HALFBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) ); 4552 mpParaSheet[ TSS_TYPE_HALFBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) ); 4553 } 4554 if ( !mpCharSheet[ TSS_TYPE_QUARTERBODY ] ) 4555 { 4556 mpCharSheet[ TSS_TYPE_QUARTERBODY ] = new PPTCharSheet( *( mpCharSheet[ TSS_TYPE_BODY ] ) ); 4557 mpParaSheet[ TSS_TYPE_QUARTERBODY ] = new PPTParaSheet( *( mpParaSheet[ TSS_TYPE_BODY ] ) ); 4558 } 4559 if ( !bFoundTxMasterStyleAtom04 ) 4560 { // try to locate the txMasterStyleAtom in the Environment 4561 DffRecordHeader* pEnvHeader2 = rManager.aDocRecManager.GetRecordHeader( PPT_PST_Environment ); 4562 if ( pEnvHeader2 ) 4563 { 4564 pEnvHeader2->SeekToContent( rIn ); 4565 DffRecordHeader aTxMasterStyleHd2; 4566 while ( rIn.Tell() < pEnvHeader2->GetRecEndFilePos() ) 4567 { 4568 rIn >> aTxMasterStyleHd2; 4569 if ( aTxMasterStyleHd2.nRecType == PPT_PST_TxMasterStyleAtom ) 4570 { 4571 sal_uInt16 nLevelAnz; 4572 rIn >> nLevelAnz; 4573 4574 sal_uInt16 nLev = 0; 4575 sal_Bool bFirst = sal_True; 4576 while ( rIn.GetError() == 0 && rIn.Tell() < aTxMasterStyleHd2.GetRecEndFilePos() && nLev < nLevelAnz ) 4577 { 4578 if ( nLev ) 4579 { 4580 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev ] = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ nLev - 1 ]; 4581 mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev ] = mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev - 1 ]; 4582 } 4583 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rManager, rIn, sal_True, nLev, bFirst ); 4584 if ( !nLev ) 4585 { 4586 // set paragraph defaults for instance 4 (TSS_TYPE_TEXT_IN_SHAPE) 4587 if ( rTxPFStyle.bValid ) 4588 { 4589 PPTParaLevel& rParaLevel = mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maParaLevel[ 0 ]; 4590 rParaLevel.mnAsianLineBreak = 0; 4591 if ( rTxPFStyle.bForbiddenRules ) 4592 rParaLevel.mnAsianLineBreak |= 1; 4593 if ( !rTxPFStyle.bLatinTextWrap ) 4594 rParaLevel.mnAsianLineBreak |= 2; 4595 if ( rTxPFStyle.bHangingPunctuation ) 4596 rParaLevel.mnAsianLineBreak |= 4; 4597 } 4598 } 4599 mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->Read( rIn, sal_True, nLev, bFirst ); 4600 mpParaSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->UpdateBulletRelSize( nLev, mpCharSheet[ TSS_TYPE_TEXT_IN_SHAPE ]->maCharLevel[ nLev ].mnFontHeight ); 4601 bFirst = sal_False; 4602 nLev++; 4603 } 4604 break; 4605 } 4606 else 4607 aTxMasterStyleHd2.SeekToEndOfRecord( rIn ); 4608 } 4609 } 4610 } 4611 rIn.Seek( nOldFilePos ); 4612 4613 // will will create the default numbulletitem for each instance 4614 for ( i = 0; i < PPT_STYLESHEETENTRYS; i++ ) 4615 { 4616 sal_uInt16 nLevels, nDepth = 0; 4617 SvxNumRuleType eNumRuleType; 4618 4619 switch ( i ) 4620 { 4621 case TSS_TYPE_PAGETITLE : 4622 case TSS_TYPE_TITLE : 4623 nLevels = 1; 4624 eNumRuleType = SVX_RULETYPE_NUMBERING; 4625 break; 4626 case TSS_TYPE_SUBTITLE : 4627 nLevels = 10; 4628 eNumRuleType = SVX_RULETYPE_NUMBERING; 4629 break; 4630 case TSS_TYPE_BODY : 4631 case TSS_TYPE_HALFBODY : 4632 case TSS_TYPE_QUARTERBODY : 4633 nLevels = 10; 4634 eNumRuleType = SVX_RULETYPE_PRESENTATION_NUMBERING; 4635 break; 4636 default : 4637 case TSS_TYPE_NOTES : 4638 case TSS_TYPE_UNUSED : 4639 case TSS_TYPE_TEXT_IN_SHAPE : 4640 nLevels = 10; 4641 eNumRuleType = SVX_RULETYPE_NUMBERING; 4642 break; 4643 } 4644 SvxNumRule aRule( NUM_BULLET_REL_SIZE | NUM_BULLET_COLOR | 4645 NUM_CHAR_TEXT_DISTANCE | NUM_SYMBOL_ALIGNMENT, 4646 nLevels, sal_False, eNumRuleType ); 4647 for ( sal_uInt16 nCount = 0; nDepth < nLevels; nCount++ ) 4648 { 4649 const PPTParaLevel& rParaLevel = mpParaSheet[ i ]->maParaLevel[ nCount ]; 4650 const PPTCharLevel& rCharLevel = mpCharSheet[ i ]->maCharLevel[ nCount ]; 4651 SvxNumberFormat aNumberFormat( SVX_NUM_CHAR_SPECIAL ); 4652 aNumberFormat.SetBulletChar( ' ' ); 4653 GetNumberFormat( rManager, aNumberFormat, nCount, rParaLevel, rCharLevel, i ); 4654 aRule.SetLevel( nDepth++, aNumberFormat ); 4655 if ( nCount >= 4 ) 4656 { 4657 for ( ;nDepth < nLevels; nDepth++ ) 4658 aRule.SetLevel( nDepth, aNumberFormat ); 4659 if ( eNumRuleType == SVX_RULETYPE_PRESENTATION_NUMBERING ) 4660 aRule.SetLevel( 0, aNumberFormat ); 4661 } 4662 } 4663 mpNumBulletItem[ i ] = new SvxNumBulletItem( aRule, EE_PARA_NUMBULLET ); 4664 } 4665 } 4666 4667 PPTStyleSheet::~PPTStyleSheet() 4668 { 4669 for ( sal_uInt32 i = 0; i < PPT_STYLESHEETENTRYS; i++ ) 4670 { 4671 delete mpCharSheet[ i ]; 4672 delete mpParaSheet[ i ]; 4673 delete mpNumBulletItem[ i ]; 4674 } 4675 } 4676 4677 //////////////////////////////////////////////////////////////////////////////////////////////////// 4678 4679 PPTParaPropSet::PPTParaPropSet() : 4680 pParaSet( new ImplPPTParaPropSet ) 4681 { 4682 pParaSet->mnHasAnm = 1; 4683 } 4684 4685 PPTParaPropSet::PPTParaPropSet( PPTParaPropSet& rParaPropSet ) 4686 { 4687 pParaSet = rParaPropSet.pParaSet; 4688 pParaSet->mnRefCount++; 4689 4690 mnOriginalTextPos = rParaPropSet.mnOriginalTextPos; 4691 } 4692 4693 PPTParaPropSet::~PPTParaPropSet() 4694 { 4695 if ( ! ( --pParaSet->mnRefCount ) ) 4696 delete pParaSet; 4697 } 4698 4699 PPTParaPropSet& PPTParaPropSet::operator=( PPTParaPropSet& rParaPropSet ) 4700 { 4701 if ( this != &rParaPropSet ) 4702 { 4703 if ( ! ( --pParaSet->mnRefCount ) ) 4704 delete pParaSet; 4705 pParaSet = rParaPropSet.pParaSet; 4706 pParaSet->mnRefCount++; 4707 4708 mnOriginalTextPos = rParaPropSet.mnOriginalTextPos; 4709 } 4710 return *this; 4711 } 4712 4713 PPTCharPropSet::PPTCharPropSet( sal_uInt32 nParagraph ) : 4714 mnParagraph ( nParagraph ), 4715 mpFieldItem ( NULL ), 4716 pCharSet ( new ImplPPTCharPropSet ) 4717 { 4718 mnHylinkOrigColor = 0; 4719 mbIsHyperlink = sal_False; 4720 mbHardHylinkOrigColor = sal_False; 4721 mnLanguage[ 0 ] = mnLanguage[ 1 ] = mnLanguage[ 2 ] = 0; 4722 } 4723 4724 PPTCharPropSet::PPTCharPropSet( PPTCharPropSet& rCharPropSet ) 4725 { 4726 mnHylinkOrigColor = rCharPropSet.mnHylinkOrigColor; 4727 mbIsHyperlink = rCharPropSet.mbIsHyperlink; 4728 mbHardHylinkOrigColor = rCharPropSet.mbHardHylinkOrigColor; 4729 pCharSet = rCharPropSet.pCharSet; 4730 pCharSet->mnRefCount++; 4731 4732 mnParagraph = rCharPropSet.mnParagraph; 4733 mnOriginalTextPos = rCharPropSet.mnOriginalTextPos; 4734 maString = rCharPropSet.maString; 4735 mpFieldItem = ( rCharPropSet.mpFieldItem ) ? new SvxFieldItem( *rCharPropSet.mpFieldItem ) : NULL; 4736 mnLanguage[ 0 ] = rCharPropSet.mnLanguage[ 0 ]; 4737 mnLanguage[ 1 ] = rCharPropSet.mnLanguage[ 1 ]; 4738 mnLanguage[ 2 ] = rCharPropSet.mnLanguage[ 2 ]; 4739 } 4740 4741 PPTCharPropSet::PPTCharPropSet( PPTCharPropSet& rCharPropSet, sal_uInt32 nParagraph ) 4742 { 4743 pCharSet = rCharPropSet.pCharSet; 4744 pCharSet->mnRefCount++; 4745 4746 mnHylinkOrigColor = rCharPropSet.mnHylinkOrigColor; 4747 mbIsHyperlink = rCharPropSet.mbIsHyperlink; 4748 mbHardHylinkOrigColor = rCharPropSet.mbHardHylinkOrigColor; 4749 4750 mnParagraph = nParagraph; 4751 mnOriginalTextPos = rCharPropSet.mnOriginalTextPos; 4752 maString = rCharPropSet.maString; 4753 mpFieldItem = ( rCharPropSet.mpFieldItem ) ? new SvxFieldItem( *rCharPropSet.mpFieldItem ) : NULL; 4754 mnLanguage[ 0 ] = mnLanguage[ 1 ] = mnLanguage[ 2 ] = 0; 4755 } 4756 4757 PPTCharPropSet::~PPTCharPropSet() 4758 { 4759 if ( ! ( --pCharSet->mnRefCount ) ) 4760 delete pCharSet; 4761 delete mpFieldItem; 4762 } 4763 4764 PPTCharPropSet& PPTCharPropSet::operator=( PPTCharPropSet& rCharPropSet ) 4765 { 4766 if ( this != &rCharPropSet ) 4767 { 4768 if ( ! ( --pCharSet->mnRefCount ) ) 4769 delete pCharSet; 4770 pCharSet = rCharPropSet.pCharSet; 4771 pCharSet->mnRefCount++; 4772 4773 mnOriginalTextPos = rCharPropSet.mnOriginalTextPos; 4774 mnParagraph = rCharPropSet.mnParagraph; 4775 maString = rCharPropSet.maString; 4776 mpFieldItem = ( rCharPropSet.mpFieldItem ) ? new SvxFieldItem( *rCharPropSet.mpFieldItem ) : NULL; 4777 } 4778 return *this; 4779 } 4780 4781 void PPTCharPropSet::ImplMakeUnique() 4782 { 4783 if ( pCharSet->mnRefCount > 1 ) 4784 { 4785 ImplPPTCharPropSet& rOld = *pCharSet; 4786 rOld.mnRefCount--; 4787 pCharSet = new ImplPPTCharPropSet( rOld ); 4788 pCharSet->mnRefCount = 1; 4789 } 4790 } 4791 4792 void PPTCharPropSet::SetFont( sal_uInt16 nFont ) 4793 { 4794 sal_uInt32 nMask = 1 << PPT_CharAttr_Font; 4795 sal_uInt32 bDoNotMake = pCharSet->mnAttrSet & nMask; 4796 4797 if ( bDoNotMake ) 4798 bDoNotMake = nFont == pCharSet->mnFont; 4799 4800 if ( !bDoNotMake ) 4801 { 4802 ImplMakeUnique(); 4803 pCharSet->mnFont = nFont; 4804 pCharSet->mnAttrSet |= nMask; 4805 } 4806 } 4807 4808 void PPTCharPropSet::SetColor( sal_uInt32 nColor ) 4809 { 4810 ImplMakeUnique(); 4811 pCharSet->mnColor = nColor; 4812 pCharSet->mnAttrSet |= 1 << PPT_CharAttr_FontColor; 4813 } 4814 4815 //////////////////////////////////////////////////////////////////////////////////////////////////// 4816 4817 PPTRuler::PPTRuler() : 4818 nRefCount ( 1 ), 4819 nFlags ( 0 ), 4820 pTab ( NULL ), 4821 nTabCount ( 0 ) 4822 { 4823 } 4824 4825 PPTRuler::~PPTRuler() 4826 { 4827 delete[] pTab; 4828 }; 4829 4830 4831 PPTTextRulerInterpreter::PPTTextRulerInterpreter() : 4832 mpImplRuler ( new PPTRuler() ) 4833 { 4834 } 4835 4836 PPTTextRulerInterpreter::PPTTextRulerInterpreter( PPTTextRulerInterpreter& rRuler ) 4837 { 4838 mpImplRuler = rRuler.mpImplRuler; 4839 mpImplRuler->nRefCount++; 4840 } 4841 4842 PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, SdrPowerPointImport& rMan, DffRecordHeader& rHeader, SvStream& rIn ) : 4843 mpImplRuler ( new PPTRuler() ) 4844 { 4845 if ( nFileOfs != 0xffffffff ) 4846 { 4847 sal_uInt32 nOldPos = rIn.Tell(); 4848 DffRecordHeader rHd; 4849 if ( nFileOfs ) 4850 { 4851 rIn.Seek( nFileOfs ); 4852 rIn >> rHd; 4853 } 4854 else 4855 { 4856 rHeader.SeekToContent( rIn ); 4857 if ( rMan.SeekToRec( rIn, PPT_PST_TextRulerAtom, rHeader.GetRecEndFilePos(), &rHd ) ) 4858 nFileOfs++; 4859 } 4860 if ( nFileOfs ) 4861 { 4862 sal_Int16 nTCount; 4863 sal_Int32 i; 4864 rIn >> mpImplRuler->nFlags; 4865 if ( mpImplRuler->nFlags & 1 ) 4866 rIn >> mpImplRuler->nDefaultTab; 4867 if ( mpImplRuler->nFlags & 4 ) 4868 { 4869 rIn >> nTCount; 4870 if ( nTCount ) 4871 { 4872 mpImplRuler->nTabCount = (sal_uInt16)nTCount; 4873 mpImplRuler->pTab = new PPTTabEntry[ mpImplRuler->nTabCount ]; 4874 for ( i = 0; i < nTCount; i++ ) 4875 { 4876 rIn >> mpImplRuler->pTab[ i ].nOffset 4877 >> mpImplRuler->pTab[ i ].nStyle; 4878 } 4879 } 4880 } 4881 for ( i = 0; i < 5; i++ ) 4882 { 4883 if ( mpImplRuler->nFlags & ( 8 << i ) ) 4884 rIn >> mpImplRuler->nTextOfs[ i ]; 4885 if ( mpImplRuler->nFlags & ( 256 << i ) ) 4886 rIn >> mpImplRuler->nBulletOfs[ i ]; 4887 } 4888 } 4889 rIn.Seek( nOldPos ); 4890 } 4891 } 4892 4893 sal_Bool PPTTextRulerInterpreter::GetDefaultTab( sal_uInt32 /*nLevel*/, sal_uInt16& nValue ) const 4894 { 4895 if ( ! ( mpImplRuler->nFlags & 1 ) ) 4896 return sal_False; 4897 nValue = mpImplRuler->nDefaultTab; 4898 return sal_True; 4899 } 4900 4901 sal_Bool PPTTextRulerInterpreter::GetTextOfs( sal_uInt32 nLevel, sal_uInt16& nValue ) const 4902 { 4903 if ( ! ( ( nLevel < 5 ) && ( mpImplRuler->nFlags & ( 8 << nLevel ) ) ) ) 4904 return sal_False; 4905 nValue = mpImplRuler->nTextOfs[ nLevel ]; 4906 return sal_True; 4907 } 4908 4909 sal_Bool PPTTextRulerInterpreter::GetBulletOfs( sal_uInt32 nLevel, sal_uInt16& nValue ) const 4910 { 4911 if ( ! ( ( nLevel < 5 ) && ( mpImplRuler->nFlags & ( 256 << nLevel ) ) ) ) 4912 return sal_False; 4913 nValue = mpImplRuler->nBulletOfs[ nLevel ]; 4914 return sal_True; 4915 } 4916 4917 PPTTextRulerInterpreter& PPTTextRulerInterpreter::operator=( PPTTextRulerInterpreter& rRuler ) 4918 { 4919 if ( this != &rRuler ) 4920 { 4921 if ( ! ( --mpImplRuler->nRefCount ) ) 4922 delete mpImplRuler; 4923 mpImplRuler = rRuler.mpImplRuler; 4924 mpImplRuler->nRefCount++; 4925 } 4926 return *this; 4927 } 4928 4929 PPTTextRulerInterpreter::~PPTTextRulerInterpreter() 4930 { 4931 if ( ! ( --mpImplRuler->nRefCount ) ) 4932 delete mpImplRuler; 4933 } 4934 4935 //////////////////////////////////////////////////////////////////////////////////////////////////// 4936 4937 PPTTextCharacterStyleAtomInterpreter::PPTTextCharacterStyleAtomInterpreter() : 4938 nFlags1 ( 0 ), 4939 nFlags2 ( 0 ), 4940 nFlags3 ( 0 ) 4941 { 4942 } 4943 4944 sal_Bool PPTTextCharacterStyleAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader& rRecHd ) 4945 { 4946 rRecHd.SeekToContent( rIn ); 4947 4948 rIn >> nFlags1 4949 >> nFlags2 4950 >> nFlags3 4951 >> n1 4952 >> nFontHeight 4953 >> nFontColor; 4954 4955 return sal_True; 4956 } 4957 4958 PPTTextCharacterStyleAtomInterpreter::~PPTTextCharacterStyleAtomInterpreter() 4959 { 4960 } 4961 4962 //////////////////////////////////////////////////////////////////////////////////////////////////// 4963 PPTTextParagraphStyleAtomInterpreter::PPTTextParagraphStyleAtomInterpreter() : 4964 bValid ( sal_False ), 4965 bForbiddenRules ( sal_False ), 4966 bHangingPunctuation ( sal_False ), 4967 bLatinTextWrap ( sal_False ) 4968 { 4969 } 4970 4971 sal_Bool PPTTextParagraphStyleAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader& rRecHd ) 4972 { 4973 bValid = sal_False; 4974 rRecHd.SeekToContent( rIn ); 4975 sal_uInt32 nDummy32, nFlags, nRecEndPos = rRecHd.GetRecEndFilePos(); 4976 sal_uInt16 nDummy16; 4977 4978 rIn >> nDummy16 4979 >> nFlags; 4980 4981 if ( nFlags & 0xf && ( rIn.Tell() < nRecEndPos ) ) 4982 rIn >> nDummy16; // BuFlags 4983 if ( nFlags & 0x80 && ( rIn.Tell() < nRecEndPos ) ) 4984 rIn >> nDummy16; // BuChar 4985 if ( nFlags & 0x10 && ( rIn.Tell() < nRecEndPos ) ) 4986 rIn >> nDummy16; // nBuFont; 4987 if ( nFlags & 0x40 && ( rIn.Tell() < nRecEndPos ) ) 4988 rIn >> nDummy16; // nBuHeight; 4989 if ( nFlags & 0x0020 && ( rIn.Tell() < nRecEndPos ) ) 4990 rIn >> nDummy32; // nBuColor; 4991 if ( nFlags & 0x800 && ( rIn.Tell() < nRecEndPos ) ) 4992 rIn >> nDummy16; // AbsJust! 4993 if ( nFlags & 0x400 && ( rIn.Tell() < nRecEndPos ) ) 4994 rIn >> nDummy16; 4995 if ( nFlags & 0x200 && ( rIn.Tell() < nRecEndPos ) ) 4996 rIn >> nDummy16; 4997 if ( nFlags & 0x100 && ( rIn.Tell() < nRecEndPos ) ) 4998 rIn >> nDummy16; 4999 if ( nFlags & 0x1000 && ( rIn.Tell() < nRecEndPos ) ) 5000 rIn >> nDummy16; // LineFeed 5001 if ( nFlags & 0x2000 && ( rIn.Tell() < nRecEndPos ) ) 5002 rIn >> nDummy16; // nUpperDist 5003 if ( nFlags & 0x4000 && ( rIn.Tell() < nRecEndPos ) ) 5004 rIn >> nDummy16; // nLowerDist 5005 if ( nFlags & 0x8000 && ( rIn.Tell() < nRecEndPos ) ) 5006 rIn >> nDummy16; 5007 if ( nFlags & 0x10000 && ( rIn.Tell() < nRecEndPos ) ) 5008 rIn >> nDummy16; 5009 if ( nFlags & 0xe0000 && ( rIn.Tell() < nRecEndPos ) ) 5010 { 5011 rIn >> nDummy16; 5012 if ( nFlags & 0x20000 ) 5013 bForbiddenRules = ( nDummy16 & 1 ) == 1; 5014 if ( nFlags & 0x40000 ) 5015 bLatinTextWrap = ( nDummy16 & 2 ) == 0; 5016 if ( nFlags & 0x80000 ) 5017 bHangingPunctuation = ( nDummy16 & 4 ) == 4; 5018 } 5019 nFlags &=~ 0xfffff; 5020 sal_uInt32 nMask = 0x100000; 5021 while ( nFlags && nMask && ( rIn.Tell() < nRecEndPos ) ) 5022 { 5023 if ( nFlags & nMask ) 5024 { 5025 rIn >> nDummy16; 5026 nFlags ^= nMask; 5027 } 5028 nMask <<= 1; 5029 } 5030 bValid = rIn.Tell() == nRecEndPos; 5031 return bValid; 5032 } 5033 5034 PPTTextParagraphStyleAtomInterpreter::~PPTTextParagraphStyleAtomInterpreter() 5035 { 5036 5037 } 5038 5039 //////////////////////////////////////////////////////////////////////////////////////////////////// 5040 5041 PPTTextSpecInfo::PPTTextSpecInfo( sal_uInt32 _nCharIdx ) : 5042 nCharIdx ( _nCharIdx ), 5043 nDontKnow ( 1 ) 5044 { 5045 nLanguage[ 0 ] = 0x400; 5046 nLanguage[ 1 ] = 0; 5047 nLanguage[ 2 ] = 0; 5048 } 5049 5050 PPTTextSpecInfo::~PPTTextSpecInfo() 5051 { 5052 } 5053 5054 PPTTextSpecInfoAtomInterpreter::PPTTextSpecInfoAtomInterpreter() : 5055 bValid ( sal_False ) 5056 { 5057 } 5058 5059 sal_Bool PPTTextSpecInfoAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader& rRecHd, 5060 sal_uInt16 nRecordType, const PPTTextSpecInfo* pTextSpecDefault ) 5061 { 5062 bValid = sal_False; 5063 sal_uInt32 nCharIdx = 0; 5064 rRecHd.SeekToContent( rIn ); 5065 5066 while ( rIn.Tell() < rRecHd.GetRecEndFilePos() ) 5067 { 5068 sal_uInt32 nCharCount, 5069 nFlags, i; 5070 5071 if ( nRecordType == PPT_PST_TextSpecInfoAtom ) 5072 { 5073 rIn >> nCharCount; 5074 nCharIdx += nCharCount; 5075 } 5076 rIn >> nFlags; 5077 5078 PPTTextSpecInfo* pEntry = new PPTTextSpecInfo( nCharIdx ); 5079 if ( pTextSpecDefault ) 5080 { 5081 pEntry->nDontKnow = pTextSpecDefault->nDontKnow; 5082 pEntry->nLanguage[ 0 ] = pTextSpecDefault->nLanguage[ 0 ]; 5083 pEntry->nLanguage[ 1 ] = pTextSpecDefault->nLanguage[ 1 ]; 5084 pEntry->nLanguage[ 2 ] = pTextSpecDefault->nLanguage[ 2 ]; 5085 } 5086 for ( i = 1; nFlags && i ; i <<= 1 ) 5087 { 5088 sal_uInt16 nLang = 0; 5089 switch( nFlags & i ) 5090 { 5091 case 0 : break; 5092 case 1 : rIn >> pEntry->nDontKnow; break; 5093 case 2 : rIn >> nLang; break; 5094 case 4 : rIn >> nLang; break; 5095 default : 5096 { 5097 rIn.SeekRel( 2 ); 5098 } 5099 } 5100 if ( nLang ) 5101 { 5102 // bug119985 2012.06.14 5103 if (i == 2) 5104 { 5105 pEntry->nLanguage[ 0 ] = pEntry->nLanguage[ 1 ] = pEntry->nLanguage[ 2 ] = nLang; 5106 } 5107 } 5108 nFlags &= ~i; 5109 } 5110 aList.Insert( pEntry, LIST_APPEND ); 5111 } 5112 bValid = rIn.Tell() == rRecHd.GetRecEndFilePos(); 5113 return bValid; 5114 } 5115 5116 PPTTextSpecInfoAtomInterpreter::~PPTTextSpecInfoAtomInterpreter() 5117 { 5118 void *pPtr; 5119 for ( pPtr = aList.First(); pPtr; pPtr = aList.Next() ) 5120 delete (PPTTextSpecInfo*)pPtr; 5121 } 5122 5123 //////////////////////////////////////////////////////////////////////////////////////////////////// 5124 5125 void StyleTextProp9::Read( SvStream& rIn ) 5126 { 5127 rIn >> mnExtParagraphMask; 5128 if ( mnExtParagraphMask & 0x800000 ) 5129 rIn >> mnBuBlip; 5130 if ( mnExtParagraphMask & 0x2000000 ) 5131 rIn >> mnHasAnm; 5132 if ( mnExtParagraphMask & 0x1000000 ) 5133 rIn >> mnAnmScheme; 5134 if ( mnExtParagraphMask & 0x4000000 ) 5135 rIn >> mpfPP10Ext; 5136 rIn >> mnExtCharacterMask; 5137 if ( mnExtCharacterMask & 0x100000 ) 5138 rIn >> mncfPP10Ext; 5139 rIn >> mnSpecialInfoMask; 5140 if ( mnSpecialInfoMask & 0x20 ) 5141 rIn >> mnPP10Ext; 5142 if ( mnSpecialInfoMask & 0x40 ) 5143 rIn >> mfBidi; 5144 } 5145 5146 PPTStyleTextPropReader::PPTStyleTextPropReader( SvStream& rIn, SdrPowerPointImport& rMan, const DffRecordHeader& rTextHeader, 5147 PPTTextRulerInterpreter& rRuler, const DffRecordHeader& rExtParaHd, sal_uInt32 nInstance ) 5148 { 5149 Init(rIn, rMan, rTextHeader, rRuler, rExtParaHd, nInstance); 5150 } 5151 5152 void PPTStyleTextPropReader::ReadParaProps( SvStream& rIn, SdrPowerPointImport& rMan, const DffRecordHeader& rTextHeader, 5153 const String& aString, PPTTextRulerInterpreter& rRuler, 5154 sal_uInt32& nCharCount, sal_Bool& bTextPropAtom ) 5155 { 5156 sal_uInt32 nMask = 0; //TODO: nMask initialized here to suppress warning for now, see corresponding TODO below 5157 sal_uInt32 nCharAnzRead = 0; 5158 sal_uInt16 nDummy16; 5159 5160 sal_uInt16 nStringLen = aString.Len(); 5161 5162 DffRecordHeader aTextHd2; 5163 rTextHeader.SeekToContent( rIn ); 5164 if ( rMan.SeekToRec( rIn, PPT_PST_StyleTextPropAtom, rTextHeader.GetRecEndFilePos(), &aTextHd2 ) ) 5165 bTextPropAtom = sal_True; 5166 while ( nCharAnzRead <= nStringLen ) 5167 { 5168 PPTParaPropSet aParaPropSet; 5169 ImplPPTParaPropSet& aSet = *aParaPropSet.pParaSet; 5170 if ( bTextPropAtom ) 5171 { 5172 rIn >> nCharCount 5173 >> aParaPropSet.pParaSet->mnDepth; // Einruecktiefe 5174 5175 aParaPropSet.pParaSet->mnDepth = // taking care of about using not more than 9 outliner levels 5176 std::min(sal_uInt16(8), 5177 aParaPropSet.pParaSet->mnDepth); 5178 5179 nCharCount--; 5180 5181 rIn >> nMask; 5182 aSet.mnAttrSet = nMask & 0x207df7; 5183 sal_uInt16 nBulFlg = 0; 5184 if ( nMask & 0xF ) 5185 rIn >> nBulFlg; // Bullet-HardAttr-Flags 5186 aSet.mpArry[ PPT_ParaAttr_BulletOn ] = ( nBulFlg & 1 ) ? 1 : 0; 5187 aSet.mpArry[ PPT_ParaAttr_BuHardFont ] = ( nBulFlg & 2 ) ? 1 : 0; 5188 aSet.mpArry[ PPT_ParaAttr_BuHardColor ] = ( nBulFlg & 4 ) ? 1 : 0; 5189 5190 if ( nMask & 0x0080 ) // buChar 5191 rIn >> aSet.mpArry[ PPT_ParaAttr_BulletChar ]; 5192 if ( nMask & 0x0010 ) // buTypeface 5193 rIn >> aSet.mpArry[ PPT_ParaAttr_BulletFont ]; 5194 if ( nMask & 0x0040 ) // buSize 5195 { 5196 rIn >> aSet.mpArry[ PPT_ParaAttr_BulletHeight ]; 5197 if ( ! ( ( nMask & ( 1 << PPT_ParaAttr_BuHardHeight ) ) 5198 && ( nBulFlg & ( 1 << PPT_ParaAttr_BuHardHeight ) ) ) ) 5199 aSet.mnAttrSet ^= 0x40; 5200 } 5201 if ( nMask & 0x0020 ) // buColor 5202 { 5203 sal_uInt32 nVal32, nHiByte; 5204 rIn >> nVal32; 5205 nHiByte = nVal32 >> 24; 5206 if ( nHiByte <= 8 ) 5207 nVal32 = nHiByte | PPT_COLSCHEME; 5208 aSet.mnBulletColor = nVal32; 5209 } 5210 if ( nMask & 0x0800 ) // pfAlignment 5211 { 5212 rIn >> nDummy16; 5213 aSet.mpArry[ PPT_ParaAttr_Adjust ] = nDummy16 & 3; 5214 } 5215 if ( nMask & 0x1000 ) // pfLineSpacing 5216 rIn >> aSet.mpArry[ PPT_ParaAttr_LineFeed ]; 5217 if ( nMask & 0x2000 ) // pfSpaceBefore 5218 rIn >> aSet.mpArry[ PPT_ParaAttr_UpperDist ]; 5219 if ( nMask & 0x4000 ) // pfSpaceAfter 5220 rIn >> aSet.mpArry[ PPT_ParaAttr_LowerDist ]; 5221 if ( nMask & 0x100 ) // pfLeftMargin 5222 { 5223 rIn >> aSet.mpArry[ PPT_ParaAttr_TextOfs ]; 5224 aSet.mnAttrSet |= 1 << PPT_ParaAttr_TextOfs; 5225 } 5226 if ( nMask & 0x400 ) // pfIndent 5227 { 5228 rIn >> aSet.mpArry[ PPT_ParaAttr_BulletOfs ]; 5229 aSet.mnAttrSet |= 1 << PPT_ParaAttr_BulletOfs; 5230 } 5231 if ( nMask & 0x8000 ) // pfDefaultTabSize 5232 rIn >> nDummy16; 5233 if ( nMask & 0x100000 ) // pfTabStops 5234 { 5235 sal_uInt16 i, nDistance, nAlignment, nNumberOfTabStops = 0; 5236 rIn >> nNumberOfTabStops; 5237 for ( i = 0; i < nNumberOfTabStops; i++ ) 5238 { 5239 rIn >> nDistance 5240 >> nAlignment; 5241 } 5242 } 5243 if ( nMask & 0x10000 ) // pfBaseLine 5244 rIn >> nDummy16; 5245 if ( nMask & 0xe0000 ) // pfCharWrap, pfWordWrap, pfOverflow 5246 { 5247 rIn >> nDummy16; 5248 if ( nMask & 0x20000 ) 5249 aSet.mpArry[ PPT_ParaAttr_AsianLB_1 ] = nDummy16 & 1; 5250 if ( nMask & 0x40000 ) 5251 aSet.mpArry[ PPT_ParaAttr_AsianLB_2 ] = ( nDummy16 >> 1 ) & 1; 5252 if ( nMask & 0x80000 ) 5253 aSet.mpArry[ PPT_ParaAttr_AsianLB_3 ] = ( nDummy16 >> 2 ) & 1; 5254 aSet.mnAttrSet |= ( ( nMask >> 17 ) & 7 ) << PPT_ParaAttr_AsianLB_1; 5255 } 5256 if ( nMask & 0x200000 ) // pfTextDirection 5257 rIn >> aSet.mpArry[ PPT_ParaAttr_BiDi ]; 5258 } 5259 else 5260 nCharCount = nStringLen; 5261 5262 //if the textofs attr has been read at above, need not to reset. 5263 if ( ( !( aSet.mnAttrSet & 1 << PPT_ParaAttr_TextOfs ) ) && rRuler.GetTextOfs( aParaPropSet.pParaSet->mnDepth, aSet.mpArry[ PPT_ParaAttr_TextOfs ] ) ) 5264 aSet.mnAttrSet |= 1 << PPT_ParaAttr_TextOfs; 5265 if ( ( !( aSet.mnAttrSet & 1 << PPT_ParaAttr_BulletOfs ) ) && rRuler.GetBulletOfs( aParaPropSet.pParaSet->mnDepth, aSet.mpArry[ PPT_ParaAttr_BulletOfs ] ) ) 5266 aSet.mnAttrSet |= 1 << PPT_ParaAttr_BulletOfs; 5267 if ( rRuler.GetDefaultTab( aParaPropSet.pParaSet->mnDepth, aSet.mpArry[ PPT_ParaAttr_DefaultTab ] ) ) 5268 aSet.mnAttrSet |= 1 << PPT_ParaAttr_DefaultTab; 5269 5270 if ( ( nCharCount > nStringLen ) || ( nStringLen < nCharAnzRead + nCharCount ) ) 5271 { 5272 bTextPropAtom = sal_False; 5273 nCharCount = nStringLen - nCharAnzRead; 5274 // please fix the right hand side of 5275 // PPTParaPropSet& PPTParaPropSet::operator=(PPTParaPropSet&), 5276 // it should be a const reference 5277 PPTParaPropSet aTmpPPTParaPropSet; 5278 aParaPropSet = aTmpPPTParaPropSet; 5279 DBG_ERROR( "SJ:PPTStyleTextPropReader::could not get this PPT_PST_StyleTextPropAtom by reading the paragraph attributes" ); 5280 } 5281 PPTParaPropSet* pPara = new PPTParaPropSet( aParaPropSet ); 5282 pPara->mnOriginalTextPos = nCharAnzRead; 5283 aParaPropList.Insert( pPara, LIST_APPEND ); 5284 if ( nCharCount ) 5285 { 5286 sal_uInt32 nCount; 5287 const sal_Unicode* pDat = aString.GetBuffer() + nCharAnzRead; 5288 for ( nCount = 0; nCount < nCharCount; nCount++ ) 5289 { 5290 if ( pDat[ nCount ] == 0xd ) 5291 { 5292 pPara = new PPTParaPropSet( aParaPropSet ); 5293 pPara->mnOriginalTextPos = nCharAnzRead + nCount + 1; 5294 aParaPropList.Insert( pPara, LIST_APPEND ); 5295 } 5296 } 5297 } 5298 nCharAnzRead += nCharCount + 1; 5299 } 5300 } 5301 5302 void PPTStyleTextPropReader::ReadCharProps( SvStream& rIn, PPTCharPropSet& aCharPropSet, const String& aString, 5303 sal_uInt32& nCharCount, sal_uInt32 nCharAnzRead, 5304 sal_Bool& bTextPropAtom, sal_uInt32 nExtParaPos, 5305 const std::vector< StyleTextProp9 >& aStyleTextProp9, 5306 sal_uInt32& nExtParaFlags, sal_uInt16& nBuBlip, 5307 sal_uInt16& nHasAnm, sal_uInt32& nAnmScheme ) 5308 { 5309 sal_uInt32 nMask = 0; //TODO: nMask initialized here to suppress warning for now, see corresponding TODO below 5310 sal_uInt16 nDummy16; 5311 sal_Int32 nCharsToRead; 5312 sal_uInt32 nExtParaNibble = 0; 5313 5314 sal_uInt16 nStringLen = aString.Len(); 5315 5316 rIn >> nDummy16; 5317 nCharCount = nDummy16; 5318 rIn >> nDummy16; 5319 nCharsToRead = nStringLen - ( nCharAnzRead + nCharCount ); 5320 if ( nCharsToRead < 0 ) 5321 { 5322 nCharCount = nStringLen - nCharAnzRead; 5323 if ( nCharsToRead < -1 ) 5324 { 5325 bTextPropAtom = sal_False; 5326 DBG_ERROR( "SJ:PPTStyleTextPropReader::could not get this PPT_PST_StyleTextPropAtom by reading the character attributes" ); 5327 } 5328 } 5329 ImplPPTCharPropSet& aSet = *aCharPropSet.pCharSet; 5330 5331 // character attributes 5332 rIn >> nMask; 5333 if ( (sal_uInt16)nMask ) 5334 { 5335 aSet.mnAttrSet |= (sal_uInt16)nMask; 5336 rIn >> aSet.mnFlags; 5337 } 5338 if ( nMask & 0x10000 ) // cfTypeface 5339 { 5340 rIn >> aSet.mnFont; 5341 aSet.mnAttrSet |= 1 << PPT_CharAttr_Font; 5342 } 5343 if ( nMask & 0x200000 ) // cfFEOldTypeface 5344 { 5345 rIn >> aSet.mnAsianOrComplexFont; 5346 aSet.mnAttrSet |= 1 << PPT_CharAttr_AsianOrComplexFont; 5347 } 5348 if ( nMask & 0x400000 ) // cfANSITypeface 5349 { 5350 rIn >> aSet.mnANSITypeface; 5351 aSet.mnAttrSet |= 1 << PPT_CharAttr_ANSITypeface; 5352 } 5353 if ( nMask & 0x800000 ) // cfSymbolTypeface 5354 { 5355 rIn >> aSet.mnSymbolFont; 5356 aSet.mnAttrSet |= 1 << PPT_CharAttr_Symbol; 5357 } 5358 if ( nMask & 0x20000 ) // cfSize 5359 { 5360 rIn >> aSet.mnFontHeight; 5361 aSet.mnAttrSet |= 1 << PPT_CharAttr_FontHeight; 5362 } 5363 if ( nMask & 0x40000 ) // cfColor 5364 { 5365 sal_uInt32 nVal; 5366 rIn >> nVal; 5367 if ( !( nVal & 0xff000000 ) ) 5368 nVal = PPT_COLSCHEME_HINTERGRUND; 5369 aSet.mnColor = nVal; 5370 aSet.mnAttrSet |= 1 << PPT_CharAttr_FontColor; 5371 } 5372 if ( nMask & 0x80000 ) // cfPosition 5373 { 5374 rIn >> aSet.mnEscapement; 5375 aSet.mnAttrSet |= 1 << PPT_CharAttr_Escapement; 5376 } 5377 if ( nExtParaPos ) 5378 { 5379 sal_uInt32 nExtBuInd = nMask & 0x3c00; 5380 if ( nExtBuInd ) 5381 nExtBuInd = ( aSet.mnFlags & 0x3c00 ) >> 10; 5382 if ( nExtBuInd < aStyleTextProp9.size() ) 5383 { 5384 if ( nExtParaNibble && ( ( nExtBuInd + nExtParaNibble ) < aStyleTextProp9.size() ) ) 5385 nExtBuInd += nExtParaNibble; 5386 5387 nExtParaFlags = aStyleTextProp9[ nExtBuInd ].mnExtParagraphMask; 5388 nBuBlip = aStyleTextProp9[ nExtBuInd ].mnBuBlip; 5389 nHasAnm = aStyleTextProp9[ nExtBuInd ].mnHasAnm; 5390 nAnmScheme = aStyleTextProp9[ nExtBuInd ].mnAnmScheme; 5391 } 5392 if ( ( nExtBuInd & 0xf ) == 0xf ) 5393 nExtParaNibble += 16; 5394 } 5395 } 5396 5397 void PPTStyleTextPropReader::Init( SvStream& rIn, SdrPowerPointImport& rMan, const DffRecordHeader& rTextHeader, 5398 PPTTextRulerInterpreter& rRuler, const DffRecordHeader& rExtParaHd, sal_uInt32 nInstance ) 5399 { 5400 sal_uInt32 nMerk = rIn.Tell(); 5401 sal_uInt32 nExtParaPos = ( rExtParaHd.nRecType == PPT_PST_ExtendedParagraphAtom ) ? rExtParaHd.nFilePos + 8 : 0; 5402 5403 std::vector< StyleTextProp9 > aStyleTextProp9; 5404 if ( rExtParaHd.nRecType == PPT_PST_ExtendedParagraphAtom ) 5405 { 5406 rIn.Seek( rExtParaHd.nFilePos + 8 ); 5407 while( ( rIn.GetError() == 0 ) && ( rIn.Tell() < rExtParaHd.GetRecEndFilePos() ) ) 5408 { 5409 aStyleTextProp9.resize( aStyleTextProp9.size() + 1 ); 5410 aStyleTextProp9.back().Read( rIn ); 5411 } 5412 rIn.Seek( nMerk ); 5413 } 5414 5415 String aString; 5416 DffRecordHeader aTextHd; 5417 rIn >> aTextHd; 5418 sal_uInt32 nMaxLen = aTextHd.nRecLen; 5419 if ( nMaxLen >= 0xFFFF ) 5420 nMaxLen = 0xFFFE; 5421 5422 if( aTextHd.nRecType == PPT_PST_TextCharsAtom ) 5423 { 5424 sal_uInt32 i; 5425 sal_Unicode nChar,*pBuf = new sal_Unicode[ ( nMaxLen >> 1 ) + 1 ]; 5426 rIn.Read( pBuf, nMaxLen ); 5427 nMaxLen >>= 1; 5428 pBuf[ nMaxLen ] = 0; 5429 sal_Unicode* pPtr = pBuf; 5430 #ifdef OSL_BIGENDIAN 5431 sal_Unicode nTemp; 5432 for ( i = 0; i < nMaxLen; i++ ) 5433 { 5434 nTemp = *pPtr; 5435 *pPtr++ = ( nTemp << 8 ) | ( nTemp >> 8 ); 5436 } 5437 pPtr = pBuf; 5438 #endif 5439 5440 for ( i = 0; i < nMaxLen; pPtr++, i++ ) 5441 { 5442 nChar = *pPtr; 5443 if ( !nChar ) 5444 break; 5445 if ( ( nChar & 0xff00 ) == 0xf000 ) // in this special case we got a symbol 5446 aSpecMarkerList.Insert( (void*)( i | PPT_SPEC_SYMBOL ), LIST_APPEND ); 5447 else if ( nChar == 0xd ) 5448 { 5449 if ( nInstance == TSS_TYPE_PAGETITLE ) 5450 *pPtr = 0xb; 5451 else 5452 aSpecMarkerList.Insert( (void*)( i | PPT_SPEC_NEWLINE ), LIST_APPEND ); 5453 } 5454 } 5455 if ( i ) 5456 aString = String( pBuf, (sal_uInt16)i ); 5457 delete[] pBuf; 5458 } 5459 else if( aTextHd.nRecType == PPT_PST_TextBytesAtom ) 5460 { 5461 sal_Char *pBuf = new sal_Char[ nMaxLen + 1 ]; 5462 pBuf[ nMaxLen ] = 0; 5463 rIn.Read( pBuf, nMaxLen ); 5464 sal_Char* pPtr = pBuf; 5465 for (;;) 5466 { 5467 sal_Char cLo = *pPtr; 5468 if ( cLo == 0 ) 5469 break; 5470 if ( cLo == 0xd ) 5471 { 5472 if ( nInstance == TSS_TYPE_PAGETITLE ) 5473 *pPtr = 0xb; 5474 else 5475 aSpecMarkerList.Insert( (void*)( (pPtr - pBuf) | PPT_SPEC_NEWLINE ), LIST_APPEND ); 5476 } 5477 pPtr++; 5478 } 5479 xub_StrLen nLen = sal::static_int_cast< xub_StrLen >( pPtr - pBuf ); 5480 if ( nLen ) 5481 aString = String( pBuf, nLen, RTL_TEXTENCODING_MS_1252 ); 5482 delete[] pBuf; 5483 } 5484 else 5485 { 5486 // no chars, but potentially char/para props? 5487 sal_uInt32 nCharCount; 5488 sal_Bool bTextPropAtom = sal_False; 5489 ReadParaProps( rIn, rMan, rTextHeader, aString, rRuler, nCharCount, bTextPropAtom ); 5490 5491 if ( bTextPropAtom ) 5492 { 5493 // yeah, StyleTextProp is there, read it all & push to 5494 // aParaPropList 5495 PPTCharPropSet aCharPropSet(0); 5496 aCharPropSet.mnOriginalTextPos = 0; 5497 5498 sal_uInt32 nCharAnzRead = 0; 5499 sal_uInt32 nExtParaFlags = 0, nAnmScheme = 0; 5500 sal_uInt16 nBuBlip = 0xffff, nHasAnm = 0; 5501 ReadCharProps( rIn, aCharPropSet, aString, nCharCount, nCharAnzRead, 5502 bTextPropAtom, nExtParaPos, aStyleTextProp9, nExtParaFlags, 5503 nBuBlip, nHasAnm, nAnmScheme ); 5504 5505 aCharPropList.Insert( 5506 new PPTCharPropSet( aCharPropSet, 0 ), LIST_APPEND ); 5507 } 5508 } 5509 5510 if ( aString.Len() ) 5511 { 5512 sal_uInt32 nCharCount; 5513 sal_Bool bTextPropAtom = sal_False; 5514 5515 ReadParaProps( rIn, rMan, rTextHeader, aString, rRuler, nCharCount, bTextPropAtom ); 5516 5517 sal_Bool bEmptyParaPossible = sal_True; 5518 sal_uInt32 nCharAnzRead = 0; 5519 sal_uInt32 nCurrentPara = 0; 5520 sal_uInt32 nCurrentSpecMarker = (sal_uInt32)(sal_uIntPtr)aSpecMarkerList.First(); 5521 sal_uInt16 nStringLen = aString.Len(); 5522 5523 while ( nCharAnzRead < nStringLen ) 5524 { 5525 sal_uInt32 nExtParaFlags = 0, nLatestParaUpdate = 0xffffffff, nAnmScheme = 0; 5526 sal_uInt16 nBuBlip = 0xffff, nHasAnm = 0; 5527 5528 PPTCharPropSet aCharPropSet( nCurrentPara ); 5529 if ( bTextPropAtom ) 5530 ReadCharProps( rIn, aCharPropSet, aString, nCharCount, nCharAnzRead, 5531 bTextPropAtom, nExtParaPos, aStyleTextProp9, nExtParaFlags, 5532 nBuBlip, nHasAnm, nAnmScheme ); 5533 else 5534 nCharCount = nStringLen; 5535 5536 sal_uInt32 nLen; 5537 while( nCharCount ) 5538 { 5539 if ( nExtParaPos && ( nLatestParaUpdate != nCurrentPara ) && ( nCurrentPara < aParaPropList.Count() ) ) 5540 { 5541 PPTParaPropSet* pPropSet = (PPTParaPropSet*)aParaPropList.GetObject( nCurrentPara ); 5542 pPropSet->pParaSet->mnExtParagraphMask = nExtParaFlags; 5543 if ( nExtParaFlags & 0x800000 ) 5544 pPropSet->pParaSet->mnBuBlip = nBuBlip; 5545 if ( nExtParaFlags & 0x01000000 ) 5546 pPropSet->pParaSet->mnAnmScheme = nAnmScheme; 5547 if ( nExtParaFlags & 0x02000000 ) 5548 pPropSet->pParaSet->mnHasAnm = nHasAnm; 5549 nLatestParaUpdate = nCurrentPara; 5550 } 5551 aCharPropSet.mnOriginalTextPos = nCharAnzRead; 5552 if ( nCurrentSpecMarker && ( ( nCurrentSpecMarker & 0xffff ) < ( nCharAnzRead + nCharCount ) ) ) 5553 { 5554 if ( nCurrentSpecMarker & PPT_SPEC_NEWLINE ) 5555 { 5556 nLen = ( nCurrentSpecMarker & 0xffff ) - nCharAnzRead; 5557 if ( nLen ) 5558 aCharPropSet.maString = String( aString, (sal_uInt16)nCharAnzRead, (sal_uInt16)nLen ); 5559 else if ( bEmptyParaPossible ) 5560 aCharPropSet.maString = String(); 5561 if ( nLen || bEmptyParaPossible ) 5562 aCharPropList.Insert( new PPTCharPropSet( aCharPropSet, nCurrentPara ), LIST_APPEND ); 5563 nCurrentPara++; 5564 nLen++; 5565 nCharAnzRead += nLen; 5566 nCharCount -= nLen; 5567 bEmptyParaPossible = sal_True; 5568 } 5569 else if ( nCurrentSpecMarker & PPT_SPEC_SYMBOL ) 5570 { 5571 if ( ( nCurrentSpecMarker & 0xffff ) != nCharAnzRead ) 5572 { 5573 nLen = ( nCurrentSpecMarker & 0xffff ) - nCharAnzRead; 5574 aCharPropSet.maString = String( aString, (sal_uInt16)nCharAnzRead, (sal_uInt16)nLen ); 5575 aCharPropList.Insert( new PPTCharPropSet( aCharPropSet, nCurrentPara ), LIST_APPEND ); 5576 nCharCount -= nLen; 5577 nCharAnzRead += nLen; 5578 } 5579 PPTCharPropSet* pCPropSet = new PPTCharPropSet( aCharPropSet, nCurrentPara ); 5580 pCPropSet->maString = aString.GetChar( (sal_uInt16)nCharAnzRead ); 5581 if ( aCharPropSet.pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_Symbol ) ) 5582 pCPropSet->SetFont( aCharPropSet.pCharSet->mnSymbolFont ); 5583 aCharPropList.Insert( pCPropSet, LIST_APPEND ); 5584 nCharCount--; 5585 nCharAnzRead++; 5586 bEmptyParaPossible = sal_False; 5587 } 5588 nCurrentSpecMarker = (sal_uInt32)(sal_uIntPtr)aSpecMarkerList.Next(); 5589 } 5590 else 5591 { 5592 aCharPropSet.maString = String( aString, (sal_uInt16)nCharAnzRead, (sal_uInt16)nCharCount ); 5593 aCharPropList.Insert( new PPTCharPropSet( aCharPropSet, nCurrentPara ), LIST_APPEND ); 5594 nCharAnzRead += nCharCount; 5595 bEmptyParaPossible = sal_False; 5596 break; 5597 } 5598 } 5599 } 5600 if ( aCharPropList.Count() && ( ((PPTCharPropSet*)aCharPropList.Last())->mnParagraph != nCurrentPara ) ) 5601 { 5602 PPTCharPropSet* pCharPropSet = new PPTCharPropSet( *(PPTCharPropSet*)aCharPropList.Last(), nCurrentPara ); 5603 pCharPropSet->maString = String(); 5604 pCharPropSet->mnOriginalTextPos = nStringLen - 1; 5605 aCharPropList.Insert( pCharPropSet, LIST_APPEND ); 5606 } 5607 } 5608 rIn.Seek( nMerk ); 5609 } 5610 5611 PPTStyleTextPropReader::~PPTStyleTextPropReader() 5612 { 5613 void* pTmp; 5614 for ( pTmp = aParaPropList.First(); pTmp; pTmp = aParaPropList.Next() ) 5615 delete (PPTParaPropSet*)pTmp; 5616 for ( pTmp = aCharPropList.First(); pTmp; pTmp = aCharPropList.Next() ) 5617 delete (PPTCharPropSet*)pTmp; 5618 } 5619 5620 //////////////////////////////////////////////////////////////////////////////////////////////////// 5621 5622 struct FieldEntry 5623 { 5624 sal_uInt32 nFieldType; 5625 sal_uInt32 nFieldStartPos; 5626 sal_uInt32 nFieldEndPos; 5627 String aFieldUrl; 5628 5629 FieldEntry( sal_uInt32 nType, sal_uInt32 nStart, sal_uInt32 nEnd ) 5630 { 5631 nFieldType = nType; 5632 nFieldStartPos = nStart; 5633 nFieldEndPos = nEnd; 5634 } 5635 FieldEntry( FieldEntry& rFieldEntry ) 5636 { 5637 nFieldType = rFieldEntry.nFieldType; 5638 nFieldStartPos = rFieldEntry.nFieldStartPos; 5639 nFieldEndPos = rFieldEntry.nFieldEndPos; 5640 aFieldUrl = rFieldEntry.aFieldUrl; 5641 } 5642 }; 5643 5644 5645 PPTPortionObj::PPTPortionObj( const PPTStyleSheet& rStyleSheet, sal_uInt32 nInstance, sal_uInt32 nDepth ) : 5646 PPTCharPropSet ( 0 ), 5647 mrStyleSheet ( rStyleSheet ), 5648 mnInstance ( nInstance ), 5649 mnDepth ( ( nDepth > 4 ) ? 4 : nDepth ) 5650 { 5651 } 5652 5653 PPTPortionObj::PPTPortionObj( PPTCharPropSet& rCharPropSet, const PPTStyleSheet& rStyleSheet, sal_uInt32 nInstance, sal_uInt32 nDepth ) : 5654 PPTCharPropSet ( rCharPropSet ), 5655 mrStyleSheet ( rStyleSheet ), 5656 mnInstance ( nInstance ), 5657 mnDepth ( nDepth ) 5658 { 5659 } 5660 5661 PPTPortionObj::PPTPortionObj( PPTPortionObj& rPortionObj ) : 5662 PPTCharPropSet ( rPortionObj ), 5663 mrStyleSheet ( rPortionObj.mrStyleSheet ), 5664 mnInstance ( rPortionObj.mnInstance ), 5665 mnDepth ( rPortionObj.mnDepth ) 5666 { 5667 } 5668 5669 PPTPortionObj::~PPTPortionObj() 5670 { 5671 } 5672 5673 sal_Bool PPTPortionObj::HasTabulator() 5674 { 5675 sal_Bool bRetValue = sal_False; 5676 sal_Int32 nCount; 5677 const sal_Unicode* pPtr = maString.GetBuffer(); 5678 for ( nCount = 0; nCount < maString.Len(); nCount++ ) 5679 { 5680 if ( pPtr[ nCount ] == 0x9 ) 5681 { 5682 bRetValue = sal_True; 5683 break; 5684 } 5685 5686 } 5687 return bRetValue; 5688 } 5689 5690 sal_Bool PPTPortionObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& nRetValue, sal_uInt32 nDestinationInstance ) 5691 { 5692 sal_uInt32 nMask = 1 << nAttr; 5693 nRetValue = 0; 5694 5695 sal_uInt32 bIsHardAttribute = ( ( pCharSet->mnAttrSet & nMask ) != 0 ) ? 1 : 0; 5696 5697 if ( bIsHardAttribute ) 5698 { 5699 switch ( nAttr ) 5700 { 5701 case PPT_CharAttr_Bold : 5702 case PPT_CharAttr_Italic : 5703 case PPT_CharAttr_Underline : 5704 case PPT_CharAttr_Shadow : 5705 case PPT_CharAttr_Strikeout : 5706 case PPT_CharAttr_Embossed : 5707 nRetValue = ( pCharSet->mnFlags & nMask ) ? 1 : 0; 5708 break; 5709 case PPT_CharAttr_Font : 5710 nRetValue = pCharSet->mnFont; 5711 break; 5712 case PPT_CharAttr_AsianOrComplexFont : 5713 nRetValue = pCharSet->mnAsianOrComplexFont; 5714 break; 5715 case PPT_CharAttr_FontHeight : 5716 nRetValue = pCharSet->mnFontHeight; 5717 break; 5718 case PPT_CharAttr_FontColor : 5719 nRetValue = pCharSet->mnColor; 5720 break; 5721 case PPT_CharAttr_Escapement : 5722 nRetValue = pCharSet->mnEscapement; 5723 break; 5724 default : 5725 DBG_ERROR( "SJ:PPTPortionObj::GetAttrib ( hard attribute does not exist )" ); 5726 } 5727 } 5728 else 5729 { 5730 const PPTCharLevel& rCharLevel = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ mnDepth ]; 5731 PPTCharLevel* pCharLevel = NULL; 5732 if ( ( nDestinationInstance == 0xffffffff ) 5733 || ( mnDepth && ( ( mnInstance == TSS_TYPE_SUBTITLE ) || ( mnInstance == TSS_TYPE_TEXT_IN_SHAPE ) ) ) ) 5734 bIsHardAttribute = 1; 5735 else if ( nDestinationInstance != mnInstance ) 5736 pCharLevel = &mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ mnDepth ]; 5737 switch( nAttr ) 5738 { 5739 case PPT_CharAttr_Bold : 5740 case PPT_CharAttr_Italic : 5741 case PPT_CharAttr_Underline : 5742 case PPT_CharAttr_Shadow : 5743 case PPT_CharAttr_Strikeout : 5744 case PPT_CharAttr_Embossed : 5745 { 5746 nRetValue = ( rCharLevel.mnFlags & nMask ) ? 1 : 0; 5747 if ( pCharLevel ) 5748 { 5749 sal_uInt32 nTmp = ( pCharLevel->mnFlags & nMask ) ? 1 : 0; 5750 if ( nRetValue != nTmp ) 5751 bIsHardAttribute = 1; 5752 } 5753 } 5754 break; 5755 case PPT_CharAttr_Font : 5756 { 5757 nRetValue = rCharLevel.mnFont; 5758 if ( pCharLevel && ( nRetValue != pCharLevel->mnFont ) ) 5759 bIsHardAttribute = 1; 5760 } 5761 break; 5762 case PPT_CharAttr_AsianOrComplexFont : 5763 { 5764 nRetValue = rCharLevel.mnAsianOrComplexFont; 5765 if ( pCharLevel && ( nRetValue != pCharLevel->mnAsianOrComplexFont ) ) 5766 bIsHardAttribute = 1; 5767 } 5768 break; 5769 case PPT_CharAttr_FontHeight : 5770 { 5771 nRetValue = rCharLevel.mnFontHeight; 5772 if ( pCharLevel && ( nRetValue != pCharLevel->mnFontHeight ) ) 5773 bIsHardAttribute = 1; 5774 } 5775 break; 5776 case PPT_CharAttr_FontColor : 5777 { 5778 nRetValue = rCharLevel.mnFontColor; 5779 if ( pCharLevel && ( nRetValue != pCharLevel->mnFontColor ) ) 5780 bIsHardAttribute = 1; 5781 } 5782 break; 5783 case PPT_CharAttr_Escapement : 5784 { 5785 nRetValue = rCharLevel.mnEscapement; 5786 if ( pCharLevel && ( nRetValue != pCharLevel->mnEscapement ) ) 5787 bIsHardAttribute = 1; 5788 } 5789 break; 5790 default : 5791 DBG_ERROR( "SJ:PPTPortionObj::GetAttrib ( attribute does not exist )" ); 5792 } 5793 } 5794 return (sal_Bool)bIsHardAttribute; 5795 } 5796 5797 void PPTPortionObj::ApplyTo( SfxItemSet& rSet, SdrPowerPointImport& rManager, sal_uInt32 nDestinationInstance ) 5798 { 5799 ApplyTo( rSet, rManager, nDestinationInstance, NULL ); 5800 } 5801 5802 void PPTPortionObj::ApplyTo( SfxItemSet& rSet, SdrPowerPointImport& rManager, sal_uInt32 nDestinationInstance, const PPTTextObj* pTextObj ) 5803 { 5804 sal_uInt32 nVal; 5805 if ( GetAttrib( PPT_CharAttr_Bold, nVal, nDestinationInstance ) ) 5806 { 5807 rSet.Put( SvxWeightItem( nVal != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) ); 5808 rSet.Put( SvxWeightItem( nVal != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) ); 5809 rSet.Put( SvxWeightItem( nVal != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) ); 5810 } 5811 if ( GetAttrib( PPT_CharAttr_Italic, nVal, nDestinationInstance ) ) 5812 { 5813 rSet.Put( SvxPostureItem( nVal != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC ) ); 5814 rSet.Put( SvxPostureItem( nVal != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC_CJK ) ); 5815 rSet.Put( SvxPostureItem( nVal != 0 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC_CTL ) ); 5816 } 5817 if ( GetAttrib( PPT_CharAttr_Underline, nVal, nDestinationInstance ) ) 5818 rSet.Put( SvxUnderlineItem( nVal != 0 ? UNDERLINE_SINGLE : UNDERLINE_NONE, EE_CHAR_UNDERLINE ) ); 5819 5820 if ( GetAttrib( PPT_CharAttr_Shadow, nVal, nDestinationInstance ) ) 5821 rSet.Put( SvxShadowedItem( nVal != 0, EE_CHAR_SHADOW ) ); 5822 5823 if ( GetAttrib( PPT_CharAttr_Strikeout, nVal, nDestinationInstance ) ) 5824 rSet.Put( SvxCrossedOutItem( nVal != 0 ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) ); 5825 5826 sal_uInt32 nAsianFontId = 0xffff; 5827 if ( GetAttrib( PPT_CharAttr_AsianOrComplexFont, nAsianFontId, nDestinationInstance ) ) 5828 { 5829 if ( nAsianFontId != 0xffff ) 5830 { 5831 PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nAsianFontId ); 5832 if ( pFontEnityAtom ) 5833 { 5834 rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName, 5835 String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO_CJK ) ); 5836 rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName, 5837 String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO_CTL ) ); 5838 } 5839 } 5840 } 5841 if ( GetAttrib( PPT_CharAttr_Font, nVal, nDestinationInstance ) ) 5842 { 5843 PptFontEntityAtom* pFontEnityAtom = rManager.GetFontEnityAtom( nVal ); 5844 if ( pFontEnityAtom ) 5845 { 5846 rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName, String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO ) ); 5847 5848 // #119475# bullet font info for CJK and CTL 5849 if ( RTL_TEXTENCODING_SYMBOL == pFontEnityAtom->eCharSet ) 5850 { 5851 rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName, String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO_CJK ) ); 5852 rSet.Put( SvxFontItem( pFontEnityAtom->eFamily, pFontEnityAtom->aName, String(), pFontEnityAtom->ePitch, pFontEnityAtom->eCharSet, EE_CHAR_FONTINFO_CTL ) ); 5853 } 5854 } 5855 } 5856 if ( GetAttrib( PPT_CharAttr_FontHeight, nVal, nDestinationInstance ) ) // Schriftgrad in Point 5857 { 5858 sal_uInt32 nHeight = rManager.ScalePoint( nVal ); 5859 rSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) ); 5860 rSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) ); 5861 rSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) ); 5862 } 5863 5864 if ( GetAttrib( PPT_CharAttr_Embossed, nVal, nDestinationInstance ) ) 5865 rSet.Put( SvxCharReliefItem( nVal != 0 ? RELIEF_EMBOSSED : RELIEF_NONE, EE_CHAR_RELIEF ) ); 5866 if ( nVal ) /* if Embossed is set, the font color depends to the fillstyle/color of the object, 5867 if the object has no fillstyle, the font color depends to fillstyle of the background */ 5868 { 5869 Color aDefColor( COL_BLACK ); 5870 MSO_FillType eFillType = mso_fillSolid; 5871 if ( rManager.GetPropertyValue( DFF_Prop_fNoFillHitTest ) & 0x10 ) 5872 eFillType = (MSO_FillType)rManager.GetPropertyValue( DFF_Prop_fillType, mso_fillSolid ); 5873 else 5874 eFillType = mso_fillBackground; 5875 switch( eFillType ) 5876 { 5877 case mso_fillShade : 5878 case mso_fillShadeCenter : 5879 case mso_fillShadeShape : 5880 case mso_fillShadeScale : 5881 case mso_fillShadeTitle : 5882 case mso_fillSolid : 5883 aDefColor = rManager.MSO_CLR_ToColor( rManager.GetPropertyValue( DFF_Prop_fillColor ) ); 5884 break; 5885 case mso_fillPattern : 5886 aDefColor = rManager.MSO_CLR_ToColor( rManager.GetPropertyValue( DFF_Prop_fillBackColor ) ); 5887 break; 5888 case mso_fillTexture : 5889 { 5890 Graphic aGraf; 5891 if ( rManager.GetBLIP( rManager.GetPropertyValue( DFF_Prop_fillBlip ), aGraf, NULL ) ) 5892 { 5893 Bitmap aBmp( aGraf.GetBitmap() ); 5894 Size aSize( aBmp.GetSizePixel() ); 5895 if ( aSize.Width() && aSize.Height() ) 5896 { 5897 if ( aSize.Width () > 64 ) 5898 aSize.Width () = 64; 5899 if ( aSize.Height() > 64 ) 5900 aSize.Height() = 64; 5901 5902 sal_uLong nRt = 0, nGn = 0, nBl = 0; 5903 BitmapReadAccess* pAcc = aBmp.AcquireReadAccess(); 5904 if( pAcc ) 5905 { 5906 const long nWidth = aSize.Width(); 5907 const long nHeight = aSize.Height(); 5908 5909 if( pAcc->HasPalette() ) 5910 { 5911 for( long nY = 0L; nY < nHeight; nY++ ) 5912 { 5913 for( long nX = 0L; nX < nWidth; nX++ ) 5914 { 5915 const BitmapColor& rCol = pAcc->GetPaletteColor( pAcc->GetPixelIndex( nY, nX ) ); 5916 nRt+=rCol.GetRed(); nGn+=rCol.GetGreen(); nBl+=rCol.GetBlue(); 5917 } 5918 } 5919 } 5920 else 5921 { 5922 for( long nY = 0L; nY < nHeight; nY++ ) 5923 { 5924 for( long nX = 0L; nX < nWidth; nX++ ) 5925 { 5926 const BitmapColor aCol( pAcc->GetPixel( nY, nX ) ); 5927 nRt+=aCol.GetRed(); nGn+=aCol.GetGreen(); nBl+=aCol.GetBlue(); 5928 } 5929 } 5930 } 5931 aBmp.ReleaseAccess( pAcc ); 5932 sal_uInt32 nC = ( aSize.Width() * aSize.Height() ); 5933 nRt /= nC; 5934 nGn /= nC; 5935 nBl /= nC; 5936 aDefColor = Color(sal_uInt8( nRt ), sal_uInt8( nGn ),sal_uInt8( nBl ) ); 5937 } 5938 } 5939 } 5940 } 5941 break; 5942 case mso_fillBackground : 5943 { 5944 if ( pTextObj ) // the textobject is needed 5945 { 5946 const SfxItemSet* pItemSet = pTextObj->GetBackground(); 5947 if ( pItemSet ) 5948 { 5949 const SfxPoolItem* pFillStyleItem = NULL; 5950 pItemSet->GetItemState( XATTR_FILLSTYLE, sal_False, &pFillStyleItem ); 5951 if ( pFillStyleItem ) 5952 { 5953 XFillStyle eFillStyle = ((XFillStyleItem*)pFillStyleItem)->GetValue(); 5954 switch( eFillStyle ) 5955 { 5956 case XFILL_SOLID : 5957 { 5958 const SfxPoolItem* pFillColorItem = NULL; 5959 pItemSet->GetItemState( XATTR_FILLCOLOR, sal_False, &pFillColorItem ); 5960 if ( pFillColorItem ) 5961 aDefColor = ((XColorItem*)pFillColorItem)->GetColorValue(); 5962 } 5963 break; 5964 case XFILL_GRADIENT : 5965 { 5966 const SfxPoolItem* pGradientItem = NULL; 5967 pItemSet->GetItemState( XATTR_FILLGRADIENT, sal_False, &pGradientItem ); 5968 if ( pGradientItem ) 5969 aDefColor = ((XFillGradientItem*)pGradientItem)->GetGradientValue().GetStartColor(); 5970 } 5971 break; 5972 case XFILL_HATCH : 5973 case XFILL_BITMAP : 5974 aDefColor = Color( COL_WHITE ); 5975 break; 5976 default: break; 5977 } 5978 } 5979 } 5980 } 5981 } 5982 break; 5983 // case mso_fillPicture : 5984 default: break; 5985 } 5986 rSet.Put( SvxColorItem( aDefColor, EE_CHAR_COLOR ) ); 5987 } 5988 else 5989 { 5990 if ( GetAttrib( PPT_CharAttr_FontColor, nVal, nDestinationInstance ) ) // Textfarbe (4Byte-Arg) 5991 { 5992 Color aCol( rManager.MSO_TEXT_CLR_ToColor( nVal ) ); 5993 rSet.Put( SvxColorItem( aCol, EE_CHAR_COLOR ) ); 5994 if ( nDestinationInstance == 0xffffffff ) 5995 mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ mnDepth ].mnFontColorInStyleSheet = aCol; 5996 } 5997 else if ( nVal & 0x0f000000 ) // this is not a hard attribute, but maybe the page has a different colerscheme, 5998 { // so that in this case we must use a hard color attribute 5999 Color aCol( rManager.MSO_TEXT_CLR_ToColor( nVal ) ); 6000 Color& aColorInSheet = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ mnDepth ].mnFontColorInStyleSheet; 6001 if ( aColorInSheet != aCol ) 6002 rSet.Put( SvxColorItem( aCol, EE_CHAR_COLOR ) ); 6003 } 6004 } 6005 6006 if ( GetAttrib( PPT_CharAttr_Escapement, nVal, nDestinationInstance ) ) // Hoch/Tiefstellung in % 6007 { 6008 sal_uInt16 nEsc = 0; 6009 sal_uInt8 nProp = 100; 6010 6011 if ( nVal ) 6012 { 6013 nEsc = (sal_Int16)nVal; 6014 nProp = DFLT_ESC_PROP; 6015 } 6016 SvxEscapementItem aItem( nEsc, nProp, EE_CHAR_ESCAPEMENT ); 6017 rSet.Put( aItem ); 6018 } 6019 if ( mnLanguage[ 0 ] ) 6020 rSet.Put( SvxLanguageItem( mnLanguage[ 0 ], EE_CHAR_LANGUAGE ) ); 6021 if ( mnLanguage[ 1 ] ) 6022 rSet.Put( SvxLanguageItem( mnLanguage[ 1 ], EE_CHAR_LANGUAGE_CJK ) ); 6023 if ( mnLanguage[ 2 ] ) 6024 rSet.Put( SvxLanguageItem( mnLanguage[ 2 ], EE_CHAR_LANGUAGE_CTL ) ); 6025 } 6026 6027 SvxFieldItem* PPTPortionObj::GetTextField() 6028 { 6029 if ( mpFieldItem ) 6030 return new SvxFieldItem( *mpFieldItem ); 6031 return NULL; 6032 } 6033 6034 // ----------------------------------------------------------------------- 6035 6036 PPTParagraphObj::PPTParagraphObj( const PPTStyleSheet& rStyleSheet, sal_uInt32 nInstance, sal_uInt16 nDepth ) : 6037 PPTNumberFormatCreator ( NULL ), 6038 mrStyleSheet ( rStyleSheet ), 6039 mnInstance ( nInstance ), 6040 mbTab ( sal_True ), // style sheets always have to get the right tabulator setting 6041 mnPortionCount ( 0 ), 6042 mpPortionList ( NULL ) 6043 { 6044 if ( nDepth > 4 ) 6045 nDepth = 4; 6046 pParaSet->mnDepth = nDepth; 6047 } 6048 6049 PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader, const PPTStyleSheet& rStyleSheet, 6050 sal_uInt32 nInstance, PPTTextRulerInterpreter& rRuler ) : 6051 PPTParaPropSet ( *( (PPTParaPropSet*)rPropReader.aParaPropList.GetCurObject() ) ), 6052 PPTNumberFormatCreator ( NULL ), 6053 PPTTextRulerInterpreter ( rRuler ), 6054 mrStyleSheet ( rStyleSheet ), 6055 mnInstance ( nInstance ), 6056 mbTab ( sal_False ), 6057 mnCurrentObject ( 0 ), 6058 mnPortionCount ( 0 ), 6059 mpPortionList ( NULL ) 6060 { 6061 sal_uInt32 nCurPos = rPropReader.aCharPropList.GetCurPos(); 6062 PPTCharPropSet* pCharPropSet = (PPTCharPropSet*)rPropReader.aCharPropList.GetCurObject(); 6063 if ( pCharPropSet ) 6064 { 6065 sal_uInt32 nCurrentParagraph = pCharPropSet->mnParagraph; 6066 for ( ; pCharPropSet && ( pCharPropSet->mnParagraph == nCurrentParagraph ); pCharPropSet = (PPTCharPropSet*)rPropReader.aCharPropList.Next() ) 6067 mnPortionCount++; // counting number of portions that are part of this paragraph 6068 pCharPropSet = (PPTCharPropSet*)rPropReader.aCharPropList.Seek( nCurPos ); 6069 6070 mpPortionList = new PPTPortionObj*[ mnPortionCount ]; 6071 for ( sal_uInt32 i = 0; i < mnPortionCount; i++ ) 6072 { 6073 if ( pCharPropSet ) 6074 { 6075 PPTPortionObj* pPPTPortion = new PPTPortionObj( *pCharPropSet, rStyleSheet, nInstance, pParaSet->mnDepth ); 6076 mpPortionList[ i ] = pPPTPortion; 6077 if ( !mbTab ) 6078 mbTab = mpPortionList[ i ]->HasTabulator(); 6079 } 6080 else 6081 { 6082 DBG_ERROR( "SJ:PPTParagraphObj::It seems that there are missing some textportions" ); 6083 mpPortionList[ i ] = NULL; 6084 } 6085 pCharPropSet = (PPTCharPropSet*)rPropReader.aCharPropList.Next(); 6086 } 6087 } 6088 } 6089 6090 PPTParagraphObj::~PPTParagraphObj() 6091 { 6092 ImplClear(); 6093 } 6094 6095 void PPTParagraphObj::AppendPortion( PPTPortionObj& rPPTPortion ) 6096 { 6097 sal_uInt32 i; 6098 PPTPortionObj** mpOldPortionList = mpPortionList; 6099 mpPortionList = new PPTPortionObj*[ ++mnPortionCount ]; 6100 for ( i = 0; i < mnPortionCount - 1; i++ ) 6101 mpPortionList[ i ] = mpOldPortionList[ i ]; 6102 delete[] mpOldPortionList; 6103 mpPortionList[ mnPortionCount - 1 ] = new PPTPortionObj( rPPTPortion ); 6104 if ( !mbTab ) 6105 mbTab = mpPortionList[ mnPortionCount - 1 ]->HasTabulator(); 6106 } 6107 6108 void PPTParagraphObj::UpdateBulletRelSize( sal_uInt32& nBulletRelSize ) const 6109 { 6110 if ( nBulletRelSize > 0x7fff ) // a negative value is the absolute bullet height 6111 { 6112 sal_uInt16 nFontHeight = 0; 6113 if ( mpPortionList ) 6114 { 6115 PPTPortionObj* pPortion = mpPortionList[ 0 ]; 6116 if ( pPortion && ( pPortion->pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_FontHeight ) ) ) 6117 nFontHeight = pPortion->pCharSet->mnFontHeight; 6118 } 6119 // if we do not have a hard attributed fontheight, the fontheight is taken from the style 6120 if ( !nFontHeight ) 6121 nFontHeight = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontHeight; 6122 nBulletRelSize = nFontHeight ? ((-((sal_Int16)nBulletRelSize)) * 100 ) / nFontHeight : 100; 6123 } 6124 } 6125 6126 sal_Bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& nRetValue, sal_uInt32 nDestinationInstance ) 6127 { 6128 sal_uInt32 nMask = 1 << nAttr; 6129 nRetValue = 0; 6130 6131 if ( nAttr > 21 ) 6132 { 6133 DBG_ERROR( "SJ:PPTParagraphObj::GetAttrib - attribute does not exist" ); 6134 return sal_False; 6135 } 6136 6137 sal_uInt32 bIsHardAttribute = ( ( pParaSet->mnAttrSet & nMask ) != 0 ) ? 1 : 0; 6138 6139 if ( bIsHardAttribute ) 6140 { 6141 if ( nAttr == PPT_ParaAttr_BulletColor ) 6142 { 6143 sal_Bool bHardBulletColor; 6144 if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardColor ) ) 6145 bHardBulletColor = pParaSet->mpArry[ PPT_ParaAttr_BuHardColor ] != 0; 6146 else 6147 bHardBulletColor = ( mrStyleSheet.mpParaSheet[ mnInstance ]->maParaLevel[ pParaSet->mnDepth ].mnBuFlags 6148 & ( 1 << PPT_ParaAttr_BuHardColor ) ) != 0; 6149 if ( bHardBulletColor ) 6150 nRetValue = pParaSet->mnBulletColor; 6151 else 6152 { 6153 nRetValue = PPT_COLSCHEME_TEXT_UND_ZEILEN; 6154 if ( ( nDestinationInstance != 0xffffffff ) && mnPortionCount ) 6155 { 6156 PPTPortionObj* pPortion = mpPortionList[ 0 ]; 6157 if ( pPortion ) 6158 { 6159 if ( pPortion->pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_FontColor ) ) 6160 nRetValue = pPortion->pCharSet->mnColor; 6161 else 6162 nRetValue = mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontColor; 6163 } 6164 } 6165 } 6166 } 6167 else if ( nAttr == PPT_ParaAttr_BulletFont ) 6168 { 6169 sal_Bool bHardBuFont; 6170 if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardFont ) ) 6171 bHardBuFont = pParaSet->mpArry[ PPT_ParaAttr_BuHardFont ] != 0; 6172 else 6173 bHardBuFont = ( mrStyleSheet.mpParaSheet[ mnInstance ]->maParaLevel[ pParaSet->mnDepth ].mnBuFlags 6174 & ( 1 << PPT_ParaAttr_BuHardFont ) ) != 0; 6175 if ( bHardBuFont ) 6176 nRetValue = pParaSet->mpArry[ PPT_ParaAttr_BulletFont ]; 6177 else 6178 { 6179 // it is the font used which assigned to the first character of the following text 6180 nRetValue = 0; 6181 if ( ( nDestinationInstance != 0xffffffff ) && mnPortionCount ) 6182 { 6183 PPTPortionObj* pPortion = mpPortionList[ 0 ]; 6184 if ( pPortion ) 6185 { 6186 if ( pPortion->pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_Font ) ) 6187 nRetValue = pPortion->pCharSet->mnFont; 6188 else 6189 nRetValue = mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFont; 6190 } 6191 } 6192 } 6193 } 6194 else 6195 nRetValue = pParaSet->mpArry[ nAttr ]; 6196 } 6197 else 6198 { 6199 const PPTParaLevel& rParaLevel = mrStyleSheet.mpParaSheet[ mnInstance ]->maParaLevel[ pParaSet->mnDepth ]; 6200 6201 PPTParaLevel* pParaLevel = NULL; 6202 if ( ( nDestinationInstance == 0xffffffff ) 6203 || ( pParaSet->mnDepth && ( ( mnInstance == TSS_TYPE_SUBTITLE ) || ( mnInstance == TSS_TYPE_TEXT_IN_SHAPE ) ) ) ) 6204 bIsHardAttribute = 1; 6205 else if ( nDestinationInstance != mnInstance ) 6206 pParaLevel = &mrStyleSheet.mpParaSheet[ nDestinationInstance ]->maParaLevel[ pParaSet->mnDepth ]; 6207 switch ( nAttr ) 6208 { 6209 case PPT_ParaAttr_BulletOn : 6210 { 6211 nRetValue = rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BulletOn ); 6212 if ( pParaLevel ) 6213 { 6214 if ( nRetValue != ( (sal_uInt32)pParaLevel->mnBuFlags & ( 1 << PPT_ParaAttr_BulletOn ) ) ) 6215 bIsHardAttribute = 1; 6216 } 6217 } 6218 break; 6219 case PPT_ParaAttr_BuHardFont : 6220 case PPT_ParaAttr_BuHardColor : 6221 case PPT_ParaAttr_BuHardHeight : 6222 DBG_ERROR( "SJ:PPTParagraphObj::GetAttrib - this attribute does not make sense" ); 6223 break; 6224 case PPT_ParaAttr_BulletChar : 6225 { 6226 nRetValue = rParaLevel.mnBulletChar; 6227 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletChar ) ) 6228 bIsHardAttribute = 1; 6229 } 6230 break; 6231 case PPT_ParaAttr_BulletFont : 6232 { 6233 sal_Bool bHardBuFont; 6234 if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardFont ) ) 6235 bHardBuFont = pParaSet->mpArry[ PPT_ParaAttr_BuHardFont ] != 0; 6236 else 6237 bHardBuFont = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardFont ) ) != 0; 6238 if ( bHardBuFont ) 6239 { 6240 nRetValue = rParaLevel.mnBulletFont; 6241 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletFont ) ) 6242 bIsHardAttribute = 1; 6243 } 6244 else 6245 { 6246 if ( mnPortionCount ) 6247 { 6248 PPTPortionObj* pPortion = mpPortionList[ 0 ]; 6249 if ( pPortion ) 6250 bIsHardAttribute = pPortion->GetAttrib( PPT_CharAttr_Font, nRetValue, nDestinationInstance ); 6251 } 6252 else 6253 { 6254 nRetValue = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFont; 6255 bIsHardAttribute = 1; 6256 } 6257 } 6258 } 6259 break; 6260 case PPT_ParaAttr_BulletHeight : 6261 { 6262 nRetValue = rParaLevel.mnBulletHeight; 6263 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletHeight ) ) 6264 bIsHardAttribute = 1; 6265 } 6266 break; 6267 case PPT_ParaAttr_BulletColor : 6268 { 6269 sal_Bool bHardBulletColor; 6270 if ( pParaSet->mnAttrSet & ( 1 << PPT_ParaAttr_BuHardColor ) ) 6271 bHardBulletColor = pParaSet->mpArry[ PPT_ParaAttr_BuHardColor ] != 0; 6272 else 6273 bHardBulletColor = ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardColor ) ) != 0; 6274 if ( bHardBulletColor ) 6275 { 6276 nRetValue = rParaLevel.mnBulletColor; 6277 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletColor ) ) 6278 bIsHardAttribute = 1; 6279 } 6280 else 6281 { 6282 if ( mnPortionCount ) 6283 { 6284 PPTPortionObj* pPortion = mpPortionList[ 0 ]; 6285 if ( pPortion ) 6286 { 6287 if (pPortion->mbIsHyperlink ) 6288 { 6289 if( pPortion->mbHardHylinkOrigColor ) 6290 nRetValue = pPortion->mnHylinkOrigColor; 6291 else 6292 nRetValue = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontColor; 6293 bIsHardAttribute = sal_True; 6294 } 6295 else 6296 { 6297 bIsHardAttribute = pPortion->GetAttrib( PPT_CharAttr_FontColor, nRetValue, nDestinationInstance ); 6298 } 6299 } 6300 } 6301 else 6302 { 6303 nRetValue = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontColor; 6304 bIsHardAttribute = 1; 6305 } 6306 } 6307 } 6308 break; 6309 case PPT_ParaAttr_Adjust : 6310 { 6311 nRetValue = rParaLevel.mnAdjust; 6312 if ( pParaLevel && ( nRetValue != pParaLevel->mnAdjust ) ) 6313 bIsHardAttribute = 1; 6314 } 6315 break; 6316 case PPT_ParaAttr_LineFeed : 6317 { 6318 nRetValue = rParaLevel.mnLineFeed; 6319 if ( pParaLevel && ( nRetValue != pParaLevel->mnLineFeed ) ) 6320 bIsHardAttribute = 1; 6321 } 6322 break; 6323 case PPT_ParaAttr_UpperDist : 6324 { 6325 nRetValue = rParaLevel.mnUpperDist; 6326 if ( pParaLevel && ( nRetValue != pParaLevel->mnUpperDist ) ) 6327 bIsHardAttribute = 1; 6328 } 6329 break; 6330 case PPT_ParaAttr_LowerDist : 6331 { 6332 nRetValue = rParaLevel.mnLowerDist; 6333 if ( pParaLevel && ( nRetValue != pParaLevel->mnLowerDist ) ) 6334 bIsHardAttribute = 1; 6335 } 6336 break; 6337 case PPT_ParaAttr_TextOfs : 6338 { 6339 nRetValue = rParaLevel.mnTextOfs; 6340 if ( pParaLevel && ( nRetValue != pParaLevel->mnTextOfs ) ) 6341 bIsHardAttribute = 1; 6342 } 6343 break; 6344 case PPT_ParaAttr_BulletOfs : 6345 { 6346 nRetValue = rParaLevel.mnBulletOfs; 6347 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletOfs ) ) 6348 bIsHardAttribute = 1; 6349 } 6350 break; 6351 case PPT_ParaAttr_DefaultTab : 6352 { 6353 nRetValue = rParaLevel.mnDefaultTab; 6354 if ( pParaLevel && ( nRetValue != pParaLevel->mnBulletOfs ) ) 6355 bIsHardAttribute = 1; 6356 } 6357 break; 6358 case PPT_ParaAttr_AsianLB_1 : 6359 { 6360 nRetValue = rParaLevel.mnAsianLineBreak & 1; 6361 if ( pParaLevel && ( nRetValue != ( (sal_uInt32)pParaLevel->mnAsianLineBreak & 1 ) ) ) 6362 bIsHardAttribute = 1; 6363 } 6364 break; 6365 case PPT_ParaAttr_AsianLB_2 : 6366 { 6367 nRetValue = ( rParaLevel.mnAsianLineBreak >> 1 ) & 1; 6368 if ( pParaLevel && ( nRetValue != ( ( (sal_uInt32)pParaLevel->mnAsianLineBreak >> 1 ) & 1 ) ) ) 6369 bIsHardAttribute = 1; 6370 } 6371 break; 6372 case PPT_ParaAttr_AsianLB_3 : 6373 { 6374 nRetValue = ( rParaLevel.mnAsianLineBreak >> 2 ) & 1; 6375 if ( pParaLevel && ( nRetValue != ( ( (sal_uInt32)pParaLevel->mnAsianLineBreak >> 2 ) & 1 ) ) ) 6376 bIsHardAttribute = 1; 6377 } 6378 break; 6379 case PPT_ParaAttr_BiDi : 6380 { 6381 nRetValue = rParaLevel.mnBiDi; 6382 if ( pParaLevel && ( nRetValue != pParaLevel->mnBiDi ) ) 6383 bIsHardAttribute = 1; 6384 } 6385 break; 6386 } 6387 } 6388 return (sal_Bool)bIsHardAttribute; 6389 } 6390 6391 void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, boost::optional< sal_Int16 >& rStartNumbering, SdrPowerPointImport& rManager, sal_uInt32 nDestinationInstance, const PPTParagraphObj* /*pPrev*/) 6392 { 6393 sal_Int16 nVal2; 6394 sal_uInt32 nVal, nUpperDist, nLowerDist; 6395 sal_uInt32 nInstance = nDestinationInstance != 0xffffffff ? nDestinationInstance : mnInstance; 6396 6397 if ( ( nDestinationInstance != 0xffffffff ) || ( pParaSet->mnDepth <= 1 ) ) 6398 { 6399 SvxNumBulletItem* pNumBulletItem = mrStyleSheet.mpNumBulletItem[ nInstance ]; 6400 if ( pNumBulletItem ) 6401 { 6402 SvxNumberFormat aNumberFormat( SVX_NUM_NUMBER_NONE ); 6403 if ( GetNumberFormat( rManager, aNumberFormat, this, nDestinationInstance, rStartNumbering ) ) 6404 { 6405 if ( aNumberFormat.GetNumberingType() == SVX_NUM_NUMBER_NONE ) 6406 { 6407 aNumberFormat.SetLSpace( 0 ); 6408 aNumberFormat.SetAbsLSpace( 0 ); 6409 aNumberFormat.SetFirstLineOffset( 0 ); 6410 aNumberFormat.SetCharTextDistance( 0 ); 6411 aNumberFormat.SetFirstLineIndent( 0 ); 6412 aNumberFormat.SetIndentAt( 0 ); 6413 } 6414 SvxNumBulletItem aNewNumBulletItem( *pNumBulletItem ); 6415 SvxNumRule* pRule = aNewNumBulletItem.GetNumRule(); 6416 if ( pRule ) 6417 { 6418 pRule->SetLevel( pParaSet->mnDepth, aNumberFormat ); 6419 sal_uInt16 i, n; 6420 for ( i = 0; i < pRule->GetLevelCount(); i++ ) 6421 { 6422 if ( i != pParaSet->mnDepth ) 6423 { 6424 n = i > 4 ? 4 : i; 6425 6426 SvxNumberFormat aNumberFormat2( pRule->GetLevel( i ) ); 6427 const PPTParaLevel& rParaLevel = mrStyleSheet.mpParaSheet[ nInstance ]->maParaLevel[ n ]; 6428 const PPTCharLevel& rCharLevel = mrStyleSheet.mpCharSheet[ nInstance ]->maCharLevel[ n ]; 6429 sal_uInt32 nColor; 6430 if ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardColor ) ) 6431 nColor = rParaLevel.mnBulletColor; 6432 else 6433 nColor = rCharLevel.mnFontColor; 6434 aNumberFormat2.SetBulletColor( rManager.MSO_TEXT_CLR_ToColor( nColor ) ); 6435 pRule->SetLevel( i, aNumberFormat2 ); 6436 } 6437 } 6438 rSet.Put( aNewNumBulletItem ); 6439 } 6440 } 6441 } 6442 } 6443 6444 sal_uInt32 nIsBullet2, _nTextOfs, _nBulletOfs, nHardAttribute = 0; 6445 GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet2, nDestinationInstance ); 6446 nHardAttribute += GetAttrib( PPT_ParaAttr_TextOfs, _nTextOfs, nDestinationInstance ); 6447 nHardAttribute += GetAttrib( PPT_ParaAttr_BulletOfs, _nBulletOfs, nDestinationInstance ); 6448 if ( !nIsBullet2 ) 6449 { 6450 SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE ); 6451 sal_uInt16 nAbsLSpace = (sal_uInt16)( ( (sal_uInt32)_nTextOfs * 2540 ) / 576 ); 6452 sal_uInt16 nFirstLineOffset = nAbsLSpace - (sal_uInt16)( ( (sal_uInt32)_nBulletOfs * 2540 ) / 576 ); 6453 aLRSpaceItem.SetLeft( nAbsLSpace ); 6454 aLRSpaceItem.SetTxtFirstLineOfstValue( -nFirstLineOffset ); 6455 rSet.Put( aLRSpaceItem ); 6456 } 6457 else 6458 { 6459 SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE ); 6460 aLRSpaceItem.SetLeft( 0 ); 6461 aLRSpaceItem.SetTxtFirstLineOfstValue( 0 ); 6462 rSet.Put( aLRSpaceItem ); 6463 } 6464 if ( GetAttrib( PPT_ParaAttr_Adjust, nVal, nDestinationInstance ) ) 6465 { 6466 if ( nVal <= 3 ) 6467 { // Absatzausrichtung 6468 static SvxAdjust __READONLY_DATA aAdj[ 4 ] = { SVX_ADJUST_LEFT, SVX_ADJUST_CENTER, SVX_ADJUST_RIGHT, SVX_ADJUST_BLOCK }; 6469 rSet.Put( SvxAdjustItem( aAdj[ nVal ], EE_PARA_JUST ) ); 6470 } 6471 } 6472 6473 if ( GetAttrib( PPT_ParaAttr_AsianLB_1, nVal, nDestinationInstance ) ) 6474 rSet.Put( SfxBoolItem( EE_PARA_FORBIDDENRULES, nVal != 0 ) ); 6475 if ( GetAttrib( PPT_ParaAttr_AsianLB_3, nVal, nDestinationInstance ) ) 6476 rSet.Put( SfxBoolItem( EE_PARA_HANGINGPUNCTUATION, nVal != 0 ) ); 6477 6478 if ( GetAttrib( PPT_ParaAttr_BiDi, nVal, nDestinationInstance ) ) 6479 rSet.Put( SvxFrameDirectionItem( nVal == 1 ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) ); 6480 6481 // LineSpacing 6482 PPTPortionObj* pPortion = First(); 6483 sal_Bool bIsHardAttribute = GetAttrib( PPT_ParaAttr_LineFeed, nVal, nDestinationInstance ); 6484 nVal2 = (sal_Int16)nVal; 6485 sal_uInt32 nFont = sal_uInt32(); 6486 if ( pPortion && pPortion->GetAttrib( PPT_CharAttr_Font, nFont, nDestinationInstance ) ) 6487 bIsHardAttribute = sal_True; 6488 6489 if ( bIsHardAttribute ) 6490 { 6491 if ( pPortion && ( nVal2 > 200 ) ) 6492 { 6493 sal_uInt32 nFontHeight; 6494 pPortion->GetAttrib( PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance ); 6495 nVal2 = -(sal_Int16)( ( nFontHeight * nVal * 8 ) / 100 ); 6496 } 6497 rSet.Put( SdrTextFixedCellHeightItem( sal_True ), SDRATTR_TEXT_USEFIXEDCELLHEIGHT ); 6498 SvxLineSpacingItem aItem( 200, EE_PARA_SBL ); 6499 if ( nVal2 <= 0 ) 6500 { 6501 aItem.SetLineHeight( (sal_uInt16)( rManager.ScalePoint( -nVal2 ) / 8 ) ); 6502 aItem.GetLineSpaceRule() = SVX_LINE_SPACE_FIX; 6503 } 6504 else 6505 { 6506 sal_uInt8 nPropLineSpace = (sal_uInt8)nVal2; 6507 aItem.SetPropLineSpace( nPropLineSpace ); 6508 aItem.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 6509 } 6510 rSet.Put( aItem ); 6511 } 6512 6513 // Paragraph Spacing 6514 sal_uInt32 nFontHeight = 0; 6515 bIsHardAttribute = ( (sal_uInt32)GetAttrib( PPT_ParaAttr_UpperDist, nUpperDist, nDestinationInstance ) + 6516 (sal_uInt32)GetAttrib( PPT_ParaAttr_LowerDist, nLowerDist, nDestinationInstance ) ) != 0; 6517 if ( ( nUpperDist > 0 ) || ( nLowerDist > 0 ) ) 6518 { 6519 if ( mnPortionCount ) 6520 { 6521 mpPortionList[ mnPortionCount - 1 ]->GetAttrib( PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance ); 6522 if ( ((sal_Int16)nUpperDist) > 0 ) 6523 nUpperDist = - (sal_Int16)( ( nFontHeight * nUpperDist * 100 ) / 1000 ); 6524 if ( ((sal_Int16)nLowerDist) > 0 ) 6525 nLowerDist = - (sal_Int16)( ( nFontHeight * nLowerDist * 100 ) / 1000 ); 6526 } 6527 bIsHardAttribute = sal_True; 6528 } 6529 if ( bIsHardAttribute ) 6530 { 6531 SvxULSpaceItem aULSpaceItem( EE_PARA_ULSPACE ); 6532 nVal2 = (sal_Int16)nUpperDist; 6533 if ( nVal2 <= 0 ) 6534 aULSpaceItem.SetUpper( (sal_uInt16)(((sal_uInt32) - nVal2 * 2540 ) / ( 72 * 8 ) ) ); 6535 else 6536 { 6537 aULSpaceItem.SetUpperValue( 0 ); 6538 aULSpaceItem.SetPropUpper( (sal_uInt16)nUpperDist == 100 ? 101 : (sal_uInt16)nUpperDist ); 6539 } 6540 nVal2 = (sal_Int16)nLowerDist; 6541 if ( nVal2 <= 0 ) 6542 aULSpaceItem.SetLower( (sal_uInt16)(((sal_uInt32) - nVal2 * 2540 ) / ( 72 * 8 ) ) ); 6543 else 6544 { 6545 aULSpaceItem.SetLowerValue( 0 ); 6546 aULSpaceItem.SetPropLower( (sal_uInt16)nLowerDist == 100 ? 101 : (sal_uInt16)nLowerDist ); 6547 } 6548 rSet.Put( aULSpaceItem ); 6549 } 6550 6551 if ( mbTab ) // makes it sense to apply tabsettings 6552 { 6553 sal_uInt32 i, nDefaultTab, nTab, nTextOfs2 = 0; 6554 sal_uInt32 nLatestManTab = 0; 6555 GetAttrib( PPT_ParaAttr_TextOfs, nTextOfs2, nDestinationInstance ); 6556 GetAttrib( PPT_ParaAttr_BulletOfs, nTab, nDestinationInstance ); 6557 GetAttrib( PPT_ParaAttr_BulletOn, i, nDestinationInstance ); 6558 GetAttrib( PPT_ParaAttr_DefaultTab, nDefaultTab, nDestinationInstance ); 6559 SvxTabStopItem aTabItem( 0, 0, SVX_TAB_ADJUST_DEFAULT, EE_PARA_TABS ); 6560 if ( GetTabCount() ) 6561 { 6562 //paragraph offset = MIN(first_line_offset, hanging_offset) 6563 sal_uInt32 nParaOffset = Min( nTextOfs2, nTab ); 6564 for ( i = 0; i < GetTabCount(); i++ ) 6565 { 6566 SvxTabAdjust eTabAdjust; 6567 nTab = GetTabOffsetByIndex( (sal_uInt16)i ); 6568 switch( GetTabStyleByIndex( (sal_uInt16)i ) ) 6569 { 6570 case 1 : eTabAdjust = SVX_TAB_ADJUST_CENTER; break; 6571 case 2 : eTabAdjust = SVX_TAB_ADJUST_RIGHT; break; 6572 case 3 : eTabAdjust = SVX_TAB_ADJUST_DECIMAL; break; 6573 default : eTabAdjust = SVX_TAB_ADJUST_LEFT; 6574 } 6575 if ( nTab > nParaOffset )//If tab stop greater than paragraph offset 6576 aTabItem.Insert( SvxTabStop( ( ( (long( nTab - nTextOfs2 )) * 2540 ) / 576 ), eTabAdjust ) ); 6577 } 6578 nLatestManTab = nTab; 6579 } 6580 if ( nIsBullet2 == 0 ) 6581 aTabItem.Insert( SvxTabStop( (sal_uInt16)0 ) ); 6582 if ( nDefaultTab ) 6583 { 6584 nTab = ( nTextOfs2 > nLatestManTab ) ? nTextOfs2 : nLatestManTab; 6585 nTab /= nDefaultTab; 6586 nTab = nDefaultTab * ( 1 + nTab ); 6587 for ( i = 0; ( i < 20 ) && ( nTab < 0x1b00 ); i++ ) 6588 { 6589 aTabItem.Insert( SvxTabStop( (sal_uInt16)( ( ( nTab - nTextOfs2 ) * 2540 ) / 576 ) ) ); 6590 nTab += nDefaultTab; 6591 } 6592 } 6593 rSet.Put( aTabItem ); 6594 } 6595 } 6596 6597 sal_uInt32 PPTParagraphObj::GetTextSize() 6598 { 6599 sal_uInt32 nCount, nRetValue = 0; 6600 for ( sal_uInt32 i = 0; i < mnPortionCount; i++ ) 6601 { 6602 PPTPortionObj* pPortionObj = mpPortionList[ i ]; 6603 nCount = pPortionObj->Count(); 6604 if ( ( !nCount ) && pPortionObj->mpFieldItem ) 6605 nCount++; 6606 nRetValue += nCount; 6607 } 6608 return nRetValue; 6609 } 6610 6611 PPTPortionObj* PPTParagraphObj::First() 6612 { 6613 mnCurrentObject = 0; 6614 if ( !mnPortionCount ) 6615 return NULL; 6616 return mpPortionList[ 0 ]; 6617 } 6618 6619 PPTPortionObj* PPTParagraphObj::Next() 6620 { 6621 sal_uInt32 i = mnCurrentObject + 1; 6622 if ( i >= mnPortionCount ) 6623 return NULL; 6624 mnCurrentObject++; 6625 return mpPortionList[ i ]; 6626 } 6627 6628 void PPTParagraphObj::ImplClear() 6629 { 6630 for ( void* pPtr = First(); pPtr; pPtr = Next() ) 6631 delete (PPTPortionObj*)pPtr; 6632 delete[] mpPortionList; 6633 } 6634 6635 PPTFieldEntry::~PPTFieldEntry() 6636 { 6637 delete pField1; 6638 delete pField2; 6639 delete pString; 6640 }; 6641 6642 void PPTFieldEntry::GetDateTime( const sal_uInt32 nVal, SvxDateFormat& eDateFormat, SvxTimeFormat& eTimeFormat ) 6643 { 6644 eDateFormat = SVXDATEFORMAT_APPDEFAULT; 6645 eTimeFormat = SVXTIMEFORMAT_APPDEFAULT; 6646 // ID auswerten 6647 switch( nVal ) 6648 { 6649 case 0: 6650 case 6: 6651 eDateFormat = SVXDATEFORMAT_A; 6652 break; 6653 case 1: 6654 eDateFormat = SVXDATEFORMAT_F; 6655 break; 6656 case 2: 6657 case 3: 6658 eDateFormat = SVXDATEFORMAT_D; 6659 break; 6660 case 4: 6661 case 5: 6662 eDateFormat = SVXDATEFORMAT_C; 6663 break; 6664 case 7: 6665 eDateFormat = SVXDATEFORMAT_A; 6666 case 9: 6667 eTimeFormat = SVXTIMEFORMAT_24_HM; 6668 break; 6669 case 8: 6670 eDateFormat = SVXDATEFORMAT_A; 6671 case 11: 6672 eTimeFormat = SVXTIMEFORMAT_12_HM; 6673 break; 6674 case 10: 6675 eTimeFormat = SVXTIMEFORMAT_24_HMS; 6676 break; 6677 case 12: 6678 eTimeFormat = SVXTIMEFORMAT_12_HMS; 6679 break; 6680 } 6681 } 6682 6683 void PPTFieldEntry::SetDateTime( sal_uInt32 nVal ) 6684 { 6685 SvxDateFormat eDateFormat; 6686 SvxTimeFormat eTimeFormat; 6687 GetDateTime( nVal, eDateFormat, eTimeFormat ); 6688 if ( eDateFormat != SVXDATEFORMAT_APPDEFAULT ) 6689 pField1 = new SvxFieldItem( SvxDateField( Date(), SVXDATETYPE_VAR, eDateFormat ), EE_FEATURE_FIELD ); 6690 if ( eTimeFormat != SVXTIMEFORMAT_APPDEFAULT ) 6691 { 6692 SvxFieldItem* pFieldItem = new SvxFieldItem( SvxExtTimeField( Time(), SVXTIMETYPE_VAR, eTimeFormat ), EE_FEATURE_FIELD ); 6693 if ( pField1 ) 6694 pField2 = pFieldItem; 6695 else 6696 pField1 = pFieldItem; 6697 } 6698 } 6699 6700 // ----------------------------------------------------------------------- 6701 6702 PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport, PptSlidePersistEntry& rPersistEntry, DffObjData* pObjData ) : 6703 mpImplTextObj ( new ImplPPTTextObj( rPersistEntry ) ) 6704 { 6705 mpImplTextObj->mnRefCount = 1; 6706 mpImplTextObj->mnShapeId = 0; 6707 mpImplTextObj->mnShapeMaster = 0; 6708 mpImplTextObj->mpPlaceHolderAtom = NULL; 6709 mpImplTextObj->mnDestinationInstance = mpImplTextObj->mnInstance = 4; 6710 mpImplTextObj->mnCurrentObject = 0; 6711 mpImplTextObj->mnParagraphCount = 0; 6712 mpImplTextObj->mpParagraphList = NULL; 6713 mpImplTextObj->mnTextFlags = 0; 6714 mpImplTextObj->meShapeType = ( pObjData && pObjData->bShapeType ) ? pObjData->eShapeType : mso_sptMin; 6715 6716 DffRecordHeader aExtParaHd; 6717 aExtParaHd.nRecType = 0; // set empty 6718 6719 sal_uInt32 bStatus = sal_True; 6720 6721 DffRecordHeader aShapeContainerHd; 6722 rIn >> aShapeContainerHd; 6723 6724 if ( ( pObjData == NULL ) || ( pObjData->bShapeType ) ) 6725 { 6726 PPTExtParaProv* pExtParaProv = rSdrPowerPointImport.pPPTStyleSheet->pExtParaProv; 6727 if ( pObjData ) 6728 { 6729 mpImplTextObj->mnShapeId = pObjData->nShapeId; 6730 if ( pObjData->nSpFlags & SP_FHAVEMASTER ) 6731 mpImplTextObj->mnShapeMaster = rSdrPowerPointImport.GetPropertyValue( DFF_Prop_hspMaster, 0 ); 6732 } 6733 //////////////// 6734 // ClientData // 6735 //////////////// 6736 if ( rSdrPowerPointImport.maShapeRecords.SeekToContent( rIn, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) ) 6737 { 6738 sal_uInt32 nOldPos = rIn.Tell(); 6739 DffRecordHeader& aClientDataContainerHd = *rSdrPowerPointImport.maShapeRecords.Current(); 6740 DffRecordHeader aPlaceHolderAtomHd; 6741 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_OEPlaceholderAtom, aClientDataContainerHd.GetRecEndFilePos(), &aPlaceHolderAtomHd ) ) 6742 { 6743 mpImplTextObj->mpPlaceHolderAtom = new PptOEPlaceholderAtom; 6744 rIn >> *( mpImplTextObj->mpPlaceHolderAtom ); 6745 } 6746 rIn.Seek( nOldPos ); 6747 DffRecordHeader aProgTagHd; 6748 if ( rSdrPowerPointImport.SeekToContentOfProgTag( 9, rIn, aClientDataContainerHd, aProgTagHd ) ) 6749 { 6750 rIn >> aExtParaHd; 6751 } 6752 } 6753 6754 /////////////////// 6755 // ClientTextBox // 6756 /////////////////// 6757 if ( rSdrPowerPointImport.maShapeRecords.SeekToContent( rIn, DFF_msofbtClientTextbox, SEEK_FROM_CURRENT_AND_RESTART ) ) 6758 { 6759 DffRecordHeader aClientTextBoxHd( *rSdrPowerPointImport.maShapeRecords.Current() ); 6760 sal_uInt32 nTextRulerAtomOfs = 0; // case of zero -> this atom may be found in aClientDataContainerHd; 6761 // case of -1 -> ther is no atom of this kind 6762 // else -> this is the fileofs where we can get it 6763 6764 ////////////////////////////////////// 6765 // checkout if this is a referenced // 6766 // textobj, if so the we will patch // 6767 // the ClientTextBoxHd for a // 6768 // equivalent one // 6769 ////////////////////////////////////// 6770 DffRecordHeader aTextHd; 6771 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_OutlineTextRefAtom, aClientTextBoxHd.GetRecEndFilePos(), &aTextHd ) ) 6772 { 6773 sal_uInt32 nRefNum; 6774 rIn >> nRefNum; 6775 6776 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_TextRulerAtom, aClientTextBoxHd.GetRecEndFilePos() ) ) 6777 nTextRulerAtomOfs = rIn.Tell(); 6778 else 6779 nTextRulerAtomOfs = 0xffffffff; 6780 6781 sal_uInt32 nInstance = 0; 6782 switch( rSdrPowerPointImport.eAktPageKind ) 6783 { 6784 case PPT_NOTEPAGE : 6785 nInstance++; 6786 case PPT_MASTERPAGE : 6787 nInstance++; 6788 case PPT_SLIDEPAGE : 6789 break; 6790 default : 6791 bStatus = sal_False; 6792 } 6793 if ( bStatus ) 6794 { 6795 sal_uInt32 nSlideId = rSdrPowerPointImport.GetAktPageId(); 6796 if ( !nSlideId ) 6797 bStatus = sal_False; 6798 else 6799 { 6800 if ( !aExtParaHd.nRecType ) 6801 { 6802 sal_uInt32 nOldPos = rIn.Tell(); 6803 // try to locate the referenced ExtendedParaHd 6804 DffRecordHeader* pHd = pExtParaProv-> 6805 aExtendedPresRules.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom, 6806 SEEK_FROM_CURRENT_AND_RESTART ); 6807 DffRecordHeader aPresRuleHd; 6808 DffRecordHeader* pFirst = pHd; 6809 6810 sal_uInt32 nTmpSlideId, nTmpRef; 6811 while ( pHd ) 6812 { 6813 pHd->SeekToContent( rIn ); 6814 rIn >> nTmpSlideId 6815 >> nTmpRef; // this seems to be the instance 6816 6817 if ( ( nTmpSlideId == nSlideId ) && ( pHd->nRecInstance == nRefNum ) ) 6818 { 6819 pHd->SeekToEndOfRecord( rIn ); 6820 rIn >> aPresRuleHd; 6821 if ( aPresRuleHd.nRecType == PPT_PST_ExtendedParagraphAtom ) 6822 { 6823 aExtParaHd = aPresRuleHd; 6824 break; 6825 } 6826 } 6827 pHd = pExtParaProv-> 6828 aExtendedPresRules.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom, 6829 SEEK_FROM_CURRENT_AND_RESTART ); 6830 if ( pHd == pFirst ) 6831 break; 6832 } 6833 rIn.Seek( nOldPos ); 6834 } 6835 // now pHd points to the right SlideListWithText Container 6836 PptSlidePersistList* pPageList = rSdrPowerPointImport.GetPageList( rSdrPowerPointImport.eAktPageKind ); 6837 PptSlidePersistEntry* pE = NULL; 6838 if ( pPageList && ( rSdrPowerPointImport.nAktPageNum < pPageList->Count() ) ) 6839 pE = (*pPageList)[ rSdrPowerPointImport.nAktPageNum ]; 6840 if ( (!pE) || (!pE->nSlidePersistStartOffset) || ( pE->aPersistAtom.nSlideId != nSlideId ) ) 6841 bStatus = sal_False; 6842 else 6843 { 6844 rIn.Seek( pE->nSlidePersistStartOffset ); 6845 // now we got the right page and are searching for the right 6846 // TextHeaderAtom 6847 while ( rIn.Tell() < pE->nSlidePersistEndOffset ) 6848 { 6849 rIn >> aClientTextBoxHd; 6850 if ( aClientTextBoxHd.nRecType == PPT_PST_TextHeaderAtom ) 6851 { 6852 if ( aClientTextBoxHd.nRecInstance == nRefNum ) 6853 { 6854 aClientTextBoxHd.SeekToEndOfRecord( rIn ); 6855 break; 6856 } 6857 } 6858 aClientTextBoxHd.SeekToEndOfRecord( rIn ); 6859 } 6860 if ( rIn.Tell() > pE->nSlidePersistEndOffset ) 6861 bStatus = sal_False; 6862 else 6863 { // patching the RecordHeader 6864 aClientTextBoxHd.nFilePos -= DFF_COMMON_RECORD_HEADER_SIZE; 6865 aClientTextBoxHd.nRecLen += DFF_COMMON_RECORD_HEADER_SIZE; 6866 aClientTextBoxHd.nRecType = DFF_msofbtClientTextbox; 6867 aClientTextBoxHd.nRecVer = DFF_PSFLAG_CONTAINER; 6868 6869 // we have to calculate the correct record len 6870 DffRecordHeader aTmpHd; 6871 while ( rIn.Tell() < pE->nSlidePersistEndOffset ) 6872 { 6873 rIn >> aTmpHd; 6874 if ( ( aTmpHd.nRecType == PPT_PST_SlidePersistAtom ) || ( aTmpHd.nRecType == PPT_PST_TextHeaderAtom ) ) 6875 break; 6876 aTmpHd.SeekToEndOfRecord( rIn ); 6877 aClientTextBoxHd.nRecLen += aTmpHd.nRecLen + DFF_COMMON_RECORD_HEADER_SIZE; 6878 } 6879 aClientTextBoxHd.SeekToContent( rIn ); 6880 } 6881 } 6882 } 6883 } 6884 } 6885 6886 if ( bStatus ) 6887 { 6888 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_TextHeaderAtom, aClientTextBoxHd.GetRecEndFilePos(), &aTextHd ) ) 6889 { 6890 // TextHeaderAtom is always the first Atom 6891 sal_uInt16 nInstance; 6892 rIn >> nInstance; // this number tells us the TxMasterStyleAtom Instance 6893 if ( nInstance > 8 ) 6894 nInstance = 4; 6895 aTextHd.SeekToEndOfRecord( rIn ); 6896 mpImplTextObj->mnInstance = nInstance; 6897 6898 sal_uInt32 nFilePos = rIn.Tell(); 6899 if ( rSdrPowerPointImport.SeekToRec2( PPT_PST_TextBytesAtom, 6900 PPT_PST_TextCharsAtom, 6901 aClientTextBoxHd.GetRecEndFilePos() ) 6902 || rSdrPowerPointImport.SeekToRec( rIn, 6903 PPT_PST_StyleTextPropAtom, 6904 aClientTextBoxHd.GetRecEndFilePos() ) ) 6905 { 6906 PPTTextRulerInterpreter aTextRulerInterpreter( nTextRulerAtomOfs, rSdrPowerPointImport, 6907 aClientTextBoxHd, rIn ); 6908 6909 PPTStyleTextPropReader aStyleTextPropReader( rIn, rSdrPowerPointImport, aClientTextBoxHd, 6910 aTextRulerInterpreter, aExtParaHd, nInstance ); 6911 sal_uInt32 nParagraphs = mpImplTextObj->mnParagraphCount = aStyleTextPropReader.aParaPropList.Count(); 6912 if ( nParagraphs ) 6913 { 6914 // the language settings will be merged into the list of PPTCharPropSet 6915 DffRecordHeader aTextSpecInfoHd; 6916 PPTTextSpecInfoAtomInterpreter aTextSpecInfoAtomInterpreter; 6917 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_TextSpecInfoAtom, 6918 aClientTextBoxHd.GetRecEndFilePos(), &aTextSpecInfoHd ) ) 6919 { 6920 if ( aTextSpecInfoAtomInterpreter.Read( rIn, aTextSpecInfoHd, PPT_PST_TextSpecInfoAtom, 6921 &(rSdrPowerPointImport.pPPTStyleSheet->maTxSI) ) ) 6922 { 6923 sal_uInt32 nI = 0; 6924 PPTTextSpecInfo* pSpecInfo; 6925 for ( pSpecInfo = (PPTTextSpecInfo*)aTextSpecInfoAtomInterpreter.aList.First(); 6926 pSpecInfo; pSpecInfo =(PPTTextSpecInfo*)aTextSpecInfoAtomInterpreter.aList.Next() ) 6927 { 6928 sal_uInt32 nCharIdx = pSpecInfo->nCharIdx; 6929 6930 // portions and text have to been splitted in some cases 6931 for ( ; nI < aStyleTextPropReader.aCharPropList.Count(); ) 6932 { 6933 PPTCharPropSet* pSet = (PPTCharPropSet*)aStyleTextPropReader.aCharPropList.GetObject( nI ); 6934 if ( pSet->mnOriginalTextPos < nCharIdx ) 6935 { 6936 pSet->mnLanguage[ 0 ] = pSpecInfo->nLanguage[ 0 ]; 6937 pSet->mnLanguage[ 1 ] = pSpecInfo->nLanguage[ 1 ]; 6938 pSet->mnLanguage[ 2 ] = pSpecInfo->nLanguage[ 2 ]; 6939 // test if the current portion needs to be splitted 6940 if ( pSet->maString.Len() > 1 ) 6941 { 6942 sal_Int32 nIndexOfNextPortion = pSet->maString.Len() + pSet->mnOriginalTextPos; 6943 sal_Int32 nNewLen = nIndexOfNextPortion - nCharIdx; 6944 sal_Int32 nOldLen = pSet->maString.Len() - nNewLen; 6945 6946 if ( ( nNewLen > 0 ) && ( nOldLen > 0 ) ) 6947 { 6948 String aString( pSet->maString ); 6949 PPTCharPropSet* pNew = new PPTCharPropSet( *pSet ); 6950 pSet->maString = String( aString, 0, (sal_uInt16)nOldLen ); 6951 pNew->maString = String( aString, (sal_uInt16)nOldLen, (sal_uInt16)nNewLen ); 6952 pNew->mnOriginalTextPos += nOldLen; 6953 aStyleTextPropReader.aCharPropList.Insert( pNew, nI + 1 ); 6954 } 6955 } 6956 } 6957 else 6958 break; 6959 nI++; 6960 } 6961 } 6962 } 6963 #ifdef DBG_UTIL 6964 else 6965 { 6966 if (!(rSdrPowerPointImport.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT)) 6967 { 6968 DBG_ERROR( "SdrTextSpecInfoAtomInterpreter::Ctor(): parsing error, this document needs to be analysed (SJ)" ); 6969 } 6970 } 6971 #endif 6972 } 6973 // 6974 // now will search for possible textextensions such as date/time fields 6975 // or ParaTabStops and append them on this textobj 6976 // 6977 rIn.Seek( nFilePos ); 6978 List* pFieldList = NULL; 6979 while ( rIn.Tell() < aClientTextBoxHd.GetRecEndFilePos() ) 6980 { 6981 rIn >> aTextHd; 6982 sal_uInt16 nVal = 0; 6983 PPTFieldEntry* pEntry = NULL; 6984 switch ( aTextHd.nRecType ) 6985 { 6986 case PPT_PST_DateTimeMCAtom : 6987 { 6988 pEntry = new PPTFieldEntry; 6989 rIn >> pEntry->nPos 6990 >> nVal 6991 >> nVal; 6992 pEntry->SetDateTime( nVal & 0xff ); 6993 } 6994 break; 6995 6996 case PPT_PST_FooterMCAtom : 6997 { 6998 pEntry = new PPTFieldEntry; 6999 rIn >> pEntry->nPos; 7000 pEntry->pField1 = new SvxFieldItem( SvxFooterField(), EE_FEATURE_FIELD ); 7001 } 7002 break; 7003 7004 case PPT_PST_HeaderMCAtom : 7005 { 7006 pEntry = new PPTFieldEntry; 7007 rIn >> pEntry->nPos; 7008 pEntry->pField1 = new SvxFieldItem( SvxHeaderField(), EE_FEATURE_FIELD ); 7009 } 7010 break; 7011 7012 case PPT_PST_GenericDateMCAtom : 7013 { 7014 pEntry = new PPTFieldEntry; 7015 rIn >> pEntry->nPos; 7016 pEntry->pField1 = new SvxFieldItem( SvxDateTimeField(), EE_FEATURE_FIELD ); 7017 if ( rPersistEntry.pHeaderFooterEntry ) // sj: #i34111# on master pages it is possible 7018 { // that there is no HeaderFooterEntry available 7019 if ( rPersistEntry.pHeaderFooterEntry->nAtom & 0x20000 ) // auto date time 7020 pEntry->SetDateTime( rPersistEntry.pHeaderFooterEntry->nAtom & 0xff ); 7021 else 7022 pEntry->pString = new String( rPersistEntry.pHeaderFooterEntry->pPlaceholder[ nVal ] ); 7023 } 7024 } 7025 break; 7026 7027 case PPT_PST_SlideNumberMCAtom : 7028 case PPT_PST_RTFDateTimeMCAtom : 7029 { 7030 pEntry = new PPTFieldEntry; 7031 if ( aTextHd.nRecLen >= 4 ) 7032 { 7033 rIn >> pEntry->nPos 7034 >> nVal; 7035 7036 // ID auswerten 7037 //SvxFieldItem* pFieldItem = NULL; 7038 switch( aTextHd.nRecType ) 7039 { 7040 case PPT_PST_SlideNumberMCAtom: 7041 pEntry->pField1 = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD ); 7042 break; 7043 7044 case PPT_PST_RTFDateTimeMCAtom: 7045 { 7046 // Rude workaround for one specal case reported 7047 // by a customer. (#i75203#) 7048 7049 // Don't even attempt to handle the general use 7050 // case for PPT_PST_RTFDateTimeMCAtom (a generic 7051 // MS style date/time format string). Just handle 7052 // the special case where the format string 7053 // contains only one or several possibly empty 7054 // quoted strings. I.e. something that doesn't 7055 // expand to any date or time at all, but to a 7056 // fixed string. How on earth somebody manages to 7057 // produce such things in PPT slides I have no 7058 // idea. 7059 if (nVal == 0) 7060 { 7061 sal_Unicode n; 7062 xub_StrLen nLen; 7063 String aStr; 7064 bool inquote = sal_False; 7065 for (nLen = 0, n = 0; nLen < 64; nLen++) 7066 { 7067 rIn >> n; 7068 7069 // Collect quoted characters into aStr 7070 if ( n == '\'') 7071 inquote = !inquote; 7072 else if (!n) 7073 { 7074 // End of format string 7075 pEntry->pString = new String( aStr ); 7076 break; 7077 } 7078 else if (!inquote) 7079 { 7080 // Non-quoted character, i.e. a real 7081 // format specifier. We don't handle 7082 // those. Sorry. 7083 break; 7084 } 7085 else 7086 { 7087 aStr += n; 7088 } 7089 } 7090 } 7091 if ( pEntry->pString == NULL ) 7092 { 7093 // Handle as previously 7094 pEntry->pField1 = new SvxFieldItem( SvxDateField( Date(), SVXDATETYPE_FIX ), EE_FEATURE_FIELD ); 7095 } 7096 } 7097 } 7098 } 7099 } 7100 break; 7101 7102 case PPT_PST_InteractiveInfo : 7103 { 7104 DffRecordHeader aHdInteractiveInfoAtom; 7105 if ( rSdrPowerPointImport.SeekToRec( rIn, PPT_PST_InteractiveInfoAtom, aTextHd.GetRecEndFilePos(), &aHdInteractiveInfoAtom ) ) 7106 { 7107 PptInteractiveInfoAtom aInteractiveInfoAtom; 7108 rIn >> aInteractiveInfoAtom; 7109 for ( SdHyperlinkEntry* pHyperlink = (SdHyperlinkEntry*)rSdrPowerPointImport.aHyperList.First(); 7110 pHyperlink; pHyperlink = (SdHyperlinkEntry*)rSdrPowerPointImport.aHyperList.Next() ) 7111 { 7112 if ( pHyperlink->nIndex == aInteractiveInfoAtom.nExHyperlinkId ) 7113 { 7114 aTextHd.SeekToEndOfRecord( rIn ); 7115 rIn >> aTextHd; 7116 if ( aTextHd.nRecType != PPT_PST_TxInteractiveInfoAtom ) 7117 { 7118 aTextHd.SeekToBegOfRecord( rIn ); 7119 continue; 7120 } 7121 else 7122 { 7123 sal_uInt32 nStartPos, nEndPos; 7124 rIn >> nStartPos 7125 >> nEndPos; 7126 if ( nEndPos ) 7127 { 7128 pEntry = new PPTFieldEntry; 7129 pEntry->nPos = (sal_uInt16)nStartPos; 7130 pEntry->nTextRangeEnd = (sal_uInt16)nEndPos; 7131 String aTarget( pHyperlink->aTarget ); 7132 if ( pHyperlink->aConvSubString.Len() ) 7133 { 7134 aTarget.Append( (sal_Unicode)'#' ); 7135 aTarget.Append( pHyperlink->aConvSubString ); 7136 } 7137 pEntry->pField1 = new SvxFieldItem( SvxURLField( aTarget, String(), SVXURLFORMAT_REPR ), EE_FEATURE_FIELD ); 7138 } 7139 } 7140 break; 7141 } 7142 } 7143 } 7144 } 7145 break; 7146 } 7147 aTextHd.SeekToEndOfRecord( rIn ); 7148 if ( pEntry ) 7149 { 7150 if ( !pFieldList ) 7151 pFieldList = new List; 7152 sal_uInt32 n; 7153 for ( n = 0; n < pFieldList->Count(); n++ ) 7154 { // sorting fields ( hi >> lo ) 7155 if ( ( (PPTFieldEntry*)pFieldList->GetObject( n ) )->nPos < pEntry->nPos ) 7156 break; 7157 } 7158 pFieldList->Insert( pEntry, (sal_uInt32)n ); 7159 } 7160 } 7161 if ( pFieldList ) 7162 { 7163 PPTFieldEntry* pFE = (PPTFieldEntry*)pFieldList->First(); 7164 List& aCharPropList = aStyleTextPropReader.aCharPropList; 7165 7166 sal_Int32 i = nParagraphs - 1; 7167 sal_Int32 n = aCharPropList.Count() - 1; 7168 7169 // at this point we just have a list of textportions(aCharPropList) 7170 // the next while loop tries to resolve the list of fields(pFieldList) 7171 while( pFE && ( n >= 0 ) && ( i >= 0 ) ) 7172 { 7173 PPTCharPropSet* pSet = (PPTCharPropSet*)aCharPropList.GetObject( n ); 7174 String aString( pSet->maString ); 7175 sal_uInt32 nCount = aString.Len(); 7176 sal_uInt32 nPos = pSet->mnOriginalTextPos + nCount; 7177 while ( pFE && nCount-- ) 7178 { 7179 nPos--; 7180 while ( pFE && ( pFE->nPos > nPos ) ) 7181 pFE = (PPTFieldEntry*)pFieldList->Next(); 7182 if ( !pFE ) 7183 break; 7184 7185 if ( pFE->nPos == nPos ) 7186 { 7187 if ( aString.GetChar( (sal_uInt16)nCount ) == 0x2a ) 7188 { 7189 sal_uInt32 nBehind = aString.Len() - ( nCount + 1 ); 7190 pSet->maString = String(); 7191 if ( nBehind ) 7192 { 7193 PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet ); 7194 pNewCPS->maString = String( aString, (sal_uInt16)nCount + 1, (sal_uInt16)nBehind ); 7195 aCharPropList.Insert( pNewCPS, n + 1 ); 7196 } 7197 if ( pFE->pField2 ) 7198 { 7199 PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet ); 7200 pNewCPS->mpFieldItem = pFE->pField2, pFE->pField2 = NULL; 7201 aCharPropList.Insert( pNewCPS, n + 1 ); 7202 7203 pNewCPS = new PPTCharPropSet( *pSet ); 7204 pNewCPS->maString = String( String( RTL_CONSTASCII_USTRINGPARAM( " " ) ) ); 7205 aCharPropList.Insert( pNewCPS, n + 1 ); 7206 } 7207 if ( nCount ) 7208 { 7209 PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet ); 7210 pNewCPS->maString = String( aString, (sal_uInt16)0, (sal_uInt16)nCount ); 7211 aCharPropList.Insert( pNewCPS, n++ ); 7212 } 7213 if ( pFE->pField1 ) 7214 { 7215 pSet->mpFieldItem = pFE->pField1, pFE->pField1 = NULL; 7216 } 7217 else if ( pFE->pString ) 7218 pSet->maString = *pFE->pString; 7219 } 7220 else 7221 { 7222 if ( pFE->nTextRangeEnd ) // text range hyperlink 7223 { 7224 sal_uInt32 nHyperLen = pFE->nTextRangeEnd - nPos; 7225 if ( nHyperLen ) 7226 { 7227 PPTCharPropSet* pBefCPS = NULL; 7228 if ( nCount ) 7229 { 7230 pBefCPS = new PPTCharPropSet( *pSet ); 7231 pSet->maString = String( pSet->maString, (sal_uInt16)nCount, (sal_uInt16)( pSet->maString.Len() - nCount ) ); 7232 } 7233 sal_uInt32 nIdx = n; 7234 sal_Int32 nHyperLenLeft = nHyperLen; 7235 7236 while ( ( aCharPropList.Count() > nIdx ) && nHyperLenLeft ) 7237 { 7238 // the textrange hyperlink can take more than 1 paragraph 7239 // the solution here is to clone the hyperlink... 7240 7241 PPTCharPropSet* pCurrent = (PPTCharPropSet*)aCharPropList.GetObject( nIdx ); 7242 sal_Int32 nNextStringLen = pCurrent->maString.Len(); 7243 7244 DBG_ASSERT( pFE->pField1, "missing field!" ); 7245 if (!pFE->pField1) 7246 break; 7247 7248 const SvxURLField* pField = (const SvxURLField*)pFE->pField1->GetField(); 7249 7250 pCurrent->mbIsHyperlink=sal_True; 7251 pCurrent->mnHylinkOrigColor=pCurrent->pCharSet->mnColor; 7252 pCurrent->mbHardHylinkOrigColor= ( ( pCurrent->pCharSet->mnAttrSet >>PPT_CharAttr_FontColor ) & 1)>0; 7253 7254 if ( pCurrent->mpFieldItem ) 7255 { 7256 pCurrent->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK ); 7257 if ( pCurrent->mpFieldItem->GetField()->ISA( SvxURLField ) ) 7258 break; 7259 nHyperLenLeft--; 7260 } 7261 else if ( nNextStringLen ) 7262 { 7263 if ( nNextStringLen <= nHyperLenLeft ) 7264 { 7265 pCurrent->mpFieldItem = new SvxFieldItem( SvxURLField( pField->GetURL(), pCurrent->maString, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD ); 7266 nHyperLenLeft -= nNextStringLen; 7267 7268 if ( nHyperLenLeft ) 7269 { 7270 // if the next portion is in a higher paragraph, 7271 // the textrange is to decrease (because of the LineBreak character) 7272 if ( aCharPropList.Count() > ( nIdx + 1 ) ) 7273 { 7274 PPTCharPropSet* pNext = (PPTCharPropSet*)aCharPropList.GetObject( nIdx + 1 ); 7275 if ( pNext->mnParagraph > pCurrent->mnParagraph ) 7276 nHyperLenLeft--; 7277 } 7278 } 7279 } 7280 else 7281 { 7282 PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pCurrent ); 7283 pNewCPS->maString = String( pCurrent->maString, (sal_uInt16)nHyperLenLeft, (sal_uInt16)( nNextStringLen - nHyperLenLeft ) ); 7284 aCharPropList.Insert( pNewCPS, nIdx + 1 ); 7285 String aRepresentation( pCurrent->maString, 0, (sal_uInt16)nHyperLenLeft ); 7286 pCurrent->mpFieldItem = new SvxFieldItem( SvxURLField( pField->GetURL(), aRepresentation, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD ); 7287 nHyperLenLeft = 0; 7288 } 7289 pCurrent->maString = String(); 7290 pCurrent->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK ); 7291 } 7292 nIdx++; 7293 } 7294 delete pFE->pField1, pFE->pField1 = NULL; 7295 7296 if ( pBefCPS ) 7297 { 7298 pBefCPS->maString = String( aString, (sal_uInt16)0, (sal_uInt16)nCount ); 7299 aCharPropList.Insert( pBefCPS, n++ ); 7300 7301 } 7302 } 7303 } 7304 } 7305 break; 7306 } 7307 } 7308 n--; 7309 } 7310 for ( void* pPtr = pFieldList->First(); pPtr; pPtr = pFieldList->Next() ) 7311 delete (PPTFieldEntry*)pPtr; 7312 delete pFieldList; 7313 } 7314 mpImplTextObj->mpParagraphList = new PPTParagraphObj*[ nParagraphs ]; 7315 aStyleTextPropReader.aCharPropList.First(); 7316 sal_uInt32 nCount = 0; 7317 for ( void* pPtr = aStyleTextPropReader.aParaPropList.First(); 7318 pPtr; 7319 pPtr = aStyleTextPropReader.aParaPropList.Next() ) 7320 { 7321 PPTParagraphObj* pPara = new PPTParagraphObj( aStyleTextPropReader, *rSdrPowerPointImport.pPPTStyleSheet, nInstance, aTextRulerInterpreter ); 7322 mpImplTextObj->mpParagraphList[ nCount++ ] = pPara; 7323 7324 sal_uInt32 nParaAdjust, nFlags = 0; 7325 pPara->GetAttrib( PPT_ParaAttr_Adjust, nParaAdjust, GetInstance() ); 7326 7327 switch ( nParaAdjust ) 7328 { 7329 case 0 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT; break; 7330 case 1 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER; break; 7331 case 2 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; break; 7332 case 3 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK; break; 7333 } 7334 mpImplTextObj->mnTextFlags |= nFlags; 7335 } 7336 } 7337 } 7338 } 7339 } 7340 } 7341 } 7342 } 7343 7344 PPTTextObj::PPTTextObj( PPTTextObj& rTextObj ) 7345 { 7346 mpImplTextObj = rTextObj.mpImplTextObj; 7347 mpImplTextObj->mnRefCount++; 7348 } 7349 7350 PPTTextObj::~PPTTextObj() 7351 { 7352 ImplClear(); 7353 } 7354 7355 PPTParagraphObj* PPTTextObj::First() 7356 { 7357 mpImplTextObj->mnCurrentObject = 0; 7358 if ( !mpImplTextObj->mnParagraphCount ) 7359 return NULL; 7360 return mpImplTextObj->mpParagraphList[ 0 ]; 7361 } 7362 7363 PPTParagraphObj* PPTTextObj::Next() 7364 { 7365 sal_uInt32 i = mpImplTextObj->mnCurrentObject + 1; 7366 if ( i >= mpImplTextObj->mnParagraphCount ) 7367 return NULL; 7368 mpImplTextObj->mnCurrentObject++; 7369 return mpImplTextObj->mpParagraphList[ i ]; 7370 } 7371 7372 const SfxItemSet* PPTTextObj::GetBackground() const 7373 { 7374 if ( mpImplTextObj->mrPersistEntry.pBObj ) 7375 return &mpImplTextObj->mrPersistEntry.pBObj->GetMergedItemSet(); 7376 else 7377 return NULL; 7378 } 7379 7380 void PPTTextObj::ImplClear() 7381 { 7382 if ( ! ( --mpImplTextObj->mnRefCount ) ) 7383 { 7384 for ( PPTParagraphObj* pPtr = First(); pPtr; pPtr = Next() ) 7385 delete pPtr; 7386 delete[] mpImplTextObj->mpParagraphList; 7387 delete mpImplTextObj->mpPlaceHolderAtom; 7388 delete mpImplTextObj; 7389 } 7390 } 7391 7392 PPTTextObj& PPTTextObj::operator=( PPTTextObj& rTextObj ) 7393 { 7394 if ( this != &rTextObj ) 7395 { 7396 ImplClear(); 7397 mpImplTextObj = rTextObj.mpImplTextObj; 7398 mpImplTextObj->mnRefCount++; 7399 } 7400 return *this; 7401 } 7402 7403 sal_Bool IsLine( const SdrObject* pObj ) 7404 { 7405 return pObj->ISA( SdrPathObj ) && ((SdrPathObj*)pObj)->IsLine() && (((SdrPathObj*)pObj)->GetPointCount() == 2 ); 7406 } 7407 7408 sal_Bool GetCellPosition( const SdrObject* pObj, const std::set< sal_Int32 >& rRows, const std::set< sal_Int32 >& rColumns, 7409 sal_Int32& nTableIndex, sal_Int32& nRow, sal_Int32& nRowCount, sal_Int32& nColumn, sal_Int32& nColumnCount ) 7410 { 7411 Rectangle aSnapRect( pObj->GetSnapRect() ); 7412 sal_Bool bCellObject = ( aSnapRect.GetWidth() > 1 ) && ( aSnapRect.GetHeight() > 1 ); 7413 if ( bCellObject ) 7414 { 7415 std::set< sal_Int32 >::const_iterator aRowIter( rRows.find( aSnapRect.Top() ) ); 7416 std::set< sal_Int32 >::const_iterator aColumnIter( rColumns.find( aSnapRect.Left() ) ); 7417 if ( ( aRowIter == rRows.end() ) || ( aColumnIter == rColumns.end() ) ) 7418 bCellObject = sal_False; 7419 else 7420 { 7421 nRowCount = 1; 7422 nRow = std::distance( rRows.begin(), aRowIter ); 7423 while( ++aRowIter != rRows.end() ) 7424 { 7425 if ( *aRowIter >= aSnapRect.Bottom() ) 7426 break; 7427 nRowCount++; 7428 } 7429 nColumnCount = 1; 7430 nColumn = std::distance( rColumns.begin(), aColumnIter ); 7431 while( ++aColumnIter != rColumns.end() ) 7432 { 7433 if ( *aColumnIter >= aSnapRect.Right() ) 7434 break; 7435 nColumnCount++; 7436 } 7437 nTableIndex = nRow * rColumns.size() + nColumn; 7438 } 7439 } 7440 return bCellObject; 7441 } 7442 7443 #define LinePositionLeft 0x01000000 7444 #define LinePositionTop 0x02000000 7445 #define LinePositionRight 0x04000000 7446 #define LinePositionBottom 0x08000000 7447 #define LinePositionTLBR 0x10000000 7448 #define LinePositionBLTR 0x20000000 7449 7450 7451 void GetRowPositions( const Rectangle& rSnapRect, const std::set< sal_Int32 >& rRows, 7452 const std::set< sal_Int32 >& rColumns, std::vector< sal_Int32 >& rPositions, sal_Int32 nColumn, sal_Int32 nFlags ) 7453 { 7454 std::set< sal_Int32 >::const_iterator aRow( rRows.find( rSnapRect.Top() ) ); 7455 if ( aRow != rRows.end() ) 7456 { 7457 sal_Int32 nRow = std::distance( rRows.begin(), aRow ); 7458 while( ( aRow != rRows.end() ) && ((*aRow) < rSnapRect.Bottom() ) ) 7459 { 7460 if ( nFlags & LinePositionLeft ) 7461 rPositions.push_back( ( ( nRow * rColumns.size() ) + nColumn ) | LinePositionLeft ); 7462 if ( nFlags & LinePositionRight ) 7463 rPositions.push_back( ( ( nRow * rColumns.size() ) + ( nColumn - 1 ) ) | LinePositionRight ); 7464 7465 nRow++; 7466 aRow++; 7467 } 7468 } 7469 } 7470 7471 7472 void GetColumnPositions( const Rectangle& rSnapRect, const std::set< sal_Int32 >& /* rRows */, 7473 const std::set< sal_Int32 >& rColumns, std::vector< sal_Int32 >& rPositions, sal_Int32 nRow, sal_Int32 nFlags ) 7474 { 7475 std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( rSnapRect.Left() ) ); 7476 if ( aColumn != rColumns.end() ) 7477 { 7478 sal_Int32 nColumn = std::distance( rColumns.begin(), aColumn ); 7479 while( ( aColumn != rColumns.end() ) && ((*aColumn) < rSnapRect.Right() ) ) 7480 { 7481 if ( nFlags & LinePositionTop ) 7482 rPositions.push_back( ( ( nRow * rColumns.size() ) + nColumn ) | LinePositionTop ); 7483 if ( nFlags & LinePositionBottom ) 7484 rPositions.push_back( ( ( ( nRow - 1 ) * rColumns.size() ) + nColumn ) | LinePositionBottom ); 7485 7486 nColumn++; 7487 aColumn++; 7488 } 7489 } 7490 } 7491 7492 void GetLinePositions( const SdrObject* pObj, const std::set< sal_Int32 >& rRows, const std::set< sal_Int32 >& rColumns, 7493 std::vector< sal_Int32 >& rPositions, const Rectangle& rGroupSnap ) 7494 { 7495 Rectangle aSnapRect( pObj->GetSnapRect() ); 7496 if ( aSnapRect.Left() == aSnapRect.Right() ) 7497 { 7498 std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( aSnapRect.Left() ) ); 7499 if ( ( aColumn != rColumns.end() ) || ( aSnapRect.Left() == rGroupSnap.Right() ) ) 7500 { 7501 sal_Int32 nColumn, nFlags; 7502 if ( aColumn != rColumns.end() ) 7503 { 7504 nColumn = std::distance( rColumns.begin(), aColumn ); 7505 nFlags = LinePositionLeft; 7506 if ( aColumn != rColumns.begin() ) 7507 nFlags |= LinePositionRight; 7508 } 7509 else 7510 { 7511 nColumn = rColumns.size(); 7512 nFlags = LinePositionRight; 7513 } 7514 GetRowPositions( aSnapRect, rRows, rColumns, rPositions, nColumn, nFlags ); 7515 } 7516 } 7517 else if ( aSnapRect.Top() == aSnapRect.Bottom() ) 7518 { 7519 std::set< sal_Int32 >::const_iterator aRow( rRows.find( aSnapRect.Top() ) ); 7520 if ( ( aRow != rRows.end() ) || ( aSnapRect.Top() == rGroupSnap.Bottom() ) ) 7521 { 7522 sal_Int32 nRow, nFlags; 7523 if ( aRow != rRows.end() ) 7524 { 7525 nRow = std::distance( rRows.begin(), aRow ); 7526 nFlags = LinePositionTop; 7527 if ( aRow != rRows.begin() ) 7528 nFlags |= LinePositionBottom; 7529 } 7530 else 7531 { 7532 nRow = rRows.size(); 7533 nFlags = LinePositionBottom; 7534 } 7535 GetColumnPositions( aSnapRect, rRows, rColumns, rPositions, nRow, nFlags ); 7536 } 7537 } 7538 else 7539 { 7540 sal_uInt32 nPosition = 0; 7541 Point aPt1( ((SdrPathObj*)pObj)->GetPoint( 0 ) ); 7542 Point aPt2( ((SdrPathObj*)pObj)->GetPoint( 1 ) ); 7543 if ( aPt1.X() < aPt2.X() ) 7544 nPosition |= aPt1.Y() < aPt2.Y() ? LinePositionTLBR : LinePositionBLTR; 7545 else 7546 nPosition |= aPt1.Y() < aPt2.Y() ? LinePositionBLTR : LinePositionTLBR; 7547 7548 std::set< sal_Int32 >::const_iterator aRow( rRows.find( aPt1.Y() < aPt2.Y() ? aPt1.Y() : aPt2.Y() ) ); 7549 std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( aPt1.X() < aPt2.X() ? aPt1.X() : aPt2.X() ) ); 7550 if ( ( aRow != rRows.end() ) && ( aColumn != rColumns.end() ) ) 7551 { 7552 nPosition |= ( std::distance( rRows.begin(), aRow ) * rColumns.size() ) + std::distance( rColumns.begin(), aColumn ); 7553 rPositions.push_back( nPosition ); 7554 } 7555 } 7556 } 7557 7558 void CreateTableRows( Reference< XTableRows > xTableRows, const std::set< sal_Int32 >& rRows, sal_Int32 nTableBottom ) 7559 { 7560 if ( rRows.size() > 1 ) 7561 xTableRows->insertByIndex( 0, rRows.size() - 1 ); 7562 7563 std::set< sal_Int32 >::const_iterator aIter( rRows.begin() ); 7564 sal_Int32 nLastPosition( *aIter ); 7565 Reference< XIndexAccess > xIndexAccess( xTableRows, UNO_QUERY_THROW ); 7566 for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ ) 7567 { 7568 sal_Int32 nHeight; 7569 if ( ++aIter != rRows.end() ) 7570 { 7571 nHeight = *aIter - nLastPosition; 7572 nLastPosition = *aIter; 7573 } 7574 else 7575 nHeight = nTableBottom - nLastPosition; 7576 7577 static const rtl::OUString sWidth( RTL_CONSTASCII_USTRINGPARAM ( "Height" ) ); 7578 Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW ); 7579 xPropSet->setPropertyValue( sWidth, Any( nHeight ) ); 7580 } 7581 } 7582 7583 void CreateTableColumns( Reference< XTableColumns > xTableColumns, const std::set< sal_Int32 >& rColumns, sal_Int32 nTableRight ) 7584 { 7585 if ( rColumns.size() > 1 ) 7586 xTableColumns->insertByIndex( 0, rColumns.size() - 1 ); 7587 7588 std::set< sal_Int32 >::const_iterator aIter( rColumns.begin() ); 7589 sal_Int32 nLastPosition( *aIter ); 7590 Reference< XIndexAccess > xIndexAccess( xTableColumns, UNO_QUERY_THROW ); 7591 for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ ) 7592 { 7593 sal_Int32 nWidth; 7594 if ( ++aIter != rColumns.end() ) 7595 { 7596 nWidth = *aIter - nLastPosition; 7597 nLastPosition = *aIter; 7598 } 7599 else 7600 nWidth = nTableRight - nLastPosition; 7601 7602 static const rtl::OUString sWidth( RTL_CONSTASCII_USTRINGPARAM ( "Width" ) ); 7603 Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW ); 7604 xPropSet->setPropertyValue( sWidth, Any( nWidth ) ); 7605 } 7606 } 7607 7608 void MergeCells( const Reference< XTable >& xTable, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan ) 7609 { 7610 DBG_ASSERT( (nColSpan > 1) || (nRowSpan > 1), "nonsense parameter!!" ); 7611 DBG_ASSERT( (nCol >= 0) && (nCol < xTable->getColumnCount()) && (nRow >= 0) && (nRow < xTable->getRowCount()), "die celle gibts nicht!!" ); 7612 DBG_ASSERT( (nColSpan >= 1) && ((nCol + nColSpan - 1) < xTable->getColumnCount()), "nColSpan murks!" ); 7613 DBG_ASSERT( (nRowSpan >= 1) && ((nRow + nRowSpan - 1) < xTable->getRowCount()), "nRowSpan murks!" ); 7614 7615 if( xTable.is() ) try 7616 { 7617 Reference< XMergeableCellRange > xRange( xTable->createCursorByRange( xTable->getCellRangeByPosition( nCol, nRow,nCol + nColSpan - 1, nRow + nRowSpan - 1 ) ), UNO_QUERY_THROW ); 7618 if( xRange->isMergeable() ) 7619 xRange->merge(); 7620 } 7621 catch( Exception& ) 7622 { 7623 DBG_ASSERT( false, "exception caught!" ); 7624 } 7625 } 7626 7627 void ApplyCellAttributes( const SdrObject* pObj, Reference< XCell >& xCell ) 7628 { 7629 try 7630 { 7631 Reference< XPropertySet > xPropSet( xCell, UNO_QUERY_THROW ); 7632 7633 const sal_Int32 nLeftDist(((const SdrTextLeftDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_LEFTDIST)).GetValue()); 7634 const sal_Int32 nRightDist(((const SdrTextRightDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_RIGHTDIST)).GetValue()); 7635 const sal_Int32 nUpperDist(((const SdrTextUpperDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST)).GetValue()); 7636 const sal_Int32 nLowerDist(((const SdrTextLowerDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST)).GetValue()); 7637 static const rtl::OUString sTopBorder( RTL_CONSTASCII_USTRINGPARAM( "TextUpperDistance" ) ); 7638 static const rtl::OUString sBottomBorder( RTL_CONSTASCII_USTRINGPARAM( "TextLowerDistance" ) ); 7639 static const rtl::OUString sLeftBorder( RTL_CONSTASCII_USTRINGPARAM( "TextLeftDistance" ) ); 7640 static const rtl::OUString sRightBorder( RTL_CONSTASCII_USTRINGPARAM( "TextRightDistance" ) ); 7641 xPropSet->setPropertyValue( sTopBorder, Any( nUpperDist ) ); 7642 xPropSet->setPropertyValue( sRightBorder, Any( nRightDist ) ); 7643 xPropSet->setPropertyValue( sLeftBorder, Any( nLeftDist ) ); 7644 xPropSet->setPropertyValue( sBottomBorder, Any( nLowerDist ) ); 7645 7646 static const rtl::OUString sTextVerticalAdjust( RTL_CONSTASCII_USTRINGPARAM( "TextVerticalAdjust" ) ); 7647 const SdrTextVertAdjust eTextVertAdjust(((const SdrTextVertAdjustItem&)pObj->GetMergedItem(SDRATTR_TEXT_VERTADJUST)).GetValue()); 7648 drawing::TextVerticalAdjust eVA( drawing::TextVerticalAdjust_TOP ); 7649 if ( eTextVertAdjust == SDRTEXTVERTADJUST_CENTER ) 7650 eVA = drawing::TextVerticalAdjust_CENTER; 7651 else if ( eTextVertAdjust == SDRTEXTVERTADJUST_BOTTOM ) 7652 eVA = drawing::TextVerticalAdjust_BOTTOM; 7653 xPropSet->setPropertyValue( sTextVerticalAdjust, Any( eVA ) ); 7654 7655 //set textHorizontalAdjust and TextWritingMode attr 7656 const sal_Int32 eHA(((const SdrTextLeftDistItem&)pObj->GetMergedItem(SDRATTR_TEXT_HORZADJUST)).GetValue()); 7657 const SvxFrameDirection eDirection = (const SvxFrameDirection)((( const SvxFrameDirectionItem&)pObj->GetMergedItem(EE_PARA_WRITINGDIR)).GetValue()); 7658 static const rtl::OUString sHorizontalAdjust( RTL_CONSTASCII_USTRINGPARAM( "TextHorizontalAdjust" ) ); 7659 static const rtl::OUString sWritingMode( RTL_CONSTASCII_USTRINGPARAM("TextWritingMode") ); 7660 xPropSet->setPropertyValue( sHorizontalAdjust , Any( eHA ) ); 7661 if ( eDirection == FRMDIR_VERT_TOP_RIGHT ) 7662 {//vertical writing 7663 xPropSet->setPropertyValue( sWritingMode , Any( ::com::sun::star::text::WritingMode_TB_RL ) ); 7664 } 7665 SfxItemSet aSet( pObj->GetMergedItemSet() ); 7666 XFillStyle eFillStyle(((XFillStyleItem&)pObj->GetMergedItem( XATTR_FILLSTYLE )).GetValue()); 7667 ::com::sun::star::drawing::FillStyle eFS( com::sun::star::drawing::FillStyle_NONE ); 7668 switch( eFillStyle ) 7669 { 7670 case XFILL_SOLID : 7671 { 7672 static const rtl::OUString sFillColor( String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ) ); 7673 eFS = com::sun::star::drawing::FillStyle_SOLID; 7674 Color aFillColor( ((XFillColorItem&)pObj->GetMergedItem( XATTR_FILLCOLOR )).GetColorValue() ); 7675 sal_Int32 nFillColor( aFillColor.GetColor() ); 7676 xPropSet->setPropertyValue( sFillColor, Any( nFillColor ) ); 7677 } 7678 break; 7679 case XFILL_GRADIENT : 7680 { 7681 eFS = com::sun::star::drawing::FillStyle_GRADIENT; 7682 XGradient aXGradient(((const XFillGradientItem&)pObj->GetMergedItem(XATTR_FILLGRADIENT)).GetGradientValue()); 7683 7684 com::sun::star::awt::Gradient aGradient; 7685 aGradient.Style = (awt::GradientStyle) aXGradient.GetGradientStyle(); 7686 aGradient.StartColor = (sal_Int32)aXGradient.GetStartColor().GetColor(); 7687 aGradient.EndColor = (sal_Int32)aXGradient.GetEndColor().GetColor(); 7688 aGradient.Angle = (short)aXGradient.GetAngle(); 7689 aGradient.Border = aXGradient.GetBorder(); 7690 aGradient.XOffset = aXGradient.GetXOffset(); 7691 aGradient.YOffset = aXGradient.GetYOffset(); 7692 aGradient.StartIntensity = aXGradient.GetStartIntens(); 7693 aGradient.EndIntensity = aXGradient.GetEndIntens(); 7694 aGradient.StepCount = aXGradient.GetSteps(); 7695 7696 static const rtl::OUString sFillGradient( String( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ) ) ); 7697 xPropSet->setPropertyValue( sFillGradient, Any( aGradient ) ); 7698 } 7699 break; 7700 case XFILL_HATCH : 7701 eFS = com::sun::star::drawing::FillStyle_HATCH; 7702 break; 7703 case XFILL_BITMAP : 7704 { 7705 eFS = com::sun::star::drawing::FillStyle_BITMAP; 7706 7707 const XFillBitmapItem aXFillBitmapItem((const XFillBitmapItem&)pObj->GetMergedItem( XATTR_FILLBITMAP )); 7708 rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); 7709 aURL += rtl::OUString::createFromAscii(aXFillBitmapItem.GetGraphicObject().GetUniqueID().GetBuffer()); 7710 7711 static const rtl::OUString sFillBitmapURL( String( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" ) ) ); 7712 xPropSet->setPropertyValue( sFillBitmapURL, Any( aURL ) ); 7713 7714 static const rtl::OUString sFillBitmapMode( String( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapMode" ) ) ); 7715 const XFillBmpStretchItem aStretchItem(( const XFillBmpStretchItem&)pObj->GetMergedItem( XATTR_FILLBMP_STRETCH )); 7716 const XFillBmpTileItem aTileItem(( const XFillBmpTileItem&)pObj->GetMergedItem( XATTR_FILLBMP_TILE )); 7717 if( aTileItem.GetValue() ) 7718 xPropSet->setPropertyValue( sFillBitmapMode, Any( com::sun::star::drawing::BitmapMode_REPEAT ) ); 7719 else if( aStretchItem.GetValue() ) 7720 xPropSet->setPropertyValue( sFillBitmapMode, Any( com::sun::star::drawing::BitmapMode_STRETCH ) ); 7721 else 7722 xPropSet->setPropertyValue( sFillBitmapMode, Any( com::sun::star::drawing::BitmapMode_NO_REPEAT ) ); 7723 } 7724 break; 7725 case XFILL_NONE : 7726 eFS = com::sun::star::drawing::FillStyle_NONE; 7727 break; 7728 7729 } 7730 static const rtl::OUString sFillStyle( String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ) ); 7731 xPropSet->setPropertyValue( sFillStyle, Any( eFS ) ); 7732 if ( eFillStyle != XFILL_NONE ) 7733 { 7734 sal_Int16 nFillTransparence( ( (const XFillTransparenceItem&)pObj->GetMergedItem( XATTR_FILLTRANSPARENCE ) ).GetValue() ); 7735 static const rtl::OUString sFillTransparence( String( RTL_CONSTASCII_USTRINGPARAM( "FillTransparence" ) ) ); 7736 xPropSet->setPropertyValue( sFillTransparence, Any( nFillTransparence ) ); 7737 } 7738 } 7739 catch( Exception& ) 7740 { 7741 } 7742 } 7743 7744 void ApplyCellLineAttributes( const SdrObject* pLine, Reference< XTable >& xTable, const std::vector< sal_Int32 > vPositions, sal_Int32 nColumns ) 7745 { 7746 try 7747 { 7748 SfxItemSet aSet( pLine->GetMergedItemSet() ); 7749 XLineStyle eLineStyle(((XLineStyleItem&)pLine->GetMergedItem( XATTR_LINESTYLE )).GetValue()); 7750 com::sun::star::table::BorderLine aBorderLine; 7751 switch( eLineStyle ) 7752 { 7753 case XLINE_DASH : 7754 case XLINE_SOLID : 7755 { 7756 Color aLineColor( ((XLineColorItem&)pLine->GetMergedItem( XATTR_LINECOLOR )).GetColorValue() ); 7757 aBorderLine.Color = aLineColor.GetColor(); 7758 // Avoid width = 0, the min value should be 1. 7759 aBorderLine.OuterLineWidth = std::max( static_cast< sal_Int16 >( 1 ), static_cast< sal_Int16 >( ((const XLineWidthItem&)(pLine->GetMergedItem(XATTR_LINEWIDTH))).GetValue() / 4) ); 7760 aBorderLine.InnerLineWidth = std::max( static_cast< sal_Int16 >( 1 ), static_cast< sal_Int16 >( ((const XLineWidthItem&)(pLine->GetMergedItem(XATTR_LINEWIDTH))).GetValue() / 4) ); 7761 aBorderLine.LineDistance = 0; 7762 } 7763 break; 7764 case XLINE_NONE : 7765 { 7766 aBorderLine.OuterLineWidth = 0; 7767 aBorderLine.InnerLineWidth = 0; 7768 aBorderLine.LineDistance = 0; 7769 } 7770 break; 7771 } 7772 Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW ); 7773 std::vector< sal_Int32 >::const_iterator aIter( vPositions.begin() ); 7774 while( aIter != vPositions.end() ) 7775 { 7776 static const rtl::OUString sTopBorder( String( RTL_CONSTASCII_USTRINGPARAM( "TopBorder" ) ) ); 7777 static const rtl::OUString sBottomBorder( String( RTL_CONSTASCII_USTRINGPARAM( "BottomBorder" ) ) ); 7778 static const rtl::OUString sLeftBorder( String( RTL_CONSTASCII_USTRINGPARAM( "LeftBorder" ) ) ); 7779 static const rtl::OUString sRightBorder( String( RTL_CONSTASCII_USTRINGPARAM( "RightBorder" ) ) ); 7780 static const rtl::OUString sDiagonalTLBR( RTL_CONSTASCII_USTRINGPARAM ( "DiagonalTLBR" ) ); 7781 static const rtl::OUString sDiagonalBLTR( RTL_CONSTASCII_USTRINGPARAM ( "DiagonalBLTR" ) ); 7782 7783 sal_Int32 nPosition = *aIter & 0xffffff; 7784 sal_Int32 nFlags = *aIter &~0xffffff; 7785 sal_Int32 nRow = nPosition / nColumns; 7786 sal_Int32 nColumn = nPosition - ( nRow * nColumns ); 7787 Reference< XCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ) ); 7788 Reference< XPropertySet > xPropSet( xCell, UNO_QUERY_THROW ); 7789 7790 if ( nFlags & LinePositionLeft ) 7791 xPropSet->setPropertyValue( sLeftBorder, Any( aBorderLine ) ); 7792 if ( nFlags & LinePositionTop ) 7793 xPropSet->setPropertyValue( sTopBorder, Any( aBorderLine ) ); 7794 if ( nFlags & LinePositionRight ) 7795 xPropSet->setPropertyValue( sRightBorder, Any( aBorderLine ) ); 7796 if ( nFlags & LinePositionBottom ) 7797 xPropSet->setPropertyValue( sBottomBorder, Any( aBorderLine ) ); 7798 if ( nFlags & LinePositionTLBR ) 7799 xPropSet->setPropertyValue( sDiagonalTLBR, Any( sal_True ) ); 7800 if ( nFlags & LinePositionBLTR ) 7801 xPropSet->setPropertyValue( sDiagonalBLTR, Any( sal_True ) ); 7802 aIter++; 7803 } 7804 } 7805 catch( Exception& ) 7806 { 7807 } 7808 } 7809 7810 SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, sal_uInt32* pTableArry, SvxMSDffSolverContainer* pSolverContainer ) 7811 { 7812 SdrObject* pRet = pGroup; 7813 sal_uInt32 nRows = pTableArry[ 1 ]; 7814 if ( nRows && pGroup->ISA( SdrObjGroup ) ) 7815 { 7816 SdrObjList* pSubList(((SdrObjGroup*)pGroup)->GetSubList()); 7817 if ( pSubList ) 7818 { 7819 std::set< sal_Int32 > aRows; 7820 std::set< sal_Int32 > aColumns; 7821 7822 SdrObjListIter aGroupIter( *pSubList, IM_DEEPNOGROUPS, sal_False ); 7823 while( aGroupIter.IsMore() ) 7824 { 7825 const SdrObject* pObj( aGroupIter.Next() ); 7826 if ( !IsLine( pObj ) ) 7827 { 7828 Rectangle aSnapRect( pObj->GetSnapRect() ); 7829 aRows.insert( aSnapRect.Top() ); 7830 aColumns.insert( aSnapRect.Left() ); 7831 } 7832 } 7833 ::sdr::table::SdrTableObj* pTable = new ::sdr::table::SdrTableObj( pSdrModel ); 7834 pTable->uno_lock(); 7835 Reference< XTable > xTable( pTable->getTable() ); 7836 try 7837 { 7838 Reference< XColumnRowRange > xColumnRowRange( xTable, UNO_QUERY_THROW ); 7839 7840 CreateTableRows( xColumnRowRange->getRows(), aRows, pGroup->GetSnapRect().Bottom() ); 7841 CreateTableColumns( xColumnRowRange->getColumns(), aColumns, pGroup->GetSnapRect().Right() ); 7842 7843 sal_Int32 nCellCount = aRows.size() * aColumns.size(); 7844 sal_Int32 *pMergedCellIndexTable = new sal_Int32[ nCellCount ]; 7845 for ( sal_Int32 i = 0; i < nCellCount; i++ ) 7846 pMergedCellIndexTable[ i ] = i; 7847 7848 aGroupIter.Reset(); 7849 while( aGroupIter.IsMore() ) 7850 { 7851 SdrObject* pObj( aGroupIter.Next() ); 7852 if ( !IsLine( pObj ) ) 7853 { 7854 Rectangle aSnapRect( pObj->GetSnapRect() ); 7855 sal_Int32 nTableIndex = 0; 7856 sal_Int32 nRow = 0; 7857 sal_Int32 nRowCount = 0; 7858 sal_Int32 nColumn = 0; 7859 sal_Int32 nColumnCount = 0; 7860 if ( GetCellPosition( pObj, aRows, aColumns, nTableIndex, nRow, nRowCount, nColumn, nColumnCount ) ) 7861 { 7862 Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW ); 7863 Reference< XCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ) ); 7864 7865 ApplyCellAttributes( pObj, xCell ); 7866 7867 if ( ( nRowCount > 1 ) || ( nColumnCount > 1 ) ) // cell merging 7868 { 7869 MergeCells( xTable, nColumn, nRow, nColumnCount, nRowCount ); 7870 for ( sal_Int32 nRowIter = 0; nRowIter < nRowCount; nRowIter++ ) 7871 { 7872 for ( sal_Int32 nColumnIter = 0; nColumnIter < nColumnCount; nColumnIter++ ) 7873 { // now set the correct index for the merged cell 7874 pMergedCellIndexTable[ ( ( nRow + nRowIter ) * aColumns.size() ) + nColumn + nColumnIter ] = nTableIndex; 7875 } 7876 } 7877 } 7878 7879 // applying text 7880 OutlinerParaObject* pParaObject = pObj->GetOutlinerParaObject(); 7881 if ( pParaObject ) 7882 { 7883 SdrText* pSdrText = pTable->getText( nTableIndex ); 7884 if ( pSdrText ) 7885 pSdrText->SetOutlinerParaObject(new OutlinerParaObject(*pParaObject) ); 7886 } 7887 } 7888 } 7889 } 7890 aGroupIter.Reset(); 7891 while( aGroupIter.IsMore() ) 7892 { 7893 SdrObject* pObj( aGroupIter.Next() ); 7894 if ( IsLine( pObj ) ) 7895 { 7896 std::vector< sal_Int32 > vPositions; // containing cell indexes + cell position 7897 GetLinePositions( pObj, aRows, aColumns, vPositions, pGroup->GetSnapRect() ); 7898 7899 // correcting merged cell position 7900 std::vector< sal_Int32 >::iterator aIter( vPositions.begin() ); 7901 while( aIter != vPositions.end() ) 7902 { 7903 sal_Int32 nOldPosition = *aIter & 0xffff; 7904 sal_Int32 nOldFlags = *aIter & 0xffff0000; 7905 sal_Int32 nNewPosition = pMergedCellIndexTable[ nOldPosition ] | nOldFlags; 7906 *aIter++ = nNewPosition; 7907 } 7908 ApplyCellLineAttributes( pObj, xTable, vPositions, aColumns.size() ); 7909 } 7910 } 7911 delete[] pMergedCellIndexTable; 7912 7913 // we are replacing the whole group object by a single table object, so 7914 // possibly connections to the group object have to be removed. 7915 if ( pSolverContainer ) 7916 { 7917 for ( SvxMSDffConnectorRule* pPtr = (SvxMSDffConnectorRule*)pSolverContainer->aCList.First(); 7918 pPtr; pPtr = (SvxMSDffConnectorRule*)pSolverContainer->aCList.Next() ) 7919 { 7920 SdrObjListIter aIter( *pGroup, IM_DEEPWITHGROUPS ); 7921 while( aIter.IsMore() ) 7922 { 7923 SdrObject* pPartObj = aIter.Next(); 7924 if ( pPtr->pAObj == pPartObj ) 7925 pPtr->pAObj = NULL; 7926 if ( pPtr->pBObj == pPartObj ) 7927 pPtr->pBObj = NULL; 7928 } 7929 //In MS, the one_row_one_col table is made up of five shape,the connector is connected to some part of a table. 7930 //but in AOO, the connector is connected to the whole group table,so the connector obj is a group table when export by AOO. 7931 //should process this situation when import. 7932 if ( pPtr->pAObj == pGroup ) 7933 pPtr->pAObj = pTable; 7934 if ( pPtr->pBObj == pGroup ) 7935 pPtr->pBObj = pTable; 7936 } 7937 } 7938 pTable->uno_unlock(); 7939 pTable->SetSnapRect( pGroup->GetSnapRect() ); 7940 pRet = pTable; 7941 7942 //Remove Objects from shape map 7943 SdrObjListIter aIter( *pGroup, IM_DEEPWITHGROUPS ); 7944 while( aIter.IsMore() ) 7945 { 7946 SdrObject* pPartObj = aIter.Next(); 7947 removeShapeId( pPartObj ); 7948 } 7949 7950 SdrObject::Free( pGroup ); 7951 } 7952 catch( Exception& ) 7953 { 7954 pTable->uno_unlock(); 7955 SdrObject* pObj = pTable; 7956 SdrObject::Free( pObj ); 7957 } 7958 } 7959 } 7960 return pRet; 7961 } 7962 7963 7964 //////////////////////////////////////////////////////////////////////////////////////////////////// 7965 sal_Bool SdrPowerPointImport::IsVerticalText() const 7966 { 7967 sal_Bool bVerticalText = sal_False; 7968 if ( IsProperty( DFF_Prop_txflTextFlow ) ) 7969 { 7970 MSO_TextFlow eTextFlow = (MSO_TextFlow)( GetPropertyValue( DFF_Prop_txflTextFlow ) & 0xFFFF ); 7971 switch( eTextFlow ) 7972 { 7973 case mso_txflTtoBA : // Top to Bottom @-font, above -> below 7974 case mso_txflTtoBN : // Top to Bottom non-@, above -> below 7975 case mso_txflVertN : // Vertical, non-@, above -> below 7976 bVerticalText = !bVerticalText; 7977 break; 7978 default: break; 7979 } 7980 } 7981 7982 return bVerticalText; 7983 } 7984 7985 void SdrPowerPointImport::ApplyTextAnchorAttributes( PPTTextObj& rTextObj, SfxItemSet& rSet ) const 7986 { 7987 SdrTextVertAdjust eTVA; 7988 SdrTextHorzAdjust eTHA; 7989 7990 sal_uInt32 nTextFlags = rTextObj.GetTextFlags(); 7991 7992 nTextFlags &= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT 7993 | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK; 7994 7995 if ( IsVerticalText() ) 7996 { 7997 eTVA = SDRTEXTVERTADJUST_BLOCK; 7998 eTHA = SDRTEXTHORZADJUST_CENTER; 7999 8000 // Textverankerung lesen 8001 MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop ); 8002 8003 switch( eTextAnchor ) 8004 { 8005 case mso_anchorTop: 8006 case mso_anchorTopCentered: 8007 eTHA = SDRTEXTHORZADJUST_RIGHT; 8008 break; 8009 8010 case mso_anchorMiddle : 8011 case mso_anchorMiddleCentered: 8012 eTHA = SDRTEXTHORZADJUST_CENTER; 8013 break; 8014 8015 case mso_anchorBottom: 8016 case mso_anchorBottomCentered: 8017 eTHA = SDRTEXTHORZADJUST_LEFT; 8018 break; 8019 8020 default: 8021 break; 8022 } 8023 // if there is a 100% use of following attributes, the textbox can been aligned also in vertical direction 8024 switch ( eTextAnchor ) 8025 { 8026 case mso_anchorTopCentered : 8027 case mso_anchorMiddleCentered : 8028 case mso_anchorBottomCentered : 8029 { 8030 // check if it is sensible to use the centered alignment 8031 sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; 8032 if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left or also right aligned pararagraphs 8033 eTVA = SDRTEXTVERTADJUST_CENTER; // the text has to be displayed using the full width; 8034 } 8035 break; 8036 8037 default : 8038 { 8039 if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT ) 8040 eTVA = SDRTEXTVERTADJUST_TOP; 8041 else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT ) 8042 eTVA = SDRTEXTVERTADJUST_BOTTOM; 8043 } 8044 break; 8045 } 8046 } 8047 else 8048 { 8049 eTVA = SDRTEXTVERTADJUST_CENTER; 8050 eTHA = SDRTEXTHORZADJUST_BLOCK; 8051 8052 // Textverankerung lesen 8053 MSO_Anchor eTextAnchor = (MSO_Anchor)GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop ); 8054 8055 switch( eTextAnchor ) 8056 { 8057 case mso_anchorTop: 8058 case mso_anchorTopCentered: 8059 eTVA = SDRTEXTVERTADJUST_TOP; 8060 break; 8061 8062 case mso_anchorMiddle : 8063 case mso_anchorMiddleCentered: 8064 eTVA = SDRTEXTVERTADJUST_CENTER; 8065 break; 8066 8067 case mso_anchorBottom: 8068 case mso_anchorBottomCentered: 8069 eTVA = SDRTEXTVERTADJUST_BOTTOM; 8070 break; 8071 8072 default: 8073 break; 8074 } 8075 // if there is a 100% usage of following attributes, the textbox can be aligned also in horizontal direction 8076 switch ( eTextAnchor ) 8077 { 8078 case mso_anchorTopCentered : 8079 case mso_anchorMiddleCentered : 8080 case mso_anchorBottomCentered : 8081 { 8082 // check if it is sensible to use the centered alignment 8083 sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; 8084 if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left or also right aligned pararagraphs 8085 eTHA = SDRTEXTHORZADJUST_CENTER; // the text has to be displayed using the full width; 8086 } 8087 break; 8088 8089 default : 8090 { 8091 if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT ) 8092 eTHA = SDRTEXTHORZADJUST_LEFT; 8093 else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT ) 8094 eTHA = SDRTEXTHORZADJUST_RIGHT; 8095 } 8096 break; 8097 } 8098 } 8099 rSet.Put( SdrTextVertAdjustItem( eTVA ) ); 8100 rSet.Put( SdrTextHorzAdjustItem( eTHA ) ); 8101 } 8102