27#include <com/sun/star/awt/MenuItemStyle.hpp>
28#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
29#include <com/sun/star/container/XNameContainer.hpp>
30#include <com/sun/star/beans/XPropertySet.hpp>
33#include <rtl/ustrbuf.hxx>
34#include <osl/mutex.hxx>
57 return "com.sun.star.comp.framework.HeaderMenuController";
71 svt::PopupMenuControllerBase( xContext )
85 resetPopupMenu( rPopupMenu );
88 if (!xStyleFamiliesSupplier.is())
93 OUString aCmd(
".uno:InsertPageHeader" );
94 OUString aHeaderFooterIsOnStr(
"HeaderIsOn" );
97 aCmd =
".uno:InsertPageFooter";
98 aHeaderFooterIsOnStr =
"FooterIsOn";
100 static constexpr OUStringLiteral aIsPhysicalStr(
u"IsPhysical" );
101 static constexpr OUStringLiteral aDisplayNameStr(
u"DisplayName" );
106 if ( xStyleFamilies->getByName(
"PageStyles") >>= xNameContainer )
112 bool bAllOneState(
true );
113 bool bLastCheck(
true );
114 bool bFirstChecked(
false );
115 bool bFirstItemInserted(
false );
116 for ( sal_Int32
n = 0;
n < aSeqNames.getLength();
n++ )
118 OUString
aName = aSeqNames[
n];
122 bool bIsPhysical(
false );
123 if (( xPropSet->getPropertyValue( aIsPhysicalStr ) >>= bIsPhysical ) && bIsPhysical )
125 OUString aDisplayName;
126 bool bHeaderIsOn(
false );
127 xPropSet->getPropertyValue( aDisplayNameStr ) >>= aDisplayName;
128 xPropSet->getPropertyValue( aHeaderFooterIsOnStr ) >>= bHeaderIsOn;
130 OUStringBuffer aStrBuf( aCmd
131 +
"?PageStyle:string="
135 aStrBuf.append(
"true" );
137 aStrBuf.append(
"false" );
138 OUString
aCommand( aStrBuf.makeStringAndClear() );
139 rPopupMenu->insertItem(
nId, aDisplayName, css::awt::MenuItemStyle::CHECKABLE,
nCount);
140 if ( !bFirstItemInserted )
142 bFirstItemInserted =
true;
143 bFirstChecked = bHeaderIsOn;
147 rPopupMenu->checkItem(
nId, bHeaderIsOn);
151 if( bAllOneState &&
n && bHeaderIsOn != bLastCheck )
152 bAllOneState =
false;
153 bLastCheck = bHeaderIsOn;
159 if ( bAllOneState && (
nCount > 1 ))
164 OUStringBuffer aStrBuf( aCmd +
"?On:bool=" );
167 if ( !bFirstChecked )
168 aStrBuf.append(
"true" );
170 aStrBuf.append(
"false" );
172 rPopupMenu->setCommand(1, aStrBuf.makeStringAndClear());
173 rPopupMenu->insertSeparator(1);
177 catch (
const css::container::NoSuchElementException& )
191 if ( m_xPopupMenu.is() )
193 m_xPopupMenu.clear();
201 if ( Event.State >>=
xModel )
205 if ( m_xPopupMenu.is() )
215 throwIfDisposed(aLock);
221 svt::PopupMenuControllerBase::updatePopupMenu();
224 if ( m_xPopupMenu.is() &&
m_xModel.is() )
230extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
232 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
constexpr OUStringLiteral sServiceName
css::uno::Reference< css::lang::XComponent > m_xFrame
css::uno::Reference< css::frame::XDispatch > m_xDispatch
OUString FwkResId(TranslateId aId)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral SERVICENAME_POPUPMENUCONTROLLER
Reference< XModel > xModel