Avoid potential negative array index access to cached text.
[LibreOffice.git] / embedserv / source / embed / iipaobj.cxx
blob008a33f11925ae5fe4af1ab9e10369676ad92191
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <iipaobj.hxx>
21 #include <embeddoc.hxx>
24 CIIAObj::CIIAObj(DocumentHolder* pDocHolder)
25 : m_refCount( 0 ),
26 m_rDocHolder( pDocHolder )
31 CIIAObj::~CIIAObj()
33 return;
36 /* IUnknown methods */
38 STDMETHODIMP CIIAObj::QueryInterface(REFIID riid, LPVOID* ppv)
40 *ppv=nullptr;
42 if(IID_IUnknown==riid ||
43 IID_IOleWindow==riid ||
44 IID_IOleInPlaceActiveObject==riid)
45 *ppv=this;
47 //AddRef any interface we'll return.
48 if (nullptr!=*ppv)
50 static_cast<LPUNKNOWN>(*ppv)->AddRef();
51 return NOERROR;
54 return ResultFromScode(E_NOINTERFACE);
58 STDMETHODIMP_(ULONG) CIIAObj::AddRef()
60 return osl_atomic_increment( &m_refCount);
63 STDMETHODIMP_(ULONG) CIIAObj::Release()
65 sal_Int32 nCount = osl_atomic_decrement( &m_refCount);
66 if ( nCount == 0 )
67 delete this;
69 return nCount;
72 /* IOleInPlaceActiveObject methods*/
74 STDMETHODIMP CIIAObj::GetWindow(HWND *)
76 return NOERROR;
79 STDMETHODIMP CIIAObj::ContextSensitiveHelp(BOOL)
81 return NOERROR;
84 STDMETHODIMP CIIAObj::TranslateAccelerator(LPMSG)
86 return NOERROR;
89 STDMETHODIMP CIIAObj::OnFrameWindowActivate(BOOL)
91 return NOERROR;
94 STDMETHODIMP CIIAObj::OnDocWindowActivate(BOOL)
96 return NOERROR;
99 STDMETHODIMP CIIAObj::ResizeBorder(
100 LPCRECT pRect,LPOLEINPLACEUIWINDOW,BOOL bFrame)
102 if(!bFrame) return NOERROR;
104 if ( !m_rDocHolder.is() )
105 return E_FAIL;
107 return m_rDocHolder->SetContRects(pRect);
111 STDMETHODIMP CIIAObj::EnableModeless(BOOL)
113 return NOERROR;
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */