xref: /aoo41x/main/embedserv/source/embed/iipaobj.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "iipaobj.hxx"
29 #include "embeddoc.hxx"
30 
31 
32 
33 CIIAObj::CIIAObj(DocumentHolder* pDocHolder)
34 	: m_refCount( 0L ),
35       m_rDocHolder( pDocHolder )
36 {
37 }
38 
39 
40 CIIAObj::~CIIAObj()
41 {
42     return;
43 }
44 
45 /* IUnknown methods */
46 
47 STDMETHODIMP CIIAObj::QueryInterface(REFIID riid, LPVOID FAR *ppv)
48 {
49     *ppv=NULL;
50 
51     if(IID_IUnknown==riid ||
52 	   IID_IOleWindow==riid ||
53 	   IID_IOleInPlaceActiveObject==riid)
54         *ppv=this;
55 
56     //AddRef any interface we'll return.
57     if (NULL!=*ppv)
58 	{
59         ((LPUNKNOWN)*ppv)->AddRef();
60         return NOERROR;
61 	}
62 
63     return ResultFromScode(E_NOINTERFACE);
64 }
65 
66 
67 STDMETHODIMP_(ULONG) CIIAObj::AddRef(void)
68 {
69 	return osl_incrementInterlockedCount( &m_refCount);
70 }
71 
72 STDMETHODIMP_(ULONG) CIIAObj::Release(void)
73 {
74 	sal_Int32 nCount = osl_decrementInterlockedCount( &m_refCount);
75 	if ( nCount == 0 )
76 		delete this;
77 
78 	return nCount;
79 }
80 
81 /* IOleInPlaceActiveObject methods*/
82 
83 STDMETHODIMP CIIAObj::GetWindow(HWND *)
84 {
85 	return NOERROR;
86 }
87 
88 STDMETHODIMP CIIAObj::ContextSensitiveHelp(BOOL)
89 {
90 	return NOERROR;
91 }
92 
93 STDMETHODIMP CIIAObj::TranslateAccelerator(LPMSG)
94 {
95 	return NOERROR;
96 }
97 
98 STDMETHODIMP CIIAObj::OnFrameWindowActivate(BOOL)
99 {
100 	return NOERROR;
101 }
102 
103 STDMETHODIMP CIIAObj::OnDocWindowActivate(BOOL)
104 {
105 	return NOERROR;
106 }
107 
108 STDMETHODIMP CIIAObj::ResizeBorder(
109 	LPCRECT pRect,LPOLEINPLACEUIWINDOW,BOOL bFrame)
110 {
111     if(!bFrame) return NOERROR;
112 
113 	if ( !m_rDocHolder.is() )
114 		return E_FAIL;
115 
116     return m_rDocHolder->SetContRects(pRect);
117 }
118 
119 
120 STDMETHODIMP CIIAObj::EnableModeless(BOOL)
121 {
122 	return NOERROR;
123 }
124 
125 // Fix strange warnings about some
126 // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
127 // warning C4505: 'xxx' : unreferenced local function has been removed
128 #if defined(_MSC_VER)
129 #pragma warning(disable: 4505)
130 #endif
131