LCOV - code coverage report
Current view: top level - framework/source/uielement - toolbarmerger.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 33 138 23.9 %
Date: 2015-06-13 12:38:46 Functions: 4 13 30.8 %
Legend: Lines: hit not hit

          Line data    Source code
       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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <uielement/toolbarmerger.hxx>
      21             : #include <uielement/generictoolbarcontroller.hxx>
      22             : #include <framework/imageproducer.hxx>
      23             : 
      24             : #include <svtools/miscopt.hxx>
      25             : #include <comphelper/processfactory.hxx>
      26             : 
      27             : namespace framework
      28             : {
      29             : 
      30             : static const char MERGE_TOOLBAR_URL[]             = "URL";
      31             : static const char MERGE_TOOLBAR_TITLE[]           = "Title";
      32             : static const char MERGE_TOOLBAR_IMAGEID[]         = "ImageIdentifier";
      33             : static const char MERGE_TOOLBAR_CONTEXT[]         = "Context";
      34             : static const char MERGE_TOOLBAR_TARGET[]          = "Target";
      35             : static const char MERGE_TOOLBAR_CONTROLTYPE[]     = "ControlType";
      36             : static const char MERGE_TOOLBAR_WIDTH[]           = "Width";
      37             : 
      38             : static const char MERGECOMMAND_ADDAFTER[]         = "AddAfter";
      39             : static const char MERGECOMMAND_ADDBEFORE[]        = "AddBefore";
      40             : static const char MERGECOMMAND_REPLACE[]          = "Replace";
      41             : static const char MERGECOMMAND_REMOVE[]           = "Remove";
      42             : 
      43             : static const char MERGEFALLBACK_ADDLAST[]         = "AddLast";
      44             : static const char MERGEFALLBACK_ADDFIRST[]        = "AddFirst";
      45             : static const char MERGEFALLBACK_IGNORE[]          = "Ignore";
      46             : 
      47             : static const char TOOLBARCONTROLLER_BUTTON[]      = "Button";
      48             : static const char TOOLBARCONTROLLER_COMBOBOX[]    = "Combobox";
      49             : static const char TOOLBARCONTROLLER_EDIT[]        = "Editfield";
      50             : static const char TOOLBARCONTROLLER_SPINFIELD[]   = "Spinfield";
      51             : static const char TOOLBARCONTROLLER_IMGBUTTON[]   = "ImageButton";
      52             : static const char TOOLBARCONTROLLER_DROPDOWNBOX[] = "Dropdownbox";
      53             : static const char TOOLBARCONTROLLER_DROPDOWNBTN[] = "DropdownButton";
      54             : static const char TOOLBARCONTROLLER_TOGGLEDDBTN[] = "ToggleDropdownButton";
      55             : 
      56             : static const char   TOOLBOXITEM_SEPARATOR_STR[]   = "private:separator";
      57             : 
      58             : using namespace ::com::sun::star;
      59             : 
      60             : /**
      61             :  Check whether a module identifier is part of a context
      62             :  defined by a colon separated list of module identifier.
      63             : 
      64             :  @param
      65             :      rContext
      66             : 
      67             :      Describes a context string list where all contexts
      68             :      are delimited by a colon. For more information about
      69             :      the module identifier used as context strings see the
      70             :      IDL description of com::sun::star::frame::XModuleManager
      71             : 
      72             :  @param
      73             :      rModuleIdentifier
      74             : 
      75             :      A string describing a module identifier. See IDL
      76             :      description of com::sun::star::frame::XModuleManager.
      77             : 
      78             :  @result
      79             :      The result is true if the rContext is an empty string
      80             :      or rModuleIdentifier is part of the context string.
      81             : 
      82             : */
      83           0 : bool ToolBarMerger::IsCorrectContext(
      84             :     const OUString& rContext,
      85             :     const OUString& rModuleIdentifier )
      86             : {
      87           0 :     return ( rContext.isEmpty() || ( rContext.indexOf( rModuleIdentifier ) >= 0 ));
      88             : }
      89             : 
      90             : /**
      91             :  Converts a sequence, sequence of property values to
      92             :  a vector of structs.
      93             : 
      94             :  @param
      95             :      rSequence
      96             : 
      97             :      Provides a sequence, sequence of property values.
      98             : 
      99             :  @param
     100             :      rContainer
     101             : 
     102             :      A vector of AddonToolbarItems which will hold the
     103             :      conversion from the rSequence argument.
     104             : 
     105             :  @result
     106             :      The result is true if the sequence, sequence of property
     107             :      values could be converted to a vector of structs.
     108             : 
     109             : */
     110           0 : bool ToolBarMerger::ConvertSeqSeqToVector(
     111             :     const uno::Sequence< uno::Sequence< beans::PropertyValue > >& rSequence,
     112             :     AddonToolbarItemContainer& rContainer )
     113             : {
     114           0 :     sal_Int32 nLen( rSequence.getLength() );
     115           0 :     for ( sal_Int32 i = 0; i < nLen; i++ )
     116             :     {
     117           0 :         AddonToolbarItem aAddonToolbarItem;
     118           0 :         ConvertSequenceToValues( rSequence[i],
     119             :                                  aAddonToolbarItem.aCommandURL,
     120             :                                  aAddonToolbarItem.aLabel,
     121             :                                  aAddonToolbarItem.aImageIdentifier,
     122             :                                  aAddonToolbarItem.aTarget,
     123             :                                  aAddonToolbarItem.aContext,
     124             :                                  aAddonToolbarItem.aControlType,
     125           0 :                                  aAddonToolbarItem.nWidth );
     126           0 :         rContainer.push_back( aAddonToolbarItem );
     127           0 :     }
     128             : 
     129           0 :     return true;
     130             : }
     131             : 
     132             : /**
     133             :  Converts a sequence of property values to single
     134             :  values.
     135             : 
     136             :  @param
     137             :      rSequence
     138             : 
     139             :      Provides a sequence of property values.
     140             : 
     141             :  @param
     142             :      rCommandURL
     143             : 
     144             :      Contains the value of the property with
     145             :      Name="CommandURL".
     146             : 
     147             :  @param
     148             :      rLabel
     149             : 
     150             :      Contains the value of the property with
     151             :      Name="Title"
     152             : 
     153             :  @param
     154             :      rImageIdentifier
     155             : 
     156             :      Contains the value of the property with
     157             :      Name="ImageIdentifier"
     158             : 
     159             :  @param
     160             :      rTarget
     161             : 
     162             :      Contains the value of the property with
     163             :      Name="Target"
     164             : 
     165             :  @param
     166             :      rContext
     167             : 
     168             :      Contains the value of the property with
     169             :      Name="Context"
     170             : 
     171             :  @param
     172             :      rControlType
     173             : 
     174             :      Contains the value of the property with
     175             :      Name="ControlType"
     176             : 
     177             :  @result
     178             :      All possible mapping between sequence of property
     179             :      values and the single values are done.
     180             : 
     181             : */
     182       27580 : void ToolBarMerger::ConvertSequenceToValues(
     183             :     const uno::Sequence< beans::PropertyValue >& rSequence,
     184             :     OUString& rCommandURL,
     185             :     OUString& rLabel,
     186             :     OUString& rImageIdentifier,
     187             :     OUString& rTarget,
     188             :     OUString& rContext,
     189             :     OUString& rControlType,
     190             :     sal_uInt16&      rWidth )
     191             : {
     192      220640 :     for ( sal_Int32 i = 0; i < rSequence.getLength(); i++ )
     193             :     {
     194      193060 :         if ( rSequence[i].Name == MERGE_TOOLBAR_URL )
     195       27580 :             rSequence[i].Value >>= rCommandURL;
     196      165480 :         else if ( rSequence[i].Name == MERGE_TOOLBAR_TITLE )
     197       27580 :             rSequence[i].Value >>= rLabel;
     198      137900 :         else if ( rSequence[i].Name == MERGE_TOOLBAR_IMAGEID )
     199       27580 :             rSequence[i].Value >>= rImageIdentifier;
     200      110320 :         else if ( rSequence[i].Name == MERGE_TOOLBAR_CONTEXT )
     201       27580 :             rSequence[i].Value >>= rContext;
     202       82740 :         else if ( rSequence[i].Name == MERGE_TOOLBAR_TARGET )
     203       27580 :             rSequence[i].Value >>= rTarget;
     204       55160 :         else if ( rSequence[i].Name == MERGE_TOOLBAR_CONTROLTYPE )
     205       27580 :             rSequence[i].Value >>= rControlType;
     206       27580 :         else if ( rSequence[i].Name == MERGE_TOOLBAR_WIDTH )
     207             :         {
     208       27580 :             sal_Int32 aValue = 0;
     209       27580 :             rSequence[i].Value >>= aValue;
     210       27580 :             rWidth = sal_uInt16( aValue );
     211             :         }
     212             :     }
     213       27580 : }
     214             : 
     215             : /**
     216             :  Tries to find the reference point provided and delivers
     217             :  position and result of the search process.
     218             : 
     219             :  @param
     220             :      pToolbar
     221             : 
     222             :      Must be a valid pointer to a toolbar with items which
     223             :      should be searched.
     224             : 
     225             :  @param
     226             :      rReferencePoint
     227             : 
     228             :      A command URL which should be the reference point for
     229             :      the coming merge operation.
     230             : 
     231             :  @result
     232             :      Provides information about the search result, the
     233             :      position of the reference point and the toolbar used.
     234             : */
     235           0 : ReferenceToolbarPathInfo ToolBarMerger::FindReferencePoint(
     236             :     ToolBox*               pToolbar,
     237             :     const OUString& rReferencePoint )
     238             : {
     239           0 :     ReferenceToolbarPathInfo aResult;
     240           0 :     aResult.bResult  = false;
     241           0 :     aResult.pToolbar = pToolbar;
     242           0 :     aResult.nPos     = TOOLBOX_ITEM_NOTFOUND;
     243             : 
     244           0 :     const sal_uInt16 nSize( pToolbar->GetItemCount() );
     245             : 
     246           0 :     for ( sal_uInt16 i = 0; i < nSize; i++ )
     247             :     {
     248           0 :         const sal_uInt16 nItemId = pToolbar->GetItemId( i );
     249           0 :         if ( nItemId > 0 )
     250             :         {
     251           0 :             const OUString rCmd = pToolbar->GetItemCommand( nItemId );
     252           0 :             if ( rCmd == rReferencePoint )
     253             :             {
     254           0 :                 aResult.bResult = true;
     255           0 :                 aResult.nPos    = i;
     256           0 :                 return aResult;
     257           0 :             }
     258             :         }
     259             :     }
     260             : 
     261           0 :     return aResult;
     262             : }
     263             : 
     264             : /**
     265             :  Processes a merge operation.
     266             : 
     267             :  @param
     268             :      xFrame
     269             : 
     270             :      Must be a valid reference to a frame.
     271             : 
     272             :  @param
     273             :      pToolbar
     274             : 
     275             :      A valid pointer to the toolbar where the merge
     276             :      operation is applied to.
     277             : 
     278             :  @param
     279             :      nPos
     280             : 
     281             :      The reference position of the toolbar item for
     282             :      the merge operation. Value must be between
     283             :      0 and number of toolbar items - 1.
     284             : 
     285             :  @param
     286             :      rItemId
     287             : 
     288             :      A unique item ID.
     289             : 
     290             :  @param
     291             :      rModuleIdentifier
     292             : 
     293             :      The current application module context.
     294             : 
     295             :  @param
     296             :      rMergeCommand
     297             : 
     298             :      A merge command.
     299             : 
     300             :  @param
     301             :      rMergeCommandParameter.
     302             : 
     303             :      An optional argument for the merge command.
     304             : 
     305             :  @param
     306             :      rItems
     307             : 
     308             :      Toolbar items which are associated to the merge
     309             :      command.
     310             : 
     311             :  @result
     312             :      Returns true for a successful operation otherwise
     313             :      false.
     314             : */
     315           0 : bool ToolBarMerger::ProcessMergeOperation(
     316             :     const uno::Reference< frame::XFrame >& xFrame,
     317             :     ToolBox*                               pToolbar,
     318             :     sal_uInt16                             nPos,
     319             :     sal_uInt16&                            rItemId,
     320             :     CommandToInfoMap&                      rCommandMap,
     321             :     const OUString&                 rModuleIdentifier,
     322             :     const OUString&                 rMergeCommand,
     323             :     const OUString&                 rMergeCommandParameter,
     324             :     const AddonToolbarItemContainer&       rItems )
     325             : {
     326           0 :     if ( rMergeCommand == MERGECOMMAND_ADDAFTER )
     327           0 :         return MergeItems( xFrame, pToolbar, nPos, 1, rItemId, rCommandMap, rModuleIdentifier, rItems );
     328           0 :     else if ( rMergeCommand == MERGECOMMAND_ADDBEFORE )
     329           0 :         return MergeItems( xFrame, pToolbar, nPos, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
     330           0 :     else if ( rMergeCommand == MERGECOMMAND_REPLACE )
     331           0 :         return ReplaceItem( xFrame, pToolbar, nPos, rItemId, rCommandMap, rModuleIdentifier, rItems );
     332           0 :     else if ( rMergeCommand == MERGECOMMAND_REMOVE )
     333           0 :         return RemoveItems( pToolbar, nPos, rMergeCommandParameter );
     334             : 
     335           0 :     return false;
     336             : }
     337             : 
     338             : /**
     339             :  Processes a merge fallback operation.
     340             : 
     341             :  @param
     342             :      xFrame
     343             : 
     344             :      Must be a valid reference to a frame.
     345             : 
     346             :  @param
     347             :      pToolbar
     348             : 
     349             :      A valid pointer to the toolbar where the merge
     350             :      fall back operation is applied to.
     351             : 
     352             :  @param
     353             :      nPos
     354             : 
     355             :      The reference position of the toolbar item for
     356             :      the merge operation. Value must be between
     357             :      0 and number of toolbar items - 1.
     358             : 
     359             :  @param
     360             :      rItemId
     361             : 
     362             :      A unique item ID.
     363             : 
     364             :  @param
     365             :      rModuleIdentifier
     366             : 
     367             :      The current application module context.
     368             : 
     369             :  @param
     370             :      rMergeCommand
     371             : 
     372             :      A merge command.
     373             : 
     374             :  @param
     375             :      rItems
     376             : 
     377             :      Toolbar items which are associated to the merge
     378             :      command.
     379             : 
     380             :  @result
     381             :      Returns true for a successful operation otherwise
     382             :      false.
     383             : */
     384           0 : bool ToolBarMerger::ProcessMergeFallback(
     385             :     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
     386             :     ToolBox*                         pToolbar,
     387             :     sal_uInt16                       /*nPos*/,
     388             :     sal_uInt16&                      rItemId,
     389             :     CommandToInfoMap&                rCommandMap,
     390             :     const OUString&           rModuleIdentifier,
     391             :     const OUString&           rMergeCommand,
     392             :     const OUString&           rMergeFallback,
     393             :     const AddonToolbarItemContainer& rItems )
     394             : {
     395           0 :     if (( rMergeFallback == MERGEFALLBACK_IGNORE ) ||
     396           0 :         ( rMergeCommand == MERGECOMMAND_REPLACE ) ||
     397           0 :         ( rMergeCommand == MERGECOMMAND_REMOVE ) )
     398             :     {
     399           0 :         return true;
     400             :     }
     401           0 :     else if (( rMergeCommand == MERGECOMMAND_ADDBEFORE ) ||
     402           0 :              ( rMergeCommand == MERGECOMMAND_ADDAFTER ) )
     403             :     {
     404           0 :         if ( rMergeFallback == MERGEFALLBACK_ADDFIRST )
     405           0 :             return MergeItems( xFrame, pToolbar, 0, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
     406           0 :         else if ( rMergeFallback == MERGEFALLBACK_ADDLAST )
     407           0 :             return MergeItems( xFrame, pToolbar, TOOLBOX_APPEND, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
     408             :     }
     409             : 
     410           0 :     return false;
     411             : }
     412             : 
     413             : /**
     414             :  Merges (adds) toolbar items into an existing toolbar.
     415             : 
     416             :  @param
     417             :      xFrame
     418             : 
     419             :      Must be a valid reference to a frame.
     420             : 
     421             :  @param
     422             :      pToolbar
     423             : 
     424             :      A valid pointer to the toolbar where the merge
     425             :      fall back operation is applied to.
     426             : 
     427             :  @param
     428             :      nPos
     429             : 
     430             :      The reference position of the toolbar item for
     431             :      the merge operation. Value must be between
     432             :      0 and number of toolbar items - 1.
     433             : 
     434             :  @param
     435             :      rItemId
     436             : 
     437             :      A unique item ID.
     438             : 
     439             :  @param
     440             :      rModuleIdentifier
     441             : 
     442             :      The current application module context.
     443             : 
     444             :  @param
     445             :      rItems
     446             : 
     447             :      Toolbar items which are associated to the merge
     448             :      command.
     449             : 
     450             :  @result
     451             :      Returns true for a successful operation otherwise
     452             :      false.
     453             : */
     454           0 : bool ToolBarMerger::MergeItems(
     455             :     const uno::Reference< frame::XFrame >& rFrame,
     456             :     ToolBox*                               pToolbar,
     457             :     sal_uInt16                             nPos,
     458             :     sal_uInt16                             nModIndex,
     459             :     sal_uInt16&                            rItemId,
     460             :     CommandToInfoMap&                      rCommandMap,
     461             :     const OUString&                 rModuleIdentifier,
     462             :     const AddonToolbarItemContainer&       rAddonToolbarItems )
     463             : {
     464           0 :     const sal_Int32 nSize( rAddonToolbarItems.size() );
     465             : 
     466           0 :     uno::Reference< frame::XFrame > xFrame( rFrame );
     467             : 
     468           0 :     sal_uInt16 nIndex( 0 );
     469           0 :     for ( sal_Int32 i = 0; i < nSize; i++ )
     470             :     {
     471           0 :         const AddonToolbarItem& rItem = rAddonToolbarItems[i];
     472           0 :         if ( IsCorrectContext( rItem.aContext, rModuleIdentifier ))
     473             :         {
     474           0 :             sal_Int32 nInsPos = nPos+nModIndex+i;
     475           0 :             if ( nInsPos > sal_Int32( pToolbar->GetItemCount() ))
     476           0 :                 nInsPos = TOOLBOX_APPEND;
     477             : 
     478           0 :             if ( rItem.aCommandURL == TOOLBOXITEM_SEPARATOR_STR )
     479           0 :                 pToolbar->InsertSeparator( sal_uInt16( nInsPos ));
     480             :             else
     481             :             {
     482           0 :                 CommandToInfoMap::iterator pIter = rCommandMap.find( rItem.aCommandURL );
     483           0 :                 if ( pIter == rCommandMap.end())
     484             :                 {
     485           0 :                     CommandInfo aCmdInfo;
     486           0 :                     aCmdInfo.nId = rItemId;
     487           0 :                     const CommandToInfoMap::value_type aValue( rItem.aCommandURL, aCmdInfo );
     488           0 :                     rCommandMap.insert( aValue );
     489             :                 }
     490             :                 else
     491             :                 {
     492           0 :                     pIter->second.aIds.push_back( rItemId );
     493             :                 }
     494             : 
     495           0 :                 ToolBarMerger::CreateToolbarItem( pToolbar, rCommandMap, sal_uInt16( nInsPos ), rItemId, rItem );
     496             :             }
     497             : 
     498           0 :             ++nIndex;
     499           0 :             ++rItemId;
     500             :         }
     501             :     }
     502             : 
     503           0 :     return true;
     504             : }
     505             : 
     506             : /**
     507             :  Replaces a toolbar item with new items for an
     508             :  existing toolbar.
     509             : 
     510             :  @param
     511             :      xFrame
     512             : 
     513             :      Must be a valid reference to a frame.
     514             : 
     515             :  @param
     516             :      pToolbar
     517             : 
     518             :      A valid pointer to the toolbar where the merge
     519             :      fall back operation is applied to.
     520             : 
     521             :  @param
     522             :      nPos
     523             : 
     524             :      The reference position of the toolbar item for
     525             :      the merge operation. Value must be between
     526             :      0 and number of toolbar items - 1.
     527             : 
     528             :  @param
     529             :      rItemId
     530             : 
     531             :      A unique item ID.
     532             : 
     533             :  @param
     534             :      rModuleIdentifier
     535             : 
     536             :      The current application module context.
     537             : 
     538             :  @param
     539             :      rItems
     540             : 
     541             :      Toolbar items which are associated to the merge
     542             :      command.
     543             : 
     544             :  @result
     545             :      Returns true for a successful operation otherwise
     546             :      false.
     547             : */
     548           0 : bool ToolBarMerger::ReplaceItem(
     549             :     const uno::Reference< frame::XFrame >& xFrame,
     550             :     ToolBox*                               pToolbar,
     551             :     sal_uInt16                             nPos,
     552             :     sal_uInt16&                            rItemId,
     553             :     CommandToInfoMap&                      rCommandMap,
     554             :     const OUString&                 rModuleIdentifier,
     555             :     const AddonToolbarItemContainer&       rAddonToolbarItems )
     556             : {
     557           0 :     pToolbar->RemoveItem( nPos );
     558           0 :     return MergeItems( xFrame, pToolbar, nPos, 0, rItemId, rCommandMap, rModuleIdentifier, rAddonToolbarItems );
     559             : }
     560             : 
     561             : /**
     562             :  Removes toolbar items from an existing toolbar.
     563             : 
     564             :  @param
     565             :      pToolbar
     566             : 
     567             :      A valid pointer to the toolbar where the merge
     568             :      fall back operation is applied to.
     569             : 
     570             :  @param
     571             :      nPos
     572             : 
     573             :      The reference position of the toolbar item for
     574             :      the merge operation. Value must be between
     575             :      0 and number of toolbar items - 1.
     576             : 
     577             :  @param
     578             :      rMergeCommandParameter.
     579             : 
     580             :      An optional argument for the merge command.
     581             : 
     582             :  @result
     583             :      Returns true for a successful operation otherwise
     584             :      false.
     585             : */
     586           0 : bool ToolBarMerger::RemoveItems(
     587             :     ToolBox*                  pToolbar,
     588             :     sal_uInt16                nPos,
     589             :     const OUString&    rMergeCommandParameter )
     590             : {
     591           0 :     sal_Int32 nCount = rMergeCommandParameter.toInt32();
     592           0 :     if ( nCount > 0 )
     593             :     {
     594           0 :         for ( sal_Int32 i = 0; i < nCount; i++ )
     595             :         {
     596           0 :             if ( nPos < pToolbar->GetItemCount() )
     597           0 :                 pToolbar->RemoveItem( nPos );
     598             :         }
     599             :     }
     600           0 :     return true;
     601             : }
     602             : 
     603             : /**
     604             :  Removes toolbar items from an existing toolbar.
     605             : 
     606             :  @param
     607             :      pToolbar
     608             : 
     609             :      A valid pointer to the toolbar where the merge
     610             :      fall back operation is applied to.
     611             : 
     612             :  @param
     613             :      nPos
     614             : 
     615             :      The reference position of the toolbar item for
     616             :      the merge operation. Value must be between
     617             :      0 and number of toolbar items - 1.
     618             : 
     619             :  @param
     620             :      rMergeCommandParameter.
     621             : 
     622             :      An optional argument for the merge command.
     623             : 
     624             :  @result
     625             :      Returns true for a successful operation otherwise
     626             :      false.
     627             : */
     628       27580 : ::cppu::OWeakObject* ToolBarMerger::CreateController(
     629             :     const uno::Reference< uno::XComponentContext >& rxContext,
     630             :     const uno::Reference< frame::XFrame > & xFrame,
     631             :     ToolBox*               pToolbar,
     632             :     const OUString& rCommandURL,
     633             :     sal_uInt16             nId,
     634             :     sal_uInt16             nWidth,
     635             :     const OUString& rControlType )
     636             : {
     637       27580 :     ::cppu::OWeakObject* pResult( 0 );
     638             : 
     639       27580 :     if ( rControlType == TOOLBARCONTROLLER_BUTTON )
     640           0 :         pResult = new ButtonToolbarController( rxContext, pToolbar, rCommandURL );
     641       27580 :     else if ( rControlType == TOOLBARCONTROLLER_COMBOBOX )
     642           0 :         pResult = new ComboboxToolbarController( rxContext, xFrame, pToolbar, nId, nWidth, rCommandURL );
     643       27580 :     else if ( rControlType == TOOLBARCONTROLLER_EDIT )
     644        2758 :         pResult = new EditToolbarController( rxContext, xFrame, pToolbar, nId, nWidth, rCommandURL );
     645       24822 :     else if ( rControlType == TOOLBARCONTROLLER_SPINFIELD )
     646           0 :         pResult = new SpinfieldToolbarController( rxContext, xFrame, pToolbar, nId, nWidth, rCommandURL );
     647       24822 :     else if ( rControlType == TOOLBARCONTROLLER_IMGBUTTON )
     648           0 :         pResult = new ImageButtonToolbarController( rxContext, xFrame, pToolbar, nId, rCommandURL );
     649       24822 :     else if ( rControlType == TOOLBARCONTROLLER_DROPDOWNBOX )
     650           0 :         pResult = new DropdownToolbarController( rxContext, xFrame, pToolbar, nId, nWidth, rCommandURL );
     651       24822 :     else if ( rControlType == TOOLBARCONTROLLER_DROPDOWNBTN )
     652             :         pResult = new ToggleButtonToolbarController( rxContext, xFrame, pToolbar, nId,
     653           0 :                                                      ToggleButtonToolbarController::STYLE_DROPDOWNBUTTON, rCommandURL );
     654       24822 :     else if ( rControlType == TOOLBARCONTROLLER_TOGGLEDDBTN )
     655             :         pResult = new ToggleButtonToolbarController( rxContext, xFrame, pToolbar, nId,
     656           0 :                                                      ToggleButtonToolbarController::STYLE_TOGGLE_DROPDOWNBUTTON, rCommandURL );
     657             :     else
     658       24822 :         pResult = new GenericToolbarController( rxContext, xFrame, pToolbar, nId, rCommandURL );
     659             : 
     660       27580 :     return pResult;
     661             : }
     662             : 
     663           0 : void ToolBarMerger::CreateToolbarItem( ToolBox* pToolbar, CommandToInfoMap& rCommandMap, sal_uInt16 nPos, sal_uInt16 nItemId, const AddonToolbarItem& rItem )
     664             : {
     665           0 :     pToolbar->InsertItem( nItemId, rItem.aLabel, ToolBoxItemBits::NONE, nPos );
     666           0 :     pToolbar->SetItemCommand( nItemId, rItem.aCommandURL );
     667           0 :     pToolbar->SetQuickHelpText( nItemId, rItem.aLabel );
     668           0 :     pToolbar->SetItemText( nItemId, rItem.aLabel );
     669           0 :     pToolbar->EnableItem( nItemId, true );
     670           0 :     pToolbar->SetItemState( nItemId, TRISTATE_FALSE );
     671             : 
     672           0 :     CommandToInfoMap::iterator pIter = rCommandMap.find( rItem.aCommandURL );
     673           0 :     if ( pIter != rCommandMap.end() )
     674           0 :         pIter->second.nWidth = rItem.nWidth;
     675             : 
     676             :     // Use the user data to store add-on specific data with the toolbar item
     677           0 :     AddonsParams* pAddonParams = new AddonsParams;
     678           0 :     pAddonParams->aImageId     = rItem.aImageIdentifier;
     679           0 :     pAddonParams->aTarget      = rItem.aTarget;
     680           0 :     pAddonParams->aControlType = rItem.aControlType;
     681           0 :     pToolbar->SetItemData( nItemId, pAddonParams );
     682           0 : }
     683             : 
     684         648 : } // namespace framework
     685             : 
     686             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11