705 :
706 wxDialog(pParent, wxID_ANY, title,wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
707{
708 wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
709 wxSizer *sizerRow = new wxBoxSizer(wxHORIZONTAL);
710
711 wxSize winSize = wxDefaultSize;
712
713 winSize.SetWidth(100);
714 wxStaticText *labelSttus = new wxStaticText(this, wxID_ANY, _T("Validation Status:"), wxDefaultPosition, winSize, wxALIGN_RIGHT);
715
716 winSize.SetWidth(500);
717 wxStaticText *textStatus = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, winSize,
718 wxSTATIC_BORDER | wxTE_LEFT | wxST_ELLIPSIZE_END);
719
720 sizerRow->Add(labelSttus, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5);
721 sizerRow->Add(textStatus, 1, wxALL | wxALIGN_CENTRE_VERTICAL, 5);
722
723 sizer->Add(sizerRow, wxSizerFlags().Expand());
724
725 winSize = wxSize(500, 400);
726 wxTextCtrl *textReport = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, winSize,
727 wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_BESTWRAP);
728
729 sizer->Add(textReport, wxSizerFlags(1).Expand());
730
732 wxString theReport, theValidateStatus;
733
734 std::string ver_str;
735
736 if (profilePath.IsEmpty()) {
737 theReport = "Invalid Profile Path!\n";
739 }
740 else {
741 std::string sReport;
742 wxBeginBusyCursor();
743 char * pPath = strdup( profilePath.mb_str() );
745 if (pIcc) {
746 int m, n;
747 TagEntryList::iterator i, j;
749 char str[256];
750
752 ver_str = " for version ";
754
755
756
757 for (n = 0, i = pIcc->m_Tags->begin(); i != pIcc->m_Tags->end(); i++, n++)
758 for (m = 0, j = pIcc->m_Tags->begin(); j != pIcc->m_Tags->end(); j++, m++)
759 if ((i != j) && (i->TagInfo.sig == j->TagInfo.sig)) {
760 sprintf(str,
"%28s is duplicated at positions %d and %d!\n", Fmt.
GetTagSigName(i->TagInfo.sig), n, m);
761 sReport += str;
763 }
764
765
766
767
768
769
770
771
772
773
774
775
776
777 int closest, pad, rndup, smallest_offset = pHdr->
size;
778
779
780
781
784 sReport += "File size is not a multiple of 4 bytes (last tag needs padding?).\n";
786 }
787
788 for (i = pIcc->m_Tags->begin(); i != pIcc->m_Tags->end(); i++) {
789 rndup = 4 * ((i->TagInfo.size + 3) / 4);
790 pad = rndup - i->TagInfo.size;
791
792
793 if (i->TagInfo.offset + i->TagInfo.size > pHdr->
size) {
795 sprintf(str, "Tag %s (offset %d, size %d) ends beyond EOF.\n",
796 Fmt.
GetTagSigName(i->TagInfo.sig), i->TagInfo.offset, i->TagInfo.size);
797 sReport += str;
799 }
800
801
802 if ((int)i->TagInfo.offset < smallest_offset) {
803 smallest_offset = (int)i->TagInfo.offset;
804 }
805
806
807 closest = pHdr->
size;
808 for (j = pIcc->m_Tags->begin(); j != pIcc->m_Tags->end(); j++) {
809 if ((i != j) && (j->TagInfo.offset > i->TagInfo.offset) && ((int)j->TagInfo.offset <= closest)) {
810 closest = j->TagInfo.offset;
811 }
812 }
813
814
815 if ((closest < (
int)i->TagInfo.offset + (int)i->TagInfo.size) && (closest < (int)pHdr->
size)) {
817 sprintf(str, "Tag %s (offset %d, size %d) overlaps with following tag data starting at offset %d.\n",
818 Fmt.
GetTagSigName(i->TagInfo.sig), i->TagInfo.offset, i->TagInfo.size, closest);
819 sReport += str;
821 }
822
823
824 if (closest > (int)i->TagInfo.offset + rndup) {
826 sprintf(str, "Tag %s (size %d) is followed by %d unnecessary additional bytes (from offset %d).\n",
827 Fmt.
GetTagSigName(i->TagInfo.sig), i->TagInfo.size, closest - (i->TagInfo.offset + rndup), (i->TagInfo.offset + rndup));
828 sReport += str;
830 }
831 }
832
833
834
835 if ((n > 0) && (smallest_offset > 128 + 4 + (n * 12))) {
837 sprintf(str, "First tag data is at offset %d rather than immediately after tag table (offset %d).\n",
838 smallest_offset, 128 + 4 + (n * 12));
839 sReport += str;
841 }
842 delete pIcc;
843 }
844 wxEndBusyCursor();
845
846 if (sReport.empty())
847 sReport = "There is nothing to report.\n";
848
849 theReport = sReport.c_str();
850 }
851
852 wxColour status_color = *wxBLACK;
853 switch(nStat) {
855 status_color = wxColour("DARK GREEN");
856 ver_str = "Valid Profile" + ver_str;
857 break;
858
860 status_color = wxColour("ORANGE RED");
861 ver_str = "Validation Warning(s)" + ver_str;
862 break;
863
865 status_color = *wxRED;
866 ver_str = "Profile violates ICC Specification" + ver_str;
867 break;
868
870 status_color = *wxRED;
871 ver_str = "Critical Error - Profile Violates ICC Specification" + ver_str;
872 break;
873
874 default:
875 status_color = *wxRED;
876 ver_str = "Unknown Validation Status";
877 break;
878 }
879 theValidateStatus = ver_str.c_str();
880
881 textStatus->SetForegroundColour(status_color);
882 textStatus->SetLabel(theValidateStatus);
883 *textReport << theReport;
884
885 SetSizer(sizer);
886 sizer->Fit(this);
887}
@ icValidateCriticalError
CIccProfile * ValidateIccProfile(CIccIO *pIO, std::string &sReport, icValidateStatus &nStatus)
Name: ValidateIccProfile.
icValidateStatus icMaxStatus(icValidateStatus s1, icValidateStatus s2)
Name: icMaxStatus.
const char * icMsgValidateWarning
const char * icMsgValidateNonCompliant
const icChar * GetVersionName(icUInt32Number val)
const icChar * GetTagSigName(icTagSignature sig)