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
d387f5d0
Commit
d387f5d0
authored
Nov 15, 2011
by
Ivan Ilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CFF partial support. All sankre compatible features
parent
5aebe0cf
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
68 additions
and
248 deletions
+68
-248
UBCFFSubsetAdaptor.cpp
src/adaptors/UBCFFSubsetAdaptor.cpp
+61
-234
UBCFFSubsetAdaptor.h
src/adaptors/UBCFFSubsetAdaptor.h
+3
-5
UBThumbnailAdaptor.cpp
src/adaptors/UBThumbnailAdaptor.cpp
+0
-1
UBPersistenceManager.h
src/core/UBPersistenceManager.h
+1
-0
UBGraphicsPixmapItem.h
src/domain/UBGraphicsPixmapItem.h
+1
-2
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+1
-1
UBGraphicsTextItem.h
src/domain/UBGraphicsTextItem.h
+1
-4
PDFRenderer.cpp
src/pdf/PDFRenderer.cpp
+0
-1
No files found.
src/adaptors/UBCFFSubsetAdaptor.cpp
View file @
d387f5d0
...
@@ -43,10 +43,7 @@
...
@@ -43,10 +43,7 @@
#include "core/memcheck.h"
#include "core/memcheck.h"
//enum of xmlparse status
//tag names definition. Use them everiwhere!
//tag names definition
//use them everiwhere!
static
QString
tElement
=
"element"
;
static
QString
tElement
=
"element"
;
static
QString
tGroup
=
"group"
;
static
QString
tGroup
=
"group"
;
static
QString
tEllipse
=
"ellipse"
;
static
QString
tEllipse
=
"ellipse"
;
...
@@ -67,7 +64,6 @@ static QString tFlash = "flash";
...
@@ -67,7 +64,6 @@ static QString tFlash = "flash";
static
QString
tAudio
=
"audio"
;
static
QString
tAudio
=
"audio"
;
static
QString
tVideo
=
"video"
;
static
QString
tVideo
=
"video"
;
//attribute names definition
//attribute names definition
static
QString
aFill
=
"fill"
;
static
QString
aFill
=
"fill"
;
static
QString
aFillopacity
=
"fill-opacity"
;
static
QString
aFillopacity
=
"fill-opacity"
;
...
@@ -126,7 +122,6 @@ bool UBCFFSubsetAdaptor::ConvertCFFFileToUbz(QString &cffSourceFile, UBDocumentP
...
@@ -126,7 +122,6 @@ bool UBCFFSubsetAdaptor::ConvertCFFFileToUbz(QString &cffSourceFile, UBDocumentP
return
result
;
return
result
;
}
}
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
UBCFFSubsetReader
(
UBDocumentProxy
*
proxy
,
QFile
*
content
)
:
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
UBCFFSubsetReader
(
UBDocumentProxy
*
proxy
,
QFile
*
content
)
:
mProxy
(
proxy
)
mProxy
(
proxy
)
{
{
...
@@ -141,7 +136,6 @@ UBCFFSubsetAdaptor::UBCFFSubsetReader::UBCFFSubsetReader(UBDocumentProxy *proxy,
...
@@ -141,7 +136,6 @@ UBCFFSubsetAdaptor::UBCFFSubsetReader::UBCFFSubsetReader(UBDocumentProxy *proxy,
}
}
qDebug
()
<<
"tmp path is"
<<
pwdContent
;
qDebug
()
<<
"tmp path is"
<<
pwdContent
;
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parse
()
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parse
()
{
{
UBMetadataDcSubsetAdaptor
::
persist
(
mProxy
);
UBMetadataDcSubsetAdaptor
::
persist
(
mProxy
);
...
@@ -150,7 +144,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parse()
...
@@ -150,7 +144,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parse()
if
(
!
getTempFileName
()
||
!
createTempFlashPath
())
if
(
!
getTempFileName
()
||
!
createTempFlashPath
())
return
false
;
return
false
;
if
(
mDOMdoc
.
isNull
())
if
(
mDOMdoc
.
isNull
())
return
false
;
return
false
;
...
@@ -166,7 +159,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parse()
...
@@ -166,7 +159,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parse()
return
result
;
return
result
;
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgRect
(
const
QDomElement
&
element
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgRect
(
const
QDomElement
&
element
)
{
{
qreal
x1
=
element
.
attribute
(
aX
).
toDouble
();
qreal
x1
=
element
.
attribute
(
aX
).
toDouble
();
...
@@ -215,7 +207,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgRect(const QDomElement &elem
...
@@ -215,7 +207,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgRect(const QDomElement &elem
transform
=
transformFromString
(
textTransform
);
transform
=
transformFromString
(
textTransform
);
hastransform
=
true
;
hastransform
=
true
;
}
}
repositionSvgItem
(
svgItem
,
width
,
height
,
x1
,
y1
,
hastransform
,
transform
);
repositionSvgItem
(
svgItem
,
width
,
height
,
x1
,
y1
,
hastransform
,
transform
);
hashSceneItem
(
element
,
svgItem
);
delete
generator
;
delete
generator
;
return
true
;
return
true
;
...
@@ -257,7 +252,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgEllipse(const QDomElement &e
...
@@ -257,7 +252,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgEllipse(const QDomElement &e
transform
=
transformFromString
(
textTransform
);
transform
=
transformFromString
(
textTransform
);
hastransform
=
true
;
hastransform
=
true
;
}
}
repositionSvgItem
(
svgItem
,
rx
*
2
,
ry
*
2
,
cx
-
rx
,
cy
-
ry
,
hastransform
,
transform
);
repositionSvgItem
(
svgItem
,
rx
*
2
,
ry
*
2
,
cx
-
rx
,
cy
-
ry
,
hastransform
,
transform
);
hashSceneItem
(
element
,
svgItem
);
delete
generator
;
delete
generator
;
return
true
;
return
true
;
...
@@ -329,6 +327,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e
...
@@ -329,6 +327,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e
hastransform
=
true
;
hastransform
=
true
;
}
}
repositionSvgItem
(
svgItem
,
width
+
10
,
height
+
10
,
x1
-
5
,
y1
-
5
,
hastransform
,
transform
);
repositionSvgItem
(
svgItem
,
width
+
10
,
height
+
10
,
x1
-
5
,
y1
-
5
,
hastransform
,
transform
);
hashSceneItem
(
element
,
svgItem
);
delete
generator
;
delete
generator
;
return
true
;
return
true
;
...
@@ -394,11 +394,12 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
...
@@ -394,11 +394,12 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
hastransform
=
true
;
hastransform
=
true
;
}
}
repositionSvgItem
(
svgItem
,
width
+
10
,
height
+
10
,
x1
-
5
,
y1
-
5
,
hastransform
,
transform
);
repositionSvgItem
(
svgItem
,
width
+
10
,
height
+
10
,
x1
-
5
,
y1
-
5
,
hastransform
,
transform
);
hashSceneItem
(
element
,
svgItem
);
delete
generator
;
delete
generator
;
return
true
;
return
true
;
}
}
void
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseTextAttributes
(
const
QDomElement
&
element
,
void
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseTextAttributes
(
const
QDomElement
&
element
,
qreal
&
fontSize
,
QColor
&
fontColor
,
QString
&
fontFamily
,
qreal
&
fontSize
,
QColor
&
fontColor
,
QString
&
fontFamily
,
QString
&
fontStretch
,
bool
&
italic
,
int
&
fontWeight
,
QString
&
fontStretch
,
bool
&
italic
,
int
&
fontWeight
,
...
@@ -439,7 +440,6 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTextAttributes(const QDomElemen
...
@@ -439,7 +440,6 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTextAttributes(const QDomElemen
if
(
!
element
.
attribute
(
aTransform
).
isNull
())
if
(
!
element
.
attribute
(
aTransform
).
isNull
())
fontTransform
=
transformFromString
(
element
.
attribute
(
aTransform
));
fontTransform
=
transformFromString
(
element
.
attribute
(
aTransform
));
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgText
(
const
QDomElement
&
element
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgText
(
const
QDomElement
&
element
)
{
{
qreal
x
=
element
.
attribute
(
aX
).
toDouble
();
qreal
x
=
element
.
attribute
(
aX
).
toDouble
();
...
@@ -447,6 +447,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgText(const QDomElement &elem
...
@@ -447,6 +447,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgText(const QDomElement &elem
qreal
width
=
element
.
attribute
(
aWidth
).
toDouble
();
qreal
width
=
element
.
attribute
(
aWidth
).
toDouble
();
qreal
height
=
element
.
attribute
(
aHeight
).
toDouble
();
qreal
height
=
element
.
attribute
(
aHeight
).
toDouble
();
qreal
fontSize
=
12
;
qreal
fontSize
=
12
;
QColor
fontColor
(
qApp
->
palette
().
foreground
().
color
());
QColor
fontColor
(
qApp
->
palette
().
foreground
().
color
());
QString
fontFamily
=
"Arial"
;
QString
fontFamily
=
"Arial"
;
...
@@ -457,10 +458,14 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgText(const QDomElement &elem
...
@@ -457,10 +458,14 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgText(const QDomElement &elem
QTransform
fontTransform
;
QTransform
fontTransform
;
parseTextAttributes
(
element
,
fontSize
,
fontColor
,
fontFamily
,
fontStretch
,
italic
,
fontWeight
,
textAlign
,
fontTransform
);
parseTextAttributes
(
element
,
fontSize
,
fontColor
,
fontFamily
,
fontStretch
,
italic
,
fontWeight
,
textAlign
,
fontTransform
);
QFont
startFont
(
fontFamily
,
fontSize
,
fontWeight
,
italic
);
height
=
QFontMetrics
(
startFont
).
height
();
width
=
QFontMetrics
(
startFont
).
width
(
element
.
text
())
+
5
;
QSvgGenerator
*
generator
=
createSvgGenerator
(
width
,
height
);
QSvgGenerator
*
generator
=
createSvgGenerator
(
width
,
height
);
QPainter
painter
;
QPainter
painter
;
painter
.
begin
(
generator
);
painter
.
begin
(
generator
);
painter
.
setFont
(
QFont
(
fontFamily
,
fontSize
,
fontWeight
,
italic
)
);
painter
.
setFont
(
startFont
);
qreal
curY
=
0.0
;
qreal
curY
=
0.0
;
qreal
curX
=
0.0
;
qreal
curX
=
0.0
;
...
@@ -483,7 +488,9 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgText(const QDomElement &elem
...
@@ -483,7 +488,9 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgText(const QDomElement &elem
//add resulting svg file to scene
//add resulting svg file to scene
UBGraphicsSvgItem
*
svgItem
=
mCurrentScene
->
addSvg
(
QUrl
::
fromLocalFile
(
generator
->
fileName
()));
UBGraphicsSvgItem
*
svgItem
=
mCurrentScene
->
addSvg
(
QUrl
::
fromLocalFile
(
generator
->
fileName
()));
repositionSvgItem
(
svgItem
,
width
,
height
,
x
,
y
,
hasTransform
,
transform
);
repositionSvgItem
(
svgItem
,
width
,
height
,
x
,
y
,
hasTransform
,
transform
);
hashSceneItem
(
element
,
svgItem
);
delete
generator
;
delete
generator
;
return
true
;
return
true
;
...
@@ -513,6 +520,7 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTSpan(const QDomElement &parent
...
@@ -513,6 +520,7 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::parseTSpan(const QDomElement &parent
QDomCharacterData
textData
=
curNode
.
toCharacterData
();
QDomCharacterData
textData
=
curNode
.
toCharacterData
();
QString
text
=
textData
.
data
().
trimmed
();
QString
text
=
textData
.
data
().
trimmed
();
// width = painter.fontMetrics().width(text);
//get bounding rect to obtain desired text height
//get bounding rect to obtain desired text height
lastDrawnTextBoundingRect
=
painter
.
boundingRect
(
QRectF
(
curX
,
curY
,
width
,
height
-
curY
),
textAlign
|
Qt
::
TextWordWrap
,
text
);
lastDrawnTextBoundingRect
=
painter
.
boundingRect
(
QRectF
(
curX
,
curY
,
width
,
height
-
curY
),
textAlign
|
Qt
::
TextWordWrap
,
text
);
painter
.
drawText
(
curX
,
curY
,
width
,
lastDrawnTextBoundingRect
.
height
(),
textAlign
|
Qt
::
TextWordWrap
,
text
);
painter
.
drawText
(
curX
,
curY
,
width
,
lastDrawnTextBoundingRect
.
height
(),
textAlign
|
Qt
::
TextWordWrap
,
text
);
...
@@ -548,6 +556,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgTextarea(const QDomElement &
...
@@ -548,6 +556,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgTextarea(const QDomElement &
QSvgGenerator
*
generator
=
createSvgGenerator
(
width
,
height
);
QSvgGenerator
*
generator
=
createSvgGenerator
(
width
,
height
);
QPainter
painter
;
QPainter
painter
;
painter
.
begin
(
generator
);
painter
.
begin
(
generator
);
painter
.
setFont
(
QFont
(
fontFamily
,
fontSize
,
fontWeight
,
italic
));
painter
.
setFont
(
QFont
(
fontFamily
,
fontSize
,
fontWeight
,
italic
));
qreal
curY
=
0.0
;
qreal
curY
=
0.0
;
...
@@ -571,7 +580,9 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgTextarea(const QDomElement &
...
@@ -571,7 +580,9 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgTextarea(const QDomElement &
//add resulting svg file to scene
//add resulting svg file to scene
UBGraphicsSvgItem
*
svgItem
=
mCurrentScene
->
addSvg
(
QUrl
::
fromLocalFile
(
generator
->
fileName
()));
UBGraphicsSvgItem
*
svgItem
=
mCurrentScene
->
addSvg
(
QUrl
::
fromLocalFile
(
generator
->
fileName
()));
repositionSvgItem
(
svgItem
,
width
,
height
,
x
,
y
,
hasTransform
,
transform
);
repositionSvgItem
(
svgItem
,
width
,
height
,
x
,
y
,
hasTransform
,
transform
);
hashSceneItem
(
element
,
svgItem
);
delete
generator
;
delete
generator
;
return
true
;
return
true
;
...
@@ -609,7 +620,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgImage(const QDomElement &ele
...
@@ -609,7 +620,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgImage(const QDomElement &ele
hastransform
=
true
;
hastransform
=
true
;
}
}
repositionSvgItem
(
pixItem
,
width
,
height
,
x
,
y
,
hastransform
,
transform
);
repositionSvgItem
(
pixItem
,
width
,
height
,
x
,
y
,
hastransform
,
transform
);
// experimentalReposition(pixItem, width, height, x, y, hastransform, transform);
hashSceneItem
(
element
,
pixItem
);
hashSceneItem
(
element
,
pixItem
);
return
true
;
return
true
;
...
@@ -739,12 +749,6 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::hashSceneItem(const QDomElement &ele
...
@@ -739,12 +749,6 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::hashSceneItem(const QDomElement &ele
QString
key
=
element
.
attribute
(
aId
);
QString
key
=
element
.
attribute
(
aId
);
if
(
!
key
.
isNull
())
{
if
(
!
key
.
isNull
())
{
persistedItems
.
insert
(
key
,
item
);
persistedItems
.
insert
(
key
,
item
);
QHash
<
QString
,
UBGraphicsItem
*>::
iterator
iter
;
iter
=
persistedItems
.
find
(
key
);
UBGraphicsItem
*
itered
=
*
iter
;
if
(
key
==
"background"
)
itered
->
Delegate
()
->
lock
(
true
);
}
}
}
}
...
@@ -780,7 +784,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPage(const QDomElement &pare
...
@@ -780,7 +784,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPage(const QDomElement &pare
currentSvgElement
=
currentSvgElement
.
nextSiblingElement
();
currentSvgElement
=
currentSvgElement
.
nextSiblingElement
();
}
}
persistCurrentScene
();
return
true
;
return
true
;
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgPageset
(
const
QDomElement
&
parent
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseSvgPageset
(
const
QDomElement
&
parent
)
...
@@ -824,6 +828,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvg(const QDomElement &svgSecti
...
@@ -824,6 +828,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvg(const QDomElement &svgSecti
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseIwbGroup
(
QDomElement
&
parent
)
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
parseIwbGroup
(
QDomElement
&
parent
)
{
{
//TODO. Create groups from elements parsed by parseIwbElement() function
if
(
parent
.
namespaceURI
()
!=
iwbNS
)
{
if
(
parent
.
namespaceURI
()
!=
iwbNS
)
{
qDebug
()
<<
"incorrect iwb group namespace, incorrect document"
;
qDebug
()
<<
"incorrect iwb group namespace, incorrect document"
;
return
false
;
return
false
;
...
@@ -852,16 +857,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbElement(QDomElement &element
...
@@ -852,16 +857,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbElement(QDomElement &element
QHash
<
QString
,
UBGraphicsItem
*>::
iterator
iReferedItem
;
QHash
<
QString
,
UBGraphicsItem
*>::
iterator
iReferedItem
;
iReferedItem
=
persistedItems
.
find
(
IDRef
);
iReferedItem
=
persistedItems
.
find
(
IDRef
);
if
(
iReferedItem
!=
persistedItems
.
end
()
&&
IDRef
==
"background"
)
{
if
(
iReferedItem
!=
persistedItems
.
end
())
{
UBGraphicsItem
*
referedItem
=
*
iReferedItem
;
UBGraphicsItem
*
referedItem
=
*
iReferedItem
;
// UBGraphicsPixmapItem *item = dynamic_cast<UBGraphicsPixmapItem*>(referedItem);
referedItem
->
Delegate
()
->
lock
(
locked
);
referedItem
->
Delegate
()
->
lock
(
false
);
referedItem
->
Delegate
()
->
printMessage
(
"called from extended"
);
}
}
// UBGraphicsItem *referedItem = *(persistedItems.find(IDRef));
// referedItem->Delegate()->lock(locked);
}
}
return
true
;
return
true
;
...
@@ -878,6 +877,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseDoc()
...
@@ -878,6 +877,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseDoc()
currentTopElement
=
currentTopElement
.
nextSiblingElement
();
currentTopElement
=
currentTopElement
.
nextSiblingElement
();
}
}
if
(
!
persistScenes
())
return
false
;
return
true
;
return
true
;
}
}
...
@@ -910,212 +911,6 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::repositionSvgItem(QGraphicsItem *ite
...
@@ -910,212 +911,6 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::repositionSvgItem(QGraphicsItem *ite
(
int
)((
y
-
mViewBoxCenter
.
y
())
*
mVBTransFactor
));
(
int
)((
y
-
mViewBoxCenter
.
y
())
*
mVBTransFactor
));
}
}
}
}
void
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
experimentalReposition
(
QGraphicsItem
*
item
,
qreal
width
,
qreal
height
,
qreal
x
,
qreal
y
,
bool
useTransform
,
QTransform
&
transform
)
{
Q_UNUSED
(
useTransform
)
Q_UNUSED
(
transform
)
QRectF
itemBounds
=
item
->
boundingRect
();
qreal
xScale
=
width
/
itemBounds
.
width
();
qreal
yScale
=
height
/
itemBounds
.
height
();
qreal
newX
=
(
x
-
mViewBox
.
center
().
x
())
*
xScale
*
mVBTransFactor
;
qreal
newY
=
(
y
-
mViewBox
.
center
().
y
())
*
yScale
*
mVBTransFactor
;
// qDebug() << item->transform();
// QTransform transform1(1, 0, 0, 1, mCurrentSceneRect.center().x(), mCurrentSceneRect.center().y());
// QPointF newPos = QTransform(xScale * mVBTransFactor, 0, 0, yScale * mVBTransFactor,
// mCurrentSceneRect.center().x(), mCurrentSceneRect.center().y()).map(QPointF(x, y));
QPointF
newPos
(
newX
,
newY
);
item
->
setTransform
(
QTransform
(
xScale
*
mVBTransFactor
,
0
,
0
,
yScale
*
mVBTransFactor
,
0
,
0
));
item
->
setPos
(
newPos
);
item
->
setPos
(
newPos
);
qDebug
();
// QTransform transform;
// QTransform newTransform(mVBTransFactor, 0, 0,
// mVBTransFactor, mViewPort.center().x(), mViewPort.center().y());
// QRectF newItemRect = newTransform.mapRect(itemRect);
// item->setPos(newItemRect.topLeft());
// item->setBou
// QTransform translateTransform(width * mVBTransFactor, 0, 0, height * mVBTransFactor,
// mViewPort.center().x(), mViewPort.center().y());
// item->setTransform(translateTransform);
}
//bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseText()
//{
// if (currentState != SVG && currentState != PAGE)
// {
// qWarning() << "iwb content parse error, unexpected textarea tag at line" << mReader.lineNumber();
// return false;
// }
// //create new scene if it's not created yet (for one page document case)
// if (currentState == SVG && mCurrentScene == NULL)
// createNewScene();
// qreal x = mReader.attributes().value(aX).toString().toDouble();
// qreal y = mReader.attributes().value(aY).toString().toDouble();
// qreal width = 0;
// qreal height = 0;
// QList<QRectF> textRects;
// QList<QFont> textFonts;
// QList<QString> textLines;
// QList<int> textAligns;
// QList<QColor> textColors;
// qWarning() << QString().sprintf("Text coordinates : %f,%f. Text size %f,%f", x, y, width, height);
// qreal fontSize = 12.0;
// QFont textFont;
// QColor fontColor;
// QString fontFamily = "Arial";
// QString fontStretch = "normal";
// bool italic = false;
// int fontWeight = QFont::Normal;
// int textAlign = Qt::AlignLeft;
// QTransform fontTransform;
// parseTextAttributes(fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
// textFont = QFont(fontFamily, fontSize, fontWeight, italic);
// QFontMetricsF metrics = QFontMetricsF(textFont);
// qreal curHeight = metrics.height();
// qreal curY = 0.0;
// qreal curX = 0.0;
// qreal linespacing = QFontMetrics(textFont).leading();
// //remember if text area has transform
// QTransform transform;
// bool hasTransform = getCurElementTransorm(transform);
// QRectF lastDrawnTextBoundingRect;
// QStack<QFont> fontStack;
// QStack<QColor> colorStack;
// QStack<int> alignStack;
// // first extimate desired text area size
// // to do that, parse text area tags
// while(true)
// {
// mReader.readNext();
// QStringRef elementName = mReader.name();
// if (mReader.isEndDocument())
// break;
// if (mReader.isEndElement())
// {
// if (elementName == tBreak)
// {
// //when tbreak appers, move down by the drawn rect height
// //TODO: line spacing is not calculated yet, probably additional code is required
// curY += lastDrawnTextBoundingRect.height() + linespacing;
// curX = 0.0;
// height += lastDrawnTextBoundingRect.height();
// lastDrawnTextBoundingRect = QRectF(0,0,0,0);
// continue;
// }
// if (elementName == tTspan)
// {
// textFont = fontStack.pop();
// fontColor = colorStack.pop();
// textAlign = alignStack.pop();
// continue;
// }
// }
// if (mReader.isEndElement() && elementName == tText)
// break;
// if (mReader.isStartElement() && elementName == tTspan)
// {
// fontStack.push(textFont);
// colorStack.push(fontColor);
// alignStack.push(textAlign);
// parseTextAttributes(fontSize, fontColor, fontFamily, fontStretch, italic, fontWeight, textAlign, fontTransform);
// textFont = QFont(fontFamily, fontSize, fontWeight, italic);
// metrics = QFontMetricsF(textFont);
// curHeight = metrics.height();
// linespacing = QFontMetricsF(textFont).leading();
// continue;
// }
// if (mReader.isCharacters() || mReader.isCDATA())
// {
// QString text = mReader.text().toString();
// //skip empty text
// if (text.trimmed().length() == 0)
// continue;
// //get bounding rect to obtain desired text height
// lastDrawnTextBoundingRect = metrics.boundingRect(QRectF(), textAlign, text);
// QString log = QString().sprintf(" at rect %f, %f, %f, %f. Bounding rect is %f, %f, %f, %f", 0.0, curY, width, height - curY, lastDrawnTextBoundingRect.x(), lastDrawnTextBoundingRect.y(), lastDrawnTextBoundingRect.width(), lastDrawnTextBoundingRect.height());
// qWarning() << "Text " << text << log;
// textFonts.append(textFont);
// textRects.append(QRectF(curX, curY, lastDrawnTextBoundingRect.width(), lastDrawnTextBoundingRect.height()));
// textLines.append(text);
// textAligns.append(textAlign);
// textColors.append(fontColor);
// curX += lastDrawnTextBoundingRect.width();
// if (width < curX)
// width = curX;
// if (height == 0)
// height = curHeight;
// continue;
// }
// }
// QSvgGenerator *generator = createSvgGenerator(width, height);
// QPainter painter;
// painter.begin(generator);
// if (textRects.count() != 0)
// {
// QListIterator<QRectF> textRectsIter(textRects);
// QListIterator<QFont> textFontsIter(textFonts);
// QListIterator<QString> textLinesIter(textLines);
// QListIterator<int> textAlignsIter(textAligns);
// QListIterator<QColor> textColorsIter(textColors);
// while (textRectsIter.hasNext())
// {
// QRectF rt = textRectsIter.next();
// QFont font = textFontsIter.next();
// QString line = textLinesIter.next();
// int align = textAlignsIter.next();
// QColor color = textColorsIter.next();
// painter.setFont(font);
// painter.setPen(color);
// painter.drawText(rt.x(), rt.y(), rt.width(), rt.height(), align, line);
// }
// }
// painter.end();
// //add resulting svg file to scene
// UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
// repositionSvgItem(svgItem, width, height, x, y, hasTransform, transform);
// delete generator;
// return true;
//}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
createNewScene
()
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
createNewScene
()
{
{
...
@@ -1138,6 +933,30 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistCurrentScene()
...
@@ -1138,6 +933,30 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistCurrentScene()
}
}
return
true
;
return
true
;
}
}
bool
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
persistScenes
()
{
if
(
!
mProxy
->
pageCount
())
{
qDebug
()
<<
"No pages created"
;
return
false
;
}
for
(
int
i
=
0
;
i
<
mProxy
->
pageCount
();
i
++
)
{
mCurrentScene
=
UBPersistenceManager
::
persistenceManager
()
->
getDocumentScene
(
mProxy
,
i
);
if
(
!
mCurrentScene
)
{
qDebug
()
<<
"can't allocate scene, loading failed"
;
return
false
;
}
UBSvgSubsetAdaptor
::
persistScene
(
mProxy
,
mCurrentScene
,
i
);
UBGraphicsScene
*
tmpScene
=
UBSvgSubsetAdaptor
::
loadScene
(
mProxy
,
i
);
tmpScene
->
setModified
(
true
);
UBThumbnailAdaptor
::
persistScene
(
mProxy
->
persistencePath
(),
tmpScene
,
i
);
delete
tmpScene
;
mCurrentScene
->
setModified
(
false
);
}
return
true
;
}
QColor
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
colorFromString
(
const
QString
&
clrString
)
QColor
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::
colorFromString
(
const
QString
&
clrString
)
{
{
...
@@ -1277,3 +1096,11 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::createTempFlashPath()
...
@@ -1277,3 +1096,11 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::createTempFlashPath()
return
true
;
return
true
;
}
}
UBCFFSubsetAdaptor
::
UBCFFSubsetReader
::~
UBCFFSubsetReader
()
{
// QList<int> pages;
// for (int i = 0; i < mProxy->pageCount(); i++) {
// pages << i;
// }
// UBPersistenceManager::persistenceManager()->deleteDocumentScenes(mProxy, pages);
}
src/adaptors/UBCFFSubsetAdaptor.h
View file @
d387f5d0
...
@@ -38,7 +38,6 @@ class UBCFFSubsetAdaptor
...
@@ -38,7 +38,6 @@ class UBCFFSubsetAdaptor
{
{
public
:
public
:
UBCFFSubsetAdaptor
();
UBCFFSubsetAdaptor
();
static
bool
ConvertCFFFileToUbz
(
QString
&
cffSourceFile
,
UBDocumentProxy
*
pDocument
);
static
bool
ConvertCFFFileToUbz
(
QString
&
cffSourceFile
,
UBDocumentProxy
*
pDocument
);
private
:
private
:
...
@@ -46,6 +45,7 @@ private:
...
@@ -46,6 +45,7 @@ private:
{
{
public
:
public
:
UBCFFSubsetReader
(
UBDocumentProxy
*
proxy
,
QFile
*
content
);
UBCFFSubsetReader
(
UBDocumentProxy
*
proxy
,
QFile
*
content
);
~
UBCFFSubsetReader
();
UBDocumentProxy
*
mProxy
;
UBDocumentProxy
*
mProxy
;
QString
pwdContent
;
QString
pwdContent
;
...
@@ -101,7 +101,7 @@ private:
...
@@ -101,7 +101,7 @@ private:
inline
void
hashSceneItem
(
const
QDomElement
&
element
,
UBGraphicsItem
*
item
);
inline
void
hashSceneItem
(
const
QDomElement
&
element
,
UBGraphicsItem
*
item
);
// to kill
// to kill
void
parseTextAttributes
(
const
QDomElement
&
element
,
qreal
&
fontSize
,
QColor
&
fontColor
,
inline
void
parseTextAttributes
(
const
QDomElement
&
element
,
qreal
&
fontSize
,
QColor
&
fontColor
,
QString
&
fontFamily
,
QString
&
fontStretch
,
bool
&
italic
,
QString
&
fontFamily
,
QString
&
fontStretch
,
bool
&
italic
,
int
&
fontWeight
,
int
&
textAlign
,
QTransform
&
fontTransform
);
int
&
fontWeight
,
int
&
textAlign
,
QTransform
&
fontTransform
);
...
@@ -110,14 +110,12 @@ private:
...
@@ -110,14 +110,12 @@ private:
bool
createNewScene
();
bool
createNewScene
();
bool
persistCurrentScene
();
bool
persistCurrentScene
();
bool
persistScenes
();
// helper methods
// helper methods
void
repositionSvgItem
(
QGraphicsItem
*
item
,
qreal
width
,
qreal
height
,
void
repositionSvgItem
(
QGraphicsItem
*
item
,
qreal
width
,
qreal
height
,
qreal
x
,
qreal
y
,
qreal
x
,
qreal
y
,
bool
useTransform
,
QTransform
&
transform
);
bool
useTransform
,
QTransform
&
transform
);
void
experimentalReposition
(
QGraphicsItem
*
item
,
qreal
width
,
qreal
height
,
qreal
x
,
qreal
y
,
bool
useTransform
,
QTransform
&
transform
);
QColor
colorFromString
(
const
QString
&
clrString
);
QColor
colorFromString
(
const
QString
&
clrString
);
QTransform
transformFromString
(
const
QString
trString
);
QTransform
transformFromString
(
const
QString
trString
);
bool
getViewBoxDimenstions
(
const
QString
&
viewBox
);
bool
getViewBoxDimenstions
(
const
QString
&
viewBox
);
...
...
src/adaptors/UBThumbnailAdaptor.cpp
View file @
d387f5d0
...
@@ -111,7 +111,6 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
...
@@ -111,7 +111,6 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
moreToProcess
=
false
;
moreToProcess
=
false
;
}
}
}
}
return
thumbnails
;
return
thumbnails
;
}
}
...
...
src/core/UBPersistenceManager.h
View file @
d387f5d0
...
@@ -86,6 +86,7 @@ class UBPersistenceManager : public QObject
...
@@ -86,6 +86,7 @@ class UBPersistenceManager : public QObject
virtual
void
moveSceneToIndex
(
UBDocumentProxy
*
pDocumentProxy
,
int
source
,
int
target
);
virtual
void
moveSceneToIndex
(
UBDocumentProxy
*
pDocumentProxy
,
int
source
,
int
target
);
virtual
UBGraphicsScene
*
loadDocumentScene
(
UBDocumentProxy
*
pDocumentProxy
,
int
sceneIndex
);
virtual
UBGraphicsScene
*
loadDocumentScene
(
UBDocumentProxy
*
pDocumentProxy
,
int
sceneIndex
);
UBGraphicsScene
*
getDocumentScene
(
UBDocumentProxy
*
pDocumentProxy
,
int
sceneIndex
)
{
return
mSceneCache
.
value
(
pDocumentProxy
,
sceneIndex
);}
QList
<
QPointer
<
UBDocumentProxy
>
>
documentProxies
;
QList
<
QPointer
<
UBDocumentProxy
>
>
documentProxies
;
...
...
src/domain/UBGraphicsPixmapItem.h
View file @
d387f5d0
...
@@ -26,7 +26,7 @@ class UBGraphicsItemDelegate;
...
@@ -26,7 +26,7 @@ class UBGraphicsItemDelegate;
class
UBGraphicsPixmapItem
:
public
QObject
,
public
QGraphicsPixmapItem
,
public
UBItem
,
public
UBGraphicsItem
class
UBGraphicsPixmapItem
:
public
QObject
,
public
QGraphicsPixmapItem
,
public
UBItem
,
public
UBGraphicsItem
{
{
Q_OBJECT
;
Q_OBJECT
public
:
public
:
UBGraphicsPixmapItem
(
QGraphicsItem
*
parent
=
0
);
UBGraphicsPixmapItem
(
QGraphicsItem
*
parent
=
0
);
...
@@ -38,7 +38,6 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
...
@@ -38,7 +38,6 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
{
{
return
Type
;
return
Type
;
}
}
virtual
UBItem
*
deepCopy
()
const
;
virtual
UBItem
*
deepCopy
()
const
;
virtual
UBGraphicsScene
*
scene
();
virtual
UBGraphicsScene
*
scene
();
...
...
src/domain/UBGraphicsScene.h
View file @
d387f5d0
...
@@ -52,7 +52,7 @@ const double PI = 4.0 * atan(1.0);
...
@@ -52,7 +52,7 @@ const double PI = 4.0 * atan(1.0);
class
UBGraphicsScene
:
public
UBCoreGraphicsScene
,
public
UBItem
class
UBGraphicsScene
:
public
UBCoreGraphicsScene
,
public
UBItem
{
{
Q_OBJECT
;
Q_OBJECT
public
:
public
:
...
...
src/domain/UBGraphicsTextItem.h
View file @
d387f5d0
...
@@ -26,7 +26,7 @@ class UBGraphicsScene;
...
@@ -26,7 +26,7 @@ class UBGraphicsScene;
class
UBGraphicsTextItem
:
public
QGraphicsTextItem
,
public
UBItem
,
public
UBResizableGraphicsItem
,
public
UBGraphicsItem
class
UBGraphicsTextItem
:
public
QGraphicsTextItem
,
public
UBItem
,
public
UBResizableGraphicsItem
,
public
UBGraphicsItem
{
{
Q_OBJECT
;
Q_OBJECT
public
:
public
:
UBGraphicsTextItem
(
QGraphicsItem
*
parent
=
0
);
UBGraphicsTextItem
(
QGraphicsItem
*
parent
=
0
);
...
@@ -97,7 +97,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
...
@@ -97,7 +97,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
virtual
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
);
virtual
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
);
private
:
private
:
// UBGraphicsItemDelegate *mDelegate;
qreal
mTextHeight
;
qreal
mTextHeight
;
int
mMultiClickState
;
int
mMultiClickState
;
...
@@ -106,8 +105,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
...
@@ -106,8 +105,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
QColor
mColorOnDarkBackground
;
QColor
mColorOnDarkBackground
;
QColor
mColorOnLightBackground
;
QColor
mColorOnLightBackground
;
};
};
#endif
/* UBGRAPHICSTEXTITEM_H_ */
#endif
/* UBGRAPHICSTEXTITEM_H_ */
src/pdf/PDFRenderer.cpp
View file @
d387f5d0
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
#include "XPDFRenderer.h"
#include "XPDFRenderer.h"
#include "core/memcheck.h"
#include "core/memcheck.h"
QMap
<
QUuid
,
QPointer
<
PDFRenderer
>
>
PDFRenderer
::
sRenderers
;
QMap
<
QUuid
,
QPointer
<
PDFRenderer
>
>
PDFRenderer
::
sRenderers
;
...
...
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