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