sfx2/source/doc/guisaveas.cxx |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

New commits:
commit 754f13a4217b4fbf7c18832eea21a395a2cd2423
Author:     Tor Lillqvist <[email protected]>
AuthorDate: Tue Nov 4 17:33:28 2025 +0200
Commit:     Miklos Vajna <[email protected]>
CommitDate: Thu Dec 11 15:49:15 2025 +0100

    Add horrible hack to ask the filename when exporting PDF in CODA-W
    
    The PDF export functionality displays a dialog from JavaScript that
    allows the user to choose various PDF parameters. But unlike export to
    other formats, no system file save dialog gets displayed by CODA. So
    do something horrible: Look up a function in CODA.cpp and call it
    directly. Sorry.
    
    Change-Id: I21932b2ba67d3aab72463d51f8ef71182ca5c736
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195379
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 55798c19af1a..1c9dd37343f7 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -107,6 +107,7 @@
 #include <vcl/abstdlg.hxx>
 
 #ifdef _WIN32
+#include <o3tl/char16_t2wchar_t.hxx>
 #include <Shlobj.h>
 #ifdef GetTempPath
 #undef GetTempPath
@@ -1717,6 +1718,22 @@ bool 
SfxStoringHelper::FinishGUIStoreModel(::comphelper::SequenceAsHashMap::cons
     {
         OUString aFileName;
         aFileNameIter->second >>= aFileName;
+#ifdef _WIN32
+        if (comphelper::LibreOfficeKit::isActive())
+        {
+            // FIXME: Horrible hack. In CODA-W, we didn't actually
+            // display any dialog yet, so call into a function in
+            // CODA.cpp.
+            typedef void (*ofd_t)(const std::wstring& suggestedURI, 
std::string& result);
+            ofd_t ofd = (ofd_t)GetProcAddress(GetModuleHandle(NULL), 
"output_file_dialog_from_core");
+            std::string newURI;
+            (*ofd)(std::wstring(o3tl::toW(aFileName)), newURI);
+            if (newURI == "")
+                return false;
+            aFileName = OUString::fromUtf8(newURI.c_str());
+        }
+#endif
+
         aURL.SetURL( aFileName );
         DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "Illegal 
URL!" );
 

Reply via email to