[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Bug 93853: JJ: KWord/KPresenter: no network transparency when
From:       Giovanni Venturi <gventuri73 () tiscali ! it>
Date:       2004-12-01 0:24:53
Message-ID: 200412010124.58235.gventuri73 () tiscali ! it
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


I attach the first patch (just for KWord now).
If you like it I commit. I tryed it and it works.
Gianni
-- 
A KDE Italian translator
Slackware GNU/Linux current version - kernel 2.6.9

["kword.patch" (text/x-diff)]

Index: kwview.cc
===================================================================
RCS file: /home/kde/koffice/kword/kwview.cc,v
retrieving revision 1.1056
diff -u -p -p -u -r1.1056 kwview.cc
--- kwview.cc	14 Nov 2004 09:44:51 -0000	1.1056
+++ kwview.cc	1 Dec 2004 00:18:12 -0000
@@ -125,6 +125,7 @@
 using namespace KSpell2;
 #endif
 
+#include <kio/netaccess.h>
 
 KWView::KWView( KWViewMode* viewMode, QWidget *_parent, const char *_name, KWDocument* _doc )
     : KoView( _doc, _parent, _name )
@@ -5890,40 +5891,71 @@ void KWView::savePicture()
     if ( frame )//test for dcop call
     {
         KWPictureFrameSet *frameset = static_cast<KWPictureFrameSet *>(frame->frameSet());
-        QString oldFile=frameset->picture().getKey().filename();
+        QString oldFile = frameset->picture().getKey().filename();
         KURL url;
         url.setPath( oldFile );
-        if (!QDir(url.directory()).exists())
+        if ( !QDir(url.directory()).exists() )
             oldFile = url.fileName();
 
-        KoPicture picture(frameset->picture());
-        QString mimetype=picture.getMimeType();
+        KoPicture picture( frameset->picture() );
+        QString mimetype = picture.getMimeType();
         kdDebug() << "Picture has mime type: " << mimetype << endl;
         QStringList mimetypes;
         mimetypes << mimetype;
         KFileDialog fd( oldFile, QString::null, this, 0, TRUE );
         fd.setMimeFilter( mimetypes );
         fd.setCaption(i18n("Save Picture"));
+	fd.setOperationMode(KFileDialog::Saving);
         if ( fd.exec() == QDialog::Accepted )
-        {
-            url = fd.selectedURL();
-            if( url.isEmpty() )
+	{
+	    url = fd.selectedURL();
+	    if ( url.isValid() )
             {
-                KMessageBox::sorry( this,
-                                    i18n("File name is empty."),
-                                    i18n("Save Picture"));
-                return;
-            }
-            // ### TODO: (JJ:) network transparency, use KIO::NetAccess::upload
-            QFile file( url.path() );
-            if ( file.open( IO_ReadWrite ) ) {
-                picture.save( &file );
-                file.close();
-            } else {
-                KMessageBox::error(this,
+                if ( url.isLocalFile() )
+	        {
+                    QFile file( url.path() );
+                    if ( file.open( IO_ReadWrite ) )
+		    {
+                        picture.save( &file );
+                        file.close();
+                    }
+		    else
+		    {
+                        KMessageBox::error(this,
                                    i18n("Error during saving."),
                                    i18n("Save Picture"));
-            }
+                    }
+	        }
+	        else
+	        {
+	            KTempFile tempFile;
+                    tempFile.setAutoDelete( true );
+	            if ( tempFile.status() == 0 )
+		    {
+		        QFile file( tempFile.name() );
+		        if ( file.open( IO_ReadWrite ) )
+		        {
+		            picture.save( &file );
+                            file.close();
+			    if ( !KIO::NetAccess::upload( tempFile.name(), url, this ) )
+			    {
+			        KMessageBox::sorry( this, i18n(
+				    "Unable to save the file to '%1'.").arg( url.prettyURL() ),
+				    i18n("Save Failed") );
+		            }
+                        }
+		        else
+		            KMessageBox::error(this,
+                                   i18n("Error during saving."),
+                                   i18n("Save Picture"));
+                    }
+		    else
+		        KMessageBox::sorry( this, i18n(
+			  "Error during saving."), i18n("Save Picture") );
+	        }
+	    }
+	    else
+	        KMessageBox::sorry( this, i18n("URL is invalid."), i18n("Save Picture") );
         }
     }
 }

[Attachment #8 (application/pgp-signature)]

_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic