إدارة روابط العروض التقديمية في C++
الارتباط التشعبي هو إشارة إلى كائن أو بيانات أو مكان ما. هذه أمثلة على الارتباطات التشعبية الشائعة في عروض PowerPoint التقديمية:
- روابط إلى مواقع ويب داخل النصوص أو الأشكال أو الوسائط
- روابط إلى الشرائح
Aspose.Slides for C++ يتيح لك تنفيذ مهام عديدة تتعلق بالارتباطات التشعبية في العروض التقديمية.
إضافة ارتباطات URL
إضافة ارتباطات URL إلى النص
يُظهر لك هذا الكود C++ كيفية إضافة ارتباط موقع ويب إلى نص:
auto presentation = System::MakeObject<Presentation>();
auto shapes = presentation->get_Slides()->idx_get(0)->get_Shapes();
auto shape = shapes->AddAutoShape(ShapeType::Rectangle, 100.0f, 100.0f, 600.0f, 50.0f, false);
shape->AddTextFrame(u"Aspose: File Format APIs");
auto portionFormat = shape->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(0)->get_PortionFormat();
portionFormat->set_HyperlinkClick(MakeObject<Hyperlink>(u"https://www.aspose.com/"));
portionFormat->get_HyperlinkClick()->set_Tooltip(u"More than 70% Fortune 100 companies trust Aspose APIs");
portionFormat->set_FontHeight(32.0f);
presentation->Save(u"presentation-out.pptx", SaveFormat::Pptx);
إضافة ارتباطات URL إلى الأشكال أو الأطر
يُظهر لك هذا المثال المكتوب بلغة C++ كيفية إضافة ارتباط موقع ويب إلى شكل:
auto pres = System::MakeObject<Presentation>();
auto shapes = pres->get_Slides()->idx_get(0)->get_Shapes();
auto shape = shapes->AddAutoShape(ShapeType::Rectangle, 100.0f, 100.0f, 600.0f, 50.0f);
shape->set_HyperlinkClick(System::MakeObject<Hyperlink>(u"https://www.aspose.com/"));
shape->get_HyperlinkClick()->set_Tooltip(u"More than 70% Fortune 100 companies trust Aspose APIs");
pres->Save(u"pres-out.pptx", SaveFormat::Pptx);
إضافة ارتباطات URL إلى الوسائط
Aspose.Slides يتيح لك إضافة ارتباطات تشعبية إلى الصور والملفات الصوتية وملفات الفيديو.
يُظهر لك هذا المثال كيفية إضافة ارتباط تشعبي إلى صورة:
auto pres = System::MakeObject<Presentation>();
auto shapes = pres->get_Slides()->idx_get(0)->get_Shapes();
// يضيف صورة إلى العرض التقديمي
auto image = pres->get_Images()->AddImage(File::ReadAllBytes(u"image.png"));
// ينشئ إطار صورة على الشريحة 1 بناءً على الصورة المضافة مسبقًا
auto pictureFrame = shapes->AddPictureFrame(ShapeType::Rectangle, 10.0f, 10.0f, 100.0f, 100.0f, image);
pictureFrame->set_HyperlinkClick(MakeObject<Hyperlink>(u"https://www.aspose.com/"));
pictureFrame->get_HyperlinkClick()->set_Tooltip(u"More than 70% Fortune 100 companies trust Aspose APIs");
pres->Save(u"pres-out.pptx", SaveFormat::Pptx);
يُظهر لك هذا المثال كيفية إضافة ارتباط تشعبي إلى ملف صوتي:
auto pres = System::MakeObject<Presentation>();
auto shapes = pres->get_Slides()->idx_get(0)->get_Shapes();
auto audio = pres->get_Audios()->AddAudio(File::ReadAllBytes(u"audio.mp3"));
auto audioFrame = shapes->AddAudioFrameEmbedded(10.0f, 10.0f, 100.0f, 100.0f, audio);
audioFrame->set_HyperlinkClick(MakeObject<Hyperlink>(u"https://www.aspose.com/"));
audioFrame->get_HyperlinkClick()->set_Tooltip(u"More than 70% Fortune 100 companies trust Aspose APIs");
pres->Save(u"pres-out.pptx", SaveFormat::Pptx);
يُظهر لك هذا المثال كيفية إضافة ارتباط تشعبي إلى فيديو:
auto pres = System::MakeObject<Presentation>();
auto shapes = pres->get_Slides()->idx_get(0)->get_Shapes();
auto video = pres->get_Videos()->AddVideo(File::ReadAllBytes(u"video.avi"));
auto videoFrame = shapes->AddVideoFrame(10.0f, 10.0f, 100.0f, 100.0f, video);
videoFrame->set_HyperlinkClick(MakeObject<Hyperlink>(u"https://www.aspose.com/"));
videoFrame->get_HyperlinkClick()->set_Tooltip(u"More than 70% Fortune 100 companies trust Aspose APIs");
pres->Save(u"pres-out.pptx", SaveFormat::Pptx);
Tip
قد ترغب في الاطلاع على إدارة OLE.استخدام الارتباطات التشعبية لإنشاء جدول محتويات
نظرًا لأن الارتباطات التشعبية تسمح لك بإضافة إشارات إلى كائنات أو أماكن، يمكنك استخدامها لإنشاء جدول محتويات.
يُظهر لك هذا المثال كيفية إنشاء جدول محتويات يحتوي على روابط تشعبية:
auto presentation = System::MakeObject<Presentation>();
auto firstSlide = presentation->get_Slides()->idx_get(0);
auto secondSlide = presentation->get_Slides()->AddEmptySlide(firstSlide->get_LayoutSlide());
auto contentTable = firstSlide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 40.0f, 40.0f, 300.0f, 100.0f);
contentTable->get_FillFormat()->set_FillType(FillType::NoFill);
contentTable->get_LineFormat()->get_FillFormat()->set_FillType(FillType::NoFill);
contentTable->get_TextFrame()->get_Paragraphs()->Clear();
auto paragraph = System::MakeObject<Paragraph>();
auto paragraphFillFormat = paragraph->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat();
paragraphFillFormat->set_FillType(FillType::Solid);
paragraphFillFormat->get_SolidFillColor()->set_Color(Color::get_Black());
paragraph->set_Text(u"Title of slide 2 .......... ");
auto linkPortion = System::MakeObject<Portion>();
linkPortion->set_Text(u"Page 2");
linkPortion->get_PortionFormat()->get_HyperlinkManager()->SetInternalHyperlinkClick(secondSlide);
paragraph->get_Portions()->Add(linkPortion);
contentTable->get_TextFrame()->get_Paragraphs()->Add(paragraph);
تنسيق الارتباطات التشعبية
اللون
باستخدام طريقتي set_ColorSource() و get_ColorSource() في واجهة IHyperlink، يمكنك تعيين اللون للارتباطات التشعبية وكذلك الحصول على معلومات اللون منها. تم تقديم هذه الميزة لأول مرة في PowerPoint 2019، لذا فإن التغييرات المتعلقة بهذه الخاصية لا تنطبق على إصدارات PowerPoint الأقدم.
يُظهر لك هذا المثال طريقة إضافة ارتباطات تشعبية بألوان مختلفة إلى نفس الشريحة:
auto presentation = System::MakeObject<Presentation>();
auto shapes = presentation->get_Slides()->idx_get(0)->get_Shapes();
auto shape1 = shapes->AddAutoShape(ShapeType::Rectangle, 100.0f, 100.0f, 450.0f, 50.0f, false);
shape1->AddTextFrame(u"This is a sample of colored hyperlink.");
auto shape1PortionFormat = shape1->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(0)->get_PortionFormat();
shape1PortionFormat->set_HyperlinkClick(MakeObject<Hyperlink>(u"https://www.aspose.com/"));
shape1PortionFormat->get_HyperlinkClick()->set_ColorSource(HyperlinkColorSource::PortionFormat);
shape1PortionFormat->get_FillFormat()->set_FillType(FillType::Solid);
shape1PortionFormat->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Red());
auto shape2 = shapes->AddAutoShape(ShapeType::Rectangle, 100.0f, 200.0f, 450.0f, 50.0f, false);
shape2->AddTextFrame(u"This is a sample of usual hyperlink.");
auto shape2PortionFormat = shape2->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(0)->get_PortionFormat();
shape2PortionFormat->set_HyperlinkClick(MakeObject<Hyperlink>(u"https://www.aspose.com/"));
presentation->Save(u"presentation-out-hyperlink.pptx", SaveFormat::Pptx);
إزالة الارتباطات التشعبية من العروض التقديمية
إزالة الارتباطات التشعبية من النص
يُظهر لك هذا الكود C++ كيفية إزالة الارتباط التشعبي من نص في شريحة عرض تقديمي:
auto pres = System::MakeObject<Presentation>(u"pres.pptx");
auto slide = pres->get_Slides()->idx_get(0);
for (const auto& shape : slide->get_Shapes())
{
auto autoShape = System::AsCast<IAutoShape>(shape);
if (autoShape != nullptr)
{
for (const auto& paragraph : autoShape->get_TextFrame()->get_Paragraphs())
{
for (const auto& portion : paragraph->get_Portions())
{
auto hyperlinkManager = portion->get_PortionFormat()->get_HyperlinkManager();
hyperlinkManager->RemoveHyperlinkClick();
}
}
}
}
pres->Save(u"pres-removed-hyperlinks.pptx", SaveFormat::Pptx);
إزالة الارتباطات التشعبية من الأشكال أو الأطر
يُظهر لك هذا الكود C++ كيفية إزالة الارتباط التشعبي من شكل في شريحة عرض تقديمي:
auto pres = System::MakeObject<Presentation>(u"demo.pptx");
auto slide = pres->get_Slides()->idx_get(0);
for (const auto& shape : slide->get_Shapes())
{
shape->get_HyperlinkManager()->RemoveHyperlinkClick();
}
pres->Save(u"pres-removed-hyperlinks.pptx", SaveFormat::Pptx);
الارتباط التشعبي القابل للتغيير
فئة Hyperlink قابلة للتغيير. باستخدام هذه الفئة، يمكنك تعديل القيم للطرق التالية:
- IHyperlink::set_TargetFrame()
- IHyperlink::set_Tooltip()
- IHyperlink.set_History()
- IHyperlink.set_HighlightClick()
- IHyperlink.set_StopSoundOnClick()
يُظهر لك هذا المقتطف كيفية إضافة ارتباط تشعبي إلى شريحة وتعديل تلميحه لاحقًا:
auto presentation = System::MakeObject<Presentation>();
auto shapes = presentation->get_Slides()->idx_get(0)->get_Shapes();
auto shape = shapes->AddAutoShape(ShapeType::Rectangle, 100.0f, 100.0f, 600.0f, 50.0f, false);
shape->AddTextFrame(u"Aspose: File Format APIs");
auto shapePortionFormat = shape->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(0)->get_PortionFormat();
shapePortionFormat->set_HyperlinkClick(MakeObject<Hyperlink>(u"https://www.aspose.com/"));
shapePortionFormat->get_HyperlinkClick()->set_Tooltip(u"More than 70% Fortune 100 companies trust Aspose APIs");
shapePortionFormat->set_FontHeight(32.0f);
presentation->Save(u"presentation-out.pptx", SaveFormat::Pptx);
الطرق المدعومة في IHyperlinkQueries
يمكنك الوصول إلى IHyperlinkQueries من عرض تقديمي أو شريحة أو نص معرف فيه الارتباط التشعبي.
- IPresentation::get_HyperlinkQueries()
- IBaseSlide::get_HyperlinkQueries()
- ITextFrame::get_HyperlinkQueries()
تدعم فئة IHyperlinkQueries الطرق التالية:
- IHyperlinkQueries::GetHyperlinkClicks()
- IHyperlinkQueries::GetHyperlinkMouseOvers()
- IHyperlinkQueries::GetAnyHyperlinks()
- IHyperlinkQueries::RemoveAllHyperlinks()
FAQ
كيف يمكنني إنشاء تنقل داخلي ليس فقط إلى شريحة، بل إلى “قسم” أو الشريحة الأولى في القسم؟
الأقسام في PowerPoint هي مجموعات من الشرائح؛ التقنية تستهدف شريحة محددة. للتنقل إلى قسم، عادةً ما تقوم بربط إلى الشريحة الأولى فيه.
هل يمكنني إرفاق ارتباط تشعبي بعناصر الشريحة الرئيسة بحيث يعمل على جميع الشرائح؟
نعم. تدعم عناصر الشريحة الرئيسة وتنسيقها الارتباطات التشعبية. تظهر هذه الروابط على الشرائح الفرعية وتكون قابلة للنقر أثناء العرض.
هل سيتم حفظ الارتباطات التشعبية عند التصدير إلى PDF أو HTML أو الصور أو الفيديو؟
في PDF و HTML، نعم—تُحافظ الروابط عادةً. عند التصدير إلى الصور و الفيديو، لن يتم نقل قابلية النقر بسبب طبيعة هذه الصيغ (الإطارات النقطية/الفيديو لا تدعم الارتباطات التشعبية).