summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/ui/fldui/flddok.cxx411
-rw-r--r--sw/source/ui/fldui/flddok.hxx41
-rw-r--r--sw/source/ui/fldui/fldpage.cxx2
-rw-r--r--sw/source/ui/fldui/fldpage.hxx2
-rw-r--r--sw/source/uibase/inc/numfmtlb.hxx96
-rw-r--r--sw/source/uibase/utlui/numfmtlb.cxx99
-rw-r--r--sw/uiconfig/swriter/ui/flddocumentpage.ui198
-rw-r--r--sw/uiconfig/swriter/ui/fldrefpage.ui4
8 files changed, 517 insertions, 336 deletions
diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx
index 2b68cecac158..7cee887a6687 100644
--- a/sw/source/ui/fldui/flddok.cxx
+++ b/sw/source/ui/fldui/flddok.cxx
@@ -32,48 +32,44 @@
#define USER_DATA_VERSION_1 "1"
#define USER_DATA_VERSION USER_DATA_VERSION_1
-SwFieldDokPage::SwFieldDokPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet)
- : SwFieldPage(pParent, "FieldDocumentPage",
- "modules/swriter/ui/flddocumentpage.ui", pCoreSet)
+SwFieldDokPage::SwFieldDokPage(TabPageParent pParent, const SfxItemSet *const pCoreSet)
+ : SwFieldPage(pParent, "modules/swriter/ui/flddocumentpage.ui",
+ "FieldDocumentPage", pCoreSet)
, nOldSel(0)
, nOldFormat(0)
+ , m_xTypeLB(m_xBuilder->weld_tree_view("type"))
+ , m_xSelection(m_xBuilder->weld_widget("selectframe"))
+ , m_xSelectionLB(m_xBuilder->weld_tree_view("select"))
+ , m_xValueFT(m_xBuilder->weld_label("valueft"))
+ , m_xValueED(m_xBuilder->weld_entry("value"))
+ , m_xLevelFT(m_xBuilder->weld_label("levelft"))
+ , m_xLevelED(m_xBuilder->weld_spin_button("level"))
+ , m_xDateFT(m_xBuilder->weld_label("daysft"))
+ , m_xTimeFT(m_xBuilder->weld_label("minutesft"))
+ , m_xDateOffsetED(m_xBuilder->weld_spin_button("offset"))
+ , m_xFormat(m_xBuilder->weld_widget("formatframe"))
+ , m_xFormatLB(m_xBuilder->weld_tree_view("format"))
+ , m_xNumFormatLB(new SwNumFormatTreeView(m_xBuilder->weld_tree_view("numformat")))
+ , m_xFixedCB(m_xBuilder->weld_check_button("fixed"))
{
- get(m_pSelection, "selectframe");
- get(m_pFormat, "formatframe");
- get(m_pTypeLB, "type");
- m_pTypeLB->SetStyle(m_pTypeLB->GetStyle() | WB_SORT);
- get(m_pSelectionLB, "select");
- get(m_pValueFT, "valueft");
- get(m_pValueED, "value");
- get(m_pLevelFT, "levelft");
- get(m_pLevelED, "level");
- get(m_pDateFT, "daysft");
- get(m_pTimeFT, "minutesft");
- get(m_pDateOffsetED, "offset");
- get(m_pFormatLB, "format");
- m_pFormatLB->SetStyle(m_pFormatLB->GetStyle() | WB_SORT);
- get(m_pNumFormatLB, "numformat");
- get(m_pFixedCB, "fixed");
-
- long nHeight = m_pTypeLB->GetTextHeight() * 20;
- m_pTypeLB->set_height_request(nHeight);
- m_pSelectionLB->set_height_request(nHeight);
- m_pFormatLB->set_height_request(nHeight);
-
- long nWidth = m_pTypeLB->LogicToPixel(Size(FIELD_COLUMN_WIDTH, 0), MapMode(MapUnit::MapAppFont)).Width();
- m_pTypeLB->set_width_request(nWidth);
- m_pSelectionLB->set_width_request(nWidth);
- m_pFormatLB->set_width_request(nWidth);
-
- m_pSelectionLB->SetDoubleClickHdl(LINK(this, SwFieldDokPage, ListBoxInsertHdl));
- m_pFormatLB->SetDoubleClickHdl(LINK(this, SwFieldDokPage, ListBoxInsertHdl));
- m_pNumFormatLB->SetDoubleClickHdl(LINK(this, SwFieldDokPage, NumFormatHdl));
-
- m_pLevelED->SetMax(MAXLEVEL);
- m_pDateOffsetED->SetMin(LONG_MIN);
- m_pDateOffsetED->SetMax(LONG_MAX);
+ m_xTypeLB->make_sorted();
+ m_xFormatLB->make_sorted();
+
+ auto nWidth = LogicToPixel(Size(FIELD_COLUMN_WIDTH, 0), MapMode(MapUnit::MapAppFont)).Width();
+ auto nHeight = m_xTypeLB->get_height_rows(20);
+
+ m_xTypeLB->set_size_request(nWidth, nHeight);
+ m_xSelectionLB->set_size_request(nWidth, nHeight);
+ m_xFormatLB->set_size_request(nWidth, nHeight);
+
+ m_xSelectionLB->connect_row_activated(LINK(this, SwFieldDokPage, TreeViewInsertHdl));
+ m_xFormatLB->connect_row_activated(LINK(this, SwFieldDokPage, TreeViewInsertHdl));
+ m_xNumFormatLB->connect_row_activated(LINK(this, SwFieldDokPage, NumFormatHdl));
+
+ m_xLevelED->set_max(MAXLEVEL);
+ m_xDateOffsetED->set_range(INT_MIN, INT_MAX);
//enable 'active' language selection
- m_pNumFormatLB->SetShowLanguageControl(true);
+ m_xNumFormatLB->SetShowLanguageControl(true);
}
SwFieldDokPage::~SwFieldDokPage()
@@ -81,38 +77,16 @@ SwFieldDokPage::~SwFieldDokPage()
disposeOnce();
}
-void SwFieldDokPage::dispose()
-{
- m_pTypeLB.clear();
- m_pSelection.clear();
- m_pSelectionLB.clear();
- m_pValueFT.clear();
- m_pValueED.clear();
- m_pLevelFT.clear();
- m_pLevelED.clear();
- m_pDateFT.clear();
- m_pTimeFT.clear();
- m_pDateOffsetED.clear();
- m_pFormat.clear();
- m_pFormatLB.clear();
- m_pNumFormatLB.clear();
- m_pFixedCB.clear();
- SwFieldPage::dispose();
-}
-
-
void SwFieldDokPage::Reset(const SfxItemSet* )
{
- SavePos(m_pTypeLB);
+ SavePos(*m_xTypeLB);
Init(); // general initialisation
// initialise TypeListBox
const SwFieldGroupRgn& rRg = SwFieldMgr::GetGroupRange(IsFieldDlgHtmlMode(), GetGroup());
- m_pTypeLB->SetUpdateMode(false);
- m_pTypeLB->Clear();
-
- sal_Int32 nPos;
+ m_xTypeLB->freeze();
+ m_xTypeLB->clear();
if (!IsFieldEdit())
{
@@ -129,15 +103,13 @@ void SwFieldDokPage::Reset(const SfxItemSet* )
case TYP_PAGENUMBERFLD:
if (!bPage)
{
- nPos = m_pTypeLB->InsertEntry(SwResId(FMT_REF_PAGE));
- m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(USHRT_MAX));
+ m_xTypeLB->append(OUString::number(USHRT_MAX), SwResId(FMT_REF_PAGE));
bPage = true;
}
break;
default:
- nPos = m_pTypeLB->InsertEntry(SwFieldMgr::GetTypeStr(i));
- m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
+ m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(i));
break;
}
}
@@ -150,9 +122,8 @@ void SwFieldDokPage::Reset(const SfxItemSet* )
nTypeId = TYP_DATEFLD;
if (nTypeId == TYP_FIXTIMEFLD)
nTypeId = TYP_TIMEFLD;
- nPos = m_pTypeLB->InsertEntry(SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId)));
- m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
- m_pNumFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage());
+ m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId)));
+ m_xNumFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage());
SwWrtShell *pSh = GetWrtShell();
if(!pSh)
pSh = ::GetActiveWrtShell();
@@ -160,17 +131,19 @@ void SwFieldDokPage::Reset(const SfxItemSet* )
{
const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat());
if(pFormat)
- m_pNumFormatLB->SetLanguage(pFormat->GetLanguage());
+ m_xNumFormatLB->SetLanguage(pFormat->GetLanguage());
}
}
+
+ m_xTypeLB->thaw();
+
// select old Pos
- RestorePos(m_pTypeLB);
+ RestorePos(*m_xTypeLB);
- m_pTypeLB->SetUpdateMode(true);
- m_pTypeLB->SetDoubleClickHdl(LINK(this, SwFieldDokPage, ListBoxInsertHdl));
- m_pTypeLB->SetSelectHdl(LINK(this, SwFieldDokPage, TypeHdl));
- m_pFormatLB->SetSelectHdl(LINK(this, SwFieldDokPage, FormatHdl));
+ m_xTypeLB->connect_row_activated(LINK(this, SwFieldDokPage, TreeViewInsertHdl));
+ m_xTypeLB->connect_changed(LINK(this, SwFieldDokPage, TypeHdl));
+ m_xFormatLB->connect_changed(LINK(this, SwFieldDokPage, FormatHdl));
if( !IsRefresh() )
{
@@ -181,40 +154,42 @@ void SwFieldDokPage::Reset(const SfxItemSet* )
const sal_uInt16 nVal = static_cast< sal_uInt16 >(sUserData.getToken(0, ';', nIdx).toInt32());
if(nVal != USHRT_MAX)
{
- for(sal_Int32 i = 0; i < m_pTypeLB->GetEntryCount(); i++)
- if(nVal == static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(i))))
+ for (int i = 0, nEntryCount = m_xTypeLB->n_children(); i < nEntryCount; i++)
+ {
+ if (nVal == m_xTypeLB->get_id(i).toUInt32())
{
- m_pTypeLB->SelectEntryPos(i);
+ m_xTypeLB->select(i);
break;
}
+ }
}
}
}
- TypeHdl(*m_pTypeLB);
+ TypeHdl(*m_xTypeLB);
if (IsFieldEdit())
{
- nOldSel = m_pSelectionLB->GetSelectedEntryPos();
+ nOldSel = m_xSelectionLB->get_selected_index();
nOldFormat = GetCurField()->GetFormat();
- m_pFixedCB->SaveValue();
- m_pValueED->SaveValue();
- m_pLevelED->SaveValue();
- m_pDateOffsetED->SaveValue();
+ m_xFixedCB->save_state();
+ m_xValueED->save_value();
+ m_xLevelED->save_value();
+ m_xDateOffsetED->save_value();
}
}
-IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, ListBox&, void)
+IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void)
{
// save old ListBoxPos
const sal_Int32 nOld = GetTypeSel();
// current ListBoxPos
- SetTypeSel(m_pTypeLB->GetSelectedEntryPos());
+ SetTypeSel(m_xTypeLB->get_selected_index());
- if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
+ if(GetTypeSel() == -1)
{
SetTypeSel(0);
- m_pTypeLB->SelectEntryPos(0);
+ m_xTypeLB->select(0);
}
if (nOld == GetTypeSel())
@@ -222,13 +197,13 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, ListBox&, void)
size_t nCount;
- m_pDateFT->Hide();
- m_pTimeFT->Hide();
+ m_xDateFT->hide();
+ m_xTimeFT->hide();
- sal_uInt16 nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel())));
+ sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
// fill Selection-Listbox
- m_pSelectionLB->Clear();
+ m_xSelectionLB->clear();
if (nTypeId != USHRT_MAX)
{
@@ -240,49 +215,44 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, ListBox&, void)
else
nCount = GetFieldMgr().GetFormatCount(nTypeId, IsFieldDlgHtmlMode());
- size_t nPos;
-
- for(size_t i = 0; i < nCount; ++i)
+ for (size_t i = 0; i < nCount; ++i)
{
if (!IsFieldEdit())
{
+ OUString sId(OUString::number(i));
if (nTypeId != TYP_AUTHORFLD)
- nPos = m_pSelectionLB->InsertEntry(aLst[i]);
+ m_xSelectionLB->append(sId, aLst[i]);
else
- nPos = m_pSelectionLB->InsertEntry(GetFieldMgr().GetFormatStr(nTypeId, i));
-
- m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
+ m_xSelectionLB->append(sId, GetFieldMgr().GetFormatStr(nTypeId, i));
}
else
{
bool bInsert = false;
+ OUString sId(OUString::number(i));
+
switch (nTypeId)
{
case TYP_DATEFLD:
case TYP_TIMEFLD:
- nPos = m_pSelectionLB->InsertEntry(aLst[i]);
- m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
+ m_xSelectionLB->append(sId, aLst[i]);
if (static_cast<SwDateTimeField*>(GetCurField())->IsFixed() && !i)
- m_pSelectionLB->SelectEntryPos(nPos);
+ m_xSelectionLB->select_id(sId);
if (!static_cast<SwDateTimeField*>(GetCurField())->IsFixed() && i)
- m_pSelectionLB->SelectEntryPos(nPos);
+ m_xSelectionLB->select_id(sId);
break;
-
case TYP_EXTUSERFLD:
case TYP_DOCSTATFLD:
- nPos = m_pSelectionLB->InsertEntry(aLst[i]);
- m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
+ m_xSelectionLB->append(sId, aLst[i]);
if (GetCurField()->GetSubType() == i)
- m_pSelectionLB->SelectEntryPos(nPos);
+ m_xSelectionLB->select_id(sId);
break;
case TYP_AUTHORFLD:
{
const OUString sFormat(GetFieldMgr().GetFormatStr(nTypeId, i));
- nPos = m_pSelectionLB->InsertEntry(sFormat);
- m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
- m_pSelectionLB->SelectEntry(GetFieldMgr().GetFormatStr(nTypeId, GetCurField()->GetFormat()));
+ m_xSelectionLB->append(sId, sFormat);
+ m_xSelectionLB->select_text(GetFieldMgr().GetFormatStr(nTypeId, GetCurField()->GetFormat()));
break;
}
@@ -293,30 +263,29 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, ListBox&, void)
}
if (bInsert)
{
- nPos = m_pSelectionLB->InsertEntry(aLst[i]);
- m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
+ m_xSelectionLB->append(sId, aLst[i]);
break;
}
}
}
- m_pSelectionLB->SetSelectHdl(Link<ListBox&,void>());
+ m_xSelectionLB->connect_changed(Link<weld::TreeView&,void>());
}
else
{
AddSubType(TYP_PAGENUMBERFLD);
AddSubType(TYP_PREVPAGEFLD);
AddSubType(TYP_NEXTPAGEFLD);
- nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(0)));
+ nTypeId = m_xSelectionLB->get_id(0).toUInt32();
nCount = 3;
- m_pSelectionLB->SetSelectHdl(LINK(this, SwFieldDokPage, SubTypeHdl));
+ m_xSelectionLB->connect_changed(LINK(this, SwFieldDokPage, SubTypeHdl));
}
bool bEnable = nCount != 0;
- if (bEnable && !m_pSelectionLB->GetSelectedEntryCount())
- m_pSelectionLB->SelectEntryPos(0);
+ if (bEnable && m_xSelectionLB->get_selected_index() == -1)
+ m_xSelectionLB->select(0);
- m_pSelection->Enable( bEnable );
+ m_xSelection->set_sensitive( bEnable );
// fill Format-Listbox
sal_Int32 nSize = FillFormatLB(nTypeId);
@@ -334,13 +303,12 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, ListBox&, void)
nFormatType = SvNumFormatType::DATE;
- m_pDateFT->Show();
+ m_xDateFT->show();
- m_pDateOffsetED->SetFirst(-31); // one month
- m_pDateOffsetED->SetLast(31);
+ m_xDateOffsetED->set_range(-31, 31); // one month
if (IsFieldEdit())
- m_pDateOffsetED->SetValue( static_cast<SwDateTimeField*>(GetCurField())->GetOffset() / 24 / 60);
+ m_xDateOffsetED->set_value( static_cast<SwDateTimeField*>(GetCurField())->GetOffset() / 24 / 60);
break;
case TYP_TIMEFLD:
@@ -348,51 +316,49 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, ListBox&, void)
nFormatType = SvNumFormatType::TIME;
- m_pTimeFT->Show();
+ m_xTimeFT->show();
- m_pDateOffsetED->SetFirst(-1440); // one day
- m_pDateOffsetED->SetLast(1440);
+ m_xDateOffsetED->set_range(-1440, 1440); // one day
if (IsFieldEdit())
- m_pDateOffsetED->SetValue( static_cast<SwDateTimeField*>(GetCurField())->GetOffset() );
+ m_xDateOffsetED->set_value( static_cast<SwDateTimeField*>(GetCurField())->GetOffset() );
break;
case TYP_PREVPAGEFLD:
case TYP_NEXTPAGEFLD:
if (IsFieldEdit())
{
- const sal_uInt16 nTmp = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pFormatLB->GetEntryData(
- m_pFormatLB->GetSelectedEntryPos() )));
+ const sal_uInt16 nTmp = m_xFormatLB->get_selected_id().toUInt32();
if(SVX_NUM_CHAR_SPECIAL != nTmp)
{
sal_Int32 nOff = GetCurField()->GetPar2().toInt32();
if( TYP_NEXTPAGEFLD == nTypeId && 1 != nOff )
- m_pValueED->SetText(
+ m_xValueED->set_text(
OUString::number(nOff - 1) );
else if( TYP_PREVPAGEFLD == nTypeId && -1 != nOff )
- m_pValueED->SetText(
+ m_xValueED->set_text(
OUString::number(nOff + 1) );
else
- m_pValueED->SetText(OUString());
+ m_xValueED->set_text(OUString());
}
else
- m_pValueED->SetText(static_cast<SwPageNumberField*>(GetCurField())->GetUserString());
+ m_xValueED->set_text(static_cast<SwPageNumberField*>(GetCurField())->GetUserString());
}
bValue = true;
break;
case TYP_CHAPTERFLD:
- m_pValueFT->SetText(SwResId(STR_LEVEL));
+ m_xValueFT->set_label(SwResId(STR_LEVEL));
if (IsFieldEdit())
- m_pLevelED->SetText(OUString::number(static_cast<SwChapterField*>(GetCurField())->GetLevel(GetWrtShell()->GetLayout()) + 1));
+ m_xLevelED->set_text(OUString::number(static_cast<SwChapterField*>(GetCurField())->GetLevel(GetWrtShell()->GetLayout()) + 1));
bLevel = true;
break;
case TYP_PAGENUMBERFLD:
- m_pValueFT->SetText( SwResId( STR_OFFSET ));
+ m_xValueFT->set_label( SwResId( STR_OFFSET ));
if (IsFieldEdit())
- m_pValueED->SetText(GetCurField()->GetPar2());
+ m_xValueED->set_text(GetCurField()->GetPar2());
bValue = true;
break;
@@ -410,60 +376,58 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, ListBox&, void)
{
if (IsFieldEdit())
{
- m_pNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
+ m_xNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
- if (m_pNumFormatLB->GetFormatType() == (SvNumFormatType::DATE|SvNumFormatType::TIME))
+ if (m_xNumFormatLB->GetFormatType() == (SvNumFormatType::DATE|SvNumFormatType::TIME))
{
// always set Format-Type because otherwise when date/time formats are combined,
// both formats would be displayed at the same time
- m_pNumFormatLB->SetFormatType(SvNumFormatType::ALL);
- m_pNumFormatLB->SetFormatType(nFormatType);
+ m_xNumFormatLB->SetFormatType(SvNumFormatType::ALL);
+ m_xNumFormatLB->SetFormatType(nFormatType);
// set correct format once again
- m_pNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
+ m_xNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
}
}
else
- m_pNumFormatLB->SetFormatType(nFormatType);
+ m_xNumFormatLB->SetFormatType(nFormatType);
- m_pNumFormatLB->SetOneArea(bOneArea);
+ m_xNumFormatLB->SetOneArea(bOneArea);
}
- m_pFormatLB->Show(!bNumFormat);
- m_pNumFormatLB->Show(bNumFormat);
+ m_xFormatLB->set_visible(!bNumFormat);
+ m_xNumFormatLB->set_visible(bNumFormat);
- m_pValueFT->Show(bValue);
- m_pValueED->Show(bValue);
- m_pLevelFT->Show(bLevel);
- m_pLevelED->Show(bLevel);
- m_pDateOffsetED->Show(bOffset);
- m_pFixedCB->Show(!bValue && !bLevel && !bOffset);
+ m_xValueFT->set_visible(bValue);
+ m_xValueED->set_visible(bValue);
+ m_xLevelFT->set_visible(bLevel);
+ m_xLevelED->set_visible(bLevel);
+ m_xDateOffsetED->set_visible(bOffset);
+ m_xFixedCB->set_visible(!bValue && !bLevel && !bOffset);
- m_pFormat->Enable(bFormat);
- m_pFixedCB->Enable(bFixed);
+ m_xFormat->set_sensitive(bFormat);
+ m_xFixedCB->set_sensitive(bFixed);
if (IsFieldEdit())
- m_pFixedCB->Check( (GetCurField()->GetFormat() & AF_FIXED) != 0 && bFixed );
-
- if (m_pNumFormatLB->GetSelectedEntryPos() == LISTBOX_ENTRY_NOTFOUND)
- m_pNumFormatLB->SelectEntryPos(0);
- m_pValueFT->Enable(bValue || bLevel || bOffset);
- m_pValueED->Enable(bValue);
+ m_xFixedCB->set_active((GetCurField()->GetFormat() & AF_FIXED) != 0 && bFixed);
+ if (m_xNumFormatLB->get_selected_index() == -1)
+ m_xNumFormatLB->select(0);
+ m_xValueFT->set_sensitive(bValue || bLevel || bOffset);
+ m_xValueED->set_sensitive(bValue);
}
void SwFieldDokPage::AddSubType(sal_uInt16 nTypeId)
{
- const sal_Int32 nPos = m_pSelectionLB->InsertEntry(SwFieldType::GetTypeStr(nTypeId));
- m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
+ m_xSelectionLB->append(OUString::number(nTypeId), SwFieldType::GetTypeStr(nTypeId));
}
-IMPL_LINK_NOARG(SwFieldDokPage, SubTypeHdl, ListBox&, void)
+IMPL_LINK_NOARG(SwFieldDokPage, SubTypeHdl, weld::TreeView&, void)
{
- sal_Int32 nPos = m_pSelectionLB->GetSelectedEntryPos();
- if(nPos == LISTBOX_ENTRY_NOTFOUND)
+ sal_Int32 nPos = m_xSelectionLB->get_selected_index();
+ if(nPos == -1)
nPos = 0;
- const sal_uInt16 nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(nPos)));
+ const sal_uInt16 nTypeId = m_xSelectionLB->get_id(nPos).toUInt32();
FillFormatLB(nTypeId);
const char* pTextRes = nullptr;
@@ -475,8 +439,7 @@ IMPL_LINK_NOARG(SwFieldDokPage, SubTypeHdl, ListBox&, void)
case TYP_PREVPAGEFLD:
case TYP_NEXTPAGEFLD:
- pTextRes = SVX_NUM_CHAR_SPECIAL == static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pFormatLB->GetEntryData(
- m_pFormatLB->GetSelectedEntryPos() )))
+ pTextRes = SVX_NUM_CHAR_SPECIAL == m_xFormatLB->get_selected_id().toUInt32()
? STR_VALUE : STR_OFFSET;
break;
@@ -486,102 +449,101 @@ IMPL_LINK_NOARG(SwFieldDokPage, SubTypeHdl, ListBox&, void)
}
if (pTextRes)
- m_pValueFT->SetText(SwResId(pTextRes));
+ m_xValueFT->set_label(SwResId(pTextRes));
}
sal_Int32 SwFieldDokPage::FillFormatLB(sal_uInt16 nTypeId)
{
// fill Format-Listbox
- m_pFormatLB->Clear();
+ m_xFormatLB->clear();
if (nTypeId == TYP_AUTHORFLD)
- return m_pFormatLB->GetEntryCount();
+ return m_xFormatLB->n_children();
const sal_uInt16 nSize = GetFieldMgr().GetFormatCount(nTypeId, IsFieldDlgHtmlMode());
for( sal_uInt16 i = 0; i < nSize; ++i )
{
- const sal_Int32 nPos = m_pFormatLB->InsertEntry(GetFieldMgr().GetFormatStr(nTypeId, i));
const sal_uInt16 nFormatId = GetFieldMgr().GetFormatId( nTypeId, i );
- m_pFormatLB->SetEntryData( nPos, reinterpret_cast<void*>( nFormatId ));
+ OUString sId(OUString::number(nFormatId));
+ m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr(nTypeId, i));
if (IsFieldEdit() && nFormatId == (GetCurField()->GetFormat() & ~AF_FIXED))
- m_pFormatLB->SelectEntryPos( nPos );
+ m_xFormatLB->select_id(sId);
}
- if( nSize && !m_pFormatLB->GetSelectedEntryCount() )
+ if (nSize && m_xFormatLB->get_selected_index() == -1)
{
- m_pFormatLB->SelectEntry( SwResId(FMT_NUM_PAGEDESC) );
- if( !m_pFormatLB->GetSelectedEntryCount() )
+ m_xFormatLB->select_text( SwResId(FMT_NUM_PAGEDESC) );
+ if (m_xFormatLB->get_selected_index() == -1)
{
- m_pFormatLB->SelectEntry( SwResId(FMT_NUM_ARABIC) );
- if( !m_pFormatLB->GetSelectedEntryCount() )
- m_pFormatLB->SelectEntryPos( 0 );
+ m_xFormatLB->select_text( SwResId(FMT_NUM_ARABIC) );
+ if (m_xFormatLB->get_selected_index() == -1)
+ m_xFormatLB->select( 0 );
}
}
- FormatHdl(*m_pFormatLB);
+ FormatHdl(*m_xFormatLB);
return nSize;
}
-IMPL_LINK_NOARG(SwFieldDokPage, FormatHdl, ListBox&, void)
+IMPL_LINK_NOARG(SwFieldDokPage, FormatHdl, weld::TreeView&, void)
{
- sal_uInt16 nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel())));
+ sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
if (nTypeId == USHRT_MAX)
{
- sal_Int32 nPos = m_pSelectionLB->GetSelectedEntryPos();
- if(nPos == LISTBOX_ENTRY_NOTFOUND)
+ sal_Int32 nPos = m_xSelectionLB->get_selected_index();
+ if(nPos == -1)
nPos = 0;
- nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(nPos)));
+ nTypeId = m_xSelectionLB->get_id(nPos).toUInt32();
}
if (nTypeId == TYP_NEXTPAGEFLD || nTypeId == TYP_PREVPAGEFLD)
{
// Prev/Next - PageNumFields special treatment:
- sal_uInt16 nTmp = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pFormatLB->GetEntryData(
- m_pFormatLB->GetSelectedEntryPos() )));
- const OUString sOldText( m_pValueFT->GetText() );
+ sal_uInt16 nTmp = m_xFormatLB->get_selected_id().toUInt32();
+ const OUString sOldText( m_xValueFT->get_label() );
const OUString sNewText( SwResId( SVX_NUM_CHAR_SPECIAL == nTmp ? STR_VALUE
: STR_OFFSET ));
- if( sOldText != sNewText )
- m_pValueFT->SetText( sNewText );
+ if (sOldText != sNewText)
+ m_xValueFT->set_label(sNewText);
- if (sOldText != m_pValueFT->GetText())
- m_pValueED->SetText(OUString());
+ if (sOldText != m_xValueFT->get_label())
+ m_xValueED->set_text(OUString());
}
}
bool SwFieldDokPage::FillItemSet(SfxItemSet* )
{
- sal_uInt16 nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel())));
+ sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
if (nTypeId == USHRT_MAX)
{
- sal_Int32 nPos = m_pSelectionLB->GetSelectedEntryPos();
- if(nPos == LISTBOX_ENTRY_NOTFOUND)
+ sal_Int32 nPos = m_xSelectionLB->get_selected_index();
+ if(nPos == -1)
nPos = 0;
- nTypeId = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(nPos)));
+ nTypeId = m_xSelectionLB->get_id(nPos).toUInt32();
}
- OUString aVal(m_pValueED->GetText());
+ OUString aVal(m_xValueED->get_text());
sal_uLong nFormat = 0;
sal_uInt16 nSubType = 0;
- if (m_pFormatLB->IsEnabled())
+ if (m_xFormatLB->get_sensitive())
{
- sal_Int32 nPos = m_pFormatLB->GetSelectedEntryPos();
- if(nPos != LISTBOX_ENTRY_NOTFOUND)
- nFormat = reinterpret_cast<sal_uLong>(m_pFormatLB->GetEntryData(nPos));
+ sal_Int32 nPos = m_xFormatLB->get_selected_index();
+ if(nPos != -1)
+ nFormat = m_xFormatLB->get_id(nPos).toUInt32();
}
- if (m_pSelectionLB->IsEnabled())
+ if (m_xSelectionLB->get_sensitive())
{
- sal_Int32 nPos = m_pSelectionLB->GetSelectedEntryPos();
- if(nPos != LISTBOX_ENTRY_NOTFOUND)
- nSubType = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pSelectionLB->GetEntryData(nPos)));
+ sal_Int32 nPos = m_xSelectionLB->get_selected_index();
+ if(nPos != -1)
+ nSubType = m_xSelectionLB->get_id(nPos).toUInt32();
}
switch (nTypeId)
@@ -591,18 +553,18 @@ bool SwFieldDokPage::FillItemSet(SfxItemSet* )
nSubType = 0;
[[fallthrough]];
case TYP_EXTUSERFLD:
- nFormat |= m_pFixedCB->IsChecked() ? AF_FIXED : 0;
+ nFormat |= m_xFixedCB->get_active() ? AF_FIXED : 0;
break;
case TYP_FILENAMEFLD:
- nFormat |= m_pFixedCB->IsChecked() ? FF_FIXED : 0;
+ nFormat |= m_xFixedCB->get_active() ? FF_FIXED : 0;
break;
case TYP_DATEFLD:
case TYP_TIMEFLD:
{
- nFormat = m_pNumFormatLB->GetFormat();
- long nVal = static_cast< long >(m_pDateOffsetED->GetValue());
+ nFormat = m_xNumFormatLB->GetFormat();
+ long nVal = static_cast< long >(m_xDateOffsetED->get_value());
if (nTypeId == TYP_DATEFLD)
aVal = OUString::number(nVal * 60 * 24);
else
@@ -618,14 +580,14 @@ bool SwFieldDokPage::FillItemSet(SfxItemSet* )
if( SVX_NUM_CHAR_SPECIAL != nFormat &&
(TYP_PREVPAGEFLD == nTypeId || TYP_NEXTPAGEFLD == nTypeId))
{
- sal_Int32 nVal = m_pValueED->GetText().toInt32();
+ sal_Int32 nVal = m_xValueED->get_text().toInt32();
aVal = OUString::number(nVal);
}
break;
}
case TYP_CHAPTERFLD:
- aVal = m_pLevelED->GetText();
+ aVal = m_xLevelED->get_text();
break;
default:
@@ -633,23 +595,23 @@ bool SwFieldDokPage::FillItemSet(SfxItemSet* )
}
if (!IsFieldEdit() ||
- nOldSel != m_pSelectionLB->GetSelectedEntryPos() ||
+ nOldSel != m_xSelectionLB->get_selected_index() ||
nOldFormat != nFormat ||
- m_pFixedCB->IsValueChangedFromSaved() ||
- m_pValueED->IsValueChangedFromSaved() ||
- m_pLevelED->IsValueChangedFromSaved() ||
- m_pDateOffsetED->IsValueChangedFromSaved())
+ m_xFixedCB->get_state_changed_from_saved() ||
+ m_xValueED->get_value_changed_from_saved() ||
+ m_xLevelED->get_value_changed_from_saved() ||
+ m_xDateOffsetED->get_value_changed_from_saved())
{
- InsertField(nTypeId, nSubType, OUString(), aVal, nFormat, ' ', m_pNumFormatLB->IsAutomaticLanguage());
+ InsertField(nTypeId, nSubType, OUString(), aVal, nFormat, ' ', m_xNumFormatLB->IsAutomaticLanguage());
}
return false;
}
-VclPtr<SfxTabPage> SwFieldDokPage::Create( TabPageParent pParent,
- const SfxItemSet *const pAttrSet)
+VclPtr<SfxTabPage> SwFieldDokPage::Create(TabPageParent pParent,
+ const SfxItemSet *const pAttrSet)
{
- return VclPtr<SwFieldDokPage>::Create( pParent.pParent, pAttrSet );
+ return VclPtr<SwFieldDokPage>::Create(pParent, pAttrSet);
}
sal_uInt16 SwFieldDokPage::GetGroup()
@@ -659,10 +621,9 @@ sal_uInt16 SwFieldDokPage::GetGroup()
void SwFieldDokPage::FillUserData()
{
- const sal_Int32 nEntryPos = m_pTypeLB->GetSelectedEntryPos();
- const sal_uInt16 nTypeSel = ( LISTBOX_ENTRY_NOTFOUND == nEntryPos )
- ? USHRT_MAX : sal::static_int_cast< sal_uInt16 >
- (reinterpret_cast< sal_uIntPtr >(m_pTypeLB->GetEntryData( nEntryPos )));
+ const sal_Int32 nEntryPos = m_xTypeLB->get_selected_index();
+ const sal_uInt16 nTypeSel = ( -1 == nEntryPos )
+ ? USHRT_MAX : m_xTypeLB->get_id(nEntryPos).toUInt32();
SetUserData(USER_DATA_VERSION ";" + OUString::number( nTypeSel ));
}
diff --git a/sw/source/ui/fldui/flddok.hxx b/sw/source/ui/fldui/flddok.hxx
index 1a07e5afdf93..8ee99cf74b27 100644
--- a/sw/source/ui/fldui/flddok.hxx
+++ b/sw/source/ui/fldui/flddok.hxx
@@ -31,27 +31,27 @@
class SwFieldDokPage : public SwFieldPage
{
- VclPtr<ListBox> m_pTypeLB;
- VclPtr<VclContainer> m_pSelection;
- VclPtr<ListBox> m_pSelectionLB;
- VclPtr<FixedText> m_pValueFT;
- VclPtr<Edit> m_pValueED;
- VclPtr<FixedText> m_pLevelFT;
- VclPtr<NumericField> m_pLevelED;
- VclPtr<FixedText> m_pDateFT;
- VclPtr<FixedText> m_pTimeFT;
- VclPtr<NumericField> m_pDateOffsetED;
- VclPtr<VclContainer> m_pFormat;
- VclPtr<ListBox> m_pFormatLB;
- VclPtr<NumFormatListBox> m_pNumFormatLB;
- VclPtr<CheckBox> m_pFixedCB;
-
sal_Int32 nOldSel;
sal_uLong nOldFormat;
- DECL_LINK(TypeHdl, ListBox&, void);
- DECL_LINK(FormatHdl, ListBox&, void);
- DECL_LINK(SubTypeHdl, ListBox&, void);
+ std::unique_ptr<weld::TreeView> m_xTypeLB;
+ std::unique_ptr<weld::Widget> m_xSelection;
+ std::unique_ptr<weld::TreeView> m_xSelectionLB;
+ std::unique_ptr<weld::Label> m_xValueFT;
+ std::unique_ptr<weld::Entry> m_xValueED;
+ std::unique_ptr<weld::Label> m_xLevelFT;
+ std::unique_ptr<weld::SpinButton> m_xLevelED;
+ std::unique_ptr<weld::Label> m_xDateFT;
+ std::unique_ptr<weld::Label> m_xTimeFT;
+ std::unique_ptr<weld::SpinButton> m_xDateOffsetED;
+ std::unique_ptr<weld::Widget> m_xFormat;
+ std::unique_ptr<weld::TreeView> m_xFormatLB;
+ std::unique_ptr<SwNumFormatTreeView> m_xNumFormatLB;
+ std::unique_ptr<weld::CheckButton> m_xFixedCB;
+
+ DECL_LINK(TypeHdl, weld::TreeView&, void);
+ DECL_LINK(FormatHdl, weld::TreeView&, void);
+ DECL_LINK(SubTypeHdl, weld::TreeView&, void);
void AddSubType(sal_uInt16 nTypeId);
sal_Int32 FillFormatLB(sal_uInt16 nTypeId);
@@ -60,10 +60,9 @@ protected:
virtual sal_uInt16 GetGroup() override;
public:
- SwFieldDokPage(vcl::Window* pWindow, const SfxItemSet * pSet);
+ SwFieldDokPage(TabPageParent pWindow, const SfxItemSet * pSet);
- virtual ~SwFieldDokPage() override;
- virtual void dispose() override;
+ virtual ~SwFieldDokPage() override;
static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rAttrSet);
diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx
index 8c961cd6fe30..1fccc557c39b 100644
--- a/sw/source/ui/fldui/fldpage.cxx
+++ b/sw/source/ui/fldui/fldpage.cxx
@@ -385,7 +385,7 @@ void SwFieldPage::EnableInsert(bool bEnable)
m_bInsert = bEnable;
}
-IMPL_LINK_NOARG(SwFieldPage, NumFormatHdl, ListBox&, void)
+IMPL_LINK_NOARG(SwFieldPage, NumFormatHdl, weld::TreeView&, void)
{
InsertHdl(nullptr);
}
diff --git a/sw/source/ui/fldui/fldpage.hxx b/sw/source/ui/fldui/fldpage.hxx
index 650989d51f01..e640d409d7e2 100644
--- a/sw/source/ui/fldui/fldpage.hxx
+++ b/sw/source/ui/fldui/fldpage.hxx
@@ -57,7 +57,7 @@ protected:
DECL_LINK( ListBoxInsertHdl, ListBox&, void );
DECL_LINK( TreeViewInsertHdl, weld::TreeView&, void );
DECL_LINK( TreeListBoxInsertHdl, SvTreeListBox*, bool );
- DECL_LINK( NumFormatHdl, ListBox&, void );
+ DECL_LINK( NumFormatHdl, weld::TreeView&, void );
void InsertHdl(void *);
void Init();
diff --git a/sw/source/uibase/inc/numfmtlb.hxx b/sw/source/uibase/inc/numfmtlb.hxx
index 6d120242b18c..cee592194eb6 100644
--- a/sw/source/uibase/inc/numfmtlb.hxx
+++ b/sw/source/uibase/inc/numfmtlb.hxx
@@ -66,39 +66,113 @@ public:
SAL_DLLPRIVATE static double GetDefValue(const SvNumFormatType nFormatType);
};
-class SW_DLLPUBLIC SwNumFormatListBox
+class SW_DLLPUBLIC SwNumFormatBase
{
+protected:
SvNumFormatType nCurrFormatType;
bool mbCurrFormatTypeNeedsInit;
sal_Int32 nStdEntry;
+ bool bOneArea;
sal_uInt32 nDefFormat;
LanguageType eCurLanguage;
+ bool bShowLanguageControl; //determine whether the language control has
+ //to be shown in the number format dialog
bool bUseAutomaticLanguage;//determine whether language is automatically assigned
+public:
+ SwNumFormatBase();
+
+ void SetAutomaticLanguage(bool bSet) { bUseAutomaticLanguage = bSet; }
+ bool IsAutomaticLanguage()const { return bUseAutomaticLanguage; }
+ SvNumFormatType GetFormatType() const { return nCurrFormatType; }
+ void SetLanguage(LanguageType eSet) { eCurLanguage = eSet; }
+ void SetShowLanguageControl(bool bSet) { bShowLanguageControl = bSet; }
+ void SetOneArea(bool bOnlyOne) { bOneArea = bOnlyOne; }
+
+ void SetFormatType(const SvNumFormatType nFormatType);
+ void SetDefFormat(const sal_uInt32 nDefFormat);
+ virtual sal_uInt32 GetFormat() const = 0;
+
+ virtual void Init();
+ void CallSelectHdl();
+
+ virtual void clear();
+ virtual int get_count() const = 0;
+ virtual int get_active() const = 0;
+ virtual OUString get_id(int nPos) const = 0;
+ virtual OUString get_text(int nPos) const = 0;
+ virtual weld::Widget& get_widget() const = 0;
+ virtual void append(const OUString& rId, const OUString& rText) = 0;
+ virtual void append_text(const OUString& rText) = 0;
+ virtual void insert_text(int nPos, const OUString& rText) = 0;
+ virtual void set_active(int nPos) = 0;
+ virtual void set_id(int nPos, const OUString& rId) = 0;
+ virtual ~SwNumFormatBase() {}
+};
+class SW_DLLPUBLIC SwNumFormatListBox : public SwNumFormatBase
+{
std::unique_ptr<weld::ComboBox> mxControl;
DECL_DLLPRIVATE_LINK( SelectHdl, weld::ComboBox&, void );
- SAL_DLLPRIVATE void Init();
+ virtual void Init() override;
public:
SwNumFormatListBox(std::unique_ptr<weld::ComboBox> xControl);
- ~SwNumFormatListBox();
-
- void clear();
+ virtual sal_uInt32 GetFormat() const override;
+
+ virtual void clear() override;
+ virtual int get_count() const override { return mxControl->get_count(); }
+ virtual int get_active() const override { return mxControl->get_active(); }
+ virtual OUString get_id(int nPos) const override { return mxControl->get_id(nPos); }
+ virtual OUString get_text(int nPos) const override { return mxControl->get_text(nPos); }
+ virtual weld::Widget& get_widget() const override { return *mxControl; }
+ virtual void append(const OUString& rId, const OUString& rText) override { mxControl->append(rId, rText); }
+ virtual void append_text(const OUString& rText) override { mxControl->append_text(rText); }
+ virtual void insert_text(int nPos, const OUString& rText) override { mxControl->insert_text(nPos, rText); }
+ virtual void set_active(int nPos) override { mxControl->set_active(nPos); }
+ virtual void set_id(int nPos, const OUString& rId) override { mxControl->set_id(nPos, rId); }
void show() { mxControl->show(); }
void hide() { mxControl->hide(); }
- void SetFormatType(const SvNumFormatType nFormatType);
- void SetDefFormat(const sal_uInt32 nDefFormat);
- sal_uInt32 GetFormat() const;
+ void set_sensitive(bool bSensitive) { mxControl->set_sensitive(bSensitive); }
+ void connect_changed(const Link<weld::ComboBox&, void>& rLink) { mxControl->connect_changed(rLink); }
+};
+
+class SW_DLLPUBLIC SwNumFormatTreeView : public SwNumFormatBase
+{
+ std::unique_ptr<weld::TreeView> mxControl;
- void CallSelectHdl();
+ DECL_DLLPRIVATE_LINK( SelectHdl, weld::TreeView&, void );
+
+ virtual void Init() override;
+
+public:
+ SwNumFormatTreeView(std::unique_ptr<weld::TreeView> xControl);
+
+ virtual sal_uInt32 GetFormat() const override;
+
+ virtual void clear() override;
+ virtual int get_count() const override { return mxControl->n_children(); }
+ virtual int get_active() const override { return mxControl->get_selected_index(); }
+ virtual OUString get_id(int nPos) const override { return mxControl->get_id(nPos); }
+ virtual OUString get_text(int nPos) const override { return mxControl->get_text(nPos); }
+ virtual weld::Widget& get_widget() const override { return *mxControl; }
+ virtual void append(const OUString& rId, const OUString& rText) override { mxControl->append(rId, rText); }
+ virtual void append_text(const OUString& rText) override { mxControl->append_text(rText); }
+ virtual void insert_text(int nPos, const OUString& rText) override { mxControl->insert_text(nPos, rText); }
+ virtual void set_active(int nPos) override { mxControl->select(nPos); }
+ virtual void set_id(int nPos, const OUString& rId) override { mxControl->set_id(nPos, rId); }
+ void show() { mxControl->show(); }
+ void hide() { mxControl->hide(); }
+ int get_selected_index() const { return mxControl->get_selected_index(); }
+ void set_visible(bool bVisible) { mxControl->set_visible(bVisible); }
+ void select(int nPos) { mxControl->select(nPos); }
+ void connect_row_activated(const Link<weld::TreeView&, void>& rLink) { mxControl->connect_row_activated(rLink); }
void set_sensitive(bool bSensitive) { mxControl->set_sensitive(bSensitive); }
- void connect_changed(const Link<weld::ComboBox&, void>& rLink) { mxControl->connect_changed(rLink); }
- weld::ComboBox& get_widget() const { return *mxControl; }
+ void connect_changed(const Link<weld::TreeView&, void>& rLink) { mxControl->connect_changed(rLink); }
};
#endif
diff --git a/sw/source/uibase/utlui/numfmtlb.cxx b/sw/source/uibase/utlui/numfmtlb.cxx
index a7766a505a1b..bd14c4cce32a 100644
--- a/sw/source/uibase/utlui/numfmtlb.cxx
+++ b/sw/source/uibase/utlui/numfmtlb.cxx
@@ -454,18 +454,30 @@ void NumFormatListBox::Clear()
nCurrFormatType = SvNumFormatType::ALL;
}
-SwNumFormatListBox::SwNumFormatListBox(std::unique_ptr<weld::ComboBox> xControl)
+SwNumFormatBase::SwNumFormatBase()
: nCurrFormatType(SvNumFormatType::ALL)
, mbCurrFormatTypeNeedsInit(true)
, nStdEntry(0)
+ , bOneArea(false)
, nDefFormat(0)
+ , bShowLanguageControl(false)
, bUseAutomaticLanguage(true)
- , mxControl(std::move(xControl))
+{
+}
+
+SwNumFormatListBox::SwNumFormatListBox(std::unique_ptr<weld::ComboBox> xControl)
+ : mxControl(std::move(xControl))
{
Init();
}
-void SwNumFormatListBox::Init()
+SwNumFormatTreeView::SwNumFormatTreeView(std::unique_ptr<weld::TreeView> xControl)
+ : mxControl(std::move(xControl))
+{
+ Init();
+}
+
+void SwNumFormatBase::Init()
{
SwView *pView = GetActiveView();
@@ -476,15 +488,23 @@ void SwNumFormatListBox::Init()
SetFormatType(SvNumFormatType::NUMBER);
SetDefFormat(nDefFormat);
+}
+
+void SwNumFormatListBox::Init()
+{
+ SwNumFormatBase::Init();
mxControl->connect_changed(LINK(this, SwNumFormatListBox, SelectHdl));
}
-SwNumFormatListBox::~SwNumFormatListBox()
+void SwNumFormatTreeView::Init()
{
+ SwNumFormatBase::Init();
+
+ mxControl->connect_changed(LINK(this, SwNumFormatTreeView, SelectHdl));
}
-void SwNumFormatListBox::SetFormatType(const SvNumFormatType nFormatType)
+void SwNumFormatBase::SetFormatType(const SvNumFormatType nFormatType)
{
if (!mbCurrFormatTypeNeedsInit &&
(nCurrFormatType & nFormatType)) // there are mixed formats, like for example DateTime
@@ -599,7 +619,7 @@ void SwNumFormatListBox::SetFormatType(const SvNumFormatType nFormatType)
nFormat != nSysShortDateFormat &&
nFormat != nSysLongDateFormat)
{
- mxControl->append(OUString::number(nFormat), sValue);
+ append(OUString::number(nFormat), sValue);
if( nFormat == pFormatter->GetStandardFormat(
nFormatType, eCurLanguage ) )
@@ -608,16 +628,16 @@ void SwNumFormatListBox::SetFormatType(const SvNumFormatType nFormatType)
}
}
- mxControl->append_text(SwResId(STR_DEFINE_NUMBERFORMAT));
+ append_text(SwResId(STR_DEFINE_NUMBERFORMAT));
- mxControl->set_active(nStdEntry);
+ set_active(nStdEntry);
nCurrFormatType = nFormatType;
mbCurrFormatTypeNeedsInit = false;
}
-void SwNumFormatListBox::SetDefFormat(const sal_uInt32 nDefaultFormat)
+void SwNumFormatBase::SetDefFormat(const sal_uInt32 nDefaultFormat)
{
if (nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
{
@@ -638,11 +658,11 @@ void SwNumFormatListBox::SetDefFormat(const sal_uInt32 nDefaultFormat)
sal_uInt32 nFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nDefaultFormat, eCurLanguage);
- for (sal_Int32 i = 0, nCount = mxControl->get_count(); i < nCount; ++i)
+ for (sal_Int32 i = 0, nCount = get_count(); i < nCount; ++i)
{
- if (nFormat == mxControl->get_id(i).toUInt32())
+ if (nFormat == get_id(i).toUInt32())
{
- mxControl->set_active(i);
+ set_active(i);
nStdEntry = i;
nDefFormat = GetFormat();
return;
@@ -663,7 +683,7 @@ void SwNumFormatListBox::SetDefFormat(const sal_uInt32 nDefaultFormat)
}
sal_Int32 nPos = 0;
- while (mxControl->get_id(nPos).toUInt32() == NUMBERFORMAT_ENTRY_NOT_FOUND)
+ while (get_id(nPos).toUInt32() == NUMBERFORMAT_ENTRY_NOT_FOUND)
nPos++;
if ( lcl_isSystemFormat(nDefaultFormat, pFormatter, eCurLanguage) )
@@ -671,9 +691,9 @@ void SwNumFormatListBox::SetDefFormat(const sal_uInt32 nDefaultFormat)
sValue += SwResId(RID_STR_SYSTEM);
}
- mxControl->insert_text(nPos, sValue); // Insert as first numeric entry
- mxControl->set_id(nPos, OUString::number(nDefaultFormat));
- mxControl->set_active(nPos);
+ insert_text(nPos, sValue); // Insert as first numeric entry
+ set_id(nPos, OUString::number(nDefaultFormat));
+ set_active(nPos);
nDefFormat = GetFormat();
}
@@ -682,14 +702,18 @@ sal_uInt32 SwNumFormatListBox::GetFormat() const
return mxControl->get_active_id().toUInt32();
}
-void SwNumFormatListBox::CallSelectHdl()
+sal_uInt32 SwNumFormatTreeView::GetFormat() const
+{
+ return mxControl->get_selected_id().toUInt32();
+}
+
+void SwNumFormatBase::CallSelectHdl()
{
- const sal_Int32 nPos = mxControl->get_active();
+ const sal_Int32 nPos = get_active();
OUString sDefine(SwResId( STR_DEFINE_NUMBERFORMAT ));
SwView *pView = GetActiveView();
- if( !pView || nPos != mxControl->get_count() - 1 ||
- mxControl->get_text(nPos) != sDefine )
+ if (!pView || nPos != get_count() - 1 || get_text(nPos) != sDefine)
return;
SwWrtShell &rSh = pView->GetWrtShell();
@@ -714,13 +738,16 @@ void SwNumFormatListBox::CallSelectHdl()
SID_ATTR_NUMBERFORMAT_INFO ) );
if( (SvNumFormatType::DATE | SvNumFormatType::TIME) & nCurrFormatType )
- aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, false));
+ aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, bOneArea));
- aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_NOLANGUAGE, true));
+ aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_NOLANGUAGE, !bShowLanguageControl));
aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ADD_AUTO, bUseAutomaticLanguage));
+ // force deselect to break mouse lock on selected entry
+ set_active(-1);
+
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
- ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateNumFormatDialog(mxControl.get(), aCoreSet));
+ ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateNumFormatDialog(&get_widget(), aCoreSet));
if (RET_OK == pDlg->Execute())
{
@@ -745,7 +772,11 @@ void SwNumFormatListBox::CallSelectHdl()
// SetDefFormat uses eCurLanguage to look for if this format already in the list
SetDefFormat(nNumberFormat);
}
-
+ if( bShowLanguageControl && SfxItemState::SET == pOutSet->GetItemState(
+ SID_ATTR_NUMBERFORMAT_ADD_AUTO, false, &pItem ))
+ {
+ bUseAutomaticLanguage = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ }
}
else
SetDefFormat(nFormat);
@@ -757,11 +788,27 @@ IMPL_LINK_NOARG(SwNumFormatListBox, SelectHdl, weld::ComboBox&, void)
CallSelectHdl();
}
-void SwNumFormatListBox::clear()
+IMPL_LINK_NOARG(SwNumFormatTreeView, SelectHdl, weld::TreeView&, void)
+{
+ CallSelectHdl();
+}
+
+void SwNumFormatBase::clear()
{
- mxControl->clear();
mbCurrFormatTypeNeedsInit = true;
nCurrFormatType = SvNumFormatType::ALL;
}
+void SwNumFormatListBox::clear()
+{
+ mxControl->clear();
+ SwNumFormatBase::clear();
+}
+
+void SwNumFormatTreeView::clear()
+{
+ mxControl->clear();
+ SwNumFormatBase::clear();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/uiconfig/swriter/ui/flddocumentpage.ui b/sw/uiconfig/swriter/ui/flddocumentpage.ui
index ff1a8dead329..b62a505c4f17 100644
--- a/sw/uiconfig/swriter/ui/flddocumentpage.ui
+++ b/sw/uiconfig/swriter/ui/flddocumentpage.ui
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
<interface domain="sw">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
@@ -9,6 +10,38 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkTreeStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkTreeStore" id="liststore2">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkTreeStore" id="liststore3">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkTreeStore" id="liststore4">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkBox" id="FieldDocumentPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -29,15 +62,37 @@
<property name="hexpand">True</property>
<property name="top_padding">6</property>
<child>
- <object class="GtkTreeView" id="type:border">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="search_column">0</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection1"/>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="type">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection1"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
</child>
@@ -47,9 +102,9 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="flddocumentpage|label1">_Type</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -76,14 +131,37 @@
<property name="hexpand">True</property>
<property name="top_padding">6</property>
<child>
- <object class="GtkTreeView" id="select:border">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection3"/>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="select">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore2</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection2"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext2"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
</child>
@@ -93,9 +171,9 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="flddocumentpage|label2">S_elect</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -137,15 +215,37 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkTreeView" id="format:border">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="search_column">0</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection5"/>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="format">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore3</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection3"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext3"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
<packing>
@@ -155,14 +255,38 @@
</packing>
</child>
<child>
- <object class="swlo-NumFormatListBox" id="numformat:border">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="entry_text_column">0</property>
- <property name="id_column">1</property>
- <property name="dropdown">False</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="numformat">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore4</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection4"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn4">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext4"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -178,9 +302,9 @@
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="flddocumentpage|label3">F_ormat</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -190,8 +314,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -207,8 +329,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -220,16 +340,14 @@
<object class="GtkLabel" id="levelft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="flddocumentpage|levelft">Level</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">level</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -241,60 +359,51 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="offset">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="daysft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="flddocumentpage|daysft">Offs_et in days</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">offset</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="minutesft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="flddocumentpage|minutesft">Offs_et in minutes</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">offset</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -306,36 +415,31 @@
<object class="GtkLabel" id="valueft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="flddocumentpage|valueft">_Value</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">value</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="value">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
diff --git a/sw/uiconfig/swriter/ui/fldrefpage.ui b/sw/uiconfig/swriter/ui/fldrefpage.ui
index 812ee1cfa0ef..6344f9013fec 100644
--- a/sw/uiconfig/swriter/ui/fldrefpage.ui
+++ b/sw/uiconfig/swriter/ui/fldrefpage.ui
@@ -463,8 +463,4 @@
</packing>
</child>
</object>
- <object class="GtkSizeGroup" id="sizegroup1">
- <property name="mode">both</property>
- <property name="ignore_hidden">True</property>
- </object>
</interface>