21#include <unordered_map>
23#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
24#include <com/sun/star/beans/XPropertySet.hpp>
25#include <com/sun/star/container/XNameAccess.hpp>
37#include <officecfg/Office/Common.hxx>
39#include <osl/diagnose.h>
51#include <sfx2/sfxsids.hrc>
52#include <sfx2/strings.hrc>
69using namespace css::beans;
70using namespace css::frame;
71using namespace css::uno;
80 : DropTargetHelper(rTreeView.get_drop_target())
98Color ColorHash(std::u16string_view rString)
100 static std::vector aSaturationArray{ 0.90, 0.75, 0.60 };
101 static std::vector aLightnessArray = aSaturationArray;
103 sal_uInt32 nStringHash = rtl_ustr_hashCode_WithLength(rString.data(), rString.length());
105 double nHue = nStringHash % 359;
106 double nSaturation = aSaturationArray[nStringHash / 360 % aSaturationArray.size()];
108 = aLightnessArray[nStringHash / 360 / aSaturationArray.size() % aLightnessArray.size()];
116std::optional<OUString> sDefaultCharStyleUIName;
123 OUString treeviewname, OUString flatviewname)
124 : m_bHierarchical(false)
125 , m_bAllowReParentDrop(false)
126 , m_bNewByExampleDisabled(false)
127 , m_bDontUpdate(false)
133 , m_bUpdateFamily(false)
135 , m_bBindingUpdate(true)
136 , m_pStyleSheetPool(nullptr)
138 , m_xFmtLb(pBuilder->weld_tree_view(flatviewname))
139 , m_xTreeBox(pBuilder->weld_tree_view(treeviewname))
140 , m_pCurObjShell(nullptr)
141 , m_nActFamily(0xffff)
144 , m_pBindings(pBindings)
151 uno::Reference<frame::XFrame>
xFrame
165 if (m_pStyleSheetPool)
166 EndListening(*m_pStyleSheetPool);
167 m_pStyleSheetPool =
nullptr;
168 m_xTreeView1DropTargetHelper.reset();
169 m_xTreeView2DropTargetHelper.reset();
193 if (pItem && pItem->
GetFamily() == SfxStyleFamily::Table)
195 mxMenu->set_sensitive(
"edit",
false);
196 mxMenu->set_sensitive(
"new",
false);
198 if (pItem && pItem->
GetFamily() == SfxStyleFamily::Pseudo)
201 if (aTemplName ==
"No List")
203 mxMenu->set_sensitive(
"edit",
false);
204 mxMenu->set_sensitive(
"new",
false);
205 mxMenu->set_sensitive(
"hide",
false);
213 for (
auto&
i : m_pFamilyState)
218 m_Module = m_pCurObjShell ? m_pCurObjShell->
GetModule() :
nullptr;
221 if (!m_xStyleFamilies)
222 m_xStyleFamilies.emplace();
224 m_nActFilter = 0xffff;
228 m_nActFilter =
static_cast<sal_uInt16
>(m_aLoadFactoryStyleFilter.Call(m_pCurObjShell));
229 if (0xffff == m_nActFilter)
231 m_nActFilter = m_pCurObjShell->GetAutoStyleFilterIndex();
233 if (m_bModuleHasStylesHighlighterFeature)
234 sDefaultCharStyleUIName = getDefaultStyleName(SfxStyleFamily::Char);
236 size_t nCount = m_xStyleFamilies->size();
237 m_pBindings->ENTERREGISTRATIONS();
242 sal_uInt16 nSlot = 0;
243 switch (m_xStyleFamilies->at(
i).GetFamily())
245 case SfxStyleFamily::Char:
246 nSlot = SID_STYLE_FAMILY1;
248 case SfxStyleFamily::Para:
249 nSlot = SID_STYLE_FAMILY2;
251 case SfxStyleFamily::Frame:
252 nSlot = SID_STYLE_FAMILY3;
254 case SfxStyleFamily::Page:
255 nSlot = SID_STYLE_FAMILY4;
257 case SfxStyleFamily::Pseudo:
258 nSlot = SID_STYLE_FAMILY5;
260 case SfxStyleFamily::Table:
261 nSlot = SID_STYLE_FAMILY6;
264 OSL_FAIL(
"unknown StyleFamily");
269 pBoundItems[
i++].reset(
271 pBoundItems[
i++].reset(
273 pBoundItems[
i++].reset(
275 pBoundItems[
i++].reset(
277 pBoundItems[
i++].reset(
279 pBoundItems[
i++].reset(
281 pBoundItems[
i++].reset(
283 pBoundItems[
i++].reset(
285 m_pBindings->LEAVEREGISTRATIONS();
288 pBoundItems[
i] =
nullptr;
292 for (
i = SID_STYLE_FAMILY1;
i <= SID_STYLE_FAMILY4;
i++)
293 m_pBindings->Update(
i);
313 if (pOldStyleSheetPool)
324 if (m_nActFamily != 0xFFFF)
325 m_pParentDialog->CheckItem(OUString::number(m_nActFamily),
false);
329 m_bUpdateFamily =
true;
358 m_xFmtLb->set_selection_mode(SelectionMode::Multiple);
384 int nTreeHeight =
m_xFmtLb->get_height_rows(8);
385 m_xFmtLb->set_size_request(-1, nTreeHeight);
386 m_xTreeBox->set_size_request(-1, nTreeHeight);
392 bool bCustomPreview = officecfg::Office::Common::StylesAndFormatting::Preview::get();
393 m_xFmtLb->set_column_custom_renderer(1, bCustomPreview);
394 m_xTreeBox->set_column_custom_renderer(1, bCustomPreview);
413 if (pOldStyleSheetPool)
457 if (rHelper.IsDropFormatSupported(SotClipboardFormatId::OBJECTDESCRIPTOR))
479 sal_uInt32 nFormatCount =
aHelper.GetFormatCount();
483 bool bFormatFound =
false;
485 for (sal_uInt32
i = 0;
i < nFormatCount; ++
i)
490 if (
aHelper.GetTransferableObjectDescriptor(
nId, aDesc))
499 nRet = rEvt.mnAction;
509 if (!m_xTreeBox->get_visible())
512 if (!m_bAllowReParentDrop)
518 if (!pSource || pSource != m_xTreeBox.get())
521 std::unique_ptr<weld::TreeIter> xSource(m_xTreeBox->make_iterator());
522 if (!m_xTreeBox->get_selected(xSource.get()))
525 std::unique_ptr<weld::TreeIter>
xTarget(m_xTreeBox->make_iterator());
526 if (!m_xTreeBox->get_dest_row_at_pos(rEvt.maPosPixel,
xTarget.get(),
true))
529 int nChildren = m_xTreeBox->n_children();
532 if (!m_xTreeBox->get_iter_first(*
xTarget)
533 || !m_xTreeBox->iter_nth_sibling(*
xTarget, nChildren - 1))
535 while (m_xTreeBox->get_row_expanded(*
xTarget))
537 nChildren = m_xTreeBox->iter_n_children(*
xTarget);
538 if (!m_xTreeBox->iter_children(*
xTarget)
539 || !m_xTreeBox->iter_nth_sibling(*
xTarget, nChildren - 1))
543 OUString aTargetStyle = m_xTreeBox->get_text(*
xTarget);
544 DropHdl(m_xTreeBox->get_text(*xSource), aTargetStyle);
545 m_xTreeBox->unset_drag_dest_row();
546 FillTreeBox(GetActualFamily());
547 m_pParentDialog->SelectStyle(aTargetStyle,
false, *
this);
553 if (!m_pStyleSheetPool || m_nActFamily == 0xffff)
559 if (pItem && m_nActFilter != 0xffff)
561 if (nFilter == SfxStyleSearchBits::Auto)
562 nFilter = m_nAppFilter;
566 auto nResult = aDlg.
run();
569 const OUString aTemplName(aDlg.
GetName());
570 m_pParentDialog->Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE, aTemplName,
"",
571 static_cast<sal_uInt16
>(GetFamilyItem()->GetFamily()), *
this,
574 m_aUpdateFamily.Call(*
this);
584 pStyle->SetParent(rParent);
591 std::unique_ptr<weld::TreeIter> xIter(pTreeView->
make_iterator());
596 pTreeView->
select(*xIter);
598 FmtSelectHdl(*pTreeView);
619 bool HasParent()
const {
return !aParent.isEmpty(); }
621 StyleTree_Impl(OUString _aName, OUString _aParent)
622 :
aName(std::move(_aName))
623 , aParent(std::move(_aParent))
628 const OUString& getName()
const {
return aName; }
629 const OUString& getParent()
const {
return aParent; }
637 ::comphelper::getProcessComponentContext(),
640 std::unordered_map<OUString, StyleTree_Impl*> styleFinder;
641 styleFinder.reserve(rArr.size());
642 for (
const auto& pEntry : rArr)
644 styleFinder.emplace(pEntry->getName(), pEntry.get());
648 for (
auto& pEntry : rArr)
650 if (!pEntry->HasParent())
652 auto it = styleFinder.find(pEntry->getParent());
653 if (it != styleFinder.end())
655 StyleTree_Impl* pCmp = it->second;
657 auto iPos = std::lower_bound(
658 pCmp->getChildren().begin(), pCmp->getChildren().end(), pEntry,
659 [&aSorter](std::unique_ptr<StyleTree_Impl>
const& pEntry1,
660 std::unique_ptr<StyleTree_Impl>
const& pEntry2) {
661 return aSorter.compare(pEntry1->getName(), pEntry2->getName()) < 0;
663 pCmp->getChildren().insert(iPos, std::move(pEntry));
669 std::remove_if(rArr.begin(), rArr.end(),
670 [](std::unique_ptr<StyleTree_Impl>
const& pEntry) { return !pEntry; }),
674 std::sort(rArr.begin(), rArr.end());
675 std::sort(rArr.begin(), rArr.end(),
676 [&aSorter, &
aUIName](std::unique_ptr<StyleTree_Impl>
const& pEntry1,
677 std::unique_ptr<StyleTree_Impl>
const& pEntry2) {
678 if (pEntry2->getName() == aUIName)
680 if (pEntry1->getName() == aUIName)
682 return aSorter.compare(pEntry1->getName(), pEntry2->getName()) < 0;
686static bool IsExpanded_Impl(
const std::vector<OUString>& rEntries, std::u16string_view rStr)
688 for (
const auto& rEntry : rEntries)
699 Color aColor(ColorHash(rName));
702 if (eFam == SfxStyleFamily::Para)
706 nColor = rParaStylesColorMap.size();
707 rParaStylesColorMap[rName] = std::pair(aColor, nColor);
713 nColor = rCharStylesColorMap.size();
714 rCharStylesColorMap[rName] = std::pair(aColor, nColor);
716 if (rName == sDefaultCharStyleUIName.value() )
718 rTreeView.
insert(pParent, -1, &rName, &rName,
nullptr,
nullptr,
false, pRet);
727 xDevice->SetOutputSize(aImageSize);
728 xDevice->SetFillColor(aColor);
730 xDevice->DrawRect(aRect);
732 xDevice->DrawText(aRect, OUString::number(nColor),
733 DrawTextFlags::Center | DrawTextFlags::VCenter);
735 rTreeView.
insert(pParent, -1, &rName, &rName,
nullptr, xDevice.
get(),
false, pRet);
739 const std::vector<OUString>& rEntries,
SfxStyleFamily eStyleFamily,
742 std::unique_ptr<weld::TreeIter> xResult = rBox.
make_iterator();
743 const OUString& rName = pEntry->getName();
746 lcl_Insert(rBox, rName, eStyleFamily, pParent, xResult.get(), pViewShell);
748 rBox.
insert(pParent, -1, &rName, &rName,
nullptr,
nullptr,
false, xResult.get());
750 for (
size_t i = 0;
i < pEntry->getChildren().
size(); ++
i)
751 FillBox_Impl(rBox, pEntry->getChildren()[
i].get(), rEntries, eStyleFamily, xResult.get(),
752 blcl_insert, pViewShell);
762 case SfxStyleFamily::Char:
764 case SfxStyleFamily::Para:
766 case SfxStyleFamily::Frame:
768 case SfxStyleFamily::Page:
770 case SfxStyleFamily::Pseudo:
772 case SfxStyleFamily::Table:
784 return SfxStyleFamily::Char;
786 return SfxStyleFamily::Para;
788 return SfxStyleFamily::Frame;
790 return SfxStyleFamily::Page;
792 return SfxStyleFamily::Pseudo;
794 return SfxStyleFamily::Table;
796 return SfxStyleFamily::All;
835 aRet =
m_xFmtLb->get_selected_text();
847 if (m_xTreeBox->get_visible())
848 return m_xTreeBox->get_selected_index() != -1;
850 return m_xFmtLb->count_selected_rows() == 1;
855 size_t nCount = m_xStyleFamilies->size();
856 m_pBindings->EnterRegistrations();
860 bool bChecked = pItem && pItem->GetValue();
861 if (pCItem->
IsBound() == bChecked)
869 m_pBindings->LeaveRegistrations();
876 bool bCustomPreview = officecfg::Office::Common::StylesAndFormatting::Preview::get();
878 m_xFmtLb->set_column_custom_renderer(1, bCustomPreview);
880 m_xTreeBox->set_column_custom_renderer(1, bCustomPreview);
905 bool bReadWrite = !(pStyle->
GetMask() & SfxStyleSearchBits::ReadOnly);
924 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeBox->make_iterator();
925 bool bEntry =
m_xTreeBox->get_iter_first(*xEntry);
937 else if (eFam == SfxStyleFamily::Pseudo)
939 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeBox->make_iterator();
951 bool bSelect = !rStr.isEmpty();
954 std::unique_ptr<weld::TreeIter> xEntry =
m_xFmtLb->make_iterator();
955 bool bEntry =
m_xFmtLb->get_iter_first(*xEntry);
956 while (bEntry &&
m_xFmtLb->get_text(*xEntry) != rStr)
957 bEntry =
m_xFmtLb->iter_next(*xEntry);
962 if (!
m_xFmtLb->is_selected(*xEntry))
983 std::unique_ptr<weld::TreeIter> xEntry = rBox.
make_iterator();
989 rEntries.push_back(rBox.
get_text(*xEntry));
996 if (m_pStyleSheetPool)
1002 m_bTreeDrag = m_bEnable;
1009 assert(
m_xTreeBox &&
"FillTreeBox() without treebox");
1024 StyleTree_Impl* pNew =
new StyleTree_Impl(pStyle->
GetName(), pStyle->
GetParent());
1025 aArr.emplace_back(pNew);
1039 if (eFam == SfxStyleFamily::Para)
1041 else if (eFam == SfxStyleFamily::Char)
1067 pViewFrame->
Resize(
true);
1070 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeBox->make_iterator();
1071 bool bEntry =
m_xTreeBox->get_iter_first(*xEntry);
1086 EnableDelete(
nullptr);
1091 if (nFamily == SfxStyleFamily::Char)
1092 return "CharacterStyles";
1093 if (nFamily == SfxStyleFamily::Para)
1094 return "ParagraphStyles";
1095 if (nFamily == SfxStyleFamily::Page)
1096 return "PageStyles";
1097 if (nFamily == SfxStyleFamily::Table)
1098 return "TableStyles";
1099 if (nFamily == SfxStyleFamily::Pseudo)
1100 return "NumberingStyles";
1106 OUString sDefaultStyle;
1108 if (aFamilyName ==
"TableStyles")
1109 sDefaultStyle =
"Default Style";
1110 else if (aFamilyName ==
"NumberingStyles")
1111 sDefaultStyle =
"No List";
1113 sDefaultStyle =
"Standard";
1119 uno::Reference<container::XNameAccess> xStyles;
1120 uno::Reference<container::XNameAccess> xCont =
xModel->getStyleFamilies();
1121 xCont->getByName(aFamilyName) >>= xStyles;
1122 uno::Reference<beans::XPropertySet> xInfo;
1123 xStyles->getByName(sDefaultStyle) >>= xInfo;
1124 xInfo->getPropertyValue(
"DisplayName") >>=
aUIName;
1126 catch (
const uno::Exception&)
1136 return SfxStyleFamily::Para;
1143 return m_xTreeBox->get_visible() ? m_xTreeBox->get_selected_index() != -1
1144 : m_xFmtLb->count_selected_rows() != 0;
1150 if (m_nActFamily != 0xffff && m_pParentDialog->IsCheckedItem(
"watercan") &&
1152 nullptr != m_pFamilyState[m_nActFamily - 1] && IsSafeForWaterCan(
nullptr))
1154 m_pParentDialog->Execute_Impl(SID_STYLE_WATERCAN,
"",
"", 0, *
this);
1155 m_pParentDialog->Execute_Impl(SID_STYLE_WATERCAN, GetSelectedEntry(),
"",
1156 static_cast<sal_uInt16
>(GetFamilyItem()->GetFamily()), *
this);
1170 for (
n = 0;
n < nFamilyCount;
n++)
1173 if (
n == nFamilyCount)
1185 : SfxStyleSearchBits::Auto);
1186 if (nFilter == SfxStyleSearchBits::Auto)
1197 std::unique_ptr<weld::TreeIter> xEntry =
m_xFmtLb->make_iterator();
1198 std::vector<OUString> aStrings;
1201 ::comphelper::getProcessComponentContext(),
1206 aStrings.push_back(pStyle->
GetName());
1215 std::sort(aStrings.begin(), aStrings.end());
1216 std::sort(aStrings.begin(), aStrings.end(),
1217 [&aSorter, &
aUIName](
const OUString& rLHS,
const OUString& rRHS) {
1218 if (rRHS == aUIName)
1220 if (rLHS == aUIName)
1222 return aSorter.compare(rLHS, rRHS) < 0;
1232 if (eFam == SfxStyleFamily::Para)
1234 else if (eFam == SfxStyleFamily::Char)
1238 size_t nCount = aStrings.size();
1262 pViewFrame->
Resize(
true);
1271 EnableDelete(
nullptr);
1276 sal_uInt16 nIdx = nSlotId - SID_STYLE_FAMILY_START;
1312 if (nMask == SfxStyleSearchBits::Auto)
1316 static_cast<sal_uInt16
>(eFam), *
this, nMask);
1322 if (
m_nActFamily != 0xffff && HasSelectedStyle(
nullptr))
1328 static_cast<sal_uInt16
>(
GetFamilyItem()->GetFamily()), *
this,
1329 SfxStyleSearchBits::Auto, &nFilter);
1336 if (
m_nActFamily == 0xffff || !HasSelectedStyle(
nullptr))
1339 bool bUsedStyle =
false;
1341 std::vector<std::unique_ptr<weld::TreeIter>> aList;
1345 OUStringBuffer aMsg(
SfxResId(STR_DELETE_STYLE_USED) +
SfxResId(STR_DELETE_STYLE));
1348 [
this, pTreeView, pItem, &aList, &bUsedStyle, &aMsg](
weld::TreeIter& rEntry) {
1351 const OUString aTemplName(pTreeView->
get_text(rEntry));
1355 if (pStyle->IsUsed())
1359 aMsg.append(aTemplName);
1366 bool aApproved =
false;
1372 pTreeView, VclMessageType::Question, VclButtonsType::YesNo, aMsg.makeStringAndClear()));
1373 aApproved = xBox->run() ==
RET_YES;
1377 if (bUsedStyle && !aApproved)
1380 for (
auto const& elem : aList)
1382 const OUString aTemplName(pTreeView->
get_text(*elem));
1385 static_cast<sal_uInt16
>(
GetFamilyItem()->GetFamily()), *
this);
1399 if (
m_nActFamily == 0xffff || !HasSelectedStyle(
nullptr))
1404 OUString aTemplName = pTreeView->
get_text(rEntry);
1407 static_cast<sal_uInt16
>(
GetFamilyItem()->GetFamily()), *
this);
1415 if (
m_nActFamily == 0xffff || !HasSelectedStyle(
nullptr))
1420 OUString aTemplName = pTreeView->
get_text(rEntry);
1423 static_cast<sal_uInt16
>(
GetFamilyItem()->GetFamily()), *
this);
1431 bool bEnableDelete(
false);
1432 if (m_nActFamily != 0xffff && HasSelectedStyle(
nullptr))
1434 OSL_ENSURE(m_pStyleSheetPool,
"No StyleSheetPool");
1435 const OUString aTemplName(GetSelectedEntry());
1441 if (nFilter == SfxStyleSearchBits::Auto)
1442 nFilter = m_nAppFilter;
1444 aTemplName, eFam, m_xTreeBox->get_visible() ? SfxStyleSearchBits::All : nFilter);
1446 OSL_ENSURE(pStyle,
"Style not found");
1451 bEnableDelete =
true;
1455 m_pParentDialog->EnableDel(bEnableDelete,
this);
1460 if (m_pCurObjShell && m_bModuleHasStylesHighlighterFeature)
1469 m_xStyleFamilies.reset();
1470 for (
auto&
i : m_pFamilyState)
1472 m_pCurObjShell =
nullptr;
1473 for (
auto&
i : pBoundItems)
1500 case SfxHintId::UpdateDone:
1520 if (!
aStr.isEmpty())
1529 bool bReadWrite = !(pStyle->
GetMask() & SfxStyleSearchBits::ReadOnly);
1549 case SfxHintId::DocChanged:
1552 case SfxHintId::Dying:
1569 ||
dynamic_cast<const SfxStyleSheetModifiedHint*
>(&rHint)))
1573 pIdle.reset(
new Idle(
"SfxCommonTemplate"));
1574 pIdle->SetPriority(TaskPriority::LOWEST);
1585 m_bDontUpdate =
true;
1586 if (!m_xTreeBox->get_visible())
1590 FillTreeBox(GetActualFamily());
1594 m_pParentDialog->SelectStyle(pState->
GetStyleName(),
false, *
this);
1595 EnableDelete(
nullptr);
1598 m_bDontUpdate =
false;
1607 if (sLastItemIdent ==
"new")
1609 else if (sLastItemIdent ==
"edit")
1611 else if (sLastItemIdent ==
"delete")
1613 else if (sLastItemIdent ==
"hide")
1615 else if (sLastItemIdent ==
"show")
1622 rUnsetDragIcon =
false;
1624 return !m_bAllowReParentDrop;
1642 const OUString aTemplName(pTreeView->
get_text(rEntry));
1643 OUString sQuickHelpText(aTemplName);
1647 return sQuickHelpText;
1649 if (pStyle && pStyle->
IsUsed())
1652 if (pStyle->
GetFamily() == SfxStyleFamily::Pseudo)
1655 if (!sUsedBy.isEmpty())
1657 const sal_Int32 nMaxLen = 80;
1658 if (sUsedBy.getLength() > nMaxLen)
1660 sUsedBy = OUString::Concat(sUsedBy.subView(0, nMaxLen)) +
"...";
1663 OUString aMessage =
SfxResId(STR_STYLEUSEDBY);
1664 aMessage = aMessage.replaceFirst(
"%STYLELIST", sUsedBy);
1665 sQuickHelpText = aTemplName +
" " + aMessage;
1669 return sQuickHelpText;
1675 const ::tools::Rectangle& rRect = std::get<1>(aPayload);
1679 bool bSelected = std::get<2>(aPayload);
1680 const OUString& rId = std::get<3>(aPayload);
1689 bool bSuccess =
false;
1708 std::unique_ptr<sfx2::StylePreviewRenderer> pStylePreviewRenderer(
1711 = pStylePreviewRenderer->recalculate() && pStylePreviewRenderer->render(aRect);
1712 rRenderContext.
Pop();
1718 rRenderContext.
DrawText(aRect, rId, DrawTextFlags::Left | DrawTextFlags::VCenter);
1720 rRenderContext.
Pop();
1726 std::unique_ptr<weld::TreeIter> xHdlEntry = rListBox.make_iterator();
1727 if (!rListBox.get_cursor(xHdlEntry.get()))
1730 m_pParentDialog->SelectStyle(rListBox.get_text(*xHdlEntry),
true, *
this);
1736 if (m_nActFamily != 0xffff &&
nullptr != m_pFamilyState[m_nActFamily - 1]
1737 && !GetSelectedEntry().isEmpty())
1739 m_pParentDialog->Execute_Impl(SID_STYLE_APPLY, GetSelectedEntry(), OUString(),
1740 static_cast<sal_uInt16
>(GetFamilyItem()->GetFamily()), *
this,
1741 SfxStyleSearchBits::Auto,
nullptr, &m_nModifier);
1758 m_nModifier = rMEvt.GetModifier();
1766 bool bDocChanged =
false;
1776 if (pNewModule && pNewModule !=
m_Module)
1816 for (
n = 0;
n < nFamilyCount;
n++)
1823 pItem = pNewItem.get();
1825 else if (bDocChanged)
1866 EnableDelete(
nullptr);
1883 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
1886 PrepareMenu(rCEvt.GetMousePosPixel());
1888 if (m_xFmtLb->count_selected_rows() <= 0)
1890 m_pParentDialog->EnableEdit(
false,
this);
1891 m_pParentDialog->EnableDel(
false,
this);
1901 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
1904 PrepareMenu(rCEvt.GetMousePosPixel());
IMPL_LINK_NOARG(StyleList, Cleanup, void *, void)
static void FillBox_Impl(weld::TreeView &rBox, StyleTree_Impl *pEntry, const std::vector< OUString > &rEntries, SfxStyleFamily eStyleFamily, const weld::TreeIter *pParent, bool blcl_insert, SfxViewShell *pViewShell)
static OUString lcl_GetStyleFamilyName(SfxStyleFamily nFamily)
static void MakeTree_Impl(StyleTreeArr_Impl &rArr, const OUString &aUIName)
IMPL_LINK(StyleList, SetFamily, sal_uInt16, nId, void)
static void lcl_Insert(weld::TreeView &rTreeView, const OUString &rName, SfxStyleFamily eFam, const weld::TreeIter *pParent, weld::TreeIter *pRet, SfxViewShell *pViewSh)
IMPL_STATIC_LINK(StyleList, CustomGetSizeHdl, weld::TreeView::get_size_args, aPayload, Size)
static void MakeExpanded_Impl(const weld::TreeView &rBox, std::vector< OUString > &rEntries)
static bool IsExpanded_Impl(const std::vector< OUString > &rEntries, std::u16string_view rStr)
std::vector< std::unique_ptr< StyleTree_Impl > > StyleTreeArr_Impl
constexpr int COUNT_BOUND_FUNC
constexpr int MAX_FAMILIES
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
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)
const Point & GetMousePosPixel() const
Size GetOutputSize() const
float GetDPIScaleFactor() const
void SetTextColor(const Color &rColor)
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
SAL_DLLPRIVATE SfxDispatcher * GetDispatcher_Impl()
void Update(sal_uInt16 nId)
SfxDispatcher * GetDispatcher() const
void Invalidate(sal_uInt16 nId)
bool GetNotifyUpdate() const
void SelectStyle(const OUString &rStyle, bool bIsCallback, StyleList &rStyleList)
void SetNotifyupdate(bool b)
virtual void EnableItem(const OUString &, bool=true)
void FamilySelect(sal_uInt16 nId, StyleList &rStyleList, bool bRefresh=false)
void IsUpdate(StyleList &)
void connect_stylelist_enable_delete(const Link< void *, void > rLink)
void connect_stylelist_cleanup(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 EnableShow(bool b, const StyleList *rStyleList)
void connect_stylelist_execute_new_menu(const Link< void *, void > &rLink)
void connect_stylelist_execute_drop(const Link< const ExecuteDropEvent &, sal_Int8 > &rLink)
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)
void connect_stylelist_for_watercan(const Link< void *, bool > &rLink)
void connect_stylelist_enable_tree_drag(const Link< bool, void > rLink)
void connect_stylelist_has_selected_style(const Link< void *, bool > &rLink)
void EnableNew(bool b, const StyleList *rStyleList)
virtual bool IsCheckedItem(const OUString &)
void connect_set_family(const Link< sal_uInt16, void > rLink)
void connect_stylelist_read_resource(const Link< void *, size_t > &rLink)
virtual void CheckItem(const OUString &, bool=true)
void connect_stylelist_clear(const Link< void *, void > &rLink)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
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.
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
virtual std::optional< SfxStyleFamilies > CreateStyleFamilies()
const SvGlobalName & GetClassId() const
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
sal_uInt16 GetAutoStyleFilterIndex() const
virtual sfx2::StyleManager * GetStyleManager()
virtual SfxObjectFactory & GetFactory() const =0
SfxModule * GetModule() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
SfxViewShell * GetViewShell() const
Returns the SfxViewShell in which they are located in the subshells.
SfxStyleFamily GetFamily() const
const SfxStyleFilter & GetFilterList() const
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
SfxStyleSheetBase * Next()
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
SfxStyleSearchBits GetMask() const
virtual bool HasClearParentSupport() const
virtual const OUString & GetParent() const
const OUString & GetName() const
SfxStyleFamily GetFamily() const
bool IsUserDefined() const
virtual bool HasParentSupport() const
virtual bool IsHidden() const
virtual bool IsUsed() const
virtual OUString GetUsedBy()
const OUString & GetStyleName() const
SfxStyleSearchBits GetValue() const
void Resize(bool bForce=false)
SfxFrame & GetFrame() const
virtual SfxObjectShell * GetObjectShell() override
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
StylesHighlighterColorMap & GetStylesHighlighterCharColorMap()
StylesHighlighterColorMap & GetStylesHighlighterParaColorMap()
vcl::Window * GetWindow() const
constexpr tools::Long Width() const
const SfxStyleFamilyItem & GetFamilyItemByIndex(size_t i) const
sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt, const DropTargetHelper &rHelper)
Drop is enabled as long as it is allowed to create a new style by example, i.e.
void FamilySelect(sal_uInt16 nEntry, bool bRefresh=false)
bool m_bNewByExampleDisabled
Link< StyleFlags, void > m_aUpdateStyles
std::unique_ptr< weld::TreeView > m_xTreeBox
void UpdateStyles(StyleFlags nFlags)
SfxStyleFamily GetActualFamily() const
bool m_bHighlightCharStyles
OUString getDefaultStyleName(const SfxStyleFamily eFam)
std::optional< SfxStyleFamilies > m_xStyleFamilies
std::array< std::unique_ptr< SfxTemplateItem >, MAX_FAMILIES > m_pFamilyState
std::unique_ptr< Idle > pIdle
Link< StyleList &, SfxObjectShell * > m_aSaveSelection
SfxCommonTemplateDialog_Impl * m_pParentDialog
Link< void *, void > m_aClearResource
void connect_LoadFactoryStyleFilter(const Link< SfxObjectShell const *, sal_Int32 > &rLink)
Link< StyleList &, void > m_aUpdateFamily
void SelectStyle(const OUString &rStr, bool bIsCallback)
Link< StyleList &, void > m_aReadResource
const SfxStyleFamilyItem * GetFamilyItem() const
void SetFamilyState(sal_uInt16 nSlotId, const SfxTemplateItem *pItem)
void PrepareMenu(const Point &rPos)
void EnableNewByExample(bool newByExampleDisabled)
void connect_SaveSelection(const Link< StyleList &, SfxObjectShell * > rLink)
std::unique_ptr< weld::Menu > mxMenu
void MenuSelect(const OUString &rIdent)
bool m_bHighlightParaStyles
std::unique_ptr< TreeViewDropTarget > m_xTreeView2DropTargetHelper
SfxObjectShell * m_pCurObjShell
StyleList(weld::Builder *pBuilder, SfxBindings *pBindings, SfxCommonTemplateDialog_Impl *Parent, weld::Container *pC, OUString treeviewname, OUString flatviewname)
void SetFilterControlsHandle()
void ShowMenu(const CommandEvent &rCEvt)
void FillTreeBox(SfxStyleFamily eFam)
sal_uInt16 StyleNrToInfoOffset(sal_uInt16 i)
SfxStyleSearchBits m_nAppFilter
std::unique_ptr< TreeViewDropTarget > m_xTreeView1DropTargetHelper
void FilterSelect(sal_uInt16 nActFilter, bool bsetFilter)
SfxBindings * m_pBindings
bool m_bModuleHasStylesHighlighterFeature
std::unique_ptr< weld::TreeView > m_xFmtLb
Link< SfxObjectShell const *, sal_Int32 > m_aLoadFactoryStyleFilter
bool m_bAllowReParentDrop
void InvalidateBindings()
SfxStyleSheetBasePool * m_pStyleSheetPool
void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
void DropHdl(const OUString &rStyle, const OUString &rParent)
std::unique_ptr< weld::Builder > mxMenuBuilder
friend class TreeViewDropTarget
void GetSelectedStyle() const
OUString GetSelectedEntry() const
const Color & GetDialogTextColor() const
const Color & GetHighlightTextColor() const
const Color & GetDisableColor() const
const Size & GetListBoxPreviewDefaultPixelSize() const
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
TreeViewDropTarget(StyleList &rStyleList, weld::TreeView &rTreeView)
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
reference_type * get() const
virtual std::unique_ptr< StylePreviewRenderer > CreateStylePreviewRenderer(OutputDevice &rOutputDev, SfxStyleSheetBase *pStyle, tools::Long nMaxHeight)=0
SfxStyleSheetBase * Search(std::u16string_view rStyleName, SfxStyleFamily eFamily)
sal_uInt16 GetCode() const
sal_uInt16 GetModifier() const
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const=0
virtual bool get_row_expanded(const TreeIter &rIter) const=0
virtual OUString get_text(int row, int col=-1) const=0
std::tuple< vcl::RenderContext &, const tools::Rectangle &, bool, const OUString & > render_args
virtual void insert(const TreeIter *pParent, int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface, bool bChildrenOnDemand, TreeIter *pRet)=0
virtual TreeView * get_drag_source() const=0
virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter *pResult, bool bDnDMode, bool bAutoScroll=true)=0
virtual void selected_foreach(const std::function< bool(TreeIter &)> &func)=0
virtual bool get_iter_first(TreeIter &rIter) const=0
virtual bool is_selected(int pos) const=0
virtual void select(int pos)=0
virtual bool iter_next(TreeIter &rIter) const=0
std::pair< vcl::RenderContext &, const OUString & > get_size_args
virtual void set_cursor(int pos)=0
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
ScXMLEditAttributeMap::Entry const aEntries[]
Reference< XInterface > xTarget
constexpr OUStringLiteral HID_TEMPLATE_FMT
constexpr sal_uInt16 KEY_DELETE
#define LINK(Instance, Class, Member)
std::vector< SvLinkSource_Entry_Impl * > aArr
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
static SfxStyleFamily NIdToSfxFamilyId(sal_uInt16 nId)
static sal_uInt16 SfxFamilyIdToNId(SfxStyleFamily nFamily)
void Clear(EHistoryType eHistory)
BColor hsl2rgb(const BColor &rHSLColor)
const LanguageTag & getLocale()
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
void RemoveParentKeepChildren(weld::TreeView &rTreeView, const weld::TreeIter &rParent)
OUString SfxResId(TranslateId aId)
Reference< XFrame > xFrame
Reference< XModel > xModel
std::unordered_map< OUString, std::pair< Color, int > > StylesHighlighterColorMap