sc/source/filter/html/htmlexp.cxx | 62 +++++++++++++++++++++++++++++++++++++ sc/source/filter/html/htmlexp2.cxx | 2 - 2 files changed, 63 insertions(+), 1 deletion(-)
New commits: commit 503ea2d347c696eff22a87df11c8c377f0f6ddc9 Author: Joan Paraiso <phora.pub...@outlook.com> Date: Fri Sep 25 01:50:36 2015 -0700 Render the notes in spreadsheets as inline html comments It's more valuable to have the raw text data of the html instead of having it locked up in images. If the comments are exported as images, then it makes it almost impossible to discern what comment belongs to what cell when viewing the html file itself. This is done by rendering the comments in their own comment tag (to make it still easy to extract from scripts that modify html) that is shown to the user. This element is initially not displayed until the user hovers over the comment indicator The comment indicator is denoted by a 0.5em by 0.5em red square with a black border. The notes will always appear on a pale yellow background with black text when the indicator is hovered over. Change-Id: I01a3dfd77ec54566e64b196b8df3309ea941ad4c Reviewed-on: https://gerrit.libreoffice.org/18837 Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index fef9390..8ddd831 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -52,6 +52,7 @@ #include "htmlexp.hxx" #include "filter.hxx" #include "global.hxx" +#include "postit.hxx" #include "document.hxx" #include "attrib.hxx" #include "patattr.hxx" @@ -88,6 +89,13 @@ const static sal_Char sMyBegComment[] = "<!-- "; const static sal_Char sMyEndComment[] = " -->"; const static sal_Char sFontFamily[] = "font-family:"; const static sal_Char sFontSize[] = "font-size:"; +const static sal_Char sDisplay[] = "display:"; +const static sal_Char sBorder[] = "border:"; +const static sal_Char sPadding[] = "padding:"; +const static sal_Char sPosition[] = "position:"; +const static sal_Char sBackground[] = "background:"; +const static sal_Char sWidth[] = "width:"; +const static sal_Char sHeight[] = "height:"; const sal_uInt16 ScHTMLExport::nDefaultFontSize[SC_HTML_FONTSIZES] = { @@ -390,6 +398,38 @@ void ScHTMLExport::WriteHeader() } rStrm.WriteCharPtr( "; " ).WriteCharPtr( sFontSize ) .WriteCharPtr( GetFontSizeCss( ( sal_uInt16 ) aHTMLStyle.nFontHeight ) ).WriteCharPtr( " }" ); + + OUT_LF(); + + // write the style for the comments to make them stand out from normal cell content + // this is done through only showing the cell contents when the custom indicator is hovered + rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_HTML_anchor ).WriteCharPtr(".comment-indicator:hover") + .WriteCharPtr(" + ").WriteCharPtr( OOO_STRING_SVTOOLS_HTML_comment2 ).WriteCharPtr(" { ") + .WriteCharPtr(sBackground).WriteCharPtr("#ffd").WriteCharPtr("; ") + .WriteCharPtr(sPosition).WriteCharPtr("absolute").WriteCharPtr("; ") + .WriteCharPtr(sDisplay).WriteCharPtr("block").WriteCharPtr("; ") + .WriteCharPtr(sBorder).WriteCharPtr("1px solid black").WriteCharPtr("; ") + .WriteCharPtr(sPadding).WriteCharPtr("0.5em").WriteCharPtr("; ") + .WriteCharPtr(" } "); + + OUT_LF(); + + rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_HTML_anchor ).WriteCharPtr(".comment-indicator") + .WriteCharPtr(" { ") + .WriteCharPtr(sBackground).WriteCharPtr("red").WriteCharPtr("; ") + .WriteCharPtr(sDisplay).WriteCharPtr("inline-block").WriteCharPtr("; ") + .WriteCharPtr(sBorder).WriteCharPtr("1px solid black").WriteCharPtr("; ") + .WriteCharPtr(sWidth).WriteCharPtr("0.5em").WriteCharPtr("; ") + .WriteCharPtr(sHeight).WriteCharPtr("0.5em").WriteCharPtr("; ") + .WriteCharPtr(" } "); + + OUT_LF(); + + rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_HTML_comment2 ).WriteCharPtr(" { ") + .WriteCharPtr(sDisplay).WriteCharPtr("none").WriteCharPtr("; ") + .WriteCharPtr(" } "); + + IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_style ); IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_head ); @@ -1059,6 +1099,28 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab ) TAG_ON(aStrTD.makeStringAndClear().getStr()); + //write the note for this as the first thing in the tag + if (pDoc->HasNote(aPos)) + { + ScPostIt* pNote = pDoc->GetNote(aPos); + + //create the comment indicator + OStringBuffer aStr(OOO_STRING_SVTOOLS_HTML_anchor); + aStr.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_class) + .append("=\"").append("comment-indicator").append("\""); + TAG_ON(aStr.makeStringAndClear().getStr()); + TAG_OFF(OOO_STRING_SVTOOLS_HTML_anchor); + OUT_LF(); + + //create the element holding the contents + //this is a bit naive, since it doesn't separate + //lines into html breaklines yet + TAG_ON(OOO_STRING_SVTOOLS_HTML_comment2); + OUT_STR( pNote->GetText() ); + TAG_OFF(OOO_STRING_SVTOOLS_HTML_comment2); + OUT_LF(); + } + if ( bBold ) TAG_ON( OOO_STRING_SVTOOLS_HTML_bold ); if ( bItalic ) TAG_ON( OOO_STRING_SVTOOLS_HTML_italic ); if ( bUnderline ) TAG_ON( OOO_STRING_SVTOOLS_HTML_underline ); diff --git a/sc/source/filter/html/htmlexp2.cxx b/sc/source/filter/html/htmlexp2.cxx index c96388d..aa80aa2 100644 --- a/sc/source/filter/html/htmlexp2.cxx +++ b/sc/source/filter/html/htmlexp2.cxx @@ -77,7 +77,7 @@ void ScHTMLExport::FillGraphList( const SdrPage* pPage, SCTAB nTab, while ( pObject ) { Rectangle aObjRect = pObject->GetCurrentBoundRect(); - if ( bAll || aRect.IsInside( aObjRect ) ) + if ( (bAll || aRect.IsInside( aObjRect )) && !ScDrawLayer::IsNoteCaption(pObject) ) { Size aSpace; ScRange aR = pDoc->GetRange( nTab, aObjRect ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits