desktop/source/app/app.cxx               |    1 +
 desktop/source/app/cmdlineargs.cxx       |    4 +++-
 desktop/source/app/cmdlineargs.hxx       |    2 ++
 desktop/source/app/cmdlinehelp.cxx       |    3 ++-
 desktop/source/app/dispatchwatcher.cxx   |    4 +++-
 desktop/source/app/officeipcthread.cxx   |    1 +
 desktop/source/app/officeipcthread.hxx   |    1 +
 include/sfx2/sfxsids.hrc                 |    2 +-
 sd/inc/drawdoc.hxx                       |    8 ++++----
 sd/sdi/sdraw.sdi                         |    2 +-
 sd/source/core/drawdoc.cxx               |    6 +++---
 sd/source/ui/docshell/docshel4.cxx       |    8 ++++----
 sd/source/ui/slideshow/slideshowimpl.cxx |    7 ++++---
 sd/source/ui/view/ViewShellBase.cxx      |   13 +++++++++----
 sd/source/ui/view/drviewse.cxx           |    7 ++++++-
 sfx2/source/appl/appuno.cxx              |    8 ++++----
 sfx2/source/doc/objstor.cxx              |    2 +-
 17 files changed, 50 insertions(+), 29 deletions(-)

New commits:
commit 0e61cdd3e306be3ddb8935728abb5c04eaa8431b
Author:     Justin Luth <[email protected]>
AuthorDate: Fri May 3 08:32:27 2024 -0400
Commit:     Nagy Tibor <[email protected]>
CommitDate: Wed Sep 11 15:58:41 2024 +0200

    tdf#69192: add StartingSlide to SID_PRESENTATION and cmdline show=
    
    Allow the user to start the presentation at a specific slide
    using command-line parameters.
    
    This patch depends on the previous variable renaming patch.
    
    Change-Id: I87797cbccb463904e5d2fe9b078e3921be27c91a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167066
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 90eb9ea881a7497bb2ec348b3e4cba5aa5d51fa8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173166
    Tested-by: allotropia jenkins <[email protected]>
    Reviewed-by: Nagy Tibor <[email protected]>

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 0d66a48daac7..7c81b0a3bbc1 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2081,6 +2081,7 @@ void Desktop::OpenClients()
     aRequest.aConversionParams = rArgs.GetConversionParams();
     aRequest.aConversionOut = rArgs.GetConversionOut();
     aRequest.aImageConversionType = rArgs.GetImageConversionType();
+    aRequest.aStartListParams = rArgs.GetStartListParams();
     aRequest.aInFilter = rArgs.GetInFilter();
     aRequest.bTextCat = rArgs.IsTextCat();
     aRequest.bScriptCat = rArgs.IsScriptCat();
diff --git a/desktop/source/app/cmdlineargs.cxx 
b/desktop/source/app/cmdlineargs.cxx
index e7f315204048..3a3f876f6e90 100644
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -538,10 +538,12 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& 
supplier )
                 // open in viewmode
                 eCurrentEvent = CommandLineEvent::View;
             }
-            else if ( oArg == "show" )
+            else if (oArg == "show" || oArg.startsWith("show=", &rest))
             {
                 // open in viewmode
                 eCurrentEvent = CommandLineEvent::Start;
+                // start on the first slide unless a valid starting slide # 
was provided
+                m_startListParams = rest.toUInt32() > 0 ? rest : "1";
             }
             else if ( oArg == "display" )
             {
diff --git a/desktop/source/app/cmdlineargs.hxx 
b/desktop/source/app/cmdlineargs.hxx
index 64a1bcfd0ccb..8e0c6e649584 100644
--- a/desktop/source/app/cmdlineargs.hxx
+++ b/desktop/source/app/cmdlineargs.hxx
@@ -113,6 +113,7 @@ class CommandLineArgs
         const OUString&         GetConversionParams() const { return 
m_conversionparams;}
         OUString                GetConversionOut() const;
         OUString const &        GetImageConversionType() const { return 
m_convertimages; }
+        const OUString&         GetStartListParams() const { return 
m_startListParams; }
         const OUString&         GetPidfileName() const { return m_pidfile;}
 
         // Special analyzed states (does not match directly to a command line 
parameter!)
@@ -176,6 +177,7 @@ class CommandLineArgs
         OUString m_conversionparams;
         OUString m_conversionout; // contains external URIs
         OUString m_convertimages; // The format in which images should be 
converted
+        OUString m_startListParams;
         std::vector< OUString > m_infilter;
         OUString m_language;
         OUString m_pidfile;
diff --git a/desktop/source/app/cmdlinehelp.cxx 
b/desktop/source/app/cmdlinehelp.cxx
index 9c9fd940f233..10b3e5c48cbb 100644
--- a/desktop/source/app/cmdlinehelp.cxx
+++ b/desktop/source/app/cmdlinehelp.cxx
@@ -145,8 +145,9 @@ namespace desktop
         "                       not appear. If the file name contains spaces, 
then it   
"
         "                       must be enclosed in quotation marks.           
         
"
         "   --view              Opens following files in viewer mode 
(read-only).       
"
-        "   --show              Opens and starts the following presentation 
documents   
"
+        "   --show{=slide#}     Opens and starts the following presentation 
documents   
"
         "                       of each immediately. Files are closed after 
the showing.
"
+        "                       If a slide # is provided, they start at that 
slide.     
"
         "                       Files other than Impress documents are opened 
in        
"
         "                       default mode , regardless of previous mode.    
         
"
         "   --convert-to OutputFileExtension[:OutputFilterName] \              
        
"
diff --git a/desktop/source/app/dispatchwatcher.cxx 
b/desktop/source/app/dispatchwatcher.cxx
index 41184ca37b82..cd953245f38f 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -503,7 +503,9 @@ bool DispatchWatcher::executeDispatchRequests( const 
std::vector<DispatchRequest
 
             // if we are called with --show set Start in mediadescriptor
             if(aDispatchRequest.aRequestType == REQUEST_START) {
-                aArgs.emplace_back("StartPresentation", 0, Any(true), 
PropertyState_DIRECT_VALUE);
+                const sal_Int32 nStartingSlide = 
aDispatchRequest.aParam.toInt32();
+                const sal_uInt16 nSlide = nStartingSlide > 0 ? nStartingSlide 
: 1;
+                aArgs.emplace_back("StartPresentation", 0, Any(nSlide), 
PropertyState_DIRECT_VALUE);
             }
 
             // Force input filter, if possible
diff --git a/desktop/source/app/officeipcthread.cxx 
b/desktop/source/app/officeipcthread.cxx
index 9d342bf35a84..79dd765b24b7 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -985,6 +985,7 @@ bool IpcThread::process(OString const & arguments, bool * 
waitProcessed) {
         pRequest->aConversionParams = aCmdLineArgs->GetConversionParams();
         pRequest->aConversionOut = aCmdLineArgs->GetConversionOut();
         pRequest->aImageConversionType = 
aCmdLineArgs->GetImageConversionType();
+        pRequest->aStartListParams = aCmdLineArgs->GetStartListParams();
         pRequest->aInFilter = aCmdLineArgs->GetInFilter();
         pRequest->bTextCat = aCmdLineArgs->IsTextCat();
         pRequest->bScriptCat = aCmdLineArgs->IsScriptCat();
diff --git a/desktop/source/app/officeipcthread.hxx 
b/desktop/source/app/officeipcthread.hxx
index a233c18e012b..fc95b42668bc 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -60,6 +60,7 @@ struct ProcessDocumentsRequest
     OUString aConversionParams;
     OUString aConversionOut;
     OUString aImageConversionType;
+    OUString aStartListParams;
     std::vector< OUString > aInFilter;
     ::osl::Condition *pcProcessed;  // pointer condition to be set when the 
request has been processed
     bool* mpbSuccess = nullptr; // pointer to boolean receiving if the 
processing was successful
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index c5479d836855..4aa9424e13bb 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -344,7 +344,7 @@ class SvxZoomItem;
 #define SID_MODIFIER                        
TypedWhichId<SfxUInt16Item>(SID_SFX_START + 669)
 #define SID_SETOPTIONS                      (SID_SFX_START + 670)
 #define SID_SOURCEVIEW                      (SID_SFX_START + 675)
-#define SID_DOC_STARTPRESENTATION           
TypedWhichId<SfxBoolItem>(SID_SFX_START + 695)
+#define SID_DOC_STARTPRESENTATION           
TypedWhichId<SfxUInt16Item>(SID_SFX_START + 695)
 #define SID_DDE_RECONNECT_ONLOAD            
TypedWhichId<SfxBoolItem>(SID_SFX_START + 696)
 
 #define SID_DOCTEMPLATE                     (SID_SFX_START + 538)
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index 401bde6b5f88..b48d0dcf2cf1 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -154,8 +154,8 @@ private:
 
     bool                mbOnlineSpell;
     bool                mbSummationOfParagraphs;
-    bool                mbStartWithPresentation;        ///< is set to true 
when starting with command line parameter -start
-    bool                mbExitAfterPresenting;         ///< true if 
mbStartWithPresentation AND Presentation was shown fully
+    sal_uInt16          mnStartWithPresentation; ///< 1-based starting slide# 
when presenting via command line parameter --show
+    bool                mbExitAfterPresenting; ///< true if 
GetStartWithPresentation AND Presentation was shown fully
     LanguageType        meLanguage;
     LanguageType        meLanguageCJK;
     LanguageType        meLanguageCTL;
@@ -284,8 +284,8 @@ public:
                             ::sd::DrawDocShell* pBookmarkDocSh,
                             Point const * pObjPos);
 
-    SAL_DLLPRIVATE bool IsStartWithPresentation() const { return 
mbStartWithPresentation;}
-    SAL_DLLPRIVATE void SetStartWithPresentation( bool bStartWithPresentation 
);
+    SAL_DLLPRIVATE sal_uInt16 GetStartWithPresentation() const { return 
mnStartWithPresentation; }
+    SAL_DLLPRIVATE void SetStartWithPresentation(sal_uInt16 nStartingSlide);
 
     SAL_DLLPRIVATE bool IsExitAfterPresenting() const { return 
mbExitAfterPresenting;}
     SAL_DLLPRIVATE void SetExitAfterPresenting( bool bExitAfterPresenting );
diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
index 1077dc0c0b77..da7ee37f4b33 100644
--- a/sd/sdi/sdraw.sdi
+++ b/sd/sdi/sdraw.sdi
@@ -3176,7 +3176,7 @@ SfxBoolItem PickThrough SID_PICK_THROUGH
 ]
 
 SfxVoidItem Presentation SID_PRESENTATION
-()
+(SfxUInt16Item StartingSlide FN_PARAM_1)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index 54a828c81094..2e10cf488834 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -127,7 +127,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, 
SfxObjectShell* pDrDocSh)
 , mbInitialOnlineSpellingEnabled(true)
 , mbNewOrLoadCompleted(false)
 , mbOnlineSpell(false)
-, mbStartWithPresentation( false )
+, mnStartWithPresentation(0)
 , mbExitAfterPresenting( false )
 , meLanguage( LANGUAGE_SYSTEM )
 , meLanguageCJK( LANGUAGE_SYSTEM )
@@ -1066,9 +1066,9 @@ void SdDrawDocument::SetPrinterIndependentLayout 
(sal_Int32 nMode)
     }
 }
 
-void SdDrawDocument::SetStartWithPresentation( bool bStartWithPresentation )
+void SdDrawDocument::SetStartWithPresentation(sal_uInt16 nStartingSlide)
 {
-    mbStartWithPresentation = bStartWithPresentation;
+    mnStartWithPresentation = nStartingSlide;
 }
 
 void SdDrawDocument::SetExitAfterPresenting( bool bExitAfterPresenting )
diff --git a/sd/source/ui/docshell/docshel4.cxx 
b/sd/source/ui/docshell/docshel4.cxx
index 63722ba11c68..fbc0615b5ea3 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -433,7 +433,7 @@ bool DrawDocShell::ImportFrom(SfxMedium &rMedium,
     const bool bRet = SfxObjectShell::ImportFrom(rMedium, xInsertPosition);
 
     SfxItemSet& rSet = rMedium.GetItemSet();
-    if( SfxItemState::SET == rSet.GetItemState(SID_DOC_STARTPRESENTATION) )
+    if (SfxItemState::SET == rSet.GetItemState(SID_DOC_STARTPRESENTATION))
     {
         sal_uInt16 nStartingSlide = 
rSet.Get(SID_DOC_STARTPRESENTATION).GetValue();
         if (nStartingSlide == 0)
@@ -451,9 +451,9 @@ bool DrawDocShell::ImportFrom(SfxMedium &rMedium,
         mpDoc->SetStartWithPresentation(nStartingSlide);
 
         // tell SFX to change viewshell when in preview mode
-        if( IsPreview() )
+        if (IsPreview())
         {
-            GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, 1 ) );
+            GetMedium()->GetItemSet().Put(SfxUInt16Item(SID_VIEW_ID, 1));
         }
     }
 
@@ -477,7 +477,7 @@ bool DrawDocShell::ConvertFrom( SfxMedium& rMedium )
         mpDoc->SetStarDrawPreviewMode( true );
     }
 
-    if( SfxItemState::SET == rSet.GetItemState(SID_DOC_STARTPRESENTATION) )
+    if (SfxItemState::SET == rSet.GetItemState(SID_DOC_STARTPRESENTATION))
     {
         sal_uInt16 nStartingSlide = 
rSet.Get(SID_DOC_STARTPRESENTATION).GetValue();
         if (nStartingSlide == 0)
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx 
b/sd/source/ui/slideshow/slideshowimpl.cxx
index 5c3ad1f9f2d5..9cc3b30da159 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -1047,7 +1047,8 @@ bool SlideshowImpl::startShow( PresentationSettingsEx 
const * pPresSettings )
         return false;
 
     // Autoplay (pps/ppsx)
-    if (mpViewShell->GetDoc()->IsStartWithPresentation()){
+    if (mpViewShell->GetDoc()->GetStartWithPresentation())
+    {
         mpViewShell->GetDoc()->SetExitAfterPresenting(true);
     }
 
@@ -2245,7 +2246,7 @@ IMPL_LINK_NOARG(SlideshowImpl, ContextMenuHdl, void*, 
void)
     const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
     xMenu->set_visible("next", mpSlideController->getNextSlideIndex() != -1);
     xMenu->set_visible("prev", (mpSlideController->getPreviousSlideIndex() != 
-1 ) || (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || 
(eMode == SHOWWINDOWMODE_BLANK));
-    xMenu->set_visible("edit", 
mpViewShell->GetDoc()->IsStartWithPresentation());
+    xMenu->set_visible("edit", 
mpViewShell->GetDoc()->GetStartWithPresentation() != 0);
 
     std::unique_ptr<weld::Menu> xPageMenu(xBuilder->weld_menu("gotomenu"));
     OUString sFirstImage(BMP_MENU_FIRST), sLastImage(BMP_MENU_LAST);
@@ -3115,7 +3116,7 @@ void SAL_CALL SlideshowImpl::gotoNextSlide(  )
                     if( mpShowWindow )
                     {
                         mpShowWindow->SetEndMode();
-                        if( !mpViewShell->GetDoc()->IsStartWithPresentation() )
+                        if (!mpViewShell->GetDoc()->GetStartWithPresentation())
                             pause();
                     }
                 }
diff --git a/sd/source/ui/view/ViewShellBase.cxx 
b/sd/source/ui/view/ViewShellBase.cxx
index fff32c685a8a..04522c19ceed 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -62,6 +62,7 @@
 #include <sfx2/msg.hxx>
 #include <sfx2/objface.hxx>
 #include <sfx2/viewfrm.hxx>
+#include <svl/intitem.hxx>
 #include <svl/whiter.hxx>
 #include <vcl/commandinfoprovider.hxx>
 #include <vcl/settings.hxx>
@@ -410,13 +411,17 @@ void ViewShellBase::Notify(SfxBroadcaster& rBC, const 
SfxHint& rHint)
         switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
         {
             case SfxEventHintId::OpenDoc:
-                if( GetDocument() && GetDocument()->IsStartWithPresentation() )
+            {
+                const sal_uInt16 nStartingSlide
+                    = GetDocument() ? 
GetDocument()->GetStartWithPresentation() : 0;
+                if (nStartingSlide)
                 {
-                    GetViewFrame().GetDispatcher()->Execute(
-                        SID_PRESENTATION, SfxCallMode::ASYNCHRON );
+                    SfxUInt16Item aItem(FN_PARAM_1, nStartingSlide);
+                    GetViewFrame().GetDispatcher()->ExecuteList(
+                        SID_PRESENTATION, SfxCallMode::ASYNCHRON, { &aItem });
                 }
                 break;
-
+            }
             default:
                 break;
         }
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 138830bf74bf..bd8e76f4d0a0 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -1700,8 +1700,13 @@ namespace slideshowhelp
         {
             //Start at page 0, this would blow away any custom
             //show settings if any were set
+            const SfxUInt16Item* pStartingSlide = 
rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
+            const sal_uInt16 nStartingSlide = pStartingSlide ? 
pStartingSlide->GetValue() - 1 : 0;
+            SdPage* pSlide = rDoc.GetSdPage(nStartingSlide, 
PageKind::Standard);
+            const OUString& rStartingSlide = pSlide ? pSlide->GetName() : 
OUString();
+
             Sequence< PropertyValue > aArguments{ 
comphelper::makePropertyValue("FirstPage",
-                                                                               
 OUString("0")) };
+                                                                               
 rStartingSlide) };
             xPresentation->startWithArguments( aArguments );
         }
         sfx2::SfxNotebookBar::UnlockNotebookBar();
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index 386cce711c7c..2985fe8ab98c 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -545,11 +545,11 @@ void TransformParameters( sal_uInt16 nSlotId, const 
uno::Sequence<beans::Propert
             }
             else if ( aName == sStartPresentation )
             {
-                bool bVal = false;
-                bool bOK = (rProp.Value >>= bVal);
+                sal_uInt16 nVal = 0;
+                bool bOK = (rProp.Value >>= nVal);
                 DBG_ASSERT( bOK, "invalid type for StartPresentation" );
                 if (bOK)
-                    rSet.Put( SfxBoolItem( SID_DOC_STARTPRESENTATION, bVal ) );
+                    rSet.Put(SfxUInt16Item(SID_DOC_STARTPRESENTATION, nVal));
             }
             else if ( aName == sSelectionOnly )
             {
@@ -1491,7 +1491,7 @@ void TransformItems( sal_uInt16 nSlotId, const 
SfxItemSet& rSet, uno::Sequence<b
             pValue[nActProp].Name = sDdeReconnect;
             pValue[nActProp++].Value <<= pItem->GetValue();
         }
-        if ( const SfxBoolItem *pItem = rSet.GetItemIfSet( 
SID_DOC_STARTPRESENTATION, false) )
+        if (const SfxUInt16Item* pItem = 
rSet.GetItemIfSet(SID_DOC_STARTPRESENTATION, false))
         {
             pValue[nActProp].Name = sStartPresentation;
             pValue[nActProp++].Value <<= pItem->GetValue();
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 4cf78b262903..ef3a3a324881 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -652,7 +652,7 @@ bool SfxObjectShell::DoLoad( SfxMedium *pMed )
             SetError(nError);
 
         if (pMedium->GetFilter()->GetFilterFlags() & 
SfxFilterFlags::STARTPRESENTATION)
-            rSet.Put( SfxBoolItem( SID_DOC_STARTPRESENTATION, true) );
+            rSet.Put(SfxUInt16Item(SID_DOC_STARTPRESENTATION, 1));
     }
 
     EnableSetModified( false );

Reply via email to