Finale PDK Framework 0.77
Power Up Your Finale Music Software
Loading...
Searching...
No Matches
ff_text.h
1/*
2 * File: ff_text.h
3 * Author: Jari Williamsson
4 *
5 * Created on den 7 november 2010, 20:56
6 */
7
8#ifndef FF_TEXT_H
9#define FF_TEXT_H
10
16class FCRawText : public __FCBaseData
17{
18 bool _workaround2012bug; /* Working around a FinMac2012 bug */
19
20 template <typename T>
21 int _GetNumChars() const
22 {
23 int length = DataSizeLoad() / sizeof(T);
24 const T* pData = reinterpret_cast<T*>(_datablock);
25 while (length > 0 && !pData[length-1]) length--;
26 return length;
27 }
28
29protected:
30
32 virtual void SetRawTextNumber(twobyte number)
33 {
34 _dataid.text.rawTextNumber = number;
35 }
36 int DataSizeLoad() const override;
37 void* Allocate() override;
38 void Deallocate() override;
39 bool IsDynamicSize() override { return true; }
40
41 EVERSION EnigmaVersion() const override;
42
43
45 __FCBaseData* CreateObject() override { return NULL; }
46
49 virtual bool HasUnicodeSupport() const;
50
51public:
52 const char* ClassName() const override { return "FCRawText"; }
53 const PDKFRAMEWORK_CLASSID GetClassID() const override { return FCID_RAWTEXT; }
54
55#ifndef DOXYGEN_SHOULD_IGNORE_THIS
56 EXTAG Tag() const override { return GetCustomTag() ? GetCustomTag() : tx_TextBlock; }
57#endif // DOXYGEN_SHOULD_IGNORE_THIS
58
60 FCRawText();
61
63 virtual ~FCRawText();
64
100
101#ifndef DOXYGEN_SHOULD_IGNORE_THIS
103 static EXTAG _exTagFromRawTextType(RAWTEXTTYPES val)
104 {
105 switch (val)
106 {
107 default:
108#ifdef PDK_FRAMEWORK_LUAFRIENDLY
109 throw std::runtime_error("invalid value for raw text type");
110#endif
111 break;
112 case RAWTEXTTYPE_TEXTBLOCK: return tx_TextBlock;
113 case RAWTEXTTYPE_VERSELYRIC: return tx_VerseLyric;
114 case RAWTEXTTYPE_CHORUSLYRIC: return tx_ChorusLyric;
115 case RAWTEXTTYPE_SECTIONLYRIC: return tx_SectionLyric;
116 case RAWTEXTTYPE_CUSTOMLINE: return tx_SmartShape;
117 case RAWTEXTTYPE_EXPRESSION: return tx_TextExpression;
118 case RAWTEXTTYPE_FILEINFO: return tx_FileInfo;
119 case RAWTEXTTYPE_BOOKMARK: return tx_BookMark;
120 }
121 return 0; // catch-all
122 }
123
125 static RAWTEXTTYPES _rawTextTypeFromExTag(EXTAG val)
126 {
127 switch (val)
128 {
129 case tx_TextBlock: return RAWTEXTTYPE_TEXTBLOCK;
130 case tx_VerseLyric: return RAWTEXTTYPE_VERSELYRIC;
131 case tx_ChorusLyric: return RAWTEXTTYPE_CHORUSLYRIC;
132 case tx_SectionLyric: return RAWTEXTTYPE_SECTIONLYRIC;
133 case tx_SmartShape: return RAWTEXTTYPE_CUSTOMLINE;
134 case tx_TextExpression: return RAWTEXTTYPE_EXPRESSION;
135 case tx_FileInfo: return RAWTEXTTYPE_FILEINFO;
136 case tx_BookMark: return RAWTEXTTYPE_BOOKMARK;
137 }
138 // no throw here, because Finale might have introduced a new type,
139 // or there could be file corruption. This allows us to recover.
140 return RAWTEXTTYPE_UNKNOWN;
141 }
142#endif // DOXYGEN_SHOULD_IGNORE_THIS
143
150#ifndef PDK_FRAMEWORK_LUAFRIENDLY
152#else
153 int
154#endif
155 GetBlockType() const { return _rawTextTypeFromExTag(Tag()); }
156
161 int GetNumChars() const
162 {
163 if (HasUnicodeSupport())
164 return _GetNumChars<eUniChar16>();
165 return _GetNumChars<char>();
166 }
167
172 bool Load(twobyte number);
173
175 bool LoadFirst() override
176 {
178 return LoadNext();
179 }
180
187 bool SaveAs(twobyte number);
188
193 bool SaveNew();
194
202 void SetText(const FCString* pString);
203
210 void GetText(FCString* pString) const;
211
216 virtual twobyte GetItemNo() const { return _dataid.text.rawTextNumber; }
217
226 FCString* CreateString() const;
227
228#ifdef PDK_FRAMEWORK_LUAFRIENDLY_CPP
230 luabridge::RefCountedPtr<FCString> CreateString_GC() const
231 { return makeLuaSharedPtr(CreateString()); }
232#endif
233
234
252 bool GetSubString(FCString* pString, const FCRange *pRange) const;
253
254#ifdef PDK_FRAMEWORK_DEBUG
255 void DebugDump() override
256 {
258 FCString* pString = CreateString();
259 DebugOutString("String value: ", pString->GetCString());
260 delete pString;
261 }
262#endif
263};
264
265
266
274{
275protected:
277 void SetRawTextNumber(twobyte number) override
278 {
279 _dataid.other.cmper = number;
280 }
281
282 EXTAG Tag() const override { return 0; } /* MUST be overwritten in child classes. */
283public:
284 const char* ClassName() const override { return "__FCOtherText"; }
285
287 twobyte GetItemNo() const override { return _dataid.other.cmper; }
288};
289
292{
293 EXTAG Tag() const override { return ot_EndingRepeatText; }
294public:
295 const char* ClassName() const override { return "FCEndingRepeatText"; }
296};
297
298
301{
302 EXTAG Tag() const override {
303#if FXT_VERSION >= FINALEVERSION_25_3
304 /* Unicode and tag change since 25.3 */
305 return ot_RepeatStaffListName;
306#else
307 return ot_StaffListName;
308#endif
309 }
310
311 bool HasUnicodeSupport() const override;
312
313public:
314 const char* ClassName() const override { return "FCStaffListText"; }
315};
316
317
318/* Previously undocumented */
319
320const EXTAG __ot_CategoryStaffListName = MAKEEXTAG(edOther, 'C', 'L');
321
324{
325 EXTAG Tag() const override { return __ot_CategoryStaffListName; }
326 bool HasUnicodeSupport() const override { return false; }
327public:
328 const char* ClassName() const override { return "FCCategoryStaffListText"; }
329};
330
331
332/* Previously undocumented */
333const EXTAG __ot_StaffAssignStaffListName = MAKEEXTAG(edOther, 'S', 'l');
334
337{
338 EXTAG Tag() const override { return __ot_StaffAssignStaffListName; }
339 bool HasUnicodeSupport() const override { return false; }
340public:
341 const char* ClassName() const override { return "FCStaffListStaffAssignText"; }
342};
343
346protected:
347 EXTAG Tag() const override { return ot_TextRepeatStyleText; }
348public:
349 const char* ClassName() const override { return "FCTextRepeatText"; }
350};
351
355protected:
356 EXTAG Tag() const override { return ot_PercussionMapTitle; }
357public:
358 const char* ClassName() const override { return "FCPercussionLayoutNotesText"; }
359};
360
364protected:
365 EXTAG Tag() const override { return ot_InstDefinitionName; }
366public:
367 const char* ClassName() const override { return "FCInstrumentDefText"; }
368};
369
372class FCBookmarkText : public FCRawText {
373protected:
374 EXTAG Tag() const override { return tx_BookMark; }
375public:
376 const char* ClassName() const override { return "FCBookmarkText"; }
377};
378
384class __FCLyricsBase : public FCRawText {
385public:
386 EXTAG Tag() const override = 0; /* Override, but keep a public reference here */
387 const char* ClassName() const override { return "__FCLyricsBase"; }
388
400 int CalcSyllableOffset(int syllableindex, int searchfromindex = 0) const;
401
431 FCFontInfo* CreateSyllableFontInfo(int syllableindex, int searchfromindex = 0) const;
432
433#ifdef PDK_FRAMEWORK_LUAFRIENDLY_CPP
435 luabridge::RefCountedPtr<FCFontInfo> CreateSyllableFontInfo_GC(int syllableindex, int searchfromindex = 0) const
436 { return makeLuaSharedPtr(CreateSyllableFontInfo(syllableindex, searchfromindex)); }
437#endif
438
454 bool GetSyllableRange(FCRange* pRange, int syllableindex, int searchfromindex = 0) const;
455
464 bool GetSyllableText(FCString* pString, int syllableno) const;
465};
466
473protected:
474 EXTAG Tag() const override { return tx_VerseLyric; }
475public:
476 const char* ClassName() const override { return "FCVerseLyricsText"; }
477};
478
485protected:
486 EXTAG Tag() const override { return tx_SectionLyric; }
487public:
488 const char* ClassName() const override { return "FCSectionLyricsText"; }
489};
490
497protected:
498 EXTAG Tag() const override { return tx_ChorusLyric; }
499public:
500 const char* ClassName() const override { return "FCChorusLyricsText"; }
501};
502
503
504#ifdef PDK_FRAMEWORK_ENIGMASTRINGS
517class FCFileInfoText : public FCRawText {
518#ifndef DOXYGEN_SHOULD_IGNORE_THIS
519private:
524 bool _LoadWrapper(twobyte number)
525 {
526 if (!Load(number)) return false;
527 FCString* pString = CreateString();
528 if (!pString) return true;
529 pString->TrimEnigmaFontTags();
530 SetText(pString);
531 delete pString;
532 return true;
533 }
534#endif /* #ifndef DOXYGEN_SHOULD_IGNORE_THIS */
535protected:
536 EXTAG Tag() const override { return tx_FileInfo; }
537public:
538 const char* ClassName() const override { return "FCFileInfoText"; }
539
540#ifndef DOXYGEN_SHOULD_IGNORE_THIS
541 const twobyte GetID_Title() { return 1; }
542 const twobyte GetID_Subtitle() { return 7; }
543 const twobyte GetID_Composer() { return 2; }
544 const twobyte GetID_Arranger() { return 6; }
545 const twobyte GetID_Lyricist() { return 5; }
546 const twobyte GetID_Copyright() { return 3; }
547 const twobyte GetID_Description() { return 4; }
548#endif /* #ifndef DOXYGEN_SHOULD_IGNORE_THIS */
549
554 bool LoadTitle() { return _LoadWrapper(GetID_Title()); }
555
560 bool LoadSubtitle() { return _LoadWrapper(GetID_Subtitle()); }
561
566 bool LoadComposer() { return _LoadWrapper(GetID_Composer()); }
567
572 bool LoadArranger() { return _LoadWrapper(GetID_Arranger()); }
573
578 bool LoadLyricist() { return _LoadWrapper(GetID_Lyricist()); }
579
584 bool LoadCopyright() { return _LoadWrapper(GetID_Copyright()); }
585
590 bool LoadDescription() { return _LoadWrapper(GetID_Description()); }
591
597 bool SaveAsTitle() { return SaveAs(GetID_Title()); }
598
604 bool SaveAsSubtitle() { return SaveAs(GetID_Subtitle()); }
605
611 bool SaveAsComposer() { return SaveAs(GetID_Composer()); }
612
618 bool SaveAsArranger() { return SaveAs(GetID_Arranger()); }
619
625 bool SaveAsLyricist() { return SaveAs(GetID_Lyricist()); }
626
632 bool SaveAsCopyright() { return SaveAs(GetID_Copyright()); }
633
639 bool SaveAsDescription() { return SaveAs(GetID_Description()); }
640};
641#endif /* PDK_FRAMEWORK_ENIGMASTRINGS */
642
643
644
645
646#endif /* FF_TEXT_H */
647
Base class for all data-related classes (that handles Finale data).
Definition ff_base.h:676
EXTAG GetCustomTag() const
Returns the custom Enigma tag, if any.
Definition ff_base.h:870
EDataID _dataid
The EdataID for the last loaded/saved object.
Definition ff_base.h:712
void * _datablock
Pointer to the object's data block, the meaning is implementation-specific for each derived subclass.
Definition ff_base.h:695
virtual EXTAG Tag() const =0
The Enigma tag for the derived class.
void DebugDump() override
Outputs the class data/information for debugging purposes.
Definition ff_base.h:1006
virtual bool LoadNext()
Loads the next element from the database, if any.
Definition finaleframework.cpp:980
static void DebugOutString(const char *pszPrefixText, const char *thestring)
Static method that outputs a line for debugging purposes (C string version). The text appears with th...
Definition finaleframework.cpp:436
PDKFRAMEWORK_CLASSID
Constants for the GetClassID method.
Definition ff_base.h:84
The base class for all lyrics text classes.
Definition ff_text.h:384
FCFontInfo * CreateSyllableFontInfo(int syllableindex, int searchfromindex=0) const
Creates a font info object for the start of the syllable.
Definition finaleframework.cpp:4539
bool GetSyllableText(FCString *pString, int syllableno) const
Returns the plain syllable text without hyphen, space, or formatting.
Definition finaleframework.cpp:4574
EXTAG Tag() const override=0
The Enigma tag for the derived class.
int CalcSyllableOffset(int syllableindex, int searchfromindex=0) const
Get the character offset of a syllable from the beginning of the raw text.
Definition finaleframework.cpp:4519
bool GetSyllableRange(FCRange *pRange, int syllableindex, int searchfromindex=0) const
Returns the range of characters of the syllable.
Definition finaleframework.cpp:4559
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:387
The base class for text classes that loads from 'other' (not as regular raw text).
Definition ff_text.h:274
EXTAG Tag() const override
The Enigma tag for the derived class.
Definition ff_text.h:282
twobyte GetItemNo() const override
Gets the item number for the text.
Definition ff_text.h:287
void SetRawTextNumber(twobyte number) override
Definition ff_text.h:277
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:284
Text used for a bookmarks. Please refer to the FCBookmark class.
Definition ff_text.h:372
EXTAG Tag() const override
The Enigma tag for the derived class.
Definition ff_text.h:374
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:376
The class for chorus lyrics texts.
Definition ff_text.h:496
EXTAG Tag() const override
The Enigma tag for the derived class.
Definition ff_text.h:498
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:500
Text in repeat endings.
Definition ff_text.h:292
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:295
The class for file information text fields.
Definition ff_text.h:517
bool SaveAsDescription()
Saves the text as the "Description" in the File Info text.
Definition ff_text.h:639
bool LoadSubtitle()
Loads the subtitle File Info text.
Definition ff_text.h:560
bool LoadCopyright()
Loads the copyright File Info text.
Definition ff_text.h:584
bool LoadArranger()
Loads the arranger File Info text.
Definition ff_text.h:572
bool LoadDescription()
Loads the description File Info text.
Definition ff_text.h:590
bool SaveAsArranger()
Saves the text as the "Arranger" in the File Info text.
Definition ff_text.h:618
bool LoadTitle()
Loads the title File Info text.
Definition ff_text.h:554
bool SaveAsTitle()
Saves the text as the "Title" in the File Info text.
Definition ff_text.h:597
bool SaveAsLyricist()
Saves the text as the "Lyricist" in the File Info text.
Definition ff_text.h:625
bool LoadLyricist()
Loads the lyricist File Info text.
Definition ff_text.h:578
bool SaveAsSubtitle()
Saves the text as the "Subtitle" in the File Info text.
Definition ff_text.h:604
bool LoadComposer()
Loads the composer File Info text.
Definition ff_text.h:566
bool SaveAsComposer()
Saves the text as the "Composer" in the File Info text.
Definition ff_text.h:611
bool SaveAsCopyright()
Saves the text as the "Copyright" in the File Info text.
Definition ff_text.h:632
EXTAG Tag() const override
The Enigma tag for the derived class.
Definition ff_text.h:536
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:538
Class for document-independent font information.
Definition ff_base.h:1138
Text used for an instrument definition. Please refer to the FCInstrumentDef class.
Definition ff_text.h:363
EXTAG Tag() const override
The Enigma tag for the derived class.
Definition ff_text.h:365
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:367
Text used for the name of a percussion layout. Please refer to the FCPercussionLayoutNotes class.
Definition ff_text.h:354
EXTAG Tag() const override
The Enigma tag for the derived class.
Definition ff_text.h:356
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:358
Class that encapsulates a range (start, length)
Definition ff_base.h:5570
The class for raw text objects. All other text classes are based on this class, but it can also be us...
Definition ff_text.h:17
void GetText(FCString *pString) const
Copies the object's text to a FCString object.
Definition finaleframework.cpp:4458
bool Load(twobyte number)
Loads the text with the indicated text number.
Definition finaleframework.cpp:4386
bool SaveNew()
Saves the text at the first empty spot.
Definition finaleframework.cpp:4430
virtual void SetRawTextNumber(twobyte number)
Definition ff_text.h:32
const PDKFRAMEWORK_CLASSID GetClassID() const override
Returns the internal class ID for the PDK Framework class. This is implemented mostly because Lua has...
Definition ff_text.h:53
FCString * CreateString() const
Creates a string object with the loaded text. If the string doesn't exist (or if it's empty),...
Definition finaleframework.cpp:4470
RAWTEXTTYPES GetBlockType() const
Returns the text block type of this FCRawText.
Definition ff_text.h:155
virtual bool HasUnicodeSupport() const
Should return true if the data structure has Unicode support on the running platform.
Definition finaleframework.cpp:4491
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:52
bool LoadFirst() override
Loads the first raw text entry.
Definition ff_text.h:175
FCRawText()
The constructor.
Definition finaleframework.cpp:4337
EVERSION EnigmaVersion() const override
The Enigma version for save/load/create/delete operations.
Definition finaleframework.cpp:4348
bool SaveAs(twobyte number)
Saves the text by a new text number.
Definition finaleframework.cpp:4423
void SetText(const FCString *pString)
Sets the text for the object. (The object needs to be saved to Finale to take effect....
Definition finaleframework.cpp:4437
void * Allocate() override
Definition finaleframework.cpp:4373
RAWTEXTTYPES
enumerates the possible raw text types.
Definition ff_text.h:72
@ RAWTEXTTYPE_VERSELYRIC
Definition ff_text.h:77
@ RAWTEXTTYPE_CHORUSLYRIC
Definition ff_text.h:80
@ RAWTEXTTYPE_BOOKMARK
Definition ff_text.h:95
@ RAWTEXTTYPE_CUSTOMLINE
Definition ff_text.h:86
@ RAWTEXTTYPE_EXPRESSION
Definition ff_text.h:89
@ RAWTEXTTYPE_SECTIONLYRIC
Definition ff_text.h:83
@ RAWTEXTTYPE_FILEINFO
Definition ff_text.h:92
@ RAWTEXTTYPE_UNKNOWN
Definition ff_text.h:98
@ RAWTEXTTYPE_TEXTBLOCK
Definition ff_text.h:74
void DebugDump() override
Outputs the class data/information for debugging purposes.
Definition ff_text.h:255
bool GetSubString(FCString *pString, const FCRange *pRange) const
Gets a string object with the range of characters from loaded text.
Definition finaleframework.cpp:4477
void Deallocate() override
Definition finaleframework.cpp:4379
int GetNumChars() const
Returns the number of characters in the raw text.
Definition ff_text.h:161
int DataSizeLoad() const override
Returns the data size for the data structure that should be loaded.
Definition finaleframework.cpp:4366
virtual twobyte GetItemNo() const
Gets the item number for the text.
Definition ff_text.h:216
virtual ~FCRawText()
The (virtual) destructor.
Definition finaleframework.cpp:4342
__FCBaseData * CreateObject() override
Definition ff_text.h:45
bool IsDynamicSize() override
Definition ff_text.h:39
The class for section lyrics texts.
Definition ff_text.h:484
EXTAG Tag() const override
The Enigma tag for the derived class.
Definition ff_text.h:486
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:488
Staff list titles for staff lists in categories.
Definition ff_text.h:324
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:328
Staff list titles for staff-assigned staff lists
Definition ff_text.h:337
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:341
Staff list titles for staff lists in repeats
Definition ff_text.h:301
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:314
Class that provides storage for text. This is to achieve platform-transparent text handling,...
Definition ff_base.h:1877
const char * GetCString() const
Returns a C-string version of the string.
Definition finaleframework.cpp:1338
bool TrimEnigmaFontTags()
Removes all Enigma font tags from a string, leaving only the actual text and text insert tags,...
Definition finaleframework.cpp:1437
Text used for text repeats.
Definition ff_text.h:345
EXTAG Tag() const override
The Enigma tag for the derived class.
Definition ff_text.h:347
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:349
The class for verse lyrics texts.
Definition ff_text.h:472
EXTAG Tag() const override
The Enigma tag for the derived class.
Definition ff_text.h:474
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_text.h:476