CVS commit by faure: Use .html, .xml or .xhtml as extension depending on the type of document, for "View Source" actions and "Save" actions (when no filename exists). BUG: 40496 M +15 -4 khtml_part.cpp 1.1097 M +3 -0 khtml_part.h 1.281 --- kdelibs/khtml/khtml_part.cpp #1.1096:1.1097 @@ -3793,5 +3793,5 @@ void KHTMLPart::slotViewDocumentSource() if (!(url.isLocalFile()) && KHTMLPageCache::self()->isComplete(d->m_cacheId)) { - KTempFile sourceFile(QString::null, QString::fromLatin1(".html")); + KTempFile sourceFile(QString::null, defaultExtension()); if (sourceFile.status() == 0) { @@ -3873,5 +3873,5 @@ void KHTMLPart::slotViewFrameSource() if (KHTMLPageCache::self()->isComplete(cacheId)) { - KTempFile sourceFile(QString::null, QString::fromLatin1(".html")); + KTempFile sourceFile(QString::null, defaultExtension()); if (sourceFile.status() == 0) { @@ -3910,5 +3910,5 @@ void KHTMLPart::slotSaveDocument() if ( srcURL.fileName(false).isEmpty() ) - srcURL.setFileName( "index.html" ); + srcURL.setFileName( "index" + defaultExtension() ); KIO::MetaData metaData; @@ -3985,5 +3985,5 @@ void KHTMLPart::slotSaveFrame() if ( srcURL.fileName(false).isEmpty() ) - srcURL.setFileName( "index.html" ); + srcURL.setFileName( "index" + defaultExtension() ); KIO::MetaData metaData; @@ -7089,4 +7089,15 @@ void KHTMLPart::setSuppressedPopupIndica } +// Extension to use for "view document source", "save as" etc. +// Using the right extension can help the viewer get into the right mode (#40496) +QString KHTMLPart::defaultExtension() const +{ + if ( !d->m_doc ) + return ".html"; + if ( !d->m_doc->isHTMLDocument() ) + return ".xml"; + return d->m_doc->htmlMode() == DOM::DocumentImpl::XHtml ? ".xhtml" : ".html"; +} + using namespace KParts; #include "khtml_part.moc" --- kdelibs/khtml/khtml_part.h #1.280:1.281 @@ -1599,4 +1599,7 @@ private: QString defaultEncoding() const; + /** .html, .xhtml or .xml */ + QString defaultExtension() const; + /** @internal * generic zoom in