Doxygen
Loading...
Searching...
No Matches
rtfgen.h File Reference

#include <src/rtfgen.h>

Include dependency graph for rtfgen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  RTFCodeGenerator
 Generator for RTF code fragments. More...
class  RTFGenerator
 Generator for RTF output. More...
struct  RTFGenerator::RTFListItemInfo

Functions

DString rtfFormatBmkStr (const DString &name)

Function Documentation

◆ rtfFormatBmkStr()

DString rtfFormatBmkStr ( const DString & name)

Definition at line 2880 of file rtfgen.cpp.

2881{
2882 std::lock_guard<std::mutex> lock(g_rtfFormatMutex);
2883
2884 // To overcome the 40-character tag limitation, we
2885 // substitute a short arbitrary string for the name
2886 // supplied, and keep track of the correspondence
2887 // between names and strings.
2888 auto it = g_tagMap.find(name.str());
2889 if (it!=g_tagMap.end()) // already known
2890 {
2891 return it->second;
2892 }
2893
2894 DString tag = g_nextTag;
2895 auto result = g_tagMap.emplace(name.str(), g_nextTag.str());
2896
2897 if (result.second) // new item was added
2898 {
2899 // increment the next tag.
2900
2901 char* nxtTag = g_nextTag.rawData() + g_nextTag.length() - 1;
2902 for ( unsigned int i = 0; i < g_nextTag.length(); ++i, --nxtTag )
2903 {
2904 if ( ( ++(*nxtTag) ) > 'Z' )
2905 {
2906 *nxtTag = 'A';
2907 }
2908 else
2909 {
2910 // Since there was no carry, we can stop now
2911 break;
2912 }
2913 }
2914 }
2915
2916 Debug::print(Debug::Rtf,0,"Name = {} RTF_tag = {}\n",name,tag);
2917 return tag;
2918}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
char * rawData()
Returns a writable pointer to the data.
Definition dstring.h:166
const std::string & str() const
Definition dstring.h:645
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:151
@ Rtf
Definition debug.h:44
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
Definition debug.h:78
static std::mutex g_rtfFormatMutex
Definition rtfgen.cpp:2876
static std::unordered_map< std::string, std::string > g_tagMap
Definition rtfgen.cpp:2877
static DString g_nextTag("AAAAAAAAAA")

References g_nextTag, g_rtfFormatMutex, g_tagMap, DString::length(), Rtf_Style_Default::name, Debug::print(), DString::rawData(), Debug::Rtf, and DString::str().

Referenced by RTFGenerator::endDoxyAnchor(), objectLinkToString(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::startLink(), RTFGenerator::startTextLink(), RTFGenerator::writeAnchor(), RTFCodeGenerator::writeCodeLink(), RTFCodeGenerator::writeLineNumber(), RTFGenerator::writeRTFReference(), and RTFGenerator::writeStartAnnoItem().