30#define USER_DATA_VERSION_1 "1"
31#define USER_DATA_VERSION USER_DATA_VERSION_1
34 :
SwFieldPage(pPage, pController,
"modules/swriter/ui/flddbpage.ui",
"FieldDbPage", pCoreSet)
37 , m_xTypeLB(m_xBuilder->weld_tree_view(
"type"))
38 , m_xDatabaseTLB(new
SwDBTreeList(m_xBuilder->weld_tree_view(
"select")))
39 , m_xAddDBPB(m_xBuilder->weld_button(
"browse"))
40 , m_xCondition(m_xBuilder->weld_widget(
"condgroup"))
41 , m_xConditionED(new
ConditionEdit(m_xBuilder->weld_entry(
"condition")))
42 , m_xValue(m_xBuilder->weld_widget(
"recgroup"))
43 , m_xValueED(m_xBuilder->weld_entry(
"recnumber"))
44 , m_xDBFormatRB(m_xBuilder->weld_radio_button(
"fromdatabasecb"))
45 , m_xNewFormatRB(m_xBuilder->weld_radio_button(
"userdefinedcb"))
46 , m_xNumFormatLB(new
NumFormatListBox(m_xBuilder->weld_combo_box(
"numformat")))
47 , m_xFormatLB(m_xBuilder->weld_combo_box(
"format"))
48 , m_xFormat(m_xBuilder->weld_widget(
"formatframe"))
56 auto nHeight =
m_xTypeLB->get_height_rows(10);
57 m_xTypeLB->set_size_request(nWidth, nHeight);
79 SwDBManager* pDbManager = pSh->GetDoc()->GetDBManager();
90 const sal_Int32 nOldPos =
m_xTypeLB->get_selected_index();
110 m_xTypeLB->append(OUString::number(
static_cast<sal_uInt16
>(nTypeId)),
123 for( sal_uInt16
i = 0;
i < nSize; ++
i )
126 OUString
sId(OUString::number(nFormatId));
158 if (nVal != USHRT_MAX)
160 for (sal_Int32
i = 0, nEntryCount =
m_xTypeLB->n_children();
i < nEntryCount; ++
i)
193 OUString sColumnName;
197 aData.sCommand = sTableName;
198 aData.nCommandType = bIsTable ? 0 : 1;
202 SwDBManager* pDbManager = pSh->GetDoc()->GetDBManager();
206 if (
aData.sDataSource.isEmpty())
207 aData = pSh->GetDBData();
210 if(!
aData.sDataSource.isEmpty())
213 sal_uInt32 nFormat = 0;
214 sal_uInt16 nSubType = 0;
216 OUString sDBName =
aData.sDataSource
220 + OUString::number(
aData.nCommandType)
222 if (!sColumnName.isEmpty())
224 sDBName += sColumnName + OUStringChar(
DB_DELIM);
244 OUString sTempTableName;
245 OUString sTempColumnName;
246 OUString sTempDBName =
m_xDatabaseTLB->GetDBName(sTempTableName, sTempColumnName);
265 return std::make_unique<SwFieldDBPage>( pPage, pController, pAttrSet );
295 bool bCond =
false, bSetNo =
false, bFormat =
false, bDBFormat =
false;
303 OUString sColumnName;
308 aData = pField->GetDBData();
317 aData = pField->GetDBData(pSh->GetDoc());
399 m_xFormat->set_sensitive(bDBFormat || bFormat);
415 m_xNewFormatRB->set_active(
true);
416 m_xNumFormatLB->CallSelectHdl();
424 std::unique_ptr<weld::TreeIter> xIter(
m_xDatabaseTLB->make_iterator());
439 bool bHasValue = !
m_xValueED->get_text().isEmpty();
441 bInsert &= bHasValue;
449 std::unique_ptr<weld::TreeIter> xIter(rBox.make_iterator());
450 if (!rBox.get_selected(xIter.get()))
455 bool bEntry = m_xDatabaseTLB->iter_parent(*xIter);
458 bEntry = m_xDatabaseTLB->iter_parent(*xIter);
465 bool bNumFormat =
false;
470 OUString sColumnName;
472 OUString sDBName = m_xDatabaseTLB->GetDBName(sTableName, sColumnName, &bIsTable);
473 bNumFormat = GetFieldMgr().IsDBNumeric(sDBName,
478 m_xDBFormatRB->set_active(
true);
481 m_xDBFormatRB->set_sensitive(bNumFormat);
482 m_xNewFormatRB->set_sensitive(bNumFormat);
483 m_xNumFormatLB->set_sensitive(bNumFormat);
484 m_xFormat->set_sensitive(bNumFormat);
493 if (!sNewDB.isEmpty())
495 m_xDatabaseTLB->AddDataSource(sNewDB);
508 const sal_Int32 nEntryPos =
m_xTypeLB->get_selected_index();
509 const sal_uInt16 nTypeSel = ( -1 == nEntryPos )
510 ? USHRT_MAX :
m_xTypeLB->get_id(nEntryPos).toUInt32();
518 const SwDBData& rData =
SW_MOD()->GetDBConfig()->GetAddressSource();
void SetUserData(const OUString &rString)
const OUString & GetUserData() const
void RevokeLastRegistrations()
Revoke not committed registrations in case of mail merge cancel.
static OUString LoadAndRegisterDataSource(weld::Window *pParent, SwDocShell *pDocShell=nullptr)
Loads a data source from file and registers it.
void CommitLastRegistrations()
Accept not committed registrations.
virtual void FillUserData() override
std::unique_ptr< weld::Entry > m_xValueED
SwFieldDBPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
void TypeHdl(const weld::TreeView *)
void ActivateMailMergeAddress()
virtual ~SwFieldDBPage() override
std::unique_ptr< ConditionEdit > m_xConditionED
std::unique_ptr< NumFormatListBox > m_xNumFormatLB
std::unique_ptr< weld::Widget > m_xCondition
OUString m_sOldColumnName
virtual void Reset(const SfxItemSet *rSet) override
std::unique_ptr< weld::RadioButton > m_xDBFormatRB
virtual bool DeferResetToFirstActivation() override
std::unique_ptr< weld::RadioButton > m_xNewFormatRB
virtual sal_uInt16 GetGroup() override
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Button > m_xAddDBPB
std::unique_ptr< weld::ComboBox > m_xFormatLB
std::unique_ptr< weld::Widget > m_xFormat
std::unique_ptr< weld::TreeView > m_xTypeLB
SwWrtShell * CheckAndGetWrtShell()
std::unique_ptr< SwDBTreeList > m_xDatabaseTLB
void SetWrtShell(SwWrtShell &rSh)
std::unique_ptr< weld::Widget > m_xValue
virtual bool FillItemSet(SfxItemSet *rSet) override
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
static const OUString & GetTypeStr(sal_uInt16 nPos)
static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId)
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
void InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, const OUString &rPar1, const OUString &rPar2, sal_uInt32 nFormatId, sal_Unicode cDelim=' ', bool bIsAutomaticLanguage=true)
sal_Int32 GetTypeSel() const
void SetWrtShell(SwWrtShell *m_pWrtShell)
void SetTypeSel(sal_Int32 nSet)
SwFieldMgr & GetFieldMgr()
bool IsFieldDlgHtmlMode() const
void EnableInsert(bool bEnable)
SwWrtShell * GetWrtShell()
SwFieldTypesEnum GetTypeId() const
virtual OUString GetPar1() const
virtual sal_uInt16 GetSubType() const
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
SwFieldType * GetTyp() const
virtual OUString GetPar2() const
Used by the UI to modify the document model.
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
SwFieldTypesEnum
List of FieldTypes at UI.
#define USER_DATA_VERSION_1
#define USER_DATA_VERSION
IMPL_LINK(SwFieldDBPage, TypeListBoxHdl, weld::TreeView &, rBox, void)
IMPL_LINK_NOARG(SwFieldDBPage, NumSelectHdl, weld::ComboBox &, void)
#define FIELD_COLUMN_WIDTH
#define LINK(Instance, Class, Member)
constexpr OUStringLiteral aData
const SwExtendedSubType SUB_OWN_FMT
SwDBField: Don't accept formatting from database.
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
SwWrtShell * GetActiveWrtShell()