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