Aspose::Words::WarningInfo::get_Source method

WarningInfo::get_Source method

Returns the source of the warning.

Aspose::Words::WarningSource Aspose::Words::WarningInfo::get_Source() const

Examples

Shows how to work with the warning source.

auto doc = System::MakeObject<Aspose::Words::Document>(System::String(get_MyDir() + u"Emphases markdown warning.docx"));

auto warnings = System::MakeObject<Aspose::Words::WarningInfoCollection>();
doc->set_WarningCallback(warnings);
doc->Save(get_ArtifactsDir() + u"DocumentBuilder.EmphasesWarningSourceMarkdown.md");

for (auto&& warningInfo : warnings)
{
    if (warningInfo->get_Source() == WarningSource::Markdown)
    {
        ASSERT_EQ(warningInfo->get_Description(), u"The (*, 0:11) cannot be properly written into Markdown.");
    }
}

Shows how to get additional information about font substitution.

auto doc = System::MakeObject<Aspose::Words::Document>(System::String(get_MyDir() + u"Rendering.docx"));

auto callback = System::MakeObject<Aspose::Words::WarningInfoCollection>();
doc->set_WarningCallback(callback);

auto fontSettings = System::MakeObject<Aspose::Words::Fonts::FontSettings>();
fontSettings->get_SubstitutionSettings()->get_DefaultFontSubstitution()->set_DefaultFontName(u"Arial");
fontSettings->SetFontsFolder(get_FontsDir(), false);
fontSettings->get_SubstitutionSettings()->get_TableSubstitution()->AddSubstitutes(u"Arial", System::MakeArray<System::String>({u"Arvo", u"Slab"}));

doc->set_FontSettings(fontSettings);
doc->Save(get_ArtifactsDir() + u"FontSettings.SubstitutionWarnings.pdf");

auto warningInfo = System::ExplicitCast<Aspose::Words::FontSubstitutionWarningInfo>(callback->idx_get(0));
ASSERT_EQ(warningInfo->get_Source(), WarningSource::Layout);
ASSERT_EQ(warningInfo->get_WarningType(), WarningType::FontSubstitution);
ASSERT_EQ(warningInfo->get_Reason(), FontSubstitutionReason::TableSubstitutionRule);
ASSERT_EQ(warningInfo->get_Description(), u"Font \'Arial\' has not been found. Using \'Arvo\' font instead. Reason: table substitution.");
ASSERT_TRUE(warningInfo->get_RequestedBold());
ASSERT_FALSE(warningInfo->get_RequestedItalic());
ASSERT_EQ(warningInfo->get_RequestedFamilyName(), u"Arial");

See Also