[Libreoffice-commits] core.git: sw/inc sw/source sw/uiconfig

Caolán McNamara caolanm at redhat.com
Mon Jun 16 03:50:06 PDT 2014


 sw/inc/helpid.h                             |    2 
 sw/source/ui/dbui/mmoutputtypepage.cxx      |    1 
 sw/source/ui/dbui/selectdbtabledialog.cxx   |  134 ++++++++++++++++------------
 sw/source/ui/dbui/selectdbtabledialog.hxx   |   17 +--
 sw/uiconfig/swriter/ui/selecttabledialog.ui |   13 +-
 5 files changed, 90 insertions(+), 77 deletions(-)

New commits:
commit be0837fbc0c5bf49497d8fffc1e8e626942481b1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Jun 16 11:43:11 2014 +0100

    rework to use a SvSimpleTableContainer
    
    Change-Id: I6737d75c70c36b19c5bec075f6f82f159ef00d2d

diff --git a/sw/inc/helpid.h b/sw/inc/helpid.h
index 0639edf..5465bb2 100644
--- a/sw/inc/helpid.h
+++ b/sw/inc/helpid.h
@@ -365,9 +365,7 @@
 #define HID_MODULE_TOOLBOX                                      "SW_HID_MODULE_TOOLBOX"
 
 #define HID_MM_SELECTDBTABLEDDIALOG                             "SW_HID_MM_SELECTDBTABLEDDIALOG"
-#define HID_MM_SELECTDBTABLEDDIALOG_LISTBOX                     "SW_HID_MM_SELECTDBTABLEDDIALOG_LISTBOX"
 #define HID_MM_DBTABLEPREVIEWDIALOG                             "SW_HID_MM_DBTABLEPREVIEWDIALOG"
-#define HID_MM_ADDRESSLIST_HB                                   "SW_HID_MM_ADDRESSLIST_HB"
 #define HID_MM_MAILBODY                                         "SW_HID_MM_MAILBODY"
 #define HID_MM_SENDMAILS                                        "SW_HID_MM_SENDMAILS"
 #define HID_MM_SENDMAILS_STATUSLB                               "SW_HID_MM_SENDMAILS_STATUSLB"
diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx b/sw/source/ui/dbui/mmoutputtypepage.cxx
index e4a7397..b23aa92 100644
--- a/sw/source/ui/dbui/mmoutputtypepage.cxx
+++ b/sw/source/ui/dbui/mmoutputtypepage.cxx
@@ -291,7 +291,6 @@ SwSendMailDialog::SwSendMailDialog(Window *pParent, SwMailMergeConfigItem& rConf
     m_aStatusHB.InsertItem( ITEMID_STATUS, sStatus,
                             nPos2,
                             HIB_LEFT | HIB_VCENTER );
-    m_aStatusHB.SetHelpId(HID_MM_ADDRESSLIST_HB );
     m_aStatusHB.Show();
 
     m_aStatusLB.SetHelpId(HID_MM_MAILSTATUS_TLB);
diff --git a/sw/source/ui/dbui/selectdbtabledialog.cxx b/sw/source/ui/dbui/selectdbtabledialog.cxx
index 1d6fb3f..2724e35 100644
--- a/sw/source/ui/dbui/selectdbtabledialog.cxx
+++ b/sw/source/ui/dbui/selectdbtabledialog.cxx
@@ -20,6 +20,7 @@
 #include <swtypes.hxx>
 #include <selectdbtabledialog.hxx>
 #include <dbtablepreviewdialog.hxx>
+#include <svtools/simptabl.hxx>
 #include <svtools/treelistentry.hxx>
 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
@@ -42,56 +43,78 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::beans;
 
+class SwAddressTable : public SvSimpleTable
+{
+public:
+    SwAddressTable(SvSimpleTableContainer& rParent, WinBits nBits = 0);
+    void InsertHeaderItem(sal_uInt16 nColumn, const OUString& rText, HeaderBarItemBits nBits);
+    virtual void Resize() SAL_OVERRIDE;
+    void setColSizes();
+};
+
+SwAddressTable::SwAddressTable(SvSimpleTableContainer& rParent, WinBits nBits)
+    : SvSimpleTable(rParent, nBits)
+{
+    SetSpaceBetweenEntries(3);
+    SetSelectionMode(SINGLE_SELECTION);
+    SetDragDropMode(0);
+    EnableAsyncDrag(false);
+}
+
+void SwAddressTable::InsertHeaderItem(sal_uInt16 nColumn, const OUString& rText, HeaderBarItemBits nBits)
+{
+    GetTheHeaderBar().InsertItem( nColumn, rText, 0, nBits );
+}
+
+void SwAddressTable::Resize()
+{
+    SvSimpleTable::Resize();
+    setColSizes();
+}
+
+void SwAddressTable::setColSizes()
+{
+    HeaderBar &rHB = GetTheHeaderBar();
+    if (rHB.GetItemCount() < 2)
+        return;
+
+    long nWidth = rHB.GetSizePixel().Width();
+    nWidth /= 2;
+
+    long nTabs_Impl[3];
+
+    nTabs_Impl[0] = 2;
+    nTabs_Impl[1] = 0;
+    nTabs_Impl[2] = nWidth;
+
+    SvSimpleTable::SetTabs(&nTabs_Impl[0], MAP_PIXEL);
+}
+
 SwSelectDBTableDialog::SwSelectDBTableDialog(Window* pParent,
-        const uno::Reference< sdbc::XConnection>& rConnection) :
-    SfxModalDialog(pParent, "SelectTableDialog", "modules/swriter/ui/selecttabledialog.ui"),
-    m_sName( SW_RES( ST_NAME )),
-    m_sType( SW_RES( ST_TYPE )),
-    m_sTable( SW_RES( ST_TABLE )),
-    m_sQuery( SW_RES( ST_QUERY )),
-    m_xConnection(rConnection)
+        const uno::Reference< sdbc::XConnection>& rConnection)
+    : SfxModalDialog(pParent, "SelectTableDialog", "modules/swriter/ui/selecttabledialog.ui")
+    , m_sName(SW_RES(ST_NAME))
+    , m_sType(SW_RES(ST_TYPE))
+    , m_sTable(SW_RES(ST_TABLE))
+    , m_sQuery(SW_RES(ST_QUERY))
+    , m_xConnection(rConnection)
 {
     get(m_pPreviewPB, "preview");
-    get(m_pContainer, "table");
-    m_pTableHB = new HeaderBar(m_pContainer, WB_BUTTONSTYLE | WB_BOTTOMBORDER);
-    m_pTableHB->set_height_request(40);
-    m_pTableLB = new SvTabListBox(m_pContainer, WB_BORDER);
-
-    Size aLBSize(Size(400, 100));
-    m_pContainer->SetSizePixel(aLBSize);
-    Size aHeadSize(m_pTableHB->CalcWindowSizePixel());
-    aHeadSize.Width() = aLBSize.Width();
-    m_pTableHB->SetSizePixel(aHeadSize);
-    Point aLBPos(0, 0);
-    m_pTableHB->SetPosPixel(aLBPos);
-    aLBPos.Y() += aHeadSize.Height();
-    aLBSize.Height() -= aHeadSize.Height();
-    m_pTableLB->SetPosSizePixel(aLBPos, aLBSize);
-
-    Size aSz(m_pTableHB->GetOutputSizePixel());
-    m_pTableHB->InsertItem( 1, m_sName,
-                            aSz.Width()/2,
-                            HIB_LEFT | HIB_VCENTER /*| HIB_CLICKABLE | HIB_UPARROW */);
-    m_pTableHB->InsertItem( 2, m_sType,
-                            aSz.Width()/2,
-                            HIB_LEFT | HIB_VCENTER /*| HIB_CLICKABLE | HIB_UPARROW */);
-    m_pTableHB->SetHelpId(HID_MM_ADDRESSLIST_HB );
-    m_pTableHB->Show();
-    m_pTableLB->Show();
-
-    static long nTabs[] = {3, 0, aSz.Width()/2, aSz.Width() };
-    m_pTableLB->SetTabs(&nTabs[0], MAP_PIXEL);
-    m_pTableLB->SetHelpId(HID_MM_SELECTDBTABLEDDIALOG_LISTBOX);
-    m_pTableLB->SetStyle( m_pTableLB->GetStyle() | WB_CLIPCHILDREN );
-    m_pTableLB->SetSpaceBetweenEntries(3);
-    m_pTableLB->SetSelectionMode( SINGLE_SELECTION );
-    m_pTableLB->SetDragDropMode( 0 );
-    m_pTableLB->EnableAsyncDrag(false);
+
+    SvSimpleTableContainer *pHeaderTreeContainer = get<SvSimpleTableContainer>("table");
+    Size aSize = pHeaderTreeContainer->LogicToPixel(Size(238 , 50), MAP_APPFONT);
+    pHeaderTreeContainer->set_width_request(aSize.Width());
+    pHeaderTreeContainer->set_height_request(aSize.Height());
+    m_pTable = new SwAddressTable(*pHeaderTreeContainer);
+    long aStaticTabs[]= { 2, 0, 0 };
+    m_pTable->SetTabs( aStaticTabs );
+    m_pTable->InsertHeaderItem(1, m_sName, HIB_LEFT | HIB_VCENTER);
+    m_pTable->InsertHeaderItem(2, m_sType, HIB_LEFT | HIB_VCENTER);
 
     m_pPreviewPB->SetClickHdl(LINK(this, SwSelectDBTableDialog, PreviewHdl));
 
     Reference<XTablesSupplier> xTSupplier(m_xConnection, UNO_QUERY);
-    if(xTSupplier.is())
+    if (xTSupplier.is())
     {
         Reference<XNameAccess> xTbls = xTSupplier->getTables();
         Sequence<OUString> aTbls = xTbls->getElementNames();
@@ -101,12 +124,12 @@ SwSelectDBTableDialog::SwSelectDBTableDialog(Window* pParent,
             OUString sEntry = pTbls[i];
             sEntry += "\t";
             sEntry += m_sTable;
-            SvTreeListEntry* pEntry = m_pTableLB->InsertEntry(sEntry);
+            SvTreeListEntry* pEntry = m_pTable->InsertEntry(sEntry);
             pEntry->SetUserData((void*)0);
         }
     }
     Reference<XQueriesSupplier> xQSupplier(m_xConnection, UNO_QUERY);
-    if(xQSupplier.is())
+    if (xQSupplier.is())
     {
         Reference<XNameAccess> xQueries = xQSupplier->getQueries();
         Sequence<OUString> aQueries = xQueries->getElementNames();
@@ -116,7 +139,7 @@ SwSelectDBTableDialog::SwSelectDBTableDialog(Window* pParent,
             OUString sEntry = pQueries[i];
             sEntry += "\t";
             sEntry += m_sQuery;
-            SvTreeListEntry* pEntry = m_pTableLB->InsertEntry(sEntry);
+            SvTreeListEntry* pEntry = m_pTable->InsertEntry(sEntry);
             pEntry->SetUserData((void*)1);
         }
     }
@@ -124,16 +147,15 @@ SwSelectDBTableDialog::SwSelectDBTableDialog(Window* pParent,
 
 SwSelectDBTableDialog::~SwSelectDBTableDialog()
 {
-    delete m_pTableHB;
-    delete m_pTableLB;
+    delete m_pTable;
 }
 
 IMPL_LINK(SwSelectDBTableDialog, PreviewHdl, PushButton*, pButton)
 {
-    SvTreeListEntry* pEntry = m_pTableLB->FirstSelected();
+    SvTreeListEntry* pEntry = m_pTable->FirstSelected();
     if(pEntry)
     {
-        OUString sTableOrQuery = m_pTableLB->GetEntryText(pEntry, 0);
+        OUString sTableOrQuery = m_pTable->GetEntryText(pEntry, 0);
         sal_Int32 nCommandType = 0 == pEntry->GetUserData() ? 0 : 1;
 
         OUString sDataSourceName;
@@ -167,23 +189,23 @@ IMPL_LINK(SwSelectDBTableDialog, PreviewHdl, PushButton*, pButton)
 
 OUString    SwSelectDBTableDialog::GetSelectedTable(bool& bIsTable)
 {
-    SvTreeListEntry* pEntry = m_pTableLB->FirstSelected();
+    SvTreeListEntry* pEntry = m_pTable->FirstSelected();
     bIsTable = pEntry->GetUserData() ? false : true;
-    return m_pTableLB->GetEntryText(pEntry, 0);
+    return m_pTable->GetEntryText(pEntry, 0);
 }
 
 void   SwSelectDBTableDialog::SetSelectedTable(const OUString& rTable, bool bIsTable)
 {
-    SvTreeListEntry*    pEntry = m_pTableLB->First();
+    SvTreeListEntry*    pEntry = m_pTable->First();
     while(pEntry)
     {
-        if((m_pTableLB->GetEntryText(pEntry, 0) == rTable) &&
+        if((m_pTable->GetEntryText(pEntry, 0) == rTable) &&
                  ((pEntry->GetUserData() == 0 ) == bIsTable))
         {
-            m_pTableLB->Select(pEntry);
+            m_pTable->Select(pEntry);
             break;
         }
-        pEntry = m_pTableLB->Next( pEntry );
+        pEntry = m_pTable->Next( pEntry );
     }
 }
 
diff --git a/sw/source/ui/dbui/selectdbtabledialog.hxx b/sw/source/ui/dbui/selectdbtabledialog.hxx
index d310769..1668e81 100644
--- a/sw/source/ui/dbui/selectdbtabledialog.hxx
+++ b/sw/source/ui/dbui/selectdbtabledialog.hxx
@@ -24,34 +24,31 @@
 #include <vcl/button.hxx>
 #include <vcl/fixed.hxx>
 #include <vcl/layout.hxx>
-#include <svtools/svtabbx.hxx>
-#include <svtools/headbar.hxx>
+
 namespace com{namespace sun{namespace star{
     namespace sdbc{
         class XConnection;
     }
 }}}
 
+class SwAddressTable;
+
 class SwSelectDBTableDialog : public SfxModalDialog
 {
-    HeaderBar       *m_pTableHB;
-    SvTabListBox    *m_pTableLB;
-    PushButton      *m_pPreviewPB;
-    Window          *m_pContainer;
+    SwAddressTable* m_pTable;
+    PushButton*     m_pPreviewPB;
 
     OUString        m_sName;
     OUString        m_sType;
     OUString        m_sTable;
     OUString        m_sQuery;
 
-    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+    css::uno::Reference<css::sdbc::XConnection> m_xConnection;
 
     DECL_LINK(PreviewHdl, PushButton*);
 public:
-
     SwSelectDBTableDialog(Window* pParent,
-        const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& xConnection
-            );
+        const css::uno::Reference<css::sdbc::XConnection>& xConnection);
     virtual ~SwSelectDBTableDialog();
 
     OUString    GetSelectedTable(bool& bIsTable);
diff --git a/sw/uiconfig/swriter/ui/selecttabledialog.ui b/sw/uiconfig/swriter/ui/selecttabledialog.ui
index 1095980..dd2e7ed 100644
--- a/sw/uiconfig/swriter/ui/selecttabledialog.ui
+++ b/sw/uiconfig/swriter/ui/selecttabledialog.ui
@@ -2,6 +2,7 @@
 <!-- Generated with glade 3.16.1 -->
 <interface>
   <requires lib="gtk+" version="3.0"/>
+  <!-- interface-requires LibreOffice 1.0 -->
   <object class="GtkDialog" id="SelectTableDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
@@ -88,7 +89,7 @@
                 <property name="label" translatable="yes">The file you have selected contains more than one table. Please select the table containing the address list you want to use.</property>
                 <property name="use_underline">True</property>
                 <property name="wrap">True</property>
-                <property name="max_width_chars">70</property>
+                <property name="max_width_chars">90</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -97,17 +98,13 @@
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="table">
+              <object class="svtlo-SvSimpleTableContainer" id="table">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <property name="orientation">vertical</property>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection" id="Simple Table Container-selection1"/>
                 </child>
               </object>
               <packing>


More information about the Libreoffice-commits mailing list