Commit 31dd5842 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Write protection flags. Store falg. (excel_read_workbook_PROTECT): New

2006-03-13  Morten Welinder  <terra@gnome.org>

	* ms-excel-write.c (write_sheet_head): Write protection flags.
	* ms-excel-read.c (excel_read_sheet_PROTECT): Store falg.
	(excel_read_workbook_PROTECT): New function.
	(excel_read_workbook): Read protection flags.
	Patch from Klokan Petr Pridal.  [#330129]
parent 09eacd5e
...@@ -2,6 +2,7 @@ Gnumeric 1.6.3 ...@@ -2,6 +2,7 @@ Gnumeric 1.6.3
Klokan Pridal: Klokan Pridal:
* Implement xml saving/loading of "protected" attribute. [#334257] * Implement xml saving/loading of "protected" attribute. [#334257]
* Implement xls saving/loading of "protected" attribute. [#330129]
Morten: Morten:
* Fix printing issue when sheet is zoomed. [#332932] * Fix printing issue when sheet is zoomed. [#332932]
......
2006-03-13 Morten Welinder <terra@gnome.org>
* ms-excel-write.c (write_sheet_head): Write protection flags.
* ms-excel-read.c (excel_read_sheet_PROTECT): Store falg.
(excel_read_workbook_PROTECT): New function.
(excel_read_workbook): Read protection flags.
Patch from Klokan Petr Pridal. [#330129]
2006-03-10 Jody Goldberg <jody@gnome.org> 2006-03-10 Jody Goldberg <jody@gnome.org>
* ms-formula-read.c (excel_parse_formula) : back port handling of * ms-formula-read.c (excel_parse_formula) : back port handling of
......
...@@ -4199,19 +4199,35 @@ sheet_container (ExcelReadSheet *esheet) ...@@ -4199,19 +4199,35 @@ sheet_container (ExcelReadSheet *esheet)
} }
static gboolean static gboolean
excel_read_PROTECT (BiffQuery *q, char const *obj_type) excel_read_sheet_PROTECT (BiffQuery *q, ExcelReadSheet *esheet)
{ {
/* TODO: Use this information when gnumeric supports protection */
gboolean is_protected = TRUE; gboolean is_protected = TRUE;
/* MS Docs fail to mention that in some stream this /* MS Docs fail to mention that in some stream this
* record can have size zero. I assume the in that * record can have size zero. I assume the in that
* case its existence is the flag. * case its existence is the flag.
*/ */
if (q->length > 0) if (q->length >= 2)
is_protected = (1 == GSF_LE_GET_GUINT16 (q->data)); is_protected = (1 == GSF_LE_GET_GUINT16 (q->data));
d (1,if (is_protected) fprintf (stderr,"%s is protected\n", obj_type);); esheet->sheet->is_protected = is_protected;
return is_protected;
}
static gboolean
excel_read_workbook_PROTECT (BiffQuery *q, WorkbookView *wb_view)
{
gboolean is_protected = TRUE;
/* MS Docs fail to mention that in some stream this
* record can have size zero. I assume the in that
* case its existence is the flag.
*/
if (q->length >= 2)
is_protected = (1 == GSF_LE_GET_GUINT16 (q->data));
wb_view->is_protected = is_protected;
return is_protected; return is_protected;
} }
...@@ -5547,7 +5563,8 @@ excel_read_sheet (BiffQuery *q, GnmXLImporter *importer, ...@@ -5547,7 +5563,8 @@ excel_read_sheet (BiffQuery *q, GnmXLImporter *importer,
case BIFF_REFMODE: excel_read_REFMODE (q, esheet); break; case BIFF_REFMODE: excel_read_REFMODE (q, esheet); break;
case BIFF_DELTA: excel_read_DELTA (q, importer); break; case BIFF_DELTA: excel_read_DELTA (q, importer); break;
case BIFF_ITERATION: excel_read_ITERATION (q, importer); break; case BIFF_ITERATION: excel_read_ITERATION (q, importer); break;
case BIFF_PROTECT: excel_read_PROTECT (q, "Sheet"); break; case BIFF_OBJPROTECT:
case BIFF_PROTECT: excel_read_sheet_PROTECT (q, esheet); break;
case BIFF_PASSWORD: case BIFF_PASSWORD:
if (q->length == 2) { if (q->length == 2) {
...@@ -5633,7 +5650,6 @@ excel_read_sheet (BiffQuery *q, GnmXLImporter *importer, ...@@ -5633,7 +5650,6 @@ excel_read_sheet (BiffQuery *q, GnmXLImporter *importer,
case BIFF_SAVERECALC: break; case BIFF_SAVERECALC: break;
case BIFF_TAB_COLOR: excel_read_TAB_COLOR (q, esheet); break; case BIFF_TAB_COLOR: excel_read_TAB_COLOR (q, esheet); break;
case BIFF_OBJPROTECT: excel_read_PROTECT (q, "Sheet"); break;
case BIFF_COLINFO: excel_read_COLINFO (q, esheet); break; case BIFF_COLINFO: excel_read_COLINFO (q, esheet); break;
case BIFF_RK: case BIFF_RK:
...@@ -6082,7 +6098,7 @@ excel_read_workbook (IOContext *context, WorkbookView *wb_view, GsfInput *input, ...@@ -6082,7 +6098,7 @@ excel_read_workbook (IOContext *context, WorkbookView *wb_view, GsfInput *input,
case BIFF_OBJPROTECT: case BIFF_OBJPROTECT:
case BIFF_PROTECT: case BIFF_PROTECT:
excel_read_PROTECT (q, "Workbook"); excel_read_workbook_PROTECT (q, wb_view);
break; break;
case BIFF_PASSWORD: case BIFF_PASSWORD:
......
...@@ -4077,6 +4077,12 @@ write_sheet_head (BiffPut *bp, ExcelWriteSheet *esheet) ...@@ -4077,6 +4077,12 @@ write_sheet_head (BiffPut *bp, ExcelWriteSheet *esheet)
* to make our lives easier */ * to make our lives easier */
excel_write_externsheets_v7 (esheet->ewb); excel_write_externsheets_v7 (esheet->ewb);
} }
if (sheet->is_protected) {
ms_biff_put_2byte (bp, BIFF_PROTECT, 1 );
ms_biff_put_2byte (bp, BIFF_OBJPROTECT, 1);
ms_biff_put_2byte (bp, BIFF_SCENPROTECT, 1);
ms_biff_put_2byte (bp, BIFF_PASSWORD, 0);
}
excel_write_DEFCOLWIDTH (bp, esheet); excel_write_DEFCOLWIDTH (bp, esheet);
excel_write_colinfos (bp, esheet); excel_write_colinfos (bp, esheet);
excel_write_AUTOFILTERINFO (bp, esheet); excel_write_AUTOFILTERINFO (bp, esheet);
...@@ -5191,7 +5197,7 @@ excel_write_workbook (ExcelWriteState *ewb) ...@@ -5191,7 +5197,7 @@ excel_write_workbook (ExcelWriteState *ewb)
} }
ms_biff_put_2byte (ewb->bp, BIFF_WINDOWPROTECT, 0); ms_biff_put_2byte (ewb->bp, BIFF_WINDOWPROTECT, 0);
ms_biff_put_2byte (ewb->bp, BIFF_PROTECT, 0); ms_biff_put_2byte (ewb->bp, BIFF_PROTECT, ewb->gnum_wb_view->is_protected ? 1 : 0);
ms_biff_put_2byte (ewb->bp, BIFF_PASSWORD, 0); ms_biff_put_2byte (ewb->bp, BIFF_PASSWORD, 0);
if (bp->version >= MS_BIFF_V8) { if (bp->version >= MS_BIFF_V8) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment