LibreOffice Module cui (master) 1
cuigaldlg.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <config_features.h>
21
22#include <sal/config.h>
23
24#include <algorithm>
25#include <cassert>
26
27#include <utility>
28#include <vcl/errinf.hxx>
29#include <ucbhelper/content.hxx>
30#include <vcl/svapp.hxx>
31#include <vcl/weld.hxx>
35#include <sfx2/opengrf.hxx>
36#include <vcl/graphicfilter.hxx>
37#include <svx/gallery1.hxx>
38#include <svx/galtheme.hxx>
39#include <cuigaldlg.hxx>
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>
51#include <dialmgr.hxx>
52#include <strings.hrc>
53#include <svx/dialmgr.hxx>
54#include <svx/strings.hrc>
55#include <osl/diagnose.h>
56#include <o3tl/string_view.hxx>
57
58using namespace ::ucbhelper;
59using namespace ::cppu;
60using namespace ::com::sun::star::lang;
61using namespace ::com::sun::star::sdbc;
62using namespace ::com::sun::star::ucb;
63using namespace ::com::sun::star::ui::dialogs;
64using namespace ::com::sun::star::uno;
65
66
69 INetURLObject aStartURL)
70 : Thread("cuiSearchThread")
71 , mpProgress(pProgress)
72 , mpBrowser(pBrowser)
73 , maStartURL(std::move(aStartURL))
74{
75}
76
78{
79}
80
82{
83 const OUString aFileType(mpBrowser->m_xCbbFileType->get_active_text());
84
85 if (!aFileType.isEmpty())
86 {
87 const int nFileNumber = mpBrowser->m_xCbbFileType->find_text(aFileType);
88 sal_Int32 nBeginFormat, nEndFormat;
89 std::vector< OUString > aFormats;
90
91 if( !nFileNumber || nFileNumber == -1)
92 {
93 nBeginFormat = 1;
94 nEndFormat = mpBrowser->m_xCbbFileType->get_count() - 1;
95 }
96 else
97 nBeginFormat = nEndFormat = nFileNumber;
98
99 for (sal_Int32 i = nBeginFormat; i <= nEndFormat; ++i)
100 aFormats.push_back( mpBrowser->aFilterEntryList[ i ]->aFilterName.toAsciiLowerCase() );
101
103 }
104
106}
107
108
110 const std::vector< OUString >& rFormats,
111 bool bRecursive )
112{
113 {
114 SolarMutexGuard aGuard;
115
116 mpProgress->SetDirectory( rStartURL );
117 }
118
119 try
120 {
121 css::uno::Reference< XCommandEnvironment > xEnv;
123 Sequence< OUString > aProps( 2 );
124
125 aProps.getArray()[ 0 ] = "IsFolder";
126 aProps.getArray()[ 1 ] = "IsDocument";
127 css::uno::Reference< XResultSet > xResultSet(
128 aCnt.createCursor( aProps ) );
129
130 if( xResultSet.is() )
131 {
132 css::uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY_THROW );
133 css::uno::Reference< XRow > xRow( xResultSet, UNO_QUERY_THROW );
134
135 while( xResultSet->next() && schedule() )
136 {
137 INetURLObject aFoundURL( xContentAccess->queryContentIdentifierString() );
138 DBG_ASSERT( aFoundURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
139
140 bool bFolder = xRow->getBoolean( 1 ); // property "IsFolder"
141 if ( xRow->wasNull() )
142 bFolder = false;
143
144 if( bRecursive && bFolder )
145 ImplSearch( aFoundURL, rFormats, true );
146 else
147 {
148 bool bDocument = xRow->getBoolean( 2 ); // property "IsDocument"
149 if ( xRow->wasNull() )
150 bDocument = false;
151
152 if( bDocument )
153 {
154 GraphicDescriptor aDesc( aFoundURL );
155
156 if( ( aDesc.Detect() &&
157 std::find( rFormats.begin(),
158 rFormats.end(),
160 aDesc.GetFileFormat() ).toAsciiLowerCase() )
161 != rFormats.end() ) ||
162 std::find( rFormats.begin(),
163 rFormats.end(),
164 aFoundURL.GetFileExtension().toAsciiLowerCase())
165 != rFormats.end() )
166 {
167 SolarMutexGuard aGuard;
168
169 mpBrowser->aFoundList.push_back(
171 );
172 mpBrowser->m_xLbxFound->insert_text(
173 mpBrowser->aFoundList.size() - 1,
174 GetReducedString(aFoundURL, 50));
175 }
176 }
177 }
178 }
179 }
180 }
181 catch (const ContentCreationException&)
182 {
183 }
184 catch (const css::uno::RuntimeException&)
185 {
186 }
187 catch (const css::uno::Exception&)
188 {
189 }
190}
191
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"))
199{
200 m_xFtSearchType->set_size_request(m_xFtSearchType->get_preferred_size().Width(), -1);
201 m_xBtnCancel->connect_clicked(LINK(this, SearchProgress, ClickCancelBtn));
202}
203
205{
206}
207
209{
210 if (m_aSearchThread.is())
211 m_aSearchThread->terminate();
212}
213
214IMPL_LINK_NOARG(SearchProgress, CleanUpHdl, void*, void)
215{
216 if (m_aSearchThread.is())
217 m_aSearchThread->join();
218
219 m_xDialog->response(RET_OK);
220}
221
223{
224 assert(!m_aSearchThread.is());
226 m_aSearchThread->launch();
227}
228
230 TakeProgress* pProgress,
231 TPGalleryThemeProperties* pBrowser,
232 TokenList_impl& rTakenList
233) :
234 Thread ( "cuiTakeThread" ),
235 mpProgress ( pProgress ),
236 mpBrowser ( pBrowser ),
237 mrTakenList ( rTakenList )
238{
239}
240
241
243{
244}
245
247{
248 sal_Int32 nEntries;
250 std::unique_ptr<GalleryProgress> pStatusProgress;
251
252 std::vector<int> aSelectedRows;
253
254 {
255 SolarMutexGuard aGuard;
256 pStatusProgress.reset(new GalleryProgress);
257 if (mpBrowser->bTakeAll)
258 nEntries = mpBrowser->m_xLbxFound->n_children();
259 else
260 {
261 aSelectedRows = mpBrowser->m_xLbxFound->get_selected_rows();
262 nEntries = aSelectedRows.size();
263 }
264 pThm->LockBroadcaster();
265 }
266
267 for( sal_Int32 i = 0; i < nEntries && schedule(); ++i )
268 {
269 const sal_Int32 nPos = mpBrowser->bTakeAll ? i : aSelectedRows[i];
271
272 mrTakenList.push_back( nPos );
273
274 {
275 SolarMutexGuard aGuard;
276
278 pStatusProgress->Update( i, nEntries - 1 );
279 pThm->InsertURL( aURL );
280 }
281 }
282
283 {
284 SolarMutexGuard aGuard;
285
286 pThm->UnlockBroadcaster();
287 pStatusProgress.reset();
288 }
289
291}
292
294 : GenericDialogController(pParent, "cui/ui/galleryapplyprogress.ui",
295 "GalleryApplyProgress")
296 , m_pParent(pParent)
297 , m_pTabPage(pTabPage)
298 , m_xFtTakeFile(m_xBuilder->weld_label("file"))
299 , m_xBtnCancel(m_xBuilder->weld_button("cancel"))
300{
301 m_xBtnCancel->connect_clicked(LINK(this, TakeProgress, ClickCancelBtn));
302}
303
305{
306}
307
309{
310 if (maTakeThread.is())
311 maTakeThread->terminate();
312}
313
314
315IMPL_LINK_NOARG(TakeProgress, CleanUpHdl, void*, void)
316{
317 if (maTakeThread.is())
318 maTakeThread->join();
319
320 std::vector<bool, std::allocator<bool> > aRemoveEntries(m_pTabPage->aFoundList.size(), false);
321 std::vector< OUString > aRemainingVector;
322 sal_uInt32 i, nCount;
323
324 std::unique_ptr<weld::WaitObject> xWait(new weld::WaitObject(m_pParent));
325
326 m_pTabPage->m_xLbxFound->select(-1);
327 m_pTabPage->m_xLbxFound->freeze();
328
329 // mark all taken positions in aRemoveEntries
330 for( i = 0, nCount = maTakenList.size(); i < nCount; ++i )
331 aRemoveEntries[ maTakenList[ i ] ] = true;
332 maTakenList.clear();
333
334 // refill found list
335 for( i = 0, nCount = aRemoveEntries.size(); i < nCount; ++i )
336 if( !aRemoveEntries[ i ] )
337 aRemainingVector.push_back( m_pTabPage->aFoundList[i] );
338
339 std::swap(m_pTabPage->aFoundList, aRemainingVector);
340 aRemainingVector.clear();
341
342 // refill list box
343 for( i = 0, nCount = aRemoveEntries.size(); i < nCount; ++i )
344 if( !aRemoveEntries[ i ] )
345 aRemainingVector.push_back(m_pTabPage->m_xLbxFound->get_text(i));
346
347 m_pTabPage->m_xLbxFound->clear();
348 for( i = 0, nCount = aRemainingVector.size(); i < nCount; ++i )
349 m_pTabPage->m_xLbxFound->append_text(aRemainingVector[i]);
350 aRemainingVector.clear();
351
352 m_pTabPage->m_xLbxFound->thaw();
353 m_pTabPage->SelectFoundHdl( *m_pTabPage->m_xLbxFound );
354
355 xWait.reset();
356
357 m_xDialog->response(RET_OK);
358}
359
361{
362 assert(!maTakeThread.is());
364 maTakeThread->launch();
365}
366
368 : GenericDialogController(pWindow, "cui/ui/galleryupdateprogress.ui",
369 "GalleryUpdateProgress")
370 , pIdle(nullptr)
371 , pTheme(pThm)
372 , m_xFtActualizeFile(m_xBuilder->weld_label("file"))
373 , m_xBtnCancel(m_xBuilder->weld_button("cancel"))
374{
375 m_xBtnCancel->connect_clicked(LINK(this, ActualizeProgress, ClickCancelBtn));
376}
377
379{
380}
381
383{
384 pIdle = new Idle("ActualizeProgressTimeout");
385 pIdle->SetInvokeHandler( LINK( this, ActualizeProgress, TimeoutHdl ) );
386 pIdle->SetPriority( TaskPriority::LOWEST );
387 pIdle->Start();
388
389 return GenericDialogController::run();
390}
391
393{
394 pTheme->AbortActualize();
395 m_xDialog->response(RET_OK);
396}
397
398IMPL_LINK( ActualizeProgress, TimeoutHdl, Timer*, _pTimer, void)
399{
400 if (_pTimer)
401 {
402 _pTimer->Stop();
403 delete _pTimer;
404 }
405
406 pTheme->Actualize(LINK(this, ActualizeProgress, ActualizeHdl), &aStatusProgress);
407 ClickCancelBtn(*m_xBtnCancel);
408}
409
410IMPL_LINK( ActualizeProgress, ActualizeHdl, const INetURLObject&, rURL, void )
411{
413 m_xFtActualizeFile->set_label(GetReducedString(rURL, 30));
414}
415
416TitleDialog::TitleDialog(weld::Widget* pParent, const OUString& rOldTitle)
417 : GenericDialogController(pParent, "cui/ui/gallerytitledialog.ui", "GalleryTitleDialog")
418 , m_xEdit(m_xBuilder->weld_entry("entry"))
419{
420 m_xEdit->set_text(rOldTitle);
421 m_xEdit->grab_focus();
422}
423
425{
426}
427
429 : GenericDialogController(pParent, "cui/ui/gallerythemeiddialog.ui", "GalleryThemeIDDialog")
430 , m_pThm(_pThm)
431 , m_xBtnOk(m_xBuilder->weld_button("ok"))
432 , m_xLbResName(m_xBuilder->weld_combo_box("entry"))
433{
434 m_xLbResName->append_text("!!! No Id !!!");
435
437
438 m_xLbResName->set_active(m_pThm->GetId());
439 m_xLbResName->grab_focus();
440
441 m_xBtnOk->connect_clicked(LINK(this, GalleryIdDialog, ClickOkHdl));
442}
443
445{
446}
447
449{
450 Gallery* pGal = m_pThm->GetParent();
451 const sal_uInt32 nId = GetId();
452 bool bDifferentThemeExists = false;
453
454 for( size_t i = 0, nCount = pGal->GetThemeCount(); i < nCount && !bDifferentThemeExists; i++ )
455 {
456 const GalleryThemeEntry* pInfo = pGal->GetThemeInfo( i );
457
458 if ((pInfo->GetId() == nId) && (pInfo->GetThemeName() != m_pThm->GetName()))
459 {
460 OUString aStr = CuiResId( RID_CUISTR_GALLERY_ID_EXISTS ) +
461 " (" + pInfo->GetThemeName() + ")";
462
463 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
464 VclMessageType::Info, VclButtonsType::Ok,
465 aStr));
466 xInfoBox->run();
467 m_xLbResName->grab_focus();
468 bDifferentThemeExists = true;
469 }
470 }
471
472 if (!bDifferentThemeExists)
473 m_xDialog->response(RET_OK);
474}
475
477 ExchangeData* _pData, SfxItemSet const * pItemSet)
478 : SfxTabDialogController(pParent, "cui/ui/gallerythemedialog.ui",
479 "GalleryThemeDialog", pItemSet)
480 , pData(_pData)
481{
482 AddTabPage("general", TPGalleryThemeGeneral::Create, nullptr);
484 if (pData->pTheme->IsReadOnly())
485 RemoveTabPage("files");
486
487 OUString aText = m_xDialog->get_title().replaceFirst( "%1", pData->pTheme->GetName() );
488
489 if (pData->pTheme->IsReadOnly())
490 aText += " " + CuiResId( RID_CUISTR_GALLERY_READONLY );
491
492 m_xDialog->set_title(aText);
493}
494
495void GalleryThemeProperties::PageCreated(const OUString& rId, SfxTabPage &rPage)
496{
497 if (rId == "general")
498 static_cast<TPGalleryThemeGeneral&>( rPage ).SetXChgData( pData );
499 else
500 static_cast<TPGalleryThemeProperties&>( rPage ).SetXChgData( pData );
501}
502
504 : SfxTabPage(pPage, pController, "cui/ui/gallerygeneralpage.ui", "GalleryGeneralPage", &rSet)
505 , pData(nullptr)
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"))
512{
513}
514
516{
517 pData = _pData;
518
519 GalleryTheme* pThm = pData->pTheme;
520 OUString aOutStr( OUString::number(pThm->GetObjectCount()) );
521 OUString aObjStr( CuiResId( RID_CUISTR_GALLERYPROPS_OBJECT ) );
522 OUString aAccess;
523 OUString aType( SvxResId( RID_SVXSTR_GALLERYPROPS_GALTHEME ) );
524 bool bReadOnly = pThm->IsReadOnly();
525
526 m_xEdtMSName->set_text(pThm->GetName());
527 m_xEdtMSName->set_editable(!bReadOnly);
528 m_xEdtMSName->set_sensitive(!bReadOnly);
529
530 if( pThm->IsReadOnly() )
531 aType += CuiResId( RID_CUISTR_GALLERY_READONLY );
532
533 m_xFtMSShowType->set_label(aType);
535
536 // singular or plural?
537 if ( 1 == pThm->GetObjectCount() )
538 aObjStr = aObjStr.getToken( 0, ';' );
539 else
540 aObjStr = aObjStr.getToken( 1, ';' );
541
542 aOutStr += " " + aObjStr;
543
544 m_xFtMSShowContent->set_label(aOutStr);
545
546 // get locale wrapper (singleton)
547 const SvtSysLocale aSysLocale;
548 const LocaleDataWrapper& aLocaleData = aSysLocale.GetLocaleData();
549
550 // ChangeDate/Time
551 aAccess = aLocaleData.getDate( pData->aThemeChangeDate ) + ", " + aLocaleData.getTime( pData->aThemeChangeTime );
552 m_xFtMSShowChangeDate->set_label(aAccess);
553
554 // set image
555 OUString sId;
556
557 if( pThm->IsReadOnly() )
558 sId = RID_SVXBMP_THEME_READONLY_BIG;
559 else if( pThm->IsDefault() )
560 sId = RID_SVXBMP_THEME_DEFAULT_BIG;
561 else
562 sId = RID_SVXBMP_THEME_NORMAL_BIG;
563
564 m_xFiMSImage->set_from_icon_name(sId);
565}
566
568{
569 pData->aEditedTitle = m_xEdtMSName->get_text();
570 return true;
571}
572
573std::unique_ptr<SfxTabPage> TPGalleryThemeGeneral::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
574{
575 return std::make_unique<TPGalleryThemeGeneral>(pPage, pController, *rSet);
576}
577
579 : SfxTabPage(pPage, pController, "cui/ui/galleryfilespage.ui", "GalleryFilesPage", &rSet)
580 , pData(nullptr)
581 , aPreviewTimer("cui TPGalleryThemeProperties aPreviewTimer")
582 , bEntriesFound(false)
583 , bInputAllowed(true)
584 , bTakeAll(false)
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))
594{
595 m_xLbxFound->set_size_request(m_xLbxFound->get_approximate_digit_width() * 35,
596 m_xLbxFound->get_height_rows(15));
597 m_xLbxFound->set_selection_mode(SelectionMode::Multiple);
598 xDialogListener->SetDialogClosedLink( LINK( this, TPGalleryThemeProperties, DialogClosedHdl ) );
599}
600
602{
603 pData = _pData;
604
605 aPreviewTimer.SetInvokeHandler( LINK( this, TPGalleryThemeProperties, PreviewTimerHdl ) );
607 m_xBtnSearch->connect_clicked(LINK(this, TPGalleryThemeProperties, ClickSearchHdl));
608 m_xBtnTake->connect_clicked(LINK(this, TPGalleryThemeProperties, ClickTakeHdl));
609 m_xBtnTakeAll->connect_clicked(LINK(this, TPGalleryThemeProperties, ClickTakeAllHdl));
610 m_xCbxPreview->connect_toggled(LINK(this, TPGalleryThemeProperties, ClickPreviewHdl));
611 m_xCbbFileType->connect_changed(LINK(this, TPGalleryThemeProperties, SelectFileTypeHdl));
612 m_xLbxFound->connect_row_activated(LINK(this, TPGalleryThemeProperties, DClickFoundHdl));
613 m_xLbxFound->connect_changed(LINK(this, TPGalleryThemeProperties, SelectFoundHdl));
614 m_xLbxFound->append_text(CuiResId(RID_CUISTR_GALLERY_NOFILES));
615 m_xLbxFound->show();
616
618
619 m_xBtnTake->set_sensitive(true);
620 m_xBtnTakeAll->set_sensitive(false);
621 m_xCbxPreview->set_sensitive(false);
622}
623
624void TPGalleryThemeProperties::StartSearchFiles( std::u16string_view _rFolderURL, short _nDlgResult )
625{
626 if ( RET_OK == _nDlgResult )
627 {
628 aURL = INetURLObject( _rFolderURL );
629 bSearchRecursive = true; // UI choice no longer possible, windows file picker allows no user controls
630 SearchFiles();
631 }
632}
633
635{
636 xMediaPlayer.clear();
637 xDialogListener.clear();
638 aFilterEntryList.clear();
639}
640
641std::unique_ptr<SfxTabPage> TPGalleryThemeProperties::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
642{
643 return std::make_unique<TPGalleryThemeProperties>(pPage, pController, *rSet);
644}
645
646OUString TPGalleryThemeProperties::addExtension( const OUString& _rDisplayText, std::u16string_view _rExtension )
647{
648 OUString sRet = _rDisplayText;
649 if ( sRet.indexOf( "(*.*)" ) == -1 )
650 {
651 sRet += OUString::Concat(" (") + _rExtension + ")";
652 }
653 return sRet;
654}
655
657{
659 OUString aExt;
660 OUString aName;
661 sal_uInt16 i, nKeyCount;
662
663 // graphic filters
664 for( i = 0, nKeyCount = rFilter.GetImportFormatCount(); i < nKeyCount; i++ )
665 {
666 aExt = rFilter.GetImportFormatShortName( i );
667 aName = rFilter.GetImportFormatName( i );
668 size_t entryIndex = 0;
669 FilterEntry* pTestEntry = aFilterEntryList.empty() ? nullptr : aFilterEntryList[ entryIndex ].get();
670 bool bInList = false;
671
672 OUString aExtensions;
673 int j = 0;
674 OUString sWildcard;
675 while( true )
676 {
677 sWildcard = rFilter.GetImportWildcard( i, j++ );
678 if ( sWildcard.isEmpty() )
679 break;
680 if ( aExtensions.indexOf( sWildcard ) == -1 )
681 {
682 if ( !aExtensions.isEmpty() )
683 aExtensions += ";";
684 aExtensions += sWildcard;
685 }
686 }
687 aName = addExtension( aName, aExtensions );
688
689 while( pTestEntry )
690 {
691 if ( pTestEntry->aFilterName == aExt )
692 {
693 bInList = true;
694 break;
695 }
696 pTestEntry = ( ++entryIndex < aFilterEntryList.size() )
697 ? aFilterEntryList[ entryIndex ].get() : nullptr;
698 }
699 if ( !bInList )
700 {
701 std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
702 pFilterEntry->aFilterName = aExt;
703 m_xCbbFileType->append_text(aName);
704 aFilterEntryList.push_back(std::move(pFilterEntry));
705 }
706 }
707
708#if HAVE_FEATURE_AVMEDIA
709 // media filters
710 static constexpr OUStringLiteral aWildcard = u"*.";
712
713 for(const std::pair<OUString,OUString> & aFilter : aFilters)
714 {
715 for( sal_Int32 nIndex = 0; nIndex >= 0; )
716 {
717 OUString aFilterWildcard( aWildcard );
718
719 std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
720 pFilterEntry->aFilterName = aFilter.second.getToken( 0, ';', nIndex );
721 aFilterWildcard += pFilterEntry->aFilterName;
722 m_xCbbFileType->append_text(addExtension(aFilter.first, aFilterWildcard));
723 aFilterEntryList.push_back( std::move(pFilterEntry) );
724 }
725 }
726#endif
727
728 // 'All' filters
729 OUString aExtensions;
730
731 // graphic filters
732 for ( i = 0; i < nKeyCount; ++i )
733 {
734 int j = 0;
735 OUString sWildcard;
736 while( true )
737 {
738 sWildcard = rFilter.GetImportWildcard( i, j++ );
739 if ( sWildcard.isEmpty() )
740 break;
741 if ( aExtensions.indexOf( sWildcard ) == -1 )
742 {
743 if ( !aExtensions.isEmpty() )
744 aExtensions += ";";
745
746 aExtensions += sWildcard;
747 }
748 }
749 }
750
751#if HAVE_FEATURE_AVMEDIA
752 // media filters
753 for(const std::pair<OUString,OUString> & aFilter : aFilters)
754 {
755 for( sal_Int32 nIndex = 0; nIndex >= 0; )
756 {
757 if ( !aExtensions.isEmpty() )
758 aExtensions += ";";
759 aExtensions += OUString::Concat(aWildcard) + o3tl::getToken(aFilter.second, 0, ';', nIndex );
760 }
761 }
762#endif
763
764#if defined(_WIN32)
765 if (aExtensions.getLength() > 240)
766 aExtensions = "*.*";
767#endif
768
769 std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
770 pFilterEntry->aFilterName = CuiResId(RID_CUISTR_GALLERY_ALLFILES);
771 pFilterEntry->aFilterName = addExtension(pFilterEntry->aFilterName, aExtensions);
772 m_xCbbFileType->insert_text(0, pFilterEntry->aFilterName);
773 m_xCbbFileType->set_active(0);
774 aFilterEntryList.insert(aFilterEntryList.begin(), std::move(pFilterEntry));
775}
776
778{
779 OUString aText(m_xCbbFileType->get_active_text());
780
781 if( bInputAllowed && ( aLastFilterName != aText ) )
782 {
783 aLastFilterName = aText;
784
785 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryupdategalleryfilelistdialog.ui"));
786 std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("QueryUpdateFileListDialog"));
787 if (xQuery->run() == RET_YES)
788 SearchFiles();
789 }
790}
791
793{
794 auto xProgress = std::make_shared<SearchProgress>(GetFrameWeld(), this, aURL);
795
796 aFoundList.clear();
797 m_xLbxFound->clear();
798
799 xProgress->SetFileType( m_xCbbFileType->get_active_text() );
800 xProgress->SetDirectory( INetURLObject() );
801
802 xProgress->LaunchThread();
803 weld::DialogController::runAsync(xProgress, [this](sal_Int32 nResult) {
804 EndSearchProgressHdl(nResult);
805 });
806}
807
809{
810 if( !bInputAllowed )
811 return;
812
813 try
814 {
815 // setup folder picker
816 css::uno::Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
817 xFolderPicker = sfx2::createFolderPicker(xContext, GetFrameWeld());
818
819 OUString aDlgPathName( SvtPathOptions().GetGraphicPath() );
820 xFolderPicker->setDisplayDirectory(aDlgPathName);
821
822 aPreviewTimer.Stop();
823
824 css::uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY );
825 if ( xAsyncDlg.is() )
826 xAsyncDlg->startExecuteModal( xDialogListener );
827 else
828 {
829 if( xFolderPicker->execute() == RET_OK )
830 {
831 aURL = INetURLObject( xFolderPicker->getDirectory() );
832 bSearchRecursive = true; // UI choice no longer possible, windows file picker allows no user controls
833 SearchFiles();
834 }
835 }
836 }
837 catch (const IllegalArgumentException&)
838 {
839 OSL_FAIL( "Folder picker failed with illegal arguments" );
840 }
841}
842
844{
845 if (m_xLbxFound->count_selected_rows() || (bTakeAll && bEntriesFound))
846 {
847 auto xTakeProgress = std::make_shared<TakeProgress>(GetFrameWeld(), this);
848 xTakeProgress->LaunchThread();
849 weld::DialogController::runAsync(xTakeProgress, [](sal_Int32 /*nResult*/) {
850 /* no postprocessing needed, pTakeProgress
851 will be disposed in TakeProgress::CleanupHdl */
852 });
853
854 }
855}
856
858{
859 if ( !bInputAllowed )
860 return;
861
862 aPreviewTimer.Stop();
863 aPreviewString.clear();
864
865 if (!m_xCbxPreview->get_active())
866 {
867 xMediaPlayer.clear();
868 m_aWndPreview.SetGraphic(Graphic());
869 m_aWndPreview.Invalidate();
870 }
871 else
872 DoPreview();
873}
874
876{
877 int nIndex = m_xLbxFound->get_selected_index();
878 OUString aString(m_xLbxFound->get_text(nIndex));
879
880 if (aString == aPreviewString)
881 return;
882
884 bInputAllowed = false;
885
886 if (!m_aWndPreview.SetGraphic(_aURL))
887 {
888 weld::WaitObject aWaitObject(GetFrameWeld());
890 }
891#if HAVE_FEATURE_AVMEDIA
893 {
895 if( xMediaPlayer.is() )
896 xMediaPlayer->start();
897 }
898#endif
899 bInputAllowed = true;
900 aPreviewString = aString;
901}
902
904{
905 if( !bInputAllowed )
906 return;
907
908 aPreviewTimer.Stop();
909
910 if (!m_xLbxFound->count_selected_rows() || !bEntriesFound)
911 {
912 SvxOpenGraphicDialog aDlg(CuiResId(RID_CUISTR_KEY_GALLERY_DIR), GetFrameWeld());
913 aDlg.EnableLink(false);
914 aDlg.AsLink(false);
915
916 if( !aDlg.Execute() )
917 pData->pTheme->InsertURL( INetURLObject( aDlg.GetPath() ) );
918 }
919 else
920 {
921 bTakeAll = false;
922 TakeFiles();
923 }
924}
925
927{
928 if( bInputAllowed )
929 {
930 aPreviewTimer.Stop();
931 bTakeAll = true;
932 TakeFiles();
933 }
934}
935
937{
938 if (!bInputAllowed)
939 return;
940
941 bool bPreviewPossible = false;
942
943 aPreviewTimer.Stop();
944
945 if( bEntriesFound )
946 {
947 if (m_xLbxFound->count_selected_rows() == 1)
948 {
949 m_xCbxPreview->set_sensitive(true);
950 bPreviewPossible = true;
951 }
952 else
953 m_xCbxPreview->set_sensitive(false);
954
955 if( !aFoundList.empty() )
956 m_xBtnTakeAll->set_sensitive(true);
957 else
958 m_xBtnTakeAll->set_sensitive(false);
959 }
960
961 if (bPreviewPossible && m_xCbxPreview->get_active())
962 aPreviewTimer.Start();
963}
964
966{
967 if( bInputAllowed )
968 {
969 aPreviewTimer.Stop();
970
971 if (m_xLbxFound->count_selected_rows() == 1 && bEntriesFound)
972 ClickTakeHdl(*m_xBtnTake);
973 }
974 return true;
975}
976
978{
979 aPreviewTimer.Stop();
980 DoPreview();
981}
982
984{
985 if( !aFoundList.empty() )
986 {
987 m_xLbxFound->select(0);
988 m_xBtnTakeAll->set_sensitive(true);
989 m_xCbxPreview->set_sensitive(true);
990 bEntriesFound = true;
991 }
992 else
993 {
994 m_xLbxFound->append_text(CuiResId(RID_CUISTR_GALLERY_NOFILES));
995 m_xBtnTakeAll->set_sensitive(false);
996 m_xCbxPreview->set_sensitive(false);
997 bEntriesFound = false;
998 }
999}
1000
1001IMPL_LINK( TPGalleryThemeProperties, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvt, void )
1002{
1003 DBG_ASSERT( xFolderPicker.is(), "TPGalleryThemeProperties::DialogClosedHdl(): no folder picker" );
1004
1005 OUString sURL = xFolderPicker->getDirectory();
1006 StartSearchFiles( sURL, pEvt->DialogResult );
1007}
1008
1009/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
virtual short run() override
Definition: cuigaldlg.cxx:382
virtual ~ActualizeProgress() override
Definition: cuigaldlg.cxx:378
std::unique_ptr< weld::Button > m_xBtnCancel
Definition: cuigaldlg.hxx:144
ActualizeProgress(weld::Widget *pWindow, GalleryTheme *pThm)
Definition: cuigaldlg.cxx:367
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
Definition: cuigaldlg.cxx:444
std::unique_ptr< weld::ComboBox > m_xLbResName
Definition: cuigaldlg.hxx:172
std::unique_ptr< weld::Button > m_xBtnOk
Definition: cuigaldlg.hxx:171
GalleryIdDialog(weld::Widget *pParent, GalleryTheme *pThm)
Definition: cuigaldlg.cxx:428
GalleryTheme * m_pThm
Definition: cuigaldlg.hxx:170
const OUString & GetThemeName() const
sal_uInt32 GetId() const
ExchangeData * pData
Definition: cuigaldlg.hxx:183
GalleryThemeProperties(weld::Widget *pParent, ExchangeData *pData, SfxItemSet const *pItemSet)
Definition: cuigaldlg.cxx:476
virtual void PageCreated(const OUString &rId, SfxTabPage &rPage) override
Definition: cuigaldlg.cxx:495
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)
void UnlockBroadcaster()
sal_uInt32 GetId() const
bool IsReadOnly() const
SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const
const INetURLObject & getThemeURL() const
bool IsDefault() 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)
Definition: cuigaldlg.cxx:192
void SetDirectory(const INetURLObject &rURL)
Definition: cuigaldlg.hxx:91
std::unique_ptr< weld::Label > m_xFtSearchType
Definition: cuigaldlg.hxx:78
std::unique_ptr< weld::Button > m_xBtnCancel
Definition: cuigaldlg.hxx:79
TPGalleryThemeProperties * m_pTabPage
Definition: cuigaldlg.hxx:75
INetURLObject startUrl_
Definition: cuigaldlg.hxx:74
void LaunchThread()
Definition: cuigaldlg.cxx:222
rtl::Reference< SearchThread > m_aSearchThread
Definition: cuigaldlg.hxx:76
virtual ~SearchProgress() override
Definition: cuigaldlg.cxx:204
TPGalleryThemeProperties * mpBrowser
Definition: cuigaldlg.hxx:54
SearchProgress * mpProgress
Definition: cuigaldlg.hxx:53
void ImplSearch(const INetURLObject &rStartURL, const std::vector< OUString > &rFormats, bool bRecursive)
Definition: cuigaldlg.cxx:109
virtual ~SearchThread() override
Definition: cuigaldlg.cxx:77
SearchThread(SearchProgress *pProgress, TPGalleryThemeProperties *pBrowser, INetURLObject aStartURL)
Definition: cuigaldlg.cxx:67
INetURLObject maStartURL
Definition: cuigaldlg.hxx:55
virtual void execute() override
Definition: cuigaldlg.cxx:81
void AddTabPage(const OUString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
void RemoveTabPage(const OUString &rName)
weld::Window * GetFrameWeld() const
const LocaleDataWrapper & GetLocaleData() const
OUString GetPath() const
ExchangeData * pData
Definition: cuigaldlg.hxx:194
std::unique_ptr< weld::Image > m_xFiMSImage
Definition: cuigaldlg.hxx:196
std::unique_ptr< weld::Label > m_xFtMSShowChangeDate
Definition: cuigaldlg.hxx:201
std::unique_ptr< weld::Label > m_xFtMSShowPath
Definition: cuigaldlg.hxx:199
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: cuigaldlg.cxx:567
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: cuigaldlg.cxx:573
std::unique_ptr< weld::Entry > m_xEdtMSName
Definition: cuigaldlg.hxx:197
TPGalleryThemeGeneral(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: cuigaldlg.cxx:503
void SetXChgData(ExchangeData *pData)
Definition: cuigaldlg.cxx:515
std::unique_ptr< weld::Label > m_xFtMSShowContent
Definition: cuigaldlg.hxx:200
std::unique_ptr< weld::Label > m_xFtMSShowType
Definition: cuigaldlg.hxx:198
virtual ~TPGalleryThemeProperties() override
Definition: cuigaldlg.cxx:634
void SetXChgData(ExchangeData *pData)
Definition: cuigaldlg.cxx:601
void StartSearchFiles(std::u16string_view _rFolderURL, short _nDlgResult)
Definition: cuigaldlg.cxx:624
ExchangeData * pData
Definition: cuigaldlg.hxx:218
std::unique_ptr< weld::Button > m_xBtnTake
Definition: cuigaldlg.hxx:239
void EndSearchProgressHdl(sal_Int32 nResult)
Definition: cuigaldlg.cxx:983
static OUString addExtension(const OUString &, std::u16string_view)
Definition: cuigaldlg.cxx:646
std::unique_ptr< weld::TreeView > m_xLbxFound
Definition: cuigaldlg.hxx:237
std::unique_ptr< weld::CheckButton > m_xCbxPreview
Definition: cuigaldlg.hxx:241
DialogGalleryPreview m_aWndPreview
Definition: cuigaldlg.hxx:235
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: cuigaldlg.cxx:641
std::vector< OUString > aFoundList
Definition: cuigaldlg.hxx:219
TPGalleryThemeProperties(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: cuigaldlg.cxx:578
const ExchangeData * GetXChgData() const
Definition: cuigaldlg.hxx:269
std::unique_ptr< weld::Button > m_xBtnTakeAll
Definition: cuigaldlg.hxx:240
css::uno::Reference< css::media::XPlayer > xMediaPlayer
Definition: cuigaldlg.hxx:232
std::unique_ptr< weld::Button > m_xBtnSearch
Definition: cuigaldlg.hxx:238
std::unique_ptr< weld::ComboBox > m_xCbbFileType
Definition: cuigaldlg.hxx:236
rtl::Reference< ::svt::DialogClosedListener > xDialogListener
Definition: cuigaldlg.hxx:231
std::vector< std::unique_ptr< FilterEntry > > aFilterEntryList
Definition: cuigaldlg.hxx:221
std::unique_ptr< weld::Button > m_xBtnCancel
Definition: cuigaldlg.hxx:122
void SetFile(const INetURLObject &rURL)
Definition: cuigaldlg.hxx:134
TPGalleryThemeProperties * m_pTabPage
Definition: cuigaldlg.hxx:118
void LaunchThread()
Definition: cuigaldlg.cxx:360
TakeProgress(weld::Window *pParent, TPGalleryThemeProperties *pTabPage)
Definition: cuigaldlg.cxx:293
rtl::Reference< TakeThread > maTakeThread
Definition: cuigaldlg.hxx:119
virtual ~TakeProgress() override
Definition: cuigaldlg.cxx:304
TokenList_impl maTakenList
Definition: cuigaldlg.hxx:120
TPGalleryThemeProperties * mpBrowser
Definition: cuigaldlg.hxx:99
TakeThread(TakeProgress *pProgress, TPGalleryThemeProperties *pBrowser, TokenList_impl &rTakenList)
Definition: cuigaldlg.cxx:229
virtual void execute() override
Definition: cuigaldlg.cxx:246
TakeProgress * mpProgress
Definition: cuigaldlg.hxx:98
virtual ~TakeThread() override
Definition: cuigaldlg.cxx:242
TokenList_impl & mrTakenList
Definition: cuigaldlg.hxx:100
void SetPriority(TaskPriority ePriority)
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
virtual ~TitleDialog() override
Definition: cuigaldlg.cxx:424
std::unique_ptr< weld::Entry > m_xEdit
Definition: cuigaldlg.hxx:160
TitleDialog(weld::Widget *pParent, const OUString &rOldText)
Definition: cuigaldlg.cxx:416
static css::uno::Reference< css::media::XPlayer > createPlayer(const OUString &rURL, const OUString &rReferer, const OUString *pMimeType=nullptr)
static FilterNameVector getMediaFilters()
static bool isMediaURL(std::u16string_view rURL, const OUString &rReferer, bool bDeep=false, rtl::Reference< PlayerListener > xPreferredPixelSizeListener=nullptr)
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
IMPL_LINK_NOARG(SearchProgress, ClickCancelBtn, weld::Button &, void)
Definition: cuigaldlg.cxx:208
IMPL_LINK(ActualizeProgress, TimeoutHdl, Timer *, _pTimer, void)
Definition: cuigaldlg.cxx:398
std::vector< sal_Int32 > TokenList_impl
Definition: cuigaldlg.hxx:40
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
int nCount
#define DBG_ASSERT(sCon, aError)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
URL aURL
virtual sal_uInt32 GetId() const override
float u
#define ERRCODE_IO_NOTEXISTSPATH
OUString aWildcard
bool bReadOnly
SVXCORE_DLLPUBLIC OUString GetReducedString(const INetURLObject &rURL, sal_Int32 nMaxLen)
sal_Int32 nIndex
OUString aName
sal_uInt16 nPos
aStr
std::unique_ptr< sal_Int32[]> pData
::std::vector< ::std::pair< OUString, OUString > > FilterNameVector
Reference< XComponentContext > getProcessComponentContext()
int i
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)
sal_Int16 nId
static SfxItemSet & rSet
GalleryTheme * pTheme
OUString aEditedTitle
tools::Time aThemeChangeTime
Date aThemeChangeDate
OUString sId
RET_OK
RET_YES