Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
0482d9a6
Commit
0482d9a6
authored
Sep 23, 2011
by
Ivan Ilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paused working on CFF. Feature is temporary commented
parent
1b82fdfa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
82 deletions
+68
-82
UBCFFSubsetAdaptor.cpp
src/adaptors/UBCFFSubsetAdaptor.cpp
+13
-0
UBImportCFF.cpp
src/adaptors/UBImportCFF.cpp
+55
-82
No files found.
src/adaptors/UBCFFSubsetAdaptor.cpp
View file @
0482d9a6
...
...
@@ -31,6 +31,9 @@
#include "UBThumbnailAdaptor.h"
#include "UBSvgSubsetAdaptor.h"
#include "core/UBApplication.h"
#include "QFile"
//enum of xmlparse status
//tag names definition
...
...
@@ -92,6 +95,9 @@ bool UBCFFSubsetAdaptor::ConvertCFFFileToUbz(QString &cffSourceFile, UBDocumentP
return
false
;
}
// QTextStream out(&file);
// out.setCodec("UTF-8");
// QString dta = out.readAll();
QByteArray
data
=
file
.
readAll
();
if
(
data
.
length
()
==
0
)
{
...
...
@@ -110,6 +116,11 @@ bool UBCFFSubsetAdaptor::ConvertCFFFileToUbz(QString &cffSourceFile, UBDocumentP
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
UBCFFSubsetReader
(
UBDocumentProxy
*
proxy
,
QByteArray
&
content
)
:
mReader
(
content
),
mProxy
(
proxy
),
currentState
(
NONE
)
{
// QFile tfile("/home/ilia/Documents/tmp/2/out.xml");
// tfile.open(QIODevice::ReadWr ite | QIODevice::Text);
// QTextStream out(&tfile);
// out << content;
// tfile.close();
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parse
()
...
...
@@ -170,6 +181,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseDoc()
return
false
;
}
}
if
(
!
mReader
.
error
()
==
QXmlStreamReader
::
NoError
)
UBApplication
::
showMessage
(
mReader
.
errorString
());
return
true
;
}
...
...
src/adaptors/UBImportCFF.cpp
View file @
0482d9a6
...
...
@@ -47,7 +47,8 @@ UBImportCFF::~UBImportCFF()
QStringList
UBImportCFF
::
supportedExtentions
()
{
return
QStringList
(
"iwb"
);
// return QStringList("iwb");
return
QStringList
();
}
...
...
@@ -124,8 +125,7 @@ QString UBImportCFF::expandFileToDir(const QFile& pZipFile, const QString& pDir)
{
QuaZip
zip
(
pZipFile
.
fileName
());
if
(
!
zip
.
open
(
QuaZip
::
mdUnzip
))
{
if
(
!
zip
.
open
(
QuaZip
::
mdUnzip
))
{
qWarning
()
<<
"Import failed. Cause zip.open(): "
<<
zip
.
getZipError
();
return
""
;
}
...
...
@@ -139,67 +139,48 @@ QString UBImportCFF::expandFileToDir(const QFile& pZipFile, const QString& pDir)
QString
documentRootFolder
;
int
tmpNumber
=
0
;
QDir
rootDir
;
while
(
true
)
{
while
(
true
)
{
QString
tempPath
=
QString
(
"%1/sank%2.%3"
)
.
arg
(
pDir
)
.
arg
(
QDateTime
::
currentDateTime
().
toString
(
"dd_MM_yyyy_HH-mm"
))
.
arg
(
tmpNumber
);
if
(
!
rootDir
.
exists
(
tempPath
))
{
if
(
!
rootDir
.
exists
(
tempPath
))
{
documentRootFolder
=
tempPath
;
break
;
}
tmpNumber
++
;
if
(
tmpNumber
==
100000
)
{
if
(
tmpNumber
==
100000
)
{
qWarning
()
<<
"Import failed. Failed to create temporary directory for iwb file"
;
return
""
;
}
}
if
(
!
rootDir
.
mkdir
(
documentRootFolder
))
{
if
(
!
rootDir
.
mkdir
(
documentRootFolder
))
{
qWarning
()
<<
"Import failed. Couse: failed to create temp folder for cff package"
;
}
// first we search the metadata.rdf to check the document properties
for
(
bool
more
=
zip
.
goToFirstFile
();
more
;
more
=
zip
.
goToNextFile
())
{
if
(
!
zip
.
getCurrentFileInfo
(
&
info
))
{
qWarning
()
<<
"Import failed. Cause: getCurrentFileInfo(): "
<<
zip
.
getZipError
();
return
""
;
}
QFileInfo
currentFileInfo
(
pDir
+
"/"
+
file
.
getActualFileName
());
}
QStringList
lst
=
zip
.
getFileNameList
();
QFile
out
;
char
c
;
for
(
bool
more
=
zip
.
goToFirstFile
();
more
;
more
=
zip
.
goToNextFile
())
{
if
(
!
zip
.
getCurrentFileInfo
(
&
info
))
{
for
(
bool
more
=
zip
.
goToFirstFile
();
more
;
more
=
zip
.
goToNextFile
())
{
if
(
!
zip
.
getCurrentFileInfo
(
&
info
))
{
//TOD UB 4.3 O display error to user or use crash reporter
qWarning
()
<<
"Import failed. Cause: getCurrentFileInfo(): "
<<
zip
.
getZipError
();
return
""
;
}
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
qWarning
()
<<
"Import failed. Cause: file.open(): "
<<
zip
.
getZipError
();
return
""
;
}
if
(
file
.
getZipError
()
!=
UNZ_OK
)
{
// if(!file.open(QIODevice::ReadOnly)) {
// qWarning() << "Import failed. Cause: file.open(): " << zip.getZipError();
// return "";
// }
file
.
open
(
QIODevice
::
ReadOnly
);
if
(
file
.
getZipError
()
!=
UNZ_OK
)
{
qWarning
()
<<
"Import failed. Cause: file.getFileName(): "
<<
zip
.
getZipError
();
return
""
;
}
QString
newFileName
=
documentRootFolder
+
"/"
+
file
.
getActualFileName
();
bool
ends
=
newFileName
.
endsWith
(
'/'
);
if
(
!
ends
)
{
QFileInfo
newFileInfo
(
newFileName
);
rootDir
.
mkpath
(
newFileInfo
.
absolutePath
());
...
...
@@ -216,47 +197,39 @@ QString UBImportCFF::expandFileToDir(const QFile& pZipFile, const QString& pDir)
out
.
close
();
return
""
;
}
while
(
file
.
getChar
(
&
c
))
out
.
putChar
(
c
);
out
.
close
();
if
(
file
.
getZipError
()
!=
UNZ_OK
)
{
if
(
file
.
getZipError
()
!=
UNZ_OK
)
{
qWarning
()
<<
"Import failed. Cause: "
<<
zip
.
getZipError
();
return
""
;
}
if
(
!
file
.
atEnd
())
{
if
(
!
file
.
atEnd
())
{
qWarning
()
<<
"Import failed. Cause: read all but not EOF"
;
return
""
;
}
file
.
close
();
if
(
file
.
getZipError
()
!=
UNZ_OK
)
{
if
(
file
.
getZipError
()
!=
UNZ_OK
)
{
qWarning
()
<<
"Import failed. Cause: file.close(): "
<<
file
.
getZipError
();
return
""
;
}
}
}
zip
.
close
();
if
(
zip
.
getZipError
()
!=
UNZ_OK
)
{
if
(
zip
.
getZipError
()
!=
UNZ_OK
)
{
qWarning
()
<<
"Import failed. Cause: zip.close(): "
<<
zip
.
getZipError
();
return
""
;
}
return
documentRootFolder
;
}
UBDocumentProxy
*
UBImportCFF
::
importFile
(
const
QFile
&
pFile
,
const
QString
&
pGroup
)
{
Q_UNUSED
(
pGroup
);
// group is defined in the imported file
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment