20#include <config_features.h>
40#include <bitmaps.hlst>
43#include <com/sun/star/uno/Reference.hxx>
44#include <com/sun/star/lang/IllegalArgumentException.hpp>
46#include <com/sun/star/sdbc/XResultSet.hpp>
47#include <com/sun/star/sdbc/XRow.hpp>
48#include <com/sun/star/ucb/ContentCreationException.hpp>
49#include <com/sun/star/ucb/XContentAccess.hpp>
50#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
54#include <svx/strings.hrc>
55#include <osl/diagnose.h>
59using namespace ::
cppu;
70 : Thread(
"cuiSearchThread")
71 , mpProgress(pProgress)
73 , maStartURL(
std::move(aStartURL))
85 if (!aFileType.isEmpty())
88 sal_Int32 nBeginFormat, nEndFormat;
89 std::vector< OUString > aFormats;
91 if( !nFileNumber || nFileNumber == -1)
97 nBeginFormat = nEndFormat = nFileNumber;
99 for (sal_Int32
i = nBeginFormat;
i <= nEndFormat; ++
i)
110 const std::vector< OUString >& rFormats,
121 css::uno::Reference< XCommandEnvironment > xEnv;
125 aProps.getArray()[ 0 ] =
"IsFolder";
126 aProps.getArray()[ 1 ] =
"IsDocument";
127 css::uno::Reference< XResultSet > xResultSet(
128 aCnt.createCursor( aProps ) );
130 if( xResultSet.is() )
132 css::uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY_THROW );
133 css::uno::Reference< XRow > xRow( xResultSet, UNO_QUERY_THROW );
135 while( xResultSet->next() && schedule() )
137 INetURLObject aFoundURL( xContentAccess->queryContentIdentifierString() );
140 bool bFolder = xRow->getBoolean( 1 );
141 if ( xRow->wasNull() )
144 if( bRecursive && bFolder )
148 bool bDocument = xRow->getBoolean( 2 );
149 if ( xRow->wasNull() )
157 std::find( rFormats.begin(),
161 != rFormats.end() ) ||
162 std::find( rFormats.begin(),
181 catch (
const ContentCreationException&)
184 catch (
const css::uno::RuntimeException&)
187 catch (
const css::uno::Exception&)
193 : GenericDialogController(pParent,
"cui/ui/gallerysearchprogress.ui",
"GallerySearchProgress")
194 , startUrl_(
std::move(aStartURL))
195 , m_pTabPage(pTabPage)
196 , m_xFtSearchDir(m_xBuilder->weld_label(
"dir"))
197 , m_xFtSearchType(m_xBuilder->weld_label(
"file"))
198 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
210 if (m_aSearchThread.is())
211 m_aSearchThread->terminate();
216 if (m_aSearchThread.is())
217 m_aSearchThread->join();
234 Thread (
"cuiTakeThread" ),
235 mpProgress ( pProgress ),
236 mpBrowser ( pBrowser ),
237 mrTakenList ( rTakenList )
250 std::unique_ptr<GalleryProgress> pStatusProgress;
252 std::vector<int> aSelectedRows;
262 nEntries = aSelectedRows.size();
267 for( sal_Int32
i = 0;
i < nEntries && schedule(); ++
i )
278 pStatusProgress->Update(
i, nEntries - 1 );
287 pStatusProgress.reset();
294 : GenericDialogController(pParent,
"cui/ui/galleryapplyprogress.ui",
295 "GalleryApplyProgress")
297 , m_pTabPage(pTabPage)
298 , m_xFtTakeFile(m_xBuilder->weld_label(
"file"))
299 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
310 if (maTakeThread.is())
311 maTakeThread->terminate();
317 if (maTakeThread.is())
318 maTakeThread->join();
320 std::vector<bool, std::allocator<bool> > aRemoveEntries(m_pTabPage->aFoundList.size(),
false);
321 std::vector< OUString > aRemainingVector;
326 m_pTabPage->m_xLbxFound->select(-1);
327 m_pTabPage->m_xLbxFound->freeze();
331 aRemoveEntries[ maTakenList[
i ] ] =
true;
336 if( !aRemoveEntries[
i ] )
337 aRemainingVector.push_back( m_pTabPage->aFoundList[
i] );
339 std::swap(m_pTabPage->aFoundList, aRemainingVector);
340 aRemainingVector.clear();
344 if( !aRemoveEntries[
i ] )
345 aRemainingVector.push_back(m_pTabPage->m_xLbxFound->get_text(
i));
347 m_pTabPage->m_xLbxFound->clear();
349 m_pTabPage->m_xLbxFound->append_text(aRemainingVector[
i]);
350 aRemainingVector.clear();
352 m_pTabPage->m_xLbxFound->thaw();
353 m_pTabPage->SelectFoundHdl( *m_pTabPage->m_xLbxFound );
368 : GenericDialogController(pWindow,
"cui/ui/galleryupdateprogress.ui",
369 "GalleryUpdateProgress")
372 , m_xFtActualizeFile(m_xBuilder->weld_label(
"file"))
373 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
384 pIdle =
new Idle(
"ActualizeProgressTimeout");
389 return GenericDialogController::run();
394 pTheme->AbortActualize();
407 ClickCancelBtn(*m_xBtnCancel);
417 : GenericDialogController(pParent,
"cui/ui/gallerytitledialog.ui",
"GalleryTitleDialog")
418 , m_xEdit(m_xBuilder->weld_entry(
"entry"))
429 : GenericDialogController(pParent,
"cui/ui/gallerythemeiddialog.ui",
"GalleryThemeIDDialog")
431 , m_xBtnOk(m_xBuilder->weld_button(
"ok"))
432 , m_xLbResName(m_xBuilder->weld_combo_box(
"entry"))
450 Gallery* pGal = m_pThm->GetParent();
452 bool bDifferentThemeExists =
false;
460 OUString
aStr =
CuiResId( RID_CUISTR_GALLERY_ID_EXISTS ) +
464 VclMessageType::Info, VclButtonsType::Ok,
467 m_xLbResName->grab_focus();
468 bDifferentThemeExists =
true;
472 if (!bDifferentThemeExists)
479 "GalleryThemeDialog", pItemSet)
490 aText +=
" " +
CuiResId( RID_CUISTR_GALLERY_READONLY );
497 if (rId ==
"general")
504 :
SfxTabPage(pPage, pController,
"cui/ui/gallerygeneralpage.ui",
"GalleryGeneralPage", &
rSet)
506 , m_xFiMSImage(m_xBuilder->weld_image(
"image"))
507 , m_xEdtMSName(m_xBuilder->weld_entry(
"name"))
508 , m_xFtMSShowType(m_xBuilder->weld_label(
"type"))
509 , m_xFtMSShowPath(m_xBuilder->weld_label(
"location"))
510 , m_xFtMSShowContent(m_xBuilder->weld_label(
"contents"))
511 , m_xFtMSShowChangeDate(m_xBuilder->weld_label(
"modified"))
521 OUString aObjStr(
CuiResId( RID_CUISTR_GALLERYPROPS_OBJECT ) );
523 OUString aType(
SvxResId( RID_SVXSTR_GALLERYPROPS_GALTHEME ) );
531 aType +=
CuiResId( RID_CUISTR_GALLERY_READONLY );
538 aObjStr = aObjStr.getToken( 0,
';' );
540 aObjStr = aObjStr.getToken( 1,
';' );
542 aOutStr +=
" " + aObjStr;
558 sId = RID_SVXBMP_THEME_READONLY_BIG;
560 sId = RID_SVXBMP_THEME_DEFAULT_BIG;
562 sId = RID_SVXBMP_THEME_NORMAL_BIG;
575 return std::make_unique<TPGalleryThemeGeneral>(pPage, pController, *
rSet);
579 :
SfxTabPage(pPage, pController,
"cui/ui/galleryfilespage.ui",
"GalleryFilesPage", &
rSet)
581 , aPreviewTimer(
"cui TPGalleryThemeProperties aPreviewTimer")
582 , bEntriesFound(false)
583 , bInputAllowed(true)
585 , bSearchRecursive(false)
586 , xDialogListener(new ::
svt::DialogClosedListener())
587 , m_xCbbFileType(m_xBuilder->weld_combo_box(
"filetype"))
588 , m_xLbxFound(m_xBuilder->weld_tree_view(
"files"))
589 , m_xBtnSearch(m_xBuilder->weld_button(
"findfiles"))
590 , m_xBtnTake(m_xBuilder->weld_button(
"add"))
591 , m_xBtnTakeAll(m_xBuilder->weld_button(
"addall"))
592 , m_xCbxPreview(m_xBuilder->weld_check_button(
"preview"))
593 , m_xWndPreview(new
weld::CustomWeld(*m_xBuilder,
"image", m_aWndPreview))
597 m_xLbxFound->set_selection_mode(SelectionMode::Multiple);
626 if (
RET_OK == _nDlgResult )
643 return std::make_unique<TPGalleryThemeProperties>(pPage, pController, *
rSet);
648 OUString sRet = _rDisplayText;
649 if ( sRet.indexOf(
"(*.*)" ) == -1 )
651 sRet += OUString::Concat(
" (") + _rExtension +
")";
661 sal_uInt16
i, nKeyCount;
668 size_t entryIndex = 0;
670 bool bInList =
false;
672 OUString aExtensions;
678 if ( sWildcard.isEmpty() )
680 if ( aExtensions.indexOf( sWildcard ) == -1 )
682 if ( !aExtensions.isEmpty() )
684 aExtensions += sWildcard;
691 if ( pTestEntry->aFilterName == aExt )
701 std::unique_ptr<FilterEntry> pFilterEntry(
new FilterEntry);
702 pFilterEntry->aFilterName = aExt;
708#if HAVE_FEATURE_AVMEDIA
710 static constexpr OUStringLiteral
aWildcard =
u"*.";
713 for(
const std::pair<OUString,OUString> & aFilter : aFilters)
719 std::unique_ptr<FilterEntry> pFilterEntry(
new FilterEntry);
720 pFilterEntry->aFilterName = aFilter.second.getToken( 0,
';',
nIndex );
721 aFilterWildcard += pFilterEntry->aFilterName;
729 OUString aExtensions;
732 for (
i = 0;
i < nKeyCount; ++
i )
739 if ( sWildcard.isEmpty() )
741 if ( aExtensions.indexOf( sWildcard ) == -1 )
743 if ( !aExtensions.isEmpty() )
746 aExtensions += sWildcard;
751#if HAVE_FEATURE_AVMEDIA
753 for(
const std::pair<OUString,OUString> & aFilter : aFilters)
757 if ( !aExtensions.isEmpty() )
765 if (aExtensions.getLength() > 240)
769 std::unique_ptr<FilterEntry> pFilterEntry(
new FilterEntry);
770 pFilterEntry->aFilterName =
CuiResId(RID_CUISTR_GALLERY_ALLFILES);
771 pFilterEntry->aFilterName =
addExtension(pFilterEntry->aFilterName, aExtensions);
779 OUString aText(m_xCbbFileType->get_active_text());
781 if( bInputAllowed && ( aLastFilterName != aText ) )
783 aLastFilterName = aText;
786 std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog(
"QueryUpdateFileListDialog"));
794 auto xProgress = std::make_shared<SearchProgress>(
GetFrameWeld(),
this,
aURL);
802 xProgress->LaunchThread();
816 css::uno::Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
820 xFolderPicker->setDisplayDirectory(aDlgPathName);
822 aPreviewTimer.Stop();
824 css::uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY );
825 if ( xAsyncDlg.is() )
826 xAsyncDlg->startExecuteModal( xDialogListener );
829 if( xFolderPicker->execute() ==
RET_OK )
832 bSearchRecursive =
true;
837 catch (
const IllegalArgumentException&)
839 OSL_FAIL(
"Folder picker failed with illegal arguments" );
847 auto xTakeProgress = std::make_shared<TakeProgress>(
GetFrameWeld(),
this);
848 xTakeProgress->LaunchThread();
859 if ( !bInputAllowed )
862 aPreviewTimer.Stop();
863 aPreviewString.clear();
865 if (!m_xCbxPreview->get_active())
867 xMediaPlayer.clear();
868 m_aWndPreview.SetGraphic(
Graphic());
869 m_aWndPreview.Invalidate();
891#if HAVE_FEATURE_AVMEDIA
908 aPreviewTimer.Stop();
910 if (!m_xLbxFound->count_selected_rows() || !bEntriesFound)
930 aPreviewTimer.Stop();
941 bool bPreviewPossible =
false;
943 aPreviewTimer.Stop();
947 if (m_xLbxFound->count_selected_rows() == 1)
949 m_xCbxPreview->set_sensitive(
true);
950 bPreviewPossible =
true;
953 m_xCbxPreview->set_sensitive(
false);
955 if( !aFoundList.empty() )
956 m_xBtnTakeAll->set_sensitive(
true);
958 m_xBtnTakeAll->set_sensitive(
false);
961 if (bPreviewPossible && m_xCbxPreview->get_active())
962 aPreviewTimer.Start();
969 aPreviewTimer.Stop();
971 if (m_xLbxFound->count_selected_rows() == 1 && bEntriesFound)
972 ClickTakeHdl(*m_xBtnTake);
979 aPreviewTimer.Stop();
1003 DBG_ASSERT( xFolderPicker.is(),
"TPGalleryThemeProperties::DialogClosedHdl(): no folder picker" );
1005 OUString sURL = xFolderPicker->getDirectory();
1006 StartSearchFiles( sURL, pEvt->DialogResult );
Reference< XExecutableDialog > m_xDialog
virtual short run() override
virtual ~ActualizeProgress() override
std::unique_ptr< weld::Button > m_xBtnCancel
ActualizeProgress(weld::Widget *pWindow, GalleryTheme *pThm)
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)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static bool Reschedule(bool bHandleAllCurrentEvents=false)
void SetGraphic(const Graphic &rGraphic)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
virtual ~GalleryIdDialog() override
std::unique_ptr< weld::ComboBox > m_xLbResName
std::unique_ptr< weld::Button > m_xBtnOk
GalleryIdDialog(weld::Widget *pParent, GalleryTheme *pThm)
const OUString & GetThemeName() const
GalleryThemeProperties(weld::Widget *pParent, ExchangeData *pData, SfxItemSet const *pItemSet)
virtual void PageCreated(const OUString &rId, SfxTabPage &rPage) override
SAL_DLLPRIVATE void LockBroadcaster()
const OUString & GetName() const
bool InsertURL(const INetURLObject &rURL, sal_uInt32 nInsertPos=SAL_MAX_UINT32)
static void InsertAllThemes(weld::ComboBox &rListBox)
SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const
const INetURLObject & getThemeURL() const
size_t GetThemeCount() const
SAL_DLLPRIVATE const GalleryThemeEntry * GetThemeInfo(size_t nPos)
static OUString GetImportFormatShortName(GraphicFileFormat nFormat)
bool Detect(bool bExtendedInfo=false)
GraphicFileFormat GetFileFormat() const
OUString GetImportFormatShortName(sal_uInt16 nFormat)
static GraphicFilter & GetGraphicFilter()
OUString GetImportFormatName(sal_uInt16 nFormat)
sal_uInt16 GetImportFormatCount() const
OUString GetImportWildcard(sal_uInt16 nFormat, sal_Int32 nEntry)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetFileExtension() const
INetProtocol GetProtocol() const
virtual void Start(bool bStartTimer=true) override
OUString getDate(const Date &rDate) const
OUString getTime(const tools::Time &rTime, bool bSec=true, bool b100Sec=false) const
SearchProgress(weld::Window *pParent, TPGalleryThemeProperties *pTabPage, INetURLObject aStartURL)
void SetDirectory(const INetURLObject &rURL)
std::unique_ptr< weld::Label > m_xFtSearchType
std::unique_ptr< weld::Button > m_xBtnCancel
TPGalleryThemeProperties * m_pTabPage
rtl::Reference< SearchThread > m_aSearchThread
virtual ~SearchProgress() override
TPGalleryThemeProperties * mpBrowser
SearchProgress * mpProgress
void ImplSearch(const INetURLObject &rStartURL, const std::vector< OUString > &rFormats, bool bRecursive)
virtual ~SearchThread() override
SearchThread(SearchProgress *pProgress, TPGalleryThemeProperties *pBrowser, INetURLObject aStartURL)
virtual void execute() override
void AddTabPage(const OUString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
void RemoveTabPage(const OUString &rName)
weld::Window * GetFrameWeld() const
const LocaleDataWrapper & GetLocaleData() const
std::unique_ptr< weld::Image > m_xFiMSImage
std::unique_ptr< weld::Label > m_xFtMSShowChangeDate
std::unique_ptr< weld::Label > m_xFtMSShowPath
virtual bool FillItemSet(SfxItemSet *rSet) override
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
std::unique_ptr< weld::Entry > m_xEdtMSName
TPGalleryThemeGeneral(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
void SetXChgData(ExchangeData *pData)
std::unique_ptr< weld::Label > m_xFtMSShowContent
std::unique_ptr< weld::Label > m_xFtMSShowType
virtual ~TPGalleryThemeProperties() override
void SetXChgData(ExchangeData *pData)
void StartSearchFiles(std::u16string_view _rFolderURL, short _nDlgResult)
std::unique_ptr< weld::Button > m_xBtnTake
void EndSearchProgressHdl(sal_Int32 nResult)
static OUString addExtension(const OUString &, std::u16string_view)
std::unique_ptr< weld::TreeView > m_xLbxFound
std::unique_ptr< weld::CheckButton > m_xCbxPreview
DialogGalleryPreview m_aWndPreview
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
std::vector< OUString > aFoundList
TPGalleryThemeProperties(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
const ExchangeData * GetXChgData() const
std::unique_ptr< weld::Button > m_xBtnTakeAll
css::uno::Reference< css::media::XPlayer > xMediaPlayer
std::unique_ptr< weld::Button > m_xBtnSearch
std::unique_ptr< weld::ComboBox > m_xCbbFileType
rtl::Reference< ::svt::DialogClosedListener > xDialogListener
std::vector< std::unique_ptr< FilterEntry > > aFilterEntryList
std::unique_ptr< weld::Button > m_xBtnCancel
void SetFile(const INetURLObject &rURL)
TPGalleryThemeProperties * m_pTabPage
TakeProgress(weld::Window *pParent, TPGalleryThemeProperties *pTabPage)
rtl::Reference< TakeThread > maTakeThread
virtual ~TakeProgress() override
TokenList_impl maTakenList
TPGalleryThemeProperties * mpBrowser
TakeThread(TakeProgress *pProgress, TPGalleryThemeProperties *pBrowser, TokenList_impl &rTakenList)
virtual void execute() override
TakeProgress * mpProgress
virtual ~TakeThread() override
TokenList_impl & mrTakenList
void SetPriority(TaskPriority ePriority)
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
virtual ~TitleDialog() override
std::unique_ptr< weld::Entry > m_xEdit
TitleDialog(weld::Widget *pParent, const OUString &rOldText)
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
IMPL_LINK_NOARG(SearchProgress, ClickCancelBtn, weld::Button &, void)
IMPL_LINK(ActualizeProgress, TimeoutHdl, Timer *, _pTimer, void)
std::vector< sal_Int32 > TokenList_impl
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual sal_uInt32 GetId() const override
#define ERRCODE_IO_NOTEXISTSPATH
SVXCORE_DLLPUBLIC OUString GetReducedString(const INetURLObject &rURL, sal_Int32 nMaxLen)
#define LINK(Instance, Class, Member)
std::unique_ptr< sal_Int32[]> pData
Reference< XComponentContext > getProcessComponentContext()
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
tools::Time aThemeChangeTime