home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / STEP16.PAK / STEP16DV.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  16.6 KB  |  756 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1994 by Borland International
  3. //   Tutorial application -- step16dv.cpp
  4. //   Automation Server example
  5. //----------------------------------------------------------------------------
  6. #include <owl/pch.h>
  7. #include <owl/dc.h>
  8. #include <owl/inputdia.h>
  9. #include <owl/chooseco.h>
  10. #include <owl/gdiobjec.h>
  11. #include <owl/docmanag.h>
  12. #include <owl/listbox.h>
  13. #include <owl/controlb.h>
  14. #include <owl/buttonga.h>
  15. #include <classlib/arrays.h>
  16. #include <owl/olemdifr.h>
  17. #include <owl/oledoc.h>
  18. #include <owl/oleview.h>
  19. #include <ocf/automacr.h>
  20. #include <owl/edit.rh>
  21. #include "step16dv.h"
  22. #include "step16.h"
  23. #include "step16dv.rc"
  24.  
  25. BEGIN_REGISTRATION(DocReg)
  26.   REGDATA(progid,     "DrawPad.Drawing.16")
  27.   REGDATA(description,"DrawPad (Step16--AutoServer) Drawing")
  28.   REGDATA(menuname,   "Drawing")
  29.   REGDATA(extension,  "p16")
  30.   REGDATA(docfilter,  "*.p16")
  31.   REGDOCFLAGS(dtAutoOpen | dtAutoDelete | dtUpdateDir | dtCreatePrompt | dtRegisterExt)
  32. //REGDATA(debugger,   "tdw")
  33.   REGDATA(insertable, "")
  34.   REGDATA(verb0,      "&Edit")
  35.   REGDATA(verb1,      "&Open")
  36.   REGFORMAT(0, ocrEmbedSource,  ocrContent,  ocrIStorage,  ocrSet)
  37.   REGFORMAT(1, ocrMetafilePict, ocrContent,  ocrMfPict|ocrStaticMed, ocrGet)
  38. END_REGISTRATION
  39. BEGIN_REGISTRATION(ListReg)
  40.   REGDATA(description,"Line List")
  41.   REGDATA(extension,  "p16")
  42.   REGDATA(docfilter,  "*.p16")
  43.   REGDOCFLAGS(dtAutoDelete | dtHidden)
  44. END_REGISTRATION
  45.  
  46. DEFINE_DOC_TEMPLATE_CLASS(TDrawDocument, TDrawView,       DrawTemplate);
  47. DEFINE_DOC_TEMPLATE_CLASS(TDrawDocument, TDrawListView,   DrawListTemplate);
  48. DrawTemplate drawTpl(DocReg);
  49. DrawListTemplate drawListTpl(ListReg);
  50.  
  51. //===============================  TLine  =====================================
  52. //
  53. void
  54. TLine::SetPen(int penSize)
  55. {
  56.   if (penSize < 1)
  57.     PenSize = 1;
  58.   else
  59.     PenSize = penSize;
  60. }
  61.  
  62. void
  63. TLine::SetPen(const TColor& newColor, int penSize)
  64. {
  65.   // If penSize isn't the default (0), set PenSize to the new size.
  66.   if (penSize)
  67.     PenSize = penSize;
  68.  
  69.   Color = newColor;
  70. }
  71.  
  72. bool
  73. TLine::Draw(TDC& dc) const
  74. {
  75.   // Set pen for the dc to the values for this line
  76.   TPen pen(Color, PenSize, PS_INSIDEFRAME);
  77.   dc.SelectObject(pen);
  78.  
  79.   // Iterates through the points in the line i.
  80.   TPointsIterator j(*this);
  81.   bool first = true;
  82.  
  83.   while (j) {
  84.     TPoint p = j++;
  85.  
  86.     if (!first)
  87.       dc.LineTo(p);
  88.     else {
  89.       dc.MoveTo(p);
  90.       first = false;
  91.     }
  92.   }
  93.   dc.RestorePen();
  94.   return true;
  95. }
  96.  
  97. ostream&
  98. operator <<(ostream& os, const TLine& line)
  99. {
  100.   // Write the number of points in the line
  101.   os << line.GetItemsInContainer();
  102.  
  103.   // Get and write pen attributes.
  104.   os << ' ' << line.Color << ' ' << line.PenSize;
  105.  
  106.   // Get an iterator for the array of points
  107.   TPointsIterator j(line);
  108.  
  109.   // While the iterator is valid (i.e. we haven't run out of points)
  110.   while(j)
  111.     // Write the point from the iterator and increment the array.
  112.     os << j++;
  113.   os << '\n';
  114.  
  115.   // return the stream object
  116.   return os;
  117. }
  118.  
  119. istream&
  120. operator >>(istream& is, TLine& line)
  121. {
  122.   unsigned numPoints;
  123.   is >> numPoints;
  124.  
  125.   COLORREF color;
  126.   int penSize;
  127.   is >> color >> penSize;
  128.   line.SetPen(TColor(color), penSize);
  129.  
  130.   while (numPoints--) {
  131.     TPoint point;
  132.     is >> point;
  133.     line.Add(point);
  134.   }
  135.  
  136.   // return the stream object
  137.   return is;
  138. }
  139.  
  140. DEFINE_AUTOCLASS(TDrawDocument)
  141.   EXPOSE_PROPRW(PenSize,    TAutoShort, "PenSize",    "Current pen size", 0)
  142.   EXPOSE_PROPRW(PenColor,   TAutoLong,  "PenColor",   "Current pen color", 0)
  143.   EXPOSE_METHOD(AddPoint,   TAutoVoid,  "AddPoint",   "Add a point to the current line", 0)
  144.    REQUIRED_ARG(            TAutoShort, "X")
  145.    REQUIRED_ARG(            TAutoShort, "Y")
  146.   EXPOSE_METHOD(AddLine,    TAutoVoid,  "AddLine",    "Add current line into drawing", 0)
  147.   EXPOSE_METHOD(ClearLine,  TAutoVoid,  "ClearLine",  "Erases current line", 0)
  148.   EXPOSE_APPLICATION(       TDrawApp,   "Application","Application object", 0)
  149. END_AUTOCLASS(TDrawDocument, tfNormal,  "TDrawDoc",   "Draw document class", 0)
  150.  
  151. TDrawDocument::TDrawDocument(TDocument* parent)
  152.   : TOleDocument(parent), UndoLine(0), UndoState(UndoNone)
  153. {
  154.   Lines         = new TLines(100, 0, 5);
  155.   AutoPenSize   = 1;
  156.   AutoPenColor  = RGB(0, 0, 0);
  157.   AutoLine      = new TLine(AutoPenColor, AutoPenSize);
  158. }
  159.  
  160. TDrawDocument::~TDrawDocument()
  161. {
  162.   delete AutoLine;
  163.   delete Lines;
  164.   delete UndoLine;
  165. }
  166.  
  167. bool
  168. TDrawDocument::Commit(bool force)
  169. {
  170.   TOleDocument::Commit(force);
  171.  
  172.   TOutStream* os = OutStream(ofWrite);
  173.   if (!os)
  174.     return false;
  175.  
  176.   // Write the number of lines in the figure
  177.   *os << Lines->GetItemsInContainer();
  178.  
  179.   // Append a description using a resource string
  180.   *os << ' ' << FileInfo << '\n';
  181.  
  182.   // Get an iterator for the array of lines
  183.   TLinesIterator i(*Lines);
  184.  
  185.   // While the iterator is valid (i.e. we haven't run out of lines)
  186.   while (i) {
  187.     // Copy the current line from the iterator and increment the array.
  188.     *os << i++;
  189.   }
  190.   delete os;
  191.  
  192.   //
  193.   // Commit the storage if it was opened in transacted mode
  194.   TOleDocument::CommitTransactedStorage();
  195.   SetDirty(false);
  196.  
  197.   return true;
  198. }
  199.  
  200. bool
  201. TDrawDocument::Open(int mode, const char far* path)
  202. {
  203.   char fileinfo[100];
  204.  
  205.   TOleDocument::Open(mode, path);
  206.   if (GetDocPath()) {
  207.     TInStream* is = (TInStream*)InStream(ofRead);
  208.     if (!is)
  209.       return false;
  210.  
  211.     unsigned numLines;
  212.     *is >> numLines;
  213.     is->getline(fileinfo, sizeof(fileinfo));
  214.     while (numLines--) {
  215.       TLine line;
  216.       *is >> line;
  217.       Lines->Add(line);
  218.     }
  219.  
  220.     delete is;
  221.  
  222.     FileInfo = fileinfo;
  223.   } else {
  224.     FileInfo = string(*::Module,IDS_FILEINFO);
  225.   }
  226.   SetDirty(false);
  227.   UndoState = UndoNone;
  228.   return true;
  229. }
  230.  
  231. bool
  232. TDrawDocument::Close()
  233. {
  234.   if (TOleDocument::Close()) {
  235.     Lines->Flush();
  236.     return true;
  237.   }
  238.  
  239.   return false;
  240. }
  241.  
  242. TLine*
  243. TDrawDocument::GetLine(uint index)
  244. {
  245.   return index < Lines->GetItemsInContainer() ? &(*Lines)[index] : 0;
  246. }
  247.  
  248. int
  249. TDrawDocument::AddLine(TLine& line)
  250. {
  251.   int index = Lines->GetItemsInContainer();
  252.   Lines->Add(line);
  253.   SetDirty(true);
  254.   NotifyViews(vnDrawAppend, index);
  255.   UndoState = UndoAppend;
  256.   return index;
  257. }
  258.  
  259. void
  260. TDrawDocument::DeleteLine(uint index)
  261. {
  262.   const TLine* oldLine = GetLine(index);
  263.   if (!oldLine)
  264.     return;
  265.   delete UndoLine;
  266.   UndoLine = new TLine(*oldLine);
  267.   Lines->Detach(index);
  268.   SetDirty(true);
  269.   NotifyViews(vnDrawDelete, index);
  270.   UndoState = UndoDelete;
  271. }
  272.  
  273. void
  274. TDrawDocument::ModifyLine(TLine& line, uint index)
  275. {
  276.   delete UndoLine;
  277.   UndoLine = new TLine((*Lines)[index]);
  278.   SetDirty(true);
  279.   (*Lines)[index] = line;
  280.   NotifyViews(vnDrawModify, index);
  281.   UndoState = UndoModify;
  282.   UndoIndex = index;
  283. }
  284.  
  285. void
  286. TDrawDocument::Clear()
  287. {
  288.   Lines->Flush();
  289.   NotifyViews(vnRevert, true);
  290. }
  291.  
  292. void
  293. TDrawDocument::Undo()
  294. {
  295.   switch (UndoState) {
  296.     case UndoAppend:
  297.       DeleteLine(Lines->GetItemsInContainer()-1);
  298.       return;
  299.     case UndoDelete:
  300.       AddLine(*UndoLine);
  301.       delete UndoLine;
  302.       UndoLine = 0;
  303.       return;
  304.     case UndoModify:
  305.       TLine* temp = UndoLine;
  306.       UndoLine = 0;
  307.       ModifyLine(*temp, UndoIndex);
  308.       delete temp;
  309.   }
  310. }
  311.  
  312. bool
  313. GetPenSize(TWindow* parent, TLine& line)
  314. {
  315.   char inputText[6];
  316.  
  317.   wsprintf(inputText, "%d", line.PenSize);
  318.   if (TInputDialog(parent, "Line Thickness",
  319.                    "Input a new thickness:",
  320.                    inputText,
  321.                    sizeof(inputText)).Execute() != IDOK)
  322.     return false;
  323.   line.PenSize = atoi(inputText);
  324.  
  325.   if (line.PenSize < 1)
  326.     line.PenSize = 1;
  327.  
  328.   return true;
  329. }
  330.  
  331. bool
  332. GetPenColor(TWindow* parent, TLine& line)
  333. {
  334.   TChooseColorDialog::TData colors;
  335.   static TColor custColors[16] =
  336.   {
  337.     0x010101L, 0x101010L, 0x202020L, 0x303030L,
  338.     0x404040L, 0x505050L, 0x606060L, 0x707070L,
  339.     0x808080L, 0x909090L, 0xA0A0A0L, 0xB0B0B0L,
  340.     0xC0C0C0L, 0xD0D0D0L, 0xE0E0E0L, 0xF0F0F0L
  341.   };
  342.  
  343.   colors.Flags = CC_RGBINIT;
  344.   colors.Color = TColor(line.QueryColor());
  345.   colors.CustColors = custColors;
  346.   if (TChooseColorDialog(parent, colors).Execute() != IDOK)
  347.     return false;
  348.   line.SetPen(colors.Color);
  349.   return true;
  350. }
  351.  
  352. DEFINE_RESPONSE_TABLE1(TDrawView, TOleView)
  353.   EV_WM_LBUTTONDOWN,
  354.   EV_WM_MOUSEMOVE,
  355.   EV_WM_LBUTTONUP,
  356.   EV_COMMAND(CM_PENSIZE, CmPenSize),
  357.   EV_COMMAND(CM_PENCOLOR, CmPenColor),
  358.   EV_COMMAND(CM_EDITCLEAR, CmClear),
  359.   EV_COMMAND(CM_EDITUNDO, CmUndo),
  360.   EV_VN_COMMIT,
  361.   EV_VN_REVERT,
  362.   EV_VN_DRAWAPPEND,
  363.   EV_VN_DRAWDELETE,
  364.   EV_VN_DRAWMODIFY,
  365.   EV_OC_VIEWPARTSIZE,
  366.   EV_OC_VIEWSHOWTOOLS,
  367. END_RESPONSE_TABLE;
  368.  
  369. TDrawView::TDrawView(TDrawDocument& doc, TWindow* parent)
  370. :
  371.   TOleView(doc, parent), DrawDoc(&doc)
  372. {
  373.   Line      = new TLine(TColor::Black, 1);
  374.   Attr.AccelTable = IDA_DRAWVIEW;
  375.   SetViewMenu(new TMenuDescr(IDM_DRAWVIEW));
  376.   ToolBar = 0;
  377. }
  378.  
  379. //
  380. // Let container know about the server view size in pixels
  381. //
  382. bool
  383. TDrawView::EvOcViewPartSize(TOcPartSize far& ps)
  384. {
  385.   TClientDC dc(*this);
  386.  
  387.   TRect rect(0, 0, 0, 0);
  388.   // a 2" x 2" extent for server
  389.   //
  390.   rect.right  = dc.GetDeviceCaps(LOGPIXELSX) * 2;
  391.   rect.bottom = dc.GetDeviceCaps(LOGPIXELSY) * 2;
  392.  
  393.   ps.PartRect = rect;
  394.   return true;
  395. }
  396.  
  397. bool
  398. TDrawView::EvOcViewShowTools(TOcToolBarInfo far& tbi)
  399. {
  400.   // Construct & create a control bar for show, destroy our bar for hide
  401.   //
  402.   if (tbi.Show) {
  403.     if (!ToolBar) {
  404.       ToolBar = new TControlBar(this);
  405.       ToolBar->Insert(*new TButtonGadget(CM_PENSIZE, CM_PENSIZE, TButtonGadget::Command));
  406.       ToolBar->Insert(*new TButtonGadget(CM_PENCOLOR, CM_PENCOLOR, TButtonGadget::Command));
  407.       ToolBar->Insert(*new TSeparatorGadget);
  408.       ToolBar->Insert(*new TButtonGadget(CM_ABOUT, CM_ABOUT, TButtonGadget::Command));
  409.       ToolBar->SetHintMode(TGadgetWindow::EnterHints);
  410.     }
  411.     ToolBar->Create();
  412.     tbi.HTopTB = (HWND)*ToolBar;
  413.   }
  414.   else {
  415.     if (ToolBar) {
  416.       ToolBar->Destroy();
  417.       delete ToolBar;
  418.       ToolBar = 0;
  419.     }
  420.   }
  421.   return true;
  422. }
  423.  
  424. void
  425. TDrawView::EvLButtonDown(uint modKeys, TPoint& point)
  426. {
  427.   TOleView::EvLButtonDown(modKeys, point);
  428.  
  429.   if (DragDC) {
  430.     SetCapture();
  431.     Pen = new TPen(Line->QueryColor(), Line->QueryPenSize());
  432.     DragDC->SelectObject(*Pen);
  433.     DragDC->MoveTo(point);
  434.     Line->Add(point);
  435.   }
  436. }
  437.  
  438. void
  439. TDrawView::EvMouseMove(uint modKeys, TPoint& point)
  440. {
  441.   TOleView::EvMouseMove(modKeys, point);
  442.  
  443.   if (DragDC) {
  444.     DragDC->LineTo(point);
  445.     Line->Add(point);
  446.   }
  447. }
  448.  
  449. void
  450. TDrawView::EvLButtonUp(uint modKeys, TPoint& point)
  451. {
  452.   if (DragDC) {
  453.     ReleaseCapture();
  454.     if (Line->GetItemsInContainer() > 1)
  455.       DrawDoc->AddLine(*Line);
  456.     Line->Flush();
  457.     delete Pen;
  458.   }
  459.  
  460.   TOleView::EvLButtonUp(modKeys, point);
  461. }
  462.  
  463. void
  464. TDrawView::CmPenSize()
  465. {
  466.   GetPenSize(this, *Line);
  467. }
  468.  
  469. void
  470. TDrawView::CmPenColor()
  471. {
  472.   GetPenColor(this, *Line);
  473. }
  474.  
  475. void
  476. TDrawView::CmClear()
  477. {
  478.   DrawDoc->Clear();
  479. }
  480.  
  481. void
  482. TDrawView::CmUndo()
  483. {
  484.   DrawDoc->Undo();
  485. }
  486.  
  487. //
  488. // Paint into the window dc
  489. //
  490. void
  491. TDrawView::Paint(TDC& dc, bool /*erase*/, TRect& /*rect*/)
  492. {
  493.   // Iterates through the array of line objects.
  494.   int j = 0;
  495.   TLine* line;
  496.   while ((line = const_cast<TLine *>(DrawDoc->GetLine(j++))) != 0)
  497.     line->Draw(dc);
  498. }
  499.  
  500. bool
  501. TDrawView::VnCommit(bool /*force*/)
  502. {
  503.   // nothing to do here, no data held in view
  504.   return true;
  505. }
  506.  
  507. bool
  508. TDrawView::VnRevert(bool /*clear*/)
  509. {
  510.   Invalidate();  // force full repaint
  511.   InvalidatePart(invView); // OC server change
  512.   return true;
  513. }
  514.  
  515. bool
  516. TDrawView::VnAppend(uint index)
  517. {
  518.   TClientDC dc(*this);
  519.   const TLine* line = DrawDoc->GetLine(index);
  520.   bool metafile = dc.GetDeviceCaps(TECHNOLOGY) == DT_METAFILE;
  521.   SetupDC(dc, !metafile);
  522.   line->Draw(dc);
  523.   InvalidatePart(invView);
  524.   return true;
  525. }
  526.  
  527. bool
  528. TDrawView::VnModify(uint /*index*/)
  529. {
  530.   Invalidate();  // force full repaint
  531.   InvalidatePart(invView); // OC server change
  532.   return true;
  533. }
  534.  
  535. bool
  536. TDrawView::VnDelete(uint /*index*/)
  537. {
  538.   Invalidate();  // force full repaint
  539.   InvalidatePart(invView); // OC server change
  540.   return true;
  541. }
  542.  
  543. DEFINE_RESPONSE_TABLE1(TDrawListView, TListBox)
  544.   EV_COMMAND(CM_PENSIZE, CmPenSize),
  545.   EV_COMMAND(CM_PENCOLOR, CmPenColor),
  546.   EV_COMMAND(CM_EDITCLEAR, CmClear),
  547.   EV_COMMAND(CM_EDITUNDO, CmUndo),
  548.   EV_COMMAND(CM_EDITDELETE, CmDelete),
  549.   EV_VN_ISWINDOW,
  550.   EV_VN_COMMIT,
  551.   EV_VN_REVERT,
  552.   EV_VN_DRAWAPPEND,
  553.   EV_VN_DRAWDELETE,
  554.   EV_VN_DRAWMODIFY,
  555. END_RESPONSE_TABLE;
  556.  
  557. TDrawListView::TDrawListView(TDrawDocument& doc,TWindow* parent)
  558.        : TView(doc), TListBox(parent, GetNextViewId(), 0,0,0,0), DrawDoc(&doc)
  559. {
  560.   Attr.Style &= ~(WS_BORDER | LBS_SORT);
  561.   Attr.Style |= LBS_NOINTEGRALHEIGHT;
  562.   Attr.AccelTable = IDA_DRAWLISTVIEW;
  563.   SetViewMenu(new TMenuDescr(IDM_DRAWLISTVIEW));
  564. }
  565.  
  566. bool
  567. TDrawListView::CanClose()
  568. {
  569.   TView* curView = Doc->GetViewList();
  570.   while (curView) {
  571.     if (curView != this)
  572.       return true;
  573.  
  574.     curView = curView->GetNextView();
  575.   }
  576.  
  577.   return Doc->CanClose();
  578. }
  579.  
  580. bool
  581. TDrawListView::Create()
  582. {
  583.   TListBox::Create();
  584.   LoadData();
  585.   return true;
  586. }
  587.  
  588. void
  589. TDrawListView::LoadData()
  590. {
  591.   ClearList();
  592.   int i = 0;
  593.   const TLine* line;
  594.   while ((line = DrawDoc->GetLine(i)) != 0)
  595.     FormatData(line, i++);
  596.  
  597.   SetSelIndex(0);
  598. }
  599.  
  600. void
  601. TDrawListView::FormatData(const TLine* line, int unsigned index)
  602. {
  603.   char buf[80];
  604.   TColor color(line->QueryColor());
  605.   wsprintf(buf, "Color = R%d G%d B%d, Size = %d, Points = %d",
  606.            color.Red(), color.Green(), color.Blue(),
  607.            line->QueryPenSize(), line->GetItemsInContainer());
  608.   DeleteString(index);
  609.   InsertString(buf, index);
  610.   SetSelIndex(index);
  611. }
  612.  
  613. void
  614. TDrawListView::CmPenSize()
  615. {
  616.   int index = GetSelIndex();
  617.   const TLine* line = DrawDoc->GetLine(index);
  618.   if (line) {
  619.     TLine* newline = new TLine(*line);
  620.     if (GetPenSize(this, *newline))
  621.       DrawDoc->ModifyLine(*newline, index);
  622.     delete newline;
  623.   }
  624. }
  625.  
  626. void
  627. TDrawListView::CmPenColor()
  628. {
  629.   int index = GetSelIndex();
  630.   const TLine* line = DrawDoc->GetLine(index);
  631.   if (line) {
  632.     TLine* newline = new TLine(*line);
  633.     if (GetPenColor(this, *newline))
  634.       DrawDoc->ModifyLine(*newline, index);
  635.     delete newline;
  636.   }
  637. }
  638.  
  639. void
  640. TDrawListView::CmClear()
  641. {
  642.   DrawDoc->Clear();
  643. }
  644.  
  645. void
  646. TDrawListView::CmUndo()
  647. {
  648.   DrawDoc->Undo();
  649. }
  650.  
  651. void
  652. TDrawListView::CmDelete()
  653. {
  654.   DrawDoc->DeleteLine(GetSelIndex());
  655. }
  656.  
  657. bool
  658. TDrawListView::VnCommit(bool /*force*/)
  659. {
  660.   return true;
  661. }
  662.  
  663. bool
  664. TDrawListView::VnRevert(bool /*clear*/)
  665. {
  666.   LoadData();
  667.   return true;
  668. }
  669.  
  670. bool
  671. TDrawListView::VnAppend(uint index)
  672. {
  673.   const TLine* line = DrawDoc->GetLine(index);
  674.   FormatData(line, index);
  675.   SetSelIndex(index);
  676.   return true;
  677. }
  678.  
  679. bool
  680. TDrawListView::VnDelete(uint index)
  681. {
  682.   DeleteString(index);
  683.   HandleMessage(WM_KEYDOWN,VK_DOWN); // force selection
  684.   return true;
  685. }
  686.  
  687. bool
  688. TDrawListView::VnModify(uint index)
  689. {
  690.   const TLine* line = DrawDoc->GetLine(index);
  691.   FormatData(line, index);
  692.   return true;
  693. }
  694.  
  695. static char* PropNames[] = {
  696.   "Line Count",      // LineCount
  697.   "Description",       // Description
  698. };
  699.  
  700. static int PropFlags[] = {
  701.   pfGetBinary|pfGetText, // LineCount
  702.   pfGetText,             // Description
  703. };
  704.  
  705. const char*
  706. TDrawDocument::PropertyName(int index)
  707. {
  708.   if (index <= PrevProperty)
  709.     return TStorageDocument::PropertyName(index);  // OC server change
  710.   else if (index < NextProperty)
  711.     return PropNames[index-PrevProperty-1];
  712.   else
  713.     return 0;
  714. }
  715.  
  716. int
  717. TDrawDocument::PropertyFlags(int index)
  718. {
  719.   if (index <= PrevProperty)
  720.     return TStorageDocument::PropertyFlags(index); // OC server change
  721.   else if (index < NextProperty)
  722.     return PropFlags[index-PrevProperty-1];
  723.   else
  724.     return 0;
  725. }
  726.  
  727. int
  728. TDrawDocument::FindProperty(const char far* name)
  729. {
  730.   for (int i=0; i < NextProperty-PrevProperty-1; i++)
  731.     if (strcmp(PropNames[i], name) == 0)
  732.       return i+PrevProperty+1;
  733.   return 0;
  734. }
  735.  
  736. int
  737. TDrawDocument::GetProperty(int prop, void far* dest, int textlen)
  738. {
  739.   switch(prop) {
  740.     case LineCount: {
  741.       int count = Lines->GetItemsInContainer();
  742.       if (!textlen) {
  743.         *(int far*)dest = count;
  744.         return sizeof(int);
  745.       }
  746.       return wsprintf((char far*)dest, "%d", count);
  747.     }
  748.     case Description:
  749.       char* temp = new char[textlen]; // need local copy for medium model
  750.       int len = FileInfo.copy(temp, textlen);
  751.       strcpy((char far*)dest, temp);
  752.       return len;
  753.   }
  754.   return TStorageDocument::GetProperty(prop, dest, textlen); // OC server change
  755. }
  756.