C++ में प्रस्तुतियों में बुलेटेड और क्रमांकित सूचियों का प्रबंधन
Overview
Aspose.Slides for C++ आपको PowerPoint और OpenDocument प्रस्तुतियों में बुलेटेड और क्रमांकित सूचियों को बनाने और फॉर्मेट करने की सुविधा देता है। एक सूची आइटम वह पैराग्राफ है जिसका बुलेट सेटिंग उसके पैराग्राफ फ़ॉर्मेट के माध्यम से नियंत्रित किया जाता है।
पैराग्राफ‑स्तर की सूची सेटिंग्स तक पहुंचने के लिए IParagraph::get_ParagraphFormat मेथड का उपयोग करें। मुख्य प्रवेश बिंदु है IParagraphFormat::get_Bullet, जो एक IBulletFormat ऑब्जेक्ट लौटाता है। इस ऑब्जेक्ट के साथ आप बुलेट का प्रकार, चिन्ह, चित्र, रंग, आकार, क्रमांक शैली और प्रारंभिक संख्या सेट कर सकते हैं।
यह लेख दिखाता है कि कैसे:
- कस्टम चिन्ह के साथ बुलेटेड सूची बनाएं
- चित्र बुलेट बनाएं
- पैराग्राफ डेप्थ सेट करके मल्टीलेवल सूची बनाएं
- क्रमांकित सूची बनाएं
- मौजूदा प्रस्तुति में सूची फ़ॉर्मेटिंग को देखें और बदलें
- पैराग्राफ टेक्स्ट के साथ वास्तविक सूची मार्कर और संख्याएं पढ़ें
Create a Bulleted List
बुलेटेड सूची बनाने के लिए, Paragraph ऑब्जेक्ट को एक ITextFrame में जोड़ें और IBulletFormat::set_Type को BulletType::Symbol पर सेट करें। इसके बाद आप IBulletFormat::set_Char, IBulletFormat::get_Color और IBulletFormat::set_Height सेट करके बुलेट की दिखावट को नियंत्रित कर सकते हैं।
निम्नलिखित C++ कोड एक स्लाइड में बुलेटेड सूची बनाने का प्रदर्शन करता है:
#include <DOM/BulletType.h>
#include <DOM/IAutoShape.h>
#include <DOM/IBulletFormat.h>
#include <DOM/IColorFormat.h>
#include <DOM/IParagraphCollection.h>
#include <DOM/IParagraphFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/NullableBool.h>
#include <DOM/Paragraph.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
#include <drawing/color.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System::Drawing;
auto createParagraph = [](System::String text)
{
auto paragraph = System::MakeObject<Paragraph>();
auto paragraphFormat = paragraph->get_ParagraphFormat();
auto bulletFormat = paragraphFormat->get_Bullet();
bulletFormat->set_Type(BulletType::Symbol);
bulletFormat->set_Char(u'*');
paragraphFormat->set_Indent(15);
bulletFormat->set_IsBulletHardColor(NullableBool::True);
bulletFormat->get_Color()->set_Color(System::Drawing::Color::get_IndianRed());
bulletFormat->set_Height(100);
paragraph->set_Text(text);
return paragraph;
};
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 20, 20, 200, 50);
auto textFrame = autoShape->get_TextFrame();
textFrame->get_Paragraphs()->Clear();
auto paragraph1 = createParagraph(u"The first paragraph");
textFrame->get_Paragraphs()->Add(paragraph1);
auto paragraph2 = createParagraph(u"The second paragraph");
textFrame->get_Paragraphs()->Add(paragraph2);
presentation->Save(u"symbol_bullets.pptx", SaveFormat::Pptx);
presentation->Dispose();
परिणाम:

Create a Numbered List
जब आइटमों का क्रम महत्वपूर्ण हो, तो क्रमांकित सूचियों का उपयोग करें। IBulletFormat::set_Type को BulletType::Numbered पर सेट करें। आप IBulletFormat::set_NumberedBulletStyle के साथ क्रमांक शैली भी चुन सकते हैं या सूची को 1 से अलग किसी मान से शुरू करने के लिए IBulletFormat::set_NumberedBulletStartWith सेट कर सकते हैं।
निम्नलिखित C++ कोड एक स्लाइड में क्रमांकित सूची बनाने का प्रदर्शन करता है:
#include <DOM/BulletType.h>
#include <DOM/IAutoShape.h>
#include <DOM/IBulletFormat.h>
#include <DOM/IParagraphCollection.h>
#include <DOM/IParagraphFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/Paragraph.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 20, 20, 90, 80);
auto textFrame = autoShape->get_TextFrame();
textFrame->get_Paragraphs()->Clear();
auto paragraph1 = System::MakeObject<Paragraph>();
paragraph1->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Numbered);
paragraph1->set_Text(u"Apple");
textFrame->get_Paragraphs()->Add(paragraph1);
auto paragraph2 = System::MakeObject<Paragraph>();
paragraph2->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Numbered);
paragraph2->set_Text(u"Orange");
textFrame->get_Paragraphs()->Add(paragraph2);
auto paragraph3 = System::MakeObject<Paragraph>();
paragraph3->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Numbered);
paragraph3->set_Text(u"Banana");
textFrame->get_Paragraphs()->Add(paragraph3);
presentation->Save(u"numbered_bullets.pptx", SaveFormat::Pptx);
presentation->Dispose();
परिणाम:

Create a Picture Bullet
Aspose.Slides आपको नियमित बुलेट चिन्ह को चित्र से बदलने की अनुमति देता है। चित्र बुलेट सबसे बेहतर होते हैं जब वे सरल चित्र हों जो छोटे आकार में भी पठनीय रहें, जैसे आइकॉन या छोटे पारदर्शी PNG फ़ाइलें।
Note
आदर्श रूप से, यदि आप नियमित बुलेट चिन्ह को चित्र से बदलने की योजना बना रहे हैं, तो पारदर्शी पृष्ठभूमि वाले सरल ग्राफ़िक का चयन करना सबसे अच्छा है। ऐसे चित्र कस्टम बुलेट चिन्हों के रूप में अच्छी तरह काम करते हैं।
ध्यान रखें कि चित्र को बहुत छोटे आकार में स्केल किया जाएगा। इसलिए हम दृढ़ता से सलाह देते हैं कि ऐसा चित्र चुनें जो सूची में बुलेट के रूप में उपयोग करने पर भी स्पष्ट और प्रभावी दिखे।
चित्र बुलेट बनाने के लिए, एक चित्र को IPresentation::get_Images में जोड़ें और लौटाए गए IPPImage ऑब्जेक्ट को IBulletFormat::get_Picture को असाइन करें। असाइन करने से पहले IBulletFormat::set_Type को BulletType::Picture पर सेट करें।
मान लीजिए हमारे पास एक “image.png” है:

निम्नलिखित C++ कोड एक स्लाइड में चित्र बुलेट बनाने का प्रदर्शन करता है:
#include <DOM/BulletType.h>
#include <DOM/IAutoShape.h>
#include <DOM/IBulletFormat.h>
#include <DOM/IImageCollection.h>
#include <DOM/IParagraphCollection.h>
#include <DOM/IParagraphFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ISlidesPicture.h>
#include <DOM/ITextFrame.h>
#include <DOM/Paragraph.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
#include <IImage.h>
#include <Util/Images.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
auto createParagraph = [](System::String text, System::SharedPtr<IPPImage> image)
{
auto paragraph = System::MakeObject<Paragraph>();
auto paragraphFormat = paragraph->get_ParagraphFormat();
auto bulletFormat = paragraphFormat->get_Bullet();
bulletFormat->set_Type(BulletType::Picture);
bulletFormat->get_Picture()->set_Image(image);
paragraphFormat->set_Indent(15);
bulletFormat->set_Height(100);
paragraph->set_Text(text);
return paragraph;
};
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 20, 20, 200, 50);
auto textFrame = autoShape->get_TextFrame();
textFrame->get_Paragraphs()->Clear();
auto sourceImage = Images::FromFile(u"image.png");
auto bulletImage = presentation->get_Images()->AddImage(sourceImage);
sourceImage->Dispose();
auto paragraph1 = createParagraph(u"The first paragraph", bulletImage);
textFrame->get_Paragraphs()->Add(paragraph1);
auto paragraph2 = createParagraph(u"The second paragraph", bulletImage);
textFrame->get_Paragraphs()->Add(paragraph2);
presentation->Save(u"picture_bullets.pptx", SaveFormat::Pptx);
presentation->Dispose();
परिणाम:

Create a Multilevel List
सूची आइटमों को विभिन्न स्तरों पर रखने के लिए IParagraphFormat::set_Depth का उपयोग करें। स्तर 0 शीर्ष स्तर है, स्तर 1 उसके नीचे नेस्टेड है, आदि।
निम्नलिखित C++ कोड मल्टीलेवल बुलेटेड सूची बनाने का प्रदर्शन करता है:
#include <DOM/IAutoShape.h>
#include <DOM/IParagraphCollection.h>
#include <DOM/IParagraphFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/Paragraph.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 20, 20, 260, 110);
auto textFrame = autoShape->get_TextFrame();
textFrame->get_Paragraphs()->Clear();
auto paragraph1 = System::MakeObject<Paragraph>();
paragraph1->get_ParagraphFormat()->set_Depth(0);
paragraph1->set_Text(u"My text - Depth 0");
textFrame->get_Paragraphs()->Add(paragraph1);
auto paragraph2 = System::MakeObject<Paragraph>();
paragraph2->get_ParagraphFormat()->set_Depth(1);
paragraph2->set_Text(u"My text - Depth 1");
textFrame->get_Paragraphs()->Add(paragraph2);
auto paragraph3 = System::MakeObject<Paragraph>();
paragraph3->get_ParagraphFormat()->set_Depth(2);
paragraph3->set_Text(u"My text - Depth 2");
textFrame->get_Paragraphs()->Add(paragraph3);
auto paragraph4 = System::MakeObject<Paragraph>();
paragraph4->get_ParagraphFormat()->set_Depth(3);
paragraph4->set_Text(u"My text - Depth 3");
textFrame->get_Paragraphs()->Add(paragraph4);
presentation->Save(u"multilevel_bullets.pptx", SaveFormat::Pptx);
presentation->Dispose();
परिणाम:

Change an Existing List
मौजूदा प्रस्तुति में सूची फ़ॉर्मेटिंग बदलने के लिए, लक्ष्य पैराग्राफ तक पहुंचें और उसके IParagraphFormat::get_Bullet सेटिंग्स को अपडेट करें। सूचियों को बनाने के लिए उपयोग की गई वही प्रॉपर्टीज़ PPT, PPTX या ODP फ़ाइल से लोड की गई सूचियों को जांचने या संशोधित करने में भी प्रयोग की जा सकती हैं।
निम्नलिखित C++ कोड एक टेक्स्ट फ़्रेम में पहले पैराग्राफ को क्रमांकित सूची शैली में बदलता है:
#include <DOM/BulletType.h>
#include <DOM/IAutoShape.h>
#include <DOM/IBulletFormat.h>
#include <DOM/IParagraph.h>
#include <DOM/IParagraphFormat.h>
#include <DOM/ISlide.h>
#include <DOM/ITextFrame.h>
#include <DOM/NumberedBulletStyle.h>
#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
auto presentation = System::MakeObject<Presentation>(u"input.pptx");
auto slide = presentation->get_Slide(0);
auto autoShape = System::ExplicitCast<IAutoShape>(slide->get_Shape(0));
auto paragraph = autoShape->get_TextFrame()->get_Paragraph(0);
auto paragraphFormat = paragraph->get_ParagraphFormat();
auto bulletFormat = paragraphFormat->get_Bullet();
bulletFormat->set_Type(BulletType::Numbered);
bulletFormat->set_NumberedBulletStyle(NumberedBulletStyle::BulletRomanUCPeriod);
bulletFormat->set_NumberedBulletStartWith(1);
paragraphFormat->set_MarginLeft(30);
paragraphFormat->set_Indent(-20);
presentation->Save(u"updated_list.pptx", SaveFormat::Pptx);
presentation->Dispose();
Read Actual Bullet Values
प्रस्तुति सामग्री निकालते समय, सूची मार्करों को पैराग्राफ टेक्स्ट के साथ रखें। IParagraphFormat::GetEffective को कॉल करें और IParagraphFormatEffectiveData::get_Bullet तक पहुंचकर प्रभावी बुलेट फ़ॉर्मेट प्राप्त करें। वास्तविक मान पढ़ने से पहले उसके get_Type की जाँच करें और फिर get_ActualBulletValue को पढ़ें।
क्रमांकित सूचियों के लिए इन तीन मानों में अंतर करें:
- get_NumberedBulletStyle स्वरूप निर्धारित करता है, जैसे कि अवधि के साथ अरबी अंक या छोटी अक्षर।
- get_NumberedBulletStartWith किसी समूह के क्रमांकित पैराग्राफों के लिए प्रारंभिक संख्या निर्दिष्ट करता है।
- get_ActualBulletValue किसी विशिष्ट पैराग्राफ के लिए स्वरूपित मार्कर लौटाता है। उदाहरण के लिए, यदि सूची 5 से शुरू होती है तो दूसरा आइटम
6.लौटाएगा।
प्रत्येक पैराग्राफ के साथ IParagraphFormat::get_Depth को बनाए रखें ताकि उसका नेस्टिंग स्तर बना रहे। वास्तविक मार्कर पूर्ण पदानुक्रम को एन्कोड नहीं करता: एक नेस्टेड आइटम c. लौट सकता है, न कि मिश्रित लेबल जैसे 6.c.।
निम्नलिखित स्व-अंतर्निहित उदाहरण सूचियों को बनाता है, उन्हें एक प्रस्तुति में सहेजता है, और फिर प्रस्तुति को पुनः लोड करके प्रत्येक पैराग्राफ का टेक्स्ट, डेप्थ, बुलेट प्रकार और वास्तविक मान रिपोर्ट करता है। छोटा नीला चित्र मार्कर इनलाइन SVG से बनाया गया है।
#include <DOM/BulletType.h>
#include <DOM/IAutoShape.h>
#include <DOM/IBulletFormat.h>
#include <DOM/IBulletFormatEffectiveData.h>
#include <DOM/IColorFormat.h>
#include <DOM/IFillFormat.h>
#include <DOM/IImageCollection.h>
#include <DOM/ILineFormat.h>
#include <DOM/IParagraph.h>
#include <DOM/IParagraphCollection.h>
#include <DOM/IParagraphFormat.h>
#include <DOM/IParagraphFormatEffectiveData.h>
#include <DOM/IPortionFormat.h>
#include <DOM/IShapeCollection.h>
#include <DOM/ISlide.h>
#include <DOM/ISlideSize.h>
#include <DOM/ISlidesPicture.h>
#include <DOM/ITextFrame.h>
#include <DOM/FillType.h>
#include <DOM/NullableBool.h>
#include <DOM/NumberedBulletStyle.h>
#include <DOM/Paragraph.h>
#include <DOM/Presentation.h>
#include <DOM/ShapeType.h>
#include <DOM/SlideSizeScaleType.h>
#include <DOM/SvgImage.h>
#include <Export/SaveFormat.h>
#include <drawing/color.h>
#include <system/console.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System::Drawing;
{
auto presentation = System::MakeObject<Presentation>();
presentation->get_SlideSize()->SetSize(720, 440, SlideSizeScaleType::DoNotScale);
auto slide = presentation->get_Slide(0);
auto shape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 30, 20, 660, 400);
shape->get_FillFormat()->set_FillType(FillType::NoFill);
shape->get_LineFormat()->get_FillFormat()->set_FillType(FillType::NoFill);
auto textFrame = shape->get_TextFrame();
textFrame->get_Paragraphs()->Clear();
// बिना बाहरी छवि फ़ाइल के एक चित्र मार्कर बनाएं.
auto svg = System::MakeObject<SvgImage>(u"<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'><rect width='16' height='16' rx='4' fill='#0078D4'/></svg>");
auto bulletImage = presentation->get_Images()->AddImage(svg);
auto addParagraph = [&](System::String text, int16_t depth, BulletType type, int16_t start = 1, NumberedBulletStyle style = NumberedBulletStyle::BulletArabicPeriod)
{
auto paragraph = System::MakeObject<Paragraph>();
paragraph->set_Text(text);
auto format = paragraph->get_ParagraphFormat();
format->set_Depth(depth);
format->set_MarginLeft(30 + depth * 40);
format->set_Indent(-28);
format->set_SpaceAfter(8);
format->get_DefaultPortionFormat()->set_FontHeight(22);
format->get_DefaultPortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
format->get_DefaultPortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
auto bullet = format->get_Bullet();
bullet->set_Type(type);
bullet->set_IsBulletHardColor(NullableBool::True);
bullet->get_Color()->set_Color(Color::get_Black());
if (type == BulletType::Numbered)
{
bullet->set_NumberedBulletStyle(style);
bullet->set_NumberedBulletStartWith(start);
}
else if (type == BulletType::Symbol)
{
bullet->set_Char(u'\u2022');
}
else if (type == BulletType::Picture)
{
bullet->get_Picture()->set_Image(bulletImage);
}
textFrame->get_Paragraphs()->Add(paragraph);
};
addParagraph(u"First item", 0, BulletType::Numbered, 5);
addParagraph(u"Second item", 0, BulletType::Numbered, 5);
addParagraph(u"Nested item", 1, BulletType::Numbered, 3, NumberedBulletStyle::BulletAlphaLCPeriod);
addParagraph(u"Next nested item", 1, BulletType::Numbered, 3, NumberedBulletStyle::BulletAlphaLCPeriod);
addParagraph(u"Deep item", 2, BulletType::Numbered, 4, NumberedBulletStyle::BulletRomanLCPeriod);
addParagraph(u"Back to top level", 0, BulletType::Numbered, 5);
addParagraph(u"Symbol marker", 0, BulletType::Symbol);
addParagraph(u"No bullet", 0, BulletType::None);
addParagraph(u"Picture marker", 0, BulletType::Picture);
presentation->Save(u"actual_bullet_values.pptx", SaveFormat::Pptx);
presentation->Dispose();
}
auto loadedPresentation = System::MakeObject<Presentation>(u"actual_bullet_values.pptx");
auto loadedShape = System::ExplicitCast<IAutoShape>(loadedPresentation->get_Slide(0)->get_Shape(0));
System::Console::WriteLine(u"Text | Depth | Type | Actual value");
for (auto paragraph : loadedShape->get_TextFrame()->get_Paragraphs())
{
auto bullet = paragraph->get_ParagraphFormat()->GetEffective()->get_Bullet();
auto actualValue = bullet->get_ActualBulletValue();
System::String marker;
switch (bullet->get_Type())
{
case BulletType::Numbered:
case BulletType::Symbol:
marker = actualValue;
break;
case BulletType::None:
marker = (actualValue.IsNull() ? System::String(u"null") : actualValue) + u" (no bullet)";
break;
case BulletType::Picture:
marker = (actualValue.IsNull() ? System::String(u"null") : actualValue) + u" (image required)";
break;
default:
marker = u"unsupported bullet type";
break;
}
System::Console::WriteLine(u"{0} | {1} | {2} | {3}", paragraph->get_Text(), paragraph->get_ParagraphFormat()->get_Depth(), bullet->get_Type(), marker);
}
loadedPresentation->Dispose();
स्रोत सूचियों को नीचे दिखाया गया है।

रिपोर्ट PowerPoint में दिखाए गए मार्करों से मेल खाती है:
Text | Depth | Type | Actual value
First item | 0 | Numbered | 5.
Second item | 0 | Numbered | 6.
Nested item | 1 | Numbered | c.
Next nested item | 1 | Numbered | d.
Deep item | 2 | Numbered | iv.
Back to top level | 0 | Numbered | 7.
Symbol marker | 0 | Symbol | •
No bullet | 0 | None | null (no bullet)
Picture marker | 0 | Picture | null (image required)
BulletType::None and BulletType::Picture के लिए, get_ActualBulletValue एक null System::String लौटाता है, खाली स्ट्रिंग नहीं। इस मान की जांच के लिए IsNull का उपयोग करें। इन प्रकारों को अलग‑अलग संभालें: पहला कोई मार्कर नहीं देता, जबकि दूसरा बुलेट छवि को अलग से निकालने की आवश्यकता होती है। केवल टेक्स्ट मार्कर निकालकर चित्र बुलेट को पुनः उत्पन्न नहीं किया जा सकता।
FAQ
क्या बुलेटेड और क्रमांकित सूचियों को PDF या इमेज में निर्यात किया जा सकता है?
हां। Aspose.Slides सूची फ़ॉर्मेटिंग को बरकरार रखता है जब लक्ष्य फ़ॉर्मेट संबंधित टेक्स्ट लेआउट और बुलेट सुविधाओं का समर्थन करता है।
क्या मैं मौजूदा प्रस्तुतियों में सूचियों को संपादित कर सकता हूँ?
हां। प्रस्तुति लोड करें, लक्ष्य पैराग्राफ तक पहुंचें, उसके IParagraphFormat::get_Bullet सेटिंग्स को देखें या अपडेट करें, और फिर प्रस्तुति बचा लें।
क्या सूचियों में गैर‑लैटिन टेक्स्ट हो सकता है?
हां। सूची आइटम टेक्स्ट Unicode अक्षरों को समाहित कर सकता है, इसलिए आप बहुभाषी प्रस्तुतियों में सूचियां बना सकते हैं। सुनिश्चित करें कि प्रस्तुति में उपयोग किए गए फ़ॉन्ट आवश्यक अक्षरों का समर्थन करते हैं।