bump product version to 4.1.6.2
[LibreOffice.git] / filter / source / msfilter / mstoolbar.cxx
blobfd08ddc11c5542dc88fec7e6392a3ab67576fd3a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9 #include <filter/msfilter/mstoolbar.hxx>
10 #include <rtl/ustrbuf.hxx>
11 #include <stdarg.h>
12 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
13 #include <com/sun/star/ui/XImageManager.hpp>
14 #include <com/sun/star/ui/ItemType.hpp>
15 #include <com/sun/star/ui/ItemStyle.hpp>
16 #include <com/sun/star/frame/XLayoutManager.hpp>
17 #include <fstream>
18 #include <vcl/graph.hxx>
19 #include <vcl/bitmapex.hxx>
20 #include <vcl/image.hxx>
21 #include <map>
22 #include <sfx2/objsh.hxx>
23 #include <basic/basmgr.hxx>
24 #include <filter/msfilter/msvbahelper.hxx>
25 #include <svtools/miscopt.hxx>
26 #include <vcl/svapp.hxx>
27 #include <vcl/window.hxx>
29 using namespace com::sun::star;
31 int TBBase::nIndent = 0;
33 void CustomToolBarImportHelper::ScaleImage( uno::Reference< graphic::XGraphic >& xGraphic, long nNewSize )
35 Graphic aGraphic( xGraphic );
36 Size aSize = aGraphic.GetSizePixel();
37 if ( aSize.Height() && ( aSize.Height() == aSize.Width() ) )
39 Image aImage( xGraphic );
40 if ( aSize.Height() != nNewSize )
42 BitmapEx aBitmap = aImage.GetBitmapEx();
43 BitmapEx aBitmapex = BitmapEx::AutoScaleBitmap(aBitmap, nNewSize );
44 aImage = Image( aBitmapex);
45 xGraphic = aImage.GetXGraphic();
50 void CustomToolBarImportHelper::applyIcons()
52 for ( std::vector< iconcontrolitem >::iterator it = iconcommands.begin(); it != iconcommands.end(); ++it )
54 uno::Sequence< OUString > commands(1);
55 commands[ 0 ] = it->sCommand;
56 uno::Sequence< uno::Reference< graphic::XGraphic > > images(1);
57 images[ 0 ] = it->image;
59 OSL_TRACE("About to applyIcons for command %s, have image ? %s", OUStringToOString( commands[ 0 ], RTL_TEXTENCODING_UTF8 ).getStr(), images[ 0 ].is() ? "yes" : "no" );
60 uno::Reference< ui::XImageManager > xImageManager( getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
61 sal_uInt16 nColor = ui::ImageType::COLOR_NORMAL;
63 Window* topwin = Application::GetActiveTopWindow();
64 if ( topwin != NULL && topwin->GetDisplayBackground().GetColor().IsDark() )
65 nColor = css::ui::ImageType::COLOR_HIGHCONTRAST;
67 ScaleImage( images[ 0 ], 16 );
68 xImageManager->replaceImages( ui::ImageType::SIZE_DEFAULT | nColor, commands, images );
69 ScaleImage( images[ 0 ], 26 );
70 xImageManager->replaceImages( ui::ImageType::SIZE_LARGE | nColor, commands, images );
74 void CustomToolBarImportHelper::addIcon( const uno::Reference< graphic::XGraphic >& xImage, const OUString& sString )
76 iconcontrolitem item;
77 item.sCommand = sString;
78 item.image = xImage;
79 iconcommands.push_back( item );
82 CustomToolBarImportHelper::CustomToolBarImportHelper( SfxObjectShell& rDocShell, const css::uno::Reference< css::ui::XUIConfigurationManager>& rxAppCfgMgr ) : mrDocSh( rDocShell )
84 m_xCfgSupp.set( mrDocSh.GetModel(), uno::UNO_QUERY_THROW );
85 m_xAppCfgMgr.set( rxAppCfgMgr, uno::UNO_QUERY_THROW );
88 uno::Reference< ui::XUIConfigurationManager >
89 CustomToolBarImportHelper::getCfgManager()
91 return m_xCfgSupp->getUIConfigurationManager();
94 uno::Reference< ui::XUIConfigurationManager >
95 CustomToolBarImportHelper::getAppCfgManager()
97 return m_xAppCfgMgr;
100 uno::Any
101 CustomToolBarImportHelper::createCommandFromMacro( const OUString& sCmd )
103 //"vnd.sun.star.script:Standard.Module1.Main?language=Basic&location=document"
104 static OUString scheme( "vnd.sun.star.script:" );
105 static OUString part2( "?language=Basic&location=document" );
106 // create script url
107 OUString scriptURL = scheme + sCmd + part2;
108 return uno::makeAny( scriptURL );
111 OUString CustomToolBarImportHelper::MSOCommandToOOCommand( sal_Int16 msoCmd )
113 OUString result;
114 if ( pMSOCmdConvertor.get() )
115 result = pMSOCmdConvertor->MSOCommandToOOCommand( msoCmd );
116 return result;
119 OUString CustomToolBarImportHelper::MSOTCIDToOOCommand( sal_Int16 msoTCID )
121 OUString result;
122 if ( pMSOCmdConvertor.get() )
123 result = pMSOCmdConvertor->MSOTCIDToOOCommand( msoTCID );
124 return result;
127 bool
128 CustomToolBarImportHelper::createMenu( const OUString& rName, const uno::Reference< container::XIndexAccess >& xMenuDesc, bool bPersist )
130 bool bRes = true;
133 uno::Reference< ui::XUIConfigurationManager > xCfgManager( getCfgManager() );
134 OUString sMenuBar("private:resource/menubar/");
135 sMenuBar += rName;
136 uno::Reference< container::XIndexContainer > xPopup( xCfgManager->createSettings(), uno::UNO_QUERY_THROW );
137 uno::Reference< beans::XPropertySet > xProps( xPopup, uno::UNO_QUERY_THROW );
138 // set name for menubar
139 xProps->setPropertyValue( OUString("UIName"), uno::makeAny( rName ) );
140 if ( xPopup.is() )
142 uno::Sequence< beans::PropertyValue > aPopupMenu( 4 );
143 aPopupMenu[0].Name = OUString("CommandURL");
144 aPopupMenu[0].Value = uno::makeAny( OUString("vnd.openoffice.org:") + rName );
145 aPopupMenu[1].Name = OUString("Label");
146 aPopupMenu[1].Value <<= rName;
147 aPopupMenu[2].Name = OUString("ItemDescriptorContainer");
148 aPopupMenu[2].Value = uno::makeAny( xMenuDesc );
149 aPopupMenu[3].Name = OUString("Type" );
150 aPopupMenu[3].Value <<= sal_Int32( 0 );
152 xPopup->insertByIndex( xPopup->getCount(), uno::makeAny( aPopupMenu ) );
153 if ( bPersist )
155 xCfgManager->insertSettings( sMenuBar, uno::Reference< container::XIndexAccess >( xPopup, uno::UNO_QUERY ) );
156 uno::Reference< ui::XUIConfigurationPersistence > xPersistence( xCfgManager, uno::UNO_QUERY_THROW );
157 xPersistence->store();
161 catch( const uno::Exception& )
163 bRes = false;
165 return bRes;
168 void
169 TBBase::indent_printf( FILE* fp, const char* format, ... )
171 va_list ap;
172 va_start ( ap, format );
174 // indent nIndent spaces
175 for ( int i=0; i<nIndent; ++i)
176 fprintf(fp," ");
177 // append the rest of the message
178 vfprintf( fp, format, ap );
179 va_end( ap );
182 TBCHeader::TBCHeader() : bSignature( 0x3 )
183 ,bVersion( 0x01 )
184 ,bFlagsTCR( 0 )
185 ,tct(0x1) // default to Button
186 ,tcid(0)
187 ,tbct(0)
192 TBCHeader::~TBCHeader()
196 bool TBCHeader::Read( SvStream &rS )
198 OSL_TRACE("TBCHeader::Read() stream pos 0x%x", rS.Tell() );
199 nOffSet = rS.Tell();
200 rS >> bSignature >> bVersion >> bFlagsTCR >> tct >> tcid >> tbct >> bPriority;
201 // bit 4 ( from lsb )
202 if ( bFlagsTCR & 0x10 )
204 width.reset( new sal_uInt16 );
205 height.reset( new sal_uInt16 );
206 rS >> *width >> *height;
208 return true;
211 void TBCHeader::Print( FILE* fp )
213 Indent a;
214 indent_printf(fp,"[ 0x%x ] TBCHeader -- dump\n", nOffSet );
215 indent_printf(fp," bSignature 0x%x\n", bSignature );
216 indent_printf(fp," bVersion 0x%x\n", bVersion );
217 indent_printf(fp," bFlagsTCR 0x%x\n", bFlagsTCR );
218 indent_printf(fp," tct 0x%x\n", tct );
219 indent_printf(fp," tcid 0x%x\n", tcid );
220 indent_printf(fp," tbct 0x%x\n", static_cast< unsigned int >( tbct ));
221 indent_printf(fp," bPriority 0x%x\n", bPriority );
222 if ( width.get() )
223 indent_printf(fp," width 0x%d(0x%x)\n", *width, *width);
224 if ( height.get() )
225 indent_printf(fp," height 0x%d(0x%x)\n", *height, *height);
228 TBCData::TBCData( const TBCHeader& Header ) : rHeader( Header )
232 bool TBCData::Read(SvStream &rS)
234 OSL_TRACE("TBCData::Read() stream pos 0x%x", rS.Tell() );
235 nOffSet = rS.Tell();
236 if ( !controlGeneralInfo.Read(rS) /*|| !controlSpecificInfo.Read(rS)*/ )
237 return false;
238 switch ( rHeader.getTct() )
240 case 0x01: // (Button control)
241 case 0x10: // (ExpandingGrid control)
242 controlSpecificInfo.reset( new TBCBSpecific() );
243 break;
244 case 0x0A: // (Popup control)
245 case 0x0C: // (ButtonPopup control)
246 case 0x0D: // (SplitButtonPopup control)
247 case 0x0E: // (SplitButtonMRUPopup control)
248 controlSpecificInfo.reset( new TBCMenuSpecific() );
249 break;
250 case 0x02: // (Edit control)
251 case 0x04: // (ComboBox control)
252 case 0x14: // (GraphicCombo control)
253 case 0x03: // (DropDown control)
254 case 0x06: // (SplitDropDown control)
255 case 0x09: // (GraphicDropDown control)
256 controlSpecificInfo.reset( new TBCComboDropdownSpecific( rHeader ) );
257 break;
258 default:
259 break;
261 if ( controlSpecificInfo.get() )
262 return controlSpecificInfo->Read( rS );
263 //#FIXME I need to be able to handle different controlSpecificInfo types.
264 return true;
267 TBCMenuSpecific* TBCData::getMenuSpecific()
269 TBCMenuSpecific* pMenu = dynamic_cast< TBCMenuSpecific* >( controlSpecificInfo.get() );
270 return pMenu;
272 bool TBCData::ImportToolBarControl( CustomToolBarImportHelper& helper, std::vector< css::beans::PropertyValue >& props, bool& bBeginGroup, bool bIsMenuBar )
274 sal_uInt16 nStyle = 0;
275 bBeginGroup = rHeader.isBeginGroup();
276 controlGeneralInfo.ImportToolBarControlData( helper, props );
277 beans::PropertyValue aProp;
278 aProp.Name = OUString("Visible") ;
279 aProp.Value = uno::makeAny( rHeader.isVisible() ); // where is the visible attribute stored
280 props.push_back( aProp );
281 if ( rHeader.getTct() == 0x01
282 || rHeader.getTct() == 0x10 )
284 TBCBSpecific* pSpecificInfo = dynamic_cast< TBCBSpecific* >( controlSpecificInfo.get() );
285 if ( pSpecificInfo )
287 // if we have a icon then lets set it for the command
288 OUString sCommand;
289 for ( std::vector< css::beans::PropertyValue >::iterator it = props.begin(); it != props.end(); ++it )
291 if ( it->Name == "CommandURL" )
292 it->Value >>= sCommand;
294 if ( TBCBitMap* pIcon = pSpecificInfo->getIcon() )
296 // Without a command openoffice won't display the icon
297 if ( !sCommand.isEmpty() )
299 BitmapEx aBitEx( pIcon->getBitMap() );
300 if ( pSpecificInfo->getIconMask() )
301 // according to the spec:
302 // "the iconMask is white in all the areas in which the icon is
303 // displayed as transparent and is black in all other areas."
304 aBitEx = BitmapEx( aBitEx.GetBitmap(), pSpecificInfo->getIconMask()->getBitMap().CreateMask( Color( COL_WHITE ) ) );
306 Graphic aGraphic( aBitEx );
307 helper.addIcon( aGraphic.GetXGraphic(), sCommand );
310 else if ( pSpecificInfo->getBtnFace() )
313 OUString sBuiltInCmd = helper.MSOTCIDToOOCommand( *pSpecificInfo->getBtnFace() );
314 if ( !sBuiltInCmd.isEmpty() )
316 uno::Sequence< OUString> sCmds(1);
317 sCmds[ 0 ] = sBuiltInCmd;
318 uno::Reference< ui::XImageManager > xImageManager( helper.getAppCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
319 // 0 = default image size
320 uno::Sequence< uno::Reference< graphic::XGraphic > > sImages = xImageManager->getImages( 0, sCmds );
321 if ( sImages.getLength() && sImages[0].is() )
322 helper.addIcon( sImages[0], sCommand );
327 else if ( rHeader.getTct() == 0x0a )
329 aProp.Name = OUString("CommandURL") ;
330 OUString sMenuBar("private:resource/menubar/");
332 TBCMenuSpecific* pMenu = getMenuSpecific();
333 if ( pMenu )
334 aProp.Value = uno::makeAny( sMenuBar += pMenu->Name() ); // name of popup
335 nStyle |= ui::ItemStyle::DROP_DOWN;
336 props.push_back( aProp );
339 short icontext = ( rHeader.getTbct() & 0x03 );
340 aProp.Name = OUString("Style") ;
341 if ( bIsMenuBar )
343 nStyle |= ui::ItemStyle::TEXT;
344 if ( !icontext || icontext == 0x3 )
345 // Text And image
346 nStyle |= ui::ItemStyle::ICON;
348 else
350 if ( ( icontext & 0x02 ) == 0x02 )
351 nStyle |= ui::ItemStyle::TEXT;
352 if ( !icontext || ( icontext & 0x03 ) == 0x03 )
353 nStyle |= ui::ItemStyle::ICON;
355 aProp.Value <<= nStyle;
356 props.push_back( aProp );
357 return true; // just ignore
360 void TBCData::Print( FILE* fp )
362 Indent a;
363 indent_printf(fp,"[ 0x%x ] TBCData -- dump\n", nOffSet );
364 indent_printf(fp," dumping controlGeneralInfo( TBCGeneralInfo )\n");
365 controlGeneralInfo.Print( fp );
366 //if ( rHeader.getTct() == 1 )
367 if ( controlSpecificInfo.get() )
369 indent_printf(fp," dumping controlSpecificInfo( TBCBSpecificInfo )\n");
370 controlSpecificInfo->Print( fp );
374 bool
375 WString::Read( SvStream &rS )
377 OSL_TRACE("WString::Read() stream pos 0x%x", rS.Tell() );
378 nOffSet = rS.Tell();
379 sal_uInt8 nChars = 0;
380 rS >> nChars;
381 sString = read_uInt16s_ToOUString(rS, nChars);
382 return true;
385 TBCExtraInfo::TBCExtraInfo() : idHelpContext( 0 )
389 bool
390 TBCExtraInfo::Read( SvStream &rS )
392 OSL_TRACE("TBCExtraInfo::Read() stream pos 0x%x", rS.Tell() );
393 nOffSet = rS.Tell();
394 if( !wstrHelpFile.Read( rS ) )
395 return false;
397 rS >> idHelpContext;
399 if ( !wstrTag.Read( rS ) || !wstrOnAction.Read( rS ) || !wstrParam.Read( rS ) )
400 return false;
402 rS >> tbcu >> tbmg;
403 return true;
406 void
407 TBCExtraInfo::Print( FILE* fp )
409 Indent a;
410 indent_printf( fp, "[ 0x%x ] TBCExtraInfo -- dump\n", nOffSet );
411 indent_printf( fp, " wstrHelpFile %s\n",
412 OUStringToOString( wstrHelpFile.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
413 indent_printf( fp, " idHelpContext 0x%x\n", static_cast< unsigned int >( idHelpContext ) );
414 indent_printf( fp, " wstrTag %s\n",
415 OUStringToOString( wstrTag.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
416 indent_printf( fp, " wstrOnAction %s\n",
417 OUStringToOString( wstrOnAction.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
418 indent_printf( fp, " wstrParam %s\n",
419 OUStringToOString( wstrParam.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
420 indent_printf( fp, " tbcu 0x%x\n", tbcu );
421 indent_printf( fp, " tbmg 0x%x\n", tbmg );
425 OUString
426 TBCExtraInfo::getOnAction()
428 return wstrOnAction.getString();
431 TBCGeneralInfo::TBCGeneralInfo() : bFlags( 0 )
435 bool TBCGeneralInfo::Read( SvStream &rS )
437 OSL_TRACE("TBCGeneralInfo::Read() stream pos 0x%x", rS.Tell() );
438 nOffSet = rS.Tell();
439 rS >> bFlags;
441 if ( ( bFlags & 0x1 ) && !customText.Read( rS ) )
442 return false;
443 if ( ( bFlags & 0x2 ) && ( !descriptionText.Read( rS ) || !tooltip.Read( rS ) ) )
444 return false;
445 if ( ( bFlags & 0x4 ) && !extraInfo.Read( rS ) )
446 return false;
447 return true;
450 void
451 TBCGeneralInfo::Print( FILE* fp )
453 Indent a;
454 indent_printf( fp, "[ 0x%x ] TBCGeneralInfo -- dump\n", nOffSet );
455 indent_printf( fp, " bFlags 0x%x\n", bFlags );
456 indent_printf( fp, " customText %s\n",
457 OUStringToOString( customText.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
458 indent_printf( fp, " description %s\n",
459 OUStringToOString( descriptionText.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
460 indent_printf( fp, " tooltip %s\n",
461 OUStringToOString( tooltip.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
462 if ( bFlags & 0x4 )
463 extraInfo.Print( fp );
466 bool
467 TBCGeneralInfo::ImportToolBarControlData( CustomToolBarImportHelper& helper, std::vector< beans::PropertyValue >& sControlData )
469 if ( ( bFlags & 0x5 ) )
471 beans::PropertyValue aProp;
472 // probably access to the header would be a better test than seeing if there is an action, e.g.
473 // if ( rHeader.getTct() == 0x01 && rHeader.getTcID() == 0x01 ) // not defined, probably this is a command
474 if ( !extraInfo.getOnAction().isEmpty() )
476 aProp.Name = OUString("CommandURL");
477 ooo::vba::MacroResolvedInfo aMacroInf = ooo::vba::resolveVBAMacro( &helper.GetDocShell(), extraInfo.getOnAction(), true );
478 if ( aMacroInf.mbFound )
479 aProp.Value = helper.createCommandFromMacro( aMacroInf.msResolvedMacro );
480 else
481 aProp.Value <<= OUString( "UnResolvedMacro[" ).concat( extraInfo.getOnAction() ).concat( OUString( "]" ) );
482 sControlData.push_back( aProp );
485 aProp.Name = OUString("Label");
486 aProp.Value = uno::makeAny( customText.getString().replace('&','~') );
487 sControlData.push_back( aProp );
489 aProp.Name = OUString("Type");
490 aProp.Value = uno::makeAny( ui::ItemType::DEFAULT );
491 sControlData.push_back( aProp );
493 aProp.Name = OUString("Tooltip");
494 aProp.Value = uno::makeAny( tooltip.getString() );
495 sControlData.push_back( aProp );
497 aToolbarItem(0).Name = "CommandURL" wstrOnAction
498 aToolbarItem(0).Value = Command
499 aToolbarItem(1).Name = "Label" customText
500 aToolbarItem(1).Value = Label
501 aToolbarItem(2).Name = "Type"
502 aToolbarItem(2).Value = 0
503 aToolbarItem(3).Name = "Visible"
504 aToolbarItem(3).Value = true
507 return true;
510 TBCMenuSpecific::TBCMenuSpecific() : tbid( 0 )
514 bool
515 TBCMenuSpecific::Read( SvStream &rS)
517 OSL_TRACE("TBCMenuSpecific::Read() stream pos 0x%x", rS.Tell() );
518 nOffSet = rS.Tell();
519 rS >> tbid;
520 if ( tbid == 1 )
522 name.reset( new WString() );
523 return name->Read( rS );
525 return true;
528 void
529 TBCMenuSpecific::Print( FILE* fp )
531 Indent a;
532 indent_printf( fp, "[ 0x%x ] TBCMenuSpecific -- dump\n", nOffSet );
533 indent_printf( fp, " tbid 0x%x\n", static_cast< unsigned int >( tbid ) );
534 if ( tbid == 1 )
535 indent_printf( fp, " name %s\n", OUStringToOString( name->getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
539 OUString TBCMenuSpecific::Name()
541 OUString aName;
542 if ( name.get() )
543 aName = name->getString();
544 return aName;
546 TBCBSpecific::TBCBSpecific() : bFlags( 0 )
550 bool TBCBSpecific::Read( SvStream &rS)
552 OSL_TRACE("TBCBSpecific::Read() stream pos 0x%x", rS.Tell() );
553 nOffSet = rS.Tell();
554 rS >> bFlags;
556 // bFlags determines what we read next
558 // bFlags.fCustomBitmap = 1 ( 0x8 ) set
559 if ( bFlags & 0x8 )
561 icon.reset( new TBCBitMap() );
562 iconMask.reset( new TBCBitMap() );
563 if ( !icon->Read( rS ) || !iconMask->Read( rS ) )
564 return false;
566 // if bFlags.fCustomBtnFace = 1 ( 0x10 )
567 if ( bFlags & 0x10 )
569 iBtnFace.reset( new sal_uInt16 );
570 rS >> *iBtnFace.get();
572 // if bFlags.fAccelerator equals 1 ( 0x04 )
573 if ( bFlags & 0x04 )
575 wstrAcc.reset( new WString() );
576 return wstrAcc->Read( rS );
578 return true;
582 void TBCBSpecific::Print( FILE* fp )
584 Indent a;
585 indent_printf( fp, "[ 0x%x ] TBCBSpecific -- dump\n", nOffSet );
586 indent_printf( fp, " bFlags 0x%x\n", bFlags );
587 bool bResult = ( icon.get() != NULL );
588 indent_printf( fp, " icon present? %s\n", bResult ? "true" : "false" );
589 if ( bResult )
591 Indent b;
592 indent_printf( fp, " icon: \n");
593 icon->Print( fp ); // will dump size
595 bResult = ( iconMask.get() != NULL );
596 indent_printf( fp, " icon mask present? %s\n", bResult ? "true" : "false" );
597 if ( bResult )
599 Indent c;
600 indent_printf( fp, " icon mask: \n");
601 iconMask->Print( fp ); // will dump size
603 if ( iBtnFace.get() )
605 indent_printf( fp, " iBtnFace 0x%x\n", *(iBtnFace.get()) );
607 bResult = ( wstrAcc.get() != NULL );
608 indent_printf( fp, " option string present? %s ->%s<-\n", bResult ? "true" : "false", bResult ? OUStringToOString( wstrAcc->getString(), RTL_TEXTENCODING_UTF8 ).getStr() : "N/A" );
611 TBCBitMap*
612 TBCBSpecific::getIcon()
614 return icon.get();
617 TBCBitMap*
618 TBCBSpecific::getIconMask()
620 return iconMask.get();
623 TBCComboDropdownSpecific::TBCComboDropdownSpecific(const TBCHeader& header )
625 if ( header.getTcID() == 0x01 )
626 data.reset( new TBCCDData() );
629 bool TBCComboDropdownSpecific::Read( SvStream &rS)
631 nOffSet = rS.Tell();
632 if ( data.get() )
633 return data->Read( rS );
634 return true;
637 void TBCComboDropdownSpecific::Print( FILE* fp)
639 Indent a;
640 indent_printf(fp,"[ 0x%x ] TBCComboDropdownSpecific -- dump\n", nOffSet );
641 if ( data.get() )
642 data->Print( fp );
643 else
644 indent_printf(fp," no data " );
647 TBCCDData::TBCCDData() : cwstrItems( 0 )
648 ,iSel( 0 )
649 ,cLines( 0 )
650 ,dxWidth( 0 )
654 TBCCDData::~TBCCDData()
658 bool TBCCDData::Read( SvStream &rS)
660 nOffSet = rS.Tell();
661 rS >> cwstrItems;
662 if ( cwstrItems )
664 for( sal_Int32 index=0; index < cwstrItems; ++index )
666 WString aString;
667 if ( !aString.Read( rS ) )
668 return false;
669 wstrList.push_back( aString );
672 rS >> cwstrMRU >> iSel >> cLines >> dxWidth;
674 return wstrEdit.Read( rS );
677 void TBCCDData::Print( FILE* fp)
679 Indent a;
680 indent_printf(fp,"[ 0x%x ] TBCCDData -- dump\n", nOffSet );
681 indent_printf(fp," cwstrItems items in wstrList 0x%d\n", cwstrItems);
682 for ( sal_Int32 index=0; index < cwstrItems; ++index )
684 Indent b;
685 indent_printf(fp, " wstrList[%d] %s", static_cast< int >( index ), OUStringToOString( wstrList[index].getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
687 indent_printf(fp," cwstrMRU num most recently used string 0x%d item\n", cwstrMRU);
688 indent_printf(fp," iSel index of selected item 0x%d item\n", iSel);
689 indent_printf(fp," cLines num of suggested lines to display 0x%d", cLines);
690 indent_printf(fp," dxWidth width in pixels 0x%d", dxWidth);
691 indent_printf(fp," wstrEdit %s", OUStringToOString( wstrEdit.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
694 TBCBitMap::TBCBitMap() : cbDIB( 0 )
698 TBCBitMap::~TBCBitMap()
702 // #FIXME Const-ness
703 Bitmap&
704 TBCBitMap::getBitMap()
706 return mBitMap;
709 bool TBCBitMap::Read( SvStream& rS)
711 OSL_TRACE("TBCBitMap::Read() stream pos 0x%x", rS.Tell() );
712 nOffSet = rS.Tell();
713 rS >> cbDIB;
714 // cbDIB = sizeOf(biHeader) + sizeOf(colors) + sizeOf(bitmapData) + 10
715 return mBitMap.Read( rS, sal_False, sal_True );
718 void TBCBitMap::Print( FILE* fp )
720 Indent a;
721 indent_printf(fp, "[ 0x%x ] TBCBitMap -- dump\n", nOffSet );
722 indent_printf(fp, " TBCBitMap size of bitmap data 0x%x\n", static_cast< unsigned int > ( cbDIB ) );
725 TB::TB() : bSignature(0x2),
726 bVersion(0x1),
727 cCL(0),
728 ltbid( 0x1 ),
729 ltbtr(0),
730 cRowsDefault( 0 ),
731 bFlags( 0 )
735 bool TB::Read(SvStream &rS)
737 OSL_TRACE("TB::Read() stream pos 0x%x", rS.Tell() );
738 nOffSet = rS.Tell();
739 rS >> bSignature >> bVersion >> cCL >> ltbid >> ltbtr >> cRowsDefault >> bFlags;
740 name.Read( rS );
741 return true;
745 bool TB::IsEnabled()
747 return ( bFlags & 0x01 ) != 0x01;
750 void TB::Print( FILE* fp )
752 Indent a;
753 indent_printf(fp,"[ 0x%x ] TB -- dump\n", nOffSet );
754 indent_printf(fp," bSignature 0x%x\n", bSignature );
755 indent_printf(fp," bVersion 0x%x\n", bVersion );
756 indent_printf(fp," cCL 0x%x\n", cCL );
757 indent_printf(fp," ltbid 0x%x\n", ltbid );
758 indent_printf(fp," ltbtr 0x%x\n", ltbtr );
759 indent_printf(fp," cRowsDefault 0x%x\n", cRowsDefault );
760 indent_printf(fp," bFlags 0x%x\n", bFlags );
761 indent_printf(fp, " name %s\n", OUStringToOString( name.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
764 TBVisualData::TBVisualData() : tbds(0), tbv(0), tbdsDock(0), iRow(0)
768 bool TBVisualData::Read( SvStream& rS )
770 OSL_TRACE("TBVisualData::Read() stream pos 0x%x", rS.Tell() );
771 nOffSet = rS.Tell();
772 rS >> tbds >> tbv >> tbdsDock >> iRow;
773 rcDock.Read( rS );
774 rcFloat.Read( rS );
775 return true;
778 void SRECT::Print( FILE* fp )
780 Indent a;
781 indent_printf( fp, " left 0x%x\n", left);
782 indent_printf( fp, " top 0x%x\n", top);
783 indent_printf( fp, " right 0x%x\n", right);
784 indent_printf( fp, " bottom 0x%x\n", bottom);
787 void TBVisualData::Print( FILE* fp )
789 Indent a;
790 indent_printf( fp, "[ 0x%x ] TBVisualData -- dump\n", nOffSet );
791 indent_printf( fp, " tbds 0x%x\n", tbds);
792 indent_printf( fp, " tbv 0x%x\n", tbv);
793 indent_printf( fp, " tbdsDoc 0x%x\n", tbdsDock);
794 indent_printf( fp, " iRow 0x%x\n", iRow);
795 rcDock.Print( fp );
796 rcFloat.Print( fp );
799 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */