28#include <com/sun/star/lang/XServiceInfo.hpp>
48 ,
m_xWidget(m_xBuilder->weld_entry(
"entry"))
52 m_xWidget->connect_key_press(
LINK(
this, CurrentEdit, KeyInputHdl));
62 void set_sensitive(
bool bSensitive)
68 bool get_sensitive()
const
78 OUString get_text()
const
88 virtual ~CurrentEdit()
override
96 return ChildKeyInput(rKEvt);
100typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> MMCurrentEntryController_Base;
101class MMCurrentEntryController :
public MMCurrentEntryController_Base
108 explicit MMCurrentEntryController(
const uno::Reference<uno::XComponentContext>& rContext)
109 : MMCurrentEntryController_Base(rContext,
uno::
Reference<frame::XFrame>(),
".uno:MailMergeCurrentEntry")
110 , m_xCurrentEdit(nullptr)
117 return "lo.writer.MMCurrentEntryController";
127 return {
"com.sun.star.frame.ToolbarController" };
131 virtual void SAL_CALL
dispose()
override;
134 virtual uno::Reference<awt::XWindow> SAL_CALL createItemWindow(
const uno::Reference<awt::XWindow>& rParent)
override;
137 virtual void SAL_CALL statusChanged(
const frame::FeatureStateEvent& rEvent)
override;
143 std::unique_ptr<weld::CheckButton>
m_xWidget;
149 ,
m_xWidget(m_xBuilder->weld_check_button(
"checkbutton"))
154 m_xWidget->connect_key_press(
LINK(
this, ExcludeCheckBox, KeyInputHdl));
158 virtual void dispose()
override
164 void set_sensitive(
bool bSensitive)
170 void set_active(
bool bActive)
180 virtual ~ExcludeCheckBox()
override
188 return ChildKeyInput(rKEvt);
192typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> MMExcludeEntryController_Base;
193class MMExcludeEntryController :
public MMExcludeEntryController_Base
200 explicit MMExcludeEntryController(
const uno::Reference<uno::XComponentContext>& rContext)
201 : MMExcludeEntryController_Base(rContext,
uno::
Reference<frame::XFrame>(),
".uno:MailMergeExcludeEntry")
202 , m_xExcludeCheckbox(nullptr)
209 return "lo.writer.MMExcludeEntryController";
219 return {
"com.sun.star.frame.ToolbarController" };
223 virtual void SAL_CALL
dispose()
override;
226 virtual uno::Reference<awt::XWindow> SAL_CALL createItemWindow(
const uno::Reference<awt::XWindow>& rParent)
override;
229 virtual void SAL_CALL statusChanged(
const frame::FeatureStateEvent& rEvent)
override;
237 m_xCurrentEdit.disposeAndClear();
240uno::Reference<awt::XWindow> MMCurrentEntryController::createItemWindow(
const uno::Reference<awt::XWindow>& rParent)
248 m_xCurrentEdit->connect_activate(
LINK(
this, MMCurrentEntryController, CurrentEditUpdatedHdl));
256 std::shared_ptr<SwMailMergeConfigItem> xConfigItem;
258 xConfigItem = pView->GetMailMergeConfigItem();
263 OUString aText(rEdit.get_text());
264 sal_Int32 nEntry = aText.toInt32();
265 if (!aText.isEmpty() && nEntry != xConfigItem->GetResultSetPosition())
267 xConfigItem->MoveResultSet(nEntry);
269 dispatchCommand(
".uno:MailMergeCurrentEntry", uno::Sequence<beans::PropertyValue>());
274void MMCurrentEntryController::statusChanged(
const frame::FeatureStateEvent& rEvent)
279 std::shared_ptr<SwMailMergeConfigItem> xConfigItem;
281 xConfigItem = pView->GetMailMergeConfigItem();
283 if (!xConfigItem || !rEvent.IsEnabled)
285 m_xCurrentEdit->set_sensitive(
false);
286 m_xCurrentEdit->set_text(
"");
290 sal_Int32 nEntry = m_xCurrentEdit->get_text().toInt32();
291 if (!m_xCurrentEdit->get_sensitive() || nEntry != xConfigItem->GetResultSetPosition())
293 m_xCurrentEdit->set_sensitive(
true);
294 m_xCurrentEdit->set_text(OUString::number(xConfigItem->GetResultSetPosition()));
304 m_xExcludeCheckbox.disposeAndClear();
307uno::Reference<awt::XWindow> MMExcludeEntryController::createItemWindow(
const uno::Reference<awt::XWindow>& rParent)
315 m_xExcludeCheckbox->connect_toggled(
LINK(
this, MMExcludeEntryController, ExcludeHdl));
323 std::shared_ptr<SwMailMergeConfigItem> xConfigItem;
325 xConfigItem = pView->GetMailMergeConfigItem();
328 xConfigItem->ExcludeRecord(xConfigItem->GetResultSetPosition(), rCheckbox.get_active());
331void MMExcludeEntryController::statusChanged(
const frame::FeatureStateEvent& rEvent)
333 if (!m_xExcludeCheckbox)
336 std::shared_ptr<SwMailMergeConfigItem> xConfigItem;
338 xConfigItem = pView->GetMailMergeConfigItem();
340 if (!xConfigItem || !rEvent.IsEnabled)
342 m_xExcludeCheckbox->set_sensitive(
false);
343 m_xExcludeCheckbox->set_active(
false);
347 m_xExcludeCheckbox->set_sensitive(
true);
348 m_xExcludeCheckbox->set_active(xConfigItem->IsRecordExcluded(xConfigItem->GetResultSetPosition()));
354extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface *
356 uno::XComponentContext *context,
357 uno::Sequence<uno::Any>
const &)
359 return cppu::acquire(
new MMCurrentEntryController(context));
362extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface *
364 uno::XComponentContext *context,
365 uno::Sequence<uno::Any>
const &)
367 return cppu::acquire(
new MMExcludeEntryController(context));
IMPL_LINK(SwAccessibleDocument, WindowChildEventListener, VclWindowEvent &, rEvent, void)
virtual void dispose() override
void InitControlBase(weld::Widget *pWidget)
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void SetSizePixel(const Size &rNewSize)
void Enable(bool bEnable=true, bool bChild=true)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
#define LINK(Instance, Class, Member)
#define DECL_STATIC_LINK(Class, Member, ArgType, RetType)
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OUString SwResId(TranslateId aId)