utelle / wxpdfdoc

wxPdfDocument - Generation of PDF documents from wxWidgets applications
http://utelle.github.io/wxpdfdoc/
Other
70 stars 27 forks source link

Compilation against wx 3.0.5 #93

Closed archdvx closed 5 months ago

archdvx commented 5 months ago

I got error:

src/pdfencrypt.cpp:661:35: error: ‘const class wxString’ has no member named ‘utf8_string’; did you mean ‘utf8_str’?
  661 |   ComputeUandUEforV5(userPassword.utf8_string(), m_fileEncryptionKey);
      |                                   ^~~~~~~~~~~
      |                                   utf8_str

wx 3.0.5 is for example on Ubuntu Jammy

For fix I use:

#if ((wxVERSION_NUMBER > 3104))
  ComputeUandUEforV5(userPassword.utf8_string(), m_fileEncryptionKey);
  ComputeOandOEforV5(ownerPassword.utf8_string(), m_fileEncryptionKey);
#else
  ComputeUandUEforV5(userPassword.ToStdString(), m_fileEncryptionKey);
  ComputeOandOEforV5(ownerPassword.ToStdString(), m_fileEncryptionKey);
#endif

Also I got:

src/pdfencrypt.cpp:462:8: error: ‘vector’ is not a member of ‘std’
  462 |   std::vector<unsigned char> K1andE(64 * (127 + 64 + 48), 0);
      |        ^~~~~~
src/pdfencrypt.cpp:37:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
utelle commented 5 months ago

I got error:

src/pdfencrypt.cpp:661:35: error: ‘const class wxString’ has no member named ‘utf8_string’; did you mean ‘utf8_str’?
  661 |   ComputeUandUEforV5(userPassword.utf8_string(), m_fileEncryptionKey);
      |                                   ^~~~~~~~~~~
      |                                   utf8_str

wx 3.0.5 is for example on Ubuntu Jammy

In the release comments for wxPdfDocument 1.2.0 I stated that only wxWidgets version 3.2.x is supported. However, since wx 3.0.5 is still in use on some common Linux platforms I adjusted the code to support wx 3.0.x in commit 276d6ed6b538c728af0e4a4d4eebb76b2a7e44d7.

For fix I use:

#if ((wxVERSION_NUMBER > 3104))
  ComputeUandUEforV5(userPassword.utf8_string(), m_fileEncryptionKey);
  ComputeOandOEforV5(ownerPassword.utf8_string(), m_fileEncryptionKey);
#else
  ComputeUandUEforV5(userPassword.ToStdString(), m_fileEncryptionKey);
  ComputeOandOEforV5(ownerPassword.ToStdString(), m_fileEncryptionKey);
#endif

Unfortunately, ToStdString() can't be used here, because it uses the standard C library character set conversion - which will not work for UTF-8 in general.

Also I got:

src/pdfencrypt.cpp:462:8: error: ‘vector’ is not a member of ‘std’
  462 |   std::vector<unsigned char> K1andE(64 * (127 + 64 + 48), 0);
      |        ^~~~~~
src/pdfencrypt.cpp:37:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?

Well, I guess in wx 3.2.x the header <vector> is implicitly included, while in wx 3.0.5 it is not. So, I added an explicit include.

archdvx commented 5 months ago

Fix works perfect, thanks