e0f5613
From 74879ff0ef14db47365650819bbe7c9f105b057a Mon Sep 17 00:00:00 2001
e0f5613
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
e0f5613
Date: Wed, 8 Jul 2015 12:24:46 +0100
e0f5613
Subject: [PATCH] when skipping hidden pages omit the hidden pages from page
e0f5613
 bookmarks
e0f5613
e0f5613
three slides, set second to hidden, export to pdf (without toggling
e0f5613
on include hidden slides), in evince/acroread click on the "slide 3"
e0f5613
title, and the viewers will not jump to that slide, seeing as the
e0f5613
index is mis-calculated assuming 1-1 export-import pages
e0f5613
e0f5613
Change-Id: I2f21eb655684ac4cb06384a8e9a17b419f644f3f
e0f5613
---
e0f5613
 sd/source/ui/unoidl/unomodel.cxx | 26 ++++++++++++++++++++++++--
e0f5613
 1 file changed, 24 insertions(+), 2 deletions(-)
e0f5613
e0f5613
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
e0f5613
index 2d72378..472edac 100644
e0f5613
--- a/sd/source/ui/unoidl/unomodel.cxx
e0f5613
+++ b/sd/source/ui/unoidl/unomodel.cxx
e0f5613
@@ -1851,6 +1851,25 @@ bool ImplRenderPaintProc::IsPrintable( const SdrObject* pObj ) const
e0f5613
     return bPrintable;
e0f5613
 
e0f5613
 }
e0f5613
+
e0f5613
+namespace
e0f5613
+{
e0f5613
+    sal_Int16 CalcOutputPageNum(vcl::PDFExtOutDevData* pPDFExtOutDevData, SdDrawDocument *pDoc, sal_Int16 nPageNumber)
e0f5613
+    {
e0f5613
+        //export all pages, simple one to one case
e0f5613
+        if (pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportHiddenSlides())
e0f5613
+            return nPageNumber-1;
e0f5613
+        //check all preceding pages, and only count non-hidden ones
e0f5613
+        sal_Int16 nRet = 0;
e0f5613
+        for (sal_Int16 i = 0; i < nPageNumber-1; ++i)
e0f5613
+        {
e0f5613
+           if (!(pDoc->GetSdPage(i, PK_STANDARD))->IsExcluded())
e0f5613
+                ++nRet;
e0f5613
+        }
e0f5613
+        return nRet;
e0f5613
+    }
e0f5613
+}
e0f5613
+
e0f5613
 void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection,
e0f5613
                                           const uno::Sequence< beans::PropertyValue >& rxOptions )
e0f5613
     throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
e0f5613
@@ -2135,9 +2154,12 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
e0f5613
                                 OUString aPageName = mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1 , PK_STANDARD )->GetName();
e0f5613
                                 if( !aPageName.isEmpty() )
e0f5613
                                 {
e0f5613
+                                    // Destination PageNum
e0f5613
+                                    const sal_Int32 nDestPageNum = CalcOutputPageNum(pPDFExtOutDevData, mpDoc, nPageNumber);
e0f5613
+
e0f5613
                                     // insert the bookmark to this page into the NamedDestinations
e0f5613
                                     if( pPDFExtOutDevData->GetIsExportNamedDestinations() )
e0f5613
-                                        pPDFExtOutDevData->CreateNamedDest( aPageName, aPageRect,  nPageNumber - 1 );
e0f5613
+                                        pPDFExtOutDevData->CreateNamedDest(aPageName, aPageRect, nDestPageNum);
e0f5613
 
e0f5613
                                     // add the name to the outline, (almost) same code as in sc/source/ui/unoobj/docuno.cxx
e0f5613
                                     // issue #i40318.
e0f5613
@@ -2146,7 +2168,7 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
e0f5613
                                     {
e0f5613
                                         // Destination Export
e0f5613
                                         const sal_Int32 nDestId =
e0f5613
-                                            pPDFExtOutDevData->CreateDest( aPageRect , nPageNumber - 1 );
e0f5613
+                                            pPDFExtOutDevData->CreateDest(aPageRect , nDestPageNum);
e0f5613
 
e0f5613
                                         // Create a new outline item:
e0f5613
                                         pPDFExtOutDevData->CreateOutlineItem( -1 , aPageName, nDestId );
e0f5613
-- 
e0f5613
2.4.0
e0f5613