summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-07-20 23:09:59 +0200
committerCaolán McNamara <caolanm@redhat.com>2021-07-25 15:54:14 +0200
commit55f0121dd7ed2d7e84adc597bdd24ca40e0b0ce4 (patch)
tree756379e45c4c02260a6d083f08ccd148274d9817
parent2a265bdda19d86437c6eb4d8deb0057d5b45e97f (diff)
Related: tdf#135762 Suppress cout if not command line
Change-Id: I9431221aadf97739bb197871f25fa151ef4c391c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119294 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit 0cda081c9aa3b3dcb363f97bac60c845ce9a13e0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119255 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--desktop/source/app/dispatchwatcher.cxx19
-rw-r--r--sc/source/ui/docshell/docsh.cxx48
2 files changed, 45 insertions, 22 deletions
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 1c4d878614c5..0e39415d8fab 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -608,15 +608,17 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector<DispatchRequest
else
{
sal_Int32 nFilterOptionsIndex = aFilter.indexOf(':');
- sal_Int32 nProps = ( 0 < nFilterOptionsIndex ) ? 3 : 2;
+ sal_Int32 nProps = ( 0 < nFilterOptionsIndex ) ? 4 : 3;
if ( !aImgOut.isEmpty() )
nProps +=1;
Sequence<PropertyValue> conversionProperties( nProps );
- conversionProperties[0].Name = "Overwrite";
- conversionProperties[0].Value <<= true;
+ conversionProperties[0].Name = "ConversionRequestOrigin";
+ conversionProperties[0].Value <<= OUString("CommandLine");
+ conversionProperties[1].Name = "Overwrite";
+ conversionProperties[1].Value <<= true;
- conversionProperties[1].Name = "FilterName";
+ conversionProperties[2].Name = "FilterName";
if( 0 < nFilterOptionsIndex )
{
OUString sFilterName = aFilter.copy(0, nFilterOptionsIndex);
@@ -641,18 +643,19 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector<DispatchRequest
bMultiFileTarget = (!aTok.isEmpty() && aTok.toInt32() != 0);
}
- conversionProperties[1].Value <<= sFilterName;
+ conversionProperties[2].Value <<= sFilterName;
- conversionProperties[2].Name = "FilterOptions";
- conversionProperties[2].Value <<= sFilterOptions;
+ conversionProperties[3].Name = "FilterOptions";
+ conversionProperties[3].Value <<= sFilterOptions;
}
else
{
- conversionProperties[1].Value <<= aFilter;
+ conversionProperties[2].Value <<= aFilter;
}
if ( !aImgOut.isEmpty() )
{
+ assert(conversionProperties[nProps-1].Name.isEmpty());
conversionProperties[nProps-1].Name = "ImageFilter";
conversionProperties[nProps-1].Value <<= aImgOut;
}
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 21137a7bb1b6..29435d90a2f4 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -2417,6 +2417,19 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
// Only from command line --convert-to
bRet = true;
+ // Verbose only from command line, not UI (in case we actually
+ // implement that) nor macro filter options.
+ bool bVerbose = false;
+ const css::uno::Sequence<css::beans::PropertyValue> & rArgs = rMed.GetArgs();
+ const auto pProp = std::find_if( rArgs.begin(), rArgs.end(),
+ [](const css::beans::PropertyValue& rProp) { return rProp.Name == "ConversionRequestOrigin"; });
+ if (pProp != rArgs.end())
+ {
+ OUString aOrigin;
+ pProp->Value >>= aOrigin;
+ bVerbose = (aOrigin == "CommandLine");
+ }
+
SCTAB nStartTab;
SCTAB nCount = m_aDocument.GetTableCount();
if (aOptions.nSheetToExport == -1)
@@ -2433,11 +2446,14 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
else
{
// Usage error, no export but log.
- if (aOptions.nSheetToExport < 0)
- std::cout << "Bad sheet number string given." << std::endl;
- else
- std::cout << "No sheet number " << OString::number(aOptions.nSheetToExport)
- << ", number of sheets is " << nCount << std::endl;
+ if (bVerbose)
+ {
+ if (aOptions.nSheetToExport < 0)
+ std::cout << "Bad sheet number string given." << std::endl;
+ else
+ std::cout << "No sheet number " << aOptions.nSheetToExport
+ << ", number of sheets is " << nCount << std::endl;
+ }
nStartTab = 0;
nCount = 0;
SetError(SCERR_EXPORT_DATA);
@@ -2462,15 +2478,19 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
// log similar to DispatchWatcher::executeDispatchRequests
OUString aOutFile = aSheetURLObject.GetMainURL(INetURLObject::DecodeMechanism::NONE);
- OUString aDisplayedName;
- if (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(aOutFile, aDisplayedName))
- aDisplayedName = aOutFile;
- std::cout << "Writing sheet " << OUStringToOString(sTabName, osl_getThreadTextEncoding()) << " -> "
- << OUStringToOString(aDisplayedName, osl_getThreadTextEncoding())
- << std::endl;
-
- if (FStatHelper::IsDocument(aOutFile))
- std::cout << "Overwriting: " << OUStringToOString(aDisplayedName, osl_getThreadTextEncoding()) << std::endl ;
+ if (bVerbose)
+ {
+ OUString aDisplayedName;
+ if (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(aOutFile, aDisplayedName))
+ aDisplayedName = aOutFile;
+ std::cout << "Writing sheet " << OUStringToOString(sTabName, osl_getThreadTextEncoding()) << " -> "
+ << OUStringToOString(aDisplayedName, osl_getThreadTextEncoding())
+ << std::endl;
+
+ if (FStatHelper::IsDocument(aOutFile))
+ std::cout << "Overwriting: " << OUStringToOString(aDisplayedName, osl_getThreadTextEncoding())
+ << std::endl ;
+ }
std::unique_ptr<SvStream> xStm = ::utl::UcbStreamHelper::CreateStream(aOutFile, StreamMode::TRUNC | StreamMode::WRITE);
if (!xStm)