22#include <osl/diagnose.h>
26#include <svtools/strings.hrc>
27#include <bitmaps.hlst>
29#include <com/sun/star/task/InteractionHandler.hpp>
30#include <com/sun/star/ucb/XProgressHandler.hpp>
31#include <com/sun/star/ucb/XContent.hpp>
32#include <com/sun/star/container/XChild.hpp>
33#include <com/sun/star/ucb/CommandAbortedException.hpp>
34#include <com/sun/star/ucb/XCommandInfo.hpp>
35#include <com/sun/star/beans/XPropertySetInfo.hpp>
36#include <com/sun/star/beans/PropertyAttribute.hpp>
47#include <rtl/math.hxx>
51#include <osl/mutex.hxx>
52#include <osl/conditn.hxx>
75using ::svt::SortingData_Impl;
76using ::svt::FolderDescriptor;
85#define QUICK_SEARCH_TIMEOUT 1500
89enum class FileViewFlags
115 explicit CallbackTimer(
SvtFileView_Impl* _pHandler ) : m_pTimeoutHandler( _pHandler ) { }
118 virtual void SAL_CALL
onShot()
override;
121class ViewTabListBox_Impl
124 Reference< XCommandEnvironment > mxCmdEnv;
125 std::unique_ptr<weld::TreeView> mxTreeView;
126 std::unique_ptr<weld::TreeIter> mxScratchIter;
130 Timer maResetQuickSearch {
"fpicker SvtFileView_Impl maResetQuickSearch" };
131 OUString maQuickSearchText;
132 sal_uInt32 mnSearchIndex;
135 bool const mbShowType;
137 void DeleteEntries();
139 bool Kill(
const OUString& rURL );
142 ViewTabListBox_Impl(std::unique_ptr<weld::TreeView> xTreeView,
weld::Window* pTopLevel,
SvtFileView_Impl* pParent, FileViewFlags nFlags);
144 std::unique_ptr<weld::TreeIter> make_iterator()
const {
return mxTreeView->make_iterator(); }
145 void insert(
const OUString &rEntry,
const OUString& rId,
const OUString& rImage,
weld::TreeIter& rIter)
147 mxTreeView->insert(
nullptr, -1, &rEntry, &rId,
nullptr,
nullptr,
false, &rIter);
148 mxTreeView->set_image(rIter, rImage);
150 void append(
const OUString& rId,
const OUString& rStr,
const OUString& rType,
const OUString& rSize,
const OUString& rDate,
const OUString& rImage)
152 mxTreeView->insert(
nullptr, -1, &rStr, &rId,
nullptr,
nullptr,
false, mxScratchIter.get());
153 mxTreeView->set_image(*mxScratchIter, rImage);
156 mxTreeView->set_text(*mxScratchIter, rType, nCol++);
157 mxTreeView->set_text(*mxScratchIter, rSize, nCol++);
158 mxTreeView->set_text(*mxScratchIter, rDate, nCol++);
161 void scroll_to_row(
const weld::TreeIter& rIter) { mxTreeView->scroll_to_row(rIter); }
162 void set_cursor(
int nPos) { mxTreeView->set_cursor(nPos); }
163 void set_cursor(
const weld::TreeIter& rIter) { mxTreeView->set_cursor(rIter); }
164 bool get_cursor(
weld::TreeIter* pIter)
const {
return mxTreeView->get_cursor(pIter); }
165 bool get_iter_first(
weld::TreeIter& rIter)
const {
return mxTreeView->get_iter_first(rIter); }
166 bool get_selected(
weld::TreeIter* pIter)
const {
return mxTreeView->get_selected(pIter); }
168 OUString get_selected_text()
const
171 int nIndex = mxTreeView->get_selected_index();
172 return nIndex != -1 ? mxTreeView->get_text(nIndex, 0) : OUString();
175 void unselect_all() { mxTreeView->unselect_all(); }
177 OUString get_id(
const weld::TreeIter& rIter) {
return mxTreeView->get_id(rIter); }
182 int n_children()
const {
return mxTreeView->n_children(); }
184 void freeze() { mxTreeView->freeze(); }
185 void thaw() { mxTreeView->thaw(); }
187 void show() { mxTreeView->show(); }
188 void hide() { mxTreeView->hide(); }
189 bool get_visible()
const {
return mxTreeView->get_visible(); }
191 int count_selected_rows()
const {
return mxTreeView->count_selected_rows(); }
193 void grab_focus() { mxTreeView->grab_focus(); }
194 bool has_focus()
const {
return mxTreeView->has_focus(); }
196 void set_help_id(
const OUString& rHelpId) { mxTreeView->set_help_id(rHelpId); }
197 OUString get_help_id()
const {
return mxTreeView->get_help_id(); }
199 bool IsEditingActive()
const {
return mbEditing; }
203 mxTreeView->end_editing();
208 void selected_foreach(
const std::function<
bool(
weld::TreeIter&)>& func)
210 mxTreeView->selected_foreach(func);
215 return mxTreeView.get();
218 void clear() { mxTreeView->
clear(); }
220 void EnableDelete(
bool bEnable ) { mbEnableDelete = bEnable; }
221 bool TypeColumnVisible()
const {
return mbShowType; }
223 const Reference< XCommandEnvironment >& GetCommandEnvironment()
const {
return mxCmdEnv; }
228 typedef std::pair<const weld::TreeIter&, OUString> IterString;
229 DECL_LINK(EditedEntryHdl,
const IterString&,
bool);
232 void ExecuteContextMenuAction(std::u16string_view rSelectedPopentry);
255 ::std::vector<std::unique_ptr<SortingData_Impl>>
maContent;
256 ::std::vector<std::unique_ptr<SvtContentEntry>>
maEntries;
260 std::unique_ptr<ViewTabListBox_Impl>
mxView;
279 std::unique_ptr<weld::TreeView> xTreeView,
280 std::unique_ptr<weld::IconView> xIconView,
281 Reference < XCommandEnvironment >
const & xEnv,
282 FileViewFlags nFlags,
290 std::u16string_view rFolder,
292 const css::uno::Sequence< OUString >& rDenyList );
295 const FolderDescriptor& _rFolder,
297 const css::uno::Sequence< OUString >& rDenyList );
308 const OUString& rName );
310 const OUString& rTitle );
318 void Resort_Impl( sal_Int16 nColumn,
bool bAscending );
320 std::u16string_view rTitle,
330 if (
mxView->IsEditingActive())
338 if (
mxView->get_visible())
355 return nOldSortID - 1;
371 mxView->EnableDelete( bEnable );
378 OUString CreateExactSizeText( sal_Int64 nSize )
380 double fSize(
static_cast<double>(nSize) );
386 OUString aUnitStr(
' ');
390 aUnitStr +=
SvtResId(STR_SVT_BYTES );
393 else if ( nSize < nMega )
399 else if ( nSize < nGiga )
413 ::rtl::math::doubleToUString( fSize,
414 rtl_math_StringFormat_F, nDec,
422ViewTabListBox_Impl::ViewTabListBox_Impl(std::unique_ptr<weld::TreeView> xTreeView,
425 FileViewFlags nFlags)
426 : mxTreeView(
std::move(xTreeView))
427 , mxScratchIter(mxTreeView->make_iterator())
430 , mbEnableDelete( false )
432 , mbShowType(nFlags & FileViewFlags::SHOW_TYPE)
434 std::vector<int> aWidths { 180 };
435 if (nFlags & FileViewFlags::SHOW_TYPE)
436 aWidths.push_back(140);
437 aWidths.push_back(80);
438 mxTreeView->set_column_fixed_widths(aWidths);
440 if (nFlags & FileViewFlags::MULTISELECTION)
441 mxTreeView->set_selection_mode(SelectionMode::Multiple);
444 maResetQuickSearch.SetInvokeHandler(
LINK(
this, ViewTabListBox_Impl, ResetQuickSearch_Impl ) );
446 Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
447 Reference< XInteractionHandler > xInteractionHandler(
448 InteractionHandler::createWithParent(xContext, pTopLevel->
GetXWindow()), UNO_QUERY_THROW);
450 mxCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() );
452 mxTreeView->connect_popup_menu(
LINK(
this, ViewTabListBox_Impl, CommandHdl));
453 mxTreeView->connect_key_press(
LINK(
this, ViewTabListBox_Impl, KeyInputHdl));
463 ::osl::MutexGuard aGuard(
maMutex );
465 maQuickSearchText.clear();
474 bool bHandled =
false;
482 ResetQuickSearch_Impl(
nullptr );
486 else if ( ( rKEvt.GetKeyCode().GetGroup() ==
KEYGROUP_NUM ) ||
489 DoQuickSearch( rKEvt.GetCharCode() );
495 ResetQuickSearch_Impl(
nullptr );
501 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
504 bool bEnableDelete = mbEnableDelete;
505 bool bEnableRename =
true;
508 mxTreeView->selected_foreach([
this, &
nCount, &bEnableDelete, &bEnableRename](
weld::TreeIter& rEntry){
514 OUString
aURL(weld::fromId<SvtContentEntry*>(
515 mxTreeView->get_id(rEntry))->maURL);
520 bEnableDelete = bEnableRename =
false;
527 Reference< XCommandInfo > aCommands = aCnt.
getCommands();
528 if ( aCommands.is() )
529 bEnableDelete = aCommands->hasCommandByName(
"delete" );
531 bEnableDelete =
false;
535 bEnableDelete =
false;
546 Property aProp = aProps->getPropertyByName(
"Title");
548 = !( aProp.Attributes & PropertyAttribute::READONLY );
551 bEnableRename =
false;
555 bEnableRename =
false;
559 bool bStop = !bEnableDelete && !bEnableRename;
564 bEnableDelete =
false;
566 bEnableRename =
false;
568 if (bEnableDelete || bEnableRename)
571 auto xContextMenu = xBuilder->weld_menu(
"menu");
572 xContextMenu->set_visible(
"delete", bEnableDelete);
573 xContextMenu->set_visible(
"rename", bEnableRename);
574 OUString sCommand(xContextMenu->popup_at_rect(mxTreeView.get(),
tools::Rectangle(rCEvt.GetMousePosPixel(),
Size(1,1))));
575 ExecuteContextMenuAction(sCommand);
581void ViewTabListBox_Impl::ExecuteContextMenuAction(std::u16string_view rSelectedPopupEntry)
583 if (rSelectedPopupEntry == u
"delete")
585 else if (rSelectedPopupEntry == u
"rename")
587 std::unique_ptr<weld::TreeIter> xEntry = mxTreeView->make_iterator();
588 if (mxTreeView->get_selected(xEntry.get()))
592 mxTreeView->connect_editing(
LINK(
this, ViewTabListBox_Impl, EditingEntryHdl),
593 LINK(
this, ViewTabListBox_Impl, EditedEntryHdl));
595 mxTreeView->start_editing(*xEntry);
600void ViewTabListBox_Impl::DeleteEntries()
604 mxTreeView->selected_foreach([
this, &eResult](
weld::TreeIter& rCurEntry){
606 if (!mxTreeView->get_id(rCurEntry).isEmpty())
607 aURL = weld::fromId<SvtContentEntry*>(mxTreeView->get_id(rCurEntry))->maURL;
610 mxTreeView->unselect(rCurEntry);
614 bool canDelete =
true;
617 ::ucbhelper::Content aCnt( aURL, mxCmdEnv, comphelper::getProcessComponentContext() );
618 Reference< XCommandInfo > aCommands = aCnt.getCommands();
619 if ( aCommands.is() )
620 canDelete = aCommands->hasCommandByName(
"delete" );
624 catch( Exception
const & )
631 mxTreeView->unselect(rCurEntry);
641 if (mxTreeView->count_selected_rows() > 1)
642 aDlg.EnableAllButton();
644 eResult = aDlg.run();
647 bool bDeleted =
false;
659 mxTreeView->unselect(rCurEntry);
664 mxTreeView->remove_selection();
667IMPL_LINK(ViewTabListBox_Impl, EditedEntryHdl,
const IterString&, rIterString,
bool)
674 OUString sNewText = rIterString.second;
676 if (sNewText.isEmpty())
687 if (
aURL.isEmpty() )
693 bool canRename =
true;
698 Reference< XPropertySetInfo > aProps = aContent.
getProperties();
702 canRename = !( aProp.Attributes & PropertyAttribute::READONLY );
736void ViewTabListBox_Impl::DoQuickSearch(
sal_Unicode rChar )
738 ::osl::MutexGuard aGuard( maMutex );
740 maResetQuickSearch.Stop();
742 OUString aLastText = maQuickSearchText;
743 sal_uInt32 aLastPos = mnSearchIndex;
745 maQuickSearchText += OUString(rChar).toAsciiLowerCase();
747 bool bFound =
mpParent->SearchNextEntry( mnSearchIndex, maQuickSearchText,
false );
749 if ( !bFound && ( aLastText.getLength() == 1 ) &&
750 ( aLastText == OUStringChar(rChar) ) )
752 mnSearchIndex = aLastPos + 1;
753 maQuickSearchText = aLastText;
754 bFound =
mpParent->SearchNextEntry( mnSearchIndex, maQuickSearchText,
true );
759 mxTreeView->unselect_all();
760 mxTreeView->select(mnSearchIndex);
761 mxTreeView->set_cursor(mnSearchIndex);
762 mxTreeView->scroll_to_row(mnSearchIndex);
765 maResetQuickSearch.Start();
768bool ViewTabListBox_Impl::Kill(
const OUString& rContent )
775 aCnt.executeCommand(
"delete",
Any(
true ) );
777 catch( css::ucb::CommandAbortedException
const & )
779 SAL_INFO(
"svtools.contnr",
"CommandAbortedException" );
782 catch( Exception
const & )
784 SAL_INFO(
"svtools.contnr",
"Any other exception" );
792 std::unique_ptr<weld::TreeView> xTreeView,
793 std::unique_ptr<weld::IconView> xIconView,
794 bool bOnlyFolder,
bool bMultiSelection,
bool bShowType )
796 FileViewFlags nFlags = FileViewFlags::NONE;
797 if ( bMultiSelection )
798 nFlags |= FileViewFlags::MULTISELECTION;
800 nFlags |= FileViewFlags::SHOW_TYPE;
802 Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
803 Reference< XInteractionHandler > xInteractionHandler(
804 InteractionHandler::createWithParent(xContext, pTopLevel->
GetXWindow()), UNO_QUERY_THROW);
805 Reference < XCommandEnvironment > xCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() );
807 mpImpl.reset(
new SvtFileView_Impl(
this, pTopLevel, std::move(xTreeView), std::move(xIconView), xCmdEnv, nFlags, bOnlyFolder));
820 return mpImpl->has_focus();
835 if (
mpImpl->mxView->get_visible())
836 pEntry = weld::fromId<SvtContentEntry*>(
mpImpl->mxView->get_id(rEntry));
838 pEntry = weld::fromId<SvtContentEntry*>(
mpImpl->mxIconView->get_id(rEntry));
840 return pEntry->
maURL;
848 if (
mpImpl->mxView->get_visible())
850 std::unique_ptr<weld::TreeIter> xEntry =
mpImpl->mxView->make_iterator();
851 if (
mpImpl->mxView->get_selected(xEntry.get()))
852 pEntry = weld::fromId<SvtContentEntry*>(
mpImpl->mxView->get_id(*xEntry));
856 std::unique_ptr<weld::TreeIter> xEntry =
mpImpl->mxIconView->make_iterator();
857 if (
mpImpl->mxIconView->get_selected(xEntry.get()))
858 pEntry = weld::fromId<SvtContentEntry*>(
mpImpl->mxIconView->get_id(*xEntry));
867 const SortingData_Impl& rEntry =
mpImpl->FolderInserted( rUrl, rNewFolder );
869 mpImpl->maEntries.emplace_back(std::make_unique<SvtContentEntry>(rUrl,
true));
872 std::unique_ptr<weld::TreeIter> xEntry =
mpImpl->mxView->make_iterator();
873 mpImpl->mxView->insert(rEntry.maDisplayName,
sId,
mpImpl->maFolderImage, *xEntry);
874 mpImpl->mxView->scroll_to_row(*xEntry);
876 std::unique_ptr<weld::TreeIter> xIconEntry =
mpImpl->mxIconView->make_iterator();
877 mpImpl->mxIconView->insert(-1, &rEntry.maDisplayName, &
sId, &
mpImpl->maFolderImage, xIconEntry.get());
878 mpImpl->mxIconView->scroll_to_item(*xIconEntry);
898 Reference< XContent > xContent( aCnt.
get() );
899 Reference< css::container::XChild > xChild( xContent, UNO_QUERY );
902 Reference< XContent > xParent( xChild->getParent(), UNO_QUERY );
905 rParentURL = xParent->getIdentifier()->getContentIdentifier();
906 bRet = !rParentURL.isEmpty() && rParentURL !=
mpImpl->maViewURL;
920 return mpImpl->mxView->get_help_id();
925 mpImpl->mxView->set_help_id(rHelpId);
930 if (
mpImpl->mxView->get_visible())
931 return mpImpl->mxView->get_selected_text();
932 return mpImpl->mxIconView->get_selected_text();
936 const OUString& rURL,
937 const OUString& rFilter,
939 const css::uno::Sequence< OUString >& rDenyList )
944 OUString sPushURL(
mpImpl->maViewURL );
952 mpImpl->maViewURL = sPushURL;
956 OSL_ENSURE( pAsyncDescriptor,
"SvtFileView::Initialize: we told it to read synchronously!" );
962 OSL_FAIL(
"SvtFileView::Initialize: unreachable!" );
968 mpImpl->maCurrentFilter = rFilter.toAsciiLowerCase();
972 OSL_ENSURE( ( eResult !=
eStillRunning ) || pAsyncDescriptor,
"SvtFileView::ExecuteFilter: we told it to read synchronously!" );
978 mpImpl->CancelRunningAsyncAction();
983 mpImpl->mxView->unselect_all();
984 mpImpl->mxIconView->unselect_all();
989 mpImpl->SetSelectHandler(rHdl);
994 mpImpl->SetDoubleClickHandler(rHdl);
999 if (
mpImpl->mxView->get_visible())
1000 return mpImpl->mxView->count_selected_rows();
1001 return mpImpl->mxIconView->count_selected_items();
1006 if (
mpImpl->mxView->get_visible())
1009 std::unique_ptr<weld::TreeIter> xEntry =
mpImpl->mxView->make_iterator();
1010 if (
mpImpl->mxView->get_selected(xEntry.get()))
1011 pRet = weld::fromId<SvtContentEntry*>(
mpImpl->mxView->get_id(*xEntry));
1016 std::unique_ptr<weld::TreeIter> xEntry =
mpImpl->mxIconView->make_iterator();
1017 if (
mpImpl->mxIconView->get_selected(xEntry.get()))
1018 pRet = weld::fromId<SvtContentEntry*>(
mpImpl->mxIconView->get_id(*xEntry));
1024 return mpImpl->maViewURL;
1029 mpImpl->maOpenDoneLink = rHdl;
1034 mpImpl->EnableDelete( bEnable );
1039 return mpImpl->EndEditing();
1044 sal_uInt16
nItemID = nColumn + 1;
1050 bool bSortAtoZ = mpImpl->mbAscending;
1053 if (
nItemID != mpImpl->mnSortColumn)
1059 bSortAtoZ = !bSortAtoZ;
1061 mpImpl->Resort_Impl(
nItemID, bSortAtoZ);
1067 OUString sRet = OUString::number(
mpImpl->mnSortColumn ) +
";";
1069 bool bUp =
mpImpl->mbAscending;
1070 sRet += OUString::Concat(bUp ? std::u16string_view(
u"1") : std::u16string_view(
u"0")) +
";";
1073 sal_uInt16
nCount =
mpImpl->mxView->TypeColumnVisible() ? 4 : 3;
1076 sal_uInt16
nId =
i + 1;
1081 sRet += OUString::number(
nId )
1092 ::std::vector< SvtContentEntry > aContent;
1094 for(
auto const& elem :
mpImpl->maContent)
1097 aContent.push_back( aEntry );
1109 std::vector<int> aWidths(
mpImpl->mxView->TypeColumnVisible() ? 4 : 3, -1);
1111 while ( nIdx != -1 )
1120 int nColumn = nItemId - 1;
1123 aWidths[nColumn] = nWidth;
1128 if (
mpImpl->mnSortColumn != nSortColumn)
1130 mpImpl->Resort_Impl(nSortColumn, bAscending);
1134 std::unique_ptr<weld::TreeView> xTreeView,
1135 std::unique_ptr<weld::IconView> xIconView,
1136 Reference < XCommandEnvironment >
const & xEnv,
1137 FileViewFlags nFlags,
bool bOnlyFolder)
1138 : m_pAntiImpl ( pAntiImpl )
1140 , m_bRunningAsyncAction ( false )
1141 , m_bAsyncActionCancelled ( false )
1142 , m_pTopLevel ( pTopLevel )
1143 ,
mxView(new ViewTabListBox_Impl(
std::move(xTreeView), pTopLevel, this, nFlags))
1144 , mxIconView(
std::move(xIconView))
1146 , mbAscending ( true )
1147 , mbOnlyFolder ( bOnlyFolder )
1148 , mnSuspendSelectCallback ( 0 )
1149 , mbIsFirstResort ( true )
1150 , aIntlWrapper (
Application::GetSettings().GetLanguageTag() )
1151 , maFolderImage (RID_BMP_FOLDER)
1170 ::osl::MutexGuard aGuard(
maMutex );
1176 std::u16string_view rFolder,
1178 const css::uno::Sequence< OUString >& rDenyList )
1180 ::osl::ClearableMutexGuard aGuard(
maMutex );
1191 const FolderDescriptor& _rFolder,
1193 const css::uno::Sequence< OUString >& rDenyList )
1196 ::osl::ClearableMutexGuard aGuard(
maMutex );
1198 OSL_ENSURE( !
m_xContentEnumerator.is(),
"SvtFileView_Impl::GetFolderContent_Impl: still running another enumeration!" );
1203 if ( !pAsyncDescriptor )
1228 sal_Int32 nMinTimeout = pAsyncDescriptor->
nMinTimeout;
1229 OSL_ENSURE( nMinTimeout > 0,
"SvtFileView_Impl::GetFolderContent_Impl: invalid minimum timeout!" );
1230 if ( nMinTimeout <= 0 )
1231 nMinTimeout = sal_Int32( 1000 );
1232 aTimeout.Seconds = nMinTimeout / 1000;
1233 aTimeout.Nanosec = ( nMinTimeout % 1000 ) * 1000000;
1241 ::osl::Condition::Result eResult = ::osl::Condition::result_ok;
1252 ::osl::MutexGuard aGuard2(
maMutex );
1253 if ( ::osl::Condition::result_timeout == eResult )
1257 "SvtFileView_Impl::GetFolderContent_Impl: there's still a previous timer!");
1259 sal_Int32 nMaxTimeout = pAsyncDescriptor->
nMaxTimeout;
1260 OSL_ENSURE( nMaxTimeout > nMinTimeout,
1261 "SvtFileView_Impl::GetFolderContent_Impl: invalid maximum timeout!" );
1262 if ( nMaxTimeout <= nMinTimeout )
1263 nMaxTimeout = nMinTimeout + 5000;
1279 case ::svt::EnumerationResult::SUCCESS:
1282 case ::svt::EnumerationResult::ERROR:
1286 SAL_WARN(
"svtools.contnr",
"SvtFileView_Impl::GetFolderContent_Impl: unreachable!" );
1296 ::osl::MutexGuard aGuard(
maMutex );
1302 ::std::vector< WildCard > aFilters;
1303 FilterMatch::createWildCardFilterList(rFilter,aFilters);
1308 [&aFilters](
const std::unique_ptr<SortingData_Impl>& rxContent) {
1309 if (rxContent->mbIsFolder)
1313 OUString sCompareString = rxContent->GetFileName();
1314 return std::none_of(aFilters.begin(), aFilters.end(), FilterMatch(sCompareString));
1321 if (!mnSuspendSelectCallback)
1322 m_aSelectHandler.Call(m_pAntiImpl);
1327 if (!mnSuspendSelectCallback)
1328 m_aSelectHandler.Call(m_pAntiImpl);
1341 return maDoubleClickHandler.Call(m_pAntiImpl);
1346 return maDoubleClickHandler.Call(m_pAntiImpl);
1359 ::osl::MutexGuard aGuard(
maMutex );
1373 maEntries.emplace_back(std::make_unique<SvtContentEntry>(elem->maTargetURL, elem->mbIsFolder));
1375 mxView->append(
sId, elem->maDisplayName, elem->maType, elem->maDisplaySize, elem->maDisplayDate, elem->maImage);
1376 mxIconView->append(
sId, elem->maDisplayName, elem->maImage);
1394 if (
mxView->get_visible())
1396 std::unique_ptr<weld::TreeIter> xFirst =
mxView->make_iterator();
1397 if (
mxView->get_iter_first(*xFirst))
1400 mxView->set_cursor(*xFirst);
1407 std::unique_ptr<weld::TreeIter> xFirst =
mxIconView->make_iterator();
1421 ::osl::MutexGuard aGuard(
maMutex );
1439 ::osl::MutexGuard aGuard(
maMutex );
1457 ::osl::MutexGuard aGuard(
maMutex );
1495 return rValue.replaceAll(
u"\t",
u"%09");
1500 ::osl::MutexGuard aGuard(
maMutex );
1507 if ( ! elem->mbIsFolder )
1508 elem->maDisplaySize = CreateExactSizeText( elem->maSize );
1510 if ( ! elem->mbIsFolder || ! elem->mbIsVolume )
1514 elem->maDisplayDate = rLocaleData.
getDate( elem->maModDate )
1516 + rLocaleData.
getTime( elem->maModDate,
false );
1520 if ( elem->mbIsFolder )
1523 elem->mbIsRemoveable, elem->mbIsFloppy,
1524 elem->mbIsCompactDisc );
1535 ::osl::MutexGuard aGuard(
maMutex );
1542 mxView->ResetQuickSearch_Impl(
nullptr );
1544 std::unique_ptr<weld::TreeIter> xEntry(
mxView->make_iterator());
1545 bool bEntry =
mxView->get_cursor(xEntry.get());
1548 if (bEntry && !
mxView->get_id(*xEntry).isEmpty())
1549 aEntryURL = weld::fromId<SvtContentEntry*>(
mxView->get_id(*xEntry))->maURL;
1560 if (
nPos != -1 && nPos < mxView->n_children())
1577static bool CompareSortingData_Impl( std::unique_ptr<SortingData_Impl>
const & aOne, std::unique_ptr<SortingData_Impl>
const & aTwo )
1583 bool bEqual =
false;
1585 if ( aOne->mbIsFolder != aTwo->mbIsFolder )
1587 bRet = aOne->mbIsFolder;
1606 else if ( nComp > 0 )
1615 else if ( nComp > 0 )
1621 if ( aOne->maSize < aTwo->maSize )
1623 else if ( aOne->maSize > aTwo->maSize )
1629 if ( aOne->maModDate < aTwo->maModDate )
1631 else if ( aOne->maModDate > aTwo->maModDate )
1637 SAL_INFO(
"svtools.contnr",
"CompareSortingData_Impl: Compare unknown type!" );
1653 ::osl::MutexGuard aGuard(
maMutex );
1670 ::osl::MutexGuard aGuard(
maMutex );
1673 [&](
const std::unique_ptr<SortingData_Impl> & data) { return data->maTargetURL == rURL; }));
1678 const OUString& rTitle )
1680 ::osl::MutexGuard aGuard(
maMutex );
1683 [&](
const std::unique_ptr<SortingData_Impl> & data) { return data->maTargetURL == rURL; });
1686 (*aFoundElem)->SetNewTitle( rTitle );
1694 (*aFoundElem)->maTargetURL = rURL;
1700 ::osl::MutexGuard aGuard(
maMutex );
1702 std::unique_ptr<SortingData_Impl>
pData(
new SortingData_Impl);
1704 pData->SetNewTitle( rTitle );
1706 pData->mbIsFolder =
true;
1707 pData->maTargetURL = rURL;
1729 ::osl::MutexGuard aGuard(
maMutex );
1732 [&](
const std::unique_ptr<SortingData_Impl> & data) { return data->maTargetURL == rURL; });
1733 return aFoundElem !=
maContent.end() ? std::distance(
maContent.begin(), aFoundElem) : -1;
1758 ::osl::MutexGuard aGuard(
maMutex );
1761 sal_uInt32 nStart =
nIndex;
1765 if (
pData->GetLowerTitle().startsWith( rTitle ) )
1776 if (
pData->GetLowerTitle().startsWith( rTitle ) )
1786 void SAL_CALL CallbackTimer::onShot()
1788 OSL_ENSURE( m_pTimeoutHandler,
"CallbackTimer::onShot: nobody interested in?" );
1791 pHandler->onTimeout();
1797 if (
mpImpl->mxView->get_visible())
1798 mpImpl->mxView->selected_foreach(func);
1800 mpImpl->mxIconView->selected_foreach(func);
1805 return mpImpl->mxView->getWidget();
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool setName(std::u16string_view rTheName, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
INetProtocol GetProtocol() const
const CollatorWrapper * getCaseCollator() const
OUString getDate(const Date &rDate) const
OUString getTime(const tools::Time &rTime, bool bSec=true, bool b100Sec=false) const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
Link< SvtFileView *, bool > maDoubleClickHandler
::rtl::Reference< ::svt::FileViewContentEnumerator > m_xContentEnumerator
::std::vector< std::unique_ptr< SortingData_Impl > > maContent
bool m_bRunningAsyncAction
DECL_LINK(ChangedHdl, weld::TreeView &, void)
void EntryRenamed(OUString &rURL, const OUString &rName)
virtual void enumerationDone(::svt::EnumerationResult eResult) override
SvtFileView * m_pAntiImpl
::svt::EnumerationResult m_eAsyncActionResult
DECL_LINK(RowActivatedHdl, weld::TreeView &, bool)
Link< void *, void > m_aCurrentAsyncActionHandler
Link< SvtFileView *, void > maOpenDoneLink
std::unique_ptr< ViewTabListBox_Impl > mxView
const SortingData_Impl & FolderInserted(const OUString &rURL, const OUString &rTitle)
bool SearchNextEntry(sal_uInt32 &nIndex, std::u16string_view rTitle, bool bWrapAround)
void SetViewMode(FileViewMode eMode)
::osl::Condition m_aAsyncActionFinished
void FilterFolderContent_Impl(std::u16string_view rFilter)
void implEnumerationSuccess()
weld::Window * m_pTopLevel
sal_Int16 mnSuspendSelectCallback
FileViewResult GetFolderContent_Impl(std::u16string_view rFolder, const FileViewAsyncAction *pAsyncDescriptor, const css::uno::Sequence< OUString > &rDenyList)
std::unique_ptr< weld::IconView > mxIconView
::rtl::Reference< ::salhelper::Timer > m_xCancelAsyncTimer
virtual ~SvtFileView_Impl()
int GetEntryPos(std::u16string_view rURL)
void Resort_Impl(sal_Int16 nColumn, bool bAscending)
void SetSelectHandler(const Link< SvtFileView *, void > &rHdl)
Reference< XCommandEnvironment > mxCmdEnv
SvtFileView_Impl(SvtFileView *pAntiImpl, weld::Window *pTopLevel, std::unique_ptr< weld::TreeView > xTreeView, std::unique_ptr< weld::IconView > xIconView, Reference< XCommandEnvironment > const &xEnv, FileViewFlags nFlags, bool bOnlyFolder)
void CancelRunningAsyncAction()
::std::vector< std::unique_ptr< SvtContentEntry > > maEntries
void SortFolderContent_Impl()
Link< SvtFileView *, void > m_aSelectHandler
bool m_bAsyncActionCancelled
void CreateDisplayText_Impl()
static OUString ReplaceTabWithString(const OUString &rValue)
void EnableDelete(bool bEnable)
IntlWrapper const aIntlWrapper
DECL_LINK(ItemActivatedHdl, weld::IconView &, bool)
void SetDoubleClickHandler(const Link< SvtFileView *, bool > &rHdl)
DECL_LINK(SelectionChangedHdl, weld::IconView &, void)
void EntryRemoved(std::u16string_view rURL)
int GetSortColumn() const
css::uno::Sequence< OUString > maDenyList
void set_help_id(const OUString &rHelpId)
SvtContentEntry * FirstSelected() const
const OUString & GetViewURL() const
FileViewResult PreviousLevel(const FileViewAsyncAction *pAsyncDescriptor)
initializes the view with the parent folder of the current folder
OUString get_help_id() const
void SetConfigString(std::u16string_view rCfgStr)
sal_uInt32 GetSelectionCount() const
void SetViewMode(FileViewMode eMode)
::std::vector< SvtContentEntry > GetContent()
bool GetParentURL(OUString &_rParentURL) const
void CancelRunningAsyncAction()
cancels a running async action (if any)
weld::Widget * identifier() const
void CreatedFolder(const OUString &rUrl, const OUString &rNewFolder)
std::unique_ptr< SvtFileView_Impl > mpImpl
void SetOpenDoneHdl(const Link< SvtFileView *, void > &rHdl)
SvtFileView(weld::Window *pTopLevel, std::unique_ptr< weld::TreeView > xTreeView, std::unique_ptr< weld::IconView > xIconView, bool bOnlyFolder, bool bMultiSelection, bool bShowType=true)
OUString GetURL(const weld::TreeIter &rEntry) const
void selected_foreach(const std::function< bool(weld::TreeIter &)> &func)
FileViewResult Initialize(const OUString &rFolderURL, const OUString &rFilter, const FileViewAsyncAction *pAsyncDescriptor, const css::uno::Sequence< OUString > &rDenyList)
initialize the view with the content of a folder given by URL, and apply an immediate filter
FileViewResult ExecuteFilter(const OUString &rFilter, const FileViewAsyncAction *pAsyncDescriptor)
reads the current content of the current folder again, and applies the given filter to it
void SetDoubleClickHdl(const Link< SvtFileView *, bool > &rHdl)
OUString get_selected_text() const
void SetSelectHdl(const Link< SvtFileView *, void > &rHdl)
OUString GetCurrentURL() const
void EnableDelete(bool bEnable)
OUString GetConfigString() const
const LocaleDataWrapper & GetLocaleData() const
virtual void SAL_CALL onShot()=0
css::uno::Any setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue)
css::uno::Reference< css::beans::XPropertySetInfo > getProperties()
css::uno::Reference< css::ucb::XCommandInfo > getCommands()
css::uno::Reference< css::ucb::XContent > get() const
sal_uInt16 GetCode() const
sal_uInt16 GetModifier() const
virtual void set_sort_indicator(TriState eState, int nColumn)=0
virtual int get_height_rows(int nRows) const=0
virtual void set_column_fixed_widths(const std::vector< int > &rWidths)=0
virtual int get_column_width(int nCol) const=0
void connect_column_clicked(const Link< int, void > &rLink)
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
#define DBG_ASSERT(sCon, aError)
#define DBG_TESTSOLARMUTEX()
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
RegionData_Impl * mpParent
#define QUICK_SEARCH_TIMEOUT
static bool CompareSortingData_Impl(std::unique_ptr< SortingData_Impl > const &aOne, std::unique_ptr< SortingData_Impl > const &aTwo)
IMPL_LINK(ViewTabListBox_Impl, KeyInputHdl, const KeyEvent &, rKEvt, bool)
IMPL_LINK_NOARG(ViewTabListBox_Impl, EditingEntryHdl, const weld::TreeIter &, bool)
static sal_Int16 gnColumn
static const CollatorWrapper * pCollatorWrapper
constexpr OUStringLiteral ALL_FILES_FILTER
FileViewResult
the result of an action in the FileView
constexpr sal_uInt16 KEYGROUP_ALPHA
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEYGROUP_NUM
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
std::unique_ptr< sal_Int32[]> pData
OString stripEnd(const OString &rIn, char c)
Reference< XComponentContext > getProcessComponentContext()
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
@ ERROR
the enumeration was successful
UNOTOOLS_DLLPUBLIC bool Kill(OUString const &url)
const LocaleDataWrapper & GetLocaleData()
OUString toId(const void *pValue)
uno::Reference< presentation::XSlideShowView > mxView
describes parameters for doing an action on the FileView asynchronously
sal_uInt32 nMaxTimeout
minimum time to wait for a result, in milliseconds
Link< void *, void > aFinishHandler
maximum time to wait for a result, in milliseconds, until eTimeout is returned
SVT_DLLPUBLIC OUString SvtResId(TranslateId aId)