[Libreoffice-commits] core.git: Branch 'feature/window-iter' - 35 commits - chart2/IwyuFilter_chart2.yaml chart2/source editeng/source hwpfilter/source icon-themes/elementary icon-themes/elementary_svg include/oox include/toolkit include/tools include/ucbhelper include/unoidl include/vcl lotuswordpro/inc lotuswordpro/source oox/source reportdesign/source sc/source sc/uiconfig sd/source sfx2/qa sfx2/source sw/CppunitTest_sw_unoapi.mk sw/inc sw/Module_sw.mk sw/qa sw/source toolkit/inc toolkit/source tools/source ucbhelper/source ucb/source UnoControls/source unoidl/source vcl/source writerfilter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Sep 27 09:19:57 UTC 2018
Rebased ref, commits from common ancestor:
commit b9dc80d02224845727be76ab5655ec8fd8771d98
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Sep 26 17:33:22 2018 +0200
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 27 09:11:25 2018 +0000
Debug infrastructure
Change-Id: Idd09c131240c1372a40c36feb07094e28c2a1581
diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx
index af70f4bbc484..f27e4b44424f 100644
--- a/vcl/source/window/dlgctrl.cxx
+++ b/vcl/source/window/dlgctrl.cxx
@@ -35,6 +35,13 @@
#include <com/sun/star/i18n/XCharacterClassification.hpp>
+// #define ITER_ONLY
+#define DUMP_ITER
+// #define DUMP_SUBCHILD
+#define DUMP_IMPL_FIND_DLGCTRL
+#define DUMP_IMPL_DLGCTL
+#define DUMP_UPDATE_DEF_BUTTON
+
using namespace ::com::sun::star;
static bool ImplHasIndirectTabParent( vcl::Window* pWindow )
@@ -119,14 +126,23 @@ public:
, m_bCurrentWindowMayHaveChildren(true)
, m_bIsTabControl(false)
{
+#ifdef DUMP_ITER
+ SAL_DEBUG("Iter construct start " << m_pRealParent << " " << pWindow << " " << m_bTestEnabled);
+#endif
vcl::Window* pRealWindow = m_pRealParent->ImplGetWindow();
if (pRealWindow->GetType() == WindowType::TABCONTROL)
m_bIsTabControl = true;
++(*this);
+#ifdef DUMP_ITER
+ SAL_DEBUG("Iter construct end " << m_bIsTabControl);
+#endif
}
WindowIterator& operator++()
{
+#ifdef DUMP_ITER
+ SAL_DEBUG("++ In");
+#endif
vcl::Window* pWindow = nullptr;
vcl::Window* pNextWindow = m_pCurrentWindow;
vcl::Window* pParent = nullptr;
@@ -138,27 +154,50 @@ public:
// check if pNextWindow has children => not in dispose
pWindow = firstLogicalChildOfParent(pNextWindow);
if (pWindow)
+ {
pWindow = ImplGetCurTabWindow(pNextWindow->ImplGetWindow());
+#ifdef DUMP_ITER
+ SAL_DEBUG("ImplGetTabWindow " << pNextWindow->ImplGetWindow() << " >> " << pWindow);
+#endif
+ }
}
else if (m_bCurrentWindowMayHaveChildren)
+ {
pWindow = firstLogicalChildOfParent(pNextWindow);
+#ifdef DUMP_ITER
+ SAL_DEBUG("firstLogicalChildOfParent " << pNextWindow << " => " << pWindow << " (" << (pWindow ? pWindow->ImplGetWindow() : nullptr) << ")");
+#endif
+ }
if (!pWindow)
{
+#ifdef DUMP_ITER
+ SAL_DEBUG("!window " << pNextWindow);
+#endif
while (true)
{
assert(!pWindow);
pParent = getNonLayoutParent(pNextWindow);
+#ifdef DUMP_ITER
+ SAL_DEBUG("getNonLayoutParent " << pNextWindow << " >> " << pParent);
+#endif
if (pNextWindow == m_pParent || !pParent)
break;
if (pParent->ImplGetWindow()->GetType() == WindowType::TABCONTROL)
{
+#ifdef DUMP_ITER
+ SAL_DEBUG("IsTabcontrol " << pParent << " (" << pParent->ImplGetWindow() << ")");
+#endif
pNextWindow = pParent;
continue;
}
pWindow = nextLogicalChildOfParent(pParent, pNextWindow);
+#ifdef DUMP_ITER
+ SAL_DEBUG("nextLogicalChildOfParent " << pParent << " " << pNextWindow << " >> " << pWindow
+ << " (" << (pWindow ? pWindow->ImplGetWindow() : nullptr) << ")");
+#endif
if (!pWindow)
{
pNextWindow = pParent;
@@ -174,6 +213,9 @@ public:
}
}
}
+#ifdef DUMP_ITER
+ SAL_DEBUG("!window end " << pWindow);
+#endif
if (!pWindow)
break;
}
@@ -188,6 +230,9 @@ public:
{
m_bIsTabControl = (pRealWindow->GetType() == WindowType::TABCONTROL);
m_bCurrentWindowMayHaveChildren = pRealWindow->GetStyle() & (WB_DIALOGCONTROL | WB_CHILDDLGCTRL);
+#ifdef DUMP_ITER
+ SAL_DEBUG("isVisibleInLayout " << pWindow << " " << m_bCurrentWindowMayHaveChildren << " " << m_bIsTabControl);
+#endif
if (m_bCurrentWindowMayHaveChildren && !m_bIsTabControl)
continue;
else
@@ -200,10 +245,17 @@ public:
}
pWindow = nextLogicalChildOfParent(pParent, pNextWindow);
+#ifdef DUMP_ITER
+ SAL_DEBUG("nextLogicalChildOfParent " << pParent << " " << pNextWindow << " >> " << pWindow
+ << " (" << (pWindow ? pWindow->ImplGetWindow() : nullptr) << ")");
+#endif
if (pWindow)
pNextWindow = pWindow;
}
+#ifdef DUMP_ITER
+ SAL_DEBUG("++ >> " << pWindow);
+#endif
m_pCurrentParent = pParent;
m_pCurrentWindow = pWindow;
return *this;
@@ -265,7 +317,12 @@ static vcl::Window* ImplGetSubChildWindow( vcl::Window* pParent, sal_uInt16 n, s
}
if ( n == nIndex )
+ {
+#ifdef DUMP_SUBCHILD
+ SAL_DEBUG("1. " << nIndex << " " << pFoundWindow);
+#endif
return pFoundWindow;
+ }
nIndex++;
}
@@ -279,6 +336,9 @@ static vcl::Window* ImplGetSubChildWindow( vcl::Window* pParent, sal_uInt16 n, s
}
nIndex--;
+#ifdef DUMP_SUBCHILD
+ SAL_DEBUG("2. " << nIndex << " " << pFoundWindow);
+#endif
return pFoundWindow;
}
@@ -445,6 +505,10 @@ vcl::Window* ImplFindDlgCtrlWindow( vcl::Window* pParent, vcl::Window* pWindow,
sal_uInt16 nSecondFormStart = 0;
sal_uInt16 nFormEnd;
+#ifdef DUMP_IMPL_FIND_DLGCTRL
+ SAL_DEBUG("ImplFindDlgCtrlWindow " << pParent << " " << pWindow);
+#endif
+
// find focus window in the child list
vcl::Window* pFirstChildWindow = pSWindow = ImplGetChildWindow( pParent, 0, i, false );
@@ -461,6 +525,9 @@ vcl::Window* ImplFindDlgCtrlWindow( vcl::Window* pParent, vcl::Window* pWindow,
// SecondWindow for composite controls like ComboBoxes and arrays
if ( pSWindow->ImplIsWindowOrChild( pWindow ) )
{
+#ifdef DUMP_IMPL_FIND_DLGCTRL
+ SAL_DEBUG("SecondWindow");
+#endif
pSecondWindow = pSWindow;
nSecond_i = i;
nSecondFormStart = nFormStart;
@@ -471,8 +538,17 @@ vcl::Window* ImplFindDlgCtrlWindow( vcl::Window* pParent, vcl::Window* pWindow,
pSWindow = ImplGetNextWindow( pParent, i, i, false );
if ( !i )
pSWindow = nullptr;
+#ifdef DUMP_IMPL_FIND_DLGCTRL
+ else
+ SAL_DEBUG("1 " << pSWindow << " " << i);
+#endif
}
+#ifdef DUMP_IMPL_FIND_DLGCTRL
+ if ( pSWindow )
+ SAL_DEBUG("2 " << pSWindow << " " << i);
+#endif
+
if ( !pSWindow )
{
// Window not found; we cannot handle it
@@ -503,6 +579,10 @@ vcl::Window* ImplFindDlgCtrlWindow( vcl::Window* pParent, vcl::Window* pWindow,
&& pTempWindow->ImplGetWindow()->IsDialogControlStart() ) )
break;
+#ifdef DUMP_IMPL_FIND_DLGCTRL
+ SAL_DEBUG("3 " << pTempWindow << " " << i);
+#endif
+
if ( pTempWindow && pTempWindow == pFirstChildWindow )
{
// It is possible to go through the begin of hierarchy once
@@ -730,6 +810,10 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput )
vcl::Window* pTempWindow;
vcl::Window* pButtonWindow;
sal_uInt16 i;
+#ifndef ITER_ONLY
+ sal_uInt16 iButton;
+ sal_uInt16 iButtonStart;
+#endif
sal_uInt16 iTemp;
sal_uInt16 nIndex;
sal_uInt16 nFormStart;
@@ -761,15 +845,43 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput )
pButtonWindow = nullptr;
+#ifdef DUMP_IMPL_DLGCTL
+ SAL_DEBUG("Window::ImplDlgCtrl");
+#endif
if ( nKeyCode == KEY_RETURN )
{
// search first for a DefPushButton
WindowIterator aIter(this, pFocusWindow, true);
+#ifdef ITER_ONLY
for (; *aIter; ++aIter)
if ( (aIter->GetStyle() & WB_DEFBUTTON) &&
aIter->mpWindowImpl->mbPushButton )
break;
pButtonWindow = *aIter;
+#else
+ pButtonWindow = ImplGetChildWindow(this, nFormStart, iButton, true);
+ iButtonStart = iButton;
+#ifdef DUMP_IMPL_DLGCTL
+ SAL_DEBUG("iter start: " << nFormStart << " " << iButton << " " << this << " " << pFocusWindow);
+ SAL_DEBUG("old: " << pButtonWindow << " new: " << *aIter);
+#endif
+ assert(pButtonWindow == *aIter);
+ while ( pButtonWindow )
+ {
+ if ( (pButtonWindow->GetStyle() & WB_DEFBUTTON) &&
+ pButtonWindow->mpWindowImpl->mbPushButton )
+ break;
+
+ pButtonWindow = ImplGetNextWindow( this, iButton, iButton, true );
+ if ( (iButton <= iButtonStart) || (iButton > nFormEnd) )
+ pButtonWindow = nullptr;
+ ++aIter;
+#ifdef DUMP_IMPL_DLGCTL
+ SAL_DEBUG("old: " << pButtonWindow << " new: " << *aIter);
+#endif
+ assert(pButtonWindow == *aIter);
+ }
+#endif // !ITER_ONLY
if ( bKeyInput && !pButtonWindow && (nDlgCtrlFlags & DialogControlFlags::Return) )
{
@@ -835,10 +947,34 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput )
{
// search first for a CancelButton
WindowIterator aIter(this, pFocusWindow, true);
+#ifdef ITER_ONLY
for (; *aIter; ++aIter)
if (aIter->GetType() == WindowType::CANCELBUTTON)
break;
pButtonWindow = *aIter;
+#else
+ pButtonWindow = ImplGetChildWindow(this, nFormStart, iButton, true);
+ iButtonStart = iButton;
+#ifdef DUMP_IMPL_DLGCTL
+ SAL_DEBUG("iter start: " << nFormStart << " " << iButton << " " << this << " " << pFocusWindow);
+ SAL_DEBUG("old: " << pButtonWindow << " new: " << *aIter);
+#endif
+ assert(pButtonWindow == *aIter);
+ while ( pButtonWindow )
+ {
+ if ( pButtonWindow->GetType() == WindowType::CANCELBUTTON )
+ break;
+
+ pButtonWindow = ImplGetNextWindow( this, iButton, iButton, true );
+ if ( (iButton <= iButtonStart) || (iButton > nFormEnd) )
+ pButtonWindow = nullptr;
+ ++aIter;
+#ifdef DUMP_IMPL_DLGCTL
+ SAL_DEBUG("old: " << pButtonWindow << " new: " << *aIter);
+#endif
+ assert(pButtonWindow == *aIter);
+ }
+#endif // !ITER_ONLY
if ( bKeyInput && mpWindowImpl->mpDlgCtrlDownWindow )
{
@@ -868,7 +1004,13 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput )
// search group
vcl::Window* pFormularFirstWindow = nullptr;
vcl::Window* pLastFormularFirstWindow = nullptr;
+ WindowIterator aIter(this, nullptr, false);
pTempWindow = ImplGetChildWindow( this, 0, iTemp, false );
+#ifdef DUMP_IMPL_DLGCTL
+ SAL_DEBUG("iter start: " << iTemp << " " << i << " " << this);
+ SAL_DEBUG("old: " << pTempWindow << " new: " << *aIter);
+#endif
+ assert(pTempWindow == *aIter);
vcl::Window* pPrevFirstFormularFirstWindow = nullptr;
vcl::Window* pFirstFormularFirstWindow = pTempWindow;
while ( pTempWindow )
@@ -891,9 +1033,14 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput )
pLastFormularFirstWindow = pTempWindow;
}
+ ++aIter;
pTempWindow = ImplGetNextWindow( this, iTemp, iTemp, false );
if ( !iTemp )
pTempWindow = nullptr;
+#ifdef DUMP_IMPL_DLGCTL
+ SAL_DEBUG("old: " << pTempWindow << " new: " << *aIter);
+#endif
+ assert(pTempWindow == *aIter);
}
if ( bFormular )
@@ -1139,7 +1286,18 @@ static void ImplDlgCtrlUpdateDefButton( vcl::Window* pParent, vcl::Window* pFocu
nFormEnd = 0xFFFF;
}
+ WindowIterator aIter(pParent, pFocusWindow, false);
+#ifdef ITER_ONLY
+ pSWindow = *aIter;
+#else
pSWindow = ImplGetChildWindow( pParent, nFormStart, i, false );
+#endif
+#ifdef DUMP_UPDATE_DEF_BUTTON
+ SAL_DEBUG("ImplDlgCtrlUpdateDefButton");
+ SAL_DEBUG("iter start: " << nFormStart << " " << i << " " << pParent << " " << pFocusWindow << " " << pSWindow);
+ SAL_DEBUG("old: " << pSWindow << " new: " << *aIter);
+#endif
+ assert(pSWindow == *aIter);
while ( pSWindow )
{
if ( pSWindow->ImplIsPushButton() )
@@ -1153,9 +1311,18 @@ static void ImplDlgCtrlUpdateDefButton( vcl::Window* pParent, vcl::Window* pFocu
pNewDefButton = pPushButton;
}
+ ++aIter;
+#ifdef ITER_ONLY
+ pSWindow = *aIter;
+#else
pSWindow = ImplGetNextWindow( pParent, i, i, false );
if ( !i || (i > nFormEnd) )
pSWindow = nullptr;
+#endif
+#ifdef DUMP_UPDATE_DEF_BUTTON
+ SAL_DEBUG("old: " << pSWindow << " new: " << *aIter << " " << i);
+#endif
+ assert(pSWindow == *aIter);
}
if ( !bGetFocus )
commit e9569427271eade5dedb66db0fccd4521ddbb631
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Sep 26 14:16:09 2018 +0200
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 27 09:08:00 2018 +0000
Initial vcl::Window iterator
Change-Id: I414d9eb3539d6a2a8844e24a7ef245fa99935f1b
diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx
index 6efbe1f39eb1..af70f4bbc484 100644
--- a/vcl/source/window/dlgctrl.cxx
+++ b/vcl/source/window/dlgctrl.cxx
@@ -92,6 +92,141 @@ static vcl::Window* ImplGetCurTabWindow(const vcl::Window* pWindow)
return nullptr;
}
+namespace {
+
+class WindowIterator
+ : public std::iterator<std::forward_iterator_tag, vcl::Window*>
+{
+ const value_type m_pParent, m_pRealParent, m_pWindow;
+ const bool m_bTestEnabled;
+ value_type m_pCurrentWindow, m_pCurrentParent;
+ bool m_bCurrentWindowMayHaveChildren;
+ bool m_bIsTabControl;
+
+ inline bool IsEnabled(value_type pWindow)
+ {
+ return (!m_bTestEnabled || (isEnabledInLayout(pWindow) && pWindow->IsInputEnabled()));
+ }
+
+public:
+ explicit WindowIterator(value_type pParent, value_type pWindow, bool bEnabled)
+ : m_pParent(pParent)
+ , m_pRealParent(ImplGetTopParentOfTabHierarchy(pParent))
+ , m_pWindow(pWindow)
+ , m_bTestEnabled(bEnabled)
+ , m_pCurrentWindow(m_pRealParent)
+ , m_pCurrentParent(nullptr)
+ , m_bCurrentWindowMayHaveChildren(true)
+ , m_bIsTabControl(false)
+ {
+ vcl::Window* pRealWindow = m_pRealParent->ImplGetWindow();
+ if (pRealWindow->GetType() == WindowType::TABCONTROL)
+ m_bIsTabControl = true;
+ ++(*this);
+ }
+
+ WindowIterator& operator++()
+ {
+ vcl::Window* pWindow = nullptr;
+ vcl::Window* pNextWindow = m_pCurrentWindow;
+ vcl::Window* pParent = nullptr;
+
+ while (true)
+ {
+ if (m_bIsTabControl)
+ {
+ // check if pNextWindow has children => not in dispose
+ pWindow = firstLogicalChildOfParent(pNextWindow);
+ if (pWindow)
+ pWindow = ImplGetCurTabWindow(pNextWindow->ImplGetWindow());
+ }
+ else if (m_bCurrentWindowMayHaveChildren)
+ pWindow = firstLogicalChildOfParent(pNextWindow);
+
+ if (!pWindow)
+ {
+ while (true)
+ {
+ assert(!pWindow);
+ pParent = getNonLayoutParent(pNextWindow);
+ if (pNextWindow == m_pParent || !pParent)
+ break;
+
+ if (pParent->ImplGetWindow()->GetType() == WindowType::TABCONTROL)
+ {
+ pNextWindow = pParent;
+ continue;
+ }
+
+ pWindow = nextLogicalChildOfParent(pParent, pNextWindow);
+ if (!pWindow)
+ {
+ pNextWindow = pParent;
+ }
+ else
+ {
+ if (!ImplHasIndirectTabParent(pWindow) && pWindow->ImplGetWindow()->IsDialogControlStart())
+ pWindow = nullptr;
+ else
+ {
+ pNextWindow = pWindow;
+ break;
+ }
+ }
+ }
+ if (!pWindow)
+ break;
+ }
+ else if (m_bCurrentWindowMayHaveChildren || m_bIsTabControl)
+ {
+ pParent = pNextWindow;
+ pNextWindow = pWindow;
+ }
+
+ vcl::Window* pRealWindow = pWindow->ImplGetWindow();
+ if (isVisibleInLayout(pRealWindow) && IsEnabled(pWindow))
+ {
+ m_bIsTabControl = (pRealWindow->GetType() == WindowType::TABCONTROL);
+ m_bCurrentWindowMayHaveChildren = pRealWindow->GetStyle() & (WB_DIALOGCONTROL | WB_CHILDDLGCTRL);
+ if (m_bCurrentWindowMayHaveChildren && !m_bIsTabControl)
+ continue;
+ else
+ break;
+ }
+ else
+ {
+ m_bCurrentWindowMayHaveChildren = false;
+ m_bIsTabControl = false;
+ }
+
+ pWindow = nextLogicalChildOfParent(pParent, pNextWindow);
+ if (pWindow)
+ pNextWindow = pWindow;
+ }
+
+ m_pCurrentParent = pParent;
+ m_pCurrentWindow = pWindow;
+ return *this;
+ }
+ WindowIterator operator++(int)
+ { WindowIterator retval = *this; ++(*this); return retval; }
+
+ bool operator==(WindowIterator other) const { return m_pCurrentWindow == other.m_pCurrentWindow; }
+ bool operator!=(WindowIterator other) const { return m_pCurrentWindow != other.m_pCurrentWindow; }
+ value_type operator*() const { return m_pCurrentWindow ? m_pCurrentWindow->ImplGetWindow() : nullptr; }
+ value_type operator->() const { return this->operator*(); }
+ WindowIterator begin()
+ { return WindowIterator(m_pParent, m_pWindow, m_bTestEnabled); }
+ WindowIterator end()
+ {
+ WindowIterator aEnd(m_pParent, m_pWindow, m_bTestEnabled);
+ aEnd.m_pCurrentWindow = nullptr;
+ return aEnd;
+ }
+};
+
+};
+
static vcl::Window* ImplGetSubChildWindow( vcl::Window* pParent, sal_uInt16 n, sal_uInt16& nIndex )
{
vcl::Window* pTabPage = nullptr;
@@ -595,8 +730,6 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput )
vcl::Window* pTempWindow;
vcl::Window* pButtonWindow;
sal_uInt16 i;
- sal_uInt16 iButton;
- sal_uInt16 iButtonStart;
sal_uInt16 iTemp;
sal_uInt16 nIndex;
sal_uInt16 nFormStart;
@@ -630,19 +763,13 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput )
if ( nKeyCode == KEY_RETURN )
{
- // search first for a DefPushButton/CancelButton
- pButtonWindow = ImplGetChildWindow( this, nFormStart, iButton, true );
- iButtonStart = iButton;
- while ( pButtonWindow )
- {
- if ( (pButtonWindow->GetStyle() & WB_DEFBUTTON) &&
- pButtonWindow->mpWindowImpl->mbPushButton )
+ // search first for a DefPushButton
+ WindowIterator aIter(this, pFocusWindow, true);
+ for (; *aIter; ++aIter)
+ if ( (aIter->GetStyle() & WB_DEFBUTTON) &&
+ aIter->mpWindowImpl->mbPushButton )
break;
-
- pButtonWindow = ImplGetNextWindow( this, iButton, iButton, true );
- if ( (iButton <= iButtonStart) || (iButton > nFormEnd) )
- pButtonWindow = nullptr;
- }
+ pButtonWindow = *aIter;
if ( bKeyInput && !pButtonWindow && (nDlgCtrlFlags & DialogControlFlags::Return) )
{
@@ -706,18 +833,12 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput )
}
else if ( nKeyCode == KEY_ESCAPE )
{
- // search first for a DefPushButton/CancelButton
- pButtonWindow = ImplGetChildWindow( this, nFormStart, iButton, true );
- iButtonStart = iButton;
- while ( pButtonWindow )
- {
- if ( pButtonWindow->GetType() == WindowType::CANCELBUTTON )
+ // search first for a CancelButton
+ WindowIterator aIter(this, pFocusWindow, true);
+ for (; *aIter; ++aIter)
+ if (aIter->GetType() == WindowType::CANCELBUTTON)
break;
-
- pButtonWindow = ImplGetNextWindow( this, iButton, iButton, true );
- if ( (iButton <= iButtonStart) || (iButton > nFormEnd) )
- pButtonWindow = nullptr;
- }
+ pButtonWindow = *aIter;
if ( bKeyInput && mpWindowImpl->mpDlgCtrlDownWindow )
{
commit 5f83d8882f6074b17184ce4945998d421733b4f5
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Sep 26 14:09:59 2018 +0200
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 27 09:08:00 2018 +0000
Don't iter over hidden tab pages
Change-Id: Ie8699dae8d08628b66b33e0704237b9e219874bc
diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx
index 4479291b6f24..6efbe1f39eb1 100644
--- a/vcl/source/window/dlgctrl.cxx
+++ b/vcl/source/window/dlgctrl.cxx
@@ -98,7 +98,14 @@ static vcl::Window* ImplGetSubChildWindow( vcl::Window* pParent, sal_uInt16 n, s
vcl::Window* pFoundWindow = nullptr;
vcl::Window* pWindow = firstLogicalChildOfParent(pParent);
+ // pParent is a tab control and has tabs (not in dispose)
+ if (pWindow && pParent->ImplGetWindow()->GetType() == WindowType::TABCONTROL)
+ {
+ pTabPage = ImplGetCurTabWindow(pParent->ImplGetWindow());
+ pWindow = lastLogicalChildOfParent(pParent);
+ }
vcl::Window* pNextWindow = pWindow;
+
while ( pWindow )
{
pWindow = pWindow->ImplGetWindow();
commit 241af0f65ccac816ee306692edc848d5cb09e20e
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Thu Aug 30 16:19:30 2018 +0200
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 27 09:08:00 2018 +0000
Move TabPage lookup into extra function
Probably easier to review the follow up patch.
Change-Id: I42e8f78b69b4ed2cb28bf0f36496eb751e8cb433
diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx
index 76adefb1d2a1..4479291b6f24 100644
--- a/vcl/source/window/dlgctrl.cxx
+++ b/vcl/source/window/dlgctrl.cxx
@@ -68,6 +68,30 @@ static vcl::Window* ImplGetTopParentOfTabHierarchy( vcl::Window* pParent )
return pResult;
}
+static vcl::Window* ImplGetCurTabWindow(const vcl::Window* pWindow)
+{
+ assert(pWindow->GetType() == WindowType::TABCONTROL);
+ const TabControl* pTabControl = static_cast<const TabControl*>(pWindow);
+ // Check if the TabPage is a Child of the TabControl and still exists (by
+ // walking all child windows); because it could be that the TabPage has been
+ // destroyed already by a Dialog-Dtor, event that the TabControl still exists.
+ const TabPage* pTempTabPage = pTabControl->GetTabPage(pTabControl->GetCurPageId());
+ if (pTempTabPage)
+ {
+ vcl::Window* pTempWindow = pTabControl->GetWindow(GetWindowType::FirstChild);
+ while (pTempWindow)
+ {
+ if (pTempWindow->ImplGetWindow() == pTempTabPage)
+ {
+ return const_cast<TabPage*>(pTempTabPage);
+ }
+ pTempWindow = nextLogicalChildOfParent(pTabControl, pTempWindow);
+ }
+ }
+
+ return nullptr;
+}
+
static vcl::Window* ImplGetSubChildWindow( vcl::Window* pParent, sal_uInt16 n, sal_uInt16& nIndex )
{
vcl::Window* pTabPage = nullptr;
@@ -91,31 +115,10 @@ static vcl::Window* ImplGetSubChildWindow( vcl::Window* pParent, sal_uInt16 n, s
else
{
pFoundWindow = pWindow;
-
// for a TabControl, remember the current TabPage for later use
if ( pWindow->GetType() == WindowType::TABCONTROL )
- {
- TabControl* pTabControl = static_cast<TabControl*>(pWindow);
- // Check if the TabPage is a Child of the TabControl and still exists (by
- // walking all child windows); because it could be that the TabPage has been
- // destroyed already by a Dialog-Dtor, event that the TabControl still exists.
- TabPage* pTempTabPage = pTabControl->GetTabPage( pTabControl->GetCurPageId() );
- if ( pTempTabPage )
- {
- vcl::Window* pTempWindow = pTabControl->GetWindow( GetWindowType::FirstChild );
- while ( pTempWindow )
- {
- if ( pTempWindow->ImplGetWindow() == pTempTabPage )
- {
- pTabPage = pTempTabPage;
- break;
- }
- pTempWindow = nextLogicalChildOfParent(pTabControl, pTempWindow);
- }
- }
- }
- else if ( ( pWindow->GetStyle() & WB_DIALOGCONTROL )
- || ( pWindow->GetStyle() & WB_CHILDDLGCTRL ) )
+ pTabPage = ImplGetCurTabWindow(pWindow);
+ else if (pWindow->GetStyle() & (WB_DIALOGCONTROL | WB_CHILDDLGCTRL))
pFoundWindow = ImplGetSubChildWindow( pWindow, n, nIndex );
}
commit 7cee4392f6ca9dafc94b5eb38d1a5b614c02a3b1
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri Aug 31 16:43:18 2018 +0200
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Sep 27 09:08:00 2018 +0000
Constify vcl::Window child lookup
Change-Id: I11425dc4aa372423fcf469ab1374159ce8b180e2
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 50fd57663542..22d494dfa6e2 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -767,21 +767,28 @@ public:
//i.e. acts like pChild = pChild->GetWindow(GetWindowType::FirstChild);
//in a flat hierarchy where dialogs only have one layer
//of children
-VCL_DLLPUBLIC vcl::Window* firstLogicalChildOfParent(vcl::Window *pTopLevel);
+VCL_DLLPUBLIC vcl::Window* firstLogicalChildOfParent(const vcl::Window *pTopLevel);
+
+//Get last window of a pTopLevel window as
+//if any intermediate layout widgets didn't exist
+//i.e. acts like pChild = pChild->GetWindow(GetWindowType::LastChild);
+//in a flat hierarchy where dialogs only have one layer
+//of children
+VCL_DLLPUBLIC vcl::Window* lastLogicalChildOfParent(const vcl::Window *pTopLevel);
//Get next window after pChild of a pTopLevel window as
//if any intermediate layout widgets didn't exist
//i.e. acts like pChild = pChild->GetWindow(GetWindowType::Next);
//in a flat hierarchy where dialogs only have one layer
//of children
-VCL_DLLPUBLIC vcl::Window* nextLogicalChildOfParent(vcl::Window *pTopLevel, vcl::Window *pChild);
+VCL_DLLPUBLIC vcl::Window* nextLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild);
//Get previous window before pChild of a pTopLevel window as
//if any intermediate layout widgets didn't exist
//i.e. acts like pChild = pChild->GetWindow(GetWindowType::Prev);
//in a flat hierarchy where dialogs only have one layer
//of children
-VCL_DLLPUBLIC vcl::Window* prevLogicalChildOfParent(vcl::Window *pTopLevel, vcl::Window *pChild);
+VCL_DLLPUBLIC vcl::Window* prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild);
//Returns true is the Window has a single child which is a container
VCL_DLLPUBLIC bool isLayoutEnabled(const vcl::Window *pWindow);
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index ed3016ad64d2..5d5505836807 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -128,9 +128,9 @@ void ImplHideSplash()
//Get next window after pChild of a pTopLevel window as
//if any intermediate layout widgets didn't exist
-vcl::Window * nextLogicalChildOfParent(vcl::Window *pTopLevel, vcl::Window *pChild)
+vcl::Window * nextLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild)
{
- vcl::Window *pLastChild = pChild;
+ const vcl::Window *pLastChild = pChild;
if (isContainerWindow(*pChild))
pChild = pChild->GetWindow(GetWindowType::FirstChild);
@@ -151,12 +151,12 @@ vcl::Window * nextLogicalChildOfParent(vcl::Window *pTopLevel, vcl::Window *pChi
if (pChild && isContainerWindow(*pChild))
pChild = nextLogicalChildOfParent(pTopLevel, pChild);
- return pChild;
+ return const_cast<vcl::Window *>(pChild);
}
-vcl::Window * prevLogicalChildOfParent(vcl::Window *pTopLevel, vcl::Window *pChild)
+vcl::Window * prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild)
{
- vcl::Window *pLastChild = pChild;
+ const vcl::Window *pLastChild = pChild;
if (isContainerWindow(*pChild))
pChild = pChild->GetWindow(GetWindowType::LastChild);
@@ -177,17 +177,23 @@ vcl::Window * prevLogicalChildOfParent(vcl::Window *pTopLevel, vcl::Window *pChi
if (pChild && isContainerWindow(*pChild))
pChild = prevLogicalChildOfParent(pTopLevel, pChild);
- return pChild;
+ return const_cast<vcl::Window *>(pChild);
}
-//Get first window of a pTopLevel window as
-//if any intermediate layout widgets didn't exist
-vcl::Window * firstLogicalChildOfParent(vcl::Window *pTopLevel)
+vcl::Window * firstLogicalChildOfParent(const vcl::Window *pTopLevel)
{
vcl::Window *pChild = pTopLevel->GetWindow(GetWindowType::FirstChild);
if (pChild && isContainerWindow(*pChild))
pChild = nextLogicalChildOfParent(pTopLevel, pChild);
- return pChild;
+ return const_cast<vcl::Window *>(pChild);
+}
+
+vcl::Window * lastLogicalChildOfParent(const vcl::Window *pTopLevel)
+{
+ vcl::Window *pChild = pTopLevel->GetWindow(GetWindowType::LastChild);
+ if (pChild && isContainerWindow(*pChild))
+ pChild = prevLogicalChildOfParent(pTopLevel, pChild);
+ return const_cast<vcl::Window *>(pChild);
}
void Accelerator::GenerateAutoMnemonicsOnHierarchy(vcl::Window* pWindow)
commit 9a89a75052c7327187cd5788dbaf8891a0a95cac
Author: Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Tue Sep 25 11:21:55 2018 +0300
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Thu Sep 27 10:57:10 2018 +0200
sw: new unit test for XAutoTextGroup and rdf::URI
Change-Id: I989ff797ddcd4ce77ac9b87fde2a2f8f75dbbc6b
Reviewed-on: https://gerrit.libreoffice.org/60961
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/CppunitTest_sw_unoapi.mk b/sw/CppunitTest_sw_unoapi.mk
new file mode 100644
index 000000000000..3a7403169ec3
--- /dev/null
+++ b/sw/CppunitTest_sw_unoapi.mk
@@ -0,0 +1,62 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sw_unoapi))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_unoapi, \
+ sw/qa/unit/unoapi \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_unoapi, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ editeng \
+ i18nlangtag \
+ sal \
+ sfx \
+ svl \
+ svt \
+ sw \
+ test \
+ tl \
+ unotest \
+ utl \
+ vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_unoapi,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_unoapi,\
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/source/core/inc \
+ -I$(SRCDIR)/sw/source/uibase/inc \
+ -I$(SRCDIR)/sw/qa/extras/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_unoapi,\
+ udkapi \
+ offapi \
+ oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_unoapi))
+$(eval $(call gb_CppunitTest_use_vcl,sw_unoapi))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_unoapi,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_unoapi))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index e825f09cef9e..92be67b23af9 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -97,6 +97,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_accessible_relation_set \
CppunitTest_sw_apitests \
CppunitTest_sw_unowriter \
+ CppunitTest_sw_unoapi \
))
ifneq ($(DISABLE_GUI),TRUE)
diff --git a/sw/qa/unit/data/xautotextgroup.odt b/sw/qa/unit/data/xautotextgroup.odt
new file mode 100644
index 000000000000..e1cb9e7ea052
Binary files /dev/null and b/sw/qa/unit/data/xautotextgroup.odt differ
diff --git a/sw/qa/unit/unoapi.cxx b/sw/qa/unit/unoapi.cxx
new file mode 100644
index 000000000000..cc08d5d440c9
--- /dev/null
+++ b/sw/qa/unit/unoapi.cxx
@@ -0,0 +1,235 @@
+/* -*- 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/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+
+#include <com/sun/star/text/AutoTextContainer.hpp>
+#include <com/sun/star/text/XAutoTextGroup.hpp>
+
+#include <com/sun/star/rdf/URI.hpp>
+#include <com/sun/star/rdf/URIs.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+
+class UnoApiTest : public SwModelTestBase
+{
+public:
+ UnoApiTest()
+ : SwModelTestBase("sw/qa/unit/data/", "writer8")
+ {
+ }
+};
+
+/**
+ * Macro to declare a new test with preloaded file
+ * (similar to DECLARE_SW_ROUNDTRIP_TEST)
+ */
+#define DECLARE_UNOAPI_TEST_FILE(TestName, filename) \
+ class TestName : public UnoApiTest \
+ { \
+ protected: \
+ virtual OUString getTestName() override { return OUString(#TestName); } \
+ \
+ public: \
+ CPPUNIT_TEST_SUITE(TestName); \
+ CPPUNIT_TEST(loadAndTest); \
+ CPPUNIT_TEST_SUITE_END(); \
+ void loadAndTest() \
+ { \
+ load(mpTestDocumentPath, filename); \
+ runTest(); \
+ } \
+ void runTest(); \
+ }; \
+ CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
+ void TestName::runTest()
+
+/**
+ * Macro to declare a new test without loading any files
+ */
+#define DECLARE_UNOAPI_TEST(TestName) \
+ class TestName : public CppUnit::TestFixture \
+ { \
+ public: \
+ CPPUNIT_TEST_SUITE(TestName); \
+ CPPUNIT_TEST(runTest); \
+ CPPUNIT_TEST_SUITE_END(); \
+ void runTest(); \
+ }; \
+ CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
+ void TestName::runTest()
+
+static bool ensureAutoTextExistsByTitle(const Reference<XAutoTextGroup>& autoTextGroup,
+ const OUString& autoTextName)
+{
+ uno::Sequence<OUString> aTitles(autoTextGroup->getTitles());
+ for (const auto& rTitle : aTitles)
+ {
+ if (rTitle == autoTextName)
+ return true;
+ }
+ return false;
+}
+
+static bool ensureAutoTextExistsByName(const Reference<XAutoTextGroup>& autoTextGroup,
+ const OUString& autoTextName)
+{
+ uno::Sequence<OUString> aTitles(autoTextGroup->getElementNames());
+ for (const auto& rTitle : aTitles)
+ {
+ if (rTitle == autoTextName)
+ return true;
+ }
+ return false;
+}
+
+DECLARE_UNOAPI_TEST_FILE(testXAutoTextGroup, "xautotextgroup.odt")
+{
+ Reference<XAutoTextContainer> xAutoTextContainer
+ = AutoTextContainer::create(comphelper::getProcessComponentContext());
+
+ uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
+
+ const OUString sGroupName = "TestGroup*1";
+ const OUString sTextName = "TEST";
+ const OUString sTextNameNew = "TESTRENAMED";
+ const OUString sTextTitle = "Test Auto Text";
+ const OUString sTextTitleNew = "Test Auto Text Renamed";
+
+ // Create new temporary group
+ Reference<XAutoTextGroup> xAutoTextGroup(xAutoTextContainer->insertNewByName(sGroupName),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE("AutoTextGroup was not found!", xAutoTextGroup.is());
+
+ // Insert new element and ensure it exists
+ Reference<XAutoTextEntry> xAutoTextEntry
+ = xAutoTextGroup->insertNewByName(sTextName, sTextTitle, xTextRange);
+ CPPUNIT_ASSERT_MESSAGE("AutoText was not inserted!", xAutoTextEntry.is());
+ CPPUNIT_ASSERT_MESSAGE("Can't find newly created AutoText by title!",
+ ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitle));
+ CPPUNIT_ASSERT_MESSAGE("Can't find newly created AutoText by name!",
+ ensureAutoTextExistsByName(xAutoTextGroup, sTextName));
+
+ // Insert once again the same should throw an exception
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on insertion of same AutoText",
+ xAutoTextGroup->insertNewByName(sTextName, sTextTitle, xTextRange),
+ container::ElementExistException);
+
+ // Rename it & ensure everything is ok
+ xAutoTextGroup->renameByName(sTextName, sTextNameNew, sTextTitleNew);
+ CPPUNIT_ASSERT_MESSAGE("Can't find renamed AutoText by title!",
+ ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitleNew));
+ CPPUNIT_ASSERT_MESSAGE("Can't find renamed AutoText by name!",
+ ensureAutoTextExistsByName(xAutoTextGroup, sTextNameNew));
+ // Not found by old names
+ CPPUNIT_ASSERT_MESSAGE("Found AutoText by old title!",
+ !ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitle));
+ CPPUNIT_ASSERT_MESSAGE("Found AutoText by old name!",
+ !ensureAutoTextExistsByName(xAutoTextGroup, sTextName));
+
+ // Rename not existing should throw an exception
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "We expect an exception on renaming not-exising AutoText",
+ xAutoTextGroup->renameByName(sTextName, sTextNameNew, sTextTitleNew),
+ container::ElementExistException);
+
+ // Remove it and ensure it does not exist
+ xAutoTextGroup->removeByName(sTextNameNew);
+ CPPUNIT_ASSERT_MESSAGE("AutoText was not removed!",
+ !ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitleNew));
+ CPPUNIT_ASSERT_MESSAGE("AutoText was not removed!",
+ !ensureAutoTextExistsByName(xAutoTextGroup, sTextNameNew));
+
+ // Remove non-existing element should throw an exception
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on removing not-existing AutoText",
+ xAutoTextGroup->removeByName(sTextName),
+ container::NoSuchElementException);
+
+ // Remove our temporary group
+ xAutoTextContainer->removeByName(sGroupName);
+}
+
+DECLARE_UNOAPI_TEST(testXURI)
+{
+ Reference<XComponentContext> xContext(::comphelper::getProcessComponentContext());
+
+ // createKnown()
+ Reference<rdf::XURI> xURIcreateKnown(rdf::URI::createKnown(xContext, rdf::URIs::ODF_PREFIX),
+ UNO_SET_THROW);
+ CPPUNIT_ASSERT(xURIcreateKnown.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://docs.oasis-open.org/ns/office/1.2/meta/odf#"),
+ xURIcreateKnown->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("prefix"), xURIcreateKnown->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://docs.oasis-open.org/ns/office/1.2/meta/odf#prefix"),
+ xURIcreateKnown->getStringValue());
+
+ // createKnown() with invalid constant
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid constant",
+ rdf::URI::createKnown(xContext, 12345),
+ lang::IllegalArgumentException);
+
+ // create()
+ Reference<rdf::XURI> xURIcreate(rdf::URI::create(xContext, "http://example.com/url#somedata"),
+ UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#"), xURIcreate->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("somedata"), xURIcreate->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#somedata"), xURIcreate->getStringValue());
+
+ // create() without local name splitted with "/"
+ Reference<rdf::XURI> xURIcreate2(rdf::URI::create(xContext, "http://example.com/url"),
+ UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/"), xURIcreate2->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("url"), xURIcreate2->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url"), xURIcreate2->getStringValue());
+
+ // create() without prefix
+ Reference<rdf::XURI> xURIcreate3(rdf::URI::create(xContext, "#somedata"), UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("#"), xURIcreate3->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("somedata"), xURIcreate3->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("#somedata"), xURIcreate3->getStringValue());
+
+ // create() with invalid URI
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid URI",
+ rdf::URI::create(xContext, "some junk and not URI"),
+ lang::IllegalArgumentException);
+
+ // createNS()
+ Reference<rdf::XURI> xURIcreateNS(
+ rdf::URI::createNS(xContext, "http://example.com/url#", "somedata"), UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#"), xURIcreateNS->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("somedata"), xURIcreateNS->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#somedata"),
+ xURIcreateNS->getStringValue());
+
+ // TODO: What's going on here? Is such usecase valid?
+ Reference<rdf::XURI> xURIcreateNS2(
+ rdf::URI::createNS(xContext, "http://example.com/url", "somedata"), UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/"), xURIcreateNS2->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("urlsomedata"), xURIcreateNS2->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/urlsomedata"),
+ xURIcreateNS2->getStringValue());
+
+ // createNS() some invalid cases
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid URI",
+ rdf::URI::createNS(xContext, "bla", "bla"),
+ lang::IllegalArgumentException);
+
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid URI",
+ rdf::URI::createNS(xContext, OUString(), OUString()),
+ lang::IllegalArgumentException);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 70fe1a5c9aae1876d3a0f4c6fd3d4f11dc25369f
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Sep 27 09:20:31 2018 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Sep 27 09:21:59 2018 +0200
Fix prev blind fix
Change-Id: I58d534e7da346062c631791f9c016850602e40ad
Reviewed-on: https://gerrit.libreoffice.org/61024
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
Tested-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/include/unoidl/unoidl.hxx b/include/unoidl/unoidl.hxx
index 9450ebf83bf0..98674f6789e6 100644
--- a/include/unoidl/unoidl.hxx
+++ b/include/unoidl/unoidl.hxx
@@ -505,11 +505,11 @@ public:
bool const rest;
};
- Constructor(): defaultConstructor(true)
+ Constructor():
#if defined __clang__ && CLANG_VERSION == 30800
- , annotations()
+ annotations(),
#endif
- {}
+ defaultConstructor(true) {}
Constructor(
rtl::OUString const & theName,
commit a887c42095d5749e896a8e8ee41e9e07f4e65557
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Sep 27 08:47:42 2018 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Sep 27 08:47:42 2018 +0200
Blind fix for error with old Clang
<https://ci.libreoffice.org//job/lo_ubsan/1050/consoleFull#-18477798892a810015-1db5-427c-9ce2-83b5f06a5284>:
> In file included from /home/tdf/lode/jenkins/workspace/lo_ubsan/codemaker/source/codemaker/exceptiontree.cxx:28:
> /home/tdf/lode/jenkins/workspace/lo_ubsan/include/unoidl/unoidl.hxx:507:9: error: constructor for 'unoidl::SingleInterfaceBasedServiceEntity::Constructor' must explicitly initialize the const member 'annotations'
> Constructor(): defaultConstructor(true) {}
> ^
> /home/tdf/lode/jenkins/workspace/lo_ubsan/include/unoidl/unoidl.hxx:524:44: note: 'annotations' declared here
> std::vector< rtl::OUString > const annotations;
^
1 error generated.
Change-Id: I041a67599b48959bcca136bab646f6943d071bed
diff --git a/include/unoidl/unoidl.hxx b/include/unoidl/unoidl.hxx
index 711b220f7e0a..9450ebf83bf0 100644
--- a/include/unoidl/unoidl.hxx
+++ b/include/unoidl/unoidl.hxx
@@ -15,6 +15,7 @@
#include <cassert>
#include <vector>
+#include <config_clang.h>
#include <osl/mutex.hxx>
#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
@@ -504,7 +505,11 @@ public:
bool const rest;
};
- Constructor(): defaultConstructor(true) {}
+ Constructor(): defaultConstructor(true)
+#if defined __clang__ && CLANG_VERSION == 30800
+ , annotations()
+#endif
+ {}
Constructor(
rtl::OUString const & theName,
commit 1fb688b2e13da39b8099a3f4ba58dc9aeef8d723
Author: Brian Fraser <andthebrain at softfrog.ca>
AuthorDate: Wed Sep 26 10:19:11 2018 -0700
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 27 08:38:23 2018 +0200
tdf#118065 Fix slow Impress custom animation sidebar update
Timer MainSequence::maTimer dropped from 500ms to 50ms.
Reorder declarations of UI elements in CustomAnimationPane.hxx
to be more intuitive and reflect order shown in UI.
Change-Id: I2857dbbd6a4131c4ca6f9a054132f34056e95338
Reviewed-on: https://gerrit.libreoffice.org/61019
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx
index f10210ca9c72..1b35a3a48a97 100644
--- a/sd/source/core/CustomAnimationEffect.cxx
+++ b/sd/source/core/CustomAnimationEffect.cxx
@@ -2969,7 +2969,7 @@ void MainSequence::init()
mnSequenceType = EffectNodeType::MAIN_SEQUENCE;
maTimer.SetInvokeHandler( LINK(this, MainSequence, onTimerHdl) );
- maTimer.SetTimeout(500);
+ maTimer.SetTimeout(50);
mxChangesListener.set( new AnimationChangeListener( this ) );
@@ -3356,7 +3356,7 @@ IMPL_LINK_NOARG(MainSequence, onTimerHdl, Timer *, void)
}
}
-/** starts a timer that recreates the internal structure from the API core after 1 second */
+/** starts a timer that recreates the internal structure from the API core */
void MainSequence::startRecreateTimer()
{
if( !mbRebuilding && (mbIgnoreChanges == 0) )
@@ -3366,7 +3366,10 @@ void MainSequence::startRecreateTimer()
}
}
-/** starts a timer that rebuilds the API core from the internal structure after 1 second */
+/**
+ * starts a timer that rebuilds the API core from the internal structure
+ * This is used to reduce the number of screen redraws due to animation changes.
+*/
void MainSequence::startRebuildTimer()
{
mbTimerMode = true;
diff --git a/sd/source/ui/animations/CustomAnimationPane.hxx b/sd/source/ui/animations/CustomAnimationPane.hxx
index f1aff2e25cdc..d1e1475b6a92 100644
--- a/sd/source/ui/animations/CustomAnimationPane.hxx
+++ b/sd/source/ui/animations/CustomAnimationPane.hxx
@@ -136,28 +136,29 @@ private:
const CustomAnimationPresets* mpCustomAnimationPresets;
- VclPtr<PushButton> mpPBAddEffect;
- VclPtr<PushButton> mpPBRemoveEffect;
- VclPtr<FixedText> mpFTEffect;
- VclPtr<FixedText> mpFTStart;
- VclPtr<ListBox> mpLBStart;
- VclPtr<FixedText> mpFTProperty;
- VclPtr<VclHBox> mpPlaceholderBox;
- VclPtr<PropertyControl> mpLBProperty;
- VclPtr<PushButton> mpPBPropertyMore;
- VclPtr<FixedText> mpFTDuration;
+ // UI Elements
+ VclPtr<FixedText> mpFTAnimation;
+ VclPtr<CustomAnimationList> mpCustomAnimationList;
+ VclPtr<PushButton> mpPBAddEffect;
+ VclPtr<PushButton> mpPBRemoveEffect;
+ VclPtr<PushButton> mpPBMoveUp;
+ VclPtr<PushButton> mpPBMoveDown;
+ VclPtr<FixedText> mpFTCategory;
+ VclPtr<ListBox> mpLBCategory;
+ VclPtr<FixedText> mpFTEffect;
+ VclPtr<CategoryListBox> mpLBAnimation;
+ VclPtr<FixedText> mpFTStart;
+ VclPtr<ListBox> mpLBStart;
+ VclPtr<FixedText> mpFTProperty;
+ VclPtr<PropertyControl> mpLBProperty;
+ VclPtr<VclHBox> mpPlaceholderBox;
+ VclPtr<PushButton> mpPBPropertyMore;
+ VclPtr<FixedText> mpFTDuration;
VclPtr<MetricBox> mpCBXDuration;
VclPtr<FixedText> mpFTStartDelay;
VclPtr<MetricField> mpMFStartDelay;
- VclPtr<CustomAnimationList> mpCustomAnimationList;
- VclPtr<PushButton> mpPBMoveUp;
- VclPtr<PushButton> mpPBMoveDown;
- VclPtr<PushButton> mpPBPlay;
- VclPtr<CheckBox> mpCBAutoPreview;
- VclPtr<FixedText> mpFTCategory;
- VclPtr<ListBox> mpLBCategory;
- VclPtr<FixedText> mpFTAnimation;
- VclPtr<CategoryListBox> mpLBAnimation;
+ VclPtr<CheckBox> mpCBAutoPreview;
+ VclPtr<PushButton> mpPBPlay;
OUString maStrModify;
OUString maStrProperty;
commit e14c7fa64eff20bf5fc0a97600a0dd58531e1046
Author: Jim Raykowski <raykowj at gmail.com>
AuthorDate: Tue Sep 25 23:30:40 2018 -0800
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 27 08:37:15 2018 +0200
tdf#120122 Fix key input being passed to doc view from floating sidebar
...tab bar
Change-Id: Iae327e0de3a129f28315a3fe2961a6ae572e4056
Reviewed-on: https://gerrit.libreoffice.org/61020
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx
index 9487e8079c7c..7930f98ebb72 100644
--- a/sfx2/source/sidebar/TabBar.cxx
+++ b/sfx2/source/sidebar/TabBar.cxx
@@ -229,7 +229,11 @@ void TabBar::DataChanged (const DataChangedEvent& rDataChangedEvent)
bool TabBar::EventNotify(NotifyEvent& rEvent)
{
- if(rEvent.GetType() == MouseNotifyEvent::COMMAND)
+ MouseNotifyEvent nType = rEvent.GetType();
+ if (MouseNotifyEvent::KEYINPUT == nType)
+ return true;
+
+ if(MouseNotifyEvent::COMMAND == nType)
{
const CommandEvent& rCommandEvent = *rEvent.GetCommandEvent();
if(rCommandEvent.GetCommand() == CommandEventId::Wheel)
commit ec2cc68a666b573e226fce94919041538345cd9b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 26 15:27:01 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 27 08:36:31 2018 +0200
loplugin:useuniqueptr in SwReader::Read
Change-Id: Iff7936e440951e65653ef42ce5a2aebd22a03029
Reviewed-on: https://gerrit.libreoffice.org/61004
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx
index ccfd9d69c74e..c4bd839976fa 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -150,12 +150,12 @@ ErrCode SwReader::Read( const Reader& rOptions )
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
- SwPaM* pUndoPam = nullptr;
+ std::unique_ptr<SwPaM> pUndoPam;
if( bDocUndo || pCursor )
{
// set Pam to the previous node, so that it is not also moved
const SwNodeIndex& rTmp = pPam->GetPoint()->nNode;
- pUndoPam = new SwPaM( rTmp, rTmp, 0, -1 );
+ pUndoPam.reset(new SwPaM( rTmp, rTmp, 0, -1 ));
}
// store for now all Fly's
@@ -316,7 +316,7 @@ ErrCode SwReader::Read( const Reader& rOptions )
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
}
- delete pUndoPam;
+ pUndoPam.reset();
pPam = pPam->GetNext();
if( pPam == pEnd )
commit 07e5c4381ac405b4379767f9735152b8f0314faa
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 26 14:08:43 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 27 08:36:19 2018 +0200
loplugin:useuniqueptr in SwObjPosOscillationControl
Point is a small object, no need to store separately on the heap
Change-Id: Id8fb1829b711831860ad1d7709fb4bf71ae8ff09
Reviewed-on: https://gerrit.libreoffice.org/61002
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx
index 0a4292638342..88f9969a422f 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -137,11 +137,10 @@ class SwObjPosOscillationControl
private:
const SwAnchoredDrawObject* mpAnchoredDrawObj;
- std::vector<Point*> maObjPositions;
+ std::vector<Point> maObjPositions;
public:
explicit SwObjPosOscillationControl( const SwAnchoredDrawObject& _rAnchoredDrawObj );
- ~SwObjPosOscillationControl();
bool OscillationDetected();
};
@@ -152,17 +151,6 @@ SwObjPosOscillationControl::SwObjPosOscillationControl(
{
}
-SwObjPosOscillationControl::~SwObjPosOscillationControl()
-{
- while ( !maObjPositions.empty() )
- {
- Point* pPos = maObjPositions.back();
- delete pPos;
-
- maObjPositions.pop_back();
- }
-}
-
bool SwObjPosOscillationControl::OscillationDetected()
{
bool bOscillationDetected = false;
@@ -174,22 +162,19 @@ bool SwObjPosOscillationControl::OscillationDetected()
}
else
{
- Point* pNewObjPos = new Point( mpAnchoredDrawObj->GetObjRect().Pos() );
- for ( std::vector<Point*>::iterator aObjPosIter = maObjPositions.begin();
- aObjPosIter != maObjPositions.end();
- ++aObjPosIter )
+ Point aNewObjPos = mpAnchoredDrawObj->GetObjRect().Pos();
+ for ( auto const & pt : maObjPositions )
{
- if ( *pNewObjPos == *(*aObjPosIter) )
+ if ( aNewObjPos == pt )
{
// position already occurred -> oscillation
bOscillationDetected = true;
- delete pNewObjPos;
break;
}
}
if ( !bOscillationDetected )
{
- maObjPositions.push_back( pNewObjPos );
+ maObjPositions.push_back( aNewObjPos );
}
}
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 5d9f1ba2fce5..0b0de1ed1076 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -210,7 +210,7 @@ class SwOszControl
static const SwFlyFrame *pStack5;
const SwFlyFrame *pFly;
- std::vector<Point*> maObjPositions;
+ std::vector<Point> maObjPositions;
public:
explicit SwOszControl( const SwFlyFrame *pFrame );
@@ -253,13 +253,7 @@ SwOszControl::~SwOszControl()
else if ( SwOszControl::pStack5 == pFly )
SwOszControl::pStack5 = nullptr;
// #i3317#
- while ( !maObjPositions.empty() )
- {
- Point* pPos = maObjPositions.back();
- delete pPos;
-
- maObjPositions.pop_back();
- }
+ maObjPositions.clear();
}
bool SwOszControl::IsInProgress( const SwFlyFrame *pFly )
@@ -288,22 +282,19 @@ bool SwOszControl::ChkOsz()
}
else
{
- Point* pNewObjPos = new Point( pFly->GetObjRect().Pos() );
- for ( std::vector<Point*>::iterator aObjPosIter = maObjPositions.begin();
- aObjPosIter != maObjPositions.end();
- ++aObjPosIter )
+ Point aNewObjPos = pFly->GetObjRect().Pos();
+ for ( auto const & pt : maObjPositions )
{
- if ( *pNewObjPos == *(*aObjPosIter) )
+ if ( aNewObjPos == pt )
{
// position already occurred -> oscillation
bOscillationDetected = true;
- delete pNewObjPos;
break;
}
}
if ( !bOscillationDetected )
{
- maObjPositions.push_back( pNewObjPos );
+ maObjPositions.push_back( aNewObjPos );
}
}
commit 10f2196266dd3bb0fe6c8da0c5967f80815e9492
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 26 13:41:05 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 27 08:34:38 2018 +0200
loplugin:useuniqueptr in ScTable::FillAuto
Change-Id: Ia75a0dc9aa567b00517c066a65e4a0d1536fa9bd
Reviewed-on: https://gerrit.libreoffice.org/60999
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 61a818000980..a565ab8433a0 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -611,7 +611,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
const ScPatternAttr* pSrcPattern = nullptr;
const ScStyleSheet* pStyleSheet = nullptr;
SCCOLROW nAtSrc = nISrcStart;
- ScPatternAttr* pNewPattern = nullptr;
+ std::unique_ptr<ScPatternAttr> pNewPattern;
bool bGetPattern = true;
rInner = nIStart;
while (true) // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
@@ -620,7 +620,6 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
{
if ( bGetPattern )
{
- delete pNewPattern;
if (bVertical) // rInner&:=nRow, rOuter&:=nCol
pSrcPattern = aCol[nCol].GetPattern(static_cast<SCROW>(nAtSrc));
else // rInner&:=nCol, rOuter&:=nRow
@@ -632,13 +631,13 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
if ( rSet.GetItemState(ATTR_MERGE, false) == SfxItemState::SET
|| rSet.GetItemState(ATTR_MERGE_FLAG, false) == SfxItemState::SET )
{
- pNewPattern = new ScPatternAttr( *pSrcPattern );
+ pNewPattern.reset( new ScPatternAttr( *pSrcPattern ));
SfxItemSet& rNewSet = pNewPattern->GetItemSet();
rNewSet.ClearItem(ATTR_MERGE);
rNewSet.ClearItem(ATTR_MERGE_FLAG);
}
else
- pNewPattern = nullptr;
+ pNewPattern.reset();
}
const ScCondFormatItem& rCondFormatItem = pSrcPattern->GetItem(ATTR_CONDITIONAL);
@@ -728,7 +727,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
if (rInner == nIEnd) break;
if (bPositive) ++rInner; else --rInner;
}
- delete pNewPattern;
+ pNewPattern.reset();
// Analyse
commit 2d34c3c421cf8b43fd6601ca688e882f6d493bfc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 26 13:15:24 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 27 08:34:26 2018 +0200
loplugin:useuniqueptr in Chart2PositionMap
Change-Id: I6db63c66da67fa9133333b4d0cda2b2978140e77
Reviewed-on: https://gerrit.libreoffice.org/60998
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 74d79e7d7e04..79ec21b2596d 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -143,7 +143,7 @@ struct TokenTable
{
SCROW mnRowCount;
SCCOL mnColCount;
- vector<FormulaToken*> maTokens;
+ vector<std::unique_ptr<FormulaToken>> maTokens;
// noncopyable
TokenTable(const TokenTable&) = delete;
@@ -163,12 +163,13 @@ struct TokenTable
}
void clear()
{
- std::for_each(maTokens.begin(), maTokens.end(), std::default_delete<FormulaToken>());
+ for (auto & rToken : maTokens)
+ rToken.reset();
}
- void push_back( FormulaToken* pToken )
+ void push_back( std::unique_ptr<FormulaToken> pToken )
{
- maTokens.push_back( pToken );
+ maTokens.push_back( std::move(pToken) );
OSL_ENSURE( maTokens.size()<= static_cast<sal_uInt32>( mnColCount*mnRowCount ), "too much tokens" );
}
@@ -197,7 +198,7 @@ vector<ScTokenRef> TokenTable::getColRanges(SCCOL nCol) const
sal_uInt32 nLast = getIndex(nCol, mnRowCount-1);
for (sal_uInt32 i = getIndex(nCol, 0); i <= nLast; ++i)
{
- FormulaToken* p = maTokens[i];
+ FormulaToken* p = maTokens[i].get();
if (!p)
continue;
@@ -218,7 +219,7 @@ vector<ScTokenRef> TokenTable::getRowRanges(SCROW nRow) const
sal_uInt32 nLast = getIndex(mnColCount-1, nRow);
for (sal_uInt32 i = getIndex(0, nRow); i <= nLast; i += mnRowCount)
{
- FormulaToken* p = maTokens[i];
+ FormulaToken* p = maTokens[i].get();
if (!p)
continue;
@@ -234,7 +235,7 @@ vector<ScTokenRef> TokenTable::getAllRanges() const
sal_uInt32 nStop = mnColCount*mnRowCount;
for (sal_uInt32 i = 0; i < nStop; i++)
{
- FormulaToken* p = maTokens[i];
+ FormulaToken* p = maTokens[i].get();
if (!p)
continue;
@@ -244,8 +245,8 @@ vector<ScTokenRef> TokenTable::getAllRanges() const
return aTokens;
}
-typedef std::map<SCROW, FormulaToken*> FormulaTokenMap;
-typedef std::map<sal_uInt32, FormulaTokenMap*> FormulaTokenMapMap;
+typedef std::map<SCROW, std::unique_ptr<FormulaToken>> FormulaTokenMap;
+typedef std::map<sal_uInt32, FormulaTokenMap> FormulaTokenMapMap;
class Chart2PositionMap
{
@@ -305,7 +306,7 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
bool bFoundValuesInCol = false;
bool bFoundAnythingInCol = false;
SCROW nRow = 0;
- for (auto it2 = rCol.second->begin(); it2 != rCol.second->end(); ++it2, ++nRow)
+ for (auto it2 = rCol.second.begin(); it2 != rCol.second.end(); ++it2, ++nRow)
{
const auto& rCell = *it2;
@@ -365,33 +366,33 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
maRowHeaders.init(nHeaderColCount,mnDataRowCount);
maData.init(mnDataColCount,mnDataRowCount);
- FormulaTokenMapMap::const_iterator it1 = rCols.begin();
+ FormulaTokenMapMap::iterator it1 = rCols.begin();
for (SCCOL nCol = 0; nCol < nAllColCount; ++nCol)
{
if (it1 != rCols.end())
{
- FormulaTokenMap* pCol = it1->second;
- FormulaTokenMap::const_iterator it2 = pCol->begin();
+ FormulaTokenMap& rCol = it1->second;
+ FormulaTokenMap::iterator it2 = rCol.begin();
for (SCROW nRow = 0; nRow < nAllRowCount; ++nRow)
{
- FormulaToken* pToken = nullptr;
- if (it2 != pCol->end())
+ std::unique_ptr<FormulaToken> pToken;
+ if (it2 != rCol.end())
{
- pToken = it2->second;
+ pToken = std::move(it2->second);
++it2;
}
if( nCol < nHeaderColCount )
{
if( nRow < nHeaderRowCount )
- maLeftUpperCorner.push_back(pToken);
+ maLeftUpperCorner.push_back(std::move(pToken));
else
- maRowHeaders.push_back(pToken);
+ maRowHeaders.push_back(std::move(pToken));
}
else if( nRow < nHeaderRowCount )
- maColHeaders.push_back(pToken);
+ maColHeaders.push_back(std::move(pToken));
else
- maData.push_back(pToken);
+ maData.push_back(std::move(pToken));
}
++it1;
}
@@ -718,8 +719,7 @@ void Chart2Positioner::createPositionMap()
glueState();
bool bNoGlue = (meGlue == GLUETYPE_NONE);
- unique_ptr<FormulaTokenMapMap> pCols(new FormulaTokenMapMap);
- FormulaTokenMap* pCol = nullptr;
+ FormulaTokenMapMap aCols;
SCROW nNoGlueRow = 0;
for (vector<ScTokenRef>::const_iterator itr = mrRefTokens.begin(), itrEnd = mrRefTokens.end();
itr != itrEnd; ++itr)
@@ -751,14 +751,7 @@ void Chart2Positioner::createPositionMap()
for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol, ++nInsCol)
{
- FormulaTokenMapMap::const_iterator it = pCols->find(nInsCol);
- if (it == pCols->end())
- {
- pCol = new FormulaTokenMap;
- (*pCols)[ nInsCol ] = pCol;
- }
- else
- pCol = it->second;
+ FormulaTokenMap& rCol = aCols[nInsCol];
auto nInsRow = bNoGlue ? nNoGlueRow : nRow1;
for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow, ++nInsRow)
@@ -773,12 +766,12 @@ void Chart2Positioner::createPositionMap()
aCellData.SetAbsRow(nRow);
aCellData.SetAbsTab(nTab);
- if (pCol->find(nInsRow) == pCol->end())
+ if (rCol.find(nInsRow) == rCol.end())
{
if (bExternal)
- (*pCol)[ nInsRow ] = new ScExternalSingleRefToken(nFileId, aTabName, aCellData);
+ rCol[ nInsRow ].reset(new ScExternalSingleRefToken(nFileId, aTabName, aCellData));
else
- (*pCol)[ nInsRow ] = new ScSingleRefToken(aCellData);
+ rCol[ nInsRow ].reset(new ScSingleRefToken(aCellData));
}
}
}
@@ -789,30 +782,30 @@ void Chart2Positioner::createPositionMap()
bool bFillRowHeader = mbRowHeaders;
bool bFillColumnHeader = mbColHeaders;
- SCSIZE nAllColCount = static_cast<SCSIZE>(pCols->size());
+ SCSIZE nAllColCount = static_cast<SCSIZE>(aCols.size());
SCSIZE nAllRowCount = 0;
- if (!pCols->empty())
+ if (!aCols.empty())
{
- pCol = pCols->begin()->second;
+ FormulaTokenMap& rCol = aCols.begin()->second;
if (mbDummyUpperLeft)
- if (pCol->find(0) == pCol->end())
- (*pCol)[ 0 ] = nullptr; // dummy for labeling
- nAllRowCount = static_cast<SCSIZE>(pCol->size());
+ if (rCol.find(0) == rCol.end())
+ rCol[ 0 ] = nullptr; // dummy for labeling
+ nAllRowCount = static_cast<SCSIZE>(rCol.size());
}
if( nAllColCount!=0 && nAllRowCount!=0 )
{
if (bNoGlue)
{
- FormulaTokenMap* pFirstCol = pCols->begin()->second;
- for (FormulaTokenMap::const_iterator it1 = pFirstCol->begin(); it1 != pFirstCol->end(); ++it1)
+ FormulaTokenMap& rFirstCol = aCols.begin()->second;
+ for (FormulaTokenMap::iterator it1 = rFirstCol.begin(); it1 != rFirstCol.end(); ++it1)
{
SCROW nKey = it1->first;
- for (FormulaTokenMapMap::const_iterator it2 = pCols->begin(); it2 != pCols->end(); ++it2)
+ for (FormulaTokenMapMap::iterator it2 = aCols.begin(); it2 != aCols.end(); ++it2)
{
- pCol = it2->second;
- if (pCol->find(nKey) == pCol->end())
- (*pCol)[ nKey ] = nullptr;
+ FormulaTokenMap& rCol = it2->second;
+ if (rCol.find(nKey) == rCol.end())
+ rCol[ nKey ] = nullptr;
}
}
}
@@ -820,14 +813,7 @@ void Chart2Positioner::createPositionMap()
mpPositionMap.reset(
new Chart2PositionMap(
static_cast<SCCOL>(nAllColCount), static_cast<SCROW>(nAllRowCount),
- bFillRowHeader, bFillColumnHeader, *pCols, mpDoc));
-
- // Destroy all column instances.
- for (FormulaTokenMapMap::const_iterator it = pCols->begin(); it != pCols->end(); ++it)
- {
- pCol = it->second;
- delete pCol;
- }
+ bFillRowHeader, bFillColumnHeader, aCols, mpDoc));
}
/**
commit d1c74bda372044154b05c1a0863808ae838b1c42
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 26 12:55:27 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 27 08:31:49 2018 +0200
loplugin:useuniqueptr in ScAddInAsyncs
Change-Id: I18086623378a6ffd9272b2255ea8060d301b6c43
Reviewed-on: https://gerrit.libreoffice.org/60997
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 8cb867ace6bb..43bcb6c3cdb9 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -543,10 +543,6 @@ void ScGlobal::InitTextHeight(const SfxItemPool* pPool)
void ScGlobal::Clear()
{
// Destroy asyncs _before_ ExitExternalFunc!
- for( ScAddInAsyncs::iterator it = theAddInAsyncTbl.begin(); it != theAddInAsyncTbl.end(); ++it )
- {
- delete *it;
- }
theAddInAsyncTbl.clear();
ExitExternalFunc();
ClearAutoFormat();
diff --git a/sc/source/core/inc/adiasync.hxx b/sc/source/core/inc/adiasync.hxx
index 50e3924479a1..bc0a22ee3315 100644
--- a/sc/source/core/inc/adiasync.hxx
+++ b/sc/source/core/inc/adiasync.hxx
@@ -69,9 +69,9 @@ public:
struct CompareScAddInAsync
{
- bool operator()( ScAddInAsync* const& lhs, ScAddInAsync* const& rhs ) const { return (*lhs)<(*rhs); }
+ bool operator()( std::unique_ptr<ScAddInAsync> const& lhs, std::unique_ptr<ScAddInAsync> const& rhs ) const { return (*lhs)<(*rhs); }
};
-using ScAddInAsyncs = std::set<ScAddInAsync*, CompareScAddInAsync>;
+using ScAddInAsyncs = std::set<std::unique_ptr<ScAddInAsync>, CompareScAddInAsync>;
extern ScAddInAsyncs theAddInAsyncTbl; // in adiasync.cxx
diff --git a/sc/source/core/tool/adiasync.cxx b/sc/source/core/tool/adiasync.cxx
index e7070603c8c2..9a0770b7addb 100644
--- a/sc/source/core/tool/adiasync.cxx
+++ b/sc/source/core/tool/adiasync.cxx
@@ -50,7 +50,7 @@ ScAddInAsync::ScAddInAsync(sal_uLong nHandleP, LegacyFuncData* pFuncData, ScDocu
{
pDocs.reset(new ScAddInDocs);
pDocs->insert( pDoc );
- theAddInAsyncTbl.insert( this );
+ theAddInAsyncTbl.emplace( this );
}
ScAddInAsync::~ScAddInAsync()
@@ -65,26 +65,29 @@ ScAddInAsync::~ScAddInAsync()
ScAddInAsync* ScAddInAsync::Get( sal_uLong nHandleP )
{
ScAddInAsync* pRet = nullptr;
- ScAddInAsyncs::iterator it = std::find_if(
+ auto it = std::find_if(
theAddInAsyncTbl.begin(), theAddInAsyncTbl.end(),
- [nHandleP](ScAddInAsync const * el)
+ [nHandleP](std::unique_ptr<ScAddInAsync> const & el)
{ return el->nHandle == nHandleP; });
if ( it != theAddInAsyncTbl.end() )
- pRet = *it;
+ pRet = it->get();
return pRet;
}
void ScAddInAsync::CallBack( sal_uLong nHandleP, void* pData )
{
- ScAddInAsync* p;
- if ( (p = Get( nHandleP )) == nullptr )
+ auto asyncIt = std::find_if(
+ theAddInAsyncTbl.begin(), theAddInAsyncTbl.end(),
+ [nHandleP](std::unique_ptr<ScAddInAsync> const & el)
+ { return el->nHandle == nHandleP; });
+ if ( asyncIt == theAddInAsyncTbl.end() )
return;
+ ScAddInAsync* p = asyncIt->get();
if ( !p->HasListeners() )
{
// not in dTor because of theAddInAsyncTbl.DeleteAndDestroy in ScGlobal::Clear
- theAddInAsyncTbl.erase( p );
- delete p;
+ theAddInAsyncTbl.erase( asyncIt );
return ;
}
switch ( p->meType )
@@ -122,7 +125,7 @@ void ScAddInAsync::RemoveDocument( ScDocument* pDocumentP )
{
for( ScAddInAsyncs::reverse_iterator iter1 = theAddInAsyncTbl.rbegin(); iter1 != theAddInAsyncTbl.rend(); ++iter1 )
{ // backwards because of pointer-movement in array
- ScAddInAsync* pAsync = *iter1;
+ ScAddInAsync* pAsync = iter1->get();
ScAddInDocs* p = pAsync->pDocs.get();
ScAddInDocs::iterator iter2 = p->find( pDocumentP );
if( iter2 != p->end() )
@@ -131,7 +134,6 @@ void ScAddInAsync::RemoveDocument( ScDocument* pDocumentP )
if ( p->empty() )
{ // this AddIn is not used anymore
theAddInAsyncTbl.erase( --(iter1.base()) );
- delete pAsync;
}
}
}
commit 175834ce6a3ba707a6d34aa8de7351574381f481
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 26 13:52:39 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 27 08:30:01 2018 +0200
loplugin:constfields in toolkit
Change-Id: I26254acc84b1bfe71e4addbde51cb6a9ed52c981
Reviewed-on: https://gerrit.libreoffice.org/60990
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/toolkit/controls/eventcontainer.hxx b/include/toolkit/controls/eventcontainer.hxx
index 65d0418bdc27..cc1d20493e4c 100644
--- a/include/toolkit/controls/eventcontainer.hxx
+++ b/include/toolkit/controls/eventcontainer.hxx
@@ -38,7 +38,7 @@ class ScriptEventContainer : public ::cppu::WeakImplHelper<
{
std::unordered_map< OUString, css::uno::Any>
mHashMap;
- css::uno::Type mType;
+ css::uno::Type const mType;
ContainerListenerMultiplexer maContainerListeners;
diff --git a/toolkit/inc/helper/msgbox.hxx b/toolkit/inc/helper/msgbox.hxx
index 0fc7631d93de..f353b2ff9d57 100644
--- a/toolkit/inc/helper/msgbox.hxx
+++ b/toolkit/inc/helper/msgbox.hxx
@@ -50,7 +50,7 @@ class MessBox : public ButtonDialog
VclPtr<FixedImage> mpFixedImage;
Image maImage;
bool mbHelpBtn;
- MessBoxStyle mnMessBoxStyle;
+ MessBoxStyle const mnMessBoxStyle;
protected:
OUString maMessText;
diff --git a/toolkit/source/awt/asynccallback.cxx b/toolkit/source/awt/asynccallback.cxx
index e9cc75f5f462..c37b20930a71 100644
--- a/toolkit/source/awt/asynccallback.cxx
+++ b/toolkit/source/awt/asynccallback.cxx
@@ -57,7 +57,7 @@ private:
xCallback( rCallback ), aData( rAny ) {}
css::uno::Reference< css::awt::XCallback > xCallback;
- css::uno::Any aData;
+ css::uno::Any const aData;
};
DECL_STATIC_LINK( AsyncCallback, Notify_Impl, void*, void );
diff --git a/toolkit/source/awt/stylesettings.cxx b/toolkit/source/awt/stylesettings.cxx
index 556fa8040371..22cce1247cc6 100644
--- a/toolkit/source/awt/stylesettings.cxx
+++ b/toolkit/source/awt/stylesettings.cxx
@@ -87,7 +87,7 @@ namespace toolkit
}
private:
- SolarMutexGuard m_aGuard;
+ SolarMutexGuard const m_aGuard;
};
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 5e7c9e823c39..737bdc529554 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -415,7 +415,7 @@ public:
delete this;
}
- sal_Int32 m_nPauseMilliseconds;
+ sal_Int32 const m_nPauseMilliseconds;
};
class VCLXToolkitMutexHelper
@@ -439,8 +439,8 @@ class VCLXToolkit : public VCLXToolkitMutexHelper,
::comphelper::OInterfaceContainerHelper2 m_aTopWindowListeners;
::comphelper::OInterfaceContainerHelper2 m_aKeyHandlers;
::comphelper::OInterfaceContainerHelper2 m_aFocusListeners;
- ::Link<VclSimpleEvent&,void> m_aEventListenerLink;
- ::Link<VclWindowEvent&,bool> m_aKeyListenerLink;
+ ::Link<VclSimpleEvent&,void> const m_aEventListenerLink;
+ ::Link<VclWindowEvent&,bool> const m_aKeyListenerLink;
bool m_bEventListener;
bool m_bKeyListener;
@@ -801,9 +801,9 @@ WindowType ImplGetComponentType( const OUString& rServiceName )
struct MessageBoxTypeInfo
{
- css::awt::MessageBoxType eType;
+ css::awt::MessageBoxType const eType;
const sal_Char *pName;
- sal_Int32 nLen;
+ sal_Int32 const nLen;
};
static const MessageBoxTypeInfo aMessageBoxTypeInfo[] =
diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx
index 9edf3ed9086c..eb3df832c972 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -118,7 +118,7 @@ public:
bool mbDisposing : 1;
bool mbDesignMode : 1;
bool mbSynthesizingVCLEvent : 1;
- bool mbWithDefaultProps : 1;
+ bool const mbWithDefaultProps : 1;
sal_uLong mnListenerLockLevel;
sal_Int16 mnWritingMode;
diff --git a/toolkit/source/controls/geometrycontrolmodel.cxx b/toolkit/source/controls/geometrycontrolmodel.cxx
index d8f9045668fc..5fe1a2194d84 100644
--- a/toolkit/source/controls/geometrycontrolmodel.cxx
+++ b/toolkit/source/controls/geometrycontrolmodel.cxx
@@ -585,7 +585,7 @@
struct Int32Equal
{
- sal_Int32 m_nCompare;
+ sal_Int32 const m_nCompare;
explicit Int32Equal( sal_Int32 _nCompare ) : m_nCompare( _nCompare ) { }
bool operator()( sal_Int32 _nLHS )
diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx
index 011aa72e08df..9432f67b78ec 100644
--- a/toolkit/source/controls/unocontrol.cxx
+++ b/toolkit/source/controls/unocontrol.cxx
@@ -60,7 +60,7 @@ using ::com::sun::star::accessibility::XAccessible;
struct LanguageDependentProp
{
const char* pPropName;
- sal_Int32 nPropNameLength;
+ sal_Int32 const nPropNameLength;
};
static const LanguageDependentProp aLanguageDependentProp[] =
diff --git a/toolkit/source/controls/unocontrolcontainer.cxx b/toolkit/source/controls/unocontrolcontainer.cxx
index b704b0dd01cb..7311a184ed48 100644
--- a/toolkit/source/controls/unocontrolcontainer.cxx
+++ b/toolkit/source/controls/unocontrolcontainer.cxx
@@ -48,7 +48,7 @@ using namespace ::com::sun::star;
struct UnoControlHolder
{
uno::Reference< awt::XControl > mxControl;
- OUString msName;
+ OUString const msName;
public:
UnoControlHolder( const OUString& rName, const uno::Reference< awt::XControl > & rControl )
diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx
index 904e520fd0ea..d7dfe76e162e 100644
--- a/toolkit/source/helper/vclunohelper.cxx
+++ b/toolkit/source/helper/vclunohelper.cxx
@@ -360,9 +360,9 @@ namespace
{
static struct _unit_table
{
- FieldUnit eFieldUnit;
- sal_Int16 nMeasurementUnit;
- sal_Int16 nFieldToMeasureFactor;
+ FieldUnit const eFieldUnit;
+ sal_Int16 const nMeasurementUnit;
+ sal_Int16 const nFieldToMeasureFactor;
} aUnits[] = {
{ FUNIT_NONE, -1 , -1},
{ FUNIT_MM, MeasureUnit::MM, 1 }, // must precede MM_10TH
commit 833c4965fc0941ea997852e3d99dcd7688e58c14
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 26 13:40:27 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 27 08:29:49 2018 +0200
loplugin:constfields in tools
Change-Id: I83499cfb49f7abdbf0629c60167d09a1352571ee
Reviewed-on: https://gerrit.libreoffice.org/60987
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/tools/multisel.hxx b/include/tools/multisel.hxx
index 3e06a3dce239..feb96abd2760 100644
--- a/include/tools/multisel.hxx
+++ b/include/tools/multisel.hxx
@@ -77,16 +77,16 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC StringRangeEnumerator
{
struct Range
{
- sal_Int32 nFirst;
- sal_Int32 nLast;
+ sal_Int32 const nFirst;
+ sal_Int32 const nLast;
Range( sal_Int32 i_nFirst, sal_Int32 i_nLast ) : nFirst( i_nFirst ), nLast( i_nLast ) {}
};
std::vector< StringRangeEnumerator::Range > maSequence;
sal_Int32 mnCount;
- sal_Int32 mnMin;
- sal_Int32 mnMax;
- sal_Int32 mnOffset;
+ sal_Int32 const mnMin;
+ sal_Int32 const mnMax;
+ sal_Int32 const mnOffset;
bool mbValidInput;
bool setRange( const OUString& i_rNewRange );
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index ce6db9ac4217..86a29f8093ff 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -100,7 +100,7 @@ enum SvLockBytesStatFlag { SVSTATFLAG_DEFAULT };
class TOOLS_DLLPUBLIC SvLockBytes: public virtual SvRefBase
{
SvStream * m_pStream;
- bool m_bOwner;
+ bool const m_bOwner;
bool m_bSync;
protected:
diff --git a/include/tools/vcompat.hxx b/include/tools/vcompat.hxx
index 85e3b1d44240..ba4692f663e2 100644
--- a/include/tools/vcompat.hxx
+++ b/include/tools/vcompat.hxx
@@ -38,7 +38,7 @@ class TOOLS_DLLPUBLIC VersionCompat
SvStream* mpRWStm;
sal_uInt32 mnCompatPos;
sal_uInt32 mnTotalSize;
- StreamMode mnStmMode;
+ StreamMode const mnStmMode;
sal_uInt16 mnVersion;
VersionCompat( const VersionCompat& ) = delete;
diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx
index 57af7c50c2a1..9f26d263adba 100644
--- a/include/tools/zcodec.hxx
+++ b/include/tools/zcodec.hxx
@@ -40,11 +40,11 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC ZCodec
bool mbStatus;
bool mbFinish;
sal_uInt8* mpInBuf;
- size_t mnInBufSize;
+ size_t const mnInBufSize;
size_t mnInToRead;
SvStream* mpOStm;
sal_uInt8* mpOutBuf;
- size_t mnOutBufSize;
+ size_t const mnOutBufSize;
sal_uInt32 mnCRC;
int mnCompressLevel;
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index f024fec558bf..6a53e29d9d03 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -290,14 +290,14 @@ struct INetURLObject::SchemeInfo
{
sal_Char const * m_pScheme;
sal_Char const * m_pPrefix;
- bool m_bAuthority;
- bool m_bUser;
- bool m_bAuth;
- bool m_bPassword;
- bool m_bHost;
- bool m_bPort;
- bool m_bHierarchical;
- bool m_bQuery;
+ bool const m_bAuthority;
+ bool const m_bUser;
+ bool const m_bAuth;
+ bool const m_bPassword;
+ bool const m_bHost;
+ bool const m_bPort;
+ bool const m_bHierarchical;
+ bool const m_bQuery;
};
struct INetURLObject::PrefixInfo
@@ -306,8 +306,8 @@ struct INetURLObject::PrefixInfo
sal_Char const * m_pPrefix;
sal_Char const * m_pTranslatedPrefix;
- INetProtocol m_eScheme;
- Kind m_eKind;
+ INetProtocol const m_eScheme;
+ Kind const m_eKind;
};
// static
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 1f8cb5196d3e..d2f2f4baec6a 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -309,12 +309,12 @@ void appendISO88591(OUStringBuffer & rText, sal_Char const * pBegin,
struct Parameter
{
- OString m_aAttribute;
- OString m_aCharset;
- OString m_aLanguage;
- OString m_aValue;
- sal_uInt32 m_nSection;
- bool m_bExtended;
+ OString const m_aAttribute;
+ OString const m_aCharset;
+ OString const m_aLanguage;
+ OString const m_aValue;
+ sal_uInt32 const m_nSection;
+ bool const m_bExtended;
bool operator<(const Parameter& rhs) const // is used by std::list<Parameter>::sort
{
@@ -800,7 +800,7 @@ bool equalIgnoreCase(const sal_Char * pBegin1,
struct EncodingEntry
{
sal_Char const * m_aName;
- rtl_TextEncoding m_eEncoding;
+ rtl_TextEncoding const m_eEncoding;
};
// The source for the following table is <ftp://ftp.iana.org/in-notes/iana/
diff --git a/tools/source/reversemap/bestreversemap.cxx b/tools/source/reversemap/bestreversemap.cxx
index 63fbd2b1cb90..90679654cbbe 100644
--- a/tools/source/reversemap/bestreversemap.cxx
+++ b/tools/source/reversemap/bestreversemap.cxx
@@ -15,7 +15,7 @@
struct Encoder
{
- rtl_UnicodeToTextConverter m_aConverter;
+ rtl_UnicodeToTextConverter const m_aConverter;
bool m_bCapable;
const char *m_pEncoding;
Encoder(rtl_TextEncoding nEncoding, const char *pEncoding)
diff --git a/tools/source/xml/XmlWriter.cxx b/tools/source/xml/XmlWriter.cxx
index 8895e92064db..58c4a26f2cb5 100644
--- a/tools/source/xml/XmlWriter.cxx
+++ b/tools/source/xml/XmlWriter.cxx
@@ -39,7 +39,7 @@ struct XmlWriterImpl
{
}
- SvStream* mpStream;
+ SvStream* const mpStream;
xmlTextWriterPtr mpWriter;
};
commit 64035391ebe8810520a214a3ae0aeb4c1b039819
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 26 10:47:52 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 27 08:29:41 2018 +0200
loplugin:constfields in ucbhelper
Change-Id: Ic9d59b352dcb771191de963c0f6e90c74647c8b8
Reviewed-on: https://gerrit.libreoffice.org/60983
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/UnoControls/source/inc/OConnectionPointHelper.hxx b/UnoControls/source/inc/OConnectionPointHelper.hxx
index cf87833b29ca..51143fc4c681 100644
--- a/UnoControls/source/inc/OConnectionPointHelper.hxx
+++ b/UnoControls/source/inc/OConnectionPointHelper.hxx
@@ -100,7 +100,7 @@ private:
css::uno::WeakReference< css::lang::XConnectionPointContainer > m_oContainerWeakReference; // Reference to container-class!. Don't use Reference<...>
// It is a ring-reference => and must be a wekreference!
OConnectionPointContainerHelper* m_pContainerImplementation;
- css::uno::Type m_aInterfaceType;
+ css::uno::Type const m_aInterfaceType;
css::uno::Reference< css::uno::XInterface > m_xLock;
};
diff --git a/include/ucbhelper/interactionrequest.hxx b/include/ucbhelper/interactionrequest.hxx
index 4ee4e93715f8..74df7f1f6c87 100644
--- a/include/ucbhelper/interactionrequest.hxx
+++ b/include/ucbhelper/interactionrequest.hxx
@@ -307,22 +307,22 @@ class UCBHELPER_DLLPUBLIC InteractionSupplyAuthentication :
public css::lang::XTypeProvider,
public css::ucb::XInteractionSupplyAuthentication2
{
- css::uno::Sequence< css::ucb::RememberAuthentication >
+ css::uno::Sequence< css::ucb::RememberAuthentication > const
m_aRememberPasswordModes;
- css::uno::Sequence< css::ucb::RememberAuthentication >
+ css::uno::Sequence< css::ucb::RememberAuthentication > const
m_aRememberAccountModes;
OUString m_aRealm;
OUString m_aUserName;
OUString m_aPassword;
OUString m_aAccount;
css::ucb::RememberAuthentication m_eRememberPasswordMode;
- css::ucb::RememberAuthentication m_eDefaultRememberPasswordMode;
- css::ucb::RememberAuthentication m_eDefaultRememberAccountMode;
- bool m_bCanSetRealm : 1;
- bool m_bCanSetUserName : 1;
- bool m_bCanSetPassword : 1;
- bool m_bCanSetAccount : 1;
- bool m_bCanUseSystemCredentials : 1;
+ css::ucb::RememberAuthentication const m_eDefaultRememberPasswordMode;
+ css::ucb::RememberAuthentication const m_eDefaultRememberAccountMode;
+ bool const m_bCanSetRealm : 1;
+ bool const m_bCanSetUserName : 1;
+ bool const m_bCanSetPassword : 1;
+ bool const m_bCanSetAccount : 1;
+ bool const m_bCanUseSystemCredentials : 1;
bool m_bUseSystemCredentials : 1;
public:
diff --git a/include/ucbhelper/resultsethelper.hxx b/include/ucbhelper/resultsethelper.hxx
index 7c9452b8407b..15c74b4235c1 100644
--- a/include/ucbhelper/resultsethelper.hxx
+++ b/include/ucbhelper/resultsethelper.hxx
@@ -62,7 +62,7 @@ class UCBHELPER_DLLPUBLIC ResultSetImplHelper :
protected:
osl::Mutex m_aMutex;
- css::ucb::OpenCommandArgument2 m_aCommand;
+ css::ucb::OpenCommandArgument2 const m_aCommand;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
// Resultset #1
css::uno::Reference< css::sdbc::XResultSet > m_xResultSet1;
diff --git a/include/ucbhelper/resultsetmetadata.hxx b/include/ucbhelper/resultsetmetadata.hxx
index 2e410a88a83a..3a11d8f99468 100644
--- a/include/ucbhelper/resultsetmetadata.hxx
+++ b/include/ucbhelper/resultsetmetadata.hxx
@@ -52,9 +52,6 @@ struct ResultSetColumnData
/** @see ResultSetMetaData::isCaseSensitive */
bool isCaseSensitive;
- /** @see ResultSetMetaData::getColumnDisplaySize */
- sal_Int32 columnDisplaySize;
-
inline ResultSetColumnData();
};
@@ -62,8 +59,7 @@ struct ResultSetColumnData
// may heavily depend on the behaviour of the default constructor.
ResultSetColumnData::ResultSetColumnData()
-: isCaseSensitive( true ),
- columnDisplaySize( 16 )
+: isCaseSensitive( true )
{
}
diff --git a/ucbhelper/source/client/proxydecider.cxx b/ucbhelper/source/client/proxydecider.cxx
index 0f5bd69553b7..31e26055ffcf 100644
--- a/ucbhelper/source/client/proxydecider.cxx
+++ b/ucbhelper/source/client/proxydecider.cxx
@@ -66,7 +66,7 @@ namespace proxydecider_impl
class WildCard
{
private:
- OString m_aWildString;
+ OString const m_aWildString;
public:
explicit WildCard( const OUString& rWildCard )
@@ -80,18 +80,13 @@ public:
typedef std::pair< WildCard, WildCard > NoProxyListEntry;
-
class HostnameCache
{
typedef std::pair< OUString, OUString > HostListEntry;
std::deque< HostListEntry > m_aHostList;
- sal_uInt32 m_nCapacity;
public:
- explicit HostnameCache()
- : m_nCapacity( 256 ) {}
-
bool get( const OUString & rKey, OUString & rValue ) const
{
for (auto const& host : m_aHostList)
@@ -107,8 +102,10 @@ public:
void put( const OUString & rKey, const OUString & rValue )
{
- if ( m_aHostList.size() == m_nCapacity )
- m_aHostList.resize( m_nCapacity / 2 );
+ static constexpr sal_uInt32 nCapacity = 256;
+
+ if ( m_aHostList.size() == nCapacity )
+ m_aHostList.resize( nCapacity / 2 );
m_aHostList.push_front( HostListEntry( rKey, rValue ) );
}
diff --git a/ucbhelper/source/provider/resultset.cxx b/ucbhelper/source/provider/resultset.cxx
index c482332909c4..4ed85d478550 100644
--- a/ucbhelper/source/provider/resultset.cxx
+++ b/ucbhelper/source/provider/resultset.cxx
@@ -42,8 +42,8 @@ namespace ucbhelper_impl
struct PropertyInfo
{
const char* pName;
- sal_Int32 nHandle;
- sal_Int16 nAttributes;
+ sal_Int32 const nHandle;
+ sal_Int16 const nAttributes;
const uno::Type& (*pGetCppuType)();
};
@@ -143,7 +143,7 @@ struct ResultSet_Impl
uno::Reference< css::ucb::XCommandEnvironment > m_xEnv;
uno::Reference< beans::XPropertySetInfo > m_xPropSetInfo;
uno::Reference< sdbc::XResultSetMetaData > m_xMetaData;
- uno::Sequence< beans::Property > m_aProperties;
+ uno::Sequence< beans::Property > const m_aProperties;
rtl::Reference< ResultSetDataSupplier > m_xDataSupplier;
osl::Mutex m_aMutex;
std::unique_ptr<cppu::OInterfaceContainerHelper> m_pDisposeEventListeners;
diff --git a/ucbhelper/source/provider/resultsetmetadata.cxx b/ucbhelper/source/provider/resultsetmetadata.cxx
index 4f99af2cae39..3666fa802f9b 100644
--- a/ucbhelper/source/provider/resultsetmetadata.cxx
+++ b/ucbhelper/source/provider/resultsetmetadata.cxx
@@ -198,16 +198,12 @@ sal_Bool SAL_CALL ResultSetMetaData::isSigned( sal_Int32 /*column*/ )
// virtual
-sal_Int32 SAL_CALL ResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
+sal_Int32 SAL_CALL ResultSetMetaData::getColumnDisplaySize( sal_Int32 /*column*/ )
{
/*
Gets the normal maximum width in characters for column.
*/
-
- if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
- return 16;
-
- return m_pImpl->m_aColumnData[ column - 1 ].columnDisplaySize;
+ return 16;
}
commit 850c575d67162a97c1b7acd4fb75c32d0884e7b9
Author: Justin Luth <justin_luth at sil.org>
AuthorDate: Wed Sep 26 17:46:33 2018 +0300
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Thu Sep 27 06:37:14 2018 +0200
editeng ConvertBorderWidthToWord ensure minimum width
If the border in LO has a width, then make sure that the
converted width is non-zero.
The specific fix intended is for the "Horizontal Line"
paragraph style (double, width =1) to export to .doc
format and retain the bottom border.
Change-Id: I65392b2312360d51c290030ceb415155e6139302
Reviewed-on: https://gerrit.libreoffice.org/61006
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
diff --git a/editeng/source/items/borderline.cxx b/editeng/source/items/borderline.cxx
index 5c9042f307fe..33cd0ca6de31 100644
--- a/editeng/source/items/borderline.cxx
+++ b/editeng/source/items/borderline.cxx
@@ -250,6 +250,9 @@ ConvertBorderWidthFromWord(SvxBorderLineStyle const eStyle, double const i_fWidt
double
ConvertBorderWidthToWord(SvxBorderLineStyle const eStyle, double const fWidth)
{
+ if ( !fWidth )
+ return 0;
+
switch (eStyle)
{
// Single lines
@@ -264,31 +267,31 @@ ConvertBorderWidthToWord(SvxBorderLineStyle const eStyle, double const fWidth)
// Double lines
case SvxBorderLineStyle::DOUBLE:
case SvxBorderLineStyle::DOUBLE_THIN:
- return fWidth / 3.0;
+ return std::max(1.0, fWidth / 3.0);
case SvxBorderLineStyle::THINTHICK_MEDIUMGAP:
case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP:
case SvxBorderLineStyle::EMBOSSED:
case SvxBorderLineStyle::ENGRAVED:
- return fWidth / 2.0;
+ return std::max(1.0, fWidth / 2.0);
case SvxBorderLineStyle::THINTHICK_SMALLGAP:
- return fWidth - THINTHICK_SMALLGAP_line2 - THINTHICK_SMALLGAP_gap;
+ return std::max(1.0, fWidth - THINTHICK_SMALLGAP_line2 - THINTHICK_SMALLGAP_gap);
case SvxBorderLineStyle::THINTHICK_LARGEGAP:
- return fWidth - THINTHICK_LARGEGAP_line1 - THINTHICK_LARGEGAP_line2;
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list