include/vcl/print.hxx               |    3 -
 vcl/osx/salprn.cxx                  |    2 -
 vcl/source/gdi/print.cxx            |   58 +++---------------------------------
 vcl/source/gdi/print3.cxx           |   16 ++++-----
 vcl/unx/generic/print/genprnpsp.cxx |    2 -
 5 files changed, 15 insertions(+), 66 deletions(-)

New commits:
commit e2f6c1cb82498da172938dc34458a1c0fa4195ee
Author:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
AuthorDate: Thu Jul 9 08:32:38 2020 +0200
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Tue Jul 21 12:44:57 2020 +0200

    tdf#134646 Remove "nearest paper matching" feature
    
    This was introduced with da62b0feb684b34ab191fb0f03ed5432c14cba97 to find
    the best paper size for user defined page sizes.
    
    However, this leads to problems with Impress: Slides have screen sizes which
    have no relation to paper sizes. For the slide site "Screen (16:9)" the
    page size "Executive" is the nearest matching size.
    
    However, this paper is (though supported by printers), very uncommon.
    We do not want the nearest matching paper size the printer supports, but
    rather we want to fit the slide on the printer default paper.
    
    Note that finding a matching print paper still works (and it even has some
    fuzzy matching), so some sort of "nearest paper matching" still exists,
    (but with sane limits).
    
    Change-Id: Ie60023d64b251954aa50e8bbdd36f6a290b9f278
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98396
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
    (cherry picked from commit 3cfc390ecd7c7e9095c77383c460c522437bdabe)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98968
    Reviewed-by: Michael Stahl <michael.st...@cib.de>

diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index edc55728e5f0..5ce81b9a9a27 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -207,7 +207,7 @@ private:
                                 ImplGetQueueInfo( const OUString& 
rPrinterName, const OUString* pDriver );
     VCL_DLLPRIVATE void         ImplUpdatePageData();
     VCL_DLLPRIVATE void         ImplUpdateFontList();
-    VCL_DLLPRIVATE void         ImplFindPaperFormatForUserSize( JobSetup&, 
bool bMatchNearest );
+    VCL_DLLPRIVATE void         ImplFindPaperFormatForUserSize( JobSetup& );
 
     VCL_DLLPRIVATE bool         StartJob( const OUString& rJobName, 
std::shared_ptr<vcl::PrinterController> const & );
 
@@ -314,7 +314,6 @@ public:
     sal_uInt16                  GetPaperBin() const;
     void                        SetPaper( Paper ePaper );
     bool                        SetPaperSizeUser( const Size& rSize );
-    bool                        SetPaperSizeUser( const Size& rSize, bool 
bMatchNearest );
     Paper                       GetPaper() const;
     static OUString             GetPaperName( Paper ePaper );
 
diff --git a/vcl/osx/salprn.cxx b/vcl/osx/salprn.cxx
index a1e5a0908b3b..56510b977852 100644
--- a/vcl/osx/salprn.cxx
+++ b/vcl/osx/salprn.cxx
@@ -448,7 +448,7 @@ bool AquaSalInfoPrinter::StartJob( const OUString* 
i_pFileName,
             // platform independent paper matching algorithm
             VclPtr<Printer> pPrinter( i_rController.getPrinter() );
             pPrinter->SetMapMode( MapMode( MapUnit::Map100thMM ) );
-            pPrinter->SetPaperSizeUser( aCurSize, true );
+            pPrinter->SetPaperSizeUser( aCurSize );
 
             // create view
             NSView* pPrintView = [[AquaPrintView alloc] initWithController: 
&i_rController withInfoPrinter: this];
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index c825d25f3501..e6386ef17048 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -1218,16 +1218,13 @@ void Printer::SetPrinterSettingsPreferred( bool 
bPaperSizeFromSetup)
 }
 
 // Map user paper format to an available printer paper format
-void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup, bool 
bMatchNearest )
+void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup )
 {
     ImplJobSetup& rData = aJobSetup.ImplGetData();
 
     // The angle that a landscape page will be turned counterclockwise wrt to 
portrait.
     int     nLandscapeAngle = mpInfoPrinter ? 
mpInfoPrinter->GetLandscapeAngle( &maJobSetup.ImplGetConstData() ) : 900;
-
     int     nPaperCount     = GetPaperInfoCount();
-    bool    bFound = false;
-
     PaperInfo aInfo(rData.GetPaperWidth(), rData.GetPaperHeight());
 
     // Compare all paper formats and get the appropriate one
@@ -1241,8 +1238,7 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& 
aJobSetup, bool bMatchNe
                 ImplGetPaperFormat( rPaperInfo.getWidth(),
                     rPaperInfo.getHeight() ));
             rData.SetOrientation( Orientation::Portrait );
-            bFound = true;
-            break;
+            return;
         }
     }
 
@@ -1267,49 +1263,10 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& 
aJobSetup, bool bMatchNe
                     ImplGetPaperFormat( rPaperInfo.getWidth(),
                         rPaperInfo.getHeight() ));
                 rData.SetOrientation( Orientation::Landscape );
-                bFound = true;
-                break;
+                return;
             }
         }
     }
-
-    if( ! bFound && bMatchNearest )
-    {
-         sal_Int64 nBestMatch = SAL_MAX_INT64;
-         int nBestIndex = 0;
-         Orientation eBestOrientation = Orientation::Portrait;
-         for( int i = 0; i < nPaperCount; i++ )
-         {
-             const PaperInfo& rPaperInfo = GetPaperInfo( i );
-
-             // check portrait match
-             sal_Int64 nDX = rData.GetPaperWidth() - rPaperInfo.getWidth();
-             sal_Int64 nDY = rData.GetPaperHeight() - rPaperInfo.getHeight();
-             sal_Int64 nMatch = nDX*nDX + nDY*nDY;
-             if( nMatch < nBestMatch )
-             {
-                 nBestMatch = nMatch;
-                 nBestIndex = i;
-                 eBestOrientation = Orientation::Portrait;
-             }
-
-             // check landscape match
-             nDX = rData.GetPaperWidth() - rPaperInfo.getHeight();
-             nDY = rData.GetPaperHeight() - rPaperInfo.getWidth();
-             nMatch = nDX*nDX + nDY*nDY;
-             if( nMatch < nBestMatch )
-             {
-                 nBestMatch = nMatch;
-                 nBestIndex = i;
-                 eBestOrientation = Orientation::Landscape;
-             }
-         }
-         const PaperInfo& rBestInfo = GetPaperInfo( nBestIndex );
-         rData.SetPaperFormat(
-            ImplGetPaperFormat( rBestInfo.getWidth(),
-                rBestInfo.getHeight() ));
-         rData.SetOrientation(eBestOrientation);
-    }
 }
 
 void Printer::SetPaper( Paper ePaper )
@@ -1339,7 +1296,7 @@ void Printer::SetPaper( Paper ePaper )
 
         ReleaseGraphics();
         if ( ePaper == PAPER_USER )
-            ImplFindPaperFormatForUserSize( aJobSetup, false );
+            ImplFindPaperFormatForUserSize( aJobSetup );
         if ( mpInfoPrinter->SetData( JobSetFlags::PAPERSIZE | 
JobSetFlags::ORIENTATION, &rData ))
         {
             ImplUpdateJobSetupPaper( aJobSetup );
@@ -1352,11 +1309,6 @@ void Printer::SetPaper( Paper ePaper )
 }
 
 bool Printer::SetPaperSizeUser( const Size& rSize )
-{
-    return SetPaperSizeUser( rSize, false );
-}
-
-bool Printer::SetPaperSizeUser( const Size& rSize, bool bMatchNearest )
 {
     if ( mbInPrintPage )
         return false;
@@ -1395,7 +1347,7 @@ bool Printer::SetPaperSizeUser( const Size& rSize, bool 
bMatchNearest )
         }
 
         ReleaseGraphics();
-        ImplFindPaperFormatForUserSize( aJobSetup, bMatchNearest );
+        ImplFindPaperFormatForUserSize( aJobSetup );
 
         // Changing the paper size can also change the orientation!
         if ( mpInfoPrinter->SetData( JobSetFlags::PAPERSIZE | 
JobSetFlags::ORIENTATION, &rData ))
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index cb326ae9d31a..cbf486713330 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -218,8 +218,6 @@ public:
             return maMultiPage.aPaperSize;
         return i_rPageSize;
     }
-    bool isFixedPageSize() const
-    { return mbPapersizeFromSetup; }
     PrinterController::PageSize modifyJobSetup( const css::uno::Sequence< 
css::beans::PropertyValue >& i_rProps );
     void resetPaperToLastConfigured();
 };
@@ -812,7 +810,7 @@ void PrinterController::setPrinter( const VclPtr<Printer>& 
i_rPrinter )
 
     if ( bSavedSizeOrientation )
     {
-          mpImplData->mxPrinter->SetPaperSizeUser(aPaperSize, 
!mpImplData->isFixedPageSize());
+          mpImplData->mxPrinter->SetPaperSizeUser(aPaperSize);
           mpImplData->mxPrinter->SetOrientation(eOrientation);
     }
 
@@ -892,7 +890,7 @@ void PrinterController::setupPrinter( weld::Window* 
i_pParent )
             //restore to whatever it was before we entered this method
             xPrinter->SetOrientation( eOrientation );
             if (aPaperSize != aNewPaperSize)
-                xPrinter->SetPaperSizeUser(aPaperSize, 
!mpImplData->isFixedPageSize());
+                xPrinter->SetPaperSizeUser(aPaperSize);
         }
         xPrinter->Pop();
     }
@@ -945,7 +943,7 @@ PrinterController::PageSize 
vcl::ImplPrinterControllerData::modifyJobSetup( cons
 
         Size aRealPaperSize( getRealPaperSize( aPageSize.aSize, true/*bNoNUP*/ 
) );
         if( aRealPaperSize != aCurSize )
-            mxPrinter->SetPaperSizeUser( aRealPaperSize, ! isFixedPageSize() );
+            mxPrinter->SetPaperSizeUser( aRealPaperSize );
     }
 
     // paper bin set from properties in print dialog overrides
@@ -974,7 +972,7 @@ void 
vcl::ImplPrinterControllerData::resetPaperToLastConfigured()
     mxPrinter->SetMapMode(MapMode(MapUnit::Map100thMM));
     Size aCurSize(mxPrinter->GetPaperSize());
     if (aCurSize != maDefaultPageSize)
-        mxPrinter->SetPaperSizeUser(maDefaultPageSize, !isFixedPageSize());
+        mxPrinter->SetPaperSizeUser(maDefaultPageSize);
     mxPrinter->Pop();
 }
 
@@ -1121,7 +1119,7 @@ PrinterController::PageSize 
PrinterController::getFilteredPageFile( int i_nFilte
         }
         Size aPaperSize = mpImplData->getRealPaperSize( aPageSize.aSize, true 
);
         mpImplData->mxPrinter->SetMapMode( MapMode( MapUnit::Map100thMM ) );
-        mpImplData->mxPrinter->SetPaperSizeUser( aPaperSize, ! 
mpImplData->isFixedPageSize() );
+        mpImplData->mxPrinter->SetPaperSizeUser( aPaperSize );
         if( aPaperSize != aPageSize.aSize )
         {
             // user overridden page size, center Metafile
@@ -1231,7 +1229,7 @@ PrinterController::PageSize 
PrinterController::getFilteredPageFile( int i_nFilte
 
     // subsequent getPageFile calls have changed the paper, reset it to 
current value
     mpImplData->mxPrinter->SetMapMode( MapMode( MapUnit::Map100thMM ) );
-    mpImplData->mxPrinter->SetPaperSizeUser( aPaperSize, ! 
mpImplData->isFixedPageSize() );
+    mpImplData->mxPrinter->SetPaperSizeUser( aPaperSize );
 
     return PrinterController::PageSize( aPaperSize, true );
 }
@@ -1327,7 +1325,7 @@ void PrinterController::printFilteredPage( int i_nPage )
     // in N-Up printing set the correct page size
     mpImplData->mxPrinter->SetMapMode(MapMode(MapUnit::Map100thMM));
     // aPageSize was filtered through mpImplData->getRealPaperSize already by 
getFilteredPageFile()
-    mpImplData->mxPrinter->SetPaperSizeUser( aPageSize.aSize, ! 
mpImplData->isFixedPageSize() );
+    mpImplData->mxPrinter->SetPaperSizeUser( aPageSize.aSize );
     if( mpImplData->mnFixedPaperBin != -1 &&
         mpImplData->mxPrinter->GetPaperBin() != mpImplData->mnFixedPaperBin )
     {
diff --git a/vcl/unx/generic/print/genprnpsp.cxx 
b/vcl/unx/generic/print/genprnpsp.cxx
index f88d8e18bbe2..3287e365f0e7 100644
--- a/vcl/unx/generic/print/genprnpsp.cxx
+++ b/vcl/unx/generic/print/genprnpsp.cxx
@@ -1031,7 +1031,7 @@ bool PspSalPrinter::StartJob( const OUString* 
i_pFileName, const OUString& i_rJo
         else
         {
             xPrinter->SetMapMode( MapMode( MapUnit::Map100thMM ) );
-            xPrinter->SetPaperSizeUser( aPageSize.aSize, true );
+            xPrinter->SetPaperSizeUser( aPageSize.aSize );
             PDFNewJobParameters aNewParm(xPrinter->GetPaperSize(), 
xPrinter->GetPaperBin());
 
             // create PDF writer on demand
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to