1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _DIBPREVIEW_HXX_
29 #define _DIBPREVIEW_HXX_
31 //------------------------------------------------------------------------
33 //------------------------------------------------------------------------
35 #include "previewbase.hxx"
36 #include <osl/mutex.hxx>
39 #pragma warning(push, 1)
46 //---------------------------------------------
47 // A very simple wrapper for a window that does
49 // Maybe it would be better and more extensible
50 // to create another class that is responsible
51 // for rendering a specific image format into
52 // the area of the window, but for our purpose
53 // it's enough to go the simple way - KISS.
54 //---------------------------------------------
56 class CDIBPreview
: public PreviewBase
61 CDIBPreview(HINSTANCE instance
,HWND parent
,sal_Bool bShowWindow
= sal_False
);
64 virtual ~CDIBPreview( );
66 // preview interface implementation
68 virtual sal_Int32 SAL_CALL
getTargetColorDepth()
69 throw (::com::sun::star::uno::RuntimeException
);
71 virtual sal_Int32 SAL_CALL
getAvailableWidth()
72 throw (::com::sun::star::uno::RuntimeException
);
74 virtual sal_Int32 SAL_CALL
getAvailableHeight()
75 throw (::com::sun::star::uno::RuntimeException
);
77 virtual void SAL_CALL
setImage(sal_Int16 aImageFormat
, const ::com::sun::star::uno::Any
& aImage
)
78 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
80 virtual sal_Bool SAL_CALL
setShowState(sal_Bool bShowState
)
81 throw (::com::sun::star::uno::RuntimeException
);
83 virtual sal_Bool SAL_CALL
getShowState()
84 throw (::com::sun::star::uno::RuntimeException
);
86 virtual HWND SAL_CALL
getWindowHandle() const;
89 virtual void SAL_CALL
onPaint( HWND hWnd
, HDC hDC
);
91 ATOM SAL_CALL
RegisterDibPreviewWindowClass( );
92 void SAL_CALL
UnregisterDibPreviewWindowClass( );
94 static LRESULT CALLBACK
WndProc( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
99 com::sun::star::uno::Sequence
<sal_Int8
> m_Image
;
100 osl::Mutex m_PaintLock
;
102 // the preview window class has to be registered only
103 // once per process, so multiple instance of this class
104 // share the registered window class
105 static ATOM s_ClassAtom
;
106 static osl::Mutex s_Mutex
;
107 static sal_Int32 s_RegisterDibPreviewWndCount
;
109 // prevent copy and assignment
111 CDIBPreview(const CDIBPreview
&);
112 CDIBPreview
& operator=(const CDIBPreview
&);