20 #include <config_features.h>
38 #include <bitmaps.hlst>
41 #include <com/sun/star/uno/Reference.hxx>
42 #include <com/sun/star/lang/IllegalArgumentException.hpp>
44 #include <com/sun/star/sdbc/XResultSet.hpp>
45 #include <com/sun/star/sdbc/XRow.hpp>
46 #include <com/sun/star/ucb/ContentCreationException.hpp>
47 #include <com/sun/star/ucb/XContentAccess.hpp>
48 #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
49 #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
51 #include <strings.hrc>
53 #include <svx/strings.hrc>
56 using namespace ::
cppu;
67 : Thread(
"cuiSearchThread")
68 , mpProgress(pProgress)
70 , maStartURL(rStartURL)
82 if (!aFileType.isEmpty())
85 sal_Int32 nBeginFormat, nEndFormat;
86 std::vector< OUString > aFormats;
88 if( !nFileNumber || nFileNumber == -1)
94 nBeginFormat = nEndFormat = nFileNumber;
96 for (sal_Int32
i = nBeginFormat;
i <= nEndFormat; ++
i)
107 const std::vector< OUString >& rFormats,
118 css::uno::Reference< XCommandEnvironment > xEnv;
122 aProps.getArray()[ 0 ] =
"IsFolder";
123 aProps.getArray()[ 1 ] =
"IsDocument";
124 css::uno::Reference< XResultSet > xResultSet(
125 aCnt.createCursor( aProps ) );
127 if( xResultSet.is() )
129 css::uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY_THROW );
130 css::uno::Reference< XRow >
xRow( xResultSet, UNO_QUERY_THROW );
132 while( xResultSet->next() && schedule() )
134 INetURLObject aFoundURL( xContentAccess->queryContentIdentifierString() );
135 DBG_ASSERT( aFoundURL.GetProtocol() != INetProtocol::NotValid,
"invalid URL" );
137 bool bFolder = xRow->getBoolean( 1 );
138 if ( xRow->wasNull() )
141 if( bRecursive && bFolder )
145 bool bDocument = xRow->getBoolean( 2 );
146 if ( xRow->wasNull() )
154 std::find( rFormats.begin(),
158 != rFormats.end() ) ||
159 std::find( rFormats.begin(),
161 aFoundURL.GetFileExtension().toAsciiLowerCase())
178 catch (
const ContentCreationException&)
181 catch (
const css::uno::RuntimeException&)
184 catch (
const css::uno::Exception&)
190 : GenericDialogController(pParent,
"cui/ui/gallerysearchprogress.ui",
"GallerySearchProgress")
191 , startUrl_(rStartURL)
192 , m_pTabPage(pTabPage)
193 , m_xFtSearchDir(m_xBuilder->weld_label(
"dir"))
194 , m_xFtSearchType(m_xBuilder->weld_label(
"file"))
195 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
207 if (m_aSearchThread.is())
208 m_aSearchThread->terminate();
213 if (m_aSearchThread.is())
214 m_aSearchThread->join();
223 m_aSearchThread->launch();
231 Thread (
"cuiTakeThread" ),
232 mpProgress ( pProgress ),
233 mpBrowser ( pBrowser ),
234 mrTakenList ( rTakenList )
247 std::unique_ptr<GalleryProgress> pStatusProgress;
249 std::vector<int> aSelectedRows;
259 nEntries = aSelectedRows.size();
264 for( sal_Int32
i = 0;
i < nEntries && schedule(); ++
i )
275 pStatusProgress->Update(
i, nEntries - 1 );
284 pStatusProgress.reset();
291 : GenericDialogController(pParent,
"cui/ui/galleryapplyprogress.ui",
292 "GalleryApplyProgress")
294 , m_pTabPage(pTabPage)
295 , m_xFtTakeFile(m_xBuilder->weld_label(
"file"))
296 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
307 if (maTakeThread.is())
308 maTakeThread->terminate();
314 if (maTakeThread.is())
315 maTakeThread->join();
317 std::vector<bool, std::allocator<bool> > aRemoveEntries(m_pTabPage->aFoundList.size(),
false);
318 std::vector< OUString > aRemainingVector;
323 m_pTabPage->m_xLbxFound->select(-1);
324 m_pTabPage->m_xLbxFound->freeze();
327 for( i = 0, nCount = maTakenList.size(); i < nCount; ++i )
328 aRemoveEntries[ maTakenList[ i ] ] =
true;
332 for( i = 0, nCount = aRemoveEntries.size(); i < nCount; ++i )
333 if( !aRemoveEntries[ i ] )
334 aRemainingVector.push_back( m_pTabPage->aFoundList[i] );
336 m_pTabPage->aFoundList.clear();
338 for( i = 0, nCount = aRemainingVector.size(); i < nCount; ++i )
339 m_pTabPage->aFoundList.push_back( aRemainingVector[ i ] );
341 aRemainingVector.clear();
344 for( i = 0, nCount = aRemoveEntries.size(); i < nCount; ++i )
345 if( !aRemoveEntries[ i ] )
346 aRemainingVector.push_back(m_pTabPage->m_xLbxFound->get_text(i));
348 m_pTabPage->m_xLbxFound->clear();
350 for( i = 0, nCount = aRemainingVector.size(); i < nCount; ++i )
351 m_pTabPage->m_xLbxFound->append_text(aRemainingVector[i]);
353 aRemainingVector.clear();
355 m_pTabPage->m_xLbxFound->thaw();
356 m_pTabPage->SelectFoundHdl( *m_pTabPage->m_xLbxFound );
367 maTakeThread->launch();
371 : GenericDialogController(pWindow,
"cui/ui/galleryupdateprogress.ui",
372 "GalleryUpdateProgress")
375 , m_xFtActualizeFile(m_xBuilder->weld_label(
"file"))
376 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
387 pIdle =
new Idle(
"ActualizeProgressTimeout");
392 return GenericDialogController::run();
397 pTheme->AbortActualize();
410 ClickCancelBtn(*m_xBtnCancel);
420 : GenericDialogController(pParent,
"cui/ui/gallerytitledialog.ui",
"GalleryTitleDialog")
421 , m_xEdit(m_xBuilder->weld_entry(
"entry"))
432 : GenericDialogController(pParent,
"cui/ui/gallerythemeiddialog.ui",
"GalleryThemeIDDialog")
434 , m_xBtnOk(m_xBuilder->weld_button(
"ok"))
435 , m_xLbResName(m_xBuilder->weld_combo_box(
"entry"))
453 Gallery* pGal = m_pThm->GetParent();
454 const sal_uInt32
nId = GetId();
455 bool bDifferentThemeExists =
false;
463 OUString
aStr =
CuiResId( RID_SVXSTR_GALLERY_ID_EXISTS ) +
467 VclMessageType::Info, VclButtonsType::Ok,
470 m_xLbResName->grab_focus();
471 bDifferentThemeExists =
true;
475 if (!bDifferentThemeExists)
482 "GalleryThemeDialog", pItemSet)
493 aText +=
" " +
CuiResId( RID_SVXSTR_GALLERY_READONLY );
500 if (rId ==
"general")
507 :
SfxTabPage(pPage, pController,
"cui/ui/gallerygeneralpage.ui",
"GalleryGeneralPage", &rSet)
509 , m_xFiMSImage(m_xBuilder->weld_image(
"image"))
510 , m_xEdtMSName(m_xBuilder->weld_entry(
"name"))
511 , m_xFtMSShowType(m_xBuilder->weld_label(
"type"))
512 , m_xFtMSShowPath(m_xBuilder->weld_label(
"location"))
513 , m_xFtMSShowContent(m_xBuilder->weld_label(
"contents"))
514 , m_xFtMSShowChangeDate(m_xBuilder->weld_label(
"modified"))
524 OUString aObjStr(
CuiResId( RID_SVXSTR_GALLERYPROPS_OBJECT ) );
526 OUString aType(
SvxResId( RID_SVXSTR_GALLERYPROPS_GALTHEME ) );
534 aType +=
CuiResId( RID_SVXSTR_GALLERY_READONLY );
541 aObjStr = aObjStr.getToken( 0,
';' );
543 aObjStr = aObjStr.getToken( 1,
';' );
545 aOutStr +=
" " + aObjStr;
561 sId = RID_SVXBMP_THEME_READONLY_BIG;
563 sId = RID_SVXBMP_THEME_DEFAULT_BIG;
565 sId = RID_SVXBMP_THEME_NORMAL_BIG;
578 return std::make_unique<TPGalleryThemeGeneral>(pPage, pController, *rSet);
582 :
SfxTabPage(pPage, pController,
"cui/ui/galleryfilespage.ui",
"GalleryFilesPage", &rSet)
584 , bEntriesFound(false)
585 , bInputAllowed(true)
587 , bSearchRecursive(false)
588 , xDialogListener(new ::
svt::DialogClosedListener())
589 , m_xCbbFileType(m_xBuilder->weld_combo_box(
"filetype"))
590 , m_xLbxFound(m_xBuilder->weld_tree_view(
"files"))
591 , m_xBtnSearch(m_xBuilder->weld_button(
"findfiles"))
592 , m_xBtnTake(m_xBuilder->weld_button(
"add"))
593 , m_xBtnTakeAll(m_xBuilder->weld_button(
"addall"))
594 , m_xCbxPreview(m_xBuilder->weld_check_button(
"preview"))
595 , m_xWndPreview(new
weld::CustomWeld(*m_xBuilder,
"image", m_aWndPreview))
599 m_xLbxFound->set_selection_mode(SelectionMode::Multiple);
628 if (
RET_OK == _nDlgResult )
645 return std::make_unique<TPGalleryThemeProperties>(pPage, pController, *rSet);
650 OUString sRet = _rDisplayText;
651 if ( sRet.indexOf(
"(*.*)" ) == -1 )
653 sRet += OUString::Concat(
" (") + _rExtension +
")";
663 sal_uInt16
i, nKeyCount;
670 size_t entryIndex = 0;
672 bool bInList =
false;
674 OUString aExtensions;
680 if ( sWildcard.isEmpty() )
682 if ( aExtensions.indexOf( sWildcard ) == -1 )
684 if ( !aExtensions.isEmpty() )
686 aExtensions += sWildcard;
693 if ( pTestEntry->aFilterName == aExt )
703 std::unique_ptr<FilterEntry> pFilterEntry(
new FilterEntry);
704 pFilterEntry->aFilterName = aExt;
710 #if HAVE_FEATURE_AVMEDIA
712 static constexpr OUStringLiteral
aWildcard =
u"*.";
715 for(
const std::pair<OUString,OUString> & aFilter : aFilters)
719 OUString aFilterWildcard( aWildcard );
721 std::unique_ptr<FilterEntry> pFilterEntry(
new FilterEntry);
722 pFilterEntry->aFilterName = aFilter.second.getToken( 0,
';',
nIndex );
723 aFilterWildcard += pFilterEntry->aFilterName;
731 OUString aExtensions;
734 for ( i = 0; i < nKeyCount; ++i )
741 if ( sWildcard.isEmpty() )
743 if ( aExtensions.indexOf( sWildcard ) == -1 )
745 if ( !aExtensions.isEmpty() )
748 aExtensions += sWildcard;
753 #if HAVE_FEATURE_AVMEDIA
755 for(
const std::pair<OUString,OUString> & aFilter : aFilters)
759 if ( !aExtensions.isEmpty() )
761 aExtensions += aWildcard + aFilter.second.getToken( 0,
';',
nIndex );
767 if (aExtensions.getLength() > 240)
771 std::unique_ptr<FilterEntry> pFilterEntry(
new FilterEntry);
772 pFilterEntry->aFilterName =
CuiResId(RID_SVXSTR_GALLERY_ALLFILES);
773 pFilterEntry->aFilterName =
addExtension(pFilterEntry->aFilterName, aExtensions);
781 OUString aText(m_xCbbFileType->get_active_text());
783 if( bInputAllowed && ( aLastFilterName != aText ) )
785 aLastFilterName = aText;
788 std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog(
"QueryUpdateFileListDialog"));
796 auto xProgress = std::make_shared<SearchProgress>(
GetFrameWeld(),
this,
aURL);
804 xProgress->LaunchThread();
819 xFolderPicker = FolderPicker::create(xContext);
822 xFolderPicker->setDisplayDirectory(aDlgPathName);
824 aPreviewTimer.Stop();
826 css::uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY );
827 if ( xAsyncDlg.is() )
828 xAsyncDlg->startExecuteModal( xDialogListener.get() );
831 if( xFolderPicker->execute() ==
RET_OK )
834 bSearchRecursive =
true;
839 catch (
const IllegalArgumentException&)
841 OSL_FAIL(
"Folder picker failed with illegal arguments" );
849 auto xTakeProgress = std::make_shared<TakeProgress>(
GetFrameWeld(),
this);
850 xTakeProgress->LaunchThread();
861 if ( !bInputAllowed )
864 aPreviewTimer.Stop();
865 aPreviewString.clear();
867 if (!m_xCbxPreview->get_active())
869 xMediaPlayer.clear();
870 m_aWndPreview.SetGraphic(
Graphic());
871 m_aWndPreview.Invalidate();
893 #if HAVE_FEATURE_AVMEDIA
910 aPreviewTimer.Stop();
912 if (!m_xLbxFound->count_selected_rows() || !bEntriesFound)
932 aPreviewTimer.Stop();
943 bool bPreviewPossible =
false;
945 aPreviewTimer.Stop();
949 if (m_xLbxFound->count_selected_rows() == 1)
951 m_xCbxPreview->set_sensitive(
true);
952 bPreviewPossible =
true;
955 m_xCbxPreview->set_sensitive(
false);
957 if( !aFoundList.empty() )
958 m_xBtnTakeAll->set_sensitive(
true);
960 m_xBtnTakeAll->set_sensitive(
false);
963 if (bPreviewPossible && m_xCbxPreview->get_active())
964 aPreviewTimer.Start();
971 aPreviewTimer.Stop();
973 if (m_xLbxFound->count_selected_rows() == 1 && bEntriesFound)
974 ClickTakeHdl(*m_xBtnTake);
981 aPreviewTimer.Stop();
1005 DBG_ASSERT( xFolderPicker.is(),
"TPGalleryThemeProperties::DialogClosedHdl(): no folder picker" );
1007 OUString sURL = xFolderPicker->getDirectory();
1008 StartSearchFiles( sURL, pEvt->DialogResult );
std::unique_ptr< weld::ComboBox > m_xCbbFileType
#define LINK(Instance, Class, Member)
const INetURLObject & getThemeURL() const
std::unique_ptr< weld::Button > m_xBtnOk
OUString GetReducedString(const INetURLObject &rURL, sal_Int32 nMaxLen)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
GalleryThemeProperties(weld::Widget *pParent, ExchangeData *pData, SfxItemSet const *pItemSet)
std::unique_ptr< weld::Button > m_xBtnCancel
std::unique_ptr< ContentProperties > pData
css::uno::Reference< css::media::XPlayer > xMediaPlayer
const ExchangeData * GetXChgData() const
std::unique_ptr< weld::CheckButton > m_xCbxPreview
SearchProgress(weld::Window *pParent, TPGalleryThemeProperties *pTabPage, const INetURLObject &rStartURL)
OUString GetImportFormatName(sal_uInt16 nFormat)
TPGalleryThemeGeneral(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
void RemoveTabPage(const OString &rName)
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void InsertAllThemes(weld::ComboBox &rListBox)
std::unique_ptr< weld::Image > m_xFiMSImage
TPGalleryThemeProperties * mpBrowser
virtual short run() override
TakeProgress(weld::Window *pParent, TPGalleryThemeProperties *pTabPage)
DialogGalleryPreview m_aWndPreview
TakeThread(TakeProgress *pProgress, TPGalleryThemeProperties *pBrowser, TokenList_impl &rTakenList)
void StartSearchFiles(const OUString &_rFolderURL, short _nDlgResult)
void SetXChgData(ExchangeData *pData)
#define ERRCODE_IO_NOTEXISTSPATH
std::unique_ptr< weld::Label > m_xFtMSShowContent
rtl::Reference< ::svt::DialogClosedListener > xDialogListener
TPGalleryThemeProperties(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
OUString GetImportWildcard(sal_uInt16 nFormat, sal_Int32 nEntry)
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
const LocaleDataWrapper & GetLocaleData() const
size_t GetThemeCount() const
virtual ~TitleDialog() override
GalleryIdDialog(weld::Widget *pParent, GalleryTheme *pThm)
virtual ~SearchProgress() override
OUString SvxResId(const char *pId)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void SetXChgData(ExchangeData *pData)
std::unique_ptr< weld::Label > m_xFtMSShowChangeDate
virtual void Start() override
void SetGraphic(const Graphic &rGraphic)
uno::Reference< sdbc::XRow > xRow
rtl::Reference< TakeThread > maTakeThread
TokenList_impl & mrTakenList
virtual ~GalleryIdDialog() override
SAL_DLLPRIVATE void LockBroadcaster()
std::unique_ptr< weld::Label > m_xFtMSShowPath
static OUString GetImportFormatShortName(GraphicFileFormat nFormat)
virtual ~ActualizeProgress() override
std::vector< OUString > aFoundList
static bool Reschedule(bool bHandleAllCurrentEvents=false)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
TPGalleryThemeProperties * mpBrowser
#define DBG_ASSERT(sCon, aError)
bool InsertURL(const INetURLObject &rURL, sal_uInt32 nInsertPos=SAL_MAX_UINT32)
std::unique_ptr< weld::Button > m_xBtnCancel
void SetDirectory(const INetURLObject &rURL)
TokenList_impl maTakenList
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
virtual void execute() override
std::unique_ptr< weld::Button > m_xBtnCancel
void SetFile(const INetURLObject &rURL)
static OUString addExtension(const OUString &, std::u16string_view)
SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const
std::unique_ptr< weld::TreeView > m_xLbxFound
std::unique_ptr< weld::Button > m_xBtnTakeAll
TPGalleryThemeProperties * m_pTabPage
void SetTimeout(sal_uInt64 nTimeoutMs)
OUString CuiResId(const char *pKey)
std::unique_ptr< weld::Entry > m_xEdit
std::unique_ptr< weld::ComboBox > m_xLbResName
tools::Time aThemeChangeTime
OUString GetImportFormatShortName(sal_uInt16 nFormat)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString getDate(const Date &rDate) const
std::vector< std::unique_ptr< FilterEntry > > aFilterEntryList
virtual void execute() override
weld::Window * GetFrameWeld() const
virtual ~TakeThread() override
TakeProgress * mpProgress
TPGalleryThemeProperties * m_pTabPage
TitleDialog(weld::Widget *pParent, const OUString &rOldText)
std::unique_ptr< weld::Button > m_xBtnSearch
sal_uInt16 GetImportFormatCount() const
SAL_DLLPRIVATE const GalleryThemeEntry * GetThemeInfo(size_t nPos)
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
IMPL_LINK(ActualizeProgress, TimeoutHdl, Timer *, _pTimer, void)
Reference< XExecutableDialog > m_xDialog
virtual ~TPGalleryThemeProperties() override
Reference< XComponentContext > getProcessComponentContext()
void SetInvokeHandler(const Link< Timer *, void > &rLink)
std::unique_ptr< weld::Label > m_xFtSearchType
ActualizeProgress(weld::Widget *pWindow, GalleryTheme *pThm)
std::unique_ptr< weld::Entry > m_xEdtMSName
virtual ~TakeProgress() override
IMPL_LINK_NOARG(SearchProgress, ClickCancelBtn, weld::Button &, void)
void EndSearchProgressHdl(sal_Int32 nResult)
static GraphicFilter & GetGraphicFilter()
GraphicFileFormat GetFileFormat() const
std::unique_ptr< weld::Button > m_xBtnTake
void ImplSearch(const INetURLObject &rStartURL, const std::vector< OUString > &rFormats, bool bRecursive)
rtl::Reference< SearchThread > m_aSearchThread
void SetPriority(TaskPriority ePriority)
const OUString & GetName() const
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
SearchProgress * mpProgress
OUString getTime(const tools::Time &rTime, bool bSec=true, bool b100Sec=false) const
SearchThread(SearchProgress *pProgress, TPGalleryThemeProperties *pBrowser, const INetURLObject &rStartURL)
bool Detect(bool bExtendedInfo=false)
virtual ~SearchThread() override
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
const OUString & GetThemeName() const
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::Label > m_xFtMSShowType
std::vector< sal_uLong > TokenList_impl