[LyX/master] Address #9368

Juergen Spitzmueller spitz at lyx.org
Thu Apr 9 07:48:42 UTC 2020


commit 9cccbb36157d97d2c8f13fcc3c22b090bcb35e44
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Thu Apr 9 10:08:44 2020 +0200

    Address #9368
    
    pdfview creates a temp pdf file to determine the standard pdf viewer,
    code simplification, reducing dll dependencies
    
    Patch by Eugene.
---
 development/Win32/packaging/installer/Readme.txt   |    3 +-
 .../Win32/packaging/installer/include/filelist.nsh |    2 -
 development/Win32/pdfview/pdfview.nsi              |   58 +++++---------------
 3 files changed, 16 insertions(+), 47 deletions(-)

diff --git a/development/Win32/packaging/installer/Readme.txt b/development/Win32/packaging/installer/Readme.txt
index 7f1d331..3d8fe1d 100644
--- a/development/Win32/packaging/installer/Readme.txt
+++ b/development/Win32/packaging/installer/Readme.txt
@@ -96,7 +96,6 @@ Updating dependencies
 
 - pdfview.exe
   this is a NSIS script, which calls users standard pdf viewer to display pdf files you compile with
-  LaTeX using LyX, its source is available in %%lyxgit%%\development\Win32\pdfview,
-  it uses System.dll and Console.dll
+  LaTeX using LyX, its source is available in %%lyxgit%%\development\Win32\pdfview
 
 Note: if you update any dependencies, please add a note to ChangeLog.txt
\ No newline at end of file
diff --git a/development/Win32/packaging/installer/include/filelist.nsh b/development/Win32/packaging/installer/include/filelist.nsh
index b1d3df7..1efdb4d 100644
--- a/development/Win32/packaging/installer/include/filelist.nsh
+++ b/development/Win32/packaging/installer/include/filelist.nsh
@@ -129,8 +129,6 @@ Lists of files to include in the installer
 !macro FileListPDFViewBin COMMAND DIRECTORY
 
   ${FILE}pdfview.exe"
-  ${FILE}System.dll"
-  ${FILE}Console.dll"
 
 !macroend
 
diff --git a/development/Win32/pdfview/pdfview.nsi b/development/Win32/pdfview/pdfview.nsi
index b8c5b1a..5e49a1e 100644
--- a/development/Win32/pdfview/pdfview.nsi
+++ b/development/Win32/pdfview/pdfview.nsi
@@ -10,9 +10,7 @@ but works around the file locking problems of Adobe Reader and Acrobat.
 
 */
 
-# FIXME
-#Unicode true
-#doesn't work with the Uniode system.dll of NSIS 3.0.2 
+Unicode true
 
 !include LogicLib.nsh
 !include FileFunc.nsh
@@ -34,11 +32,9 @@ RequestExecutionLevel user
 # Variables
 
 Var Character
-Var RunAppReturn
 
 Var OriginalFile
 Var OriginalFileName
-Var OriginalDir
 
 Var PDFFile
 Var ViewerFileName
@@ -47,32 +43,6 @@ Var ViewerHandle
 Var ViewerVersion
 
 #--------------------------------
-# Macros
-
-!macro SystemCall STACK
-
-  # Call a Windows API function
-
-  Push `${STACK}`
-  CallInstDLL "$EXEDIR\System.dll" Call
-
-!macroend
-
-!macro HideConsole COMMAND_LINE
-
-  # Run an application and hide console output
-
-  Push `${COMMAND_LINE}`
-  CallInstDLL "$EXEDIR\Console.dll" Exec
-  Pop $RunAppReturn
-  
-  ${If} $RunAppReturn == "error"
-    MessageBox MB_OK|MB_ICONSTOP "Error opening PDF file $PDFFile."
-  ${EndIf}
-
-!macroend
-
-#--------------------------------
 # PDF viewing
 
 Section "View PDF file"
@@ -80,30 +50,32 @@ Section "View PDF file"
   InitPluginsDir # Temporary directory for PDF file
 
   # Command line parameters
-  ${GetParameters} $OriginalFile
+  ${GetParameters} $OriginalFileName
 
   # Trim quotes
-  StrCpy $Character $OriginalFile 1
+  StrCpy $Character $OriginalFileName 1
   ${If} $Character == '"'
-    StrCpy $OriginalFile $OriginalFile "" 1
+    StrCpy $OriginalFileName $OriginalFileName "" 1
   ${EndIf}
-  StrCpy $Character $OriginalFile 1 -1
+  StrCpy $Character $OriginalFileName 1 -1
   ${If} $Character == '"'
-    StrCpy $OriginalFile $OriginalFile -1
+    StrCpy $OriginalFileName $OriginalFileName -1
   ${EndIf}
 
-  GetFullPathName $OriginalFile $OriginalFile
-  ${GetFileName} $OriginalFile $OriginalFileName
-  ${GetParent} $OriginalFile $OriginalDir # tmpbuf
-  ${GetParent} $OriginalDir $OriginalDir # tmpdir
+  GetFullPathName $OriginalFile $OriginalFileName
 
   SetOutPath $TEMP # The LyX tmpbuf should not be locked
 
   StrCpy $PDFFile $PLUGINSDIR\$OriginalFileName
 
   # Check whether the file will be opened with Adobe Reader or Adobe Acrobat
-  !insertmacro SystemCall "shell32::FindExecutable(t '$OriginalFile', t '', t .s)"
-  Pop $ViewerFileName
+ 
+  FileOpen $R0 "$PLUGINSDIR\a.pdf" "w" #create a temp pdf file with a simple name
+  FileClose $R0
+  
+  #find stadard executable for "a.pdf", writes result in $0 (".r0" below)
+  System::Call "shell32::FindExecutable(t '$PLUGINSDIR\a.pdf', t '', t .r0)"
+  StrCpy $ViewerFileName $0
   ${GetFileName} $ViewerFileName $Viewer
 
   ${If} $Viewer == ""
@@ -148,7 +120,7 @@ Section "View PDF file"
     CopyFiles /SILENT $OriginalFile $PDFFile
     
     # Open a new view
-    !insertmacro HideConsole '"$ViewerFileName" "$PDFFile"'
+    ExecWait '"$ViewerFileName" "$PDFFile"'
     
   ${Else}
   


More information about the lyx-cvs mailing list