Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
StyledTextEmbeddedObjects.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4
5namespace Stroika::Frameworks::Led {
6
7#if qStroika_Frameworks_Led_SupportGDI
8 /*
9 ********************************************************************************
10 *********************** EmbeddedObjectCreatorRegistry::Assoc *******************
11 ********************************************************************************
12 */
13 inline Led_ClipFormat EmbeddedObjectCreatorRegistry::Assoc::GetIthFormat (size_t i) const
14 {
15 Assert (fFormatTagCount >= 1);
16 Require (i < fFormatTagCount);
17 return (fFormatTagCount == 1) ? fFormatTag : fFormatTags[i];
18 }
19
20 // class EmbeddedObjectCreatorRegistry
21 inline EmbeddedObjectCreatorRegistry::EmbeddedObjectCreatorRegistry ()
22 : fAssocList ()
23 {
24 }
25 inline EmbeddedObjectCreatorRegistry& EmbeddedObjectCreatorRegistry::Get ()
26 {
27 if (sThe == nullptr) {
28 sThe = new EmbeddedObjectCreatorRegistry ();
29 }
30 return *sThe;
31 }
32 inline void EmbeddedObjectCreatorRegistry::AddAssoc (Assoc assoc)
33 {
34 fAssocList.push_back (assoc);
35 }
36 inline void EmbeddedObjectCreatorRegistry::AddAssoc (const char* embeddingTag,
37 SimpleEmbeddedObjectStyleMarker* (*memReader) (const char* embeddingTag,
38 const void* data, size_t len))
39 {
40 Assoc assoc;
41 assoc.fFormatTagCount = 0;
42 memcpy (assoc.fEmbeddingTag, embeddingTag, sizeof (assoc.fEmbeddingTag));
43 assoc.fReadFromMemory = memReader;
44 assoc.fReadFromFlavorPackage = nullptr;
45 AddAssoc (assoc);
46 }
47 inline void EmbeddedObjectCreatorRegistry::AddAssoc (Led_ClipFormat clipFormat, const char* embeddingTag,
48 SimpleEmbeddedObjectStyleMarker* (*memReader) (const char* embeddingTag,
49 const void* data, size_t len),
50 SimpleEmbeddedObjectStyleMarker* (*packageReader) (ReaderFlavorPackage& flavorPackage))
51 {
52 Assoc assoc;
53 assoc.fFormatTag = clipFormat;
54 assoc.fFormatTagCount = 1;
55 memcpy (assoc.fEmbeddingTag, embeddingTag, sizeof (assoc.fEmbeddingTag));
56 assoc.fReadFromMemory = memReader;
57 assoc.fReadFromFlavorPackage = packageReader;
58 AddAssoc (assoc);
59 }
60 inline void EmbeddedObjectCreatorRegistry::AddAssoc (const Led_ClipFormat* clipFormats, size_t clipFormatCount, const char* embeddingTag,
61 SimpleEmbeddedObjectStyleMarker* (*memReader) (const char* embeddingTag,
62 const void* data, size_t len),
63 SimpleEmbeddedObjectStyleMarker* (*packageReader) (ReaderFlavorPackage& flavorPackage))
64 {
65 Assoc assoc;
66 assoc.fFormatTags = clipFormats;
67 assoc.fFormatTagCount = clipFormatCount;
68 memcpy (assoc.fEmbeddingTag, embeddingTag, sizeof (assoc.fEmbeddingTag));
69 assoc.fReadFromMemory = memReader;
70 assoc.fReadFromFlavorPackage = packageReader;
71 AddAssoc (assoc);
72 }
73 inline const vector<EmbeddedObjectCreatorRegistry::Assoc>& EmbeddedObjectCreatorRegistry::GetAssocList () const
74 {
75 return fAssocList;
76 }
77 inline void EmbeddedObjectCreatorRegistry::SetAssocList (const vector<Assoc>& assocList)
78 {
79 fAssocList = assocList;
80 }
81
82 // class SimpleEmbeddedObjectStyleMarker
83 /*
84 @METHOD: SimpleEmbeddedObjectStyleMarker::GetCommandNames
85 @DESCRIPTION: <p>Returns command name for each of the user-visible commands produced by this module.</p>
86 <p>See also @'TextInteractor::CommandNames'.</p>
87 */
88 inline const SimpleEmbeddedObjectStyleMarker::CommandNames& SimpleEmbeddedObjectStyleMarker::GetCommandNames ()
89 {
90 return sCommandNames;
91 }
92 /*
93 @METHOD: SimpleEmbeddedObjectStyleMarker::SetCommandNames
94 @DESCRIPTION: <p>See @'SimpleEmbeddedObjectStyleMarker::GetCommandNames'.</p>
95 */
96 inline void SimpleEmbeddedObjectStyleMarker::SetCommandNames (const SimpleEmbeddedObjectStyleMarker::CommandNames& cmdNames)
97 {
98 sCommandNames = cmdNames;
99 }
100
101#if qStroika_Platform_Windows
102 // class StandardMacPictureStyleMarker
103 inline StandardMacPictureStyleMarker::PictureHandle StandardMacPictureStyleMarker::GetPictureHandle () const
104 {
105 EnsureNotNull (fPictureHandle);
106 return fPictureHandle;
107 }
108 inline size_t StandardMacPictureStyleMarker::GetPictureByteSize () const
109 {
110#if qStroika_Platform_Windows
111 return fPictureSize; // cannot use ::GlobalSize () since that sometimes returns result larger than
112 // actual picture size (rounds up)
113#endif
114 }
115#endif
116
117 // class StandardDIBStyleMarker
118 inline const Led_DIB* StandardDIBStyleMarker::GetDIBData () const
119 {
120 EnsureNotNull (fDIBData);
121 return (fDIBData);
122 }
123
124#if qStroika_Platform_Windows
125 // class StandardMacPictureWithURLStyleMarker
126 inline StandardMacPictureStyleMarker::PictureHandle StandardMacPictureWithURLStyleMarker::GetPictureHandle () const
127 {
128 EnsureNotNull (fPictureHandle);
129 return fPictureHandle;
130 }
131 inline size_t StandardMacPictureWithURLStyleMarker::GetPictureByteSize () const
132 {
133#if qStroika_Platform_Windows
134 return fPictureSize; // cannot use ::GlobalSize () since that sometimes returns result larger than
135 // actual picture size (rounds up)
136#endif
137 }
138#endif
139
140 // class StandardDIBWithURLStyleMarker
141 inline const Led_DIB* StandardDIBWithURLStyleMarker::GetDIBData () const
142 {
143 EnsureNotNull (fDIBData);
144 return (fDIBData);
145 }
146
147 // class StandardUnknownTypeStyleMarker
148 /*
149 @METHOD: StandardUnknownTypeStyleMarker::GetShownSize
150 @DESCRIPTION: <p>Return the size in TWIPS
151 of this embeddings display. Defaults to some size appropriate for the picture drawn. But sometimes
152 (like in reading RTF files which contain size annotations), we select an appropriate size.</p>
153 <p>See @'StandardUnknownTypeStyleMarker::SetShownSize'
154 */
155 inline TWIPS_Point StandardUnknownTypeStyleMarker::GetShownSize () const
156 {
157 return fShownSize;
158 }
159 inline const void* StandardUnknownTypeStyleMarker::GetData () const
160 {
161 return fData;
162 }
163 inline size_t StandardUnknownTypeStyleMarker::GetDataLength () const
164 {
165 return fLength;
166 }
167#endif
168
169}
#define EnsureNotNull(p)
Definition Assertions.h:343