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
45d7b6dd
Commit
45d7b6dd
authored
Sep 27, 2012
by
Ilia Ryabokon
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/aleksei_kanash_dev' into Ilia_dev
parents
f283193f
6df3ae06
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
180 additions
and
55 deletions
+180
-55
UBCFFSubsetAdaptor.cpp
src/adaptors/UBCFFSubsetAdaptor.cpp
+179
-54
UBCFFSubsetAdaptor.h
src/adaptors/UBCFFSubsetAdaptor.h
+1
-1
No files found.
src/adaptors/UBCFFSubsetAdaptor.cpp
View file @
45d7b6dd
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include <QSvgGenerator>
#include <QSvgGenerator>
#include <QSvgRenderer>
#include <QSvgRenderer>
#include <QPixmap>
#include <QPixmap>
#include <QMap>
#include "core/UBPersistenceManager.h"
#include "core/UBPersistenceManager.h"
...
@@ -373,6 +374,29 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e
...
@@ -373,6 +374,29 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e
brush
.
setColor
(
fillColor
);
brush
.
setColor
(
fillColor
);
brush
.
setStyle
(
Qt
::
SolidPattern
);
brush
.
setStyle
(
Qt
::
SolidPattern
);
QUuid
itemUuid
(
element
.
attribute
(
aId
).
right
(
QUuid
().
toString
().
length
()));
QUuid
itemGroupUuid
(
element
.
attribute
(
aId
).
left
(
QUuid
().
toString
().
length
()
-
1
));
if
(
!
itemUuid
.
isNull
()
&&
(
itemGroupUuid
!=
itemUuid
))
// reimported from UBZ
{
UBGraphicsPolygonItem
*
graphicsPolygon
=
new
UBGraphicsPolygonItem
(
polygon
);
graphicsPolygon
->
setBrush
(
brush
);
QTransform
transform
;
QString
textTransform
=
element
.
attribute
(
aTransform
);
graphicsPolygon
->
resetTransform
();
if
(
!
textTransform
.
isNull
())
{
transform
=
transformFromString
(
textTransform
,
graphicsPolygon
);
}
mCurrentScene
->
addItem
(
graphicsPolygon
);
graphicsPolygon
->
setUuid
(
itemUuid
);
}
else
// single CFF
{
QSvgGenerator
*
generator
=
createSvgGenerator
(
width
+
pen
.
width
(),
height
+
pen
.
width
());
QSvgGenerator
*
generator
=
createSvgGenerator
(
width
+
pen
.
width
(),
height
+
pen
.
width
());
QPainter
painter
;
QPainter
painter
;
...
@@ -403,7 +427,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e
...
@@ -403,7 +427,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e
}
}
delete
generator
;
delete
generator
;
}
return
true
;
return
true
;
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgPolyline
(
const
QDomElement
&
element
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgPolyline
(
const
QDomElement
&
element
)
...
@@ -441,6 +465,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
...
@@ -441,6 +465,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
//bounding rect lef top corner coordinates
//bounding rect lef top corner coordinates
qreal
x1
=
polygon
.
boundingRect
().
topLeft
().
x
();
qreal
x1
=
polygon
.
boundingRect
().
topLeft
().
x
();
qreal
y1
=
polygon
.
boundingRect
().
topLeft
().
y
();
qreal
y1
=
polygon
.
boundingRect
().
topLeft
().
y
();
//bounding rect dimensions
//bounding rect dimensions
qreal
width
=
polygon
.
boundingRect
().
width
();
qreal
width
=
polygon
.
boundingRect
().
width
();
qreal
height
=
polygon
.
boundingRect
().
height
();
qreal
height
=
polygon
.
boundingRect
().
height
();
...
@@ -458,14 +483,41 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
...
@@ -458,14 +483,41 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
pen
.
setColor
(
strokeColor
);
pen
.
setColor
(
strokeColor
);
pen
.
setWidth
(
strokeWidth
);
pen
.
setWidth
(
strokeWidth
);
QBrush
brush
;
brush
.
setColor
(
strokeColor
);
brush
.
setStyle
(
Qt
::
SolidPattern
);
QUuid
itemUuid
(
element
.
attribute
(
aId
).
right
(
QUuid
().
toString
().
length
()));
QUuid
itemGroupUuid
(
element
.
attribute
(
aId
).
left
(
QUuid
().
toString
().
length
()
-
1
));
if
(
!
itemUuid
.
isNull
()
&&
(
itemGroupUuid
!=
itemUuid
))
// reimported from UBZ
{
UBGraphicsPolygonItem
*
graphicsPolygon
=
new
UBGraphicsPolygonItem
(
polygon
);
UBGraphicsStroke
*
stroke
=
new
UBGraphicsStroke
();
graphicsPolygon
->
setStroke
(
stroke
);
graphicsPolygon
->
setBrush
(
brush
);
QTransform
transform
;
QString
textTransform
=
element
.
attribute
(
aTransform
);
graphicsPolygon
->
resetTransform
();
if
(
!
textTransform
.
isNull
())
{
transform
=
transformFromString
(
textTransform
,
graphicsPolygon
);
}
mCurrentScene
->
addItem
(
graphicsPolygon
);
}
else
// simple CFF
{
QSvgGenerator
*
generator
=
createSvgGenerator
(
width
+
pen
.
width
(),
height
+
pen
.
width
());
QSvgGenerator
*
generator
=
createSvgGenerator
(
width
+
pen
.
width
(),
height
+
pen
.
width
());
QPainter
painter
;
QPainter
painter
;
painter
.
begin
(
generator
);
//drawing to svg tmp file
painter
.
begin
(
generator
);
//drawing to svg tmp file
painter
.
translate
(
pen
.
widthF
()
/
2
-
x1
,
pen
.
widthF
()
/
2
-
y1
);
painter
.
translate
(
pen
.
widthF
()
/
2
-
x1
,
pen
.
widthF
()
/
2
-
y1
);
painter
.
setBrush
(
brush
);
painter
.
setPen
(
pen
);
painter
.
setPen
(
pen
);
painter
.
drawPolyline
(
polygon
);
painter
.
drawPolygon
(
polygon
);
painter
.
end
();
painter
.
end
();
...
@@ -478,7 +530,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
...
@@ -478,7 +530,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
if
(
!
textTransform
.
isNull
())
{
if
(
!
textTransform
.
isNull
())
{
transform
=
transformFromString
(
textTransform
,
svgItem
);
transform
=
transformFromString
(
textTransform
,
svgItem
);
}
}
repositionSvgItem
(
svgItem
,
width
+
strokeWidth
,
height
+
strokeWidth
,
x1
+
transform
.
m31
()
-
strokeWidth
/
2
,
y1
+
transform
.
m32
()
+
strokeWidth
/
2
,
transform
);
repositionSvgItem
(
svgItem
,
width
+
strokeWidth
,
height
+
strokeWidth
,
x1
-
strokeWidth
/
2
+
transform
.
m31
(),
y1
+
strokeWidth
/
2
+
transform
.
m32
()
,
transform
);
hashSceneItem
(
element
,
svgItem
);
hashSceneItem
(
element
,
svgItem
);
if
(
mGSectionContainer
)
if
(
mGSectionContainer
)
...
@@ -487,6 +539,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
...
@@ -487,6 +539,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
}
}
delete
generator
;
delete
generator
;
}
return
true
;
return
true
;
}
}
...
@@ -980,8 +1034,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgElement(const QDomElement &p
...
@@ -980,8 +1034,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgElement(const QDomElement &p
{
{
QString
tagName
=
parent
.
tagName
();
QString
tagName
=
parent
.
tagName
();
if
(
parent
.
namespaceURI
()
!=
svgNS
)
{
if
(
parent
.
namespaceURI
()
!=
svgNS
)
{
q
Debu
g
()
<<
"Incorrect namespace, error at content file, line number"
<<
parent
.
lineNumber
();
q
Warnin
g
()
<<
"Incorrect namespace, error at content file, line number"
<<
parent
.
lineNumber
();
return
false
;
//
return false;
}
}
if
(
tagName
==
tG
&&
!
parseGSection
(
parent
))
return
false
;
if
(
tagName
==
tG
&&
!
parseGSection
(
parent
))
return
false
;
...
@@ -1027,8 +1081,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPageset(const QDomElement &p
...
@@ -1027,8 +1081,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPageset(const QDomElement &p
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseIwbMeta
(
const
QDomElement
&
element
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseIwbMeta
(
const
QDomElement
&
element
)
{
{
if
(
element
.
namespaceURI
()
!=
iwbNS
)
{
if
(
element
.
namespaceURI
()
!=
iwbNS
)
{
q
Debu
g
()
<<
"incorrect meta namespace, incorrect document"
;
q
Warnin
g
()
<<
"incorrect meta namespace, incorrect document"
;
return
false
;
//
return false;
}
}
return
true
;
return
true
;
...
@@ -1036,8 +1090,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbMeta(const QDomElement &elem
...
@@ -1036,8 +1090,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbMeta(const QDomElement &elem
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvg
(
const
QDomElement
&
svgSection
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvg
(
const
QDomElement
&
svgSection
)
{
{
if
(
svgSection
.
namespaceURI
()
!=
svgNS
)
{
if
(
svgSection
.
namespaceURI
()
!=
svgNS
)
{
q
Debu
g
()
<<
"incorrect svg namespace, incorrect document"
;
q
Warnin
g
()
<<
"incorrect svg namespace, incorrect document"
;
return
false
;
//
return false;
}
}
parseSvgSectionAttr
(
svgSection
);
parseSvgSectionAttr
(
svgSection
);
...
@@ -1052,15 +1106,86 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvg(const QDomElement &svgSecti
...
@@ -1052,15 +1106,86 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvg(const QDomElement &svgSecti
return
true
;
return
true
;
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseIwbGroup
(
QDomElement
&
parent
)
UBGraphicsGroupContainerItem
*
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseIwbGroup
(
QDomElement
&
parent
)
{
{
//TODO. Create groups from elements parsed by parseIwbElement() function
//TODO. Create groups from elements parsed by parseIwbElement() function
if
(
parent
.
namespaceURI
()
!=
iwbNS
)
{
if
(
parent
.
namespaceURI
()
!=
iwbNS
)
{
q
Debu
g
()
<<
"incorrect iwb group namespace, incorrect document"
;
q
Warnin
g
()
<<
"incorrect iwb group namespace, incorrect document"
;
return
false
;
//
return false;
}
}
return
true
;
UBGraphicsGroupContainerItem
*
group
=
new
UBGraphicsGroupContainerItem
();
QMultiMap
<
QString
,
UBGraphicsPolygonItem
*>
strokesGroupsContainer
;
QList
<
QGraphicsItem
*>
groupContainer
;
QString
currentStrokeIdentifier
;
QDomElement
currentStrokeElement
=
parent
.
firstChildElement
();
while
(
!
currentStrokeElement
.
isNull
())
{
if
(
tGroup
==
currentStrokeElement
.
tagName
())
group
->
addToGroup
(
parseIwbGroup
(
currentStrokeElement
));
else
{
QString
uuid
=
currentStrokeElement
.
attribute
(
aRef
);
if
(
!
uuid
.
isEmpty
())
{
if
(
uuid
.
size
()
>
QUuid
().
toString
().
length
())
// create stroke group
{
currentStrokeIdentifier
=
uuid
.
left
(
QUuid
().
toString
().
length
()
-
1
);
UBGraphicsPolygonItem
*
strokeByUuid
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
mCurrentScene
->
itemForUuid
(
QUuid
(
uuid
.
right
(
QUuid
().
toString
().
length
()))));
if
(
strokeByUuid
)
strokesGroupsContainer
.
insert
(
currentStrokeIdentifier
,
strokeByUuid
);
}
else
// single elements in group
groupContainer
.
append
(
mCurrentScene
->
itemForUuid
(
QUuid
(
uuid
)));
}
}
currentStrokeElement
=
currentStrokeElement
.
nextSiblingElement
();
}
foreach
(
QString
key
,
strokesGroupsContainer
.
keys
())
{
UBGraphicsStrokesGroup
*
pStrokesGroup
=
new
UBGraphicsStrokesGroup
();
UBGraphicsStroke
*
currentStroke
=
new
UBGraphicsStroke
();
foreach
(
UBGraphicsPolygonItem
*
poly
,
strokesGroupsContainer
.
values
(
key
))
{
if
(
poly
)
{
mCurrentScene
->
removeItem
(
poly
);
mCurrentScene
->
removeItemFromDeletion
(
poly
);
poly
->
setStrokesGroup
(
pStrokesGroup
);
poly
->
setStroke
(
currentStroke
);
pStrokesGroup
->
addToGroup
(
poly
);
}
}
if
(
currentStroke
->
polygons
().
empty
())
delete
currentStroke
;
if
(
pStrokesGroup
->
childItems
().
count
())
mCurrentScene
->
addItem
(
pStrokesGroup
);
else
delete
pStrokesGroup
;
if
(
pStrokesGroup
)
group
->
addToGroup
(
pStrokesGroup
);
}
foreach
(
QGraphicsItem
*
item
,
groupContainer
)
group
->
addToGroup
(
item
);
if
(
group
->
childItems
().
count
())
{
mCurrentScene
->
addItem
(
group
);
if
(
!
groupContainer
.
count
())
{
group
->
destroy
(
false
);
}
}
return
group
;
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
strToBool
(
QString
str
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
strToBool
(
QString
str
)
...
@@ -1071,8 +1196,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::strToBool(QString str)
...
@@ -1071,8 +1196,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::strToBool(QString str)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseIwbElement
(
QDomElement
&
element
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseIwbElement
(
QDomElement
&
element
)
{
{
if
(
element
.
namespaceURI
()
!=
iwbNS
)
{
if
(
element
.
namespaceURI
()
!=
iwbNS
)
{
q
Debu
g
()
<<
"incorrect iwb element namespace, incorrect document"
;
q
Warnin
g
()
<<
"incorrect iwb element namespace, incorrect document"
;
return
false
;
//
return false;
}
}
bool
locked
=
false
;
bool
locked
=
false
;
...
...
src/adaptors/UBCFFSubsetAdaptor.h
View file @
45d7b6dd
...
@@ -102,7 +102,7 @@ private:
...
@@ -102,7 +102,7 @@ private:
inline
bool
parseSvgFlash
(
const
QDomElement
&
element
);
inline
bool
parseSvgFlash
(
const
QDomElement
&
element
);
inline
bool
parseSvgAudio
(
const
QDomElement
&
element
);
inline
bool
parseSvgAudio
(
const
QDomElement
&
element
);
inline
bool
parseSvgVideo
(
const
QDomElement
&
element
);
inline
bool
parseSvgVideo
(
const
QDomElement
&
element
);
inline
bool
parseIwbGroup
(
QDomElement
&
parent
);
inline
UBGraphicsGroupContainerItem
*
parseIwbGroup
(
QDomElement
&
parent
);
inline
bool
parseIwbElement
(
QDomElement
&
element
);
inline
bool
parseIwbElement
(
QDomElement
&
element
);
inline
void
parseTSpan
(
const
QDomElement
&
parent
,
QPainter
&
painter
inline
void
parseTSpan
(
const
QDomElement
&
parent
,
QPainter
&
painter
,
qreal
&
curX
,
qreal
&
curY
,
qreal
&
width
,
qreal
&
height
,
qreal
&
linespacing
,
QRectF
&
lastDrawnTextBoundingRect
,
qreal
&
curX
,
qreal
&
curY
,
qreal
&
width
,
qreal
&
height
,
qreal
&
linespacing
,
QRectF
&
lastDrawnTextBoundingRect
...
...
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