LCOV - code coverage report
Current view: top level - libreoffice/cui/source/dialogs - iconcdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 521 0.0 %
Date: 2012-12-17 Functions: 0 49 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/app.hxx>
      21             : #include <tools/rc.h>
      22             : #include <tools/shl.hxx>
      23             : 
      24             : #include <dialmgr.hxx>
      25             : 
      26             : #include "iconcdlg.hxx"
      27             : 
      28             : #include "helpid.hrc"
      29             : #include <cuires.hrc>
      30             : #include <unotools/viewoptions.hxx>
      31             : #include <svtools/apearcfg.hxx>
      32             : #include <vcl/mnemonic.hxx>
      33             : #include <vcl/i18nhelp.hxx>
      34             : 
      35             : using ::std::vector;
      36             : 
      37             : // some stuff for easier changes for SvtViewOptions
      38             : static const sal_Char*      pViewOptDataName = "dialog data";
      39             : #define VIEWOPT_DATANAME    ::rtl::OUString::createFromAscii( pViewOptDataName )
      40             : 
      41           0 : static inline void SetViewOptUserItem( SvtViewOptions& rOpt, const String& rData )
      42             : {
      43           0 :     rOpt.SetUserItem( VIEWOPT_DATANAME, ::com::sun::star::uno::makeAny( ::rtl::OUString( rData ) ) );
      44           0 : }
      45             : 
      46           0 : static inline String GetViewOptUserItem( const SvtViewOptions& rOpt )
      47             : {
      48           0 :     ::com::sun::star::uno::Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) );
      49           0 :     ::rtl::OUString aUserData;
      50           0 :     aAny >>= aUserData;
      51             : 
      52           0 :     return String( aUserData );
      53             : }
      54             : 
      55             : 
      56             : //#####################################################################
      57             : //
      58             : // Class IconChoicePage
      59             : //
      60             : //#####################################################################
      61             : 
      62             : /**********************************************************************
      63             : |
      64             : | Ctor / Dtor
      65             : |
      66             : \**********************************************************************/
      67             : 
      68           0 : IconChoicePage::IconChoicePage( Window *pParent, const ResId &rResId,
      69             :                                 const SfxItemSet &rAttrSet )
      70             : :   TabPage                   ( pParent, rResId ),
      71             :     pSet                      ( &rAttrSet ),
      72             :     bHasExchangeSupport       ( sal_False ),
      73           0 :     pDialog                   ( NULL )
      74             : {
      75           0 :     SetStyle ( GetStyle()  | WB_DIALOGCONTROL | WB_HIDE );
      76           0 : }
      77             : 
      78             : // -----------------------------------------------------------------------
      79             : 
      80           0 : IconChoicePage::~IconChoicePage()
      81             : {
      82           0 : }
      83             : 
      84             : /**********************************************************************
      85             : |
      86             : | Activate / Deaktivate
      87             : |
      88             : \**********************************************************************/
      89             : 
      90           0 : void IconChoicePage::ActivatePage( const SfxItemSet& )
      91             : {
      92           0 : }
      93             : 
      94             : // -----------------------------------------------------------------------
      95             : 
      96           0 : int IconChoicePage::DeactivatePage( SfxItemSet* )
      97             : {
      98           0 :     return LEAVE_PAGE;
      99             : }
     100             : 
     101             : /**********************************************************************
     102             : |
     103             : | ...
     104             : |
     105             : \**********************************************************************/
     106             : 
     107           0 : void IconChoicePage::FillUserData()
     108             : {
     109           0 : }
     110             : 
     111             : // -----------------------------------------------------------------------
     112             : 
     113           0 : sal_Bool IconChoicePage::IsReadOnly() const
     114             : {
     115           0 :     return sal_False;
     116             : }
     117             : 
     118             : // -----------------------------------------------------------------------
     119             : 
     120           0 : sal_Bool IconChoicePage::QueryClose()
     121             : {
     122           0 :     return sal_True;
     123             : }
     124             : 
     125             : /**********************************************************************
     126             : |
     127             : | window-methods
     128             : |
     129             : \**********************************************************************/
     130             : 
     131           0 : void IconChoicePage::ImplInitSettings()
     132             : {
     133           0 :     Window* pParent = GetParent();
     134           0 :     if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
     135             :     {
     136           0 :         EnableChildTransparentMode( sal_True );
     137           0 :         SetParentClipMode( PARENTCLIPMODE_NOCLIP );
     138           0 :         SetPaintTransparent( sal_True );
     139           0 :         SetBackground();
     140             :     }
     141             :     else
     142             :     {
     143           0 :         EnableChildTransparentMode( sal_False );
     144           0 :         SetParentClipMode( 0 );
     145           0 :         SetPaintTransparent( sal_False );
     146             : 
     147           0 :         if ( IsControlBackground() )
     148           0 :             SetBackground( GetControlBackground() );
     149             :         else
     150           0 :             SetBackground( pParent->GetBackground() );
     151             :     }
     152           0 : }
     153             : 
     154             : // -----------------------------------------------------------------------
     155             : 
     156           0 : void IconChoicePage::StateChanged( StateChangedType nType )
     157             : {
     158           0 :     Window::StateChanged( nType );
     159             : 
     160           0 :     if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     161             :     {
     162           0 :         ImplInitSettings();
     163           0 :         Invalidate();
     164             :     }
     165           0 : }
     166             : 
     167             : // -----------------------------------------------------------------------
     168             : 
     169           0 : void IconChoicePage::DataChanged( const DataChangedEvent& rDCEvt )
     170             : {
     171           0 :     Window::DataChanged( rDCEvt );
     172             : 
     173           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     174           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     175             :     {
     176           0 :         ImplInitSettings();
     177           0 :         Invalidate();
     178             :     }
     179           0 : }
     180             : 
     181             : //#####################################################################
     182             : //
     183             : // Class IconChoiceDialog
     184             : //
     185             : //#####################################################################
     186             : 
     187             : /**********************************************************************
     188             : |
     189             : | Ctor / Dtor
     190             : |
     191             : \**********************************************************************/
     192             : 
     193           0 : IconChoiceDialog::IconChoiceDialog ( Window* pParent, const ResId &rResId,
     194             :                                      const EIconChoicePos ePos,
     195             :                                      const SfxItemSet *pItemSet )
     196             : :   ModalDialog         ( pParent, rResId ),
     197             :     meChoicePos     ( ePos ),
     198             :     maIconCtrl      ( this, WB_3DLOOK | WB_ICON | WB_BORDER |
     199             :                             WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME |
     200             :                             WB_NODRAGSELECTION | WB_TABSTOP ),
     201             :     mnCurrentPageId ( USHRT_MAX ),
     202             : 
     203             :     aOKBtn          ( this, WB_DEFBUTTON ),
     204             :     aCancelBtn      ( this, WB_DEFBUTTON ),
     205             :     aHelpBtn        ( this ),
     206             :     aResetBtn       ( this ),
     207             :     pSet            ( pItemSet ),
     208             :     pOutSet         ( NULL ),
     209             :     pExampleSet     ( NULL ),
     210             :     pRanges         ( NULL ),
     211           0 :     nResId          ( rResId.GetId() ),
     212             : 
     213             :     bHideResetBtn   ( sal_False ),
     214             :     bModal          ( sal_False ),
     215             :     bInOK           ( sal_False ),
     216             :     bModified       ( sal_False ),
     217           0 :     bItemsReset     ( sal_False )
     218             : {
     219             : 
     220           0 :     maIconCtrl.SetStyle (WB_3DLOOK | WB_ICON | WB_BORDER | WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME | WB_NODRAGSELECTION | WB_TABSTOP | WB_CLIPCHILDREN );
     221           0 :     SetCtrlPos ( meChoicePos );
     222           0 :     maIconCtrl.SetClickHdl ( LINK ( this, IconChoiceDialog , ChosePageHdl_Impl ) );
     223           0 :     maIconCtrl.Show();
     224           0 :     maIconCtrl.SetChoiceWithCursor ( sal_True );
     225           0 :     maIconCtrl.SetSelectionMode( SINGLE_SELECTION );
     226           0 :     maIconCtrl.SetHelpId( HID_ICCDIALOG_CHOICECTRL );
     227             : 
     228             :     // ItemSet
     229           0 :     if ( pSet )
     230             :     {
     231           0 :         pExampleSet = new SfxItemSet( *pSet );
     232           0 :         pOutSet = new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() );
     233             :     }
     234             : 
     235             :     // Buttons
     236           0 :     aOKBtn.SetClickHdl   ( LINK( this, IconChoiceDialog, OkHdl ) );
     237           0 :     aOKBtn.SetHelpId( HID_ICCDIALOG_OK_BTN );
     238           0 :     aCancelBtn.SetHelpId( HID_ICCDIALOG_CANCEL_BTN );
     239           0 :     aResetBtn.SetClickHdl( LINK( this, IconChoiceDialog, ResetHdl ) );
     240           0 :     aResetBtn.SetText( CUI_RESSTR(RID_SVXSTR_ICONCHOICEDLG_RESETBUT) );
     241           0 :     aResetBtn.SetHelpId( HID_ICCDIALOG_RESET_BTN );
     242           0 :     aOKBtn.Show();
     243           0 :     aCancelBtn.Show();
     244           0 :     aHelpBtn.Show();
     245           0 :     aResetBtn.Show();
     246             : 
     247           0 :     SetPosSizeCtrls ( sal_True );
     248           0 : }
     249             : 
     250             : // -----------------------------------------------------------------------
     251             : 
     252           0 : IconChoiceDialog ::~IconChoiceDialog ()
     253             : {
     254             :     // save configuration at INI-Manager
     255             :     // and remove pages
     256           0 :     SvtViewOptions aTabDlgOpt( E_TABDIALOG, String::CreateFromInt32( nResId ) );
     257           0 :     aTabDlgOpt.SetWindowState(::rtl::OStringToOUString(GetWindowState((WINDOWSTATE_MASK_X | WINDOWSTATE_MASK_Y | WINDOWSTATE_MASK_STATE | WINDOWSTATE_MASK_MINIMIZED)), RTL_TEXTENCODING_ASCII_US));
     258           0 :     aTabDlgOpt.SetPageID( mnCurrentPageId );
     259             : 
     260           0 :     for ( size_t i = 0, nCount = maPageList.size(); i < nCount; ++i )
     261             :     {
     262           0 :         IconChoicePageData* pData = maPageList[ i ];
     263             : 
     264           0 :         if ( pData->pPage )
     265             :         {
     266           0 :             pData->pPage->FillUserData();
     267           0 :             String aPageData(pData->pPage->GetUserData());
     268           0 :             if ( aPageData.Len() )
     269             :             {
     270           0 :                 SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pData->nId ) );
     271             : 
     272           0 :                 SetViewOptUserItem( aTabPageOpt, aPageData );
     273             :             }
     274             : 
     275           0 :             if ( pData->bOnDemand )
     276           0 :                 delete (SfxItemSet*)&pData->pPage->GetItemSet();
     277           0 :             delete pData->pPage;
     278             :         }
     279           0 :         delete pData;
     280             :     }
     281             : 
     282             :     // remove Userdata from Icons
     283           0 :     for ( sal_uLong i=0; i < maIconCtrl.GetEntryCount(); i++)
     284             :     {
     285           0 :         SvxIconChoiceCtrlEntry* pEntry = maIconCtrl.GetEntry ( i );
     286           0 :         sal_uInt16* pUserData = (sal_uInt16*) pEntry->GetUserData();
     287           0 :         delete pUserData;
     288             :     }
     289             : 
     290             :     //
     291           0 :     if ( pRanges )
     292           0 :         delete pRanges;
     293           0 :     if ( pOutSet )
     294           0 :         delete pOutSet;
     295           0 : }
     296             : 
     297             : /**********************************************************************
     298             : |
     299             : | add new page
     300             : |
     301             : \**********************************************************************/
     302             : 
     303           0 : SvxIconChoiceCtrlEntry* IconChoiceDialog::AddTabPage(
     304             :     sal_uInt16          nId,
     305             :     const String&   rIconText,
     306             :     const Image&    rChoiceIcon,
     307             :     CreatePage      pCreateFunc /* != 0 */,
     308             :     GetPageRanges   pRangesFunc /* darf 0 sein */,
     309             :     sal_Bool            bItemsOnDemand,
     310             :     sal_uLong           /*nPos*/
     311             : )
     312             : {
     313             :     IconChoicePageData* pData = new IconChoicePageData ( nId, pCreateFunc,
     314             :                                                          pRangesFunc,
     315           0 :                                                          bItemsOnDemand );
     316           0 :     maPageList.push_back( pData );
     317             : 
     318           0 :     pData->fnGetRanges = pRangesFunc;
     319           0 :     pData->bOnDemand = bItemsOnDemand;
     320             : 
     321           0 :     sal_uInt16 *pId = new sal_uInt16 ( nId );
     322           0 :     SvxIconChoiceCtrlEntry* pEntry = maIconCtrl.InsertEntry( rIconText, rChoiceIcon );
     323           0 :     pEntry->SetUserData ( (void*) pId );
     324           0 :     return pEntry;
     325             : }
     326             : 
     327             : /**********************************************************************
     328             : |
     329             : | Paint-method
     330             : |
     331             : \**********************************************************************/
     332             : 
     333           0 : void IconChoiceDialog::Paint( const Rectangle& rRect )
     334             : {
     335           0 :     Dialog::Paint ( rRect );
     336             : 
     337           0 :     for ( size_t i = 0; i < maPageList.size(); i++ )
     338             :     {
     339           0 :         IconChoicePageData* pData = maPageList[ i ];
     340             : 
     341           0 :         if ( pData->nId == mnCurrentPageId )
     342             :         {
     343           0 :             ShowPageImpl ( pData );
     344             :         }
     345             :         else
     346             :         {
     347           0 :             HidePageImpl ( pData );
     348             :         }
     349             :     }
     350           0 : }
     351             : 
     352           0 : EIconChoicePos IconChoiceDialog::SetCtrlPos( const EIconChoicePos& rPos )
     353             : {
     354           0 :     WinBits aWinBits = maIconCtrl.GetStyle ();
     355             : 
     356           0 :     switch ( meChoicePos )
     357             :     {
     358             :         case PosLeft :
     359           0 :             aWinBits &= ~WB_ALIGN_TOP & ~WB_NOVSCROLL;
     360           0 :             aWinBits |= WB_ALIGN_LEFT | WB_NOHSCROLL;
     361           0 :             break;
     362             :         case PosRight :
     363           0 :             aWinBits &= ~WB_ALIGN_TOP & ~WB_NOVSCROLL;
     364           0 :             aWinBits |= WB_ALIGN_LEFT | WB_NOHSCROLL;
     365           0 :             break;
     366             :         case PosTop :
     367           0 :             aWinBits &= ~WB_ALIGN_LEFT & ~WB_NOHSCROLL;
     368           0 :             aWinBits |= WB_ALIGN_TOP | WB_NOVSCROLL;
     369           0 :             break;
     370             :         case PosBottom :
     371           0 :             aWinBits &= ~WB_ALIGN_LEFT & ~WB_NOHSCROLL;
     372           0 :             aWinBits |= WB_ALIGN_TOP | WB_NOVSCROLL;
     373           0 :             break;
     374             :     };
     375           0 :     maIconCtrl.SetStyle ( aWinBits );
     376             : 
     377           0 :     SetPosSizeCtrls();
     378             : 
     379             : 
     380           0 :     EIconChoicePos eOldPos = meChoicePos;
     381           0 :     meChoicePos = rPos;
     382             : 
     383           0 :     return eOldPos;
     384             : }
     385             : 
     386             : /**********************************************************************
     387             : |
     388             : | Show / Hide page or button
     389             : |
     390             : \**********************************************************************/
     391             : 
     392           0 : void IconChoiceDialog::ShowPageImpl ( IconChoicePageData* pData )
     393             : {
     394           0 :     if ( pData->pPage )
     395           0 :         pData->pPage->Show();
     396           0 : }
     397             : 
     398             : // -----------------------------------------------------------------------
     399             : 
     400           0 : void IconChoiceDialog::HidePageImpl ( IconChoicePageData* pData )
     401             : {
     402           0 :     if ( pData->pPage )
     403           0 :         pData->pPage->Hide();
     404           0 : }
     405             : 
     406             : // -----------------------------------------------------------------------
     407             : 
     408           0 : void IconChoiceDialog::ShowPage( sal_uInt16 nId )
     409             : {
     410           0 :     bool bInvalidate = GetCurPageId() != nId;
     411           0 :     SetCurPageId( nId );
     412           0 :     ActivatePageImpl( );
     413           0 :     if(bInvalidate)
     414           0 :         Invalidate();
     415           0 : }
     416             : 
     417             : /**********************************************************************
     418             : |
     419             : | Resize Dialog
     420             : |
     421             : \**********************************************************************/
     422             : 
     423             : #define ICONCTRL_WIDTH_PIXEL       110
     424             : #define ICONCTRL_HEIGHT_PIXEL       75
     425             : 
     426           0 : void IconChoiceDialog::Resize()
     427             : {
     428           0 :     Dialog::Resize ();
     429             : 
     430           0 :     if ( IsReallyVisible() )
     431             :     {
     432           0 :         SetPosSizeCtrls ();
     433             :     }
     434           0 : }
     435             : 
     436           0 : void IconChoiceDialog::SetPosSizeCtrls ( sal_Bool bInit )
     437             : {
     438           0 :     const Point aCtrlOffset ( LogicToPixel( Point( CTRLS_OFFSET, CTRLS_OFFSET ), MAP_APPFONT ) );
     439           0 :     Size aOutSize ( GetOutputSizePixel() );
     440             : 
     441             :     ////////////////////////////////////////
     442             :     // Button-Defaults
     443             :     //
     444           0 :     Size aDefaultButtonSize = LogicToPixel( Size( 50, 14 ), MAP_APPFONT );
     445             : 
     446             :     // Reset-Button
     447             :     Size aResetButtonSize ( bInit ? aDefaultButtonSize :
     448           0 :                                     aResetBtn.GetSizePixel () );
     449             : 
     450             :     ////////////////////////////////////////
     451             :     // IconChoiceCtrl resizen & positionieren
     452             :     //
     453           0 :     SvtTabAppearanceCfg aCfg;
     454           0 :     const long nDefaultWidth = (aCfg.GetScaleFactor() * ICONCTRL_WIDTH_PIXEL) / 100;
     455           0 :     const long nDefaultHeight = (aCfg.GetScaleFactor() * ICONCTRL_HEIGHT_PIXEL) / 100;
     456             : 
     457             :     Size aNewIconCtrlSize  ( nDefaultWidth,
     458           0 :                              aOutSize.Height()-(2*aCtrlOffset.X()) );
     459           0 :     Point aIconCtrlPos;
     460           0 :     switch ( meChoicePos )
     461             :     {
     462             :         case PosLeft :
     463           0 :             aIconCtrlPos = aCtrlOffset;
     464             :             aNewIconCtrlSize = Size ( nDefaultWidth,
     465           0 :                                       aOutSize.Height()-(2*aCtrlOffset.X()) );
     466           0 :             break;
     467             :         case PosRight :
     468           0 :             aIconCtrlPos = Point ( aOutSize.Width() - nDefaultWidth -
     469           0 :                                    aCtrlOffset.X(), aCtrlOffset.X() );
     470             :             aNewIconCtrlSize = Size ( nDefaultWidth,
     471           0 :                                       aOutSize.Height()-(2*aCtrlOffset.X()) );
     472           0 :             break;
     473             :         case PosTop :
     474           0 :             aIconCtrlPos = aCtrlOffset;
     475           0 :             aNewIconCtrlSize = Size ( aOutSize.Width()-(2*aCtrlOffset.X()),
     476           0 :                                       nDefaultHeight );
     477           0 :             break;
     478             :         case PosBottom :
     479           0 :             aIconCtrlPos = Point ( aCtrlOffset.X(), aOutSize.Height() -
     480           0 :                                    aResetButtonSize.Height() - (2*aCtrlOffset.X()) -
     481           0 :                                    nDefaultHeight );
     482           0 :             aNewIconCtrlSize = Size ( aOutSize.Width()-(2*aCtrlOffset.X()),
     483           0 :                                       nDefaultHeight );
     484           0 :             break;
     485             :     };
     486           0 :     maIconCtrl.SetPosSizePixel ( aIconCtrlPos, aNewIconCtrlSize );
     487           0 :     maIconCtrl.ArrangeIcons();
     488             : 
     489             :     ////////////////////////////////////////
     490             :     // resize & position the pages
     491             :     //
     492           0 :     for ( size_t i = 0; i < maPageList.size(); i++ )
     493             :     {
     494           0 :         IconChoicePageData* pData = maPageList[ i ];
     495             : 
     496           0 :         Point aNewPagePos;
     497           0 :         Size aNewPageSize;
     498           0 :         switch ( meChoicePos )
     499             :         {
     500             :             case PosLeft :
     501           0 :                 aNewPagePos = Point ( aNewIconCtrlSize.Width() + (2*CTRLS_OFFSET),
     502           0 :                                       CTRLS_OFFSET );
     503           0 :                 aNewPageSize = Size ( aOutSize.Width() - aNewIconCtrlSize.Width() -
     504             :                                       (3*CTRLS_OFFSET),
     505           0 :                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
     506           0 :                                       (3*CTRLS_OFFSET) );
     507           0 :                 break;
     508             :             case PosRight :
     509           0 :                 aNewPagePos = aCtrlOffset;
     510           0 :                 aNewPageSize = Size ( aOutSize.Width() - aNewIconCtrlSize.Width() -
     511           0 :                                       (3*aCtrlOffset.X()),
     512           0 :                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
     513           0 :                                       (3*aCtrlOffset.X()) );
     514           0 :                 break;
     515             :             case PosTop :
     516           0 :                 aNewPagePos = Point ( aCtrlOffset.X(), aNewIconCtrlSize.Height() +
     517           0 :                                       (2*aCtrlOffset.X()) );
     518           0 :                 aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
     519           0 :                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
     520           0 :                                       aNewIconCtrlSize.Height() - (4*aCtrlOffset.X()) );
     521           0 :                 break;
     522             :             case PosBottom :
     523           0 :                 aNewPagePos = aCtrlOffset;
     524           0 :                 aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
     525           0 :                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
     526           0 :                                       aNewIconCtrlSize.Height() - (4*aCtrlOffset.X()) );
     527           0 :                 break;
     528             :         };
     529             : 
     530           0 :         if ( pData->pPage )
     531           0 :             pData->pPage->SetPosSizePixel ( aNewPagePos, aNewPageSize );
     532             :     }
     533             : 
     534             :     ////////////////////////////////////////
     535             :     // position the buttons
     536             :     //
     537           0 :     sal_uLong nXOffset=0;
     538           0 :     if ( meChoicePos == PosRight )
     539           0 :         nXOffset = aNewIconCtrlSize.Width()+(2*aCtrlOffset.X());
     540             : 
     541           0 :     aResetBtn.SetPosSizePixel ( Point( aOutSize.Width() - nXOffset -
     542           0 :                                        aResetButtonSize.Width()-aCtrlOffset.X(),
     543           0 :                                        aOutSize.Height()-aResetButtonSize.Height()-
     544           0 :                                        aCtrlOffset.X() ),
     545           0 :                                aResetButtonSize );
     546             :     // Help-Button
     547             :     Size aHelpButtonSize ( bInit ? aDefaultButtonSize :
     548           0 :                                    aHelpBtn.GetSizePixel () );
     549           0 :     aHelpBtn.SetPosSizePixel ( Point( aOutSize.Width()-aResetButtonSize.Width()-
     550           0 :                                       aHelpButtonSize.Width()- nXOffset -
     551           0 :                                       (2*aCtrlOffset.X()),
     552           0 :                                       aOutSize.Height()-aHelpButtonSize.Height()-
     553           0 :                                       aCtrlOffset.X() ),
     554           0 :                                aHelpButtonSize );
     555             :     // Cancel-Button
     556             :     Size aCancelButtonSize ( bInit ? aDefaultButtonSize :
     557           0 :                                      aCancelBtn.GetSizePixel () );
     558           0 :     aCancelBtn.SetPosSizePixel ( Point( aOutSize.Width()-aCancelButtonSize.Width()-
     559           0 :                                         aResetButtonSize.Width()-aHelpButtonSize.Width()-
     560           0 :                                         (3*aCtrlOffset.X()) -  nXOffset,
     561           0 :                                         aOutSize.Height()-aCancelButtonSize.Height()-
     562           0 :                                         aCtrlOffset.X() ),
     563           0 :                                 aCancelButtonSize );
     564             :     // OK-Button
     565           0 :     Size aOKButtonSize ( bInit ? aDefaultButtonSize : aOKBtn.GetSizePixel () );
     566           0 :     aOKBtn.SetPosSizePixel ( Point( aOutSize.Width()-aOKButtonSize.Width()-
     567           0 :                                     aCancelButtonSize.Width()-aResetButtonSize.Width()-
     568           0 :                                     aHelpButtonSize.Width()-(4*aCtrlOffset.X())-  nXOffset,
     569           0 :                                     aOutSize.Height()-aOKButtonSize.Height()-aCtrlOffset.X() ),
     570           0 :                             aOKButtonSize );
     571             : 
     572           0 :     Invalidate();
     573           0 : }
     574             : 
     575           0 : void IconChoiceDialog::SetPosSizePages ( sal_uInt16 nId )
     576             : {
     577           0 :     const Point aCtrlOffset ( LogicToPixel( Point( CTRLS_OFFSET, CTRLS_OFFSET ), MAP_APPFONT ) );
     578           0 :     IconChoicePageData* pData = GetPageData ( nId );
     579             : 
     580           0 :     if ( pData->pPage )
     581             :     {
     582           0 :         Size aOutSize ( GetOutputSizePixel() );
     583           0 :         Size aIconCtrlSize ( maIconCtrl.GetSizePixel() );
     584             : 
     585           0 :         Point aNewPagePos;
     586           0 :         Size aNewPageSize;
     587           0 :         switch ( meChoicePos )
     588             :         {
     589             :             case PosLeft :
     590           0 :                 aNewPagePos = Point ( aIconCtrlSize.Width() + (2*aCtrlOffset.X()),
     591           0 :                                       aCtrlOffset.X() );
     592           0 :                 aNewPageSize = Size ( aOutSize.Width() - maIconCtrl.GetSizePixel().Width() -
     593           0 :                                       (3*aCtrlOffset.X()),
     594           0 :                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
     595           0 :                                       (3*aCtrlOffset.X()) );
     596           0 :                 break;
     597             :             case PosRight :
     598           0 :                 aNewPagePos = aCtrlOffset;
     599           0 :                 aNewPageSize = Size ( aOutSize.Width() - maIconCtrl.GetSizePixel().Width() -
     600           0 :                                       (3*aCtrlOffset.X()),
     601           0 :                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
     602           0 :                                       (3*aCtrlOffset.X()) );
     603           0 :                 break;
     604             :             case PosTop :
     605           0 :                 aNewPagePos = Point ( aCtrlOffset.X(), aIconCtrlSize.Height() +
     606           0 :                                       (2*aCtrlOffset.X()) );
     607           0 :                 aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
     608           0 :                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
     609           0 :                                       maIconCtrl.GetSizePixel().Height() - (4*aCtrlOffset.X()) );
     610           0 :                 break;
     611             :             case PosBottom :
     612           0 :                 aNewPagePos = aCtrlOffset;
     613           0 :                 aNewPageSize = Size ( aOutSize.Width() - (2*aCtrlOffset.X()),
     614           0 :                                       aOutSize.Height() - aOKBtn.GetSizePixel().Height() -
     615           0 :                                       maIconCtrl.GetSizePixel().Height() - (4*aCtrlOffset.X()) );
     616           0 :                 break;
     617             :         };
     618             : 
     619           0 :         pData->pPage->SetPosSizePixel ( aNewPagePos, aNewPageSize );
     620             :     }
     621           0 : }
     622             : 
     623             : /**********************************************************************
     624             : |
     625             : | select a page
     626             : |
     627             : \**********************************************************************/
     628             : 
     629           0 : IMPL_LINK_NOARG(IconChoiceDialog , ChosePageHdl_Impl)
     630             : {
     631             :     sal_uLong nPos;
     632             : 
     633           0 :     SvxIconChoiceCtrlEntry *pEntry = maIconCtrl.GetSelectedEntry ( nPos );
     634           0 :     if ( !pEntry )
     635           0 :         pEntry = maIconCtrl.GetCursor( );
     636             : 
     637           0 :     sal_uInt16 *pId = (sal_uInt16*)pEntry->GetUserData ();
     638             : 
     639           0 :     if( *pId != mnCurrentPageId )
     640             :     {
     641           0 :         IconChoicePageData* pData = GetPageData ( mnCurrentPageId );
     642           0 :         if ( pData->pPage )
     643           0 :             DeActivatePageImpl();
     644             : 
     645           0 :         SetCurPageId ( *pId );
     646             : 
     647           0 :         ActivatePageImpl();
     648           0 :         Invalidate();
     649             :     }
     650             : 
     651           0 :     return 0L;
     652             : }
     653             : 
     654             : /**********************************************************************
     655             : |
     656             : | Button-handler
     657             : |
     658             : \**********************************************************************/
     659             : 
     660           0 : IMPL_LINK_NOARG(IconChoiceDialog, OkHdl)
     661             : {
     662           0 :     bInOK = sal_True;
     663             : 
     664           0 :     if ( OK_Impl() )
     665             :     {
     666           0 :         if ( bModal )
     667           0 :             EndDialog( Ok() );
     668             :         else
     669             :         {
     670           0 :             Ok();
     671           0 :             Close();
     672             :         }
     673             :     }
     674           0 :     return 0;
     675             : }
     676             : 
     677             : // -----------------------------------------------------------------------
     678             : 
     679           0 : IMPL_LINK_NOARG(IconChoiceDialog, ResetHdl)
     680             : {
     681           0 :     ResetPageImpl ();
     682             : 
     683           0 :     IconChoicePageData* pData = GetPageData ( mnCurrentPageId );
     684             :     DBG_ASSERT( pData, "Id nicht bekannt" );
     685             : 
     686           0 :     if ( pData->bOnDemand )
     687             :     {
     688             :         // CSet on AIS has problems here, therefore seperated
     689           0 :         const SfxItemSet* _pSet = &( pData->pPage->GetItemSet() );
     690           0 :         pData->pPage->Reset( *(SfxItemSet*)_pSet );
     691             :     }
     692             :     else
     693           0 :         pData->pPage->Reset( *pSet );
     694             : 
     695             : 
     696           0 :     return 0;
     697             : }
     698             : 
     699             : // -----------------------------------------------------------------------
     700             : 
     701           0 : IMPL_LINK_NOARG(IconChoiceDialog, CancelHdl)
     702             : {
     703           0 :     Close();
     704             : 
     705           0 :     return 0;
     706             : }
     707             : 
     708             : /**********************************************************************
     709             : |
     710             : | call page
     711             : |
     712             : \**********************************************************************/
     713             : 
     714           0 : void IconChoiceDialog::ActivatePageImpl ()
     715             : {
     716             :     DBG_ASSERT( !maPageList.empty(), "keine Pages angemeldet" );
     717           0 :     IconChoicePageData* pData = GetPageData ( mnCurrentPageId );
     718             :     DBG_ASSERT( pData, "Id nicht bekannt" );
     719           0 :     bool bReadOnly = false;
     720           0 :     if ( pData )
     721             :     {
     722           0 :         if ( !pData->pPage )
     723             :         {
     724           0 :             const SfxItemSet* pTmpSet = 0;
     725             : 
     726           0 :             if ( pSet )
     727             :             {
     728           0 :                 if ( bItemsReset && pSet->GetParent() )
     729           0 :                     pTmpSet = pSet->GetParent();
     730             :                 else
     731           0 :                     pTmpSet = pSet;
     732             :             }
     733             : 
     734           0 :             if ( pTmpSet && !pData->bOnDemand )
     735           0 :                 pData->pPage = (pData->fnCreatePage)( this, *pTmpSet );
     736             :             else
     737           0 :                 pData->pPage = (pData->fnCreatePage)( this, *CreateInputItemSet( mnCurrentPageId ) );
     738             : 
     739           0 :             SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pData->nId ) );
     740           0 :             pData->pPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) );
     741           0 :             SetPosSizePages ( pData->nId );
     742             : 
     743           0 :             if ( pData->bOnDemand )
     744           0 :                 pData->pPage->Reset( (SfxItemSet &)pData->pPage->GetItemSet() );
     745             :             else
     746           0 :                 pData->pPage->Reset( *pSet );
     747             : 
     748           0 :             PageCreated( mnCurrentPageId, *pData->pPage );
     749             :         }
     750           0 :         else if ( pData->bRefresh )
     751             :         {
     752           0 :             pData->pPage->Reset( *pSet );
     753             :         }
     754             : 
     755           0 :         pData->bRefresh = sal_False;
     756             : 
     757           0 :         if ( pExampleSet )
     758           0 :             pData->pPage->ActivatePage( *pExampleSet );
     759           0 :         SetHelpId( pData->pPage->GetHelpId() );
     760           0 :         bReadOnly = pData->pPage->IsReadOnly();
     761             :     }
     762             : 
     763             : 
     764           0 :     if ( bReadOnly || bHideResetBtn )
     765           0 :         aResetBtn.Hide();
     766             :     else
     767           0 :         aResetBtn.Show();
     768             : 
     769           0 : }
     770             : 
     771             : // -----------------------------------------------------------------------
     772             : 
     773           0 : sal_Bool IconChoiceDialog::DeActivatePageImpl ()
     774             : {
     775           0 :     IconChoicePageData *pData = GetPageData ( mnCurrentPageId );
     776             : 
     777           0 :     int nRet = IconChoicePage::LEAVE_PAGE;
     778             : 
     779           0 :     if ( pData )
     780             :     {
     781           0 :         IconChoicePage * pPage = pData->pPage;
     782             : 
     783           0 :         if ( !pExampleSet && pPage->HasExchangeSupport() && pSet )
     784           0 :             pExampleSet = new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() );
     785             : 
     786           0 :         if ( pSet )
     787             :         {
     788           0 :             SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() );
     789             : 
     790           0 :             if ( pPage->HasExchangeSupport() )
     791           0 :                 nRet = pPage->DeactivatePage( &aTmp );
     792             : 
     793           0 :             if ( ( IconChoicePage::LEAVE_PAGE & nRet ) == IconChoicePage::LEAVE_PAGE &&
     794           0 :                  aTmp.Count() )
     795             :             {
     796           0 :                 pExampleSet->Put( aTmp );
     797           0 :                 pOutSet->Put( aTmp );
     798           0 :             }
     799             :         }
     800             :         else
     801             :         {
     802           0 :             if ( pPage->HasExchangeSupport() ) //!!!
     803             :             {
     804           0 :                 if ( !pExampleSet )
     805             :                 {
     806           0 :                     SfxItemPool* pPool = pPage->GetItemSet().GetPool();
     807             :                     pExampleSet =
     808           0 :                         new SfxItemSet( *pPool, GetInputRanges( *pPool ) );
     809             :                 }
     810           0 :                 nRet = pPage->DeactivatePage( pExampleSet );
     811             :             }
     812             :             else
     813           0 :                 nRet = pPage->DeactivatePage( NULL );
     814             :         }
     815             : 
     816           0 :         if ( nRet & IconChoicePage::REFRESH_SET )
     817             :         {
     818           0 :             pSet = GetRefreshedSet();
     819             :             DBG_ASSERT( pSet, "GetRefreshedSet() liefert NULL" );
     820             :             // flag all pages to be newly initialized
     821           0 :             for ( size_t i = 0, nCount = maPageList.size(); i < nCount; ++i )
     822             :             {
     823           0 :                 IconChoicePageData* pObj = maPageList[ i ];
     824           0 :                 if ( pObj->pPage != pPage )
     825           0 :                     pObj->bRefresh = sal_True;
     826             :                 else
     827           0 :                     pObj->bRefresh = sal_False;
     828             :             }
     829             :         }
     830             :     }
     831             : 
     832           0 :     if ( nRet & IconChoicePage::LEAVE_PAGE )
     833           0 :         return sal_True;
     834             :     else
     835           0 :         return sal_False;
     836             : }
     837             : 
     838             : // -----------------------------------------------------------------------
     839             : 
     840           0 : void IconChoiceDialog::ResetPageImpl ()
     841             : {
     842           0 :     IconChoicePageData *pData = GetPageData ( mnCurrentPageId );
     843             : 
     844             :     DBG_ASSERT( pData, "Id nicht bekannt" );
     845             : 
     846           0 :     if ( pData->bOnDemand )
     847             :     {
     848             :         // CSet on AIS has problems here, therefore seperated
     849           0 :         const SfxItemSet* _pSet = &pData->pPage->GetItemSet();
     850           0 :         pData->pPage->Reset( *(SfxItemSet*)_pSet );
     851             :     }
     852             :     else
     853           0 :         pData->pPage->Reset( *pSet );
     854           0 : }
     855             : 
     856             : /**********************************************************************
     857             : |
     858             : | handling itemsets
     859             : |
     860             : \**********************************************************************/
     861             : 
     862           0 : const sal_uInt16* IconChoiceDialog::GetInputRanges( const SfxItemPool& rPool )
     863             : {
     864           0 :     if ( pSet )
     865             :     {
     866             :         SAL_WARN( "cui.dialogs", "Set does already exist!" );
     867           0 :         return pSet->GetRanges();
     868             :     }
     869             : 
     870           0 :     if ( pRanges )
     871           0 :         return pRanges;
     872           0 :     std::vector<sal_uInt16> aUS;
     873             : 
     874           0 :     size_t nCount = maPageList.size();
     875           0 :     for ( size_t i = 0; i < nCount; ++i )
     876             :     {
     877           0 :         IconChoicePageData* pData = maPageList[ i ];
     878           0 :         if ( pData->fnGetRanges )
     879             :         {
     880           0 :             const sal_uInt16* pTmpRanges = (pData->fnGetRanges)();
     881           0 :             const sal_uInt16* pIter = pTmpRanges;
     882             : 
     883             :             sal_uInt16 nLen;
     884           0 :             for( nLen = 0; *pIter; ++nLen, ++pIter )
     885             :                 ;
     886           0 :             aUS.insert( aUS.end(), pTmpRanges, pTmpRanges + nLen );
     887             :         }
     888             :     }
     889             : 
     890             :     // remove double Id's
     891             :     {
     892           0 :         nCount = aUS.size();
     893           0 :         for ( size_t i = 0; i < nCount; ++i )
     894           0 :             aUS[i] = rPool.GetWhich( aUS[i] );
     895             :     }
     896             : 
     897           0 :     if ( aUS.size() > 1 )
     898             :     {
     899           0 :         std::sort( aUS.begin(), aUS.end() );
     900             :     }
     901             : 
     902           0 :     pRanges = new sal_uInt16[aUS.size() + 1];
     903           0 :     std::copy( aUS.begin(), aUS.end(), pRanges );
     904           0 :     pRanges[aUS.size()] = 0;
     905             : 
     906           0 :     return pRanges;
     907             : }
     908             : 
     909             : // -----------------------------------------------------------------------
     910             : 
     911           0 : void IconChoiceDialog::SetInputSet( const SfxItemSet* pInSet )
     912             : {
     913           0 :     bool bSet = ( pSet != NULL );
     914             : 
     915           0 :     pSet = pInSet;
     916             : 
     917           0 :     if ( !bSet && !pExampleSet && !pOutSet )
     918             :     {
     919           0 :         pExampleSet = new SfxItemSet( *pSet );
     920           0 :         pOutSet = new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() );
     921             :     }
     922           0 : }
     923             : 
     924             : // -----------------------------------------------------------------------
     925             : 
     926           0 : void IconChoiceDialog::PageCreated( sal_uInt16 /*nId*/, IconChoicePage& /*rPage*/ )
     927             : {
     928             :     // not interested in
     929           0 : }
     930             : 
     931             : // -----------------------------------------------------------------------
     932             : 
     933           0 : SfxItemSet* IconChoiceDialog::CreateInputItemSet( sal_uInt16 )
     934             : {
     935             :     SAL_INFO( "cui.dialogs", "CreateInputItemSet not implemented" );
     936             : 
     937           0 :     return 0;
     938             : }
     939             : 
     940             : /**********************************************************************
     941             : |
     942             : | start dialog
     943             : |
     944             : \**********************************************************************/
     945             : 
     946           0 : short IconChoiceDialog::Execute()
     947             : {
     948           0 :     if ( maPageList.empty() )
     949           0 :         return RET_CANCEL;
     950             : 
     951           0 :     Start_Impl();
     952             : 
     953           0 :     return Dialog::Execute();
     954             : }
     955             : 
     956             : // -----------------------------------------------------------------------
     957             : 
     958           0 : void IconChoiceDialog::Start( sal_Bool bShow )
     959             : {
     960             : 
     961           0 :     aCancelBtn.SetClickHdl( LINK( this, IconChoiceDialog, CancelHdl ) );
     962           0 :     bModal = sal_False;
     963             : 
     964           0 :     Start_Impl();
     965             : 
     966           0 :     if ( bShow )
     967           0 :         Window::Show();
     968             : 
     969           0 : }
     970             : 
     971             : // -----------------------------------------------------------------------
     972             : 
     973           0 : sal_Bool IconChoiceDialog::QueryClose()
     974             : {
     975           0 :     sal_Bool bRet = sal_True;
     976           0 :     for ( size_t i = 0, nCount = maPageList.size(); i < nCount; ++i )
     977             :     {
     978           0 :         IconChoicePageData* pData = maPageList[i ];
     979           0 :         if ( pData->pPage && !pData->pPage->QueryClose() )
     980             :         {
     981           0 :             bRet = sal_False;
     982           0 :             break;
     983             :         }
     984             :     }
     985           0 :     return bRet;
     986             : }
     987             : 
     988             : // -----------------------------------------------------------------------
     989             : 
     990           0 : void IconChoiceDialog::Start_Impl()
     991             : {
     992           0 :     Point aPos;
     993             :     sal_uInt16 nActPage;
     994             : 
     995           0 :     if ( mnCurrentPageId == 0 || mnCurrentPageId == USHRT_MAX )
     996           0 :         nActPage = maPageList.front()->nId;
     997             :     else
     998           0 :         nActPage = mnCurrentPageId;
     999             : 
    1000             :     // configuration existing?
    1001           0 :     SvtViewOptions aTabDlgOpt( E_TABDIALOG, String::CreateFromInt32( nResId ) );
    1002             : 
    1003           0 :     if ( aTabDlgOpt.Exists() )
    1004             :     {
    1005             :         // possibly position from config
    1006           0 :         SetWindowState(rtl::OUStringToOString(aTabDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US));
    1007             : 
    1008             :         // initial TabPage from program/help/config
    1009           0 :         nActPage = (sal_uInt16)aTabDlgOpt.GetPageID();
    1010             : 
    1011           0 :         if ( USHRT_MAX != mnCurrentPageId )
    1012           0 :             nActPage = mnCurrentPageId;
    1013             : 
    1014           0 :         if ( GetPageData ( nActPage ) == NULL )
    1015           0 :             nActPage = maPageList.front()->nId;
    1016             :     }
    1017           0 :     else if ( USHRT_MAX != mnCurrentPageId && GetPageData ( mnCurrentPageId ) != NULL )
    1018           0 :         nActPage = mnCurrentPageId;
    1019             : 
    1020           0 :     mnCurrentPageId = nActPage;
    1021             : 
    1022           0 :     FocusOnIcon( mnCurrentPageId );
    1023             : 
    1024           0 :     ActivatePageImpl();
    1025           0 : }
    1026             : 
    1027             : // -----------------------------------------------------------------------
    1028             : 
    1029           0 : const SfxItemSet* IconChoiceDialog::GetRefreshedSet()
    1030             : {
    1031             :     SAL_WARN( "cui.dialogs", "GetRefreshedSet not implemented" );
    1032           0 :     return 0;
    1033             : }
    1034             : 
    1035             : /**********************************************************************
    1036             : |
    1037             : | tool-methods
    1038             : |
    1039             : \**********************************************************************/
    1040             : 
    1041           0 : IconChoicePageData* IconChoiceDialog::GetPageData ( sal_uInt16 nId )
    1042             : {
    1043           0 :     IconChoicePageData *pRet = NULL;
    1044           0 :     for ( size_t i=0; i < maPageList.size(); i++ )
    1045             :     {
    1046           0 :         IconChoicePageData* pData = maPageList[ i ];
    1047           0 :         if ( pData->nId == nId )
    1048             :         {
    1049           0 :             pRet = pData;
    1050           0 :             break;
    1051             :         }
    1052             :     }
    1053           0 :     return pRet;
    1054             : }
    1055             : 
    1056             : /**********************************************************************
    1057             : |
    1058             : | OK-Status
    1059             : |
    1060             : \**********************************************************************/
    1061             : 
    1062           0 : sal_Bool IconChoiceDialog::OK_Impl()
    1063             : {
    1064           0 :     IconChoicePage* pPage = GetPageData ( mnCurrentPageId )->pPage;
    1065             : 
    1066           0 :     bool bEnd = !pPage;
    1067           0 :     if ( pPage )
    1068             :     {
    1069           0 :         int nRet = IconChoicePage::LEAVE_PAGE;
    1070           0 :         if ( pSet )
    1071             :         {
    1072           0 :             SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() );
    1073           0 :             sal_Bool bRet = sal_False;
    1074             : 
    1075           0 :             if ( pPage->HasExchangeSupport() )
    1076           0 :                 nRet = pPage->DeactivatePage( &aTmp );
    1077             : 
    1078           0 :             if ( ( IconChoicePage::LEAVE_PAGE & nRet ) == IconChoicePage::LEAVE_PAGE
    1079           0 :                  && aTmp.Count() )
    1080             :             {
    1081           0 :                 pExampleSet->Put( aTmp );
    1082           0 :                 pOutSet->Put( aTmp );
    1083             :             }
    1084           0 :             else if ( bRet )
    1085           0 :                 bModified |= sal_True;
    1086             :         }
    1087             :         else
    1088           0 :             nRet = pPage->DeactivatePage( NULL );
    1089           0 :         bEnd = nRet;
    1090             :     }
    1091             : 
    1092           0 :     return bEnd;
    1093             : }
    1094             : 
    1095             : // -----------------------------------------------------------------------
    1096             : 
    1097           0 : short IconChoiceDialog::Ok()
    1098             : {
    1099           0 :     bInOK = sal_True;
    1100             : 
    1101           0 :     if ( !pOutSet )
    1102             :     {
    1103           0 :         if ( !pExampleSet && pSet )
    1104           0 :             pOutSet = pSet->Clone( sal_False ); // without items
    1105           0 :         else if ( pExampleSet )
    1106           0 :             pOutSet = new SfxItemSet( *pExampleSet );
    1107             :     }
    1108           0 :     sal_Bool _bModified = sal_False;
    1109             : 
    1110           0 :     for ( size_t i = 0, nCount = maPageList.size(); i < nCount; ++i )
    1111             :     {
    1112           0 :         IconChoicePageData* pData = GetPageData ( i );
    1113             : 
    1114           0 :         IconChoicePage* pPage = pData->pPage;
    1115             : 
    1116           0 :         if ( pPage )
    1117             :         {
    1118           0 :             if ( pData->bOnDemand )
    1119             :             {
    1120           0 :                 SfxItemSet& rSet = (SfxItemSet&)pPage->GetItemSet();
    1121           0 :                 rSet.ClearItem();
    1122           0 :                 _bModified |= pPage->FillItemSet( rSet );
    1123             :             }
    1124           0 :             else if ( pSet && !pPage->HasExchangeSupport() )
    1125             :             {
    1126           0 :                 SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() );
    1127             : 
    1128           0 :                 if ( pPage->FillItemSet( aTmp ) )
    1129             :                 {
    1130           0 :                     _bModified |= sal_True;
    1131           0 :                     pExampleSet->Put( aTmp );
    1132           0 :                     pOutSet->Put( aTmp );
    1133           0 :                 }
    1134             :             }
    1135             :         }
    1136             :     }
    1137             : 
    1138           0 :     if ( _bModified || ( pOutSet && pOutSet->Count() > 0 ) )
    1139           0 :         _bModified |= sal_True;
    1140             : 
    1141           0 :     return _bModified ? RET_OK : RET_CANCEL;
    1142             : }
    1143             : 
    1144             : // -----------------------------------------------------------------------
    1145             : 
    1146           0 : void IconChoiceDialog::FocusOnIcon( sal_uInt16 nId )
    1147             : {
    1148             :     // set focus to icon for the current visible page
    1149           0 :     for ( sal_uInt16 i=0; i<maIconCtrl.GetEntryCount(); i++)
    1150             :     {
    1151           0 :         SvxIconChoiceCtrlEntry* pEntry = maIconCtrl.GetEntry ( i );
    1152           0 :         sal_uInt16* pUserData = (sal_uInt16*) pEntry->GetUserData();
    1153             : 
    1154           0 :         if ( pUserData && *pUserData == nId )
    1155             :         {
    1156           0 :             maIconCtrl.SetCursor( pEntry );
    1157           0 :             break;
    1158             :         }
    1159             :     }
    1160           0 : }
    1161             : 
    1162             : 
    1163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10