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@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 0000000..796b57b
--- /dev/null
+++ b/sd/qa/unit/data/tdf129898_faulty_DrawnInSlideshow.odp
Binary files differ
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
index 3e23752..53707a5 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 e43d08b..1b63f0d 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 dab56e5..110e775 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 f9b5e6b..a0c6524 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 65589c4..220f1f61 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& )