Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Tusooa Zhu
Krita
Commits
647f7332
Commit
647f7332
authored
Apr 01, 2007
by
Thomas Zander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a static method on KoParagraphStyle to create a style from a QTextBlockFormat
svn path=/trunk/koffice/; revision=648993
parent
b1078694
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
63 deletions
+88
-63
libs/kotext/styles/KoParagraphStyle.cpp
libs/kotext/styles/KoParagraphStyle.cpp
+83
-62
libs/kotext/styles/KoParagraphStyle.h
libs/kotext/styles/KoParagraphStyle.h
+5
-0
libs/kotext/styles/KoStyleManager.cpp
libs/kotext/styles/KoStyleManager.cpp
+0
-1
No files found.
libs/kotext/styles/KoParagraphStyle.cpp
View file @
647f7332
...
...
@@ -30,6 +30,70 @@
#include <KoStyleStack.h>
#include <KoXmlNS.h>
// all relevant properties.
static
const
int
properties
[]
=
{
QTextFormat
::
BlockTopMargin
,
QTextFormat
::
BlockBottomMargin
,
QTextFormat
::
BlockLeftMargin
,
QTextFormat
::
BlockRightMargin
,
QTextFormat
::
BlockAlignment
,
QTextFormat
::
TextIndent
,
QTextFormat
::
BlockIndent
,
QTextFormat
::
BlockNonBreakableLines
,
KoParagraphStyle
::
StyleId
,
KoParagraphStyle
::
FixedLineHeight
,
KoParagraphStyle
::
MinimumLineHeight
,
KoParagraphStyle
::
LineSpacing
,
KoParagraphStyle
::
LineSpacingFromFont
,
// KoParagraphStyle::AlignLastLine,
// KoParagraphStyle::WidowThreshold,
// KoParagraphStyle::OrphanThreshold,
// KoParagraphStyle::DropCaps,
// KoParagraphStyle::DropCapsLength,
// KoParagraphStyle::DropCapsLines,
// KoParagraphStyle::DropCapsDistance,
// KoParagraphStyle::FollowDocBaseline,
KoParagraphStyle
::
BreakBefore
,
KoParagraphStyle
::
BreakAfter
,
// KoParagraphStyle::HasLeftBorder,
// KoParagraphStyle::HasTopBorder,
// KoParagraphStyle::HasRightBorder,
// KoParagraphStyle::HasBottomBorder,
// KoParagraphStyle::BorderLineWidth,
// KoParagraphStyle::SecondBorderLineWidth,
// KoParagraphStyle::DistanceToSecondBorder,
KoParagraphStyle
::
LeftPadding
,
KoParagraphStyle
::
TopPadding
,
KoParagraphStyle
::
RightPadding
,
KoParagraphStyle
::
BottomPadding
,
KoParagraphStyle
::
LeftBorderWidth
,
KoParagraphStyle
::
LeftInnerBorderWidth
,
KoParagraphStyle
::
LeftBorderSpacing
,
KoParagraphStyle
::
LeftBorderStyle
,
KoParagraphStyle
::
TopBorderWidth
,
KoParagraphStyle
::
TopInnerBorderWidth
,
KoParagraphStyle
::
TopBorderSpacing
,
KoParagraphStyle
::
TopBorderStyle
,
KoParagraphStyle
::
RightBorderWidth
,
KoParagraphStyle
::
RightInnerBorderWidth
,
KoParagraphStyle
::
RightBorderSpacing
,
KoParagraphStyle
::
RightBorderStyle
,
KoParagraphStyle
::
BottomBorderWidth
,
KoParagraphStyle
::
BottomInnerBorderWidth
,
KoParagraphStyle
::
BottomBorderSpacing
,
KoParagraphStyle
::
BottomBorderStyle
,
KoParagraphStyle
::
LeftBorderColor
,
KoParagraphStyle
::
TopBorderColor
,
KoParagraphStyle
::
RightBorderColor
,
KoParagraphStyle
::
BottomBorderColor
,
KoParagraphStyle
::
ExplicitListValue
,
KoParagraphStyle
::
RestartListNumbering
,
-
1
};
KoParagraphStyle
::
KoParagraphStyle
()
:
m_charStyle
(
new
KoCharacterStyle
(
this
)),
m_listStyle
(
0
),
...
...
@@ -131,68 +195,6 @@ QColor KoParagraphStyle::propertyColor(int key) const {
}
void
KoParagraphStyle
::
applyStyle
(
QTextBlockFormat
&
format
)
const
{
// copy all relevant properties.
static
const
int
properties
[]
=
{
QTextFormat
::
BlockTopMargin
,
QTextFormat
::
BlockBottomMargin
,
QTextFormat
::
BlockLeftMargin
,
QTextFormat
::
BlockRightMargin
,
QTextFormat
::
BlockAlignment
,
QTextFormat
::
TextIndent
,
QTextFormat
::
BlockIndent
,
QTextFormat
::
BlockNonBreakableLines
,
StyleId
,
FixedLineHeight
,
MinimumLineHeight
,
LineSpacing
,
LineSpacingFromFont
,
// AlignLastLine,
// WidowThreshold,
// OrphanThreshold,
// DropCaps,
// DropCapsLength,
// DropCapsLines,
// DropCapsDistance,
// FollowDocBaseline,
BreakBefore
,
BreakAfter
,
// HasLeftBorder,
// HasTopBorder,
// HasRightBorder,
// HasBottomBorder,
// BorderLineWidth,
// SecondBorderLineWidth,
// DistanceToSecondBorder,
LeftPadding
,
TopPadding
,
RightPadding
,
BottomPadding
,
LeftBorderWidth
,
LeftInnerBorderWidth
,
LeftBorderSpacing
,
LeftBorderStyle
,
TopBorderWidth
,
TopInnerBorderWidth
,
TopBorderSpacing
,
TopBorderStyle
,
RightBorderWidth
,
RightInnerBorderWidth
,
RightBorderSpacing
,
RightBorderStyle
,
BottomBorderWidth
,
BottomInnerBorderWidth
,
BottomBorderSpacing
,
BottomBorderStyle
,
LeftBorderColor
,
TopBorderColor
,
RightBorderColor
,
BottomBorderColor
,
ExplicitListValue
,
RestartListNumbering
,
-
1
};
int
i
=
0
;
while
(
properties
[
i
]
!=
-
1
)
{
QVariant
const
*
variant
=
get
(
properties
[
i
]);
...
...
@@ -533,4 +535,23 @@ void KoParagraphStyle::loadOasis(KoStyleStack& styleStack) {
}
// static
KoParagraphStyle
*
KoParagraphStyle
::
fromBlockFormat
(
const
QTextBlockFormat
&
format
)
{
KoParagraphStyle
*
answer
=
new
KoParagraphStyle
();
delete
answer
->
characterStyle
();
// TODO instead replace it with a character style from a QTextCharFormat
answer
->
m_charStyle
=
0
;
int
i
=
0
;
while
(
properties
[
i
]
!=
-
1
)
{
int
key
=
properties
[
i
];
if
(
format
.
hasProperty
(
key
))
answer
->
setProperty
(
key
,
format
.
property
(
key
));
i
++
;
}
// listStyle ??
return
answer
;
}
#include "KoParagraphStyle.moc"
libs/kotext/styles/KoParagraphStyle.h
View file @
647f7332
...
...
@@ -349,10 +349,13 @@ public:
void
setTextIndent
(
double
margin
)
{
setProperty
(
QTextFormat
::
TextIndent
,
margin
);
}
/// duplicated property from QTextBlockFormat
double
textIndent
()
const
{
return
propertyDouble
(
QTextFormat
::
TextIndent
);
}
#if 0
as this is a duplicate of leftMargin, lets make it very clear we are using that one.
/// duplicated property from QTextBlockFormat
void setIndent (int indent) { setProperty(QTextFormat::BlockIndent, indent); }
/// duplicated property from QTextBlockFormat
int indent () const { return propertyInt(QTextFormat::BlockIndent); }
#endif
/// duplicated property from QTextBlockFormat
void
setNonBreakableLines
(
bool
on
)
{
setProperty
(
QTextFormat
::
BlockNonBreakableLines
,
on
);
}
/// duplicated property from QTextBlockFormat
...
...
@@ -435,6 +438,8 @@ public:
*/
void
loadOasis
(
KoStyleStack
&
styleStack
);
static
KoParagraphStyle
*
fromBlockFormat
(
const
QTextBlockFormat
&
format
);
private:
void
setProperty
(
int
key
,
const
QVariant
&
value
);
void
remove
(
int
key
);
...
...
libs/kotext/styles/KoStyleManager.cpp
View file @
647f7332
...
...
@@ -53,7 +53,6 @@ KoStyleManager::KoStyleManager(QObject *parent)
d
->
standard
->
setBottomMargin
(
0
);
d
->
standard
->
setRightMargin
(
0
);
d
->
standard
->
setTextIndent
(
0
);
d
->
standard
->
setIndent
(
0
);
d
->
standard
->
setAlignment
(
Qt
::
AlignLeft
);
d
->
standard
->
setName
(
i18n
(
"[No Paragraph Style]"
));
d
->
standard
->
characterStyle
()
->
setName
(
i18n
(
"[No Character Style]"
));
...
...
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