diff options
Diffstat (limited to 'dbaccess/source/ui/control/opendoccontrols.cxx')
-rw-r--r-- | dbaccess/source/ui/control/opendoccontrols.cxx | 48 |
1 files changed, 15 insertions, 33 deletions
diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx index 699eae894d89..58f12c9e01a0 100644 --- a/dbaccess/source/ui/control/opendoccontrols.cxx +++ b/dbaccess/source/ui/control/opendoccontrols.cxx @@ -52,18 +52,14 @@ namespace dbaui using ::com::sun::star::ui::XImageManager; using ::com::sun::star::graphic::XGraphic; - Reference< XGraphic> GetCommandIcon( const char* _pCommandURL, const OUString& _rModuleName ) + Reference< XGraphic> GetCommandIcon( const OUString& sCommandURL, const OUString& _rModuleName ) { - if ( !_pCommandURL || !*_pCommandURL ) - return nullptr; - - OUString sCommandURL = OUString::createFromAscii( _pCommandURL ); try { do { // Retrieve popup menu labels - Reference< css::uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + const Reference< css::uno::XComponentContext >& xContext( ::comphelper::getProcessComponentContext() ); if ( !xContext.is() ) break; @@ -94,24 +90,16 @@ namespace dbaui // OpenButton - OpenDocumentButton::OpenDocumentButton(std::unique_ptr<weld::Button> xControl, const char* _pAsciiModuleName) + OpenDocumentButton::OpenDocumentButton(std::unique_ptr<weld::Button> xControl, const OUString& _rAsciiModuleName) : m_xControl(std::move(xControl)) { - impl_init( _pAsciiModuleName ); - } - - void OpenDocumentButton::impl_init( const char* _pAsciiModuleName ) - { - OSL_ENSURE( _pAsciiModuleName, "OpenDocumentButton::impl_init: invalid module name!" ); - m_sModule = OUString::createFromAscii( _pAsciiModuleName ); - // our label should equal the UI text of the "Open" command - auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:Open", m_sModule); + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(u".uno:Open"_ustr, _rAsciiModuleName); OUString sLabel(vcl::CommandInfoProvider::GetLabelForCommand(aProperties)); m_xControl->set_label(" " + sLabel.replaceAll("~", "")); // Place icon left of text and both centered in the button. - m_xControl->set_image(GetCommandIcon(".uno:Open", m_sModule)); + m_xControl->set_image(GetCommandIcon(u".uno:Open"_ustr, _rAsciiModuleName)); } // OpenDocumentListBox @@ -130,39 +118,33 @@ namespace dbaui { OSL_ENSURE( _pAsciiModuleName, "OpenDocumentListBox::impl_init: invalid module name!" ); - Sequence< Sequence< PropertyValue> > aHistory = SvtHistoryOptions().GetList( EHistoryType::PickList ); + std::vector< SvtHistoryOptions::HistoryItem > aHistory = SvtHistoryOptions::GetList( EHistoryType::PickList ); Reference< XNameAccess > xFilterFactory; xFilterFactory.set(::comphelper::getProcessServiceFactory()->createInstance( - "com.sun.star.document.FilterFactory" ), css::uno::UNO_QUERY); + u"com.sun.star.document.FilterFactory"_ustr ), css::uno::UNO_QUERY); - sal_uInt32 nCount = aHistory.getLength(); - for ( sal_uInt32 nItem = 0; nItem < nCount; ++nItem ) + for ( const SvtHistoryOptions::HistoryItem& rHistoryItem : aHistory ) { try { // Get the current history item's properties. - ::comphelper::SequenceAsHashMap aItemProperties( aHistory[ nItem ] ); - OUString sURL = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_URL, OUString() ); - OUString sFilter = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_FILTER, OUString() ); - OUString sTitle = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_TITLE, OUString() ); - OUString sPassword = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_PASSWORD, OUString() ); + OUString sURL = rHistoryItem.sURL; + OUString sFilter = rHistoryItem.sFilter; + OUString sTitle = rHistoryItem.sTitle; - // If the entry is an impress file then insert it into the + // If the entry is a Base file then insert it into the // history list and the list box. Sequence< PropertyValue > aProps; xFilterFactory->getByName( sFilter ) >>= aProps; ::comphelper::SequenceAsHashMap aFilterProperties( aProps ); OUString sDocumentService = aFilterProperties.getUnpackedValueOrDefault( - "DocumentService", OUString() ); + u"DocumentService"_ustr, OUString() ); if ( sDocumentService.equalsAscii( _pAsciiModuleName ) ) { // yes, it's a Base document INetURLObject aURL; aURL.SetSmartURL( sURL ); - // The password is set only when it is not empty. - if ( !sPassword.isEmpty() ) - aURL.SetPass( sPassword ); if ( sTitle.isEmpty() ) sTitle = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::Unambiguous ); @@ -170,7 +152,7 @@ namespace dbaui OUString sDecodedURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); m_xControl->append_text(sTitle); - m_aURLs.emplace_back(StringPair(sDecodedURL, sFilter)); + m_aURLs.emplace_back(sDecodedURL, sFilter); } } catch( Exception& ) {} @@ -186,7 +168,7 @@ namespace dbaui return sURL; } - OpenDocumentListBox::StringPair OpenDocumentListBox::impl_getDocumentAtIndex( sal_uInt16 _nListIndex ) const + const OpenDocumentListBox::StringPair & OpenDocumentListBox::impl_getDocumentAtIndex( sal_uInt16 _nListIndex ) const { return m_aURLs[_nListIndex]; } |