Commit 94a77582 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Merged revisions...

Merged revisions 1112881,1112927,1112977-1112982,1112989,1113002,1113005-1113008,1113045,1113049-1113050,1113218 via svnmerge from 
https://rempt@svn.kde.org/home/kde/trunk/koffice

........
  r1112881 | berger | 2010-04-09 14:17:17 +0200 (Fri, 09 Apr 2010) | 6 lines
  
  Make KoColor::setPixel takes a const pointer (and also reallocate memory
  only if necesserary)
  Make KisPaintDevice::pixel be const and use const iterator, this avoid
  the memento manager to start creating a new history point, and therefor
  fix the KisTransaction test
........
  r1112927 | lassin | 2010-04-09 15:59:00 +0200 (Fri, 09 Apr 2010) | 3 lines
  
  Fixes cases where paragraphs has both par and text properties in styles.xml
........
  r1112977 | zander | 2010-04-09 17:39:27 +0200 (Fri, 09 Apr 2010) | 1 line
  
  Remove redundant cast
........
  r1112978 | zander | 2010-04-09 17:39:29 +0200 (Fri, 09 Apr 2010) | 1 line
  
  Fix tab offset with parag that has indent.
........
  r1112979 | zander | 2010-04-09 17:39:31 +0200 (Fri, 09 Apr 2010) | 1 line
  
  Fix background color
........
  r1112980 | zander | 2010-04-09 17:39:33 +0200 (Fri, 09 Apr 2010) | 1 line
  
  Change default when XML does not specify it to noWrap
........
  r1112981 | zander | 2010-04-09 17:39:35 +0200 (Fri, 09 Apr 2010) | 3 lines
  
  Fix NaN creation on height or width zero.
  
  BUG:231846
........
  r1112982 | zander | 2010-04-09 17:39:37 +0200 (Fri, 09 Apr 2010) | 1 line
  
  Add some asserts
........
  r1112989 | lukast | 2010-04-09 18:09:16 +0200 (Fri, 09 Apr 2010) | 4 lines
  
  Revert "Fix the expected value in the test."
  
  Seems like magic stuff happens. Now it is 7 and the test passes. I'm not aware
  what might change.
........
  r1113002 | sebsauer | 2010-04-09 18:48:38 +0200 (Fri, 09 Apr 2010) | 2 lines
  
  Fix for the parser-issue discovered by Carlos. We cannot just keep the whitespaces even if removing them is wrong too cause compile() does lot of compression and token modifications which do not proper handle whitespaces. Seems what needs to be done is to change the meaning depending on the referenced content and we cannot do that on compile() but only on evalRecursive(). That in turn means that compile() needs to be extended to transparently ignore operators so we have them still available on evaluation to decide then what to do with them. For now let's go with the easiest solution and just ignore (as in remove) the intersect operator. Lot of thanks to Carlos :)
........
  r1113005 | berger | 2010-04-09 19:34:44 +0200 (Fri, 09 Apr 2010) | 4 lines
  
  better delete the node model before the image (since the node model is
  referencing the layers themselves)
........
  r1113006 | berger | 2010-04-09 19:36:32 +0200 (Fri, 09 Apr 2010) | 3 lines
  
  disable the projection, it is not what we are testing in the tests and
  it is causing random crashes in the tests
........
  r1113007 | berger | 2010-04-09 19:46:57 +0200 (Fri, 09 Apr 2010) | 2 lines
  
  since painterly framework is not installed, disable its test
........
  r1113008 | sebsauer | 2010-04-09 19:50:47 +0200 (Fri, 09 Apr 2010) | 3 lines
  
  Make POINT_TO_MM & co return qreal's
  http://reviewboard.kde.org/r/3526/
........
  r1113045 | berger | 2010-04-09 21:13:51 +0200 (Fri, 09 Apr 2010) | 7 lines
  
  Fix: change the color of the solid color generator result in a black
  generator
  
  Stop using legacyXML
  
  BUG:233796
........
  r1113049 | berger | 2010-04-09 21:27:33 +0200 (Fri, 09 Apr 2010) | 2 lines
  
  Remove last bit of toLegacyXML
........
  r1113050 | berger | 2010-04-09 21:29:57 +0200 (Fri, 09 Apr 2010) | 2 lines
  
  --warnings (int vs uint)
........
  r1113218 | cfeck | 2010-04-10 05:00:37 +0200 (Sat, 10 Apr 2010) | 6 lines
  
  SVN_SILENT compile after r1113049
  
  Please verify :)
  
  CCMAIL: cyb@lepi.org
........

svn path=/branches/work/koffice-ko/; revision=1113251
parent 8f563a68
......@@ -46,14 +46,14 @@ public:
public:
virtual void redo() {
if (m_config)
m_config->fromLegacyXML(m_after);
m_config->fromXML(m_after);
m_node->setFilter(m_config);
m_node->setDirty();
}
virtual void undo() {
if (m_config)
m_config->fromLegacyXML(m_before);
m_config->fromXML(m_before);
m_node->setFilter(m_config);
m_node->setDirty();
}
......
......@@ -45,13 +45,13 @@ public:
}
public:
virtual void redo() {
m_config->fromLegacyXML(m_after);
m_config->fromXML(m_after);
m_node->setGenerator(m_config);
m_node->setDirty();
}
virtual void undo() {
m_config->fromLegacyXML(m_before);
m_config->fromXML(m_before);
m_node->setGenerator(m_config);
m_node->setDirty();
}
......
......@@ -60,36 +60,9 @@ KisFilterConfiguration::~KisFilterConfiguration()
delete d;
}
void KisFilterConfiguration::toLegacyXML(QDomDocument& doc, QDomElement& root) const
{
root.setAttribute("name", d->name);
root.setAttribute("version", d->version);
QMap<QString, QVariant> properties = getProperties();
QMap<QString, QVariant>::Iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
QDomElement e = doc.createElement("property");
e.setAttribute("name", QString(it.key().toLatin1()));
QVariant v = it.value();
e.setAttribute("type", v.typeName());
QString s = v.toString();
QDomText text = doc.createCDATASection(v.toString()); // XXX: Unittest this!
e.appendChild(text);
root.appendChild(e);
}
}
QString KisFilterConfiguration::toLegacyXML() const
{
QDomDocument doc = QDomDocument("filterconfig");
QDomElement root = doc.createElement("filterconfig");
doc.appendChild(root);
toLegacyXML(doc, root);
return doc.toString();
}
void KisFilterConfiguration::fromLegacyXML(const QDomElement& e)
{
clearProperties();
d->name = e.attribute("name");
d->version = e.attribute("version").toInt();
......@@ -116,16 +89,6 @@ void KisFilterConfiguration::fromLegacyXML(const QDomElement& e)
}
}
void KisFilterConfiguration::fromLegacyXML(const QString & s)
{
clearProperties();
QDomDocument doc;
doc.setContent(s);
QDomElement e = doc.documentElement();
fromLegacyXML(e);
}
const QString & KisFilterConfiguration::name() const
{
return d->name;
......
......@@ -52,22 +52,10 @@ public:
public:
/**
* This function is use to convert from legacy XML as used in .kra file.
*/
virtual void fromLegacyXML(const QString &);
/**
* This function is use to convert from legacy XML as used in .kra file.
*/
virtual void fromLegacyXML(const QDomElement&);
/**
* This function is use to convert to legacy XML as used in .kra file.
*/
virtual QString toLegacyXML() const;
/**
* This function is use to convert to legacy XML as used in .kra file.
*/
virtual void toLegacyXML(QDomDocument&, QDomElement&) const;
/**
* Get the unique, language independent name of the filter.
......
......@@ -881,9 +881,9 @@ void KisPaintDevice::applySelectionMask(KisSelectionSP mask)
}
}
bool KisPaintDevice::pixel(qint32 x, qint32 y, QColor *c)
bool KisPaintDevice::pixel(qint32 x, qint32 y, QColor *c) const
{
KisHLineConstIteratorPixel iter = createHLineIterator(x, y, 1);
KisHLineConstIteratorPixel iter = createHLineConstIterator(x, y, 1);
const quint8 *pix = iter.rawData();
......@@ -895,11 +895,11 @@ bool KisPaintDevice::pixel(qint32 x, qint32 y, QColor *c)
}
bool KisPaintDevice::pixel(qint32 x, qint32 y, KoColor * kc)
bool KisPaintDevice::pixel(qint32 x, qint32 y, KoColor * kc) const
{
KisHLineIteratorPixel iter = createHLineIterator(x, y, 1);
KisHLineConstIteratorPixel iter = createHLineConstIterator(x, y, 1);
quint8 *pix = iter.rawData();
const quint8 *pix = iter.rawData();
if (!pix) return false;
......
......@@ -346,7 +346,7 @@ public:
*
* @return true if the operation was successful.
*/
bool pixel(qint32 x, qint32 y, QColor *c);
bool pixel(qint32 x, qint32 y, QColor *c) const;
/**
* Fill kc with the values found at x and y. This method differs
......@@ -357,7 +357,7 @@ public:
*
* @return true if the operation was successful.
*/
bool pixel(qint32 x, qint32 y, KoColor * kc);
bool pixel(qint32 x, qint32 y, KoColor * kc) const;
/**
* Set the specified pixel to the specified color. Note that this
......
......@@ -43,10 +43,10 @@ void KisFilterConfigurationTest::testRoundTrip()
KisFilterConfiguration * kfc = new KisFilterConfiguration("test", 1);
QCOMPARE(kfc->version(), 1);
QCOMPARE(kfc->name(), QString("test"));
QString s = kfc->toLegacyXML();
QString s = kfc->toXML();
delete kfc;
kfc = new KisFilterConfiguration("test2", 2);
kfc->fromLegacyXML(s);
kfc->fromXML(s);
QCOMPARE(kfc->version(), 1);
QCOMPARE(kfc->name(), QString("test"));
delete kfc;
......@@ -59,13 +59,13 @@ void KisFilterConfigurationTest::testSetGetProperty()
kfc->setProperty("value2", "foo");
QCOMPARE(kfc->getInt("value1"), 10);
QCOMPARE(kfc->getString("value2"), QString("foo"));
QString s = kfc->toLegacyXML();
QString s = kfc->toXML();
delete kfc;
kfc = new KisFilterConfiguration("test2", 2);
kfc->fromLegacyXML(s);
kfc->fromXML(s);
QCOMPARE(kfc->getInt("value1"), 10);
QCOMPARE(kfc->getString("value2"), QString("foo"));
delete kfc;
delete kfc;
}
......
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(illuminants)
add_subdirectory(tests)
#add_subdirectory(tests)
#################################################
# Painterly Common Libraries
......
......@@ -79,12 +79,12 @@ QVariantMap Filter::properties()
void Filter::fromXML(const QString& xml)
{
config()->fromLegacyXML(xml);
config()->fromXML(xml);
}
const QString Filter::toXML()
{
return config()->toLegacyXML();
return config()->toXML();
}
bool Filter::process(QObject* layer)
......
......@@ -107,11 +107,6 @@ void KisBrightnessContrastFilterConfiguration::setCurve(const KisCubicCurve &cur
*/
//void KisPerChannelFilterConfiguration::fromXML(const QString& s)
void KisBrightnessContrastFilterConfiguration::toLegacyXML(QDomDocument& doc, QDomElement& root) const
{
toXML(doc, root);
}
void KisBrightnessContrastFilterConfiguration::toXML(QDomDocument& doc, QDomElement& root) const
{
/**
......
......@@ -51,11 +51,9 @@ class KisBrightnessContrastFilterConfiguration : public KisFilterConfiguration
public:
using KisFilterConfiguration::fromXML;
using KisFilterConfiguration::toXML;
using KisFilterConfiguration::toLegacyXML;
using KisFilterConfiguration::fromLegacyXML;
virtual void fromLegacyXML(const QDomElement& root);
virtual void toLegacyXML(QDomDocument& doc, QDomElement& root) const;
virtual void fromXML(const QDomElement& e);
virtual void toXML(QDomDocument& doc, QDomElement& root) const;
......
......@@ -244,10 +244,10 @@ void KisPerChannelConfigWidget::setConfiguration(const KisPropertiesConfiguratio
KisPerChannelFilterConfiguration::initDefaultCurves(m_curves,
m_dev->colorSpace()->colorChannelCount());
} else if (cfg->m_curves.size() != m_dev->colorSpace()->colorChannelCount()) {
} else if (cfg->m_curves.size() != int(m_dev->colorSpace()->colorChannelCount())) {
return;
} else {
for (unsigned int ch = 0; ch < cfg->m_curves.size(); ch++)
for (int ch = 0; ch < cfg->m_curves.size(); ch++)
m_curves[ch] = cfg->m_curves[ch];
}
......@@ -333,11 +333,6 @@ void KisPerChannelFilterConfiguration::fromXML(const QDomElement& root)
*/
//void KisPerChannelFilterConfiguration::fromXML(const QString& s)
void KisPerChannelFilterConfiguration::toLegacyXML(QDomDocument& doc, QDomElement& root) const
{
toXML(doc, root);
}
void KisPerChannelFilterConfiguration::toXML(QDomDocument& doc, QDomElement& root) const
{
/**
......@@ -405,7 +400,7 @@ KoColorTransformation* KisPerChannelFilter::createTransformation(const KoColorSp
KisPerChannelFilterConfiguration* configBC =
const_cast<KisPerChannelFilterConfiguration*>(dynamic_cast<const KisPerChannelFilterConfiguration*>(config)); // Somehow, this shouldn't happen
Q_ASSERT(configBC);
if (configBC->m_curves.size() != cs->colorChannelCount()) {
if (configBC->m_curves.size() != int(cs->colorChannelCount())) {
// We got an illegal number of colorchannels.KisFilter
return 0;
}
......
......@@ -49,11 +49,9 @@ public:
using KisFilterConfiguration::fromXML;
using KisFilterConfiguration::toXML;
using KisFilterConfiguration::toLegacyXML;
using KisFilterConfiguration::fromLegacyXML;
virtual void fromLegacyXML(const QDomElement& root);
virtual void toLegacyXML(QDomDocument& doc, QDomElement& root) const;
virtual void fromXML(const QDomElement& e);
virtual void toXML(QDomDocument& doc, QDomElement& root) const;
......
......@@ -75,7 +75,7 @@ KisFilterConfiguration* KisFilterOpSettings::filterConfig() const
Q_ASSERT(filter);
if(filter) {
KisFilterConfiguration* configuration = filter->factoryConfiguration(0);
configuration->fromLegacyXML(getString(FILTER_CONFIGURATION));
configuration->fromXML(getString(FILTER_CONFIGURATION));
return configuration;
}
}
......@@ -104,7 +104,7 @@ void KisFilterOpSettings::fromXML(const QDomElement& e)
if(filter) {
KisFilterConfiguration* configuration = filter->factoryConfiguration(0);
configuration->fromXML(element);
setProperty(FILTER_CONFIGURATION, configuration->toLegacyXML());
setProperty(FILTER_CONFIGURATION, configuration->toXML());
delete configuration;
}
}
......
......@@ -125,7 +125,7 @@ void KisAutoBrushTest::testSizeRotation()
QCOMPARE(a->maskHeight(1.0,M_PI), 6);
QCOMPARE(a->maskWidth(1.0,M_PI_2), 6);
QCOMPARE(a->maskHeight(1.0,M_PI_2), 11);
QCOMPARE(a->maskWidth(1.0,-M_PI_2), 6);
QCOMPARE(a->maskWidth(1.0,-M_PI_2), 7);
QCOMPARE(a->maskHeight(1.0,-M_PI_2), 11);
QCOMPARE(a->maskWidth(1.0,0.25*M_PI), 12);
QCOMPARE(a->maskHeight(1.0,0.25*M_PI), 12);
......
......@@ -179,7 +179,7 @@ void KisFilterOption::writeOptionSetting(KisPropertiesConfiguration* setting) co
setting->setProperty(FILTER_ID, m_currentFilter->id());
setting->setProperty(FILTER_IGNORE_ALPHA, ignoreAlpha());
if(filterConfig()) {
setting->setProperty(FILTER_CONFIGURATION, filterConfig()->toLegacyXML());
setting->setProperty(FILTER_CONFIGURATION, filterConfig()->toXML());
}
}
......@@ -190,7 +190,7 @@ void KisFilterOption::readOptionSetting(const KisPropertiesConfiguration* settin
m_options->checkBoxIgnoreAlpha->setChecked(setting->getBool(FILTER_IGNORE_ALPHA));
KisFilterConfiguration* configuration = filterConfig();
if(configuration) {
configuration->fromLegacyXML(setting->getString(FILTER_CONFIGURATION));
configuration->fromXML(setting->getString(FILTER_CONFIGURATION));
m_currentFilterConfigWidget->setConfiguration(configuration);
}
}
......
......@@ -154,7 +154,11 @@ KisDoc2::KisDoc2(QWidget *parentWidget, QObject *parent, bool singleViewMode)
KisDoc2::~KisDoc2()
{
delete m_d->shapeController; // Despite being a QObject it needs to be deleted before the image
// Despite being QObject they needs to be deleted before the image
delete m_d->shapeController;
delete m_d->nodeModel;
// The following line trigger the deletion of the image
m_d->image.clear();
delete m_d;
......
......@@ -243,13 +243,13 @@ void KisLayerManager::layerProperties()
KisFilterConfiguration* config = dlg.filterConfiguration();
QString before;
if (config) {
before = config->toLegacyXML();
before = config->toXML();
}
if (dlg.exec() == QDialog::Accepted) {
QString after;
if (dlg.filterConfiguration()) {
after = dlg.filterConfiguration()->toLegacyXML();
after = dlg.filterConfiguration()->toXML();
}
if (after != before) {
alayer->setName(dlg.layerName());
......@@ -269,13 +269,13 @@ void KisLayerManager::layerProperties()
KisDlgGeneratorLayer dlg(alayer->name(), m_view);
dlg.setCaption(i18n("Generator Layer Properties"));
QString before = alayer->generator()->toLegacyXML();
QString before = alayer->generator()->toXML();
dlg.setConfiguration(alayer->generator());
dlg.resize(dlg.minimumSizeHint());
if (dlg.exec() == QDialog::Accepted) {
QString after = dlg.configuration()->toLegacyXML();
QString after = dlg.configuration()->toXML();
if (after != before) {
KisChangeGeneratorCmd<KisGeneratorLayerSP> * cmd
= new KisChangeGeneratorCmd<KisGeneratorLayerSP>(alayer,
......
......@@ -457,11 +457,11 @@ void KisMaskManager::maskProperties()
KisDlgAdjLayerProps dlg(dev, layer->image(), mask->filter(), mask->name(), i18n("Effect Mask Properties"), m_view, "dlgeffectmaskprops");
QString before;
if (dlg.filterConfiguration())
before = dlg.filterConfiguration()->toLegacyXML();
before = dlg.filterConfiguration()->toXML();
if (dlg.exec() == QDialog::Accepted) {
QString after;
if (dlg.filterConfiguration())
after = dlg.filterConfiguration()->toLegacyXML();
after = dlg.filterConfiguration()->toXML();
KisChangeFilterCmd<KisFilterMaskSP> * cmd = new KisChangeFilterCmd<KisFilterMaskSP>(mask,
dlg.filterConfiguration(),
before,
......
......@@ -308,7 +308,15 @@ bool KisKraLoadVisitor::loadFilterConfiguration(KisFilterConfiguration* kfc, con
data = m_store->read(m_store->size());
m_store->close();
if (!data.isEmpty()) {
kfc->fromLegacyXML(QString(data));
QString xml(data);
QDomDocument doc;
doc.setContent(data);
QDomElement e = doc.documentElement();
if (e.tagName() == "filterconfig") {
kfc->fromLegacyXML(e);
} else {
kfc->fromXML(e);
}
return true;
}
}
......
......@@ -262,7 +262,7 @@ bool KisKraSaveVisitor::saveFilterConfiguration(KisNode* node)
if (filter) {
QString location = getLocation(node, DOT_FILTERCONFIG);
if (m_store->open(location)) {
QString s = filter->toLegacyXML();
QString s = filter->toXML();
m_store->write(s.toUtf8(), qstrlen(s.toUtf8()));
m_store->close();
return true;
......
......@@ -83,7 +83,7 @@ KisSelectionSP createVectorSelection(KisPaintDeviceSP paintDevice, KisImageWSP i
KisDoc2* createCompleteDocument()
{
KisImageWSP image = new KisImage(0, 1024, 1024, KoColorSpaceRegistry::instance()->rgb8(), "test for roundtrip");
KisImageWSP image = new KisImage(0, 1024, 1024, KoColorSpaceRegistry::instance()->rgb8(), "test for roundtrip", false);
KisDoc2* doc = new KisDoc2;
doc->setCurrentImage(image);
doc->documentInfo()->setAboutInfo("title", image->objectName());
......
......@@ -44,6 +44,11 @@
#include <KDebug>
#include <QtGui/QPainter>
#include <qnumeric.h> // for qIsNaN
static bool qIsNaNPoint(const QPointF &p) {
return qIsNaN(p.x()) || qIsNaN(p.y());
}
KoPathShapePrivate::KoPathShapePrivate(KoPathShape *q)
: KoShapePrivate(q),
fillRule(Qt::OddEvenFill)
......@@ -319,23 +324,31 @@ QPainterPath KoPathShape::outline() const
KoPathPoint::PointProperties currProperties = currPoint->properties();
if (currPoint == subpath->first()) {
if (currProperties & KoPathPoint::StartSubpath) {
Q_ASSERT(!qIsNaNPoint(currPoint->point()));
path.moveTo(currPoint->point());
}
} else if (activeCP && currPoint->activeControlPoint1()) {
Q_ASSERT(!qIsNaNPoint(lastPoint->controlPoint2()));
Q_ASSERT(!qIsNaNPoint(currPoint->controlPoint1()));
Q_ASSERT(!qIsNaNPoint(currPoint->point()));
path.cubicTo(
lastPoint->controlPoint2(),
currPoint->controlPoint1(),
currPoint->point());
} else if( activeCP || currPoint->activeControlPoint1()) {
Q_ASSERT(!qIsNaNPoint(lastPoint->controlPoint2()));
Q_ASSERT(!qIsNaNPoint(currPoint->controlPoint1()));
path.quadTo(
activeCP ? lastPoint->controlPoint2() : currPoint->controlPoint1(),
currPoint->point());
} else {
Q_ASSERT(!qIsNaNPoint(currPoint->point()));
path.lineTo(currPoint->point());
}
if (currProperties & KoPathPoint::CloseSubpath && currProperties & KoPathPoint::StopSubpath) {
// add curve when there is a curve on the way to the first point
KoPathPoint * firstPoint = subpath->first();
Q_ASSERT(!qIsNaNPoint(firstPoint->point()));
if (currPoint->activeControlPoint2() && firstPoint->activeControlPoint1()) {
path.cubicTo(
currPoint->controlPoint2(),
......@@ -343,6 +356,8 @@ QPainterPath KoPathShape::outline() const
firstPoint->point());
}
else if(currPoint->activeControlPoint2() || firstPoint->activeControlPoint1()) {
Q_ASSERT(!qIsNaNPoint(currPoint->point()));
Q_ASSERT(!qIsNaNPoint(currPoint->controlPoint1()));
path.quadTo(
currPoint->activeControlPoint2() ? currPoint->controlPoint2() : firstPoint->controlPoint1(),
firstPoint->point());
......
......@@ -33,20 +33,20 @@
// 1 cc = 12 dd
// Note: I don't use division but multiplication with the inverse value
// because it's faster ;p (Werner)
#define POINT_TO_MM(px) ((px)*0.352777167)
#define MM_TO_POINT(mm) ((mm)*2.83465058)
#define POINT_TO_CM(px) ((px)*0.0352777167)
#define CM_TO_POINT(cm) ((cm)*28.3465058)
#define POINT_TO_DM(px) ((px)*0.00352777167)
#define DM_TO_POINT(dm) ((dm)*283.465058)
#define POINT_TO_INCH(px) ((px)*0.01388888888889)
#define INCH_TO_POINT(inch) ((inch)*72.0)
#define MM_TO_INCH(mm) ((mm)*0.039370147)
#define INCH_TO_MM(inch) ((inch)*25.399956)
#define POINT_TO_PI(px)((px)*0.083333333)
#define POINT_TO_CC(px)((px)*0.077880997)
#define PI_TO_POINT(pi)((pi)*12)
#define CC_TO_POINT(cc)((cc)*12.840103)
#define POINT_TO_MM(px) qreal((px)*0.352777167)
#define MM_TO_POINT(mm) qreal((mm)*2.83465058)
#define POINT_TO_CM(px) qreal((px)*0.0352777167)
#define CM_TO_POINT(cm) qreal((cm)*28.3465058)
#define POINT_TO_DM(px) qreal((px)*0.00352777167)
#define DM_TO_POINT(dm) qreal((dm)*283.465058)
#define POINT_TO_INCH(px) qreal((px)*0.01388888888889)
#define INCH_TO_POINT(inch) qreal((inch)*72.0)
#define MM_TO_INCH(mm) qreal((mm)*0.039370147)
#define INCH_TO_MM(inch) qreal((inch)*25.399956)
#define POINT_TO_PI(px) qreal((px)*0.083333333)
#define POINT_TO_CC(px) qreal((px)*0.077880997)
#define PI_TO_POINT(pi) qreal((pi)*12)
#define CC_TO_POINT(cc) qreal((cc)*12.840103)
/**
* %KOffice stores everything in pt (using "qreal") internally.
* When displaying a value to the user, the value is converted to the user's unit
......
......@@ -158,12 +158,15 @@ void KoColor::convertTo(const KoColorSpace * cs)
}
void KoColor::setColor(quint8 * data, const KoColorSpace * colorSpace)
void KoColor::setColor(const quint8 * data, const KoColorSpace * colorSpace)
{
Q_ASSERT(data);
Q_ASSERT(colorSpace);
delete [] d->data;
d->data = new quint8[colorSpace->pixelSize()];
if(d->colorSpace->pixelSize() != colorSpace->pixelSize())
{
delete [] d->data;
d->data = new quint8[colorSpace->pixelSize()];
}
memcpy(d->data, data, colorSpace->pixelSize());
d->colorSpace = KoColorSpaceRegistry::instance()->permanentColorspace(colorSpace);
}
......
......@@ -78,7 +78,9 @@ public:
void convertTo(const KoColorSpace * cs);
/// Replace the existing color data, and colorspace with the specified data.
void setColor(quint8 * data, const KoColorSpace * colorSpace = 0);
/// The data pointer remains of the responsability of the caller, and this function
/// might change the internal pointer and reallocate memory if necesserary.
void setColor(const quint8 * data, const KoColorSpace * colorSpace = 0);
/// Convert the color from src and replace the value of the current color with the converted data.
/// Don't convert the color if src and this have the same colorspace.
......
......@@ -456,10 +456,13 @@ bool Layout::nextParag()
QList<QTextOption::Tab> tabs;
QVariant variant = m_format.property(KoParagraphStyle::TabPositions);
if (!variant.isNull()) {
const qreal tabOffset = x();
foreach(const QVariant &tv, qvariant_cast<QList<QVariant> >(variant)) {
KoText::Tab koTab = tv.value<KoText::Tab>();
QTextOption::Tab tab;
tab.position = koTab.position * qt_defaultDpiY() / 72.; // convertion here is required because Qt thinks in device units and we don't
// convertion here is required because Qt thinks in device units and we don't
tab.position = (koTab.position - tabOffset) * qt_defaultDpiY() / 72.;
tab.type = koTab.type;
tab.delimiter = koTab.delimiter;
tabs.append(tab);
......@@ -1012,7 +1015,7 @@ void Layout::drawFrame(QTextFrame *frame, QPainter *painter, const KoTextDocumen
for (it = frame->begin(); !(it.atEnd()); ++it) {
QTextBlock block = it.currentBlock();
QTextTable *table = qobject_cast<QTextTable*>(it.currentFrame());
QTextFrame *subFrame = qobject_cast<QTextFrame*>(it.currentFrame());
QTextFrame *subFrame = it.currentFrame();
if (table) {
m_tableLayout.setTable(table);
......
......@@ -217,7 +217,7 @@ void FormattingPreview::paintEvent(QPaintEvent *event)
painter.fillRect(contentsRect(), QBrush(QColor(Qt::white)));
if (m_paragBackgroundColor.isValid() && m_paragBackgroundColor.alpha() > 1)
painter.fillRect(contentsRect(), QBrush(m_paragBackgroundColor.isValid()));
painter.fillRect(contentsRect(), QBrush(m_paragBackgroundColor));
//set up the Font properties
QFont displayFont = QFont(m_font, paintDevice);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment