xref: /aoo42x/main/shell/inc/internal/thumbviewer.hxx (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 #ifndef THUMBVIEWER_HXX_INCLUDED
29 #define THUMBVIEWER_HXX_INCLUDED
30 
31 #if defined _MSC_VER
32 #pragma warning(push, 1)
33 #pragma warning(disable:4917)
34 #endif
35 #include <objidl.h>
36 #include <shlobj.h>
37 #ifdef __MINGW32__
38 #include <algorithm>
39 using std::min;
40 using std::max;
41 #endif
42 #include <gdiplus.h>
43 #if defined _MSC_VER
44 #pragma warning(pop)
45 #endif
46 #include <string>
47 
48 class CThumbviewer : public IPersistFile, public IExtractImage
49 {
50 public:
51 	CThumbviewer(long RefCnt = 1);
52 	virtual ~CThumbviewer();
53 
54 	//-----------------------------
55 	// IUnknown methods
56 	//-----------------------------
57 
58 	virtual HRESULT STDMETHODCALLTYPE QueryInterface(
59             REFIID riid,
60             void __RPC_FAR *__RPC_FAR *ppvObject);
61 
62     virtual ULONG STDMETHODCALLTYPE AddRef( void);
63 
64     virtual ULONG STDMETHODCALLTYPE Release( void);
65 
66 	//----------------------------
67 	// IExtractImage methods
68 	//----------------------------
69 
70 	virtual HRESULT STDMETHODCALLTYPE Extract(HBITMAP *phBmpImage);
71 
72     virtual HRESULT STDMETHODCALLTYPE GetLocation(
73         LPWSTR pszPathBuffer,
74         DWORD cchMax,
75         DWORD *pdwPriority,
76         const SIZE *prgSize,
77         DWORD dwRecClrDepth,
78         DWORD *pdwFlags);
79 
80 	//----------------------------
81 	// IPersist methods
82 	//----------------------------
83 
84 	virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID* pClassID);
85 
86 	//----------------------------
87 	// IPersistFile methods
88 	//----------------------------
89 
90 	virtual HRESULT STDMETHODCALLTYPE IsDirty();
91 
92     virtual HRESULT STDMETHODCALLTYPE Load(
93             /* [in] */ LPCOLESTR pszFileName,
94             /* [in] */ DWORD dwMode);
95 
96     virtual HRESULT STDMETHODCALLTYPE Save(
97             /* [unique][in] */ LPCOLESTR pszFileName,
98             /* [in] */ BOOL fRemember);
99 
100     virtual HRESULT STDMETHODCALLTYPE SaveCompleted(
101             /* [unique][in] */ LPCOLESTR pszFileName);
102 
103     virtual HRESULT STDMETHODCALLTYPE GetCurFile(
104             /* [out] */ LPOLESTR __RPC_FAR *ppszFileName);
105 
106 private:
107     Gdiplus::Rect CalcScaledAspectRatio(Gdiplus::Rect src, Gdiplus::Rect dest);
108 
109 private:
110 	long		 ref_count_;
111 	std::wstring filename_;
112 	SIZE         thumbnail_size_;
113 	DWORD        color_depth_;
114 	ULONG_PTR    gdiplus_token_;
115 	Gdiplus::Bitmap* signet_;
116 };
117 
118 #endif
119