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
9f4b3f27
Commit
9f4b3f27
authored
Oct 19, 2011
by
Ivan Ilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cff new functional
parent
5683ee7a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
25 deletions
+105
-25
UBCFFSubsetAdaptor.cpp
src/adaptors/UBCFFSubsetAdaptor.cpp
+81
-23
UBCFFSubsetAdaptor.h
src/adaptors/UBCFFSubsetAdaptor.h
+22
-0
UBImportCFF.cpp
src/adaptors/UBImportCFF.cpp
+2
-2
No files found.
src/adaptors/UBCFFSubsetAdaptor.cpp
View file @
9f4b3f27
...
...
@@ -34,6 +34,8 @@
#include "core/UBApplication.h"
#include "QFile"
#include "QDomDocument"
//enum of xmlparse status
//tag names definition
...
...
@@ -75,11 +77,54 @@ static QString aFontstyle = "font-style";
static
QString
aFontweight
=
"font-weight"
;
static
QString
aTextalign
=
"text-align"
;
static
QString
aPoints
=
"points"
;
static
QString
svgNS
=
"http://www.w3.org/2000/svg"
;
static
QString
tId
=
"id"
;
UBCFFSubsetAdaptor
::
UBCFFSubsetAdaptor
()
{
}
void
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
hashNode
(
QDomNode
*
parent
,
QString
prefix
)
{
QDomNode
n
=
parent
->
firstChild
();
while
(
!
n
.
isNull
())
{
QDomElement
e
=
n
.
toElement
();
QString
id
=
e
.
attribute
(
tId
);
if
(
!
id
.
isNull
())
{
extProperties
.
insert
(
id
,
IwbExt
(
e
));
qDebug
()
<<
prefix
+
e
.
prefix
()
+
":"
+
e
.
tagName
();
}
if
(
n
.
hasChildNodes
())
{
hashNode
(
&
n
,
QString
(
"| %1"
).
arg
(
prefix
));
}
n
=
n
.
nextSibling
();
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
hashElements
()
{
QDomElement
svgSection
=
mDOMdoc
.
elementsByTagNameNS
(
svgNS
,
tSvg
).
at
(
0
).
toElement
();
Q_ASSERT
(
!
svgSection
.
isNull
());
hashNode
(
&
svgSection
);
qDebug
()
<<
"ext properties count "
<<
extProperties
.
count
();
qDebug
()
<<
extProperties
.
value
(
"link1"
).
element
.
toElement
().
tagName
();
// QDomNode n = docElem.firstChild();
// int i = 0;
// while(!n.isNull()) {
// QDomElement e = n.toElement(); // try to convert the node to an element.
// if(!e.isNull()) {
// qDebug() << e.prefix() << ":" << e.tagName() ; // the node really is an element.
// i++;
// }
// n = n.nextSibling();
// }
return
false
;
}
bool
UBCFFSubsetAdaptor
::
ConvertCFFFileToUbz
(
QString
&
cffSourceFile
,
UBDocumentProxy
*
pDocument
)
{
...
...
@@ -116,6 +161,14 @@ bool UBCFFSubsetAdaptor::ConvertCFFFileToUbz(QString &cffSourceFile, UBDocumentP
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
UBCFFSubsetReader
(
UBDocumentProxy
*
proxy
,
QByteArray
&
content
)
:
mReader
(
content
),
mProxy
(
proxy
),
currentState
(
NONE
)
{
int
errorLine
,
errorColumn
;
QString
errorStr
;
if
(
!
mDOMdoc
.
setContent
(
content
,
true
,
&
errorStr
,
&
errorLine
,
&
errorColumn
)){
qWarning
()
<<
"Error:Parseerroratline"
<<
errorLine
<<
","
<<
"column"
<<
errorColumn
<<
":"
<<
errorStr
;
}
else
{
qDebug
()
<<
"well parsed to DOM"
;
}
// QFile tfile("/home/ilia/Documents/tmp/2/out.xml");
// tfile.open(QIODevice::ReadWr ite | QIODevice::Text);
// QTextStream out(&tfile);
...
...
@@ -131,6 +184,9 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parse()
if
(
!
getTempFileName
())
return
false
;
if
(
mDOMdoc
.
isNull
())
return
false
;
bool
result
=
parseDoc
();
if
(
result
)
result
=
mProxy
->
pageCount
()
!=
0
;
...
...
@@ -160,29 +216,31 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::PushState(int state)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseDoc
()
{
while
(
!
mReader
.
atEnd
())
{
mReader
.
readNext
();
if
(
mReader
.
isStartElement
())
{
if
(
!
parseCurrentElementStart
())
return
false
;
}
else
if
(
mReader
.
isCharacters
())
{
if
(
!
parseCurrentElementCharacters
())
return
false
;
}
else
if
(
mReader
.
isEndElement
())
{
if
(
!
parseCurrentElementEnd
())
return
false
;
}
}
if
(
!
mReader
.
error
()
==
QXmlStreamReader
::
NoError
)
UBApplication
::
showMessage
(
mReader
.
errorString
());
// while (!mReader.atEnd())
// {
// mReader.readNext();
// if (mReader.isStartElement())
// {
// if (!parseCurrentElementStart())
// return false;
// }
// else
// if (mReader.isCharacters())
// {
// if (!parseCurrentElementCharacters())
// return false;
// }
// else
// if (mReader.isEndElement())
// {
// if (!parseCurrentElementEnd())
// return false;
// }
// }
// if (!mReader.error() == QXmlStreamReader::NoError)
// UBApplication::showMessage(mReader.errorString());
if
(
!
hashElements
())
return
false
;
return
true
;
}
...
...
src/adaptors/UBCFFSubsetAdaptor.h
View file @
9f4b3f27
...
...
@@ -19,6 +19,8 @@
#include <QtXml>
#include <QString>
#include <QStack>
#include <QDomDocument>
#include <QHash>
class
UBDocumentProxy
;
class
UBGraphicsScene
;
...
...
@@ -26,6 +28,15 @@ class QSvgGenerator;
class
UBGraphicsSvgItem
;
class
QTransform
;
struct
IwbExt
{
IwbExt
()
:
group
(
NULL
)
{;}
IwbExt
(
QDomNode
element
)
:
group
(
NULL
),
element
(
element
)
{;}
QDomNode
*
group
;
QDomNode
element
;
QHash
<
QString
,
QString
>
textAttributes
;
};
class
UBCFFSubsetAdaptor
{
public
:
...
...
@@ -65,6 +76,15 @@ private:
QPointF
mViewBoxCenter
;
QSize
mSize
;
private
:
QDomDocument
mDOMdoc
;
QHash
<
QString
,
IwbExt
>
extProperties
;
bool
hashElements
();
void
hashNode
(
QDomNode
*
parent
,
QString
prefix
=
""
);
//methods to store current xml parse state
int
PopState
();
void
PushState
(
int
state
);
...
...
@@ -92,7 +112,9 @@ private:
bool
createNewScene
();
bool
persistCurrentScene
();
QStack
<
int
>
stateStack
;
int
currentState
;
//helper methods
...
...
src/adaptors/UBImportCFF.cpp
View file @
9f4b3f27
...
...
@@ -47,8 +47,8 @@ UBImportCFF::~UBImportCFF()
QStringList
UBImportCFF
::
supportedExtentions
()
{
//
return QStringList("iwb");
return
QStringList
();
return
QStringList
(
"iwb"
);
//
return QStringList();
}
...
...
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