weld SwEditRegionDlg
Change-Id: I6aacd013a344caa731841ff4f015017ba16c4aca
Reviewed-on: https://gerrit.libreoffice.org/69325
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index b0c669d..f0f7c95 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -414,10 +414,12 @@ private:
protected:
Link<ComboBox&, void> m_aChangeHdl;
Link<ComboBox&, void> m_aPopupToggledHdl;
Link<ComboBox&, bool> m_aEntryActivateHdl;
Link<OUString&, bool> m_aEntryInsertTextHdl;
void signal_changed() { m_aChangeHdl.Call(*this); }
virtual void signal_popup_toggled() { m_aPopupToggledHdl.Call(*this); }
public:
virtual void insert(int pos, const OUString& rStr, const OUString* pId,
@@ -470,6 +472,10 @@ public:
void remove_id(const OUString& rId) { remove(find_id(rId)); }
void connect_changed(const Link<ComboBox&, void>& rLink) { m_aChangeHdl = rLink; }
virtual void connect_popup_toggled(const Link<ComboBox&, void>& rLink)
{
m_aPopupToggledHdl = rLink;
}
//entry related
virtual bool has_entry() const = 0;
@@ -664,6 +670,7 @@ public:
}
virtual bool iter_parent(TreeIter& rIter) const = 0;
virtual int get_iter_depth(const TreeIter& rIter) const = 0;
virtual int get_iter_index_in_parent(const TreeIter& rIter) const = 0;
virtual bool iter_has_child(const TreeIter& rIter) const = 0;
virtual void remove(const TreeIter& rIter) = 0;
virtual void select(const TreeIter& rIter) = 0;
@@ -682,8 +689,14 @@ public:
virtual void scroll_to_row(const TreeIter& rIter) = 0;
virtual bool is_selected(const TreeIter& rIter) const = 0;
virtual void selected_foreach(const std::function<void(TreeIter&)>& func) = 0;
virtual void visible_foreach(const std::function<void(TreeIter&)>& func) = 0;
virtual void move_subtree(weld::TreeIter& rNode, const weld::TreeIter* pNewParent,
int nIndexInNewParent)
= 0;
//calling func on each selected element until func returns true or we run out of elements
virtual void selected_foreach(const std::function<bool(TreeIter&)>& func) = 0;
//calling func on each visible element until func returns true or we run out of elements
virtual void visible_foreach(const std::function<bool(TreeIter&)>& func) = 0;
void connect_expanding(const Link<const TreeIter&, bool>& rLink) { m_aExpandingHdl = rLink; }
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index 0268fd3..5be7b4e 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -358,6 +358,7 @@ void RangeManagerTable::CheckForFormulaString()
m_xTreeView->set_text(rEntry, aFormulaString, 1);
maCalculatedFormulaEntries.insert( std::pair<OUString, bool>(sId, true) );
}
return false;
});
}
@@ -415,6 +416,7 @@ std::vector<ScRangeNameLine> RangeManagerTable::GetSelectedEntries()
ScRangeNameLine aLine;
GetLine(aLine, rEntry);
aSelectedEntries.push_back(aLine);
return false;
});
return aSelectedEntries;
}
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index ff1de86..3258630 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -1422,6 +1422,7 @@ IMPL_LINK_NOARG(SdPageObjsTLV, SelectHdl, weld::TreeView&, void)
m_xTreeView->selected_foreach([this](weld::TreeIter& rEntry){
if (m_xTreeView->get_id(rEntry).toInt64() == 0)
m_bLinkableSelected = false;
return false;
});
m_aChangeHdl.Call(*m_xTreeView);
@@ -1450,6 +1451,7 @@ std::vector<OUString> SdPageObjsTLV::GetSelectEntryList(const int nDepth) const
int nListDepth = m_xTreeView->get_iter_depth(rEntry);
if (nListDepth == nDepth)
aEntries.push_back(m_xTreeView->get_text(rEntry));
return false;
});
return aEntries;
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 5746d28..10d0fe9 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -477,7 +477,7 @@ public:
SwWrtShell &rShell,
SwTOXBase* pCurTOX,
bool bGlobal) = 0;
virtual VclPtr<AbstractEditRegionDlg> CreateEditRegionDlg(vcl::Window* pParent, SwWrtShell& rWrtSh) = 0;
virtual VclPtr<AbstractEditRegionDlg> CreateEditRegionDlg(weld::Window* pParent, SwWrtShell& rWrtSh) = 0;
virtual VclPtr<AbstractInsertSectionTabDialog> CreateInsertSectionTabDialog(weld::Window* pParent,
const SfxItemSet& rSet, SwWrtShell& rSh) = 0;
virtual VclPtr<AbstractMarkFloatDlg> CreateIndexMarkFloatDlg(
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 070eea5..1ac4ada 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -243,7 +243,11 @@ short AbstractMailMergeFieldConnectionsDlg_Impl::Execute()
}
IMPL_ABSTDLG_BASE(AbstractMultiTOXTabDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractEditRegionDlg_Impl);
short AbstractEditRegionDlg_Impl::Execute()
{
return m_xDlg->run();
}
short AbstractInsertSectionTabDialog_Impl::Execute()
{
@@ -670,7 +674,7 @@ const SfxItemSet* AbstractMultiTOXTabDialog_Impl::GetOutputItemSet() const
void AbstractEditRegionDlg_Impl::SelectSection(const OUString& rSectionName)
{
pDlg->SelectSection(rSectionName);
m_xDlg->SelectSection(rSectionName);
}
void
@@ -1082,10 +1086,9 @@ VclPtr<AbstractMultiTOXTabDialog> SwAbstractDialogFactory_Impl::CreateMultiTOXTa
return VclPtr<AbstractMultiTOXTabDialog_Impl>::Create( pDlg );
}
VclPtr<AbstractEditRegionDlg> SwAbstractDialogFactory_Impl::CreateEditRegionDlg(vcl::Window* pParent, SwWrtShell& rWrtSh)
VclPtr<AbstractEditRegionDlg> SwAbstractDialogFactory_Impl::CreateEditRegionDlg(weld::Window* pParent, SwWrtShell& rWrtSh)
{
VclPtr<SwEditRegionDlg> pDlg = VclPtr<SwEditRegionDlg>::Create( pParent, rWrtSh );
return VclPtr<AbstractEditRegionDlg_Impl>::Create( pDlg );
return VclPtr<AbstractEditRegionDlg_Impl>::Create(std::make_unique<SwEditRegionDlg>(pParent, rWrtSh));
}
VclPtr<AbstractInsertSectionTabDialog> SwAbstractDialogFactory_Impl::CreateInsertSectionTabDialog(weld::Window* pParent,
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index f1ce1c6..262eb39 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -523,7 +523,13 @@ class AbstractMultiTOXTabDialog_Impl : public AbstractMultiTOXTabDialog
class SwEditRegionDlg;
class AbstractEditRegionDlg_Impl : public AbstractEditRegionDlg
{
DECL_ABSTDLG_BASE(AbstractEditRegionDlg_Impl,SwEditRegionDlg)
std::shared_ptr<SwEditRegionDlg> m_xDlg;
public:
explicit AbstractEditRegionDlg_Impl(std::unique_ptr<SwEditRegionDlg> p)
: m_xDlg(std::move(p))
{
}
virtual short Execute() override;
virtual void SelectSection(const OUString& rSectionName) override;
};
@@ -698,7 +704,7 @@ public:
SwWrtShell &rShell,
SwTOXBase* pCurTOX,
bool bGlobal) override;
virtual VclPtr<AbstractEditRegionDlg> CreateEditRegionDlg(vcl::Window* pParent, SwWrtShell& rWrtSh) override;
virtual VclPtr<AbstractEditRegionDlg> CreateEditRegionDlg(weld::Window* pParent, SwWrtShell& rWrtSh) override;
virtual VclPtr<AbstractInsertSectionTabDialog> CreateInsertSectionTabDialog(
weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) override;
virtual VclPtr<AbstractMarkFloatDlg> CreateIndexMarkFloatDlg(
diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx
index 26acfcf..80960fe 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -67,65 +67,17 @@ using namespace ::com::sun::star;
namespace {
Image BuildBitmap(bool bProtect, bool bHidden)
OUString BuildBitmap(bool bProtect, bool bHidden)
{
if (bProtect)
return Image(StockImage::Yes, bHidden ? OUString(RID_BMP_PROT_HIDE) : OUString(RID_BMP_PROT_NO_HIDE));
return Image(StockImage::Yes, bHidden ? OUString(RID_BMP_HIDE) : OUString(RID_BMP_NO_HIDE));
return bHidden ? OUString(RID_BMP_PROT_HIDE) : OUString(RID_BMP_PROT_NO_HIDE);
return bHidden ? OUString(RID_BMP_HIDE) : OUString(RID_BMP_NO_HIDE);
}
}
static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox );
static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox );
static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames, const SwSectionFormat* pNewFormat )
{
if( !pNewFormat )
{
const size_t nCount = rSh.GetSectionFormatCount();
for (size_t i = 0; i<nCount; i++)
{
SectionType eTmpType;
const SwSectionFormat* pFormat = &rSh.GetSectionFormat(i);
if( !pFormat->GetParent() &&
pFormat->IsInNodesArr() &&
(eTmpType = pFormat->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType )
{
const OUString sString(pFormat->GetSection()->GetSectionName());
if(pAvailNames)
pAvailNames->InsertEntry(sString);
rSubRegions.InsertEntry(sString);
lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
}
}
}
else
{
SwSections aTmpArr;
pNewFormat->GetChildSections(aTmpArr, SectionSort::Pos);
if( !aTmpArr.empty() )
{
SectionType eTmpType;
for( const auto pSect : aTmpArr )
{
const SwSectionFormat* pFormat = pSect->GetFormat();
if( pFormat->IsInNodesArr()&&
(eTmpType = pFormat->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType )
{
const OUString sString(pFormat->GetSection()->GetSectionName());
if(pAvailNames)
pAvailNames->InsertEntry(sString);
rSubRegions.InsertEntry(sString);
lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
}
}
}
}
}
static void lcl_FillList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames, const SwSectionFormat* pNewFormat )
{
if( !pNewFormat )
@@ -173,23 +125,9 @@ static void lcl_FillList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::Co
}
}
static void lcl_FillSubRegionList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames )
{
lcl_FillList( rSh, rSubRegions, pAvailNames, nullptr );
IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
ppMark != pMarkAccess->getBookmarksEnd();
++ppMark)
{
const ::sw::mark::IMark* pBkmk = ppMark->get();
if( pBkmk->IsExpanded() )
rSubRegions.InsertEntry( pBkmk->GetName() );
}
}
static void lcl_FillSubRegionList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames )
{
rSubRegions.clear();
lcl_FillList( rSh, rSubRegions, pAvailNames, nullptr );
IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
@@ -374,102 +312,106 @@ OUString SectRepr::GetSubRegion() const
}
// dialog edit regions
SwEditRegionDlg::SwEditRegionDlg( vcl::Window* pParent, SwWrtShell& rWrtSh )
: SfxModalDialog(pParent, "EditSectionDialog",
"modules/swriter/ui/editsectiondialog.ui")
SwEditRegionDlg::SwEditRegionDlg(weld::Window* pParent, SwWrtShell& rWrtSh)
: SfxDialogController(pParent, "modules/swriter/ui/editsectiondialog.ui",
"EditSectionDialog")
, m_bSubRegionsFilled(false)
, rSh(rWrtSh)
, bDontCheckPasswd(true)
, m_xCurName(m_xBuilder->weld_entry("curname"))
, m_xTree(m_xBuilder->weld_tree_view("tree"))
, m_xFileCB(m_xBuilder->weld_check_button("link"))
, m_xDDECB(m_xBuilder->weld_check_button("dde"))
, m_xDDEFrame(m_xBuilder->weld_widget("ddedepend"))
, m_xFileNameFT(m_xBuilder->weld_label("filenameft"))
, m_xDDECommandFT(m_xBuilder->weld_label("ddeft"))
, m_xFileNameED(m_xBuilder->weld_entry("filename"))
, m_xFilePB(m_xBuilder->weld_button("file"))
, m_xSubRegionFT(m_xBuilder->weld_label("sectionft"))
, m_xSubRegionED(m_xBuilder->weld_combo_box("section"))
, m_xProtectCB(m_xBuilder->weld_check_button("protect"))
, m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
, m_xPasswdPB(m_xBuilder->weld_button("password"))
, m_xHideCB(m_xBuilder->weld_check_button("hide"))
, m_xConditionFT(m_xBuilder->weld_label("conditionft"))
, m_xConditionED(new SwConditionEdit(m_xBuilder->weld_entry("condition")))
, m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editinro"))
, m_xOK(m_xBuilder->weld_button("ok"))
, m_xOptionsPB(m_xBuilder->weld_button("options"))
, m_xDismiss(m_xBuilder->weld_button("remove"))
, m_xHideFrame(m_xBuilder->weld_widget("hideframe"))
{
get(m_pCurName, "curname");
get(m_pTree, "tree");
m_pTree->set_height_request(m_pTree->GetTextHeight() * 16);
get(m_pFileCB, "link");
m_pFileCB->SetState(TRISTATE_FALSE);
get(m_pDDECB, "dde");
get(m_pDDEFrame, "ddedepend");
get(m_pFileNameFT, "filenameft");
get(m_pDDECommandFT, "ddeft");
get(m_pFileNameED, "filename");
get(m_pFilePB, "file");
get(m_pSubRegionFT, "sectionft");
get(m_pSubRegionED, "section");
m_pSubRegionED->SetStyle(m_pSubRegionED->GetStyle() | WB_SORT);
get(m_pProtectCB, "protect");
m_pProtectCB->SetState(TRISTATE_FALSE);
get(m_pPasswdCB, "withpassword");
get(m_pPasswdPB, "password");
get(m_pHideCB, "hide");
m_pHideCB->SetState(TRISTATE_FALSE);
get(m_pConditionFT, "conditionft");
get(m_pConditionED, "condition");
m_xTree->set_size_request(-1, m_xTree->get_height_rows(16));
m_xFileCB->set_state(TRISTATE_FALSE);
m_xSubRegionED->make_sorted();
m_xProtectCB->set_state(TRISTATE_FALSE);
m_xHideCB->set_state(TRISTATE_FALSE);
// edit in readonly sections
get(m_pEditInReadonlyCB, "editinro");
m_pEditInReadonlyCB->SetState(TRISTATE_FALSE);
get(m_pOptionsPB, "options");
get(m_pDismiss, "remove");
get(m_pOK, "ok");
m_xEditInReadonlyCB->set_state(TRISTATE_FALSE);
bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr;
m_pTree->SetSelectHdl(LINK(this, SwEditRegionDlg, GetFirstEntryHdl));
m_pTree->SetDeselectHdl(LINK(this, SwEditRegionDlg, DeselectHdl));
m_pCurName->SetModifyHdl(LINK(this, SwEditRegionDlg, NameEditHdl));
m_pConditionED->SetModifyHdl( LINK( this, SwEditRegionDlg, ConditionEditHdl));
m_pOK->SetClickHdl ( LINK( this, SwEditRegionDlg, OkHdl));
m_pPasswdCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
m_pPasswdPB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
m_pHideCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangeHideHdl));
m_xTree->connect_changed(LINK(this, SwEditRegionDlg, GetFirstEntryHdl));
m_xCurName->connect_changed(LINK(this, SwEditRegionDlg, NameEditHdl));
m_xConditionED->connect_changed( LINK( this, SwEditRegionDlg, ConditionEditHdl));
m_xOK->connect_clicked( LINK( this, SwEditRegionDlg, OkHdl));
m_xPasswdCB->connect_toggled(LINK(this, SwEditRegionDlg, TogglePasswdHdl));
m_xPasswdPB->connect_clicked(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
m_xHideCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeHideHdl));
// edit in readonly sections
m_pEditInReadonlyCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangeEditInReadonlyHdl));
m_xEditInReadonlyCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeEditInReadonlyHdl));
m_pOptionsPB->SetClickHdl(LINK(this, SwEditRegionDlg, OptionsHdl));
m_pProtectCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangeProtectHdl));
m_pDismiss->SetClickHdl ( LINK( this, SwEditRegionDlg, ChangeDismissHdl));
m_pFileCB->SetClickHdl(LINK(this, SwEditRegionDlg, UseFileHdl));
m_pFilePB->SetClickHdl(LINK(this, SwEditRegionDlg, FileSearchHdl));
m_pFileNameED->SetModifyHdl(LINK(this, SwEditRegionDlg, FileNameHdl));
m_pSubRegionED->SetModifyHdl(LINK(this, SwEditRegionDlg, FileNameHdl));
m_pSubRegionED->AddEventListener(LINK(this, SwEditRegionDlg, SubRegionEventHdl));
m_pSubRegionED->EnableAutocomplete(true, true);
m_xOptionsPB->connect_clicked(LINK(this, SwEditRegionDlg, OptionsHdl));
m_xProtectCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeProtectHdl));
m_xDismiss->connect_clicked( LINK( this, SwEditRegionDlg, ChangeDismissHdl));
m_xFileCB->connect_toggled(LINK(this, SwEditRegionDlg, UseFileHdl));
m_xFilePB->connect_clicked(LINK(this, SwEditRegionDlg, FileSearchHdl));
m_xFileNameED->connect_changed(LINK(this, SwEditRegionDlg, FileNameEntryHdl));
m_xSubRegionED->connect_changed(LINK(this, SwEditRegionDlg, FileNameComboBoxHdl));
m_xSubRegionED->connect_popup_toggled(LINK(this, SwEditRegionDlg, SubRegionEventHdl));
m_xSubRegionED->set_entry_completion(true, true);
m_pTree->SetSelectionMode( SelectionMode::Multiple );
m_pTree->SetStyle(m_pTree->GetStyle()|WB_HASBUTTONSATROOT|WB_CLIPCHILDREN|WB_HSCROLL);
m_pTree->SetSpaceBetweenEntries(0);
m_pTree->SetAllEntriesAccessibleRoleType(SvTreeAccRoleType::TREE);
m_xTree->set_selection_mode(SelectionMode::Multiple);
if(bWeb)
if (bWeb)
{
m_pDDECB->Hide();
get<VclContainer>("hideframe")->Hide();
m_pPasswdCB->Hide();
m_xDDECB->hide();
m_xHideFrame->hide();
m_xPasswdCB->hide();
}
m_pDDECB->SetClickHdl(LINK(this, SwEditRegionDlg, DDEHdl));
m_xDDECB->connect_toggled(LINK(this, SwEditRegionDlg, DDEHdl));
pCurrSect = rSh.GetCurrSection();
RecurseList( nullptr, nullptr );
// if the cursor is not in a region
// the first one will always be selected
if( !m_pTree->FirstSelected() && m_pTree->First() )
m_pTree->Select( m_pTree->First() );
m_pTree->Show();
// if the cursor is not in a region the first one will always be selected
if (!m_xTree->get_selected(nullptr))
{
std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
if (m_xTree->get_iter_first(*xIter))
{
m_xTree->select(*xIter);
GetFirstEntryHdl(*m_xTree);
}
}
m_xTree->show();
bDontCheckPasswd = false;
}
bool SwEditRegionDlg::CheckPasswd(CheckBox* pBox)
bool SwEditRegionDlg::CheckPasswd(weld::ToggleButton* pBox)
{
if(bDontCheckPasswd)
if (bDontCheckPasswd)
return true;
bool bRet = true;
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
while( pEntry )
{
SectRepr* pRepr = static_cast<SectRepr*>(pEntry->GetUserData());
m_xTree->selected_foreach([this, &bRet](weld::TreeIter& rEntry){
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
if (!pRepr->GetTempPasswd().getLength()
&& pRepr->GetSectionData().GetPassword().getLength())
{
SfxPasswordDialog aPasswdDlg(GetFrameWeld());
SfxPasswordDialog aPasswdDlg(m_xDialog.get());
bRet = false;
if (aPasswdDlg.run())
{
@@ -484,31 +426,29 @@ bool SwEditRegionDlg::CheckPasswd(CheckBox* pBox)
}
else
{
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Info, VclButtonsType::Ok,
SwResId(STR_WRONG_PASSWORD)));
xInfoBox->run();
}
}
}
pEntry = m_pTree->NextSelected(pEntry);
}
if(!bRet && pBox)
return false;
});
if (!bRet && pBox)
{
//reset old button state
if(pBox->IsTriStateEnabled())
pBox->SetState(pBox->IsChecked() ? TRISTATE_FALSE : TRISTATE_INDET);
else
pBox->Check(!pBox->IsChecked());
if (pBox->get_state() != TRISTATE_INDET)
pBox->set_active(!pBox->get_active());
}
return bRet;
}
// recursively look for child-sections
void SwEditRegionDlg::RecurseList(const SwSectionFormat* pFormat, SvTreeListEntry* pEntry)
void SwEditRegionDlg::RecurseList(const SwSectionFormat* pFormat, weld::TreeIter* pEntry)
{
SvTreeListEntry* pSelEntry = nullptr;
std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
if (!pFormat)
{
const size_t nCount=rSh.GetSectionFormatCount();
@@ -522,21 +462,27 @@ void SwEditRegionDlg::RecurseList(const SwSectionFormat* pFormat, SvTreeListEntr
{
SwSection *pSect = pFormat->GetSection();
SectRepr* pSectRepr = new SectRepr( n, *pSect );
Image aImg = BuildBitmap( pSect->IsProtect(),pSect->IsHidden());
SvTreeListEntry* pNewEntry = m_pTree->InsertEntry(pSect->GetSectionName(), aImg, aImg);
pNewEntry->SetUserData(pSectRepr);
RecurseList( pFormat, pNewEntry );
if (pNewEntry->HasChildren())
m_pTree->Expand(pNewEntry);
OUString sText(pSect->GetSectionName());
OUString sImage(BuildBitmap(pSect->IsProtect(),pSect->IsHidden()));
OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
m_xTree->insert(nullptr, -1, &sText, &sId, nullptr, nullptr, &sImage, false, xIter.get());
RecurseList(pFormat, xIter.get());
if (m_xTree->iter_has_child(*xIter))
m_xTree->expand_row(*xIter);
if (pCurrSect==pSect)
m_pTree->Select(pNewEntry);
{
m_xTree->select(*xIter);
m_xTree->scroll_to_row(*xIter);
GetFirstEntryHdl(*m_xTree);
}
}
}
}
else
{
SwSections aTmpArr;
SvTreeListEntry* pNEntry;
pFormat->GetChildSections(aTmpArr, SectionSort::Pos);
for( const auto pSect : aTmpArr )
{
@@ -548,24 +494,24 @@ void SwEditRegionDlg::RecurseList(const SwSectionFormat* pFormat, SvTreeListEntr
{
SectRepr* pSectRepr=new SectRepr(
FindArrPos( pSect->GetFormat() ), *pSect );
Image aImage = BuildBitmap( pSect->IsProtect(),
pSect->IsHidden());
pNEntry = m_pTree->InsertEntry(
pSect->GetSectionName(), aImage, aImage, pEntry);
pNEntry->SetUserData(pSectRepr);
RecurseList( pSect->GetFormat(), pNEntry );
if( pNEntry->HasChildren())
m_pTree->Expand(pNEntry);
OUString sText(pSect->GetSectionName());
OUString sImage = BuildBitmap(pSect->IsProtect(), pSect->IsHidden());
OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
m_xTree->insert(pEntry, -1, &sText, &sId, nullptr, nullptr, &sImage, false, xIter.get());
RecurseList(pSect->GetFormat(), xIter.get());
if (m_xTree->iter_has_child(*xIter))
m_xTree->expand_row(*xIter);
if (pCurrSect==pSect)
pSelEntry = pNEntry;
{
m_xTree->select(*xIter);
m_xTree->scroll_to_row(*xIter);
GetFirstEntryHdl(*m_xTree);
}
}
}
}
if(nullptr != pSelEntry)
{
m_pTree->MakeVisible(pSelEntry);
m_pTree->Select(pSelEntry);
}
}
size_t SwEditRegionDlg::FindArrPos(const SwSectionFormat* pFormat )
@@ -581,82 +527,57 @@ size_t SwEditRegionDlg::FindArrPos(const SwSectionFormat* pFormat )
SwEditRegionDlg::~SwEditRegionDlg( )
{
disposeOnce();
std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
if (m_xTree->get_iter_first(*xIter))
{
do
{
delete reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
} while (m_xTree->iter_next(*xIter));
}
}
void SwEditRegionDlg::dispose()
void SwEditRegionDlg::SelectSection(const OUString& rSectionName)
{
SvTreeListEntry* pEntry = m_pTree->First();
while( pEntry )
std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
if (m_xTree->get_iter_first(*xIter))
{
delete static_cast<SectRepr*>(pEntry->GetUserData());
pEntry = m_pTree->Next( pEntry );
}
m_pDocInserter.reset();
m_pCurName.clear();
m_pTree.clear();
m_pFileCB.clear();
m_pDDECB.clear();
m_pDDEFrame.clear();
m_pFileNameFT.clear();
m_pDDECommandFT.clear();
m_pFileNameED.clear();
m_pFilePB.clear();
m_pSubRegionFT.clear();
m_pSubRegionED.clear();
m_pProtectCB.clear();
m_pPasswdCB.clear();
m_pPasswdPB.clear();
m_pHideCB.clear();
m_pConditionFT.clear();
m_pConditionED.clear();
m_pEditInReadonlyCB.clear();
m_pOK.clear();
m_pOptionsPB.clear();
m_pDismiss.clear();
SfxModalDialog::dispose();
}
void SwEditRegionDlg::SelectSection(const OUString& rSectionName)
{
SvTreeListEntry* pEntry = m_pTree->First();
while(pEntry)
{
SectRepr* pRepr = static_cast<SectRepr*>(pEntry->GetUserData());
if (pRepr->GetSectionData().GetSectionName() == rSectionName)
break;
pEntry = m_pTree->Next(pEntry);
}
if(pEntry)
{
m_pTree->SelectAll(false);
m_pTree->Select(pEntry);
m_pTree->MakeVisible(pEntry);
do
{
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
if (pRepr->GetSectionData().GetSectionName() == rSectionName)
{
m_xTree->unselect_all();
m_xTree->select(*xIter);
m_xTree->scroll_to_row(*xIter);
GetFirstEntryHdl(*m_xTree);
break;
}
} while (m_xTree->iter_next(*xIter));
}
}
// selected entry in TreeListBox is showed in Edit window in case of
// multiselection some controls are disabled
IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox, void )
IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView&, rBox, void)
{
bDontCheckPasswd = true;
SvTreeListEntry* pEntry=pBox->FirstSelected();
m_pHideCB->Enable();
std::unique_ptr<weld::TreeIter> xIter(rBox.make_iterator());
bool bEntry = rBox.get_selected(xIter.get());
m_xHideCB->set_sensitive(true);
// edit in readonly sections
m_pEditInReadonlyCB->Enable();
m_xEditInReadonlyCB->set_sensitive(true);
m_pProtectCB->Enable();
m_pFileCB->Enable();
m_xProtectCB->set_sensitive(true);
m_xFileCB->set_sensitive(true);
css::uno::Sequence <sal_Int8> aCurPasswd;
if( 1 < pBox->GetSelectionCount() )
if (1 < rBox.count_selected_rows())
{
m_pHideCB->EnableTriState();
m_pProtectCB->EnableTriState();
m_xHideCB->set_state(TRISTATE_INDET);
m_xProtectCB->set_state(TRISTATE_INDET);
// edit in readonly sections
m_pEditInReadonlyCB->EnableTriState();
m_pFileCB->EnableTriState();
m_xEditInReadonlyCB->set_state(TRISTATE_INDET);
m_xFileCB->set_state(TRISTATE_INDET);
bool bHiddenValid = true;
bool bProtectValid = true;
@@ -673,9 +594,8 @@ IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox, void )
bool bFile = true;
bool bPasswdValid = true;
while( pEntry )
{
SectRepr* pRepr=static_cast<SectRepr*>(pEntry->GetUserData());
m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
SwSectionData const& rData( pRepr->GetSectionData() );
if(bFirst)
{
@@ -702,127 +622,130 @@ IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox, void )
(rData.GetType() != CONTENT_SECTION));
bPasswdValid = (aCurPasswd == rData.GetPassword());
}
pEntry = pBox->NextSelected(pEntry);
bFirst = false;
}
return false;
});
m_pHideCB->SetState(!bHiddenValid ? TRISTATE_INDET :
m_xHideCB->set_state(!bHiddenValid ? TRISTATE_INDET :
bHidden ? TRISTATE_TRUE : TRISTATE_FALSE);
m_pProtectCB->SetState(!bProtectValid ? TRISTATE_INDET :
m_xProtectCB->set_state(!bProtectValid ? TRISTATE_INDET :
bProtect ? TRISTATE_TRUE : TRISTATE_FALSE);
// edit in readonly sections
m_pEditInReadonlyCB->SetState(!bEditInReadonlyValid ? TRISTATE_INDET :
m_xEditInReadonlyCB->set_state(!bEditInReadonlyValid ? TRISTATE_INDET :
bEditInReadonly ? TRISTATE_TRUE : TRISTATE_FALSE);
m_pFileCB->SetState(!bFileValid ? TRISTATE_INDET :
m_xFileCB->set_state(!bFileValid ? TRISTATE_INDET :
bFile ? TRISTATE_TRUE : TRISTATE_FALSE);
if (bConditionValid)
m_pConditionED->SetText(sCondition);
m_xConditionED->set_text(sCondition);
else
{
m_pConditionFT->Enable(false);
m_pConditionED->Enable(false);
m_xConditionFT->set_sensitive(false);
m_xConditionED->set_sensitive(false);
}
m_pCurName->Enable(false);
m_pDDECB->Enable(false);
m_pDDEFrame->Enable(false);
m_pOptionsPB->Enable(false);
bool bPasswdEnabled = m_pProtectCB->GetState() == TRISTATE_TRUE;
m_pPasswdCB->Enable(bPasswdEnabled);
m_pPasswdPB->Enable(bPasswdEnabled);
m_xCurName->set_sensitive(false);
m_xDDECB->set_sensitive(false);
m_xDDEFrame->set_sensitive(false);
m_xOptionsPB->set_sensitive(false);
bool bPasswdEnabled = m_xProtectCB->get_state() == TRISTATE_TRUE;
m_xPasswdCB->set_sensitive(bPasswdEnabled);
m_xPasswdPB->set_sensitive(bPasswdEnabled);
if(!bPasswdValid)
{
pEntry = pBox->FirstSelected();
pBox->SelectAll( false );
pBox->Select( pEntry );
GetFirstEntryHdl(pBox);
rBox.get_selected(xIter.get());
rBox.unselect_all();
rBox.select(*xIter);
GetFirstEntryHdl(rBox);
return;
}
else
m_pPasswdCB->Check(aCurPasswd.getLength() > 0);
m_xPasswdCB->set_active(aCurPasswd.getLength() > 0);
}
else if (pEntry )
else if (bEntry )
{
m_pCurName->Enable();
m_pOptionsPB->Enable();
SectRepr* pRepr=static_cast<SectRepr*>(pEntry->GetUserData());
m_xCurName->set_sensitive(true);
m_xOptionsPB->set_sensitive(true);
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
SwSectionData const& rData( pRepr->GetSectionData() );
m_pConditionED->SetText(rData.GetCondition());
m_pHideCB->Enable();
m_pHideCB->SetState((rData.IsHidden()) ? TRISTATE_TRUE : TRISTATE_FALSE);
bool bHide = TRISTATE_TRUE == m_pHideCB->GetState();
m_pConditionED->Enable(bHide);
m_pConditionFT->Enable(bHide);
m_pPasswdCB->Check(rData.GetPassword().getLength() > 0);
m_xConditionED->set_text(rData.GetCondition());
m_xHideCB->set_sensitive(true);
m_xHideCB->set_state((rData.IsHidden()) ? TRISTATE_TRUE : TRISTATE_FALSE);
bool bHide = TRISTATE_TRUE == m_xHideCB->get_state();
m_xConditionED->set_sensitive(bHide);
m_xConditionFT->set_sensitive(bHide);
m_xPasswdCB->set_active(rData.GetPassword().getLength() > 0);
m_pOK->Enable();
m_pPasswdCB->Enable();
m_pCurName->SetText(pBox->GetEntryText(pEntry));
m_pCurName->Enable();
m_pDismiss->Enable();
m_xOK->set_sensitive(true);
m_xPasswdCB->set_sensitive(true);
m_xCurName->set_text(rBox.get_text(*xIter));
m_xCurName->set_sensitive(true);
m_xDismiss->set_sensitive(true);
const OUString aFile = pRepr->GetFile();
const OUString sSub = pRepr->GetSubRegion();
m_xSubRegionED->clear();
m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
m_bSubRegionsFilled = false;
m_pSubRegionED->Clear();
if( !aFile.isEmpty() || !sSub.isEmpty() )
{
m_pFileCB->Check();
m_pFileNameED->SetText(aFile);
m_pSubRegionED->SetText(sSub);
m_pDDECB->Check(rData.GetType() == DDE_LINK_SECTION);
m_xFileCB->set_active(true);
m_xFileNameED->set_text(aFile);
m_xSubRegionED->set_entry_text(sSub);
m_xDDECB->set_active(rData.GetType() == DDE_LINK_SECTION);
}
else
{
m_pFileCB->Check(false);
m_pFileNameED->SetText(aFile);
m_pDDECB->Enable(false);
m_pDDECB->Check(false);
m_xFileCB->set_active(false);
m_xFileNameED->set_text(aFile);
m_xDDECB->set_sensitive(false);
m_xDDECB->set_active(false);
}
UseFileHdl(m_pFileCB);
DDEHdl(m_pDDECB);
m_pProtectCB->SetState((rData.IsProtectFlag())
UseFileHdl(*m_xFileCB);
DDEHdl(*m_xDDECB);
m_xProtectCB->set_state((rData.IsProtectFlag())
? TRISTATE_TRUE : TRISTATE_FALSE);
m_pProtectCB->Enable();
m_xProtectCB->set_sensitive(true);
// edit in readonly sections
m_pEditInReadonlyCB->SetState((rData.IsEditInReadonlyFlag())
m_xEditInReadonlyCB->set_state((rData.IsEditInReadonlyFlag())
? TRISTATE_TRUE : TRISTATE_FALSE);
m_pEditInReadonlyCB->Enable();
m_xEditInReadonlyCB->set_sensitive(true);
bool bPasswdEnabled = m_pProtectCB->IsChecked();
m_pPasswdCB->Enable(bPasswdEnabled);
m_pPasswdPB->Enable(bPasswdEnabled);
bool bPasswdEnabled = m_xProtectCB->get_active();
m_xPasswdCB->set_sensitive(bPasswdEnabled);
m_xPasswdPB->set_sensitive(bPasswdEnabled);
}
bDontCheckPasswd = false;
}
#if 0
IMPL_LINK( SwEditRegionDlg, DeselectHdl, SvTreeListBox *, pBox, void )
{
if( pBox->GetSelectionCount() )
return;
m_pHideCB->Enable(false);
m_pProtectCB->Enable(false);
m_xHideCB->set_sensitive(false);
m_xProtectCB->set_sensitive(false);
// edit in readonly sections
m_pEditInReadonlyCB->Enable(false);
m_xEditInReadonlyCB->set_sensitive(false);
m_pPasswdCB->Enable(false);
m_pConditionFT->Enable(false);
m_pConditionED->Enable(false);
m_pFileCB->Enable(false);
m_pDDEFrame->Enable(false);
m_pDDECB->Enable(false);
m_pCurName->Enable(false);
m_xPasswdCB->set_sensitive(false);
m_xConditionFT->set_sensitive(false);
m_xConditionED->set_sensitive(false);
m_xFileCB->set_sensitive(false);
m_xDDEFrame->set_sensitive(false);
m_xDDECB->set_sensitive(false);
m_xCurName->set_sensitive(false);
UseFileHdl(m_pFileCB);
DDEHdl(m_pDDECB);
UseFileHdl(*m_xFileCB);
DDEHdl(m_xDDECB);
}
#endif
// in OkHdl the modified settings are being applied and reversed regions are deleted
IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, Button*, void)
IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, weld::Button&, void)
{
// temp. Array because during changing of a region the position
// inside of the "Core-Arrays" can be shifted:
@@ -837,46 +760,48 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, Button*, void)
rSh.StartAllAction();
rSh.StartUndo();
rSh.ResetSelect( nullptr,false );
SvTreeListEntry* pEntry = m_pTree->First();
while( pEntry )
std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
if (m_xTree->get_iter_first(*xIter))
{
SectRepr* pRepr = static_cast<SectRepr*>(pEntry->GetUserData());
SwSectionFormat* pFormat = aOrigArray[ pRepr->GetArrPos() ];
if (!pRepr->GetSectionData().IsProtectFlag())
do
{
pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
}
size_t nNewPos = rDocFormats.GetPos(pFormat);
if ( SIZE_MAX != nNewPos )
{
std::unique_ptr<SfxItemSet> pSet(pFormat->GetAttrSet().Clone( false ));
if( pFormat->GetCol() != pRepr->GetCol() )
pSet->Put( pRepr->GetCol() );
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
SwSectionFormat* pFormat = aOrigArray[ pRepr->GetArrPos() ];
if (!pRepr->GetSectionData().IsProtectFlag())
{
pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
}
size_t nNewPos = rDocFormats.GetPos(pFormat);
if ( SIZE_MAX != nNewPos )
{
std::unique_ptr<SfxItemSet> pSet(pFormat->GetAttrSet().Clone( false ));
if( pFormat->GetCol() != pRepr->GetCol() )
pSet->Put( pRepr->GetCol() );
SvxBrushItem aBrush(pFormat->makeBackgroundBrushItem(false));
if( aBrush != pRepr->GetBackground() )
pSet->Put( pRepr->GetBackground() );
SvxBrushItem aBrush(pFormat->makeBackgroundBrushItem(false));
if( aBrush != pRepr->GetBackground() )
pSet->Put( pRepr->GetBackground() );
if( pFormat->GetFootnoteAtTextEnd(false) != pRepr->GetFootnoteNtAtEnd() )
pSet->Put( pRepr->GetFootnoteNtAtEnd() );
if( pFormat->GetFootnoteAtTextEnd(false) != pRepr->GetFootnoteNtAtEnd() )
pSet->Put( pRepr->GetFootnoteNtAtEnd() );
if( pFormat->GetEndAtTextEnd(false) != pRepr->GetEndNtAtEnd() )
pSet->Put( pRepr->GetEndNtAtEnd() );
if( pFormat->GetEndAtTextEnd(false) != pRepr->GetEndNtAtEnd() )
pSet->Put( pRepr->GetEndNtAtEnd() );
if( pFormat->GetBalancedColumns() != pRepr->GetBalance() )
pSet->Put( pRepr->GetBalance() );
if( pFormat->GetBalancedColumns() != pRepr->GetBalance() )
pSet->Put( pRepr->GetBalance() );
if( pFormat->GetFrameDir() != pRepr->GetFrameDir() )
pSet->Put( pRepr->GetFrameDir() );
if( pFormat->GetFrameDir() != pRepr->GetFrameDir() )
pSet->Put( pRepr->GetFrameDir() );
if( pFormat->GetLRSpace() != pRepr->GetLRSpace())
pSet->Put( pRepr->GetLRSpace());
if( pFormat->GetLRSpace() != pRepr->GetLRSpace())
pSet->Put( pRepr->GetLRSpace());
rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
pSet->Count() ? pSet.get() : nullptr );
}
pEntry = m_pTree->Next( pEntry );
rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
pSet->Count() ? pSet.get() : nullptr );
}
} while (m_xTree->iter_next(*xIter));
}
for (SectReprs_t::reverse_iterator it = m_SectReprs.rbegin(), aEnd = m_SectReprs.rend(); it != aEnd; ++it)
@@ -890,172 +815,154 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, Button*, void)
aOrigArray.clear();
// EndDialog must be called ahead of EndAction's end,
// response must be called ahead of EndAction's end,
// otherwise ScrollError can occur.
EndDialog(RET_OK);
m_xDialog->response(RET_OK);
rSh.EndUndo();
rSh.EndAllAction();
}
// Toggle protect
IMPL_LINK( SwEditRegionDlg, ChangeProtectHdl, Button *, pButton, void )
IMPL_LINK(SwEditRegionDlg, ChangeProtectHdl, weld::ToggleButton&, rButton, void)
{
TriStateBox* pBox = static_cast<TriStateBox*>(pButton);
if(!CheckPasswd(pBox))
if (!CheckPasswd(&rButton))
return;
pBox->EnableTriState(false);
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
OSL_ENSURE(pEntry,"no entry found");
bool bCheck = TRISTATE_TRUE == pBox->GetState();
while( pEntry )
{
SectRepr* pRepr = static_cast<SectRepr*>(pEntry->GetUserData());
bool bCheck = TRISTATE_TRUE == rButton.get_state();
m_xTree->selected_foreach([this, bCheck](weld::TreeIter& rEntry){
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
pRepr->GetSectionData().SetProtectFlag(bCheck);
Image aImage = BuildBitmap(bCheck,
TRISTATE_TRUE == m_pHideCB->GetState());
m_pTree->SetExpandedEntryBmp( pEntry, aImage );
m_pTree->SetCollapsedEntryBmp( pEntry, aImage );
pEntry = m_pTree->NextSelected(pEntry);
}
m_pPasswdCB->Enable(bCheck);
m_pPasswdPB->Enable(bCheck);
OUString aImage = BuildBitmap(bCheck, TRISTATE_TRUE == m_xHideCB->get_state());
m_xTree->set_image(rEntry, aImage);
return false;
});
m_xPasswdCB->set_sensitive(bCheck);
m_xPasswdPB->set_sensitive(bCheck);
}
// Toggle hide
IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, Button *, pButton, void )
IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, weld::ToggleButton&, rButton, void)
{
TriStateBox* pBox = static_cast<TriStateBox*>(pButton);
if(!CheckPasswd(pBox))
if (!CheckPasswd(&rButton))
return;
pBox->EnableTriState(false);
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
OSL_ENSURE(pEntry,"no entry found");
while( pEntry )
{
SectRepr* pRepr = static_cast<SectRepr*>(pEntry->GetUserData());
pRepr->GetSectionData().SetHidden(TRISTATE_TRUE == pBox->GetState());
Image aImage = BuildBitmap(TRISTATE_TRUE == m_pProtectCB->GetState(),
TRISTATE_TRUE == pBox->GetState());
m_pTree->SetExpandedEntryBmp( pEntry, aImage );
m_pTree->SetCollapsedEntryBmp( pEntry, aImage );
pEntry = m_pTree->NextSelected(pEntry);
}
bool bHide = TRISTATE_TRUE == pBox->GetState();
m_pConditionED->Enable(bHide);
m_pConditionFT->Enable(bHide);
m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
pRepr->GetSectionData().SetHidden(TRISTATE_TRUE == rButton.get_state());
OUString aImage = BuildBitmap(TRISTATE_TRUE == m_xProtectCB->get_state(),
TRISTATE_TRUE == rButton.get_state());
m_xTree->set_image(rEntry, aImage);
return false;
});
bool bHide = TRISTATE_TRUE == rButton.get_state();
m_xConditionED->set_sensitive(bHide);
m_xConditionFT->set_sensitive(bHide);
}
// Toggle edit in readonly
IMPL_LINK( SwEditRegionDlg, ChangeEditInReadonlyHdl, Button *, pButton, void )
IMPL_LINK(SwEditRegionDlg, ChangeEditInReadonlyHdl, weld::ToggleButton&, rButton, void)
{
TriStateBox* pBox = static_cast<TriStateBox*>(pButton);
if(!CheckPasswd(pBox))
if (!CheckPasswd(&rButton))
return;
pBox->EnableTriState(false);
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
OSL_ENSURE(pEntry,"no entry found");
while( pEntry )
{
SectRepr* pRepr = static_cast<SectRepr*>(pEntry->GetUserData());
m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
pRepr->GetSectionData().SetEditInReadonlyFlag(
TRISTATE_TRUE == pBox->GetState());
pEntry = m_pTree->NextSelected(pEntry);
}
TRISTATE_TRUE == rButton.get_state());
return false;
});
}
// clear selected region
IMPL_LINK_NOARG(SwEditRegionDlg, ChangeDismissHdl, Button*, void)
IMPL_LINK_NOARG(SwEditRegionDlg, ChangeDismissHdl, weld::Button&, void)
{
if(!CheckPasswd())
return;
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
SvTreeListEntry* pChild;
SvTreeListEntry* pParent;
// at first mark all selected
while(pEntry)
{
SectRepr* const pSectRepr = static_cast<SectRepr*>(pEntry->GetUserData());
m_xTree->selected_foreach([this](weld::TreeIter& rEntry){
SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
pSectRepr->SetSelected();
pEntry = m_pTree->NextSelected(pEntry);
}
pEntry = m_pTree->FirstSelected();
return false;
});
std::unique_ptr<weld::TreeIter> xEntry(m_xTree->make_iterator());
bool bEntry(m_xTree->get_selected(xEntry.get()));
// then delete
while(pEntry)
while (bEntry)
{
SectRepr* const pSectRepr = static_cast<SectRepr*>(pEntry->GetUserData());
SvTreeListEntry* pRemove = nullptr;
SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xEntry).toInt64());
std::unique_ptr<weld::TreeIter> xRemove;
bool bRestart = false;
if(pSectRepr->IsSelected())
if (pSectRepr->IsSelected())
{
m_SectReprs.insert(std::make_pair(pSectRepr->GetArrPos(),
std::unique_ptr<SectRepr>(pSectRepr)));
while( (pChild = m_pTree->FirstChild(pEntry) )!= nullptr )
if (m_xTree->iter_has_child(*xEntry))
{
// because of the repositioning we have to start at the beginning again
bRestart = true;
pParent = m_pTree->GetParent(pEntry);
m_pTree->GetModel()->Move(pChild, pParent, SvTreeList::GetRelPos(pEntry));
std::unique_ptr<weld::TreeIter> xChild(m_xTree->make_iterator(xEntry.get()));
m_xTree->iter_children(*xChild);
std::unique_ptr<weld::TreeIter> xParent(m_xTree->make_iterator(xEntry.get()));
if (!m_xTree->iter_parent(*xParent))
xParent.reset();
bool bChild = true;
do
{
// because of the repositioning we have to start at the beginning again
bRestart = true;
std::unique_ptr<weld::TreeIter> xMove(m_xTree->make_iterator(xChild.get()));
bChild = m_xTree->iter_next_sibling(*xChild);
m_xTree->move_subtree(*xMove, xParent.get(), m_xTree->get_iter_index_in_parent(*xEntry));
} while (bChild);
}
pRemove = pEntry;
xRemove = m_xTree->make_iterator(xEntry.get());
}
if(bRestart)
pEntry = m_pTree->First();
if (bRestart)
bEntry = m_xTree->get_iter_first(*xEntry);
else
pEntry = m_pTree->Next(pEntry);
if(pRemove)
m_pTree->GetModel()->Remove( pRemove );
bEntry = m_xTree->iter_next(*xEntry);
if (xRemove)
m_xTree->remove(*xRemove);
}
if ( m_pTree->FirstSelected() )
if (m_xTree->get_selected(nullptr))
return;
m_pConditionFT->Enable(false);
m_pConditionED->Enable(false);
m_pDismiss-> Enable(false);
m_pCurName->Enable(false);
m_pProtectCB->Enable(false);
m_pPasswdCB->Enable(false);
m_pHideCB->Enable(false);
m_xConditionFT->set_sensitive(false);
m_xConditionED->set_sensitive(false);
m_xDismiss->set_sensitive(false);
m_xCurName->set_sensitive(false);
m_xProtectCB->set_sensitive(false);
m_xPasswdCB->set_sensitive(false);
m_xHideCB->set_sensitive(false);
// edit in readonly sections
m_pEditInReadonlyCB->Enable(false);
m_pEditInReadonlyCB->SetState(TRISTATE_FALSE);
m_pProtectCB->SetState(TRISTATE_FALSE);
m_pPasswdCB->Check(false);
m_pHideCB->SetState(TRISTATE_FALSE);
m_pFileCB->Check(false);
m_xEditInReadonlyCB->set_sensitive(false);
m_xEditInReadonlyCB->set_state(TRISTATE_FALSE);
m_xProtectCB->set_state(TRISTATE_FALSE);
m_xPasswdCB->set_active(false);
m_xHideCB->set_state(TRISTATE_FALSE);
m_xFileCB->set_active(false);
// otherwise the focus would be on HelpButton
m_pOK->GrabFocus();
UseFileHdl(m_pFileCB);
m_xOK->grab_focus();
UseFileHdl(*m_xFileCB);
}
// link CheckBox to file?
IMPL_LINK( SwEditRegionDlg, UseFileHdl, Button *, pButton, void )
IMPL_LINK(SwEditRegionDlg, UseFileHdl, weld::ToggleButton&, rButton, void)
{
CheckBox* pBox = static_cast<CheckBox*>(pButton);
if(!CheckPasswd(pBox))
if (!CheckPasswd(&rButton))
return;
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
pBox->EnableTriState(false);
bool bMulti = 1 < m_pTree->GetSelectionCount();
bool bFile = pBox->IsChecked();
if(pEntry)
bool bMulti = 1 < m_xTree->count_selected_rows();
bool bFile = rButton.get_active();
if (m_xTree->get_selected(nullptr))
{
while(pEntry)
{
SectRepr* const pSectRepr = static_cast<SectRepr*>(pEntry->GetUserData());
m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
bool bContent = pSectRepr->IsContent();
if( pBox->IsChecked() && bContent && rSh.HasSelection() )
if( rButton.get_active() && bContent && rSh.HasSelection() )
{
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Question, VclButtonsType::YesNo,
SwResId(STR_QUERY_CONNECT)));
if (RET_NO == xQueryBox->run())
pBox->Check( false );
rButton.set_active( false );
}
if( bFile )
pSectRepr->SetContent(false);
@@ -1065,53 +972,51 @@ IMPL_LINK( SwEditRegionDlg, UseFileHdl, Button *, pButton, void )
pSectRepr->SetSubRegion(OUString());
pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
}
pEntry = m_pTree->NextSelected(pEntry);
}
m_pDDECB->Enable(bFile && ! bMulti);
m_pDDEFrame->Enable(bFile && ! bMulti);
return false;
});
m_xDDECB->set_sensitive(bFile && !bMulti);
m_xDDEFrame->set_sensitive(bFile && !bMulti);
if( bFile )
{
m_pProtectCB->SetState(TRISTATE_TRUE);
m_pFileNameED->GrabFocus();
m_xProtectCB->set_state(TRISTATE_TRUE);
ChangeProtectHdl(*m_xProtectCB);
m_xFileNameED->grab_focus();
}
else
{
m_pDDECB->Check(false);
DDEHdl(m_pDDECB);
m_pSubRegionED->SetText(OUString());
m_xDDECB->set_active(false);
m_xSubRegionED->set_entry_text(OUString());
}
DDEHdl(*m_xDDECB);
}
else
{
pBox->Check(false);
pBox->Enable(false);
m_pDDECB->Check(false);
m_pDDECB->Enable(false);
m_pDDEFrame->Enable(false);
rButton.set_active(false);
rButton.set_sensitive(false);
m_xDDECB->set_active(false);
m_xDDECB->set_sensitive(false);
m_xDDEFrame->set_sensitive(false);
}
}
// call dialog paste file
IMPL_LINK_NOARG(SwEditRegionDlg, FileSearchHdl, Button*, void)
IMPL_LINK_NOARG(SwEditRegionDlg, FileSearchHdl, weld::Button&, void)
{
if(!CheckPasswd())
return;
m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetFrameWeld(), "swriter"));
m_pDocInserter.reset(new ::sfx2::DocumentInserter(m_xDialog.get(), "swriter"));
m_pDocInserter->StartExecuteModal( LINK( this, SwEditRegionDlg, DlgClosedHdl ) );
}
IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl, Button*, void)
IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl, weld::Button&, void)
{
if(!CheckPasswd())
return;
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
if(!pEntry)
SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
if (!pSectRepr)
return;
SectRepr* pSectRepr = static_cast<SectRepr*>(pEntry->GetUserData());
SfxItemSet aSet(
rSh.GetView().GetPool(),
svl::Items<
@@ -1143,7 +1048,7 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl, Button*, void)
aSet.Put(SwFormatFrameSize(ATT_VAR_SIZE, nWidth));
aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
SwSectionPropertyTabDialog aTabDlg(GetFrameWeld(), aSet, rSh);
SwSectionPropertyTabDialog aTabDlg(m_xDialog.get(), aSet, rSh);
if (RET_OK == aTabDlg.run())
{
const SfxItemSet* pOutSet = aTabDlg.GetOutputItemSet();
@@ -1175,10 +1080,8 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl, Button*, void)
SfxItemState::SET == eFrameDirState||
SfxItemState::SET == eLRState)
{
SvTreeListEntry* pSelEntry = m_pTree->FirstSelected();
while( pSelEntry )
{
SectRepr* pRepr = static_cast<SectRepr*>(pSelEntry->GetUserData());
m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
if( SfxItemState::SET == eColState )
pRepr->GetCol() = *static_cast<const SwFormatCol*>(pColItem);
if( SfxItemState::SET == eBrushState )
@@ -1193,133 +1096,131 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl, Button*, void)
pRepr->GetFrameDir().SetValue(static_cast<const SvxFrameDirectionItem*>(pFrameDirItem)->GetValue());
if( SfxItemState::SET == eLRState )
pRepr->GetLRSpace() = *static_cast<const SvxLRSpaceItem*>(pLRSpaceItem);
pSelEntry = m_pTree->NextSelected(pSelEntry);
}
return false;
});
}
}
}
}
IMPL_LINK(SwEditRegionDlg, FileNameComboBoxHdl, weld::ComboBox&, rEdit, void)
{
int nStartPos, nEndPos;
rEdit.get_entry_selection_bounds(nStartPos, nEndPos);
if (!CheckPasswd())
return;
rEdit.select_entry_region(nStartPos, nEndPos);
SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
pSectRepr->SetSubRegion( rEdit.get_active_text() );
}
// Applying of the filename or the linked region
IMPL_LINK( SwEditRegionDlg, FileNameHdl, Edit&, rEdit, void )
IMPL_LINK(SwEditRegionDlg, FileNameEntryHdl, weld::Entry&, rEdit, void)
{
Selection aSelect = rEdit.GetSelection();
if(!CheckPasswd())
int nStartPos, nEndPos;
rEdit.get_selection_bounds(nStartPos, nEndPos);
if (!CheckPasswd())
return;
rEdit.SetSelection(aSelect);
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
OSL_ENSURE(pEntry,"no entry found");
SectRepr* pSectRepr = static_cast<SectRepr*>(pEntry->GetUserData());
if (&rEdit == m_pFileNameED)
rEdit.select_region(nStartPos, nEndPos);
SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
m_xSubRegionED->clear();
m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
m_bSubRegionsFilled = false;
if (m_xDDECB->get_active())
{
m_bSubRegionsFilled = false;
m_pSubRegionED->Clear();
if (m_pDDECB->IsChecked())
OUString sLink( SwSectionData::CollapseWhiteSpaces(rEdit.get_text()) );
sal_Int32 nPos = 0;
sLink = sLink.replaceFirst( " ", OUStringLiteral1(sfx2::cTokenSeparator), &nPos );
if (nPos>=0)
{
OUString sLink( SwSectionData::CollapseWhiteSpaces(rEdit.GetText()) );
sal_Int32 nPos = 0;
sLink = sLink.replaceFirst( " ", OUStringLiteral1(sfx2::cTokenSeparator), &nPos );
if (nPos>=0)
{
sLink = sLink.replaceFirst( " ", OUStringLiteral1(sfx2::cTokenSeparator), &nPos );
}
}
pSectRepr->GetSectionData().SetLinkFileName( sLink );
pSectRepr->GetSectionData().SetType( DDE_LINK_SECTION );
}
else
{
OUString sTmp(rEdit.GetText());
if(!sTmp.isEmpty())
{
SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
INetURLObject aAbs;
if( pMedium )
aAbs = pMedium->GetURLObject();
sTmp = URIHelper::SmartRel2Abs(
aAbs, sTmp, URIHelper::GetMaybeFileHdl() );
}
pSectRepr->SetFile( sTmp );
pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
}
pSectRepr->GetSectionData().SetLinkFileName( sLink );
pSectRepr->GetSectionData().SetType( DDE_LINK_SECTION );
}
else
{
pSectRepr->SetSubRegion( rEdit.GetText() );
OUString sTmp(rEdit.get_text());
if(!sTmp.isEmpty())
{
SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
INetURLObject aAbs;
if( pMedium )
aAbs = pMedium->GetURLObject();
sTmp = URIHelper::SmartRel2Abs(
aAbs, sTmp, URIHelper::GetMaybeFileHdl() );
}
pSectRepr->SetFile( sTmp );
pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
}
}
IMPL_LINK( SwEditRegionDlg, DDEHdl, Button*, pButton, void )
IMPL_LINK(SwEditRegionDlg, DDEHdl, weld::ToggleButton&, rButton, void)
{
CheckBox* pBox = static_cast<CheckBox*>(pButton);
if(!CheckPasswd(pBox))
if (!CheckPasswd(&rButton))
return;
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
if(pEntry)
SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
if (pSectRepr)
{
bool bFile = m_pFileCB->IsChecked();
SectRepr* pSectRepr = static_cast<SectRepr*>(pEntry->GetUserData());
bool bFile = m_xFileCB->get_active();
SwSectionData & rData( pSectRepr->GetSectionData() );
bool bDDE = pBox->IsChecked();
bool bDDE = rButton.get_active();
if(bDDE)
{
m_pFileNameFT->Hide();
m_pDDECommandFT->Enable();
m_pDDECommandFT->Show();
m_pSubRegionFT->Hide();
m_pSubRegionED->Hide();
m_xFileNameFT->hide();
m_xDDECommandFT->set_sensitive(true);
m_xDDECommandFT->show();
m_xSubRegionFT->hide();
m_xSubRegionED->hide();
if (FILE_LINK_SECTION == rData.GetType())
{
pSectRepr->SetFile(OUString());
m_pFileNameED->SetText(OUString());
m_xFileNameED->set_text(OUString());
rData.SetLinkFilePassword(OUString());
}
rData.SetType(DDE_LINK_SECTION);
}
else
{
m_pDDECommandFT->Hide();
m_pFileNameFT->Enable(bFile);
m_pFileNameFT->Show();
m_pSubRegionED->Show();
m_pSubRegionFT->Show();
m_pSubRegionED->Enable(bFile);
m_pSubRegionFT->Enable(bFile);
m_pSubRegionED->Enable(bFile);
m_xDDECommandFT->hide();
m_xFileNameFT->set_sensitive(bFile);
m_xFileNameFT->show();
m_xSubRegionED->show();
m_xSubRegionFT->show();
m_xSubRegionED->set_sensitive(bFile);
m_xSubRegionFT->set_sensitive(bFile);
m_xSubRegionED->set_sensitive(bFile);
if (DDE_LINK_SECTION == rData.GetType())
{
rData.SetType(FILE_LINK_SECTION);
pSectRepr->SetFile(OUString());
rData.SetLinkFilePassword(OUString());
m_pFileNameED->SetText(OUString());
m_xFileNameED->set_text(OUString());
}
}
m_pFilePB->Enable(bFile && !bDDE);
m_xFilePB->set_sensitive(bFile && !bDDE);
}
}
IMPL_LINK( SwEditRegionDlg, ChangePasswdHdl, Button *, pBox, void )
void SwEditRegionDlg::ChangePasswd(bool bChange)
{
bool bChange = pBox == m_pPasswdPB;
if(!CheckPasswd())
if (!CheckPasswd())
{
if(!bChange)
m_pPasswdCB->Check(!m_pPasswdCB->IsChecked());
if (!bChange)
m_xPasswdCB->set_active(!m_xPasswdCB->get_active());
return;
}
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
bool bSet = bChange ? bChange : m_pPasswdCB->IsChecked();
OSL_ENSURE(pEntry,"no entry found");
while( pEntry )
{
SectRepr* pRepr = static_cast<SectRepr*>(pEntry->GetUserData());
bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
m_xTree->selected_foreach([this, bChange, bSet](weld::TreeIter& rEntry){
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
if(bSet)
{
if(!pRepr->GetTempPasswd().getLength() || bChange)
{
SfxPasswordDialog aPasswdDlg(GetFrameWeld());
SfxPasswordDialog aPasswdDlg(m_xDialog.get());
aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
if (RET_OK == aPasswdDlg.run())
{
@@ -1330,19 +1231,19 @@ IMPL_LINK( SwEditRegionDlg, ChangePasswdHdl, Button *, pBox, void )
}
else
{
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pBox->GetFrameWeld(),
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Info, VclButtonsType::Ok,
SwResId(STR_WRONG_PASSWD_REPEAT)));
xInfoBox->run();
ChangePasswdHdl(pBox);
break;
ChangePasswd(bChange);
return true;
}
}
else
{
if(!bChange)
m_pPasswdCB->Check(false);
break;
m_xPasswdCB->set_active(false);
return true;
}
}
pRepr->GetSectionData().SetPassword(pRepr->GetTempPasswd());
@@ -1351,43 +1252,51 @@ IMPL_LINK( SwEditRegionDlg, ChangePasswdHdl, Button *, pBox, void )
{
pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
}
pEntry = m_pTree->NextSelected(pEntry);
}
return false;
});
}
IMPL_LINK_NOARG(SwEditRegionDlg, TogglePasswdHdl, weld::ToggleButton&, void)
{
ChangePasswd(false);
}
IMPL_LINK_NOARG(SwEditRegionDlg, ChangePasswdHdl, weld::Button&, void)
{
ChangePasswd(true);
}
// the current region name is being added to the TreeListBox immediately during
// editing, with empty string no Ok()
IMPL_LINK_NOARG(SwEditRegionDlg, NameEditHdl, Edit&, void)
IMPL_LINK_NOARG(SwEditRegionDlg, NameEditHdl, weld::Entry&, void)
{
if(!CheckPasswd())
return;
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
OSL_ENSURE(pEntry,"no entry found");
if (pEntry)
std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
if (m_xTree->get_selected(xIter.get()))
{
const OUString aName = m_pCurName->GetText();
m_pTree->SetEntryText(pEntry,aName);
SectRepr* pRepr = static_cast<SectRepr*>(pEntry->GetUserData());
const OUString aName = m_xCurName->get_text();
m_xTree->set_text(*xIter, aName);
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
pRepr->GetSectionData().SetSectionName(aName);
m_pOK->Enable(!aName.isEmpty());
m_xOK->set_sensitive(!aName.isEmpty());
}
}
IMPL_LINK( SwEditRegionDlg, ConditionEditHdl, Edit&, rEdit, void )
IMPL_LINK( SwEditRegionDlg, ConditionEditHdl, weld::Entry&, rEdit, void )
{
Selection aSelect = rEdit.GetSelection();
int nStartPos, nEndPos;
rEdit.get_selection_bounds(nStartPos, nEndPos);
if(!CheckPasswd())
return;
rEdit.SetSelection(aSelect);
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
OSL_ENSURE(pEntry,"no entry found");
while( pEntry )
{
SectRepr* pRepr = static_cast<SectRepr*>(pEntry->GetUserData());
pRepr->GetSectionData().SetCondition(rEdit.GetText());
pEntry = m_pTree->NextSelected(pEntry);
}
rEdit.select_region(nStartPos, nEndPos);
m_xTree->selected_foreach([this, &rEdit](weld::TreeIter& rEntry){
SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
pRepr->GetSectionData().SetCondition(rEdit.get_text());
return false;
});
}
IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void )
@@ -1403,29 +1312,27 @@ IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, v
const SfxPoolItem* pItem;
if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
sPassword = static_cast<const SfxStringItem*>(pItem )->GetValue();
::lcl_ReadSections(*pMedium, *m_pSubRegionED);
::lcl_ReadSections(*pMedium, *m_xSubRegionED);
}
}
SvTreeListEntry* pEntry = m_pTree->FirstSelected();
OSL_ENSURE( pEntry, "no entry found" );
if ( pEntry )
SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
if (pSectRepr)
{
SectRepr* pSectRepr = static_cast<SectRepr*>(pEntry->GetUserData());
pSectRepr->SetFile( sFileName );
pSectRepr->SetFilter( sFilterName );
pSectRepr->GetSectionData().SetLinkFilePassword(sPassword);
m_pFileNameED->SetText(pSectRepr->GetFile());
m_xFileNameED->set_text(pSectRepr->GetFile());
}
}
IMPL_LINK( SwEditRegionDlg, SubRegionEventHdl, VclWindowEvent&, rEvent, void )
IMPL_LINK_NOARG(SwEditRegionDlg, SubRegionEventHdl, weld::ComboBox&, void)
{
if( !m_bSubRegionsFilled && rEvent.GetId() == VclEventId::DropdownPreOpen )
if (!m_bSubRegionsFilled)
{
//if necessary fill the names bookmarks/sections/tables now
OUString sFileName = m_pFileNameED->GetText();
OUString sFileName = m_xFileNameED->get_text();
if(!sFileName.isEmpty())
{
SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
@@ -1438,35 +1345,15 @@ IMPL_LINK( SwEditRegionDlg, SubRegionEventHdl, VclWindowEvent&, rEvent, void )
//load file and set the shell
SfxMedium aMedium( sFileName, StreamMode::STD_READ );
sFileName = aMedium.GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
::lcl_ReadSections(aMedium, *m_pSubRegionED);
::lcl_ReadSections(aMedium, *m_xSubRegionED);
}
else
lcl_FillSubRegionList(rSh, *m_pSubRegionED, nullptr);
lcl_FillSubRegionList(rSh, *m_xSubRegionED, nullptr);
m_bSubRegionsFilled = true;
}
}
// helper function - read section names from medium
static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox )
{
rBox.Clear();
uno::Reference < embed::XStorage > xStg;
if( rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is() )
{
std::vector<OUString> aArr;
SotClipboardFormatId nFormat = SotStorage::GetFormatID( xStg );
if ( nFormat == SotClipboardFormatId::STARWRITER_60 || nFormat == SotClipboardFormatId::STARWRITERGLOB_60 ||
nFormat == SotClipboardFormatId::STARWRITER_8 || nFormat == SotClipboardFormatId::STARWRITERGLOB_8)
SwGetReaderXML()->GetSectionList( rMedium, aArr );
for (auto const& it : aArr)
{
rBox.InsertEntry(it);
}
}
}
// helper function - read section names from medium
static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox )
{
rBox.clear();
@@ -1650,6 +1537,7 @@ void SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh)
const OUString sSectionName(pSectionData->GetSectionName());
m_xCurName->set_entry_text(rSh.GetUniqueSectionName(&sSectionName));
m_xProtectCB->set_active( pSectionData->IsProtectFlag() );
ChangeProtectHdl(*m_xProtectCB);
m_sFileName = pSectionData->GetLinkFileName();
m_sFilePasswd = pSectionData->GetLinkFilePassword();
m_xFileCB->set_active( !m_sFileName.isEmpty() );
@@ -1821,6 +1709,7 @@ IMPL_LINK(SwInsertSectionTabPage, UseFileHdl, weld::ToggleButton&, rButton, void
{
m_xFileNameED->grab_focus();
m_xProtectCB->set_active(true);
ChangeProtectHdl(*m_xProtectCB);
}
else
{
@@ -2047,7 +1936,7 @@ void SwSectionFootnoteEndTabPage::ResetState( bool bFootnote,
[[fallthrough]];
case FTNEND_ATTXTEND_OWNNUMSEQ:
pNumViewBox->Enable( false );
pNumViewBox->set_sensitive( false );
pPrefixFT->set_sensitive( false );
pPrefixED->set_sensitive( false );
pSuffixFT->set_sensitive( false );
@@ -2115,7 +2004,7 @@ IMPL_LINK( SwSectionFootnoteEndTabPage, FootEndHdl, weld::ToggleButton&, rBox, v
pOffsetText->set_sensitive( bEnableNum );
pOffsetField->set_sensitive( bEnableNum );
pNumFormatBox->set_sensitive( bEnableNum );
pNumViewBox->Enable( bEnableNumFormat );
pNumViewBox->set_sensitive( bEnableNumFormat );
pPrefixED->set_sensitive( bEnableNumFormat );
pSuffixED->set_sensitive( bEnableNumFormat );
pPrefixFT->set_sensitive( bEnableNumFormat );
diff --git a/sw/source/ui/fldui/changedb.cxx b/sw/source/ui/fldui/changedb.cxx
index 4ddfff3..3db42d2 100644
--- a/sw/source/ui/fldui/changedb.cxx
+++ b/sw/source/ui/fldui/changedb.cxx
@@ -193,6 +193,7 @@ void SwChangeDBDlg::UpdateFields()
m_xUsedDBTLB->get_id(rEntry));
aDBNames.push_back(sTmp);
}
return false;
});
pSh->StartAllAction();
diff --git a/sw/source/uibase/dialog/regionsw.cxx b/sw/source/uibase/dialog/regionsw.cxx
index 30b97749..da57a0b 100644
--- a/sw/source/uibase/dialog/regionsw.cxx
+++ b/sw/source/uibase/dialog/regionsw.cxx
@@ -208,7 +208,7 @@ void SwBaseShell::EditRegionDialog(SfxRequest const & rReq)
case FN_EDIT_REGION:
case FN_EDIT_CURRENT_REGION:
{
vcl::Window* pParentWin = &GetView().GetViewFrame()->GetWindow();
weld::Window* pParentWin = GetView().GetViewFrame()->GetWindow().GetFrameWeld();
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
ScopedVclPtr<AbstractEditRegionDlg> pEditRegionDlg(pFact->CreateEditRegionDlg(pParentWin, rWrtShell));
diff --git a/sw/source/uibase/inc/condedit.hxx b/sw/source/uibase/inc/condedit.hxx
index 4efdbff..81716bd 100644
--- a/sw/source/uibase/inc/condedit.hxx
+++ b/sw/source/uibase/inc/condedit.hxx
@@ -69,8 +69,10 @@ public:
SwConditionEdit(std::unique_ptr<weld::Entry> xControl);
OUString get_text() const { return m_xControl->get_text(); }
void set_text(const OUString& rText) { m_xControl->set_text(rText); }
bool get_sensitive() const { return m_xControl->get_sensitive(); }
void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
void connect_changed(const Link<weld::Entry&, void>& rLink) { m_xControl->connect_changed(rLink); }
void hide() { m_xControl->hide(); }
weld::Entry& get_widget() { return *m_xControl; }
diff --git a/sw/source/uibase/inc/numberingtypelistbox.hxx b/sw/source/uibase/inc/numberingtypelistbox.hxx
index 0cb067b..291fe8a 100644
--- a/sw/source/uibase/inc/numberingtypelistbox.hxx
+++ b/sw/source/uibase/inc/numberingtypelistbox.hxx
@@ -52,7 +52,7 @@ public:
SvxNumType GetSelectedNumberingType();
bool SelectNumberingType(SvxNumType nType);
void SetNoSelection() { m_xWidget->set_active(-1); }
void Enable(bool bEnable) { m_xWidget->set_sensitive(bEnable); }
void set_sensitive(bool bEnable) { m_xWidget->set_sensitive(bEnable); }
};
#endif
diff --git a/sw/source/uibase/inc/regionsw.hxx b/sw/source/uibase/inc/regionsw.hxx
index 4a54a0d..60e5bb2 100644
--- a/sw/source/uibase/inc/regionsw.hxx
+++ b/sw/source/uibase/inc/regionsw.hxx
@@ -57,37 +57,10 @@ namespace sfx2
class SectRepr;
typedef std::map<size_t, std::unique_ptr<SectRepr>> SectReprs_t;
class SwEditRegionDlg : public SfxModalDialog
class SwEditRegionDlg : public SfxDialogController
{
VclPtr<Edit> m_pCurName;
VclPtr<SvTreeListBox> m_pTree;
VclPtr<TriStateBox> m_pFileCB;
VclPtr<CheckBox> m_pDDECB;
VclPtr<VclContainer> m_pDDEFrame;
VclPtr<FixedText> m_pFileNameFT;
VclPtr<FixedText> m_pDDECommandFT;
VclPtr<Edit> m_pFileNameED;
VclPtr<PushButton> m_pFilePB;
VclPtr<FixedText> m_pSubRegionFT;
VclPtr<ComboBox> m_pSubRegionED;
bool m_bSubRegionsFilled;
VclPtr<TriStateBox> m_pProtectCB;
VclPtr<CheckBox> m_pPasswdCB;
VclPtr<PushButton> m_pPasswdPB;
VclPtr<TriStateBox> m_pHideCB;
VclPtr<FixedText> m_pConditionFT;
VclPtr<ConditionEdit> m_pConditionED;
// #114856# edit in readonly sections
VclPtr<TriStateBox> m_pEditInReadonlyCB;
VclPtr<OKButton> m_pOK;
VclPtr<PushButton> m_pOptionsPB;
VclPtr<PushButton> m_pDismiss;
SwWrtShell& rSh;
SectReprs_t m_SectReprs;
const SwSection* pCurrSect;
@@ -95,36 +68,62 @@ class SwEditRegionDlg : public SfxModalDialog
bool bDontCheckPasswd :1;
void RecurseList( const SwSectionFormat* pFormat, SvTreeListEntry* pEntry);
std::unique_ptr<weld::Entry> m_xCurName;
std::unique_ptr<weld::TreeView> m_xTree;
std::unique_ptr<weld::CheckButton> m_xFileCB;
std::unique_ptr<weld::CheckButton> m_xDDECB;
std::unique_ptr<weld::Widget> m_xDDEFrame;
std::unique_ptr<weld::Label> m_xFileNameFT;
std::unique_ptr<weld::Label> m_xDDECommandFT;
std::unique_ptr<weld::Entry> m_xFileNameED;
std::unique_ptr<weld::Button> m_xFilePB;
std::unique_ptr<weld::Label> m_xSubRegionFT;
std::unique_ptr<weld::ComboBox> m_xSubRegionED;
std::unique_ptr<weld::CheckButton> m_xProtectCB;
std::unique_ptr<weld::CheckButton> m_xPasswdCB;
std::unique_ptr<weld::Button> m_xPasswdPB;
std::unique_ptr<weld::CheckButton> m_xHideCB;
std::unique_ptr<weld::Label> m_xConditionFT;
std::unique_ptr<SwConditionEdit> m_xConditionED;
// #114856# edit in readonly sections
std::unique_ptr<weld::CheckButton> m_xEditInReadonlyCB;
std::unique_ptr<weld::Button> m_xOK;
std::unique_ptr<weld::Button> m_xOptionsPB;
std::unique_ptr<weld::Button> m_xDismiss;
std::unique_ptr<weld::Widget> m_xHideFrame;
void RecurseList(const SwSectionFormat* pFormat, weld::TreeIter* pIter);
size_t FindArrPos(const SwSectionFormat* pFormat);
DECL_LINK( GetFirstEntryHdl, SvTreeListBox *, void );
DECL_LINK( DeselectHdl, SvTreeListBox *, void );
DECL_LINK( GetFirstEntryHdl, weld::TreeView&, void );
DECL_LINK( DeselectHdl, weld::TreeView&, void );
DECL_LINK( OkHdl, Button*, void );
DECL_LINK( NameEditHdl, Edit&, void );
DECL_LINK( ConditionEditHdl, Edit&, void );
DECL_LINK( OkHdl, weld::Button&, void );
DECL_LINK( NameEditHdl, weld::Entry&, void );
DECL_LINK( ConditionEditHdl, weld::Entry&, void );
DECL_LINK( ChangePasswdHdl, Button *, void );
DECL_LINK( ChangeProtectHdl, Button *, void );
DECL_LINK( ChangeHideHdl, Button *, void );
void ChangePasswd(bool bChange);
DECL_LINK( TogglePasswdHdl, weld::ToggleButton&, void );
DECL_LINK( ChangePasswdHdl, weld::Button&, void );
DECL_LINK( ChangeProtectHdl, weld::ToggleButton&, void );
DECL_LINK( ChangeHideHdl, weld::ToggleButton&, void );
// #114856# edit in readonly sections
DECL_LINK( ChangeEditInReadonlyHdl, Button *, void );
DECL_LINK( ChangeDismissHdl, Button*, void);
DECL_LINK( UseFileHdl, Button*, void );
DECL_LINK( FileSearchHdl, Button*, void );
DECL_LINK( OptionsHdl, Button*, void );
DECL_LINK( FileNameHdl, Edit&, void );
DECL_LINK( DDEHdl, Button*, void );
DECL_LINK( ChangeEditInReadonlyHdl, weld::ToggleButton&, void );
DECL_LINK( ChangeDismissHdl, weld::Button&, void);
DECL_LINK( UseFileHdl, weld::ToggleButton&, void );
DECL_LINK( FileSearchHdl, weld::Button&, void );
DECL_LINK( OptionsHdl, weld::Button&, void );
DECL_LINK( FileNameComboBoxHdl, weld::ComboBox&, void );
DECL_LINK( FileNameEntryHdl, weld::Entry&, void );
DECL_LINK( DDEHdl, weld::ToggleButton&, void );
DECL_LINK( DlgClosedHdl, sfx2::FileDialogHelper*, void );
DECL_LINK( SubRegionEventHdl, VclWindowEvent&, void );
DECL_LINK( SubRegionEventHdl, weld::ComboBox&, void );
bool CheckPasswd(CheckBox* pBox = nullptr);
bool CheckPasswd(weld::ToggleButton* pBox = nullptr);
public:
SwEditRegionDlg( vcl::Window* pParent, SwWrtShell& rWrtSh );
SwEditRegionDlg(weld::Window* pParent, SwWrtShell& rWrtSh);
virtual ~SwEditRegionDlg() override;
virtual void dispose() override;
void SelectSection(const OUString& rSectionName);
diff --git a/sw/uiconfig/swriter/ui/editsectiondialog.ui b/sw/uiconfig/swriter/ui/editsectiondialog.ui
index 37c3081..a35f916 100644
--- a/sw/uiconfig/swriter/ui/editsectiondialog.ui
+++ b/sw/uiconfig/swriter/ui/editsectiondialog.ui
@@ -2,11 +2,23 @@
<!-- Generated with glade 3.22.1 -->
<interface domain="sw">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkTreeStore" id="liststore1">
<columns>
<!-- column-name expander -->
<column type="GdkPixbuf"/>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="EditSectionDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="editsectiondialog|EditSectionDialog">Edit Sections</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
@@ -133,7 +145,6 @@
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkEntry" id="curname">
<property name="visible">True</property>
@@ -146,13 +157,43 @@
</packing>
</child>
<child>
<object class="vcllo-SvTreeListBox" id="tree: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>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Tree List-selection1"/>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="tree">
<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>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="spacing">6</property>
<child>
<object class="GtkCellRendererPixbuf" id="cellrenderertext4"/>
<attributes>
<attribute name="pixbuf">0</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
@@ -274,6 +315,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -302,7 +344,8 @@
<property name="has_entry">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxtext-entry">
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
</object>
</child>
</object>
@@ -562,11 +605,12 @@
</packing>
</child>
<child>
<object class="swlo-ConditionEdit" id="condition">
<object class="GtkEntry" id="condition">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -678,8 +722,8 @@
<action-widgets>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
<action-widget response="0">options</action-widget>
<action-widget response="0">remove</action-widget>
<action-widget response="101">options</action-widget>
<action-widget response="102">remove</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
</object>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 82bae78..216de77 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -249,6 +249,7 @@ private:
bool m_bKeyEventListener;
int m_nBlockNotify;
protected:
void ensure_event_listener()
{
if (!m_bEventListener)
@@ -270,7 +271,6 @@ private:
}
}
protected:
virtual void HandleEventListener(VclWindowEvent& rEvent);
virtual bool HandleKeyEventListener(VclWindowEvent& rEvent);
@@ -1690,15 +1690,7 @@ public:
{
m_xRadioButton->SetImageAlign(ImageAlign::Center);
if (pDevice)
{
BitmapEx aBitmap(pDevice->GetBitmapEx(Point(0, 0), pDevice->GetOutputSize()));
vcl::PNGWriter aWriter(aBitmap);
SvFileStream sOutput("file:///tmp/demo.png", StreamMode::WRITE);
aWriter.Write(sOutput);
m_xRadioButton->SetModeImage(createImage(*pDevice));
}
else
m_xRadioButton->SetModeImage(Image());
}
@@ -2387,7 +2379,7 @@ public:
for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry))
{
if (SvTabListBox::GetEntryText(pEntry, 0) == rText)
return m_xTreeView->GetAbsPos(pEntry);
return SvTreeList::GetRelPos(pEntry);
}
return -1;
}
@@ -2400,7 +2392,7 @@ public:
if (!pId)
continue;
if (rId == *pId)
return m_xTreeView->GetAbsPos(pEntry);
return SvTreeList::GetRelPos(pEntry);
}
return -1;
}
@@ -2488,7 +2480,7 @@ public:
aRows.reserve(m_xTreeView->GetSelectionCount());
for (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected(); pEntry; pEntry = m_xTreeView->NextSelected(pEntry))
aRows.push_back(m_xTreeView->GetAbsPos(pEntry));
aRows.push_back(SvTreeList::GetRelPos(pEntry));
return aRows;
}
@@ -2719,7 +2711,7 @@ public:
SvTreeListEntry* pEntry = m_xTreeView->FirstSelected();
if (!pEntry)
return -1;
return m_xTreeView->GetAbsPos(pEntry);
return SvTreeList::GetRelPos(pEntry);
}
virtual OUString get_selected_text() const override
@@ -2928,24 +2920,26 @@ public:
m_xTreeView->SetSelectionMode(eMode);
}
virtual void selected_foreach(const std::function<void(weld::TreeIter&)>& func) override
virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) override
{
SalInstanceTreeIter aVclIter(nullptr);
aVclIter.iter = m_xTreeView->FirstSelected();
while (aVclIter.iter)
{
func(aVclIter);
if (func(aVclIter))
return;
aVclIter.iter = m_xTreeView->NextSelected(aVclIter.iter);
}
}
virtual void visible_foreach(const std::function<void(weld::TreeIter&)>& func) override
virtual void visible_foreach(const std::function<bool(weld::TreeIter&)>& func) override
{
SalInstanceTreeIter aVclIter(nullptr);
aVclIter.iter = m_xTreeView->GetFirstEntryInView();
while (aVclIter.iter)
{
func(aVclIter);
if (func(aVclIter))
return;
aVclIter.iter = m_xTreeView->GetNextEntryInView(aVclIter.iter);
}
}
@@ -2962,6 +2956,19 @@ public:
return m_xTreeView->IsSelected(rVclIter.iter);
}
virtual int get_iter_index_in_parent(const weld::TreeIter& rIter) const override
{
const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
return SvTreeList::GetRelPos(rVclIter.iter);
}
virtual void move_subtree(weld::TreeIter& rNode, const weld::TreeIter* pNewParent, int nIndexInNewParent) override
{
SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNode);
const SalInstanceTreeIter* pVclParentIter = static_cast<const SalInstanceTreeIter*>(pNewParent);
m_xTreeView->GetModel()->Move(rVclIter.iter, pVclParentIter ? pVclParentIter->iter : nullptr, nIndexInNewParent);
}
virtual int count_selected_rows() const override
{
return m_xTreeView->GetSelectionCount();
@@ -3141,7 +3148,7 @@ IMPL_LINK(SalInstanceTreeView, ToggleHdl, SvLBoxButtonData*, pData, void)
SvLBoxItem& rItem = pEntry->GetItem(i);
if (&rItem == pBox)
{
int nRow = m_xTreeView->GetAbsPos(pEntry);
int nRow = SvTreeList::GetRelPos(pEntry);
int nCol = i - 1; // less dummy/expander column
signal_toggled(std::make_pair(nRow, nCol));
break;
@@ -3928,6 +3935,23 @@ public:
{
return m_xComboBox->IsInDropDown();
}
virtual void connect_popup_toggled(const Link<ComboBox&, void>& rLink) override
{
weld::ComboBox::connect_popup_toggled(rLink);
ensure_event_listener();
}
virtual void HandleEventListener(VclWindowEvent& rEvent) override
{
if (rEvent.GetId() == VclEventId::DropdownPreOpen ||
rEvent.GetId() == VclEventId::DropdownClose)
{
signal_popup_toggled();
return;
}
SalInstanceContainer::HandleEventListener(rEvent);
}
};
class SalInstanceComboBoxWithoutEdit : public SalInstanceComboBox<ListBox>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 15f3a78..910c1cb 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -5310,7 +5310,11 @@ namespace
gtk_tree_model_get(model, iter, search->col, &pStr, -1);
bool found = strcmp(pStr, search->str.getStr()) == 0;
if (found)
search->index = gtk_tree_path_get_indices(path)[0];
{
gint depth;
gint* indices = gtk_tree_path_get_indices_with_depth(path, &depth);
search->index = indices[depth-1];
}
g_free(pStr);
return found;
}
@@ -5666,7 +5670,10 @@ private:
bRet = !bRet;
gtk_tree_store_set(m_pTreeStore, &iter, nCol, bRet, -1);
int nRow = gtk_tree_path_get_indices(tree_path)[0];
gint depth;
gint* indices = gtk_tree_path_get_indices_with_depth(tree_path, &depth);
int nRow = indices[depth-1];
signal_toggled(std::make_pair(nRow, nCol));
gtk_tree_path_free(tree_path);
@@ -6055,14 +6062,19 @@ public:
for (GList* pItem = g_list_first(pList); pItem; pItem = g_list_next(pItem))
{
GtkTreePath* path = static_cast<GtkTreePath*>(pItem->data);
aRows.push_back(gtk_tree_path_get_indices(path)[0]);
gint depth;
gint* indices = gtk_tree_path_get_indices_with_depth(path, &depth);
int nRow = indices[depth-1];
aRows.push_back(nRow);
}
g_list_free_full(pList, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
return aRows;
}
virtual void selected_foreach(const std::function<void(weld::TreeIter&)>& func) override
virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) override
{
GtkInstanceTreeIter aGtkIter(nullptr);
@@ -6072,12 +6084,13 @@ public:
{
GtkTreePath* path = static_cast<GtkTreePath*>(pItem->data);
gtk_tree_model_get_iter(pModel, &aGtkIter.iter, path);
func(aGtkIter);
if (func(aGtkIter))
break;
}
g_list_free_full(pList, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
}
virtual void visible_foreach(const std::function<void(weld::TreeIter&)>& func) override
virtual void visible_foreach(const std::function<bool(weld::TreeIter&)>& func) override
{
GtkTreePath* start_path;
GtkTreePath* end_path;
@@ -6090,7 +6103,8 @@ public:
do
{
func(aGtkIter);
if (func(aGtkIter))
break;
GtkTreePath* path = gtk_tree_model_get_path(pModel, &aGtkIter.iter);
bool bContinue = gtk_tree_path_compare(path, end_path) != 0;
gtk_tree_path_free(path);
@@ -6222,6 +6236,61 @@ public:
return set(pos, m_nIdCol, rId);
}
virtual int get_iter_index_in_parent(const weld::TreeIter& rIter) const override
{
const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter);
GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
GtkTreePath* path = gtk_tree_model_get_path(pModel, const_cast<GtkTreeIter*>(&rGtkIter.iter));
gint depth;
gint* indices = gtk_tree_path_get_indices_with_depth(path, &depth);
int nRet = indices[depth-1];
gtk_tree_path_free(path);
return nRet;
}
// by copy and delete of old copy
void move_subtree(GtkTreeIter& rFromIter, GtkTreeIter* pGtkParentIter, int nIndexInNewParent)
{
GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
int nCols = gtk_tree_model_get_n_columns(pModel);
GValue value;
GtkTreeIter toiter;
gtk_tree_store_insert(m_pTreeStore, &toiter, pGtkParentIter, nIndexInNewParent);
for (int i = 0; i < nCols; ++i)
{
memset(&value, 0, sizeof(GValue));
gtk_tree_model_get_value(pModel, &rFromIter, i, &value);
gtk_tree_store_set_value(m_pTreeStore, &toiter, i, &value);
g_value_unset(&value);
}
GtkTreeIter tmpfromiter;
if (gtk_tree_model_iter_children(pModel, &tmpfromiter, &rFromIter))
{
int j = 0;
do
{
move_subtree(tmpfromiter, &toiter, j++);
} while (gtk_tree_model_iter_next(pModel, &tmpfromiter));
}
gtk_tree_store_remove(m_pTreeStore, &rFromIter);
}
virtual void move_subtree(weld::TreeIter& rNode, const weld::TreeIter* pNewParent, int nIndexInNewParent) override
{
GtkInstanceTreeIter& rGtkIter = static_cast<GtkInstanceTreeIter&>(rNode);
const GtkInstanceTreeIter* pGtkParentIter = static_cast<const GtkInstanceTreeIter*>(pNewParent);
move_subtree(rGtkIter.iter, pGtkParentIter ? const_cast<GtkTreeIter*>(&pGtkParentIter->iter) : nullptr, nIndexInNewParent);
}
virtual int get_selected_index() const override
{
assert(gtk_tree_view_get_model(m_pTreeView) && "don't request selection when frozen");
@@ -6234,7 +6303,11 @@ public:
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(m_pTreeView), &pModel, &iter))
{
GtkTreePath* path = gtk_tree_model_get_path(pModel, &iter);
nRet = gtk_tree_path_get_indices(path)[0];
gint depth;
gint* indices = gtk_tree_path_get_indices_with_depth(path, &depth);
nRet = indices[depth-1];
gtk_tree_path_free(path);
}
}
@@ -6246,21 +6319,24 @@ public:
return nRet;
}
bool get_selected_iterator(GtkTreeIter& rIter) const
bool get_selected_iterator(GtkTreeIter* pIter) const
{
assert(gtk_tree_view_get_model(m_pTreeView) && "don't request selection when frozen");
bool bRet = false;
GtkTreeSelection *selection = gtk_tree_view_get_selection(m_pTreeView);
if (gtk_tree_selection_get_mode(selection) != GTK_SELECTION_MULTIPLE)
bRet = gtk_tree_selection_get_selected(gtk_tree_view_get_selection(m_pTreeView), nullptr, &rIter);
bRet = gtk_tree_selection_get_selected(gtk_tree_view_get_selection(m_pTreeView), nullptr, pIter);
else
{
GtkTreeModel* pModel;
GList* pList = gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(m_pTreeView), &pModel);
for (GList* pItem = g_list_first(pList); pItem; pItem = g_list_next(pItem))
{
GtkTreePath* path = static_cast<GtkTreePath*>(pItem->data);
gtk_tree_model_get_iter(pModel, &rIter, path);
if (pIter)
{
GtkTreePath* path = static_cast<GtkTreePath*>(pItem->data);
gtk_tree_model_get_iter(pModel, pIter, path);
}
bRet = true;
break;
}
@@ -6273,7 +6349,7 @@ public:
{
assert(gtk_tree_view_get_model(m_pTreeView) && "don't request selection when frozen");
GtkTreeIter iter;
if (get_selected_iterator(iter))
if (get_selected_iterator(&iter))
return get(iter, m_nTextCol);
return OUString();
}
@@ -6282,7 +6358,7 @@ public:
{
assert(gtk_tree_view_get_model(m_pTreeView) && "don't request selection when frozen");
GtkTreeIter iter;
if (get_selected_iterator(iter))
if (get_selected_iterator(&iter))
return get(iter, m_nIdCol);
return OUString();
}
@@ -6302,7 +6378,7 @@ public:
virtual bool get_selected(weld::TreeIter* pIter) const override
{
GtkInstanceTreeIter* pGtkIter = static_cast<GtkInstanceTreeIter*>(pIter);
return gtk_tree_selection_get_selected(gtk_tree_view_get_selection(m_pTreeView), nullptr, pGtkIter ? &pGtkIter->iter : nullptr);
return get_selected_iterator(pGtkIter ? &pGtkIter->iter : nullptr);
}
virtual bool get_cursor(weld::TreeIter* pIter) const override
@@ -7540,13 +7616,13 @@ private:
pThis->signal_changed();
}
static void signalPopupShown(GtkComboBox*, GParamSpec*, gpointer widget)
static void signalPopupToggled(GtkComboBox*, GParamSpec*, gpointer widget)
{
GtkInstanceComboBox* pThis = static_cast<GtkInstanceComboBox*>(widget);
pThis->signal_popup_shown();
pThis->signal_popup_toggled();
}
void signal_popup_shown()
virtual void signal_popup_toggled() override
{
m_aQuickSelectionEngine.Reset();
gboolean bIsShown(false);
@@ -7554,6 +7630,7 @@ private:
if (m_bPopupActive != bIsShown)
{
m_bPopupActive = bIsShown;
ComboBox::signal_popup_toggled();
//restore focus to the entry view when the popup is gone, which
//is what the vcl case does, to ease the transition a little
gtk_widget_grab_focus(m_pWidget);
@@ -7658,7 +7735,11 @@ private:
{
GtkInstanceComboBox* pThis = static_cast<GtkInstanceComboBox*>(widget);
GtkTreePath* path = gtk_tree_model_get_path(pTreeModel, pIter);
int nIndex = gtk_tree_path_get_indices(path)[0];
gint depth;
gint* indices = gtk_tree_path_get_indices_with_depth(path, &depth);
int nIndex = indices[depth-1];
gtk_tree_path_free(path);
return pThis->separator_function(nIndex);
}
@@ -7825,7 +7906,7 @@ public:
, m_nToggleFocusInSignalId(0)
, m_nToggleFocusOutSignalId(0)
, m_nChangedSignalId(g_signal_connect(m_pComboBox, "changed", G_CALLBACK(signalChanged), this))
, m_nPopupShownSignalId(g_signal_connect(m_pComboBox, "notify::popup-shown", G_CALLBACK(signalPopupShown), this))
, m_nPopupShownSignalId(g_signal_connect(m_pComboBox, "notify::popup-shown", G_CALLBACK(signalPopupToggled), this))
, m_nAutoCompleteIdleId(0)
{
GList* cells = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_pComboBox));
diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx
index 91e4383..757c200 100644
--- a/xmlsecurity/source/dialogs/certificatechooser.cxx
+++ b/xmlsecurity/source/dialogs/certificatechooser.cxx
@@ -246,6 +246,7 @@ uno::Sequence<uno::Reference< css::security::XCertificate > > CertificateChooser
m_xCertLB->selected_foreach([this, &aRet](weld::TreeIter& rEntry){
UserData* userData = reinterpret_cast<UserData*>(m_xCertLB->get_id(rEntry).toInt64());
aRet.push_back( userData->xCertificate );
return false;
});
}
else