summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Ahrens <ka@openoffice.org>2001-02-13 11:08:24 +0000
committerKai Ahrens <ka@openoffice.org>2001-02-13 11:08:24 +0000
commit667bd43e3f792b3f70c97d785c9df6d34c3f4438 (patch)
tree7d731d37a696fa66c4e9944f2c3d836d249b46a6
parent3901e1132bb1e594bcf4ee25f959483c8c1f1889 (diff)
initial revision
-rw-r--r--sd/inc/sdcgmfilter.hxx82
-rw-r--r--sd/inc/sdfilter.hxx125
-rw-r--r--sd/inc/sdgrffilter.hxx86
-rw-r--r--sd/source/filter/cgm/makefile.mk80
-rw-r--r--sd/source/filter/cgm/sdcgmfilter.cxx192
-rw-r--r--sd/source/filter/grf/makefile.mk80
-rw-r--r--sd/source/filter/grf/sdgrffilter.cxx211
-rw-r--r--sd/source/filter/sdfilter.cxx243
8 files changed, 1099 insertions, 0 deletions
diff --git a/sd/inc/sdcgmfilter.hxx b/sd/inc/sdcgmfilter.hxx
new file mode 100644
index 000000000000..4ed69259e094
--- /dev/null
+++ b/sd/inc/sdcgmfilter.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * $RCSfile: sdcgmfilter.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: ka $ $Date: 2001-02-13 12:01:15 $
+ *
+ * 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 _SD_SDCGMFILTER_HXX
+#define _SD_SDCGMFILTER_HXX
+
+#include "sdfilter.hxx"
+
+// ---------------
+// - SdCGMFilter -
+// ---------------
+
+class SdCGMFilter : public SdFilter
+{
+public:
+
+ SdCGMFilter( SfxMedium& rMedium, SdDrawDocShell& rDocShell, sal_Bool bShowProgress );
+ ~SdCGMFilter();
+
+ virtual sal_Bool Import();
+ virtual sal_Bool Export();
+};
+
+#endif // _SD_SDCGMFILTER_HXX
diff --git a/sd/inc/sdfilter.hxx b/sd/inc/sdfilter.hxx
new file mode 100644
index 000000000000..75367a65c328
--- /dev/null
+++ b/sd/inc/sdfilter.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * $RCSfile: sdfilter.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: ka $ $Date: 2001-02-13 12:01:15 $
+ *
+ * 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 _SD_SDFILTER_HXX
+#define _SD_SDFILTER_HXX
+
+#include <tools/gen.hxx>
+#include <rtl/ustring>
+
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XSTATUSINDICATOR_HPP_
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XSTATUSINDICATORSUPPLIER_HPP_
+#include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
+#endif
+
+// ------------
+// - SdFilter -
+// ------------
+
+class SfxMedium;
+class SdDrawDocShell;
+class SdDrawDocument;
+class SfxProgress;
+namespace vos { class OModule; }
+
+class SdFilter
+{
+private:
+
+ ::rtl::OUString ImplGetFullLibraryName( const ::rtl::OUString& rLibraryName ) const;
+
+protected:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > mxStatusIndicator;
+
+protected:
+
+ SfxMedium& mrMedium;
+ SdDrawDocShell& mrDocShell;
+ SdDrawDocument& mrDocument;
+ SfxProgress* mpProgress;
+ sal_Bool mbIsDraw : 1;
+ sal_Bool mbShowProgress : 1;
+
+ ::vos::OModule* OpenLibrary( const ::rtl::OUString& rLibraryName ) const;
+ void CreateStatusIndicator();
+ void CreateProgress();
+
+public:
+
+ SdFilter( SfxMedium& rMedium, SdDrawDocShell& rDocShell, sal_Bool bShowProgress );
+ ~SdFilter();
+
+ virtual sal_Bool Import();
+ virtual sal_Bool Export();
+
+ sal_Bool IsProgress() const { return mbShowProgress; }
+ sal_Bool IsDraw() const { return mbIsDraw; }
+ sal_Bool IsImpress() const { return !mbIsDraw; }
+};
+
+#endif // _SD_SDFILTER_HXX
diff --git a/sd/inc/sdgrffilter.hxx b/sd/inc/sdgrffilter.hxx
new file mode 100644
index 000000000000..c7ea0d88405f
--- /dev/null
+++ b/sd/inc/sdgrffilter.hxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * $RCSfile: sdgrffilter.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: ka $ $Date: 2001-02-13 12:01:15 $
+ *
+ * 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 _SD_SDGRFFILTER_HXX
+#define _SD_SDGRFFILTER_HXX
+
+#include <tools/errinf.hxx>
+#include "sdfilter.hxx"
+
+// ---------------
+// - SdCGMFilter -
+// ---------------
+
+class SdGRFFilter : public SdFilter
+{
+public:
+
+ SdGRFFilter( SfxMedium& rMedium, SdDrawDocShell& rDocShell, sal_Bool bShowProgress );
+ ~SdGRFFilter();
+
+ virtual sal_Bool Import();
+
+public:
+
+ static void HandleGraphicFilterError( USHORT nFilterError, ULONG nStreamError = ERRCODE_NONE );
+};
+
+#endif // _SD_SDGRFFILTER_HXX
diff --git a/sd/source/filter/cgm/makefile.mk b/sd/source/filter/cgm/makefile.mk
new file mode 100644
index 000000000000..88df77ac5673
--- /dev/null
+++ b/sd/source/filter/cgm/makefile.mk
@@ -0,0 +1,80 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: ka $ $Date: 2001-02-13 12:07:34 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=sd
+TARGET=cgm
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = $(SLO)$/sdcgmfilter.obj
+
+# --- Targets --------------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/sd/source/filter/cgm/sdcgmfilter.cxx b/sd/source/filter/cgm/sdcgmfilter.cxx
new file mode 100644
index 000000000000..4a2a0d438bfb
--- /dev/null
+++ b/sd/source/filter/cgm/sdcgmfilter.cxx
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * $RCSfile: sdcgmfilter.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: ka $ $Date: 2001-02-13 12:07:34 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <vos/module.hxx>
+#include <tools/urlobj.hxx>
+#include <svtools/itemset.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xfillit0.hxx>
+
+#include "sdpage.hxx"
+#include "drawdoc.hxx"
+#include "sdcgmfilter.hxx"
+
+// -----------
+// - Defines -
+// -----------
+
+#define CGM_IMPORT_CGM 0x00000001
+#define CGM_IMPORT_IM 0x00000002
+
+#define CGM_EXPORT_IMPRESS 0x00000100
+#define CGM_EXPORT_META 0x00000200
+#define CGM_EXPORT_COMMENT 0x00000400
+
+#define CGM_NO_PAD_BYTE 0x00010000
+#define CGM_BIG_ENDIAN 0x00020000
+#define CGM_LITTLE_ENDIAN 0x00040000
+
+// --------------
+// - Namespaces -
+// --------------
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::frame;
+
+// ------------
+// - Typedefs -
+// ------------
+
+typedef UINT32 ( __LOADONCALLAPI *ImportCGM )( ::rtl::OUString&, Reference< XModel >&, UINT32, Reference< XStatusIndicator >& );
+typedef BOOL ( __LOADONCALLAPI *ExportCGM )( ::rtl::OUString&, Reference< XModel >&, Reference< XStatusIndicator >&, void* );
+
+// ---------------
+// - SdPPTFilter -
+// ---------------
+
+SdCGMFilter::SdCGMFilter( SfxMedium& rMedium, SdDrawDocShell& rDocShell, sal_Bool bShowProgress ) :
+ SdFilter( rMedium, rDocShell, bShowProgress )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SdCGMFilter::~SdCGMFilter()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SdCGMFilter::Import()
+{
+ ::vos::OModule* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
+ sal_Bool bRet = sal_False;
+
+ if( pLibrary && mxModel.is() )
+ {
+ ImportCGM FncImportCGM = ( ImportCGM ) pLibrary->getSymbol( ::rtl::OUString::createFromAscii( "ImportCGM" ) );
+ ::rtl::OUString aFileURL( mrMedium.GetURLObject().GetMainURL() );
+ UINT32 nRetValue;
+
+ if( mrDocument.GetPageCount() == 0L )
+ mrDocument.CreateFirstPages();
+
+ CreateStatusIndicator();
+ nRetValue = FncImportCGM( aFileURL, mxModel, CGM_IMPORT_CGM | CGM_BIG_ENDIAN | CGM_EXPORT_IMPRESS, mxStatusIndicator );
+
+ if( nRetValue )
+ {
+ bRet = TRUE;
+
+ if( ( nRetValue &~0xff000000 ) != 0xffffff ) // maybe the backgroundcolor is already white
+ { // so we must not set a master page
+ mrDocument.StopWorkStartupDelay();
+ SdrObject* pObj = mrDocument.GetMasterSdPage(0, PK_STANDARD)->GetPresObj(PRESOBJ_BACKGROUND);
+
+ if( pObj )
+ {
+ SfxItemSet aSet( mrDocument.GetPool() );
+ Color aColor( (BYTE)( nRetValue >> 16 ), (BYTE)( nRetValue >> 8 ), (BYTE)( nRetValue >> 16 ) );
+
+ aSet.Put( XFillColorItem( String(), aColor ) );
+ aSet.Put( XFillStyleItem( XFILL_SOLID ) );
+ pObj->SetItemSetAndBroadcast( aSet );
+ }
+ }
+ }
+ }
+
+ delete pLibrary;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SdCGMFilter::Export()
+{
+ ::vos::OModule* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
+ sal_Bool bRet = sal_False;
+
+ if( pLibrary && mxModel.is() )
+ {
+ ExportCGM FncCGMExport = ( ExportCGM ) pLibrary->getSymbol( ::rtl::OUString::createFromAscii( "ExportCGM" ) );
+
+ if( FncCGMExport )
+ {
+ ::rtl::OUString aPhysicalName( mrMedium.GetPhysicalName() );
+
+ /* !!!
+ if ( pViewShell && pViewShell->GetView() )
+ pViewShell->GetView()->EndTextEdit();
+ */
+ CreateStatusIndicator();
+ bRet = FncCGMExport( aPhysicalName, mxModel, mxStatusIndicator, NULL );
+ }
+ }
+
+ delete pLibrary;
+
+ return bRet;
+}
diff --git a/sd/source/filter/grf/makefile.mk b/sd/source/filter/grf/makefile.mk
new file mode 100644
index 000000000000..9cbe7efb758d
--- /dev/null
+++ b/sd/source/filter/grf/makefile.mk
@@ -0,0 +1,80 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: ka $ $Date: 2001-02-13 12:08:24 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=sd
+TARGET=grf
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = $(SLO)$/sdgrffilter.obj
+
+# --- Targets --------------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/sd/source/filter/grf/sdgrffilter.cxx b/sd/source/filter/grf/sdgrffilter.cxx
new file mode 100644
index 000000000000..45e0b2914881
--- /dev/null
+++ b/sd/source/filter/grf/sdgrffilter.cxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * $RCSfile: sdgrffilter.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: ka $ $Date: 2001-02-13 12:08:24 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <tools/errinf.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <svx/impgrf.hxx>
+#include <svx/svdograf.hxx>
+
+#ifndef MAC
+#ifndef SVX_LIGHT
+#include "../../ui/inc/strings.hrc"
+#include "../../ui/inc/graphpro.hxx"
+#endif //!SVX_LIGHT
+#else //MAC
+#ifndef SVX_LIGHT
+#include "strings.hrc"
+#include "graphpro.hxx"
+#endif //!SVX_LIGHT
+#endif //!MAC
+
+
+#include "sdpage.hxx"
+#include "drawdoc.hxx"
+#include "sdresid.hxx"
+#include "sdgrffilter.hxx"
+
+// ---------------
+// - SdPPTFilter -
+// ---------------
+
+SdGRFFilter::SdGRFFilter( SfxMedium& rMedium, SdDrawDocShell& rDocShell, sal_Bool bShowProgress ) :
+ SdFilter( rMedium, rDocShell, bShowProgress )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SdGRFFilter::~SdGRFFilter()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SdGRFFilter::HandleGraphicFilterError( USHORT nFilterError, ULONG nStreamError )
+{
+ USHORT nId;
+
+ switch( nFilterError )
+ {
+ case GRFILTER_OPENERROR:
+ nId = STR_IMPORT_GRFILTER_OPENERROR;
+ break;
+ case GRFILTER_IOERROR:
+ nId = STR_IMPORT_GRFILTER_IOERROR;
+ break;
+ case GRFILTER_FORMATERROR:
+ nId = STR_IMPORT_GRFILTER_FORMATERROR;
+ break;
+ case GRFILTER_VERSIONERROR:
+ nId = STR_IMPORT_GRFILTER_VERSIONERROR;
+ break;
+ case GRFILTER_FILTERERROR:
+ nId = STR_IMPORT_GRFILTER_FILTERERROR;
+ break;
+ case GRFILTER_TOOBIG:
+ nId = STR_IMPORT_GRFILTER_TOOBIG;
+ break;
+ default:
+ nId = STR_IMPORT_GRFILTER_FILTERERROR;
+ break;
+ }
+
+ if( ERRCODE_NONE != nStreamError )
+ ErrorHandler::HandleError( nStreamError );
+ else if( STR_IMPORT_GRFILTER_IOERROR == nId )
+ ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
+ else
+ {
+ ErrorBox aErrorBox( NULL, WB_OK, String( SdResId( nId ) ) );
+ aErrorBox.Execute();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SdGRFFilter::Import()
+{
+ Graphic aGraphic;
+ const String aName( mrMedium.GetFilter()->GetName() );
+ const String aFileName( mrMedium.GetURLObject().GetMainURL() );
+ GraphicFilter* pGraphicFilter = GetGrfFilter();
+ const USHORT nFilter = pGraphicFilter->GetImportFormatNumber( aName );
+ sal_Bool bRet = sal_False;
+
+ // ggf. Filterdialog ausfuehren
+ if ( !pGraphicFilter->HasImportDialog( nFilter ) || pGraphicFilter->DoImportDialog( NULL, nFilter ) )
+ {
+ SvStream* pIStm = mrMedium.GetInStream();
+ FilterProgress* pFilterProgress = mbShowProgress ? new FilterProgress( pGraphicFilter, &(SfxObjectShell&) mrDocShell ) : NULL;
+ USHORT nReturn = pIStm ? pGraphicFilter->ImportGraphic( aGraphic, aFileName, *pIStm, nFilter ) : 1;
+
+ if( nReturn )
+ HandleGraphicFilterError( nReturn, pGraphicFilter->GetLastError().nStreamError );
+ else
+ {
+ if( mrDocument.GetPageCount() == 0L )
+ mrDocument.CreateFirstPages();
+
+ SdPage* pPage = mrDocument.GetSdPage( 0, PK_STANDARD );
+ Point aPos;
+ Size aPagSize( pPage->GetSize() );
+ Size aGrfSize( OutputDevice::LogicToLogic( aGraphic.GetPrefSize(),
+ aGraphic.GetPrefMapMode(), MAP_100TH_MM ) );
+
+ aPagSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder();
+ aPagSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
+
+ // scale to fit page
+ if ( ( aGrfSize.Height() > aPagSize.Height() ) || (aGrfSize.Width() > aPagSize.Width() ) &&
+ aGrfSize.Height() && aPagSize.Height() )
+ {
+ double fGrfWH = (double) aGrfSize.Width() / aGrfSize.Height();
+ double fWinWH = (double) aPagSize.Width() / aPagSize.Height();
+
+ // Grafik an Pagesize anpassen (skaliert)
+ if( fGrfWH < fWinWH )
+ {
+ aGrfSize.Width() = (long) ( aPagSize.Height() * fGrfWH );
+ aGrfSize.Height() = aPagSize.Height();
+ }
+ else if( fGrfWH > 0.F )
+ {
+ aGrfSize.Width() = aPagSize.Width();
+ aGrfSize.Height()= (long) ( aPagSize.Width() / fGrfWH );
+ }
+ }
+
+ // Ausgaberechteck fuer Grafik setzen
+ aPos.X() = ( ( aPagSize.Width() - aGrfSize.Width() ) >> 1 ) + pPage->GetLftBorder();
+ aPos.Y() = ( ( aPagSize.Height() - aGrfSize.Height() ) >> 1 ) + pPage->GetUppBorder();
+
+ pPage->InsertObject( new SdrGrafObj( aGraphic, Rectangle( aPos, aGrfSize ) ) );
+ bRet = sal_True;
+ }
+
+ delete pFilterProgress;
+ }
+
+ return bRet;
+}
diff --git a/sd/source/filter/sdfilter.cxx b/sd/source/filter/sdfilter.cxx
new file mode 100644
index 000000000000..6a5dc8bfaa02
--- /dev/null
+++ b/sd/source/filter/sdfilter.cxx
@@ -0,0 +1,243 @@
+/*************************************************************************
+ *
+ * $RCSfile: sdfilter.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: ka $ $Date: 2001-02-13 12:05:19 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <tools/debug.hxx>
+#include <osl/file.hxx>
+#include <vos/module.hxx>
+#include <svtools/pathoptions.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/progress.hxx>
+
+#ifndef MAC
+#ifndef SVX_LIGHT
+#include "../../ui/inc/docshell.hxx"
+#include "../../ui/inc/strings.hrc"
+#endif //!SVX_LIGHT
+#else //MAC
+#ifndef SVX_LIGHT
+#include "docshell.hxx"
+#include "strings.hrc"
+#endif //!SVX_LIGHT
+#endif //!MAC
+
+#include "sdresid.hxx"
+#include "pres.hxx"
+#include "drawdoc.hxx"
+#include "sdfilter.hxx"
+
+// --------------
+// - Namespaces -
+// --------------
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::frame;
+
+// ------------
+// - SdFilter -
+// ------------
+
+SdFilter::SdFilter( SfxMedium& rMedium, SdDrawDocShell& rDocShell, sal_Bool bShowProgress ) :
+ mrMedium( rMedium ),
+ mrDocShell( rDocShell ),
+ mrDocument( *rDocShell.GetDoc() ),
+ mxModel( rDocShell.GetModel() ),
+ mpProgress( NULL ),
+ mbIsDraw( rDocShell.GetDocumentType() == DOCUMENT_TYPE_DRAW ),
+ mbShowProgress( bShowProgress )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SdFilter::~SdFilter()
+{
+ if( !mrDocShell.HasSpecialProgress() )
+ delete mpProgress;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SdFilter::ImplGetFullLibraryName( const ::rtl::OUString& rLibraryName ) const
+{
+ USHORT i,nq,npq;
+ String aLibrary( rLibraryName );
+ String aUPD( String::CreateFromInt32( SOLARUPD ) );
+ String aDllExt( RTL_CONSTASCII_USTRINGPARAM(__DLLEXTENSION));
+
+ aDllExt.Erase( 2 );
+
+ // Fragezeichen suchen
+ for( i = 0, nq = 0; aLibrary.GetChar(i)!=0; i++ )
+ {
+ if( aLibrary.GetChar(i) == '?' )
+ {
+ if( nq == 0 )
+ npq=i;
+
+ nq++;
+ }
+ else if( nq==aUPD.Len() )
+ break;
+ else
+ nq=0;
+ }
+
+ // Fragezeichen durch UPD-Nummer ersetzen
+ if( nq == aUPD.Len() )
+ aLibrary.Replace( npq, nq, aUPD );
+
+ // Sternchen suchen
+ for( i = 0, nq = 0; aLibrary.GetChar(i) != 0; i++ )
+ {
+ if( aLibrary.GetChar(i) == '*' )
+ {
+ if( nq == 0 )
+ npq=i;
+
+ nq++;
+ }
+ else if( nq == 2 )
+ break;
+ else
+ nq=0;
+ }
+
+ // Sternchen durch Plattform-Kuerzel ersetzen
+ if( nq == 2 )
+ aLibrary.Replace( npq, nq, aDllExt );
+
+ return aLibrary;
+}
+
+// -----------------------------------------------------------------------------
+
+::vos::OModule* SdFilter::OpenLibrary( const ::rtl::OUString& rLibraryName ) const
+{
+ ::rtl::OUString aDest;
+ ::rtl::OUString aNormalizedPath;
+ ::vos::OModule* pRet;
+
+ ::osl::FileBase::normalizePath( SvtPathOptions().GetFilterPath(), aDest );
+ aDest += ::rtl::OUString( sal_Unicode( '/' ) );
+ aDest += ::rtl::OUString( ImplGetFullLibraryName( rLibraryName ) );
+ ::osl::FileBase::getSystemPathFromNormalizedPath( aDest, aNormalizedPath );
+
+ if( !( pRet = new ::vos::OModule( aNormalizedPath ) )->isLoaded() )
+ delete pRet, pRet = NULL;
+
+ return pRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdFilter::CreateStatusIndicator()
+{
+ if( mxModel.is() )
+ {
+ Reference< XController > xController( mxModel->getCurrentController() );
+
+ if( xController.is() )
+ {
+ Reference< XFrame > xFrame( xController->getFrame() );
+
+ if( xFrame.is() )
+ {
+ Reference< XStatusIndicatorSupplier > xSupplier( xFrame, UNO_QUERY );
+
+ if( xSupplier.is() )
+ {
+ mxStatusIndicator = xSupplier->getStatusIndicator();
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdFilter::CreateProgress()
+{
+ if( mrDocShell.HasSpecialProgress() )
+ mpProgress = mrDocShell.GetSpecialProgress();
+ else
+ {
+ mpProgress = new SfxProgress( &mrDocShell, String( SdResId( STR_OPEN_DOCUMENT ) ), 100 );
+ mpProgress->SetState( 0, 100 );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SdFilter::Import()
+{
+ DBG_ERROR( "Not implemented" );
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SdFilter::Export()
+{
+ DBG_ERROR( "Not implemented" );
+ return sal_False;
+}