LCOV - code coverage report
Current view: top level - cui/source/customize - cfg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 2432 0.0 %
Date: 2012-08-25 Functions: 0 199 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 4921 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <stdlib.h>
      30                 :            : #include <time.h>
      31                 :            : 
      32                 :            : #include <vcl/help.hxx>
      33                 :            : #include <vcl/msgbox.hxx>
      34                 :            : #include <vcl/decoview.hxx>
      35                 :            : #include <vcl/toolbox.hxx>
      36                 :            : #include <vcl/scrbar.hxx>
      37                 :            : #include <vcl/virdev.hxx>
      38                 :            : 
      39                 :            : #include <sfx2/app.hxx>
      40                 :            : #include <sfx2/sfxdlg.hxx>
      41                 :            : #include <sfx2/viewfrm.hxx>
      42                 :            : #include <sfx2/viewsh.hxx>
      43                 :            : #include <sfx2/msg.hxx>
      44                 :            : #include <sfx2/msgpool.hxx>
      45                 :            : #include <sfx2/mnumgr.hxx>
      46                 :            : #include <sfx2/minfitem.hxx>
      47                 :            : #include <sfx2/objsh.hxx>
      48                 :            : #include <sfx2/request.hxx>
      49                 :            : #include <sfx2/filedlghelper.hxx>
      50                 :            : #include <svl/stritem.hxx>
      51                 :            : #include <svtools/miscopt.hxx>
      52                 :            : #include <tools/diagnose_ex.h>
      53                 :            : #include <toolkit/unohlp.hxx>
      54                 :            : 
      55                 :            : #include <algorithm>
      56                 :            : #include <cuires.hrc>
      57                 :            : #include "cfg.hrc"
      58                 :            : #include "helpid.hrc"
      59                 :            : 
      60                 :            : #include "acccfg.hxx"
      61                 :            : #include "cfg.hxx"
      62                 :            : #include "eventdlg.hxx"
      63                 :            : #include <dialmgr.hxx>
      64                 :            : 
      65                 :            : #include <comphelper/documentinfo.hxx>
      66                 :            : #include <comphelper/processfactory.hxx>
      67                 :            : #include <unotools/configmgr.hxx>
      68                 :            : #include <com/sun/star/ui/ItemType.hpp>
      69                 :            : #include <com/sun/star/ui/ItemStyle.hpp>
      70                 :            : #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
      71                 :            : #include <com/sun/star/frame/XController.hpp>
      72                 :            : #include <com/sun/star/frame/XDesktop.hpp>
      73                 :            : #include <com/sun/star/ui/XUIConfiguration.hpp>
      74                 :            : #include <com/sun/star/ui/XUIConfigurationListener.hpp>
      75                 :            : #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
      76                 :            : #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
      77                 :            : #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
      78                 :            : #include <com/sun/star/ui/XModuleUIConfigurationManager.hpp>
      79                 :            : #include <com/sun/star/ui/XUIElement.hpp>
      80                 :            : #include <com/sun/star/ui/UIElementType.hpp>
      81                 :            : #include <com/sun/star/ui/ImageType.hpp>
      82                 :            : #include <com/sun/star/frame/XLayoutManager.hpp>
      83                 :            : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      84                 :            : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
      85                 :            : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
      86                 :            : #include <com/sun/star/frame/XFramesSupplier.hpp>
      87                 :            : #include <com/sun/star/frame/XFrames.hpp>
      88                 :            : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      89                 :            : #include <com/sun/star/graphic/GraphicProvider.hpp>
      90                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      91                 :            : #include <com/sun/star/embed/FileSystemStorageFactory.hpp>
      92                 :            : 
      93                 :            : #include "dlgname.hxx"
      94                 :            : 
      95                 :            : #define PRTSTR(x) rtl::OUStringToOString(x, RTL_TEXTENCODING_ASCII_US).pData->buffer
      96                 :            : 
      97                 :            : #define ENTRY_HEIGHT 16
      98                 :            : 
      99                 :            : static const char ITEM_DESCRIPTOR_COMMANDURL[]  = "CommandURL";
     100                 :            : static const char ITEM_DESCRIPTOR_CONTAINER[]   = "ItemDescriptorContainer";
     101                 :            : static const char ITEM_DESCRIPTOR_LABEL[]       = "Label";
     102                 :            : static const char ITEM_DESCRIPTOR_TYPE[]        = "Type";
     103                 :            : static const char ITEM_DESCRIPTOR_STYLE[]       = "Style";
     104                 :            : static const char ITEM_DESCRIPTOR_ISVISIBLE[]   = "IsVisible";
     105                 :            : static const char ITEM_DESCRIPTOR_RESOURCEURL[] = "ResourceURL";
     106                 :            : static const char ITEM_DESCRIPTOR_UINAME[]      = "UIName";
     107                 :            : 
     108                 :            : static const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar";
     109                 :            : static const char ITEM_TOOLBAR_URL[] = "private:resource/toolbar/";
     110                 :            : 
     111                 :            : static const char CUSTOM_TOOLBAR_STR[] = "custom_toolbar_";
     112                 :            : static const char CUSTOM_MENU_STR[] = "vnd.openoffice.org:CustomMenu";
     113                 :            : 
     114                 :            : static const char aSeparatorStr[] = "----------------------------------";
     115                 :            : static const char aMenuSeparatorStr[] = " | ";
     116                 :            : 
     117                 :            : #ifdef _MSC_VER
     118                 :            : #pragma warning (disable:4355)
     119                 :            : #endif
     120                 :            : 
     121                 :            : using rtl::OUString;
     122                 :            : namespace css = com::sun::star;
     123                 :            : namespace uno = com::sun::star::uno;
     124                 :            : namespace frame = com::sun::star::frame;
     125                 :            : namespace lang = com::sun::star::lang;
     126                 :            : namespace container = com::sun::star::container;
     127                 :            : namespace beans = com::sun::star::beans;
     128                 :            : namespace graphic = com::sun::star::graphic;
     129                 :            : 
     130                 :            : #if OSL_DEBUG_LEVEL > 1
     131                 :            : 
     132                 :            : void printPropertySet(
     133                 :            :     const OUString& prefix,
     134                 :            :     const uno::Reference< beans::XPropertySet >& xPropSet )
     135                 :            : {
     136                 :            :     uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
     137                 :            :         xPropSet->getPropertySetInfo();
     138                 :            : 
     139                 :            :     uno::Sequence< beans::Property > aPropDetails =
     140                 :            :         xPropSetInfo->getProperties();
     141                 :            : 
     142                 :            :     OSL_TRACE("printPropertySet: %d properties", aPropDetails.getLength());
     143                 :            : 
     144                 :            :     for ( sal_Int32 i = 0; i < aPropDetails.getLength(); ++i )
     145                 :            :     {
     146                 :            :         OUString tmp;
     147                 :            :         sal_Int32 ival;
     148                 :            : 
     149                 :            :         uno::Any a = xPropSet->getPropertyValue( aPropDetails[i].Name );
     150                 :            : 
     151                 :            :         if ( a >>= tmp )
     152                 :            :         {
     153                 :            :             OSL_TRACE("%s: Got property: %s = %s",
     154                 :            :                 PRTSTR(prefix), PRTSTR(aPropDetails[i].Name), PRTSTR(tmp));
     155                 :            :         }
     156                 :            :         else if ( ( a >>= ival ) )
     157                 :            :         {
     158                 :            :             OSL_TRACE("%s: Got property: %s = %d",
     159                 :            :                 PRTSTR(prefix), PRTSTR(aPropDetails[i].Name), PRTSTR(tmp));
     160                 :            :         }
     161                 :            :         else
     162                 :            :         {
     163                 :            :             OSL_TRACE("%s: Got property: %s of type %s",
     164                 :            :                 PRTSTR(prefix), PRTSTR(aPropDetails[i].Name), PRTSTR(a.getValueTypeName()));
     165                 :            :         }
     166                 :            :     }
     167                 :            : }
     168                 :            : 
     169                 :            : void printProperties(
     170                 :            :     const OUString& prefix,
     171                 :            :     const uno::Sequence< beans::PropertyValue >& aProp )
     172                 :            : {
     173                 :            :     for ( sal_Int32 i = 0; i < aProp.getLength(); ++i )
     174                 :            :     {
     175                 :            :         OUString tmp;
     176                 :            : 
     177                 :            :         aProp[i].Value >>= tmp;
     178                 :            : 
     179                 :            :         OSL_TRACE("%s: Got property: %s = %s",
     180                 :            :             PRTSTR(prefix), PRTSTR(aProp[i].Name), PRTSTR(tmp));
     181                 :            :     }
     182                 :            : }
     183                 :            : 
     184                 :            : void printEntries(SvxEntries* entries)
     185                 :            : {
     186                 :            :     SvxEntries::const_iterator iter = entries->begin();
     187                 :            : 
     188                 :            :     for ( ; iter != entries->end(); ++iter )
     189                 :            :     {
     190                 :            :         SvxConfigEntry* entry = *iter;
     191                 :            : 
     192                 :            :         OSL_TRACE("printEntries: %s", PRTSTR(entry->GetName()));
     193                 :            :     }
     194                 :            : }
     195                 :            : 
     196                 :            : #endif
     197                 :            : 
     198                 :            : OUString
     199                 :          0 : stripHotKey( const OUString& str )
     200                 :            : {
     201                 :          0 :     sal_Int32 index = str.indexOf( '~' );
     202         [ #  # ]:          0 :     if ( index == -1 )
     203                 :            :     {
     204                 :          0 :         return str;
     205                 :            :     }
     206                 :            :     else
     207                 :            :     {
     208                 :          0 :         return str.replaceAt( index, 1, OUString() );
     209                 :            :     }
     210                 :            : }
     211                 :            : 
     212                 :          0 : OUString replaceSaveInName(
     213                 :            :     const OUString& rMessage,
     214                 :            :     const OUString& rSaveInName )
     215                 :            : {
     216                 :          0 :     OUString name;
     217                 :          0 :     OUString placeholder("%SAVE IN SELECTION%" );
     218                 :            : 
     219                 :          0 :     sal_Int32 pos = rMessage.indexOf( placeholder );
     220                 :            : 
     221         [ #  # ]:          0 :     if ( pos != -1 )
     222                 :            :     {
     223                 :            :         name = rMessage.replaceAt(
     224                 :          0 :             pos, placeholder.getLength(), rSaveInName );
     225                 :            :     }
     226                 :            : 
     227                 :          0 :     return name;
     228                 :            : }
     229                 :            : 
     230                 :            : OUString
     231                 :          0 : replaceSixteen( const OUString& str, sal_Int32 nReplacement )
     232                 :            : {
     233                 :          0 :     OUString result( str );
     234                 :          0 :     OUString sixteen = OUString::valueOf( (sal_Int32)16 );
     235                 :          0 :     OUString expected = OUString::valueOf( nReplacement );
     236                 :            : 
     237                 :          0 :     sal_Int32 len = sixteen.getLength();
     238                 :          0 :     sal_Int32 index = result.indexOf( sixteen );
     239                 :            : 
     240         [ #  # ]:          0 :     while ( index != -1 )
     241                 :            :     {
     242                 :          0 :         result = result.replaceAt( index, len, expected );
     243                 :          0 :         index = result.indexOf( sixteen, index );
     244                 :            :     }
     245                 :            : 
     246                 :          0 :     return result;
     247                 :            : }
     248                 :            : 
     249                 :            : OUString
     250                 :          0 : generateCustomName(
     251                 :            :     const OUString& prefix,
     252                 :            :     SvxEntries* entries,
     253                 :            :     sal_Int32 suffix = 1 )
     254                 :            : {
     255                 :            :     // find and replace the %n placeholder in the prefix string
     256                 :          0 :     OUString name;
     257                 :          0 :     OUString placeholder("%n" );
     258                 :            : 
     259                 :          0 :     sal_Int32 pos = prefix.indexOf( placeholder );
     260                 :            : 
     261         [ #  # ]:          0 :     if ( pos != -1 )
     262                 :            :     {
     263                 :            :         name = prefix.replaceAt(
     264                 :          0 :             pos, placeholder.getLength(), OUString::valueOf( suffix ) );
     265                 :            :     }
     266                 :            :     else
     267                 :            :     {
     268                 :            :         // no placeholder found so just append the suffix
     269                 :          0 :         name = prefix + OUString::valueOf( suffix );
     270                 :            :     }
     271                 :            : 
     272                 :            :     // now check is there is an already existing entry with this name
     273         [ #  # ]:          0 :     SvxEntries::const_iterator iter = entries->begin();
     274                 :            : 
     275                 :            :     SvxConfigEntry* pEntry;
     276 [ #  # ][ #  # ]:          0 :     while ( iter != entries->end() )
     277                 :            :     {
     278                 :          0 :         pEntry = *iter;
     279                 :            : 
     280         [ #  # ]:          0 :         if ( name.equals( pEntry->GetName() ) )
     281                 :            :         {
     282                 :          0 :             break;
     283                 :            :         }
     284                 :          0 :         ++iter;
     285                 :            :     }
     286                 :            : 
     287 [ #  # ][ #  # ]:          0 :     if ( iter != entries->end() )
     288                 :            :     {
     289                 :            :         // name already exists so try the next number up
     290         [ #  # ]:          0 :         return generateCustomName( prefix, entries, ++suffix );
     291                 :            :     }
     292                 :            : 
     293                 :          0 :     return name;
     294                 :            : }
     295                 :            : 
     296                 :          0 : sal_uInt32 generateRandomValue()
     297                 :            : {
     298                 :          0 :     srand( unsigned( time( NULL ) ));
     299                 :          0 :     return sal_uInt32( rand() );
     300                 :            : }
     301                 :            : 
     302                 :            : OUString
     303                 :          0 : generateCustomURL(
     304                 :            :     SvxEntries* entries )
     305                 :            : {
     306                 :          0 :     OUString url = OUString(ITEM_TOOLBAR_URL );
     307                 :          0 :     url += OUString(CUSTOM_TOOLBAR_STR );
     308                 :            : 
     309                 :            :     // use a random number to minimize possible clash with existing custom toolbars
     310                 :          0 :     url += OUString::valueOf( sal_Int64( generateRandomValue() ), 16 );
     311                 :            : 
     312                 :            :     // now check is there is an already existing entry with this url
     313         [ #  # ]:          0 :     SvxEntries::const_iterator iter = entries->begin();
     314                 :            : 
     315                 :            :     SvxConfigEntry* pEntry;
     316 [ #  # ][ #  # ]:          0 :     while ( iter != entries->end() )
     317                 :            :     {
     318                 :          0 :         pEntry = *iter;
     319                 :            : 
     320         [ #  # ]:          0 :         if ( url.equals( pEntry->GetCommand() ) )
     321                 :            :         {
     322                 :          0 :             break;
     323                 :            :         }
     324                 :          0 :         ++iter;
     325                 :            :     }
     326                 :            : 
     327 [ #  # ][ #  # ]:          0 :     if ( iter != entries->end() )
     328                 :            :     {
     329                 :            :         // url already exists so try the next number up
     330         [ #  # ]:          0 :         return generateCustomURL( entries );
     331                 :            :     }
     332                 :            : 
     333                 :          0 :     return url;
     334                 :            : }
     335                 :            : 
     336                 :            : OUString
     337                 :          0 : generateCustomMenuURL(
     338                 :            :     SvxEntries* entries,
     339                 :            :     sal_Int32 suffix = 1 )
     340                 :            : {
     341                 :          0 :     OUString url(CUSTOM_MENU_STR );
     342                 :          0 :     url += OUString::valueOf( suffix );
     343                 :            : 
     344                 :            :     // now check is there is an already existing entry with this url
     345         [ #  # ]:          0 :     SvxEntries::const_iterator iter = entries->begin();
     346                 :            : 
     347                 :            :     SvxConfigEntry* pEntry;
     348 [ #  # ][ #  # ]:          0 :     while ( iter != entries->end() )
     349                 :            :     {
     350                 :          0 :         pEntry = *iter;
     351                 :            : 
     352         [ #  # ]:          0 :         if ( url.equals( pEntry->GetCommand() ) )
     353                 :            :         {
     354                 :          0 :             break;
     355                 :            :         }
     356                 :          0 :         ++iter;
     357                 :            :     }
     358                 :            : 
     359 [ #  # ][ #  # ]:          0 :     if ( iter != entries->end() )
     360                 :            :     {
     361                 :            :         // url already exists so try the next number up
     362         [ #  # ]:          0 :         return generateCustomMenuURL( entries, ++suffix );
     363                 :            :     }
     364                 :            : 
     365                 :          0 :     return url;
     366                 :            : }
     367                 :            : 
     368                 :            : static sal_Int16 theImageType =
     369                 :            :     css::ui::ImageType::COLOR_NORMAL |
     370                 :            :     css::ui::ImageType::SIZE_DEFAULT;
     371                 :            : 
     372                 :          0 : void InitImageType()
     373                 :            : {
     374                 :            :     theImageType =
     375                 :            :         css::ui::ImageType::COLOR_NORMAL |
     376                 :          0 :         css::ui::ImageType::SIZE_DEFAULT;
     377                 :            : 
     378 [ #  # ][ #  # ]:          0 :     if ( SvtMiscOptions().AreCurrentSymbolsLarge() )
     379                 :            :     {
     380                 :          0 :         theImageType |= css::ui::ImageType::SIZE_LARGE;
     381                 :            :     }
     382                 :          0 : }
     383                 :            : 
     384                 :          0 : sal_Int16 GetImageType()
     385                 :            : {
     386                 :          0 :     return theImageType;
     387                 :            : }
     388                 :            : 
     389                 :          0 : void RemoveEntry( SvxEntries* pEntries, SvxConfigEntry* pChildEntry )
     390                 :            : {
     391                 :          0 :     SvxEntries::iterator iter = pEntries->begin();
     392                 :            : 
     393 [ #  # ][ #  # ]:          0 :     while ( iter != pEntries->end() )
     394                 :            :     {
     395         [ #  # ]:          0 :         if ( pChildEntry == *iter )
     396                 :            :         {
     397         [ #  # ]:          0 :             pEntries->erase( iter );
     398                 :          0 :             break;
     399                 :            :         }
     400                 :          0 :         ++iter;
     401                 :            :     }
     402                 :          0 : }
     403                 :            : 
     404                 :            : bool
     405                 :          0 : SvxConfigPage::CanConfig( const OUString& aModuleId )
     406                 :            : {
     407                 :            :     OSL_TRACE("SupportsDocumentConfig: %s", PRTSTR(aModuleId));
     408                 :            : 
     409 [ #  # ][ #  # ]:          0 :     if  ( aModuleId == "com.sun.star.script.BasicIDE" || aModuleId == "com.sun.star.frame.Bibliography" )
                 [ #  # ]
     410                 :            :     {
     411                 :          0 :         return sal_False;
     412                 :            :     }
     413                 :          0 :     return sal_True;
     414                 :            : }
     415                 :            : 
     416                 :          0 : OUString GetModuleName( const OUString& aModuleId )
     417                 :            : {
     418   [ #  #  #  # ]:          0 :     if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.text.TextDocument" ) ) ||
                 [ #  # ]
     419                 :          0 :          aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.text.GlobalDocument" ) ) )
     420                 :          0 :         return OUString("Writer");
     421         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.text.WebDocument" )
     422                 :          0 :         return OUString("Writer/Web");
     423         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.drawing.DrawingDocument" )
     424                 :          0 :         return OUString("Draw");
     425         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.presentation.PresentationDocument" )
     426                 :          0 :         return OUString("Impress");
     427         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.sheet.SpreadsheetDocument" )
     428                 :          0 :         return OUString("Calc");
     429         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.script.BasicIDE" )
     430                 :          0 :         return OUString("Basic");
     431         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.formula.FormulaProperties" )
     432                 :          0 :         return OUString("Math");
     433         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.sdb.RelationDesign" )
     434                 :          0 :         return OUString("Relation Design");
     435         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.sdb.QueryDesign" )
     436                 :          0 :         return OUString("Query Design");
     437         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.sdb.TableDesign" )
     438                 :          0 :         return OUString("Table Design");
     439         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.sdb.DataSourceBrowser" )
     440                 :          0 :         return OUString("Data Source Browser" );
     441         [ #  # ]:          0 :     else if ( aModuleId == "com.sun.star.sdb.DatabaseDocument" )
     442                 :          0 :         return OUString("Database" );
     443                 :            : 
     444                 :          0 :     return ::rtl::OUString();
     445                 :            : }
     446                 :            : 
     447                 :          0 : OUString GetUIModuleName( const OUString& aModuleId, const uno::Reference< css::frame::XModuleManager >& rModuleManager )
     448                 :            : {
     449                 :          0 :     OUString aModuleUIName;
     450                 :            : 
     451         [ #  # ]:          0 :     if ( rModuleManager.is() )
     452                 :            :     {
     453         [ #  # ]:          0 :         uno::Reference< css::container::XNameAccess > xNameAccess( rModuleManager, uno::UNO_QUERY );
     454         [ #  # ]:          0 :         if ( xNameAccess.is() )
     455                 :            :         {
     456                 :            :             try
     457                 :            :             {
     458 [ #  # ][ #  # ]:          0 :                 uno::Any a = xNameAccess->getByName( aModuleId );
     459         [ #  # ]:          0 :                 uno::Sequence< beans::PropertyValue > aSeq;
     460                 :            : 
     461 [ #  # ][ #  # ]:          0 :                 if ( a >>= aSeq )
     462                 :            :                 {
     463         [ #  # ]:          0 :                     for ( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
     464                 :            :                     {
     465 [ #  # ][ #  # ]:          0 :                         if ( aSeq[i].Name == "ooSetupFactoryUIName" )
     466                 :            :                         {
     467         [ #  # ]:          0 :                             aSeq[i].Value >>= aModuleUIName;
     468                 :          0 :                             break;
     469                 :            :                         }
     470                 :            :                     }
     471         [ #  # ]:          0 :                 }
     472                 :            :             }
     473      [ #  #  # ]:          0 :             catch ( uno::RuntimeException& )
     474                 :            :             {
     475                 :          0 :                 throw;
     476                 :            :             }
     477         [ #  # ]:          0 :             catch ( uno::Exception& )
     478                 :            :             {
     479                 :            :             }
     480                 :          0 :         }
     481                 :            :     }
     482                 :            : 
     483         [ #  # ]:          0 :     if ( aModuleUIName.isEmpty() )
     484         [ #  # ]:          0 :         aModuleUIName = GetModuleName( aModuleId );
     485                 :            : 
     486                 :          0 :     return aModuleUIName;
     487                 :            : }
     488                 :            : 
     489                 :          0 : bool GetMenuItemData(
     490                 :            :     const uno::Reference< container::XIndexAccess >& rItemContainer,
     491                 :            :     sal_Int32 nIndex,
     492                 :            :     OUString& rCommandURL,
     493                 :            :     OUString& rLabel,
     494                 :            :     sal_uInt16& rType,
     495                 :            :     uno::Reference< container::XIndexAccess >& rSubMenu )
     496                 :            : {
     497                 :            :     try
     498                 :            :     {
     499         [ #  # ]:          0 :         uno::Sequence< beans::PropertyValue > aProp;
     500 [ #  # ][ #  # ]:          0 :         if ( rItemContainer->getByIndex( nIndex ) >>= aProp )
         [ #  # ][ #  # ]
     501                 :            :         {
     502         [ #  # ]:          0 :             for ( sal_Int32 i = 0; i < aProp.getLength(); ++i )
     503                 :            :             {
     504 [ #  # ][ #  # ]:          0 :                 if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL ))
     505                 :            :                 {
     506         [ #  # ]:          0 :                     aProp[i].Value >>= rCommandURL;
     507                 :            :                 }
     508 [ #  # ][ #  # ]:          0 :                 else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_CONTAINER ))
     509                 :            :                 {
     510 [ #  # ][ #  # ]:          0 :                     aProp[i].Value >>= rSubMenu;
     511                 :            :                 }
     512 [ #  # ][ #  # ]:          0 :                 else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ))
     513                 :            :                 {
     514         [ #  # ]:          0 :                     aProp[i].Value >>= rLabel;
     515                 :            :                 }
     516 [ #  # ][ #  # ]:          0 :                 else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE ))
     517                 :            :                 {
     518         [ #  # ]:          0 :                     aProp[i].Value >>= rType;
     519                 :            :                 }
     520                 :            :             }
     521                 :            : 
     522                 :          0 :             return sal_True;
     523 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     524                 :            :     }
     525                 :          0 :     catch ( ::com::sun::star::lang::IndexOutOfBoundsException& )
     526                 :            :     {
     527                 :            :     }
     528                 :            : 
     529                 :          0 :     return sal_False;
     530                 :            : }
     531                 :            : 
     532                 :          0 : bool GetToolbarItemData(
     533                 :            :     const uno::Reference< container::XIndexAccess >& rItemContainer,
     534                 :            :     sal_Int32 nIndex,
     535                 :            :     OUString& rCommandURL,
     536                 :            :     OUString& rLabel,
     537                 :            :     sal_uInt16& rType,
     538                 :            :     sal_Bool& rIsVisible,
     539                 :            :     sal_Int32& rStyle,
     540                 :            :     uno::Reference< container::XIndexAccess >& rSubMenu )
     541                 :            : {
     542                 :            :     try
     543                 :            :     {
     544         [ #  # ]:          0 :         uno::Sequence< beans::PropertyValue > aProp;
     545 [ #  # ][ #  # ]:          0 :         if ( rItemContainer->getByIndex( nIndex ) >>= aProp )
         [ #  # ][ #  # ]
     546                 :            :         {
     547         [ #  # ]:          0 :             for ( sal_Int32 i = 0; i < aProp.getLength(); ++i )
     548                 :            :             {
     549 [ #  # ][ #  # ]:          0 :                 if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL ))
     550                 :            :                 {
     551         [ #  # ]:          0 :                     aProp[i].Value >>= rCommandURL;
     552                 :            :                 }
     553 [ #  # ][ #  # ]:          0 :                 if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE ))
     554                 :            :                 {
     555         [ #  # ]:          0 :                     aProp[i].Value >>= rStyle;
     556                 :            :                 }
     557 [ #  # ][ #  # ]:          0 :                 else if (aProp[i].Name.equalsAscii(ITEM_DESCRIPTOR_CONTAINER))
     558                 :            :                 {
     559 [ #  # ][ #  # ]:          0 :                     aProp[i].Value >>= rSubMenu;
     560                 :            :                 }
     561 [ #  # ][ #  # ]:          0 :                 else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ))
     562                 :            :                 {
     563         [ #  # ]:          0 :                     aProp[i].Value >>= rLabel;
     564                 :            :                 }
     565 [ #  # ][ #  # ]:          0 :                 else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE ))
     566                 :            :                 {
     567         [ #  # ]:          0 :                     aProp[i].Value >>= rType;
     568                 :            :                 }
     569 [ #  # ][ #  # ]:          0 :                 else if (aProp[i].Name.equalsAscii(ITEM_DESCRIPTOR_ISVISIBLE))
     570                 :            :                 {
     571         [ #  # ]:          0 :                     aProp[i].Value >>= rIsVisible;
     572                 :            :                 }
     573                 :            :             }
     574                 :            : 
     575                 :          0 :             return sal_True;
     576 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     577                 :            :     }
     578                 :          0 :     catch ( ::com::sun::star::lang::IndexOutOfBoundsException& )
     579                 :            :     {
     580                 :            :     }
     581                 :            : 
     582                 :          0 :     return sal_False;
     583                 :            : }
     584                 :            : 
     585                 :            : uno::Sequence< beans::PropertyValue >
     586                 :          0 : ConvertSvxConfigEntry(
     587                 :            :     const uno::Reference< container::XNameAccess >& xCommandToLabelMap,
     588                 :            :     const SvxConfigEntry* pEntry )
     589                 :            : {
     590                 :            :     static const OUString aDescriptorCommandURL (
     591 [ #  # ][ #  # ]:          0 :         ITEM_DESCRIPTOR_COMMANDURL  );
     592                 :            : 
     593                 :            :     static const OUString aDescriptorType(
     594 [ #  # ][ #  # ]:          0 :             ITEM_DESCRIPTOR_TYPE  );
     595                 :            : 
     596                 :            :     static const OUString aDescriptorLabel(
     597 [ #  # ][ #  # ]:          0 :             ITEM_DESCRIPTOR_LABEL  );
     598                 :            : 
     599                 :            :     static const OUString aDescriptorContainer(
     600 [ #  # ][ #  # ]:          0 :             ITEM_DESCRIPTOR_CONTAINER  );
     601                 :            : 
     602                 :          0 :     uno::Sequence< beans::PropertyValue > aPropSeq( 3 );
     603                 :            : 
     604         [ #  # ]:          0 :     aPropSeq[0].Name = aDescriptorCommandURL;
     605 [ #  # ][ #  # ]:          0 :     aPropSeq[0].Value <<= rtl::OUString( pEntry->GetCommand() );
     606                 :            : 
     607         [ #  # ]:          0 :     aPropSeq[1].Name = aDescriptorType;
     608 [ #  # ][ #  # ]:          0 :     aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
     609                 :            : 
     610                 :            :     // If the name has not been changed and the name is the same as
     611                 :            :     // in the default command to label map then the label can be stored
     612                 :            :     // as an empty string.
     613                 :            :     // It will be initialised again later using the command to label map.
     614         [ #  # ]:          0 :     aPropSeq[2].Name = aDescriptorLabel;
     615 [ #  # ][ #  # ]:          0 :     if ( pEntry->HasChangedName() == sal_False && !pEntry->GetCommand().isEmpty() )
                 [ #  # ]
     616                 :            :     {
     617                 :          0 :         sal_Bool isDefaultName = sal_False;
     618                 :            :         try
     619                 :            :         {
     620 [ #  # ][ #  # ]:          0 :             uno::Any a( xCommandToLabelMap->getByName( pEntry->GetCommand() ) );
     621         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > tmpPropSeq;
     622 [ #  # ][ #  # ]:          0 :             if ( a >>= tmpPropSeq )
     623                 :            :             {
     624         [ #  # ]:          0 :                 for ( sal_Int32 i = 0; i < tmpPropSeq.getLength(); ++i )
     625                 :            :                 {
     626 [ #  # ][ #  # ]:          0 :                     if ( tmpPropSeq[i].Name.equals( aDescriptorLabel ) )
     627                 :            :                     {
     628                 :          0 :                         OUString tmpLabel;
     629         [ #  # ]:          0 :                         tmpPropSeq[i].Value >>= tmpLabel;
     630                 :            : 
     631         [ #  # ]:          0 :                         if ( tmpLabel.equals( pEntry->GetName() ) )
     632                 :            :                         {
     633                 :          0 :                             isDefaultName = sal_True;
     634                 :            :                         }
     635                 :            : 
     636                 :          0 :                         break;
     637                 :            :                     }
     638                 :            :                 }
     639 [ #  # ][ #  # ]:          0 :             }
     640                 :            :         }
     641         [ #  # ]:          0 :         catch ( container::NoSuchElementException& )
     642                 :            :         {
     643                 :            :             // isDefaultName is left as FALSE
     644                 :            :         }
     645                 :            : 
     646         [ #  # ]:          0 :         if ( isDefaultName )
     647                 :            :         {
     648 [ #  # ][ #  # ]:          0 :             aPropSeq[2].Value <<= rtl::OUString();
     649                 :            :         }
     650                 :            :         else
     651                 :            :         {
     652 [ #  # ][ #  # ]:          0 :             aPropSeq[2].Value <<= rtl::OUString( pEntry->GetName() );
     653                 :            :         }
     654                 :            :     }
     655                 :            :     else
     656                 :            :     {
     657 [ #  # ][ #  # ]:          0 :         aPropSeq[2].Value <<= rtl::OUString( pEntry->GetName() );
     658                 :            :     }
     659                 :            : 
     660                 :          0 :     return aPropSeq;
     661                 :            : }
     662                 :            : 
     663                 :            : uno::Sequence< beans::PropertyValue >
     664                 :          0 : ConvertToolbarEntry(
     665                 :            :     const uno::Reference< container::XNameAccess >& xCommandToLabelMap,
     666                 :            :     const SvxConfigEntry* pEntry )
     667                 :            : {
     668                 :            :     static const OUString aDescriptorCommandURL (
     669 [ #  # ][ #  # ]:          0 :         ITEM_DESCRIPTOR_COMMANDURL  );
     670                 :            : 
     671                 :            :     static const OUString aDescriptorType(
     672 [ #  # ][ #  # ]:          0 :             ITEM_DESCRIPTOR_TYPE  );
     673                 :            : 
     674                 :            :     static const OUString aDescriptorLabel(
     675 [ #  # ][ #  # ]:          0 :             ITEM_DESCRIPTOR_LABEL  );
     676                 :            : 
     677                 :            :     static const OUString aDescriptorContainer(
     678 [ #  # ][ #  # ]:          0 :             ITEM_DESCRIPTOR_CONTAINER  );
     679                 :            : 
     680                 :            :     static const OUString aIsVisible(
     681 [ #  # ][ #  # ]:          0 :             ITEM_DESCRIPTOR_ISVISIBLE  );
     682                 :            : 
     683                 :          0 :     uno::Sequence< beans::PropertyValue > aPropSeq( 4 );
     684                 :            : 
     685         [ #  # ]:          0 :     aPropSeq[0].Name = aDescriptorCommandURL;
     686 [ #  # ][ #  # ]:          0 :     aPropSeq[0].Value <<= rtl::OUString( pEntry->GetCommand() );
     687                 :            : 
     688         [ #  # ]:          0 :     aPropSeq[1].Name = aDescriptorType;
     689 [ #  # ][ #  # ]:          0 :     aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
     690                 :            : 
     691                 :            :     // If the name has not been changed and the name is the same as
     692                 :            :     // in the default command to label map then the label can be stored
     693                 :            :     // as an empty string.
     694                 :            :     // It will be initialised again later using the command to label map.
     695         [ #  # ]:          0 :     aPropSeq[2].Name = aDescriptorLabel;
     696 [ #  # ][ #  # ]:          0 :     if ( pEntry->HasChangedName() == sal_False && !pEntry->GetCommand().isEmpty() )
                 [ #  # ]
     697                 :            :     {
     698                 :          0 :         sal_Bool isDefaultName = sal_False;
     699                 :            :         try
     700                 :            :         {
     701 [ #  # ][ #  # ]:          0 :             uno::Any a( xCommandToLabelMap->getByName( pEntry->GetCommand() ) );
     702         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > tmpPropSeq;
     703 [ #  # ][ #  # ]:          0 :             if ( a >>= tmpPropSeq )
     704                 :            :             {
     705         [ #  # ]:          0 :                 for ( sal_Int32 i = 0; i < tmpPropSeq.getLength(); ++i )
     706                 :            :                 {
     707 [ #  # ][ #  # ]:          0 :                     if ( tmpPropSeq[i].Name.equals( aDescriptorLabel ) )
     708                 :            :                     {
     709                 :          0 :                         OUString tmpLabel;
     710         [ #  # ]:          0 :                         tmpPropSeq[i].Value >>= tmpLabel;
     711                 :            : 
     712         [ #  # ]:          0 :                         if ( tmpLabel.equals( pEntry->GetName() ) )
     713                 :            :                         {
     714                 :          0 :                             isDefaultName = sal_True;
     715                 :            :                         }
     716                 :            : 
     717                 :          0 :                         break;
     718                 :            :                     }
     719                 :            :                 }
     720 [ #  # ][ #  # ]:          0 :             }
     721                 :            :         }
     722         [ #  # ]:          0 :         catch ( container::NoSuchElementException& )
     723                 :            :         {
     724                 :            :             // isDefaultName is left as FALSE
     725                 :            :         }
     726                 :            : 
     727         [ #  # ]:          0 :         if ( isDefaultName )
     728                 :            :         {
     729 [ #  # ][ #  # ]:          0 :             aPropSeq[2].Value <<= rtl::OUString();
     730                 :            :         }
     731                 :            :         else
     732                 :            :         {
     733 [ #  # ][ #  # ]:          0 :             aPropSeq[2].Value <<= rtl::OUString( pEntry->GetName() );
     734                 :            :         }
     735                 :            :     }
     736                 :            :     else
     737                 :            :     {
     738 [ #  # ][ #  # ]:          0 :         aPropSeq[2].Value <<= rtl::OUString( pEntry->GetName() );
     739                 :            :     }
     740                 :            : 
     741         [ #  # ]:          0 :     aPropSeq[3].Name = aIsVisible;
     742 [ #  # ][ #  # ]:          0 :     aPropSeq[3].Value <<= pEntry->IsVisible();
     743                 :            : 
     744                 :          0 :     return aPropSeq;
     745                 :            : }
     746                 :            : 
     747                 :          0 : SfxTabPage *CreateSvxMenuConfigPage( Window *pParent, const SfxItemSet& rSet )
     748                 :            : {
     749         [ #  # ]:          0 :     return new SvxMenuConfigPage( pParent, rSet );
     750                 :            : }
     751                 :            : 
     752                 :          0 : SfxTabPage *CreateKeyboardConfigPage( Window *pParent, const SfxItemSet& rSet )
     753                 :            : {
     754         [ #  # ]:          0 :        return new SfxAcceleratorConfigPage( pParent, rSet );
     755                 :            : }
     756                 :            : 
     757                 :          0 : SfxTabPage *CreateSvxToolbarConfigPage( Window *pParent, const SfxItemSet& rSet )
     758                 :            : {
     759         [ #  # ]:          0 :     return new SvxToolbarConfigPage( pParent, rSet );
     760                 :            : }
     761                 :            : 
     762                 :          0 : SfxTabPage *CreateSvxEventConfigPage( Window *pParent, const SfxItemSet& rSet )
     763                 :            : {
     764 [ #  # ][ #  # ]:          0 :     return new SvxEventConfigPage( pParent, rSet, SvxEventConfigPage::EarlyInit() );
     765                 :            : }
     766                 :            : 
     767                 :          0 : sal_Bool impl_showKeyConfigTabPage( const css::uno::Reference< css::frame::XFrame >& xFrame )
     768                 :            : {
     769 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString SERVICENAME_MODULEMANAGER ("com.sun.star.frame.ModuleManager" );
     770 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString SERVICENAME_DESKTOP       ("com.sun.star.frame.Desktop"            );
     771 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString MODULEID_STARTMODULE      ("com.sun.star.frame.StartModule"        );
     772                 :            : 
     773                 :            :     try
     774                 :            :     {
     775         [ #  # ]:          0 :         css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR   = ::comphelper::getProcessServiceFactory();
     776 [ #  # ][ #  # ]:          0 :         css::uno::Reference< css::frame::XFramesSupplier >     xDesktop(xSMGR->createInstance(SERVICENAME_DESKTOP), css::uno::UNO_QUERY_THROW);
                 [ #  # ]
     777 [ #  # ][ #  # ]:          0 :         css::uno::Reference< css::frame::XModuleManager >     xMM     (xSMGR->createInstance(SERVICENAME_MODULEMANAGER), css::uno::UNO_QUERY_THROW);
                 [ #  # ]
     778                 :            : 
     779 [ #  # ][ #  # ]:          0 :         if (xMM.is() && xFrame.is())
                 [ #  # ]
     780                 :            :         {
     781 [ #  # ][ #  # ]:          0 :             ::rtl::OUString sModuleId = xMM->identify(xFrame);
     782         [ #  # ]:          0 :             if (
           [ #  #  #  # ]
     783                 :          0 :                 ( !sModuleId.isEmpty()                 ) &&
     784                 :          0 :                 (!sModuleId.equals(MODULEID_STARTMODULE))
     785                 :            :                )
     786         [ #  # ]:          0 :                return sal_True;
     787 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
     788                 :            :     }
     789                 :          0 :     catch(const css::uno::Exception&)
     790                 :            :         {}
     791                 :            : 
     792                 :          0 :     return sal_False;
     793                 :            : }
     794                 :            : 
     795                 :            : /******************************************************************************
     796                 :            :  *
     797                 :            :  * SvxConfigDialog is the configuration dialog which is brought up from the
     798                 :            :  * Tools menu. It includes tabs for customizing menus, toolbars, events and
     799                 :            :  * key bindings.
     800                 :            :  *
     801                 :            :  *****************************************************************************/
     802                 :          0 : SvxConfigDialog::SvxConfigDialog(
     803                 :            :     Window * pParent, const SfxItemSet* pSet_ )
     804                 :            :     :
     805                 :            :         SfxTabDialog( pParent,
     806         [ #  # ]:          0 :             CUI_RES( RID_SVXDLG_CUSTOMIZE ), pSet_ )
     807                 :            : {
     808         [ #  # ]:          0 :     FreeResource();
     809                 :            : 
     810         [ #  # ]:          0 :     InitImageType();
     811                 :            : 
     812         [ #  # ]:          0 :     AddTabPage( RID_SVXPAGE_MENUS, CreateSvxMenuConfigPage, NULL );
     813         [ #  # ]:          0 :     AddTabPage( RID_SVXPAGE_KEYBOARD, CreateKeyboardConfigPage, NULL );
     814         [ #  # ]:          0 :     AddTabPage( RID_SVXPAGE_TOOLBARS, CreateSvxToolbarConfigPage, NULL );
     815         [ #  # ]:          0 :     AddTabPage( RID_SVXPAGE_EVENTS, CreateSvxEventConfigPage, NULL );
     816                 :            : 
     817                 :            :     const SfxPoolItem* pItem =
     818 [ #  # ][ #  # ]:          0 :         pSet_->GetItem( pSet_->GetPool()->GetWhich( SID_CONFIG ) );
     819                 :            : 
     820         [ #  # ]:          0 :     if ( pItem )
     821                 :            :     {
     822         [ #  # ]:          0 :         OUString text = ((const SfxStringItem*)pItem)->GetValue();
     823                 :            : 
     824         [ #  # ]:          0 :         if (text.indexOf( ITEM_TOOLBAR_URL ) == 0)
     825                 :            :         {
     826                 :          0 :             SetCurPageId( RID_SVXPAGE_TOOLBARS );
     827                 :          0 :         }
     828                 :            :     }
     829                 :          0 : }
     830                 :            : 
     831                 :          0 : void SvxConfigDialog::SetFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame)
     832                 :            : {
     833                 :          0 :     m_xFrame = xFrame;
     834                 :            : 
     835         [ #  # ]:          0 :     if (!impl_showKeyConfigTabPage( xFrame ))
     836                 :          0 :         RemoveTabPage( RID_SVXPAGE_KEYBOARD );
     837                 :          0 : }
     838                 :            : 
     839                 :          0 : SvxConfigDialog::~SvxConfigDialog()
     840                 :            : {
     841         [ #  # ]:          0 : }
     842                 :            : 
     843                 :          0 : short SvxConfigDialog::Ok()
     844                 :            : {
     845                 :          0 :     return SfxTabDialog::Ok();
     846                 :            : }
     847                 :            : 
     848                 :          0 : void SvxConfigDialog::PageCreated( sal_uInt16 nId, SfxTabPage& rPage )
     849                 :            : {
     850                 :            :     (void)rPage;
     851                 :            : 
     852      [ #  #  # ]:          0 :     switch ( nId )
     853                 :            :     {
     854                 :            :         case RID_SVXPAGE_MENUS:
     855                 :            :         case RID_SVXPAGE_TOOLBARS:
     856                 :            :         case RID_SVXPAGE_KEYBOARD:
     857                 :            :             {
     858                 :          0 :                 rPage.SetFrame(m_xFrame);
     859                 :            :             }
     860                 :          0 :             break;
     861                 :            :         case RID_SVXPAGE_EVENTS:
     862                 :            :             {
     863         [ #  # ]:          0 :                 dynamic_cast< SvxEventConfigPage& >( rPage ).LateInit( m_xFrame );
     864                 :            :             };
     865                 :          0 :             break;
     866                 :            :         default:
     867                 :          0 :             break;
     868                 :            :     }
     869                 :          0 : }
     870                 :            : 
     871                 :            : /******************************************************************************
     872                 :            :  *
     873                 :            :  * The SaveInData class is used to hold data for entries in the Save In
     874                 :            :  * ListBox controls in the menu and toolbar tabs
     875                 :            :  *
     876                 :            :  ******************************************************************************/
     877                 :            : 
     878                 :            : // Initialize static variable which holds default XImageManager
     879                 :            : uno::Reference< css::ui::XImageManager>* SaveInData::xDefaultImgMgr = NULL;
     880                 :            : 
     881                 :          0 : SaveInData::SaveInData(
     882                 :            :     const uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
     883                 :            :     const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
     884                 :            :     const OUString& aModuleId,
     885                 :            :     bool isDocConfig )
     886                 :            :         :
     887                 :            :             bModified( sal_False ),
     888                 :            :             bDocConfig( isDocConfig ),
     889                 :            :             bReadOnly( sal_False ),
     890                 :            :             m_xCfgMgr( xCfgMgr ),
     891         [ #  # ]:          0 :             m_xParentCfgMgr( xParentCfgMgr )
     892                 :            : {
     893                 :            :     uno::Reference< beans::XPropertySet > xProps(
     894 [ #  # ][ #  # ]:          0 :         ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
     895                 :            : 
     896         [ #  # ]:          0 :     xProps->getPropertyValue(
     897                 :          0 :         OUString("DefaultContext" ))
     898 [ #  # ][ #  # ]:          0 :             >>= m_xComponentContext;
     899                 :            : 
     900         [ #  # ]:          0 :     m_aSeparatorSeq.realloc( 1 );
     901         [ #  # ]:          0 :     m_aSeparatorSeq[0].Name  = OUString( ITEM_DESCRIPTOR_TYPE  );
     902 [ #  # ][ #  # ]:          0 :     m_aSeparatorSeq[0].Value <<= css::ui::ItemType::SEPARATOR_LINE;
     903                 :            : 
     904         [ #  # ]:          0 :     if ( bDocConfig )
     905                 :            :     {
     906                 :            :         uno::Reference< css::ui::XUIConfigurationPersistence >
     907 [ #  # ][ #  # ]:          0 :             xDocPersistence( GetConfigManager(), uno::UNO_QUERY );
     908                 :            : 
     909 [ #  # ][ #  # ]:          0 :         bReadOnly = xDocPersistence->isReadOnly();
     910                 :            :     }
     911                 :            : 
     912                 :            :     m_xServiceManager = uno::Reference< lang::XMultiServiceFactory >(
     913 [ #  # ][ #  # ]:          0 :         ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
                 [ #  # ]
     914                 :            : 
     915                 :            :     uno::Reference< container::XNameAccess > xNameAccess(
     916         [ #  # ]:          0 :         m_xServiceManager->createInstance(
     917                 :          0 :             OUString( "com.sun.star.frame.UICommandDescription"  ) ),
     918 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY );
     919                 :            : 
     920         [ #  # ]:          0 :     if ( xNameAccess.is() )
     921 [ #  # ][ #  # ]:          0 :         xNameAccess->getByName( aModuleId ) >>= m_xCommandToLabelMap;
                 [ #  # ]
     922                 :            : 
     923         [ #  # ]:          0 :     if ( !m_xImgMgr.is() )
     924                 :            :     {
     925                 :            :         m_xImgMgr = uno::Reference< css::ui::XImageManager >(
     926 [ #  # ][ #  # ]:          0 :             GetConfigManager()->getImageManager(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     927                 :            :     }
     928                 :            : 
     929         [ #  # ]:          0 :     if ( !IsDocConfig() )
     930                 :            :     {
     931                 :            :         // If this is not a document configuration then it is the settings
     932                 :            :         // for the module (writer, calc, impress etc.) Use this as the default
     933                 :            :         // XImageManager instance
     934                 :          0 :         xDefaultImgMgr = &m_xImgMgr;
     935                 :            :     }
     936                 :            :     else
     937                 :            :     {
     938                 :            :         // If this is a document configuration then use the module image manager
     939                 :            :         // as default.
     940         [ #  # ]:          0 :         if ( m_xParentCfgMgr.is() )
     941                 :            :         {
     942                 :            :             m_xParentImgMgr = uno::Reference< css::ui::XImageManager >(
     943 [ #  # ][ #  # ]:          0 :                 m_xParentCfgMgr->getImageManager(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
     944                 :          0 :             xDefaultImgMgr = &m_xParentImgMgr;
     945                 :            :         }
     946                 :          0 :     }
     947                 :          0 : }
     948                 :            : 
     949                 :          0 : uno::Reference< graphic::XGraphic > GetGraphic(
     950                 :            :     const uno::Reference< css::ui::XImageManager >& xImageManager,
     951                 :            :     const OUString& rCommandURL )
     952                 :            : {
     953                 :          0 :     uno::Reference< graphic::XGraphic > result;
     954                 :            : 
     955         [ #  # ]:          0 :     if ( xImageManager.is() )
     956                 :            :     {
     957                 :            :         // TODO handle large graphics
     958         [ #  # ]:          0 :         uno::Sequence< uno::Reference< graphic::XGraphic > > aGraphicSeq;
     959                 :            : 
     960         [ #  # ]:          0 :         uno::Sequence< OUString > aImageCmdSeq( 1 );
     961         [ #  # ]:          0 :         aImageCmdSeq[0] = rCommandURL;
     962                 :            : 
     963                 :            :         try
     964                 :            :         {
     965                 :            :             aGraphicSeq =
     966 [ #  # ][ #  # ]:          0 :                 xImageManager->getImages( GetImageType(), aImageCmdSeq );
           [ #  #  #  # ]
                 [ #  # ]
     967                 :            : 
     968         [ #  # ]:          0 :             if ( aGraphicSeq.getLength() > 0 )
     969                 :            :             {
     970 [ #  # ][ #  # ]:          0 :                 result =  aGraphicSeq[0];
     971                 :            :             }
     972                 :            :         }
     973         [ #  # ]:          0 :         catch ( uno::Exception& )
     974                 :            :         {
     975                 :            :             // will return empty XGraphic
     976 [ #  # ][ #  # ]:          0 :         }
     977                 :            :     }
     978                 :            : 
     979                 :          0 :     return result;
     980                 :            : }
     981                 :            : 
     982                 :          0 : Image SaveInData::GetImage( const OUString& rCommandURL )
     983                 :            : {
     984         [ #  # ]:          0 :     Image aImage;
     985                 :            : 
     986                 :            :     uno::Reference< graphic::XGraphic > xGraphic =
     987         [ #  # ]:          0 :         GetGraphic( m_xImgMgr, rCommandURL );
     988                 :            : 
     989         [ #  # ]:          0 :     if ( xGraphic.is() )
     990                 :            :     {
     991 [ #  # ][ #  # ]:          0 :         aImage = Image( xGraphic );
                 [ #  # ]
     992                 :            :     }
     993 [ #  # ][ #  # ]:          0 :     else if ( xDefaultImgMgr != NULL && (*xDefaultImgMgr).is() )
                 [ #  # ]
     994                 :            :     {
     995 [ #  # ][ #  # ]:          0 :         xGraphic = GetGraphic( (*xDefaultImgMgr), rCommandURL );
     996                 :            : 
     997         [ #  # ]:          0 :         if ( xGraphic.is() )
     998                 :            :         {
     999 [ #  # ][ #  # ]:          0 :             aImage = Image( xGraphic );
                 [ #  # ]
    1000                 :            :         }
    1001                 :            :     }
    1002                 :            : 
    1003                 :          0 :     return aImage;
    1004                 :            : }
    1005                 :            : 
    1006                 :          0 : bool SaveInData::PersistChanges(
    1007                 :            :     const uno::Reference< uno::XInterface >& xManager )
    1008                 :            : {
    1009                 :          0 :     bool result = sal_True;
    1010                 :            : 
    1011                 :            :     try
    1012                 :            :     {
    1013 [ #  # ][ #  # ]:          0 :         if ( xManager.is() && !IsReadOnly() )
                 [ #  # ]
    1014                 :            :         {
    1015                 :            :             uno::Reference< css::ui::XUIConfigurationPersistence >
    1016         [ #  # ]:          0 :                 xConfigPersistence( xManager, uno::UNO_QUERY );
    1017                 :            : 
    1018 [ #  # ][ #  # ]:          0 :             if ( xConfigPersistence->isModified() )
                 [ #  # ]
    1019                 :            :             {
    1020 [ #  # ][ #  # ]:          0 :                 xConfigPersistence->store();
    1021         [ #  # ]:          0 :             }
    1022                 :            :         }
    1023                 :            :     }
    1024                 :          0 :     catch ( com::sun::star::io::IOException& )
    1025                 :            :     {
    1026                 :          0 :         result = sal_False;
    1027                 :            :     }
    1028                 :            : 
    1029                 :          0 :     return result;
    1030                 :            : }
    1031                 :            : 
    1032                 :            : /******************************************************************************
    1033                 :            :  *
    1034                 :            :  * The MenuSaveInData class extends SaveInData and provides menu specific
    1035                 :            :  * load and store functionality.
    1036                 :            :  *
    1037                 :            :  ******************************************************************************/
    1038                 :            : 
    1039                 :            : // Initialize static variable which holds default Menu data
    1040                 :            : MenuSaveInData* MenuSaveInData::pDefaultData = NULL;
    1041                 :            : 
    1042                 :          0 : MenuSaveInData::MenuSaveInData(
    1043                 :            :     const uno::Reference< css::ui::XUIConfigurationManager >& cfgmgr,
    1044                 :            :     const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
    1045                 :            :     const OUString& aModuleId,
    1046                 :            :     bool isDocConfig )
    1047                 :            :     :
    1048                 :            :         SaveInData( cfgmgr, xParentCfgMgr, aModuleId, isDocConfig ),
    1049                 :            :         m_aMenuResourceURL(
    1050                 :            :             ITEM_MENUBAR_URL  ),
    1051                 :            :         m_aDescriptorContainer(
    1052                 :            :             ITEM_DESCRIPTOR_CONTAINER  ),
    1053                 :          0 :         pRootEntry( 0 )
    1054                 :            : {
    1055                 :            :     try
    1056                 :            :     {
    1057                 :          0 :         OUString url( ITEM_MENUBAR_URL  );
    1058 [ #  # ][ #  # ]:          0 :         m_xMenuSettings = GetConfigManager()->getSettings( url, sal_False );
         [ #  # ][ #  # ]
                 [ #  # ]
    1059                 :            :     }
    1060         [ #  # ]:          0 :     catch ( container::NoSuchElementException& )
    1061                 :            :     {
    1062                 :            :         // will use menu settings for the module
    1063                 :            :     }
    1064                 :            : 
    1065                 :            :     // If this is not a document configuration then it is the settings
    1066                 :            :     // for the module (writer, calc, impress etc.). These settings should
    1067                 :            :     // be set as the default to be used for SaveIn locations that do not
    1068                 :            :     // have custom settings
    1069         [ #  # ]:          0 :     if ( !IsDocConfig() )
    1070                 :            :     {
    1071                 :          0 :         SetDefaultData( this );
    1072                 :            :     }
    1073                 :          0 : }
    1074                 :            : 
    1075                 :          0 : MenuSaveInData::~MenuSaveInData()
    1076                 :            : {
    1077         [ #  # ]:          0 :     if ( pRootEntry != NULL )
    1078                 :            :     {
    1079 [ #  # ][ #  # ]:          0 :         delete pRootEntry;
    1080                 :            :     }
    1081         [ #  # ]:          0 : }
    1082                 :            : 
    1083                 :            : SvxEntries*
    1084                 :          0 : MenuSaveInData::GetEntries()
    1085                 :            : {
    1086         [ #  # ]:          0 :     if ( pRootEntry == NULL )
    1087                 :            :     {
    1088                 :            :         pRootEntry = new SvxConfigEntry(
    1089                 :            :             rtl::OUString("MainMenus"),
    1090 [ #  # ][ #  # ]:          0 :             rtl::OUString(), sal_True);
    1091                 :            : 
    1092         [ #  # ]:          0 :         if ( m_xMenuSettings.is() )
    1093                 :            :         {
    1094 [ #  # ][ #  # ]:          0 :             LoadSubMenus( m_xMenuSettings, String(), pRootEntry );
    1095                 :            :         }
    1096         [ #  # ]:          0 :         else if ( GetDefaultData() != NULL )
    1097                 :            :         {
    1098                 :            :             // If the doc has no config settings use module config settings
    1099 [ #  # ][ #  # ]:          0 :             LoadSubMenus( GetDefaultData()->m_xMenuSettings, String(), pRootEntry );
    1100                 :            :         }
    1101                 :            :     }
    1102                 :            : 
    1103                 :          0 :     return pRootEntry->GetEntries();
    1104                 :            : }
    1105                 :            : 
    1106                 :            : void
    1107                 :          0 : MenuSaveInData::SetEntries( SvxEntries* pNewEntries )
    1108                 :            : {
    1109                 :            :     // delete old menu hierarchy first
    1110         [ #  # ]:          0 :     if ( pRootEntry != NULL )
    1111                 :            :     {
    1112         [ #  # ]:          0 :         delete pRootEntry->GetEntries();
    1113                 :            :     }
    1114                 :            : 
    1115                 :            :     // now set new menu hierarchy
    1116                 :          0 :     pRootEntry->SetEntries( pNewEntries );
    1117                 :          0 : }
    1118                 :            : 
    1119                 :          0 : bool MenuSaveInData::LoadSubMenus(
    1120                 :            :     const uno::Reference< container::XIndexAccess >& xMenuSettings,
    1121                 :            :     const OUString& rBaseTitle,
    1122                 :            :     SvxConfigEntry* pParentData )
    1123                 :            : {
    1124                 :          0 :     SvxEntries* pEntries = pParentData->GetEntries();
    1125                 :            : 
    1126                 :            :     // Don't access non existing menu configuration!
    1127         [ #  # ]:          0 :     if ( !xMenuSettings.is() )
    1128                 :          0 :         return true;
    1129                 :            : 
    1130         [ #  # ]:          0 :     for ( sal_Int32 nIndex = 0; nIndex < xMenuSettings->getCount(); ++nIndex )
    1131                 :            :     {
    1132                 :          0 :         uno::Reference< container::XIndexAccess >   xSubMenu;
    1133                 :          0 :         OUString                aCommandURL;
    1134                 :          0 :         OUString                aLabel;
    1135                 :          0 :         bool                    bIsUserDefined = sal_True;
    1136                 :            : 
    1137                 :          0 :         sal_uInt16 nType( css::ui::ItemType::DEFAULT );
    1138                 :            : 
    1139                 :            :         bool bItem = GetMenuItemData( xMenuSettings, nIndex,
    1140         [ #  # ]:          0 :             aCommandURL, aLabel, nType, xSubMenu );
    1141                 :            : 
    1142         [ #  # ]:          0 :         if ( bItem )
    1143                 :            :         {
    1144         [ #  # ]:          0 :             if ( nType == css::ui::ItemType::DEFAULT )
    1145                 :            :             {
    1146                 :          0 :                 uno::Any a;
    1147                 :            :                 try
    1148                 :            :                 {
    1149 [ #  # ][ #  # ]:          0 :                     a = m_xCommandToLabelMap->getByName( aCommandURL );
    1150                 :          0 :                     bIsUserDefined = sal_False;
    1151                 :            :                 }
    1152         [ #  # ]:          0 :                 catch ( container::NoSuchElementException& )
    1153                 :            :                 {
    1154                 :          0 :                     bIsUserDefined = sal_True;
    1155                 :            :                 }
    1156                 :            : 
    1157                 :            :                 // If custom label not set retrieve it from the command
    1158                 :            :                 // to info service
    1159         [ #  # ]:          0 :                 if ( aLabel.equals( OUString() ) )
    1160                 :            :                 {
    1161         [ #  # ]:          0 :                     uno::Sequence< beans::PropertyValue > aPropSeq;
    1162 [ #  # ][ #  # ]:          0 :                     if ( a >>= aPropSeq )
    1163                 :            :                     {
    1164         [ #  # ]:          0 :                         for ( sal_Int32 i = 0; i < aPropSeq.getLength(); ++i )
    1165                 :            :                         {
    1166 [ #  # ][ #  # ]:          0 :                             if ( aPropSeq[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ) )
    1167                 :            :                             {
    1168         [ #  # ]:          0 :                                 aPropSeq[i].Value >>= aLabel;
    1169                 :          0 :                                 break;
    1170                 :            :                             }
    1171                 :            :                         }
    1172         [ #  # ]:          0 :                     }
    1173                 :            :                 }
    1174                 :            : 
    1175         [ #  # ]:          0 :                 if ( xSubMenu.is() )
    1176                 :            :                 {
    1177                 :            :                     // popup menu
    1178                 :            :                     SvxConfigEntry* pEntry = new SvxConfigEntry(
    1179 [ #  # ][ #  # ]:          0 :                         aLabel, aCommandURL, sal_True );
    1180                 :            : 
    1181                 :          0 :                     pEntry->SetUserDefined( bIsUserDefined );
    1182                 :            : 
    1183         [ #  # ]:          0 :                     pEntries->push_back( pEntry );
    1184                 :            : 
    1185                 :          0 :                     OUString subMenuTitle( rBaseTitle );
    1186                 :            : 
    1187         [ #  # ]:          0 :                     if ( !subMenuTitle.isEmpty() )
    1188                 :            :                     {
    1189                 :          0 :                         subMenuTitle += OUString( aMenuSeparatorStr);
    1190                 :            :                     }
    1191                 :            :                     else
    1192                 :            :                     {
    1193                 :          0 :                         pEntry->SetMain( sal_True );
    1194                 :            :                     }
    1195                 :            : 
    1196                 :          0 :                     subMenuTitle += stripHotKey( aLabel );
    1197                 :            : 
    1198         [ #  # ]:          0 :                     LoadSubMenus( xSubMenu, subMenuTitle, pEntry );
    1199                 :            :                 }
    1200                 :            :                 else
    1201                 :            :                 {
    1202                 :            :                     SvxConfigEntry* pEntry = new SvxConfigEntry(
    1203 [ #  # ][ #  # ]:          0 :                         aLabel, aCommandURL, sal_False );
    1204                 :          0 :                     pEntry->SetUserDefined( bIsUserDefined );
    1205         [ #  # ]:          0 :                     pEntries->push_back( pEntry );
    1206                 :          0 :                 }
    1207                 :            :             }
    1208                 :            :             else
    1209                 :            :             {
    1210 [ #  # ][ #  # ]:          0 :                 SvxConfigEntry* pEntry = new SvxConfigEntry;
    1211                 :          0 :                 pEntry->SetUserDefined( bIsUserDefined );
    1212         [ #  # ]:          0 :                 pEntries->push_back( pEntry );
    1213                 :            :             }
    1214                 :            :         }
    1215                 :          0 :     }
    1216         [ #  # ]:          0 :     return true;
    1217                 :            : }
    1218                 :            : 
    1219                 :          0 : bool MenuSaveInData::Apply()
    1220                 :            : {
    1221                 :          0 :     bool result = sal_False;
    1222                 :            : 
    1223         [ #  # ]:          0 :     if ( IsModified() )
    1224                 :            :     {
    1225                 :            :         // Apply new menu bar structure to our settings container
    1226                 :            :         m_xMenuSettings = uno::Reference< container::XIndexAccess >(
    1227 [ #  # ][ #  # ]:          0 :             GetConfigManager()->createSettings(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
    1228                 :            : 
    1229                 :            :         uno::Reference< container::XIndexContainer > xIndexContainer (
    1230         [ #  # ]:          0 :             m_xMenuSettings, uno::UNO_QUERY );
    1231                 :            : 
    1232                 :            :         uno::Reference< lang::XSingleComponentFactory > xFactory (
    1233         [ #  # ]:          0 :             m_xMenuSettings, uno::UNO_QUERY );
    1234                 :            : 
    1235         [ #  # ]:          0 :         Apply( pRootEntry, xIndexContainer, xFactory, NULL );
    1236                 :            : 
    1237                 :            :         try
    1238                 :            :         {
    1239 [ #  # ][ #  # ]:          0 :             if ( GetConfigManager()->hasSettings( m_aMenuResourceURL ) )
         [ #  # ][ #  # ]
    1240                 :            :             {
    1241 [ #  # ][ #  # ]:          0 :                 GetConfigManager()->replaceSettings(
    1242         [ #  # ]:          0 :                     m_aMenuResourceURL, m_xMenuSettings );
    1243                 :            :             }
    1244                 :            :             else
    1245                 :            :             {
    1246 [ #  # ][ #  # ]:          0 :                 GetConfigManager()->insertSettings(
           [ #  #  #  # ]
    1247         [ #  # ]:          0 :                     m_aMenuResourceURL, m_xMenuSettings );
    1248                 :            :             }
    1249                 :            :         }
    1250         [ #  # ]:          0 :         catch ( container::NoSuchElementException& )
    1251                 :            :         {
    1252                 :            :             OSL_TRACE("caught container::NoSuchElementException saving settings");
    1253                 :            :         }
    1254         [ #  # ]:          0 :         catch ( com::sun::star::io::IOException& )
    1255                 :            :         {
    1256                 :            :             OSL_TRACE("caught IOException saving settings");
    1257                 :            :         }
    1258         [ #  # ]:          0 :         catch ( com::sun::star::uno::Exception& )
    1259                 :            :         {
    1260                 :            :             OSL_TRACE("caught some other exception saving settings");
    1261                 :            :         }
    1262                 :            : 
    1263                 :          0 :         SetModified( sal_False );
    1264                 :            : 
    1265 [ #  # ][ #  # ]:          0 :         result = PersistChanges( GetConfigManager() );
    1266                 :            :     }
    1267                 :            : 
    1268                 :          0 :     return result;
    1269                 :            : }
    1270                 :            : 
    1271                 :          0 : void MenuSaveInData::Apply(
    1272                 :            :     SvxConfigEntry* pRootEntry_,
    1273                 :            :     uno::Reference< container::XIndexContainer >& rMenuBar,
    1274                 :            :     uno::Reference< lang::XSingleComponentFactory >& rFactory,
    1275                 :            :     SvLBoxEntry *pParentEntry )
    1276                 :            : {
    1277                 :            :     (void)pRootEntry_;
    1278                 :            :     (void)pParentEntry;
    1279                 :            : 
    1280 [ #  # ][ #  # ]:          0 :     SvxEntries::const_iterator iter = GetEntries()->begin();
    1281 [ #  # ][ #  # ]:          0 :     SvxEntries::const_iterator end = GetEntries()->end();
    1282                 :            : 
    1283 [ #  # ][ #  # ]:          0 :     for ( ; iter != end; ++iter )
    1284                 :            :     {
    1285                 :          0 :         SvxConfigEntry* pEntryData = *iter;
    1286                 :            : 
    1287                 :            :         uno::Sequence< beans::PropertyValue > aPropValueSeq =
    1288         [ #  # ]:          0 :             ConvertSvxConfigEntry( m_xCommandToLabelMap, pEntryData );
    1289                 :            : 
    1290                 :            :         uno::Reference< container::XIndexContainer > xSubMenuBar(
    1291         [ #  # ]:          0 :             rFactory->createInstanceWithContext( m_xComponentContext ),
    1292 [ #  # ][ #  # ]:          0 :             uno::UNO_QUERY );
    1293                 :            : 
    1294                 :          0 :         sal_Int32 nIndex = aPropValueSeq.getLength();
    1295         [ #  # ]:          0 :         aPropValueSeq.realloc( nIndex + 1 );
    1296         [ #  # ]:          0 :         aPropValueSeq[nIndex].Name = m_aDescriptorContainer;
    1297 [ #  # ][ #  # ]:          0 :         aPropValueSeq[nIndex].Value <<= xSubMenuBar;
    1298         [ #  # ]:          0 :         rMenuBar->insertByIndex(
    1299 [ #  # ][ #  # ]:          0 :             rMenuBar->getCount(), uno::makeAny( aPropValueSeq ));
         [ #  # ][ #  # ]
    1300         [ #  # ]:          0 :         ApplyMenu( xSubMenuBar, rFactory, pEntryData );
    1301         [ #  # ]:          0 :     }
    1302                 :          0 : }
    1303                 :            : 
    1304                 :          0 : void MenuSaveInData::ApplyMenu(
    1305                 :            :     uno::Reference< container::XIndexContainer >& rMenuBar,
    1306                 :            :     uno::Reference< lang::XSingleComponentFactory >& rFactory,
    1307                 :            :     SvxConfigEntry* pMenuData )
    1308                 :            : {
    1309         [ #  # ]:          0 :     SvxEntries::const_iterator iter = pMenuData->GetEntries()->begin();
    1310         [ #  # ]:          0 :     SvxEntries::const_iterator end = pMenuData->GetEntries()->end();
    1311                 :            : 
    1312 [ #  # ][ #  # ]:          0 :     for ( ; iter != end; ++iter )
    1313                 :            :     {
    1314                 :          0 :         SvxConfigEntry* pEntry = *iter;
    1315                 :            : 
    1316         [ #  # ]:          0 :         if ( pEntry->IsPopup() )
    1317                 :            :         {
    1318                 :            :             uno::Sequence< beans::PropertyValue > aPropValueSeq =
    1319         [ #  # ]:          0 :                 ConvertSvxConfigEntry( m_xCommandToLabelMap, pEntry );
    1320                 :            : 
    1321                 :            :             uno::Reference< container::XIndexContainer > xSubMenuBar(
    1322         [ #  # ]:          0 :                 rFactory->createInstanceWithContext( m_xComponentContext ),
    1323 [ #  # ][ #  # ]:          0 :                     uno::UNO_QUERY );
    1324                 :            : 
    1325                 :          0 :             sal_Int32 nIndex = aPropValueSeq.getLength();
    1326         [ #  # ]:          0 :             aPropValueSeq.realloc( nIndex + 1 );
    1327         [ #  # ]:          0 :             aPropValueSeq[nIndex].Name = m_aDescriptorContainer;
    1328 [ #  # ][ #  # ]:          0 :             aPropValueSeq[nIndex].Value <<= xSubMenuBar;
    1329                 :            : 
    1330         [ #  # ]:          0 :             rMenuBar->insertByIndex(
    1331 [ #  # ][ #  # ]:          0 :                 rMenuBar->getCount(), uno::makeAny( aPropValueSeq ));
         [ #  # ][ #  # ]
    1332                 :            : 
    1333 [ #  # ][ #  # ]:          0 :             ApplyMenu( xSubMenuBar, rFactory, pEntry );
    1334                 :            :         }
    1335         [ #  # ]:          0 :         else if ( pEntry->IsSeparator() )
    1336                 :            :         {
    1337         [ #  # ]:          0 :             rMenuBar->insertByIndex(
    1338 [ #  # ][ #  # ]:          0 :                 rMenuBar->getCount(), uno::makeAny( m_aSeparatorSeq ));
         [ #  # ][ #  # ]
    1339                 :            :         }
    1340                 :            :         else
    1341                 :            :         {
    1342                 :            :             uno::Sequence< beans::PropertyValue > aPropValueSeq =
    1343         [ #  # ]:          0 :                 ConvertSvxConfigEntry( m_xCommandToLabelMap, pEntry );
    1344         [ #  # ]:          0 :             rMenuBar->insertByIndex(
    1345 [ #  # ][ #  # ]:          0 :                 rMenuBar->getCount(), uno::makeAny( aPropValueSeq ));
         [ #  # ][ #  # ]
                 [ #  # ]
    1346                 :            :         }
    1347                 :            :     }
    1348                 :          0 : }
    1349                 :            : 
    1350                 :            : void
    1351                 :          0 : MenuSaveInData::Reset()
    1352                 :            : {
    1353 [ #  # ][ #  # ]:          0 :     GetConfigManager()->reset();
    1354                 :            : 
    1355         [ #  # ]:          0 :     delete pRootEntry;
    1356                 :          0 :     pRootEntry = NULL;
    1357                 :            : 
    1358                 :            :     try
    1359                 :            :     {
    1360         [ #  # ]:          0 :         m_xMenuSettings = GetConfigManager()->getSettings(
           [ #  #  #  # ]
    1361 [ #  # ][ #  # ]:          0 :             m_aMenuResourceURL, sal_False );
    1362                 :            :     }
    1363                 :          0 :     catch ( container::NoSuchElementException& )
    1364                 :            :     {
    1365                 :            :         // will use default settings
    1366                 :            :     }
    1367                 :          0 : }
    1368                 :            : 
    1369                 :            : class PopupPainter : public SvLBoxString
    1370                 :            : {
    1371                 :            : public:
    1372                 :          0 :     PopupPainter( SvLBoxEntry* pEntry, const String& rStr )
    1373         [ #  # ]:          0 :         : SvLBoxString( pEntry, 0, rStr )
    1374                 :          0 :     { }
    1375                 :            : 
    1376         [ #  # ]:          0 :     ~PopupPainter() { }
    1377                 :            : 
    1378                 :          0 :     void Paint( const Point& rPos, SvLBox& rOutDev,
    1379                 :            :         sal_uInt16 nViewDataEntryFlags, SvLBoxEntry* pEntry )
    1380                 :            :     {
    1381         [ #  # ]:          0 :         SvLBoxString::Paint( rPos, rOutDev, nViewDataEntryFlags, pEntry );
    1382                 :            : 
    1383                 :          0 :         Color aOldFillColor = rOutDev.GetFillColor();
    1384                 :            : 
    1385                 :          0 :         SvTreeListBox* pTreeBox = static_cast< SvTreeListBox* >( &rOutDev );
    1386         [ #  # ]:          0 :         long nX = pTreeBox->GetSizePixel().Width();
    1387                 :            : 
    1388         [ #  # ]:          0 :         ScrollBar* pVScroll = pTreeBox->GetVScroll();
    1389 [ #  # ][ #  # ]:          0 :         if ( pVScroll->IsVisible() )
    1390                 :            :         {
    1391         [ #  # ]:          0 :             nX -= pVScroll->GetSizePixel().Width();
    1392                 :            :         }
    1393                 :            : 
    1394         [ #  # ]:          0 :         SvViewDataItem* pItem = rOutDev.GetViewDataItem( pEntry, this );
    1395                 :          0 :         nX -= pItem->aSize.Height();
    1396                 :            : 
    1397                 :          0 :         long nSize = pItem->aSize.Height() / 2;
    1398                 :          0 :         long nHalfSize = nSize / 2;
    1399                 :          0 :         long nY = rPos.Y() + nHalfSize;
    1400                 :            : 
    1401         [ #  # ]:          0 :         if ( aOldFillColor == COL_WHITE )
    1402                 :            :         {
    1403         [ #  # ]:          0 :             rOutDev.SetFillColor( Color( COL_BLACK ) );
    1404                 :            :         }
    1405                 :            :         else
    1406                 :            :         {
    1407         [ #  # ]:          0 :             rOutDev.SetFillColor( Color( COL_WHITE ) );
    1408                 :            :         }
    1409                 :            : 
    1410                 :          0 :         long n = 0;
    1411         [ #  # ]:          0 :         while ( n <= nHalfSize )
    1412                 :            :         {
    1413 [ #  # ][ #  # ]:          0 :             rOutDev.DrawRect( Rectangle( nX+n, nY+n, nX+n, nY+nSize-n ) );
    1414                 :          0 :             ++n;
    1415                 :            :         }
    1416                 :            : 
    1417         [ #  # ]:          0 :         rOutDev.SetFillColor( aOldFillColor );
    1418                 :          0 :     }
    1419                 :            : };
    1420                 :            : 
    1421                 :            : /******************************************************************************
    1422                 :            :  *
    1423                 :            :  * SvxMenuEntriesListBox is the listbox in which the menu items for a
    1424                 :            :  * particular menu are shown. We have a custom listbox because we need
    1425                 :            :  * to add drag'n'drop support from the Macro Selector and within the
    1426                 :            :  * listbox
    1427                 :            :  *
    1428                 :            :  *****************************************************************************/
    1429                 :          0 : SvxMenuEntriesListBox::SvxMenuEntriesListBox(
    1430                 :            :     Window* pParent, const ResId& rResId)
    1431                 :            :     : SvTreeListBox( pParent, rResId )
    1432                 :            :     , pPage( (SvxMenuConfigPage*) pParent )
    1433                 :          0 :     , m_bIsInternalDrag( sal_False )
    1434                 :            : {
    1435                 :            :     SetStyle(
    1436 [ #  # ][ #  # ]:          0 :         GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_HIDESELECTION );
    1437                 :            : 
    1438         [ #  # ]:          0 :     SetSpaceBetweenEntries( 3 );
    1439         [ #  # ]:          0 :     SetEntryHeight( ENTRY_HEIGHT );
    1440                 :            : 
    1441         [ #  # ]:          0 :     SetHighlightRange();
    1442         [ #  # ]:          0 :     SetSelectionMode(SINGLE_SELECTION);
    1443                 :            : 
    1444                 :            :     SetDragDropMode( SV_DRAGDROP_CTRL_MOVE  |
    1445                 :            :                      SV_DRAGDROP_APP_COPY   |
    1446                 :            :                      SV_DRAGDROP_ENABLE_TOP |
    1447         [ #  # ]:          0 :                      SV_DRAGDROP_APP_DROP);
    1448                 :          0 : }
    1449                 :            : 
    1450                 :          0 : SvxMenuEntriesListBox::~SvxMenuEntriesListBox()
    1451                 :            : {
    1452                 :            :     // do nothing
    1453         [ #  # ]:          0 : }
    1454                 :            : 
    1455                 :            : // drag and drop support
    1456                 :          0 : DragDropMode SvxMenuEntriesListBox::NotifyStartDrag(
    1457                 :            :     TransferDataContainer& aTransferDataContainer, SvLBoxEntry* pEntry )
    1458                 :            : {
    1459                 :            :     (void)aTransferDataContainer;
    1460                 :            :     (void)pEntry;
    1461                 :            : 
    1462                 :          0 :     m_bIsInternalDrag = sal_True;
    1463                 :          0 :     return GetDragDropMode();
    1464                 :            : }
    1465                 :            : 
    1466                 :          0 : void SvxMenuEntriesListBox::DragFinished( sal_Int8 nDropAction )
    1467                 :            : {
    1468                 :            :     (void)nDropAction;
    1469                 :          0 :     m_bIsInternalDrag = sal_False;
    1470                 :          0 : }
    1471                 :            : 
    1472                 :          0 : sal_Int8 SvxMenuEntriesListBox::AcceptDrop( const AcceptDropEvent& rEvt )
    1473                 :            : {
    1474         [ #  # ]:          0 :     if ( m_bIsInternalDrag )
    1475                 :            :     {
    1476                 :            :         // internal copy isn't allowed!
    1477         [ #  # ]:          0 :         if ( rEvt.mnAction == DND_ACTION_COPY )
    1478                 :          0 :             return DND_ACTION_NONE;
    1479                 :            :         else
    1480         [ #  # ]:          0 :             return SvTreeListBox::AcceptDrop( rEvt );
    1481                 :            :     }
    1482                 :            : 
    1483                 :            :     // Always do COPY instead of MOVE if D&D comes from outside!
    1484         [ #  # ]:          0 :     AcceptDropEvent aNewAcceptDropEvent( rEvt );
    1485                 :          0 :     aNewAcceptDropEvent.mnAction = DND_ACTION_COPY;
    1486 [ #  # ][ #  # ]:          0 :     return SvTreeListBox::AcceptDrop( aNewAcceptDropEvent );
    1487                 :            : }
    1488                 :            : 
    1489                 :          0 : sal_Bool SvxMenuEntriesListBox::NotifyAcceptDrop( SvLBoxEntry* )
    1490                 :            : {
    1491                 :          0 :     return sal_True;
    1492                 :            : }
    1493                 :            : 
    1494                 :          0 : sal_Bool SvxMenuEntriesListBox::NotifyMoving(
    1495                 :            :     SvLBoxEntry* pTarget, SvLBoxEntry* pSource,
    1496                 :            :     SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos)
    1497                 :            : {
    1498                 :            :     // only try to do a move if we are dragging within the list box
    1499         [ #  # ]:          0 :     if ( m_bIsInternalDrag )
    1500                 :            :     {
    1501         [ #  # ]:          0 :         if ( pPage->MoveEntryData( pSource, pTarget ) == sal_True )
    1502                 :            :         {
    1503                 :            :             SvTreeListBox::NotifyMoving(
    1504                 :          0 :                 pTarget, pSource, rpNewParent, rNewChildPos );
    1505                 :          0 :             return sal_True;
    1506                 :            :         }
    1507                 :            :         else
    1508                 :            :         {
    1509                 :          0 :             return sal_False;
    1510                 :            :         }
    1511                 :            :     }
    1512                 :            :     else
    1513                 :            :     {
    1514                 :          0 :         return NotifyCopying( pTarget, pSource, rpNewParent, rNewChildPos );
    1515                 :            :     }
    1516                 :            : }
    1517                 :            : 
    1518                 :          0 : sal_Bool SvxMenuEntriesListBox::NotifyCopying(
    1519                 :            :     SvLBoxEntry* pTarget, SvLBoxEntry* pSource,
    1520                 :            :     SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos)
    1521                 :            : {
    1522                 :            :     (void)pSource;
    1523                 :            :     (void)rpNewParent;
    1524                 :            :     (void)rNewChildPos;
    1525                 :            : 
    1526         [ #  # ]:          0 :     if ( !m_bIsInternalDrag )
    1527                 :            :     {
    1528                 :            :         // if the target is NULL then add function to the start of the list
    1529                 :          0 :         pPage->AddFunction( pTarget, pTarget == NULL );
    1530                 :            : 
    1531                 :            :         // AddFunction already adds the listbox entry so return FALSE
    1532                 :            :         // to stop another listbox entry being added
    1533                 :          0 :         return sal_False;
    1534                 :            :     }
    1535                 :            : 
    1536                 :            :     // Copying is only allowed from external controls, not within the listbox
    1537                 :          0 :     return sal_False;
    1538                 :            : }
    1539                 :            : 
    1540                 :          0 : void SvxMenuEntriesListBox::KeyInput( const KeyEvent& rKeyEvent )
    1541                 :            : {
    1542                 :          0 :     KeyCode keycode = rKeyEvent.GetKeyCode();
    1543                 :            : 
    1544                 :            :     // support DELETE for removing the current entry
    1545 [ #  # ][ #  # ]:          0 :     if ( keycode == KEY_DELETE )
    1546                 :            :     {
    1547         [ #  # ]:          0 :         pPage->DeleteSelectedContent();
    1548                 :            :     }
    1549                 :            :     // support CTRL+UP and CTRL+DOWN for moving selected entries
    1550 [ #  # ][ #  # ]:          0 :     else if ( keycode.GetCode() == KEY_UP && keycode.IsMod1() )
                 [ #  # ]
    1551                 :            :     {
    1552         [ #  # ]:          0 :         pPage->MoveEntry( sal_True );
    1553                 :            :     }
    1554 [ #  # ][ #  # ]:          0 :     else if ( keycode.GetCode() == KEY_DOWN && keycode.IsMod1() )
                 [ #  # ]
    1555                 :            :     {
    1556         [ #  # ]:          0 :         pPage->MoveEntry( sal_False );
    1557                 :            :     }
    1558                 :            :     else
    1559                 :            :     {
    1560                 :            :         // pass on to superclass
    1561         [ #  # ]:          0 :         SvTreeListBox::KeyInput( rKeyEvent );
    1562                 :            :     }
    1563                 :          0 : }
    1564                 :            : 
    1565                 :            : // class SvxDescriptionEdit ----------------------------------------------
    1566                 :            : 
    1567                 :          0 : SvxDescriptionEdit::SvxDescriptionEdit( Window* pParent, const ResId& _rId ) :
    1568                 :            : 
    1569         [ #  # ]:          0 :     ExtMultiLineEdit( pParent, _rId )
    1570                 :            : 
    1571                 :            : {
    1572                 :            :     // calculate the available space for help text
    1573 [ #  # ][ #  # ]:          0 :     m_aRealRect = Rectangle( Point(), GetSizePixel() );
    1574 [ #  # ][ #  # ]:          0 :     if ( GetVScrollBar() )
    1575 [ #  # ][ #  # ]:          0 :         m_aRealRect.Right() -= ( GetVScrollBar()->GetSizePixel().Width() + 4 );
    1576                 :            : 
    1577         [ #  # ]:          0 :     SetLeftMargin(2);
    1578         [ #  # ]:          0 :     SetBorderStyle( WINDOW_BORDER_MONO );
    1579                 :          0 : }
    1580                 :            : 
    1581                 :            : // -----------------------------------------------------------------------
    1582                 :            : 
    1583                 :          0 : void SvxDescriptionEdit::SetNewText( const String& _rText )
    1584                 :            : {
    1585         [ #  # ]:          0 :     String sTemp( _rText );
    1586                 :          0 :     sal_Bool bShow = sal_False;
    1587         [ #  # ]:          0 :     if ( sTemp.Len() > 0 )
    1588                 :            :     {
    1589                 :            :         // detect if a scrollbar is necessary
    1590         [ #  # ]:          0 :         Rectangle aRect = GetTextRect( m_aRealRect, sTemp, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE );
    1591                 :          0 :         bShow = ( aRect.Bottom() > m_aRealRect.Bottom() );
    1592                 :            :     }
    1593                 :            : 
    1594 [ #  # ][ #  # ]:          0 :     if ( GetVScrollBar() )
    1595 [ #  # ][ #  # ]:          0 :         GetVScrollBar()->Show( bShow );
    1596                 :            : 
    1597         [ #  # ]:          0 :     if ( bShow )
    1598         [ #  # ]:          0 :         sTemp += '\n';
    1599                 :            : 
    1600 [ #  # ][ #  # ]:          0 :     SetText( sTemp );
    1601                 :          0 : }
    1602                 :            : 
    1603                 :            : /******************************************************************************
    1604                 :            :  *
    1605                 :            :  * SvxConfigPage is the abstract base class on which the Menu and Toolbar
    1606                 :            :  * configuration tabpages are based. It includes methods which are common to
    1607                 :            :  * both tabpages to add, delete, move and rename items etc.
    1608                 :            :  *
    1609                 :            :  *****************************************************************************/
    1610                 :          0 : SvxConfigPage::SvxConfigPage(
    1611                 :            :     Window *pParent, const SfxItemSet& rSet )
    1612                 :            :     :
    1613                 :          0 :     SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_MENUS ), rSet ),
    1614                 :            :     bInitialised( sal_False ),
    1615                 :            :     pCurrentSaveInData( 0 ),
    1616         [ #  # ]:          0 :     aTopLevelSeparator( this, CUI_RES( GRP_MENUS ) ),
    1617         [ #  # ]:          0 :     aTopLevelLabel( this, CUI_RES( FT_MENUS ) ),
    1618         [ #  # ]:          0 :     aTopLevelListBox( this, CUI_RES( LB_MENUS ) ),
    1619         [ #  # ]:          0 :     aNewTopLevelButton( this, CUI_RES( BTN_NEW ) ),
    1620         [ #  # ]:          0 :     aModifyTopLevelButton( this, CUI_RES( BTN_CHANGE ) ),
    1621         [ #  # ]:          0 :     aContentsSeparator( this, CUI_RES( GRP_MENU_SEPARATOR ) ),
    1622         [ #  # ]:          0 :     aContentsLabel( this, CUI_RES( GRP_MENU_ENTRIES ) ),
    1623                 :            :     aContentsListBox( 0 ),
    1624         [ #  # ]:          0 :     aAddCommandsButton( this, CUI_RES( BTN_ADD_COMMANDS ) ),
    1625         [ #  # ]:          0 :     aModifyCommandButton( this, CUI_RES( BTN_CHANGE_ENTRY ) ),
    1626         [ #  # ]:          0 :     aMoveUpButton( this, CUI_RES( BTN_UP ) ),
    1627         [ #  # ]:          0 :     aMoveDownButton( this, CUI_RES( BTN_DOWN ) ),
    1628         [ #  # ]:          0 :     aSaveInText( this, CUI_RES( TXT_SAVEIN ) ),
    1629         [ #  # ]:          0 :     aSaveInListBox( this, CUI_RES( LB_SAVEIN ) ),
    1630         [ #  # ]:          0 :     aDescriptionLabel( this, CUI_RES( FT_DESCRIPTION ) ),
    1631         [ #  # ]:          0 :     aDescriptionField( this, CUI_RES( ED_DESCRIPTION ) ),
    1632 [ #  # ][ #  # ]:          0 :     pSelectorDlg( 0 )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1633                 :            : {
    1634         [ #  # ]:          0 :     aDescriptionField.SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() );
    1635         [ #  # ]:          0 :     aDescriptionField.SetAutoScroll( sal_True );
    1636         [ #  # ]:          0 :     aDescriptionField.EnableCursor( sal_False );
    1637                 :            : 
    1638 [ #  # ][ #  # ]:          0 :     aMoveUpButton.SetAccessibleName(String(CUI_RES(BUTTON_STR_UP)));
         [ #  # ][ #  # ]
    1639 [ #  # ][ #  # ]:          0 :     aMoveDownButton.SetAccessibleName(String(CUI_RES(BUTTON_STR_DOWN)));
         [ #  # ][ #  # ]
    1640         [ #  # ]:          0 :     aMoveUpButton.SetAccessibleRelationMemberOf(&aContentsSeparator);
    1641         [ #  # ]:          0 :     aMoveDownButton.SetAccessibleRelationMemberOf(&aContentsSeparator);
    1642         [ #  # ]:          0 :     aNewTopLevelButton.SetAccessibleRelationMemberOf(&aTopLevelSeparator);
    1643         [ #  # ]:          0 :     aModifyTopLevelButton.SetAccessibleRelationMemberOf(&aTopLevelSeparator);
    1644         [ #  # ]:          0 :     aAddCommandsButton.SetAccessibleRelationMemberOf(&aContentsSeparator);
    1645         [ #  # ]:          0 :     aModifyCommandButton.SetAccessibleRelationMemberOf(&aContentsSeparator);
    1646                 :          0 : }
    1647                 :            : 
    1648 [ #  # ][ #  # ]:          0 : SvxConfigPage::~SvxConfigPage()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1649                 :            : {
    1650         [ #  # ]:          0 : }
    1651                 :            : 
    1652                 :          0 : void SvxConfigPage::Reset( const SfxItemSet& )
    1653                 :            : {
    1654                 :            :     // If we haven't initialised our XMultiServiceFactory reference
    1655                 :            :     // then Reset is being called at the opening of the dialog.
    1656                 :            :     //
    1657                 :            :     // Load menu configuration data for the module of the currently
    1658                 :            :     // selected document, for the currently selected document, and for
    1659                 :            :     // all other open documents of the same module type
    1660         [ #  # ]:          0 :     if ( !bInitialised )
    1661                 :            :     {
    1662                 :          0 :         sal_uInt16 nPos = 0;
    1663                 :          0 :         uno::Reference < css::ui::XUIConfigurationManager > xCfgMgr;
    1664                 :          0 :         uno::Reference < css::ui::XUIConfigurationManager > xDocCfgMgr;
    1665                 :            : 
    1666                 :            :         uno::Reference< lang::XMultiServiceFactory > xServiceManager(
    1667 [ #  # ][ #  # ]:          0 :             ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
    1668                 :            : 
    1669 [ #  # ][ #  # ]:          0 :         m_xFrame = GetFrame();
    1670         [ #  # ]:          0 :         OUString aModuleId = GetFrameWithDefaultAndIdentify( m_xFrame );
    1671                 :            : 
    1672                 :            :         // replace %MODULENAME in the label with the correct module name
    1673                 :            :         uno::Reference< css::frame::XModuleManager > xModuleManager(
    1674         [ #  # ]:          0 :             xServiceManager->createInstance(
    1675                 :          0 :                 OUString( "com.sun.star.frame.ModuleManager"  ) ),
    1676 [ #  # ][ #  # ]:          0 :             uno::UNO_QUERY_THROW );
    1677         [ #  # ]:          0 :         OUString aModuleName = GetUIModuleName( aModuleId, xModuleManager );
    1678                 :            : 
    1679 [ #  # ][ #  # ]:          0 :         OUString title = aTopLevelSeparator.GetText();
                 [ #  # ]
    1680                 :          0 :         OUString aSearchString("%MODULENAME" );
    1681                 :          0 :         sal_Int32 index = title.indexOf( aSearchString );
    1682                 :            : 
    1683         [ #  # ]:          0 :         if ( index != -1 )
    1684                 :            :         {
    1685                 :            :             title = title.replaceAt(
    1686                 :          0 :                 index, aSearchString.getLength(), aModuleName );
    1687 [ #  # ][ #  # ]:          0 :             aTopLevelSeparator.SetText( title );
                 [ #  # ]
    1688                 :            :         }
    1689                 :            : 
    1690                 :            :         uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier >
    1691         [ #  # ]:          0 :             xModuleCfgSupplier( xServiceManager->createInstance(
    1692                 :          0 :                 OUString( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" )),
    1693 [ #  # ][ #  # ]:          0 :             uno::UNO_QUERY );
    1694                 :            : 
    1695                 :            :         // Set up data for module specific menus
    1696                 :          0 :         SaveInData* pModuleData = NULL;
    1697                 :            : 
    1698                 :            :         try
    1699                 :            :         {
    1700                 :            :             xCfgMgr =
    1701 [ #  # ][ #  # ]:          0 :                 xModuleCfgSupplier->getUIConfigurationManager( aModuleId );
                 [ #  # ]
    1702                 :            : 
    1703                 :            :             pModuleData = CreateSaveInData( xCfgMgr,
    1704                 :            :                                             uno::Reference< css::ui::XUIConfigurationManager >(),
    1705                 :            :                                             aModuleId,
    1706 [ #  # ][ #  # ]:          0 :                                             sal_False );
    1707                 :            :         }
    1708         [ #  # ]:          0 :         catch ( container::NoSuchElementException& )
    1709                 :            :         {
    1710                 :            :         }
    1711                 :            : 
    1712         [ #  # ]:          0 :         if ( pModuleData != NULL )
    1713                 :            :         {
    1714                 :            :             nPos = aSaveInListBox.InsertEntry(
    1715                 :            :                 utl::ConfigManager::getProductName() +
    1716 [ #  # ][ #  # ]:          0 :                 OUString( " "  ) + aModuleName );
         [ #  # ][ #  # ]
    1717         [ #  # ]:          0 :             aSaveInListBox.SetEntryData( nPos, pModuleData );
    1718                 :            :         }
    1719                 :            : 
    1720                 :            :         // try to retrieve the document based ui configuration manager
    1721                 :          0 :         OUString aTitle;
    1722                 :            :         uno::Reference< frame::XController > xController =
    1723 [ #  # ][ #  # ]:          0 :             m_xFrame->getController();
    1724 [ #  # ][ #  # ]:          0 :         if ( CanConfig( aModuleId ) && xController.is() )
         [ #  # ][ #  # ]
    1725                 :            :         {
    1726 [ #  # ][ #  # ]:          0 :             uno::Reference< frame::XModel > xModel( xController->getModel() );
    1727         [ #  # ]:          0 :             if ( xModel.is() )
    1728                 :            :             {
    1729                 :            :                 uno::Reference< css::ui::XUIConfigurationManagerSupplier >
    1730         [ #  # ]:          0 :                     xCfgSupplier( xModel, uno::UNO_QUERY );
    1731                 :            : 
    1732         [ #  # ]:          0 :                 if ( xCfgSupplier.is() )
    1733                 :            :                 {
    1734 [ #  # ][ #  # ]:          0 :                     xDocCfgMgr = xCfgSupplier->getUIConfigurationManager();
                 [ #  # ]
    1735                 :            :                 }
    1736         [ #  # ]:          0 :                 aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
    1737                 :          0 :             }
    1738                 :            :         }
    1739                 :            : 
    1740                 :          0 :         SaveInData* pDocData = NULL;
    1741         [ #  # ]:          0 :         if ( xDocCfgMgr.is() )
    1742                 :            :         {
    1743         [ #  # ]:          0 :             pDocData = CreateSaveInData( xDocCfgMgr, xCfgMgr, aModuleId, sal_True );
    1744                 :            : 
    1745         [ #  # ]:          0 :             if ( !pDocData->IsReadOnly() )
    1746                 :            :             {
    1747 [ #  # ][ #  # ]:          0 :                 nPos = aSaveInListBox.InsertEntry( aTitle );
                 [ #  # ]
    1748         [ #  # ]:          0 :                 aSaveInListBox.SetEntryData( nPos, pDocData );
    1749                 :            :             }
    1750                 :            :         }
    1751                 :            : 
    1752                 :            :         // if an item to select has been passed in (eg. the ResourceURL for a
    1753                 :            :         // toolbar) then try to select the SaveInData entry that has that item
    1754                 :          0 :         bool bURLToSelectFound = sal_False;
    1755         [ #  # ]:          0 :         if ( !m_aURLToSelect.isEmpty() )
    1756                 :            :         {
    1757 [ #  # ][ #  # ]:          0 :             if ( pDocData != NULL && pDocData->HasURL( m_aURLToSelect ) )
         [ #  # ][ #  # ]
    1758                 :            :             {
    1759         [ #  # ]:          0 :                 aSaveInListBox.SelectEntryPos( nPos, sal_True );
    1760                 :          0 :                 pCurrentSaveInData = pDocData;
    1761                 :          0 :                 bURLToSelectFound = sal_True;
    1762                 :            :             }
    1763 [ #  # ][ #  # ]:          0 :             else if ( pModuleData->HasURL( m_aURLToSelect ) )
    1764                 :            :             {
    1765         [ #  # ]:          0 :                 aSaveInListBox.SelectEntryPos( 0, sal_True );
    1766                 :          0 :                 pCurrentSaveInData = pModuleData;
    1767                 :          0 :                 bURLToSelectFound = sal_True;
    1768                 :            :             }
    1769                 :            :         }
    1770                 :            : 
    1771         [ #  # ]:          0 :         if ( bURLToSelectFound == sal_False )
    1772                 :            :         {
    1773                 :            :             // if the document has menu configuration settings select it
    1774                 :            :             // it the SaveIn listbox, otherwise select the module data
    1775 [ #  # ][ #  # ]:          0 :             if ( pDocData != NULL && pDocData->HasSettings() )
         [ #  # ][ #  # ]
    1776                 :            :             {
    1777         [ #  # ]:          0 :                 aSaveInListBox.SelectEntryPos( nPos, sal_True );
    1778                 :          0 :                 pCurrentSaveInData = pDocData;
    1779                 :            :             }
    1780                 :            :             else
    1781                 :            :             {
    1782         [ #  # ]:          0 :                 aSaveInListBox.SelectEntryPos( 0, sal_True );
    1783                 :          0 :                 pCurrentSaveInData = pModuleData;
    1784                 :            :             }
    1785                 :            :         }
    1786                 :            : 
    1787                 :            : #ifdef DBG_UTIL
    1788                 :            :         DBG_ASSERT( pCurrentSaveInData, "SvxConfigPage::Reset(): no SaveInData" );
    1789                 :            : #endif
    1790                 :            : 
    1791 [ #  # ][ #  # ]:          0 :         if ( CanConfig( aModuleId ) )
    1792                 :            :         {
    1793                 :            :             // Load configuration for other open documents which have
    1794                 :            :             // same module type
    1795         [ #  # ]:          0 :             uno::Sequence< uno::Reference< frame::XFrame > > aFrameList;
    1796                 :            :             try
    1797                 :            :             {
    1798                 :            :                 uno::Reference< frame::XFramesSupplier > xFramesSupplier(
    1799         [ #  # ]:          0 :                     xServiceManager->createInstance(
    1800                 :          0 :                         OUString( "com.sun.star.frame.Desktop"  ) ),
    1801 [ #  # ][ #  # ]:          0 :                     uno::UNO_QUERY_THROW );
    1802                 :            : 
    1803                 :            :                 uno::Reference< frame::XFrames > xFrames =
    1804 [ #  # ][ #  # ]:          0 :                     xFramesSupplier->getFrames();
    1805                 :            : 
    1806         [ #  # ]:          0 :                 aFrameList = xFrames->queryFrames(
    1807 [ #  # ][ #  # ]:          0 :                     frame::FrameSearchFlag::ALL & ~frame::FrameSearchFlag::SELF );
         [ #  # ][ #  # ]
    1808                 :            : 
    1809                 :            :             }
    1810   [ #  #  #  # ]:          0 :             catch( const uno::Exception& )
    1811                 :            :             {
    1812                 :            :                 DBG_UNHANDLED_EXCEPTION();
    1813                 :            :             }
    1814                 :            : 
    1815         [ #  # ]:          0 :             for ( sal_Int32 i = 0; i < aFrameList.getLength(); ++i )
    1816                 :            :             {
    1817                 :          0 :                 SaveInData* pData = NULL;
    1818         [ #  # ]:          0 :                 uno::Reference < frame::XFrame > xf = aFrameList[i];
    1819                 :            : 
    1820 [ #  # ][ #  # ]:          0 :                 if ( xf.is() && xf != m_xFrame )
         [ #  # ][ #  # ]
    1821                 :            :                 {
    1822                 :          0 :                     OUString aCheckId;
    1823                 :            :                     try{
    1824 [ #  # ][ #  # ]:          0 :                         aCheckId = xModuleManager->identify( xf );
    1825         [ #  # ]:          0 :                     } catch(const uno::Exception&)
    1826                 :          0 :                         { aCheckId = ::rtl::OUString(); }
    1827                 :            : 
    1828         [ #  # ]:          0 :                     if ( aModuleId.equals( aCheckId ) )
    1829                 :            :                     {
    1830                 :            :                         // try to get the document based ui configuration manager
    1831                 :          0 :                         OUString aTitle2;
    1832                 :            :                         uno::Reference< frame::XController > xController_ =
    1833 [ #  # ][ #  # ]:          0 :                             xf->getController();
    1834                 :            : 
    1835         [ #  # ]:          0 :                         if ( xController_.is() )
    1836                 :            :                         {
    1837                 :            :                             uno::Reference< frame::XModel > xModel(
    1838 [ #  # ][ #  # ]:          0 :                                 xController_->getModel() );
    1839                 :            : 
    1840         [ #  # ]:          0 :                             if ( xModel.is() )
    1841                 :            :                             {
    1842                 :            :                                 uno::Reference<
    1843                 :            :                                     css::ui::XUIConfigurationManagerSupplier >
    1844         [ #  # ]:          0 :                                         xCfgSupplier( xModel, uno::UNO_QUERY );
    1845                 :            : 
    1846         [ #  # ]:          0 :                                 if ( xCfgSupplier.is() )
    1847                 :            :                                 {
    1848                 :            :                                     xDocCfgMgr =
    1849 [ #  # ][ #  # ]:          0 :                                         xCfgSupplier->getUIConfigurationManager();
                 [ #  # ]
    1850                 :            :                                 }
    1851         [ #  # ]:          0 :                                 aTitle2 = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
    1852                 :          0 :                             }
    1853                 :            :                         }
    1854                 :            : 
    1855         [ #  # ]:          0 :                         if ( xDocCfgMgr.is() )
    1856                 :            :                         {
    1857         [ #  # ]:          0 :                             pData = CreateSaveInData( xDocCfgMgr, xCfgMgr, aModuleId, sal_True );
    1858                 :            : 
    1859 [ #  # ][ #  # ]:          0 :                             if ( pData && !pData->IsReadOnly() )
                 [ #  # ]
    1860                 :            :                             {
    1861 [ #  # ][ #  # ]:          0 :                                 nPos = aSaveInListBox.InsertEntry( aTitle2 );
                 [ #  # ]
    1862         [ #  # ]:          0 :                                 aSaveInListBox.SetEntryData( nPos, pData );
    1863                 :            :                             }
    1864                 :          0 :                         }
    1865                 :          0 :                     }
    1866                 :            :                 }
    1867         [ #  # ]:          0 :             }
    1868                 :            :         }
    1869                 :            : 
    1870                 :            :         aSaveInListBox.SetSelectHdl(
    1871         [ #  # ]:          0 :             LINK( this, SvxConfigPage, SelectSaveInLocation ) );
    1872                 :            : 
    1873                 :          0 :         bInitialised = sal_True;
    1874                 :            : 
    1875         [ #  # ]:          0 :         Init();
    1876                 :            :     }
    1877                 :            :     else
    1878                 :            :     {
    1879         [ #  # ]:          0 :         if ( QueryReset() == RET_YES )
    1880                 :            :         {
    1881                 :            :             // Reset menu configuration for currently selected SaveInData
    1882                 :          0 :             GetSaveInData()->Reset();
    1883                 :            : 
    1884                 :          0 :             Init();
    1885                 :            :         }
    1886                 :            :     }
    1887                 :          0 : }
    1888                 :            : 
    1889                 :          0 : ::rtl::OUString SvxConfigPage::GetFrameWithDefaultAndIdentify( uno::Reference< frame::XFrame >& _inout_rxFrame )
    1890                 :            : {
    1891                 :          0 :     ::rtl::OUString sModuleID;
    1892                 :            :     try
    1893                 :            :     {
    1894                 :            :         uno::Reference< lang::XMultiServiceFactory > xServiceManager(
    1895 [ #  # ][ #  # ]:          0 :             ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
    1896                 :            : 
    1897                 :            :         uno::Reference< frame::XFramesSupplier > xFramesSupplier(
    1898         [ #  # ]:          0 :             xServiceManager->createInstance(
    1899                 :          0 :                 OUString( "com.sun.star.frame.Desktop"  ) ),
    1900 [ #  # ][ #  # ]:          0 :             uno::UNO_QUERY_THROW );
    1901                 :            : 
    1902         [ #  # ]:          0 :         if ( !_inout_rxFrame.is() )
    1903 [ #  # ][ #  # ]:          0 :             _inout_rxFrame = xFramesSupplier->getActiveFrame();
                 [ #  # ]
    1904                 :            : 
    1905         [ #  # ]:          0 :         if ( !_inout_rxFrame.is() )
    1906                 :            :         {
    1907         [ #  # ]:          0 :             uno::Reference< frame::XDesktop > xDesktop( xFramesSupplier, uno::UNO_QUERY_THROW );
    1908 [ #  # ][ #  # ]:          0 :             _inout_rxFrame = xDesktop->getCurrentFrame();
                 [ #  # ]
    1909                 :            :         }
    1910                 :            : 
    1911 [ #  # ][ #  # ]:          0 :         if ( !_inout_rxFrame.is() && SfxViewFrame::Current() )
         [ #  # ][ #  # ]
    1912 [ #  # ][ #  # ]:          0 :             _inout_rxFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
         [ #  # ][ #  # ]
    1913                 :            : 
    1914         [ #  # ]:          0 :         if ( !_inout_rxFrame.is() )
    1915                 :            :         {
    1916                 :            :             SAL_WARN( "cui.customize", "SvxConfigPage::GetFrameWithDefaultAndIdentify(): no frame found!" );
    1917                 :            :             return sModuleID;
    1918                 :            :         }
    1919                 :            : 
    1920                 :            :         uno::Reference< css::frame::XModuleManager > xModuleManager(
    1921         [ #  # ]:          0 :             xServiceManager->createInstance(
    1922                 :          0 :                 OUString( "com.sun.star.frame.ModuleManager"  ) ),
    1923 [ #  # ][ #  # ]:          0 :             uno::UNO_QUERY_THROW );
                 [ #  # ]
    1924                 :            : 
    1925                 :            :         try
    1926                 :            :         {
    1927 [ #  # ][ #  # ]:          0 :             sModuleID = xModuleManager->identify( _inout_rxFrame );
    1928                 :            :         }
    1929         [ #  # ]:          0 :         catch ( const frame::UnknownModuleException& )
    1930                 :            :         {
    1931 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
    1932                 :            : 
    1933                 :            :     }
    1934         [ #  # ]:          0 :     catch( const uno::Exception& )
    1935                 :            :     {
    1936                 :            :         DBG_UNHANDLED_EXCEPTION();
    1937                 :            :     }
    1938                 :            : 
    1939                 :          0 :     return sModuleID;
    1940                 :            : }
    1941                 :            : 
    1942                 :          0 : sal_Bool SvxConfigPage::FillItemSet( SfxItemSet& )
    1943                 :            : {
    1944                 :          0 :     bool result = sal_False;
    1945                 :            : 
    1946         [ #  # ]:          0 :     for ( sal_uInt16 i = 0 ; i < aSaveInListBox.GetEntryCount(); ++i )
    1947                 :            :     {
    1948                 :            :         SaveInData* pData =
    1949                 :          0 :             (SaveInData*) aSaveInListBox.GetEntryData( i );
    1950                 :            : 
    1951                 :          0 :         result = pData->Apply();
    1952                 :            :     }
    1953                 :          0 :     return result;
    1954                 :            : }
    1955                 :            : 
    1956                 :          0 : void SvxConfigPage::PositionContentsListBox()
    1957                 :            : {
    1958         [ #  # ]:          0 :     if ( aContentsListBox == NULL )
    1959                 :            :     {
    1960                 :          0 :         return;
    1961                 :            :     }
    1962                 :            : 
    1963                 :          0 :     Point p, newp;
    1964                 :          0 :     Size s, news;
    1965                 :            :     long x, y, width, height;
    1966                 :            : 
    1967                 :            :     // x and width is same as aTopLevelListBox
    1968         [ #  # ]:          0 :     x = aTopLevelListBox.GetPosPixel().X();
    1969         [ #  # ]:          0 :     width = aTopLevelListBox.GetSizePixel().Width();
    1970                 :            : 
    1971                 :            :     // y is same as aAddCommandsButton
    1972         [ #  # ]:          0 :     y = aAddCommandsButton.GetPosPixel().Y();
    1973                 :            : 
    1974                 :            :     // get gap between aAddCommandsButton and aContentsSeparator
    1975         [ #  # ]:          0 :     p = aContentsSeparator.GetPosPixel();
    1976         [ #  # ]:          0 :     s = aContentsSeparator.GetSizePixel();
    1977                 :          0 :     long gap = y - ( p.Y() + s.Height() );
    1978                 :            : 
    1979         [ #  # ]:          0 :     height = aSaveInListBox.GetPosPixel().Y() - y - gap;
    1980                 :            : 
    1981         [ #  # ]:          0 :     aContentsListBox->SetPosPixel( Point( x, y ) );
    1982         [ #  # ]:          0 :     aContentsListBox->SetSizePixel( Size( width, height ) );
    1983                 :            : }
    1984                 :            : 
    1985                 :          0 : IMPL_LINK( SvxConfigPage, SelectSaveInLocation, ListBox *, pBox )
    1986                 :            : {
    1987                 :            :     (void)pBox;
    1988                 :            : 
    1989                 :            :     pCurrentSaveInData = (SaveInData*) aSaveInListBox.GetEntryData(
    1990                 :          0 :             aSaveInListBox.GetSelectEntryPos());
    1991                 :            : 
    1992                 :          0 :     Init();
    1993                 :          0 :     return 1;
    1994                 :            : }
    1995                 :            : 
    1996                 :          0 : void SvxConfigPage::ReloadTopLevelListBox( SvxConfigEntry* pToSelect )
    1997                 :            : {
    1998                 :          0 :     sal_uInt16 nSelectionPos = aTopLevelListBox.GetSelectEntryPos();
    1999                 :          0 :     aTopLevelListBox.Clear();
    2000                 :            : 
    2001 [ #  # ][ #  # ]:          0 :     if ( GetSaveInData() && GetSaveInData()->GetEntries() )
                 [ #  # ]
    2002                 :            :     {
    2003 [ #  # ][ #  # ]:          0 :         SvxEntries::const_iterator iter = GetSaveInData()->GetEntries()->begin();
    2004 [ #  # ][ #  # ]:          0 :         SvxEntries::const_iterator end = GetSaveInData()->GetEntries()->end();
    2005                 :            : 
    2006 [ #  # ][ #  # ]:          0 :         for ( ; iter != end; ++iter )
    2007                 :            :         {
    2008                 :          0 :             SvxConfigEntry* pEntryData = *iter;
    2009 [ #  # ][ #  # ]:          0 :             sal_uInt16 nPos = aTopLevelListBox.InsertEntry( stripHotKey( pEntryData->GetName() ) );
                 [ #  # ]
    2010         [ #  # ]:          0 :             aTopLevelListBox.SetEntryData( nPos, pEntryData );
    2011                 :            : 
    2012         [ #  # ]:          0 :             if ( pEntryData == pToSelect )
    2013                 :          0 :                 nSelectionPos = nPos;
    2014                 :            : 
    2015 [ #  # ][ #  # ]:          0 :             AddSubMenusToUI( stripHotKey( pEntryData->GetName() ), pEntryData );
                 [ #  # ]
    2016                 :            :         }
    2017                 :            :     }
    2018                 :            : #ifdef DBG_UTIL
    2019                 :            :     else
    2020                 :            :     {
    2021                 :            :         DBG_ASSERT( GetSaveInData(), "SvxConfigPage::ReloadTopLevelListBox(): no SaveInData" );
    2022                 :            :         DBG_ASSERT( GetSaveInData()->GetEntries() ,
    2023                 :            :             "SvxConfigPage::ReloadTopLevelListBox(): no SaveInData entries" );
    2024                 :            :     }
    2025                 :            : #endif
    2026                 :            : 
    2027                 :          0 :     nSelectionPos = nSelectionPos < aTopLevelListBox.GetEntryCount() ?
    2028         [ #  # ]:          0 :         nSelectionPos : aTopLevelListBox.GetEntryCount() - 1;
    2029                 :            : 
    2030                 :          0 :     aTopLevelListBox.SelectEntryPos( nSelectionPos, sal_True );
    2031                 :          0 :     aTopLevelListBox.GetSelectHdl().Call( this );
    2032                 :          0 : }
    2033                 :            : 
    2034                 :          0 : void SvxConfigPage::AddSubMenusToUI(
    2035                 :            :     const String& rBaseTitle, SvxConfigEntry* pParentData )
    2036                 :            : {
    2037         [ #  # ]:          0 :     SvxEntries::const_iterator iter = pParentData->GetEntries()->begin();
    2038         [ #  # ]:          0 :     SvxEntries::const_iterator end = pParentData->GetEntries()->end();
    2039                 :            : 
    2040 [ #  # ][ #  # ]:          0 :     for ( ; iter != end; ++iter )
    2041                 :            :     {
    2042                 :          0 :         SvxConfigEntry* pEntryData = *iter;
    2043                 :            : 
    2044         [ #  # ]:          0 :         if ( pEntryData->IsPopup() )
    2045                 :            :         {
    2046         [ #  # ]:          0 :             OUString subMenuTitle( rBaseTitle );
    2047                 :          0 :             subMenuTitle += OUString(aMenuSeparatorStr);
    2048                 :          0 :             subMenuTitle += stripHotKey( pEntryData->GetName() );
    2049                 :            : 
    2050 [ #  # ][ #  # ]:          0 :             sal_uInt16 nPos = aTopLevelListBox.InsertEntry( subMenuTitle );
                 [ #  # ]
    2051         [ #  # ]:          0 :             aTopLevelListBox.SetEntryData( nPos, pEntryData );
    2052                 :            : 
    2053 [ #  # ][ #  # ]:          0 :             AddSubMenusToUI( subMenuTitle, pEntryData );
                 [ #  # ]
    2054                 :            :         }
    2055                 :            :     }
    2056                 :          0 : }
    2057                 :            : 
    2058                 :          0 : SvxEntries* SvxConfigPage::FindParentForChild(
    2059                 :            :     SvxEntries* pRootEntries, SvxConfigEntry* pChildData )
    2060                 :            : {
    2061         [ #  # ]:          0 :     SvxEntries::const_iterator iter = pRootEntries->begin();
    2062         [ #  # ]:          0 :     SvxEntries::const_iterator end = pRootEntries->end();
    2063                 :            : 
    2064 [ #  # ][ #  # ]:          0 :     for ( ; iter != end; ++iter )
    2065                 :            :     {
    2066                 :          0 :         SvxConfigEntry* pEntryData = *iter;
    2067                 :            : 
    2068         [ #  # ]:          0 :         if ( pEntryData == pChildData )
    2069                 :            :         {
    2070                 :          0 :             return pRootEntries;
    2071                 :            :         }
    2072         [ #  # ]:          0 :         else if ( pEntryData->IsPopup() )
    2073                 :            :         {
    2074                 :            :             SvxEntries* result =
    2075         [ #  # ]:          0 :                 FindParentForChild( pEntryData->GetEntries(), pChildData );
    2076                 :            : 
    2077         [ #  # ]:          0 :             if ( result != NULL )
    2078                 :            :             {
    2079                 :          0 :                 return result;
    2080                 :            :             }
    2081                 :            :         }
    2082                 :            :     }
    2083                 :          0 :     return NULL;
    2084                 :            : }
    2085                 :            : 
    2086                 :          0 : SvLBoxEntry* SvxConfigPage::AddFunction(
    2087                 :            :     SvLBoxEntry* pTarget, bool bFront, bool bAllowDuplicates )
    2088                 :            : {
    2089         [ #  # ]:          0 :     String aDisplayName = pSelectorDlg->GetSelectedDisplayName();
    2090         [ #  # ]:          0 :     String aHelpText = pSelectorDlg->GetSelectedHelpText();
    2091         [ #  # ]:          0 :     String aURL = pSelectorDlg->GetScriptURL();
    2092                 :            : 
    2093         [ #  # ]:          0 :     if ( !aURL.Len() )
    2094                 :            :     {
    2095                 :          0 :         return NULL;
    2096                 :            :     }
    2097                 :            : 
    2098                 :            :     SvxConfigEntry* pNewEntryData =
    2099 [ #  # ][ #  # ]:          0 :         new SvxConfigEntry( aDisplayName, aURL, sal_False );
         [ #  # ][ #  # ]
    2100                 :          0 :     pNewEntryData->SetUserDefined( sal_True );
    2101                 :            : 
    2102                 :            :     // check that this function is not already in the menu
    2103         [ #  # ]:          0 :     SvxConfigEntry* pParent = GetTopLevelSelection();
    2104                 :            : 
    2105         [ #  # ]:          0 :     SvxEntries::const_iterator iter = pParent->GetEntries()->begin();
    2106         [ #  # ]:          0 :     SvxEntries::const_iterator end = pParent->GetEntries()->end();
    2107                 :            : 
    2108         [ #  # ]:          0 :     if ( !bAllowDuplicates )
    2109                 :            :     {
    2110 [ #  # ][ #  # ]:          0 :         while ( iter != end )
    2111                 :            :         {
    2112                 :          0 :             SvxConfigEntry *pCurEntry = *iter;
    2113                 :            : 
    2114         [ #  # ]:          0 :             if ( pCurEntry->GetCommand() == pNewEntryData->GetCommand() )
    2115                 :            :             {
    2116                 :            :                 // asynchronous error message, because of MsgBoxes
    2117                 :            :                 PostUserEvent(
    2118 [ #  # ][ #  # ]:          0 :                     LINK( this, SvxConfigPage, AsyncInfoMsg ) );
    2119                 :          0 :                 return NULL;
    2120                 :            :             }
    2121                 :            : 
    2122                 :          0 :             ++iter;
    2123                 :            :         }
    2124                 :            :     }
    2125                 :            : 
    2126 [ #  # ][ #  # ]:          0 :     return InsertEntry( pNewEntryData, pTarget, bFront );
         [ #  # ][ #  # ]
    2127                 :            : }
    2128                 :            : 
    2129                 :          0 : SvLBoxEntry* SvxConfigPage::InsertEntry(
    2130                 :            :     SvxConfigEntry* pNewEntryData,
    2131                 :            :     SvLBoxEntry* pTarget,
    2132                 :            :     bool bFront )
    2133                 :            : {
    2134                 :            :     // Grab the entries list for the currently selected menu
    2135                 :          0 :     SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
    2136                 :            : 
    2137                 :          0 :     SvLBoxEntry* pNewEntry = NULL;
    2138                 :            :     SvLBoxEntry* pCurEntry =
    2139         [ #  # ]:          0 :         pTarget != NULL ? pTarget : aContentsListBox->GetCurEntry();
    2140                 :            : 
    2141         [ #  # ]:          0 :     if ( bFront )
    2142                 :            :     {
    2143                 :          0 :         pEntries->insert( pEntries->begin(), pNewEntryData );
    2144                 :          0 :         pNewEntry = InsertEntryIntoUI( pNewEntryData, 0 );
    2145                 :            :     }
    2146 [ #  # ][ #  # ]:          0 :     else if ( pCurEntry == NULL || pCurEntry == aContentsListBox->Last() )
                 [ #  # ]
    2147                 :            :     {
    2148                 :          0 :         pEntries->push_back( pNewEntryData );
    2149                 :          0 :         pNewEntry = InsertEntryIntoUI( pNewEntryData );
    2150                 :            :     }
    2151                 :            :     else
    2152                 :            :     {
    2153                 :            :         SvxConfigEntry* pEntryData =
    2154                 :          0 :             (SvxConfigEntry*) pCurEntry->GetUserData();
    2155                 :            : 
    2156                 :          0 :         SvxEntries::iterator iter = pEntries->begin();
    2157         [ #  # ]:          0 :         SvxEntries::const_iterator end = pEntries->end();
    2158                 :            : 
    2159                 :            :         // Advance the iterator to the data for currently selected entry
    2160                 :          0 :         sal_uInt16 nPos = 0;
    2161 [ #  # ][ #  # ]:          0 :         while (*iter != pEntryData && ++iter != end)
         [ #  # ][ #  # ]
    2162                 :            :         {
    2163                 :          0 :             ++nPos;
    2164                 :            :         }
    2165                 :            : 
    2166                 :            :         // Now step past it to the entry after the currently selected one
    2167                 :          0 :         ++iter;
    2168                 :          0 :         ++nPos;
    2169                 :            : 
    2170                 :            :         // Now add the new entry to the UI and to the parent's list
    2171 [ #  # ][ #  # ]:          0 :         if ( iter != end )
    2172                 :            :         {
    2173         [ #  # ]:          0 :             pEntries->insert( iter, pNewEntryData );
    2174         [ #  # ]:          0 :             pNewEntry = InsertEntryIntoUI( pNewEntryData, nPos );
    2175                 :            :         }
    2176                 :            :     }
    2177                 :            : 
    2178         [ #  # ]:          0 :     if ( pNewEntry != NULL )
    2179                 :            :     {
    2180                 :          0 :         aContentsListBox->Select( pNewEntry );
    2181                 :          0 :         aContentsListBox->MakeVisible( pNewEntry );
    2182                 :            : 
    2183                 :          0 :         GetSaveInData()->SetModified( sal_True );
    2184                 :            :     }
    2185                 :            : 
    2186                 :          0 :     return pNewEntry;
    2187                 :            : }
    2188                 :            : 
    2189                 :          0 : SvLBoxEntry* SvxConfigPage::InsertEntryIntoUI(
    2190                 :            :     SvxConfigEntry* pNewEntryData, sal_uLong nPos )
    2191                 :            : {
    2192                 :          0 :     SvLBoxEntry* pNewEntry = NULL;
    2193                 :            : 
    2194         [ #  # ]:          0 :     if (pNewEntryData->IsSeparator())
    2195                 :            :     {
    2196                 :            :         pNewEntry = aContentsListBox->InsertEntry(
    2197                 :            :             rtl::OUString(aSeparatorStr),
    2198 [ #  # ][ #  # ]:          0 :             0, sal_False, nPos, pNewEntryData);
                 [ #  # ]
    2199                 :            :     }
    2200                 :            :     else
    2201                 :            :     {
    2202                 :          0 :         OUString aName = stripHotKey( pNewEntryData->GetName() );
    2203                 :            : 
    2204                 :          0 :         Image aImage = GetSaveInData()->GetImage(
    2205         [ #  # ]:          0 :             pNewEntryData->GetCommand());
    2206                 :            : 
    2207         [ #  # ]:          0 :         if ( !!aImage )
    2208                 :            :         {
    2209                 :            :             pNewEntry = aContentsListBox->InsertEntry(
    2210 [ #  # ][ #  # ]:          0 :                 aName, aImage, aImage, 0, sal_False, nPos, pNewEntryData );
                 [ #  # ]
    2211                 :            :         }
    2212                 :            :         else
    2213                 :            :         {
    2214                 :            :             pNewEntry = aContentsListBox->InsertEntry(
    2215 [ #  # ][ #  # ]:          0 :                 aName, 0, sal_False, nPos, pNewEntryData );
                 [ #  # ]
    2216                 :            :         }
    2217                 :            : 
    2218   [ #  #  #  # ]:          0 :         if ( pNewEntryData->IsPopup() ||
                 [ #  # ]
    2219                 :          0 :              pNewEntryData->GetStyle() & css::ui::ItemStyle::DROP_DOWN )
    2220                 :            :         {
    2221                 :            :             // add new popup painter, it gets destructed by the entry
    2222                 :            :             pNewEntry->ReplaceItem(
    2223         [ #  # ]:          0 :                 new PopupPainter( pNewEntry, aName ),
    2224 [ #  # ][ #  # ]:          0 :                 pNewEntry->ItemCount() - 1 );
         [ #  # ][ #  # ]
    2225         [ #  # ]:          0 :         }
    2226                 :            :     }
    2227                 :            : 
    2228                 :          0 :     return pNewEntry;
    2229                 :            : }
    2230                 :            : 
    2231                 :          0 : IMPL_LINK( SvxConfigPage, AsyncInfoMsg, String*, pMsg )
    2232                 :            : {
    2233                 :            :     (void)pMsg;
    2234                 :            : 
    2235                 :            :     // Asynchronous msg because of D&D
    2236                 :          0 :     InfoBox( this, CUI_RES(
    2237 [ #  # ][ #  # ]:          0 :         IBX_MNUCFG_ALREADY_INCLUDED ) ).Execute();
                 [ #  # ]
    2238                 :            : 
    2239                 :          0 :     return 0;
    2240                 :            : }
    2241                 :            : 
    2242                 :          0 : IMPL_LINK( SvxConfigPage, MoveHdl, Button *, pButton )
    2243                 :            : {
    2244                 :          0 :     MoveEntry( pButton == &aMoveUpButton );
    2245                 :          0 :     return 0;
    2246                 :            : }
    2247                 :            : 
    2248                 :          0 : void SvxConfigPage::MoveEntry( bool bMoveUp )
    2249                 :            : {
    2250                 :          0 :     SvLBoxEntry *pSourceEntry = aContentsListBox->FirstSelected();
    2251                 :          0 :     SvLBoxEntry *pTargetEntry = NULL;
    2252                 :          0 :     SvLBoxEntry *pToSelect = NULL;
    2253                 :            : 
    2254         [ #  # ]:          0 :     if ( !pSourceEntry )
    2255                 :            :     {
    2256                 :          0 :         return;
    2257                 :            :     }
    2258                 :            : 
    2259         [ #  # ]:          0 :     if ( bMoveUp )
    2260                 :            :     {
    2261                 :            :         // Move Up is just a Move Down with the source and target reversed
    2262                 :          0 :         pTargetEntry = pSourceEntry;
    2263                 :          0 :         pSourceEntry = aContentsListBox->PrevSibling( pTargetEntry );
    2264                 :          0 :         pToSelect = pTargetEntry;
    2265                 :            :     }
    2266                 :            :     else
    2267                 :            :     {
    2268                 :          0 :         pTargetEntry = aContentsListBox->NextSibling( pSourceEntry );
    2269                 :          0 :         pToSelect = pSourceEntry;
    2270                 :            :     }
    2271                 :            : 
    2272         [ #  # ]:          0 :     if ( MoveEntryData( pSourceEntry, pTargetEntry ) )
    2273                 :            :     {
    2274                 :          0 :         aContentsListBox->GetModel()->Move( pSourceEntry, pTargetEntry );
    2275                 :          0 :         aContentsListBox->Select( pToSelect );
    2276                 :          0 :         aContentsListBox->MakeVisible( pToSelect );
    2277                 :            : 
    2278                 :          0 :         UpdateButtonStates();
    2279                 :            :     }
    2280                 :            : }
    2281                 :            : 
    2282                 :          0 : bool SvxConfigPage::MoveEntryData(
    2283                 :            :     SvLBoxEntry* pSourceEntry, SvLBoxEntry* pTargetEntry )
    2284                 :            : {
    2285                 :            :     //modified by shizhoubo for issue53677
    2286 [ #  # ][ #  # ]:          0 :     if ( NULL == pSourceEntry || NULL == pTargetEntry )
    2287                 :            :      {
    2288                 :          0 :          return sal_False;
    2289                 :            :      }
    2290                 :            : 
    2291                 :            :     // Grab the entries list for the currently selected menu
    2292         [ #  # ]:          0 :     SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
    2293                 :            : 
    2294                 :            :     SvxConfigEntry* pSourceData =
    2295                 :          0 :         (SvxConfigEntry*) pSourceEntry->GetUserData();
    2296                 :            : 
    2297         [ #  # ]:          0 :     if ( pTargetEntry == NULL )
    2298                 :            :     {
    2299         [ #  # ]:          0 :         RemoveEntry( pEntries, pSourceData );
    2300                 :            :         pEntries->insert(
    2301         [ #  # ]:          0 :             pEntries->begin(), pSourceData );
    2302                 :            : 
    2303                 :          0 :         GetSaveInData()->SetModified( sal_True );
    2304                 :            : 
    2305                 :          0 :         return sal_True;
    2306                 :            :     }
    2307                 :            :     else
    2308                 :            :     {
    2309                 :            :         SvxConfigEntry* pTargetData =
    2310                 :          0 :             (SvxConfigEntry*) pTargetEntry->GetUserData();
    2311                 :            : 
    2312 [ #  # ][ #  # ]:          0 :         if ( pSourceData != NULL && pTargetData != NULL )
    2313                 :            :         {
    2314                 :            :             // remove the source entry from our list
    2315         [ #  # ]:          0 :             RemoveEntry( pEntries, pSourceData );
    2316                 :            : 
    2317                 :          0 :             SvxEntries::iterator iter = pEntries->begin();
    2318         [ #  # ]:          0 :             SvxEntries::const_iterator end = pEntries->end();
    2319                 :            : 
    2320                 :            :             // advance the iterator to the position of the target entry
    2321 [ #  # ][ #  # ]:          0 :             while (*iter != pTargetData && ++iter != end) ;
         [ #  # ][ #  # ]
    2322                 :            : 
    2323                 :            :             // insert the source entry at the position after the target
    2324         [ #  # ]:          0 :             pEntries->insert( ++iter, pSourceData );
    2325                 :            : 
    2326                 :          0 :             GetSaveInData()->SetModified( sal_True );
    2327                 :            : 
    2328                 :          0 :             return sal_True;
    2329                 :            :         }
    2330                 :            :     }
    2331                 :            : 
    2332                 :          0 :     return sal_False;
    2333                 :            : }
    2334                 :            : 
    2335                 :          0 : SvxMenuConfigPage::SvxMenuConfigPage(
    2336                 :            :     Window *pParent, const SfxItemSet& rSet )
    2337                 :            :     :
    2338                 :          0 :     SvxConfigPage( pParent, rSet )
    2339                 :            : {
    2340 [ #  # ][ #  # ]:          0 :     aContentsListBox = new SvxMenuEntriesListBox( this, CUI_RES( BOX_ENTRIES ) );
                 [ #  # ]
    2341         [ #  # ]:          0 :     FreeResource();
    2342                 :            : 
    2343         [ #  # ]:          0 :     PositionContentsListBox();
    2344         [ #  # ]:          0 :     aContentsListBox->SetZOrder( &aAddCommandsButton, WINDOW_ZORDER_BEFOR );
    2345                 :            : 
    2346                 :            :     aTopLevelListBox.SetSelectHdl(
    2347         [ #  # ]:          0 :         LINK( this, SvxMenuConfigPage, SelectMenu ) );
    2348                 :            : 
    2349                 :            :     aContentsListBox->SetSelectHdl(
    2350         [ #  # ]:          0 :         LINK( this, SvxMenuConfigPage, SelectMenuEntry ) );
    2351                 :            : 
    2352         [ #  # ]:          0 :     aMoveUpButton.SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
    2353         [ #  # ]:          0 :     aMoveDownButton.SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
    2354                 :            : 
    2355                 :            :     aNewTopLevelButton.SetClickHdl  (
    2356         [ #  # ]:          0 :         LINK( this, SvxMenuConfigPage, NewMenuHdl ) );
    2357                 :            : 
    2358                 :            :     aAddCommandsButton.SetClickHdl  (
    2359         [ #  # ]:          0 :         LINK( this, SvxMenuConfigPage, AddCommandsHdl ) );
    2360                 :            : 
    2361 [ #  # ][ #  # ]:          0 :     PopupMenu* pMenu = new PopupMenu( CUI_RES( MODIFY_MENU ) );
                 [ #  # ]
    2362                 :            :     pMenu->SetMenuFlags(
    2363                 :          0 :         pMenu->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
    2364                 :            : 
    2365         [ #  # ]:          0 :     aModifyTopLevelButton.SetPopupMenu( pMenu );
    2366                 :            :     aModifyTopLevelButton.SetSelectHdl(
    2367         [ #  # ]:          0 :         LINK( this, SvxMenuConfigPage, MenuSelectHdl ) );
    2368                 :            : 
    2369 [ #  # ][ #  # ]:          0 :     PopupMenu* pEntry = new PopupMenu( CUI_RES( MODIFY_ENTRY ) );
                 [ #  # ]
    2370                 :            :     pEntry->SetMenuFlags(
    2371                 :          0 :         pEntry->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
    2372                 :            : 
    2373         [ #  # ]:          0 :     aModifyCommandButton.SetPopupMenu( pEntry );
    2374                 :            :     aModifyCommandButton.SetSelectHdl(
    2375         [ #  # ]:          0 :         LINK( this, SvxMenuConfigPage, EntrySelectHdl ) );
    2376                 :          0 : }
    2377                 :            : 
    2378                 :            : // Populates the Menu combo box
    2379                 :          0 : void SvxMenuConfigPage::Init()
    2380                 :            : {
    2381                 :            :     // ensure that the UI is cleared before populating it
    2382                 :          0 :     aTopLevelListBox.Clear();
    2383                 :          0 :     aContentsListBox->Clear();
    2384                 :            : 
    2385                 :          0 :     ReloadTopLevelListBox();
    2386                 :            : 
    2387                 :          0 :     aTopLevelListBox.SelectEntryPos(0, sal_True);
    2388                 :          0 :     aTopLevelListBox.GetSelectHdl().Call(this);
    2389                 :          0 : }
    2390                 :            : 
    2391                 :          0 : SvxMenuConfigPage::~SvxMenuConfigPage()
    2392                 :            : {
    2393 [ #  # ][ #  # ]:          0 :     for ( sal_uInt16 i = 0 ; i < aSaveInListBox.GetEntryCount(); ++i )
    2394                 :            :     {
    2395                 :            :         MenuSaveInData* pData =
    2396         [ #  # ]:          0 :             (MenuSaveInData*) aSaveInListBox.GetEntryData( i );
    2397                 :            : 
    2398 [ #  # ][ #  # ]:          0 :         delete pData;
    2399                 :            :     }
    2400                 :            : 
    2401         [ #  # ]:          0 :     if ( pSelectorDlg != NULL )
    2402                 :            :     {
    2403 [ #  # ][ #  # ]:          0 :         delete pSelectorDlg;
    2404                 :            :     }
    2405                 :            : 
    2406 [ #  # ][ #  # ]:          0 :     delete aContentsListBox;
    2407         [ #  # ]:          0 : }
    2408                 :            : 
    2409                 :          0 : IMPL_LINK( SvxMenuConfigPage, SelectMenuEntry, Control *, pBox )
    2410                 :            : {
    2411                 :            :     (void)pBox;
    2412                 :            : 
    2413                 :          0 :     UpdateButtonStates();
    2414                 :            : 
    2415                 :          0 :     return 1;
    2416                 :            : }
    2417                 :            : 
    2418                 :          0 : void SvxMenuConfigPage::UpdateButtonStates()
    2419                 :            : {
    2420                 :          0 :     PopupMenu* pPopup = aModifyCommandButton.GetPopupMenu();
    2421                 :            : 
    2422                 :            :     // Disable Up and Down buttons depending on current selection
    2423                 :          0 :     SvLBoxEntry* selection = aContentsListBox->GetCurEntry();
    2424                 :            : 
    2425 [ #  # ][ #  # ]:          0 :     if ( aContentsListBox->GetEntryCount() == 0 || selection == NULL )
                 [ #  # ]
    2426                 :            :     {
    2427                 :          0 :         aMoveUpButton.Enable( sal_False );
    2428                 :          0 :         aMoveDownButton.Enable( sal_False );
    2429                 :            : 
    2430                 :          0 :         pPopup->EnableItem( ID_BEGIN_GROUP, sal_True );
    2431                 :          0 :         pPopup->EnableItem( ID_RENAME, sal_False );
    2432                 :          0 :         pPopup->EnableItem( ID_DELETE, sal_False );
    2433                 :            : 
    2434                 :          0 :         aDescriptionField.Clear();
    2435                 :            : 
    2436                 :          0 :         return;
    2437                 :            :     }
    2438                 :            : 
    2439                 :          0 :     SvLBoxEntry* first = aContentsListBox->First();
    2440                 :          0 :     SvLBoxEntry* last = aContentsListBox->Last();
    2441                 :            : 
    2442                 :          0 :     aMoveUpButton.Enable( selection != first );
    2443                 :          0 :     aMoveDownButton.Enable( selection != last );
    2444                 :            : 
    2445                 :            :     SvxConfigEntry* pEntryData =
    2446                 :          0 :         (SvxConfigEntry*) selection->GetUserData();
    2447                 :            : 
    2448         [ #  # ]:          0 :     if ( pEntryData->IsSeparator() )
    2449                 :            :     {
    2450                 :          0 :         pPopup->EnableItem( ID_DELETE, sal_True );
    2451                 :          0 :         pPopup->EnableItem( ID_BEGIN_GROUP, sal_False );
    2452                 :          0 :         pPopup->EnableItem( ID_RENAME, sal_False );
    2453                 :            : 
    2454                 :          0 :         aDescriptionField.Clear();
    2455                 :            :     }
    2456                 :            :     else
    2457                 :            :     {
    2458                 :          0 :         pPopup->EnableItem( ID_BEGIN_GROUP, sal_True );
    2459                 :          0 :         pPopup->EnableItem( ID_DELETE, sal_True );
    2460                 :          0 :         pPopup->EnableItem( ID_RENAME, sal_True );
    2461                 :            : 
    2462         [ #  # ]:          0 :         aDescriptionField.SetNewText( pEntryData->GetHelpText() );
    2463                 :            :     }
    2464                 :            : }
    2465                 :            : 
    2466                 :          0 : void SvxMenuConfigPage::DeleteSelectedTopLevel()
    2467                 :            : {
    2468                 :          0 :     SvxConfigEntry* pMenuData = GetTopLevelSelection();
    2469                 :            : 
    2470                 :            :     SvxEntries* pParentEntries =
    2471                 :          0 :         FindParentForChild( GetSaveInData()->GetEntries(), pMenuData );
    2472                 :            : 
    2473                 :          0 :     RemoveEntry( pParentEntries, pMenuData );
    2474         [ #  # ]:          0 :     delete pMenuData;
    2475                 :            : 
    2476                 :          0 :     ReloadTopLevelListBox();
    2477                 :            : 
    2478                 :          0 :     GetSaveInData()->SetModified( sal_True );
    2479                 :          0 : }
    2480                 :            : 
    2481                 :          0 : bool SvxMenuConfigPage::DeleteSelectedContent()
    2482                 :            : {
    2483                 :          0 :     SvLBoxEntry *pActEntry = aContentsListBox->FirstSelected();
    2484                 :            : 
    2485         [ #  # ]:          0 :     if ( pActEntry != NULL )
    2486                 :            :     {
    2487                 :            :         // get currently selected menu entry
    2488                 :            :         SvxConfigEntry* pMenuEntry =
    2489                 :          0 :             (SvxConfigEntry*) pActEntry->GetUserData();
    2490                 :            : 
    2491                 :            :         // get currently selected menu
    2492                 :          0 :         SvxConfigEntry* pMenu = GetTopLevelSelection();
    2493                 :            : 
    2494                 :            :         // remove menu entry from the list for this menu
    2495                 :          0 :         RemoveEntry( pMenu->GetEntries(), pMenuEntry );
    2496                 :            : 
    2497                 :            :         // remove menu entry from UI
    2498                 :          0 :         aContentsListBox->GetModel()->Remove( pActEntry );
    2499                 :            : 
    2500                 :            :         // if this is a submenu entry, redraw the menus list box
    2501         [ #  # ]:          0 :         if ( pMenuEntry->IsPopup() )
    2502                 :            :         {
    2503                 :          0 :             ReloadTopLevelListBox();
    2504                 :            :         }
    2505                 :            : 
    2506                 :            :         // delete data for menu entry
    2507         [ #  # ]:          0 :         delete pMenuEntry;
    2508                 :            : 
    2509                 :          0 :         GetSaveInData()->SetModified( sal_True );
    2510                 :            : 
    2511                 :          0 :         return sal_True;
    2512                 :            :     }
    2513                 :          0 :     return sal_False;
    2514                 :            : }
    2515                 :            : 
    2516                 :          0 : short SvxMenuConfigPage::QueryReset()
    2517                 :            : {
    2518                 :            :     String msg =
    2519 [ #  # ][ #  # ]:          0 :         String( CUI_RES( RID_SVXSTR_CONFIRM_MENU_RESET ) );
    2520                 :            : 
    2521                 :            :     String saveInName = aSaveInListBox.GetEntry(
    2522 [ #  # ][ #  # ]:          0 :         aSaveInListBox.GetSelectEntryPos() );
    2523                 :            : 
    2524 [ #  # ][ #  # ]:          0 :     OUString label = replaceSaveInName( msg, saveInName );
                 [ #  # ]
    2525                 :            : 
    2526 [ #  # ][ #  # ]:          0 :     QueryBox qbox( this, WB_YES_NO, label );
                 [ #  # ]
    2527                 :            : 
    2528 [ #  # ][ #  # ]:          0 :     return qbox.Execute();
         [ #  # ][ #  # ]
    2529                 :            : }
    2530                 :            : 
    2531                 :          0 : IMPL_LINK( SvxMenuConfigPage, SelectMenu, ListBox *, pBox )
    2532                 :            : {
    2533                 :            :     (void)pBox;
    2534                 :            : 
    2535                 :          0 :     aContentsListBox->Clear();
    2536                 :            : 
    2537                 :          0 :     SvxConfigEntry* pMenuData = GetTopLevelSelection();
    2538                 :            : 
    2539                 :          0 :     PopupMenu* pPopup = aModifyTopLevelButton.GetPopupMenu();
    2540         [ #  # ]:          0 :     if ( pMenuData )
    2541                 :            :     {
    2542         [ #  # ]:          0 :         pPopup->EnableItem( ID_DELETE, pMenuData->IsDeletable() );
    2543         [ #  # ]:          0 :         pPopup->EnableItem( ID_RENAME, pMenuData->IsRenamable() );
    2544         [ #  # ]:          0 :         pPopup->EnableItem( ID_MOVE, pMenuData->IsMovable() );
    2545                 :            : 
    2546                 :          0 :         SvxEntries* pEntries = pMenuData->GetEntries();
    2547         [ #  # ]:          0 :         SvxEntries::const_iterator iter = pEntries->begin();
    2548                 :            : 
    2549 [ #  # ][ #  # ]:          0 :         for ( ; iter != pEntries->end(); ++iter )
    2550                 :            :         {
    2551                 :          0 :             SvxConfigEntry* pEntry = *iter;
    2552         [ #  # ]:          0 :             InsertEntryIntoUI( pEntry );
    2553                 :            :         }
    2554                 :            :     }
    2555                 :            : 
    2556                 :          0 :     UpdateButtonStates();
    2557                 :            : 
    2558                 :          0 :     return 0;
    2559                 :            : }
    2560                 :            : 
    2561                 :          0 : IMPL_LINK( SvxMenuConfigPage, MenuSelectHdl, MenuButton *, pButton )
    2562                 :            : {
    2563   [ #  #  #  # ]:          0 :     switch( pButton->GetCurItemId() )
    2564                 :            :     {
    2565                 :            :         case ID_DELETE:
    2566                 :            :         {
    2567                 :          0 :             DeleteSelectedTopLevel();
    2568                 :          0 :             break;
    2569                 :            :         }
    2570                 :            :         case ID_RENAME:
    2571                 :            :         {
    2572         [ #  # ]:          0 :             SvxConfigEntry* pMenuData = GetTopLevelSelection();
    2573                 :            : 
    2574         [ #  # ]:          0 :             String aNewName( stripHotKey( pMenuData->GetName() ) );
    2575 [ #  # ][ #  # ]:          0 :             String aDesc = CUI_RESSTR( RID_SVXSTR_LABEL_NEW_NAME );
                 [ #  # ]
    2576                 :            : 
    2577 [ #  # ][ #  # ]:          0 :             SvxNameDialog* pNameDialog = new SvxNameDialog( this, aNewName, aDesc );
    2578         [ #  # ]:          0 :             pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_MENU );
    2579 [ #  # ][ #  # ]:          0 :             pNameDialog->SetText( CUI_RESSTR( RID_SVXSTR_RENAME_MENU ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    2580                 :            : 
    2581         [ #  # ]:          0 :             bool ret = pNameDialog->Execute();
    2582                 :            : 
    2583         [ #  # ]:          0 :             if ( ret == RET_OK ) {
    2584         [ #  # ]:          0 :                 pNameDialog->GetName( aNewName );
    2585         [ #  # ]:          0 :                 pMenuData->SetName( aNewName );
    2586                 :            : 
    2587         [ #  # ]:          0 :                 ReloadTopLevelListBox();
    2588                 :            : 
    2589                 :          0 :                 GetSaveInData()->SetModified( sal_True );
    2590                 :            :             }
    2591                 :            : 
    2592                 :            :             // #i68101# Memory leak (!)
    2593 [ #  # ][ #  # ]:          0 :             delete pNameDialog;
    2594                 :            : 
    2595 [ #  # ][ #  # ]:          0 :             break;
    2596                 :            :         }
    2597                 :            :         case ID_MOVE:
    2598                 :            :         {
    2599                 :          0 :             SvxConfigEntry* pMenuData = GetTopLevelSelection();
    2600                 :            : 
    2601                 :            :             SvxMainMenuOrganizerDialog* pDialog =
    2602                 :            :                 new SvxMainMenuOrganizerDialog( this,
    2603         [ #  # ]:          0 :                     GetSaveInData()->GetEntries(), pMenuData );
    2604                 :            : 
    2605                 :          0 :             bool ret = pDialog->Execute();
    2606                 :            : 
    2607         [ #  # ]:          0 :             if ( ret == RET_OK )
    2608                 :            :             {
    2609                 :          0 :                 GetSaveInData()->SetEntries( pDialog->GetEntries() );
    2610                 :            : 
    2611                 :          0 :                 ReloadTopLevelListBox( pDialog->GetSelectedEntry() );
    2612                 :            : 
    2613                 :          0 :                 GetSaveInData()->SetModified( sal_True );
    2614                 :            :             }
    2615                 :            : 
    2616         [ #  # ]:          0 :             delete pDialog;
    2617                 :            : 
    2618                 :          0 :             break;
    2619                 :            :         }
    2620                 :            :         default:
    2621                 :          0 :             return sal_False;
    2622                 :            :     }
    2623                 :          0 :     return sal_True;
    2624                 :            : }
    2625                 :            : 
    2626                 :          0 : IMPL_LINK( SvxMenuConfigPage, EntrySelectHdl, MenuButton *, pButton )
    2627                 :            : {
    2628   [ #  #  #  #  :          0 :     switch( pButton->GetCurItemId() )
                      # ]
    2629                 :            :     {
    2630                 :            :         case ID_ADD_SUBMENU:
    2631                 :            :         {
    2632         [ #  # ]:          0 :             String aNewName;
    2633 [ #  # ][ #  # ]:          0 :             String aDesc = CUI_RESSTR( RID_SVXSTR_SUBMENU_NAME );
                 [ #  # ]
    2634                 :            : 
    2635 [ #  # ][ #  # ]:          0 :             SvxNameDialog* pNameDialog = new SvxNameDialog( this, aNewName, aDesc );
    2636         [ #  # ]:          0 :             pNameDialog->SetHelpId( HID_SVX_CONFIG_NAME_SUBMENU );
    2637 [ #  # ][ #  # ]:          0 :             pNameDialog->SetText( CUI_RESSTR( RID_SVXSTR_ADD_SUBMENU ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    2638                 :            : 
    2639         [ #  # ]:          0 :             bool ret = pNameDialog->Execute();
    2640                 :            : 
    2641         [ #  # ]:          0 :             if ( ret == RET_OK ) {
    2642         [ #  # ]:          0 :                 pNameDialog->GetName(aNewName);
    2643                 :            : 
    2644                 :            :                 SvxConfigEntry* pNewEntryData =
    2645 [ #  # ][ #  # ]:          0 :                     new SvxConfigEntry( aNewName, aNewName, sal_True );
         [ #  # ][ #  # ]
    2646                 :          0 :                 pNewEntryData->SetUserDefined( sal_True );
    2647                 :            : 
    2648         [ #  # ]:          0 :                 InsertEntry( pNewEntryData );
    2649                 :            : 
    2650         [ #  # ]:          0 :                 ReloadTopLevelListBox();
    2651                 :            : 
    2652                 :          0 :                 GetSaveInData()->SetModified( sal_True );
    2653                 :            :             }
    2654                 :            : 
    2655 [ #  # ][ #  # ]:          0 :             delete pNameDialog;
    2656                 :            : 
    2657 [ #  # ][ #  # ]:          0 :             break;
    2658                 :            :         }
    2659                 :            :         case ID_BEGIN_GROUP:
    2660                 :            :         {
    2661         [ #  # ]:          0 :             SvxConfigEntry* pNewEntryData = new SvxConfigEntry;
    2662                 :          0 :             pNewEntryData->SetUserDefined( sal_True );
    2663                 :          0 :             InsertEntry( pNewEntryData );
    2664                 :            : 
    2665                 :          0 :             break;
    2666                 :            :         }
    2667                 :            :         case ID_DELETE:
    2668                 :            :         {
    2669                 :          0 :             DeleteSelectedContent();
    2670                 :          0 :             break;
    2671                 :            :         }
    2672                 :            :         case ID_RENAME:
    2673                 :            :         {
    2674         [ #  # ]:          0 :             SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry();
    2675                 :            :             SvxConfigEntry* pEntry =
    2676                 :          0 :                 (SvxConfigEntry*) pActEntry->GetUserData();
    2677                 :            : 
    2678         [ #  # ]:          0 :             String aNewName( stripHotKey( pEntry->GetName() ) );
    2679 [ #  # ][ #  # ]:          0 :             String aDesc = CUI_RESSTR( RID_SVXSTR_LABEL_NEW_NAME );
                 [ #  # ]
    2680                 :            : 
    2681 [ #  # ][ #  # ]:          0 :             SvxNameDialog* pNameDialog = new SvxNameDialog( this, aNewName, aDesc );
    2682         [ #  # ]:          0 :             pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_MENU_ITEM );
    2683 [ #  # ][ #  # ]:          0 :             pNameDialog->SetText( CUI_RESSTR( RID_SVXSTR_RENAME_MENU ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    2684                 :            : 
    2685         [ #  # ]:          0 :             bool ret = pNameDialog->Execute();
    2686                 :            : 
    2687         [ #  # ]:          0 :             if ( ret == RET_OK ) {
    2688         [ #  # ]:          0 :                 pNameDialog->GetName(aNewName);
    2689                 :            : 
    2690         [ #  # ]:          0 :                 pEntry->SetName( aNewName );
    2691         [ #  # ]:          0 :                 aContentsListBox->SetEntryText( pActEntry, aNewName );
    2692                 :            : 
    2693                 :          0 :                 GetSaveInData()->SetModified( sal_True );
    2694                 :            :             }
    2695                 :            : 
    2696 [ #  # ][ #  # ]:          0 :             delete pNameDialog;
    2697                 :            : 
    2698 [ #  # ][ #  # ]:          0 :             break;
    2699                 :            :         }
    2700                 :            :         default:
    2701                 :            :         {
    2702                 :          0 :             return sal_False;
    2703                 :            :         }
    2704                 :            :     }
    2705                 :            : 
    2706         [ #  # ]:          0 :     if ( GetSaveInData()->IsModified() )
    2707                 :            :     {
    2708                 :          0 :         UpdateButtonStates();
    2709                 :            :     }
    2710                 :            : 
    2711                 :          0 :     return sal_True;
    2712                 :            : }
    2713                 :            : 
    2714                 :          0 : IMPL_LINK( SvxMenuConfigPage, AddFunctionHdl,
    2715                 :            :     SvxScriptSelectorDialog *, pDialog )
    2716                 :            : {
    2717                 :            :     (void)pDialog;
    2718                 :            : 
    2719                 :          0 :     AddFunction();
    2720                 :            : 
    2721                 :          0 :     return 0;
    2722                 :            : }
    2723                 :            : 
    2724                 :          0 : IMPL_LINK( SvxMenuConfigPage, NewMenuHdl, Button *, pButton )
    2725                 :            : {
    2726                 :            :     (void)pButton;
    2727                 :            : 
    2728                 :            :     SvxMainMenuOrganizerDialog* pDialog =
    2729                 :            :         new SvxMainMenuOrganizerDialog( 0,
    2730         [ #  # ]:          0 :             GetSaveInData()->GetEntries(), NULL, sal_True );
    2731                 :            : 
    2732                 :          0 :     bool ret = pDialog->Execute();
    2733                 :            : 
    2734         [ #  # ]:          0 :     if ( ret == RET_OK )
    2735                 :            :     {
    2736                 :          0 :         GetSaveInData()->SetEntries( pDialog->GetEntries() );
    2737                 :          0 :         ReloadTopLevelListBox( pDialog->GetSelectedEntry() );
    2738                 :          0 :         GetSaveInData()->SetModified( sal_True );
    2739                 :            :     }
    2740                 :            : 
    2741         [ #  # ]:          0 :     delete pDialog;
    2742                 :            : 
    2743                 :          0 :     return 0;
    2744                 :            : }
    2745                 :            : 
    2746                 :          0 : IMPL_LINK( SvxMenuConfigPage, AddCommandsHdl, Button *, pButton )
    2747                 :            : {
    2748                 :            :     (void)pButton;
    2749                 :            : 
    2750         [ #  # ]:          0 :     if ( pSelectorDlg == NULL )
    2751                 :            :     {
    2752                 :            :         // Create Script Selector which also shows builtin commands
    2753         [ #  # ]:          0 :         pSelectorDlg = new SvxScriptSelectorDialog( this, sal_True, m_xFrame );
    2754                 :            : 
    2755                 :            :         pSelectorDlg->SetAddHdl(
    2756                 :          0 :             LINK( this, SvxMenuConfigPage, AddFunctionHdl ) );
    2757                 :            : 
    2758                 :            :         pSelectorDlg->SetDialogDescription( String(
    2759 [ #  # ][ #  # ]:          0 :             CUI_RES( RID_SVXSTR_MENU_ADDCOMMANDS_DESCRIPTION ) ) );
                 [ #  # ]
    2760                 :            :     }
    2761                 :            : 
    2762                 :            :     // Position the Script Selector over the Add button so it is
    2763                 :            :     // beside the menu contents list and does not obscure it
    2764         [ #  # ]:          0 :     pSelectorDlg->SetPosPixel( aAddCommandsButton.GetPosPixel() );
    2765                 :            : 
    2766                 :            :     pSelectorDlg->SetImageProvider(
    2767                 :          0 :         static_cast< ImageProvider* >( GetSaveInData() ) );
    2768                 :            : 
    2769                 :          0 :     pSelectorDlg->Show();
    2770                 :          0 :     return 1;
    2771                 :            : }
    2772                 :            : 
    2773                 :          0 : SaveInData* SvxMenuConfigPage::CreateSaveInData(
    2774                 :            :     const uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
    2775                 :            :     const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
    2776                 :            :     const OUString& aModuleId,
    2777                 :            :     bool bDocConfig )
    2778                 :            : {
    2779                 :            :     return static_cast< SaveInData* >(
    2780         [ #  # ]:          0 :         new MenuSaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig ));
    2781                 :            : }
    2782                 :            : 
    2783                 :          0 : SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
    2784                 :            :     Window* pParent, SvxEntries* entries,
    2785                 :            :     SvxConfigEntry* selection, bool bCreateMenu )
    2786                 :            :     :
    2787                 :          0 :     ModalDialog( pParent, CUI_RES( MD_MENU_ORGANISER ) ),
    2788         [ #  # ]:          0 :     aMenuNameText( this, CUI_RES( TXT_MENU_NAME ) ),
    2789         [ #  # ]:          0 :     aMenuNameEdit( this, CUI_RES( EDIT_MENU_NAME ) ),
    2790         [ #  # ]:          0 :     aMenuListText( this, CUI_RES( TXT_MENU ) ),
    2791         [ #  # ]:          0 :     aMenuListBox( this, CUI_RES( BOX_MAIN_MENUS ) ),
    2792         [ #  # ]:          0 :     aMoveUpButton( this, CUI_RES( BTN_MENU_UP ) ),
    2793         [ #  # ]:          0 :     aMoveDownButton( this, CUI_RES( BTN_MENU_DOWN ) ),
    2794         [ #  # ]:          0 :     aOKButton( this, CUI_RES( BTN_MENU_ADD ) ),
    2795         [ #  # ]:          0 :     aCloseButton( this, CUI_RES( BTN_MENU_CLOSE ) ),
    2796         [ #  # ]:          0 :     aHelpButton( this, CUI_RES( BTN_MENU_HELP ) ),
    2797 [ #  # ][ #  # ]:          0 :     bModified( sal_False )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2798                 :            : {
    2799         [ #  # ]:          0 :     FreeResource();
    2800                 :            : 
    2801                 :            :     // Copy the entries list passed in
    2802         [ #  # ]:          0 :     if ( entries != NULL )
    2803                 :            :     {
    2804                 :            :         SvxConfigEntry* pEntry;
    2805                 :            :         SvLBoxEntry* pLBEntry;
    2806                 :            : 
    2807 [ #  # ][ #  # ]:          0 :         pEntries = new SvxEntries();
    2808         [ #  # ]:          0 :         SvxEntries::const_iterator iter = entries->begin();
    2809                 :            : 
    2810 [ #  # ][ #  # ]:          0 :         while ( iter != entries->end() )
    2811                 :            :         {
    2812                 :          0 :             pEntry = *iter;
    2813                 :            :             pLBEntry =
    2814 [ #  # ][ #  # ]:          0 :                 aMenuListBox.InsertEntry( stripHotKey( pEntry->GetName() ) );
                 [ #  # ]
    2815                 :          0 :             pLBEntry->SetUserData( pEntry );
    2816         [ #  # ]:          0 :             pEntries->push_back( pEntry );
    2817                 :            : 
    2818         [ #  # ]:          0 :             if ( pEntry == selection )
    2819                 :            :             {
    2820         [ #  # ]:          0 :                 aMenuListBox.Select( pLBEntry );
    2821                 :            :             }
    2822                 :          0 :             ++iter;
    2823                 :            :         }
    2824                 :            :     }
    2825                 :            : 
    2826         [ #  # ]:          0 :     if ( bCreateMenu )
    2827                 :            :     {
    2828                 :            :         // Generate custom name for new menu
    2829                 :            :         String prefix =
    2830 [ #  # ][ #  # ]:          0 :             String( CUI_RES( RID_SVXSTR_NEW_MENU ) );
    2831                 :            : 
    2832 [ #  # ][ #  # ]:          0 :         OUString newname = generateCustomName( prefix, entries );
    2833         [ #  # ]:          0 :         OUString newurl = generateCustomMenuURL( pEntries );
    2834                 :            : 
    2835                 :            :         SvxConfigEntry* pNewEntryData =
    2836 [ #  # ][ #  # ]:          0 :             new SvxConfigEntry( newname, newurl, sal_True );
    2837                 :          0 :         pNewEntryData->SetUserDefined( sal_True );
    2838                 :          0 :         pNewEntryData->SetMain( sal_True );
    2839                 :            : 
    2840                 :            :         pNewMenuEntry =
    2841 [ #  # ][ #  # ]:          0 :             aMenuListBox.InsertEntry( stripHotKey( pNewEntryData->GetName() ) );
                 [ #  # ]
    2842         [ #  # ]:          0 :         aMenuListBox.Select( pNewMenuEntry );
    2843                 :            : 
    2844                 :          0 :         pNewMenuEntry->SetUserData( pNewEntryData );
    2845                 :            : 
    2846         [ #  # ]:          0 :         pEntries->push_back( pNewEntryData );
    2847                 :            : 
    2848 [ #  # ][ #  # ]:          0 :         aMenuNameEdit.SetText( newname );
                 [ #  # ]
    2849                 :            :         aMenuNameEdit.SetModifyHdl(
    2850 [ #  # ][ #  # ]:          0 :             LINK( this, SvxMainMenuOrganizerDialog, ModifyHdl ) );
    2851                 :            :     }
    2852                 :            :     else
    2853                 :            :     {
    2854                 :          0 :         Point p, newp;
    2855                 :          0 :         Size s, news;
    2856                 :            : 
    2857                 :            :         // get offset to bottom of name textfield from top of dialog
    2858         [ #  # ]:          0 :         p = aMenuNameEdit.GetPosPixel();
    2859         [ #  # ]:          0 :         s = aMenuNameEdit.GetSizePixel();
    2860                 :          0 :         long offset = p.Y() + s.Height();
    2861                 :            : 
    2862                 :            :         // reposition menu list and label
    2863 [ #  # ][ #  # ]:          0 :         aMenuListText.SetPosPixel( aMenuNameText.GetPosPixel() );
    2864 [ #  # ][ #  # ]:          0 :         aMenuListBox.SetPosPixel( aMenuNameEdit.GetPosPixel() );
    2865                 :            : 
    2866                 :            :         // reposition up and down buttons
    2867         [ #  # ]:          0 :         p = aMoveUpButton.GetPosPixel();
    2868                 :          0 :         newp = Point( p.X(), p.Y() - offset );
    2869         [ #  # ]:          0 :         aMoveUpButton.SetPosPixel( newp );
    2870                 :            : 
    2871         [ #  # ]:          0 :         p = aMoveDownButton.GetPosPixel();
    2872                 :          0 :         newp = Point( p.X(), p.Y() - offset );
    2873         [ #  # ]:          0 :         aMoveDownButton.SetPosPixel( newp );
    2874                 :            : 
    2875                 :            :         // change size of dialog
    2876         [ #  # ]:          0 :         s = GetSizePixel();
    2877                 :          0 :         news = Size( s.Width(), s.Height() - offset );
    2878         [ #  # ]:          0 :         SetSizePixel( news );
    2879                 :            : 
    2880                 :            :         // hide name label and textfield
    2881         [ #  # ]:          0 :         aMenuNameText.Hide();
    2882         [ #  # ]:          0 :         aMenuNameEdit.Hide();
    2883                 :            : 
    2884                 :            :         // change the title
    2885 [ #  # ][ #  # ]:          0 :         SetText( CUI_RES( RID_SVXSTR_MOVE_MENU ) );
         [ #  # ][ #  # ]
    2886                 :            :     }
    2887                 :            : 
    2888                 :            :     aMenuListBox.SetSelectHdl(
    2889         [ #  # ]:          0 :         LINK( this, SvxMainMenuOrganizerDialog, SelectHdl ) );
    2890                 :            : 
    2891                 :            :     aMoveUpButton.SetClickHdl (
    2892         [ #  # ]:          0 :         LINK( this, SvxMainMenuOrganizerDialog, MoveHdl) );
    2893                 :            :     aMoveDownButton.SetClickHdl (
    2894         [ #  # ]:          0 :         LINK( this, SvxMainMenuOrganizerDialog, MoveHdl) );
    2895                 :            : 
    2896 [ #  # ][ #  # ]:          0 :     aMoveUpButton.SetAccessibleName(String(CUI_RES(BUTTON_STR_UP)));
         [ #  # ][ #  # ]
    2897 [ #  # ][ #  # ]:          0 :     aMoveDownButton.SetAccessibleName(String(CUI_RES(BUTTON_STR_DOWN)));
         [ #  # ][ #  # ]
    2898                 :          0 : }
    2899                 :            : 
    2900                 :          0 : IMPL_LINK(SvxMainMenuOrganizerDialog, ModifyHdl, Edit*, pEdit)
    2901                 :            : {
    2902                 :            :     (void)pEdit;
    2903                 :            : 
    2904                 :            :     // if the Edit control is empty do not change the name
    2905 [ #  # ][ #  # ]:          0 :     if ( aMenuNameEdit.GetText().Equals( String() ) )
         [ #  # ][ #  # ]
    2906                 :            :     {
    2907                 :          0 :         return 0;
    2908                 :            :     }
    2909                 :            : 
    2910                 :            :     SvxConfigEntry* pNewEntryData =
    2911                 :          0 :         (SvxConfigEntry*) pNewMenuEntry->GetUserData();
    2912                 :            : 
    2913         [ #  # ]:          0 :     pNewEntryData->SetName( aMenuNameEdit.GetText() );
    2914                 :            : 
    2915         [ #  # ]:          0 :     aMenuListBox.SetEntryText( pNewMenuEntry, pNewEntryData->GetName() );
    2916                 :            : 
    2917                 :          0 :     return 0;
    2918                 :            : }
    2919                 :            : 
    2920 [ #  # ][ #  # ]:          0 : SvxMainMenuOrganizerDialog::~SvxMainMenuOrganizerDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2921                 :            : {
    2922         [ #  # ]:          0 : }
    2923                 :            : 
    2924                 :          0 : IMPL_LINK( SvxMainMenuOrganizerDialog, SelectHdl, Control*, pCtrl )
    2925                 :            : {
    2926                 :            :     (void)pCtrl;
    2927                 :          0 :     UpdateButtonStates();
    2928                 :          0 :     return 1;
    2929                 :            : }
    2930                 :            : 
    2931                 :          0 : void SvxMainMenuOrganizerDialog::UpdateButtonStates()
    2932                 :            : {
    2933                 :            :     // Disable Up and Down buttons depending on current selection
    2934                 :          0 :     SvLBoxEntry* selection = aMenuListBox.GetCurEntry();
    2935                 :          0 :     SvLBoxEntry* first = aMenuListBox.First();
    2936                 :          0 :     SvLBoxEntry* last = aMenuListBox.Last();
    2937                 :            : 
    2938                 :          0 :     aMoveUpButton.Enable( selection != first );
    2939                 :          0 :     aMoveDownButton.Enable( selection != last );
    2940                 :          0 : }
    2941                 :            : 
    2942                 :          0 : IMPL_LINK( SvxMainMenuOrganizerDialog, MoveHdl, Button *, pButton )
    2943                 :            : {
    2944                 :          0 :     SvLBoxEntry *pSourceEntry = aMenuListBox.FirstSelected();
    2945                 :          0 :     SvLBoxEntry *pTargetEntry = NULL;
    2946                 :            : 
    2947         [ #  # ]:          0 :     if ( !pSourceEntry )
    2948                 :            :     {
    2949                 :          0 :         return 0;
    2950                 :            :     }
    2951                 :            : 
    2952         [ #  # ]:          0 :     if ( pButton == &aMoveDownButton )
    2953                 :            :     {
    2954                 :          0 :         pTargetEntry = aMenuListBox.NextSibling( pSourceEntry );
    2955                 :            :     }
    2956         [ #  # ]:          0 :     else if ( pButton == &aMoveUpButton )
    2957                 :            :     {
    2958                 :            :         // Move Up is just a Move Down with the source and target reversed
    2959                 :          0 :         pTargetEntry = pSourceEntry;
    2960                 :          0 :         pSourceEntry = aMenuListBox.PrevSibling( pTargetEntry );
    2961                 :            :     }
    2962                 :            : 
    2963 [ #  # ][ #  # ]:          0 :     if ( pSourceEntry != NULL && pTargetEntry != NULL )
    2964                 :            :     {
    2965                 :            :         SvxConfigEntry* pSourceData =
    2966                 :          0 :             (SvxConfigEntry*) pSourceEntry->GetUserData();
    2967                 :            :         SvxConfigEntry* pTargetData =
    2968                 :          0 :             (SvxConfigEntry*) pTargetEntry->GetUserData();
    2969                 :            : 
    2970                 :          0 :         SvxEntries::iterator iter1 = GetEntries()->begin();
    2971                 :          0 :         SvxEntries::iterator iter2 = GetEntries()->begin();
    2972         [ #  # ]:          0 :         SvxEntries::const_iterator end = GetEntries()->end();
    2973                 :            : 
    2974                 :            :         // Advance the iterators to the positions of the source and target
    2975 [ #  # ][ #  # ]:          0 :         while (*iter1 != pSourceData && ++iter1 != end) ;
         [ #  # ][ #  # ]
    2976 [ #  # ][ #  # ]:          0 :         while (*iter2 != pTargetData && ++iter2 != end) ;
         [ #  # ][ #  # ]
    2977                 :            : 
    2978                 :            :         // Now swap the entries in the menu list and in the UI
    2979 [ #  # ][ #  # ]:          0 :         if ( iter1 != end && iter2 != end )
         [ #  # ][ #  # ]
                 [ #  # ]
    2980                 :            :         {
    2981                 :          0 :             std::swap( *iter1, *iter2 );
    2982         [ #  # ]:          0 :             aMenuListBox.GetModel()->Move( pSourceEntry, pTargetEntry );
    2983         [ #  # ]:          0 :             aMenuListBox.MakeVisible( pSourceEntry );
    2984                 :            : 
    2985                 :          0 :             bModified = sal_True;
    2986                 :            :         }
    2987                 :            :     }
    2988                 :            : 
    2989         [ #  # ]:          0 :     if ( bModified )
    2990                 :            :     {
    2991                 :          0 :         UpdateButtonStates();
    2992                 :            :     }
    2993                 :            : 
    2994                 :          0 :     return 0;
    2995                 :            : }
    2996                 :            : 
    2997                 :          0 : SvxEntries* SvxMainMenuOrganizerDialog::GetEntries()
    2998                 :            : {
    2999                 :          0 :     return pEntries;
    3000                 :            : }
    3001                 :            : 
    3002                 :          0 : SvxConfigEntry* SvxMainMenuOrganizerDialog::GetSelectedEntry()
    3003                 :            : {
    3004                 :          0 :     return (SvxConfigEntry*)aMenuListBox.FirstSelected()->GetUserData();
    3005                 :            : }
    3006                 :            : 
    3007                 :            : const OUString&
    3008                 :          0 : SvxConfigEntry::GetHelpText()
    3009                 :            : {
    3010         [ #  # ]:          0 :     if ( aHelpText.isEmpty() )
    3011                 :            :     {
    3012         [ #  # ]:          0 :         if ( !aCommand.isEmpty() )
    3013                 :            :         {
    3014 [ #  # ][ #  # ]:          0 :             aHelpText = Application::GetHelp()->GetHelpText( aCommand, NULL );
                 [ #  # ]
    3015                 :            :         }
    3016                 :            :     }
    3017                 :            : 
    3018                 :          0 :     return aHelpText;
    3019                 :            : }
    3020                 :            : 
    3021                 :          0 : SvxConfigEntry::SvxConfigEntry( const OUString& rDisplayName,
    3022                 :            :                                 const OUString& rCommandURL, bool bPopup, bool bParentData )
    3023                 :            :     : nId( 1 )
    3024                 :            :     , aLabel(rDisplayName)
    3025                 :            :     , aCommand(rCommandURL)
    3026                 :            :     , bPopUp(bPopup)
    3027                 :            :     , bStrEdited( sal_False )
    3028                 :            :     , bIsUserDefined( sal_False )
    3029                 :            :     , bIsMain( sal_False )
    3030                 :            :     , bIsParentData( bParentData )
    3031                 :            :     , bIsVisible( sal_True )
    3032                 :            :     , nStyle( 0 )
    3033                 :          0 :     , pEntries( 0 )
    3034                 :            : {
    3035         [ #  # ]:          0 :     if (bPopUp)
    3036                 :            :     {
    3037 [ #  # ][ #  # ]:          0 :         pEntries = new SvxEntries();
    3038                 :            :     }
    3039                 :          0 : }
    3040                 :            : 
    3041                 :          0 : SvxConfigEntry::~SvxConfigEntry()
    3042                 :            : {
    3043         [ #  # ]:          0 :     if ( pEntries != NULL )
    3044                 :            :     {
    3045         [ #  # ]:          0 :         SvxEntries::const_iterator iter = pEntries->begin();
    3046                 :            : 
    3047 [ #  # ][ #  # ]:          0 :         for ( ; iter != pEntries->end(); ++iter )
    3048                 :            :         {
    3049 [ #  # ][ #  # ]:          0 :             delete *iter;
    3050                 :            :         }
    3051         [ #  # ]:          0 :         delete pEntries;
    3052                 :            :     }
    3053                 :          0 : }
    3054                 :            : 
    3055                 :          0 : bool SvxConfigEntry::IsMovable()
    3056                 :            : {
    3057 [ #  # ][ #  # ]:          0 :     if ( IsPopup() && !IsMain() )
                 [ #  # ]
    3058                 :            :     {
    3059                 :          0 :         return sal_False;
    3060                 :            :     }
    3061                 :          0 :     return sal_True;
    3062                 :            : }
    3063                 :            : 
    3064                 :          0 : bool SvxConfigEntry::IsDeletable()
    3065                 :            : {
    3066 [ #  # ][ #  # ]:          0 :     if ( IsMain() && !IsUserDefined() )
                 [ #  # ]
    3067                 :            :     {
    3068                 :          0 :         return sal_False;
    3069                 :            :     }
    3070                 :          0 :     return sal_True;
    3071                 :            : }
    3072                 :            : 
    3073                 :          0 : bool SvxConfigEntry::IsRenamable()
    3074                 :            : {
    3075 [ #  # ][ #  # ]:          0 :     if ( IsMain() && !IsUserDefined() )
                 [ #  # ]
    3076                 :            :     {
    3077                 :          0 :         return sal_False;
    3078                 :            :     }
    3079                 :          0 :     return sal_True;
    3080                 :            : }
    3081                 :            : 
    3082                 :          0 : SvxToolbarConfigPage::SvxToolbarConfigPage(
    3083                 :            :     Window *pParent, const SfxItemSet& rSet )
    3084                 :            :     :
    3085                 :          0 :     SvxConfigPage( pParent, rSet )
    3086                 :            : {
    3087         [ #  # ]:          0 :     SetHelpId( HID_SVX_CONFIG_TOOLBAR );
    3088                 :            : 
    3089 [ #  # ][ #  # ]:          0 :     aContentsListBox = new SvxToolbarEntriesListBox(this, CUI_RES(BOX_ENTRIES));
                 [ #  # ]
    3090         [ #  # ]:          0 :     FreeResource();
    3091         [ #  # ]:          0 :     PositionContentsListBox();
    3092         [ #  # ]:          0 :     aContentsListBox->SetZOrder( &aAddCommandsButton, WINDOW_ZORDER_BEFOR );
    3093                 :            : 
    3094         [ #  # ]:          0 :     aContentsListBox->SetHelpId( HID_SVX_CONFIG_TOOLBAR_CONTENTS );
    3095         [ #  # ]:          0 :     aNewTopLevelButton.SetHelpId( HID_SVX_NEW_TOOLBAR );
    3096         [ #  # ]:          0 :     aModifyTopLevelButton.SetHelpId( HID_SVX_MODIFY_TOOLBAR );
    3097         [ #  # ]:          0 :     aAddCommandsButton.SetHelpId( HID_SVX_NEW_TOOLBAR_ITEM );
    3098         [ #  # ]:          0 :     aModifyCommandButton.SetHelpId( HID_SVX_MODIFY_TOOLBAR_ITEM );
    3099         [ #  # ]:          0 :     aSaveInListBox.SetHelpId( HID_SVX_SAVE_IN );
    3100                 :            : 
    3101                 :            :     aTopLevelSeparator.SetText(
    3102 [ #  # ][ #  # ]:          0 :         CUI_RES ( RID_SVXSTR_PRODUCTNAME_TOOLBARS ) );
         [ #  # ][ #  # ]
    3103                 :            : 
    3104 [ #  # ][ #  # ]:          0 :     aTopLevelLabel.SetText( CUI_RES( RID_SVXSTR_TOOLBAR ) );
         [ #  # ][ #  # ]
    3105 [ #  # ][ #  # ]:          0 :     aModifyTopLevelButton.SetText( CUI_RES( RID_SVXSTR_TOOLBAR ) );
         [ #  # ][ #  # ]
    3106 [ #  # ][ #  # ]:          0 :     aContentsSeparator.SetText( CUI_RES( RID_SVXSTR_TOOLBAR_CONTENT ) );
         [ #  # ][ #  # ]
    3107 [ #  # ][ #  # ]:          0 :     aContentsLabel.SetText( CUI_RES( RID_SVXSTR_COMMANDS ) );
         [ #  # ][ #  # ]
    3108                 :            : 
    3109                 :            :     aTopLevelListBox.SetSelectHdl(
    3110         [ #  # ]:          0 :         LINK( this, SvxToolbarConfigPage, SelectToolbar ) );
    3111                 :            :     aContentsListBox->SetSelectHdl(
    3112         [ #  # ]:          0 :         LINK( this, SvxToolbarConfigPage, SelectToolbarEntry ) );
    3113                 :            : 
    3114                 :            :     aNewTopLevelButton.SetClickHdl  (
    3115         [ #  # ]:          0 :         LINK( this, SvxToolbarConfigPage, NewToolbarHdl ) );
    3116                 :            : 
    3117                 :            :     aAddCommandsButton.SetClickHdl  (
    3118         [ #  # ]:          0 :         LINK( this, SvxToolbarConfigPage, AddCommandsHdl ) );
    3119                 :            : 
    3120         [ #  # ]:          0 :     aMoveUpButton.SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
    3121         [ #  # ]:          0 :     aMoveDownButton.SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
    3122                 :            :     // Always enable Up and Down buttons
    3123                 :            :     // added for issue i53677 by shizhoubo
    3124         [ #  # ]:          0 :     aMoveDownButton.Enable( sal_True );
    3125         [ #  # ]:          0 :     aMoveUpButton.Enable( sal_True );
    3126                 :            : 
    3127 [ #  # ][ #  # ]:          0 :     PopupMenu* pMenu = new PopupMenu( CUI_RES( MODIFY_TOOLBAR ) );
                 [ #  # ]
    3128                 :            :     pMenu->SetMenuFlags(
    3129                 :          0 :         pMenu->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
    3130                 :            : 
    3131         [ #  # ]:          0 :     aModifyTopLevelButton.SetPopupMenu( pMenu );
    3132                 :            :     aModifyTopLevelButton.SetSelectHdl(
    3133         [ #  # ]:          0 :         LINK( this, SvxToolbarConfigPage, ToolbarSelectHdl ) );
    3134                 :            : 
    3135                 :            :     PopupMenu* pEntry = new PopupMenu(
    3136 [ #  # ][ #  # ]:          0 :         CUI_RES( MODIFY_TOOLBAR_CONTENT ) );
                 [ #  # ]
    3137                 :            :     pEntry->SetMenuFlags(
    3138                 :          0 :         pEntry->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
    3139                 :            : 
    3140         [ #  # ]:          0 :     aModifyCommandButton.SetPopupMenu( pEntry );
    3141                 :            :     aModifyCommandButton.SetSelectHdl(
    3142         [ #  # ]:          0 :         LINK( this, SvxToolbarConfigPage, EntrySelectHdl ) );
    3143                 :            : 
    3144                 :            :     // default toolbar to select is standardbar unless a different one
    3145                 :            :     // has been passed in
    3146                 :          0 :     m_aURLToSelect = OUString(ITEM_TOOLBAR_URL );
    3147                 :          0 :     m_aURLToSelect += OUString("standardbar" );
    3148                 :            : 
    3149                 :            :     const SfxPoolItem* pItem =
    3150 [ #  # ][ #  # ]:          0 :         rSet.GetItem( rSet.GetPool()->GetWhich( SID_CONFIG ) );
    3151                 :            : 
    3152         [ #  # ]:          0 :     if ( pItem )
    3153                 :            :     {
    3154         [ #  # ]:          0 :         OUString text = ((const SfxStringItem*)pItem)->GetValue();
    3155         [ #  # ]:          0 :         if (text.indexOf( ITEM_TOOLBAR_URL ) == 0)
    3156                 :            :         {
    3157                 :          0 :             m_aURLToSelect = text.copy( 0 );
    3158                 :          0 :         }
    3159                 :            :     }
    3160                 :            : 
    3161 [ #  # ][ #  # ]:          0 :     long nTxtW = aTopLevelLabel.GetCtrlTextWidth( aTopLevelLabel.GetText() );
                 [ #  # ]
    3162         [ #  # ]:          0 :     long nCtrlW = aTopLevelLabel.GetSizePixel().Width();
    3163         [ #  # ]:          0 :     if ( nTxtW >= nCtrlW )
    3164                 :            :     {
    3165                 :          0 :         long nDelta = Max( (long)10, nTxtW - nCtrlW );
    3166         [ #  # ]:          0 :         Size aNewSz = aTopLevelLabel.GetSizePixel();
    3167                 :          0 :         aNewSz.Width() += nDelta;
    3168         [ #  # ]:          0 :         aTopLevelLabel.SetSizePixel( aNewSz );
    3169         [ #  # ]:          0 :         aNewSz = aTopLevelListBox.GetSizePixel();
    3170                 :          0 :         aNewSz.Width() -= nDelta;
    3171         [ #  # ]:          0 :         Point aNewPt = aTopLevelListBox.GetPosPixel();
    3172                 :          0 :         aNewPt.X() += nDelta;
    3173         [ #  # ]:          0 :         aTopLevelListBox.SetPosSizePixel( aNewPt, aNewSz );
    3174                 :            :     }
    3175                 :          0 : }
    3176                 :            : 
    3177                 :          0 : SvxToolbarConfigPage::~SvxToolbarConfigPage()
    3178                 :            : {
    3179 [ #  # ][ #  # ]:          0 :     for ( sal_uInt16 i = 0 ; i < aSaveInListBox.GetEntryCount(); ++i )
    3180                 :            :     {
    3181                 :            :         ToolbarSaveInData* pData =
    3182         [ #  # ]:          0 :             (ToolbarSaveInData*) aSaveInListBox.GetEntryData( i );
    3183                 :            : 
    3184 [ #  # ][ #  # ]:          0 :         delete pData;
    3185                 :            :     }
    3186                 :            : 
    3187         [ #  # ]:          0 :     if ( pSelectorDlg != NULL )
    3188                 :            :     {
    3189 [ #  # ][ #  # ]:          0 :         delete pSelectorDlg;
    3190                 :            :     }
    3191                 :            : 
    3192                 :            : 
    3193 [ #  # ][ #  # ]:          0 :     delete aContentsListBox;
    3194         [ #  # ]:          0 : }
    3195                 :            : 
    3196                 :          0 : void SvxToolbarConfigPage::DeleteSelectedTopLevel()
    3197                 :            : {
    3198                 :          0 :     sal_uInt16 nSelectionPos = aTopLevelListBox.GetSelectEntryPos();
    3199                 :          0 :     ToolbarSaveInData* pSaveInData = (ToolbarSaveInData*) GetSaveInData();
    3200                 :          0 :     pSaveInData->RemoveToolbar( GetTopLevelSelection() );
    3201                 :            : 
    3202         [ #  # ]:          0 :     if ( aTopLevelListBox.GetEntryCount() > 1 )
    3203                 :            :     {
    3204                 :            :         // select next entry after the one being deleted
    3205                 :            :         // selection position is indexed from 0 so need to
    3206                 :            :         // subtract one from the entry count
    3207         [ #  # ]:          0 :         if ( nSelectionPos != aTopLevelListBox.GetEntryCount() - 1 )
    3208                 :            :         {
    3209                 :          0 :             aTopLevelListBox.SelectEntryPos( nSelectionPos + 1, sal_True );
    3210                 :            :         }
    3211                 :            :         else
    3212                 :            :         {
    3213                 :          0 :             aTopLevelListBox.SelectEntryPos( nSelectionPos - 1, sal_True );
    3214                 :            :         }
    3215                 :          0 :         aTopLevelListBox.GetSelectHdl().Call( this );
    3216                 :            : 
    3217                 :            :         // and now remove the entry
    3218                 :          0 :         aTopLevelListBox.RemoveEntry( nSelectionPos );
    3219                 :            :     }
    3220                 :            :     else
    3221                 :            :     {
    3222                 :          0 :         ReloadTopLevelListBox();
    3223                 :            :     }
    3224                 :          0 : }
    3225                 :            : 
    3226                 :          0 : bool SvxToolbarConfigPage::DeleteSelectedContent()
    3227                 :            : {
    3228                 :          0 :     SvLBoxEntry *pActEntry = aContentsListBox->FirstSelected();
    3229                 :            : 
    3230         [ #  # ]:          0 :     if ( pActEntry != NULL )
    3231                 :            :     {
    3232                 :            :         // get currently selected entry
    3233                 :            :         SvxConfigEntry* pEntry =
    3234                 :          0 :             (SvxConfigEntry*) pActEntry->GetUserData();
    3235                 :            : 
    3236                 :          0 :         SvxConfigEntry* pToolbar = GetTopLevelSelection();
    3237                 :            : 
    3238                 :            :         // remove entry from the list for this toolbar
    3239                 :          0 :         RemoveEntry( pToolbar->GetEntries(), pEntry );
    3240                 :            : 
    3241                 :            :         // remove toolbar entry from UI
    3242                 :          0 :         aContentsListBox->GetModel()->Remove( pActEntry );
    3243                 :            : 
    3244                 :            :         // delete data for toolbar entry
    3245         [ #  # ]:          0 :         delete pEntry;
    3246                 :            : 
    3247                 :          0 :         (( ToolbarSaveInData* ) GetSaveInData())->ApplyToolbar( pToolbar );
    3248                 :          0 :         UpdateButtonStates();
    3249                 :            : 
    3250                 :            :         // if this is the last entry in the toolbar and it is a user
    3251                 :            :         // defined toolbar pop up a dialog asking the user if they
    3252                 :            :         // want to delete the toolbar
    3253         [ #  # ]:          0 :         if ( aContentsListBox->GetEntryCount() == 0 &&
           [ #  #  #  # ]
    3254                 :          0 :              GetTopLevelSelection()->IsDeletable() )
    3255                 :            :         {
    3256                 :            :             QueryBox qbox( this,
    3257 [ #  # ][ #  # ]:          0 :                 CUI_RES( QBX_CONFIRM_DELETE_TOOLBAR ) );
    3258                 :            : 
    3259 [ #  # ][ #  # ]:          0 :             if ( qbox.Execute() == RET_YES )
    3260                 :            :             {
    3261         [ #  # ]:          0 :                 DeleteSelectedTopLevel();
    3262         [ #  # ]:          0 :             }
    3263                 :            :         }
    3264                 :            : 
    3265                 :          0 :         return sal_True;
    3266                 :            :     }
    3267                 :            : 
    3268                 :          0 :     return sal_False;
    3269                 :            : }
    3270                 :            : 
    3271                 :          0 : IMPL_LINK( SvxToolbarConfigPage, MoveHdl, Button *, pButton )
    3272                 :            : {
    3273                 :          0 :     MoveEntry( pButton == &aMoveUpButton );
    3274                 :          0 :     return 0;
    3275                 :            : }
    3276                 :            : 
    3277                 :          0 : void SvxToolbarConfigPage::MoveEntry( bool bMoveUp )
    3278                 :            : {
    3279                 :          0 :     SvxConfigPage::MoveEntry( bMoveUp );
    3280                 :            : 
    3281                 :            :     // Apply change to currently selected toolbar
    3282                 :          0 :     SvxConfigEntry* pToolbar = GetTopLevelSelection();
    3283         [ #  # ]:          0 :     if ( pToolbar )
    3284                 :          0 :         ((ToolbarSaveInData*)GetSaveInData())->ApplyToolbar( pToolbar );
    3285                 :            :     else
    3286                 :            :     {
    3287                 :            :         SAL_WARN( "cui.customize", "SvxToolbarConfigPage::MoveEntry(): no entry" );
    3288                 :          0 :         UpdateButtonStates();
    3289                 :            :     }
    3290                 :          0 : }
    3291                 :            : 
    3292                 :          0 : IMPL_LINK( SvxToolbarConfigPage, ToolbarSelectHdl, MenuButton *, pButton )
    3293                 :            : {
    3294                 :          0 :     sal_uInt16 nSelectionPos = aTopLevelListBox.GetSelectEntryPos();
    3295                 :            : 
    3296                 :            :     SvxConfigEntry* pToolbar =
    3297                 :          0 :         (SvxConfigEntry*)aTopLevelListBox.GetEntryData( nSelectionPos );
    3298                 :            : 
    3299                 :          0 :     ToolbarSaveInData* pSaveInData = (ToolbarSaveInData*) GetSaveInData();
    3300                 :            : 
    3301   [ #  #  #  #  :          0 :     switch( pButton->GetCurItemId() )
                #  #  # ]
    3302                 :            :     {
    3303                 :            :         case ID_DELETE:
    3304                 :            :         {
    3305                 :          0 :             DeleteSelectedTopLevel();
    3306                 :          0 :             UpdateButtonStates();
    3307                 :          0 :             break;
    3308                 :            :         }
    3309                 :            :         case ID_RENAME:
    3310                 :            :         {
    3311         [ #  # ]:          0 :             String aNewName( stripHotKey( pToolbar->GetName() ) );
    3312 [ #  # ][ #  # ]:          0 :             String aDesc = CUI_RESSTR( RID_SVXSTR_LABEL_NEW_NAME );
                 [ #  # ]
    3313                 :            : 
    3314 [ #  # ][ #  # ]:          0 :             SvxNameDialog* pNameDialog = new SvxNameDialog( this, aNewName, aDesc );
    3315         [ #  # ]:          0 :             pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_TOOLBAR );
    3316 [ #  # ][ #  # ]:          0 :             pNameDialog->SetText( CUI_RESSTR( RID_SVXSTR_RENAME_TOOLBAR ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    3317                 :            : 
    3318         [ #  # ]:          0 :             bool ret = pNameDialog->Execute();
    3319                 :            : 
    3320         [ #  # ]:          0 :             if ( ret == RET_OK )
    3321                 :            :             {
    3322         [ #  # ]:          0 :                 pNameDialog->GetName(aNewName);
    3323                 :            : 
    3324         [ #  # ]:          0 :                 pToolbar->SetName( aNewName );
    3325         [ #  # ]:          0 :                 pSaveInData->ApplyToolbar( pToolbar );
    3326                 :            : 
    3327                 :            :                 // have to use remove and insert to change the name
    3328         [ #  # ]:          0 :                 aTopLevelListBox.RemoveEntry( nSelectionPos );
    3329                 :            :                 nSelectionPos =
    3330         [ #  # ]:          0 :                     aTopLevelListBox.InsertEntry( aNewName, nSelectionPos );
    3331         [ #  # ]:          0 :                 aTopLevelListBox.SetEntryData( nSelectionPos, pToolbar );
    3332         [ #  # ]:          0 :                 aTopLevelListBox.SelectEntryPos( nSelectionPos );
    3333                 :            :             }
    3334                 :            : 
    3335 [ #  # ][ #  # ]:          0 :             delete pNameDialog;
    3336                 :            : 
    3337 [ #  # ][ #  # ]:          0 :             break;
    3338                 :            :         }
    3339                 :            :         case ID_DEFAULT_STYLE:
    3340                 :            :         {
    3341                 :            :             QueryBox qbox( this,
    3342 [ #  # ][ #  # ]:          0 :                 CUI_RES( QBX_CONFIRM_RESTORE_DEFAULT ) );
    3343                 :            : 
    3344 [ #  # ][ #  # ]:          0 :             if ( qbox.Execute() == RET_YES )
    3345                 :            :             {
    3346                 :            :                 ToolbarSaveInData* pSaveInData_ =
    3347                 :          0 :                     (ToolbarSaveInData*) GetSaveInData();
    3348                 :            : 
    3349         [ #  # ]:          0 :                 pSaveInData_->RestoreToolbar( pToolbar );
    3350                 :            : 
    3351         [ #  # ]:          0 :                 aTopLevelListBox.GetSelectHdl().Call( this );
    3352                 :            :             }
    3353                 :            : 
    3354         [ #  # ]:          0 :             break;
    3355                 :            :         }
    3356                 :            :         case ID_ICONS_ONLY:
    3357                 :            :         {
    3358                 :          0 :             pToolbar->SetStyle( 0 );
    3359         [ #  # ]:          0 :             pSaveInData->SetSystemStyle( m_xFrame, pToolbar->GetCommand(), 0 );
    3360                 :            : 
    3361                 :          0 :             aTopLevelListBox.GetSelectHdl().Call( this );
    3362                 :            : 
    3363                 :          0 :             break;
    3364                 :            :         }
    3365                 :            :         case ID_TEXT_ONLY:
    3366                 :            :         {
    3367                 :          0 :             pToolbar->SetStyle( 1 );
    3368         [ #  # ]:          0 :             pSaveInData->SetSystemStyle( m_xFrame, pToolbar->GetCommand(), 1 );
    3369                 :            : 
    3370                 :          0 :             aTopLevelListBox.GetSelectHdl().Call( this );
    3371                 :            : 
    3372                 :          0 :             break;
    3373                 :            :         }
    3374                 :            :         case ID_ICONS_AND_TEXT:
    3375                 :            :         {
    3376                 :          0 :             pToolbar->SetStyle( 2 );
    3377         [ #  # ]:          0 :             pSaveInData->SetSystemStyle( m_xFrame, pToolbar->GetCommand(), 2 );
    3378                 :            : 
    3379                 :          0 :             aTopLevelListBox.GetSelectHdl().Call( this );
    3380                 :            : 
    3381                 :          0 :             break;
    3382                 :            :         }
    3383                 :            :     }
    3384                 :          0 :     return 1;
    3385                 :            : }
    3386                 :            : 
    3387                 :          0 : IMPL_LINK( SvxToolbarConfigPage, EntrySelectHdl, MenuButton *, pButton )
    3388                 :            : {
    3389                 :          0 :     bool bNeedsApply = sal_False;
    3390                 :            : 
    3391                 :            :     // get currently selected toolbar
    3392                 :          0 :     SvxConfigEntry* pToolbar = GetTopLevelSelection();
    3393                 :            : 
    3394   [ #  #  #  #  :          0 :     switch( pButton->GetCurItemId() )
          #  #  #  #  #  
                      # ]
    3395                 :            :     {
    3396                 :            :         case ID_RENAME:
    3397                 :            :         {
    3398         [ #  # ]:          0 :             SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry();
    3399                 :            :             SvxConfigEntry* pEntry =
    3400                 :          0 :                 (SvxConfigEntry*) pActEntry->GetUserData();
    3401                 :            : 
    3402         [ #  # ]:          0 :             String aNewName( stripHotKey( pEntry->GetName() ) );
    3403 [ #  # ][ #  # ]:          0 :             String aDesc = CUI_RESSTR( RID_SVXSTR_LABEL_NEW_NAME );
                 [ #  # ]
    3404                 :            : 
    3405 [ #  # ][ #  # ]:          0 :             SvxNameDialog* pNameDialog = new SvxNameDialog( this, aNewName, aDesc );
    3406         [ #  # ]:          0 :             pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM );
    3407 [ #  # ][ #  # ]:          0 :             pNameDialog->SetText( CUI_RESSTR( RID_SVXSTR_RENAME_TOOLBAR ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    3408                 :            : 
    3409         [ #  # ]:          0 :             bool ret = pNameDialog->Execute();
    3410                 :            : 
    3411         [ #  # ]:          0 :             if ( ret == RET_OK ) {
    3412         [ #  # ]:          0 :                 pNameDialog->GetName(aNewName);
    3413                 :            : 
    3414         [ #  # ]:          0 :                 pEntry->SetName( aNewName );
    3415         [ #  # ]:          0 :                 aContentsListBox->SetEntryText( pActEntry, aNewName );
    3416                 :            : 
    3417                 :          0 :                 bNeedsApply = sal_True;
    3418                 :            :             }
    3419                 :            : 
    3420 [ #  # ][ #  # ]:          0 :             delete pNameDialog;
    3421 [ #  # ][ #  # ]:          0 :             break;
    3422                 :            :         }
    3423                 :            :         case ID_DEFAULT_COMMAND:
    3424                 :            :         {
    3425         [ #  # ]:          0 :             SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry();
    3426                 :            :             SvxConfigEntry* pEntry =
    3427                 :          0 :                 (SvxConfigEntry*) pActEntry->GetUserData();
    3428                 :            : 
    3429                 :          0 :             sal_uInt16 nSelectionPos = 0;
    3430                 :            : 
    3431                 :            :             // find position of entry within the list
    3432         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < aContentsListBox->GetEntryCount(); ++i )
    3433                 :            :             {
    3434 [ #  # ][ #  # ]:          0 :                 if ( aContentsListBox->GetEntry( 0, i ) == pActEntry )
    3435                 :            :                 {
    3436                 :          0 :                     nSelectionPos = i;
    3437                 :          0 :                     break;
    3438                 :            :                 }
    3439                 :            :             }
    3440                 :            : 
    3441                 :            :             ToolbarSaveInData* pSaveInData =
    3442                 :          0 :                 (ToolbarSaveInData*) GetSaveInData();
    3443                 :            : 
    3444                 :            :             OUString aSystemName =
    3445         [ #  # ]:          0 :                 pSaveInData->GetSystemUIName( pEntry->GetCommand() );
    3446                 :            : 
    3447         [ #  # ]:          0 :             if ( !pEntry->GetName().equals( aSystemName ) )
    3448                 :            :             {
    3449 [ #  # ][ #  # ]:          0 :                 pEntry->SetName( aSystemName );
                 [ #  # ]
    3450                 :            :                 aContentsListBox->SetEntryText(
    3451 [ #  # ][ #  # ]:          0 :                     pActEntry, stripHotKey( aSystemName ) );
                 [ #  # ]
    3452                 :          0 :                 bNeedsApply = sal_True;
    3453                 :            :             }
    3454                 :            : 
    3455         [ #  # ]:          0 :             uno::Sequence< OUString > aURLSeq( 1 );
    3456         [ #  # ]:          0 :             aURLSeq[ 0 ] = pEntry->GetCommand();
    3457                 :            : 
    3458                 :            :             try
    3459                 :            :             {
    3460 [ #  # ][ #  # ]:          0 :                 GetSaveInData()->GetImageManager()->removeImages(
    3461         [ #  # ]:          0 :                     GetImageType(), aURLSeq );
    3462                 :            : 
    3463                 :            :                 // reset backup in entry
    3464                 :            :                 pEntry->SetBackupGraphic(
    3465         [ #  # ]:          0 :                     uno::Reference< graphic::XGraphic >() );
    3466                 :            : 
    3467                 :            :                 GetSaveInData()->PersistChanges(
    3468 [ #  # ][ #  # ]:          0 :                     GetSaveInData()->GetImageManager() );
                 [ #  # ]
    3469                 :            : 
    3470         [ #  # ]:          0 :                 aContentsListBox->GetModel()->Remove( pActEntry );
    3471                 :            : 
    3472                 :            :                 SvLBoxEntry* pNewLBEntry =
    3473         [ #  # ]:          0 :                     InsertEntryIntoUI( pEntry, nSelectionPos );
    3474                 :            : 
    3475                 :            :                 aContentsListBox->SetCheckButtonState( pNewLBEntry,
    3476                 :          0 :                     pEntry->IsVisible() ?
    3477 [ #  # ][ #  # ]:          0 :                         SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
    3478                 :            : 
    3479         [ #  # ]:          0 :                 aContentsListBox->Select( pNewLBEntry );
    3480         [ #  # ]:          0 :                 aContentsListBox->MakeVisible( pNewLBEntry );
    3481                 :            : 
    3482                 :          0 :                 bNeedsApply = sal_True;
    3483                 :            :             }
    3484         [ #  # ]:          0 :                catch ( uno::Exception& )
    3485                 :            :                {
    3486                 :            :                 OSL_TRACE("Error restoring image");
    3487                 :            :                }
    3488         [ #  # ]:          0 :             break;
    3489                 :            :         }
    3490                 :            :         case ID_BEGIN_GROUP:
    3491                 :            :         {
    3492         [ #  # ]:          0 :             SvxConfigEntry* pNewEntryData = new SvxConfigEntry;
    3493                 :          0 :             pNewEntryData->SetUserDefined( sal_True );
    3494                 :            : 
    3495                 :          0 :             SvLBoxEntry* pNewLBEntry = InsertEntry( pNewEntryData );
    3496                 :            : 
    3497                 :            :             aContentsListBox->SetCheckButtonState(
    3498                 :          0 :                 pNewLBEntry, SV_BUTTON_TRISTATE );
    3499                 :            : 
    3500                 :          0 :             bNeedsApply = sal_True;
    3501                 :          0 :             break;
    3502                 :            :         }
    3503                 :            :         case ID_DELETE:
    3504                 :            :         {
    3505                 :          0 :             DeleteSelectedContent();
    3506                 :          0 :             break;
    3507                 :            :         }
    3508                 :            :         case ID_ICON_ONLY:
    3509                 :            :         {
    3510                 :          0 :             break;
    3511                 :            :         }
    3512                 :            :         case ID_TEXT_ONLY:
    3513                 :            :         {
    3514                 :          0 :             break;
    3515                 :            :         }
    3516                 :            :         case ID_ICON_AND_TEXT:
    3517                 :            :         {
    3518                 :          0 :             break;
    3519                 :            :         }
    3520                 :            :         case ID_CHANGE_SYMBOL:
    3521                 :            :         {
    3522                 :          0 :             SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry();
    3523                 :            :             SvxConfigEntry* pEntry =
    3524                 :          0 :                 (SvxConfigEntry*) pActEntry->GetUserData();
    3525                 :            : 
    3526                 :          0 :             sal_uInt16 nSelectionPos = 0;
    3527                 :            : 
    3528                 :            :             // find position of entry within the list
    3529         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < aContentsListBox->GetEntryCount(); ++i )
    3530                 :            :             {
    3531         [ #  # ]:          0 :                 if ( aContentsListBox->GetEntry( 0, i ) == pActEntry )
    3532                 :            :                 {
    3533                 :          0 :                     nSelectionPos = i;
    3534                 :          0 :                     break;
    3535                 :            :                 }
    3536                 :            :             }
    3537                 :            : 
    3538                 :            :             SvxIconSelectorDialog* pIconDialog =
    3539                 :            :                 new SvxIconSelectorDialog( 0,
    3540                 :            :                     GetSaveInData()->GetImageManager(),
    3541 [ #  # ][ #  # ]:          0 :                     GetSaveInData()->GetParentImageManager() );
                 [ #  # ]
    3542                 :            : 
    3543                 :          0 :             bool ret = pIconDialog->Execute();
    3544                 :            : 
    3545         [ #  # ]:          0 :             if ( ret == RET_OK )
    3546                 :            :             {
    3547                 :            :                 uno::Reference< graphic::XGraphic > newgraphic =
    3548         [ #  # ]:          0 :                     pIconDialog->GetSelectedIcon();
    3549                 :            : 
    3550         [ #  # ]:          0 :                 if ( newgraphic.is() )
    3551                 :            :                 {
    3552                 :            :                     uno::Sequence< uno::Reference< graphic::XGraphic > >
    3553         [ #  # ]:          0 :                         aGraphicSeq( 1 );
    3554                 :            : 
    3555         [ #  # ]:          0 :                     uno::Sequence< OUString > aURLSeq( 1 );
    3556         [ #  # ]:          0 :                     aURLSeq[ 0 ] = pEntry->GetCommand();
    3557                 :            : 
    3558 [ #  # ][ #  # ]:          0 :                     if ( !pEntry->GetBackupGraphic().is() )
    3559                 :            :                     {
    3560                 :          0 :                         uno::Reference< graphic::XGraphic > backup;
    3561                 :            :                         backup = GetGraphic(
    3562 [ #  # ][ #  # ]:          0 :                             GetSaveInData()->GetImageManager(), aURLSeq[ 0 ] );
         [ #  # ][ #  # ]
    3563                 :            : 
    3564         [ #  # ]:          0 :                         if ( backup.is() )
    3565                 :            :                         {
    3566         [ #  # ]:          0 :                             pEntry->SetBackupGraphic( backup );
    3567                 :          0 :                         }
    3568                 :            :                     }
    3569                 :            : 
    3570 [ #  # ][ #  # ]:          0 :                     aGraphicSeq[ 0 ] = newgraphic;
    3571                 :            :                     try
    3572                 :            :                     {
    3573 [ #  # ][ #  # ]:          0 :                         GetSaveInData()->GetImageManager()->replaceImages(
    3574         [ #  # ]:          0 :                             GetImageType(), aURLSeq, aGraphicSeq );
    3575                 :            : 
    3576         [ #  # ]:          0 :                         Image aImage( newgraphic );
    3577                 :            : 
    3578         [ #  # ]:          0 :                         aContentsListBox->GetModel()->Remove( pActEntry );
    3579                 :            :                         SvLBoxEntry* pNewLBEntry =
    3580         [ #  # ]:          0 :                             InsertEntryIntoUI( pEntry, nSelectionPos );
    3581                 :            : 
    3582                 :            :                         aContentsListBox->SetCheckButtonState( pNewLBEntry,
    3583                 :          0 :                             pEntry->IsVisible() ?
    3584 [ #  # ][ #  # ]:          0 :                                 SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
    3585                 :            : 
    3586         [ #  # ]:          0 :                         aContentsListBox->Select( pNewLBEntry );
    3587         [ #  # ]:          0 :                         aContentsListBox->MakeVisible( pNewLBEntry );
    3588                 :            : 
    3589                 :            :                         GetSaveInData()->PersistChanges(
    3590 [ #  # ][ #  # ]:          0 :                             GetSaveInData()->GetImageManager() );
         [ #  # ][ #  # ]
    3591                 :            :                     }
    3592         [ #  # ]:          0 :                     catch ( uno::Exception& )
    3593                 :            :                     {
    3594                 :            :                         OSL_TRACE("Error replacing image");
    3595 [ #  # ][ #  # ]:          0 :                     }
    3596                 :          0 :                 }
    3597                 :            :             }
    3598                 :            : 
    3599         [ #  # ]:          0 :             delete pIconDialog;
    3600                 :            : 
    3601                 :          0 :             break;
    3602                 :            :         }
    3603                 :            :         case ID_RESET_SYMBOL:
    3604                 :            :         {
    3605         [ #  # ]:          0 :             SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry();
    3606                 :            :             SvxConfigEntry* pEntry =
    3607                 :          0 :                 (SvxConfigEntry*) pActEntry->GetUserData();
    3608                 :            : 
    3609                 :          0 :             sal_uInt16 nSelectionPos = 0;
    3610                 :            : 
    3611                 :            :             // find position of entry within the list
    3612         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < aContentsListBox->GetEntryCount(); ++i )
    3613                 :            :             {
    3614 [ #  # ][ #  # ]:          0 :                 if ( aContentsListBox->GetEntry( 0, i ) == pActEntry )
    3615                 :            :                 {
    3616                 :          0 :                     nSelectionPos = i;
    3617                 :          0 :                     break;
    3618                 :            :                 }
    3619                 :            :             }
    3620                 :            : 
    3621                 :            :             uno::Reference< graphic::XGraphic > backup =
    3622         [ #  # ]:          0 :                 pEntry->GetBackupGraphic();
    3623                 :            : 
    3624                 :            :             uno::Sequence< uno::Reference< graphic::XGraphic > >
    3625         [ #  # ]:          0 :                 aGraphicSeq( 1 );
    3626 [ #  # ][ #  # ]:          0 :             aGraphicSeq[ 0 ] = backup;
    3627                 :            : 
    3628         [ #  # ]:          0 :             uno::Sequence< OUString > aURLSeq( 1 );
    3629         [ #  # ]:          0 :             aURLSeq[ 0 ] = pEntry->GetCommand();
    3630                 :            : 
    3631                 :            :             try
    3632                 :            :             {
    3633 [ #  # ][ #  # ]:          0 :                 GetSaveInData()->GetImageManager()->replaceImages(
    3634         [ #  # ]:          0 :                     GetImageType(), aURLSeq, aGraphicSeq );
    3635                 :            : 
    3636         [ #  # ]:          0 :                 Image aImage( backup );
    3637         [ #  # ]:          0 :                 aContentsListBox->GetModel()->Remove( pActEntry );
    3638                 :            : 
    3639                 :            :                 SvLBoxEntry* pNewLBEntry =
    3640         [ #  # ]:          0 :                     InsertEntryIntoUI( pEntry, nSelectionPos );
    3641                 :            : 
    3642                 :            :                 aContentsListBox->SetCheckButtonState( pNewLBEntry,
    3643                 :          0 :                     pEntry->IsVisible() ?
    3644 [ #  # ][ #  # ]:          0 :                         SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
    3645                 :            : 
    3646         [ #  # ]:          0 :                 aContentsListBox->Select( pNewLBEntry );
    3647         [ #  # ]:          0 :                 aContentsListBox->MakeVisible( pNewLBEntry );
    3648                 :            : 
    3649                 :            :                 // reset backup in entry
    3650                 :            :                 pEntry->SetBackupGraphic(
    3651         [ #  # ]:          0 :                     uno::Reference< graphic::XGraphic >() );
    3652                 :            : 
    3653                 :            :                 GetSaveInData()->PersistChanges(
    3654 [ #  # ][ #  # ]:          0 :                     GetSaveInData()->GetImageManager() );
         [ #  # ][ #  # ]
    3655                 :            :             }
    3656         [ #  # ]:          0 :             catch ( uno::Exception& )
    3657                 :            :             {
    3658                 :            :                 OSL_TRACE("Error resetting image");
    3659                 :            :             }
    3660 [ #  # ][ #  # ]:          0 :             break;
    3661                 :            :         }
    3662                 :            :     }
    3663                 :            : 
    3664         [ #  # ]:          0 :     if ( bNeedsApply == sal_True )
    3665                 :            :     {
    3666                 :          0 :         (( ToolbarSaveInData* ) GetSaveInData())->ApplyToolbar( pToolbar );
    3667                 :          0 :         UpdateButtonStates();
    3668                 :            :     }
    3669                 :            : 
    3670                 :          0 :     return 1;
    3671                 :            : }
    3672                 :            : 
    3673                 :          0 : void SvxToolbarConfigPage::Init()
    3674                 :            : {
    3675                 :            :     // ensure that the UI is cleared before populating it
    3676                 :          0 :     aTopLevelListBox.Clear();
    3677                 :          0 :     aContentsListBox->Clear();
    3678                 :            : 
    3679                 :          0 :     ReloadTopLevelListBox();
    3680                 :            : 
    3681                 :          0 :     sal_uInt16 nPos = 0;
    3682         [ #  # ]:          0 :     if ( !m_aURLToSelect.isEmpty() )
    3683                 :            :     {
    3684         [ #  # ]:          0 :         for ( sal_uInt16 i = 0 ; i < aTopLevelListBox.GetEntryCount(); ++i )
    3685                 :            :         {
    3686                 :            :             SvxConfigEntry* pData =
    3687                 :          0 :                 (SvxConfigEntry*) aTopLevelListBox.GetEntryData( i );
    3688                 :            : 
    3689         [ #  # ]:          0 :             if ( pData->GetCommand().equals( m_aURLToSelect ) )
    3690                 :            :             {
    3691                 :          0 :                 nPos = i;
    3692                 :          0 :                 break;
    3693                 :            :             }
    3694                 :            :         }
    3695                 :            : 
    3696                 :            :         // in future select the default toolbar: Standard
    3697                 :          0 :         m_aURLToSelect = OUString(ITEM_TOOLBAR_URL );
    3698                 :          0 :         m_aURLToSelect += OUString("standardbar" );
    3699                 :            :     }
    3700                 :            : 
    3701                 :          0 :     aTopLevelListBox.SelectEntryPos(nPos, sal_True);
    3702                 :          0 :     aTopLevelListBox.GetSelectHdl().Call(this);
    3703                 :          0 : }
    3704                 :            : 
    3705                 :          0 : SaveInData* SvxToolbarConfigPage::CreateSaveInData(
    3706                 :            :     const uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
    3707                 :            :     const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
    3708                 :            :     const OUString& aModuleId,
    3709                 :            :     bool bDocConfig )
    3710                 :            : {
    3711                 :            :     return static_cast< SaveInData* >(
    3712         [ #  # ]:          0 :         new ToolbarSaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig ));
    3713                 :            : }
    3714                 :            : 
    3715                 :          0 : ToolbarSaveInData::ToolbarSaveInData(
    3716                 :            :     const uno::Reference < css::ui::XUIConfigurationManager >& xCfgMgr,
    3717                 :            :     const uno::Reference < css::ui::XUIConfigurationManager >& xParentCfgMgr,
    3718                 :            :     const OUString& aModuleId,
    3719                 :            :     bool docConfig ) :
    3720                 :            : 
    3721                 :            :     SaveInData              ( xCfgMgr, xParentCfgMgr, aModuleId, docConfig ),
    3722                 :            :     pRootEntry              ( NULL ),
    3723                 :          0 :     m_aDescriptorContainer  ( ITEM_DESCRIPTOR_CONTAINER  )
    3724                 :            : 
    3725                 :            : {
    3726                 :            :     // Initialize the m_xPersistentWindowState variable which is used
    3727                 :            :     // to get the default properties of system toolbars such as name
    3728                 :            :     uno::Reference< container::XNameAccess > xPWSS(
    3729         [ #  # ]:          0 :         m_xServiceManager->createInstance(
    3730                 :          0 :             OUString( "com.sun.star.ui.WindowStateConfiguration"  ) ),
    3731 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY );
    3732                 :            : 
    3733         [ #  # ]:          0 :     if ( xPWSS.is() )
    3734 [ #  # ][ #  # ]:          0 :         xPWSS->getByName( aModuleId ) >>= m_xPersistentWindowState;
                 [ #  # ]
    3735                 :          0 : }
    3736                 :            : 
    3737                 :          0 : ToolbarSaveInData::~ToolbarSaveInData()
    3738                 :            : {
    3739 [ #  # ][ #  # ]:          0 :     delete pRootEntry;
    3740         [ #  # ]:          0 : }
    3741                 :            : 
    3742                 :          0 : void ToolbarSaveInData::SetSystemStyle(
    3743                 :            :     uno::Reference< frame::XFrame > xFrame,
    3744                 :            :     const OUString& rResourceURL,
    3745                 :            :     sal_Int32 nStyle )
    3746                 :            : {
    3747                 :            :     // change the style using the API
    3748         [ #  # ]:          0 :     SetSystemStyle( rResourceURL, nStyle );
    3749                 :            : 
    3750                 :            :     // this code is a temporary hack as the UI is not updating after
    3751                 :            :     // changing the toolbar style via the API
    3752                 :          0 :     uno::Reference< css::frame::XLayoutManager > xLayoutManager;
    3753                 :          0 :     Window *window = NULL;
    3754                 :            : 
    3755         [ #  # ]:          0 :     uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY );
    3756         [ #  # ]:          0 :     if ( xPropSet.is() )
    3757                 :            :     {
    3758         [ #  # ]:          0 :         uno::Any a = xPropSet->getPropertyValue(
    3759         [ #  # ]:          0 :             OUString( "LayoutManager"  ) );
    3760         [ #  # ]:          0 :         a >>= xLayoutManager;
    3761                 :            :     }
    3762                 :            : 
    3763         [ #  # ]:          0 :     if ( xLayoutManager.is() )
    3764                 :            :     {
    3765                 :            :         uno::Reference< css::ui::XUIElement > xUIElement =
    3766 [ #  # ][ #  # ]:          0 :             xLayoutManager->getElement( rResourceURL );
    3767                 :            : 
    3768                 :            :         // check reference before we call getRealInterface. The layout manager
    3769                 :            :         // can only provide references for elements that have been created
    3770                 :            :         // before. It's possible that the current element is not available.
    3771                 :          0 :         uno::Reference< com::sun::star::awt::XWindow > xWindow;
    3772         [ #  # ]:          0 :         if ( xUIElement.is() )
    3773                 :            :             xWindow = uno::Reference< com::sun::star::awt::XWindow >(
    3774 [ #  # ][ #  # ]:          0 :                         xUIElement->getRealInterface(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
    3775                 :            : 
    3776         [ #  # ]:          0 :         window = VCLUnoHelper::GetWindow( xWindow );
    3777                 :            :     }
    3778                 :            : 
    3779 [ #  # ][ #  # ]:          0 :     if ( window != NULL && window->GetType() == WINDOW_TOOLBOX )
         [ #  # ][ #  # ]
    3780                 :            :     {
    3781                 :          0 :         ToolBox* toolbox = (ToolBox*)window;
    3782                 :            : 
    3783         [ #  # ]:          0 :         if ( nStyle == 0 )
    3784                 :            :         {
    3785         [ #  # ]:          0 :             toolbox->SetButtonType( BUTTON_SYMBOL );
    3786                 :            :         }
    3787         [ #  # ]:          0 :         else if ( nStyle == 1 )
    3788                 :            :         {
    3789         [ #  # ]:          0 :             toolbox->SetButtonType( BUTTON_TEXT );
    3790                 :            :         }
    3791         [ #  # ]:          0 :         if ( nStyle == 2 )
    3792                 :            :         {
    3793         [ #  # ]:          0 :             toolbox->SetButtonType( BUTTON_SYMBOLTEXT );
    3794                 :            :         }
    3795                 :          0 :     }
    3796                 :          0 : }
    3797                 :            : 
    3798                 :          0 : void ToolbarSaveInData::SetSystemStyle(
    3799                 :            :     const OUString& rResourceURL,
    3800                 :            :     sal_Int32 nStyle )
    3801                 :            : {
    3802   [ #  #  #  #  :          0 :     if ( rResourceURL.indexOf( "private" ) == 0 &&
           #  # ][ #  # ]
    3803                 :          0 :          m_xPersistentWindowState.is() &&
    3804                 :          0 :          m_xPersistentWindowState->hasByName( rResourceURL ) )
    3805                 :            :     {
    3806                 :            :         try
    3807                 :            :         {
    3808         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > aProps;
    3809                 :            : 
    3810 [ #  # ][ #  # ]:          0 :             uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
    3811                 :            : 
    3812 [ #  # ][ #  # ]:          0 :             if ( a >>= aProps )
    3813                 :            :             {
    3814         [ #  # ]:          0 :                 for ( sal_Int32 i = 0; i < aProps.getLength(); ++i )
    3815                 :            :                 {
    3816 [ #  # ][ #  # ]:          0 :                     if ( aProps[ i ].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE) )
    3817                 :            :                     {
    3818 [ #  # ][ #  # ]:          0 :                         aProps[ i ].Value = uno::makeAny( nStyle );
    3819                 :          0 :                         break;
    3820                 :            :                     }
    3821                 :            :                 }
    3822                 :            :             }
    3823                 :            : 
    3824                 :            :             uno::Reference< container::XNameReplace >
    3825         [ #  # ]:          0 :                 xNameReplace( m_xPersistentWindowState, uno::UNO_QUERY );
    3826                 :            : 
    3827 [ #  # ][ #  # ]:          0 :             xNameReplace->replaceByName( rResourceURL, uno::makeAny( aProps ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    3828                 :            :         }
    3829                 :          0 :         catch ( uno::Exception& )
    3830                 :            :         {
    3831                 :            :             // do nothing, a default value is returned
    3832                 :            :             OSL_TRACE("Exception setting toolbar style");
    3833                 :            :         }
    3834                 :            :     }
    3835                 :          0 : }
    3836                 :            : 
    3837                 :          0 : sal_Int32 ToolbarSaveInData::GetSystemStyle( const OUString& rResourceURL )
    3838                 :            : {
    3839                 :          0 :     sal_Int32 result = 0;
    3840                 :            : 
    3841   [ #  #  #  # ]:          0 :     if ( rResourceURL.indexOf( "private" ) == 0 &&
         [ #  # ][ #  # ]
    3842                 :          0 :          m_xPersistentWindowState.is() &&
    3843 [ #  # ][ #  # ]:          0 :          m_xPersistentWindowState->hasByName( rResourceURL ) )
    3844                 :            :     {
    3845                 :            :         try
    3846                 :            :         {
    3847         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > aProps;
    3848 [ #  # ][ #  # ]:          0 :             uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
    3849                 :            : 
    3850 [ #  # ][ #  # ]:          0 :             if ( a >>= aProps )
    3851                 :            :             {
    3852         [ #  # ]:          0 :                 for ( sal_Int32 i = 0; i < aProps.getLength(); ++i )
    3853                 :            :                 {
    3854 [ #  # ][ #  # ]:          0 :                     if ( aProps[ i ].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE) )
    3855                 :            :                     {
    3856         [ #  # ]:          0 :                         aProps[i].Value >>= result;
    3857                 :          0 :                         break;
    3858                 :            :                     }
    3859                 :            :                 }
    3860 [ #  # ][ #  # ]:          0 :             }
    3861                 :            :         }
    3862         [ #  # ]:          0 :         catch ( uno::Exception& )
    3863                 :            :         {
    3864                 :            :             // do nothing, a default value is returned
    3865                 :            :         }
    3866                 :            :     }
    3867                 :            : 
    3868                 :          0 :     return result;
    3869                 :            : }
    3870                 :            : 
    3871                 :          0 : OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
    3872                 :            : {
    3873                 :          0 :     OUString result;
    3874                 :            : 
    3875 [ #  # ][ #  # ]:          0 :     if ( rResourceURL.indexOf( "private" ) == 0 &&
           [ #  #  #  # ]
    3876                 :          0 :          m_xPersistentWindowState.is() &&
    3877 [ #  # ][ #  # ]:          0 :          m_xPersistentWindowState->hasByName( rResourceURL ) )
    3878                 :            :     {
    3879                 :            :         try
    3880                 :            :         {
    3881         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > aProps;
    3882 [ #  # ][ #  # ]:          0 :             uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
    3883                 :            : 
    3884 [ #  # ][ #  # ]:          0 :             if ( a >>= aProps )
    3885                 :            :             {
    3886         [ #  # ]:          0 :                 for ( sal_Int32 i = 0; i < aProps.getLength(); ++i )
    3887                 :            :                 {
    3888 [ #  # ][ #  # ]:          0 :                     if ( aProps[ i ].Name.equalsAscii( ITEM_DESCRIPTOR_UINAME) )
    3889                 :            :                     {
    3890         [ #  # ]:          0 :                         aProps[ i ].Value >>= result;
    3891                 :            :                     }
    3892                 :            :                 }
    3893 [ #  # ][ #  # ]:          0 :             }
    3894                 :            :         }
    3895         [ #  # ]:          0 :         catch ( uno::Exception& )
    3896                 :            :         {
    3897                 :            :             // do nothing, an empty UIName will be returned
    3898                 :            :         }
    3899                 :            :     }
    3900                 :            : 
    3901   [ #  #  #  # ]:          0 :     if ( rResourceURL.indexOf( ".uno" ) == 0 &&
         [ #  # ][ #  # ]
    3902                 :          0 :          m_xCommandToLabelMap.is() &&
    3903 [ #  # ][ #  # ]:          0 :          m_xCommandToLabelMap->hasByName( rResourceURL ) )
    3904                 :            :     {
    3905                 :          0 :         uno::Any a;
    3906                 :            :         try
    3907                 :            :         {
    3908 [ #  # ][ #  # ]:          0 :             a = m_xCommandToLabelMap->getByName( rResourceURL );
    3909                 :            : 
    3910         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > aPropSeq;
    3911 [ #  # ][ #  # ]:          0 :             if ( a >>= aPropSeq )
    3912                 :            :             {
    3913         [ #  # ]:          0 :                 for ( sal_Int32 i = 0; i < aPropSeq.getLength(); ++i )
    3914                 :            :                 {
    3915 [ #  # ][ #  # ]:          0 :                     if ( aPropSeq[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ) )
    3916                 :            :                     {
    3917         [ #  # ]:          0 :                         aPropSeq[i].Value >>= result;
    3918                 :            :                     }
    3919                 :            :                 }
    3920 [ #  # ][ #  # ]:          0 :             }
    3921                 :            :         }
    3922         [ #  # ]:          0 :         catch ( uno::Exception& )
    3923                 :            :         {
    3924                 :            :             // not a system command name
    3925                 :          0 :         }
    3926                 :            :     }
    3927                 :            : 
    3928                 :          0 :     return result;
    3929                 :            : }
    3930                 :            : 
    3931                 :          0 : bool EntrySort( SvxConfigEntry* a, SvxConfigEntry* b )
    3932                 :            : {
    3933                 :          0 :     return a->GetName().compareTo( b->GetName() ) < 0;
    3934                 :            : }
    3935                 :            : 
    3936                 :          0 : SvxEntries* ToolbarSaveInData::GetEntries()
    3937                 :            : {
    3938                 :            :     typedef ::boost::unordered_map< ::rtl::OUString,
    3939                 :            :                              bool,
    3940                 :            :                              ::rtl::OUStringHash,
    3941                 :            :                              ::std::equal_to< ::rtl::OUString > > ToolbarInfo;
    3942                 :            : 
    3943         [ #  # ]:          0 :     ToolbarInfo aToolbarInfo;
    3944                 :            : 
    3945         [ #  # ]:          0 :     if ( pRootEntry == NULL )
    3946                 :            :     {
    3947                 :            : 
    3948                 :            :         pRootEntry = new SvxConfigEntry(
    3949                 :            :             rtl::OUString("MainToolbars"),
    3950 [ #  # ][ #  # ]:          0 :             rtl::OUString(), sal_True);
    3951                 :            : 
    3952                 :            :         uno::Sequence< uno::Sequence < beans::PropertyValue > > info =
    3953 [ #  # ][ #  # ]:          0 :             GetConfigManager()->getUIElementsInfo(
    3954         [ #  # ]:          0 :                 css::ui::UIElementType::TOOLBAR );
    3955                 :            : 
    3956         [ #  # ]:          0 :         for ( sal_Int32 i = 0; i < info.getLength(); ++i )
    3957                 :            :         {
    3958 [ #  # ][ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > props = info[ i ];
    3959                 :            : 
    3960                 :          0 :             OUString url;
    3961                 :          0 :             OUString systemname;
    3962                 :          0 :             OUString uiname;
    3963                 :            : 
    3964         [ #  # ]:          0 :             for ( sal_Int32 j = 0; j < props.getLength(); ++j )
    3965                 :            :             {
    3966 [ #  # ][ #  # ]:          0 :                 if ( props[ j ].Name.equalsAscii( ITEM_DESCRIPTOR_RESOURCEURL) )
    3967                 :            :                 {
    3968         [ #  # ]:          0 :                     props[ j ].Value >>= url;
    3969                 :          0 :                     systemname = url.copy( url.lastIndexOf( '/' ) + 1 );
    3970                 :            :                 }
    3971 [ #  # ][ #  # ]:          0 :                 else if ( props[ j ].Name.equalsAscii( ITEM_DESCRIPTOR_UINAME) )
    3972                 :            :                 {
    3973         [ #  # ]:          0 :                     props[ j ].Value >>= uiname;
    3974                 :            :                 }
    3975                 :            :             }
    3976                 :            : 
    3977                 :            :             try
    3978                 :            :             {
    3979                 :            :                 uno::Reference< container::XIndexAccess > xToolbarSettings =
    3980 [ #  # ][ #  # ]:          0 :                     GetConfigManager()->getSettings( url, sal_False );
                 [ #  # ]
    3981                 :            : 
    3982         [ #  # ]:          0 :                 if ( uiname.isEmpty() )
    3983                 :            :                 {
    3984                 :            :                     // try to get the name from m_xPersistentWindowState
    3985         [ #  # ]:          0 :                     uiname = GetSystemUIName( url );
    3986                 :            : 
    3987         [ #  # ]:          0 :                     if ( uiname.isEmpty() )
    3988                 :            :                     {
    3989                 :          0 :                         uiname = systemname;
    3990                 :            :                     }
    3991                 :            :                 }
    3992                 :            : 
    3993                 :            :                 SvxConfigEntry* pEntry = new SvxConfigEntry(
    3994 [ #  # ][ #  # ]:          0 :                     uiname, url, sal_True );
    3995                 :            : 
    3996                 :          0 :                 pEntry->SetMain( sal_True );
    3997         [ #  # ]:          0 :                 pEntry->SetStyle( GetSystemStyle( url ) );
    3998                 :            : 
    3999                 :            : 
    4000                 :            :                 // insert into boost::unordered_map to filter duplicates from the parent
    4001         [ #  # ]:          0 :                 aToolbarInfo.insert( ToolbarInfo::value_type( systemname, true ));
    4002                 :            : 
    4003                 :          0 :                 OUString custom(CUSTOM_TOOLBAR_STR);
    4004         [ #  # ]:          0 :                 if ( systemname.indexOf( custom ) == 0 )
    4005                 :            :                 {
    4006                 :          0 :                     pEntry->SetUserDefined( sal_True );
    4007                 :            :                 }
    4008                 :            :                 else
    4009                 :            :                 {
    4010                 :          0 :                     pEntry->SetUserDefined( sal_False );
    4011                 :            :                 }
    4012                 :            : 
    4013         [ #  # ]:          0 :                 pRootEntry->GetEntries()->push_back( pEntry );
    4014                 :            : 
    4015 [ #  # ][ #  # ]:          0 :                 LoadToolbar( xToolbarSettings, pEntry );
    4016                 :            :             }
    4017         [ #  # ]:          0 :             catch ( container::NoSuchElementException& )
    4018                 :            :             {
    4019                 :            :                 // TODO, handle resourceURL with no settings
    4020                 :            :             }
    4021         [ #  # ]:          0 :         }
    4022                 :            : 
    4023         [ #  # ]:          0 :         uno::Reference< css::ui::XUIConfigurationManager > xParentCfgMgr = GetParentConfigManager();
    4024         [ #  # ]:          0 :         if ( xParentCfgMgr.is() )
    4025                 :            :         {
    4026                 :            :             // Retrieve also the parent toolbars to make it possible
    4027                 :            :             // to configure module toolbars and save them into the document
    4028                 :            :             // config manager.
    4029                 :            :             uno::Sequence< uno::Sequence < beans::PropertyValue > > info_ =
    4030         [ #  # ]:          0 :                 xParentCfgMgr->getUIElementsInfo(
    4031         [ #  # ]:          0 :                     css::ui::UIElementType::TOOLBAR );
    4032                 :            : 
    4033         [ #  # ]:          0 :             for ( sal_Int32 i = 0; i < info_.getLength(); ++i )
    4034                 :            :             {
    4035 [ #  # ][ #  # ]:          0 :                 uno::Sequence< beans::PropertyValue > props = info_[ i ];
    4036                 :            : 
    4037                 :          0 :                 OUString url;
    4038                 :          0 :                 OUString systemname;
    4039                 :          0 :                 OUString uiname;
    4040                 :            : 
    4041         [ #  # ]:          0 :                 for ( sal_Int32 j = 0; j < props.getLength(); ++j )
    4042                 :            :                 {
    4043 [ #  # ][ #  # ]:          0 :                     if ( props[ j ].Name.equalsAscii( ITEM_DESCRIPTOR_RESOURCEURL) )
    4044                 :            :                     {
    4045         [ #  # ]:          0 :                         props[ j ].Value >>= url;
    4046                 :          0 :                         systemname = url.copy( url.lastIndexOf( '/' ) + 1 );
    4047                 :            :                     }
    4048 [ #  # ][ #  # ]:          0 :                     else if ( props[ j ].Name.equalsAscii( ITEM_DESCRIPTOR_UINAME) )
    4049                 :            :                     {
    4050         [ #  # ]:          0 :                         props[ j ].Value >>= uiname;
    4051                 :            :                     }
    4052                 :            :                 }
    4053                 :            : 
    4054                 :            :                 // custom toolbars of the parent are not visible in the document layer
    4055                 :          0 :                 OUString custom(CUSTOM_TOOLBAR_STR);
    4056         [ #  # ]:          0 :                 if ( systemname.indexOf( custom ) == 0 )
    4057                 :          0 :                     continue;
    4058                 :            : 
    4059                 :            :                 // check if toolbar is already in the document layer
    4060         [ #  # ]:          0 :                 ToolbarInfo::const_iterator pIter = aToolbarInfo.find( systemname );
    4061 [ #  # ][ #  # ]:          0 :                 if ( pIter == aToolbarInfo.end() )
    4062                 :            :                 {
    4063         [ #  # ]:          0 :                     aToolbarInfo.insert( ToolbarInfo::value_type( systemname, true ));
    4064                 :            : 
    4065                 :            :                     try
    4066                 :            :                     {
    4067                 :            :                         uno::Reference< container::XIndexAccess > xToolbarSettings =
    4068 [ #  # ][ #  # ]:          0 :                             xParentCfgMgr->getSettings( url, sal_False );
    4069                 :            : 
    4070         [ #  # ]:          0 :                         if ( uiname.isEmpty() )
    4071                 :            :                         {
    4072                 :            :                             // try to get the name from m_xPersistentWindowState
    4073         [ #  # ]:          0 :                             uiname = GetSystemUIName( url );
    4074                 :            : 
    4075         [ #  # ]:          0 :                             if ( uiname.isEmpty() )
    4076                 :            :                             {
    4077                 :          0 :                                 uiname = systemname;
    4078                 :            :                             }
    4079                 :            :                         }
    4080                 :            : 
    4081                 :            :                         SvxConfigEntry* pEntry = new SvxConfigEntry(
    4082 [ #  # ][ #  # ]:          0 :                             uiname, url, sal_True, sal_True );
    4083                 :            : 
    4084                 :          0 :                         pEntry->SetMain( sal_True );
    4085         [ #  # ]:          0 :                         pEntry->SetStyle( GetSystemStyle( url ) );
    4086                 :            : 
    4087         [ #  # ]:          0 :                         if ( systemname.indexOf( custom ) == 0 )
    4088                 :            :                         {
    4089                 :          0 :                             pEntry->SetUserDefined( sal_True );
    4090                 :            :                         }
    4091                 :            :                         else
    4092                 :            :                         {
    4093                 :          0 :                             pEntry->SetUserDefined( sal_False );
    4094                 :            :                         }
    4095                 :            : 
    4096         [ #  # ]:          0 :                         pRootEntry->GetEntries()->push_back( pEntry );
    4097                 :            : 
    4098 [ #  # ][ #  # ]:          0 :                         LoadToolbar( xToolbarSettings, pEntry );
    4099                 :            :                     }
    4100         [ #  # ]:          0 :                     catch ( container::NoSuchElementException& )
    4101                 :            :                     {
    4102                 :            :                         // TODO, handle resourceURL with no settings
    4103                 :            :                     }
    4104                 :            :                 }
    4105 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    4106                 :            :         }
    4107                 :            : 
    4108 [ #  # ][ #  # ]:          0 :         std::sort( GetEntries()->begin(), GetEntries()->end(), EntrySort );
         [ #  # ][ #  # ]
    4109                 :            :     }
    4110                 :            : 
    4111         [ #  # ]:          0 :     return pRootEntry->GetEntries();
    4112                 :            : }
    4113                 :            : 
    4114                 :            : void
    4115                 :          0 : ToolbarSaveInData::SetEntries( SvxEntries* pNewEntries )
    4116                 :            : {
    4117                 :            :     // delete old menu hierarchy first
    4118 [ #  # ][ #  # ]:          0 :     if ( pRootEntry != NULL && pRootEntry->GetEntries() != NULL )
                 [ #  # ]
    4119                 :            :     {
    4120         [ #  # ]:          0 :         delete pRootEntry->GetEntries();
    4121                 :            :     }
    4122                 :            : 
    4123                 :            :     // now set new menu hierarchy
    4124                 :          0 :     pRootEntry->SetEntries( pNewEntries );
    4125                 :          0 : }
    4126                 :            : 
    4127                 :            : bool
    4128                 :          0 : ToolbarSaveInData::HasURL( const OUString& rURL )
    4129                 :            : {
    4130 [ #  # ][ #  # ]:          0 :     SvxEntries::const_iterator iter = GetEntries()->begin();
    4131 [ #  # ][ #  # ]:          0 :     SvxEntries::const_iterator end = GetEntries()->end();
    4132                 :            : 
    4133 [ #  # ][ #  # ]:          0 :     while ( iter != end )
    4134                 :            :     {
    4135                 :          0 :         SvxConfigEntry* pEntry = *iter;
    4136                 :            : 
    4137         [ #  # ]:          0 :         if ( pEntry->GetCommand().equals( rURL ) )
    4138                 :            :         {
    4139         [ #  # ]:          0 :             if ( pEntry->IsParentData() )
    4140                 :          0 :                 return sal_False;
    4141                 :            :             else
    4142                 :          0 :                 return sal_True;
    4143                 :            :         }
    4144                 :            : 
    4145                 :          0 :         ++iter;
    4146                 :            :     }
    4147                 :          0 :     return sal_False;
    4148                 :            : }
    4149                 :            : 
    4150                 :          0 : bool ToolbarSaveInData::HasSettings()
    4151                 :            : {
    4152                 :            :     // return true if there is at least one toolbar entry
    4153         [ #  # ]:          0 :     if ( GetEntries()->size() > 0 )
    4154                 :            :     {
    4155                 :          0 :         return sal_True;
    4156                 :            :     }
    4157                 :          0 :     return sal_False;
    4158                 :            : }
    4159                 :            : 
    4160                 :          0 : void ToolbarSaveInData::Reset()
    4161                 :            : {
    4162 [ #  # ][ #  # ]:          0 :     SvxEntries::const_iterator toolbars = GetEntries()->begin();
    4163 [ #  # ][ #  # ]:          0 :     SvxEntries::const_iterator end = GetEntries()->end();
    4164                 :            : 
    4165                 :            :     // reset each toolbar by calling removeSettings for it's toolbar URL
    4166 [ #  # ][ #  # ]:          0 :     for ( ; toolbars != end; ++toolbars )
    4167                 :            :     {
    4168                 :          0 :         SvxConfigEntry* pToolbar = *toolbars;
    4169                 :            : 
    4170                 :            :         try
    4171                 :            :         {
    4172                 :          0 :             OUString url = pToolbar->GetCommand();
    4173 [ #  # ][ #  # ]:          0 :             GetConfigManager()->removeSettings( url );
         [ #  # ][ #  # ]
    4174                 :            :         }
    4175         [ #  # ]:          0 :         catch ( uno::Exception& )
    4176                 :            :         {
    4177                 :            :             // error occurred removing the settings
    4178                 :            :             // TODO - add error dialog in future?
    4179                 :            :         }
    4180                 :            :     }
    4181                 :            : 
    4182                 :            :     // persist changes to toolbar storage
    4183 [ #  # ][ #  # ]:          0 :     PersistChanges( GetConfigManager() );
    4184                 :            : 
    4185                 :            :     // now delete the root SvxConfigEntry the next call to GetEntries()
    4186                 :            :     // causes it to be reinitialised
    4187 [ #  # ][ #  # ]:          0 :     delete pRootEntry;
    4188                 :          0 :     pRootEntry = NULL;
    4189                 :            : 
    4190                 :            :     // reset all icons to default
    4191                 :            :     try
    4192                 :            :     {
    4193 [ #  # ][ #  # ]:          0 :         GetImageManager()->reset();
                 [ #  # ]
    4194 [ #  # ][ #  # ]:          0 :         PersistChanges( GetImageManager() );
                 [ #  # ]
    4195                 :            :     }
    4196         [ #  # ]:          0 :     catch ( uno::Exception& )
    4197                 :            :     {
    4198                 :            :         OSL_TRACE("Error resetting all icons when resetting toolbars");
    4199                 :            :     }
    4200                 :          0 : }
    4201                 :            : 
    4202                 :          0 : bool ToolbarSaveInData::Apply()
    4203                 :            : {
    4204                 :            :     // toolbar changes are instantly applied
    4205                 :          0 :     return sal_False;
    4206                 :            : }
    4207                 :            : 
    4208                 :          0 : void ToolbarSaveInData::ApplyToolbar(
    4209                 :            :     uno::Reference< container::XIndexContainer >& rToolbarBar,
    4210                 :            :     uno::Reference< lang::XSingleComponentFactory >& rFactory,
    4211                 :            :     SvxConfigEntry* pToolbarData )
    4212                 :            : {
    4213         [ #  # ]:          0 :     SvxEntries::const_iterator iter = pToolbarData->GetEntries()->begin();
    4214         [ #  # ]:          0 :     SvxEntries::const_iterator end = pToolbarData->GetEntries()->end();
    4215                 :            : 
    4216 [ #  # ][ #  # ]:          0 :     for ( ; iter != end; ++iter )
    4217                 :            :     {
    4218                 :          0 :         SvxConfigEntry* pEntry = *iter;
    4219                 :            : 
    4220         [ #  # ]:          0 :         if ( pEntry->IsPopup() )
    4221                 :            :         {
    4222                 :            :             uno::Sequence< beans::PropertyValue > aPropValueSeq =
    4223         [ #  # ]:          0 :                 ConvertToolbarEntry( m_xCommandToLabelMap, pEntry );
    4224                 :            : 
    4225                 :            :             uno::Reference< container::XIndexContainer > xSubMenuBar(
    4226         [ #  # ]:          0 :                 rFactory->createInstanceWithContext( m_xComponentContext ),
    4227 [ #  # ][ #  # ]:          0 :                     uno::UNO_QUERY );
    4228                 :            : 
    4229                 :          0 :             sal_Int32 nIndex = aPropValueSeq.getLength();
    4230         [ #  # ]:          0 :             aPropValueSeq.realloc( nIndex + 1 );
    4231         [ #  # ]:          0 :             aPropValueSeq[nIndex].Name = m_aDescriptorContainer;
    4232 [ #  # ][ #  # ]:          0 :             aPropValueSeq[nIndex].Value <<= xSubMenuBar;
    4233         [ #  # ]:          0 :             rToolbarBar->insertByIndex(
    4234 [ #  # ][ #  # ]:          0 :                 rToolbarBar->getCount(), uno::makeAny( aPropValueSeq ));
         [ #  # ][ #  # ]
    4235                 :            : 
    4236 [ #  # ][ #  # ]:          0 :             ApplyToolbar( xSubMenuBar, rFactory, pEntry );
    4237                 :            :         }
    4238         [ #  # ]:          0 :         else if ( pEntry->IsSeparator() )
    4239                 :            :         {
    4240         [ #  # ]:          0 :             rToolbarBar->insertByIndex(
    4241 [ #  # ][ #  # ]:          0 :                 rToolbarBar->getCount(), uno::makeAny( m_aSeparatorSeq ));
         [ #  # ][ #  # ]
    4242                 :            :         }
    4243                 :            :         else
    4244                 :            :         {
    4245                 :            :             uno::Sequence< beans::PropertyValue > aPropValueSeq =
    4246         [ #  # ]:          0 :                 ConvertToolbarEntry( m_xCommandToLabelMap, pEntry );
    4247                 :            : 
    4248         [ #  # ]:          0 :             rToolbarBar->insertByIndex(
    4249 [ #  # ][ #  # ]:          0 :                 rToolbarBar->getCount(), uno::makeAny( aPropValueSeq ));
         [ #  # ][ #  # ]
                 [ #  # ]
    4250                 :            :         }
    4251                 :            :     }
    4252                 :          0 : }
    4253                 :            : 
    4254                 :          0 : void ToolbarSaveInData::ApplyToolbar( SvxConfigEntry* pToolbar )
    4255                 :            : {
    4256                 :            :     // Apply new toolbar structure to our settings container
    4257                 :            :     uno::Reference< container::XIndexAccess > xSettings(
    4258 [ #  # ][ #  # ]:          0 :         GetConfigManager()->createSettings(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
    4259                 :            : 
    4260                 :            :     uno::Reference< container::XIndexContainer > xIndexContainer (
    4261         [ #  # ]:          0 :         xSettings, uno::UNO_QUERY );
    4262                 :            : 
    4263                 :            :     uno::Reference< lang::XSingleComponentFactory > xFactory (
    4264         [ #  # ]:          0 :         xSettings, uno::UNO_QUERY );
    4265                 :            : 
    4266         [ #  # ]:          0 :     ApplyToolbar( xIndexContainer, xFactory, pToolbar );
    4267                 :            : 
    4268                 :            :     uno::Reference< beans::XPropertySet > xProps(
    4269         [ #  # ]:          0 :         xSettings, uno::UNO_QUERY );
    4270                 :            : 
    4271         [ #  # ]:          0 :     if ( pToolbar->IsUserDefined() )
    4272                 :            :     {
    4273         [ #  # ]:          0 :         xProps->setPropertyValue(
    4274                 :            :             OUString(ITEM_DESCRIPTOR_UINAME ),
    4275 [ #  # ][ #  # ]:          0 :             uno::makeAny( OUString( pToolbar->GetName() ) ) );
    4276                 :            :     }
    4277                 :            : 
    4278                 :            :     try
    4279                 :            :     {
    4280 [ #  # ][ #  # ]:          0 :         if ( GetConfigManager()->hasSettings( pToolbar->GetCommand() ) )
         [ #  # ][ #  # ]
    4281                 :            :         {
    4282 [ #  # ][ #  # ]:          0 :             GetConfigManager()->replaceSettings(
    4283         [ #  # ]:          0 :                 pToolbar->GetCommand(), xSettings );
    4284                 :            :         }
    4285                 :            :         else
    4286                 :            :         {
    4287 [ #  # ][ #  # ]:          0 :             GetConfigManager()->insertSettings(
           [ #  #  #  # ]
    4288         [ #  # ]:          0 :                 pToolbar->GetCommand(), xSettings );
    4289         [ #  # ]:          0 :             if ( pToolbar->IsParentData() )
    4290                 :          0 :                 pToolbar->SetParentData( false );
    4291                 :            :         }
    4292                 :            :     }
    4293         [ #  # ]:          0 :     catch ( container::NoSuchElementException& )
    4294                 :            :     {
    4295                 :            :         OSL_TRACE("caught container::NoSuchElementException saving settings");
    4296                 :            :     }
    4297         [ #  # ]:          0 :     catch ( com::sun::star::io::IOException& )
    4298                 :            :     {
    4299                 :            :         OSL_TRACE("caught IOException saving settings");
    4300                 :            :     }
    4301         [ #  # ]:          0 :     catch ( com::sun::star::uno::Exception& )
    4302                 :            :     {
    4303                 :            :         OSL_TRACE("caught some other exception saving settings");
    4304                 :            :     }
    4305                 :            : 
    4306 [ #  # ][ #  # ]:          0 :     PersistChanges( GetConfigManager() );
    4307                 :          0 : }
    4308                 :            : 
    4309                 :          0 : void ToolbarSaveInData::CreateToolbar( SvxConfigEntry* pToolbar )
    4310                 :            : {
    4311                 :            :     // show the new toolbar in the UI also
    4312                 :            :     uno::Reference< container::XIndexAccess >
    4313 [ #  # ][ #  # ]:          0 :         xSettings( GetConfigManager()->createSettings(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
    4314                 :            : 
    4315                 :            :     uno::Reference< container::XIndexContainer >
    4316         [ #  # ]:          0 :         xIndexContainer ( xSettings, uno::UNO_QUERY );
    4317                 :            : 
    4318                 :            :     uno::Reference< beans::XPropertySet >
    4319         [ #  # ]:          0 :         xPropertySet( xSettings, uno::UNO_QUERY );
    4320                 :            : 
    4321         [ #  # ]:          0 :     xPropertySet->setPropertyValue(
    4322                 :            :         OUString(ITEM_DESCRIPTOR_UINAME ),
    4323 [ #  # ][ #  # ]:          0 :             uno::makeAny( pToolbar->GetName() ) );
    4324                 :            : 
    4325                 :            :     try
    4326                 :            :     {
    4327 [ #  # ][ #  # ]:          0 :         GetConfigManager()->insertSettings( pToolbar->GetCommand(), xSettings );
           [ #  #  #  #  
              # ][ #  # ]
    4328                 :            :     }
    4329         [ #  # ]:          0 :     catch ( container::ElementExistException& )
    4330                 :            :     {
    4331                 :            :         OSL_TRACE("caught ElementExistsException saving settings");
    4332                 :            :     }
    4333         [ #  # ]:          0 :     catch ( com::sun::star::lang::IllegalArgumentException& )
    4334                 :            :     {
    4335                 :            :         OSL_TRACE("caught IOException saving settings");
    4336                 :            :     }
    4337         [ #  # ]:          0 :     catch ( com::sun::star::lang::IllegalAccessException& )
    4338                 :            :     {
    4339                 :            :         OSL_TRACE("caught IOException saving settings");
    4340                 :            :     }
    4341         [ #  # ]:          0 :     catch ( com::sun::star::uno::Exception& )
    4342                 :            :     {
    4343                 :            :         OSL_TRACE("caught some other exception saving settings");
    4344                 :            :     }
    4345                 :            : 
    4346 [ #  # ][ #  # ]:          0 :     GetEntries()->push_back( pToolbar );
    4347                 :            : 
    4348 [ #  # ][ #  # ]:          0 :     PersistChanges( GetConfigManager() );
    4349                 :          0 : }
    4350                 :            : 
    4351                 :          0 : void ToolbarSaveInData::RemoveToolbar( SvxConfigEntry* pToolbar )
    4352                 :            : {
    4353                 :            :     try
    4354                 :            :     {
    4355                 :          0 :         OUString url = pToolbar->GetCommand();
    4356 [ #  # ][ #  # ]:          0 :         GetConfigManager()->removeSettings( url );
                 [ #  # ]
    4357 [ #  # ][ #  # ]:          0 :         RemoveEntry( GetEntries(), pToolbar );
    4358 [ #  # ][ #  # ]:          0 :         delete pToolbar;
    4359                 :            : 
    4360 [ #  # ][ #  # ]:          0 :         PersistChanges( GetConfigManager() );
    4361                 :            : 
    4362                 :            :         // remove the persistent window state data
    4363                 :            :         css::uno::Reference< css::container::XNameContainer > xNameContainer(
    4364         [ #  # ]:          0 :             m_xPersistentWindowState, css::uno::UNO_QUERY_THROW );
    4365                 :            : 
    4366 [ #  # ][ #  # ]:          0 :         xNameContainer->removeByName( url );
                 [ #  # ]
    4367                 :            :     }
    4368                 :          0 :     catch ( uno::Exception& )
    4369                 :            :     {
    4370                 :            :         // error occurred removing the settings
    4371                 :            :     }
    4372                 :          0 : }
    4373                 :            : 
    4374                 :          0 : void ToolbarSaveInData::RestoreToolbar( SvxConfigEntry* pToolbar )
    4375                 :            : {
    4376                 :          0 :     OUString url = pToolbar->GetCommand();
    4377                 :            : 
    4378                 :            :     // Restore of toolbar is done by removing it from
    4379                 :            :     // it's configuration manager and then getting it again
    4380                 :          0 :     bool bParentToolbar = pToolbar->IsParentData();
    4381                 :            : 
    4382                 :            :     // Cannot restore parent toolbar
    4383         [ #  # ]:          0 :     if ( bParentToolbar )
    4384                 :            :         return;
    4385                 :            : 
    4386                 :            :     try
    4387                 :            :     {
    4388 [ #  # ][ #  # ]:          0 :         GetConfigManager()->removeSettings( url );
                 [ #  # ]
    4389                 :          0 :         pToolbar->GetEntries()->clear();
    4390 [ #  # ][ #  # ]:          0 :         PersistChanges( GetConfigManager() );
                 [ #  # ]
    4391                 :            :     }
    4392         [ #  # ]:          0 :     catch ( uno::Exception& )
    4393                 :            :     {
    4394                 :            :         // if an error occurs removing the settings then just return
    4395                 :            :         return;
    4396                 :            :     }
    4397                 :            : 
    4398                 :            :     // Now reload the toolbar settings
    4399                 :            :     try
    4400                 :            :     {
    4401                 :          0 :         uno::Reference< container::XIndexAccess > xToolbarSettings;
    4402         [ #  # ]:          0 :         if ( IsDocConfig() )
    4403                 :            :         {
    4404 [ #  # ][ #  # ]:          0 :             xToolbarSettings = GetParentConfigManager()->getSettings( url, sal_False );
         [ #  # ][ #  # ]
    4405                 :          0 :             pToolbar->SetParentData( true );
    4406                 :            :         }
    4407                 :            :         else
    4408 [ #  # ][ #  # ]:          0 :             xToolbarSettings = GetConfigManager()->getSettings( url, sal_False );
         [ #  # ][ #  # ]
    4409                 :            : 
    4410         [ #  # ]:          0 :         LoadToolbar( xToolbarSettings, pToolbar );
    4411                 :            : 
    4412                 :            :         // After reloading, ensure that the icon is reset of each entry
    4413                 :            :         // in the toolbar
    4414         [ #  # ]:          0 :         SvxEntries::const_iterator iter = pToolbar->GetEntries()->begin();
    4415         [ #  # ]:          0 :         uno::Sequence< OUString > aURLSeq( 1 );
    4416 [ #  # ][ #  # ]:          0 :         for ( ; iter != pToolbar->GetEntries()->end(); ++iter )
    4417                 :            :         {
    4418                 :          0 :             SvxConfigEntry* pEntry = *iter;
    4419         [ #  # ]:          0 :             aURLSeq[ 0 ] = pEntry->GetCommand();
    4420                 :            : 
    4421                 :            :             try
    4422                 :            :             {
    4423 [ #  # ][ #  # ]:          0 :                 GetImageManager()->removeImages( GetImageType(), aURLSeq );
         [ #  # ][ #  # ]
    4424                 :            :             }
    4425         [ #  # ]:          0 :                catch ( uno::Exception& )
    4426                 :            :                {
    4427                 :            :                 OSL_TRACE("Error restoring icon when resetting toolbar");
    4428                 :            :                }
    4429                 :            :         }
    4430 [ #  # ][ #  # ]:          0 :         PersistChanges( GetImageManager() );
         [ #  # ][ #  # ]
    4431                 :            :     }
    4432         [ #  # ]:          0 :     catch ( container::NoSuchElementException& )
    4433                 :            :     {
    4434                 :            :         // cannot find the resource URL after removing it
    4435                 :            :         // so no entry will appear in the toolbar list
    4436         [ #  # ]:          0 :     }
    4437                 :            : }
    4438                 :            : 
    4439                 :          0 : bool ToolbarSaveInData::LoadToolbar(
    4440                 :            :     const uno::Reference< container::XIndexAccess >& xToolbarSettings,
    4441                 :            :     SvxConfigEntry* pParentData )
    4442                 :            : {
    4443                 :          0 :     SvxEntries*         pEntries            = pParentData->GetEntries();
    4444                 :            : 
    4445         [ #  # ]:          0 :     for ( sal_Int32 nIndex = 0; nIndex < xToolbarSettings->getCount(); ++nIndex )
    4446                 :            :     {
    4447                 :          0 :         uno::Reference< container::XIndexAccess >   xSubMenu;
    4448                 :          0 :         OUString                aCommandURL;
    4449                 :          0 :         OUString                aLabel;
    4450                 :          0 :         bool                    bIsUserDefined = sal_True;
    4451                 :            :         sal_Bool                bIsVisible;
    4452                 :            :         sal_Int32               nStyle;
    4453                 :            : 
    4454                 :          0 :         sal_uInt16 nType( css::ui::ItemType::DEFAULT );
    4455                 :            : 
    4456                 :            :         bool bItem = GetToolbarItemData( xToolbarSettings, nIndex, aCommandURL,
    4457         [ #  # ]:          0 :             aLabel, nType, bIsVisible, nStyle, xSubMenu );
    4458                 :            : 
    4459         [ #  # ]:          0 :         if ( bItem )
    4460                 :            :         {
    4461         [ #  # ]:          0 :             if ( nType == css::ui::ItemType::DEFAULT )
    4462                 :            :             {
    4463                 :          0 :                 uno::Any a;
    4464                 :            :                 try
    4465                 :            :                 {
    4466 [ #  # ][ #  # ]:          0 :                     a = m_xCommandToLabelMap->getByName( aCommandURL );
    4467                 :          0 :                     bIsUserDefined = sal_False;
    4468                 :            :                 }
    4469         [ #  # ]:          0 :                 catch ( container::NoSuchElementException& )
    4470                 :            :                 {
    4471                 :          0 :                     bIsUserDefined = sal_True;
    4472                 :            :                 }
    4473                 :            : 
    4474                 :            :                 // If custom label not set retrieve it from the command
    4475                 :            :                 // to info service
    4476         [ #  # ]:          0 :                 if ( aLabel.equals( OUString() ) )
    4477                 :            :                 {
    4478         [ #  # ]:          0 :                     uno::Sequence< beans::PropertyValue > aPropSeq;
    4479 [ #  # ][ #  # ]:          0 :                     if ( a >>= aPropSeq )
    4480                 :            :                     {
    4481         [ #  # ]:          0 :                         for ( sal_Int32 i = 0; i < aPropSeq.getLength(); ++i )
    4482                 :            :                         {
    4483 [ #  # ][ #  # ]:          0 :                             if ( aPropSeq[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ) )
    4484                 :            :                             {
    4485         [ #  # ]:          0 :                                 aPropSeq[i].Value >>= aLabel;
    4486                 :          0 :                                 break;
    4487                 :            :                             }
    4488                 :            :                         }
    4489         [ #  # ]:          0 :                     }
    4490                 :            :                 }
    4491                 :            : 
    4492         [ #  # ]:          0 :                 if ( xSubMenu.is() )
    4493                 :            :                 {
    4494                 :            :                     SvxConfigEntry* pEntry = new SvxConfigEntry(
    4495 [ #  # ][ #  # ]:          0 :                         aLabel, aCommandURL, sal_True );
    4496                 :            : 
    4497                 :          0 :                     pEntry->SetUserDefined( bIsUserDefined );
    4498                 :          0 :                     pEntry->SetVisible( bIsVisible );
    4499                 :            : 
    4500         [ #  # ]:          0 :                     pEntries->push_back( pEntry );
    4501                 :            : 
    4502         [ #  # ]:          0 :                     LoadToolbar( xSubMenu, pEntry );
    4503                 :            :                 }
    4504                 :            :                 else
    4505                 :            :                 {
    4506                 :            :                     SvxConfigEntry* pEntry = new SvxConfigEntry(
    4507 [ #  # ][ #  # ]:          0 :                         aLabel, aCommandURL, sal_False );
    4508                 :          0 :                     pEntry->SetUserDefined( bIsUserDefined );
    4509                 :          0 :                     pEntry->SetVisible( bIsVisible );
    4510                 :          0 :                     pEntry->SetStyle( nStyle );
    4511         [ #  # ]:          0 :                     pEntries->push_back( pEntry );
    4512                 :          0 :                 }
    4513                 :            :             }
    4514                 :            :             else
    4515                 :            :             {
    4516 [ #  # ][ #  # ]:          0 :                 SvxConfigEntry* pEntry = new SvxConfigEntry;
    4517                 :          0 :                 pEntry->SetUserDefined( bIsUserDefined );
    4518         [ #  # ]:          0 :                 pEntries->push_back( pEntry );
    4519                 :            :             }
    4520                 :            :         }
    4521                 :          0 :     }
    4522                 :            : 
    4523         [ #  # ]:          0 :     return true;
    4524                 :            : }
    4525                 :            : 
    4526                 :          0 : IMPL_LINK( SvxToolbarConfigPage, SelectToolbarEntry, Control *, pBox )
    4527                 :            : {
    4528                 :            :     (void)pBox;
    4529                 :          0 :     UpdateButtonStates();
    4530                 :          0 :     return 1;
    4531                 :            : }
    4532                 :            : 
    4533                 :          0 : void SvxToolbarConfigPage::UpdateButtonStates()
    4534                 :            : {
    4535                 :          0 :     PopupMenu* pPopup = aModifyCommandButton.GetPopupMenu();
    4536                 :          0 :     pPopup->EnableItem( ID_RENAME, sal_False );
    4537                 :          0 :     pPopup->EnableItem( ID_DELETE, sal_False );
    4538                 :          0 :     pPopup->EnableItem( ID_BEGIN_GROUP, sal_False );
    4539                 :          0 :     pPopup->EnableItem( ID_DEFAULT_COMMAND, sal_False );
    4540                 :          0 :     pPopup->EnableItem( ID_ICON_ONLY, sal_False );
    4541                 :          0 :     pPopup->EnableItem( ID_ICON_AND_TEXT, sal_False );
    4542                 :          0 :     pPopup->EnableItem( ID_TEXT_ONLY, sal_False );
    4543                 :          0 :     pPopup->EnableItem( ID_CHANGE_SYMBOL, sal_False );
    4544                 :          0 :     pPopup->EnableItem( ID_RESET_SYMBOL, sal_False );
    4545                 :            : 
    4546                 :          0 :     aDescriptionField.Clear();
    4547                 :            : 
    4548                 :          0 :     SvLBoxEntry* selection = aContentsListBox->GetCurEntry();
    4549 [ #  # ][ #  # ]:          0 :     if ( aContentsListBox->GetEntryCount() == 0 || selection == NULL )
                 [ #  # ]
    4550                 :            :     {
    4551                 :          0 :         return;
    4552                 :            :     }
    4553                 :            : 
    4554                 :          0 :     SvxConfigEntry* pEntryData = (SvxConfigEntry*) selection->GetUserData();
    4555         [ #  # ]:          0 :     if ( pEntryData->IsSeparator() )
    4556                 :          0 :         pPopup->EnableItem( ID_DELETE, sal_True );
    4557                 :            :     else
    4558                 :            :     {
    4559                 :          0 :         pPopup->EnableItem( ID_BEGIN_GROUP, sal_True );
    4560                 :          0 :         pPopup->EnableItem( ID_DELETE, sal_True );
    4561                 :          0 :         pPopup->EnableItem( ID_RENAME, sal_True );
    4562                 :          0 :         pPopup->EnableItem( ID_ICON_ONLY, sal_True );
    4563                 :          0 :         pPopup->EnableItem( ID_ICON_AND_TEXT, sal_True );
    4564                 :          0 :         pPopup->EnableItem( ID_TEXT_ONLY, sal_True );
    4565                 :          0 :         pPopup->EnableItem( ID_CHANGE_SYMBOL, sal_True );
    4566                 :            : 
    4567         [ #  # ]:          0 :         if ( !pEntryData->IsUserDefined() )
    4568                 :          0 :             pPopup->EnableItem( ID_DEFAULT_COMMAND, sal_True );
    4569                 :            : 
    4570         [ #  # ]:          0 :         if ( pEntryData->IsIconModified() )
    4571                 :          0 :             pPopup->EnableItem( ID_RESET_SYMBOL, sal_True );
    4572                 :            : 
    4573         [ #  # ]:          0 :         aDescriptionField.SetNewText( pEntryData->GetHelpText() );
    4574                 :            :     }
    4575                 :            : }
    4576                 :            : 
    4577                 :          0 : short SvxToolbarConfigPage::QueryReset()
    4578                 :            : {
    4579                 :            :     String msg =
    4580 [ #  # ][ #  # ]:          0 :         String( CUI_RES( RID_SVXSTR_CONFIRM_TOOLBAR_RESET ) );
    4581                 :            : 
    4582                 :            :     String saveInName = aSaveInListBox.GetEntry(
    4583 [ #  # ][ #  # ]:          0 :         aSaveInListBox.GetSelectEntryPos() );
    4584                 :            : 
    4585 [ #  # ][ #  # ]:          0 :     OUString label = replaceSaveInName( msg, saveInName );
                 [ #  # ]
    4586                 :            : 
    4587 [ #  # ][ #  # ]:          0 :     QueryBox qbox( this, WB_YES_NO, label );
                 [ #  # ]
    4588                 :            : 
    4589 [ #  # ][ #  # ]:          0 :     return qbox.Execute();
         [ #  # ][ #  # ]
    4590                 :            : }
    4591                 :            : 
    4592                 :          0 : IMPL_LINK( SvxToolbarConfigPage, SelectToolbar, ListBox *, pBox )
    4593                 :            : {
    4594                 :            :     (void)pBox;
    4595                 :            : 
    4596         [ #  # ]:          0 :     aContentsListBox->Clear();
    4597                 :            : 
    4598         [ #  # ]:          0 :     SvxConfigEntry* pToolbar = GetTopLevelSelection();
    4599         [ #  # ]:          0 :     if ( pToolbar == NULL )
    4600                 :            :     {
    4601         [ #  # ]:          0 :         aModifyTopLevelButton.Enable( sal_False );
    4602         [ #  # ]:          0 :         aModifyCommandButton.Enable( sal_False );
    4603         [ #  # ]:          0 :         aAddCommandsButton.Enable( sal_False );
    4604                 :            : 
    4605                 :          0 :         return 0;
    4606                 :            :     }
    4607                 :            : 
    4608         [ #  # ]:          0 :     aModifyTopLevelButton.Enable( sal_True );
    4609         [ #  # ]:          0 :     aModifyCommandButton.Enable( sal_True );
    4610         [ #  # ]:          0 :     aAddCommandsButton.Enable( sal_True );
    4611                 :            : 
    4612                 :          0 :     PopupMenu* pPopup = aModifyTopLevelButton.GetPopupMenu();
    4613                 :            : 
    4614         [ #  # ]:          0 :     pPopup->EnableItem( ID_DELETE, pToolbar->IsDeletable() );
    4615         [ #  # ]:          0 :     pPopup->EnableItem( ID_RENAME, pToolbar->IsRenamable() );
    4616         [ #  # ]:          0 :     pPopup->EnableItem( ID_DEFAULT_STYLE, !pToolbar->IsRenamable() );
    4617                 :            : 
    4618   [ #  #  #  # ]:          0 :     switch( pToolbar->GetStyle() )
    4619                 :            :     {
    4620                 :            :         case 0:
    4621                 :            :         {
    4622         [ #  # ]:          0 :             pPopup->CheckItem( ID_ICONS_ONLY );
    4623                 :          0 :             break;
    4624                 :            :         }
    4625                 :            :         case 1:
    4626                 :            :         {
    4627         [ #  # ]:          0 :             pPopup->CheckItem( ID_TEXT_ONLY );
    4628                 :          0 :             break;
    4629                 :            :         }
    4630                 :            :         case 2:
    4631                 :            :         {
    4632         [ #  # ]:          0 :             pPopup->CheckItem( ID_ICONS_AND_TEXT );
    4633                 :          0 :             break;
    4634                 :            :         }
    4635                 :            :     }
    4636                 :            : 
    4637                 :          0 :     SvxEntries* pEntries = pToolbar->GetEntries();
    4638         [ #  # ]:          0 :     SvxEntries::const_iterator iter = pEntries->begin();
    4639                 :            : 
    4640 [ #  # ][ #  # ]:          0 :     for ( ; iter != pEntries->end(); ++iter )
    4641                 :            :     {
    4642                 :          0 :         SvxConfigEntry* pEntry = *iter;
    4643                 :            : 
    4644         [ #  # ]:          0 :         SvLBoxEntry* pNewLBEntry = InsertEntryIntoUI( pEntry );
    4645                 :            : 
    4646         [ #  # ]:          0 :         if (pEntry->IsBinding())
    4647                 :            :         {
    4648                 :            :             aContentsListBox->SetCheckButtonState( pNewLBEntry,
    4649 [ #  # ][ #  # ]:          0 :                 pEntry->IsVisible() ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
    4650                 :            :         }
    4651                 :            :         else
    4652                 :            :         {
    4653                 :            :             aContentsListBox->SetCheckButtonState(
    4654         [ #  # ]:          0 :                 pNewLBEntry, SV_BUTTON_TRISTATE );
    4655                 :            :         }
    4656                 :            :     }
    4657                 :            : 
    4658         [ #  # ]:          0 :     UpdateButtonStates();
    4659                 :            : 
    4660                 :          0 :     return 0;
    4661                 :            : }
    4662                 :            : 
    4663                 :          0 : IMPL_LINK( SvxToolbarConfigPage, NewToolbarHdl, Button *, pButton )
    4664                 :            : {
    4665                 :            :     (void)pButton;
    4666                 :            : 
    4667                 :            :     String prefix =
    4668 [ #  # ][ #  # ]:          0 :         String( CUI_RES( RID_SVXSTR_NEW_TOOLBAR ) );
    4669                 :            : 
    4670                 :            :     OUString aNewName =
    4671 [ #  # ][ #  # ]:          0 :         generateCustomName( prefix, GetSaveInData()->GetEntries() );
                 [ #  # ]
    4672                 :            : 
    4673                 :            :     OUString aNewURL =
    4674 [ #  # ][ #  # ]:          0 :         generateCustomURL( GetSaveInData()->GetEntries() );
    4675                 :            : 
    4676 [ #  # ][ #  # ]:          0 :     SvxNewToolbarDialog* pNameDialog = new SvxNewToolbarDialog( 0, aNewName );
         [ #  # ][ #  # ]
    4677                 :            : 
    4678                 :            :     sal_uInt16 nInsertPos;
    4679 [ #  # ][ #  # ]:          0 :     for ( sal_uInt16 i = 0 ; i < aSaveInListBox.GetEntryCount(); ++i )
    4680                 :            :     {
    4681                 :            :         SaveInData* pData =
    4682         [ #  # ]:          0 :             (SaveInData*) aSaveInListBox.GetEntryData( i );
    4683                 :            : 
    4684                 :            :         nInsertPos = pNameDialog->aSaveInListBox.InsertEntry(
    4685 [ #  # ][ #  # ]:          0 :             aSaveInListBox.GetEntry( i ) );
                 [ #  # ]
    4686                 :            : 
    4687         [ #  # ]:          0 :         pNameDialog->aSaveInListBox.SetEntryData( nInsertPos, pData );
    4688                 :            :     }
    4689                 :            : 
    4690                 :            :     pNameDialog->aSaveInListBox.SelectEntryPos(
    4691 [ #  # ][ #  # ]:          0 :         aSaveInListBox.GetSelectEntryPos(), sal_True );
    4692                 :            : 
    4693         [ #  # ]:          0 :     bool ret = pNameDialog->Execute();
    4694         [ #  # ]:          0 :     if ( ret == RET_OK )
    4695                 :            :     {
    4696         [ #  # ]:          0 :         pNameDialog->GetName( aNewName );
    4697                 :            : 
    4698         [ #  # ]:          0 :         nInsertPos = pNameDialog->aSaveInListBox.GetSelectEntryPos();
    4699                 :            : 
    4700                 :            :         ToolbarSaveInData* pData = (ToolbarSaveInData*)
    4701         [ #  # ]:          0 :             pNameDialog->aSaveInListBox.GetEntryData( nInsertPos );
    4702                 :            : 
    4703         [ #  # ]:          0 :         if ( GetSaveInData() != pData )
    4704                 :            :         {
    4705         [ #  # ]:          0 :             aSaveInListBox.SelectEntryPos( nInsertPos, sal_True );
    4706         [ #  # ]:          0 :             aSaveInListBox.GetSelectHdl().Call(this);
    4707                 :            :         }
    4708                 :            : 
    4709                 :            :         SvxConfigEntry* pToolbar =
    4710 [ #  # ][ #  # ]:          0 :             new SvxConfigEntry( aNewName, aNewURL, sal_True );
    4711                 :            : 
    4712                 :          0 :         pToolbar->SetUserDefined( sal_True );
    4713                 :          0 :         pToolbar->SetMain( sal_True );
    4714                 :            : 
    4715         [ #  # ]:          0 :         pData->CreateToolbar( pToolbar );
    4716                 :            : 
    4717 [ #  # ][ #  # ]:          0 :         nInsertPos = aTopLevelListBox.InsertEntry( pToolbar->GetName() );
                 [ #  # ]
    4718         [ #  # ]:          0 :         aTopLevelListBox.SetEntryData( nInsertPos, pToolbar );
    4719         [ #  # ]:          0 :         aTopLevelListBox.SelectEntryPos( nInsertPos, sal_True );
    4720         [ #  # ]:          0 :         aTopLevelListBox.GetSelectHdl().Call(this);
    4721                 :            : 
    4722                 :          0 :         pData->SetModified( sal_True );
    4723                 :            :     }
    4724                 :            : 
    4725 [ #  # ][ #  # ]:          0 :     delete pNameDialog;
    4726                 :            : 
    4727         [ #  # ]:          0 :     return 0;
    4728                 :            : }
    4729                 :            : 
    4730                 :          0 : IMPL_LINK( SvxToolbarConfigPage, AddCommandsHdl, Button *, pButton )
    4731                 :            : {
    4732                 :            :     (void)pButton;
    4733                 :            : 
    4734         [ #  # ]:          0 :     if ( pSelectorDlg == NULL )
    4735                 :            :     {
    4736                 :            :         // Create Script Selector which shows slot commands
    4737         [ #  # ]:          0 :         pSelectorDlg = new SvxScriptSelectorDialog( this, sal_True, m_xFrame );
    4738                 :            : 
    4739                 :            :         // Position the Script Selector over the Add button so it is
    4740                 :            :         // beside the menu contents list and does not obscure it
    4741         [ #  # ]:          0 :         pSelectorDlg->SetPosPixel( aAddCommandsButton.GetPosPixel() );
    4742                 :            : 
    4743                 :            :         pSelectorDlg->SetAddHdl(
    4744                 :          0 :             LINK( this, SvxToolbarConfigPage, AddFunctionHdl ) );
    4745                 :            :     }
    4746                 :            : 
    4747                 :            :     pSelectorDlg->SetImageProvider(
    4748                 :          0 :         static_cast< ImageProvider* >( GetSaveInData() ) );
    4749                 :            : 
    4750                 :          0 :     pSelectorDlg->Show();
    4751                 :          0 :     return 1;
    4752                 :            : }
    4753                 :            : 
    4754                 :          0 : IMPL_LINK( SvxToolbarConfigPage, AddFunctionHdl,
    4755                 :            :     SvxScriptSelectorDialog *, pDialog )
    4756                 :            : {
    4757                 :            :     (void)pDialog;
    4758                 :            : 
    4759                 :          0 :     AddFunction();
    4760                 :            : 
    4761                 :          0 :     return 0;
    4762                 :            : }
    4763                 :            : 
    4764                 :          0 : SvLBoxEntry* SvxToolbarConfigPage::AddFunction(
    4765                 :            :     SvLBoxEntry* pTarget, bool bFront, bool bAllowDuplicates )
    4766                 :            : {
    4767                 :            :     SvLBoxEntry* pNewLBEntry =
    4768                 :          0 :         SvxConfigPage::AddFunction( pTarget, bFront, bAllowDuplicates );
    4769                 :            : 
    4770                 :          0 :     SvxConfigEntry* pEntry = (SvxConfigEntry*) pNewLBEntry->GetUserData();
    4771                 :            : 
    4772         [ #  # ]:          0 :     if ( pEntry->IsBinding() )
    4773                 :            :     {
    4774                 :          0 :         pEntry->SetVisible( sal_True );
    4775                 :            :         aContentsListBox->SetCheckButtonState(
    4776                 :          0 :             pNewLBEntry, SV_BUTTON_CHECKED );
    4777                 :            :     }
    4778                 :            :     else
    4779                 :            :     {
    4780                 :            :         aContentsListBox->SetCheckButtonState(
    4781                 :          0 :             pNewLBEntry, SV_BUTTON_TRISTATE );
    4782                 :            :     }
    4783                 :            : 
    4784                 :            :     // get currently selected toolbar and apply change
    4785                 :          0 :     SvxConfigEntry* pToolbar = GetTopLevelSelection();
    4786                 :            : 
    4787         [ #  # ]:          0 :     if ( pToolbar != NULL )
    4788                 :            :     {
    4789                 :          0 :         ( ( ToolbarSaveInData* ) GetSaveInData() )->ApplyToolbar( pToolbar );
    4790                 :            :     }
    4791                 :            : 
    4792                 :          0 :     return pNewLBEntry;
    4793                 :            : }
    4794                 :            : 
    4795                 :            : // -----------------------------------------------------------------------
    4796                 :            : 
    4797                 :          0 : SvxToolbarEntriesListBox::SvxToolbarEntriesListBox(
    4798                 :            :     Window* pParent, const ResId& aResId )
    4799                 :            :     :
    4800                 :            :         SvxMenuEntriesListBox( pParent, aResId ),
    4801         [ #  # ]:          0 :         pPage( ( SvxToolbarConfigPage* ) pParent )
    4802                 :            : {
    4803 [ #  # ][ #  # ]:          0 :     m_pButtonData = new SvLBoxButtonData( this );
    4804         [ #  # ]:          0 :     BuildCheckBoxButtonImages( m_pButtonData );
    4805         [ #  # ]:          0 :     EnableCheckButton( m_pButtonData );
    4806                 :          0 : }
    4807                 :            : 
    4808                 :            : // --------------------------------------------------------
    4809                 :            : 
    4810                 :          0 : SvxToolbarEntriesListBox::~SvxToolbarEntriesListBox()
    4811                 :            : {
    4812 [ #  # ][ #  # ]:          0 :     delete m_pButtonData;
    4813         [ #  # ]:          0 : }
    4814                 :            : 
    4815                 :            : // --------------------------------------------------------
    4816                 :            : 
    4817                 :          0 : void SvxToolbarEntriesListBox::BuildCheckBoxButtonImages( SvLBoxButtonData* pData )
    4818                 :            : {
    4819                 :            :     // Build checkbox images according to the current application
    4820                 :            :     // settings. This is necessary to be able to have correct colors
    4821                 :            :     // in all color modes, like high contrast.
    4822         [ #  # ]:          0 :     const AllSettings& rSettings = Application::GetSettings();
    4823                 :            : 
    4824         [ #  # ]:          0 :     VirtualDevice   aDev;
    4825                 :          0 :     Size            aSize( 26, 20 );
    4826                 :            : 
    4827         [ #  # ]:          0 :     aDev.SetOutputSizePixel( aSize );
    4828                 :            : 
    4829                 :            :     Image aImage = GetSizedImage( aDev, aSize,
    4830 [ #  # ][ #  # ]:          0 :         CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT ));
                 [ #  # ]
    4831                 :            : 
    4832                 :            :     // Fill button data struct with new images
    4833         [ #  # ]:          0 :     pData->aBmps[SV_BMP_UNCHECKED]      = aImage;
    4834 [ #  # ][ #  # ]:          0 :     pData->aBmps[SV_BMP_CHECKED]        = GetSizedImage( aDev, aSize, CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED ));
         [ #  # ][ #  # ]
                 [ #  # ]
    4835 [ #  # ][ #  # ]:          0 :     pData->aBmps[SV_BMP_HICHECKED]      = GetSizedImage( aDev, aSize, CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED | BUTTON_DRAW_PRESSED ));
         [ #  # ][ #  # ]
                 [ #  # ]
    4836 [ #  # ][ #  # ]:          0 :     pData->aBmps[SV_BMP_HIUNCHECKED]    = GetSizedImage( aDev, aSize, CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT | BUTTON_DRAW_PRESSED));
         [ #  # ][ #  # ]
                 [ #  # ]
    4837 [ #  # ][ #  # ]:          0 :     pData->aBmps[SV_BMP_TRISTATE]       = GetSizedImage( aDev, aSize, Image() ); // Use tristate bitmaps to have no checkbox for separator entries
         [ #  # ][ #  # ]
                 [ #  # ]
    4838 [ #  # ][ #  # ]:          0 :     pData->aBmps[SV_BMP_HITRISTATE]     = GetSizedImage( aDev, aSize, Image() );
         [ #  # ][ #  # ]
                 [ #  # ]
    4839                 :            : 
    4840                 :            :     // Get image size
    4841 [ #  # ][ #  # ]:          0 :     m_aCheckBoxImageSizePixel = aImage.GetSizePixel();
                 [ #  # ]
    4842                 :          0 : }
    4843                 :            : 
    4844                 :          0 : Image SvxToolbarEntriesListBox::GetSizedImage(
    4845                 :            :     VirtualDevice& aDev, const Size& aNewSize, const Image& aImage )
    4846                 :            : {
    4847                 :            :     // Create new checkbox images for treelistbox. They must have a
    4848                 :            :     // decent width to have a clear column for the visibility checkbox.
    4849                 :            : 
    4850                 :            :     // Standard transparent color is light magenta as is won't be
    4851                 :            :     // used for other things
    4852                 :          0 :     Color   aFillColor( COL_LIGHTMAGENTA );
    4853                 :            : 
    4854                 :            :     // Position image at the center of (width-2),(height) rectangle.
    4855                 :            :     // We need 2 pixels to have a bigger border to the next button image
    4856 [ #  # ][ #  # ]:          0 :     sal_uInt16  nPosX = std::max( (sal_uInt16) (((( aNewSize.Width() - 2 ) - aImage.GetSizePixel().Width() ) / 2 ) - 1), (sal_uInt16) 0 );
    4857 [ #  # ][ #  # ]:          0 :     sal_uInt16  nPosY = std::max( (sal_uInt16) (((( aNewSize.Height() - 2 ) - aImage.GetSizePixel().Height() ) / 2 ) + 1), (sal_uInt16) 0 );
    4858 [ #  # ][ #  # ]:          0 :     Point   aPos( nPosX > 0 ? nPosX : 0, nPosY > 0 ? nPosY : 0 );
    4859         [ #  # ]:          0 :     aDev.SetFillColor( aFillColor );
    4860         [ #  # ]:          0 :     aDev.SetLineColor( aFillColor );
    4861 [ #  # ][ #  # ]:          0 :     aDev.DrawRect( Rectangle( Point(), aNewSize ));
    4862         [ #  # ]:          0 :     aDev.DrawImage( aPos, aImage );
    4863                 :            : 
    4864                 :            :     // Draw separator line 2 pixels left from the right border
    4865 [ #  # ][ #  # ]:          0 :     Color aLineColor = GetDisplayBackground().GetColor().IsDark() ? Color( COL_WHITE ) : Color( COL_BLACK );
         [ #  # ][ #  # ]
    4866         [ #  # ]:          0 :     aDev.SetLineColor( aLineColor );
    4867         [ #  # ]:          0 :     aDev.DrawLine( Point( aNewSize.Width()-3, 0 ), Point( aNewSize.Width()-3, aNewSize.Height()-1 ));
    4868                 :            : 
    4869                 :            :     // Create new image that uses the fillcolor as transparent
    4870 [ #  # ][ #  # ]:          0 :     return Image( aDev.GetBitmap( Point(), aNewSize ), aFillColor );
                 [ #  # ]
    4871                 :            : }
    4872                 :            : 
    4873                 :          0 : void SvxToolbarEntriesListBox::DataChanged( const DataChangedEvent& rDCEvt )
    4874                 :            : {
    4875                 :          0 :     SvTreeListBox::DataChanged( rDCEvt );
    4876                 :            : 
    4877         [ #  # ]:          0 :     if (( rDCEvt.GetType() == DATACHANGED_SETTINGS ) &&
           [ #  #  #  # ]
    4878                 :          0 :         ( rDCEvt.GetFlags() & SETTINGS_STYLE ))
    4879                 :            :     {
    4880                 :          0 :         BuildCheckBoxButtonImages( m_pButtonData );
    4881                 :          0 :         Invalidate();
    4882                 :            :     }
    4883                 :          0 : }
    4884                 :            : 
    4885                 :            : // --------------------------------------------------------
    4886                 :            : 
    4887                 :          0 : void SvxToolbarEntriesListBox::ChangeVisibility( SvLBoxEntry* pEntry )
    4888                 :            : {
    4889         [ #  # ]:          0 :     if ( pEntry != NULL )
    4890                 :            :     {
    4891                 :            :         SvxConfigEntry* pEntryData =
    4892                 :          0 :             (SvxConfigEntry*) pEntry->GetUserData();
    4893                 :            : 
    4894         [ #  # ]:          0 :         if ( pEntryData->IsBinding() )
    4895                 :            :         {
    4896                 :          0 :             pEntryData->SetVisible( !pEntryData->IsVisible() );
    4897                 :            : 
    4898                 :          0 :             SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection();
    4899                 :            : 
    4900                 :            :             ToolbarSaveInData* pToolbarSaveInData = ( ToolbarSaveInData* )
    4901                 :          0 :                 pPage->GetSaveInData();
    4902                 :            : 
    4903                 :          0 :                pToolbarSaveInData->ApplyToolbar( pToolbar );
    4904                 :            : 
    4905                 :          0 :             SetCheckButtonState( pEntry, pEntryData->IsVisible() ?
    4906         [ #  # ]:          0 :                 SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
    4907                 :            :         }
    4908                 :            :     }
    4909                 :          0 : }
    4910                 :            : 
    4911                 :          0 : void SvxToolbarEntriesListBox::CheckButtonHdl()
    4912                 :            : {
    4913                 :          0 :     ChangeVisibility( GetHdlEntry() );
    4914                 :          0 : }
    4915                 :            : 
    4916                 :          0 : void SvxToolbarEntriesListBox::KeyInput( const KeyEvent& rKeyEvent )
    4917                 :            : {
    4918                 :            :     // space key will change visibility of toolbar items
    4919 [ #  # ][ #  # ]:          0 :     if ( rKeyEvent.GetKeyCode() == KEY_SPACE )
    4920                 :            :     {
    4921                 :          0 :         ChangeVisibility( GetCurEntry() );
    4922                 :            :     }
    4923                 :            :     else
    4924                 :            :     {
    4925                 :            :         // pass on to superclass
    4926                 :          0 :         SvxMenuEntriesListBox::KeyInput( rKeyEvent );
    4927                 :            :     }
    4928                 :          0 : }
    4929                 :            : 
    4930                 :          0 : sal_Bool SvxToolbarEntriesListBox::NotifyMoving(
    4931                 :            :     SvLBoxEntry* pTarget, SvLBoxEntry* pSource,
    4932                 :            :     SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos)
    4933                 :            : {
    4934                 :            :     bool result = SvxMenuEntriesListBox::NotifyMoving(
    4935                 :          0 :         pTarget, pSource, rpNewParent, rNewChildPos );
    4936                 :            : 
    4937         [ #  # ]:          0 :     if ( result == sal_True )
    4938                 :            :     {
    4939                 :            :         // Instant Apply changes to UI
    4940                 :          0 :         SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection();
    4941         [ #  # ]:          0 :         if ( pToolbar != NULL )
    4942                 :            :         {
    4943                 :            :             ToolbarSaveInData* pSaveInData =
    4944                 :          0 :                 ( ToolbarSaveInData*) pPage->GetSaveInData();
    4945                 :          0 :             pSaveInData->ApplyToolbar( pToolbar );
    4946                 :            :         }
    4947                 :            :     }
    4948                 :            : 
    4949                 :          0 :     return result;
    4950                 :            : }
    4951                 :            : 
    4952                 :          0 : sal_Bool SvxToolbarEntriesListBox::NotifyCopying(
    4953                 :            :     SvLBoxEntry*  pTarget,
    4954                 :            :     SvLBoxEntry*  pSource,
    4955                 :            :     SvLBoxEntry*& rpNewParent,
    4956                 :            :     sal_uLong&      rNewChildPos)
    4957                 :            : {
    4958                 :            :     (void)pSource;
    4959                 :            :     (void)rpNewParent;
    4960                 :            :     (void)rNewChildPos;
    4961                 :            : 
    4962         [ #  # ]:          0 :     if ( !m_bIsInternalDrag )
    4963                 :            :     {
    4964                 :            :         // if the target is NULL then add function to the start of the list
    4965                 :          0 :         ((SvxToolbarConfigPage*)pPage)->AddFunction( pTarget, pTarget == NULL );
    4966                 :            : 
    4967                 :            :         // Instant Apply changes to UI
    4968                 :          0 :         SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection();
    4969         [ #  # ]:          0 :         if ( pToolbar != NULL )
    4970                 :            :         {
    4971                 :            :             ToolbarSaveInData* pSaveInData =
    4972                 :          0 :                 ( ToolbarSaveInData*) pPage->GetSaveInData();
    4973                 :          0 :             pSaveInData->ApplyToolbar( pToolbar );
    4974                 :            :         }
    4975                 :            : 
    4976                 :            :         // AddFunction already adds the listbox entry so return FALSE
    4977                 :            :         // to stop another listbox entry being added
    4978                 :          0 :         return sal_False;
    4979                 :            :     }
    4980                 :            : 
    4981                 :            :     // Copying is only allowed from external controls, not within the listbox
    4982                 :          0 :     return sal_False;
    4983                 :            : }
    4984                 :            : 
    4985                 :          0 : SvxNewToolbarDialog::SvxNewToolbarDialog(
    4986                 :            :     Window* pWindow, const String& rName )
    4987                 :            :     :
    4988                 :          0 :     ModalDialog     ( pWindow, CUI_RES( MD_NEW_TOOLBAR ) ),
    4989         [ #  # ]:          0 :     aFtDescription  ( this, CUI_RES( FT_NAME ) ),
    4990         [ #  # ]:          0 :     aEdtName        ( this, CUI_RES( EDT_STRING ) ),
    4991         [ #  # ]:          0 :     aSaveInText     ( this, CUI_RES( TXT_SAVEIN ) ),
    4992         [ #  # ]:          0 :     aBtnOK          ( this, CUI_RES( BTN_OK ) ),
    4993         [ #  # ]:          0 :     aBtnCancel      ( this, CUI_RES( BTN_CANCEL ) ),
    4994         [ #  # ]:          0 :     aBtnHelp        ( this, CUI_RES( BTN_HELP ) ),
    4995 [ #  # ][ #  # ]:          0 :     aSaveInListBox  ( this, CUI_RES( LB_SAVEIN ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    4996                 :            : {
    4997         [ #  # ]:          0 :     FreeResource();
    4998                 :            : 
    4999         [ #  # ]:          0 :     aEdtName.SetText( rName );
    5000         [ #  # ]:          0 :     aEdtName.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
    5001         [ #  # ]:          0 :     ModifyHdl(&aEdtName);
    5002         [ #  # ]:          0 :     aEdtName.SetModifyHdl(LINK(this, SvxNewToolbarDialog, ModifyHdl));
    5003                 :          0 : }
    5004                 :            : 
    5005                 :          0 : IMPL_LINK(SvxNewToolbarDialog, ModifyHdl, Edit*, pEdit)
    5006                 :            : {
    5007                 :            :     (void)pEdit;
    5008                 :            : 
    5009         [ #  # ]:          0 :     if(aCheckNameHdl.IsSet())
    5010                 :          0 :         aBtnOK.Enable(aCheckNameHdl.Call(this) > 0);
    5011                 :            : 
    5012                 :          0 :     return 0;
    5013                 :            : }
    5014                 :            : 
    5015                 :            : /*******************************************************************************
    5016                 :            : *
    5017                 :            : * The SvxIconSelectorDialog class
    5018                 :            : *
    5019                 :            : *******************************************************************************/
    5020                 :          0 : SvxIconSelectorDialog::SvxIconSelectorDialog( Window *pWindow,
    5021                 :            :     const uno::Reference< css::ui::XImageManager >& rXImageManager,
    5022                 :            :     const uno::Reference< css::ui::XImageManager >& rXParentImageManager )
    5023                 :            :     :
    5024                 :          0 :     ModalDialog          ( pWindow, CUI_RES( MD_ICONSELECTOR ) ),
    5025         [ #  # ]:          0 :     aFtDescription       ( this, CUI_RES( FT_SYMBOLS ) ),
    5026         [ #  # ]:          0 :     aTbSymbol            ( this, CUI_RES( TB_SYMBOLS ) ),
    5027         [ #  # ]:          0 :     aFtNote              ( this, CUI_RES( FT_NOTE ) ),
    5028         [ #  # ]:          0 :     aBtnOK               ( this, CUI_RES( BTN_OK ) ),
    5029         [ #  # ]:          0 :     aBtnCancel           ( this, CUI_RES( BTN_CANCEL ) ),
    5030         [ #  # ]:          0 :     aBtnHelp             ( this, CUI_RES( BTN_HELP ) ),
    5031         [ #  # ]:          0 :     aBtnImport           ( this, CUI_RES( BTN_IMPORT ) ),
    5032         [ #  # ]:          0 :     aBtnDelete           ( this, CUI_RES( BTN_DELETE ) ),
    5033         [ #  # ]:          0 :     aFlSeparator         ( this, CUI_RES( FL_SEPARATOR ) ),
    5034                 :            :     m_nNextId            ( 0 ),
    5035                 :            :     m_xImageManager      ( rXImageManager ),
    5036 [ #  # ][ #  # ]:          0 :     m_xParentImageManager( rXParentImageManager )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5037                 :            : {
    5038         [ #  # ]:          0 :     FreeResource();
    5039                 :            : 
    5040                 :            :     typedef ::boost::unordered_map< ::rtl::OUString,
    5041                 :            :                              bool,
    5042                 :            :                              ::rtl::OUStringHash,
    5043                 :            :                              ::std::equal_to< ::rtl::OUString > > ImageInfo;
    5044                 :            : 
    5045         [ #  # ]:          0 :     aTbSymbol.SetPageScroll( sal_True );
    5046                 :            : 
    5047                 :          0 :     bool bLargeIcons = GetImageType() & css::ui::ImageType::SIZE_LARGE;
    5048         [ #  # ]:          0 :     m_nExpectedSize = bLargeIcons ? 26 : 16;
    5049                 :            : 
    5050         [ #  # ]:          0 :     if ( m_nExpectedSize != 16 )
    5051                 :            :     {
    5052 [ #  # ][ #  # ]:          0 :         aFtNote.SetText( replaceSixteen( aFtNote.GetText(), m_nExpectedSize ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5053                 :            :     }
    5054                 :            : 
    5055                 :            :     uno::Reference< lang::XMultiServiceFactory > xServiceManager =
    5056         [ #  # ]:          0 :         ::comphelper::getProcessServiceFactory();
    5057                 :            :     uno::Reference< uno::XComponentContext > xComponentContext =
    5058         [ #  # ]:          0 :         ::comphelper::getProcessComponentContext();
    5059                 :            : 
    5060                 :            :     m_xGraphProvider = uno::Reference< graphic::XGraphicProvider >(
    5061 [ #  # ][ #  # ]:          0 :         graphic::GraphicProvider::create( xComponentContext ) );
    5062                 :            : 
    5063                 :            :     uno::Reference< beans::XPropertySet > xPropSet(
    5064         [ #  # ]:          0 :         xServiceManager->createInstance( ::rtl::OUString("com.sun.star.util.PathSettings"  ) ),
    5065 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY );
    5066                 :            : 
    5067 [ #  # ][ #  # ]:          0 :     uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString( "UserConfig"  ) );
    5068                 :            : 
    5069                 :          0 :     ::rtl::OUString aDirectory;
    5070                 :            : 
    5071                 :          0 :     aAny >>= aDirectory;
    5072                 :            : 
    5073                 :          0 :     sal_Int32 aCount = aDirectory.getLength();
    5074                 :            : 
    5075         [ #  # ]:          0 :     if ( aCount > 0 )
    5076                 :            :     {
    5077                 :          0 :         sal_Unicode aChar = aDirectory[ aCount-1 ];
    5078         [ #  # ]:          0 :         if ( aChar != '/')
    5079                 :            :         {
    5080                 :          0 :             aDirectory += ::rtl::OUString( "/"  );
    5081                 :            :         }
    5082                 :            :     }
    5083                 :            :     else
    5084                 :            :     {
    5085         [ #  # ]:          0 :         aBtnImport.Enable( sal_False );
    5086                 :            :     }
    5087                 :            : 
    5088                 :          0 :     aDirectory += ::rtl::OUString( "soffice.cfg/import"  );
    5089                 :            : 
    5090                 :            :     uno::Reference< lang::XSingleServiceFactory > xStorageFactory(
    5091         [ #  # ]:          0 :           ::com::sun::star::embed::FileSystemStorageFactory::create( xComponentContext ) );
    5092                 :            : 
    5093         [ #  # ]:          0 :     uno::Sequence< uno::Any > aArgs( 2 );
    5094 [ #  # ][ #  # ]:          0 :     aArgs[ 0 ] <<= aDirectory;
    5095 [ #  # ][ #  # ]:          0 :     aArgs[ 1 ] <<= com::sun::star::embed::ElementModes::READWRITE;
    5096                 :            : 
    5097                 :            :     uno::Reference< com::sun::star::embed::XStorage > xStorage(
    5098 [ #  # ][ #  # ]:          0 :         xStorageFactory->createInstanceWithArguments( aArgs ), uno::UNO_QUERY );
                 [ #  # ]
    5099                 :            : 
    5100         [ #  # ]:          0 :     uno::Sequence< uno::Any > aProp( 2 );
    5101                 :          0 :     beans::PropertyValue aPropValue;
    5102                 :            : 
    5103                 :          0 :     aPropValue.Name = ::rtl::OUString( "UserConfigStorage"  );
    5104         [ #  # ]:          0 :     aPropValue.Value <<= xStorage;
    5105 [ #  # ][ #  # ]:          0 :     aProp[ 0 ] <<= aPropValue;
    5106                 :            : 
    5107                 :          0 :     aPropValue.Name = ::rtl::OUString( "OpenMode"  );
    5108         [ #  # ]:          0 :     aPropValue.Value <<= com::sun::star::embed::ElementModes::READWRITE;
    5109 [ #  # ][ #  # ]:          0 :     aProp[ 1 ] <<= aPropValue;
    5110                 :            : 
    5111                 :            :     m_xImportedImageManager = uno::Reference< com::sun::star::ui::XImageManager >(
    5112         [ #  # ]:          0 :         xServiceManager->createInstanceWithArguments(
    5113                 :          0 :         ::rtl::OUString("com.sun.star.ui.ImageManager"  ), aProp ),
    5114 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY );
                 [ #  # ]
    5115                 :            : 
    5116         [ #  # ]:          0 :     ImageInfo mImageInfo;
    5117         [ #  # ]:          0 :     uno::Sequence< OUString > names;
    5118         [ #  # ]:          0 :     if ( m_xImportedImageManager.is() )
    5119                 :            :     {
    5120 [ #  # ][ #  # ]:          0 :         names = m_xImportedImageManager->getAllImageNames( GetImageType() );
         [ #  # ][ #  # ]
    5121         [ #  # ]:          0 :         for ( sal_Int32 n = 0; n < names.getLength(); ++n )
    5122 [ #  # ][ #  # ]:          0 :             mImageInfo.insert( ImageInfo::value_type( names[n], false ));
    5123                 :            :     }
    5124                 :          0 :     sal_uInt16 nId = 1;
    5125         [ #  # ]:          0 :     ImageInfo::const_iterator pConstIter = mImageInfo.begin();
    5126         [ #  # ]:          0 :     uno::Sequence< OUString > name( 1 );
    5127 [ #  # ][ #  # ]:          0 :     while ( pConstIter != mImageInfo.end() )
    5128                 :            :     {
    5129 [ #  # ][ #  # ]:          0 :         name[ 0 ] = pConstIter->first;
    5130 [ #  # ][ #  # ]:          0 :         uno::Sequence< uno::Reference< graphic::XGraphic> > graphics = m_xImportedImageManager->getImages( GetImageType(), name );
    5131         [ #  # ]:          0 :         if ( graphics.getLength() > 0 )
    5132                 :            :         {
    5133 [ #  # ][ #  # ]:          0 :             Image img = Image( graphics[ 0 ] );
    5134 [ #  # ][ #  # ]:          0 :             aTbSymbol.InsertItem( nId, img, pConstIter->first );
         [ #  # ][ #  # ]
    5135                 :            : 
    5136 [ #  # ][ #  # ]:          0 :             graphics[ 0 ]->acquire();
    5137                 :            : 
    5138                 :            :             aTbSymbol.SetItemData(
    5139 [ #  # ][ #  # ]:          0 :                 nId, static_cast< void * > ( graphics[ 0 ].get() ) );
                 [ #  # ]
    5140                 :            : 
    5141         [ #  # ]:          0 :             ++nId;
    5142                 :            :         }
    5143                 :          0 :         ++pConstIter;
    5144         [ #  # ]:          0 :     }
    5145                 :            : 
    5146         [ #  # ]:          0 :     ImageInfo                 aImageInfo;
    5147                 :            : 
    5148         [ #  # ]:          0 :     if ( m_xParentImageManager.is() )
    5149                 :            :     {
    5150 [ #  # ][ #  # ]:          0 :         names = m_xParentImageManager->getAllImageNames( GetImageType() );
         [ #  # ][ #  # ]
    5151         [ #  # ]:          0 :         for ( sal_Int32 n = 0; n < names.getLength(); ++n )
    5152 [ #  # ][ #  # ]:          0 :             aImageInfo.insert( ImageInfo::value_type( names[n], false ));
    5153                 :            :     }
    5154                 :            : 
    5155 [ #  # ][ #  # ]:          0 :     names = m_xImageManager->getAllImageNames( GetImageType() );
         [ #  # ][ #  # ]
    5156         [ #  # ]:          0 :     for ( sal_Int32 n = 0; n < names.getLength(); ++n )
    5157                 :            :     {
    5158 [ #  # ][ #  # ]:          0 :         ImageInfo::iterator pIter = aImageInfo.find( names[n] );
    5159 [ #  # ][ #  # ]:          0 :         if ( pIter != aImageInfo.end() )
    5160         [ #  # ]:          0 :             pIter->second = true;
    5161                 :            :         else
    5162 [ #  # ][ #  # ]:          0 :             aImageInfo.insert( ImageInfo::value_type( names[n], true ));
    5163                 :            :     }
    5164                 :            : 
    5165                 :            :     // large growth factor, expecting many entries
    5166         [ #  # ]:          0 :     pConstIter = aImageInfo.begin();
    5167 [ #  # ][ #  # ]:          0 :     while ( pConstIter != aImageInfo.end() )
    5168                 :            :     {
    5169 [ #  # ][ #  # ]:          0 :         name[ 0 ] = pConstIter->first;
    5170                 :            : 
    5171         [ #  # ]:          0 :         uno::Sequence< uno::Reference< graphic::XGraphic> > graphics;
    5172                 :            :         try
    5173                 :            :         {
    5174 [ #  # ][ #  # ]:          0 :             if ( pConstIter->second )
    5175 [ #  # ][ #  # ]:          0 :                 graphics = m_xImageManager->getImages( GetImageType(), name );
         [ #  # ][ #  # ]
    5176                 :            :             else
    5177 [ #  # ][ #  # ]:          0 :                 graphics = m_xParentImageManager->getImages( GetImageType(), name );
         [ #  # ][ #  # ]
                 [ #  # ]
    5178                 :            :         }
    5179         [ #  # ]:          0 :         catch ( uno::Exception& )
    5180                 :            :         {
    5181                 :            :             // can't get sequence for this name so it will not be
    5182                 :            :             // added to the list
    5183                 :            :         }
    5184                 :            : 
    5185         [ #  # ]:          0 :         if ( graphics.getLength() > 0 )
    5186                 :            :         {
    5187 [ #  # ][ #  # ]:          0 :             Image img = Image( graphics[ 0 ] );
    5188 [ #  # ][ #  # ]:          0 :             aTbSymbol.InsertItem( nId, img, pConstIter->first );
         [ #  # ][ #  # ]
    5189                 :            : 
    5190         [ #  # ]:          0 :             uno::Reference< graphic::XGraphic > xGraphic = graphics[ 0 ];
    5191                 :            : 
    5192         [ #  # ]:          0 :             if ( xGraphic.is() )
    5193         [ #  # ]:          0 :                 xGraphic->acquire();
    5194                 :            : 
    5195                 :            :             aTbSymbol.SetItemData(
    5196 [ #  # ][ #  # ]:          0 :                 nId, static_cast< void * > ( xGraphic.get() ) );
    5197                 :            : 
    5198         [ #  # ]:          0 :             ++nId;
    5199                 :            :         }
    5200                 :            : 
    5201                 :          0 :         ++pConstIter;
    5202         [ #  # ]:          0 :     }
    5203                 :            : 
    5204         [ #  # ]:          0 :     aBtnDelete.Enable( sal_False );
    5205         [ #  # ]:          0 :     aTbSymbol.SetSelectHdl( LINK(this, SvxIconSelectorDialog, SelectHdl) );
    5206         [ #  # ]:          0 :     aBtnImport.SetClickHdl( LINK(this, SvxIconSelectorDialog, ImportHdl) );
    5207         [ #  # ]:          0 :     aBtnDelete.SetClickHdl( LINK(this, SvxIconSelectorDialog, DeleteHdl) );
    5208                 :            : 
    5209 [ #  # ][ #  # ]:          0 :     m_nNextId = aTbSymbol.GetItemCount()+1;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    5210                 :          0 : }
    5211                 :            : 
    5212 [ #  # ][ #  # ]:          0 : SvxIconSelectorDialog::~SvxIconSelectorDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    5213                 :            : {
    5214         [ #  # ]:          0 :     sal_uInt16 nCount = aTbSymbol.GetItemCount();
    5215                 :            : 
    5216         [ #  # ]:          0 :     for (sal_uInt16 n = 0; n < nCount; ++n )
    5217                 :            :     {
    5218         [ #  # ]:          0 :         sal_uInt16 nId = aTbSymbol.GetItemId(n);
    5219                 :            : 
    5220                 :            :         uno::XInterface* xi = static_cast< uno::XInterface* >(
    5221         [ #  # ]:          0 :             aTbSymbol.GetItemData( nId ) );
    5222                 :            : 
    5223         [ #  # ]:          0 :         if ( xi != NULL )
    5224                 :            :         {
    5225                 :          0 :             xi->release();
    5226                 :            :         }
    5227                 :            :     }
    5228         [ #  # ]:          0 : }
    5229                 :            : 
    5230                 :          0 : uno::Reference< graphic::XGraphic> SvxIconSelectorDialog::GetSelectedIcon()
    5231                 :            : {
    5232                 :          0 :     uno::Reference< graphic::XGraphic > result;
    5233                 :            : 
    5234                 :            :     sal_uInt16 nId;
    5235 [ #  # ][ #  # ]:          0 :     for ( sal_uInt16 n = 0; n < aTbSymbol.GetItemCount(); ++n )
    5236                 :            :     {
    5237         [ #  # ]:          0 :         nId = aTbSymbol.GetItemId( n );
    5238 [ #  # ][ #  # ]:          0 :         if ( aTbSymbol.IsItemChecked( nId ) )
    5239                 :            :         {
    5240                 :            :             result = uno::Reference< graphic::XGraphic >(
    5241                 :            :                 reinterpret_cast< graphic::XGraphic* >(
    5242 [ #  # ][ #  # ]:          0 :                     aTbSymbol.GetItemData( nId ) ) );
                 [ #  # ]
    5243                 :            :         }
    5244                 :            :     }
    5245                 :            : 
    5246                 :          0 :     return result;
    5247                 :            : }
    5248                 :            : 
    5249                 :          0 : IMPL_LINK( SvxIconSelectorDialog, SelectHdl, ToolBox *, pToolBox )
    5250                 :            : {
    5251                 :            :     (void)pToolBox;
    5252                 :            : 
    5253         [ #  # ]:          0 :     sal_uInt16 nCount = aTbSymbol.GetItemCount();
    5254                 :            : 
    5255         [ #  # ]:          0 :     for (sal_uInt16 n = 0; n < nCount; ++n )
    5256                 :            :     {
    5257         [ #  # ]:          0 :         sal_uInt16 nId = aTbSymbol.GetItemId( n );
    5258                 :            : 
    5259 [ #  # ][ #  # ]:          0 :         if ( aTbSymbol.IsItemChecked( nId ) )
    5260                 :            :         {
    5261         [ #  # ]:          0 :             aTbSymbol.CheckItem( nId, sal_False );
    5262                 :            :         }
    5263                 :            :     }
    5264                 :            : 
    5265                 :          0 :     sal_uInt16 nId = aTbSymbol.GetCurItemId();
    5266         [ #  # ]:          0 :     aTbSymbol.CheckItem( nId );
    5267                 :            : 
    5268 [ #  # ][ #  # ]:          0 :     ::rtl::OUString aSelImageText = aTbSymbol.GetItemText( nId );
    5269 [ #  # ][ #  # ]:          0 :     if ( m_xImportedImageManager->hasImage( GetImageType(), aSelImageText ) )
                 [ #  # ]
    5270                 :            :     {
    5271         [ #  # ]:          0 :         aBtnDelete.Enable( sal_True );
    5272                 :            :     }
    5273                 :            :     else
    5274                 :            :     {
    5275         [ #  # ]:          0 :         aBtnDelete.Enable( sal_False );
    5276                 :            :     }
    5277                 :            : 
    5278                 :          0 :     return 0;
    5279                 :            : }
    5280                 :            : 
    5281                 :          0 : IMPL_LINK( SvxIconSelectorDialog, ImportHdl, PushButton *, pButton )
    5282                 :            : {
    5283                 :            :     (void)pButton;
    5284                 :            : 
    5285                 :            :     sfx2::FileDialogHelper aImportDialog(
    5286                 :            :         css::ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
    5287         [ #  # ]:          0 :         SFXWB_GRAPHIC | SFXWB_MULTISELECTION );
    5288                 :            : 
    5289                 :            :     // disable the link checkbox in the dialog
    5290                 :            :     uno::Reference< css::ui::dialogs::XFilePickerControlAccess >
    5291 [ #  # ][ #  # ]:          0 :         xController( aImportDialog.GetFilePicker(), uno::UNO_QUERY);
    5292         [ #  # ]:          0 :     if ( xController.is() )
    5293                 :            :     {
    5294         [ #  # ]:          0 :         xController->enableControl(
    5295                 :            :             css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK,
    5296         [ #  # ]:          0 :             sal_False);
    5297                 :            :     }
    5298                 :            : 
    5299                 :            :     aImportDialog.SetCurrentFilter(
    5300 [ #  # ][ #  # ]:          0 :         rtl::OUString("PNG - Portable Network Graphic"));
                 [ #  # ]
    5301                 :            : 
    5302 [ #  # ][ #  # ]:          0 :     if ( ERRCODE_NONE == aImportDialog.Execute() )
    5303                 :            :     {
    5304         [ #  # ]:          0 :         uno::Sequence< OUString > paths = aImportDialog.GetMPath();
    5305 [ #  # ][ #  # ]:          0 :         ImportGraphics ( paths );
    5306                 :            :     }
    5307                 :            : 
    5308         [ #  # ]:          0 :     return 0;
    5309                 :            : }
    5310                 :            : 
    5311                 :          0 : IMPL_LINK( SvxIconSelectorDialog, DeleteHdl, PushButton *, pButton )
    5312                 :            : {
    5313                 :            :     (void)pButton;
    5314                 :            : 
    5315 [ #  # ][ #  # ]:          0 :     OUString message = String( CUI_RES( RID_SVXSTR_DELETE_ICON_CONFIRM ) );
         [ #  # ][ #  # ]
    5316 [ #  # ][ #  # ]:          0 :     bool ret = WarningBox( this, WinBits(WB_OK_CANCEL), message ).Execute();
         [ #  # ][ #  # ]
                 [ #  # ]
    5317                 :            : 
    5318         [ #  # ]:          0 :     if ( ret == RET_OK )
    5319                 :            :     {
    5320         [ #  # ]:          0 :         sal_uInt16 nCount = aTbSymbol.GetItemCount();
    5321                 :            : 
    5322         [ #  # ]:          0 :         for (sal_uInt16 n = 0; n < nCount; ++n )
    5323                 :            :         {
    5324         [ #  # ]:          0 :             sal_uInt16 nId = aTbSymbol.GetItemId( n );
    5325                 :            : 
    5326 [ #  # ][ #  # ]:          0 :             if ( aTbSymbol.IsItemChecked( nId ) )
    5327                 :            :             {
    5328 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString aSelImageText = aTbSymbol.GetItemText( nId );
    5329         [ #  # ]:          0 :                 uno::Sequence< OUString > URLs(1);
    5330         [ #  # ]:          0 :                 URLs[0] = aSelImageText;
    5331 [ #  # ][ #  # ]:          0 :                 aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) );
    5332 [ #  # ][ #  # ]:          0 :                 m_xImportedImageManager->removeImages( GetImageType(), URLs );
    5333                 :            :                 uno::Reference< css::ui::XUIConfigurationPersistence >
    5334         [ #  # ]:          0 :                     xConfigPersistence( m_xImportedImageManager, uno::UNO_QUERY );
    5335 [ #  # ][ #  # ]:          0 :                 if ( xConfigPersistence.is() && xConfigPersistence->isModified() )
         [ #  # ][ #  # ]
                 [ #  # ]
    5336                 :            :                 {
    5337 [ #  # ][ #  # ]:          0 :                     xConfigPersistence->store();
    5338                 :            :                 }
    5339         [ #  # ]:          0 :                 break;
    5340                 :            :             }
    5341                 :            :         }
    5342                 :            :     }
    5343                 :          0 :     return 0;
    5344                 :            : }
    5345                 :            : 
    5346                 :          0 : bool SvxIconSelectorDialog::ReplaceGraphicItem(
    5347                 :            :     const ::rtl::OUString& aURL )
    5348                 :            : {
    5349         [ #  # ]:          0 :     uno::Sequence< OUString > URLs(1);
    5350         [ #  # ]:          0 :     uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
    5351                 :            :     uno::Reference< css::ui::XUIConfigurationPersistence >
    5352         [ #  # ]:          0 :         xConfigPer( m_xImportedImageManager, uno::UNO_QUERY );
    5353                 :            : 
    5354                 :          0 :     uno::Reference< graphic::XGraphic > xGraphic;
    5355         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
    5356         [ #  # ]:          0 :     aMediaProps[0].Name = ::rtl::OUString("URL" );
    5357 [ #  # ][ #  # ]:          0 :     aMediaProps[0].Value <<= aURL;
    5358                 :            : 
    5359                 :          0 :     com::sun::star::awt::Size aSize;
    5360                 :          0 :     bool bOK = sal_False;
    5361                 :            :     try
    5362                 :            :     {
    5363 [ #  # ][ #  # ]:          0 :         xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
                 [ #  # ]
    5364                 :            : 
    5365                 :            :         uno::Reference< beans::XPropertySet > props =
    5366 [ #  # ][ #  # ]:          0 :             m_xGraphProvider->queryGraphicDescriptor( aMediaProps );
    5367         [ #  # ]:          0 :         uno::Any a = props->getPropertyValue(
    5368         [ #  # ]:          0 :             OUString("SizePixel") );
    5369         [ #  # ]:          0 :         a >>= aSize;
    5370 [ #  # ][ #  # ]:          0 :         if (0 == aSize.Width || 0 == aSize.Height)
    5371                 :          0 :             return sal_False;
    5372                 :            :         else
    5373         [ #  # ]:          0 :             bOK = sal_True;
           [ #  #  #  # ]
    5374                 :            :     }
    5375         [ #  # ]:          0 :     catch ( uno::Exception& )
    5376                 :            :     {
    5377                 :          0 :         return false;
    5378                 :            :     }
    5379                 :            : 
    5380                 :          0 :     bool   bResult( false );
    5381         [ #  # ]:          0 :     sal_uInt16 nCount = aTbSymbol.GetItemCount();
    5382         [ #  # ]:          0 :     for (sal_uInt16 n = 0; n < nCount; ++n )
    5383                 :            :     {
    5384         [ #  # ]:          0 :         sal_uInt16 nId = aTbSymbol.GetItemId( n );
    5385                 :            : 
    5386 [ #  # ][ #  # ]:          0 :         if ( OUString( aTbSymbol.GetItemText( nId ) ) == aURL )
                 [ #  # ]
    5387                 :            :         {
    5388                 :            :             try
    5389                 :            :             {
    5390                 :            :                 // replace/insert image with provided URL
    5391 [ #  # ][ #  # ]:          0 :                 aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) );
    5392 [ #  # ][ #  # ]:          0 :                 aMediaProps[0].Value <<= aURL;
    5393                 :            : 
    5394         [ #  # ]:          0 :                 Image aImage( xGraphic );
    5395 [ #  # ][ #  # ]:          0 :                 if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
                 [ #  # ]
    5396                 :            :                 {
    5397         [ #  # ]:          0 :                     BitmapEx aBitmap = aImage.GetBitmapEx();
    5398         [ #  # ]:          0 :                     BitmapEx aBitmapex = BitmapEx::AutoScaleBitmap(aBitmap, m_nExpectedSize);
    5399 [ #  # ][ #  # ]:          0 :                     aImage = Image( aBitmapex);
         [ #  # ][ #  # ]
                 [ #  # ]
    5400                 :            :                 }
    5401 [ #  # ][ #  # ]:          0 :                 aTbSymbol.InsertItem( nId,aImage, aURL, 0, 0 ); //modify
                 [ #  # ]
    5402                 :            : 
    5403 [ #  # ][ #  # ]:          0 :                 xGraphic = aImage.GetXGraphic();
    5404                 :            : 
    5405         [ #  # ]:          0 :                 URLs[0] = aURL;
    5406 [ #  # ][ #  # ]:          0 :                 aImportGraph[ 0 ] = xGraphic;
    5407 [ #  # ][ #  # ]:          0 :                 m_xImportedImageManager->replaceImages( GetImageType(), URLs, aImportGraph );
    5408 [ #  # ][ #  # ]:          0 :                 xConfigPer->store();
    5409                 :            : 
    5410                 :          0 :                 bResult = true;
    5411 [ #  # ][ #  # ]:          0 :                 break;
    5412                 :            :             }
    5413         [ #  # ]:          0 :             catch ( ::com::sun::star::uno::Exception& )
    5414                 :            :             {
    5415                 :            :                 break;
    5416                 :            :             }
    5417                 :            :         }
    5418                 :            :     }
    5419                 :            : 
    5420 [ #  # ][ #  # ]:          0 :     return bResult;
                 [ #  # ]
    5421                 :            : }
    5422                 :            : 
    5423                 :          0 : void SvxIconSelectorDialog::ImportGraphics(
    5424                 :            :     const uno::Sequence< OUString >& rPaths )
    5425                 :            : {
    5426         [ #  # ]:          0 :     uno::Sequence< OUString > rejected( rPaths.getLength() );
    5427                 :          0 :     sal_Int32 rejectedCount = 0;
    5428                 :            : 
    5429                 :          0 :     sal_uInt16 ret = 0;
    5430                 :            :     sal_Int32 aIndex;
    5431                 :          0 :     OUString aIconName;
    5432         [ #  # ]:          0 :     uno::Sequence< OUString > URLs(1);
    5433         [ #  # ]:          0 :     uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
    5434         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
    5435         [ #  # ]:          0 :     aMediaProps[0].Name = ::rtl::OUString("URL" );
    5436                 :            :     uno::Reference< css::ui::XUIConfigurationPersistence >
    5437         [ #  # ]:          0 :         xConfigPer( m_xImportedImageManager, uno::UNO_QUERY );
    5438                 :            : 
    5439         [ #  # ]:          0 :     if ( rPaths.getLength() == 1 )
    5440                 :            :     {
    5441 [ #  # ][ #  # ]:          0 :         if ( m_xImportedImageManager->hasImage( GetImageType(), rPaths[0] ) )
                 [ #  # ]
    5442                 :            :         {
    5443                 :          0 :             aIndex = rPaths[0].lastIndexOf( '/' );
    5444                 :          0 :             aIconName = rPaths[0].copy( aIndex+1 );
    5445 [ #  # ][ #  # ]:          0 :             ret = SvxIconReplacementDialog( this, aIconName ).ShowDialog();
                 [ #  # ]
    5446         [ #  # ]:          0 :             if ( ret == 2 )
    5447                 :            :             {
    5448         [ #  # ]:          0 :                 ReplaceGraphicItem( rPaths[0] );
    5449                 :            :             }
    5450                 :            :         }
    5451                 :            :         else
    5452                 :            :         {
    5453 [ #  # ][ #  # ]:          0 :             if ( ImportGraphic( rPaths[0] ) == sal_False )
    5454                 :            :             {
    5455         [ #  # ]:          0 :                 rejected[0] = rPaths[0];
    5456                 :          0 :                 rejectedCount = 1;
    5457                 :            :             }
    5458                 :            :         }
    5459                 :            :     }
    5460                 :            :     else
    5461                 :            :     {
    5462                 :          0 :         ::rtl::OUString aSourcePath( rPaths[0] );
    5463         [ #  # ]:          0 :         if ( rPaths[0].lastIndexOf( '/' ) != rPaths[0].getLength() -1 )
    5464                 :          0 :             aSourcePath = rPaths[0] + ::rtl::OUString("/"  );
    5465                 :            : 
    5466         [ #  # ]:          0 :         for ( sal_Int32 i = 1; i < rPaths.getLength(); ++i )
    5467                 :            :         {
    5468                 :          0 :             ::rtl::OUString aPath = aSourcePath + rPaths[i];
    5469 [ #  # ][ #  # ]:          0 :             if ( m_xImportedImageManager->hasImage( GetImageType(), aPath ) )
                 [ #  # ]
    5470                 :            :             {
    5471                 :          0 :                 aIndex = rPaths[i].lastIndexOf( '/' );
    5472                 :          0 :                 aIconName = rPaths[i].copy( aIndex+1 );
    5473 [ #  # ][ #  # ]:          0 :                 ret = SvxIconReplacementDialog( this, aIconName, sal_True ).ShowDialog();
                 [ #  # ]
    5474         [ #  # ]:          0 :                 if ( ret == 2 )
    5475                 :            :                 {
    5476         [ #  # ]:          0 :                     ReplaceGraphicItem( aPath );
    5477                 :            :                 }
    5478         [ #  # ]:          0 :                 else if ( ret == 5 )
    5479                 :            :                 {
    5480         [ #  # ]:          0 :                     for ( sal_Int32 k = i; k < rPaths.getLength(); ++k )
    5481                 :            :                     {
    5482                 :          0 :                         aPath = aSourcePath + rPaths[k];
    5483         [ #  # ]:          0 :                         bool bHasReplaced = ReplaceGraphicItem( aPath );
    5484                 :            : 
    5485         [ #  # ]:          0 :                         if ( !bHasReplaced )
    5486                 :            :                         {
    5487         [ #  # ]:          0 :                             bool result = ImportGraphic( aPath );
    5488         [ #  # ]:          0 :                             if ( result == sal_False )
    5489                 :            :                             {
    5490         [ #  # ]:          0 :                                 rejected[ rejectedCount ] = rPaths[i];
    5491                 :          0 :                                 ++rejectedCount;
    5492                 :            :                             }
    5493                 :            :                         }
    5494                 :            :                     }
    5495                 :            :                     break;
    5496                 :            :                 }
    5497                 :            :             }
    5498                 :            :             else
    5499                 :            :             {
    5500         [ #  # ]:          0 :                 bool result = ImportGraphic( aSourcePath + rPaths[i] );
    5501         [ #  # ]:          0 :                 if ( result == sal_False )
    5502                 :            :                 {
    5503         [ #  # ]:          0 :                     rejected[ rejectedCount ] = rPaths[i];
    5504                 :          0 :                     ++rejectedCount;
    5505                 :            :                 }
    5506                 :            :             }
    5507         [ #  # ]:          0 :         }
    5508                 :            :     }
    5509                 :            : 
    5510         [ #  # ]:          0 :     if ( rejectedCount != 0 )
    5511                 :            :     {
    5512                 :          0 :         OUString message;
    5513                 :          0 :         OUString newLine("\n");
    5514                 :          0 :         OUString fPath;
    5515         [ #  # ]:          0 :         if (rejectedCount > 1)
    5516                 :          0 :               fPath = rPaths[0].copy(8) + ::rtl::OUString("/"  );
    5517         [ #  # ]:          0 :         for ( sal_Int32 i = 0; i < rejectedCount; ++i )
    5518                 :            :         {
    5519         [ #  # ]:          0 :             message += fPath + rejected[i];
    5520                 :          0 :             message += newLine;
    5521                 :            :         }
    5522                 :            : 
    5523         [ #  # ]:          0 :         SvxIconChangeDialog aDialog(this, message);
    5524 [ #  # ][ #  # ]:          0 :         aDialog.Execute();
    5525 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
    5526                 :          0 : }
    5527                 :            : 
    5528                 :          0 : bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
    5529                 :            : {
    5530                 :          0 :     bool result = sal_False;
    5531                 :            : 
    5532                 :          0 :     sal_uInt16 nId = m_nNextId;
    5533                 :          0 :     ++m_nNextId;
    5534                 :            : 
    5535         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
    5536         [ #  # ]:          0 :     aMediaProps[0].Name = ::rtl::OUString("URL" );
    5537                 :            : 
    5538                 :          0 :     uno::Reference< graphic::XGraphic > xGraphic;
    5539                 :          0 :     com::sun::star::awt::Size aSize;
    5540                 :          0 :     bool bOK = sal_True;
    5541 [ #  # ][ #  # ]:          0 :     aMediaProps[0].Value <<= aURL;
    5542                 :            :     try
    5543                 :            :     {
    5544                 :            :         uno::Reference< beans::XPropertySet > props =
    5545 [ #  # ][ #  # ]:          0 :             m_xGraphProvider->queryGraphicDescriptor( aMediaProps );
    5546                 :            : 
    5547         [ #  # ]:          0 :         uno::Any a = props->getPropertyValue(
    5548         [ #  # ]:          0 :             OUString("SizePixel") );
    5549                 :            : 
    5550 [ #  # ][ #  # ]:          0 :             xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
                 [ #  # ]
    5551         [ #  # ]:          0 :             if ( xGraphic.is() )
    5552                 :            :             {
    5553         [ #  # ]:          0 :                 a >>= aSize;
    5554 [ #  # ][ #  # ]:          0 :                 if ( 0 == aSize.Width || 0 == aSize.Height )
    5555                 :          0 :                     bOK = sal_False;
    5556                 :            : 
    5557         [ #  # ]:          0 :                 Image aImage( xGraphic );
    5558                 :            : 
    5559 [ #  # ][ #  # ]:          0 :                 if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
                 [ #  # ]
    5560                 :            :                 {
    5561         [ #  # ]:          0 :                     BitmapEx aBitmap = aImage.GetBitmapEx();
    5562         [ #  # ]:          0 :                     BitmapEx aBitmapex = BitmapEx::AutoScaleBitmap(aBitmap, m_nExpectedSize);
    5563 [ #  # ][ #  # ]:          0 :                     aImage = Image( aBitmapex);
         [ #  # ][ #  # ]
                 [ #  # ]
    5564                 :            :                 }
    5565 [ #  # ][ #  # ]:          0 :                 if ( bOK && !!aImage )
                 [ #  # ]
    5566                 :            :                 {
    5567 [ #  # ][ #  # ]:          0 :                     aTbSymbol.InsertItem( nId, aImage, aURL, 0, 0 );
                 [ #  # ]
    5568                 :            : 
    5569 [ #  # ][ #  # ]:          0 :                     xGraphic = aImage.GetXGraphic();
    5570         [ #  # ]:          0 :                     xGraphic->acquire();
    5571                 :            : 
    5572                 :            :                     aTbSymbol.SetItemData(
    5573 [ #  # ][ #  # ]:          0 :                         nId, static_cast< void * > ( xGraphic.get() ) );
    5574         [ #  # ]:          0 :                     uno::Sequence< OUString > aImportURL( 1 );
    5575         [ #  # ]:          0 :                     aImportURL[ 0 ] = aURL;
    5576         [ #  # ]:          0 :                     uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
    5577 [ #  # ][ #  # ]:          0 :                     aImportGraph[ 0 ] = xGraphic;
    5578 [ #  # ][ #  # ]:          0 :                     m_xImportedImageManager->insertImages( GetImageType(), aImportURL, aImportGraph );
    5579                 :            :                     uno::Reference< css::ui::XUIConfigurationPersistence >
    5580         [ #  # ]:          0 :                     xConfigPersistence( m_xImportedImageManager, uno::UNO_QUERY );
    5581                 :            : 
    5582 [ #  # ][ #  # ]:          0 :                     if ( xConfigPersistence.is() && xConfigPersistence->isModified() )
         [ #  # ][ #  # ]
                 [ #  # ]
    5583                 :            :                     {
    5584 [ #  # ][ #  # ]:          0 :                         xConfigPersistence->store();
    5585                 :            :                     }
    5586                 :            : 
    5587 [ #  # ][ #  # ]:          0 :                     result = sal_True;
    5588                 :            :                 }
    5589                 :            :                 else
    5590                 :            :                 {
    5591                 :            :                     OSL_TRACE("could not create Image from XGraphic");
    5592         [ #  # ]:          0 :                 }
    5593                 :            :             }
    5594                 :            :             else
    5595                 :            :             {
    5596                 :            :                 OSL_TRACE("could not get query XGraphic");
    5597         [ #  # ]:          0 :             }
    5598                 :            :     }
    5599         [ #  # ]:          0 :     catch( uno::Exception& e )
    5600                 :            :     {
    5601                 :            :         OSL_TRACE("Caught exception importing XGraphic: %s", PRTSTR(e.Message));
    5602                 :            :     }
    5603         [ #  # ]:          0 :     return result;
    5604                 :            : }
    5605                 :            : 
    5606                 :            : /*******************************************************************************
    5607                 :            : *
    5608                 :            : * The SvxIconReplacementDialog class
    5609                 :            : *
    5610                 :            : *******************************************************************************/
    5611                 :          0 : SvxIconReplacementDialog :: SvxIconReplacementDialog(
    5612                 :            :     Window *pWindow, const rtl::OUString& aMessage, bool /*bYestoAll*/ )
    5613                 :            :     :
    5614 [ #  # ][ #  # ]:          0 : MessBox( pWindow, WB_DEF_YES, String( CUI_RES( RID_SVXSTR_REPLACE_ICON_CONFIRM ) ),  String( CUI_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5615                 :            : 
    5616                 :            : {
    5617 [ #  # ][ #  # ]:          0 :     SetImage( WarningBox::GetStandardImage() );
                 [ #  # ]
    5618 [ #  # ][ #  # ]:          0 :     SetMessText( ReplaceIconName( aMessage ) );
         [ #  # ][ #  # ]
    5619         [ #  # ]:          0 :     RemoveButton( 1 );
    5620         [ #  # ]:          0 :     AddButton( BUTTON_YES, 2, 0 );
    5621 [ #  # ][ #  # ]:          0 :     AddButton( String( CUI_RES( RID_SVXSTR_YESTOALL ) ), 5, 0 );
         [ #  # ][ #  # ]
    5622         [ #  # ]:          0 :     AddButton( BUTTON_NO, 3, 0 );
    5623         [ #  # ]:          0 :     AddButton( BUTTON_CANCEL, 4, 0 );
    5624                 :          0 : }
    5625                 :            : 
    5626                 :          0 : SvxIconReplacementDialog :: SvxIconReplacementDialog(
    5627                 :            :     Window *pWindow, const rtl::OUString& aMessage )
    5628                 :            :     :
    5629 [ #  # ][ #  # ]:          0 : MessBox( pWindow, WB_YES_NO_CANCEL, String( CUI_RES( RID_SVXSTR_REPLACE_ICON_CONFIRM ) ),  String( CUI_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5630                 :            : {
    5631 [ #  # ][ #  # ]:          0 :     SetImage( WarningBox::GetStandardImage() );
                 [ #  # ]
    5632 [ #  # ][ #  # ]:          0 :     SetMessText( ReplaceIconName( aMessage ));
         [ #  # ][ #  # ]
    5633                 :          0 : }
    5634                 :            : 
    5635                 :          0 : rtl::OUString SvxIconReplacementDialog :: ReplaceIconName( const OUString& rMessage )
    5636                 :            : {
    5637                 :          0 :     rtl::OUString name;
    5638 [ #  # ][ #  # ]:          0 :     rtl::OUString message = String( CUI_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) );
         [ #  # ][ #  # ]
    5639                 :          0 :     rtl::OUString placeholder("%ICONNAME" );
    5640                 :          0 :     sal_Int32 pos = message.indexOf( placeholder );
    5641         [ #  # ]:          0 :     if ( pos != -1 )
    5642                 :            :     {
    5643                 :            :         name = message.replaceAt(
    5644                 :          0 :             pos, placeholder.getLength(), rMessage );
    5645                 :            :     }
    5646                 :          0 :     return name;
    5647                 :            : }
    5648                 :            : 
    5649                 :          0 : sal_uInt16 SvxIconReplacementDialog :: ShowDialog()
    5650                 :            : {
    5651                 :          0 :     this->Execute();
    5652                 :          0 :     return ( this->GetCurButtonId() );
    5653                 :            : }
    5654                 :            : /*******************************************************************************
    5655                 :            : *
    5656                 :            : * The SvxIconChangeDialog class added for issue83555
    5657                 :            : *
    5658                 :            : *******************************************************************************/
    5659                 :          0 : SvxIconChangeDialog::SvxIconChangeDialog(
    5660                 :            :     Window *pWindow, const rtl::OUString& aMessage)
    5661                 :            :     :
    5662                 :          0 :     ModalDialog            ( pWindow, CUI_RES( MD_ICONCHANGE ) ),
    5663         [ #  # ]:          0 :     aFImageInfo            (this, CUI_RES( FI_INFO ) ),
    5664         [ #  # ]:          0 :     aBtnOK                 (this, CUI_RES(MD_BTN_OK)),
    5665         [ #  # ]:          0 :     aDescriptionLabel      (this, CUI_RES(FTCHGE_DESCRIPTION)),
    5666 [ #  # ][ #  # ]:          0 :     aLineEditDescription   (this, CUI_RES(EDT_ADDR))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    5667                 :            : {
    5668         [ #  # ]:          0 :     FreeResource();
    5669 [ #  # ][ #  # ]:          0 :     aFImageInfo.SetImage(InfoBox::GetStandardImage());
                 [ #  # ]
    5670         [ #  # ]:          0 :     aLineEditDescription.SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() );
    5671         [ #  # ]:          0 :     aLineEditDescription.SetAutoScroll( sal_True );
    5672         [ #  # ]:          0 :     aLineEditDescription.EnableCursor( sal_False );
    5673 [ #  # ][ #  # ]:          0 :     aLineEditDescription.SetText(aMessage);
                 [ #  # ]
    5674                 :          0 : }
    5675                 :            : 
    5676                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10