32#include <document.hxx>
45 VclMessageType::Warning, VclButtonsType::Ok,
94void DBSaveData::Save()
97 aStr = rEdAssign.GetText();
98 bHeader = rBtnHeader.get_active();
99 bTotals = rBtnTotals.get_active();
100 bSize = rBtnSize.get_active();
101 bFormat = rBtnFormat.get_active();
102 bStrip = rBtnStrip.get_active();
106void DBSaveData::Restore()
111 rEdAssign.SetText( aStr );
112 rBtnHeader.set_active ( bHeader );
113 rBtnTotals.set_active ( bTotals );
114 rBtnSize.set_active ( bSize );
115 rBtnFormat.set_active ( bFormat );
116 rBtnStrip.set_active ( bStrip );
126 "modules/scalc/ui/definedatabaserangedialog.ui",
"DefineDatabaseRangeDialog")
127 , m_rViewData(rViewData)
128 , rDoc(rViewData.GetDocument())
129 , bRefInputMode(false)
130 , aAddrDetails(rDoc.GetAddressConvention(), 0, 0)
131 , aLocalDbCol(*(rDoc.GetDBCollection()))
132 , m_xEdName(m_xBuilder->weld_entry_tree_view(
"entrygrid",
"entry",
"entry-list"))
133 , m_xAssignFrame(m_xBuilder->weld_frame(
"RangeFrame"))
134 , m_xEdAssign(new
formula::RefEdit(m_xBuilder->weld_entry(
"assign")))
135 , m_xRbAssign(new
formula::RefButton(m_xBuilder->weld_button(
"assignrb")))
136 , m_xOptions(m_xBuilder->weld_widget(
"Options"))
137 , m_xBtnHeader(m_xBuilder->weld_check_button(
"ContainsColumnLabels"))
138 , m_xBtnTotals(m_xBuilder->weld_check_button(
"ContainsTotalsRow"))
139 , m_xBtnDoSize(m_xBuilder->weld_check_button(
"InsertOrDeleteCells"))
140 , m_xBtnKeepFmt(m_xBuilder->weld_check_button(
"KeepFormatting"))
141 , m_xBtnStripData(m_xBuilder->weld_check_button(
"DontSaveImportedData"))
142 , m_xFTSource(m_xBuilder->weld_label(
"Source"))
143 , m_xFTOperations(m_xBuilder->weld_label(
"Operations"))
144 , m_xBtnOk(m_xBuilder->weld_button(
"ok"))
145 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
146 , m_xBtnAdd(m_xBuilder->weld_button(
"add"))
147 , m_xBtnRemove(m_xBuilder->weld_button(
"delete"))
148 , m_xModifyPB(m_xBuilder->weld_button(
"modify"))
149 , m_xInvalidFT(m_xBuilder->weld_label(
"invalid"))
150 , m_xFrameLabel(m_xAssignFrame->weld_label_widget())
152 m_xEdName->set_height_request_by_rows(4);
200 nEndCol, nEndRow, nEndTab );
202 theCurArea =
ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
220 pDBData->
GetArea( nTab, nCol1, nRow1, nCol2, nRow2 );
222 if ( (rStart.
Tab() == nTab)
223 && (rStart.
Col() == nCol1) && (rStart.
Row() == nRow1)
224 && (rEnd.
Col() == nCol2) && (rEnd.
Row() == nRow2 ) )
226 OUString aDBName = pDBData->
GetName();
288 DoClose( ScDbNameDlgWrapper::GetChildWindowId() );
315 for (
const auto& rxDB : rDBs)
341 pData->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
371 AddBtnHdl(*m_xBtnAdd);
392 OUString aNewArea = m_xEdAssign->GetText();
394 if ( aNewName.isEmpty() || aNewArea.isEmpty() )
402 OUString aText = m_xEdAssign->GetText();
405 theCurArea = aTmpRange;
417 pOldEntry->
SetHeader( m_xBtnHeader->get_active() );
418 pOldEntry->
SetTotals( m_xBtnTotals->get_active() );
419 pOldEntry->
SetDoSize( m_xBtnDoSize->get_active() );
420 pOldEntry->
SetKeepFmt( m_xBtnKeepFmt->get_active() );
421 pOldEntry->
SetStripData( m_xBtnStripData->get_active() );
427 std::unique_ptr<ScDBData> pNewEntry(
new ScDBData( aNewName, aStart.
Tab(),
428 aStart.
Col(), aStart.
Row(),
430 true, m_xBtnHeader->get_active(),
431 m_xBtnTotals->get_active() ));
432 pNewEntry->SetDoSize( m_xBtnDoSize->get_active() );
433 pNewEntry->SetKeepFmt( m_xBtnKeepFmt->get_active() );
434 pNewEntry->SetStripData( m_xBtnStripData->get_active() );
436 bool ins = aLocalDbCol.getNamedDBs().insert(std::move(pNewEntry));
437 assert(ins); (void)ins;
442 m_xEdName->set_entry_text( OUString() );
443 m_xEdName->grab_focus();
444 m_xBtnAdd->set_label( aStrAdd );
445 m_xBtnAdd->set_sensitive(
false);
446 m_xBtnRemove->set_sensitive(
false);
447 m_xEdAssign->SetText( OUString() );
448 m_xBtnHeader->set_active(
true);
449 m_xBtnTotals->set_active(
false );
450 m_xBtnDoSize->set_active(
false );
451 m_xBtnKeepFmt->set_active(
false );
452 m_xBtnStripData->set_active(
false );
453 SetInfoStrings(
nullptr );
457 NameModifyHdl( *m_xEdName );
462 m_xEdAssign->SelectAll();
463 m_xEdAssign->GrabFocus();
470 m_xEdName->select_entry_region(0, -1);
471 m_xEdName->grab_focus();
480 const OUString& mrName;
482 explicit FindByName(
const OUString& rName) : mrName(rName) {}
483 bool operator() (std::unique_ptr<ScDBData>
const& p)
const
485 return p->GetName() == mrName;
493 OUString aStrEntry = m_xEdName->get_active_text();
496 ::std::find_if(rDBs.
begin(), rDBs.
end(), FindByName(aStrEntry));
498 if (itr == rDBs.
end())
501 OUString aStrDelMsg =
ScResId( STR_QUERY_DELENTRY );
504 VclMessageType::Question, VclButtonsType::YesNo,
506 xQueryBox->set_default_response(
RET_YES);
507 if (
RET_YES != xQueryBox->run())
511 SCCOL nColStart, nColEnd;
512 SCROW nRowStart, nRowEnd;
513 (*itr)->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
514 aRemoveList.emplace_back(
ScAddress( nColStart, nRowStart, nTab ),
521 m_xEdName->set_entry_text( OUString() );
522 m_xEdName->grab_focus();
523 m_xBtnAdd->set_label( aStrAdd );
524 m_xBtnAdd->set_sensitive(
false);
525 m_xBtnRemove->set_sensitive(
false);
526 m_xEdAssign->SetText( OUString() );
528 m_xBtnHeader->set_active(
true);
529 m_xBtnTotals->set_active(
false );
530 m_xBtnDoSize->set_active(
false );
531 m_xBtnKeepFmt->set_active(
false );
532 m_xBtnStripData->set_active(
false );
533 SetInfoStrings(
nullptr );
536 NameModifyHdl( *m_xEdName );
541 OUString theName = m_xEdName->get_active_text();
542 bool bNameFound = m_xEdName->find_text(theName) != -1;
544 if ( theName.isEmpty() )
546 if (m_xBtnAdd->get_label() != aStrAdd)
547 m_xBtnAdd->set_label( aStrAdd );
548 m_xBtnAdd->set_sensitive(
false);
549 m_xBtnRemove->set_sensitive(
false);
550 m_xAssignFrame->set_sensitive(
false);
551 m_xOptions->set_sensitive(
false);
556 bRefInputMode =
false;
562 if (m_xBtnAdd->get_label() != aStrModify)
563 m_xBtnAdd->set_label( aStrModify );
570 UpdateDBData( theName );
574 if (m_xBtnAdd->get_label() != aStrAdd)
575 m_xBtnAdd->set_label( aStrAdd );
580 if ( !m_xEdAssign->GetText().isEmpty() )
582 m_xBtnAdd->set_sensitive(
true);
583 m_xOptions->set_sensitive(
true);
587 m_xBtnAdd->set_sensitive(
false);
588 m_xOptions->set_sensitive(
false);
590 m_xBtnRemove->set_sensitive(
false);
593 m_xAssignFrame->set_sensitive(
true);
597 bRefInputMode =
true;
606 OUString aText = m_xEdAssign->GetText();
608 theCurArea = aTmpRange;
610 if (!aText.isEmpty() && !m_xEdName->get_active_text().isEmpty())
612 m_xBtnAdd->set_sensitive(
true);
613 m_xBtnHeader->set_sensitive(
true);
614 m_xBtnTotals->set_sensitive(
true);
615 m_xBtnDoSize->set_sensitive(
true);
616 m_xBtnKeepFmt->set_sensitive(
true);
617 m_xBtnStripData->set_sensitive(
true);
618 m_xFTSource->set_sensitive(
true);
619 m_xFTOperations->set_sensitive(
true);
623 m_xBtnAdd->set_sensitive(
false);
624 m_xBtnHeader->set_sensitive(
false);
625 m_xBtnTotals->set_sensitive(
false);
626 m_xBtnDoSize->set_sensitive(
false);
627 m_xBtnKeepFmt->set_sensitive(
false);
628 m_xBtnStripData->set_sensitive(
false);
629 m_xFTSource->set_sensitive(
false);
630 m_xFTOperations->set_sensitive(
false);
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
Stores global named database ranges.
iterator erase(const iterator &itr)
DBsType::iterator iterator
ScDBData * findByUpperName(const OUString &rName)
const ScDBData * GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCCOL nUpdateCol=-1)
const OUString & GetName() const
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
void SetDoSize(bool bSet)
void SetTotals(bool bTotals)
void SetHeader(bool bHasH)
OUString GetOperations() const
void SetStripData(bool bSet)
void SetKeepFmt(bool bSet)
OUString GetSourceString() const
void ModifyAllDBData(const ScDBCollection &rNewColl, const std::vector< ScRange > &rDelAreaList)
std::unique_ptr< weld::Button > m_xModifyPB
std::unique_ptr< weld::Button > m_xBtnAdd
std::unique_ptr< weld::Label > m_xFTSource
std::unique_ptr< weld::EntryTreeView > m_xEdName
std::unique_ptr< formula::RefButton > m_xRbAssign
void UpdateDBData(const OUString &rStrName)
virtual void Close() override
std::unique_ptr< weld::Label > m_xInvalidFT
std::unique_ptr< weld::CheckButton > m_xBtnDoSize
std::unique_ptr< weld::Label > m_xFTOperations
std::unique_ptr< weld::Label > m_xFrameLabel
ScAddress::Details aAddrDetails
virtual void SetActive() override
virtual void SetReference(const ScRange &rRef, ScDocument &rDoc) override
std::unique_ptr< weld::CheckButton > m_xBtnHeader
virtual ~ScDbNameDlg() override
std::unique_ptr< weld::Widget > m_xOptions
void SetInfoStrings(const ScDBData *pDBData)
std::unique_ptr< weld::Button > m_xBtnRemove
ScDBCollection aLocalDbCol
std::unique_ptr< weld::CheckButton > m_xBtnStripData
virtual bool IsRefInputMode() const override
std::unique_ptr< weld::CheckButton > m_xBtnKeepFmt
std::unique_ptr< weld::CheckButton > m_xBtnTotals
std::unique_ptr< formula::RefEdit > m_xEdAssign
std::unique_ptr< weld::Button > m_xBtnCancel
std::unique_ptr< weld::Button > m_xBtnOk
ScDbNameDlg(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent, ScViewData &rViewData)
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
static SC_DLLPUBLIC const CharClass & getCharClass()
static SC_DLLPUBLIC IsNameValidType IsNameValid(const OUString &rName, const ScDocument &rDoc)
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
ScRefFlags ParseAny(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
virtual void RefInputDone(bool bForced=false) override
bool DoClose(sal_uInt16 nId)
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
@ TOP_LEFT
top left cell of area
static std::unique_ptr< DBSaveData > xSaveObj
IMPL_LINK_NOARG(ScDbNameDlg, OkBtnHdl, weld::Button &, void)
constexpr OUStringLiteral STR_DB_LOCAL_NONAME
#define LINK(Instance, Class, Member)
std::unique_ptr< sal_Int32[]> pData
OString strip(const OString &rIn, char c)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
OUString ScResId(TranslateId aId)