Re: [PATCH] BUG 1486 copied formula is not previewed.

2007-06-21 Thread Alfredo Braunstein
Bo Peng wrote:

 Waiting for two OKs.
 
 Please use this version.

I wonder if there is any side-effect of using something like the attached
instead.

A/

Index: InsetMathHull.cpp
===
--- InsetMathHull.cpp	(revision 18837)
+++ InsetMathHull.cpp	(working copy)
@@ -182,7 +182,7 @@
 InsetMathHull::InsetMathHull(InsetMathHull const  other)
 	: InsetMathGrid(other),
 	  type_(other.type_), nonum_(other.nonum_), label_(other.label_),
-	  preview_(new RenderPreview(this))
+	  preview_(new RenderPreview(*other.preview_, this))
 {}
 
 



Re: [PATCH] BUG 1486 copied formula is not previewed.

2007-06-21 Thread Bo Peng

I wonder if there is any side-effect of using something like the attached
instead.


Your patch is better, so you have my OK.

My original thought was to remove outside addPreview so that all
MathHull (and other previewable insets) get their preview in this way
(if preview empty, add snippet). I mean, buffer or bufferview should
not have to worry about adding preview for insets. If some nested
mathed is changed, it can simply remove this snippet so that it will
be re-generated

Anyway, your patch fixes this specific problem with less code, so it can go in.

Cheers,
Bo


Re: [PATCH] BUG 1486 copied formula is not previewed.

2007-06-21 Thread José Matos
On Thursday 21 June 2007 14:36:33 Bo Peng wrote:
 Anyway, your patch fixes this specific problem with less code, so it can go
 in.

 Cheers,
 Bo

OK.

-- 
José Abílio


Re: [PATCH] BUG 1486 copied formula is not previewed.

2007-06-21 Thread Alfredo Braunstein
Bo Peng wrote:

>> Waiting for two OKs.
> 
> Please use this version.

I wonder if there is any side-effect of using something like the attached
instead.

A/

Index: InsetMathHull.cpp
===
--- InsetMathHull.cpp	(revision 18837)
+++ InsetMathHull.cpp	(working copy)
@@ -182,7 +182,7 @@
 InsetMathHull::InsetMathHull(InsetMathHull const & other)
 	: InsetMathGrid(other),
 	  type_(other.type_), nonum_(other.nonum_), label_(other.label_),
-	  preview_(new RenderPreview(this))
+	  preview_(new RenderPreview(*other.preview_, this))
 {}
 
 



Re: [PATCH] BUG 1486 copied formula is not previewed.

2007-06-21 Thread Bo Peng

I wonder if there is any side-effect of using something like the attached
instead.


Your patch is better, so you have my OK.

My original thought was to remove outside addPreview so that all
MathHull (and other previewable insets) get their preview in this way
(if preview empty, add snippet). I mean, buffer or bufferview should
not have to worry about adding preview for insets. If some nested
mathed is changed, it can simply remove this snippet so that it will
be re-generated

Anyway, your patch fixes this specific problem with less code, so it can go in.

Cheers,
Bo


Re: [PATCH] BUG 1486 copied formula is not previewed.

2007-06-21 Thread José Matos
On Thursday 21 June 2007 14:36:33 Bo Peng wrote:
> Anyway, your patch fixes this specific problem with less code, so it can go
> in.
>
> Cheers,
> Bo

OK.

-- 
José Abílio


Re: [PATCH] BUG 1486 copied formula is not previewed.

2007-06-20 Thread Bo Peng

Waiting for two OKs.


Please use this version.

Bo
Index: src/insets/RenderPreview.h
===
--- src/insets/RenderPreview.h	(revision 18839)
+++ src/insets/RenderPreview.h	(working copy)
@@ -51,6 +51,9 @@
 	RenderPreview(RenderPreview const , Inset const *);
 	std::auto_ptrRenderBase clone(Inset const *) const;
 
+	/// 
+	bool empty() const { return snippet_.empty(); }
+
 	/// Compute the size of the object, returned in dim
 	bool metrics(MetricsInfo , Dimension  dim) const;
 	///
Index: src/mathed/InsetMathHull.cpp
===
--- src/mathed/InsetMathHull.cpp	(revision 18839)
+++ src/mathed/InsetMathHull.cpp	(working copy)
@@ -114,7 +114,15 @@
 		return numbered ?  : *;
 	}
 
+	docstring const latex_string(InsetMathHull const  inset)
+	{
+		odocstringstream ls;
+		WriteStream wi(ls, false, false);
+		inset.write(wi);
+		return ls.str();
+	}
 
+
 } // end anon namespace
 
 
@@ -276,6 +284,11 @@
 bool InsetMathHull::previewState(BufferView * bv) const
 {
 	if (!editing(bv)  RenderPreview::status() == LyXRC::PREVIEW_ON) {
+		// BUG 1486: preview_ of copied formula is empty
+		if (preview_-empty()) {
+			docstring const snippet = latex_string(*this);
+			preview_-addPreview(snippet, *bv-buffer());
+		}
 		graphics::PreviewImage const * pimage =
 			preview_-getPreviewImage(*bv-buffer());
 		return pimage  pimage-image();
@@ -395,19 +408,7 @@
 }
 
 
-namespace {
 
-docstring const latex_string(InsetMathHull const  inset)
-{
-	odocstringstream ls;
-	WriteStream wi(ls, false, false);
-	inset.write(wi);
-	return ls.str();
-}
-
-} // namespace anon
-
-
 void InsetMathHull::addPreview(graphics::PreviewLoader  ploader) const
 {
 	if (RenderPreview::status() == LyXRC::PREVIEW_ON) {


Re: [PATCH] BUG 1486 copied formula is not previewed.

2007-06-20 Thread Bo Peng

Waiting for two OKs.


Please use this version.

Bo
Index: src/insets/RenderPreview.h
===
--- src/insets/RenderPreview.h	(revision 18839)
+++ src/insets/RenderPreview.h	(working copy)
@@ -51,6 +51,9 @@
 	RenderPreview(RenderPreview const &, Inset const *);
 	std::auto_ptr clone(Inset const *) const;
 
+	/// 
+	bool empty() const { return snippet_.empty(); }
+
 	/// Compute the size of the object, returned in dim
 	bool metrics(MetricsInfo &, Dimension & dim) const;
 	///
Index: src/mathed/InsetMathHull.cpp
===
--- src/mathed/InsetMathHull.cpp	(revision 18839)
+++ src/mathed/InsetMathHull.cpp	(working copy)
@@ -114,7 +114,15 @@
 		return numbered ? "" : "*";
 	}
 
+	docstring const latex_string(InsetMathHull const & inset)
+	{
+		odocstringstream ls;
+		WriteStream wi(ls, false, false);
+		inset.write(wi);
+		return ls.str();
+	}
 
+
 } // end anon namespace
 
 
@@ -276,6 +284,11 @@
 bool InsetMathHull::previewState(BufferView * bv) const
 {
 	if (!editing(bv) && RenderPreview::status() == LyXRC::PREVIEW_ON) {
+		// BUG 1486: preview_ of copied formula is empty
+		if (preview_->empty()) {
+			docstring const snippet = latex_string(*this);
+			preview_->addPreview(snippet, *bv->buffer());
+		}
 		graphics::PreviewImage const * pimage =
 			preview_->getPreviewImage(*bv->buffer());
 		return pimage && pimage->image();
@@ -395,19 +408,7 @@
 }
 
 
-namespace {
 
-docstring const latex_string(InsetMathHull const & inset)
-{
-	odocstringstream ls;
-	WriteStream wi(ls, false, false);
-	inset.write(wi);
-	return ls.str();
-}
-
-} // namespace anon
-
-
 void InsetMathHull::addPreview(graphics::PreviewLoader & ploader) const
 {
 	if (RenderPreview::status() == LyXRC::PREVIEW_ON) {