LCOV - code coverage report
Current view: top level - sfx2/source/dialog - templdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 592 1370 43.2 %
Date: 2012-08-25 Functions: 60 187 32.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 497 2230 22.3 %

           Branch data     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 <boost/noncopyable.hpp>
      21                 :            : #include <boost/scoped_ptr.hpp>
      22                 :            : 
      23                 :            : #include <vcl/menu.hxx>
      24                 :            : #include <svl/intitem.hxx>
      25                 :            : #include <svl/stritem.hxx>
      26                 :            : #include <svl/style.hxx>
      27                 :            : #include <comphelper/processfactory.hxx>
      28                 :            : #include <comphelper/sequenceashashmap.hxx>
      29                 :            : #include <unotools/intlwrapper.hxx>
      30                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      31                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      32                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      33                 :            : #include <com/sun/star/frame/XModuleManager.hpp>
      34                 :            : 
      35                 :            : #include "sfx2/sfxhelp.hxx"
      36                 :            : #include <sfx2/app.hxx>
      37                 :            : #include <sfx2/dispatch.hxx>
      38                 :            : #include <sfx2/bindings.hxx>
      39                 :            : #include <sfx2/templdlg.hxx>
      40                 :            : #include "templdgi.hxx"
      41                 :            : #include "tplcitem.hxx"
      42                 :            : #include "sfxtypes.hxx"
      43                 :            : #include <sfx2/styfitem.hxx>
      44                 :            : #include <sfx2/objsh.hxx>
      45                 :            : #include <sfx2/viewsh.hxx>
      46                 :            : #include <sfx2/newstyle.hxx>
      47                 :            : #include "sfx2/tplpitem.hxx"
      48                 :            : #include "sfx2/sfxresid.hxx"
      49                 :            : 
      50                 :            : #include "templdlg.hrc"
      51                 :            : #include <sfx2/sfx.hrc>
      52                 :            : #include "dialog.hrc"
      53                 :            : #include "arrdecl.hxx"
      54                 :            : #include "fltfnc.hxx"
      55                 :            : #include <sfx2/docfilt.hxx>
      56                 :            : #include <sfx2/docfac.hxx>
      57                 :            : #include "docvor.hxx"
      58                 :            : #include <sfx2/doctempl.hxx>
      59                 :            : #include <sfx2/module.hxx>
      60                 :            : #include "sfx2/imgmgr.hxx"
      61                 :            : #include "helpid.hrc"
      62                 :            : #include "appdata.hxx"
      63                 :            : #include <sfx2/viewfrm.hxx>
      64                 :            : 
      65                 :            : #include <comphelper/configurationhelper.hxx>
      66                 :            : #include <comphelper/string.hxx>
      67                 :            : 
      68                 :            : using namespace ::com::sun::star;
      69                 :            : using namespace ::com::sun::star::beans;
      70                 :            : using namespace ::com::sun::star::frame;
      71                 :            : using namespace ::com::sun::star::uno;
      72                 :            : 
      73                 :            : //=========================================================================
      74                 :            : // Window is now created dynamically. So here margins, etc.
      75                 :            : 
      76                 :            : #define SFX_TEMPLDLG_HFRAME         3
      77                 :            : #define SFX_TEMPLDLG_VTOPFRAME      3
      78                 :            : 
      79                 :            : #define SFX_TEMPLDLG_VBOTFRAME      3
      80                 :            : #define SFX_TEMPLDLG_MIDHSPACE      3
      81                 :            : #define SFX_TEMPLDLG_MIDVSPACE      3
      82                 :            : #define SFX_TEMPLDLG_FILTERHEIGHT   100
      83                 :            : 
      84                 :            : static sal_uInt16 nLastItemId = USHRT_MAX;
      85                 :            : 
      86                 :            : // filter box has maximum 12 entries visible
      87                 :            : #define MAX_FILTER_ENTRIES          12
      88                 :            : 
      89                 :            : //=========================================================================
      90                 :            : 
      91         [ #  # ]:          0 : TYPEINIT0(SfxCommonTemplateDialog_Impl);
      92 [ #  # ][ #  # ]:          0 : TYPEINIT1(SfxTemplateDialog_Impl,SfxCommonTemplateDialog_Impl);
      93 [ #  # ][ #  # ]:          0 : TYPEINIT1(SfxTemplateCatalog_Impl,SfxCommonTemplateDialog_Impl);
      94                 :            : 
      95 [ +  - ][ +  - ]:      10492 : SFX_IMPL_DOCKINGWINDOW_WITHID(SfxTemplateDialogWrapper, SID_STYLE_DESIGNER)
                 [ +  - ]
      96                 :            : 
      97                 :            : //-------------------------------------------------------------------------
      98                 :            : 
      99                 :            : class SfxCommonTemplateDialog_Impl::DeletionWatcher : private boost::noncopyable
     100                 :            : {
     101                 :            :     typedef void (DeletionWatcher::* bool_type)();
     102                 :            : 
     103                 :            : public:
     104                 :          0 :     explicit DeletionWatcher(SfxCommonTemplateDialog_Impl& rDialog)
     105                 :          0 :         : m_pDialog(&rDialog)
     106                 :            :     {
     107                 :          0 :         m_pDialog->impl_setDeletionWatcher(this);
     108                 :          0 :     }
     109                 :            : 
     110                 :          0 :     ~DeletionWatcher()
     111                 :          0 :     {
     112         [ #  # ]:          0 :         if (m_pDialog)
     113                 :          0 :             m_pDialog->impl_setDeletionWatcher(0);
     114                 :          0 :     }
     115                 :            : 
     116                 :            :     // Signal that the dialog was deleted
     117                 :          0 :     void signal()
     118                 :            :     {
     119                 :          0 :         m_pDialog = 0;
     120                 :          0 :     }
     121                 :            : 
     122                 :            :     // Return true if the dialog was deleted
     123                 :          0 :     operator bool_type() const
     124                 :            :     {
     125         [ #  # ]:          0 :         return m_pDialog ? 0 : &DeletionWatcher::signal;
     126                 :            :     }
     127                 :            : 
     128                 :            : private:
     129                 :            :     SfxCommonTemplateDialog_Impl* m_pDialog;
     130                 :            : };
     131                 :            : 
     132                 :            : // Re-direct functions
     133                 :            : 
     134                 :        120 : SfxTemplateDialog::SfxTemplateDialog
     135                 :            : (
     136                 :            :     SfxBindings *pBind,
     137                 :            :     SfxChildWindow *pCW,
     138                 :            :     Window *pParent
     139                 :            : )
     140                 :            : 
     141                 :            : /*  [Description]
     142                 :            :     Designer class.
     143                 :            : */
     144                 :            :     : SfxDockingWindow( pBind, pCW, pParent, SfxResId(DLG_STYLE_DESIGNER) ),
     145                 :            : 
     146 [ +  - ][ +  - ]:        120 :     pImpl( new SfxTemplateDialog_Impl( pParent, pBind, this ) )
                 [ +  - ]
     147                 :            : 
     148                 :            : {
     149         [ +  - ]:        120 :     pImpl->updateNonFamilyImages();
     150                 :        120 : }
     151                 :            : 
     152                 :            : //-------------------------------------------------------------------------
     153                 :            : 
     154                 :        120 : SfxTemplateDialog::~SfxTemplateDialog()
     155                 :            : {
     156 [ +  - ][ +  - ]:        120 :     delete pImpl;
     157         [ -  + ]:        240 : }
     158                 :            : 
     159                 :       1228 : ISfxTemplateCommon* SfxTemplateDialog::GetISfxTemplateCommon()
     160                 :            : {
     161                 :       1228 :     return pImpl->GetISfxTemplateCommon();
     162                 :            : }
     163                 :            : 
     164                 :          0 : void SfxTemplateDialog::SetParagraphFamily()
     165                 :            : {
     166                 :            :     // first select the paragraph family
     167                 :          0 :     pImpl->FamilySelect( SFX_STYLE_FAMILY_PARA );
     168                 :            :     // then select the automatic filter
     169                 :          0 :     pImpl->SetAutomaticFilter();
     170                 :          0 : }
     171                 :            : 
     172                 :            : // ------------------------------------------------------------------------
     173                 :            : 
     174                 :          0 : void SfxTemplateDialog::DataChanged( const DataChangedEvent& _rDCEvt )
     175                 :            : {
     176   [ #  #  #  # ]:          0 :     if ( ( DATACHANGED_SETTINGS == _rDCEvt.GetType() ) &&
                 [ #  # ]
     177                 :          0 :          ( 0 != ( SETTINGS_STYLE & _rDCEvt.GetFlags() ) ) )
     178                 :            :     {
     179                 :          0 :         pImpl->updateFamilyImages();
     180                 :          0 :         pImpl->updateNonFamilyImages();
     181                 :            :     }
     182                 :            : 
     183                 :          0 :     SfxDockingWindow::DataChanged( _rDCEvt );
     184                 :          0 : }
     185                 :            : 
     186                 :            : //-------------------------------------------------------------------------
     187                 :            : 
     188                 :          0 : void SfxTemplateDialog::Update()
     189                 :            : {
     190                 :          0 :     pImpl->Update();
     191                 :          0 : }
     192                 :            : 
     193                 :            : //-------------------------------------------------------------------------
     194                 :            : 
     195                 :        121 : void SfxTemplateDialog::Resize()
     196                 :            : {
     197         [ +  - ]:        121 :     if(pImpl)
     198                 :        121 :         pImpl->Resize();
     199                 :        121 :     SfxDockingWindow::Resize();
     200                 :        121 : }
     201                 :            : 
     202                 :            : 
     203                 :            : //-------------------------------------------------------------------------
     204                 :            : 
     205                 :        120 : SfxChildAlignment SfxTemplateDialog::CheckAlignment(SfxChildAlignment eActAlign,SfxChildAlignment eAlign)
     206                 :            : {
     207      [ -  +  - ]:        120 :     switch (eAlign)
     208                 :            :     {
     209                 :            :         case SFX_ALIGN_TOP:
     210                 :            :         case SFX_ALIGN_HIGHESTTOP:
     211                 :            :         case SFX_ALIGN_LOWESTTOP:
     212                 :            :         case SFX_ALIGN_BOTTOM:
     213                 :            :         case SFX_ALIGN_LOWESTBOTTOM:
     214                 :            :         case SFX_ALIGN_HIGHESTBOTTOM:
     215                 :          0 :             return eActAlign;
     216                 :            : 
     217                 :            :         case SFX_ALIGN_LEFT:
     218                 :            :         case SFX_ALIGN_RIGHT:
     219                 :            :         case SFX_ALIGN_FIRSTLEFT:
     220                 :            :         case SFX_ALIGN_LASTLEFT:
     221                 :            :         case SFX_ALIGN_FIRSTRIGHT:
     222                 :            :         case SFX_ALIGN_LASTRIGHT:
     223                 :        120 :             return eAlign;
     224                 :            : 
     225                 :            :         default:
     226                 :        120 :             return eAlign;
     227                 :            :     }
     228                 :            : }
     229                 :            : 
     230                 :            : //-------------------------------------------------------------------------
     231                 :            : 
     232                 :          0 : SfxTemplateCatalog::SfxTemplateCatalog(Window *pParent, SfxBindings *pBindings)
     233         [ #  # ]:          0 :  : SfxModalDialog(pParent,SfxResId(RID_STYLECATALOG))
     234                 :            : {
     235 [ #  # ][ #  # ]:          0 :     pImpl = new SfxTemplateCatalog_Impl(pParent, pBindings, this);
     236                 :          0 : }
     237                 :            : 
     238                 :            : //-------------------------------------------------------------------------
     239                 :            : 
     240                 :          0 : SfxTemplateCatalog::~SfxTemplateCatalog()
     241                 :            : {
     242 [ #  # ][ #  # ]:          0 :     delete pImpl;
     243         [ #  # ]:          0 : }
     244                 :            : 
     245                 :            : //-------------------------------------------------------------------------
     246                 :            : 
     247                 :          0 : void DropListBox_Impl::MouseButtonDown( const MouseEvent& rMEvt )
     248                 :            : {
     249                 :          0 :     nModifier = rMEvt.GetModifier();
     250                 :            : 
     251                 :          0 :     sal_Bool bHitEmptySpace = ( NULL == GetEntry( rMEvt.GetPosPixel(), sal_True ) );
     252 [ #  # ][ #  # ]:          0 :     if( bHitEmptySpace && ( rMEvt.GetClicks() == 2 ) && rMEvt.IsMod1() )
         [ #  # ][ #  # ]
     253                 :          0 :         Control::MouseButtonDown( rMEvt );
     254                 :            :     else
     255                 :          0 :         SvTreeListBox::MouseButtonDown( rMEvt );
     256                 :          0 : }
     257                 :            : 
     258                 :          0 : sal_Int8 DropListBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt )
     259                 :            : 
     260                 :            : /*  [Description: ]
     261                 :            :     Drop is enabled as long as it is allowed to create a new style by example, i.e. to
     262                 :            :     create a style out of the current selection.
     263                 :            : */
     264                 :            : 
     265                 :            : {
     266         [ #  # ]:          0 :     if ( IsDropFormatSupported( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
     267                 :            :     {
     268                 :            :         // special case: page styles are allowed to create new styles by example
     269                 :            :         // but not allowed to be created by drag and drop
     270 [ #  # ][ #  # ]:          0 :         if( pDialog->nActFamily == SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE ) ||
                 [ #  # ]
     271                 :            :                 pDialog->bNewByExampleDisabled )
     272                 :          0 :             return DND_ACTION_NONE;
     273                 :            :         else
     274                 :          0 :             return DND_ACTION_COPY;
     275                 :            :     }
     276                 :          0 :     return SvTreeListBox::AcceptDrop( rEvt );
     277                 :            : }
     278                 :            : 
     279                 :            : //-------------------------------------------------------------------------
     280                 :            : 
     281                 :          0 : sal_Int8 DropListBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt )
     282                 :            : {
     283                 :          0 :     sal_Int8 nRet = DND_ACTION_NONE;
     284                 :          0 :     SfxObjectShell* pDocShell = pDialog->GetObjectShell();
     285         [ #  # ]:          0 :     TransferableDataHelper aHelper( rEvt.maDropEvent.Transferable );
     286         [ #  # ]:          0 :     sal_uInt32 nFormatCount = aHelper.GetFormatCount();
     287         [ #  # ]:          0 :     if ( pDocShell )
     288                 :            :     {
     289                 :          0 :         sal_Bool bFormatFound = sal_False;
     290                 :            : 
     291         [ #  # ]:          0 :         for ( sal_uInt32 i = 0; i < nFormatCount; ++i )
     292                 :            :         {
     293         [ #  # ]:          0 :             SotFormatStringId nId = aHelper.GetFormat(i);
     294         [ #  # ]:          0 :             TransferableObjectDescriptor aDesc;
     295                 :            : 
     296 [ #  # ][ #  # ]:          0 :             if ( aHelper.GetTransferableObjectDescriptor( nId, aDesc ) )
     297                 :            :             {
     298 [ #  # ][ #  # ]:          0 :                 if ( aDesc.maClassName == pDocShell->GetFactory().GetClassId() )
         [ #  # ][ #  # ]
     299                 :            :                 {
     300 [ #  # ][ #  # ]:          0 :                     PostUserEvent( LINK( this, DropListBox_Impl, OnAsyncExecuteDrop ), 0 );
     301                 :            : 
     302                 :          0 :                     bFormatFound = sal_True;
     303                 :          0 :                     nRet =  rEvt.mnAction;
     304                 :            :                     break;
     305                 :            :                 }
     306                 :            :             }
     307 [ #  # ][ #  # ]:          0 :         }
     308                 :            : 
     309         [ #  # ]:          0 :         if ( !bFormatFound )
     310         [ #  # ]:          0 :             return SvTreeListBox::ExecuteDrop( rEvt );
     311                 :            :     }
     312                 :            : 
     313         [ #  # ]:          0 :     return nRet;
     314                 :            : }
     315                 :            : 
     316                 :            : 
     317                 :          0 : IMPL_LINK_NOARG(DropListBox_Impl, OnAsyncExecuteDrop)
     318                 :            : {
     319                 :          0 :     pDialog->ActionSelect( SID_STYLE_NEW_BY_EXAMPLE );
     320                 :          0 :     return 0;
     321                 :            : }
     322                 :            : 
     323                 :          2 : long DropListBox_Impl::Notify( NotifyEvent& rNEvt )
     324                 :            : {
     325                 :          2 :     long nRet = 0;
     326         [ -  + ]:          2 :     if( rNEvt.GetType() == EVENT_KEYINPUT )
     327                 :            :     {
     328                 :          0 :         const KeyCode&  rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
     329         [ #  # ]:          0 :         if(!rKeyCode.GetModifier())
     330                 :            :         {
     331 [ #  # ][ #  # ]:          0 :             if( pDialog->bCanDel && KEY_DELETE == rKeyCode.GetCode())
                 [ #  # ]
     332                 :            :             {
     333                 :          0 :                 pDialog->DeleteHdl( NULL );
     334                 :          0 :                 nRet =  1;
     335                 :            :             }
     336         [ #  # ]:          0 :             else if( KEY_RETURN == rKeyCode.GetCode())
     337                 :            :             {
     338                 :          0 :                 GetDoubleClickHdl().Call(this);
     339                 :          0 :                 nRet = 1;
     340                 :            :             }
     341                 :            :         }
     342                 :            :     }
     343         [ +  - ]:          2 :     if(!nRet)
     344                 :          2 :         nRet = SvTreeListBox::Notify( rNEvt );
     345                 :          2 :     return nRet;
     346                 :            : }
     347                 :            : 
     348                 :            : 
     349                 :            : //-------------------------------------------------------------------------
     350                 :            : 
     351                 :            : 
     352                 :        120 : SfxActionListBox::SfxActionListBox
     353                 :            : (
     354                 :            :     SfxCommonTemplateDialog_Impl* pParent,
     355                 :            :     WinBits nWinBits
     356                 :            : )
     357                 :            : 
     358                 :            : /*  [Description]
     359                 :            : 
     360                 :            :     ListBox class that starts a PopupMenu (designer specific) in the
     361                 :            :     command handler.
     362                 :            : */
     363                 :            : 
     364                 :        120 : :       DropListBox_Impl(pParent->GetWindow(), nWinBits, pParent)
     365                 :            : 
     366                 :            : {
     367         [ +  - ]:        120 :     EnableContextMenuHandling();
     368                 :        120 : }
     369                 :            : 
     370                 :            : //-------------------------------------------------------------------------
     371                 :            : 
     372                 :          0 : SfxActionListBox::SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent,
     373                 :            :                                     const ResId &rResId) :
     374                 :          0 :     DropListBox_Impl(pParent->GetWindow(), rResId, pParent)
     375                 :            : {
     376         [ #  # ]:          0 :     EnableContextMenuHandling();
     377                 :          0 : }
     378                 :            : 
     379                 :            : //-------------------------------------------------------------------------
     380                 :            : 
     381                 :          0 : PopupMenu* SfxActionListBox::CreateContextMenu( void )
     382                 :            : {
     383                 :            : 
     384         [ #  # ]:          0 :     if( !( GetSelectionCount() > 0 ) )
     385                 :            :     {
     386                 :          0 :         pDialog->EnableEdit( sal_False );
     387                 :          0 :         pDialog->EnableDel( sal_False );
     388                 :            :     }
     389                 :          0 :     return pDialog->CreateContextMenu();
     390                 :            : }
     391                 :            : 
     392                 :            : //-------------------------------------------------------------------------
     393                 :            : 
     394                 :        120 : SfxTemplateDialogWrapper::SfxTemplateDialogWrapper(Window *pParentWnd,
     395                 :            :         sal_uInt16 nId,  SfxBindings *p, SfxChildWinInfo *pInfo) :
     396                 :        120 :     SfxChildWindow(pParentWnd, nId)
     397                 :            : {
     398 [ +  - ][ +  - ]:        120 :     SfxTemplateDialog *pWin = new SfxTemplateDialog(p, this, pParentWnd);
     399                 :        120 :     pWindow = pWin;
     400                 :        120 :     eChildAlignment = SFX_ALIGN_NOALIGNMENT;
     401                 :            : 
     402         [ +  - ]:        120 :     pWin->Initialize( pInfo );
     403 [ +  - ][ +  - ]:        120 :     pWin->SetMinOutputSizePixel(pWin->pImpl->GetMinOutputSizePixel());
     404                 :        120 : }
     405                 :            : 
     406                 :          0 : void SfxTemplateDialogWrapper::SetParagraphFamily()
     407                 :            : {
     408                 :            :     // forward to SfxTemplateDialog, because SfxTemplateDialog isn't exported
     409                 :          0 :     static_cast< SfxTemplateDialog* >( GetWindow() )->SetParagraphFamily();
     410                 :          0 : }
     411                 :            : 
     412                 :            : //=========================================================================
     413                 :            : typedef std::vector<rtl::OUString> ExpandedEntries_t;
     414                 :            : 
     415                 :            : /*  [Description]
     416                 :            : 
     417                 :            :     TreeListBox class for displaying the hierarchical view of the templates
     418                 :            : */
     419                 :            : 
     420 [ #  # ][ #  # ]:          0 : class StyleTreeListBox_Impl : public DropListBox_Impl
                 [ #  # ]
     421                 :            : {
     422                 :            : private:
     423                 :            :     SvLBoxEntry*                    pCurEntry;
     424                 :            :     Link                            aDoubleClickLink;
     425                 :            :     Link                            aDropLink;
     426                 :            :     String                          aParent;
     427                 :            :     String                          aStyle;
     428                 :            : 
     429                 :            : protected:
     430                 :            :     virtual void    Command( const CommandEvent& rMEvt );
     431                 :            :     virtual long    Notify( NotifyEvent& rNEvt );
     432                 :            :     virtual sal_Bool    DoubleClickHdl();
     433                 :            :     virtual long    ExpandingHdl();
     434                 :            :     virtual void    ExpandedHdl();
     435                 :            :     virtual sal_Bool    NotifyMoving(SvLBoxEntry*  pTarget,
     436                 :            :                                      SvLBoxEntry*  pEntry,
     437                 :            :                                      SvLBoxEntry*& rpNewParent,
     438                 :            :                                      sal_uIntPtr&        rNewChildPos);
     439                 :            : public:
     440                 :            :     StyleTreeListBox_Impl( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle = 0);
     441                 :            : 
     442                 :          0 :     void            SetDoubleClickHdl(const Link &rLink) { aDoubleClickLink = rLink; }
     443                 :          0 :     void            SetDropHdl(const Link &rLink) { aDropLink = rLink; }
     444                 :            :         using SvLBox::GetParent;
     445                 :          0 :     const String&   GetParent() const { return aParent; }
     446                 :          0 :     const String&   GetStyle() const { return aStyle; }
     447                 :            :     void            MakeExpanded_Impl(ExpandedEntries_t& rEntries) const;
     448                 :            : 
     449                 :            :     virtual PopupMenu* CreateContextMenu( void );
     450                 :            : };
     451                 :            : 
     452                 :            : //-------------------------------------------------------------------------
     453                 :            : 
     454                 :            : 
     455                 :          0 : void StyleTreeListBox_Impl::MakeExpanded_Impl(ExpandedEntries_t& rEntries) const
     456                 :            : {
     457                 :            :     SvLBoxEntry *pEntry;
     458         [ #  # ]:          0 :     for(pEntry=(SvLBoxEntry*)FirstVisible();pEntry;pEntry=(SvLBoxEntry*)NextVisible(pEntry))
     459                 :            :     {
     460         [ #  # ]:          0 :         if(IsExpanded(pEntry))
     461                 :            :         {
     462 [ #  # ][ #  # ]:          0 :             rEntries.push_back(GetEntryText(pEntry));
     463                 :            :         }
     464                 :            :     }
     465                 :          0 : }
     466                 :            : 
     467                 :          0 : PopupMenu* StyleTreeListBox_Impl::CreateContextMenu()
     468                 :            : {
     469                 :          0 :     return pDialog->CreateContextMenu();
     470                 :            : }
     471                 :            : 
     472                 :          0 : sal_Bool StyleTreeListBox_Impl::DoubleClickHdl()
     473                 :            : 
     474                 :            : /*  [Description]
     475                 :            : 
     476                 :            :     DoubleClick-Handler; calls the link.
     477                 :            :     SV virtual method.
     478                 :            : */
     479                 :            : {
     480                 :          0 :     aDoubleClickLink.Call(this);
     481                 :          0 :     return sal_False;
     482                 :            : }
     483                 :            : 
     484                 :            : //-------------------------------------------------------------------------
     485                 :            : 
     486                 :          0 : void StyleTreeListBox_Impl::Command( const CommandEvent& rCEvt )
     487                 :            : 
     488                 :            : /*  [Description]
     489                 :            : 
     490                 :            :     Command Handler; this executes a PopupMenu (designer-specific)
     491                 :            :     SV virtual method.
     492                 :            : */
     493                 :            : {
     494                 :          0 :     SvTreeListBox::Command(rCEvt);
     495                 :          0 : }
     496                 :            : 
     497                 :            : //-------------------------------------------------------------------------
     498                 :            : 
     499                 :          0 : long StyleTreeListBox_Impl::Notify( NotifyEvent& rNEvt )
     500                 :            : {
     501                 :            :     // handle <RETURN> as double click
     502                 :            : 
     503                 :          0 :     long nRet = 0;
     504         [ #  # ]:          0 :     if ( rNEvt.GetType() == EVENT_KEYINPUT )
     505                 :            :     {
     506                 :          0 :         const KeyCode&  rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
     507 [ #  # ][ #  # ]:          0 :         if ( !rKeyCode.GetModifier() && KEY_RETURN == rKeyCode.GetCode() )
                 [ #  # ]
     508                 :            :         {
     509                 :          0 :             aDoubleClickLink.Call( this );
     510                 :          0 :             nRet = 1;
     511                 :            :         }
     512                 :            :     }
     513                 :            : 
     514         [ #  # ]:          0 :     if ( !nRet )
     515                 :          0 :         nRet = DropListBox_Impl::Notify( rNEvt );
     516                 :            : 
     517                 :          0 :     return nRet;
     518                 :            : }
     519                 :            : 
     520                 :            : //-------------------------------------------------------------------------
     521                 :            : 
     522                 :          0 : sal_Bool StyleTreeListBox_Impl::NotifyMoving(SvLBoxEntry*  pTarget,
     523                 :            :                                          SvLBoxEntry*  pEntry,
     524                 :            :                                          SvLBoxEntry*& rpNewParent,
     525                 :            :                                          sal_uIntPtr& lPos)
     526                 :            : /*  [Description]
     527                 :            : 
     528                 :            :     NotifyMoving Handler; This leads via a link on the event to the dialog.
     529                 :            :     SV virtual method.
     530                 :            : */
     531                 :            : {
     532 [ #  # ][ #  # ]:          0 :     if(!pTarget || !pEntry)
     533                 :          0 :         return sal_False;
     534 [ #  # ][ #  # ]:          0 :     aParent = GetEntryText(pTarget);
                 [ #  # ]
     535 [ #  # ][ #  # ]:          0 :     aStyle  = GetEntryText(pEntry);
                 [ #  # ]
     536         [ #  # ]:          0 :     const sal_Bool bRet = (sal_Bool)aDropLink.Call(this);
     537                 :          0 :     rpNewParent = pTarget;
     538                 :          0 :     lPos=0;
     539 [ #  # ][ #  # ]:          0 :     IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
         [ #  # ][ #  # ]
     540         [ #  # ]:          0 :     const CollatorWrapper* pCollator = aIntlWrapper.getCaseCollator();
     541 [ #  # ][ #  # ]:          0 :     for(SvLBoxEntry *pTmpEntry=FirstChild(pTarget);
         [ #  # ][ #  # ]
                 [ #  # ]
     542                 :            :         pTmpEntry && COMPARE_LESS==pCollator->compareString(
     543 [ #  # ][ #  # ]:          0 :             GetEntryText(pTmpEntry),GetEntryText(pEntry));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
                      # ]
     544                 :          0 :         pTmpEntry=NextSibling(pTmpEntry),lPos++) ;
     545                 :            : 
     546 [ #  # ][ #  # ]:          0 :     return bRet? (sal_Bool)2: sal_False;
     547                 :            : }
     548                 :            : 
     549                 :            : //-------------------------------------------------------------------------
     550                 :            : 
     551                 :          0 : long  StyleTreeListBox_Impl::ExpandingHdl()
     552                 :            : 
     553                 :            : /*  [Description]
     554                 :            : 
     555                 :            :     ExpandingHdl Handler; the current entry is noticed.
     556                 :            :     SV virtual method.
     557                 :            : 
     558                 :            :     [Cross-reference]
     559                 :            :     <StyleTreeListBox_Impl::ExpandedHdl()>
     560                 :            : */
     561                 :            : {
     562                 :          0 :     pCurEntry = GetCurEntry();
     563                 :          0 :     return sal_True;
     564                 :            : }
     565                 :            : 
     566                 :            : //-------------------------------------------------------------------------
     567                 :            : 
     568                 :          0 : void  StyleTreeListBox_Impl::ExpandedHdl()
     569                 :            : 
     570                 :            : /*  [Description]
     571                 :            : 
     572                 :            :     ExpandedHdl Handler;
     573                 :            :     SV virtual method.
     574                 :            : 
     575                 :            :     [Cross-reference]
     576                 :            :     <StyleTreeListBox_Impl::ExpandingHdl()>
     577                 :            : */
     578                 :            : 
     579                 :            : {
     580                 :          0 :     SvLBoxEntry *pEntry = GetHdlEntry();
     581 [ #  # ][ #  # ]:          0 :     if(!IsExpanded(pEntry) && pCurEntry != GetCurEntry())
                 [ #  # ]
     582                 :          0 :         SelectAll( sal_False );
     583                 :          0 :     pCurEntry = 0;
     584                 :          0 : }
     585                 :            : 
     586                 :            : //-------------------------------------------------------------------------
     587                 :            : 
     588                 :          0 : StyleTreeListBox_Impl::StyleTreeListBox_Impl(
     589                 :            :     SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle) :
     590                 :            :     DropListBox_Impl(pParent->GetWindow(), nWinStyle, pParent),
     591 [ #  # ][ #  # ]:          0 :     pCurEntry(0)
         [ #  # ][ #  # ]
     592                 :            : 
     593                 :            : /*  [Description]
     594                 :            : 
     595                 :            :     Constructor StyleTreeListBox_Impl
     596                 :            : */
     597                 :            : {
     598         [ #  # ]:          0 :     EnableContextMenuHandling();
     599                 :          0 : }
     600                 :            : 
     601                 :            : //-------------------------------------------------------------------------
     602                 :            : 
     603                 :            : class StyleTreeArr_Impl;
     604                 :            : 
     605                 :            : /*  [Description]
     606                 :            : 
     607                 :            :     Internal structure for the establishment of the hierarchical view
     608                 :            : */
     609                 :            : 
     610                 :            : struct StyleTree_Impl
     611                 :            : {
     612                 :            :     String aName;
     613                 :            :     String aParent;
     614                 :            :     StyleTreeArr_Impl *pChildren;
     615                 :            :     sal_Bool bIsExpanded;
     616                 :          0 :     sal_Bool HasParent() const { return aParent.Len() != 0; }
     617                 :            : 
     618                 :          0 :     StyleTree_Impl(const String &rName, const String &rParent):
     619         [ #  # ]:          0 :         aName(rName), aParent(rParent), pChildren(0), bIsExpanded(0) {}
     620                 :            :     ~StyleTree_Impl();
     621                 :            :     void Put(StyleTree_Impl* pIns, sal_uIntPtr lPos=ULONG_MAX);
     622                 :            :     sal_uIntPtr Count();
     623                 :            : };
     624                 :            : 
     625                 :          0 : class StyleTreeArr_Impl : public std::vector<StyleTree_Impl*>
     626                 :            : {
     627                 :            : public:
     628                 :          0 :     ~StyleTreeArr_Impl()
     629                 :          0 :     {
     630 [ #  # ][ #  # ]:          0 :         for(const_iterator it = begin(); it != end(); ++it)
                 [ #  # ]
     631 [ #  # ][ #  # ]:          0 :             delete *it;
     632                 :          0 :     }
     633                 :            : 
     634                 :            : };
     635                 :            : 
     636                 :          0 : sal_uIntPtr StyleTree_Impl::Count()
     637                 :            : {
     638         [ #  # ]:          0 :     return pChildren ? pChildren->size() : 0L;
     639                 :            : }
     640                 :            : 
     641                 :            : //-------------------------------------------------------------------------
     642                 :            : 
     643         [ #  # ]:          0 : StyleTree_Impl::~StyleTree_Impl()
     644                 :            : {
     645 [ #  # ][ #  # ]:          0 :     delete pChildren;
     646                 :          0 : }
     647                 :            : 
     648                 :            : //-------------------------------------------------------------------------
     649                 :            : 
     650                 :          0 : void StyleTree_Impl::Put(StyleTree_Impl* pIns, sal_uIntPtr lPos)
     651                 :            : {
     652         [ #  # ]:          0 :     if ( !pChildren )
     653         [ #  # ]:          0 :         pChildren = new StyleTreeArr_Impl;
     654                 :            : 
     655         [ #  # ]:          0 :     if ( ULONG_MAX == lPos )
     656                 :          0 :         pChildren->push_back( pIns );
     657                 :            :     else
     658 [ #  # ][ #  # ]:          0 :         pChildren->insert( pChildren->begin() + (sal_uInt16)lPos, pIns );
     659                 :          0 : }
     660                 :            : 
     661                 :            : //-------------------------------------------------------------------------
     662                 :            : 
     663                 :          0 : StyleTreeArr_Impl &MakeTree_Impl(StyleTreeArr_Impl &rArr)
     664                 :            : {
     665                 :          0 :     const sal_uInt16 nCount = rArr.size();
     666                 :            : 
     667                 :            :     comphelper::string::NaturalStringSorter aSorter(
     668                 :            :         ::comphelper::getProcessComponentContext(),
     669 [ #  # ][ #  # ]:          0 :         Application::GetSettings().GetLocale());
         [ #  # ][ #  # ]
     670                 :            : 
     671                 :            :     // Arrange all under their Parents
     672                 :            :     sal_uInt16 i;
     673         [ #  # ]:          0 :     for(i = 0; i < nCount; ++i)
     674                 :            :     {
     675                 :          0 :         StyleTree_Impl* pEntry = rArr[i];
     676         [ #  # ]:          0 :         if(pEntry->HasParent())
     677                 :            :         {
     678         [ #  # ]:          0 :             for(sal_uInt16 j = 0; j < nCount; ++j)
     679                 :            :             {
     680                 :          0 :                 StyleTree_Impl* pCmp = rArr[j];
     681 [ #  # ][ #  # ]:          0 :                 if(pCmp->aName == pEntry->aParent)
     682                 :            :                 {
     683                 :            :                     // Paste initial filter
     684                 :            :                     sal_uInt16 nPos;
     685 [ #  # ][ #  # ]:          0 :                     for( nPos = 0 ; nPos < pCmp->Count() &&
                 [ #  # ]
     686 [ #  # ][ #  # ]:          0 :                              aSorter.compare((*pCmp->pChildren)[nPos]->aName, pEntry->aName) < 0 ; nPos++)
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     687                 :            :                     {};
     688         [ #  # ]:          0 :                     pCmp->Put(pEntry,nPos);
     689                 :          0 :                     break;
     690                 :            :                 }
     691                 :            :             }
     692                 :            :         }
     693                 :            :     }
     694                 :            : 
     695         [ #  # ]:          0 :     for(i = 0; i < rArr.size(); )
     696                 :            :     {
     697         [ #  # ]:          0 :         if(rArr[i]->HasParent())
     698 [ #  # ][ #  # ]:          0 :             rArr.erase(rArr.begin() + i);
     699                 :            :         else
     700                 :          0 :             ++i;
     701                 :            :     }
     702         [ #  # ]:          0 :     return rArr;
     703                 :            : }
     704                 :            : 
     705                 :            : //-------------------------------------------------------------------------
     706                 :            : 
     707                 :            : 
     708                 :          0 : inline sal_Bool IsExpanded_Impl( const ExpandedEntries_t& rEntries,
     709                 :            :                              const rtl::OUString &rStr)
     710                 :            : {
     711         [ #  # ]:          0 :     for (size_t n = 0; n < rEntries.size(); ++n)
     712                 :            :     {
     713         [ #  # ]:          0 :         if (rEntries[n] == rStr)
     714                 :          0 :             return sal_True;
     715                 :            :     }
     716                 :          0 :     return sal_False;
     717                 :            : }
     718                 :            : 
     719                 :            : 
     720                 :            : 
     721                 :          0 : SvLBoxEntry* FillBox_Impl(SvTreeListBox *pBox,
     722                 :            :                                  StyleTree_Impl* pEntry,
     723                 :            :                                  const ExpandedEntries_t& rEntries,
     724                 :            :                                  SvLBoxEntry* pParent = 0)
     725                 :            : {
     726                 :          0 :     SvLBoxEntry* pNewEntry = pBox->InsertEntry(pEntry->aName, pParent);
     727         [ #  # ]:          0 :     const sal_uInt16 nCount = pEntry->pChildren ? pEntry->pChildren->size() : 0;
     728         [ #  # ]:          0 :     for(sal_uInt16 i = 0; i < nCount; ++i)
     729                 :          0 :         FillBox_Impl(pBox, (*pEntry->pChildren)[i], rEntries, pNewEntry);
     730                 :          0 :     return pNewEntry;
     731                 :            : }
     732                 :            : 
     733                 :            : //-------------------------------------------------------------------------
     734                 :            : // Constructor
     735                 :            : 
     736                 :        120 : SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, SfxDockingWindow* pW ) :
     737                 :            : 
     738                 :            :     aISfxTemplateCommon     ( this ),
     739                 :            :     pBindings               ( pB ),
     740                 :            :     pWindow                 ( pW ),
     741                 :            :     pModule                 ( NULL ),
     742                 :            :     pTimer                  ( NULL ),
     743                 :            :     m_pStyleFamiliesId      ( NULL ),
     744                 :            :     pStyleSheetPool         ( NULL ),
     745                 :            :     pTreeBox                ( NULL ),
     746                 :            :     pCurObjShell            ( NULL ),
     747 [ +  - ][ +  - ]:        240 :     xModuleManager          ( ::comphelper::getProcessServiceFactory()->createInstance(
     748                 :        120 :                                 DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY ),
     749                 :            :     m_pDeletionWatcher      ( NULL ),
     750                 :            : 
     751                 :            :     aFmtLb                  ( this, WB_BORDER | WB_TABSTOP | WB_SORT | WB_QUICK_SEARCH ),
     752                 :            :     aFilterLb               ( pW, WB_BORDER | WB_DROPDOWN | WB_TABSTOP ),
     753                 :            : 
     754                 :            :     nActFamily              ( 0xffff ),
     755                 :            :     nActFilter              ( 0 ),
     756                 :            :     nAppFilter              ( 0 ),
     757                 :            : 
     758                 :            :     bDontUpdate             ( sal_False ),
     759                 :            :     bIsWater                ( sal_False ),
     760                 :            :     bEnabled                ( sal_True ),
     761                 :            :     bUpdate                 ( sal_False ),
     762                 :            :     bUpdateFamily           ( sal_False ),
     763                 :            :     bCanEdit                ( sal_False ),
     764                 :            :     bCanDel                 ( sal_False ),
     765                 :            :     bCanNew                 ( sal_True ),
     766                 :            :     bWaterDisabled          ( sal_False ),
     767                 :            :     bNewByExampleDisabled   ( sal_False ),
     768                 :            :     bUpdateByExampleDisabled( sal_False ),
     769                 :            :     bTreeDrag               ( sal_True ),
     770                 :            :     bHierarchical           ( sal_False ),
     771 [ +  - ][ +  - ]:        360 :     bBindingUpdate          ( sal_True )
         [ +  - ][ +  - ]
           [ +  -  +  - ]
                 [ +  - ]
     772                 :            : {
     773 [ +  - ][ +  - ]:        120 :     aFmtLb.SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST).toString());
         [ +  - ][ +  - ]
                 [ +  - ]
     774         [ +  - ]:        120 :     aFmtLb.SetHelpId( HID_TEMPLATE_FMT );
     775         [ +  - ]:        120 :     aFilterLb.SetHelpId( HID_TEMPLATE_FILTER );
     776 [ +  - ][ +  - ]:        120 :     aFmtLb.SetStyle( aFmtLb.GetStyle() | WB_SORT | WB_HIDESELECTION );
     777         [ +  - ]:        120 :     Font aFont = aFmtLb.GetFont();
     778         [ +  - ]:        120 :     aFont.SetWeight( WEIGHT_NORMAL );
     779 [ +  - ][ +  - ]:        120 :     aFmtLb.SetFont( aFont );
     780                 :        120 : }
     781                 :            : 
     782                 :            : //-------------------------------------------------------------------------
     783                 :            : 
     784                 :          0 : SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, ModalDialog* pW ) :
     785                 :            : 
     786                 :            :     aISfxTemplateCommon     ( this ),
     787                 :            :     pBindings               ( pB ),
     788                 :            :     pWindow                 ( pW ),
     789                 :            :     pModule                 ( NULL ),
     790                 :            :     pTimer                  ( NULL ),
     791                 :            :     pStyleSheetPool         ( NULL ),
     792                 :            :     pTreeBox                ( NULL ),
     793                 :            :     pCurObjShell            ( NULL ),
     794                 :            :     m_pDeletionWatcher      ( NULL ),
     795                 :            : 
     796                 :            :     aFmtLb                  ( this, SfxResId( BT_VLIST ) ),
     797                 :            :     aFilterLb               ( pW, SfxResId( BT_FLIST ) ),
     798                 :            : 
     799                 :            :     nActFamily              ( 0xffff ),
     800                 :            :     nActFilter              ( 0 ),
     801                 :            :     nAppFilter              ( 0 ),
     802                 :            : 
     803                 :            :     bDontUpdate             ( sal_False ),
     804                 :            :     bIsWater                ( sal_False ),
     805                 :            :     bEnabled                ( sal_True ),
     806                 :            :     bUpdate                 ( sal_False ),
     807                 :            :     bUpdateFamily           ( sal_False ),
     808                 :            :     bCanEdit                ( sal_False ),
     809                 :            :     bCanDel                 ( sal_False ),
     810                 :            :     bCanNew                 ( sal_True ),
     811                 :            :     bWaterDisabled          ( sal_False ),
     812                 :            :     bNewByExampleDisabled   ( sal_False ),
     813                 :            :     bUpdateByExampleDisabled( sal_False ),
     814                 :            :     bTreeDrag               ( sal_True ),
     815                 :            :     bHierarchical           ( sal_False ),
     816 [ #  # ][ #  # ]:          0 :     bBindingUpdate          ( sal_True )
         [ #  # ][ #  # ]
     817                 :            : 
     818                 :            : {
     819 [ #  # ][ #  # ]:          0 :     aFmtLb.SetStyle( aFmtLb.GetStyle() | WB_SORT );
     820                 :          0 : }
     821                 :            : 
     822                 :            : //-------------------------------------------------------------------------
     823                 :            : 
     824                 :        360 : sal_uInt16 SfxCommonTemplateDialog_Impl::StyleNrToInfoOffset(sal_uInt16 nId)
     825                 :            : {
     826                 :        360 :     const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nId );
     827                 :        360 :     return SfxFamilyIdToNId(pItem->GetFamily())-1;
     828                 :            : }
     829                 :            : 
     830                 :            : //-------------------------------------------------------------------------
     831                 :            : 
     832                 :        793 : void SfxTemplateDialog_Impl::EnableEdit(sal_Bool bEnable)
     833                 :            : {
     834                 :        793 :     SfxCommonTemplateDialog_Impl::EnableEdit( bEnable );
     835 [ +  + ][ +  + ]:        793 :     if( !bEnable || !bUpdateByExampleDisabled )
     836                 :        321 :         EnableItem( SID_STYLE_UPDATE_BY_EXAMPLE, bEnable);
     837                 :        793 : }
     838                 :            : 
     839                 :            : //-------------------------------------------------------------------------
     840                 :            : 
     841                 :        120 : void SfxCommonTemplateDialog_Impl::ReadResource()
     842                 :            : {
     843                 :            :     // Read global user resource
     844         [ +  + ]:        720 :     for(sal_uInt16 i = 0; i < MAX_FAMILIES; ++i)
     845                 :        600 :         pFamilyState[i] = 0;
     846                 :            : 
     847         [ +  - ]:        120 :     SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
     848         [ +  - ]:        120 :     pCurObjShell = pViewFrame->GetObjectShell();
     849 [ +  - ][ +  - ]:        120 :     ResMgr* pMgr = pCurObjShell ? pCurObjShell->GetResMgr() : NULL;
     850                 :        120 :     ResId aFamId( DLG_STYLE_DESIGNER, *pMgr );
     851                 :        120 :     aFamId.SetRT(RSC_SFX_STYLE_FAMILIES);
     852         [ +  - ]:        120 :     m_pStyleFamiliesId = new ResId( aFamId.GetId(), *pMgr );
     853                 :        120 :     m_pStyleFamiliesId->SetRT(RSC_SFX_STYLE_FAMILIES);
     854 [ +  - ][ -  + ]:        120 :     if( !pMgr || !pMgr->IsAvailable( aFamId ) )
         [ -  + ][ +  - ]
     855 [ #  # ][ #  # ]:          0 :         pStyleFamilies = new SfxStyleFamilies;
     856                 :            :     else
     857 [ +  - ][ +  - ]:        120 :         pStyleFamilies = new SfxStyleFamilies( aFamId );
     858                 :            : 
     859 [ +  - ][ +  - ]:        120 :     nActFilter = pCurObjShell ? static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) ) : 0xFFFF;
     860 [ +  - ][ +  - ]:        120 :     if ( pCurObjShell && 0xFFFF == nActFilter )
     861         [ +  - ]:        120 :         nActFilter = pCurObjShell->GetAutoStyleFilterIndex();
     862                 :            : 
     863                 :            :     // Paste in the toolbox
     864                 :            :     // reverse order, since always inserted at the head
     865                 :        120 :     size_t nCount = pStyleFamilies->size();
     866                 :            : 
     867         [ +  - ]:        120 :     pBindings->ENTERREGISTRATIONS();
     868                 :            : 
     869                 :            :     size_t i;
     870         [ +  + ]:        714 :     for(i = 0; i < nCount; ++i)
     871                 :            :     {
     872                 :        594 :         sal_uInt16 nSlot = 0;
     873 [ +  - ][ +  +  :        594 :         switch( (sal_uInt16)pStyleFamilies->at( i )->GetFamily() )
             +  +  +  - ]
     874                 :            :         {
     875                 :        118 :             case SFX_STYLE_FAMILY_CHAR: nSlot = SID_STYLE_FAMILY1; break;
     876                 :        120 :             case SFX_STYLE_FAMILY_PARA: nSlot = SID_STYLE_FAMILY2; break;
     877                 :        118 :             case SFX_STYLE_FAMILY_FRAME:nSlot = SID_STYLE_FAMILY3; break;
     878                 :        118 :             case SFX_STYLE_FAMILY_PAGE: nSlot = SID_STYLE_FAMILY4; break;
     879                 :        120 :             case SFX_STYLE_FAMILY_PSEUDO: nSlot = SID_STYLE_FAMILY5; break;
     880                 :          0 :             default: OSL_FAIL("unknown StyleFamily"); break;
     881                 :            :         }
     882                 :            :         pBoundItems[i] =
     883 [ +  - ][ +  - ]:        594 :             new SfxTemplateControllerItem(nSlot, *this, *pBindings);
     884                 :            :     }
     885                 :        120 :     pBoundItems[i++] = new SfxTemplateControllerItem(
     886 [ +  - ][ +  - ]:        120 :         SID_STYLE_WATERCAN, *this, *pBindings);
     887                 :        120 :     pBoundItems[i++] = new SfxTemplateControllerItem(
     888 [ +  - ][ +  - ]:        120 :         SID_STYLE_NEW_BY_EXAMPLE, *this, *pBindings);
     889                 :        120 :     pBoundItems[i++] = new SfxTemplateControllerItem(
     890 [ +  - ][ +  - ]:        120 :         SID_STYLE_UPDATE_BY_EXAMPLE, *this, *pBindings);
     891                 :        120 :     pBoundItems[i++] = new SfxTemplateControllerItem(
     892 [ +  - ][ +  - ]:        120 :         SID_STYLE_NEW, *this, *pBindings);
     893                 :        120 :     pBoundItems[i++] = new SfxTemplateControllerItem(
     894 [ +  - ][ +  - ]:        120 :         SID_STYLE_DRAGHIERARCHIE, *this, *pBindings);
     895                 :        120 :     pBoundItems[i++] = new SfxTemplateControllerItem(
     896 [ +  - ][ +  - ]:        120 :         SID_STYLE_EDIT, *this, *pBindings);
     897                 :        120 :     pBoundItems[i++] = new SfxTemplateControllerItem(
     898 [ +  - ][ +  - ]:        120 :         SID_STYLE_DELETE, *this, *pBindings);
     899                 :        120 :     pBoundItems[i++] = new SfxTemplateControllerItem(
     900 [ +  - ][ +  - ]:        120 :         SID_STYLE_FAMILY, *this, *pBindings);
     901         [ +  - ]:        120 :     pBindings->LEAVEREGISTRATIONS();
     902                 :            : 
     903         [ +  + ]:        126 :     for(; i < COUNT_BOUND_FUNC; ++i)
     904                 :          6 :         pBoundItems[i] = 0;
     905                 :            : 
     906         [ +  - ]:        120 :     StartListening(*pBindings);
     907                 :            : 
     908                 :            : // Insert in the reverse order of occurrence in the Style Families. This is for
     909                 :            : // the toolbar of the designer. The list box of the catalog respects the
     910                 :            : // correct order by itself.
     911                 :            : 
     912                 :            : // Sequences: the order of Resource = the order of Toolbar for example list box.
     913                 :            : // Order of ascending SIDs: Low SIDs are displayed first when templates of
     914                 :            : // several families are active.
     915                 :            : 
     916                 :            :     // in the Writer the UpdateStyleByExample Toolbox button is removed and
     917                 :            :     // the NewStyle button gets a PopupMenu
     918         [ +  + ]:        120 :     if(nCount > 4)
     919         [ +  - ]:        118 :         ReplaceUpdateButtonByMenu();
     920                 :            : 
     921         [ +  + ]:        714 :     for( ; nCount--; )
     922                 :            :     {
     923         [ +  - ]:        594 :         const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nCount );
     924                 :        594 :         sal_uInt16 nId = SfxFamilyIdToNId( pItem->GetFamily() );
     925         [ +  - ]:        594 :         InsertFamilyItem( nId, pItem );
     926                 :            :     }
     927                 :            : 
     928         [ +  - ]:        120 :     LoadedFamilies();
     929                 :            : 
     930                 :        120 :     sal_uInt16 nStart = SID_STYLE_FAMILY1;
     931                 :        120 :     sal_uInt16 nEnd = SID_STYLE_FAMILY4;
     932                 :            : 
     933         [ +  + ]:        600 :     for ( i = nStart; i <= nEnd; i++ )
     934         [ +  - ]:        480 :         pBindings->Update(i);
     935                 :            : 
     936 [ +  - ][ +  - ]:        120 :     pModule = pCurObjShell ? pCurObjShell->GetModule() : NULL;
     937                 :        120 : }
     938                 :            : 
     939                 :            : //-------------------------------------------------------------------------
     940                 :            : 
     941                 :          0 : void SfxCommonTemplateDialog_Impl::ClearResource()
     942                 :            : {
     943                 :          0 :     ClearFamilyList();
     944                 :          0 :     impl_clear();
     945                 :          0 : }
     946                 :            : 
     947                 :        120 : void SfxCommonTemplateDialog_Impl::impl_clear()
     948                 :            : {
     949         [ +  - ]:        120 :     DELETEX(pStyleFamilies);
     950                 :            :     sal_uInt16 i;
     951         [ +  + ]:        720 :     for ( i = 0; i < MAX_FAMILIES; ++i )
     952         [ +  + ]:        600 :         DELETEX(pFamilyState[i]);
     953         [ +  + ]:       1680 :     for ( i = 0; i < COUNT_BOUND_FUNC; ++i )
     954         [ +  + ]:       1560 :         delete pBoundItems[i];
     955                 :        120 :     pCurObjShell = NULL;
     956                 :            : 
     957                 :        120 :     DELETEZ( m_pStyleFamiliesId );
     958                 :        120 : }
     959                 :            : 
     960                 :          0 : void SfxCommonTemplateDialog_Impl::impl_setDeletionWatcher(DeletionWatcher* pNewWatcher)
     961                 :            : {
     962                 :          0 :     m_pDeletionWatcher = pNewWatcher;
     963                 :          0 : }
     964                 :            : 
     965                 :            : //-------------------------------------------------------------------------
     966                 :            : 
     967                 :        120 : void SfxCommonTemplateDialog_Impl::Initialize()
     968                 :            : {
     969                 :            :     // Read global user resource
     970                 :        120 :     ReadResource();
     971                 :        120 :     pBindings->Invalidate( SID_STYLE_FAMILY );
     972                 :        120 :     pBindings->Update( SID_STYLE_FAMILY );
     973                 :        120 :     Update_Impl();
     974                 :            : 
     975                 :        120 :     aFilterLb.SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FilterSelectHdl ) );
     976                 :        120 :     aFmtLb.SetDoubleClickHdl( LINK( this, SfxCommonTemplateDialog_Impl, ApplyHdl ) );
     977                 :        120 :     aFmtLb.SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FmtSelectHdl ) );
     978                 :            : 
     979                 :        120 :     aFilterLb.Show();
     980                 :        120 :     aFmtLb.Show();
     981                 :        120 : }
     982                 :            : 
     983                 :            : //-------------------------------------------------------------------------
     984                 :            : 
     985 [ +  - ][ +  - ]:        120 : SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
     986                 :            : {
     987         [ +  - ]:        120 :     String aEmpty;
     988         [ -  + ]:        120 :     if ( bIsWater )
     989         [ #  # ]:          0 :         Execute_Impl(SID_STYLE_WATERCAN, aEmpty, aEmpty, 0);
     990         [ +  - ]:        120 :     GetWindow()->Hide();
     991         [ +  - ]:        120 :     impl_clear();
     992         [ +  - ]:        120 :     if ( pStyleSheetPool )
     993         [ +  - ]:        120 :         EndListening(*pStyleSheetPool);
     994                 :        120 :     pStyleSheetPool = NULL;
     995 [ -  + ][ #  # ]:        120 :     delete pTreeBox;
     996 [ -  + ][ #  # ]:        120 :     delete pTimer;
     997         [ -  + ]:        120 :     if ( m_pDeletionWatcher )
     998         [ +  - ]:        120 :         m_pDeletionWatcher->signal();
     999         [ -  + ]:        120 : }
    1000                 :            : 
    1001                 :            : //-------------------------------------------------------------------------
    1002                 :            : 
    1003                 :       5938 : sal_uInt16 SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SfxStyleFamily nFamily )
    1004                 :            : {
    1005   [ +  +  +  +  :       5938 :     switch ( nFamily )
                   +  - ]
    1006                 :            :     {
    1007                 :        354 :         case SFX_STYLE_FAMILY_CHAR:   return 1;
    1008                 :       4516 :         case SFX_STYLE_FAMILY_PARA:   return 2;
    1009                 :        354 :         case SFX_STYLE_FAMILY_FRAME:  return 3;
    1010                 :        354 :         case SFX_STYLE_FAMILY_PAGE:   return 4;
    1011                 :        360 :         case SFX_STYLE_FAMILY_PSEUDO: return 5;
    1012                 :       5938 :         default:                      return 0;
    1013                 :            :     }
    1014                 :            : }
    1015                 :            : 
    1016                 :          0 : void SfxCommonTemplateDialog_Impl::SetAutomaticFilter()
    1017                 :            : {
    1018                 :          0 :     sal_uInt16 nCount = aFilterLb.GetEntryCount();
    1019         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
    1020                 :            :     {
    1021                 :          0 :         sal_uIntPtr nFlags = (sal_uIntPtr)aFilterLb.GetEntryData(i);
    1022         [ #  # ]:          0 :         if ( SFXSTYLEBIT_AUTO == nFlags )
    1023                 :            :         {
    1024                 :            :             // automatic entry found -> select it
    1025                 :          0 :             aFilterLb.SelectEntryPos(i);
    1026                 :            :             // then call the handler to filter the styles
    1027                 :          0 :             FilterSelect( i - 1 );
    1028                 :          0 :             break;
    1029                 :            :         }
    1030                 :            :     }
    1031                 :          0 : }
    1032                 :            : 
    1033                 :            : //-------------------------------------------------------------------------
    1034                 :            : // Helper function: Access to the current family item
    1035                 :       3916 : const SfxStyleFamilyItem *SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() const
    1036                 :            : {
    1037                 :       3916 :     const size_t nCount = pStyleFamilies->size();
    1038         [ +  + ]:       4510 :     for(size_t i = 0; i < nCount; ++i)
    1039                 :            :     {
    1040                 :       4390 :         const SfxStyleFamilyItem *pItem = pStyleFamilies->at( i );
    1041                 :       4390 :         sal_uInt16 nId = SfxFamilyIdToNId(pItem->GetFamily());
    1042         [ +  + ]:       4390 :         if(nId == nActFamily)
    1043                 :       3796 :             return pItem;
    1044                 :            :     }
    1045                 :       3916 :     return 0;
    1046                 :            : }
    1047                 :            : 
    1048                 :          0 : SfxStyleSheetBase *SfxCommonTemplateDialog_Impl::GetSelectedStyle() const
    1049                 :            : {
    1050 [ #  # ][ #  # ]:          0 :     if (!IsInitialized() || !pStyleSheetPool || !HasSelectedStyle())
         [ #  # ][ #  # ]
                 [ #  # ]
    1051                 :          0 :         return NULL;
    1052         [ #  # ]:          0 :     const String aTemplName( GetSelectedEntry() );
    1053         [ #  # ]:          0 :     const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
    1054 [ #  # ][ #  # ]:          0 :     return pStyleSheetPool->Find( aTemplName, pItem->GetFamily(), SFXSTYLEBIT_ALL );
    1055                 :            : }
    1056                 :            : 
    1057                 :            : //-------------------------------------------------------------------------
    1058                 :            : 
    1059                 :        564 : void SfxCommonTemplateDialog_Impl::SelectStyle(const String &rStr)
    1060                 :            : {
    1061                 :        564 :     const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
    1062         [ -  + ]:        564 :     if ( !pItem )
    1063                 :          0 :         return;
    1064                 :        564 :     const SfxStyleFamily eFam = pItem->GetFamily();
    1065                 :        564 :     SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( rStr, eFam, SFXSTYLEBIT_ALL );
    1066         [ +  + ]:        564 :     if( pStyle )
    1067                 :        549 :         EnableEdit( !(pStyle->GetMask() & SFXSTYLEBIT_READONLY) );
    1068                 :            :     else
    1069                 :         15 :         EnableEdit(sal_False);
    1070                 :            : 
    1071         [ -  + ]:        564 :     if ( pTreeBox )
    1072                 :            :     {
    1073         [ #  # ]:          0 :         if ( rStr.Len() )
    1074                 :            :         {
    1075                 :          0 :             SvLBoxEntry* pEntry = pTreeBox->First();
    1076         [ #  # ]:          0 :             while ( pEntry )
    1077                 :            :             {
    1078 [ #  # ][ #  # ]:          0 :                 if ( pTreeBox->GetEntryText( pEntry ) == rStr )
    1079                 :            :                 {
    1080                 :          0 :                     pTreeBox->MakeVisible( pEntry );
    1081                 :          0 :                     pTreeBox->Select( pEntry );
    1082                 :          0 :                     return;
    1083                 :            :                 }
    1084                 :          0 :                 pEntry = pTreeBox->Next( pEntry );
    1085                 :            :             }
    1086                 :            :         }
    1087                 :            :         else
    1088                 :          0 :             pTreeBox->SelectAll( sal_False );
    1089                 :            :     }
    1090                 :            :     else
    1091                 :            :     {
    1092                 :        564 :         sal_Bool bSelect = ( rStr.Len() > 0 );
    1093         [ +  + ]:        564 :         if ( bSelect )
    1094                 :            :         {
    1095                 :        549 :             SvLBoxEntry* pEntry = (SvLBoxEntry*)aFmtLb.FirstVisible();
    1096 [ +  - ][ +  - ]:       1098 :             while ( pEntry && aFmtLb.GetEntryText( pEntry ) != rStr )
         [ +  - ][ +  + ]
                 [ +  - ]
           [ +  +  #  # ]
    1097                 :        549 :                 pEntry = (SvLBoxEntry*)aFmtLb.NextVisible( pEntry );
    1098         [ -  + ]:        549 :             if ( !pEntry )
    1099                 :          0 :                 bSelect = sal_False;
    1100                 :            :             else
    1101                 :            :             {
    1102                 :        549 :                 aFmtLb.MakeVisible( pEntry );
    1103                 :        549 :                 aFmtLb.Select( pEntry );
    1104                 :        549 :                 bWaterDisabled = !HasSelectedStyle();
    1105                 :        549 :                 FmtSelectHdl( NULL );
    1106                 :            :             }
    1107                 :            :         }
    1108                 :            : 
    1109         [ +  + ]:        564 :         if ( !bSelect )
    1110                 :            :         {
    1111                 :         15 :             aFmtLb.SelectAll( sal_False );
    1112                 :        564 :             EnableEdit(sal_False);
    1113                 :            :         }
    1114                 :            :     }
    1115                 :            : }
    1116                 :            : 
    1117                 :            : //-------------------------------------------------------------------------
    1118                 :            : 
    1119                 :       1199 : String SfxCommonTemplateDialog_Impl::GetSelectedEntry() const
    1120                 :            : {
    1121                 :       1199 :     String aRet;
    1122         [ -  + ]:       1199 :     if ( pTreeBox )
    1123                 :            :     {
    1124         [ #  # ]:          0 :         SvLBoxEntry* pEntry = pTreeBox->FirstSelected();
    1125         [ #  # ]:          0 :         if ( pEntry )
    1126 [ #  # ][ #  # ]:          0 :             aRet = pTreeBox->GetEntryText( pEntry );
                 [ #  # ]
    1127                 :            :     }
    1128                 :            :     else
    1129                 :            :     {
    1130         [ +  - ]:       1199 :         SvLBoxEntry* pEntry = aFmtLb.FirstSelected();
    1131         [ +  + ]:       1199 :         if ( pEntry )
    1132 [ +  - ][ +  - ]:       1192 :             aRet = aFmtLb.GetEntryText( pEntry );
                 [ +  - ]
    1133                 :            :     }
    1134                 :       1199 :     return aRet;
    1135                 :            : }
    1136                 :            : 
    1137                 :            : //-------------------------------------------------------------------------
    1138                 :            : 
    1139                 :        244 : void SfxCommonTemplateDialog_Impl::EnableTreeDrag( sal_Bool bEnable )
    1140                 :            : {
    1141         [ +  + ]:        244 :     if ( pStyleSheetPool )
    1142                 :            :     {
    1143                 :        242 :         SfxStyleSheetBase* pStyle = pStyleSheetPool->First();
    1144         [ -  + ]:        242 :         if ( pTreeBox )
    1145                 :            :         {
    1146 [ #  # ][ #  # ]:          0 :             if ( pStyle && pStyle->HasParentSupport() && bEnable )
         [ #  # ][ #  # ]
    1147                 :          0 :                 pTreeBox->SetDragDropMode(SV_DRAGDROP_CTRL_MOVE);
    1148                 :            :             else
    1149                 :          0 :                 pTreeBox->SetDragDropMode(SV_DRAGDROP_NONE);
    1150                 :            :         }
    1151                 :            :     }
    1152                 :        244 :     bTreeDrag = bEnable;
    1153                 :        244 : }
    1154                 :            : 
    1155                 :            : //-------------------------------------------------------------------------
    1156                 :            : 
    1157                 :          0 : void SfxCommonTemplateDialog_Impl::FillTreeBox()
    1158                 :            : {
    1159                 :            :     OSL_ENSURE( pTreeBox, "FillTreeBox() without treebox");
    1160 [ #  # ][ #  # ]:          0 :     if(pStyleSheetPool && nActFamily != 0xffff)
    1161                 :            :     {
    1162         [ #  # ]:          0 :         const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
    1163         [ #  # ]:          0 :         pStyleSheetPool->SetSearchMask(pItem->GetFamily(), SFXSTYLEBIT_ALL);
    1164         [ #  # ]:          0 :         StyleTreeArr_Impl aArr;
    1165         [ #  # ]:          0 :         SfxStyleSheetBase *pStyle = pStyleSheetPool->First();
    1166 [ #  # ][ #  # ]:          0 :         if(pStyle && pStyle->HasParentSupport() && bTreeDrag )
         [ #  # ][ #  # ]
                 [ #  # ]
    1167         [ #  # ]:          0 :             pTreeBox->SetDragDropMode(SV_DRAGDROP_CTRL_MOVE);
    1168                 :            :         else
    1169         [ #  # ]:          0 :             pTreeBox->SetDragDropMode(SV_DRAGDROP_NONE);
    1170         [ #  # ]:          0 :         while(pStyle)
    1171                 :            :         {
    1172                 :            :             StyleTree_Impl* pNew =
    1173 [ #  # ][ #  # ]:          0 :                 new StyleTree_Impl(pStyle->GetName(), pStyle->GetParent());
         [ #  # ][ #  # ]
    1174         [ #  # ]:          0 :             aArr.push_back(pNew);
    1175         [ #  # ]:          0 :             pStyle = pStyleSheetPool->Next();
    1176                 :            :         }
    1177         [ #  # ]:          0 :         MakeTree_Impl(aArr);
    1178         [ #  # ]:          0 :         ExpandedEntries_t aEntries;
    1179         [ #  # ]:          0 :         if(pTreeBox)
    1180                 :            :             ((const StyleTreeListBox_Impl *)pTreeBox)->
    1181         [ #  # ]:          0 :                 MakeExpanded_Impl( aEntries);
    1182         [ #  # ]:          0 :         pTreeBox->SetUpdateMode( sal_False );
    1183         [ #  # ]:          0 :         pTreeBox->Clear();
    1184                 :          0 :         const sal_uInt16 nCount = aArr.size();
    1185         [ #  # ]:          0 :         for(sal_uInt16 i = 0; i < nCount; ++i)
    1186         [ #  # ]:          0 :             FillBox_Impl(pTreeBox, aArr[i], aEntries);
    1187                 :            : 
    1188         [ #  # ]:          0 :         EnableItem(SID_STYLE_WATERCAN,sal_False);
    1189                 :            : 
    1190                 :          0 :         SfxTemplateItem* pState = pFamilyState[nActFamily-1];
    1191                 :            : 
    1192         [ #  # ]:          0 :         if ( nCount )
    1193 [ #  # ][ #  # ]:          0 :             pTreeBox->Expand( pTreeBox->First() );
    1194                 :            : 
    1195 [ #  # ][ #  # ]:          0 :         for ( SvLBoxEntry* pEntry = pTreeBox->First(); pEntry; pEntry = pTreeBox->Next( pEntry ) )
                 [ #  # ]
    1196                 :            :         {
    1197 [ #  # ][ #  # ]:          0 :             if ( IsExpanded_Impl( aEntries, pTreeBox->GetEntryText( pEntry ) ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1198         [ #  # ]:          0 :                 pTreeBox->Expand( pEntry );
    1199                 :            :         }
    1200                 :            : 
    1201         [ #  # ]:          0 :         pTreeBox->SetUpdateMode( sal_True );
    1202                 :            : 
    1203         [ #  # ]:          0 :         String aStyle;
    1204         [ #  # ]:          0 :         if(pState)  // Select current entry
    1205         [ #  # ]:          0 :             aStyle = pState->GetStyleName();
    1206         [ #  # ]:          0 :         SelectStyle(aStyle);
    1207 [ #  # ][ #  # ]:          0 :         EnableDelete();
                 [ #  # ]
    1208                 :            :     }
    1209                 :          0 : }
    1210                 :            : 
    1211                 :            : //-------------------------------------------------------------------------
    1212                 :       1749 : sal_Bool SfxCommonTemplateDialog_Impl::HasSelectedStyle() const
    1213                 :            : {
    1214                 :          0 :     return pTreeBox? pTreeBox->FirstSelected() != 0:
    1215         [ -  + ]:       1749 :             aFmtLb.GetSelectionCount() != 0;
    1216                 :            : }
    1217                 :            : 
    1218                 :            : 
    1219                 :            : //-------------------------------------------------------------------------
    1220                 :            : 
    1221                 :            : // internal: Refresh the display
    1222                 :            : // nFlags: what we should update.
    1223                 :        364 : void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags)
    1224                 :            : {
    1225                 :            :     OSL_ENSURE(nFlags, "nothing to do");
    1226                 :        364 :     const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
    1227         [ +  + ]:        364 :     if (!pItem)
    1228                 :            :     {
    1229                 :            :         // Is the case for the template catalog
    1230                 :        120 :         SfxTemplateItem **ppItem = pFamilyState;
    1231                 :        120 :         const size_t nFamilyCount = pStyleFamilies->size();
    1232                 :            :         size_t n;
    1233         [ +  - ]:        120 :         for( n = 0; n < nFamilyCount; n++ )
    1234         [ +  - ]:        120 :             if( ppItem[ StyleNrToInfoOffset(n) ] ) break;
    1235         [ -  + ]:        120 :         if ( n == nFamilyCount )
    1236                 :            :             // It happens sometimes, God knows why
    1237                 :        364 :             return;
    1238                 :        120 :         ppItem += StyleNrToInfoOffset(n);
    1239                 :        120 :         nAppFilter = (*ppItem)->GetValue();
    1240                 :        120 :         FamilySelect(  StyleNrToInfoOffset(n)+1 );
    1241                 :        120 :         pItem = GetFamilyItem_Impl();
    1242                 :            :     }
    1243                 :            : 
    1244                 :        364 :     const SfxStyleFamily eFam = pItem->GetFamily();
    1245                 :            : 
    1246         [ +  - ]:        364 :     SfxFilterTupel* pT = ( nActFilter < pItem->GetFilterList().size() ? pItem->GetFilterList()[nActFilter] : NULL );
    1247         [ +  - ]:        364 :     sal_uInt16 nFilter     = pT ? pT->nFlags : 0;
    1248         [ +  + ]:        364 :     if(!nFilter)   // automatic
    1249                 :        354 :         nFilter = nAppFilter;
    1250                 :            : 
    1251                 :            :     OSL_ENSURE(pStyleSheetPool, "no StyleSheetPool");
    1252         [ +  - ]:        364 :     if(pStyleSheetPool)
    1253                 :            :     {
    1254                 :        364 :         pStyleSheetPool->SetSearchMask(eFam, nFilter);
    1255                 :        364 :         pItem = GetFamilyItem_Impl();
    1256         [ +  + ]:        364 :         if((nFlags & UPDATE_FAMILY) == UPDATE_FAMILY)   // Update view type list (Hierarchical, All, etc.
    1257                 :            :         {
    1258                 :        242 :             CheckItem(nActFamily, sal_True);    // check Button in Toolbox
    1259                 :        242 :             aFilterLb.SetUpdateMode(sal_False);
    1260                 :        242 :             aFilterLb.Clear();
    1261                 :            :             //insert hierarchical at the beginning
    1262 [ +  - ][ +  - ]:        242 :             sal_uInt16 nPos = aFilterLb.InsertEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL).toString(), 0);
         [ +  - ][ +  - ]
    1263                 :        242 :             aFilterLb.SetEntryData( nPos, (void*)(sal_uIntPtr)SFXSTYLEBIT_ALL );
    1264                 :        242 :             const SfxStyleFilter& rFilter = pItem->GetFilterList();
    1265         [ +  + ]:       2856 :             for( size_t i = 0; i < rFilter.size(); ++i)
    1266                 :            :             {
    1267                 :       2614 :                 sal_uIntPtr nFilterFlags = rFilter[ i ]->nFlags;
    1268                 :       2614 :                 nPos = aFilterLb.InsertEntry( rFilter[ i ]->aName );
    1269                 :       2614 :                 aFilterLb.SetEntryData( nPos, (void*)nFilterFlags );
    1270                 :            :             }
    1271         [ +  - ]:        242 :             if(nActFilter < aFilterLb.GetEntryCount() - 1)
    1272                 :        242 :                 aFilterLb.SelectEntryPos(nActFilter + 1);
    1273                 :            :             else
    1274                 :            :             {
    1275                 :          0 :                 nActFilter = 0;
    1276                 :          0 :                 aFilterLb.SelectEntryPos(1);
    1277         [ #  # ]:          0 :                 SfxFilterTupel* pActT = ( nActFilter < rFilter.size() ) ? rFilter[ nActFilter ] : NULL;
    1278         [ #  # ]:          0 :                 sal_uInt16 nFilterFlags = pActT ? pActT->nFlags : 0;
    1279                 :          0 :                 pStyleSheetPool->SetSearchMask(eFam, nFilterFlags);
    1280                 :            :             }
    1281                 :            : 
    1282                 :            :             // if the tree view again, select family hierarchy
    1283         [ -  + ]:        242 :             if(pTreeBox)
    1284 [ #  # ][ #  # ]:          0 :                 aFilterLb.SelectEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL).toString());
         [ #  # ][ #  # ]
    1285                 :            : 
    1286                 :            :             // show maximum 12 entries
    1287                 :        242 :             aFilterLb.SetDropDownLineCount( MAX_FILTER_ENTRIES );
    1288                 :        242 :             aFilterLb.SetUpdateMode(sal_True);
    1289                 :            :         }
    1290                 :            :         else
    1291                 :            :         {
    1292         [ +  - ]:        122 :             if( nActFilter < aFilterLb.GetEntryCount() - 1)
    1293                 :        122 :                 aFilterLb.SelectEntryPos(nActFilter + 1);
    1294                 :            :             else
    1295                 :            :             {
    1296                 :          0 :                 nActFilter = 0;
    1297                 :          0 :                 aFilterLb.SelectEntryPos(1);
    1298                 :            :             }
    1299                 :            :         }
    1300                 :            : 
    1301         [ +  - ]:        364 :         if(nFlags & UPDATE_FAMILY_LIST)
    1302                 :            :         {
    1303         [ +  - ]:        364 :             EnableItem(SID_STYLE_WATERCAN,sal_False);
    1304                 :            : 
    1305         [ +  - ]:        364 :             SfxStyleSheetBase *pStyle = pStyleSheetPool->First();
    1306         [ +  - ]:        364 :             SvLBoxEntry* pEntry = aFmtLb.First();
    1307         [ +  - ]:        364 :             std::vector<rtl::OUString> aStrings;
    1308                 :            : 
    1309                 :            :             comphelper::string::NaturalStringSorter aSorter(
    1310                 :            :                 ::comphelper::getProcessComponentContext(),
    1311 [ +  - ][ +  - ]:        364 :                 Application::GetSettings().GetLocale());
         [ +  - ][ +  - ]
    1312                 :            : 
    1313         [ +  + ]:       7594 :             while( pStyle )
    1314                 :            :             {
    1315                 :            :                 //Bubblesort
    1316                 :            :                 size_t nPos;
    1317 [ +  + ][ +  - ]:      31762 :                 for(nPos = aStrings.size(); nPos && aSorter.compare(aStrings[nPos-1], pStyle->GetName()) > 0; --nPos)
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
           [ +  +  #  # ]
    1318                 :            :                 {};
    1319 [ +  - ][ +  - ]:       7230 :                 aStrings.insert(aStrings.begin() + nPos, pStyle->GetName());
         [ +  - ][ +  - ]
    1320         [ +  - ]:       7230 :                 pStyle = pStyleSheetPool->Next();
    1321                 :            :             }
    1322                 :            : 
    1323                 :        364 :             size_t nCount = aStrings.size();
    1324                 :        364 :             size_t nPos = 0;
    1325         [ +  + ]:      15248 :             while(nPos < nCount && pEntry &&
           [ +  +  +  - ]
                 [ +  + ]
    1326 [ +  - ][ +  - ]:      10044 :                   aStrings[nPos] == rtl::OUString(aFmtLb.GetEntryText(pEntry)))
         [ +  + ][ +  + ]
                 [ +  - ]
           [ #  #  #  # ]
    1327                 :            :             {
    1328                 :       4840 :                 ++nPos;
    1329         [ +  - ]:       4840 :                 pEntry = aFmtLb.Next( pEntry );
    1330                 :            :             }
    1331                 :            : 
    1332 [ +  + ][ -  + ]:        364 :             if( nPos < nCount || pEntry )
    1333                 :            :             {
    1334                 :            :                 // Fills the display box
    1335         [ +  - ]:        120 :                 aFmtLb.SetUpdateMode(sal_False);
    1336         [ +  - ]:        120 :                 aFmtLb.Clear();
    1337                 :            : 
    1338         [ +  + ]:       2510 :                 for(nPos = 0; nPos < nCount; ++nPos)
    1339 [ +  - ][ +  - ]:       2390 :                     aFmtLb.InsertEntry(aStrings[nPos], 0, sal_False, nPos);
                 [ +  - ]
    1340                 :            : 
    1341         [ +  - ]:        120 :                 aFmtLb.SetUpdateMode(true);
    1342                 :            :             }
    1343                 :            :             // Selects the current style if any
    1344                 :        364 :             SfxTemplateItem *pState = pFamilyState[nActFamily-1];
    1345         [ +  - ]:        364 :             String aStyle;
    1346         [ +  - ]:        364 :             if(pState)
    1347         [ +  - ]:        364 :                 aStyle = pState->GetStyleName();
    1348         [ +  - ]:        364 :             SelectStyle(aStyle);
    1349 [ +  - ][ +  - ]:        364 :             EnableDelete();
                 [ +  - ]
    1350                 :            :         }
    1351                 :            :     }
    1352                 :            : }
    1353                 :            : 
    1354                 :            : //-------------------------------------------------------------------------
    1355                 :            : 
    1356                 :            : // Updated display: Watering the house
    1357                 :        205 : void SfxCommonTemplateDialog_Impl::SetWaterCanState(const SfxBoolItem *pItem)
    1358                 :            : {
    1359                 :        205 :     bWaterDisabled =  pItem == 0;
    1360                 :            : 
    1361         [ +  + ]:        205 :     if(!bWaterDisabled)
    1362                 :         87 :         bWaterDisabled = !HasSelectedStyle();
    1363                 :            : 
    1364 [ +  + ][ +  + ]:        205 :     if(pItem && !bWaterDisabled)
    1365                 :            :     {
    1366                 :         83 :         CheckItem(SID_STYLE_WATERCAN, pItem->GetValue());
    1367                 :         83 :         EnableItem( SID_STYLE_WATERCAN, sal_True );
    1368                 :            :     }
    1369                 :            :     else
    1370         [ -  + ]:        122 :         if(!bWaterDisabled)
    1371                 :          0 :             EnableItem(SID_STYLE_WATERCAN, sal_True);
    1372                 :            :         else
    1373                 :        122 :             EnableItem(SID_STYLE_WATERCAN, sal_False);
    1374                 :            : 
    1375                 :            : // Ignore while in watercan mode statusupdates
    1376                 :            : 
    1377                 :        205 :     size_t nCount = pStyleFamilies->size();
    1378                 :        205 :     pBindings->EnterRegistrations();
    1379         [ +  + ]:       1218 :     for(size_t n = 0; n < nCount; n++)
    1380                 :            :     {
    1381                 :       1013 :         SfxControllerItem *pCItem=pBoundItems[n];
    1382 [ +  + ][ -  + ]:       1013 :         sal_Bool bChecked = pItem && pItem->GetValue();
    1383         [ -  + ]:       1013 :         if( pCItem->IsBound() == bChecked )
    1384                 :            :         {
    1385         [ #  # ]:          0 :             if( !bChecked )
    1386                 :          0 :                 pCItem->ReBind();
    1387                 :            :             else
    1388                 :          0 :                 pCItem->UnBind();
    1389                 :            :         }
    1390                 :            :     }
    1391                 :        205 :     pBindings->LeaveRegistrations();
    1392                 :        205 : }
    1393                 :            : 
    1394                 :            : //-------------------------------------------------------------------------
    1395                 :            : 
    1396                 :            : // Item with the status of a Family is copied and noted
    1397                 :            : // (is updated when all states have also been updated.)
    1398                 :            : // See also: <SfxBindings::AddDoneHdl(const Link &)>
    1399                 :            : 
    1400                 :        594 : void SfxCommonTemplateDialog_Impl::SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* pItem )
    1401                 :            : {
    1402                 :        594 :     sal_uInt16 nIdx = nSlotId - SID_STYLE_FAMILY_START;
    1403         [ -  + ]:        594 :     DELETEZ(pFamilyState[nIdx]);
    1404         [ +  + ]:        594 :     if ( pItem )
    1405         [ +  - ]:        474 :         pFamilyState[nIdx] = new SfxTemplateItem(*pItem);
    1406                 :        594 :     bUpdate = sal_True;
    1407                 :            : 
    1408                 :            :     // If used templates (how the hell you find this out??)
    1409                 :        594 :     bUpdateFamily = sal_True;
    1410                 :        594 : }
    1411                 :            : 
    1412                 :            : //-------------------------------------------------------------------------
    1413                 :            : // Notice from SfxBindings that the update is completed. Pushes out the update
    1414                 :            : // of the display.
    1415                 :            : 
    1416                 :        200 : void SfxCommonTemplateDialog_Impl::Update_Impl()
    1417                 :            : {
    1418                 :        200 :     sal_Bool bDocChanged=sal_False;
    1419                 :        200 :     SfxStyleSheetBasePool* pNewPool = NULL;
    1420         [ +  - ]:        200 :     SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
    1421         [ +  - ]:        200 :     SfxObjectShell* pDocShell = pViewFrame->GetObjectShell();
    1422         [ +  - ]:        200 :     if( pDocShell )
    1423         [ +  - ]:        200 :         pNewPool = pDocShell->GetStyleSheetPool();
    1424                 :            : 
    1425 [ +  + ][ +  - ]:        200 :     if ( pNewPool != pStyleSheetPool && pDocShell )
    1426                 :            :     {
    1427         [ +  - ]:        120 :         SfxModule* pNewModule = pDocShell->GetModule();
    1428 [ +  - ][ -  + ]:        120 :         if( pNewModule && pNewModule != pModule )
    1429                 :            :         {
    1430         [ #  # ]:          0 :             ClearResource();
    1431         [ #  # ]:          0 :             ReadResource();
    1432                 :            :         }
    1433         [ -  + ]:        120 :         if ( pStyleSheetPool )
    1434                 :            :         {
    1435         [ #  # ]:          0 :             EndListening(*pStyleSheetPool);
    1436                 :          0 :             pStyleSheetPool = 0;
    1437                 :            :         }
    1438                 :            : 
    1439         [ +  - ]:        120 :         if ( pNewPool )
    1440                 :            :         {
    1441         [ +  - ]:        120 :             StartListening(*pNewPool);
    1442                 :        120 :             pStyleSheetPool = pNewPool;
    1443                 :        120 :             bDocChanged=sal_True;
    1444                 :            :         }
    1445                 :            :     }
    1446                 :            : 
    1447         [ +  + ]:        200 :     if (bUpdateFamily)
    1448         [ +  - ]:        122 :         UpdateFamily_Impl();
    1449                 :            : 
    1450                 :            :     sal_uInt16 i;
    1451         [ +  - ]:        205 :     for(i = 0; i < MAX_FAMILIES; ++i)
    1452         [ +  + ]:        205 :         if(pFamilyState[i])
    1453                 :        200 :             break;
    1454 [ +  - ][ +  - ]:        200 :     if(i == MAX_FAMILIES || !pNewPool)
    1455                 :            :         // nothing is allowed
    1456                 :        200 :         return;
    1457                 :            : 
    1458                 :        200 :      SfxTemplateItem *pItem = 0;
    1459                 :            :      // current region not within the allowed region or default
    1460 [ +  - ][ -  + ]:        200 :      if(nActFamily == 0xffff || 0 == (pItem = pFamilyState[nActFamily-1] ) )
                 [ -  + ]
    1461                 :            :      {
    1462         [ #  # ]:          0 :          CheckItem(nActFamily, sal_False);
    1463                 :          0 :          SfxTemplateItem **ppItem = pFamilyState;
    1464                 :          0 :          const size_t nFamilyCount = pStyleFamilies->size();
    1465                 :            :          size_t n;
    1466         [ #  # ]:          0 :          for( n = 0; n < nFamilyCount; n++ )
    1467 [ #  # ][ #  # ]:          0 :              if( ppItem[ StyleNrToInfoOffset(n) ] ) break;
    1468         [ #  # ]:          0 :          ppItem+=StyleNrToInfoOffset(n);
    1469                 :            : 
    1470                 :          0 :          nAppFilter = (*ppItem)->GetValue();
    1471 [ #  # ][ #  # ]:          0 :          FamilySelect(  StyleNrToInfoOffset(n)+1 );
    1472                 :            : 
    1473                 :          0 :          pItem = *ppItem;
    1474                 :            :      }
    1475         [ +  + ]:        200 :      else if( bDocChanged )
    1476                 :            :      {
    1477                 :            :          // other DocShell -> all new
    1478         [ +  - ]:        120 :          CheckItem( nActFamily, sal_True );
    1479         [ +  - ]:        120 :          nActFilter = static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pDocShell ) );
    1480         [ +  - ]:        120 :          if ( 0xFFFF == nActFilter )
    1481         [ +  - ]:        120 :             nActFilter = pDocShell->GetAutoStyleFilterIndex();
    1482                 :            : 
    1483                 :        120 :          nAppFilter = pItem->GetValue();
    1484         [ +  - ]:        120 :          if(!pTreeBox)
    1485                 :            :          {
    1486         [ +  - ]:        120 :              UpdateStyles_Impl(UPDATE_FAMILY_LIST);
    1487                 :            :          }
    1488                 :            :          else
    1489         [ #  # ]:          0 :              FillTreeBox();
    1490                 :            :      }
    1491                 :            :      else
    1492                 :            :      {
    1493                 :            :          // other filters for automatic
    1494         [ +  - ]:         80 :          CheckItem( nActFamily, sal_True );
    1495         [ +  - ]:         80 :          const SfxStyleFamilyItem *pStyleItem =  GetFamilyItem_Impl();
    1496   [ +  +  -  + ]:        157 :          if (  0 == pStyleItem->GetFilterList()[ nActFilter ]->nFlags
                 [ -  + ]
    1497                 :         77 :             && nAppFilter != pItem->GetValue())
    1498                 :            :          {
    1499                 :          0 :              nAppFilter = pItem->GetValue();
    1500         [ #  # ]:          0 :              if(!pTreeBox)
    1501         [ #  # ]:          0 :                  UpdateStyles_Impl(UPDATE_FAMILY_LIST);
    1502                 :            :              else
    1503         [ #  # ]:          0 :                  FillTreeBox();
    1504                 :            :          }
    1505                 :            :          else
    1506                 :         80 :              nAppFilter = pItem->GetValue();
    1507                 :            :      }
    1508         [ +  - ]:        200 :      const String aStyle(pItem->GetStyleName());
    1509         [ +  - ]:        200 :      SelectStyle(aStyle);
    1510         [ +  - ]:        200 :      EnableDelete();
    1511 [ +  - ][ +  - ]:        200 :      EnableNew( bCanNew );
    1512                 :            : }
    1513                 :            : 
    1514                 :            : //-------------------------------------------------------------------------
    1515                 :            : 
    1516                 :          2 : IMPL_LINK( SfxCommonTemplateDialog_Impl, TimeOut, Timer *, pTim )
    1517                 :            : {
    1518                 :            :     (void)pTim; // unused
    1519         [ +  - ]:          2 :     if(!bDontUpdate)
    1520                 :            :     {
    1521                 :          2 :         bDontUpdate=sal_True;
    1522         [ +  - ]:          2 :         if(!pTreeBox)
    1523                 :          2 :             UpdateStyles_Impl(UPDATE_FAMILY_LIST);
    1524                 :            :         else
    1525                 :            :         {
    1526                 :          0 :             FillTreeBox();
    1527                 :          0 :             SfxTemplateItem *pState = pFamilyState[nActFamily-1];
    1528         [ #  # ]:          0 :             if(pState)
    1529                 :            :             {
    1530         [ #  # ]:          0 :                 const String aStyle(pState->GetStyleName());
    1531         [ #  # ]:          0 :                 SelectStyle(aStyle);
    1532 [ #  # ][ #  # ]:          0 :                 EnableDelete();
    1533                 :            :             }
    1534                 :            :         }
    1535                 :          2 :         bDontUpdate=sal_False;
    1536         [ +  - ]:          2 :         DELETEZ(pTimer);
    1537                 :            :     }
    1538                 :            :     else
    1539                 :          0 :         pTimer->Start();
    1540                 :          2 :     return 0;
    1541                 :            : }
    1542                 :            : 
    1543                 :            : 
    1544                 :            : //-------------------------------------------------------------------------
    1545                 :        425 : void SfxCommonTemplateDialog_Impl::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
    1546                 :            : {
    1547                 :            :     // tap update
    1548         [ +  + ]:        425 :     if(rHint.Type() == TYPE(SfxSimpleHint))
    1549                 :            :     {
    1550   [ +  +  -  - ]:        415 :         switch(((SfxSimpleHint&) rHint ).GetId())
    1551                 :            :         {
    1552                 :            :           case SFX_HINT_UPDATEDONE:
    1553                 :            :             {
    1554                 :        101 :                 SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
    1555                 :        101 :                 SfxObjectShell *pDocShell = pViewFrame->GetObjectShell();
    1556   [ #  #  #  # ]:        181 :                 if (
                 [ +  + ]
           [ +  +  -  + ]
    1557                 :            :                     bUpdate &&
    1558                 :            :                     (
    1559                 :         80 :                      !IsCheckedItem(SID_STYLE_WATERCAN) ||
    1560                 :          0 :                      (pDocShell && pDocShell->GetStyleSheetPool() != pStyleSheetPool)
    1561                 :            :                     )
    1562                 :            :                    )
    1563                 :            :                 {
    1564                 :         80 :                     bUpdate = sal_False;
    1565                 :         80 :                     Update_Impl();
    1566                 :            :                 }
    1567         [ -  + ]:         21 :                 else if ( bUpdateFamily )
    1568                 :            :                 {
    1569                 :          0 :                     UpdateFamily_Impl();
    1570                 :            :                 }
    1571                 :            : 
    1572         [ +  - ]:        101 :                 if( pStyleSheetPool )
    1573                 :            :                 {
    1574         [ +  - ]:        101 :                     String aStr = GetSelectedEntry();
    1575 [ +  + ][ +  - ]:        101 :                     if( aStr.Len() && pStyleSheetPool )
                 [ +  + ]
    1576                 :            :                     {
    1577         [ +  - ]:         94 :                         const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
    1578         [ -  + ]:         94 :                         if( !pItem ) break;
    1579                 :         94 :                         const SfxStyleFamily eFam = pItem->GetFamily();
    1580                 :            :                         SfxStyleSheetBase *pStyle =
    1581                 :            :                             pStyleSheetPool->Find(
    1582         [ +  - ]:         94 :                                 aStr, eFam, SFXSTYLEBIT_ALL );
    1583         [ +  - ]:         94 :                         if( pStyle )
    1584                 :            :                             EnableEdit(
    1585         [ +  - ]:         94 :                                 !(pStyle->GetMask() & SFXSTYLEBIT_READONLY) );
    1586                 :            :                         else
    1587         [ #  # ]:        101 :                             EnableEdit(sal_False);
    1588 [ +  - ][ +  - ]:        101 :                     }
    1589                 :            :                 }
    1590                 :        101 :                 break;
    1591                 :            :             }
    1592                 :            : 
    1593                 :            :         // Necessary if switching between documents and in both documents
    1594                 :            :         // the same template is used. Do not immediately call Update_Impl,
    1595                 :            :         // for the case that one of the documents is an internal InPlaceObjekt!
    1596                 :            :           case SFX_HINT_DOCCHANGED:
    1597                 :        314 :             bUpdate = sal_True;
    1598                 :        314 :             break;
    1599                 :            :           case SFX_HINT_DYING:
    1600                 :            :           {
    1601                 :          0 :             EndListening(*pStyleSheetPool);
    1602                 :          0 :             pStyleSheetPool=0;
    1603                 :        415 :             break;
    1604                 :            :           }
    1605                 :            :         }
    1606                 :            :     }
    1607                 :            : 
    1608                 :            :     // Do not set timer when the stylesheet pool is in the box, because it is
    1609                 :            :     // possible that a new one is registered after the timer is up -
    1610                 :            :     // works bad in UpdateStyles_Impl ()!
    1611                 :            : 
    1612         [ +  + ]:        425 :     sal_uIntPtr nId = rHint.ISA(SfxSimpleHint) ? ( (SfxSimpleHint&)rHint ).GetId() : 0;
    1613                 :            : 
    1614 [ +  - ][ +  -  :       1696 :     if(!bDontUpdate && nId != SFX_HINT_DYING &&
          +  +  +  -  -  
              + ][ +  + ]
    1615                 :        425 :        (rHint.Type() == TYPE(SfxStyleSheetPoolHint)||
    1616                 :        423 :        rHint.Type() == TYPE(SfxStyleSheetHint) ||
    1617                 :        423 :        rHint.Type() == TYPE( SfxStyleSheetHintExtended )))
    1618                 :            :     {
    1619         [ +  - ]:          2 :         if(!pTimer)
    1620                 :            :         {
    1621         [ +  - ]:          2 :             pTimer=new Timer;
    1622                 :          2 :             pTimer->SetTimeout(500);
    1623                 :          2 :             pTimer->SetTimeoutHdl(LINK(this,SfxCommonTemplateDialog_Impl,TimeOut));
    1624                 :            :         }
    1625                 :          2 :         pTimer->Start();
    1626                 :            : 
    1627                 :            :     }
    1628                 :        425 : }
    1629                 :            : 
    1630                 :            : 
    1631                 :            : //-------------------------------------------------------------------------
    1632                 :            : 
    1633                 :            : // Other filters; can be switched by the users or as a result of new or
    1634                 :            : // editing, if the current document has been assigned a different filter.
    1635                 :          0 : void SfxCommonTemplateDialog_Impl::FilterSelect(
    1636                 :            :                 sal_uInt16 nEntry,  // Idx of the new Filters
    1637                 :            :                 sal_Bool bForce )   // Force update, even if the new filter is
    1638                 :            :                                 // equal to the current
    1639                 :            : {
    1640 [ #  # ][ #  # ]:          0 :     if( nEntry != nActFilter || bForce )
    1641                 :            :     {
    1642                 :          0 :         nActFilter = nEntry;
    1643                 :          0 :         SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
    1644                 :          0 :         SfxObjectShell *pDocShell = pViewFrame->GetObjectShell();
    1645         [ #  # ]:          0 :         if (pDocShell)
    1646                 :            :         {
    1647                 :          0 :             pDocShell->SetAutoStyleFilterIndex(nActFilter);
    1648                 :          0 :             SaveFactoryStyleFilter( pDocShell, nActFilter );
    1649                 :            :         }
    1650                 :            : 
    1651                 :          0 :         SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool;
    1652         [ #  # ]:          0 :         pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): 0;
    1653         [ #  # ]:          0 :         if ( pOldStyleSheetPool != pStyleSheetPool )
    1654                 :            :         {
    1655         [ #  # ]:          0 :             if ( pOldStyleSheetPool )
    1656                 :          0 :                 EndListening(*pOldStyleSheetPool);
    1657         [ #  # ]:          0 :             if ( pStyleSheetPool )
    1658                 :          0 :                 StartListening(*pOldStyleSheetPool);
    1659                 :            :         }
    1660                 :            : 
    1661                 :          0 :         UpdateStyles_Impl(UPDATE_FAMILY_LIST);
    1662                 :            :     }
    1663                 :          0 : }
    1664                 :            : 
    1665                 :            : //-------------------------------------------------------------------------
    1666                 :            : 
    1667                 :            : // Internal: Perform functions through the Dispatcher
    1668                 :          0 : sal_Bool SfxCommonTemplateDialog_Impl::Execute_Impl(
    1669                 :            :     sal_uInt16 nId, const String &rStr, const String& rRefStr, sal_uInt16 nFamily,
    1670                 :            :     sal_uInt16 nMask, sal_uInt16 *pIdx, const sal_uInt16* pModifier)
    1671                 :            : {
    1672 [ #  # ][ #  # ]:          0 :     SfxDispatcher &rDispatcher = *SFX_APP()->GetDispatcher_Impl();
    1673         [ #  # ]:          0 :     SfxStringItem aItem(nId, rStr);
    1674         [ #  # ]:          0 :     SfxUInt16Item aFamily(SID_STYLE_FAMILY, nFamily);
    1675         [ #  # ]:          0 :     SfxUInt16Item aMask( SID_STYLE_MASK, nMask );
    1676         [ #  # ]:          0 :     SfxStringItem aUpdName(SID_STYLE_UPD_BY_EX_NAME, rStr);
    1677         [ #  # ]:          0 :     SfxStringItem aRefName( SID_STYLE_REFERENCE, rRefStr );
    1678                 :            :     const SfxPoolItem* pItems[ 6 ];
    1679                 :          0 :     sal_uInt16 nCount = 0;
    1680         [ #  # ]:          0 :     if( rStr.Len() )
    1681                 :          0 :         pItems[ nCount++ ] = &aItem;
    1682                 :          0 :     pItems[ nCount++ ] = &aFamily;
    1683         [ #  # ]:          0 :     if( nMask )
    1684                 :          0 :         pItems[ nCount++ ] = &aMask;
    1685         [ #  # ]:          0 :     if(SID_STYLE_UPDATE_BY_EXAMPLE == nId)
    1686                 :            :     {
    1687                 :            :         // Special solution for Numbering update in Writer
    1688         [ #  # ]:          0 :         const String aTemplName(GetSelectedEntry());
    1689         [ #  # ]:          0 :         aUpdName.SetValue(aTemplName);
    1690         [ #  # ]:          0 :         pItems[ nCount++ ] = &aUpdName;
    1691                 :            :     }
    1692         [ #  # ]:          0 :     if ( rRefStr.Len() )
    1693                 :          0 :         pItems[ nCount++ ] = &aRefName;
    1694                 :            : 
    1695                 :          0 :     pItems[ nCount++ ] = 0;
    1696                 :            : 
    1697         [ #  # ]:          0 :     DeletionWatcher aDeleted(*this);
    1698         [ #  # ]:          0 :     sal_uInt16 nModi = pModifier ? *pModifier : 0;
    1699                 :            :     const SfxPoolItem* pItem = rDispatcher.Execute(
    1700                 :            :         nId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL,
    1701         [ #  # ]:          0 :         pItems, nModi );
    1702                 :            : 
    1703                 :            :     // Dialog can be destroyed while in Execute() because started
    1704                 :            :     // subdialogs are not modal to it (#i97888#).
    1705 [ #  # ][ #  # ]:          0 :     if ( !pItem || aDeleted )
                 [ #  # ]
    1706                 :          0 :         return sal_False;
    1707                 :            : 
    1708 [ #  # ][ #  # ]:          0 :     if ( nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId )
    1709                 :            :     {
    1710 [ #  # ][ #  # ]:          0 :         SfxUInt16Item *pFilterItem = PTR_CAST(SfxUInt16Item, pItem);
         [ #  # ][ #  # ]
    1711                 :            :         OSL_ENSURE(pFilterItem, "SfxUINT16Item expected");
    1712                 :          0 :         sal_uInt16 nFilterFlags = pFilterItem->GetValue() & ~SFXSTYLEBIT_USERDEF;
    1713         [ #  # ]:          0 :         if(!nFilterFlags)       // User Template?
    1714                 :          0 :             nFilterFlags = pFilterItem->GetValue();
    1715         [ #  # ]:          0 :         const SfxStyleFamilyItem *pFamilyItem = GetFamilyItem_Impl();
    1716                 :          0 :         const size_t nFilterCount = pFamilyItem->GetFilterList().size();
    1717                 :            : 
    1718         [ #  # ]:          0 :         for ( size_t i = 0; i < nFilterCount; ++i )
    1719                 :            :         {
    1720                 :          0 :             const SfxFilterTupel *pTupel = pFamilyItem->GetFilterList()[ i ];
    1721                 :            : 
    1722 [ #  # ][ #  # ]:          0 :             if ( ( pTupel->nFlags & nFilterFlags ) == nFilterFlags && pIdx )
    1723                 :          0 :                 *pIdx = i;
    1724                 :            :         }
    1725                 :            :     }
    1726                 :            : 
    1727 [ #  # ][ #  # ]:          0 :     return sal_True;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1728                 :            : }
    1729                 :            : 
    1730                 :            : //-------------------------------------------------------------------------
    1731                 :            : 
    1732                 :            : // Handler der Listbox der Filter
    1733                 :          0 : IMPL_LINK( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox *, pBox )
    1734                 :            : {
    1735 [ #  # ][ #  # ]:          0 :     if ( SfxResId(STR_STYLE_FILTER_HIERARCHICAL).toString().equals(pBox->GetSelectEntry()) )
         [ #  # ][ #  # ]
    1736                 :            :     {
    1737         [ #  # ]:          0 :         if ( !bHierarchical )
    1738                 :            :         {
    1739                 :            :             // Turn on treeView
    1740                 :          0 :             bHierarchical=sal_True;
    1741         [ #  # ]:          0 :             const String aSelectEntry( GetSelectedEntry());
    1742         [ #  # ]:          0 :             aFmtLb.Hide();
    1743                 :            : 
    1744                 :            :             pTreeBox = new StyleTreeListBox_Impl(
    1745                 :            :                     this, WB_HASBUTTONS | WB_HASLINES |
    1746                 :            :                     WB_BORDER | WB_TABSTOP | WB_HASLINESATROOT |
    1747 [ #  # ][ #  # ]:          0 :                     WB_HASBUTTONSATROOT | WB_HIDESELECTION | WB_QUICK_SEARCH );
    1748         [ #  # ]:          0 :             pTreeBox->SetFont( aFmtLb.GetFont() );
    1749                 :            : 
    1750 [ #  # ][ #  # ]:          0 :             pTreeBox->SetPosSizePixel(aFmtLb.GetPosPixel(), aFmtLb.GetSizePixel());
                 [ #  # ]
    1751         [ #  # ]:          0 :             pTreeBox->SetNodeDefaultImages();
    1752                 :            :             pTreeBox->SetSelectHdl(
    1753         [ #  # ]:          0 :                 LINK(this, SfxCommonTemplateDialog_Impl, FmtSelectHdl));
    1754                 :            :             ((StyleTreeListBox_Impl*)pTreeBox)->
    1755                 :            :                 SetDoubleClickHdl(
    1756         [ #  # ]:          0 :                     LINK(this, SfxCommonTemplateDialog_Impl,  ApplyHdl));
    1757                 :            :             ((StyleTreeListBox_Impl*)pTreeBox)->
    1758         [ #  # ]:          0 :                 SetDropHdl(LINK(this, SfxCommonTemplateDialog_Impl,  DropHdl));
    1759         [ #  # ]:          0 :             pTreeBox->SetIndent(10);
    1760         [ #  # ]:          0 :             FillTreeBox();
    1761         [ #  # ]:          0 :             SelectStyle(aSelectEntry);
    1762 [ #  # ][ #  # ]:          0 :             pTreeBox->SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST).toString());
         [ #  # ][ #  # ]
                 [ #  # ]
    1763 [ #  # ][ #  # ]:          0 :             pTreeBox->Show();
    1764                 :            :         }
    1765                 :            :     }
    1766                 :            : 
    1767                 :            :     else
    1768                 :            :     {
    1769         [ #  # ]:          0 :         DELETEZ(pTreeBox);
    1770                 :          0 :         aFmtLb.Show();
    1771                 :            :         // If bHierarchical, then the family can have changed
    1772                 :            :         // minus one since hierarchical is inserted at the start
    1773                 :          0 :         FilterSelect(pBox->GetSelectEntryPos() - 1, bHierarchical );
    1774                 :          0 :         bHierarchical=sal_False;
    1775                 :            :     }
    1776                 :            : 
    1777                 :          0 :     return 0;
    1778                 :            : }
    1779                 :            : 
    1780                 :            : //-------------------------------------------------------------------------
    1781                 :            : 
    1782                 :            : // Select-Handler for the Toolbox
    1783                 :        120 : void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry)
    1784                 :            : {
    1785         [ +  - ]:        120 :     if( nEntry != nActFamily )
    1786                 :            :     {
    1787         [ +  - ]:        120 :         CheckItem( nActFamily, sal_False );
    1788                 :        120 :         nActFamily = nEntry;
    1789                 :        120 :         SfxDispatcher* pDispat = pBindings->GetDispatcher_Impl();
    1790         [ +  - ]:        120 :         SfxUInt16Item aItem( SID_STYLE_FAMILY, nEntry );
    1791         [ +  - ]:        120 :         pDispat->Execute( SID_STYLE_FAMILY, SFX_CALLMODE_SYNCHRON, &aItem, 0L );
    1792         [ +  - ]:        120 :         pBindings->Invalidate( SID_STYLE_FAMILY );
    1793         [ +  - ]:        120 :         pBindings->Update( SID_STYLE_FAMILY );
    1794 [ +  - ][ +  - ]:        120 :         UpdateFamily_Impl();
    1795                 :            :     }
    1796                 :        120 : }
    1797                 :            : 
    1798                 :            : //-------------------------------------------------------------------------
    1799                 :            : 
    1800                 :          0 : void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry)
    1801                 :            : {
    1802         [ #  # ]:          0 :     String aEmpty;
    1803   [ #  #  #  #  :          0 :     switch(nEntry)
                      # ]
    1804                 :            :     {
    1805                 :            :         case SID_STYLE_WATERCAN:
    1806                 :            :         {
    1807         [ #  # ]:          0 :             const sal_Bool bState = IsCheckedItem(nEntry);
    1808                 :            :             sal_Bool bCheck;
    1809         [ #  # ]:          0 :             SfxBoolItem aBool;
    1810                 :            :             // when a template is chosen.
    1811 [ #  # ][ #  # ]:          0 :             if(!bState && aFmtLb.GetSelectionCount())
                 [ #  # ]
    1812                 :            :             {
    1813                 :            :                 const String aTemplName(
    1814         [ #  # ]:          0 :                     GetSelectedEntry());
    1815                 :            :                 Execute_Impl(
    1816                 :            :                     SID_STYLE_WATERCAN, aTemplName, aEmpty,
    1817 [ #  # ][ #  # ]:          0 :                     (sal_uInt16)GetFamilyItem_Impl()->GetFamily() );
    1818         [ #  # ]:          0 :                 bCheck = sal_True;
    1819                 :            :             }
    1820                 :            :             else
    1821                 :            :             {
    1822         [ #  # ]:          0 :                 Execute_Impl(SID_STYLE_WATERCAN, aEmpty, aEmpty, 0);
    1823                 :          0 :                 bCheck = sal_False;
    1824                 :            :             }
    1825         [ #  # ]:          0 :             CheckItem(nEntry, bCheck);
    1826                 :          0 :             aBool.SetValue(bCheck);
    1827         [ #  # ]:          0 :             SetWaterCanState(&aBool);
    1828         [ #  # ]:          0 :             break;
    1829                 :            :         }
    1830                 :            :         case SID_STYLE_NEW_BY_EXAMPLE:
    1831                 :            :         {
    1832 [ #  # ][ #  # ]:          0 :             if(pStyleSheetPool && nActFamily != 0xffff)
    1833                 :            :             {
    1834         [ #  # ]:          0 :                 const SfxStyleFamily eFam=GetFamilyItem_Impl()->GetFamily();
    1835         [ #  # ]:          0 :                 const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
    1836                 :            :                 sal_uInt16 nFilter;
    1837 [ #  # ][ #  # ]:          0 :                 if( pItem && nActFilter != 0xffff )
    1838                 :            :                 {
    1839                 :          0 :                     nFilter = pItem->GetFilterList()[ nActFilter ]->nFlags;
    1840         [ #  # ]:          0 :                     if(!nFilter)    // automatisch
    1841                 :          0 :                         nFilter = nAppFilter;
    1842                 :            :                 }
    1843                 :            :                 else
    1844         [ #  # ]:          0 :                     nFilter=pStyleSheetPool->GetSearchMask();
    1845         [ #  # ]:          0 :                 pStyleSheetPool->SetSearchMask( eFam, SFXSTYLEBIT_USERDEF );
    1846                 :            : 
    1847 [ #  # ][ #  # ]:          0 :                 SfxNewStyleDlg *pDlg = new SfxNewStyleDlg(pWindow, *pStyleSheetPool);
    1848                 :            :                     // why? : FloatingWindow must not be parent of a modal dialog
    1849 [ #  # ][ #  # ]:          0 :                 if(RET_OK == pDlg->Execute())
    1850                 :            :                 {
    1851         [ #  # ]:          0 :                     pStyleSheetPool->SetSearchMask(eFam, nFilter);
    1852         [ #  # ]:          0 :                     const String aTemplName(pDlg->GetName());
    1853                 :            :                     Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE,
    1854                 :            :                                  aTemplName, aEmpty,
    1855         [ #  # ]:          0 :                                  (sal_uInt16)GetFamilyItem_Impl()->GetFamily(),
    1856 [ #  # ][ #  # ]:          0 :                                  nFilter);
    1857                 :            :                 }
    1858         [ #  # ]:          0 :                 pStyleSheetPool->SetSearchMask( eFam, nFilter );
    1859 [ #  # ][ #  # ]:          0 :                 delete pDlg;
    1860                 :            :             }
    1861                 :          0 :             break;
    1862                 :            :         }
    1863                 :            :         case SID_STYLE_UPDATE_BY_EXAMPLE:
    1864                 :            :         {
    1865                 :            :             Execute_Impl(SID_STYLE_UPDATE_BY_EXAMPLE,
    1866                 :            :                     aEmpty, aEmpty,
    1867 [ #  # ][ #  # ]:          0 :                     (sal_uInt16)GetFamilyItem_Impl()->GetFamily());
    1868                 :          0 :             break;
    1869                 :            :         }
    1870                 :            :         case SID_TEMPLATE_LOAD:
    1871 [ #  # ][ #  # ]:          0 :             SFX_APP()->GetDispatcher_Impl()->Execute(nEntry);
                 [ #  # ]
    1872                 :          0 :         break;
    1873                 :          0 :         default: OSL_FAIL("not implemented"); break;
    1874         [ #  # ]:          0 :     }
    1875                 :          0 : }
    1876                 :            : 
    1877                 :            : //-------------------------------------------------------------------------
    1878                 :            : 
    1879                 :        240 : static rtl::OUString getModuleIdentifier( const Reference< XModuleManager >& i_xModMgr, SfxObjectShell* i_pObjSh )
    1880                 :            : {
    1881                 :            :     OSL_ENSURE( i_xModMgr.is(), "getModuleIdentifier(): no XModuleManager" );
    1882                 :            :     OSL_ENSURE( i_pObjSh, "getModuleIdentifier(): no ObjectShell" );
    1883                 :            : 
    1884                 :        240 :     ::rtl::OUString sIdentifier;
    1885                 :            : 
    1886                 :            :     try
    1887                 :            :     {
    1888 [ +  - ][ +  - ]:        240 :         sIdentifier = i_xModMgr->identify( i_pObjSh->GetModel() );
              [ #  #  # ]
                 [ +  - ]
    1889                 :            :     }
    1890         [ #  # ]:          0 :     catch ( ::com::sun::star::frame::UnknownModuleException& )
    1891                 :            :     {
    1892                 :            :         OSL_TRACE( "getModuleIdentifier(): unknown module" );
    1893                 :            :     }
    1894         [ #  # ]:          0 :     catch ( Exception& )
    1895                 :            :     {
    1896                 :            :         OSL_FAIL( "getModuleIdentifier(): exception of XModuleManager::identify()" );
    1897                 :            :     }
    1898                 :            : 
    1899                 :        240 :     return sIdentifier;
    1900                 :            : }
    1901                 :            : 
    1902                 :            : //-------------------------------------------------------------------------
    1903                 :            : 
    1904                 :        240 : sal_Int32 SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh )
    1905                 :            : {
    1906                 :            :     OSL_ENSURE( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" );
    1907                 :        240 :     sal_Int32 nFilter = -1;
    1908                 :            : 
    1909         [ +  - ]:        240 :     Sequence< PropertyValue > lProps;
    1910         [ +  - ]:        240 :     Reference< ::com::sun::star::container::XNameAccess > xContainer( xModuleManager, UNO_QUERY );
    1911         [ +  - ]:        240 :     if ( xContainer.is() )
    1912                 :            :     {
    1913                 :            :         ::comphelper::SequenceAsHashMap aFactoryProps(
    1914 [ +  - ][ +  - ]:        240 :             xContainer->getByName( getModuleIdentifier( xModuleManager, i_pObjSh ) ) );
         [ +  - ][ +  - ]
    1915                 :        240 :         sal_Int32 nDefault = -1;
    1916 [ +  - ][ +  - ]:        240 :         nFilter = aFactoryProps.getUnpackedValueOrDefault( DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"), nDefault );
         [ +  - ][ +  - ]
                 [ +  - ]
    1917                 :            :     }
    1918                 :            : 
    1919         [ +  - ]:        240 :     return nFilter;
    1920                 :            : }
    1921                 :            : 
    1922                 :            : //-------------------------------------------------------------------------
    1923                 :            : 
    1924                 :          0 : void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter )
    1925                 :            : {
    1926                 :            :     OSL_ENSURE( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" );
    1927         [ #  # ]:          0 :     Reference< ::com::sun::star::container::XNameReplace > xContainer( xModuleManager, UNO_QUERY );
    1928         [ #  # ]:          0 :     if ( xContainer.is() )
    1929                 :            :     {
    1930         [ #  # ]:          0 :         Sequence< PropertyValue > lProps(1);
    1931 [ #  # ][ #  # ]:          0 :         lProps[0].Name = DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter");
         [ #  # ][ #  # ]
    1932 [ #  # ][ #  # ]:          0 :         lProps[0].Value = makeAny( i_nFilter );;
    1933 [ #  # ][ #  # ]:          0 :         xContainer->replaceByName( getModuleIdentifier( xModuleManager, i_pObjSh ), makeAny( lProps ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1934                 :          0 :     }
    1935                 :          0 : }
    1936                 :            : 
    1937                 :            : //-------------------------------------------------------------------------
    1938                 :            : 
    1939                 :          0 : IMPL_LINK( SfxCommonTemplateDialog_Impl, DropHdl, StyleTreeListBox_Impl *, pBox )
    1940                 :            : {
    1941                 :          0 :     bDontUpdate=sal_True;
    1942                 :          0 :     const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
    1943                 :          0 :     const SfxStyleFamily eFam = pItem->GetFamily();
    1944         [ #  # ]:          0 :     long ret= pStyleSheetPool->SetParent(eFam,pBox->GetStyle(), pBox->GetParent())? 1L: 0L;
    1945                 :          0 :     bDontUpdate=sal_False;
    1946                 :          0 :     return ret;
    1947                 :            : }
    1948                 :            : 
    1949                 :            : //-------------------------------------------------------------------------
    1950                 :            : 
    1951                 :            : // Handler for the New-Buttons
    1952                 :          0 : void SfxCommonTemplateDialog_Impl::NewHdl(void *)
    1953                 :            : {
    1954         [ #  # ]:          0 :     String aEmpty;
    1955         [ #  # ]:          0 :     if ( nActFamily != 0xffff )
    1956                 :            :     {
    1957                 :            :         Window* pTmp;
    1958         [ #  # ]:          0 :         pTmp = Application::GetDefDialogParent();
    1959 [ #  # ][ #  # ]:          0 :         if ( ISA(SfxTemplateDialog_Impl) )
    1960 [ #  # ][ #  # ]:          0 :             Application::SetDefDialogParent( pWindow->GetParent() );
    1961                 :            :         else
    1962         [ #  # ]:          0 :             Application::SetDefDialogParent( pWindow );
    1963                 :            : 
    1964         [ #  # ]:          0 :         const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
    1965                 :          0 :         const SfxStyleFamily eFam=pItem->GetFamily();
    1966                 :            :         sal_uInt16 nMask;
    1967 [ #  # ][ #  # ]:          0 :         if( pItem && nActFilter != 0xffff )
    1968                 :            :         {
    1969                 :          0 :             nMask = pItem->GetFilterList()[ nActFilter ]->nFlags;
    1970         [ #  # ]:          0 :             if(!nMask)    // automatic
    1971                 :          0 :                 nMask = nAppFilter;
    1972                 :            :         }
    1973                 :            :         else
    1974         [ #  # ]:          0 :             nMask=pStyleSheetPool->GetSearchMask();
    1975                 :            : 
    1976         [ #  # ]:          0 :         pStyleSheetPool->SetSearchMask(eFam,nMask);
    1977                 :            : 
    1978                 :            :         Execute_Impl(SID_STYLE_NEW,
    1979                 :            :                      aEmpty, GetSelectedEntry(),
    1980         [ #  # ]:          0 :                      ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily(),
    1981 [ #  # ][ #  # ]:          0 :                      nMask);
                 [ #  # ]
    1982                 :            : 
    1983         [ #  # ]:          0 :         Application::SetDefDialogParent( pTmp );
    1984         [ #  # ]:          0 :     }
    1985                 :          0 : }
    1986                 :            : 
    1987                 :            : //-------------------------------------------------------------------------
    1988                 :            : 
    1989                 :            : // Handler for the edit-Buttons
    1990                 :          0 : void SfxCommonTemplateDialog_Impl::EditHdl(void *)
    1991                 :            : {
    1992 [ #  # ][ #  # ]:          0 :     if(IsInitialized() && HasSelectedStyle())
                 [ #  # ]
    1993                 :            :     {
    1994                 :          0 :         sal_uInt16 nFilter = nActFilter;
    1995         [ #  # ]:          0 :         String aTemplName(GetSelectedEntry());
    1996         [ #  # ]:          0 :         GetSelectedStyle(); // -Wall required??
    1997                 :            :         Window* pTmp;
    1998                 :            :         //DefModalDialogParent set for modality of the following dialogs
    1999         [ #  # ]:          0 :         pTmp = Application::GetDefDialogParent();
    2000 [ #  # ][ #  # ]:          0 :         if ( ISA(SfxTemplateDialog_Impl) )
    2001 [ #  # ][ #  # ]:          0 :             Application::SetDefDialogParent( pWindow->GetParent() );
    2002                 :            :         else
    2003         [ #  # ]:          0 :             Application::SetDefDialogParent( pWindow );
    2004                 :          0 :         if ( Execute_Impl( SID_STYLE_EDIT, aTemplName, String(),
    2005 [ #  # ][ #  # ]:          0 :                           (sal_uInt16)GetFamilyItem_Impl()->GetFamily(), 0, &nFilter ) )
         [ #  # ][ #  # ]
    2006                 :            :         {
    2007                 :            :         }
    2008 [ #  # ][ #  # ]:          0 :         Application::SetDefDialogParent( pTmp );
    2009                 :            :     }
    2010                 :          0 : }
    2011                 :            : 
    2012                 :            : //-------------------------------------------------------------------------
    2013                 :            : 
    2014                 :            : // Handler for the Delete-Buttons
    2015                 :          0 : void SfxCommonTemplateDialog_Impl::DeleteHdl(void *)
    2016                 :            : {
    2017 [ #  # ][ #  # ]:          0 :     if ( IsInitialized() && HasSelectedStyle() )
                 [ #  # ]
    2018                 :            :     {
    2019         [ #  # ]:          0 :         const String aTemplName( GetSelectedEntry() );
    2020         [ #  # ]:          0 :         SfxStyleSheetBase* pStyle = GetSelectedStyle();
    2021         [ #  # ]:          0 :         if ( pStyle )
    2022                 :            :         {
    2023         [ #  # ]:          0 :             String aMsg;
    2024 [ #  # ][ #  # ]:          0 :             if ( pStyle->IsUsed() )
    2025 [ #  # ][ #  # ]:          0 :                 aMsg = SfxResId(STR_DELETE_STYLE_USED).toString();
                 [ #  # ]
    2026 [ #  # ][ #  # ]:          0 :             aMsg += SfxResId(STR_DELETE_STYLE).toString();
                 [ #  # ]
    2027         [ #  # ]:          0 :             aMsg.SearchAndReplaceAscii( "$1", aTemplName );
    2028                 :            : #if defined UNX
    2029 [ #  # ][ #  # ]:          0 :             QueryBox aBox( SFX_APP()->GetTopWindow(), WB_YES_NO | WB_DEF_NO, aMsg );
                 [ #  # ]
    2030                 :            : #else
    2031                 :            :             QueryBox aBox( GetWindow(), WB_YES_NO | WB_DEF_NO , aMsg );
    2032                 :            : #endif
    2033 [ #  # ][ #  # ]:          0 :             if ( RET_YES == aBox.Execute() )
    2034                 :            :             {
    2035         [ #  # ]:          0 :                 PrepareDeleteAction();
    2036                 :            : 
    2037         [ #  # ]:          0 :                 if ( pTreeBox ) // To prevent the Treelistbox to shut down while
    2038                 :            :                                 // deleting.
    2039                 :            :                 {
    2040                 :          0 :                     bDontUpdate = sal_True;
    2041                 :            :                 }
    2042                 :            :                 Execute_Impl( SID_STYLE_DELETE, aTemplName,
    2043 [ #  # ][ #  # ]:          0 :                               String(), (sal_uInt16)GetFamilyItem_Impl()->GetFamily() );
         [ #  # ][ #  # ]
    2044                 :            : 
    2045         [ #  # ]:          0 :                 if ( pTreeBox )
    2046                 :            :                 {
    2047 [ #  # ][ #  # ]:          0 :                     pTreeBox->RemoveParentKeepChildren( pTreeBox->FirstSelected() );
    2048                 :          0 :                     bDontUpdate = sal_False;
    2049                 :            :                 }
    2050 [ #  # ][ #  # ]:          0 :             }
    2051         [ #  # ]:          0 :         }
    2052                 :            :     }
    2053                 :          0 : }
    2054                 :            : 
    2055                 :            : //-------------------------------------------------------------------------
    2056                 :            : 
    2057                 :       1113 : void    SfxCommonTemplateDialog_Impl::EnableDelete()
    2058                 :            : {
    2059 [ +  - ][ +  + ]:       1113 :     if(IsInitialized() && HasSelectedStyle())
                 [ +  + ]
    2060                 :            :     {
    2061                 :            :         OSL_ENSURE(pStyleSheetPool, "No StyleSheetPool");
    2062         [ +  - ]:       1098 :         const String aTemplName(GetSelectedEntry());
    2063         [ +  - ]:       1098 :         const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
    2064                 :       1098 :         const SfxStyleFamily eFam = pItem->GetFamily();
    2065                 :       1098 :         sal_uInt16 nFilter = 0;
    2066         [ +  - ]:       1098 :         if(pItem->GetFilterList().size() > nActFilter)
    2067                 :       1098 :             nFilter = pItem->GetFilterList()[ nActFilter ]->nFlags;
    2068         [ +  - ]:       1098 :         if(!nFilter)    // automatic
    2069                 :       1098 :             nFilter = nAppFilter;
    2070                 :            :         const SfxStyleSheetBase *pStyle =
    2071 [ +  - ][ +  - ]:       1098 :             pStyleSheetPool->Find(aTemplName,eFam, pTreeBox? SFXSTYLEBIT_ALL: nFilter);
    2072                 :            : 
    2073                 :            :         OSL_ENSURE(pStyle, "Style ot found");
    2074 [ +  - ][ -  + ]:       1098 :         if(pStyle && pStyle->IsUserDefined())
                 [ -  + ]
    2075                 :            :         {
    2076         [ #  # ]:          0 :             EnableDel(sal_True);
    2077                 :            :         }
    2078                 :            :         else
    2079                 :            :         {
    2080         [ +  - ]:       1098 :             EnableDel(sal_False);
    2081         [ +  - ]:       1098 :         }
    2082                 :            :     }
    2083                 :            :     else
    2084                 :            :     {
    2085                 :         15 :         EnableDel(sal_False);
    2086                 :            :     }
    2087                 :       1113 : }
    2088                 :            : 
    2089                 :            : //-------------------------------------------------------------------------
    2090                 :            : // After selecting a focused item if possible again on the app window
    2091                 :          0 : void    SfxCommonTemplateDialog_Impl::ResetFocus()
    2092                 :            : {
    2093         [ #  # ]:          0 :     if(ISA(SfxTemplateDialog_Impl))
    2094                 :            :     {
    2095                 :          0 :         SfxViewFrame *pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
    2096                 :          0 :         SfxViewShell *pVu = pViewFrame->GetViewShell();
    2097         [ #  # ]:          0 :         Window *pAppWin = pVu ? pVu->GetWindow(): 0;
    2098         [ #  # ]:          0 :         if(pAppWin)
    2099                 :          0 :             pAppWin->GrabFocus();
    2100                 :            :     }
    2101                 :          0 : }
    2102                 :            : 
    2103                 :            : //-------------------------------------------------------------------------
    2104                 :            : 
    2105                 :            : // Doppelclick on a style sheet in the ListBox is applied.
    2106                 :          0 : IMPL_LINK( SfxCommonTemplateDialog_Impl, ApplyHdl, Control *, pControl )
    2107                 :            : {
    2108                 :            :     (void)pControl; //unused
    2109                 :            :     // only if that region is allowed
    2110         [ #  # ]:          0 :     if ( IsInitialized() && 0 != pFamilyState[nActFamily-1] &&
           [ #  #  #  # ]
                 [ #  # ]
    2111 [ #  # ][ #  # ]:          0 :          GetSelectedEntry().Len() )
                 [ #  # ]
    2112                 :            :     {
    2113                 :          0 :         sal_uInt16 nModifier = aFmtLb.GetModifier();
    2114                 :            :         Execute_Impl(SID_STYLE_APPLY,
    2115                 :            :                      GetSelectedEntry(), String(),
    2116         [ #  # ]:          0 :                      ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily(),
    2117 [ #  # ][ #  # ]:          0 :                      0, 0, &nModifier );
         [ #  # ][ #  # ]
                 [ #  # ]
    2118 [ #  # ][ #  # ]:          0 :         if(ISA(SfxTemplateCatalog_Impl))
    2119         [ #  # ]:          0 :             ((SfxTemplateCatalog_Impl*) this)->pReal->EndDialog(RET_OK);
    2120                 :            :     }
    2121                 :          0 :     ResetFocus();
    2122                 :          0 :     return 0;
    2123                 :            : }
    2124                 :            : 
    2125                 :            : //-------------------------------------------------------------------------
    2126                 :            : 
    2127                 :            : // Selection of a template during the Watercan-Status
    2128                 :          0 : IMPL_LINK( SfxCommonTemplateDialog_Impl, FmtSelectHdl, SvTreeListBox *, pListBox )
    2129                 :            : {
    2130                 :            :     // Trigger Help PI, if this is permitted of call handlers and field
    2131 [ -  + ][ #  # ]:        549 :     if( !pListBox || pListBox->IsSelected( pListBox->GetHdlEntry() ) )
                 [ +  - ]
    2132                 :            :     {
    2133                 :            :         // Only when the watercan is on
    2134   [ +  -  -  + ]:       1098 :         if ( IsInitialized() &&
         [ #  # ][ -  + ]
    2135                 :        549 :              IsCheckedItem(SID_STYLE_WATERCAN) &&
    2136                 :            :              // only if that region is allowed
    2137                 :          0 :              0 != pFamilyState[nActFamily-1] )
    2138                 :            :         {
    2139         [ #  # ]:          0 :             String aEmpty;
    2140                 :            :             Execute_Impl(SID_STYLE_WATERCAN,
    2141         [ #  # ]:          0 :                          aEmpty, aEmpty, 0);
    2142                 :            :             Execute_Impl(SID_STYLE_WATERCAN,
    2143                 :            :                          GetSelectedEntry(), aEmpty,
    2144 [ #  # ][ #  # ]:          0 :                          ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily());
         [ #  # ][ #  # ]
                 [ #  # ]
    2145                 :            :         }
    2146                 :        549 :         EnableItem(SID_STYLE_WATERCAN, !bWaterDisabled);
    2147                 :        549 :         EnableDelete();
    2148                 :            :     }
    2149         [ -  + ]:        549 :     if( pListBox )
    2150         [ #  # ]:          0 :         SelectStyle( pListBox->GetEntryText( pListBox->GetHdlEntry() ));
    2151                 :            : 
    2152                 :        549 :     return 0;
    2153                 :            : }
    2154                 :            : 
    2155                 :            : //-------------------------------------------------------------------------
    2156                 :            : 
    2157                 :          0 : IMPL_LINK( SfxCommonTemplateDialog_Impl, MenuSelectHdl, Menu *, pMenu )
    2158                 :            : {
    2159         [ #  # ]:          0 :     if( pMenu )
    2160                 :            :     {
    2161                 :          0 :         nLastItemId = pMenu->GetCurItemId();
    2162                 :            :         Application::PostUserEvent(
    2163         [ #  # ]:          0 :             LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ), 0 );
    2164                 :          0 :         return sal_True;
    2165                 :            :     }
    2166                 :            : 
    2167   [ #  #  #  # ]:          0 :     switch(nLastItemId) {
    2168                 :          0 :     case ID_NEW: NewHdl(0); break;
    2169                 :          0 :     case ID_EDIT: EditHdl(0); break;
    2170                 :          0 :     case ID_DELETE: DeleteHdl(0); break;
    2171                 :          0 :     default: return sal_False;
    2172                 :            :     }
    2173                 :          0 :     return sal_True;
    2174                 :            : }
    2175                 :            : 
    2176                 :            : // -----------------------------------------------------------------------
    2177                 :            : 
    2178                 :          0 : void SfxCommonTemplateDialog_Impl::ExecuteContextMenu_Impl( const Point& rPos, Window* pWin )
    2179                 :            : {
    2180                 :            :     // Bug# 94152: This part should never be called, because before this happens, the TreeListBox should captured this!
    2181                 :            :     OSL_FAIL( "+SfxCommonTemplateDialog_Impl::ExecuteContextMenu_Impl(): How could this happen? Please infirm developer ASAP!" );
    2182                 :            : 
    2183                 :          0 :     PopupMenu* pMenu = CreateContextMenu();
    2184                 :          0 :     pMenu->Execute( pWin, rPos );
    2185         [ #  # ]:          0 :     delete pMenu;
    2186                 :          0 : }
    2187                 :            : 
    2188                 :            : // -----------------------------------------------------------------------
    2189                 :            : 
    2190                 :       1232 : SfxStyleFamily SfxCommonTemplateDialog_Impl::GetActualFamily() const
    2191                 :            : {
    2192                 :       1232 :     const SfxStyleFamilyItem *pFamilyItem = GetFamilyItem_Impl();
    2193 [ -  + ][ +  - ]:       1232 :     if( !pFamilyItem || nActFamily == 0xffff )
    2194                 :          0 :         return SFX_STYLE_FAMILY_PARA;
    2195                 :            :     else
    2196                 :       1232 :         return pFamilyItem->GetFamily();
    2197                 :            : }
    2198                 :            : 
    2199                 :            : // -----------------------------------------------------------------------
    2200                 :            : 
    2201                 :        654 : void SfxCommonTemplateDialog_Impl::EnableExample_Impl(sal_uInt16 nId, sal_Bool bEnable)
    2202                 :            : {
    2203         [ +  + ]:        654 :     if( nId == SID_STYLE_NEW_BY_EXAMPLE )
    2204                 :        327 :         bNewByExampleDisabled = !bEnable;
    2205         [ +  - ]:        327 :     else if( nId == SID_STYLE_UPDATE_BY_EXAMPLE )
    2206                 :        327 :         bUpdateByExampleDisabled = !bEnable;
    2207                 :        654 :     EnableItem(nId, bEnable);
    2208                 :        654 : }
    2209                 :            : 
    2210                 :          0 : void SfxCommonTemplateDialog_Impl::PrepareDeleteAction()
    2211                 :            : {
    2212                 :          0 : }
    2213                 :            : 
    2214                 :            : // -----------------------------------------------------------------------
    2215                 :            : 
    2216                 :          0 : PopupMenu* SfxCommonTemplateDialog_Impl::CreateContextMenu( void )
    2217                 :            : {
    2218         [ #  # ]:          0 :     if ( bBindingUpdate )
    2219                 :            :     {
    2220                 :          0 :         pBindings->Invalidate( SID_STYLE_NEW, sal_True, sal_False );
    2221                 :          0 :         pBindings->Update( SID_STYLE_NEW );
    2222                 :          0 :         bBindingUpdate = sal_False;
    2223                 :            :     }
    2224 [ #  # ][ #  # ]:          0 :     PopupMenu* pMenu = new PopupMenu( SfxResId( MN_CONTEXT_TEMPLDLG ) );
    2225                 :          0 :     pMenu->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ) );
    2226                 :          0 :     pMenu->EnableItem( ID_EDIT, bCanEdit );
    2227                 :          0 :     pMenu->EnableItem( ID_DELETE, bCanDel );
    2228                 :          0 :     pMenu->EnableItem( ID_NEW, bCanNew );
    2229                 :            : 
    2230                 :          0 :     return pMenu;
    2231                 :            : }
    2232                 :            : 
    2233                 :            : // ------------------------------------------------------------------------
    2234                 :            : 
    2235                 :        120 : SfxTemplateDialog_Impl::SfxTemplateDialog_Impl(
    2236                 :            :     Window* /*pParent*/, SfxBindings* pB, SfxTemplateDialog* pDlgWindow ) :
    2237                 :            : 
    2238                 :            :     SfxCommonTemplateDialog_Impl( pB, pDlgWindow ),
    2239                 :            : 
    2240                 :            :     m_pFloat            ( pDlgWindow ),
    2241                 :            :     m_bZoomIn           ( sal_False ),
    2242                 :            :     m_aActionTbL        ( pDlgWindow, this ),
    2243 [ +  - ][ +  - ]:        120 :     m_aActionTbR        ( pDlgWindow, SfxResId( TB_ACTION ) )
                 [ +  - ]
    2244                 :            : 
    2245                 :            : {
    2246         [ +  - ]:        120 :     pDlgWindow->FreeResource();
    2247         [ +  - ]:        120 :     Initialize();
    2248                 :            : 
    2249         [ +  - ]:        120 :     m_aActionTbL.SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxLSelect));
    2250         [ +  - ]:        120 :     m_aActionTbR.SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxRSelect));
    2251 [ +  - ][ +  - ]:        120 :     m_aActionTbR.SetDropdownClickHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxRClick));
    2252         [ +  - ]:        120 :     m_aActionTbL.Show();
    2253         [ +  - ]:        120 :     m_aActionTbR.Show();
    2254         [ +  - ]:        120 :     Font aFont=aFilterLb.GetFont();
    2255         [ +  - ]:        120 :     aFont.SetWeight( WEIGHT_NORMAL );
    2256         [ +  - ]:        120 :     aFilterLb.SetFont( aFont );
    2257 [ +  - ][ +  - ]:        120 :     m_aActionTbL.SetHelpId( HID_TEMPLDLG_TOOLBOX_LEFT );
    2258                 :        120 : }
    2259                 :            : 
    2260                 :            : // ------------------------------------------------------------------------
    2261                 :            : 
    2262                 :        594 : void SfxTemplateDialog_Impl::EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnable )
    2263                 :            : {
    2264                 :        594 :     m_aActionTbL.EnableItem( nId, bEnable );
    2265                 :        594 : }
    2266                 :            : 
    2267                 :            : //-------------------------------------------------------------------------
    2268                 :            : // Insert element into dropdown filter "Frame Styles", "List Styles", etc.
    2269                 :            : 
    2270                 :        594 : void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId,const SfxStyleFamilyItem *pItem)
    2271                 :            : {
    2272                 :        594 :     rtl::OString sHelpId;
    2273   [ +  +  +  +  :        594 :     switch( (sal_uInt16) pItem->GetFamily() )
                   +  - ]
    2274                 :            :     {
    2275                 :        118 :         case SFX_STYLE_FAMILY_CHAR:     sHelpId = ".uno:CharStyle"; break;
    2276                 :        120 :         case SFX_STYLE_FAMILY_PARA:     sHelpId = ".uno:ParaStyle"; break;
    2277                 :        118 :         case SFX_STYLE_FAMILY_FRAME:    sHelpId = ".uno:FrameStyle"; break;
    2278                 :        118 :         case SFX_STYLE_FAMILY_PAGE:     sHelpId = ".uno:PageStyle"; break;
    2279                 :        120 :         case SFX_STYLE_FAMILY_PSEUDO:   sHelpId = ".uno:ListStyle"; break;
    2280                 :          0 :         default: OSL_FAIL("unknown StyleFamily"); break;
    2281                 :            :     }
    2282         [ +  - ]:        594 :     m_aActionTbL.InsertItem( nId, pItem->GetImage(), pItem->GetText(), 0, 0);
    2283         [ +  - ]:        594 :     m_aActionTbL.SetHelpId( nId, sHelpId );
    2284                 :        594 : }
    2285                 :            : 
    2286                 :            : // ------------------------------------------------------------------------
    2287                 :            : 
    2288                 :        118 : void SfxTemplateDialog_Impl::ReplaceUpdateButtonByMenu()
    2289                 :            : {
    2290                 :        118 :     m_aActionTbR.HideItem(SID_STYLE_UPDATE_BY_EXAMPLE);
    2291                 :            :     m_aActionTbR.SetItemBits( SID_STYLE_NEW_BY_EXAMPLE,
    2292                 :        118 :             TIB_DROPDOWNONLY|m_aActionTbR.GetItemBits( SID_STYLE_NEW_BY_EXAMPLE ));
    2293                 :        118 : }
    2294                 :            : 
    2295                 :            : // ------------------------------------------------------------------------
    2296                 :        120 : void SfxTemplateDialog_Impl::updateFamilyImages()
    2297                 :            : {
    2298         [ -  + ]:        120 :     if ( !m_pStyleFamiliesId )
    2299                 :            :         // we do not have a resource id to load the new images from
    2300                 :        120 :         return;
    2301                 :            : 
    2302                 :            :     // let the families collection update the images
    2303                 :        120 :     pStyleFamilies->updateImages( *m_pStyleFamiliesId );
    2304                 :            : 
    2305                 :            :     // and set the new images on our toolbox
    2306                 :        120 :     size_t nLoop = pStyleFamilies->size();
    2307         [ +  + ]:        714 :     for( ; nLoop--; )
    2308                 :            :     {
    2309                 :        594 :         const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nLoop );
    2310                 :        594 :         sal_uInt16 nId = SfxFamilyIdToNId( pItem->GetFamily() );
    2311                 :        594 :         m_aActionTbL.SetItemImage( nId, pItem->GetImage() );
    2312                 :            :     }
    2313                 :            : }
    2314                 :            : 
    2315                 :            : // ------------------------------------------------------------------------
    2316                 :        120 : void SfxTemplateDialog_Impl::updateNonFamilyImages()
    2317                 :            : {
    2318 [ +  - ][ +  - ]:        120 :     m_aActionTbR.SetImageList( ImageList( SfxResId( DLG_STYLE_DESIGNER ) ) );
                 [ +  - ]
    2319                 :        120 : }
    2320                 :            : 
    2321                 :            : // ------------------------------------------------------------------------
    2322                 :            : 
    2323                 :          0 : void SfxTemplateDialog_Impl::ClearFamilyList()
    2324                 :            : {
    2325                 :          0 :     m_aActionTbL.Clear();
    2326                 :          0 : }
    2327                 :            : 
    2328                 :            : //-------------------------------------------------------------------------
    2329                 :            : 
    2330                 :        242 : void SfxCommonTemplateDialog_Impl::InvalidateBindings()
    2331                 :            : {
    2332                 :        242 :     pBindings->Invalidate(SID_STYLE_NEW_BY_EXAMPLE, sal_True, sal_False);
    2333                 :        242 :     pBindings->Update( SID_STYLE_NEW_BY_EXAMPLE );
    2334                 :        242 :     pBindings->Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE, sal_True, sal_False);
    2335                 :        242 :     pBindings->Update( SID_STYLE_UPDATE_BY_EXAMPLE );
    2336                 :        242 :     pBindings->Invalidate( SID_STYLE_WATERCAN, sal_True, sal_False);
    2337                 :        242 :     pBindings->Update( SID_STYLE_WATERCAN );
    2338                 :        242 :     pBindings->Invalidate( SID_STYLE_NEW, sal_True, sal_False );
    2339                 :        242 :     pBindings->Update( SID_STYLE_NEW );
    2340                 :        242 :     pBindings->Invalidate( SID_STYLE_DRAGHIERARCHIE, sal_True, sal_False );
    2341                 :        242 :     pBindings->Update( SID_STYLE_DRAGHIERARCHIE );
    2342                 :        242 : }
    2343                 :            : 
    2344                 :            : //-------------------------------------------------------------------------
    2345                 :            : 
    2346 [ +  - ][ +  - ]:        120 : SfxTemplateDialog_Impl::~SfxTemplateDialog_Impl()
    2347                 :            : {
    2348         [ -  + ]:        240 : }
    2349                 :            : 
    2350                 :            : //-------------------------------------------------------------------------
    2351                 :            : 
    2352                 :        120 : void SfxTemplateDialog_Impl::LoadedFamilies()
    2353                 :            : {
    2354                 :        120 :     updateFamilyImages();
    2355                 :        120 :     Resize();
    2356                 :        120 : }
    2357                 :            : 
    2358                 :            : //-------------------------------------------------------------------------
    2359                 :            : 
    2360                 :            : // Overloaded Resize-Handler ( StarView )
    2361                 :            : // The size of the Listboxen is adjusted
    2362                 :        241 : void SfxTemplateDialog_Impl::Resize()
    2363                 :            : {
    2364                 :        241 :     FloatingWindow *pF = m_pFloat->GetFloatingWindow();
    2365         [ -  + ]:        241 :     if ( pF )
    2366                 :            :     {
    2367                 :          0 :         m_bZoomIn = pF->IsRollUp();
    2368         [ #  # ]:          0 :         if ( m_bZoomIn )
    2369                 :        241 :             return;
    2370                 :            :     }
    2371                 :            : 
    2372 [ +  - ][ +  - ]:        241 :     Size aDlgSize=m_pFloat->PixelToLogic(m_pFloat->GetOutputSizePixel());
    2373 [ +  - ][ +  - ]:        241 :     Size aSizeATL=m_pFloat->PixelToLogic(m_aActionTbL.CalcWindowSizePixel());
    2374 [ +  - ][ +  - ]:        241 :     Size aSizeATR=m_pFloat->PixelToLogic(m_aActionTbR.CalcWindowSizePixel());
    2375         [ +  - ]:        241 :     Size aMinSize = GetMinOutputSizePixel();
    2376                 :            : 
    2377 [ +  - ][ +  - ]:        241 :     long nListHeight = m_pFloat->PixelToLogic( aFilterLb.GetSizePixel() ).Height();
    2378                 :        241 :     long nWidth = aDlgSize.Width()- 2 * SFX_TEMPLDLG_HFRAME;
    2379                 :            : 
    2380                 :        241 :     m_aActionTbL.SetPosSizePixel(m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME,SFX_TEMPLDLG_VTOPFRAME)),
    2381         [ +  - ]:        482 :                                  m_pFloat->LogicToPixel(aSizeATL));
           [ +  -  +  - ]
    2382                 :            : 
    2383                 :            :     // only change the position of the right toolbox, when the window is wide
    2384                 :            :     // enough
    2385                 :        241 :     Point aPosATR(aDlgSize.Width()-SFX_TEMPLDLG_HFRAME-aSizeATR.Width(),SFX_TEMPLDLG_VTOPFRAME);
    2386         [ +  - ]:        241 :     if(aDlgSize.Width() >= aMinSize.Width())
    2387 [ +  - ][ +  - ]:        241 :         m_aActionTbR.SetPosPixel(m_pFloat->LogicToPixel(aPosATR));
    2388                 :            :     else
    2389                 :            :         m_aActionTbR.SetPosPixel( m_pFloat->LogicToPixel(
    2390                 :          0 :             Point( SFX_TEMPLDLG_HFRAME + aSizeATL.Width() + SFX_TEMPLDLG_MIDHSPACE,
    2391 [ #  # ][ #  # ]:          0 :                    SFX_TEMPLDLG_VTOPFRAME ) ) );
    2392                 :            : 
    2393 [ +  - ][ +  - ]:        241 :     m_aActionTbR.SetSizePixel(m_pFloat->LogicToPixel(aSizeATR));
    2394                 :            : 
    2395                 :            :     Point aFilterPos(
    2396                 :            :         m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME,
    2397         [ +  - ]:        241 :             aDlgSize.Height()-SFX_TEMPLDLG_VBOTFRAME-nListHeight)) );
    2398                 :            : 
    2399                 :            :     Size aFilterSize(
    2400         [ +  - ]:        241 :         m_pFloat->LogicToPixel(Size(nWidth,SFX_TEMPLDLG_FILTERHEIGHT)) );
    2401                 :            : 
    2402                 :            :     Point aFmtPos(
    2403                 :            :         m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME, SFX_TEMPLDLG_VTOPFRAME +
    2404         [ +  - ]:        241 :                             SFX_TEMPLDLG_MIDVSPACE+aSizeATL.Height())) );
    2405                 :            :     Size aFmtSize(
    2406                 :            :         m_pFloat->LogicToPixel(Size(nWidth,
    2407                 :        241 :                     aDlgSize.Height() - SFX_TEMPLDLG_VBOTFRAME -
    2408                 :            :                     SFX_TEMPLDLG_VTOPFRAME - 2*SFX_TEMPLDLG_MIDVSPACE-
    2409         [ +  - ]:        241 :                     nListHeight-aSizeATL.Height())) );
    2410                 :            : 
    2411                 :            :     // only change the position of the listbox, when the window is high enough
    2412         [ +  - ]:        241 :     if(aDlgSize.Height() >= aMinSize.Height())
    2413                 :            :     {
    2414         [ +  - ]:        241 :         aFilterLb.SetPosPixel(aFilterPos);
    2415         [ +  - ]:        241 :         aFmtLb.SetPosPixel( aFmtPos );
    2416         [ -  + ]:        241 :         if(pTreeBox)
    2417         [ #  # ]:          0 :             pTreeBox->SetPosPixel(aFmtPos);
    2418                 :            :     }
    2419                 :            :     else
    2420                 :          0 :         aFmtSize.Height() += aFilterSize.Height();
    2421                 :            : 
    2422         [ +  - ]:        241 :     aFilterLb.SetSizePixel(aFilterSize);
    2423         [ +  - ]:        241 :     aFmtLb.SetSizePixel( aFmtSize );
    2424         [ -  + ]:        241 :     if(pTreeBox)
    2425         [ #  # ]:        241 :         pTreeBox->SetSizePixel(aFmtSize);
    2426                 :            : }
    2427                 :            : 
    2428                 :            : // -----------------------------------------------------------------------
    2429                 :            : 
    2430                 :            : 
    2431                 :        361 : Size SfxTemplateDialog_Impl::GetMinOutputSizePixel()
    2432                 :            : {
    2433 [ +  - ][ +  - ]:        361 :     Size aSizeATL=m_pFloat->PixelToLogic(m_aActionTbL.CalcWindowSizePixel());
    2434 [ +  - ][ +  - ]:        361 :     Size aSizeATR=m_pFloat->PixelToLogic(m_aActionTbR.CalcWindowSizePixel());
    2435                 :            :     Size aMinSize=Size(
    2436                 :        361 :         aSizeATL.Width()+aSizeATR.Width()+
    2437                 :            :         2*SFX_TEMPLDLG_HFRAME + SFX_TEMPLDLG_MIDHSPACE,
    2438                 :        722 :         4*aSizeATL.Height()+2*SFX_TEMPLDLG_MIDVSPACE);
    2439                 :        361 :     return aMinSize;
    2440                 :            : }
    2441                 :            : 
    2442                 :            : //-------------------------------------------------------------------------
    2443                 :            : 
    2444                 :          0 : void SfxTemplateDialog_Impl::Command( const CommandEvent& rCEvt )
    2445                 :            : {
    2446         [ #  # ]:          0 :     if(COMMAND_CONTEXTMENU  == rCEvt.GetCommand())
    2447                 :          0 :         ExecuteContextMenu_Impl( rCEvt.GetMousePosPixel(), m_pFloat );
    2448                 :            :     else
    2449                 :          0 :         m_pFloat->Command(rCEvt);
    2450                 :          0 : }
    2451                 :            : 
    2452                 :            : //-------------------------------------------------------------------------
    2453                 :            : 
    2454                 :       2093 : void SfxTemplateDialog_Impl::EnableItem(sal_uInt16 nMesId, sal_Bool bCheck)
    2455                 :            : {
    2456         [ +  - ]:       2093 :     String aEmpty;
    2457      [ +  +  - ]:       2093 :     switch(nMesId)
    2458                 :            :     {
    2459                 :            :       case SID_STYLE_WATERCAN :
    2460 [ +  + ][ +  - ]:       1118 :           if(!bCheck && IsCheckedItem(SID_STYLE_WATERCAN))
         [ -  + ][ -  + ]
    2461         [ #  # ]:          0 :             Execute_Impl(SID_STYLE_WATERCAN, aEmpty, aEmpty, 0);
    2462                 :            :       case SID_STYLE_NEW_BY_EXAMPLE:
    2463                 :            :       case SID_STYLE_UPDATE_BY_EXAMPLE:
    2464         [ +  - ]:       2093 :         m_aActionTbR.EnableItem(nMesId,bCheck);
    2465                 :       2093 :         break;
    2466         [ +  - ]:       2093 :     }
    2467                 :       2093 : }
    2468                 :            : 
    2469                 :            : //-------------------------------------------------------------------------
    2470                 :            : 
    2471                 :        645 : void SfxTemplateDialog_Impl::CheckItem(sal_uInt16 nMesId, sal_Bool bCheck)
    2472                 :            : {
    2473         [ +  + ]:        645 :     switch(nMesId)
    2474                 :            :     {
    2475                 :            :         case SID_STYLE_WATERCAN :
    2476                 :         83 :             bIsWater=bCheck;
    2477                 :         83 :             m_aActionTbR.CheckItem(SID_STYLE_WATERCAN,bCheck);
    2478                 :         83 :             break;
    2479                 :            :         default:
    2480                 :        562 :             m_aActionTbL.CheckItem(nMesId,bCheck); break;
    2481                 :            :     }
    2482                 :        645 : }
    2483                 :            : 
    2484                 :            : //-------------------------------------------------------------------------
    2485                 :            : 
    2486                 :       1357 : sal_Bool SfxTemplateDialog_Impl::IsCheckedItem(sal_uInt16 nMesId)
    2487                 :            : {
    2488         [ +  - ]:       1357 :     switch(nMesId)
    2489                 :            :     {
    2490                 :            :         case SID_STYLE_WATERCAN :
    2491                 :       1357 :             return m_aActionTbR.GetItemState(SID_STYLE_WATERCAN)==STATE_CHECK;
    2492                 :            :         default:
    2493                 :       1357 :             return m_aActionTbL.GetItemState(nMesId)==STATE_CHECK;
    2494                 :            :     }
    2495                 :            : }
    2496                 :            : 
    2497                 :            : //-------------------------------------------------------------------------
    2498                 :            : 
    2499                 :          0 : IMPL_LINK_INLINE_START( SfxTemplateDialog_Impl, ToolBoxLSelect, ToolBox *, pBox )
    2500                 :            : {
    2501                 :          0 :     const sal_uInt16 nEntry = pBox->GetCurItemId();
    2502                 :          0 :     FamilySelect(nEntry);
    2503                 :          0 :     return 0;
    2504                 :            : }
    2505                 :          0 : IMPL_LINK_INLINE_END( SfxTemplateDialog_Impl, ToolBoxLSelect, ToolBox *, pBox )
    2506                 :            : 
    2507                 :            : //-------------------------------------------------------------------------
    2508                 :          0 : ::rtl::OUString lcl_GetLabel(uno::Any& rAny)
    2509                 :            : {
    2510                 :          0 :     ::rtl::OUString sRet;
    2511         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue >aPropSeq;
    2512 [ #  # ][ #  # ]:          0 :     if ( rAny >>= aPropSeq )
    2513                 :            :     {
    2514         [ #  # ]:          0 :         for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
    2515                 :            :         {
    2516 [ #  # ][ #  # ]:          0 :             if ( aPropSeq[i].Name == "Label" )
    2517                 :            :             {
    2518         [ #  # ]:          0 :                 aPropSeq[i].Value >>= sRet;
    2519                 :          0 :                 break;
    2520                 :            :             }
    2521                 :            :         }
    2522                 :            :     }
    2523         [ #  # ]:          0 :     return sRet;
    2524                 :            : }
    2525                 :            : //-------------------------------------------------------------------------
    2526                 :            : 
    2527                 :          0 : IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRSelect, ToolBox *, pBox )
    2528                 :            : {
    2529                 :          0 :     const sal_uInt16 nEntry = pBox->GetCurItemId();
    2530         [ #  # ]:          0 :     if(nEntry != SID_STYLE_NEW_BY_EXAMPLE ||
           [ #  #  #  # ]
    2531                 :          0 :             TIB_DROPDOWN != (pBox->GetItemBits(nEntry)&TIB_DROPDOWN))
    2532                 :          0 :         ActionSelect(nEntry);
    2533                 :          0 :     return 0;
    2534                 :            : }
    2535                 :            : //-------------------------------------------------------------------------
    2536                 :          0 : IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRClick, ToolBox *, pBox )
    2537                 :            : {
    2538                 :          0 :     const sal_uInt16 nEntry = pBox->GetCurItemId();
    2539         [ #  # ]:          0 :     if(nEntry == SID_STYLE_NEW_BY_EXAMPLE &&
           [ #  #  #  # ]
    2540                 :          0 :             TIB_DROPDOWN == (pBox->GetItemBits(nEntry)&TIB_DROPDOWN))
    2541                 :            :     {
    2542                 :            :         //create a popup menu in Writer
    2543 [ #  # ][ #  # ]:          0 :         boost::scoped_ptr<PopupMenu> pMenu(new PopupMenu);
    2544                 :            :         uno::Reference< container::XNameAccess > xNameAccess(
    2545 [ #  # ][ #  # ]:          0 :                     ::comphelper::getProcessServiceFactory()->
    2546                 :            :                     createInstance( ::rtl::OUString(
    2547 [ #  # ][ #  # ]:          0 :                             "com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY );
    2548                 :          0 :         uno::Reference< container::XNameAccess > xUICommands;
    2549         [ #  # ]:          0 :         if ( xNameAccess.is() )
    2550                 :            :         {
    2551                 :          0 :             rtl::OUString sTextDoc("com.sun.star.text.TextDocument");
    2552 [ #  # ][ #  # ]:          0 :             if(xNameAccess->hasByName(sTextDoc))
                 [ #  # ]
    2553                 :            :             {
    2554 [ #  # ][ #  # ]:          0 :                 uno::Any a = xNameAccess->getByName( sTextDoc );
    2555         [ #  # ]:          0 :                 a >>= xUICommands;
    2556                 :          0 :             }
    2557                 :            :         }
    2558         [ #  # ]:          0 :         if(!xUICommands.is())
    2559                 :          0 :             return 0;
    2560                 :            :         try
    2561                 :            :         {
    2562         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > aPropSeq;
    2563 [ #  # ][ #  # ]:          0 :             uno::Any aCommand = xUICommands->getByName(::rtl::OUString(".uno:StyleNewByExample"));
    2564         [ #  # ]:          0 :             ::rtl::OUString sLabel = lcl_GetLabel( aCommand );
    2565 [ #  # ][ #  # ]:          0 :             pMenu->InsertItem( SID_STYLE_NEW_BY_EXAMPLE, sLabel );
                 [ #  # ]
    2566         [ #  # ]:          0 :             pMenu->SetHelpId(SID_STYLE_NEW_BY_EXAMPLE, HID_TEMPLDLG_NEWBYEXAMPLE);
    2567                 :            : 
    2568 [ #  # ][ #  # ]:          0 :             aCommand = xUICommands->getByName(::rtl::OUString(".uno:StyleUpdateByExample"));
    2569         [ #  # ]:          0 :             sLabel = lcl_GetLabel( aCommand );
    2570                 :            : 
    2571 [ #  # ][ #  # ]:          0 :             pMenu->InsertItem( SID_STYLE_UPDATE_BY_EXAMPLE, sLabel );
                 [ #  # ]
    2572         [ #  # ]:          0 :             pMenu->SetHelpId(SID_STYLE_UPDATE_BY_EXAMPLE, HID_TEMPLDLG_UPDATEBYEXAMPLE);
    2573                 :            : 
    2574 [ #  # ][ #  # ]:          0 :             aCommand = xUICommands->getByName(::rtl::OUString(".uno:LoadStyles"));
    2575         [ #  # ]:          0 :             sLabel = lcl_GetLabel( aCommand );
    2576 [ #  # ][ #  # ]:          0 :             pMenu->InsertItem( SID_TEMPLATE_LOAD, sLabel );
                 [ #  # ]
    2577         [ #  # ]:          0 :             pMenu->SetHelpId(SID_TEMPLATE_LOAD, ".uno:LoadStyles");
    2578                 :            : 
    2579         [ #  # ]:          0 :             pMenu->SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, MenuSelectHdl));
    2580                 :            :             pMenu->Execute( pBox,
    2581                 :          0 :                             pBox->GetItemRect(nEntry),
    2582 [ #  # ][ #  # ]:          0 :                             POPUPMENU_EXECUTE_DOWN );
    2583 [ #  # ][ #  # ]:          0 :             pBox->EndSelection();
                 [ #  # ]
    2584                 :            :         }
    2585         [ #  # ]:          0 :         catch(uno::Exception&)
    2586                 :            :         {
    2587                 :            :         }
    2588 [ #  # ][ #  # ]:          0 :         pBox->Invalidate();
         [ #  # ][ #  # ]
                 [ #  # ]
    2589                 :            :     }
    2590                 :          0 :     return 0;
    2591                 :            : }
    2592                 :            : //-------------------------------------------------------------------------
    2593                 :          0 : IMPL_LINK( SfxTemplateDialog_Impl, MenuSelectHdl, Menu*, pMenu)
    2594                 :            : {
    2595                 :          0 :     sal_uInt16 nMenuId = pMenu->GetCurItemId();
    2596                 :          0 :     ActionSelect(nMenuId);
    2597                 :          0 :     return 0;
    2598                 :            : }
    2599                 :            : //-------------------------------------------------------------------------
    2600                 :            : 
    2601                 :          0 : SfxTemplateCatalog_Impl::SfxTemplateCatalog_Impl( Window* /*pParent*/, SfxBindings* pB,
    2602                 :            :                                                   SfxTemplateCatalog* pTmpWindow ) :
    2603                 :            : 
    2604                 :            :     SfxCommonTemplateDialog_Impl( pB, pTmpWindow ),
    2605                 :            : 
    2606                 :            :     aFamList    ( pTmpWindow, SfxResId( BT_TOOL ) ),
    2607                 :            :     aOkBtn      ( pTmpWindow, SfxResId( BT_OK ) ),
    2608                 :            :     aCancelBtn  ( pTmpWindow, SfxResId( BT_CANCEL ) ),
    2609                 :            :     aNewBtn     ( pTmpWindow, SfxResId( BT_NEW ) ),
    2610                 :            :     aChangeBtn  ( pTmpWindow, SfxResId( BT_EDIT ) ),
    2611                 :            :     aDelBtn     ( pTmpWindow, SfxResId( BT_DEL ) ),
    2612                 :            :     aOrgBtn     ( pTmpWindow, SfxResId( BT_ORG ) ),
    2613                 :            :     aHelpBtn    ( pTmpWindow, SfxResId( BT_HELP ) ),
    2614                 :            :     pReal       ( pTmpWindow ),
    2615 [ #  # ][ #  # ]:          0 :     aHelper     ( pTmpWindow )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2616                 :            : 
    2617                 :            : {
    2618         [ #  # ]:          0 :     aNewBtn.Disable();
    2619         [ #  # ]:          0 :     aDelBtn.Disable();
    2620         [ #  # ]:          0 :     aChangeBtn.Disable();
    2621                 :            : 
    2622         [ #  # ]:          0 :     SFX_APP()->Get_Impl()->pTemplateCommon = GetISfxTemplateCommon();
    2623         [ #  # ]:          0 :     pTmpWindow->FreeResource();
    2624                 :            : 
    2625         [ #  # ]:          0 :     Initialize();
    2626                 :            : 
    2627         [ #  # ]:          0 :     aFamList.SetSelectHdl(  LINK( this, SfxTemplateCatalog_Impl, FamListSelect ) );
    2628         [ #  # ]:          0 :     aOkBtn.SetClickHdl(     LINK( this, SfxTemplateCatalog_Impl, OkHdl ) );
    2629         [ #  # ]:          0 :     aCancelBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, CancelHdl ) );
    2630         [ #  # ]:          0 :     aNewBtn.SetClickHdl(    LINK( this, SfxTemplateCatalog_Impl, NewHdl ) );
    2631         [ #  # ]:          0 :     aDelBtn.SetClickHdl(    LINK( this, SfxTemplateCatalog_Impl, DelHdl ) );
    2632         [ #  # ]:          0 :     aChangeBtn.SetClickHdl( LINK( this, SfxTemplateCatalog_Impl, ChangeHdl ) );
    2633         [ #  # ]:          0 :     aOrgBtn.SetClickHdl(    LINK( this, SfxTemplateCatalog_Impl, OrgHdl ) );
    2634                 :          0 : }
    2635                 :            : 
    2636                 :            : //-------------------------------------------------------------------------
    2637                 :            : 
    2638 [ #  # ][ #  # ]:          0 : SfxTemplateCatalog_Impl::~SfxTemplateCatalog_Impl()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2639                 :            : {
    2640         [ #  # ]:          0 :     SFX_APP()->Get_Impl()->pTemplateCommon = 0;
    2641         [ #  # ]:          0 : }
    2642                 :            : 
    2643                 :            : //-------------------------------------------------------------------------
    2644                 :            : 
    2645                 :          0 : IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, OkHdl, Button *, pButton )
    2646                 :            : {
    2647                 :            :     (void)pButton; //unused
    2648                 :          0 :     ApplyHdl( NULL );
    2649                 :          0 :     pReal->EndDialog( RET_OK );
    2650                 :          0 :     return 0;
    2651                 :            : }
    2652                 :          0 : IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, OkHdl, Button *, pButton )
    2653                 :            : 
    2654                 :            : //-------------------------------------------------------------------------
    2655                 :            : 
    2656                 :          0 : IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, CancelHdl, Button *, pButton )
    2657                 :            : {
    2658                 :            :     (void)pButton; //unused
    2659                 :          0 :     pReal->EndDialog( RET_CANCEL );
    2660                 :          0 :     return 0;
    2661                 :            : }
    2662                 :          0 : IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, CancelHdl, Button *, pButton )
    2663                 :            : 
    2664                 :            : //-------------------------------------------------------------------------
    2665                 :            : 
    2666                 :          0 : IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, NewHdl, Button *, pButton )
    2667                 :            : {
    2668                 :            :     (void)pButton; //unused
    2669 [ #  # ][ #  # ]:          0 :     aCancelBtn.SetText( SfxResId(STR_CLOSE).toString() );
         [ #  # ][ #  # ]
    2670                 :          0 :     SfxCommonTemplateDialog_Impl::NewHdl( NULL );
    2671                 :          0 :     return 0;
    2672                 :            : }
    2673                 :          0 : IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, NewHdl, Button *, pButton )
    2674                 :            : 
    2675                 :            : //-------------------------------------------------------------------------
    2676                 :            : 
    2677                 :          0 : IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, ChangeHdl, Button *, pButton )
    2678                 :            : {
    2679                 :            :     (void)pButton; //unused
    2680 [ #  # ][ #  # ]:          0 :     aCancelBtn.SetText( SfxResId(STR_CLOSE).toString() );
         [ #  # ][ #  # ]
    2681                 :          0 :     SfxCommonTemplateDialog_Impl::EditHdl( NULL );
    2682                 :          0 :     return 0;
    2683                 :            : }
    2684                 :          0 : IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, ChangeHdl, Button *, pButton )
    2685                 :            : 
    2686                 :            : //-------------------------------------------------------------------------
    2687                 :            : 
    2688                 :          0 : IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, DelHdl, Button *, pButton )
    2689                 :            : {
    2690                 :            :     (void)pButton; //unused
    2691                 :          0 :     SfxCommonTemplateDialog_Impl::DeleteHdl( NULL );
    2692                 :          0 :     return 0;
    2693                 :            : }
    2694                 :          0 : IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, DelHdl, Button *, pButton )
    2695                 :            : 
    2696                 :            : //-------------------------------------------------------------------------
    2697                 :            : 
    2698                 :          0 : IMPL_LINK( SfxTemplateCatalog_Impl, OrgHdl, Button *, pButton )
    2699                 :            : {
    2700                 :            :     (void)pButton; //unused
    2701 [ #  # ][ #  # ]:          0 :     aCancelBtn.SetText( SfxResId(STR_CLOSE).toString() );
         [ #  # ][ #  # ]
                 [ #  # ]
    2702         [ #  # ]:          0 :     SfxDocumentTemplates aTemplates;
    2703         [ #  # ]:          0 :     aTemplates.Construct();
    2704 [ #  # ][ #  # ]:          0 :     SfxTemplateOrganizeDlg* pDlg = new SfxTemplateOrganizeDlg( pReal, &aTemplates );
    2705         [ #  # ]:          0 :     const short nRet = pDlg->Execute();
    2706 [ #  # ][ #  # ]:          0 :     delete pDlg;
    2707         [ #  # ]:          0 :     if ( RET_OK == nRet )
    2708         [ #  # ]:          0 :         Update_Impl();
    2709         [ #  # ]:          0 :     else if ( RET_EDIT_STYLE == nRet )
    2710         [ #  # ]:          0 :         pReal->EndDialog( RET_CANCEL );
    2711         [ #  # ]:          0 :     return 0;
    2712                 :            : }
    2713                 :            : 
    2714                 :            : //-------------------------------------------------------------------------
    2715                 :            : 
    2716                 :          0 : void SfxTemplateCatalog_Impl::EnableEdit( sal_Bool bEnable )
    2717                 :            : {
    2718                 :          0 :     SfxCommonTemplateDialog_Impl::EnableEdit( bEnable );
    2719                 :          0 :     aChangeBtn.Enable( bEnable );
    2720                 :          0 : }
    2721                 :            : 
    2722                 :            : //-------------------------------------------------------------------------
    2723                 :            : 
    2724                 :          0 : void SfxTemplateCatalog_Impl::EnableDel( sal_Bool bEnable )
    2725                 :            : {
    2726                 :          0 :     SfxCommonTemplateDialog_Impl::EnableDel( bEnable );
    2727                 :          0 :     aDelBtn.Enable( bEnable );
    2728                 :          0 : }
    2729                 :            : 
    2730                 :          0 : void SfxTemplateCatalog_Impl::EnableNew(sal_Bool bEnable)
    2731                 :            : {
    2732                 :          0 :     SfxCommonTemplateDialog_Impl::EnableNew( bEnable );
    2733                 :          0 :     aNewBtn.Enable( bEnable );
    2734                 :          0 : }
    2735                 :            : 
    2736                 :            : //-------------------------------------------------------------------------
    2737                 :            : 
    2738                 :          0 : IMPL_LINK_INLINE_START( SfxTemplateCatalog_Impl, FamListSelect, ListBox *, pList )
    2739                 :            : {
    2740                 :          0 :     const sal_uInt16 nEntry = aFamIds[pList->GetSelectEntryPos()];
    2741                 :          0 :     FamilySelect(nEntry);
    2742                 :          0 :     return 0;
    2743                 :            : }
    2744                 :          0 : IMPL_LINK_INLINE_END( SfxTemplateCatalog_Impl, FamListSelect, ListBox *, pList )
    2745                 :            : 
    2746                 :            : //-------------------------------------------------------------------------
    2747                 :            : 
    2748                 :          0 : void SfxTemplateCatalog_Impl::EnableItem( sal_uInt16 nMesId, sal_Bool bCheck )
    2749                 :            : {
    2750         [ #  # ]:          0 :     if ( nMesId == SID_STYLE_WATERCAN )
    2751                 :          0 :         aOkBtn.Enable( bCheck );
    2752 [ #  # ][ #  # ]:          0 :     if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR )
    2753                 :          0 :         return;
    2754                 :            : }
    2755                 :            : 
    2756                 :            : //-------------------------------------------------------------------------
    2757                 :            : 
    2758                 :          0 : void SfxTemplateCatalog_Impl::CheckItem(sal_uInt16 nMesId, sal_Bool /*bCheck*/)
    2759                 :            : {
    2760 [ #  # ][ #  # ]:          0 :     if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR )
    2761                 :          0 :         return;
    2762                 :            :     sal_uInt16 i;
    2763 [ #  # ][ #  # ]:          0 :     for ( i = 0; i < aFamIds.size() && aFamIds[i] != nMesId; i++ ) ;
                 [ #  # ]
    2764                 :          0 :     aFamList.SelectEntryPos(i);
    2765                 :            : }
    2766                 :            : 
    2767                 :            : //-------------------------------------------------------------------------
    2768                 :            : 
    2769                 :          0 : sal_Bool SfxTemplateCatalog_Impl::IsCheckedItem(sal_uInt16 nMesId)
    2770                 :            : {
    2771 [ #  # ][ #  # ]:          0 :     if ( nMesId > SFX_STYLE_FAMILY_PSEUDO || nMesId < SFX_STYLE_FAMILY_CHAR )
    2772                 :          0 :         return sal_False;
    2773                 :            :     sal_uInt16 i;
    2774 [ #  # ][ #  # ]:          0 :     for ( i = 0; i < aFamIds.size() && aFamIds[i] != nMesId; i++ )
                 [ #  # ]
    2775                 :            :         ;
    2776 [ #  # ][ #  # ]:          0 :     return aFamList.IsEntrySelected( rtl::OUString::valueOf(static_cast<sal_Int32>(i)) );
                 [ #  # ]
    2777                 :            : }
    2778                 :            : 
    2779                 :            : //-------------------------------------------------------------------------
    2780                 :            : // The list has only to master the disabling, since during his life time no
    2781                 :            : // changes in selection can be made,
    2782                 :          0 : void SfxTemplateCatalog_Impl::EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnable )
    2783                 :            : {
    2784         [ #  # ]:          0 :     if ( !bEnable )
    2785         [ #  # ]:          0 :         for ( sal_uInt16 nPos = aFamIds.size(); nPos--; )
    2786         [ #  # ]:          0 :             if ( aFamIds[ nPos ] == nId )
    2787                 :            :             {
    2788 [ #  # ][ #  # ]:          0 :                 aFamIds.erase( aFamIds.begin() + nPos );
    2789                 :          0 :                 aFamList.RemoveEntry( nPos );
    2790                 :            :             }
    2791                 :          0 : }
    2792                 :            : 
    2793                 :          0 : void SfxTemplateCatalog_Impl::InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pItem )
    2794                 :            : {
    2795 [ #  # ][ #  # ]:          0 :     if ( nId > SFX_STYLE_FAMILY_PSEUDO || nId < SFX_STYLE_FAMILY_CHAR )
    2796                 :          0 :         return;
    2797                 :          0 :     aFamList.InsertEntry( pItem->GetText(), 0 );
    2798                 :          0 :     aFamIds.insert( aFamIds.begin(), nId );
    2799                 :            : }
    2800                 :            : 
    2801                 :          0 : void SfxTemplateCatalog_Impl::ClearFamilyList()
    2802                 :            : {
    2803                 :          0 :     aFamList.Clear();
    2804                 :          0 :     aFamIds.clear();
    2805                 :          0 : }
    2806                 :            : 
    2807                 :          0 : void SfxTemplateCatalog_Impl::PrepareDeleteAction()
    2808                 :            : {
    2809                 :          0 :     aDelBtn.Disable();
    2810 [ #  # ][ #  # ]:          0 :     aCancelBtn.SetText( SfxResId(STR_CLOSE).toString() );
         [ #  # ][ #  # ]
    2811                 :          0 : }
    2812                 :            : 
    2813                 :            : 
    2814                 :        240 : void SfxCommonTemplateDialog_Impl::SetFamily( sal_uInt16 nId )
    2815                 :            : {
    2816         [ -  + ]:        240 :     if ( nId != nActFamily )
    2817                 :            :     {
    2818         [ #  # ]:          0 :         if ( nActFamily != 0xFFFF )
    2819                 :          0 :             CheckItem( nActFamily, sal_False );
    2820                 :          0 :         nActFamily = nId;
    2821         [ #  # ]:          0 :         if ( nId != 0xFFFF )
    2822                 :          0 :             bUpdateFamily = sal_True;
    2823                 :            :     }
    2824                 :        240 : }
    2825                 :            : 
    2826                 :        242 : void SfxCommonTemplateDialog_Impl::UpdateFamily_Impl()
    2827                 :            : {
    2828                 :        242 :     bUpdateFamily = sal_False;
    2829                 :            : 
    2830                 :        242 :     SfxDispatcher* pDispat = pBindings->GetDispatcher_Impl();
    2831                 :        242 :     SfxViewFrame *pViewFrame = pDispat->GetFrame();
    2832                 :        242 :     SfxObjectShell *pDocShell = pViewFrame->GetObjectShell();
    2833                 :            : 
    2834                 :        242 :     SfxStyleSheetBasePool *pOldStyleSheetPool = pStyleSheetPool;
    2835         [ +  - ]:        242 :     pStyleSheetPool = pDocShell? pDocShell->GetStyleSheetPool(): 0;
    2836         [ -  + ]:        242 :     if ( pOldStyleSheetPool != pStyleSheetPool )
    2837                 :            :     {
    2838         [ #  # ]:          0 :         if ( pOldStyleSheetPool )
    2839                 :          0 :             EndListening(*pOldStyleSheetPool);
    2840         [ #  # ]:          0 :         if ( pStyleSheetPool )
    2841                 :          0 :             StartListening(*pOldStyleSheetPool);
    2842                 :            :     }
    2843                 :            : 
    2844                 :        242 :     bWaterDisabled = sal_False;
    2845                 :        242 :     bCanNew = sal_True;
    2846                 :        242 :     bTreeDrag = sal_True;
    2847                 :        242 :     bUpdateByExampleDisabled = sal_False;
    2848                 :            : 
    2849         [ +  - ]:        242 :     if ( pStyleSheetPool )
    2850                 :            :     {
    2851         [ +  - ]:        242 :         if(!pTreeBox)
    2852                 :        242 :             UpdateStyles_Impl(UPDATE_FAMILY | UPDATE_FAMILY_LIST);
    2853                 :            :         else
    2854                 :            :         {
    2855                 :          0 :             UpdateStyles_Impl(UPDATE_FAMILY);
    2856                 :          0 :             FillTreeBox();
    2857                 :            :         }
    2858                 :            :     }
    2859                 :            : 
    2860                 :        242 :     InvalidateBindings();
    2861                 :            : 
    2862 [ #  # ][ -  + ]:        242 :     if ( IsCheckedItem( SID_STYLE_WATERCAN ) &&
                 [ -  + ]
    2863                 :            :          // only if that area is allowed
    2864                 :          0 :          0 != pFamilyState[ nActFamily - 1 ] )
    2865                 :            :         Execute_Impl( SID_STYLE_APPLY, GetSelectedEntry(),
    2866 [ #  # ][ #  # ]:          0 :                       String(), (sal_uInt16)GetFamilyItem_Impl()->GetFamily() );
                 [ #  # ]
    2867                 :        242 : }
    2868                 :          0 : void SfxCommonTemplateDialog_Impl::ReplaceUpdateButtonByMenu()
    2869                 :            : {
    2870                 :            :     //does nothing
    2871                 :          0 : }
    2872                 :            : 
    2873                 :        360 : void SfxTemplateDialog::StateChanged( StateChangedType nStateChange )
    2874                 :            : {
    2875         [ +  + ]:        360 :     if ( nStateChange == STATE_CHANGE_INITSHOW )
    2876                 :            :     {
    2877         [ +  - ]:        120 :         SfxViewFrame *pFrame = GetBindings().GetDispatcher_Impl()->GetFrame();
    2878         [ +  - ]:        120 :         Window* pEditWin = pFrame->GetViewShell()->GetWindow();
    2879                 :            : 
    2880         [ +  - ]:        120 :         Size aSize = pEditWin->GetSizePixel();
    2881 [ +  - ][ +  - ]:        120 :         Point aPoint = pEditWin->OutputToScreenPixel( pEditWin->GetPosPixel() );
    2882 [ +  - ][ +  - ]:        120 :         aPoint = GetParent()->ScreenToOutputPixel( aPoint );
    2883         [ +  - ]:        120 :         Size aWinSize = GetSizePixel();
    2884                 :        120 :         aPoint.X() += aSize.Width() - aWinSize.Width() - 20;
    2885                 :        120 :         aPoint.Y() += aSize.Height() / 2 - aWinSize.Height() / 2;
    2886         [ +  - ]:        120 :         SetFloatingPos( aPoint );
    2887                 :            :     }
    2888                 :            : 
    2889                 :        360 :     SfxDockingWindow::StateChanged( nStateChange );
    2890                 :        360 : }
    2891                 :            : 
    2892                 :        120 : DropToolBox_Impl::DropToolBox_Impl(Window* pParent, SfxTemplateDialog_Impl* pTemplateDialog) :
    2893                 :            :     ToolBox(pParent),
    2894                 :            :     DropTargetHelper(this),
    2895         [ +  - ]:        120 :     rParent(*pTemplateDialog)
    2896                 :            : {
    2897                 :        120 : }
    2898                 :            : 
    2899         [ +  - ]:        120 : DropToolBox_Impl::~DropToolBox_Impl()
    2900                 :            : {
    2901         [ -  + ]:        120 : }
    2902                 :            : 
    2903                 :          0 : sal_Int8    DropToolBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt )
    2904                 :            : {
    2905                 :          0 :     sal_Int8 nReturn = DND_ACTION_NONE;
    2906                 :          0 :     sal_uInt16 nItemId = GetItemId( rEvt.maPosPixel );
    2907 [ #  # ][ #  # ]:          0 :     if(USHRT_MAX != nItemId && !IsItemChecked( nItemId ))
                 [ #  # ]
    2908                 :            :     {
    2909                 :          0 :         SetCurItemId(nItemId);
    2910                 :          0 :         GetSelectHdl().Call(this);
    2911                 :            :     }
    2912                 :            :     // special case: page styles are allowed to create new styles by example
    2913                 :            :     // but not allowed to be created by drag and drop
    2914   [ #  #  #  # ]:          0 :     if ( nItemId != SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE )&&
         [ #  # ][ #  # ]
    2915                 :          0 :         IsDropFormatSupported( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) &&
    2916                 :          0 :         !rParent.bNewByExampleDisabled )
    2917                 :            :     {
    2918                 :          0 :         nReturn = DND_ACTION_COPY;
    2919                 :            :     }
    2920                 :          0 :     return nReturn;
    2921                 :            : }
    2922                 :            : 
    2923                 :          0 : sal_Int8    DropToolBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt )
    2924                 :            : {
    2925                 :          0 :      return rParent.aFmtLb.ExecuteDrop(rEvt);
    2926                 :            : }
    2927                 :            : 
    2928                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10