summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid E. Narvaez <[email protected]>2014-01-01 20:57:57 -0500
committerDavid E. Narvaez <[email protected]>2014-01-14 13:54:10 -0500
commit0f1c3356379194ab99365a1c8acc4e98d25a2f45 (patch)
treecf3cf7a0a00047fa231e2199987ffa14933d1815
parente2c746cfeca5f7c87b785a6a5b4e89a2474dd663 (diff)
Let the Native Filter Load Docs from Memory
Will be used to load a transformation of a Geogebra XML file to a Kig Native file.
-rw-r--r--filters/native-filter.cc15
-rw-r--r--filters/native-filter.h6
2 files changed, 14 insertions, 7 deletions
diff --git a/filters/native-filter.cc b/filters/native-filter.cc
index dd193f4..65ff4fc 100644
--- a/filters/native-filter.cc
+++ b/filters/native-filter.cc
@@ -105,7 +105,7 @@ bool KigFilterNative::supportMime( const QString& mime )
return mime == "application/x-kig";
}
-KigDocument* KigFilterNative::load( const QString& file )
+KigDocument* KigFilterNative::load( const QString& file)
{
QFile ffile( file );
if ( ! ffile.open( QIODevice::ReadOnly ) )
@@ -166,7 +166,12 @@ KigDocument* KigFilterNative::load( const QString& file )
// removing temp file
if ( iscompressed )
kigdoc.remove();
+
+ return load( doc );
+}
+KigDocument* KigFilterNative::load( const QDomDocument& doc )
+{
QDomElement main = doc.documentElement();
QString version = main.attribute( "CompatibilityVersion" );
@@ -207,12 +212,12 @@ KigDocument* KigFilterNative::load( const QString& file )
return 0;
}
else if ( major == 0 && minor <= 6 )
- return load04( file, main );
+ return load04( main );
else
- return load07( file, main );
+ return load07( main );
}
-KigDocument* KigFilterNative::load04( const QString& file, const QDomElement& docelem )
+KigDocument* KigFilterNative::load04( const QDomElement& docelem )
{
bool ok = true;
@@ -390,7 +395,7 @@ static const char* obsoletemessage = I18N_NOOP(
"which is obsolete, you should save the construction with "
"a different name and check that it works as expected." );
-KigDocument* KigFilterNative::load07( const QString& file, const QDomElement& docelem )
+KigDocument* KigFilterNative::load07( const QDomElement& docelem )
{
KigDocument* ret = new KigDocument();
diff --git a/filters/native-filter.h b/filters/native-filter.h
index 12778f3..d79cc92 100644
--- a/filters/native-filter.h
+++ b/filters/native-filter.h
@@ -21,6 +21,7 @@
#include "filter.h"
class QDomElement;
+class QDomDocument;
class KigDocument;
class QTextStream;
class QString;
@@ -38,12 +39,12 @@ private:
* this is the load function for the Kig format that is used,
* starting at Kig 0.4
*/
- KigDocument* load04( const QString& file, const QDomElement& doc );
+ KigDocument* load04( const QDomElement& doc );
/**
* this is the load function for the Kig format that is used
* starting at Kig 0.7
*/
- KigDocument* load07( const QString& file, const QDomElement& doc );
+ KigDocument* load07( const QDomElement& doc );
/**
* save in the Kig format that is used starting at Kig 0.7
@@ -58,6 +59,7 @@ public:
bool supportMime( const QString& mime );
KigDocument* load( const QString& file );
+ KigDocument* load( const QDomDocument& doc );
bool save( const KigDocument& data, const QString& file );
// bool save( const KigDocument& data, QTextStream& stream );