home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / WTJ9403.ZIP / OTEXT / SRVRITEM.CPP < prev    next >
C/C++ Source or Header  |  1994-01-01  |  3KB  |  107 lines

  1. // srvritem.cpp : implementation of the COTextSrvrItem class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "otext.h"
  6.  
  7. #include "otextdoc.h"
  8. #include "srvritem.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // COTextSrvrItem implementation
  17.  
  18. IMPLEMENT_DYNAMIC(COTextSrvrItem, COleServerItem)
  19.  
  20. COTextSrvrItem::COTextSrvrItem(COTextDoc* pContainerDoc)
  21.     : COleServerItem(pContainerDoc, TRUE)
  22. {
  23.     // TODO: add one-time construction code here
  24.     //  (eg, adding additional clipboard formats to the item's data source)
  25. }
  26.  
  27. COTextSrvrItem::~COTextSrvrItem()
  28. {
  29.     // TODO: add cleanup code here
  30. }
  31.  
  32. void COTextSrvrItem::Serialize(CArchive& ar)
  33. {
  34.     // COTextSrvrItem::Serialize will be called by the framework if
  35.     //  the item is copied to the clipboard.  This can happen automatically
  36.     //  through the OLE callback OnGetClipboardData.  A good default for
  37.     //  the embedded item is simply to delegate to the document's Serialize
  38.     //  function.  If you support links, then you will want to serialize
  39.     //  just a portion of the document.
  40.  
  41.     if (!IsLinkedItem())
  42.     {
  43.         COTextDoc* pDoc = GetDocument();
  44.         ASSERT_VALID(pDoc);
  45.         pDoc->Serialize(ar);
  46.     }
  47. }
  48.  
  49. BOOL COTextSrvrItem::OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize)
  50. {
  51.     // Most applications, like this one, only handle drawing the content
  52.     //  aspect of the item.  If you wish to support other aspects, such
  53.     //  as DVASPECT_THUMBNAIL (by overriding OnDrawEx), then this
  54.     //  implementation of OnGetExtent should be modified to handle the
  55.     //  additional aspect(s).
  56.  
  57.     if (dwDrawAspect != DVASPECT_CONTENT)
  58.         return COleServerItem::OnGetExtent(dwDrawAspect, rSize);
  59.  
  60.     // COTextSrvrItem::OnGetExtent is called to get the extent in
  61.     //  HIMETRIC units of the entire item.  The default implementation
  62.     //  here simply returns a hard-coded number of units.
  63.  
  64.     COTextDoc* pDoc = GetDocument();
  65.     ASSERT_VALID(pDoc);
  66.  
  67.     // TODO: replace this arbitrary size
  68.  
  69.     rSize = CSize(3000, 3000);   // 3000 x 3000 HIMETRIC units
  70.  
  71.     return TRUE;
  72. }
  73.  
  74. BOOL COTextSrvrItem::OnDraw(CDC* pDC, CSize& rSize)
  75. {
  76.     COTextDoc* pDoc = GetDocument();
  77.     ASSERT_VALID(pDoc);
  78.  
  79.     // TODO: set mapping mode and extent
  80.     //  (The extent is usually the same as the size returned from OnGetExtent)
  81.     pDC->SetMapMode(MM_ANISOTROPIC);
  82.     pDC->SetWindowOrg(0,0);
  83.     pDC->SetWindowExt(3000, 3000);
  84.  
  85.     // TODO: add drawing code here.  Optionally, fill in the HIMETRIC extent.
  86.     //  All drawing takes place in the metafile device context (pDC).
  87.  
  88.     return TRUE;
  89. }
  90.  
  91. /////////////////////////////////////////////////////////////////////////////
  92. // COTextSrvrItem diagnostics
  93.  
  94. #ifdef _DEBUG
  95. void COTextSrvrItem::AssertValid() const
  96. {
  97.     COleServerItem::AssertValid();
  98. }
  99.  
  100. void COTextSrvrItem::Dump(CDumpContext& dc) const
  101. {
  102.     COleServerItem::Dump(dc);
  103. }
  104. #endif
  105.  
  106. /////////////////////////////////////////////////////////////////////////////
  107.