19#include <com/sun/star/frame/XController.hpp>
20#include <com/sun/star/frame/status/Template.hpp>
21#include <com/sun/star/lang/DisposedException.hpp>
22#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
23#include <com/sun/star/util/XURLTransformer.hpp>
27OUString MapFamilyToCommand( std::u16string_view rFamily )
29 if ( rFamily == u
"ParagraphStyles" ||
30 rFamily == u
"CellStyles" ||
31 rFamily == u
"graphics" )
32 return ".uno:ParaStyle";
33 else if ( rFamily == u
"CharacterStyles" )
34 return ".uno:CharStyle";
35 else if ( rFamily == u
"PageStyles" )
36 return ".uno:PageStyle";
37 else if ( rFamily == u
"FrameStyles" ||
38 rFamily == u
"GraphicStyles" )
39 return ".uno:FrameStyle";
40 else if ( rFamily == u
"NumberingStyles" )
41 return ".uno:ListStyle";
42 else if ( rFamily == u
"TableStyles" )
43 return ".uno:TableStyle";
48OUString GetDisplayFromInternalName(
const css::uno::Reference< css::frame::XFrame >& rFrame,
49 const OUString& rStyleName,
50 const OUString& rFamilyName )
54 css::uno::Reference< css::frame::XController >
xController(
55 rFrame->getController(), css::uno::UNO_SET_THROW );
56 css::uno::Reference< css::style::XStyleFamiliesSupplier > xStylesSupplier(
57 xController->getModel(), css::uno::UNO_QUERY_THROW );
58 css::uno::Reference< css::container::XNameAccess > xFamilies(
59 xStylesSupplier->getStyleFamilies(), css::uno::UNO_SET_THROW );
61 css::uno::Reference< css::container::XNameAccess > xStyleSet;
62 xFamilies->getByName( rFamilyName ) >>= xStyleSet;
63 css::uno::Reference< css::beans::XPropertySet > xStyle;
64 xStyleSet->getByName( rStyleName ) >>= xStyle;
66 OUString aDisplayName;
68 xStyle->getPropertyValue(
"DisplayName" ) >>= aDisplayName;
71 catch (
const css::uno::Exception& )
85 css::uno::Reference< css::util::XURLTransformer > xUrlTransformer,
86 const css::util::URL& rURL )
88 , m_xUrlTransformer(
std::move( xUrlTransformer ))
93 OUString aParams = rURL.Arguments;
94 OUString aStyleName, aFamilyName;
100 sal_Int32 nParamIndex = 0;
101 std::u16string_view aParamName =
o3tl::getToken(aParam, 0,
'=', nParamIndex );
102 if ( nParamIndex < 0 )
105 if ( aParamName ==
u"Style:string" )
107 std::u16string_view aValue =
o3tl::getToken(aParam, 0,
'=', nParamIndex );
110 else if ( aParamName ==
u"FamilyName:string" )
126 m_aStyleName = GetDisplayFromInternalName( rFrame, aStyleName, aFamilyName );
129 css::util::URL aStatusURL;
137 const css::uno::Sequence< css::beans::PropertyValue >& rArguments )
142 css::uno::Reference< css::frame::XDispatch >
xDispatch(
m_xFrame->queryDispatch( rURL, OUString(), 0 ) );
148 const css::util::URL& )
155 css::util::URL aStatusURL;
163 const css::util::URL& )
167 css::util::URL aStatusURL;
176 css::frame::status::Template aTemplate;
177 rEvent.State >>= aTemplate;
179 css::frame::FeatureStateEvent
aEvent;
183 aEvent.IsEnabled = rEvent.IsEnabled;
184 aEvent.Requery = rEvent.Requery;
195 const css::uno::Reference< css::frame::XFrame >& rFrame,
196 const OUString& rCommand )
197 : ToolboxController( rContext, rFrame, rCommand )
204 throw css::lang::DisposedException();
211 if ( xDispatcher.is() )
212 xDispatcher->removeStatusListener(
this,
aURL );
215 xDispatcher->addStatusListener(
this,
aURL );
223 throw css::lang::DisposedException();
229 bool bChecked =
false;
230 rEvent.State >>= bChecked;
231 pToolBox->
CheckItem( nItemId, bChecked );
232 pToolBox->
EnableItem( nItemId, rEvent.IsEnabled );
238 ToolboxController::dispose();
css::uno::Reference< css::lang::XComponent > m_xFrame
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
A dispatcher that serves as a proxy for style commands with arguments i.e.
css::uno::Reference< css::util::XURLTransformer > m_xUrlTransformer
css::uno::Reference< css::frame::XStatusListener > m_xOwner
css::uno::Reference< css::frame::XDispatchProvider > m_xFrame
void SAL_CALL dispatch(const css::util::URL &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rArguments) override
OUString m_aStatusCommand
void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &rEvent) override
void SAL_CALL disposing(const css::lang::EventObject &rSource) override
void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > &rListener, const css::util::URL &rURL) override
void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > &rListener, const css::util::URL &rURL) override
css::uno::Reference< css::frame::XDispatch > m_xStatusDispatch
StyleDispatcher(const css::uno::Reference< css::frame::XFrame > &rFrame, css::uno::Reference< css::util::XURLTransformer > xUrlTransformer, const css::util::URL &rURL)
Reference< XDispatch > xDispatch
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
Reference< XController > xController