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 27 #define ITEMID_FIELD 0 28 29 #include "svgwriter.hxx" 30 #include "svgfontexport.hxx" 31 #include "svgfilter.hxx" 32 #include "impsvgdialog.hxx" 33 34 #include <svtools/FilterConfigItem.hxx> 35 #include <svx/unopage.hxx> 36 #include <svx/unoshape.hxx> 37 #include <svx/svdpage.hxx> 38 #include <svx/svdoutl.hxx> 39 #include <editeng/outliner.hxx> 40 #include <editeng/flditem.hxx> 41 #include <editeng/numitem.hxx> 42 43 using ::rtl::OUString; 44 45 // ------------- 46 // - SVGExport - 47 // ------------- 48 49 SVGExport::SVGExport( 50 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, 51 const Reference< XDocumentHandler >& rxHandler, 52 const Sequence< PropertyValue >& rFilterData ) : 53 SvXMLExport( xServiceFactory, MAP_100TH_MM ), 54 mrFilterData( rFilterData ) 55 { 56 SetDocHandler( rxHandler ); 57 GetDocHandler()->startDocument(); 58 } 59 60 // ----------------------------------------------------------------------------- 61 62 SVGExport::~SVGExport() 63 { 64 GetDocHandler()->endDocument(); 65 } 66 67 // ----------------------------------------------------------------------------- 68 69 sal_Bool SVGExport::IsUseTinyProfile() const 70 { 71 sal_Bool bRet = sal_False; 72 73 if( mrFilterData.getLength() > 0 ) 74 mrFilterData[ 0 ].Value >>= bRet; 75 76 return bRet; 77 } 78 79 // ----------------------------------------------------------------------------- 80 81 sal_Bool SVGExport::IsEmbedFonts() const 82 { 83 sal_Bool bRet = sal_False; 84 85 if( mrFilterData.getLength() > 1 ) 86 mrFilterData[ 1 ].Value >>= bRet; 87 88 return bRet; 89 } 90 91 // ----------------------------------------------------------------------------- 92 93 sal_Bool SVGExport::IsUseNativeTextDecoration() const 94 { 95 sal_Bool bRet = !IsUseTinyProfile(); 96 97 if( bRet && ( mrFilterData.getLength() > 2 ) ) 98 mrFilterData[ 2 ].Value >>= bRet; 99 100 return bRet; 101 } 102 103 // ----------------------------------------------------------------------------- 104 105 ::rtl::OUString SVGExport::GetGlyphPlacement() const 106 { 107 ::rtl::OUString aRet; 108 109 if( mrFilterData.getLength() > 3 ) 110 mrFilterData[ 3 ].Value >>= aRet; 111 else 112 aRet = B2UCONST( "abs" ); 113 114 return aRet; 115 } 116 117 // ----------------------------------------------------------------------------- 118 119 sal_Bool SVGExport::IsUseOpacity() const 120 { 121 sal_Bool bRet = !IsUseTinyProfile(); 122 123 if( !bRet && ( mrFilterData.getLength() > 4 ) ) 124 mrFilterData[ 4 ].Value >>= bRet; 125 126 return bRet; 127 } 128 129 // ----------------------------------------------------------------------------- 130 131 sal_Bool SVGExport::IsUseGradient() const 132 { 133 sal_Bool bRet = !IsUseTinyProfile(); 134 135 if( !bRet && ( mrFilterData.getLength() > 5 ) ) 136 mrFilterData[ 5 ].Value >>= bRet; 137 138 return bRet; 139 } 140 141 // ----------------------------------------------------------------------------- 142 143 void SVGExport::pushClip( const ::basegfx::B2DPolyPolygon& rPolyPoly ) 144 { 145 maClipList.push_front( ::basegfx::tools::correctOrientations( rPolyPoly ) ); 146 } 147 148 // ----------------------------------------------------------------------------- 149 150 void SVGExport::popClip() 151 { 152 if( !maClipList.empty() ) 153 maClipList.pop_front(); 154 } 155 156 // ----------------------------------------------------------------------------- 157 158 sal_Bool SVGExport::hasClip() const 159 { 160 return( !maClipList.empty() ); 161 } 162 163 // ----------------------------------------------------------------------------- 164 165 const ::basegfx::B2DPolyPolygon* SVGExport::getCurClip() const 166 { 167 return( maClipList.empty() ? NULL : &( *maClipList.begin() ) ); 168 } 169 170 // ------------------------ 171 // - ObjectRepresentation - 172 // ------------------------ 173 174 ObjectRepresentation::ObjectRepresentation() : 175 mpMtf( NULL ) 176 { 177 } 178 179 // ----------------------------------------------------------------------------- 180 181 ObjectRepresentation::ObjectRepresentation( const Reference< XInterface >& rxObject, 182 const GDIMetaFile& rMtf ) : 183 mxObject( rxObject ), 184 mpMtf( new GDIMetaFile( rMtf ) ) 185 { 186 } 187 188 // ----------------------------------------------------------------------------- 189 190 ObjectRepresentation::ObjectRepresentation( const ObjectRepresentation& rPresentation ) : 191 mxObject( rPresentation.mxObject ), 192 mpMtf( rPresentation.mpMtf ? new GDIMetaFile( *rPresentation.mpMtf ) : NULL ) 193 { 194 } 195 196 // ----------------------------------------------------------------------------- 197 198 ObjectRepresentation::~ObjectRepresentation() 199 { 200 delete mpMtf; 201 } 202 203 // ----------------------------------------------------------------------------- 204 205 ObjectRepresentation& ObjectRepresentation::operator=( const ObjectRepresentation& rPresentation ) 206 { 207 mxObject = rPresentation.mxObject; 208 delete mpMtf, ( mpMtf = rPresentation.mpMtf ? new GDIMetaFile( *rPresentation.mpMtf ) : NULL ); 209 210 return *this; 211 } 212 213 // ----------------------------------------------------------------------------- 214 215 sal_Bool ObjectRepresentation::operator==( const ObjectRepresentation& rPresentation ) const 216 { 217 return( ( mxObject == rPresentation.mxObject ) && 218 ( *mpMtf == *rPresentation.mpMtf ) ); 219 } 220 221 // ------------- 222 // - SVGFilter - 223 // ------------- 224 225 sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) 226 throw (RuntimeException) 227 { 228 Reference< XMultiServiceFactory > xServiceFactory( ::comphelper::getProcessServiceFactory() ) ; 229 Reference< XOutputStream > xOStm; 230 SvStream* pOStm = NULL; 231 sal_Int32 nLength = rDescriptor.getLength(); 232 sal_Int32 nPageToExport = SVG_EXPORT_ALLPAGES; 233 const PropertyValue* pValue = rDescriptor.getConstArray(); 234 sal_Bool bRet = sal_False; 235 236 mnMasterSlideId = mnSlideId = mnDrawingGroupId = mnDrawingId = 0; 237 maFilterData.realloc( 0 ); 238 239 for ( sal_Int32 i = 0 ; i < nLength; ++i) 240 { 241 if( pValue[ i ].Name.equalsAscii( "OutputStream" ) ) 242 pValue[ i ].Value >>= xOStm; 243 else if( pValue[ i ].Name.equalsAscii( "FileName" ) ) 244 { 245 ::rtl::OUString aFileName; 246 247 pValue[ i ].Value >>= aFileName; 248 pOStm = ::utl::UcbStreamHelper::CreateStream( aFileName, STREAM_WRITE | STREAM_TRUNC ); 249 250 if( pOStm ) 251 xOStm = Reference< XOutputStream >( new ::utl::OOutputStreamWrapper ( *pOStm ) ); 252 } 253 else if( pValue[ i ].Name.equalsAscii( "PagePos" ) ) 254 { 255 pValue[ i ].Value >>= nPageToExport; 256 } 257 else if( pValue[ i ].Name.equalsAscii( "FilterData" ) ) 258 { 259 pValue[ i ].Value >>= maFilterData; 260 } 261 } 262 263 // if no filter data is given use stored/prepared ones 264 if( !maFilterData.getLength() ) 265 { 266 #ifdef _SVG_USE_CONFIG 267 FilterConfigItem aCfgItem( String( RTL_CONSTASCII_USTRINGPARAM( SVG_EXPORTFILTER_CONFIGPATH ) ) ); 268 269 aCfgItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_TINYPROFILE ) ), sal_True ); 270 aCfgItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_EMBEDFONTS ) ), sal_True ); 271 aCfgItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_NATIVEDECORATION ) ), sal_False ); 272 aCfgItem.ReadString( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_NATIVEDECORATION ) ), B2UCONST( "xlist" ) ); 273 aCfgItem.ReadString( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_OPACITY ) ), sal_True ); 274 aCfgItem.ReadString( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_GRADIENT ) ), sal_True ); 275 276 maFilterData = aCfgItem.GetFilterData(); 277 #else 278 maFilterData.realloc( 6 ); 279 280 maFilterData[ 0 ].Name = B2UCONST( SVG_PROP_TINYPROFILE ); 281 maFilterData[ 0 ].Value <<= (sal_Bool) sal_True; 282 283 // font embedding 284 const char* pSVGDisableFontEmbedding = getenv( "SVG_DISABLE_FONT_EMBEDDING" ); 285 286 maFilterData[ 1 ].Name = B2UCONST( SVG_PROP_EMBEDFONTS ); 287 maFilterData[ 1 ].Value <<= (sal_Bool) ( pSVGDisableFontEmbedding ? sal_False : sal_True ); 288 289 // Native decoration 290 maFilterData[ 2 ].Name = B2UCONST( SVG_PROP_NATIVEDECORATION ); 291 maFilterData[ 2 ].Value <<= (sal_Bool) sal_False; 292 293 // glyph placement 294 const char* pSVGGlyphPlacement = getenv( "SVG_GLYPH_PLACEMENT" ); 295 296 maFilterData[ 3 ].Name = B2UCONST( SVG_PROP_GLYPHPLACEMENT ); 297 298 if( pSVGGlyphPlacement ) 299 maFilterData[ 3 ].Value <<= ::rtl::OUString::createFromAscii( pSVGGlyphPlacement ); 300 else 301 maFilterData[ 3 ].Value <<= B2UCONST( "xlist" ); 302 303 // Tiny Opacity 304 maFilterData[ 4 ].Name = B2UCONST( SVG_PROP_OPACITY ); 305 maFilterData[ 4 ].Value <<= (sal_Bool) sal_True; 306 307 // Tiny Gradient 308 maFilterData[ 5 ].Name = B2UCONST( SVG_PROP_GRADIENT ); 309 maFilterData[ 5 ].Value <<= (sal_Bool) sal_False; 310 #endif 311 } 312 313 if( xOStm.is() && xServiceFactory.is() ) 314 { 315 Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxSrcDoc, UNO_QUERY ); 316 Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxSrcDoc, UNO_QUERY ); 317 318 if( xMasterPagesSupplier.is() && xDrawPagesSupplier.is() ) 319 { 320 Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY ); 321 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY ); 322 323 if( xMasterPages.is() && xMasterPages->getCount() && xDrawPages.is() && xDrawPages->getCount() ) 324 { 325 Reference< XDocumentHandler > xDocHandler( implCreateExportDocumentHandler( xOStm ) ); 326 327 if( xDocHandler.is() ) 328 { 329 mbPresentation = Reference< XPresentationSupplier >( mxSrcDoc, UNO_QUERY ).is(); 330 mpObjects = new ObjectMap; 331 332 // #110680# 333 // mpSVGExport = new SVGExport( xDocHandler ); 334 mpSVGExport = new SVGExport( xServiceFactory, xDocHandler, maFilterData ); 335 336 if( nPageToExport < 0 || nPageToExport >= xDrawPages->getCount() ) 337 nPageToExport = SVG_EXPORT_ALLPAGES; 338 339 try 340 { 341 const sal_Int32 nDefaultPage = ( ( SVG_EXPORT_ALLPAGES == nPageToExport ) ? 0 : nPageToExport ); 342 343 xDrawPages->getByIndex( nDefaultPage ) >>= mxDefaultPage; 344 345 if( mxDefaultPage.is() ) 346 { 347 SvxDrawPage* pSvxDrawPage = SvxDrawPage::getImplementation( mxDefaultPage ); 348 349 if( pSvxDrawPage ) 350 { 351 mpDefaultSdrPage = pSvxDrawPage->GetSdrPage(); 352 mpSdrModel = mpDefaultSdrPage->GetModel(); 353 354 if( mpSdrModel ) 355 { 356 SdrOutliner& rOutl = mpSdrModel->GetDrawOutliner(NULL); 357 358 maOldFieldHdl = rOutl.GetCalcFieldValueHdl(); 359 rOutl.SetCalcFieldValueHdl( LINK( this, SVGFilter, CalcFieldHdl) ); 360 } 361 } 362 363 if( implCreateObjects( xMasterPages, xDrawPages, nPageToExport ) ) 364 { 365 ObjectMap::const_iterator aIter( mpObjects->begin() ); 366 ::std::vector< ObjectRepresentation > aObjects( mpObjects->size() ); 367 sal_uInt32 nPos = 0; 368 369 while( aIter != mpObjects->end() ) 370 { 371 aObjects[ nPos++ ] = (*aIter).second; 372 ++aIter; 373 } 374 375 mpSVGFontExport = new SVGFontExport( *mpSVGExport, aObjects ); 376 mpSVGWriter = new SVGActionWriter( *mpSVGExport, *mpSVGFontExport ); 377 378 bRet = implExportDocument( xMasterPages, xDrawPages, nPageToExport ); 379 } 380 } 381 } 382 catch( ... ) 383 { 384 delete mpSVGDoc, mpSVGDoc = NULL; 385 DBG_ERROR( "Exception caught" ); 386 } 387 388 if( mpSdrModel ) 389 mpSdrModel->GetDrawOutliner( NULL ).SetCalcFieldValueHdl( maOldFieldHdl ); 390 391 delete mpSVGWriter, mpSVGWriter = NULL; 392 delete mpSVGExport, mpSVGExport = NULL; 393 delete mpSVGFontExport, mpSVGFontExport = NULL; 394 delete mpObjects, mpObjects = NULL; 395 mbPresentation = sal_False; 396 } 397 } 398 } 399 } 400 401 delete pOStm; 402 403 return bRet; 404 } 405 406 // ----------------------------------------------------------------------------- 407 408 Reference< XDocumentHandler > SVGFilter::implCreateExportDocumentHandler( const Reference< XOutputStream >& rxOStm ) 409 { 410 Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); 411 Reference< XDocumentHandler > xSaxWriter; 412 413 if( xMgr.is() && rxOStm.is() ) 414 { 415 xSaxWriter = Reference< XDocumentHandler >( xMgr->createInstance( B2UCONST( "com.sun.star.xml.sax.Writer" ) ), UNO_QUERY ); 416 417 if( xSaxWriter.is() ) 418 { 419 Reference< XActiveDataSource > xActiveDataSource( xSaxWriter, UNO_QUERY ); 420 421 if( xActiveDataSource.is() ) 422 xActiveDataSource->setOutputStream( rxOStm ); 423 else 424 xSaxWriter = NULL; 425 } 426 } 427 428 return xSaxWriter; 429 } 430 431 // ----------------------------------------------------------------------------- 432 433 sal_Bool SVGFilter::implExportDocument( const Reference< XDrawPages >& rxMasterPages, 434 const Reference< XDrawPages >& rxDrawPages, 435 sal_Int32 nPageToExport ) 436 { 437 DBG_ASSERT( rxMasterPages.is() && rxDrawPages.is(), 438 "SVGFilter::implExportDocument: invalid parameter" ); 439 440 OUString aAttr; 441 sal_Int32 nDocWidth = 0, nDocHeight = 0; 442 sal_Int32 nVisible = -1, nVisibleMaster = -1; 443 sal_Bool bRet = sal_False; 444 const sal_Bool bSinglePage = ( rxDrawPages->getCount() == 1 ) || ( SVG_EXPORT_ALLPAGES != nPageToExport ); 445 const sal_Int32 nFirstPage = ( ( SVG_EXPORT_ALLPAGES == nPageToExport ) ? 0 : nPageToExport ); 446 sal_Int32 nCurPage = nFirstPage, nLastPage = ( bSinglePage ? nFirstPage : ( rxDrawPages->getCount() - 1 ) ); 447 448 const Reference< XPropertySet > xDefaultPagePropertySet( mxDefaultPage, UNO_QUERY ); 449 const Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY ); 450 451 if( xDefaultPagePropertySet.is() ) 452 { 453 xDefaultPagePropertySet->getPropertyValue( B2UCONST( "Width" ) ) >>= nDocWidth; 454 xDefaultPagePropertySet->getPropertyValue( B2UCONST( "Height" ) ) >>= nDocHeight; 455 } 456 457 if( xExtDocHandler.is() && !mpSVGExport->IsUseTinyProfile() ) 458 { 459 xExtDocHandler->unknown( SVG_DTD_STRING ); 460 } 461 462 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "version", B2UCONST( "1.2" ) ); 463 464 if( mpSVGExport->IsUseTinyProfile() ) 465 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "baseProfile", B2UCONST( "tiny" ) ); 466 467 #ifdef _SVG_WRITE_EXTENTS 468 aAttr = OUString::valueOf( nDocWidth * 0.01 ); 469 aAttr += B2UCONST( "mm" ); 470 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "width", aAttr ); 471 472 aAttr = OUString::valueOf( nDocHeight * 0.01 ); 473 aAttr += B2UCONST( "mm" ); 474 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "height", aAttr ); 475 #endif 476 477 aAttr = B2UCONST( "0 0 " ); 478 aAttr += OUString::valueOf( nDocWidth ); 479 aAttr += B2UCONST( " " ); 480 aAttr += OUString::valueOf( nDocHeight ); 481 482 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "viewBox", aAttr ); 483 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "preserveAspectRatio", B2UCONST( "xMidYMid" ) ); 484 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "fill-rule", B2UCONST( "evenodd" ) ); 485 486 // standard line width is based on 1 pixel on a 90 DPI device (0.28222mmm) 487 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "stroke-width", OUString::valueOf( 28.222 ) ); 488 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "stroke-linejoin", B2UCONST( "round" ) ); 489 490 if( !bSinglePage ) 491 { 492 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:ooo", B2UCONST( "http://xml.openoffice.org/svg/export" ) ); 493 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "onclick", B2UCONST( "onClick(evt)" ) ); 494 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "onkeypress", B2UCONST( "onKeyPress(evt)" ) ); 495 } 496 497 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns", B2UCONST( "http://www.w3.org/2000/svg" ) ); 498 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:xlink", B2UCONST( "http://www.w3.org/1999/xlink" ) ); 499 500 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xml:space", B2UCONST( "preserve" ) ); 501 502 mpSVGDoc = new SvXMLElementExport( *mpSVGExport, XML_NAMESPACE_NONE, "svg", sal_True, sal_True ); 503 504 while( ( nCurPage <= nLastPage ) && ( -1 == nVisible ) ) 505 { 506 Reference< XDrawPage > xDrawPage; 507 508 rxDrawPages->getByIndex( nCurPage ) >>= xDrawPage; 509 510 if( xDrawPage.is() ) 511 { 512 Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY ); 513 514 if( xPropSet.is() ) 515 { 516 sal_Bool bVisible = sal_False; 517 518 if( !mbPresentation || bSinglePage || 519 ( ( xPropSet->getPropertyValue( B2UCONST( "Visible" ) ) >>= bVisible ) && bVisible ) ) 520 { 521 Reference< XMasterPageTarget > xMasterTarget( xDrawPage, UNO_QUERY ); 522 523 if( xMasterTarget.is() ) 524 { 525 Reference< XDrawPage > xMasterPage( xMasterTarget->getMasterPage() ); 526 527 nVisible = nCurPage; 528 529 for( sal_Int32 nMaster = 0, nMasterCount = rxMasterPages->getCount(); 530 ( nMaster < nMasterCount ) && ( -1 == nVisibleMaster ); 531 ++nMaster ) 532 { 533 Reference< XDrawPage > xMasterTestPage; 534 535 rxMasterPages->getByIndex( nMaster ) >>= xMasterTestPage; 536 537 if( xMasterTestPage == xMasterPage ) 538 nVisibleMaster = nMaster; 539 } 540 } 541 } 542 } 543 } 544 545 ++nCurPage; 546 } 547 548 if( mpSVGExport->IsEmbedFonts() ) 549 { 550 mpSVGFontExport->EmbedFonts(); 551 } 552 553 if( -1 != nVisible ) 554 { 555 if( bSinglePage ) 556 implExportPages( rxMasterPages, nVisibleMaster, nVisibleMaster, nVisibleMaster, sal_True ); 557 else 558 { 559 implGenerateMetaData( rxMasterPages, rxDrawPages ); 560 implGenerateScript( rxMasterPages, rxDrawPages ); 561 implExportPages( rxMasterPages, 0, rxMasterPages->getCount() - 1, nVisibleMaster, sal_True ); 562 } 563 564 implExportPages( rxDrawPages, nFirstPage, nLastPage, nVisible, sal_False ); 565 566 delete mpSVGDoc, mpSVGDoc = NULL; 567 bRet = sal_True; 568 } 569 570 return bRet; 571 } 572 573 // ----------------------------------------------------------------------------- 574 575 sal_Bool SVGFilter::implGenerateMetaData( const Reference< XDrawPages >& /* rxMasterPages */, 576 const Reference< XDrawPages >& rxDrawPages ) 577 { 578 sal_Bool bRet = sal_False; 579 580 if( rxDrawPages->getCount() ) 581 { 582 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", B2UCONST( "meta_slides" ) ); 583 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "numberOfSlides", OUString::valueOf( rxDrawPages->getCount() ) ); 584 585 { 586 SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "ooo:slidesInfo", sal_True, sal_True ); 587 const OUString aId( B2UCONST( "meta_slide" ) ); 588 589 for( sal_Int32 i = 0, nCount = rxDrawPages->getCount(); i < nCount; ++i ) 590 { 591 OUString aSlideId( aId ); 592 Reference< XDrawPage > xDrawPage( rxDrawPages->getByIndex( i ), UNO_QUERY ); 593 Reference< XMasterPageTarget > xMasterPageTarget( xDrawPage, UNO_QUERY ); 594 Reference< XDrawPage > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY ); 595 sal_Bool bMasterVisible = sal_True; 596 OUString aMasterVisibility; 597 598 aSlideId += OUString::valueOf( i ); 599 600 if( mbPresentation ) 601 { 602 Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY ); 603 604 if( xPropSet.is() ) 605 xPropSet->getPropertyValue( B2UCONST( "Background" ) ) >>= bMasterVisible; 606 } 607 608 if( bMasterVisible ) 609 aMasterVisibility = B2UCONST( "visible" ); 610 else 611 aMasterVisibility = B2UCONST( "hidden" ); 612 613 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aSlideId ); 614 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "slide", implGetValidIDFromInterface( xDrawPage ) ); 615 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "master", implGetValidIDFromInterface( xMasterPage ) ); 616 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "master-visibility", aMasterVisibility ); 617 618 { 619 SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "ooo:slideInfo", sal_True, sal_True ); 620 } 621 } 622 } 623 624 625 bRet =sal_True; 626 } 627 628 return bRet; 629 } 630 631 // ----------------------------------------------------------------------------- 632 633 sal_Bool SVGFilter::implGenerateScript( const Reference< XDrawPages >& /* rxMasterPages */, 634 const Reference< XDrawPages >& /* rxDrawPages */ ) 635 { 636 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "type", B2UCONST( "text/ecmascript" ) ); 637 638 { 639 SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "script", sal_True, sal_True ); 640 Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY ); 641 642 if( xExtDocHandler.is() ) 643 { 644 xExtDocHandler->unknown( OUString::createFromAscii( aSVGScript1 ) ); 645 xExtDocHandler->unknown( OUString::createFromAscii( aSVGScript2 ) ); 646 } 647 } 648 649 return sal_True; 650 } 651 652 // ----------------------------------------------------------------------------- 653 654 sal_Bool SVGFilter::implExportPages( const Reference< XDrawPages >& rxPages, 655 sal_Int32 nFirstPage, sal_Int32 nLastPage, 656 sal_Int32 nVisiblePage, sal_Bool bMaster ) 657 { 658 DBG_ASSERT( nFirstPage <= nLastPage, 659 "SVGFilter::implExportPages: nFirstPage > nLastPage" ); 660 661 sal_Bool bRet = sal_False; 662 663 for( sal_Int32 i = nFirstPage; i <= nLastPage; ++i ) 664 { 665 Reference< XDrawPage > xDrawPage; 666 667 rxPages->getByIndex( i ) >>= xDrawPage; 668 669 if( xDrawPage.is() ) 670 { 671 Reference< XShapes > xShapes( xDrawPage, UNO_QUERY ); 672 673 if( xShapes.is() ) 674 { 675 OUString aVisibility, aId, aSlideName( implGetValidIDFromInterface( xShapes, sal_True ) ); 676 677 // add visibility attribute 678 if( i == nVisiblePage ) 679 aVisibility = B2UCONST( "visible" ); 680 else 681 aVisibility = B2UCONST( "hidden" ); 682 683 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", aVisibility ); 684 685 // add id attribute 686 if( bMaster ) 687 aId = ( B2UCONST( "MasterSlide_" ) ) += ::rtl::OUString::valueOf( ++mnMasterSlideId ); 688 else 689 aId = ( B2UCONST( "Slide_" ) ) += ::rtl::OUString::valueOf( ++mnSlideId ); 690 691 if( aSlideName.getLength() ) 692 ( aId += B2UCONST( "_" ) ) += aSlideName; 693 694 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aId ); 695 696 { 697 SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); 698 const Point aNullPt; 699 700 if( mpObjects->find( xDrawPage ) != mpObjects->end() ) 701 { 702 Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY ); 703 704 if( xExtDocHandler.is() ) 705 { 706 SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "desc", sal_True, sal_True ); 707 OUString aDesc; 708 709 if( bMaster ) 710 aDesc = B2UCONST( "Master slide" ); 711 else 712 aDesc = B2UCONST( "Slide" ); 713 714 xExtDocHandler->unknown( aDesc ); 715 } 716 } 717 718 if( bMaster ) 719 { 720 const GDIMetaFile& rMtf = (*mpObjects)[ xDrawPage ].GetRepresentation(); 721 mpSVGWriter->WriteMetaFile( aNullPt, rMtf.GetPrefSize(), rMtf, SVGWRITER_WRITE_FILL ); 722 } 723 724 bRet = implExportShapes( xShapes ) || bRet; 725 } 726 } 727 } 728 } 729 730 return bRet; 731 } 732 733 // ----------------------------------------------------------------------------- 734 735 sal_Bool SVGFilter::implExportShapes( const Reference< XShapes >& rxShapes ) 736 { 737 Reference< XShape > xShape; 738 sal_Bool bRet = sal_False; 739 740 for( sal_Int32 i = 0, nCount = rxShapes->getCount(); i < nCount; ++i ) 741 { 742 if( ( rxShapes->getByIndex( i ) >>= xShape ) && xShape.is() ) 743 bRet = implExportShape( xShape ) || bRet; 744 745 xShape = NULL; 746 } 747 748 return bRet; 749 } 750 751 // ----------------------------------------------------------------------------- 752 753 sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape ) 754 { 755 Reference< XPropertySet > xShapePropSet( rxShape, UNO_QUERY ); 756 sal_Bool bRet = sal_False; 757 758 if( xShapePropSet.is() ) 759 { 760 const ::rtl::OUString aShapeType( rxShape->getShapeType() ); 761 sal_Bool bHideObj = sal_False; 762 763 if( mbPresentation ) 764 { 765 xShapePropSet->getPropertyValue( B2UCONST( "IsEmptyPresentationObject" ) ) >>= bHideObj; 766 767 if( !bHideObj ) 768 { 769 const Reference< XPropertySet > xDefaultPagePropertySet( mxDefaultPage, UNO_QUERY ); 770 Reference< XPropertySetInfo > xPagePropSetInfo( xDefaultPagePropertySet->getPropertySetInfo() ); 771 772 if( xPagePropSetInfo.is() ) 773 { 774 const ::rtl::OUString aHeaderString( B2UCONST( "IsHeaderVisible" ) ); 775 const ::rtl::OUString aFooterString( B2UCONST( "IsFooterVisible" ) ); 776 const ::rtl::OUString aDateTimeString( B2UCONST( "IsDateTimeVisible" ) ); 777 const ::rtl::OUString aPageNumberString( B2UCONST( "IsPageNumberVisible" ) ); 778 779 Any aProperty; 780 sal_Bool bValue = sal_False; 781 782 if( ( aShapeType.lastIndexOf( B2UCONST( "presentation.HeaderShape" ) ) != -1 ) && 783 xPagePropSetInfo->hasPropertyByName( aHeaderString ) && 784 ( ( aProperty = xDefaultPagePropertySet->getPropertyValue( aHeaderString ) ) >>= bValue ) && 785 !bValue ) 786 { 787 bHideObj = sal_True; 788 } 789 else if( ( aShapeType.lastIndexOf( B2UCONST( "presentation.FooterShape" ) ) != -1 ) && 790 xPagePropSetInfo->hasPropertyByName( aFooterString ) && 791 ( ( aProperty = xDefaultPagePropertySet->getPropertyValue( aFooterString ) ) >>= bValue ) && 792 !bValue ) 793 { 794 bHideObj = sal_True; 795 } 796 else if( ( aShapeType.lastIndexOf( B2UCONST( "presentation.DateTimeShape" ) ) != -1 ) && 797 xPagePropSetInfo->hasPropertyByName( aDateTimeString ) && 798 ( ( aProperty = xDefaultPagePropertySet->getPropertyValue( aDateTimeString ) ) >>= bValue ) && 799 !bValue ) 800 { 801 bHideObj = sal_True; 802 } 803 else if( ( aShapeType.lastIndexOf( B2UCONST( "presentation.SlideNumberShape" ) ) != -1 ) && 804 xPagePropSetInfo->hasPropertyByName( aPageNumberString ) && 805 ( ( aProperty = xDefaultPagePropertySet->getPropertyValue( aPageNumberString ) ) >>= bValue ) && 806 !bValue ) 807 { 808 bHideObj = sal_True; 809 } 810 } 811 } 812 } 813 814 if( !bHideObj ) 815 { 816 if( aShapeType.lastIndexOf( B2UCONST( "drawing.GroupShape" ) ) != -1 ) 817 { 818 Reference< XShapes > xShapes( rxShape, UNO_QUERY ); 819 820 if( xShapes.is() ) 821 { 822 OUString aId( B2UCONST( "DrawingGroup_" ) ); 823 OUString aObjName( implGetValidIDFromInterface( rxShape, sal_True ) ), aObjDesc; 824 825 aId += ::rtl::OUString::valueOf( ++mnDrawingGroupId ); 826 827 if( aObjName.getLength() ) 828 ( aId += B2UCONST( "_" ) ) += aObjName; 829 830 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aId ); 831 832 { 833 SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); 834 bRet = implExportShapes( xShapes ); 835 } 836 } 837 } 838 839 if( !bRet && mpObjects->find( rxShape ) != mpObjects->end() ) 840 { 841 Reference< XText > xText( rxShape, UNO_QUERY ); 842 ::com::sun::star::awt::Rectangle aBoundRect; 843 const GDIMetaFile& rMtf = (*mpObjects)[ rxShape ].GetRepresentation(); 844 845 xShapePropSet->getPropertyValue( B2UCONST( "BoundRect" ) ) >>= aBoundRect; 846 847 const Point aTopLeft( aBoundRect.X, aBoundRect.Y ); 848 const Size aSize( aBoundRect.Width, aBoundRect.Height ); 849 850 if( rMtf.GetActionCount() ) 851 { 852 OUString aId( B2UCONST( "Drawing_" ) ); 853 OUString aObjName( implGetValidIDFromInterface( rxShape, sal_True ) ), aObjDesc; 854 855 aId += ::rtl::OUString::valueOf( ++mnDrawingId ); 856 857 if( aObjName.getLength() ) 858 ( aId += B2UCONST( "_" ) ) += aObjName; 859 860 { 861 if( ( aShapeType.lastIndexOf( B2UCONST( "drawing.OLE2Shape" ) ) != -1 ) || 862 ( aShapeType.lastIndexOf( B2UCONST( "drawing.GraphicObjectShape" ) ) != -1 ) ) 863 { 864 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aId ); 865 866 { 867 SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); 868 mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_FILL | SVGWRITER_WRITE_TEXT ); 869 } 870 } 871 else 872 { 873 if( implHasText( rMtf ) ) 874 { 875 mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aId ); 876 877 { 878 SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); 879 mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_FILL ); 880 mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_TEXT ); 881 } 882 } 883 else 884 { 885 SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); 886 mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_FILL | SVGWRITER_WRITE_TEXT, &aId ); 887 } 888 } 889 } 890 } 891 892 bRet = sal_True; 893 } 894 } 895 } 896 897 return bRet; 898 } 899 900 // ----------------------------------------------------------------------------- 901 902 sal_Bool SVGFilter::implCreateObjects( const Reference< XDrawPages >& rxMasterPages, 903 const Reference< XDrawPages >& rxDrawPages, 904 sal_Int32 nPageToExport ) 905 { 906 if( SVG_EXPORT_ALLPAGES == nPageToExport ) 907 { 908 sal_Int32 i, nCount; 909 910 for( i = 0, nCount = rxMasterPages->getCount(); i < nCount; ++i ) 911 { 912 Reference< XDrawPage > xMasterPage; 913 914 rxMasterPages->getByIndex( i ) >>= xMasterPage; 915 916 if( xMasterPage.is() ) 917 { 918 Reference< XShapes > xShapes( xMasterPage, UNO_QUERY ); 919 920 implCreateObjectsFromBackground( xMasterPage ); 921 922 if( xShapes.is() ) 923 implCreateObjectsFromShapes( xShapes ); 924 } 925 } 926 927 for( i = 0, nCount = rxDrawPages->getCount(); i < nCount; ++i ) 928 { 929 Reference< XDrawPage > xDrawPage; 930 931 rxDrawPages->getByIndex( i ) >>= xDrawPage; 932 933 if( xDrawPage.is() ) 934 { 935 Reference< XShapes > xShapes( xDrawPage, UNO_QUERY ); 936 937 if( xShapes.is() ) 938 implCreateObjectsFromShapes( xShapes ); 939 } 940 } 941 } 942 else 943 { 944 DBG_ASSERT( nPageToExport >= 0 && nPageToExport < rxDrawPages->getCount(), 945 "SVGFilter::implCreateObjects: invalid page number to export" ); 946 947 Reference< XDrawPage > xDrawPage; 948 949 rxDrawPages->getByIndex( nPageToExport ) >>= xDrawPage; 950 951 if( xDrawPage.is() ) 952 { 953 Reference< XMasterPageTarget > xMasterTarget( xDrawPage, UNO_QUERY ); 954 955 if( xMasterTarget.is() ) 956 { 957 Reference< XDrawPage > xMasterPage( xMasterTarget->getMasterPage() ); 958 959 if( xMasterPage.is() ) 960 { 961 Reference< XShapes > xShapes( xMasterPage, UNO_QUERY ); 962 963 implCreateObjectsFromBackground( xMasterPage ); 964 965 if( xShapes.is() ) 966 implCreateObjectsFromShapes( xShapes ); 967 } 968 } 969 970 Reference< XShapes > xShapes( xDrawPage, UNO_QUERY ); 971 972 if( xShapes.is() ) 973 implCreateObjectsFromShapes( xShapes ); 974 } 975 } 976 977 return sal_True; 978 } 979 980 // ----------------------------------------------------------------------------- 981 982 sal_Bool SVGFilter::implCreateObjectsFromShapes( const Reference< XShapes >& rxShapes ) 983 { 984 Reference< XShape > xShape; 985 sal_Bool bRet = sal_False; 986 987 for( sal_Int32 i = 0, nCount = rxShapes->getCount(); i < nCount; ++i ) 988 { 989 if( ( rxShapes->getByIndex( i ) >>= xShape ) && xShape.is() ) 990 bRet = implCreateObjectsFromShape( xShape ) || bRet; 991 992 xShape = NULL; 993 } 994 995 return bRet; 996 } 997 998 // ----------------------------------------------------------------------------- 999 1000 sal_Bool SVGFilter::implCreateObjectsFromShape( const Reference< XShape >& rxShape ) 1001 { 1002 sal_Bool bRet = sal_False; 1003 1004 if( rxShape->getShapeType().lastIndexOf( B2UCONST( "drawing.GroupShape" ) ) != -1 ) 1005 { 1006 Reference< XShapes > xShapes( rxShape, UNO_QUERY ); 1007 1008 if( xShapes.is() ) 1009 bRet = implCreateObjectsFromShapes( xShapes ); 1010 } 1011 else 1012 { 1013 SdrObject* pObj = GetSdrObjectFromXShape( rxShape ); 1014 1015 if( pObj ) 1016 { 1017 Graphic aGraphic( SdrExchangeView::GetObjGraphic( pObj->GetModel(), pObj ) ); 1018 1019 if( aGraphic.GetType() != GRAPHIC_NONE ) 1020 { 1021 if( aGraphic.GetType() == GRAPHIC_BITMAP ) 1022 { 1023 GDIMetaFile aMtf; 1024 const Point aNullPt; 1025 const Size aSize( pObj->GetCurrentBoundRect().GetSize() ); 1026 1027 aMtf.AddAction( new MetaBmpExScaleAction( aNullPt, aSize, aGraphic.GetBitmapEx() ) ); 1028 aMtf.SetPrefSize( aSize ); 1029 aMtf.SetPrefMapMode( MAP_100TH_MM ); 1030 1031 (*mpObjects)[ rxShape ] = ObjectRepresentation( rxShape, aMtf ); 1032 } 1033 else 1034 (*mpObjects)[ rxShape ] = ObjectRepresentation( rxShape, aGraphic.GetGDIMetaFile() ); 1035 1036 bRet = sal_True; 1037 } 1038 } 1039 } 1040 1041 return bRet; 1042 } 1043 1044 // ----------------------------------------------------------------------------- 1045 1046 sal_Bool SVGFilter::implCreateObjectsFromBackground( const Reference< XDrawPage >& rxMasterPage ) 1047 { 1048 Reference< XExporter > xExporter( mxMSF->createInstance( B2UCONST( "com.sun.star.drawing.GraphicExportFilter" ) ), UNO_QUERY ); 1049 sal_Bool bRet = sal_False; 1050 1051 if( xExporter.is() ) 1052 { 1053 GDIMetaFile aMtf; 1054 Reference< XFilter > xFilter( xExporter, UNO_QUERY ); 1055 1056 utl::TempFile aFile; 1057 aFile.EnableKillingFile(); 1058 1059 Sequence< PropertyValue > aDescriptor( 3 ); 1060 aDescriptor[0].Name = B2UCONST( "FilterName" ); 1061 aDescriptor[0].Value <<= B2UCONST( "SVM" ); 1062 aDescriptor[1].Name = B2UCONST( "URL" ); 1063 aDescriptor[1].Value <<= OUString( aFile.GetURL() ); 1064 aDescriptor[2].Name = B2UCONST( "ExportOnlyBackground" ); 1065 aDescriptor[2].Value <<= (sal_Bool) sal_True; 1066 1067 xExporter->setSourceDocument( Reference< XComponent >( rxMasterPage, UNO_QUERY ) ); 1068 xFilter->filter( aDescriptor ); 1069 aMtf.Read( *aFile.GetStream( STREAM_READ ) ); 1070 1071 (*mpObjects)[ rxMasterPage ] = ObjectRepresentation( rxMasterPage, aMtf ); 1072 1073 bRet = sal_True; 1074 } 1075 1076 return bRet; 1077 } 1078 1079 // ----------------------------------------------------------------------------- 1080 1081 OUString SVGFilter::implGetDescriptionFromShape( const Reference< XShape >& rxShape ) 1082 { 1083 OUString aRet; 1084 const OUString aShapeType( rxShape->getShapeType() ); 1085 1086 if( aShapeType.lastIndexOf( B2UCONST( "drawing.GroupShape" ) ) != -1 ) 1087 aRet = B2UCONST( "Group" ); 1088 else if( aShapeType.lastIndexOf( B2UCONST( "drawing.GraphicObjectShape" ) ) != -1 ) 1089 aRet = B2UCONST( "Graphic" ); 1090 else if( aShapeType.lastIndexOf( B2UCONST( "drawing.OLE2Shape" ) ) != -1 ) 1091 aRet = B2UCONST( "OLE2" ); 1092 else if( aShapeType.lastIndexOf( B2UCONST( "presentation.HeaderShape" ) ) != -1 ) 1093 aRet = B2UCONST( "Header" ); 1094 else if( aShapeType.lastIndexOf( B2UCONST( "presentation.FooterShape" ) ) != -1 ) 1095 aRet = B2UCONST( "Footer" ); 1096 else if( aShapeType.lastIndexOf( B2UCONST( "presentation.DateTimeShape" ) ) != -1 ) 1097 aRet = B2UCONST( "Date/Time" ); 1098 else if( aShapeType.lastIndexOf( B2UCONST( "presentation.SlideNumberShape" ) ) != -1 ) 1099 aRet = B2UCONST( "Slide Number" ); 1100 else 1101 aRet = B2UCONST( "Drawing" ); 1102 1103 return aRet; 1104 } 1105 1106 // ----------------------------------------------------------------------------- 1107 1108 OUString SVGFilter::implGetValidIDFromInterface( const Reference< XInterface >& rxIf, sal_Bool bUnique ) 1109 { 1110 Reference< XNamed > xNamed( rxIf, UNO_QUERY ); 1111 OUString aRet; 1112 1113 if( xNamed.is() ) 1114 { 1115 aRet = xNamed->getName().replace( ' ', '_' ). 1116 replace( ':', '_' ). 1117 replace( ',', '_' ). 1118 replace( ';', '_' ). 1119 replace( '&', '_' ). 1120 replace( '!', '_' ). 1121 replace( '|', '_' ); 1122 } 1123 1124 if( ( aRet.getLength() > 0 ) && bUnique ) 1125 { 1126 while( ::std::find( maUniqueIdVector.begin(), maUniqueIdVector.end(), aRet ) != maUniqueIdVector.end() ) 1127 { 1128 aRet += B2UCONST( "_" ); 1129 } 1130 1131 maUniqueIdVector.push_back( aRet ); 1132 } 1133 1134 return aRet; 1135 } 1136 1137 // ----------------------------------------------------------------------------- 1138 1139 sal_Bool SVGFilter::implHasText( const GDIMetaFile& rMtf ) const 1140 { 1141 sal_Bool bRet = sal_False; 1142 1143 for( sal_uInt32 nCurAction = 0, nCount = rMtf.GetActionCount(); ( nCurAction < nCount ) && !bRet; ++nCurAction ) 1144 { 1145 switch( rMtf.GetAction( nCurAction )->GetType() ) 1146 { 1147 case( META_TEXT_ACTION ): 1148 case( META_TEXTRECT_ACTION ): 1149 case( META_TEXTARRAY_ACTION ): 1150 case( META_STRETCHTEXT_ACTION ): 1151 { 1152 bRet = sal_True; 1153 } 1154 break; 1155 1156 default: 1157 break; 1158 } 1159 } 1160 1161 return bRet; 1162 } 1163 1164 // ----------------------------------------------------------------------------- 1165 1166 IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo ) 1167 { 1168 OUString aRepresentation; 1169 sal_Bool bFieldProcessed = sal_False; 1170 1171 if( pInfo ) 1172 { 1173 const ::rtl::OUString aHeaderText( B2UCONST( "HeaderText" ) ); 1174 const ::rtl::OUString aFooterText( B2UCONST( "FooterText" ) ); 1175 const ::rtl::OUString aDateTimeText( B2UCONST( "DateTimeText" ) ); 1176 const ::rtl::OUString aPageNumberText( B2UCONST( "Number" ) ); 1177 1178 const Reference< XPropertySet > xDefaultPagePropertySet( mxDefaultPage, UNO_QUERY ); 1179 Reference< XPropertySetInfo > xDefaultPagePropSetInfo( xDefaultPagePropertySet->getPropertySetInfo() ); 1180 1181 if( xDefaultPagePropSetInfo.is() ) 1182 { 1183 const SvxFieldData* pField = pInfo->GetField().GetField(); 1184 Any aProperty; 1185 1186 if( pField->ISA( SvxHeaderField ) && 1187 xDefaultPagePropSetInfo->hasPropertyByName( aHeaderText ) ) 1188 { 1189 xDefaultPagePropertySet->getPropertyValue( aHeaderText ) >>= aRepresentation; 1190 bFieldProcessed = sal_True; 1191 } 1192 else if( pField->ISA( SvxFooterField ) && 1193 xDefaultPagePropSetInfo->hasPropertyByName( aFooterText ) ) 1194 { 1195 xDefaultPagePropertySet->getPropertyValue( aFooterText ) >>= aRepresentation; 1196 bFieldProcessed = sal_True; 1197 } 1198 else if( pField->ISA( SvxDateTimeField ) && 1199 xDefaultPagePropSetInfo->hasPropertyByName( aDateTimeText ) ) 1200 { 1201 xDefaultPagePropertySet->getPropertyValue( aDateTimeText ) >>= aRepresentation; 1202 bFieldProcessed = sal_True; 1203 } 1204 else if( pField->ISA( SvxPageField ) && 1205 xDefaultPagePropSetInfo->hasPropertyByName( aPageNumberText ) ) 1206 { 1207 String aPageNumValue; 1208 sal_Int16 nPageNumber = 0; 1209 1210 xDefaultPagePropertySet->getPropertyValue( aPageNumberText ) >>= nPageNumber; 1211 1212 if( mpSdrModel ) 1213 { 1214 sal_Bool bUpper = sal_False; 1215 1216 switch( mpSdrModel->GetPageNumType() ) 1217 { 1218 case SVX_CHARS_UPPER_LETTER: 1219 aPageNumValue += (sal_Unicode)(char)( ( nPageNumber - 1 ) % 26 + 'A' ); 1220 break; 1221 case SVX_CHARS_LOWER_LETTER: 1222 aPageNumValue += (sal_Unicode)(char)( ( nPageNumber- 1 ) % 26 + 'a' ); 1223 break; 1224 case SVX_ROMAN_UPPER: 1225 bUpper = sal_True; 1226 case SVX_ROMAN_LOWER: 1227 aPageNumValue += SvxNumberFormat::CreateRomanString( nPageNumber, bUpper ); 1228 break; 1229 case SVX_NUMBER_NONE: 1230 aPageNumValue.Erase(); 1231 aPageNumValue += sal_Unicode(' '); 1232 break; 1233 default : break; 1234 } 1235 } 1236 1237 if( !aPageNumValue.Len() ) 1238 aPageNumValue += String::CreateFromInt32( nPageNumber ); 1239 1240 aRepresentation = aPageNumValue; 1241 bFieldProcessed = sal_True; 1242 } 1243 } 1244 1245 pInfo->SetRepresentation( aRepresentation ); 1246 } 1247 1248 return( bFieldProcessed ? 0 : maOldFieldHdl.Call( pInfo ) ); 1249 } 1250