[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svx/qa svx/source

2022-10-25 Thread Miklos Vajna (via logerrit)
 svx/qa/unit/data/page-view-draw-layer-clip.docx |binary
 svx/qa/unit/svdraw.cxx  |   37 
 svx/source/svdraw/svdpagv.cxx   |2 -
 3 files changed, 38 insertions(+), 1 deletion(-)

New commits:
commit 475e698826e2103bdc78ac286e1fc8970363638e
Author: Miklos Vajna 
AuthorDate: Mon Oct 10 20:38:40 2022 +0200
Commit: Xisco Fauli 
CommitDate: Tue Oct 25 21:08:12 2022 +0200

tdf#151060 sw PDF export: don't paint off-page part of drawing object

Reported to be a regression from
c12358166a9bd88fe10feabca45a6ad3f65dff8e (DOCX import: fix lost objects
anchored to an empty linked header, 2020-01-10), the 3rd page of the PDF
export result contains an unexpected line shape.

This was "working" before as all objects anchored to the empty header
were lost.

Fix the problem by clipping the rendering to the page frame when
handling shapes, similar to what
689cead9e0837dc932e3a4cd765f7d319b529018 (tdf#91260 svx, sw: don't paint
off-page part of drawing object, 2016-12-06) did to fix the normal
rendering of the document.

The testcase document just has 2 pages, so there the unexpected shape
was on the 2nd page.

Change-Id: Ica24cd15717a1ee97dff448d385a10536671103e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141167
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit bab44a97d21d0ac8a8a06678e71024c1a830943f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141180
Reviewed-by: Xisco Fauli 

diff --git a/svx/qa/unit/data/page-view-draw-layer-clip.docx 
b/svx/qa/unit/data/page-view-draw-layer-clip.docx
new file mode 100644
index ..7136a800f01f
Binary files /dev/null and b/svx/qa/unit/data/page-view-draw-layer-clip.docx 
differ
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index dacf558c5f7f..564998bcf9a9 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -37,6 +38,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -512,6 +515,40 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testVideoSnapshot)
 // i.e. ~25% crop from left and right should result in half width, but it 
was not reduced.
 CPPUNIT_ASSERT_EQUAL(static_cast(321), 
rBitmap.GetSizePixel().getWidth());
 }
+
+CPPUNIT_TEST_FIXTURE(SvdrawTest, testPageViewDrawLayerClip)
+{
+// Given a document with 2 pages, first page footer has an off-page line 
shape:
+OUString aURL = 
m_directories.getURLFromSrc(u"svx/qa/unit/data/page-view-draw-layer-clip.docx");
+mxComponent = loadFromDesktop(aURL);
+
+// When saving that document to PDF:
+utl::TempFile aTempFile;
+uno::Reference xStorable(mxComponent, uno::UNO_QUERY);
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+xStorable->storeToURL(aTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
+
+// Then make sure that line shape gets clipped:
+SvFileStream aFile(aTempFile.GetURL(), StreamMode::READ);
+SvMemoryStream aMemory;
+aMemory.WriteStream(aFile);
+std::shared_ptr pPDFium = vcl::pdf::PDFiumLibrary::get();
+if (!pPDFium)
+{
+return;
+}
+std::unique_ptr pDoc
+= pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize(), 
OString());
+std::unique_ptr pPage1 = pDoc->openPage(0);
+CPPUNIT_ASSERT_EQUAL(3, pPage1->getObjectCount());
+std::unique_ptr pPage2 = pDoc->openPage(1);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 2
+// - Actual  : 3
+// i.e. the 2nd page had a line shape from the first page's footer.
+CPPUNIT_ASSERT_EQUAL(2, pPage2->getObjectCount());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index 0e35d09b080e..60cd8cfe8ca0 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -262,7 +262,7 @@ void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* 
pGivenTarget,
 if(pKnownTarget)
 {
 // paint known target
-pKnownTarget->RedrawLayer(, pRedirector, nullptr);
+pKnownTarget->RedrawLayer(, pRedirector, pPageFrame);
 }
 else
 {


[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svx/qa svx/source

2022-08-29 Thread Miklos Vajna (via logerrit)
 svx/qa/unit/data/video-snapshot.pptx |binary
 svx/qa/unit/svdraw.cxx   |   23 +++
 svx/source/svdraw/svdomedia.cxx  |9 +
 3 files changed, 32 insertions(+)

New commits:
commit 4daac4a6b18be593550e87f97e304d5475d7e6d7
Author: Miklos Vajna 
AuthorDate: Wed Aug 24 13:53:38 2022 +0200
Commit: Caolán McNamara 
CommitDate: Mon Aug 29 22:17:05 2022 +0200

Related: tdf#149971 svx: support explicitly provided snapshots for media 
shapes

Snapshots / previews for media objects are used when the shape's video
is not playing. This is generated by seeking to the 3rd second in the
video, probably to avoid initial black frames.

The trouble is that PowerPoint takes the initial frame (at least in case
of the bugdoc), so our snapshot doesn't match the reference.

We already import a bitmap snapshot from PPTX files since commit
e2d46da076f43a7c0d56fc486b9f15339243f7c9 (avmedia: add doc model for
bitmap fill of slide narrations, 2021-01-21), fix the problem by
changing the snapshot generation to prefer this bitmap over generating
one from the video.

The crop properties of this bitmap / the video are still not yet handled
from PPTX.

(cherry picked from commit 8fa1d453c94cdbb03dac646fb8db2ebd1a0e84bd)

Change-Id: Id985ed5e4222d9a98203d054e08a0f97a0f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138962
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/svx/qa/unit/data/video-snapshot.pptx 
b/svx/qa/unit/data/video-snapshot.pptx
new file mode 100644
index ..9a0ec9ebd867
Binary files /dev/null and b/svx/qa/unit/data/video-snapshot.pptx differ
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index 9ad02060d68e..1bb9a6dab4db 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -483,6 +484,28 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testMaterialSpecular)
 // The first light is harsh, the second light soft. So the 3D scene should 
have 6 lights (1+1+4).
 assertXPath(pXmlDoc, "//light", 6);
 }
+
+CPPUNIT_TEST_FIXTURE(SvdrawTest, testVideoSnapshot)
+{
+// Given a slide with a media shape, containing a 4 sec video, 
red-green-blue-black being the 4
+// seconds:
+OUString aURL = 
m_directories.getURLFromSrc(u"svx/qa/unit/data/video-snapshot.pptx");
+mxComponent = loadFromDesktop(aURL, 
"com.sun.star.presentation.PresentationDocument");
+SdrPage* pSdrPage = getFirstDrawPageWithAssert();
+auto pSdrMediaObj = dynamic_cast(pSdrPage->GetObj(0));
+
+// When getting the red snapshot of the video:
+Graphic aSnapshot(pSdrMediaObj->getSnapshot());
+
+// Then make sure the color is correct:
+const BitmapEx& rBitmap = aSnapshot.GetBitmapExRef();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: rgba[ffff]
+// - Actual  : rgba[00ff]
+// i.e. the preview was black, not red; since we seeked 3 secs into the 
video, while PowerPoint
+// doesn't do that.
+CPPUNIT_ASSERT_EQUAL(Color(0xff, 0x0, 0x0), rBitmap.GetPixelColor(0, 0));
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 8ab9d45a54c6..de813b9000be 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -151,6 +151,15 @@ uno::Reference< graphic::XGraphic > const & 
SdrMediaObj::getSnapshot() const
 #if HAVE_FEATURE_AVMEDIA
 if( !m_xImpl->m_xCachedSnapshot.is() )
 {
+Graphic aGraphic = m_xImpl->m_MediaProperties.getGraphic();
+if (!aGraphic.IsNone())
+{
+// We have an explicit graphic for this media object, then go with 
that instead of
+// generating our own one.
+m_xImpl->m_xCachedSnapshot = aGraphic.GetXGraphic();
+return m_xImpl->m_xCachedSnapshot;
+}
+
 OUString aRealURL = m_xImpl->m_MediaProperties.getTempURL();
 if( aRealURL.isEmpty() )
 aRealURL = m_xImpl->m_MediaProperties.getURL();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - svx/qa svx/source

2022-06-27 Thread Miklos Vajna (via logerrit)
 svx/qa/unit/table.cxx|   38 +++
 svx/source/table/tablecontroller.cxx |7 ++
 2 files changed, 45 insertions(+)

New commits:
commit ee68863baa51e47ae9bb00373fce2f86ba8df1e8
Author: Miklos Vajna 
AuthorDate: Fri Jun 24 10:46:40 2022 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jun 27 14:29:44 2022 +0200

tdf#148522 svx: fix undo of cell border changes text alignment in other 
cells

The Impress table properties dialog has multiple purposes: normally it
only affects the properties of the currently active cell, but shadow is
applied on the whole shape.

Regression from commit fdeb04f7c59cf8032fe17072ed779e70505cc6ab
(tdf#129961 svx: finish UI for table shadow as direct format,
2020-12-15), we started to apply properties to the current cell, and
then to the whole shape as well, unconditionally. This affects
undo/redo, as there is a separate undo manager while the text edit of a
table cell is active and when the text edit is ended.

Fix the problem by only applying properties on the shape when there we
actually have some properties: this way the text edit is typically not
ended, bringing back the old undo/redo behavior.

Note that we still need to end the text edit if the user explicitly sets
some shadow properties, that part is unchanged with this commit.

Change-Id: I78e28bd326a2c12c3775b33957adca4cd95ac582
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136357
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins
(cherry picked from commit 3edfbc19950610bb2061d29cb58b3811b1a0b1a5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136460
Reviewed-by: Xisco Fauli 

diff --git a/svx/qa/unit/table.cxx b/svx/qa/unit/table.cxx
index c82f331f2d17..c68abe18beea 100644
--- a/svx/qa/unit/table.cxx
+++ b/svx/qa/unit/table.cxx
@@ -24,6 +24,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 using namespace ::com::sun::star;
 
@@ -99,6 +104,39 @@ CPPUNIT_TEST_FIXTURE(Test, testTableShadowBlur)
 // itself and the transparency of the cell fill.
 assertXPath(pDocument, "//objectinfo/unifiedtransparence[1]", 
"transparence", "80");
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSvxTableControllerSetAttrToSelectedShape)
+{
+// Given a document with a table shape, editing cell text:
+getComponent() = loadFromDesktop("private:factory/simpress",
+ 
"com.sun.star.presentation.PresentationDocument");
+uno::Sequence aArgs
+= { comphelper::makePropertyValue("Rows", sal_Int32(2)),
+comphelper::makePropertyValue("Columns", sal_Int32(2)) };
+dispatchCommand(mxComponent, ".uno:InsertTable", aArgs);
+uno::Reference 
xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+uno::Reference 
xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+auto pDrawPage = dynamic_cast(xDrawPage.get());
+CPPUNIT_ASSERT(pDrawPage);
+SdrPage* pSdrPage = pDrawPage->GetSdrPage();
+auto pSdrObject
+= 
dynamic_cast(pSdrPage->GetObj(pSdrPage->GetObjCount() 
- 1));
+SfxViewShell* pViewShell = SfxViewShell::Current();
+SdrView* pSdrView = pViewShell->GetDrawView();
+pSdrView->SdrBeginTextEdit(pSdrObject);
+CPPUNIT_ASSERT(pSdrView->IsTextEdit());
+const EditTextObject& rEdit = 
pSdrObject->getText(0)->GetOutlinerParaObject()->GetTextObject();
+SfxItemSet aSet(rEdit.GetParaAttribs(0));
+auto pTableController
+= 
dynamic_cast(pSdrView->getSelectionController().get());
+
+// When applying attributes which only affect the cell text, not the table 
shape:
+pTableController->SetAttrToSelectedShape(aSet);
+
+// Then make sure the text edit is not ended:
+CPPUNIT_ASSERT(pSdrView->IsTextEdit());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablecontroller.cxx 
b/svx/source/table/tablecontroller.cxx
index ef7401489c1d..1ceaa5141245 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -2754,6 +2754,13 @@ void SvxTableController::SetAttrToSelectedShape(const 
SfxItemSet& rAttr)
 SfxItemSetFixed 
aSet(*rAttr.GetPool());
 aSet.Put(rAttr);
 
+if (!aSet.Count())
+{
+// If there are no items to be applied on the shape, then don't set 
anything, it would
+// terminate text edit without a good reason, which affects undo/redo.
+return;
+}
+
 // Set shadow items on the marked shape.
 mrView.SetAttrToMarked(aSet, /*bReplaceAll=*/false);
 }