28#include <sfx2/sfxsids.hrc>
35#include <editeng/editids.hrc>
57#include <com/sun/star/drawing/FillStyle.hpp>
58#include <com/sun/star/i18n/ScriptType.hpp>
59#include <com/sun/star/uno/Sequence.hxx>
65 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
67 , m_pPreviewControl(pPreviewControl)
86 : m_pPreviewControl(pPreviewControl)
111 , m_aStyleName(
std::move(aStyleName))
122 rRenderContext.
Pop();
127 if (rEvent.
GetCommand() != CommandEventId::ContextMenu)
130 std::unique_ptr<weld::Builder> xBuilder(
132 std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu(
"menu"));
135 if (rIdent ==
"update" || rIdent ==
"edit")
137 css::uno::Sequence<css::beans::PropertyValue> aArgs(0);
140 rIdent ==
"update" ? OUString(
".uno:StyleUpdateByExample")
141 : OUString(
".uno:EditStyle"),
152 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_CHAR_COLOR);
161 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_BRUSH_CHAR);
163 return static_cast<const SvxBrushItem*
>(pItem)->GetColor();
172 return static_cast<const XFillColorItem*
>(pItem)->GetColorValue();
183 return css::drawing::FillStyle_NONE;
187 std::optional<SfxItemSet>
const& pItemSet)
193 aFont.SetFontSize(aPixelFontSize);
195 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_CHAR_WEIGHT);
197 aFont.SetWeight(
static_cast<const SvxWeightItem*
>(pItem)->GetWeight());
199 pItem = pItemSet->GetItem(SID_ATTR_CHAR_POSTURE);
201 aFont.SetItalic(
static_cast<const SvxPostureItem*
>(pItem)->GetPosture());
203 pItem = pItemSet->GetItem(SID_ATTR_CHAR_CONTOUR);
207 pItem = pItemSet->GetItem(SID_ATTR_CHAR_SHADOWED);
211 pItem = pItemSet->GetItem(SID_ATTR_CHAR_RELIEF);
215 pItem = pItemSet->GetItem(SID_ATTR_CHAR_UNDERLINE);
217 aFont.SetUnderline(
static_cast<const SvxUnderlineItem*
>(pItem)->GetLineStyle());
219 pItem = pItemSet->GetItem(SID_ATTR_CHAR_OVERLINE);
223 pItem = pItemSet->GetItem(SID_ATTR_CHAR_STRIKEOUT);
225 aFont.SetStrikeout(
static_cast<const SvxCrossedOutItem*
>(pItem)->GetStrikeout());
227 pItem = pItemSet->GetItem(SID_ATTR_CHAR_CASEMAP);
231 pItem = pItemSet->GetItem(SID_ATTR_CHAR_EMPHASISMARK);
253 pStyle = pPool->
Next();
273 sal_Int16 nScriptType
276 sal_uInt16 nFontSlot = SID_ATTR_CHAR_FONT;
277 if (nScriptType == css::i18n::ScriptType::ASIAN)
278 nFontSlot = SID_ATTR_CHAR_CJK_FONT;
279 else if (nScriptType == css::i18n::ScriptType::COMPLEX)
280 nFontSlot = SID_ATTR_CHAR_CTL_FONT;
286 if (pFontItem && pFontHeightItem)
288 Size aFontSize(0, pFontHeightItem->GetHeight());
304 case css::drawing::FillStyle_SOLID:
333 rRenderContext.
DrawRect(aContentRect);
372 weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
373 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
374 : m_xDispatchProvider(xDispatchProvider)
375 , m_xStylesView(xBuilder.weld_icon_view(
"stylesview"))
376 , m_aUpdateTask(*this)
377 , m_aDefaultStyles(
std::move(aDefaultStyles))
392 OUString sStyleName = rIconView.get_selected_text();
394 css::uno::Sequence<css::beans::PropertyValue> aArgs{
403 OUString sStyleName = rIconView.get_selected_text();
405 css::uno::Sequence<css::beans::PropertyValue> aArgs{
416 return Command(rPos);
429 catch (css::uno::Exception&)
445 for (std::vector<std::pair<OUString, OUString>>::size_type
i = 0;
i <
m_aAllStyles.size(); ++
i)
475 auto xIter = pStyleSheetPool->
CreateIterator(SfxStyleFamily::Para,
476 SfxStyleSearchBits::UserDefined);
483 pStyle = xIter->Next();
491 const Size aSize(100, 30);
492 pImg->SetOutputSizePixel(aSize);
495 aStyleController.
Paint(*pImg);
502 vcl::Window* pParent, std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
503 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
static Color GetTextColorFromItemSet(std::optional< SfxItemSet > const &pItemSet)
IMPL_LINK(StylesPreviewWindow_Base, Selected, weld::IconView &, rIconView, void)
static css::drawing::FillStyle GetFillStyleFromItemSet(std::optional< SfxItemSet > const &pItemSet)
static SvxFont GetFontFromItems(const SvxFontItem *pFontItem, Size aPixelFontSize, std::optional< SfxItemSet > const &pItemSet)
static Color GetHighlightColorFromItemSet(std::optional< SfxItemSet > const &pItemSet)
static Color GetBackgroundColorFromItemSet(std::optional< SfxItemSet > const &pItemSet)
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
virtual void Start(bool bStartTimer=true) override
virtual void dispose() override
static sal_Int16 getScriptType(LanguageType nLang)
void SetFont(const vcl::Font &rNewFont)
Size GetOutputSizePixel() const
void DrawRect(const tools::Rectangle &rRect)
tools::Long GetOutputHeightPixel() const
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
void SetTextColor(const Color &rColor)
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const Color & GetLineColor() const
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)
const Color & GetFillColor() const
static SalLayoutGlyphsCache * self()
const SalLayoutGlyphs * GetLayoutGlyphs(VclPtr< const OutputDevice > outputDevice, const OUString &text, const vcl::text::TextLayoutCache *layoutCache=nullptr)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
MapUnit GetMapUnit() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
SfxStyleSheetBase * Next()
const OUString & GetName() const
virtual std::optional< SfxItemSet > GetItemSetForPreview()
const OUString & GetStyleName() const
const OUString & GetStyleIdentifier() const
constexpr tools::Long getHeight() const
tools::Long AdjustHeight(tools::Long n)
void DrawHighlight(vcl::RenderContext &rRenderContext, Color aFontBack)
void Paint(vcl::RenderContext &rRenderContext)
void DrawText(vcl::RenderContext &rRenderContext)
StyleItemController(std::pair< OUString, OUString > aStyleName)
static void DrawContentBackground(vcl::RenderContext &rRenderContext, const tools::Rectangle &aContentRect, const Color &aColor)
void DrawEntry(vcl::RenderContext &rRenderContext)
static constexpr unsigned LEFT_MARGIN
SfxStyleFamily m_eStyleFamily
std::pair< OUString, OUString > m_aStyleName
Listener for styles creation or modification.
~StylePoolChangeListener()
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
StylesPreviewWindow_Base * m_pPreviewControl
StylePoolChangeListener(StylesPreviewWindow_Base *pPreviewControl)
SfxStyleSheetBasePool * m_pStyleSheetPool
Listener for style selection.
StyleStatusListener(StylesPreviewWindow_Base *pPreviewControl, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
void StateChangedAtStatusListener(SfxItemState eState, const SfxPoolItem *pState) override
StylesPreviewWindow_Base * m_pPreviewControl
virtual void Invoke() override
StylesPreviewWindow_Base & m_rStylesList
std::vector< std::pair< OUString, OUString > > m_aDefaultStyles
void RequestStylesListUpdate()
StylesListUpdateTask m_aUpdateTask
OUString m_sSelectedStyle
~StylesPreviewWindow_Base()
std::unique_ptr< weld::IconView > m_xStylesView
css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider
std::vector< std::pair< OUString, OUString > > m_aAllStyles
bool Command(const CommandEvent &rEvent)
void Select(const OUString &rStyleName)
StylesPreviewWindow_Base(weld::Builder &xBuilder, std::vector< std::pair< OUString, OUString > > &&aDefaultStyles, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
rtl::Reference< StyleStatusListener > m_xStatusListener
std::unique_ptr< StylePoolChangeListener > m_pStylePoolChangeListener
StylesPreviewWindow_Impl(vcl::Window *pParent, std::vector< std::pair< OUString, OUString > > &&aDefaultStyles, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
~StylesPreviewWindow_Impl()
const OUString & GetStyleName() const
const OUString & GetFamilyName() const
void SetCaseMap(const SvxCaseMap eNew)
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void SetSizePixel(const Size &rNewSize)
Size get_preferred_size() const
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define LINK(Instance, Class, Member)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr OUStringLiteral first
sal_Int16 GetCaseMap(sal_Int32 nToken)
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)