summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-02-23 12:30:02 +0100
committerAndras Timar <andras.timar@collabora.com>2018-02-28 09:12:14 +0100
commitea68707c2fed39eb00fdc8c24b0360005b1f1c0e (patch)
treefc4c8e5462c431fe57623b449833fe40fca11146 /sd
parenta055e423512d2b19afb57ea5c3518b920d7dd131 (diff)
tdf#115873 sd navigator: adapt IsEqualToDoc() to Fill() further
SdPageObjsTLB::Fill() populates the navigator tree list box, SdPageObjsTLB::IsEqualToDoc() determintes if it has to be refreshed or not. Commit f3c68cdf8f6a0273c62b493552f78af0138a44e8 (tdf#115873 sd navigator: allow selecting but not focusing on objects, 2018-02-21) already brought IsEqualToDoc() closer to Fill() with using the same iteration mode for the SdrObjects, but that's not enough. Fill() uses flat iteration, then checks for group shapes explicitly and visits them recursively. Change IsEqualToDoc() to do the same, this way selecting "Rectangle 3" in the testcase won't result in a jump back to "Slide 1" (as an effect of IsEqualToDoc() returning false for an up to date tree list box). Change-Id: If2543cbc282af06ba43d4804e7ed455c8b9828cd Reviewed-on: https://gerrit.libreoffice.org/50234 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 1f159a4df7dcf9c4b1a35d16aee2303b8fa34b27) Reviewed-on: https://gerrit.libreoffice.org/50346 Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/data/tdf115873-group.fodp36
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx17
-rw-r--r--sd/source/ui/dlg/sdtreelb.cxx82
-rw-r--r--sd/source/ui/inc/sdtreelb.hxx3
4 files changed, 104 insertions, 34 deletions
diff --git a/sd/qa/unit/tiledrendering/data/tdf115873-group.fodp b/sd/qa/unit/tiledrendering/data/tdf115873-group.fodp
new file mode 100644
index 000000000000..603ec4c7e5b2
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/tdf115873-group.fodp
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.presentation">
+ <office:automatic-styles>
+ <style:style style:name="dp1" style:family="drawing-page">
+ </style:style>
+ <style:style style:name="gr1" style:family="graphic" style:parent-style-name="standard">
+ <style:graphic-properties draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" draw:auto-grow-height="false" fo:min-height="2.15cm" fo:min-width="1.3cm"/>
+ </style:style>
+ <style:style style:name="gr2" style:family="graphic" style:parent-style-name="standard">
+ <style:graphic-properties draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" draw:auto-grow-height="false" fo:min-height="1.55cm" fo:min-width="1.3cm"/>
+ </style:style>
+ <style:style style:name="gr3" style:family="graphic" style:parent-style-name="standard">
+ <style:graphic-properties draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" draw:auto-grow-height="false" fo:min-height="1.55cm" fo:min-width="2.1cm"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:presentation>
+ <draw:page draw:name="page1" draw:style-name="dp1">
+ <draw:g draw:name="Group 1">
+ <draw:custom-shape draw:name="Rectangle 1" draw:style-name="gr1" draw:layer="layout" svg:width="1.8cm" svg:height="2.4cm" svg:x="2.8cm" svg:y="2.8cm">
+ <text:p/>
+ <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:type="rectangle" draw:enhanced-path="M 0 0 L 21600 0 21600 21600 0 21600 0 0 Z N"/>
+ </draw:custom-shape>
+ <draw:custom-shape draw:name="Rectangle 2" draw:style-name="gr2" draw:layer="layout" svg:width="1.8cm" svg:height="1.8cm" svg:x="6cm" svg:y="3.2cm">
+ <text:p/>
+ <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:type="rectangle" draw:enhanced-path="M 0 0 L 21600 0 21600 21600 0 21600 0 0 Z N"/>
+ </draw:custom-shape>
+ </draw:g>
+ <draw:custom-shape draw:name="Rectangle 3" draw:style-name="gr3" draw:layer="layout" svg:width="2.6cm" svg:height="1.8cm" svg:x="4.6cm" svg:y="7.4cm">
+ <text:p/>
+ <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:type="rectangle" draw:enhanced-path="M 0 0 L 21600 0 21600 21600 0 21600 0 0 Z N"/>
+ </draw:custom-shape>
+ </draw:page>
+ </office:presentation>
+ </office:body>
+</office:document>
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 91cc1b672c4c..bb5ad0581e0d 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -103,6 +103,7 @@ public:
void testMultiViewInsertDeletePage();
void testTdf115783();
void testTdf115873();
+ void testTdf115873Group();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -141,6 +142,7 @@ public:
CPPUNIT_TEST(testMultiViewInsertDeletePage);
CPPUNIT_TEST(testTdf115783);
CPPUNIT_TEST(testTdf115873);
+ CPPUNIT_TEST(testTdf115873Group);
CPPUNIT_TEST_SUITE_END();
@@ -1885,6 +1887,21 @@ void SdTiledRenderingTest::testTdf115873()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rMarkList.GetMarkCount());
}
+void SdTiledRenderingTest::testTdf115873Group()
+{
+ // Initialize the navigator.
+ SdXImpressDocument* pXImpressDocument = createDoc("tdf115873-group.fodp");
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ CPPUNIT_ASSERT(pViewShell);
+ SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
+ ScopedVclPtrInstance<SdNavigatorWin> pNavigator(nullptr, &rBindings);
+ pNavigator->InitTreeLB(pXImpressDocument->GetDoc());
+ VclPtr<SdPageObjsTLB> pObjects = pNavigator->GetObjects();
+ // This failed, Fill() and IsEqualToDoc() were out of sync for group
+ // shapes.
+ CPPUNIT_ASSERT(pObjects->IsEqualToDoc(pXImpressDocument->GetDoc()));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index 763c074213db..dfe7a00bd9b6 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -779,6 +779,52 @@ void SdPageObjsTLB::SetShowAllShapes (
}
}
+bool SdPageObjsTLB::IsEqualToShapeList(SvTreeListEntry*& pEntry, const SdrObjList& rList,
+ const OUString& rListName)
+{
+ if (!pEntry)
+ return false;
+ OUString aName = GetEntryText(pEntry);
+
+ if (rListName != aName)
+ return false;
+
+ pEntry = Next(pEntry);
+
+ SdrObjListIter aIter(rList,
+ !rList.HasObjectNavigationOrder() /* use navigation order, if available */,
+ SdrIterMode::Flat);
+
+ while (aIter.IsMore())
+ {
+ SdrObject* pObj = aIter.Next();
+
+ const OUString aObjectName(GetObjectName(pObj));
+
+ if (!aObjectName.isEmpty())
+ {
+ if (!pEntry)
+ return false;
+
+ aName = GetEntryText(pEntry);
+
+ if (aObjectName != aName)
+ return false;
+
+ if (pObj->IsGroupObject())
+ {
+ bool bRet = IsEqualToShapeList(pEntry, *pObj->GetSubList(), aObjectName);
+ if (!bRet)
+ return false;
+ }
+ else
+ pEntry = Next(pEntry);
+ }
+ }
+
+ return true;
+}
+
/**
* Checks if the pages (PageKind::Standard) of a doc and the objects on the pages
* are identical to the TreeLB.
@@ -793,9 +839,7 @@ bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc )
if( !mpDoc )
return false;
- SdrObject* pObj = nullptr;
SvTreeListEntry* pEntry = First();
- OUString aName;
// compare all pages including the objects
sal_uInt16 nPage = 0;
@@ -806,39 +850,9 @@ bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc )
const SdPage* pPage = static_cast<const SdPage*>( mpDoc->GetPage( nPage ) );
if( pPage->GetPageKind() == PageKind::Standard )
{
- if( !pEntry )
- return false;
- aName = GetEntryText( pEntry );
-
- if( pPage->GetName() != aName )
+ bool bRet = IsEqualToShapeList(pEntry, *pPage, pPage->GetName());
+ if (!bRet)
return false;
-
- pEntry = Next( pEntry );
-
- SdrObjListIter aIter(
- *pPage,
- !pPage->HasObjectNavigationOrder() /* use navigation order, if available */,
- SdrIterMode::Flat );
-
- while( aIter.IsMore() )
- {
- pObj = aIter.Next();
-
- const OUString aObjectName( GetObjectName( pObj ) );
-
- if( !aObjectName.isEmpty() )
- {
- if( !pEntry )
- return false;
-
- aName = GetEntryText( pEntry );
-
- if( aObjectName != aName )
- return false;
-
- pEntry = Next( pEntry );
- }
- }
}
nPage++;
}
diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx
index 0f51776a1e6b..619cbee2a8d6 100644
--- a/sd/source/ui/inc/sdtreelb.hxx
+++ b/sd/source/ui/inc/sdtreelb.hxx
@@ -206,6 +206,9 @@ public:
bool GetShowAllShapes() const { return mbShowAllShapes;}
bool IsNavigationGrabsFocus() const { return mbNavigationGrabsFocus; }
bool IsEqualToDoc( const SdDrawDocument* pInDoc );
+ /// Visits rList recursively and tries to advance pEntry accordingly.
+ bool IsEqualToShapeList(SvTreeListEntry*& pEntry, const SdrObjList& rList,
+ const OUString& rListName);
bool HasSelectedChildren( const OUString& rName );
bool SelectEntry( const OUString& rName );
OUString GetSelectEntry();