29#include <com/sun/star/beans/PropertyValue.hpp>
30#include <com/sun/star/frame/ModuleManager.hpp>
31#include <com/sun/star/frame/UnknownModuleException.hpp>
32#include <officecfg/Office/Common.hxx>
35#include <osl/diagnose.h>
47#include <sfx2/sfxsids.hrc>
48#include <sfx2/strings.hrc>
53using namespace css::beans;
54using namespace css::frame;
55using namespace css::uno;
106 if (pStyle == &m_aStyleList)
107 ActionSelect(
"new", m_aStyleList);
111 :
PanelLayout(pParent,
"TemplatePanel",
"sfx/ui/templatepanel.ui")
114 OSL_ASSERT(pBindings!=
nullptr);
117SfxTemplatePanelControl::~SfxTemplatePanelControl()
128 case SfxStyleFamily::Char:
return 1;
129 case SfxStyleFamily::Para:
return 2;
130 case SfxStyleFamily::Frame:
return 3;
131 case SfxStyleFamily::Page:
return 4;
132 case SfxStyleFamily::Pseudo:
return 5;
133 case SfxStyleFamily::Table:
return 6;
134 default:
return 0xffff;
143 return SfxStyleFamily::Char;
145 return SfxStyleFamily::Para;
147 return SfxStyleFamily::Frame;
149 return SfxStyleFamily::Page;
151 return SfxStyleFamily::Pseudo;
153 return SfxStyleFamily::Table;
155 return SfxStyleFamily::All;
197 , m_pDeletionWatcher(nullptr)
198 , m_aStyleList(pBuilder, pB, this, pC,
"treeview",
"flatview")
199 , mxPreviewCheckbox(pBuilder->weld_check_button(
"showpreview"))
200 , mxHighlightCheckbox(pBuilder->weld_check_button(
"highlightstyles"))
201 , mxFilterLb(pBuilder->weld_combo_box(
"filter"))
206 , bWaterDisabled(false)
207 , bNewByExampleDisabled(false)
208 , bUpdateByExampleDisabled(false)
209 , m_bWantHierarchical(false)
212 mxPreviewCheckbox->set_active(officecfg::Office::Common::StylesAndFormatting::Preview::get());
217 if(rStyleList == &
m_aStyleList || rStyleList ==
nullptr)
231 nActFilter =
static_cast<sal_uInt16
>(LoadFactoryStyleFilter_Hdl(pCurObjShell));
232 if (0xffff == nActFilter)
238 size_t nCount = m_aStyleListReadResource.Call(
nullptr);
251 ReplaceUpdateButtonByMenu();
257 InsertFamilyItem(
nId, rItem);
264 m_aStyleListClear.Call(
nullptr);
293 && (eFam == SfxStyleFamily::Para || eFam == SfxStyleFamily::Char));
302 CheckItem(OUString::number(nActFamily));
304 mxFilterLb->freeze();
308 mxFilterLb->append(OUString::number(
static_cast<int>(SfxStyleSearchBits::All)),
309 SfxResId(STR_STYLE_FILTER_HIERARCHICAL));
312 mxFilterLb->append(OUString::number(
static_cast<int>(
i.nFlags)),
i.aName);
315 if (nActFilter < mxFilterLb->get_count() - 1)
316 mxFilterLb->set_active(nActFilter + 1);
320 m_aStyleList.FilterSelect(nActFilter,
false);
321 mxFilterLb->set_active(1);
325 if (m_aStyleList.IsTreeView() || m_bWantHierarchical)
327 mxFilterLb->set_active_text(
SfxResId(STR_STYLE_FILTER_HIERARCHICAL));
328 EnableHierarchical(
true, m_aStyleList);
333 if (nActFilter < mxFilterLb->get_count() - 1)
334 mxFilterLb->set_active(nActFilter + 1);
338 m_aStyleList.FilterSelect(nActFilter,
false);
339 mxFilterLb->set_active(1);
346 EnableItem(
"watercan",
false);
379 UpdateStyleDependents_Hdl(
nullptr);
425 sal_uInt16 nId,
const OUString &rStr,
const OUString& rRefStr, sal_uInt16 nFamily,
StyleList& rStyleList,
431 SfxUInt16Item aMask( SID_STYLE_MASK,
static_cast<sal_uInt16
>(nMask) );
436 if( !rStr.isEmpty() )
437 pItems[
nCount++ ] = &aItem;
438 pItems[
nCount++ ] = &aFamily;
439 if( nMask != SfxStyleSearchBits::Auto )
440 pItems[
nCount++ ] = &aMask;
441 if(SID_STYLE_UPDATE_BY_EXAMPLE ==
nId)
446 pItems[
nCount++ ] = &aUpdName;
449 if ( !rRefStr.isEmpty() )
450 pItems[
nCount++ ] = &aRefName;
452 pItems[
nCount++ ] =
nullptr;
455 sal_uInt16 nModi = pModifier ? *pModifier : 0;
462 if ( !pItem || aDeleted )
465 if ((
nId == SID_STYLE_NEW || SID_STYLE_EDIT ==
nId)
471 if(nFilterFlags == SfxStyleSearchBits::Auto)
474 const size_t nFilterCount = pFamilyItem->
GetFilterList().size();
476 for (
size_t i = 0;
i < nFilterCount; ++
i )
480 if ( ( rTupel.
nFlags & nFilterFlags ) == nFilterFlags && pIdx )
498 SaveSelection_Hdl(rStyleList);
527 nActFilter =
static_cast<sal_uInt16
>(LoadFactoryStyleFilter_Hdl(pDocShell));
536 if (
SfxResId(STR_STYLE_FILTER_HIERARCHICAL) == rBox.get_active_text())
538 EnableHierarchical(
true, m_aStyleList);
542 EnableHierarchical(
false, m_aStyleList);
549 assert((0 < nEntry && nEntry <=
MAX_FAMILIES) || 0xffff == nEntry);
558 && (eFam == SfxStyleFamily::Para || eFam == SfxStyleFamily::Char));
561 bool bActive =
false;
562 if (eFam == SfxStyleFamily::Para)
564 else if (eFam == SfxStyleFamily::Char)
573 if (rEntry ==
"watercan")
588 Execute_Impl(SID_STYLE_WATERCAN,
"",
"", 0, rStyleList);
595 else if (rEntry ==
"new" || rEntry ==
"newmenu")
599 else if (rEntry ==
"update")
605 else if (rEntry ==
"load")
608 SAL_WARN(
"sfx",
"not implemented: " << rEntry);
613 OSL_ENSURE( i_xModMgr.is(),
"getModuleIdentifier(): no XModuleManager" );
614 OSL_ENSURE( i_pObjSh,
"getModuleIdentifier(): no ObjectShell" );
616 OUString sIdentifier;
620 sIdentifier = i_xModMgr->identify( i_pObjSh->
GetModel() );
622 catch ( css::frame::UnknownModuleException& )
624 SAL_WARN(
"sfx",
"getModuleIdentifier(): unknown module" );
628 TOOLS_WARN_EXCEPTION(
"sfx",
"getModuleIdentifier(): exception of XModuleManager::identify()" );
636 OSL_ENSURE( i_pObjSh,
"SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" );
642 m_bWantHierarchical = (nFilter & 0x1000) != 0;
650 OSL_ENSURE( i_pObjSh,
"SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" );
658 SfxViewFrame *
const pViewFrame(pBindings->GetDispatcher_Impl()->GetFrame());
663 SaveFactoryStyleFilter( pDocShell, nActFilter );
671 bool bCustomPreview = mxPreviewCheckbox->get_active();
672 officecfg::Office::Common::StylesAndFormatting::Preview::set(bCustomPreview, batch );
675 FamilySelect(nActFamily, m_aStyleList,
true);
680 bool bActive = mxHighlightCheckbox->get_active();
682 if (eFam == SfxStyleFamily::Para)
683 m_aStyleList.SetHighlightParaStyles(bActive);
684 else if (eFam == SfxStyleFamily::Char)
685 m_aStyleList.SetHighlightCharStyles(bActive);
686 FamilySelect(nActFamily, m_aStyleList,
true);
691 m_aStyleListUpdateStyleDependents.Call(
nullptr);
692 EnableItem(
"watercan", !bWaterDisabled);
693 m_aStyleListEnableDelete.Call(
nullptr);
699 if (
nId == SID_STYLE_NEW_BY_EXAMPLE)
706 else if(
nId == SID_STYLE_UPDATE_BY_EXAMPLE )
720 : DropTargetHelper(rToolbar.get_drop_target())
738 , m_xActionTbL(pDlgWindow->get_builder()->weld_toolbar(
"left"))
739 , m_xActionTbR(pDlgWindow->get_builder()->weld_toolbar(
"right"))
740 , m_xToolMenu(pDlgWindow->get_builder()->weld_menu(
"toolmenu"))
741 , m_nActionTbLVisible(0)
776 case SfxStyleFamily::Char: sHelpId =
".uno:CharStyle";
break;
777 case SfxStyleFamily::Para: sHelpId =
".uno:ParaStyle";
break;
778 case SfxStyleFamily::Frame: sHelpId =
".uno:FrameStyle";
break;
779 case SfxStyleFamily::Page: sHelpId =
".uno:PageStyle";
break;
780 case SfxStyleFamily::Pseudo: sHelpId =
".uno:ListStyle";
break;
781 case SfxStyleFamily::Table: sHelpId =
".uno:TableStyle";
break;
782 default: OSL_FAIL(
"unknown StyleFamily");
break;
785 OUString
sId(OUString::number(
nId));
817 if (rMesId ==
"watercan" && !bCheck &&
IsCheckedItem(
"watercan"))
824 if (rMesId ==
"watercan")
835 if (rMesId ==
"watercan")
842 FamilySelect(rEntry.toUInt32(), m_aStyleList);
847 if (rEntry ==
"newmenu")
848 m_xActionTbR->set_menu_item_active(rEntry, !m_xActionTbR->get_menu_item_active(rEntry));
850 ActionSelect(rEntry, m_aStyleList);
856 OUString sTextDoc(
"com.sun.star.text.TextDocument");
873 if (rMenuId.isEmpty())
875 ActionSelect(rMenuId, m_aStyleList);
891 bWaterDisabled =
false;
892 bUpdateByExampleDisabled =
false;
894 if (IsCheckedItem(
"watercan") &&
896 rStyleList.CurrentFamilyHasState())
898 Execute_Impl(SID_STYLE_APPLY, rStyleList.GetSelectedEntry(), OUString(),
899 static_cast<sal_uInt16
>(rStyleList.GetFamilyItem()->GetFamily()), rStyleList);
918 if (!sIdent.isEmpty() && !
m_xActionTbL->get_item_active(sIdent))
919 ToolBoxLSelect(sIdent);
924 rHelper.IsDropFormatSupported(SotClipboardFormatId::OBJECTDESCRIPTOR) &&
934 if (rStyleList == &
m_aStyleList || rStyleList ==
nullptr)
939 if (rStyleList == &
m_aStyleList || rStyleList ==
nullptr)
944 if (rStyleList == &
m_aStyleList || rStyleList ==
nullptr)
949 if (rStyleList == &
m_aStyleList || rStyleList ==
nullptr)
954 if (rStyleList == &
m_aStyleList || rStyleList ==
nullptr)
constexpr int MAX_FAMILIES
PropertiesInfo aProperties
SfxApplication * SfxGetpApp()
sal_uInt16 GetValue() const
void SetValue(const OUString &rTheValue)
This class is the base for the Widget Layout-based sidebar panels.
SAL_DLLPRIVATE SfxDispatcher * GetDispatcher_Impl()
SAL_DLLPRIVATE SfxDispatcher * GetDispatcher_Impl()
void SetValue(bool const bTheValue)
DeletionWatcher(SfxCommonTemplateDialog_Impl &rDialog)
void(DeletionWatcher::* bool_type)()
DeletionWatcher(const DeletionWatcher &)=delete
DeletionWatcher & operator=(const DeletionWatcher &)=delete
DeletionWatcher *const m_pPrevious
SfxCommonTemplateDialog_Impl * m_pDialog
void SetFamilyState(sal_uInt16 nSlotId, const SfxTemplateItem *)
bool bUpdateByExampleDisabled
Link< void *, void > m_aStyleListNewMenu
Link< bool, void > m_aStyleListEnableTreeDrag
void SetFamily(SfxStyleFamily nFamily)
sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
void EnableHierarchical(bool, StyleList &rStyleList)
void SelectStyle(const OUString &rStyle, bool bIsCallback, StyleList &rStyleList)
Link< void *, bool > m_aStyleListHasSelectedStyle
Link< void *, void > m_aStyleListEnableDelete
virtual void EnableItem(const OUString &, bool=true)
void EnableDel(bool b, const StyleList *rStyleList)
DeletionWatcher * m_pDeletionWatcher
virtual void ReplaceUpdateButtonByMenu()
Link< const ExecuteDropEvent &, sal_Int8 > m_aStyleListExecuteDrop
Link< void *, void > m_aStyleListClear
void FamilySelect(sal_uInt16 nId, StyleList &rStyleList, bool bRefresh=false)
void IsUpdate(StyleList &)
void ActionSelect(const OUString &rId, StyleList &rStyleList)
void connect_stylelist_enable_delete(const Link< void *, void > rLink)
bool Execute_Impl(sal_uInt16 nId, const OUString &rStr, const OUString &rRefStr, sal_uInt16 nFamily, StyleList &rStyleList, SfxStyleSearchBits nMask=SfxStyleSearchBits::Auto, sal_uInt16 *pIdx=nullptr, const sal_uInt16 *pModifier=nullptr)
void FilterSelect(sal_uInt16 nFilterIdx)
std::unique_ptr< weld::ComboBox > mxFilterLb
void EnableShow(bool b, const StyleList *rStyleList)
Link< const SfxBoolItem *, void > m_aStyleListSetWaterCanState
void EnableExample_Impl(sal_uInt16 nId, bool bEnable)
DeletionWatcher * impl_setDeletionWatcher(DeletionWatcher *pNewWatcher)
void EnableTreeDrag(bool b)
SfxCommonTemplateDialog_Impl(SfxBindings *pB, weld::Container *, weld::Builder *pBuilder)
void connect_stylelist_execute_drop(const Link< const ExecuteDropEvent &, sal_Int8 > &rLink)
void SaveFactoryStyleFilter(SfxObjectShell const *i_pObjSh, sal_Int32 i_nFilter)
virtual void EnableEdit(bool b, StyleList *rStyleList)
void EnableHide(bool b, const StyleList *rStyleList)
void connect_stylelist_set_water_can_state(const Link< const SfxBoolItem *, void > rLink)
void connect_stylelist_update_style_dependents(const Link< void *, void > &rLink)
css::uno::Reference< css::frame::XModuleManager2 > xModuleManager
void connect_stylelist_enable_tree_drag(const Link< bool, void > rLink)
bool IsSafeForWaterCan() const
Is it safe to show the water-can / fill icon.
Link< void *, void > m_aStyleListCleanup
void connect_stylelist_has_selected_style(const Link< void *, bool > &rLink)
void EnableNew(bool b, const StyleList *rStyleList)
Link< sal_uInt16, void > m_aStyleListSetFamily
virtual bool IsCheckedItem(const OUString &)
void SetWaterCanState(const SfxBoolItem *pItem)
virtual void CheckItem(const OUString &, bool=true)
Link< void *, void > m_aStyleListUpdateStyleDependents
bool bNewByExampleDisabled
Link< void *, bool > m_aStyleListWaterCan
std::unique_ptr< weld::CheckButton > mxPreviewCheckbox
virtual ~SfxCommonTemplateDialog_Impl()
std::unique_ptr< weld::CheckButton > mxHighlightCheckbox
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
Method to execute a <SfxSlot>s over the Slot-Id.
SfxViewFrame * GetFrame() const
Returns a pointer to the <SfxViewFrame> instance, which belongs to this SfxDispatcher.
sal_uInt16 GetAutoStyleFilterIndex() const
void SetAutoStyleFilterIndex(sal_uInt16 nSet)
css::uno::Reference< css::frame::XModel3 > GetModel() const
const OUString & GetText() const
SfxStyleFamily GetFamily() const
const OUString & GetImage() const
const SfxStyleFilter & GetFilterList() const
virtual void EnableItem(const OUString &rMesId, bool bCheck=true) override
std::unique_ptr< weld::Toolbar > m_xActionTbR
SfxTemplateDialog_Impl(SfxBindings *, SfxTemplatePanelControl *pDlgWindow)
virtual void EnableEdit(bool, StyleList *rStyleList) override
sal_Int8 AcceptToolbarDrop(const AcceptDropEvent &rEvt, const DropTargetHelper &rHelper)
virtual bool IsCheckedItem(const OUString &rMesId) override
virtual void CheckItem(const OUString &rMesId, bool bCheck=true) override
virtual void ReplaceUpdateButtonByMenu() override
std::unique_ptr< weld::Menu > m_xToolMenu
std::unique_ptr< ToolbarDropTarget > m_xToolbarDropTargetHelper
virtual void EnableFamilyItem(sal_uInt16 nId, bool bEnabled) override
virtual void InsertFamilyItem(sal_uInt16 nId, const SfxStyleFamilyItem &rItem) override
virtual ~SfxTemplateDialog_Impl() override
std::unique_ptr< weld::Toolbar > m_xActionTbL
virtual void ClearFamilyList() override
SfxFrame & GetFrame() const
virtual SfxObjectShell * GetObjectShell() override
bool IsHierarchical() const
void FamilySelect(sal_uInt16 nEntry, bool bRefresh=false)
void Enabledel(bool candel)
bool HasStylesHighlighterFeature()
void connect_LoadFactoryStyleFilter(const Link< SfxObjectShell const *, sal_Int32 > &rLink)
void Enableshow(bool canshow)
void SelectStyle(const OUString &rStr, bool bIsCallback)
void connect_ClearResource(const Link< void *, void > &rLink)
const SfxStyleFamilyItem * GetFamilyItem() const
void SetFamilyState(sal_uInt16 nSlotId, const SfxTemplateItem *pItem)
void Enablenew(bool cannew)
void connect_ReadResource(const Link< StyleList &, void > &rLink)
void EnableNewByExample(bool newByExampleDisabled)
void connect_SaveSelection(const Link< StyleList &, SfxObjectShell * > rLink)
void Enableedit(bool canedit)
void connect_UpdateFamily(const Link< StyleList &, void > rLink)
void SetFilterControlsHandle()
void connect_UpdateStyles(const Link< StyleFlags, void > &rLink)
void FilterSelect(sal_uInt16 nActFilter, bool bsetFilter)
void Enablehide(bool canhide)
bool IsHighlightParaStyles()
OUString GetSelectedEntry() const
bool IsHighlightCharStyles()
static std::shared_ptr< ConfigurationChanges > create()
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
#define TOOLS_WARN_EXCEPTION(area, stream)
constexpr OUStringLiteral HID_TEMPLDLG_NEWBYEXAMPLE
constexpr OUStringLiteral HID_TEMPLDLG_WATERCAN
constexpr OUStringLiteral HID_TEMPLATE_FILTER
constexpr OUStringLiteral HID_TEMPLDLG_TOOLBOX_LEFT
constexpr OUStringLiteral HID_TEMPLDLG_UPDATEBYEXAMPLE
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
static SfxStyleFamily NIdToSfxFamilyId(sal_uInt16 nId)
static sal_uInt16 SfxFamilyIdToNId(SfxStyleFamily nFamily)
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
OUString GetPopupLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
OUString SfxResId(TranslateId aId)
SfxStyleSearchBits nFlags
std::vector< SfxFilterTuple > SfxStyleFilter
IMPL_LINK(SfxCommonTemplateDialog_Impl, OnAsyncExecuteDrop, void *, pStyleList, void)
IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, ClearResource_Hdl, void *, void)
static OUString getModuleIdentifier(const Reference< XModuleManager2 > &i_xModMgr, SfxObjectShell const *i_pObjSh)