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 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_fpicker.hxx"
30 #include "previewbase.hxx"
31 
32 #ifndef _COM_SUN_STAR_UI_DIALOG_FILEPREVIEWIMAGEFORMATS_HPP_
33 #include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp>
34 #endif
35 
36 using namespace com::sun::star::uno;
37 using namespace com::sun::star::lang;
38 using namespace rtl;
39 
40 //-------------------------------
41 //
42 //-------------------------------
43 
44 PreviewBase::PreviewBase() :
45 	m_ImageFormat(::com::sun::star::ui::dialogs::FilePreviewImageFormats::BITMAP),
46 	m_bShowState(sal_False)
47 {
48 }
49 
50 //-------------------------------
51 //
52 //-------------------------------
53 
54 PreviewBase::~PreviewBase()
55 {
56 }
57 
58 //-------------------------------
59 //
60 //-------------------------------
61 
62 sal_Int32 SAL_CALL PreviewBase::getTargetColorDepth() throw (RuntimeException)
63 {
64 	return 0;
65 }
66 
67 //-------------------------------
68 //
69 //-------------------------------
70 
71 sal_Int32 SAL_CALL PreviewBase::getAvailableWidth() throw (RuntimeException)
72 {
73 	return 0;
74 }
75 
76 //-------------------------------
77 //
78 //-------------------------------
79 
80 sal_Int32 SAL_CALL PreviewBase::getAvailableHeight() throw (RuntimeException)
81 {
82 	return 0;
83 }
84 
85 //-------------------------------
86 //
87 //-------------------------------
88 
89 void SAL_CALL PreviewBase::setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage )
90 	throw (IllegalArgumentException, RuntimeException)
91 {
92 	if (aImageFormat != ::com::sun::star::ui::dialogs::FilePreviewImageFormats::BITMAP)
93 		throw IllegalArgumentException(
94 			OUString::createFromAscii("unsupported image format"), 0, 1);
95 
96     if (aImage.hasValue() && (aImage.getValueType() != getCppuType((Sequence<sal_Int8>*)0)))
97         throw IllegalArgumentException(
98             OUString::createFromAscii("invalid image data"), 0, 2);
99 
100 	 // save the new image data and force a redraw
101     m_ImageData   = aImage;
102 	m_ImageFormat = aImageFormat;
103 }
104 
105 //-------------------------------
106 //
107 //-------------------------------
108 
109 void SAL_CALL PreviewBase::getImage(sal_Int16& aImageFormat,com::sun::star::uno::Any& aImage)
110 {
111 	aImageFormat = m_ImageFormat;
112 	aImage       = m_ImageData;
113 }
114 
115 //-------------------------------
116 //
117 //-------------------------------
118 
119 sal_Bool SAL_CALL PreviewBase::setShowState( sal_Bool bShowState ) throw (RuntimeException)
120 {
121 	m_bShowState = bShowState;
122 	return sal_True;
123 }
124 
125 //-------------------------------
126 //
127 //-------------------------------
128 
129 sal_Bool SAL_CALL PreviewBase::getShowState() throw (RuntimeException)
130 {
131 	return sal_False;
132 }
133 
134 //-------------------------------
135 //
136 //-------------------------------
137 
138 sal_Bool SAL_CALL PreviewBase::getImaginaryShowState() const
139 {
140 	return m_bShowState;
141 }
142 
143 //-------------------------------
144 //
145 //-------------------------------
146 
147 HWND SAL_CALL PreviewBase::getWindowHandle() const
148 {
149 	return 0;
150 }
151