Kaydet (Commit) 7722a590 authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky Kaydeden (comit) Caolán McNamara

fdo#68099 Move pdf viewer call to GUI related code

This change fixes two bugs:
1) In it's old location at PDFFilter::implExport, the pdf viewer is called
*before* the final file is actually written. It causes a problem under
Windows, because we use ShellExecute function which fails if the file
doesn't exist. Calling a function blocks execution, so we have no chance
to write the file before that function fails. (fdo#68099)
2) Being a part of the saving/filter code means that the pdf viewer will
open even when converting to a pdf in headless mode. It's definitely not
something that we want to happen.

Change-Id: I1a6f70ec76100ac9e008869aa57ad738ced3ab6c
Reviewed-on: https://gerrit.libreoffice.org/6565Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 9841ae65
...@@ -24,10 +24,7 @@ ...@@ -24,10 +24,7 @@
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <svl/outstrm.hxx> #include <svl/outstrm.hxx>
#include <vcl/FilterConfigItem.hxx> #include <vcl/FilterConfigItem.hxx>
#include <com/sun/star/system/SystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
using namespace css::system;
// ------------- // -------------
// - PDFFilter - // - PDFFilter -
// ------------- // -------------
...@@ -54,10 +51,6 @@ sal_Bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) ...@@ -54,10 +51,6 @@ sal_Bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
sal_Bool bRet = sal_False; sal_Bool bRet = sal_False;
Reference< task::XStatusIndicator > xStatusIndicator; Reference< task::XStatusIndicator > xStatusIndicator;
Reference< task::XInteractionHandler > xIH; Reference< task::XInteractionHandler > xIH;
OUString aUrl;
FilterConfigItem aItem( "Office.Common/Filter/PDF/Export/" );
sal_Bool aViewPDF = aItem.ReadBool( "ViewPDFAfterExport", sal_False );
for ( sal_Int32 i = 0 ; ( i < nLength ) && !xOStm.is(); ++i) for ( sal_Int32 i = 0 ; ( i < nLength ) && !xOStm.is(); ++i)
{ {
...@@ -69,8 +62,6 @@ sal_Bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) ...@@ -69,8 +62,6 @@ sal_Bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
pValue[ i ].Value >>= xStatusIndicator; pValue[ i ].Value >>= xStatusIndicator;
else if ( pValue[i].Name == "InteractionHandler" ) else if ( pValue[i].Name == "InteractionHandler" )
pValue[i].Value >>= xIH; pValue[i].Value >>= xIH;
else if ( pValue[ i ].Name == "URL" )
pValue[ i ].Value >>= aUrl;
} }
/* we don't get FilterData if we are exporting directly /* we don't get FilterData if we are exporting directly
...@@ -142,10 +133,6 @@ sal_Bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) ...@@ -142,10 +133,6 @@ sal_Bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
} }
} }
if(aViewPDF==sal_True) {
Reference<XSystemShellExecute> xSystemShellExecute(SystemShellExecute::create( ::comphelper::getProcessComponentContext() ) ); //Open the newly exported pdf
xSystemShellExecute->execute(aUrl, "", SystemShellExecuteFlags::URIS_ONLY ); }
return bRet; return bRet;
} }
......
...@@ -93,6 +93,10 @@ ...@@ -93,6 +93,10 @@
#include <officecfg/Office/Common.hxx> #include <officecfg/Office/Common.hxx>
#include <vcl/FilterConfigItem.hxx>
#include <com/sun/star/system/SystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
// flags that specify requested operation // flags that specify requested operation
#define EXPORT_REQUESTED 1 #define EXPORT_REQUESTED 1
#define PDFEXPORT_REQUESTED 2 #define PDFEXPORT_REQUESTED 2
...@@ -114,6 +118,7 @@ const char aFilterDataString[] = "FilterData"; ...@@ -114,6 +118,7 @@ const char aFilterDataString[] = "FilterData";
const char aFilterFlagsString[] = "FilterFlags"; const char aFilterFlagsString[] = "FilterFlags";
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace css::system;
namespace { namespace {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
...@@ -1705,6 +1710,17 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel ...@@ -1705,6 +1710,17 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel
aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), aArgsSequence ); aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), aArgsSequence );
} }
// Launch PDF viewer
if ( nStoreMode & PDFEXPORT_REQUESTED ) {
FilterConfigItem aItem( "Office.Common/Filter/PDF/Export/" );
sal_Bool aViewPDF = aItem.ReadBool( "ViewPDFAfterExport", sal_False );
if ( aViewPDF==sal_True ) {
uno::Reference<XSystemShellExecute> xSystemShellExecute(SystemShellExecute::create( ::comphelper::getProcessComponentContext() ) );
xSystemShellExecute->execute( aURL.GetMainURL( INetURLObject::NO_DECODE ), "", SystemShellExecuteFlags::URIS_ONLY );
}
}
return bDialogUsed; return bDialogUsed;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment