[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/filters
From: Björn Breitmeyer <bjoern.breitmeyer () kdab ! com>
Date: 2010-10-15 9:09:40
Message-ID: 20101015090940.EEBD4AC895 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1186158 by breitmeyer:
removed the spreadsheet mode from the theme reader, the wrong colors
in kspread came from a strange excel 2007 behavior that switches
indexes for colors 0 to 1, 1 to 0, 2 to 3 and 3 to 2. This seems
to be hardcoded in excel. further explanation can be found as
comments in the code
M +0 -1 kpresenter/pptx/PptxXmlDocumentReader.cpp
M +34 -7 kspread/xlsx/XlsxXmlStylesReader.cpp
M +10 -18 libmsooxml/MsooXmlThemesReader.cpp
M +2 -5 libmsooxml/MsooXmlThemesReader.h
--- trunk/koffice/filters/kpresenter/pptx/PptxXmlDocumentReader.cpp #1186157:1186158
@@ -409,7 +409,6 @@
MSOOXML::MsooXmlThemesReader themesReader(m_writers);
MSOOXML::MsooXmlThemesReaderContext themecontext(masterPageProperties.theme, \
m_context->relationships, m_context->import, slideThemePath, slideThemeFile);
- themecontext.spreadMode = false; // In this mode, colors behave better with pptx
QString errorMessage;
--- trunk/koffice/filters/kspread/xlsx/XlsxXmlStylesReader.cpp #1186157:1186158
@@ -380,11 +380,25 @@
//! @todo implement more styling;
//! use XlsxColorStyle::automatic, XlsxColorStyle::indexed, \
XlsxColorStyle::theme...
const XlsxColorStyle* realBackgroundColor = this->realBackgroundColor( themes );
- if (realBackgroundColor) {
-kDebug() << patternType << realBackgroundColor->value(themes).name()
- << realBackgroundColor->tint << realBackgroundColor->isValid(themes);
- if (realBackgroundColor->isValid(themes)) {
- cellStyle->addProperty("fo:background-color", \
realBackgroundColor->value(themes).name()); + if ( realBackgroundColor )
+ {
+ // This is necessary because excel switches the indexes of 0 - 1 and 2 - 3 \
for theme colorindexes + // looks like it has a different internal indexing \
table + // i found the info here : \
http://blogs.msdn.com/b/excel/archive/2007/11/16/chart-pattern-fills.aspx + // \
and verified it + XlsxColorStyle changedColor( *realBackgroundColor );
+ if ( changedColor.theme == 0 )
+ changedColor.theme = 1;
+ else if ( changedColor.theme == 1 )
+ changedColor.theme = 0;
+ else if ( changedColor.theme == 2 )
+ changedColor.theme = 3;
+ else if ( changedColor.theme == 3 )
+ changedColor.theme = 2;
+ kDebug() << patternType << changedColor.value(themes).name()
+ << changedColor.tint << changedColor.isValid(themes);
+ if (changedColor.isValid(themes)) {
+ cellStyle->addProperty("fo:background-color", \
changedColor.value(themes).name()); }
}
}
@@ -520,8 +534,21 @@
//!@ todo reenable this cellStyle->addProperty("style:font-name", name, \
KoGenStyle::TextType);
cellStyle->addProperty("fo:font-family", name, KoGenStyle::TextType);
}
- if (color.isValid(themes)) {
- const QColor c(color.value(themes));
+ // This is necessary because excel switches the indexes of 0 - 1 and 2 - 3 for \
theme colorindexes + // looks like it has a different internal indexing table
+ // i found the info here : \
http://blogs.msdn.com/b/excel/archive/2007/11/16/chart-pattern-fills.aspx + // and \
verified it + XlsxColorStyle changedColor( color );
+ if ( changedColor.theme == 0 )
+ changedColor.theme = 1;
+ else if ( changedColor.theme == 1 )
+ changedColor.theme = 0;
+ else if ( changedColor.theme == 2 )
+ changedColor.theme = 3;
+ else if ( changedColor.theme == 3 )
+ changedColor.theme = 2;
+ else if (changedColor.isValid(themes)) {
+ const QColor c(changedColor.value(themes));
cellStyle->addProperty("fo:color", c.name(), KoGenStyle::TextType);
}
//! @todo implement more styling
--- trunk/koffice/filters/libmsooxml/MsooXmlThemesReader.cpp #1186157:1186158
@@ -109,38 +109,34 @@
{
}
-DrawingMLColorSchemeSystemItem::DrawingMLColorSchemeSystemItem(bool spreadMode)
- : spreadsheetMode(spreadMode)
+DrawingMLColorSchemeSystemItem::DrawingMLColorSchemeSystemItem()
{
}
QColor DrawingMLColorSchemeSystemItem::value() const
{
- // In this mode we prefer last color
- if (!spreadsheetMode) {
+
if (lastColor.isValid()) {
return lastColor;
}
- }
-
//! 20.1.10.58 ST_SystemColorVal (System Color Value)
if ( systemColor == QLatin1String("windowText")
|| systemColor == QLatin1String("menuText"))
{
- if (!spreadsheetMode) {
+// if (!spreadsheetMode) {
return QPalette().color(QPalette::Active, QPalette::WindowText);
+// }
+// return QPalette().color(QPalette::Active, QPalette::Window);
}
- return QPalette().color(QPalette::Active, QPalette::Window);
- }
else if ( systemColor == QLatin1String("window")
|| systemColor == QLatin1String("menu")
|| systemColor == QLatin1String("menuBar"))
{
- if (!spreadsheetMode) {
+// if (!spreadsheetMode) {
return QPalette().color(QPalette::Active, QPalette::Window);
+// }
+// return QPalette().color(QPalette::Active, QPalette::WindowText);
}
- return QPalette().color(QPalette::Active, QPalette::WindowText);
- }
else if (systemColor == QLatin1String("highlightText")) {
return QPalette().color(QPalette::Active, QPalette::HighlightedText);
}
@@ -162,9 +158,6 @@
else if (systemColor == QLatin1String("btnShadow")) {
return QPalette().color(QPalette::Active, QPalette::Dark);
}
- if (lastColor.isValid()) {
- return lastColor;
- }
//! @todo Use more of systemColor
return QColor(Qt::black); // TODO; better default?
}
@@ -271,7 +264,7 @@
MsooXmlThemesReaderContext::MsooXmlThemesReaderContext(DrawingMLTheme& t, \
MSOOXML::MsooXmlRelationships* rel, MSOOXML::MsooXmlImport* imp, QString pathName, \
QString fileName) : MsooXmlReaderContext()
- , theme(&t), spreadMode(true), relationships(rel), import(imp), \
path(pathName), file(fileName) + , theme(&t), relationships(rel), import(imp), \
path(pathName), file(fileName) {
}
@@ -299,7 +292,6 @@
{
m_context = dynamic_cast<MsooXmlThemesReaderContext*>(context);
Q_ASSERT(m_context);
- m_spreadMode = m_context->spreadMode;
m_import = m_context->import;
m_path = m_context->path;
m_file = m_context->file;
@@ -785,7 +777,7 @@
*/
KoFilter::ConversionStatus MsooXmlThemesReader::read_sysClr()
{
- std::auto_ptr<DrawingMLColorSchemeSystemItem> color(new \
DrawingMLColorSchemeSystemItem(m_spreadMode)); + \
std::auto_ptr<DrawingMLColorSchemeSystemItem> color(new \
DrawingMLColorSchemeSystemItem); m_currentColor = 0;
READ_PROLOGUE
const QXmlStreamAttributes attrs(attributes());
--- trunk/koffice/filters/libmsooxml/MsooXmlThemesReader.h #1186157:1186158
@@ -63,12 +63,11 @@
class MSOOXML_EXPORT DrawingMLColorSchemeSystemItem : public \
DrawingMLColorSchemeItemBase {
public:
- DrawingMLColorSchemeSystemItem(bool spreadMode);
+ DrawingMLColorSchemeSystemItem();
virtual QColor value() const;
QColor lastColor;
- QString systemColor; //!< ST_SystemColorVal ( §20.1.10.58).
- bool spreadsheetMode;
+ QString systemColor; //!< ST_SystemColorVal ( §20.1.10.58).;
DrawingMLColorSchemeSystemItem* clone() const { return new \
DrawingMLColorSchemeSystemItem(*this); } };
@@ -206,7 +205,6 @@
MsooXmlThemesReaderContext(DrawingMLTheme& t, MSOOXML::MsooXmlRelationships* \
rel, MSOOXML::MsooXmlImport* imp, QString pathName, QString fileName);
DrawingMLTheme * const theme;
- bool spreadMode;
MSOOXML::MsooXmlRelationships* relationships;
MSOOXML::MsooXmlImport* import;
QString path;
@@ -268,7 +266,6 @@
QHash<QString, QString> m_colorSchemeIndices;
bool m_clrScheme_initialized;
bool m_color_initialized;
- bool m_spreadMode;
MSOOXML::MsooXmlRelationships* m_relationships;
MSOOXML::MsooXmlImport* m_import;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic