@@ -270,22 +270,16 @@ private bool generateEquation(bool createShape, bool useSystemDPI)
270270
271271 m_latexEquation = new LatexEquation ( m_scintilla . Text , size , dpiValue , m_textColor , ( LatexFont ) comboBoxFont . SelectedItem ,
272272 ( LatexFontSeries ) comboBoxSeries . SelectedItem ,
273- ( LatexFontShape ) comboBoxShape . SelectedItem , false ) ;
273+ ( LatexFontShape ) comboBoxShape . SelectedItem ) ;
274274
275- // Run once with preview to get depth value
276- m_finishedSuccessfully = AddinUtilities . createLatexPng ( m_latexEquation , true , true ) ;
277275
278- if ( m_finishedSuccessfully )
276+ m_finishedSuccessfully = AddinUtilities . createLatexPng ( m_latexEquation ) ;
277+ if ( createShape )
279278 {
280- // Run once without to get correct tight image
281- AddinUtilities . createLatexPng ( m_latexEquation , false , false ) ;
282- if ( createShape )
283- {
284- AddinUtilities . createLatexShape ( "teximport.png" , m_latexEquation ) ;
285- m_latexEquation . m_shape . Select ( Microsoft . Office . Core . MsoTriState . msoTrue ) ;
286- AddinUtilities . centerLatexShape ( m_latexEquation ) ;
287- alignLatexShape ( m_latexEquation ) ;
288- }
279+ AddinUtilities . createLatexShape ( "teximport.png" , m_latexEquation ) ;
280+ m_latexEquation . m_shape . Select ( Microsoft . Office . Core . MsoTriState . msoTrue ) ;
281+ AddinUtilities . centerLatexShape ( m_latexEquation ) ;
282+ alignLatexShape ( m_latexEquation ) ;
289283 }
290284 return m_finishedSuccessfully ;
291285 }
@@ -294,31 +288,25 @@ private void alignLatexShape(LatexEquation equation)
294288 {
295289 if ( m_textRange != null )
296290 {
297- System . Drawing . FontFamily family = AddinUtilities . getFontFamily ( m_textRange ) ;
298- //float height = (float)(m_textRange.BoundHeight * ((float)family.GetCellAscent(System.Drawing.FontStyle.Regular) / (float)family.GetLineSpacing(System.Drawing.FontStyle.Regular)));
299- float lineSpacing = m_textRange . Font . Size * ( float ) family . GetLineSpacing ( System . Drawing . FontStyle . Regular ) / ( float ) family . GetEmHeight ( System . Drawing . FontStyle . Regular ) ;
300- float spaceBefore = 0.0f ;
301- if ( m_textRange . BoundHeight > lineSpacing )
302- spaceBefore = m_textRange . ParagraphFormat . SpaceBefore * lineSpacing ;
303- float height = spaceBefore + ( m_textRange . Font . Size * ( float ) family . GetCellAscent ( System . Drawing . FontStyle . Regular ) ) / ( float ) family . GetEmHeight ( System . Drawing . FontStyle . Regular ) ;
304- float offset = ( float ) equation . m_offset / ( float ) equation . m_imageHeight ;
291+ // System.Drawing.FontFamily family = AddinUtilities.getFontFamily(m_textRange);
292+ //// float height = (float)(m_textRange.BoundHeight * ((float)family.GetCellAscent(System.Drawing.FontStyle.Regular) / (float)family.GetLineSpacing(System.Drawing.FontStyle.Regular)));
293+ // float lineSpacing = m_textRange.Font.Size*(float)family.GetLineSpacing(System.Drawing.FontStyle.Regular) / (float)family.GetEmHeight(System.Drawing.FontStyle.Regular);
294+ // float spaceBefore = 0.0f;
295+ // if (m_textRange.BoundHeight > lineSpacing)
296+ // spaceBefore = m_textRange.ParagraphFormat.SpaceBefore * lineSpacing;
297+ // float height = spaceBefore + (m_textRange.Font.Size * (float)family.GetCellAscent(System.Drawing.FontStyle.Regular)) / (float)family.GetEmHeight(System.Drawing.FontStyle.Regular);
298+ // float offset = (float)equation.m_offset / (float)equation.m_imageHeight;
305299
306300 //// Test
307301 //int slideId = ThisAddIn.Current.Application.ActiveWindow.Selection.SlideRange.SlideID;
308302 //Microsoft.Office.Interop.PowerPoint.Slide slide = ThisAddIn.Current.Application.ActivePresentation.Slides.FindBySlideID(slideId);
309- //slide.Shapes.AddLine(m_textRange.BoundLeft, m_textRange.BoundTop + height + spaceBefore, m_textRange.BoundLeft + 50, m_textRange.BoundTop + height + spaceBefore);
310- //slide.Shapes.AddLine(m_textRange.BoundLeft, m_textRange.BoundTop + height + spaceBefore, m_textRange.BoundLeft + 50, m_textRange.BoundTop + height + offset * equation.m_shape.Height + spaceBefore);
311- //slide.Shapes.AddLine(m_textRange.BoundLeft - 5, m_textRange.BoundTop, m_textRange.BoundLeft - 5, m_textRange.BoundTop + lineSpacing + spaceBefore);
312- //float asc = m_textRange.Font.Size * (float)family.GetCellAscent(System.Drawing.FontStyle.Regular) / (float)family.GetEmHeight(System.Drawing.FontStyle.Regular);
313- //float ds = m_textRange.Font.Size * (float)family.GetCellDescent(System.Drawing.FontStyle.Regular) / (float)family.GetEmHeight(System.Drawing.FontStyle.Regular);
314- //slide.Shapes.AddLine(m_textRange.BoundLeft - 15, m_textRange.BoundTop, m_textRange.BoundLeft - 15, m_textRange.BoundTop + asc + spaceBefore);
315- //slide.Shapes.AddLine(m_textRange.BoundLeft - 25, m_textRange.BoundTop, m_textRange.BoundLeft - 25, m_textRange.BoundTop + asc + ds + spaceBefore);
303+ //slide.Shapes.AddLine(m_textRange.BoundLeft, m_textRange.BoundTop, m_textRange.BoundLeft + m_textRange.BoundWidth, m_textRange.BoundTop + m_textRange.BoundHeight);
316304 //// Test
317305
318306 if ( equation . m_shape != null )
319307 {
320- equation . m_shape . Left = m_textRange . BoundLeft + 2 * m_textRange . BoundWidth ;
321- equation . m_shape . Top = m_textRange . BoundTop + height - ( 1.0f - offset ) * equation . m_shape . Height ;
308+ equation . m_shape . Left = m_textRange . BoundLeft + m_textRange . BoundWidth ;
309+ equation . m_shape . Top = m_textRange . BoundTop + m_textRange . BoundHeight - equation . m_shape . Height ; // - offset * equation.m_shape.Height;
322310 }
323311 }
324312 }
0 commit comments