Kaydet (Commit) 4600b07c authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#102195: don't exclude everything between first and last subset

When subsets are non-contiguous, we need to include the parts between
subsets.

Change-Id: I28214dccc75e6a6af5c65397b2126049a65bf79f
Reviewed-on: https://gerrit.libreoffice.org/56571
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 1113f93d
...@@ -164,50 +164,65 @@ namespace slideshow ...@@ -164,50 +164,65 @@ namespace slideshow
mbNodeTreeInitialized = true; mbNodeTreeInitialized = true;
} }
void DrawShapeSubsetting::updateSubsetBounds( const SubsetEntry& rSubsetEntry ) void DrawShapeSubsetting::excludeSubset(sal_Int32 nExcludedStart, sal_Int32 nExcludedEnd)
{ {
// TODO(F1): This removes too much from non-contiguous subsets // If current subsets are empty, fill it with initial range
mnMinSubsetActionIndex = ::std::min( initCurrentSubsets();
mnMinSubsetActionIndex, if (maCurrentSubsets.empty())
rSubsetEntry.mnStartActionIndex ); {
mnMaxSubsetActionIndex = ::std::max( // Non-subsetting mode (not a subset of anything; child subsets subtract content)
mnMaxSubsetActionIndex, maCurrentSubsets.emplace_back(0, maActionClassVector.size());
rSubsetEntry.mnEndActionIndex ); }
}
void DrawShapeSubsetting::updateSubsets()
{
maCurrentSubsets.clear();
if( !maSubsetShapes.empty() ) slideshow::internal::VectorOfDocTreeNodes aNodesToAppend;
for (auto i = maCurrentSubsets.begin(); i != maCurrentSubsets.end();)
{ {
if( maSubset.isEmpty() ) if (i->getStartIndex() < nExcludedStart)
{ {
// non-subsetted node, with some child subsets if (i->getEndIndex() > nExcludedStart)
// that subtract from it {
maCurrentSubsets.emplace_back( 0, // Some overlap -> append new node (if required), and correct this node's end
mnMinSubsetActionIndex ); if (i->getEndIndex() > nExcludedEnd)
maCurrentSubsets.emplace_back( mnMaxSubsetActionIndex, {
maActionClassVector.size() ); aNodesToAppend.emplace_back(nExcludedEnd, i->getEndIndex());
}
i->setEndIndex(nExcludedStart);
}
++i;
}
else if (i->getStartIndex() < nExcludedEnd)
{
if (i->getEndIndex() > nExcludedEnd)
{
// Partial overlap; change the node's start
i->setStartIndex(nExcludedEnd);
++i;
}
else
{
// Node is fully inside the removed range: erase it
i = maCurrentSubsets.erase(i);
}
} }
else else
{ {
// subsetted node, from which some further child // Node is fully outside (after) excluded range
// subsets subtract content ++i;
maCurrentSubsets.emplace_back( maSubset.getStartIndex(),
mnMinSubsetActionIndex );
maCurrentSubsets.emplace_back( mnMaxSubsetActionIndex,
maSubset.getEndIndex() );
} }
} }
else
maCurrentSubsets.insert(maCurrentSubsets.end(), aNodesToAppend.begin(),
aNodesToAppend.end());
}
void DrawShapeSubsetting::updateSubsets()
{
maCurrentSubsets.clear();
initCurrentSubsets();
for (const auto& rSubsetShape : maSubsetShapes)
{ {
// no further child subsets, simply add our subset (if any) excludeSubset(rSubsetShape.mnStartActionIndex, rSubsetShape.mnEndActionIndex);
if( !maSubset.isEmpty() )
{
// subsetted node, without any subset children
maCurrentSubsets.push_back( maSubset );
}
} }
} }
...@@ -220,8 +235,6 @@ namespace slideshow ...@@ -220,8 +235,6 @@ namespace slideshow
mpMtf(), mpMtf(),
maSubset(), maSubset(),
maSubsetShapes(), maSubsetShapes(),
mnMinSubsetActionIndex( SAL_MAX_INT32 ),
mnMaxSubsetActionIndex(0),
maCurrentSubsets(), maCurrentSubsets(),
mbNodeTreeInitialized( false ) mbNodeTreeInitialized( false )
{ {
...@@ -233,8 +246,6 @@ namespace slideshow ...@@ -233,8 +246,6 @@ namespace slideshow
mpMtf( rMtf ), mpMtf( rMtf ),
maSubset( rShapeSubset ), maSubset( rShapeSubset ),
maSubsetShapes(), maSubsetShapes(),
mnMinSubsetActionIndex( SAL_MAX_INT32 ),
mnMaxSubsetActionIndex(0),
maCurrentSubsets(), maCurrentSubsets(),
mbNodeTreeInitialized( false ) mbNodeTreeInitialized( false )
{ {
...@@ -250,8 +261,6 @@ namespace slideshow ...@@ -250,8 +261,6 @@ namespace slideshow
mpMtf.reset(); mpMtf.reset();
maSubset.reset(); maSubset.reset();
maSubsetShapes.clear(); maSubsetShapes.clear();
mnMinSubsetActionIndex = SAL_MAX_INT32;
mnMaxSubsetActionIndex = 0;
maCurrentSubsets.clear(); maCurrentSubsets.clear();
mbNodeTreeInitialized = false; mbNodeTreeInitialized = false;
} }
...@@ -326,9 +335,7 @@ namespace slideshow ...@@ -326,9 +335,7 @@ namespace slideshow
maSubsetShapes.insert( aEntry ); maSubsetShapes.insert( aEntry );
// update cached subset borders excludeSubset(aEntry.mnStartActionIndex, aEntry.mnEndActionIndex);
updateSubsetBounds( aEntry );
updateSubsets();
} }
} }
...@@ -380,19 +387,10 @@ namespace slideshow ...@@ -380,19 +387,10 @@ namespace slideshow
// part of this shape that is visible, i.e. not displayed // part of this shape that is visible, i.e. not displayed
// in subset shapes) // in subset shapes)
// init bounds
mnMinSubsetActionIndex = SAL_MAX_INT32;
mnMaxSubsetActionIndex = 0;
// TODO(P2): This is quite expensive, when // TODO(P2): This is quite expensive, when
// after every subset effect end, we have to scan // after every subset effect end, we have to scan
// the whole shape set // the whole shape set
// determine new subset range
for( const auto& rSubsetShape : maSubsetShapes )
updateSubsetBounds( rSubsetShape );
updateSubsets(); updateSubsets();
return true; return true;
......
...@@ -202,7 +202,7 @@ namespace slideshow ...@@ -202,7 +202,7 @@ namespace slideshow
typedef ::std::set< SubsetEntry > ShapeSet; typedef ::std::set< SubsetEntry > ShapeSet;
void ensureInitializedNodeTree() const; void ensureInitializedNodeTree() const;
void updateSubsetBounds( const SubsetEntry& rSubsetEntry ); void excludeSubset(sal_Int32 nExcludedStart, sal_Int32 nExcludedEnd);
void updateSubsets(); void updateSubsets();
void initCurrentSubsets(); void initCurrentSubsets();
void reset(); void reset();
...@@ -226,12 +226,6 @@ namespace slideshow ...@@ -226,12 +226,6 @@ namespace slideshow
/// the list of subset shapes spawned from this one. /// the list of subset shapes spawned from this one.
ShapeSet maSubsetShapes; ShapeSet maSubsetShapes;
/// caches minimal subset index from maSubsetShapes
sal_Int32 mnMinSubsetActionIndex;
/// caches maximal subset index from maSubsetShapes
sal_Int32 mnMaxSubsetActionIndex;
/** Current number of subsets to render (calculated from /** Current number of subsets to render (calculated from
maSubset and mnMin/MaxSubsetActionIndex). maSubset and mnMin/MaxSubsetActionIndex).
......
...@@ -90,6 +90,7 @@ namespace slideshow ...@@ -90,6 +90,7 @@ namespace slideshow
bool isEmpty() const { return mnStartIndex == mnEndIndex; } bool isEmpty() const { return mnStartIndex == mnEndIndex; }
sal_Int32 getStartIndex() const { return mnStartIndex; } sal_Int32 getStartIndex() const { return mnStartIndex; }
void setStartIndex( sal_Int32 nIndex ) { mnStartIndex = nIndex; }
sal_Int32 getEndIndex() const { return mnEndIndex; } sal_Int32 getEndIndex() const { return mnEndIndex; }
void setEndIndex( sal_Int32 nIndex ) { mnEndIndex = nIndex; } void setEndIndex( sal_Int32 nIndex ) { mnEndIndex = nIndex; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment