[Libreoffice-commits] core.git: Branch 'feature/mailmerge-toolbar' - officecfg/registry sw/Library_sw.mk sw/source sw/uiconfig sw/util

Jan Holesovsky kendy at collabora.com
Tue Dec 29 15:04:28 PST 2015


 officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu |   11 
 sw/Library_sw.mk                                                |    1 
 sw/source/uibase/app/apphdl.cxx                                 |    1 
 sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx              |  175 ++++++++++
 sw/uiconfig/swform/toolbar/mailmerge.xml                        |    1 
 sw/uiconfig/swreport/toolbar/mailmerge.xml                      |    1 
 sw/uiconfig/swriter/toolbar/mailmerge.xml                       |    1 
 sw/uiconfig/swxform/toolbar/mailmerge.xml                       |    1 
 sw/util/sw.component                                            |    4 
 9 files changed, 196 insertions(+)

New commits:
commit 1d0d967d0d18efe6e2125349af84150c316a1a6b
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Dec 30 00:00:37 2015 +0100

    mailmerge: Implement toolbar controller to exclude entries.
    
    Change-Id: I68269538f779a6680b0ba98395b7985d3f1ab95a

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index 31c9e4c..42559cf 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -855,6 +855,17 @@
           <value>starshapes;.uno:StarShapes.star5</value>
         </prop>
       </node>
+      <node oor:name="lo.writer.MMExcludeEntryController" oor:op="replace">
+        <prop oor:name="Command">
+          <value>.uno:MailMergeExcludeEntry</value>
+        </prop>
+        <prop oor:name="Module">
+          <value/>
+        </prop>
+        <prop oor:name="Controller">
+          <value>lo.writer.MMExcludeEntryController</value>
+        </prop>
+      </node>
       <node oor:name="com.sun.star.svx.FindTextToolboxController" oor:op="replace">
         <prop oor:name="Command">
           <value>.uno:FindText</value>
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index f9725be..f8c16b7 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -768,6 +768,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/uibase/dbui/maildispatcher \
     sw/source/uibase/dbui/mailmergechildwindow \
     sw/source/uibase/dbui/mailmergehelper \
+    sw/source/uibase/dbui/mailmergetoolbarcontrols \
     sw/source/uibase/dbui/mmconfigitem \
     sw/source/uibase/uno/unomailmerge \
 ))
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index ec12358..a6d9ff4 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -784,6 +784,7 @@ void SwModule::ExecOther(SfxRequest& rReq)
             rBindings.Invalidate(FN_MAILMERGE_PREV_ENTRY);
             rBindings.Invalidate(FN_MAILMERGE_NEXT_ENTRY);
             rBindings.Invalidate(FN_MAILMERGE_LAST_ENTRY);
+            // TODO an equivalent of rBindings.Invalidate(".uno:MailMergeExcludeEntry");
             rBindings.Update();
         }
         break;
diff --git a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
new file mode 100644
index 0000000..6858e96
--- /dev/null
+++ b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
@@ -0,0 +1,175 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <svtools/toolboxcontroller.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/button.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/toolbox.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <mmconfigitem.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+
+using namespace css;
+
+namespace {
+
+/// Controller for .uno:MailMergeExcludeEntry toolbar checkbox: creates the checkbox & handles the value.
+class MMExcludeEntryController : public svt::ToolboxController, public lang::XServiceInfo
+{
+    VclPtr<CheckBox> m_pExcludeCheckbox;
+
+    DECL_LINK_TYPED(ExcludeHdl, CheckBox&, void);
+
+public:
+    MMExcludeEntryController(const uno::Reference<uno::XComponentContext>& rContext)
+        : svt::ToolboxController(rContext, uno::Reference<frame::XFrame>(), OUString(".uno:MailMergeExcludeEntry"))
+        , m_pExcludeCheckbox(nullptr)
+    {
+    }
+
+    virtual ~MMExcludeEntryController()
+    {
+    }
+
+    // XInterface
+    virtual uno::Any SAL_CALL queryInterface(const uno::Type& aType) throw (uno::RuntimeException, std::exception) override
+    {
+        uno::Any a(ToolboxController::queryInterface(aType));
+        if (a.hasValue())
+            return a;
+
+        return ::cppu::queryInterface(aType, static_cast<lang::XServiceInfo*>(this));
+    }
+
+    void SAL_CALL acquire() throw ()
+    {
+        ToolboxController::acquire();
+    }
+
+    void SAL_CALL release() throw ()
+    {
+        ToolboxController::release();
+    }
+
+    // XServiceInfo
+    virtual OUString SAL_CALL getImplementationName() throw (uno::RuntimeException, std::exception) override
+    {
+        return OUString("lo.writer.MMExcludeEntryController");
+    }
+
+    virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) throw (uno::RuntimeException, std::exception) override
+    {
+        return cppu::supportsService(this, rServiceName);
+    }
+
+    virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw (uno::RuntimeException, std::exception) override
+    {
+        uno::Sequence<OUString> aServices { "com.sun.star.frame.ToolbarController" };
+        return aServices;
+    }
+
+    // XComponent
+    virtual void SAL_CALL dispose() throw (uno::RuntimeException, std::exception) override;
+
+    // XInitialization
+    virtual void SAL_CALL initialize(const uno::Sequence< uno::Any >& aArguments) throw (uno::Exception, uno::RuntimeException, std::exception) override;
+
+    // XToolbarController
+    virtual uno::Reference<awt::XWindow> SAL_CALL createItemWindow(const uno::Reference<awt::XWindow>& rParent) throw (uno::RuntimeException, std::exception) override;
+
+    // XStatusListener
+    virtual void SAL_CALL statusChanged(const frame::FeatureStateEvent& rEvent) throw (uno::RuntimeException, std::exception) override;
+};
+
+void MMExcludeEntryController::dispose() throw (uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aSolarMutexGuard;
+
+    svt::ToolboxController::dispose();
+    m_pExcludeCheckbox.disposeAndClear();
+}
+
+void MMExcludeEntryController::initialize(const uno::Sequence< uno::Any >& aArguments) throw (uno::Exception, uno::RuntimeException, std::exception)
+{
+    svt::ToolboxController::initialize(aArguments);
+}
+
+uno::Reference<awt::XWindow> MMExcludeEntryController::createItemWindow(const uno::Reference<awt::XWindow>& rParent) throw (uno::RuntimeException, std::exception)
+{
+    vcl::Window* pParent = VCLUnoHelper::GetWindow(rParent);
+    ToolBox* pToolbar = dynamic_cast<ToolBox*>(pParent);
+    if (pToolbar)
+    {
+        // make it visible
+        m_pExcludeCheckbox = VclPtr<CheckBox>::Create(pToolbar, 0);
+        m_pExcludeCheckbox->SetText(/*TODO proper resid*/"Exclude recipient");
+        m_pExcludeCheckbox->SetSizePixel(m_pExcludeCheckbox->GetOptimalSize());
+
+        m_pExcludeCheckbox->SetToggleHdl(LINK(this, MMExcludeEntryController, ExcludeHdl));
+    }
+
+    return uno::Reference<awt::XWindow>(VCLUnoHelper::GetInterface(m_pExcludeCheckbox));
+}
+
+IMPL_LINK_TYPED(MMExcludeEntryController, ExcludeHdl, CheckBox&, rCheckbox, void)
+{
+    SwView* pView = ::GetActiveView();
+    SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem();
+
+    if (pConfigItem)
+        pConfigItem->ExcludeRecord(pConfigItem->GetResultSetPosition(), rCheckbox.IsChecked());
+};
+
+void MMExcludeEntryController::statusChanged(const frame::FeatureStateEvent&) throw (uno::RuntimeException, std::exception)
+{
+    if (!m_pExcludeCheckbox)
+        return;
+
+    SwView* pView = ::GetActiveView();
+    SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem();
+
+    if (pConfigItem)
+    {
+        m_pExcludeCheckbox->Enable();
+        m_pExcludeCheckbox->Check(pConfigItem->IsRecordExcluded(pConfigItem->GetResultSetPosition()));
+    }
+    else
+    {
+        m_pExcludeCheckbox->Disable();
+        m_pExcludeCheckbox->Check(false);
+    }
+}
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface * SAL_CALL
+lo_writer_MMExcludeEntryController_get_implementation(
+    uno::XComponentContext *context,
+    uno::Sequence<uno::Any> const &)
+{
+    return cppu::acquire(new MMExcludeEntryController(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/uiconfig/swform/toolbar/mailmerge.xml b/sw/uiconfig/swform/toolbar/mailmerge.xml
index 7610f2a..61cca36 100644
--- a/sw/uiconfig/swform/toolbar/mailmerge.xml
+++ b/sw/uiconfig/swform/toolbar/mailmerge.xml
@@ -15,6 +15,7 @@
   <toolbar:toolbaritem xlink:href=".uno:MailMergePrevEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeNextEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeLastEntry"/>
+  <toolbar:toolbaritem xlink:href=".uno:MailMergeExcludeEntry"/>
   <toolbar:toolbarseparator/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeCreateDocuments"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeSaveDocuments"/>
diff --git a/sw/uiconfig/swreport/toolbar/mailmerge.xml b/sw/uiconfig/swreport/toolbar/mailmerge.xml
index 7610f2a..61cca36 100644
--- a/sw/uiconfig/swreport/toolbar/mailmerge.xml
+++ b/sw/uiconfig/swreport/toolbar/mailmerge.xml
@@ -15,6 +15,7 @@
   <toolbar:toolbaritem xlink:href=".uno:MailMergePrevEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeNextEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeLastEntry"/>
+  <toolbar:toolbaritem xlink:href=".uno:MailMergeExcludeEntry"/>
   <toolbar:toolbarseparator/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeCreateDocuments"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeSaveDocuments"/>
diff --git a/sw/uiconfig/swriter/toolbar/mailmerge.xml b/sw/uiconfig/swriter/toolbar/mailmerge.xml
index 7610f2a..61cca36 100644
--- a/sw/uiconfig/swriter/toolbar/mailmerge.xml
+++ b/sw/uiconfig/swriter/toolbar/mailmerge.xml
@@ -15,6 +15,7 @@
   <toolbar:toolbaritem xlink:href=".uno:MailMergePrevEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeNextEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeLastEntry"/>
+  <toolbar:toolbaritem xlink:href=".uno:MailMergeExcludeEntry"/>
   <toolbar:toolbarseparator/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeCreateDocuments"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeSaveDocuments"/>
diff --git a/sw/uiconfig/swxform/toolbar/mailmerge.xml b/sw/uiconfig/swxform/toolbar/mailmerge.xml
index 7610f2a..61cca36 100644
--- a/sw/uiconfig/swxform/toolbar/mailmerge.xml
+++ b/sw/uiconfig/swxform/toolbar/mailmerge.xml
@@ -15,6 +15,7 @@
   <toolbar:toolbaritem xlink:href=".uno:MailMergePrevEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeNextEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeLastEntry"/>
+  <toolbar:toolbaritem xlink:href=".uno:MailMergeExcludeEntry"/>
   <toolbar:toolbarseparator/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeCreateDocuments"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeSaveDocuments"/>
diff --git a/sw/util/sw.component b/sw/util/sw.component
index 010f41b..ff6b032 100644
--- a/sw/util/sw.component
+++ b/sw/util/sw.component
@@ -27,6 +27,10 @@
     <service name="com.sun.star.sdb.DataAccessDescriptor"/>
     <service name="com.sun.star.text.MailMerge"/>
   </implementation>
+  <implementation name="lo.writer.MMExcludeEntryController"
+      constructor="lo_writer_MMExcludeEntryController_get_implementation">
+    <service name="com.sun.star.frame.ToolbarController"/>
+  </implementation>
   <implementation name="SwXModule" constructor="SwXModule_get_implementation">
     <service name="com.sun.star.text.GlobalSettings"/>
   </implementation>


More information about the Libreoffice-commits mailing list