24#include <com/sun/star/uno/Reference.hxx>
25#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
26#include <com/sun/star/beans/XPropertySet.hpp>
51 const css::uno::Reference<css::frame::XModel>& xModel)
58 css::uno::Reference<css::style::XStyleFamiliesSupplier> xStylesSupplier(
59 xModel, css::uno::UNO_QUERY_THROW);
60 css::uno::Reference<css::lang::XServiceInfo> xServices(
xModel, css::uno::UNO_QUERY_THROW);
61 if (xServices->supportsService(
"com.sun.star.text.TextDocument"))
63 css::uno::Reference<css::container::XNameAccess> xParaStyles;
64 xStylesSupplier->getStyleFamilies()->getByName(
"ParagraphStyles") >>= xParaStyles;
65 static const std::vector<OUString> aWriterStyles
66 = {
"Standard",
"Text body",
"Heading 1",
"Heading 2",
"Heading 3",
67 "Heading 4",
"Title",
"Subtitle",
"Quotations",
"Preformatted Text" };
68 for (
const OUString& aStyle : aWriterStyles)
72 css::uno::Reference<css::beans::XPropertySet> xStyle;
73 xParaStyles->getByName(aStyle) >>= xStyle;
75 xStyle->getPropertyValue(
"DisplayName") >>=
sName;
79 catch (
const css::container::NoSuchElementException&)
82 catch (
const css::uno::Exception&)
87 else if (xServices->supportsService(
"com.sun.star.sheet.SpreadsheetDocument"))
89 static const char* aCalcStyles[] = {
"Default",
"Accent 1",
"Accent 2",
"Accent 3",
90 "Heading 1",
"Heading 2",
"Result" };
91 css::uno::Reference<css::container::XNameAccess> xCellStyles;
92 xStylesSupplier->getStyleFamilies()->getByName(
"CellStyles") >>= xCellStyles;
93 for (
const char* pCalcStyle : aCalcStyles)
97 const OUString sStyleName(OUString::createFromAscii(pCalcStyle));
98 if (xCellStyles->hasByName(sStyleName))
100 css::uno::Reference<css::beans::XPropertySet> xStyle(
101 xCellStyles->getByName(sStyleName), css::uno::UNO_QUERY_THROW);
103 xStyle->getPropertyValue(
"DisplayName") >>=
sName;
104 if (!
sName.isEmpty())
107 std::pair<OUString, OUString>(sStyleName,
sName));
111 catch (
const css::uno::Exception&)
117 catch (
const css::uno::Exception&)
119 OSL_FAIL(
"error while initializing style names");
127css::uno::Reference<css::awt::XWindow>
130 css::uno::Reference<css::awt::XWindow> xItemWindow;
164 return "com.sun.star.comp.svx.StylesPreviewToolBoxControl";
174 return {
"com.sun.star.frame.ToolbarController" };
177extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
179 css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any>
const&)
css::uno::Reference< css::lang::XComponent > m_xFrame
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
static VclPtr< reference_type > Create(Arg &&... arg)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Reference< XModel > xModel