LibreOffice Module filter (master) 1
mstoolbar.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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
10#include <sal/config.h>
11
14#include <o3tl/safeint.hxx>
15#include <sal/log.hxx>
16#include <com/sun/star/beans/XPropertySet.hpp>
17#include <com/sun/star/container/XIndexContainer.hpp>
18#include <com/sun/star/frame/XModel.hpp>
19#include <com/sun/star/ui/XUIConfigurationManager.hpp>
20#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
21#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
22#include <com/sun/star/ui/XImageManager.hpp>
23#include <com/sun/star/ui/ImageType.hpp>
24#include <com/sun/star/ui/ItemType.hpp>
25#include <com/sun/star/ui/ItemStyle.hpp>
26#include <utility>
27#include <vcl/dibtools.hxx>
28#include <vcl/graph.hxx>
29#include <vcl/bitmapex.hxx>
30#include <sfx2/objsh.hxx>
32#include <vcl/svapp.hxx>
33#include <vcl/window.hxx>
34
35using namespace com::sun::star;
36
37int TBBase::nIndent = 0;
38
39void CustomToolBarImportHelper::ScaleImage( uno::Reference< graphic::XGraphic >& xGraphic, tools::Long nNewSize )
40{
41 Graphic aGraphic( xGraphic );
42 Size aSize = aGraphic.GetSizePixel();
43 if ( aSize.Height() && ( aSize.Height() == aSize.Width() ) )
44 {
45 Graphic aImage(xGraphic);
46 if ( aSize.Height() != nNewSize )
47 {
48 BitmapEx aBitmap = aImage.GetBitmapEx();
49 BitmapEx aBitmapex = BitmapEx::AutoScaleBitmap(aBitmap, nNewSize );
50 aImage = Graphic(aBitmapex);
51 xGraphic = aImage.GetXGraphic();
52 }
53 }
54}
55
57{
58 for (auto const& concommand : iconcommands)
59 {
60 uno::Sequence<OUString> commands { concommand.sCommand };
61 uno::Sequence< uno::Reference< graphic::XGraphic > > images { concommand.image };
62 auto pimages = images.getArray();
63
64 uno::Reference< ui::XImageManager > xImageManager( getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
65 sal_uInt16 nColor = ui::ImageType::COLOR_NORMAL;
66
68 if ( topwin != nullptr && topwin->GetBackgroundColor().IsDark() )
69 nColor = css::ui::ImageType::COLOR_HIGHCONTRAST;
70
71 ScaleImage( pimages[ 0 ], 16 );
72 xImageManager->replaceImages( ui::ImageType::SIZE_DEFAULT | nColor, commands, images );
73 ScaleImage( pimages[ 0 ], 26 );
74 xImageManager->replaceImages( ui::ImageType::SIZE_LARGE | nColor, commands, images );
75 }
76}
77
78void CustomToolBarImportHelper::addIcon( const uno::Reference< graphic::XGraphic >& xImage, const OUString& sString )
79{
80 iconcontrolitem item;
81 item.sCommand = sString;
82 item.image = xImage;
83 iconcommands.push_back( item );
84}
85
86CustomToolBarImportHelper::CustomToolBarImportHelper( SfxObjectShell& rDocShell, const css::uno::Reference< css::ui::XUIConfigurationManager>& rxAppCfgMgr ) : mrDocSh( rDocShell )
87{
88 m_xCfgSupp.set( mrDocSh.GetModel(), uno::UNO_QUERY_THROW );
89 m_xAppCfgMgr.set( rxAppCfgMgr, uno::UNO_SET_THROW );
90}
91
92uno::Reference< ui::XUIConfigurationManager >
94{
95 return m_xCfgSupp->getUIConfigurationManager();
96}
97
98
101{
102 //"vnd.sun.star.script:Standard.Module1.Main?language=Basic&location=document"
103 // create script url
104 OUString scriptURL
105 = OUString::Concat("vnd.sun.star.script:") + sCmd + "?language=Basic&location=document";
106 return uno::Any( scriptURL );
107}
108
110{
111 OUString result;
113 result = pMSOCmdConvertor->MSOCommandToOOCommand( msoCmd );
114 return result;
115}
116
118{
119 OUString result;
121 result = pMSOCmdConvertor->MSOTCIDToOOCommand( msoTCID );
122 return result;
123}
124
125bool
126CustomToolBarImportHelper::createMenu( const OUString& rName, const uno::Reference< container::XIndexAccess >& xMenuDesc )
127{
128 bool bRes = true;
129 try
130 {
131 uno::Reference< ui::XUIConfigurationManager > xCfgManager( getCfgManager() );
132 OUString sMenuBar = "private:resource/menubar/" + rName;
133 uno::Reference< container::XIndexContainer > xPopup( xCfgManager->createSettings(), uno::UNO_SET_THROW );
134 uno::Reference< beans::XPropertySet > xProps( xPopup, uno::UNO_QUERY_THROW );
135 // set name for menubar
136 xProps->setPropertyValue("UIName", uno::Any( rName ) );
137 if ( xPopup.is() )
138 {
139 uno::Sequence< beans::PropertyValue > aPopupMenu{
140 comphelper::makePropertyValue("CommandURL", "vnd.openoffice.org:" + rName),
141 comphelper::makePropertyValue("Label", rName),
142 comphelper::makePropertyValue("ItemDescriptorContainer", xMenuDesc),
143 comphelper::makePropertyValue("Type", sal_Int32( 0 ))
144 };
145
146 xPopup->insertByIndex( xPopup->getCount(), uno::Any( aPopupMenu ) );
147 xCfgManager->insertSettings( sMenuBar, xPopup );
148 uno::Reference< ui::XUIConfigurationPersistence > xPersistence( xCfgManager, uno::UNO_QUERY_THROW );
149 xPersistence->store();
150 }
151 }
152 catch( const uno::Exception& )
153 {
154 bRes = false;
155 }
156 return bRes;
157}
158
159#ifdef DEBUG_FILTER_MSTOOLBAR
160void TBBase::indent_printf( FILE* fp, const char* format, ... )
161{
162 va_list ap;
163 va_start ( ap, format );
164
165 // indent nIndent spaces
166 for ( int i=0; i<nIndent; ++i)
167 fprintf(fp," ");
168 // append the rest of the message
169 vfprintf( fp, format, ap );
170 va_end( ap );
171}
172#endif
173
175 : bSignature(0x3)
176 , bVersion(0x01)
177 , bFlagsTCR(0)
178 , tct(0x1) // default to Button
179 , tcid(0)
180 , tbct(0)
181 , bPriority(0)
182{
183}
184
186{
187}
188
190{
191 SAL_INFO("filter.ms", "stream pos " << rS.Tell());
192 nOffSet = rS.Tell();
194 // bit 4 ( from lsb )
195 if ( bFlagsTCR & 0x10 )
196 {
197 width = std::make_shared<sal_uInt16>();
198 height = std::make_shared<sal_uInt16>();
199 rS.ReadUInt16( *width ).ReadUInt16( *height );
200 }
201 return true;
202}
203
204#ifdef DEBUG_FILTER_MSTOOLBAR
205void TBCHeader::Print( FILE* fp )
206{
207 Indent a;
208 indent_printf(fp,"[ 0x%x ] TBCHeader -- dump\n", nOffSet );
209 indent_printf(fp," bSignature 0x%x\n", bSignature );
210 indent_printf(fp," bVersion 0x%x\n", bVersion );
211 indent_printf(fp," bFlagsTCR 0x%x\n", bFlagsTCR );
212 indent_printf(fp," tct 0x%x\n", tct );
213 indent_printf(fp," tcid 0x%x\n", tcid );
214 indent_printf(fp," tbct 0x%x\n", static_cast< unsigned int >( tbct ));
215 indent_printf(fp," bPriority 0x%x\n", bPriority );
216 if ( width.get() )
217 indent_printf(fp," width %d(0x%x)\n", *width, *width);
218 if ( height.get() )
219 indent_printf(fp," height %d(0x%x)\n", *height, *height);
220}
221#endif
222
223TBCData::TBCData( TBCHeader Header ) : rHeader(std::move( Header ))
224{
225}
226
228{
229 SAL_INFO("filter.ms", "stream pos " << rS.Tell());
230 nOffSet = rS.Tell();
231 if ( !controlGeneralInfo.Read(rS) /*|| !controlSpecificInfo.Read(rS)*/ )
232 return false;
233 switch ( rHeader.getTct() )
234 {
235 case 0x01: // (Button control)
236 case 0x10: // (ExpandingGrid control)
237 controlSpecificInfo = std::make_shared<TBCBSpecific>();
238 break;
239 case 0x0A: // (Popup control)
240 case 0x0C: // (ButtonPopup control)
241 case 0x0D: // (SplitButtonPopup control)
242 case 0x0E: // (SplitButtonMRUPopup control)
243 controlSpecificInfo = std::make_shared<TBCMenuSpecific>();
244 break;
245 case 0x02: // (Edit control)
246 case 0x04: // (ComboBox control)
247 case 0x14: // (GraphicCombo control)
248 case 0x03: // (DropDown control)
249 case 0x06: // (SplitDropDown control)
250 case 0x09: // (GraphicDropDown control)
251 controlSpecificInfo = std::make_shared<TBCComboDropdownSpecific>( rHeader );
252 break;
253 default:
254 break;
255 }
257 return controlSpecificInfo->Read( rS );
258 //#FIXME I need to be able to handle different controlSpecificInfo types.
259 return true;
260}
261
263{
264 TBCMenuSpecific* pMenu = dynamic_cast< TBCMenuSpecific* >( controlSpecificInfo.get() );
265 return pMenu;
266}
267void TBCData::ImportToolBarControl( CustomToolBarImportHelper& helper, std::vector< css::beans::PropertyValue >& props, bool& bBeginGroup, bool bIsMenuBar )
268{
269 sal_uInt16 nStyle = 0;
270 bBeginGroup = rHeader.isBeginGroup();
272 beans::PropertyValue aProp;
273 aProp.Name = "Visible";
274 aProp.Value <<= rHeader.isVisible(); // where is the visible attribute stored
275 props.push_back( aProp );
276 if ( rHeader.getTct() == 0x01
277 || rHeader.getTct() == 0x10 )
278 {
279 TBCBSpecific* pSpecificInfo = dynamic_cast< TBCBSpecific* >( controlSpecificInfo.get() );
280 if ( pSpecificInfo )
281 {
282 // if we have an icon then lets set it for the command
283 OUString sCommand;
284 for (auto const& property : props)
285 {
286 // TODO JNA : couldn't we break if we find CommandURL to avoid keeping on the loop?
287 if ( property.Name == "CommandURL" )
288 property.Value >>= sCommand;
289 }
290 if ( TBCBitMap* pIcon = pSpecificInfo->getIcon() )
291 {
292 // Without a command openoffice won't display the icon
293 if ( !sCommand.isEmpty() )
294 {
295 BitmapEx aBitEx( pIcon->getBitMap() );
296 TBCBitMap* pIconMask = pSpecificInfo->getIconMask();
297 if (pIconMask)
298 {
299 const Bitmap& rMaskBase(pIconMask->getBitMap().GetBitmap());
300 Size aMaskSize = rMaskBase.GetSizePixel();
301 if (aMaskSize.Width() && aMaskSize.Height())
302 {
303 // according to the spec:
304 // "the iconMask is white in all the areas in which the icon is
305 // displayed as transparent and is black in all other areas."
306 aBitEx = BitmapEx(aBitEx.GetBitmap(), rMaskBase.CreateMask(COL_WHITE));
307 }
308 }
309
310 Graphic aGraphic( aBitEx );
311 helper.addIcon( aGraphic.GetXGraphic(), sCommand );
312 }
313 }
314 else if ( pSpecificInfo->getBtnFace() )
315 {
316
317 OUString sBuiltInCmd = helper.MSOTCIDToOOCommand( *pSpecificInfo->getBtnFace() );
318 if ( !sBuiltInCmd.isEmpty() )
319 {
320 uno::Sequence<OUString> sCmds { sBuiltInCmd };
321 uno::Reference< ui::XImageManager > xImageManager( helper.getAppCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
322 // 0 = default image size
323 uno::Sequence< uno::Reference< graphic::XGraphic > > sImages = xImageManager->getImages( 0, sCmds );
324 if ( sImages.hasElements() && sImages[0].is() )
325 helper.addIcon( sImages[0], sCommand );
326 }
327 }
328 }
329 }
330 else if ( rHeader.getTct() == 0x0a )
331 {
332 aProp.Name = "CommandURL";
333
335 if ( pMenu )
336 {
337 OUString sMenuBar = "private:resource/menubar/" + pMenu->Name();
338 aProp.Value <<= sMenuBar; // name of popup
339 }
340 nStyle |= ui::ItemStyle::DROP_DOWN;
341 props.push_back( aProp );
342 }
343
344 short icontext = ( rHeader.getTbct() & 0x03 );
345 aProp.Name = "Style";
346 if ( bIsMenuBar )
347 {
348 nStyle |= ui::ItemStyle::TEXT;
349 if ( !icontext || icontext == 0x3 )
350 // Text And image
351 nStyle |= ui::ItemStyle::ICON;
352 }
353 else
354 {
355 if ( ( icontext & 0x02 ) == 0x02 )
356 nStyle |= ui::ItemStyle::TEXT;
357 if ( !icontext || ( icontext & 0x03 ) == 0x03 )
358 nStyle |= ui::ItemStyle::ICON;
359 }
360 aProp.Value <<= nStyle;
361 props.push_back( aProp );
362}
363
364#ifdef DEBUG_FILTER_MSTOOLBAR
365void TBCData::Print( FILE* fp )
366{
367 Indent a;
368 indent_printf(fp,"[ 0x%x ] TBCData -- dump\n", nOffSet );
369 indent_printf(fp," dumping controlGeneralInfo( TBCGeneralInfo )\n");
370 controlGeneralInfo.Print( fp );
371 //if ( rHeader.getTct() == 1 )
372 if ( controlSpecificInfo.get() )
373 {
374 indent_printf(fp," dumping controlSpecificInfo( TBCBSpecificInfo )\n");
375 controlSpecificInfo->Print( fp );
376 }
377}
378#endif
379
380bool
382{
383 SAL_INFO("filter.ms", "stream pos " << rS.Tell());
384 nOffSet = rS.Tell();
385 sal_uInt8 nChars = 0;
386 rS.ReadUChar( nChars );
387 sString = read_uInt16s_ToOUString(rS, nChars);
388 return true;
389}
390
392 : idHelpContext(0)
393 , tbcu(0)
394 , tbmg(0)
395{
396}
397
398bool
400{
401 SAL_INFO("filter.ms", "stream pos " << rS.Tell());
402 nOffSet = rS.Tell();
403 if( !wstrHelpFile.Read( rS ) )
404 return false;
405
407
408 if ( !wstrTag.Read( rS ) || !wstrOnAction.Read( rS ) || !wstrParam.Read( rS ) )
409 return false;
410
411 rS.ReadSChar( tbcu ).ReadSChar( tbmg );
412 return true;
413}
414
415#ifdef DEBUG_FILTER_MSTOOLBAR
416void
417TBCExtraInfo::Print( FILE* fp )
418{
419 Indent a;
420 indent_printf( fp, "[ 0x%x ] TBCExtraInfo -- dump\n", nOffSet );
421 indent_printf( fp, " wstrHelpFile %s\n",
422 OUStringToOString( wstrHelpFile.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
423 indent_printf( fp, " idHelpContext 0x%x\n", static_cast< unsigned int >( idHelpContext ) );
424 indent_printf( fp, " wstrTag %s\n",
425 OUStringToOString( wstrTag.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
426 indent_printf( fp, " wstrOnAction %s\n",
427 OUStringToOString( wstrOnAction.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
428 indent_printf( fp, " wstrParam %s\n",
429 OUStringToOString( wstrParam.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
430 indent_printf( fp, " tbcu 0x%x\n", tbcu );
431 indent_printf( fp, " tbmg 0x%x\n", tbmg );
432}
433#endif
434
435OUString const &
437{
438 return wstrOnAction.getString();
439}
440
442{
443}
444
446{
447 SAL_INFO("filter.ms", "stream pos " << rS.Tell());
448 nOffSet = rS.Tell();
449 rS.ReadUChar( bFlags );
450
451 if ( ( bFlags & 0x1 ) && !customText.Read( rS ) )
452 return false;
453 if ( ( bFlags & 0x2 ) && ( !descriptionText.Read( rS ) || !tooltip.Read( rS ) ) )
454 return false;
455 if ( ( bFlags & 0x4 ) && !extraInfo.Read( rS ) )
456 return false;
457 return true;
458}
459
460#ifdef DEBUG_FILTER_MSFILTER
461void
462TBCGeneralInfo::Print( FILE* fp )
463{
464 Indent a;
465 indent_printf( fp, "[ 0x%x ] TBCGeneralInfo -- dump\n", nOffSet );
466 indent_printf( fp, " bFlags 0x%x\n", bFlags );
467 indent_printf( fp, " customText %s\n",
468 OUStringToOString( customText.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
469 indent_printf( fp, " description %s\n",
470 OUStringToOString( descriptionText.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
471 indent_printf( fp, " tooltip %s\n",
472 OUStringToOString( tooltip.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
473 if ( bFlags & 0x4 )
474 extraInfo.Print( fp );
475}
476#endif
477
478void
479TBCGeneralInfo::ImportToolBarControlData( CustomToolBarImportHelper& helper, std::vector< beans::PropertyValue >& sControlData )
480{
481 if ( !(bFlags & 0x5) )
482 return;
483
484 beans::PropertyValue aProp;
485 // probably access to the header would be a better test than seeing if there is an action, e.g.
486 // if ( rHeader.getTct() == 0x01 && rHeader.getTcID() == 0x01 ) // not defined, probably this is a command
487 if ( !extraInfo.getOnAction().isEmpty() )
488 {
489 aProp.Name = "CommandURL";
491 if ( aMacroInf.mbFound )
493 else
494 aProp.Value <<= "UnResolvedMacro[" + extraInfo.getOnAction() + "]";
495 sControlData.push_back( aProp );
496 }
497
498 aProp.Name = "Label";
499 aProp.Value <<= customText.getString().replace('&','~');
500 sControlData.push_back( aProp );
501
502 aProp.Name = "Type";
503 aProp.Value <<= ui::ItemType::DEFAULT;
504 sControlData.push_back( aProp );
505
506 aProp.Name = "Tooltip";
507 aProp.Value <<= tooltip.getString();
508 sControlData.push_back( aProp );
509/*
510aToolbarItem(0).Name = "CommandURL" wstrOnAction
511aToolbarItem(0).Value = Command
512aToolbarItem(1).Name = "Label" customText
513aToolbarItem(1).Value = Label
514aToolbarItem(2).Name = "Type"
515aToolbarItem(2).Value = 0
516aToolbarItem(3).Name = "Visible"
517aToolbarItem(3).Value = true
518*/
519}
520
522{
523}
524
525bool
527{
528 SAL_INFO("filter.ms", "stream pos " << rS.Tell());
529 nOffSet = rS.Tell();
530 rS.ReadInt32( tbid );
531 if ( tbid == 1 )
532 {
533 name = std::make_shared<WString>();
534 return name->Read( rS );
535 }
536 return true;
537}
538
539#ifdef DEBUG_FILTER_MSFILTER
540void
541TBCMenuSpecific::Print( FILE* fp )
542{
543 Indent a;
544 indent_printf( fp, "[ 0x%x ] TBCMenuSpecific -- dump\n", nOffSet );
545 indent_printf( fp, " tbid 0x%x\n", static_cast< unsigned int >( tbid ) );
546 if ( tbid == 1 )
547 indent_printf( fp, " name %s\n", OUStringToOString( name->getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
548}
549#endif
550
552{
553 OUString aName;
554 if ( name )
555 aName = name->getString();
556 return aName;
557}
559{
560}
561
563{
564 SAL_INFO("filter.ms", "stream pos " << rS.Tell());
565 nOffSet = rS.Tell();
566 rS.ReadUChar( bFlags );
567
568 // bFlags determines what we read next
569
570 // bFlags.fCustomBitmap = 1 ( 0x8 ) set
571 if ( bFlags & 0x8 )
572 {
573 icon = std::make_shared<TBCBitMap>();
574 iconMask = std::make_shared<TBCBitMap>();
575 if ( !icon->Read( rS ) || !iconMask->Read( rS ) )
576 return false;
577 }
578 // if bFlags.fCustomBtnFace = 1 ( 0x10 )
579 if ( bFlags & 0x10 )
580 {
581 iBtnFace = std::make_shared<sal_uInt16>();
582 rS.ReadUInt16( *iBtnFace );
583 }
584 // if bFlags.fAccelerator equals 1 ( 0x04 )
585 if ( bFlags & 0x04 )
586 {
587 wstrAcc = std::make_shared<WString>();
588 return wstrAcc->Read( rS );
589 }
590 return true;
591}
592
593
594#ifdef DEBUG_FILTER_MSFILTER
595void TBCBSpecific::Print( FILE* fp )
596{
597 Indent a;
598 indent_printf( fp, "[ 0x%x ] TBCBSpecific -- dump\n", nOffSet );
599 indent_printf( fp, " bFlags 0x%x\n", bFlags );
600 bool bResult = ( icon.get() != NULL );
601 indent_printf( fp, " icon present? %s\n", bResult ? "true" : "false" );
602 if ( bResult )
603 {
604 Indent b;
605 indent_printf( fp, " icon: \n");
606 icon->Print( fp ); // will dump size
607 }
608 bResult = ( iconMask.get() != NULL );
609 indent_printf( fp, " icon mask present? %s\n", bResult ? "true" : "false" );
610 if ( bResult )
611 {
612 Indent c;
613 indent_printf( fp, " icon mask: \n");
614 iconMask->Print( fp ); // will dump size
615 }
616 if ( iBtnFace.get() )
617 {
618 indent_printf( fp, " iBtnFace 0x%x\n", *iBtnFace );
619 }
620 bResult = ( wstrAcc.get() != NULL );
621 indent_printf( fp, " option string present? %s ->%s<-\n", bResult ? "true" : "false", bResult ? OUStringToOString( wstrAcc->getString(), RTL_TEXTENCODING_UTF8 ).getStr() : "N/A" );
622}
623#endif
624
627{
628 return icon.get();
629}
630
633{
634 return iconMask.get();
635}
636
638{
639 if ( header.getTcID() == 0x01 )
640 data = std::make_shared<TBCCDData>();
641}
642
644{
645 nOffSet = rS.Tell();
646 if ( data )
647 return data->Read( rS );
648 return true;
649}
650
651#ifdef DEBUG_FILTER_MSFILTER
652void TBCComboDropdownSpecific::Print( FILE* fp)
653{
654 Indent a;
655 indent_printf(fp,"[ 0x%x ] TBCComboDropdownSpecific -- dump\n", nOffSet );
656 if ( data.get() )
657 data->Print( fp );
658 else
659 indent_printf(fp," no data " );
660}
661#endif
662
664 : cwstrItems(0)
665 , cwstrMRU(0)
666 , iSel(0)
667 , cLines(0)
668 , dxWidth(0)
669{
670}
671
673{
674}
675
677{
678 nOffSet = rS.Tell();
679 rS.ReadInt16( cwstrItems );
680 if (cwstrItems > 0)
681 {
682 auto nItems = o3tl::make_unsigned(cwstrItems);
683 //each WString is at least one byte
684 if (rS.remainingSize() < nItems)
685 return false;
686 for (decltype(nItems) index = 0; index < nItems; ++index)
687 {
688 WString aString;
689 if ( !aString.Read( rS ) )
690 return false;
691 wstrList.push_back( aString );
692 }
693 }
695
696 return wstrEdit.Read( rS );
697}
698
699#ifdef DEBUG_FILTER_MSFILTER
700void TBCCDData::Print( FILE* fp)
701{
702 Indent a;
703 indent_printf(fp,"[ 0x%x ] TBCCDData -- dump\n", nOffSet );
704 indent_printf(fp," cwstrItems items in wstrList %d\n", cwstrItems);
705 for ( sal_Int32 index=0; index < cwstrItems; ++index )
706 {
707 Indent b;
708 indent_printf(fp, " wstrList[%d] %s", static_cast< int >( index ), OUStringToOString( wstrList[index].getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
709 }
710 indent_printf(fp," cwstrMRU num most recently used string %d item\n", cwstrMRU);
711 indent_printf(fp," iSel index of selected item %d item\n", iSel);
712 indent_printf(fp," cLines num of suggested lines to display %d", cLines);
713 indent_printf(fp," dxWidth width in pixels %d", dxWidth);
714 indent_printf(fp," wstrEdit %s", OUStringToOString( wstrEdit.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
715}
716#endif
717
719{
720}
721
723{
724}
725
727{
728 SAL_INFO("filter.ms", "stream pos " << rS.Tell());
729 nOffSet = rS.Tell();
730 rS.ReadInt32( cbDIB );
731 // cbDIB = sizeOf(biHeader) + sizeOf(colors) + sizeOf(bitmapData) + 10
732 return ReadDIBBitmapEx(mBitMap, rS, false, true);
733}
734
735#ifdef DEBUG_FILTER_MSTOOLBAR
736void TBCBitMap::Print( FILE* fp )
737{
738 Indent a;
739 indent_printf(fp, "[ 0x%x ] TBCBitMap -- dump\n", nOffSet );
740 indent_printf(fp, " TBCBitMap size of bitmap data 0x%x\n", static_cast< unsigned int > ( cbDIB ) );
741}
742#endif
743
744TB::TB() : bSignature(0x2),
745bVersion(0x1),
746cCL(0),
747ltbid( 0x1 ),
748ltbtr(0),
749cRowsDefault( 0 ),
750bFlags( 0 )
751{
752}
753
755{
756 SAL_INFO("filter.ms", "stream pos " << rS.Tell());
757 nOffSet = rS.Tell();
759 name.Read( rS );
760 return true;
761
762}
763
764bool TB::IsEnabled() const
765{
766 return ( bFlags & 0x01 ) != 0x01;
767}
768
769#ifdef DEBUG_FILTER_MSTOOLBAR
770void TB::Print( FILE* fp )
771{
772 Indent a;
773 indent_printf(fp,"[ 0x%x ] TB -- dump\n", nOffSet );
774 indent_printf(fp," bSignature 0x%x\n", bSignature );
775 indent_printf(fp," bVersion 0x%x\n", bVersion );
776 indent_printf(fp," cCL 0x%x\n", cCL );
777 indent_printf(fp," ltbid 0x%x\n", ltbid );
778 indent_printf(fp," ltbtr 0x%x\n", ltbtr );
779 indent_printf(fp," cRowsDefault 0x%x\n", cRowsDefault );
780 indent_printf(fp," bFlags 0x%x\n", bFlags );
781 indent_printf(fp, " name %s\n", OUStringToOString( name.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
782}
783#endif
784
785TBVisualData::TBVisualData() : tbds(0), tbv(0), tbdsDock(0), iRow(0)
786{
787}
788
790{
791 SAL_INFO("filter.ms", "stream pos " << rS.Tell());
792 nOffSet = rS.Tell();
794 rcDock.Read( rS );
795 rcFloat.Read( rS );
796 return true;
797}
798
799#ifdef DEBUG_FILTER_MSTOOLBAR
800void SRECT::Print( FILE* fp )
801{
802 Indent a;
803 indent_printf( fp, " left 0x%x\n", left);
804 indent_printf( fp, " top 0x%x\n", top);
805 indent_printf( fp, " right 0x%x\n", right);
806 indent_printf( fp, " bottom 0x%x\n", bottom);
807}
808#endif
809
810#ifdef DEBUG_FILTER_MSTOOLBAR
811void TBVisualData::Print( FILE* fp )
812{
813 Indent a;
814 indent_printf( fp, "[ 0x%x ] TBVisualData -- dump\n", nOffSet );
815 indent_printf( fp, " tbds 0x%x\n", tbds);
816 indent_printf( fp, " tbv 0x%x\n", tbv);
817 indent_printf( fp, " tbdsDoc 0x%x\n", tbdsDock);
818 indent_printf( fp, " iRow 0x%x\n", iRow);
819 rcDock.Print( fp );
820 rcFloat.Print( fp );
821}
822#endif
823
824/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_Int8 header[]
static vcl::Window * GetActiveTopWindow()
static BitmapEx AutoScaleBitmap(BitmapEx const &aBitmap, const tools::Long aStandardSize)
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Bitmap CreateMask(const Color &rTransColor) const
Size GetSizePixel() const
bool IsDark() const
static css::uno::Any createCommandFromMacro(std::u16string_view sCmd)
Definition: mstoolbar.cxx:100
CustomToolBarImportHelper(SfxObjectShell &rDocSh, const css::uno::Reference< css::ui::XUIConfigurationManager > &rxAppCfgMgr)
Definition: mstoolbar.cxx:86
css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > m_xCfgSupp
Definition: mstoolbar.hxx:53
SfxObjectShell & mrDocSh
Definition: mstoolbar.hxx:55
static void ScaleImage(css::uno::Reference< css::graphic::XGraphic > &xGraphic, tools::Long nNewSize)
Definition: mstoolbar.cxx:39
OUString MSOTCIDToOOCommand(sal_Int16 msoTCID)
Definition: mstoolbar.cxx:117
css::uno::Reference< css::ui::XUIConfigurationManager > getCfgManager()
Definition: mstoolbar.cxx:93
OUString MSOCommandToOOCommand(sal_Int16 msoCmd)
Definition: mstoolbar.cxx:109
std::vector< iconcontrolitem > iconcommands
Definition: mstoolbar.hxx:51
void addIcon(const css::uno::Reference< css::graphic::XGraphic > &xImage, const OUString &sString)
Definition: mstoolbar.cxx:78
css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr
Definition: mstoolbar.hxx:54
std::unique_ptr< MSOCommandConvertor > pMSOCmdConvertor
Definition: mstoolbar.hxx:52
bool createMenu(const OUString &rName, const css::uno::Reference< css::container::XIndexAccess > &xMenuDesc)
Definition: mstoolbar.cxx:126
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
sal_Int16 right
Definition: mstoolbar.hxx:326
sal_Int16 bottom
Definition: mstoolbar.hxx:327
sal_Int16 left
Definition: mstoolbar.hxx:324
sal_Int16 top
Definition: mstoolbar.hxx:325
bool Read(SvStream &rS) override
Definition: mstoolbar.hxx:328
css::uno::Reference< css::frame::XModel3 > GetModel() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
sal_uInt64 Tell() const
SvStream & ReadInt16(sal_Int16 &rInt16)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
SvStream & ReadInt32(sal_Int32 &rInt32)
SvStream & ReadSChar(signed char &rChar)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
SvStream & ReadUChar(unsigned char &rChar)
sal_uInt32 nOffSet
Definition: mstoolbar.hxx:83
static int nIndent
Definition: mstoolbar.hxx:78
std::shared_ptr< TBCBitMap > icon
Definition: mstoolbar.hxx:213
std::shared_ptr< TBCBitMap > iconMask
Definition: mstoolbar.hxx:214
TBCBitMap * getIcon()
Definition: mstoolbar.cxx:626
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:562
sal_uInt8 bFlags
Definition: mstoolbar.hxx:212
std::shared_ptr< sal_uInt16 > iBtnFace
Definition: mstoolbar.hxx:215
TBCBitMap * getIconMask()
Definition: mstoolbar.cxx:632
std::shared_ptr< WString > wstrAcc
Definition: mstoolbar.hxx:216
sal_uInt16 * getBtnFace()
Definition: mstoolbar.hxx:224
BitmapEx mBitMap
Definition: mstoolbar.hxx:164
BitmapEx & getBitMap()
Definition: mstoolbar.hxx:173
virtual ~TBCBitMap() override
Definition: mstoolbar.cxx:722
sal_Int32 cbDIB
Definition: mstoolbar.hxx:163
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:726
WString wstrEdit
Definition: mstoolbar.hxx:194
virtual ~TBCCDData() override
Definition: mstoolbar.cxx:672
sal_Int16 cwstrMRU
Definition: mstoolbar.hxx:190
sal_Int16 cLines
Definition: mstoolbar.hxx:192
sal_Int16 dxWidth
Definition: mstoolbar.hxx:193
sal_Int16 cwstrItems
Definition: mstoolbar.hxx:188
sal_Int16 iSel
Definition: mstoolbar.hxx:191
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:676
std::vector< WString > wstrList
Definition: mstoolbar.hxx:189
std::shared_ptr< TBCCDData > data
Definition: mstoolbar.hxx:204
TBCComboDropdownSpecific(const TBCHeader &header)
Definition: mstoolbar.cxx:637
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:643
TBCGeneralInfo controlGeneralInfo
Definition: mstoolbar.hxx:283
TBCData(const TBCData &)=delete
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:227
void ImportToolBarControl(CustomToolBarImportHelper &, std::vector< css::beans::PropertyValue > &, bool &bBeginGroup, bool bIsMenuBar)
Definition: mstoolbar.cxx:267
TBCHeader rHeader
Definition: mstoolbar.hxx:282
std::shared_ptr< TBBase > controlSpecificInfo
Definition: mstoolbar.hxx:284
TBCMenuSpecific * getMenuSpecific()
Definition: mstoolbar.cxx:262
sal_Int8 tbmg
Definition: mstoolbar.hxx:132
OUString const & getOnAction() const
Definition: mstoolbar.cxx:436
sal_Int32 idHelpContext
Definition: mstoolbar.hxx:127
WString wstrHelpFile
Definition: mstoolbar.hxx:126
sal_Int8 tbcu
Definition: mstoolbar.hxx:131
WString wstrTag
Definition: mstoolbar.hxx:128
WString wstrOnAction
Definition: mstoolbar.hxx:129
WString wstrParam
Definition: mstoolbar.hxx:130
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:399
TBCExtraInfo extraInfo
Definition: mstoolbar.hxx:151
WString tooltip
Definition: mstoolbar.hxx:150
void ImportToolBarControlData(CustomToolBarImportHelper &, std::vector< css::beans::PropertyValue > &)
Definition: mstoolbar.cxx:479
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:445
WString descriptionText
Definition: mstoolbar.hxx:149
WString customText
Definition: mstoolbar.hxx:148
sal_uInt8 bFlags
Definition: mstoolbar.hxx:147
sal_uInt8 tct
Definition: mstoolbar.hxx:253
sal_uInt8 bFlagsTCR
Definition: mstoolbar.hxx:252
sal_uInt8 getTct() const
Definition: mstoolbar.hxx:269
bool isVisible() const
Definition: mstoolbar.hxx:271
sal_uInt8 bPriority
Definition: mstoolbar.hxx:256
virtual ~TBCHeader() override
Definition: mstoolbar.cxx:185
std::shared_ptr< sal_uInt16 > width
Definition: mstoolbar.hxx:257
sal_uInt32 getTbct() const
Definition: mstoolbar.hxx:277
std::shared_ptr< sal_uInt16 > height
Definition: mstoolbar.hxx:258
sal_Int8 bVersion
Definition: mstoolbar.hxx:251
sal_uInt16 tcid
Definition: mstoolbar.hxx:254
sal_uInt32 tbct
Definition: mstoolbar.hxx:255
bool isBeginGroup() const
Definition: mstoolbar.hxx:272
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:189
sal_Int8 bSignature
Definition: mstoolbar.hxx:250
sal_Int32 tbid
Definition: mstoolbar.hxx:178
OUString Name()
Definition: mstoolbar.cxx:551
std::shared_ptr< WString > name
Definition: mstoolbar.hxx:179
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:526
sal_Int8 tbdsDock
Definition: mstoolbar.hxx:339
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:789
sal_Int8 iRow
Definition: mstoolbar.hxx:340
sal_Int8 tbds
Definition: mstoolbar.hxx:337
sal_Int8 tbv
Definition: mstoolbar.hxx:338
sal_uInt8 bSignature
Definition: mstoolbar.hxx:300
sal_uInt16 bFlags
Definition: mstoolbar.hxx:306
sal_Int32 ltbid
Definition: mstoolbar.hxx:303
sal_uInt16 cRowsDefault
Definition: mstoolbar.hxx:305
bool IsEnabled() const
Definition: mstoolbar.cxx:764
TB()
Definition: mstoolbar.cxx:744
sal_uInt32 ltbtr
Definition: mstoolbar.hxx:304
sal_Int16 cCL
Definition: mstoolbar.hxx:302
sal_uInt8 bVersion
Definition: mstoolbar.hxx:301
WString name
Definition: mstoolbar.hxx:307
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:754
const OUString & getString() const
Definition: mstoolbar.hxx:121
bool Read(SvStream &rS) override
Definition: mstoolbar.cxx:381
OUString sString
Definition: mstoolbar.hxx:116
Color GetBackgroundColor() const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
bool VCL_DLLPUBLIC ReadDIBBitmapEx(BitmapEx &rTarget, SvStream &rIStm, bool bFileHeader=true, bool bMSOFormat=false)
OUString aName
uno_Any a
#define SAL_INFO(area, stream)
return NULL
Shape IDs per cluster in DGG atom.
OUString getString(const Any &_rAny)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
int i
Definition: gentoken.py:48
index
Definition: js2hxx.py:50
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
OUString resolveVBAMacro(SfxObjectShell const *pShell, const OUString &rLibName, const OUString &rModuleName, const OUString &rMacroName, bool bOnlyPublic, const OUString &sSkipModule)
Header
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
dictionary props
long Long
TOOLS_DLLPUBLIC OUString read_uInt16s_ToOUString(SvStream &rStrm, std::size_t nUnits)
css::uno::Reference< css::graphic::XGraphic > image
Definition: mstoolbar.hxx:49
unsigned char sal_uInt8
Any result