sc/source/ui/miscdlgs/duplicaterecordsdlg.cxx |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

New commits:
commit e2378e0074c35fa5b7980f8202ca137c518e399b
Author:     Sahil Gautam <sahil.gautam.ext...@allotropia.de>
AuthorDate: Mon Nov 25 13:10:30 2024 +0530
Commit:     Sahil Gautam <sahil.gautam.ext...@allotropia.de>
CommitDate: Mon Nov 25 17:06:43 2024 +0100

    tdf#85976 consider 'contains column labels' property for database range
    
    A database range  is an <table:database-range> element in file  format. It 
has the
    attribute 'table:contains-header'  with values  'true' (default) and  
'false', and
    the attribute  'table:orientation' with values  'row' (default) and  
'column'. The
    attributes are only written to file, if the value is not default.
    
    If the  selected range has a  database range element then  use its 
contains-header
    property rather than what was last selected.
    
    Change-Id: I120daa2756c50b6c51fab4f6a0549a0b874abaee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177231
    Reviewed-by: Sahil Gautam <sahil.gautam.ext...@allotropia.de>
    Tested-by: Jenkins

diff --git a/sc/source/ui/miscdlgs/duplicaterecordsdlg.cxx 
b/sc/source/ui/miscdlgs/duplicaterecordsdlg.cxx
index f3fe991b92a7..0817d3a75914 100644
--- a/sc/source/ui/miscdlgs/duplicaterecordsdlg.cxx
+++ b/sc/source/ui/miscdlgs/duplicaterecordsdlg.cxx
@@ -144,13 +144,27 @@ void ScDuplicateRecordsDlg::Init()
     m_xOkBtn->connect_clicked(LINK(this, ScDuplicateRecordsDlg, OkHdl));
     m_xAllChkBtn->connect_toggled(LINK(this, ScDuplicateRecordsDlg, 
AllCheckBtnHdl));
 
+    const ScDocument& rDoc = mrViewData.GetDocument();
+    bool bIncludeHeaders
+        = 
officecfg::Office::Calc::Misc::HandleDuplicateRecords::DataIncludesHeaders::get();
+
+    ScDBCollection* pDBColl = rDoc.GetDBCollection();
+    const SCTAB nCurTab = mrViewData.GetTabNo();
+    if (pDBColl)
+    {
+        ScDBData* pDBData
+            = pDBColl->GetDBAtArea(nCurTab, mrRange.aStart.Col(), 
mrRange.aStart.Row(),
+                                   mrRange.aEnd.Col(), mrRange.aEnd.Row());
+        if (pDBData)
+            bIncludeHeaders = pDBData->HasHeader();
+    }
+
     // defaults (find duplicate rows | data doesn't include headers)
+    m_xIncludesHeaders->set_active(bIncludeHeaders);
     m_xRadioRow->set_active(
         
officecfg::Office::Calc::Misc::HandleDuplicateRecords::RemoveDuplicateRows::get());
     m_xRadioColumn->set_active(
         
!officecfg::Office::Calc::Misc::HandleDuplicateRecords::RemoveDuplicateRows::get());
-    m_xIncludesHeaders->set_active(
-        
officecfg::Office::Calc::Misc::HandleDuplicateRecords::DataIncludesHeaders::get());
     m_xRadioRemove->set_active(
         
officecfg::Office::Calc::Misc::HandleDuplicateRecords::RemoveRecords::get());
     m_xRadioSelect->set_active(

Reply via email to