summaryrefslogtreecommitdiff
path: root/iup/srcole/tOleClientSite.cpp
blob: 314b17262a8419b17061ef7d264cdd1353cb1d3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//////////////////////////////////////////////////////////////////////
//
// tOleClientSite.cpp: implementation of the tOleClientSite class.
//
//////////////////////////////////////////////////////////////////////


#include <windows.h>
#include <assert.h>

#include "tOleClientSite.h"
#include "tOleHandler.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

tOleClientSite::tOleClientSite(LPUNKNOWN pUnkOuter,
                               tOleHandler *olehandler)
{
  m_cRef=0;
  m_pUnkOuter = pUnkOuter;
  handler = olehandler;
  return;
}

tOleClientSite::~tOleClientSite()
{

}

STDMETHODIMP tOleClientSite::QueryInterface(REFIID riid,
                                            LPVOID *ppv)
{
  return m_pUnkOuter->QueryInterface(riid, ppv);
}


STDMETHODIMP_(ULONG) tOleClientSite::AddRef(void)
{
  ++m_cRef;
  return m_pUnkOuter->AddRef();
}

STDMETHODIMP_(ULONG) tOleClientSite::Release(void)
{
  --m_cRef;
  return m_pUnkOuter->Release();
}

STDMETHODIMP tOleClientSite::SaveObject(void)
{
  // persistencia ainda nao suportada
  return E_FAIL;
}


STDMETHODIMP tOleClientSite::GetMoniker(DWORD dwAssign,
                                        DWORD dwWhich,
                                        LPMONIKER *ppmk)
{
  // Linking nao suportado
  return E_FAIL;
}


STDMETHODIMP tOleClientSite::GetContainer(LPOLECONTAINER * ppContainer)
{

  *ppContainer=NULL;

  return E_NOINTERFACE;
}


/*
 * tOleClientSite::ShowObject
 *
 * Purpose:
 *  Tells the container to bring the object fully into view as much
 *  as possible, that is, scroll the document.
 *
 * Parameters:
 *  None
 *
 * Return Value:
 *  HRESULT         Standard.
 */

STDMETHODIMP tOleClientSite::ShowObject(void)
{
  return NOERROR;
}


STDMETHODIMP tOleClientSite::OnShowWindow(BOOL fShow)
{
  return NOERROR;
}

/*
 * tOleClientSite::RequestNewObjectLayout
 *
 * Purpose:
 *  Called when the object would like to have its layout
 *  reinitialized.  This is used by OLE Controls.
 *
 * Parameters:
 *  None
 *
 * Return Value:
 *  HRESULT         Standard.
 */

STDMETHODIMP tOleClientSite::RequestNewObjectLayout(void)
{
  RECT    rc, rcT;
  SIZEL   szl;
  HRESULT hr;

  /*
   * This function is called by a control that is not in-place
   * active or UI active and therefore doesn't have our
   * IOleInPlaceSite interface in which to call OnPosRectChange.
   * Therefore we do pretty much the same thing we do in that
   * function although we ask the control for the size it wants.
   */

  if (!handler->m_pIViewObject2)
    return E_FAIL;

  //Get the size from the control
  hr=handler->m_pIViewObject2->GetExtent(handler->m_fe.dwAspect, -1, NULL, &szl);
  if (FAILED(hr))
    return hr;

  //Add these extents to the existing tenant position.
  SetRect(&rcT, 0, 0, szl.cx*10, -szl.cy*10);
  RectConvertMappings(&rcT, NULL, TRUE);

  rc=handler->m_rcPos;
  rc.right=rc.left+rcT.right;
  rc.bottom=rc.top+rcT.bottom;

  handler->UpdateInPlaceObjectRects(&rc, FALSE);
  return NOERROR;
}