[Libreoffice-commits] core.git: 2 commits - sw/source vcl/inc vcl/source

2023-05-09 Thread Caolán McNamara (via logerrit)
 sw/source/core/access/acccontext.cxx |7 ++-
 sw/source/core/access/acccontext.hxx |2 ++
 sw/source/core/access/accmap.cxx |4 +++-
 vcl/inc/svdata.hxx   |1 -
 vcl/source/app/svapp.cxx |6 --
 5 files changed, 11 insertions(+), 9 deletions(-)

New commits:
commit 5c73c3aa6875b1e69b2d58a47ba823faf78b8aa2
Author: Caolán McNamara 
AuthorDate: Tue May 9 11:59:40 2023 +0100
Commit: Caolán McNamara 
CommitDate: Tue May 9 20:42:35 2023 +0200

drop unused ImplPrepareExitMsg

Change-Id: I9254328829ac051524fbfdf6a3b5b2f72b12c427
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151574
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 6d1d8adac015..448262492054 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -168,7 +168,6 @@ struct ImplSVAppData
 bool m_bUseSystemLoop = false;
 
 DECL_STATIC_LINK(ImplSVAppData, ImplQuitMsg, void*, void);
-DECL_STATIC_LINK(ImplSVAppData, ImplPrepareExitMsg, void*, void);
 DECL_STATIC_LINK(ImplSVAppData, ImplEndAllDialogsMsg, void*, void);
 DECL_STATIC_LINK(ImplSVAppData, ImplEndAllPopupsMsg, void*, void);
 };
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 4690c534df70..c61d9ea0f2aa 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -339,12 +339,6 @@ void Application::notifyInvalidation(tools::Rectangle 
const* /*pRect*/) const
 {
 }
 
-IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplPrepareExitMsg, void*, void )
-{
-//now close top level frames
-(void)GetpApp()->QueryExit();
-}
-
 void Application::Execute()
 {
 ImplSVData* pSVData = ImplGetSVData();
commit 5e99e5d734f19fe7299a3e390b23a93db971e013
Author: Caolán McNamara 
AuthorDate: Tue May 9 14:16:20 2023 +0100
Commit: Caolán McNamara 
CommitDate: Tue May 9 20:42:22 2023 +0200

Resolves: tdf#138512 don't crash on removing already Disposed a11y context

Change-Id: I2a8f3d10a1349de233e11d841f7f244e4e513b2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151582
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/source/core/access/acccontext.cxx 
b/sw/source/core/access/acccontext.cxx
index 37cb87fb3114..3445114b2d78 100644
--- a/sw/source/core/access/acccontext.cxx
+++ b/sw/source/core/access/acccontext.cxx
@@ -518,9 +518,14 @@ bool SwAccessibleContext::IsEditableState()
 return bRet;
 }
 
+bool SwAccessibleContext::IsDisposed() const
+{
+return !(GetFrame() && GetMap());
+}
+
 void SwAccessibleContext::ThrowIfDisposed()
 {
-if (!(GetFrame() && GetMap()))
+if (IsDisposed())
 {
 throw lang::DisposedException("object is nonfunctional",
 static_cast(this));
diff --git a/sw/source/core/access/acccontext.hxx 
b/sw/source/core/access/acccontext.hxx
index 32d13efbf513..d64939089622 100644
--- a/sw/source/core/access/acccontext.hxx
+++ b/sw/source/core/access/acccontext.hxx
@@ -349,6 +349,8 @@ public:
 virtual bool SetSelectedState(bool bSelected);
 bool  IsSelectedInDoc() const { return m_isSelectedInDoc; }
 
+bool IsDisposed() const;
+
 static OUString GetResource(TranslateId pResId,
 const OUString *pArg1 = nullptr,
 const OUString *pArg2 = nullptr);
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index fe0384ca0ea2..5cc2fd73801b 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -2673,7 +2673,9 @@ void SwAccessibleMap::InvalidateCursorPosition( const 
SwFrame *pFrame )
 
 for (SwAccessibleParagraph* pAccPara : m_setParaRemove)
 {
-if(pAccPara && pAccPara->getSelectedAccessibleChildCount() == 0 && 
pAccPara->getSelectedText().getLength() == 0)
+if (pAccPara && !pAccPara->IsDisposed() &&
+pAccPara->getSelectedAccessibleChildCount() == 0 &&
+pAccPara->getSelectedText().getLength() == 0)
 {
 if(pAccPara->SetSelectedState(false))
 {


[Libreoffice-commits] core.git: 2 commits - sw/source vcl/inc vcl/source

2017-11-16 Thread Noel Grandin
 sw/source/uibase/config/uinums.cxx |   29 +++--
 sw/source/uibase/inc/uinums.hxx|6 +++---
 vcl/inc/sallayout.hxx  |3 ++-
 vcl/source/gdi/sallayout.cxx   |   10 --
 4 files changed, 20 insertions(+), 28 deletions(-)

New commits:
commit 54604f01330063635fb974b0ab4335d6af851551
Author: Noel Grandin 
Date:   Thu Nov 16 09:51:25 2017 +0200

loplugin:useuniqueptr in SwNumRulesWithName

Change-Id: If539e9a3d859cea034d53690fdad746479a9f548
Reviewed-on: https://gerrit.libreoffice.org/44820
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/sw/source/uibase/config/uinums.cxx 
b/sw/source/uibase/config/uinums.cxx
index 24c79ddc2c79..3b7f3e35e10c 100644
--- a/sw/source/uibase/config/uinums.cxx
+++ b/sw/source/uibase/config/uinums.cxx
@@ -73,14 +73,12 @@ void SwChapterNumRules::Save()
 
 SwChapterNumRules::~SwChapterNumRules()
 {
-for(SwNumRulesWithName* pNumRule : pNumRules)
-delete pNumRule;
 }
 
 void  SwChapterNumRules::Init()
 {
-for(SwNumRulesWithName* & rpNumRule : pNumRules)
-rpNumRule = nullptr;
+for(auto & rpNumRule : pNumRules)
+rpNumRule.reset();
 
 OUString sNm(CHAPTER_FILENAME);
 SvtPathOptions aOpt;
@@ -96,14 +94,14 @@ void SwChapterNumRules::CreateEmptyNumRule(sal_uInt16 const 
nIndex)
 {
 assert(nIndex < nMaxRules);
 assert(!pNumRules[nIndex]);
-pNumRules[nIndex] = new SwNumRulesWithName;
+pNumRules[nIndex].reset(new SwNumRulesWithName);
 }
 
 void SwChapterNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, 
sal_uInt16 nIdx)
 {
 assert(nIdx < nMaxRules);
 if( !pNumRules[nIdx] )
-pNumRules[nIdx] = new SwNumRulesWithName( rCopy );
+pNumRules[nIdx].reset(new SwNumRulesWithName( rCopy ));
 else
 *pNumRules[nIdx] = rCopy;
 Save(); // store it immediately
@@ -117,9 +115,9 @@ SwNumRulesWithName::SwNumRulesWithName( const SwNumRule 
&rCopy,
 {
 const SwNumFormat* pFormat = rCopy.GetNumFormat( n );
 if( pFormat )
-aFormats[ n ] = new SwNumFormatGlobal( *pFormat );
+aFormats[ n ].reset(new SwNumFormatGlobal( *pFormat ));
 else
-aFormats[ n ] = nullptr;
+aFormats[ n ].reset();
 }
 }
 
@@ -136,8 +134,6 @@ SwNumRulesWithName::SwNumRulesWithName( const 
SwNumRulesWithName& rCopy )
 
 SwNumRulesWithName::~SwNumRulesWithName()
 {
-for(SwNumFormatGlobal* p : aFormats)
-delete p;
 }
 
 SwNumRulesWithName& SwNumRulesWithName::operator=(const SwNumRulesWithName 
&rCopy)
@@ -147,13 +143,11 @@ SwNumRulesWithName& SwNumRulesWithName::operator=(const 
SwNumRulesWithName &rCop
 maName = rCopy.maName;
 for( int n = 0; n < MAXLEVEL; ++n )
 {
-delete aFormats[ n ];
-
-SwNumFormatGlobal* pFormat = rCopy.aFormats[ n ];
+SwNumFormatGlobal* pFormat = rCopy.aFormats[ n ].get();
 if( pFormat )
-aFormats[ n ] = new SwNumFormatGlobal( *pFormat );
+aFormats[ n ].reset(new SwNumFormatGlobal( *pFormat ));
 else
-aFormats[ n ] = nullptr;
+aFormats[ n ].reset();
 }
 }
 return *this;
@@ -166,7 +160,7 @@ SwNumRule* SwNumRulesWithName::MakeNumRule(SwWrtShell& rSh) 
const
 pChg->SetAutoRule( false );
 for (sal_uInt16 n = 0; n < MAXLEVEL; ++n)
 {
-SwNumFormatGlobal* pFormat = aFormats[ n ];
+SwNumFormatGlobal* pFormat = aFormats[ n ].get();
 if (!pFormat)
 continue;
 pChg->Set(n, pFormat->MakeNumFormat(rSh));
@@ -184,8 +178,7 @@ void SwNumRulesWithName::GetNumFormat(
 void SwNumRulesWithName::SetNumFormat(
 size_t const nIndex, SwNumFormat const& rNumFormat, OUString const& 
rName)
 {
-delete aFormats[nIndex];
-aFormats[nIndex] = new SwNumFormatGlobal(rNumFormat);
+aFormats[nIndex].reset( new SwNumFormatGlobal(rNumFormat) );
 aFormats[nIndex]->sCharFormatName = rName;
 aFormats[nIndex]->nCharPoolId = USHRT_MAX;
 aFormats[nIndex]->m_Items.clear();
diff --git a/sw/source/uibase/inc/uinums.hxx b/sw/source/uibase/inc/uinums.hxx
index 9ccbddcae512..3e5767c4d87a 100644
--- a/sw/source/uibase/inc/uinums.hxx
+++ b/sw/source/uibase/inc/uinums.hxx
@@ -56,7 +56,7 @@ class SW_DLLPUBLIC SwNumRulesWithName final
 SwNumFormat MakeNumFormat(SwWrtShell& rSh) const;
 };
 
-SwNumFormatGlobal* aFormats[ MAXLEVEL ];
+std::unique_ptr aFormats[ MAXLEVEL ];
 
 friend class sw::StoredChapterNumberingRules;
 friend class SwChapterNumRules;
@@ -82,7 +82,7 @@ class SW_DLLPUBLIC SwChapterNumRules final
 public:
 enum { nMaxRules = MAX_NUM_RULES }; // currently 9 defined forms
 private:
-SwNumRulesWithName   *pNumRules[ MAX_NUM_RULES ];
+std::unique_ptr pNumRules[ MAX_NUM_RULES ];
 
 void Init();
 void Save();
@@ -100,7 +100,7 @@ public:
 inline const SwNumRulesWithName *SwChapterNumRul

[Libreoffice-commits] core.git: 2 commits - sw/source vcl/inc vcl/source

2013-03-01 Thread Caolán McNamara
 sw/source/core/view/viewsh.cxx |2 -
 vcl/inc/vcl/layout.hxx |   13 +++-
 vcl/source/window/builder.cxx  |   24 +-
 vcl/source/window/layout.cxx   |   43 ++---
 4 files changed, 68 insertions(+), 14 deletions(-)

New commits:
commit 16d7194ee73786c212e8639d41c7c31735ca930a
Author: Caolán McNamara 
Date:   Fri Mar 1 16:15:05 2013 +

sort frame labels before frame contents for tab traversal

If there is more than one widget with the same mnemonic, and one is a frame
label, then we need to sort frame labels before frame bodies in the tab
traversal order. Otherwise if the focus is in the body of a frame whose 
label
has that shortcut and the shortcut is pressed again, the traversal through
following widgets will encounter the frame label as the next candidate, 
leading
back to the starting point and not onwards to the next widget using that
shortcut.

Frame labels have type "label" in the .ui, so suck that out to designate 
which
widget is the frame label at load time.

Change-Id: Ie21ed87867bd0c983981a3a8f3318b3cf598c1d6

diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx
index 239e84c..457a389 100644
--- a/vcl/inc/vcl/layout.hxx
+++ b/vcl/inc/vcl/layout.hxx
@@ -436,9 +436,20 @@ public:
 
 class VCL_DLLPUBLIC VclFrame : public VclBin
 {
+private:
+Window *m_pLabel;
+private:
+friend class VclBuilder;
+void designate_label(Window *pWindow);
 public:
-VclFrame(Window *pParent) : VclBin(pParent) {}
+VclFrame(Window *pParent)
+: VclBin(pParent)
+, m_pLabel(NULL)
+{
+}
 void set_label(const OUString &rLabel);
+virtual Window *get_child();
+virtual const Window *get_child() const;
 Window *get_label_widget();
 const Window *get_label_widget() const;
 protected:
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 8654b65..3716a02 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1425,7 +1425,20 @@ bool 
VclBuilder::sortIntoBestTabTraversalOrder::operator()(const Window *pA, con
 return false;
 }
 //honour relative box positions with pack group
-return m_pBuilder->get_window_packing_data(pA).m_nPosition < 
m_pBuilder->get_window_packing_data(pB).m_nPosition;
+bPackA = m_pBuilder->get_window_packing_data(pA).m_nPosition;
+bPackB = m_pBuilder->get_window_packing_data(pB).m_nPosition;
+if (bPackA < bPackB)
+return true;
+if (bPackA > bPackB)
+return false;
+//sort labels of Frames before body
+if (pA->GetParent() == pB->GetParent())
+{
+const VclFrame *pFrameParent = dynamic_cast(pA->GetParent());
+if (pFrameParent && pA == pFrameParent->get_label_widget())
+return true;
+}
+return false;
 }
 
 void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader)
@@ -1487,6 +1500,15 @@ void VclBuilder::handleChild(Window *pParent, 
xmlreader::XmlReader &reader)
 }
 else
 {
+// We want to sort labels before contents of frames
+// for key board traversal, especially if there
+// are multiple widgets using the same mnemonic
+if (sType.equals("label"))
+{
+if (VclFrame *pFrameParent = 
dynamic_cast(pParent))
+pFrameParent->designate_label(pCurrentChild);
+}
+
 //To-Do make reorder a virtual in Window, move this foo
 //there and see above
 std::vector aChilds;
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 934e08e..88790f3 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1088,10 +1088,8 @@ Size VclFrame::calculateRequisition() const
 {
 Size aRet(0, 0);
 
-WindowImpl* pWindowImpl = ImplGetWindowImpl();
-
 const Window *pChild = get_child();
-const Window *pLabel = pChild != pWindowImpl->mpLastChild ? 
pWindowImpl->mpLastChild : NULL;
+const Window *pLabel = get_label_widget();
 
 if (pChild && pChild->IsVisible())
 aRet = getLayoutRequisition(*pChild);
@@ -1121,11 +1119,8 @@ void VclFrame::setAllocation(const Size &rAllocation)
 rAllocation.Height() - rFrameStyle.top - rFrameStyle.bottom);
 Point aChildPos(rFrameStyle.left, rFrameStyle.top);
 
-WindowImpl* pWindowImpl = ImplGetWindowImpl();
-
-//The label widget is the last (of two) children
 Window *pChild = get_child();
-Window *pLabel = pChild != pWindowImpl->mpLastChild ? 
pWindowImpl->mpLastChild : NULL;
+Window *pLabel = get_label_widget();
 
 if (pLabel && pLabel->IsVisible())
 {
@@ -1141,12 +1136,22 @@ void VclFrame::setAllocati