weld GalleryFilesPage
Change-Id: I5fa399144fb12bb19c3b88bf99f99dad6a64e052
Reviewed-on: https://gerrit.libreoffice.org/64211
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx
index aacb1f3..f2eeb83 100644
--- a/cui/source/dialogs/cuigaldlg.cxx
+++ b/cui/source/dialogs/cuigaldlg.cxx
@@ -73,31 +73,29 @@ SearchThread::SearchThread( SearchProgress* pProgress,
{
}
SearchThread::~SearchThread()
{
}
void SearchThread::execute()
{
const OUString aFileType( mpBrowser->m_pCbbFileType->GetText() );
const OUString aFileType(mpBrowser->m_xCbbFileType->get_active_text());
if( !aFileType.isEmpty() )
if (!aFileType.isEmpty())
{
const sal_Int32 nFileNumber = mpBrowser->m_pCbbFileType->GetEntryPos( aFileType );
const int nFileNumber = mpBrowser->m_xCbbFileType->find_text(aFileType);
sal_Int32 nBeginFormat, nEndFormat;
std::vector< OUString > aFormats;
if( !nFileNumber || ( nFileNumber >= mpBrowser->m_pCbbFileType->GetEntryCount() ) )
if( !nFileNumber || nFileNumber == -1)
{
nBeginFormat = 1;
nEndFormat = mpBrowser->m_pCbbFileType->GetEntryCount() - 1;
nEndFormat = mpBrowser->m_xCbbFileType->get_count() - 1;
}
else
nBeginFormat = nEndFormat = nFileNumber;
for( sal_Int32 i = nBeginFormat; i <= nEndFormat; ++i )
for (sal_Int32 i = nBeginFormat; i <= nEndFormat; ++i)
aFormats.push_back( mpBrowser->aFilterEntryList[ i ]->aFilterName.toAsciiLowerCase() );
ImplSearch( maStartURL, aFormats, mpBrowser->bSearchRecursive );
@@ -171,9 +169,9 @@ void SearchThread::ImplSearch( const INetURLObject& rStartURL,
mpBrowser->aFoundList.push_back(
aFoundURL.GetMainURL( INetURLObject::DecodeMechanism::NONE )
);
mpBrowser->m_pLbxFound->InsertEntry(
GetReducedString( aFoundURL, 50 ),
static_cast<sal_uInt16>(mpBrowser->aFoundList.size()) - 1 );
mpBrowser->m_xLbxFound->insert_text(
mpBrowser->aFoundList.size() - 1,
GetReducedString(aFoundURL, 50));
}
}
}
@@ -279,16 +277,24 @@ void TakeThread::execute()
GalleryTheme* pThm = mpBrowser->GetXChgData()->pTheme;
std::unique_ptr<GalleryProgress> pStatusProgress;
std::vector<int> aSelectedRows;
{
SolarMutexGuard aGuard;
pStatusProgress.reset(new GalleryProgress);
nEntries = mpBrowser->bTakeAll ? mpBrowser->m_pLbxFound->GetEntryCount() : mpBrowser->m_pLbxFound->GetSelectedEntryCount();
if (mpBrowser->bTakeAll)
nEntries = mpBrowser->m_xLbxFound->n_children();
else
{
aSelectedRows = mpBrowser->m_xLbxFound->get_selected_rows();
nEntries = aSelectedRows.size();
}
pThm->LockBroadcaster();
}
for( sal_Int32 i = 0; i < nEntries && schedule(); ++i )
{
const sal_Int32 nPos = mpBrowser->bTakeAll ? i : mpBrowser->m_pLbxFound->GetSelectedEntryPos( i );
const sal_Int32 nPos = mpBrowser->bTakeAll ? i : aSelectedRows[i];
const INetURLObject aURL( mpBrowser->aFoundList[ nPos ]);
mrTakenList.push_back( static_cast<sal_uLong>(nPos) );
@@ -359,8 +365,8 @@ IMPL_LINK_NOARG(TakeProgress, CleanUpHdl, void*, void)
sal_uInt32 i, nCount;
GetParent()->EnterWait();
pBrowser->m_pLbxFound->SetUpdateMode( false );
pBrowser->m_pLbxFound->SetNoSelection();
pBrowser->m_xLbxFound->select(-1);
pBrowser->m_xLbxFound->freeze();
// mark all taken positions in aRemoveEntries
for( i = 0, nCount = maTakenList.size(); i < nCount; ++i )
@@ -382,17 +388,17 @@ IMPL_LINK_NOARG(TakeProgress, CleanUpHdl, void*, void)
// refill list box
for( i = 0, nCount = aRemoveEntries.size(); i < nCount; ++i )
if( !aRemoveEntries[ i ] )
aRemainingVector.push_back( pBrowser->m_pLbxFound->GetEntry( static_cast<sal_uInt16>(i) ) );
aRemainingVector.push_back(pBrowser->m_xLbxFound->get_text(i));
pBrowser->m_pLbxFound->Clear();
pBrowser->m_xLbxFound->clear();
for( i = 0, nCount = aRemainingVector.size(); i < nCount; ++i )
pBrowser->m_pLbxFound->InsertEntry( aRemainingVector[ i ] );
pBrowser->m_xLbxFound->append_text(aRemainingVector[i]);
aRemainingVector.clear();
pBrowser->m_pLbxFound->SetUpdateMode( true );
pBrowser->SelectFoundHdl( *pBrowser->m_pLbxFound );
pBrowser->m_xLbxFound->thaw();
pBrowser->SelectFoundHdl( *pBrowser->m_xLbxFound );
GetParent()->LeaveWait();
EndDialog( RET_OK );
@@ -653,57 +659,51 @@ VclPtr<SfxTabPage> TPGalleryThemeGeneral::Create(TabPageParent pParent, const Sf
return VclPtr<TPGalleryThemeGeneral>::Create(pParent, *rSet);
}
TPGalleryThemeProperties::TPGalleryThemeProperties( vcl::Window* pWindow, const SfxItemSet& rSet )
: SfxTabPage(pWindow, "GalleryFilesPage", "cui/ui/galleryfilespage.ui", &rSet)
TPGalleryThemeProperties::TPGalleryThemeProperties(TabPageParent pWindow, const SfxItemSet& rSet)
: SfxTabPage(pWindow, "cui/ui/galleryfilespage.ui", "GalleryFilesPage", &rSet)
, pData(nullptr)
, nFirstExtFilterPos(0)
, bEntriesFound(false)
, bInputAllowed(true)
, bTakeAll(false)
, bSearchRecursive(false)
, xDialogListener(new ::svt::DialogClosedListener())
, m_xCbbFileType(m_xBuilder->weld_combo_box("filetype"))
, m_xLbxFound(m_xBuilder->weld_tree_view("files"))
, m_xBtnSearch(m_xBuilder->weld_button("findfiles"))
, m_xBtnTake(m_xBuilder->weld_button("add"))
, m_xBtnTakeAll(m_xBuilder->weld_button("addall"))
, m_xCbxPreview(m_xBuilder->weld_check_button("preview"))
, m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "image", m_aWndPreview))
{
get(m_pCbbFileType, "filetype");
get(m_pLbxFound, "files");
Size aSize(LogicToPixel(Size(172, 156), MapMode(MapUnit::MapAppFont)));
m_pLbxFound->set_width_request(aSize.Width());
m_pLbxFound->set_height_request(aSize.Height());
m_pLbxFound->EnableMultiSelection(true);
get(m_pBtnSearch, "findfiles");
get(m_pBtnTake, "add");
get(m_pBtnTakeAll, "addall");
get(m_pCbxPreview, "preview");
get(m_pWndPreview, "image");
m_xLbxFound->set_size_request(m_xLbxFound->get_approximate_digit_width() * 35,
m_xLbxFound->get_height_rows(15));
m_xLbxFound->set_selection_mode(true);
xDialogListener->SetDialogClosedLink( LINK( this, TPGalleryThemeProperties, DialogClosedHdl ) );
}
void TPGalleryThemeProperties::SetXChgData( ExchangeData* _pData )
{
pData = _pData;
aPreviewTimer.SetInvokeHandler( LINK( this, TPGalleryThemeProperties, PreviewTimerHdl ) );
aPreviewTimer.SetTimeout( 500 );
m_pBtnSearch->SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickSearchHdl));
m_pBtnTake->SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickTakeHdl));
m_pBtnTakeAll->SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickTakeAllHdl));
m_pCbxPreview->SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickPreviewHdl));
m_pCbbFileType->SetSelectHdl(LINK(this, TPGalleryThemeProperties, SelectFileTypeHdl));
m_pCbbFileType->EnableDDAutoWidth( false );
m_pLbxFound->SetDoubleClickHdl(LINK(this, TPGalleryThemeProperties, DClickFoundHdl));
m_pLbxFound->SetSelectHdl(LINK(this, TPGalleryThemeProperties, SelectFoundHdl));
m_pLbxFound->InsertEntry(CuiResId(RID_SVXSTR_GALLERY_NOFILES));
m_pLbxFound->Show();
m_xBtnSearch->connect_clicked(LINK(this, TPGalleryThemeProperties, ClickSearchHdl));
m_xBtnTake->connect_clicked(LINK(this, TPGalleryThemeProperties, ClickTakeHdl));
m_xBtnTakeAll->connect_clicked(LINK(this, TPGalleryThemeProperties, ClickTakeAllHdl));
m_xCbxPreview->connect_toggled(LINK(this, TPGalleryThemeProperties, ClickPreviewHdl));
m_xCbbFileType->connect_changed(LINK(this, TPGalleryThemeProperties, SelectFileTypeHdl));
m_xLbxFound->connect_row_activated(LINK(this, TPGalleryThemeProperties, DClickFoundHdl));
m_xLbxFound->connect_changed(LINK(this, TPGalleryThemeProperties, SelectFoundHdl));
m_xLbxFound->append_text(CuiResId(RID_SVXSTR_GALLERY_NOFILES));
m_xLbxFound->show();
FillFilterList();
m_pBtnTake->Enable();
m_pBtnTakeAll->Disable();
m_pCbxPreview->Disable();
m_xBtnTake->set_sensitive(true);
m_xBtnTakeAll->set_sensitive(false);
m_xCbxPreview->set_sensitive(false);
}
void TPGalleryThemeProperties::StartSearchFiles( const OUString& _rFolderURL, short _nDlgResult )
{
if ( RET_OK == _nDlgResult )
@@ -714,37 +714,24 @@ void TPGalleryThemeProperties::StartSearchFiles( const OUString& _rFolderURL, sh
}
}
TPGalleryThemeProperties::~TPGalleryThemeProperties()
{
disposeOnce();
}
void TPGalleryThemeProperties::dispose()
{
xMediaPlayer.clear();
xDialogListener.clear();
aFilterEntryList.clear();
m_pCbbFileType.clear();
m_pLbxFound.clear();
m_pBtnSearch.clear();
m_pBtnTake.clear();
m_pBtnTakeAll.clear();
m_pCbxPreview.clear();
m_pWndPreview.clear();
SfxTabPage::dispose();
}
VclPtr<SfxTabPage> TPGalleryThemeProperties::Create( TabPageParent pParent, const SfxItemSet* rSet )
VclPtr<SfxTabPage> TPGalleryThemeProperties::Create(TabPageParent pParent, const SfxItemSet* rSet)
{
return VclPtr<TPGalleryThemeProperties>::Create( pParent.pParent, *rSet );
return VclPtr<TPGalleryThemeProperties>::Create(pParent, *rSet);
}
OUString TPGalleryThemeProperties::addExtension( const OUString& _rDisplayText, const OUString& _rExtension )
{
OUString sRet = _rDisplayText;
@@ -755,7 +742,6 @@ OUString TPGalleryThemeProperties::addExtension( const OUString& _rDisplayText,
return sRet;
}
void TPGalleryThemeProperties::FillFilterList()
{
GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
@@ -803,12 +789,8 @@ void TPGalleryThemeProperties::FillFilterList()
{
std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
pFilterEntry->aFilterName = aExt;
size_t pos = m_pCbbFileType->InsertEntry( aName );
if ( pos < aFilterEntryList.size() ) {
aFilterEntryList.insert( aFilterEntryList.begin() + pos, std::move(pFilterEntry) );
} else {
aFilterEntryList.push_back( std::move(pFilterEntry) );
}
m_xCbbFileType->append_text(aName);
aFilterEntryList.push_back(std::move(pFilterEntry));
}
}
@@ -827,21 +809,10 @@ void TPGalleryThemeProperties::FillFilterList()
std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
pFilterEntry->aFilterName = aFilter.second.getToken( 0, ';', nIndex );
aFilterWildcard += pFilterEntry->aFilterName;
nFirstExtFilterPos = m_pCbbFileType->InsertEntry(
addExtension( aFilter.first, aFilterWildcard )
);
if ( nFirstExtFilterPos < aFilterEntryList.size() ) {
aFilterEntryList.insert(
aFilterEntryList.begin() + nFirstExtFilterPos,
std::move(pFilterEntry)
);
} else {
aFilterEntryList.push_back( std::move(pFilterEntry) );
}
m_xCbbFileType->append_text(addExtension(aFilter.first, aFilterWildcard));
aFilterEntryList.push_back( std::move(pFilterEntry) );
}
}
#else
(void) nFirstExtFilterPos;
#endif
// 'All' filters
@@ -887,19 +858,15 @@ void TPGalleryThemeProperties::FillFilterList()
std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
pFilterEntry->aFilterName = CuiResId(RID_SVXSTR_GALLERY_ALLFILES);
pFilterEntry->aFilterName = addExtension( pFilterEntry->aFilterName, aExtensions );
size_t pos = m_pCbbFileType->InsertEntry( pFilterEntry->aFilterName, 0 );
m_pCbbFileType->SetText( pFilterEntry->aFilterName );
if ( pos < aFilterEntryList.size() ) {
aFilterEntryList.insert( aFilterEntryList.begin() + pos, std::move(pFilterEntry) );
} else {
aFilterEntryList.push_back( std::move(pFilterEntry) );
}
pFilterEntry->aFilterName = addExtension(pFilterEntry->aFilterName, aExtensions);
m_xCbbFileType->insert_text(0, pFilterEntry->aFilterName);
m_xCbbFileType->set_active(0);
aFilterEntryList.insert(aFilterEntryList.begin(), std::move(pFilterEntry));
}
IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFileTypeHdl, ComboBox&, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFileTypeHdl, weld::ComboBox&, void)
{
OUString aText( m_pCbbFileType->GetText() );
OUString aText(m_xCbbFileType->get_active_text());
if( bInputAllowed && ( aLastFilterName != aText ) )
{
@@ -917,9 +884,9 @@ void TPGalleryThemeProperties::SearchFiles()
VclPtrInstance<SearchProgress> pProgress( this, aURL );
aFoundList.clear();
m_pLbxFound->Clear();
m_xLbxFound->clear();
pProgress->SetFileType( m_pCbbFileType->GetText() );
pProgress->SetFileType( m_xCbbFileType->get_active_text() );
pProgress->SetDirectory( INetURLObject() );
pProgress->Update();
@@ -928,8 +895,7 @@ void TPGalleryThemeProperties::SearchFiles()
});
}
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickSearchHdl, Button*, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickSearchHdl, weld::Button&, void)
{
if( bInputAllowed )
{
@@ -966,7 +932,7 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickSearchHdl, Button*, void)
void TPGalleryThemeProperties::TakeFiles()
{
if( m_pLbxFound->GetSelectedEntryCount() || ( bTakeAll && bEntriesFound ) )
if (m_xLbxFound->count_selected_rows() || (bTakeAll && bEntriesFound))
{
VclPtrInstance<TakeProgress> pTakeProgress( this );
pTakeProgress->Update();
@@ -978,39 +944,38 @@ void TPGalleryThemeProperties::TakeFiles()
}
}
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickPreviewHdl, Button*, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickPreviewHdl, weld::ToggleButton&, void)
{
if ( bInputAllowed )
{
aPreviewTimer.Stop();
aPreviewString.clear();
if( !m_pCbxPreview->IsChecked() )
if (!m_xCbxPreview->get_active())
{
xMediaPlayer.clear();
m_pWndPreview->SetGraphic( Graphic() );
m_pWndPreview->Invalidate();
m_aWndPreview.SetGraphic(Graphic());
m_aWndPreview.Invalidate();
}
else
DoPreview();
}
}
void TPGalleryThemeProperties::DoPreview()
{
OUString aString( m_pLbxFound->GetSelectedEntry() );
int nIndex = m_xLbxFound->get_selected_index();
OUString aString(m_xLbxFound->get_text(nIndex));
if( aString != aPreviewString )
if (aString != aPreviewString)
{
INetURLObject _aURL( aFoundList[ m_pLbxFound->GetEntryPos( aString ) ] );
INetURLObject _aURL(aFoundList[nIndex]);
bInputAllowed = false;
if ( !m_pWndPreview->SetGraphic( _aURL ) )
if (!m_aWndPreview.SetGraphic(_aURL))
{
GetParent()->LeaveWait();
ErrorHandler::HandleError( ERRCODE_IO_NOTEXISTSPATH );
ErrorHandler::HandleError(ERRCODE_IO_NOTEXISTSPATH, GetDialogFrameWeld());
GetParent()->EnterWait();
}
#if HAVE_FEATURE_AVMEDIA
@@ -1026,14 +991,13 @@ void TPGalleryThemeProperties::DoPreview()
}
}
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeHdl, Button*, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeHdl, weld::Button&, void)
{
if( bInputAllowed )
{
aPreviewTimer.Stop();
if( !m_pLbxFound->GetSelectedEntryCount() || !bEntriesFound )
if (!m_xLbxFound->count_selected_rows() || !bEntriesFound)
{
SvxOpenGraphicDialog aDlg("Gallery", GetFrameWeld());
aDlg.EnableLink(false);
@@ -1050,8 +1014,7 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeHdl, Button*, void)
}
}
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeAllHdl, Button*, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeAllHdl, weld::Button&, void)
{
if( bInputAllowed )
{
@@ -1061,10 +1024,9 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeAllHdl, Button*, void)
}
}
IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFoundHdl, ListBox&, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFoundHdl, weld::TreeView&, void)
{
if( bInputAllowed )
if (bInputAllowed)
{
bool bPreviewPossible = false;
@@ -1072,38 +1034,36 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFoundHdl, ListBox&, void)
if( bEntriesFound )
{
if( m_pLbxFound->GetSelectedEntryCount() == 1 )
if (m_xLbxFound->count_selected_rows() == 1)
{
m_pCbxPreview->Enable();
m_xCbxPreview->set_sensitive(true);
bPreviewPossible = true;
}
else
m_pCbxPreview->Disable();
m_xCbxPreview->set_sensitive(false);
if( !aFoundList.empty() )
m_pBtnTakeAll->Enable();
m_xBtnTakeAll->set_sensitive(true);
else
m_pBtnTakeAll->Disable();
m_xBtnTakeAll->set_sensitive(false);
}
if( bPreviewPossible && m_pCbxPreview->IsChecked() )
if (bPreviewPossible && m_xCbxPreview->get_active())
aPreviewTimer.Start();
}
}
IMPL_LINK_NOARG(TPGalleryThemeProperties, DClickFoundHdl, ListBox&, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, DClickFoundHdl, weld::TreeView&, void)
{
if( bInputAllowed )
{
aPreviewTimer.Stop();
if (m_pLbxFound->GetSelectedEntryCount() == 1 && bEntriesFound)
ClickTakeHdl(nullptr);
if (m_xLbxFound->count_selected_rows() == 1 && bEntriesFound)
ClickTakeHdl(*m_xBtnTake);
}
}
IMPL_LINK_NOARG(TPGalleryThemeProperties, PreviewTimerHdl, Timer *, void)
{
aPreviewTimer.Stop();
@@ -1114,16 +1074,16 @@ void TPGalleryThemeProperties::EndSearchProgressHdl(sal_Int32 /*nResult*/)
{
if( !aFoundList.empty() )
{
m_pLbxFound->SelectEntryPos( 0 );
m_pBtnTakeAll->Enable();
m_pCbxPreview->Enable();
m_xLbxFound->select(0);
m_xBtnTakeAll->set_sensitive(true);
m_xCbxPreview->set_sensitive(true);
bEntriesFound = true;
}
else
{
m_pLbxFound->InsertEntry( CuiResId( RID_SVXSTR_GALLERY_NOFILES ) );
m_pBtnTakeAll->Disable();
m_pCbxPreview->Disable();
m_xLbxFound->append_text(CuiResId(RID_SVXSTR_GALLERY_NOFILES));
m_xBtnTakeAll->set_sensitive(false);
m_xCbxPreview->set_sensitive(false);
bEntriesFound = false;
}
}
diff --git a/cui/source/inc/cuigaldlg.hxx b/cui/source/inc/cuigaldlg.hxx
index 9b5231b..a6085e8 100644
--- a/cui/source/inc/cuigaldlg.hxx
+++ b/cui/source/inc/cuigaldlg.hxx
@@ -232,14 +232,6 @@ class TPGalleryThemeProperties : public SfxTabPage
friend class TakeProgress;
friend class TakeThread;
VclPtr<ComboBox> m_pCbbFileType;
VclPtr<ListBox> m_pLbxFound;
VclPtr<PushButton> m_pBtnSearch;
VclPtr<PushButton> m_pBtnTake;
VclPtr<PushButton> m_pBtnTakeAll;
VclPtr<CheckBox> m_pCbxPreview;
VclPtr<GalleryPreview> m_pWndPreview;
ExchangeData* pData;
std::vector<OUString> aFoundList;
std::vector< std::unique_ptr<FilterEntry> >
@@ -248,7 +240,6 @@ class TPGalleryThemeProperties : public SfxTabPage
OUString aLastFilterName;
OUString aPreviewString;
INetURLObject aURL;
sal_uInt16 nFirstExtFilterPos;
bool bEntriesFound;
bool bInputAllowed;
bool bTakeAll;
@@ -258,6 +249,15 @@ class TPGalleryThemeProperties : public SfxTabPage
css::uno::Reference< css::media::XPlayer > xMediaPlayer;
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker;
SvxGalleryPreview m_aWndPreview;
std::unique_ptr<weld::ComboBox> m_xCbbFileType;
std::unique_ptr<weld::TreeView> m_xLbxFound;
std::unique_ptr<weld::Button> m_xBtnSearch;
std::unique_ptr<weld::Button> m_xBtnTake;
std::unique_ptr<weld::Button> m_xBtnTakeAll;
std::unique_ptr<weld::CheckButton> m_xCbxPreview;
std::unique_ptr<weld::CustomWeld> m_xWndPreview;
virtual void Reset( const SfxItemSet* /*rSet*/ ) override {}
virtual bool FillItemSet( SfxItemSet* /*rSet*/ ) override { return true; }
static OUString addExtension( const OUString&, const OUString& );
@@ -268,19 +268,19 @@ class TPGalleryThemeProperties : public SfxTabPage
void DoPreview();
void EndSearchProgressHdl(sal_Int32 nResult);
DECL_LINK( ClickPreviewHdl, Button*, void );
DECL_LINK( ClickSearchHdl, Button*, void );
DECL_LINK( ClickTakeHdl, Button*, void );
DECL_LINK( ClickTakeAllHdl, Button*, void );
DECL_LINK( SelectFoundHdl, ListBox&, void );
DECL_LINK( SelectFileTypeHdl, ComboBox&, void );
DECL_LINK( DClickFoundHdl, ListBox&, void );
DECL_LINK( PreviewTimerHdl, Timer*, void );
DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void );
DECL_LINK(ClickPreviewHdl, weld::ToggleButton&, void);
DECL_LINK(ClickSearchHdl, weld::Button&, void);
DECL_LINK(ClickTakeHdl, weld::Button&, void);
DECL_LINK(ClickTakeAllHdl, weld::Button&, void);
DECL_LINK(SelectFoundHdl, weld::TreeView&, void);
DECL_LINK(SelectFileTypeHdl, weld::ComboBox&, void);
DECL_LINK(DClickFoundHdl, weld::TreeView&, void);
DECL_LINK(PreviewTimerHdl, Timer*, void);
DECL_LINK(DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void);
public:
TPGalleryThemeProperties( vcl::Window* pWindow, const SfxItemSet& rSet );
virtual ~TPGalleryThemeProperties() override;
TPGalleryThemeProperties(TabPageParent pWindow, const SfxItemSet& rSet);
virtual ~TPGalleryThemeProperties() override;
virtual void dispose() override;
void SetXChgData( ExchangeData* pData );
@@ -288,7 +288,7 @@ public:
void StartSearchFiles( const OUString& _rFolderURL, short _nDlgResult );
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rSet );
static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rSet);
};
#endif // INCLUDED_CUI_SOURCE_INC_CUIGALDLG_HXX
diff --git a/cui/uiconfig/ui/galleryfilespage.ui b/cui/uiconfig/ui/galleryfilespage.ui
index 9fd436d..456627d 100644
--- a/cui/uiconfig/ui/galleryfilespage.ui
+++ b/cui/uiconfig/ui/galleryfilespage.ui
@@ -1,8 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkTreeStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkGrid" id="GalleryFilesPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -15,6 +22,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">12</property>
<child>
<object class="GtkGrid" id="grid2">
@@ -26,10 +34,10 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="galleryfilespage|label1">_File type:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">filetype</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -37,16 +45,16 @@
</packing>
</child>
<child>
<object class="VclComboBoxText" id="filetype">
<object class="GtkComboBoxText" id="filetype">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="has_entry">True</property>
<property name="max_width_chars">30</property>
<property name="width_request">0</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxtext-entry">
<property name="can_focus">False</property>
<property name="width_chars">30</property>
<property name="activates_default">True</property>
</object>
</child>
</object>
@@ -62,20 +70,43 @@
</packing>
</child>
<child>
<object class="GtkTreeView" id="files:border">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1">
<property name="mode">multiple</property>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="files:border-atkobject">
<property name="AtkObject::accessible-name" translatable="yes" context="galleryfilespage|files-atkobject">Files Found</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="files">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1">
<property name="mode">multiple</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="types-atkobject">
<property name="AtkObject::accessible-name" translatable="yes" context="galleryfilespage|files-atkobject">Files Found</property>
</object>
</child>
</object>
</child>
</object>
@@ -116,14 +147,27 @@
</packing>
</child>
<child>
<object class="svxcorelo-GalleryPreview" id="image:border">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="image:border-atkobject">
<property name="AtkObject::accessible-name" translatable="yes" context="galleryfilespage|image-atkobject">Preview</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkDrawingArea" id="image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child internal-child="accessible">
<object class="AtkObject" id="image-atkobject">
<property name="AtkObject::accessible-name" translatable="yes" context="galleryfilespage|image-atkobject">Preview</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 9318e11..3777421 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -154,9 +154,6 @@
<glade-widget-class title="Mark Preview" name="swuilo-SwMarkPreview"
generic-name="Mark Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Gallery Preview" name="svxcorelo-GalleryPreview"
generic-name="Gallery Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Html Attribute Preview" name="sduilo-SdHtmlAttrPreview"
generic-name="Html Attribute Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
diff --git a/include/svx/galctrl.hxx b/include/svx/galctrl.hxx
index 16eda95..d9f5d4c 100644
--- a/include/svx/galctrl.hxx
+++ b/include/svx/galctrl.hxx
@@ -27,6 +27,7 @@
#include <vcl/menu.hxx>
#include <vcl/edit.hxx>
#include <vcl/combobox.hxx>
#include <vcl/customweld.hxx>
#include <svl/slstitm.hxx>
#include <vcl/transfer.hxx>
#include <svtools/valueset.hxx>
@@ -76,6 +77,26 @@ public:
static void PreviewMedia( const INetURLObject& rURL );
};
class SVX_DLLPUBLIC SvxGalleryPreview : public weld::CustomWidgetController
{
private:
GraphicObject aGraphicObj;
tools::Rectangle aPreviewRect;
SVX_DLLPRIVATE bool ImplGetGraphicCenterRect( const Graphic& rGraphic, tools::Rectangle& rResultRect ) const;
SVX_DLLPRIVATE void InitSettings();
SVX_DLLPRIVATE virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
public:
SvxGalleryPreview();
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
void SetGraphic( const Graphic& rGraphic ) { aGraphicObj.SetGraphic( rGraphic ); }
bool SetGraphic( const INetURLObject& );
};
class GalleryIconView : public ValueSet, public DropTargetHelper, public DragSourceHelper
{
using ValueSet::StartDrag;
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
index 1a95c13..08c3e60 100644
--- a/svx/source/gallery2/galctrl.cxx
+++ b/svx/source/gallery2/galctrl.cxx
@@ -51,8 +51,6 @@ GalleryPreview::GalleryPreview(vcl::Window* pParent, WinBits nStyle, GalleryThem
InitSettings();
}
VCL_BUILDER_FACTORY_CONSTRUCTOR(GalleryPreview, WB_TABSTOP)
Size GalleryPreview::GetOptimalSize() const
{
return LogicToPixel(Size(70, 88), MapMode(MapUnit::MapAppFont));
@@ -257,6 +255,90 @@ void GalleryPreview::PreviewMedia( const INetURLObject& rURL )
#endif
}
SvxGalleryPreview::SvxGalleryPreview()
{
}
void SvxGalleryPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
CustomWidgetController::SetDrawingArea(pDrawingArea);
Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(70, 88), MapMode(MapUnit::MapAppFont)));
pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
pDrawingArea->set_help_id(HID_GALLERY_WINDOW);
}
bool SvxGalleryPreview::SetGraphic( const INetURLObject& _aURL )
{
bool bRet = true;
Graphic aGraphic;
#if HAVE_FEATURE_AVMEDIA
if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ), "" ) )
{
aGraphic = BitmapEx(RID_SVXBMP_GALLERY_MEDIA);
}
else
#endif
{
GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
GalleryProgress aProgress( &rFilter );
if( rFilter.ImportGraphic( aGraphic, _aURL ) )
bRet = false;
}
SetGraphic( aGraphic );
Invalidate();
return bRet;
}
bool SvxGalleryPreview::ImplGetGraphicCenterRect( const Graphic& rGraphic, tools::Rectangle& rResultRect ) const
{
const Size aWinSize(GetOutputSizePixel());
Size aNewSize(GetDrawingArea()->get_ref_device().LogicToPixel(rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode()));
bool bRet = false;
if( aNewSize.Width() && aNewSize.Height() )
{
// scale to fit window
const double fGrfWH = static_cast<double>(aNewSize.Width()) / aNewSize.Height();
const double fWinWH = static_cast<double>(aWinSize.Width()) / aWinSize.Height();
if ( fGrfWH < fWinWH )
{
aNewSize.setWidth( static_cast<long>( aWinSize.Height() * fGrfWH ) );
aNewSize.setHeight( aWinSize.Height() );
}
else
{
aNewSize.setWidth( aWinSize.Width() );
aNewSize.setHeight( static_cast<long>( aWinSize.Width() / fGrfWH) );
}
const Point aNewPos( ( aWinSize.Width() - aNewSize.Width() ) >> 1,
( aWinSize.Height() - aNewSize.Height() ) >> 1 );
rResultRect = tools::Rectangle( aNewPos, aNewSize );
bRet = true;
}
return bRet;
}
void SvxGalleryPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
rRenderContext.SetBackground(Wallpaper(GALLERY_BG_COLOR));
if (ImplGetGraphicCenterRect(aGraphicObj.GetGraphic(), aPreviewRect))
{
const Point aPos( aPreviewRect.TopLeft() );
const Size aSize( aPreviewRect.GetSize() );
if( aGraphicObj.IsAnimated() )
aGraphicObj.StartAnimation(&rRenderContext, aPos, aSize);
else
aGraphicObj.Draw(&rRenderContext, aPos, aSize);
}
}
static void drawTransparenceBackground(vcl::RenderContext& rOut, const Point& rPos, const Size& rSize)
{