[Libreoffice-commits] core.git: desktop/source sc/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 20 23:26:58 UTC 2021


 desktop/source/app/dispatchwatcher.cxx |   19 +++++++------
 sc/source/ui/docshell/docsh.cxx        |   48 +++++++++++++++++++++++----------
 2 files changed, 45 insertions(+), 22 deletions(-)

New commits:
commit 0cda081c9aa3b3dcb363f97bac60c845ce9a13e0
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Tue Jul 20 23:09:59 2021 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Wed Jul 21 01:26:15 2021 +0200

    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 at redhat.com>
    Tested-by: Jenkins

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)


More information about the Libreoffice-commits mailing list