예제 #1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Run the export
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public void Run()
 {
     // Check whether we're about to overwrite an existing file.
     if (File.Exists(m_fileName))
     {
         string sFmt     = DlgResources.ResourceString("kstidAlreadyExists");
         string sMsg     = String.Format(sFmt, m_fileName);
         string sCaption = DlgResources.ResourceString("kstidExportXHTML");
         if (MessageBox.Show(sMsg, sCaption, MessageBoxButtons.YesNo,
                             MessageBoxIcon.Warning) == DialogResult.No)
         {
             return;
         }
     }
     try
     {
         try
         {
             m_writer = new StreamWriter(m_fileName, false, Encoding.UTF8);
             m_strm   = new TextWriterStream(m_writer);
             m_xhtml  = new XhtmlHelper(m_writer, m_cache);
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message, Application.ProductName,
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         ExportTE();
     }
     catch (Exception e)
     {
         Exception inner = e.InnerException != null ? e.InnerException : e;
         if (inner is IOException)
         {
             MessageBox.Show(inner.Message, Application.ProductName,
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         else
         {
             throw inner;
         }
     }
     finally
     {
         if (m_writer != null)
         {
             try
             {
                 m_writer.Close();
             }
             catch
             {
                 // ignore errors on close
             }
         }
         m_writer = null;
     }
 }
예제 #2
0
        public void MapCssToLang_UsesGetValidCssClassName()
        {
            var helper = new XhtmlHelper();

            helper.MapCssToLang("#MyClass", "dummy");
            List <string> output;

            Assert.That(helper.TryGetLangsFromCss("#MyClass", out output), Is.True, "unmodified class name should retrieve successfully");
            Assert.That(helper.TryGetLangsFromCss("NUMBER_SIGNMyClass", out output), Is.True, "corrected class name should also work");
        }
예제 #3
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initialize the object with some useful information, and write the initial
 /// element start tag to the output.
 /// </summary>
 /// <param name="cache">The cache.</param>
 /// <param name="w">The w.</param>
 /// <param name="sDataType">Type of the s data.</param>
 /// <param name="sFormat">The s format.</param>
 /// <param name="sOutPath">The s out path.</param>
 /// ------------------------------------------------------------------------------------
 public void Initialize(FdoCache cache, TextWriter w, string sDataType, string sFormat,
                        string sOutPath)
 {
     m_writer      = w;
     m_strm        = new TextWriterStream(w);
     m_cache       = cache;
     m_sFormat     = sFormat.ToLowerInvariant();
     m_fUseRFC4646 = m_sFormat == "xhtml" || m_sFormat == "lift";
     m_xhtml       = new XhtmlHelper(w, cache);
     if (m_sFormat == "xhtml")
     {
         m_xhtml.WriteXhtmlHeading(sOutPath, null, "dicBody");
     }
     else
     {
         w.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
         w.WriteLine("<{0}>", sDataType);
     }
 }