Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
LedItControlItem.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
5#include "Stroika/Foundation/StroikaPreComp.h"
6
7#include "LedItDocument.h"
8#include "LedItView.h"
9
10#include "LedItControlItem.h"
11
12using namespace Stroika::Foundation;
13using namespace Stroika::Frameworks::Led;
14using namespace Stroika::Frameworks::Led::Platform;
15using namespace Stroika::Frameworks::Led::StyledTextIO;
16
17/*
18 ********************************************************************************
19 ******************************** LedItControlItem ******************************
20 ********************************************************************************
21 */
22IMPLEMENT_SERIAL (LedItControlItem, Led_MFC_ControlItem, 0)
23
24LedItControlItem::LedItControlItem (COleDocument* pContainer)
25 : Led_MFC_ControlItem (pContainer)
26{
27}
28
29SimpleEmbeddedObjectStyleMarker* LedItControlItem::mkLedItControlItemStyleMarker (const char* embeddingTag, const void* data, size_t len)
30{
31 RequireNotNull (DocContextDefiner::GetDoc ()); // See doc in header for class DocContextDefiner.
32 // must declare one of these on call stack before calling this
33 // method...
34 Led_MFC_ControlItem* e = new LedItControlItem (DocContextDefiner::GetDoc ());
35 try {
36 return mkLed_MFC_ControlItemStyleMarker_ (embeddingTag, data, len, e);
37 }
38 catch (...) {
39 delete e;
40 throw;
41 }
42 Assert (false);
43 return NULL; //notreached
44}
45
46SimpleEmbeddedObjectStyleMarker* LedItControlItem::mkLedItControlItemStyleMarker (ReaderFlavorPackage& flavorPackage)
47{
48 RequireNotNull (DocContextDefiner::GetDoc ()); // See doc in header for class DocContextDefiner.
49 // must declare one of these on call stack before calling this
50 // method...
51 Led_MFC_ControlItem* e = new LedItControlItem (DocContextDefiner::GetDoc ());
52 try {
53 return mkLed_MFC_ControlItemStyleMarker_ (flavorPackage, e);
54 }
55 catch (...) {
56 delete e;
57 throw;
58 }
59 Assert (false);
60 return NULL; //notreached
61}
62
63BOOL LedItControlItem::CanActivate ()
64{
65 // Editing in-place while the server itself is being edited in-place
66 // does not work and is not supported. So, disable in-place
67 // activation in this case.
68 LedItDocument& pDoc = GetDocument ();
69 if (pDoc.IsInPlaceActive ()) {
70 return FALSE;
71 }
72
73 // otherwise, rely on default behavior
74 return inherited::CanActivate ();
75}
76
77#if qStroika_Foundation_Debug_AssertionsChecked
78LedItDocument& LedItControlItem::GetDocument () const
79{
80 LedItDocument* result = (LedItDocument*)COleClientItem::GetDocument ();
81 EnsureNotNull (result);
82 ASSERT_VALID (result);
83 ASSERT (result->IsKindOf (RUNTIME_CLASS (LedItDocument)));
84 return *result;
85}
86#endif
#define EnsureNotNull(p)
Definition Assertions.h:340
#define RequireNotNull(p)
Definition Assertions.h:347