summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2002-03-21 06:12:10 +0000
committerTino Rachui <tra@openoffice.org>2002-03-21 06:12:10 +0000
commitcd329519ffd78703eca2c8fa213ef15bed9e60bb (patch)
tree1bc16b77735880435018dcbf93cf84b53442fc95 /fpicker
parentfb267eb68e2e4e7f8f76220248b6b467f2802e96 (diff)
#97633#
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/win32/filepicker/previewadapter.cxx751
-rw-r--r--fpicker/source/win32/filepicker/previewadapter.hxx149
-rw-r--r--fpicker/source/win32/filepicker/previewbase.cxx184
-rw-r--r--fpicker/source/win32/filepicker/previewbase.hxx130
4 files changed, 1214 insertions, 0 deletions
diff --git a/fpicker/source/win32/filepicker/previewadapter.cxx b/fpicker/source/win32/filepicker/previewadapter.cxx
new file mode 100644
index 000000000000..9108927786d5
--- /dev/null
+++ b/fpicker/source/win32/filepicker/previewadapter.cxx
@@ -0,0 +1,751 @@
+/*************************************************************************
+ *
+ * $RCSfile: previewadapter.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2002-03-21 07:11:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PREVIEWADAPTER_HXX_
+#include "previewadapter.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_UI_DIALOG_FILEPREVIEWIMAGEFORMATS_HPP_
+#include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp>
+#endif
+
+#ifndef _DIBPREVIEW_HXX_
+#include "dibpreview.hxx"
+#endif
+
+#ifndef _WINIMPLHELPER_HXX_
+#include "../misc/WinImplHelper.hxx"
+#endif
+
+#include <memory>
+#include <stdexcept>
+
+//---------------------------------------------
+//
+//---------------------------------------------
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+//---------------------------------------------
+// An impl class to hide implementation details
+// from clients
+//---------------------------------------------
+
+class CPreviewAdapterImpl
+{
+public:
+ CPreviewAdapterImpl(HINSTANCE instance);
+
+ virtual ~CPreviewAdapterImpl();
+
+ virtual sal_Int32 SAL_CALL getTargetColorDepth();
+
+ virtual sal_Int32 SAL_CALL getAvailableWidth();
+
+ virtual sal_Int32 SAL_CALL getAvailableHeight();
+
+ virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const Any& aImage )
+ throw (IllegalArgumentException,RuntimeException);
+
+ virtual sal_Bool SAL_CALL setShowState(sal_Bool bShowState);
+
+ virtual sal_Bool SAL_CALL getShowState();
+
+ virtual void SAL_CALL setParent(HWND parent);
+
+ virtual HWND SAL_CALL getParent();
+
+ //-------------------------------------
+ // parent notification handler
+ //-------------------------------------
+
+ virtual void SAL_CALL notifyParentShow(sal_Bool bShow);
+
+ virtual void SAL_CALL notifyParentSizeChanged();
+
+ virtual void SAL_CALL notifyParentWindowPosChanged(sal_Bool bIsVisible);
+
+protected:
+ virtual void SAL_CALL calcRightMargin();
+
+ virtual void SAL_CALL rearrangeLayout();
+
+ void SAL_CALL initializeActivePreview() throw(std::runtime_error);
+
+ HWND SAL_CALL findFileListbox() const;
+
+// member
+protected:
+ HINSTANCE m_Instance;
+ std::auto_ptr<PreviewBase> m_Preview;
+ HWND m_FileDialog;
+ int m_RightMargin;
+
+//prevent copy/assignment
+private:
+ CPreviewAdapterImpl(const CPreviewAdapterImpl&);
+ CPreviewAdapterImpl& operator=(const CPreviewAdapterImpl&);
+};
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+CPreviewAdapterImpl::CPreviewAdapterImpl(HINSTANCE instance) :
+ m_Instance(instance),
+ m_Preview(new PreviewBase()), // create dummy preview (NULL-Object pattern)
+ m_FileDialog(0),
+ m_RightMargin(0)
+{
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+CPreviewAdapterImpl::~CPreviewAdapterImpl()
+{
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+sal_Int32 SAL_CALL CPreviewAdapterImpl::getTargetColorDepth()
+{
+ return m_Preview->getTargetColorDepth();
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+sal_Int32 SAL_CALL CPreviewAdapterImpl::getAvailableWidth()
+{
+ return m_Preview->getAvailableWidth();
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+sal_Int32 SAL_CALL CPreviewAdapterImpl::getAvailableHeight()
+{
+ return m_Preview->getAvailableHeight();
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+void SAL_CALL CPreviewAdapterImpl::setImage( sal_Int16 aImageFormat, const Any& aImage )
+ throw (IllegalArgumentException,RuntimeException)
+{
+ m_Preview->setImage(aImageFormat,aImage);
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+sal_Bool SAL_CALL CPreviewAdapterImpl::setShowState( sal_Bool bShowState )
+{
+ sal_Bool bRet = m_Preview->setShowState(bShowState);
+ rearrangeLayout();
+ return bRet;
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+sal_Bool SAL_CALL CPreviewAdapterImpl::getShowState()
+{
+ return m_Preview->getShowState();
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+void SAL_CALL CPreviewAdapterImpl::setParent(HWND parent)
+{
+ OSL_PRECOND(IsWindow(parent),"Invalid FileDialog handle");
+
+ m_FileDialog = parent;
+ calcRightMargin();
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+HWND SAL_CALL CPreviewAdapterImpl::getParent()
+{
+ return m_FileDialog;
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+void SAL_CALL CPreviewAdapterImpl::calcRightMargin()
+{
+ // Calculate the right reference margin
+ //
+ // Assumtions:
+ // 1. This method will be called before the dialog becomes
+ // visible
+ // 2. There exist a FileListbox with the id lst1 even
+ // if it is not visible like under Win2000/XP
+ // 3. Initially this FileListbox has the appropriate size
+ // to fit within the FileListbox
+ // 4. The margin between the right edge of the FileListbox
+ // and the right edge of the FileDialog will be constant
+ // even if the size of the dialog changes
+
+ HWND flb = GetDlgItem(m_FileDialog,lst1);
+
+ OSL_ENSURE(IsWindow(flb),"Filelistbox not found");
+
+ RECT rcFlb;
+ GetWindowRect(flb,&rcFlb);
+
+ RECT rcFileDlg;
+ GetWindowRect(m_FileDialog,&rcFileDlg);
+
+ m_RightMargin = rcFileDlg.right - rcFlb.right;
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+void SAL_CALL CPreviewAdapterImpl::notifyParentShow(sal_Bool bShow)
+{
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+void SAL_CALL CPreviewAdapterImpl::notifyParentSizeChanged()
+{
+ rearrangeLayout();
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+void SAL_CALL CPreviewAdapterImpl::notifyParentWindowPosChanged(sal_Bool bIsVisible)
+{
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+void SAL_CALL CPreviewAdapterImpl::rearrangeLayout()
+{
+ // try to get a handle to the filelistbox
+ // if there is no new-style filelistbox like
+ // in Win2000/XP there should be at least the
+ // old listbox, so we take this one
+ // lst1 - identifies the old-style filelistbox
+ // lst2 - identifies the new-style filelistbox
+ // see dlgs.h
+ HWND flb_new = findFileListbox();
+
+ // under Windows NT 4.0 the size of the old
+ // filelistbox will be used as reference for
+ // sizing the new filelistbox, so we have
+ // to change the size of it too
+ HWND flb_old = GetDlgItem(m_FileDialog,lst1);
+
+ RECT rcFlbNew;
+ GetWindowRect(flb_new,&rcFlbNew);
+
+ RECT rcFileDlg;
+ GetWindowRect(m_FileDialog,&rcFileDlg);
+ rcFileDlg.right -= m_RightMargin;
+
+ // the available area for the filelistbox should be
+ // the left edge of the filelistbox and the right
+ // edge of the OK button, we take this as reference
+ int height = rcFlbNew.bottom - rcFlbNew.top;
+ int width = rcFileDlg.right - rcFlbNew.left;
+
+ HWND prvwnd = m_Preview->getWindowHandle();
+
+ // we use GetWindowLong to ask for the visibility
+ // of the preview window because IsWindowVisible
+ // only returns true the specified window including
+ // its parent windows are visible
+ // this is not the case when we are called in response
+ // to the WM_SHOWWINDOW message, somehow the WS_VISIBLE
+ // style bit of the FileOpen dialog must be set after that
+ // message
+ LONG lStyle = GetWindowLongA(prvwnd,GWL_STYLE);
+ BOOL bIsVisible = (BOOL)(lStyle & WS_VISIBLE);
+
+ int cx = 0;
+
+ if (IsWindow(prvwnd) && bIsVisible)
+ {
+ cx = width/2;
+
+ // resize the filelistbox to the half of the
+ // available space
+ BOOL bRet = SetWindowPos(flb_new,
+ NULL, 0, 0, cx, height,
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
+
+ bRet = SetWindowPos(flb_old,
+ NULL, 0, 0, cx, height,
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
+
+ // get the new dimensions of the filelistbox after
+ // resizing and take the right,top corner as starting
+ // point for the preview window
+ GetWindowRect(flb_new,&rcFlbNew);
+ POINT pt = { rcFlbNew.right, rcFlbNew.top };
+ ScreenToClient(m_FileDialog,&pt);
+
+ // resize the preview window to fit within
+ // the available space and set the window
+ // to the top of the z-order else it will
+ // be invisible
+ SetWindowPos(prvwnd,
+ HWND_TOP, pt.x, pt.y, cx, height, SWP_NOACTIVATE);
+ }
+ else
+ {
+ // resize the filelistbox to the maximum available
+ // space
+ cx = rcFileDlg.right - rcFlbNew.left;
+
+ // resize the old filelistbox
+ SetWindowPos(flb_old,
+ NULL, 0, 0, cx, height,
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
+
+ // resize the new filelistbox
+ SetWindowPos(flb_new,
+ NULL, 0, 0, cx, height,
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
+ }
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+void SAL_CALL CPreviewAdapterImpl::initializeActivePreview() throw(std::runtime_error)
+{
+ sal_Bool bShowState = m_Preview->getImaginaryShowState();
+
+ sal_Int16 aImgFrmt;
+ Any aImg;
+ m_Preview->getImage(aImgFrmt,aImg);
+
+ HWND flb = findFileListbox();
+
+ PreviewBase* prv = new CDIBPreview(
+ m_Instance, GetParent(flb), bShowState);
+
+ m_Preview.reset(prv);
+
+ m_Preview->setImage(aImgFrmt,aImg);
+}
+
+//-----------------------------------------
+//
+//-----------------------------------------
+
+HWND SAL_CALL CPreviewAdapterImpl::findFileListbox() const
+{
+ // try to get a handle to the filelistbox
+ // if there is no new-style filelistbox like
+ // in Win2000/XP there should be at least the
+ // old listbox, so we take this one
+ // lst1 - identifies the old-style filelistbox
+ // lst2 - identifies the new-style filelistbox
+ // see dlgs.h
+ HWND flb = GetDlgItem(m_FileDialog,lst2);
+ if (!IsWindow(flb))
+ flb = GetDlgItem(m_FileDialog,lst1);
+
+ return flb;
+}
+
+
+//##############################################################
+
+
+//-----------------------------------------
+// Special implementation for Win98
+// because:
+//
+//-----------------------------------------
+
+class CWin98PreviewAdapterImpl : public CPreviewAdapterImpl
+{
+public:
+ CWin98PreviewAdapterImpl(HINSTANCE instance);
+
+ virtual void SAL_CALL notifyParentWindowPosChanged(sal_Bool bIsVisible);
+
+protected:
+ virtual void SAL_CALL rearrangeLayout();
+
+ bool isValidToolbarDimension() const;
+
+private:
+ sal_Bool m_PreviewActive;
+ int m_ToolbarPosX;
+ int m_ToolbarPosY;
+ int m_ToolbarWidth;
+ int m_ToolbarHeight;
+};
+
+//--------------------------------------------
+//
+//--------------------------------------------
+
+CWin98PreviewAdapterImpl::CWin98PreviewAdapterImpl(HINSTANCE instance) :
+ CPreviewAdapterImpl(instance),
+ m_PreviewActive(sal_False),
+ m_ToolbarPosX(0),
+ m_ToolbarPosY(0),
+ m_ToolbarWidth(0),
+ m_ToolbarHeight(0)
+{
+}
+
+//--------------------------------------------
+//
+//--------------------------------------------
+
+void SAL_CALL CWin98PreviewAdapterImpl::notifyParentWindowPosChanged(sal_Bool bIsVisible)
+{
+ try
+ {
+ // the reason for this condition is
+ // Windows 98
+ // Under Windows 98 the message WM_SHOWWINDOW
+ // will be sent only the first time the
+ // GetOpenFileName function is called within
+ // the same process
+ // so we must use another message to initialize
+ // the preview window
+ if (IsWindow(m_FileDialog) && !m_PreviewActive)
+ {
+ initializeActivePreview();
+ m_PreviewActive = sal_True;
+ rearrangeLayout();
+ }
+
+ if (IsWindow(m_FileDialog) && !isValidToolbarDimension())
+ {
+ RECT rcStc1;
+ GetWindowRect(GetDlgItem(m_FileDialog,stc1),&rcStc1);
+
+ RECT rcCmb2;
+ GetWindowRect(GetDlgItem(m_FileDialog,cmb2),&rcCmb2);
+
+ // Assumption:
+ // the toolbar position is only valid
+ // if the left edge is greater or equal
+ // than the right edge of the drives listbox
+ // the stc1 static text is invisible at runtime
+ // but will be used as reference for the position
+ // and dimension of the toolbar
+ if (rcStc1.left >= rcCmb2.right)
+ {
+ // important: save the upper left corner in
+ // client coordinates
+ POINT pt = {rcStc1.left,rcStc1.top};
+ ScreenToClient(m_FileDialog,&pt);
+
+ m_ToolbarPosX = pt.x;
+ m_ToolbarPosY = pt.y;
+ m_ToolbarWidth = rcStc1.right - rcStc1.left;
+ m_ToolbarHeight = rcStc1.bottom - rcStc1.top;
+ }
+ }
+ }
+ catch(std::runtime_error&)
+ {
+ }
+}
+
+//--------------------------------------------
+//
+//--------------------------------------------
+
+void SAL_CALL CWin98PreviewAdapterImpl::rearrangeLayout()
+{
+ CPreviewAdapterImpl::rearrangeLayout();
+
+ // fix the position of the upper toolbar
+ // because the FileDialog moves all windows
+ // that are to the right of the FileListbox
+ // so if we have changed the size of the
+ // FileListbox we would run into trouble else
+ if (isValidToolbarDimension())
+ {
+ HWND hwndTlb = FindWindowEx(
+ m_FileDialog,NULL,"ToolbarWindow32",NULL);
+
+ SetWindowPos(hwndTlb,
+ HWND_TOP,
+ m_ToolbarPosX,
+ m_ToolbarPosY,
+ m_ToolbarWidth,
+ m_ToolbarHeight,
+ SWP_NOACTIVATE);
+ }
+}
+
+//--------------------------------------------
+//
+//--------------------------------------------
+
+bool CWin98PreviewAdapterImpl::isValidToolbarDimension() const
+{
+ return (m_ToolbarPosX > 0 &&
+ m_ToolbarPosY > 0 &&
+ m_ToolbarWidth > 0 &&
+ m_ToolbarHeight > 0);
+}
+
+//##############################################################
+
+
+//--------------------------------------------
+// Implementation for Windows 95/NT/ME/2000/XP
+// because:
+//
+//--------------------------------------------
+
+class CWin95NTPreviewAdapterImpl : public CPreviewAdapterImpl
+{
+public:
+ CWin95NTPreviewAdapterImpl(HINSTANCE instance);
+
+ virtual void SAL_CALL notifyParentShow(sal_Bool bShow);
+};
+
+//--------------------------------------------
+//
+//--------------------------------------------
+
+CWin95NTPreviewAdapterImpl::CWin95NTPreviewAdapterImpl(HINSTANCE instance) :
+ CPreviewAdapterImpl(instance)
+{
+}
+
+//--------------------------------------------
+//
+//--------------------------------------------
+
+void SAL_CALL CWin95NTPreviewAdapterImpl::notifyParentShow(sal_Bool bShow)
+{
+ try
+ {
+ if (bShow)
+ {
+ initializeActivePreview();
+ rearrangeLayout();
+ }
+ }
+ catch(std::runtime_error&)
+ {
+ }
+}
+
+
+//##############################################################
+
+
+//-------------------------------
+// ctor
+//-------------------------------
+
+CPreviewAdapter::CPreviewAdapter(HINSTANCE instance)
+{
+ if (!IsWindows98())
+ m_pImpl.reset(new CWin95NTPreviewAdapterImpl(instance));
+ else
+ m_pImpl.reset(new CWin98PreviewAdapterImpl(instance));
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+CPreviewAdapter::~CPreviewAdapter()
+{
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+Sequence<sal_Int16> SAL_CALL CPreviewAdapter::getSupportedImageFormats()
+{
+ com::sun::star::uno::Sequence<sal_Int16> imgFormats(1);
+ imgFormats[0] = ::com::sun::star::ui::dialogs::FilePreviewImageFormats::BITMAP;
+ return imgFormats;
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Int32 SAL_CALL CPreviewAdapter::getTargetColorDepth()
+{
+ return m_pImpl->getTargetColorDepth();
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Int32 SAL_CALL CPreviewAdapter::getAvailableWidth()
+{
+ return m_pImpl->getAvailableWidth();
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Int32 SAL_CALL CPreviewAdapter::getAvailableHeight()
+{
+ return m_pImpl->getAvailableHeight();
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+void SAL_CALL CPreviewAdapter::setImage( sal_Int16 aImageFormat, const Any& aImage )
+ throw (IllegalArgumentException, RuntimeException)
+{
+ m_pImpl->setImage(aImageFormat,aImage);
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Bool SAL_CALL CPreviewAdapter::setShowState( sal_Bool bShowState )
+{
+ return m_pImpl->setShowState(bShowState);
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Bool SAL_CALL CPreviewAdapter::getShowState()
+{
+ return m_pImpl->getShowState();
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+void SAL_CALL CPreviewAdapter::setParent(HWND parent)
+{
+ m_pImpl->setParent(parent);
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+void SAL_CALL CPreviewAdapter::notifyParentShow(sal_Bool bShow)
+{
+ m_pImpl->notifyParentShow(bShow);
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+void SAL_CALL CPreviewAdapter::notifyParentSizeChanged()
+{
+ m_pImpl->notifyParentSizeChanged();
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+void SAL_CALL CPreviewAdapter::notifyParentWindowPosChanged(sal_Bool bIsVisible)
+{
+ m_pImpl->notifyParentWindowPosChanged(bIsVisible);
+}
diff --git a/fpicker/source/win32/filepicker/previewadapter.hxx b/fpicker/source/win32/filepicker/previewadapter.hxx
new file mode 100644
index 000000000000..39e114da4ce3
--- /dev/null
+++ b/fpicker/source/win32/filepicker/previewadapter.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * $RCSfile: previewadapter.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2002-03-21 07:11:58 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PREVIEWADAPTER_HXX_
+#define _PREVIEWADAPTER_HXX_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_
+#include <com/sun/star/uno/RuntimeException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+
+#include <windows.h>
+#include <memory>
+
+// forward declaration
+class CPreviewAdapterImpl;
+
+//---------------------------------------------
+// A kind of a facade for the preview class.
+// We want to hide the fact that the preview
+// window may only become visible if there is
+// a valid parent window (means, the FilePicker)
+// is in execution mode. So unless someone sets
+// the preview active with a valid parent
+// window the preview may not be visible
+//---------------------------------------------
+
+class CPreviewAdapter
+{
+public:
+
+ // ctor
+ CPreviewAdapter(HINSTANCE instance);
+
+ ~CPreviewAdapter();
+
+ ::com::sun::star::uno::Sequence<sal_Int16> SAL_CALL getSupportedImageFormats();
+
+ sal_Int32 SAL_CALL getTargetColorDepth();
+
+ sal_Int32 SAL_CALL getAvailableWidth();
+
+ sal_Int32 SAL_CALL getAvailableHeight();
+
+ void SAL_CALL setImage(sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage)
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ sal_Bool SAL_CALL setShowState(sal_Bool bShowState);
+
+ sal_Bool SAL_CALL getShowState();
+
+ void SAL_CALL setParent(HWND parent);
+
+ //--------------------------------------
+ // notification from parent
+ //--------------------------------------
+
+ void SAL_CALL notifyParentShow(sal_Bool bShow);
+
+ void SAL_CALL notifyParentSizeChanged();
+
+ void SAL_CALL notifyParentWindowPosChanged(sal_Bool bIsVisible);
+
+private:
+ // hide implementation details using the
+ // bridge pattern
+ std::auto_ptr<CPreviewAdapterImpl> m_pImpl;
+
+// prevent copy and assignment
+private:
+ CPreviewAdapter(const CPreviewAdapter&);
+ CPreviewAdapter& operator=(const CPreviewAdapter&);
+};
+
+
+#endif \ No newline at end of file
diff --git a/fpicker/source/win32/filepicker/previewbase.cxx b/fpicker/source/win32/filepicker/previewbase.cxx
new file mode 100644
index 000000000000..3bc44758dca9
--- /dev/null
+++ b/fpicker/source/win32/filepicker/previewbase.cxx
@@ -0,0 +1,184 @@
+/*************************************************************************
+ *
+ * $RCSfile: previewbase.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2002-03-21 07:12:04 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PREVIEWBASE_HXX_
+#include "previewbase.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_UI_DIALOG_FILEPREVIEWIMAGEFORMATS_HPP_
+#include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp>
+#endif
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace rtl;
+
+//-------------------------------
+//
+//-------------------------------
+
+PreviewBase::PreviewBase() :
+ m_ImageFormat(::com::sun::star::ui::dialogs::FilePreviewImageFormats::BITMAP),
+ m_bShowState(sal_False)
+{
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+PreviewBase::~PreviewBase()
+{
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Int32 SAL_CALL PreviewBase::getTargetColorDepth() throw (RuntimeException)
+{
+ return 0;
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Int32 SAL_CALL PreviewBase::getAvailableWidth() throw (RuntimeException)
+{
+ return 0;
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Int32 SAL_CALL PreviewBase::getAvailableHeight() throw (RuntimeException)
+{
+ return 0;
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+void SAL_CALL PreviewBase::setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage )
+ throw (IllegalArgumentException, RuntimeException)
+{
+ if (aImageFormat != ::com::sun::star::ui::dialogs::FilePreviewImageFormats::BITMAP)
+ throw IllegalArgumentException(
+ OUString::createFromAscii("unsupported image format"), 0, 1);
+
+ if (aImage.hasValue() && (aImage.getValueType() != getCppuType((Sequence<sal_Int8>*)0)))
+ throw IllegalArgumentException(
+ OUString::createFromAscii("invalid image data"), 0, 2);
+
+ // save the new image data and force a redraw
+ m_ImageData = aImage;
+ m_ImageFormat = aImageFormat;
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+void SAL_CALL PreviewBase::getImage(sal_Int16& aImageFormat,com::sun::star::uno::Any& aImage)
+{
+ aImageFormat = m_ImageFormat;
+ aImage = m_ImageData;
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Bool SAL_CALL PreviewBase::setShowState( sal_Bool bShowState ) throw (RuntimeException)
+{
+ m_bShowState = bShowState;
+ return sal_True;
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Bool SAL_CALL PreviewBase::getShowState() throw (RuntimeException)
+{
+ return sal_False;
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+sal_Int16 SAL_CALL PreviewBase::getImaginaryShowState() const
+{
+ return m_bShowState;
+}
+
+//-------------------------------
+//
+//-------------------------------
+
+HWND SAL_CALL PreviewBase::getWindowHandle() const
+{
+ return 0;
+}
diff --git a/fpicker/source/win32/filepicker/previewbase.hxx b/fpicker/source/win32/filepicker/previewbase.hxx
new file mode 100644
index 000000000000..6defc7a269e4
--- /dev/null
+++ b/fpicker/source/win32/filepicker/previewbase.hxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * $RCSfile: previewbase.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tra $ $Date: 2002-03-21 07:12:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PREVIEWBASE_HXX_
+#define _PREVIEWBASE_HXX_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_
+#include <com/sun/star/uno/RuntimeException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+
+#include <windows.h>
+
+//---------------------------------------------
+// Common interface for previews
+//---------------------------------------------
+
+class PreviewBase
+{
+public:
+ PreviewBase();
+
+ // dtor
+ virtual ~PreviewBase();
+
+ virtual sal_Int32 SAL_CALL getTargetColorDepth()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getAvailableWidth()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getAvailableHeight()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL getShowState()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL getImage(sal_Int16& aImageFormat,com::sun::star::uno::Any& aImage);
+
+ sal_Int16 SAL_CALL getImaginaryShowState() const;
+
+ virtual HWND SAL_CALL getWindowHandle() const;
+
+protected:
+ ::com::sun::star::uno::Any m_ImageData;
+ sal_Int16 m_ImageFormat;
+ sal_Bool m_bShowState;
+};
+
+
+#endif \ No newline at end of file