r16856 by craig - Commit GSoC 2011 Tables work so it doesn't bitrot. Hope nothing breaks too badly (run away if it does). Missing functionality: save/load/copy/paste/export/print.. but its damn good on canvas

scribus-commit scribus-commit at lists.scribus.net
Fri Sep 23 21:47:57 UTC 2011


Author: craig
Date: Fri Sep 23 21:47:57 2011
New Revision: 16856

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16856
Log:
Commit GSoC 2011 Tables work so it doesn't bitrot. Hope nothing breaks too badly (run away if it does). Missing functionality: save/load/copy/paste/export/print.. but its damn good on canvas

Added:
    trunk/Scribus/resources/icons/16/delete-table-columns.png   (with props)
    trunk/Scribus/resources/icons/16/delete-table-rows.png   (with props)
    trunk/Scribus/resources/icons/16/insert-table-columns.png   (with props)
    trunk/Scribus/resources/icons/16/insert-table-rows.png   (with props)
    trunk/Scribus/resources/icons/16/merge-table-cells.png   (with props)
    trunk/Scribus/resources/icons/16/split-table-cells.png   (with props)
    trunk/Scribus/resources/icons/22/delete-table-columns.png   (with props)
    trunk/Scribus/resources/icons/22/delete-table-rows.png   (with props)
    trunk/Scribus/resources/icons/22/insert-table-columns.png   (with props)
    trunk/Scribus/resources/icons/22/insert-table-rows.png   (with props)
    trunk/Scribus/resources/icons/22/merge-table-cells.png   (with props)
    trunk/Scribus/resources/icons/22/split-table-cells.png   (with props)
    trunk/Scribus/resources/icons/select_column.png   (with props)
    trunk/Scribus/resources/icons/select_row.png   (with props)
    trunk/Scribus/scribus/canvasgesture_cellselect.cpp   (with props)
    trunk/Scribus/scribus/canvasgesture_cellselect.h   (with props)
    trunk/Scribus/scribus/canvasgesture_columnresize.cpp   (with props)
    trunk/Scribus/scribus/canvasgesture_columnresize.h   (with props)
    trunk/Scribus/scribus/canvasgesture_rowresize.cpp   (with props)
    trunk/Scribus/scribus/canvasgesture_rowresize.h   (with props)
    trunk/Scribus/scribus/canvasgesture_table.cpp   (with props)
    trunk/Scribus/scribus/canvasgesture_table.h   (with props)
    trunk/Scribus/scribus/canvasgesture_tableresize.cpp   (with props)
    trunk/Scribus/scribus/canvasgesture_tableresize.h   (with props)
    trunk/Scribus/scribus/canvasmode_edittable.cpp   (with props)
    trunk/Scribus/scribus/canvasmode_edittable.h   (with props)
    trunk/Scribus/scribus/cellarea.cpp   (with props)
    trunk/Scribus/scribus/cellarea.h   (with props)
    trunk/Scribus/scribus/collapsedtablepainter.cpp   (with props)
    trunk/Scribus/scribus/collapsedtablepainter.h   (with props)
    trunk/Scribus/scribus/pageitem_table.cpp   (with props)
    trunk/Scribus/scribus/pageitem_table.h   (with props)
    trunk/Scribus/scribus/plugins/scriptplugin/cmdcell.cpp   (with props)
    trunk/Scribus/scribus/plugins/scriptplugin/cmdcell.h   (with props)
    trunk/Scribus/scribus/plugins/scriptplugin/cmdtable.cpp   (with props)
    trunk/Scribus/scribus/plugins/scriptplugin/cmdtable.h   (with props)
    trunk/Scribus/scribus/styles/cellstyle.attrdefs.cxx
    trunk/Scribus/scribus/styles/cellstyle.cpp   (with props)
    trunk/Scribus/scribus/styles/cellstyle.h   (with props)
    trunk/Scribus/scribus/styles/tablestyle.attrdefs.cxx
    trunk/Scribus/scribus/styles/tablestyle.cpp   (with props)
    trunk/Scribus/scribus/styles/tablestyle.h   (with props)
    trunk/Scribus/scribus/tableborder.cpp   (with props)
    trunk/Scribus/scribus/tableborder.h   (with props)
    trunk/Scribus/scribus/tablecell.cpp   (with props)
    trunk/Scribus/scribus/tablecell.h   (with props)
    trunk/Scribus/scribus/tablehandle.h   (with props)
    trunk/Scribus/scribus/tablepainter.h   (with props)
    trunk/Scribus/scribus/tableutils.cpp   (with props)
    trunk/Scribus/scribus/tableutils.h   (with props)
    trunk/Scribus/scribus/tests/cellareatests.cpp   (with props)
    trunk/Scribus/scribus/tests/cellareatests.h   (with props)
    trunk/Scribus/scribus/tests/scripts/
    trunk/Scribus/scribus/tests/scripts/test_table_border_joins.py
    trunk/Scribus/scribus/tests/scripts/test_tables.py
    trunk/Scribus/scribus/ui/inserttablecolumnsdialog.cpp   (with props)
    trunk/Scribus/scribus/ui/inserttablecolumnsdialog.h   (with props)
    trunk/Scribus/scribus/ui/inserttablecolumnsdialog.ui
    trunk/Scribus/scribus/ui/inserttablerowsdialog.cpp   (with props)
    trunk/Scribus/scribus/ui/inserttablerowsdialog.h   (with props)
    trunk/Scribus/scribus/ui/inserttablerowsdialog.ui
    trunk/Scribus/scribus/ui/propertiespalette_table.cpp   (with props)
    trunk/Scribus/scribus/ui/propertiespalette_table.h   (with props)
    trunk/Scribus/scribus/ui/propertiespalette_tablebase.ui
    trunk/Scribus/scribus/ui/smcellstyle.cpp   (with props)
    trunk/Scribus/scribus/ui/smcellstyle.h   (with props)
    trunk/Scribus/scribus/ui/smcellstylewidget.cpp   (with props)
    trunk/Scribus/scribus/ui/smcellstylewidget.h   (with props)
    trunk/Scribus/scribus/ui/smcellstylewidget.ui
    trunk/Scribus/scribus/ui/smtablestyle.cpp   (with props)
    trunk/Scribus/scribus/ui/smtablestyle.h   (with props)
    trunk/Scribus/scribus/ui/smtablestylewidget.cpp   (with props)
    trunk/Scribus/scribus/ui/smtablestylewidget.h   (with props)
    trunk/Scribus/scribus/ui/smtablestylewidget.ui
    trunk/Scribus/scribus/ui/tablecolumnwidthsdialog.cpp   (with props)
    trunk/Scribus/scribus/ui/tablecolumnwidthsdialog.h   (with props)
    trunk/Scribus/scribus/ui/tablecolumnwidthsdialog.ui
    trunk/Scribus/scribus/ui/tablerowheightsdialog.cpp   (with props)
    trunk/Scribus/scribus/ui/tablerowheightsdialog.h   (with props)
    trunk/Scribus/scribus/ui/tablerowheightsdialog.ui
    trunk/Scribus/scribus/ui/tablesideselector.cpp   (with props)
    trunk/Scribus/scribus/ui/tablesideselector.h   (with props)
Modified:
    trunk/Scribus/CMakeLists.txt
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/actionmanager.cpp
    trunk/Scribus/scribus/canvas.cpp
    trunk/Scribus/scribus/canvas.h
    trunk/Scribus/scribus/canvasgesture.h
    trunk/Scribus/scribus/canvasgesture_linemove.h
    trunk/Scribus/scribus/canvasgesture_pan.h
    trunk/Scribus/scribus/canvasgesture_rectselect.h
    trunk/Scribus/scribus/canvasgesture_resize.h
    trunk/Scribus/scribus/canvasgesture_rulermove.h
    trunk/Scribus/scribus/canvasmode.cpp
    trunk/Scribus/scribus/canvasmode.h
    trunk/Scribus/scribus/canvasmode_copyproperties.h
    trunk/Scribus/scribus/canvasmode_create.cpp
    trunk/Scribus/scribus/canvasmode_create.h
    trunk/Scribus/scribus/canvasmode_drawbezier.h
    trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp
    trunk/Scribus/scribus/canvasmode_drawcalligraphic.h
    trunk/Scribus/scribus/canvasmode_drawfreehand.cpp
    trunk/Scribus/scribus/canvasmode_drawfreehand.h
    trunk/Scribus/scribus/canvasmode_edit.cpp
    trunk/Scribus/scribus/canvasmode_edit.h
    trunk/Scribus/scribus/canvasmode_editarc.h
    trunk/Scribus/scribus/canvasmode_editgradient.h
    trunk/Scribus/scribus/canvasmode_editmeshgradient.h
    trunk/Scribus/scribus/canvasmode_editpolygon.h
    trunk/Scribus/scribus/canvasmode_editspiral.h
    trunk/Scribus/scribus/canvasmode_eyedropper.h
    trunk/Scribus/scribus/canvasmode_framelinks.cpp
    trunk/Scribus/scribus/canvasmode_framelinks.h
    trunk/Scribus/scribus/canvasmode_magnifier.cpp
    trunk/Scribus/scribus/canvasmode_magnifier.h
    trunk/Scribus/scribus/canvasmode_measurements.h
    trunk/Scribus/scribus/canvasmode_nodeedit.h
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/canvasmode_normal.h
    trunk/Scribus/scribus/canvasmode_objimport.cpp
    trunk/Scribus/scribus/canvasmode_objimport.h
    trunk/Scribus/scribus/canvasmode_panning.h
    trunk/Scribus/scribus/canvasmode_rotate.h
    trunk/Scribus/scribus/commonstrings.cpp
    trunk/Scribus/scribus/commonstrings.h
    trunk/Scribus/scribus/fpoint.h
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/pageitem_textframe.h
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/CMakeLists.txt
    trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.h
    trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.h
    trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
    trunk/Scribus/scribus/resourcecollection.h
    trunk/Scribus/scribus/scpainter.cpp
    trunk/Scribus/scribus/scpainter.h
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribus.h
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/scribusstructs.h
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/styles/CMakeLists.txt
    trunk/Scribus/scribus/styles/styleset.h
    trunk/Scribus/scribus/tests/CMakeLists.txt
    trunk/Scribus/scribus/tests/runtests.cpp
    trunk/Scribus/scribus/tests/testStoryText.cpp
    trunk/Scribus/scribus/ui/about.cpp
    trunk/Scribus/scribus/ui/contextmenu.cpp
    trunk/Scribus/scribus/ui/modetoolbar.cpp
    trunk/Scribus/scribus/ui/propertiespalette.cpp
    trunk/Scribus/scribus/ui/propertiespalette.h

Modified: trunk/Scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/CMakeLists.txt (original)
+++ trunk/Scribus/CMakeLists.txt Fri Sep 23 21:47:57 2011
@@ -33,6 +33,8 @@
 INCLUDE(CheckCXXCompilerFlag)
 INCLUDE(CheckTypeSize)
 INCLUDE(TestBigEndian)
+
+#ENABLE_TESTING()
 
 #Set the custom CMake module directory where our include/lib finders are
 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Fri Sep 23 21:47:57 2011
@@ -81,6 +81,8 @@
   ui/gtfiledialog.ui
   ui/guidemanager.ui
   ui/insertaframe.ui
+  ui/inserttablecolumnsdialog.ui
+  ui/inserttablerowsdialog.ui
   ui/latexeditor.ui
   ui/newmarginwidgetbase.ui
   ui/measurementsbase.ui
@@ -126,6 +128,7 @@
   ui/propertiespalette_imagebase.ui
   ui/propertiespalette_linebase.ui
   ui/propertiespalette_shapebase.ui
+  ui/propertiespalette_tablebase.ui
   ui/propertiespalette_textbase.ui
   ui/propertiespalette_xyzbase.ui
   ui/propertywidget_advancedbase.ui
@@ -139,14 +142,18 @@
   ui/replaceonecolor.ui
   ui/selectobjects.ui
   ui/shortcutwidget.ui
+  ui/smcellstylewidget.ui
   ui/smcstylewidget.ui
   ui/smlinestylewidget.ui
+  ui/smtablestylewidget.ui
   ui/smpstylewidget.ui
   ui/smreplacedia.ui
   ui/smstyleimport.ui
   ui/spiralvectorbase.ui
   ui/spiralwidgetbase.ui
   ui/stylemanager.ui
+  ui/tablecolumnwidthsdialog.ui
+  ui/tablerowheightsdialog.ui
   ui/transformdialogbase.ui
   ui/transparencypalette.ui
   ui/copypagetomasterpage.ui
@@ -162,12 +169,18 @@
 SET(SCRIBUS_MOC_CLASSES
   actionmanager.h
   canvas.h
+  canvasgesture_cellselect.h
+  canvasgesture_columnresize.h
+  canvasgesture_rowresize.h
   canvasgesture_rulermove.h
+  canvasgesture_table.h
+  canvasgesture_tableresize.h
   canvasmode.h
   canvasmode_edit.h
   canvasmode_editarc.h
   canvasmode_editpolygon.h
   canvasmode_editspiral.h
+  canvasmode_edittable.h
   canvasmode_measurements.h
   canvasmode_normal.h
   chartablemodel.h
@@ -202,6 +215,7 @@
   pageitem_regularpolygon.h
   pageitem_spiral.h
   pageitem_symbol.h
+  pageitem_table.h
   pageitem_textframe.h
   pageitempointer.h
   pdf_analyzer.h
@@ -286,6 +300,8 @@
   ui/imageinfodialog.h
   ui/insertTable.h
   ui/insertaframe.h
+  ui/inserttablecolumnsdialog.h
+  ui/inserttablerowsdialog.h
   ui/inspage.h
   ui/javadocs.h
   ui/latexeditor.h
@@ -357,6 +373,7 @@
   ui/propertiespalette_image.h
   ui/propertiespalette_line.h
   ui/propertiespalette_shape.h
+  ui/propertiespalette_table.h
   ui/propertiespalette_text.h
   ui/propertiespalette_utils.h
   ui/propertiespalette_xyz.h
@@ -391,9 +408,12 @@
   ui/shadebutton.h
   ui/shortcutwidget.h
   ui/smalignselect.h
+  ui/smcellstylewidget.h
+  ui/smcellstyle.h
   ui/smcheckbox.h
   ui/smcolorcombo.h
   ui/smcstylewidget.h
+  ui/smtablestylewidget.h
   ui/smfontcomboh.h
   ui/smlinestyle.h
   ui/smlinestylewidget.h
@@ -405,6 +425,7 @@
   ui/smspinbox.h
   ui/smstyleimport.h
   ui/smstyleselect.h
+  ui/smtablestyle.h
   ui/smtabruler.h
   ui/smtextstyles.h
   ui/spalette.h
@@ -416,6 +437,9 @@
   ui/styleview.h
   ui/swatchcombo.h
   ui/symbolpalette.h
+  ui/tablecolumnwidthsdialog.h
+  ui/tablesideselector.h
+  ui/tablerowheightsdialog.h
   ui/tabmanager.h
   ui/tabpdfoptions.h
   ui/tabruler.h
@@ -438,11 +462,16 @@
 SET(SCRIBUS_SOURCES
   actionmanager.cpp
   canvas.cpp
+  canvasgesture_cellselect.cpp
+  canvasgesture_columnresize.cpp
   canvasgesture_linemove.cpp
   canvasgesture_pan.cpp
   canvasgesture_rectselect.cpp
   canvasgesture_resize.cpp
+  canvasgesture_rowresize.cpp
   canvasgesture_rulermove.cpp
+  canvasgesture_table.cpp
+  canvasgesture_tableresize.cpp
   canvasmode.cpp
   canvasmode_copyproperties.cpp
   canvasmode_create.cpp
@@ -457,6 +486,7 @@
   canvasmode_editmeshgradient.cpp
   canvasmode_editpolygon.cpp
   canvasmode_editspiral.cpp
+  canvasmode_edittable.cpp
   canvasmode_magnifier.cpp
   canvasmode_measurements.cpp
   canvasmode_nodeedit.cpp
@@ -464,10 +494,12 @@
   canvasmode_objimport.cpp
   canvasmode_panning.cpp
   canvasmode_rotate.cpp
+  cellarea.cpp
   chartablemodel.cpp
   chartableview.cpp
   cmserrorhandling.cpp
   cmsettings.cpp
+  collapsedtablepainter.cpp
   collect4output.cpp
   colorblind.cpp
   colorsetmanager.cpp
@@ -524,6 +556,7 @@
   pageitem_regularpolygon.cpp
   pageitem_spiral.cpp
   pageitem_symbol.cpp
+  pageitem_table.cpp
   pageitem_textframe.cpp
   pageitempointer.cpp
   pagesize.cpp
@@ -604,6 +637,9 @@
   selection.cpp
   serializer.cpp
   styleitem.cpp
+  tableborder.cpp
+  tablecell.cpp
+  tableutils.cpp
   textwriter.cpp
   tocgenerator.cpp
   transaction.cpp
@@ -682,6 +718,8 @@
   ui/imageinfodialog.cpp
   ui/insertTable.cpp
   ui/insertaframe.cpp
+  ui/inserttablecolumnsdialog.cpp
+  ui/inserttablerowsdialog.cpp
   ui/inspage.cpp
   ui/javadocs.cpp
   ui/latexeditor.cpp
@@ -754,6 +792,7 @@
   ui/propertiespalette_group.cpp
   ui/propertiespalette_line.cpp
   ui/propertiespalette_shape.cpp
+  ui/propertiespalette_table.cpp
   ui/propertiespalette_text.cpp
   ui/propertiespalette_utils.cpp
   ui/propertiespalette_xyz.cpp
@@ -791,6 +830,8 @@
   ui/shadebutton.cpp
   ui/shortcutwidget.cpp
   ui/smalignselect.cpp
+  ui/smcellstylewidget.cpp
+  ui/smcellstyle.cpp
   ui/smcheckbox.cpp
   ui/smcolorcombo.cpp
   ui/smcstylewidget.cpp
@@ -806,6 +847,8 @@
   ui/smspinbox.cpp
   ui/smstyleimport.cpp
   ui/smstyleselect.cpp
+  ui/smtablestylewidget.cpp
+  ui/smtablestyle.cpp
   ui/smtabruler.cpp
   ui/smtextstyles.cpp
   ui/spalette.cpp
@@ -818,6 +861,9 @@
   ui/styleview.cpp
   ui/swatchcombo.cpp
   ui/symbolpalette.cpp
+  ui/tablecolumnwidthsdialog.cpp
+  ui/tablerowheightsdialog.cpp
+  ui/tablesideselector.cpp
   ui/tabmanager.cpp
   ui/tabpdfoptions.cpp
   ui/tabruler.cpp

Modified: trunk/Scribus/scribus/actionmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/actionmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/actionmanager.cpp (original)
+++ trunk/Scribus/scribus/actionmanager.cpp Fri Sep 23 21:47:57 2011
@@ -429,6 +429,30 @@
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name="itemUpdateImage";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	name="tableInsertRows";
+	scrActions->insert(name, new ScrAction(loadIcon("16/insert-table-rows.png"), loadIcon("22/insert-table-rows.png"), "", defaultKey(name), mainWindow));
+	name="tableInsertColumns";
+	scrActions->insert(name, new ScrAction(loadIcon("16/insert-table-columns.png"), loadIcon("22/insert-table-columns.png"), "", defaultKey(name), mainWindow));
+	name="tableDeleteRows";
+	scrActions->insert(name, new ScrAction(loadIcon("16/delete-table-rows.png"), loadIcon("22/delete-table-rows.png"), "", defaultKey(name), mainWindow));
+	name="tableDeleteColumns";
+	scrActions->insert(name, new ScrAction(loadIcon("16/delete-table-columns.png"), loadIcon("22/delete-table-columns.png"), "", defaultKey(name), mainWindow));
+	name="tableMergeCells";
+	scrActions->insert(name, new ScrAction(loadIcon("16/merge-table-cells.png"), loadIcon("22/merge-table-cells.png"), "", defaultKey(name), mainWindow));
+	name="tableSplitCells";
+	scrActions->insert(name, new ScrAction(loadIcon("16/split-table-cells.png"), loadIcon("22/split-table-cells.png"), "", defaultKey(name), mainWindow));
+	name="tableSetRowHeights";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	name="tableSetColumnWidths";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	name="tableDistributeRowsEvenly";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	name="tableDistributeColumnsEvenly";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	name="tableAdjustFrameToTable";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	name = "tableAdjustTableToFrame";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name="itemAdjustFrameToImage";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name = "itemAdjustImageToFrame";
@@ -705,6 +729,8 @@
 	scrActions->insert(name, new ScrAction(ScrAction::DataInt, loadIcon("16/insert-renderframe.png"), loadIcon("22/insert-renderframe.png"), "", defaultKey(name), mainWindow, modeDrawLatex));
 	name="toolsInsertTableFrame";
 	scrActions->insert(name, new ScrAction(ScrAction::DataInt, loadIcon("16/insert-table.png"), loadIcon("22/insert-table.png"), "", defaultKey(name), mainWindow, modeDrawTable));
+	name="toolsInsertTable";
+	scrActions->insert(name, new ScrAction(ScrAction::DataInt, loadIcon("16/insert-table.png"), loadIcon("22/insert-table.png"), "", defaultKey(name), mainWindow, modeDrawTable2));
 	name="toolsInsertShape";
 	scrActions->insert(name, new ScrAction(ScrAction::DataInt, QPixmap(), QPixmap(), "", defaultKey(name), mainWindow, modeDrawShapes));
 	name="toolsInsertPolygon";
@@ -787,7 +813,7 @@
 	(*scrActions)["toolsToolbarTools"]->setToggleAction(true);
 	(*scrActions)["toolsToolbarPDF"]->setToggleAction(true);
 
-	*modeActionNames << "toolsSelect" << "toolsInsertTextFrame" << "toolsInsertImageFrame" << "toolsInsertTableFrame";
+	*modeActionNames << "toolsSelect" << "toolsInsertTextFrame" << "toolsInsertImageFrame" << "toolsInsertTableFrame" << "toolsInsertTable";
 	*modeActionNames << "toolsInsertShape" << "toolsInsertPolygon" << "toolsInsertArc" << "toolsInsertSpiral" << "toolsInsertLine" << "toolsInsertBezier";
 	*modeActionNames << "toolsInsertFreehandLine" << "toolsInsertCalligraphicLine" << "toolsInsertRenderFrame" << "toolsRotate" << "toolsZoom" << "toolsEditContents";
 	*modeActionNames << "toolsEditWithStoryEditor" << "toolsLinkTextFrame" << "toolsUnlinkTextFrame";
@@ -1058,6 +1084,18 @@
 
 void ActionManager::disconnectNewDocActions()
 {
+	disconnect( (*scrActions)["tableInsertRows"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableInsertColumns"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableDeleteRows"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableDeleteColumns"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableMergeCells"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableSplitCells"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableSetRowHeights"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableSetColumnWidths"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableDistributeRowsEvenly"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableDistributeColumnsEvenly"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableAdjustFrameToTable"], 0, 0, 0 );
+	disconnect( (*scrActions)["tableAdjustTableToFrame"], 0, 0, 0 );
 	disconnect( (*scrActions)["itemAdjustFrameToImage"], 0, 0, 0 );
 	disconnect( (*scrActions)["itemAdjustImageToFrame"], 0, 0, 0 );
 	disconnect( (*scrActions)["itemLock"], 0, 0, 0);
@@ -1089,6 +1127,18 @@
 	connect( (*scrActions)["extrasHyphenateText"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_DoHyphenate()) );
 	connect( (*scrActions)["extrasDeHyphenateText"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_DoDeHyphenate()) );
 	connect( (*scrActions)["itemDelete"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_DeleteItem()) );
+	connect( (*scrActions)["tableInsertRows"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_InsertTableRows()));
+	connect( (*scrActions)["tableInsertColumns"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_InsertTableColumns()));
+	connect( (*scrActions)["tableDeleteRows"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_DeleteTableRows()));
+	connect( (*scrActions)["tableDeleteColumns"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_DeleteTableColumns()));
+	connect( (*scrActions)["tableMergeCells"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_MergeTableCells()));
+	connect( (*scrActions)["tableSplitCells"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_SplitTableCells()));
+	connect( (*scrActions)["tableSetRowHeights"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_SetTableRowHeights()));
+	connect( (*scrActions)["tableSetColumnWidths"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_SetTableColumnWidths()));
+	connect( (*scrActions)["tableDistributeRowsEvenly"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_DistributeTableRowsEvenly()));
+	connect( (*scrActions)["tableDistributeColumnsEvenly"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_DistributeTableColumnsEvenly()));
+	connect( (*scrActions)["tableAdjustFrameToTable"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_AdjustFrameToTable()));
+	connect( (*scrActions)["tableAdjustTableToFrame"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_AdjustTableToFrame()));
 	connect( (*scrActions)["itemAdjustFrameToImage"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_AdjustFrametoImageSize()) );
 	connect( (*scrActions)["itemAdjustImageToFrame"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_AdjustImagetoFrameSize()) );
 }
@@ -1380,6 +1430,18 @@
 	(*scrActions)["itemImageInfo"]->setTexts( tr("More Info..."));
 	(*scrActions)["itemImageIsVisible"]->setTexts( tr("I&mage Visible"));
 	(*scrActions)["itemUpdateImage"]->setTexts( tr("&Update Image"));
+	(*scrActions)["tableInsertRows"]->setTexts(tr("Insert Rows..."));
+	(*scrActions)["tableInsertColumns"]->setTexts(tr("Insert Columns..."));
+	(*scrActions)["tableDeleteRows"]->setTexts(tr("Delete Rows"));
+	(*scrActions)["tableDeleteColumns"]->setTexts(tr("Delete Columns"));
+	(*scrActions)["tableMergeCells"]->setTexts(tr("Merge Cells"));
+	(*scrActions)["tableSplitCells"]->setTexts(tr("Split Cells..."));
+	(*scrActions)["tableSetRowHeights"]->setTexts(tr("Set Row Heights..."));
+	(*scrActions)["tableSetColumnWidths"]->setTexts(tr("Set Column Widths..."));
+	(*scrActions)["tableDistributeRowsEvenly"]->setTexts(tr("Distribute Rows Evenly"));
+	(*scrActions)["tableDistributeColumnsEvenly"]->setTexts(tr("Distribute Columns Evenly"));
+	(*scrActions)["tableAdjustFrameToTable"]->setTexts(tr("Adjust Frame to Table"));
+	(*scrActions)["tableAdjustTableToFrame"]->setTexts(tr("Adjust Table to Frame"));
 	(*scrActions)["itemAdjustFrameToImage"]->setTexts( tr("Adjust Frame to Image"));
 	(*scrActions)["itemAdjustImageToFrame"]->setTexts( tr("Adjust Image to Frame"));
 	(*scrActions)["itemToggleInlineImage"]->setTexts( tr("Embed Image"));
@@ -1478,6 +1540,7 @@
 	(*scrActions)["toolsInsertImageFrame"]->setText( tr("Insert &Image Frame"));
 	(*scrActions)["toolsInsertRenderFrame"]->setText( tr("Insert &Render Frame"));
 	(*scrActions)["toolsInsertTableFrame"]->setText( tr("Insert T&able"));
+	(*scrActions)["toolsInsertTable"]->setText( tr("Insert Table 2"));
 	(*scrActions)["toolsInsertShape"]->setText( tr("Insert &Shape"));
 	(*scrActions)["toolsInsertPolygon"]->setText( tr("Insert &Polygon"));
 	(*scrActions)["toolsInsertArc"]->setText( tr("Insert Arc"));
@@ -1838,6 +1901,18 @@
 		<< "itemLockSize" 
 		<< "itemImageIsVisible" 
 		<< "itemUpdateImage" 
+		<< "tableInsertRows"
+		<< "tableInsertColumns"
+		<< "tableDeleteRows"
+		<< "tableDeleteColumns"
+		<< "tableMergeCells"
+		<< "tableSplitCells"
+		<< "tableSetRowHeights"
+		<< "tableSetColumnWidths"
+		<< "tableDistributeRowsEvenly"
+		<< "tableDistributeColumnsEvenly"
+		<< "tableAdjustFrameToTable"
+		<< "tableAdjustTableToFrame"
 		<< "itemAdjustFrameToImage" 
 		<< "itemAdjustImageToFrame" 
 		<< "itemToggleInlineImage" 
@@ -1872,6 +1947,7 @@
 		<< "toolsInsertTextFrame"
 		<< "toolsInsertImageFrame"
 		<< "toolsInsertTableFrame"
+		<< "toolsInsertTable"
 		<< "toolsInsertShape"
 		<< "toolsInsertPolygon"
 		<< "toolsInsertArc"

Modified: trunk/Scribus/scribus/canvas.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvas.cpp
==============================================================================
--- trunk/Scribus/scribus/canvas.cpp (original)
+++ trunk/Scribus/scribus/canvas.cpp Fri Sep 23 21:47:57 2011
@@ -1788,6 +1788,8 @@
 	double pageHeight=page->height();
 	double pageWidth=page->width();
 	p->setFillMode(ScPainter::None);
+	p->setStrokeMode(ScPainter::Solid);
+
 	p->setPen(Qt::black, lineWidth, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 	p->drawRect(0, 0, pageWidth, pageHeight);
 	//Draw the margins
@@ -2237,6 +2239,13 @@
 	QToolTip::showText(m + QPoint(5, 5), tr("Angle: %1").arg(value2String(rot, SC_DEGREES, true, true)), this);
 }
 
+void Canvas::displayDoubleHUD(QPoint point, const QString& label, double value)
+{
+	if (!PrefsManager::instance()->appPrefs.displayPrefs.showMouseCoordinates)
+		return;
+	QToolTip::showText(point + QPoint(5, 5), QString("%1: %2").arg(label, value2String(value, m_doc->unitIndex(), true, true)), this);
+}
+
 void Canvas::setupEditHRuler(PageItem * item, bool forceAndReset)
 {
 	static QString rulerItemRef;

Modified: trunk/Scribus/scribus/canvas.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvas.h
==============================================================================
--- trunk/Scribus/scribus/canvas.h (original)
+++ trunk/Scribus/scribus/canvas.h Fri Sep 23 21:47:57 2011
@@ -95,6 +95,7 @@
 	friend class CanvasMode_EditMeshGradient;
 	friend class CanvasMode_EditPolygon;
 	friend class CanvasMode_EditSpiral;
+	friend class CanvasMode_EditTable;
 	friend class CanvasMode_EyeDropper;
 	friend class CanvasMode_FrameLinks;
 	friend class CanvasMode_Magnifier;
@@ -198,7 +199,13 @@
 	void displaySizeHUD(QPoint m, double x, double y, bool isLine = false);
 	void displayRotHUD(QPoint m, double rot);
 	void displayRealRotHUD(QPoint m, double rot);
-	
+	/**
+	 * Displays a tooltip of the format <code>{label}: {N} {unit}</code> where <code>N</code> is
+	 * @a value converted to the current document unit and <code>unit</code> the current document
+	 * unit. The tooltip will be displayed nearby the global point @a point.
+	 */
+		void displayDoubleHUD(QPoint point, const QString& label, double value);
+
 	void setupEditHRuler(PageItem * item, bool forceAndReset = false);
 	
 private:

Modified: trunk/Scribus/scribus/canvasgesture.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasgesture.h
==============================================================================
--- trunk/Scribus/scribus/canvasgesture.h (original)
+++ trunk/Scribus/scribus/canvasgesture.h Fri Sep 23 21:47:57 2011
@@ -47,10 +47,11 @@
 class SCRIBUS_API CanvasGesture : public CanvasMode
 {
 protected:
-	CanvasGesture (CanvasMode* parent) : CanvasMode(parent->view()), m_delegate(parent) {};
-	CanvasGesture (ScribusView* view) : CanvasMode(view), m_delegate(NULL) {};
+	explicit CanvasGesture (CanvasMode* parent) : CanvasMode(parent->view()), m_delegate(parent) {};
+	explicit CanvasGesture (ScribusView* view) : CanvasMode(view), m_delegate(NULL) {};
 	
-public:	
+public:
+	virtual ~CanvasGesture() {}
 	virtual void enterEvent(QEvent * e) { m_delegate->enterEvent(e); }
 	virtual void leaveEvent(QEvent * e) { m_delegate->leaveEvent(e); }
 

Modified: trunk/Scribus/scribus/canvasgesture_linemove.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasgesture_linemove.h
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_linemove.h (original)
+++ trunk/Scribus/scribus/canvasgesture_linemove.h Fri Sep 23 21:47:57 2011
@@ -49,8 +49,8 @@
 class SCRIBUS_API LineMove : public CanvasGesture
 {
 public:
-	LineMove (CanvasMode* parent): CanvasGesture(parent), m_haveLineItem(false), m_bounds(0,0,0,0) {};
-	~LineMove() {}
+	explicit LineMove (CanvasMode* parent): CanvasGesture(parent), m_haveLineItem(false), m_bounds(0,0,0,0) {}
+	virtual ~LineMove() {}
 	
 	/**
 		Prepare a LineMove without attached PageItem

Modified: trunk/Scribus/scribus/canvasgesture_pan.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasgesture_pan.h
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_pan.h (original)
+++ trunk/Scribus/scribus/canvasgesture_pan.h Fri Sep 23 21:47:57 2011
@@ -26,8 +26,8 @@
 class SCRIBUS_API PanGesture : public CanvasGesture
 {
 public:
-	PanGesture (CanvasMode* parent);
-	~PanGesture() {}
+	explicit PanGesture (CanvasMode* parent);
+	virtual ~PanGesture() {}
 	
 	virtual void activate(bool);
 	virtual void deactivate(bool);

Modified: trunk/Scribus/scribus/canvasgesture_rectselect.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasgesture_rectselect.h
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_rectselect.h (original)
+++ trunk/Scribus/scribus/canvasgesture_rectselect.h Fri Sep 23 21:47:57 2011
@@ -48,7 +48,8 @@
 class SCRIBUS_API RectSelect : public CanvasGesture
 {
 public:
-	RectSelect (CanvasMode* parent) : CanvasGesture(parent), m_start(0,0), m_rectangle(0) {};
+	explicit RectSelect (CanvasMode* parent) : CanvasGesture(parent), m_start(0,0), m_rectangle(0) {};
+	virtual ~RectSelect() {}
 	
 	void prepare(QPoint globalStartPos);
 	void clear();

Modified: trunk/Scribus/scribus/canvasgesture_resize.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasgesture_resize.h
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_resize.h (original)
+++ trunk/Scribus/scribus/canvasgesture_resize.h Fri Sep 23 21:47:57 2011
@@ -47,7 +47,8 @@
 class SCRIBUS_API ResizeGesture : public CanvasGesture
 {
 public:
-	ResizeGesture (CanvasMode* parent);
+	explicit ResizeGesture (CanvasMode* parent);
+	virtual ~ResizeGesture() {}
 	
 	/**
 		Prepares the gesture for resizing the selection

Modified: trunk/Scribus/scribus/canvasgesture_rulermove.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasgesture_rulermove.h
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_rulermove.h (original)
+++ trunk/Scribus/scribus/canvasgesture_rulermove.h Fri Sep 23 21:47:57 2011
@@ -48,6 +48,7 @@
 	enum Mode { HORIZONTAL, VERTICAL, ORIGIN };
 	RulerGesture (ScribusView* view, Mode mode) : 
 		CanvasGesture(view), m_ScMW(m_view->m_ScMW), m_mode(mode), m_haveGuide(false), m_haveCursor(false), m_xy(0,0) {};
+	virtual ~RulerGesture() {}
 
 	/**
 		Prepares the gesture for 'mode' without using an existing guide. If 'mode' is HORIZONTAL

Modified: trunk/Scribus/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode.cpp (original)
+++ trunk/Scribus/scribus/canvasmode.cpp Fri Sep 23 21:47:57 2011
@@ -29,6 +29,7 @@
 #include "canvasmode_editmeshgradient.h"
 #include "canvasmode_editpolygon.h"
 #include "canvasmode_editspiral.h"
+#include "canvasmode_edittable.h"
 #include "canvasmode_eyedropper.h"
 #include "canvasmode_framelinks.h"
 #include "canvasmode_magnifier.h"
@@ -42,8 +43,10 @@
 #include "pageitempreview.h"
 #endif
 #include "pageitem_group.h"
+#include "pageitem_textframe.h"
 #include "prefsmanager.h"
 #include "selection.h"
+#include "sccolorengine.h"
 #include "scpainter.h"
 #include "scraction.h"
 #include "scribus.h"
@@ -63,7 +66,7 @@
 #include <QMdiArea>
 #include <QMdiSubWindow>
 #include <QPainter>
-
+#include <QPointF>
 
 CanvasMode::CanvasMode (ScribusView* view) :
 	QObject(),
@@ -139,6 +142,7 @@
 		case modeDrawLatex:
 		case modeDrawText:
 		case modeDrawTable:
+		case modeDrawTable2:
 		case modeDrawRegularPolygon:
 		case modeDrawArc:
 		case modeDrawSpiral:
@@ -182,6 +186,9 @@
 			break;
 		case modeEditSpiral:
 			result = new CanvasMode_EditSpiral(view);
+			break;
+		case modeEditTable:
+			result = new CanvasMode_EditTable(view);
 			break;
 			// more modes as they are defined...
 			
@@ -606,6 +613,9 @@
 			qApp->changeOverrideCursor(QCursor(loadIcon("DrawTextFrame.xpm")));
 			break;
 		case modeDrawTable:
+			qApp->changeOverrideCursor(QCursor(loadIcon("DrawTable.xpm")));
+			break;
+		case modeDrawTable2:
 			qApp->changeOverrideCursor(QCursor(loadIcon("DrawTable.xpm")));
 			break;
 		case modeDrawRegularPolygon:
@@ -721,6 +731,147 @@
 		drawOutline(p);
 	else
 		drawSelection(p, drawHandles);
+}
+
+void CanvasMode::commonDrawTextCursor(QPainter* p, PageItem_TextFrame* textframe, const QPointF& offset)
+{
+	double dx, dy, dy1;
+	QPen cPen ( Qt::black, 0.9 , Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin );
+
+	// normalize Current Position
+	textframe->itemText.normalizeCursorPosition();
+	int textCursorPos ( textframe->itemText.cursorPosition() );
+
+	if ( textframe->lastInFrame() >= signed ( textframe->itemText.nrOfItems() )
+		 || textframe->itemText.length() == 0 )
+	{
+		dx = textframe->textToFrameDistLeft();
+		dy = textframe->textToFrameDistTop();
+		dy1 = textframe->textToFrameDistTop() + (textframe->itemText.defaultStyle().charStyle().fontSize() / 10.0);
+
+		cPen.setColor ( ScColorEngine::getRGBColor ( m_doc->PageColors[textframe->itemText.defaultStyle().charStyle().fillColor() ], m_doc ) );
+	}
+	else if ( textCursorPos > textframe->lastInFrame() )
+	{
+		// Happens often when typing directly into frame.
+		// And the cursor curses nothing, vertigo.
+		textCursorPos = qMax(0, textframe->lastInFrame());
+		QChar textCursorChar = textframe->itemText.text(textCursorPos);
+		if (textCursorChar == SpecialChars::PARSEP || textCursorChar == SpecialChars::LINEBREAK)
+		{
+			// The cursor must be moved to the beginning of the next line
+			FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
+			double lineSpacing(textframe->itemText.paragraphStyle(textCursorPos).lineSpacing());
+
+			// take care if cursor is not in first column
+			int curCol(1);
+			double ccPos(textframe->itemText.boundingBox ( textCursorPos ).x());
+			double leftOffset(textframe->textToFrameDistLeft());
+			for(int ci(1); ci <= textframe->columns(); ++ci)
+			{
+				double cLeft(((ci-1) * textframe->columnWidth()) + ((ci -1) * textframe->columnGap()) + leftOffset);
+				double cRight((ci * textframe->columnWidth()) + ((ci -1) * textframe->columnGap()) + leftOffset);
+				if((cLeft <= ccPos) && (ccPos <= cRight))
+				{
+					curCol = ci;
+					break;
+				}
+			}
+			dx = (textframe->columnWidth() * (curCol - 1)) + (textframe->columnGap() * (curCol - 1))  + leftOffset;
+			dy = bbox.y();
+
+			if ( bbox.height() <= 2 )
+				dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0;
+			else
+				dy1 = bbox.y() + bbox.height();
+
+			dy  += lineSpacing;
+			dy1 += lineSpacing;
+		}
+		else if (textCursorChar == SpecialChars::COLBREAK)
+		{
+			// A bit tricky :)
+			// We want to position the cursor at the beginning of the next column, if any.
+			// At first we need to know in which column the cursor is.
+			int curCol(1);
+			double ccPos(textframe->itemText.boundingBox ( textCursorPos ).x());
+			double leftOffset(textframe->textToFrameDistLeft());
+			for(int ci(1); ci <= textframe->columns(); ++ci)
+			{
+				double cLeft(((ci-1) * textframe->columnWidth()) + ((ci -1) * textframe->columnGap()) + leftOffset);
+				double cRight((ci * textframe->columnWidth()) + ((ci -1) * textframe->columnGap()) + leftOffset);
+				if((cLeft <= ccPos) && (ccPos <= cRight))
+				{
+					curCol = ci;
+					break;
+				}
+			}
+			if(textframe->columns() > curCol)
+			{
+				dx = (textframe->columnWidth() * curCol) + (textframe->columnGap() * curCol)  + leftOffset;
+				dy = textframe->textToFrameDistTop();
+				dy1 = textframe->textToFrameDistTop() + textframe->itemText.boundingBox ( textCursorPos ).height();
+			}
+			else // there is no column after the current column
+			{
+				FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
+				dx = bbox.x();
+				dy = bbox.y();
+				dx += textframe->itemText.item ( textCursorPos )->glyph.wide();
+				if ( bbox.height() <= 2 )
+					dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0;
+				else
+					dy1 = bbox.y() + bbox.height();
+			}
+		}
+		else
+		{
+			FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
+			dx = bbox.x();
+			dy = bbox.y();
+			dx += textframe->itemText.item ( textCursorPos )->glyph.wide();
+			if ( bbox.height() <= 2 )
+				dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0;
+			else
+				dy1 = bbox.y() + bbox.height();
+
+		}
+		cPen.setColor ( ScColorEngine::getRGBColor ( m_doc->PageColors[textframe->itemText.charStyle ( textCursorPos ).fillColor() ], m_doc ) );
+	}
+	else
+	{
+		FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
+		dx = bbox.x();
+		dy = bbox.y();
+		if ( bbox.height() <= 2 )
+			dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0;
+		else
+			dy1 = bbox.y() + bbox.height();
+
+		cPen.setColor ( ScColorEngine::getRGBColor ( m_doc->PageColors[textframe->itemText.charStyle ( textCursorPos ).fillColor() ], m_doc ) );
+	}
+	//handle Right to Left writing
+	if ( textframe->reversed() )
+	{
+		dx=textframe->width()-dx;
+	}
+
+	p->save();
+	p->translate ( textframe->xPos(), textframe->yPos() );
+	p->rotate ( textframe->rotation() );
+
+
+	p->setPen ( cPen );
+	p->setRenderHint ( QPainter::Antialiasing, true );
+	// avoid displaying the cursor on the frameborder
+	dx = qMax ( ( cPen.widthF() / 2.0 ), dx );
+
+	dy =  qMin ( qMax ( dy,0.0 ) , textframe->height() );
+	dy1 = qMin ( qMax ( dy1,0.0 ), textframe->height() );
+
+	p->drawLine ( QLineF ( dx,dy,dx,dy1 ).translated(offset) );
+
+	p->restore();
 }
 
 void CanvasMode::commonkeyPressEvent_NormalNodeEdit(QKeyEvent *e)

Modified: trunk/Scribus/scribus/canvasmode.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode.h (original)
+++ trunk/Scribus/scribus/canvasmode.h Fri Sep 23 21:47:57 2011
@@ -22,6 +22,7 @@
 
 #include <QMap>
 #include <QPen>
+#include <QPointF>
 #include <QBrush>
 
 class QDragEnterEvent;
@@ -43,6 +44,7 @@
 class  ScribusMainWindow;
 class  PageItem;
 class  PageItemPreview;
+class  PageItem_TextFrame;
 
 /** These aren't real appmodes but open a new window or override behaviour for a short time */
 enum SubMode
@@ -67,7 +69,7 @@
 {
 	Q_OBJECT
 protected:
-	CanvasMode (ScribusView* view);
+	explicit CanvasMode (ScribusView* view);
 	
 public:
 	static CanvasMode* createForAppMode(ScribusView* view, int appMode);
@@ -144,7 +146,8 @@
 	void setResizeCursor(int how, double rot = 0.0);
 	bool commonMouseMove(QMouseEvent *m);
 	void commonDrawControls(QPainter* p, bool drawHandles);
-
+	/// Draws the text cursor for @a textframe, offset by @a offset.
+	void commonDrawTextCursor(QPainter* p, PageItem_TextFrame* textframe, const QPointF& offset);
 	void commonkeyPressEvent_NormalNodeEdit(QKeyEvent *e);
 	void commonkeyReleaseEvent(QKeyEvent *e);
 	

Modified: trunk/Scribus/scribus/canvasmode_copyproperties.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_copyproperties.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_copyproperties.h (original)
+++ trunk/Scribus/scribus/canvasmode_copyproperties.h Fri Sep 23 21:47:57 2011
@@ -29,7 +29,8 @@
 class CanvasMode_CopyProperties :  public CanvasMode
 {
 public:
-	CanvasMode_CopyProperties(ScribusView* view);
+	explicit CanvasMode_CopyProperties(ScribusView* view);
+	virtual ~CanvasMode_CopyProperties() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_create.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_create.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_create.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_create.cpp Fri Sep 23 21:47:57 2011
@@ -32,11 +32,13 @@
 #include "canvas.h"
 #include "fpoint.h"
 #include "fpointarray.h"
+#include "text/frect.h"
 #include "ui/hruler.h"
 #include "ui/vruler.h"
 #include "hyphenator.h"
 #include "ui/insertTable.h"
 #include "ui/oneclick.h"
+#include "pageitem_table.h"
 #include "pageitem_textframe.h"
 #include "ui/pageselector.h"
 #include "prefscontext.h"
@@ -369,9 +371,12 @@
 
 	switch (m_doc->appMode)
 	{
-	case modeDrawTable:
-		m_view->Deselect(false);
-		break;
+		case modeDrawTable:
+			m_view->Deselect(false);
+			break;
+		case modeDrawTable2:
+			m_view->Deselect(false);
+			break;
 	}
 
 	inItemCreation = true;
@@ -392,16 +397,7 @@
 
 	m_createTransaction = new UndoTransaction(Um::instance()->beginTransaction("creating"));
 	currItem = doCreateNewObject();
-	if (m_createTransaction && currItem && currItem->isGroup())
-	{
-		// We created a table, just commit transaction
-		m_view->resetMousePressed();
-		m_createTransaction->commit();
-		m_doc->changed();
-		delete m_createTransaction;
-		m_createTransaction = NULL;	
-	}
-	else if (m_createTransaction && currItem)
+	if (m_createTransaction && currItem)
 	{
 		m_view->resetMousePressed();
 		currItem->checkChanges(true);
@@ -563,6 +559,10 @@
 		itemType  = (int) PageItem::TextFrame;
 		frameType = (int) PageItem::Unspecified;
 		break;
+	case modeDrawTable2:
+		itemType  = (int) PageItem::Table;
+		frameType = (int) PageItem::Unspecified;
+		break;
 #ifdef HAVE_OSG
 	case modeInsertPDF3DAnnotation:
 		itemType  = (int) PageItem::OSGFrame;
@@ -580,7 +580,7 @@
 	double wSize = canvasCurrCoord.x() - createObjectPos.x();
 	double hSize = canvasCurrCoord.y() - createObjectPos.y();
 	bool   skipOneClick = (modifiers == Qt::ShiftModifier);
-	if ((createObjectMode == modeDrawLine) || (createObjectMode == modeDrawTable) ||
+	if ((createObjectMode == modeDrawLine) || (createObjectMode == modeDrawTable) || (createObjectMode == modeDrawTable2) ||
 		(createObjectMode == modeInsertPDFButton) || (createObjectMode == modeInsertPDFTextfield) ||
 		(createObjectMode == modeInsertPDFTextfield) || (createObjectMode == modeInsertPDFCheckbox) ||
 		(createObjectMode == modeInsertPDFCombobox) || (createObjectMode == modeInsertPDFListbox) ||
@@ -846,6 +846,51 @@
 			m_doc->m_Selection->delaySignalsOff();
 		}
 		break;
+	case modeDrawTable2:
+		// TODO: Figure out what these conditions actually do.
+		if ((m_doc->m_Selection->count() == 0) && (m_view->HaveSelRect) && (!m_view->MidButt))
+		{
+			m_view->HaveSelRect = false;
+			// Calculate table rectangle.
+			FRect tableRect = adjustedRect(canvasPressCoord, canvasCurrCoord);
+			if (tableRect.width() < 6 || tableRect.height() < 6)
+			{
+				// Ignore tiny tables.
+				m_view->requestMode(submodePaintingDone);
+				break;
+			}
+			// Show table insert dialog.
+			qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+			InsertTable *dia = new InsertTable(m_view, static_cast<int>(tableRect.height()/6), static_cast<int>(tableRect.width()/6));
+			if (!dia->exec())
+			{
+				m_view->requestMode(submodePaintingDone);
+				delete dia;
+				dia = 0;
+				break;
+			}
+			int numRows = dia->Rows->value();
+			int numColumns = dia->Cols->value();
+			delete dia;
+			dia = 0;
+			// Add the table item.
+			// TODO: This should be done in an undo transaction.
+			z = m_doc->itemAdd(PageItem::Table, PageItem::Unspecified,
+						   tableRect.x(),
+						   tableRect.y(),
+						   tableRect.width(),
+						   tableRect.height(),
+						   0,                   // Unused.
+						   CommonStrings::None, // Unused.
+						   CommonStrings::None, // Unused.
+						   true);
+			PageItem_Table *table = m_doc->Items->at(z)->asTable();
+			table->insertRows(0, numRows - 1);
+			table->insertColumns(0, numColumns - 1);
+			table->adjustTableToFrame();
+			table->adjustFrameToTable();
+		}
+		break;
 	case modeInsertPDF3DAnnotation:
 		if (modifiers == Qt::ShiftModifier)
 		{
@@ -968,6 +1013,27 @@
 	}
 	delete dia;
 	return doCreate;
+}
+
+FRect CreateMode::adjustedRect(FPoint &firstPoint, FPoint &secondPoint)
+{
+	// Lock to grid.
+	FPoint first = m_doc->ApplyGridF(firstPoint);
+	FPoint second = m_doc->ApplyGridF(secondPoint);
+
+	// Lock to guides.
+	double firstX = first.x();
+	double firstY = first.y();
+	m_doc->ApplyGuides(&firstX, &firstY);
+
+	double secondX = second.x();
+	double secondY = second.y();
+	m_doc->ApplyGuides(&secondX, &secondY);
+
+	// Return normalized rectangle.
+	FRect rect(firstX, firstY, secondX - firstX, secondY - firstY);
+
+	return rect.normalize();
 }
 
 // void CreateMode::setResizeCursor(int how)

Modified: trunk/Scribus/scribus/canvasmode_create.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_create.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_create.h (original)
+++ trunk/Scribus/scribus/canvasmode_create.h Fri Sep 23 21:47:57 2011
@@ -20,6 +20,7 @@
 
 #include "canvasmode.h"
 #include "fpointarray.h"
+#include "text/frect.h"
 
 class PageItem;
 class ScribusMainWindow;
@@ -32,7 +33,8 @@
 class CreateMode : public CanvasMode
 {
 public:
-	CreateMode(ScribusView* view);
+	explicit CreateMode(ScribusView* view);
+	virtual ~CreateMode() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);
@@ -60,6 +62,16 @@
 	// for the pure sake of not including pageitem.h
 	void getFrameItemTypes(int& itemType, int& frameType);
 
+	/**
+	 * Convenience function which given two points calculates and returns the
+	 * normalized rectangle between the two points, adjusted to grid and guides.
+	 *
+	 * @param firstPoint the first point
+	 * @param secondPoint the second point
+	 * @return a normalized rectangle adjusted to grid and guides
+	 */
+	FRect adjustedRect(FPoint &firstPoint, FPoint &secondPoint);
+
 	bool   inItemCreation;
 	bool   m_MouseButtonPressed;
 	FPoint mouseGlobalCoord;

Modified: trunk/Scribus/scribus/canvasmode_drawbezier.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_drawbezier.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawbezier.h (original)
+++ trunk/Scribus/scribus/canvasmode_drawbezier.h Fri Sep 23 21:47:57 2011
@@ -32,7 +32,8 @@
 class BezierMode : public CanvasMode
 {
 public:
-	BezierMode(ScribusView* view);
+	explicit BezierMode(ScribusView* view);
+	virtual ~BezierMode() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp Fri Sep 23 21:47:57 2011
@@ -173,7 +173,7 @@
 			newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
 			SeRx = newX;
 			SeRy = newY;
-			QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
+			QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable || m_doc->appMode == modeDrawTable2 ? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
 			m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
 			if (!m_view->redrawMarker->isVisible())
 				m_view->redrawMarker->show();

Modified: trunk/Scribus/scribus/canvasmode_drawcalligraphic.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_drawcalligraphic.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawcalligraphic.h (original)
+++ trunk/Scribus/scribus/canvasmode_drawcalligraphic.h Fri Sep 23 21:47:57 2011
@@ -32,7 +32,8 @@
 class CalligraphicMode : public CanvasMode
 {
 public:
-	CalligraphicMode(ScribusView* view);
+	explicit CalligraphicMode(ScribusView* view);
+	virtual ~CalligraphicMode() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_drawfreehand.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_drawfreehand.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawfreehand.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_drawfreehand.cpp Fri Sep 23 21:47:57 2011
@@ -161,7 +161,7 @@
 			newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
 			SeRx = newX;
 			SeRy = newY;
-			QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
+			QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable || m_doc->appMode == modeDrawTable2 ? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
 			m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
 			if (!m_view->redrawMarker->isVisible())
 				m_view->redrawMarker->show();

Modified: trunk/Scribus/scribus/canvasmode_drawfreehand.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_drawfreehand.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawfreehand.h (original)
+++ trunk/Scribus/scribus/canvasmode_drawfreehand.h Fri Sep 23 21:47:57 2011
@@ -32,7 +32,8 @@
 class FreehandMode : public CanvasMode
 {
 public:
-	FreehandMode(ScribusView* view);
+	explicit FreehandMode(ScribusView* view);
+	virtual ~FreehandMode() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp Fri Sep 23 21:47:57 2011
@@ -25,6 +25,7 @@
 #include <QMouseEvent>
 #include <QPainterPath>
 #include <QPoint>
+#include <QPointF>
 #include <QRect>
 #include <QTimer>
 #include <QWidgetAction>
@@ -232,144 +233,7 @@
 // 		qDebug()<<dbgString;
 // 		qDebug()<<"==============================================================";
 		// end debug
-		double dx, dy, dy1;
-		QPen cPen ( Qt::black, 1.5 , Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin );
-		cPen.setCosmetic(true); // #10049 : make cursor line width constant on screen
-
-		// normalize Current Position
-		textframe->itemText.normalizeCursorPosition();
-		int textCursorPos ( textframe->itemText.cursorPosition() );
-
-		if ( textframe->lastInFrame() >= signed ( textframe->itemText.nrOfItems() )
-		        || textframe->itemText.length() == 0 )
-		{
-			dx = textframe->textToFrameDistLeft();
-			dy = textframe->textToFrameDistTop();
-			dy1 = textframe->textToFrameDistTop() + (textframe->itemText.defaultStyle().charStyle().fontSize() / 10.0);
-
-			cPen.setColor ( ScColorEngine::getRGBColor ( m_doc->PageColors[textframe->itemText.defaultStyle().charStyle().fillColor() ], m_doc ) );
-		}
-		else if ( textCursorPos > textframe->lastInFrame() )
-		{
-			// Happens often when typing directly into frame.
-			// And the cursor curses nothing, vertigo.
-			textCursorPos = qMax(0, textframe->lastInFrame());
-			QChar textCursorChar = textframe->itemText.text(textCursorPos);
-			if (textCursorChar == SpecialChars::PARSEP || textCursorChar == SpecialChars::LINEBREAK)
-			{
-				// The cursor must be moved to the beginning of the next line
-				FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
-				double lineSpacing(textframe->itemText.paragraphStyle(textCursorPos).lineSpacing());
-				
-				// take care if cursor is not in first column
-				int curCol(1);
-				double ccPos(textframe->itemText.boundingBox ( textCursorPos ).x());
-				double leftOffset(textframe->textToFrameDistLeft());
-				for(int ci(1); ci <= textframe->columns(); ++ci)
-				{
-					double cLeft(((ci-1) * textframe->columnWidth()) + ((ci -1) * textframe->columnGap()) + leftOffset);
-					double cRight((ci * textframe->columnWidth()) + ((ci -1) * textframe->columnGap()) + leftOffset);
-					if((cLeft <= ccPos) && (ccPos <= cRight))
-					{
-						curCol = ci;
-						break;
-					}
-				}
-				dx = (textframe->columnWidth() * (curCol - 1)) + (textframe->columnGap() * (curCol - 1))  + leftOffset;
-				dy = bbox.y();
-				
-				if ( bbox.height() <= 2 )
-					dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0;
-				else
-					dy1 = bbox.y() + bbox.height();
-				
-				dy  += lineSpacing;
-				dy1 += lineSpacing;
-			}
-			else if (textCursorChar == SpecialChars::COLBREAK)
-			{
-				// A bit tricky :)
-				// We want to position the cursor at the beginning of the next column, if any.
-				// At first we need to know in which column the cursor is.
-				int curCol(1);
-				double ccPos(textframe->itemText.boundingBox ( textCursorPos ).x());
-				double leftOffset(textframe->textToFrameDistLeft());
-				for(int ci(1); ci <= textframe->columns(); ++ci)
-				{
-					double cLeft(((ci-1) * textframe->columnWidth()) + ((ci -1) * textframe->columnGap()) + leftOffset);
-					double cRight((ci * textframe->columnWidth()) + ((ci -1) * textframe->columnGap()) + leftOffset);
-					if((cLeft <= ccPos) && (ccPos <= cRight))
-					{
-						curCol = ci;
-						break;
-					}
-				}
-				if(textframe->columns() > curCol)
-				{
-					dx = (textframe->columnWidth() * curCol) + (textframe->columnGap() * curCol)  + leftOffset;
-					dy = textframe->textToFrameDistTop();
-					dy1 = textframe->textToFrameDistTop() + textframe->itemText.boundingBox ( textCursorPos ).height();
-				}
-				else // there is no column after the current column
-				{
-					FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
-					dx = bbox.x();
-					dy = bbox.y();
-					dx += textframe->itemText.item ( textCursorPos )->glyph.wide();
-					if ( bbox.height() <= 2 )
-						dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0;
-					else
-						dy1 = bbox.y() + bbox.height();
-				}
-			}
-			else
-			{
-				FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
-				dx = bbox.x();
-				dy = bbox.y();
-				dx += textframe->itemText.item ( textCursorPos )->glyph.wide();
-				if ( bbox.height() <= 2 )
-					dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0;
-				else
-					dy1 = bbox.y() + bbox.height();
-	
-			}
-			cPen.setColor ( ScColorEngine::getRGBColor ( m_doc->PageColors[textframe->itemText.charStyle ( textCursorPos ).fillColor() ], m_doc ) );
-		}
-		else
-		{
-			FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
-			dx = bbox.x();
-			dy = bbox.y();
-			if ( bbox.height() <= 2 )
-				dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0;
-			else
-				dy1 = bbox.y() + bbox.height();
-
-			cPen.setColor ( ScColorEngine::getRGBColor ( m_doc->PageColors[textframe->itemText.charStyle ( textCursorPos ).fillColor() ], m_doc ) );
-		}
-		//handle Right to Left writing
-		if ( textframe->reversed() )
-		{
-			dx=textframe->width()-dx;
-		}
-
-		p->save();
-		p->translate ( textframe->xPos(), textframe->yPos() );
-		p->rotate ( textframe->rotation() );
-
-
-		p->setPen ( cPen );
-		p->setRenderHint ( QPainter::Antialiasing, true );
-		// avoid displaying the cursor on the frameborder
-		dx = qMax ( ( cPen.widthF() / 2.0 ), dx );
-
-		dy =  qMin ( qMax ( dy,0.0 ) , textframe->height() );
-		dy1 = qMin ( qMax ( dy1,0.0 ), textframe->height() );
-
-		p->drawLine ( QLineF ( dx,dy,dx,dy1 ) );
-
-		p->restore();
+		commonDrawTextCursor(p, textframe, QPointF());
 	}
 }
 

Modified: trunk/Scribus/scribus/canvasmode_edit.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_edit.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.h (original)
+++ trunk/Scribus/scribus/canvasmode_edit.h Fri Sep 23 21:47:57 2011
@@ -37,7 +37,8 @@
 	Q_OBJECT
 	
 public:
-	CanvasMode_Edit(ScribusView* view);
+	explicit CanvasMode_Edit(ScribusView* view);
+	virtual ~CanvasMode_Edit() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_editarc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_editarc.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editarc.h (original)
+++ trunk/Scribus/scribus/canvasmode_editarc.h Fri Sep 23 21:47:57 2011
@@ -41,7 +41,8 @@
 {	
 	Q_OBJECT
 public:
-	CanvasMode_EditArc(ScribusView* view);
+	explicit CanvasMode_EditArc(ScribusView* view);
+	virtual ~CanvasMode_EditArc() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_editgradient.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_editgradient.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editgradient.h (original)
+++ trunk/Scribus/scribus/canvasmode_editgradient.h Fri Sep 23 21:47:57 2011
@@ -35,7 +35,8 @@
 class CanvasMode_EditGradient :  public CanvasMode
 {	
 public:
-	CanvasMode_EditGradient(ScribusView* view);
+	explicit CanvasMode_EditGradient(ScribusView* view);
+	virtual ~CanvasMode_EditGradient() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_editmeshgradient.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_editmeshgradient.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editmeshgradient.h (original)
+++ trunk/Scribus/scribus/canvasmode_editmeshgradient.h Fri Sep 23 21:47:57 2011
@@ -40,7 +40,8 @@
 class CanvasMode_EditMeshGradient :  public CanvasMode
 {	
 public:
-	CanvasMode_EditMeshGradient(ScribusView* view);
+	explicit CanvasMode_EditMeshGradient(ScribusView* view);
+	virtual ~CanvasMode_EditMeshGradient() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_editpolygon.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_editpolygon.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editpolygon.h (original)
+++ trunk/Scribus/scribus/canvasmode_editpolygon.h Fri Sep 23 21:47:57 2011
@@ -41,7 +41,8 @@
 {
 	Q_OBJECT
 public:
-	CanvasMode_EditPolygon(ScribusView* view);
+	explicit CanvasMode_EditPolygon(ScribusView* view);
+	virtual ~CanvasMode_EditPolygon() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_editspiral.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_editspiral.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editspiral.h (original)
+++ trunk/Scribus/scribus/canvasmode_editspiral.h Fri Sep 23 21:47:57 2011
@@ -41,7 +41,8 @@
 {	
 	Q_OBJECT
 public:
-	CanvasMode_EditSpiral(ScribusView* view);
+	explicit CanvasMode_EditSpiral(ScribusView* view);
+	virtual ~CanvasMode_EditSpiral() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_eyedropper.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_eyedropper.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_eyedropper.h (original)
+++ trunk/Scribus/scribus/canvasmode_eyedropper.h Fri Sep 23 21:47:57 2011
@@ -27,7 +27,8 @@
 class CanvasMode_EyeDropper :  public CanvasMode
 {
 public:
-	CanvasMode_EyeDropper(ScribusView* view);
+	explicit CanvasMode_EyeDropper(ScribusView* view);
+	virtual ~CanvasMode_EyeDropper() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_framelinks.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_framelinks.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_framelinks.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_framelinks.cpp Fri Sep 23 21:47:57 2011
@@ -132,7 +132,7 @@
 		/*
 		m_view->redrawMarker->setGeometry(QRect(Mxp, Myp, m->globalPos().x() - Mxp, m->globalPos().y() - Myp).normalized());
 		*/
-		QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
+		QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable || m_doc->appMode == modeDrawTable2 ? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
 		m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
 		if (!m_view->redrawMarker->isVisible())
 			m_view->redrawMarker->show();

Modified: trunk/Scribus/scribus/canvasmode_framelinks.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_framelinks.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_framelinks.h (original)
+++ trunk/Scribus/scribus/canvasmode_framelinks.h Fri Sep 23 21:47:57 2011
@@ -38,7 +38,8 @@
 class CanvasMode_FrameLinks :  public CanvasMode
 {
 public:
-	CanvasMode_FrameLinks(ScribusView* view);
+	explicit CanvasMode_FrameLinks(ScribusView* view);
+	virtual ~CanvasMode_FrameLinks() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_magnifier.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_magnifier.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_magnifier.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_magnifier.cpp Fri Sep 23 21:47:57 2011
@@ -131,7 +131,7 @@
 		/*
 		m_view->redrawMarker->setGeometry(QRect(Mxp, Myp, m->globalPos().x() - Mxp, m->globalPos().y() - Myp).normalized());
 		*/
-		QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
+		QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable || m_doc->appMode == modeDrawTable2 ? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
 		m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
 		if (!m_view->redrawMarker->isVisible())
 			m_view->redrawMarker->show();

Modified: trunk/Scribus/scribus/canvasmode_magnifier.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_magnifier.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_magnifier.h (original)
+++ trunk/Scribus/scribus/canvasmode_magnifier.h Fri Sep 23 21:47:57 2011
@@ -37,7 +37,8 @@
 class CanvasMode_Magnifier :  public CanvasMode
 {
 public:
-	CanvasMode_Magnifier(ScribusView* view);
+	explicit CanvasMode_Magnifier(ScribusView* view);
+	virtual ~CanvasMode_Magnifier() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_measurements.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_measurements.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_measurements.h (original)
+++ trunk/Scribus/scribus/canvasmode_measurements.h Fri Sep 23 21:47:57 2011
@@ -35,7 +35,8 @@
 	Q_OBJECT
 	
 public:
-	MeasurementsMode(ScribusView* view);
+	explicit MeasurementsMode(ScribusView* view);
+	virtual ~MeasurementsMode() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_nodeedit.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_nodeedit.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_nodeedit.h (original)
+++ trunk/Scribus/scribus/canvasmode_nodeedit.h Fri Sep 23 21:47:57 2011
@@ -32,7 +32,7 @@
 class SCRIBUS_API CanvasMode_NodeEdit : public CanvasMode
 {
 public:
-	CanvasMode_NodeEdit (ScribusView* view);
+	explicit CanvasMode_NodeEdit (ScribusView* view);
 	
 	virtual void activate(bool fromgesture);
 	virtual void deactivate(bool forGesture);

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Fri Sep 23 21:47:57 2011
@@ -255,6 +255,11 @@
 		else if (currItem->asSpiral())
 		{
 			m_view->requestMode(modeEditSpiral);
+		}
+		else if (currItem->asTable())
+		{
+			m_view->requestMode(modeEditTable);
+			m_view->slotSetCurs(m->globalPos().x(), m->globalPos().y());
 		}
 	}
 }

Modified: trunk/Scribus/scribus/canvasmode_normal.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_normal.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.h (original)
+++ trunk/Scribus/scribus/canvasmode_normal.h Fri Sep 23 21:47:57 2011
@@ -39,7 +39,8 @@
 	Q_OBJECT
 	
 public:
-	CanvasMode_Normal(ScribusView* view);
+	explicit CanvasMode_Normal(ScribusView* view);
+	virtual ~CanvasMode_Normal() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_objimport.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_objimport.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_objimport.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_objimport.cpp Fri Sep 23 21:47:57 2011
@@ -48,7 +48,7 @@
 	m_trSettings = NULL;
 }
 
-CanvasMode_ObjImport::~CanvasMode_ObjImport(void)
+CanvasMode_ObjImport::~CanvasMode_ObjImport()
 {
 	if (m_mimeData)
 		delete m_mimeData;

Modified: trunk/Scribus/scribus/canvasmode_objimport.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_objimport.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_objimport.h (original)
+++ trunk/Scribus/scribus/canvasmode_objimport.h Fri Sep 23 21:47:57 2011
@@ -35,8 +35,8 @@
 class CanvasMode_ObjImport :  public CanvasMode
 {
 public:
-	CanvasMode_ObjImport(ScribusView* view);
-	~CanvasMode_ObjImport(void);
+	explicit CanvasMode_ObjImport(ScribusView* view);
+	virtual ~CanvasMode_ObjImport();
 
 	void setMimeData(QMimeData* mimeData);
 	void setTransactionSettings(TransactionSettings* settings);

Modified: trunk/Scribus/scribus/canvasmode_panning.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_panning.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_panning.h (original)
+++ trunk/Scribus/scribus/canvasmode_panning.h Fri Sep 23 21:47:57 2011
@@ -34,7 +34,8 @@
 class CanvasMode_Panning :  public CanvasMode
 {
 public:
-	CanvasMode_Panning(ScribusView* view);
+	explicit CanvasMode_Panning(ScribusView* view);
+	virtual ~CanvasMode_Panning() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/canvasmode_rotate.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/canvasmode_rotate.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_rotate.h (original)
+++ trunk/Scribus/scribus/canvasmode_rotate.h Fri Sep 23 21:47:57 2011
@@ -35,7 +35,8 @@
 class SCRIBUS_API CanvasMode_Rotate : public CanvasMode
 {
 public:
-	CanvasMode_Rotate(ScribusView* view);
+	explicit CanvasMode_Rotate(ScribusView* view);
+	virtual ~CanvasMode_Rotate() {}
 
 	virtual void enterEvent(QEvent *);
 	virtual void leaveEvent(QEvent *);

Modified: trunk/Scribus/scribus/commonstrings.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/commonstrings.cpp
==============================================================================
--- trunk/Scribus/scribus/commonstrings.cpp (original)
+++ trunk/Scribus/scribus/commonstrings.cpp Fri Sep 23 21:47:57 2011
@@ -104,9 +104,13 @@
 QString CommonStrings::DefaultParagraphStyle     ="";
 QString CommonStrings::DefaultCharacterStyle     ="";
 QString CommonStrings::DefaultLineStyle          ="";
+QString CommonStrings::DefaultTableStyle         ="";
+QString CommonStrings::DefaultCellStyle          ="";
 QString CommonStrings::trDefaultParagraphStyle   ="";
 QString CommonStrings::trDefaultCharacterStyle   ="";
 QString CommonStrings::trDefaultLineStyle        ="";
+QString CommonStrings::trDefaultTableStyle       ="";
+QString CommonStrings::trDefaultCellStyle        ="";
 
 
 QString CommonStrings::monday="", CommonStrings::tuesday="", CommonStrings::wednesday="";

Modified: trunk/Scribus/scribus/commonstrings.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/commonstrings.h
==============================================================================
--- trunk/Scribus/scribus/commonstrings.h (original)
+++ trunk/Scribus/scribus/commonstrings.h Fri Sep 23 21:47:57 2011
@@ -171,9 +171,13 @@
 	static QString DefaultParagraphStyle;
 	static QString DefaultCharacterStyle;
 	static QString DefaultLineStyle;
+	static QString DefaultTableStyle;
+	static QString DefaultCellStyle;
 	static QString trDefaultParagraphStyle;
 	static QString trDefaultCharacterStyle;
 	static QString trDefaultLineStyle;
+	static QString trDefaultTableStyle;
+	static QString trDefaultCellStyle;
 
 	//Days and Months
 	static QString monday;

Modified: trunk/Scribus/scribus/fpoint.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/fpoint.h
==============================================================================
--- trunk/Scribus/scribus/fpoint.h (original)
+++ trunk/Scribus/scribus/fpoint.h Fri Sep 23 21:47:57 2011
@@ -26,6 +26,7 @@
 
 #include <QTransform>
 #include <QPoint>
+#include <QPointF>
 #include "scribusapi.h"
 /**
   *@author Franz Schmid
@@ -61,6 +62,8 @@
 	//Transform an existing point, return a new one
 	FPoint transformPoint(const QTransform& m, const bool invert) const;
 	FPoint transformPoint(const double dx, const double dy, const double rot, const double sx, const double sy, const bool invert) const;
+	/// Returns a copy of the point as a QPointF.
+	QPointF toQPointF() const { return QPointF(xp, yp); }
 	friend class FPointArray;
 
 private:

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Fri Sep 23 21:47:57 2011
@@ -28,6 +28,7 @@
 #include <QFont>
 #include <QRegion>
 #include <QPoint>
+#include <QPointF>
 #include <QFileInfo>
 #include <qdrawutil.h>
 #include <QRegExp>
@@ -570,6 +571,10 @@
 		AnName = tr("Spiral");
 		setUPixmap(Um::IPolygon);
 		break;
+	case Table:
+		AnName = tr("Table");
+		//setUPixmap(Um::IPolygon); // TODO: Fix this.
+		break;
 	default:
 		AnName = "Item";
 		break;
@@ -1102,6 +1107,39 @@
 	//and has been linked with previous frame
 	//if you will find any better solution - fix that function
 	return (firstInFrame() > lastInFrame());
+}
+
+void PageItem::drawOverflowMarker(ScPainter *p)
+{
+	qreal sideLength = 10 / qMax(p->zoomFactor(), 1.0);
+	qreal offset = 1 / qMax(p->zoomFactor(), 1.0);
+	qreal left = Width - sideLength-offset;// / 2;
+	qreal right = left + sideLength;
+	qreal top = Height - sideLength-offset;// * 1.5;
+	qreal bottom = top + sideLength;
+
+	QColor color(PrefsManager::instance()->appPrefs.displayPrefs.frameNormColor);
+	if ((isBookmark) || (m_isAnnotation))
+		color = PrefsManager::instance()->appPrefs.displayPrefs.frameAnnotationColor;
+	if ((BackBox != 0) || (NextBox != 0))
+		color = PrefsManager::instance()->appPrefs.displayPrefs.frameLinkColor;
+	if (m_Locked)
+		color = PrefsManager::instance()->appPrefs.displayPrefs.frameLockColor;
+	if (m_Doc->m_Selection->containsItem(this))
+		color = Qt::red;
+
+	p->save();
+
+	p->setPen(color, 0.5 / p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+	p->setPenOpacity(1.0);
+	p->setBrush(Qt::white);
+	p->setBrushOpacity(1.0);
+	p->setFillMode(ScPainter::Solid);
+	p->drawRect(left, top, sideLength, sideLength);
+	p->drawLine(QPointF(left, top), QPointF(right, bottom));
+	p->drawLine(QPointF(left, bottom), QPointF(right, top));
+
+	p->restore();
 }
 
 int PageItem::firstInFrame() const
@@ -1635,7 +1673,8 @@
 			p->setBlendModeFill(0);
 	#endif
 			p->setMaskMode(0);
-			if (itemType()==PathText || itemType()==PolyLine || itemType()==Spiral || itemType()==Line || itemType()==Symbol || itemType()==Group)
+			// TODO: Investigate whether itemType()==Table should really be here. I got artifacts without it so keeping it here for now. /estan
+			if (itemType()==PathText || itemType()==PolyLine || itemType()==Spiral || itemType()==Line || itemType()==Symbol || itemType()==Group || itemType()==Table)
 				doStroke=false;
 			if ((doStroke) && (!m_Doc->RePos))
 			{

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Fri Sep 23 21:47:57 2011
@@ -70,6 +70,7 @@
 class PageItem_Polygon;
 class PageItem_PolyLine;
 class PageItem_RegularPolygon;
+class PageItem_Table;
 class PageItem_TextFrame;
 class PageItem_PathText;
 class PageItem_LatexFrame;
@@ -172,6 +173,7 @@
 		RegularPolygon	= 13,
 		Arc				= 14,
 		Spiral			= 15,
+		Table			= 16,
 		Multiple		= 99
 	};
 
@@ -202,6 +204,7 @@
 	virtual PageItem_RegularPolygon * asRegularPolygon() { return NULL; }
 	virtual PageItem_Arc * asArc() { return NULL; }
 	virtual PageItem_Spiral * asSpiral() { return NULL; }
+	virtual PageItem_Table * asTable() { return NULL; }
 
 	virtual bool isImageFrame()		const { return false; }
 	virtual bool isLine()			const { return false; }
@@ -216,6 +219,7 @@
 	virtual bool isRegularPolygon()	const { return false; }
 	virtual bool isArc()			const { return false; }
 	virtual bool isSpiral()			const { return false; }
+	virtual bool isTable()			const { return false; }
 
 	/** @brief Frame Type
 	 *
@@ -352,6 +356,8 @@
 	bool frameOverflows() const;
 	bool frameUnderflows() const;
 	int frameOverflowCount() const;
+	/// Draws the overflow marker.
+	void drawOverflowMarker(ScPainter *p);
 	/// returns index of first char displayed in this frame, used to be 0
 	int firstInFrame() const;
 	/// returns index of last char displayed in this frame, used to be MaxChars-1

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Fri Sep 23 21:47:57 2011
@@ -2381,7 +2381,7 @@
 					if (!m_Doc->RePos)
 					{
 						if (((selecteds && Select) || ((NextBox != 0 || BackBox != 0) && selecteds))
-							&& (m_Doc->appMode == modeEdit))
+							&& (m_Doc->appMode == modeEdit || m_Doc->appMode == modeEditTable))
 						{
 							double xcoZli = selX + hls->glyph.xoffset;
 							desc = - charStyleS.font().descent(charStyleS.fontSize() / 10.0);
@@ -2464,7 +2464,7 @@
 				{
 					desc = - charStyle.font().descent(charStyle.fontSize() / 10.0);
 					asce = charStyle.font().ascent(charStyle.fontSize() / 10.0);
-					if (((selected && Select) || ((NextBox != 0 || BackBox != 0) && selected)) && (m_Doc->appMode == modeEdit))
+					if (((selected && Select) || ((NextBox != 0 || BackBox != 0) && selected)) && (m_Doc->appMode == modeEdit || m_Doc->appMode == modeEditTable))
 					{
 						// set text color to highlight if its selected
 						p->setBrush(qApp->palette().color(QPalette::Active, QPalette::HighlightedText));
@@ -3466,6 +3466,7 @@
 //	return (Width - (ColGap * (Cols - 1)) - Extra - RExtra - lineCorr) / Cols;
 }
 
+/*
 void PageItem_TextFrame::drawOverflowMarker(ScPainter *p)
 {
 	qreal sideLength = 10 / qMax(p->zoomFactor(), 1.0);
@@ -3493,6 +3494,7 @@
 	p->drawLine(FPoint(left, top), FPoint(right, bottom));
 	p->drawLine(FPoint(left, bottom), FPoint(right, top));
 }
+*/
 
 void PageItem_TextFrame::drawColumnBorders(ScPainter *p)
 {

Modified: trunk/Scribus/scribus/pageitem_textframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/pageitem_textframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.h (original)
+++ trunk/Scribus/scribus/pageitem_textframe.h Fri Sep 23 21:47:57 2011
@@ -81,7 +81,7 @@
 	virtual void DrawObj_Item(ScPainter *p, QRectF e);
 	virtual void DrawObj_Post(ScPainter *p);
 	virtual void DrawObj_Decoration(ScPainter *p);
-	void drawOverflowMarker(ScPainter *p);
+	//void drawOverflowMarker(ScPainter *p);
 	void drawUnderflowMarker(ScPainter *p);
 	void drawColumnBorders(ScPainter *p);
 	QRegion availableRegion(QRegion clip);

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Fri Sep 23 21:47:57 2011
@@ -3399,6 +3399,13 @@
 		if (pagenr > -2) 
 			currItem->OwnPage = pagenr;
 		break;
+	case PageItem::Table:
+		// TODO: Actually handle pasting of tables properly.
+		z = doc->itemAdd(PageItem::Table, PageItem::Unspecified, x, y, w, h, 0.0, CommonStrings::None, CommonStrings::None, true);
+		currItem = doc->Items->at(z);
+		if (pagenr > -2)
+			currItem->OwnPage = pagenr;
+		break;
 	case PageItem::Line:
 		z = doc->itemAdd(PageItem::Line, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor2, true);
 		currItem = doc->Items->at(z);

Modified: trunk/Scribus/scribus/plugins/scriptplugin/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/plugins/scriptplugin/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/CMakeLists.txt Fri Sep 23 21:47:57 2011
@@ -23,6 +23,7 @@
 )
 
 SET(SCRIPTER_PLUGIN_SOURCES
+  cmdcell.cpp
   cmdcolor.cpp
   cmddialog.cpp
   cmddoc.cpp
@@ -34,6 +35,7 @@
   cmdpage.cpp
   cmdsetprop.cpp
   cmdstyle.cpp
+  cmdtable.cpp
   cmdtext.cpp
   cmdutil.cpp
   guiapp.cpp

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp Fri Sep 23 21:47:57 2011
@@ -11,6 +11,7 @@
 #include "commonstrings.h"
 #include "scribuscore.h"
 #include "scribusdoc.h"
+#include "pageitem_table.h"
 
 PyObject *scribus_newrect(PyObject* /* self */, PyObject* args)
 {
@@ -116,6 +117,43 @@
 			ScCore->primaryMainWindow()->doc->Items->at(i)->setItemName(objName);
 	}
 	return PyString_FromString(ScCore->primaryMainWindow()->doc->Items->at(i)->itemName().toUtf8());
+}
+
+PyObject *scribus_newtable(PyObject* /* self */, PyObject* args)
+{
+	double x, y, w, h;
+	int numRows, numColumns;
+	char *Name = const_cast<char*>("");
+	if (!PyArg_ParseTuple(args, "ddddii|es", &x, &y, &w, &h, &numRows, &numColumns, "utf-8", &Name))
+		return NULL;
+	if (!checkHaveDocument())
+		return NULL;
+	if (numRows < 1 || numColumns < 1)
+	{
+		PyErr_SetString(PyExc_ValueError, QObject::tr("Both numRows and numColumns must be greater than 0.","python error").toLocal8Bit().constData());
+		return NULL;
+	}
+	int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::Table, PageItem::Unspecified,
+								pageUnitXToDocX(x),
+								pageUnitYToDocY(y),
+								ValueToPoint(w),
+								ValueToPoint(h),
+								0,                    // Unused.
+								CommonStrings::None,  // Unused.
+								CommonStrings::None,  // Unused.
+								true);
+	PageItem_Table *table = ScCore->primaryMainWindow()->doc->Items->at(i)->asTable();
+	table->insertRows(0, numRows - 1);
+	table->insertColumns(0, numColumns - 1);
+	table->adjustTableToFrame();
+	table->adjustFrameToTable();
+	if (Name != EMPTY_STRING)
+	{
+		QString objName = QString::fromUtf8(Name);
+		if (!ItemExists(objName))
+			ScCore->primaryMainWindow()->doc->Items->at(i)->setItemName(objName);
+	}
+	return PyString_FromString(table->itemName().toUtf8());
 }
 
 PyObject *scribus_newline(PyObject* /* self */, PyObject* args)
@@ -663,5 +701,5 @@
 void cmdobjdocwarnings()
 {
     QStringList s;
-    s << scribus_newrect__doc__ <<scribus_newellipse__doc__ << scribus_newimage__doc__ << scribus_newtext__doc__ << scribus_newline__doc__ <<scribus_polyline__doc__ << scribus_polygon__doc__ << scribus_bezierline__doc__ <<scribus_pathtext__doc__ <<scribus_deleteobj__doc__ <<scribus_textflow__doc__ <<scribus_objectexists__doc__ <<scribus_setstyle__doc__ <<scribus_getstylenames__doc__ <<scribus_duplicateobject__doc__;
-}
+	s << scribus_newrect__doc__ <<scribus_newellipse__doc__ << scribus_newimage__doc__ << scribus_newtext__doc__ << scribus_newtable__doc__ << scribus_newline__doc__ <<scribus_polyline__doc__ << scribus_polygon__doc__ << scribus_bezierline__doc__ <<scribus_pathtext__doc__ <<scribus_deleteobj__doc__ <<scribus_textflow__doc__ <<scribus_objectexists__doc__ <<scribus_setstyle__doc__ <<scribus_getstylenames__doc__ <<scribus_duplicateobject__doc__;
+}

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.h (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.h Fri Sep 23 21:47:57 2011
@@ -75,6 +75,22 @@
 "));
 /** Creates a text frame - x, y, b, h and opt. name. */
 PyObject *scribus_newtext(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
+PyDoc_STRVAR(scribus_newtable__doc__,
+QT_TR_NOOP("createTable(x, y, width, height, numRows, numColumns, [\"name\"]) -> string\n\
+\n\
+Creates a new table with the given number of rows and columns on the actual page\n\
+and returns its name. The coordinates are given in the actual measurement unit of\n\
+the document (see UNIT constants). \"name\" should be a unique identifier for\n\
+the object because you need this name for further referencing of that object. If\n\
+\"name\" is not given Scribus will create one for you.\n\
+\n\
+May raise NameExistsError if you explicitly pass a name that's already used.\n\
+May raise ValueError if an insufficient number of rows or columns is passed.\n\
+"));
+/** Creates a table - x, y, width, height, numRows, numColumns and opt. name. */
+PyObject *scribus_newtable(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
 PyDoc_STRVAR(scribus_newline__doc__,

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp Fri Sep 23 21:47:57 2011
@@ -9,6 +9,7 @@
 #include "scribuscore.h"
 #include "scribusdoc.h"
 #include "selection.h"
+#include "tableborder.h"
 #include "units.h"
 
 ScribusMainWindow* Carrier;
@@ -230,3 +231,51 @@
 	}
 	return true;
 }
+
+TableBorder parseBorder(PyObject* borderLines, bool* ok)
+{
+	TableBorder border;
+
+	if (!PyList_Check(borderLines))
+	{
+		PyErr_SetString(PyExc_ValueError, QObject::tr("Expected a list of border lines", "python error").toLocal8Bit().constData());
+		*ok = false;
+		return border;
+	}
+
+	// Get the sequence of border lines.
+	PyObject* borderLinesList = PySequence_List(borderLines);
+	if (borderLinesList == NULL)
+	{
+		PyErr_SetString(PyExc_ValueError, QObject::tr("Expected a list of border lines", "python error").toLocal8Bit().constData());
+		*ok = false;
+		return border;
+	}
+
+	// Parse each tuple decribing a border line and append it to the border.
+	int nBorderLines = PyList_Size(borderLinesList);
+	for (int i = 0; i < nBorderLines; i++) {
+		double width = 0.0;
+		int style;
+		char* color;
+		PyObject* props = PyList_GET_ITEM(borderLinesList, i);
+		if (!PyArg_ParseTuple(props, "dies", &width, &style, "utf-8", &color))
+		{
+			PyErr_SetString(PyExc_ValueError, QObject::tr("Border lines are specified as (width,style,color) tuples", "python error").toLocal8Bit().constData());
+			*ok = false;
+			return border;
+		}
+		if (width <= 0.0)
+		{
+			PyErr_SetString(PyExc_ValueError, QObject::tr("Border line width must be > 0.0", "python error").toLocal8Bit().constData());
+			*ok = false;
+			return border;
+		}
+		border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), QString::fromUtf8(color)));
+	}
+	Py_DECREF(borderLinesList);
+
+	*ok = true;
+	return border;
+}
+

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.h (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.h Fri Sep 23 21:47:57 2011
@@ -68,4 +68,8 @@
  */
 bool setSelectedItemsByName(QStringList& itemNames);
 
+/// Helper method to parse a border from a list of tuples.
+TableBorder parseBorder(PyObject* borderLines, bool* ok);
+
+
 #endif

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp Fri Sep 23 21:47:57 2011
@@ -23,6 +23,7 @@
 
 // include cmdvar.h first, as it pulls in <Python.h>
 #include "cmdvar.h"
+#include "cmdcell.h"
 #include "cmdcolor.h"
 #include "cmddialog.h"
 #include "cmddoc.h"
@@ -33,6 +34,7 @@
 #include "cmdobj.h"
 #include "cmdpage.h"
 #include "cmdsetprop.h"
+#include "cmdtable.h"
 #include "cmdtext.h"
 #include "cmdutil.h"
 #include "cmdstyle.h"
@@ -314,6 +316,7 @@
 	{const_cast<char*>("createPolyLine"), scribus_polyline, METH_VARARGS, tr(scribus_polyline__doc__)},
 	{const_cast<char*>("createRect"), scribus_newrect, METH_VARARGS, tr(scribus_newrect__doc__)},
 	{const_cast<char*>("createText"), scribus_newtext, METH_VARARGS, tr(scribus_newtext__doc__)},
+	{const_cast<char*>("createTable"), scribus_newtable, METH_VARARGS, tr(scribus_newtable__doc__)},
 	{const_cast<char*>("createParagraphStyle"), (PyCFunction)scribus_createparagraphstyle, METH_KEYWORDS, tr(scribus_createparagraphstyle__doc__)},
 	{const_cast<char*>("createCharStyle"), (PyCFunction)scribus_createcharstyle, METH_KEYWORDS, tr(scribus_createcharstyle__doc__)},
 	{const_cast<char*>("currentPage"), (PyCFunction)scribus_actualpage, METH_NOARGS, tr(scribus_actualpage__doc__)},
@@ -336,6 +339,10 @@
 	{const_cast<char*>("getAllObjects"), scribus_getallobj, METH_VARARGS, tr(scribus_getallobj__doc__)},
 	{const_cast<char*>("getAllStyles"), (PyCFunction)scribus_getstylenames, METH_NOARGS, tr(scribus_getstylenames__doc__)},
 	{const_cast<char*>("getAllText"), scribus_gettext, METH_VARARGS, tr(scribus_gettext__doc__)},
+	{const_cast<char*>("getCellStyle"), scribus_getcellstyle, METH_VARARGS, tr(scribus_getcellstyle__doc__)},
+	{const_cast<char*>("getCellColumnSpan"), scribus_getcellcolumnspan, METH_VARARGS, tr(scribus_getcellcolumnspan__doc__)},
+	{const_cast<char*>("getCellRowSpan"), scribus_getcellrowspan, METH_VARARGS, tr(scribus_getcellrowspan__doc__)},
+	{const_cast<char*>("getCellFillColor"), scribus_getcellfillcolor, METH_VARARGS, tr(scribus_getcellfillcolor__doc__)},
 	{const_cast<char*>("getColorNames"), (PyCFunction)scribus_colornames, METH_NOARGS, tr(scribus_colornames__doc__)},
 	{const_cast<char*>("getColor"), scribus_getcolor, METH_VARARGS, tr(scribus_getcolor__doc__)},
 	{const_cast<char*>("getColorAsRGB"), scribus_getcolorasrgb, METH_VARARGS, tr(scribus_getcolorasrgb__doc__)},
@@ -380,6 +387,12 @@
 	{const_cast<char*>("getObjectType"), scribus_getobjecttype, METH_VARARGS, tr(scribus_getobjecttype__doc__)},
 	{const_cast<char*>("getSelectedObject"), scribus_getselobjnam, METH_VARARGS, tr(scribus_getselobjnam__doc__)},
 	{const_cast<char*>("getSize"), scribus_getsize, METH_VARARGS, tr(scribus_getsize__doc__)},
+	{const_cast<char*>("getTableRows"), scribus_gettablerows, METH_VARARGS, tr(scribus_gettablerows__doc__)},
+	{const_cast<char*>("getTableRowHeight"), scribus_gettablerowheight, METH_VARARGS, tr(scribus_gettablerowheight__doc__)},
+	{const_cast<char*>("getTableColumns"), scribus_gettablecolumns, METH_VARARGS, tr(scribus_gettablecolumns__doc__)},
+	{const_cast<char*>("getTableColumnWidth"), scribus_gettablecolumnwidth, METH_VARARGS, tr(scribus_gettablecolumnwidth__doc__)},
+	{const_cast<char*>("getTableStyle"), scribus_gettablestyle, METH_VARARGS, tr(scribus_gettablestyle__doc__)},
+	{const_cast<char*>("getTableFillColor"), scribus_gettablefillcolor, METH_VARARGS, tr(scribus_gettablefillcolor__doc__)},
 	{const_cast<char*>("getTextColor"), scribus_getlinecolor, METH_VARARGS, tr(scribus_getlinecolor__doc__)},
 	{const_cast<char*>("getTextLength"), scribus_gettextsize, METH_VARARGS, tr(scribus_gettextsize__doc__)},
 	{const_cast<char*>("getTextLines"), scribus_gettextlines, METH_VARARGS, tr(scribus_gettextlines__doc__)},
@@ -396,6 +409,8 @@
 	{const_cast<char*>("placeEPS"), scribus_placevec, METH_VARARGS, tr(scribus_placeeps__doc__)},
 	{const_cast<char*>("placeSXD"), scribus_placevec, METH_VARARGS, tr(scribus_placesxd__doc__)},
 	{const_cast<char*>("placeODG"), scribus_placevec, METH_VARARGS, tr(scribus_placeodg__doc__)},
+	{const_cast<char*>("insertTableRows"), scribus_inserttablerows, METH_VARARGS, tr(scribus_inserttablerows__doc__)},
+	{const_cast<char*>("insertTableColumns"), scribus_inserttablecolumns, METH_VARARGS, tr(scribus_inserttablecolumns__doc__)},
 	{const_cast<char*>("insertText"), scribus_inserttext, METH_VARARGS, tr(scribus_inserttext__doc__)},
 	{const_cast<char*>("isLayerPrintable"), scribus_glayerprint, METH_VARARGS, tr(scribus_glayerprint__doc__)},
 	{const_cast<char*>("isLayerVisible"), scribus_glayervisib, METH_VARARGS, tr(scribus_glayervisib__doc__)},
@@ -408,6 +423,7 @@
 	{const_cast<char*>("loadStylesFromFile"), scribus_loadstylesfromfile, METH_VARARGS, tr(scribus_loadstylesfromfile__doc__)},
 	{const_cast<char*>("lockObject"), scribus_lockobject, METH_VARARGS, tr(scribus_lockobject__doc__)},
 	{const_cast<char*>("masterPageNames"), (PyCFunction)scribus_masterpagenames, METH_NOARGS, tr(scribus_masterpagenames__doc__)},
+	{const_cast<char*>("mergeTableCells"), scribus_mergetablecells, METH_VARARGS, tr(scribus_mergetablecells__doc__)},
 	{const_cast<char*>("messagebarText"), scribus_messagebartext, METH_VARARGS, tr(scribus_messagebartext__doc__)},
 	{const_cast<char*>("messageBox"), (PyCFunction)scribus_messdia, METH_VARARGS|METH_KEYWORDS, tr(scribus_messdia__doc__)},
 	{const_cast<char*>("moveObjectAbs"), scribus_moveobjabs, METH_VARARGS, tr(scribus_moveobjabs__doc__)},
@@ -425,8 +441,12 @@
 	{const_cast<char*>("progressSet"), scribus_progresssetprogress, METH_VARARGS, tr(scribus_progresssetprogress__doc__)},
 	{const_cast<char*>("progressTotal"), scribus_progresssettotalsteps, METH_VARARGS, tr(scribus_progresssettotalsteps__doc__)},
 	{const_cast<char*>("redrawAll"), (PyCFunction)scribus_redraw, METH_NOARGS, tr(scribus_redraw__doc__)},
+	{const_cast<char*>("removeTableRows"), scribus_removetablerows, METH_VARARGS, tr(scribus_removetablerows__doc__)},
+	{const_cast<char*>("removeTableColumns"), scribus_removetablecolumns, METH_VARARGS, tr(scribus_removetablecolumns__doc__)},
 	{const_cast<char*>("renderFont"), (PyCFunction)scribus_renderfont, METH_KEYWORDS, tr(scribus_renderfont__doc__)},
 	{const_cast<char*>("replaceColor"), scribus_replcolor, METH_VARARGS, tr(scribus_replcolor__doc__)},
+	{const_cast<char*>("resizeTableColumn"), scribus_resizetablecolumn, METH_VARARGS, tr(scribus_resizetablecolumn__doc__)},
+	{const_cast<char*>("resizeTableRow"), scribus_resizetablerow, METH_VARARGS, tr(scribus_resizetablerow__doc__)},
 	{const_cast<char*>("rotateObjectAbs"), scribus_rotobjabs, METH_VARARGS, tr(scribus_rotobjabs__doc__)},
 	{const_cast<char*>("rotateObject"), scribus_rotobjrel, METH_VARARGS, tr(scribus_rotobjrel__doc__)},
 	{const_cast<char*>("getDocName"), (PyCFunction)scribus_getdocname, METH_NOARGS, tr(scribus_getdocname__doc__)},
@@ -447,6 +467,17 @@
 	{const_cast<char*>("setPDFBookmark"), scribus_setpdfbookmark, METH_VARARGS, tr(scribus_setpdfbookmark__doc__)},
 	{const_cast<char*>("isPDFBookmark"), scribus_ispdfbookmark, METH_VARARGS, tr(scribus_ispdfbookmark__doc__)},
 	{const_cast<char*>("setTextDistances"), scribus_settextdistances, METH_VARARGS, tr(scribus_settextdistances__doc__)},
+	{const_cast<char*>("setCellStyle"), scribus_setcellstyle, METH_VARARGS, tr(scribus_setcellstyle__doc__)},
+	{const_cast<char*>("setCellText"), scribus_setcelltext, METH_VARARGS, tr(scribus_setcelltext__doc__)},
+	{const_cast<char*>("setCellFillColor"), scribus_setcellfillcolor, METH_VARARGS, tr(scribus_setcellfillcolor__doc__)},
+	{const_cast<char*>("setCellLeftBorder"), scribus_setcellleftborder, METH_VARARGS, tr(scribus_setcellleftborder__doc__)},
+	{const_cast<char*>("setCellLeftPadding"), scribus_setcellleftpadding, METH_VARARGS, tr(scribus_setcellleftpadding__doc__)},
+	{const_cast<char*>("setCellRightBorder"), scribus_setcellrightborder, METH_VARARGS, tr(scribus_setcellrightborder__doc__)},
+	{const_cast<char*>("setCellRightPadding"), scribus_setcellrightpadding, METH_VARARGS, tr(scribus_setcellrightpadding__doc__)},
+	{const_cast<char*>("setCellTopBorder"), scribus_setcelltopborder, METH_VARARGS, tr(scribus_setcelltopborder__doc__)},
+	{const_cast<char*>("setCellTopPadding"), scribus_setcelltoppadding, METH_VARARGS, tr(scribus_setcelltoppadding__doc__)},
+	{const_cast<char*>("setCellBottomBorder"), scribus_setcellbottomborder, METH_VARARGS, tr(scribus_setcellbottomborder__doc__)},
+	{const_cast<char*>("setCellBottomPadding"), scribus_setcellbottompadding, METH_VARARGS, tr(scribus_setcellbottompadding__doc__)},
 	{const_cast<char*>("setColumnGap"), scribus_setcolumngap, METH_VARARGS, tr(scribus_setcolumngap__doc__)},
 	{const_cast<char*>("setColumns"), scribus_setcolumns, METH_VARARGS, tr(scribus_setcolumns__doc__)},
 	{const_cast<char*>("setCornerRadius"), scribus_setcornerrad, METH_VARARGS, tr(scribus_setcornerrad__doc__)},
@@ -489,6 +520,12 @@
 	{const_cast<char*>("dehyphenateText"), scribus_dehyphenatetext, METH_VARARGS, tr(scribus_dehyphenatetext__doc__)},
 	{const_cast<char*>("setScaleImageToFrame"), (PyCFunction)scribus_setscaleimagetoframe, METH_KEYWORDS, tr(scribus_setscaleimagetoframe__doc__)},
 	{const_cast<char*>("setStyle"), scribus_setstyle, METH_VARARGS, tr(scribus_setstyle__doc__)},
+	{const_cast<char*>("setTableStyle"), scribus_settablestyle, METH_VARARGS, tr(scribus_settablestyle__doc__)},
+	{const_cast<char*>("setTableLeftBorder"), scribus_settableleftborder, METH_VARARGS, tr(scribus_settableleftborder__doc__)},
+	{const_cast<char*>("setTableRightBorder"), scribus_settablerightborder, METH_VARARGS, tr(scribus_settablerightborder__doc__)},
+	{const_cast<char*>("setTableTopBorder"), scribus_settabletopborder, METH_VARARGS, tr(scribus_settabletopborder__doc__)},
+	{const_cast<char*>("setTableBottomBorder"), scribus_settablebottomborder, METH_VARARGS, tr(scribus_settablebottomborder__doc__)},
+	{const_cast<char*>("setTableFillColor"), scribus_settablefillcolor, METH_VARARGS, tr(scribus_settablefillcolor__doc__)},
 	{const_cast<char*>("setTextAlignment"), scribus_setalign, METH_VARARGS, tr(scribus_setalign__doc__)},
 	{const_cast<char*>("setTextColor"), scribus_settextfill, METH_VARARGS, tr(scribus_settextfill__doc__)},
 	{const_cast<char*>("setText"), scribus_setboxtext, METH_VARARGS, tr(scribus_setboxtext__doc__)},

Modified: trunk/Scribus/scribus/resourcecollection.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/resourcecollection.h
==============================================================================
--- trunk/Scribus/scribus/resourcecollection.h (original)
+++ trunk/Scribus/scribus/resourcecollection.h Fri Sep 23 21:47:57 2011
@@ -22,6 +22,9 @@
 #include <QString>
 #include "vgradient.h"
 
+class ColorList;
+class SCFonts;
+
 /** 
 *   A simple structure which holds the names of all resources & styles used in a doc or part of a document.
 *   Also holds pointers to the doc's fontset and colorset.
@@ -45,6 +48,8 @@
 	void collectStyle(const QString& name)     { if (!name.isEmpty()) m_pstyles.insert(name,name); }
 	void collectCharStyle(const QString& name) { if (!name.isEmpty()) m_cstyles.insert(name,name); }
 	void collectLineStyle(const QString& name) { if (!name.isEmpty()) m_linestyles.insert(name,name); }
+	void collectTableStyle(const QString& name) { if (!name.isEmpty()) m_tableStyles.insert(name,name); }
+	void collectCellStyle(const QString& name) { if (!name.isEmpty()) m_cellStyles.insert(name,name); }
 	
 	void mapFont(const QString& oldname, const QString& newname)      { m_fonts.insert(oldname, newname); }
 	void mapPattern(const QString& oldname, const QString& newname)   { m_patterns.insert(oldname, newname); }
@@ -53,6 +58,8 @@
 	void mapStyle(const QString& oldname, const QString& newname)     { m_pstyles.insert(oldname, newname); }
 	void mapCharStyle(const QString& oldname, const QString& newname) { m_cstyles.insert(oldname, newname); }
 	void mapLineStyle(const QString& oldname, const QString& newname) { m_linestyles.insert(oldname, newname); }
+	void mapTableStyle(const QString& oldname, const QString& newname) { m_tableStyles.insert(oldname, newname); }
+	void mapCellStyle(const QString& oldname, const QString& newname) { m_cellStyles.insert(oldname, newname); }
 	
 	void mapFonts(const QMap<QString,QString>& newnames)      { m_fonts = newnames; }
 	void mapPatterns(const QMap<QString,QString>& newnames)   { m_patterns = newnames; }
@@ -61,6 +68,8 @@
 	void mapStyles(const QMap<QString,QString>& newnames)     { m_pstyles = newnames; }
 	void mapCharStyles(const QMap<QString,QString>& newnames) { m_cstyles = newnames; }
 	void mapLineStyles(const QMap<QString,QString>& newnames) { m_linestyles = newnames; }
+	void mapTableStyles(const QMap<QString,QString>& newnames) { m_tableStyles = newnames; }
+	void mapCellStyles(const QMap<QString,QString>& newnames) { m_cellStyles = newnames; }
 	
 	const QMap<QString, QString>& fonts()      { return m_fonts; }
 	const QMap<QString, QString>& patterns()   { return m_patterns; }
@@ -69,6 +78,8 @@
 	const QMap<QString, QString>& styles()     { return m_pstyles; }
 	const QMap<QString, QString>& charStyles() { return m_cstyles; }
 	const QMap<QString, QString>& lineStyles() { return m_linestyles; }
+	const QMap<QString, QString>& tableStyles() { return m_tableStyles; }
+	const QMap<QString, QString>& cellStyles() { return m_cellStyles; }
 	
 	QList<QString> fontNames() const      { return m_fonts.keys(); }
 	QList<QString> patternNames() const   { return m_patterns.keys(); }
@@ -77,6 +88,8 @@
 	QList<QString> styleNames() const     { return m_pstyles.keys(); }
 	QList<QString> charStyleNames() const { return m_cstyles.keys(); }
 	QList<QString> lineStyleNames() const { return m_linestyles.keys(); }
+	QList<QString> tableStyleNames() const { return m_tableStyles.keys(); }
+	QList<QString> cellStyleNames() const { return m_cellStyles.keys(); }
 
 	// modifies newNames so that forall x in both newNames.key() and in existingNames, newNames[x] will map to a new unique name
 	static void makeUnique(QMap<QString,QString>& newNames, const QList<QString> existingNames);
@@ -94,6 +107,8 @@
 	QMap<QString,QString> m_pstyles;
 	QMap<QString,QString> m_cstyles;
 	QMap<QString,QString> m_linestyles;
+	QMap<QString,QString> m_tableStyles;
+	QMap<QString,QString> m_cellStyles;
 };
 
 

Modified: trunk/Scribus/scribus/scpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/scpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/scpainter.cpp (original)
+++ trunk/Scribus/scribus/scpainter.cpp Fri Sep 23 21:47:57 2011
@@ -478,6 +478,11 @@
 	cairo_translate (m_cr, x, y);
 }
 
+void ScPainter::translate( const QPointF& offset )
+{
+	cairo_translate (m_cr, offset.x(), offset.y());
+}
+
 void ScPainter::rotate( double r )
 {
 	cairo_rotate (m_cr, r * 3.1415927 / 180.0);
@@ -1858,6 +1863,14 @@
 	strokePath();
 }
 
+void ScPainter::drawLine(const QPointF& start, const QPointF& end)
+{
+	newPath();
+	moveTo(start.x(), start.y());
+	lineTo(end.x(), end.y());
+	strokePath();
+}
+
 void ScPainter::drawRect(double x, double y, double w, double h)
 {
 	newPath();

Modified: trunk/Scribus/scribus/scpainter.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/scpainter.h
==============================================================================
--- trunk/Scribus/scribus/scpainter.h (original)
+++ trunk/Scribus/scribus/scpainter.h Fri Sep 23 21:47:57 2011
@@ -16,6 +16,7 @@
 #include <QTransform>
 #include <QFont>
 #include <QImage>
+#include <QPointF>
 #include "scribusapi.h"
 #include "scconfig.h"
 #include "fpoint.h"
@@ -48,6 +49,7 @@
 	virtual void setZoomFactor( double );
 	virtual double zoomFactor() { return m_zoomFactor; }
 	virtual void translate( double, double );
+	virtual void translate( const QPointF& offset );
 	virtual void rotate( double );
 	virtual void scale( double, double );
 
@@ -85,6 +87,7 @@
 	virtual void drawPolygon();
 	virtual void drawPolyLine();
 	virtual void drawLine(FPoint start, FPoint end);
+	virtual void drawLine(const QPointF& start, const QPointF& end);
 	virtual void drawRect(double, double, double, double);
 	virtual void drawText(QRectF area, QString text);
 

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Fri Sep 23 21:47:57 2011
@@ -101,6 +101,7 @@
 #include "langmgr.h"
 #include "pageitem_imageframe.h"
 #include "pageitem_latexframe.h"
+#include "pageitem_table.h"
 #include "pageitem_textframe.h"
 #include "pagesize.h"
 #include "pdflib.h"
@@ -201,7 +202,9 @@
 #include "ui/scmwmenumanager.h"
 #include "ui/selectobjects.h"
 #include "ui/search.h"
+#include "ui/smcellstyle.h"
 #include "ui/smlinestyle.h"
+#include "ui/smtablestyle.h"
 #include "ui/smtextstyles.h"
 #include "ui/splash.h"
 #include "ui/storyeditor.h"
@@ -571,6 +574,8 @@
 	SMCharacterStyle *tmpCS = new SMCharacterStyle();
 	styleManager->addStyle(new SMParagraphStyle(tmpCS->tmpStyles()));
 	styleManager->addStyle(tmpCS);
+	styleManager->addStyle(new SMTableStyle());
+	styleManager->addStyle(new SMCellStyle());
 	connect( scrActions["editStyles"], SIGNAL(toggled(bool)), styleManager, SLOT(setPaletteShown(bool)) );
 	connect( styleManager, SIGNAL(paletteShown(bool)), scrActions["editStyles"], SLOT(setChecked(bool)));
 	styleManager->installEventFilter(this);
@@ -763,6 +768,27 @@
 	scrMenuMgr->addMenuToMenu("itemSendToScrapbook", "Item");
 //	scrMenuMgr->addMenuItem(scrActions["itemSendToScrapbook"], "Item", false);
 	scrMenuMgr->addMenuItem(scrActions["itemSendToPattern"], "Item", false);
+	// Table submenu.
+	scrMenuMgr->addMenuSeparator("Item");
+	scrMenuMgr->createMenu("ItemTable", tr("Table"));
+	scrMenuMgr->addMenuToMenu("ItemTable", "Item");
+	scrMenuMgr->addMenuItem(scrActions["tableInsertRows"], "ItemTable", false);
+	scrMenuMgr->addMenuItem(scrActions["tableInsertColumns"], "ItemTable", false);
+	scrMenuMgr->addMenuItem(scrActions["tableDeleteRows"], "ItemTable", false);
+	scrMenuMgr->addMenuItem(scrActions["tableDeleteColumns"], "ItemTable", false);
+	scrMenuMgr->addMenuSeparator("ItemTable");
+	scrMenuMgr->addMenuItem(scrActions["tableMergeCells"], "ItemTable", false);
+	scrMenuMgr->addMenuItem(scrActions["tableSplitCells"], "ItemTable", false);
+	scrMenuMgr->addMenuSeparator("ItemTable");
+	scrMenuMgr->addMenuItem(scrActions["tableSetRowHeights"], "ItemTable", false);
+	scrMenuMgr->addMenuItem(scrActions["tableSetColumnWidths"], "ItemTable", false);
+	scrMenuMgr->addMenuItem(scrActions["tableDistributeRowsEvenly"], "ItemTable", false);
+	scrMenuMgr->addMenuItem(scrActions["tableDistributeColumnsEvenly"], "ItemTable", false);
+	scrMenuMgr->addMenuSeparator("ItemTable");
+	scrMenuMgr->addMenuItem(scrActions["tableAdjustFrameToTable"], "ItemTable", false);
+	scrMenuMgr->addMenuItem(scrActions["tableAdjustTableToFrame"], "ItemTable", false);
+	scrMenuMgr->addMenuSeparator("Item");
+	// End Table submenu.
 	scrMenuMgr->addMenuSeparator("Item");
 	scrMenuMgr->addMenuItem(scrActions["itemAdjustFrameToImage"], "Item", false);
 	scrMenuMgr->addMenuItem(scrActions["itemAdjustImageToFrame"], "Item", false);
@@ -812,6 +838,7 @@
 	scrMenuMgr->addMenuItem(scrActions["toolsInsertImageFrame"], "Insert", false);
 	scrMenuMgr->addMenuItem(scrActions["toolsInsertRenderFrame"], "Insert", false);
 	scrMenuMgr->addMenuItem(scrActions["toolsInsertTableFrame"], "Insert", false);
+	scrMenuMgr->addMenuItem(scrActions["toolsInsertTable"], "Insert", false);
 	scrMenuMgr->addMenuItem(scrActions["toolsInsertShape"], "Insert", false);
 	scrMenuMgr->addMenuItem(scrActions["toolsInsertPolygon"], "Insert", false);
 	scrMenuMgr->addMenuItem(scrActions["toolsInsertArc"], "Insert", false);
@@ -2465,6 +2492,7 @@
 	scrActions["toolsInsertTextFrame"]->setEnabled(true);
 	scrActions["toolsInsertImageFrame"]->setEnabled(true);
 	scrActions["toolsInsertTableFrame"]->setEnabled(true);
+	scrActions["toolsInsertTable"]->setEnabled(true);
 	scrActions["toolsInsertShape"]->setEnabled(true);
 	scrActions["toolsInsertLine"]->setEnabled(true);
 	scrActions["toolsInsertBezier"]->setEnabled(true);
@@ -3155,6 +3183,7 @@
 				pluginAction->setEnabled(ixplug->handleSelection(doc, SelectedType));
 		}
 	}
+	updateTableMenuActions();
 }
 
 void ScribusMainWindow::slotDocCh(bool /*reb*/)
@@ -4660,6 +4689,9 @@
 		else
 			QDir::setCurrent( QDir::homePath() );
 	}
+
+	updateTableMenuActions();
+
 	return true;
 }
 
@@ -6110,6 +6142,7 @@
 		scrActions["toolsInsertTextFrame"]->setEnabled(false);
 		scrActions["toolsInsertImageFrame"]->setEnabled(false);
 		scrActions["toolsInsertTableFrame"]->setEnabled(false);
+		scrActions["toolsInsertTable"]->setEnabled(false);
 		scrActions["toolsInsertShape"]->setEnabled(false);
 		scrActions["toolsInsertLine"]->setEnabled(false);
 		scrActions["toolsInsertBezier"]->setEnabled(false);
@@ -6193,6 +6226,7 @@
 	scrActions["toolsInsertTextFrame"]->setEnabled(true);
 	scrActions["toolsInsertImageFrame"]->setEnabled(true);
 	scrActions["toolsInsertTableFrame"]->setEnabled(true);
+	scrActions["toolsInsertTable"]->setEnabled(true);
 	scrActions["toolsInsertShape"]->setEnabled(true);
 	scrActions["toolsInsertLine"]->setEnabled(true);
 	scrActions["toolsInsertBezier"]->setEnabled(true);
@@ -6288,6 +6322,7 @@
 	scrActions["toolsInsertTextFrame"]->setChecked(mode==modeDrawText);
 	scrActions["toolsInsertImageFrame"]->setChecked(mode==modeDrawImage);
 	scrActions["toolsInsertTableFrame"]->setChecked(mode==modeDrawTable);
+	scrActions["toolsInsertTable"]->setChecked(mode==modeDrawTable2);
 	scrActions["toolsInsertShape"]->setChecked(mode==modeDrawShapes);
 	scrActions["toolsInsertPolygon"]->setChecked(mode==modeDrawRegularPolygon);
 	scrActions["toolsInsertArc"]->setChecked(mode==modeDrawArc);
@@ -6337,11 +6372,20 @@
 			delete doc->CurTimer;
 			doc->CurTimer = NULL;
 		} */
+
+		// Restore/save action shortcuts when entering/leaving edit mode.
 		if (mode!=modeEdit && oldMode==modeEdit)
 			actionManager->restoreActionShortcutsPostEditMode();
 		else
 		if (mode==modeEdit && oldMode!=modeEdit)
 			actionManager->saveActionShortcutsPreEditMode();
+
+		// Restore/save action shortcuts when entering/leaving table edit mode.
+		if (mode != modeEditTable && oldMode == modeEditTable)
+			actionManager->restoreActionShortcutsPostEditMode();
+		else if (mode == modeEditTable && oldMode != modeEditTable)
+			actionManager->saveActionShortcutsPreEditMode();
+
 		if (oldMode == modeEdit)
 		{
 			view->zoomSpinBox->setFocusPolicy(Qt::ClickFocus);
@@ -6477,6 +6521,11 @@
 				qApp->changeOverrideCursor(QCursor(loadIcon("DrawTextFrame.xpm")));
 				break;
 			case modeDrawTable:
+				if (docSelectionCount!=0)
+					view->Deselect(true);
+				qApp->changeOverrideCursor(QCursor(loadIcon("DrawTable.xpm")));
+				break;
+			case modeDrawTable2:
 				if (docSelectionCount!=0)
 					view->Deselect(true);
 				qApp->changeOverrideCursor(QCursor(loadIcon("DrawTable.xpm")));
@@ -9165,6 +9214,7 @@
 	scrActions["toolsInsertTextFrame"]->setEnabled(setter);
 	scrActions["toolsInsertImageFrame"]->setEnabled(setter);
 	scrActions["toolsInsertTableFrame"]->setEnabled(setter);
+	scrActions["toolsInsertTable"]->setEnabled(setter);
 	scrActions["toolsInsertShape"]->setEnabled(setter);
 	scrActions["toolsInsertLine"]->setEnabled(setter);
 	scrActions["toolsInsertBezier"]->setEnabled(setter);
@@ -10119,3 +10169,34 @@
 	scrMenuMgr->setMenuEnabled("InsertSpace", enabled);
 	scrMenuMgr->setMenuEnabled("InsertLigature", enabled);
 }
+
+void ScribusMainWindow::updateTableMenuActions()
+{
+	// Determine state.
+	PageItem* item = doc ? doc->m_Selection->itemAt(0) : 0;
+	PageItem_Table* table = (item && item->isTable()) ? item->asTable() : 0;
+	const bool tableEdited = table && doc->appMode == modeEditTable;
+	const int tableRows = table ? table->rows() : 0;
+	const int tableColumns = table ? table->columns() : 0;
+	const int selectedRows = tableEdited ? table->selectedRows().size() : 0;
+	const int selectedColumns = tableEdited ? table->selectedColumns().size() : 0;
+	const int selectedCells = tableEdited ? table->selectedCells().size() : 0;
+
+	// Enable/disable menu actions.
+	scrMenuMgr->setMenuEnabled("ItemTable", table);
+	scrActions["tableInsertRows"]->setEnabled(table || (tableEdited && selectedCells < 1));
+	scrActions["tableInsertColumns"]->setEnabled(table || (tableEdited && selectedCells < 1));
+	scrActions["tableDeleteRows"]->setEnabled(tableEdited &&
+		((selectedRows < 1 && tableRows > 1) || (selectedRows > 0 && selectedRows < tableRows)));
+	scrActions["tableDeleteColumns"]->setEnabled(tableEdited &&
+		((selectedColumns < 1 && tableColumns > 1) || (selectedColumns > 0 && selectedColumns < tableColumns)));
+	scrActions["tableMergeCells"]->setEnabled(selectedCells > 1);
+	scrActions["tableSplitCells"]->setEnabled(false); // Not implemented.
+	scrActions["tableSetRowHeights"]->setEnabled(tableEdited);
+	scrActions["tableSetColumnWidths"]->setEnabled(tableEdited);
+	scrActions["tableDistributeRowsEvenly"]->setEnabled(selectedRows > 1);
+	scrActions["tableDistributeColumnsEvenly"]->setEnabled(selectedColumns > 1);
+	scrActions["tableAdjustFrameToTable"]->setEnabled(table);
+	scrActions["tableAdjustTableToFrame"]->setEnabled(table);
+}
+

Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Fri Sep 23 21:47:57 2011
@@ -558,6 +558,14 @@
 	//! \brief allow SE to get the SM for edit stlyes
 	StyleManager *styleMgr() const {return styleManager;};
 
+	/**
+	 * Enables/disables the actions in the "Table" menu.
+	 *
+	 * This has a functions of its own, since it needs to be called from the table edit
+	 * canvas modes/gestures.
+	 */
+	void updateTableMenuActions();
+
 signals:
 	void TextStyle(const ParagraphStyle&);
 //deprecated: (av)

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Fri Sep 23 21:47:57 2011
@@ -26,13 +26,16 @@
 #include <sstream>
 
 #include <QByteArray>
- #include <QDebug>
+#include <QDebug>
+#include <QDialog>
 #include <QEventLoop>
 #include <QFile>
 #include <QList>
+#include <QtAlgorithms>
 #include <QTime>
 #include <QPainter>
 #include <QPixmap>
+#include <QPointer>
 #include <QProgressBar>
 
 #include "canvas.h"
@@ -42,8 +45,11 @@
 //#include "desaxe/saxXML.h"
 #include "fileloader.h"
 #include "filewatcher.h"
+#include "fpoint.h"
 #include "ui/guidemanager.h"
 #include "hyphenator.h"
+#include "ui/inserttablecolumnsdialog.h"
+#include "ui/inserttablerowsdialog.h"
 #include "pageitem.h"
 #include "pageitem_imageframe.h"
 #include "pageitem_latexframe.h"
@@ -51,6 +57,7 @@
 #include "pageitem_pathtext.h"
 #include "pageitem_polygon.h"
 #include "pageitem_polyline.h"
+#include "pageitem_table.h"
 #include "pageitem_textframe.h"
 #ifdef HAVE_OSG
 	#include "pageitem_osgframe.h"
@@ -80,6 +87,9 @@
 #include "scribuswin.h"
 #include "selection.h"
 #include "serializer.h"
+#include "tableborder.h"
+#include "ui/tablecolumnwidthsdialog.h"
+#include "ui/tablerowheightsdialog.h"
 #include "text/nlsconfig.h"
 #include "undomanager.h"
 #include "units.h"
@@ -212,6 +222,8 @@
 	DragElements(),
 	docParagraphStyles(),
 	docCharStyles(),
+	docTableStyles(),
+	docCellStyles(),
 	Layers(),
 	GroupCounter(1),
 	colorEngine(ScCore->defaultEngine),
@@ -301,6 +313,8 @@
 	DragElements(),
 	docParagraphStyles(),
 	docCharStyles(),
+	docTableStyles(),
+	docCellStyles(),
 	Layers(),
 	GroupCounter(1),
 	colorEngine(ScCore->defaultEngine),
@@ -466,6 +480,34 @@
 //	docParagraphStyles[0].charStyle().setName( "cdocdefault" ); // DONT TRANSLATE
 
 	currentStyle = pstyle;
+
+	// Create default table style.
+	// TODO: We should have preferences for the default values.
+	TableStyle defaultTableStyle;
+	defaultTableStyle.setName(CommonStrings::DefaultTableStyle);
+	defaultTableStyle.setFillColor(CommonStrings::None);
+	defaultTableStyle.setLeftBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
+	defaultTableStyle.setRightBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
+	defaultTableStyle.setTopBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
+	defaultTableStyle.setBottomBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
+	docTableStyles.create(defaultTableStyle);
+	docTableStyles.makeDefault(&(docTableStyles[0]));
+
+	// Create default table cell style.
+	// TODO: We should have preferences for the default values.
+	CellStyle defaultCellStyle;
+	defaultCellStyle.setName(CommonStrings::DefaultCellStyle);
+	defaultCellStyle.setFillColor(CommonStrings::None);
+	defaultCellStyle.setLeftBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
+	defaultCellStyle.setRightBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
+	defaultCellStyle.setTopBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
+	defaultCellStyle.setBottomBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
+	defaultCellStyle.setLeftPadding(1.0);
+	defaultCellStyle.setRightPadding(1.0);
+	defaultCellStyle.setTopPadding(1.0);
+	defaultCellStyle.setBottomPadding(1.0);
+	docCellStyles.create(defaultCellStyle);
+	docCellStyles.makeDefault(&(docCellStyles[0]));
 	
 	Layers.addLayer( tr("Background") );
 	// FIXME: Check PDF version input
@@ -985,6 +1027,10 @@
 		docParagraphStyles[i].getNamedResources(lists);
 	for (int i = 0; i < docCharStyles.count(); ++i)
 		docCharStyles[i].getNamedResources(lists);
+	for (int i = 0; i < docTableStyles.count(); ++i)
+		docTableStyles[i].getNamedResources(lists);
+	for (int i = 0; i < docCellStyles.count(); ++i)
+		docCellStyles[i].getNamedResources(lists);
 //	for (uint i = 0; i < docLineStyles.count(); ++i)
 //		docLineStyles[i].getNamedResources(lists);
 	
@@ -1125,6 +1171,20 @@
 		else
 			docCharStyles[i].replaceNamedResources(newNames);
 	}
+	for (int i = docTableStyles.count() - 1; i >= 0; --i)
+	{
+		if (newNames.tableStyles().contains(docTableStyles[i].name()))
+			docTableStyles.remove(i);
+		else
+			docTableStyles[i].replaceNamedResources(newNames);
+	}
+	for (int i = docCellStyles.count() - 1; i >= 0; --i)
+	{
+		if (newNames.cellStyles().contains(docCellStyles[i].name()))
+			docCellStyles.remove(i);
+		else
+			docCellStyles[i].replaceNamedResources(newNames);
+	}
 
 	QMap<QString,ScPattern>::Iterator it;
 	for (it = docPatterns.begin(); it != docPatterns.end(); ++it)
@@ -1165,17 +1225,24 @@
 	if (newNames.colors().count() > 0 || newNames.fonts().count() > 0)
 	{
 		docCharStyles.invalidate();
-		docParagraphStyles.invalidate();	
+		docParagraphStyles.invalidate();
+		docTableStyles.invalidate();
+		docCellStyles.invalidate();
 	}
 	else
 	{
 		if (newNames.charStyles().count() > 0)
 			docCharStyles.invalidate();
 		if (newNames.styles().count() > 0)
-			docParagraphStyles.invalidate();	
+			docParagraphStyles.invalidate();
+		if (newNames.tableStyles().count() > 0)
+			docTableStyles.invalidate();
+		if (newNames.cellStyles().count() > 0)
+			docCellStyles.invalidate();
 	}
 	if (!isLoading() && !(newNames.colors().isEmpty() && newNames.fonts().isEmpty() && newNames.patterns().isEmpty() 
-						  && newNames.styles().isEmpty() && newNames.charStyles().isEmpty() && newNames.lineStyles().isEmpty()) )
+			&& newNames.styles().isEmpty() && newNames.charStyles().isEmpty() && newNames.lineStyles().isEmpty()
+			&& newNames.tableStyles().isEmpty() && newNames.cellStyles().isEmpty()))
 		changed();
 }
 
@@ -1225,6 +1292,19 @@
 	*/
 }
 
+void ScribusDoc::replaceTableStyles(const QMap<QString, QString>& newNameForOld)
+{
+	ResourceCollection newNames;
+	newNames.mapTableStyles(newNameForOld);
+	replaceNamedResources(newNames);
+}
+
+void ScribusDoc::replaceCellStyles(const QMap<QString, QString>& newNameForOld)
+{
+	ResourceCollection newNames;
+	newNames.mapCellStyles(newNameForOld);
+	replaceNamedResources(newNames);
+}
 
 void ScribusDoc::redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused)
 {
@@ -1280,6 +1360,47 @@
 	docCharStyles.invalidate();
 }
 
+void ScribusDoc::redefineTableStyles(const StyleSet<TableStyle>& newStyles, bool removeUnused)
+{
+	docTableStyles.redefine(newStyles, false);
+	if (removeUnused)
+	{
+		QMap<QString, QString> deletion;
+		QString deflt("");
+		for (int i = 0; i < docTableStyles.count(); ++i)
+		{
+			const QString& nam(docTableStyles[i].name());
+			if (newStyles.find(nam) < 0)
+			{
+				deletion[nam] = deflt;
+			}
+		}
+		if (deletion.count() > 0)
+			replaceTableStyles(deletion);
+	}
+	docTableStyles.invalidate();
+}
+
+void ScribusDoc::redefineCellStyles(const StyleSet<CellStyle>& newStyles, bool removeUnused)
+{
+	docCellStyles.redefine(newStyles, false);
+	if (removeUnused)
+	{
+		QMap<QString, QString> deletion;
+		QString deflt("");
+		for (int i = 0; i < docCellStyles.count(); ++i)
+		{
+			const QString& nam(docCellStyles[i].name());
+			if (newStyles.find(nam) < 0)
+			{
+				deletion[nam] = deflt;
+			}
+		}
+		if (deletion.count() > 0)
+			replaceCellStyles(deletion);
+	}
+	docCellStyles.invalidate();
+}
 
 /*
  * Split out from loadStyles in editFormats.cpp so it's callable from anywhere,
@@ -4202,6 +4323,10 @@
 				Q_ASSERT(frameType==PageItem::Unspecified);
 			}
 			break;
+		case PageItem::Table:
+			newItem = new PageItem_Table(this, x, y, b, h, w, fill, outline);
+			Q_ASSERT(frameType==PageItem::Rectangle || frameType==PageItem::Unspecified);
+			break;
 		case PageItem::Polygon:
 			newItem = new PageItem_Polygon(this, x, y, b, h, w, fill, outline);
 			Q_ASSERT(frameType==PageItem::Rectangle || frameType==PageItem::Ellipse || frameType==PageItem::Unspecified);
@@ -4485,7 +4610,7 @@
 			break;
 	}
 
-	if (frameType==PageItem::Rectangle || itemType==PageItem::TextFrame || itemType==PageItem::ImageFrame || itemType==PageItem::LatexFrame || itemType==PageItem::OSGFrame || itemType==PageItem::Symbol || itemType==PageItem::Group)
+	if (frameType==PageItem::Rectangle || itemType==PageItem::TextFrame || itemType==PageItem::ImageFrame || itemType==PageItem::LatexFrame || itemType==PageItem::OSGFrame || itemType==PageItem::Symbol || itemType==PageItem::Group || itemType==PageItem::Table)
 	{
 		newItem->SetRectFrame();
 		//TODO one day hopefully, if(ScCore->usingGUI())
@@ -6867,6 +6992,395 @@
 	}
 }
 
+void ScribusDoc::itemSelection_InsertTableRows()
+{
+	PageItem* item = m_Selection->itemAt(0);
+	if (!item || !item->isTable())
+		return;
+
+	PageItem_Table* table = item->asTable();
+	if (!table)
+		return;
+
+	QPointer<InsertTableRowsDialog> dialog = new InsertTableRowsDialog(appMode, m_ScMW);
+	if (dialog->exec() == QDialog::Accepted)
+	{
+		/*
+		 * In table edit mode we insert either before or after the active
+		 * cell, otherwise we insert at beginning or end of table.
+		 */
+		int index = 0;
+		const TableCell cell = table->activeCell();
+		if (dialog->position() == InsertTableRowsDialog::Before)
+			index = appMode == modeEditTable ? cell.row() : 0;
+		else
+			index = appMode == modeEditTable ? cell.row() + cell.rowSpan() : table->rows();
+
+		// Insert the rows.
+		table->insertRows(index, dialog->numberOfRows());
+		table->clearSelection();
+		table->update();
+
+		m_ScMW->updateTableMenuActions();
+		changed();
+	}
+
+	delete dialog;
+}
+
+void ScribusDoc::itemSelection_InsertTableColumns()
+{
+	PageItem* item = m_Selection->itemAt(0);
+	if (!item || !item->isTable())
+		return;
+
+	PageItem_Table* table = item->asTable();
+	if (!table)
+		return;
+
+	QPointer<InsertTableColumnsDialog> dialog = new InsertTableColumnsDialog(appMode, m_ScMW);
+	if (dialog->exec() == QDialog::Accepted)
+	{
+		/*
+		 * In table edit mode we insert either before or after the active
+		 * cell, otherwise we insert at beginning or end of table.
+		 */
+		int index = 0;
+		const TableCell cell = table->activeCell();
+		if (dialog->position() == InsertTableColumnsDialog::Before)
+			index = appMode == modeEditTable ? cell.column() : 0;
+		else
+			index = appMode == modeEditTable ? cell.column() + cell.columnSpan() : table->columns();
+
+		// Insert the columns.
+		table->insertColumns(index, dialog->numberOfColumns());
+		table->clearSelection();
+		table->update();
+
+		m_ScMW->updateTableMenuActions();
+		changed();
+	}
+
+	delete dialog;
+}
+
+void ScribusDoc::itemSelection_DeleteTableRows()
+{
+	PageItem* item = m_Selection->itemAt(0);
+	if (!item || !item->isTable())
+		return;
+
+	PageItem_Table* table = item->asTable();
+	if (!table)
+		return;
+
+	if (appMode != modeEditTable)
+		return;
+
+	if (table->selectedRows().size() >= table->rows())
+		return;
+
+	if (table->selectedRows().isEmpty())
+	{
+		// Remove rows spanned by active cell.
+	TableCell activeCell = table->activeCell();
+		table->removeRows(activeCell.row(), activeCell.rowSpan());
+	}
+	else
+	{
+		// Remove selected row(s).
+		QList<int> selectedRows = table->selectedRows().toList();
+		qSort(selectedRows.begin(), selectedRows.end(), qGreater<int>());
+
+		int index = 0;
+		int numRows = 1;
+		for (int i = 0; i < selectedRows.size() - 1; ++i)
+		{
+			index = selectedRows[i];
+			if (selectedRows[i] - 1 == selectedRows[i + 1])
+			{
+				index = selectedRows[i + 1];
+				numRows++;
+			}
+			else
+			{
+				table->removeRows(index, numRows);
+				numRows = 1;
+			}
+		}
+		table->removeRows(index, numRows);
+	}
+
+	m_View->stopGesture(); // FIXME: Don't use m_View.
+	table->update();
+
+	m_ScMW->updateTableMenuActions();
+	changed();
+}
+
+void ScribusDoc::itemSelection_DeleteTableColumns()
+{
+	PageItem* item = m_Selection->itemAt(0);
+	if (!item || !item->isTable())
+		return;
+
+	PageItem_Table* table = item->asTable();
+	if (!table)
+		return;
+
+	if (appMode != modeEditTable)
+		return;
+
+	if (table->selectedColumns().size() >= table->columns())
+		return;
+
+	if (table->selectedColumns().isEmpty())
+	{
+		// Remove columns spanned by active cell.
+		TableCell activeCell = table->activeCell();
+		table->removeColumns(activeCell.column(), activeCell.columnSpan());
+	}
+	else
+	{
+		// Remove selected column(s).
+		QList<int> selectedColumns = table->selectedColumns().toList();
+		qSort(selectedColumns.begin(), selectedColumns.end(), qGreater<int>());
+
+		int index = 0;
+		int numColumns = 1;
+		for (int i = 0; i < selectedColumns.size() - 1; ++i)
+		{
+			index = selectedColumns[i];
+			if (selectedColumns[i] - 1 == selectedColumns[i + 1])
+			{
+				index = selectedColumns[i + 1];
+				numColumns++;
+			}
+			else
+			{
+				table->removeColumns(index, numColumns);
+				numColumns = 1;
+			}
+		}
+		table->removeColumns(index, numColumns);
+	}
+
+	m_View->stopGesture(); // FIXME: Don't use m_View.
+	table->update();
+
+	m_ScMW->updateTableMenuActions();
+	changed();
+}
+
+void ScribusDoc::itemSelection_MergeTableCells()
+{
+	PageItem* item = m_Selection->itemAt(0);
+	if (!item || !item->isTable())
+		return;
+
+	PageItem_Table* table = item->asTable();
+	if (!table)
+		return;
+
+	if (appMode != modeEditTable)
+		return;
+
+	if (table->selectedCells().size() < 2)
+		return;
+
+	QList<int> selectedRows = table->selectedRows().toList();
+	QList<int> selectedColumns = table->selectedColumns().toList();
+	qSort(selectedRows);
+	qSort(selectedColumns);
+
+	const int row = selectedRows.first();
+	const int column = selectedColumns.first();
+	const int numRows = selectedRows.last() - row + 1;
+	const int numColumns = selectedColumns.last() - column + 1;
+
+	table->mergeCells(row, column, numRows, numColumns);
+
+	m_View->stopGesture(); // FIXME: Don't use m_View.
+	table->update();
+
+	m_ScMW->updateTableMenuActions();
+	changed();
+}
+
+void ScribusDoc::itemSelection_SetTableRowHeights()
+{
+	PageItem* item = m_Selection->itemAt(0);
+	if (!item || !item->isTable())
+		return;
+
+	PageItem_Table* table = item->asTable();
+	if (!table)
+		return;
+
+	QPointer<TableRowHeightsDialog> dialog = new TableRowHeightsDialog(this, m_ScMW);
+	if (dialog->exec() == QDialog::Rejected)
+		return;
+
+	const qreal rowHeight = dialog->rowHeight();
+	if (appMode == modeEditTable)
+	{
+		if (table->selectedCells().isEmpty())
+		{
+			// Set height of rows spanned by active cell.
+			TableCell activeCell = table->activeCell();
+			int startRow = activeCell.row();
+			int endRow = startRow + activeCell.rowSpan() - 1;
+			for (int row = startRow; row <= endRow; ++row)
+				table->resizeRow(row, rowHeight / unitRatio());
+		}
+		else
+		{
+			// Set height of selected rows.
+			foreach (const int row, table->selectedRows())
+				table->resizeRow(row, rowHeight / unitRatio());
+		}
+	}
+	else
+	{
+		// Set height of all rows in table.
+		for (int row = 0; row < table->rows(); ++row)
+			table->resizeRow(row, rowHeight / unitRatio());
+	}
+
+	delete dialog;
+
+	table->update();
+	changed();
+}
+
+void ScribusDoc::itemSelection_SetTableColumnWidths()
+{
+	PageItem* item = m_Selection->itemAt(0);
+	if (!item || !item->isTable())
+		return;
+
+	PageItem_Table* table = item->asTable();
+	if (!table)
+		return;
+
+	QPointer<TableColumnWidthsDialog> dialog = new TableColumnWidthsDialog(this, m_ScMW);
+	if (dialog->exec() == QDialog::Rejected)
+		return;
+
+	const qreal columnWidth = dialog->columnWidth();
+	if (appMode == modeEditTable)
+	{
+		if (table->selectedCells().isEmpty())
+		{
+			// Set width of columns spanned by active cell.
+			TableCell activeCell = table->activeCell();
+			int startColumn = activeCell.column();
+			int endColumn = startColumn + activeCell.columnSpan() - 1;
+			for (int column = startColumn; column <= endColumn; ++column)
+				table->resizeColumn(column, columnWidth / unitRatio());
+		}
+		else
+		{
+			// Set width of selected columns.
+			foreach (const int column, table->selectedColumns())
+				table->resizeColumn(column, columnWidth / unitRatio());
+		}
+	}
+	else
+	{
+		// Set width of all columns in table.
+		for (int column = 0; column < table->columns(); ++column)
+			table->resizeColumn(column, columnWidth / unitRatio());
+	}
+
+	delete dialog;
+
+	table->update();
+	changed();
+}
+
+void ScribusDoc::itemSelection_DistributeTableRowsEvenly()
+{
+	PageItem* item = m_Selection->itemAt(0);
+	if (!item || !item->isTable())
+		return;
+
+	PageItem_Table* table = item->asTable();
+	if (!table)
+		return;
+
+	if (appMode == modeEditTable && !table->selectedRows().isEmpty())
+	{
+		// Distribute each contigous range of selected rows.
+		QList<int> selectedRows = table->selectedRows().toList();
+		qSort(selectedRows);
+		int startRow = selectedRows.first();
+		int endRow = startRow;
+		for (int i = 0; i < selectedRows.size() - 1; ++i)
+		{
+			if (selectedRows[i + 1] == endRow + 1)
+				endRow++; // Extend range.
+			else
+			{
+				table->distributeRows(startRow, endRow);
+				// Move range.
+				startRow = selectedRows[i + 1];
+				endRow = startRow;
+			}
+		}
+		table->distributeRows(startRow, endRow);
+	}
+	else
+	{
+		// Distribute all rows in the table.
+		table->distributeRows(0, table->rows() - 1);
+	}
+
+	table->update();
+	changed();
+}
+
+void ScribusDoc::itemSelection_DistributeTableColumnsEvenly()
+{
+	PageItem* item = m_Selection->itemAt(0);
+	if (!item || !item->isTable())
+		return;
+
+	PageItem_Table* table = item->asTable();
+	if (!table)
+		return;
+
+	if (appMode == modeEditTable && !table->selectedColumns().isEmpty())
+	{
+		// Distribute each contigous range of selected columns.
+		QList<int> selectedColumns = table->selectedColumns().toList();
+		qSort(selectedColumns);
+		int startColumn = selectedColumns.first();
+		int endColumn = startColumn;
+		for (int i = 0; i < selectedColumns.size() - 1; ++i)
+		{
+			if (selectedColumns[i + 1] == endColumn + 1)
+				endColumn++; // Extend range.
+			else
+			{
+				table->distributeColumns(startColumn, endColumn);
+				// Move range.
+				startColumn = selectedColumns[i + 1];
+				endColumn = startColumn;
+			}
+		}
+		table->distributeColumns(startColumn, endColumn);
+	}
+	else
+	{
+		// Distribute all columns in the table.
+		table->distributeColumns(0, table->columns() - 1);
+	}
+
+	table->update();
+	changed();
+}
+
 void ScribusDoc::itemSelection_SetEffects(int s, Selection* customSelection)
 {
 	CharStyle newStyle;
@@ -11558,6 +12072,16 @@
 	return ret;
 }
 
+bool ScribusDoc::ApplyGuides(FPoint* point)
+{
+	double newX = point->x();
+	double newY = point->y();
+	bool ret = ApplyGuides(&newX, &newY);
+	point->setX(newX);
+	point->setY(newY);
+
+	return ret;
+}
 
 bool ScribusDoc::MoveItem(double newX, double newY, PageItem* currItem, bool fromMP)
 {
@@ -12841,7 +13365,43 @@
 	}
 }
 
-
+void ScribusDoc::itemSelection_AdjustFrameToTable()
+{
+	// TODO: Do this in an undo transaction?
+	int selectedItemCount = m_Selection->count();
+
+	if (selectedItemCount < 1)
+		return;
+
+	for (int i = 0; i < selectedItemCount; ++i)
+	{
+		PageItem *item = m_Selection->itemAt(i);
+		if (item && item->isTable())
+			item->asTable()->adjustFrameToTable();
+	}
+
+	regionsChanged()->update(QRectF());
+	changed();
+}
+
+void ScribusDoc::itemSelection_AdjustTableToFrame()
+{
+	// TODO: Do this in an undo transaction?
+	int selectedItemCount = m_Selection->count();
+
+	if (selectedItemCount < 1)
+		return;
+
+	for (int i = 0; i < selectedItemCount; ++i)
+	{
+		PageItem *item = m_Selection->itemAt(i);
+		if (item && item->isTable())
+			item->asTable()->adjustTableToFrame();
+	}
+
+	regionsChanged()->update(QRectF());
+	changed();
+}
 
 NodeEditContext::NodeEditContext() 
 : submode(MOVE_POINT), isContourLine(false), oldClip(NULL), nodeTransaction(NULL),

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Fri Sep 23 21:47:57 2011
@@ -48,6 +48,8 @@
 #include "scpage.h"
 #include "sclayer.h"
 #include "styles/styleset.h"
+#include "styles/tablestyle.h"
+#include "styles/cellstyle.h"
 #include "undoobject.h"
 #include "undostate.h"
 #include "updatemanager.h"
@@ -57,6 +59,7 @@
 #include FT_FREETYPE_H
 
 class DocUpdater;
+class FPoint;
 class UndoManager;
 // class UndoState;
 class PDFOptions;
@@ -518,6 +521,56 @@
 	bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); }
 // 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
 
+	/**
+	 * Returns the table style named @a name.
+	 */
+	const TableStyle& tableStyle(QString name) { return docTableStyles.get(name); }
+	/**
+	 * Returns the set of table styles in the document.
+	 */
+	const StyleSet<TableStyle>& tableStyles()   { return docTableStyles; }
+	/**
+	 * Returns <code>true</code> if @a style is the default table style.
+	 */
+	bool isDefaultStyle(const TableStyle& style) const { return docTableStyles.isDefault(style); }
+	/**
+	 * Redefines the set of table styles in the document using styles in @a newStyles.
+	 * Removes unused table styles if @a removeUnused is <code>true</code>.
+	 */
+	void redefineTableStyles(const StyleSet<TableStyle>& newStyles, bool removeUnused = false);
+	/**
+	 * Remove any reference to old table styles and replace with new name.
+	 * This needs to be called when a style was removed. New name may be "".
+	 * @a newNameForOld is a map which maps the name of any style to remove
+	 * to a new table style name
+	 */
+	void replaceTableStyles(const QMap<QString, QString>& newNameForOld);
+
+	/**
+	 * Returns the table cell style named @a name.
+	 */
+	const CellStyle& cellStyle(QString name) { return docCellStyles.get(name); }
+	/**
+	 * Returns the set of table cell styles in the document.
+	 */
+	const StyleSet<CellStyle>& cellStyles()   { return docCellStyles; }
+	/**
+	 * Returns <code>true</code> if @a style is the default table cell style.
+	 */
+	bool isDefaultStyle(const CellStyle& style) const { return docCellStyles.isDefault(style); }
+	/**
+	 * Redefines the set of table cell styles in the document using styles in @a newStyles.
+	 * Removes unused table cell styles if @a removeUnused is <code>true</code>.
+	 */
+	void redefineCellStyles(const StyleSet<CellStyle>& newStyles, bool removeUnused = false);
+	/**
+	 * Remove any reference to old table cell styles and replace with new name.
+	 * This needs to be called when a style was removed. New name may be "".
+	 * @a newNameForOld is a map which maps the name of any style to remove
+	 * to a new table cell style name
+	 */
+	void replaceCellStyles(const QMap<QString, QString>& newNameForOld);
+
 	void getNamedResources(ResourceCollection& lists) const;
 	void replaceNamedResources(ResourceCollection& newNames);
 	bool styleExists(QString styleName);
@@ -1009,6 +1062,7 @@
 	//! \brief Snap an item to the guides
 	void SnapToGuides(PageItem *currItem);
 	bool ApplyGuides(double *x, double *y);
+	bool ApplyGuides(FPoint* point);
 	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
 	void RotateItem(double win, int ite);
 	void RotateItem(double win, PageItem *currItem);
@@ -1128,6 +1182,8 @@
 private:
 	StyleSet<ParagraphStyle> docParagraphStyles;
 	StyleSet<CharStyle> docCharStyles;
+	StyleSet<TableStyle> docTableStyles;
+	StyleSet<CellStyle> docCellStyles;
 public:
 	ScLayers Layers;
 	//bool marginColored;
@@ -1341,6 +1397,129 @@
 	void itemSelection_SetItemPatternMask(QString pattern);
 	void itemSelection_SetItemPatternMaskProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
 
+	// Table related slots.
+
+	/**
+	 * Inserts rows in a table.
+	 *
+	 * The user will be prompted by a dialog for the number of rows and where they should
+	 * be inserted. If in table edit mode, rows may be inserted before or after the active
+	 * cell. If in normal mode, rows may be inserted at the beginning or end of the selected
+	 * table.
+	 *
+	 * If no table is selected, then this slot does nothing.
+	 */
+	void itemSelection_InsertTableRows();
+
+	/**
+	 * Inserts columns in a table.
+	 *
+	 * The user will be prompted by a dialog for the number of columns and where they should
+	 * be inserted. If in table edit mode, columns may be inserted before or after the active
+	 * cell. If in normal mode, columns may be inserted at the beginning or end of the selected
+	 * table.
+	 *
+	 * If no table is selected, then this slot does nothing.
+	 */
+	void itemSelection_InsertTableColumns();
+
+	/**
+	 * Deletes rows in a table.
+	 *
+	 * If the there is a cell selection, all rows spanned by the selection will be deleted.
+	 * If there is no cell selection, the rows spanned by the active cell will be deleted.
+	 *
+	 * If no table is selected, or if the application is not in table edit mode, then this slot
+	 * does nothing.
+	 */
+	void itemSelection_DeleteTableRows();
+
+	/**
+	 * Deletes columns in a table.
+	 *
+	 * If the there is a cell selection, all columns spanned by the selection will be deleted.
+	 * If there is no cell selection, the columns spanned by the active cell will be deleted.
+	 *
+	 * If no table is selected, or if the application is not in table edit mode, then this slot
+	 * does nothing.
+	 */
+	void itemSelection_DeleteTableColumns();
+
+	/**
+	 * Merges the selected cells in a table.
+	 *
+	 * The merged area will span from the top left to the bottom right of the selected cells.
+	 *
+	 * If no table is selected, or if the application is not in table edit mode, or if less
+	 * than two cells is selected, then this slot does nothing.
+	 */
+	void itemSelection_MergeTableCells();
+
+	/**
+	 * Splits cells in a table.
+	 *
+	 * TODO: Implement this.
+	 */
+	void itemSelection_SplitTableCells() {}
+
+	/**
+	 * Sets the height of rows in a table.
+	 *
+	 * The user will be prompted by a dialog for entering a row height. If in table editing
+	 * mode, all rows of the table will get their height set. If the there is a cell selection,
+	 * all rows spanned by the selection will get their height set. If there is no cell
+	 * selection, the rows spanned by the active cell will get their height set.
+	 *
+	 * If no table is selected, then this slot does nothing.
+	 */
+	void itemSelection_SetTableRowHeights();
+
+	/**
+	 * Sets the width of columns in a table.
+	 *
+	 * The user will be prompted by a dialog for entering a column width. If in table editing
+	 * mode, all columns of the table will get their width set. If the there is a cell selection,
+	 * all columns spanned by the selection will get their width set. If there is no cell
+	 * selection, the columns spanned by the active cell will get their width set.
+	 *
+	 * If no table is selected, then this slot does nothing.
+	 */
+	void itemSelection_SetTableColumnWidths();
+
+	/**
+	 * Distributes rows in a table evenly.
+	 *
+	 * If in table edit mode and there is a cell selection, each contigous range of selected rows
+	 * is distributed. If there is no cell selection, all rows in the table are distributed.
+	 *
+	 * If there is no table selected, then this slot does nothing.
+	 */
+	void itemSelection_DistributeTableRowsEvenly();
+
+	/**
+	 * Distributes columns in a table evenly.
+	 *
+	 * If in table edit mode and there is a cell selection, each contigous range of selected columns
+	 * is distributed. If there is no cell selection, all columns in the table are distributed.
+	 *
+	 * If there is no table selected, then this slot does nothing.
+	 */
+	void itemSelection_DistributeTableColumnsEvenly();
+
+	/**
+	 * Adjusts the size of the frames of any selected tables to fit the size of the tables they contain.
+	 *
+	 * If there are no tables in the current selection, then this slot does nothing.
+	 */
+	void itemSelection_AdjustFrameToTable();
+
+	/**
+	 * Adjusts the size of any selected tables to fit the size of their frames.
+	 *
+	 * If there are no tables in the current selection, then this slot does nothing.
+	 */
+	void itemSelection_AdjustTableToFrame();
+
 	void undoRedoBegin();
 	void undoRedoDone();
 

Modified: trunk/Scribus/scribus/scribusstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/scribusstructs.h
==============================================================================
--- trunk/Scribus/scribus/scribusstructs.h (original)
+++ trunk/Scribus/scribus/scribusstructs.h Fri Sep 23 21:47:57 2011
@@ -301,6 +301,7 @@
 	modeInsertPDFLinkAnnotation,
 	modeDrawFreehandLine,
 	modeDrawTable,
+	modeDrawTable2, // Temporary name for new tables.
 	modePanning,
 	modeMeasurementTool,
 	modeEditGradientVectors,
@@ -316,7 +317,8 @@
 	modeEditArc,
 	modeEditPolygon,
 	modeDrawSpiral,
-	modeEditSpiral
+	modeEditSpiral,
+	modeEditTable
 };
 
 struct AlignObjs

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Fri Sep 23 21:47:57 2011
@@ -84,6 +84,7 @@
 #include "pageitem_pathtext.h"
 #include "pageitem_polygon.h"
 #include "pageitem_polyline.h"
+#include "pageitem_table.h"
 #include "pageitem_textframe.h"
 #include "pageitem_latexframe.h"
 #include "prefscontext.h"
@@ -1570,56 +1571,65 @@
 
 bool ScribusView::slotSetCurs(int x, int y)
 {
-	PageItem *currItemGeneric;
-	if (GetItem(&currItemGeneric))
-	{
-		if (!((currItemGeneric->asTextFrame()) || (currItemGeneric->asImageFrame())))
-			return false;
-		if (currItemGeneric->asImageFrame())
+	PageItem *item;
+	if (!GetItem(&item))
+		return false;
+
+	PageItem_TextFrame *textFrame;
+	QPointF canvasPoint;
+	if (item->isTextFrame())
+	{
+		textFrame = item->asTextFrame();
+		canvasPoint = m_canvas->globalToCanvas(QPoint(x,y)).toQPointF();
+	}
+	else if (item->isTable())
+	{
+		// Move to cell under cursor and position the text cursor.
+		PageItem_Table *table = item->asTable();
+		table->moveTo(table->cellAt(m_canvas->globalToCanvas(QPoint(x,y)).toQPointF()));
+		textFrame = table->activeCell().textFrame();
+		canvasPoint = table->getTransform().inverted().map(m_canvas->globalToCanvas(QPoint(x, y)).toQPointF()) - table->gridOffset();
+	}
+	else if (item->isImageFrame())
+		return true;
+	else
+		return false;
+
+
+	if (m_canvas->frameHitTest(canvasPoint, textFrame) == Canvas::INSIDE)
+	{
+		// #9592 : layout must be valid here, or screenToPosition() may crash
+		if (textFrame->invalid)
+			textFrame->layout();
+		if(textFrame->reversed())
+		{ //handle Right to Left writing
+			FPoint point(textFrame->width() - (canvasPoint.x() - textFrame->xPos()), canvasPoint.y() - textFrame->yPos());
+			textFrame->itemText.setCursorPosition(textFrame->itemText.length() == 0 ? 0 :
+				textFrame->itemText.screenToPosition(point));
+		}
+		else
+		{
+			FPoint point(canvasPoint.x() - textFrame->xPos(), canvasPoint.y() - textFrame->yPos());
+			textFrame->itemText.setCursorPosition(textFrame->itemText.length() == 0 ? 0 :
+				textFrame->itemText.screenToPosition(point));
+		}
+
+		if (textFrame->itemText.length() > 0)
+		{
+			int pos = qMax(qMin(textFrame->itemText.cursorPosition() - 1, textFrame->itemText.length()), 0);
+			Doc->currentStyle.charStyle() = textFrame->itemText.charStyle(pos);
+			emit ItemCharStyle(Doc->currentStyle.charStyle());
+			emit ItemTextEffects(Doc->currentStyle.charStyle().effects());
+			emit ItemTextAlign(textFrame->itemText.paragraphStyle(pos).alignment());
 			return true;
-		PageItem_TextFrame *currItem=currItemGeneric->asTextFrame();
-		if (currItem==0)
-			return false;
-		
-		FPoint pf(m_canvas->globalToCanvas(QPoint(x,y)));
-		if( m_canvas->frameHitTest(QPointF(pf.x(),pf.y()), currItem) == Canvas::INSIDE )
-		{
-			// #9592 : layout must be valid here, or screenToPosition() may crash
-			if (currItem->invalid)
-				currItem->layout();
-
-			QTransform transform = currItem->getTransform();
-			FPoint point(pf.x() - currItem->xPos(), pf.y() - currItem->yPos());
-			if (transform.isInvertible() && currItem->itemText.length() > 0)
-			{
-				double tx = 0, ty = 0;
-				transform.inverted().map(pf.x(), pf.y(), &tx, &ty);
-				point.setXY(tx, ty);
-			}
-			if (currItem->reversed())
-				point.setX(currItem->width() - point.x());
-			currItem->itemText.setCursorPosition( currItem->itemText.length() == 0 ? 0 :
-				currItem->itemText.screenToPosition(point) );
-
-			if (currItem->itemText.length() > 0)
-			{
-				int b = qMin(currItem->itemText.cursorPosition()- 1, currItem->itemText.length());
-				if (b < 0)
-					b = 0;
-				Doc->currentStyle.charStyle() = currItem->itemText.charStyle(b);
-				emit ItemCharStyle(Doc->currentStyle.charStyle());
-				emit ItemTextEffects(Doc->currentStyle.charStyle().effects());
-				emit ItemTextAlign(currItem->itemText.paragraphStyle(b).alignment());
-				return true;
-			}
-			else
-			{
-				Doc->currentStyle.charStyle() = currItem->itemText.defaultStyle().charStyle();
-				emit ItemCharStyle(currItem->itemText.defaultStyle().charStyle());
-				emit ItemTextEffects(currItem->itemText.defaultStyle().charStyle().effects());
-				emit ItemTextAlign( 0 );
-				return true;
-			}
+		}
+		else
+		{
+			Doc->currentStyle.charStyle() = textFrame->itemText.defaultStyle().charStyle();
+			emit ItemCharStyle(textFrame->itemText.defaultStyle().charStyle());
+			emit ItemTextEffects(textFrame->itemText.defaultStyle().charStyle().effects());
+			emit ItemTextAlign(0);
+			return true;
 		}
 	}
 	return false;

Modified: trunk/Scribus/scribus/styles/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/styles/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/styles/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/styles/CMakeLists.txt Fri Sep 23 21:47:57 2011
@@ -15,6 +15,8 @@
   linestyle.cpp
   charstyle.cpp
   paragraphstyle.cpp
+  tablestyle.cpp
+  cellstyle.cpp
 )
 
 QT4_WRAP_CPP(SCRIBUS_STYLES_MOC_SOURCES ${SCRIBUS_STYLES_MOC_CLASSES})

Modified: trunk/Scribus/scribus/styles/styleset.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/styles/styleset.h
==============================================================================
--- trunk/Scribus/scribus/styles/styleset.h (original)
+++ trunk/Scribus/scribus/styles/styleset.h Fri Sep 23 21:47:57 2011
@@ -67,16 +67,22 @@
 	StyleSet() : styles(), m_context(NULL), m_default(NULL) {}
 	
 	~StyleSet() { 
-		clear(); 
-	}
-	
-	void clear() { 
+		clear(false);
+	}
+	
+	/**
+	 * Deletes all styles in the style set.
+	 *
+	 * If @a invalid is <code>true</code>, this function also invalidates the style set.
+	 */
+	void clear(bool invalid = true) {
 		while(styles.count()>0) 
 		{ 
 			delete styles.front(); 
 			styles.pop_front(); 
 		}
-		invalidate();
+		if (invalid)
+			invalidate();
 	}
 
 	void setContext(const StyleContext* context) {

Modified: trunk/Scribus/scribus/tests/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/tests/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/tests/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/tests/CMakeLists.txt Fri Sep 23 21:47:57 2011
@@ -7,13 +7,13 @@
 
 
 SET(SCRIBUS_TEST_MOC_CLASSES
-testIndex.h
+#testIndex.h
 testStoryText.h
 )
 
 SET(SCRIBUS_TEST_SOURCES
 runtests.cpp
-testIndex.cpp
+#testIndex.cpp
 testStoryText.cpp
 )
 
@@ -32,3 +32,19 @@
   COMPILE_FLAGS -DCOMPILE_SCRIBUS_MAIN_APP
   )
 
+
+# Regular unit tests below.
+#
+# These tests are built as standalone executables and runned using "make test"
+#
+
+SET(TESTS_LIBRARIES ${QT_QTTEST_LIBRARY} ${QT_LIBRARIES})
+
+# Unit tests for CellArea
+SET(CELLAREATESTS_CLASSES cellareatests.h)
+SET(CELLAREATESTS_SOURCES cellareatests.cpp ../cellarea.cpp)
+QT4_WRAP_CPP(CELLAREATESTS_SOURCES ${CELLAREATESTS_CLASSES})
+ADD_EXECUTABLE(cellareatests ${CELLAREATESTS_SOURCES})
+TARGET_LINK_LIBRARIES(cellareatests ${TESTS_LIBRARIES})
+ADD_TEST(NAME cellareatests COMMAND cellareatests)
+

Modified: trunk/Scribus/scribus/tests/runtests.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/tests/runtests.cpp
==============================================================================
--- trunk/Scribus/scribus/tests/runtests.cpp (original)
+++ trunk/Scribus/scribus/tests/runtests.cpp Fri Sep 23 21:47:57 2011
@@ -1,7 +1,7 @@
 
 #include <QTest>
 //#include "testGlyphStore.h"
-#include "testIndex.h"
+//#include "testIndex.h"
 #include "testStoryText.h"
 #include "runtests.h"
 

Modified: trunk/Scribus/scribus/tests/testStoryText.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/tests/testStoryText.cpp
==============================================================================
--- trunk/Scribus/scribus/tests/testStoryText.cpp (original)
+++ trunk/Scribus/scribus/tests/testStoryText.cpp Fri Sep 23 21:47:57 2011
@@ -22,7 +22,7 @@
 void TestStoryText::addText()
 {
 	StoryText story;
-	story.insertChars(0, "Hallo Welt");
+	story.insertChars(0, QString("Hallo Welt"));
 	QCOMPARE(story.length(), 10);
 	QCOMPARE(story.text(0, story.length()), QString("Hallo Welt"));
 	story.insertChars(5, " schöne neue");
@@ -32,7 +32,7 @@
 void TestStoryText::removeText()
 {
 	StoryText story;
-	story.insertChars(0, "Hallo Welt");
+	story.insertChars(0, QString("Hallo Welt"));
 	story.removeChars(5, 5);
 	QCOMPARE(story.text(0, story.length()), QString("Hallo"));	
 }
@@ -40,7 +40,7 @@
 void TestStoryText::copy()
 {
 	StoryText story1;
-	story1.insertChars(0, "Hallo Welt");
+	story1.insertChars(0, QString("Hallo Welt"));
 	StoryText story2;
 	story2.insert(0, story1);
 	QCOMPARE(story2.text(0, story2.length()), QString("Hallo Welt"));

Modified: trunk/Scribus/scribus/ui/about.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/ui/about.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/about.cpp (original)
+++ trunk/Scribus/scribus/ui/about.cpp Fri Sep 23 21:47:57 2011
@@ -112,7 +112,7 @@
 	buildID = new QLabel( tab );
 	buildID->setAlignment(Qt::AlignCenter);
 	buildID->setTextInteractionFlags(Qt::TextSelectableByMouse);
-	QString BUILD_DAY = "18";
+	QString BUILD_DAY = "23";
 	QString BUILD_MONTH = CommonStrings::september;
 	QString BUILD_YEAR = "2011";
 	QString BUILD_TIME = "";

Modified: trunk/Scribus/scribus/ui/contextmenu.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/ui/contextmenu.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/contextmenu.cpp (original)
+++ trunk/Scribus/scribus/ui/contextmenu.cpp Fri Sep 23 21:47:57 2011
@@ -191,6 +191,32 @@
 			addAction(m_AP->scrActions["itemAdjustFrameToImage"]);
 		if (m_actionList.contains("itemAdjustImageToFrame"))
 			addAction(m_AP->scrActions["itemAdjustImageToFrame"]);
+
+		if (m_actionList.contains("tableInsertRows"))
+			addAction(m_AP->scrActions["tableInsertRows"]);
+		if (m_actionList.contains("tableInsertColumns"))
+			addAction(m_AP->scrActions["tableInsertColumns"]);
+		if (m_actionList.contains("tableDeleteRows"))
+			addAction(m_AP->scrActions["tableDeleteRows"]);
+		if (m_actionList.contains("tableDeleteColumns"))
+			addAction(m_AP->scrActions["tableDeleteColumns"]);
+		if (m_actionList.contains("tableMergeCells"))
+			addAction(m_AP->scrActions["tableMergeCells"]);
+		if (m_actionList.contains("tableSplitCells"))
+			addAction(m_AP->scrActions["tableSplitCells"]);
+		if (m_actionList.contains("tableSetRowHeights"))
+			addAction(m_AP->scrActions["tableSetRowHeights"]);
+		if (m_actionList.contains("tableSetColumnWidths"))
+			addAction(m_AP->scrActions["tableSetColumnWidths"]);
+		if (m_actionList.contains("tableDistributeRowsEvenly"))
+			addAction(m_AP->scrActions["tableDistributeRowsEvenly"]);
+		if (m_actionList.contains("tableDistributeColumnsEvenly"))
+			addAction(m_AP->scrActions["tableDistributeColumnsEvenly"]);
+		if (m_actionList.contains("tableAdjustFrameToTable"))
+			addAction(m_AP->scrActions["tableAdjustFrameToTable"]);
+		if (m_actionList.contains("tableAdjustTableToFrame"))
+			addAction(m_AP->scrActions["tableAdjustTableToFrame"]);
+
 		if (m_actionList.contains("itemExtendedImageProperties"))
 			addAction(m_AP->scrActions["itemExtendedImageProperties"]);
 		if (m_actionList.contains("itemAdjustFrameToImage"))

Modified: trunk/Scribus/scribus/ui/modetoolbar.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/ui/modetoolbar.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/modetoolbar.cpp (original)
+++ trunk/Scribus/scribus/ui/modetoolbar.cpp Fri Sep 23 21:47:57 2011
@@ -51,6 +51,7 @@
 	this->addAction(m_ScMW->scrActions["toolsInsertImageFrame"]);
 	this->addAction(m_ScMW->scrActions["toolsInsertRenderFrame"]);
 	this->addAction(m_ScMW->scrActions["toolsInsertTableFrame"]);
+	this->addAction(m_ScMW->scrActions["toolsInsertTable"]);
 	
 	this->addAction(m_ScMW->scrActions["toolsInsertShape"]);
 //	insertShapeButtonMenu = new QMenu();

Modified: trunk/Scribus/scribus/ui/propertiespalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/ui/propertiespalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette.cpp Fri Sep 23 21:47:57 2011
@@ -41,6 +41,7 @@
 #include "propertiespalette_image.h"
 #include "propertiespalette_line.h"
 #include "propertiespalette_shape.h"
+#include "propertiespalette_table.h"
 #include "propertiespalette_text.h"
 #include "propertiespalette_utils.h"
 #include "propertiespalette_xyz.h"
@@ -175,6 +176,14 @@
 	pageLayout_7->addWidget( Tpal );
 	idTransparencyItem = TabStack->addItem(page_7, "&Transparency" );
 
+	page_8 = new QWidget(TabStack);
+	pageLayout_8 = new QVBoxLayout(page_8);
+	pageLayout_8->setSpacing(5);
+	pageLayout_8->setMargin(0);
+	tablePal = new PropertiesPalette_Table(page_8);
+	pageLayout_8->addWidget(tablePal);
+	idTableItem = TabStack->addItem(page_8, "T&able" );
+
 //	MpalLayout->addWidget( TabStack );
 
 	setWidget( TabStack );
@@ -194,7 +203,7 @@
 	connect(Tpal, SIGNAL(editGradient()), this, SLOT(toggleGradientEditM()));
 
 	m_haveItem = false;
-	for (int ws = 1; ws < 8; ++ws)
+	for (int ws = 1; ws < 9; ++ws)
 		TabStack->setItemEnabled(ws, false);
 	TabStack->setCurrentIndex(0);
 	TabStack->widget(0)->setEnabled(false);
@@ -232,6 +241,7 @@
 	this->imagePal->setMainWindow(mw);
 	this->linePal->setMainWindow(mw);
 	this->textPal->setMainWindow(mw);
+	this->tablePal->setMainWindow(mw);
 
 	connect(this, SIGNAL(DocChanged()), m_ScMW, SLOT(slotDocCh()));
 	//connect(this->Cpal, SIGNAL(gradientChanged()), m_ScMW, SLOT(updtGradFill()));
@@ -293,6 +303,7 @@
 	imagePal->setDoc(m_doc);
 	linePal->setDoc(m_doc);
 	textPal->setDoc(m_doc);
+	tablePal->setDocument(m_doc);
 
 	updateColorList();
 
@@ -325,6 +336,8 @@
 	linePal->unsetDoc();
 	textPal->unsetItem();
 	textPal->unsetDoc();
+	tablePal->unsetItem();
+	tablePal->unsetDocument();
 
 	Cpal->setCurrentItem(NULL);
 	Cpal->setDocument(NULL);
@@ -332,7 +345,7 @@
 	Tpal->setDocument(NULL);
 
 	m_haveItem = false;
-	for (int ws = 1; ws < 8; ++ws)
+	for (int ws = 1; ws < 9; ++ws)
 		TabStack->setItemEnabled(ws, false);
 	TabStack->widget(0)->setEnabled(false);
 	TabStack->setItemEnabled(idXYZItem, false);
@@ -455,6 +468,7 @@
 	imagePal->handleSelectionChanged();
 	linePal->handleSelectionChanged();
 	textPal->handleSelectionChanged();
+	tablePal->handleSelectionChanged();
 
 	if (m_item->asOSGFrame())
 	{
@@ -463,6 +477,7 @@
 		TabStack->setItemEnabled(idGroupItem, false);
 		TabStack->setItemEnabled(idLineItem, false);
 		TabStack->setItemEnabled(idColorsItem, true);
+		TabStack->setItemEnabled(idTableItem, false);
 		TabStack->setItemEnabled(idTransparencyItem, false);
 		TabStack->setItemEnabled(idTextItem, false);
 		TabStack->setItemEnabled(idImageItem, false);
@@ -500,13 +515,14 @@
 	PageItem* currItem = currentItemFromSelection();
 	if (m_doc->m_Selection->count() > 1)
 	{
-		for (int ws = 1; ws < 8; ++ws)
+		for (int ws = 1; ws < 9; ++ws)
 			TabStack->setItemEnabled(ws, false);
 		TabStack->widget(0)->setEnabled(true);
 		TabStack->setItemEnabled(idXYZItem, true);
 		TabStack->setItemEnabled(idLineItem, false);
 		TabStack->setItemEnabled(idColorsItem, true);
 		TabStack->setItemEnabled(idTransparencyItem, true);
+		TabStack->setItemEnabled(idTableItem, false); // At least not for now.
 		if (m_haveItem && m_item)
 		{
 			if ((m_item->isGroup()) && (!m_item->isSingleSel))
@@ -527,7 +543,7 @@
 		{
 		case -1:
 			m_haveItem = false;
-			for (int ws = 1; ws < 8; ++ws)
+			for (int ws = 1; ws < 9; ++ws)
 				TabStack->setItemEnabled(ws, false);
 			TabStack->widget(0)->setEnabled(false);
 			TabStack->setItemEnabled(idXYZItem, false);
@@ -544,6 +560,7 @@
 				TabStack->setItemEnabled(idLineItem, false);
 				TabStack->setItemEnabled(idColorsItem, true);
 				TabStack->setItemEnabled(idTransparencyItem, false);
+				TabStack->setItemEnabled(idTableItem, false);
 				TabStack->setItemEnabled(idTextItem, false);
 				TabStack->setItemEnabled(idImageItem, false);
 			}
@@ -600,6 +617,16 @@
 			TabStack->setItemEnabled(idColorsItem, false);
 			TabStack->setItemEnabled(idTransparencyItem, false);
 			break;
+		case PageItem::Table:
+			TabStack->setItemEnabled(idTableItem, true);
+			TabStack->setItemEnabled(idShapeItem, true);
+			TabStack->setItemEnabled(idTextItem, false);
+			TabStack->setItemEnabled(idImageItem, false);
+			TabStack->setItemEnabled(idLineItem, false);
+			TabStack->setItemEnabled(idGroupItem, false);
+			TabStack->setItemEnabled(idColorsItem, false);
+			TabStack->setItemEnabled(idTransparencyItem, false);
+			break;
 		}
 	}
 	if (TabStack->isItemEnabled(currentTab) && (TabStack->currentIndex() != currentTab))
@@ -861,7 +888,7 @@
 
 	groupPal->updateColorList();
 	textPal->updateColorList();
-
+	tablePal->updateColorList();
 	Cpal->updateColorList();
 	Tpal->updateColorList();
 
@@ -898,6 +925,7 @@
 	TabStack->setItemText(idColorsItem, tr("&Colors"));
 	TabStack->setItemText(idGroupItem, tr("&Group"));
 	TabStack->setItemText(idTransparencyItem, tr("&Transparency"));
+	TabStack->setItemText(idTableItem, tr("T&able"));
 
 	xyzPal->languageChange();
 	shapePal->languageChange();
@@ -905,6 +933,7 @@
 	imagePal->languageChange();
 	linePal->languageChange();
 	textPal->languageChange();
+	tablePal->languageChange();
 }
 
 const VGradient PropertiesPalette::getMaskGradient()

Modified: trunk/Scribus/scribus/ui/propertiespalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16856&path=/trunk/Scribus/scribus/ui/propertiespalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette.h (original)
+++ trunk/Scribus/scribus/ui/propertiespalette.h Fri Sep 23 21:47:57 2011
@@ -37,6 +37,7 @@
 class PropertiesPalette_Image;
 class PropertiesPalette_Line;
 class PropertiesPalette_Shape;
+class PropertiesPalette_Table;
 class PropertiesPalette_Text;
 class PropertiesPalette_XYZ;
 class ScComboBox;
@@ -74,6 +75,7 @@
 	PropertiesPalette_Image* imagePal;
 	PropertiesPalette_Line*  linePal;
 	PropertiesPalette_Shape* shapePal;
+	PropertiesPalette_Table* tablePal;
 	PropertiesPalette_Text*  textPal;
 	PropertiesPalette_XYZ*   xyzPal;
 	Cpalette *Cpal;
@@ -124,6 +126,7 @@
 	QVBoxLayout* pageLayout_5;
 	QVBoxLayout* pageLayout_6;
 	QVBoxLayout* pageLayout_7;
+	QVBoxLayout* pageLayout_8;
 
 	QVBoxLayout* page_group_layout;
 	
@@ -134,6 +137,7 @@
 	QWidget* page_5;
 	QWidget* page_6;
 	QWidget* page_7;
+	QWidget* page_8;
 	QWidget* page_group;
 
 	QToolBox* TabStack;
@@ -149,6 +153,7 @@
 	
 	int idXYZItem;
 	int idShapeItem;
+	int idTableItem;
 	int idTextItem;
 	int idImageItem;
 	int idLineItem;




More information about the scribus-commit mailing list