[Libreoffice-commits] core.git: sd/qa sd/source slideshow/source xmloff/source
Regina Henschel (via logerrit)
logerrit at kemper.freedesktop.org
Sat Apr 25 12:50:04 UTC 2020
sd/qa/unit/data/tdf129898_faulty_DrawnInSlideshow.odp |binary
sd/qa/unit/misc-tests.cxx | 25 ++++++++++++++++
sd/source/ui/slideshow/slideshow.cxx | 26 +++++++++++++++++
sd/source/ui/view/drviews5.cxx | 17 +++++++++++
slideshow/source/engine/slideshowimpl.cxx | 27 +++++++++++-------
xmloff/source/draw/layerimp.cxx | 9 ++++++
6 files changed, 94 insertions(+), 10 deletions(-)
New commits:
commit eb2d669af61b8808d5819b16157c59d3c6c3e03b
Author: Regina Henschel <rb.henschel at t-online.de>
AuthorDate: Sun Apr 19 18:22:11 2020 +0200
Commit: Regina Henschel <rb.henschel at t-online.de>
CommitDate: Sat Apr 25 14:49:30 2020 +0200
tdf#129898 Use layer DrawnInSlideshow in edit mode
If 'Mouse pointer as pen' is set in slideshow settings, painting in
slideshow becomes persistent. A layer DrawnInSlideshow is created
for that purpose during slideshow. But that layer was not known to
the view from where the slideshow was started.
Generating a layer had been done regardless whether such layer
already exists or not. That had produced several layers with
identical name. That may not happen, because layers are identified
by name.
Change-Id: I2ba9bad5babe5a1bba3d1fc69d028d9037d2bd47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92502
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel at t-online.de>
diff --git a/sd/qa/unit/data/tdf129898_faulty_DrawnInSlideshow.odp b/sd/qa/unit/data/tdf129898_faulty_DrawnInSlideshow.odp
new file mode 100644
index 000000000000..796b57b2cb84
Binary files /dev/null and b/sd/qa/unit/data/tdf129898_faulty_DrawnInSlideshow.odp differ
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
index 3e23752aa477..53707a5676a2 100644
--- a/sd/qa/unit/misc-tests.cxx
+++ b/sd/qa/unit/misc-tests.cxx
@@ -82,6 +82,7 @@ public:
void testTdf98839_ShearVFlipH();
void testTdf130988();
void testTdf131033();
+ void testTdf129898LayerDrawnInSlideshow();
CPPUNIT_TEST_SUITE(SdMiscTest);
CPPUNIT_TEST(testTdf96206);
@@ -102,6 +103,7 @@ public:
CPPUNIT_TEST(testTdf98839_ShearVFlipH);
CPPUNIT_TEST(testTdf130988);
CPPUNIT_TEST(testTdf131033);
+ CPPUNIT_TEST(testTdf129898LayerDrawnInSlideshow);
CPPUNIT_TEST_SUITE_END();
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -854,6 +856,29 @@ void SdMiscTest::testTdf131033()
xDocShRef->DoClose();
}
+void SdMiscTest::testTdf129898LayerDrawnInSlideshow()
+{
+ // Versions LO 6.2 to 6.4 have produced files, where the layer DrawnInSlideshow has
+ // got visible=false and printable=false attributes. Those files should be repaired now.
+ const OUString sURL = "sd/qa/unit/data/tdf129898_faulty_DrawnInSlideshow.odp";
+ sd::DrawDocShellRef xDocShRef = Load(m_directories.getURLFromSrc(sURL), ODP);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load file.", xDocShRef.is());
+
+ // Verify model
+ const OUString sName = "DrawnInSlideshow";
+ SdrLayerAdmin& rLayerAdmin = xDocShRef->GetDoc()->GetLayerAdmin();
+ SdrLayer* pLayer = rLayerAdmin.GetLayer(sName);
+ CPPUNIT_ASSERT_MESSAGE("No layer DrawnInSlideshow", pLayer);
+ CPPUNIT_ASSERT(pLayer->IsVisibleODF() && pLayer->IsPrintableODF());
+
+ // Verify view
+ sd::DrawViewShell* pViewShell = static_cast<sd::DrawViewShell*>(xDocShRef->GetViewShell());
+ SdrPageView* pPageView = pViewShell->GetView()->GetSdrPageView();
+ CPPUNIT_ASSERT(pPageView->IsLayerVisible(sName) && pPageView->IsLayerPrintable(sName));
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx
index e43d08b960a9..1b63f0d06f14 100644
--- a/sd/source/ui/slideshow/slideshow.cxx
+++ b/sd/source/ui/slideshow/slideshow.cxx
@@ -28,6 +28,7 @@
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
#include <svx/svdpool.hxx>
+#include <svx/svdlayer.hxx>
#include <svl/itemprop.hxx>
#include <sfx2/bindings.hxx>
@@ -35,6 +36,7 @@
#include <sfx2/sfxsids.hrc>
#include <framework/FrameworkHelper.hxx>
+#include <comphelper/extract.hxx>
#include <FrameView.hxx>
#include <createpresentation.hxx>
@@ -766,6 +768,30 @@ void SAL_CALL SlideShow::end()
}
}
+ // In case mbMouseAsPen was set, a new layer DrawnInSlideshow might have been generated
+ // during slideshow, which is not known to FrameView yet.
+ if (any2bool(getPropertyValue("UsePen"))
+ && pViewShell->GetDoc()->GetLayerAdmin().GetLayer("DrawnInSlideshow"))
+ {
+ SdrLayerIDSet aDocLayerIDSet;
+ pViewShell->GetDoc()->GetLayerAdmin().getVisibleLayersODF(aDocLayerIDSet);
+ if (pViewShell->GetFrameView()->GetVisibleLayers() != aDocLayerIDSet)
+ {
+ pViewShell->GetFrameView()->SetVisibleLayers(aDocLayerIDSet);
+ }
+ pViewShell->GetDoc()->GetLayerAdmin().getPrintableLayersODF(aDocLayerIDSet);
+ if (pViewShell->GetFrameView()->GetPrintableLayers() != aDocLayerIDSet)
+ {
+ pViewShell->GetFrameView()->SetPrintableLayers(aDocLayerIDSet);
+ }
+ pViewShell->GetDoc()->GetLayerAdmin().getLockedLayersODF(aDocLayerIDSet);
+ if (pViewShell->GetFrameView()->GetLockedLayers() != aDocLayerIDSet)
+ {
+ pViewShell->GetFrameView()->SetLockedLayers(aDocLayerIDSet);
+ }
+ pViewShell->InvalidateWindows();
+ }
+
// Fire the acc focus event when focus is switched back. The above method
// mpCurrentViewShellBase->GetWindow()->GrabFocus() will set focus to WorkWindow
// instead of the sd::window, so here call Shell's method to fire the focus event
diff --git a/sd/source/ui/view/drviews5.cxx b/sd/source/ui/view/drviews5.cxx
index dab56e56aa6b..110e7756225f 100644
--- a/sd/source/ui/view/drviews5.cxx
+++ b/sd/source/ui/view/drviews5.cxx
@@ -493,6 +493,23 @@ void DrawViewShell::ReadUserDataSequence ( const css::uno::Sequence < css::beans
rLayerAdmin.getLockedLayersODF( aSdrLayerIDSet );
mpFrameView -> SetLockedLayers( aSdrLayerIDSet );
}
+ else
+ {
+ // tdf#129898 repair layer "DrawnInSlideshow", which was wrongly written
+ // in LO 6.2 to 6.4. The ODF defaults were corrected when reading draw:layer-set, but
+ // not in reading config settings, because there the name is not known.
+ const SdrLayerAdmin& rLayerAdmin = GetDocSh()->GetDoc()->GetLayerAdmin();
+ if (rLayerAdmin.GetLayer("DrawnInSlideshow"))
+ {
+ SdrLayerIDSet aSdrLayerIDSet;
+ rLayerAdmin.getVisibleLayersODF( aSdrLayerIDSet );
+ mpFrameView -> SetVisibleLayers( aSdrLayerIDSet );
+ rLayerAdmin.getPrintableLayersODF( aSdrLayerIDSet );
+ mpFrameView -> SetPrintableLayers( aSdrLayerIDSet );
+ rLayerAdmin.getLockedLayersODF( aSdrLayerIDSet );
+ mpFrameView -> SetLockedLayers( aSdrLayerIDSet );
+ }
+ }
if( mpFrameView->GetPageKind() != mePageKind )
diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx
index f9b5e6ba8032..a0c652450bcb 100644
--- a/slideshow/source/engine/slideshowimpl.cxx
+++ b/slideshow/source/engine/slideshowimpl.cxx
@@ -1376,25 +1376,32 @@ void SlideShowImpl::registerUserPaintPolygons( const uno::Reference< lang::XMult
maPolygons.insert(make_pair(mpCurrentSlide->getXDrawPage(),mpCurrentSlide->getPolygons()));
}
- //Creating the layer for shapes
+ //Creating the layer for shapes drawn during slideshow
// query for the XLayerManager
uno::Reference< drawing::XLayerSupplier > xLayerSupplier(xDocFactory, uno::UNO_QUERY);
uno::Reference< container::XNameAccess > xNameAccess = xLayerSupplier->getLayerManager();
-
uno::Reference< drawing::XLayerManager > xLayerManager(xNameAccess, uno::UNO_QUERY);
- // create a layer and set its properties
- uno::Reference< drawing::XLayer > xDrawnInSlideshow = xLayerManager->insertNewByIndex(xLayerManager->getCount());
- //Layer Name which enables to catch annotations
- OUString layerName = "DrawnInSlideshow";
+ // create layer
+ uno::Reference< drawing::XLayer > xDrawnInSlideshow;
uno::Any aPropLayer;
+ OUString sLayerName = "DrawnInSlideshow";
+ if (xNameAccess->hasByName(sLayerName))
+ {
+ xNameAccess->getByName(sLayerName) >>= xDrawnInSlideshow;
+ }
+ else
+ {
+ xDrawnInSlideshow = xLayerManager->insertNewByIndex(xLayerManager->getCount());
+ aPropLayer <<= sLayerName;
+ xDrawnInSlideshow->setPropertyValue("Name", aPropLayer);
+ }
- aPropLayer <<= layerName;
- xDrawnInSlideshow->setPropertyValue("Name", aPropLayer);
-
+ // ODF defaults from ctor of SdrLayer are not automatically set on the here
+ // created XLayer. Need to be done explicitely here.
aPropLayer <<= true;
xDrawnInSlideshow->setPropertyValue("IsVisible", aPropLayer);
-
+ xDrawnInSlideshow->setPropertyValue("IsPrintable", aPropLayer);
aPropLayer <<= false;
xDrawnInSlideshow->setPropertyValue("IsLocked", aPropLayer);
diff --git a/xmloff/source/draw/layerimp.cxx b/xmloff/source/draw/layerimp.cxx
index 65589c486e17..220f1f618d23 100644
--- a/xmloff/source/draw/layerimp.cxx
+++ b/xmloff/source/draw/layerimp.cxx
@@ -149,6 +149,15 @@ void SdXMLLayerContext::EndElement()
if ( !msProtected.isEmpty() )
bIsLocked = (msProtected == "true");
xLayer->setPropertyValue("IsLocked", Any( bIsLocked ) );
+
+ // tdf#129898 repair layer "DrawnInSlideshow", which was wrongly written
+ // in LO 6.2 to 6.4. It should always have ODF defaults.
+ if (msName == "DrawnInSlideshow")
+ {
+ xLayer->setPropertyValue("IsVisible", Any(true));
+ xLayer->setPropertyValue("IsPrintable", Any(true));
+ xLayer->setPropertyValue("IsLocked", Any(false));
+ }
}
}
catch( Exception& )
More information about the Libreoffice-commits
mailing list