xref: /aoo41x/main/cui/source/options/webconninfo.cxx (revision 2ee96f1c)
1*2ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2ee96f1cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2ee96f1cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2ee96f1cSAndrew Rist  * distributed with this work for additional information
6*2ee96f1cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2ee96f1cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2ee96f1cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2ee96f1cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2ee96f1cSAndrew Rist  *
11*2ee96f1cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2ee96f1cSAndrew Rist  *
13*2ee96f1cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2ee96f1cSAndrew Rist  * software distributed under the License is distributed on an
15*2ee96f1cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2ee96f1cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2ee96f1cSAndrew Rist  * specific language governing permissions and limitations
18*2ee96f1cSAndrew Rist  * under the License.
19*2ee96f1cSAndrew Rist  *
20*2ee96f1cSAndrew Rist  *************************************************************/
21*2ee96f1cSAndrew Rist 
22*2ee96f1cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir #include <dialmgr.hxx>
29cdf0e10cSrcweir #include <cuires.hrc>
30cdf0e10cSrcweir #include <com/sun/star/task/UrlRecord.hpp>
31cdf0e10cSrcweir #include <com/sun/star/task/XPasswordContainer.hpp>
32cdf0e10cSrcweir #include <com/sun/star/task/XMasterPasswordHandling.hpp>
33cdf0e10cSrcweir #include "com/sun/star/task/XUrlContainer.hpp"
34cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
35cdf0e10cSrcweir #include <comphelper/docpasswordrequest.hxx>
36cdf0e10cSrcweir #include "webconninfo.hxx"
37cdf0e10cSrcweir #include "webconninfo.hrc"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir using namespace ::com::sun::star;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir //........................................................................
42cdf0e10cSrcweir namespace svx
43cdf0e10cSrcweir {
44cdf0e10cSrcweir //........................................................................
45cdf0e10cSrcweir 
46cdf0e10cSrcweir // class PasswordTable ---------------------------------------------------
47cdf0e10cSrcweir 
PasswordTable(Window * pParent,const ResId & rResId)48cdf0e10cSrcweir PasswordTable::PasswordTable( Window* pParent, const ResId& rResId ) :
49cdf0e10cSrcweir     SvxSimpleTable( pParent, rResId )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir     SetStyle( GetStyle() | WB_NOINITIALSELECTION );
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
InsertHeaderItem(sal_uInt16 nColumn,const String & rText,HeaderBarItemBits nBits)54cdf0e10cSrcweir void PasswordTable::InsertHeaderItem( sal_uInt16 nColumn, const String& rText, HeaderBarItemBits nBits )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir     GetTheHeaderBar()->InsertItem( nColumn, rText, 0, nBits );
57cdf0e10cSrcweir }
58cdf0e10cSrcweir 
ResetTabs()59cdf0e10cSrcweir void PasswordTable::ResetTabs()
60cdf0e10cSrcweir {
61cdf0e10cSrcweir     SetTabs();
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
Resort(bool bForced)64cdf0e10cSrcweir void PasswordTable::Resort( bool bForced )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     sal_uInt16 nColumn = GetSelectedCol();
67cdf0e10cSrcweir     if ( 0 == nColumn || bForced ) // only the first column is sorted
68cdf0e10cSrcweir     {
69cdf0e10cSrcweir         HeaderBarItemBits nBits = GetTheHeaderBar()->GetItemBits(1);
70cdf0e10cSrcweir         sal_Bool bUp = ( ( nBits & HIB_UPARROW ) == HIB_UPARROW );
71cdf0e10cSrcweir         SvSortMode eMode = SortAscending;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         if ( bUp )
74cdf0e10cSrcweir         {
75cdf0e10cSrcweir             nBits &= ~HIB_UPARROW;
76cdf0e10cSrcweir             nBits |= HIB_DOWNARROW;
77cdf0e10cSrcweir             eMode = SortDescending;
78cdf0e10cSrcweir         }
79cdf0e10cSrcweir         else
80cdf0e10cSrcweir         {
81cdf0e10cSrcweir             nBits &= ~HIB_DOWNARROW;
82cdf0e10cSrcweir             nBits |= HIB_UPARROW;
83cdf0e10cSrcweir         }
84cdf0e10cSrcweir         GetTheHeaderBar()->SetItemBits( 1, nBits );
85cdf0e10cSrcweir         SvTreeList* pListModel = GetModel();
86cdf0e10cSrcweir         pListModel->SetSortMode( eMode );
87cdf0e10cSrcweir         pListModel->Resort();
88cdf0e10cSrcweir     }
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir // class WebConnectionInfoDialog -----------------------------------------
92cdf0e10cSrcweir 
93cdf0e10cSrcweir // -----------------------------------------------------------------------
WebConnectionInfoDialog(Window * pParent)94cdf0e10cSrcweir WebConnectionInfoDialog::WebConnectionInfoDialog( Window* pParent ) :
95cdf0e10cSrcweir      ModalDialog( pParent, CUI_RES( RID_SVXDLG_WEBCONNECTION_INFO ) )
96cdf0e10cSrcweir     ,m_aNeverShownFI    ( this, CUI_RES( FI_NEVERSHOWN ) )
97cdf0e10cSrcweir     ,m_aPasswordsLB     ( this, CUI_RES( LB_PASSWORDS ) )
98cdf0e10cSrcweir     ,m_aRemoveBtn       ( this, CUI_RES( PB_REMOVE ) )
99cdf0e10cSrcweir     ,m_aRemoveAllBtn    ( this, CUI_RES( PB_REMOVEALL ) )
100cdf0e10cSrcweir     ,m_aChangeBtn       ( this, CUI_RES( PB_CHANGE ) )
101cdf0e10cSrcweir     ,m_aButtonsFL       ( this, CUI_RES( FL_BUTTONS ) )
102cdf0e10cSrcweir     ,m_aCloseBtn        ( this, CUI_RES( PB_CLOSE ) )
103cdf0e10cSrcweir     ,m_aHelpBtn         ( this, CUI_RES( PB_HELP ) )
104cdf0e10cSrcweir     ,m_nPos             ( -1 )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     static long aStaticTabs[]= { 3, 0, 150, 250 };
107cdf0e10cSrcweir     m_aPasswordsLB.SetTabs( aStaticTabs );
108cdf0e10cSrcweir     m_aPasswordsLB.InsertHeaderItem( 1, CUI_RESSTR( STR_WEBSITE ),
109cdf0e10cSrcweir         HIB_LEFT | HIB_VCENTER | HIB_FIXEDPOS | HIB_CLICKABLE | HIB_UPARROW );
110cdf0e10cSrcweir     m_aPasswordsLB.InsertHeaderItem( 2, CUI_RESSTR( STR_USERNAME ),
111cdf0e10cSrcweir         HIB_LEFT | HIB_VCENTER | HIB_FIXEDPOS );
112cdf0e10cSrcweir     m_aPasswordsLB.ResetTabs();
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     FreeResource();
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     m_aPasswordsLB.SetHeaderBarClickHdl( LINK( this, WebConnectionInfoDialog, HeaderBarClickedHdl ) );
117cdf0e10cSrcweir     m_aRemoveBtn.SetClickHdl( LINK( this, WebConnectionInfoDialog, RemovePasswordHdl ) );
118cdf0e10cSrcweir     m_aRemoveAllBtn.SetClickHdl( LINK( this, WebConnectionInfoDialog, RemoveAllPasswordsHdl ) );
119cdf0e10cSrcweir     m_aChangeBtn.SetClickHdl( LINK( this, WebConnectionInfoDialog, ChangePasswordHdl ) );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     // one button too small for its text?
122cdf0e10cSrcweir     sal_Int32 i = 0;
123cdf0e10cSrcweir     long nBtnTextWidth = 0;
124cdf0e10cSrcweir     Window* pButtons[] = { &m_aRemoveBtn, &m_aRemoveAllBtn, &m_aChangeBtn };
125cdf0e10cSrcweir     Window** pButton = pButtons;
126cdf0e10cSrcweir     const sal_Int32 nBCount = sizeof( pButtons ) / sizeof( pButtons[ 0 ] );
127cdf0e10cSrcweir     for ( ; i < nBCount; ++i, ++pButton )
128cdf0e10cSrcweir     {
129cdf0e10cSrcweir         long nTemp = (*pButton)->GetCtrlTextWidth( (*pButton)->GetText() );
130cdf0e10cSrcweir         if ( nTemp > nBtnTextWidth )
131cdf0e10cSrcweir             nBtnTextWidth = nTemp;
132cdf0e10cSrcweir     }
133cdf0e10cSrcweir     nBtnTextWidth = nBtnTextWidth * 115 / 100; // a little offset
134cdf0e10cSrcweir     long nButtonWidth = m_aRemoveBtn.GetSizePixel().Width();
135cdf0e10cSrcweir     if ( nBtnTextWidth > nButtonWidth )
136cdf0e10cSrcweir     {
137cdf0e10cSrcweir         // so make the buttons broader and its control in front of it smaller
138cdf0e10cSrcweir         long nDelta = nBtnTextWidth - nButtonWidth;
139cdf0e10cSrcweir         pButton = pButtons;
140cdf0e10cSrcweir         for ( i = 0; i < nBCount; ++i, ++pButton )
141cdf0e10cSrcweir         {
142cdf0e10cSrcweir             Point aNewPos = (*pButton)->GetPosPixel();
143cdf0e10cSrcweir             if ( &m_aRemoveAllBtn == (*pButton) )
144cdf0e10cSrcweir                 aNewPos.X() += nDelta;
145cdf0e10cSrcweir             else if ( &m_aChangeBtn == (*pButton) )
146cdf0e10cSrcweir                 aNewPos.X() -= nDelta;
147cdf0e10cSrcweir             Size aNewSize = (*pButton)->GetSizePixel();
148cdf0e10cSrcweir             aNewSize.Width() += nDelta;
149cdf0e10cSrcweir             (*pButton)->SetPosSizePixel( aNewPos, aNewSize );
150cdf0e10cSrcweir         }
151cdf0e10cSrcweir     }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     FillPasswordList();
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     m_aRemoveBtn.SetClickHdl( LINK( this, WebConnectionInfoDialog, RemovePasswordHdl ) );
156cdf0e10cSrcweir     m_aRemoveAllBtn.SetClickHdl( LINK( this, WebConnectionInfoDialog, RemoveAllPasswordsHdl ) );
157cdf0e10cSrcweir     m_aChangeBtn.SetClickHdl( LINK( this, WebConnectionInfoDialog, ChangePasswordHdl ) );
158cdf0e10cSrcweir     m_aPasswordsLB.SetSelectHdl( LINK( this, WebConnectionInfoDialog, EntrySelectedHdl ) );
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     m_aRemoveBtn.Enable( sal_False );
161cdf0e10cSrcweir     m_aChangeBtn.Enable( sal_False );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     HeaderBarClickedHdl( NULL );
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir // -----------------------------------------------------------------------
~WebConnectionInfoDialog()167cdf0e10cSrcweir WebConnectionInfoDialog::~WebConnectionInfoDialog()
168cdf0e10cSrcweir {
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir // -----------------------------------------------------------------------
IMPL_LINK(WebConnectionInfoDialog,HeaderBarClickedHdl,SvxSimpleTable *,pTable)172cdf0e10cSrcweir IMPL_LINK( WebConnectionInfoDialog, HeaderBarClickedHdl, SvxSimpleTable*, pTable )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir     m_aPasswordsLB.Resort( NULL == pTable );
175cdf0e10cSrcweir     return 0;
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir // -----------------------------------------------------------------------
FillPasswordList()179cdf0e10cSrcweir void WebConnectionInfoDialog::FillPasswordList()
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     try
182cdf0e10cSrcweir     {
183cdf0e10cSrcweir         uno::Reference< task::XMasterPasswordHandling > xMasterPasswd(
184cdf0e10cSrcweir             comphelper::getProcessServiceFactory()->createInstance(
185cdf0e10cSrcweir                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ),
186cdf0e10cSrcweir             uno::UNO_QUERY );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir         if ( xMasterPasswd.is() && xMasterPasswd->isPersistentStoringAllowed() )
189cdf0e10cSrcweir         {
190cdf0e10cSrcweir             uno::Reference< task::XPasswordContainer > xPasswdContainer( xMasterPasswd, uno::UNO_QUERY_THROW );
191cdf0e10cSrcweir             uno::Reference< task::XInteractionHandler > xInteractionHandler(
192cdf0e10cSrcweir                 comphelper::getProcessServiceFactory()->createInstance(
193cdf0e10cSrcweir                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.InteractionHandler" ) ) ),
194cdf0e10cSrcweir                 uno::UNO_QUERY_THROW );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir             uno::Sequence< task::UrlRecord > aURLEntries = xPasswdContainer->getAllPersistent( xInteractionHandler );
197cdf0e10cSrcweir             sal_Int32 nCount = 0;
198cdf0e10cSrcweir             for ( sal_Int32 nURLInd = 0; nURLInd < aURLEntries.getLength(); nURLInd++ )
199cdf0e10cSrcweir             {
200cdf0e10cSrcweir                 for ( sal_Int32 nUserInd = 0; nUserInd < aURLEntries[nURLInd].UserList.getLength(); nUserInd++ )
201cdf0e10cSrcweir                 {
202cdf0e10cSrcweir                     ::rtl::OUString aUIEntry( aURLEntries[nURLInd].Url );
203cdf0e10cSrcweir                     aUIEntry += ::rtl::OUString::valueOf( (sal_Unicode)'\t' );
204cdf0e10cSrcweir                     aUIEntry += aURLEntries[nURLInd].UserList[nUserInd].UserName;
205cdf0e10cSrcweir                     SvLBoxEntry* pEntry = m_aPasswordsLB.InsertEntry( aUIEntry );
206cdf0e10cSrcweir                     pEntry->SetUserData( (void*)(nCount++) );
207cdf0e10cSrcweir                 }
208cdf0e10cSrcweir             }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir             // remember pos of first url container entry.
211cdf0e10cSrcweir             m_nPos = nCount;
212cdf0e10cSrcweir 
213cdf0e10cSrcweir             uno::Reference< task::XUrlContainer > xUrlContainer(
214cdf0e10cSrcweir                 xPasswdContainer, uno::UNO_QUERY_THROW );
215cdf0e10cSrcweir 
216cdf0e10cSrcweir             uno::Sequence< rtl::OUString > aUrls
217cdf0e10cSrcweir                 = xUrlContainer->getUrls( sal_True /* OnlyPersistent */ );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir             for ( sal_Int32 nURLIdx = 0; nURLIdx < aUrls.getLength(); nURLIdx++ )
220cdf0e10cSrcweir             {
221cdf0e10cSrcweir                 ::rtl::OUString aUIEntry( aUrls[ nURLIdx ] );
222cdf0e10cSrcweir                 aUIEntry += ::rtl::OUString::valueOf( (sal_Unicode)'\t' );
223cdf0e10cSrcweir                 aUIEntry += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*" ) );
224cdf0e10cSrcweir                 SvLBoxEntry* pEntry = m_aPasswordsLB.InsertEntry( aUIEntry );
225cdf0e10cSrcweir                 pEntry->SetUserData( (void*)(nCount++) );
226cdf0e10cSrcweir             }
227cdf0e10cSrcweir         }
228cdf0e10cSrcweir     }
229cdf0e10cSrcweir     catch( uno::Exception& )
230cdf0e10cSrcweir     {}
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir // -----------------------------------------------------------------------
IMPL_LINK(WebConnectionInfoDialog,RemovePasswordHdl,PushButton *,EMPTYARG)234cdf0e10cSrcweir IMPL_LINK( WebConnectionInfoDialog, RemovePasswordHdl, PushButton*, EMPTYARG )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir     try
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         SvLBoxEntry* pEntry = m_aPasswordsLB.GetCurEntry();
239cdf0e10cSrcweir         if ( pEntry )
240cdf0e10cSrcweir         {
241cdf0e10cSrcweir             ::rtl::OUString aURL = m_aPasswordsLB.GetEntryText( pEntry, 0 );
242cdf0e10cSrcweir             ::rtl::OUString aUserName = m_aPasswordsLB.GetEntryText( pEntry, 1 );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir             uno::Reference< task::XPasswordContainer > xPasswdContainer(
245cdf0e10cSrcweir                 comphelper::getProcessServiceFactory()->createInstance(
246cdf0e10cSrcweir                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
247cdf0e10cSrcweir                         "com.sun.star.task.PasswordContainer" ) ) ),
248cdf0e10cSrcweir                 uno::UNO_QUERY_THROW );
249cdf0e10cSrcweir 
250cdf0e10cSrcweir             sal_Int32 nPos = (sal_Int32)(sal_IntPtr)pEntry->GetUserData();
251cdf0e10cSrcweir             if ( nPos < m_nPos )
252cdf0e10cSrcweir             {
253cdf0e10cSrcweir                 xPasswdContainer->removePersistent( aURL, aUserName );
254cdf0e10cSrcweir             }
255cdf0e10cSrcweir             else
256cdf0e10cSrcweir             {
257cdf0e10cSrcweir                 uno::Reference< task::XUrlContainer > xUrlContainer(
258cdf0e10cSrcweir                     xPasswdContainer, uno::UNO_QUERY_THROW );
259cdf0e10cSrcweir                 xUrlContainer->removeUrl( aURL );
260cdf0e10cSrcweir             }
261cdf0e10cSrcweir             m_aPasswordsLB.RemoveEntry( pEntry );
262cdf0e10cSrcweir         }
263cdf0e10cSrcweir     }
264cdf0e10cSrcweir     catch( uno::Exception& )
265cdf0e10cSrcweir     {}
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     return 0;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir // -----------------------------------------------------------------------
IMPL_LINK(WebConnectionInfoDialog,RemoveAllPasswordsHdl,PushButton *,EMPTYARG)271cdf0e10cSrcweir IMPL_LINK( WebConnectionInfoDialog, RemoveAllPasswordsHdl, PushButton*, EMPTYARG )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir     try
274cdf0e10cSrcweir     {
275cdf0e10cSrcweir         uno::Reference< task::XPasswordContainer > xPasswdContainer(
276cdf0e10cSrcweir             comphelper::getProcessServiceFactory()->createInstance(
277cdf0e10cSrcweir                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
278cdf0e10cSrcweir                     "com.sun.star.task.PasswordContainer" ) ) ),
279cdf0e10cSrcweir             uno::UNO_QUERY_THROW );
280cdf0e10cSrcweir 
281cdf0e10cSrcweir         // should the master password be requested before?
282cdf0e10cSrcweir         xPasswdContainer->removeAllPersistent();
283cdf0e10cSrcweir 
284cdf0e10cSrcweir         uno::Reference< task::XUrlContainer > xUrlContainer(
285cdf0e10cSrcweir             xPasswdContainer, uno::UNO_QUERY_THROW );
286cdf0e10cSrcweir         uno::Sequence< rtl::OUString > aUrls
287cdf0e10cSrcweir             = xUrlContainer->getUrls( sal_True /* OnlyPersistent */ );
288cdf0e10cSrcweir         for ( sal_Int32 nURLIdx = 0; nURLIdx < aUrls.getLength(); nURLIdx++ )
289cdf0e10cSrcweir             xUrlContainer->removeUrl( aUrls[ nURLIdx ] );
290cdf0e10cSrcweir 
291cdf0e10cSrcweir         m_aPasswordsLB.Clear();
292cdf0e10cSrcweir     }
293cdf0e10cSrcweir     catch( uno::Exception& )
294cdf0e10cSrcweir     {}
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     return 0;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir // -----------------------------------------------------------------------
IMPL_LINK(WebConnectionInfoDialog,ChangePasswordHdl,PushButton *,EMPTYARG)300cdf0e10cSrcweir IMPL_LINK( WebConnectionInfoDialog, ChangePasswordHdl, PushButton*, EMPTYARG )
301cdf0e10cSrcweir {
302cdf0e10cSrcweir     try
303cdf0e10cSrcweir     {
304cdf0e10cSrcweir         SvLBoxEntry* pEntry = m_aPasswordsLB.GetCurEntry();
305cdf0e10cSrcweir         if ( pEntry )
306cdf0e10cSrcweir         {
307cdf0e10cSrcweir             ::rtl::OUString aURL = m_aPasswordsLB.GetEntryText( pEntry, 0 );
308cdf0e10cSrcweir             ::rtl::OUString aUserName = m_aPasswordsLB.GetEntryText( pEntry, 1 );
309cdf0e10cSrcweir 
310cdf0e10cSrcweir             ::comphelper::SimplePasswordRequest* pPasswordRequest
311cdf0e10cSrcweir                   = new ::comphelper::SimplePasswordRequest( task::PasswordRequestMode_PASSWORD_CREATE );
312cdf0e10cSrcweir             uno::Reference< task::XInteractionRequest > rRequest( pPasswordRequest );
313cdf0e10cSrcweir 
314cdf0e10cSrcweir             uno::Reference< task::XInteractionHandler > xInteractionHandler(
315cdf0e10cSrcweir                 comphelper::getProcessServiceFactory()->createInstance(
316cdf0e10cSrcweir                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
317cdf0e10cSrcweir                         "com.sun.star.task.InteractionHandler" ) ) ),
318cdf0e10cSrcweir                 uno::UNO_QUERY_THROW );
319cdf0e10cSrcweir             xInteractionHandler->handle( rRequest );
320cdf0e10cSrcweir 
321cdf0e10cSrcweir             if ( pPasswordRequest->isPassword() )
322cdf0e10cSrcweir             {
323cdf0e10cSrcweir                 String aNewPass = pPasswordRequest->getPassword();
324cdf0e10cSrcweir                 uno::Sequence< ::rtl::OUString > aPasswd( 1 );
325cdf0e10cSrcweir                 aPasswd[0] = aNewPass;
326cdf0e10cSrcweir 
327cdf0e10cSrcweir                 uno::Reference< task::XPasswordContainer > xPasswdContainer(
328cdf0e10cSrcweir                     comphelper::getProcessServiceFactory()->createInstance(
329cdf0e10cSrcweir                         rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
330cdf0e10cSrcweir                             "com.sun.star.task.PasswordContainer" ) ) ),
331cdf0e10cSrcweir                     uno::UNO_QUERY_THROW );
332cdf0e10cSrcweir                 xPasswdContainer->addPersistent(
333cdf0e10cSrcweir                     aURL, aUserName, aPasswd, xInteractionHandler );
334cdf0e10cSrcweir             }
335cdf0e10cSrcweir         }
336cdf0e10cSrcweir     }
337cdf0e10cSrcweir     catch( uno::Exception& )
338cdf0e10cSrcweir     {}
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     return 0;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir // -----------------------------------------------------------------------
IMPL_LINK(WebConnectionInfoDialog,EntrySelectedHdl,void *,EMPTYARG)344cdf0e10cSrcweir IMPL_LINK( WebConnectionInfoDialog, EntrySelectedHdl, void*, EMPTYARG )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir     SvLBoxEntry* pEntry = m_aPasswordsLB.GetCurEntry();
347cdf0e10cSrcweir 	if ( !pEntry )
348cdf0e10cSrcweir     {
349cdf0e10cSrcweir         m_aRemoveBtn.Enable( sal_False );
350cdf0e10cSrcweir         m_aChangeBtn.Enable( sal_False );
351cdf0e10cSrcweir     }
352cdf0e10cSrcweir     else
353cdf0e10cSrcweir 	{
354cdf0e10cSrcweir         m_aRemoveBtn.Enable( sal_True );
355cdf0e10cSrcweir 
356cdf0e10cSrcweir         // url container entries (-> use system credentials) have
357cdf0e10cSrcweir         // no password
358cdf0e10cSrcweir         sal_Int32 nPos = (sal_Int32)(sal_IntPtr)pEntry->GetUserData();
359cdf0e10cSrcweir         m_aChangeBtn.Enable( nPos < m_nPos );
360cdf0e10cSrcweir 	}
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 	return 0;
363cdf0e10cSrcweir }
364cdf0e10cSrcweir 
365cdf0e10cSrcweir //........................................................................
366cdf0e10cSrcweir }   // namespace svx
367cdf0e10cSrcweir //........................................................................
368cdf0e10cSrcweir 
369