LCOV - code coverage report
Current view: top level - sfx2/source/dialog - versdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 249 0.0 %
Date: 2012-08-25 Functions: 0 29 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 598 0.0 %

           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 <unotools/localedatawrapper.hxx>
      21                 :            : #include <comphelper/processfactory.hxx>
      22                 :            : #include <svl/eitem.hxx>
      23                 :            : #include <svl/intitem.hxx>
      24                 :            : #include <svl/stritem.hxx>
      25                 :            : #include <svl/itemset.hxx>
      26                 :            : #include <unotools/useroptions.hxx>
      27                 :            : #include <vcl/msgbox.hxx>
      28                 :            : #include <vcl/svapp.hxx>
      29                 :            : #include <tools/datetime.hxx>
      30                 :            : 
      31                 :            : #include "versdlg.hrc"
      32                 :            : #include "versdlg.hxx"
      33                 :            : #include <sfx2/viewfrm.hxx>
      34                 :            : #include "sfx2/sfxresid.hxx"
      35                 :            : #include <sfx2/docfile.hxx>
      36                 :            : #include <sfx2/objsh.hxx>
      37                 :            : #include <sfx2/sfxsids.hrc>
      38                 :            : #include <sfx2/dispatch.hxx>
      39                 :            : #include <sfx2/request.hxx>
      40                 :            : 
      41                 :            : #include <sfx2/sfxuno.hxx>
      42                 :            : #include <vector>
      43                 :            : 
      44                 :            : using namespace com::sun::star;
      45                 :            : using ::std::vector;
      46                 :            : 
      47                 :            : // **************************************************************************
      48 [ #  # ][ #  # ]:          0 : struct SfxVersionInfo
      49                 :            : {
      50                 :            :     String                  aName;
      51                 :            :     String                  aComment;
      52                 :            :     String                  aAuthor;
      53                 :            :     DateTime                aCreationDate;
      54                 :            : 
      55                 :            :                             SfxVersionInfo();
      56                 :          0 :                             SfxVersionInfo( const SfxVersionInfo& rInfo )
      57 [ #  # ][ #  # ]:          0 :                                 : aCreationDate( DateTime::EMPTY )
      58         [ #  # ]:          0 :                             { *this = rInfo; }
      59                 :            : 
      60                 :          0 :     SfxVersionInfo&         operator=( const SfxVersionInfo &rInfo )
      61                 :            :                             {
      62                 :          0 :                                 aName = rInfo.aName;
      63                 :          0 :                                 aComment = rInfo.aComment;
      64                 :          0 :                                 aAuthor = rInfo.aAuthor;
      65                 :          0 :                                 aCreationDate = rInfo.aCreationDate;
      66                 :          0 :                                 return *this;
      67                 :            :                             }
      68                 :            : };
      69                 :            : 
      70                 :            : typedef vector< SfxVersionInfo* > _SfxVersionTable;
      71                 :            : 
      72                 :            : class SfxVersionTableDtor
      73                 :            : {
      74                 :            : private:
      75                 :            :     _SfxVersionTable        aTableList;
      76                 :            : public:
      77                 :            :                             SfxVersionTableDtor( const SfxVersionTableDtor &rCpy )
      78                 :            :                             { *this = rCpy; }
      79                 :            : 
      80                 :            :                             SfxVersionTableDtor( const uno::Sequence < util::RevisionTag >& rInfo );
      81                 :            : 
      82                 :          0 :                             ~SfxVersionTableDtor()
      83         [ #  # ]:          0 :                             { DelDtor(); }
      84                 :            : 
      85                 :            :     SfxVersionTableDtor&    operator=( const SfxVersionTableDtor &rCpy );
      86                 :            :     void                    DelDtor();
      87                 :            :     SvStream&               Read( SvStream & );
      88                 :            :     SvStream&               Write( SvStream & ) const;
      89                 :            : 
      90                 :          0 :     size_t                  size() const
      91                 :          0 :                             { return aTableList.size(); }
      92                 :            : 
      93                 :          0 :     SfxVersionInfo*         at( size_t i ) const
      94                 :          0 :                             { return aTableList[ i ]; }
      95                 :            : };
      96                 :            : 
      97                 :          0 : SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < util::RevisionTag >& rInfo )
      98                 :            : {
      99         [ #  # ]:          0 :     for ( sal_Int32 n=0; n<(sal_Int32)rInfo.getLength(); n++ )
     100                 :            :     {
     101 [ #  # ][ #  # ]:          0 :         SfxVersionInfo* pInfo = new SfxVersionInfo;
     102         [ #  # ]:          0 :         pInfo->aName = rInfo[n].Identifier;
     103         [ #  # ]:          0 :         pInfo->aComment = rInfo[n].Comment;
     104         [ #  # ]:          0 :         pInfo->aAuthor = rInfo[n].Author;
     105                 :            : 
     106                 :          0 :         Date aDate ( rInfo[n].TimeStamp.Day,   rInfo[n].TimeStamp.Month,   rInfo[n].TimeStamp.Year );
     107         [ #  # ]:          0 :         Time aTime ( rInfo[n].TimeStamp.Hours, rInfo[n].TimeStamp.Minutes, rInfo[n].TimeStamp.Seconds, rInfo[n].TimeStamp.HundredthSeconds );
     108                 :            : 
     109 [ #  # ][ #  # ]:          0 :         pInfo->aCreationDate = DateTime( aDate, aTime );
     110         [ #  # ]:          0 :         aTableList.push_back( pInfo );
     111                 :            :     }
     112                 :          0 : }
     113                 :            : 
     114                 :          0 : void SfxVersionTableDtor::DelDtor()
     115                 :            : {
     116         [ #  # ]:          0 :     for ( size_t i = 0, n = aTableList.size(); i < n; ++i )
     117         [ #  # ]:          0 :         delete aTableList[ i ];
     118                 :          0 :     aTableList.clear();
     119                 :          0 : }
     120                 :            : 
     121                 :          0 : SfxVersionTableDtor& SfxVersionTableDtor::operator=( const SfxVersionTableDtor& rTbl )
     122                 :            : {
     123                 :          0 :     DelDtor();
     124         [ #  # ]:          0 :     for ( size_t i = 0, n = rTbl.size(); i < n; ++i )
     125                 :            :     {
     126 [ #  # ][ #  # ]:          0 :         SfxVersionInfo* pNew = new SfxVersionInfo( *(rTbl.at( i )) );
                 [ #  # ]
     127         [ #  # ]:          0 :         aTableList.push_back( pNew );
     128                 :            :     }
     129                 :          0 :     return *this;
     130                 :            : }
     131                 :            : 
     132                 :            : //----------------------------------------------------------------
     133                 :          0 : SfxVersionInfo::SfxVersionInfo()
     134 [ #  # ][ #  # ]:          0 :     : aCreationDate( DateTime::EMPTY )
     135                 :            : {
     136                 :          0 : }
     137                 :            : 
     138                 :          0 : static String ConvertDateTime_Impl(const DateTime& rTime, const LocaleDataWrapper& rWrapper)
     139                 :            : {
     140         [ #  # ]:          0 :      const String pDelim ( DEFINE_CONST_UNICODE( ", "));
     141 [ #  # ][ #  # ]:          0 :      String aStr(rWrapper.getDate(rTime));
     142         [ #  # ]:          0 :      aStr += pDelim;
     143 [ #  # ][ #  # ]:          0 :      aStr += rWrapper.getTime(rTime, sal_True, sal_False);
     144         [ #  # ]:          0 :      return aStr;
     145                 :            : }
     146                 :            : 
     147                 :            : // Caution in the code this array si indexed directly (0, 1, ...)
     148                 :            : static long nTabs_Impl[] =
     149                 :            : {
     150                 :            :     3, // Number of Tabs
     151                 :            :     0, 62, 124
     152                 :            : };
     153                 :            : 
     154                 :          0 : void SfxVersionsTabListBox_Impl::KeyInput( const KeyEvent& rKeyEvent )
     155                 :            : {
     156                 :          0 :     const KeyCode& rCode = rKeyEvent.GetKeyCode();
     157         [ #  # ]:          0 :     switch ( rCode.GetCode() )
     158                 :            :     {
     159                 :            :         case KEY_RETURN :
     160                 :            :         case KEY_ESCAPE :
     161                 :            :         case KEY_TAB :
     162                 :          0 :             Window::GetParent()->KeyInput( rKeyEvent );
     163                 :          0 :             break;
     164                 :            :         default:
     165                 :          0 :             SvTabListBox::KeyInput( rKeyEvent );
     166                 :          0 :             break;
     167                 :            :     }
     168                 :          0 : }
     169                 :            : 
     170                 :          0 : SfxVersionsTabListBox_Impl::SfxVersionsTabListBox_Impl( Window* pParent, const ResId& rResId )
     171                 :          0 :     : SvTabListBox( pParent, rResId )
     172                 :            : {
     173                 :          0 : }
     174                 :            : 
     175                 :          0 : SfxVersionDialog::SfxVersionDialog ( SfxViewFrame* pVwFrame, sal_Bool bIsSaveVersionOnClose )
     176                 :            :     : SfxModalDialog( NULL, SfxResId( DLG_VERSIONS ) )
     177                 :            :     , aNewGroup( this, SfxResId( GB_NEWVERSIONS ) )
     178                 :            :     , aSaveButton( this, SfxResId( PB_SAVE ) )
     179                 :            :     , aSaveCheckBox( this, SfxResId( CB_SAVEONCLOSE ) )
     180                 :            :     , aExistingGroup( this, SfxResId( GB_OLDVERSIONS ) )
     181                 :            :     , aDateTimeText( this, SfxResId( FT_DATETIME ) )
     182                 :            :     , aSavedByText( this, SfxResId( FT_SAVEDBY ) )
     183                 :            :     , aCommentText( this, SfxResId( FT_COMMENTS ) )
     184                 :            :     , aVersionBox( this, SfxResId( TLB_VERSIONS ) )
     185                 :            :     , aCloseButton( this, SfxResId( PB_CLOSE ) )
     186                 :            :     , aOpenButton( this, SfxResId( PB_OPEN ) )
     187                 :            :     , aViewButton( this, SfxResId( PB_VIEW ) )
     188                 :            :     , aDeleteButton( this, SfxResId( PB_DELETE ) )
     189                 :            :     , aCompareButton( this, SfxResId( PB_COMPARE ) )
     190                 :            :     , aHelpButton( this, SfxResId( PB_HELP ) )
     191                 :            :     , pViewFrame( pVwFrame )
     192                 :            :     , mpTable( NULL )
     193                 :            :     , mpLocaleWrapper( NULL )
     194 [ #  # ][ #  # ]:          0 :     , mbIsSaveVersionOnClose( bIsSaveVersionOnClose )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     195                 :            : {
     196         [ #  # ]:          0 :     FreeResource();
     197                 :            : 
     198         [ #  # ]:          0 :     Link aClickLink = LINK( this, SfxVersionDialog, ButtonHdl_Impl );
     199                 :          0 :     aViewButton.SetClickHdl ( aClickLink );
     200                 :          0 :     aSaveButton.SetClickHdl ( aClickLink );
     201                 :          0 :     aDeleteButton.SetClickHdl ( aClickLink );
     202                 :          0 :     aCompareButton.SetClickHdl ( aClickLink );
     203                 :          0 :     aOpenButton.SetClickHdl ( aClickLink );
     204                 :          0 :     aSaveCheckBox.SetClickHdl ( aClickLink );
     205                 :            : 
     206         [ #  # ]:          0 :     aVersionBox.SetSelectHdl( LINK( this, SfxVersionDialog, SelectHdl_Impl ) );
     207         [ #  # ]:          0 :     aVersionBox.SetDoubleClickHdl( LINK( this, SfxVersionDialog, DClickHdl_Impl ) );
     208                 :            : 
     209         [ #  # ]:          0 :     aVersionBox.GrabFocus();
     210 [ #  # ][ #  # ]:          0 :     aVersionBox.SetStyle( aVersionBox.GetStyle() | WB_HSCROLL | WB_CLIPCHILDREN );
     211         [ #  # ]:          0 :     aVersionBox.SetSelectionMode( SINGLE_SELECTION );
     212         [ #  # ]:          0 :     aVersionBox.SetTabs( &nTabs_Impl[0], MAP_APPFONT );
     213         [ #  # ]:          0 :     aVersionBox.Resize();       // OS: Hack for correct selection
     214         [ #  # ]:          0 :     RecalcDateColumn();
     215                 :            : 
     216                 :            :     // set dialog title (filename or docinfo title)
     217         [ #  # ]:          0 :     String sText = GetText();
     218 [ #  # ][ #  # ]:          0 :     ( sText += ' ' ) += pViewFrame->GetObjectShell()->GetTitle();
         [ #  # ][ #  # ]
                 [ #  # ]
     219         [ #  # ]:          0 :     SetText( sText );
     220                 :            : 
     221 [ #  # ][ #  # ]:          0 :     Init_Impl();
     222                 :          0 : }
     223                 :            : 
     224                 :          0 : String ConvertWhiteSpaces_Impl( const String& rText )
     225                 :            : {
     226                 :            :     // converted linebreaks and tabs to blanks; it's necessary for the display
     227                 :          0 :     String sConverted;
     228                 :          0 :     const sal_Unicode* pChars = rText.GetBuffer();
     229         [ #  # ]:          0 :     while ( *pChars )
     230                 :            :     {
     231         [ #  # ]:          0 :         switch ( *pChars )
     232                 :            :         {
     233                 :            :             case '\n' :
     234                 :            :             case '\t' :
     235         [ #  # ]:          0 :                 sConverted += ' ';
     236                 :          0 :                 break;
     237                 :            : 
     238                 :            :             default:
     239         [ #  # ]:          0 :                 sConverted += *pChars;
     240                 :            :         }
     241                 :            : 
     242                 :          0 :         ++pChars;
     243                 :            :     }
     244                 :            : 
     245                 :          0 :     return sConverted;
     246                 :            : }
     247                 :            : 
     248                 :          0 : void SfxVersionDialog::Init_Impl()
     249                 :            : {
     250         [ #  # ]:          0 :     SfxObjectShell *pObjShell = pViewFrame->GetObjectShell();
     251                 :          0 :     SfxMedium* pMedium = pObjShell->GetMedium();
     252 [ #  # ][ #  # ]:          0 :     uno::Sequence < util::RevisionTag > aVersions = pMedium->GetVersionList( true );
     253 [ #  # ][ #  # ]:          0 :     delete mpTable;
     254 [ #  # ][ #  # ]:          0 :     mpTable = new SfxVersionTableDtor( aVersions );
     255                 :            :     {
     256         [ #  # ]:          0 :         for ( size_t n = 0; n < mpTable->size(); ++n )
     257                 :            :         {
     258         [ #  # ]:          0 :             SfxVersionInfo *pInfo = mpTable->at( n );
     259         [ #  # ]:          0 :             String aEntry = ConvertDateTime_Impl( pInfo->aCreationDate, *mpLocaleWrapper );
     260         [ #  # ]:          0 :             aEntry += '\t';
     261         [ #  # ]:          0 :             aEntry += pInfo->aAuthor;
     262         [ #  # ]:          0 :             aEntry += '\t';
     263 [ #  # ][ #  # ]:          0 :             aEntry += ConvertWhiteSpaces_Impl( pInfo->aComment );
                 [ #  # ]
     264         [ #  # ]:          0 :             SvLBoxEntry *pEntry = aVersionBox.InsertEntry( aEntry );
     265                 :          0 :             pEntry->SetUserData( pInfo );
     266         [ #  # ]:          0 :         }
     267                 :            :     }
     268                 :            : 
     269         [ #  # ]:          0 :     aSaveCheckBox.Check( mbIsSaveVersionOnClose );
     270                 :            : 
     271         [ #  # ]:          0 :     sal_Bool bEnable = !pObjShell->IsReadOnly();
     272         [ #  # ]:          0 :     aSaveButton.Enable( bEnable );
     273         [ #  # ]:          0 :     aSaveCheckBox.Enable( bEnable );
     274                 :            : 
     275         [ #  # ]:          0 :     aOpenButton.Disable();
     276         [ #  # ]:          0 :     aViewButton.Disable();
     277         [ #  # ]:          0 :     aDeleteButton.Disable();
     278         [ #  # ]:          0 :     aCompareButton.Disable();
     279                 :            : 
     280 [ #  # ][ #  # ]:          0 :     SelectHdl_Impl( &aVersionBox );
     281                 :          0 : }
     282                 :            : 
     283 [ #  # ][ #  # ]:          0 : SfxVersionDialog::~SfxVersionDialog ()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     284                 :            : {
     285 [ #  # ][ #  # ]:          0 :     delete mpTable;
     286 [ #  # ][ #  # ]:          0 :     delete mpLocaleWrapper;
     287         [ #  # ]:          0 : }
     288                 :            : 
     289                 :          0 : void SfxVersionDialog::Open_Impl()
     290                 :            : {
     291         [ #  # ]:          0 :     SfxObjectShell *pObjShell = pViewFrame->GetObjectShell();
     292                 :            : 
     293         [ #  # ]:          0 :     SvLBoxEntry *pEntry = aVersionBox.FirstSelected();
     294         [ #  # ]:          0 :     sal_uIntPtr nPos = aVersionBox.GetModel()->GetRelPos( pEntry );
     295         [ #  # ]:          0 :     SfxInt16Item aItem( SID_VERSION, (short)nPos+1 );
     296 [ #  # ][ #  # ]:          0 :     SfxStringItem aTarget( SID_TARGETNAME, DEFINE_CONST_UNICODE("_blank") );
                 [ #  # ]
     297 [ #  # ][ #  # ]:          0 :     SfxStringItem aReferer( SID_REFERER, DEFINE_CONST_UNICODE("private:user") );
                 [ #  # ]
     298 [ #  # ][ #  # ]:          0 :     SfxStringItem aFile( SID_FILE_NAME, pObjShell->GetMedium()->GetName() );
         [ #  # ][ #  # ]
     299                 :            : 
     300         [ #  # ]:          0 :     uno::Sequence< beans::NamedValue > aEncryptionData;
     301 [ #  # ][ #  # ]:          0 :     if ( GetEncryptionData_Impl( pObjShell->GetMedium()->GetItemSet(), aEncryptionData ) )
                 [ #  # ]
     302                 :            :     {
     303                 :            :         // there is a password, it should be used during the opening
     304 [ #  # ][ #  # ]:          0 :         SfxUnoAnyItem aEncryptionDataItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) );
     305                 :            :         pViewFrame->GetDispatcher()->Execute(
     306 [ #  # ][ #  # ]:          0 :             SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aFile, &aItem, &aTarget, &aReferer, &aEncryptionDataItem, 0L );
     307                 :            :     }
     308                 :            :     else
     309                 :            :         pViewFrame->GetDispatcher()->Execute(
     310         [ #  # ]:          0 :             SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aFile, &aItem, &aTarget, &aReferer, 0L );
     311                 :            : 
     312 [ #  # ][ #  # ]:          0 :     Close();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     313                 :          0 : }
     314                 :            : 
     315                 :          0 : void SfxVersionDialog::RecalcDateColumn()
     316                 :            : {
     317                 :            :     // recalculate the datetime column width
     318         [ #  # ]:          0 :     DateTime aNow( DateTime::SYSTEM );
     319                 :            :     mpLocaleWrapper = new LocaleDataWrapper(
     320 [ #  # ][ #  # ]:          0 :         ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
         [ #  # ][ #  # ]
                 [ #  # ]
     321         [ #  # ]:          0 :     String sDateTime = ConvertDateTime_Impl( aNow, *mpLocaleWrapper );
     322         [ #  # ]:          0 :     long nWidth = aVersionBox.GetTextWidth( sDateTime );
     323                 :          0 :     nWidth += 15; // a little offset
     324         [ #  # ]:          0 :     long nTab = aVersionBox.GetTab(1);
     325         [ #  # ]:          0 :     if ( nWidth > nTab )
     326                 :            :     {
     327                 :            :         // resize columns
     328                 :          0 :         long nDelta = nWidth - nTab;
     329         [ #  # ]:          0 :         aVersionBox.SetTab( 1, nTab + nDelta, MAP_PIXEL );
     330         [ #  # ]:          0 :         nTab = aVersionBox.GetTab(2);
     331         [ #  # ]:          0 :         aVersionBox.SetTab( 2, nTab + nDelta, MAP_PIXEL );
     332                 :            : 
     333                 :            :         // resize and move header
     334         [ #  # ]:          0 :         Size aSize = aDateTimeText.GetSizePixel();
     335                 :          0 :         aSize.Width() += nDelta;
     336         [ #  # ]:          0 :         aDateTimeText.SetSizePixel( aSize );
     337         [ #  # ]:          0 :         Point aPos = aSavedByText.GetPosPixel();
     338                 :          0 :         aPos.X() += nDelta;
     339         [ #  # ]:          0 :         aSavedByText.SetPosPixel( aPos );
     340         [ #  # ]:          0 :         aPos = aCommentText.GetPosPixel();
     341                 :          0 :         aPos.X() += nDelta;
     342         [ #  # ]:          0 :         aCommentText.SetPosPixel( aPos );
     343         [ #  # ]:          0 :     }
     344                 :          0 : }
     345                 :            : 
     346                 :          0 : IMPL_LINK_NOARG(SfxVersionDialog, DClickHdl_Impl)
     347                 :            : {
     348                 :          0 :     Open_Impl();
     349                 :          0 :     return 0L;
     350                 :            : }
     351                 :            : 
     352                 :          0 : IMPL_LINK_NOARG(SfxVersionDialog, SelectHdl_Impl)
     353                 :            : {
     354         [ #  # ]:          0 :     bool bEnable = ( aVersionBox.FirstSelected() != NULL );
     355         [ #  # ]:          0 :     SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
     356 [ #  # ][ #  # ]:          0 :     aDeleteButton.Enable( bEnable!= false && !pObjShell->IsReadOnly() );
         [ #  # ][ #  # ]
     357         [ #  # ]:          0 :     aOpenButton.Enable( bEnable!= false );
     358         [ #  # ]:          0 :     aViewButton.Enable( bEnable!= false );
     359                 :            : 
     360                 :          0 :     const SfxPoolItem *pDummy=NULL;
     361         [ #  # ]:          0 :     SfxItemState eState = pViewFrame->GetDispatcher()->QueryState( SID_DOCUMENT_MERGE, pDummy );
     362         [ #  # ]:          0 :     eState = pViewFrame->GetDispatcher()->QueryState( SID_DOCUMENT_COMPARE, pDummy );
     363 [ #  # ][ #  # ]:          0 :     aCompareButton.Enable( bEnable!= false && eState >= SFX_ITEM_AVAILABLE );
                 [ #  # ]
     364                 :            : 
     365                 :          0 :     return 0L;
     366                 :            : }
     367                 :            : 
     368                 :          0 : IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton )
     369                 :            : {
     370                 :          0 :     SfxObjectShell *pObjShell = pViewFrame->GetObjectShell();
     371                 :          0 :     SvLBoxEntry *pEntry = aVersionBox.FirstSelected();
     372                 :            : 
     373         [ #  # ]:          0 :     if ( pButton == &aSaveCheckBox )
     374                 :            :     {
     375                 :          0 :         mbIsSaveVersionOnClose = aSaveCheckBox.IsChecked();
     376                 :            :     }
     377         [ #  # ]:          0 :     else if ( pButton == &aSaveButton )
     378                 :            :     {
     379         [ #  # ]:          0 :         SfxVersionInfo aInfo;
     380 [ #  # ][ #  # ]:          0 :         aInfo.aAuthor = SvtUserOptions().GetFullName();
         [ #  # ][ #  # ]
     381 [ #  # ][ #  # ]:          0 :         SfxViewVersionDialog_Impl* pDlg = new SfxViewVersionDialog_Impl( this, aInfo, sal_True );
     382         [ #  # ]:          0 :         short nRet = pDlg->Execute();
     383         [ #  # ]:          0 :         if ( nRet == RET_OK )
     384                 :            :         {
     385         [ #  # ]:          0 :             SfxStringItem aComment( SID_DOCINFO_COMMENTS, aInfo.aComment );
     386         [ #  # ]:          0 :             pObjShell->SetModified( sal_True );
     387                 :            :             const SfxPoolItem* aItems[2];
     388                 :          0 :             aItems[0] = &aComment;
     389                 :          0 :             aItems[1] = NULL;
     390         [ #  # ]:          0 :             pViewFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, aItems, 0 );
     391         [ #  # ]:          0 :             aVersionBox.SetUpdateMode( sal_False );
     392         [ #  # ]:          0 :             aVersionBox.Clear();
     393         [ #  # ]:          0 :             Init_Impl();
     394 [ #  # ][ #  # ]:          0 :             aVersionBox.SetUpdateMode( sal_True );
     395                 :            :         }
     396                 :            : 
     397 [ #  # ][ #  # ]:          0 :         delete pDlg;
                 [ #  # ]
     398                 :            :     }
     399 [ #  # ][ #  # ]:          0 :     if ( pButton == &aDeleteButton && pEntry )
     400                 :            :     {
     401         [ #  # ]:          0 :         pObjShell->GetMedium()->RemoveVersion_Impl( ((SfxVersionInfo*) pEntry->GetUserData())->aName );
     402                 :          0 :         pObjShell->SetModified( sal_True );
     403                 :          0 :         aVersionBox.SetUpdateMode( sal_False );
     404                 :          0 :         aVersionBox.Clear();
     405                 :          0 :         Init_Impl();
     406                 :          0 :         aVersionBox.SetUpdateMode( sal_True );
     407                 :            :     }
     408 [ #  # ][ #  # ]:          0 :     else if ( pButton == &aOpenButton && pEntry )
     409                 :            :     {
     410                 :          0 :         Open_Impl();
     411                 :            :     }
     412 [ #  # ][ #  # ]:          0 :     else if ( pButton == &aViewButton && pEntry )
     413                 :            :     {
     414                 :          0 :         SfxVersionInfo* pInfo = (SfxVersionInfo*) pEntry->GetUserData();
     415         [ #  # ]:          0 :         SfxViewVersionDialog_Impl* pDlg = new SfxViewVersionDialog_Impl( this, *pInfo, sal_False );
     416                 :          0 :         pDlg->Execute();
     417         [ #  # ]:          0 :         delete pDlg;
     418                 :            :     }
     419 [ #  # ][ #  # ]:          0 :     else if ( pEntry && pButton == &aCompareButton )
     420                 :            :     {
     421         [ #  # ]:          0 :         SfxAllItemSet aSet( pObjShell->GetPool() );
     422         [ #  # ]:          0 :         sal_uIntPtr nPos = aVersionBox.GetModel()->GetRelPos( pEntry );
     423 [ #  # ][ #  # ]:          0 :         aSet.Put( SfxInt16Item( SID_VERSION, (short)nPos+1 ) );
                 [ #  # ]
     424 [ #  # ][ #  # ]:          0 :         aSet.Put( SfxStringItem( SID_FILE_NAME, pObjShell->GetMedium()->GetName() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     425                 :            : 
     426         [ #  # ]:          0 :         SfxItemSet* pSet = pObjShell->GetMedium()->GetItemSet();
     427 [ #  # ][ #  # ]:          0 :         SFX_ITEMSET_ARG( pSet, pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False );
     428 [ #  # ][ #  # ]:          0 :         SFX_ITEMSET_ARG( pSet, pFilterOptItem, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
     429         [ #  # ]:          0 :         if ( pFilterItem )
     430         [ #  # ]:          0 :             aSet.Put( *pFilterItem );
     431         [ #  # ]:          0 :         if ( pFilterOptItem )
     432         [ #  # ]:          0 :             aSet.Put( *pFilterOptItem );
     433                 :            : 
     434         [ #  # ]:          0 :         pViewFrame->GetDispatcher()->Execute( SID_DOCUMENT_COMPARE, SFX_CALLMODE_ASYNCHRON, aSet );
     435 [ #  # ][ #  # ]:          0 :         Close();
     436                 :            :     }
     437                 :            : 
     438                 :          0 :     return 0L;
     439                 :            : }
     440                 :            : 
     441                 :          0 : SfxViewVersionDialog_Impl::SfxViewVersionDialog_Impl ( Window *pParent, SfxVersionInfo& rInfo, sal_Bool bEdit )
     442                 :            :     : SfxModalDialog( pParent, SfxResId( DLG_COMMENTS ) )
     443                 :            :     , aDateTimeText( this, SfxResId( FT_DATETIME ) )
     444                 :            :     , aSavedByText( this, SfxResId( FT_SAVEDBY ) )
     445                 :            :     , aEdit( this, SfxResId( ME_VERSIONS ) )
     446                 :            :     , aOKButton( this, SfxResId( PB_OK ) )
     447                 :            :     , aCancelButton( this, SfxResId( PB_CANCEL ) )
     448                 :            :     , aCloseButton( this, SfxResId( PB_CLOSE ) )
     449                 :            :     , aHelpButton( this, SfxResId( PB_HELP ) )
     450 [ #  # ][ #  # ]:          0 :     , pInfo( &rInfo )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     451                 :            : {
     452         [ #  # ]:          0 :     FreeResource();
     453                 :            : 
     454 [ #  # ][ #  # ]:          0 :     LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
         [ #  # ][ #  # ]
     455 [ #  # ][ #  # ]:          0 :     aDateTimeText.SetText( aDateTimeText.GetText().Append(ConvertDateTime_Impl( pInfo->aCreationDate, aLocaleWrapper )) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     456 [ #  # ][ #  # ]:          0 :     aSavedByText.SetText( aSavedByText.GetText().Append(pInfo->aAuthor) );
         [ #  # ][ #  # ]
     457         [ #  # ]:          0 :     aEdit.SetText( rInfo.aComment );
     458                 :            : 
     459         [ #  # ]:          0 :     aCloseButton.SetClickHdl ( LINK( this, SfxViewVersionDialog_Impl, ButtonHdl ) );
     460         [ #  # ]:          0 :     aOKButton.SetClickHdl ( LINK( this, SfxViewVersionDialog_Impl, ButtonHdl ) );
     461                 :            : 
     462         [ #  # ]:          0 :     aEdit.GrabFocus();
     463         [ #  # ]:          0 :     if ( !bEdit )
     464                 :            :     {
     465         [ #  # ]:          0 :         aOKButton.Hide();
     466         [ #  # ]:          0 :         aCancelButton.Hide();
     467         [ #  # ]:          0 :         aEdit.SetReadOnly( sal_True );
     468 [ #  # ][ #  # ]:          0 :         SetText( SfxResId( STR_VIEWVERSIONCOMMENT ) );
         [ #  # ][ #  # ]
     469                 :            :     }
     470                 :            :     else
     471                 :            :     {
     472         [ #  # ]:          0 :         aDateTimeText.Hide();
     473         [ #  # ]:          0 :         aCloseButton.Hide();
     474         [ #  # ]:          0 :     }
     475                 :          0 : }
     476                 :            : 
     477                 :          0 : IMPL_LINK( SfxViewVersionDialog_Impl, ButtonHdl, Button*, pButton )
     478                 :            : {
     479         [ #  # ]:          0 :     if ( pButton == &aCloseButton )
     480                 :            :     {
     481                 :          0 :         EndDialog( RET_CANCEL );
     482                 :            :     }
     483         [ #  # ]:          0 :     else if ( pButton == &aOKButton )
     484                 :            :     {
     485         [ #  # ]:          0 :         pInfo->aComment = aEdit.GetText();
     486                 :          0 :         EndDialog( RET_OK );
     487                 :            :     }
     488                 :            : 
     489                 :          0 :     return 0L;
     490                 :            : }
     491                 :            : 
     492                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10