[Libreoffice-commits] core.git: 2 commits - compilerplugins/clang include/vcl svl/source vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Nov 26 18:12:08 UTC 2018
compilerplugins/clang/unusedenumconstants.readonly.results | 2
include/vcl/splitwin.hxx | 3
svl/source/items/IndexedStyleSheets.cxx | 30 ++-
vcl/source/window/splitwin.cxx | 99 ++++---------
4 files changed, 51 insertions(+), 83 deletions(-)
New commits:
commit 37b3502b5c781007e701e78c3b361eba5ce8cfe0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Nov 23 15:18:50 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Nov 26 19:11:57 2018 +0100
remove unused enum value SplitWindowItemFlags::Invisible
Change-Id: I4d63601ca3658b4ffd9eaf1c13d4c17503640aa0
Reviewed-on: https://gerrit.libreoffice.org/64041
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/compilerplugins/clang/unusedenumconstants.readonly.results b/compilerplugins/clang/unusedenumconstants.readonly.results
index 2994af2a95fe..0c0bad002db6 100644
--- a/compilerplugins/clang/unusedenumconstants.readonly.results
+++ b/compilerplugins/clang/unusedenumconstants.readonly.results
@@ -1070,8 +1070,6 @@ include/vcl/ptrstyle.hxx:92
enum PointerStyle Chart
include/vcl/salctype.hxx:41
enum ConvertDataFormat PDF
-include/vcl/splitwin.hxx:37
- enum SplitWindowItemFlags Invisible
include/vcl/vclenum.hxx:37
enum MenuItemBits POPUPSELECT
include/vcl/vclenum.hxx:143
diff --git a/include/vcl/splitwin.hxx b/include/vcl/splitwin.hxx
index 0c8edcfe298e..7f015ce96cf0 100644
--- a/include/vcl/splitwin.hxx
+++ b/include/vcl/splitwin.hxx
@@ -34,11 +34,10 @@ enum class SplitWindowItemFlags
RelativeSize = 0x0002,
PercentSize = 0x0004,
ColSet = 0x0008,
- Invisible = 0x0010,
};
namespace o3tl
{
- template<> struct typed_flags<SplitWindowItemFlags> : is_typed_flags<SplitWindowItemFlags, 0x1f> {};
+ template<> struct typed_flags<SplitWindowItemFlags> : is_typed_flags<SplitWindowItemFlags, 0x0f> {};
}
#define SPLITWINDOW_APPEND (sal_uInt16(0xFFFF))
diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx
index 18085cade791..ed5b9621990a 100644
--- a/vcl/source/window/splitwin.cxx
+++ b/vcl/source/window/splitwin.cxx
@@ -401,7 +401,6 @@ static void ImplCalcSet( ImplSplitSet* pSet,
sal_uInt16 nMins;
sal_uInt16 nCalcItems;
size_t nItems = pSet->mvItems.size();
- sal_uInt16 nVisItems;
sal_uInt16 nAbsItems;
long nCalcSize;
long nPos;
@@ -409,20 +408,12 @@ static void ImplCalcSet( ImplSplitSet* pSet,
std::vector< ImplSplitItem >& rItems = pSet->mvItems;
bool bEmpty;
- // get number of visible items
- nVisItems = 0;
- for ( auto& rItem : rItems )
- {
- if ( !(rItem.mnBits & SplitWindowItemFlags::Invisible) )
- nVisItems++;
- }
-
// calculate sizes
if ( bRows )
nCalcSize = nSetHeight;
else
nCalcSize = nSetWidth;
- nCalcSize -= (nVisItems-1)*pSet->mnSplitSize;
+ nCalcSize -= (rItems.size()-1)*pSet->mnSplitSize;
if ( pSet->mbCalcPix || (pSet->mnLastSize != nCalcSize) )
{
long nPercentFactor = 10;
@@ -433,15 +424,12 @@ static void ImplCalcSet( ImplSplitSet* pSet,
long nCurSize = 0;
for ( auto& rItem : rItems )
{
- if ( !(rItem.mnBits & SplitWindowItemFlags::Invisible) )
- {
- if ( rItem.mnBits & SplitWindowItemFlags::RelativeSize )
- nRelCount += rItem.mnSize;
- else if ( rItem.mnBits & SplitWindowItemFlags::PercentSize )
- nPercent += rItem.mnSize;
- else
- nAbsSize += rItem.mnSize;
- }
+ if ( rItem.mnBits & SplitWindowItemFlags::RelativeSize )
+ nRelCount += rItem.mnSize;
+ else if ( rItem.mnBits & SplitWindowItemFlags::PercentSize )
+ nPercent += rItem.mnSize;
+ else
+ nAbsSize += rItem.mnSize;
}
// map relative values to percentages (percentage here one tenth of a procent)
nPercent *= nPercentFactor;
@@ -466,9 +454,7 @@ static void ImplCalcSet( ImplSplitSet* pSet,
long nSizeDelta = nCalcSize-nAbsSize;
for ( auto& rItem : rItems )
{
- if ( rItem.mnBits & SplitWindowItemFlags::Invisible )
- rItem.mnPixSize = 0;
- else if ( rItem.mnBits & SplitWindowItemFlags::RelativeSize )
+ if ( rItem.mnBits & SplitWindowItemFlags::RelativeSize )
{
if ( nSizeDelta <= 0 )
rItem.mnPixSize = 0;
@@ -500,13 +486,10 @@ static void ImplCalcSet( ImplSplitSet* pSet,
// first resize absolute items relative
for ( auto& rItem : rItems )
{
- if ( !(rItem.mnBits & SplitWindowItemFlags::Invisible) )
+ if ( !(rItem.mnBits & (SplitWindowItemFlags::RelativeSize | SplitWindowItemFlags::PercentSize)) )
{
- if ( !(rItem.mnBits & (SplitWindowItemFlags::RelativeSize | SplitWindowItemFlags::PercentSize)) )
- {
- nAbsItems++;
- nSizeWinSize += rItem.mnPixSize;
- }
+ nAbsItems++;
+ nSizeWinSize += rItem.mnPixSize;
}
}
// do not compensate rounding errors here
@@ -516,13 +499,10 @@ static void ImplCalcSet( ImplSplitSet* pSet,
for ( auto& rItem : rItems )
{
- if ( !(rItem.mnBits & SplitWindowItemFlags::Invisible) )
+ if ( !(rItem.mnBits & (SplitWindowItemFlags::RelativeSize | SplitWindowItemFlags::PercentSize)) )
{
- if ( !(rItem.mnBits & (SplitWindowItemFlags::RelativeSize | SplitWindowItemFlags::PercentSize)) )
- {
- rItem.mnPixSize += (nSizeDelta*rItem.mnPixSize)/nSizeWinSize;
- nNewSizeWinSize += rItem.mnPixSize;
- }
+ rItem.mnPixSize += (nSizeDelta*rItem.mnPixSize)/nSizeWinSize;
+ nNewSizeWinSize += rItem.mnPixSize;
}
}
@@ -546,17 +526,14 @@ static void ImplCalcSet( ImplSplitSet* pSet,
rItem.mbSubSize = true;
else
{
- if ( !(rItem.mnBits & SplitWindowItemFlags::Invisible) )
+ if ( (nSizeDelta > 0) || rItem.mnPixSize )
{
- if ( (nSizeDelta > 0) || rItem.mnPixSize )
+ if ( j >= 1 )
+ rItem.mbSubSize = true;
+ else
{
- if ( j >= 1 )
+ if ( (j == 0) && (rItem.mnBits & (SplitWindowItemFlags::RelativeSize | SplitWindowItemFlags::PercentSize)) )
rItem.mbSubSize = true;
- else
- {
- if ( (j == 0) && (rItem.mnBits & (SplitWindowItemFlags::RelativeSize | SplitWindowItemFlags::PercentSize)) )
- rItem.mbSubSize = true;
- }
}
}
}
@@ -574,9 +551,7 @@ static void ImplCalcSet( ImplSplitSet* pSet,
nMins = 0;
for ( auto& rItem : rItems )
{
- if ( rItem.mnBits & SplitWindowItemFlags::Invisible )
- nMins++;
- else if ( rItem.mbSubSize )
+ if ( rItem.mbSubSize )
{
long* pSize = &(rItem.mnPixSize);
long nTempErr;
@@ -644,22 +619,17 @@ static void ImplCalcSet( ImplSplitSet* pSet,
rItems[i].mnOldWidth = rItems[i].mnWidth;
rItems[i].mnOldHeight = rItems[i].mnHeight;
- if ( rItems[i].mnBits & SplitWindowItemFlags::Invisible )
- bEmpty = true;
+ bEmpty = false;
+ if ( bDown )
+ {
+ if ( nPos+rItems[i].mnPixSize > nMaxPos )
+ bEmpty = true;
+ }
else
{
- bEmpty = false;
- if ( bDown )
- {
- if ( nPos+rItems[i].mnPixSize > nMaxPos )
- bEmpty = true;
- }
- else
- {
- nPos -= rItems[i].mnPixSize;
- if ( nPos < nMaxPos )
- bEmpty = true;
- }
+ nPos -= rItems[i].mnPixSize;
+ if ( nPos < nMaxPos )
+ bEmpty = true;
}
if ( bEmpty )
@@ -705,13 +675,10 @@ static void ImplCalcSet( ImplSplitSet* pSet,
}
}
- if ( !(rItems[i].mnBits & SplitWindowItemFlags::Invisible) )
- {
- if ( !bDown )
- nPos -= pSet->mnSplitSize;
- else
- nPos += rItems[i].mnPixSize+pSet->mnSplitSize;
- }
+ if ( !bDown )
+ nPos -= pSet->mnSplitSize;
+ else
+ nPos += rItems[i].mnPixSize+pSet->mnSplitSize;
}
// calculate Sub-Set's
commit 361fa01df3851fdc540144f54a17837c7f76103e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Nov 26 14:51:17 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Nov 26 19:11:46 2018 +0100
inline FindPositionsByName in a couple of places
it is no more complex, and it saves us the construction of an
intermediate vector
Change-Id: Ie92c2970c5b10805d7bcfc0cc2a74378f2cbda08
Reviewed-on: https://gerrit.libreoffice.org/64039
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svl/source/items/IndexedStyleSheets.cxx b/svl/source/items/IndexedStyleSheets.cxx
index 6b28873a05ba..c3b8ad6706c2 100644
--- a/svl/source/items/IndexedStyleSheets.cxx
+++ b/svl/source/items/IndexedStyleSheets.cxx
@@ -97,15 +97,16 @@ IndexedStyleSheets::AddStyleSheet(const rtl::Reference< SfxStyleSheetBase >& sty
bool
IndexedStyleSheets::RemoveStyleSheet(const rtl::Reference< SfxStyleSheetBase >& style)
{
- OUString styleName = style->GetName();
- std::vector<unsigned> positions = FindPositionsByName(styleName);
- auto it = std::find_if(positions.begin(), positions.end(),
- [&](const unsigned pos) { return mStyleSheets.at(pos) == style; });
-
- if (it != positions.end()) {
- mStyleSheets.erase(mStyleSheets.begin() + *it);
- Reindex();
- return true;
+ std::pair<MapType::const_iterator, MapType::const_iterator> range = mPositionsByName.equal_range(style->GetName());
+ for (MapType::const_iterator it = range.first; it != range.second; ++it)
+ {
+ unsigned pos = it->second;
+ if (mStyleSheets.at(pos) == style)
+ {
+ mStyleSheets.erase(mStyleSheets.begin() + pos);
+ Reindex();
+ return true;
+ }
}
return false;
}
@@ -199,10 +200,13 @@ IndexedStyleSheets::~IndexedStyleSheets()
bool
IndexedStyleSheets::HasStyleSheet(const rtl::Reference< SfxStyleSheetBase >& style) const
{
- OUString styleName = style->GetName();
- std::vector<unsigned> positions = FindPositionsByName(styleName);
- return std::any_of(positions.begin(), positions.end(),
- [&](const unsigned pos) { return mStyleSheets.at(pos) == style; });
+ std::pair<MapType::const_iterator, MapType::const_iterator> range = mPositionsByName.equal_range(style->GetName());
+ for (MapType::const_iterator it = range.first; it != range.second; ++it)
+ {
+ if (mStyleSheets.at(it->second) == style)
+ return true;
+ }
+ return false;
}
SfxStyleSheetBase*
More information about the Libreoffice-commits
mailing list