Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
odthelpbrowser: Remove unused variable and all code paths return values
[xestiaab/.git] / source / tools / odthelpbrowser / frmMain.cpp
1 #include "frmMain.h"
3 class tocItemTreeData : public wxTreeItemData
4 {
5 public:
6         uint32_t itemIndex;
8         tocItemTreeData()
9                 : wxTreeItemData()
10         {
11         };
12 };
14 frmMain::frmMain( wxWindow* parent, ODT::ODT *document )
15 :
16 frmMainADT( parent )
17 , document( document )
18 {
19         wxTreeItemId rootItem = treHelpTopics->AddRoot("Xestia Address Book", -1, -1, nullptr);
21         wxTreeItemId parentItem = rootItem;
22         wxTreeItemId previousItem;
23         
24         wxTreeItemId lastItemAtLevel[9];
25         lastItemAtLevel[ODT::HelpTopicCurrentLevel::TOPIC_LEVEL1] = rootItem;
26         uint32_t itemIndex = 0;
28         for (auto tocItem : document->tocData)
29         {
30                 if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL1)
31                 {
32                         lastItemAtLevel[0] = treHelpTopics->AppendItem(rootItem, tocItem.tocItemName, -1, -1, nullptr);
33                         tocItem.tocItemData = lastItemAtLevel[0].GetID();
34                 }
35                 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL2)
36                 {
37                         lastItemAtLevel[1] = treHelpTopics->AppendItem(lastItemAtLevel[0], tocItem.tocItemName, -1, -1, nullptr);
38                         tocItem.tocItemData = lastItemAtLevel[1].GetID();
39                 }
40                 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL3)
41                 {
42                         lastItemAtLevel[2] = treHelpTopics->AppendItem(lastItemAtLevel[1], tocItem.tocItemName, -1, -1, nullptr);
43                         tocItem.tocItemData = lastItemAtLevel[2].GetID();
44                 }
45                 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL4)
46                 {
47                         lastItemAtLevel[3] = treHelpTopics->AppendItem(lastItemAtLevel[2], tocItem.tocItemName, -1, -1, nullptr);
48                         tocItem.tocItemData = lastItemAtLevel[3].GetID();
49                 }
50                 else
51                 {
52                         wxTreeItemId newItem = treHelpTopics->AppendItem(rootItem, tocItem.tocItemName, -1, -1, nullptr);
53                         tocItem.tocItemData = newItem.GetID();
54                 }
55         
56                 tocItemTreeData *tocItemIndexData = new tocItemTreeData();
57                 tocItemIndexData->itemIndex = itemIndex;
58                 treHelpTopics->SetItemData(tocItem.tocItemData, tocItemIndexData);
59                 
60                 itemIndex++;
61         }
63         // Load in the images.
64         
65         
67         SetTitle(document->title);
68 }
70 void frmMain::UpdateHelpTopic( wxTreeEvent& event )
71 {
72         wxTreeItemId currentTreeItem = event.GetItem();
73         tocItemTreeData *tocItemData = static_cast<tocItemTreeData*>(treHelpTopics->GetItemData(currentTreeItem));
74         
75         std::string pageData;
76         
77         pageData += "<h2>" + std::string(treHelpTopics->GetItemText(currentTreeItem).ToStdString()) + "</h2>\n";
78         
79         // Process the help topic sections.
80         
81         bool firstSection = true;
82         
83         for (auto helpTopicSection : document->helpTopicData[tocItemData->itemIndex].helpTopicSections)
84         {
85                 if (!firstSection)
86                         pageData += "<br><br>";
87                 
88                 firstSection = false;
89                 pageData += helpTopicSection.sectionText + "\n";
90         }
91         
92         // Process the foot note sections.
94         if (document->helpTopicData[tocItemData->itemIndex].helpTopicFootnotes.size() > 0)
95                 pageData += "<hr>\n";
96         
97         for (auto footnoteSection : document->helpTopicData[tocItemData->itemIndex].helpTopicFootnotes)
98         {
99                 std::string footnoteID = std::to_string(footnoteSection.footnoteID);
100                 pageData += "<a name=\"footnote" + footnoteID + "\"></a><sup>" + footnoteID + "</sup>&nbsp;" + footnoteSection.footnoteText + "<br>\n";
101         }
102         
103         htmPage->SetPage((wxString)pageData);
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy