cui/Library_cui.mk | 1 cui/inc/strings.hrc | 2 cui/source/inc/dbregister.hxx | 6 cui/source/inc/optpath.hxx | 32 +- cui/source/options/dbregister.cxx | 2 cui/source/options/optHeaderTabListbox.cxx | 80 ------- cui/source/options/optHeaderTabListbox.hxx | 38 --- cui/source/options/optaboutconfig.cxx | 2 cui/source/options/optaboutconfig.hxx | 1 cui/source/options/optopencl.cxx | 1 cui/source/options/optpath.cxx | 319 ++++++++--------------------- cui/uiconfig/ui/optpathspage.ui | 166 ++++++++------- include/vcl/weld.hxx | 1 vcl/source/app/salvtables.cxx | 6 vcl/unx/gtk3/gtk3gtkinst.cxx | 29 +- 15 files changed, 231 insertions(+), 455 deletions(-)
New commits: commit b11195b416d2c4fbffa44da4049d6136055ba9d1 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Aug 1 11:52:16 2019 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Aug 1 15:20:39 2019 +0200 drop newly unused OptHeaderTabListBox Change-Id: I08926e91a61e7bdd4de4ac96083e970268801d6f Reviewed-on: https://gerrit.libreoffice.org/76789 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk index df4a94126a63..1822dc311097 100644 --- a/cui/Library_cui.mk +++ b/cui/Library_cui.mk @@ -169,7 +169,6 @@ $(eval $(call gb_Library_add_exception_objects,cui,\ cui/source/options/optfltr \ cui/source/options/optgdlg \ cui/source/options/optgenrl \ - cui/source/options/optHeaderTabListbox \ cui/source/options/opthtml \ cui/source/options/optinet2 \ cui/source/options/optjava \ diff --git a/cui/source/inc/dbregister.hxx b/cui/source/inc/dbregister.hxx index 12fe0eff140a..b177fb3b0de2 100644 --- a/cui/source/inc/dbregister.hxx +++ b/cui/source/inc/dbregister.hxx @@ -24,12 +24,6 @@ #include <sfx2/basedlgs.hxx> #include <sfx2/tabdlg.hxx> -class SvTreeListEntry; -namespace svx -{ - class OptHeaderTabListBox; -} - namespace svx { diff --git a/cui/source/inc/optpath.hxx b/cui/source/inc/optpath.hxx index a3f82f3c0206..40ceb1156805 100644 --- a/cui/source/inc/optpath.hxx +++ b/cui/source/inc/optpath.hxx @@ -28,16 +28,10 @@ #include <svtools/dialogclosedlistener.hxx> // forward --------------------------------------------------------------- - -namespace svx -{ - class OptHeaderTabListBox; -} struct OptPath_Impl; class SvxPathTabPage; // class SvxPathTabPage -------------------------------------------------- - class SvxPathTabPage : public SfxTabPage { private: diff --git a/cui/source/options/dbregister.cxx b/cui/source/options/dbregister.cxx index 4d409f14fdc5..f8680e3a53f2 100644 --- a/cui/source/options/dbregister.cxx +++ b/cui/source/options/dbregister.cxx @@ -22,6 +22,7 @@ #include "connpooloptions.hxx" #include <svl/filenotation.hxx> #include <helpids.h> +#include <tools/debug.hxx> #include <svtools/editbrowsebox.hxx> #include <strings.hrc> #include <bitmaps.hlst> @@ -36,7 +37,6 @@ #include <svl/itemset.hxx> #include "doclinkdialog.hxx" #include <unotools/localfilehelper.hxx> -#include "optHeaderTabListbox.hxx" #include <sfx2/docfilt.hxx> #include <dialmgr.hxx> #include "dbregisterednamesconfig.hxx" diff --git a/cui/source/options/optHeaderTabListbox.cxx b/cui/source/options/optHeaderTabListbox.cxx deleted file mode 100644 index eb9205335b10..000000000000 --- a/cui/source/options/optHeaderTabListbox.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "optHeaderTabListbox.hxx" -#include <vcl/svapp.hxx> -#include <vcl/settings.hxx> -#include <vcl/headbar.hxx> -#include <vcl/svlbitm.hxx> -#include <vcl/treelistentry.hxx> -namespace svx -{ -// class OptLBoxString_Impl ---------------------------------------------- - -class OptLBoxString_Impl : public SvLBoxString -{ -public: - explicit OptLBoxString_Impl(const OUString& rTxt) - : SvLBoxString(rTxt) - { - } - - virtual void Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext, - const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override; -}; - - -void OptLBoxString_Impl::Paint(const Point& rPos, SvTreeListBox& /*rDev*/, vcl::RenderContext& rRenderContext, - const SvViewDataEntry* /*pView*/, const SvTreeListEntry& rEntry) -{ - rRenderContext.Push(PushFlags::FONT); - vcl::Font aFont(rRenderContext.GetFont()); - //detect readonly state by asking for a valid Image - if (!(!SvTreeListBox::GetCollapsedEntryBmp(&rEntry))) - aFont.SetColor(Application::GetSettings().GetStyleSettings().GetDeactiveTextColor()); - rRenderContext.SetFont(aFont); - rRenderContext.DrawText(rPos, GetText()); - rRenderContext.Pop(); -} - - -OptHeaderTabListBox::OptHeaderTabListBox(SvSimpleTableContainer& rParent, WinBits nWinStyle) - : SvSimpleTable(rParent, nWinStyle) -{ -} - - -void OptHeaderTabListBox::InitEntry( SvTreeListEntry* pEntry, const OUString& rTxt, - const Image& rImg1, const Image& rImg2, - SvLBoxButtonKind eButtonKind ) -{ - SvTabListBox::InitEntry( pEntry, rTxt, rImg1, rImg2, eButtonKind ); - sal_uInt16 _nTabCount = TabCount(); - - for ( sal_uInt16 nCol = 1; nCol < _nTabCount; ++nCol ) - { - // initialize all columns with own class (column 0 == Bitmap) - SvLBoxString& rCol = static_cast<SvLBoxString&>(pEntry->GetItem( nCol )); - pEntry->ReplaceItem(std::make_unique<OptLBoxString_Impl>(rCol.GetText()), nCol); - } -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optHeaderTabListbox.hxx b/cui/source/options/optHeaderTabListbox.hxx deleted file mode 100644 index 147bbde49fb7..000000000000 --- a/cui/source/options/optHeaderTabListbox.hxx +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_CUI_SOURCE_OPTIONS_OPTHEADERTABLISTBOX_HXX -#define INCLUDED_CUI_SOURCE_OPTIONS_OPTHEADERTABLISTBOX_HXX - -#include <svtools/simptabl.hxx> - -namespace svx -{ - // class OptHeaderTabListBox --------------------------------------------- - - class OptHeaderTabListBox : public SvSimpleTable - { - public: - OptHeaderTabListBox(SvSimpleTableContainer& rParent, WinBits nBits); - - virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind) override; - }; -} // svx -#endif // INCLUDED_CUI_SOURCE_OPTIONS_OPTHEADERTABLISTBOX_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index b1d156aab5c7..41d590a6953f 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -8,7 +8,6 @@ */ #include "optaboutconfig.hxx" -#include "optHeaderTabListbox.hxx" #include <vcl/button.hxx> #include <vcl/event.hxx> @@ -37,7 +36,6 @@ #include <vector> #include <iostream> -using namespace svx; using namespace ::com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::container; diff --git a/cui/source/options/optaboutconfig.hxx b/cui/source/options/optaboutconfig.hxx index 5591f40e43db..c045ed42095e 100644 --- a/cui/source/options/optaboutconfig.hxx +++ b/cui/source/options/optaboutconfig.hxx @@ -19,7 +19,6 @@ #include <vector> -namespace svx { class OptHeaderTabListBox; } class CuiAboutConfigTabPage; class CuiAboutConfigValueDialog; struct Prop_Impl; diff --git a/cui/source/options/optopencl.cxx b/cui/source/options/optopencl.cxx index 5131714e18c8..062d21be531f 100644 --- a/cui/source/options/optopencl.cxx +++ b/cui/source/options/optopencl.cxx @@ -25,7 +25,6 @@ #include <opencl/openclwrapper.hxx> #include <officecfg/Office/Common.hxx> #include <svtools/restartdialog.hxx> -#include "optHeaderTabListbox.hxx" #include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx index 5f0dd831835f..46d930d1c346 100644 --- a/cui/source/options/optpath.cxx +++ b/cui/source/options/optpath.cxx @@ -50,7 +50,6 @@ #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/util/thePathSettings.hpp> #include <officecfg/Office/Common.hxx> -#include "optHeaderTabListbox.hxx" #include <vcl/help.hxx> #include <tools/diagnose_ex.h> #include <sal/log.hxx> commit 3f738d8f9e5c448ddf352a8e10e6c619dde7d87d Author: Caolán McNamara <[email protected]> AuthorDate: Thu Aug 1 11:50:08 2019 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Aug 1 15:20:29 2019 +0200 weld SvxPathTabPage Change-Id: If9b982d9e73adbb55e940ae12e5d894dd803f7f3 Reviewed-on: https://gerrit.libreoffice.org/76788 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc index e1fdec1ef480..d7e581fccb26 100644 --- a/cui/inc/strings.hrc +++ b/cui/inc/strings.hrc @@ -389,6 +389,8 @@ #define RID_SVXSTR_ABOUT_WEBSITE NC_("aboutdialog|website", "~Website") #define RID_SVXSTR_ABOUT_CREDITS NC_("aboutdialog|credits", "Cre~dits") +#define RID_SVXSTR_EDIT_PATHS NC_("optpathspage|editpaths", "Edit Paths: %1") + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/optpath.hxx b/cui/source/inc/optpath.hxx index 47f813730a08..a3f82f3c0206 100644 --- a/cui/source/inc/optpath.hxx +++ b/cui/source/inc/optpath.hxx @@ -41,27 +41,24 @@ class SvxPathTabPage; class SvxPathTabPage : public SfxTabPage { private: - VclPtr<SvSimpleTableContainer> m_pPathCtrl; - VclPtr<PushButton> m_pStandardBtn; - VclPtr<PushButton> m_pPathBtn; - - VclPtr<svx::OptHeaderTabListBox> pPathBox; std::unique_ptr<OptPath_Impl> pImpl; rtl::Reference< ::svt::DialogClosedListener > xDialogListener; css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker; + std::unique_ptr<weld::Button> m_xStandardBtn; + std::unique_ptr<weld::Button> m_xPathBtn; + std::unique_ptr<weld::TreeView> m_xPathBox; + void ChangeCurrentEntry( const OUString& _rFolder ); - DECL_LINK( PathHdl_Impl, Button*, void); - DECL_LINK( DoubleClickPathHdl_Impl, SvTreeListBox*, bool); - DECL_LINK( StandardHdl_Impl, Button*, void); + DECL_LINK(PathHdl_Impl, weld::Button&, void); + DECL_LINK(DoubleClickPathHdl_Impl, weld::TreeView&, void); + DECL_LINK(StandardHdl_Impl, weld::Button&, void); - DECL_LINK( PathSelect_Impl, SvTreeListBox*, void); - DECL_LINK( HeaderSelect_Impl, HeaderBar *, void ); - DECL_LINK( HeaderEndDrag_Impl, HeaderBar *, void ); + DECL_LINK(PathSelect_Impl, weld::TreeView&, void); - DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void ); + DECL_LINK(DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void); void GetPathList( sal_uInt16 _nPathHandle, OUString& _rInternalPath, OUString& _rUserPath, OUString& _rWritablePath, bool& _rReadOnly ); @@ -69,15 +66,14 @@ private: const OUString& _rUserPath, const OUString& _rWritablePath ); public: - SvxPathTabPage( vcl::Window* pParent, const SfxItemSet& rSet ); - virtual ~SvxPathTabPage() override; + SvxPathTabPage( TabPageParent pParent, const SfxItemSet& rSet ); virtual void dispose() override; + virtual ~SvxPathTabPage() override; static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rSet ); virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; - virtual void FillUserData() override; }; #endif diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx index 9a0cbb1f6ff3..5f0dd831835f 100644 --- a/cui/source/options/optpath.cxx +++ b/cui/source/options/optpath.cxx @@ -32,8 +32,9 @@ #include <unotools/moduleoptions.hxx> #include <unotools/viewoptions.hxx> -#include <optpath.hxx> +#include <bitmaps.hlst> #include <dialmgr.hxx> +#include <optpath.hxx> #include <strings.hrc> #include <comphelper/configuration.hxx> #include <comphelper/processfactory.hxx> @@ -63,11 +64,6 @@ using namespace svx; // define ---------------------------------------------------------------- -#define TAB_WIDTH_MIN 10 -#define ITEMID_TYPE 1 -#define ITEMID_USER_PATHS 2 -#define ITEMID_INTERNAL_PATHS 3 - #define POSTFIX_INTERNAL "_internal" #define POSTFIX_USER "_user" #define POSTFIX_WRITABLE "_writable" @@ -79,13 +75,11 @@ using namespace svx; struct OptPath_Impl { SvtDefaultOptions m_aDefOpt; - Image m_aLockImage; OUString m_sMultiPathDlg; Reference< css::util::XPathSettings > m_xPathSettings; - OptPath_Impl(const Image& rLockImage, const OUString& rMultiPathDlg) - : m_aLockImage(rLockImage) - , m_sMultiPathDlg(rMultiPathDlg) + OptPath_Impl() + : m_sMultiPathDlg(CuiResId(RID_SVXSTR_EDIT_PATHS)) { } }; @@ -96,9 +90,14 @@ struct PathUserData_Impl SfxItemState eState; OUString sUserPath; OUString sWritablePath; + bool bReadOnly; - explicit PathUserData_Impl( sal_uInt16 nId ) : - nRealId( nId ), eState( SfxItemState::UNKNOWN ) {} + explicit PathUserData_Impl(sal_uInt16 nId) + : nRealId(nId) + , eState(SfxItemState::UNKNOWN) + , bReadOnly(false) + { + } }; struct Handle2CfgNameMapping_Impl @@ -189,59 +188,27 @@ static bool IsMultiPath_Impl( const sal_uInt16 nIndex ) // class SvxPathTabPage -------------------------------------------------- -SvxPathTabPage::SvxPathTabPage(vcl::Window* pParent, const SfxItemSet& rSet) - : SfxTabPage( pParent, "OptPathsPage", "cui/ui/optpathspage.ui", &rSet) - , pImpl( new OptPath_Impl(get<FixedImage>("lock")->GetImage(), - get<FixedText>("editpaths")->GetText()) ) +SvxPathTabPage::SvxPathTabPage(TabPageParent pParent, const SfxItemSet& rSet) + : SfxTabPage( pParent, "cui/ui/optpathspage.ui", "OptPathsPage", &rSet) + , pImpl(new OptPath_Impl) , xDialogListener ( new ::svt::DialogClosedListener() ) + , m_xStandardBtn(m_xBuilder->weld_button("default")) + , m_xPathBtn(m_xBuilder->weld_button("edit")) + , m_xPathBox(m_xBuilder->weld_tree_view("paths")) { - get(m_pStandardBtn, "default"); - get(m_pPathBtn, "edit"); - get(m_pPathCtrl, "paths"); - - m_pStandardBtn->SetClickHdl(LINK(this, SvxPathTabPage, StandardHdl_Impl)); - m_pPathBtn->SetClickHdl( LINK( this, SvxPathTabPage, PathHdl_Impl ) ); - - Size aControlSize(236 , 147); - aControlSize = LogicToPixel(aControlSize, MapMode(MapUnit::MapAppFont)); - m_pPathCtrl->set_width_request(aControlSize.Width()); - m_pPathCtrl->set_height_request(aControlSize.Height()); - WinBits nBits = WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP; - pPathBox = VclPtr<svx::OptHeaderTabListBox>::Create( *m_pPathCtrl, nBits ); - - HeaderBar &rBar = pPathBox->GetTheHeaderBar(); - rBar.SetSelectHdl( LINK( this, SvxPathTabPage, HeaderSelect_Impl ) ); - rBar.SetEndDragHdl( LINK( this, SvxPathTabPage, HeaderEndDrag_Impl ) ); - - rBar.InsertItem( ITEMID_TYPE, get<FixedText>("type")->GetText(), - 0, - HeaderBarItemBits::LEFT | HeaderBarItemBits::CLICKABLE | HeaderBarItemBits::UPARROW ); - rBar.InsertItem( ITEMID_USER_PATHS, get<FixedText>("user_paths")->GetText(), - 0, - HeaderBarItemBits::LEFT ); - rBar.InsertItem( ITEMID_INTERNAL_PATHS, get<FixedText>("internal_paths")->GetText(), - 0, - HeaderBarItemBits::LEFT ); - - long nWidth1 = rBar.GetTextWidth(rBar.GetItemText(ITEMID_TYPE)); - long nWidth2 = rBar.GetTextWidth(rBar.GetItemText(ITEMID_USER_PATHS)); - long nWidth3 = rBar.GetTextWidth(rBar.GetItemText(ITEMID_INTERNAL_PATHS)); - - long aTabs[] = {0, 0, 0, 0}; - aTabs[1] = nWidth1 + 12; - aTabs[2] = aTabs[1] + nWidth2 + 12; - aTabs[3] = aTabs[2] + nWidth3 + 12; - pPathBox->SetTabs(SAL_N_ELEMENTS(aTabs), aTabs, MapUnit::MapPixel); - - pPathBox->SetDoubleClickHdl( LINK( this, SvxPathTabPage, DoubleClickPathHdl_Impl ) ); - pPathBox->SetSelectHdl( LINK( this, SvxPathTabPage, PathSelect_Impl ) ); - pPathBox->SetSelectionMode( SelectionMode::Multiple ); - pPathBox->SetHighlightRange(); + m_xStandardBtn->connect_clicked(LINK(this, SvxPathTabPage, StandardHdl_Impl)); + m_xPathBtn->connect_clicked( LINK( this, SvxPathTabPage, PathHdl_Impl ) ); + + m_xPathBox->set_size_request(m_xPathBox->get_approximate_digit_width() * 60, + m_xPathBox->get_height_rows(20)); + + m_xPathBox->connect_row_activated( LINK( this, SvxPathTabPage, DoubleClickPathHdl_Impl ) ); + m_xPathBox->connect_changed( LINK( this, SvxPathTabPage, PathSelect_Impl ) ); + m_xPathBox->set_selection_mode(SelectionMode::Multiple); xDialogListener->SetDialogClosedLink( LINK( this, SvxPathTabPage, DialogClosedHdl ) ); } - SvxPathTabPage::~SvxPathTabPage() { disposeOnce(); @@ -249,32 +216,24 @@ SvxPathTabPage::~SvxPathTabPage() void SvxPathTabPage::dispose() { - if ( pPathBox ) - { - for ( sal_uLong i = 0; i < pPathBox->GetEntryCount(); ++i ) - delete static_cast<PathUserData_Impl*>(pPathBox->GetEntry(i)->GetUserData()); - pPathBox.disposeAndClear(); - } - pImpl.reset(); - m_pPathCtrl.clear(); - m_pStandardBtn.clear(); - m_pPathBtn.clear(); + for (int i = 0, nEntryCount = m_xPathBox->n_children(); i < nEntryCount; ++i) + delete reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(i).toInt64()); SfxTabPage::dispose(); } VclPtr<SfxTabPage> SvxPathTabPage::Create( TabPageParent pParent, const SfxItemSet* rAttrSet ) { - return VclPtr<SvxPathTabPage>::Create( pParent.pParent, *rAttrSet ); + return VclPtr<SvxPathTabPage>::Create( pParent, *rAttrSet ); } bool SvxPathTabPage::FillItemSet( SfxItemSet* ) { - for ( sal_uLong i = 0; i < pPathBox->GetEntryCount(); ++i ) + for (int i = 0, nEntryCount = m_xPathBox->n_children(); i < nEntryCount; ++i) { - PathUserData_Impl* pPathImpl = static_cast<PathUserData_Impl*>(pPathBox->GetEntry(i)->GetUserData()); + PathUserData_Impl* pPathImpl = reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(i).toInt64()); sal_uInt16 nRealId = pPathImpl->nRealId; - if ( pPathImpl->eState == SfxItemState::SET ) + if (pPathImpl->eState == SfxItemState::SET) SetPathList( nRealId, pPathImpl->sUserPath, pPathImpl->sWritablePath ); } return true; @@ -282,13 +241,9 @@ bool SvxPathTabPage::FillItemSet( SfxItemSet* ) void SvxPathTabPage::Reset( const SfxItemSet* ) { - pPathBox->Clear(); - - HeaderBar &rBar = pPathBox->GetTheHeaderBar(); - long nWidth1 = rBar.GetTextWidth(rBar.GetItemText(1)); - long nWidth2 = rBar.GetTextWidth(rBar.GetItemText(2)); - long nWidth3 = rBar.GetTextWidth(rBar.GetItemText(3)); + m_xPathBox->clear(); + std::unique_ptr<weld::TreeIter> xIter = m_xPathBox->make_iterator(); for( sal_uInt16 i = 0; i <= sal_uInt16(SvtPathOptions::PATH_CLASSIFICATION); ++i ) { // only writer uses autotext @@ -339,82 +294,66 @@ void SvxPathTabPage::Reset( const SfxItemSet* ) if (pId) { + m_xPathBox->append(xIter.get()); + OUString aStr(CuiResId(pId)); + m_xPathBox->set_text(*xIter, aStr, 0); - nWidth1 = std::max(nWidth1, pPathBox->GetTextWidth(aStr)); - aStr += "\t"; OUString sInternal, sUser, sWritable; bool bReadOnly = false; GetPathList( i, sInternal, sUser, sWritable, bReadOnly ); + + if (bReadOnly) + m_xPathBox->set_image(*xIter, RID_SVXBMP_LOCK); + OUString sTmpPath = sUser; if ( !sTmpPath.isEmpty() && !sWritable.isEmpty() ) sTmpPath += OUStringLiteral1(MULTIPATH_DELIMITER); sTmpPath += sWritable; const OUString aValue = Convert_Impl( sTmpPath ); - nWidth2 = std::max(nWidth2, pPathBox->GetTextWidth(aValue)); - aStr += aValue; - aStr += "\t"; + + m_xPathBox->set_text(*xIter, aValue, 1); + const OUString aValueInternal = Convert_Impl( sInternal ); - nWidth3 = std::max(nWidth3, pPathBox->GetTextWidth(aValueInternal)); - aStr += aValueInternal; - SvTreeListEntry* pEntry = pPathBox->InsertEntry( aStr ); - if ( bReadOnly ) - { - pPathBox->SetCollapsedEntryBmp( pEntry, pImpl->m_aLockImage ); - } + + m_xPathBox->set_text(*xIter, aValueInternal, 2); + + m_xPathBox->set_sensitive(*xIter, !bReadOnly, 0); + m_xPathBox->set_sensitive(*xIter, !bReadOnly, 1); + m_xPathBox->set_sensitive(*xIter, !bReadOnly, 2); + PathUserData_Impl* pPathImpl = new PathUserData_Impl(i); pPathImpl->sUserPath = sUser; pPathImpl->sWritablePath = sWritable; - pEntry->SetUserData( pPathImpl ); + pPathImpl->bReadOnly = bReadOnly; + + OUString sId = OUString::number(reinterpret_cast<sal_Int64>(pPathImpl)); + m_xPathBox->set_id(*xIter, sId); } } - long aTabs[] = {0, 0, 0, 0}; - aTabs[1] = nWidth1 + 12; - aTabs[2] = aTabs[1] + nWidth2 + 12; - aTabs[3] = aTabs[2] + nWidth3 + 12; - pPathBox->SetTabs(SAL_N_ELEMENTS(aTabs), aTabs, MapUnit::MapPixel); - - PathSelect_Impl( nullptr ); -} - -void SvxPathTabPage::FillUserData() -{ - HeaderBar &rBar = pPathBox->GetTheHeaderBar(); - - OUString aUserData = OUString::number( rBar.GetItemSize( ITEMID_TYPE ) ) + ";"; - HeaderBarItemBits nBits = rBar.GetItemBits( ITEMID_TYPE ); - bool bUp = ( ( nBits & HeaderBarItemBits::UPARROW ) == HeaderBarItemBits::UPARROW ); - aUserData += bUp ? OUString("1") : OUString("0"); - SetUserData( aUserData ); + m_xPathBox->columns_autosize(); + PathSelect_Impl(*m_xPathBox); } -IMPL_LINK_NOARG(SvxPathTabPage, PathSelect_Impl, SvTreeListBox*, void) +IMPL_LINK_NOARG(SvxPathTabPage, PathSelect_Impl, weld::TreeView&, void) { - sal_uInt16 nSelCount = 0; - SvTreeListEntry* pEntry = pPathBox->FirstSelected(); - - //the entry image indicates whether the path is write protected - Image aEntryImage; - if(pEntry) - aEntryImage = SvTreeListBox::GetCollapsedEntryBmp( pEntry ); - bool bEnable = !aEntryImage; - while ( pEntry && ( nSelCount < 2 ) ) + bool bEnable = false; + int nEntry = m_xPathBox->get_selected_index(); + if (nEntry != -1) { - nSelCount++; - pEntry = pPathBox->NextSelected( pEntry ); + PathUserData_Impl* pPathImpl = reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(nEntry).toInt64()); + bEnable = !pPathImpl->bReadOnly; } - - m_pPathBtn->Enable( 1 == nSelCount && bEnable); - m_pStandardBtn->Enable( nSelCount > 0 && bEnable); + sal_uInt16 nSelCount = m_xPathBox->count_selected_rows(); + m_xPathBtn->set_sensitive(1 == nSelCount && bEnable); + m_xStandardBtn->set_sensitive(nSelCount > 0 && bEnable); } -IMPL_LINK_NOARG(SvxPathTabPage, StandardHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvxPathTabPage, StandardHdl_Impl, weld::Button&, void) { - SvTreeListEntry* pEntry = pPathBox->FirstSelected(); - while ( pEntry ) - { - PathUserData_Impl* pPathImpl = static_cast<PathUserData_Impl*>(pEntry->GetUserData()); + m_xPathBox->selected_foreach([this](weld::TreeIter& rEntry){ + PathUserData_Impl* pPathImpl = reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(rEntry).toInt64()); OUString aOldPath = pImpl->m_aDefOpt.GetDefaultPath( pPathImpl->nRealId ); if ( !aOldPath.isEmpty() ) @@ -466,27 +405,26 @@ IMPL_LINK_NOARG(SvxPathTabPage, StandardHdl_Impl, Button*, void) sUserPath.append(sToken); } } - pPathBox->SetEntryText( Convert_Impl( sTemp ), pEntry, 1 ); + m_xPathBox->set_text(rEntry, Convert_Impl(sTemp), 1); pPathImpl->eState = SfxItemState::SET; pPathImpl->sUserPath = sUserPath.makeStringAndClear(); pPathImpl->sWritablePath = sWritablePath; } - pEntry = pPathBox->NextSelected( pEntry ); - } + return false; + }); } - void SvxPathTabPage::ChangeCurrentEntry( const OUString& _rFolder ) { - SvTreeListEntry* pEntry = pPathBox->GetCurEntry(); - if ( !pEntry ) + int nEntry = m_xPathBox->get_cursor_index(); + if (nEntry == -1) { SAL_WARN( "cui.options", "SvxPathTabPage::ChangeCurrentEntry(): no entry" ); return; } OUString sInternal, sUser, sWritable; - PathUserData_Impl* pPathImpl = static_cast<PathUserData_Impl*>(pEntry->GetUserData()); + PathUserData_Impl* pPathImpl = reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(nEntry).toInt64()); bool bReadOnly = false; GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly ); sUser = pPathImpl->sUserPath; @@ -511,9 +449,7 @@ void SvxPathTabPage::ChangeCurrentEntry( const OUString& _rFolder ) if ( bChanged ) { - pPathBox->SetEntryText( Convert_Impl( sNewPathStr ), pEntry, 1 ); - sal_uInt16 nPos = static_cast<sal_uInt16>(pPathBox->GetModel()->GetAbsPos( pEntry )); - pPathImpl = static_cast<PathUserData_Impl*>(pPathBox->GetEntry(nPos)->GetUserData()); + m_xPathBox->set_text(nEntry, Convert_Impl(sNewPathStr), 1); pPathImpl->eState = SfxItemState::SET; pPathImpl->sWritablePath = sNewPathStr; if ( SvtPathOptions::PATH_WORK == pPathImpl->nRealId ) @@ -537,33 +473,28 @@ void SvxPathTabPage::ChangeCurrentEntry( const OUString& _rFolder ) } } - -IMPL_LINK_NOARG(SvxPathTabPage, DoubleClickPathHdl_Impl, SvTreeListBox*, bool) +IMPL_LINK_NOARG(SvxPathTabPage, DoubleClickPathHdl_Impl, weld::TreeView&, void) { - PathHdl_Impl(nullptr); - return false; + PathHdl_Impl(*m_xPathBtn); } -IMPL_LINK_NOARG(SvxPathTabPage, PathHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvxPathTabPage, PathHdl_Impl, weld::Button&, void) { - SvTreeListEntry* pEntry = pPathBox->GetCurEntry(); - sal_uInt16 nPos = ( pEntry != nullptr ) ? static_cast<PathUserData_Impl*>(pEntry->GetUserData())->nRealId : 0; + int nEntry = m_xPathBox->get_cursor_index(); + PathUserData_Impl* pPathImpl = nEntry != -1 ? reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(nEntry).toInt64()) : nullptr; + if (!pPathImpl || pPathImpl->bReadOnly) + return; + + sal_uInt16 nPos = pPathImpl->nRealId; OUString sInternal, sUser, sWritable; bool bPickFile = false; - if ( pEntry ) - { - PathUserData_Impl* pPathImpl = static_cast<PathUserData_Impl*>(pEntry->GetUserData()); - bool bReadOnly = false; - GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly ); - sUser = pPathImpl->sUserPath; - sWritable = pPathImpl->sWritablePath; - bPickFile = pPathImpl->nRealId == SvtPathOptions::PATH_CLASSIFICATION; - } - - if(pEntry && !(!SvTreeListBox::GetCollapsedEntryBmp(pEntry))) - return; + bool bReadOnly = false; + GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly ); + sUser = pPathImpl->sUserPath; + sWritable = pPathImpl->sWritablePath; + bPickFile = pPathImpl->nRealId == SvtPathOptions::PATH_CLASSIFICATION; - if ( IsMultiPath_Impl( nPos ) ) + if (IsMultiPath_Impl(nPos)) { SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); ScopedVclPtr<AbstractSvxMultiPathDialog> pMultiDlg( @@ -575,11 +506,11 @@ IMPL_LINK_NOARG(SvxPathTabPage, PathHdl_Impl, Button*, void) sPath += sWritable; pMultiDlg->SetPath( sPath ); - const OUString sPathName = SvTabListBox::GetEntryText( pEntry, 0 ); + const OUString sPathName = m_xPathBox->get_text(nEntry, 0); const OUString sNewTitle = pImpl->m_sMultiPathDlg.replaceFirst( VAR_ONE, sPathName ); pMultiDlg->SetTitle( sNewTitle ); - if ( pMultiDlg->Execute() == RET_OK && pEntry ) + if (pMultiDlg->Execute() == RET_OK) { sUser.clear(); sWritable.clear(); @@ -607,15 +538,14 @@ IMPL_LINK_NOARG(SvxPathTabPage, PathHdl_Impl, Button*, void) sFullPath += sWritable; } - pPathBox->SetEntryText( Convert_Impl( sFullPath ), pEntry, 1 ); + m_xPathBox->set_text(nEntry, Convert_Impl(sFullPath), 1); // save modified flag - PathUserData_Impl* pPathImpl = static_cast<PathUserData_Impl*>(pEntry->GetUserData()); pPathImpl->eState = SfxItemState::SET; pPathImpl->sUserPath = sUser; pPathImpl->sWritablePath = sWritable; } } - else if (pEntry && !bPickFile) + else if (!bPickFile) { try { @@ -644,7 +574,7 @@ IMPL_LINK_NOARG(SvxPathTabPage, PathHdl_Impl, Button*, void) SAL_WARN( "cui.options", "SvxPathTabPage::PathHdl_Impl: exception from folder picker " << exceptionToString(ex) ); } } - else if (pEntry) + else { try { @@ -664,62 +594,6 @@ IMPL_LINK_NOARG(SvxPathTabPage, PathHdl_Impl, Button*, void) } } - -IMPL_LINK( SvxPathTabPage, HeaderSelect_Impl, HeaderBar*, pBar, void ) -{ - if (!pBar || pBar->GetCurItemId() != ITEMID_TYPE) - return; - - HeaderBarItemBits nBits = pBar->GetItemBits(ITEMID_TYPE); - bool bUp = ( ( nBits & HeaderBarItemBits::UPARROW ) == HeaderBarItemBits::UPARROW ); - SvSortMode eMode = SortAscending; - - if ( bUp ) - { - nBits &= ~HeaderBarItemBits::UPARROW; - nBits |= HeaderBarItemBits::DOWNARROW; - eMode = SortDescending; - } - else - { - nBits &= ~HeaderBarItemBits::DOWNARROW; - nBits |= HeaderBarItemBits::UPARROW; - } - pBar->SetItemBits( ITEMID_TYPE, nBits ); - SvTreeList* pModel = pPathBox->GetModel(); - pModel->SetSortMode( eMode ); - pModel->Resort(); -} - - -IMPL_LINK( SvxPathTabPage, HeaderEndDrag_Impl, HeaderBar*, pBar, void ) -{ - if (!pBar || !pBar->GetCurItemId()) - return; - - if ( !pBar->IsItemMode() ) - { - Size aSz; - sal_uInt16 nTabs = pBar->GetItemCount(); - long nTmpSz = 0; - long nWidth = pBar->GetItemSize(ITEMID_TYPE); - long nBarWidth = pBar->GetSizePixel().Width(); - - if(nWidth < TAB_WIDTH_MIN) - pBar->SetItemSize( ITEMID_TYPE, TAB_WIDTH_MIN); - else if ( ( nBarWidth - nWidth ) < TAB_WIDTH_MIN ) - pBar->SetItemSize( ITEMID_TYPE, nBarWidth - TAB_WIDTH_MIN ); - - for ( sal_uInt16 i = 1; i <= nTabs; ++i ) - { - long _nWidth = pBar->GetItemSize(i); - aSz.setWidth( _nWidth + nTmpSz ); - nTmpSz += _nWidth; - pPathBox->SetTab( i, PixelToLogic( aSz, MapMode(MapUnit::MapAppFont) ).Width() ); - } - } -} - IMPL_LINK( SvxPathTabPage, DialogClosedHdl, DialogClosedEvent*, pEvt, void ) { if (RET_OK == pEvt->DialogResult) diff --git a/cui/uiconfig/ui/optpathspage.ui b/cui/uiconfig/ui/optpathspage.ui index 1cfdb9c8bd7e..1bd03de34de0 100644 --- a/cui/uiconfig/ui/optpathspage.ui +++ b/cui/uiconfig/ui/optpathspage.ui @@ -2,7 +2,32 @@ <!-- Generated with glade 3.22.1 --> <interface domain="cui"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name image --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name text1 --> + <column type="gchararray"/> + <!-- column-name text2 --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + <!-- column-name weight1 --> + <column type="gint"/> + <!-- column-name weight2 --> + <column type="gint"/> + <!-- column-name weight3 --> + <column type="gint"/> + <!-- column-name sensitive1 --> + <column type="gboolean"/> + <!-- column-name sensitive2 --> + <column type="gboolean"/> + <!-- column-name sensitive3 --> + <column type="gboolean"/> + </columns> + </object> <object class="GtkBox" id="OptPathsPage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -31,80 +56,77 @@ <property name="can_focus">False</property> <property name="orientation">vertical</property> <child> - <object class="GtkGrid" id="grid1"> - <property name="can_focus">False</property> - <property name="no_show_all">True</property> - <property name="column_homogeneous">True</property> - <child> - <object class="GtkLabel" id="type"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="optpathspage|type">Type</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="user_paths"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="optpathspage|user_paths">User Paths</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="editpaths"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="optpathspage|editpaths">Edit Paths: %1</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkImage" id="lock"> - <property name="can_focus">False</property> - <property name="no_show_all">True</property> - <property name="pixbuf">res/lock.png</property> - </object> - <packing> - <property name="left_attach">4</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="internal_paths"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="optpathspage|internal_paths">Internal Paths</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">0</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="svtlo-SvSimpleTableContainer" id="paths"> + <object class="GtkScrolledWindow" id="pathscroll"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="paths"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Macro Library List-selection2"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext1"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn5"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="optpathspage|type">Type</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer4"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn9"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="optpathspage|user_paths">User Paths</property> + <property name="clickable">True</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer9"/> + <attributes> + <attribute name="text">2</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="title" translatable="yes" context="optpathspage|internal_paths">Internal Paths</property> + <property name="clickable">True</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer1"/> + <attributes> + <attribute name="text">3</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 49db045b2a9d..9f781faf1c1c 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -785,6 +785,7 @@ public: virtual void expand_row(const TreeIter& rIter) = 0; virtual void collapse_row(const TreeIter& rIter) = 0; virtual void set_text(const TreeIter& rIter, const OUString& rStr, int col = -1) = 0; + virtual void set_sensitive(const TreeIter& rIter, bool bSensitive, int col = -1) = 0; virtual void set_image(const TreeIter& rIter, const OUString& rImage, int col = -1) = 0; virtual void set_text_emphasis(const TreeIter& rIter, bool bOn, int col) = 0; virtual bool get_text_emphasis(const TreeIter& rIter, int col) const = 0; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 7ad3a1fd521c..6db8e912378f 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3271,6 +3271,12 @@ public: set_sensitive(pEntry, bSensitive, col); } + virtual void set_sensitive(const weld::TreeIter& rIter, bool bSensitive, int col) override + { + const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); + set_sensitive(rVclIter.iter, bSensitive, col); + } + virtual TriState get_toggle(int pos, int col) const override { SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index f4695e08ded3..f06f818930ad 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -6870,6 +6870,19 @@ private: g_DragSource = nullptr; } + int get_sensitive_model_col(int col) + { + if (col == -1) + col = m_nTextCol; + else + col = get_model_col(col); + col += m_nIdCol + 1; // skip over id column + col += m_aToggleVisMap.size(); // skip over toggle columns + col += m_aToggleTriStateMap.size(); // skip over tristate columns + col += m_aWeightMap.size(); // skip over weight columns + return col; + } + public: GtkInstanceTreeView(GtkTreeView* pTreeView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pTreeView), pBuilder, bTakeOwnership) @@ -7480,15 +7493,13 @@ public: virtual void set_sensitive(int pos, bool bSensitive, int col) override { - if (col == -1) - col = m_nTextCol; - else - col = get_model_col(col); - col += m_nIdCol + 1; // skip over id column - col += m_aToggleVisMap.size(); // skip over toggle columns - col += m_aToggleTriStateMap.size(); // skip over tristate columns - col += m_aWeightMap.size(); // skip over weight columns - set(pos, col, bSensitive); + set(pos, get_sensitive_model_col(col), bSensitive); + } + + virtual void set_sensitive(const weld::TreeIter& rIter, bool bSensitive, int col) override + { + const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter); + set(rGtkIter.iter, get_sensitive_model_col(col), bSensitive); } void set_image(const GtkTreeIter& iter, int col, GdkPixbuf* pixbuf) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
