Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
MFC_WordProcessor.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#include "Stroika/Frameworks/StroikaPreComp.h"
5
6#include <climits>
7
8#if qStroika_HasComponent_ATLMFC
9
10#include <afxext.h>
11#include <atlstr.h>
12
13DISABLE_COMPILER_MSC_WARNING_START (5054)
14#include <afxole.h>
15DISABLE_COMPILER_MSC_WARNING_END (5054)
16
17#include "Stroika/Foundation/DataExchange/BadFormatException.h"
19
20#include "MFC_WordProcessor.h"
21
22using std::byte;
23
24using namespace Stroika::Foundation;
25using namespace Stroika::Frameworks::Led;
26using namespace Stroika::Frameworks::Led::Platform;
27using namespace Stroika::Frameworks::Led::StyledTextIO;
28
29using std::byte;
30
31#if qSupportOLEControlEmbedding
32
33inline SIZE HIMETRICtoDP (SIZE s)
34{
35 // Crazy convention of passing NULL as this, used in MFC alot and the routine
36 // checks for NULL this??? - WOW!
37 ((CDC*)NULL)->HIMETRICtoDP (&s);
38 return s;
39}
40inline SIZE DPtoHIMETRIC (SIZE s)
41{
42 // Crazy convention of passing NULL as this, used in MFC alot and the routine
43 // checks for NULL this??? - WOW!
44 ((CDC*)NULL)->DPtoHIMETRIC (&s);
45 return s;
46}
47
48/*
49 ********************************************************************************
50 ***************************** Led_MFC_ControlItem ******************************
51 ********************************************************************************
52 */
53COleDocument* Led_MFC_ControlItem::DocContextDefiner::sDoc = NULL;
54
55// Note sure this is the right type????
56const Led_ClipFormat Led_MFC_ControlItem::kClipFormat = static_cast<Led_ClipFormat> (::RegisterClipboardFormat (_T("Object Descriptor")));
57const Led_PrivateEmbeddingTag Led_MFC_ControlItem::kEmbeddingTag = "OLE2Embed";
58
59IMPLEMENT_SERIAL (Led_MFC_ControlItem, COleClientItem, 0)
60
61Led_MFC_ControlItem::Led_MFC_ControlItem (COleDocument* pContainer)
62 : COleClientItem (pContainer)
63 , fSize (Led_Size (0, 0))
64{
65}
66
67Led_MFC_ControlItem::~Led_MFC_ControlItem ()
68{
69}
70
71SimpleEmbeddedObjectStyleMarker* Led_MFC_ControlItem::mkLed_MFC_ControlItemStyleMarker (const char* embeddingTag, const void* data, size_t len)
72{
73 Require (memcmp (embeddingTag, kEmbeddingTag, sizeof (kEmbeddingTag)) == 0 or
74 memcmp (embeddingTag, RTFIO::RTFOLEEmbedding::kEmbeddingTag, sizeof (RTFIO::RTFOLEEmbedding::kEmbeddingTag)) == 0);
75
76 RequireNotNull (DocContextDefiner::GetDoc ()); // See doc in header for class DocContextDefiner.
77 // must declare one of these on call stack before calling this
78 // method...
79 Led_MFC_ControlItem* e = new Led_MFC_ControlItem (DocContextDefiner::GetDoc ());
80
81 return mkLed_MFC_ControlItemStyleMarker_ (embeddingTag, data, len, e);
82}
83
84SimpleEmbeddedObjectStyleMarker* Led_MFC_ControlItem::mkLed_MFC_ControlItemStyleMarker (ReaderFlavorPackage& flavorPackage)
85{
86 RequireNotNull (DocContextDefiner::GetDoc ()); // See doc in header for class DocContextDefiner.
87 // must declare one of these on call stack before calling this
88 // method...
89 Led_MFC_ControlItem* e = new Led_MFC_ControlItem (DocContextDefiner::GetDoc ());
90
91 return mkLed_MFC_ControlItemStyleMarker_ (flavorPackage, e);
92}
93
94struct MyOLEStream_input : OLESTREAM {
95 OLESTREAMVTBL theVTbl;
96 const byte* start;
97 const byte* end;
98 const byte* cur;
99 static DWORD __stdcall MyOLE1STREAMGetter (LPOLESTREAM lpoleStr, void* data, DWORD nb)
100 {
101 MyOLEStream_input* myStream = (MyOLEStream_input*)lpoleStr;
102 size_t bytesLeft = myStream->end - myStream->cur;
103 size_t bytesToRead = min<size_t> (bytesLeft, nb);
104 (void)::memcpy (data, myStream->cur, bytesToRead);
105 myStream->cur += bytesToRead;
106 return static_cast<DWORD> (bytesToRead);
107 }
108 MyOLEStream_input (const void* data, size_t nBytes)
109 : start ((byte*)data)
110 , end ((byte*)data + nBytes)
111 , cur ((byte*)data)
112 {
113 lpstbl = &theVTbl;
114 theVTbl.Get = MyOLE1STREAMGetter;
115 theVTbl.Put = NULL;
116 }
117};
118SimpleEmbeddedObjectStyleMarker* Led_MFC_ControlItem::mkLed_MFC_ControlItemStyleMarker_ (const char* embeddingTag, const void* data,
119 size_t len, Led_MFC_ControlItem* builtItem)
120{
121 Require (memcmp (embeddingTag, kEmbeddingTag, sizeof (kEmbeddingTag)) == 0 or
122 memcmp (embeddingTag, RTFIO::RTFOLEEmbedding::kEmbeddingTag, sizeof (RTFIO::RTFOLEEmbedding::kEmbeddingTag)) == 0);
123 // Need todo try/catch eror handling...??? Or does caller delete embedding? On error? Decide!!!
124 //&&&&&&&
125 if (memcmp (embeddingTag, kEmbeddingTag, sizeof (kEmbeddingTag)) == 0) {
126 Memory::StackBuffer<char> buf{Memory::eUninitialized, len};
127 CMemFile memFile ((unsigned char*)data, static_cast<UINT> (len));
128 CArchive archive (&memFile, CArchive::load);
129 builtItem->Serialize (archive);
130 }
131 else if (memcmp (embeddingTag, RTFIO::RTFOLEEmbedding::kEmbeddingTag, sizeof (RTFIO::RTFOLEEmbedding::kEmbeddingTag)) == 0) {
132 /*
133 * NB: The RTF 1.4 spec says the contents are in a format where all you need todo is to call
134 * ::OleLoadFromStream. But this is apparantly not so. The data is apparantly in OLE1 format, and
135 * so must be converted via OleConvertOLESTREAMToIStorage (). This - in turn - is extrememly badly
136 * documented. But I've managed to cobble something together which appears to work.
137 *
138 * Then - there is the matter of patching all the right MFC COleClientItem member variables so they
139 * are all happy. MFC (4.2? version with MSVC50) doesn't make this very clear. But what I did was trace
140 * through the code which was executed during a "Serialize" call. And I do most of that stuff.
141 */
142
143 // Magic from COleClientItem::Serialize()
144 builtItem->m_dwItemNumber = builtItem->GetNewItemNumber ();
145 builtItem->GetItemStorage ();
146
147 // Build my own OLE1 OLESTREAM
148 MyOLEStream_input myStream (data, len);
149
150 // Docs don't seem to say passing NULL for DVTARGETDEVICE, but - seems to work - and I don't know which one to use?
151 builtItem->CheckGeneral (::OleConvertOLESTREAMToIStorage (&myStream, builtItem->m_lpStorage, NULL));
152
153 Assert (Led_MFC_ControlItem::DocContextDefiner::sWindowsWhichHadDisplaySuppressed.empty ()); // if someplace ELSE is adding these windows,
154 // we must be careful - else could be using bogus windows!
155 /*
156 * See COleClientItem::ReadFlat code - next query OleXXX interface, and assign that to some
157 * data member, and then call finish create???
158 *
159 * NB: unlike ReadFlat, we cannot call OleLoadFromStream - since this appears to assume an OLE2 format stream.
160 */
161 IUnknown* pUnk = NULL;
162 builtItem->CheckGeneral (::OleLoad (builtItem->m_lpStorage, IID_IUnknown, builtItem->GetClientSite (), (LPVOID*)&pUnk));
163 Assert (pUnk != NULL);
164
165 {
166 /*
167 * Building OLE controls CAN cause the MFC COleMessageFilter to pass WM_PAINT messages to us. That is a big
168 * performance no-no (reading in large files, because it disables the IsWholeWindowInvalid () optimization).
169 * So - inside of WordProcessorCommonCommandHelper_MFC<BASECLASS,CMD_INFO>::OnPaint () we check
170 * and see that we are not creating OLE objects, and if we are, then skip the paint event and save the window
171 * so we can RE-INVALIDATE it (here).
172 */
173 for (auto i = Led_MFC_ControlItem::DocContextDefiner::sWindowsWhichHadDisplaySuppressed.begin ();
174 i != Led_MFC_ControlItem::DocContextDefiner::sWindowsWhichHadDisplaySuppressed.end (); ++i) {
175 Verify (::InvalidateRect (*i, NULL, true) != 0);
176 }
177 Led_MFC_ControlItem::DocContextDefiner::sWindowsWhichHadDisplaySuppressed.clear ();
178 }
179
180 if (pUnk->QueryInterface (IID_IOleObject, (LPVOID*)&builtItem->m_lpObject) != S_OK) {
181 pUnk->Release ();
182 throw bad_alloc ();
183 }
184 pUnk->Release ();
185
186 if (not builtItem->FinishCreate (S_OK)) {
187 AfxThrowArchiveException (CArchiveException::genericException);
188 }
189
190 SIZE size;
191 builtItem->GetExtent (&size);
192 builtItem->fSize = AsLedSize (HIMETRICtoDP (size));
193 }
194 return builtItem;
195}
196
197SimpleEmbeddedObjectStyleMarker* Led_MFC_ControlItem::mkLed_MFC_ControlItemStyleMarker_ (ReaderFlavorPackage& flavorPackage, Led_MFC_ControlItem* builtItem)
198{
199 Led_MFC_ControlItem* e = builtItem;
200
201 // MUST BE MORE EXCPETION FRIENDLY HERE!!! - DELETE e if FIALURE AND ALSO BE CAREFUL OF CLIP OWNER!!!
202 // LGP 960412
203
204 ReaderClipboardFlavorPackage* rcfp = dynamic_cast<ReaderClipboardFlavorPackage*> (&flavorPackage);
205 if (rcfp != NULL) {
206 // fairly complex what MFC does here... Rather than reproduce it all, close the clipboard, and let MFC take care of it all.
207 // Reopen it so we our later close code doesn't fail...
208 HWND oldClipOwner = ::GetOpenClipboardWindow ();
209 AssertNotNull (oldClipOwner);
210 (void)::CloseClipboard ();
211
212 // Let MFC do the OLE clipboard copy...
213 e->CreateFromClipboard ();
214
215 // now restore things so we don't fail later on our attempt to close...
216 (void)::OpenClipboard (oldClipOwner);
217 }
218 else {
219 Led_MFCReaderDAndDFlavorPackage* dndfp = dynamic_cast<Led_MFCReaderDAndDFlavorPackage*> (&flavorPackage);
220 AssertNotNull (dndfp); // if not from clip, must be from Drag and Drop!
221 DISABLE_COMPILER_MSC_WARNING_START (28182)
222 if (e->CreateFromData (dndfp->GetOleDataObject ()) == 0) {
223 Execution::Throw (DataExchange::BadFormatException::kThe);
224 }
225 DISABLE_COMPILER_MSC_WARNING_END (28182)
226 }
227
228 {
229 CSize size;
230 if (e->GetCachedExtent (&size)) {
231 e->fSize = AsLedSize (HIMETRICtoDP (size));
232 }
233 }
234
235 return e;
236}
237
238void Led_MFC_ControlItem::OnChange (OLE_NOTIFICATION nCode, DWORD dwParam)
239{
240 ASSERT_VALID (this);
241
242 COleClientItem::OnChange (nCode, dwParam);
243 // When an item is being edited (either in-place or fully open)
244 // it sends OnChange notifications for changes in the state of the
245 // item or visual appearance of its content.
246
247 // TODO: invalidate the item by calling UpdateAllViews
248 // (with hints appropriate to your application)
249
250 GetDocument ().UpdateAllViews (NULL);
251 // for now just update ALL views/no hints
252}
253
254BOOL Led_MFC_ControlItem::OnChangeItemPosition (const CRect& rectPos)
255{
256 ASSERT_VALID (this);
257
258 // During in-place activation Led_MFC_ControlItem::OnChangeItemPosition
259 // is called by the server to change the position of the in-place
260 // window. Usually, this is a result of the data in the server
261 // document changing such that the extent has changed or as a result
262 // of in-place resizing.
263 //
264 // The default here is to call the base class, which will call
265 // COleClientItem::SetItemRects to move the item
266 // to the new position.
267
268 if (!COleClientItem::OnChangeItemPosition (rectPos)) {
269 return FALSE;
270 }
271
272 if (fSize != AsLedSize (rectPos.Size ())) {
273 TextStore& textStore = *GetOwner ()->PeekAtTextStore ();
274 TextStore::SimpleUpdater updater (textStore, GetStart (), GetEnd ());
275 fSize = AsLedSize (rectPos.Size ());
276 }
277
278 return TRUE;
279}
280
281void Led_MFC_ControlItem::OnGetItemPosition (CRect& rPosition)
282{
283 ASSERT_VALID (this);
284
285 // During in-place activation, Led_MFC_ControlItem::OnGetItemPosition
286 // will be called to determine the location of this item. The default
287 // implementation created from AppWizard simply returns a hard-coded
288 // rectangle. Usually, this rectangle would reflect the current
289 // position of the item relative to the view used for activation.
290 // You can obtain the view by calling Led_MFC_ControlItem::GetActiveView.
291
292 // return correct rectangle (in pixels) in rPosition
293 rPosition = AsCRect (GetActiveView ().GetCharWindowLocation (this->GetStart ()));
294}
295
296BOOL Led_MFC_ControlItem::DoVerb (LONG nVerb, CView* pView, LPMSG lpMsg)
297{
298 BOOL result = COleClientItem::DoVerb (nVerb, pView, lpMsg);
299 if (nVerb == OLEIVERB_SHOW or nVerb == OLEIVERB_OPEN) {
300 SIZE size;
301 const_cast<Led_MFC_ControlItem*> (this)->GetExtent (&size);
302 if (fSize != AsLedSize (HIMETRICtoDP (size))) {
303 TextStore& textStore = *GetOwner ()->PeekAtTextStore ();
304 TextStore::SimpleUpdater updater (textStore, GetStart (), GetEnd ());
305 fSize = AsLedSize (HIMETRICtoDP (size));
306
307 // SPR#1450 - quirky hack so embedded widgets show up immediately at the right size.
308 const_cast<Led_MFC_ControlItem*> (this)->SetExtent (size);
309 }
310 }
311 return result;
312}
313
314void Led_MFC_ControlItem::OnActivate ()
315{
316 // Allow only one inplace activate item per frame
317 Led_MFC& pView = GetActiveView ();
318 COleClientItem* pItem = GetDocument ().GetInPlaceActiveItem (&pView);
319 if (pItem != NULL && pItem != this) {
320 pItem->Close ();
321 }
322 COleClientItem::OnActivate ();
323}
324
325void Led_MFC_ControlItem::OnDeactivateUI (BOOL bUndoable)
326{
327 COleClientItem::OnDeactivateUI (bUndoable);
328
329 // Hide the object if it is not an outside-in object
330 DWORD dwMisc = 0;
331 m_lpObject->GetMiscStatus (GetDrawAspect (), &dwMisc);
332 if (dwMisc & OLEMISC_INSIDEOUT) {
333 DoVerb (OLEIVERB_HIDE, NULL);
334 }
335}
336
337void Led_MFC_ControlItem::DrawSegment (const StyledTextImager* imager, const StyleRunElement& /*runElement*/, Tablet* tablet,
338 [[maybe_unused]] size_t from, [[maybe_unused]] size_t to, [[maybe_unused]] const TextLayoutBlock& text,
339 const Led_Rect& drawInto, const Led_Rect& /*invalidRect*/, CoordinateType useBaseLine, DistanceType* pixelsDrawn)
340{
341 Require (to - from == 1);
342 Require (text.PeekAtVirtualText ()[0] == kEmbeddingSentinelChar);
343
344 Color foreColor = imager->GetEffectiveDefaultTextColor (TextImager::eDefaultTextColor);
345 ;
346 Color backColor = imager->GetEffectiveDefaultTextColor (TextImager::eDefaultBackgroundColor);
347 GDI_Obj_Selector pen (tablet, ::GetStockObject (WHITE_PEN));
348 tablet->SetTextColor (foreColor.GetOSRep ());
349 tablet->SetBkColor (backColor.GetOSRep ());
350
351 Led_Rect ourBoundsRect = drawInto;
352 ourBoundsRect.right = ourBoundsRect.left + fSize.h + 2 * kDefaultEmbeddingMargin.h;
353 CoordinateType embedBottom = useBaseLine;
354 CoordinateType embedTop = embedBottom - fSize.v;
355 Assert (embedTop >= drawInto.top);
356 Assert (embedBottom <= drawInto.bottom);
357 Led_Rect innerBoundsRect = Led_Rect (Led_Point (embedTop, drawInto.left + kDefaultEmbeddingMargin.h), fSize);
358
359 if (pixelsDrawn != NULL) {
360 *pixelsDrawn = ourBoundsRect.GetWidth ();
361 }
362
363 COleClientItem::Draw (Led_MFC_CDCFromTablet (tablet), CRect (AsRECT (innerBoundsRect)));
364}
365
366void Led_MFC_ControlItem::MeasureSegmentWidth ([[maybe_unused]] const StyledTextImager* imager, [[maybe_unused]] const StyleRunElement& runElement,
367 [[maybe_unused]] size_t from, [[maybe_unused]] size_t to,
368 [[maybe_unused]] const Led_tChar* text, DistanceType* distanceResults) const
369{
370 Assert (from + 1 == to);
371 Assert (text[0] == kEmbeddingSentinelChar);
372 distanceResults[0] = fSize.h + 2 * kDefaultEmbeddingMargin.h;
373}
374
375DistanceType Led_MFC_ControlItem::MeasureSegmentHeight (const StyledTextImager* /*imager*/, const StyleRunElement& /*runElement*/,
376 [[maybe_unused]] size_t from, [[maybe_unused]] size_t to) const
377{
378 Assert (from + 1 == to);
379 return fSize.v + 2 * kDefaultEmbeddingMargin.v;
380}
381
382void Led_MFC_ControlItem::Write (SinkStream& sink)
383{
384 CMemFile memFile;
385 CArchive archive (&memFile, CArchive::store);
386 Serialize (archive);
387 archive.Close ();
388 size_t nBytes = static_cast<size_t> (memFile.GetLength ());
389 BYTE* written = memFile.Detach ();
390 if (written != NULL) {
391 sink.write (written, nBytes);
392 ::free (written);
393 }
394}
395
396void Led_MFC_ControlItem::ExternalizeFlavors (WriterFlavorPackage& flavorPackage)
397{
398 WriterClipboardFlavorPackage* wcfp = dynamic_cast<WriterClipboardFlavorPackage*> (&flavorPackage);
399 if (wcfp != NULL) {
400 // fairly complex what MFC does here... Rather than reproduce it all, close the clipboard, and let MFC take care of it all.
401 // Reopen it so we our later close code doesn't fail...
402 HWND oldClipOwner = ::GetOpenClipboardWindow ();
403 AssertNotNull (oldClipOwner);
404 (void)::CloseClipboard ();
405
406 // Let MFC do the OLE clipboard copy...
407 CopyToClipboard ();
408
409 // now restore things so we don't fail later on our attempt to close...
410 (void)::OpenClipboard (oldClipOwner);
411 }
412 else {
413 Led_MFCWriterDAndDFlavorPackage* dndfp = dynamic_cast<Led_MFCWriterDAndDFlavorPackage*> (&flavorPackage);
414 AssertNotNull (dndfp);
415 DISABLE_COMPILER_MSC_WARNING_START (28182)
416 GetClipboardData (dndfp->GetOleDataSource ());
417 DISABLE_COMPILER_MSC_WARNING_END (28182)
418 }
419}
420
421const char* Led_MFC_ControlItem::GetTag () const
422{
423 return kEmbeddingTag;
424}
425
426void Led_MFC_ControlItem::Serialize (CArchive& ar)
427{
428 COleClientItem::Serialize (ar);
429 if (not ar.IsStoring ()) {
430 // then grab our size from the GetExtent() method to see the fSize field...
431 // Don't need to notify owning textstore etc cuz not yet even owned (probably?).
432 SIZE size;
433 const_cast<Led_MFC_ControlItem*> (this)->GetExtent (&size);
434 fSize = AsLedSize (HIMETRICtoDP (size));
435 }
436}
437
438void Led_MFC_ControlItem::DidUpdateText (const MarkerOwner::UpdateInfo& updateInfo) noexcept
439{
440 if (GetLength () == 0) {
441 AssertNotNull (GetOwner ()->PeekAtTextStore ());
442 GetOwner ()->PeekAtTextStore ()->RemoveMarker (this);
443 Delete (); // calls 'delete this', after doing much other needed cleanup
444 }
445 else {
446 SimpleEmbeddedObjectStyleMarker::DidUpdateText (updateInfo);
447 }
448}
449
450void Led_MFC_ControlItem::PostCreateSpecifyExtraInfo (TWIPS_Point size)
451{
452 // SetExtent (DPtoHIMETRIC (AsSIZE (size)));
453 // Cannot call SetExtent() here. Only after we've called Run () - otherwise exception.
454 // Really I think all my current logic for deadling with sizes of embeddings is questionable. I just don't
455 // understand it very well.
456 //
457 // Probably, all needs to be redone. Anyhow, for now, setting fSize field seems to work pretty well.
458 // LGP 971017
459 fSize = Led_Size (Led_CvtScreenPixelsFromTWIPSV (size.v), Led_CvtScreenPixelsFromTWIPSH (size.h));
460}
461
462SDKString Led_MFC_ControlItem::GetObjClassName () const
463{
464 CLSID clsid;
465 GetClassID (&clsid);
466 LPOLESTR oleStr = NULL;
467 if (::ProgIDFromCLSID (clsid, &oleStr) == S_OK) {
468 SDKString result = SDKString{::CString (oleStr)};
469 ::CoTaskMemFree (oleStr);
470 return result;
471 }
472 return SDKString{};
473}
474
475struct MyOLEStream_output : OLESTREAM {
476 OLESTREAMVTBL theVTbl;
477 vector<char> fData;
478 static DWORD __stdcall MyOLE1STREAMPutter (LPOLESTREAM lpoleStr, const void* data, DWORD nb)
479 {
480 MyOLEStream_output* myStream = (MyOLEStream_output*)lpoleStr;
481 using ci = const char*;
482 myStream->fData.insert (myStream->fData.end (), ci (data), ci (data) + nb);
483 return nb;
484 }
485 MyOLEStream_output ()
486 {
487 lpstbl = &theVTbl;
488 theVTbl.Get = NULL;
489 theVTbl.Put = MyOLE1STREAMPutter;
490 }
491};
492void Led_MFC_ControlItem::DoWriteToOLE1Stream (size_t* nBytes, byte** resultData)
493{
494 IStorage* pStorage = NULL;
495 IPersistStorage* ips = NULL;
496 try {
497 // Create a tmp storage
498 CheckGeneral (::StgCreateDocfile (NULL, STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &pStorage));
499 AssertNotNull (pStorage);
500
501 // Get IPersistStorage interface, and save data to my storage
502 CheckGeneral (m_lpObject->QueryInterface (IID_IPersistStorage, (LPVOID*)&ips));
503 AssertNotNull (ips);
504 CLSID myCLSID;
505 GetClassID (&myCLSID);
506 CheckGeneral (::WriteClassStg (pStorage, myCLSID));
507 DISABLE_COMPILER_MSC_WARNING_START (6011) // safe because ips != null = due to assert on QueryInterface above
508 CheckGeneral (ips->Save (pStorage, false));
509 CheckGeneral (ips->SaveCompleted (pStorage));
510 DISABLE_COMPILER_MSC_WARNING_END (6011) // safe because ips != null = due to assert on QueryInterface above
511
512 // Convert storage into array of bytes
513 MyOLEStream_output myStream;
514 CheckGeneral (::OleConvertIStorageToOLESTREAM (pStorage, &myStream));
515 *nBytes = myStream.fData.size ();
516 *resultData = new byte[*nBytes];
517 (void)::memcpy (*resultData, Traversal::Iterator2Pointer (myStream.fData.begin ()), *nBytes);
518 }
519 catch (...) {
520 if (pStorage != NULL) {
521 pStorage->Release ();
522 }
523 throw;
524 }
525 pStorage->Release ();
526 ips->Release ();
527}
528
529Led_Size Led_MFC_ControlItem::GetSize ()
530{
531 return fSize;
532}
533
534bool Led_MFC_ControlItem::HandleOpen ()
535{
536 (void)DoVerb (OLEIVERB_PRIMARY, NULL); // invoke in-place editing, or whatever the primary verb for the object is...
537 return false; // eat the open command
538}
539
540vector<Led_MFC_ControlItem::PrivateCmdNumber> Led_MFC_ControlItem::GetCmdNumbers () const
541{
542 vector<PrivateCmdNumber> x;
543 x.push_back (eOpenCmdNum);
544 return x;
545}
546
547bool Led_MFC_ControlItem::IsCmdEnabled (PrivateCmdNumber cmd) const
548{
549 switch (cmd) {
550 case eOpenCmdNum:
551 return true;
552 default:
553 return SimpleEmbeddedObjectStyleMarker::IsCmdEnabled (cmd);
554 }
555}
556
557#if qStroika_Foundation_Debug_AssertionsChecked
558COleDocument& Led_MFC_ControlItem::GetDocument () const
559{
560 COleDocument* result = (COleDocument*)COleClientItem::GetDocument ();
561 EnsureNotNull (result);
562 ASSERT_VALID (result);
563 Assert (result->IsKindOf (RUNTIME_CLASS (COleDocument)));
564 return *result;
565}
566
567Led_MFC& Led_MFC_ControlItem::GetActiveView () const
568{
569 EnsureNotNull (COleClientItem::GetActiveView ());
570 AssertMember (COleClientItem::GetActiveView (), Led_MFC);
571 return *(Led_MFC*)COleClientItem::GetActiveView ();
572}
573#endif
574
575/*
576 ********************************************************************************
577 ******************** Led_MFC_ControlItem::DocContextDefiner ********************
578 ********************************************************************************
579 */
580
581set<HWND> Led_MFC_ControlItem::DocContextDefiner::sWindowsWhichHadDisplaySuppressed;
582
583#endif
584#endif
#define AssertNotNull(p)
Definition Assertions.h:333
#define EnsureNotNull(p)
Definition Assertions.h:340
#define RequireNotNull(p)
Definition Assertions.h:347
#define AssertMember(p, c)
Definition Assertions.h:312
#define Verify(c)
Definition Assertions.h:419
Logically halfway between std::array and std::vector; Smart 'direct memory array' - which when needed...
basic_string< SDKChar > SDKString
Definition SDKString.h:38