22#include <tools/datetime.hxx>
28#include <com/sun/star/ucb/ContentCreationException.hpp>
35#include <svx/strings.hrc>
40#include <com/sun/star/beans/PropertyValue.hpp>
43#include <bitmaps.hlst>
50 std::function<
void ()> aThemeSelectionHandler)
52 mxNewTheme(rBuilder.weld_button(
"insert")),
53 mxThemes(rBuilder.weld_tree_view(
"themelist")),
54 mxMoreGalleries(rBuilder.weld_button(
"btnMoreGalleries")),
55 mpGallery ( pGallery ),
57 aImgNormal ( RID_SVXBMP_THEME_NORMAL ),
58 aImgDefault ( RID_SVXBMP_THEME_DEFAULT ),
59 aImgReadOnly ( RID_SVXBMP_THEME_READONLY ),
60 maThemeSelectionHandler(
std::move(aThemeSelectionHandler))
92 static const bool bShowHiddenThemes = ( getenv(
"GALLERY_SHOW_HIDDEN_THEMES" ) != nullptr );
94 if( !(pEntry && ( !pEntry->
IsHidden() || bShowHiddenThemes )) )
97 const OUString* pImage;
121 catch(
const ucb::ContentCreationException& )
124 catch(
const uno::RuntimeException& )
127 catch(
const uno::Exception& )
139 bool bUpdateAllowed, bRenameAllowed, bRemoveAllowed;
140 static const bool bIdDialog = ( getenv(
"GALLERY_ENABLE_ID_DIALOG" ) != nullptr );
143 bUpdateAllowed = bRenameAllowed = bRemoveAllowed =
false;
146 bUpdateAllowed = bRenameAllowed =
true;
147 bRemoveAllowed =
false;
150 bUpdateAllowed = bRenameAllowed = bRemoveAllowed =
true;
153 o_aExec.emplace_back(
"update");
156 o_aExec.emplace_back(
"rename");
159 o_aExec.emplace_back(
"delete");
162 o_aExec.emplace_back(
"assign");
164 o_aExec.emplace_back(
"properties");
182 xThemePropertiesDialog->StartExecuteAsync([xThemePropertiesDialog,
this](sal_Int32 nResult){
184 xThemePropertiesDialog->disposeOnce();
189 xThemePropertiesDialog->StartExecuteAsync([xThemePropertiesDialog,
this](sal_Int32 nResult){
191 xThemePropertiesDialog->disposeOnce();
225 if ( bCreateNew && ( nRet !=
RET_OK ) )
243 if (rIdent ==
u"update")
250 aActualizeProgress->Execute();
253 else if (rIdent ==
u"delete")
256 std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog(
"QueryDeleteThemeDialog"));
260 else if (rIdent ==
u"rename")
263 const OUString aOldName( pTheme->
GetName() );
268 if( aDlg->Execute() ==
RET_OK )
270 const OUString aNewName( aDlg->GetTitle() );
272 if( !aNewName.isEmpty() && ( aNewName != aOldName ) )
274 OUString
aName( aNewName );
279 aName = aNewName +
" " + OUString::number(
nCount );
287 else if (rIdent ==
u"assign")
296 if( aDlg->Execute() ==
RET_OK )
297 pTheme->
SetId( aDlg->GetId(),
true );
302 else if (rIdent ==
u"properties")
312 switch( rGalleryHint.
GetType() )
320 const sal_Int32 nCurSelectPos =
mxThemes->get_selected_index();
326 if( nCurSelectPos == nRenameEntryPos )
342 const sal_Int32 nCurSelectPos =
mxThemes->get_selected_index();
345 if( nCurSelectPos == nCloseEntryPos )
347 if( nCurSelectPos < (
mxThemes->n_children() - 1 ) )
348 mxThemes->select( nCurSelectPos + 1 );
349 else if( nCurSelectPos )
350 mxThemes->select( nCurSelectPos - 1 );
366 css::uno::Sequence<css::beans::PropertyValue> aArgs{
376 std::vector<OUString> aExecVector;
377 ImplGetExecuteVector(aExecVector);
378 OUString sExecuteIdent;
379 bool bMod1 = rKEvt.GetKeyCode().IsMod1();
381 switch( rKEvt.GetKeyCode().GetCode() )
384 ClickNewThemeHdl(*mxNewTheme);
390 ClickNewThemeHdl(*mxNewTheme);
397 sExecuteIdent =
"update";
402 sExecuteIdent =
"delete";
408 sExecuteIdent =
"delete";
415 sExecuteIdent =
"rename";
422 sExecuteIdent =
"properties";
427 if (!sExecuteIdent.isEmpty() && (std::find( aExecVector.begin(), aExecVector.end(), sExecuteIdent) != aExecVector.end()))
429 ImplExecute(sExecuteIdent);
438 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
441 std::vector<OUString> aExecVector;
442 ImplGetExecuteVector(aExecVector);
444 if (aExecVector.empty())
448 std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu(
"menu"));
450 xMenu->set_visible(
"update", std::find( aExecVector.begin(), aExecVector.end(),
"update" ) != aExecVector.end());
451 xMenu->set_visible(
"rename", std::find( aExecVector.begin(), aExecVector.end(),
"rename" ) != aExecVector.end());
452 xMenu->set_visible(
"delete", std::find( aExecVector.begin(), aExecVector.end(),
"delete" ) != aExecVector.end());
453 xMenu->set_visible(
"assign", std::find( aExecVector.begin(), aExecVector.end(),
"assign" ) != aExecVector.end());
454 xMenu->set_visible(
"properties", std::find( aExecVector.begin(), aExecVector.end(),
"properties" ) != aExecVector.end());
456 OUString sCommand(xMenu->popup_at_rect(mxThemes.get(),
tools::Rectangle(rCEvt.GetMousePosPixel(),
Size(1,1))));
457 ImplExecute(sCommand);
464 if (maThemeSelectionHandler)
465 maThemeSelectionHandler();
470 OUString aNewTheme(
SvxResId(RID_SVXSTR_GALLERY_NEWTHEME) );
471 OUString
aName( aNewTheme );
474 while( mpGallery->HasTheme(
aName ) && (
nCount++ < 16000 ) )
476 aName = aNewTheme +
" " + OUString::number(
nCount );
479 if( !mpGallery->HasTheme(
aName ) && mpGallery->CreateTheme(
aName ) )
481 ImplGalleryThemeProperties(
aName,
true );
SfxApplication * SfxGetpApp()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
void EndThemePropertiesDlgHdl(sal_Int32 nResult)
void ImplGalleryThemeProperties(std::u16string_view rThemeName, bool bCreateNew)
void ImplEndGalleryThemeProperties(bool bCreateNew, sal_Int32 nResult)
static void ImplFillExchangeData(const GalleryTheme *pThm, ExchangeData &rData)
std::unique_ptr< weld::Button > mxMoreGalleries
std::unique_ptr< SfxItemSet > mpThemePropsDlgItemSet
OUString GetSelectedTheme() const
void ImplExecute(std::u16string_view rIdent)
GalleryBrowser1(weld::Builder &rBuilder, Gallery *pGallery, ::std::function< void()> aThemeSelectionHandler)
void ImplInsertThemeEntry(const GalleryThemeEntry *pEntry)
std::unique_ptr< weld::TreeView > mxThemes
std::unique_ptr< weld::Button > mxNewTheme
void ImplGetExecuteVector(std::vector< OUString > &o_aExec)
void EndNewThemePropertiesDlgHdl(sal_Int32 nResult)
std::unique_ptr< ExchangeData > mpExchangeData
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
const OUString & GetThemeName() const
const OUString & GetStringData() const
GalleryHintType GetType() const
const OUString & GetThemeName() const
const OUString & GetName() const
SAL_DLLPRIVATE void SetId(sal_uInt32 nNewId, bool bResetThemeName)
SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const
DateTime getModificationDate() const
void ReleaseTheme(GalleryTheme *pTheme, SfxListener &rListener)
SAL_DLLPRIVATE const INetURLObject & GetUserURL() const
bool HasTheme(std::u16string_view rThemeName)
void RenameTheme(const OUString &rOldName, const OUString &rNewName)
bool RemoveTheme(const OUString &rThemeName)
size_t GetThemeCount() const
SAL_DLLPRIVATE const GalleryThemeEntry * GetThemeInfo(size_t nPos)
GalleryTheme * AcquireTheme(std::u16string_view rThemeName, SfxListener &rListener)
INetProtocol GetProtocol() const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
virtual VclPtr< VclAbstractDialog > CreateActualizeProgressDialog(weld::Widget *pParent, GalleryTheme *pThm)=0
virtual VclPtr< AbstractGalleryIdDialog > CreateGalleryIdDialog(weld::Widget *pParent, GalleryTheme *pThm)=0
static SvxAbstractDialogFactory * Create()
virtual VclPtr< VclAbstractDialog > CreateGalleryThemePropertiesDialog(weld::Widget *pParent, ExchangeData *pData, SfxItemSet *pItemSet)=0
virtual VclPtr< AbstractTitleDialog > CreateTitleDialog(weld::Widget *pParent, const OUString &rOldText)=0
#define DBG_ASSERT(sCon, aError)
OUString SvxResId(TranslateId aId)
IMPL_STATIC_LINK_NOARG(GalleryBrowser1, OnMoreGalleriesClick, weld::Button &, void)
IMPL_LINK(GalleryBrowser1, KeyInputHdl, const KeyEvent &, rKEvt, bool)
IMPL_LINK_NOARG(GalleryBrowser1, SelectThemeHdl, weld::TreeView &, void)
constexpr OUStringLiteral HID_GALLERY_THEMELIST
constexpr OUStringLiteral HID_GALLERY_NEWTHEME
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_R
constexpr sal_uInt16 KEY_I
constexpr sal_uInt16 KEY_U
constexpr sal_uInt16 KEY_D
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_INSERT
#define LINK(Instance, Class, Member)
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
tools::Time aThemeChangeTime