[Libreoffice-commits] core.git: 4 commits - libreofficekit/qa sc/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Oct 30 15:21:48 UTC 2015
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 181 ++++++++++++++------
sc/source/ui/view/tabview.cxx | 14 +
2 files changed, 146 insertions(+), 49 deletions(-)
New commits:
commit f5ab3e84dfd58722dc74c7369c1ad67237ca462e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 30 16:20:58 2015 +0100
gtktiledviewer: add missing spreadsheet corner button
Change-Id: I3a7af693ccdce2012ddbaa6a3ac8321f29b6356c
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index de57dc9..72297aa 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -67,6 +67,16 @@ public:
static void drawText(cairo_t* pCairo, const GdkRectangle& rRectangle, const std::string& rText);
};
+/// Represents the button at the top left corner for spreadsheets.
+class TiledCornerButton
+{
+public:
+ GtkWidget* m_pDrawingArea;
+ TiledCornerButton();
+ static gboolean draw(GtkWidget* pWidget, cairo_t* pCairo, gpointer pData);
+ gboolean drawImpl(GtkWidget* pWidget, cairo_t* pCairo);
+};
+
/// Represents all the state that is specific to one GtkWindow of this app.
class TiledWindow
{
@@ -93,6 +103,7 @@ public:
bool m_bFindAll;
std::shared_ptr<TiledRowColumnBar> m_pRowBar;
std::shared_ptr<TiledRowColumnBar> m_pColumnBar;
+ std::shared_ptr<TiledCornerButton> m_pCornerButton;
TiledWindow()
: m_pDocView(0),
@@ -169,6 +180,9 @@ gboolean TiledRowColumnBar::drawImpl(GtkWidget* /*pWidget*/, cairo_t* pCairo)
aRectangle.y = nTotal - 1;
aRectangle.width = ROW_HEADER_WIDTH - 1;
aRectangle.height = rHeader.m_nSize;
+ // Left line.
+ cairo_rectangle(pCairo, aRectangle.x, aRectangle.y, 1, aRectangle.height);
+ cairo_fill(pCairo);
// Bottom line.
cairo_rectangle(pCairo, aRectangle.x, aRectangle.y + aRectangle.height, aRectangle.width, 1);
cairo_fill(pCairo);
@@ -178,10 +192,13 @@ gboolean TiledRowColumnBar::drawImpl(GtkWidget* /*pWidget*/, cairo_t* pCairo)
}
else
{
- aRectangle.x = nTotal -1;
+ aRectangle.x = nTotal - 1;
aRectangle.y = 0;
aRectangle.width = rHeader.m_nSize;
aRectangle.height = COLUMN_HEADER_HEIGHT - 1;
+ // Top line.
+ cairo_rectangle(pCairo, aRectangle.x, aRectangle.y, aRectangle.width, 1);
+ cairo_fill(pCairo);
// Right line.
cairo_rectangle(pCairo, aRectangle.x + aRectangle.width , aRectangle.y, 1, aRectangle.height);
cairo_fill(pCairo);
@@ -216,6 +233,8 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
boost::property_tree::ptree aTree;
boost::property_tree::read_json(aStream, aTree);
+ gtk_widget_show(rWindow.m_pCornerButton->m_pDrawingArea);
+
rWindow.m_pRowBar->m_aHeaders.clear();
for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows"))
{
@@ -238,6 +257,33 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
return TRUE;
}
+TiledCornerButton::TiledCornerButton()
+ : m_pDrawingArea(gtk_drawing_area_new())
+{
+ gtk_widget_set_size_request(m_pDrawingArea, TiledRowColumnBar::ROW_HEADER_WIDTH, TiledRowColumnBar::COLUMN_HEADER_HEIGHT);
+ g_signal_connect(m_pDrawingArea, "draw", G_CALLBACK(TiledCornerButton::draw), this);
+}
+
+gboolean TiledCornerButton::draw(GtkWidget* pWidget, cairo_t* pCairo, gpointer pData)
+{
+ return static_cast<TiledCornerButton*>(pData)->drawImpl(pWidget, pCairo);
+}
+
+gboolean TiledCornerButton::drawImpl(GtkWidget* /*pWidget*/, cairo_t* pCairo)
+{
+ cairo_set_source_rgb(pCairo, 0, 0, 0);
+
+ GdkRectangle aRectangle;
+ aRectangle.x = 0;
+ aRectangle.y = 0;
+ aRectangle.width = TiledRowColumnBar::ROW_HEADER_WIDTH;
+ aRectangle.height = TiledRowColumnBar::COLUMN_HEADER_HEIGHT;
+ cairo_rectangle(pCairo, aRectangle.x, aRectangle.y, aRectangle.width, aRectangle.height);
+ cairo_stroke(pCairo);
+
+ return FALSE;
+}
+
static void lcl_registerToolItem(TiledWindow& rWindow, GtkToolItem* pItem, const std::string& rName)
{
rWindow.m_aToolItemCommandNames[pItem] = rName;
@@ -947,6 +993,9 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
// Grid for the row/column bar + doc view.
GtkWidget* pGrid = gtk_grid_new();
gtk_container_add(GTK_CONTAINER(rWindow.m_pVBox), pGrid);
+ rWindow.m_pCornerButton.reset(new TiledCornerButton());
+ // "A1" cell of the grid.
+ gtk_grid_attach(GTK_GRID(pGrid), rWindow.m_pCornerButton->m_pDrawingArea, 0, 0, 1, 1);
rWindow.m_pRowBar.reset(new TiledRowColumnBar(TiledRowColumnBar::ROW));
// "A2" cell of the grid.
gtk_grid_attach(GTK_GRID(pGrid), rWindow.m_pRowBar->m_pDrawingArea, 0, 1, 1, 1);
@@ -977,6 +1026,7 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
// Hide the findbar by default.
gtk_widget_hide(rWindow.m_pFindbar);
// Same for the row/column bar.
+ gtk_widget_hide(rWindow.m_pCornerButton->m_pDrawingArea);
gtk_widget_hide(rWindow.m_pRowBar->m_pDrawingArea);
gtk_widget_hide(rWindow.m_pColumnBar->m_pDrawingArea);
commit 3bdce53c557a1279e7e40d215e34405626bbc628
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 30 16:00:03 2015 +0100
ScTabView::getRowColumnHeaders: emit info about last formatted row/col
Change-Id: I6b4f6eacde84433fa3865e62c692a3f97895b887
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index f35500c..7254ff9 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2290,7 +2290,7 @@ OUString ScTabView::getRowColumnHeaders()
pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
boost::property_tree::ptree aRows;
- for (SCROW nRow = 0; nRow < nEndRow; ++nRow)
+ for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
{
boost::property_tree::ptree aRow;
sal_uInt16 nSize = pRowBar[SC_SPLIT_BOTTOM]->GetEntrySize(nRow);
@@ -2301,7 +2301,7 @@ OUString ScTabView::getRowColumnHeaders()
}
boost::property_tree::ptree aCols;
- for (SCCOL nCol = 0; nCol < nEndCol; ++nCol)
+ for (SCCOL nCol = 0; nCol <= nEndCol; ++nCol)
{
boost::property_tree::ptree aCol;
sal_uInt16 nSize = pColBar[SC_SPLIT_LEFT]->GetEntrySize(nCol);
commit 18bf71a2002b979dbf80d85c8863af39783bf87d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 30 14:57:16 2015 +0100
gtktiledviewer: initial column headers for spreadsheet documents
Change-Id: I10e88b4ff4ab0cfb29e97fa608d8acd69ce0f062
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 2502b50..de57dc9 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -32,8 +32,8 @@ static int help()
return 1;
}
-/// Represents the row header widget for spreadsheets.
-class TiledRowBar
+/// Represents the row or column header widget for spreadsheets.
+class TiledRowColumnBar
{
public:
/// Stores size and content of a single row header.
@@ -48,17 +48,21 @@ public:
}
};
- static const int HEADER_WIDTH = 50;
+ enum TiledBarType { ROW, COLUMN };
+
+ static const int ROW_HEADER_WIDTH = 50;
+ static const int COLUMN_HEADER_HEIGHT = 20;
GtkWidget* m_pDrawingArea;
std::vector<Header> m_aHeaders;
- int m_nHeightPixel = 0;
+ /// Height for row bar, width for column bar.
+ int m_nSizePixel;
+ TiledBarType m_eType;
- TiledRowBar(GtkWidget* pDocView);
+ TiledRowColumnBar(TiledBarType eType);
static gboolean draw(GtkWidget* pWidget, cairo_t* pCairo, gpointer pData);
gboolean drawImpl(GtkWidget* pWidget, cairo_t* pCairo);
static gboolean docConfigureEvent(GtkWidget* pWidget, GdkEventConfigure* pEvent, gpointer pData);
- gboolean docConfigureEventImpl(GtkWidget* pWidget, GdkEventConfigure* pEvent);
/// Draws rText at the center of rRectangle on pCairo.
static void drawText(cairo_t* pCairo, const GdkRectangle& rRectangle, const std::string& rText);
};
@@ -87,7 +91,8 @@ public:
GtkWidget* m_pFindbarEntry;
GtkWidget* m_pFindbarLabel;
bool m_bFindAll;
- std::shared_ptr<TiledRowBar> m_pRowBar;
+ std::shared_ptr<TiledRowColumnBar> m_pRowBar;
+ std::shared_ptr<TiledRowColumnBar> m_pColumnBar;
TiledWindow()
: m_pDocView(0),
@@ -124,21 +129,24 @@ static TiledWindow& lcl_getTiledWindow(GtkWidget* pWidget)
return g_aWindows[pToplevel];
}
-TiledRowBar::TiledRowBar(GtkWidget* pDocView)
+TiledRowColumnBar::TiledRowColumnBar(TiledBarType eType)
: m_pDrawingArea(gtk_drawing_area_new()),
- m_nHeightPixel(0)
+ m_nSizePixel(0),
+ m_eType(eType)
{
- gtk_widget_set_size_request(m_pDrawingArea, HEADER_WIDTH, -1);
- g_signal_connect(m_pDrawingArea, "draw", G_CALLBACK(TiledRowBar::draw), this);
- g_signal_connect(pDocView, "configure-event", G_CALLBACK(TiledRowBar::docConfigureEvent), this);
+ if (m_eType == ROW)
+ gtk_widget_set_size_request(m_pDrawingArea, ROW_HEADER_WIDTH, -1);
+ else
+ gtk_widget_set_size_request(m_pDrawingArea, -1, COLUMN_HEADER_HEIGHT);
+ g_signal_connect(m_pDrawingArea, "draw", G_CALLBACK(TiledRowColumnBar::draw), this);
}
-gboolean TiledRowBar::draw(GtkWidget* pWidget, cairo_t* pCairo, gpointer pData)
+gboolean TiledRowColumnBar::draw(GtkWidget* pWidget, cairo_t* pCairo, gpointer pData)
{
- return static_cast<TiledRowBar*>(pData)->drawImpl(pWidget, pCairo);
+ return static_cast<TiledRowColumnBar*>(pData)->drawImpl(pWidget, pCairo);
}
-void TiledRowBar::drawText(cairo_t* pCairo, const GdkRectangle& rRectangle, const std::string& rText)
+void TiledRowColumnBar::drawText(cairo_t* pCairo, const GdkRectangle& rRectangle, const std::string& rText)
{
cairo_text_extents_t extents;
cairo_text_extents(pCairo, rText.c_str(), &extents);
@@ -147,7 +155,7 @@ void TiledRowBar::drawText(cairo_t* pCairo, const GdkRectangle& rRectangle, cons
cairo_show_text(pCairo, rText.c_str());
}
-gboolean TiledRowBar::drawImpl(GtkWidget* /*pWidget*/, cairo_t* pCairo)
+gboolean TiledRowColumnBar::drawImpl(GtkWidget* /*pWidget*/, cairo_t* pCairo)
{
cairo_set_source_rgb(pCairo, 0, 0, 0);
@@ -155,56 +163,76 @@ gboolean TiledRowBar::drawImpl(GtkWidget* /*pWidget*/, cairo_t* pCairo)
for (const Header& rHeader : m_aHeaders)
{
GdkRectangle aRectangle;
- aRectangle.x = 0;
- aRectangle.y = nTotal - 1;
- aRectangle.width = HEADER_WIDTH - 1;
- aRectangle.height = rHeader.m_nSize;
- // Bottom line.
- cairo_rectangle(pCairo, aRectangle.x, aRectangle.y + aRectangle.height, aRectangle.width, 1);
- cairo_fill(pCairo);
- // Left line.
- cairo_rectangle(pCairo, aRectangle.width, aRectangle.y, 1, aRectangle.height);
- cairo_fill(pCairo);
+ if (m_eType == ROW)
+ {
+ aRectangle.x = 0;
+ aRectangle.y = nTotal - 1;
+ aRectangle.width = ROW_HEADER_WIDTH - 1;
+ aRectangle.height = rHeader.m_nSize;
+ // Bottom line.
+ cairo_rectangle(pCairo, aRectangle.x, aRectangle.y + aRectangle.height, aRectangle.width, 1);
+ cairo_fill(pCairo);
+ // Right line.
+ cairo_rectangle(pCairo, aRectangle.width, aRectangle.y, 1, aRectangle.height);
+ cairo_fill(pCairo);
+ }
+ else
+ {
+ aRectangle.x = nTotal -1;
+ aRectangle.y = 0;
+ aRectangle.width = rHeader.m_nSize;
+ aRectangle.height = COLUMN_HEADER_HEIGHT - 1;
+ // Right line.
+ cairo_rectangle(pCairo, aRectangle.x + aRectangle.width , aRectangle.y, 1, aRectangle.height);
+ cairo_fill(pCairo);
+ // Bottom line.
+ cairo_rectangle(pCairo, aRectangle.x, aRectangle.height, aRectangle.width, 1);
+ cairo_fill(pCairo);
+ }
drawText(pCairo, aRectangle, rHeader.m_aText);
nTotal += rHeader.m_nSize;
- if (nTotal > m_nHeightPixel)
+ if (nTotal > m_nSizePixel)
break;
}
return FALSE;
}
-gboolean TiledRowBar::docConfigureEvent(GtkWidget* pWidget, GdkEventConfigure* pEvent, gpointer pData)
-{
- return static_cast<TiledRowBar*>(pData)->docConfigureEventImpl(pWidget, pEvent);
-}
-
-gboolean TiledRowBar::docConfigureEventImpl(GtkWidget* pDocView, GdkEventConfigure* /*pEvent*/)
+gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfigure* /*pEvent*/, gpointer /*pData*/)
{
- if (g_aWindows.find(gtk_widget_get_toplevel(pDocView)) == g_aWindows.end())
- return TRUE;
-
TiledWindow& rWindow = lcl_getTiledWindow(pDocView);
GtkAdjustment* pVAdjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(rWindow.m_pScrolledWindow));
- m_nHeightPixel = gtk_adjustment_get_page_size(pVAdjustment);
+ rWindow.m_pRowBar->m_nSizePixel = gtk_adjustment_get_page_size(pVAdjustment);
+ GtkAdjustment* pHAdjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(rWindow.m_pScrolledWindow));
+ rWindow.m_pColumnBar->m_nSizePixel = gtk_adjustment_get_page_size(pHAdjustment);
LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(pDocView));
if (pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_SPREADSHEET)
{
- m_aHeaders.clear();
char* pValues = pDocument->pClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders");
std::stringstream aStream(pValues);
free(pValues);
assert(!aStream.str().empty());
boost::property_tree::ptree aTree;
boost::property_tree::read_json(aStream, aTree);
+
+ rWindow.m_pRowBar->m_aHeaders.clear();
for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows"))
{
Header aHeader(std::atoi(rValue.second.get<std::string>("size").c_str()), rValue.second.get<std::string>("text"));
- m_aHeaders.push_back(aHeader);
+ rWindow.m_pRowBar->m_aHeaders.push_back(aHeader);
+ }
+ gtk_widget_show(rWindow.m_pRowBar->m_pDrawingArea);
+ gtk_widget_queue_draw(rWindow.m_pRowBar->m_pDrawingArea);
+
+ rWindow.m_pColumnBar->m_aHeaders.clear();
+ for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns"))
+ {
+ Header aHeader(std::atoi(rValue.second.get<std::string>("size").c_str()), rValue.second.get<std::string>("text"));
+ rWindow.m_pColumnBar->m_aHeaders.push_back(aHeader);
}
- gtk_widget_show(m_pDrawingArea);
- gtk_widget_queue_draw(m_pDrawingArea);
+ gtk_widget_show(rWindow.m_pColumnBar->m_pDrawingArea);
+ gtk_widget_queue_draw(rWindow.m_pColumnBar->m_pDrawingArea);
}
return TRUE;
@@ -916,17 +944,22 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
gtk_box_pack_end(GTK_BOX(rWindow.m_pVBox), rWindow.m_pFindbar, FALSE, FALSE, 0);
- // Horizontal box for the row bar + doc view.
- GtkWidget* pHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_container_add(GTK_CONTAINER(rWindow.m_pVBox), pHBox);
- rWindow.m_pRowBar.reset(new TiledRowBar(rWindow.m_pDocView));
- gtk_box_pack_start(GTK_BOX(pHBox), rWindow.m_pRowBar->m_pDrawingArea, FALSE, FALSE, 0);
+ // Grid for the row/column bar + doc view.
+ GtkWidget* pGrid = gtk_grid_new();
+ gtk_container_add(GTK_CONTAINER(rWindow.m_pVBox), pGrid);
+ rWindow.m_pRowBar.reset(new TiledRowColumnBar(TiledRowColumnBar::ROW));
+ // "A2" cell of the grid.
+ gtk_grid_attach(GTK_GRID(pGrid), rWindow.m_pRowBar->m_pDrawingArea, 0, 1, 1, 1);
+ rWindow.m_pColumnBar.reset(new TiledRowColumnBar(TiledRowColumnBar::COLUMN));
+ // "B1" cell of the grid.
+ gtk_grid_attach(GTK_GRID(pGrid), rWindow.m_pColumnBar->m_pDrawingArea, 1, 0, 1, 1);
// Scrolled window for DocView
rWindow.m_pScrolledWindow = gtk_scrolled_window_new(0, 0);
gtk_widget_set_hexpand(rWindow.m_pScrolledWindow, TRUE);
gtk_widget_set_vexpand(rWindow.m_pScrolledWindow, TRUE);
- gtk_container_add(GTK_CONTAINER(pHBox), rWindow.m_pScrolledWindow);
+ // "B2" cell of the grid
+ gtk_grid_attach(GTK_GRID(pGrid), rWindow.m_pScrolledWindow, 1, 1, 1, 1);
gtk_container_add(GTK_CONTAINER(rWindow.m_pScrolledWindow), rWindow.m_pDocView);
@@ -943,10 +976,12 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
gtk_widget_show_all(pWindow);
// Hide the findbar by default.
gtk_widget_hide(rWindow.m_pFindbar);
- // Same for the row bar.
+ // Same for the row/column bar.
gtk_widget_hide(rWindow.m_pRowBar->m_pDrawingArea);
+ gtk_widget_hide(rWindow.m_pColumnBar->m_pDrawingArea);
g_aWindows[pWindow] = rWindow;
+ g_signal_connect(rWindow.m_pDocView, "configure-event", G_CALLBACK(TiledRowColumnBar::docConfigureEvent), 0);
return pWindow;
}
commit ac47e5758e56ac30d98c1d6386dfad24ac59b1f6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 30 13:57:28 2015 +0100
ScTabView::getRowColumnHeaders: include info about columns, too
Change-Id: Id7db9fa9b451dcf2423142b38c2c12b369e16fae
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index aa50aaf..f35500c 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2300,8 +2300,20 @@ OUString ScTabView::getRowColumnHeaders()
aRows.push_back(std::make_pair("", aRow));
}
+ boost::property_tree::ptree aCols;
+ for (SCCOL nCol = 0; nCol < nEndCol; ++nCol)
+ {
+ boost::property_tree::ptree aCol;
+ sal_uInt16 nSize = pColBar[SC_SPLIT_LEFT]->GetEntrySize(nCol);
+ aCol.put("size", OString::number(nSize).getStr());
+ OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol);
+ aCol.put("text", aText.toUtf8().getStr());
+ aCols.push_back(std::make_pair("", aCol));
+ }
+
boost::property_tree::ptree aTree;
aTree.add_child("rows", aRows);
+ aTree.add_child("columns", aCols);
std::stringstream aStream;
boost::property_tree::write_json(aStream, aTree);
return OUString::fromUtf8(aStream.str().c_str());
More information about the Libreoffice-commits
mailing list