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

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <vcl/svapp.hxx>
      30                 :            : #include <sfx2/filedlghelper.hxx>
      31                 :            : #include <svl/zforlist.hxx>
      32                 :            : #include "optupdt.hxx"
      33                 :            : #include "optupdt.hrc"
      34                 :            : #include <dialmgr.hxx>
      35                 :            : #include <cuires.hrc>
      36                 :            : #include <comphelper/componentcontext.hxx>
      37                 :            : #include <comphelper/processfactory.hxx>
      38                 :            : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      39                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      40                 :            : #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
      41                 :            : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      42                 :            : #include <com/sun/star/frame/XDesktop.hpp>
      43                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      44                 :            : #include <com/sun/star/util/XChangesBatch.hpp>
      45                 :            : #include <com/sun/star/util/URLTransformer.hpp>
      46                 :            : #include <com/sun/star/util/XURLTransformer.hpp>
      47                 :            : #include <osl/file.hxx>
      48                 :            : #include <osl/security.hxx>
      49                 :            : 
      50                 :            : namespace beans = ::com::sun::star::beans;
      51                 :            : namespace container = ::com::sun::star::container;
      52                 :            : namespace dialogs = ::com::sun::star::ui::dialogs;
      53                 :            : namespace frame = ::com::sun::star::frame;
      54                 :            : namespace lang = ::com::sun::star::lang;
      55                 :            : namespace uno = ::com::sun::star::uno;
      56                 :            : namespace util = ::com::sun::star::util;
      57                 :            : 
      58                 :            : // define ----------------------------------------------------------------
      59                 :            : 
      60                 :            : #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
      61                 :            : 
      62                 :            : // class SvxOnlineUpdateTabPage --------------------------------------------------
      63                 :            : 
      64                 :          0 : SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage( Window* pParent, const SfxItemSet& rSet ) :
      65                 :            : 
      66                 :          0 :     SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_ONLINEUPDATE ), rSet ),
      67         [ #  # ]:          0 :         m_aOptionsLine( this, CUI_RES( FL_OPTIONS ) ),
      68         [ #  # ]:          0 :         m_aAutoCheckCheckBox( this, CUI_RES( CB_AUTOCHECK ) ),
      69         [ #  # ]:          0 :         m_aEveryDayButton( this, CUI_RES( RB_EVERYDAY ) ),
      70         [ #  # ]:          0 :         m_aEveryWeekButton( this, CUI_RES( RB_EVERYWEEK ) ),
      71         [ #  # ]:          0 :         m_aEveryMonthButton( this, CUI_RES( RB_EVERYMONTH ) ),
      72         [ #  # ]:          0 :         m_aCheckNowButton( this, CUI_RES( PB_CHECKNOW ) ),
      73         [ #  # ]:          0 :         m_aAutoDownloadCheckBox( this, CUI_RES( CB_AUTODOWNLOAD ) ),
      74         [ #  # ]:          0 :         m_aDestPathLabel( this, CUI_RES( FT_DESTPATHLABEL ) ),
      75         [ #  # ]:          0 :         m_aDestPath( this, CUI_RES( FT_DESTPATH ) ),
      76         [ #  # ]:          0 :         m_aChangePathButton( this, CUI_RES( PB_CHANGEPATH ) ),
      77 [ #  # ][ #  # ]:          0 :         m_aLastChecked( this, CUI_RES( FT_LASTCHECKED ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      78                 :            : {
      79 [ #  # ][ #  # ]:          0 :     m_aNeverChecked = String( CUI_RES( STR_NEVERCHECKED ) );
         [ #  # ][ #  # ]
      80         [ #  # ]:          0 :     FreeResource();
      81                 :            : 
      82         [ #  # ]:          0 :     m_aAutoCheckCheckBox.SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, AutoCheckHdl_Impl ) );
      83         [ #  # ]:          0 :     m_aCheckNowButton.SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, CheckNowHdl_Impl ) );
      84         [ #  # ]:          0 :     m_aChangePathButton.SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, FileDialogHdl_Impl ) );
      85                 :            : 
      86         [ #  # ]:          0 :     uno::Reference < lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
      87                 :            : 
      88                 :            :     m_xUpdateAccess = uno::Reference < container::XNameReplace >(
      89         [ #  # ]:          0 :         xFactory->createInstance( UNISTRING( "com.sun.star.setup.UpdateCheckConfig" ) ),
      90 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY_THROW );
         [ #  # ][ #  # ]
      91                 :            : 
      92                 :          0 :     sal_Bool bDownloadSupported = sal_False;
      93 [ #  # ][ #  # ]:          0 :     m_xUpdateAccess->getByName( UNISTRING( "DownloadSupported") ) >>= bDownloadSupported;
                 [ #  # ]
      94                 :            : 
      95         [ #  # ]:          0 :     WinBits nStyle = m_aDestPath.GetStyle();
      96                 :          0 :     nStyle |= WB_PATHELLIPSIS;
      97         [ #  # ]:          0 :     m_aDestPath.SetStyle(nStyle);
      98                 :            : 
      99         [ #  # ]:          0 :     m_aAutoDownloadCheckBox.Show(bDownloadSupported);
     100         [ #  # ]:          0 :     m_aDestPathLabel.Show(bDownloadSupported);
     101         [ #  # ]:          0 :     m_aDestPath.Show(bDownloadSupported);
     102         [ #  # ]:          0 :     m_aChangePathButton.Show(bDownloadSupported);
     103                 :            : 
     104                 :            :     // dynamical length of the PushButtons
     105         [ #  # ]:          0 :     CalcButtonWidth();
     106                 :            : 
     107 [ #  # ][ #  # ]:          0 :     m_aLastCheckedTemplate = m_aLastChecked.GetText();
                 [ #  # ]
     108                 :            : 
     109         [ #  # ]:          0 :     UpdateLastCheckedText();
     110                 :          0 : }
     111                 :            : 
     112                 :            : // -----------------------------------------------------------------------
     113                 :            : 
     114 [ #  # ][ #  # ]:          0 : SvxOnlineUpdateTabPage::~SvxOnlineUpdateTabPage()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     115                 :            : {
     116         [ #  # ]:          0 : }
     117                 :            : 
     118                 :            : // -----------------------------------------------------------------------
     119                 :          0 : void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
     120                 :            : {
     121                 :          0 :     rtl::OUString aDateStr;
     122                 :          0 :     rtl::OUString aTimeStr;
     123                 :          0 :     rtl::OUString aText;
     124                 :          0 :     sal_Int64 lastChecked = 0;
     125                 :            : 
     126 [ #  # ][ #  # ]:          0 :     m_xUpdateAccess->getByName( UNISTRING( "LastCheck") ) >>= lastChecked;
                 [ #  # ]
     127                 :            : 
     128         [ #  # ]:          0 :     if( lastChecked == 0 ) // never checked
     129                 :            :     {
     130                 :          0 :         aText = m_aNeverChecked;
     131                 :            :     }
     132                 :            :     else
     133                 :            :     {
     134                 :            :         TimeValue   lastCheckedTV;
     135                 :            :         oslDateTime lastCheckedDT;
     136                 :            : 
     137                 :          0 :         Date  aDate( Date::EMPTY );
     138                 :          0 :         Time  aTime( Time::EMPTY );
     139                 :            : 
     140                 :          0 :         lastCheckedTV.Seconds = (sal_uInt32) lastChecked;
     141         [ #  # ]:          0 :         osl_getLocalTimeFromSystemTime( &lastCheckedTV, &lastCheckedTV );
     142                 :            : 
     143 [ #  # ][ #  # ]:          0 :         if ( osl_getDateTimeFromTimeValue(  &lastCheckedTV, &lastCheckedDT ) )
     144                 :            :         {
     145                 :          0 :             aDate = Date( lastCheckedDT.Day, lastCheckedDT.Month, lastCheckedDT.Year );
     146 [ #  # ][ #  # ]:          0 :             aTime = Time( lastCheckedDT.Hours, lastCheckedDT.Minutes );
     147                 :            :         }
     148                 :            : 
     149 [ #  # ][ #  # ]:          0 :         LanguageType eUILang = Application::GetSettings().GetUILanguage();
     150 [ #  # ][ #  # ]:          0 :         SvNumberFormatter *pNumberFormatter = new SvNumberFormatter( ::comphelper::getProcessServiceFactory(), eUILang );
                 [ #  # ]
     151         [ #  # ]:          0 :         String      aTmpStr;
     152                 :          0 :         Color*      pColor = NULL;
     153         [ #  # ]:          0 :         Date*       pNullDate = pNumberFormatter->GetNullDate();
     154         [ #  # ]:          0 :         sal_uInt32  nFormat = pNumberFormatter->GetStandardFormat( NUMBERFORMAT_DATE, eUILang );
     155                 :            : 
     156 [ #  # ][ #  # ]:          0 :         pNumberFormatter->GetOutputString( aDate - *pNullDate, nFormat, aTmpStr, &pColor );
     157         [ #  # ]:          0 :         aDateStr = aTmpStr;
     158                 :            : 
     159         [ #  # ]:          0 :         nFormat = pNumberFormatter->GetStandardFormat( NUMBERFORMAT_TIME, eUILang );
     160 [ #  # ][ #  # ]:          0 :         pNumberFormatter->GetOutputString( aTime.GetTimeInDays(), nFormat, aTmpStr, &pColor );
     161         [ #  # ]:          0 :         aTimeStr = aTmpStr;
     162                 :            : 
     163                 :          0 :         delete pColor;
     164 [ #  # ][ #  # ]:          0 :         delete pNumberFormatter;
     165                 :            : 
     166                 :          0 :         aText = m_aLastCheckedTemplate;
     167         [ #  # ]:          0 :         sal_Int32 nIndex = aText.indexOf( UNISTRING( "%DATE%" ) );
     168         [ #  # ]:          0 :         if ( nIndex != -1 )
     169                 :          0 :             aText = aText.replaceAt( nIndex, 6, aDateStr );
     170                 :            : 
     171         [ #  # ]:          0 :         nIndex = aText.indexOf( UNISTRING( "%TIME%" ) );
     172         [ #  # ]:          0 :         if ( nIndex != -1 )
     173         [ #  # ]:          0 :             aText = aText.replaceAt( nIndex, 6, aTimeStr );
     174                 :            :     }
     175                 :            : 
     176 [ #  # ][ #  # ]:          0 :     m_aLastChecked.SetText( aText );
                 [ #  # ]
     177                 :          0 : }
     178                 :            : 
     179                 :            : // -----------------------------------------------------------------------
     180                 :            : 
     181                 :            : SfxTabPage*
     182                 :          0 : SvxOnlineUpdateTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
     183                 :            : {
     184         [ #  # ]:          0 :     return new SvxOnlineUpdateTabPage( pParent, rAttrSet );
     185                 :            : }
     186                 :            : 
     187                 :            : // -----------------------------------------------------------------------
     188                 :            : 
     189                 :            : 
     190                 :          0 : sal_Bool SvxOnlineUpdateTabPage::FillItemSet( SfxItemSet& )
     191                 :            : {
     192                 :          0 :     sal_Bool bModified = sal_False;
     193                 :            : 
     194                 :            :     sal_Bool bValue;
     195                 :            :     sal_Int64 nValue;
     196                 :            : 
     197 [ #  # ][ #  # ]:          0 :     if( m_aAutoCheckCheckBox.GetSavedValue() != m_aAutoCheckCheckBox.IsChecked() )
     198                 :            :     {
     199         [ #  # ]:          0 :         bValue = (sal_True == m_aAutoCheckCheckBox.IsChecked());
     200 [ #  # ][ #  # ]:          0 :         m_xUpdateAccess->replaceByName( UNISTRING("AutoCheckEnabled"), uno::makeAny( bValue ) );
         [ #  # ][ #  # ]
     201                 :          0 :         bModified = sal_True;
     202                 :            :     }
     203                 :            : 
     204                 :          0 :     nValue = 0;
     205         [ #  # ]:          0 :     if( sal_True == m_aEveryDayButton.IsChecked() )
     206                 :            :     {
     207         [ #  # ]:          0 :         if( sal_False == m_aEveryDayButton.GetSavedValue() )
     208                 :          0 :             nValue = 86400;
     209                 :            :     }
     210         [ #  # ]:          0 :     else if( sal_True == m_aEveryWeekButton.IsChecked() )
     211                 :            :     {
     212         [ #  # ]:          0 :         if( sal_False == m_aEveryWeekButton.GetSavedValue() )
     213                 :          0 :             nValue = 604800;
     214                 :            :     }
     215         [ #  # ]:          0 :     else if( sal_True == m_aEveryMonthButton.IsChecked() )
     216                 :            :     {
     217         [ #  # ]:          0 :         if( sal_False == m_aEveryMonthButton.GetSavedValue() )
     218                 :          0 :             nValue = 2592000;
     219                 :            :     }
     220                 :            : 
     221         [ #  # ]:          0 :     if( nValue > 0 )
     222                 :            :     {
     223 [ #  # ][ #  # ]:          0 :         m_xUpdateAccess->replaceByName( UNISTRING("CheckInterval"), uno::makeAny( nValue ) );
         [ #  # ][ #  # ]
     224                 :          0 :         bModified = sal_True;
     225                 :            :     }
     226                 :            : 
     227 [ #  # ][ #  # ]:          0 :     if( m_aAutoDownloadCheckBox.GetSavedValue() != m_aAutoDownloadCheckBox.IsChecked() )
     228                 :            :     {
     229         [ #  # ]:          0 :         bValue = (sal_True == m_aAutoDownloadCheckBox.IsChecked());
     230 [ #  # ][ #  # ]:          0 :         m_xUpdateAccess->replaceByName( UNISTRING("AutoDownloadEnabled"), uno::makeAny( bValue ) );
         [ #  # ][ #  # ]
     231                 :          0 :         bModified = sal_True;
     232                 :            :     }
     233                 :            : 
     234                 :          0 :     rtl::OUString sValue, aURL;
     235 [ #  # ][ #  # ]:          0 :     m_xUpdateAccess->getByName( UNISTRING("DownloadDestination") ) >>= sValue;
                 [ #  # ]
     236                 :            : 
     237 [ #  # ][ #  # ]:          0 :     if( ( osl::FileBase::E_None == osl::FileBase::getFileURLFromSystemPath(m_aDestPath.GetText(), aURL) ) &&
           [ #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
                 [ #  # ]
     238                 :          0 :         ( ! aURL.equals( sValue ) ) )
     239                 :            :     {
     240 [ #  # ][ #  # ]:          0 :         m_xUpdateAccess->replaceByName( UNISTRING("DownloadDestination"), uno::makeAny( aURL ) );
         [ #  # ][ #  # ]
     241                 :          0 :         bModified = sal_True;
     242                 :            :     }
     243                 :            : 
     244         [ #  # ]:          0 :     uno::Reference< util::XChangesBatch > xChangesBatch(m_xUpdateAccess, uno::UNO_QUERY);
     245 [ #  # ][ #  # ]:          0 :     if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
         [ #  # ][ #  # ]
                 [ #  # ]
     246 [ #  # ][ #  # ]:          0 :         xChangesBatch->commitChanges();
     247                 :            : 
     248                 :          0 :     return bModified;
     249                 :            : }
     250                 :            : 
     251                 :            : // -----------------------------------------------------------------------
     252                 :            : 
     253                 :          0 : void SvxOnlineUpdateTabPage::Reset( const SfxItemSet& )
     254                 :            : {
     255                 :          0 :     sal_Bool bValue = sal_Bool();
     256 [ #  # ][ #  # ]:          0 :     m_xUpdateAccess->getByName( UNISTRING("AutoCheckEnabled") ) >>= bValue;
                 [ #  # ]
     257                 :            : 
     258         [ #  # ]:          0 :     m_aAutoCheckCheckBox.Check(bValue);
     259         [ #  # ]:          0 :     m_aEveryDayButton.Enable(bValue);
     260         [ #  # ]:          0 :     m_aEveryWeekButton.Enable(bValue);
     261         [ #  # ]:          0 :     m_aEveryMonthButton.Enable(bValue);
     262                 :            : 
     263                 :          0 :     sal_Int64 nValue = 0;
     264 [ #  # ][ #  # ]:          0 :     m_xUpdateAccess->getByName( UNISTRING("CheckInterval") ) >>= nValue;
                 [ #  # ]
     265                 :            : 
     266         [ #  # ]:          0 :     if( nValue == 86400 )
     267         [ #  # ]:          0 :         m_aEveryDayButton.Check();
     268         [ #  # ]:          0 :     else if( nValue == 604800 )
     269         [ #  # ]:          0 :         m_aEveryWeekButton.Check();
     270                 :            :     else
     271         [ #  # ]:          0 :         m_aEveryMonthButton.Check();
     272                 :            : 
     273                 :          0 :     m_aAutoCheckCheckBox.SaveValue();
     274                 :          0 :     m_aEveryDayButton.SaveValue();
     275                 :          0 :     m_aEveryWeekButton.SaveValue();
     276                 :          0 :     m_aEveryMonthButton.SaveValue();
     277                 :            : 
     278 [ #  # ][ #  # ]:          0 :     m_xUpdateAccess->getByName( UNISTRING("AutoDownloadEnabled") ) >>= bValue;
                 [ #  # ]
     279         [ #  # ]:          0 :     m_aAutoDownloadCheckBox.Check(bValue);
     280         [ #  # ]:          0 :     m_aDestPathLabel.Enable(sal_True);
     281         [ #  # ]:          0 :     m_aDestPath.Enable(sal_True);
     282         [ #  # ]:          0 :     m_aChangePathButton.Enable(sal_True);
     283                 :            : 
     284                 :          0 :     rtl::OUString sValue, aPath;
     285 [ #  # ][ #  # ]:          0 :     m_xUpdateAccess->getByName( UNISTRING("DownloadDestination") ) >>= sValue;
                 [ #  # ]
     286                 :            : 
     287 [ #  # ][ #  # ]:          0 :     if( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(sValue, aPath) )
     288 [ #  # ][ #  # ]:          0 :         m_aDestPath.SetText(aPath);
                 [ #  # ]
     289                 :            : 
     290                 :          0 :     m_aAutoDownloadCheckBox.SaveValue();
     291                 :          0 : }
     292                 :            : 
     293                 :            : // -----------------------------------------------------------------------
     294                 :            : 
     295                 :          0 : void SvxOnlineUpdateTabPage::FillUserData()
     296                 :            : {
     297                 :          0 : }
     298                 :            : 
     299                 :            : // -----------------------------------------------------------------------
     300                 :            : 
     301                 :          0 : IMPL_LINK( SvxOnlineUpdateTabPage, AutoCheckHdl_Impl, CheckBox *, pBox )
     302                 :            : {
     303                 :          0 :     sal_Bool bEnabled = pBox->IsChecked();
     304                 :            : 
     305                 :          0 :     m_aEveryDayButton.Enable(bEnabled);
     306                 :          0 :     m_aEveryWeekButton.Enable(bEnabled);
     307                 :          0 :     m_aEveryMonthButton.Enable(bEnabled);
     308                 :            : 
     309                 :          0 :     return 0;
     310                 :            : }
     311                 :            : 
     312                 :            : // -----------------------------------------------------------------------
     313                 :            : 
     314                 :          0 : IMPL_LINK_NOARG(SvxOnlineUpdateTabPage, FileDialogHdl_Impl)
     315                 :            : {
     316         [ #  # ]:          0 :     uno::Reference < lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
     317                 :            :     uno::Reference < dialogs::XFolderPicker > xFolderPicker(
     318         [ #  # ]:          0 :         xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( FOLDER_PICKER_SERVICE_NAME ) ) ),
     319 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY );
                 [ #  # ]
     320                 :            : 
     321                 :          0 :     rtl::OUString aURL;
     322 [ #  # ][ #  # ]:          0 :     if( osl::FileBase::E_None != osl::FileBase::getFileURLFromSystemPath(m_aDestPath.GetText(), aURL) )
         [ #  # ][ #  # ]
                 [ #  # ]
     323 [ #  # ][ #  # ]:          0 :         osl::Security().getHomeDir(aURL);
                 [ #  # ]
     324                 :            : 
     325 [ #  # ][ #  # ]:          0 :     xFolderPicker->setDisplayDirectory( aURL );
     326 [ #  # ][ #  # ]:          0 :     sal_Int16 nRet = xFolderPicker->execute();
     327                 :            : 
     328         [ #  # ]:          0 :     if ( dialogs::ExecutableDialogResults::OK == nRet )
     329                 :            :     {
     330                 :          0 :         rtl::OUString aFolder;
     331 [ #  # ][ #  # ]:          0 :         if( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(xFolderPicker->getDirectory(), aFolder))
         [ #  # ][ #  # ]
     332 [ #  # ][ #  # ]:          0 :             m_aDestPath.SetText( aFolder );
                 [ #  # ]
     333                 :            :     }
     334                 :            : 
     335                 :          0 :     return 0;
     336                 :            : }
     337                 :            : 
     338                 :            : // -----------------------------------------------------------------------
     339                 :            : 
     340                 :          0 : IMPL_LINK_NOARG(SvxOnlineUpdateTabPage, CheckNowHdl_Impl)
     341                 :            : {
     342         [ #  # ]:          0 :     uno::Reference < lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
     343                 :            : 
     344                 :            :     try
     345                 :            :     {
     346                 :            :         uno::Reference< lang::XMultiServiceFactory > xConfigProvider(
     347                 :            :             com::sun::star::configuration::theDefaultProvider::get(
     348 [ #  # ][ #  # ]:          0 :                 comphelper::getProcessComponentContext() ) );
     349                 :            : 
     350                 :          0 :         beans::NamedValue aProperty;
     351         [ #  # ]:          0 :         aProperty.Name  = UNISTRING( "nodepath" );
     352 [ #  # ][ #  # ]:          0 :         aProperty.Value = uno::makeAny( UNISTRING("org.openoffice.Office.Addons/AddonUI/OfficeHelp/UpdateCheckJob") );
     353                 :            : 
     354         [ #  # ]:          0 :         uno::Sequence< uno::Any > aArgumentList( 1 );
     355 [ #  # ][ #  # ]:          0 :         aArgumentList[0] = uno::makeAny( aProperty );
     356                 :            : 
     357                 :            :         uno::Reference< container::XNameAccess > xNameAccess(
     358         [ #  # ]:          0 :             xConfigProvider->createInstanceWithArguments(
     359                 :          0 :                 UNISTRING("com.sun.star.configuration.ConfigurationAccess"), aArgumentList ),
     360 [ #  # ][ #  # ]:          0 :             uno::UNO_QUERY_THROW );
                 [ #  # ]
     361                 :            : 
     362                 :          0 :         util::URL aURL;
     363 [ #  # ][ #  # ]:          0 :         xNameAccess->getByName(UNISTRING("URL")) >>= aURL.Complete;
                 [ #  # ]
     364                 :            : 
     365                 :            :         uno::Reference < util::XURLTransformer > xTransformer(
     366 [ #  # ][ #  # ]:          0 :             util::URLTransformer::create( comphelper::getProcessComponentContext() ) );
     367                 :            : 
     368 [ #  # ][ #  # ]:          0 :         xTransformer->parseStrict(aURL);
     369                 :            : 
     370                 :            :         uno::Reference < frame::XDesktop > xDesktop(
     371         [ #  # ]:          0 :             xFactory->createInstance(  UNISTRING( "com.sun.star.frame.Desktop" ) ),
     372 [ #  # ][ #  # ]:          0 :             uno::UNO_QUERY_THROW );
                 [ #  # ]
     373                 :            : 
     374                 :            :         uno::Reference< frame::XDispatchProvider > xDispatchProvider(
     375 [ #  # ][ #  # ]:          0 :             xDesktop->getCurrentFrame(), uno::UNO_QUERY );
                 [ #  # ]
     376                 :            : 
     377 [ #  # ][ #  # ]:          0 :         uno::Reference< frame::XDispatch > xDispatch = xDispatchProvider->queryDispatch(aURL, rtl::OUString(), 0);
     378                 :            : 
     379         [ #  # ]:          0 :         if( xDispatch.is() )
     380                 :            :         {
     381 [ #  # ][ #  # ]:          0 :             xDispatch->dispatch(aURL, uno::Sequence< beans::PropertyValue > ());
         [ #  # ][ #  # ]
     382         [ #  # ]:          0 :             UpdateLastCheckedText();
     383 [ #  # ][ #  # ]:          0 :         }
     384                 :            :     }
     385         [ #  # ]:          0 :     catch( const uno::Exception& e )
     386                 :            :     {
     387                 :            :          OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
     388                 :            :             rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
     389                 :            :     }
     390                 :            : 
     391                 :          0 :     return 0;
     392                 :            : }
     393                 :            : 
     394                 :          0 : void SvxOnlineUpdateTabPage::CalcButtonWidth()
     395                 :            : {
     396                 :            :     // detect the longest button text
     397 [ #  # ][ #  # ]:          0 :     long nTxtWidth = ::std::max( m_aCheckNowButton.GetCtrlTextWidth( m_aCheckNowButton.GetText() ),
                 [ #  # ]
     398 [ #  # ][ #  # ]:          0 :                                  m_aCheckNowButton.GetCtrlTextWidth( m_aChangePathButton.GetText() ) );
         [ #  # ][ #  # ]
     399                 :            :     // add a little offset
     400                 :          0 :     nTxtWidth = nTxtWidth + 12;
     401                 :            :     // compare with the button width
     402         [ #  # ]:          0 :     Size aSize = m_aCheckNowButton.GetSizePixel();
     403                 :            :     // and change it if it's necessary
     404         [ #  # ]:          0 :     if ( nTxtWidth > aSize.Width() )
     405                 :            :     {
     406                 :          0 :         aSize.Width() = nTxtWidth;
     407         [ #  # ]:          0 :         m_aCheckNowButton.SetSizePixel( aSize );
     408         [ #  # ]:          0 :         m_aChangePathButton.SetSizePixel( aSize );
     409                 :            :     }
     410                 :          0 : }
     411                 :            : 
     412                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10