merge the formfield patch from ooo-build
[ooovba.git] / svx / source / msfilter / mstoolbar.cxx
blob0d45af7a4c43bcb482fcf2747d6f924128efab74
1 #include <svx/mstoolbar.hxx>
2 #include <rtl/ustrbuf.hxx>
3 #include <stdarg.h>
4 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
5 #include <com/sun/star/ui/XImageManager.hpp>
6 #include <com/sun/star/ui/ItemType.hpp>
7 #include <com/sun/star/ui/ItemStyle.hpp>
8 #include <com/sun/star/frame/XLayoutManager.hpp>
9 #include <fstream>
10 #include <vcl/graph.hxx>
11 #include <vcl/bitmapex.hxx>
12 #include <vcl/image.hxx>
13 #include <map>
14 #include <sfx2/objsh.hxx>
15 #include <basic/basmgr.hxx>
16 #include <svtools/filterutils.hxx>
17 #include <boost/scoped_array.hpp>
18 #include <svx/msvbahelper.hxx>
19 #include <svtools/miscopt.hxx>
20 #include <vcl/svapp.hxx>
21 #include <vcl/window.hxx>
23 using namespace com::sun::star;
25 int TBBase::nIndent = 0;
27 void CustomToolBarImportHelper::showToolbar( const rtl::OUString& rName )
29 try
31 uno::Reference< frame::XController > xCntrller( mrDocSh.GetModel()->getCurrentController(), uno::UNO_QUERY_THROW );
32 uno::Reference< beans::XPropertySet > xProps( xCntrller->getFrame(), uno::UNO_QUERY_THROW );
33 uno::Reference< frame::XLayoutManager > xLayoutMgr( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LayoutManager") ) ), uno::UNO_QUERY_THROW );
34 xLayoutMgr->showElement( rName );
36 catch( uno::Exception& ) {}
39 void CustomToolBarImportHelper::ScaleImage( uno::Reference< graphic::XGraphic >& xGraphic, long nNewSize )
41 Graphic aGraphic( xGraphic );
42 Size aSize = aGraphic.GetSizePixel();
43 if ( aSize.Height() && ( aSize.Height() == aSize.Width() ) )
45 Image aImage( xGraphic );
46 if ( aSize.Height() != nNewSize )
48 BitmapEx aBitmap = aImage.GetBitmapEx();
49 BitmapEx aBitmapex = BitmapEx::AutoScaleBitmap(aBitmap, nNewSize );
50 aImage = Image( aBitmapex);
51 xGraphic = aImage.GetXGraphic();
56 void CustomToolBarImportHelper::applyIcons()
58 for ( std::vector< iconcontrolitem >::iterator it = iconcommands.begin(); it != iconcommands.end(); ++it )
60 uno::Sequence< rtl::OUString > commands(1);
61 commands[ 0 ] = it->sCommand;
62 uno::Sequence< uno::Reference< graphic::XGraphic > > images(1);
63 images[ 0 ] = it->image;
65 OSL_TRACE("About to applyIcons for command %s, have image ? %s", rtl::OUStringToOString( commands[ 0 ], RTL_TEXTENCODING_UTF8 ).getStr(), images[ 0 ].is() ? "yes" : "no" );
66 uno::Reference< ui::XImageManager > xImageManager( getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
67 sal_uInt16 nColor = ui::ImageType::COLOR_NORMAL;
69 Window* topwin = Application::GetActiveTopWindow();
70 if ( topwin != NULL && topwin->GetDisplayBackground().GetColor().IsDark() )
71 nColor = css::ui::ImageType::COLOR_HIGHCONTRAST;
73 ScaleImage( images[ 0 ], 16 );
74 xImageManager->replaceImages( ui::ImageType::SIZE_DEFAULT | nColor, commands, images );
75 ScaleImage( images[ 0 ], 26 );
76 xImageManager->replaceImages( ui::ImageType::SIZE_LARGE | nColor, commands, images );
80 void CustomToolBarImportHelper::addIcon( const uno::Reference< graphic::XGraphic >& xImage, const rtl::OUString& sString )
82 iconcontrolitem item;
83 item.sCommand = sString;
84 item.image = xImage;
85 iconcommands.push_back( item );
88 CustomToolBarImportHelper::CustomToolBarImportHelper( SfxObjectShell& rDocShell, const css::uno::Reference< css::ui::XUIConfigurationManager>& rxAppCfgMgr ) : mrDocSh( rDocShell )
90 m_xCfgSupp.set( mrDocSh.GetModel(), uno::UNO_QUERY_THROW );
91 m_xAppCfgMgr.set( rxAppCfgMgr, uno::UNO_QUERY_THROW );
94 uno::Reference< ui::XUIConfigurationManager >
95 CustomToolBarImportHelper::getCfgManager()
97 return m_xCfgSupp->getUIConfigurationManager();
100 uno::Reference< ui::XUIConfigurationManager >
101 CustomToolBarImportHelper::getAppCfgManager()
103 return m_xAppCfgMgr;
106 uno::Any
107 CustomToolBarImportHelper::createCommandFromMacro( const rtl::OUString& sCmd )
109 //"vnd.sun.star.script:Standard.Module1.Main?language=Basic&location=document"
110 static rtl::OUString scheme = rtl::OUString::createFromAscii( "vnd.sun.star.script:");
111 static rtl::OUString part2 = rtl::OUString::createFromAscii("?language=Basic&location=document");
112 // create script url
113 rtl::OUString scriptURL = scheme + sCmd + part2;
114 return uno::makeAny( scriptURL );
117 rtl::OUString CustomToolBarImportHelper::MSOCommandToOOCommand( sal_Int16 msoCmd )
119 rtl::OUString result;
120 if ( pMSOCmdConvertor.get() )
121 result = pMSOCmdConvertor->MSOCommandToOOCommand( msoCmd );
122 return result;
125 rtl::OUString CustomToolBarImportHelper::MSOTCIDToOOCommand( sal_Int16 msoTCID )
127 rtl::OUString result;
128 if ( pMSOCmdConvertor.get() )
129 result = pMSOCmdConvertor->MSOTCIDToOOCommand( msoTCID );
130 return result;
133 void
134 TBBase::indent_printf( FILE* fp, const char* format, ... )
136 va_list ap;
137 va_start ( ap, format );
139 // indent nIndent spaces
140 for ( int i=0; i<nIndent; ++i)
141 fprintf(fp," ");
142 // append the rest of the message
143 vfprintf( fp, format, ap );
144 va_end( ap );
147 rtl::OUString TBBase::readUnicodeString( SvStream* pS, sal_Int32 nChars )
149 sal_Int32 nBufSize = nChars * 2;
150 boost::scoped_array< sal_uInt8 > pArray( new sal_uInt8[ nBufSize ] );
151 pS->Read( pArray.get(), nBufSize );
152 return svt::BinFilterUtils::CreateOUStringFromUniStringArray( reinterpret_cast< const char* >( pArray.get() ), nBufSize );
155 TBCHeader::TBCHeader() : bSignature( 0x3 )
156 ,bVersion( 0x01 )
157 ,bFlagsTCR( 0 )
158 ,tct(0x1) // default to Button
159 ,tcid(0)
160 ,tbct(0)
165 TBCHeader::~TBCHeader()
169 bool TBCHeader::Read( SvStream* pS )
171 OSL_TRACE("TBCHeader::Read() stream pos 0x%x", pS->Tell() );
172 nOffSet = pS->Tell();
173 *pS >> bSignature >> bVersion >> bFlagsTCR >> tct >> tcid >> tbct >> bPriority;
174 // bit 4 ( from lsb )
175 if ( bFlagsTCR & 0x10 )
177 width.reset( new sal_uInt16 );
178 height.reset( new sal_uInt16 );
179 *pS >> *width >> *height;
181 return true;
184 void TBCHeader::Print( FILE* fp )
186 Indent a;
187 indent_printf(fp,"[ 0x%x ] TBCHeader -- dump\n", nOffSet );
188 indent_printf(fp," bSignature 0x%x\n", bSignature );
189 indent_printf(fp," bVersion 0x%x\n", bVersion );
190 indent_printf(fp," bFlagsTCR 0x%x\n", bFlagsTCR );
191 indent_printf(fp," tct 0x%x\n", tct );
192 indent_printf(fp," tcid 0x%x\n", tcid );
193 indent_printf(fp," tbct 0x%x\n", static_cast< unsigned int >( tbct ));
194 indent_printf(fp," bPriority 0x%x\n", bPriority );
195 if ( width.get() )
196 indent_printf(fp," width 0x%d(0x%x)\n", *width, *width);
197 if ( height.get() )
198 indent_printf(fp," height 0x%d(0x%x)\n", *height, *height);
201 TBCData::TBCData( const TBCHeader& Header ) : rHeader( Header )
205 bool TBCData::Read(SvStream *pS)
207 OSL_TRACE("TBCData::Read() stream pos 0x%x", pS->Tell() );
208 nOffSet = pS->Tell();
209 if ( !controlGeneralInfo.Read(pS) /*|| !controlSpecificInfo.Read(pS)*/ )
210 return false;
211 switch ( rHeader.getTct() )
213 case 0x01: // (Button control)
214 case 0x10: // (ExpandingGrid control)
215 controlSpecificInfo.reset( new TBCBSpecific() );
216 break;
217 case 0x0A: // (Popup control)
218 case 0x0C: // (ButtonPopup control)
219 case 0x0D: // (SplitButtonPopup control)
220 case 0x0E: // (SplitButtonMRUPopup control)
221 controlSpecificInfo.reset( new TBCMenuSpecific() );
222 break;
223 case 0x02: // (Edit control)
224 case 0x04: // (ComboBox control)
225 case 0x14: // (GraphicCombo control)
226 case 0x03: // (DropDown control)
227 case 0x06: // (SplitDropDown control)
228 case 0x09: // (GraphicDropDown control)
229 controlSpecificInfo.reset( new TBCComboDropdownSpecific( rHeader ) );
230 break;
231 default:
232 break;
234 if ( controlSpecificInfo.get() )
235 return controlSpecificInfo->Read( pS );
236 //#FIXME I need to be able to handle different controlSpecificInfo types.
237 return true;
240 TBCMenuSpecific* TBCData::getMenuSpecific()
242 TBCMenuSpecific* pMenu = dynamic_cast< TBCMenuSpecific* >( controlSpecificInfo.get() );
243 return pMenu;
245 bool TBCData::ImportToolBarControl( CustomToolBarImportHelper& helper, std::vector< css::beans::PropertyValue >& props, bool& bBeginGroup, bool bIsMenuBar )
247 sal_uInt16 nStyle = 0;
248 bBeginGroup = rHeader.isBeginGroup();
249 controlGeneralInfo.ImportToolBarControlData( helper, props );
250 beans::PropertyValue aProp;
251 aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Visible") ) ;
252 aProp.Value = uno::makeAny( rHeader.isVisible() ); // where is the visible attribute stored
253 props.push_back( aProp );
254 if ( rHeader.getTct() == 0x01
255 || rHeader.getTct() == 0x10 )
257 TBCBSpecific* pSpecificInfo = dynamic_cast< TBCBSpecific* >( controlSpecificInfo.get() );
258 if ( pSpecificInfo )
260 // if we have a icon then lets set it for the command
261 rtl::OUString sCommand;
262 for ( std::vector< css::beans::PropertyValue >::iterator it = props.begin(); it != props.end(); ++it )
264 if ( it->Name.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CommandURL") ) ) )
265 it->Value >>= sCommand;
267 if ( TBCBitMap* pIcon = pSpecificInfo->getIcon() )
269 // Without a command openoffice won't display the icon
270 if ( sCommand.getLength() )
272 BitmapEx aBitEx( pIcon->getBitMap() );
273 if ( pSpecificInfo->getIconMask() )
274 // according to the spec:
275 // "the iconMask is white in all the areas in which the icon is
276 // displayed as transparent and is black in all other areas."
277 aBitEx = BitmapEx( aBitEx.GetBitmap(), pSpecificInfo->getIconMask()->getBitMap().CreateMask( Color( COL_WHITE ) ) );
279 Graphic aGraphic( aBitEx );
280 helper.addIcon( aGraphic.GetXGraphic(), sCommand );
283 else if ( pSpecificInfo->getBtnFace() )
286 rtl::OUString sBuiltInCmd = helper.MSOTCIDToOOCommand( *pSpecificInfo->getBtnFace() );
287 if ( sBuiltInCmd.getLength() )
289 uno::Sequence< rtl::OUString> sCmds(1);
290 sCmds[ 0 ] = sBuiltInCmd;
291 uno::Reference< ui::XImageManager > xImageManager( helper.getAppCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
292 // 0 = default image size
293 uno::Sequence< uno::Reference< graphic::XGraphic > > sImages = xImageManager->getImages( 0, sCmds );
294 if ( sImages.getLength() && sImages[0].is() )
295 helper.addIcon( sImages[0], sCommand );
300 else if ( rHeader.getTct() == 0x0a )
302 aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CommandURL") ) ;
303 aProp.Value = uno::makeAny( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("private:" ) ) ); // dummy command
304 nStyle |= ui::ItemStyle::DROP_DOWN;
305 props.push_back( aProp );
308 short icontext = ( rHeader.getTbct() & 0x03 );
309 aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Style") ) ;
310 if ( bIsMenuBar )
312 nStyle |= ui::ItemStyle::TEXT;
313 if ( !icontext || icontext == 0x3 )
314 // Text And image
315 nStyle |= ui::ItemStyle::ICON;
317 else
319 if ( ( icontext & 0x02 ) == 0x02 )
320 nStyle |= ui::ItemStyle::TEXT;
321 if ( !icontext || ( icontext & 0x03 ) == 0x03 )
322 nStyle |= ui::ItemStyle::ICON;
324 aProp.Value <<= nStyle;
325 props.push_back( aProp );
326 return true; // just ignore
329 void TBCData::Print( FILE* fp )
331 Indent a;
332 indent_printf(fp,"[ 0x%x ] TBCData -- dump\n", nOffSet );
333 indent_printf(fp," dumping controlGeneralInfo( TBCGeneralInfo )\n");
334 controlGeneralInfo.Print( fp );
335 //if ( rHeader.getTct() == 1 )
336 if ( controlSpecificInfo.get() )
338 indent_printf(fp," dumping controlSpecificInfo( TBCBSpecificInfo )\n");
339 controlSpecificInfo->Print( fp );
343 bool
344 WString::Read( SvStream *pS )
346 OSL_TRACE("WString::Read() stream pos 0x%x", pS->Tell() );
347 nOffSet = pS->Tell();
348 sal_Int8 nChars = 0;
349 *pS >> nChars;
350 sString = readUnicodeString( pS, static_cast< sal_Int32 >( nChars ) );
351 return true;
354 TBCExtraInfo::TBCExtraInfo() : idHelpContext( 0 )
358 bool
359 TBCExtraInfo::Read( SvStream *pS )
361 OSL_TRACE("TBCExtraInfo::Read() stream pos 0x%x", pS->Tell() );
362 nOffSet = pS->Tell();
363 if( !wstrHelpFile.Read( pS ) )
364 return false;
366 *pS >> idHelpContext;
368 if ( !wstrTag.Read( pS ) || !wstrOnAction.Read( pS ) || !wstrParam.Read( pS ) )
369 return false;
371 *pS >> tbcu >> tbmg;
372 return true;
375 void
376 TBCExtraInfo::Print( FILE* fp )
378 Indent a;
379 indent_printf( fp, "[ 0x%x ] TBCExtraInfo -- dump\n", nOffSet );
380 indent_printf( fp, " wstrHelpFile %s\n",
381 rtl::OUStringToOString( wstrHelpFile.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
382 indent_printf( fp, " idHelpContext 0x%x\n", static_cast< unsigned int >( idHelpContext ) );
383 indent_printf( fp, " wstrTag %s\n",
384 rtl::OUStringToOString( wstrTag.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
385 indent_printf( fp, " wstrOnAction %s\n",
386 rtl::OUStringToOString( wstrOnAction.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
387 indent_printf( fp, " wstrParam %s\n",
388 rtl::OUStringToOString( wstrParam.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
389 indent_printf( fp, " tbcu 0x%x\n", tbcu );
390 indent_printf( fp, " tbmg 0x%x\n", tbmg );
394 rtl::OUString
395 TBCExtraInfo::getOnAction()
397 return wstrOnAction.getString();
400 TBCGeneralInfo::TBCGeneralInfo() : bFlags( 0 )
404 bool TBCGeneralInfo::Read( SvStream *pS )
406 OSL_TRACE("TBCGeneralInfo::Read() stream pos 0x%x", pS->Tell() );
407 nOffSet = pS->Tell();
408 *pS >> bFlags;
410 if ( ( bFlags & 0x1 ) && !customText.Read( pS ) )
411 return false;
412 if ( ( bFlags & 0x2 ) && ( !descriptionText.Read( pS ) || !tooltip.Read( pS ) ) )
413 return false;
414 if ( ( bFlags & 0x4 ) && !extraInfo.Read( pS ) )
415 return false;
416 return true;
419 void
420 TBCGeneralInfo::Print( FILE* fp )
422 Indent a;
423 indent_printf( fp, "[ 0x%x ] TBCGeneralInfo -- dump\n", nOffSet );
424 indent_printf( fp, " bFlags 0x%x\n", bFlags );
425 indent_printf( fp, " customText %s\n",
426 rtl::OUStringToOString( customText.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
427 indent_printf( fp, " description %s\n",
428 rtl::OUStringToOString( descriptionText.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
429 indent_printf( fp, " tooltip %s\n",
430 rtl::OUStringToOString( tooltip.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
431 if ( bFlags & 0x4 )
432 extraInfo.Print( fp );
435 bool
436 TBCGeneralInfo::ImportToolBarControlData( CustomToolBarImportHelper& helper, std::vector< beans::PropertyValue >& sControlData )
438 if ( ( bFlags & 0x5 ) )
440 beans::PropertyValue aProp;
441 // probably access to the header would be a better test than seeing if there is an action, e.g.
442 // if ( rHeader.getTct() == 0x01 && rHeader.getTcID() == 0x01 ) // not defined, probably this is a command
443 if ( extraInfo.getOnAction().getLength() )
445 aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CommandURL") );
446 ooo::vba::VBAMacroResolvedInfo aMacroInf = ooo::vba::resolveVBAMacro( &helper.GetDocShell(), extraInfo.getOnAction(), true );
447 if ( aMacroInf.IsResolved() )
448 aProp.Value = helper.createCommandFromMacro( aMacroInf.ResolvedMacro() );
449 else
450 aProp.Value <<= rtl::OUString::createFromAscii("UnResolvedMacro[").concat( extraInfo.getOnAction() ).concat( rtl::OUString::createFromAscii("]") );
451 sControlData.push_back( aProp );
454 aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Label") );
455 aProp.Value = uno::makeAny( customText.getString().replace('&','~') );
456 sControlData.push_back( aProp );
458 aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Type") );
459 aProp.Value = uno::makeAny( ui::ItemType::DEFAULT );
460 sControlData.push_back( aProp );
462 aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Tooltip") );
463 aProp.Value = uno::makeAny( tooltip.getString() );
464 sControlData.push_back( aProp );
466 aToolbarItem(0).Name = "CommandURL" wstrOnAction
467 aToolbarItem(0).Value = Command
468 aToolbarItem(1).Name = "Label" customText
469 aToolbarItem(1).Value = Label
470 aToolbarItem(2).Name = "Type"
471 aToolbarItem(2).Value = 0
472 aToolbarItem(3).Name = "Visible"
473 aToolbarItem(3).Value = true
476 return true;
479 TBCMenuSpecific::TBCMenuSpecific() : tbid( 0 )
483 bool
484 TBCMenuSpecific::Read( SvStream *pS)
486 OSL_TRACE("TBCMenuSpecific::Read() stream pos 0x%x", pS->Tell() );
487 nOffSet = pS->Tell();
488 *pS >> tbid;
489 if ( tbid == 1 )
491 name.reset( new WString() );
492 return name->Read( pS );
494 return true;
497 void
498 TBCMenuSpecific::Print( FILE* fp )
500 Indent a;
501 indent_printf( fp, "[ 0x%x ] TBCMenuSpecific -- dump\n", nOffSet );
502 indent_printf( fp, " tbid 0x%x\n", static_cast< unsigned int >( tbid ) );
503 if ( tbid == 1 )
504 indent_printf( fp, " name %s\n", rtl::OUStringToOString( name->getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
508 rtl::OUString TBCMenuSpecific::Name()
510 rtl::OUString aName;
511 if ( name.get() )
512 aName = name->getString();
513 return aName;
515 TBCBSpecific::TBCBSpecific() : bFlags( 0 )
519 bool TBCBSpecific::Read( SvStream *pS)
521 OSL_TRACE("TBCBSpecific::Read() stream pos 0x%x", pS->Tell() );
522 nOffSet = pS->Tell();
523 *pS >> bFlags;
525 // bFlags determines what we read next
527 // bFlags.fCustomBitmap = 1 ( 0x8 ) set
528 if ( bFlags & 0x8 )
530 icon.reset( new TBCBitMap() );
531 iconMask.reset( new TBCBitMap() );
532 if ( !icon->Read( pS ) || !iconMask->Read( pS ) )
533 return false;
535 // if bFlags.fCustomBtnFace = 1 ( 0x10 )
536 if ( bFlags & 0x10 )
538 iBtnFace.reset( new sal_uInt16 );
539 *pS >> *iBtnFace.get();
541 // if bFlags.fAccelerator equals 1 ( 0x04 )
542 if ( bFlags & 0x04 )
544 wstrAcc.reset( new WString() );
545 return wstrAcc->Read( pS );
547 return true;
551 void TBCBSpecific::Print( FILE* fp )
553 Indent a;
554 indent_printf( fp, "[ 0x%x ] TBCBSpecific -- dump\n", nOffSet );
555 indent_printf( fp, " bFlags 0x%x\n", bFlags );
556 bool bResult = ( icon.get() != NULL );
557 indent_printf( fp, " icon present? %s\n", bResult ? "true" : "false" );
558 if ( bResult )
560 Indent b;
561 indent_printf( fp, " icon: \n");
562 icon->Print( fp ); // will dump size
564 bResult = ( iconMask.get() != NULL );
565 indent_printf( fp, " icon mask present? %s\n", bResult ? "true" : "false" );
566 if ( bResult )
568 Indent c;
569 indent_printf( fp, " icon mask: \n");
570 iconMask->Print( fp ); // will dump size
572 if ( iBtnFace.get() )
574 indent_printf( fp, " iBtnFace 0x%x\n", *(iBtnFace.get()) );
576 bResult = ( wstrAcc.get() != NULL );
577 indent_printf( fp, " option string present? %s ->%s<-\n", bResult ? "true" : "false", bResult ? rtl::OUStringToOString( wstrAcc->getString(), RTL_TEXTENCODING_UTF8 ).getStr() : "N/A" );
580 TBCBitMap*
581 TBCBSpecific::getIcon()
583 return icon.get();
586 TBCBitMap*
587 TBCBSpecific::getIconMask()
589 return iconMask.get();
592 TBCComboDropdownSpecific::TBCComboDropdownSpecific(const TBCHeader& header )
594 if ( header.getTcID() == 0x01 )
595 data.reset( new TBCCDData() );
598 bool TBCComboDropdownSpecific::Read( SvStream *pS)
600 nOffSet = pS->Tell();
601 if ( data.get() )
602 return data->Read( pS );
603 return true;
606 void TBCComboDropdownSpecific::Print( FILE* fp)
608 Indent a;
609 indent_printf(fp,"[ 0x%x ] TBCComboDropdownSpecific -- dump\n", nOffSet );
610 if ( data.get() )
611 data->Print( fp );
612 else
613 indent_printf(fp," no data " );
616 TBCCDData::TBCCDData() : cwstrItems( 0 )
617 ,iSel( 0 )
618 ,cLines( 0 )
619 ,dxWidth( 0 )
623 TBCCDData::~TBCCDData()
627 bool TBCCDData::Read( SvStream *pS)
629 nOffSet = pS->Tell();
630 *pS >> cwstrItems;
631 if ( cwstrItems )
633 for( sal_Int32 index=0; index < cwstrItems; ++index )
635 WString aString;
636 if ( !aString.Read( pS ) )
637 return false;
638 wstrList.push_back( aString );
641 *pS >> cwstrMRU >> iSel >> cLines >> dxWidth;
643 return wstrEdit.Read( pS );
646 void TBCCDData::Print( FILE* fp)
648 Indent a;
649 indent_printf(fp,"[ 0x%x ] TBCCDData -- dump\n", nOffSet );
650 indent_printf(fp," cwstrItems items in wstrList 0x%d\n", cwstrItems);
651 for ( sal_Int32 index=0; index < cwstrItems; ++index )
653 Indent b;
654 indent_printf(fp, " wstrList[%d] %s", static_cast< int >( index ), rtl::OUStringToOString( wstrList[index].getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
656 indent_printf(fp," cwstrMRU num most recently used string 0x%d item\n", cwstrMRU);
657 indent_printf(fp," iSel index of selected item 0x%d item\n", iSel);
658 indent_printf(fp," cLines num of suggested lines to display 0x%d", cLines);
659 indent_printf(fp," dxWidth width in pixels 0x%d", dxWidth);
660 indent_printf(fp," wstrEdit %s", rtl::OUStringToOString( wstrEdit.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
663 TBCBitMap::TBCBitMap() : cbDIB( 0 ), size( 0 )
667 TBCBitMap::~TBCBitMap()
671 // #FIXME Const-ness
672 Bitmap&
673 TBCBitMap::getBitMap()
675 return mBitMap;
678 bool TBCBitMap::Read( SvStream* pS)
680 OSL_TRACE("TBCBitMap::Read() stream pos 0x%x", pS->Tell() );
681 nOffSet = pS->Tell();
682 *pS >> cbDIB;
683 // cbDIB = sizeOf(biHeader) + sizeOf(colors) + sizeOf(bitmapData) + 10
684 return mBitMap.Read( *pS, FALSE, TRUE );
687 void TBCBitMap::Print( FILE* fp )
689 Indent a;
690 indent_printf(fp, "[ 0x%x ] TBCBitMap -- dump\n", nOffSet );
691 indent_printf(fp, " TBCBitMap size of bitmap data 0x%x\n", static_cast< unsigned int > ( cbDIB ) );
694 TB::TB() : bSignature(0x2),
695 bVersion(0x1),
696 cCL(0),
697 ltbid( 0x1 ),
698 ltbtr(0),
699 cRowsDefault( 0 ),
700 bFlags( 0 )
704 bool TB::Read(SvStream *pS)
706 OSL_TRACE("TB::Read() stream pos 0x%x", pS->Tell() );
707 nOffSet = pS->Tell();
708 *pS >> bSignature >> bVersion >> cCL >> ltbid >> ltbtr >> cRowsDefault >> bFlags;
709 name.Read( pS );
710 return true;
714 bool TB::IsEnabled()
716 return ( bFlags & 0x01 ) != 0x01;
719 bool TB::NeedsPositioning()
721 return ( bFlags & 0x10 ) == 0x10;
724 void TB::Print( FILE* fp )
726 Indent a;
727 indent_printf(fp,"[ 0x%x ] TB -- dump\n", nOffSet );
728 indent_printf(fp," bSignature 0x%x\n", bSignature );
729 indent_printf(fp," bVersion 0x%x\n", bVersion );
730 indent_printf(fp," cCL 0x%x\n", cCL );
731 indent_printf(fp," ltbid 0x%x\n", ltbid );
732 indent_printf(fp," ltbtr 0x%x\n", ltbtr );
733 indent_printf(fp," cRowsDefault 0x%x\n", cRowsDefault );
734 indent_printf(fp," bFlags 0x%x\n", bFlags );
735 indent_printf(fp, " name %s\n", rtl::OUStringToOString( name.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
738 TBVisualData::TBVisualData() : tbds(0), tbv(0), tbdsDock(0), iRow(0)
742 bool TBVisualData::Read( SvStream* pS )
744 OSL_TRACE("TBVisualData::Read() stream pos 0x%x", pS->Tell() );
745 nOffSet = pS->Tell();
746 *pS >> tbds >> tbv >> tbdsDock >> iRow;
747 rcDock.Read( pS );
748 rcFloat.Read( pS );
749 return true;
752 void SRECT::Print( FILE* fp )
754 Indent a;
755 indent_printf( fp, " left 0x%x\n", left);
756 indent_printf( fp, " top 0x%x\n", top);
757 indent_printf( fp, " right 0x%x\n", right);
758 indent_printf( fp, " bottom 0x%x\n", bottom);
761 void TBVisualData::Print( FILE* fp )
763 Indent a;
764 indent_printf( fp, "[ 0x%x ] TBVisualData -- dump\n", nOffSet );
765 indent_printf( fp, " tbds 0x%x\n", tbds);
766 indent_printf( fp, " tbv 0x%x\n", tbv);
767 indent_printf( fp, " tbdsDoc 0x%x\n", tbdsDock);
768 indent_printf( fp, " iRow 0x%x\n", iRow);
769 rcDock.Print( fp );
770 rcFloat.Print( fp );