summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-06-28 14:51:31 +1000
committerAron Budea <aron.budea@collabora.com>2018-06-28 19:09:44 +0200
commite6f945ad12245496f09d01f05ca75d673b3d58d2 (patch)
treef9e63251de4d294e64df8a8c523108c8e69afdbc /slideshow
parentc5463b865f4096246833d2cee9cbfbae336151e5 (diff)
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/56575 Reviewed-by: Aron Budea <aron.budea@collabora.com> Tested-by: Aron Budea <aron.budea@collabora.com>
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/shapes/drawshapesubsetting.cxx108
-rw-r--r--slideshow/source/engine/shapes/drawshapesubsetting.hxx8
-rw-r--r--slideshow/source/inc/doctreenode.hxx1
3 files changed, 54 insertions, 63 deletions
diff --git a/slideshow/source/engine/shapes/drawshapesubsetting.cxx b/slideshow/source/engine/shapes/drawshapesubsetting.cxx
index d8a1ad127f55..fdb6bdc66f4a 100644
--- a/slideshow/source/engine/shapes/drawshapesubsetting.cxx
+++ b/slideshow/source/engine/shapes/drawshapesubsetting.cxx
@@ -164,54 +164,67 @@ namespace slideshow
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
- mnMinSubsetActionIndex = ::std::min(
- mnMinSubsetActionIndex,
- rSubsetEntry.mnStartActionIndex );
- mnMaxSubsetActionIndex = ::std::max(
- mnMaxSubsetActionIndex,
- rSubsetEntry.mnEndActionIndex );
- }
-
- void DrawShapeSubsetting::updateSubsets()
- {
- maCurrentSubsets.clear();
+ // If current subsets are empty, fill it with initial range
+ initCurrentSubsets();
+ if (maCurrentSubsets.empty())
+ {
+ // Non-subsetting mode (not a subset of anything; child subsets subtract content)
+ maCurrentSubsets.push_back(DocTreeNode(0, maActionClassVector.size(),
+ DocTreeNode::NODETYPE_INVALID));
+ }
- 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
- // that subtract from it
- maCurrentSubsets.push_back( DocTreeNode( 0,
- mnMinSubsetActionIndex,
- DocTreeNode::NODETYPE_INVALID ) );
- maCurrentSubsets.push_back( DocTreeNode( mnMaxSubsetActionIndex,
- maActionClassVector.size(),
- DocTreeNode::NODETYPE_INVALID ) );
+ if (i->getEndIndex() > nExcludedStart)
+ {
+ // Some overlap -> append new node (if required), and correct this node's end
+ if (i->getEndIndex() > nExcludedEnd)
+ {
+ aNodesToAppend.push_back(DocTreeNode(nExcludedEnd, i->getEndIndex(),
+ DocTreeNode::NODETYPE_INVALID));
+ }
+ 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
{
- // subsetted node, from which some further child
- // subsets subtract content
- maCurrentSubsets.push_back( DocTreeNode( maSubset.getStartIndex(),
- mnMinSubsetActionIndex,
- DocTreeNode::NODETYPE_INVALID ) );
- maCurrentSubsets.push_back( DocTreeNode( mnMaxSubsetActionIndex,
- maSubset.getEndIndex(),
- DocTreeNode::NODETYPE_INVALID ) );
+ // Node is fully outside (after) excluded range
+ ++i;
}
}
- 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)
- if( !maSubset.isEmpty() )
- {
- // subsetted node, without any subset children
- maCurrentSubsets.push_back( maSubset );
- }
+ excludeSubset(rSubsetShape.mnStartActionIndex, rSubsetShape.mnEndActionIndex);
}
}
@@ -224,8 +237,6 @@ namespace slideshow
mpMtf(),
maSubset(),
maSubsetShapes(),
- mnMinSubsetActionIndex( SAL_MAX_INT32 ),
- mnMaxSubsetActionIndex(0),
maCurrentSubsets(),
mbNodeTreeInitialized( false )
{
@@ -237,8 +248,6 @@ namespace slideshow
mpMtf( rMtf ),
maSubset( rShapeSubset ),
maSubsetShapes(),
- mnMinSubsetActionIndex( SAL_MAX_INT32 ),
- mnMaxSubsetActionIndex(0),
maCurrentSubsets(),
mbNodeTreeInitialized( false )
{
@@ -254,8 +263,6 @@ namespace slideshow
mpMtf.reset();
maSubset.reset();
maSubsetShapes.clear();
- mnMinSubsetActionIndex = SAL_MAX_INT32;
- mnMaxSubsetActionIndex = 0;
maCurrentSubsets.clear();
mbNodeTreeInitialized = false;
}
@@ -330,9 +337,7 @@ namespace slideshow
maSubsetShapes.insert( aEntry );
- // update cached subset borders
- updateSubsetBounds( aEntry );
- updateSubsets();
+ excludeSubset(aEntry.mnStartActionIndex, aEntry.mnEndActionIndex);
}
}
@@ -384,19 +389,10 @@ namespace slideshow
// part of this shape that is visible, i.e. not displayed
// in subset shapes)
-
- // init bounds
- mnMinSubsetActionIndex = SAL_MAX_INT32;
- mnMaxSubsetActionIndex = 0;
-
// TODO(P2): This is quite expensive, when
// after every subset effect end, we have to scan
// the whole shape set
- // determine new subset range
- for( const auto& rSubsetShape : maSubsetShapes )
- updateSubsetBounds( rSubsetShape );
-
updateSubsets();
return true;
diff --git a/slideshow/source/engine/shapes/drawshapesubsetting.hxx b/slideshow/source/engine/shapes/drawshapesubsetting.hxx
index 56c4f5dca346..4a5fccaf15fa 100644
--- a/slideshow/source/engine/shapes/drawshapesubsetting.hxx
+++ b/slideshow/source/engine/shapes/drawshapesubsetting.hxx
@@ -202,7 +202,7 @@ namespace slideshow
typedef ::std::set< SubsetEntry > ShapeSet;
void ensureInitializedNodeTree() const;
- void updateSubsetBounds( const SubsetEntry& rSubsetEntry );
+ void excludeSubset(sal_Int32 nExcludedStart, sal_Int32 nExcludedEnd);
void updateSubsets();
void initCurrentSubsets();
void reset();
@@ -226,12 +226,6 @@ namespace slideshow
/// the list of subset shapes spawned from this one.
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
maSubset and mnMin/MaxSubsetActionIndex).
diff --git a/slideshow/source/inc/doctreenode.hxx b/slideshow/source/inc/doctreenode.hxx
index 584832cc3b9d..edcc17c54e50 100644
--- a/slideshow/source/inc/doctreenode.hxx
+++ b/slideshow/source/inc/doctreenode.hxx
@@ -102,6 +102,7 @@ namespace slideshow
bool isEmpty() const { return mnStartIndex == mnEndIndex; }
sal_Int32 getStartIndex() const { return mnStartIndex; }
+ void setStartIndex( sal_Int32 nIndex ) { mnStartIndex = nIndex; }
sal_Int32 getEndIndex() const { return mnEndIndex; }
void setEndIndex( sal_Int32 nIndex ) { mnEndIndex = nIndex; }