summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell/docsh.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-07-20 23:09:59 +0200
committerEike Rathke <erack@redhat.com>2021-07-21 01:26:15 +0200
commit0cda081c9aa3b3dcb363f97bac60c845ce9a13e0 (patch)
tree84de8289bee6b9e53b9f7be034bc55805103a20b /sc/source/ui/docshell/docsh.cxx
parent07bd6ccf98e2062739beed84e64345918546c64a (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
Diffstat (limited to 'sc/source/ui/docshell/docsh.cxx')
-rw-r--r--sc/source/ui/docshell/docsh.cxx48
1 files changed, 34 insertions, 14 deletions
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)