Question about show view of calligra tables

tien dh tiendh11986 at gmail.com
Fri Mar 11 07:58:07 GMT 2011


Hi every one,
Please help me on that problem, it's so difficult for me to solve:

 int main(int argc, char** argv){    QApplication qapp(argc, argv);
KComponentData cd("graphicsview-test");    Calligra::Tables::Doc doc;
  bool ok = doc.*openUrl*(KUrl("/home/excel_samples/Cash_Flow_Projection_Worksheet.xls"));
   if (!ok) {        qDebug() << "failed to load";        return 0;
}    QFont font(KoGlobal::defaultFont());
Calligra::Tables::CanvasItem* canvas = new
Calligra::Tables::CanvasItem(&doc);    QRect usedArea =
canvas->*activeSheet*()->usedArea(true);    QSizeF
size(canvas->*activeSheet*()->columnPosition(usedArea.right()+3),
canvas->*activeSheet*()->rowPosition(usedArea.bottom()+5));
canvas->setDocumentSize(size);    size =
canvas->*zoomHandler*()->*documentToView*(size);
canvas->resize(size);    canvas->setPos(0, 0);
Calligra::Tables::ColumnHeaderItem* columnHeader =
static_cast<Calligra::Tables::ColumnHeaderItem*>(canvas->*columnHeader*());
   static_cast<QGraphicsWidget*>(columnHeader)->resize(size.width(),
canvas->*zoomHandler*()->zoomItY(font.pointSizeF() + 3));
columnHeader->setPos(0, -columnHeader->height());
Calligra::Tables::RowHeaderItem* rowHeader =
static_cast<Calligra::Tables::RowHeaderItem*>(canvas->*rowHeader*());
  static_cast<QGraphicsWidget*>(rowHeader)->resize(canvas->*zoomHandler*()->zoomItX(YBORDER_WIDTH),
size.height());    rowHeader->setPos(-rowHeader->width(), 0);
columnHeader->toolChanged("PanTool");
rowHeader->toolChanged("PanTool");        QGraphicsScene scene;
scene.addItem(canvas);    scene.addItem(columnHeader);
scene.addItem(rowHeader);    QGraphicsView view(&scene);
view.show();    qapp.exec();}


This portion of code can run and show a excel file. But when I try using
function: doc.createView().show, only tabbars and scrollbars shown. Sheet
area is completely black. I try using canvas, canvasWidget and
canvasController but it isn't successful.
Anyone can show me why it is and how to render the view to an image ?

-- 
Do Huu Tien
Handphone No: 0972471786
Email: tiendh11986 at gmail.com
Y!M: dohuu_tien86
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20110311/3b2dcfbf/attachment.htm>


More information about the calligra-devel mailing list