summaryrefslogtreecommitdiffstats
path: root/opensuse/tdelibs/fix-gnome-help-support_legacy.diff
blob: 0e2922e413f9fddf8960907d07acd6362e537317 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
--- kdoctools/kio_help.cpp
+++ kdoctools/kio_help.cpp
@@ -44,7 +44,27 @@
     // assemble the local search paths
     const QStringList localDoc = KGlobal::dirs()->resourceDirs("html");
 
+    kdDebug( 7119 ) << "Looking up help for: " << fname << endl;
+    QString _fname = fname;
+
+    QString path;
+    int slash = _fname.findRev ('/');
+    if (slash == -1 || slash == 0) {
+      path = _fname;
+      _fname = "";
+    } else {
+      path = _fname.left (slash);
+      _fname = _fname.right (_fname.length() - slash);
+    }
+
     QStringList langs = KGlobal::locale()->languageList();
+    QStringList::ConstIterator lang;
+    for (lang = langs.begin(); lang != langs.end(); ++lang)
+        if ((*lang).left(2) == "en")
+	    search.append(QString("/opt/gnome/share/gnome/help/%1/C%2").arg(path).arg(_fname));
+        else
+	    search.append(QString("/opt/gnome/share/gnome/help/%1/%2%3").arg(path).arg(*lang).arg(_fname));
+
     langs.append( "en" );
     langs.remove( "C" );
 
@@ -60,7 +80,7 @@
     {
         QStringList::ConstIterator lang;
         for (lang = langs.begin(); lang != langs.end(); ++lang)
-            search.append(QString("%1%2/%3").arg(localDoc[id], *lang, fname));
+            search.append(QString("%1%2/%3").arg(localDoc[id], *lang, path + _fname));
     }
 
     // try to locate the file
@@ -81,6 +101,15 @@
             if (info.exists() && info.isFile() && info.isReadable())
                 return *it;
         }
+
+        if ( ( *it ).right( 5 ) == ".html" )
+        {
+            QString file = (*it).left((*it).findRev('/')) + "/" + path + ".xml";
+            kdDebug( 7119 ) << "Looking for help in: " << file << endl;
+            info.setFile(file);
+            if (info.exists() && info.isFile() && info.isReadable())
+                return *it;
+        }
     }
 
 
@@ -100,7 +129,7 @@
     result = langLookup(path);
     if (result.isEmpty())
     {
-        result = langLookup(path+"/index.html");
+        result = langLookup(path + "/index.html");
         if (!result.isEmpty())
 	{
             KURL red( "help:/" );
@@ -190,12 +219,26 @@
       }
     } else {
         QString docbook_file = file.left(file.findRev('/')) + "/index.docbook";
+        int last_slash = file.findRev('/');
+        if (last_slash != -1 && last_slash != 0) {
+          int slash2 = file.findRev('/', last_slash -1);
+          if (slash2 != -1 && slash2 != 0) {
+	     int slash3 = file.findRev('/', slash2 - 1);
+	     if (slash3 != -1) {
+	       QString xml_file = file.left(file.findRev('/')) + "/" + file.mid(slash3 + 1, slash2 - (slash3 + 1)) + ".xml";
+	       kdDebug( 7119 ) << "xml_file " << xml_file << endl;
+	       QFileInfo fi(xml_file);
+	       if (fi.exists())
+	         docbook_file = xml_file;
+	     }
+          }
+        }
         if (!KStandardDirs::exists(file)) {
             file = docbook_file;
         } else {
             QFileInfo fi(file);
             if (fi.isDir()) {
-                file = file + "/index.docbook";
+                file = docbook_file;
             } else {
                 if ( file.right( 5 ) != ".html" || !compareTimeStamps( file, docbook_file ) ) {
                     get_file( target );
@@ -238,7 +281,11 @@
             mParsed = transform(file, locate("dtd", "customization/kde-chunk.xsl"));
             if ( !mParsed.isEmpty() ) {
                 infoMessage( i18n( "Saving to cache" ) );
-                QString cache = file.left( file.length() - 7 );
+		QString cache;
+		if (file.endsWith(".xml"))
+		    cache = file.left( file.length() - strlen ("xml") );
+		else
+		    cache = file.left( file.length() - strlen ("docbook") );
                 saveToCache( mParsed, locateLocal( "cache",
                                                         "kio_help" + cache +
                                                         "cache.bz2" ) );
--- kdoctools/xslt.cpp
+++ kdoctools/xslt.cpp
@@ -274,10 +274,16 @@
 QString lookForCache( const QString &filename )
 {
     kdDebug() << "lookForCache " << filename << endl;
-    assert( filename.endsWith( ".docbook" ) );
+    assert( filename.endsWith( ".docbook" ) || filename.endsWith( ".xml" ) );
     assert( filename.at( 0 ) == '/' );
 
-    QString cache = filename.left( filename.length() - 7 );
+    QString cache;
+
+    if (filename.endsWith( ".xml" ))
+      cache = filename.left( filename.length() - strlen ("xml") );
+    else
+      cache = filename.left( filename.length() - strlen ("docbook") );
+
     QString output;
     if ( readCache( filename, cache + "cache.bz2", output) )
         return output;