1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "iipaobj.hxx"
25 #include "embeddoc.hxx"
26 
27 
28 
CIIAObj(DocumentHolder * pDocHolder)29 CIIAObj::CIIAObj(DocumentHolder* pDocHolder)
30 	: m_refCount( 0L ),
31       m_rDocHolder( pDocHolder )
32 {
33 }
34 
35 
~CIIAObj()36 CIIAObj::~CIIAObj()
37 {
38     return;
39 }
40 
41 /* IUnknown methods */
42 
QueryInterface(REFIID riid,LPVOID FAR * ppv)43 STDMETHODIMP CIIAObj::QueryInterface(REFIID riid, LPVOID FAR *ppv)
44 {
45     *ppv=NULL;
46 
47     if(IID_IUnknown==riid ||
48 	   IID_IOleWindow==riid ||
49 	   IID_IOleInPlaceActiveObject==riid)
50         *ppv=this;
51 
52     //AddRef any interface we'll return.
53     if (NULL!=*ppv)
54 	{
55         ((LPUNKNOWN)*ppv)->AddRef();
56         return NOERROR;
57 	}
58 
59     return ResultFromScode(E_NOINTERFACE);
60 }
61 
62 
STDMETHODIMP_(ULONG)63 STDMETHODIMP_(ULONG) CIIAObj::AddRef(void)
64 {
65 	return osl_incrementInterlockedCount( &m_refCount);
66 }
67 
STDMETHODIMP_(ULONG)68 STDMETHODIMP_(ULONG) CIIAObj::Release(void)
69 {
70 	sal_Int32 nCount = osl_decrementInterlockedCount( &m_refCount);
71 	if ( nCount == 0 )
72 		delete this;
73 
74 	return nCount;
75 }
76 
77 /* IOleInPlaceActiveObject methods*/
78 
GetWindow(HWND *)79 STDMETHODIMP CIIAObj::GetWindow(HWND *)
80 {
81 	return NOERROR;
82 }
83 
ContextSensitiveHelp(BOOL)84 STDMETHODIMP CIIAObj::ContextSensitiveHelp(BOOL)
85 {
86 	return NOERROR;
87 }
88 
TranslateAccelerator(LPMSG)89 STDMETHODIMP CIIAObj::TranslateAccelerator(LPMSG)
90 {
91 	return NOERROR;
92 }
93 
OnFrameWindowActivate(BOOL)94 STDMETHODIMP CIIAObj::OnFrameWindowActivate(BOOL)
95 {
96 	return NOERROR;
97 }
98 
OnDocWindowActivate(BOOL)99 STDMETHODIMP CIIAObj::OnDocWindowActivate(BOOL)
100 {
101 	return NOERROR;
102 }
103 
ResizeBorder(LPCRECT pRect,LPOLEINPLACEUIWINDOW,BOOL bFrame)104 STDMETHODIMP CIIAObj::ResizeBorder(
105 	LPCRECT pRect,LPOLEINPLACEUIWINDOW,BOOL bFrame)
106 {
107     if(!bFrame) return NOERROR;
108 
109 	if ( !m_rDocHolder.is() )
110 		return E_FAIL;
111 
112     return m_rDocHolder->SetContRects(pRect);
113 }
114 
115 
EnableModeless(BOOL)116 STDMETHODIMP CIIAObj::EnableModeless(BOOL)
117 {
118 	return NOERROR;
119 }
120 
121 // Fix strange warnings about some
122 // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
123 // warning C4505: 'xxx' : unreferenced local function has been removed
124 #if defined(_MSC_VER)
125 #pragma warning(disable: 4505)
126 #endif
127