[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/filters/kspread/excel
From: Marijn Kruisselbrink <m.kruisselbrink () student ! tue ! nl>
Date: 2010-09-24 17:57:04
Message-ID: 20100924175704.807F3AC88F () svn ! kde ! org
[Download RAW message or body]
SVN commit 1179159 by mkruisselbrink:
add support for horizontal/vertical text align when converting text-on-shape text
M +1 -0 import/ExcelImport.cpp
M +28 -3 import/ODrawClient.cpp
M +3 -2 import/ODrawClient.h
M +1 -0 import/excelimporttoods.cc
M +4 -3 sidewinder/excel.cpp
M +23 -2 sidewinder/excel.h
M +2 -2 sidewinder/objects.cpp
M +4 -3 sidewinder/objects.h
M +2 -1 sidewinder/worksheetsubstreamhandler.cpp
--- trunk/koffice/filters/kspread/excel/import/ExcelImport.cpp #1179158:1179159
@@ -72,6 +72,7 @@
#include <NumberFormatParser.h>
#include "swinder.h"
+#include "objects.h"
#include <iostream>
#include "ODrawClient.h"
#include "ImportUtils.h"
--- trunk/koffice/filters/kspread/excel/import/ODrawClient.cpp #1179158:1179159
@@ -112,13 +112,13 @@
bool ODrawClient::onlyClientData(const MSO::OfficeArtClientData &o)
{
qDebug() << "NOT YET IMPLEMENTED" << __PRETTY_FUNCTION__;
- return !m_shapeText.isEmpty();
+ return !m_shapeText.m_text.isEmpty();
}
void ODrawClient::processClientData(const MSO::OfficeArtClientData &o, Writer &out)
{
qDebug() << "NOT YET IMPLEMENTED" << __PRETTY_FUNCTION__;
- QStringList lines = m_shapeText.split(QRegExp("[\n\r]"));
+ QStringList lines = m_shapeText.m_text.split(QRegExp("[\n\r]"));
foreach (const QString& line, lines) {
out.xml.startElement("text:p", false);
int pos = 0;
@@ -148,6 +148,31 @@
KoGenStyle ODrawClient::createGraphicStyle(const MSO::OfficeArtClientTextBox *ct, \
const MSO::OfficeArtClientData *cd, Writer &out) {
KoGenStyle style = KoGenStyle(KoGenStyle::GraphicAutoStyle, "graphic");
+ if (!m_shapeText.m_text.isEmpty()) {
+ switch (m_shapeText.halign) {
+ case Swinder::TxORecord::Left:
+ style.addProperty("draw:textarea-horizontal-align", "left");
+ break;
+ case Swinder::TxORecord::Centered:
+ style.addProperty("draw:textarea-horizontal-align", "center");
+ break;
+ case Swinder::TxORecord::Right:
+ style.addProperty("draw:textarea-horizontal-align", "right");
+ break;
+ }
+ switch (m_shapeText.valign) {
+ case Swinder::TxORecord::Top:
+ style.addProperty("draw:textarea-vertical-align", "top");
+ break;
+ case Swinder::TxORecord::VCentered:
+ style.addProperty("draw:textarea-vertical-align", "middle");
+ break;
+ case Swinder::TxORecord::Bottom:
+ style.addProperty("draw:textarea-vertical-align", "bottom");
+ break;
+ }
+ }
+ //draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="top"
style.setAutoStyleInStylesDotXml(out.stylesxml);
return style;
}
@@ -176,7 +201,7 @@
return QString::number(v, 'f', 11) + "pt";
}
-void ODrawClient::setShapeText(const QString &text)
+void ODrawClient::setShapeText(const Swinder::TxORecord &text)
{
m_shapeText = text;
}
--- trunk/koffice/filters/kspread/excel/import/ODrawClient.h #1179158:1179159
@@ -20,6 +20,7 @@
#define ODRAWCLIENT_H
#include <ODrawToOdf.h>
+#include <excel.h>
namespace Swinder {
class Sheet;
@@ -41,10 +42,10 @@
virtual QColor toQColor(const MSO::OfficeArtCOLORREF &c);
virtual QString formatPos(qreal v);
- void setShapeText(const QString& text);
+ void setShapeText(const Swinder::TxORecord& text);
private:
Swinder::Sheet* m_sheet;
- QString m_shapeText;
+ Swinder::TxORecord m_shapeText;
};
#endif // ODRAWCLIENT_H
--- trunk/koffice/filters/kspread/excel/import/excelimporttoods.cc #1179158:1179159
@@ -46,6 +46,7 @@
#include <NumberFormatParser.h>
#include "swinder.h"
+#include "objects.h"
#include <iostream>
#include "ODrawClient.h"
#include "ImportUtils.h"
--- trunk/koffice/filters/kspread/excel/sidewinder/excel.cpp #1179158:1179159
@@ -1669,14 +1669,15 @@
void TxORecord::dump(std::ostream& out) const
{
out << "TxO" << std::endl;
+ out << " " << m_text << " " << halign << " " << valign;
}
void TxORecord::setData(unsigned size, const unsigned char* data, const unsigned* \
continuePositions) {
- //const unsigned long opts1 = readU16(data);
+ const unsigned long opts1 = readU16(data);
//const bool reserved1 = opts1 & 0x01;
- //const unsigned int hAlignment = opts1 & 0x000e; // 3 bits
- //const unsigned int vAlignment = opts1 & 0x0070; // 3 bits
+ halign = static_cast<HorizontalAlignment>((opts1 & 0x000e) >> 1); // 3 bits
+ valign = static_cast<VerticalAlignment>((opts1 & 0x0070) >> 4); // 3 bits
//const unsigned long rot = readU16(data + 2);
// 4 bytes reserved
--- trunk/koffice/filters/kspread/excel/sidewinder/excel.h #1179158:1179159
@@ -28,7 +28,6 @@
#include "swinder.h"
#include "formulas.h"
#include "records.h"
-#include "objects.h"
// libmso
//#include <generated/simpleParser.h>
@@ -41,6 +40,9 @@
namespace Swinder
{
+
+class Object;
+
// rich-text, unicode, far-east support Excel string
class EString
@@ -777,9 +779,28 @@
class TxORecord : public Record
{
public:
+ enum HorizontalAlignment {
+ Left = 1,
+ Centered = 2,
+ Right = 3,
+ Justified = 4,
+ Distributed = 7
+ };
+ enum VerticalAlignment {
+ Top = 1,
+ VCentered = 2,
+ Bottom = 3,
+ VJustified = 4,
+ VDistributed = 7
+ };
+
+
QString m_text;
+ HorizontalAlignment halign;
+ VerticalAlignment valign;
+
static const unsigned id;
- TxORecord(Workbook *book);
+ TxORecord(Workbook *book=0);
virtual ~TxORecord();
virtual unsigned rtti() const {
return this->id;
--- trunk/koffice/filters/kspread/excel/sidewinder/objects.cpp #1179158:1179159
@@ -120,12 +120,12 @@
return m_object;
}
-void OfficeArtObject::setText(const QString &text)
+void OfficeArtObject::setText(const TxORecord &text)
{
m_text = text;
}
-QString OfficeArtObject::text() const
+TxORecord OfficeArtObject::text() const
{
return m_text;
}
--- trunk/koffice/filters/kspread/excel/sidewinder/objects.h #1179158:1179159
@@ -29,6 +29,7 @@
#include "cell.h"
#include "sheet.h"
#include "workbook.h"
+#include "excel.h"
#include <string>
#include <iostream>
@@ -212,13 +213,13 @@
explicit OfficeArtObject(const MSO::OfficeArtSpContainer& object);
~OfficeArtObject();
MSO::OfficeArtSpContainer object() const;
- void setText(const QString& text);
- QString text() const;
+ void setText(const TxORecord& text);
+ TxORecord text() const;
bool operator==(const OfficeArtObject& other) const { return this == &other; }
bool operator!=(const OfficeArtObject& other) const { return !(*this == other); \
} private:
MSO::OfficeArtSpContainer m_object;
- QString m_text;
+ TxORecord m_text;
};
} // namespace Swinder
--- trunk/koffice/filters/kspread/excel/sidewinder/worksheetsubstreamhandler.cpp \
#1179158:1179159 @@ -26,6 +26,7 @@
#include "globalssubstreamhandler.h"
#include "excel.h"
#include "cell.h"
+#include "objects.h"
#include "sheet.h"
#include <QPoint>
@@ -728,7 +729,7 @@
d->textObjects.push_back(record->m_text);
if (d->lastOfficeArtObject) {
- d->lastOfficeArtObject->setText(record->m_text);
+ d->lastOfficeArtObject->setText(*record);
d->lastOfficeArtObject = 0;
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic