Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
StyledTextEmbeddedObjects.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. 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_Foundation_Common_Platform_MacOS || qStroika_Foundation_Common_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_Foundation_Common_Platform_MacOS
111 return ::GetHandleSize (Handle (fPictureHandle));
112#elif qStroika_Foundation_Common_Platform_Windows
113 return fPictureSize; // cannot use ::GlobalSize () since that sometimes returns result larger than
114 // actual picture size (rounds up)
115#endif
116 }
117#endif
118
119 // class StandardDIBStyleMarker
120 inline const Led_DIB* StandardDIBStyleMarker::GetDIBData () const
121 {
122 EnsureNotNull (fDIBData);
123 return (fDIBData);
124 }
125
126#if qStroika_Foundation_Common_Platform_MacOS || qStroika_Foundation_Common_Platform_Windows
127 // class StandardMacPictureWithURLStyleMarker
128 inline StandardMacPictureStyleMarker::PictureHandle StandardMacPictureWithURLStyleMarker::GetPictureHandle () const
129 {
130 EnsureNotNull (fPictureHandle);
131 return fPictureHandle;
132 }
133 inline size_t StandardMacPictureWithURLStyleMarker::GetPictureByteSize () const
134 {
135#if qStroika_Foundation_Common_Platform_MacOS
136 return ::GetHandleSize (Handle (fPictureHandle));
137#elif qStroika_Foundation_Common_Platform_Windows
138 return fPictureSize; // cannot use ::GlobalSize () since that sometimes returns result larger than
139 // actual picture size (rounds up)
140#endif
141 }
142#endif
143
144 // class StandardDIBWithURLStyleMarker
145 inline const Led_DIB* StandardDIBWithURLStyleMarker::GetDIBData () const
146 {
147 EnsureNotNull (fDIBData);
148 return (fDIBData);
149 }
150
151 // class StandardUnknownTypeStyleMarker
152 /*
153 @METHOD: StandardUnknownTypeStyleMarker::GetShownSize
154 @DESCRIPTION: <p>Return the size in TWIPS
155 of this embeddings display. Defaults to some size appropriate for the picture drawn. But sometimes
156 (like in reading RTF files which contain size annotations), we select an appropriate size.</p>
157 <p>See @'StandardUnknownTypeStyleMarker::SetShownSize'
158 */
159 inline TWIPS_Point StandardUnknownTypeStyleMarker::GetShownSize () const
160 {
161 return fShownSize;
162 }
163 inline const void* StandardUnknownTypeStyleMarker::GetData () const
164 {
165 return fData;
166 }
167 inline size_t StandardUnknownTypeStyleMarker::GetDataLength () const
168 {
169 return fLength;
170 }
171#endif
172
173}
#define EnsureNotNull(p)
Definition Assertions.h:340