C# Interop.Visio | Is there a way to collect unsaved progress from the Application? - Stack Overflow

admin2025-04-09  0

I need to check that all the unsaved progress from Visio is in the UTF-8 encoding before I save the document. The reason I need this, is because the xml data is encoded in UTF-8 and I have people using the plugin in many different languages that can cause problems.

I use the event to trigger the Method:

this.Application.BeforeDocumentSave += new Visio.EApplication_BeforeDocumentSaveEventHandler(Visio_BeforeDocumentSave);

private void Visio_BeforeDocumentSave(Visio.Document doc) //Ensure UTF-8 encodeing before save
  {   
      if (!doc.Saved)
      {

      }
  }

I noticed that people suggested to iterate through all shapes and pages to check encoding, but considering the size of the document this will take unnecessarily long amount of time.

Therefore I wonder if there is a way to collect all unsaved progress from the Application, so I can at least skip data that is already saved and safe.

private void Visio_BeforeDocumentSaveAs(Visio.Document doc)
{
 // doc.Saved checks if there is unsaved progress in the visio app
 // Is there also a way to retrieve this data that doc.Saved is referring to     
}

Any suggestions is welcome, even if it changes my approach to the "problem".

I need to check that all the unsaved progress from Visio is in the UTF-8 encoding before I save the document. The reason I need this, is because the xml data is encoded in UTF-8 and I have people using the plugin in many different languages that can cause problems.

I use the event to trigger the Method:

this.Application.BeforeDocumentSave += new Visio.EApplication_BeforeDocumentSaveEventHandler(Visio_BeforeDocumentSave);

private void Visio_BeforeDocumentSave(Visio.Document doc) //Ensure UTF-8 encodeing before save
  {   
      if (!doc.Saved)
      {

      }
  }

I noticed that people suggested to iterate through all shapes and pages to check encoding, but considering the size of the document this will take unnecessarily long amount of time.

Therefore I wonder if there is a way to collect all unsaved progress from the Application, so I can at least skip data that is already saved and safe.

private void Visio_BeforeDocumentSaveAs(Visio.Document doc)
{
 // doc.Saved checks if there is unsaved progress in the visio app
 // Is there also a way to retrieve this data that doc.Saved is referring to     
}

Any suggestions is welcome, even if it changes my approach to the "problem".

Share Improve this question edited Mar 26 at 8:41 DanTheMan asked Mar 25 at 10:46 DanTheManDanTheMan 175 bronze badges 4
  • It is not clear what your problem actually is? UTF-8 encoding allows all languages that are available on this planet, including ancient languages. Maybe you mean something else? Could you explain the real problem? Without mentioning UTF8. Your post looks like a typical XY-problem (en.wikipedia./wiki/XY_problem) – Nikolay Commented Mar 25 at 16:28
  • @Nikolay, when it comes to Unicode there are still languages that aren't fully supported. My problem is conversion between UTF16 -> UTF8, which is not the problem in this post. I will update clarify. – DanTheMan Commented Mar 26 at 8:32
  • Visio file (VSDX) is a ZIP (binary) file; therefore, what you mean by Unicode encoding and UTF stuff is unclear. UTF8 and UTF16 both support the same set of characters (full Unicode range). You cannot do anything with the output file form "OnBeforeDocumentSave" event. Summarizing: what is your real issue? Please update. – Nikolay Commented Mar 26 at 11:35
  • Let me try to ask like this: do you want to prevent any "non-ASCII" (i.e. non-English) characters to present in the shape text (or some shape properties)? Note this is not related to Unicode or UTF8 or UTF16. – Nikolay Commented Mar 26 at 13:44
Add a comment  | 

1 Answer 1

Reset to default -1

It's not possible to get any extra information about what's unsaved in the Visio Application without making a custom method for it, by doing a full file comparison.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744202803a235880.html

最新回复(0)