27 #include <sfx2/sfxsids.hrc>
34 #include <editeng/editids.hrc>
56 #include <com/sun/star/drawing/FillStyle.hpp>
57 #include <com/sun/star/i18n/ScriptType.hpp>
58 #include <com/sun/star/uno/Sequence.hxx>
64 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
66 , m_pPreviewControl(pPreviewControl)
85 : m_pPreviewControl(pPreviewControl)
110 , m_aStyleName(aStyleName)
121 rRenderContext.
Pop();
126 if (rEvent.
GetCommand() != CommandEventId::ContextMenu)
129 std::unique_ptr<weld::Builder> xBuilder(
131 std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu(
"menu"));
134 if (rIdent ==
"update" || rIdent ==
"edit")
136 css::uno::Sequence<css::beans::PropertyValue> aArgs(0);
139 rIdent ==
"update" ? OUString(
".uno:StyleUpdateByExample")
140 : OUString(
".uno:EditStyle"),
151 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_CHAR_COLOR);
160 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_BRUSH_CHAR);
162 return static_cast<const SvxBrushItem*
>(pItem)->GetColor();
171 return static_cast<const XFillColorItem*
>(pItem)->GetColorValue();
182 return css::drawing::FillStyle_NONE;
186 std::optional<SfxItemSet>
const& pItemSet)
192 aFont.SetFontSize(aPixelFontSize);
194 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_CHAR_WEIGHT);
196 aFont.SetWeight(static_cast<const SvxWeightItem*>(pItem)->GetWeight());
198 pItem = pItemSet->GetItem(SID_ATTR_CHAR_POSTURE);
200 aFont.SetItalic(static_cast<const SvxPostureItem*>(pItem)->GetPosture());
202 pItem = pItemSet->GetItem(SID_ATTR_CHAR_CONTOUR);
204 aFont.SetOutline(static_cast<const SvxContourItem*>(pItem)->
GetValue());
206 pItem = pItemSet->GetItem(SID_ATTR_CHAR_SHADOWED);
208 aFont.SetShadow(static_cast<const SvxShadowedItem*>(pItem)->
GetValue());
210 pItem = pItemSet->GetItem(SID_ATTR_CHAR_RELIEF);
212 aFont.SetRelief(static_cast<const SvxCharReliefItem*>(pItem)->
GetValue());
214 pItem = pItemSet->GetItem(SID_ATTR_CHAR_UNDERLINE);
216 aFont.SetUnderline(static_cast<const SvxUnderlineItem*>(pItem)->GetLineStyle());
218 pItem = pItemSet->GetItem(SID_ATTR_CHAR_OVERLINE);
220 aFont.SetOverline(static_cast<const SvxOverlineItem*>(pItem)->
GetValue());
222 pItem = pItemSet->GetItem(SID_ATTR_CHAR_STRIKEOUT);
224 aFont.SetStrikeout(static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout());
226 pItem = pItemSet->GetItem(SID_ATTR_CHAR_CASEMAP);
230 pItem = pItemSet->GetItem(SID_ATTR_CHAR_EMPHASISMARK);
232 aFont.SetEmphasisMark(static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark());
252 pStyle = pPool->
Next();
272 sal_Int16 nScriptType
275 sal_uInt16 nFontSlot = SID_ATTR_CHAR_FONT;
276 if (nScriptType == css::i18n::ScriptType::ASIAN)
277 nFontSlot = SID_ATTR_CHAR_CJK_FONT;
278 else if (nScriptType == css::i18n::ScriptType::COMPLEX)
279 nFontSlot = SID_ATTR_CHAR_CTL_FONT;
285 if (pFontItem && pFontHeightItem)
287 Size aFontSize(0, pFontHeightItem->GetHeight());
303 case css::drawing::FillStyle_SOLID:
332 rRenderContext.
DrawRect(aContentRect);
370 weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
371 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
372 : m_xDispatchProvider(xDispatchProvider)
373 , m_xStylesView(xBuilder.weld_icon_view(
"stylesview"))
374 , m_aUpdateTask(*this)
375 , m_aDefaultStyles(
std::move(aDefaultStyles))
390 OUString sStyleName = rIconView.get_selected_text();
392 css::uno::Sequence<css::beans::PropertyValue> aArgs{
401 OUString sStyleName = rIconView.get_selected_text();
403 css::uno::Sequence<css::beans::PropertyValue> aArgs{
414 return Command(rPos);
427 catch (css::uno::Exception&)
443 for (std::vector<std::pair<OUString, OUString>>::size_type
i = 0;
i <
m_aAllStyles.size(); ++
i)
473 auto xIter = pStyleSheetPool->
CreateIterator(SfxStyleFamily::Para,
474 SfxStyleSearchBits::UserDefined);
481 pStyle = xIter->Next();
489 const Size aSize(100, 30);
490 pImg->SetOutputSizePixel(aSize);
493 aStyleController.
Paint(*pImg);
500 vcl::Window* pParent, std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
501 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
#define LINK(Instance, Class, Member)
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
StylesPreviewWindow_Base & m_rStylesList
StyleStatusListener(StylesPreviewWindow_Base *pPreviewControl, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
~StylesPreviewWindow_Impl()
void DrawEntry(vcl::RenderContext &rRenderContext)
virtual std::optional< SfxItemSet > GetItemSetForPreview()
bool Command(const CommandEvent &rEvent)
virtual void Invoke() override
std::vector< std::pair< OUString, OUString > > m_aDefaultStyles
const SalLayoutGlyphs * GetLayoutGlyphs(VclPtr< const OutputDevice > outputDevice, const OUString &text, const vcl::text::TextLayoutCache *layoutCache=nullptr)
std::unique_ptr< StylePoolChangeListener > m_pStylePoolChangeListener
Listener for style selection.
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
static const AllSettings & GetSettings()
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
constexpr::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
virtual void SetSizePixel(const Size &rNewSize)
static SfxObjectShell * Current()
static void DrawContentBackground(vcl::RenderContext &rRenderContext, const tools::Rectangle &aContentRect, const Color &aColor)
SfxStyleSheetBasePool * m_pStyleSheetPool
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
const OUString & GetName() const
StylesPreviewWindow_Base(weld::Builder &xBuilder, std::vector< std::pair< OUString, OUString >> &&aDefaultStyles, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
void StateChangedAtStatusListener(SfxItemState eState, const SfxPoolItem *pState) override
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, o3tl::span< const sal_Int32 > pDXArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
constexpr tools::Long getHeight() const
void DrawRect(const tools::Rectangle &rRect)
const OUString & GetStyleName() const
css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider
std::vector< std::pair< OUString, OUString > > m_aAllStyles
static SalLayoutGlyphsCache * self()
tools::Long GetOutputHeightPixel() const
static css::drawing::FillStyle GetFillStyleFromItemSet(std::optional< SfxItemSet > const &pItemSet)
const Color & GetLineColor() const
CommandEventId GetCommand() const
static Color GetBackgroundColorFromItemSet(std::optional< SfxItemSet > const &pItemSet)
void SetTextColor(const Color &rColor)
Size get_preferred_size() const
Size GetOutputSizePixel() const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
SfxStyleFamily m_eStyleFamily
const OUString & GetStyleName() const
static sal_Int16 getScriptType(LanguageType nLang)
void RequestStylesListUpdate()
exports com.sun.star. style
StylesPreviewWindow_Impl(vcl::Window *pParent, std::vector< std::pair< OUString, OUString >> &&aDefaultStyles, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
const Point & GetMousePosPixel() const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
std::pair< OUString, OUString > m_aStyleName
void Paint(vcl::RenderContext &rRenderContext)
const OUString & GetFamilyName() const
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
StylesPreviewWindow_Base * m_pPreviewControl
static constexpr unsigned LEFT_MARGIN
void SetCaseMap(const SvxCaseMap eNew)
void Select(const OUString &rStyleName)
void DrawHighlight(vcl::RenderContext &rRenderContext, Color aFontBack)
Listener for styles creation or modification.
~StylesPreviewWindow_Base()
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
void SetFont(const vcl::Font &rNewFont)
SfxStyleSheetBase * Next()
virtual void dispose() override
void DrawText(vcl::RenderContext &rRenderContext)
MapUnit GetMapUnit() const
std::unique_ptr< weld::IconView > m_xStylesView
const OUString & GetStyleIdentifier() const
static VclPtr< reference_type > Create(Arg &&...arg)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
StylesPreviewWindow_Base * m_pPreviewControl
~StylePoolChangeListener()
tools::Long AdjustHeight(tools::Long n)
OUString m_sSelectedStyle
IMPL_LINK(StylesPreviewWindow_Base, Selected, weld::IconView &, rIconView, void)
StylesListUpdateTask m_aUpdateTask
virtual void Start(bool bStartTimer=true) override
static Color GetTextColorFromItemSet(std::optional< SfxItemSet > const &pItemSet)
rtl::Reference< StyleStatusListener > m_xStatusListener
StylePoolChangeListener(StylesPreviewWindow_Base *pPreviewControl)
constexpr OUStringLiteral first
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)
StyleItemController(const std::pair< OUString, OUString > &aStyleName)
sal_Int16 GetCaseMap(sal_Int32 nToken)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
const Color & GetFillColor() const
static Color GetHighlightColorFromItemSet(std::optional< SfxItemSet > const &pItemSet)
static SvxFont GetFontFromItems(const SvxFontItem *pFontItem, Size aPixelFontSize, std::optional< SfxItemSet > const &pItemSet)