[Libreoffice-commits] core.git: Branch 'feature/print_revamp' - basctl/inc basctl/source sc/inc sc/source sd/inc sd/source sfx2/source sw/inc sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Aug 11 13:52:20 UTC 2018


 basctl/inc/strings.hrc                     |    2 
 basctl/source/basicide/basicrenderable.cxx |   32 +++++++++
 basctl/source/basicide/basicrenderable.hxx |    8 +-
 sc/inc/docuno.hxx                          |    5 +
 sc/inc/strings.hrc                         |    2 
 sc/source/ui/unoobj/docuno.cxx             |   96 +++++++++++++++++++++++++----
 sd/inc/DocumentRenderer.hrc                |    4 +
 sd/source/ui/view/DocumentRenderer.cxx     |   74 ++++++++++++++--------
 sfx2/source/view/viewprn.cxx               |   13 +++
 sw/inc/strings.hrc                         |    2 
 sw/source/core/doc/doc.cxx                 |   14 ++--
 sw/source/core/view/printdata.cxx          |   51 +++------------
 12 files changed, 212 insertions(+), 91 deletions(-)

New commits:
commit edc0aef18a259d9d194fe4be7dfe881836bd5083
Author:     Daniel Silva <danielfaleirosilva at gmail.com>
AuthorDate: Thu Jul 12 23:00:45 2018 -0300
Commit:     Daniel Silva <danielfaleirosilva at gmail.com>
CommitDate: Sat Aug 11 15:51:59 2018 +0200

    Adds print even pages/print odd pages options in print dialog
    
    Change-Id: I17733d83cc652be8c5abaf20cd4b5e23d3a577a1
    Reviewed-on: https://gerrit.libreoffice.org/57380
    Tested-by: Jenkins
    Reviewed-by: Daniel Silva <danielfaleirosilva at gmail.com>

diff --git a/basctl/inc/strings.hrc b/basctl/inc/strings.hrc
index 88d1f0a669e9..e78a5e1156b5 100644
--- a/basctl/inc/strings.hrc
+++ b/basctl/inc/strings.hrc
@@ -100,6 +100,8 @@
 #define RID_STR_PRINTDLG_PAGES              NC_("RID_STR_PRINTDLG_PAGES", "Pages:")
 #define RID_STR_PRINTDLG_PRINTALLPAGES      NC_("RID_STR_PRINTDLG_PRINTALLPAGES", "Print all pages")
 #define RID_STR_PRINTDLG_PRINTPAGES         NC_("RID_STR_PRINTDLG_PRINTPAGES", "Print pages")
+#define RID_STR_PRINTDLG_PRINTEVENPAGES     NC_("RID_STR_PRINTDLG_PRINTEVENPAGES", "Print even pages")
+#define RID_STR_PRINTDLG_PRINTODDPAGES      NC_("RID_STR_PRINTDLG_PRINTODDPAGES", "Print odd pages")
 #define RID_STR_BTNDEL                      NC_("RID_STR_BTNDEL", "~Delete")
 #define RID_STR_BTNNEW                      NC_("RID_STR_BTNNEW", "~New")
 #define RID_STR_CHOOSE                      NC_("RID_STR_CHOOSE", "Choose")
diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx
index e89adb755686..7913c8a10d75 100644
--- a/basctl/source/basicide/basicrenderable.cxx
+++ b/basctl/source/basicide/basicrenderable.cxx
@@ -48,7 +48,9 @@ Renderable::Renderable (BaseWindow* pWin)
     // create a choice for the range to print
     OUString aPrintContentName( "PrintContent" );
     const Sequence<OUString> aChoices{IDEResId(RID_STR_PRINTDLG_PRINTALLPAGES),
-                                      IDEResId(RID_STR_PRINTDLG_PRINTPAGES)};
+                                      IDEResId(RID_STR_PRINTDLG_PRINTPAGES),
+                                      IDEResId(RID_STR_PRINTDLG_PRINTEVENPAGES),
+                                      IDEResId(RID_STR_PRINTDLG_PRINTODDPAGES)};
     const Sequence<OUString> aHelpIds{".HelpID:vcl:PrintDialog:PrintContent:ListBox"};
     m_aUIProperties[1].Value = setChoiceListControlOpt( "printpagesbox", OUString(),
                                                    aHelpIds, aPrintContentName,
@@ -80,12 +82,26 @@ VclPtr< Printer > Renderable::getPrinter()
     return pPrinter;
 }
 
+bool Renderable::isPrintOddPages()
+{
+    sal_Int64 nContent = getIntValue( "PrintContent", -1 );
+    return nContent != 2;
+}
+
+bool Renderable::isPrintEvenPages()
+{
+    sal_Int64 nContent = getIntValue( "PrintContent", -1 );
+    return nContent != 3;
+}
+
 sal_Int32 SAL_CALL Renderable::getRendererCount (
         const Any&, const Sequence<beans::PropertyValue >& i_xOptions
         )
 {
     processProperties( i_xOptions );
 
+    maValidPages.clear();
+
     sal_Int32 nCount = 0;
     if( mpWindow )
     {
@@ -94,6 +110,16 @@ sal_Int32 SAL_CALL Renderable::getRendererCount (
             throw lang::IllegalArgumentException();
 
         nCount = mpWindow->countPages( pPrinter );
+
+        for (sal_Int32 nPage = 1; nPage <= nCount; nPage++)
+        {
+            if ( (isPrintEvenPages() && isOnEvenPage( nPage ))
+                || (isPrintOddPages() && !isOnEvenPage( nPage )) )
+            {
+                maValidPages.push_back( nPage-1 );
+            }
+        }
+
         sal_Int64 nContent = getIntValue( "PrintContent", -1 );
         if( nContent == 1 )
         {
@@ -106,6 +132,8 @@ sal_Int32 SAL_CALL Renderable::getRendererCount (
                     nCount = nSelCount;
             }
         }
+        else if ( nContent == 2 || nContent == 3 ) // even/odd pages
+            return static_cast<sal_Int32>( maValidPages.size() );
     }
 
     return nCount;
@@ -170,7 +198,7 @@ void SAL_CALL Renderable::render (
                 mpWindow->printPage( nRenderer, pPrinter );
         }
         else
-            mpWindow->printPage( nRenderer, pPrinter );
+            mpWindow->printPage( maValidPages.at( nRenderer ), pPrinter );
     }
 }
 
diff --git a/basctl/source/basicide/basicrenderable.hxx b/basctl/source/basicide/basicrenderable.hxx
index 412480609f0c..6f5bd29396bf 100644
--- a/basctl/source/basicide/basicrenderable.hxx
+++ b/basctl/source/basicide/basicrenderable.hxx
@@ -33,10 +33,14 @@ class Renderable :
     public cppu::WeakComponentImplHelper< css::view::XRenderable >,
     public vcl::PrinterOptionsHelper
 {
-    VclPtr<BaseWindow>  mpWindow;
-    osl::Mutex          maMutex;
+    VclPtr<BaseWindow>      mpWindow;
+    osl::Mutex              maMutex;
+    std::vector<sal_Int32>  maValidPages;
 
     VclPtr<Printer> getPrinter();
+    bool isPrintOddPages();
+    bool isPrintEvenPages();
+    static bool isOnEvenPage( sal_Int32 nPage ) { return nPage % 2 == 0; };
 public:
     explicit Renderable (BaseWindow*);
     virtual ~Renderable() override;
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index bb99b2e07f59..e442c17d4ea8 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -120,7 +120,10 @@ private:
         OUString const & aServiceSpecifier,
         css::uno::Sequence<css::uno::Any> const * arguments);
 
-    OUString           maBuildId;
+    static bool             IsOnEvenPage( sal_Int32 nPage ) { return nPage % 2 == 0; };
+
+    OUString                maBuildId;
+    std::vector<sal_Int32>  maValidPages;
 protected:
     const SfxItemPropertySet&   GetPropertySet() const { return aPropSet; }
 
diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 4966fad11343..09150f5f0209 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -108,6 +108,8 @@
 #define SCSTR_PRINTOPT_FROMWHICH                    NC_("SCSTR_PRINTOPT_FROMWHICH", "From which:")
 #define SCSTR_PRINTOPT_PRINTALLPAGES                NC_("SCSTR_PRINTOPT_PRINTALLPAGES", "Print all pages")
 #define SCSTR_PRINTOPT_PRINTPAGES                   NC_("SCSTR_PRINTOPT_PRINTPAGES", "Print pages")
+#define SCSTR_PRINTOPT_PRINTEVENPAGES               NC_("SCSTR_PRINTOPT_PRINTEVENPAGES", "Print even pages")
+#define SCSTR_PRINTOPT_PRINTODDPAGES                NC_("SCSTR_PRINTOPT_PRINTODDPAGES", "Print odd pages")
 #define SCSTR_PRINTOPT_PRODNAME                     NC_("SCSTR_PRINTOPT_PRODNAME", "%PRODUCTNAME %s")
 #define SCSTR_WARN_ME_IN_FUTURE_CHECK               NC_("SCSTR_WARN_ME_IN_FUTURE_CHECK", "Warn me about this in the future.")
 #define SCSTR_DDEDOC_NOT_LOADED                     NC_("SCSTR_DDEDOC_NOT_LOADED", "The following DDE source could not be updated possibly because the source document was not open. Please launch the source document and try again." )
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index e1c4283130c6..b35b08c15ec0 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -298,10 +298,12 @@ ScPrintUIOptions::ScPrintUIOptions()
 
     // create a choice for the range to print
     OUString aPrintRangeName( "PrintRange" );
-    aChoices.realloc( 2 );
+    aChoices.realloc( 4 );
     aHelpIds.realloc( 1 );
     aChoices[0] = ScResId( SCSTR_PRINTOPT_PRINTALLPAGES );
     aChoices[1] = ScResId( SCSTR_PRINTOPT_PRINTPAGES );
+    aChoices[2] = ScResId( SCSTR_PRINTOPT_PRINTEVENPAGES );
+    aChoices[3] = ScResId( SCSTR_PRINTOPT_PRINTODDPAGES );
     aHelpIds[0] = ".HelpID:vcl:PrintDialog:PrintRange:ListBox";
     m_aUIProperties[nIdx++].Value = setChoiceListControlOpt( "printextrabox", OUString(),
                                                     aHelpIds,
@@ -1503,7 +1505,7 @@ bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
 
     bool bHasPrintContent = false;
     sal_Int32 nPrintContent = 0;        // all sheets / selected sheets / selected cells
-    sal_Int32 nPrintRange = 0;          // all pages / pages
+    sal_Int32 nPrintRange = 0;          // all pages / pages / even pages / odd pages
     OUString aPageRange;           // "pages" edit value
 
     for( sal_Int32 i = 0, nLen = rOptions.getLength(); i < nLen; i++ )
@@ -1689,8 +1691,32 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection,
     sal_Int32 nPages = pPrintFuncCache->GetPageCount();
 
     m_pPrintState.reset();
+    maValidPages.clear();
+
+    sal_Int32 nContent = 0;
+    for ( const auto& rValue : rOptions)
+    {
+        if ( rValue.Name == "PrintRange" )
+        {
+            rValue.Value >>= nContent;
+            break;
+        }
+    }
+
+    bool bIsPrintEvenPages = nContent != 3;
+    bool bIsPrintOddPages = nContent != 2;
+
+    for ( sal_Int32 nPage = 1; nPage <= nPages; nPage++ )
+    {
+        if ( (bIsPrintEvenPages && IsOnEvenPage( nPage )) || (bIsPrintOddPages && !IsOnEvenPage( nPage )) )
+            maValidPages.push_back( nPage );
+    }
+
+    sal_Int32 nSelectCount = static_cast<sal_Int32>( maValidPages.size() );
+
+    if ( nContent == 2 || nContent == 3 ) // even pages / odd pages
+        return nSelectCount;
 
-    sal_Int32 nSelectCount = nPages;
     if ( !aPagesStr.isEmpty() )
     {
         StringRangeEnumerator aRangeEnum( aPagesStr, 0, nPages-1 );
@@ -1787,7 +1813,12 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
 
     //  printer is used as device (just for page layout), draw view is not needed
 
-    SCTAB nTab = pPrintFuncCache->GetTabForPage( nRenderer );
+    SCTAB nTab;
+    if ( !maValidPages.empty() )
+        nTab = pPrintFuncCache->GetTabForPage( maValidPages.at( nRenderer )-1 );
+    else
+        nTab = pPrintFuncCache->GetTabForPage( nRenderer );
+
 
     ScRange aRange;
     const ScRange* pSelRange = nullptr;
@@ -1820,10 +1851,27 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
                                              pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions()));
         pPrintFunc->SetRenderFlag( true );
 
-        Range aPageRange( nRenderer+1, nRenderer+1 );
-        MultiSelection aPage( aPageRange );
-        aPage.SetTotalRange( Range(0,RANGE_MAX) );
-        aPage.Select( aPageRange );
+        sal_Int32 nContent = 0;
+        for ( const auto& rValue : rOptions)
+        {
+            if ( rValue.Name == "PrintRange" )
+            {
+                rValue.Value >>= nContent;
+                break;
+            }
+        }
+
+        MultiSelection aPage;
+        if ( nContent == 2 || nContent == 3 ) // even pages or odd pages
+        {
+            aPage.SetTotalRange( Range(0,RANGE_MAX) );
+            aPage.Select( maValidPages.at( nRenderer ) );
+        }
+        else
+        {
+            aPage.SetTotalRange( Range(0,RANGE_MAX) );
+            aPage.Select( nRenderer+1 );
+        }
 
         long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab );
         long nTabStart = pPrintFuncCache->GetTabStart( nTab );
@@ -1944,7 +1992,12 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
         }
     } aDrawViewKeeper;
 
-    SCTAB nTab = pPrintFuncCache->GetTabForPage( nRenderer );
+    SCTAB nTab;
+    if ( !maValidPages.empty() )
+        nTab = pPrintFuncCache->GetTabForPage( maValidPages.at( nRenderer )-1 );
+    else
+        nTab = pPrintFuncCache->GetTabForPage( nRenderer );
+
     ScDrawLayer* pModel = rDoc.GetDrawLayer();
 
     if( pModel )
@@ -1971,10 +2024,27 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
     if( aStatus.GetMode() == SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS )
         pPrintFunc->SetExclusivelyDrawOleAndDrawObjects();
 
-    Range aPageRange( nRenderer+1, nRenderer+1 );
-    MultiSelection aPage( aPageRange );
-    aPage.SetTotalRange( Range(0,RANGE_MAX) );
-    aPage.Select( aPageRange );
+    sal_Int32 nContent = 0;
+    for ( const auto& rValue : rOptions)
+    {
+        if ( rValue.Name == "PrintRange" )
+        {
+            rValue.Value >>= nContent;
+            break;
+        }
+    }
+
+    MultiSelection aPage;
+    if ( nContent == 2 || nContent == 3 ) // even pages or odd pages
+    {
+        aPage.SetTotalRange( Range(0,RANGE_MAX) );
+        aPage.Select( maValidPages.at( nRenderer ) );
+    }
+    else
+    {
+        aPage.SetTotalRange( Range(0,RANGE_MAX) );
+        aPage.Select( nRenderer+1 );
+    }
 
     long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab );
     long nTabStart = pPrintFuncCache->GetTabStart( nTab );
diff --git a/sd/inc/DocumentRenderer.hrc b/sd/inc/DocumentRenderer.hrc
index 59c3601c0b5f..e88459d35acd 100644
--- a/sd/inc/DocumentRenderer.hrc
+++ b/sd/inc/DocumentRenderer.hrc
@@ -81,6 +81,8 @@ const char* STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE[] =
 {
     NC_("STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE", "Print all slides"),
     NC_("STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE", "Print slides"),
+    NC_("STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE", "Print even slides"),
+    NC_("STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE", "Print odd slides"),
     NC_("STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE", "Print selection")
 };
 
@@ -88,6 +90,8 @@ const char* STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE[] =
 {
     NC_("STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE", "Print all pages"),
     NC_("STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE", "Print pages"),
+    NC_("STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE", "Print even pages"),
+    NC_("STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE", "Print odd pages"),
     NC_("STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE", "Print selection")
 };
 
diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx
index 4fbe3f2961cd..8bc87f0830b0 100644
--- a/sd/source/ui/view/DocumentRenderer.cxx
+++ b/sd/source/ui/view/DocumentRenderer.cxx
@@ -179,14 +179,14 @@ namespace {
 
         bool IsPrintFrontPage() const
         {
-            sal_Int32 nInclude = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintProspectInclude", 0 ));
-            return nInclude == 0 || nInclude == 1;
+            sal_Int32 nInclude = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintContent", 0 ));
+            return nInclude != 2;
         }
 
         bool IsPrintBackPage() const
         {
-            sal_Int32 nInclude = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintProspectInclude", 0 ));
-            return nInclude == 0 || nInclude == 2;
+            sal_Int32 nInclude = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintContent", 0 ));
+            return nInclude != 3;
         }
 
         bool IsPaperBin() const
@@ -196,7 +196,7 @@ namespace {
 
         bool IsPrintMarkedOnly() const
         {
-            return GetBoolValue("PrintContent", sal_Int32(2));
+            return GetBoolValue("PrintContent", sal_Int32(4));
         }
 
         OUString GetPrinterSelection (sal_Int32 nPageCount, sal_Int32 nCurrentPageIndex) const
@@ -204,7 +204,7 @@ namespace {
             sal_Int32 nContent = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintContent", 0 ));
             OUString sFullRange = "1-" + OUString::number(nPageCount);
 
-            if (nContent == 0) // all pages/slides
+            if (nContent == 0 || nContent == 2 || nContent == 3 ) // all pages/slides || even pages/slides || odd pages/slides
             {
                 return sFullRange;
             }
@@ -215,7 +215,7 @@ namespace {
                 return sValue.isEmpty() ? sFullRange : sValue;
             }
 
-            if (nContent == 2 && // selection
+            if (nContent == 4 && // selection
                 nCurrentPageIndex >= 0)
             {
                 return OUString::number(nCurrentPageIndex + 1);
@@ -1706,7 +1706,9 @@ private:
                 }
             }
 
-            maPrinterPages.push_back(
+            if ( CheckForFrontBackPages( nIndex ) )
+            {
+                maPrinterPages.push_back(
                 std::shared_ptr<PrinterPage>(
                     new OutlinerPrinterPage(
                         pOutliner->CreateParaObject(),
@@ -1716,6 +1718,7 @@ private:
                         rInfo.mnDrawMode,
                         rInfo.meOrientation,
                         rInfo.mpPrinter->GetPaperBin())));
+            }
         }
 
         pOutliner->SetRefMapMode(aSavedMapMode);
@@ -1820,7 +1823,8 @@ private:
 
             // Create a printer page when we have found one page for each
             // placeholder or when this is the last (and special) loop.
-            if (!aPageIndices.empty() && (aPageIndices.size() == nShapeCount || bLastLoop))
+            if ( !aPageIndices.empty() && CheckForFrontBackPages( nPageIndex )
+                && (aPageIndices.size() == nShapeCount || bLastLoop) )
             {
                 maPrinterPages.push_back(
                     std::shared_ptr<PrinterPage>(
@@ -2043,9 +2047,7 @@ private:
              nIndex < nCount;
              ++nIndex)
         {
-            const bool bIsIndexOdd (nIndex & 1);
-            if ((!bIsIndexOdd && mpOptions->IsPrintFrontPage())
-                || (bIsIndexOdd && mpOptions->IsPrintBackPage()))
+            if ( CheckForFrontBackPages( nIndex ) )
             {
                 const std::pair<sal_uInt16, sal_uInt16> aPair (aPairVector[nIndex]);
                 Point aSecondOffset (aOffset);
@@ -2086,7 +2088,9 @@ private:
         else
             nPaperBin = rInfo.mpPrinter->GetPaperBin();
 
-        maPrinterPages.push_back(
+        if ( CheckForFrontBackPages( nPageIndex ) )
+        {
+            maPrinterPages.push_back(
             std::shared_ptr<PrinterPage>(
                 new TiledPrinterPage(
                     sal::static_int_cast<sal_uInt16>(nPageIndex),
@@ -2097,6 +2101,7 @@ private:
                     rInfo.mnDrawMode,
                     rInfo.meOrientation,
                     nPaperBin)));
+        }
     }
 
     /** Print one standard slide or notes page on one to many printer
@@ -2127,7 +2132,7 @@ private:
         const bool bScalePage (mpOptions->IsPaperSize());
         const bool bCutPage (mpOptions->IsCutPage());
         MapMode aMap (rInfo.maMap);
-        if (bScalePage || bCutPage)
+        if ( (bScalePage || bCutPage) && CheckForFrontBackPages( nPageIndex ) )
         {
             // Handle 1 and 2.
 
@@ -2168,23 +2173,38 @@ private:
                      -aPageOrigin.X()<nPageWidth;
                      aPageOrigin.AdjustX(-rInfo.maPrintSize.Width()))
                 {
-                    aMap.SetOrigin(aPageOrigin);
-                    maPrinterPages.push_back(
-                        std::shared_ptr<PrinterPage>(
-                            new RegularPrinterPage(
-                                sal::static_int_cast<sal_uInt16>(nPageIndex),
-                                ePageKind,
-                                aMap,
-                                rInfo.mbPrintMarkedOnly,
-                                rInfo.msPageString,
-                                aPageOffset,
-                                rInfo.mnDrawMode,
-                                rInfo.meOrientation,
-                                nPaperBin)));
+                    if ( CheckForFrontBackPages( nPageIndex ) )
+                    {
+                        aMap.SetOrigin(aPageOrigin);
+                        maPrinterPages.push_back(
+                            std::shared_ptr<PrinterPage>(
+                                new RegularPrinterPage(
+                                    sal::static_int_cast<sal_uInt16>(nPageIndex),
+                                    ePageKind,
+                                    aMap,
+                                    rInfo.mbPrintMarkedOnly,
+                                    rInfo.msPageString,
+                                    aPageOffset,
+                                    rInfo.mnDrawMode,
+                                    rInfo.meOrientation,
+                                    nPaperBin)));
+                    }
                 }
             }
         }
     }
+
+bool CheckForFrontBackPages( sal_Int32 nPage )
+{
+    const bool bIsIndexOdd(nPage & 1);
+    if ((!bIsIndexOdd && mpOptions->IsPrintFrontPage())
+        || (bIsIndexOdd && mpOptions->IsPrintBackPage()))
+    {
+        return true;
+    }
+    else
+        return false;
+}
 };
 
 //===== DocumentRenderer ======================================================
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 19534cb129e1..a7e10b9a6062 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -185,11 +185,20 @@ const Any& SfxPrinterController::getSelectionObject() const
         return bSel ? maSelection : maCompleteSelection;
     }
 
+    bool bIsCalc = false;
+    pVal = getValue( OUString( "PrintRange" ) );
+    if ( pVal )
+        bIsCalc = true;
+
     sal_Int32 nChoice = 0;
-    pVal = getValue( OUString( "PrintContent"  ) );
+    pVal = getValue( OUString( "PrintContent" ) );
     if( pVal )
         pVal->Value >>= nChoice;
-    return (nChoice > 1) ? maSelection : maCompleteSelection;
+
+    if ( bIsCalc )
+        return (nChoice > 1) ? maSelection : maCompleteSelection;
+    else
+        return (nChoice > 3) ? maSelection : maCompleteSelection;
 }
 
 Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 44466cd64936..f71c35eaa928 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -592,6 +592,8 @@
 #define STR_PRINTOPTUI_RANGE_COPIES             NC_("STR_PRINTOPTUI_RANGE_COPIES", "Range and copies")
 #define STR_PRINTOPTUI_PRINTALLPAGES            NC_("STR_PRINTOPTUI_PRINTALLPAGES", "Print all pages")
 #define STR_PRINTOPTUI_PRINTPAGES               NC_("STR_PRINTOPTUI_PRINTPAGES", "Print pages")
+#define STR_PRINTOPTUI_PRINTEVENPAGES           NC_("STR_PRINTOPTUI_PRINTEVENPAGES", "Print even pages")
+#define STR_PRINTOPTUI_PRINTODDPAGES            NC_("STR_PRINTOPTUI_PRINTODDPAGES", "Print odd pages")
 #define STR_PRINTOPTUI_PRINTSELECTION           NC_("STR_PRINTOPTUI_PRINTSELECTION", "Print selection")
 #define STR_PRINTOPTUI_PLACE_MARGINS            NC_("STR_PRINTOPTUI_PLACE_MARGINS", "Place in margins")
 
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 5fbd8f84271d..4bc227836ea8 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -689,7 +689,7 @@ void SwDoc::CalculatePagesForPrinting(
     sal_Int32 nDocPageCount )
 {
     const sal_Int64 nContent = rOptions.getIntValue( "PrintContent", 0 );
-    const bool bPrintSelection = nContent == 2;
+    const bool bPrintSelection = nContent == 4;
 
     // properties to take into account when calculating the set of pages
     // (PDF export UI does not allow for selecting left or right pages only)
@@ -741,14 +741,16 @@ void SwDoc::CalculatePagesForPrinting(
         // PageContent :
         // 0 -> print all pages (default if aPageRange is empty)
         // 1 -> print range according to PageRange
-        // 2 -> print selection
+        // 2 -> print even pages
+        // 3 -> print odd pages
+        // 4 -> print selection
         if (1 == nContent)
             aPageRange = rOptions.getStringValue( "PageRange" );
-        if (2 == nContent)
+        if (4 == nContent)
         {
             // note that printing selections is actually implemented by copying
             // the selection to a new temporary document and printing all of that one.
-            // Thus for Writer "PrintContent" must never be 2.
+            // Thus for Writer "PrintContent" must never be 4.
             // See SwXTextDocument::GetRenderDoc for evaluating if a selection is to be
             // printed and for creating the temporary document.
         }
@@ -931,7 +933,9 @@ void SwDoc::CalculatePagePairsForProspectPrinting(
     // PageContent :
     // 0 -> print all pages (default if aPageRange is empty)
     // 1 -> print range according to PageRange
-    // 2 -> print selection
+    // 2 -> print even pages
+    // 3 -> print odd pages
+    // 4 -> print selection
     const sal_Int64 nContent = rOptions.getIntValue( "PrintContent", 0 );
     if (nContent == 1)
         aPageRange = rOptions.getStringValue( "PageRange" );
diff --git a/sw/source/core/view/printdata.cxx b/sw/source/core/view/printdata.cxx
index 3f0021cb287f..13144150c2ef 100644
--- a/sw/source/core/view/printdata.cxx
+++ b/sw/source/core/view/printdata.cxx
@@ -173,7 +173,7 @@ SwPrintUIOptions::SwPrintUIOptions(
     // create sequence of print UI options
     // (5 options are not available for Writer-Web)
     const int nRTLOpts = bRTL ? 1 : 0;
-    const int nNumProps = nRTLOpts + (bWeb ? 14 : 20);
+    const int nNumProps = nRTLOpts + (bWeb ? 14 : 18);
     m_aUIProperties.resize( nNumProps );
     int nIdx = 0;
 
@@ -271,17 +271,19 @@ SwPrintUIOptions::SwPrintUIOptions(
 
     // create a choice for the content to create
     const OUString aPrintRangeName( "PrintContent" );
-    uno::Sequence< OUString > aChoices( 2 );
+    uno::Sequence< OUString > aChoices( 4 );
     uno::Sequence< OUString > aHelpIds( 1 );
 
     aHelpIds[0] = ".HelpID:vcl:PrintDialog:PrintContent:ListBox";
 
     aChoices[0] = SwResId( STR_PRINTOPTUI_PRINTALLPAGES );
     aChoices[1] = SwResId( STR_PRINTOPTUI_PRINTPAGES );
+    aChoices[2] = SwResId( STR_PRINTOPTUI_PRINTEVENPAGES );
+    aChoices[3] = SwResId( STR_PRINTOPTUI_PRINTODDPAGES );
     if ( bHasSelection )
     {
-        aChoices.realloc( 3 );
-        aChoices[2] = SwResId( STR_PRINTOPTUI_PRINTSELECTION );
+        aChoices.realloc( 5 );
+        aChoices[4] = SwResId( STR_PRINTOPTUI_PRINTSELECTION );
     }
 
     m_aUIProperties[ nIdx++ ].Value = setChoiceListControlOpt( "printpagesbox",
@@ -325,35 +327,6 @@ SwPrintUIOptions::SwPrintUIOptions(
     vcl::PrinterOptionsHelper::UIControlOptions aPageSetOpt;
     aPageSetOpt.maGroupHint = "LayoutPage";
 
-    if (!bWeb)
-    {
-        m_aUIProperties[nIdx++].Value = setSubgroupControlOpt("pagesides",
-                                                              SwResId( STR_PRINTOPTUI_PAGE_SIDES),
-                                                               OUString(), aPageSetOpt);
-        uno::Sequence< OUString > aRLChoices( 3 );
-        aRLChoices[0] = SwResId( STR_PRINTOPTUI_ALL_PAGES);
-        aRLChoices[1] = SwResId( STR_PRINTOPTUI_BACK_PAGES);
-        aRLChoices[2] = SwResId( STR_PRINTOPTUI_FONT_PAGES);
-        uno::Sequence<OUString> aRLHelp { ".HelpID:vcl:PrintDialog:PrintLeftRightPages:ListBox" };
-        // create a choice option for all/left/right pages
-        // 0 : all pages (left & right)
-        // 1 : left pages
-        // 2 : right pages
-        OSL_ENSURE( rDefaultPrintData.IsPrintLeftPage() || rDefaultPrintData.IsPrintRightPage(),
-                "unexpected value combination" );
-        sal_Int16 nPagesChoice = 0;
-        if (rDefaultPrintData.IsPrintLeftPage() && !rDefaultPrintData.IsPrintRightPage())
-            nPagesChoice = 1;
-        else if (!rDefaultPrintData.IsPrintLeftPage() && rDefaultPrintData.IsPrintRightPage())
-            nPagesChoice = 2;
-        m_aUIProperties[ nIdx++ ].Value = setChoiceListControlOpt("brochureinclude",
-                                                   SwResId( STR_PRINTOPTUI_INCLUDE),
-                                                   aRLHelp,
-                                                   "PrintLeftRightPages",
-                                                   aRLChoices,
-                                                   nPagesChoice);
-    }
-
     // create a bool option for brochure
     bDefaultVal = rDefaultPrintData.IsPrintProspect();
     const OUString aBrochurePropertyName( "PrintProspect" );
@@ -401,9 +374,9 @@ bool SwPrintUIOptions::IsPrintLeftPages() const
     // 0: left and right pages
     // 1: left pages only
     // 2: right pages only
-    sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 /* default: all */ );
-    bool bRes = nLRPages == 0 || nLRPages == 1;
-    bRes = getBoolValue( "PrintLeftPages", bRes /* <- default value if property is not found */ );
+    sal_Int64 nLRPages = getIntValue( "PrintContent", 0 /* default: all */ );
+    bool bRes = nLRPages != 3;
+    bRes = getBoolValue( "PrintContent", bRes /* <- default value if property is not found */ );
     return bRes;
 }
 
@@ -412,9 +385,9 @@ bool SwPrintUIOptions::IsPrintRightPages() const
     // take care of different property names for the option.
     // for compatibility the old name should win (may still be used for PDF export or via Uno API)
 
-    sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 /* default: all */ );
-    bool bRes = nLRPages == 0 || nLRPages == 2;
-    bRes = getBoolValue( "PrintRightPages", bRes /* <- default value if property is not found */ );
+    sal_Int64 nLRPages = getIntValue( "PrintContent", 0 /* default: all */ );
+    bool bRes = nLRPages != 2;
+    bRes = getBoolValue( "PrintContent", bRes /* <- default value if property is not found */ );
     return bRes;
 }
 


More information about the Libreoffice-commits mailing list