1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pickerhelper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include "pickerhelper.hxx"
35 #include "rtl/ustring.hxx"
36 #include "com/sun/star/ui/dialogs/XFilePicker.hpp"
37 #include "com/sun/star/ui/dialogs/XFolderPicker.hpp"
38 #include "com/sun/star/beans/XPropertySet.hpp"
39 #include "com/sun/star/beans/XPropertySetInfo.hpp"
40 #include "com/sun/star/uno/Any.hxx"
41 #include "tools/debug.hxx"
43 namespace css
= com::sun::star
;
45 using css::uno::Reference
;
51 Reference
< css::ui::dialogs::XFilePicker
> _mxFileDlg
, sal_Int32 _nHelpId
)
55 // does the dialog haver a help URL property?
56 Reference
< css::beans::XPropertySet
> xDialogProps( _mxFileDlg
, css::uno::UNO_QUERY
);
57 Reference
< css::beans::XPropertySetInfo
> xInfo
;
58 if( xDialogProps
.is() )
59 xInfo
= xDialogProps
->getPropertySetInfo( );
61 const OUString
sHelpURLPropertyName( RTL_CONSTASCII_USTRINGPARAM( "HelpURL" ) );
63 if( xInfo
.is() && xInfo
->hasPropertyByName( sHelpURLPropertyName
) )
65 OUString
sId( RTL_CONSTASCII_USTRINGPARAM( "HID:" ) );
66 sId
+= OUString::valueOf( _nHelpId
);
67 xDialogProps
->setPropertyValue( sHelpURLPropertyName
, css::uno::makeAny( sId
) );
70 catch( const css::uno::Exception
& )
72 DBG_ERROR( "svt::SetDialogHelpId(): caught an exception while setting the help id!" );
77 Reference
< css::ui::dialogs::XFolderPicker
> _mxFileDlg
, sal_Int32 _nHelpId
)
81 // does the dialog haver a help URL property?
82 Reference
< css::beans::XPropertySet
> xDialogProps( _mxFileDlg
, css::uno::UNO_QUERY
);
83 Reference
< css::beans::XPropertySetInfo
> xInfo
;
84 if( xDialogProps
.is() )
85 xInfo
= xDialogProps
->getPropertySetInfo( );
87 const OUString
sHelpURLPropertyName( RTL_CONSTASCII_USTRINGPARAM( "HelpURL" ) );
89 if( xInfo
.is() && xInfo
->hasPropertyByName( sHelpURLPropertyName
) )
91 OUString
sId( RTL_CONSTASCII_USTRINGPARAM( "HID:" ) );
92 sId
+= OUString::valueOf( _nHelpId
);
93 xDialogProps
->setPropertyValue( sHelpURLPropertyName
, css::uno::makeAny( sId
) );
96 catch( const css::uno::Exception
& )
98 DBG_ERROR( "svt::SetDialogHelpId(): caught an exception while setting the help id!" );