diff options
Diffstat (limited to 'fpicker/source/office/fileview.cxx')
-rw-r--r-- | fpicker/source/office/fileview.cxx | 95 |
1 files changed, 43 insertions, 52 deletions
diff --git a/fpicker/source/office/fileview.cxx b/fpicker/source/office/fileview.cxx index 7086d17597a9..6a77f9154ac8 100644 --- a/fpicker/source/office/fileview.cxx +++ b/fpicker/source/office/fileview.cxx @@ -47,6 +47,7 @@ #include <rtl/math.hxx> #include <o3tl/safeint.hxx> #include <o3tl/typed_flags_set.hxx> +#include <o3tl/string_view.hxx> #include <osl/mutex.hxx> #include <osl/conditn.hxx> #include <salhelper/timer.hxx> @@ -63,7 +64,6 @@ #include <memory> #include "fileview.hxx" -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::task; using namespace ::com::sun::star::ucb; @@ -192,8 +192,8 @@ public: void grab_focus() { mxTreeView->grab_focus(); } bool has_focus() const { return mxTreeView->has_focus(); } - void set_help_id(const OString& rHelpId) { mxTreeView->set_help_id(rHelpId); } - OString get_help_id() const { return mxTreeView->get_help_id(); } + void set_help_id(const OUString& rHelpId) { mxTreeView->set_help_id(rHelpId); } + OUString get_help_id() const { return mxTreeView->get_help_id(); } bool IsEditingActive() const { return mbEditing; } @@ -228,7 +228,7 @@ public: DECL_LINK(EditedEntryHdl, const IterString&, bool); DECL_LINK(KeyInputHdl, const KeyEvent&, bool); - void ExecuteContextMenuAction(std::string_view rSelectedPopentry); + void ExecuteContextMenuAction(std::u16string_view rSelectedPopentry); }; } @@ -286,7 +286,7 @@ public: void Clear(); FileViewResult GetFolderContent_Impl( - const OUString& rFolder, + std::u16string_view rFolder, const FileViewAsyncAction* pAsyncDescriptor, const css::uno::Sequence< OUString >& rDenyList ); @@ -294,7 +294,7 @@ public: const FolderDescriptor& _rFolder, const FileViewAsyncAction* pAsyncDescriptor, const css::uno::Sequence< OUString >& rDenyList ); - void FilterFolderContent_Impl( const OUString &rFilter ); + void FilterFolderContent_Impl( std::u16string_view rFilter ); void CancelRunningAsyncAction(); void OpenFolder_Impl(); @@ -408,10 +408,11 @@ namespace nDec = 3; } - OUString aSizeStr( ::rtl::math::doubleToUString( fSize, + OUString aSizeStr = + ::rtl::math::doubleToUString( fSize, rtl_math_StringFormat_F, nDec, - SvtSysLocale().GetLocaleData().getNumDecimalSep()[0]) ); - aSizeStr += aUnitStr; + SvtSysLocale().GetLocaleData().getNumDecimalSep()[0]) + + aUnitStr; return aSizeStr; } @@ -509,8 +510,8 @@ IMPL_LINK(ViewTabListBox_Impl, CommandHdl, const CommandEvent&, rCEvt, bool) ::ucbhelper::Content aCnt; try { - OUString aURL(reinterpret_cast<SvtContentEntry*>( - mxTreeView->get_id(rEntry).toInt64())->maURL); + OUString aURL(weld::fromId<SvtContentEntry*>( + mxTreeView->get_id(rEntry))->maURL); aCnt = ::ucbhelper::Content( aURL, mxCmdEnv, comphelper::getProcessComponentContext() ); } catch( Exception const & ) @@ -569,18 +570,18 @@ IMPL_LINK(ViewTabListBox_Impl, CommandHdl, const CommandEvent&, rCEvt, bool) auto xContextMenu = xBuilder->weld_menu("menu"); xContextMenu->set_visible("delete", bEnableDelete); xContextMenu->set_visible("rename", bEnableRename); - OString sCommand(xContextMenu->popup_at_rect(mxTreeView.get(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1)))); + OUString sCommand(xContextMenu->popup_at_rect(mxTreeView.get(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1)))); ExecuteContextMenuAction(sCommand); } return true; } -void ViewTabListBox_Impl::ExecuteContextMenuAction(std::string_view rSelectedPopupEntry) +void ViewTabListBox_Impl::ExecuteContextMenuAction(std::u16string_view rSelectedPopupEntry) { - if (rSelectedPopupEntry == "delete") + if (rSelectedPopupEntry == u"delete") DeleteEntries(); - else if (rSelectedPopupEntry == "rename") + else if (rSelectedPopupEntry == u"rename") { std::unique_ptr<weld::TreeIter> xEntry = mxTreeView->make_iterator(); if (mxTreeView->get_selected(xEntry.get())) @@ -602,7 +603,7 @@ void ViewTabListBox_Impl::DeleteEntries() mxTreeView->selected_foreach([this, &eResult](weld::TreeIter& rCurEntry){ OUString aURL; if (!mxTreeView->get_id(rCurEntry).isEmpty()) - aURL = reinterpret_cast<SvtContentEntry*>(mxTreeView->get_id(rCurEntry).toInt64())->maURL; + aURL = weld::fromId<SvtContentEntry*>(mxTreeView->get_id(rCurEntry))->maURL; if (aURL.isEmpty()) { mxTreeView->unselect(rCurEntry); @@ -677,7 +678,7 @@ IMPL_LINK(ViewTabListBox_Impl, EditedEntryHdl, const IterString&, rIterString, b bool bRet = false; OUString aURL; - SvtContentEntry* pData = reinterpret_cast<SvtContentEntry*>(mxTreeView->get_id(rEntry).toInt64()); + SvtContentEntry* pData = weld::fromId<SvtContentEntry*>(mxTreeView->get_id(rEntry)); if ( pData ) aURL = pData->maURL; @@ -719,7 +720,7 @@ IMPL_LINK(ViewTabListBox_Impl, EditedEntryHdl, const IterString&, rIterString, b if (pData) pData->maURL = aURL; - mxTreeView->set_id(rEntry, OUString::number(reinterpret_cast<sal_Int64>(pData))); + mxTreeView->set_id(rEntry, weld::toId(pData)); bRet = true; } @@ -770,7 +771,7 @@ bool ViewTabListBox_Impl::Kill( const OUString& rContent ) try { ::ucbhelper::Content aCnt( rContent, mxCmdEnv, comphelper::getProcessComponentContext() ); - aCnt.executeCommand( "delete", makeAny( true ) ); + aCnt.executeCommand( "delete", Any( true ) ); } catch( css::ucb::CommandAbortedException const & ) { @@ -831,9 +832,9 @@ OUString SvtFileView::GetURL(const weld::TreeIter& rEntry) const { SvtContentEntry* pEntry; if (mpImpl->mxView->get_visible()) - pEntry = reinterpret_cast<SvtContentEntry*>(mpImpl->mxView->get_id(rEntry).toInt64()); + pEntry = weld::fromId<SvtContentEntry*>(mpImpl->mxView->get_id(rEntry)); else - pEntry = reinterpret_cast<SvtContentEntry*>(mpImpl->mxIconView->get_id(rEntry).toInt64()); + pEntry = weld::fromId<SvtContentEntry*>(mpImpl->mxIconView->get_id(rEntry)); if (pEntry) return pEntry->maURL; return OUString(); @@ -847,13 +848,13 @@ OUString SvtFileView::GetCurrentURL() const { std::unique_ptr<weld::TreeIter> xEntry = mpImpl->mxView->make_iterator(); if (mpImpl->mxView->get_selected(xEntry.get())) - pEntry = reinterpret_cast<SvtContentEntry*>(mpImpl->mxView->get_id(*xEntry).toInt64()); + pEntry = weld::fromId<SvtContentEntry*>(mpImpl->mxView->get_id(*xEntry)); } else { std::unique_ptr<weld::TreeIter> xEntry = mpImpl->mxIconView->make_iterator(); if (mpImpl->mxIconView->get_selected(xEntry.get())) - pEntry = reinterpret_cast<SvtContentEntry*>(mpImpl->mxIconView->get_id(*xEntry).toInt64()); + pEntry = weld::fromId<SvtContentEntry*>(mpImpl->mxIconView->get_id(*xEntry)); } if (pEntry) aURL = pEntry->maURL; @@ -865,7 +866,7 @@ void SvtFileView::CreatedFolder( const OUString& rUrl, const OUString& rNewFolde const SortingData_Impl& rEntry = mpImpl->FolderInserted( rUrl, rNewFolder ); mpImpl->maEntries.emplace_back(std::make_unique<SvtContentEntry>(rUrl, true)); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(mpImpl->maEntries.back().get()))); + OUString sId(weld::toId(mpImpl->maEntries.back().get())); std::unique_ptr<weld::TreeIter> xEntry = mpImpl->mxView->make_iterator(); mpImpl->mxView->insert(rEntry.maDisplayName, sId, mpImpl->maFolderImage, *xEntry); @@ -913,12 +914,12 @@ bool SvtFileView::GetParentURL( OUString& rParentURL ) const return bRet; } -OString SvtFileView::get_help_id() const +OUString SvtFileView::get_help_id() const { return mpImpl->mxView->get_help_id(); } -void SvtFileView::set_help_id(const OString& rHelpId) +void SvtFileView::set_help_id(const OUString& rHelpId) { mpImpl->mxView->set_help_id(rHelpId); } @@ -1006,14 +1007,14 @@ SvtContentEntry* SvtFileView::FirstSelected() const SvtContentEntry* pRet = nullptr; std::unique_ptr<weld::TreeIter> xEntry = mpImpl->mxView->make_iterator(); if (mpImpl->mxView->get_selected(xEntry.get())) - pRet = reinterpret_cast<SvtContentEntry*>(mpImpl->mxView->get_id(*xEntry).toInt64()); + pRet = weld::fromId<SvtContentEntry*>(mpImpl->mxView->get_id(*xEntry)); return pRet; } SvtContentEntry* pRet = nullptr; std::unique_ptr<weld::TreeIter> xEntry = mpImpl->mxIconView->make_iterator(); if (mpImpl->mxIconView->get_selected(xEntry.get())) - pRet = reinterpret_cast<SvtContentEntry*>(mpImpl->mxIconView->get_id(*xEntry).toInt64()); + pRet = weld::fromId<SvtContentEntry*>(mpImpl->mxIconView->get_id(*xEntry)); return pRet; } @@ -1098,19 +1099,19 @@ OUString SvtFileView::GetConfigString() const return aContent; } -void SvtFileView::SetConfigString(const OUString& rCfgStr) +void SvtFileView::SetConfigString(std::u16string_view rCfgStr) { sal_Int32 nIdx = 0; - sal_uInt16 nSortColumn = static_cast<sal_uInt16>(rCfgStr.getToken( 0, ';', nIdx ).toInt32()); - bool bAscending = static_cast<bool>(static_cast<sal_uInt16>(rCfgStr.getToken( 0, ';', nIdx ).toInt32())); + sal_uInt16 nSortColumn = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx ))); + bool bAscending = static_cast<bool>(static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx )))); std::vector<int> aWidths(mpImpl->mxView->TypeColumnVisible() ? 4 : 3, -1); while ( nIdx != -1 ) { - sal_uInt16 nItemId = static_cast<sal_uInt16>(rCfgStr.getToken( 0, ';', nIdx ).toInt32()); + sal_uInt16 nItemId = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx ))); - int nWidth = rCfgStr.getToken( 0, ';', nIdx ).toInt32(); + int nWidth = o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx )); // skip "TYPE" if (!mpImpl->mxView->TypeColumnVisible() && nItemId != COLUMN_TITLE) @@ -1171,7 +1172,7 @@ void SvtFileView_Impl::Clear() } FileViewResult SvtFileView_Impl::GetFolderContent_Impl( - const OUString& rFolder, + std::u16string_view rFolder, const FileViewAsyncAction* pAsyncDescriptor, const css::uno::Sequence< OUString >& rDenyList ) { @@ -1285,9 +1286,9 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl( return eFailure; } -void SvtFileView_Impl::FilterFolderContent_Impl( const OUString &rFilter ) +void SvtFileView_Impl::FilterFolderContent_Impl( std::u16string_view rFilter ) { - if ( rFilter.isEmpty() || ( rFilter == ALL_FILES_FILTER ) ) + if ( rFilter.empty() || ( rFilter == ALL_FILES_FILTER ) ) // when replacing names, there is always something to filter (no view of ".nametranslation.table") return; @@ -1302,7 +1303,7 @@ void SvtFileView_Impl::FilterFolderContent_Impl( const OUString &rFilter ) // do the filtering - maContent.erase(std::remove_if(maContent.begin(), maContent.end(), + std::erase_if(maContent, [&aFilters](const std::unique_ptr<SortingData_Impl>& rxContent) { if (rxContent->mbIsFolder) return false; @@ -1310,8 +1311,7 @@ void SvtFileView_Impl::FilterFolderContent_Impl( const OUString &rFilter ) // 91872 - 11.09.2001 - frank.schoenheit@sun.com OUString sCompareString = rxContent->GetFileName(); // filter works on file name, not on title! return std::none_of(aFilters.begin(), aFilters.end(), FilterMatch(sCompareString)); - }), - maContent.end()); + }); } IMPL_LINK_NOARG(SvtFileView_Impl, ChangedHdl, weld::TreeView&, void) @@ -1369,7 +1369,7 @@ void SvtFileView_Impl::OpenFolder_Impl() // insert entry and set user data maEntries.emplace_back(std::make_unique<SvtContentEntry>(elem->maTargetURL, elem->mbIsFolder)); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(maEntries.back().get()))); + OUString sId(weld::toId(maEntries.back().get())); mxView->append(sId, elem->maDisplayName, elem->maType, elem->maDisplaySize, elem->maDisplayDate, elem->maImage); mxIconView->append(sId, elem->maDisplayName, elem->maImage); } @@ -1490,22 +1490,13 @@ void SvtFileView_Impl::implEnumerationSuccess() OUString SvtFileView_Impl::ReplaceTabWithString(const OUString& rValue) { - OUString const aTab( "\t" ); - OUString const aTabString( "%09" ); - - sal_Int32 iPos; - OUString aValue(rValue); - while ( ( iPos = aValue.indexOf( aTab ) ) >= 0 ) - aValue = aValue.replaceAt( iPos, 1, aTabString ); - return aValue; + return rValue.replaceAll(u"\t", u"%09"); } void SvtFileView_Impl::CreateDisplayText_Impl() { ::osl::MutexGuard aGuard( maMutex ); - OUString const aDateSep( ", " ); - for (auto const& elem : maContent) { // title, type, size, date @@ -1519,7 +1510,7 @@ void SvtFileView_Impl::CreateDisplayText_Impl() SvtSysLocale aSysLocale; const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData(); elem->maDisplayDate = rLocaleData.getDate( elem->maModDate ) - + aDateSep + + ", " + rLocaleData.getTime( elem->maModDate, false ); } @@ -1553,7 +1544,7 @@ void SvtFileView_Impl::Resort_Impl( sal_Int16 nColumn, bool bAscending ) OUString aEntryURL; if (bEntry && !mxView->get_id(*xEntry).isEmpty()) - aEntryURL = reinterpret_cast<SvtContentEntry*>(mxView->get_id(*xEntry).toInt64())->maURL; + aEntryURL = weld::fromId<SvtContentEntry*>(mxView->get_id(*xEntry))->maURL; mnSortColumn = nColumn; mbAscending = bAscending; |