tomboy r1880 - in trunk: . Tomboy/Addins/ExportToHtml



Author: btimothy
Date: Fri Feb 22 21:42:18 2008
New Revision: 1880
URL: http://svn.gnome.org/viewvc/tomboy?rev=1880&view=rev

Log:
* Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs,
  Tomboy/Addins/ExportToHtml/NoteNameResolver.cs: Pass in the
  original note when constructing NoteNameResolver so the original
  note is not included more than once on an export.  Also keep track
  of how many times a note is resolved so that notes cannot be
  included more than once on an export (regardless of what the
  ExportToHtml.xsl says).  Fixes bug #422951.
* Tomboy/Addins/ExportToHtml/ExportToHtml.xsl: Don't use the width
  value from the tomboy note anymore.  In some cases this isn't being
  set properly anyway and it's ending up being width:0, which is note
  displaying properly in a browser.

Modified:
   trunk/ChangeLog
   trunk/Tomboy/Addins/ExportToHtml/ExportToHtml.xsl
   trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs
   trunk/Tomboy/Addins/ExportToHtml/NoteNameResolver.cs

Modified: trunk/Tomboy/Addins/ExportToHtml/ExportToHtml.xsl
==============================================================================
--- trunk/Tomboy/Addins/ExportToHtml/ExportToHtml.xsl	(original)
+++ trunk/Tomboy/Addins/ExportToHtml/ExportToHtml.xsl	Fri Feb 22 21:42:18 2008
@@ -71,8 +71,7 @@
 
 <xsl:template match="tomboy:text">
 	<div class="note" 
-	     id="{/tomboy:note/tomboy:title}"
-	     style="width:{/tomboy:note/tomboy:width};">
+	     id="{/tomboy:note/tomboy:title}">
 		<a name="#{/tomboy:note/tomboy:title}" />
 		<xsl:apply-templates select="node()" />
 	</div>

Modified: trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs	(original)
+++ trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs	Fri Feb 22 21:42:18 2008
@@ -188,7 +188,7 @@
 				args.AddParam ("font", "", font);
 			}
 
-			NoteNameResolver resolver = new NoteNameResolver (note.Manager);
+			NoteNameResolver resolver = new NoteNameResolver (note.Manager, note);
 			xsl.Transform (doc, args, writer, resolver);
 		}
 	}

Modified: trunk/Tomboy/Addins/ExportToHtml/NoteNameResolver.cs
==============================================================================
--- trunk/Tomboy/Addins/ExportToHtml/NoteNameResolver.cs	(original)
+++ trunk/Tomboy/Addins/ExportToHtml/NoteNameResolver.cs	Fri Feb 22 21:42:18 2008
@@ -1,4 +1,5 @@
 using System;
+using System.Collections.Generic;
 using System.IO;
 using System.Text;
 using System.Xml;
@@ -9,10 +10,23 @@
 	public class NoteNameResolver : XmlResolver
 	{
 		NoteManager manager;
+		
+		// Use this dictionary to keep track of notes that have already been
+		// resolved.  The key is the Note.Title:string and the value is the
+		// number of times the specified note has been requested.  ResolveUri
+		// for some reason, gets called twice for each of the notes.  Allow it
+		// to be called twice, but then return null after that.
+		Dictionary<string, int> resolvedNotes;
 
-		public NoteNameResolver (NoteManager manager)
+		public NoteNameResolver (NoteManager manager, Note originNote)
 		{
 			this.manager = manager;
+			
+			resolvedNotes = new Dictionary<string,int> ();
+			
+			// Set the resolved count to 2 for the original note so it won't
+			// be included again.
+			resolvedNotes [originNote.Title.ToLower ()] = 2;
 		}
 
 		public override System.Net.ICredentials Credentials
@@ -31,7 +45,6 @@
 			Stream stream = WriterToStream (writer);
 			writer.Close ();
 
-			Logger.Log ("GetEntity: Returning Stream");
 			return stream;
 		}
 
@@ -58,9 +71,21 @@
 
 		public override Uri ResolveUri (Uri baseUri, string relativeUri)
 		{
+			string noteTitleLowered = relativeUri.ToLower ();
+			if (resolvedNotes.ContainsKey (noteTitleLowered) == true
+				&& resolvedNotes [noteTitleLowered] > 1) {
+				return null;
+			}
+			
 			Note note = manager.Find (relativeUri);
-			if (note != null)
+			if (note != null) {
+				if (resolvedNotes.ContainsKey (noteTitleLowered) == true) {
+					resolvedNotes [noteTitleLowered] = 2;
+				} else {
+					resolvedNotes [noteTitleLowered] = 1;
+				}
 				return new Uri (note.Uri);
+			}
 
 			return null;
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]