merge the formfield patch from ooo-build
[ooovba.git] / fpicker / source / win32 / filepicker / dibpreview.hxx
blob8e018050ca7968c2a70f1e7930a680f80987cf9a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dibpreview.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DIBPREVIEW_HXX_
32 #define _DIBPREVIEW_HXX_
34 //------------------------------------------------------------------------
35 // includes
36 //------------------------------------------------------------------------
38 #include "previewbase.hxx"
39 #include <osl/mutex.hxx>
41 #if defined _MSC_VER
42 #pragma warning(push, 1)
43 #endif
44 #include <windows.h>
45 #if defined _MSC_VER
46 #pragma warning(pop)
47 #endif
49 //---------------------------------------------
50 // A very simple wrapper for a window that does
51 // display DIBs.
52 // Maybe it would be better and more extensible
53 // to create another class that is responsible
54 // for rendering a specific image format into
55 // the area of the window, but for our purpose
56 // it's enough to go the simple way - KISS.
57 //---------------------------------------------
59 class CDIBPreview : public PreviewBase
61 public:
63 // ctor
64 CDIBPreview(HINSTANCE instance,HWND parent,sal_Bool bShowWindow = sal_False);
66 // dtor
67 virtual ~CDIBPreview( );
69 // preview interface implementation
71 virtual sal_Int32 SAL_CALL getTargetColorDepth()
72 throw (::com::sun::star::uno::RuntimeException);
74 virtual sal_Int32 SAL_CALL getAvailableWidth()
75 throw (::com::sun::star::uno::RuntimeException);
77 virtual sal_Int32 SAL_CALL getAvailableHeight()
78 throw (::com::sun::star::uno::RuntimeException);
80 virtual void SAL_CALL setImage(sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage)
81 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
83 virtual sal_Bool SAL_CALL setShowState(sal_Bool bShowState)
84 throw (::com::sun::star::uno::RuntimeException);
86 virtual sal_Bool SAL_CALL getShowState()
87 throw (::com::sun::star::uno::RuntimeException);
89 virtual HWND SAL_CALL getWindowHandle() const;
91 private:
92 virtual void SAL_CALL onPaint( HWND hWnd, HDC hDC );
94 ATOM SAL_CALL RegisterDibPreviewWindowClass( );
95 void SAL_CALL UnregisterDibPreviewWindowClass( );
97 static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
99 private:
100 HINSTANCE m_Instance;
101 HWND m_Hwnd;
102 com::sun::star::uno::Sequence<sal_Int8> m_Image;
103 osl::Mutex m_PaintLock;
105 // the preview window class has to be registered only
106 // once per process, so multiple instance of this class
107 // share the registered window class
108 static ATOM s_ClassAtom;
109 static osl::Mutex s_Mutex;
110 static sal_Int32 s_RegisterDibPreviewWndCount;
112 // prevent copy and assignment
113 private:
114 CDIBPreview(const CDIBPreview&);
115 CDIBPreview& operator=(const CDIBPreview&);
119 #endif