Update ooo320-m1
[ooovba.git] / sd / source / filter / eppt / epptso.cxx
blobfc02e045eda4804a037bd61c6dbd299198dbf401
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: epptso.cxx,v $
10 * $Revision: 1.107.6.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <osl/endian.h>
34 #include <eppt.hxx>
35 #include "epptdef.hxx"
36 #ifndef _PptEscherEx_HXX
37 #include "escherex.hxx"
38 #endif
39 #include <tools/poly.hxx>
40 #include <vcl/bmpacc.hxx>
41 #include <vcl/gradient.hxx>
42 #include <vcl/gfxlink.hxx>
43 #include <tools/stream.hxx>
44 #include <sot/storage.hxx>
45 #include <vcl/outdev.hxx>
46 #include <vcl/virdev.hxx>
47 #include <vcl/gradient.hxx>
48 #include <sfx2/app.hxx>
49 #include <svtools/languageoptions.hxx>
50 //#ifndef _SVX_XIT_HXX
51 //#include <svx/xit.hxx>
52 //#endif
53 #include <svx/svxenum.hxx>
54 #include <svx/unoapi.hxx>
55 #include <svx/svdoashp.hxx>
56 #include <com/sun/star/style/VerticalAlignment.hpp>
57 #include <com/sun/star/container/XIndexReplace.hpp>
58 #include <com/sun/star/presentation/XPresentationPage.hpp>
59 #include <com/sun/star/awt/XFont.hpp>
60 #ifndef _COM_SUN_STAR_AWT_XFONTWEIGHT_HPP_
61 #include <com/sun/star/awt/FontWeight.hpp>
62 #endif
63 #ifndef _COM_SUN_STAR_AWT_XFONTUNDERLINE_HPP_
64 #include <com/sun/star/awt/FontUnderline.hpp>
65 #endif
66 #include <com/sun/star/style/ParagraphAdjust.hpp>
67 #include <com/sun/star/style/LineSpacing.hpp>
68 #include <com/sun/star/style/LineSpacingMode.hpp>
69 #ifndef _COM_SUN_STAR_STYLE_XSTYLEFAMILIESSUPPLIER_PP_
70 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
71 #endif
72 #include <com/sun/star/style/XStyle.hpp>
73 #include <com/sun/star/drawing/PointSequence.hpp>
74 #include <com/sun/star/drawing/FlagSequence.hpp>
75 #include <com/sun/star/drawing/PolygonFlags.hpp>
76 #include <com/sun/star/beans/PropertyValue.hpp>
77 #include <com/sun/star/drawing/XControlShape.hpp>
78 #include <comphelper/processfactory.hxx>
79 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
80 #include <com/sun/star/i18n/XBreakIterator.hpp>
81 #include <com/sun/star/i18n/XScriptTypeDetector.hpp>
82 #include <com/sun/star/i18n/ScriptType.hpp>
83 #include <com/sun/star/i18n/ScriptDirection.hpp>
84 #include <com/sun/star/embed/Aspects.hpp>
85 #include <vcl/cvtgrf.hxx>
86 #include <tools/urlobj.hxx>
87 #ifndef _CPPUHELPER_EXTRACT_HXX_
88 #include <comphelper/extract.hxx>
89 #endif
90 #ifndef _CPPUHELPER_PROPTYPEHLP_HXX_
91 #include <cppuhelper/proptypehlp.hxx>
92 #endif
93 #ifndef _UCBHELPER_CONTENT_HXX_
94 #include <ucbhelper/content.hxx>
95 #endif
96 #ifndef _UCBHELPER_CONTENTBROKER_HXX_
97 #include <ucbhelper/contentbroker.hxx>
98 #endif
99 #ifndef _TOOLKIT_UNOHLP_HXX
100 #include <toolkit/unohlp.hxx>
101 #endif
102 #include <rtl/crc.h>
103 #include <sot/clsids.hxx>
104 #include <unotools/ucbstreamhelper.hxx>
105 #include <com/sun/star/text/FontRelief.hpp>
106 #include <svx/frmdiritem.hxx>
108 #include <svx/outliner.hxx>
109 #include <svx/outlobj.hxx>
110 #include <svx/svdmodel.hxx>
112 #include <svtools/fltcall.hxx>
113 #include <com/sun/star/table/XTable.hpp>
114 #include <com/sun/star/table/XMergeableCell.hpp>
115 #include <com/sun/star/table/BorderLine.hpp>
116 #include <set>
118 //#include <svx/xbtmpit.hxx>
120 #include "i18npool/mslangid.hxx"
122 #include <vos/xception.hxx>
123 #ifndef _VOS_NO_NAMESPACE
124 using namespace vos;
125 #endif
127 using namespace ::com::sun::star;
129 ////////////////////////////////////////////////////////////////////////////////////////////////////
131 #define ANSI_CHARSET 0
132 #define DEFAULT_CHARSET 1
133 #define SYMBOL_CHARSET 2
134 #define SHIFTJIS_CHARSET 128
135 #define HANGEUL_CHARSET 129
136 #define CHINESEBIG5_CHARSET 136
137 #define OEM_CHARSET 255
139 ////////////////////////////////////////////////////////////////////////////////////////////////////
141 /* Font Families */
142 #define FF_DONTCARE 0x00
143 #define FF_ROMAN 0x10
144 #define FF_SWISS 0x20
145 #define FF_MODERN 0x30
146 #define FF_SCRIPT 0x40
147 #define FF_DECORATIVE 0x50
149 ////////////////////////////////////////////////////////////////////////////////////////////////////
151 #define DEFAULT_PITCH 0x00
152 #define FIXED_PITCH 0x01
153 #define VARIABLE_PITCH 0x02
155 // ---------------------------------------------------------------------------------------------
157 com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > xPPTBreakIter;
158 com::sun::star::uno::Reference< com::sun::star::i18n::XScriptTypeDetector > xScriptTypeDetector;
160 PPTExBulletProvider::PPTExBulletProvider()
162 pGraphicProv = new EscherGraphicProvider( _E_GRAPH_PROV_USE_INSTANCES | _E_GRAPH_PROV_DO_NOT_ROTATE_METAFILES );
165 PPTExBulletProvider::~PPTExBulletProvider()
167 delete pGraphicProv;
170 sal_uInt16 PPTExBulletProvider::GetId( const ByteString& rUniqueId, Size& rGraphicSize )
172 sal_uInt16 nRetValue = 0xffff;
173 sal_uInt32 nId = 0;
175 if ( rUniqueId.Len() )
177 Rectangle aRect;
178 GraphicObject aGraphicObject( rUniqueId );
179 Graphic aMappedGraphic, aGraphic( aGraphicObject.GetGraphic() );
180 Size aPrefSize( aGraphic.GetPrefSize() );
181 BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
183 if ( rGraphicSize.Width() && rGraphicSize.Height() )
185 double fQ1 = ( (double)aPrefSize.Width() / (double)aPrefSize.Height() );
186 double fQ2 = ( (double)rGraphicSize.Width() / (double)rGraphicSize.Height() );
187 double fXScale = 1;
188 double fYScale = 1;
190 if ( fQ1 > fQ2 )
191 fYScale = fQ1 / fQ2;
192 else if ( fQ1 < fQ2 )
193 fXScale = fQ2 / fQ1;
195 if ( ( fXScale != 1.0 ) || ( fYScale != 1.0 ) )
197 aBmpEx.Scale( fXScale, fYScale );
198 Size aNewSize( (sal_Int32)((double)rGraphicSize.Width() / fXScale + 0.5 ),
199 (sal_Int32)((double)rGraphicSize.Height() / fYScale + 0.5 ) );
201 rGraphicSize = aNewSize;
203 aMappedGraphic = Graphic( aBmpEx );
204 aGraphicObject = GraphicObject( aMappedGraphic );
208 nId = pGraphicProv->GetBlibID( aBuExPictureStream, aGraphicObject.GetUniqueID(), aRect, NULL, NULL );
210 if ( nId && ( nId < 0x10000 ) )
211 nRetValue = (sal_uInt16)nId - 1;
213 return nRetValue;
216 // ---------------------------------------------------------------------------------------------
218 GroupTable::GroupTable() :
219 mnCurrentGroupEntry ( 0 ),
220 mnMaxGroupEntry ( 0 ),
221 mnGroupsClosed ( 0 ),
222 mpGroupEntry ( NULL )
224 ImplResizeGroupTable( 32 );
227 // ---------------------------------------------------------------------------------------------
229 GroupTable::~GroupTable()
231 for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; delete mpGroupEntry[ i++ ] ) ;
232 delete[] mpGroupEntry;
235 // ---------------------------------------------------------------------------------------------
237 void GroupTable::ImplResizeGroupTable( sal_uInt32 nEntrys )
239 if ( nEntrys > mnMaxGroupEntry )
241 mnMaxGroupEntry = nEntrys;
242 GroupEntry** pTemp = new GroupEntry*[ nEntrys ];
243 for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; i++ )
244 pTemp[ i ] = mpGroupEntry[ i ];
245 if ( mpGroupEntry )
246 delete[] mpGroupEntry;
247 mpGroupEntry = pTemp;
251 // ---------------------------------------------------------------------------------------------
253 sal_Bool GroupTable::EnterGroup( ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rXIndexAccessRef )
255 sal_Bool bRet = sal_False;
256 if ( rXIndexAccessRef.is() )
258 GroupEntry* pNewGroup = new GroupEntry( rXIndexAccessRef );
259 if ( pNewGroup->mnCount )
261 if ( mnMaxGroupEntry == mnCurrentGroupEntry )
262 ImplResizeGroupTable( mnMaxGroupEntry + 8 );
263 mpGroupEntry[ mnCurrentGroupEntry++ ] = pNewGroup;
264 bRet = sal_True;
266 else
267 delete pNewGroup;
269 return bRet;
272 // ---------------------------------------------------------------------------------------------
274 sal_uInt32 GroupTable::GetGroupsClosed()
276 sal_uInt32 nRet = mnGroupsClosed;
277 mnGroupsClosed = 0;
278 return nRet;
281 // ---------------------------------------------------------------------------------------------
283 void GroupTable::ClearGroupTable()
285 for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; i++, delete mpGroupEntry[ i ] ) ;
286 mnCurrentGroupEntry = 0;
289 // ---------------------------------------------------------------------------------------------
291 void GroupTable::ResetGroupTable( sal_uInt32 nCount )
293 ClearGroupTable();
294 mpGroupEntry[ mnCurrentGroupEntry++ ] = new GroupEntry( nCount );
297 // ---------------------------------------------------------------------------------------------
299 sal_Bool GroupTable::GetNextGroupEntry()
301 while ( mnCurrentGroupEntry )
303 mnIndex = mpGroupEntry[ mnCurrentGroupEntry - 1 ]->mnCurrentPos++;
305 if ( mpGroupEntry[ mnCurrentGroupEntry - 1 ]->mnCount > mnIndex )
306 return TRUE;
308 delete ( mpGroupEntry[ --mnCurrentGroupEntry ] );
310 if ( mnCurrentGroupEntry )
311 mnGroupsClosed++;
313 return FALSE;
316 // ---------------------------------------------------------------------------------------------
318 void GroupTable::SkipCurrentGroup()
320 if ( mnCurrentGroupEntry )
321 delete ( mpGroupEntry[ --mnCurrentGroupEntry ] );
324 // ---------------------------------------------------------------------------------------------
326 FontCollectionEntry::~FontCollectionEntry()
330 // ---------------------------------------------------------------------------------------------
332 void FontCollectionEntry::ImplInit( const String& rName )
334 String aSubstName( GetSubsFontName( rName, SUBSFONT_ONLYONE | SUBSFONT_MS ) );
335 if ( aSubstName.Len() )
337 Name = aSubstName;
338 bIsConverted = sal_True;
340 else
342 Name = rName;
343 bIsConverted = sal_False;
347 FontCollection::~FontCollection()
349 for( void* pStr = List::First(); pStr; pStr = List::Next() )
350 delete (FontCollectionEntry*)pStr;
351 delete pVDev;
352 xPPTBreakIter = NULL;
353 xScriptTypeDetector = NULL;
356 FontCollection::FontCollection() :
357 pVDev ( NULL )
359 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
360 xMSF = ::comphelper::getProcessServiceFactory();
361 com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
362 xInterface = xMSF->createInstance( rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) );
363 if ( xInterface.is() )
364 xPPTBreakIter = com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator >
365 ( xInterface, com::sun::star::uno::UNO_QUERY );
367 xInterface = xMSF->createInstance( rtl::OUString::createFromAscii( "com.sun.star.i18n.ScriptTypeDetector" ) );
368 if ( xInterface.is() )
369 xScriptTypeDetector = com::sun::star::uno::Reference< com::sun::star::i18n::XScriptTypeDetector >
370 ( xInterface, com::sun::star::uno::UNO_QUERY );
373 short FontCollection::GetScriptDirection( const String& rString ) const
375 short nRet = com::sun::star::i18n::ScriptDirection::NEUTRAL;
376 if ( xScriptTypeDetector.is() )
378 const rtl::OUString sT( rString );
379 nRet = xScriptTypeDetector->getScriptDirection( sT, 0, com::sun::star::i18n::ScriptDirection::NEUTRAL );
381 return nRet;
384 sal_uInt32 FontCollection::GetId( FontCollectionEntry& rEntry )
386 if( rEntry.Name.Len() )
388 const sal_uInt32 nFonts = GetCount();
390 for( sal_uInt32 i = 0; i < nFonts; i++ )
392 const FontCollectionEntry* pEntry = GetById( i );
393 if( pEntry->Name == rEntry.Name )
394 return i;
396 Font aFont;
397 aFont.SetCharSet( rEntry.CharSet );
398 aFont.SetName( rEntry.Original );
399 // aFont.SetFamily( rEntry.Family );
400 // aFont.SetPitch( rEntry.Pitch );
401 aFont.SetHeight( 100 );
403 if ( !pVDev )
404 pVDev = new VirtualDevice;
406 pVDev->SetFont( aFont );
407 FontMetric aMetric( pVDev->GetFontMetric() );
409 sal_uInt16 nTxtHeight = (sal_uInt16)aMetric.GetAscent() + (sal_uInt16)aMetric.GetDescent();
411 if ( nTxtHeight )
413 double fScaling = (double)nTxtHeight / 120.0;
414 if ( ( fScaling > 0.50 ) && ( fScaling < 1.5 ) )
415 rEntry.Scaling = fScaling;
418 List::Insert( new FontCollectionEntry( rEntry ), LIST_APPEND );
419 return nFonts;
421 return 0;
424 const FontCollectionEntry* FontCollection::GetById( sal_uInt32 nId )
426 return (FontCollectionEntry*)List::GetObject( nId );
429 // ---------------------------------------------------------------------------------------------
431 sal_uInt32 PPTWriter::ImplVBAInfoContainer( SvStream* pStrm )
433 sal_uInt32 nSize = 28;
434 if ( pStrm )
436 *pStrm << (sal_uInt32)( 0x1f | ( EPP_VBAInfo << 16 ) )
437 << (sal_uInt32)( nSize - 8 )
438 << (sal_uInt32)( 2 | ( EPP_VBAInfoAtom << 16 ) )
439 << (sal_uInt32)12;
440 mpPptEscherEx->InsertPersistOffset( EPP_Persist_VBAInfoAtom, pStrm->Tell() );
441 *pStrm << (sal_uInt32)0
442 << (sal_uInt32)0
443 << (sal_uInt32)1;
445 return nSize;
448 // ---------------------------------------------------------------------------------------------
450 sal_uInt32 PPTWriter::ImplSlideViewInfoContainer( sal_uInt32 nInstance, SvStream* pStrm )
452 sal_uInt32 nSize = 111;
453 if ( pStrm )
455 sal_uInt8 bShowGuides = 0;
456 sal_uInt8 bSnapToGrid = 1;
457 sal_uInt8 bSnapToShape = 0;
459 sal_Int32 nScaling = 85;
460 sal_Int32 nMasterCoordinate = 0xdda;
461 sal_Int32 nXOrigin = -780;
462 sal_Int32 nYOrigin = -84;
464 sal_Int32 nPosition1 = 0x870;
465 sal_Int32 nPosition2 = 0xb40;
467 if ( nInstance )
469 bShowGuides = 1;
470 nScaling = 0x3b;
471 nMasterCoordinate = 0xf0c;
472 nXOrigin = -1752;
473 nYOrigin = -72;
474 nPosition1 = 0xb40;
475 nPosition2 = 0x870;
477 *pStrm << (sal_uInt32)( 0xf | ( EPP_SlideViewInfo << 16 ) | ( nInstance << 4 ) )
478 << (sal_uInt32)( nSize - 8 )
479 << (sal_uInt32)( EPP_SlideViewInfoAtom << 16 ) << (sal_uInt32)3
480 << bShowGuides << bSnapToGrid << bSnapToShape
481 << (sal_uInt32)( EPP_ViewInfoAtom << 16 ) << (sal_uInt32)52
482 << nScaling << (sal_Int32)100 << nScaling << (sal_Int32)100 // scaling atom - Keeps the current scale
483 << nScaling << (sal_Int32)100 << nScaling << (sal_Int32)100 // scaling atom - Keeps the previous scale
484 << (sal_Int32)0x17ac << nMasterCoordinate// Origin - Keeps the origin in master coordinates
485 << nXOrigin << nYOrigin // Origin
486 << (sal_uInt8)1 // Bool1 varScale - Set if zoom to fit is set
487 << (sal_uInt8)0 // bool1 draftMode - Not used
488 << (sal_uInt16)0 // padword
489 << (sal_uInt32)( ( 7 << 4 ) | ( EPP_GuideAtom << 16 ) ) << (sal_uInt32)8
490 << (sal_uInt32)0 // Type of the guide. If the guide is horizontal this value is zero. If it's vertical, it's one.
491 << nPosition1 // Position of the guide in master coordinates. X coordinate if it's vertical, and Y coordinate if it's horizontal.
492 << (sal_uInt32)( ( 7 << 4 ) | ( EPP_GuideAtom << 16 ) ) << (sal_uInt32)8
493 << (sal_Int32)1 // Type of the guide. If the guide is horizontal this value is zero. If it's vertical, it's one.
494 << nPosition2; // Position of the guide in master coordinates. X coordinate if it's vertical, and Y coordinate if it's horizontal.
496 return nSize;
499 // ---------------------------------------------------------------------------------------------
501 sal_uInt32 PPTWriter::ImplOutlineViewInfoContainer( SvStream* pStrm )
503 sal_uInt32 nSize = 68;
504 if ( pStrm )
506 *pStrm << (sal_uInt32)( 0xf | ( EPP_OutlineViewInfo << 16 ) ) << (sal_uInt32)( nSize - 8 )
507 << (sal_uInt32)( EPP_ViewInfoAtom << 16 ) << (sal_uInt32)52
508 << (sal_Int32)170 << (sal_Int32)200 << (sal_Int32)170 << (sal_Int32)200 // scaling atom - Keeps the current scale
509 << (sal_Int32)170 << (sal_Int32)200 << (sal_Int32)170 << (sal_Int32)200 // scaling atom - Keeps the previous scale
510 << (sal_Int32)0x17ac << 0xdda // Origin - Keeps the origin in master coordinates
511 << (sal_Int32)-780 << (sal_Int32)-84 // Origin
512 << (sal_uInt8)1 // bool1 varScale - Set if zoom to fit is set
513 << (sal_uInt8)0 // bool1 draftMode - Not used
514 << (sal_uInt16)0; // padword
516 return nSize;
519 // ---------------------------------------------------------------------------------------------
521 sal_uInt32 PPTWriter::ImplProgBinaryTag( SvStream* pStrm )
523 sal_uInt32 nPictureStreamSize, nOutlineStreamSize, nSize = 8;
525 nPictureStreamSize = aBuExPictureStream.Tell();
526 if ( nPictureStreamSize )
527 nSize += nPictureStreamSize + 8;
529 nOutlineStreamSize = aBuExOutlineStream.Tell();
530 if ( nOutlineStreamSize )
531 nSize += nOutlineStreamSize + 8;
533 if ( pStrm )
535 *pStrm << (sal_uInt32)( EPP_BinaryTagData << 16 ) << (sal_uInt32)( nSize - 8 );
536 if ( nPictureStreamSize )
538 *pStrm << (sal_uInt32)( 0xf | ( EPP_PST_ExtendedBuGraContainer << 16 ) ) << nPictureStreamSize;
539 pStrm->Write( aBuExPictureStream.GetData(), nPictureStreamSize );
541 if ( nOutlineStreamSize )
543 *pStrm << (sal_uInt32)( 0xf | ( EPP_PST_ExtendedPresRuleContainer << 16 ) ) << nOutlineStreamSize;
544 pStrm->Write( aBuExOutlineStream.GetData(), nOutlineStreamSize );
547 return nSize;
550 // ---------------------------------------------------------------------------------------------
552 sal_uInt32 PPTWriter::ImplProgBinaryTagContainer( SvStream* pStrm, SvMemoryStream* pBinTagStrm )
554 sal_uInt32 nSize = 8 + 8 + 14;
555 if ( pStrm )
557 *pStrm << (sal_uInt32)( 0xf | ( EPP_ProgBinaryTag << 16 ) ) << (sal_uInt32)0
558 << (sal_uInt32)( EPP_CString << 16 ) << (sal_uInt32)14
559 << (sal_uInt32)0x5f005f << (sal_uInt32)0x50005f
560 << (sal_uInt32)0x540050 << (sal_uInt16)0x39;
562 if ( pBinTagStrm )
564 sal_uInt32 nLen = pBinTagStrm->Tell();
565 nSize += nLen + 8;
566 *pStrm << (sal_uInt32)( EPP_BinaryTagData << 16 ) << nLen;
567 pStrm->Write( pBinTagStrm->GetData(), nLen );
569 else
570 nSize += ImplProgBinaryTag( pStrm );
572 if ( pStrm )
574 pStrm->SeekRel( - ( (sal_Int32)nSize - 4 ) );
575 *pStrm << (sal_uInt32)( nSize - 8 );
576 pStrm->SeekRel( nSize - 8 );
578 return nSize;
581 // ---------------------------------------------------------------------------------------------
583 sal_uInt32 PPTWriter::ImplProgTagContainer( SvStream* pStrm, SvMemoryStream* pBinTagStrm )
585 sal_uInt32 nSize = 0;
586 if ( aBuExPictureStream.Tell() || aBuExOutlineStream.Tell() || pBinTagStrm )
588 nSize = 8;
589 if ( pStrm )
591 *pStrm << (sal_uInt32)( 0xf | ( EPP_ProgTags << 16 ) ) << (sal_uInt32)0;
593 nSize += ImplProgBinaryTagContainer( pStrm, pBinTagStrm );
594 if ( pStrm )
596 pStrm->SeekRel( - ( (sal_Int32)nSize - 4 ) );
597 *pStrm << (sal_uInt32)( nSize - 8 );
598 pStrm->SeekRel( nSize - 8 );
601 return nSize;
604 // ---------------------------------------------------------------------------------------------
606 sal_uInt32 PPTWriter::ImplDocumentListContainer( SvStream* pStrm )
608 sal_uInt32 nSize = 8;
609 if ( pStrm )
611 *pStrm << (sal_uInt32)( ( EPP_List << 16 ) | 0xf ) << (sal_uInt32)0;
614 nSize += ImplVBAInfoContainer( pStrm );
615 nSize += ImplSlideViewInfoContainer( 0, pStrm );
616 nSize += ImplOutlineViewInfoContainer( pStrm );
617 nSize += ImplSlideViewInfoContainer( 1, pStrm );
618 nSize += ImplProgTagContainer( pStrm );
620 if ( pStrm )
622 pStrm->SeekRel( - ( (sal_Int32)nSize - 4 ) );
623 *pStrm << (sal_uInt32)( nSize - 8 );
624 pStrm->SeekRel( nSize - 8 );
626 return nSize;
629 // ---------------------------------------------------------------------------------------------
631 sal_uInt32 PPTWriter::ImplMasterSlideListContainer( SvStream* pStrm )
633 sal_uInt32 i, nSize = 28 * mnMasterPages + 8;
634 if ( pStrm )
636 *pStrm << (sal_uInt32)( 0x1f | ( EPP_SlideListWithText << 16 ) ) << (sal_uInt32)( nSize - 8 );
638 for ( i = 0; i < mnMasterPages; i++ )
640 *pStrm << (sal_uInt32)( EPP_SlidePersistAtom << 16 ) << (sal_uInt32)20;
641 mpPptEscherEx->InsertPersistOffset( EPP_MAINMASTER_PERSIST_KEY | i, pStrm->Tell() );
642 *pStrm << (sal_uInt32)0 // psrReference - logical reference to the slide persist object ( EPP_MAINMASTER_PERSIST_KEY )
643 << (sal_uInt32)0 // flags - only bit 3 used, if set then slide contains shapes other than placeholders
644 << (sal_Int32)0 // numberTexts - number of placeholder texts stored with the persist object. Allows to display outline view without loading the slide persist objects
645 << (sal_Int32)( 0x80000000 | i ) // slideId - Unique slide identifier, used for OLE link monikers for example
646 << (sal_uInt32)0; // reserved, usualy 0
649 return nSize;
652 // ---------------------------------------------------------------------------------------------
654 sal_uInt32 PPTWriter::ImplInsertBookmarkURL( const String& rBookmarkURL, const sal_uInt32 nType,
655 const String& rStringVer0, const String& rStringVer1, const String& rStringVer2, const String& rStringVer3 )
657 sal_uInt32 nHyperId = ++mnExEmbed;
658 maHyperlink.Insert( new EPPTHyperlink( rBookmarkURL, nType ), LIST_APPEND );
660 *mpExEmbed << (sal_uInt16)0xf
661 << (sal_uInt16)EPP_ExHyperlink
662 << (sal_uInt32)0;
663 sal_uInt32 nHyperSize, nHyperStart = mpExEmbed->Tell();
664 *mpExEmbed << (sal_uInt16)0
665 << (sal_uInt16)EPP_ExHyperlinkAtom
666 << (sal_uInt32)4
667 << nHyperId;
669 sal_uInt16 i, nStringLen;
670 nStringLen = rStringVer0.Len();
671 if ( nStringLen )
673 *mpExEmbed << (sal_uInt32)( EPP_CString << 16 ) << (sal_uInt32)( nStringLen * 2 );
674 for ( i = 0; i < nStringLen; i++ )
676 *mpExEmbed << rStringVer0.GetChar( i );
679 nStringLen = rStringVer1.Len();
680 if ( nStringLen )
682 *mpExEmbed << (sal_uInt32)( ( EPP_CString << 16 ) | 0x10 ) << (sal_uInt32)( nStringLen * 2 );
683 for ( i = 0; i < nStringLen; i++ )
685 *mpExEmbed << rStringVer1.GetChar( i );
688 nStringLen = rStringVer2.Len();
689 if ( nStringLen )
691 *mpExEmbed << (sal_uInt32)( ( EPP_CString << 16 ) | 0x20 ) << (sal_uInt32)( nStringLen * 2 );
692 for ( i = 0; i < nStringLen; i++ )
694 *mpExEmbed << rStringVer2.GetChar( i );
697 nStringLen = rStringVer3.Len();
698 if ( nStringLen )
700 *mpExEmbed << (sal_uInt32)( ( EPP_CString << 16 ) | 0x30 ) << (sal_uInt32)( nStringLen * 2 );
701 for ( i = 0; i < nStringLen; i++ )
703 *mpExEmbed << rStringVer3.GetChar( i );
706 nHyperSize = mpExEmbed->Tell() - nHyperStart;
707 mpExEmbed->SeekRel( - ( (sal_Int32)nHyperSize + 4 ) );
708 *mpExEmbed << nHyperSize;
709 mpExEmbed->SeekRel( nHyperSize );
710 return nHyperId;
713 // ---------------------------------------------------------------------------------------------
715 sal_Bool PPTWriter::ImplCloseDocument()
717 sal_uInt32 nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_Document );
718 if ( nOfs )
720 mpPptEscherEx->PtReplaceOrInsert( EPP_Persist_CurrentPos, mpStrm->Tell() );
721 mpStrm->Seek( nOfs );
723 // creating the TxMasterStyleAtom
724 SvMemoryStream aTxMasterStyleAtomStrm( 0x200, 0x200 );
726 EscherExAtom aTxMasterStyleAtom( aTxMasterStyleAtomStrm, EPP_TxMasterStyleAtom, EPP_TEXTTYPE_Other );
727 aTxMasterStyleAtomStrm << (sal_uInt16)5; // paragraph count
728 sal_uInt16 nLev;
729 sal_Bool bFirst = sal_True;
730 for ( nLev = 0; nLev < 5; nLev++ )
732 mpStyleSheet->mpParaSheet[ EPP_TEXTTYPE_Other ]->Write( aTxMasterStyleAtomStrm, mpPptEscherEx, nLev, bFirst, sal_False, mXPagePropSet );
733 mpStyleSheet->mpCharSheet[ EPP_TEXTTYPE_Other ]->Write( aTxMasterStyleAtomStrm, mpPptEscherEx, nLev, bFirst, sal_False, mXPagePropSet );
734 bFirst = sal_False;
738 mpExEmbed->Seek( STREAM_SEEK_TO_END );
739 sal_uInt32 nExEmbedSize = mpExEmbed->Tell();
741 // nEnviroment : Gesamtgroesse des Environment Containers
742 sal_uInt32 nEnvironment = maFontCollection.GetCount() * 76 // 68 bytes pro Fontenityatom und je 8 Bytes fuer die Header
743 + 8 // 1 FontCollection Container
744 + 20 // SrKinsoku Container
745 + 18 // 1 TxSiStyleAtom
746 + aTxMasterStyleAtomStrm.Tell() // 1 TxMasterStyleAtom;
747 + mpStyleSheet->SizeOfTxCFStyleAtom();
749 sal_uInt32 nBytesToInsert = nEnvironment + 8;
751 if ( nExEmbedSize )
752 nBytesToInsert += nExEmbedSize + 8 + 12;
754 nBytesToInsert += maSoundCollection.GetSize();
755 nBytesToInsert += mpPptEscherEx->DrawingGroupContainerSize();
756 nBytesToInsert += ImplMasterSlideListContainer( NULL );
757 nBytesToInsert += ImplDocumentListContainer( NULL );
759 // nBytes im Stream einfuegen, und abhaengige Container anpassen
760 mpPptEscherEx->InsertAtCurrentPos( nBytesToInsert, TRUE );
762 // CREATE HYPERLINK CONTAINER
763 if ( nExEmbedSize )
765 *mpStrm << (sal_uInt16)0xf
766 << (sal_uInt16)EPP_ExObjList
767 << (sal_uInt32)( nExEmbedSize + 12 )
768 << (sal_uInt16)0
769 << (sal_uInt16)EPP_ExObjListAtom
770 << (sal_uInt32)4
771 << (sal_uInt32)mnExEmbed;
772 mpPptEscherEx->InsertPersistOffset( EPP_Persist_ExObj, mpStrm->Tell() );
773 mpStrm->Write( mpExEmbed->GetData(), nExEmbedSize );
776 // CREATE ENVIRONMENT
777 *mpStrm << (sal_uInt16)0xf << (sal_uInt16)EPP_Environment << (sal_uInt32)nEnvironment;
779 // Open Container ( EPP_SrKinsoku )
780 *mpStrm << (sal_uInt16)0x2f << (sal_uInt16)EPP_SrKinsoku << (sal_uInt32)12;
781 mpPptEscherEx->AddAtom( 4, EPP_SrKinsokuAtom, 0, 3 );
782 *mpStrm << (sal_Int32)0; // SrKinsoku Level 0
784 // Open Container ( EPP_FontCollection )
785 *mpStrm << (sal_uInt16)0xf << (sal_uInt16)EPP_FontCollection << (sal_uInt32)maFontCollection.GetCount() * 76;
787 for ( sal_uInt32 i = 0; i < maFontCollection.GetCount(); i++ )
789 mpPptEscherEx->AddAtom( 68, EPP_FontEnityAtom, 0, i );
790 const FontCollectionEntry* pDesc = maFontCollection.GetById( i );
791 sal_uInt32 nFontLen = pDesc->Name.Len();
792 if ( nFontLen > 31 )
793 nFontLen = 31;
794 for ( sal_uInt16 n = 0; n < 32; n++ )
796 sal_Unicode nUniCode = 0;
797 if ( n < nFontLen )
798 nUniCode = pDesc->Name.GetChar( n );
799 *mpStrm << nUniCode;
801 sal_uInt8 lfCharSet = ANSI_CHARSET;
802 sal_uInt8 lfClipPrecision = 0;
803 sal_uInt8 lfQuality = 6;
804 sal_uInt8 lfPitchAndFamily = 0;
806 if ( pDesc->CharSet == RTL_TEXTENCODING_SYMBOL )
807 lfCharSet = SYMBOL_CHARSET;
809 switch( pDesc->Family )
811 case ::com::sun::star::awt::FontFamily::ROMAN :
812 lfPitchAndFamily |= FF_ROMAN;
813 break;
815 case ::com::sun::star::awt::FontFamily::SWISS :
816 lfPitchAndFamily |= FF_SWISS;
817 break;
819 case ::com::sun::star::awt::FontFamily::MODERN :
820 lfPitchAndFamily |= FF_MODERN;
821 break;
823 case ::com::sun::star::awt::FontFamily::SCRIPT:
824 lfPitchAndFamily |= FF_SCRIPT;
825 break;
827 case ::com::sun::star::awt::FontFamily::DECORATIVE:
828 lfPitchAndFamily |= FF_DECORATIVE;
829 break;
831 default:
832 lfPitchAndFamily |= FAMILY_DONTKNOW;
833 break;
835 switch( pDesc->Pitch )
837 case ::com::sun::star::awt::FontPitch::FIXED:
838 lfPitchAndFamily |= FIXED_PITCH;
839 break;
841 default:
842 lfPitchAndFamily |= DEFAULT_PITCH;
843 break;
845 *mpStrm << lfCharSet
846 << lfClipPrecision
847 << lfQuality
848 << lfPitchAndFamily;
850 mpStyleSheet->WriteTxCFStyleAtom( *mpStrm ); // create style that is used for new standard objects
851 mpPptEscherEx->AddAtom( 10, EPP_TxSIStyleAtom );
852 *mpStrm << (sal_uInt32)7 // ?
853 << (sal_Int16)2 // ?
854 << (sal_uInt8)9 // ?
855 << (sal_uInt8)8 // ?
856 << (sal_Int16)0; // ?
858 mpStrm->Write( aTxMasterStyleAtomStrm.GetData(), aTxMasterStyleAtomStrm.Tell() );
859 maSoundCollection.Write( *mpStrm );
860 mpPptEscherEx->WriteDrawingGroupContainer( *mpStrm );
861 ImplMasterSlideListContainer( mpStrm );
862 ImplDocumentListContainer( mpStrm );
864 sal_uInt32 nOldPos = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_CurrentPos );
865 if ( nOldPos )
867 mpStrm->Seek( nOldPos );
868 return TRUE;
871 return FALSE;
874 // ---------------------------------------------------------------------------------------------
876 sal_Bool PropValue::GetPropertyValue(
877 ::com::sun::star::uno::Any& rAny,
878 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
879 const String& rString,
880 sal_Bool bTestPropertyAvailability )
882 sal_Bool bRetValue = sal_True;
883 if ( bTestPropertyAvailability )
885 bRetValue = sal_False;
888 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
889 aXPropSetInfo( rXPropSet->getPropertySetInfo() );
890 if ( aXPropSetInfo.is() )
891 bRetValue = aXPropSetInfo->hasPropertyByName( rString );
893 catch( ::com::sun::star::uno::Exception& )
895 bRetValue = sal_False;
898 if ( bRetValue )
902 rAny = rXPropSet->getPropertyValue( rString );
903 if ( !rAny.hasValue() )
904 bRetValue = sal_False;
906 catch( ::com::sun::star::uno::Exception& )
908 bRetValue = sal_False;
911 return bRetValue;
914 // ---------------------------------------------------------------------------------------------
916 ::com::sun::star::beans::PropertyState PropValue::GetPropertyState(
917 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
918 const String& rPropertyName )
920 ::com::sun::star::beans::PropertyState eRetValue = ::com::sun::star::beans::PropertyState_AMBIGUOUS_VALUE;
923 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > aXPropState
924 ( rXPropSet, ::com::sun::star::uno::UNO_QUERY );
925 if ( aXPropState.is() )
926 eRetValue = aXPropState->getPropertyState( rPropertyName );
928 catch( ::com::sun::star::uno::Exception& )
930 //...
932 return eRetValue;
935 // ---------------------------------------------------------------------------------------------
937 sal_Bool PropValue::ImplGetPropertyValue( const String& rString )
939 return GetPropertyValue( mAny, mXPropSet, rString );
942 // ---------------------------------------------------------------------------------------------
944 sal_Bool PropValue::ImplGetPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & aXPropSet, const String& rString )
946 return GetPropertyValue( mAny, aXPropSet, rString );
949 // ---------------------------------------------------------------------------------------------
951 sal_Bool PropStateValue::ImplGetPropertyValue( const String& rString, sal_Bool bGetPropertyState )
953 ePropState = ::com::sun::star::beans::PropertyState_AMBIGUOUS_VALUE;
954 sal_Bool bRetValue = TRUE;
955 #ifdef UNX
956 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
957 aXPropSetInfo( mXPropSet->getPropertySetInfo() );
958 if ( !aXPropSetInfo.is() )
959 return sal_False;
960 #endif
963 mAny = mXPropSet->getPropertyValue( rString );
964 if ( !mAny.hasValue() )
965 bRetValue = FALSE;
966 else if ( bGetPropertyState )
967 ePropState = mXPropState->getPropertyState( rString );
968 else
969 ePropState = ::com::sun::star::beans::PropertyState_DIRECT_VALUE;
971 catch( ::com::sun::star::uno::Exception& )
973 bRetValue = FALSE;
975 return bRetValue;
978 // ---------------------------------------------------------------------------------------------
980 sal_Bool PPTWriter::ImplInitSOIface()
982 while( TRUE )
984 mXDrawPagesSupplier = ::com::sun::star::uno::Reference<
985 ::com::sun::star::drawing::XDrawPagesSupplier >
986 ( mXModel, ::com::sun::star::uno::UNO_QUERY );
987 if ( !mXDrawPagesSupplier.is() )
988 break;
990 mXMasterPagesSupplier = ::com::sun::star::uno::Reference<
991 ::com::sun::star::drawing::XMasterPagesSupplier >
992 ( mXModel, ::com::sun::star::uno::UNO_QUERY );
993 if ( !mXMasterPagesSupplier.is() )
994 break;
995 mXDrawPages = mXMasterPagesSupplier->getMasterPages();
996 if ( !mXDrawPages.is() )
997 break;
998 mnMasterPages = mXDrawPages->getCount();
999 mXDrawPages = mXDrawPagesSupplier->getDrawPages();
1000 if( !mXDrawPages.is() )
1001 break;
1002 mnPages = mXDrawPages->getCount();
1003 if ( !ImplGetPageByIndex( 0, NORMAL ) )
1004 break;
1006 return TRUE;
1008 return FALSE;
1011 // ---------------------------------------------------------------------------------------------
1013 sal_Bool PPTWriter::ImplSetCurrentStyleSheet( sal_uInt32 nPageNum )
1015 sal_Bool bRet = sal_False;
1016 if ( nPageNum >= maStyleSheetList.size() )
1017 nPageNum = 0;
1018 else
1019 bRet = sal_True;
1020 mpStyleSheet = maStyleSheetList[ nPageNum ];
1021 return bRet;
1024 // ---------------------------------------------------------------------------------------------
1026 sal_Bool PPTWriter::ImplGetPageByIndex( sal_uInt32 nIndex, PageType ePageType )
1028 while( TRUE )
1030 if ( ePageType != meLatestPageType )
1032 switch( ePageType )
1034 case NORMAL :
1035 case NOTICE :
1037 mXDrawPages = mXDrawPagesSupplier->getDrawPages();
1038 if( !mXDrawPages.is() )
1039 return FALSE;
1041 break;
1043 case MASTER :
1045 mXDrawPages = mXMasterPagesSupplier->getMasterPages();
1046 if( !mXDrawPages.is() )
1047 return FALSE;
1049 break;
1050 default:
1051 break;
1053 meLatestPageType = ePageType;
1055 ::com::sun::star::uno::Any aAny( mXDrawPages->getByIndex( nIndex ) );
1056 aAny >>= mXDrawPage;
1057 if ( !mXDrawPage.is() )
1058 break;
1059 if ( ePageType == NOTICE )
1061 ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XPresentationPage >
1062 aXPresentationPage( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
1063 if ( !aXPresentationPage.is() )
1064 break;
1065 mXDrawPage = aXPresentationPage->getNotesPage();
1066 if ( !mXDrawPage.is() )
1067 break;
1069 mXPagePropSet = ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
1070 ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
1071 if ( !mXPagePropSet.is() )
1072 break;
1074 mXShapes = ::com::sun::star::uno::Reference<
1075 ::com::sun::star::drawing::XShapes >
1076 ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
1077 if ( !mXShapes.is() )
1078 break;
1080 /* try to get the "real" background PropertySet. If the normal page is not supporting this property, it is
1081 taken the property from the master */
1082 sal_Bool bHasBackground = GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ), sal_True );
1083 if ( bHasBackground )
1084 bHasBackground = ( aAny >>= mXBackgroundPropSet );
1085 if ( !bHasBackground )
1087 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPageTarget >
1088 aXMasterPageTarget( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
1089 if ( aXMasterPageTarget.is() )
1091 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > aXMasterDrawPage;
1092 aXMasterDrawPage = aXMasterPageTarget->getMasterPage();
1093 if ( aXMasterDrawPage.is() )
1095 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXMasterPagePropSet;
1096 aXMasterPagePropSet = ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
1097 ( aXMasterDrawPage, ::com::sun::star::uno::UNO_QUERY );
1098 if ( aXMasterPagePropSet.is() )
1100 sal_Bool bBackground = GetPropertyValue( aAny, aXMasterPagePropSet,
1101 String( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ) );
1102 if ( bBackground )
1104 aAny >>= mXBackgroundPropSet;
1110 return TRUE;
1112 return FALSE;
1115 // ---------------------------------------------------------------------------------------------
1117 sal_Bool PPTWriter::ImplGetShapeByIndex( sal_uInt32 nIndex, sal_Bool bGroup )
1119 while(TRUE)
1121 if ( ( bGroup == FALSE ) || ( GetCurrentGroupLevel() == 0 ) )
1123 ::com::sun::star::uno::Any aAny( mXShapes->getByIndex( nIndex ) );
1124 aAny >>= mXShape;
1126 else
1128 ::com::sun::star::uno::Any aAny( GetCurrentGroupAccess()->getByIndex( GetCurrentGroupIndex() ) );
1129 aAny >>= mXShape;
1131 if ( !mXShape.is() )
1132 break;
1134 ::com::sun::star::uno::Any aAny( mXShape->queryInterface( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >*) 0 ) ));
1135 aAny >>= mXPropSet;
1137 if ( !mXPropSet.is() )
1138 break;
1139 maPosition = ImplMapPoint( mXShape->getPosition() );
1140 maSize = ImplMapSize( mXShape->getSize() );
1141 maRect = Rectangle( Point( maPosition.X, maPosition.Y ), Size( maSize.Width, maSize.Height ) );
1142 mType = ByteString( String( mXShape->getShapeType() ), RTL_TEXTENCODING_UTF8 );
1143 mType.Erase( 0, 13 ); // "com.sun.star." entfernen
1144 sal_uInt16 nPos = mType.Search( (const char*)"Shape" );
1145 mType.Erase( nPos, 5 );
1147 mbPresObj = mbEmptyPresObj = FALSE;
1148 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsPresentationObject" ) ) ) )
1149 mAny >>= mbPresObj;
1151 if ( mbPresObj && ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsEmptyPresentationObject" ) ) ) )
1152 mAny >>= mbEmptyPresObj;
1154 mnAngle = ( PropValue::GetPropertyValue( aAny,
1155 mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "RotateAngle" ) ), sal_True ) )
1156 ? *((sal_Int32*)aAny.getValue() )
1157 : 0;
1159 return TRUE;
1161 return FALSE;
1164 // -----------------------------------------------------------------------
1166 sal_uInt32 PPTWriter::ImplGetMasterIndex( PageType ePageType )
1168 sal_uInt32 nRetValue = 0;
1169 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPageTarget >
1170 aXMasterPageTarget( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
1172 if ( aXMasterPageTarget.is() )
1174 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
1175 aXDrawPage = aXMasterPageTarget->getMasterPage();
1176 if ( aXDrawPage.is() )
1178 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
1179 aXPropertySet( aXDrawPage, ::com::sun::star::uno::UNO_QUERY );
1181 if ( aXPropertySet.is() )
1183 if ( ImplGetPropertyValue( aXPropertySet, String( RTL_CONSTASCII_USTRINGPARAM( "Number" ) ) ) )
1184 nRetValue |= *(sal_Int16*)mAny.getValue();
1185 if ( nRetValue & 0xffff ) // ueberlauf vermeiden
1186 nRetValue--;
1190 if ( ePageType == NOTICE )
1191 nRetValue += mnMasterPages;
1192 return nRetValue;
1195 // -----------------------------------------------------------------------
1197 sal_Bool PPTWriter::ImplGetStyleSheets()
1199 int nInstance, nLevel;
1200 sal_Bool bRetValue = sal_False;
1201 sal_uInt32 nPageNum;
1203 for ( nPageNum = 0; nPageNum < mnMasterPages; nPageNum++ )
1205 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed >
1206 aXNamed;
1208 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
1209 aXNameAccess;
1211 ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyleFamiliesSupplier >
1212 aXStyleFamiliesSupplier( mXModel, ::com::sun::star::uno::UNO_QUERY );
1214 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
1215 aXPropSet( mXModel, ::com::sun::star::uno::UNO_QUERY );
1217 sal_uInt16 nDefaultTab = ( aXPropSet.is() && ImplGetPropertyValue( aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TabStop" ) ) ) )
1218 ? (sal_uInt16)( *(sal_Int32*)mAny.getValue() / 4.40972 )
1219 : 1250;
1221 maStyleSheetList.push_back( new PPTExStyleSheet( nDefaultTab, (PPTExBulletProvider&)*this ) );
1222 ImplSetCurrentStyleSheet( nPageNum );
1223 if ( ImplGetPageByIndex( nPageNum, MASTER ) )
1224 aXNamed = ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed >
1225 ( mXDrawPage, ::com::sun::star::uno::UNO_QUERY );
1227 if ( aXStyleFamiliesSupplier.is() )
1228 aXNameAccess = aXStyleFamiliesSupplier->getStyleFamilies();
1230 bRetValue = aXNamed.is() && aXNameAccess.is() && aXStyleFamiliesSupplier.is();
1231 if ( bRetValue )
1233 for ( nInstance = EPP_TEXTTYPE_Title; nInstance <= EPP_TEXTTYPE_CenterTitle; nInstance++ )
1235 String aStyle;
1236 String aFamily;
1237 switch ( nInstance )
1239 case EPP_TEXTTYPE_CenterTitle :
1240 case EPP_TEXTTYPE_Title :
1242 aStyle = String( RTL_CONSTASCII_USTRINGPARAM( "title" ) );
1243 aFamily = aXNamed->getName();
1245 break;
1246 case EPP_TEXTTYPE_Body :
1248 aStyle = String( RTL_CONSTASCII_USTRINGPARAM( "outline1" ) ); // SD_LT_SEPARATOR
1249 aFamily = aXNamed->getName();
1251 break;
1252 case EPP_TEXTTYPE_Other :
1254 aStyle = String( RTL_CONSTASCII_USTRINGPARAM( "standard" ) );
1255 aFamily = String( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) );
1257 break;
1258 case EPP_TEXTTYPE_CenterBody :
1260 aStyle = String( RTL_CONSTASCII_USTRINGPARAM( "subtitle" ) );
1261 aFamily = aXNamed->getName();
1263 break;
1265 if ( aStyle.Len() && aFamily.Len() )
1269 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >xNameAccess;
1270 if ( aXNameAccess->hasByName( aFamily ) )
1272 ::com::sun::star::uno::Any aAny( aXNameAccess->getByName( aFamily ) );
1273 if( aAny.getValue() && ::cppu::extractInterface( xNameAccess, aAny ) )
1275 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > aXFamily;
1276 if ( aAny >>= aXFamily )
1278 if ( aXFamily->hasByName( aStyle ) )
1280 ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle > xStyle;
1281 aAny = aXFamily->getByName( aStyle );
1282 if( aAny.getValue() && ::cppu::extractInterface( xStyle, aAny ) )
1284 ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle > aXStyle;
1285 aAny >>= aXStyle;
1286 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
1287 xPropSet( aXStyle, ::com::sun::star::uno::UNO_QUERY );
1288 if( xPropSet.is() )
1289 mpStyleSheet->SetStyleSheet( xPropSet, maFontCollection, nInstance, 0 );
1290 for ( nLevel = 1; nLevel < 5; nLevel++ )
1292 if ( nInstance == EPP_TEXTTYPE_Body )
1294 sal_Unicode cTemp = aStyle.GetChar( aStyle.Len() - 1 );
1295 aStyle.SetChar( aStyle.Len() - 1, ++cTemp );
1296 if ( aXFamily->hasByName( aStyle ) )
1298 aXFamily->getByName( aStyle ) >>= xStyle;
1299 if( xStyle.is() )
1301 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
1302 xPropertySet( xStyle, ::com::sun::star::uno::UNO_QUERY );
1303 if ( xPropertySet.is() )
1304 mpStyleSheet->SetStyleSheet( xPropertySet, maFontCollection, nInstance, nLevel );
1308 else
1309 mpStyleSheet->SetStyleSheet( xPropSet, maFontCollection, nInstance, nLevel );
1317 catch( ::com::sun::star::uno::Exception& )
1323 for ( ; nInstance <= EPP_TEXTTYPE_QuarterBody; nInstance++ )
1329 return bRetValue;
1332 // -----------------------------------------------------------------------
1334 void PPTWriter::ImplWriteParagraphs( SvStream& rOut, TextObj& rTextObj )
1336 sal_Bool bFirstParagraph = TRUE;
1337 sal_uInt32 nCharCount;
1338 sal_uInt32 nPropertyFlags = 0;
1339 sal_uInt16 nDepth = 0;
1340 sal_Int16 nLineSpacing;
1341 int nInstance = rTextObj.GetInstance();
1343 for ( ParagraphObj* pPara = rTextObj.First() ; pPara; pPara = rTextObj.Next(), bFirstParagraph = FALSE )
1345 PortionObj* pPortion = (PortionObj*)pPara->First();
1346 nCharCount = pPara->Count();
1348 nDepth = pPara->nDepth;
1349 if ( nDepth > 4)
1350 nDepth = 4;
1352 if ( ( pPara->meTextAdjust == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1353 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_Adjust, pPara->mnTextAdjust ) ) )
1354 nPropertyFlags |= 0x00000800;
1355 nLineSpacing = pPara->mnLineSpacing;
1357 const FontCollectionEntry* pDesc = maFontCollection.GetById( pPortion->mnFont );
1358 sal_Int16 nNormalSpacing = 100;
1359 if ( !mbFontIndependentLineSpacing && pDesc )
1361 double fN = 100.0;
1362 fN *= pDesc->Scaling;
1363 nNormalSpacing = (sal_Int16)( fN + 0.5 );
1365 if ( !mbFontIndependentLineSpacing && bFirstParagraph && ( nLineSpacing > nNormalSpacing ) ) // sj: i28747, no replacement for fixed linespacing
1367 nLineSpacing = nNormalSpacing;
1368 nPropertyFlags |= 0x00001000;
1370 else
1372 if ( nLineSpacing > 0 )
1374 if ( !mbFontIndependentLineSpacing && pDesc )
1375 nLineSpacing = (sal_Int16)( (double)nLineSpacing * pDesc->Scaling + 0.5 );
1377 else
1379 if ( !pPara->mbFixedLineSpacing && pPortion && pPortion->mnCharHeight > (sal_uInt16)( ((double)-nLineSpacing) * 0.001 * 72.0 / 2.54 ) ) // 1/100mm to point
1380 nLineSpacing = nNormalSpacing;
1381 else
1382 nLineSpacing = (sal_Int16)( (double)nLineSpacing / 4.40972 );
1384 if ( ( pPara->meLineSpacing == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1385 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_LineFeed, nLineSpacing ) ) )
1386 nPropertyFlags |= 0x00001000;
1388 if ( ( pPara->meLineSpacingTop == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1389 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_UpperDist, pPara->mnLineSpacingTop ) ) )
1390 nPropertyFlags |= 0x00002000;
1391 if ( ( pPara->meLineSpacingBottom == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1392 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_LowerDist, pPara->mnLineSpacingBottom ) ) )
1393 nPropertyFlags |= 0x00004000;
1394 if ( ( pPara->meForbiddenRules == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1395 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_UpperDist, pPara->mbForbiddenRules ) ) )
1396 nPropertyFlags |= 0x00020000;
1397 if ( ( pPara->meParagraphPunctation == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1398 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_UpperDist, pPara->mbParagraphPunctation ) ) )
1399 nPropertyFlags |= 0x00080000;
1400 if ( ( pPara->meBiDi == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1401 ( mpStyleSheet->IsHardAttribute( nInstance, nDepth, ParaAttr_BiDi, pPara->mnBiDi ) ) )
1402 nPropertyFlags |= 0x00200000;
1405 sal_Int32 nBuRealSize = pPara->nBulletRealSize;
1406 sal_Int16 nBulletFlags = pPara->nBulletFlags;
1408 if ( pPara->bExtendedParameters )
1409 nPropertyFlags |= pPara->nParaFlags;
1410 else
1412 nPropertyFlags |= 1; // turn off bullet explicit
1413 nBulletFlags = 0;
1415 FontCollectionEntry aFontDescEntry( pPara->aFontDesc.Name, pPara->aFontDesc.Family, pPara->aFontDesc.Pitch, pPara->aFontDesc.CharSet );
1416 sal_uInt16 nFontId = (sal_uInt16)maFontCollection.GetId( aFontDescEntry );
1418 rOut << nCharCount
1419 << nDepth // Level
1420 << (sal_uInt32)nPropertyFlags; // Paragraph Attribut Set
1422 if ( nPropertyFlags & 0xf )
1423 rOut << nBulletFlags;
1424 if ( nPropertyFlags & 0x80 )
1425 rOut << (sal_uInt16)( pPara->cBulletId );
1426 if ( nPropertyFlags & 0x10 )
1427 rOut << nFontId;
1428 if ( nPropertyFlags & 0x40 )
1429 rOut << (sal_Int16)nBuRealSize;
1430 if ( nPropertyFlags & 0x20 )
1432 sal_uInt32 nBulletColor = pPara->nBulletColor;
1433 if ( nBulletColor == COL_AUTO )
1435 sal_Bool bIsDark = sal_False;
1436 ::com::sun::star::uno::Any aAny;
1437 if ( PropValue::GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundDark" ) ), sal_True ) )
1438 aAny >>= bIsDark;
1439 nBulletColor = bIsDark ? 0xffffff : 0x000000;
1441 nBulletColor &= 0xffffff;
1442 nBulletColor |= 0xfe000000;
1443 rOut << nBulletColor;
1445 if ( nPropertyFlags & 0x00000800 )
1446 rOut << (sal_uInt16)( pPara->mnTextAdjust );
1447 if ( nPropertyFlags & 0x00001000 )
1448 rOut << (sal_uInt16)( nLineSpacing );
1449 if ( nPropertyFlags & 0x00002000 )
1450 rOut << (sal_uInt16)( pPara->mnLineSpacingTop );
1451 if ( nPropertyFlags & 0x00004000 )
1452 rOut << (sal_uInt16)( pPara->mnLineSpacingBottom );
1453 if ( nPropertyFlags & 0x000e0000 )
1455 sal_uInt16 nAsianSettings = 0;
1456 if ( pPara->mbForbiddenRules )
1457 nAsianSettings |= 1;
1458 if ( pPara->mbParagraphPunctation )
1459 nAsianSettings |= 4;
1460 rOut << nAsianSettings;
1462 if ( nPropertyFlags & 0x200000 )
1463 rOut << pPara->mnBiDi;
1467 // -----------------------------------------------------------------------
1469 void PPTWriter::ImplWritePortions( SvStream& rOut, TextObj& rTextObj )
1471 sal_uInt32 nPropertyFlags, i = 0;
1472 int nInstance = rTextObj.GetInstance();
1474 for ( ParagraphObj* pPara = rTextObj.First(); pPara; pPara = rTextObj.Next(), i++ )
1476 for ( PortionObj* pPortion = (PortionObj*)pPara->First(); pPortion; pPortion = (PortionObj*)pPara->Next() )
1478 nPropertyFlags = 0;
1479 sal_uInt32 nCharAttr = pPortion->mnCharAttr;
1480 sal_uInt32 nCharColor = pPortion->mnCharColor;
1482 if ( nCharColor == COL_AUTO ) // nCharColor depends to the background color
1484 sal_Bool bIsDark = sal_False;
1485 ::com::sun::star::uno::Any aAny;
1486 if ( PropValue::GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundDark" ) ), sal_True ) )
1487 aAny >>= bIsDark;
1488 nCharColor = bIsDark ? 0xffffff : 0x000000;
1491 nCharColor &= 0xffffff;
1493 /* the portion is using the embossed or engraved attribute, which we want to map to the relief feature of PPT.
1494 Because the relief feature of PPT is dependent to the background color, such a mapping can not always be used. */
1495 if ( nCharAttr & 0x200 )
1497 sal_uInt32 nBackgroundColor = 0xffffff;
1499 if ( !nCharColor ) // special threatment for
1500 nCharColor = 0xffffff; // black fontcolor
1502 ::com::sun::star::uno::Any aAny;
1503 ::com::sun::star::drawing::FillStyle aFS( ::com::sun::star::drawing::FillStyle_NONE );
1504 if ( PropValue::GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ) ) )
1505 aAny >>= aFS;
1506 switch( aFS )
1508 case ::com::sun::star::drawing::FillStyle_GRADIENT :
1510 Point aEmptyPoint = Point();
1511 Rectangle aRect( aEmptyPoint, Size( 28000, 21000 ) );
1512 EscherPropertyContainer aPropOpt( (EscherGraphicProvider&)*mpPptEscherEx, mpPicStrm, aRect );
1513 aPropOpt.CreateGradientProperties( mXPropSet );
1514 aPropOpt.GetOpt( ESCHER_Prop_fillColor, nBackgroundColor );
1516 break;
1517 case ::com::sun::star::drawing::FillStyle_SOLID :
1519 if ( PropValue::GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ) ) )
1520 nBackgroundColor = mpPptEscherEx->GetColor( *((sal_uInt32*)aAny.getValue()) );
1522 break;
1523 case ::com::sun::star::drawing::FillStyle_NONE :
1525 ::com::sun::star::uno::Any aBackAny;
1526 ::com::sun::star::drawing::FillStyle aBackFS( ::com::sun::star::drawing::FillStyle_NONE );
1527 if ( PropValue::GetPropertyValue( aBackAny, mXBackgroundPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ) ) )
1528 aBackAny >>= aBackFS;
1529 switch( aBackFS )
1531 case ::com::sun::star::drawing::FillStyle_GRADIENT :
1533 Point aEmptyPoint = Point();
1534 Rectangle aRect( aEmptyPoint, Size( 28000, 21000 ) );
1535 EscherPropertyContainer aPropOpt( (EscherGraphicProvider&)*mpPptEscherEx, mpPicStrm, aRect );
1536 aPropOpt.CreateGradientProperties( mXBackgroundPropSet );
1537 aPropOpt.GetOpt( ESCHER_Prop_fillColor, nBackgroundColor );
1539 break;
1540 case ::com::sun::star::drawing::FillStyle_SOLID :
1542 if ( PropValue::GetPropertyValue( aAny, mXBackgroundPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ) ) )
1543 nBackgroundColor = mpPptEscherEx->GetColor( *((sal_uInt32*)aAny.getValue()) );
1545 break;
1546 default:
1547 break;
1550 break;
1551 default:
1552 break;
1555 sal_Int32 nB = nBackgroundColor & 0xff;
1556 nB += (sal_uInt8)( nBackgroundColor >> 8 );
1557 nB += (sal_uInt8)( nBackgroundColor >> 16 );
1558 // if the background color is nearly black, relief can't been used, because the text would not be visible
1559 if ( nB < 0x60 || ( nBackgroundColor != nCharColor ) )
1561 nCharAttr &=~ 0x200;
1563 // now check if the text is part of a group, and if the previous object has the same color than the fontcolor
1564 // ( and if fillcolor is not available the background color ), it is sometimes
1565 // not possible to export the 'embossed' flag
1566 if ( ( GetCurrentGroupLevel() > 0 ) && ( GetCurrentGroupIndex() >= 1 ) )
1568 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > aGroupedShape( GetCurrentGroupAccess()->getByIndex( GetCurrentGroupIndex() - 1 ), uno::UNO_QUERY );
1569 if( aGroupedShape.is() )
1571 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aPropSetOfNextShape
1572 ( aGroupedShape, ::com::sun::star::uno::UNO_QUERY );
1573 if ( aPropSetOfNextShape.is() )
1575 if ( PropValue::GetPropertyValue( aAny, aPropSetOfNextShape,
1576 String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ), sal_True ) )
1578 if ( nCharColor == mpPptEscherEx->GetColor( *((sal_uInt32*)aAny.getValue()) ) )
1580 nCharAttr |= 0x200;
1588 nCharColor |= 0xfe000000;
1589 if ( nInstance == 4 ) // special handling for normal textobjects:
1590 nPropertyFlags |= nCharAttr & 0x217; // not all attributes ar inherited
1591 else
1593 if ( /* ( pPortion->mnCharAttrHard & 1 ) || */
1594 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, CharAttr_Bold, nCharAttr ) ) )
1595 nPropertyFlags |= 1;
1596 if ( /* ( pPortion->mnCharAttrHard & 2 ) || */
1597 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, CharAttr_Italic, nCharAttr ) ) )
1598 nPropertyFlags |= 2;
1599 if ( /* ( pPortion->mnCharAttrHard & 4 ) || */
1600 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, CharAttr_Underline, nCharAttr ) ) )
1601 nPropertyFlags |= 4;
1602 if ( /* ( pPortion->mnCharAttrHard & 0x10 ) || */
1603 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, CharAttr_Shadow, nCharAttr ) ) )
1604 nPropertyFlags |= 0x10;
1605 if ( /* ( pPortion->mnCharAttrHard & 0x200 ) || */
1606 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, CharAttr_Embossed, nCharAttr ) ) )
1607 nPropertyFlags |= 512;
1609 if ( rTextObj.HasExtendedBullets() )
1611 nPropertyFlags |= ( i & 0x3f ) << 10 ;
1612 nCharAttr |= ( i & 0x3f ) << 10;
1614 if ( ( pPortion->meFontName == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1615 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, CharAttr_Font, pPortion->mnFont ) ) )
1616 nPropertyFlags |= 0x00010000;
1617 if ( ( pPortion->meAsianOrComplexFont == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1618 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, CharAttr_AsianOrComplexFont, pPortion->mnAsianOrComplexFont ) ) )
1619 nPropertyFlags |= 0x00200000;
1620 if ( ( pPortion->meCharHeight == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1621 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, CharAttr_FontHeight, pPortion->mnCharHeight ) ) )
1622 nPropertyFlags |= 0x00020000;
1623 if ( ( pPortion->meCharColor == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1624 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, CharAttr_FontColor, nCharColor & 0xffffff ) ) )
1625 nPropertyFlags |= 0x00040000;
1626 if ( ( pPortion->meCharEscapement == ::com::sun::star::beans::PropertyState_DIRECT_VALUE ) ||
1627 ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, CharAttr_Escapement, pPortion->mnCharEscapement ) ) )
1628 nPropertyFlags |= 0x00080000;
1630 sal_uInt32 nCharCount = pPortion->Count();
1632 rOut << nCharCount
1633 << nPropertyFlags; //PropertyFlags
1635 if ( nPropertyFlags & 0xffff )
1636 rOut << (sal_uInt16)( nCharAttr );
1637 if ( nPropertyFlags & 0x00010000 )
1638 rOut << pPortion->mnFont;
1639 if ( nPropertyFlags & 0x00200000 )
1640 rOut << pPortion->mnAsianOrComplexFont;
1641 if ( nPropertyFlags & 0x00020000 )
1642 rOut << (sal_uInt16)( pPortion->mnCharHeight );
1643 if ( nPropertyFlags & 0x00040000 )
1644 rOut << (sal_uInt32)nCharColor;
1645 if ( nPropertyFlags & 0x00080000 )
1646 rOut << pPortion->mnCharEscapement;
1651 // ----------------------------------------------------------------------------------------
1652 // laedt und konvertiert text aus shape, ergebnis ist mnTextSize gespeichert;
1653 sal_Bool PPTWriter::ImplGetText()
1655 mnTextSize = 0;
1656 mbFontIndependentLineSpacing = sal_False;
1657 mXText = ::com::sun::star::uno::Reference<
1658 ::com::sun::star::text::XSimpleText >
1659 ( mXShape, ::com::sun::star::uno::UNO_QUERY );
1661 if ( mXText.is() )
1663 mnTextSize = mXText->getString().getLength();
1664 ::com::sun::star::uno::Any aAny;
1665 if ( GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FontIndependentLineSpacing" ) ) ), sal_True )
1666 aAny >>= mbFontIndependentLineSpacing;
1668 return ( mnTextSize != 0 );
1671 // -----------------------------------------------------------------------
1673 void PPTWriter::ImplFlipBoundingBox( EscherPropertyContainer& rPropOpt )
1675 if ( mnAngle < 0 )
1676 mnAngle = ( 36000 + mnAngle ) % 36000;
1677 else
1678 mnAngle = ( 36000 - ( mnAngle % 36000 ) );
1680 double fCos = cos( (double)mnAngle * F_PI18000 );
1681 double fSin = sin( (double)mnAngle * F_PI18000 );
1683 double fWidthHalf = maRect.GetWidth() / 2;
1684 double fHeightHalf = maRect.GetHeight() / 2;
1686 double fXDiff = fCos * fWidthHalf + fSin * (-fHeightHalf);
1687 double fYDiff = - ( fSin * fWidthHalf - fCos * ( -fHeightHalf ) );
1689 maRect.Move( (sal_Int32)( -( fWidthHalf - fXDiff ) ), (sal_Int32)( - ( fHeightHalf + fYDiff ) ) );
1690 mnAngle *= 655;
1691 mnAngle += 0x8000;
1692 mnAngle &=~0xffff; // nAngle auf volle Gradzahl runden
1693 rPropOpt.AddOpt( ESCHER_Prop_Rotation, mnAngle );
1695 if ( ( mnAngle >= ( 45 << 16 ) && mnAngle < ( 135 << 16 ) ) ||
1696 ( mnAngle >= ( 225 << 16 ) && mnAngle < ( 315 << 16 ) ) )
1698 // In diesen beiden Bereichen steht in PPT gemeinerweise die
1699 // BoundingBox bereits senkrecht. Daher muss diese VOR
1700 // DER ROTATION flachgelegt werden.
1701 ::com::sun::star::awt::Point
1702 aTopLeft( (sal_Int32)( maRect.Left() + fWidthHalf - fHeightHalf ), (sal_Int32)( maRect.Top() + fHeightHalf - fWidthHalf ) );
1703 Size aNewSize( maRect.GetHeight(), maRect.GetWidth() );
1704 maRect = Rectangle( Point( aTopLeft.X, aTopLeft.Y ), aNewSize );
1708 // -----------------------------------------------------------------------
1710 struct FieldEntry
1712 sal_uInt32 nFieldType;
1713 sal_uInt32 nFieldStartPos;
1714 sal_uInt32 nFieldEndPos;
1715 String aRepresentation;
1716 String aFieldUrl;
1718 FieldEntry( sal_uInt32 nType, sal_uInt32 nStart, sal_uInt32 nEnd )
1720 nFieldType = nType;
1721 nFieldStartPos = nStart;
1722 nFieldEndPos = nEnd;
1726 // -----------------------------------------------------------------------
1728 PortionObj::PortionObj( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
1729 FontCollection& rFontCollection ) :
1730 mnCharAttrHard ( 0 ),
1731 mnCharAttr ( 0 ),
1732 mnFont ( 0 ),
1733 mnAsianOrComplexFont( 0xffff ),
1734 mnTextSize ( 0 ),
1735 mbLastPortion ( TRUE ),
1736 mpText ( NULL ),
1737 mpFieldEntry ( NULL )
1739 mXPropSet = rXPropSet;
1741 ImplGetPortionValues( rFontCollection, FALSE );
1744 PortionObj::PortionObj( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & rXTextRange,
1745 sal_Bool bLast, FontCollection& rFontCollection ) :
1746 mnCharAttrHard ( 0 ),
1747 mnCharAttr ( 0 ),
1748 mnFont ( 0 ),
1749 mnAsianOrComplexFont ( 0xffff ),
1750 mbLastPortion ( bLast ),
1751 mpText ( NULL ),
1752 mpFieldEntry ( NULL )
1754 String aString( rXTextRange->getString() );
1755 String aURL;
1756 BOOL bRTL_endingParen = FALSE;
1758 mnTextSize = aString.Len();
1759 if ( bLast )
1760 mnTextSize++;
1762 if ( mnTextSize )
1764 mpFieldEntry = NULL;
1765 sal_uInt32 nFieldType = 0;
1767 mXPropSet = ::com::sun::star::uno::Reference<
1768 ::com::sun::star::beans::XPropertySet >
1769 ( rXTextRange, ::com::sun::star::uno::UNO_QUERY );
1770 mXPropState = ::com::sun::star::uno::Reference<
1771 ::com::sun::star::beans::XPropertyState >
1772 ( rXTextRange, ::com::sun::star::uno::UNO_QUERY );
1774 sal_Bool bPropSetsValid = ( mXPropSet.is() && mXPropState.is() );
1775 if ( bPropSetsValid )
1776 nFieldType = ImplGetTextField( rXTextRange, mXPropSet, aURL );
1777 if ( nFieldType )
1779 mpFieldEntry = new FieldEntry( nFieldType, 0, mnTextSize );
1780 if ( ( nFieldType >> 28 == 4 ) )
1782 mpFieldEntry->aRepresentation = aString;
1783 mpFieldEntry->aFieldUrl = aURL;
1786 sal_Bool bSymbol = FALSE;
1788 if ( bPropSetsValid && ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontCharSet" ) ), FALSE ) )
1790 sal_Int16 nCharset;
1791 mAny >>= nCharset;
1792 if ( nCharset == ::com::sun::star::awt::CharSet::SYMBOL )
1793 bSymbol = TRUE;
1795 if ( mpFieldEntry && ( nFieldType & 0x800000 ) ) // placeholder ?
1797 mnTextSize = 1;
1798 if ( bLast )
1799 mnTextSize++;
1800 mpText = new sal_uInt16[ mnTextSize ];
1801 mpText[ 0 ] = 0x2a;
1803 else
1805 const sal_Unicode* pText = aString.GetBuffer();
1806 // For i39516 - a closing parenthesis that ends an RTL string is displayed backwards by PPT
1807 // Solution: add a Unicode Right-to-Left Mark, following the method described in i18024
1808 if ( bLast && pText[ aString.Len() - 1 ] == sal_Unicode(')') && rFontCollection.GetScriptDirection( aString ) == com::sun::star::i18n::ScriptDirection::RIGHT_TO_LEFT )
1810 mnTextSize++;
1811 bRTL_endingParen = TRUE;
1813 mpText = new sal_uInt16[ mnTextSize ];
1814 sal_uInt16 nChar;
1815 for ( int i = 0; i < aString.Len(); i++ )
1817 nChar = (sal_uInt16)pText[ i ];
1818 if ( nChar == 0xa )
1819 nChar++;
1820 else if ( !bSymbol )
1822 switch ( nChar )
1824 // Currency
1825 case 128: nChar = 0x20AC; break;
1826 // Punctuation and other
1827 case 130: nChar = 0x201A; break;// SINGLE LOW-9 QUOTATION MARK
1828 case 131: nChar = 0x0192; break;// LATIN SMALL LETTER F WITH HOOK
1829 case 132: nChar = 0x201E; break;// DOUBLE LOW-9 QUOTATION MARK
1830 // LOW DOUBLE PRIME QUOTATION MARK
1831 case 133: nChar = 0x2026; break;// HORIZONTAL ELLIPSES
1832 case 134: nChar = 0x2020; break;// DAGGER
1833 case 135: nChar = 0x2021; break;// DOUBLE DAGGER
1834 case 136: nChar = 0x02C6; break;// MODIFIER LETTER CIRCUMFLEX ACCENT
1835 case 137: nChar = 0x2030; break;// PER MILLE SIGN
1836 case 138: nChar = 0x0160; break;// LATIN CAPITAL LETTER S WITH CARON
1837 case 139: nChar = 0x2039; break;// SINGLE LEFT-POINTING ANGLE QUOTATION MARK
1838 case 140: nChar = 0x0152; break;// LATIN CAPITAL LIGATURE OE
1839 case 142: nChar = 0x017D; break;// LATIN CAPITAL LETTER Z WITH CARON
1840 case 145: nChar = 0x2018; break;// LEFT SINGLE QUOTATION MARK
1841 // MODIFIER LETTER TURNED COMMA
1842 case 146: nChar = 0x2019; break;// RIGHT SINGLE QUOTATION MARK
1843 // MODIFIER LETTER APOSTROPHE
1844 case 147: nChar = 0x201C; break;// LEFT DOUBLE QUOTATION MARK
1845 // REVERSED DOUBLE PRIME QUOTATION MARK
1846 case 148: nChar = 0x201D; break;// RIGHT DOUBLE QUOTATION MARK
1847 // REVERSED DOUBLE PRIME QUOTATION MARK
1848 case 149: nChar = 0x2022; break;// BULLET
1849 case 150: nChar = 0x2013; break;// EN DASH
1850 case 151: nChar = 0x2014; break;// EM DASH
1851 case 152: nChar = 0x02DC; break;// SMALL TILDE
1852 case 153: nChar = 0x2122; break;// TRADE MARK SIGN
1853 case 154: nChar = 0x0161; break;// LATIN SMALL LETTER S WITH CARON
1854 case 155: nChar = 0x203A; break;// SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
1855 case 156: nChar = 0x0153; break;// LATIN SMALL LIGATURE OE
1856 case 158: nChar = 0x017E; break;// LATIN SMALL LETTER Z WITH CARON
1857 case 159: nChar = 0x0178; break;// LATIN CAPITAL LETTER Y WITH DIAERESIS
1858 // case 222: nChar = 0x00B6; break;// PILCROW SIGN / PARAGRAPH SIGN
1861 mpText[ i ] = nChar;
1864 if ( bRTL_endingParen )
1865 mpText[ mnTextSize - 2 ] = 0x200F; // Unicode Right-to-Left mark
1867 if ( bLast )
1868 mpText[ mnTextSize - 1 ] = 0xd;
1870 if ( bPropSetsValid )
1871 ImplGetPortionValues( rFontCollection, TRUE );
1875 PortionObj::PortionObj( PortionObj& rPortionObj )
1876 : PropStateValue( rPortionObj )
1878 ImplConstruct( rPortionObj );
1881 PortionObj::~PortionObj()
1883 ImplClear();
1886 void PortionObj::Write( SvStream* pStrm, sal_Bool bLast )
1888 sal_uInt32 nCount = mnTextSize;
1889 if ( bLast && mbLastPortion )
1890 nCount--;
1891 for ( sal_uInt32 i = 0; i < nCount; i++ )
1892 *pStrm << (sal_uInt16)mpText[ i ];
1895 void PortionObj::ImplGetPortionValues( FontCollection& rFontCollection, sal_Bool bGetPropStateValue )
1898 sal_Bool bOk = ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" ) ), bGetPropStateValue );
1899 meFontName = ePropState;
1900 if ( bOk )
1902 FontCollectionEntry aFontDesc( *(::rtl::OUString*)mAny.getValue() );
1903 sal_uInt32 nCount = rFontCollection.GetCount();
1904 mnFont = (sal_uInt16)rFontCollection.GetId( aFontDesc );
1905 if ( mnFont == nCount )
1907 FontCollectionEntry& rFontDesc = rFontCollection.GetLast();
1908 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontCharSet" ) ), sal_False ) )
1909 mAny >>= rFontDesc.CharSet;
1910 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontFamily" ) ), sal_False ) )
1911 mAny >>= rFontDesc.Family;
1912 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontPitch" ) ), sal_False ) )
1913 mAny >>= rFontDesc.Pitch;
1917 sal_Int16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( Application::GetSettings().GetLanguage() );
1918 if ( mpText && mnTextSize && xPPTBreakIter.is() )
1920 rtl::OUString sT( mpText, mnTextSize );
1921 nScriptType = xPPTBreakIter->getScriptType( sT, 0 );
1923 if ( nScriptType != com::sun::star::i18n::ScriptType::COMPLEX )
1925 bOk = ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontNameAsian" ) ), bGetPropStateValue );
1926 meAsianOrComplexFont = ePropState;
1927 if ( bOk )
1929 FontCollectionEntry aFontDesc( *(::rtl::OUString*)mAny.getValue() );
1930 sal_uInt32 nCount = rFontCollection.GetCount();
1931 mnAsianOrComplexFont = (sal_uInt16)rFontCollection.GetId( aFontDesc );
1932 if ( mnAsianOrComplexFont == nCount )
1934 FontCollectionEntry& rFontDesc = rFontCollection.GetLast();
1935 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontCharSetAsian" ) ), sal_False ) )
1936 mAny >>= rFontDesc.CharSet;
1937 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontFamilyAsian" ) ), sal_False ) )
1938 mAny >>= rFontDesc.Family;
1939 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontPitchAsian" ) ), sal_False ) )
1940 mAny >>= rFontDesc.Pitch;
1944 else
1946 bOk = ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontNameComplex" ) ), bGetPropStateValue );
1947 meAsianOrComplexFont = ePropState;
1948 if ( bOk )
1950 FontCollectionEntry aFontDesc( *(::rtl::OUString*)mAny.getValue() );
1951 sal_uInt32 nCount = rFontCollection.GetCount();
1952 mnAsianOrComplexFont = (sal_uInt16)rFontCollection.GetId( aFontDesc );
1953 if ( mnAsianOrComplexFont == nCount )
1955 FontCollectionEntry& rFontDesc = rFontCollection.GetLast();
1956 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontCharSetComplex" ) ), sal_False ) )
1957 mAny >>= rFontDesc.CharSet;
1958 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontFamilyComplex" ) ), sal_False ) )
1959 mAny >>= rFontDesc.Family;
1960 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharFontPitchComplex" ) ), sal_False ) )
1961 mAny >>= rFontDesc.Pitch;
1966 if ( nScriptType != com::sun::star::i18n::ScriptType::COMPLEX )
1968 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharWeight" ) ), bGetPropStateValue ) )
1970 float fFloat;
1971 mAny >>= fFloat;
1972 if ( fFloat >= ::com::sun::star::awt::FontWeight::SEMIBOLD )
1973 mnCharAttr |= 1;
1976 else
1978 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharWeightComplex" ) ), bGetPropStateValue ) )
1980 float fFloat;
1981 mAny >>= fFloat;
1982 if ( fFloat >= ::com::sun::star::awt::FontWeight::SEMIBOLD )
1983 mnCharAttr |= 1;
1987 if ( ePropState == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
1988 mnCharAttrHard |= 1;
1990 if ( nScriptType != com::sun::star::i18n::ScriptType::COMPLEX )
1992 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharPosture" ) ), bGetPropStateValue ) )
1994 ::com::sun::star::awt::FontSlant aFS;
1995 mAny >>= aFS;
1996 switch ( aFS )
1998 case ::com::sun::star::awt::FontSlant_OBLIQUE :
1999 case ::com::sun::star::awt::FontSlant_ITALIC :
2000 mnCharAttr |= 2;
2001 break;
2002 default:
2003 break;
2007 else
2009 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharPostureComplex" ) ), bGetPropStateValue ) )
2011 ::com::sun::star::awt::FontSlant aFS;
2012 mAny >>= aFS;
2013 switch ( aFS )
2015 case ::com::sun::star::awt::FontSlant_OBLIQUE :
2016 case ::com::sun::star::awt::FontSlant_ITALIC :
2017 mnCharAttr |= 2;
2018 break;
2019 default:
2020 break;
2025 if ( ePropState == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2026 mnCharAttrHard |= 2;
2028 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharUnderline" ) ), bGetPropStateValue ) )
2030 sal_Int16 nVal;
2031 mAny >>= nVal;
2032 switch ( nVal )
2034 case ::com::sun::star::awt::FontUnderline::SINGLE :
2035 case ::com::sun::star::awt::FontUnderline::DOUBLE :
2036 case ::com::sun::star::awt::FontUnderline::DOTTED :
2037 mnCharAttr |= 4;
2040 if ( ePropState == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2041 mnCharAttrHard |= 4;
2043 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharShadowed" ) ), bGetPropStateValue ) )
2045 sal_Bool bBool;
2046 mAny >>= bBool;
2047 if ( bBool )
2048 mnCharAttr |= 0x10;
2050 if ( ePropState == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2051 mnCharAttrHard |= 16;
2053 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharLocale" ) ), bGetPropStateValue ) )
2055 com::sun::star::lang::Locale eLocale;
2056 if ( mAny >>= eLocale )
2057 meCharLocale = eLocale;
2060 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharRelief" ) ), bGetPropStateValue ) )
2062 sal_Int16 nVal;
2063 mAny >>= nVal;
2064 if ( nVal != ::com::sun::star::text::FontRelief::NONE )
2065 mnCharAttr |= 512;
2067 if ( ePropState == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
2068 mnCharAttrHard |= 512;
2070 mnCharHeight = 24;
2071 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ) ), bGetPropStateValue ) )
2073 float fVal;
2074 mAny >>= fVal;
2075 mnCharHeight = (sal_uInt16)( fVal + 0.5 );
2077 meCharHeight = ePropState;
2079 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharColor" ) ), bGetPropStateValue ) )
2081 sal_uInt32 nSOColor = *( (sal_uInt32*)mAny.getValue() );
2082 mnCharColor = nSOColor & 0xff00ff00; // green and hibyte
2083 mnCharColor |= (sal_uInt8)( nSOColor ) << 16; // red and blue is switched
2084 mnCharColor |= (sal_uInt8)( nSOColor >> 16 );
2086 meCharColor = ePropState;
2088 mnCharEscapement = 0;
2089 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ), bGetPropStateValue ) )
2091 mAny >>= mnCharEscapement;
2092 if ( mnCharEscapement > 100 )
2093 mnCharEscapement = 33;
2094 else if ( mnCharEscapement < -100 )
2095 mnCharEscapement = -33;
2097 meCharEscapement = ePropState;
2100 void PortionObj::ImplClear()
2102 delete (FieldEntry*)mpFieldEntry;
2103 delete[] mpText;
2106 void PortionObj::ImplConstruct( PortionObj& rPortionObj )
2108 mbLastPortion = rPortionObj.mbLastPortion;
2109 mnTextSize = rPortionObj.mnTextSize;
2110 mnCharColor = rPortionObj.mnCharColor;
2111 mnCharEscapement = rPortionObj.mnCharEscapement;
2112 mnCharAttr = rPortionObj.mnCharAttr;
2113 mnCharHeight = rPortionObj.mnCharHeight;
2114 mnFont = rPortionObj.mnFont;
2115 mnAsianOrComplexFont = rPortionObj.mnAsianOrComplexFont;
2117 if ( rPortionObj.mpText )
2119 mpText = new sal_uInt16[ mnTextSize ];
2120 memcpy( mpText, rPortionObj.mpText, mnTextSize << 1 );
2122 else
2123 mpText = NULL;
2125 if ( rPortionObj.mpFieldEntry )
2126 mpFieldEntry = new FieldEntry( *( rPortionObj.mpFieldEntry ) );
2127 else
2128 mpFieldEntry = NULL;
2131 sal_uInt32 PortionObj::ImplCalculateTextPositions( sal_uInt32 nCurrentTextPosition )
2133 if ( mpFieldEntry && ( !mpFieldEntry->nFieldStartPos ) )
2135 mpFieldEntry->nFieldStartPos += nCurrentTextPosition;
2136 mpFieldEntry->nFieldEndPos += nCurrentTextPosition;
2138 return mnTextSize;
2141 // -----------------------------------------------------------------------
2142 // Rueckgabe: 0 = kein TextField
2143 // bit28->31 text field type :
2144 // 1 = Date
2145 // 2 = Time
2146 // 3 = SlideNumber
2147 // 4 = Url
2148 // 5 = DateTime
2149 // 6 = header
2150 // 7 = footer
2151 // bit24->27 text field sub type (optional)
2152 // 23-> PPT Textfield needs a placeholder
2154 sal_uInt32 PortionObj::ImplGetTextField( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & ,
2155 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet, String& rURL )
2157 sal_uInt32 nRetValue = 0;
2158 sal_Int32 nFormat;
2159 ::com::sun::star::uno::Any aAny;
2160 if ( GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextPortionType" ) ), sal_True ) )
2162 String aTextFieldType( *(::rtl::OUString*)aAny.getValue() );
2163 if ( aTextFieldType == String( RTL_CONSTASCII_USTRINGPARAM( "TextField" ) ) )
2165 if ( GetPropertyValue( aAny, rXPropSet, aTextFieldType, sal_True ) )
2167 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > aXTextField;
2168 if ( aAny >>= aXTextField )
2170 if ( aXTextField.is() )
2172 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
2173 xFieldPropSet( aXTextField, ::com::sun::star::uno::UNO_QUERY );
2174 if ( xFieldPropSet.is() )
2176 String aFieldKind( aXTextField->getPresentation( TRUE ) );
2177 if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "Date" ) ) )
2179 if ( GetPropertyValue( aAny, xFieldPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsFix" ) ) ), sal_True )
2181 sal_Bool bBool;
2182 aAny >>= bBool;
2183 if ( !bBool ) // Fixed DateFields gibt es in PPT nicht
2185 if ( GetPropertyValue( aAny, xFieldPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Format" ) ) ), sal_True )
2187 nFormat = *(sal_Int32*)aAny.getValue();
2188 switch ( nFormat )
2190 default:
2191 case 5 :
2192 case 4 :
2193 case 2 : nFormat = 0; break;
2194 case 8 :
2195 case 9 :
2196 case 3 : nFormat = 1; break;
2197 case 7 :
2198 case 6 : nFormat = 2; break;
2200 nRetValue |= ( ( ( 1 << 4 ) | nFormat ) << 24 ) | 0x800000;
2205 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) )
2207 if ( GetPropertyValue( aAny, xFieldPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) ), sal_True )
2208 rURL = String( *(::rtl::OUString*)aAny.getValue() );
2209 nRetValue = 4 << 28;
2211 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "Page" ) ) )
2213 nRetValue = 3 << 28 | 0x800000;
2215 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "Pages" ) ) )
2219 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "Time" ) ) )
2221 if ( GetPropertyValue( aAny, xFieldPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsFix" ) ) ), sal_True )
2223 sal_Bool bBool;
2224 aAny >>= bBool;
2225 if ( !bBool )
2227 if ( GetPropertyValue( aAny, xFieldPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsFix" ) ) ), sal_True )
2229 nFormat = *(sal_Int32*)aAny.getValue();
2230 nRetValue |= ( ( ( 2 << 4 ) | nFormat ) << 24 ) | 0x800000;
2235 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "File" ) ) )
2239 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "Table" ) ) )
2243 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "ExtTime" ) ) )
2245 if ( GetPropertyValue( aAny, xFieldPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsFix" ) ) ), sal_True )
2247 sal_Bool bBool;
2248 aAny >>= bBool;
2249 if ( !bBool )
2251 if ( GetPropertyValue( aAny, xFieldPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Format" ) ) ), sal_True )
2253 nFormat = *(sal_Int32*)aAny.getValue();
2254 switch ( nFormat )
2256 default:
2257 case 6 :
2258 case 7 :
2259 case 8 :
2260 case 2 : nFormat = 12; break;
2261 case 3 : nFormat = 9; break;
2262 case 5 :
2263 case 4 : nFormat = 10; break;
2266 nRetValue |= ( ( ( 2 << 4 ) | nFormat ) << 24 ) | 0x800000;
2271 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "ExtFile" ) ) )
2275 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "Author" ) ) )
2279 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "DateTime" ) ) )
2281 nRetValue = 5 << 28 | 0x800000;
2283 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "Header" ) ) )
2285 nRetValue = 6 << 28 | 0x800000;
2287 else if ( aFieldKind == String( RTL_CONSTASCII_USTRINGPARAM( "Footer" ) ) )
2289 nRetValue = 7 << 28 | 0x800000;
2297 return nRetValue;
2300 PortionObj& PortionObj::operator=( PortionObj& rPortionObj )
2302 if ( this != &rPortionObj )
2304 ImplClear();
2305 ImplConstruct( rPortionObj );
2307 return *this;
2310 // -----------------------------------------------------------------------
2312 ParagraphObj::ParagraphObj( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
2313 PPTExBulletProvider& rProv ) :
2314 maMapModeSrc ( MAP_100TH_MM ),
2315 maMapModeDest ( MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ) )
2317 mXPropSet = rXPropSet;
2319 bExtendedParameters = FALSE;
2321 nDepth = 0;
2322 nBulletFlags = 0;
2323 nParaFlags = 0;
2325 ImplGetParagraphValues( rProv, FALSE );
2328 ParagraphObj::ParagraphObj( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & rXTextContent,
2329 ParaFlags aParaFlags, FontCollection& rFontCollection, PPTExBulletProvider& rProv ) :
2330 maMapModeSrc ( MAP_100TH_MM ),
2331 maMapModeDest ( MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ) ),
2332 mbFirstParagraph ( aParaFlags.bFirstParagraph ),
2333 mbLastParagraph ( aParaFlags.bLastParagraph )
2335 bExtendedParameters = FALSE;
2337 nDepth = 0;
2338 nBulletFlags = 0;
2339 nParaFlags = 0;
2341 mXPropSet = ::com::sun::star::uno::Reference<
2342 ::com::sun::star::beans::XPropertySet >
2343 ( rXTextContent, ::com::sun::star::uno::UNO_QUERY );
2345 mXPropState = ::com::sun::star::uno::Reference<
2346 ::com::sun::star::beans::XPropertyState >
2347 ( rXTextContent, ::com::sun::star::uno::UNO_QUERY );
2349 if ( mXPropSet.is() && mXPropState.is() )
2351 ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess >
2352 aXTextPortionEA( rXTextContent, ::com::sun::star::uno::UNO_QUERY );
2353 if ( aXTextPortionEA.is() )
2355 ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >
2356 aXTextPortionE( aXTextPortionEA->createEnumeration() );
2357 if ( aXTextPortionE.is() )
2359 while ( aXTextPortionE->hasMoreElements() )
2361 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > aXCursorText;
2362 ::com::sun::star::uno::Any aAny( aXTextPortionE->nextElement() );
2363 if ( aAny >>= aXCursorText )
2365 PortionObj* pPortionObj = new PortionObj( aXCursorText, !aXTextPortionE->hasMoreElements(), rFontCollection );
2366 if ( pPortionObj->Count() )
2367 Insert( pPortionObj, LIST_APPEND );
2368 else
2369 delete pPortionObj;
2374 ImplGetParagraphValues( rProv, TRUE );//
2378 ParagraphObj::ParagraphObj( ParagraphObj& rObj )
2379 : List()
2380 , PropStateValue()
2381 , SOParagraph()
2383 ImplConstruct( rObj );
2386 ParagraphObj::~ParagraphObj()
2388 ImplClear();
2391 void ParagraphObj::Write( SvStream* pStrm )
2393 for ( void* pPtr = First(); pPtr; pPtr = Next() )
2394 ((PortionObj*)pPtr)->Write( pStrm, mbLastParagraph );
2397 void ParagraphObj::ImplClear()
2399 for ( void* pPtr = First(); pPtr; pPtr = Next() )
2400 delete (PortionObj*)pPtr;
2403 void ParagraphObj::CalculateGraphicBulletSize( sal_uInt16 nFontHeight )
2405 if ( ( (SvxExtNumType)nNumberingType == SVX_NUM_BITMAP ) && ( nBulletId != 0xffff ) )
2407 // calculate the bulletrealsize for this grafik
2408 if ( aBuGraSize.Width() && aBuGraSize.Height() )
2410 double fCharHeight = nFontHeight;
2411 double fLen = aBuGraSize.Height();
2412 fCharHeight = fCharHeight * 0.2540;
2413 double fQuo = fLen / fCharHeight;
2414 nBulletRealSize = (sal_Int16)( fQuo + 0.5 );
2415 if ( (sal_uInt16)nBulletRealSize > 400 )
2416 nBulletRealSize = 400;
2421 // from sw/source/filter/ww8/wrtw8num.cxx for default bullets to export to MS intact
2422 static void lcl_SubstituteBullet(String& rNumStr, rtl_TextEncoding& rChrSet, String& rFontName)
2424 StarSymbolToMSMultiFont *pConvert = 0;
2425 FontFamily eFamily = FAMILY_DECORATIVE;
2427 if (!pConvert)
2429 pConvert = CreateStarSymbolToMSMultiFont();
2431 sal_Unicode cChar = rNumStr.GetChar(0);
2432 String sFont = pConvert->ConvertChar(cChar);
2433 if (sFont.Len())
2435 rNumStr = static_cast< sal_Unicode >(cChar | 0xF000);
2436 rFontName = sFont;
2437 rChrSet = RTL_TEXTENCODING_SYMBOL;
2439 else if ( (rNumStr.GetChar(0) < 0xE000 || rNumStr.GetChar(0) > 0xF8FF) )
2442 Ok we can't fit into a known windows unicode font, but
2443 we are not in the private area, so we are a
2444 standardized symbol, so turn off the symbol bit and
2445 let words own font substitution kick in
2447 rChrSet = RTL_TEXTENCODING_UNICODE;
2448 eFamily = FAMILY_SWISS;
2449 rFontName = ::GetFontToken(rFontName, 0);
2451 else
2454 Well we don't have an available substition, and we're
2455 in our private area, so give up and show a standard
2456 bullet symbol
2458 rFontName.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Wingdings"));
2459 rNumStr = static_cast< sal_Unicode >(0x6C);
2461 delete pConvert;
2464 void ParagraphObj::ImplGetNumberingLevel( PPTExBulletProvider& rBuProv, sal_Int16 nNumberingDepth, sal_Bool bIsBullet, sal_Bool bGetPropStateValue )
2466 ::com::sun::star::uno::Any aAny;
2467 if ( GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "ParaLeftMargin" ) ) ) )
2469 sal_Int32 nVal;
2470 if ( aAny >>= nVal )
2471 nTextOfs = static_cast< sal_Int16 >( nVal / ( 2540.0 / 576 ) + 0.5 ) ;
2473 if ( GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "ParaFirstLineIndent" ) ) ) )
2475 if ( aAny >>= nBulletOfs )
2476 nBulletOfs = static_cast< sal_Int32 >( nBulletOfs / ( 2540.0 / 576 ) + 0.5 );
2478 if ( GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsNumber" ) ) ) )
2479 aAny >>= bNumberingIsNumber;
2481 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace > aXIndexReplace;
2483 if ( bIsBullet && ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "NumberingRules" ) ), bGetPropStateValue ) )
2485 if ( ( mAny >>= aXIndexReplace ) && nNumberingDepth < aXIndexReplace->getCount() )
2487 mAny <<= aXIndexReplace->getByIndex( nNumberingDepth );
2488 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>
2489 aPropertySequence( *( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>*)mAny.getValue() );
2491 const ::com::sun::star::beans::PropertyValue* pPropValue = aPropertySequence.getArray();
2493 sal_Int32 nPropertyCount = aPropertySequence.getLength();
2494 if ( nPropertyCount )
2496 bExtendedParameters = TRUE;
2497 nBulletRealSize = 100;
2498 nMappedNumType = 0;
2500 String aGraphicURL;
2501 for ( sal_Int32 i = 0; i < nPropertyCount; i++ )
2503 const void* pValue = pPropValue[ i ].Value.getValue();
2504 if ( pValue )
2506 ::rtl::OUString aPropName( pPropValue[ i ].Name );
2507 if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "NumberingType" ) ) )
2508 nNumberingType = *( (sal_Int16*)pValue );
2509 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Adjust" ) ) )
2510 nHorzAdjust = *( (sal_Int16*)pValue );
2511 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BulletChar" ) ) )
2513 String aString( *( (String*)pValue ) );
2514 if ( aString.Len() )
2515 cBulletId = aString.GetChar( 0 );
2517 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BulletFont" ) ) )
2519 aFontDesc = *( (::com::sun::star::awt::FontDescriptor*)pValue );
2521 // Our numbullet dialog has set the wrong textencoding for our "StarSymbol" font,
2522 // instead of a Unicode encoding the encoding RTL_TEXTENCODING_SYMBOL was used.
2523 // Because there might exist a lot of damaged documemts I added this two lines
2524 // which fixes the bullet problem for the export.
2525 if ( aFontDesc.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StarSymbol" ) ) )
2526 aFontDesc.CharSet = RTL_TEXTENCODING_MS_1252;
2529 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "GraphicURL" ) ) )
2530 aGraphicURL = ( *(::rtl::OUString*)pValue );
2531 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "GraphicSize" ) ) )
2533 if ( pPropValue[ i ].Value.getValueType() == ::getCppuType( (::com::sun::star::awt::Size*)0) )
2535 // don't cast awt::Size to Size as on 64-bits they are not the same.
2536 ::com::sun::star::awt::Size aSize;
2537 pPropValue[ i ].Value >>= aSize;
2538 aBuGraSize.nA = aSize.Width;
2539 aBuGraSize.nB = aSize.Height;
2542 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StartWith" ) ) )
2543 nStartWith = *( (sal_Int16*)pValue );
2544 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "LeftMargin" ) ) )
2545 nTextOfs = nTextOfs + static_cast< sal_Int16 >( *( (sal_Int32*)pValue ) / ( 2540.0 / 576 ) );
2546 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FirstLineOffset" ) ) )
2547 nBulletOfs += (sal_Int16)( *( (sal_Int32*)pValue ) / ( 2540.0 / 576 ) );
2548 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BulletColor" ) ) )
2550 sal_uInt32 nSOColor = *( (sal_uInt32*)pValue );
2551 nBulletColor = nSOColor & 0xff00ff00; // green and hibyte
2552 nBulletColor |= (sal_uInt8)( nSOColor ) << 16; // red
2553 nBulletColor |= (sal_uInt8)( nSOColor >> 16 ) | 0xfe000000; // blue
2555 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BulletRelSize" ) ) )
2557 nBulletRealSize = *( (sal_Int16*)pValue );
2558 nParaFlags |= 0x40;
2559 nBulletFlags |= 8;
2561 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Prefix" ) ) )
2562 sPrefix = ( *(::rtl::OUString*)pValue );
2563 else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Suffix" ) ) )
2564 sSuffix = ( *(::rtl::OUString*)pValue );
2565 #ifdef DBG_UTIL
2566 else if ( ! (
2567 ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "SymbolTextDistance" ) ) )
2568 || ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Graphic" ) ) ) ) )
2570 DBG_ERROR( "Unbekanntes Property" );
2572 #endif
2576 if ( aGraphicURL.Len() )
2578 if ( aBuGraSize.Width() && aBuGraSize.Height() )
2580 xub_StrLen nIndex = aGraphicURL.Search( (sal_Unicode)':', 0 );
2581 if ( nIndex != STRING_NOTFOUND )
2583 nIndex++;
2584 if ( aGraphicURL.Len() > nIndex )
2586 ByteString aUniqueId( aGraphicURL, nIndex, aGraphicURL.Len() - nIndex, RTL_TEXTENCODING_UTF8 );
2587 if ( aUniqueId.Len() )
2589 nBulletId = rBuProv.GetId( aUniqueId, aBuGraSize );
2590 if ( nBulletId != 0xffff )
2591 bExtendedBulletsUsed = TRUE;
2596 else
2598 nNumberingType = SVX_NUM_NUMBER_NONE;
2602 PortionObj* pPortion = (PortionObj*)First();
2603 CalculateGraphicBulletSize( ( pPortion ) ? pPortion->mnCharHeight : 24 );
2605 switch( (SvxExtNumType)nNumberingType )
2607 case SVX_NUM_NUMBER_NONE : nParaFlags |= 0xf; break;
2609 case SVX_NUM_CHAR_SPECIAL : // Bullet
2611 if ( aFontDesc.Name.equalsIgnoreAsciiCaseAscii("starsymbol") ||
2612 aFontDesc.Name.equalsIgnoreAsciiCaseAscii("opensymbol") )
2614 String sFontName = aFontDesc.Name;
2615 String sNumStr = cBulletId;
2616 rtl_TextEncoding eChrSet = aFontDesc.CharSet;
2617 lcl_SubstituteBullet(sNumStr,eChrSet,sFontName);
2618 aFontDesc.Name = sFontName;
2619 cBulletId = sNumStr.GetChar( 0 );
2620 aFontDesc.CharSet = eChrSet;
2623 if ( aFontDesc.Name.getLength() )
2626 if ( aFontDesc.CharSet != ::com::sun::star::awt::CharSet::SYMBOL )
2628 switch ( cBulletId )
2630 // Currency
2631 case 128: cBulletId = 0x20AC; break;
2632 // Punctuation and other
2633 case 130: cBulletId = 0x201A; break;// SINGLE LOW-9 QUOTATION MARK
2634 case 131: cBulletId = 0x0192; break;// LATIN SMALL LETTER F WITH HOOK
2635 case 132: cBulletId = 0x201E; break;// DOUBLE LOW-9 QUOTATION MARK
2636 // LOW DOUBLE PRIME QUOTATION MARK
2637 case 133: cBulletId = 0x2026; break;// HORIZONTAL ELLIPSES
2638 case 134: cBulletId = 0x2020; break;// DAGGER
2639 case 135: cBulletId = 0x2021; break;// DOUBLE DAGGER
2640 case 136: cBulletId = 0x02C6; break;// MODIFIER LETTER CIRCUMFLEX ACCENT
2641 case 137: cBulletId = 0x2030; break;// PER MILLE SIGN
2642 case 138: cBulletId = 0x0160; break;// LATIN CAPITAL LETTER S WITH CARON
2643 case 139: cBulletId = 0x2039; break;// SINGLE LEFT-POINTING ANGLE QUOTATION MARK
2644 case 140: cBulletId = 0x0152; break;// LATIN CAPITAL LIGATURE OE
2645 case 142: cBulletId = 0x017D; break;// LATIN CAPITAL LETTER Z WITH CARON
2646 case 145: cBulletId = 0x2018; break;// LEFT SINGLE QUOTATION MARK
2647 // MODIFIER LETTER TURNED COMMA
2648 case 146: cBulletId = 0x2019; break;// RIGHT SINGLE QUOTATION MARK
2649 // MODIFIER LETTER APOSTROPHE
2650 case 147: cBulletId = 0x201C; break;// LEFT DOUBLE QUOTATION MARK
2651 // REVERSED DOUBLE PRIME QUOTATION MARK
2652 case 148: cBulletId = 0x201D; break;// RIGHT DOUBLE QUOTATION MARK
2653 // REVERSED DOUBLE PRIME QUOTATION MARK
2654 case 149: cBulletId = 0x2022; break;// BULLET
2655 case 150: cBulletId = 0x2013; break;// EN DASH
2656 case 151: cBulletId = 0x2014; break;// EM DASH
2657 case 152: cBulletId = 0x02DC; break;// SMALL TILDE
2658 case 153: cBulletId = 0x2122; break;// TRADE MARK SIGN
2659 case 154: cBulletId = 0x0161; break;// LATIN SMALL LETTER S WITH CARON
2660 case 155: cBulletId = 0x203A; break;// SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
2661 case 156: cBulletId = 0x0153; break;// LATIN SMALL LIGATURE OE
2662 case 158: cBulletId = 0x017E; break;// LATIN SMALL LETTER Z WITH CARON
2663 case 159: cBulletId = 0x0178; break;// LATIN CAPITAL LETTER Y WITH DIAERESIS
2664 // case 222: cBulletId = 0x00B6; break;// PILCROW SIGN / PARAGRAPH SIGN
2668 nParaFlags |= 0x90; // wir geben den Font und den Charset vor
2671 case SVX_NUM_CHARS_UPPER_LETTER : // zaehlt von a-z, aa - az, ba - bz, ...
2672 case SVX_NUM_CHARS_LOWER_LETTER :
2673 case SVX_NUM_ROMAN_UPPER :
2674 case SVX_NUM_ROMAN_LOWER :
2675 case SVX_NUM_ARABIC :
2676 case SVX_NUM_PAGEDESC : // Numerierung aus der Seitenvorlage
2677 case SVX_NUM_BITMAP :
2678 case SVX_NUM_CHARS_UPPER_LETTER_N : // zaehlt von a-z, aa-zz, aaa-zzz
2679 case SVX_NUM_CHARS_LOWER_LETTER_N :
2681 if ( nNumberingType != SVX_NUM_CHAR_SPECIAL )
2683 bExtendedBulletsUsed = TRUE;
2684 if ( nNumberingDepth & 1 )
2685 cBulletId = 0x2013; // defaulting bullet characters for ppt97
2686 else if ( nNumberingDepth == 4 )
2687 cBulletId = 0xbb;
2688 else
2689 cBulletId = 0x2022;
2691 switch( (SvxExtNumType)nNumberingType )
2693 case SVX_NUM_CHARS_UPPER_LETTER :
2694 case SVX_NUM_CHARS_UPPER_LETTER_N :
2696 if ( sSuffix == String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) )
2698 if ( sPrefix == String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) )
2699 nMappedNumType = 0xa0001; // (A)
2700 else
2701 nMappedNumType = 0xb0001; // A)
2703 else
2704 nMappedNumType = 0x10001; // A.
2706 break;
2707 case SVX_NUM_CHARS_LOWER_LETTER :
2708 case SVX_NUM_CHARS_LOWER_LETTER_N :
2710 if ( sSuffix == String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) )
2712 if ( sPrefix == String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) )
2713 nMappedNumType = 0x80001; // (a)
2714 else
2715 nMappedNumType = 0x90001; // a)
2717 else
2718 nMappedNumType = 0x00001; // a.
2720 break;
2721 case SVX_NUM_ROMAN_UPPER :
2723 if ( sSuffix == String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) )
2725 if ( sPrefix == String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) )
2726 nMappedNumType = 0xe0001; // (I)
2727 else
2728 nMappedNumType = 0xf0001; // I)
2730 else
2731 nMappedNumType = 0x70001; // I.
2733 break;
2734 case SVX_NUM_ROMAN_LOWER :
2736 if ( sSuffix == String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) )
2738 if ( sPrefix == String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) )
2739 nMappedNumType = 0x40001; // (i)
2740 else
2741 nMappedNumType = 0x50001; // i)
2743 else
2744 nMappedNumType = 0x60001; // i.
2746 break;
2747 case SVX_NUM_ARABIC :
2749 if ( sSuffix == String( RTL_CONSTASCII_USTRINGPARAM( ")" ) ) )
2751 if ( sPrefix == String( RTL_CONSTASCII_USTRINGPARAM( "(" ) ) )
2752 nMappedNumType = 0xc0001; // (1)
2753 else
2754 nMappedNumType = 0x20001; // 1)
2756 else
2758 if ( ! ( sSuffix.Len() + sPrefix.Len() ) )
2759 nMappedNumType = 0xd0001; // 1
2760 else
2761 nMappedNumType = 0x30001; // 1.
2764 break;
2765 default:
2766 break;
2769 nParaFlags |= 0x2f;
2770 nBulletFlags |= 6;
2771 if ( mbIsBullet && bNumberingIsNumber )
2772 nBulletFlags |= 1;
2778 nBulletOfs = nTextOfs + nBulletOfs;
2779 if ( nBulletOfs < 0 )
2780 nBulletOfs = 0;
2783 void ParagraphObj::ImplGetParagraphValues( PPTExBulletProvider& rBuProv, sal_Bool bGetPropStateValue )
2785 static String sNumberingLevel ( RTL_CONSTASCII_USTRINGPARAM( "NumberingLevel" ) );
2787 ::com::sun::star::uno::Any aAny;
2788 if ( GetPropertyValue( aAny, mXPropSet, sNumberingLevel, sal_True ) )
2790 if ( bGetPropStateValue )
2791 meBullet = GetPropertyState( mXPropSet, sNumberingLevel );
2792 nDepth = *( (sal_Int16*)aAny.getValue() );
2794 if ( nDepth < 0 )
2796 mbIsBullet = sal_False;
2797 nDepth = 0;
2799 else
2801 if ( nDepth > 4 )
2802 nDepth = 4;
2803 mbIsBullet = sal_True;
2806 else
2808 nDepth = 0;
2809 mbIsBullet = sal_False;
2811 ImplGetNumberingLevel( rBuProv, nDepth, mbIsBullet, bGetPropStateValue );
2813 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "ParaTabStops" ) ), bGetPropStateValue ) )
2814 maTabStop = *( ::com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop>*)mAny.getValue();
2815 sal_Int16 eTextAdjust( ::com::sun::star::style::ParagraphAdjust_LEFT );
2816 if ( GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "ParaAdjust" ) ), bGetPropStateValue ) )
2817 aAny >>= eTextAdjust;
2818 switch ( (::com::sun::star::style::ParagraphAdjust)eTextAdjust )
2820 case ::com::sun::star::style::ParagraphAdjust_CENTER :
2821 mnTextAdjust = 1;
2822 break;
2823 case ::com::sun::star::style::ParagraphAdjust_RIGHT :
2824 mnTextAdjust = 2;
2825 break;
2826 case ::com::sun::star::style::ParagraphAdjust_BLOCK :
2827 mnTextAdjust = 3;
2828 break;
2829 default :
2830 case ::com::sun::star::style::ParagraphAdjust_LEFT :
2831 mnTextAdjust = 0;
2832 break;
2834 meTextAdjust = ePropState;
2836 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "ParaLineSpacing" ) ), bGetPropStateValue ) )
2838 ::com::sun::star::style::LineSpacing aLineSpacing
2839 = *( (::com::sun::star::style::LineSpacing*)mAny.getValue() );
2840 switch ( aLineSpacing.Mode )
2842 case ::com::sun::star::style::LineSpacingMode::FIX :
2843 mnLineSpacing = (sal_Int16)(-( aLineSpacing.Height ) );
2844 mbFixedLineSpacing = TRUE;
2845 break;
2846 case ::com::sun::star::style::LineSpacingMode::MINIMUM :
2847 case ::com::sun::star::style::LineSpacingMode::LEADING :
2848 mnLineSpacing = (sal_Int16)(-( aLineSpacing.Height ) );
2849 mbFixedLineSpacing = FALSE;
2850 break;
2852 case ::com::sun::star::style::LineSpacingMode::PROP :
2853 default:
2854 mnLineSpacing = (sal_Int16)( aLineSpacing.Height );
2855 break;
2858 meLineSpacing = ePropState;
2860 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "ParaBottomMargin" ) ), bGetPropStateValue ) )
2862 double fSpacing = *( (sal_uInt32*)mAny.getValue() ) + ( 2540.0 / 576.0 ) - 1;
2863 mnLineSpacingBottom = (sal_Int16)(-( fSpacing * 576.0 / 2540.0 ) );
2865 meLineSpacingBottom = ePropState;
2867 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "ParaTopMargin" ) ), bGetPropStateValue ) )
2869 double fSpacing = *( (sal_uInt32*)mAny.getValue() ) + ( 2540.0 / 576.0 ) - 1;
2870 mnLineSpacingTop = (sal_Int16)(-( fSpacing * 576.0 / 2540.0 ) );
2872 meLineSpacingTop = ePropState;
2874 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "ParaIsForbiddenRules" ) ), bGetPropStateValue ) )
2875 mAny >>= mbForbiddenRules;
2876 meForbiddenRules = ePropState;
2878 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "ParaIsHangingPunctuation" ) ), bGetPropStateValue ) )
2879 mAny >>= mbParagraphPunctation;
2880 meParagraphPunctation = ePropState;
2882 mnBiDi = 0;
2883 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "WritingMode" ) ), bGetPropStateValue ) )
2885 sal_Int16 nWritingMode;
2886 mAny >>= nWritingMode;
2888 SvxFrameDirection eWritingMode( (SvxFrameDirection)nWritingMode );
2889 if ( ( eWritingMode == FRMDIR_HORI_RIGHT_TOP )
2890 || ( eWritingMode == FRMDIR_VERT_TOP_RIGHT ) )
2892 mnBiDi = 1;
2895 meBiDi = ePropState;
2898 void ParagraphObj::ImplConstruct( ParagraphObj& rParagraphObj )
2900 mnTextSize = rParagraphObj.mnTextSize;
2901 mnTextAdjust = rParagraphObj.mnTextAdjust;
2902 mnLineSpacing = rParagraphObj.mnLineSpacing;
2903 mnLineSpacingTop = rParagraphObj.mnLineSpacingTop;
2904 mnLineSpacingBottom = rParagraphObj.mnLineSpacingBottom;
2905 mbFirstParagraph = rParagraphObj.mbFirstParagraph;
2906 mbLastParagraph = rParagraphObj.mbLastParagraph;
2907 mbParagraphPunctation = rParagraphObj.mbParagraphPunctation;
2908 mbForbiddenRules = rParagraphObj.mbForbiddenRules;
2909 mnBiDi = rParagraphObj.mnBiDi;
2911 for ( void* pPtr = rParagraphObj.First(); pPtr; pPtr = rParagraphObj.Next() )
2912 Insert( new PortionObj( *(PortionObj*)pPtr ), LIST_APPEND );
2914 maTabStop = rParagraphObj.maTabStop;
2915 bExtendedParameters = rParagraphObj.bExtendedParameters;
2916 nParaFlags = rParagraphObj.nParaFlags;
2917 nBulletFlags = rParagraphObj.nBulletFlags;
2918 sPrefix = rParagraphObj.sPrefix;
2919 sSuffix = rParagraphObj.sSuffix;
2920 sGraphicUrl = rParagraphObj.sGraphicUrl; // String auf eine Graphic
2921 aBuGraSize = rParagraphObj.aBuGraSize;
2922 nNumberingType = rParagraphObj.nNumberingType; // in wirlichkeit ist dies ein SvxEnum
2923 nHorzAdjust = rParagraphObj.nHorzAdjust;
2924 nBulletColor = rParagraphObj.nBulletColor;
2925 nBulletOfs = rParagraphObj.nBulletOfs;
2926 nStartWith = rParagraphObj.nStartWith; // Start der nummerierung
2927 nTextOfs = rParagraphObj.nTextOfs;
2928 nBulletRealSize = rParagraphObj.nBulletRealSize; // GroessenVerhaeltnis in Proz
2929 nDepth = rParagraphObj.nDepth; // aktuelle tiefe
2930 cBulletId = rParagraphObj.cBulletId; // wenn Numbering Type == CharSpecial
2931 aFontDesc = rParagraphObj.aFontDesc;
2933 bExtendedBulletsUsed = rParagraphObj.bExtendedBulletsUsed;
2934 nBulletId = rParagraphObj.nBulletId;
2937 ::com::sun::star::awt::Size ParagraphObj::ImplMapSize( const ::com::sun::star::awt::Size& rSize )
2939 Size aSize( OutputDevice::LogicToLogic( Size( rSize.Width, rSize.Height ), maMapModeSrc, maMapModeDest ) );
2940 if ( !aSize.Width() )
2941 aSize.Width()++;
2942 if ( !aSize.Height() )
2943 aSize.Height()++;
2944 return ::com::sun::star::awt::Size( aSize.Width(), aSize.Height() );
2947 sal_uInt32 ParagraphObj::ImplCalculateTextPositions( sal_uInt32 nCurrentTextPosition )
2949 mnTextSize = 0;
2950 for ( void* pPtr = First(); pPtr; pPtr = Next() )
2951 mnTextSize += ((PortionObj*)pPtr)->ImplCalculateTextPositions( nCurrentTextPosition + mnTextSize );
2952 return mnTextSize;
2955 ParagraphObj& ParagraphObj::operator=( ParagraphObj& rParagraphObj )
2957 if ( this != &rParagraphObj )
2959 ImplClear();
2960 ImplConstruct( rParagraphObj );
2962 return *this;
2965 // -----------------------------------------------------------------------
2967 ImplTextObj::ImplTextObj( int nInstance )
2969 mnRefCount = 1;
2970 mnTextSize = 0;
2971 mnInstance = nInstance;
2972 mpList = new List;
2973 mbHasExtendedBullets = FALSE;
2974 mbFixedCellHeightUsed = FALSE;
2977 ImplTextObj::~ImplTextObj()
2979 for ( ParagraphObj* pPtr = (ParagraphObj*)mpList->First(); pPtr; pPtr = (ParagraphObj*)mpList->Next() )
2980 delete pPtr;
2981 delete mpList;
2984 TextObj::TextObj( ::com::sun::star::uno::Reference< ::com::sun::star::text::XSimpleText > & rXTextRef,
2985 int nInstance, FontCollection& rFontCollection, PPTExBulletProvider& rProv )
2987 mpImplTextObj = new ImplTextObj( nInstance );
2989 ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess >
2990 aXTextParagraphEA( rXTextRef, ::com::sun::star::uno::UNO_QUERY );
2992 if ( aXTextParagraphEA.is() )
2994 ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >
2995 aXTextParagraphE( aXTextParagraphEA->createEnumeration() );
2996 if ( aXTextParagraphE.is() )
2998 ParaFlags aParaFlags;
2999 while ( aXTextParagraphE->hasMoreElements() )
3001 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > aXParagraph;
3002 ::com::sun::star::uno::Any aAny( aXTextParagraphE->nextElement() );
3003 if ( aAny >>= aXParagraph )
3005 if ( !aXTextParagraphE->hasMoreElements() )
3006 aParaFlags.bLastParagraph = TRUE;
3007 ParagraphObj* pPara = new ParagraphObj( aXParagraph, aParaFlags, rFontCollection, rProv );
3008 mpImplTextObj->mbHasExtendedBullets |= pPara->bExtendedBulletsUsed;
3009 mpImplTextObj->mpList->Insert( pPara, LIST_APPEND );
3010 aParaFlags.bFirstParagraph = FALSE;
3015 ImplCalculateTextPositions();
3018 TextObj::TextObj( TextObj& rTextObj )
3020 mpImplTextObj = rTextObj.mpImplTextObj;
3021 mpImplTextObj->mnRefCount++;
3024 TextObj::~TextObj()
3026 if ( ! ( --mpImplTextObj->mnRefCount ) )
3027 delete mpImplTextObj;
3030 void TextObj::Write( SvStream* pStrm )
3032 sal_uInt32 nSize, nPos = pStrm->Tell();
3033 *pStrm << (sal_uInt32)( EPP_TextCharsAtom << 16 ) << (sal_uInt32)0;
3034 for ( void* pPtr = First(); pPtr; pPtr = Next() )
3035 ((ParagraphObj*)pPtr)->Write( pStrm );
3036 nSize = pStrm->Tell() - nPos;
3037 pStrm->SeekRel( - ( (sal_Int32)nSize - 4 ) );
3038 *pStrm << (sal_uInt32)( nSize - 8 );
3039 pStrm->SeekRel( nSize - 8 );
3042 void TextObj::ImplCalculateTextPositions()
3044 mpImplTextObj->mnTextSize = 0;
3045 for ( void* pPtr = First(); pPtr; pPtr = Next() )
3046 mpImplTextObj->mnTextSize += ((ParagraphObj*)pPtr)->ImplCalculateTextPositions( mpImplTextObj->mnTextSize );
3049 TextObj& TextObj::operator=( TextObj& rTextObj )
3051 if ( this != &rTextObj )
3053 if ( ! ( --mpImplTextObj->mnRefCount ) )
3054 delete mpImplTextObj;
3055 mpImplTextObj = rTextObj.mpImplTextObj;
3056 mpImplTextObj->mnRefCount++;
3058 return *this;
3061 void TextObj::WriteTextSpecInfo( SvStream* pStrm )
3063 sal_uInt32 nCharactersLeft( Count() );
3064 if ( nCharactersLeft >= 1 )
3066 EscherExAtom aAnimationInfoAtom( *pStrm, EPP_TextSpecInfoAtom, 0, 0 );
3067 for ( ParagraphObj* pPtr = static_cast < ParagraphObj * >( First() ); nCharactersLeft && pPtr; pPtr = static_cast< ParagraphObj* >( Next() ) )
3069 for ( PortionObj* pPortion = static_cast< PortionObj* >( pPtr->First() ); nCharactersLeft && pPortion; pPortion = static_cast< PortionObj* >( pPtr->Next() ) )
3071 sal_Int32 nPortionSize = pPortion->mnTextSize >= nCharactersLeft ? nCharactersLeft : pPortion->mnTextSize;
3072 sal_Int32 nFlags = 7;
3073 nCharactersLeft -= nPortionSize;
3074 *pStrm << static_cast< sal_uInt32 >( nPortionSize )
3075 << nFlags
3076 << static_cast< sal_Int16 >( 1 ) // spellinfo -> needs rechecking
3077 << static_cast< sal_Int16 >( MsLangId::convertLocaleToLanguageWithFallback( pPortion->meCharLocale ) )
3078 << static_cast< sal_Int16 >( 0 ); // alt language
3081 if ( nCharactersLeft )
3082 *pStrm << nCharactersLeft << static_cast< sal_Int32 >( 1 ) << static_cast< sal_Int16 >( 1 );
3087 // -----------------------------------------------------------------------
3089 void PPTWriter::ImplAdjustFirstLineLineSpacing( TextObj& rTextObj, EscherPropertyContainer& rPropOpt )
3091 if ( !mbFontIndependentLineSpacing )
3093 ParagraphObj* pPara = rTextObj.First();
3094 if ( pPara )
3096 PortionObj* pPortion = (PortionObj*)pPara->First();
3097 if ( pPortion )
3099 sal_Int16 nLineSpacing = pPara->mnLineSpacing;
3100 const FontCollectionEntry* pDesc = maFontCollection.GetById( pPortion->mnFont );
3101 if ( pDesc )
3102 nLineSpacing = (sal_Int16)( (double)nLineSpacing * pDesc->Scaling + 0.5 );
3104 if ( ( nLineSpacing > 0 ) && ( nLineSpacing < 100 ) )
3107 if ( rxText.is() )
3109 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape( rxText, ::com::sun::star::uno::UNO_QUERY );
3110 if ( xShape.is() )
3112 SdrObject* pObj = GetSdrObjectFromXShape( mXShape );
3113 if ( pObj )
3115 const OutlinerParaObject* pParaObj = pObj->GetOutlinerParaObject();
3116 if ( pParaObj )
3118 SdrModel* pModel = pObj->GetModel();
3119 if ( pModel )
3121 Outliner aOutliner( &pModel->GetItemPool(), pParaObj->GetOutlinerMode() );
3122 aOutliner.SetText( *pParaObj );
3123 ULONG nTextHeight = aOutliner.GetLineHeight( 0, 0 );
3124 if ( nTextHeight )
3133 double fCharHeight = pPortion->mnCharHeight;
3134 fCharHeight *= 2540 / 72;
3135 fCharHeight *= 100 - nLineSpacing;
3136 fCharHeight /= 100;
3138 sal_uInt32 nUpperDistance = 0;
3139 rPropOpt.GetOpt( ESCHER_Prop_dyTextTop, nUpperDistance );
3140 nUpperDistance += static_cast< sal_uInt32 >( fCharHeight * 360.0 );
3141 rPropOpt.AddOpt( ESCHER_Prop_dyTextTop, nUpperDistance );
3148 // -----------------------------------------------------------------------
3150 void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_uInt32 nAtomInstance,
3151 TextRuleEntry* pTextRule, SvStream& rExtBuStr, EscherPropertyContainer* pPropOpt )
3153 PPTExParaSheet& rParaSheet = mpStyleSheet->GetParaSheet( nTextInstance );
3155 rOut << (sal_uInt32)( ( EPP_TextHeaderAtom << 16 ) | ( nAtomInstance << 4 ) ) << (sal_uInt32)4
3156 << nTextInstance;
3158 if ( mbEmptyPresObj )
3159 mnTextSize = 0;
3160 if ( !mbEmptyPresObj )
3162 ParagraphObj* pPara;
3163 TextObj aTextObj( mXText, nTextInstance, maFontCollection, (PPTExBulletProvider&)*this );
3165 // leaving out EPP_TextCharsAtom w/o text - still write out
3166 // attribute info though
3167 if ( mnTextSize )
3168 aTextObj.Write( &rOut );
3170 if ( pPropOpt )
3171 ImplAdjustFirstLineLineSpacing( aTextObj, *pPropOpt );
3173 sal_uInt32 nSize, nPos = rOut.Tell();
3175 rOut << (sal_uInt32)( EPP_StyleTextPropAtom << 16 ) << (sal_uInt32)0;
3176 ImplWriteParagraphs( rOut, aTextObj );
3177 ImplWritePortions( rOut, aTextObj );
3178 nSize = rOut.Tell() - nPos;
3179 rOut.SeekRel( - ( (sal_Int32)nSize - 4 ) );
3180 rOut << (sal_uInt32)( nSize - 8 );
3181 rOut.SeekRel( nSize - 8 );
3183 for ( pPara = aTextObj.First(); pPara; pPara = aTextObj.Next() )
3185 for ( PortionObj* pPortion = (PortionObj*)pPara->First(); pPortion; pPortion = (PortionObj*)pPara->Next() )
3187 if ( pPortion->mpFieldEntry )
3189 const FieldEntry* pFieldEntry = pPortion->mpFieldEntry;
3191 switch ( pFieldEntry->nFieldType >> 28 )
3193 case 1 :
3194 case 2 :
3196 rOut << (sal_uInt32)( EPP_DateTimeMCAtom << 16 ) << (sal_uInt32)8
3197 << (sal_uInt32)( pFieldEntry->nFieldStartPos ) // TxtOffset auf TxtField;
3198 << (sal_uInt8)( pFieldEntry->nFieldType & 0xff ) // Type
3199 << (sal_uInt8)0 << (sal_uInt16)0; // PadBytes
3201 break;
3202 case 3 :
3204 rOut << (sal_uInt32)( EPP_SlideNumberMCAtom << 16 ) << (sal_uInt32 ) 4
3205 << (sal_uInt32)( pFieldEntry->nFieldStartPos );
3207 break;
3208 case 4 :
3210 sal_uInt32 nPageIndex = 0;
3211 String aPageUrl;
3212 String aEmpty;
3213 String aFile( pFieldEntry->aFieldUrl );
3214 String aTarget( pFieldEntry->aFieldUrl );
3215 INetURLObject aUrl( pFieldEntry->aFieldUrl );
3216 if ( INET_PROT_FILE == aUrl.GetProtocol() )
3217 aFile = aUrl.PathToFileName();
3218 else if ( INET_PROT_SMB == aUrl.GetProtocol() )
3220 // #n382718# (and #n261623#) Convert smb notation to '\\'
3221 aFile = aUrl.GetMainURL( INetURLObject::NO_DECODE );
3222 aFile = String( aFile.GetBuffer() + 4 ); // skip the 'smb:' part
3223 aFile.SearchAndReplaceAll( '/', '\\' );
3224 aTarget = aFile;
3226 else if ( pFieldEntry->aFieldUrl.GetChar( 0 ) == '#' )
3228 String aPage( INetURLObject::decode( pFieldEntry->aFieldUrl, '%', INetURLObject::DECODE_WITH_CHARSET ) );
3229 aPage.Erase( 0, 1 );
3230 for ( String* pStr = (String*)maSlideNameList.First(); pStr; pStr = (String*)maSlideNameList.Next(), nPageIndex++ )
3232 if ( *pStr == aPage )
3234 aPageUrl = UniString::CreateFromInt32( 256 + nPageIndex );
3235 aPageUrl.Append( String( RTL_CONSTASCII_USTRINGPARAM( "," ) ) );
3236 aPageUrl.Append( String::CreateFromInt32( nPageIndex + 1 ) );
3237 aPageUrl.Append( String( RTL_CONSTASCII_USTRINGPARAM( ",Slide " ) ) );
3238 aPageUrl.Append( String::CreateFromInt32( nPageIndex + 1 ) );
3242 sal_uInt32 nHyperId;
3243 if ( aPageUrl.Len() )
3244 nHyperId = ImplInsertBookmarkURL( aPageUrl, 1 | ( nPageIndex << 8 ) | ( 1 << 31 ), pFieldEntry->aRepresentation, aEmpty, aEmpty, aPageUrl );
3245 else
3246 nHyperId = ImplInsertBookmarkURL( pFieldEntry->aFieldUrl, 2 | ( nHyperId << 8 ), aFile, aTarget, aEmpty, aEmpty );
3248 rOut << (sal_uInt32)( ( EPP_InteractiveInfo << 16 ) | 0xf ) << (sal_uInt32)24
3249 << (sal_uInt32)( EPP_InteractiveInfoAtom << 16 ) << (sal_uInt32)16
3250 << (sal_uInt32)0 // soundref
3251 << nHyperId // hyperlink id
3252 << (sal_uInt8)4 // hyperlink action
3253 << (sal_uInt8)0 // ole verb
3254 << (sal_uInt8)0 // jump
3255 << (sal_uInt8)0 // flags
3256 << (sal_uInt8)8 // hyperlink type ?
3257 << (sal_uInt8)0 << (sal_uInt8)0 << (sal_uInt8)0
3258 << (sal_uInt32)( EPP_TxInteractiveInfoAtom << 16 ) << (sal_uInt32)8
3259 << (sal_uInt32)( pFieldEntry->nFieldStartPos )
3260 << (sal_uInt32)( pFieldEntry->nFieldEndPos );
3262 break;
3263 case 5 :
3265 rOut << (sal_uInt32)( EPP_GenericDateMCAtom << 16 ) << (sal_uInt32)4
3266 << (sal_uInt32)( pFieldEntry->nFieldStartPos );
3268 break;
3269 case 6 :
3271 rOut << (sal_uInt32)( EPP_HeaderMCAtom << 16 ) << (sal_uInt32 ) 4
3272 << (sal_uInt32)( pFieldEntry->nFieldStartPos );
3274 break;
3275 case 7 :
3277 rOut << (sal_uInt32)( EPP_FooterMCAtom << 16 ) << (sal_uInt32 ) 4
3278 << (sal_uInt32)( pFieldEntry->nFieldStartPos );
3280 break;
3281 default:
3282 break;
3288 aTextObj.WriteTextSpecInfo( &rOut );
3290 // Star Office Default TabSizes schreiben ( wenn noetig )
3291 pPara = aTextObj.First();
3292 if ( pPara )
3294 sal_uInt32 nParaFlags = 0x1f;
3295 sal_Int16 nDepth, nMask, nNumberingRule[ 10 ];
3296 sal_uInt32 nTextOfs = pPara->nTextOfs;
3297 sal_uInt32 nTabs = pPara->maTabStop.getLength();
3298 const ::com::sun::star::style::TabStop* pTabStop = ( const ::com::sun::star::style::TabStop* )pPara->maTabStop.getConstArray();
3300 for ( ; pPara; pPara = aTextObj.Next() )
3302 if ( pPara->bExtendedParameters )
3304 nDepth = pPara->nDepth;
3305 if ( nDepth < 5 )
3307 nMask = 1 << nDepth;
3308 if ( nParaFlags & nMask )
3310 nParaFlags &=~ nMask;
3311 if ( ( rParaSheet.maParaLevel[ nDepth ].mnTextOfs != pPara->nTextOfs ) ||
3312 ( rParaSheet.maParaLevel[ nDepth ].mnBulletOfs != pPara->nBulletOfs ) )
3314 nParaFlags |= nMask << 16;
3315 nNumberingRule[ nDepth << 1 ] = pPara->nTextOfs;
3316 nNumberingRule[ ( nDepth << 1 ) + 1 ] = (sal_Int16)pPara->nBulletOfs;
3322 nParaFlags >>= 16;
3324 sal_uInt32 nDefaultTabSize = ImplMapSize( ::com::sun::star::awt::Size( 2011, 1 ) ).Width;
3325 sal_uInt32 nDefaultTabs = abs( maRect.GetWidth() ) / nDefaultTabSize;
3326 if ( nTabs )
3327 nDefaultTabs -= (sal_Int32)( ( ( pTabStop[ nTabs - 1 ].Position / 4.40972 ) + nTextOfs ) / nDefaultTabSize );
3328 if ( (sal_Int32)nDefaultTabs < 0 )
3329 nDefaultTabs = 0;
3331 sal_uInt32 nTabCount = nTabs + nDefaultTabs;
3332 sal_uInt32 i, nTextRulerAtomFlags = 0;
3334 if ( nTabCount )
3335 nTextRulerAtomFlags |= 4;
3336 if ( nParaFlags )
3337 nTextRulerAtomFlags |= ( ( nParaFlags << 3 ) | ( nParaFlags << 8 ) );
3339 if ( nTextRulerAtomFlags )
3341 SvStream* pRuleOut = &rOut;
3342 if ( pTextRule )
3343 pRuleOut = pTextRule->pOut = new SvMemoryStream( 0x100, 0x100 );
3345 sal_uInt32 nRulePos = pRuleOut->Tell();
3346 *pRuleOut << (sal_uInt32)( EPP_TextRulerAtom << 16 ) << (sal_uInt32)0;
3347 *pRuleOut << nTextRulerAtomFlags;
3348 if ( nTextRulerAtomFlags & 4 )
3350 *pRuleOut << (sal_uInt16)nTabCount;
3351 for ( i = 0; i < nTabs; i++ )
3353 sal_uInt16 nPosition = (sal_uInt16)( ( pTabStop[ i ].Position / 4.40972 ) + nTextOfs );
3354 sal_uInt16 nType;
3355 switch ( pTabStop[ i ].Alignment )
3357 case ::com::sun::star::style::TabAlign_DECIMAL : nType = 3; break;
3358 case ::com::sun::star::style::TabAlign_RIGHT : nType = 2; break;
3359 case ::com::sun::star::style::TabAlign_CENTER : nType = 1; break;
3361 case ::com::sun::star::style::TabAlign_LEFT :
3362 default: nType = 0;
3364 *pRuleOut << nPosition
3365 << nType;
3368 sal_uInt32 nWidth = 1;
3369 if ( nTabs )
3370 nWidth += (sal_Int32)( ( ( pTabStop[ nTabs - 1 ].Position / 4.40972 + nTextOfs ) / nDefaultTabSize ) );
3371 nWidth *= nDefaultTabSize;
3372 for ( i = 0; i < nDefaultTabs; i++, nWidth += nDefaultTabSize )
3373 *pRuleOut << nWidth;
3375 for ( i = 0; i < 5; i++ )
3377 if ( nTextRulerAtomFlags & ( 8 << i ) )
3378 *pRuleOut << nNumberingRule[ i << 1 ];
3379 if ( nTextRulerAtomFlags & ( 256 << i ) )
3380 *pRuleOut << nNumberingRule[ ( i << 1 ) + 1 ];
3382 sal_uInt32 nBufSize = pRuleOut->Tell() - nRulePos;
3383 pRuleOut->SeekRel( - ( (sal_Int32)nBufSize - 4 ) );
3384 *pRuleOut << (sal_uInt32)( nBufSize - 8 );
3385 pRuleOut->SeekRel( nBufSize - 8 );
3388 if ( aTextObj.HasExtendedBullets() )
3390 ParagraphObj* pBulletPara = aTextObj.First();
3391 if ( pBulletPara )
3393 sal_uInt32 nBulletFlags = 0;
3394 sal_uInt32 nNumberingType = 0, nPos2 = rExtBuStr.Tell();
3396 rExtBuStr << (sal_uInt32)( EPP_PST_ExtendedParagraphAtom << 16 ) << (sal_uInt32)0;
3398 for ( ; pBulletPara; pBulletPara = aTextObj.Next() )
3400 nBulletFlags = 0;
3401 sal_uInt16 nBulletId = pBulletPara->nBulletId;
3402 if ( pBulletPara->bExtendedBulletsUsed )
3404 nBulletFlags = 0x800000;
3405 if ( pBulletPara->nNumberingType != SVX_NUM_BITMAP )
3406 nBulletFlags = 0x3000000;
3408 rExtBuStr << (sal_uInt32)nBulletFlags;
3410 if ( nBulletFlags & 0x800000 )
3411 rExtBuStr << nBulletId;
3412 if ( nBulletFlags & 0x1000000 )
3414 switch( pBulletPara->nNumberingType )
3416 case SVX_NUM_NUMBER_NONE :
3417 case SVX_NUM_CHAR_SPECIAL :
3418 nNumberingType = 0;
3419 break;
3420 case SVX_NUM_CHARS_UPPER_LETTER :
3421 case SVX_NUM_CHARS_UPPER_LETTER_N :
3422 case SVX_NUM_CHARS_LOWER_LETTER :
3423 case SVX_NUM_CHARS_LOWER_LETTER_N :
3424 case SVX_NUM_ROMAN_UPPER :
3425 case SVX_NUM_ROMAN_LOWER :
3426 case SVX_NUM_ARABIC :
3427 nNumberingType = pBulletPara->nMappedNumType;
3428 break;
3430 // case SVX_NUM_PAGEDESC :
3431 case SVX_NUM_BITMAP :
3432 nNumberingType = 0;
3433 break;
3436 rExtBuStr << (sal_uInt32)nNumberingType;
3438 if ( nBulletFlags & 0x2000000 )
3439 rExtBuStr << (sal_uInt16)pBulletPara->nStartWith;
3440 rExtBuStr << (sal_uInt32)0 << (sal_uInt32)0;
3442 sal_uInt32 nBulletSize = ( rExtBuStr.Tell() - nPos2 ) - 8;
3443 rExtBuStr.SeekRel( - ( (sal_Int32)nBulletSize + 4 ) );
3444 rExtBuStr << nBulletSize;
3445 rExtBuStr.SeekRel( nBulletSize );
3451 // -----------------------------------------------------------------------
3453 void PPTWriter::ImplWriteObjectEffect( SvStream& rSt,
3454 ::com::sun::star::presentation::AnimationEffect eAe,
3455 ::com::sun::star::presentation::AnimationEffect eTe,
3456 sal_uInt16 nOrder )
3458 EscherExContainer aAnimationInfo( rSt, EPP_AnimationInfo );
3459 EscherExAtom aAnimationInfoAtom( rSt, EPP_AnimationInfoAtom, 0, 1 );
3460 sal_uInt32 nDimColor = 0x7000000; // color to use for dimming
3461 sal_uInt32 nFlags = 0x4400; // set of flags that determine type of build
3462 sal_uInt32 nSoundRef = 0; // 0 if storage is from clipboard. Otherwise index(ID) in SoundCollection list.
3463 sal_uInt32 nDelayTime = 0; // delay before playing object
3464 sal_uInt16 nSlideCount = 1; // number of slides to play object
3465 UINT8 nBuildType = 1; // type of build
3466 UINT8 nFlyMethod = 0; // animation effect( fly, zoom, appear, etc )
3467 UINT8 nFlyDirection = 0; // Animation direction( left, right, up, down, etc )
3468 UINT8 nAfterEffect = 0; // what to do after build
3469 UINT8 nSubEffect = 0; // build by word or letter
3470 UINT8 nOleVerb = 0; // Determines object's class (sound, video, other)
3472 if ( eAe == ::com::sun::star::presentation::AnimationEffect_NONE )
3474 nBuildType = 0;
3475 eAe = eTe;
3477 switch ( eAe )
3479 case ::com::sun::star::presentation::AnimationEffect_NONE :
3480 break;
3481 case ::com::sun::star::presentation::AnimationEffect_FADE_FROM_LEFT :
3483 nFlyDirection = 2;
3484 nFlyMethod = 10;
3486 break;
3487 case ::com::sun::star::presentation::AnimationEffect_FADE_FROM_TOP :
3489 nFlyDirection = 3;
3490 nFlyMethod = 10;
3492 break;
3493 case ::com::sun::star::presentation::AnimationEffect_FADE_FROM_RIGHT :
3495 nFlyDirection = 0;
3496 nFlyMethod = 10;
3498 break;
3499 case ::com::sun::star::presentation::AnimationEffect_FADE_FROM_BOTTOM :
3501 nFlyDirection = 1;
3502 nFlyMethod = 10;
3504 break;
3505 case ::com::sun::star::presentation::AnimationEffect_FADE_TO_CENTER :
3507 nFlyDirection = 1;
3508 nFlyMethod = 11;
3510 break;
3511 case ::com::sun::star::presentation::AnimationEffect_FADE_FROM_CENTER :
3513 nFlyDirection = 0;
3514 nFlyMethod = 11;
3516 break;
3517 case ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LEFT :
3519 nFlyDirection = 0;
3520 nFlyMethod = 12;
3522 break;
3523 case ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_TOP :
3525 nFlyDirection = 1;
3526 nFlyMethod = 12;
3528 break;
3529 case ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_RIGHT :
3531 nFlyDirection = 2;
3532 nFlyMethod = 12;
3534 break;
3535 case ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_BOTTOM :
3537 nFlyDirection = 3;
3538 nFlyMethod = 12;
3540 break;
3541 case ::com::sun::star::presentation::AnimationEffect_VERTICAL_STRIPES :
3543 nFlyDirection = 0;
3544 nFlyMethod = 2;
3546 break;
3547 case ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_STRIPES :
3549 nFlyDirection = 1;
3550 nFlyMethod = 2;
3552 break;
3553 case ::com::sun::star::presentation::AnimationEffect_CLOCKWISE :
3555 nFlyDirection = 1;
3556 nFlyMethod = 3;
3558 break;
3559 case ::com::sun::star::presentation::AnimationEffect_COUNTERCLOCKWISE :
3561 nFlyDirection = 0;
3562 nFlyMethod = 3;
3564 break;
3565 case ::com::sun::star::presentation::AnimationEffect_FADE_FROM_UPPERLEFT :
3567 nFlyDirection = 7;
3568 nFlyMethod = 9;
3570 break;
3571 case ::com::sun::star::presentation::AnimationEffect_FADE_FROM_UPPERRIGHT :
3573 nFlyDirection = 6;
3574 nFlyMethod = 9;
3576 break;
3577 case ::com::sun::star::presentation::AnimationEffect_FADE_FROM_LOWERLEFT :
3579 nFlyDirection = 5;
3580 nFlyMethod = 9;
3582 break;
3583 case ::com::sun::star::presentation::AnimationEffect_FADE_FROM_LOWERRIGHT :
3585 nFlyDirection = 4;
3586 nFlyMethod = 9;
3588 break;
3589 case ::com::sun::star::presentation::AnimationEffect_CLOSE_VERTICAL :
3591 nFlyDirection = 1;
3592 nFlyMethod = 13;
3594 break;
3595 case ::com::sun::star::presentation::AnimationEffect_CLOSE_HORIZONTAL :
3597 nFlyDirection = 3;
3598 nFlyMethod = 13;
3600 break;
3601 case ::com::sun::star::presentation::AnimationEffect_OPEN_VERTICAL :
3603 nFlyDirection = 0;
3604 nFlyMethod = 13;
3606 break;
3607 case ::com::sun::star::presentation::AnimationEffect_OPEN_HORIZONTAL :
3609 nFlyDirection = 2;
3610 nFlyMethod = 13;
3612 break;
3613 case ::com::sun::star::presentation::AnimationEffect_PATH :
3615 nFlyDirection = 28;
3616 nFlyMethod = 12;
3618 break;
3619 case ::com::sun::star::presentation::AnimationEffect_MOVE_TO_LEFT :
3621 nFlyDirection = 0;
3622 nFlyMethod = 1;
3624 break;
3625 case ::com::sun::star::presentation::AnimationEffect_MOVE_TO_TOP :
3627 nFlyDirection = 0;
3628 nFlyMethod = 1;
3630 break;
3631 case ::com::sun::star::presentation::AnimationEffect_MOVE_TO_RIGHT :
3633 nFlyDirection = 0;
3634 nFlyMethod = 1;
3636 break;
3637 case ::com::sun::star::presentation::AnimationEffect_MOVE_TO_BOTTOM :
3639 nFlyDirection = 0;
3640 nFlyMethod = 1;
3642 break;
3643 case ::com::sun::star::presentation::AnimationEffect_SPIRALIN_LEFT :
3644 case ::com::sun::star::presentation::AnimationEffect_SPIRALIN_RIGHT :
3645 case ::com::sun::star::presentation::AnimationEffect_SPIRALOUT_LEFT :
3646 case ::com::sun::star::presentation::AnimationEffect_SPIRALOUT_RIGHT :
3648 nFlyDirection = 0x1c;
3649 nFlyMethod = 0xc;
3651 break;
3652 case ::com::sun::star::presentation::AnimationEffect_DISSOLVE :
3654 nFlyDirection = 0;
3655 nFlyMethod = 5;
3657 break;
3658 case ::com::sun::star::presentation::AnimationEffect_WAVYLINE_FROM_LEFT :
3660 nFlyDirection = 2;
3661 nFlyMethod = 10;
3663 break;
3664 case ::com::sun::star::presentation::AnimationEffect_WAVYLINE_FROM_TOP :
3666 nFlyDirection = 3;
3667 nFlyMethod = 10;
3669 break;
3670 case ::com::sun::star::presentation::AnimationEffect_WAVYLINE_FROM_RIGHT :
3672 nFlyDirection = 0;
3673 nFlyMethod = 10;
3675 break;
3676 case ::com::sun::star::presentation::AnimationEffect_WAVYLINE_FROM_BOTTOM :
3678 nFlyDirection = 1;
3679 nFlyMethod = 10;
3681 break;
3682 case ::com::sun::star::presentation::AnimationEffect_RANDOM :
3684 nFlyDirection = 0;
3685 nFlyMethod = 1;
3687 break;
3688 case ::com::sun::star::presentation::AnimationEffect_VERTICAL_LINES :
3690 nFlyDirection = 1;
3691 nFlyMethod = 8;
3693 break;
3694 case ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_LINES :
3696 nFlyDirection = 0;
3697 nFlyMethod = 8;
3699 break;
3700 case ::com::sun::star::presentation::AnimationEffect_LASER_FROM_LEFT :
3702 nFlyDirection = 2;
3703 nFlyMethod = 10;
3705 break;
3706 case ::com::sun::star::presentation::AnimationEffect_LASER_FROM_TOP :
3708 nFlyDirection = 3;
3709 nFlyMethod = 10;
3711 break;
3712 case ::com::sun::star::presentation::AnimationEffect_LASER_FROM_RIGHT :
3714 nFlyDirection = 0;
3715 nFlyMethod = 10;
3717 break;
3718 case ::com::sun::star::presentation::AnimationEffect_LASER_FROM_BOTTOM :
3720 nFlyDirection = 1;
3721 nFlyMethod = 10;
3723 break;
3724 case ::com::sun::star::presentation::AnimationEffect_LASER_FROM_UPPERLEFT :
3726 nFlyDirection = 7;
3727 nFlyMethod = 9;
3729 break;
3730 case ::com::sun::star::presentation::AnimationEffect_LASER_FROM_UPPERRIGHT :
3732 nFlyDirection = 6;
3733 nFlyMethod = 9;
3735 break;
3736 case ::com::sun::star::presentation::AnimationEffect_LASER_FROM_LOWERLEFT :
3738 nFlyDirection = 5;
3739 nFlyMethod = 9;
3741 break;
3742 case ::com::sun::star::presentation::AnimationEffect_LASER_FROM_LOWERRIGHT :
3744 nFlyDirection = 4;
3745 nFlyMethod = 9;
3747 break;
3748 case ::com::sun::star::presentation::AnimationEffect_APPEAR :
3749 break;
3750 case ::com::sun::star::presentation::AnimationEffect_HIDE :
3752 nFlyDirection = 0;
3753 nFlyMethod = 1;
3755 break;
3756 case ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_UPPERLEFT :
3758 nFlyDirection = 4;
3759 nFlyMethod = 12;
3761 break;
3762 case ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_UPPERRIGHT :
3764 nFlyDirection = 5;
3765 nFlyMethod = 12;
3767 break;
3768 case ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LOWERRIGHT :
3770 nFlyDirection = 7;
3771 nFlyMethod = 12;
3773 break;
3774 case ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LOWERLEFT :
3776 nFlyDirection = 6;
3777 nFlyMethod = 12;
3779 break;
3780 case ::com::sun::star::presentation::AnimationEffect_MOVE_TO_UPPERLEFT :
3781 case ::com::sun::star::presentation::AnimationEffect_MOVE_TO_UPPERRIGHT :
3782 case ::com::sun::star::presentation::AnimationEffect_MOVE_TO_LOWERRIGHT :
3783 case ::com::sun::star::presentation::AnimationEffect_MOVE_TO_LOWERLEFT :
3784 nAfterEffect |= 2;
3785 break;
3786 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_LEFT :
3787 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT :
3789 nFlyDirection = 8;
3790 nFlyMethod = 12;
3792 break;
3793 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_TOP :
3794 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT :
3796 nFlyDirection = 11;
3797 nFlyMethod = 12;
3799 break;
3800 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_RIGHT :
3801 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT :
3803 nFlyDirection = 10;
3804 nFlyMethod = 12;
3806 break;
3807 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_BOTTOM :
3808 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT :
3810 nFlyDirection = 9;
3811 nFlyMethod = 12;
3813 break;
3814 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_TO_LEFT :
3815 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_TO_UPPERLEFT :
3816 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_TO_TOP :
3817 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT :
3818 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_TO_RIGHT :
3819 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT :
3820 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_TO_BOTTOM :
3821 case ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_TO_LOWERLEFT :
3822 nAfterEffect |= 2;
3823 break;
3824 case ::com::sun::star::presentation::AnimationEffect_VERTICAL_CHECKERBOARD :
3826 nFlyDirection = 1;
3827 nFlyMethod = 3;
3829 break;
3830 case ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_CHECKERBOARD :
3832 nFlyDirection = 0;
3833 nFlyMethod = 3;
3835 break;
3836 case ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_ROTATE :
3837 case ::com::sun::star::presentation::AnimationEffect_VERTICAL_ROTATE :
3839 nFlyDirection = 27;
3840 nFlyMethod = 12;
3842 break;
3843 case ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_STRETCH :
3844 case ::com::sun::star::presentation::AnimationEffect_VERTICAL_STRETCH :
3846 nFlyDirection = 22;
3847 nFlyMethod = 12;
3849 break;
3850 case ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_LEFT :
3851 case ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_UPPERLEFT :
3853 nFlyDirection = 23;
3854 nFlyMethod = 12;
3856 break;
3857 case ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_TOP :
3858 case ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_UPPERRIGHT :
3860 nFlyDirection = 24;
3861 nFlyMethod = 12;
3863 break;
3864 case ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_RIGHT :
3865 case ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_LOWERRIGHT :
3867 nFlyDirection = 25;
3868 nFlyMethod = 12;
3870 break;
3871 case ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_BOTTOM :
3872 case ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_LOWERLEFT :
3874 nFlyDirection = 26;
3875 nFlyMethod = 12;
3877 break;
3878 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN :
3880 nFlyDirection = 16;
3881 nFlyMethod = 12;
3883 break;
3884 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_SMALL :
3885 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_SPIRAL :
3887 nFlyDirection = 17;
3888 nFlyMethod = 12;
3890 break;
3891 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT :
3893 nFlyDirection = 18;
3894 nFlyMethod = 12;
3896 break;
3897 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_SMALL :
3898 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_SPIRAL :
3900 nFlyDirection = 19;
3901 nFlyMethod = 12;
3903 break;
3904 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_FROM_LEFT :
3905 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_FROM_UPPERLEFT :
3906 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_FROM_TOP :
3907 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT :
3908 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_FROM_RIGHT :
3909 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT :
3910 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_FROM_BOTTOM :
3911 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_FROM_LOWERLEFT :
3912 case ::com::sun::star::presentation::AnimationEffect_ZOOM_IN_FROM_CENTER :
3914 nFlyDirection = 16;
3915 nFlyMethod = 12;
3917 break;
3918 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_FROM_LEFT :
3919 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT :
3920 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_FROM_TOP :
3921 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT :
3922 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_FROM_RIGHT :
3923 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT :
3924 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_FROM_BOTTOM :
3925 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT :
3926 case ::com::sun::star::presentation::AnimationEffect_ZOOM_OUT_FROM_CENTER :
3927 nAfterEffect |= 2;
3928 break;
3929 default:
3930 break;
3932 if ( mnDiaMode >= 1 )
3933 nFlags |= 4;
3934 if ( eTe != ::com::sun::star::presentation::AnimationEffect_NONE )
3935 nBuildType = 2;
3936 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "SoundOn" ) ) ) )
3938 sal_Bool bBool;
3939 mAny >>= bBool;
3940 if ( bBool )
3942 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ) ) )
3944 nSoundRef = maSoundCollection.GetId( *(::rtl::OUString*)mAny.getValue() );
3945 if ( nSoundRef )
3946 nFlags |= 0x10;
3950 sal_Bool bDimHide = FALSE;
3951 sal_Bool bDimPrevious = FALSE;
3952 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "DimHide" ) ) ) )
3953 mAny >>= bDimHide;
3954 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "DimPrevious" ) ) ) )
3955 mAny >>= bDimPrevious;
3956 if ( bDimPrevious )
3957 nAfterEffect |= 1;
3958 if ( bDimHide )
3959 nAfterEffect |= 2;
3960 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "DimColor" ) ) ) )
3961 nDimColor = mpPptEscherEx->GetColor( *((sal_uInt32*)mAny.getValue()) ) | 0xfe000000;
3963 rSt << nDimColor << nFlags << nSoundRef << nDelayTime
3964 << nOrder // order of build ( 1.. )
3965 << nSlideCount << nBuildType << nFlyMethod << nFlyDirection
3966 << nAfterEffect << nSubEffect << nOleVerb
3967 << (sal_uInt16)0; // PadWord
3970 // -----------------------------------------------------------------------
3972 void PPTWriter::ImplWriteClickAction( SvStream& rSt, ::com::sun::star::presentation::ClickAction eCa, sal_Bool bMediaClickAction )
3974 sal_uInt32 nSoundRef = 0; // a reference to a sound in the sound collection, or NULL.
3975 sal_uInt32 nHyperLinkID = 0;// a persistent unique identifier to an external hyperlink object (only valid when action == HyperlinkAction).
3976 sal_uInt8 nAction = 0; // Action See Action Table
3977 sal_uInt8 nOleVerb = 0; // OleVerb Only valid when action == OLEAction. OLE verb to use, 0 = first verb, 1 = second verb, etc.
3978 sal_uInt8 nJump = 0; // Jump See Jump Table
3979 sal_uInt8 nFlags = 0; // Bit 1: Animated. If 1, then button is animated
3980 // Bit 2: Stop sound. If 1, then stop current sound when button is pressed.
3981 // Bit 3: CustomShowReturn. If 1, and this is a jump to custom show, then return to this slide after custom show.
3982 sal_uInt8 nHyperLinkType = 0;// HyperlinkType a value from the LinkTo enum, such as LT_URL (only valid when action == HyperlinkAction).
3984 String aFile;
3987 Action Table: Action Value
3988 NoAction 0
3989 MacroAction 1
3990 RunProgramAction 2
3991 JumpAction 3
3992 HyperlinkAction 4
3993 OLEAction 5
3994 MediaAction 6
3995 CustomShowAction 7
3997 Jump Table: Jump Value
3998 NoJump 0
3999 NextSlide, 1
4000 PreviousSlide, 2
4001 FirstSlide, 3
4002 LastSlide, 4
4003 LastSlideViewed 5
4004 EndShow 6
4007 if ( bMediaClickAction )
4008 nAction = 6;
4009 else switch( eCa )
4011 case ::com::sun::star::presentation::ClickAction_STOPPRESENTATION :
4012 nJump += 2;
4013 case ::com::sun::star::presentation::ClickAction_LASTPAGE :
4014 nJump++;
4015 case ::com::sun::star::presentation::ClickAction_FIRSTPAGE :
4016 nJump++;
4017 case ::com::sun::star::presentation::ClickAction_PREVPAGE :
4018 nJump++;
4019 case ::com::sun::star::presentation::ClickAction_NEXTPAGE :
4021 nJump++;
4022 nAction = 3;
4024 break;
4025 case ::com::sun::star::presentation::ClickAction_SOUND :
4027 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) ) ) )
4028 nSoundRef = maSoundCollection.GetId( *(::rtl::OUString*)mAny.getValue() );
4030 break;
4031 case ::com::sun::star::presentation::ClickAction_PROGRAM :
4033 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) ) ) )
4035 INetURLObject aUrl( *(::rtl::OUString*)mAny.getValue() );
4036 if ( INET_PROT_FILE == aUrl.GetProtocol() )
4038 aFile = aUrl.PathToFileName();
4039 nAction = 2;
4043 break;
4045 case ::com::sun::star::presentation::ClickAction_BOOKMARK :
4047 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) ) ) )
4049 String aBookmark( *(::rtl::OUString*)mAny.getValue() );
4050 sal_uInt32 nIndex = 0;
4051 for ( String* pStr = (String*)maSlideNameList.First(); pStr; pStr = (String*)maSlideNameList.Next(), nIndex++ )
4053 if ( *pStr == aBookmark )
4055 // Bookmark ist ein link zu einer Dokumentseite
4056 nAction = 4;
4057 nHyperLinkType = 7;
4059 String aEmpty;
4060 String aHyperString = UniString::CreateFromInt32( 256 + nIndex );
4061 aHyperString.Append( String( RTL_CONSTASCII_USTRINGPARAM( "," ) ) );
4062 aHyperString.Append( String::CreateFromInt32( nIndex + 1 ) );
4063 aHyperString.Append( String( RTL_CONSTASCII_USTRINGPARAM( ",Slide " ) ) );
4064 aHyperString.Append( String::CreateFromInt32( nIndex + 1 ) );
4065 nHyperLinkID = ImplInsertBookmarkURL( aHyperString, 1 | ( nIndex << 8 ) | ( 1 << 31 ), aBookmark, aEmpty, aEmpty, aHyperString );
4070 break;
4072 case ::com::sun::star::presentation::ClickAction_DOCUMENT :
4074 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) ) ) )
4076 String aBookmark( *(::rtl::OUString*)mAny.getValue() );
4077 if ( aBookmark.Len() )
4079 nAction = 4;
4080 nHyperLinkType = 8;
4082 String aEmpty;
4083 String aBookmarkFile( aBookmark );
4084 INetURLObject aUrl( aBookmark );
4085 if ( INET_PROT_FILE == aUrl.GetProtocol() )
4086 aBookmarkFile = aUrl.PathToFileName();
4087 nHyperLinkID = ImplInsertBookmarkURL( aBookmark, (sal_uInt32)(2 | ( 1 << 31 )), aBookmarkFile, aBookmark, aEmpty, aEmpty );
4091 break;
4093 case ::com::sun::star::presentation::ClickAction_INVISIBLE :
4094 case ::com::sun::star::presentation::ClickAction_VERB :
4095 case ::com::sun::star::presentation::ClickAction_VANISH :
4096 case ::com::sun::star::presentation::ClickAction_MACRO :
4097 default :
4098 break;
4101 sal_uInt32 nContainerSize = 24;
4102 if ( nAction == 2 )
4103 nContainerSize += ( aFile.Len() * 2 ) + 8;
4104 rSt << (sal_uInt32)( ( EPP_InteractiveInfo << 16 ) | 0xf ) << (sal_uInt32)nContainerSize
4105 << (sal_uInt32)( EPP_InteractiveInfoAtom << 16 ) << (sal_uInt32)16
4106 << nSoundRef
4107 << nHyperLinkID
4108 << nAction
4109 << nOleVerb
4110 << nJump
4111 << nFlags
4112 << (sal_uInt32)nHyperLinkType;
4114 if ( nAction == 2 ) // run program Action
4116 sal_uInt16 i, nLen = aFile.Len();
4117 rSt << (sal_uInt32)( ( EPP_CString << 16 ) | 0x20 ) << (sal_uInt32)( nLen * 2 );
4118 for ( i = 0; i < nLen; i++ )
4119 rSt << aFile.GetChar( i );
4122 rSt << (sal_uInt32)( ( EPP_InteractiveInfo << 16 ) | 0x1f ) << (sal_uInt32)24 // Mouse Over Action
4123 << (sal_uInt32)( EPP_InteractiveInfo << 16 ) << (sal_uInt32)16;
4124 for ( int i = 0; i < 4; i++, rSt << (sal_uInt32)0 ) ;
4127 // -----------------------------------------------------------------------
4129 sal_Bool PPTWriter::ImplGetEffect( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPropSet,
4130 ::com::sun::star::presentation::AnimationEffect& eEffect,
4131 ::com::sun::star::presentation::AnimationEffect& eTextEffect,
4132 sal_Bool& bIsSound )
4134 ::com::sun::star::uno::Any aAny;
4135 if ( GetPropertyValue( aAny, rPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Effect" ) ) ) )
4136 aAny >>= eEffect;
4137 else
4138 eEffect = ::com::sun::star::presentation::AnimationEffect_NONE;
4140 if ( GetPropertyValue( aAny, rPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextEffect" ) ) ) )
4141 aAny >>= eTextEffect;
4142 else
4143 eTextEffect = ::com::sun::star::presentation::AnimationEffect_NONE;
4144 if ( GetPropertyValue( aAny, rPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "SoundOn" ) ) ) )
4145 aAny >>= bIsSound;
4146 else
4147 bIsSound = FALSE;
4149 sal_Bool bHasEffect = ( ( eEffect != ::com::sun::star::presentation::AnimationEffect_NONE )
4150 || ( eTextEffect != ::com::sun::star::presentation::AnimationEffect_NONE )
4151 || bIsSound );
4152 return bHasEffect;
4155 // -----------------------------------------------------------------------
4157 sal_Bool PPTWriter::ImplCreatePresentationPlaceholder( const sal_Bool bMasterPage, const PageType /* ePageType */,
4158 const sal_uInt32 nStyleInstance, const sal_uInt8 nPlaceHolderId )
4160 sal_Bool bRet = ImplGetText();
4161 if ( bRet && bMasterPage )
4163 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4164 sal_uInt32 nPresShapeID = mpPptEscherEx->GetShapeID();
4165 mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xa00, nPresShapeID );// Flags: HaveAnchor | HasSpt
4166 EscherPropertyContainer aPropOpt;
4167 aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x50001 );
4168 aPropOpt.AddOpt( ESCHER_Prop_lTxid, mnTxId += 0x60 );
4169 aPropOpt.AddOpt( ESCHER_Prop_AnchorText, ESCHER_AnchorMiddle );
4170 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x110001 );
4171 aPropOpt.AddOpt( ESCHER_Prop_lineColor, 0x8000001 );
4172 aPropOpt.AddOpt( ESCHER_Prop_shadowColor, 0x8000002 );
4173 aPropOpt.CreateFillProperties( mXPropSet, sal_True );
4174 sal_uInt32 nLineFlags = 0x90001;
4175 if ( aPropOpt.GetOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags ) )
4176 nLineFlags |= 0x10001; // draw dashed line if no line
4177 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags );
4179 SvMemoryStream aExtBu( 0x200, 0x200 );
4180 SvMemoryStream aClientTextBox( 0x200, 0x200 );
4181 ImplWriteTextStyleAtom( aClientTextBox, nStyleInstance, 0, NULL, aExtBu, &aPropOpt );
4183 aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_True );
4184 aPropOpt.Commit( *mpStrm );
4185 mpPptEscherEx->AddAtom( 8, ESCHER_ClientAnchor );
4186 *mpStrm << (sal_Int16)maRect.Top() << (sal_Int16)maRect.Left() << (sal_Int16)maRect.Right() << (sal_Int16)maRect.Bottom(); // oben, links, rechts, unten ????
4187 mpPptEscherEx->OpenContainer( ESCHER_ClientData );
4188 mpPptEscherEx->AddAtom( 8, EPP_OEPlaceholderAtom );
4189 *mpStrm << (sal_uInt32)0 // PlacementID
4190 << (sal_uInt8)nPlaceHolderId // PlaceHolderID
4191 << (sal_uInt8)0 // Size of PlaceHolder ( 0 = FULL, 1 = HALF, 2 = QUARTER )
4192 << (sal_uInt16)0; // padword
4193 mpPptEscherEx->CloseContainer(); // ESCHER_ClientData
4195 if ( aExtBu.Tell() )
4197 if ( !pClientData )
4198 pClientData = new SvMemoryStream( 0x200, 0x200 );
4199 ImplProgTagContainer( pClientData, &aExtBu );
4202 if ( aClientTextBox.Tell() )
4204 *mpStrm << (sal_uInt32)( ( ESCHER_ClientTextbox << 16 ) | 0xf )
4205 << (sal_uInt32)aClientTextBox.Tell();
4207 mpStrm->Write( aClientTextBox.GetData(), aClientTextBox.Tell() );
4209 mpPptEscherEx->CloseContainer(); // ESCHER_SpContainer
4211 else
4212 bRet = sal_False;
4213 return bRet;
4216 // -----------------------------------------------------------------------
4218 void PPTWriter::ImplCreateShape( sal_uInt32 nType, sal_uInt32 nFlags, EscherSolverContainer& rSolver )
4220 sal_uInt32 nId = mpPptEscherEx->GetShapeID();
4221 mpPptEscherEx->AddShape( nType, nFlags, nId );
4222 rSolver.AddShape( mXShape, nId );
4225 void PPTWriter::ImplCreateTextShape( EscherPropertyContainer& rPropOpt, EscherSolverContainer& rSolver, sal_Bool bFill )
4227 mnTextStyle = EPP_TEXTSTYLE_TEXT;
4228 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4229 ImplCreateShape( ESCHER_ShpInst_TextBox, 0xa00, rSolver );
4230 if ( bFill )
4231 rPropOpt.CreateFillProperties( mXPropSet, sal_True );
4232 if ( ImplGetText() )
4233 rPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_True );
4236 void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& aSolverContainer, PageType ePageType, sal_Bool bMasterPage, int nPageNumber )
4238 sal_uInt32 nInstance, nGroups, nShapes, nShapeCount, nPer, nLastPer, nIndices, nGroupLevel = 0, nOlePictureId;
4239 sal_uInt16 nEffectCount;
4240 ::com::sun::star::awt::Point aTextRefPoint;
4242 ResetGroupTable( nShapes = mXShapes->getCount() );
4244 nIndices = nInstance = nLastPer = nShapeCount = nEffectCount = 0;
4246 sal_Bool bIsTitlePossible = TRUE; // bei mehr als einem title geht powerpoint in die knie
4248 sal_uInt32 nOutlinerCount = 0; // die gliederungsobjekte muessen dem layout entsprechen,
4249 sal_uInt32 nPrevTextStyle = 0; // es darf nicht mehr als zwei geben
4251 nOlePictureId = 0;
4253 sal_Bool bAdditionalText = FALSE;
4255 SvMemoryStream* pClientTextBox = NULL;
4256 SvMemoryStream* pClientData = NULL;
4258 while( GetNextGroupEntry() )
4260 nShapeCount++;
4262 nPer = ( 5 * nShapeCount ) / nShapes;
4263 if ( nPer != nLastPer )
4265 nLastPer = nPer;
4266 sal_uInt32 nValue = mnPagesWritten * 5 + nPer;
4267 if ( nValue > mnStatMaxValue )
4268 nValue = mnStatMaxValue;
4269 if ( mbStatusIndicator && ( nValue > mnLatestStatValue ) )
4271 mXStatusIndicator->setValue( nValue );
4272 mnLatestStatValue = nValue;
4275 nGroups = GetGroupsClosed();
4276 for ( sal_uInt32 i = 0; i < nGroups; i++, mpPptEscherEx->LeaveGroup() ) ;
4278 if ( ImplGetShapeByIndex( GetCurrentGroupIndex(), TRUE ) )
4280 sal_Bool bIsSound;
4281 sal_Bool bMediaClickAction = sal_False;
4282 ::com::sun::star::presentation::AnimationEffect eAe;
4283 ::com::sun::star::presentation::AnimationEffect eTe;
4285 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "PresentationOrder" ) ) ) )
4286 nEffectCount = *(sal_uInt16*)mAny.getValue();
4288 sal_Bool bEffect = ImplGetEffect( mXPropSet, eAe, eTe, bIsSound );
4289 ::com::sun::star::presentation::ClickAction eCa = ::com::sun::star::presentation::ClickAction_NONE;
4290 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ) ) )
4291 mAny >>= eCa;
4293 sal_Bool bGroup = mType == "drawing.Group";
4294 sal_Bool bOpenBezier = mType == "drawing.OpenBezier";
4295 sal_Bool bClosedBezier = mType == "drawing.ClosedBezier";
4296 sal_Bool bPolyPolygon = mType == "drawing.PolyPolygon";
4297 sal_Bool bPolyLine = mType == "drawing.PolyLine";
4299 List aAdjustmentList;
4300 Rectangle aPolyBoundRect;
4302 const ::com::sun::star::awt::Size aSize100thmm( mXShape->getSize() );
4303 const ::com::sun::star::awt::Point aPoint100thmm( mXShape->getPosition() );
4304 Rectangle aRect100thmm( Point( aPoint100thmm.X, aPoint100thmm.Y ), Size( aSize100thmm.Width, aSize100thmm.Height ) );
4305 EscherPropertyContainer aPropOpt( (EscherGraphicProvider&)*mpPptEscherEx, mpPicStrm, aRect100thmm );
4307 if ( bGroup )
4309 SvMemoryStream* pTmp = NULL;
4310 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >
4311 aXIndexAccess( mXShape, ::com::sun::star::uno::UNO_QUERY );
4312 if ( EnterGroup( aXIndexAccess ) )
4314 if ( bEffect && !mbUseNewAnimations )
4316 pTmp = new SvMemoryStream( 0x200, 0x200 );
4317 ImplWriteObjectEffect( *pTmp, eAe, eTe, ++nEffectCount );
4319 if ( eCa != ::com::sun::star::presentation::ClickAction_NONE )
4321 if ( !pTmp )
4322 pTmp = new SvMemoryStream( 0x200, 0x200 );
4323 ImplWriteClickAction( *pTmp, eCa, bMediaClickAction );
4325 sal_uInt32 nShapeId = mpPptEscherEx->EnterGroup( &maRect, pTmp );
4326 aSolverContainer.AddShape( mXShape, nShapeId );
4327 delete pTmp;
4330 else
4332 sal_Bool bIsFontwork = sal_False;
4333 sal_Bool bIsHatching = sal_False;
4334 ::com::sun::star::uno::Any aAny;
4335 ::com::sun::star::drawing::FillStyle eFS;
4336 if ( GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsFontwork" ) ), sal_True ) )
4337 aAny >>= bIsFontwork;
4338 if ( GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ), sal_True ) )
4340 aAny >>= eFS;
4341 bIsHatching = eFS == ::com::sun::star::drawing::FillStyle_HATCH;
4343 if ( bIsHatching || bIsFontwork || ( mType == "drawing.Measure" ) || ( mType == "drawing.Caption" ) )
4345 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "BoundRect" ) ) ) )
4347 ::com::sun::star::awt::Rectangle aRect( *(::com::sun::star::awt::Rectangle*)mAny.getValue() );
4348 maPosition = ImplMapPoint( ::com::sun::star::awt::Point( aRect.X, aRect.Y ) );
4349 maSize = ImplMapSize( ::com::sun::star::awt::Size( aRect.Width, aRect.Height ) );
4350 maRect = Rectangle( Point( maPosition.X, maPosition.Y ), Size( maSize.Width, maSize.Height ) );
4352 mType = "drawing.dontknow";
4355 sal_uInt8 nPlaceHolderAtom = EPP_PLACEHOLDER_NONE;
4357 mnTextSize = 0;
4358 mnTextStyle = EPP_TEXTSTYLE_NORMAL;
4360 if ( mType == "drawing.Custom" )
4362 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4363 sal_uInt32 nMirrorFlags;
4364 rtl::OUString sCustomShapeType;
4365 MSO_SPT eShapeType = aPropOpt.GetCustomShapeType( mXShape, nMirrorFlags, sCustomShapeType );
4366 if ( sCustomShapeType.equalsAscii( "col-502ad400" ) || sCustomShapeType.equalsAscii( "col-60da8460" ) )
4367 { // sj: creating metafile for customshapes that can't be saved to ms format properly
4368 ImplCreateShape( ESCHER_ShpInst_PictureFrame, 0xa00, aSolverContainer );
4369 if ( aPropOpt.CreateGraphicProperties( mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "MetaFile" ) ), sal_False ) )
4371 aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 );
4372 SdrObject* pObj = GetSdrObjectFromXShape( mXShape );
4373 if ( pObj )
4375 Rectangle aBound = pObj->GetCurrentBoundRect();
4376 maPosition = ImplMapPoint( ::com::sun::star::awt::Point( aBound.Left(), aBound.Top() ) );
4377 maSize = ImplMapSize( ::com::sun::star::awt::Size ( aBound.GetWidth(), aBound.GetHeight() ) );
4378 maRect = Rectangle( Point( maPosition.X, maPosition.Y ), Size( maSize.Width, maSize.Height ) );
4379 mnAngle = 0;
4383 else
4385 ImplCreateShape( eShapeType, nMirrorFlags | 0xa00, aSolverContainer );
4386 aPropOpt.CreateCustomShapeProperties( eShapeType, mXShape );
4387 aPropOpt.CreateFillProperties( mXPropSet, sal_True );
4388 if ( ImplGetText() )
4390 if ( !aPropOpt.IsFontWork() )
4391 aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_True, sal_True );
4395 else if ( mType == "drawing.Rectangle" )
4397 sal_Int32 nRadius = 0;
4398 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4399 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CornerRadius" ) ) ) )
4401 mAny >>= nRadius;
4402 nRadius = ImplMapSize( ::com::sun::star::awt::Size( nRadius, 0 ) ).Width;
4404 if ( nRadius )
4406 ImplCreateShape( ESCHER_ShpInst_RoundRectangle, 0xa00, aSolverContainer ); // Flags: Connector | HasSpt
4407 sal_Int32 nLenght = maRect.GetWidth();
4408 if ( nLenght > maRect.GetHeight() )
4409 nLenght = maRect.GetHeight();
4410 nLenght >>= 1;
4411 if ( nRadius >= nLenght )
4412 nRadius = 0x2a30; // 0x2a30 ist PPTs maximum radius
4413 else
4414 nRadius = ( 0x2a30 * nRadius ) / nLenght;
4415 aPropOpt.AddOpt( ESCHER_Prop_adjustValue, nRadius );
4417 else
4419 ImplCreateShape( ESCHER_ShpInst_Rectangle, 0xa00, aSolverContainer ); // Flags: Connector | HasSpt
4421 aPropOpt.CreateFillProperties( mXPropSet, sal_True );
4422 if ( ImplGetText() )
4423 aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_False );
4425 else if ( mType == "drawing.Ellipse" )
4427 ::com::sun::star::drawing::CircleKind eCircleKind( ::com::sun::star::drawing::CircleKind_FULL );
4428 PolyStyle ePolyKind = POLY_CHORD;
4429 if ( ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CircleKind" ) ) ) )
4431 mAny >>= eCircleKind;
4432 switch ( eCircleKind )
4434 case ::com::sun::star::drawing::CircleKind_SECTION :
4436 ePolyKind = POLY_PIE;
4438 break;
4439 case ::com::sun::star::drawing::CircleKind_ARC :
4441 ePolyKind = POLY_ARC;
4443 break;
4445 case ::com::sun::star::drawing::CircleKind_CUT :
4447 ePolyKind = POLY_CHORD;
4449 break;
4451 default:
4452 eCircleKind = ::com::sun::star::drawing::CircleKind_FULL;
4455 if ( eCircleKind == ::com::sun::star::drawing::CircleKind_FULL )
4457 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4458 ImplCreateShape( ESCHER_ShpInst_Ellipse, 0xa00, aSolverContainer ); // Flags: Connector | HasSpt
4459 aPropOpt.CreateFillProperties( mXPropSet, sal_True );
4460 if ( ImplGetText() )
4461 aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_False );
4463 else
4465 sal_Int32 nStartAngle, nEndAngle;
4466 if ( !ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CircleStartAngle" ) ) ) )
4467 continue;
4468 nStartAngle = *( (sal_Int32*)mAny.getValue() );
4469 if( !ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "CircleEndAngle" ) ) ) )
4470 continue;
4471 nEndAngle = *( (sal_Int32*)mAny.getValue() );
4472 ::com::sun::star::awt::Point aPoint( mXShape->getPosition() );
4473 ::com::sun::star::awt::Size aSize( mXShape->getSize() );
4474 ::com::sun::star::awt::Point aStart, aEnd, aCenter;
4475 Rectangle aRect( Point( aPoint.X, aPoint.Y ), Size( aSize.Width, aSize.Height ) );
4476 aStart.X = (sal_Int32)( ( cos( (double)( nStartAngle * F_PI18000 ) ) * 100.0 ) );
4477 aStart.Y = - (sal_Int32)( ( sin( (double)( nStartAngle * F_PI18000 ) ) * 100.0 ) );
4478 aEnd.X = (sal_Int32)( ( cos( (double)( nEndAngle * F_PI18000 ) ) * 100.0 ) );
4479 aEnd.Y = - (sal_Int32)( ( sin( (double)( nEndAngle * F_PI18000 ) ) * 100.0 ) );
4480 aCenter.X = aPoint.X + ( aSize.Width / 2 );
4481 aCenter.Y = aPoint.Y + ( aSize.Height / 2 );
4482 aStart.X += aCenter.X;
4483 aStart.Y += aCenter.Y;
4484 aEnd.X += aCenter.X;
4485 aEnd.Y += aCenter.Y;
4486 Polygon aPolygon( aRect, Point( aStart.X, aStart.Y ), Point( aEnd.X, aEnd.Y ), ePolyKind );
4487 sal_Bool bNeedText = sal_True;
4488 if ( mnAngle )
4490 aPolygon.Rotate( aRect.TopLeft(), (sal_uInt16)( mnAngle / 10 ) );
4491 if ( ImplGetText() )
4493 mpPptEscherEx->EnterGroup( 0,0 );
4494 nGroupLevel = mpPptEscherEx->GetGroupLevel();
4495 bNeedText = sal_False;
4496 bAdditionalText = TRUE;
4497 mnTextSize = 0;
4499 mnAngle = 0;
4501 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4502 ImplCreateShape( ESCHER_ShpInst_NotPrimitive, 0xa00, aSolverContainer ); // Flags: Connector | HasSpt
4503 ::com::sun::star::awt::Rectangle aNewRect;
4504 switch ( ePolyKind )
4506 case POLY_PIE :
4507 case POLY_CHORD :
4509 if ( aPropOpt.CreatePolygonProperties( mXPropSet, ESCHER_CREATEPOLYGON_POLYPOLYGON, sal_False, aNewRect, &aPolygon ) )
4510 aPropOpt.CreateFillProperties( mXPropSet, sal_True );
4512 break;
4514 case POLY_ARC :
4516 if ( aPropOpt.CreatePolygonProperties( mXPropSet, ESCHER_CREATEPOLYGON_POLYLINE, sal_False, aNewRect, &aPolygon ) )
4517 aPropOpt.CreateLineProperties( mXPropSet, sal_False );
4519 break;
4521 maRect = ImplMapRectangle( aNewRect );
4522 maPosition = ::com::sun::star::awt::Point( maRect.Left(), maRect.Top() );
4523 maSize = ::com::sun::star::awt::Size( maRect.GetWidth(), maRect.GetHeight() );
4524 if ( bNeedText && ImplGetText() )
4525 aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_False );
4528 else if ( mType == "drawing.Control" )
4530 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XControlShape >
4531 aXControlShape( mXShape, ::com::sun::star::uno::UNO_QUERY );
4532 if ( !aXControlShape.is() )
4533 continue;
4534 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
4535 aXControlModel( aXControlShape->getControl() );
4536 if ( !aXControlModel.is() )
4537 continue;
4539 sal_Int64 nAspect = ::com::sun::star::embed::Aspects::MSOLE_CONTENT;
4542 // try to get the aspect when available
4543 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
4544 xShapeProps( mXShape, ::com::sun::star::uno::UNO_QUERY_THROW );
4545 xShapeProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Aspect" ) ) ) >>= nAspect;
4547 catch( ::com::sun::star::uno::Exception& )
4550 *mpExEmbed << (sal_uInt32)( 0xf | ( EPP_ExControl << 16 ) )
4551 << (sal_uInt32)0; // Size of this container
4553 sal_uInt32 nSize, nOldPos = mpExEmbed->Tell();
4555 sal_uInt32 nPageId = nPageNumber;
4556 if ( ePageType == MASTER )
4557 nPageId |= 0x80000000;
4558 else
4559 nPageId += 0x100;
4560 *mpExEmbed << (sal_uInt32)( EPP_ExControlAtom << 16 )
4561 << (sal_uInt32)4
4562 << nPageId;
4563 PPTExOleObjEntry* pEntry = new PPTExOleObjEntry( OCX_CONTROL, mpExEmbed->Tell() );
4564 pEntry->xControlModel = aXControlModel;
4565 maExOleObj.Insert( pEntry );
4567 mnExEmbed++;
4569 *mpExEmbed << (sal_uInt32)( 1 | ( EPP_ExOleObjAtom << 16 ) )
4570 << (sal_uInt32)24
4571 << (sal_uInt32)nAspect
4572 << (sal_uInt32)2
4573 << (sal_uInt32)mnExEmbed
4574 << (sal_uInt32)0
4575 << (sal_uInt32)4 // index to the persist table
4576 << (sal_uInt32)0x0012de00;
4579 ::com::sun::star::awt::Size aSize;
4580 String aControlName;
4581 SvStorageRef xTemp( new SvStorage( new SvMemoryStream(), TRUE ) );
4582 if ( SvxMSConvertOCXControls::WriteOCXStream( xTemp, aXControlModel, aSize, aControlName ) )
4584 String aUserName( xTemp->GetUserName() );
4585 String aOleIdentifier;
4586 if ( aUserName.Len() )
4588 SvStorageStreamRef xCompObj = xTemp->OpenSotStream(
4589 String( RTL_CONSTASCII_USTRINGPARAM( "\1CompObj" ) ),
4590 STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYALL );
4591 xCompObj->Seek( STREAM_SEEK_TO_END );
4592 sal_uInt32 nStreamLen = xCompObj->Tell();
4593 xCompObj->Seek( 0 );
4594 sal_Int16 nVersion, nByteOrder;
4595 sal_Int32 nWinVersion, nVal, nStringLen;
4596 *xCompObj >> nVersion
4597 >> nByteOrder
4598 >> nWinVersion
4599 >> nVal;
4600 xCompObj->SeekRel( 16 ); // skipping clsid
4601 *xCompObj >> nStringLen;
4602 if ( ( xCompObj->Tell() + nStringLen ) < nStreamLen )
4604 xCompObj->SeekRel( nStringLen ); // now skipping the UserName;
4605 *xCompObj >> nStringLen;
4606 if ( ( xCompObj->Tell() + nStringLen ) < nStreamLen )
4608 xCompObj->SeekRel( nStringLen ); // now skipping the clipboard formatname
4609 *xCompObj >> nStringLen;
4610 if ( ( nStringLen > 1 ) && ( ( xCompObj->Tell() + nStringLen ) < nStreamLen ) )
4611 { // i think that the OleIdentifier will follow
4612 ByteString aTemp;
4613 sal_Char* p = aTemp.AllocBuffer( (USHORT)(nStringLen - 1) );
4614 xCompObj->Read( p, nStringLen - 1 );
4615 aOleIdentifier = String( aTemp, gsl_getSystemTextEncoding() );
4620 if ( aControlName.Len() )
4621 PPTWriter::WriteCString( *mpExEmbed, aControlName, 1 );
4622 if ( aOleIdentifier.Len() )
4623 PPTWriter::WriteCString( *mpExEmbed, aOleIdentifier, 2 );
4624 if ( aUserName.Len() )
4625 PPTWriter::WriteCString( *mpExEmbed, aUserName, 3 );
4627 nSize = mpExEmbed->Tell() - nOldPos;
4628 mpExEmbed->Seek( nOldPos - 4 );
4629 *mpExEmbed << nSize;
4630 mpExEmbed->Seek( STREAM_SEEK_TO_END );
4631 nOlePictureId = mnExEmbed;
4633 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4634 sal_uInt32 nSpFlags = SHAPEFLAG_HAVESPT | SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_OLESHAPE;
4635 ImplCreateShape( ESCHER_ShpInst_HostControl, nSpFlags, aSolverContainer );
4636 if ( aPropOpt.CreateGraphicProperties( mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "MetaFile" ) ), sal_False ) )
4637 aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 );
4638 aPropOpt.AddOpt( ESCHER_Prop_pictureId, mnExEmbed );
4639 aPropOpt.AddOpt( ESCHER_Prop_pictureActive, 0x10000 );
4641 if ( aControlName.Len() )
4643 sal_uInt16 i, nBufSize;
4644 nBufSize = ( aControlName.Len() + 1 ) << 1;
4645 sal_uInt8* pBuf = new sal_uInt8[ nBufSize ];
4646 sal_uInt8* pTmp = pBuf;
4647 for ( i = 0; i < aControlName.Len(); i++ )
4649 sal_Unicode nUnicode = aControlName.GetChar( i );
4650 *pTmp++ = (sal_uInt8)nUnicode;
4651 *pTmp++ = (sal_uInt8)( nUnicode >> 8 );
4653 *pTmp++ = 0;
4654 *pTmp = 0;
4655 aPropOpt.AddOpt( ESCHER_Prop_wzName, TRUE, nBufSize, pBuf, nBufSize );
4658 else if ( mType == "drawing.Connector" )
4660 sal_uInt16 nSpType, nSpFlags;
4661 ::com::sun::star::awt::Rectangle aNewRect;
4662 if ( aPropOpt.CreateConnectorProperties( mXShape, aSolverContainer, aNewRect, nSpType, nSpFlags ) == sal_False )
4663 continue;
4665 maRect = ImplMapRectangle( aNewRect );
4666 maPosition = ::com::sun::star::awt::Point( maRect.Left(), maRect.Top() );
4667 maSize = ::com::sun::star::awt::Size( maRect.GetWidth(), maRect.GetHeight() );
4669 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4670 ImplCreateShape( nSpType, nSpFlags, aSolverContainer );
4672 else if ( mType == "drawing.Measure" )
4674 continue;
4676 else if ( mType == "drawing.Line" )
4678 ::com::sun::star::awt::Rectangle aNewRect;
4679 aPropOpt.CreatePolygonProperties( mXPropSet, ESCHER_CREATEPOLYGON_LINE, sal_False, aNewRect, NULL );
4680 maRect = ImplMapRectangle( aNewRect );
4681 maPosition = ::com::sun::star::awt::Point( maRect.Left(), maRect.Top() );
4682 maSize = ::com::sun::star::awt::Size( maRect.GetWidth(), maRect.GetHeight() );
4683 if ( ImplGetText() )
4685 aTextRefPoint = ::com::sun::star::awt::Point( maRect.Left(), maRect.Top() );
4686 mnTextSize = 0;
4687 bAdditionalText = TRUE;
4688 mpPptEscherEx->EnterGroup( &maRect,0 );
4690 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4691 sal_uInt32 nFlags = 0xa00; // Flags: Connector | HasSpt
4692 if ( maRect.Top() > maRect.Bottom() )
4693 nFlags |= 0x80; // Flags: VertMirror
4694 if ( maRect.Left() > maRect.Right() )
4695 nFlags |= 0x40; // Flags: HorzMirror
4697 ImplCreateShape( ESCHER_ShpInst_Line, nFlags, aSolverContainer );
4698 aPropOpt.AddOpt( ESCHER_Prop_shapePath, ESCHER_ShapeComplex );
4699 aPropOpt.CreateLineProperties( mXPropSet, sal_False );
4700 mnAngle = 0;
4702 else if ( bPolyPolygon )
4704 if ( ImplGetText() )
4706 mpPptEscherEx->EnterGroup( 0,0 );
4707 nGroupLevel = mpPptEscherEx->GetGroupLevel();
4708 bAdditionalText = TRUE;
4709 mnTextSize = 0;
4711 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4712 ImplCreateShape( ESCHER_ShpInst_NotPrimitive, 0xa00, aSolverContainer ); // Flags: Connector | HasSpt
4713 ::com::sun::star::awt::Rectangle aNewRect;
4714 aPropOpt.CreatePolygonProperties( mXPropSet, ESCHER_CREATEPOLYGON_POLYPOLYGON, sal_False, aNewRect, NULL );
4715 maRect = ImplMapRectangle( aNewRect );
4716 maPosition = ::com::sun::star::awt::Point( maRect.Left(), maRect.Top() );
4717 maSize = ::com::sun::star::awt::Size( maRect.GetWidth(), maRect.GetHeight() );
4718 aPropOpt.CreateFillProperties( mXPropSet, sal_True );
4719 mnAngle = 0;
4721 else if ( bPolyLine )
4723 if ( ImplGetText() )
4725 mpPptEscherEx->EnterGroup( 0,0 );
4726 nGroupLevel = mpPptEscherEx->GetGroupLevel();
4727 bAdditionalText = TRUE;
4728 mnTextSize = 0;
4730 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4731 ImplCreateShape( ESCHER_ShpInst_NotPrimitive, 0xa00, aSolverContainer ); // Flags: Connector | HasSpt
4732 ::com::sun::star::awt::Rectangle aNewRect;
4733 aPropOpt.CreatePolygonProperties( mXPropSet, ESCHER_CREATEPOLYGON_POLYLINE, sal_False, aNewRect, NULL );
4734 maRect = ImplMapRectangle( aNewRect );
4735 maPosition = ::com::sun::star::awt::Point( maRect.Left(), maRect.Top() );
4736 maSize = ::com::sun::star::awt::Size( maRect.GetWidth(), maRect.GetHeight() );
4737 aPropOpt.CreateLineProperties( mXPropSet, sal_False );
4738 mnAngle = 0;
4740 else if ( bOpenBezier )
4742 if ( ImplGetText() )
4744 mpPptEscherEx->EnterGroup( 0,0 );
4745 nGroupLevel = mpPptEscherEx->GetGroupLevel();
4746 bAdditionalText = TRUE;
4747 mnTextSize = 0;
4749 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4750 ImplCreateShape( ESCHER_ShpInst_NotPrimitive, 0xa00, aSolverContainer ); // Flags: Connector | HasSpt
4751 ::com::sun::star::awt::Rectangle aNewRect;
4752 aPropOpt.CreatePolygonProperties( mXPropSet, ESCHER_CREATEPOLYGON_POLYLINE, sal_True, aNewRect, NULL );
4753 maRect = ImplMapRectangle( aNewRect );
4754 maPosition = ::com::sun::star::awt::Point( maRect.Left(), maRect.Top() );
4755 maSize = ::com::sun::star::awt::Size( maRect.GetWidth(), maRect.GetHeight() );
4756 aPropOpt.CreateLineProperties( mXPropSet, sal_False );
4757 mnAngle = 0;
4759 else if ( bClosedBezier )
4761 if ( ImplGetText() )
4763 mpPptEscherEx->EnterGroup( 0,0 );
4764 nGroupLevel = mpPptEscherEx->GetGroupLevel();
4765 bAdditionalText = TRUE;
4766 mnTextSize = 0;
4768 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4769 ImplCreateShape( ESCHER_ShpInst_NotPrimitive, 0xa00, aSolverContainer ); // Flags: Connector | HasSpt
4770 ::com::sun::star::awt::Rectangle aNewRect;
4771 aPropOpt.CreatePolygonProperties( mXPropSet, ESCHER_CREATEPOLYGON_POLYPOLYGON, sal_True, aNewRect, NULL );
4772 maRect = ImplMapRectangle( aNewRect );
4773 maPosition = ::com::sun::star::awt::Point( maRect.Left(), maRect.Top() );
4774 maSize = ::com::sun::star::awt::Size( maRect.GetWidth(), maRect.GetHeight() );
4775 aPropOpt.CreateFillProperties( mXPropSet, sal_True );
4776 mnAngle = 0;
4778 else if ( ( mType == "drawing.GraphicObject" ) || ( mType == "presentation.GraphicObject" ) )
4780 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4782 // ein GraphicObject kann auch ein ClickMe Element sein
4783 if ( mbEmptyPresObj && ( ePageType == NORMAL ) )
4785 nPlaceHolderAtom = rLayout.nUsedObjectPlaceHolder;
4786 ImplCreateShape( ESCHER_ShpInst_Rectangle, 0x220, aSolverContainer ); // Flags: HaveAnchor | HaveMaster
4787 aPropOpt.AddOpt( ESCHER_Prop_lTxid, mnTxId += 0x60 );
4788 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x10001 );
4789 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x10001 );
4790 aPropOpt.AddOpt( ESCHER_Prop_hspMaster, mnShapeMasterBody );
4792 else
4794 mXText = ::com::sun::star::uno::Reference<
4795 ::com::sun::star::text::XSimpleText >
4796 ( mXShape, ::com::sun::star::uno::UNO_QUERY );
4798 if ( mXText.is() )
4799 mnTextSize = mXText->getString().getLength();
4801 if ( mnTextSize ) // graphic object oder Flachenfuellung
4803 /* SJ #i34951#: because M. documents are not allowing GraphicObjects containing text, we
4804 have to create a simpe Rectangle with fill bitmap instead (while not allowing BitmapMode_Repeat).
4806 ImplCreateShape( ESCHER_ShpInst_Rectangle, 0xa00, aSolverContainer ); // Flags: Connector | HasSpt
4807 if ( aPropOpt.CreateGraphicProperties( mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "GraphicURL" ) ), sal_True, sal_True, sal_False ) )
4809 aPropOpt.AddOpt( ESCHER_Prop_WrapText, ESCHER_WrapNone );
4810 aPropOpt.AddOpt( ESCHER_Prop_AnchorText, ESCHER_AnchorMiddle );
4811 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x140014 );
4812 aPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0x8000000 );
4813 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
4814 if ( ImplGetText() )
4815 aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_False );
4818 else
4820 ImplCreateShape( ESCHER_ShpInst_PictureFrame, 0xa00, aSolverContainer );
4821 if ( aPropOpt.CreateGraphicProperties( mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "GraphicURL" ) ), sal_False, sal_True ) )
4822 aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 );
4826 else if ( ( mType == "drawing.Text" ) || ( mType == "presentation.Notes" ) )
4828 if ( ( ePageType == NOTICE ) && mbPresObj )
4830 if ( ImplCreatePresentationPlaceholder( bMasterPage, ePageType, EPP_TEXTTYPE_Notes, EPP_PLACEHOLDER_MASTERNOTESBODYIMAGE ) )
4831 continue;
4832 else
4833 nPlaceHolderAtom = EPP_PLACEHOLDER_NOTESBODY;
4835 ImplCreateTextShape( aPropOpt, aSolverContainer, TRUE );
4837 else if ( mType == "presentation.TitleText" )
4839 if ( mbPresObj )
4841 if ( ( ePageType == NOTICE ) && mbEmptyPresObj )
4843 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4844 nPlaceHolderAtom = EPP_PLACEHOLDER_MASTERNOTESBODYIMAGE;
4845 ImplCreateShape( ESCHER_ShpInst_Rectangle, 0x200, aSolverContainer );
4846 aPropOpt.CreateLineProperties( mXPropSet, sal_False );
4847 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x10001 );
4849 else if ( rLayout.bTitlePossible && bIsTitlePossible )
4851 bIsTitlePossible = FALSE;
4853 ImplGetText();
4854 TextObj aTextObj( mXText, EPP_TEXTTYPE_Title, maFontCollection, (PPTExBulletProvider&)*this );
4855 if ( ePageType == MASTER )
4857 if ( mnTextSize )
4859 ::rtl::OUString aUString( mXText->getString() );
4860 sal_uInt16 nChar;
4862 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4863 mnShapeMasterTitle = mpPptEscherEx->GetShapeID();
4864 mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xa00, mnShapeMasterTitle );// Flags: HaveAnchor | HasSpt
4865 EscherPropertyContainer aPropertyOptions;
4866 aPropertyOptions.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x50001 );
4867 aPropertyOptions.AddOpt( ESCHER_Prop_lTxid, mnTxId += 0x60 );
4868 aPropertyOptions.AddOpt( ESCHER_Prop_AnchorText, ESCHER_AnchorMiddle );
4869 // aPropertyOptions.AddOpt( ESCHER_Prop_fillColor, nFillColor );
4870 // aPropertyOptions.AddOpt( ESCHER_Prop_fillBackColor, nFillBackColor );
4871 aPropertyOptions.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x110001 );
4872 aPropertyOptions.AddOpt( ESCHER_Prop_lineColor, 0x8000001 );
4873 aPropertyOptions.AddOpt( ESCHER_Prop_shadowColor, 0x8000002 );
4874 aPropertyOptions.CreateFillProperties( mXPropSet, sal_True );
4875 sal_uInt32 nLineFlags = 0x90001;
4876 if ( aPropertyOptions.GetOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags ) )
4877 nLineFlags |= 0x10001; // draw dashed line if no line
4878 aPropertyOptions.AddOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags );
4879 aPropertyOptions.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_True );
4880 ImplAdjustFirstLineLineSpacing( aTextObj, aPropOpt );
4881 aPropertyOptions.Commit( *mpStrm );
4882 mpPptEscherEx->AddAtom( 8, ESCHER_ClientAnchor );
4883 *mpStrm << (sal_Int16)maRect.Top() << (sal_Int16)maRect.Left() << (sal_Int16)maRect.Right() << (sal_Int16)maRect.Bottom(); // oben, links, rechts, unten ????
4884 mpPptEscherEx->OpenContainer( ESCHER_ClientData );
4885 mpPptEscherEx->AddAtom( 8, EPP_OEPlaceholderAtom );
4886 *mpStrm << (sal_uInt32)0 // PlacementID
4887 << (sal_uInt8)EPP_PLACEHOLDER_MASTERTITLE // PlaceHolderID
4888 << (sal_uInt8)0 // Size of PlaceHolder ( 0 = FULL, 1 = HALF, 2 = QUARTER )
4889 << (sal_uInt16)0; // padword
4890 mpPptEscherEx->CloseContainer(); // ESCHER_ClientData
4891 mpPptEscherEx->OpenContainer( ESCHER_ClientTextbox );
4892 mpPptEscherEx->AddAtom( 4, EPP_TextHeaderAtom );
4893 *mpStrm << (sal_uInt32)EPP_TEXTTYPE_Title;
4894 mpPptEscherEx->AddAtom( mnTextSize << 1, EPP_TextCharsAtom );
4895 const sal_Unicode* pString = aUString;
4896 for ( sal_uInt32 i = 0; i < mnTextSize; i++ )
4898 nChar = pString[ i ]; // 0xa -> 0xb weicher Zeilenumbruch
4899 if ( nChar == 0xa )
4900 nChar++; // 0xd -> 0xd harter Zeilenumbruch
4901 *mpStrm << nChar;
4903 mpPptEscherEx->AddAtom( 6, EPP_BaseTextPropAtom );
4904 *mpStrm << (sal_uInt32)( mnTextSize + 1 ) << (sal_uInt16)0;
4905 mpPptEscherEx->AddAtom( 10, EPP_TextSpecInfoAtom );
4906 *mpStrm << (sal_uInt32)( mnTextSize + 1 ) << (sal_uInt32)1 << (sal_uInt16)0;
4907 mpPptEscherEx->CloseContainer(); // ESCHER_ClientTextBox
4908 mpPptEscherEx->CloseContainer(); // ESCHER_SpContainer
4910 continue;
4912 else
4914 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4915 mnTextStyle = EPP_TEXTSTYLE_TITLE;
4916 nPlaceHolderAtom = rLayout.nTypeOfTitle;
4917 ImplCreateShape( ESCHER_ShpInst_Rectangle, 0x220, aSolverContainer ); // Flags: HaveAnchor | HaveMaster
4918 aPropOpt.AddOpt( ESCHER_Prop_hspMaster, mnShapeMasterTitle );
4919 aPropOpt.CreateFillProperties( mXPropSet, sal_True );
4920 aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_True );
4921 ImplAdjustFirstLineLineSpacing( aTextObj, aPropOpt );
4922 if ( mbEmptyPresObj )
4924 sal_uInt32 nNoLineDrawDash = 0;
4925 aPropOpt.GetOpt( ESCHER_Prop_fNoLineDrawDash, nNoLineDrawDash );
4926 nNoLineDrawDash |= 0x10001;
4927 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, nNoLineDrawDash );
4931 else
4932 mbPresObj = FALSE;
4934 if ( !mbPresObj )
4936 mType = "drawing.Text";
4937 ImplCreateTextShape( aPropOpt, aSolverContainer, TRUE );
4940 else if ( ( mType == "presentation.Outliner" ) || ( mType == "presentation.Subtitle" ) )
4942 if ( mbPresObj )
4944 nOutlinerCount++;
4945 if ( (rLayout.bOutlinerPossible && ( nOutlinerCount == 1 )) ||
4946 (( rLayout.bSecOutlinerPossible && ( nOutlinerCount == 2 ) ) && ( nPrevTextStyle == EPP_TEXTSTYLE_BODY ))
4949 ImplGetText();
4950 TextObj aTextObj( mXText, EPP_TEXTTYPE_Body, maFontCollection, (PPTExBulletProvider&)*this );
4951 if ( ePageType == MASTER )
4953 nPrevTextStyle = EPP_TEXTSTYLE_TITLE;
4954 if ( mnTextSize )
4956 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4957 mnShapeMasterBody = mpPptEscherEx->GetShapeID();
4958 mpPptEscherEx->AddShape( ESCHER_ShpInst_Rectangle, 0xa00, mnShapeMasterBody ); // Flags: HaveAnchor | HasSpt
4959 EscherPropertyContainer aPropOpt2;
4960 aPropOpt2.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x50001 );
4961 aPropOpt2.AddOpt( ESCHER_Prop_lTxid, mnTxId += 0x60 );
4962 // aPropOpt2.AddOpt( ESCHER_Prop_fillColor, nFillColor );
4963 // aPropOpt2.AddOpt( ESCHER_Prop_fillBackColor, nFillBackColor );
4964 aPropOpt2.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x110001 );
4965 aPropOpt2.AddOpt( ESCHER_Prop_lineColor, 0x8000001 );
4966 aPropOpt2.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x90001 );
4967 aPropOpt2.AddOpt( ESCHER_Prop_shadowColor, 0x8000002 );
4968 aPropOpt2.CreateFillProperties( mXPropSet, sal_True );
4969 sal_uInt32 nLineFlags = 0x90001;
4970 if ( aPropOpt2.GetOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags ) )
4971 nLineFlags |= 0x10001; // draw dashed line if no line
4972 aPropOpt2.AddOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags );
4973 aPropOpt2.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_True );
4974 ImplAdjustFirstLineLineSpacing( aTextObj, aPropOpt2 );
4975 aPropOpt2.Commit( *mpStrm );
4976 mpPptEscherEx->AddAtom( 8, ESCHER_ClientAnchor );
4977 *mpStrm << (sal_Int16)maRect.Top() << (sal_Int16)maRect.Left() << (sal_Int16)maRect.Right() << (sal_Int16)maRect.Bottom(); // oben, links, rechts, unten ????
4978 mpPptEscherEx->OpenContainer( ESCHER_ClientData );
4979 mpPptEscherEx->AddAtom( 8, EPP_OEPlaceholderAtom );
4980 *mpStrm << (sal_uInt32)1 // PlacementID
4981 << (sal_uInt8)EPP_PLACEHOLDER_MASTERBODY // PlaceHolderID
4982 << (sal_uInt8)0 // Size of PlaceHolder ( 0 = FULL, 1 = HALF, 2 = QUARTER )
4983 << (sal_uInt16)0; // padword
4984 mpPptEscherEx->CloseContainer(); // ESCHER_ClientData
4985 mpPptEscherEx->OpenContainer( ESCHER_ClientTextbox ); // printf
4986 mpPptEscherEx->AddAtom( 4, EPP_TextHeaderAtom );
4987 *mpStrm << (sal_uInt32)EPP_TEXTTYPE_Body;
4988 mnTextSize = aTextObj.Count();
4989 aTextObj.Write( mpStrm );
4990 mpPptEscherEx->BeginAtom();
4991 for ( ParagraphObj* pPara = aTextObj.First() ; pPara; pPara = aTextObj.Next() )
4993 sal_uInt32 nCharCount = pPara->Count();
4994 sal_uInt16 nDepth = pPara->nDepth;
4995 if ( nDepth > 4)
4996 nDepth = 4;
4998 *mpStrm << nCharCount
4999 << nDepth;
5001 mpPptEscherEx->EndAtom( EPP_BaseTextPropAtom );
5002 mpPptEscherEx->AddAtom( 10, EPP_TextSpecInfoAtom );
5003 *mpStrm << (sal_uInt32)( mnTextSize ) << (sal_uInt32)1 << (sal_uInt16)0;
5005 mpPptEscherEx->CloseContainer(); // ESCHER_ClientTextBox
5006 mpPptEscherEx->CloseContainer(); // ESCHER_SpContainer
5008 continue;
5010 else
5012 mnTextStyle = EPP_TEXTSTYLE_BODY;
5013 nPlaceHolderAtom = rLayout.nTypeOfOutliner;
5014 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
5015 ImplCreateShape( ESCHER_ShpInst_Rectangle, 0x220, aSolverContainer ); // Flags: HaveAnchor | HaveMaster
5016 aPropOpt.AddOpt( ESCHER_Prop_hspMaster, mnShapeMasterBody );
5017 aPropOpt.CreateFillProperties( mXPropSet, sal_True );
5018 aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_True );
5019 ImplAdjustFirstLineLineSpacing( aTextObj, aPropOpt );
5020 if ( mbEmptyPresObj )
5022 sal_uInt32 nNoLineDrawDash = 0;
5023 aPropOpt.GetOpt( ESCHER_Prop_fNoLineDrawDash, nNoLineDrawDash );
5024 nNoLineDrawDash |= 0x10001;
5025 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, nNoLineDrawDash );
5029 else
5030 mbPresObj = FALSE;
5032 if ( !mbPresObj )
5034 mType = "drawing.Text";
5035 ImplCreateTextShape( aPropOpt, aSolverContainer, TRUE );
5038 else if ( ( mType == "drawing.Page" ) || ( mType == "presentation.Page" ) )
5040 if ( ( ePageType == NOTICE ) && mbPresObj )
5042 if ( ImplCreatePresentationPlaceholder( bMasterPage, ePageType, EPP_TEXTTYPE_Notes, EPP_PLACEHOLDER_MASTERNOTESSLIDEIMAGE ) )
5043 continue;
5044 else
5045 nPlaceHolderAtom = EPP_PLACEHOLDER_NOTESSLIDEIMAGE;
5047 ImplCreateTextShape( aPropOpt, aSolverContainer, TRUE );
5049 else if ( mType == "drawing.Frame" )
5051 continue;
5053 else if ( ( mType == "drawing.OLE2" ) || ( mType == "presentation.OLE2" )
5054 || ( mType == "presentation.Chart" ) || ( mType == "presentation.Table" )
5055 || ( mType == "presentation.OrgChart" ) )
5057 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
5058 if ( mbEmptyPresObj && ( ePageType == NORMAL ) )
5060 nPlaceHolderAtom = rLayout.nUsedObjectPlaceHolder;
5061 ImplCreateShape( ESCHER_ShpInst_Rectangle, 0x220, aSolverContainer ); // Flags: HaveAnchor | HaveMaster
5062 aPropOpt.AddOpt( ESCHER_Prop_lTxid, mnTxId += 0x60 );
5063 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x10001 );
5064 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x10001 );
5065 aPropOpt.AddOpt( ESCHER_Prop_hspMaster, mnShapeMasterBody );
5067 else
5069 *mpExEmbed << (sal_uInt32)( 0xf | ( EPP_ExEmbed << 16 ) )
5070 << (sal_uInt32)0; // Size of this container
5072 sal_uInt32 nSize, nOldPos = mpExEmbed->Tell();
5074 *mpExEmbed << (sal_uInt32)( EPP_ExEmbedAtom << 16 )
5075 << (sal_uInt32)8
5076 << (sal_uInt32)0 // follow colorscheme : 0->do not follow
5077 // 1->follow collorscheme
5078 // 2->follow text and background scheme
5079 << (sal_uInt8)1 // (bool)set if embedded server can not be locked
5080 << (sal_uInt8)0 // (bool)do not need to send dimension
5081 << (sal_uInt8)0 // (bool)is object a world table
5082 << (sal_uInt8)0; // pad byte
5084 PPTExOleObjEntry* pE = new PPTExOleObjEntry( NORMAL_OLE_OBJECT, mpExEmbed->Tell() );
5085 pE->xShape = mXShape;
5086 maExOleObj.Insert( pE );
5088 mnExEmbed++;
5090 sal_Int64 nAspect = ::com::sun::star::embed::Aspects::MSOLE_CONTENT;
5093 // try to get the aspect when available
5094 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
5095 xShapeProps( mXShape, ::com::sun::star::uno::UNO_QUERY_THROW );
5096 xShapeProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Aspect" ) ) ) >>= nAspect;
5098 catch( ::com::sun::star::uno::Exception& )
5101 *mpExEmbed << (sal_uInt32)( 1 | ( EPP_ExOleObjAtom << 16 ) )
5102 << (sal_uInt32)24
5103 << (sal_uInt32)nAspect // Aspect
5104 << (sal_uInt32)0
5105 << (sal_uInt32)mnExEmbed // index to the persist table
5106 << (sal_uInt32)0 // subtype
5107 << (sal_uInt32)0
5108 << (sal_uInt32)0x0012b600;
5110 // PPTWriter::WriteCString( *mpExEmbed, "Photo Editor Photo", 1 );
5111 // PPTWriter::WriteCString( *mpExEmbed, "MSPhotoEd.3", 2 );
5112 // PPTWriter::WriteCString( *mpExEmbed, "Microsoft Photo Editor 3.0 Photo", 3 );
5114 nSize = mpExEmbed->Tell() - nOldPos;
5115 mpExEmbed->Seek( nOldPos - 4 );
5116 *mpExEmbed << nSize;
5117 mpExEmbed->Seek( STREAM_SEEK_TO_END );
5118 nOlePictureId = mnExEmbed;
5120 sal_uInt32 nSpFlags = 0xa00;
5121 if ( nOlePictureId )
5122 nSpFlags |= 0x10;
5123 ImplCreateShape( ESCHER_ShpInst_PictureFrame, nSpFlags, aSolverContainer );
5124 if ( aPropOpt.CreateOLEGraphicProperties( mXShape ) )
5125 aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 );
5126 if ( nOlePictureId )
5127 aPropOpt.AddOpt( ESCHER_Prop_pictureId, nOlePictureId );
5130 else if ( mType == "presentation.Header" )
5132 if ( ImplCreatePresentationPlaceholder( bMasterPage, ePageType, EPP_TEXTTYPE_Other, EPP_PLACEHOLDER_MASTERHEADER ) )
5133 continue;
5134 else
5136 mbPresObj = sal_False;
5137 mType = "drawing.Text";
5138 ImplCreateTextShape( aPropOpt, aSolverContainer, TRUE );
5141 else if ( mType == "presentation.Footer" )
5143 if ( ImplCreatePresentationPlaceholder( bMasterPage, ePageType, EPP_TEXTTYPE_Other, EPP_PLACEHOLDER_MASTERFOOTER ) )
5144 continue;
5145 else
5147 mbPresObj = sal_False;
5148 mType = "drawing.Text";
5149 ImplCreateTextShape( aPropOpt, aSolverContainer, TRUE );
5152 else if ( mType == "presentation.DateTime" )
5154 if ( ImplCreatePresentationPlaceholder( bMasterPage, ePageType, EPP_TEXTTYPE_Other, EPP_PLACEHOLDER_MASTERDATE ) )
5155 continue;
5156 else
5158 mbPresObj = sal_False;
5159 mType = "drawing.Text";
5160 ImplCreateTextShape( aPropOpt, aSolverContainer, TRUE );
5163 else if ( mType == "presentation.SlideNumber" )
5165 if ( ImplCreatePresentationPlaceholder( bMasterPage, ePageType, EPP_TEXTTYPE_Other, EPP_PLACEHOLDER_MASTERSLIDENUMBER ) )
5166 continue;
5167 else
5169 mbPresObj = sal_False;
5170 mType = "drawing.Text";
5171 ImplCreateTextShape( aPropOpt, aSolverContainer, TRUE );
5174 else if ( ( (sal_Char)'3' == mType.GetChar( 8 ) ) && ( (char)'D' == mType.GetChar( 9 ) ) ) // drawing.3D
5176 // SceneObject, CubeObject, SphereObject, LatheObject, ExtrudeObject, PolygonObject
5177 if ( !ImplGetPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "Bitmap" ) ) ) )
5178 continue;
5180 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
5181 ImplCreateShape( ESCHER_ShpInst_PictureFrame, 0xa00, aSolverContainer );
5183 if ( aPropOpt.CreateGraphicProperties( mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Bitmap" ) ), sal_False ) )
5184 aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 );
5186 else if ( mType == "drawing.Media" )
5188 mnAngle = 0;
5189 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
5190 ImplCreateShape( ESCHER_ShpInst_PictureFrame, 0xa00, aSolverContainer );
5192 ::com::sun::star::uno::Any aAny;
5193 if ( PropValue::GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "MediaURL" ) ), sal_True ) )
5195 rtl::OUString aMediaURL;
5196 if ( (aAny >>= aMediaURL ) && aMediaURL.getLength() )
5198 // SJ: creating the Media RefObj
5199 sal_uInt32 nRefId = ++mnExEmbed;
5201 *mpExEmbed << (sal_uInt16)0xf
5202 << (sal_uInt16)EPP_ExMCIMovie // PPT_PST_ExAviMovie
5203 << (sal_uInt32)0;
5204 sal_uInt32 nSize, nStart = mpExEmbed->Tell();
5205 *mpExEmbed << (sal_uInt16)0
5206 << (sal_uInt16)EPP_ExObjRefAtom
5207 << (sal_uInt32)4
5208 << nRefId;
5209 *mpExEmbed << (sal_uInt16)0xf
5210 << (sal_uInt16)EPP_ExVideo
5211 << (sal_uInt32)0;
5213 *mpExEmbed << (sal_uInt16)0
5214 << (sal_uInt16)EPP_ExMediaAtom
5215 << (sal_uInt32)8
5216 << nRefId
5217 << (sal_uInt16)0
5218 << (sal_uInt16)0x435;
5221 sal_uInt16 i, nStringLen = (sal_uInt16)aMediaURL.getLength();
5222 *mpExEmbed << (sal_uInt32)( EPP_CString << 16 ) << (sal_uInt32)( nStringLen * 2 );
5223 for ( i = 0; i < nStringLen; i++ )
5225 sal_Unicode nChar = aMediaURL[ i ];
5226 *mpExEmbed << nChar;
5228 nSize = mpExEmbed->Tell() - nStart;
5229 mpExEmbed->SeekRel( - ( (sal_Int32)nSize + 4 ) );
5230 *mpExEmbed << nSize; // size of PPT_PST_ExMCIMovie
5231 mpExEmbed->SeekRel( 0x10 );
5232 nSize -= 20;
5233 *mpExEmbed << nSize; // PPT_PST_ExMediaAtom
5234 mpExEmbed->SeekRel( nSize );
5236 if ( !pClientData )
5237 pClientData = new SvMemoryStream( 0x200, 0x200 );
5238 *pClientData << (sal_uInt16)0
5239 << (sal_uInt16)EPP_ExObjRefAtom
5240 << (sal_uInt32)4
5241 << nRefId;
5245 else if ( mType == "drawing.Table" )
5247 SvMemoryStream* pTmp = NULL;
5248 if ( bEffect && !mbUseNewAnimations )
5250 pTmp = new SvMemoryStream( 0x200, 0x200 );
5251 ImplWriteObjectEffect( *pTmp, eAe, eTe, ++nEffectCount );
5253 if ( eCa != ::com::sun::star::presentation::ClickAction_NONE )
5255 if ( !pTmp )
5256 pTmp = new SvMemoryStream( 0x200, 0x200 );
5257 ImplWriteClickAction( *pTmp, eCa, bMediaClickAction );
5259 ImplCreateTable( mXShape, aSolverContainer, aPropOpt );
5260 continue;
5262 else if ( mType == "drawing.dontknow" )
5264 mnAngle = 0;
5265 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
5266 ImplCreateShape( ESCHER_ShpInst_PictureFrame, 0xa00, aSolverContainer );
5267 if ( aPropOpt.CreateGraphicProperties( mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "MetaFile" ) ), sal_False ) )
5268 aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 );
5270 else
5272 continue;
5274 sal_Int32 nPlacementID = -1;
5276 sal_Bool bClientData = ( bEffect || ( eCa != ::com::sun::star::presentation::ClickAction_NONE ) ||
5277 nPlaceHolderAtom || nOlePictureId );
5278 if ( bClientData )
5280 if ( nPlaceHolderAtom )
5282 if ( ( mnTextStyle == EPP_TEXTSTYLE_TITLE ) || ( mnTextStyle == EPP_TEXTSTYLE_BODY ) )
5283 nPlacementID = nIndices++;
5284 else
5286 switch ( nPlaceHolderAtom )
5288 default :
5290 if ( nPlaceHolderAtom < 19 )
5291 break;
5293 case EPP_PLACEHOLDER_NOTESBODY :
5294 case EPP_PLACEHOLDER_MASTERDATE :
5295 case EPP_PLACEHOLDER_NOTESSLIDEIMAGE :
5296 case EPP_PLACEHOLDER_MASTERNOTESBODYIMAGE :
5297 nPlacementID = nIndices++;
5300 if ( !pClientData )
5301 pClientData = new SvMemoryStream( 0x200, 0x200 );
5303 *pClientData << (sal_uInt32)( EPP_OEPlaceholderAtom << 16 ) << (sal_uInt32)8
5304 << nPlacementID // PlacementID
5305 << (sal_uInt8)nPlaceHolderAtom // PlaceHolderID
5306 << (sal_uInt8)0 // Size of PlaceHolder ( 0 = FULL, 1 = HALF, 2 = QUARTER )
5307 << (sal_uInt16)0; // padword
5309 if ( nOlePictureId )
5311 if ( !pClientData )
5312 pClientData = new SvMemoryStream( 0x200, 0x200 );
5314 *pClientData << (sal_uInt32)( EPP_ExObjRefAtom << 16 ) << (sal_uInt32)4
5315 << nOlePictureId;
5316 nOlePictureId = 0;
5318 if ( bEffect )
5320 if ( !pClientData )
5321 pClientData = new SvMemoryStream( 0x200, 0x200 );
5323 // check if it is sensible to replace the object effect with text effect,
5324 // because in Impress there is the possibility to use a compound effect,
5325 // e.g. the object effect is an AnimationEffect_FADE_FROM_LEFT and the
5326 // text effect is a AnimationEffect_FADE_FROM_TOP, in PowerPoint there
5327 // can be used only one effect
5328 if ( mnTextSize && ( eTe != ::com::sun::star::presentation::AnimationEffect_NONE )
5329 && ( eAe != ::com::sun::star::presentation::AnimationEffect_NONE )
5330 && ( eTe != eAe ) )
5332 sal_uInt32 nFillStyleFlags, nLineStyleFlags;
5333 if ( aPropOpt.GetOpt( ESCHER_Prop_fNoFillHitTest, nFillStyleFlags )
5334 && aPropOpt.GetOpt( ESCHER_Prop_fNoLineDrawDash, nLineStyleFlags ) )
5336 // there is no fillstyle and also no linestyle
5337 if ( ! ( ( nFillStyleFlags & 0x10 ) + ( nLineStyleFlags & 9 ) ) )
5338 eAe = eTe;
5341 if ( !mbUseNewAnimations )
5342 ImplWriteObjectEffect( *pClientData, eAe, eTe, ++nEffectCount );
5345 if ( eCa != ::com::sun::star::presentation::ClickAction_NONE )
5347 if ( !pClientData )
5348 pClientData = new SvMemoryStream( 0x200, 0x200 );
5349 ImplWriteClickAction( *pClientData, eCa, bMediaClickAction );
5352 if ( ( mnTextStyle == EPP_TEXTSTYLE_TITLE ) || ( mnTextStyle == EPP_TEXTSTYLE_BODY ) )
5354 if ( !pClientTextBox )
5355 pClientTextBox = new SvMemoryStream( 0x200, 0x200 );
5357 *pClientTextBox << (sal_uInt32)( EPP_OutlineTextRefAtom << 16 ) << (sal_uInt32)4
5358 << nPlacementID;
5360 if ( mbEmptyPresObj == FALSE )
5362 if ( ( ePageType == NORMAL ) && ( bMasterPage == FALSE ) )
5363 { // try to allocate the textruleratom
5364 TextRuleEntry* pTextRule = (TextRuleEntry*)maTextRuleList.GetCurObject();
5365 while ( pTextRule )
5367 int nRulePage = pTextRule->nPageNumber;
5368 if ( nRulePage > nPageNumber )
5369 break;
5370 else if ( nRulePage < nPageNumber )
5371 pTextRule = (TextRuleEntry*)maTextRuleList.Next();
5372 else
5374 SvMemoryStream* pOut = pTextRule->pOut;
5375 if ( pOut )
5377 pClientTextBox->Write( pOut->GetData(), pOut->Tell() );
5378 delete pOut, pTextRule->pOut = NULL;
5380 maTextRuleList.Next();
5381 break;
5387 else
5389 if ( !aPropOpt.IsFontWork() )
5391 if ( mnTextSize || ( nPlaceHolderAtom == EPP_PLACEHOLDER_MASTERDATE ) || ( nPlaceHolderAtom == EPP_PLACEHOLDER_NOTESBODY ) )
5393 int nInstance2;
5394 if ( ( nPlaceHolderAtom == EPP_PLACEHOLDER_MASTERDATE ) || ( nPlaceHolderAtom == EPP_PLACEHOLDER_NOTESBODY ) )
5395 nInstance2 = 2;
5396 else
5397 nInstance2 = EPP_TEXTTYPE_Other; // Text in a Shape
5399 if ( !pClientTextBox )
5400 pClientTextBox = new SvMemoryStream( 0x200, 0x200 );
5402 SvMemoryStream aExtBu( 0x200, 0x200 );
5403 ImplWriteTextStyleAtom( *pClientTextBox, nInstance2, 0, NULL, aExtBu, &aPropOpt );
5404 if ( aExtBu.Tell() )
5406 if ( !pClientData )
5407 pClientData = new SvMemoryStream( 0x200, 0x200 );
5408 ImplProgTagContainer( pClientData, &aExtBu );
5411 else if ( nPlaceHolderAtom >= 19 )
5413 if ( !pClientTextBox )
5414 pClientTextBox = new SvMemoryStream( 12 );
5416 *pClientTextBox << (sal_uInt32)( EPP_TextHeaderAtom << 16 ) << (sal_uInt32)4
5417 << (sal_uInt32)7;
5422 aPropOpt.CreateShadowProperties( mXPropSet );
5423 maRect.Justify();
5424 if ( mnAngle )
5425 ImplFlipBoundingBox( aPropOpt );
5426 aPropOpt.Commit( *mpStrm );
5427 mpPptEscherEx->AddClientAnchor( maRect );
5429 if ( pClientData )
5431 *mpStrm << (sal_uInt32)( ( ESCHER_ClientData << 16 ) | 0xf )
5432 << (sal_uInt32)pClientData->Tell();
5434 mpStrm->Write( pClientData->GetData(), pClientData->Tell() );
5435 delete pClientData, pClientData = NULL;
5437 if ( pClientTextBox )
5439 *mpStrm << (sal_uInt32)( ( ESCHER_ClientTextbox << 16 ) | 0xf )
5440 << (sal_uInt32)pClientTextBox->Tell();
5442 mpStrm->Write( pClientTextBox->GetData(), pClientTextBox->Tell() );
5443 delete pClientTextBox, pClientTextBox = NULL;
5445 mpPptEscherEx->CloseContainer(); // ESCHER_SpContainer
5447 nPrevTextStyle = mnTextStyle;
5449 if ( bAdditionalText )
5451 bAdditionalText = FALSE;
5453 ::com::sun::star::uno::Any aAny;
5454 EscherPropertyContainer aPropOpt;
5455 mnAngle = ( PropValue::GetPropertyValue( aAny,
5456 mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "RotateAngle" ) ), sal_True ) )
5457 ? *((sal_Int32*)aAny.getValue() )
5458 : 0;
5460 aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x90000 );
5461 aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100000 );
5462 if ( mType == "drawing.Line" )
5464 double fDist = hypot( maRect.GetWidth(), maRect.GetHeight() );
5465 maRect = Rectangle( Point( aTextRefPoint.X, aTextRefPoint.Y ),
5466 Point( (sal_Int32)( aTextRefPoint.X + fDist ), aTextRefPoint.Y - 1 ) );
5467 ImplCreateTextShape( aPropOpt, aSolverContainer, FALSE );
5468 aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x60006 ); // Size Shape To Fit Text
5469 if ( mnAngle < 0 )
5470 mnAngle = ( 36000 + mnAngle ) % 36000;
5471 if ( mnAngle )
5472 ImplFlipBoundingBox( aPropOpt );
5474 else
5476 ImplCreateTextShape( aPropOpt, aSolverContainer, FALSE );
5477 if ( mnAngle < 0 )
5478 mnAngle = ( 36000 + mnAngle ) % 36000;
5479 else
5480 mnAngle = ( 36000 - ( mnAngle % 36000 ) );
5482 mnAngle *= 655;
5483 mnAngle += 0x8000;
5484 mnAngle &=~0xffff; // nAngle auf volle Gradzahl runden
5485 aPropOpt.AddOpt( ESCHER_Prop_Rotation, mnAngle );
5486 mpPptEscherEx->SetGroupSnapRect( nGroupLevel, maRect );
5487 mpPptEscherEx->SetGroupLogicRect( nGroupLevel, maRect );
5489 if ( !pClientTextBox )
5490 pClientTextBox = new SvMemoryStream( 0x200, 0x200 );
5492 SvMemoryStream aExtBu( 0x200, 0x200 );
5493 ImplWriteTextStyleAtom( *pClientTextBox, EPP_TEXTTYPE_Other, 0, NULL, aExtBu, &aPropOpt );
5495 aPropOpt.Commit( *mpStrm );
5496 mpPptEscherEx->AddClientAnchor( maRect );
5498 *mpStrm << (sal_uInt32)( ( ESCHER_ClientTextbox << 16 ) | 0xf )
5499 << (sal_uInt32)pClientTextBox->Tell();
5501 mpStrm->Write( pClientTextBox->GetData(), pClientTextBox->Tell() );
5502 delete pClientTextBox, pClientTextBox = NULL;
5504 mpPptEscherEx->CloseContainer(); // ESCHER_SpContainer
5505 mpPptEscherEx->LeaveGroup();
5508 ClearGroupTable(); // gruppierungen wegschreiben, sofern noch irgendwelche offen sind, was eigendlich nicht sein sollte
5509 nGroups = GetGroupsClosed();
5510 for ( sal_uInt32 i = 0; i < nGroups; i++, mpPptEscherEx->LeaveGroup() ) ;
5511 mnPagesWritten++;
5514 // -----------------------------------------------------------------------
5516 ::com::sun::star::awt::Point PPTWriter::ImplMapPoint( const ::com::sun::star::awt::Point& rPoint )
5518 Point aRet( OutputDevice::LogicToLogic( Point( rPoint.X, rPoint.Y ), maMapModeSrc, maMapModeDest ) );
5519 return ::com::sun::star::awt::Point( aRet.X(), aRet.Y() );
5522 // -----------------------------------------------------------------------
5524 ::com::sun::star::awt::Size PPTWriter::ImplMapSize( const ::com::sun::star::awt::Size& rSize )
5526 Size aRetSize( OutputDevice::LogicToLogic( Size( rSize.Width, rSize.Height ), maMapModeSrc, maMapModeDest ) );
5528 if ( !aRetSize.Width() )
5529 aRetSize.Width()++;
5530 if ( !aRetSize.Height() )
5531 aRetSize.Height()++;
5532 return ::com::sun::star::awt::Size( aRetSize.Width(), aRetSize.Height() );
5535 // -----------------------------------------------------------------------
5537 Rectangle PPTWriter::ImplMapRectangle( const ::com::sun::star::awt::Rectangle& rRect )
5539 ::com::sun::star::awt::Point aPoint( rRect.X, rRect.Y );
5540 ::com::sun::star::awt::Size aSize( rRect.Width, rRect.Height );
5541 ::com::sun::star::awt::Point aP( ImplMapPoint( aPoint ) );
5542 ::com::sun::star::awt::Size aS( ImplMapSize( aSize ) );
5543 return Rectangle( Point( aP.X, aP.Y ), Size( aS.Width, aS.Height ) );
5546 // -----------------------------------------------------------------------
5548 struct CellBorder
5550 sal_Int32 mnPos; // specifies the distance to the top/left position of the table
5551 sal_Int32 mnLength;
5552 table::BorderLine maCellBorder;
5554 CellBorder() : mnPos ( 0 ), mnLength( 0 ){};
5557 void PPTWriter::ImplCreateCellBorder( const CellBorder* pCellBorder, sal_Int32 nX1, sal_Int32 nY1, sal_Int32 nX2, sal_Int32 nY2 )
5559 sal_Int32 nLineWidth = pCellBorder->maCellBorder.OuterLineWidth + pCellBorder->maCellBorder.InnerLineWidth;
5560 if ( nLineWidth )
5562 mnAngle = 0;
5563 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
5564 EscherPropertyContainer aPropOptSp;
5566 sal_uInt32 nId = mpPptEscherEx->GetShapeID();
5567 mpPptEscherEx->AddShape( ESCHER_ShpInst_Line, 0xa02, nId );
5568 aPropOptSp.AddOpt( ESCHER_Prop_shapePath, ESCHER_ShapeComplex );
5569 aPropOptSp.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0xa0008 );
5570 aPropOptSp.AddOpt( ESCHER_Prop_fshadowObscured, 0x20000 );
5572 sal_uInt32 nBorderColor = pCellBorder->maCellBorder.Color & 0xff00; // green
5573 nBorderColor |= static_cast< sal_uInt8 >( pCellBorder->maCellBorder.Color ) << 16; // red
5574 nBorderColor |= static_cast< sal_uInt8 >( pCellBorder->maCellBorder.Color >> 16 ); // blue
5575 aPropOptSp.AddOpt( ESCHER_Prop_lineColor, nBorderColor );
5577 aPropOptSp.AddOpt( ESCHER_Prop_lineWidth, nLineWidth * 360 );
5578 aPropOptSp.AddOpt( ESCHER_Prop_fc3DLightFace, 0x80000 );
5579 aPropOptSp.Commit( *mpStrm );
5580 mpPptEscherEx->AddAtom( 16, ESCHER_ChildAnchor );
5581 *mpStrm << nX1
5582 << nY1
5583 << nX2
5584 << nY2;
5585 mpPptEscherEx->CloseContainer();
5589 void PPTWriter::WriteCString( SvStream& rSt, const String& rString, sal_uInt32 nInstance )
5591 sal_uInt32 i, nLen = rString.Len();
5592 if ( nLen )
5594 rSt << (sal_uInt32)( ( nInstance << 4 ) | ( EPP_CString << 16 ) )
5595 << (sal_uInt32)( nLen << 1 );
5596 for ( i = 0; i < nLen; i++ )
5597 rSt << rString.GetChar( (sal_uInt16)i );
5601 void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape >& rXShape, EscherSolverContainer& aSolverContainer,
5602 EscherPropertyContainer& aPropOpt )
5604 mpPptEscherEx->OpenContainer( ESCHER_SpgrContainer );
5605 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
5606 mpPptEscherEx->AddAtom( 16, ESCHER_Spgr, 1 );
5607 *mpStrm << (INT32)maRect.Left() // Bounding box fuer die Gruppierten shapes an die sie attached werden
5608 << (INT32)maRect.Top()
5609 << (INT32)maRect.Right()
5610 << (INT32)maRect.Bottom();
5612 sal_uInt32 nShapeId = mpPptEscherEx->GetShapeID();
5613 mpPptEscherEx->AddShape( ESCHER_ShpInst_Min, 0x201, nShapeId ); // Flags: Group | Patriarch
5614 aSolverContainer.AddShape( rXShape, nShapeId );
5615 EscherPropertyContainer aPropOpt2;
5618 static const rtl::OUString sModel( RTL_CONSTASCII_USTRINGPARAM ( "Model" ) );
5619 static const rtl::OUString sWidth( RTL_CONSTASCII_USTRINGPARAM ( "Width" ) );
5620 static const rtl::OUString sHeight( RTL_CONSTASCII_USTRINGPARAM ( "Height" ) );
5622 uno::Reference< table::XTable > xTable;
5623 if ( mXPropSet->getPropertyValue( sModel ) >>= xTable )
5625 uno::Reference< table::XColumnRowRange > xColumnRowRange( xTable, uno::UNO_QUERY_THROW );
5626 uno::Reference< container::XIndexAccess > xColumns( xColumnRowRange->getColumns(), uno::UNO_QUERY_THROW );
5627 uno::Reference< container::XIndexAccess > xRows( xColumnRowRange->getRows(), uno::UNO_QUERY_THROW );
5628 sal_uInt16 nRowCount = static_cast< sal_uInt16 >( xRows->getCount() );
5629 sal_uInt16 nColumnCount = static_cast< sal_uInt16 >( xColumns->getCount() );
5631 std::vector< std::pair< sal_Int32, sal_Int32 > > aColumns;
5632 std::vector< std::pair< sal_Int32, sal_Int32 > > aRows;
5634 awt::Point aPosition( ImplMapPoint( rXShape->getPosition() ) );
5635 sal_uInt32 nPosition = aPosition.X;
5636 for ( sal_Int32 x = 0; x < nColumnCount; x++ )
5638 uno::Reference< beans::XPropertySet > xPropSet( xColumns->getByIndex( x ), uno::UNO_QUERY_THROW );
5639 awt::Size aS( 0, 0 );
5640 xPropSet->getPropertyValue( sWidth ) >>= aS.Width;
5641 awt::Size aM( ImplMapSize( aS ) );
5642 aColumns.push_back( std::pair< sal_Int32, sal_Int32 >( nPosition, aM.Width ) );
5643 nPosition += aM.Width;
5646 nPosition = aPosition.Y;
5647 for ( sal_Int32 y = 0; y < nRowCount; y++ )
5649 uno::Reference< beans::XPropertySet > xPropSet( xRows->getByIndex( y ), uno::UNO_QUERY_THROW );
5650 awt::Size aS( 0, 0 );
5651 xPropSet->getPropertyValue( sHeight ) >>= aS.Height;
5652 awt::Size aM( ImplMapSize( aS ) );
5653 aRows.push_back( std::pair< sal_Int32, sal_Int32 >( nPosition, aM.Height ) );
5654 nPosition += aM.Height;
5657 if ( nRowCount )
5659 SvMemoryStream aMemStrm;
5660 aMemStrm.ObjectOwnsMemory( FALSE );
5661 aMemStrm << nRowCount
5662 << nRowCount
5663 << (sal_uInt16)4;
5665 std::vector< std::pair< sal_Int32, sal_Int32 > >::const_iterator aIter( aRows.begin() );
5666 while( aIter != aRows.end() )
5667 aMemStrm << (*aIter++).second;
5669 aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x1000100 );
5670 aPropOpt2.AddOpt( ESCHER_Prop_tableProperties, 1 );
5671 aPropOpt2.AddOpt( ESCHER_Prop_tableRowProperties, sal_True, aMemStrm.Tell(), static_cast< sal_uInt8* >( const_cast< void* >( aMemStrm.GetData() ) ), aMemStrm.Tell() );
5672 aPropOpt.Commit( *mpStrm );
5673 aPropOpt2.Commit( *mpStrm, 3, ESCHER_UDefProp );
5674 mpPptEscherEx->AddAtom( 8, ESCHER_ClientAnchor );
5675 *mpStrm << (sal_Int16)maRect.Top()
5676 << (sal_Int16)maRect.Left()
5677 << (sal_Int16)( maRect.GetWidth() + maRect.Left() )
5678 << (sal_Int16)( maRect.GetHeight() + maRect.Top() );
5679 mpPptEscherEx->CloseContainer();
5682 uno::Reference< table::XCellRange > xCellRange( xTable, uno::UNO_QUERY_THROW );
5683 for( sal_Int32 nRow = 0; nRow < xRows->getCount(); nRow++ )
5685 for( sal_Int32 nColumn = 0; nColumn < xColumns->getCount(); nColumn++ )
5687 uno::Reference< table::XMergeableCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ), uno::UNO_QUERY_THROW );
5688 if ( !xCell->isMerged() )
5690 sal_Int32 nLeft = aColumns[ nColumn ].first;
5691 sal_Int32 nTop = aRows[ nRow ].first;
5692 sal_Int32 nRight = nLeft + aColumns[ nColumn ].second;
5693 sal_Int32 nBottom = nTop + aRows[ nRow ].second;
5695 for ( sal_Int32 nColumnSpan = 1; nColumnSpan < xCell->getColumnSpan(); nColumnSpan++ )
5697 sal_uInt32 nC = nColumnSpan + nColumn;
5698 if ( nC < aColumns.size() )
5699 nRight += aColumns[ nC ].second;
5700 else
5701 nRight = maRect.Right();
5703 for ( sal_Int32 nRowSpan = 1; nRowSpan < xCell->getRowSpan(); nRowSpan++ )
5705 sal_uInt32 nR = nRowSpan + nRow;
5706 if ( nR < aColumns.size() )
5707 nBottom += aRows[ nR ].second;
5708 else
5709 nBottom = maRect.Bottom();
5712 mbFontIndependentLineSpacing = sal_False;
5713 mXPropSet = uno::Reference< beans::XPropertySet >( xCell, uno::UNO_QUERY_THROW );
5714 mXText = uno::Reference< text::XSimpleText >( xCell, uno::UNO_QUERY_THROW );
5715 mnTextSize = mXText->getString().getLength();
5717 ::com::sun::star::uno::Any aAny;
5718 if ( GetPropertyValue( aAny, mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FontIndependentLineSpacing" ) ) ), sal_True )
5719 aAny >>= mbFontIndependentLineSpacing;
5721 EscherPropertyContainer aPropOptSp;
5722 mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
5723 ImplCreateShape( ESCHER_ShpInst_Rectangle, 0xa02, aSolverContainer ); // Flags: Connector | HasSpt | Child
5724 aPropOptSp.CreateFillProperties( mXPropSet, sal_True );
5725 aPropOptSp.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x90000 );
5726 aPropOptSp.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_True );
5727 aPropOptSp.AddOpt( ESCHER_Prop_WrapText, ESCHER_WrapSquare );
5729 SvMemoryStream aClientTextBox( 0x200, 0x200 );
5730 SvMemoryStream aExtBu( 0x200, 0x200 );
5732 ImplWriteTextStyleAtom( aClientTextBox, EPP_TEXTTYPE_Other, 0, NULL, aExtBu, &aPropOptSp );
5734 aPropOptSp.Commit( *mpStrm );
5735 mpPptEscherEx->AddAtom( 16, ESCHER_ChildAnchor );
5736 *mpStrm << nLeft
5737 << nTop
5738 << nRight
5739 << nBottom;
5741 *mpStrm << (sal_uInt32)( ( ESCHER_ClientTextbox << 16 ) | 0xf )
5742 << (sal_uInt32)aClientTextBox.Tell();
5744 mpStrm->Write( aClientTextBox.GetData(), aClientTextBox.Tell() );
5745 mpPptEscherEx->CloseContainer();
5750 static const rtl::OUString sTopBorder( String( RTL_CONSTASCII_USTRINGPARAM( "TopBorder" ) ) );
5751 static const rtl::OUString sBottomBorder( String( RTL_CONSTASCII_USTRINGPARAM( "BottomBorder" ) ) );
5752 static const rtl::OUString sLeftBorder( String( RTL_CONSTASCII_USTRINGPARAM( "LeftBorder" ) ) );
5753 static const rtl::OUString sRightBorder( String( RTL_CONSTASCII_USTRINGPARAM( "RightBorder" ) ) );
5754 static const rtl::OUString sDiagonalTLBR( RTL_CONSTASCII_USTRINGPARAM ( "DiagonalTLBR" ) );
5755 static const rtl::OUString sDiagonalBLTR( RTL_CONSTASCII_USTRINGPARAM ( "DiagonalBLTR" ) );
5757 // creating horz lines
5758 sal_Int32 nYPos = ImplMapPoint( rXShape->getPosition() ).Y;
5759 for( sal_Int32 nLine = 0; nLine < ( xRows->getCount() + 1 ); nLine++ )
5761 sal_Int32 nXPos = ImplMapPoint( rXShape->getPosition() ).X;
5762 std::vector< CellBorder > vCellBorders;
5763 for( sal_Int32 nColumn = 0; nColumn < xColumns->getCount(); nColumn++ )
5765 uno::Reference< beans::XPropertySet > xPropSet( xColumns->getByIndex( nColumn ), uno::UNO_QUERY_THROW );
5766 awt::Size aS( 0, 0 );
5767 xPropSet->getPropertyValue( sWidth ) >>= aS.Width;
5768 awt::Size aM( ImplMapSize( aS ) );
5770 CellBorder aCellBorder;
5771 aCellBorder.mnPos = nXPos;
5772 aCellBorder.mnLength = aM.Width;
5773 if ( nLine < xRows->getCount() )
5774 { // top border
5775 uno::Reference< table::XMergeableCell > xCell( xCellRange->getCellByPosition( nColumn, nLine ), uno::UNO_QUERY_THROW );
5776 uno::Reference< beans::XPropertySet > xPropSet2( xCell, uno::UNO_QUERY_THROW );
5777 table::BorderLine aBorderLine;
5778 if ( xPropSet2->getPropertyValue( sTopBorder ) >>= aBorderLine )
5779 aCellBorder.maCellBorder = aBorderLine;
5781 if ( nLine )
5782 { // bottom border
5783 uno::Reference< table::XMergeableCell > xCell( xCellRange->getCellByPosition( nColumn, nLine - 1 ), uno::UNO_QUERY_THROW );
5784 uno::Reference< beans::XPropertySet > xPropSet2( xCell, uno::UNO_QUERY_THROW );
5785 table::BorderLine aBorderLine;
5786 if ( xPropSet2->getPropertyValue( sBottomBorder ) >>= aBorderLine )
5787 aCellBorder.maCellBorder = aBorderLine;
5789 vCellBorders.push_back( aCellBorder );
5790 nXPos += aM.Width;
5792 std::vector< CellBorder >::const_iterator aCellBorderIter( vCellBorders.begin() );
5793 while( aCellBorderIter != vCellBorders.end() )
5795 ImplCreateCellBorder( &*aCellBorderIter, aCellBorderIter->mnPos, nYPos,
5796 static_cast< sal_Int32 >( aCellBorderIter->mnPos + aCellBorderIter->mnLength ), nYPos );
5797 aCellBorderIter++;
5799 if ( nLine < xRows->getCount() )
5801 uno::Reference< beans::XPropertySet > xPropSet( xRows->getByIndex( nLine ), uno::UNO_QUERY_THROW );
5802 awt::Size aS( 0, 0 );
5803 xPropSet->getPropertyValue( sHeight ) >>= aS.Height;
5804 awt::Size aM( ImplMapSize( aS ) );
5805 nYPos += aM.Height;
5809 // creating vertical lines
5810 sal_Int32 nXPos = ImplMapPoint( rXShape->getPosition() ).X;
5811 for( sal_Int32 nLine = 0; nLine < ( xColumns->getCount() + 1 ); nLine++ )
5813 nYPos = ImplMapPoint( rXShape->getPosition() ).Y;
5814 std::vector< CellBorder > vCellBorders;
5815 for( sal_Int32 nRow = 0; nRow < xRows->getCount(); nRow++ )
5817 uno::Reference< beans::XPropertySet > xPropSet( xRows->getByIndex( nRow ), uno::UNO_QUERY_THROW );
5818 awt::Size aS( 0, 0 );
5819 xPropSet->getPropertyValue( sHeight ) >>= aS.Height;
5820 awt::Size aM( ImplMapSize( aS ) );
5822 CellBorder aCellBorder;
5823 aCellBorder.mnPos = nYPos;
5824 aCellBorder.mnLength = aM.Height;
5825 if ( nLine < xColumns->getCount() )
5826 { // left border
5827 uno::Reference< table::XMergeableCell > xCell( xCellRange->getCellByPosition( nLine, nRow ), uno::UNO_QUERY_THROW );
5828 uno::Reference< beans::XPropertySet > xCellSet( xCell, uno::UNO_QUERY_THROW );
5829 table::BorderLine aBorderLine;
5830 if ( xCellSet->getPropertyValue( sLeftBorder ) >>= aBorderLine )
5831 aCellBorder.maCellBorder = aBorderLine;
5833 if ( nLine )
5834 { // right border
5835 uno::Reference< table::XMergeableCell > xCell( xCellRange->getCellByPosition( nLine - 1, nRow ), uno::UNO_QUERY_THROW );
5836 uno::Reference< beans::XPropertySet > xCellSet( xCell, uno::UNO_QUERY_THROW );
5837 table::BorderLine aBorderLine;
5838 if ( xCellSet->getPropertyValue( sRightBorder ) >>= aBorderLine )
5839 aCellBorder.maCellBorder = aBorderLine;
5841 vCellBorders.push_back( aCellBorder );
5842 nYPos += aM.Height;
5844 std::vector< CellBorder >::const_iterator aCellBorderIter( vCellBorders.begin() );
5845 while( aCellBorderIter != vCellBorders.end() )
5847 ImplCreateCellBorder( &*aCellBorderIter, nXPos, aCellBorderIter->mnPos,
5848 nXPos, static_cast< sal_Int32 >( aCellBorderIter->mnPos + aCellBorderIter->mnLength ) );
5849 aCellBorderIter++;
5851 if ( nLine < xColumns->getCount() )
5853 uno::Reference< beans::XPropertySet > xPropSet( xColumns->getByIndex( nLine ), uno::UNO_QUERY_THROW );
5854 awt::Size aS( 0, 0 );
5855 xPropSet->getPropertyValue( sWidth ) >>= aS.Width;
5856 awt::Size aM( ImplMapSize( aS ) );
5857 nXPos += aM.Width;
5863 catch( uno::Exception& )
5866 mpPptEscherEx->CloseContainer();