Skip to content

Commit 902ec1c

Browse files
authored
Merge branch 'master' into importTextAsCurves
2 parents 23e7916 + f84fd2d commit 902ec1c

File tree

10 files changed

+16
-126
lines changed

10 files changed

+16
-126
lines changed

AddinUtilities.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,14 @@ public static bool executePs2Pdf(LatexEquation equation)
373373
return true;
374374
}
375375

376-
public static bool createLatexPng(LatexEquation equation, bool usePreview, bool firstRun)
376+
public static bool createLatexPng(LatexEquation equation, bool firstRun)
377377
{
378378
// Check paths
379379
SettingsManager mgr = SettingsManager.getCurrent();
380380

381381
string appPath = AddinUtilities.getAppDataLocation();
382382
Directory.SetCurrentDirectory(appPath);
383-
LatexFileGenerator.writeTexFile(appPath + "\\teximport.tex", equation, usePreview);
383+
LatexFileGenerator.writeTexFile(appPath + "\\teximport.tex", equation);
384384
if (!executeMikTex())
385385
return false;
386386
if (!executeDviPng(equation, firstRun))
@@ -396,7 +396,7 @@ public static bool createLatexPdf(LatexEquation equation)
396396

397397
string appPath = AddinUtilities.getAppDataLocation();
398398
Directory.SetCurrentDirectory(appPath);
399-
LatexFileGenerator.writeTexFile(appPath + "\\teximport.tex", equation, false);
399+
LatexFileGenerator.writeTexFile(appPath + "\\teximport.tex", equation);
400400
if (!executeMikTex())
401401
return false;
402402
if (!executeDviPs(equation))

DockerUI.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public DockerUI(corel.Application app)
3838

3939
AddinUtilities.initFonts();
4040
AddinUtilities.copyLatexTemplate("LatexTemplate.txt", Properties.Resources.LatexTemplate);
41-
AddinUtilities.copyLatexTemplate("LatexInlineTemplate.txt", Properties.Resources.LatexInlineTemplate);
4241

4342
m_dialog = new LatexDialog();
4443
SettingsManager mgr = SettingsManager.getCurrent();

Latex4CorelDraw.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
<EmbeddedResource Include="Properties\Resources.resx">
118118
<Generator>ResXFileCodeGenerator</Generator>
119119
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
120+
<SubType>Designer</SubType>
120121
</EmbeddedResource>
121122
<None Include="Properties\Settings.settings">
122123
<Generator>SettingsSingleFileGenerator</Generator>
@@ -129,7 +130,6 @@
129130
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
130131
</Content>
131132
<None Include="Resources\Language.xml" />
132-
<None Include="Resources\LatexInlineTemplate.txt" />
133133
<None Include="Resources\LatexTemplate.txt" />
134134
<Content Include="UserUI.xslt">
135135
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

LatexDialog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ private bool generateEquation(bool createShape)
231231
// Run once with preview to get depth value
232232
m_finishedSuccessfully = true;
233233
if (!createShape)
234-
m_finishedSuccessfully = AddinUtilities.createLatexPng(m_latexEquation, true, true);
234+
m_finishedSuccessfully = AddinUtilities.createLatexPng(m_latexEquation, true);
235235

236236
if (m_finishedSuccessfully)
237237
{
238238
// Run once without to get correct tight image
239239
if (!createShape)
240-
m_finishedSuccessfully = AddinUtilities.createLatexPng(m_latexEquation, false, false);
240+
m_finishedSuccessfully = AddinUtilities.createLatexPng(m_latexEquation, false);
241241
else
242242
{
243243
m_finishedSuccessfully = AddinUtilities.createLatexPdf(m_latexEquation);

LatexFileGenerator.cs

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,11 @@ public LatexEquation(string latexCode, float fontSize, string textColor, LatexFo
4848
}
4949

5050
public class LatexFileGenerator
51-
{
52-
public static void writeTexFile(string fileName, LatexEquation equation, bool usePreview)
51+
{
52+
public static void writeTexFile(string fileName, LatexEquation equation)
5353
{
5454
string templateText = "";
55-
string templateFileName;
56-
if (usePreview)
57-
templateFileName = AddinUtilities.getAppDataLocation() + "\\LatexInlineTemplate.txt";
58-
else
59-
templateFileName = AddinUtilities.getAppDataLocation() + "\\LatexTemplate.txt";
55+
string templateFileName = AddinUtilities.getAppDataLocation() + "\\LatexTemplate.txt";
6056

6157
// Use resource template, if no file exists
6258
if (!File.Exists(templateFileName))
@@ -83,76 +79,15 @@ public static void writeTexFile(string fileName, LatexEquation equation, bool us
8379
}
8480

8581
string content = "";
86-
if (usePreview)
87-
content += "\\begin{preview}\n";
8882
content += "\\definecolor{txtcolor}{rgb}{" + equation.m_color + "}\n"; ;
8983
content += "\\color{txtcolor}\n";
9084
content += "\\changefont{" + equation.m_font.latexFontName + "}{" +
9185
equation.m_fontSeries.latexFontSeries + "}{" +
9286
equation.m_fontShape.latexFontShape + "}{" +
9387
equation.m_fontSize.ToString() + "}{" +
94-
((equation.m_fontSize*1.2)).ToString(System.Globalization.CultureInfo.InvariantCulture) + "}\n";
88+
((equation.m_fontSize * 1.2)).ToString(System.Globalization.CultureInfo.InvariantCulture) + "}\n";
9589
content += equation.m_code;
96-
if (usePreview)
97-
content += "\n\\end{preview}\n";
98-
99-
templateText = templateText.Replace("${Content}", content);
10090

101-
// Write Latex file
102-
try
103-
{
104-
StreamWriter sw = File.CreateText(fileName);
105-
sw.Write(templateText);
106-
sw.Close();
107-
}
108-
catch (Exception ex)
109-
{
110-
MessageBox.Show("Exception: \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
111-
}
112-
}
113-
114-
115-
public static void writeTexFile(string fileName, List<LatexEquation> equations)
116-
{
117-
string templateText = "";
118-
string templateFileName = AddinUtilities.getAppDataLocation() + "\\LatexInlineTemplate.txt";
119-
120-
// Use resource template, if no file exists
121-
if (!File.Exists(templateFileName))
122-
{
123-
templateText = Properties.Resources.LatexInlineTemplate;
124-
}
125-
else // Otherwise use the file
126-
{
127-
// Read template
128-
try
129-
{
130-
SettingsManager mgr = SettingsManager.getCurrent();
131-
132-
StreamReader sr;
133-
sr = File.OpenText(templateFileName);
134-
templateText = sr.ReadToEnd();
135-
sr.Close();
136-
}
137-
catch (Exception ex)
138-
{
139-
MessageBox.Show("Exception: \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
140-
}
141-
}
142-
143-
// Fill all equations in file
144-
string content = "";
145-
foreach (LatexEquation equation in equations)
146-
{
147-
content += "\\begin{preview}\n";
148-
content += "\\definecolor{txtcolor}{rgb}{" + equation.m_color + "}\n"; ;
149-
content += "\\color{txtcolor}\n";
150-
content += "\\changefont{" + equation.m_font.latexFontName + "}{" +
151-
equation.m_fontSeries.latexFontSeries + "}{" +
152-
equation.m_fontShape.latexFontShape + "}\n";
153-
content += equation.m_code;
154-
content += "\n\\end{preview}\n";
155-
}
15691
templateText = templateText.Replace("${Content}", content);
15792

15893
// Write Latex file

Properties/Resources.Designer.cs

Lines changed: 1 addition & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Properties/Resources.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@
121121
<data name="Language" type="System.Resources.ResXFileRef, System.Windows.Forms">
122122
<value>..\Resources\Language.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
123123
</data>
124-
<data name="LatexInlineTemplate" type="System.Resources.ResXFileRef, System.Windows.Forms">
125-
<value>..\Resources\LatexInlineTemplate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
126-
</data>
127124
<data name="LatexTemplate" type="System.Resources.ResXFileRef, System.Windows.Forms">
128125
<value>..\Resources\LatexTemplate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
129126
</data>

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ The included project file was made with Visual Studio 2015. You have to adapt th
1616
2. Right-click and open "Properties" for each DLL file in the folder. If you see the following text, you have to unblock the file:
1717
"Security: This file came from another computer and might be blocked to help protect this computer."
1818
3. Activate docker window "Latex" in the menu "Windows".
19-
4. If you have a better solution for step 2, write me an email ;-)
19+
4. Import once an arbitrary PS file manually and select import text as curves. This seems to be the only way that CorelDraw stores this option and there is no API functionality to do it.
20+
5. If you have a better solution for step 2, write me an email ;-)
2021

2122
## Screenshots
2223

Resources/LatexInlineTemplate.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

Resources/LatexTemplate.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
\documentclass[12pt,a4paper,ngerman]{article}
1+
\documentclass[12pt,a4paper]{article}
22
\usepackage{amsmath}
3+
\usepackage{amsfonts}
4+
\usepackage{amssymb}
35
\usepackage[utf8]{inputenc}
46
\usepackage{bbm}
57
\usepackage{ae,aecompl}

0 commit comments

Comments
 (0)