[Libreoffice-commits] core.git: Branch 'distro/vector/vector-7.0' - include/svx svx/source sw/inc sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 16 12:51:47 UTC 2021


 include/svx/svdxcgv.hxx                 |    2 +-
 svx/source/svdraw/svdxcgv.cxx           |    4 ++--
 sw/inc/frmfmt.hxx                       |    6 +++---
 sw/qa/extras/htmlexport/htmlexport.cxx  |   17 ++++++++---------
 sw/source/core/layout/paintfrm.cxx      |    8 ++++----
 sw/source/filter/html/htmlflywriter.cxx |    2 +-
 6 files changed, 19 insertions(+), 20 deletions(-)

New commits:
commit 24cd981bb5bdbf541b6ed263a192836565c36e2b
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Jun 16 10:11:47 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jun 16 14:51:10 2021 +0200

    sw HTML export: allow larger bitmaps for shapes than the vcl default
    
    VCL default would be 500k pixels, i.e. a 2" x 1" shape at 600 dpi would
    be already truncated from 1200 pixels width to 1000 pixels. That's a bit
    too extreme, use a larger limit in the sw HTML export.
    
    (cherry picked from commit 3c46fd3d727e4885fedef7c9f3fcd6f4c9a9ebb9)
    
    Conflicts:
            sw/qa/extras/htmlexport/htmlexport.cxx
            sw/source/core/layout/paintfrm.cxx
    
    Change-Id: I52b85d77cd27410d53c700a89190c99348de5e19

diff --git a/include/svx/svdxcgv.hxx b/include/svx/svdxcgv.hxx
index 0afaa7c6ad6f..8ed2adbb126d 100644
--- a/include/svx/svdxcgv.hxx
+++ b/include/svx/svdxcgv.hxx
@@ -58,7 +58,7 @@ public:
 
     // Draw all marked objects onto a bitmap, with the display's color depth
     // and resolution
-    BitmapEx GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked = false, const std::optional<Size>& rTargetDPI = std::nullopt) const;
+    BitmapEx GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked = false, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt) const;
 
     // Copy all marked objects to a new model, consisting of exactly one page,
     // with the flag PageNotValid set. This means, that only the page's objects
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index a576b8ee4ab0..38e7975f770d 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -425,7 +425,7 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po
     }
 }
 
-BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked, const std::optional<Size>& rTargetDPI) const
+BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked, const sal_uInt32 nMaximumQuadraticPixels, const std::optional<Size>& rTargetDPI) const
 {
     BitmapEx aBmp;
 
@@ -502,7 +502,7 @@ BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked, const
                     aBmp = convertPrimitive2DSequenceToBitmapEx(
                         xPrimitives,
                         aRange,
-                        /*nMaximumQuadraticPixels=*/ 500000,
+                        nMaximumQuadraticPixels,
                         eRangeUnit,
                         rTargetDPI);
                 }
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index e2cb600f2673..e6c72712118e 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -115,7 +115,7 @@ public:
     /// Creates the views.
     virtual void MakeFrames();
 
-    virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const std::optional<Size>& rTargetDPI = std::nullopt );
+    virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt );
 
     /**  @return the IMapObject defined at format (Fly)
         in the ImageMap at position Point.
@@ -210,7 +210,7 @@ public:
 
     SwAnchoredObject* GetAnchoredObj() const;
 
-    virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
+    virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
 
     virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
 
@@ -386,7 +386,7 @@ public:
      Reset delete marks. */
     virtual void MakeFrames() override;
 
-    virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
+    virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
 
     virtual SwFrameFormat::tLayoutDir GetLayoutDir() const override;
     virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir ) override;
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 1fd48f104ed6..3dfe581a4858 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -1764,12 +1764,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifEmbedShapeAsPNGCustomDPI)
     uno::Reference<css::lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
     uno::Reference<drawing::XShape> xShape(
         xFactory->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY);
-    xShape->setSize(awt::Size(7145, 5240));
+    xShape->setSize(awt::Size(5080, 2540));
     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
     xDrawPageSupplier->getDrawPage()->add(xShape);
-    Size aSystemDPI(
-        Application::GetDefaultDevice()->LogicToPixel(Size(1, 1), MapMode(MapUnit::MapInch)));
-    sal_Int32 nDPI = aSystemDPI.getWidth() * 2;
+    sal_Int32 nDPI = 600;
 
     // When exporting to XHTML:
     uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
@@ -1788,17 +1786,18 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifEmbedShapeAsPNGCustomDPI)
     assertXPath(pXmlDoc, "//reqif-xhtml:p/reqif-xhtml:object", "type", "image/png");
 
     // Then check the pixel size of the shape:
-    Size aPixelSize(Application::GetDefaultDevice()->LogicToPixel(Size(7145, 5240),
+    Size aPixelSize(Application::GetDefaultDevice()->LogicToPixel(Size(5080, 2540),
                                                                   MapMode(MapUnit::Map100thMM)));
-    long nPNGWidth = aPixelSize.getWidth() * 2;
+    long nPNGWidth = 1200;
     OUString aPngUrl = GetPngPath();
     SvFileStream aFileStream(aPngUrl, StreamMode::READ);
     GraphicDescriptor aDescriptor(aFileStream, nullptr);
     aDescriptor.Detect(/*bExtendedInfo=*/true);
     // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: 540
-    // - Actual  : 270
-    // i.e. setting a double DPI didn't result in larger pixel width of the PNG.
+    // - Expected: 1200
+    // - Actual  : 1000
+    // i.e. first setting a double DPI didn't result in larger pixel width of the PNG, then it was
+    // limited to 1000 pixels (because the pixel limit was 500k).
     CPPUNIT_ASSERT_EQUAL(nPNGWidth, aDescriptor.GetSizePixel().getWidth());
 
     // Then make sure the shape's logic size (in CSS pixels) don't change:
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 4692affd6a8e..bba21aa0608f 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -7364,12 +7364,12 @@ void SetOutDevAndWin( SwViewShell *pSh, OutputDevice *pO,
     pSh->mpOpt->SetZoom( nZoom );
 }
 
-Graphic SwFrameFormat::MakeGraphic( ImageMap*, const std::optional<Size>& /*rTargetDPI*/ )
+Graphic SwFrameFormat::MakeGraphic( ImageMap*, const sal_uInt32 /*nMaximumQuadraticPixels*/, const std::optional<Size>& /*rTargetDPI*/ )
 {
     return Graphic();
 }
 
-Graphic SwFlyFrameFormat::MakeGraphic( ImageMap* pMap, const std::optional<Size>& /*rTargetDPI*/ )
+Graphic SwFlyFrameFormat::MakeGraphic( ImageMap* pMap, const sal_uInt32 /*nMaximumQuadraticPixels*/, const std::optional<Size>& /*rTargetDPI*/ )
 {
     Graphic aRet;
     //search any Fly!
@@ -7476,7 +7476,7 @@ Graphic SwFlyFrameFormat::MakeGraphic( ImageMap* pMap, const std::optional<Size>
     return aRet;
 }
 
-Graphic SwDrawFrameFormat::MakeGraphic( ImageMap*, const std::optional<Size>& rTargetDPI )
+Graphic SwDrawFrameFormat::MakeGraphic( ImageMap*, const sal_uInt32 nMaximumQuadraticPixels, const std::optional<Size>& rTargetDPI )
 {
     Graphic aRet;
     SwDrawModel* pMod = getIDocumentDrawModelAccess().GetDrawModel();
@@ -7486,7 +7486,7 @@ Graphic SwDrawFrameFormat::MakeGraphic( ImageMap*, const std::optional<Size>& rT
         std::unique_ptr<SdrView> pView( new SdrView( *pMod ) );
         SdrPageView *pPgView = pView->ShowSdrPage(pView->GetModel()->GetPage(0));
         pView->MarkObj( pObj, pPgView );
-        aRet = pView->GetMarkedObjBitmapEx(/*bNoVDevIfOneBmpMarked=*/false, rTargetDPI);
+        aRet = pView->GetMarkedObjBitmapEx(/*bNoVDevIfOneBmpMarked=*/false, nMaximumQuadraticPixels, rTargetDPI);
         pView->HideSdrPage();
     }
     return aRet;
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index c5a40b3cd67f..9f249b06d4d3 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -1812,7 +1812,7 @@ static Writer & OutHTML_FrameFormatAsImage( Writer& rWrt, const SwFrameFormat& r
     {
         aDPI.emplace(*rHTMLWrt.m_nShapeDPI, *rHTMLWrt.m_nShapeDPI);
     }
-    Graphic aGraphic( const_cast<SwFrameFormat &>(rFrameFormat).MakeGraphic( &aIMap, aDPI ) );
+    Graphic aGraphic( const_cast<SwFrameFormat &>(rFrameFormat).MakeGraphic( &aIMap, /*nMaximumQuadraticPixels=*/2100000, aDPI ) );
 
     if (rHTMLWrt.mbReqIF)
     {


More information about the Libreoffice-commits mailing list