Ejemplo n.º 1
0
 private void removeEmptyDescriptions(AlternateContentProperty altProp)
 {
     foreach (AlternateContent altContent in altProp.AlternateContents.ContentsAs_ListCopy)
     {
         if (altContent.IsEmpty ||
             altContent.Text == null
             &&
             altContent.Image == null
             &&
             altContent.Audio == null
             &&
             !Daisy3_Export.AltContentHasSignificantMetadata(altContent)
             )
         {
             m_ViewModel.RemoveDescription(altContent);
         }
     }
 }
        private bool getValidationText_BasicImage(ref string message)
        {
            bool first = true;

            AlternateContent altContent = GetAltContent(DiagramContentModelHelper.D_SimplifiedImage);

            if (altContent != null)
            {
                if (altContent.Image != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- It is recommended to specify a tour for the simplified image.";
                    }
                }

                bool otherDataInAdvancedMode = altContent.Audio != null ||
                                               Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                if (altContent.Image == null &&
                    (
                        altContent.Text != null ||
                        otherDataInAdvancedMode
                    )
                    )
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The simplified image is missing.";
                        if (otherDataInAdvancedMode)
                        {
                            message += " (has other data, see advanced editor)";
                        }
                    }
                }
                //if (altContent.Image == null && altContent.Text != null)
                //{
                //    if (!first)
                //    {
                //        if (message != null)
                //        {
                //            message += "\n";
                //        }
                //    }
                //    first = false;
                //    if (message != null)
                //    {
                //        message += "- A tour is specified without its associated simplified image.";
                //    }
                //}
                if (altContent.Audio != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The simplified image has audio but no corresponding tour.";
                    }
                }
            }
            altContent = GetAltContent(DiagramContentModelHelper.D_Tactile);
            if (altContent != null)
            {
                if (altContent.Image != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- It is recommended to specify a tour for the tactile image.";
                    }
                }
                bool otherDataInAdvancedMode = altContent.Audio != null ||
                                               Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                if (altContent.Image == null &&
                    (
                        altContent.Text != null ||
                        otherDataInAdvancedMode
                    )
                    )
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The tactile image is missing.";
                        if (otherDataInAdvancedMode)
                        {
                            message += " (has other data, see advanced editor)";
                        }
                    }
                }
                //if (altContent.Image == null && altContent.Text != null)
                //{
                //    if (!first)
                //    {
                //        if (message != null)
                //        {
                //            message += "\n";
                //        }
                //    }
                //    first = false;
                //    if (message != null)
                //    {
                //        message += "- A tour is specified without its associated tactile image.";
                //    }
                //}
                if (altContent.Audio != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The tactile image has audio but no corresponding tour.";
                    }
                }
            }

            bool hasMessages = !first;

            return(hasMessages);
        }
        private bool getValidationText_BasicText(ref string message)
        {
            bool first = true;

            AlternateContent altContent = GetAltContent(DiagramContentModelHelper.D_LondDesc);

            if (altContent == null
                ||
                altContent.Text == null
                ||
                string.IsNullOrEmpty(altContent.Text.Text)
                )
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- A long description must be specified.";
                }
            }
            else
            {
                //bool otherDataInAdvancedMode = altContent.Audio != null
                //                               || Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                //if (altContent.Text == null
                //    && otherDataInAdvancedMode
                //    )
                //{
                //    if (!first)
                //    {
                //        if (message != null)
                //        {
                //            message += "\n";
                //        }
                //    }
                //    first = false;
                //    if (message != null)
                //    {
                //        message += "- The long description has no text.";
                //        if (otherDataInAdvancedMode)
                //        {
                //            message += " (has other data, see advanced editor)";
                //        }
                //    }
                //}

                //if (altContent.Audio != null && altContent.Text == null)
                //{
                //    if (!first)
                //    {
                //        if (message != null)
                //        {
                //            message += "\n";
                //        }
                //    }
                //    first = false;
                //    if (message != null)
                //    {
                //        message += "- The long description has audio but no corresponding text.";
                //    }
                //}
            }

            altContent = GetAltContent(DiagramContentModelHelper.D_Summary);
            if (altContent != null)
            {
                bool otherDataInAdvancedMode = altContent.Audio != null ||
                                               Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                if (altContent.Text == null &&
                    otherDataInAdvancedMode
                    )
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The summary has no text.";
                        if (otherDataInAdvancedMode)
                        {
                            message += " (has other data, see advanced editor)";
                        }
                    }
                }

                //if (altContent.Audio != null && altContent.Text == null)
                //{
                //    if (!first)
                //    {
                //        if (message != null)
                //        {
                //            message += "\n";
                //        }
                //    }
                //    first = false;
                //    if (message != null)
                //    {
                //        message += "- The summary has audio but no corresponding text.";
                //    }
                //}
            }

            altContent = GetAltContent(DiagramContentModelHelper.D_SimplifiedLanguageDescription);
            if (altContent != null)
            {
                bool otherDataInAdvancedMode = altContent.Audio != null ||
                                               Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                if (altContent.Text == null &&
                    otherDataInAdvancedMode
                    )
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The simplified language has no text.";
                        if (otherDataInAdvancedMode)
                        {
                            message += " (has other data, see advanced editor)";
                        }
                    }
                }

                //if (altContent.Audio != null && altContent.Text == null)
                //{
                //    if (!first)
                //    {
                //        if (message != null)
                //        {
                //            message += "\n";
                //        }
                //    }
                //    first = false;
                //    if (message != null)
                //    {
                //        message += "- The simplified language has audio but no corresponding text.";
                //    }
                //}
            }

            bool hasMessages = !first;

            return(hasMessages);
        }
Ejemplo n.º 4
0
        private bool getValidationText_Descriptions(ref string message)
        {
            bool first = true;

            int count = 0;

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_LondDesc))
            {
                count++;
            }
            if (count == 0)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- No long description is specified.";
                }
            }
            else if (count > 1)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- There are more than one long description (";
                    message += count;
                    message += ")";
                }
            }

            //foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_LondDesc))
            //{
            //    if (altContent.Audio != null && altContent.Text == null)
            //    {
            //        if (!first)
            //        {
            //            if (message != null)
            //            {
            //                message += "\n";
            //            }
            //        }
            //        first = false;
            //        if (message != null)
            //        {
            //            message += "- The long description has audio but no corresponding text.";
            //        }

            //        break;
            //    }
            //}

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_LondDesc))
            {
                if (altContent.Text == null || string.IsNullOrEmpty(altContent.Text.Text))
                {
                    bool otherDataInAdvancedMode = altContent.Audio != null ||
                                                   Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The long description text is missing.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "] ";
                        }
                        if (otherDataInAdvancedMode)
                        {
                            message += " (has other data)";
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_LondDesc))
            {
                if (altContent.Image != null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The long description shouldn't have an image.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }
            count = 0;
            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Summary))
            {
                count++;
            }
            if (count == 0)
            {
                //if (!first)
                //{
                //    if (message != null)
                //    {
                //        message += "\n";
                //    }
                //}
                //first = false;
                //if (message != null)
                //{
                //    message += "- Specifying a summary is recommended.";
                //}
            }
            else if (count > 1)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- There are more than one summary (";
                    message += count;
                    message += ")";
                }
            }

            //foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Summary))
            //{
            //    if (altContent.Audio != null && altContent.Text == null)
            //    {
            //        if (!first)
            //        {
            //            if (message != null)
            //            {
            //                message += "\n";
            //            }
            //        }
            //        first = false;
            //        if (message != null)
            //        {
            //            message += "- The summary has audio but no corresponding text.";
            //        }

            //        break;
            //    }
            //}

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Summary))
            {
                if (altContent.Text == null || string.IsNullOrEmpty(altContent.Text.Text))
                {
                    bool otherDataInAdvancedMode = altContent.Audio != null ||
                                                   Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The summary text is missing.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "] ";
                        }
                        if (otherDataInAdvancedMode)
                        {
                            message += " (has other data)";
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Summary))
            {
                if (altContent.Image != null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The summary shouldn't have an image.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            count = 0;
            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedLanguageDescription))
            {
                count++;
            }
            if (count > 1)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- There are more than one simplified language (";
                    message += count;
                    message += ")";
                }
            }

            //foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedLanguageDescription))
            //{
            //    if (altContent.Audio != null && altContent.Text == null)
            //    {
            //        if (!first)
            //        {
            //            if (message != null)
            //            {
            //                message += "\n";
            //            }
            //        }
            //        first = false;
            //        if (message != null)
            //        {
            //            message += "- The simplified language has audio but no corresponding text.";
            //        }

            //        break;
            //    }
            //}

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedLanguageDescription))
            {
                if (altContent.Text == null || string.IsNullOrEmpty(altContent.Text.Text))
                {
                    bool otherDataInAdvancedMode = altContent.Audio != null ||
                                                   Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The simplified language text is missing.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "] ";
                        }
                        if (otherDataInAdvancedMode)
                        {
                            message += " (has other data)";
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedLanguageDescription))
            {
                if (altContent.Image != null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The simplified language shouldn't have an image.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            count = 0;
            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedImage))
            {
                count++;
            }
            if (count > 1)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- There are more than one simplified image (";
                    message += count;
                    message += "), which will be grouped if they have the same identifier and share the same tour.";
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedImage))
            {
                if (altContent.Audio != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The simplified image has audio but no corresponding tour.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedImage))
            {
                if (altContent.Image == null)
                {
                    bool otherDataInAdvancedMode = altContent.Audio != null ||
                                                   altContent.Text != null ||
                                                   Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- Image is missing for simplified image.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "] ";
                        }
                        if (otherDataInAdvancedMode)
                        {
                            message += " (has other data)";
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedImage))
            {
                if (altContent.Image != null &&
                    (altContent.Text == null || string.IsNullOrEmpty(altContent.Text.Text)))
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- Tour text is recommended for simplified image.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            count = 0;
            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Tactile))
            {
                count++;
            }
            if (count > 1)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- There are more than one tactile image (";
                    message += count;
                    message += "), which will be grouped if they have the same identifier and share the same tour.";
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Tactile))
            {
                if (altContent.Audio != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- The tactile image has audio but no corresponding tour.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Tactile))
            {
                bool otherDataInAdvancedMode = altContent.Audio != null ||
                                               altContent.Text != null ||
                                               Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                if (altContent.Image == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- Image is missing for tactile image.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "] ";
                        }
                        if (otherDataInAdvancedMode)
                        {
                            message += " (has other data)";
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Tactile))
            {
                if (altContent.Image != null &&
                    (altContent.Text == null || string.IsNullOrEmpty(altContent.Text.Text)))
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += "- Tour text is recommended for tactile image.";

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            string strUnknownDIAGRAMs = "";

            foreach (var id in GetUnknownDIAGRAMnames())
            {
                strUnknownDIAGRAMs += "[";
                strUnknownDIAGRAMs += id;
                strUnknownDIAGRAMs += "]";
            }

            if (!string.IsNullOrEmpty(strUnknownDIAGRAMs))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- Unknown DIAGRAM elements: ";
                    message += strUnknownDIAGRAMs;
                }
            }

            string strInvalidDIAGRAMs = "";

            foreach (var id in GetInvalidDIAGRAMnames())
            {
                strInvalidDIAGRAMs += "[";
                strInvalidDIAGRAMs += id;
                strInvalidDIAGRAMs += "]";
            }

            if (!string.IsNullOrEmpty(strInvalidDIAGRAMs))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- Invalid syntax for DIAGRAM elements: ";
                    message += strInvalidDIAGRAMs;
                }
            }

            string strInvalidIDS = "";

            foreach (var id in GetInvalidIDs(false, true))
            {
                strInvalidIDS += "[";
                strInvalidIDS += id;
                strInvalidIDS += "]";
            }

            if (!string.IsNullOrEmpty(strInvalidIDS))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- Some identifiers are invalid: ";
                    message += strInvalidIDS;
                }
            }

            string strDupIDS = "";

            foreach (var id in GetDuplicatedIDs(false, true))
            {
                strDupIDS += "[";
                strDupIDS += id;
                strDupIDS += "]";
            }

            if (!string.IsNullOrEmpty(strDupIDS))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- Some identifiers are duplicated (this may be valid if used for grouping image objects): ";
                    message += strDupIDS;
                }
            }

            string strMissingIDS = "";

            foreach (var id in GetReferencedMissingIDs(false, true))
            {
                strMissingIDS += "[";
                strMissingIDS += id;
                strMissingIDS += "]";
            }

            if (!string.IsNullOrEmpty(strMissingIDS))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- Some identifiers are referenced, but are missing: ";
                    message += strMissingIDS;
                }
            }

            string strInvalidLangs = "";

            foreach (var id in GetInvalidLanguageTags(false, true))
            {
                strInvalidLangs += "[";
                strInvalidLangs += id;
                strInvalidLangs += "]";
            }

            if (!string.IsNullOrEmpty(strInvalidLangs))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += "- Some language tags are invalid: ";
                    message += strInvalidLangs;
                }
            }

            bool hasMessages = !first;

            return(hasMessages);
        }
        private bool getValidationText_BasicImage(ref string message)
        {
            bool first = true;

            AlternateContent altContent = GetAltContent(DiagramContentModelHelper.D_SimplifiedImage);

            if (altContent != null)
            {
                if (altContent.Image != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.SimplifiedImageTourRecommended;
                    }
                }

                bool otherDataInAdvancedMode = altContent.Audio != null ||
                                               Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                if (altContent.Image == null &&
                    (
                        altContent.Text != null ||
                        otherDataInAdvancedMode
                    )
                    )
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.SimplifiedImageMissing;
                        if (otherDataInAdvancedMode)
                        {
                            message += " ";
                            message += Tobi_Plugin_Descriptions_Lang.LongDescHasOtherDataAdvanced;
                        }
                    }
                }
                //if (altContent.Image == null && altContent.Text != null)
                //{
                //    if (!first)
                //    {
                //        if (message != null)
                //        {
                //            message += "\n";
                //        }
                //    }
                //    first = false;
                //    if (message != null)
                //    {
                //        message += "- A tour is specified without its associated simplified image.";
                //    }
                //}
                if (altContent.Audio != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.SimplifiedImageAudioNoTour;
                    }
                }
            }
            altContent = GetAltContent(DiagramContentModelHelper.D_Tactile);
            if (altContent != null)
            {
                if (altContent.Image != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.TactileImageTourRecommended;
                    }
                }
                bool otherDataInAdvancedMode = altContent.Audio != null ||
                                               Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                if (altContent.Image == null &&
                    (
                        altContent.Text != null ||
                        otherDataInAdvancedMode
                    )
                    )
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.TactileImageMissing;
                        if (otherDataInAdvancedMode)
                        {
                            message += " ";
                            message += Tobi_Plugin_Descriptions_Lang.LongDescHasOtherDataAdvanced;
                        }
                    }
                }
                //if (altContent.Image == null && altContent.Text != null)
                //{
                //    if (!first)
                //    {
                //        if (message != null)
                //        {
                //            message += "\n";
                //        }
                //    }
                //    first = false;
                //    if (message != null)
                //    {
                //        message += "- A tour is specified without its associated tactile image.";
                //    }
                //}
                if (altContent.Audio != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.TactileImageAudioNoTour;
                    }
                }
            }

            bool hasMessages = !first;

            return(hasMessages);
        }
Ejemplo n.º 6
0
        private bool getValidationText_Descriptions(ref string message)
        {
            bool first = true;

            int count = 0;

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_LondDesc))
            {
                count++;
            }
            if (count == 0)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.LongDescMissing;
                }
            }
            else if (count > 1)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.LongDescMoreThanOne;
                    message += "(";
                    message += count;
                    message += ")";
                }
            }

            //foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_LondDesc))
            //{
            //    if (altContent.Audio != null && altContent.Text == null)
            //    {
            //        if (!first)
            //        {
            //            if (message != null)
            //            {
            //                message += "\n";
            //            }
            //        }
            //        first = false;
            //        if (message != null)
            //        {
            //            message += "- The long description has audio but no corresponding text.";
            //        }

            //        break;
            //    }
            //}

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_LondDesc))
            {
                if (altContent.Text == null || string.IsNullOrEmpty(altContent.Text.Text))
                {
                    bool otherDataInAdvancedMode = altContent.Audio != null ||
                                                   Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.LongDescTextMissing;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "] ";
                        }
                        if (otherDataInAdvancedMode)
                        {
                            message += " ";
                            message += Tobi_Plugin_Descriptions_Lang.LongDescHasOtherData;
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_LondDesc))
            {
                if (altContent.Image != null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.LongDescNoImage;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }
            count = 0;
            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Summary))
            {
                count++;
            }
            if (count == 0)
            {
                //if (!first)
                //{
                //    if (message != null)
                //    {
                //        message += "\n";
                //    }
                //}
                //first = false;
                //if (message != null)
                //{
                //    message += "- Specifying a summary is recommended.";
                //}
            }
            else if (count > 1)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.SummaryMoreThanOne;
                    message += " (";
                    message += count;
                    message += ")";
                }
            }

            //foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Summary))
            //{
            //    if (altContent.Audio != null && altContent.Text == null)
            //    {
            //        if (!first)
            //        {
            //            if (message != null)
            //            {
            //                message += "\n";
            //            }
            //        }
            //        first = false;
            //        if (message != null)
            //        {
            //            message += "- The summary has audio but no corresponding text.";
            //        }

            //        break;
            //    }
            //}

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Summary))
            {
                if (altContent.Text == null || string.IsNullOrEmpty(altContent.Text.Text))
                {
                    bool otherDataInAdvancedMode = altContent.Audio != null ||
                                                   Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.SummaryTextMissing;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "] ";
                        }
                        if (otherDataInAdvancedMode)
                        {
                            message += " ";
                            message += Tobi_Plugin_Descriptions_Lang.LongDescHasOtherData;
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Summary))
            {
                if (altContent.Image != null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.SummaryNoImage;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            count = 0;
            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedLanguageDescription))
            {
                count++;
            }
            if (count > 1)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.SimplifiedLanguageMoreThanOne;
                    message += " (";
                    message += count;
                    message += ")";
                }
            }

            //foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedLanguageDescription))
            //{
            //    if (altContent.Audio != null && altContent.Text == null)
            //    {
            //        if (!first)
            //        {
            //            if (message != null)
            //            {
            //                message += "\n";
            //            }
            //        }
            //        first = false;
            //        if (message != null)
            //        {
            //            message += "- The simplified language has audio but no corresponding text.";
            //        }

            //        break;
            //    }
            //}

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedLanguageDescription))
            {
                if (altContent.Text == null || string.IsNullOrEmpty(altContent.Text.Text))
                {
                    bool otherDataInAdvancedMode = altContent.Audio != null ||
                                                   Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.SimplifiedLanguageTextMissing;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "] ";
                        }
                        if (otherDataInAdvancedMode)
                        {
                            message += " ";
                            message += Tobi_Plugin_Descriptions_Lang.LongDescHasOtherData;
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedLanguageDescription))
            {
                if (altContent.Image != null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.SimplifiedLanguageNoImage;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            count = 0;
            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedImage))
            {
                count++;
            }
            if (count > 1)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.SimplifiedImageMoreThanOne;
                    message += " (";
                    message += count;
                    message += "), ";
                    message += Tobi_Plugin_Descriptions_Lang.SimplifiedImageGroupID;
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedImage))
            {
                if (altContent.Audio != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.SimplifiedImageAudioNoTour;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedImage))
            {
                if (altContent.Image == null)
                {
                    bool otherDataInAdvancedMode = altContent.Audio != null ||
                                                   altContent.Text != null ||
                                                   Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.SimplifiedImageMissingImage;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "] ";
                        }
                        if (otherDataInAdvancedMode)
                        {
                            message += " ";
                            message += Tobi_Plugin_Descriptions_Lang.LongDescHasOtherData;
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_SimplifiedImage))
            {
                if (altContent.Image != null &&
                    (altContent.Text == null || string.IsNullOrEmpty(altContent.Text.Text)))
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.SimplifiedImageTourRecommended;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            count = 0;
            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Tactile))
            {
                count++;
            }
            if (count > 1)
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.TactileImageMoreThanOne;
                    message += " (";
                    message += count;
                    message += "), ";
                    message += Tobi_Plugin_Descriptions_Lang.SimplifiedImageGroupID;
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Tactile))
            {
                if (altContent.Audio != null && altContent.Text == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.TactileImageAudioNoTour;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Tactile))
            {
                bool otherDataInAdvancedMode = altContent.Audio != null ||
                                               altContent.Text != null ||
                                               Daisy3_Export.AltContentHasSignificantMetadata(altContent);
                if (altContent.Image == null)
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.TactileImageMissingImage;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "] ";
                        }
                        if (otherDataInAdvancedMode)
                        {
                            message += " ";
                            message += Tobi_Plugin_Descriptions_Lang.LongDescHasOtherData;
                        }
                    }
                }
            }

            foreach (var altContent in GetAltContents(DiagramContentModelHelper.D_Tactile))
            {
                if (altContent.Image != null &&
                    (altContent.Text == null || string.IsNullOrEmpty(altContent.Text.Text)))
                {
                    if (!first)
                    {
                        if (message != null)
                        {
                            message += "\n";
                        }
                    }
                    first = false;
                    if (message != null)
                    {
                        message += Tobi_Plugin_Descriptions_Lang.TactileImageTourRecommended;

                        string xmlId = GetXmlID(altContent);
                        if (!String.IsNullOrEmpty(xmlId))
                        {
                            message += " [" + xmlId + "]";
                        }
                    }
                }
            }

            string strUnknownDIAGRAMs = "";

            foreach (var id in GetUnknownDIAGRAMnames())
            {
                strUnknownDIAGRAMs += "[";
                strUnknownDIAGRAMs += id;
                strUnknownDIAGRAMs += "]";
            }

            if (!string.IsNullOrEmpty(strUnknownDIAGRAMs))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.DiagramUnknownElements;
                    message += " ";
                    message += strUnknownDIAGRAMs;
                }
            }

            string strInvalidDIAGRAMs = "";

            foreach (var id in GetInvalidDIAGRAMnames())
            {
                strInvalidDIAGRAMs += "[";
                strInvalidDIAGRAMs += id;
                strInvalidDIAGRAMs += "]";
            }

            if (!string.IsNullOrEmpty(strInvalidDIAGRAMs))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.DiagramElementsInvalidSyntax;
                    message += " ";
                    message += strInvalidDIAGRAMs;
                }
            }

            string strInvalidIDS = "";

            foreach (var id in GetInvalidIDs(false, true))
            {
                strInvalidIDS += "[";
                strInvalidIDS += id;
                strInvalidIDS += "]";
            }

            if (!string.IsNullOrEmpty(strInvalidIDS))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.InvalidIDs;
                    message += " ";
                    message += strInvalidIDS;
                }
            }

            string strDupIDS = "";

            foreach (var id in GetDuplicatedIDs(false, true))
            {
                strDupIDS += "[";
                strDupIDS += id;
                strDupIDS += "]";
            }

            if (!string.IsNullOrEmpty(strDupIDS))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.DuplicatedIDs;
                    message += " ";
                    message += strDupIDS;
                }
            }

            string strMissingIDS = "";

            foreach (var id in GetReferencedMissingIDs(false, true))
            {
                strMissingIDS += "[";
                strMissingIDS += id;
                strMissingIDS += "]";
            }

            if (!string.IsNullOrEmpty(strMissingIDS))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.MissingIDs;
                    message += " ";
                    message += strMissingIDS;
                }
            }

            string strInvalidLangs = "";

            foreach (var id in GetInvalidLanguageTags(false, true))
            {
                strInvalidLangs += "[";
                strInvalidLangs += id;
                strInvalidLangs += "]";
            }

            if (!string.IsNullOrEmpty(strInvalidLangs))
            {
                if (!first)
                {
                    if (message != null)
                    {
                        message += "\n";
                    }
                }
                first = false;
                if (message != null)
                {
                    message += Tobi_Plugin_Descriptions_Lang.InvalidLanguageTags;
                    message += " ";
                    message += strInvalidLangs;
                }
            }

            bool hasMessages = !first;

            return(hasMessages);
        }