diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 15:18:56 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 15:18:56 +0000 |
commit | 95117e7fefa9ae82431dcdffd1e58495730f6f54 (patch) | |
tree | 158386e9f19cda5c69023d678c4d3313435a206d /extensions/source |
initial import
Diffstat (limited to 'extensions/source')
107 files changed, 40111 insertions, 0 deletions
diff --git a/extensions/source/bibliography/bib.hrc b/extensions/source/bibliography/bib.hrc new file mode 100644 index 000000000000..b2af8523b10e --- /dev/null +++ b/extensions/source/bibliography/bib.hrc @@ -0,0 +1,114 @@ +/************************************************************************* + * + * $RCSfile: bib.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 BIB_HRC +#define BIB_HRC + +#include <svtools/solar.hrc> + +#ifndef RID_BIB_START +#define RID_BIB_START RID_EXTENSIONS_START +#endif + +// ResIDs + +//Dialogs (100) +#define RID_BIB_DIALOG (RID_BIB_START) +#define RID_TP_GENERAL (RID_BIB_DIALOG) +#define RID_DLG_MAPPING (RID_BIB_DIALOG + 1) +#define RID_DLG_DBCHANGE (RID_BIB_DIALOG + 2) + +//Controls(100) +#define RID_BIB_CONTROLS (RID_BIB_START + 100) +#define RID_BIB_BMPEXPANDER (RID_BIB_CONTROLS) +#define RID_BIB_TOOLBAR (RID_BIB_CONTROLS+ 1) + +//Menu(100) +#define RID_BIB_MENU (RID_BIB_CONTROLS + 100) +#define RID_MAIN_MENU (RID_BIB_MENU +1) +//#define RID_MAIN_ME_HIERARCHICAL (RID_BIB_MENU +2) +#define RID_MAIN_ME_NEWENTRY (RID_BIB_MENU +3) +#define RID_MAIN_ME_CHANGEENTRY (RID_BIB_MENU +4) +#define RID_MAIN_ME_REMOVEENTRY (RID_BIB_MENU +5) +#define RID_MAIN_ME_SEARCH (RID_BIB_MENU +6) +#define RID_MAIN_ME_FIELDDLG (RID_BIB_MENU +7) +//#define RID_MAIN_ME_LAYOUT (RID_BIB_MENU +8) +#define RID_MAIN_ME_MAPPING (RID_BIB_MENU +9) +#define RID_MAIN_ME_DBSOURCE (RID_BIB_MENU +10) + +#define RID_POPUP_ME_VIEW (RID_BIB_MENU +50) + +// Strings (500) +#define RID_BIB_STRING (RID_BIB_START + 200) +#define RID_BIB_STR_SECTION (RID_BIB_STRING + 1) +#define RID_BIB_STR_FIELDSELECTION (RID_BIB_STRING + 2) +#define RID_BIB_STR_TABWIN_PREFIX (RID_BIB_STRING + 3) +#define RID_BIB_STR_FRAME_TITLE (RID_BIB_STRING + 4) +#define RID_MAP_QUESTION (RID_BIB_STRING + 5) + +// HelpIDs *** nicht bestaetigt *** +#ifndef HID_BIB_START +#define HID_BIB_START 5000 +#define HID_DLG_MAPPING (HID_BIB_START + 1) +#define HID_DLG_DBCHANGE (HID_BIB_START + 2) +#define HID_SELECTION_TLB (HID_BIB_START + 3) +#endif + +#endif diff --git a/extensions/source/bibliography/bib.src b/extensions/source/bibliography/bib.src new file mode 100644 index 000000000000..ed37b2ad2f0f --- /dev/null +++ b/extensions/source/bibliography/bib.src @@ -0,0 +1,187 @@ +/************************************************************************* + * + * $RCSfile: bib.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 "bib.hrc" + +ImageList RID_BIB_BMPEXPANDER +{ + ImageBitmap = Bitmap { File = "expander.bmp" ; }; + IdList = { 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; }; + IdCount = { 9 ; }; +}; + +String RID_BIB_STR_SECTION +{ + Text = "Abschnitt"; + Text [ ENGLISH ] = "Section" ; + Text[ english_us ] = "Section"; + Text[ portuguese ] = "Secção"; + Text[ russian ] = "Ðàçäåë"; + Text[ greek ] = "ÔïìÝáò"; + Text[ dutch ] = "Sectie"; + Text[ french ] = "Section"; + Text[ spanish ] = "Sección"; + Text[ italian ] = "Sezione"; + Text[ danish ] = "Sektion"; + Text[ swedish ] = "Avsnitt"; + Text[ polish ] = "Sekcja"; + Text[ portuguese_brazilian ] = "Section"; + Text[ japanese ] = "¾¸¼®Ý"; + Text[ korean ] = "±¸¿ª"; + Text[ chinese_simplified ] = "¶ÎÂä"; + Text[ chinese_traditional ] = "°Ï¬q"; + Text[ arabic ] = "äØÇÞ"; + Text[ turkish ] = "Bölüm"; +}; + +String RID_BIB_STR_FIELDSELECTION +{ + Text = "Feldauswahl:" ; + Text [ English ] = "Fieldselection:" ; + Text[ english_us ] = "Field selection:"; + Text[ portuguese ] = "Selecção de campo:"; + Text[ russian ] = "Âûáîð ïîëÿ:"; + Text[ greek ] = "ÅðéëïãÞ ðåäßïõ:"; + Text[ dutch ] = "Veldselectie:"; + Text[ french ] = "Sélection de champ :"; + Text[ spanish ] = "Selección de campo:"; + Text[ italian ] = "Selezione campo:"; + Text[ danish ] = "Feltudvalg:"; + Text[ swedish ] = "Fälturval:"; + Text[ polish ] = "Wybór pola:"; + Text[ portuguese_brazilian ] = "Fieldselection:"; + Text[ japanese ] = "̨°ÙÄÞ‘I‘ð:"; + Text[ korean ] = "ÇÊµå ¼±ÅÃ:"; + Text[ chinese_simplified ] = "ÇøÓòÑ¡Ôñ£º"; + Text[ chinese_traditional ] = "¿ï¾ÜÄæ¦ì¡G"; + Text[ arabic ] = "ÇÎÊíÇÑ ÇáÍÞá:"; + Text[ turkish ] = "Alan seçimi:"; + Text[ language_user1 ] = " "; +}; + +String RID_BIB_STR_TABWIN_PREFIX +{ + Text = "Tabelle;Abfrage;Sql;Sql [Native]" ; + Text [ English ] = "Table;Query;Sql;Sql [Native]" ; + Text[ english_us ] = "Table;Query;Sql;Sql [Native]"; + Text[ portuguese ] = "Tabela; Consulta; Sql;Sql [Native]"; + Text[ russian ] = "Òàáëèöà;Çàïðîñ;Sql;Sql [Native]"; + Text[ greek ] = "Ðßíáêáò;Åñþôçìá;Sql;Sql [Native]"; + Text[ dutch ] = "Tabel;Query;Sql;Sql [Native]"; + Text[ french ] = "Table;Requête;Sql;Sql [Natif]"; + Text[ spanish ] = "Tabla;Consulta;Sql;Sql [Native]"; + Text[ italian ] = "Tabella;Ricerca;Sql;Sql [native]"; + Text[ danish ] = "Tabel;Forespørgsel;Sql;Sql [native]"; + Text[ swedish ] = "Tabell;Sökning;Sql;Sql [Native]"; + Text[ polish ] = "Tabela;Kwerenda;Sql;Sql [Native]"; + Text[ portuguese_brazilian ] = "Table;Query;Sql;Sql [Native]"; + Text[ japanese ] = "ðÌÞÙ;¸´Ø°;Sql;Sql [Native]"; + Text[ korean ] = "Å×À̺í;ÁúÀÇ;Sql;Sql [Native]"; + Text[ chinese_simplified ] = "±í¸ñ;²éѯ;Sql;Sql [Native]"; + Text[ chinese_traditional ] = "ªí®æ;¬d¸ß;Sql;Sql [Native]"; + Text[ arabic ] = "ÌÏæá;ÇÓÊÝÓÇÑ;Sql;Sql [Native]"; + Text[ turkish ] = "Tablo;Sorgu;Sql;Sql [Native]"; +}; +String RID_BIB_STR_FRAME_TITLE +{ + Text = "Literaturdatenbank" ; + Text [ English ] = "Bibliography database" ; + Text[ english_us ] = "Bibliography Database"; + Text[ portuguese ] = "Base de dados bibliográfica"; + Text[ russian ] = "Áàçà äàííûõ áèáëèîãðàôèè"; + Text[ greek ] = "ÂÜóç äåäïìÝíùí âéâëéïãñáößáò"; + Text[ dutch ] = "Literatuurdatabase"; + Text[ french ] = "Base de données bibliographique"; + Text[ spanish ] = "Base de datos bibliográfica"; + Text[ italian ] = "Database bibliografico"; + Text[ danish ] = "Litteraturdatabase"; + Text[ swedish ] = "Litteraturdatabas"; + Text[ polish ] = "Bibliograficzna baza danych"; + Text[ portuguese_brazilian ] = "Bibliography database"; + Text[ japanese ] = "‘ ‘ŠÇ—ÃÞ°ÀÍÞ°½"; + Text[ korean ] = "Âü°í¹®Çå µ¥ÀÌÅͺ£À̽º"; + Text[ chinese_simplified ] = "ÎÄÏ×Êý¾Ý¿â"; + Text[ chinese_traditional ] = "¤åÄm¸ê®Æ®w"; + Text[ arabic ] = "ÞÇÚÏÉ ÈíÇäÇÊ ÇáãÑÇÌÚ"; + Text[ turkish ] = "Kaynakça veritabaný"; +}; +String RID_MAP_QUESTION +{ + Text = "Möchten Sie die Spaltenzuordnung bearbeiten?" ; + Text [ English ] = "Dow you want to edit the column arrangement" ; + Text[ english_us ] = "Do you want to edit the column arrangement?"; + Text[ portuguese ] = "Editar disposição de colunas?"; + Text[ russian ] = "Âû õîòèòå èçìåíèòü ðàçìåùåíèå êîëîíîê?"; + Text[ greek ] = "ÈÝëåôå íá ãßíåé åðåîåñãáóßá ôçò áíôéóôïß÷éóçò óôçëþí;"; + Text[ dutch ] = "Wilt u de kolomindeling veranderen?"; + Text[ french ] = "Souhaitez-vous éditer l'assignation des colonnes ?"; + Text[ spanish ] = "¿Desea modificar el orden de las columnas?"; + Text[ italian ] = "Volete modificare l'ordine delle colonne?"; + Text[ danish ] = "Vil du redigere kolonnetildelingen?"; + Text[ swedish ] = "Vill Du redigera kolumntilldelningen?"; + Text[ polish ] = "Chcesz edytowaæ przyporz¹dkowanie kolumn?"; + Text[ portuguese_brazilian ] = "Dow you want to edit the column arrangement"; + Text[ japanese ] = "—ñ‚Ì•ª—Þ‚ð•ÒW‚µ‚Ü‚·‚©?"; + Text[ korean ] = "¿ ¹è¿À» ÆíÁýÇϽðڽÀ´Ï±î?"; + Text[ chinese_simplified ] = "ÄúÒª±à¼ÁеÄÅÅÁÐ˳Ðò£¿"; + Text[ chinese_traditional ] = "±zn½s±ÆÄæ¡H"; + Text[ arabic ] = "åá ÊÑíÏ ÊÍÑíÑ ÊÚííä ÇáÚãæÏ¿"; + Text[ turkish ] = "Sütunlarý düzenlemek istiyor musunuz?"; +}; diff --git a/extensions/source/bibliography/bibbeam.cxx b/extensions/source/bibliography/bibbeam.cxx new file mode 100644 index 000000000000..7848eab220b1 --- /dev/null +++ b/extensions/source/bibliography/bibbeam.cxx @@ -0,0 +1,309 @@ +/************************************************************************* + * + * $RCSfile: bibbeam.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef _TOOLKIT_UNOHLP_HXX +#include <toolkit/helper/vclunohelper.hxx> +#endif + +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ +#include <unotools/processfactory.hxx> +#endif + +#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_ +#include <com/sun/star/awt/PosSize.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ +#include <com/sun/star/frame/XDispatch.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ +#include <com/sun/star/util/XURLTransformer.hpp> +#endif + +#include <svtools/iniprop.hxx> +#include <svtools/iniman.hxx> +#include <extensio.hrc> + +#ifndef _SV_LSTBOX_HXX //autogen wg. form::component::ListBox +#include <vcl/lstbox.hxx> +#endif + +#ifndef _SV_EDIT_HXX //autogen wg. Edit +#include <vcl/edit.hxx> +#endif + +#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT +#include <tools/debug.hxx> +#endif + +#include "bibbeam.hxx" +#include "toolbar.hrc" +#include "bibresid.hxx" +#include "datman.hxx" + +using namespace rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; + +#define C2U(cChar) OUString::createFromAscii(cChar) + +#define PROPERTY_FRAME 1 +#define ID_TOOLBAR 1 +#define ID_GRIDWIN 2 +#define ID_ALPHAWIN 3 + +rtl::OUString gGridModelCommand( OUString::createFromAscii(".uno:Bib/newGridModel")); + +BibGridwin::BibGridwin(Window* pParent, WinBits nStyle): + DockingWindow(pParent,nStyle) +{ + aCtrContainer = VCLUnoHelper::CreateControlContainer(this); +} + +BibGridwin::~BibGridwin() +{ +} + +void BibGridwin::Resize() +{ + if(xGridWinRef.is()) + { + ::Size aSize = GetOutputSizePixel(); + xGridWinRef->setPosSize(0, 0, aSize.Width(),aSize.Height(), PosSize::SIZE); + } +} +void BibGridwin::createGridWin(const uno::Reference< XControlModel > & xGModel) +{ + xGridModel=xGModel; + + if( aCtrContainer.is()) + { + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + + if ( xGridModel.is() && xMgr.is()) + { + uno::Reference< XPropertySet > xPropSet( xGridModel, UNO_QUERY ); + + if ( xPropSet.is() && xGridModel.is() ) + { + uno::Any aAny = xPropSet->getPropertyValue( C2U("DefaultControl") ); + rtl::OUString aControlName; + aAny >>= aControlName; + + xControl=uno::Reference< XControl > (xMgr->createInstance( aControlName ), UNO_QUERY ); + if ( xControl.is() ) + { + xControl->setModel( xGridModel); + } + } + + if ( xControl.is() ) + { + // Peer als Child zu dem FrameWindow + aCtrContainer->addControl(C2U("Bla"), xControl); + xGridWinRef=uno::Reference< XWindow > (xControl, UNO_QUERY ); + xGridWinRef->setVisible( sal_True ); + xControl->setDesignMode(sal_False); + ::Size aSize = GetOutputSizePixel(); + xGridWinRef->setPosSize(0, 0, aSize.Width(),aSize.Height(), PosSize::POSSIZE); +// Window* pWindow = ::GetWindow( xGridWinRef ); +// pWindow->SetHelpId(HID_BIB_DB_GRIDCTRL); + + } + } + } +} + +void BibGridwin::disposeGridWin() +{ + if ( xControl.is() ) + { + aCtrContainer->removeControl(xControl); + xControl->dispose(); + } +} + +void BibGridwin::changeGridModel(const uno::Reference< XControlModel > & xGModel) +{ + xGridModel=xGModel; + + if ( xControl.is() ) + { + xControl->setModel( xGridModel); + } +} + + +void BibGridwin::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException ) +{ + if(rEvt.FeatureURL.Complete == gGridModelCommand) + { + if(IsEnabled() != rEvt.IsEnabled) Enable(rEvt.IsEnabled); + + uno::Any aModel=rEvt.State; + if(aModel.getValueType()==::getCppuType((Reference< XControlModel>*)0)) + { + uno::Reference< XControlModel > xGModel=*(uno::Reference< XControlModel > *) aModel.getValue(); + changeGridModel(xGModel); + } + } +}; + + + + +BibBeamer::BibBeamer(Window* pParent,BibDataManager* pDM, WinBits nStyle): + SplitWindow(pParent,nStyle|WB_NOSPLITDRAW), + pDatMan(pDM), + pToolBar (NULL), + pGridWin (NULL), + pAlphaWin(NULL) +{ + createToolBar(); + createGridWin(); + createAlphaWin(); + pDatMan->SetToolbar(pToolBar); + pDatMan->SetGridWin(pGridWin); +} + +BibBeamer::~BibBeamer() +{ + if ( xToolBarRef.is() ) xToolBarRef->dispose(); + if ( xGridRef.is() ) xGridRef->dispose(); + if ( xAlphaRef.is() ) xAlphaRef->dispose(); + + + if(pToolBar) + { + if(pDatMan) + { + pDatMan->SetToolbar(0); + pDatMan->SetGridWin(0); + } + + delete pToolBar; + } + + if(pGridWin) + { + pGridWin->disposeGridWin(); +// delete pGridWin; + xpGridWin = 0; + } + + if(pAlphaWin) delete pAlphaWin; +} + +void BibBeamer::createToolBar() +{ + pToolBar= new BibToolBar(this); + ::Size aSize=pToolBar->GetSizePixel(); + InsertItem(ID_TOOLBAR, pToolBar, aSize.Height(), 0, 0, SWIB_FIXED ); + if(xController.is()) pToolBar->SetXController(xController); +} +void BibBeamer::createGridWin() +{ + xpGridWin = pGridWin= new BibGridwin(this,0); + + InsertItem(ID_GRIDWIN, pGridWin, 40, 1, 0, SWIB_RELATIVESIZE ); + + + pGridWin->createGridWin(pDatMan->createGridModel()); +} + +void BibBeamer::createAlphaWin() +{ +} + +void BibBeamer::SetXController(const uno::Reference< frame::XController > & xCtr) +{ + xController=xCtr; + + if(xController.is()) + { + uno::Reference< frame::XDispatch > xDisp(xController, UNO_QUERY); + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY ); + if( xTrans.is() && xDisp.is()) + { + util::URL aURL; + aURL.Complete =gGridModelCommand; + + xTrans->parseStrict( aURL ); + xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pGridWin),aURL); + } + } + + if(pToolBar) + { + pToolBar->SetXController(xController); + } + +} + + diff --git a/extensions/source/bibliography/bibbeam.hxx b/extensions/source/bibliography/bibbeam.hxx new file mode 100644 index 000000000000..8fd7f4b81174 --- /dev/null +++ b/extensions/source/bibliography/bibbeam.hxx @@ -0,0 +1,169 @@ +/************************************************************************* + * + * $RCSfile: bibbeam.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 ADRBEAM_HXX +#define ADRBEAM_HXX + +#ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_ +#include <com/sun/star/awt/XControlContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROL_HPP_ +#include <com/sun/star/awt/XControl.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROLMODEL_HPP_ +#include <com/sun/star/awt/XControlModel.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_ +#include <com/sun/star/form/XForm.hpp> +#endif + + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> // helper for implementations +#endif + +#ifndef _SV_SPLITWIN_HXX +#include <vcl/splitwin.hxx> +#endif + + +#ifndef _BIB_TOOLBAR_HXX +#include "toolbar.hxx" +#endif + +extern rtl::OUString gGridModelCommand; + +class BibDataManager; + +class BibGridwin: public DockingWindow, + public cppu::WeakImplHelper1 < ::com::sun::star::frame::XStatusListener> +{ +private: + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xGridWinRef; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > xForm; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > xGridModel; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > xControl; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > aCtrContainer; + +protected: + + void Resize(); + +public: + + BibGridwin(Window* pParent, WinBits nStyle = 0 ); + ~BibGridwin(); + + void createGridWin(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & xDbForm); + void changeGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & xGModel); + void disposeGridWin(); + + // ::com::sun::star::lang::XEventListener + // we do not hold References to dispatches, so there is nothing to do on disposal + virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) + throw( ::com::sun::star::uno::RuntimeException ){}; + + // ::com::sun::star::frame::XStatusListener + virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) + throw( ::com::sun::star::uno::RuntimeException ); + +}; + + +class BibBeamer: public SplitWindow +{ + private: + + BibDataManager* pDatMan; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xController; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > xForm; + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xToolBarRef; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xGridRef; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xAlphaRef; + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xToolBarWinRef; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xGridWinRef; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xAlphaWinRef; + + BibToolBar* pToolBar; + BibGridwin* pGridWin; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener> xpGridWin; + DockingWindow* pAlphaWin; + + protected: + + void createToolBar(); + void createGridWin(); + void createAlphaWin(); + + public: + + BibBeamer(Window* pParent,BibDataManager* pDatMan, WinBits nStyle = 0 ); + ~BibBeamer(); + + void SetXController(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > &); +}; + + + + +#endif diff --git a/extensions/source/bibliography/bibcont.cxx b/extensions/source/bibliography/bibcont.cxx new file mode 100644 index 000000000000..49dca576f05b --- /dev/null +++ b/extensions/source/bibliography/bibcont.cxx @@ -0,0 +1,372 @@ +/************************************************************************* + * + * $RCSfile: bibcont.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 <osl/mutex.hxx> +#include <tools/urlobj.hxx> +#include <cppuhelper/weak.hxx> +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ +#include <unotools/processfactory.hxx> +#endif +#include <toolkit/helper/vclunohelper.hxx> +#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ +#include <com/sun/star/awt/XWindow.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XWINDOWPEER_HPP_ +#include <com/sun/star/awt/XWindowPeer.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ +#include <com/sun/star/frame/XDispatchProvider.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ +#include <com/sun/star/util/XURLTransformer.hpp> +#endif + + +#include <svtools/iniprop.hxx> +#include <svtools/iniman.hxx> + +#include "datman.hxx" +#include "bibcont.hxx" + +using namespace vos; +using namespace osl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::rtl; + +#define C2U(cChar) OUString::createFromAscii(cChar) +#define PROPERTY_FRAME 1 + + +BibWindowContainer::BibWindowContainer( Window* pParent,WinBits nStyle): + DockingWindow(pParent,nStyle), + pChild(NULL) +{ +} + +BibWindowContainer::BibWindowContainer( Window* pParent,Window* pWin, WinBits nStyle): + DockingWindow(pParent,nStyle), + pChild(pWin) +{ + if(pChild!=NULL) + { + pChild->SetParent(this); + pChild->Show(); + pChild->SetPosPixel(Point(0,0)); + } +} + +BibWindowContainer::~BibWindowContainer() +{ + if(pChild!=NULL) delete pChild; +} + +void BibWindowContainer::Resize() +{ + ::Size aSize=GetOutputSizePixel(); + if(pChild!=NULL) pChild->SetSizePixel(aSize); +} + +void BibWindowContainer::SetChild(Window* pWin) +{ + pChild=pWin; + if(pChild!=NULL) + { + pChild->SetParent(this); + pChild->Show(); + pChild->SetPosPixel(Point(0,0)); + } +} + + + +BibBookContainer::BibBookContainer(Window* pParent,BibDataManager* pDtMn, WinBits nStyle): + SplitWindow(pParent,nStyle), + pDatMan(pDtMn), + pTopWin(NULL), + pBottomWin(NULL), + bFirstTime(sal_True) +{ + pBibMod = OpenBibModul(); + aTimer.SetTimeoutHdl(LINK( this, BibBookContainer, SplitHdl)); + aTimer.SetTimeout(400); +} + +BibBookContainer::~BibBookContainer() +{ + if ( xTopFrameRef.is() ) + xTopFrameRef->dispose(); + if ( xBottomFrameRef.is() ) + xBottomFrameRef->dispose(); + + if(pTopWin) + delete pTopWin; + if(pBottomWin) + delete pBottomWin; + CloseBibModul(pBibMod); +} + +void BibBookContainer::Split() +{ + aTimer.Start(); +} +IMPL_LINK( BibBookContainer, SplitHdl, Timer*,pT) +{ + long nSize= GetItemSize( TOP_WINDOW); + pDatMan->setBeamerSize(nSize); + nSize= GetItemSize( BOTTOM_WINDOW); + pDatMan->setViewSize(nSize); + return 0; +} + + +uno::Reference < awt::XWindowPeer> BibBookContainer::GetTopComponentInterface( sal_Bool bCreate) +{ + return pTopWin->GetComponentInterface(bCreate); +} +void BibBookContainer::SetTopComponentInterface( awt::XWindowPeer* pIFace ) +{ + pTopWin->SetComponentInterface(pIFace); +} + +uno::Reference < awt::XWindowPeer > BibBookContainer::GetBottomComponentInterface( sal_Bool bCreate) +{ + return pBottomWin->GetComponentInterface(bCreate); +} +void BibBookContainer::SetBottomComponentInterface( awt::XWindowPeer* pIFace ) +{ + pBottomWin->SetComponentInterface(pIFace); +} + +/*VCLXWindow* BibBookContainer::GetTopWindowPeer() +{ + return pTopWin->GetWindowPeer(); +} +*//*void BibBookContainer::SetTopWindowPeer( VCLXWindow* pPeer ) +{ + pTopWin->SetWindowPeer(pPeer ); +} +*/ +/*VCLXWindow* BibBookContainer::GetBottomWindowPeer() +{ + return pBottomWin->GetWindowPeer(); +} +*//*void BibBookContainer::SetBottomWindowPeer( VCLXWindow* pPeer ) +{ + pBottomWin->SetWindowPeer(pPeer ); +} +*/ + +void BibBookContainer::CreateTopWin() +{ + if ( xTopFrameRef.is() ) xTopFrameRef->dispose(); + + if(pTopWin) + { + RemoveItem(TOP_WINDOW); + delete pTopWin; + } + + pTopWin= new DockingWindow(this,0); + + long nSize=pDatMan->getBeamerSize(); + InsertItem(TOP_WINDOW, pTopWin, nSize, 0, 0, SWIB_PERCENTSIZE ); + +} + +void BibBookContainer::CreateBottomWin() +{ + + if ( xBottomFrameRef.is() ) xBottomFrameRef->dispose(); + + if(pBottomWin) + { + RemoveItem(BOTTOM_WINDOW); + delete pBottomWin; + } + + pBottomWin= new DockingWindow(this,0); + long nSize=pDatMan->getViewSize(); + InsertItem(BOTTOM_WINDOW, pBottomWin, nSize, 1, 0, SWIB_PERCENTSIZE ); + +} + +void BibBookContainer::createTopFrame(const ::rtl::OUString & rURL ) +{ + uno::Reference< frame::XFrame > xNewFrame; + + CreateTopWin(); + + xTopPeerRef=uno::Reference< awt::XWindow > (GetTopComponentInterface(), UNO_QUERY ); + + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + + xNewFrame = uno::Reference< frame::XFrame > ( xMgr->createInstance( C2U("com.sun.star.frame.Frame") ), UNO_QUERY ); + uno::Reference< frame::XDispatchProvider > xDSP( xNewFrame, UNO_QUERY ); + if( xDSP.is() ) + { + xNewFrame->initialize( xTopPeerRef); + + // optional: + //xFrame->setName( C2U("WhatYouWant") ); + + uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY ); + if( xTrans.is() ) + { + // Datei laden + util::URL aURL; + aURL.Complete = rURL; + + xTrans->parseStrict( aURL ); + + uno::Reference< frame::XDispatch > xDisp = xDSP->queryDispatch( aURL, C2U("_self"), FrameSearchFlag::SELF ); + if ( xDisp.is() ) + xDisp->dispatch( aURL, uno::Sequence<beans::PropertyValue>() ); + } + } + + // set the frame + { + MutexGuard aGuard(Mutex::getGlobalMutex()); + xTopFrameRef = xNewFrame; + } + +} + +void BibBookContainer::createBottomFrame(const ::rtl::OUString & rURL ) +{ + uno::Reference< frame::XFrame > xNewFrame; + + CreateBottomWin(); + + xBottomPeerRef=uno::Reference< awt::XWindow > (GetBottomComponentInterface(), UNO_QUERY ); + + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + + xNewFrame = uno::Reference< frame::XFrame > ( xMgr->createInstance( C2U("com.sun.star.frame.Frame") ), UNO_QUERY ); + uno::Reference< frame::XDispatchProvider > xDSP( xNewFrame, UNO_QUERY ); + if( xDSP.is() ) + { + xNewFrame->initialize( xBottomPeerRef); + + // optional: + //xFrame->setName( C2U("WhatYouWant") ); + + uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY ); + if( xTrans.is() ) + { + // Datei laden + util::URL aURL; + aURL.Complete = rURL; + + xTrans->parseStrict( aURL ); + + uno::Reference< frame::XDispatch > xDisp = xDSP->queryDispatch( aURL, ::rtl::OUString(), FrameSearchFlag::SELF ); + if ( xDisp.is() ) + xDisp->dispatch( aURL, uno::Sequence<beans::PropertyValue>() ); + } + } + + // set the frame + { + MutexGuard aGuard(Mutex::getGlobalMutex()); + xBottomFrameRef = xNewFrame; + } + +} + +void BibBookContainer::createTopFrame(Window* pWin) +{ + if ( xTopFrameRef.is() ) xTopFrameRef->dispose(); + + if(pTopWin) + { + RemoveItem(TOP_WINDOW); + delete pTopWin; + } + pTopWin=new BibWindowContainer(this,pWin); + + long nSize=pDatMan->getBeamerSize(); + InsertItem(TOP_WINDOW, pTopWin, nSize, 1, 0, SWIB_PERCENTSIZE ); + +} + +void BibBookContainer::createBottomFrame(Window* pWin) +{ + if ( xBottomFrameRef.is() ) xBottomFrameRef->dispose(); + + if(pBottomWin) + { + RemoveItem(BOTTOM_WINDOW); + delete pBottomWin; + } + + pBottomWin=new BibWindowContainer(this,pWin); + + long nSize=pDatMan->getViewSize(); + InsertItem(BOTTOM_WINDOW, pBottomWin, nSize, 1, 0, SWIB_PERCENTSIZE ); + +} + diff --git a/extensions/source/bibliography/bibcont.hxx b/extensions/source/bibliography/bibcont.hxx new file mode 100644 index 000000000000..4c10b15941c3 --- /dev/null +++ b/extensions/source/bibliography/bibcont.hxx @@ -0,0 +1,158 @@ +/************************************************************************* + * + * $RCSfile: bibcont.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 ADDRCONT_HXX +#define ADDRCONT_HXX + +#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ +#include <com/sun/star/frame/XFrame.hpp> +#endif + +#ifndef _SV_SPLITWIN_HXX +#include <vcl/splitwin.hxx> +#endif + +#ifndef _SV_TIMER_HXX //autogen wg. Timer +#include <vcl/timer.hxx> +#endif +#include "bibmod.hxx" + +#define TOP_WINDOW 1 +#define BOTTOM_WINDOW 2 + +class BibDataManager; + +class BibWindowContainer: public DockingWindow +{ + private: + Window* pChild; + + protected: + virtual void Resize(); + + public: + BibWindowContainer( Window* pParent,WinBits nStyle = 0); + BibWindowContainer( Window* pParent,Window* pChild, WinBits nStyle = 0 ); + ~BibWindowContainer(); + + Window* GetChild(){return pChild;} + void SetChild(Window* pWin); +}; + + +class BibBookContainer: public SplitWindow +{ + private: + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xTopFrameRef; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xBottomFrameRef; + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xTopPeerRef; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xBottomPeerRef; + sal_Bool bFirstTime; + + DockingWindow* pTopWin; + DockingWindow* pBottomWin; + BibDataManager* pDatMan; + HdlBibModul pBibMod; + Timer aTimer; + + DECL_LINK( SplitHdl, Timer*); + + protected: + + virtual void Split(); + + void CreateTopWin(); + void CreateBottomWin(); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetTopComponentInterface( sal_Bool bCreate = sal_True ); + void SetTopComponentInterface( ::com::sun::star::awt::XWindowPeer* pIFace ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetBottomComponentInterface( sal_Bool bCreate = sal_True ); + void SetBottomComponentInterface( ::com::sun::star::awt::XWindowPeer* pIFace ); + +// VCLXWindow* GetTopWindowPeer(); +// void SetTopWindowPeer( VCLXWindow* pPeer ); + +// VCLXWindow* GetBottomWindowPeer(); +// void SetBottomWindowPeer( VCLXWindow* pPeer ); + + public: + + BibBookContainer(Window* pParent,BibDataManager*, WinBits nStyle = 0 ); + ~BibBookContainer(); + + DockingWindow* GetTopWin() {return pTopWin;} + DockingWindow* GetBottomWin() {return pBottomWin;} + + + void createTopFrame(const rtl::OUString & rURL ); + + void createBottomFrame(const rtl::OUString & rURL ); + + void createTopFrame(Window* pWin); + + void createBottomFrame(Window* pWin); + +}; + + +#endif diff --git a/extensions/source/bibliography/bibload.cxx b/extensions/source/bibliography/bibload.cxx new file mode 100644 index 000000000000..d5f246c97bc9 --- /dev/null +++ b/extensions/source/bibliography/bibload.cxx @@ -0,0 +1,881 @@ +/************************************************************************* + * + * $RCSfile: bibload.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef _CPPUHELPER_WEAK_HXX_ +#include <cppuhelper/weak.hxx> +#endif +#ifndef _SFX_ITEMPROP_HXX +#include <svtools/itemprop.hxx> +#endif +#ifndef _UNO_ENVIRONMENT_H_ +#include <uno/environment.h> +#endif +#ifndef SVTOOLS_URIHELPER_HXX +#include <svtools/urihelper.hxx> +#endif +#ifndef _TOOLKIT_UNOHLP_HXX +#include <toolkit/helper/vclunohelper.hxx> +#endif +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ +#include <unotools/processfactory.hxx> +#endif +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> // helper for factories +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XCOLUMN_HPP_ +#include <com/sun/star/sdb/XColumn.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ +#include <com/sun/star/util/XURLTransformer.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_ +#include <com/sun/star/sdbc/XRowSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XFRAMELOADER_HPP_ +#include <com/sun/star/frame/XFrameLoader.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_TEXT_BIBLIOGRAPHYDATAFIELD_HPP_ +#include <com/sun/star/text/BibliographyDataField.hpp> +#endif + +#ifndef _SV_WINDOW_HXX +#include <vcl/window.hxx> +#endif +#ifndef _SV_EDIT_HXX +#include <vcl/edit.hxx> +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif + +#ifndef _SV_GROUP_HXX //autogen wg. form +#include <vcl/group.hxx> +#endif + +#ifndef _SFXINIPROP_HXX +#include <svtools/iniprop.hxx> +#endif +#ifndef _SFXINIMGR_HXX +#include <svtools/iniman.hxx> +#endif +#ifndef _SVEDIT_HXX +#include <svtools/svmedit.hxx> +#endif + +#ifndef BIB_HRC +#include "bib.hrc" +#endif +#ifndef ADDRCONT_HXX +#include "bibcont.hxx" +#endif +#ifndef ADRBEAM_HXX +#include "bibbeam.hxx" +#endif +#ifndef ADDRMOD_HXX +#include "bibmod.hxx" +#endif +#ifndef _BIB_VIEW_HXX +#include "bibview.hxx" +#endif +#ifndef _BIB_FRAMECTR_HXX +#include "framectr.hxx" +#endif +#ifndef _BIB_DATMAN_HXX +#include "datman.hxx" +#endif + +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include <cppuhelper/implbase4.hxx> // helper for implementations +#endif + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; + +#define C2U(cChar) OUString::createFromAscii(cChar) + + +//----------------------------------------------------------------------------- + +#define PROPERTY_FRAME 1 + +class BibliographyLoader : public cppu::WeakImplHelper4 +< + XServiceInfo, + container::XNameAccess, + XPropertySet, + frame::XFrameLoader +> +{ + HdlBibModul pBibMod; + Reference< XPropertyChangeListener > xDatMan; + BibDataManager* pDatMan; + Reference< container::XNameAccess > xColumns; + Reference< XResultSet > xCursor; + +private: + + void loadView(const Reference< frame::XFrame > & aFrame, const rtl::OUString& aURL, + const Sequence< PropertyValue >& aArgs, + const Reference< frame::XLoadEventListener > & aListener); + + BibDataManager* GetDataManager()const; + Reference< container::XNameAccess > GetDataColumns() const; + Reference< XResultSet > GetDataCursor() const; + Reference< sdb::XColumn > GetIdentifierColumn() const; + +public: + BibliographyLoader(); + ~BibliographyLoader(); + + // XServiceInfo + rtl::OUString SAL_CALL getImplementationName() throw( ); + sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ); + Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ); + static rtl::OUString getImplementationName_Static() throw( ) + + { + //! + return C2U("com.sun.star.extensions.Bibliography"); + //! + } + + //XNameAccess + virtual Any SAL_CALL getByName(const rtl::OUString& aName) throw ( container::NoSuchElementException, WrappedTargetException, RuntimeException ); + virtual Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw ( RuntimeException ); + virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& aName) throw ( RuntimeException ); + + //XElementAccess + virtual Type SAL_CALL getElementType(void) throw ( RuntimeException ); + virtual sal_Bool SAL_CALL hasElements(void) throw ( RuntimeException ); + + //XPropertySet + virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo(void) throw ( RuntimeException ); + virtual void SAL_CALL setPropertyValue(const rtl::OUString& PropertyName, const Any& aValue) throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException ); + virtual Any SAL_CALL getPropertyValue(const rtl::OUString& PropertyName) throw ( UnknownPropertyException, WrappedTargetException, RuntimeException ); + virtual void SAL_CALL addPropertyChangeListener(const rtl::OUString& PropertyName, const Reference< XPropertyChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException ); + virtual void SAL_CALL removePropertyChangeListener(const rtl::OUString& PropertyName, const Reference< XPropertyChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException ); + virtual void SAL_CALL addVetoableChangeListener(const rtl::OUString& PropertyName, const Reference< XVetoableChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException ); + virtual void SAL_CALL removeVetoableChangeListener(const rtl::OUString& PropertyName, const Reference< XVetoableChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException ); + + static Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames_Static(void) throw( ); + + friend Reference< XInterface > SAL_CALL BibliographyLoader_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception ); + + // XLoader + virtual void SAL_CALL load(const Reference< frame::XFrame > & aFrame, const rtl::OUString& aURL, + const Sequence< PropertyValue >& aArgs, + const Reference< frame::XLoadEventListener > & aListener); + virtual void SAL_CALL cancel(void); +}; + +BibliographyLoader::BibliographyLoader() : + pBibMod(0), + pDatMan(0) +{ +} + +BibliographyLoader::~BibliographyLoader() +{ + if(pBibMod) + CloseBibModul(pBibMod); +} + + +Reference< XInterface > SAL_CALL BibliographyLoader_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception ) +{ + return *(new BibliographyLoader); +} + + +// XServiceInfo +rtl::OUString BibliographyLoader::getImplementationName() throw( ) + +{ + return getImplementationName_Static(); +} + +// XServiceInfo +sal_Bool BibliographyLoader::supportsService(const rtl::OUString& ServiceName) throw( ) +{ + Sequence< rtl::OUString > aSNL = getSupportedServiceNames(); + const rtl::OUString * pArray = aSNL.getConstArray(); + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return sal_True; + return sal_False; +} + +// XServiceInfo +Sequence< rtl::OUString > BibliographyLoader::getSupportedServiceNames(void) throw( ) +{ + return getSupportedServiceNames_Static(); +} + +// ORegistryServiceManager_Static +Sequence< rtl::OUString > BibliographyLoader::getSupportedServiceNames_Static(void) throw( ) +{ + Sequence< rtl::OUString > aSNS( 2 ); + aSNS.getArray()[0] = C2U("com.sun.star.frame.FrameLoader"); + //! + aSNS.getArray()[1] = C2U("com.sun.star.frame.Bibliography"); + //! + return aSNS; +} + +extern "C" +{ + void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) + { + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; + } + + sal_Bool SAL_CALL component_writeInfo( void * //pServiceManager + , registry::XRegistryKey * pRegistryKey ) + { + try + { + rtl::OUString sKey = rtl::OUString::createFromAscii("/"); + sKey += BibliographyLoader::getImplementationName_Static(); + //creates the impl key: /com.sun.star.extensions.Bibliography + Reference< registry::XRegistryKey > xImplKey = pRegistryKey->createKey(sKey); + + + //sKey += rtl::OUString::createFromAscii("/UNO/SERVICES"); + Reference< registry::XRegistryKey > xNewKey = xImplKey->createKey( C2U("/UNO/SERVICES") ); + Sequence< rtl::OUString > aServices = BibliographyLoader::getSupportedServiceNames_Static(); + for( INT32 i = 0; i < aServices.getLength(); i++ ) + xNewKey->createKey( aServices.getConstArray()[i]); + xNewKey = xImplKey->createKey( C2U("/UNO/Loader")); + + Reference< registry::XRegistryKey > xPatternKey = xImplKey->createKey( C2U("/Loader/Pattern" )); + xPatternKey->setAsciiValue( C2U( ".component:Bibliography/*" ) ); + + return sal_True; + } + catch (Exception &) + { + return sal_False; + } + } + + + void * SAL_CALL component_getFactory( + const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * /*pRegistryKey*/ ) + { + void * pRet = 0; + if (!BibliographyLoader::getImplementationName_Static().compareToAscii( pImplName ) ) + { + // create the factory + Reference< XSingleServiceFactory > xFactory = + cppu::createSingleFactory( + pServiceManager, + BibliographyLoader::getImplementationName_Static(), + BibliographyLoader_CreateInstance, + BibliographyLoader::getSupportedServiceNames_Static() ); + // acquire, because we return an interface pointer instead of a reference + xFactory->acquire(); + pRet = xFactory.get(); + } + return pRet; + } + +} +// ----------------------------------------------------------------------- +void BibliographyLoader::cancel(void) +{ + //! + //! +} +// ----------------------------------------------------------------------- +void BibliographyLoader::load(const Reference< frame::XFrame > & rFrame, const rtl::OUString& rURL, + const Sequence< PropertyValue >& rArgs, + const Reference< frame::XLoadEventListener > & rListener) +{ + //! + + pBibMod = OpenBibModul(); + + String aURLStr( rURL ); + String aPartName = aURLStr.GetToken( 1, '/' ); + + if(aPartName.EqualsAscii("View") || aPartName.EqualsAscii("View1")) + { + loadView(rFrame, rURL, rArgs, rListener); + } +} + +// ----------------------------------------------------------------------- +void BibliographyLoader::loadView(const Reference< frame::XFrame > & rFrame, const rtl::OUString& rURL, + const Sequence< PropertyValue >& rArgs, + const Reference< frame::XLoadEventListener > & rListener) +{ + //! + if(!pBibMod) + pBibMod = OpenBibModul(); + + BibDataManager* pDatMan=(*pBibMod)->createDataManager(); + xDatMan = pDatMan; + String sTableName; + rtl::OUString aBibUrl=BibModul::GetBibliographyURL(&sTableName); + + Reference< form::XForm > xForm = pDatMan->createDatabaseForm(aBibUrl, OUString(sTableName)); + + if(xForm.is()) + { + Reference< awt::XWindow > aWindow = rFrame->getContainerWindow(); + + Window* pParent = VCLUnoHelper::GetWindow( aWindow ); + + BibBookContainer *pMyWindow = new BibBookContainer( pParent, pDatMan ); + + BibView* pView = new BibView(pMyWindow,pDatMan,WB_SECTION_STYLE); + pDatMan->SetView(pView); + + BibBeamer* pBeamer=new BibBeamer( pMyWindow,pDatMan); + pMyWindow->createTopFrame(pBeamer); + + pMyWindow->createBottomFrame(pView); + + Reference< awt::XWindow > xWin ( pMyWindow->GetComponentInterface(), UNO_QUERY ); + + Reference< frame::XController > xCtrRef(new BibFrameController_Impl( xWin,pDatMan)); + + xCtrRef->attachFrame(rFrame); + rFrame->setComponent( xWin, xCtrRef); + pBeamer->SetXController(xCtrRef); + //! + + long nBeamerSize = pDatMan->getBeamerSize(); + + pDatMan->loadDatabase(); + + ResMgr* pResMgr = (*pBibMod)->GetResMgr(); + INetURLObject aEntry( URIHelper::SmartRelToAbs(pResMgr->GetFileName()) ); + String aResFile = String::CreateFromAscii(".component:"); + ( aResFile += aEntry.GetName() ) += '/'; + String aMenuRes = aResFile; + aMenuRes+=String::CreateFromInt32(RID_MAIN_MENU); + + util::URL aURL; + aURL.Complete = aMenuRes; + + Reference< XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY ); + if( xTrans.is() ) + { + // Datei laden + xTrans->parseStrict( aURL ); + + Reference< frame::XDispatchProvider > xProv( rFrame, UNO_QUERY ); + if ( xProv.is() ) + { + Reference< frame::XDispatch > aDisp = xProv->queryDispatch( aURL, C2U("_tool:_menubar"), 0 ); + if ( aDisp.is() ) + aDisp->dispatch( aURL, Sequence<PropertyValue>() ); + } + } + if ( rListener.is() ) + rListener->loadFinished( this ); + } + else + { + if ( rListener.is() ) + rListener->loadCancelled( this ); + } +} +/* -----------------06.12.99 14:37------------------- + + --------------------------------------------------*/ +BibDataManager* BibliographyLoader::GetDataManager()const +{ + if(!pDatMan) + { + if(!pBibMod) + ((BibliographyLoader*)this)->pBibMod = OpenBibModul(); + ((BibliographyLoader*)this)->pDatMan = (*pBibMod)->createDataManager(); + ((BibliographyLoader*)this)->xDatMan = pDatMan; + } + return pDatMan; +} +/* -----------------06.12.99 14:39------------------- + + --------------------------------------------------*/ +Reference< container::XNameAccess > BibliographyLoader::GetDataColumns() const +{ + if (!xColumns.is()) + { + Reference< XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + Reference< XRowSet > xRowSet(xMgr->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY); + Reference< XPropertySet > xResultSetProps(xRowSet, UNO_QUERY); + DBG_ASSERT(xResultSetProps.is() , "BibliographyLoader::GetDataCursor : invalid row set (no XResultSet or no XPropertySet) !"); + + String sTableName; + rtl::OUString aBibUrl = BibModul::GetBibliographyURL(&sTableName); + + Any aBibUrlAny; aBibUrlAny <<= aBibUrl; + xResultSetProps->setPropertyValue(C2U("DataSourceName"), aBibUrlAny); + Any aCommandType; aCommandType <<= (sal_Int32)(CommandType::TABLE); + xResultSetProps->setPropertyValue(C2U("CommandType"), aCommandType); + Any aTableName; aTableName <<= OUString(sTableName); + xResultSetProps->setPropertyValue(C2U("Command"), aTableName); + Any aResultSetType; aResultSetType <<= (sal_Int32)(ResultSetType::SCROLL_INSENSITIVE); + xResultSetProps->setPropertyValue(C2U("ResultSetType"), aResultSetType); + Any aResultSetCurrency; aResultSetCurrency <<= (sal_Int32)(ResultSetConcurrency::UPDATABLE); + xResultSetProps->setPropertyValue(C2U("ResultSetConcurrency"), aResultSetCurrency); + + sal_Bool bSuccess = sal_False; + try + { + xRowSet->execute(); + bSuccess = sal_True; + } + catch(SQLException& e) + { +#ifdef DBG_UTIL + // TODO : show a real error message + String sMsg(String::CreateFromAscii("BibliographyLoader::GetDataCursor : could not execute the result set (catched an SQL-exception")); + sMsg += String(e.Message); + sMsg.AppendAscii(") !"); + DBG_ERROR( ByteString(sMsg, RTL_TEXTENCODING_ASCII_US ).GetBuffer()); +#endif + } + catch(...) + { + DBG_ERROR("BibliographyLoader::GetDataCursor : could not execute the result set !"); + bSuccess = sal_False; + } + + if (!bSuccess) + { + Reference< XComponent > xSetComp(xRowSet, UNO_QUERY); + if (xSetComp.is()) + xSetComp->dispose(); + xRowSet = NULL; + } + else + ((BibliographyLoader*)this)->xCursor = xRowSet.get(); + + Reference< sdbcx::XColumnsSupplier > xSupplyCols(xCursor, UNO_QUERY); + if (xSupplyCols.is()) + ((BibliographyLoader*)this)->xColumns = xSupplyCols->getColumns(); + } + + return xColumns; +} +/* -----------------17.12.99 12:29------------------- + + --------------------------------------------------*/ +Reference< sdb::XColumn > BibliographyLoader::GetIdentifierColumn() const +{ + BibDataManager* pDatMan = GetDataManager(); + Reference< container::XNameAccess > xColumns = GetDataColumns(); + rtl::OUString sIdentifierColumnName = pDatMan->GetIdentifierMapping(); + + Reference< sdb::XColumn > xReturn; + if (xColumns.is() && xColumns->hasByName(sIdentifierColumnName)) + { + xReturn = Reference< XColumn > (*(Reference< XInterface > *) + xColumns->getByName(sIdentifierColumnName).getValue(), UNO_QUERY); + } + return xReturn; +} + +/* -----------------06.12.99 15:05------------------- + + --------------------------------------------------*/ +Reference< XResultSet > BibliographyLoader::GetDataCursor() const +{ + if (!xCursor.is()) + GetDataColumns(); + if (xCursor.is()) + xCursor->first(); + return xCursor; +} + +/*-- 17.11.99 12:51:38--------------------------------------------------- + + -----------------------------------------------------------------------*/ +rtl::OUString lcl_AddProperty(Reference< container::XNameAccess > xColumns, + const Mapping* pMapping, const String& rColumnName) +{ + String sColumnName(rColumnName); + if(pMapping) + { + for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++) + { + if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == rColumnName) + { + sColumnName = pMapping->aColumnPairs[nEntry].sRealColumnName; + break; + } + } + } + rtl::OUString uColumnName(sColumnName); + rtl::OUString uRet; + Reference< sdb::XColumn > xCol; + if (xColumns->hasByName(uColumnName)) + xCol = Reference< sdb::XColumn > (*(Reference< XInterface > *)xColumns->getByName(uColumnName).getValue(), UNO_QUERY); + if (xCol.is()) + uRet = xCol->getString(); + return uRet; +} +//----------------------------------------------------------------------------- +Any BibliographyLoader::getByName(const rtl::OUString& rName) throw + ( container::NoSuchElementException, WrappedTargetException, RuntimeException ) +{ + Any aRet; + try + { + BibDataManager* pDatMan = ((BibliographyLoader*)this)->GetDataManager(); + Reference< XResultSet > xCursor = GetDataCursor(); + Reference< sdbcx::XColumnsSupplier > xSupplyCols(xCursor, UNO_QUERY); + Reference< container::XNameAccess > xColumns; + if (!xSupplyCols.is()) + return aRet; + xColumns = xSupplyCols->getColumns(); + DBG_ASSERT(xSupplyCols.is(), "BibliographyLoader::getByName : invalid columns returned by the data cursor (may be the result set is not alive ?) !"); + if (!xColumns.is()) + return aRet; + + String sIdentifierMapping = pDatMan->GetIdentifierMapping(); + rtl::OUString sId = sIdentifierMapping; + Reference< sdb::XColumn > xColumn; + if (xColumns->hasByName(sId)) + xColumn = Reference< sdb::XColumn > (*(Reference< XInterface > *)xColumns->getByName(sId).getValue(), UNO_QUERY); + if (xColumn.is()) + { + do + { + if ((rName == xColumn->getString()) && !xColumn->wasNull()) + { + Sequence<PropertyValue> aPropSequ(COLUMN_COUNT); + PropertyValue* pValues = aPropSequ.getArray(); + String sTableName; + rtl::OUString aBibUrl = BibModul::GetBibliographyURL(&sTableName); + const Mapping* pMapping = pDatMan->GetMapping(sTableName, &aBibUrl); + for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++) + { + const String sColName = pDatMan->GetDefColumnName( + nEntry); + pValues[nEntry].Name = sColName; + pValues[nEntry].Value <<= lcl_AddProperty(xColumns, pMapping, sColName); + } + aRet.setValue(&aPropSequ, ::getCppuType((Sequence<PropertyValue>*)0)); + + break; + } + } + while(xCursor->next()); + } + } + catch(...) + { + DBG_ERROR("Exception in BibliographyLoader::getByName") + } + return aRet; +} +/*-- 17.11.99 12:51:39--------------------------------------------------- + + -----------------------------------------------------------------------*/ +Sequence< rtl::OUString > BibliographyLoader::getElementNames(void) throw ( RuntimeException ) +{ + Sequence< rtl::OUString > aRet(10); + int nRealNameCount = 0; + try + { + BibDataManager* pDatMan = ((BibliographyLoader*)this)->GetDataManager(); + + Reference< XResultSet > xCursor(GetDataCursor()); + Reference< sdb::XColumn > xIdColumn(GetIdentifierColumn()); + if (xIdColumn.is()) // implies xCursor.is() + { + do + { + rtl::OUString sTemp = xIdColumn->getString(); + if (sTemp.len() && !xIdColumn->wasNull()) + { + int nLen = aRet.getLength(); + if (nLen = nRealNameCount) + aRet.realloc(nLen + 10); + rtl::OUString* pArray = aRet.getArray(); + pArray[nRealNameCount] = sTemp; + nRealNameCount++; + } + } + while (xCursor->next()); + } + } + catch(...) + { + DBG_ERROR("Exception in BibliographyLoader::getElementNames") + } + + aRet.realloc(nRealNameCount); + return aRet; +} +/*-- 17.11.99 12:51:39--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Bool BibliographyLoader::hasByName(const rtl::OUString& rName) throw ( RuntimeException ) +{ + sal_Bool bRet = sal_False; + try + { + BibDataManager* pDatMan = GetDataManager(); + Reference< XResultSet > xCursor = GetDataCursor(); + Reference< sdb::XColumn > xIdColumn = GetIdentifierColumn(); + + if (xIdColumn.is()) // implies xCursor.is() + { + do + { + rtl::OUString sCurrentId = xIdColumn->getString(); + if (!xIdColumn->wasNull() && (rName.compareTo(sCurrentId) == COMPARE_EQUAL)) + { + bRet = sal_True; + break; + } + } + while(xCursor->next()); + } + } + catch(...) + { + DBG_ERROR("Exception in BibliographyLoader::getElementNames") + } + return bRet; +} +/*-- 17.11.99 12:51:39--------------------------------------------------- + + -----------------------------------------------------------------------*/ +Type BibliographyLoader::getElementType(void) throw ( RuntimeException ) +{ + return ::getCppuType((Sequence<PropertyValue>*)0); +} +/*-- 17.11.99 12:51:40--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Bool BibliographyLoader::hasElements(void) throw ( RuntimeException ) +{ + Reference< XResultSet > xCursor = GetDataCursor(); + Reference< container::XNameAccess > xColumns = GetDataColumns(); + return xColumns.is() && (xColumns->getElementNames().getLength() != 0); +} + +/*-- 07.12.99 14:28:39--------------------------------------------------- + + -----------------------------------------------------------------------*/ +Reference< XPropertySetInfo > BibliographyLoader::getPropertySetInfo(void) throw + ( RuntimeException ) +{ + static SfxItemPropertyMap aBibProps_Impl[] = + { + { MAP_CHAR_LEN("BibliographyDataFieldNames"), 0, &::getCppuType((Sequence<PropertyValue>*)0), PropertyAttribute::READONLY, 0}, + {0,0,0,0} + }; + static Reference< XPropertySetInfo > xRet = + SfxItemPropertySet(aBibProps_Impl).getPropertySetInfo(); + return xRet; +} +/*-- 07.12.99 14:28:39--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void BibliographyLoader::setPropertyValue(const rtl::OUString& PropertyName, + const Any& aValue) + throw( UnknownPropertyException, PropertyVetoException, + IllegalArgumentException, WrappedTargetException, RuntimeException) +{ + throw UnknownPropertyException(); + //no changeable properties +} +/*-- 07.12.99 14:28:39--------------------------------------------------- + + -----------------------------------------------------------------------*/ +Any BibliographyLoader::getPropertyValue(const rtl::OUString& rPropertyName) + throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) +{ + Any aRet; + static const sal_uInt16 aInternalMapping[] = + { + IDENTIFIER_POS , // BibliographyDataField_IDENTIFIER + AUTHORITYTYPE_POS , // BibliographyDataField_BIBILIOGRAPHIC_TYPE + ADDRESS_POS , // BibliographyDataField_ADDRESS + ANNOTE_POS , // BibliographyDataField_ANNOTE + AUTHOR_POS , // BibliographyDataField_AUTHOR + BOOKTITLE_POS , // BibliographyDataField_BOOKTITLE + CHAPTER_POS , // BibliographyDataField_CHAPTER + EDITION_POS , // BibliographyDataField_EDITION + EDITOR_POS , // BibliographyDataField_EDITOR + HOWPUBLISHED_POS , // BibliographyDataField_HOWPUBLISHED + INSTITUTION_POS , // BibliographyDataField_INSTITUTION + JOURNAL_POS , // BibliographyDataField_JOURNAL + MONTH_POS , // BibliographyDataField_MONTH + NOTE_POS , // BibliographyDataField_NOTE + NUMBER_POS , // BibliographyDataField_NUMBER + ORGANIZATIONS_POS , // BibliographyDataField_ORGANIZATIONS + PAGES_POS , // BibliographyDataField_PAGES + PUBLISHER_POS , // BibliographyDataField_PUBLISHER + SCHOOL_POS , // BibliographyDataField_SCHOOL + SERIES_POS , // BibliographyDataField_SERIES + TITLE_POS , // BibliographyDataField_TITLE + REPORTTYPE_POS , // BibliographyDataField_REPORT_TYPE + VOLUME_POS , // BibliographyDataField_VOLUME + YEAR_POS , // BibliographyDataField_YEAR + URL_POS , // BibliographyDataField_URL + CUSTOM1_POS , // BibliographyDataField_CUSTOM1 + CUSTOM2_POS , // BibliographyDataField_CUSTOM2 + CUSTOM3_POS , // BibliographyDataField_CUSTOM3 + CUSTOM4_POS , // BibliographyDataField_CUSTOM4 + CUSTOM5_POS , // BibliographyDataField_CUSTOM5 + ISBN_POS //BibliographyDataField_ISBN + }; + if(C2U("BibliographyDataFieldNames") == rPropertyName) + { + Sequence<PropertyValue> aSeq(COLUMN_COUNT); + PropertyValue* pArray = aSeq.getArray(); + BibDataManager* pDatMan = GetDataManager(); + for(sal_uInt16 i = 0; i <= text::BibliographyDataField::ISBN ; i++) + { + pArray[i].Name = pDatMan->GetDefColumnName(aInternalMapping[i]); + pArray[i].Value <<= (sal_Int16) i; + } + aRet.setValue(&aSeq, ::getCppuType((Sequence<PropertyValue>*)0)); + } + else + throw UnknownPropertyException(); + return aRet; +} +/*-- 07.12.99 14:28:40--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void BibliographyLoader::addPropertyChangeListener( + const rtl::OUString& PropertyName, const Reference< XPropertyChangeListener > & aListener) + throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) +{ + //no bound properties +} +/*-- 07.12.99 14:28:40--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void BibliographyLoader::removePropertyChangeListener( + const rtl::OUString& PropertyName, const Reference< XPropertyChangeListener > & aListener) + throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) +{ + //no bound properties +} +/*-- 07.12.99 14:28:40--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void BibliographyLoader::addVetoableChangeListener( + const rtl::OUString& PropertyName, const Reference< XVetoableChangeListener > & aListener) + throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) +{ + //no vetoable properties +} +/*-- 07.12.99 14:28:40--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void BibliographyLoader::removeVetoableChangeListener( + const rtl::OUString& PropertyName, const Reference< XVetoableChangeListener > & aListener) + throw( UnknownPropertyException, WrappedTargetException, RuntimeException ) +{ + //no vetoable properties +} + + + diff --git a/extensions/source/bibliography/bibmod.cxx b/extensions/source/bibliography/bibmod.cxx new file mode 100644 index 000000000000..97cf120a2cd2 --- /dev/null +++ b/extensions/source/bibliography/bibmod.cxx @@ -0,0 +1,409 @@ +/************************************************************************* + * + * $RCSfile: bibmod.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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/resmgr.hxx> +#include <svtools/iniprop.hxx> +#include <svtools/iniman.hxx> +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef SVTOOLS_URIHELPER_HXX +#include <svtools/urihelper.hxx> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XLOCALIZEDALIASES_HPP_ +#include <com/sun/star/util/XLocalizedAliases.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XLOCALIZABLE_HPP_ +#include <com/sun/star/lang/XLocalizable.hpp> +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ +#include <unotools/processfactory.hxx> +#endif +#include "bibmod.hxx" +#include "bibresid.hxx" +#include "registry.hxx" +#include "datman.hxx" +static PtrBibModul pBibModul=NULL; +static nBibModulCount=0; + +#ifndef _UCBHELPER_CONTENT_HXX +#include <ucbhelper/content.hxx> +#endif + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::ucb; + +#define C2U(cChar) OUString::createFromAscii(cChar) +#define C2S(cChar) String::CreateFromAscii(cChar) + +HdlBibModul OpenBibModul() +{ + if(pBibModul==NULL) + { + pBibModul=new BibModul(); + } + nBibModulCount++; + return &pBibModul; +} + +void CloseBibModul(HdlBibModul ppBibModul) +{ + nBibModulCount--; + if(nBibModulCount==0 && ppBibModul!=NULL) + { + delete pBibModul; + pBibModul=NULL; + } +} + +/*PtrBibModul GetBibModul() +{ + return pBibModul; +} */ + +BibResId::BibResId( sal_uInt16 nId ) : + ResId( nId, pBibModul->GetResMgr() ) +{ +} + +BibModul::BibModul() +{ + pResMgr = ResMgr::CreateResMgr( "bib" MAKE_NUMSTR(SUPD) ); + pRegistry = new BibRegistry(); + xRegistry = pRegistry; +} + +BibModul::~BibModul() +{ + delete pResMgr; + xRegistry = 0; + //delete pRegistry; +} + +BibDataManager* BibModul::createDataManager() +{ + return new BibDataManager(pRegistry); +} +//----------------------------------------------------------------------------- +String BibModul::GetBibliographyURL(String* pTableName) +{ + String aURL; + SfxAppIniManagerProperty aProp; + GetpApp()->Property( aProp ); + SfxIniManager* pIniMan = aProp.GetIniManager(); + if( !pIniMan ) + return String(); + + String aBib = pIniMan->Get( C2S(BIBLIOGRAPHY_INI_GROUP), + sal_False, sal_False, + C2S(BIBLIOGRAPHY_INI_CUR_NAME)); + sal_Bool bCorrect = sal_False; + if(aBib.Len()) + { + aURL = aBib.GetToken( 0, ';' ); + aURL = pIniMan->SubstPathVars( aURL ); + aURL = URIHelper::SmartRelToAbs(aURL); + + INetURLObject aTmpURL(aURL); + BOOL bExist = FALSE; + if(aTmpURL.GetProtocol() == INET_PROT_FILE) + try + { + bExist = ::ucb::Content( + aTmpURL.GetMainURL(), uno::Reference< XCommandEnvironment >()).isDocument(); + } + catch(...){} + + if(bExist) + { + bCorrect = sal_True; + if(pTableName) + *pTableName = aBib.GetToken( 1, ';' ); + } + } + if(!bCorrect) + { + //if there's no entry defined take the first *.sdb from the database favorites + try + { + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + uno::Reference< container::XNameAccess > xDatabaseContext(xMgr->createInstance( + C2U("com.sun.star.sdb.DatabaseAccessContext") ), UNO_QUERY ); +// uno::Sequence<rtl::OUString> aFavorites; +// if (xDatabaseContext.is()) +// aFavorites = xDatabaseContext->getElementNames(); +// if (aFavorites.getLength()) +// aURL = INetURLObject::SmartRelToAbs(U2S(aFavorites.getConstArray()[0])); + Reference<XLocalizedAliases> xAlias(xDatabaseContext, UNO_QUERY); + Reference<XLocalizable> xLocal(xDatabaseContext, UNO_QUERY); + Sequence< AliasProgrammaticPair > aAliasPairs = + xAlias->listAliases(xLocal->getLocale()); + const AliasProgrammaticPair* pPairs = aAliasPairs.getConstArray(); + for(INT32 nFav = 0; nFav < aAliasPairs.getLength(); nFav++) + { + String sURL = pPairs[nFav].ProgrammaticName; + aURL = URIHelper::SmartRelToAbs(sURL); + INetURLObject aTmpURL(aURL); + BOOL bExist = FALSE; + if(aTmpURL.GetProtocol() == INET_PROT_FILE) + try + { + bExist = ::ucb::Content( + aTmpURL.GetMainURL(), uno::Reference< XCommandEnvironment >()).isDocument(); + } + catch(...){} + + if(bExist) + break; + else + aURL.Erase(); + } + + } + catch(...) + { + DBG_ERROR("Exception in BibDataManager::DBChangeDialog_Impl::DBChangeDialog_Impl") + } + + } + return aURL; +} +//----------------------------------------------------------------------------- +void BibModul::SetBibliographyURL(const String& rURL, const String& rTable) +{ + SfxAppIniManagerProperty aProp; + GetpApp()->Property( aProp ); + SfxIniManager* pIniMan = aProp.GetIniManager(); + if( !pIniMan ) + return; + + String sEntry(rURL); + sEntry = pIniMan->UsePathVars( sEntry ); + + sEntry += ';'; + sEntry += rTable; + + pIniMan->WriteKey( C2S(BIBLIOGRAPHY_INI_GROUP), + C2S(BIBLIOGRAPHY_INI_CUR_NAME), sEntry); +} + +// PropertyNames +#define STATIC_USTRING(a,b) rtl::OUString a(b) +STATIC_USTRING(FM_PROP_LABEL,C2U("Label")); +STATIC_USTRING(FM_PROP_CONTROLSOURCE,C2U("DataField")); +STATIC_USTRING(FM_PROP_NAME,C2U("Name")); +STATIC_USTRING(FM_PROP_FORMATKEY,C2U("FormatKey")); +#ifdef TF_SDBAPI +#else // !TF_SDBAPI +STATIC_USTRING(FM_PROP_EDITMODE,C2U("RecordMode")); +STATIC_USTRING(FM_PROP_CURSORSOURCETYPE,C2U("DataSelectionType")); +STATIC_USTRING(FM_PROP_CURSORSOURCE,C2U("DataSelection")); +STATIC_USTRING(FM_PROP_DATASOURCE, C2U("DataSource")); +#endif // !TF_SDBAPI +STATIC_USTRING(FM_PROP_VALUE,C2U("Value")); +STATIC_USTRING(FM_PROP_TEXT,C2U("Text")); +/* + +STATIC_USTRING(FM_PROP_TABINDEX,C2U("TabIndex")); +STATIC_USTRING(FM_PROP_TAG,C2U("Tag")); +STATIC_USTRING(FM_PROP_CLASSID,C2U("ClassId")); +STATIC_USTRING(FM_PROP_RECORDCOUNT,C2U("RecordCount")); +STATIC_USTRING(FM_PROP_RECORDSTATUS,C2U("RecordStatus")); +STATIC_USTRING(FM_PROP_RECORDCOUNTFINAL,C2U("IsRecordCountFinal")); +STATIC_USTRING(FM_PROP_CANINSERT,C2U("CanInsert")); +STATIC_USTRING(FM_PROP_CANUPDATE,C2U("CanUpdate")); +STATIC_USTRING(FM_PROP_CANDELETE,C2U("CanDelete")); +STATIC_USTRING(FM_PROP_NAVIGATION,C2U("NavigationBarMode")); +STATIC_USTRING(FM_PROP_HASNAVIGATION,C2U("HasNavigationBar")); +STATIC_USTRING(FM_PROP_CYCLE,C2U("Cycle")); +STATIC_USTRING(FM_PROP_ENABLED,C2U("Enabled")); +STATIC_USTRING(FM_PROP_READONLY,C2U("ReadOnly")); +STATIC_USTRING(FM_PROP_ISREADONLY,C2U("IsReadOnly")); +STATIC_USTRING(FM_PROP_FILTER_CRITERIA,C2U("Filter")); +STATIC_USTRING(FM_PROP_SORT_CRITERIA,C2U("SortOrder")); +STATIC_USTRING(FM_PROP_ISREQUIRED,C2U("IsRequired")); +STATIC_USTRING(FM_PROP_AUTOINCREMENT,C2U("IsAutoIncrement")); +STATIC_USTRING(FM_PROP_CACHESIZE,C2U("CacheSize")); +STATIC_USTRING(FM_PROP_DATAENTRY,C2U("DataEntry")); +STATIC_USTRING(FM_PROP_LASTDIRTY,C2U("LastUpdated")); +STATIC_USTRING(FM_PROP_STATEMENT,C2U("Statement")); +STATIC_USTRING(FM_PROP_WIDTH,C2U("Width")); +STATIC_USTRING(FM_PROP_SEARCHINFO,C2U("SearchInfo")); +STATIC_USTRING(FM_PROP_MULTILINE,C2U("MultiLine")); +STATIC_USTRING(FM_PROP_TARGET_URL,C2U("TargetURL")); +STATIC_USTRING(FM_PROP_TARGET_FRAME,C2U("TargetFrame")); +STATIC_USTRING(FM_PROP_DEFAULTCONTROL,C2U("DefaultControl")); +STATIC_USTRING(FM_PROP_MAXTEXTLEN,C2U("MaxTextLen")); +STATIC_USTRING(FM_PROP_EDITMASK,C2U("EditMask")); +STATIC_USTRING(FM_PROP_SIZE,C2U("Size")); +STATIC_USTRING(FM_PROP_SPIN,C2U("Spin")); +STATIC_USTRING(FM_PROP_DATE,C2U("Date")); +STATIC_USTRING(FM_PROP_TIME,C2U("Time")); +STATIC_USTRING(FM_PROP_STATE,C2U("State")); +STATIC_USTRING(FM_PROP_TRISTATE,C2U("TriState")); +STATIC_USTRING(FM_PROP_HIDDEN_VALUE, C2U("HiddenValue")); +STATIC_USTRING(FM_PROP_BUTTONTYPE,C2U("ButtonType")); +STATIC_USTRING(FM_PROP_STRINGITEMLIST,C2U("StringItemList")); +STATIC_USTRING(FM_PROP_DEFAULT_TEXT,C2U("DefaultText")); +STATIC_USTRING(FM_PROP_DEFAULTCHECKED,C2U("DefaultState")); +STATIC_USTRING(FM_PROP_FORMATSSUPPLIER,C2U("FormatsSupplier")); +STATIC_USTRING(FM_PROP_SUBMIT_ACTION,C2U("SubmitAction")); +STATIC_USTRING(FM_PROP_SUBMIT_TARGET,C2U("SubmitTarget")); +STATIC_USTRING(FM_PROP_SUBMIT_METHOD,C2U("SubmitMethod")); +STATIC_USTRING(FM_PROP_SUBMIT_ENCODING,C2U("SubmitEncoding")); +STATIC_USTRING(FM_PROP_IMAGE_URL,C2U("ImageURL")); +STATIC_USTRING(FM_PROP_EMPTY_IS_NULL,C2U("ConvertEmptyToNull")); +STATIC_USTRING(FM_PROP_LISTSOURCETYPE,C2U("ListSourceType")); +STATIC_USTRING(FM_PROP_LISTSOURCE,C2U("ListSource")); +STATIC_USTRING(FM_PROP_SELECT_SEQ,C2U("SelectedItems")); +STATIC_USTRING(FM_PROP_VALUE_SEQ,C2U("SelectedValues")); +STATIC_USTRING(FM_PROP_DEFAULT_SELECT_SEQ,C2U("DefaultSelection")); +STATIC_USTRING(FM_PROP_MULTISELECTION,C2U("MultiSelection")); +STATIC_USTRING(FM_PROP_ALIGN,C2U("Align")); +STATIC_USTRING(FM_PROP_DEFAULT_DATE,C2U("DefaultDate")); +STATIC_USTRING(FM_PROP_DEFAULT_TIME,C2U("DefaultTime")); +STATIC_USTRING(FM_PROP_DEFAULT_VALUE,C2U("DefaultValue")); +STATIC_USTRING(FM_PROP_DECIMAL_ACCURACY,C2U("DecimalAccuracy")); +STATIC_USTRING(FM_PROP_FIELDTYPE,C2U("Type")); +STATIC_USTRING(FM_PROP_DECIMALS,C2U("Decimals")); +STATIC_USTRING(FM_PROP_REFVALUE,C2U("RefValue")); +STATIC_USTRING(FM_PROP_VALUEMIN,C2U("ValueMin")); +STATIC_USTRING(FM_PROP_VALUEMAX,C2U("ValueMax")); +STATIC_USTRING(FM_PROP_STRICTFORMAT,C2U("StrictFormat")); +STATIC_USTRING(FM_PROP_ALLOWADDITIONS,C2U("AllowInserts")); +STATIC_USTRING(FM_PROP_ALLOWEDITS,C2U("AllowUpdates")); +STATIC_USTRING(FM_PROP_ALLOWDELETIONS,C2U("AllowDeletes")); +STATIC_USTRING(FM_PROP_MASTERFIELDS,C2U("MasterFields")); +STATIC_USTRING(FM_PROP_SLAVEFIELDS,C2U("SlaveFields")); +STATIC_USTRING(FM_PROP_ISPASSTHROUGH,C2U("IsPassThrough")); +STATIC_USTRING(FM_PROP_QUERY,C2U("Query")); +STATIC_USTRING(FM_PROP_LITERALMASK,C2U("LiteralMask")); +STATIC_USTRING(FM_PROP_VALUESTEP,C2U("ValueStep")); +STATIC_USTRING(FM_PROP_SHOWTHOUSANDSEP,C2U("ShowThousandsSeparator")); +STATIC_USTRING(FM_PROP_CURRENCYSYMBOL,C2U("CurrencySymbol")); +STATIC_USTRING(FM_PROP_DATEFORMAT,C2U("DateFormat")); +STATIC_USTRING(FM_PROP_DATEMIN,C2U("DateMin")); +STATIC_USTRING(FM_PROP_DATEMAX,C2U("DateMax")); +STATIC_USTRING(FM_PROP_DATE_SHOW_CENTURY,C2U("DateShowCentury")); +STATIC_USTRING(FM_PROP_TIMEFORMAT, C2U("TimeFormat")); +STATIC_USTRING(FM_PROP_TIMEMIN, C2U("TimeMin")); +STATIC_USTRING(FM_PROP_TIMEMAX,C2U("TimeMax")); +STATIC_USTRING(FM_PROP_LINECOUNT,C2U("LineCount")); +STATIC_USTRING(FM_PROP_BOUNDCOLUMN, C2U("BoundColumn")); +STATIC_USTRING(FM_PROP_FONT,C2U("FontDescriptor")); +STATIC_USTRING(FM_PROP_BACKGROUNDCOLOR,C2U("BackgroundColor")); +STATIC_USTRING(FM_PROP_FILLCOLOR,C2U("FillColor")); +STATIC_USTRING(FM_PROP_TEXTCOLOR,C2U("TextColor")); +STATIC_USTRING(FM_PROP_LINECOLOR,C2U("LineColor")); +STATIC_USTRING(FM_PROP_BORDER,C2U("Border")); +STATIC_USTRING(FM_PROP_DROPDOWN,C2U("Dropdown")); +STATIC_USTRING(FM_PROP_MULTI,C2U("Multi")); +STATIC_USTRING(FM_PROP_HSCROLL,C2U("HScroll")); +STATIC_USTRING(FM_PROP_VSCROLL,C2U("VScroll")); +STATIC_USTRING(FM_PROP_TABSTOP,C2U("Tabstop")); +STATIC_USTRING(FM_PROP_AUTOCOMPLETE,C2U("Autocomplete")); +STATIC_USTRING(FM_PROP_HARDLINEBREAKS,C2U("HardLineBreaks")); +STATIC_USTRING(FM_PROP_PRINTABLE,C2U("Printable")); +STATIC_USTRING(FM_PROP_ECHO_CHAR,C2U("EchoChar")); +STATIC_USTRING(FM_PROP_ROWHEIGHT,C2U("RowHeight")); +STATIC_USTRING(FM_PROP_HELPTEXT, C2U("HelpText")); +STATIC_USTRING(FM_PROP_FONT_NAME, C2U("FontName")); +STATIC_USTRING(FM_PROP_FONT_STYLENAME, C2U("FontStyleName")); +STATIC_USTRING(FM_PROP_FONT_FAMILY, C2U("FontFamily")); +STATIC_USTRING(FM_PROP_FONT_CHARSET, C2U("FontCharset")); +STATIC_USTRING(FM_PROP_FONT_HEIGHT, C2U("FontHeight")); +STATIC_USTRING(FM_PROP_FONT_WEIGHT, C2U("FontWeight")); +STATIC_USTRING(FM_PROP_FONT_SLANT, C2U("FontSlant")); +STATIC_USTRING(FM_PROP_FONT_UNDERLINE, C2U("FontUnderline")); +STATIC_USTRING(FM_PROP_FONT_STRIKEOUT, C2U("FontStrikeout")); +STATIC_USTRING(FM_PROP_HELPURL, C2U("HelpURL")); +STATIC_USTRING(FM_PROP_RECORDMARKER, C2U("HasRecordMarker")); +STATIC_USTRING(FM_PROP_BOUNDFIELD, C2U("BoundField")); +STATIC_USTRING(FM_PROP_TREATASNUMERIC, C2U("TreatAsNumber")); +STATIC_USTRING(FM_PROP_EFFECTIVE_VALUE, C2U("EffectiveValue")); +STATIC_USTRING(FM_PROP_EFFECTIVE_DEFAULT, C2U("EffectiveDefault")); +STATIC_USTRING(FM_PROP_EFFECTIVE_MIN, C2U("EffectiveMin")); +STATIC_USTRING(FM_PROP_EFFECTIVE_MAX, C2U("EffectiveMax")); +STATIC_USTRING(FM_PROP_HIDDEN, C2U("Hidden")); +STATIC_USTRING(FM_PROP_FILTERPROPOSAL, C2U("useFilterValueProposal")); +STATIC_USTRING(FM_PROP_FIELDSOURCE, C2U("FieldSource")); +STATIC_USTRING(FM_PROP_TABLENAME, C2U("TableName")); +STATIC_USTRING(FM_PROP_FILTERSUPPLIER, C2U("FilterSupplier")); +STATIC_USTRING(FM_PROP_CURRENTFILTER, C2U("CurrentFilter")); +STATIC_USTRING(FM_PROP_SELECTED_FIELDS, C2U("SelectedFields")); +STATIC_USTRING(FM_PROP_SELECTED_TABLES, C2U("SelectedTables")); +STATIC_USTRING(FM_PROP_THREADSAFE, C2U("ThreadSafe")); +*/ + diff --git a/extensions/source/bibliography/bibmod.hxx b/extensions/source/bibliography/bibmod.hxx new file mode 100644 index 000000000000..306ede67bb3b --- /dev/null +++ b/extensions/source/bibliography/bibmod.hxx @@ -0,0 +1,113 @@ +/************************************************************************* + * + * $RCSfile: bibmod.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 ADDRMOD_HXX +#define ADDRMOD_HXX + + +#ifndef _COM_SUN_STAR_REGISTRY_MERGECONFLICTEXCEPTION_HPP_ +#include <com/sun/star/registry/MergeConflictException.hpp> +#endif +#ifndef _COM_SUN_STAR_REGISTRY_XSIMPLEREGISTRY_HPP_ +#include <com/sun/star/registry/XSimpleRegistry.hpp> +#endif + +class ResMgr; +class BibDataManager; +class BibRegistry; + +#define BIBLIOGRAPHY_INI_GROUP "Bibliography" +#define BIBLIOGRAPHY_INI_CUR_NAME "BibliographyCurrent" +#define BIBLIOGRAPHY_INI_DB_ENTRY "Bibliography" +#define BIBLIOGRAPHY_INI_MAPPING "BibliographyFields" +#define BIBLIOGRAPHY_TYPE_NAMES "BibliographyTypeNames" + +class BibModul +{ + private: + ResMgr* pResMgr; + BibRegistry* pRegistry; + ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry > xRegistry; + + public: + BibModul(); + ~BibModul(); + + ResMgr* GetResMgr(){return pResMgr;} + + static String GetBibliographyURL(String* pTableName); + static void SetBibliographyURL(const String& rURL, const String& rTable); + + BibDataManager* createDataManager(); + +}; + +typedef BibModul* PtrBibModul; +typedef PtrBibModul* HdlBibModul; + +HdlBibModul OpenBibModul(); +void CloseBibModul(HdlBibModul ppBibModul); + +//PtrBibModul GetBibModul(); + + + +#endif diff --git a/extensions/source/bibliography/bibprop.hrc b/extensions/source/bibliography/bibprop.hrc new file mode 100644 index 000000000000..8d6919bd5b0a --- /dev/null +++ b/extensions/source/bibliography/bibprop.hrc @@ -0,0 +1,211 @@ +/************************************************************************* + * + * $RCSfile: bibprop.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 _BIB_FMPROP_HRC +#define _BIB_FMPROP_HRC + +extern rtl::OUString FM_PROP_LABEL; +extern rtl::OUString FM_PROP_NAME; +extern rtl::OUString FM_PROP_CONTROLSOURCE; +extern rtl::OUString FM_PROP_FORMATKEY; +extern rtl::OUString FM_PROP_VALUE; +#ifdef TF_SDBAPI +#else // !TF_SDBAPI +extern rtl::OUString FM_PROP_EDITMODE; +extern rtl::OUString FM_PROP_DATASOURCE; +extern rtl::OUString FM_PROP_CURSORSOURCE; +extern rtl::OUString FM_PROP_CURSORSOURCETYPE; +#endif // !TF_SDBAPI +extern rtl::OUString FM_PROP_TEXT; +/* +extern rtl::OUString FM_PROP_TAG; +extern rtl::OUString FM_PROP_TABINDEX; +extern rtl::OUString FM_PROP_CLASSID; +extern rtl::OUString FM_PROP_ALIGN; +extern rtl::OUString FM_PROP_RECORDCOUNT; +extern rtl::OUString FM_PROP_RECORDSTATUS; +extern rtl::OUString FM_PROP_RECORDCOUNTFINAL; +extern rtl::OUString FM_PROP_VALUEMIN; +extern rtl::OUString FM_PROP_VALUEMAX; +extern rtl::OUString FM_PROP_VALUESTEP; +extern rtl::OUString FM_PROP_CANINSERT; +extern rtl::OUString FM_PROP_CANUPDATE; +extern rtl::OUString FM_PROP_CANDELETE; +extern rtl::OUString FM_PROP_NAVIGATION; +extern rtl::OUString FM_PROP_CYCLE; +extern rtl::OUString FM_PROP_ENABLED; +extern rtl::OUString FM_PROP_SPIN; +extern rtl::OUString FM_PROP_READONLY; +extern rtl::OUString FM_PROP_FILTER_CRITERIA; +extern rtl::OUString FM_PROP_SORT_CRITERIA; +extern rtl::OUString FM_PROP_AUTOINCREMENT; +extern rtl::OUString FM_PROP_CACHESIZE; +extern rtl::OUString FM_PROP_DATAENTRY; +extern rtl::OUString FM_PROP_LASTDIRTY; +extern rtl::OUString FM_PROP_STATEMENT; +extern rtl::OUString FM_PROP_WIDTH; +extern rtl::OUString FM_PROP_SEARCHINFO; +extern rtl::OUString FM_PROP_MULTILINE; +extern rtl::OUString FM_PROP_TARGET_URL; +extern rtl::OUString FM_PROP_DEFAULTCONTROL; +extern rtl::OUString FM_PROP_MAXTEXTLEN; +extern rtl::OUString FM_PROP_SIZE; +extern rtl::OUString FM_PROP_DATE; +extern rtl::OUString FM_PROP_TIME; +extern rtl::OUString FM_PROP_STATE; +extern rtl::OUString FM_PROP_TRISTATE; +extern rtl::OUString FM_PROP_HIDDEN_VALUE; +extern rtl::OUString FM_PROP_TARGET_FRAME; +extern rtl::OUString FM_PROP_BUTTONTYPE; +extern rtl::OUString FM_PROP_STRINGITEMLIST; +extern rtl::OUString FM_PROP_DEFAULT_TEXT; +extern rtl::OUString FM_PROP_DEFAULTCHECKED; +extern rtl::OUString FM_PROP_DEFAULT_DATE; +extern rtl::OUString FM_PROP_DEFAULT_TIME; +extern rtl::OUString FM_PROP_DEFAULT_VALUE; +extern rtl::OUString FM_PROP_FORMATSSUPPLIER; +extern rtl::OUString FM_PROP_SUBMIT_ACTION; +extern rtl::OUString FM_PROP_SUBMIT_TARGET; +extern rtl::OUString FM_PROP_SUBMIT_METHOD; +extern rtl::OUString FM_PROP_SUBMIT_ENCODING; +extern rtl::OUString FM_PROP_IMAGE_URL; +extern rtl::OUString FM_PROP_EMPTY_IS_NULL; +extern rtl::OUString FM_PROP_LISTSOURCETYPE; +extern rtl::OUString FM_PROP_LISTSOURCE; +extern rtl::OUString FM_PROP_SELECT_SEQ; +extern rtl::OUString FM_PROP_VALUE_SEQ; +extern rtl::OUString FM_PROP_DEFAULT_SELECT_SEQ; +extern rtl::OUString FM_PROP_MULTISELECTION; +extern rtl::OUString FM_PROP_DECIMAL_ACCURACY; +extern rtl::OUString FM_PROP_EDITMASK; +extern rtl::OUString FM_PROP_ISREADONLY; +extern rtl::OUString FM_PROP_ISREQUIRED; +extern rtl::OUString FM_PROP_FIELDTYPE; +extern rtl::OUString FM_PROP_DECIMALS; +extern rtl::OUString FM_PROP_REFVALUE; +extern rtl::OUString FM_PROP_STRICTFORMAT; +extern rtl::OUString FM_PROP_ALLOWADDITIONS; +extern rtl::OUString FM_PROP_ALLOWEDITS; +extern rtl::OUString FM_PROP_ALLOWDELETIONS; +extern rtl::OUString FM_PROP_MASTERFIELDS; +extern rtl::OUString FM_PROP_SLAVEFIELDS; +extern rtl::OUString FM_PROP_ISPASSTHROUGH; +extern rtl::OUString FM_PROP_QUERY; +extern rtl::OUString FM_PROP_LITERALMASK; +extern rtl::OUString FM_PROP_SHOWTHOUSANDSEP; +extern rtl::OUString FM_PROP_CURRENCYSYMBOL; +extern rtl::OUString FM_PROP_DATEFORMAT; +extern rtl::OUString FM_PROP_DATEMIN; +extern rtl::OUString FM_PROP_DATEMAX; +extern rtl::OUString FM_PROP_DATE_SHOW_CENTURY; +extern rtl::OUString FM_PROP_TIMEFORMAT; +extern rtl::OUString FM_PROP_TIMEMIN; +extern rtl::OUString FM_PROP_TIMEMAX; +extern rtl::OUString FM_PROP_LINECOUNT; +extern rtl::OUString FM_PROP_BOUNDCOLUMN; +extern rtl::OUString FM_PROP_HASNAVIGATION; +extern rtl::OUString FM_PROP_FONT; +extern rtl::OUString FM_PROP_BACKGROUNDCOLOR; +extern rtl::OUString FM_PROP_FILLCOLOR; +extern rtl::OUString FM_PROP_TEXTCOLOR; +extern rtl::OUString FM_PROP_LINECOLOR; +extern rtl::OUString FM_PROP_BORDER; +extern rtl::OUString FM_PROP_DROPDOWN; +extern rtl::OUString FM_PROP_MULTI; +extern rtl::OUString FM_PROP_HSCROLL; +extern rtl::OUString FM_PROP_VSCROLL; +extern rtl::OUString FM_PROP_TABSTOP; +extern rtl::OUString FM_PROP_AUTOCOMPLETE; +extern rtl::OUString FM_PROP_HARDLINEBREAKS; +extern rtl::OUString FM_PROP_PRINTABLE; +extern rtl::OUString FM_PROP_ECHO_CHAR; +extern rtl::OUString FM_PROP_ROWHEIGHT; +extern rtl::OUString FM_PROP_HELPTEXT; +extern rtl::OUString FM_PROP_FONT_NAME; +extern rtl::OUString FM_PROP_FONT_STYLENAME; +extern rtl::OUString FM_PROP_FONT_FAMILY; +extern rtl::OUString FM_PROP_FONT_CHARSET; +extern rtl::OUString FM_PROP_FONT_HEIGHT; +extern rtl::OUString FM_PROP_FONT_WEIGHT; +extern rtl::OUString FM_PROP_FONT_SLANT; +extern rtl::OUString FM_PROP_FONT_UNDERLINE; +extern rtl::OUString FM_PROP_FONT_STRIKEOUT; +extern rtl::OUString FM_PROP_HELPURL; +extern rtl::OUString FM_PROP_RECORDMARKER; +extern rtl::OUString FM_PROP_BOUNDFIELD; +extern rtl::OUString FM_PROP_TREATASNUMERIC; +extern rtl::OUString FM_PROP_EFFECTIVE_VALUE; +extern rtl::OUString FM_PROP_EFFECTIVE_DEFAULT; +extern rtl::OUString FM_PROP_EFFECTIVE_MIN; +extern rtl::OUString FM_PROP_EFFECTIVE_MAX; +extern rtl::OUString FM_PROP_HIDDEN; +extern rtl::OUString FM_PROP_FILTERPROPOSAL; +extern rtl::OUString FM_PROP_FIELDSOURCE; +extern rtl::OUString FM_PROP_TABLENAME; +extern rtl::OUString FM_PROP_FILTERSUPPLIER; +extern rtl::OUString FM_PROP_CURRENTFILTER; +extern rtl::OUString FM_PROP_SELECTED_FIELDS; +extern rtl::OUString FM_PROP_SELECTED_TABLES; +extern rtl::OUString FM_PROP_THREADSAFE; +*/ + + +#endif // _SVX_FMPROP_HRC + diff --git a/extensions/source/bibliography/bibresid.hxx b/extensions/source/bibliography/bibresid.hxx new file mode 100644 index 000000000000..53bd3756f6e7 --- /dev/null +++ b/extensions/source/bibliography/bibresid.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * $RCSfile: bibresid.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 ADRRESID_HXX +#define ADRRESID_HXX + +#ifndef _TOOLS_RESID_HXX //autogen +#include <tools/resid.hxx> +#endif + +//=================================================================== + +class BibResId : public ResId +{ + public: + BibResId( USHORT nId ); +}; + + + +#endif // ADRRESID_HXX + diff --git a/extensions/source/bibliography/bibview.cxx b/extensions/source/bibliography/bibview.cxx new file mode 100644 index 000000000000..c2f551d5d258 --- /dev/null +++ b/extensions/source/bibliography/bibview.cxx @@ -0,0 +1,193 @@ +/************************************************************************* + * + * $RCSfile: bibview.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 "bib.hrc" +#include "bibcont.hxx" +#include "bibbeam.hxx" +#include "bibmod.hxx" +#include "general.hxx" +#include "bibview.hxx" +#include "datman.hxx" +#include "bibresid.hxx" +#include "bibmod.hxx" +#include "sections.hrc" +#include "viewsect.hxx" + + +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif + +#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT +#include <tools/debug.hxx> +#endif + +#define DEFAULT_SIZE 500 +using namespace ::com::sun::star; +using namespace ::com::sun::star::form; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::rtl; +#define C2U(cChar) OUString::createFromAscii(cChar) + +rtl::OUString gSectionSizes(C2U("TheSectionSizes")); +rtl::OUString gSectionNames(C2U("TheSectionNames")); +rtl::OUString gSectionExpander(C2U("TheSectionExpander")); +rtl::OUString gSectionPos(C2U("TheSectionPosition")); +// ----------------------------------------------------------------------- +BibView::BibView(Window* pParent, BibDataManager* pDM, WinBits nStyle): + Window(pParent,nStyle), + pDatMan(pDM), + xDatMan(pDM), + pGeneralPage(NULL), + nDefNameCount(0) +{ + String aDefName(BibResId(RID_BIB_STR_SECTION)); + aDefaultName=aDefName; + UpdatePages(); +} + +BibView::~BibView() +{ + pGeneralPage->CommitActiveControl(); + uno::Reference< XForm > xForm = pDatMan->getDatabaseForm(); + uno::Reference< XPropertySet > xPrSet(xForm, UNO_QUERY); + if(xPrSet.is()) + { + uno::Any aProp = xPrSet->getPropertyValue(C2U("IsModified")); + if(*(sal_Bool*)aProp.getValue()) + { + uno::Any aNew = xPrSet->getPropertyValue(C2U("IsNew")); + uno::Reference< sdbc::XResultSetUpdate > xResUpd(xForm, UNO_QUERY); + if(*(sal_Bool*)aNew.getValue()) + xResUpd->insertRow(); + else + xResUpd->updateRow(); + } + } + //delete pGeneralPage; + pGeneralPage->RemoveListeners(); + xGeneralPage = 0; + +} +/* -----------------16.11.99 13:13------------------- + + --------------------------------------------------*/ +void BibView::UpdatePages() +{ + BOOL bResize = FALSE; + if(pGeneralPage) + { + bResize = TRUE; + pGeneralPage->Hide(); +// delete pGeneralPage; + pGeneralPage->RemoveListeners(); + xGeneralPage = 0; + } +// pGeneralPage = new BibGeneralPage(this, pDatMan); + xGeneralPage = pGeneralPage = new BibGeneralPage(this, pDatMan); + if(bResize) + Resize(); + String sErrorString(pGeneralPage->GetErrorString()); + if(sErrorString.Len()) + { + sErrorString += '\n'; + sErrorString += String(BibResId(RID_MAP_QUESTION)); + QueryBox aQuery( this, WB_YES_NO, sErrorString ); + if(RET_YES == aQuery.Execute()) + { + Application::PostUserEvent( STATIC_LINK( + this, BibView, CallMappingHdl ) ); + + } + } + +} +/* -----------------------------02.02.00 16:49-------------------------------- + + ---------------------------------------------------------------------------*/ +IMPL_STATIC_LINK(BibView, CallMappingHdl, BibView*, EMPTYARG) +{ + pThis->pDatMan->CreateMappingDialog(pThis); + return 0; +} +/* -----------------------------13.04.00 16:12-------------------------------- + + ---------------------------------------------------------------------------*/ +void BibView::Resize() +{ + if(pGeneralPage) + { + Size aSz(GetOutputSizePixel()); + pGeneralPage->SetSizePixel(aSz); + } + Window::Resize(); +} + + + + diff --git a/extensions/source/bibliography/bibview.hxx b/extensions/source/bibliography/bibview.hxx new file mode 100644 index 000000000000..5b39ae096733 --- /dev/null +++ b/extensions/source/bibliography/bibview.hxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * $RCSfile: bibview.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 _BIB_VIEW_HXX +#define _BIB_VIEW_HXX + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif + +#ifndef _SV_SECTION_HXX +#include <svtools/section.hxx> +#endif + +#ifndef _SV_SECTCTR_HXX +#include <svtools/sectctr.hxx> +#endif + +class BibGeneralPage; +class BibBusinessAddress; +class BibBusinessPhone; +class BibDataManager; + +namespace com{ namespace sun{ namespace star{ namespace awt{ class XFocusListener;}}}} +// ----------------------------------------------------------------------- +class BibView: public Window//SvSectionControl +{ +private: + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xViewSet; + BibDataManager* pDatMan; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > xDatMan; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener> xGeneralPage; + BibGeneralPage* pGeneralPage; + rtl::OUString aDefaultName; + sal_Int32 nDefNameCount; + +protected: + +// void InitPages(); +protected: + virtual void Resize(); + + DECL_STATIC_LINK(BibView, CallMappingHdl, BibView*); + +public: + BibView(Window* pParent,BibDataManager* pDatMan,WinBits nStyle=0); + ~BibView(); + + void UpdatePages(); +}; + +#endif + + diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx new file mode 100644 index 000000000000..662881852b56 --- /dev/null +++ b/extensions/source/bibliography/datman.cxx @@ -0,0 +1,2127 @@ +/************************************************************************* + * + * $RCSfile: datman.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ +#include <unotools/processfactory.hxx> +#endif +#ifndef _COM_SUN_STAR_IO_XPERSISTOBJECT_HPP_ +#include <com/sun/star/io/XPersistObject.hpp> +#endif + +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_ +#include <com/sun/star/sdbcx/XRowLocate.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_ +#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XDATABASEENVIRONMENT_HPP_ +#include <com/sun/star/sdb/XDatabaseEnvironment.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_ +#include <com/sun/star/uno/XNamingService.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ +#include <com/sun/star/sdbc/XDataSource.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_DATA_XDATABASEFAVORITES_HPP_ +#include <com/sun/star/data/XDatabaseFavorites.hpp> // TODO : this is obsolete .... +#endif +#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_ +#include <com/sun/star/form/XLoadable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XGRIDCOLUMNFACTORY_HPP_ +#include <com/sun/star/form/XGridColumnFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XDATAINPUTSTREAM_HPP_ +#include <com/sun/star/io/XDataInputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif + +#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_ +#include <com/sun/star/ucb/XContentProvider.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_HPP_ +#include <com/sun/star/ucb/XContentAccess.hpp> +#endif +#ifndef _UCBHELPER_CONTENTBROKER_HXX +#include <ucbhelper/contentbroker.hxx> +#endif +#ifndef _UCBHELPER_CONTENT_HXX +#include <ucbhelper/content.hxx> +#endif +#ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX +#include <ucbhelper/contentidentifier.hxx> +#endif + +#ifndef SVTOOLS_URIHELPER_HXX +#include <svtools/urihelper.hxx> +#endif +#include <svtools/iniprop.hxx> +#include <svtools/iniman.hxx> +#ifndef _SVTABBX_HXX +#include <svtools/svtabbx.hxx> +#endif +#ifndef _HEADBAR_HXX +#include <svtools/headbar.hxx> +#endif +#ifndef _SVARRAY_HXX +#include <svtools/svarray.hxx> +#endif +#ifndef _SV_DIALOG_HXX +#include <vcl/dialog.hxx> +#endif +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#ifndef _SV_LSTBOX_HXX +#include <vcl/lstbox.hxx> +#endif +#ifndef _SV_FIXED_HXX +#include <vcl/fixed.hxx> +#endif +#ifndef _SV_GROUP_HXX +#include <vcl/group.hxx> +#endif +#ifndef _SV_LSTBOX_HXX //autogen wg. form::component::ListBox +#include <vcl/lstbox.hxx> +#endif +#ifndef _SV_EDIT_HXX //autogen wg. Edit +#include <vcl/edit.hxx> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif + +#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT +#include <tools/debug.hxx> +#endif + +#ifndef _BIB_DATMAN_HXX +#include "datman.hxx" +#endif +#ifndef ADRRESID_HXX +#include "bibresid.hxx" +#endif +#ifndef ADDRMOD_HXX +#include "bibmod.hxx" +#endif +#ifndef _BIB_VIEW_HXX +#include "bibview.hxx" +#endif +#ifndef _BIB_REGISTRY_HXX +#include "registry.hxx" +#endif +#ifndef _BIB_FMPROP_HRC +#include "bibprop.hrc" +#endif +#ifndef _BIB_TOOLBAR_HXX +#include "toolbar.hxx" +#endif +#ifndef ADRBEAM_HXX +#include "bibbeam.hxx" +#endif +#ifndef BIB_HRC +#include "bib.hrc" +#endif +#include "datman.hrc" +#ifndef __EXTENSIONS_INC_EXTENSIO_HRC__ +#include "extensio.hrc" +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::form; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::ucb; +using namespace ::rtl; +using namespace ::ucb; + +#define C2U(cChar) OUString::createFromAscii(cChar) +#define C2S(cChar) String::CreateFromAscii(cChar) +#define MAP_TOKEN ';' +#define PAIR_TOKEN ':' + +/* -----------------11.11.99 14:34------------------- + + --------------------------------------------------*/ +typedef Mapping* MappingPtr; +SV_DECL_PTRARR_DEL(MappingArray, MappingPtr, 2, 2); +SV_IMPL_PTRARR(MappingArray, MappingPtr); + +/* -----------------------------15.06.00 16:12-------------------------------- + + ---------------------------------------------------------------------------*/ +BOOL lcl_IsCaseSensitive(const String& rPathURL) +{ + BOOL bCaseSensitive = FALSE; +#ifdef DBG_UTIL + static BOOL bFirstCall = TRUE; + if(bFirstCall) + { + DBG_ERROR("No case checking due to #76253#") + bFirstCall = FALSE; + } +#endif +/* Reference< lang::XMultiServiceFactory > xMSF = utl::getProcessServiceFactory(); + INetURLObject aTempObj(rPathURL); + try + { + aTempObj.SetBase(aTempObj.GetBase().ToLowerAscii()); + Reference<XContentIdentifier> xRef1 = new ::ucb::ContentIdentifier( xMSF, aTempObj.GetMainURL()); + aTempObj.SetBase(aTempObj.GetBase().ToUpperAscii()); + Reference<XContentIdentifier> xRef2 = new ::ucb::ContentIdentifier( xMSF, aTempObj.GetMainURL()); + + ContentBroker& rBroker = *ContentBroker::get(); + Reference<XContentProvider > xProv = rBroker.getContentProviderInterface(); + sal_Int32 nCompare = xProv->compareContentIds( xRef1, xRef2 ); + bCaseSensitive = nCompare != 0; + } + catch(...){} +*/ return bCaseSensitive; +} +/* -----------------17.01.00 14:38------------------- + + --------------------------------------------------*/ +uno::Reference< sdbc::XConnection > getConnection(const rtl::OUString& _rURL) +{ + // first get the sdb::DataSource corresponding to the url + uno::Reference< sdbc::XDataSource > xDataSource; + // is it a favorite title ? + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + uno::Reference< XNameAccess > xNamingContext(xMgr->createInstance(C2U("com.sun.star.sdb.DatabaseAccessContext")), UNO_QUERY); + if (xNamingContext.is() && xNamingContext->hasByName(_rURL)) + { + DBG_ASSERT(uno::Reference< XNamingService > (xNamingContext, UNO_QUERY).is(), "::getDataSource : no uno::NamingService interface on the sdb::DatabaseAccessContext !"); + xDataSource = uno::Reference< sdbc::XDataSource > (uno::Reference< XNamingService > (xNamingContext, UNO_QUERY)->getRegisteredObject(_rURL), UNO_QUERY); + } + if (!xDataSource.is()) + { + // is it a file url ? + uno::Reference< XDatabaseEnvironment > xEnvironment(xMgr->createInstance(C2U("com.sun.star.sdb.DatabaseEnvironment")), UNO_QUERY); + if (xEnvironment.is()) + { + try + { + xDataSource = uno::Reference< sdbc::XDataSource > (xEnvironment->getDatabaseAccess(_rURL), UNO_QUERY); + } + catch(sdbc::SQLException&) + { + xDataSource = NULL; + // TODO : a real error handling + } + catch(...) + { + xDataSource = NULL; + } + } + } + + // build the connection from the data source + uno::Reference< sdbc::XConnection > xConn; + if (xDataSource.is()) + { + // need user/pwd for this + rtl::OUString sUser, sPwd; + uno::Reference< XPropertySet > xDataSourceProps(xDataSource, UNO_QUERY); + uno::Reference< XPropertySetInfo > xInfo = xDataSourceProps.is() ? xDataSourceProps->getPropertySetInfo() : uno::Reference< XPropertySetInfo > (); + if (xInfo.is() && xInfo->hasPropertyByName(C2U("User"))) + xDataSourceProps->getPropertyValue(C2U("User")) >>= sUser; + if (xInfo.is() && xInfo->hasPropertyByName(C2U("Password"))) + xDataSourceProps->getPropertyValue(C2U("Password"))>>= sPwd; + + try + { + xConn = xDataSource->getConnection(sUser, sPwd); + } + catch(sdbc::SQLException&) + { + // TODO : a real error handling + } + catch(...) + { + } + + } + return xConn; +} + +/* -----------------17.01.00 14:46------------------- + + --------------------------------------------------*/ +uno::Reference< sdbc::XConnection > getConnection(const uno::Reference< XInterface > & xRowSet) +{ + uno::Reference< sdbc::XConnection > xConn; + try + { + uno::Reference< XPropertySet > xFormProps(xRowSet, UNO_QUERY); + if (!xFormProps.is()) + return xConn; + + xConn = uno::Reference< sdbc::XConnection > (*(uno::Reference< XInterface > *)xFormProps->getPropertyValue(C2U("ActiveConnection")).getValue(), UNO_QUERY); + if (!xConn.is()) + { + OUString uTmp; + xFormProps->getPropertyValue(C2U("DataSourceName")) >>= uTmp; + xConn = getConnection(uTmp); + } + } + catch(...) + { + DBG_ERROR("exception in getConnection"); + } + + return xConn; +} +/* -----------------17.01.00 16:07------------------- + + --------------------------------------------------*/ +uno::Reference< XNameAccess > getColumns(const uno::Reference< XForm > & xForm) +{ + uno::Reference< XNameAccess > xReturn; + // check if the form is alive + uno::Reference< sdbcx::XColumnsSupplier > xSupplyCols(xForm, UNO_QUERY); + if (xSupplyCols.is()) + xReturn = xSupplyCols->getColumns(); + + if (!xReturn.is() || (xReturn->getElementNames().getLength() == 0)) + { // no .... + xReturn = NULL; + // -> get the table the form is bound to and ask it for their columns + uno::Reference< sdbcx::XTablesSupplier > xSupplyTables(getConnection(xForm), UNO_QUERY); + uno::Reference< XPropertySet > xFormProps(xForm, UNO_QUERY); + if (xFormProps.is() && xSupplyTables.is()) + { + try + { + DBG_ASSERT((*(sal_Int32*)xFormProps->getPropertyValue(C2U("CommandType")).getValue()) == CommandType::TABLE, + "::getColumns : invalid form (has no table as data source) !"); + rtl::OUString sTable; + xFormProps->getPropertyValue(C2U("Command")) >>= sTable; + uno::Reference< XNameAccess > xTables = xSupplyTables->getTables(); + if (xTables.is() && xTables->hasByName(sTable)) + xSupplyCols = uno::Reference< sdbcx::XColumnsSupplier > ( + *(uno::Reference< XInterface > *)xTables->getByName(sTable).getValue(), UNO_QUERY); + if (xSupplyCols.is()) + xReturn = xSupplyCols->getColumns(); + } +#ifdef DBG_UTIL + catch(Exception& e ) +#else + catch(Exception&) +#endif + { +#ifdef DBG_UTIL + String sMsg(String::CreateFromAscii("::getColumns : catched an exception (")); + sMsg += String(e.Message); + sMsg.AppendAscii(") ..."); + DBG_ERROR( ByteString(sMsg, RTL_TEXTENCODING_ASCII_US ).GetBuffer()); +#endif + } + catch(...) + { + DBG_ERROR("::getColumns : catched a strange exception (no uno::Exception) ..."); + } + + } + } + return xReturn; +} + +/* -----------------11.11.99 15:54------------------- + + --------------------------------------------------*/ +class MappingDialog_Impl : public ModalDialog +{ + OKButton aOKBT; + CancelButton aCancelBT; + HelpButton aHelpBT; + + GroupBox aMapGB; + FixedText aIdentifierFT; + ListBox aIdentifierLB; + FixedText aAuthorityTypeFT; + ListBox aAuthorityTypeLB; + FixedText aAuthorFT; + ListBox aAuthorLB; + FixedText aTitleFT; + ListBox aTitleLB; + FixedText aMonthFT; + ListBox aMonthLB; + FixedText aYearFT; + ListBox aYearLB; + FixedText aISBNFT; + ListBox aISBNLB; + FixedText aBooktitleFT; + ListBox aBooktitleLB; + FixedText aChapterFT; + ListBox aChapterLB; + FixedText aEditionFT; + ListBox aEditionLB; + FixedText aEditorFT; + ListBox aEditorLB; + FixedText aHowpublishedFT; + ListBox aHowpublishedLB; + FixedText aInstitutionFT; + ListBox aInstitutionLB; + FixedText aJournalFT; + ListBox aJournalLB; + FixedText aNoteFT; + ListBox aNoteLB; + FixedText aAnnoteFT; + ListBox aAnnoteLB; + FixedText aNumberFT; + ListBox aNumberLB; + FixedText aOrganizationsFT; + ListBox aOrganizationsLB; + FixedText aPagesFT; + ListBox aPagesLB; + FixedText aPublisherFT; + ListBox aPublisherLB; + FixedText aAddressFT; + ListBox aAddressLB; + FixedText aSchoolFT; + ListBox aSchoolLB; + FixedText aSeriesFT; + ListBox aSeriesLB; + FixedText aReportTypeFT; + ListBox aReportTypeLB; + FixedText aVolumeFT; + ListBox aVolumeLB; + FixedText aURLFT; + ListBox aURLLB; + FixedText aCustom1FT; + ListBox aCustom1LB; + FixedText aCustom2FT; + ListBox aCustom2LB; + FixedText aCustom3FT; + ListBox aCustom3LB; + FixedText aCustom4FT; + ListBox aCustom4LB; + FixedText aCustom5FT; + ListBox aCustom5LB; + + ListBox* aListBoxes[COLUMN_COUNT]; + String sNone; + + BibDataManager* pDatMan; + + DECL_LINK(OkHdl, OKButton*); + DECL_LINK(ListBoxSelectHdl, ListBox*); + +public: + MappingDialog_Impl(Window* pParent, BibDataManager* pDatMan); + ~MappingDialog_Impl(); + +}; +/* -----------------11.11.99 16:42------------------- + + --------------------------------------------------*/ +sal_uInt16 lcl_FindLogicalName(BibDataManager* pDatMan, + const String& rLogicalColumnName) +{ + for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++) + { + if(rLogicalColumnName == pDatMan->GetDefColumnName(i)) + return i; + } + return USHRT_MAX; +} +//----------------------------------------------------------------------------- +MappingDialog_Impl::MappingDialog_Impl(Window* pParent, BibDataManager* pMan) : + ModalDialog(pParent, BibResId(RID_DLG_MAPPING) ), + pDatMan(pMan), + aOKBT(this, ResId( BT_OK )), + aCancelBT(this, ResId( BT_CANCEL )), + aHelpBT(this, ResId( BT_HELP )), + + aMapGB(this, ResId( GB_MAPPING )), + + aIdentifierFT(this, ResId( FT_IDENTIFIER )), + aIdentifierLB(this, ResId( LB_IDENTIFIER )), + aAuthorityTypeFT(this, ResId( FT_AUTHORITYTYPE )), + aAuthorityTypeLB(this, ResId( LB_AUTHORITYTYPE )), + aAuthorFT(this, ResId( FT_AUTHOR )), + aAuthorLB(this, ResId( LB_AUTHOR )), + aTitleFT(this, ResId( FT_TITLE )), + aTitleLB(this, ResId( LB_TITLE )), + aMonthFT(this, ResId( FT_MONTH )), + aMonthLB(this, ResId( LB_MONTH )), + aYearFT(this, ResId( FT_YEAR )), + aYearLB(this, ResId( LB_YEAR )), + aISBNFT(this, ResId( FT_ISBN )), + aISBNLB(this, ResId( LB_ISBN )), + aBooktitleFT(this, ResId( FT_BOOKTITLE )), + aBooktitleLB(this, ResId( LB_BOOKTITLE )), + aChapterFT(this, ResId( FT_CHAPTER )), + aChapterLB(this, ResId( LB_CHAPTER )), + aEditionFT(this, ResId( FT_EDITION )), + aEditionLB(this, ResId( LB_EDITION )), + aEditorFT(this, ResId( FT_EDITOR )), + aEditorLB(this, ResId( LB_EDITOR )), + aHowpublishedFT(this, ResId( FT_HOWPUBLISHED )), + aHowpublishedLB(this, ResId( LB_HOWPUBLISHED )), + aInstitutionFT(this, ResId( FT_INSTITUTION )), + aInstitutionLB(this, ResId( LB_INSTITUTION )), + aJournalFT(this, ResId( FT_JOURNAL )), + aJournalLB(this, ResId( LB_JOURNAL )), + aNoteFT(this, ResId( FT_NOTE )), + aNoteLB(this, ResId( LB_NOTE )), + aAnnoteFT(this, ResId( FT_ANNOTE )), + aAnnoteLB(this, ResId( LB_ANNOTE )), + aNumberFT(this, ResId( FT_NUMBER )), + aNumberLB(this, ResId( LB_NUMBER )), + aOrganizationsFT(this, ResId( FT_ORGANIZATIONS )), + aOrganizationsLB(this, ResId( LB_ORGANIZATIONS )), + aPagesFT(this, ResId( FT_PAGES )), + aPagesLB(this, ResId( LB_PAGES )), + aPublisherFT(this, ResId( FT_PUBLISHER )), + aPublisherLB(this, ResId( LB_PUBLISHER )), + aAddressFT(this, ResId( FT_ADDRESS )), + aAddressLB(this, ResId( LB_ADDRESS )), + aSchoolFT(this, ResId( FT_SCHOOL )), + aSchoolLB(this, ResId( LB_SCHOOL )), + aSeriesFT(this, ResId( FT_SERIES )), + aSeriesLB(this, ResId( LB_SERIES )), + aReportTypeFT(this, ResId( FT_REPORTTYPE )), + aReportTypeLB(this, ResId( LB_REPORTTYPE )), + aVolumeFT(this, ResId( FT_VOLUME )), + aVolumeLB(this, ResId( LB_VOLUME )), + aURLFT(this, ResId( FT_URL )), + aURLLB(this, ResId( LB_URL )), + aCustom1FT(this, ResId( FT_CUSTOM1 )), + aCustom1LB(this, ResId( LB_CUSTOM1 )), + aCustom2FT(this, ResId( FT_CUSTOM2 )), + aCustom2LB(this, ResId( LB_CUSTOM2 )), + aCustom3FT(this, ResId( FT_CUSTOM3 )), + aCustom3LB(this, ResId( LB_CUSTOM3 )), + aCustom4FT(this, ResId( FT_CUSTOM4 )), + aCustom4LB(this, ResId( LB_CUSTOM4 )), + aCustom5FT(this, ResId( FT_CUSTOM5 )), + aCustom5LB(this, ResId( LB_CUSTOM5 )), + sNone(ResId(ST_NONE)) +{ + FreeResource(); + + aOKBT.SetClickHdl(LINK(this, MappingDialog_Impl, OkHdl)); + String sTitle = GetText(); + sTitle.SearchAndReplace(C2S("%1"), pDatMan->getActiveDataTable(), 0); + SetText(sTitle); + + aListBoxes[0] = &aIdentifierLB; + aListBoxes[1] = &aAuthorityTypeLB; + aListBoxes[2] = &aAuthorLB; + aListBoxes[3] = &aTitleLB; + aListBoxes[4] = &aYearLB; + aListBoxes[5] = &aISBNLB; + aListBoxes[6] = &aBooktitleLB; + aListBoxes[7] = &aChapterLB; + aListBoxes[8] = &aEditionLB; + aListBoxes[9] = &aEditorLB; + aListBoxes[10] = &aHowpublishedLB; + aListBoxes[11] = &aInstitutionLB; + aListBoxes[12] = &aJournalLB; + aListBoxes[13] = &aMonthLB; + aListBoxes[14] = &aNoteLB; + aListBoxes[15] = &aAnnoteLB; + aListBoxes[16] = &aNumberLB; + aListBoxes[17] = &aOrganizationsLB; + aListBoxes[18] = &aPagesLB; + aListBoxes[19] = &aPublisherLB; + aListBoxes[20] = &aAddressLB; + aListBoxes[21] = &aSchoolLB; + aListBoxes[22] = &aSeriesLB; + aListBoxes[23] = &aReportTypeLB; + aListBoxes[24] = &aVolumeLB; + aListBoxes[25] = &aURLLB; + aListBoxes[26] = &aCustom1LB; + aListBoxes[27] = &aCustom2LB; + aListBoxes[28] = &aCustom3LB; + aListBoxes[29] = &aCustom4LB; + aListBoxes[30] = &aCustom5LB; + + aListBoxes[0]->InsertEntry(sNone); + uno::Reference< XNameAccess > xFields = getColumns(pDatMan->getDatabaseForm()); + DBG_ASSERT(xFields.is(), "MappingDialog_Impl::MappingDialog_Impl : gave me an invalid form !"); + uno::Sequence<rtl::OUString> aNames = xFields->getElementNames(); + sal_Int32 nFieldsCount = aNames.getLength(); + const rtl::OUString* pNames = aNames.getConstArray(); + + for(sal_Int32 nField = 0; nField < nFieldsCount; nField++) + aListBoxes[0]->InsertEntry(pNames[nField]); + + Link aLnk = LINK(this, MappingDialog_Impl, ListBoxSelectHdl); + + aListBoxes[0]->SelectEntryPos(0); + aListBoxes[0]->SetSelectHdl(aLnk); + for(sal_uInt16 i = 1; i < COLUMN_COUNT; i++) + { + for(sal_uInt16 j = 0; j < aListBoxes[0]->GetEntryCount();j++) + aListBoxes[i]->InsertEntry(aListBoxes[0]->GetEntry(j)); + aListBoxes[i]->SelectEntryPos(0); + aListBoxes[i]->SetSelectHdl(aLnk); + } + const Mapping* pMapping = pDatMan->GetMapping(pDatMan->getActiveDataTable()); + if(pMapping) + { + for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++) + { + sal_uInt16 nListBoxIndex = lcl_FindLogicalName(pDatMan, + pMapping->aColumnPairs[nEntry].sLogicalColumnName); + if(nListBoxIndex < COLUMN_COUNT) + { + aListBoxes[nListBoxIndex]->SelectEntry(pMapping->aColumnPairs[nEntry].sRealColumnName); + } + } + } +} +/* -----------------11.11.99 16:44------------------- + + --------------------------------------------------*/ +MappingDialog_Impl::~MappingDialog_Impl() +{} +/* -----------------15.11.99 10:38------------------- + + --------------------------------------------------*/ +IMPL_LINK(MappingDialog_Impl, ListBoxSelectHdl, ListBox*, pListBox) +{ + sal_uInt16 nEntryPos = pListBox->GetSelectEntryPos(); + if(0 < nEntryPos) + { + for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++) + { + if(pListBox != aListBoxes[i] && aListBoxes[i]->GetSelectEntryPos() == nEntryPos) + aListBoxes[i]->SelectEntryPos(0); + } + } + return 0; +} +/* -----------------12.11.99 14:50------------------- + + --------------------------------------------------*/ +IMPL_LINK(MappingDialog_Impl, OkHdl, OKButton*, EMPTYARG) +{ + Mapping aNew; + aNew.sTableName = String(pDatMan->getActiveDataTable()); + aNew.sURL = String(pDatMan->getActiveDataSource()); + + sal_uInt16 nWriteIndex = 0; + for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++) + { + + String sSel = aListBoxes[nEntry]->GetSelectEntry(); + if(sSel != sNone) + { + aNew.aColumnPairs[nWriteIndex].sRealColumnName = sSel; + aNew.aColumnPairs[nWriteIndex].sLogicalColumnName = pDatMan->GetDefColumnName(nEntry); + nWriteIndex++; + } + } + pDatMan->SetMapping(pDatMan->getActiveDataTable(), &aNew); + EndDialog(RET_OK); + return 0; +} +/* -----------------18.11.99 10:23------------------- + + --------------------------------------------------*/ +class DBChangeDialog_Impl : public ModalDialog +{ + OKButton aOKBT; + CancelButton aCancelBT; + HelpButton aHelpBT; + + GroupBox aSelectionGB; + SvTabListBox aSelectionLB; + HeaderBar aSelectionHB; + + String aEntryST; + String aURLST; + + BibDataManager* pDatMan; + + DECL_LINK(EndDragHdl, HeaderBar*); + DECL_LINK(DoubleClickHdl, SvTabListBox*); +public: + DBChangeDialog_Impl(Window* pParent, BibDataManager* pMan ); + ~DBChangeDialog_Impl(); + + String GetCurrentURL()const; +}; + +/*-- 18.11.99 10:35:20--------------------------------------------------- + + -----------------------------------------------------------------------*/ +DBChangeDialog_Impl::DBChangeDialog_Impl(Window* pParent, BibDataManager* pMan ) : + ModalDialog(pParent, BibResId(RID_DLG_DBCHANGE) ), + aOKBT(this, ResId( BT_OK )), + aCancelBT(this, ResId( BT_CANCEL )), + aHelpBT(this, ResId( BT_HELP )), + aSelectionGB(this, ResId( GB_SELECTION )), + aSelectionLB(this, ResId( LB_SELECTION )), + aSelectionHB(this, ResId( HB_SELECTION )), + aEntryST(ResId(ST_ENTRY)), + aURLST( ResId(ST_URL)), + pDatMan(pMan) +{ + FreeResource(); + aSelectionHB.SetEndDragHdl( LINK(this, DBChangeDialog_Impl, EndDragHdl)); + aSelectionLB.SetDoubleClickHdl( LINK(this, DBChangeDialog_Impl, DoubleClickHdl)); + try + { + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + uno::Reference< data::XDatabaseFavorites > xFav(xMgr->createInstance( C2U("com.sun.star.data.DatabaseEngine") ), UNO_QUERY ); + // TODO : XDatabaseFavorites is an obsolete interface, the whole dialog has to be based on + // the sdb::DatabaseAccessContext service + + uno::Sequence< beans::PropertyValue > aFavs = xFav->getFavorites(); + const beans::PropertyValue* pValues = aFavs.getConstArray(); + + Size aSize = aSelectionHB.GetSizePixel(); + long nTabs[3]; + nTabs[0] = 2;// Number of Tabs + nTabs[1] = 0; + nTabs[2] = aSize.Width() / 4; + + aSelectionHB.SetStyle(aSelectionHB.GetStyle()|WB_STDHEADERBAR); + aSelectionHB.InsertItem( 1, aEntryST, nTabs[2]); + aSelectionHB.InsertItem( 2, aURLST, aSize.Width() - nTabs[2]); + aSelectionHB.SetSizePixel(aSelectionHB.CalcWindowSizePixel()); + aSelectionHB.Show(); + + aSelectionLB.SetHelpId(HID_SELECTION_TLB); + aSelectionLB.SetTabs( &nTabs[0], MAP_PIXEL ); + aSelectionLB.SetWindowBits(WB_CLIPCHILDREN|WB_SORT); + //aSelectionLB.SetSelectHdl(LINK(this, SwGlossaryGroupDlg, SelectHdl)); + aSelectionLB.GetModel()->SetSortMode(SortAscending); + + String sActiveURL = pDatMan->getActiveDataSource(); + sActiveURL = URIHelper::SmartRelToAbs(sActiveURL); + for(int i = 0; i < aFavs.getLength(); i++) + { + String sTemp(pValues[i].Name); + sTemp += '\t'; + String sSource = *(OUString*)pValues[i].Value.getValue(); + sTemp += sSource; + SvLBoxEntry* pEntry = aSelectionLB.InsertEntry(sTemp); +// String sTempPath = INetURLObject(sSource).PathToFileName(); + sal_Bool bCaseSensitive = lcl_IsCaseSensitive(sSource); +// sal_Bool bCaseSensitive = DirEntry(sTempPath).IsCaseSensitive(); + if((bCaseSensitive && sActiveURL == sSource)|| + !bCaseSensitive && COMPARE_EQUAL == sActiveURL.CompareTo(sSource)) + { + aSelectionLB.Select(pEntry); + } + } + aSelectionLB.GetModel()->Resort(); + + } + catch(...) + { + DBG_ERROR("Exception in BibDataManager::DBChangeDialog_Impl::DBChangeDialog_Impl") + } + + +} +/* -----------------06.12.99 12:09------------------- + + --------------------------------------------------*/ +IMPL_LINK(DBChangeDialog_Impl, DoubleClickHdl, SvTabListBox*, pLB) +{ + EndDialog(RET_OK); + return 0; +} +/* -----------------18.11.99 11:17------------------- + + --------------------------------------------------*/ +IMPL_LINK(DBChangeDialog_Impl, EndDragHdl, HeaderBar*, pHB) +{ + long nTabs[3]; + nTabs[0] = 2;// Number of Tabs + nTabs[1] = 0; + nTabs[2] = pHB->GetItemSize( 1 ); + aSelectionLB.SetTabs( &nTabs[0], MAP_PIXEL ); + return 0; +}; + +/*-- 18.11.99 10:35:20--------------------------------------------------- + + -----------------------------------------------------------------------*/ +DBChangeDialog_Impl::~DBChangeDialog_Impl() +{ +} +/* -----------------18.11.99 12:36------------------- + + --------------------------------------------------*/ +String DBChangeDialog_Impl::GetCurrentURL()const +{ + String sRet; + SvLBoxEntry* pEntry = aSelectionLB.FirstSelected(); + if(pEntry) + { + sRet = aSelectionLB.GetEntryText(pEntry, 1); + } + return sRet; +} + +//----------------------------------------------------------------------------- +#define STR_UID "uid" +rtl::OUString gGridName(C2U("theGrid")); +rtl::OUString gViewName(C2U("theView")); +rtl::OUString gGlobalName(C2U("theGlobals")); +rtl::OUString gBeamerSize(C2U("theBeamerSize")); +rtl::OUString gViewSize(C2U("theViewSize")); + +BibDataManager::BibDataManager(BibRegistry * pRegistry) : + pMappingsArr(new MappingArray), + pToolbar(0), + pGridWin(0) +{ + //Names of the default columns + aColumnDefaults[0] = C2S("Identifier"); + aColumnDefaults[1] = C2S("BibliographyType"); + aColumnDefaults[2] = C2S("Author"); + aColumnDefaults[3] = C2S("Title"); + aColumnDefaults[4] = C2S("Year"); + aColumnDefaults[5] = C2S("ISBN"); + aColumnDefaults[6] = C2S("Booktitle"); + aColumnDefaults[7] = C2S("Chapter"); + aColumnDefaults[8] = C2S("Edition"); + aColumnDefaults[9] = C2S("Editor"); + aColumnDefaults[10] = C2S("Howpublished"); + aColumnDefaults[11] = C2S("Institution"); + aColumnDefaults[12] = C2S("Journal"); + aColumnDefaults[13] = C2S("Month"); + aColumnDefaults[14] = C2S("Note"); + aColumnDefaults[15] = C2S("Annote"); + aColumnDefaults[16] = C2S("Number"); + aColumnDefaults[17] = C2S("Organizations"); + aColumnDefaults[18] = C2S("Pages"); + aColumnDefaults[19] = C2S("Publisher"); + aColumnDefaults[20] = C2S("Address"); + aColumnDefaults[21] = C2S("School"); + aColumnDefaults[22] = C2S("Series"); + aColumnDefaults[23] = C2S("ReportType"); + aColumnDefaults[24] = C2S("Volume"); + aColumnDefaults[25] = C2S("URL"); + aColumnDefaults[26] = C2S("Custom1"); + aColumnDefaults[27] = C2S("Custom2"); + aColumnDefaults[28] = C2S("Custom3"); + aColumnDefaults[29] = C2S("Custom4"); + aColumnDefaults[30] = C2S("Custom5"); + +// nEditMode = DatabaseRecordMode_STANDARD; + xRegistry = pRegistry; + xGlobalProps=createGlobalProperties(); + + SfxAppIniManagerProperty aProp; + GetpApp()->Property( aProp ); + + SfxIniManager* pIniMan = aProp.GetIniManager(); + if(pIniMan) + { + String sBibMapping; + sal_uInt16 nIdx = USHRT_MAX; + String sEntry; + do + { + String sKey(C2S(BIBLIOGRAPHY_INI_DB_ENTRY)); + String sMapKey = C2S(BIBLIOGRAPHY_INI_MAPPING); + if(USHRT_MAX != nIdx) + { + sKey += nIdx; + sMapKey += nIdx; + } + + sEntry = pIniMan->ReadKey( C2S(BIBLIOGRAPHY_INI_GROUP), + sKey ); + String sURL = sEntry.GetToken(0, ';'); + sURL = pIniMan->SubstPathVars( sURL ); + + sURL = URIHelper::SmartRelToAbs(sURL); + + + String sTableName = sEntry.GetToken(1, ';'); + + sBibMapping = pIniMan->ReadKey( C2S(BIBLIOGRAPHY_INI_GROUP), + sMapKey ); + if(sTableName.Len()) + { + Mapping* pNew = new Mapping; + pNew->sTableName = sTableName; + pNew->sURL = sURL; + sal_uInt16 nMapTokens = sBibMapping.GetTokenCount(MAP_TOKEN); + for(sal_uInt16 i = 0; i < nMapTokens && i < COLUMN_COUNT; i++) + { + String sPair = sBibMapping.GetToken(i, MAP_TOKEN); + pNew->aColumnPairs[i].sLogicalColumnName = sPair.GetToken(0, PAIR_TOKEN); + pNew->aColumnPairs[i].sRealColumnName = sPair.GetToken(1, PAIR_TOKEN); + } + pMappingsArr->Insert(pNew, pMappingsArr->Count()); + } + nIdx = USHRT_MAX == nIdx ? 0 : nIdx + 1; + } + while(sEntry.Len()); + } +} +/* -------------------------------------------------- + + --------------------------------------------------*/ +BibDataManager::~BibDataManager() +{ + uno::Reference< XLoadable > xLoad(xForm, UNO_QUERY); + uno::Reference< lang::XComponent > xComp(xForm, UNO_QUERY); + if (xForm.is()) + { + RemoveMeAsUidListener(); + if (xLoad.is()) + xLoad->unload(); + if (xComp.is()) + xComp->dispose(); + xForm = NULL; + } + delete pMappingsArr; +} +//------------------------------------------------------------------------ +void BibDataManager::InsertFields(const uno::Reference< XFormComponent > & xGrid) +{ + if (!xGrid.is()) + return; +try +{ + uno::Reference< XNameAccess > xFields = getColumns(xForm); + if (!xFields.is()) + return; + + uno::Reference< XGridColumnFactory > xColFactory(xGrid, UNO_QUERY); + uno::Reference< XNameContainer > xColContainer(xGrid, UNO_QUERY); + + uno::Reference< XPropertySet > xField; + + uno::Sequence<rtl::OUString> aFields(xFields->getElementNames()); + const rtl::OUString* pFields = aFields.getConstArray(); + sal_Int32 nCount=aFields.getLength(); + uno::Any aElement; + for( sal_Int32 i=0; i<nCount; i++ ) + { + rtl::OUString aCurrentColName= pFields[i]; + + aElement = xFields->getByName(aCurrentColName); + xField = *(uno::Reference< XPropertySet > *)aElement.getValue(); + + sal_Int32 nFormatKey = *(sal_Int32*)xField->getPropertyValue(FM_PROP_FORMATKEY).getValue(); + + uno::Reference< XPropertySet > xCurrentCol = xColFactory->createColumn(getControlName(nFormatKey)); + + Any aColName; aColName <<= aCurrentColName; + xCurrentCol->setPropertyValue(FM_PROP_CONTROLSOURCE, aColName); + xCurrentCol->setPropertyValue(FM_PROP_LABEL, aColName); + + xColContainer->insertByName(aCurrentColName, uno::Any(&xCurrentCol, ::getCppuType((Reference<XPropertySet>*)0))); + } +} +catch(...) +{ + DBG_ERROR("Exception in BibDataManager::InsertFields") +} + + +} +/* -------------------------------------------------- + + --------------------------------------------------*/ +uno::Reference< awt::XControlModel > BibDataManager::createGridModel() +{ + return createGridModel(xForm); +} +/* -------------------------------------------------- + + --------------------------------------------------*/ +uno::Reference< awt::XControlModel > BibDataManager::createGridModel(const uno::Reference< XForm > & xDbForm) +{ + try + { + uno::Reference< XPropertySet > aFormPropSet( xDbForm, UNO_QUERY ); + uno::Any aDbSource=aFormPropSet->getPropertyValue(C2U("Command")); + rtl::OUString aName=*(OUString*)aDbSource.getValue(); + + //xGridModel=loadGridModel(aName); + xGridModel=loadGridModel(gGridName); + + uno::Reference< XNameContainer > xNameCont(xDbForm, UNO_QUERY); + + if(xNameCont->hasByName(aName)) + { + xNameCont->removeByName(aName); + } + + xNameCont->insertByName(aName, uno::Any(&xGridModel, ::getCppuType((Reference<XFormComponent>*)0))); + + } + catch(...) + { + DBG_ERROR("::createGridModel: something went wrong !"); + } + + + return xGridModel; +} +/* -------------------------------------------------- + + --------------------------------------------------*/ +uno::Reference< XForm > BibDataManager::getDatabaseForm() +{ + return xForm; +} +/* -------------------------------------------------- + + --------------------------------------------------*/ +uno::Reference< XForm > BibDataManager::createDatabaseForm(const rtl::OUString& rURL, rtl::OUString& rTable) +{ + uno::Reference< XForm > xResult; + try + { + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + xForm = uno::Reference< XForm > (xMgr->createInstance( C2U("com.sun.star.form.component.Form") ), + UNO_QUERY ); + + uno::Reference< XPropertySet > aPropertySet(xForm, UNO_QUERY ); + + aDataSourceURL = rURL; + if(aPropertySet.is()) + { + Any aVal; aVal <<= rURL; + aPropertySet->setPropertyValue(C2U("DataSourceName"), aVal); + aVal <<= (sal_Int32)sdbc::ResultSetType::SCROLL_INSENSITIVE; + aPropertySet->setPropertyValue(C2U("ResultSetType"),aVal ); + aVal <<= (sal_Int32)sdbc::ResultSetConcurrency::READ_ONLY; + aPropertySet->setPropertyValue(C2U("ResultSetConcurrency"), aVal); + + //Caching for Performance + aVal <<= (sal_Int32)50; + aPropertySet->setPropertyValue(C2U("FetchSize"), aVal); + + uno::Reference< sdbc::XConnection > xConnection = getConnection(rURL); + uno::Reference< sdbcx::XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY); + uno::Reference< XNameAccess > xTables = xSupplyTables.is() ? + xSupplyTables->getTables() : uno::Reference< XNameAccess > (); + + uno::Sequence<rtl::OUString> aTableNameSeq; + if (xTables.is()) + aTableNameSeq = xTables->getElementNames(); + + if(aTableNameSeq.getLength() > 0) + { + const rtl::OUString* pTableNames = aTableNameSeq.getConstArray(); + if(rTable.getLength()) + aActiveDataTable = rTable; + else + rTable = aActiveDataTable = pTableNames[0]; + + uno::Reference< registry::XRegistryKey > xRoot = xRegistry->getRootKey(); + uno::Reference< registry::XRegistryKey > xKey = xRoot->openKey(aActiveDataTable); + if(!xKey.is()) + xKey = xRoot->createKey(aActiveDataTable); + + xSourceProps=uno::Reference< XPropertySet > (xKey, UNO_QUERY); + + aVal <<= aActiveDataTable; + aPropertySet->setPropertyValue(C2U("Command"), aVal); + aVal <<= (sal_Int32)CommandType::TABLE; + aPropertySet->setPropertyValue(C2U("CommandType"), aVal); + + + uno::Reference< sdbc::XDatabaseMetaData > xMetaData = xConnection->getMetaData(); + aQuoteChar = xMetaData->getIdentifierQuoteString(); + + uno::Reference< sdb::XSQLQueryComposerFactory > xFactory(xConnection, UNO_QUERY); + xParser = xFactory->createQueryComposer(); + + rtl::OUString aString(C2U("SELECT * FROM ")); + aString += aQuoteChar; + aString += aActiveDataTable; + aString += aQuoteChar; + xParser->setQuery(aString); + setQueryField(getQueryField()); + startQueryWith(getQueryString()); + + xResult = xForm; + } + } + } + catch(...) + { + DBG_ERROR("::createDatabaseForm: something went wrong !"); + } + + + return xResult; +} +//------------------------------------------------------------------------ +uno::Sequence<rtl::OUString> BibDataManager::getDataSources() +{ + uno::Sequence<rtl::OUString> aTableNameSeq; + + try + { + uno::Reference< sdbcx::XTablesSupplier > xSupplyTables(getConnection(xForm), UNO_QUERY); + uno::Reference< XNameAccess > xTables; + if (xSupplyTables.is()) + xTables = xSupplyTables->getTables(); + if (xTables.is()) + aTableNameSeq = xTables->getElementNames(); + } + catch(...) + { + DBG_ERROR("::getDataSources: something went wrong !"); + } + + + return aTableNameSeq; +} +//------------------------------------------------------------------------ +rtl::OUString BibDataManager::getActiveDataTable() +{ + return aActiveDataTable; +} +//------------------------------------------------------------------------ +uno::Reference< XSQLQueryComposer > BibDataManager::getParser() +{ + return xParser; +} +//------------------------------------------------------------------------ +void BibDataManager::setFilter(const rtl::OUString& rQuery) +{ + try + { + xParser->setFilter(rQuery); + rtl::OUString aQuery=xParser->getFilter(); + uno::Reference< XPropertySet > aPropertySet(xForm, UNO_QUERY ); + Any aVal; aVal <<= aQuery; + aPropertySet->setPropertyValue(C2U("Filter"), aVal); + BOOL bVal = sal_True; + aVal.setValue(&bVal, ::getBooleanCppuType()); + aPropertySet->setPropertyValue(C2U("ApplyFilter"), aVal); + uno::Reference< XLoadable > xLoadable(xForm, UNO_QUERY ); + xLoadable->reload(); + } + catch(...) + { + DBG_ERROR("::setFilterOnActiveDataSource: something went wrong !"); + } + + +} +//------------------------------------------------------------------------ +rtl::OUString BibDataManager::getFilter() +{ + + rtl::OUString aQueryString; + try + { + uno::Reference< XPropertySet > aPropertySet(xForm, UNO_QUERY ); + uno::Any aQuery=aPropertySet->getPropertyValue(C2U("Filter")); + + if(aQuery.getValueType() == ::getCppuType((OUString*)0)) + { + aQueryString=*(OUString*)aQuery.getValue(); + } + } + catch(...) + { + DBG_ERROR("::getFilterOnActiveDataSource: something went wrong !"); + } + + + return aQueryString; + +} +//------------------------------------------------------------------------ +uno::Sequence<rtl::OUString> BibDataManager::getQueryFields() +{ + uno::Sequence<rtl::OUString> aFieldSeq; + uno::Reference< XNameAccess > xFields = getColumns(xForm); + if (xFields.is()) + aFieldSeq = xFields->getElementNames(); + return aFieldSeq; +} +//------------------------------------------------------------------------ +void BibDataManager::setQueryField(const rtl::OUString& rQuery) +{ + try + { + Any aQuery; aQuery <<= rQuery; + xSourceProps->setPropertyValue(C2U("QueryField"),aQuery); + + } + catch(...) + { + DBG_ERROR("Exception in BibDataManager::setQueryField") + } + +} +//------------------------------------------------------------------------ +rtl::OUString BibDataManager::getQueryField() +{ + rtl::OUString aFieldString; + try + { + uno::Any aField=xSourceProps->getPropertyValue(C2U("QueryField")); + + if(aField.getValueType() == ::getVoidCppuType()) + { + uno::Sequence<rtl::OUString> aSeq=getQueryFields(); + const rtl::OUString* pFields = aSeq.getConstArray(); + if(aSeq.getLength()>0) + { + aFieldString=pFields[0]; + } + } + else + { + aFieldString = *(OUString*)aField.getValue(); + } + + } + catch(...) + { + DBG_ERROR("Exception in BibDataManager::getQueryField") + } + + + return aFieldString; +} +//------------------------------------------------------------------------ +void BibDataManager::startQueryWith(const OUString& rQuery) +{ + try + { + uno::Any aQuery; + aQuery <<= rQuery; + xSourceProps->setPropertyValue(C2U("QueryText"), aQuery); + + rtl::OUString aQueryString; + if(rQuery.len()>0) + { + aQueryString=aQuoteChar; + aQueryString+=getQueryField(); + aQueryString+=aQuoteChar; + aQueryString+=C2U(" like '"); + String sQuery(rQuery); + sQuery.SearchAndReplaceAll('?','_'); + sQuery.SearchAndReplaceAll('*','%'); + aQueryString += sQuery; + aQueryString+=C2U("%'"); + } + setFilter(aQueryString); + + } + catch(...) + { + DBG_ERROR("Exception in BibDataManager::StartQueryWith") + } + +} +//------------------------------------------------------------------------ +rtl::OUString BibDataManager::getQueryString() +{ + rtl::OUString aQueryString; + try + { + uno::Any aQuery=xSourceProps->getPropertyValue(C2U("QueryText")); + if(aQuery.getValueType() == ::getCppuType((OUString*)0)) + { + aQueryString=*(OUString*)aQuery.getValue(); + } + } + catch(...) + { + DBG_ERROR("Exception in BibDataManager::getQueryString") + } + + + return aQueryString; +} +/* -----------------03.12.99 15:05------------------- + + --------------------------------------------------*/ +void BibDataManager::setActiveDataSource(const rtl::OUString& rURL) +{ + //unloadDatabase(); + rtl::OUString uTable; + aDataSourceURL = rURL; + uno::Reference< XPropertySet > aPropertySet(xForm, UNO_QUERY ); + if(aPropertySet.is()) + { + Any aVal; aVal <<= rURL; + aPropertySet->setPropertyValue(C2U("DataSourceName"), aVal); + uno::Sequence<rtl::OUString> aTableNameSeq; + uno::Reference< sdbc::XConnection > xConnection = getConnection(xForm); + uno::Reference< sdbcx::XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY); + if(xSupplyTables.is()) + { + uno::Reference< XNameAccess > xAccess = xSupplyTables->getTables(); + aTableNameSeq = xAccess->getElementNames(); + } + if(aTableNameSeq.getLength() > 0) + { + const rtl::OUString* pTableNames = aTableNameSeq.getConstArray(); + aActiveDataTable = pTableNames[0]; + aVal <<= aActiveDataTable; + aPropertySet->setPropertyValue(C2U("Command"), aVal); + rtl::OUString aString(C2U("SELECT * FROM ")); + aString+=aQuoteChar; + aString+=aActiveDataTable; + aString+=aQuoteChar; + xParser->setQuery(aString); + setQueryField(getQueryField()); + startQueryWith(getQueryString()); + setActiveDataTable(aActiveDataTable); + } + FeatureStateEvent aEvent; + util::URL aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + //aEvent.Source = (XDispatch *) this; + aEvent.FeatureDescriptor = getActiveDataTable(); + + uno::Sequence<rtl::OUString> aStringSeq = getDataSources(); + aEvent.State.setValue(&aStringSeq, ::getCppuType((uno::Sequence<rtl::OUString>*)0)); + + if(pToolbar) + { + aURL.Complete =C2U(".uno:Bib/source"); + aEvent.FeatureURL = aURL; + pToolbar->statusChanged( aEvent ); + } + if(pGridWin) + { + aURL.Complete =C2U(".uno:Bib/newGridModel"); + aEvent.FeatureURL = aURL; + uno::Reference< awt::XControlModel > xModel = createGridModel(); + aEvent.State.setValue(&xModel, ::getCppuType((Reference<awt::XControlModel>*)0)); + pGridWin->statusChanged( aEvent ); + } + } +} +/* -------------------------------------------------- + + --------------------------------------------------*/ +void BibDataManager::setActiveDataTable(const rtl::OUString& rTable) +{ + ResetIdentifierMapping(); + try + { + sal_Bool bFlag=sal_False; + uno::Reference< XPropertySet > aPropertySet(xForm, UNO_QUERY ); + + if(aPropertySet.is()) + { + uno::Reference< sdbc::XConnection > xConnection = getConnection(xForm); + uno::Reference< sdbcx::XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY); + uno::Reference< XNameAccess > xAccess = xSupplyTables->getTables(); + uno::Sequence<rtl::OUString> aTableNameSeq = xAccess->getElementNames(); + sal_uInt32 nCount = aTableNameSeq.getLength(); + const rtl::OUString* pTableNames = aTableNameSeq.getConstArray(); + + for(sal_Int32 i=0;i<nCount;i++) + { + if(rTable == pTableNames[i]) + { + aActiveDataTable=rTable; + Any aVal; aVal <<= rTable; + aPropertySet->setPropertyValue(C2U("Command"), aVal); + bFlag=sal_True; + break; + } + } + if(bFlag) + { +/* if(xGridModel.is()) + { + saveGridModel(xGridModel); + }*/ + + uno::Reference< registry::XRegistryKey > xRoot = xRegistry->getRootKey(); + uno::Reference< registry::XRegistryKey > xKey = xRoot->openKey(aActiveDataTable); + + if(!xKey.is()) + xKey = xRoot->createKey(aActiveDataTable); + + xSourceProps=uno::Reference< XPropertySet > (xKey, UNO_QUERY); + + uno::Reference< sdbc::XDatabaseMetaData > xMetaData = xConnection->getMetaData(); + aQuoteChar = xMetaData->getIdentifierQuoteString(); + + uno::Reference< sdb::XSQLQueryComposerFactory > xFactory(xConnection, UNO_QUERY); + xParser = xFactory->createQueryComposer(); + + rtl::OUString aString(C2U("SELECT * FROM ")); + aString+=aQuoteChar; + aString+=aActiveDataTable; + aString+=aQuoteChar; + xParser->setQuery(aString); + + setQueryField(getQueryField()); + startQueryWith(getQueryString()); + + BibModul::SetBibliographyURL(aDataSourceURL, aActiveDataTable); + } + if(pBibView) + pBibView->UpdatePages(); + } + } + catch(...) + { + DBG_ERROR("::setActiveDataTable: something went wrong !"); + } + +} +//------------------------------------------------------------------------ +void BibDataManager::loadDatabase() +{ + if(xForm.is()) + { + uno::Reference< XLoadable > xFormAsLoadable(xForm, UNO_QUERY ); + DBG_ASSERT(xFormAsLoadable.is(), "BibDataManager::loadDatabase : invalid form !"); + xFormAsLoadable->load(); + xFormAsLoadable->reload(); // why ? may be very expensive ! + + SetMeAsUidListener(); + } +} +//------------------------------------------------------------------------ +void BibDataManager::unloadDatabase() +{ + if(xForm.is()) + { + RemoveMeAsUidListener(); + uno::Reference< XLoadable > xFormAsLoadable(xForm, UNO_QUERY ); + DBG_ASSERT(xFormAsLoadable.is(), "BibDataManager::unloadDatabase : invalid form !"); + xFormAsLoadable->unload(); + } +} +//------------------------------------------------------------------------ +uno::Reference< awt::XControlModel > BibDataManager::loadGridModel(const rtl::OUString& rName) +{ + uno::Reference< awt::XControlModel > xModel; + + try + { + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + uno::Reference< XInterface > xObject = xMgr->createInstance(C2U("com.sun.star.form.component.GridControl")); + xModel=uno::Reference< awt::XControlModel > ( xObject, UNO_QUERY ); + uno::Reference< XPropertySet > xPropSet( xModel, UNO_QUERY ); + uno::Any aDbSource; aDbSource <<= rName; + xPropSet->setPropertyValue( C2U("Name"),aDbSource); + rtl::OUString aControlName(C2U("com.sun.star.form.control.ExtendedGridControl")); + uno::Any aAny; aAny <<= aControlName; + xPropSet->setPropertyValue( C2U("DefaultControl"),aAny ); + + uno::Reference< XFormComponent > aFormComp(xModel,UNO_QUERY ); + InsertFields(aFormComp); + + rtl::OUString uProp(C2U("HelpURL")); + uno::Reference< XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo(); + if(xPropInfo->hasPropertyByName(uProp)) + { + String sId(C2S("HID:")); + sId += HID_BIB_DB_GRIDCTRL; + uno::Any aVal; aVal <<= OUString(sId); + xPropSet->setPropertyValue(uProp, aVal); + } + } + catch(...) + { + DBG_ERROR("::loadGridModel: something went wrong !"); + } + + + return xModel; +} +//------------------------------------------------------------------------ +/*void BibDataManager::saveGridModel(const uno::Reference< awt::XControlModel > & rGridModel) +{ + try + { + uno::Reference< XPersistObject > aPersistObject(rGridModel, UNO_QUERY ); + + uno::Any aGridModel(&aPersistObject, ::getCppuType((const XPersistObject*)0)); + + xSourceProps->setPropertyValue(gGridName,aGridModel); + } + catch(...) + { + DBG_ERROR("::saveGridModelData: something went wrong !"); + } + +}*/ +//------------------------------------------------------------------------ +uno::Reference< XPropertySet > BibDataManager::createGlobalProperties() +{ + try + { + uno::Reference< registry::XRegistryKey > xRoot = xRegistry->getRootKey(); + uno::Reference< registry::XRegistryKey > xKey = xRoot->openKey(gGlobalName); + if(!xKey.is()) + xKey = xRoot->createKey(gGlobalName); + + return uno::Reference< XPropertySet > (xKey, UNO_QUERY); + } + + catch(...) + { + DBG_ERROR("::getViewProperties: something went wrong !"); + } + + return uno::Reference< XPropertySet > (); +} +//------------------------------------------------------------------------ +void BibDataManager::setViewSize(long nSize) +{ + try + { + uno::Any aViewSize; aViewSize <<= (sal_Int32) nSize; + xGlobalProps->setPropertyValue(gViewSize,aViewSize); + } + catch(...) + { + DBG_ERROR("::setViewSize: something went wrong !"); + } + +} +//------------------------------------------------------------------------ +long BibDataManager::getViewSize() +{ + long nSize=0; + try + { + uno::Any aViewSize=xGlobalProps->getPropertyValue(gViewSize); + + if(aViewSize.getValueType() != ::getVoidCppuType()) + { + aViewSize >>= nSize; + } + } + catch(...) + { + DBG_ERROR("::getViewSize: something went wrong !"); + } + return nSize; +} +//------------------------------------------------------------------------ +void BibDataManager::setBeamerSize(long nSize) +{ + try + { + uno::Any aBeamerSize; aBeamerSize <<= (sal_Int32) nSize; + xGlobalProps->setPropertyValue(gBeamerSize,aBeamerSize); + } + catch(...) + { + DBG_ERROR("::setBeamerSize: something went wrong !"); + } + +} +//------------------------------------------------------------------------ +long BibDataManager::getBeamerSize() +{ + long nSize=0; + try + { + uno::Any aBeamerSize=xGlobalProps->getPropertyValue(gBeamerSize); + + if(aBeamerSize.getValueType() != ::getVoidCppuType()) + { + aBeamerSize >>= nSize; + } + } + catch(...) + { + DBG_ERROR("::getBeamerSize: something went wrong !"); + } + return nSize; +} +//------------------------------------------------------------------------ +uno::Reference< XPropertySet > BibDataManager::getViewProperties() +{ + try + { + uno::Reference< registry::XRegistryKey > xKey = uno::Reference< registry::XRegistryKey > (xSourceProps, UNO_QUERY); + uno::Reference< registry::XRegistryKey > xViewKey=xKey->openKey(gViewName); + if(!xViewKey.is()) + { + xViewKey=xKey->createKey(gViewName); + } + return uno::Reference< XPropertySet > (xViewKey, UNO_QUERY); + } + catch(...) + { + DBG_ERROR("::getViewProperties: something went wrong !"); + } + return uno::Reference< XPropertySet > (); +} +//------------------------------------------------------------------------ +rtl::OUString BibDataManager::getControlName(sal_Int32 nFormatKey ) +{ + rtl::OUString aResStr; + switch (nFormatKey) + { + case DataType::BIT: + aResStr=C2U("CheckBox"); + break; + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + aResStr=C2U("NumericField"); ; + break; + case DataType::REAL: + case DataType::DOUBLE: + case DataType::NUMERIC: + case DataType::DECIMAL: + aResStr=C2U("FormattedField"); + break; + case DataType::TIMESTAMP: + aResStr=C2U("FormattedField"); + break; + case DataType::DATE: + aResStr=C2U("DateField"); + break; + case DataType::TIME: + aResStr=C2U("TimeField"); + break; + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + default: + aResStr=C2U("TextField"); + break; + } + return aResStr; +} +//------------------------------------------------------------------------ +uno::Reference< awt::XControlModel > BibDataManager::loadControlModel(const rtl::OUString& rName, sal_Bool bForceListBox) +{ + uno::Reference< awt::XControlModel > xModel; + + rtl::OUString aName(C2U("View_")); + aName+=rName; + + try + { + uno::Reference< io::XPersistObject > aObject; + uno::Any aControlModel=xSourceProps->getPropertyValue(aName); + if(aControlModel.getValueType() == ::getCppuType((Reference<io::XPersistObject>*)0)) + { + aObject=*(uno::Reference< io::XPersistObject > *)aControlModel.getValue(); + } + + if(!aObject.is() ) + { + uno::Reference< XNameAccess > xFields = getColumns(xForm); + if (!xFields.is()) + return xModel; + uno::Reference< XPropertySet > xField; + + uno::Any aElement; + + if(xFields->hasByName(rName)) + { + aElement = xFields->getByName(rName); + xField = *(uno::Reference< XPropertySet > *)aElement.getValue(); + uno::Reference< XPropertySetInfo > xInfo = xField.is() ? xField->getPropertySetInfo() : uno::Reference< XPropertySetInfo > (); + sal_Int32 nFormatKey = 0; + if (xInfo.is() && xInfo->hasPropertyByName(FM_PROP_FORMATKEY)) + xField->getPropertyValue(FM_PROP_FORMATKEY) >>= nFormatKey; + + rtl::OUString aInstanceName(C2U("com.sun.star.form.component.")); + + if (bForceListBox) + aInstanceName += C2U("ListBox"); + else + aInstanceName += getControlName(nFormatKey); + + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + uno::Reference< XInterface > xObject = xMgr->createInstance(aInstanceName); + xModel=uno::Reference< awt::XControlModel > ( xObject, UNO_QUERY ); + uno::Reference< XPropertySet > xPropSet( xModel, UNO_QUERY ); + uno::Any aFieldName; aFieldName <<= aName; + xPropSet->setPropertyValue( FM_PROP_NAME,aFieldName); + + uno::Any aDbSource; aDbSource <<= rName; + xPropSet->setPropertyValue(FM_PROP_CONTROLSOURCE,aDbSource); + + uno::Reference< XFormComponent > aFormComp(xModel,UNO_QUERY ); + + uno::Reference< XNameContainer > xNameCont(xForm, UNO_QUERY); + xNameCont->insertByName(aName, uno::Any(&xModel, ::getCppuType((Reference<XFormComponent>*)0))); + } + } + else + { + xModel=uno::Reference< awt::XControlModel > (aObject,UNO_QUERY ); + } + } + catch(...) + { + DBG_ERROR("::loadControlModel: something went wrong !"); + } + return xModel; +} +//------------------------------------------------------------------------ +void BibDataManager::saveCtrModel(const rtl::OUString& rName,const uno::Reference< awt::XControlModel > & rCtrModel) +{ + try + { + rtl::OUString aName(C2U("View_")); + aName+=rName; + + uno::Reference< io::XPersistObject > aPersistObject(rCtrModel, UNO_QUERY ); + + uno::Any aModel(&aPersistObject, ::getCppuType((Reference<io::XPersistObject>*)0)); + + xSourceProps->setPropertyValue(aName,aModel); + } + catch(...) + { + DBG_ERROR("::saveCtrModel: something went wrong !"); + } + +} +//------------------------------------------------------------------------ +void BibDataManager::disposing( const lang::EventObject& Source ) +{ + try + { +// if ( xForm.is()) +// { +// uno::Reference< XPropertySet > aPropSet(xForm, UNO_QUERY ); +// aPropSet->removePropertyChangeListener(FM_PROP_EDITMODE, this); +// } + } + catch(...) + { + DBG_ERROR("::propertyChange: something went wrong !"); + } + + + +} +//------------------------------------------------------------------------ +void BibDataManager::propertyChange(const beans::PropertyChangeEvent& evt) throw( uno::RuntimeException ) +{ + try + { + sal_Bool bFlag=sal_False; + if(evt.PropertyName == FM_PROP_VALUE) + { + if( evt.NewValue.getValueType() == ::getCppuType((Reference<io::XInputStream>*)0) ) + { + uno::Reference< io::XDataInputStream > xStream( + *(const uno::Reference< io::XInputStream > *)evt.NewValue.getValue(), UNO_QUERY ); + aUID <<= xStream->readUTF(); + } + else + aUID = evt.NewValue; + + uno::Reference< sdbcx::XRowLocate > xLocate(xBibCursor, UNO_QUERY); + DBG_ASSERT(xLocate.is(), "BibDataManager::propertyChange : invalid cursor !"); + bFlag = xLocate->moveToBookmark(aUID); + } + } + catch(...) + { + DBG_ERROR("::propertyChange: something went wrong !"); + } + + +} +//------------------------------------------------------------------------ +void BibDataManager::SetMeAsUidListener() +{ +try +{ + uno::Reference< XNameAccess > xFields = getColumns(xForm); + if (!xFields.is()) + return; + + uno::Sequence<rtl::OUString> aFields(xFields->getElementNames()); + const rtl::OUString* pFields = aFields.getConstArray(); + sal_Int32 nCount=aFields.getLength(); + String StrUID(C2S(STR_UID)); + rtl::OUString theFieldName; + for( sal_Int32 i=0; i<nCount; i++ ) + { + String aName= pFields[i]; + + if(aName.EqualsIgnoreCaseAscii(StrUID)) + { + theFieldName=pFields[i]; + break; + } + } + + if(theFieldName.len()>0) + { + uno::Reference< XPropertySet > xPropSet; + uno::Any aElement; + + aElement = xFields->getByName(theFieldName); + xPropSet = *(uno::Reference< XPropertySet > *)aElement.getValue(); + + xPropSet->addPropertyChangeListener(FM_PROP_VALUE, this); + } + +} +catch(...) +{ + DBG_ERROR("Exception in BibDataManager::SetMeAsUidListener") +} + + +} +//------------------------------------------------------------------------ +void BibDataManager::RemoveMeAsUidListener() +{ +try +{ + uno::Reference< XNameAccess > xFields = getColumns(xForm); + if (!xFields.is()) + return; + + + uno::Sequence<rtl::OUString> aFields(xFields->getElementNames()); + const rtl::OUString* pFields = aFields.getConstArray(); + sal_Int32 nCount=aFields.getLength(); + String StrUID(C2S(STR_UID)); + rtl::OUString theFieldName; + for( sal_Int32 i=0; i<nCount; i++ ) + { + String aName= pFields[i]; + + if(aName.EqualsIgnoreCaseAscii(StrUID)) + { + theFieldName=pFields[i]; + break; + } + } + + if(theFieldName.len()>0) + { + uno::Reference< XPropertySet > xPropSet; + uno::Any aElement; + + aElement = xFields->getByName(theFieldName); + xPropSet = *(uno::Reference< XPropertySet > *)aElement.getValue(); + + xPropSet->removePropertyChangeListener(FM_PROP_VALUE, this); + } + +} +catch(...) +{ + DBG_ERROR("Exception in BibDataManager::RemoveMeAsUidListener") +} + + +} +/* -----------------02.11.99 16:11------------------- + + --------------------------------------------------*/ +sal_Bool BibDataManager::moveRelative(sal_Int32 nCount) +{ + sal_Bool bRet = sal_False; + try + { + uno::Reference< XResultSet > xCursor(xForm, UNO_QUERY); + uno::Reference< XResultSetUpdate > xCursorUpdate(xForm, UNO_QUERY); + if (xCursor.is() && xCursorUpdate.is()) + { + bRet = xCursor->relative(nCount); + if (xCursor->isAfterLast()) + xCursorUpdate->moveToInsertRow(); + } + } + catch(...) + { + DBG_ERROR("Exception in BibDataManager::moveRelative") + } + + return bRet; +} +/* -----------------11.11.99 15:51------------------- + + --------------------------------------------------*/ +void BibDataManager::CreateMappingDialog(Window* pParent) +{ + MappingDialog_Impl* pDlg = new MappingDialog_Impl(pParent, this); + if(RET_OK == pDlg->Execute() && pBibView) + { + unloadDatabase(); + pBibView->UpdatePages(); + loadDatabase(); + } + delete pDlg; +} +/* -------------------------------------------------- + + --------------------------------------------------*/ +rtl::OUString BibDataManager::CreateDBChangeDialog(Window* pParent) +{ + rtl::OUString uRet; + DBChangeDialog_Impl * pDlg = new DBChangeDialog_Impl(pParent, this ); + if(RET_OK == pDlg->Execute()) + { + String sNewURL = pDlg->GetCurrentURL(); + if(sNewURL != String(getActiveDataSource())) + { + uRet = sNewURL; + } + } + delete pDlg; + return uRet; +} +/* -----------------12.11.99 14:26------------------- + + --------------------------------------------------*/ +const Mapping* BibDataManager::GetMapping(const rtl::OUString& rTableName, const rtl::OUString* pURL) const +{ + String sTable(rTableName); + String sURL(aDataSourceURL); + if(pURL) + sURL = String(*pURL); + for(sal_uInt16 i = 0; i < pMappingsArr->Count(); i++) + { + sal_Bool bCaseSensitive = sal_True; + INetURLObject aTempURL(sURL); + if(INET_PROT_FILE == aTempURL.GetProtocol()) + { + sal_Bool bCaseSensitive = lcl_IsCaseSensitive(aTempURL.GetMainURL()); +// DirEntry aEnt(aTempURL.GetPath()); +// bCaseSensitive = aEnt.IsCaseSensitive(); + } + + const Mapping* pMapping = pMappingsArr->GetObject(i); + sal_Bool bURLEqual = bCaseSensitive ? + sURL.Equals(pMapping->sURL) : + sURL.EqualsIgnoreCaseAscii(pMapping->sURL); + + if(sTable == pMapping->sTableName && bURLEqual) + return pMapping; + } + return 0; +} +/* -----------------12.11.99 14:26------------------- + + --------------------------------------------------*/ +void BibDataManager::SetMapping(const rtl::OUString& rTableName, const Mapping* pSetMapping) +{ + ResetIdentifierMapping(); + String sTable(rTableName); + const String sURL(aDataSourceURL); + for(sal_uInt16 i = 0; i < pMappingsArr->Count(); i++) + { + const Mapping* pMapping = pMappingsArr->GetObject(i); + + sal_Bool bCaseSensitive = sal_True; + INetURLObject aTempURL(sURL); + if(INET_PROT_FILE == aTempURL.GetProtocol()) + { + sal_Bool bCaseSensitive = lcl_IsCaseSensitive(aTempURL.GetMainURL()); +// DirEntry aEnt(aTempURL.GetPath()); +// bCaseSensitive = aEnt.IsCaseSensitive(); + } + + sal_Bool bURLEqual = bCaseSensitive ? + sURL.Equals(pMapping->sURL) : + sURL.EqualsIgnoreCaseAscii(pMapping->sURL); + + if(sTable == pMapping->sTableName && bURLEqual) + { + pMappingsArr->DeleteAndDestroy(i, 1); + break; + } + } + Mapping* pNew = new Mapping(*pSetMapping); + pMappingsArr->Insert(pNew, pMappingsArr->Count()); + + SfxAppIniManagerProperty aProp; + GetpApp()->Property( aProp ); + SfxIniManager* pIniMan = aProp.GetIniManager(); + if(pIniMan) + { + //kill all old entries an rewrite all mappings + String sTempEntry; + sal_uInt16 nIdx = USHRT_MAX; + do + { + String sDBKey(C2S(BIBLIOGRAPHY_INI_DB_ENTRY)); + String sMapKey = C2S(BIBLIOGRAPHY_INI_MAPPING); + if(USHRT_MAX != nIdx) + { + sDBKey += nIdx; + sMapKey += nIdx; + } + sTempEntry = pIniMan->ReadKey( C2S(BIBLIOGRAPHY_INI_GROUP), + sDBKey ); + pIniMan->DeleteKey( C2S(BIBLIOGRAPHY_INI_GROUP), sDBKey); + pIniMan->DeleteKey( C2S(BIBLIOGRAPHY_INI_GROUP), sMapKey); + nIdx = USHRT_MAX == nIdx ? 0 : nIdx +1; + }while(sTempEntry.Len()); + + nIdx = USHRT_MAX; + for(sal_uInt16 i = 0; i < pMappingsArr->Count(); i++) + { + const Mapping* pMapping = pMappingsArr->GetObject(i); + + String sDataTableEntry(pMapping->sURL); + sDataTableEntry = pIniMan->UsePathVars( sDataTableEntry ); + sDataTableEntry += ';'; + sDataTableEntry += pMapping->sTableName; + + String sDBKey = C2S(BIBLIOGRAPHY_INI_DB_ENTRY); + String sMapKey = C2S(BIBLIOGRAPHY_INI_MAPPING); + if(USHRT_MAX != nIdx) + { + sDBKey += nIdx; + sMapKey += nIdx; + } + pIniMan->WriteKey( C2S(BIBLIOGRAPHY_INI_GROUP), sDBKey, sDataTableEntry ); + + String sEntry; + for(sal_uInt16 nColumn = 0; nColumn < COLUMN_COUNT; nColumn++) + { + if(!pMapping->aColumnPairs[nColumn].sLogicalColumnName.Len() || + !pMapping->aColumnPairs[nColumn].sRealColumnName.Len()) + break; + sEntry += pMapping->aColumnPairs[nColumn].sLogicalColumnName; + sEntry += PAIR_TOKEN; + sEntry += pMapping->aColumnPairs[nColumn].sRealColumnName; + sEntry += MAP_TOKEN; + } + pIniMan->WriteKey( C2S(BIBLIOGRAPHY_INI_GROUP), sMapKey, sEntry ); + + nIdx = USHRT_MAX == nIdx ? 0 : nIdx +1; + } + pIniMan->Flush(); + } +} +/* -----------------06.12.99 15:11------------------- + + --------------------------------------------------*/ +const String& BibDataManager::GetIdentifierMapping() +{ + if(!sIdentifierMapping.Len()) + { + const Mapping* pMapping = GetMapping(getActiveDataTable()); + sIdentifierMapping = GetDefColumnName(IDENTIFIER_POS); + if(pMapping) + { + for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++) + { + if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == sIdentifierMapping) + { + sIdentifierMapping = pMapping->aColumnPairs[nEntry].sRealColumnName; + break; + } + } + } + } + return sIdentifierMapping; +} + diff --git a/extensions/source/bibliography/datman.hrc b/extensions/source/bibliography/datman.hrc new file mode 100644 index 000000000000..4122e7b5be3d --- /dev/null +++ b/extensions/source/bibliography/datman.hrc @@ -0,0 +1,137 @@ +/************************************************************************* + * + * $RCSfile: datman.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +#define BT_OK 1 +#define BT_CANCEL 2 +#define BT_HELP 3 +#define GB_MAPPING 4 +#define FT_IDENTIFIER 5 +#define LB_IDENTIFIER 6 +#define ST_NONE 7 + +#define FT_AUTHORITYTYPE 8 +#define LB_AUTHORITYTYPE 9 +#define FT_ADDRESS 10 +#define LB_ADDRESS 11 +#define FT_ANNOTE 12 +#define LB_ANNOTE 13 +#define FT_AUTHOR 14 +#define LB_AUTHOR 15 +#define FT_TITLE 16 +#define LB_TITLE 17 +#define FT_MONTH 18 +#define LB_MONTH 19 +#define FT_YEAR 20 +#define LB_YEAR 21 +#define FT_ISBN 22 +#define LB_ISBN 23 +#define FT_BOOKTITLE 24 +#define LB_BOOKTITLE 25 +#define FT_CHAPTER 26 +#define LB_CHAPTER 27 +#define FT_EDITION 28 +#define LB_EDITION 29 +#define FT_EDITOR 30 +#define LB_EDITOR 31 +#define FT_HOWPUBLISHED 32 +#define LB_HOWPUBLISHED 33 +#define FT_INSTITUTION 34 +#define LB_INSTITUTION 35 +#define FT_JOURNAL 36 +#define LB_JOURNAL 37 +#define FT_NOTE 38 +#define LB_NOTE 39 +#define FT_NUMBER 40 +#define LB_NUMBER 41 +#define FT_ORGANIZATIONS 42 +#define LB_ORGANIZATIONS 43 +#define FT_PAGES 44 +#define LB_PAGES 45 +#define FT_PUBLISHER 46 +#define LB_PUBLISHER 47 +#define FT_SCHOOL 48 +#define LB_SCHOOL 49 +#define FT_SERIES 50 +#define LB_SERIES 51 +#define FT_REPORTTYPE 52 +#define LB_REPORTTYPE 53 +#define FT_VOLUME 54 +#define LB_VOLUME 55 +#define FT_URL 56 +#define LB_URL 57 +#define FT_CUSTOM1 58 +#define LB_CUSTOM1 59 +#define FT_CUSTOM2 60 +#define LB_CUSTOM2 61 +#define FT_CUSTOM3 62 +#define LB_CUSTOM3 63 +#define FT_CUSTOM4 64 +#define LB_CUSTOM4 65 +#define FT_CUSTOM5 66 +#define LB_CUSTOM5 67 + +#define GB_SELECTION 68 +#define ST_ENTRY 69 +#define ST_URL 70 +#define LB_SELECTION 71 +#define HB_SELECTION 72 + diff --git a/extensions/source/bibliography/datman.hxx b/extensions/source/bibliography/datman.hxx new file mode 100644 index 000000000000..130ebfae7403 --- /dev/null +++ b/extensions/source/bibliography/datman.hxx @@ -0,0 +1,253 @@ +/************************************************************************* + * + * $RCSfile: datman.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 _BIB_DATMAN_HXX +#define _BIB_DATMAN_HXX + +#ifndef _COM_SUN_STAR_AWT_XCONTROLMODEL_HPP_ +#include <com/sun/star/awt/XControlModel.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_ +#include <com/sun/star/form/XForm.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_ +#include <com/sun/star/sdb/XSQLQueryComposer.hpp> +#endif + +#ifndef _COM_SUN_STAR_REGISTRY_XSIMPLEREGISTRY_HPP_ +#include <com/sun/star/registry/XSimpleRegistry.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> // helper for implementations +#endif + +class BibRegistry; +class MappingArray; +class Window; +//----------------------------------------------------------------------------- +#define COLUMN_COUNT 31 +#define IDENTIFIER_POS 0 +#define AUTHORITYTYPE_POS 1 +#define AUTHOR_POS 2 +#define TITLE_POS 3 +#define YEAR_POS 4 +#define ISBN_POS 5 +#define BOOKTITLE_POS 6 +#define CHAPTER_POS 7 +#define EDITION_POS 8 +#define EDITOR_POS 9 +#define HOWPUBLISHED_POS 10 +#define INSTITUTION_POS 11 +#define JOURNAL_POS 12 +#define MONTH_POS 13 +#define NOTE_POS 14 +#define ANNOTE_POS 15 +#define NUMBER_POS 16 +#define ORGANIZATIONS_POS 17 +#define PAGES_POS 18 +#define PUBLISHER_POS 19 +#define ADDRESS_POS 20 +#define SCHOOL_POS 21 +#define SERIES_POS 22 +#define REPORTTYPE_POS 23 +#define VOLUME_POS 24 +#define URL_POS 25 +#define CUSTOM1_POS 26 +#define CUSTOM2_POS 27 +#define CUSTOM3_POS 28 +#define CUSTOM4_POS 29 +#define CUSTOM5_POS 30 + +//----------------------------------------------------------------------------- +struct StringPair +{ + String sRealColumnName; + String sLogicalColumnName; +}; +//----------------------------------------------------------------------------- +struct Mapping +{ + String sTableName; + String sURL; + StringPair aColumnPairs[COLUMN_COUNT]; +}; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +class BibView; +class BibToolBar; +class BibGridwin; +class BibDataManager : public cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener> +{ +private: + ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > xForm; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > xGridModel; + ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry > xRegistry; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xSourceProps; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xGlobalProps; + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer > xParser; + ::rtl::OUString aActiveDataTable; + ::rtl::OUString aDataSourceURL; + ::rtl::OUString aQuoteChar; +// sal_Bool bNew; +// sal_Bool bModified; + ::com::sun::star::uno::Any aUID; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > xBibCursor; + MappingArray* pMappingsArr; + + BibView* pBibView; + BibToolBar* pToolbar; + BibGridwin* pGridWin; + + String aColumnDefaults[COLUMN_COUNT]; + String sIdentifierMapping; +protected: + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createGlobalProperties(); + void InsertFields(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & xGrid); + void InitRegistry(); + void SetMeAsUidListener(); + void RemoveMeAsUidListener(); + + void UpdateAddressbookCursor(::rtl::OUString aSourceName); +public: + + BibDataManager(BibRegistry * pRegistry); + ~BibDataManager(); + + virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) + throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ); + + + + ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > createDatabaseForm(const ::rtl::OUString& rURL, ::rtl::OUString& rTableName); + ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > getDatabaseForm(); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > & xDbForm); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createGridModel(); + + void loadDatabase(); + void unloadDatabase(); + + ::com::sun::star::uno::Sequence< ::rtl::OUString> getDataSources(); + + ::rtl::OUString getActiveDataSource() {return aDataSourceURL;} + void setActiveDataSource(const ::rtl::OUString& rURL); + + ::rtl::OUString getActiveDataTable(); + void setActiveDataTable(const ::rtl::OUString& rTable); + + void setFilter(const ::rtl::OUString& rQuery); + ::rtl::OUString getFilter(); + + ::com::sun::star::uno::Sequence< ::rtl::OUString> getQueryFields(); + void setQueryField(const ::rtl::OUString& rField); + ::rtl::OUString getQueryField(); + void startQueryWith(const ::rtl::OUString& rQuery); + ::rtl::OUString getQueryString(); + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer > getParser(); + +// void saveGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & xDbForm); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > loadGridModel(const ::rtl::OUString& rName); + + void setBeamerSize(long nSize); + long getBeamerSize(); + void setViewSize(long nSize); + long getViewSize(); + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getViewProperties(); + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getChildViewProperties(const ::rtl::OUString& rName); + + ::rtl::OUString getControlName(sal_Int32 nFormatKey ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > loadControlModel(const ::rtl::OUString& rName, + sal_Bool bForceListBox = sal_False); + void saveCtrModel(const ::rtl::OUString& rName, + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & rCtrModel); + +// sal_Bool isNew() { return bNew;} +// sal_Bool isModified() { return bModified;} + + sal_Bool moveRelative(long nMove); + + void CreateMappingDialog(Window* pParent); + ::rtl::OUString CreateDBChangeDialog(Window* pParent); + const Mapping* GetMapping(const ::rtl::OUString& rTableName, const ::rtl::OUString* pURL = 0) const; + void SetMapping(const ::rtl::OUString& rTableName, const Mapping* pMapping); + + const String& GetDefColumnName(sal_uInt16 nIndex) const + {return aColumnDefaults[nIndex];} + + void SetView(BibView* pView) {pBibView = pView;} + + void SetToolbar(BibToolBar* pSet) {pToolbar = pSet;} + void SetGridWin(BibGridwin* pSet) {pGridWin = pSet;} + + const String& GetIdentifierMapping(); + void ResetIdentifierMapping() {sIdentifierMapping.Erase();} +}; + + +#endif diff --git a/extensions/source/bibliography/datman.src b/extensions/source/bibliography/datman.src new file mode 100644 index 000000000000..311968f03fcc --- /dev/null +++ b/extensions/source/bibliography/datman.src @@ -0,0 +1,1276 @@ +/************************************************************************* + * + * $RCSfile: datman.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ +//================================================================== +// BibDataManager +// +// +// +// $Author: hr $ $Date: 2000-09-18 16:16:44 $ $Revision: 1.1.1.1 $ +// $Logfile: T:/sc/inc/scresid.hxv $ $Workfile: scresid.hxx $ +//------------------------------------------------------------------ + +#include "bib.hrc" +#include "datman.hrc" +ModalDialog RID_DLG_MAPPING +{ + HelpID = HID_DLG_MAPPING; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 391 , 181 ) ; + Moveable = TRUE ; + Text = "Spaltenzuordung für Tabelle %1"; + Text [ENGLISH] = "Column assignment for table %1"; + + OKButton BT_OK + { + Pos = MAP_APPFONT ( 338 , 3 ) ; + Size = MAP_APPFONT ( 50 , 12 ) ; + }; + CancelButton BT_CANCEL + { + Pos = MAP_APPFONT ( 338 , 18 ) ; + Size = MAP_APPFONT ( 50 , 12 ) ; + }; + HelpButton BT_HELP + { + Pos = MAP_APPFONT ( 338 , 36 ) ; + Size = MAP_APPFONT ( 50 , 12 ) ; + }; + GroupBox GB_MAPPING + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 329 , 175 ) ; + Text = "Spaltennamen"; + Text [ENGLISH] = "Column names"; + Text[ english_us ] = "Column names"; + Text[ portuguese ] = "Nomes de coluna"; + Text[ russian ] = "Íàçâàíèÿ êîëîíîê"; + Text[ greek ] = "Ïíüìáôá óôçëþí"; + Text[ dutch ] = "Kolomnamen"; + Text[ french ] = "Noms des colonnes"; + Text[ spanish ] = "Nombres de columna"; + Text[ italian ] = "Nomi colonna"; + Text[ danish ] = "Kolonnenavne"; + Text[ swedish ] = "Kolumnnamn"; + Text[ polish ] = "Nazwy kolumn"; + Text[ portuguese_brazilian ] = "Column names"; + Text[ japanese ] = "—ñ–¼"; + Text[ korean ] = "¿ À̸§"; + Text[ chinese_simplified ] = "ÁÐÃû³Æ"; + Text[ chinese_traditional ] = "Äæ¦W"; + Text[ arabic ] = "ÃÓãÇÁ ÇáÃÚãÏÉ"; + Text[ turkish ] = "Sütun adlarý"; + Text[ language_user1 ] = " "; + }; + FixedText FT_IDENTIFIER + { + Pos = MAP_APPFONT ( 12 , 14 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Kürzel"; + Text [ENGLISH] = "Identifier"; + Text[ english_us ] = "Identifier"; + Text[ portuguese ] = "Abreviatura"; + Text[ russian ] = "Ñîêðàùåíèå"; + Text[ greek ] = "Óõíôüìåõóç"; + Text[ dutch ] = "Initialen"; + Text[ french ] = "Abréviation"; + Text[ spanish ] = "Abreviatura"; + Text[ italian ] = "Sigla"; + Text[ danish ] = "Genvej"; + Text[ swedish ] = "Initialer"; + Text[ polish ] = "Inicja³y"; + Text[ portuguese_brazilian ] = "Identifier"; + Text[ japanese ] = "È—ª–¼"; + Text[ korean ] = "À̴ϼÈ"; + Text[ chinese_simplified ] = "±êʶ"; + Text[ chinese_traditional ] = "ÁY¼g"; + Text[ arabic ] = "ÇáÇÎÊÕÇÑ"; + Text[ turkish ] = "Kýsaltma"; + }; + ListBox LB_IDENTIFIER + { + Pos = MAP_APPFONT ( 65 , 13 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_AUTHORITYTYPE + { + Pos = MAP_APPFONT ( 118 , 14 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Literaturart"; + Text [ENGLISH] = "Type of literature"; + Text[ english_us ] = "Type of literature"; + Text[ portuguese ] = "Tipo de literatura"; + Text[ russian ] = "Æàíð"; + Text[ greek ] = "Åßäïò ëïãïôå÷íßáò"; + Text[ dutch ] = "Soort literatuur"; + Text[ french ] = "Genre"; + Text[ spanish ] = "Tipo de literatura"; + Text[ italian ] = "Tipo di letteratura"; + Text[ danish ] = "Litteraturtype"; + Text[ swedish ] = "Typ av litteratur"; + Text[ polish ] = "Rodzaj literatury"; + Text[ portuguese_brazilian ] = "Type of literature"; + Text[ japanese ] = "–{‚Ì•ª—Þ"; + Text[ korean ] = "Âü°í¹®Çå À¯Çü"; + Text[ chinese_simplified ] = "ÎÄÏ×ÀàÐÍ"; + Text[ chinese_traditional ] = "¤åÄmÃþ«¬"; + Text[ arabic ] = "ÇáäæÚ"; + Text[ turkish ] = "Kaynakça türü"; + }; + ListBox LB_AUTHORITYTYPE + { + Pos = MAP_APPFONT ( 171 , 13 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_AUTHOR + { + Pos = MAP_APPFONT ( 229 , 14 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Autor"; + Text [ENGLISH] = "Author"; + Text[ english_us ] = "Author"; + Text[ portuguese ] = "Autor"; + Text[ russian ] = "Àâòîð"; + Text[ greek ] = "ÓõããñáöÝáò"; + Text[ dutch ] = "Auteur"; + Text[ french ] = "Auteur"; + Text[ spanish ] = "Autor"; + Text[ italian ] = "Autore"; + Text[ danish ] = "Forfatter"; + Text[ swedish ] = "Författare"; + Text[ polish ] = "Autor"; + Text[ portuguese_brazilian ] = "Author"; + Text[ japanese ] = "’˜ŽÒ"; + Text[ korean ] = "ÀúÀÚ"; + Text[ chinese_simplified ] = "×÷Õß"; + Text[ chinese_traditional ] = "§@ªÌ"; + Text[ arabic ] = "ÇáãÄáÝ"; + Text[ turkish ] = "Yazan"; + }; + ListBox LB_AUTHOR + { + Pos = MAP_APPFONT ( 282 , 13 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_TITLE + { + Pos = MAP_APPFONT ( 12 , 29 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Titel"; + Text [ENGLISH] = "Title"; + Text[ english_us ] = "Title"; + Text[ portuguese ] = "Título"; + Text[ russian ] = "Íàçâàíèå"; + Text[ greek ] = "Ôßôëïò"; + Text[ dutch ] = "Titel"; + Text[ french ] = "Titre"; + Text[ spanish ] = "Título"; + Text[ italian ] = "Titolo"; + Text[ danish ] = "Titel"; + Text[ swedish ] = "Titel"; + Text[ polish ] = "Tytu³"; + Text[ portuguese_brazilian ] = "Title"; + Text[ japanese ] = "À²ÄÙ"; + Text[ korean ] = "Á¦¸ñ"; + Text[ chinese_simplified ] = "±êÌâ"; + Text[ chinese_traditional ] = "¼ÐÃD"; + Text[ arabic ] = "ÇáÚäæÇä"; + Text[ turkish ] = "Baþlýk"; + Text[ language_user1 ] = " "; + }; + ListBox LB_TITLE + { + Pos = MAP_APPFONT ( 65 , 28 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_MONTH + { + Pos = MAP_APPFONT ( 118 , 29 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Monat"; + Text [ENGLISH] = "Month"; + Text[ english_us ] = "Month"; + Text[ portuguese ] = "Mês"; + Text[ russian ] = "Ìåñÿö"; + Text[ greek ] = "ÌÞíáò"; + Text[ dutch ] = "Maand"; + Text[ french ] = "Mois"; + Text[ spanish ] = "Mes"; + Text[ italian ] = "Mese"; + Text[ danish ] = "Måned"; + Text[ swedish ] = "Månad"; + Text[ polish ] = "Miesi¹c"; + Text[ portuguese_brazilian ] = "Month"; + Text[ japanese ] = "ŒŽ"; + Text[ korean ] = "´Þ"; + Text[ chinese_simplified ] = "ÔÂ"; + Text[ chinese_traditional ] = "¤ë"; + Text[ arabic ] = "ÇáÔåÑ"; + Text[ turkish ] = "Ay"; + Text[ language_user1 ] = " "; + }; + ListBox LB_MONTH + { + Pos = MAP_APPFONT ( 171 , 28 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_YEAR + { + Pos = MAP_APPFONT ( 229 , 29 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Jahr"; + Text [ENGLISH] = "Year"; + Text[ english_us ] = "Year"; + Text[ portuguese ] = "Ano"; + Text[ russian ] = "Ãîä"; + Text[ greek ] = "¸ôïò"; + Text[ dutch ] = "Jaar"; + Text[ french ] = "An"; + Text[ spanish ] = "Año"; + Text[ italian ] = "Anno"; + Text[ danish ] = "År"; + Text[ swedish ] = "År"; + Text[ polish ] = "Rok"; + Text[ portuguese_brazilian ] = "Year"; + Text[ japanese ] = "”N"; + Text[ korean ] = "ÇØ"; + Text[ chinese_simplified ] = "Äê"; + Text[ chinese_traditional ] = "¦~"; + Text[ arabic ] = "ÇáÓäÉ"; + Text[ turkish ] = "Yýl"; + Text[ language_user1 ] = " "; + }; + ListBox LB_YEAR + { + Pos = MAP_APPFONT ( 282 , 28 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_ISBN + { + Pos = MAP_APPFONT ( 12 , 44 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "ISBN"; + Text [ENGLISH] = "ISBN"; + Text[ english_us ] = "ISBN"; + Text[ portuguese ] = "ISBN"; + Text[ russian ] = "ISBN"; + Text[ greek ] = "ISBN"; + Text[ dutch ] = "ISBN"; + Text[ french ] = "ISBN"; + Text[ spanish ] = "ISBN"; + Text[ italian ] = "ISBN"; + Text[ danish ] = "ISBN"; + Text[ swedish ] = "ISBN"; + Text[ polish ] = "ISBN"; + Text[ portuguese_brazilian ] = "ISBN"; + Text[ japanese ] = "ISBN"; + Text[ korean ] = "ISBN"; + Text[ chinese_simplified ] = "ISBN"; + Text[ chinese_traditional ] = "ISBN"; + Text[ arabic ] = "ISBN"; + Text[ turkish ] = "ISBN"; + Text[ language_user1 ] = " "; + }; + ListBox LB_ISBN + { + Pos = MAP_APPFONT ( 65 , 43 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_BOOKTITLE + { + Pos = MAP_APPFONT ( 118 , 44 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Buchtitel"; + Text [ENGLISH] = "Book title"; + Text[ english_us ] = "Book title"; + Text[ portuguese ] = "Título do livro"; + Text[ russian ] = "Íàçâàíèå êíèãè"; + Text[ greek ] = "Ôßôëïò âéâëßïõ"; + Text[ dutch ] = "Boektitel"; + Text[ french ] = "Titre du livre"; + Text[ spanish ] = "Título del libro"; + Text[ italian ] = "Titolo del libro"; + Text[ danish ] = "Bogtitel"; + Text[ swedish ] = "Boktitel"; + Text[ polish ] = "Tytu³ ksi¹¿ki"; + Text[ portuguese_brazilian ] = "Book title"; + Text[ japanese ] = "‘–¼"; + Text[ korean ] = "Ã¥ Á¦¸ñ"; + Text[ chinese_simplified ] = "Êé¼®±êÌâ"; + Text[ chinese_traditional ] = "®Ñ¦W"; + Text[ arabic ] = "ÚäæÇä ÇáßÊÇÈ"; + Text[ turkish ] = "Kitap baþlýðý"; + Text[ language_user1 ] = " "; + }; + ListBox LB_BOOKTITLE + { + Pos = MAP_APPFONT ( 171, 43 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_CHAPTER + { + Pos = MAP_APPFONT ( 229 , 44 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Kapitel"; + Text [ENGLISH] = "Chapter"; + Text[ english_us ] = "Chapter"; + Text[ portuguese ] = "Capítulo"; + Text[ russian ] = "Ãëàâà"; + Text[ greek ] = "ÊåöÜëáéï"; + Text[ dutch ] = "Hoofdstuk"; + Text[ french ] = "Chapitre"; + Text[ spanish ] = "Capítulo"; + Text[ italian ] = "Capitolo"; + Text[ danish ] = "Kapitel"; + Text[ swedish ] = "Kapitel"; + Text[ polish ] = "Rozdzia³"; + Text[ portuguese_brazilian ] = "Chapter"; + Text[ japanese ] = "Í"; + Text[ korean ] = "Àå"; + Text[ chinese_simplified ] = "ÕÂ"; + Text[ chinese_traditional ] = "³¹"; + Text[ arabic ] = "ÇáÝÕá"; + Text[ turkish ] = "Bölüm"; + Text[ language_user1 ] = " "; + }; + ListBox LB_CHAPTER + { + Pos = MAP_APPFONT ( 282 , 43 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_EDITION + { + Pos = MAP_APPFONT ( 12 , 59 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Ausgabe"; + Text [ENGLISH] = "Edition"; + Text[ english_us ] = "Edition"; + Text[ portuguese ] = "Edição"; + Text[ russian ] = "Èçäàíèå"; + Text[ greek ] = "ÅîáãùãÞ"; + Text[ dutch ] = "Editie"; + Text[ french ] = "Édition"; + Text[ spanish ] = "Edición"; + Text[ italian ] = "Edizione"; + Text[ danish ] = "Udgave"; + Text[ swedish ] = "Utgåva"; + Text[ polish ] = "Wydanie"; + Text[ portuguese_brazilian ] = "Edition"; + Text[ japanese ] = "”Å"; + Text[ korean ] = "ÆÇ"; + Text[ chinese_simplified ] = "°æ±¾"; + Text[ chinese_traditional ] = "ª©¥»"; + Text[ arabic ] = "ÇáØÈÚÉ"; + Text[ turkish ] = "Yayým"; + Text[ language_user1 ] = " "; + }; + ListBox LB_EDITION + { + Pos = MAP_APPFONT ( 65 , 58 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_EDITOR + { + Pos = MAP_APPFONT ( 118 , 59 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Herausgeber"; + Text [ENGLISH] = "Editor"; + Text[ english_us ] = "Editor"; + Text[ portuguese ] = "Editor"; + Text[ russian ] = "Ðåäàêòîð"; + Text[ greek ] = "Åêäüôçò"; + Text[ dutch ] = "Uitgever"; + Text[ french ] = "Éditeur"; + Text[ spanish ] = "Editor"; + Text[ italian ] = "Editore"; + Text[ danish ] = "Udgiver"; + Text[ swedish ] = "Utgivare"; + Text[ polish ] = "Wydawca"; + Text[ portuguese_brazilian ] = "Editor"; + Text[ japanese ] = "•ÒWŽÒ"; + Text[ korean ] = "¹ßÇàÀÎ"; + Text[ chinese_simplified ] = "·¢ÐÐÈË"; + Text[ chinese_traditional ] = "¥Xª©°Ó"; + Text[ arabic ] = "ÇáäÇÔÑ"; + Text[ turkish ] = "Yayýmcý"; + Text[ language_user1 ] = " "; + }; + ListBox LB_EDITOR + { + Pos = MAP_APPFONT ( 171, 58) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_HOWPUBLISHED + { + Pos = MAP_APPFONT ( 229 , 59 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Ausgabeart"; + Text [ENGLISH] = "How published"; + Text[ english_us ] = "Publication type"; + Text[ portuguese ] = "Tipo de publicação"; + Text[ russian ] = "Òèï èçäàíèÿ"; + Text[ greek ] = "Ôýðïò Ýêäïóçò"; + Text[ dutch ] = "Wijze van publiceren"; + Text[ french ] = "Mode de publication"; + Text[ spanish ] = "Tipo de publicación"; + Text[ italian ] = "Tipo di edizione"; + Text[ danish ] = "Udgivelsestype"; + Text[ swedish ] = "Utgivningstyp"; + Text[ polish ] = "Rodzaj publikacji"; + Text[ portuguese_brazilian ] = "How published"; + Text[ japanese ] = "¶ÊÞ°À²Ìß"; + Text[ korean ] = "¹ßÇà À¯Çü"; + Text[ chinese_simplified ] = "·¢Ðз½Ê½"; + Text[ chinese_traditional ] = "¥Xª©Ãþ«¬"; + Text[ arabic ] = "ØÑíÞÉ ÇáäÔÑ"; + Text[ turkish ] = "Yayým türü"; + }; + ListBox LB_HOWPUBLISHED + { + Pos = MAP_APPFONT ( 282 , 58 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_INSTITUTION + { + Pos = MAP_APPFONT ( 12 , 74 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Institution"; + Text [ENGLISH] = "Institution"; + Text[ english_us ] = "Institution"; + Text[ portuguese ] = "Instituição"; + Text[ russian ] = "Ó÷ðåæäåíèå"; + Text[ greek ] = "ºäñõìá"; + Text[ dutch ] = "Instelling"; + Text[ french ] = "Institution"; + Text[ spanish ] = "Institución"; + Text[ italian ] = "Istituzione"; + Text[ danish ] = "Institution"; + Text[ swedish ] = "Institution"; + Text[ polish ] = "Instytucja"; + Text[ portuguese_brazilian ] = "Institution"; + Text[ japanese ] = "‹@ŠÖ"; + Text[ korean ] = "Çùȸ"; + Text[ chinese_simplified ] = "»ú¹¹"; + Text[ chinese_traditional ] = "ÉóÌÛ"; + Text[ arabic ] = "ÇáåíÆÉ"; + Text[ turkish ] = "Kurum"; + Text[ language_user1 ] = " "; + }; + ListBox LB_INSTITUTION + { + Pos = MAP_APPFONT ( 65 , 73 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_JOURNAL + { + Pos = MAP_APPFONT ( 118 , 74 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Zeitschrift"; + Text [ENGLISH] = "Journal"; + Text[ english_us ] = "Journal"; + Text[ portuguese ] = "Revista"; + Text[ russian ] = "Æóðíàë"; + Text[ greek ] = "Ðåñéïäéêü"; + Text[ dutch ] = "Tijdschrift"; + Text[ french ] = "Revue"; + Text[ spanish ] = "Revista"; + Text[ italian ] = "Rivista"; + Text[ danish ] = "Tidsskrift"; + Text[ swedish ] = "Tidskrift"; + Text[ polish ] = "Czasopismo"; + Text[ portuguese_brazilian ] = "Journal"; + Text[ japanese ] = "ŽGŽ"; + Text[ korean ] = "ÀâÁö"; + Text[ chinese_simplified ] = "ÔÓÖ¾"; + Text[ chinese_traditional ] = "Âø»x"; + Text[ arabic ] = "ãÌáÉ"; + Text[ turkish ] = "Dergi"; + Text[ language_user1 ] = " "; + }; + ListBox LB_JOURNAL + { + Pos = MAP_APPFONT ( 171 , 73 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_NOTE + { + Pos = MAP_APPFONT ( 229 , 74 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Notiz"; + Text [ENGLISH] = "Note"; + Text[ english_us ] = "Note"; + Text[ portuguese ] = "Anotações"; + Text[ russian ] = "Ïðèìå÷àíèå"; + Text[ greek ] = "Óçìåßùóç"; + Text[ dutch ] = "Aantekening"; + Text[ french ] = "Note"; + Text[ spanish ] = "Nota"; + Text[ italian ] = "Nota"; + Text[ danish ] = "Note"; + Text[ swedish ] = "Anteckning"; + Text[ polish ] = "Notatka"; + Text[ portuguese_brazilian ] = "Note"; + Text[ japanese ] = "ÒÓ"; + Text[ korean ] = "¸Þ¸ð"; + Text[ chinese_simplified ] = "±¸×¢"; + Text[ chinese_traditional ] = "µ§°O"; + Text[ arabic ] = "ãáÇÍÙÉ"; + Text[ turkish ] = "Not"; + }; + ListBox LB_NOTE + { + Pos = MAP_APPFONT ( 282 , 73 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_ANNOTE + { + Pos = MAP_APPFONT ( 12, 89 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Anmerkung"; + Text [ENGLISH] = "Annotation"; + Text[ english_us ] = "Annotation"; + Text[ portuguese ] = "Anotações"; + Text[ russian ] = "Ïîìåòêè"; + Text[ greek ] = "ÐáñáôÞñçóç"; + Text[ dutch ] = "Commentaar"; + Text[ french ] = "Annotation"; + Text[ spanish ] = "Anotación"; + Text[ italian ] = "Annotazione"; + Text[ danish ] = "Anmærkning"; + Text[ swedish ] = "Anmärkning"; + Text[ polish ] = "Adnotacja"; + Text[ portuguese_brazilian ] = "Annotation"; + Text[ japanese ] = "ºÒÝÄ"; + Text[ korean ] = "ÁÖ¼®"; + Text[ chinese_simplified ] = "˵Ã÷"; + Text[ chinese_traditional ] = "³Æª`"; + Text[ arabic ] = "ÊÚáíÞ ÊæÖíÍí"; + Text[ turkish ] = "Açýklama"; + Text[ language_user1 ] = " "; + }; + ListBox LB_ANNOTE + { + Pos = MAP_APPFONT ( 65, 88 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_NUMBER + { + Pos = MAP_APPFONT ( 118 , 89 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Nummer"; + Text [ENGLISH] = "No."; + Text[ english_us ] = "No."; + Text[ portuguese ] = "Nº."; + Text[ russian ] = "¹"; + Text[ greek ] = "Áñéèìüò"; + Text[ dutch ] = "Nummer"; + Text[ french ] = "No."; + Text[ spanish ] = "Número"; + Text[ italian ] = "No."; + Text[ danish ] = "Nummer"; + Text[ swedish ] = "Nummer"; + Text[ polish ] = "Numer"; + Text[ portuguese_brazilian ] = "No."; + Text[ japanese ] = "No."; + Text[ korean ] = "¹øÈ£"; + Text[ chinese_simplified ] = "±àºÅ"; + Text[ chinese_traditional ] = "¸¹½X"; + Text[ arabic ] = "ÑÞã"; + Text[ turkish ] = "Sayý"; + }; + ListBox LB_NUMBER + { + Pos = MAP_APPFONT ( 171 , 88 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_ORGANIZATIONS + { + Pos = MAP_APPFONT ( 229 , 89 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Organisation"; + Text [ENGLISH] = "Organization"; + Text[ english_us ] = "Organization"; + Text[ portuguese ] = "Organização"; + Text[ russian ] = "Îðãàíèçàöèÿ"; + Text[ greek ] = "Ïñãáíéóìüò"; + Text[ dutch ] = "Organisatie"; + Text[ french ] = "Organisation"; + Text[ spanish ] = "Organización"; + Text[ italian ] = "Organizzazione"; + Text[ danish ] = "Organisation"; + Text[ swedish ] = "Organisation"; + Text[ polish ] = "Organizacja"; + Text[ portuguese_brazilian ] = "Organization"; + Text[ japanese ] = "‘gD’c‘Ì"; + Text[ korean ] = "´Üü"; + Text[ chinese_simplified ] = "×éÖ¯"; + Text[ chinese_traditional ] = "²Õ´"; + Text[ arabic ] = "ãäÙãÉ"; + Text[ turkish ] = "Organizasyon"; + }; + ListBox LB_ORGANIZATIONS + { + Pos = MAP_APPFONT ( 282, 88 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_PAGES + { + Pos = MAP_APPFONT ( 12 , 104 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Seite(n)"; + Text [ENGLISH] = "Page(s)"; + Text[ english_us ] = "Page(s)"; + Text[ portuguese ] = "Página(s)"; + Text[ russian ] = "Ñòðàíèö(û)"; + Text[ greek ] = "Óåëßäá/-åò"; + Text[ dutch ] = "Pagina(s)"; + Text[ french ] = "Page(s)"; + Text[ spanish ] = "Página(s)"; + Text[ italian ] = "Pagina/e"; + Text[ danish ] = "Side(r)"; + Text[ swedish ] = "Sida(-or)"; + Text[ polish ] = "Strona(y)"; + Text[ portuguese_brazilian ] = "Page(s)"; + Text[ japanese ] = "Íß°¼Þ"; + Text[ korean ] = "ÆäÀÌÁö ¼ö"; + Text[ chinese_simplified ] = "Ò³"; + Text[ chinese_traditional ] = "¶"; + Text[ arabic ] = "ÕÝÍÉ (ÕÝÍÇÊ)"; + Text[ turkish ] = "Sayfa sayýsý"; + Text[ language_user1 ] = " "; + }; + ListBox LB_PAGES + { + Pos = MAP_APPFONT ( 65 , 103 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_PUBLISHER + { + Pos = MAP_APPFONT ( 118 , 104 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Verlag"; + Text [ENGLISH] = "Publisher"; + Text[ english_us ] = "Publisher"; + Text[ portuguese ] = "Editora"; + Text[ russian ] = "Èçäàòåëüñòâî"; + Text[ greek ] = "Åêäïôéêüò ïßêïò"; + Text[ dutch ] = "Uitgeverij"; + Text[ french ] = "Édition"; + Text[ spanish ] = "Editorial"; + Text[ italian ] = "Casa editrice"; + Text[ danish ] = "Forlag"; + Text[ swedish ] = "Förlag"; + Text[ polish ] = "Wydawnictwo"; + Text[ portuguese_brazilian ] = "Publisher"; + Text[ japanese ] = "”sŠ"; + Text[ korean ] = "ÃâÆÇ»ç"; + Text[ chinese_simplified ] = "³ö°æÉç"; + Text[ chinese_traditional ] = "¥Xª©ªÀ"; + Text[ arabic ] = "ÏÇÑ ÇáäÔÑ"; + Text[ turkish ] = "Yayým evi"; + }; + ListBox LB_PUBLISHER + { + Pos = MAP_APPFONT ( 171, 103 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_ADDRESS + { + Pos = MAP_APPFONT ( 229 , 104 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Adresse"; + Text [ENGLISH] = "Address"; + Text[ english_us ] = "Address"; + Text[ portuguese ] = "Endereço"; + Text[ russian ] = "Àäðåñ"; + Text[ greek ] = "Äéåýèõíóç"; + Text[ dutch ] = "Adres"; + Text[ french ] = "Adresse"; + Text[ spanish ] = "Dirección"; + Text[ italian ] = "Indirizzo"; + Text[ danish ] = "Adresse"; + Text[ swedish ] = "Adress"; + Text[ polish ] = "Adres"; + Text[ portuguese_brazilian ] = "Address"; + Text[ japanese ] = "ZŠ"; + Text[ korean ] = "ÁÖ¼Ò"; + Text[ chinese_simplified ] = "µØÖ·"; + Text[ chinese_traditional ] = "¦a§}"; + Text[ arabic ] = "ÇáÚäæÇä"; + Text[ turkish ] = "Adres"; + Text[ language_user1 ] = " "; + }; + ListBox LB_ADDRESS + { + Pos = MAP_APPFONT ( 282 , 103 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_SCHOOL + { + Pos = MAP_APPFONT ( 12 , 119 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Hochschule"; + Text [ENGLISH] = "School"; + Text[ english_us ] = "University"; + Text[ portuguese ] = "Universidade"; + Text[ russian ] = "ÂÓÇ"; + Text[ greek ] = "Á.Å.É./Ô.Å.É."; + Text[ dutch ] = "Hogeschool"; + Text[ french ] = "École supérieure"; + Text[ spanish ] = "Universidad"; + Text[ italian ] = "Scuola superiore"; + Text[ danish ] = "Universitet"; + Text[ swedish ] = "Högskola"; + Text[ polish ] = "Szko³a wy¿sza"; + Text[ portuguese_brazilian ] = "School"; + Text[ japanese ] = "‹³ˆç‹@ŠÖ"; + Text[ korean ] = "Çб³"; + Text[ chinese_simplified ] = "´óѧ"; + Text[ chinese_traditional ] = "°ªµ¥°|®Õ"; + Text[ arabic ] = "ÌÇãÚÉ"; + Text[ turkish ] = "Üniversite"; + }; + ListBox LB_SCHOOL + { + Pos = MAP_APPFONT ( 65 , 118 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_SERIES + { + Pos = MAP_APPFONT ( 118 , 119 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Serie"; + Text [ENGLISH] = "Series"; + Text[ english_us ] = "Series"; + Text[ portuguese ] = "Série"; + Text[ russian ] = "Ñåðèÿ"; + Text[ greek ] = "ÓåéñÜ"; + Text[ dutch ] = "Serie"; + Text[ french ] = "Série"; + Text[ spanish ] = "Serie"; + Text[ italian ] = "Serie"; + Text[ danish ] = "Serie"; + Text[ swedish ] = "Serie"; + Text[ polish ] = "Seria"; + Text[ portuguese_brazilian ] = "Series"; + Text[ japanese ] = "‘p‘"; + Text[ korean ] = "½Ã¸®Áî"; + Text[ chinese_simplified ] = "ϵÁÐ"; + Text[ chinese_traditional ] = "¨t¦C"; + Text[ arabic ] = "ÓáÓáÉ"; + Text[ turkish ] = "Dizi"; + Text[ language_user1 ] = " "; + }; + ListBox LB_SERIES + { + Pos = MAP_APPFONT ( 171 , 118) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_REPORTTYPE + { + Pos = MAP_APPFONT ( 229 , 119 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Art des Reports"; + Text [ENGLISH] = "Report type"; + Text[ english_us ] = "Report type"; + Text[ portuguese ] = "Tipo de relatório"; + Text[ russian ] = "Òèï îò÷åòà"; + Text[ greek ] = "Ôýðïò áíáöïñÜò"; + Text[ dutch ] = "Soort bericht"; + Text[ french ] = "Type de rapport"; + Text[ spanish ] = "Tipo de informe"; + Text[ italian ] = "Rapporto"; + Text[ danish ] = "Rapporttype"; + Text[ swedish ] = "Typ av rapport"; + Text[ polish ] = "Rodzaj raportu"; + Text[ portuguese_brazilian ] = "Report type"; + Text[ japanese ] = "ÚÎß°Ä‚ÌŽí—Þ"; + Text[ korean ] = "º¸°í¼ À¯Çü"; + Text[ chinese_simplified ] = "±¨µÀÀàÐÍ"; + Text[ chinese_traditional ] = "³ø§iÃþ«¬"; + Text[ arabic ] = "äæÚ ÇáÊÞÑíÑ"; + Text[ turkish ] = "Rapor türü"; + Text[ language_user1 ] = " "; + }; + ListBox LB_REPORTTYPE + { + Pos = MAP_APPFONT ( 282 , 118 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_VOLUME + { + Pos = MAP_APPFONT ( 12 , 134 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Band"; + Text [ENGLISH] = "Volume"; + Text[ english_us ] = "Volume"; + Text[ portuguese ] = "Volume"; + Text[ russian ] = "Òîì"; + Text[ greek ] = "Ôüìïò"; + Text[ dutch ] = "Deel"; + Text[ french ] = "Volume"; + Text[ spanish ] = "Tomo"; + Text[ italian ] = "Volume"; + Text[ danish ] = "Bind"; + Text[ swedish ] = "Volym"; + Text[ polish ] = "Tom"; + Text[ portuguese_brazilian ] = "Volume"; + Text[ japanese ] = "Šª"; + Text[ korean ] = "±Ç"; + Text[ chinese_simplified ] = "²á"; + Text[ chinese_traditional ] = "¥U"; + Text[ arabic ] = "ÇáãÌáÏ"; + Text[ turkish ] = "Cilt"; + }; + ListBox LB_VOLUME + { + Pos = MAP_APPFONT ( 65 , 133) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_URL + { + Pos = MAP_APPFONT ( 118 , 134 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "URL"; + Text [ENGLISH] = "URL"; + Text[ english_us ] = "URL"; + Text[ portuguese ] = "URL"; + Text[ russian ] = "URL"; + Text[ greek ] = "URL"; + Text[ dutch ] = "URL"; + Text[ french ] = "URL"; + Text[ spanish ] = "URL"; + Text[ italian ] = "URL"; + Text[ danish ] = "URL"; + Text[ swedish ] = "URL"; + Text[ polish ] = "URL"; + Text[ portuguese_brazilian ] = "URL"; + Text[ japanese ] = "URL"; + Text[ korean ] = "URL"; + Text[ chinese_simplified ] = "URL"; + Text[ chinese_traditional ] = "URL"; + Text[ arabic ] = "URL"; + Text[ turkish ] = "URL"; + Text[ language_user1 ] = " "; + }; + ListBox LB_URL + { + Pos = MAP_APPFONT ( 171 , 133 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_CUSTOM1 + { + Pos = MAP_APPFONT ( 229 , 134 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Benutzerfeld 1"; + Text [ENGLISH] = "Custom field 1"; + Text[ english_us ] = "User-defined 1"; + Text[ portuguese ] = "Campo de utilizador 1"; + Text[ russian ] = "Ïîëå ïîëüçîâàòåëÿ 1"; + Text[ greek ] = "Ðåäßï ÷ñÞóôç 1"; + Text[ dutch ] = "Gebruikersveld 1"; + Text[ french ] = "Champ d'utilisateur 1"; + Text[ spanish ] = "Campo de usuario 1"; + Text[ italian ] = "Utente 1"; + Text[ danish ] = "Brugerdefineret 1"; + Text[ swedish ] = "Användarfält 1"; + Text[ polish ] = "Pole u¿ytkownika 1"; + Text[ portuguese_brazilian ] = "Custom field 1"; + Text[ japanese ] = "Õ°»Þ°Ì¨°ÙÄÞ1"; + Text[ korean ] = "»ç¿ëÀÚ Á¤ÀÇ Çʵå 1"; + Text[ chinese_simplified ] = "Óû§À¸ 1"; + Text[ chinese_traditional ] = "¦ÛqÄæ¦ì 1"; + Text[ arabic ] = "ÍÞá ÇáãÓÊÎÏã 1"; + Text[ turkish ] = "Kullanýcý alaný 1"; + Text[ language_user1 ] = " "; + }; + ListBox LB_CUSTOM1 + { + Pos = MAP_APPFONT ( 282 , 133 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_CUSTOM2 + { + Pos = MAP_APPFONT ( 12 , 149 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Benutzerfeld 2"; + Text [ENGLISH] = "Custom field 2"; + Text[ english_us ] = "User-defined 2"; + Text[ portuguese ] = "Campo de utilizador 2"; + Text[ russian ] = "Ïîëå ïîëüçîâàòåëÿ 2"; + Text[ greek ] = "Ðåäßï ÷ñÞóôç 2"; + Text[ dutch ] = "Gebruikersveld 2"; + Text[ french ] = "Champ d'tilisateur 2"; + Text[ spanish ] = "Campo de usuario 2"; + Text[ italian ] = "Utente 2"; + Text[ danish ] = "Brugerdefineret 2"; + Text[ swedish ] = "Användarfält 2"; + Text[ polish ] = "Pole u¿ytkownika 2"; + Text[ portuguese_brazilian ] = "Custom field 2"; + Text[ japanese ] = "Õ°»Þ°Ì¨°ÙÄÞ2"; + Text[ korean ] = "»ç¿ëÀÚ Á¤ÀÇ Çʵå 2"; + Text[ chinese_simplified ] = "Óû§À¸ 2"; + Text[ chinese_traditional ] = "¦ÛqÄæ¦ì 2"; + Text[ arabic ] = "ÍÞá ÇáãÓÊÎÏã 2"; + Text[ turkish ] = "Kullanýcý alaný 2"; + Text[ language_user1 ] = " "; + }; + ListBox LB_CUSTOM2 + { + Pos = MAP_APPFONT ( 65 , 148 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_CUSTOM3 + { + Pos = MAP_APPFONT ( 118 , 149 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Benutzerfeld 3"; + Text [ENGLISH] = "Custom field 3"; + Text[ english_us ] = "User-defined 3"; + Text[ portuguese ] = "Campo de utilizador 3"; + Text[ russian ] = "Ïîëå ïîëüçîâàòåëÿ 3"; + Text[ greek ] = "Ðåäßï ÷ñÞóôç 3"; + Text[ dutch ] = "Gebruikersveld 3"; + Text[ french ] = "Champ d'utilisateur 3"; + Text[ spanish ] = "Campo de usuario 3"; + Text[ italian ] = "Utente 3"; + Text[ danish ] = "Brugerdefineret 3"; + Text[ swedish ] = "Användarfält 3"; + Text[ polish ] = "Pole u¿ytkownika 3"; + Text[ portuguese_brazilian ] = "Custom field 3"; + Text[ japanese ] = "Õ°»Þ°Ì¨°ÙÄÞ3"; + Text[ korean ] = "»ç¿ëÀÚ Á¤ÀÇ Çʵå 3"; + Text[ chinese_simplified ] = "Óû§À¸ 3"; + Text[ chinese_traditional ] = "¦ÛqÄæ¦ì 3"; + Text[ arabic ] = "ÍÞá ÇáãÓÊÎÏã 3"; + Text[ turkish ] = "Kullanýcý alaný 3"; + }; + ListBox LB_CUSTOM3 + { + Pos = MAP_APPFONT ( 171 , 148 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_CUSTOM4 + { + Pos = MAP_APPFONT ( 229 , 149 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Benutzerfeld 4"; + Text [ENGLISH] = "Custom field 4"; + Text[ english_us ] = "User-defined 4"; + Text[ portuguese ] = "Campo de utilizador 4"; + Text[ russian ] = "Ïîëå ïîëüçîâàòåëÿ 4"; + Text[ greek ] = "Ðåäßï ÷ñÞóôç 4"; + Text[ dutch ] = "Gebruikersveld 4"; + Text[ french ] = "Champ d'utilisateur 4"; + Text[ spanish ] = "Campo de usuario 4"; + Text[ italian ] = "Utente 4"; + Text[ danish ] = "Brugerdefineret 4"; + Text[ swedish ] = "Användarfält 4"; + Text[ polish ] = "Pole u¿ytkownika 4"; + Text[ portuguese_brazilian ] = "Custom field 4"; + Text[ japanese ] = "Õ°»Þ°Ì¨°ÙÄÞ4"; + Text[ korean ] = "»ç¿ëÀÚ Á¤ÀÇ Çʵå 4"; + Text[ chinese_simplified ] = "Óû§À¸ 4"; + Text[ chinese_traditional ] = "¦ÛqÄæ¦ì 4"; + Text[ arabic ] = "ÍÞá ÇáãÓÊÎÏã 4"; + Text[ turkish ] = "Kullanýcý alaný 4"; + }; + ListBox LB_CUSTOM4 + { + Pos = MAP_APPFONT ( 282, 148 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + FixedText FT_CUSTOM5 + { + Pos = MAP_APPFONT ( 12 , 164 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text = "Benutzerfeld 5"; + Text [ENGLISH] = "Custom field 5"; + Text[ english_us ] = "User-defined 5"; + Text[ portuguese ] = "Campo de utilizador 5"; + Text[ russian ] = "Ïîëå ïîëüçîâàòåëÿ 5"; + Text[ greek ] = "Ðåäßï ÷ñÞóôç 5"; + Text[ dutch ] = "Gebruikersveld 5"; + Text[ french ] = "Champ d'utilisateur 5"; + Text[ spanish ] = "Campo de usuario 5"; + Text[ italian ] = "Utente 5"; + Text[ danish ] = "Brugerdefineret 5"; + Text[ swedish ] = "Användarfält 5"; + Text[ polish ] = "Pole u¿ytkownika 5"; + Text[ portuguese_brazilian ] = "Custom field 5"; + Text[ japanese ] = "Õ°»Þ°Ì¨°ÙÄÞ5"; + Text[ korean ] = "»ç¿ëÀÚ Á¤ÀÇ Çʵå 5"; + Text[ chinese_simplified ] = "Óû§À¸ 5"; + Text[ chinese_traditional ] = "¦ÛqÄæ¦ì 5"; + Text[ arabic ] = "ÍÞá ÇáãÓÊÎÏã 5"; + Text[ turkish ] = "Kullanýcý alaný 5"; + }; + ListBox LB_CUSTOM5 + { + Pos = MAP_APPFONT ( 65 , 163 ) ; + Size = MAP_APPFONT ( 50 , 60 ) ; + DropDown = TRUE; + }; + String ST_NONE + { + Text = "<kein>"; + Text [ENGLISH] = "<none>"; + Text[ english_us ] = "<none>"; + Text[ portuguese ] = "<nenhum>"; + Text[ russian ] = "<áåç>"; + Text[ greek ] = "<êáíÝíá>"; + Text[ dutch ] = "<geen>"; + Text[ french ] = "<aucun>"; + Text[ spanish ] = "<ninguno>"; + Text[ italian ] = "<nessuno>"; + Text[ danish ] = "<ingen>"; + Text[ swedish ] = "<ingen>"; + Text[ polish ] = "<brak>"; + Text[ portuguese_brazilian ] = "<none>"; + Text[ japanese ] = "<‚È‚µ>"; + Text[ korean ] = "<¾øÀ½>"; + Text[ chinese_simplified ] = "<ÎÞ>"; + Text[ chinese_traditional ] = "<µL>"; + Text[ arabic ] = "<ÈÏæä>"; + Text[ turkish ] = "<Yok>"; + Text[ language_user1 ] = " "; + }; + Text[ english_us ] = "Column Layout for Table %1"; + Text[ portuguese ] = "Atribuição de colunas para a tabela %1"; + Text[ russian ] = "Ðàñïîëîæåíèå êîëîíîê äëÿ òàáëèöû %1"; + Text[ greek ] = "Ðñïóäéïñéóìüò óôçëþí ãéá ðßíáêá %1"; + Text[ dutch ] = "Kolomindeling voor tabel %1"; + Text[ french ] = "Assignation de colonnes pour la table %1"; + Text[ spanish ] = "Asignación de columnas para tabla %1"; + Text[ italian ] = "Assegnazione colonne per la tabella %1"; + Text[ danish ] = "Kolonnetildeling for tabel %1"; + Text[ swedish ] = "Kolumntilldelning för tabell %1"; + Text[ polish ] = "Przyporz¹dkowanie kolumn tabeli %1"; + Text[ portuguese_brazilian ] = "Column assignment for table %1"; + Text[ japanese ] = "ðÌÞÙ%1—p‚Ì—ñ‚Ì•ª—Þ"; + Text[ korean ] = "Å×À̺í¿ë ¿ ·¹À̾ƿô %1"; + Text[ chinese_simplified ] = "Ϊ±í¸ñ %1 ±àÅÅÉè¼ÆÁÐ"; + Text[ chinese_traditional ] = "½s±Æ %1 ªí®æªºÄæ"; + Text[ arabic ] = "ÊÚííä ÇáÃÚãÏÉ ááÌÏæá %1"; + Text[ turkish ] = "Tablo %1 için sütun düzeni"; +}; +ModalDialog RID_DLG_DBCHANGE +{ + HelpID = HID_DLG_DBCHANGE; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 291 , 131 ) ; + Moveable = TRUE ; + Text = "Auswahl der Datenquelle"; + Text [ENGLISH] = "Select data source"; + + OKButton BT_OK + { + Pos = MAP_APPFONT ( 238 , 3 ) ; + Size = MAP_APPFONT ( 50 , 12 ) ; + }; + CancelButton BT_CANCEL + { + Pos = MAP_APPFONT ( 238 , 18 ) ; + Size = MAP_APPFONT ( 50 , 12 ) ; + }; + HelpButton BT_HELP + { + Pos = MAP_APPFONT ( 238 , 36 ) ; + Size = MAP_APPFONT ( 50 , 12 ) ; + }; + GroupBox GB_SELECTION + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 229 , 125 ) ; + Text = "Auswahl"; + Text [ENGLISH] = "Selection"; + Text[ english_us ] = "Selection"; + Text[ portuguese ] = "Selecção"; + Text[ russian ] = "Âûáîð"; + Text[ greek ] = "ÅðéëïãÞ"; + Text[ dutch ] = "Selectie"; + Text[ french ] = "Sélection"; + Text[ spanish ] = "Selección"; + Text[ italian ] = "Selezione"; + Text[ danish ] = "Udvalg"; + Text[ swedish ] = "Urval"; + Text[ polish ] = "Wybór"; + Text[ portuguese_brazilian ] = "Selection"; + Text[ japanese ] = "‘I‘ð"; + Text[ korean ] = "¼±ÅÃ"; + Text[ chinese_simplified ] = "Ñ¡Ôñ"; + Text[ chinese_traditional ] = "¿ï¾Ü"; + Text[ arabic ] = "ÇáÊÍÏíÏ"; + Text[ turkish ] = "Seçim"; + Text[ language_user1 ] = " "; + }; + String ST_ENTRY + { + Text = "Eintrag"; + Text [ENGLISH] = "Entry"; + Text[ english_us ] = "Entry"; + Text[ portuguese ] = "Entrada"; + Text[ russian ] = "Ýëåìåíò"; + Text[ greek ] = "ÅããñáöÞ"; + Text[ dutch ] = "Item"; + Text[ french ] = "Entrée"; + Text[ spanish ] = "Entrada"; + Text[ italian ] = "Voce"; + Text[ danish ] = "Element"; + Text[ swedish ] = "Post"; + Text[ polish ] = "Wpis"; + Text[ portuguese_brazilian ] = "Entry"; + Text[ japanese ] = "€–Ú"; + Text[ korean ] = "Ç׸ñ"; + Text[ chinese_simplified ] = "ÌõÄ¿"; + Text[ chinese_traditional ] = "±ø¥Ø"; + Text[ arabic ] = "ÅÏÎÇá"; + Text[ turkish ] = "Giriþ"; + }; + String ST_URL + { + Text = "URL"; + Text [ENGLISH] = "URL"; + Text[ english_us ] = "URL"; + Text[ portuguese ] = "URL"; + Text[ russian ] = "URL"; + Text[ greek ] = "URL"; + Text[ dutch ] = "URL"; + Text[ french ] = "URL"; + Text[ spanish ] = "URL"; + Text[ italian ] = "URL"; + Text[ danish ] = "URL"; + Text[ swedish ] = "URL"; + Text[ polish ] = "URL"; + Text[ portuguese_brazilian ] = "URL"; + Text[ japanese ] = "URL"; + Text[ korean ] = "URL"; + Text[ chinese_simplified ] = "URL"; + Text[ chinese_traditional ] = "URL"; + Text[ arabic ] = "URL"; + Text[ turkish ] = "URL"; + Text[ language_user1 ] = " "; + }; + Control LB_SELECTION + { + Pos = MAP_APPFONT ( 9 , 24 ) ; + Size = MAP_APPFONT ( 223 , 100 ) ; + Border = TRUE; + TabStop = TRUE; + }; + Window HB_SELECTION + { + Pos = MAP_APPFONT ( 9 , 12 ) ; + Size = MAP_APPFONT ( 223 , 12 ) ; + Border = TRUE; + }; + Text[ english_us ] = "Select Data Source"; + Text[ portuguese ] = "Seleccionar fonte de dados"; + Text[ russian ] = "Âûáîð èñòî÷íèêà äàííûõ"; + Text[ greek ] = "ÅðéëïãÞ ðñïÝëåõóçò äåäïìÝíùí"; + Text[ dutch ] = "Kies gegevensbron"; + Text[ french ] = "Sélection de la source de données"; + Text[ spanish ] = "Selección de la fuente de datos"; + Text[ italian ] = "Selezione della sorgente dati"; + Text[ danish ] = "Vælg datakilde"; + Text[ swedish ] = "Urval av datakälla"; + Text[ polish ] = "Wybór Ÿród³a danych"; + Text[ portuguese_brazilian ] = "Select data source"; + Text[ japanese ] = "ÃÞ°À¿°½‚Ì‘I‘ð"; + Text[ korean ] = "µ¥ÀÌÅÍ ¼Ò½º ¼±ÅÃ"; + Text[ chinese_simplified ] = "Ñ¡ÔñÊý¾ÝÔ´"; + Text[ chinese_traditional ] = "¿ï¾Ü¼ÆÕu·½"; + Text[ arabic ] = "ÊÍÏíÏ ãÕÏÑ ÇáÈíÇäÇÊ"; + Text[ turkish ] = "Veri kaynaðý seçimi"; + Text[ language_user1 ] = " "; +}; + diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx new file mode 100644 index 000000000000..e8de5942814f --- /dev/null +++ b/extensions/source/bibliography/framectr.cxx @@ -0,0 +1,629 @@ +/************************************************************************* + * + * $RCSfile: framectr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 _SV_WAITOBJ_HXX //autogen wg. WaitObject +#include <vcl/waitobj.hxx> +#endif + +#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_ +#include <cppuhelper/interfacecontainer.hxx> +#endif +#ifndef _COM_SUN_STAR_UTIL_URL_HPP_ +#include <com/sun/star/util/URL.hpp> +#endif +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +//#ifndef _USR_ITERHLP_HXX +//#include <usr/iterhlp.hxx> +//#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +//#ifndef _TOOLKIT_UNOIFACE_HXX +//#include <toolkit/unoiface.hxx> +//#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _BIB_FRAMECTR_HXX +#include "framectr.hxx" +#endif +#ifndef _BIB_DATMAN_HXX +#include "datman.hxx" +#endif +#ifndef _BIB_FIELDWIN_HXX +#include "fieldwin.hxx" +#endif +#ifndef ADRRESID_HXX +#include "bibresid.hxx" +#endif +#ifndef BIB_HRC +#include "bib.hrc" +#endif +#ifndef _TOOLKIT_UNOHLP_HXX +#include <toolkit/helper/vclunohelper.hxx> +#endif + +#ifndef _COM_SUN_STAR_DATA_XDATABASEDIALOGS_HPP_ +#include <com/sun/star/data/XDatabaseDialogs.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> // helper for implementations +#endif + +//using namespace vos; +using namespace osl; +using namespace cppu; +using namespace rtl; +using namespace com::sun::star::frame; +using namespace com::sun::star::uno; +using namespace com::sun::star; + +#define C2U(cChar) OUString::createFromAscii(cChar) +extern rtl::OUString gGridModelCommand; + +SV_IMPL_PTRARR( BibStatusDispatchArr, BibStatusDispatchPtr ); + +class BibFrameCtrl_Impl : public cppu::WeakImplHelper1 < XFrameActionListener > +{ +public: + Mutex aMutex; + OMultiTypeInterfaceContainerHelper aLC; + + BibFrameController_Impl* pController; + + BibFrameCtrl_Impl() + : aLC( aMutex ) + , pController(0) + {} + + ~BibFrameCtrl_Impl(); + + virtual void SAL_CALL frameAction(const FrameActionEvent& aEvent) throw( RuntimeException ); + virtual void SAL_CALL disposing( const lang::EventObject& Source ); +}; + + +BibFrameCtrl_Impl::~BibFrameCtrl_Impl() +{ +} + +void BibFrameCtrl_Impl::frameAction(const FrameActionEvent& aEvent) throw( uno::RuntimeException ) +{ + if ( pController && aEvent.Frame == pController->getFrame()) + { + if(aEvent.Action == FrameAction_FRAME_ACTIVATED) + { + pController->activate(); + } + else if(aEvent.Action == FrameAction_FRAME_DEACTIVATING) + { + pController->deactivate(); + } + } +} + +void BibFrameCtrl_Impl::disposing( const lang::EventObject& Source ) +{ + if ( pController ) + pController->getFrame()->removeFrameActionListener( this ); +} + +BibFrameController_Impl::BibFrameController_Impl( const uno::Reference< awt::XWindow > & xComponent): + xWindow( xComponent ), + pDatMan(NULL), + pFieldWin(NULL) + +{ + pBibMod = OpenBibModul(); + pDatMan = (*pBibMod)->createDataManager(); + xDatman = pDatMan; + bDisposing=sal_False; + bHierarchical=sal_True; + pImp = new BibFrameCtrl_Impl; + pImp->pController = this; + pImp->acquire(); +} + +BibFrameController_Impl::BibFrameController_Impl( const uno::Reference< awt::XWindow > & xComponent, + BibDataManager* pDataManager): + xWindow( xComponent ), + pDatMan(pDataManager), + pFieldWin(NULL), + pBibMod(NULL) +{ + bDisposing=sal_False; + bHierarchical=sal_True; + pImp = new BibFrameCtrl_Impl; + pImp->pController = this; + pImp->acquire(); +} + +BibDataManager* BibFrameController_Impl::GetDataManager() +{ + return pDatMan; +} + +BibFrameController_Impl::~BibFrameController_Impl() +{ + pImp->pController = NULL; + pImp->release(); + delete pDatMan; + if(pBibMod) + CloseBibModul(pBibMod); +} + +void BibFrameController_Impl::attachFrame( const uno::Reference< XFrame > & xArg ) +{ + xFrame = xArg; + xFrame->addFrameActionListener( pImp ); +} + +sal_Bool BibFrameController_Impl::attachModel( const uno::Reference< XModel > & xModel ) +{ + return sal_False; +} + +sal_Bool BibFrameController_Impl::suspend( sal_Bool bSuspend ) +{ + if ( bSuspend ) + getFrame()->removeFrameActionListener( pImp ); + else + getFrame()->addFrameActionListener( pImp ); + return sal_True; +} + +uno::Any BibFrameController_Impl::getViewData() +{ + return uno::Any(); +} + +void BibFrameController_Impl::restoreViewData( const uno::Any& Value ) +{ +} + +uno::Reference< XFrame > BibFrameController_Impl::getFrame() +{ + return xFrame; +} + +uno::Reference< XModel > BibFrameController_Impl::getModel() +{ + return uno::Reference< XModel > (); +} + +void BibFrameController_Impl::dispose() +{ + util::URL aURL; + aURL.Complete = C2U("0"); + uno::Reference< XDispatchProvider > xProv( xFrame, UNO_QUERY ); + if ( xProv.is() ) + { + uno::Reference< XDispatch > aDisp = xProv->queryDispatch( aURL, C2U("_tool:_menubar"), 0 ); + if ( aDisp.is() ) + aDisp->dispatch( aURL, uno::Sequence<beans::PropertyValue>() ); + } + + + delete pFieldWin; + bDisposing = sal_True; + lang::EventObject aObject; + aObject.Source = (XController*)this; + pImp->aLC.disposeAndClear(aObject); + xDatman = 0; + pDatMan = 0; + aStatusListeners.DeleteAndDestroy( 0, aStatusListeners.Count() ); + } + +void BibFrameController_Impl::addEventListener( const uno::Reference< lang::XEventListener > & aListener ) +{ + pImp->aLC.addInterface( ::getCppuType((const Reference< lang::XEventListener >*)0), aListener ); +} + +void BibFrameController_Impl::removeEventListener( const uno::Reference< lang::XEventListener > & aListener ) +{ + pImp->aLC.removeInterface( ::getCppuType((const Reference< lang::XEventListener >*)0), aListener ); +} + +uno::Reference< frame::XDispatch > BibFrameController_Impl::queryDispatch( const util::URL& aURL, const rtl::OUString& aTarget, sal_Int32 nSearchFlags ) +{ + if ( !bDisposing ) + { + String aCommand( aURL.Path ); + if ( aCommand.EqualsAscii("Undo") || aCommand.EqualsAscii("Cut") || + aCommand.EqualsAscii("Copy") || aCommand.EqualsAscii("Paste") || + aCommand.EqualsAscii("SelectAll") || aCommand.Copy(0,4).EqualsAscii("Bib/")|| + aCommand.EqualsAscii("Title")) + + return (frame::XDispatch*) this; + } + + return uno::Reference< frame::XDispatch > (); +} + +uno::Sequence<uno::Reference< XDispatch > > BibFrameController_Impl::queryDispatches( const uno::Sequence<DispatchDescriptor>& aDescripts ) +{ + return uno::Sequence<uno::Reference< XDispatch > >(); +} + +//class XDispatch +void BibFrameController_Impl::dispatch(const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs) +{ + if ( !bDisposing ) + { + WaitObject aWaitObject; + + String aCommand( aURL.Path); + if(aCommand.EqualsAscii("Bib/Mapping")) + { + Window* pParent = VCLUnoHelper::GetWindow( xWindow ); + pDatMan->CreateMappingDialog(pParent); + } + else if(aCommand.EqualsAscii("Bib/source")) + { + ChangeDataSource(aArgs); + } + else if(aCommand.EqualsAscii("Bib/sdbsource")) + { + Window* pParent = VCLUnoHelper::GetWindow( xWindow ); + rtl::OUString aURL = pDatMan->CreateDBChangeDialog(pParent); + if(aURL.getLength()) + { + uno::Sequence< beans::PropertyValue > aArgs(2); + beans::PropertyValue* pProps = aArgs.getArray(); + pProps[0].Value <<= rtl::OUString(); + pProps[1].Value <<= aURL; + ChangeDataSource(aArgs); + } + } + else if(aCommand.EqualsAscii("Bib/autoFilter")) + { + sal_uInt16 nCount = aStatusListeners.Count(); + for ( sal_uInt16 n=0; n<nCount; n++ ) + { + BibStatusDispatch *pObj = aStatusListeners[n]; + if ( pObj->aURL.Path == C2U("Bib/removeFilter") ) + { + FeatureStateEvent aEvent; + aEvent.FeatureURL = pObj->aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + pObj->xListener->statusChanged( aEvent ); + //break; because there are more than one + } + } + + const beans::PropertyValue* pPropertyValue = aArgs.getConstArray(); + uno::Any aValue=pPropertyValue[0].Value; + rtl::OUString aQuery; + aValue >>= aQuery; + + aValue=pPropertyValue[1].Value; + rtl::OUString aQueryField; + aValue >>= aQueryField; + pDatMan->setQueryField(aQueryField); + pDatMan->startQueryWith(aQuery); + } + else if(aCommand.EqualsAscii("Bib/standardFilter")) + { + sal_uInt16 nCount = aStatusListeners.Count(); + for ( sal_uInt16 n=0; n<nCount; n++ ) + { + BibStatusDispatch *pObj = aStatusListeners[n]; + if ( pObj->aURL.Path == C2U("Bib/removeFilter") ) + { + FeatureStateEvent aEvent; + aEvent.FeatureURL = pObj->aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + pObj->xListener->statusChanged( aEvent ); + //break; because there are more than one + } + } + + uno::Reference< sdb::XSQLQueryComposer > xParser=pDatMan->getParser(); + uno::Reference< data::XDatabaseDialogs > xDlgs(xParser, UNO_QUERY); + if (xDlgs.is()) + { + uno::Reference< container::XNamed > xField; + xDlgs->executeFilter(xField); + pDatMan->setFilter(xParser->getFilter()); + } + } + else if(aCommand.EqualsAscii("Bib/removeFilter")) + { + RemoveFilter(); + } + } +} +//----------------------------------------------------------------------------- +void BibFrameController_Impl::addStatusListener( + const uno::Reference< frame::XStatusListener > & aListener, + const util::URL& aURL) +{ + // create a new Reference and insert into listener array + aStatusListeners.Insert( new BibStatusDispatch( aURL, aListener ), aStatusListeners.Count() ); + + // den ersten Status synchron zusenden + if ( aURL.Path == C2U("Bib/hierarchical") ) + { + FeatureStateEvent aEvent; + aEvent.FeatureURL = aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + const char* pHier = bHierarchical? "" : "*" ; + aEvent.State <<= rtl::OUString::createFromAscii(pHier); + aListener->statusChanged( aEvent ); + } + else if(aURL.Path == C2U("Bib/MenuFilter")) + { + FeatureStateEvent aEvent; + aEvent.FeatureURL = aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + aEvent.FeatureDescriptor=pDatMan->getQueryField(); + + uno::Sequence<rtl::OUString> aStringSeq=pDatMan->getQueryFields(); + aEvent.State.setValue(&aStringSeq,::getCppuType((uno::Sequence<rtl::OUString>*)0)); + + aListener->statusChanged( aEvent ); + } + else if ( aURL.Path == C2U("Bib/source")) + { + FeatureStateEvent aEvent; + aEvent.FeatureURL = aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + aEvent.FeatureDescriptor=pDatMan->getActiveDataTable(); + + uno::Sequence<rtl::OUString> aStringSeq=pDatMan->getDataSources(); + aEvent.State.setValue(&aStringSeq,::getCppuType((uno::Sequence<rtl::OUString>*)0)); + aListener->statusChanged( aEvent ); + } + else if(aURL.Path == C2U("Bib/query")) + { + FeatureStateEvent aEvent; + aEvent.FeatureURL = aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + aEvent.State <<= pDatMan->getQueryString(); + aListener->statusChanged( aEvent ); + } + else if (aURL.Path == C2U("Bib/removeFilter") ) + { + rtl::OUString aFilterStr=pDatMan->getFilter(); + FeatureStateEvent aEvent; + aEvent.FeatureURL = aURL; + aEvent.IsEnabled = (aFilterStr.len() > 0); + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + aListener->statusChanged( aEvent ); + //break; because there are more than one + } + else + { + FeatureStateEvent aEvent; + aEvent.FeatureURL = aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + aEvent.State <<= OUString(String(BibResId(RID_BIB_STR_FRAME_TITLE))); + aListener->statusChanged( aEvent ); + } +} +//----------------------------------------------------------------------------- +void BibFrameController_Impl::removeStatusListener( + const uno::Reference< frame::XStatusListener > & aObject, const util::URL& aURL) +{ + // search listener array for given listener + // for checking equality always "cast" to XInterface + if ( !bDisposing ) + { + sal_uInt16 nCount = aStatusListeners.Count(); + for ( sal_uInt16 n=0; n<nCount; n++ ) + { + BibStatusDispatch *pObj = aStatusListeners[n]; + sal_Bool bFlag=pObj->xListener.is(); + if (!bFlag || (pObj->xListener == aObject && + ( !aURL.Complete.len() || pObj->aURL.Path == aURL.Path ))) + { + aStatusListeners.DeleteAndDestroy( n ); + break; + } + } + } +} +//----------------------------------------------------------------------------- +void BibFrameController_Impl::RemoveFilter() +{ + rtl::OUString aQuery; + pDatMan->startQueryWith(aQuery); + + sal_uInt16 nCount = aStatusListeners.Count(); + FeatureStateEvent aEvent; + + sal_Bool bRemoveFilter=sal_False; + sal_Bool bQueryText=sal_False; + + for ( sal_uInt16 n=0; n<nCount; n++ ) + { + BibStatusDispatch *pObj = aStatusListeners[n]; + if ( pObj->aURL.Path == C2U("Bib/removeFilter") ) + { + FeatureStateEvent aEvent; + aEvent.FeatureURL = pObj->aURL; + aEvent.IsEnabled = sal_False; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + pObj->xListener->statusChanged( aEvent ); + bRemoveFilter=sal_True; + } + else if(pObj->aURL.Path == C2U("Bib/query")) + { + FeatureStateEvent aEvent; + aEvent.FeatureURL = pObj->aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + aEvent.State <<= aQuery; + pObj->xListener->statusChanged( aEvent ); + bQueryText=sal_True; + } + + if(bRemoveFilter && bQueryText) + break; + + } +} +//----------------------------------------------------------------------------- +void BibFrameController_Impl::ChangeDataSource(const uno::Sequence< beans::PropertyValue >& aArgs) +{ + const beans::PropertyValue* pPropertyValue = aArgs.getConstArray(); + uno::Any aValue=pPropertyValue[0].Value; + rtl::OUString aDBTableName; + aValue >>= aDBTableName; + + pDatMan->unloadDatabase(); + + if(aArgs.getLength() > 1) + { + uno::Any aDB = pPropertyValue[1].Value; + rtl::OUString aURL; + aDB >>= aURL; + pDatMan->setActiveDataSource(aURL); + aDBTableName = pDatMan->getActiveDataTable(); + } + else + pDatMan->setActiveDataTable(aDBTableName); + uno::Reference< awt::XControlModel > xNewModel=pDatMan->createGridModel(); + + sal_uInt16 nCount = aStatusListeners.Count(); + FeatureStateEvent aEvent; + + sal_Bool bGridMod=sal_False; + sal_Bool bMenuFilter=sal_False; + sal_Bool bQueryText=sal_False; + for ( sal_uInt16 n=0; n<nCount; n++ ) + { + BibStatusDispatch *pObj = aStatusListeners[n]; + if ( COMPARE_EQUAL == pObj->aURL.Path.compareToAscii("Bib/newGridModel")) + { + aEvent.FeatureURL = pObj->aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + + aEvent.State.setValue(&xNewModel, ::getCppuType((uno::Reference<awt::XControlModel>*)0)); + pObj->xListener->statusChanged( aEvent ); + bGridMod=sal_True; + } + else if(COMPARE_EQUAL == pObj->aURL.Path.compareToAscii("Bib/MenuFilter")) + { + aEvent.FeatureURL = pObj->aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + aEvent.FeatureDescriptor=pDatMan->getQueryField(); + + uno::Sequence<rtl::OUString> aStringSeq=pDatMan->getQueryFields(); + aEvent.State.setValue(&aStringSeq,::getCppuType((uno::Sequence<rtl::OUString>*)0)); + + pObj->xListener->statusChanged( aEvent ); + bMenuFilter=sal_True; + } + else if(COMPARE_EQUAL == pObj->aURL.Path.compareToAscii("Bib/query")) + { + FeatureStateEvent aEvent; + aEvent.FeatureURL = pObj->aURL; + aEvent.IsEnabled = sal_True; + aEvent.Requery = sal_False; + aEvent.Source = (XDispatch *) this; + aEvent.State <<= pDatMan->getQueryString(); + pObj->xListener->statusChanged( aEvent ); + bQueryText=sal_True; + } + + if(bGridMod && bMenuFilter && bQueryText) break; + + } + pDatMan->loadDatabase(); + if(pFieldWin) + pFieldWin->Update(pDatMan->getDatabaseForm()); +} + +void BibFrameController_Impl::activate() +{ + if(pFieldWin) pFieldWin->Show(); +} +void BibFrameController_Impl::deactivate() +{ + if(pFieldWin) pFieldWin->Hide(); +} + + diff --git a/extensions/source/bibliography/framectr.hxx b/extensions/source/bibliography/framectr.hxx new file mode 100644 index 000000000000..9709c5cc29f9 --- /dev/null +++ b/extensions/source/bibliography/framectr.hxx @@ -0,0 +1,198 @@ +/************************************************************************* + * + * $RCSfile: framectr.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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 _BIB_FRAMECTR_HXX +#define _BIB_FRAMECTR_HXX +//#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +//#include <com/sun/star/frame/XController.hpp> +//#endif +//#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_ +//#include <com/sun/star/frame/XStorable.hpp> +//#endif +//#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ +//#include <com/sun/star/frame/XModel.hpp> +//#endif +//#ifndef _COM_SUN_STAR_FRAME_XFRAMEACTIONLISTENER_HPP_ +//#include <com/sun/star/frame/XFrameActionListener.hpp> +//#endif +//#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ +//#include <com/sun/star/frame/XComponentLoader.hpp> +//#endif +//#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ +//#include <com/sun/star/frame/XFrame.hpp> +//#endif +//#ifndef _COM_SUN_STAR_FRAME_FRAMEACTIONEVENT_HPP_ +//#include <com/sun/star/frame/FrameActionEvent.hpp> +//#endif +//#ifndef _COM_SUN_STAR_FRAME_FRAMEACTION_HPP_ +//#include <com/sun/star/frame/FrameAction.hpp> +//#endif +//#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ +//#include <com/sun/star/util/XURLTransformer.hpp> +//#endif +//#ifndef _COM_SUN_STAR_AWT_XTOPWINDOW_HPP_ +//#include <com/sun/star/awt/XTopWindow.hpp> +//#endif +//#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ +//#include <com/sun/star/awt/XWindow.hpp> +//#endif +//#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_ +//#include <com/sun/star/awt/PosSize.hpp> +//#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_ +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ +#include <com/sun/star/frame/XDispatchProvider.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ +#include <com/sun/star/frame/XDispatch.hpp> +#endif +//#include <usr/uno.hxx> + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include <cppuhelper/implbase3.hxx> // helper for implementations +#endif + +#ifndef _SVARRAY_HXX +#include <svtools/svarray.hxx> +#endif + +#ifndef _BIB_FIELDWIN_HXX +#include "fieldwin.hxx" +#endif +#include "bibmod.hxx" +class BibDataManager; + +class BibStatusDispatch +{ +public: + ::com::sun::star::util::URL aURL; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > xListener; + BibStatusDispatch( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > xRef ) + : aURL( rURL ) + , xListener( xRef ) + {} +}; + +typedef BibStatusDispatch* BibStatusDispatchPtr; +SV_DECL_PTRARR_DEL( BibStatusDispatchArr, BibStatusDispatchPtr, 4, 4 ); + +class BibFrameController_Impl : public cppu::WeakImplHelper3 < + ::com::sun::star::frame::XController, + ::com::sun::star::frame::XDispatch, + ::com::sun::star::frame::XDispatchProvider +> +{ +friend class BibFrameCtrl_Impl; + BibFrameCtrl_Impl* pImp; + BibStatusDispatchArr aStatusListeners; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xWindow; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame; + sal_Bool bDisposing; + sal_Bool bHierarchical; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > xDatman; + BibDataManager* pDatMan; + BibFieldWin* pFieldWin; + HdlBibModul pBibMod; + +public: + BibFrameController_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > & xComponent); + BibFrameController_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > & xComponent, + BibDataManager* pDatMan); + ~BibFrameController_Impl(); + + + void activate(); + void deactivate(); + + BibDataManager* GetDataManager(); + void ChangeDataSource(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs); + void RemoveFilter(); + + + // ::com::sun::star::frame::XController + virtual void SAL_CALL attachFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & xFrame ); + virtual sal_Bool SAL_CALL attachModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ); + virtual sal_Bool SAL_CALL suspend( sal_Bool bSuspend ); + virtual ::com::sun::star::uno::Any SAL_CALL getViewData(); + virtual void SAL_CALL restoreViewData( const ::com::sun::star::uno::Any& Value ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SAL_CALL getFrame(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL getModel(); + + // ::com::sun::star::lang::XComponent + virtual void SAL_CALL dispose(); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener ); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener ); + + // ::com::sun::star::frame::XDispatchProvider + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts); + + //class ::com::sun::star::frame::XDispatch + virtual void SAL_CALL dispatch(const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs); + virtual void SAL_CALL addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL); + virtual void SAL_CALL removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL); + +}; + +#endif + diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx new file mode 100644 index 000000000000..9a15129156d9 --- /dev/null +++ b/extensions/source/bibliography/general.cxx @@ -0,0 +1,803 @@ +/************************************************************************* + * + * $RCSfile: general.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:44 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#pragma hdrstop + +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ +#include <unotools/processfactory.hxx> +#endif +#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_ +#include <com/sun/star/awt/PosSize.hpp> +#endif + +#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_ +#include <com/sun/star/sdbc/XRowSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XCOLUMN_HPP_ +#include <com/sun/star/sdb/XColumn.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_LISTSOURCETYPE_HPP_ +#include <com/sun/star/form/ListSourceType.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ +#include <com/sun/star/awt/XWindow.hpp> +#endif +#ifndef _TOOLKIT_UNOHLP_HXX +#include <toolkit/helper/vclunohelper.hxx> +#endif + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> // helper for implementations +#endif +#ifndef _BIB_GENERAL_HXX +#include "general.hxx" +#endif +#include "sections.hrc" +#ifndef ADRRESID_HXX +#include "bibresid.hxx" +#endif +#ifndef _BIB_DATMAN_HXX +#include "datman.hxx" +#endif +#ifndef _BIB_FMPROP_HRC +#include "bibprop.hrc" +#endif +//#ifndef _TOOLKIT_UNOIFACE_HXX +//#include <toolkit/unoiface.hxx> +//#endif +#include <extensio.hrc> +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::form; +using namespace ::rtl; + +#define C2U(cChar) OUString::createFromAscii(cChar) +#define C2S(cChar) String::CreateFromAscii(cChar) + +Point lcl_MovePoint(const FixedText& rFixedText) +{ + Point aRet(rFixedText.GetPosPixel()); + aRet.X() += rFixedText.GetSizePixel().Width(); + aRet.X() += 5; + return aRet; +} + +//----------------------------------------------------------------------------- +String lcl_GetColumnName(BibDataManager* pDatMan, const Mapping* pMapping, sal_uInt16 nIndexPos) +{ + String sRet = pDatMan->GetDefColumnName(nIndexPos); + if(pMapping) + for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++) + { + if(pMapping->aColumnPairs[i].sLogicalColumnName == sRet) + { + sRet = pMapping->aColumnPairs[i].sRealColumnName; + break; + } + } + return sRet; +} +/* -----------------------------04.01.00 10:54-------------------------------- + + ---------------------------------------------------------------------------*/ +class BibPosListener :public cppu::WeakImplHelper1 <sdbc::XRowSetListener> +{ + BibGeneralPage* pParentPage; +public: + BibPosListener(BibGeneralPage* pParent); + + //XPositioningListener + virtual void SAL_CALL cursorMoved(const lang::EventObject& event) throw( uno::RuntimeException ); + virtual void SAL_CALL rowChanged(const lang::EventObject& event) throw( uno::RuntimeException ){ /* not interested in */ } + virtual void SAL_CALL rowSetChanged(const lang::EventObject& event) throw( uno::RuntimeException ){ /* not interested in */ } + + //XEventListener + virtual void SAL_CALL disposing(const lang::EventObject& Source) throw( uno::RuntimeException ); + +}; +/* -----------------------------04.01.00 10:57-------------------------------- + + ---------------------------------------------------------------------------*/ +BibPosListener::BibPosListener(BibGeneralPage* pParent) : + pParentPage(pParent) +{ +} +/* -----------------------------04.01.00 10:57-------------------------------- + + ---------------------------------------------------------------------------*/ +void BibPosListener::cursorMoved(const lang::EventObject& /*aEvent*/) throw( uno::RuntimeException ) +{ + try + { + uno::Reference< form::XBoundComponent > xLstBox = pParentPage->GetTypeListBoxModel(); + uno::Reference< beans::XPropertySet > xPropSet(xLstBox, UNO_QUERY); + if(xPropSet.is()) + { + BibDataManager* pDatMan = pParentPage->GetDataManager(); + const Mapping* pMapping = pDatMan->GetMapping(pDatMan->getActiveDataTable()); + String sTypeMapping = pDatMan->GetDefColumnName(AUTHORITYTYPE_POS); + if(pMapping) + { + for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++) + { + if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == sTypeMapping) + { + sTypeMapping = pMapping->aColumnPairs[nEntry].sRealColumnName; + break; + } + } + } + rtl::OUString uTypeMapping = sTypeMapping; + + uno::Reference< form::XForm > xForm = pDatMan->getDatabaseForm(); + uno::Reference< sdbcx::XColumnsSupplier > xSupplyCols(xForm, UNO_QUERY); + uno::Reference< container::XNameAccess > xValueAcc; + if (xSupplyCols.is()) + xValueAcc = xSupplyCols->getColumns(); + + sal_Int16 nTempVal = -1; + if(xValueAcc.is() && xValueAcc->hasByName(uTypeMapping)) + { + uno::Any aVal = xValueAcc->getByName(uTypeMapping); + uno::Reference< uno::XInterface > xInt = *(uno::Reference< uno::XInterface > *)aVal.getValue(); + uno::Reference< sdb::XColumn > xCol(xInt, UNO_QUERY); + DBG_ASSERT(xCol.is(), "BibPosListener::positioned : invalid column (no sdb::XColumn) !"); + if (xCol.is()) + { + nTempVal = xCol->getShort(); + // getShort returns zero if the value is not a number + if (!nTempVal || xCol->wasNull()) + { + rtl::OUString sTempVal = xCol->getString(); + if(sTempVal != rtl::OUString('0')) + nTempVal = -1; + } + } + } + if(nTempVal < 0 || nTempVal >= TYPE_COUNT) + { + uno::Any aSel; + uno::Sequence<sal_Int16> aSelSeq(1); + sal_Int16* pArr = aSelSeq.getArray(); + pArr[0] = TYPE_COUNT; + aSel.setValue(&aSelSeq, ::getCppuType((Sequence<sal_Int16>*)0)); + xPropSet->setPropertyValue(C2U("SelectedItems"), aSel); + } + } + } + catch(...) + { + DBG_ERROR("BibPosListener::positioned: something went wrong !"); + } +} +/* -----------------------------04.01.00 11:28-------------------------------- + + ---------------------------------------------------------------------------*/ +void BibPosListener::disposing(const lang::EventObject& Source) throw( uno::RuntimeException ) +{ +} + +/* -----------------16.11.99 13:06------------------- + + --------------------------------------------------*/ +BibGeneralPage::BibGeneralPage(Window* pParent, BibDataManager* pMan): + TabPage(pParent,BibResId(RID_TP_GENERAL)), + pDatMan(pMan), + aControlParentWin(this, WB_DIALOGCONTROL), + aIdentifierFT(&aControlParentWin, ResId(FT_IDENTIFIER )), + aAuthTypeFT(&aControlParentWin, ResId(FT_AUTHTYPE )), + aAuthorFT(&aControlParentWin, ResId(FT_AUTHOR )), + aMonthFT(&aControlParentWin, ResId(FT_MONTH )), + aYearFT(&aControlParentWin, ResId(FT_YEAR )), + + aPublisherFT(&aControlParentWin, ResId(FT_PUBLISHER )), + aISBNFT(&aControlParentWin, ResId(FT_ISBN )), + + aAddressFT(&aControlParentWin, ResId(FT_ADDRESS )), + aAnnoteFT(&aControlParentWin, ResId(FT_ANNOTE )), + aBooktitleFT(&aControlParentWin, ResId(FT_BOOKTITLE )), + aChapterFT(&aControlParentWin, ResId(FT_CHAPTER )), + aEditionFT(&aControlParentWin, ResId(FT_EDITION )), + aEditorFT(&aControlParentWin, ResId(FT_EDITOR )), + aHowpublishedFT(&aControlParentWin, ResId(FT_HOWPUBLISHED )), + aInstitutionFT(&aControlParentWin, ResId(FT_INSTITUTION )), + aJournalFT(&aControlParentWin, ResId(FT_JOURNAL )), + aNoteFT(&aControlParentWin, ResId(FT_NOTE )), + aNumberFT(&aControlParentWin, ResId(FT_NUMBER )), + aOrganizationsFT(&aControlParentWin, ResId(FT_ORGANIZATION )), + aPagesFT(&aControlParentWin, ResId(FT_PAGE )), + aSchoolFT(&aControlParentWin, ResId(FT_SCHOOL )), + aSeriesFT(&aControlParentWin, ResId(FT_SERIES )), + aTitleFT(&aControlParentWin, ResId(FT_TITLE )), + aReportTypeFT(&aControlParentWin, ResId(FT_REPORT )), + aVolumeFT(&aControlParentWin, ResId(FT_VOLUME )), + aURLFT(&aControlParentWin, ResId(FT_URL )), + aCustom1FT(&aControlParentWin, ResId(FT_CUSTOM1 )), + aCustom2FT(&aControlParentWin, ResId(FT_CUSTOM2 )), + aCustom3FT(&aControlParentWin, ResId(FT_CUSTOM3 )), + aCustom4FT(&aControlParentWin, ResId(FT_CUSTOM4 )), + aCustom5FT(&aControlParentWin, ResId(FT_CUSTOM5 )), + aHoriScroll(this, WB_HORZ), + aVertScroll(this, WB_VERT), + sErrorPrefix(ResId(ST_ERROR_PREFIX)) +{ + aControlParentWin.Show(); + aStdSize = GetOutputSizePixel(); + + aBibTypeArr[0] = String(ResId(ST_TYPE_ARTICLE)); + aBibTypeArr[1] = String(ResId(ST_TYPE_BOOK)); + aBibTypeArr[2] = String(ResId(ST_TYPE_BOOKLET)); + aBibTypeArr[3] = String(ResId(ST_TYPE_CONFERENCE)); + aBibTypeArr[4] = String(ResId(ST_TYPE_INBOOK )); + aBibTypeArr[5] = String(ResId(ST_TYPE_INCOLLECTION)); + aBibTypeArr[6] = String(ResId(ST_TYPE_INPROCEEDINGS)); + aBibTypeArr[7] = String(ResId(ST_TYPE_JOURNAL )); + aBibTypeArr[8] = String(ResId(ST_TYPE_MANUAL )); + aBibTypeArr[9] = String(ResId(ST_TYPE_MASTERSTHESIS)); + aBibTypeArr[10] = String(ResId(ST_TYPE_MISC )); + aBibTypeArr[11] = String(ResId(ST_TYPE_PHDTHESIS )); + aBibTypeArr[12] = String(ResId(ST_TYPE_PROCEEDINGS )); + aBibTypeArr[13] = String(ResId(ST_TYPE_TECHREPORT )); + aBibTypeArr[14] = String(ResId(ST_TYPE_UNPUBLISHED )); + aBibTypeArr[15] = String(ResId(ST_TYPE_EMAIL )); + aBibTypeArr[16] = String(ResId(ST_TYPE_WWW )); + aBibTypeArr[17] = String(ResId(ST_TYPE_CUSTOM1 )); + aBibTypeArr[18] = String(ResId(ST_TYPE_CUSTOM2 )); + aBibTypeArr[19] = String(ResId(ST_TYPE_CUSTOM3 )); + aBibTypeArr[20] = String(ResId(ST_TYPE_CUSTOM4 )); + aBibTypeArr[21] = String(ResId(ST_TYPE_CUSTOM5 )); + + FreeResource(); + + aBasePos = aIdentifierFT.GetPosPixel(); + aFixedTexts[0] = &aIdentifierFT; + aFixedTexts[1] = &aAuthTypeFT; + aFixedTexts[2] = &aAuthorFT; + aFixedTexts[3] = &aMonthFT; + aFixedTexts[4] = &aYearFT; + aFixedTexts[5] = &aPublisherFT; + aFixedTexts[6] = &aISBNFT; + aFixedTexts[7] = &aAddressFT; + aFixedTexts[8] = &aAnnoteFT; + aFixedTexts[9] = &aBooktitleFT; + aFixedTexts[10] = &aChapterFT; + aFixedTexts[11] = &aEditionFT; + aFixedTexts[12] = &aEditorFT; + aFixedTexts[13] = &aHowpublishedFT; + aFixedTexts[14] = &aInstitutionFT; + aFixedTexts[15] = &aJournalFT; + aFixedTexts[16] = &aNoteFT; + aFixedTexts[17] = &aNumberFT; + aFixedTexts[18] = &aOrganizationsFT; + aFixedTexts[19] = &aPagesFT; + aFixedTexts[20] = &aSchoolFT; + aFixedTexts[21] = &aSeriesFT; + aFixedTexts[22] = &aTitleFT; + aFixedTexts[23] = &aReportTypeFT; + aFixedTexts[24] = &aVolumeFT; + aFixedTexts[25] = &aURLFT; + aFixedTexts[26] = &aCustom1FT; + aFixedTexts[27] = &aCustom2FT; + aFixedTexts[28] = &aCustom3FT; + aFixedTexts[29] = &aCustom4FT; + aFixedTexts[30] = &aCustom5FT; + for(USHORT i = 0; i < FIELD_COUNT; i++) + aControls[i] = 0; + + AdjustScrollbars(); + Link aScrollLnk(LINK(this, BibGeneralPage, ScrollHdl)); + aHoriScroll.SetScrollHdl( aScrollLnk ); + aVertScroll.SetScrollHdl( aScrollLnk ); + aHoriScroll.SetLineSize(10); + aVertScroll.SetLineSize(10); + aHoriScroll.SetPageSize( aIdentifierFT.GetSizePixel().Width()); + aVertScroll.SetPageSize( + aPublisherFT.GetPosPixel().Y() - aIdentifierFT.GetPosPixel().Y()); + aHoriScroll.Show(); + aVertScroll.Show(); + + const Mapping* pMapping = pDatMan->GetMapping(pDatMan->getActiveDataTable()); + + xCtrlContnr = VCLUnoHelper::CreateControlContainer(&aControlParentWin); + + xMgr = utl::getProcessServiceFactory(); + + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, IDENTIFIER_POS), + lcl_MovePoint(aIdentifierFT), aIdentifierFT.GetSizePixel(), sTableErrorString, + aIdentifierFT.GetText(), HID_BIB_IDENTIFIER_POS); + + sTypeColumnName = lcl_GetColumnName(pDatMan, pMapping, AUTHORITYTYPE_POS); + + AddControlWithError( + sTypeColumnName, + lcl_MovePoint(aAuthTypeFT ), aAuthTypeFT .GetSizePixel(), sTableErrorString, aAuthTypeFT.GetText(), HID_BIB_AUTHORITYTYPE_POS); + + + Point aYearPos = lcl_MovePoint(aYearFT); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, YEAR_POS), + aYearPos, aYearFT.GetSizePixel(), sTableErrorString, aYearFT.GetText(), HID_BIB_YEAR_POS); + + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, AUTHOR_POS), + lcl_MovePoint(aAuthorFT ), aAuthorFT .GetSizePixel(), sTableErrorString, aAuthorFT.GetText(), HID_BIB_AUTHOR_POS); + + Point aTitlePos(lcl_MovePoint(aTitleFT)); + Size aTitleSize = aTitleFT .GetSizePixel(); + aTitleSize.Width() = aYearPos.X() + aYearFT.GetSizePixel().Width() - aTitlePos.X(); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, TITLE_POS), + aTitlePos, aTitleSize, sTableErrorString, aTitleFT.GetText(), HID_BIB_TITLE_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, PUBLISHER_POS), + lcl_MovePoint(aPublisherFT), aPublisherFT.GetSizePixel(), sTableErrorString, aPublisherFT.GetText(), HID_BIB_PUBLISHER_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, ADDRESS_POS), + lcl_MovePoint(aAddressFT ), aAddressFT .GetSizePixel(), sTableErrorString, aAddressFT.GetText(), HID_BIB_ADDRESS_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, ISBN_POS), + lcl_MovePoint(aISBNFT ), aISBNFT .GetSizePixel(), sTableErrorString, aISBNFT.GetText(), HID_BIB_ISBN_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, CHAPTER_POS), + lcl_MovePoint(aChapterFT ), aChapterFT .GetSizePixel(), sTableErrorString, aChapterFT.GetText(), HID_BIB_CHAPTER_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, PAGES_POS), + lcl_MovePoint(aPagesFT ), aPagesFT .GetSizePixel(), sTableErrorString, aPagesFT.GetText(), HID_BIB_PAGES_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, EDITOR_POS), + lcl_MovePoint(aEditorFT ), aEditorFT .GetSizePixel(), sTableErrorString, aEditorFT.GetText(), HID_BIB_EDITOR_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, EDITION_POS), + lcl_MovePoint(aEditionFT ), aEditionFT .GetSizePixel(), sTableErrorString, aEditionFT.GetText(), HID_BIB_EDITION_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, BOOKTITLE_POS), + lcl_MovePoint(aBooktitleFT ), aBooktitleFT .GetSizePixel(), sTableErrorString, aBooktitleFT.GetText(), HID_BIB_BOOKTITLE_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, VOLUME_POS), + lcl_MovePoint(aVolumeFT ), aVolumeFT .GetSizePixel(), sTableErrorString, aVolumeFT.GetText(), HID_BIB_VOLUME_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, HOWPUBLISHED_POS), + lcl_MovePoint(aHowpublishedFT ), aHowpublishedFT .GetSizePixel(), sTableErrorString, aHowpublishedFT.GetText(), HID_BIB_HOWPUBLISHED_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, ORGANIZATIONS_POS), + lcl_MovePoint(aOrganizationsFT), aOrganizationsFT.GetSizePixel(), sTableErrorString, aOrganizationsFT.GetText(), HID_BIB_ORGANIZATIONS_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, INSTITUTION_POS), + lcl_MovePoint(aInstitutionFT ), aInstitutionFT .GetSizePixel(), sTableErrorString, aInstitutionFT.GetText(), HID_BIB_INSTITUTION_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, SCHOOL_POS), + lcl_MovePoint(aSchoolFT ), aSchoolFT .GetSizePixel(), sTableErrorString, aSchoolFT.GetText(), HID_BIB_SCHOOL_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, REPORTTYPE_POS), + lcl_MovePoint(aReportTypeFT ), aReportTypeFT .GetSizePixel(), sTableErrorString, aReportTypeFT.GetText(), HID_BIB_REPORTTYPE_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, MONTH_POS), + lcl_MovePoint(aMonthFT), aMonthFT .GetSizePixel(), sTableErrorString, aMonthFT.GetText(), HID_BIB_MONTH_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, JOURNAL_POS), + lcl_MovePoint(aJournalFT ), aJournalFT .GetSizePixel(), sTableErrorString, aJournalFT.GetText(), HID_BIB_JOURNAL_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, NUMBER_POS), + lcl_MovePoint(aNumberFT ), aNumberFT .GetSizePixel(), sTableErrorString, aNumberFT.GetText(), HID_BIB_NUMBER_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, SERIES_POS), + lcl_MovePoint(aSeriesFT ), aSeriesFT .GetSizePixel(), sTableErrorString, aSeriesFT.GetText(), HID_BIB_SERIES_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, ANNOTE_POS), + lcl_MovePoint(aAnnoteFT ), aAnnoteFT .GetSizePixel(), sTableErrorString, aAnnoteFT.GetText(), HID_BIB_ANNOTE_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, NOTE_POS), + lcl_MovePoint(aNoteFT ), aNoteFT .GetSizePixel(), sTableErrorString, aNoteFT.GetText(), HID_BIB_NOTE_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, URL_POS), + lcl_MovePoint(aURLFT ), aURLFT .GetSizePixel(), sTableErrorString, aURLFT.GetText(), HID_BIB_URL_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, CUSTOM1_POS), + lcl_MovePoint(aCustom1FT ), aCustom1FT.GetSizePixel(), sTableErrorString, aCustom1FT.GetText(), HID_BIB_CUSTOM1_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, CUSTOM2_POS), + lcl_MovePoint(aCustom2FT ), aCustom2FT.GetSizePixel(), sTableErrorString, aCustom2FT.GetText(), HID_BIB_CUSTOM2_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, CUSTOM3_POS), + lcl_MovePoint(aCustom3FT ), aCustom3FT.GetSizePixel(), sTableErrorString, aCustom3FT.GetText(), HID_BIB_CUSTOM3_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, CUSTOM4_POS), + lcl_MovePoint(aCustom4FT ), aCustom4FT.GetSizePixel(), sTableErrorString, aCustom4FT.GetText(), HID_BIB_CUSTOM4_POS); + AddControlWithError( + lcl_GetColumnName(pDatMan, pMapping, CUSTOM5_POS), + lcl_MovePoint(aCustom5FT ), aCustom5FT.GetSizePixel(), sTableErrorString, aCustom5FT.GetText(), HID_BIB_CUSTOM5_POS); + +// AddXControl("", lcl_MovePoint(.GetPosPixel()), .GetSizePixel(), sTableErrorString); + + xPosListener = new BibPosListener(this); + uno::Reference< sdbc::XRowSet > xRowSet(pDatMan->getDatabaseForm(), UNO_QUERY); + if(xRowSet.is()) + xRowSet->addRowSetListener(xPosListener); + xFormCtrl = uno::Reference< form::XFormController > ( + xMgr->createInstance(C2U("com.sun.star.form.controller.FormController")), UNO_QUERY); + xFormCtrl->setModel(uno::Reference< awt::XTabControllerModel > (pDatMan->getDatabaseForm(), UNO_QUERY)); + xFormCtrl->setContainer(xCtrlContnr); + xFormCtrl->activateTabOrder(); + + if(sTableErrorString.Len()) + sTableErrorString.Insert(sErrorPrefix, 0); +} +//----------------------------------------------------------------------------- +BibGeneralPage::~BibGeneralPage() +{ + if (pDatMan && xPosListener.is()) + { + uno::Reference< sdbc::XRowSet > xRowSet(pDatMan->getDatabaseForm(), UNO_QUERY); + if(xRowSet.is()) + xRowSet->removeRowSetListener(xPosListener); + } +} + /* -----------------------------14.04.00 13:11-------------------------------- + + ---------------------------------------------------------------------------*/ + void BibGeneralPage::RemoveListeners() + { + for(USHORT i = 0; i < FIELD_COUNT; i++) + { + if(aControls[i].is()) + { + uno::Reference< awt::XWindow > xCtrWin(aControls[i], uno::UNO_QUERY ); + xCtrWin->removeFocusListener( this ); + aControls[i] = 0; + } + } + } +/* -----------------------------21.01.00 17:05-------------------------------- + + ---------------------------------------------------------------------------*/ +void BibGeneralPage::CommitActiveControl() +{ + uno::Reference< awt::XControl > xCurr = xFormCtrl->getCurrentControl(); + if(xCurr.is()) + { + uno::Reference< awt::XControlModel > xModel = xCurr->getModel(); + uno::Reference< form::XBoundComponent > xBound(xModel, UNO_QUERY); + if(xBound.is()) + xBound->commit(); + } +} +//----------------------------------------------------------------------------- +void BibGeneralPage::AddControlWithError(const String& rColumnName, + const Point& rPos, + const Size& rSize, + String& rErrorString, + String aColumnUIName, + sal_uInt16 nHelpId) +{ + uno::Reference< awt::XControlModel > xTmp = AddXControl(rColumnName, rPos, rSize, nHelpId); + if(!xTmp.is()) + { + if(rErrorString.Len()) + { + rErrorString += '\n'; + } + aColumnUIName.EraseAllChars('~'); + rErrorString += aColumnUIName; + } +} +//----------------------------------------------------------------------------- +uno::Reference< awt::XControlModel > BibGeneralPage::AddXControl( + const String& rName, + Point rPos, Size rSize, sal_uInt16 nHelpId) +{ + uno::Reference< awt::XControlModel > xCtrModel; + try + { + sal_Bool bTypeListBox = sTypeColumnName == rName; + xCtrModel = pDatMan->loadControlModel(rName, bTypeListBox); + if ( xCtrModel.is() && xMgr.is()) + { + uno::Reference< beans::XPropertySet > xPropSet( xCtrModel, UNO_QUERY ); + + if( xPropSet.is()) + { + uno::Reference< beans::XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo(); + + uno::Any aAny = xPropSet->getPropertyValue( C2U("DefaultControl") ); + rtl::OUString aControlName; + aAny >>= aControlName; + + rtl::OUString uProp(C2U("HelpURL")); + if(xPropInfo->hasPropertyByName(uProp)) + { + String sId(C2S("HID:")); + sId += nHelpId; + rtl::OUString uId(sId) ; + uno::Any aVal; aVal <<= uId; + xPropSet->setPropertyValue(uProp, aVal); + } + + if(bTypeListBox) + { + //uno::Reference< beans::XPropertySet > xPropSet(xControl, UNO_QUERY); + uno::Any aAny; + aAny <<= (sal_Int16)1; + xPropSet->setPropertyValue(C2U("BoundColumn"), aAny); + // ListSourceType eSet = ListSourceType_SQL; + ListSourceType eSet = ListSourceType_VALUELIST; + aAny.setValue( &eSet, ::getCppuType((const ListSourceType*)0) ); + xPropSet->setPropertyValue(C2U("ListSourceType"), aAny); + + uno::Sequence<rtl::OUString> aListSource(TYPE_COUNT); + rtl::OUString* pListSourceArr = aListSource.getArray(); + //pListSourceArr[0] = C2U("select TypeName, TypeIndex from TypeNms"); + for(sal_uInt16 i = 0; i < TYPE_COUNT; i++) + pListSourceArr[i] = String::CreateFromInt32(i); + aAny.setValue(&aListSource, ::getCppuType((uno::Sequence<rtl::OUString>*)0)); + + xPropSet->setPropertyValue(C2U("ListSource"), aAny); + + uno::Sequence<rtl::OUString> aValues(TYPE_COUNT + 1); + rtl::OUString* pValuesArr = aValues.getArray(); + for(sal_uInt16 j = 0; j < TYPE_COUNT; j++) + pValuesArr[j] = aBibTypeArr[j]; + // empty string if an invalid value no values is set + pValuesArr[TYPE_COUNT] = rtl::OUString(); + + aAny.setValue(&aValues, ::getCppuType((uno::Sequence<rtl::OUString>*)0)); + + xPropSet->setPropertyValue(C2U("StringItemList"), aAny); + + BOOL bTrue = sal_True; + aAny.setValue( &bTrue, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( C2U("Dropdown"), aAny ); + + aControlName = C2U("com.sun.star.form.control.ListBox"); + xLBModel = Reference< form::XBoundComponent >(xCtrModel, UNO_QUERY); + + } + + uno::Reference< awt::XControl > xControl(xMgr->createInstance( aControlName ), UNO_QUERY ); + if ( xControl.is() ) + { + xControl->setModel( xCtrModel); + + // Peer als Child zu dem FrameWindow + xCtrlContnr->addControl(rName, xControl); + uno::Reference< awt::XWindow > xCtrWin(xControl, UNO_QUERY ); + xCtrWin->addFocusListener( this ); + for(USHORT i = 0; i < FIELD_COUNT; i++) + if(!aControls[i].is()) + { + aControls[i] = xCtrWin; + break; + } + xCtrWin->setVisible( sal_True ); + xControl->setDesignMode(sal_False); + + xCtrWin->setPosSize(rPos.X(), rPos.Y(), rSize.Width(), + rSize.Height(), awt::PosSize::POSSIZE); + } + } + } + } + catch(...) + { + DBG_ERROR("BibGeneralPage::AddXControl: something went wrong !"); + } + return xCtrModel; +} +/* -----------------------------14.04.00 11:15-------------------------------- + + ---------------------------------------------------------------------------*/ +void BibGeneralPage::AdjustScrollbars() +{ + long nVertScrollWidth = aVertScroll.GetSizePixel().Width(); + long nHoriScrollHeight = aHoriScroll.GetSizePixel().Height(); + Size aOutSize(GetOutputSizePixel()); + BOOL bHoriVisible = aOutSize.Width() <= aStdSize.Width(); + BOOL bVertVisible = (aOutSize.Height()-(bHoriVisible ? nHoriScrollHeight : 0)) <= (aStdSize.Height()); + aHoriScroll.Show(bHoriVisible); + aVertScroll.Show(bVertVisible); + + if(bHoriVisible) + { + Size aHoriSize(aOutSize.Width() - (bVertVisible ? nVertScrollWidth : 0), + nHoriScrollHeight); + aHoriScroll.SetSizePixel(aHoriSize); + aHoriScroll.SetRange( Range(0, aStdSize.Width())); + aHoriScroll.SetVisibleSize( aHoriSize.Width() - (bVertVisible ? nVertScrollWidth : 0)); + } + if(bVertVisible) + { + Size aVertSize(nHoriScrollHeight, aOutSize.Height() - + (bHoriVisible ? nHoriScrollHeight : 0)); + aVertScroll.SetSizePixel(aVertSize); + aVertScroll.SetRange( Range(0, aStdSize.Height())); + aVertScroll.SetVisibleSize( aVertSize.Height() ); + } + + Size aSize(8, 8); + aSize = LogicToPixel(aSize, MapMode(MAP_APPFONT)); + Size aScrollSize(aOutSize.Width() - aSize.Height(), aSize.Height()); + Point aScrollPos(0, aOutSize.Height() - aSize.Height()); + aHoriScroll.SetPosSizePixel(aScrollPos, aScrollSize); + + aScrollPos.X() = aOutSize.Width() - aSize.Width(); + aScrollPos.Y() = 0; + aScrollSize.Width() = aSize.Width(); + aScrollSize.Height() = aOutSize.Height() - aSize.Height(); + aVertScroll.SetPosSizePixel(aScrollPos, aScrollSize); + + Size aControlParentWinSz(aOutSize); + if(bHoriVisible) + aControlParentWinSz.Height() -= aSize.Height(); + if(bVertVisible) + aControlParentWinSz.Width() -= aSize.Width(); + aControlParentWin.SetSizePixel(aControlParentWinSz); +} +/* -----------------------------13.04.00 16:54-------------------------------- + + ---------------------------------------------------------------------------*/ +void BibGeneralPage::Resize() +{ + AdjustScrollbars(); + ScrollHdl(&aVertScroll); + ScrollHdl(&aHoriScroll); + Window::Resize(); +} +/* -----------------------------14.04.00 11:18-------------------------------- + + ---------------------------------------------------------------------------*/ +IMPL_LINK(BibGeneralPage, ScrollHdl, ScrollBar*, pScroll) +{ + BOOL bVertical = &aVertScroll == pScroll; + long nOffset = 0; + if(bVertical) + { + long nCurrentOffset = aFixedTexts[0]->GetPosPixel().Y() - aBasePos.Y(); + nOffset = pScroll->GetThumbPos() + nCurrentOffset; + } + else + { + long nCurrentOffset = aFixedTexts[0]->GetPosPixel().X() - aBasePos.X(); + nOffset = pScroll->GetThumbPos() + nCurrentOffset; + } + + for(USHORT i = 0; i < FIELD_COUNT; i++) + { + Point aPos = aFixedTexts[i]->GetPosPixel(); + if(bVertical) + aPos.Y() -= nOffset; + else + aPos.X() -= nOffset; + aFixedTexts[i]->SetPosPixel(aPos); + if(aControls[i].is()) + { + awt::Rectangle aRect = aControls[i]->getPosSize(); + long nX = aRect.X; + long nY = aRect.Y; + if(bVertical) + nY -= nOffset; + else + nX -= nOffset; + aControls[i]->setPosSize(nX, nY, 0, 0, awt::PosSize::POS); + } + } + return 0; +} +/* -----------------------------14.04.00 12:49-------------------------------- + + ---------------------------------------------------------------------------*/ +void BibGeneralPage::focusGained(const awt::FocusEvent& rEvent) throw( uno::RuntimeException ) +{ + Reference<awt::XWindow> xCtrWin(rEvent.Source, UNO_QUERY ); + if(xCtrWin.is()) + { + Size aOutSize = aControlParentWin.GetOutputSizePixel(); + awt::Rectangle aRect = xCtrWin->getPosSize(); + long nX = aRect.X; + if(nX < 0) + { + // left of the visible area + aHoriScroll.SetThumbPos(aHoriScroll.GetThumbPos() + nX); + ScrollHdl(&aHoriScroll); + } + else if(nX > aOutSize.Width()) + { + // right of the visible area + aHoriScroll.SetThumbPos(aHoriScroll.GetThumbPos() + nX - aOutSize.Width() + aFixedTexts[0]->GetSizePixel().Width()); + ScrollHdl(&aHoriScroll); + } + long nY = aRect.Y; + if(nY < 0) + { + // below the visible area + aVertScroll.SetThumbPos(aVertScroll.GetThumbPos() + nY); + ScrollHdl(&aVertScroll); + } + else if(nY > aOutSize.Height()) + { + // over the visible area + aVertScroll.SetThumbPos(aVertScroll.GetThumbPos() + nY - aOutSize.Height()+ aFixedTexts[0]->GetSizePixel().Height()); + ScrollHdl(&aVertScroll); + } + } +} +/* -----------------------------14.04.00 12:49-------------------------------- + + ---------------------------------------------------------------------------*/ +void BibGeneralPage::focusLost(const awt::FocusEvent& ) throw( uno::RuntimeException ) +{ +} +/* -----------------------------14.04.00 12:52-------------------------------- + + ---------------------------------------------------------------------------*/ +void BibGeneralPage::disposing(const lang::EventObject& Source) throw( uno::RuntimeException ) +{ +} + + + + diff --git a/extensions/source/bibliography/general.hxx b/extensions/source/bibliography/general.hxx new file mode 100644 index 000000000000..6145bea8432c --- /dev/null +++ b/extensions/source/bibliography/general.hxx @@ -0,0 +1,225 @@ +/************************************************************************* + * + * $RCSfile: general.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:45 $ + * + * 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 _BIB_GENERAL_HXX +#define _BIB_GENERAL_HXX + +#ifndef _COM_SUN_STAR_AWT_XFOCUSLISTENER_HPP_ +#include <com/sun/star/awt/XFocusListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_ +#include <com/sun/star/awt/XControlContainer.hpp> +#endif +//#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +//#include <com/sun/star/lang/XMultiServiceFactory.hpp> +//#endif +#ifndef _COM_SUN_STAR_FORM_XBOUNDCOMPONENT_HPP_ +#include <com/sun/star/form/XBoundComponent.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLER_HPP_ +#include <com/sun/star/form/XFormController.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWSETLISTENER_HPP_ +#include <com/sun/star/sdbc/XRowSetListener.hpp> +#endif + +#ifndef _STDCTRL_HXX //autogen +#include <svtools/stdctrl.hxx> +#endif + +#ifndef _LSTBOX_HXX //autogen +#include <vcl/lstbox.hxx> +#endif + +#ifndef _SV_GROUP_HXX //autogen +#include <vcl/group.hxx> +#endif + +#ifndef _SVEDIT_HXX //autogen +#include <svtools/svmedit.hxx> +#endif + +#ifndef _SV_TABPAGE_HXX //autogen +#include <vcl/tabpage.hxx> +#endif + +#ifndef _SV_COMBOBOX_HXX // +#include <vcl/combobox.hxx> +#endif +#ifndef _SV_SCRBAR_HXX +#include <vcl/scrbar.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> // helper for implementations +#endif + + +class BibDataManager; +#define TYPE_COUNT 22 +#define FIELD_COUNT 31 + +typedef cppu::WeakAggImplHelper1 +< + ::com::sun::star::awt::XFocusListener +> BibGeneralPageBaseClass; + +class BibGeneralPage: + public BibGeneralPageBaseClass, + public TabPage +{ + Window aControlParentWin; + FixedText aIdentifierFT; + FixedText aAuthTypeFT; + + FixedText aAuthorFT; + FixedText aMonthFT; + FixedText aYearFT; + + FixedText aPublisherFT; + FixedText aISBNFT; + + FixedText aAddressFT; + FixedText aAnnoteFT; + FixedText aBooktitleFT; + FixedText aChapterFT; + FixedText aEditionFT; + FixedText aEditorFT; + FixedText aHowpublishedFT; + FixedText aInstitutionFT; + FixedText aJournalFT; + FixedText aNoteFT; + FixedText aNumberFT; + FixedText aOrganizationsFT; + FixedText aPagesFT; + FixedText aSchoolFT; + FixedText aSeriesFT; + FixedText aTitleFT; + FixedText aReportTypeFT; + FixedText aVolumeFT; + FixedText aURLFT; + FixedText aCustom1FT; + FixedText aCustom2FT; + FixedText aCustom3FT; + FixedText aCustom4FT; + FixedText aCustom5FT; + + ScrollBar aHoriScroll; + ScrollBar aVertScroll; + + FixedText* aFixedTexts[FIELD_COUNT]; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> aControls[FIELD_COUNT]; + + Size aStdSize; + Point aBasePos; + + String aBibTypeArr[TYPE_COUNT]; + String sErrorPrefix; + String sTableErrorString; + + String sTypeColumnName; + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > xCtrlContnr; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > xFormCtrl; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr; + + ::com::sun::star::uno::Reference< ::com::sun::star::form::XBoundComponent > xCurrentBoundComponent; + + ::com::sun::star::uno::Reference< ::com::sun::star::form::XBoundComponent > xLBModel; + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener > xPosListener; + + + BibDataManager* pDatMan; + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > AddXControl(const String& rName, Point aPos, Size aSize, sal_uInt16 nHelpId); + + void AddControlWithError(const String& rColumnName, + const Point& rPos, const Size& rSize, String& rErrorString, + String aColumnUIName, sal_uInt16 nHelpId); + + void AdjustScrollbars(); + DECL_LINK(ScrollHdl, ScrollBar*); + +protected: + virtual void Resize(); +public: + BibGeneralPage(Window* pParent, BibDataManager* pDatMan); + virtual ~BibGeneralPage(); + + const String& GetErrorString() const {return sTableErrorString;} + + ::com::sun::star::uno::Reference< ::com::sun::star::form::XBoundComponent > GetTypeListBoxModel() {return xLBModel;} + BibDataManager* GetDataManager() {return pDatMan;} + + void CommitActiveControl(); + + virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( com::sun::star::uno::RuntimeException ); + + void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( com::sun::star::uno::RuntimeException ); + void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( com::sun::star::uno::RuntimeException ); + + void RemoveListeners(); +}; + + +#endif + + diff --git a/extensions/source/bibliography/hidother.src b/extensions/source/bibliography/hidother.src new file mode 100644 index 000000000000..3582d93b0af4 --- /dev/null +++ b/extensions/source/bibliography/hidother.src @@ -0,0 +1,95 @@ +/************************************************************************* + * + * $RCSfile: hidother.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:45 $ + * + * 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 "..\..\inc\extensio.hrc" // HID_FUNC_XXX +//#include "hidother.hrc" + +hidspecial HID_BIB_IDENTIFIER_POS { HelpID = HID_BIB_IDENTIFIER_POS ; }; +hidspecial HID_BIB_AUTHORITYTYPE_POS { HelpID = HID_BIB_AUTHORITYTYPE_POS ; }; +hidspecial HID_BIB_AUTHOR_POS { HelpID = HID_BIB_AUTHOR_POS ; }; +hidspecial HID_BIB_TITLE_POS { HelpID = HID_BIB_TITLE_POS ; }; +hidspecial HID_BIB_YEAR_POS { HelpID = HID_BIB_YEAR_POS ; }; +hidspecial HID_BIB_ISBN_POS { HelpID = HID_BIB_ISBN_POS ; }; +hidspecial HID_BIB_BOOKTITLE_POS { HelpID = HID_BIB_BOOKTITLE_POS ; }; +hidspecial HID_BIB_CHAPTER_POS { HelpID = HID_BIB_CHAPTER_POS ; }; +hidspecial HID_BIB_EDITION_POS { HelpID = HID_BIB_EDITION_POS ; }; +hidspecial HID_BIB_EDITOR_POS { HelpID = HID_BIB_EDITOR_POS ; }; +hidspecial HID_BIB_HOWPUBLISHED_POS { HelpID = HID_BIB_HOWPUBLISHED_POS ; }; +hidspecial HID_BIB_INSTITUTION_POS { HelpID = HID_BIB_INSTITUTION_POS ; }; +hidspecial HID_BIB_JOURNAL_POS { HelpID = HID_BIB_JOURNAL_POS ; }; +hidspecial HID_BIB_MONTH_POS { HelpID = HID_BIB_MONTH_POS ; }; +hidspecial HID_BIB_NOTE_POS { HelpID = HID_BIB_NOTE_POS ; }; +hidspecial HID_BIB_ANNOTE_POS { HelpID = HID_BIB_ANNOTE_POS ; }; +hidspecial HID_BIB_NUMBER_POS { HelpID = HID_BIB_NUMBER_POS ; }; +hidspecial HID_BIB_ORGANIZATIONS_POS { HelpID = HID_BIB_ORGANIZATIONS_POS ; }; +hidspecial HID_BIB_PAGES_POS { HelpID = HID_BIB_PAGES_POS ; }; +hidspecial HID_BIB_PUBLISHER_POS { HelpID = HID_BIB_PUBLISHER_POS ; }; +hidspecial HID_BIB_ADDRESS_POS { HelpID = HID_BIB_ADDRESS_POS ; }; +hidspecial HID_BIB_SCHOOL_POS { HelpID = HID_BIB_SCHOOL_POS ; }; +hidspecial HID_BIB_SERIES_POS { HelpID = HID_BIB_SERIES_POS ; }; +hidspecial HID_BIB_REPORTTYPE_POS { HelpID = HID_BIB_REPORTTYPE_POS ; }; +hidspecial HID_BIB_VOLUME_POS { HelpID = HID_BIB_VOLUME_POS ; }; +hidspecial HID_BIB_URL_POS { HelpID = HID_BIB_URL_POS ; }; +hidspecial HID_BIB_CUSTOM1_POS { HelpID = HID_BIB_CUSTOM1_POS ; }; +hidspecial HID_BIB_CUSTOM2_POS { HelpID = HID_BIB_CUSTOM2_POS ; }; +hidspecial HID_BIB_CUSTOM3_POS { HelpID = HID_BIB_CUSTOM3_POS ; }; +hidspecial HID_BIB_CUSTOM4_POS { HelpID = HID_BIB_CUSTOM4_POS ; }; +hidspecial HID_BIB_CUSTOM5_POS { HelpID = HID_BIB_CUSTOM5_POS ; }; +hidspecial HID_BIB_DB_GRIDCTRL { HelpID = HID_BIB_DB_GRIDCTRL ; }; diff --git a/extensions/source/bibliography/makefile.mk b/extensions/source/bibliography/makefile.mk new file mode 100644 index 000000000000..1781f8fa1805 --- /dev/null +++ b/extensions/source/bibliography/makefile.mk @@ -0,0 +1,225 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:45 $ +# +# 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=bib +TARGET=bib +GEN_HID=TRUE +ENABLE_EXCEPTIONS=TRUE +USE_DEFFILE=TRUE +NO_BSYMBOLIC=TRUE + +# --- Settings ----------------------------------------------------- +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +CXXFILES= bibcont.cxx \ + bibload.cxx \ + bibmod.cxx \ + general.cxx \ + framectr.cxx \ + bibview.cxx \ + bibbeam.cxx \ + toolbar.cxx \ + datman.cxx \ + registry.cxx \ + bibexch.cxx \ + fieldwin.cxx \ + viewsect.cxx + + +SLOFILES= $(SLO)$/bibcont.obj \ + $(SLO)$/bibload.obj \ + $(SLO)$/bibmod.obj \ + $(SLO)$/general.obj \ + $(SLO)$/framectr.obj \ + $(SLO)$/bibview.obj \ + $(SLO)$/bibbeam.obj \ + $(SLO)$/toolbar.obj \ + $(SLO)$/datman.obj \ + $(SLO)$/registry.obj \ + $(SLO)$/bibexch.obj \ + $(SLO)$/fieldwin.obj\ + $(SLO)$/viewsect.obj + + +SRCFILES= bib.src \ + datman.src \ + sections.src \ + menu.src \ + toolbar.src + +RESLIB1NAME=bib +RESLIB1SRSFILES= $(SRS)/bib.srs +RESLIB1DEPN= bib.src bib.hrc + +SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX) + +# $(UNOLIB) \ + +SHL1STDLIBS= \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(TOOLSLIB) \ + $(SO2LIB) \ + $(VCLLIB) \ + $(TKLIB) \ + $(SVTOOLLIB)\ + $(SVLLIB) \ + $(OSLLIB) \ + $(SALLIB) \ + $(UNOTOOLSLIB) \ + $(SOTLIB) \ + $(UCBHELPERLIB) + +#Create UNO Header files +UNOUCROUT=$(OUT)$/inc$/$(PRJNAME) +INCPRE+=$(UNOUCROUT) + +UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb + +UNOTYPES=\ + com.sun.star.awt.PosSize \ + com.sun.star.awt.XPointer \ + com.sun.star.awt.XControl \ + com.sun.star.awt.XControlContainer \ + com.sun.star.awt.XControlModel \ + com.sun.star.awt.XWindowPeer \ + com.sun.star.beans.PropertyAttribute \ + com.sun.star.beans.PropertyValue \ + com.sun.star.beans.PropertyValues \ + com.sun.star.data.XDatabaseDialogs \ + com.sun.star.data.XDatabaseFavorites \ + com.sun.star.form.XBoundComponent \ + com.sun.star.form.XLoadable \ + com.sun.star.form.XGridColumnFactory \ + com.sun.star.form.ListSourceType \ + com.sun.star.form.XForm \ + com.sun.star.form.XFormController \ + com.sun.star.frame.XComponentLoader \ + com.sun.star.frame.XDispatchProvider \ + com.sun.star.frame.XFilterDetect\ + com.sun.star.frame.FrameSearchFlag \ + com.sun.star.io.XPersistObject \ + com.sun.star.io.XDataInputStream \ + com.sun.star.io.XActiveDataSource \ + com.sun.star.io.XMarkableStream \ + com.sun.star.io.XActiveDataSink \ + com.sun.star.lang.XLocalizable \ + com.sun.star.lang.XServiceName \ + com.sun.star.registry.XSimpleRegistry \ + com.sun.star.sdb.CommandType\ + com.sun.star.sdb.XDatabaseEnvironment \ + com.sun.star.sdb.XColumn\ + com.sun.star.sdb.XSQLQueryComposerFactory\ + com.sun.star.sdbc.DataType \ + com.sun.star.sdbc.ResultSetType \ + com.sun.star.sdbc.ResultSetConcurrency \ + com.sun.star.sdbc.XConnection \ + com.sun.star.sdbc.XDataSource \ + com.sun.star.sdbc.XResultSetUpdate \ + com.sun.star.sdbcx.XTablesSupplier \ + com.sun.star.sdbcx.XColumnsSupplier \ + com.sun.star.sdbcx.XRowLocate \ + com.sun.star.sdb.XSQLQueryComposer\ + com.sun.star.sdbc.XResultSet \ + com.sun.star.sdbc.ResultSetType \ + com.sun.star.sdbc.XRowSet\ + com.sun.star.text.BibliographyDataField \ + com.sun.star.uno.XNamingService\ + com.sun.star.util.XLocalizedAliases\ + com.sun.star.util.XURLTransformer + +#END + +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1IMPLIB= i$(TARGET) +SHL1DEPN= $(SHL1LIBS) +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +ALL:\ + $(do_build) \ + $(SRS)$/hidother.hid\ + ALLTAR + +$(SRS)$/hidother.hid: hidother.src +.IF "$(GUI)" =="WNT" + @+echo + @+echo NO HIDS! + @+echo + +copy ..\..\inc\extensio.hrc . + +mhids hidother.src ..$/..$/$(INPATH)$/srs bib hidother + +del extensio.hrc +.ELSE + @echo wnt only +.ENDIF + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/extensions/source/bibliography/menu.src b/extensions/source/bibliography/menu.src new file mode 100644 index 000000000000..d6981a339ca9 --- /dev/null +++ b/extensions/source/bibliography/menu.src @@ -0,0 +1,594 @@ +/************************************************************************* + * + * $RCSfile: menu.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:45 $ + * + * 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 <svtools/solar.hrc> +#include <sfx2/sfxsids.hrc> +#ifndef _GLOBLMN_HRC +#include <svx/globlmn.hrc> +#endif +#ifndef _GLOBALACC_SRC +#include <svx/globlac.hrc> +#endif +#include <offmgr/ofaids.hrc> +#include <offmgr/sbasltid.hrc> +#include <extensio.hrc> + +#include "bib.hrc" + +#define MN_EDIT 20 +#define MN_VIEW 21 +#define MN_EXTRA 22 +#define MN_WIN 30 +#define MN_HELP 31 + +Menu RID_MAIN_MENU +{ + ItemList = + { + MenuItem + { + ITEM_FILE_PICKLIST + SubMenu = Menu + { + ItemList = + { + MenuItem + { + ITEM_FILE_NEWDOC + }; + MenuItem + { + ITEM_FILE_OPENDOC + }; + ITEM_FILE_AUTOPILOT + MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + ITEM_FILE_CLOSEDOC + }; + /* + MenuItem + { + ITEM_FILE_SAVEDOC + }; + MenuItem + { + ITEM_FILE_SAVEASDOC + }; + */ + MenuItem + { + ITEM_FILE_SAVEDOCS //!!muss fuer andere geoeffnete Tasks drinbleiben + }; + MenuItem + { + Command = ".uno:ss/sendasemail" ; + Identifier = 369; + Text = "Als E-Mail ~versenden..." ; + Text[ English ] = "Send as EMail..."; + Text [ english_us ] = "Send as ~E-mail..." ; + Text[ portuguese ] = "~Enviar como e-mail..."; + Text[ russian ] = "Îòïðàâèòü êàê ýëåêòðîííîå ïèñüìî..."; + Text[ dutch ] = "Als ~e-mail verzenden..."; + Text[ french ] = "~Envoyer par e-mail..."; + Text[ spanish ] = "Enviar como ~mensaje electrónico..."; + Text[ italian ] = "~Invia come eMail..."; + Text[ danish ] = "Send som e-mail..."; + Text[ swedish ] = "~Skicka som e-post..."; + Text[ polish ] = "Wyœlij jako e-mail..."; + Text[ portuguese_brazilian ] = "Send Even~t as EMail..."; + Text[ japanese ] = "E-mail‚Æ‚µ‚Ä‘—M(~E)..."; + Text[ chinese_simplified ] = "µ±×÷µç×ÓÓʼþ¼Ä·¢(~E)..."; + Text[ chinese_traditional ] = "·í§@¹q¤l¶l¥óµo°e(~E)..."; + Text[ arabic ] = "ÅÑÓÇá ßÈÑíÏ ÅáßÊÑæäí..."; + Text[ greek ] = "ÁðïóôïëÞ ~ùò E-mail..."; + Text[ korean ] = "ÀüÀÚ¿ìÆíÀ¸·Î º¸³»±â(~E)..."; + Text[ turkish ] = "E-posta olarak gönder..."; + Text[ language_user1 ] = " "; + }; + /* + MenuItem + { + ITEM_FILE_MAIL_SENDDOC + }; + */ + MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + ITEM_FILE_PRINTDOC + }; + MenuItem + { + ITEM_FILE_SETUPPRINTER + }; + MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + ITEM_FILE_QUITAPP + }; + }; + }; + }; + MenuItem + { + Identifier = MN_EDIT ; + HelpID = MN_EDIT ; + Text = "~Bearbeiten" ; + Text [ English ] = "~Edit" ; + Text [ norwegian ] = "~Rediger" ; + Text [ italian ] = "~Modifica" ; + Text [ portuguese_brazilian ] = "~Editar" ; + Text [ portuguese ] = "~Editar" ; + Text [ finnish ] = "~Muokkaa" ; + Text [ danish ] = "~Rediger" ; + Text [ french ] = "~Édition" ; + Text [ swedish ] = "R~edigera" ; + Text [ dutch ] = "Be~werken" ; + Text [ spanish ] = "~Editar" ; + Text [ english_us ] = "~Edit" ; + SubMenu = Menu + { + ItemList = + { +/* MenuItem + { + ITEM_EDIT_UNDO + Command = ".uno:Bib/undo" ; + }; + MenuItem + { + ITEM_EDIT_REDO + }; + MenuItem + { + ITEM_EDIT_REPEAT + }; + MenuItem + { + Separator = TRUE ; + };*/ + MenuItem + { + ITEM_EDIT_CUT + }; + MenuItem + { + ITEM_EDIT_COPY + }; + MenuItem + { + ITEM_EDIT_PASTE + }; + MenuItem + { + ITEM_EDIT_SELECTALL + }; + MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + HelpId = HID_BIB_MAPPINGDLG; + Text = "~Spaltenzuordnung..." ; + Text[ English ] = "~Column assignment..." ; + Command = ".uno:Bib/Mapping" ; + Identifier = RID_MAIN_ME_MAPPING ; + Checkable=TRUE; + Text[ english_us ] = "~Column Arrangement..."; + Text[ portuguese ] = "~Dispor colunas..."; + Text[ russian ] = "~Ðàñïîëîæåíèå êîëîíîê..."; + Text[ greek ] = "Áíôéóôïß÷éóç ~óôÞëçò..."; + Text[ dutch ] = "~Kolomindeling..."; + Text[ french ] = "~Assignation de colonnes..."; + Text[ spanish ] = "~Asignación de columnas..."; + Text[ italian ] = "A~ssegnazione colonne..."; + Text[ danish ] = "Kolonnetildeling..."; + Text[ swedish ] = "~Kolumntilldelning..."; + Text[ polish ] = "Przyporz¹dkowanie kolumn..."; + Text[ portuguese_brazilian ] = "~Column assignment..."; + Text[ japanese ] = "—ñ‚Ì•ª—Þ(~C)..."; + Text[ korean ] = "¿ ¹èÁ¤(~C)..."; + Text[ chinese_simplified ] = "±àÅÅÁÐ(~C)..."; + Text[ chinese_traditional ] = "½s±ÆÄæ(~C)..."; + Text[ arabic ] = "ÊÚííä ÇáÃÚãÏÉ..."; + Text[ turkish ] = "~Sütun düzeni..."; + Text[ language_user1 ] = " "; + }; + MenuItem + { + HelpId = HID_BIB_CHANGESOURCE; + Text = "~Datenquelle..." ; + Text[ English ] = "~Data source..." ; + Command = ".uno:Bib/sdbsource" ; + Identifier = RID_MAIN_ME_DBSOURCE; + Checkable=TRUE; + Text[ english_us ] = "~Data Source..."; + Text[ portuguese ] = "~Fonte de dados..."; + Text[ russian ] = "~Èñõîäíûå äàííûå..."; + Text[ greek ] = "ÐñïÝëåõóç ~äåäïìÝíùí..."; + Text[ dutch ] = "~Gegevensbron..."; + Text[ french ] = "~Source de données..."; + Text[ spanish ] = "~Fuente de datos..."; + Text[ italian ] = "Sorgente ~dati..."; + Text[ danish ] = "Datakilde..."; + Text[ swedish ] = "~Datakälla..."; + Text[ polish ] = "ród³o danych..."; + Text[ portuguese_brazilian ] = "~Data source..."; + Text[ japanese ] = "ÃÞ°À¿°½(~D)..."; + Text[ korean ] = "µ¥ÀÌÅÍ ¼Ò½º(~D)..."; + Text[ chinese_simplified ] = "Êý¾ÝÀ´Ô´(~D)..."; + Text[ chinese_traditional ] = "¼ÆÕu·½(~D)..."; + Text[ arabic ] = "ãÕÏÑ ÇáÈíÇäÇÊ..."; + Text[ turkish ] = "~Veri kaynaðý..."; + Text[ language_user1 ] = " "; + }; +/* MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + Text = "~Layout" ; + Text[ English ] = "~Layout" ; + Command = ".uno:Bib/Layout" ; + Identifier = RID_MAIN_ME_LAYOUT; + Checkable=TRUE; + }; + + MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + ITEM_EDIT_SEARCH_DLG + }; + MenuItem + { + ITEM_EDIT_SBA_ADDRPI + }; + MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + ITEM_EDIT_EDIT_FRAMESET + }; + */ + }; + }; + Text[ russian ] = "~Ïðàâêà"; + Text[ polish ] = "~Edytuj"; + Text[ japanese ] = "•ÒW(~E)"; + Text[ chinese_simplified ] = "±à¼(~E)"; + Text[ chinese_traditional ] = "½s¿è(~E)"; + Text[ arabic ] = "~ÊÍÑíÑ"; + Text[ greek ] = "~Åðåîåñãáóßá"; + Text[ korean ] = "ÆíÁý(~E)"; + Text[ turkish ] = "~Düzenle"; + Text[ language_user1 ] = " "; + }; + MenuItem + { + Identifier = MN_VIEW ; + HelpID = MN_VIEW ; + Text = "~Ansicht" ; + Text [ English ] = "~View" ; + Text [ norwegian ] = "~Vis" ; + Text [ italian ] = "~Visualizza" ; + Text [ portuguese_brazilian ] = "~Ver" ; + Text [ portuguese ] = "~Ver" ; + Text [ finnish ] = "~Näytä" ; + Text [ danish ] = "~Vis" ; + Text [ french ] = "~Affichage" ; + Text [ swedish ] = "Vi~sa" ; + Text [ dutch ] = "Beel~d" ; + Text [ spanish ] = "~Ver" ; + Text [ english_us ] = "~View" ; + SubMenu = Menu + { + ItemList = + { + MenuItem + { + ITEM_VIEW_EXPLORER + }; + MenuItem + { + ITEM_VIEW_BROWSER + }; + MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + Identifier = 22 ; + HelpID = 22 ; + Text = "S~ymbolleisten" ; + Text [ English ] = "Toolbars" ; + Text [ english_us ] = "~Toolbars" ; + Text [ swedish ] = "S~ymbollister" ; + Text [ danish ] = "Ikonlin~jer" ; + Text [ italian ] = "Barr~e dei simboli" ; + Text [ spanish ] = "Barras de ~símbolos" ; + Text [ french ] = "Barres d'~outils" ; + Text [ dutch ] = "We~rkbalken" ; + Text [ portuguese ] = "Barras de ~ferramentas" ; + Text [ portuguese_brazilian ] = "Symbolleisten" ; + SubMenu = Menu + { + ItemList = + { + MenuItem + { + ITEM_VIEW_TOGGLEFUNCTIONBAR + }; + MenuItem + { + ITEM_VIEW_TOGGLEOBJECTBAR + }; + MenuItem + { + ITEM_INSERT_HYPERLINK_INSERT + }; + /* + MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + Identifier = SID_CUSTOMIZETOOLBOX ; + HelpID = SID_CUSTOMIZETOOLBOX ; + Text = "~Bearbeiten..." ; + Text [ English ] = "~Customize..." ; + Text [ english_us ] = "~Customize..." ; + Text [ swedish ] = "~Redigera..." ; + Text [ danish ] = "~Rediger..." ; + Text [ italian ] = "~Modifica..." ; + Text [ spanish ] = "~Personalizar..." ; + Text [ french ] = "~Personnaliser..." ; + Text [ dutch ] = "~Bewerken..." ; + Text [ portuguese ] = "~Personalizar..." ; + Text [ portuguese_brazilian ] = "~Bearbeiten..." ; + }; + */ + }; + }; + Text[ russian ] = "Ïàíåëè ñèìâîëîâ"; + Text[ polish ] = "Paski symboli"; + Text[ japanese ] = "°ÙÊÞ°(~T)"; + Text[ chinese_simplified ] = "ͼ±êÀ¸(~T)"; + Text[ chinese_traditional ] = "¤u¨ã¦C(~T)"; + Text[ arabic ] = "ÃÔÑØÉ ÇáÑãæÒ"; + Text[ greek ] = "ÃñáììÝò ó~õìâüëùí"; + Text[ korean ] = "µµ±¸¸ðÀ½(~T)"; + Text[ turkish ] = "Araç çubuklarý"; + Text[ language_user1 ] = " "; + }; + MenuItem + { + ITEM_VIEW_TOGGLESTATUSBAR + }; +/* MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + Text = "Hierarchisch" ; + Text[ English ] = "Hierarchical" ; + Command = ".uno:Bib/hierarchical" ; + Identifier = RID_MAIN_ME_HIERARCHICAL; + Checkable=TRUE; + }; +*/ MenuItem + { + Separator = TRUE ; + }; + ITEM_VIEW_SCREENMODE + }; + }; + Text[ russian ] = "~Âèä"; + Text[ greek ] = "Ðñï~âïëÞ"; + Text[ polish ] = "~Widok"; + Text[ japanese ] = "•\\Ž¦(~V)"; + Text[ korean ] = "º¸±â(~V)"; + Text[ chinese_simplified ] = "ÊÓͼ(~V)"; + Text[ chinese_traditional ] = "À˵ø(~V)"; + Text[ arabic ] = "~ÚÑÖ"; + Text[ turkish ] = "Görünüm"; + Text[ language_user1 ] = " "; + }; + MenuItem + { + Identifier = MN_EXTRA ; + HelpID = MN_EXTRA ; + Text = "E~xtras" ; + Text [ English ] = "T~ools" ; + Text [ norwegian ] = "Verk~tøy" ; + Text [ italian ] = "~Strumenti" ; + Text [ portuguese_brazilian ] = "F~erramentas" ; + Text [ portuguese ] = "~Ferramentas" ; + Text [ finnish ] = "~Työkalut" ; + Text [ danish ] = "Fun~ktioner" ; + Text [ french ] = "~Outils" ; + Text [ swedish ] = "~Verktyg" ; + Text [ dutch ] = "E~xtra" ; + Text [ spanish ] = "~Herramientas" ; + Text [ english_us ] = "~Tools" ; + SubMenu = Menu + { + ItemList = + { +/* MenuItem + { + Text = "Neue Adresse" ; + Text [ English ] = "New Address" ; + Command = ".uno:Bib/newEntry" ; + Identifier = RID_MAIN_ME_NEWENTRY; + }; + MenuItem + { + Text = "Adresse ändern" ; + Text [ English ] = "Change Address" ; + Command = ".uno:Bib/changeEntry" ; + Identifier = RID_MAIN_ME_CHANGEENTRY; + }; + MenuItem + { + Text = "Adresse löschen" ; + Text [ English ] = "Remove Address" ; + Command = ".uno:Bib/removeEntry" ; + Identifier = RID_MAIN_ME_REMOVEENTRY; + }; + + MenuItem + { + Separator = TRUE ; + }; + +*/ MenuItem + { + Command = ".uno:Bib/standardFilter" ; + Identifier = RID_MAIN_ME_SEARCH; + Text = "~Filtern..."; + Text[ English ] = "Filter..." ; + Text[ english_us ] = "~Filter..."; + Text[ portuguese ] = "~Filtrar..."; + Text[ russian ] = "Ôèëüòð..."; + Text[ greek ] = "ÖéëôñÜñéóìá..."; + Text[ dutch ] = "~Filteren..."; + Text[ french ] = "~Filtrer..."; + Text[ spanish ] = "~Filtrar..."; + Text[ italian ] = "~Filtra..."; + Text[ danish ] = "Filtrer..."; + Text[ swedish ] = "~Filtrera..."; + Text[ polish ] = "Filtruj..."; + Text[ portuguese_brazilian ] = "Filter..."; + Text[ japanese ] = "̨ÙÀ(~F)..."; + Text[ korean ] = "ÇÊÅÍ(~F)..."; + Text[ chinese_simplified ] = "ɸѡ(~F)..."; + Text[ chinese_traditional ] = "¿z¿ï(~F)..."; + Text[ arabic ] = "ÊÕÝíÉ..."; + Text[ turkish ] = "~Filtrele..."; + Text[ language_user1 ] = " "; + }; +/* MenuItem + { + Separator = TRUE ; + }; + MenuItem + { + Command = ".uno:Bib/InsertFieldDlg" ; + Identifier = RID_MAIN_ME_FIELDDLG; + Text = "Felder ~einfügen..."; + Text[ English ] = "Insert Fields..." ; + }; +*/ MenuItem + { + Separator = TRUE ; + }; + + + MenuItem + { + ITEM_TOOLS_BASICCHOOSER + }; + + + /* + MenuItem + { + ITEM_TOOLS_CONFIG + }; + */ + ITEM_MN_OPTIONS + }; + }; + Text[ russian ] = "~Ñåðâèñ"; + Text[ greek ] = "Å~ñãáëåßá"; + Text[ polish ] = "~Narzêdzia"; + Text[ japanese ] = "°Ù(~T)"; + Text[ korean ] = "µµ±¸(~T)"; + Text[ chinese_simplified ] = "¹¤¾ß(~T)"; + Text[ chinese_traditional ] = "¤u¨ã(~T)"; + Text[ arabic ] = "Ã~ÏæÇÊ"; + Text[ turkish ] = "~Araçlar"; + Text[ language_user1 ] = " "; + }; + ITEM_WINDOW_MENU + ITEM_HELP_MENU + }; +}; + diff --git a/extensions/source/bibliography/sections.hrc b/extensions/source/bibliography/sections.hrc new file mode 100644 index 000000000000..9f695c34c786 --- /dev/null +++ b/extensions/source/bibliography/sections.hrc @@ -0,0 +1,159 @@ +/************************************************************************* + * + * $RCSfile: sections.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:45 $ + * + * 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 "bib.hrc" + +//General +/*#define FT_FIRST_MIDDLE 1 +#define ED_FIRST 2 +#define ED_MIDDLE 3 +#define FT_NAME_SUFFIX 4 +#define ED_NAME 5 +#define CB_SUFFIX 6 +#define ED_INITIALS 8 +#define FT_COMPANY 9 +#define ED_COMPANY 10 +#define FT_DEPARTMENT 11 +#define ED_DEPARTMENT 12 +#define FT_SALUTATION 13 +#define CB_SALUTATION 14 +#define FT_SHOWNNAME 15 +#define ED_SHOWNNAME 16*/ +#define FT_IDENTIFIER 1 +#define FT_AUTHTYPE 2 +#define FT_AUTHOR 3 +#define FT_YEAR 4 +#define FT_ISBN 5 + +#define FT_MONTH 6 + +#define FT_PUBLISHER 8 + +#define FT_ADDRESS 9 +#define FT_ANNOTE 10 +#define FT_BOOKTITLE 11 +#define FT_CHAPTER 12 +#define FT_EDITION 13 +#define FT_EDITOR 14 +#define FT_HOWPUBLISHED 15 +#define FT_INSTITUTION 16 +#define FT_JOURNAL 17 +#define FT_NOTE 18 +#define FT_NUMBER 19 +#define FT_ORGANIZATION 20 +#define FT_PAGE 21 +#define FT_SCHOOL 22 +#define FT_SERIES 23 +#define FT_TITLE 24 +#define FT_REPORT 25 +#define FT_VOLUME 26 +#define FT_URL 27 +#define FT_CUSTOM1 28 +#define FT_CUSTOM2 29 +#define FT_CUSTOM3 30 +#define FT_CUSTOM4 31 +#define FT_CUSTOM5 32 +#define ST_ERROR_PREFIX 33 + +//Business Address +#define FT_OFFICE 1 +#define FT_STREET 2 +#define FT_CITY 3 +#define FT_STATE 4 +#define FT_COUNTRY 5 +#define FT_ZIP 6 +#define ED_OFFICE 7 +#define ED_STREET 8 +#define ED_CITY 9 +#define ED_STATE 10 +#define ED_COUNTRY 11 +#define ED_ZIP 12 +#define ED_POBOX 13 + + +//Popup SectionControl +#define PU_INSERT 1 +#define PU_REMOVE 2 +#define PU_CHG_NAME 3 + +#define ST_TYPE_ARTICLE 40 +#define ST_TYPE_BOOK 41 +#define ST_TYPE_BOOKLET 42 +#define ST_TYPE_CONFERENCE 43 +#define ST_TYPE_INBOOK 44 +#define ST_TYPE_INCOLLECTION 45 +#define ST_TYPE_INPROCEEDINGS 46 +#define ST_TYPE_JOURNAL 47 +#define ST_TYPE_MANUAL 48 +#define ST_TYPE_MASTERSTHESIS 49 +#define ST_TYPE_MISC 50 +#define ST_TYPE_PHDTHESIS 51 +#define ST_TYPE_PROCEEDINGS 52 +#define ST_TYPE_TECHREPORT 53 +#define ST_TYPE_UNPUBLISHED 54 +#define ST_TYPE_EMAIL 55 +#define ST_TYPE_WWW 56 +#define ST_TYPE_CUSTOM1 57 +#define ST_TYPE_CUSTOM2 58 +#define ST_TYPE_CUSTOM3 59 +#define ST_TYPE_CUSTOM4 60 +#define ST_TYPE_CUSTOM5 61 + diff --git a/extensions/source/bibliography/sections.src b/extensions/source/bibliography/sections.src new file mode 100644 index 000000000000..9f78026010af --- /dev/null +++ b/extensions/source/bibliography/sections.src @@ -0,0 +1,1538 @@ +/************************************************************************* + * + * $RCSfile: sections.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:45 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ +//#pragma CHARSET_ANSI + +#include "sections.hrc" + +#define FT_POS 6 +#define FTSIZE_LEFT 65 +#define ED_POS_LEFT FT_POS+FTSIZE_LEFT+1 +#define ED_SIZE 65 +#define BTN_SIZE 12 +#define ED_POS_LEFT2 ED_POS_LEFT + ED_SIZE +1 +#define FT_POS_MIDDLE ED_POS_LEFT2 + 5 +#define FT_POS_RIGHT FT_POS_MIDDLE + FT_POS_MIDDLE - FT_POS + +TabPage RID_TP_GENERAL +{ + Size = MAP_APPFONT( 452, 195 ); + Text = "Allgemein"; + Text[English]= "General"; + + FixedText FT_IDENTIFIER + { + Pos = MAP_APPFONT( FT_POS, 6 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "~Kurzbezeichnung"; + Text[English]= "Identifier"; + Text[ english_us ] = "Short ~name"; + Text[ portuguese ] = "~Abreviatura"; + Text[ russian ] = "Ñîêðàùåíèå"; + Text[ greek ] = "Óõíôïìïãñáößá"; + Text[ dutch ] = "~Beknopte aanduiding"; + Text[ french ] = "~Abrégé"; + Text[ spanish ] = "~Abreviatura"; + Text[ italian ] = "Abbreviazione"; + Text[ danish ] = "Kort betegnelse"; + Text[ swedish ] = "~Kort beteckning"; + Text[ polish ] = "Skrót"; + Text[ portuguese_brazilian ] = "Identifier"; + Text[ japanese ] = "’˜ŽÒID(~N)"; + Text[ korean ] = "¾àĪ(~N)"; + Text[ chinese_simplified ] = "¼ò³Æ(~N)"; + Text[ chinese_traditional ] = "ÃѧO¤å(~N)"; + Text[ arabic ] = "ÇÓã ãÎÊÕÑ"; + Text[ turkish ] = "~Kýsa ad"; + Text[ language_user1 ] = " "; + }; + FixedText FT_AUTHTYPE + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 6 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "~Art"; + Text[English]= "Type"; + Text[ english_us ] = "~Type"; + Text[ portuguese ] = "~Tipo"; + Text[ russian ] = "Òèï"; + Text[ greek ] = "Ôýðïò"; + Text[ dutch ] = "~Type"; + Text[ french ] = "T~ype"; + Text[ spanish ] = "~Tipo"; + Text[ italian ] = "Tipo"; + Text[ danish ] = "Type"; + Text[ swedish ] = "Typ"; + Text[ polish ] = "Typ"; + Text[ portuguese_brazilian ] = "Type"; + Text[ japanese ] = "–{‚Ì•ª—Þ(~T)"; + Text[ korean ] = "À¯Çü(~T)"; + Text[ chinese_simplified ] = "ÀàÐÍ(~T)"; + Text[ chinese_traditional ] = "Ãþ«¬(~T)"; + Text[ arabic ] = "ÇáäæÚ"; + Text[ turkish ] = "~Tür"; + Text[ language_user1 ] = " "; + }; + FixedText FT_YEAR + { + Pos = MAP_APPFONT( FT_POS_RIGHT, 6 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "~Jahr"; + Text[English]= "Year"; + Text[ english_us ] = "~Year"; + Text[ portuguese ] = "A~no"; + Text[ russian ] = "Ãîä"; + Text[ greek ] = "¸ôïò"; + Text[ dutch ] = "~Jaar"; + Text[ french ] = "A~nnée"; + Text[ spanish ] = "~Año"; + Text[ italian ] = "Anno"; + Text[ danish ] = "År"; + Text[ swedish ] = "År"; + Text[ polish ] = "Rok"; + Text[ portuguese_brazilian ] = "Year"; + Text[ japanese ] = "’˜ì”N(~Y)"; + Text[ korean ] = "¿¬µµ(~Y)"; + Text[ chinese_simplified ] = "Äê(~Y)"; + Text[ chinese_traditional ] = "¦~"; + Text[ arabic ] = "ÓäÉ"; + Text[ turkish ] = "Yýl"; + Text[ language_user1 ] = " "; + }; + FixedText FT_AUTHOR + { + Pos = MAP_APPFONT( FT_POS, 20 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "A~utor"; + Text[English]= "Author"; + Text[ english_us ] = "~Author"; + Text[ portuguese ] = "A~utor"; + Text[ russian ] = "Àâòîð"; + Text[ greek ] = "ÓõíôÜêôçò"; + Text[ dutch ] = "~Auteur"; + Text[ french ] = "A~uteur"; + Text[ spanish ] = "A~utor"; + Text[ italian ] = "A~utore"; + Text[ danish ] = "Forfatter"; + Text[ swedish ] = "Författare"; + Text[ polish ] = "Autor"; + Text[ portuguese_brazilian ] = "Author"; + Text[ japanese ] = "’˜ŽÒ(~A)"; + Text[ korean ] = "ÀúÀÚ(~A)"; + Text[ chinese_simplified ] = "×÷Õß(~A)"; + Text[ chinese_traditional ] = "§@ªÌ(~A)"; + Text[ arabic ] = "ÇáãÄáÝ"; + Text[ turkish ] = "Yazar"; + Text[ language_user1 ] = " "; + }; + FixedText FT_TITLE + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 20 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Tite~l"; + Text[English]= "Title"; + Text[ english_us ] = "Tit~le"; + Text[ portuguese ] = "Títu~lo"; + Text[ russian ] = "Çàãîëîâîê"; + Text[ greek ] = "Ôßôëïò"; + Text[ dutch ] = "~Titel"; + Text[ french ] = "Tit~re"; + Text[ spanish ] = "Títu~lo"; + Text[ italian ] = "Tito~lo"; + Text[ danish ] = "Titel"; + Text[ swedish ] = "Titel"; + Text[ polish ] = "Tytu³"; + Text[ portuguese_brazilian ] = "Title"; + Text[ japanese ] = "‘è–¼(~L)"; + Text[ korean ] = "Á¦¸ñ(~L)"; + Text[ chinese_simplified ] = "±êÌâ(~L)"; + Text[ chinese_traditional ] = "¼ÐÃD(~L)"; + Text[ arabic ] = "ÇáÚäæÇä"; + Text[ turkish ] = "Baþlýk"; + Text[ language_user1 ] = " "; + }; + FixedText FT_PUBLISHER + { + Pos = MAP_APPFONT( FT_POS, 34 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "~Verlag"; + Text[English]= "Publisher"; + Text[ english_us ] = "~Publisher"; + Text[ portuguese ] = "~Editora"; + Text[ russian ] = "Èçäàòåëüñòâî"; + Text[ greek ] = "Åêäüôçò"; + Text[ dutch ] = "~Uitgeverij"; + Text[ french ] = "Éditi~on"; + Text[ spanish ] = "~Editorial"; + Text[ italian ] = "Casa editrice"; + Text[ danish ] = "Forlag"; + Text[ swedish ] = "Förlag"; + Text[ polish ] = "Wydawnictwo"; + Text[ portuguese_brazilian ] = "Publisher"; + Text[ japanese ] = "o”ŎЖ¼(~P)"; + Text[ korean ] = "ÃâÆÇ»ç(~P)"; + Text[ chinese_simplified ] = "³ö°æÉç(~P)"; + Text[ chinese_traditional ] = "¥Xª©ªÀ(~P)"; + Text[ arabic ] = "ÏÇÑ ÇáäÔÑ"; + Text[ turkish ] = "Yayýnevi"; + Text[ language_user1 ] = " "; + }; + FixedText FT_ADDRESS + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 34 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "A~dresse"; + Text[English]= "Address"; + Text[ english_us ] = "A~ddress"; + Text[ portuguese ] = "En~dereço"; + Text[ russian ] = "Àäðåñ"; + Text[ greek ] = "Äéåýèõíóç"; + Text[ dutch ] = "A~dres"; + Text[ french ] = "A~dresse"; + Text[ spanish ] = "~Dirección"; + Text[ italian ] = "Indirizzo"; + Text[ danish ] = "Adresse"; + Text[ swedish ] = "Adress"; + Text[ polish ] = "Adres"; + Text[ portuguese_brazilian ] = "Address"; + Text[ japanese ] = "ZŠ(~D)"; + Text[ korean ] = "ÁÖ¼Ò(~D)"; + Text[ chinese_simplified ] = "µØÖ·(~D)"; + Text[ chinese_traditional ] = "¦a§}(~D)"; + Text[ arabic ] = "ÇáÚäæÇä"; + Text[ turkish ] = "Adres"; + Text[ language_user1 ] = " "; + }; + FixedText FT_ISBN + { + Pos = MAP_APPFONT( FT_POS_RIGHT, 34 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "~ISBN"; + Text[English]= "ISBN"; + Text[ english_us ] = "~ISBN"; + Text[ portuguese ] = "~ISBN"; + Text[ russian ] = "ISBN"; + Text[ greek ] = "ISBN"; + Text[ dutch ] = "~ISBN"; + Text[ french ] = "~ISBN"; + Text[ spanish ] = "I~SBN"; + Text[ italian ] = "~ISBN"; + Text[ danish ] = "ISBN"; + Text[ swedish ] = "ISBN"; + Text[ polish ] = "ISBN"; + Text[ portuguese_brazilian ] = "ISBN"; + Text[ japanese ] = "ISBN(~I)"; + Text[ korean ] = "ISBN(~I)"; + Text[ chinese_simplified ] = "ISBN(~I)"; + Text[ chinese_traditional ] = "ISBN(~I)"; + Text[ arabic ] = "ISBN"; + Text[ turkish ] = "~ISBN"; + Text[ language_user1 ] = " "; + }; + FixedText FT_CHAPTER + { + Pos = MAP_APPFONT( FT_POS, 48 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "~Kapitel"; + Text[English]= "Chapter"; + Text[ english_us ] = "~Chapter"; + Text[ portuguese ] = "~Capítulo"; + Text[ russian ] = "Ãëàâà"; + Text[ greek ] = "ÊåöÜëáéï"; + Text[ dutch ] = "~Hoofdstuk"; + Text[ french ] = "~Chapitre"; + Text[ spanish ] = "~Capítulo"; + Text[ italian ] = "Capitolo"; + Text[ danish ] = "Kapitel"; + Text[ swedish ] = "Kapitel"; + Text[ polish ] = "Rozdzia³"; + Text[ portuguese_brazilian ] = "Chapter"; + Text[ japanese ] = "Í(~C)"; + Text[ korean ] = "Àå(~C)"; + Text[ chinese_simplified ] = "ÕÂ(~C)"; + Text[ chinese_traditional ] = "³¹(~C)"; + Text[ arabic ] = "ÇáÝÕá"; + Text[ turkish ] = "Bölüm"; + Text[ language_user1 ] = " "; + }; + FixedText FT_PAGE + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 48 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Seite~(n)"; + Text[English]= "Page(s)"; + Text[ english_us ] = "Pa~ge(s)"; + Text[ portuguese ] = "Pá~gina(s)"; + Text[ russian ] = "Ñòðàíèö(û)"; + Text[ greek ] = "Óåëßäá/-åò"; + Text[ dutch ] = "~Pagina's"; + Text[ french ] = "~Page(s)"; + Text[ spanish ] = "~Página(s)"; + Text[ italian ] = "Pagina/e"; + Text[ danish ] = "Side(r)"; + Text[ swedish ] = "Sida(-or)"; + Text[ polish ] = "Strona(y)"; + Text[ portuguese_brazilian ] = "Page(s)"; + Text[ japanese ] = "Íß°¼Þ”(~G)"; + Text[ korean ] = "ÆäÀÌÁö(~G)"; + Text[ chinese_simplified ] = "Ò³(~G)"; + Text[ chinese_traditional ] = "¶(~G)"; + Text[ arabic ] = "ÕÝÍÉ (ÕÝÍÇÊ)"; + Text[ turkish ] = "Sayfa(lar)"; + Text[ language_user1 ] = " "; + }; + FixedText FT_EDITOR + { + Pos = MAP_APPFONT( FT_POS, 69 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "~Herausgeber"; + Text[English]= "Editor"; + Text[ english_us ] = "Editor"; + Text[ portuguese ] = "Edi~tor"; + Text[ russian ] = "Ðåäàêòîð èçäàíèÿ"; + Text[ greek ] = "Åêäüô~çò"; + Text[ dutch ] = "Uit~gever"; + Text[ french ] = "Éditeu~r"; + Text[ spanish ] = "~Editor"; + Text[ italian ] = "Editore"; + Text[ danish ] = "Udgiver"; + Text[ swedish ] = "Utgivare"; + Text[ polish ] = "Wydawca"; + Text[ portuguese_brazilian ] = "Editor"; + Text[ japanese ] = "•ÒŽÒ"; + Text[ korean ] = "¹ßÇàÀÎ"; + Text[ chinese_simplified ] = "·¢ÐÐÈË"; + Text[ chinese_traditional ] = "¥Xª©¤H"; + Text[ arabic ] = "ÇáäÇÔÑ"; + Text[ turkish ] = "Yayýma hazýrlayan"; + Text[ language_user1 ] = " "; + }; + FixedText FT_EDITION + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 67 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Aus~gabe"; + Text[English]= "Edition"; + Text[ english_us ] = "Ed~ition"; + Text[ portuguese ] = "~Edição"; + Text[ russian ] = "Èçäàíèå"; + Text[ greek ] = "Åîá~ãùãÞ"; + Text[ dutch ] = "E~ditie"; + Text[ french ] = "É~dition"; + Text[ spanish ] = "~Edición"; + Text[ italian ] = "Edizione"; + Text[ danish ] = "Udgave"; + Text[ swedish ] = "Utgåva"; + Text[ polish ] = "Wydanie"; + Text[ portuguese_brazilian ] = "Edition"; + Text[ japanese ] = "”Å(~I)"; + Text[ korean ] = "ÆÇ(~I)"; + Text[ chinese_simplified ] = "°æ±¾(~I)"; + Text[ chinese_traditional ] = "ª©¥»(~I)"; + Text[ arabic ] = "ÇáØÈÚÉ"; + Text[ turkish ] = "Yayým"; + Text[ language_user1 ] = " "; + }; + FixedText FT_BOOKTITLE + { + Pos = MAP_APPFONT( FT_POS, 83 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Bu~chtitel"; + Text[English]= "Book title"; + Text[ english_us ] = "~Book title"; + Text[ portuguese ] = "~Título do livro"; + Text[ russian ] = "Íàçâàíèå êíèãè"; + Text[ greek ] = "Ôßôëïò âéâëßïõ"; + Text[ dutch ] = "Bo~ektitel"; + Text[ french ] = "~Titre du livre"; + Text[ spanish ] = "~Título del libro"; + Text[ italian ] = "Titolo libro"; + Text[ danish ] = "Bogtitel"; + Text[ swedish ] = "Boktitel"; + Text[ polish ] = "Tytu³ ksi¹¿ki"; + Text[ portuguese_brazilian ] = "Book title"; + Text[ japanese ] = "‘–¼(~B)"; + Text[ korean ] = "Ã¥ Á¦¸ñ(~B)"; + Text[ chinese_simplified ] = "Êé¼®±êÌâ(~B)"; + Text[ chinese_traditional ] = "®Ñ¦W(~B)"; + Text[ arabic ] = "ÚäæÇä ÇáßÊÇÈ"; + Text[ turkish ] = "Kitap adý"; + Text[ language_user1 ] = " "; + }; + FixedText FT_VOLUME + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 83 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Buch Nummer"; + Text[English]= "Volume"; + Text[ english_us ] = "Volume"; + Text[ portuguese ] = "Volume"; + Text[ russian ] = "Òîì"; + Text[ greek ] = "Ôüìïò"; + Text[ dutch ] = "Deel nummer"; + Text[ french ] = "Volume"; + Text[ spanish ] = "Tomo"; + Text[ italian ] = "Numero libro"; + Text[ danish ] = "Bind"; + Text[ swedish ] = "Volym"; + Text[ polish ] = "Tom"; + Text[ portuguese_brazilian ] = "Volume"; + Text[ japanese ] = "Šª"; + Text[ korean ] = "±Ç"; + Text[ chinese_simplified ] = "Êé¼®±àºÅ"; + Text[ chinese_traditional ] = "®Ñ¸¹"; + Text[ arabic ] = "ÑÞã ÇáãÌáÏ"; + Text[ turkish ] = "Kitap no."; + Text[ language_user1 ] = " "; + }; + FixedText FT_HOWPUBLISHED + { + Pos = MAP_APPFONT( FT_POS_RIGHT, 83 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Au~sgabeart"; + Text[English]= "How published"; + Text[ english_us ] = "Publication t~ype"; + Text[ portuguese ] = "Ti~po de publicação"; + Text[ russian ] = "Òèï èçäàíèÿ"; + Text[ greek ] = "Ôýðï~ò Ýêäïóçò"; + Text[ dutch ] = "Wijze van ~publiceren"; + Text[ french ] = "Mode de ~publication"; + Text[ spanish ] = "Tip~o de publicación"; + Text[ italian ] = "Tipo di edizione"; + Text[ danish ] = "Udgivelsestype"; + Text[ swedish ] = "Utgivningstyp"; + Text[ polish ] = "Rodzaj publikacji"; + Text[ portuguese_brazilian ] = "How published"; + Text[ japanese ] = "¶ÊÞ°À²Ìß(~Y)"; + Text[ korean ] = "ÃâÆÇÇüÅÂ(~Y)"; + Text[ chinese_simplified ] = "·¢Ðз½Ê½(~Y)"; + Text[ chinese_traditional ] = "ª©¥»Ãþ«¬(~Y)"; + Text[ arabic ] = "ØÑíÞÉ ÇáØÈÇÚÉ"; + Text[ turkish ] = "Yayým türü"; + Text[ language_user1 ] = " "; + }; + FixedText FT_ORGANIZATION + { + Pos = MAP_APPFONT( FT_POS, 97 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "~Organisation"; + Text[English]= "Organization"; + Text[ english_us ] = "Organi~zation"; + Text[ portuguese ] = "~Organização"; + Text[ russian ] = "Îðãàíèçàöèÿ"; + Text[ greek ] = "~Ïñãáíéóìüò"; + Text[ dutch ] = "~Organisatie"; + Text[ french ] = "Or~ganisation"; + Text[ spanish ] = "~Organización"; + Text[ italian ] = "~Organizzazione"; + Text[ danish ] = "Organisation"; + Text[ swedish ] = "Organisation"; + Text[ polish ] = "Organizacja"; + Text[ portuguese_brazilian ] = "Organization"; + Text[ japanese ] = "‘gD’c‘Ì(~Z)"; + Text[ korean ] = "Á¶Á÷(~Z)"; + Text[ chinese_simplified ] = "×éÖ¯(~Z)"; + Text[ chinese_traditional ] = "²Õ´(~Z)"; + Text[ arabic ] = "ãäÙãÉ"; + Text[ turkish ] = "Organizasyon"; + Text[ language_user1 ] = " "; + }; + FixedText FT_INSTITUTION + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 97 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "~Institution"; + Text[English]= "Institution"; + Text[ english_us ] = "Instit~ution"; + Text[ portuguese ] = "~Instituição"; + Text[ russian ] = "Ðåäàêöèÿ"; + Text[ greek ] = "ºäñõìá"; + Text[ dutch ] = "~Instelling"; + Text[ french ] = "~Institution"; + Text[ spanish ] = "I~nstitución"; + Text[ italian ] = "~Istituzione"; + Text[ danish ] = "Institution"; + Text[ swedish ] = "Institution"; + Text[ polish ] = "Instytucja"; + Text[ portuguese_brazilian ] = "Institution"; + Text[ japanese ] = "‹@ŠÖ(~U)"; + Text[ korean ] = "°ø°ø±â°ü(~U)"; + Text[ chinese_simplified ] = "»ú¹¹(~U)"; + Text[ chinese_traditional ] = "ÉóÌÛ(~U)"; + Text[ arabic ] = "ÇáåíÆÉ"; + Text[ turkish ] = "Kurum"; + Text[ language_user1 ] = " "; + }; + FixedText FT_SCHOOL + { + Pos = MAP_APPFONT( FT_POS_RIGHT, 97 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Universit~ät/Hochschule"; + Text[English]= "University"; + Text[ english_us ] = "Unive~rsity"; + Text[ portuguese ] = "~Universidade/Escola Sup."; + Text[ russian ] = "ÂÓÇ"; + Text[ greek ] = "Á.Å.É./Ô.Å.É."; + Text[ dutch ] = "~Universeit/Hogeschool"; + Text[ french ] = "~Université/École supérieure"; + Text[ spanish ] = "~Universidad"; + Text[ italian ] = "Università"; + Text[ danish ] = "Universitet/læreanstalt"; + Text[ swedish ] = "Universitet/högskola"; + Text[ polish ] = "Uniwersytet/Szko³a wy¿sza"; + Text[ portuguese_brazilian ] = "University"; + Text[ japanese ] = "‘åŠw(~R)"; + Text[ korean ] = "´ëÇб³(~R)"; + Text[ chinese_simplified ] = "´óѧ(~R)"; + Text[ chinese_traditional ] = "°ªµ¥°|®Õ(~R)"; + Text[ arabic ] = "ÇáÌÇãÚÉ"; + Text[ turkish ] = "Üniversite/yüksek okul"; + Text[ language_user1 ] = " "; + }; + FixedText FT_REPORT + { + Pos = MAP_APPFONT( FT_POS, 111); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Re~port"; + Text[English]= "Report"; + Text[ english_us ] = "Re~port"; + Text[ portuguese ] = "~Relatório"; + Text[ russian ] = "Îò÷åò"; + Text[ greek ] = "ÁíáöïñÜ"; + Text[ dutch ] = "~Reportage"; + Text[ french ] = "Rapport"; + Text[ spanish ] = "I~nforme"; + Text[ italian ] = "Relazione"; + Text[ danish ] = "Rapport"; + Text[ swedish ] = "Rapport"; + Text[ polish ] = "Raport"; + Text[ portuguese_brazilian ] = "Report"; + Text[ japanese ] = "ÚÎß°Ä(~P)"; + Text[ korean ] = "¸®Æ÷Æ®(~P)"; + Text[ chinese_simplified ] = "±¨¸æ(~P)"; + Text[ chinese_traditional ] = "³ø§i(~P)"; + Text[ arabic ] = "ÊÞÑíÑ"; + Text[ turkish ] = "Rapor"; + Text[ language_user1 ] = " "; + }; + FixedText FT_MONTH + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 111 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "~Monat"; + Text[English]= "Month"; + Text[ english_us ] = "~Month"; + Text[ portuguese ] = "~Mês"; + Text[ russian ] = "Ìåñÿö"; + Text[ greek ] = "ÌÞíáò"; + Text[ dutch ] = "~Maand"; + Text[ french ] = "~Mois"; + Text[ spanish ] = "~Mes"; + Text[ italian ] = "~Mese"; + Text[ danish ] = "Måned"; + Text[ swedish ] = "Månad"; + Text[ polish ] = "Miesi¹c"; + Text[ portuguese_brazilian ] = "Month"; + Text[ japanese ] = "ŒŽ(~M)"; + Text[ korean ] = "¿ù(~M)"; + Text[ chinese_simplified ] = "ÔÂ(~M)"; + Text[ chinese_traditional ] = "¤ë(~M)"; + Text[ arabic ] = "ÔåÑ"; + Text[ turkish ] = "Ay"; + Text[ language_user1 ] = " "; + }; + FixedText FT_JOURNAL + { + Pos = MAP_APPFONT( FT_POS, 132 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Zeitschri~ft"; + Text[English]= "Journal"; + Text[ english_us ] = "~Journal"; + Text[ portuguese ] = "~Revista"; + Text[ russian ] = "Æóðíàë"; + Text[ greek ] = "Ðåñéïäéêü"; + Text[ dutch ] = "~Tijdschrift"; + Text[ french ] = "~Journal"; + Text[ spanish ] = "~Revista"; + Text[ italian ] = "Rivista"; + Text[ danish ] = "Tidsskrift"; + Text[ swedish ] = "Tidskrift"; + Text[ polish ] = "Czasopismo"; + Text[ portuguese_brazilian ] = "Journal"; + Text[ japanese ] = "ŽGŽ(~J)"; + Text[ korean ] = "ÀâÁö(~J)"; + Text[ chinese_simplified ] = "ÔÓÖ¾(~J)"; + Text[ chinese_traditional ] = "Âø»x(~J)"; + Text[ arabic ] = "ãÌáÉ"; + Text[ turkish ] = "Dergi"; + Text[ language_user1 ] = " "; + }; + + FixedText FT_NUMBER + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 132 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Numm~er"; + Text[English]= "Number"; + Text[ english_us ] = "Numb~er"; + Text[ portuguese ] = "Núm~ero"; + Text[ russian ] = "Íîìåð"; + Text[ greek ] = "Áñéèìüò"; + Text[ dutch ] = "~Nummer"; + Text[ french ] = "Nu~méro"; + Text[ spanish ] = "~Número"; + Text[ italian ] = "Num~ero"; + Text[ danish ] = "Nummer"; + Text[ swedish ] = "Nummer"; + Text[ polish ] = "Numer"; + Text[ portuguese_brazilian ] = "Number"; + Text[ japanese ] = "”Ô†(~E)"; + Text[ korean ] = "¹øÈ£(~E)"; + Text[ chinese_simplified ] = "±àºÅ(~E)"; + Text[ chinese_traditional ] = "¸¹(~E)"; + Text[ arabic ] = "ÑÞã"; + Text[ language_user1 ] = "\"Sayý\" burada istisna (dergi için)"; + Text[ turkish ] = "Sayý"; + }; + FixedText FT_SERIES + { + Pos = MAP_APPFONT( FT_POS_RIGHT, 132 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Ser~ie"; + Text[English]= "Series"; + Text[ english_us ] = "Se~ries"; + Text[ portuguese ] = "~Série"; + Text[ russian ] = "Ñåðèÿ"; + Text[ greek ] = "ÓåéñÜ"; + Text[ dutch ] = "~Serie"; + Text[ french ] = "Sér~ie"; + Text[ spanish ] = "~Serie"; + Text[ italian ] = "Ser~ie"; + Text[ danish ] = "Serie"; + Text[ swedish ] = "Serie"; + Text[ polish ] = "Seria"; + Text[ portuguese_brazilian ] = "Series"; + Text[ japanese ] = "‘p‘(~R)"; + Text[ korean ] = "½Ã¸®Áî(~R)"; + Text[ chinese_simplified ] = "ϵÁÐ(~R)"; + Text[ chinese_traditional ] = "¨t¦C(~R)"; + Text[ arabic ] = "ÓáÓáÉ"; + Text[ turkish ] = "Dizi"; + Text[ language_user1 ] = " "; + }; + FixedText FT_ANNOTE + { + Pos = MAP_APPFONT( FT_POS, 146 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "A~nmerkung"; + Text[English]= "Annotation"; + Text[ english_us ] = "Ann~otation"; + Text[ portuguese ] = "A~notações"; + Text[ russian ] = "Ïðèìå÷àíèå"; + Text[ greek ] = "ÐáñáôÞñçóç"; + Text[ dutch ] = "~Commentaar"; + Text[ french ] = "Ann~otation"; + Text[ spanish ] = "A~notación"; + Text[ italian ] = "A~nnotazione"; + Text[ danish ] = "Anmærkning"; + Text[ swedish ] = "Anmärkning"; + Text[ polish ] = "Adnotacja"; + Text[ portuguese_brazilian ] = "Annotation"; + Text[ japanese ] = "”õl(~O)"; + Text[ korean ] = "ÁÖ¼®(~O)"; + Text[ chinese_simplified ] = "˵Ã÷(~O)"; + Text[ chinese_traditional ] = "³Æª`(~O)"; + Text[ arabic ] = "ÊÚáíÞ ÊæÖíÍí"; + Text[ turkish ] = "Açýklama"; + Text[ language_user1 ] = " "; + }; + FixedText FT_NOTE + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 146 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Noti~z"; + Text[English]= "Note"; + Text[ english_us ] = "~Note"; + Text[ portuguese ] = "~Anotação"; + Text[ russian ] = "Ïðèìå÷àíèå"; + Text[ greek ] = "Óçìåßùóç"; + Text[ dutch ] = "~Aantekening"; + Text[ french ] = "N~ote"; + Text[ spanish ] = "~Nota"; + Text[ italian ] = "Nota"; + Text[ danish ] = "Note"; + Text[ swedish ] = "Anteckning"; + Text[ polish ] = "Notatka"; + Text[ portuguese_brazilian ] = "Note"; + Text[ japanese ] = "ÒÓ(~N)"; + Text[ korean ] = "¸Þ¸ð(~N)"; + Text[ chinese_simplified ] = "±¸×¢(~N)"; + Text[ chinese_traditional ] = "µ§°O(~N)"; + Text[ arabic ] = "ãáÇÍÙÉ"; + Text[ turkish ] = "Not"; + Text[ language_user1 ] = " "; + }; + FixedText FT_URL + { + Pos = MAP_APPFONT( FT_POS_RIGHT, 146 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "URL"; + Text[English]= "URL"; + Text[ english_us ] = "URL"; + Text[ portuguese ] = "URL"; + Text[ russian ] = "URL"; + Text[ greek ] = "URL"; + Text[ dutch ] = "URL"; + Text[ french ] = "URL"; + Text[ spanish ] = "URL"; + Text[ italian ] = "URL"; + Text[ danish ] = "URL"; + Text[ swedish ] = "URL"; + Text[ polish ] = "URL"; + Text[ portuguese_brazilian ] = "URL"; + Text[ japanese ] = "URL"; + Text[ korean ] = "URL"; + Text[ chinese_simplified ] = "URL"; + Text[ chinese_traditional ] = "URL"; + Text[ arabic ] = "URL"; + Text[ turkish ] = "URL"; + Text[ language_user1 ] = " "; + }; + FixedText FT_CUSTOM1 + { + Pos = MAP_APPFONT( FT_POS, 167 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Benutzerfeld ~1"; + Text[English]= "Custom field 1"; + Text[ english_us ] = "User-defined field ~1"; + Text[ portuguese ] = "Campo personalizado ~1"; + Text[ russian ] = "Ïîëå ïîëüçîâàòåëÿ 1"; + Text[ greek ] = "Ðåäßï ÷ñÞóôç 1"; + Text[ dutch ] = "Gebruikerveld ~1"; + Text[ french ] = "Champ d'utilisateur ~1"; + Text[ spanish ] = "Campo de usuario ~1"; + Text[ italian ] = "Campo utente ~1"; + Text[ danish ] = "Brugerdefineret ~1"; + Text[ swedish ] = "Användarfält 1"; + Text[ polish ] = "Pole u¿ytkownika ~1"; + Text[ portuguese_brazilian ] = "Custom field 1"; + Text[ japanese ] = "Õ°»Þ°Ì¨°ÙÄÞ 1"; + Text[ korean ] = "»ç¿ëÀÚÇʵå1(~ 1)"; + Text[ chinese_simplified ] = "Óû§À¸ 1"; + Text[ chinese_traditional ] = "¦ÛqÄæ¦ì ~1"; + Text[ arabic ] = "ÍÞá ÇáãÓÊÎÏã 1"; + Text[ turkish ] = "Kullanýcý alaný ~1"; + Text[ language_user1 ] = " "; + }; + FixedText FT_CUSTOM2 + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 167 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Benutzerfeld ~2"; + Text[English]= "Custom field 2"; + Text[ english_us ] = "User-defined field ~2"; + Text[ portuguese ] = "Campo personalizado ~2"; + Text[ russian ] = "Ïîëå ïîëüçîâàòåëÿ 2"; + Text[ greek ] = "Ðåäßï ÷ñÞóôç 2"; + Text[ dutch ] = "Gebruikerveld ~2"; + Text[ french ] = "Champ d'utilisateur ~2"; + Text[ spanish ] = "Campo de usuario ~2"; + Text[ italian ] = "Campo utente ~2"; + Text[ danish ] = "Brugerdefineret ~2"; + Text[ swedish ] = "Användarfält 2"; + Text[ polish ] = "Pole u¿ytkownika ~2"; + Text[ portuguese_brazilian ] = "Custom field 2"; + Text[ japanese ] = "Õ°»Þ°Ì¨°ÙÄÞ 2"; + Text[ korean ] = "»ç¿ëÀÚÇʵå 2(~2)"; + Text[ chinese_simplified ] = "Óû§À¸ 2"; + Text[ chinese_traditional ] = "¦ÛqÄæ¦ì ~2"; + Text[ arabic ] = "ÍÞá ÇáãÓÊÎÏã 2"; + Text[ turkish ] = "Kullanýcý alaný ~2"; + Text[ language_user1 ] = " "; + }; + FixedText FT_CUSTOM3 + { + Pos = MAP_APPFONT( FT_POS_RIGHT, 167 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Benutzerfeld ~3"; + Text[English]= "Custom field 3"; + Text[ english_us ] = "User-defined field ~3"; + Text[ portuguese ] = "Campo personalizado ~3"; + Text[ russian ] = "Ïîëå ïîëüçîâàòåëÿ 3"; + Text[ greek ] = "Ðåäßï ÷ñÞóôç 3"; + Text[ dutch ] = "Gebruikerveld ~3"; + Text[ french ] = "Champ d'utilisateur ~3"; + Text[ spanish ] = "Campo de usuario ~3"; + Text[ italian ] = "Campo utente ~3"; + Text[ danish ] = "Brugerdefineret ~3"; + Text[ swedish ] = "Användarfält 3"; + Text[ polish ] = "Pole u¿ytkownika ~3"; + Text[ portuguese_brazilian ] = "Custom field 3"; + Text[ japanese ] = "Õ°»Þ°Ì¨°ÙÄÞ 3"; + Text[ korean ] = "»ç¿ëÀÚÇʵå 3(~3)"; + Text[ chinese_simplified ] = "Óû§À¸ 3"; + Text[ chinese_traditional ] = "¦ÛqÄæ¦ì ~3"; + Text[ arabic ] = "ÍÞá ÇáãÓÊÎÏã 3"; + Text[ turkish ] = "Kullanýcý alaný ~3"; + Text[ language_user1 ] = " "; + }; + FixedText FT_CUSTOM4 + { + Pos = MAP_APPFONT( FT_POS, 181 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Benutzerfeld ~4"; + Text[English]= "Custom field 4"; + Text[ english_us ] = "User-defined field ~4"; + Text[ portuguese ] = "Campo personalizado ~4"; + Text[ russian ] = "Ïîëå ïîëüçîâàòåëÿ 4"; + Text[ greek ] = "Ðåäßï ÷ñÞóôç 4"; + Text[ dutch ] = "Gebruikerveld ~4"; + Text[ french ] = "Champ d'utilisateur ~4"; + Text[ spanish ] = "Campo de usuario ~4"; + Text[ italian ] = "Campo utente ~4"; + Text[ danish ] = "Brugerdefineret ~4"; + Text[ swedish ] = "Användarfält 4"; + Text[ polish ] = "Pole u¿ytkownika ~4"; + Text[ portuguese_brazilian ] = "Custom field 4"; + Text[ japanese ] = "Õ°»Þ°Ì¨°ÙÄÞ 4"; + Text[ korean ] = "»ç¿ëÀÚÇʵå 4(~4)"; + Text[ chinese_simplified ] = "Óû§À¸ 4"; + Text[ chinese_traditional ] = "¦ÛqÄæ¦ì ~4"; + Text[ arabic ] = "ÍÞá ÇáãÓÊÎÏã 4"; + Text[ turkish ] = "Kullanýcý alaný ~4"; + Text[ language_user1 ] = " "; + }; + FixedText FT_CUSTOM5 + { + Pos = MAP_APPFONT( FT_POS_MIDDLE, 181 ); + Size = MAP_APPFONT( FTSIZE_LEFT, 10 ); + Text = "Benutzerfeld ~5"; + Text[English]= "Custom field 5"; + Text[ english_us ] = "User-defined field ~5"; + Text[ portuguese ] = "Campo personalizado ~5"; + Text[ russian ] = "Ïîëå ïîëüçîâàòåëÿ 5"; + Text[ greek ] = "Ðåäßï ÷ñÞóôç 5"; + Text[ dutch ] = "Gebruikerveld ~5"; + Text[ french ] = "Champ d'utilisateur ~5"; + Text[ spanish ] = "Campo de usuario ~5"; + Text[ italian ] = "Campo utente ~5"; + Text[ danish ] = "Brugerdefineret ~5"; + Text[ swedish ] = "Användarfält 5"; + Text[ polish ] = "Pole u¿ytkownika ~5"; + Text[ portuguese_brazilian ] = "Custom field 5"; + Text[ japanese ] = "Õ°»Þ°Ì¨°ÙÄÞ 5"; + Text[ korean ] = "»ç¿ëÀÚÇʵå 5(~5)"; + Text[ chinese_simplified ] = "Óû§À¸ 5"; + Text[ chinese_traditional ] = "¦ÛqÄæ¦ì ~5"; + Text[ arabic ] = "ÍÞá ÇáãÓÊÎÏã 5"; + Text[ turkish ] = "Kullanýcý alaný ~5"; + Text[ language_user1 ] = " "; + }; + String ST_ERROR_PREFIX + { + Text = "Die folgenden Spaltennamen konnten nicht zugeordnet werden:\n" ; + Text [ English ] = "The following column names could not be assigned:\n" ; + Text[ english_us ] = "The following column names could not be assigned:\n"; + Text[ portuguese ] = "Foi impossível atribuir os seguintes nomes de coluna:\n"; + Text[ russian ] = "Ñëåäóþùèå èìåíà êîëîíîê êëàññèôèöèðîâàòü íå óäàëîñü:\n"; + Text[ greek ] = "Äåí Þôáí äõíáôüí íá ãßíåé áíôéóôïß÷éóç ôïõ áêüëïõèïõ ïíüìáôïò óôÞëçò:\n"; + Text[ dutch ] = "De volgende kolomnaam kon niet worden toegewezen:\n"; + Text[ french ] = "Impossible d'assigner les noms de colonnes :\n"; + Text[ spanish ] = "No se pudieron asignar los siguientes nombres de columnas:\n"; + Text[ italian ] = "Non è stato possibile assegnare i nomi seguenti delle colonne:\n"; + Text[ danish ] = "Det var ikke muligt at tildele de følgende kolonnenavne:\n"; + Text[ swedish ] = "Följande kolumnnamn kunde inte tilldelas:\n"; + Text[ polish ] = "Nie mo¿na by³o przypisaæ nastêpuj¹cej nazwy kolumny:\n"; + Text[ portuguese_brazilian ] = "The following column names could not be assigned:\n"; + Text[ japanese ] = "ˆÈ‰º‚Ì—ñ–¼‚Í•ª—Þ‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½:\n"; + Text[ korean ] = "´ÙÀ½°ú °°Àº ´Ü¸íĪÀº ÁöÁ¤µÉ ¼ö ¾ø½À´Ï´Ù :\n"; + Text[ chinese_simplified ] = "ÎÞ·¨±àÅÅÒÔÏÂÁÐÃû³Æ£º\n"; + Text[ chinese_traditional ] = "µLªk«ü©w¤U¦CÄæ¦W¡G\n"; + Text[ arabic ] = "ÊÚÐÑ ÊÚííä ÃÓãÇÁ ÇáÃÚãÏÉ ÇáÊÇáíÉ:\n"; + Text[ turkish ] = "Þu sütun adlarý atanamadý:\n"; + }; + String ST_TYPE_ARTICLE + { + Text = "Artikel" ; + Text [ English ] = "Article" ; + Text[ english_us ] = "Article"; + Text[ portuguese ] = "Artigo"; + Text[ russian ] = "Ñòàòüÿ"; + Text[ greek ] = "¢ñèñï"; + Text[ dutch ] = "Artikel"; + Text[ french ] = "Article"; + Text[ spanish ] = "Artículo"; + Text[ italian ] = "Articolo"; + Text[ danish ] = "Artikel"; + Text[ swedish ] = "Artikel"; + Text[ polish ] = "Artyku³"; + Text[ portuguese_brazilian ] = "Article"; + Text[ japanese ] = "±°Ã¨¸Ù"; + Text[ korean ] = "Ç׸ñ"; + Text[ chinese_simplified ] = "ÎÄÕÂ"; + Text[ chinese_traditional ] = "¤å³¹"; + Text[ arabic ] = "ãÞÇáÉ"; + Text[ turkish ] = "Makale"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_BOOK + { + Text = "Buch" ; + Text [ English ] = "Book" ; + Text[ english_us ] = "Book"; + Text[ portuguese ] = "Livro"; + Text[ russian ] = "Êíèãà"; + Text[ greek ] = "Âéâëßï"; + Text[ dutch ] = "Boek"; + Text[ french ] = "Livre"; + Text[ spanish ] = "Libro"; + Text[ italian ] = "Libro"; + Text[ danish ] = "Bog"; + Text[ swedish ] = "Bok"; + Text[ polish ] = "Ksi¹¿ka"; + Text[ portuguese_brazilian ] = "Book"; + Text[ japanese ] = "–{"; + Text[ korean ] = "Ã¥"; + Text[ chinese_simplified ] = "Êé¼®"; + Text[ chinese_traditional ] = "®ÑÄy"; + Text[ arabic ] = "ßÊÇÈ"; + Text[ turkish ] = "Kitap"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_BOOKLET + { + Text = "Broschüre" ; + Text [ English ] = "Booklet" ; + Text[ english_us ] = "Brochures"; + Text[ portuguese ] = "Brochura"; + Text[ russian ] = "Áðîøþðà"; + Text[ greek ] = "Ìðñïóïýñá"; + Text[ dutch ] = "Brochure"; + Text[ french ] = "Brochure"; + Text[ spanish ] = "Folleto"; + Text[ italian ] = "Dépliant"; + Text[ danish ] = "Brochure"; + Text[ swedish ] = "Broschyr"; + Text[ polish ] = "Broszura"; + Text[ portuguese_brazilian ] = "Booklet"; + Text[ japanese ] = "ÊßÝÌÚ¯Ä"; + Text[ korean ] = "¾È³»Ã¥ÀÚ"; + Text[ chinese_simplified ] = "С²á×Ó"; + Text[ chinese_traditional ] = "¤p¤â¥U"; + Text[ arabic ] = "ßÊíÈ"; + Text[ turkish ] = "Broþür"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_CONFERENCE + { + Text = "Konferenzbericht" ; + Text [ English ] = "Conference report" ; + Text[ english_us ] = "Conference report"; + Text[ portuguese ] = "Relatório sobre conferência"; + Text[ russian ] = "Îò÷åò î êîíôåðåíöèè"; + Text[ greek ] = "ÁíáöïñÜ óýóêåøçò"; + Text[ dutch ] = "Conferentiebericht"; + Text[ french ] = "Rapport de conférence"; + Text[ spanish ] = "Informe de conferencia"; + Text[ italian ] = "Rapporto sulla conferenza"; + Text[ danish ] = "Konferencerapport"; + Text[ swedish ] = "Konferensrapport"; + Text[ polish ] = "Sprawozdanie z konferencji"; + Text[ portuguese_brazilian ] = "Conference report"; + Text[ japanese ] = "‰ï‹c•ñ"; + Text[ korean ] = "ȸÀǺ¸°í¼"; + Text[ chinese_simplified ] = "ÌÖÂۻᱨ¸æ"; + Text[ chinese_traditional ] = "·|½Í³ø§i"; + Text[ arabic ] = "ÊÞÑíÑ Úä ãÄÊãÑ"; + Text[ turkish ] = "Toplantý tutanaðý"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_INBOOK + { + Text = "Buchauszug" ; + Text [ English ] = "Book excerpt" ; + Text[ english_us ] = "Book excerpt"; + Text[ portuguese ] = "Excerto de livro"; + Text[ russian ] = "Öèòàòà èç êíèãè"; + Text[ greek ] = "Áðüóðáóìá âéâëßïõ"; + Text[ dutch ] = "Uittreksel"; + Text[ french ] = "Extrait de livre"; + Text[ spanish ] = "Extracto de libro"; + Text[ italian ] = "Brano"; + Text[ danish ] = "Boguddrag"; + Text[ swedish ] = "Bokutdrag"; + Text[ polish ] = "Wyci¹g z ksi¹¿ki"; + Text[ portuguese_brazilian ] = "Book excerpt"; + Text[ japanese ] = "–{‚Ì”²ˆ"; + Text[ korean ] = "Ã¥ ¹ßÃé"; + Text[ chinese_simplified ] = "Ê鼮ժ¼ÎÄ"; + Text[ chinese_traditional ] = "®ÑÄy¤å³¹ºKn"; + Text[ arabic ] = "ãÞÊÈÓÇÊ ãä ßÊÇÈ"; + Text[ turkish ] = "Kitap özeti"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_INCOLLECTION + { + Text = "Buchauszug mit Titel" ; + Text [ English ] = "Book excerpt with title" ; + Text[ english_us ] = "Book excerpt with title"; + Text[ portuguese ] = "Excerto de livro com título"; + Text[ russian ] = "Âûäåðæêà èç êíèãè ñ çàãîëîâêîì"; + Text[ greek ] = "Áðüóðáóìá âéâëßïõ ìå ôßôëï"; + Text[ dutch ] = "Uittreksel met titel"; + Text[ french ] = "Extrait de livre avec titre"; + Text[ spanish ] = "Extracto de libro con título"; + Text[ italian ] = "Brano con titolo"; + Text[ danish ] = "Boguddrag med titel"; + Text[ swedish ] = "Bokutdrag med titel"; + Text[ polish ] = "Wyci¹g z ksi¹¿ki z tytu³em"; + Text[ portuguese_brazilian ] = "Book excerpt with title"; + Text[ japanese ] = "–{‚Ì”²ˆi‘–¼•t‚«j"; + Text[ korean ] = "Á¦¸ñÀÌ Àִ å ¹ßÃé"; + Text[ chinese_simplified ] = "×¢Ã÷±êÌâµÄÊ鼮ժ¼ÎÄ"; + Text[ chinese_traditional ] = "§t¦³¼ÐÃDªº®ÑÄy¤å³¹ºKn"; + Text[ arabic ] = "ãÞÊÈÓÇÊ ãä ßÊÇÈ ÐÇÊ ÚäæÇä"; + Text[ turkish ] = "Baþlýklý kitap özeti"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_INPROCEEDINGS + { + Text = "Tagungsbericht" ; + Text [ English ] = "Conference proceedings"; + Text[ english_us ] = "Conference proceedings"; + Text[ portuguese ] = "Relatório de congresso"; + Text[ russian ] = "Îò÷åò î çàñåäàíèè"; + Text[ greek ] = "Ðñùôüêïëëï óõíåäñßáóçò"; + Text[ dutch ] = "Conferentiebericht"; + Text[ french ] = "Rapport de congrès"; + Text[ spanish ] = "Informe de congreso"; + Text[ italian ] = "Rapporto sulla conferenza"; + Text[ danish ] = "Kongresberetning"; + Text[ swedish ] = "Konferensrapport"; + Text[ polish ] = "Sprawozdanie z obrady"; + Text[ portuguese_brazilian ] = "Conference proceedings"; + Text[ japanese ] = "‰ï•ñ"; + Text[ korean ] = "ȸÀÇ·Ï"; + Text[ chinese_simplified ] = "»áÒ鱨¸æ"; + Text[ chinese_traditional ] = "·|ij³ø§i"; + Text[ arabic ] = "ÈÑæÊæßæá ÇÌÊãÇÚ"; + Text[ turkish ] = "Konferans raporu"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_JOURNAL + { + Text = "Zeitschrift" ; + Text [ English ] = "Journal" ; + Text[ english_us ] = "Journal"; + Text[ portuguese ] = "Revista"; + Text[ russian ] = "Æóðíàë"; + Text[ greek ] = "Ðåñéïäéêü"; + Text[ dutch ] = "Tijdschrift"; + Text[ french ] = "Revue"; + Text[ spanish ] = "Revista"; + Text[ italian ] = "Rivista"; + Text[ danish ] = "Tidsskrift"; + Text[ swedish ] = "Tidskrift"; + Text[ polish ] = "Czasopismo"; + Text[ portuguese_brazilian ] = "Journal"; + Text[ japanese ] = "ŽGŽ"; + Text[ korean ] = "ÀâÁö"; + Text[ chinese_simplified ] = "ÔÓÖ¾"; + Text[ chinese_traditional ] = "Âø»x"; + Text[ arabic ] = "ãÌáÉ"; + Text[ turkish ] = "Dergi"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_MANUAL + { + Text = "Techn. Dokumentation" ; + Text [ English ] = "Manual" ; + Text[ english_us ] = "Manual"; + Text[ portuguese ] = "Documentação técnica"; + Text[ russian ] = "Òåõíè÷åñêàÿ äîêóìåíòàöèÿ"; + Text[ greek ] = "Eã÷åéñßäéï"; + Text[ dutch ] = "Techn. documentatie"; + Text[ french ] = "Documentation technique"; + Text[ spanish ] = "Documentación técnica"; + Text[ italian ] = "Documentazione tec."; + Text[ danish ] = "Teknisk dokumentation"; + Text[ swedish ] = "Manual"; + Text[ polish ] = "Dokumentacja techn."; + Text[ portuguese_brazilian ] = "Manual"; + Text[ japanese ] = "ÏƱÙ"; + Text[ korean ] = "¸Å´º¾ó"; + Text[ chinese_simplified ] = "¼¼ÊõÎÄÏ×"; + Text[ chinese_traditional ] = "§Þ³N»¡©ú®Ñ"; + Text[ arabic ] = "Ïáíá ÇÓÊÎÏÇã"; + Text[ turkish ] = "Teknik dokümantasyon"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_MASTERSTHESIS + { + Text = "Diplomarbeit" ; + Text [ English ] = "Thesis" ; + Text[ english_us ] = "Thesis"; + Text[ portuguese ] = "Tese"; + Text[ russian ] = "Äèïëîìíàÿ ðàáîòà"; + Text[ greek ] = "ÄéðëùìáôéêÞ åñãáóßá"; + Text[ dutch ] = "Scriptie"; + Text[ french ] = "Mémoire"; + Text[ spanish ] = "Trabajo de diplomatura"; + Text[ italian ] = "Tesi di laurea"; + Text[ danish ] = "Eksamensopgave"; + Text[ swedish ] = "Examensarbete"; + Text[ polish ] = "Praca dyplomowa"; + Text[ portuguese_brazilian ] = "Thesis"; + Text[ japanese ] = "‘²‹Æ˜_•¶"; + Text[ korean ] = "´ëÇÐÁ¹¾÷³í¹®"; + Text[ chinese_simplified ] = "´óѧ±ÏÒµÂÛÎÄ"; + Text[ chinese_traditional ] = "²¦·~½×¤å"; + Text[ arabic ] = "ÑÓÇáÉ ãÇÌÓÊíÑ"; + Text[ turkish ] = "Tez"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_MISC + { + Text = "Verschiedenes" ; + Text [ ENGLISH ] = "Miscellaneous" ; + Text[ english_us ] = "Miscellaneous"; + Text[ portuguese ] = "Miscelânea"; + Text[ russian ] = "Ïðî÷åå"; + Text[ greek ] = "ÄéÜöïñá"; + Text[ dutch ] = "Diverse"; + Text[ french ] = "Divers"; + Text[ spanish ] = "Diversos"; + Text[ italian ] = "Varie"; + Text[ danish ] = "Forskelligt"; + Text[ swedish ] = "Diverse"; + Text[ polish ] = "Ró¿ne"; + Text[ portuguese_brazilian ] = "Miscellaneous"; + Text[ japanese ] = "”õl"; + Text[ korean ] = "¿©·¯ °¡Áö"; + Text[ chinese_simplified ] = "ÆäËü"; + Text[ chinese_traditional ] = "Âø¶µ"; + Text[ arabic ] = "ãäæÚÇÊ"; + Text[ turkish ] = "Diðer"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_PHDTHESIS + { + Text = "Dissertation" ; + Text [ ENGLISH ] = "Dissertation"; + Text[ english_us ] = "Dissertation"; + Text[ portuguese ] = "Dissertação"; + Text[ russian ] = "Äèññåðòàöèÿ"; + Text[ greek ] = "ÄéáôñéâÞ"; + Text[ dutch ] = "Dissertatie"; + Text[ french ] = "Thèse de doctorat"; + Text[ spanish ] = "Tesis doctoral"; + Text[ italian ] = "Dottorato di ricerca"; + Text[ danish ] = "Doktorafhandling"; + Text[ swedish ] = "Avhandling"; + Text[ polish ] = "Praca doktorska"; + Text[ portuguese_brazilian ] = "Dissertation"; + Text[ japanese ] = "”ŽŽm˜_•¶"; + Text[ korean ] = "¹Ú»çÇÐÀ§³í¹®"; + Text[ chinese_simplified ] = "²©Ê¿ÂÛÎÄ"; + Text[ chinese_traditional ] = "³Õ¤h½×¤å"; + Text[ arabic ] = "ÑÓÇáÉ ÏßÊæÑÇå"; + Text[ turkish ] = "Disertasyon"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_PROCEEDINGS + { + Text = "Tagungsbericht" ; + Text [ English ] = "Conference proceedings"; + Text[ english_us ] = "Conference proceedings"; + Text[ portuguese ] = "Relatório de congresso"; + Text[ russian ] = "Îò÷åò î çàñåäàíèè"; + Text[ greek ] = "Ðñùôüêïëëï óõíåäñßáóçò"; + Text[ dutch ] = "Conferentiebericht"; + Text[ french ] = "Rapport de congrès"; + Text[ spanish ] = "Informe de congreso"; + Text[ italian ] = "Rapporto sulla conferenza"; + Text[ danish ] = "Kongresberetning"; + Text[ swedish ] = "Konferensrapport"; + Text[ polish ] = "Sprawozdanie z obrady"; + Text[ portuguese_brazilian ] = "Conference proceedings"; + Text[ japanese ] = "‰ï•ñ"; + Text[ korean ] = "ȸÀÇ·Ï"; + Text[ chinese_simplified ] = "»áÒ鱨¸æ"; + Text[ chinese_traditional ] = "·|ij³ø§i"; + Text[ arabic ] = "ÈÑæÊæßæá ÇÌÊãÇÚ"; + Text[ turkish ] = "Konferans raporu"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_TECHREPORT + { + Text = "Forschungsbericht" ; + Text [ English ] = "Research report"; + Text[ english_us ] = "Research report"; + Text[ portuguese ] = "Relatório de investigação"; + Text[ russian ] = "Îò÷åò î íàó÷íîì èññëåäîâàíèè"; + Text[ greek ] = "ÁíáöïñÜ Ýñåõíáò"; + Text[ dutch ] = "Onderzoeksbericht"; + Text[ french ] = "Rapport de recherche"; + Text[ spanish ] = "Informe de investigación"; + Text[ italian ] = "Rapporto di ricerca"; + Text[ danish ] = "Forskningsrapport"; + Text[ swedish ] = "Forskningsrapport"; + Text[ polish ] = "Sprawozdanie z badania naukow."; + Text[ portuguese_brazilian ] = "Research report"; + Text[ japanese ] = "Œ¤‹†•ñ"; + Text[ korean ] = "¿¬±¸º¸°í¼"; + Text[ chinese_simplified ] = "¿ÆÑб¨¸æ"; + Text[ chinese_traditional ] = "¬ã¨s³ø§i"; + Text[ arabic ] = "ÊÞÑíÑ Úä ÚãáíÉ ÇáÈÍË"; + Text[ turkish ] = "Araþtýrma raporu"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_UNPUBLISHED + { + Text = "Unveröffentlicht" ; + Text [ ENGLISH ] = "Unpublished" ; + Text[ english_us ] = "Unpublished"; + Text[ portuguese ] = "Inédito"; + Text[ russian ] = "Íå îïóáëèêîâàíî"; + Text[ greek ] = "Áäçìïóßåõôï"; + Text[ dutch ] = "Niet gepubliceerd"; + Text[ french ] = "Non publié"; + Text[ spanish ] = "Inédito"; + Text[ italian ] = "Non pubblicato"; + Text[ danish ] = "Ikke offentliggjort"; + Text[ swedish ] = "Opublicerad"; + Text[ polish ] = "Nieopublikowane"; + Text[ portuguese_brazilian ] = "Unpublished"; + Text[ japanese ] = "–¢”•\\"; + Text[ korean ] = "ºñ°ø°³"; + Text[ chinese_simplified ] = "ÉÐδ·¢±íµÄ"; + Text[ chinese_traditional ] = "©|¥¼µoªí"; + Text[ arabic ] = "áã íõäÔÑ ÈÚÏ"; + Text[ turkish ] = "Yayýmlanmamýþ"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_EMAIL + { + Text = "e-Mail" ; + Text [ English ] = "e-mail" ; + Text[ english_us ] = "e-mail"; + Text[ portuguese ] = "e-mail"; + Text[ russian ] = "e-mail"; + Text[ greek ] = "e-mail"; + Text[ dutch ] = "e-mail"; + Text[ french ] = "E-mail"; + Text[ spanish ] = "Mensaje electrónico"; + Text[ italian ] = "eMail"; + Text[ danish ] = "E-mail"; + Text[ swedish ] = "e-post"; + Text[ polish ] = "e-mail"; + Text[ portuguese_brazilian ] = "e-mail"; + Text[ japanese ] = "E-mail"; + Text[ korean ] = "ÀüÀÚ¿ìÆí"; + Text[ chinese_simplified ] = "µç×ÓÓʼþ"; + Text[ chinese_traditional ] = "¹q¤l¶l¥ó"; + Text[ arabic ] = "ÈÑíÏ ÅáßÊÑæäí"; + Text[ turkish ] = "e-posta"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_WWW + { + Text = "WWW-Dokument" ; + Text [ ENGLISH ] = "WWW document" ; + Text[ english_us ] = "WWW document"; + Text[ portuguese ] = "Documento WWW"; + Text[ russian ] = "Äîêóìåíò WWW"; + Text[ greek ] = "¸ããñáöï WWW"; + Text[ dutch ] = "WWW document"; + Text[ french ] = "Document WWW"; + Text[ spanish ] = "Documento WWW"; + Text[ italian ] = "Documento Web"; + Text[ danish ] = "WWW-dokument"; + Text[ swedish ] = "WWW-dokument"; + Text[ polish ] = "Dokument WWW"; + Text[ portuguese_brazilian ] = "WWW document"; + Text[ japanese ] = "WWW ÄÞ·ÒÝÄ"; + Text[ korean ] = "WWW ¹®¼"; + Text[ chinese_simplified ] = "ÍòάÍøÎĵµ"; + Text[ chinese_traditional ] = "WWW ¤å¥ó"; + Text[ arabic ] = "ãÓÊäÏ æíÈ"; + Text[ turkish ] = "WWW belgesi"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_CUSTOM1 + { + Text = "Benutzertyp1" ; + Text [ English ] = "User-defined1"; + Text[ english_us ] = "User-defined1"; + Text[ portuguese ] = "Tipo personalizado1"; + Text[ russian ] = "Òèï ïîëüçîâàòåëÿ1"; + Text[ greek ] = "Ôýðïò ÷ñÞóôç1"; + Text[ dutch ] = "Gebruikerstype1"; + Text[ french ] = "Utilisateur1"; + Text[ spanish ] = "Definido por usuario 1"; + Text[ italian ] = "Utente1"; + Text[ danish ] = "Brugerdefineret1"; + Text[ swedish ] = "Användartyp1"; + Text[ polish ] = "Typ u¿ytkownika1"; + Text[ portuguese_brazilian ] = "User-defined1"; + Text[ japanese ] = "Õ°»Þ°À²Ìß 1"; + Text[ korean ] = "»ç¿ëÀÚÀ¯Çü1"; + Text[ chinese_simplified ] = "Óû§ÀàÐÍ1"; + Text[ chinese_traditional ] = "¦ÛqÃþ«¬ 1"; + Text[ arabic ] = "ãõÚÑøóÝ ãä ÞÈá ÇáãÓÊÎÏã1"; + Text[ turkish ] = "Kullanýcý tanýmlý1"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_CUSTOM2 + { + Text = "Benutzertyp2" ; + Text [ English ] = "User-defined2"; + Text[ english_us ] = "User-defined2"; + Text[ portuguese ] = "Tipo personalizado2"; + Text[ russian ] = "Òèï ïîëüçîâàòåëÿ2"; + Text[ greek ] = "Ôýðïò ÷ñÞóôç2"; + Text[ dutch ] = "Gebruikerstype2"; + Text[ french ] = "Utilisateur2"; + Text[ spanish ] = "Definido por usuario 2"; + Text[ italian ] = "Utente2"; + Text[ danish ] = "Brugerdefineret2"; + Text[ swedish ] = "Användartyp2"; + Text[ polish ] = "Typ u¿ytkownika2"; + Text[ portuguese_brazilian ] = "User-defined2"; + Text[ japanese ] = "¶½Àϲ½Þ2"; + Text[ korean ] = "»ç¿ëÀÚÀ¯Çü2"; + Text[ chinese_simplified ] = "Óû§ÀàÐÍ2"; + Text[ chinese_traditional ] = "¦ÛqÃþ«¬ 2"; + Text[ arabic ] = "ãõÚÑøóÝ ãä ÞÈá ÇáãÓÊÎÏã2"; + Text[ turkish ] = "Kullanýcý tanýmlý2"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_CUSTOM3 + { + Text = "Benutzertyp3" ; + Text [ English ] = "User-defined3"; + Text[ english_us ] = "User-defined3"; + Text[ portuguese ] = "Tipo personalizado3"; + Text[ russian ] = "Òèï ïîëüçîâàòåëÿ3"; + Text[ greek ] = "Ôýðïò ÷ñÞóôç3"; + Text[ dutch ] = "Gebruikerstype3"; + Text[ french ] = "Utilisateur3"; + Text[ spanish ] = "Definido por usuario 3"; + Text[ italian ] = "Utente3"; + Text[ danish ] = "Brugerdefineret3"; + Text[ swedish ] = "Användartyp3"; + Text[ polish ] = "Typ u¿ytkownika3"; + Text[ portuguese_brazilian ] = "User-defined3"; + Text[ japanese ] = "¶½Àϲ½Þ3"; + Text[ korean ] = "»ç¿ëÀÚÀ¯Çü3"; + Text[ chinese_simplified ] = "Óû§ÀàÐÍ 3"; + Text[ chinese_traditional ] = "¦ÛqÃþ«¬ 3"; + Text[ arabic ] = "ãõÚÑøóÝ ãä ÞÈá ÇáãÓÊÎÏã3"; + Text[ turkish ] = "Kullanýcý tanýmlý3"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_CUSTOM4 + { + Text = "Benutzertyp4" ; + Text [ English ] = "User-defined4"; + Text[ english_us ] = "User-defined4"; + Text[ portuguese ] = "Tipo personalizado4"; + Text[ russian ] = "Òèï ïîëüçîâàòåëÿ4"; + Text[ greek ] = "Ôýðïò ÷ñÞóôç4"; + Text[ dutch ] = "Gebruikerstype4"; + Text[ french ] = "Utilisateur4"; + Text[ spanish ] = "Definido por usuario 4"; + Text[ italian ] = "Utente4"; + Text[ danish ] = "Brugerdefineret4"; + Text[ swedish ] = "Användartyp4"; + Text[ polish ] = "Typ u¿ytkownika4"; + Text[ portuguese_brazilian ] = "User-defined4"; + Text[ japanese ] = "¶½Àϲ½Þ4"; + Text[ korean ] = "»ç¿ëÀÚÀ¯Çü4"; + Text[ chinese_simplified ] = "Óû§ÀàÐÍ 4"; + Text[ chinese_traditional ] = "¦ÛqÃþ«¬ 4"; + Text[ arabic ] = "ãõÚÑøóÝ ãä ÞÈá ÇáãÓÊÎÏã4"; + Text[ turkish ] = "Kullanýcý tanýmlý4"; + Text[ language_user1 ] = " "; + }; + String ST_TYPE_CUSTOM5 + { + Text = "Benutzertyp5" ; + Text [ English ] = "User-defined5"; + Text[ english_us ] = "User-defined5"; + Text[ portuguese ] = "Tipo personalizado5"; + Text[ russian ] = "Òèï ïîëüçîâàòåëÿ5"; + Text[ greek ] = "Ôýðïò ÷ñÞóôç5"; + Text[ dutch ] = "Gebruikerstype5"; + Text[ french ] = "Utilisateur5"; + Text[ spanish ] = "Definido por usuario 5"; + Text[ italian ] = "Utente5"; + Text[ danish ] = "Brugerdefineret5"; + Text[ swedish ] = "Användartyp5"; + Text[ polish ] = "Typ u¿ytkownika5"; + Text[ portuguese_brazilian ] = "User-defined5"; + Text[ japanese ] = "¶½Àϲ½Þ5"; + Text[ korean ] = "»ç¿ëÀÚÀ¯Çü5"; + Text[ chinese_simplified ] = "Óû§ÀàÐÍ 5"; + Text[ chinese_traditional ] = "¦ÛqÃþ«¬ 5"; + Text[ arabic ] = "ãõÚÑøóÝ ãä ÞÈá ÇáãÓÊÎÏã5"; + Text[ turkish ] = "Kullanýcý tanýmlý5"; + Text[ language_user1 ] = " "; + }; + Text[ english_us ] = "General"; + Text[ portuguese ] = "Geral"; + Text[ russian ] = "Îáùåå"; + Text[ greek ] = "ÃåíéêÜ"; + Text[ dutch ] = "Algemeen"; + Text[ french ] = "Général"; + Text[ spanish ] = "General"; + Text[ italian ] = "Generale"; + Text[ danish ] = "Generel"; + Text[ swedish ] = "Allmän"; + Text[ polish ] = "Ogólne"; + Text[ portuguese_brazilian ] = "General"; + Text[ japanese ] = "‘S”Ê"; + Text[ korean ] = "ÀϹÝ"; + Text[ chinese_simplified ] = "³£¹æ"; + Text[ chinese_traditional ] = "¤@¯ë"; + Text[ arabic ] = "ÚÇã"; + Text[ turkish ] = "Genel"; + Text[ language_user1 ] = " "; +}; +Menu RID_POPUP_ME_VIEW +{ + ItemList = + { + MenuItem + { + Text = "Abschnitt einfügen..." ; + Text [ English ] = "Insert Section..." ; + Identifier = PU_INSERT; + Text[ english_us ] = "Insert Section..."; + Text[ portuguese ] = "Inserir secção..."; + Text[ russian ] = "Âñòàâèòü ðàçäåë..."; + Text[ greek ] = "ÐñïóèÞêç ôìÞìáôïò..."; + Text[ dutch ] = "Sectie invoegen..."; + Text[ french ] = "Insérer une section..."; + Text[ spanish ] = "Insertar sección..."; + Text[ italian ] = "Inserisci sezione..."; + Text[ danish ] = "Indsæt sektion..."; + Text[ swedish ] = "Infoga avsnitt..."; + Text[ polish ] = "Wstaw sekcjê..."; + Text[ portuguese_brazilian ] = "Insert Section..."; + Text[ japanese ] = "€–Ú‚Ì‘}“ü..."; + Text[ korean ] = "¼½¼Ç »ðÀÔ..."; + Text[ chinese_simplified ] = "²åÈë¶ÎÂä..."; + Text[ chinese_traditional ] = "´¡¤J¬q¸¨..."; + Text[ arabic ] = "ÅÏÑÇÌ äØÇÞ..."; + Text[ turkish ] = "Bölüm ekle..."; + Text[ language_user1 ] = " "; + }; + MenuItem + { + Text = "Abschnitt löschen..." ; + Text [ English ] = "Remove Section..." ; + Identifier = PU_REMOVE; + Text[ english_us ] = "Delete Section..."; + Text[ portuguese ] = "Eliminar secção..."; + Text[ russian ] = "Óáðàòü ðàçäåë..."; + Text[ greek ] = "ÄéáãñáöÞ ôìÞìáôïò..."; + Text[ dutch ] = "Sectie wissen..."; + Text[ french ] = "Supprimer une section..."; + Text[ spanish ] = "Eliminar sección..."; + Text[ italian ] = "Elimina sezione..."; + Text[ danish ] = "Slet sektion..."; + Text[ swedish ] = "Radera avsnitt..."; + Text[ polish ] = "Usuñ sekcjê..."; + Text[ portuguese_brazilian ] = "Remove Section..."; + Text[ japanese ] = "€–Ú‚Ìíœ..."; + Text[ korean ] = "¼½¼Ç »èÁ¦..."; + Text[ chinese_simplified ] = "ɾ³ý¶ÎÂä..."; + Text[ chinese_traditional ] = "§R°£¬q¸¨..."; + Text[ arabic ] = "ÍÐÝ äØÇÞ..."; + Text[ turkish ] = "Bölümü sil..."; + Text[ language_user1 ] = " "; + }; + MenuItem + { + Text = "Namen ändern..." ; + Text [ English ] = "Remove Address..." ; + Identifier = PU_CHG_NAME; + Text[ english_us ] = "Modify Name..."; + Text[ portuguese ] = "Modificar nome..."; + Text[ russian ] = "Èçìåíèòü èìåíà..."; + Text[ greek ] = "ÁëëáãÞ ïíüìáôïò..."; + Text[ dutch ] = "Adres wissen..."; + Text[ french ] = "Corriger un nom..."; + Text[ spanish ] = "Modificar nombre..."; + Text[ italian ] = "Cambia indirizzo..."; + Text[ danish ] = "Modificer navn..."; + Text[ swedish ] = "Ändra namn..."; + Text[ polish ] = "Modyfikuj nazwê..."; + Text[ portuguese_brazilian ] = "Remove Address..."; + Text[ japanese ] = "–¼‘O‚Ì•ÏX..."; + Text[ korean ] = "ÁÖ¼Ò »èÁ¦..."; + Text[ chinese_simplified ] = "¸ü¸ÄÃû³Æ..."; + Text[ chinese_traditional ] = "Åܧó¦WºÙ..."; + Text[ arabic ] = "ÊÚÏíá ÇÓã..."; + Text[ turkish ] = "Adý deðiþtir..."; + Text[ language_user1 ] = " "; + }; + }; +}; diff --git a/extensions/source/bibliography/toolbar.cxx b/extensions/source/bibliography/toolbar.cxx new file mode 100644 index 000000000000..5f026ea18ab5 --- /dev/null +++ b/extensions/source/bibliography/toolbar.cxx @@ -0,0 +1,566 @@ +/************************************************************************* + * + * $RCSfile: toolbar.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:45 $ + * + * 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 <osl/mutex.hxx> +#include <tools/urlobj.hxx> +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ +#include <unotools/processfactory.hxx> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ +#include <com/sun/star/frame/XDispatch.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ +#include <com/sun/star/frame/XDispatchProvider.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ +#include <com/sun/star/util/XURLTransformer.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#endif + + +#include <svtools/iniprop.hxx> +#include <svtools/iniman.hxx> + +#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT +#include <tools/debug.hxx> +#endif + +#include "bibbeam.hxx" +#include "toolbar.hrc" +#include "bibresid.hxx" + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +#define C2U(cChar) OUString::createFromAscii(cChar) + + +// Konstanten ------------------------------------------------------------- + + +BibToolBarListener::BibToolBarListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): + pToolBar(pTB), + nIndex(nId), + aCommand(aStr) +{ +} + +BibToolBarListener::~BibToolBarListener() +{ +} + +void BibToolBarListener::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvt)throw( ::com::sun::star::uno::RuntimeException ) +{ + if(rEvt.FeatureURL.Complete == aCommand) + { + pToolBar->EnableItem(nIndex,rEvt.IsEnabled); + + ::com::sun::star::uno::Any aState=rEvt.State; + if(aState.getValueType()==::getBooleanCppuType()) + { + sal_Bool bChecked= *(sal_Bool*)aState.getValue(); + pToolBar->CheckItem(nIndex, bChecked); + } + + /* + rtl::OUString FeatureDescriptor; + sal_Bool Requery; + ::com::sun::star::uno::Any State;*/ + } +}; + +sal_uInt16 BibToolBarListener::GetIndex() +{ + return nIndex; +} +void BibToolBarListener::SetIndex(sal_uInt16 nId) +{ + nIndex=nId; +} + +rtl::OUString BibToolBarListener::GetCommand() +{ + return aCommand; +} +void BibToolBarListener::SetCommand(const rtl::OUString& aStr) +{ + aCommand=aStr; +} + +BibTBListBoxListener::BibTBListBoxListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): + BibToolBarListener(pTB,aStr,nId) +{ +} + +BibTBListBoxListener::~BibTBListBoxListener() +{ +} + +void BibTBListBoxListener::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvt)throw( ::com::sun::star::uno::RuntimeException ) +{ + if(rEvt.FeatureURL.Complete == GetCommand()) + { + pToolBar->EnableSourceList(rEvt.IsEnabled); + + Any aState = rEvt.State; + if(aState.getValueType() == ::getCppuType((Sequence<rtl::OUString>*)0)) + { + pToolBar->UpdateSourceList(sal_False); + pToolBar->ClearSourceList(); + + Sequence<rtl::OUString>* pStringSeq = (Sequence<rtl::OUString>*)aState.getValue(); + const rtl::OUString* pStringArray = (const rtl::OUString*)pStringSeq->getConstArray(); + + sal_uInt32 nCount = pStringSeq->getLength(); + XubString aEntry; + for( sal_uInt32 i=0; i<nCount; i++ ) + { + aEntry = String(pStringArray[i]); + pToolBar->InsertSourceEntry(aEntry); + } + pToolBar->UpdateSourceList(sal_True); + } + + XubString aStr = String(rEvt.FeatureDescriptor); + pToolBar->SelectSourceEntry(aStr); + } +}; + +BibTBQueryMenuListener::BibTBQueryMenuListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): + BibToolBarListener(pTB,aStr,nId) +{ +} + +BibTBQueryMenuListener::~BibTBQueryMenuListener() +{ +} + +void BibTBQueryMenuListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException ) +{ + if(rEvt.FeatureURL.Complete == GetCommand()) + { + pToolBar->EnableSourceList(rEvt.IsEnabled); + + uno::Any aState=rEvt.State; + if(aState.getValueType()==::getCppuType((Sequence<rtl::OUString>*)0)) + { + pToolBar->ClearFilterMenu(); + + Sequence<rtl::OUString>* pStringSeq = (Sequence<rtl::OUString>*) aState.getValue(); + const rtl::OUString* pStringArray = (const rtl::OUString*)pStringSeq->getConstArray(); + + sal_uInt32 nCount = pStringSeq->getLength(); + for( sal_uInt32 i=0; i<nCount; i++ ) + { + sal_uInt16 nID=pToolBar->InsertFilterItem(String(pStringArray[i])); + if(pStringArray[i]==rEvt.FeatureDescriptor) + { +// XubString aStr = rEvt.FeatureDescriptor; + pToolBar->SelectFilterItem(nID); + } + } + } + } +}; + +BibTBEditListener::BibTBEditListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId): + BibToolBarListener(pTB,aStr,nId) +{ +} + +BibTBEditListener::~BibTBEditListener() +{ +} + +void BibTBEditListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException ) +{ + if(rEvt.FeatureURL.Complete == GetCommand()) + { + pToolBar->EnableQuery(rEvt.IsEnabled); + + uno::Any aState=rEvt.State; + if(aState.getValueType()==::getCppuType((const OUString*)0)) + { + String aStr = String(*(OUString*) aState.getValue()); + pToolBar->SetQueryString(aStr); + } + } +} + +SV_IMPL_PTRARR( BibToolBarListenerArr, BibToolBarListenerPtr); + +BibToolBar::BibToolBar(Window* pParent, WinBits nStyle): + ToolBox(pParent,BibResId(RID_BIB_TOOLBAR)), + aFtSource(this,WB_VCENTER), + aLBSource(this,WB_DROPDOWN), + aFtQuery(this,WB_VCENTER), + aEdQuery(this), + nSelMenuItem(0), + nMenuId(0) +{ + SetStyle(GetStyle()|nStyle); + SetOutStyle(TOOLBOX_STYLE_FLAT); + Size aSize=GetSizePixel(); + Size a2Size(GetOutputSizePixel()); + a2Size.Width()=100; + aLBSource.SetSizePixel(a2Size); + aLBSource.SetDropDownLineCount(9); + aLBSource.Show(); + aLBSource.SetSelectHdl(LINK( this, BibToolBar, SelHdl)); + + aTimer.SetTimeoutHdl(LINK( this, BibToolBar, SendSelHdl)); + aTimer.SetTimeout(400); + + aMenuTimer.SetTimeoutHdl(LINK( this, BibToolBar, MenuHdl)); + aMenuTimer.SetTimeout(300); + + aEdQuery.SetSizePixel(aLBSource.GetSizePixel()); + aEdQuery.Show(); + + XubString aStr=GetItemText(TBC_FT_SOURCE); + Rectangle aRect=GetItemRect(TBC_FT_SOURCE); + aFtSource.SetText(aStr); + aFtSource.SetSizePixel(aRect.GetSize()); + + aStr=GetItemText(TBC_FT_QUERY); + aRect=GetItemRect(TBC_FT_QUERY); + aFtQuery.SetText(aStr); + aFtQuery.SetSizePixel(aRect.GetSize()); + + SetItemWindow(TBC_FT_SOURCE,&aFtSource); + SetItemWindow(TBC_LB_SOURCE,&aLBSource); + SetItemWindow(TBC_FT_QUERY ,&aFtQuery); + SetItemWindow(TBC_ED_QUERY ,&aEdQuery); + + +} + +BibToolBar::~BibToolBar() +{ +} +void BibToolBar::InitListener() +{ + sal_uInt16 nCount=GetItemCount(); + + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + uno::Reference< frame::XDispatch > xDisp(xController,UNO_QUERY); + + uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY ); + if( xTrans.is() ) + { + util::URL aQueryURL; + aQueryURL.Complete = C2U(".uno:Bib/MenuFilter"); + xTrans->parseStrict( aQueryURL); + BibToolBarListener* pQuery=new BibTBQueryMenuListener(this,aQueryURL.Complete,TBC_BT_AUTOFILTER); + xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pQuery),aQueryURL); + + for(sal_uInt16 nPos=0;nPos<nCount;nPos++) + { + sal_uInt16 nId=GetItemId(nPos); + if(nId==TBC_FT_SOURCE || nId==TBC_FT_QUERY) continue; + + util::URL aURL; + aURL.Complete = GetItemCommand(nId); + + xTrans->parseStrict( aURL ); + + BibToolBarListener* pListener=NULL; + if(nId==TBC_LB_SOURCE) + { + pListener=new BibTBListBoxListener(this,aURL.Complete,nId); + } + else if(nId==TBC_ED_QUERY) + { + pListener=new BibTBEditListener(this,aURL.Complete,nId); + } + else + { + pListener=new BibToolBarListener(this,aURL.Complete,nId); + } + + BibToolBarListenerPtr pxInsert = new Reference<frame::XStatusListener>; + (*pxInsert) = pListener; + aListenerArr.Insert( pxInsert, aListenerArr.Count() ); + xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pListener),aURL); + } + } +} + +void BibToolBar::SetXController(const uno::Reference< frame::XController > & xCtr) +{ + xController=xCtr; + InitListener(); + +} + +void BibToolBar::Select() +{ + sal_uInt16 nId=GetCurItemId(); + + if(nId!=TBC_BT_AUTOFILTER) + { + SendDispatch(nId,Sequence<PropertyValue>() ); + } + else + { + Sequence<PropertyValue> aPropVal(2); + PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); + pPropertyVal[0].Name=C2U("QueryText"); + rtl::OUString aSelection = aEdQuery.GetText(); + pPropertyVal[0].Value <<= aSelection; + + pPropertyVal[1].Name=C2U("QueryField"); + pPropertyVal[1].Value <<= aQueryField; + SendDispatch(nId,aPropVal); + } +} + +void BibToolBar::SendDispatch(sal_uInt16 nId, const Sequence< PropertyValue >& rArgs) +{ + rtl::OUString aCommand = GetItemCommand(nId); + + uno::Reference< frame::XDispatchProvider > xDSP( xController, UNO_QUERY ); + + if( xDSP.is() && aCommand.len()) + { + uno::Reference< lang::XMultiServiceFactory > xMgr = utl::getProcessServiceFactory(); + + uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY ); + if( xTrans.is() ) + { + // Datei laden + util::URL aURL; + aURL.Complete = aCommand; + + xTrans->parseStrict( aURL ); + + uno::Reference< frame::XDispatch > xDisp = xDSP->queryDispatch( aURL, rtl::OUString(), frame::FrameSearchFlag::SELF ); + + if ( xDisp.is() ) + xDisp->dispatch( aURL, rArgs); + } + } + +} + +void BibToolBar::Click() +{ + sal_uInt16 nId=GetCurItemId(); + + if(nId==TBC_BT_AUTOFILTER) + { + aMenuTimer.Start(); + } +} + +void BibToolBar::ClearFilterMenu() +{ + aPopupMenu.Clear(); + nMenuId=0; +} +sal_uInt16 BibToolBar::InsertFilterItem(const XubString& aMenuEntry) +{ + nMenuId++; + aPopupMenu.InsertItem(nMenuId,aMenuEntry); + + return nMenuId; +} +void BibToolBar::SelectFilterItem(sal_uInt16 nId) +{ + aPopupMenu.CheckItem(nId); + nSelMenuItem=nId; + aQueryField = aPopupMenu.GetItemText(nId).EraseAllChars( '~' ); +} + +void BibToolBar::EnableSourceList(sal_Bool bFlag) +{ + aFtSource.Enable(bFlag); + aLBSource.Enable(bFlag); +} + +void BibToolBar::ClearSourceList() +{ + aLBSource.Clear(); +} + +void BibToolBar::UpdateSourceList(sal_Bool bFlag) +{ + aLBSource.SetUpdateMode(bFlag); +} + +void BibToolBar::InsertSourceEntry(const XubString& aEntry, sal_uInt16 nPos) +{ + aLBSource.InsertEntry(aEntry, nPos); +} + +void BibToolBar::SelectSourceEntry(const XubString& aStr) +{ + aLBSource.SelectEntry(aStr); +} + +void BibToolBar::EnableQuery(sal_Bool bFlag) +{ + aFtQuery.Enable(bFlag); + aEdQuery.Enable(bFlag); +} + +void BibToolBar::SetQueryString(const XubString& aStr) +{ + aEdQuery.SetText(aStr); +} + + +long BibToolBar::PreNotify( NotifyEvent& rNEvt ) +{ + long nResult=sal_True; + + sal_uInt16 nSwitch=rNEvt.GetType(); + if(aEdQuery.HasFocus() && nSwitch==EVENT_KEYINPUT)// || nSwitch==EVENT_KEYUP) + { + const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode(); + sal_uInt16 nKey = aKeyCode.GetCode(); + if(nKey == KEY_RETURN) + { + Sequence<PropertyValue> aPropVal(2); + PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); + pPropertyVal[0].Name = C2U("QueryText"); + rtl::OUString aSelection = aEdQuery.GetText(); + pPropertyVal[0].Value <<= aSelection; + pPropertyVal[1].Name=C2U("QueryField"); + pPropertyVal[1].Value <<= aQueryField; + SendDispatch(TBC_BT_AUTOFILTER,aPropVal); + return nResult; + } + + } + + nResult=ToolBox::PreNotify(rNEvt); + + return nResult; +} + +IMPL_LINK( BibToolBar, SelHdl, ListBox*, pLb ) +{ + aTimer.Start(); + return 0; +} + +IMPL_LINK( BibToolBar, SendSelHdl, Timer*,pT) +{ + Sequence<PropertyValue> aPropVal(1); + PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); + pPropertyVal[0].Name = C2U("DataSourceName"); + String aEntry( aLBSource.GetSelectEntry().EraseAllChars( '~' ) ); + rtl::OUString aSelection = aEntry; + pPropertyVal[0].Value <<= aSelection; + SendDispatch(TBC_LB_SOURCE,aPropVal); + + return 0; +} +//----------------------------------------------------------------------------- +IMPL_LINK( BibToolBar, MenuHdl, Timer*,pT) +{ + if(IsItemDown(TBC_BT_AUTOFILTER)) + { + EndSelection(); // vor SetDropMode (SetDropMode ruft SetItemImage) + + SetItemDown(TBC_BT_AUTOFILTER,sal_True); + sal_uInt16 nId = aPopupMenu.Execute(this, GetItemRect(TBC_BT_AUTOFILTER)); + + + if(nId>0) + { + aPopupMenu.CheckItem(nSelMenuItem,sal_False); + aPopupMenu.CheckItem(nId); + nSelMenuItem=nId; + aQueryField = aPopupMenu.GetItemText(nId).EraseAllChars( '~' ); + Sequence<PropertyValue> aPropVal(2); + PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray(); + pPropertyVal[0].Name = C2U("QueryText"); + rtl::OUString aSelection = aEdQuery.GetText(); + pPropertyVal[0].Value <<= aSelection; + pPropertyVal[1].Name=C2U("QueryField"); + pPropertyVal[1].Value <<= aQueryField; + SendDispatch(TBC_BT_AUTOFILTER,aPropVal); + } + + Point aPoint; + MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC ); + MouseMove( aLeave ); + SetItemDown(TBC_BT_AUTOFILTER,sal_False); + + + } + return 0; +} +//----------------------------------------------------------------------------- +void BibToolBar::statusChanged(const frame::FeatureStateEvent& rEvent) + throw( uno::RuntimeException ) +{ + for(sal_uInt16 i = 0; i < aListenerArr.Count(); i++) + { + BibToolBarListenerPtr pListener = aListenerArr.GetObject(i); + (*pListener)->statusChanged(rEvent); + } +} diff --git a/extensions/source/bibliography/toolbar.hrc b/extensions/source/bibliography/toolbar.hrc new file mode 100644 index 000000000000..95596b4ed7fd --- /dev/null +++ b/extensions/source/bibliography/toolbar.hrc @@ -0,0 +1,77 @@ +/************************************************************************* + * + * $RCSfile: toolbar.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:45 $ + * + * 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 "bib.hrc" + +#define TBC_FT_SOURCE 1 +#define TBC_LB_SOURCE 2 +#define TBC_FT_QUERY 3 +#define TBC_ED_QUERY 4 +#define TBC_BT_AUTOFILTER 5 +#define TBC_BT_FILTERCRIT 6 +#define TBC_BT_REMOVEFILTER 7 +#define TBC_BT_NEWCARD 8 +#define TBC_BT_EDITCARD 9 +#define TBC_BT_REMOVECARD 10 +#define TBC_BT_INSERT 11 +#define TBC_BT_UPDATE 12 +#define TBC_BT_MAIL 13 +#define TBC_BT_URL 14 + diff --git a/extensions/source/bibliography/toolbar.hxx b/extensions/source/bibliography/toolbar.hxx new file mode 100644 index 000000000000..223a73ba1c05 --- /dev/null +++ b/extensions/source/bibliography/toolbar.hxx @@ -0,0 +1,234 @@ +/************************************************************************* + * + * $RCSfile: toolbar.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:45 $ + * + * 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 _BIB_TOOLBAR_HXX +#define _BIB_TOOLBAR_HXX + +#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +#include <com/sun/star/frame/XController.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XSTATUSLISTENER_HPP_ +#include <com/sun/star/frame/XStatusListener.hpp> +#endif + + + +#ifndef _SV_TOOLBOX_HXX //autogen wg. ToolBox +#include <vcl/toolbox.hxx> +#endif + +#ifndef _SV_LSTBOX_HXX //autogen wg. ::com::sun::star::form +#include <vcl/lstbox.hxx> +#endif + +#ifndef _SV_EDIT_HXX //autogen wg. Edit +#include <vcl/edit.hxx> +#endif + +#ifndef _SV_FIXED_HXX //autogen wg. FixedText +#include <vcl/fixed.hxx> +#endif + +#ifndef _SVARRAY_HXX +#include <svtools/svarray.hxx> +#endif + +#ifndef _SV_TIMER_HXX //autogen wg. Timer +#include <vcl/timer.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> // helper for implementations +#endif + + +class BibToolBar; + +class BibToolBarListener: public cppu::WeakImplHelper1 < ::com::sun::star::frame::XStatusListener> +{ +private: + + sal_uInt16 nIndex; + rtl::OUString aCommand; + +protected: + + BibToolBar *pToolBar; + +public: + + BibToolBarListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId); + ~BibToolBarListener(); + + rtl::OUString GetCommand(); + void SetCommand(const rtl::OUString& aStr); + + sal_uInt16 GetIndex(); + void SetIndex(sal_uInt16 nIndex); + + // ::com::sun::star::lang::XEventListener + // we do not hold References to dispatches, so there is nothing to do on disposal + virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) + throw( ::com::sun::star::uno::RuntimeException ){}; + + // ::com::sun::star::frame::XStatusListener + virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) + throw( ::com::sun::star::uno::RuntimeException ); + +}; + +class BibTBListBoxListener: public BibToolBarListener +{ +public: + + BibTBListBoxListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId); + ~BibTBListBoxListener(); + + virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) + throw( ::com::sun::star::uno::RuntimeException ); + +}; + +class BibTBEditListener: public BibToolBarListener +{ +public: + + BibTBEditListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId); + ~BibTBEditListener(); + + virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) + throw( ::com::sun::star::uno::RuntimeException ); + +}; + +class BibTBQueryMenuListener: public BibToolBarListener +{ +public: + + BibTBQueryMenuListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId); + ~BibTBQueryMenuListener(); + + virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) + throw( ::com::sun::star::uno::RuntimeException ); + +}; + + +typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener>* BibToolBarListenerPtr; +SV_DECL_PTRARR_DEL( BibToolBarListenerArr, BibToolBarListenerPtr, 4, 4 ); + +class BibToolBar: public ToolBox +{ + private: + + BibToolBarListenerArr aListenerArr; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xController; + Timer aTimer; + Timer aMenuTimer; + + FixedText aFtSource; + ListBox aLBSource; + FixedText aFtQuery; + Edit aEdQuery; + PopupMenu aPopupMenu; + sal_uInt16 nMenuId; + sal_uInt16 nSelMenuItem; + rtl::OUString aQueryField; + DECL_LINK( SelHdl, ListBox* ); + DECL_LINK( SendSelHdl, Timer* ); + DECL_LINK( MenuHdl, Timer* ); + + protected: + + void InitListener(); + virtual void Select(); + virtual void Click(); + void SendDispatch(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs); + long PreNotify( NotifyEvent& rNEvt ); + + + public: + + BibToolBar(Window* pParent, WinBits nStyle = 0 ); + ~BibToolBar(); + + void SetXController(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > &); + + void ClearSourceList(); + void UpdateSourceList(sal_Bool bFlag=sal_True); + void EnableSourceList(sal_Bool bFlag=sal_True); + void InsertSourceEntry(const XubString&,sal_uInt16 nPos=LISTBOX_APPEND ); + void SelectSourceEntry(const XubString& ); + + void EnableQuery(sal_Bool bFlag=sal_True); + void SetQueryString(const XubString& ); + + void ClearFilterMenu(); + sal_uInt16 InsertFilterItem(const XubString& ); + void SelectFilterItem(sal_uInt16 nId); + + void statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) + throw( ::com::sun::star::uno::RuntimeException ); +}; + + + + +#endif diff --git a/extensions/source/bibliography/toolbar.src b/extensions/source/bibliography/toolbar.src new file mode 100644 index 000000000000..3b7fa7a8b975 --- /dev/null +++ b/extensions/source/bibliography/toolbar.src @@ -0,0 +1,421 @@ +/************************************************************************* + * + * $RCSfile: toolbar.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:45 $ + * + * 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 <offmgr/sba.hrc> +#include "extensio.hrc" +#include "toolbar.hrc" + +ToolBox RID_BIB_TOOLBAR +{ + HelpId = HID_BIB_DB_TBX; + Sizeable = TRUE ; + HideWhenDeactivate = TRUE ; + LineSpacing = TRUE ; + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( 200 , 16 ) ; + ButtonType = BUTTON_SYMBOL ; + ItemList = + { + ToolBoxItem + { + Identifier = TBC_FT_SOURCE; + //HelpID = SID_SBA_BRW_INSERT ; + Text = "Tabelle" ; + Text [ ENGLISH ] = "Table" ; + Text[ english_us ] = "Table"; + Text[ portuguese ] = "Tabela"; + Text[ russian ] = "Òàáëèöà"; + Text[ greek ] = "Ðßíáêáò"; + Text[ dutch ] = "Tabel"; + Text[ french ] = "Table"; + Text[ spanish ] = "Tabla"; + Text[ italian ] = "Tabella"; + Text[ danish ] = "Tabel"; + Text[ swedish ] = "Tabell"; + Text[ polish ] = "Tabela"; + Text[ portuguese_brazilian ] = "Data source"; + Text[ japanese ] = "ðÌÞÙ"; + Text[ korean ] = "µ¥ÀÌÅÍ ¼Ò½º"; + Text[ chinese_simplified ] = "±í¸ñ"; + Text[ chinese_traditional ] = "ªí®æ"; + Text[ arabic ] = "ÌÏæá"; + Text[ turkish ] = "Tablo"; + Text[ language_user1 ] = " "; + }; + ToolBoxItem + { + Identifier = TBC_LB_SOURCE; + HelpID = HID_BIB_TBX_TABLE; + Command = ".uno:Bib/source" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + + ToolBoxItem + { + Identifier = TBC_FT_QUERY; + //HelpID = SID_SBA_BRW_INSERT ; + Text = "Suchbegriff" ; + Text [ ENGLISH ] = "Search key" ; + Text[ english_us ] = "Search Key"; + Text[ portuguese ] = "Expressão procurada"; + Text[ russian ] = "Èñêîìîå ïîíÿòèå"; + Text[ greek ] = "¼ñïò áíáæÞôçóçò"; + Text[ dutch ] = "Zoekbegrip"; + Text[ french ] = "Élément recherché"; + Text[ spanish ] = "Expresión de búsqueda"; + Text[ italian ] = "Termine ricercato"; + Text[ danish ] = "Søgeord"; + Text[ swedish ] = "Sökord"; + Text[ polish ] = "Szukane has³o"; + Text[ portuguese_brazilian ] = "Search key"; + Text[ japanese ] = "ŒŸõ·°"; + Text[ korean ] = "°Ë»ö Å°"; + Text[ chinese_simplified ] = "ËÑÑ°ÄÚÈÝ"; + Text[ chinese_traditional ] = "·j´MÃöÁä¦r"; + Text[ arabic ] = "ãÕØáÍ ÇáÈÍË"; + Text[ turkish ] = "Arama ölçütü"; + }; + ToolBoxItem + { + Identifier = TBC_ED_QUERY; + HelpID = HID_BIB_TBX_SEARCH; + Command = ".uno:Bib/query" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + + ToolBoxItem + { + Identifier = TBC_BT_AUTOFILTER ; + HelpID = HID_BIB_TBX_AUTOFILTER; + ItemBitmap = Bitmap { File = "sc10716.bmp" ; }; + DropDown = TRUE ; + Text = "AutoFilter" ; + Text [ ENGLISH ] = "AutoFilter" ; + Command = ".uno:Bib/autoFilter" ; + Text[ english_us ] = "AutoFilter"; + Text[ portuguese ] = "AutoFiltro"; + Text[ russian ] = "Àâòîôèëüòð"; + Text[ greek ] = "ÁõôïÖßëôñï"; + Text[ dutch ] = "AutoFilter"; + Text[ french ] = "AutoFiltre"; + Text[ spanish ] = "AutoFiltro"; + Text[ italian ] = "Filtro automatico"; + Text[ danish ] = "AutoFilter"; + Text[ swedish ] = "AutoFilter"; + Text[ polish ] = "Autofiltr"; + Text[ portuguese_brazilian ] = "AutoFilter"; + Text[ japanese ] = "µ°Ą̈ÙÀ"; + Text[ korean ] = "ÀÚµ¿ÇÊÅÍ"; + Text[ chinese_simplified ] = "×Ô¶¯É¸Ñ¡"; + Text[ chinese_traditional ] = "¦Ûq¿z¿ï"; + Text[ arabic ] = "ÝáÊÑ Âáí"; + Text[ turkish ] = "Otomatik filtre"; + Text[ language_user1 ] = " "; + }; + + ToolBoxItem + { + Identifier = TBC_BT_FILTERCRIT ; + HelpID = SID_SBA_QRY_FILTERCRIT ; + ItemBitmap = Bitmap { File = "sc10715.bmp" ; }; + Text = "Standard Filter" ; + Text [ ENGLISH ] = "Standard Filter" ; + Command = ".uno:Bib/standardFilter" ; + Text[ english_us ] = "Standard Filter"; + Text[ portuguese ] = "Filtro padrão"; + Text[ russian ] = "Ñòàíäàðòíûé ôèëüòð"; + Text[ greek ] = "Ößëôñï ðñïåðéëïãÞò"; + Text[ dutch ] = "Standaardfilter"; + Text[ french ] = "Filtre par défaut"; + Text[ spanish ] = "Filtro estándar"; + Text[ italian ] = "Filtro standard"; + Text[ danish ] = "Standardfilter"; + Text[ swedish ] = "Standardfilter"; + Text[ polish ] = "Filtr standardowy"; + Text[ portuguese_brazilian ] = "Standard Filter"; + Text[ japanese ] = "•W€Ì¨ÙÀ"; + Text[ korean ] = "±âº» ÇÊÅÍ"; + Text[ chinese_simplified ] = "±ê׼ɸѡ"; + Text[ chinese_traditional ] = "¼Ðã¿z¿ï"; + Text[ arabic ] = "ÝáÊÑ ÞíÇÓí"; + Text[ turkish ] = "Standart filtre"; + Text[ language_user1 ] = " "; + }; + + ToolBoxItem + { + Identifier = TBC_BT_REMOVEFILTER ; + HelpID = SID_SBA_QRY_REMOVEFILTER ; + ItemBitmap = Bitmap { File = "sc10711.bmp" ; }; + Text = "Filter entfernen" ; + Text [ ENGLISH ] = "Remove Filter" ; + Command = ".uno:Bib/removeFilter" ; + Text[ english_us ] = "Remove Filter"; + Text[ portuguese ] = "Eliminar filtro"; + Text[ russian ] = "Óáðàòü ôèëüòð"; + Text[ greek ] = "ÄéáãñáöÞ ößëôñïõ"; + Text[ dutch ] = "Filter verwijderen"; + Text[ french ] = "Supprimer le filtre"; + Text[ spanish ] = "Eliminar filtro"; + Text[ italian ] = "Rimuovi filtro"; + Text[ danish ] = "Fjern filter"; + Text[ swedish ] = "Ta bort filter"; + Text[ polish ] = "Usuñ filtr"; + Text[ portuguese_brazilian ] = "Remove Filter"; + Text[ japanese ] = "̨ÙÀ‚̉ðœ"; + Text[ korean ] = "ÇÊÅÍ Á¦°Å"; + Text[ chinese_simplified ] = "ɾ³ýɸѡ"; + Text[ chinese_traditional ] = "§R°£¿z¿ï"; + Text[ arabic ] = "ÅÒÇáÉ ÝáÊÑ"; + Text[ turkish ] = "Filtreyi kaldýr"; + Text[ language_user1 ] = " "; + }; +/* + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + + ToolBoxItem + { + Identifier = TBC_BT_NEWCARD ; + //HelpID = SID_SBA_QRY_REMOVEFILTER ; + Command = ".uno:Bib/newEntry" ; + ItemBitmap = Bitmap { File = "newcard.bmp" ; }; + Text = "Neue Adresse" ; + Text [ ENGLISH ] = "New Address" ; + Text[ english_us ] = "New Address"; + Text[ portuguese ] = "Novo endereço"; + Text[ russian ] = "Íîâûé àäðåñ"; + Text[ greek ] = "New Address"; + Text[ dutch ] = "Nieuw adres"; + Text[ french ] = "Nouvelle adresse"; + Text[ spanish ] = "Nueva dirección"; + Text[ italian ] = "Nuovo indirizzo"; + Text[ danish ] = "Ny adresse"; + Text[ swedish ] = "Ny adress"; + Text[ polish ] = "Nowy adres"; + Text[ portuguese_brazilian ] = "New Address"; + Text[ japanese ] = "V‚µ‚¢ZŠ"; + Text[ korean ] = "New Address"; + Text[ chinese_simplified ] = "еØÖ·"; + Text[ chinese_traditional ] = "·s¦a§}"; + Text[ arabic ] = "ÚäæÇä ÌÏíÏ"; + }; + + ToolBoxItem + { + Identifier = TBC_BT_EDITCARD ; + //HelpID = SID_SBA_QRY_REMOVEFILTER ; + Command = ".uno:Bib/changeEntry" ; + ItemBitmap = Bitmap { File = "modcard.bmp" ; }; + Text = "Adresse bearbeiten" ; + Text [ ENGLISH ] = "Edit address" ; + Text[ english_us ] = "Edit Address"; + Text[ portuguese ] = "Editar endereço"; + Text[ russian ] = "Ïðàâêà àäðåñà"; + Text[ greek ] = "Edit address"; + Text[ dutch ] = "Adres wijzigen"; + Text[ french ] = "Éditer une adresse"; + Text[ spanish ] = "Editar dirección"; + Text[ italian ] = "Modifica indirizzo"; + Text[ danish ] = "Rediger adresse"; + Text[ swedish ] = "Redigera adress"; + Text[ polish ] = "Edytuj adres"; + Text[ portuguese_brazilian ] = "Edit address"; + Text[ japanese ] = "±ÄÞÚ½‚Ì•ÒW"; + Text[ korean ] = "Edit address"; + Text[ chinese_simplified ] = "±à¼µØÖ·"; + Text[ chinese_traditional ] = "½s¿è¦a§}"; + Text[ arabic ] = "ÊÍÑíÑ ÚäæÇä"; + }; + + ToolBoxItem + { + Identifier = TBC_BT_REMOVECARD ; + //HelpID = SID_SBA_QRY_REMOVEFILTER ; + Command = ".uno:Bib/removeEntry" ; + ItemBitmap = Bitmap { File = "remcard.bmp" ; }; + Text = "Adresse löschen" ; + Text [ ENGLISH ] = "Remove address" ; + Text[ english_us ] = "Remove Address"; + Text[ portuguese ] = "Eliminar endereço"; + Text[ russian ] = "Óäàëèòü àäðåñ"; + Text[ greek ] = "ÄéáãñáöÞ äéåýèõíóçò"; + Text[ dutch ] = "Adres wissen"; + Text[ french ] = "Supprimer une adresse"; + Text[ spanish ] = "Eliminar dirección"; + Text[ italian ] = "Elimina indirizzo"; + Text[ danish ] = "Slet adresse"; + Text[ swedish ] = "Ta bort adress"; + Text[ polish ] = "Usuñ adres"; + Text[ portuguese_brazilian ] = "Remove address"; + Text[ japanese ] = "±ÄÞÚ½‚Ìíœ"; + Text[ korean ] = "Remove address"; + Text[ chinese_simplified ] = "ɾ³ýµØÖ·"; + Text[ chinese_traditional ] = "§R°£¦a§}"; + Text[ arabic ] = "ÍÐÝ ÚäæÇä"; + }; + + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + + ToolBoxItem + { + Identifier = TBC_BT_INSERT ; + HelpID = SID_SBA_BRW_INSERT ; + ItemBitmap = Bitmap { File = "sc12202.bmp" ; }; + Text = "Daten in Text" ; + Text [ ENGLISH ] = "Insert" ; + Text[ english_us ] = "Data into Text"; + Text[ portuguese ] = "Dados no texto"; + Text[ russian ] = "Äàííûå â òåêñò"; + Text[ greek ] = "ÄåäïìÝíá óôï êåßìåíï"; + Text[ dutch ] = "Gegevens in tekst"; + Text[ french ] = "Données dans le texte"; + Text[ spanish ] = "Datos en texto"; + Text[ italian ] = "Dati nel testo"; + Text[ danish ] = "Data i tekst"; + Text[ swedish ] = "Data i text"; + Text[ polish ] = "Dane w tekœcie"; + Text[ portuguese_brazilian ] = "Insert"; + Text[ japanese ] = "•¶‘‚ÉÃÞ°À"; + Text[ korean ] = "Insert"; + Text[ chinese_simplified ] = "²åÈëÊý¾ÝÖÁÎı¾ÖÐ"; + Text[ chinese_traditional ] = "¼ÆÕuÂà´«¦¨¤å¦r"; + Text[ arabic ] = "ÈíÇäÇÊ Åáì äÕ"; + }; + ToolBoxItem + { + Identifier = TBC_BT_UPDATE ; + HelpID = SID_SBA_BRW_UPDATE ; + ItemBitmap = Bitmap { File = "sc12201.bmp" ; }; + Text = "Daten in Felder" ; + }; + + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + + ToolBoxItem + { + Identifier = TBC_BT_MAIL ; + //HelpID = HID_ADDRPI_AUTOMAIL ; + ItemBitmap = Bitmap { File = "sc06305.bmp" ; }; + Text = "AutoMail" ; + Text [ ENGLISH ] = "AutoMail" ; + Text[ english_us ] = "AutoMail"; + Text[ portuguese ] = "AutoMail"; + Text[ russian ] = "AutoMail"; + Text[ greek ] = "AutoMail"; + Text[ dutch ] = "AutoMail"; + Text[ french ] = "AutoMail"; + Text[ spanish ] = "AutoMail"; + Text[ italian ] = "Mail automatica"; + Text[ danish ] = "AutoPost"; + Text[ swedish ] = "AutoMail"; + Text[ polish ] = "AutoMail"; + Text[ portuguese_brazilian ] = "AutoMail"; + Text[ japanese ] = "µ°ÄÒ°Ù"; + Text[ korean ] = "AutoMail"; + Text[ chinese_simplified ] = "×Ô¶¯µç×ÓÓʼþ"; + Text[ chinese_traditional ] = "¦Û°Ê¹q¤l¶l¥ó"; + Text[ arabic ] = "ÈÑíÏ Âáí"; + }; + ToolBoxItem + { + Identifier = TBC_BT_URL ; + //HelpID = HID_ADDRPI_AUTOBROWSE ; + ItemBitmap = Bitmap { File = "sc06304.bmp" ; }; + Text = "AutoBrowse" ; + Text [ ENGLISH ] = "AutoBrowse" ; + Text[ english_us ] = "AutoBrowse"; + Text[ portuguese ] = "AutoBrowse"; + Text[ russian ] = "Àâòîïðîñìîòð"; + Text[ greek ] = "AutoBrowse"; + Text[ dutch ] = "AutoBrowse"; + Text[ french ] = "AutoBrowse"; + Text[ spanish ] = "AutoBrowse"; + Text[ italian ] = "Browse automatico"; + Text[ danish ] = "AutoBrowse"; + Text[ swedish ] = "AutoBrowse"; + Text[ polish ] = "AutoBrowse"; + Text[ portuguese_brazilian ] = "AutoBrowse"; + Text[ japanese ] = "µ°ÄÌÞ׳¾Þ"; + Text[ korean ] = "AutoBrowse"; + Text[ chinese_simplified ] = "×Ô¶¯ä¯ÀÀ"; + Text[ chinese_traditional ] = "¦Û°ÊÂsÄý"; + Text[ arabic ] = "ÇÓÊÚÑÇÖ Âáí"; + };*/ + }; + Scroll = TRUE ; +}; + diff --git a/extensions/source/ole/comifaces.hxx b/extensions/source/ole/comifaces.hxx new file mode 100644 index 000000000000..e3f0f4e95490 --- /dev/null +++ b/extensions/source/ole/comifaces.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * $RCSfile: comifaces.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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 __COMIFACES_HXX +#define __COMIFACES_HXX + +#include <com/sun/star/uno/XInterface.hpp> + +using namespace com::sun::star::uno; + +MIDL_INTERFACE("e40a2331-3bc1-11d4-8321-005004526ab4") +IJScriptValueObject: public IUnknown +{ + STDMETHOD( Set)( VARIANT type, VARIANT value)= 0; + STDMETHOD( Get)( VARIANT *val)= 0; + STDMETHOD( InitOutParam)()= 0; + STDMETHOD( InitInOutParam)( VARIANT type, VARIANT value)= 0; + STDMETHOD( IsOutParam)( VARIANT_BOOL * flag)= 0; + STDMETHOD( IsInOutParam)( VARIANT_BOOL * flag)= 0; + STDMETHOD( GetValue)( BSTR* type, VARIANT *value)= 0; + +}; + +MIDL_INTERFACE("7B5C3410-66FA-11d4-832A-005004526AB4") +IUnoObjectWrapper: public IUnknown +{ + STDMETHOD( getWrapperXInterface)( Reference<XInterface>* pInt)=0; + STDMETHOD( getOriginalUnoObject)( Reference<XInterface>* pInt)=0; + STDMETHOD( getOriginalUnoStruct)( Any * pStruct)=0; + +}; + +#endif diff --git a/extensions/source/ole/jscriptclasses.cxx b/extensions/source/ole/jscriptclasses.cxx new file mode 100644 index 000000000000..bf549243e412 --- /dev/null +++ b/extensions/source/ole/jscriptclasses.cxx @@ -0,0 +1,350 @@ +/************************************************************************* + * + * $RCSfile: jscriptclasses.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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 "jscriptclasses.hxx" + +//======================================================================== +// JScriptValue +//======================================================================== +JScriptValue::JScriptValue(): m_bOutParam(0), m_bInOutParam(0) +{ +} + +JScriptValue::~JScriptValue() +{ +} + + +// JScriptValue, IDispatch -------------------------------------------- +STDMETHODIMP JScriptValue::GetTypeInfoCount(UINT *pctinfo) +{ + return E_NOTIMPL; +} + +// JScriptValue, IDispatch -------------------------------------------- +STDMETHODIMP JScriptValue::GetTypeInfo( UINT iTInfo, + LCID lcid, + ITypeInfo **ppTInfo) +{ + return E_NOTIMPL; +} + +// JScriptValue, IDispatch -------------------------------------------- +STDMETHODIMP JScriptValue::GetIDsOfNames( REFIID riid, + LPOLESTR *rgszNames, + UINT cNames, + LCID lcid, + DISPID *rgDispId) +{ + if( !rgDispId) + return E_POINTER; + + + HRESULT ret= S_OK; + CComBSTR name(*rgszNames); + name.ToLower(); + + if( name == CComBSTR( L"set") ) + *rgDispId= 1; + else if( name == CComBSTR( L"get") ) + *rgDispId= 2; + else if( name == CComBSTR( L"initoutparam") ) + *rgDispId= 3; + else if( name == CComBSTR( L"initinoutparam") ) + *rgDispId= 4; + else + ret= DISP_E_UNKNOWNNAME; + + return ret; +} + +// JScriptValue, IDispatch -------------------------------------------- +STDMETHODIMP JScriptValue::Invoke( DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pDispParams, + VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr) +{ + if( pDispParams->cNamedArgs) + return DISP_E_NONAMEDARGS; + + + HRESULT ret= S_OK; + switch( dispIdMember) + { + case 0: // DISPID_VALUE + if( wFlags & DISPATCH_PROPERTYGET && pVarResult) + { + if( FAILED( VariantCopy( pVarResult, &m_varValue))) + ret= E_FAIL; + } + else + ret= E_POINTER; + break; + case 1: + if( wFlags & DISPATCH_METHOD) + ret= Set( pDispParams->rgvarg[1], pDispParams->rgvarg[0]); + if( FAILED( ret)) + ret= DISP_E_EXCEPTION; + break; + case 2: + if( wFlags & DISPATCH_METHOD) + ret= Get( pVarResult); + if( FAILED( ret)) + ret= DISP_E_EXCEPTION; + break; + case 3: + if( wFlags & DISPATCH_METHOD) + ret= InitOutParam(); + if( FAILED( ret)) + ret= DISP_E_EXCEPTION; + break; + case 4: + if( wFlags & DISPATCH_METHOD) + ret= InitInOutParam( pDispParams->rgvarg[1], pDispParams->rgvarg[0]); + if( FAILED( ret)) + ret= DISP_E_EXCEPTION; + break; + default: + ret= DISP_E_MEMBERNOTFOUND; + break; + } + + return ret; +} + +// JScriptValue, IScriptOutParam----------------------- +STDMETHODIMP JScriptValue::Set( VARIANT type, VARIANT value) +{ + Lock(); + HRESULT hr= S_OK; + m_varValue= value; + VARIANT var; + VariantInit( &var); + if( SUCCEEDED( hr= VariantChangeType( &var, &type, 0, VT_BSTR))) + m_bstrType= var.bstrVal; + Unlock(); + return hr; +} +// JScriptValue, IScriptOutParam----------------------- +STDMETHODIMP JScriptValue::Get( VARIANT *val) +{ + Lock(); + if( !val) + return E_POINTER; + HRESULT hr= VariantCopy( val, &m_varValue); + Unlock(); + return hr; +} + +STDMETHODIMP JScriptValue::InitOutParam() +{ + Lock(); + m_bOutParam= true; + m_bInOutParam= false; + Unlock(); + return S_OK; +} + +STDMETHODIMP JScriptValue::InitInOutParam( VARIANT type, VARIANT value) +{ + Lock(); + m_bInOutParam= true; + m_bOutParam= false; + Unlock(); + return Set( type, value); +} + +STDMETHODIMP JScriptValue::IsOutParam( VARIANT_BOOL * flag) +{ + Lock(); + if( !flag) + return E_POINTER; + *flag= m_bOutParam ? VARIANT_TRUE : VARIANT_FALSE; + Unlock(); + return S_OK; +} + +STDMETHODIMP JScriptValue::IsInOutParam( VARIANT_BOOL * flag) +{ + Lock(); + if( !flag) + return E_POINTER; + *flag= m_bInOutParam ? VARIANT_TRUE : VARIANT_FALSE; + Unlock(); + return S_OK; +} + +STDMETHODIMP JScriptValue::GetValue( BSTR* type, VARIANT *value) +{ + Lock(); + if( !type || !value) + return E_POINTER; + HRESULT hr; + if( SUCCEEDED( hr= m_bstrType.CopyTo( type))) + hr= VariantCopy( value, &m_varValue); + Unlock(); + return hr; +} + +//########################################################################################## +// JScriptOutValue +//########################################################################################## + +JScriptOutParam::JScriptOutParam() +{ +} + +JScriptOutParam::~JScriptOutParam() +{ +} + + +// JScriptOutParam, IDispatch -------------------------------------------- +STDMETHODIMP JScriptOutParam::GetTypeInfoCount(UINT *pctinfo) +{ + return E_NOTIMPL; +} + +// JScriptOutParam, IDispatch -------------------------------------------- +STDMETHODIMP JScriptOutParam::GetTypeInfo( UINT iTInfo, + LCID lcid, + ITypeInfo **ppTInfo) +{ + return E_NOTIMPL; +} + +// JScriptOutParam, IDispatch -------------------------------------------- +STDMETHODIMP JScriptOutParam::GetIDsOfNames( REFIID riid, + LPOLESTR *rgszNames, + UINT cNames, + LCID lcid, + DISPID *rgDispId) +{ + if( !rgDispId) + return E_POINTER; + + + HRESULT ret= S_OK; + CComBSTR name(*rgszNames); + name.ToLower(); + + if( name == CComBSTR( L"0") ) + *rgDispId= 1; + else + ret= DISP_E_UNKNOWNNAME; + + return ret; +} + +// JScriptOutParam, IDispatch -------------------------------------------- +STDMETHODIMP JScriptOutParam::Invoke( DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pDispParams, + VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr) +{ + HRESULT ret= S_OK; + switch( dispIdMember) + { + case 0: // DISPID_VALUE + if( wFlags & DISPATCH_PROPERTYGET && pVarResult) + { + if( FAILED( VariantCopy( pVarResult, &m_varValue))) + ret= E_FAIL; + } + else if( wFlags & DISPATCH_PROPERTYPUT || wFlags & DISPATCH_PROPERTYPUTREF) + { + m_varValue.Clear(); + if( FAILED( VariantCopyInd( &m_varValue, &pDispParams->rgvarg[0]))) + ret= E_FAIL; + } + else + ret= E_POINTER; + break; + case 1: // + if( wFlags & DISPATCH_PROPERTYGET && pVarResult) + { + if( FAILED( VariantCopy( pVarResult, &m_varValue))) + ret= E_FAIL; + } + else if( wFlags & DISPATCH_PROPERTYPUT || wFlags & DISPATCH_PROPERTYPUTREF) + { + m_varValue.Clear(); + if( FAILED( VariantCopyInd( &m_varValue, &pDispParams->rgvarg[0]))) + ret= E_FAIL; + } + else + ret= E_POINTER; + break; + + default: + ret= DISP_E_MEMBERNOTFOUND; + break; + } + + return ret; +} diff --git a/extensions/source/ole/jscriptclasses.hxx b/extensions/source/ole/jscriptclasses.hxx new file mode 100644 index 000000000000..13371a21318a --- /dev/null +++ b/extensions/source/ole/jscriptclasses.hxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * $RCSfile: jscriptclasses.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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 __JSCRIPTCLASSES_HXX +#define __JSCRIPTCLASSES_HXX +#include <tools/presys.h> +#include "stdafx.h" +#include <tools/postsys.h> + +#include "comifaces.hxx" + + + +// Sequences are represented by prepending "[]", e.g. []char, [][]byte, [][][]object, etc. + +// To make a JScriptValue object to an out parameter, call +// "InitOutParam" and to make it a in/out parameter call +// "InitInOutParam" + +// If the object represents an out parameter then the value can after the call +// be retrived by "Get". + +// From JavaScript the functions Get, Set, InitOutParam and InitInOutParam are +// used, that is they are accessible through IDispatch. The functions are used +// by the bridge. + +class JScriptValue: + public CComObjectRootEx<CComMultiThreadModel>, + public IJScriptValueObject, + public IDispatch +{ +public: + JScriptValue(); + virtual ~JScriptValue(); + + BEGIN_COM_MAP(JScriptValue) + COM_INTERFACE_ENTRY(IDispatch) + COM_INTERFACE_ENTRY(IJScriptValueObject) + END_COM_MAP() + + // IDispatch ------------------------------------------- + STDMETHOD( GetTypeInfoCount)(UINT *pctinfo); + + STDMETHOD( GetTypeInfo)( UINT iTInfo, + LCID lcid, + ITypeInfo **ppTInfo); + + STDMETHOD( GetIDsOfNames)( REFIID riid, + LPOLESTR *rgszNames, + UINT cNames, + LCID lcid, + DISPID *rgDispId); + + STDMETHOD( Invoke)( DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pDispParams, + VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr); + // IJScriptOutParam -------------------------------------- + + STDMETHOD( Set)( VARIANT type, VARIANT value); + STDMETHOD( Get)( VARIANT *val); + STDMETHOD( InitOutParam)(); + STDMETHOD( InitInOutParam)( VARIANT type, VARIANT value); + STDMETHOD( IsOutParam)( VARIANT_BOOL * flag); + STDMETHOD( IsInOutParam)( VARIANT_BOOL * flag); + STDMETHOD( GetValue)( BSTR* type, VARIANT *value); + + + CComVariant m_varValue; + CComBSTR m_bstrType; + unsigned m_bOutParam: 1; + unsigned m_bInOutParam: 1; + +}; + +// If a class is implemented in JScript, then its method +class JScriptOutParam: + public CComObjectRootEx<CComMultiThreadModel>, + public IDispatch +{ +public: + JScriptOutParam(); + virtual ~JScriptOutParam(); + + BEGIN_COM_MAP(JScriptOutParam) + COM_INTERFACE_ENTRY(IDispatch) + END_COM_MAP() + + // IDispatch ------------------------------------------- + STDMETHOD( GetTypeInfoCount)(UINT *pctinfo); + + STDMETHOD( GetTypeInfo)( UINT iTInfo, + LCID lcid, + ITypeInfo **ppTInfo); + + STDMETHOD( GetIDsOfNames)( REFIID riid, + LPOLESTR *rgszNames, + UINT cNames, + LCID lcid, + DISPID *rgDispId); + + STDMETHOD( Invoke)( DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pDispParams, + VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr); + + +private: + CComVariant m_varValue; +}; + +#endif diff --git a/extensions/source/ole/makefile.mk b/extensions/source/ole/makefile.mk new file mode 100644 index 000000000000..d7c68e2c45e5 --- /dev/null +++ b/extensions/source/ole/makefile.mk @@ -0,0 +1,188 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ +# +# 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=..$/.. +# from cppumaker -------------------------------------------------- +UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb + +UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb +.IF "$(BOOTSTRAP_SERVICE)" == "TRUE" +UNOUCROUT= $(OUT)$/inc$/comprehensive +INCPRE+= $(OUT)$/inc$/comprehensive +CPPUMAKERFLAGS += -C +.ELSE +UNOUCROUT= $(OUT)$/inc +INCPRE+= $(OUT)$/inc +.ENDIF + +# ----------------------------------------------------------------- + +PRJNAME=extensions +TARGET=olebrdg + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +LIBTARGET=NO +USE_DEFFILE=YES + +USE_DEFFILE=TRUE +INCPRE+= -I$(SOLARINCDIR)$/external$/atl + +.IF "$(PRODUCT)"=="" || "$(debug)"!="" +LIBCMT=msvcrtd.lib +.ENDIF +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=TRUE + + +#---------------------------------------------------------------- +#.INCLUDE: .$/cppumaker.mk + + +UNOTYPES= \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.lang.XEventListener \ + com.sun.star.lang.XUnoTunnel \ + com.sun.star.lang.XInitialization \ + com.sun.star.uno.TypeClass \ + com.sun.star.script.FinishEngineEvent \ + com.sun.star.script.XInvocation \ + com.sun.star.script.XInvocation \ + com.sun.star.script.XLibraryAccess \ + com.sun.star.script.XAllListener \ + com.sun.star.script.FailReason \ + com.sun.star.script.XEventAttacher \ + com.sun.star.script.XEventAttacherManager \ + com.sun.star.script.XAllListenerAdapterService \ + com.sun.star.script.XInvocationAdapterFactory \ + com.sun.star.script.XInvocationAdapterFactory2 \ + com.sun.star.registry.InvalidValueException \ + com.sun.star.registry.RegistryKeyType \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.registry.RegistryValueType \ + com.sun.star.registry.InvalidRegistryException \ + com.sun.star.loader.XImplementationLoader \ + com.sun.star.loader.CannotActivateFactoryException \ + com.sun.star.bridge.XBridgeSupplier \ + com.sun.star.bridge.XBridgeSupplier2 \ + com.sun.star.bridge.ModelDependent \ + com.sun.star.reflection.InvocationTargetException \ + com.sun.star.beans.UnknownPropertyException \ + com.sun.star.beans.MethodConcept \ + com.sun.star.beans.PropertyConcept \ + com.sun.star.beans.XExactName \ + com.sun.star.beans.XMaterialHolder \ + com.sun.star.uno.Exception \ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.reflection.XIdlReflection + +# com.sun.star.beans.XMaterialHolder \ + + +.IF "$(GUI)"=="WNT" + + + + +SLOFILES= \ + $(SLO)$/servreg.obj \ + $(SLO)$/servprov.obj \ + $(SLO)$/unoobjw.obj \ + $(SLO)$/oleobjw.obj \ + $(SLO)$/oleclassw.obj \ + $(SLO)$/olethread.obj \ + $(SLO)$/oledll.obj \ + $(SLO)$/StdAfx.obj \ + $(SLO)$/jscriptclasses.obj + + +SHL1TARGET=$(TARGET) +SHL1STDLIBS=\ + $(SALLIB) \ + $(VOSLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(LIBCIMT) \ + ole32.lib \ + uuid.lib \ + oleaut32.lib + +#SHL1LIBS = $(SLB)$/$(TARGET).lib +SHL1LIBS= +SHL1OBJS=$(SLOFILES) +#SHL1DEF=$(MISC)$/$(SHL1TARGET).def +#SHL1DEF=$(TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE=$(SHL1TARGET).dxp + +.ENDIF + +#---------------------------------------------------------------- + +.INCLUDE : target.mk + +#.INCLUDE : $(PRJ)$/util$/target.pmk + diff --git a/extensions/source/ole/ole2uno.hxx b/extensions/source/ole/ole2uno.hxx new file mode 100644 index 000000000000..5eeb8ea29d68 --- /dev/null +++ b/extensions/source/ole/ole2uno.hxx @@ -0,0 +1,408 @@ +/************************************************************************* + * + * $RCSfile: ole2uno.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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 _OLE2UNO_HXX +#define _OLE2UNO_HXX + + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define STRICT +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0400 +#endif + +#define _WIN32_DCOM +#ifdef _DEBUG +//#define _ATL_DEBUG_INTERFACES +#endif + +//#include <atlbase.h> +//You may derive a class from CComModule and use it if you want to override +//something, but do not change the name of _Module + +#include <tools/prewin.h> +//#include <stdlib.h> +//#include <malloc.h> +//#include <ole2.h> +//#include <oleauto.h> +//#include <oaidl.h> +//#include <ocidl.h> +#include <tchar.h> +//#include <objbase.h> +//#include <atlbase.h> +//extern CComModule _Module; +//#include <atlcom.h> +#if _MSC_VER >= 1200 +#include <dispex.h> +//#include <winbase.h> +#endif +#include <tools/postwin.h> + +#include <tools/presys.h> +#include <list> +#include <hash_map> +#include <tools/postsys.h> + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_ +#include <com/sun/star/script/XTypeConverter.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_FINISHENGINEEVENT_HPP_ +#include <com/sun/star/script/FinishEngineEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_INTERRUPTREASON_HPP_ +#include <com/sun/star/script/InterruptReason.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XENGINELISTENER_HPP_ +#include <com/sun/star/script/XEngineListener.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XDEBUGGING_HPP__ +#include <com/sun/star/script/XDebugging.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XINVOCATION_HPP_ +#include <com/sun/star/script/XInvocation.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_CONTEXTINFORMATION_HPP_ +#include <com/sun/star/script/ContextInformation.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_FINISHREASON_HPP_ +#include <com/sun/star/script/FinishReason.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XENGINE_HPP_ +#include <com/sun/star/script/XEngine.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_INTERRUPTENGINEEVENT_HPP_ +#include <com/sun/star/script/InterruptEngineEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XLIBRARYACCESS_HXX_ +#include <com/sun/star/script/XLibraryAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_REGISTRY_INVALIDVALUEEXCEPTION_HPP_ +#include <com/sun/star/registry/InvalidValueException.hpp> +#endif +#ifndef _COM_SUN_STAR_REGISTRY_REGISTRYKEYTYPE_HPP_ +#include <com/sun/star/registry/RegistryKeyType.hpp> +#endif +#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_ +#include <com/sun/star/registry/XRegistryKey.hpp> +#endif +#ifndef _COM_SUN_STAR_REGISTRY_REGISTRYVALUETYPE_HPP_ +#include <com/sun/star/registry/RegistryValueType.hpp> +#endif +#ifndef _COM_SUN_STAR_REGISTRY_INVALIDREGISTRYEXCEPTION_HPP_ +#include <com/sun/star/registry/InvalidRegistryException.hpp> +#endif +#ifndef _COM_SUN_STAR_LOADER_XIMPLEMENTATIONLOADER_HPP_ +#include <com/sun/star/loader/XImplementationLoader.hpp> +#endif +#ifndef _COM_SUN_STAR_LOADER_CANNOTACTIVATEFACTORYEXCEPTION_HPP_ +#include <com/sun/star/loader/CannotActivateFactoryException.hpp> +#endif +#ifndef _COM_SUN_STAR_BRIDGE_XBRIDGESUPPLIER_HPP_ +#include <com/sun/star/bridge/XBridgeSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_BRIDGE_XBRIDGESUPPLIER2_HPP_ +#include <com/sun/star/bridge/XBridgeSupplier2.hpp> +#endif +#ifndef _COM_SUN_STAR_BRIDGE_MODELDEPENDENT_HPP_ +#include <com/sun/star/bridge/ModelDependent.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_INVOCATIONTARGETEXCEPTION_HPP_ +#include <com/sun/star/reflection/InvocationTargetException.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_ +#include <com/sun/star/uno/Exception.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_UNKNOWNPROPERTYEXCEPTION_HPP_ +#include <com/sun/star/beans/UnknownPropertyException.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _TYPELIB_TYPECLASS_H_ +#include <typelib/typeclass.h> +#endif + +#ifndef _UNO_DISPATCHER_H_ +#include <uno/dispatcher.h> +#endif + +#ifndef _UNO_MAPPING_H_ +#include <uno/mapping.hxx> +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + +#ifndef _RTL_PROCESS_H_ +#include <rtl/process.h> +#endif + +#ifndef _RTL_UUID_H_ +#include <rtl/uuid.h> +#endif + +#define UNO_2_OLE_EXCEPTIONCODE 1001 + +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::script; +using namespace com::sun::star::registry; +using namespace com::sun::star::reflection; +using namespace com::sun::star::beans; +using namespace osl; +using namespace rtl; +using namespace std; + + + +namespace ole_adapter +{ +// function shared in this component +Reference<XSingleServiceFactory> o2u_getConverterProvider2(const Reference<XMultiServiceFactory>& xMan, const Reference<XRegistryKey>& xKey); +Reference<XSingleServiceFactory> o2u_getConverterProviderVar1(const Reference<XMultiServiceFactory>& xMan, const Reference<XRegistryKey>& xKey); +Reference<XSingleServiceFactory> o2u_getClientProvider(const Reference<XMultiServiceFactory>& xMan, const Reference<XRegistryKey>& xKey); +Reference<XSingleServiceFactory> o2u_getServerProvider(const Reference<XMultiServiceFactory>& xMan, const Reference<XRegistryKey>& xKey); + +Reference<XMultiServiceFactory> o2u_getMultiServiceFactory(); +Reference<XRegistryKey> o2u_getRegistryKey(); +const VARTYPE getVarType( const Any& val); +Type getType( BSTR type); + + +Uik o2u_uikFromGUID(GUID* pGuid); +void o2u_attachCurrentThread(); + +struct equalOUString_Impl +{ + bool operator()(const OUString & s1, const OUString & s2) const + { + return s1 == s2; + } +}; + +struct hashOUString_Impl +{ + size_t operator()(const OUString & rName) const + { + return rName.hashCode(); + } +}; + + + + +// ask the object for XBridgeSupplier2 and on success bridges +// the uno object to IDispatch. +template < class T > +sal_Bool convertSelfToIDispatch( T& unoInterface, IDispatch** ppDisp) +{ + OSL_ASSERT( ppDisp); + *ppDisp= NULL; + + Reference< XInterface > xInt( unoInterface, UNO_QUERY); + if( xInt.is()) + { + Reference< XBridgeSupplier2 > xSupplier( xInt, UNO_QUERY); + if( xSupplier.is()) + { + sal_Int8 arId[16]; + rtl_getGlobalProcessId( (sal_uInt8*)arId); + Sequence<sal_Int8> seqId( arId, 16); + Any anySource; + anySource <<= xInt; + Any anyDisp= xSupplier->createBridge( anySource, seqId, UNO, OLE); + if( anyDisp.getValueTypeClass() == TypeClass_UNSIGNED_LONG) + { + VARIANT* pvar= *(VARIANT**)anyDisp.getValue(); + if( pvar->vt == VT_DISPATCH) + { + *ppDisp= pvar->pdispVal; + (*ppDisp)->AddRef(); + } + VariantClear( pvar); + CoTaskMemFree( pvar); + } + } + } + return *ppDisp ? sal_True : sal_False; +} +// ---------------------------------------------------------------------- +// see the overloaded getCppuType function in this file +//class IUnknownWrapper: public XInterface +//{ +//public: +// +// virtual Any invokeWithDispId(DISPID dispID, const Sequence< Any >& Params, Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam) throw ( IllegalArgumentException, CannotConvertException, InvocationTargetException, Exception ) = 0; +// virtual void setValueWithDispId(DISPID dispID, const Any& Value) throw( UnknownPropertyException, CannotConvertException, InvocationTargetException, Exception) = 0; +// virtual Any getValueWithDispId(DISPID dispID) throw( UnknownPropertyException, Exception) = 0; +//}; +//----------------------------------------------------------------------- + + + +/* ref class to hold IUnknown pointer +*/ +template <class UnknownClass> class OleRef +{ +public: + + typedef OleRef<UnknownClass> self; + + OleRef() + : m_pUnknown(NULL) + {} + + OleRef(const self& copy) + : m_pUnknown(copy.m_pUnknown) + { + if (m_pUnknown) m_pUnknown->AddRef(); + } + + OleRef(UnknownClass* pUnknown) + : m_pUnknown(pUnknown) + { + if (m_pUnknown) m_pUnknown->AddRef(); + } + + ~OleRef() + { + if (m_pUnknown) m_pUnknown->Release(); + } + + self& operator = (const self& copy) + { + if (m_pUnknown) m_pUnknown->Release(); + m_pUnknown = copy.m_pUnknown; + if (m_pUnknown) m_pUnknown->AddRef(); + + return *this; + } + + self& operator = (UnknownClass* pUnknown) + { + if (m_pUnknown) m_pUnknown->Release(); + m_pUnknown = pUnknown; + if (m_pUnknown) m_pUnknown->AddRef(); + return *this; + } + + UnknownClass* get() { return m_pUnknown; } + + UnknownClass* operator->() { return m_pUnknown; } + + const UnknownClass* operator->() const { return m_pUnknown; } + + Boolean is() { return (m_pUnknown != NULL); } + +protected: + + UnknownClass* m_pUnknown; +}; + +inline sal_Bool operator == (const Uik & uik1, const Uik & uik2) +{ + if( ! memcmp( &uik1, &uik2, sizeof( Uik))) + return sal_True; + else + return sal_False; +} + +} // end namespace + + + +#endif _OLE2UNO_HXX + diff --git a/extensions/source/ole/oledll.cxx b/extensions/source/ole/oledll.cxx new file mode 100644 index 000000000000..e75309e86516 --- /dev/null +++ b/extensions/source/ole/oledll.cxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * $RCSfile: oledll.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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 "stdafx.h" + +CComModule _Module; + +BEGIN_OBJECT_MAP(ObjectMap) +END_OBJECT_MAP() + +///////////////////////////////////////////////////////////////////////////// +// DLL Entry Point + +extern "C" +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) +{ + if (dwReason == DLL_PROCESS_ATTACH) + { + _Module.Init(ObjectMap, hInstance, NULL); + DisableThreadLibraryCalls(hInstance); + } + else if (dwReason == DLL_PROCESS_DETACH) + { + _Module.Term(); + } + return TRUE; // ok +} + diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx new file mode 100644 index 000000000000..30ac9e1ac49f --- /dev/null +++ b/extensions/source/ole/oleobjw.cxx @@ -0,0 +1,1581 @@ +/************************************************************************* + * + * $RCSfile: oleobjw.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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 "ole2uno.hxx" + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#include <osl/diagnose.h> + +#ifndef _COM_SUN_STAR_SCRIPT_FAILREASON_HPP_ +#include <com/sun/star/script/FailReason.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XMATERIALHOLDER_HPP_ +#include <com/sun/star/beans/XMaterialHolder.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_ +#include <com/sun/star/script/XTypeConverter.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_FINISHENGINEEVENT_HPP_ +#include <com/sun/star/script/FinishEngineEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_INTERRUPTREASON_HPP_ +#include <com/sun/star/script/InterruptReason.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XENGINELISTENER_HPP_ +#include <com/sun/star/script/XEngineListener.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XDEBUGGING_HPP_ +#include <com/sun/star/script/XDebugging.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XINVOCATION_HPP_ +#include <com/sun/star/script/XInvocation.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_CONTEXTINFORMATION_HPP_ +#include <com/sun/star/script/ContextInformation.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_FINISHREASON_HPP_ +#include <com/sun/star/script/FinishReason.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XENGINE_HPP_ +#include <com/sun/star/script/XEngine.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_INTERRUPTENGINEEVENT_HPP_ +#include <com/sun/star/script/InterruptEngineEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XLIBRARYACCESS_HPP_ +#include <com/sun/star/script/XLibraryAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_BRIDGE_XBRIDGESUPPLIER_HPP_ +#include <com/sun/star/bridge/XBridgeSupplier.hpp> +#endif +//#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +//#include <com/sun/star/lang/XUnoTunnel.hpp> +//#endif + +#ifndef _COM_SUN_STAR_BRIDGE_MODELDEPENDENT_HPP_ +#include <com/sun/star/bridge/ModelDependent.hpp> +#endif + +#include <typelib/typedescription.hxx> +#include <rtl/uuid.h> +#include <rtl/memory.h> +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +//#include <tools/presys.h> + +#include "jscriptclasses.hxx" +//#include <tools/postsys.h> + +#include "oleobjw.hxx" +#include "unoobjw.hxx" + +using namespace std; +using namespace osl; +using namespace rtl; +using namespace cppu; +using namespace com::sun::star::lang; +using namespace com::sun::star::bridge; +using namespace com::sun::star::bridge::ModelDependent; + +#define JSCRIPT_ID_PROPERTY L"_environment" +#define JSCRIPT_ID L"jscript" +namespace ole_adapter +{ + + + + + +// key: XInterface pointer created by Invocation Adapter Factory +// value: XInterface pointer to the wrapper class. +// Entries to the map are made within +// Any createOleObjectWrapper(IUnknown* pUnknown, const Type& aType); +// Entries are being deleted if the wrapper class's destructor has been +// called. +// Before UNO object is wrapped to COM object this map is checked +// to see if the UNO object is already a wrapper. +hash_map<sal_uInt32,sal_uInt32> AdapterToWrapperMap; +// key: XInterface of the wrapper object. +// value: XInterface of the Interface created by the Invocation Adapter Factory. +// A COM wrapper is responsible for removing the corresponding entry +// in AdapterToWrappperMap if it is being destroyed. Because the wrapper does not +// know about its adapted interface it uses WrapperToAdapterMap to get the +// adapted interface which is then used to locate the entry in AdapterToWrapperMap. +hash_map<sal_uInt32,sal_uInt32> WrapperToAdapterMap; + + +/***************************************************************************** + + class implementation IUnknownWrapper_Impl + +*****************************************************************************/ + +IUnknownWrapper_Impl::IUnknownWrapper_Impl( Reference<XMultiServiceFactory>& xFactory, + sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass): + UnoConversionUtilities<IUnknownWrapper_Impl>( xFactory, unoWrapperClass, comWrapperClass), + m_pxIdlClass( NULL), m_pDispatch(NULL), m_eJScript( JScriptUndefined) +{ +} + + +IUnknownWrapper_Impl::~IUnknownWrapper_Impl() +{ + OGuard guard( globalWrapperMutex); + acquire(); // make sure we don't delete us twice + Reference<XInterface> xInt( static_cast<XWeak*>(this), UNO_QUERY); + + // remove entries in global maps + typedef hash_map<sal_uInt32, sal_uInt32>::iterator _IT; + _IT it= WrapperToAdapterMap.find( (sal_uInt32) xInt.get()); + if( it != WrapperToAdapterMap.end()) + { + sal_uInt32 adapter= it->second; + + AdapterToWrapperMap.erase( adapter); + WrapperToAdapterMap.erase( it); + } + + o2u_attachCurrentThread(); + + m_pUnknown->Release(); + if (m_pDispatch) + { + m_pDispatch->Release(); + } + +} + + + +Reference<XIntrospectionAccess> SAL_CALL IUnknownWrapper_Impl::getIntrospection(void) + throw (RuntimeException ) +{ + Reference<XIntrospectionAccess> ret; + + return ret; +} + +DispIdMap::iterator IUnknownWrapper_Impl::getDispIdEntry(const OUString& name) +{ + + DispIdMap::iterator iter = m_dispIdMap.find(name); + + if (iter == m_dispIdMap.end()) + { + unsigned int flags = 0; + HRESULT result; + DISPID dispId; + OLECHAR* oleNames[1]; + + oleNames[0] = (OLECHAR*)name.getStr(); + + result = m_pDispatch->GetIDsOfNames(IID_NULL, + oleNames, + 1, + LOCALE_SYSTEM_DEFAULT, + &dispId); + + if (result == NOERROR) + { + flags |= DISPATCH_METHOD; + flags |= DISPATCH_PROPERTYPUT; + flags |= DISPATCH_PROPERTYPUTREF; + + DISPPARAMS dispparams; + VARIANT varResult; + EXCEPINFO excepinfo; + unsigned int uArgErr; + + VariantInit(&varResult); + + // converting UNO parameters to OLE variants + dispparams.rgdispidNamedArgs = NULL; + dispparams.cArgs = 0; + dispparams.cNamedArgs = 0; + dispparams.rgvarg = NULL; + + // try to invoke PROPERTY_GET to evaluate if this name denotes a property + result = m_pDispatch->Invoke(dispId, + IID_NULL, + LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYGET, + &dispparams, + &varResult, + &excepinfo, + &uArgErr); + + if (result == S_OK) + { + flags |= DISPATCH_PROPERTYGET; + } + + // freeing allocated OLE parameters + VariantClear(&varResult); + + if (flags != 0) + { + iter = ((DispIdMap&)m_dispIdMap).insert( + DispIdMap::value_type(name, pair<DISPID, unsigned short>(dispId, flags))).first; + } + } + } + + return iter; +} + + +Any SAL_CALL IUnknownWrapper_Impl::invoke( const OUString& aFunctionName, + const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, + Sequence< Any >& aOutParam ) + throw(IllegalArgumentException, CannotConvertException, InvocationTargetException, + RuntimeException) +{ + setCurrentInvokeCall( aFunctionName); + + Any ret; + + DispIdMap::iterator iter = getDispIdEntry(aFunctionName); + + if ((iter != m_dispIdMap.end()) && (((*iter).second.second & DISPATCH_METHOD) != 0)) + { + TypeDescription methodDesc; + getMethodInfo( methodDesc ); + if( methodDesc.is()) + ret = invokeWithDispIdUnoTlb((*iter).second.first, + aParams, + aOutParamIndex, + aOutParam); + else + ret= invokeWithDispIdComTlb( (*iter).second.first, //DISPID + aParams, + aOutParamIndex, + aOutParam); + + } + else + throw IllegalArgumentException(); + + return ret; +} + +void SAL_CALL IUnknownWrapper_Impl::setValue( const OUString& aPropertyName, + const Any& aValue ) + throw(UnknownPropertyException, CannotConvertException, InvocationTargetException, + RuntimeException) +{ + + DispIdMap::iterator iter = getDispIdEntry(aPropertyName); + + if ((iter != m_dispIdMap.end()) && (((*iter).second.second & DISPATCH_PROPERTYPUT) != 0)) + { + setValueWithDispId((*iter).second.first, aValue); + } + else + throw UnknownPropertyException(); +} + +Any SAL_CALL IUnknownWrapper_Impl::getValue( const OUString& aPropertyName ) + throw(UnknownPropertyException, RuntimeException) +{ + setCurrentGetCall( aPropertyName); + + Any ret; + + DispIdMap::iterator iter = getDispIdEntry(aPropertyName); + + if (iter != m_dispIdMap.end() && (((*iter).second.second & DISPATCH_PROPERTYGET) != 0)) + { + ret = getValueWithDispId((*iter).second.first); + } + else + throw UnknownPropertyException(); + + return ret; +} + +sal_Bool SAL_CALL IUnknownWrapper_Impl::hasMethod( const OUString& aName ) + throw(RuntimeException) +{ + sal_Bool ret = FALSE; + + o2u_attachCurrentThread(); + + DispIdMap::iterator iter = ((IUnknownWrapper_Impl*)this)->getDispIdEntry(aName); + + ret = ( + (iter != ((IUnknownWrapper_Impl*)this)->m_dispIdMap.end()) && + (((*iter).second.second & DISPATCH_METHOD) != 0) + ); + + return ret; +} + +sal_Bool SAL_CALL IUnknownWrapper_Impl::hasProperty( const OUString& aName ) + throw(RuntimeException) +{ + sal_Bool ret = FALSE; + + o2u_attachCurrentThread(); + + DispIdMap::iterator iter = ((IUnknownWrapper_Impl*)this)->getDispIdEntry(aName); + + ret = ( + (iter != ((IUnknownWrapper_Impl*)this)->m_dispIdMap.end()) && + (((*iter).second.second & DISPATCH_PROPERTYGET) != 0) + ); + + return ret; +} + +Any SAL_CALL IUnknownWrapper_Impl::createBridge( const Any& modelDepObject, + const Sequence< sal_Int8 >& aProcessId, sal_Int16 sourceModelType, + sal_Int16 destModelType ) + throw( IllegalArgumentException, RuntimeException) +{ + Any ret; + + if ( + (sourceModelType == UNO) && + (destModelType == OLE) && + (modelDepObject.getValueTypeClass() == TypeClass_INTERFACE) + ) + { + Reference<XInterface> xInt( *(XInterface**) modelDepObject.getValue()); + Reference<XInterface> xSelf( (OWeakObject*)this); + + if (xInt == xSelf) + { + VARIANT* pVariant = (VARIANT*) CoTaskMemAlloc(sizeof(VARIANT)); + + VariantInit(pVariant); + + if (m_pDispatch != NULL) + { + V_VT(pVariant) = VT_DISPATCH; + V_DISPATCH(pVariant) = m_pDispatch; + m_pDispatch->AddRef(); + } + else + { + V_VT(pVariant) = VT_UNKNOWN; + V_UNKNOWN(pVariant) = m_pUnknown; + m_pUnknown->AddRef(); + } + + ret.setValue((void*)&pVariant, getCppuType( (sal_uInt32*) 0)); + } + } + + return ret; +} + +Any IUnknownWrapper_Impl::invokeWithDispIdUnoTlb(DISPID dispID, + const Sequence< Any >& Params, + Sequence< sal_Int16 >& OutParamIndex, + Sequence< Any >& OutParam) + throw ( IllegalArgumentException, CannotConvertException, + InvocationTargetException, RuntimeException) +{ + Any ret; + HRESULT hr= S_OK; + o2u_attachCurrentThread(); + + + sal_Int32 parameterCount= Params.getLength(); + sal_Int32 outParameterCount= 0; + typelib_InterfaceMethodTypeDescription* pMethod= NULL; + TypeDescription methodDesc; + getMethodInfo( methodDesc); + + // We need to know whether the IDispatch is from a JScript object. + // Then out and in/out parameters have to be treated differently than + // with common COM objects. + sal_Bool bJScriptObject= isJScriptObject(); +// CComDispatchDriver disp( m_pDispatch); + + CComVariant *pVarParams= NULL; + CComVariant *pVarParamsRef= NULL; + sal_Bool bConvOk= sal_True; + sal_Bool bConvRet= sal_True; + + if( methodDesc.is()) + { + pMethod= ( typelib_InterfaceMethodTypeDescription* )methodDesc.get(); + parameterCount= pMethod->nParams; + // Create the Array for the array being passed in DISPPARAMS + // the array also contains the outparameter (but not the values) + if( pMethod->nParams > 0) + pVarParams= new CComVariant[ parameterCount]; + // Create the Array for the out an in/out parameter. These values + // are referenced by the VT_BYREF VARIANTs in DISPPARAMS. + // We need to find out the number of out and in/out parameter. + for( sal_Int32 i=0; i < parameterCount; i++) + { + if( pMethod->pParams[i].bOut) + outParameterCount++; + } + + if( !bJScriptObject) + { + pVarParamsRef= new CComVariant[ outParameterCount]; + // build up the parameters for IDispatch::Invoke + sal_Int32 inParamIndex=0; + sal_Int32 outParamIndex=0; + + for( i= 0; i < parameterCount; i++) + { + + // In parameter + if( pMethod->pParams[i].bIn == sal_True && ! pMethod->pParams[i].bOut) + { + bConvOk= anyToVariant( &pVarParams[parameterCount - i -1], Params[inParamIndex++]); + } + // Out parameter + in/out parameter + else if( pMethod->pParams[i].bOut == sal_True) + { + CComVariant var; + switch( pMethod->pParams[i].pTypeRef->eTypeClass) + { + case TypeClass_INTERFACE: + case TypeClass_STRUCT: + if( pMethod->pParams[i].bIn && (bConvOk= anyToVariant( &var,Params[i]))) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt= VT_DISPATCH; + pVarParamsRef[ outParamIndex].pdispVal= 0; + } + pVarParams[parameterCount - i -1].vt = VT_DISPATCH | VT_BYREF; + pVarParams[parameterCount - i -1].ppdispVal= &pVarParamsRef[outParamIndex].pdispVal; + break; + case TypeClass_ENUM: + case TypeClass_LONG: + case TypeClass_UNSIGNED_LONG: + if( pMethod->pParams[i].bIn && (bConvOk= anyToVariant( &var,Params[i]))) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt = VT_I4; + pVarParamsRef[ outParamIndex].lVal= 0; + } + pVarParams[parameterCount - i -1].vt = VT_I4 | VT_BYREF; + pVarParams[parameterCount - i -1].plVal= &pVarParamsRef[outParamIndex].lVal; + break; + case TypeClass_SEQUENCE: + if( pMethod->pParams[i].bIn && (bConvOk= anyToVariant( &var,Params[i]))) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt = VT_ARRAY| VT_VARIANT; + pVarParamsRef[ outParamIndex].parray= NULL; + } + pVarParams[parameterCount - i -1].vt = VT_ARRAY| VT_BYREF | VT_VARIANT; + pVarParams[parameterCount - i -1].pparray= &pVarParamsRef[outParamIndex].parray; + break; + case TypeClass_ANY: + if( pMethod->pParams[i].bIn && (bConvOk= anyToVariant( &var,Params[i]))) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt = VT_EMPTY; + pVarParamsRef[ outParamIndex].lVal = 0; + } + pVarParams[parameterCount - i -1].vt = VT_VARIANT | VT_BYREF; + pVarParams[parameterCount - i -1].pvarVal= &pVarParamsRef[outParamIndex]; + break; + case TypeClass_BOOLEAN: + if( pMethod->pParams[i].bIn && (bConvOk= anyToVariant( &var,Params[i])) ) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt = VT_BOOL; + pVarParamsRef[ outParamIndex].boolVal = 0; + } + pVarParams[parameterCount - i -1].vt = VT_BOOL| VT_BYREF; + pVarParams[parameterCount - i -1].pboolVal= &pVarParamsRef[outParamIndex].boolVal; + break; + + case TypeClass_STRING: + if( pMethod->pParams[i].bIn && (bConvOk= anyToVariant( &var,Params[i]))) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt = VT_BSTR; + pVarParamsRef[ outParamIndex].bstrVal= 0; + } + pVarParams[parameterCount - i -1].vt = VT_BSTR| VT_BYREF; + pVarParams[parameterCount - i -1].pbstrVal= &pVarParamsRef[outParamIndex].bstrVal; + break; + + case TypeClass_FLOAT: + if( pMethod->pParams[i].bIn && (bConvOk= anyToVariant( &var,Params[i]))) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt = VT_R4; + pVarParamsRef[ outParamIndex].fltVal= 0; + } + pVarParams[parameterCount - i -1].vt = VT_R4| VT_BYREF; + pVarParams[parameterCount - i -1].pfltVal= &pVarParamsRef[outParamIndex].fltVal; + break; + case TypeClass_DOUBLE: + if( pMethod->pParams[i].bIn&& (bConvOk= anyToVariant( &var,Params[i]))) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt = VT_R8; + pVarParamsRef[ outParamIndex].dblVal= 0; + } + pVarParams[parameterCount - i -1].vt = VT_R8| VT_BYREF; + pVarParams[parameterCount - i -1].pdblVal= &pVarParamsRef[outParamIndex].dblVal; + break; + case TypeClass_BYTE: + if( pMethod->pParams[i].bIn && (bConvOk= anyToVariant( &var,Params[i]))) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt = VT_UI1; + pVarParamsRef[ outParamIndex].bVal= 0; + } + pVarParams[parameterCount - i -1].vt = VT_UI1| VT_BYREF; + pVarParams[parameterCount - i -1].pbVal= &pVarParamsRef[outParamIndex].bVal; + break; + case TypeClass_CHAR: + case TypeClass_SHORT: + case TypeClass_UNSIGNED_SHORT: + if( pMethod->pParams[i].bIn&& (bConvOk= anyToVariant( &var,Params[i]))) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt = VT_I2; + pVarParamsRef[ outParamIndex].iVal = 0; + } + pVarParams[parameterCount - i -1].vt = VT_I2| VT_BYREF; + pVarParams[parameterCount - i -1].piVal= &pVarParamsRef[outParamIndex].iVal; + break; + + default: + if( pMethod->pParams[i].bIn && (bConvOk= anyToVariant( &var,Params[i]))) + pVarParamsRef[ outParamIndex]= var; + else + { + pVarParamsRef[ outParamIndex].vt = VT_EMPTY; + pVarParamsRef[ outParamIndex].lVal = 0; + } + pVarParams[parameterCount - i -1].vt = VT_VARIANT | VT_BYREF; + pVarParams[parameterCount - i -1].pvarVal= &pVarParamsRef[outParamIndex]; + } + outParamIndex++; + } // end else if + if( ! bConvOk) break; + } // end for + } + else // it is an JScriptObject + { + sal_Int32 inParamIndex= 0; + for( sal_Int32 i= 0; i< parameterCount; i++) + { + // In parameter + if( pMethod->pParams[i].bIn == sal_True && ! pMethod->pParams[i].bOut) + { + bConvOk= anyToVariant( &pVarParams[parameterCount - i -1], Params[inParamIndex++]); + } + // Out parameter + in/out parameter + else if( pMethod->pParams[i].bOut == sal_True) + { + CComObject<JScriptOutParam>* pParamObject; + if( SUCCEEDED( CComObject<JScriptOutParam>::CreateInstance( &pParamObject))) + { + CComPtr<IUnknown> pUnk(pParamObject->GetUnknown()); + CComQIPtr<IDispatch> pDisp( pUnk); + + pVarParams[ parameterCount - i -1].vt= VT_DISPATCH; + pVarParams[ parameterCount - i -1].pdispVal= pDisp; + pVarParams[ parameterCount - i -1].pdispVal->AddRef(); + // if the param is in/out then put the parameter on index 0 + if( pMethod->pParams[i].bIn == sal_True ) // in / out + { + CComVariant varParam; + bConvOk= anyToVariant( &varParam, Params[ inParamIndex++]); + if( bConvOk) + { + CComDispatchDriver dispDriver( pDisp); + if( pDisp) + if( FAILED( dispDriver.PutPropertyByName( L"0", &varParam))) + bConvOk= sal_False; + } + } + } + } + if( ! bConvOk) break; + } + } + } + // No type description Available, that is we have to deal with a COM component, + // that does not implements UNO interfaces ( IDispatch based) + else + { + if( parameterCount) + { + pVarParams= new CComVariant[parameterCount]; + CComVariant var; + for( sal_Int32 i= 0; i < parameterCount; i++) + { + var.Clear(); + if( bConvOk= anyToVariant( &var, Params[i])) + pVarParams[ parameterCount - 1 -i]= var; + } + } + } + + if( bConvOk) + { + CComVariant varResult; + EXCEPINFO excepinfo; + unsigned int uArgErr; + DISPPARAMS dispparams= { pVarParams, NULL, parameterCount, 0}; + // invoking OLE method + hr = m_pDispatch->Invoke(dispID, + IID_NULL, + LOCALE_SYSTEM_DEFAULT, + DISPATCH_METHOD, + &dispparams, + &varResult, + &excepinfo, + &uArgErr); + + // converting return value and out parameter back to UNO + if (hr == S_OK) + { + if( outParameterCount && pMethod) + { + OutParamIndex.realloc( outParameterCount); + OutParam.realloc( outParameterCount); + sal_Int32 outIndex=0; + for( sal_Int32 i= 0; i < parameterCount; i++) + { + if( pMethod->pParams[i].bOut ) + { + OutParamIndex[outIndex]= i; + Any outAny; + if( !bJScriptObject) + { + if( bConvRet= variantToAny2( &pVarParamsRef[outIndex], outAny, + Type(pMethod->pParams[i].pTypeRef), sal_False)) + OutParam[outIndex++]= outAny; + + } + else //JScriptObject + { + if( pVarParams[i].vt= VT_DISPATCH) + { + CComDispatchDriver pDisp( pVarParams[i].pdispVal); + if( pDisp) + { + CComVariant varOut; + if( SUCCEEDED( pDisp.GetPropertyByName( L"0", &varOut))) + { + if( bConvRet= variantToAny2( &varOut, outAny, + Type(pMethod->pParams[parameterCount - 1 - i].pTypeRef), sal_False)) + OutParam[outParameterCount - 1 - outIndex++]= outAny; + + } + else + bConvRet= sal_False; + } + else + bConvRet= sal_False; + } + else + bConvRet= sal_False; + } + } + if( !bConvRet) break; + } + } + // return value, no type information available + if ( bConvRet) + if( pMethod ) + bConvRet= variantToAny2(&varResult, ret, Type( pMethod->pReturnTypeRef), sal_False); + else + bConvRet= variantToAny(&varResult, ret, sal_False); + } + + if( pVarParams) + delete[] pVarParams; + // The destructor of CComVariant calls VariantClear which takes null pointers into account + // and does not try to destroy them. + if( pVarParamsRef) + delete[] pVarParamsRef; + + if( !bConvRet) // conversion of return or out parameter failed + throw CannotConvertException( L"Call to COM object failed. Conversion of return or out value failed", + Reference<XInterface>( static_cast<XWeak*>(this), UNO_QUERY ), TypeClass_UNKNOWN, + FailReason::UNKNOWN, 0);// lookup error code + // conversion of return or out parameter failed + switch (hr) + { + case S_OK: + break; + case DISP_E_BADPARAMCOUNT: + throw IllegalArgumentException(); + break; + case DISP_E_BADVARTYPE: + throw RuntimeException(); + break; + case DISP_E_EXCEPTION: + throw InvocationTargetException(); + break; + case DISP_E_MEMBERNOTFOUND: + throw IllegalArgumentException(); + break; + case DISP_E_NONAMEDARGS: + throw IllegalArgumentException(); + break; + case DISP_E_OVERFLOW: + throw CannotConvertException(L"call to OLE object failed", static_cast<XInterface*>( + static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::OUT_OF_RANGE, uArgErr); + break; + case DISP_E_PARAMNOTFOUND: + throw IllegalArgumentException(L"call to OLE object failed", static_cast<XInterface*>( + static_cast<XWeak*>(this)), uArgErr); + break; + case DISP_E_TYPEMISMATCH: + throw CannotConvertException(L"call to OLE object failed",static_cast<XInterface*>( + static_cast<XWeak*>(this)) , TypeClass_UNKNOWN, FailReason::UNKNOWN, uArgErr); + break; + case DISP_E_UNKNOWNINTERFACE: + throw RuntimeException() ; + break; + case DISP_E_UNKNOWNLCID: + throw RuntimeException() ; + break; + case DISP_E_PARAMNOTOPTIONAL: + throw CannotConvertException(L"call to OLE object failed", static_cast<XInterface*>( + static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::NO_DEFAULT_AVAILABLE, uArgErr); + break; + default: + throw RuntimeException(); + break; + } + } + if( !bConvOk) // conversion of parameters failed + { + if( pVarParams) + delete [] pVarParams; + if( pVarParamsRef) + delete [] pVarParamsRef; + throw CannotConvertException( L"Call to COM object failed. Conversion of in or in/out parameters failed", + Reference<XInterface>( static_cast<XWeak*>(this), UNO_QUERY ), TypeClass_UNKNOWN, + FailReason::UNKNOWN, 0); + } + + return ret; +} + +void IUnknownWrapper_Impl::setValueWithDispId(DISPID dispID, + const Any& Value) + throw (UnknownPropertyException, + CannotConvertException, + InvocationTargetException, + RuntimeException) +{ + HRESULT hr= S_OK; + DISPPARAMS dispparams; + VARIANT varResult; + EXCEPINFO excepinfo; + unsigned int uArgErr; + + o2u_attachCurrentThread(); + + VariantInit(&varResult); + + // converting UNO value to OLE variant + DISPID dispidPut= DISPID_PROPERTYPUT; + dispparams.rgdispidNamedArgs = &dispidPut; + dispparams.cArgs = 1; + dispparams.cNamedArgs = 1; + + dispparams.rgvarg = (VARIANTARG*)malloc(sizeof(VARIANTARG)); + + anyToVariant(&(dispparams.rgvarg[0]), Value); + + // set OLE property + hr = m_pDispatch->Invoke(dispID, + IID_NULL, + LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, + &dispparams, + &varResult, + &excepinfo, + &uArgErr); + + // freeing allocated OLE parameters + VariantClear(&(dispparams.rgvarg[0])); + free(dispparams.rgvarg); + VariantClear(&varResult); + + // lookup error code + switch (hr) + { + case S_OK: + break; + case DISP_E_BADPARAMCOUNT: + throw RuntimeException(); + break; + case DISP_E_BADVARTYPE: + throw RuntimeException(); + break; + case DISP_E_EXCEPTION: + throw InvocationTargetException(); + break; + case DISP_E_MEMBERNOTFOUND: + throw UnknownPropertyException(); + break; + case DISP_E_NONAMEDARGS: + throw RuntimeException(); + break; + case DISP_E_OVERFLOW: + throw CannotConvertException(L"call to OLE object failed", static_cast<XInterface*>( + static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::OUT_OF_RANGE, uArgErr); + break; + case DISP_E_PARAMNOTFOUND: + throw IllegalArgumentException(L"call to OLE object failed", static_cast<XInterface*>( + static_cast<XWeak*>(this)), uArgErr) ; + break; + case DISP_E_TYPEMISMATCH: + throw CannotConvertException(L"call to OLE object failed", static_cast<XInterface*>( + static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::UNKNOWN, uArgErr); + break; + case DISP_E_UNKNOWNINTERFACE: + throw RuntimeException(); + break; + case DISP_E_UNKNOWNLCID: + throw RuntimeException(); + break; + case DISP_E_PARAMNOTOPTIONAL: + throw CannotConvertException(L"call to OLE object failed",static_cast<XInterface*>( + static_cast<XWeak*>(this)) , TypeClass_UNKNOWN, FailReason::NO_DEFAULT_AVAILABLE, uArgErr); + break; + default: + throw RuntimeException(); + break; + } +} + +Any IUnknownWrapper_Impl::getValueWithDispId(DISPID dispID) + throw (UnknownPropertyException,RuntimeException) +{ + Any ret; + HRESULT hr; + DISPPARAMS dispparams; + VARIANT varResult; + EXCEPINFO excepinfo; + unsigned int uArgErr; + + o2u_attachCurrentThread(); + + VariantInit(&varResult); + + // converting UNO parameters to OLE variants + dispparams.rgdispidNamedArgs = NULL; + dispparams.cArgs = 0; + dispparams.cNamedArgs = 0; + dispparams.rgvarg = NULL; + + // invoking OLE method + hr = m_pDispatch->Invoke(dispID, + IID_NULL, + LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYGET, + &dispparams, + &varResult, + &excepinfo, + &uArgErr); + + // converting return value and out parameter back to UNO + if (hr == S_OK) + { + variantToAny(&varResult, ret); + } + + // freeing allocated OLE parameters + VariantClear(&varResult); + + // lookup error code + switch (hr) + { + case S_OK: + break; + case DISP_E_BADPARAMCOUNT: + throw RuntimeException(); + break; + case DISP_E_BADVARTYPE: + throw RuntimeException(); + break; + case DISP_E_EXCEPTION: + throw RuntimeException(); + break; + case DISP_E_MEMBERNOTFOUND: + throw UnknownPropertyException(); + break; + case DISP_E_NONAMEDARGS: + throw RuntimeException(); + break; + case DISP_E_OVERFLOW: + throw RuntimeException(); + break; + case DISP_E_PARAMNOTFOUND: + throw RuntimeException(); + break; + case DISP_E_TYPEMISMATCH: + throw RuntimeException(); + break; + case DISP_E_UNKNOWNINTERFACE: + throw RuntimeException(); + break; + case DISP_E_UNKNOWNLCID: + throw RuntimeException(); + break; + case DISP_E_PARAMNOTOPTIONAL: + throw RuntimeException(); + break; + default: + throw RuntimeException(); + break; + } + + return ret; +} + + + // -------------------------- +// XInitialization +void SAL_CALL IUnknownWrapper_Impl::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException) +{ + // 1.parameter is IUnknown + // 2.parameter is a Sequence<Type> ( not mandatory) + HRESULT result; + o2u_attachCurrentThread(); + + if( aArguments.getLength() == 1) + { + m_pUnknown= *(IUnknown**) aArguments[0].getValue(); + result = m_pUnknown->QueryInterface(IID_IDispatch, (void**) &m_pDispatch); + m_pUnknown->AddRef(); + } + else if( aArguments.getLength() == 2) + { + m_pUnknown= *(IUnknown**) aArguments[0].getValue(); + result = m_pUnknown->QueryInterface(IID_IDispatch, (void**) &m_pDispatch); + m_pUnknown->AddRef(); + + aArguments[1] >>= m_seqTypes; + } + +} + +// UnoConversionUtilities -------------------------------------------------------------------------------- +Reference< XInterface > IUnknownWrapper_Impl::createUnoWrapperInstance() +{ + if( m_nUnoWrapperClass == INTERFACE_OLE_WRAPPER_IMPL) + { + Reference<XWeak> xWeak= static_cast<XWeak*>( new InterfaceOleWrapper_Impl( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); + } + else if( m_nUnoWrapperClass == UNO_OBJECT_WRAPPER_REMOTE_OPT) + { + Reference<XWeak> xWeak= static_cast<XWeak*>( new UnoObjectWrapperRemoteOpt( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); + } + else + return Reference<XInterface>(); +} +Reference<XInterface> IUnknownWrapper_Impl::createComWrapperInstance() +{ + Reference<XWeak> xWeak= static_cast<XWeak*>( new IUnknownWrapper_Impl( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); +} + + + +void IUnknownWrapper_Impl::getMethodInfo( TypeDescription& methodInfo) +{ + TypeDescription desc= getInterfaceMemberDescOfCurrentCall(); + if( desc.is()) + { + typelib_TypeDescription* pMember= desc.get(); + if( pMember->eTypeClass == TypeClass_INTERFACE_METHOD ) + methodInfo= pMember; + } +} + +TypeDescription IUnknownWrapper_Impl::getInterfaceMemberDescOfCurrentCall( ) +{ + TypeDescription ret; + OUString usCurrentCall; + if( m_usCurrentInvoke.getLength()) + { + usCurrentCall= m_usCurrentInvoke; + } + else + { + usCurrentCall= m_usCurrentGet; + } + OSL_ENSURE( usCurrentCall.getLength() != 0, ""); + + for( sal_Int32 i=0; i < m_seqTypes.getLength(); i++) + { + TypeDescription _curDesc( m_seqTypes[i]); + typelib_InterfaceTypeDescription * pInterface= (typelib_InterfaceTypeDescription*) _curDesc.get(); + if( pInterface) + { + typelib_InterfaceMemberTypeDescription* pMember= NULL; + //find the member description of the current call + for( int i=0; i < pInterface->nAllMembers; i++) + { + typelib_TypeDescriptionReference* pTypeRefMember = pInterface->ppAllMembers[i]; + typelib_TypeDescription* pDescMember= NULL; + TYPELIB_DANGER_GET( &pDescMember, pTypeRefMember) + + typelib_InterfaceMemberTypeDescription* pInterfaceMember= + (typelib_InterfaceMemberTypeDescription*) pDescMember; + if( OUString( pInterfaceMember->pMemberName) == usCurrentCall) + { + pMember= pInterfaceMember; + break; + } + TYPELIB_DANGER_RELEASE( pDescMember) + } + + if( pMember) + { + ret= (typelib_TypeDescription*)pMember; + TYPELIB_DANGER_RELEASE( (typelib_TypeDescription*)pMember); + } + } + if( ret.is()) + break; + } + return ret; +} + +sal_Bool IUnknownWrapper_Impl::isJScriptObject() +{ + if( m_eJScript == JScriptUndefined) + { + CComDispatchDriver disp( m_pDispatch); + if( disp) + { + CComVariant result; + if( SUCCEEDED( disp.GetPropertyByName( JSCRIPT_ID_PROPERTY, &result))) + { + if(result.vt == VT_BSTR) + { + CComBSTR name( result.bstrVal); + name.ToLower(); + if( name == JSCRIPT_ID) + m_eJScript= IsJScript; + } + } + } + if( m_eJScript == JScriptUndefined) + m_eJScript= NoJScript; + } + + return m_eJScript == NoJScript ? sal_False : sal_True; +} + +// check for all changed parameter and create UNO out parameters +void IUnknownWrapper_Impl::processOutParameters(VARIANT* pOrgParams, + VARIANT* pResultParams, + sal_uInt32 n, + Sequence< sal_Int16 >& OutParamIndex, + Sequence< Any >& OutParam) +{ + for (sal_uInt32 i = 0; i < n; i++) + { + VARIANT* pOrgElement = &(pOrgParams[n - (i + 1)]); + VARIANT* pResultElement = &(pResultParams[n - (i + 1)]); + Any aOutParam; + + // check for changes in element + if (memcmp(pOrgElement, pResultElement, sizeof(VARIANT)) != 0) + { + // out parameters are only valid if the new type matches the original type + if (V_VT(pOrgElement) == V_VT(pResultElement)) + { + variantToAny(pResultElement, aOutParam); + } + } + +// if (aOutParam.getReflection() != Void_getReflection()) + if( aOutParam.getValueTypeClass() != TypeClass_VOID) + { + sal_uInt32 outParamCount = OutParam.getLength() + 1; + + OutParam.realloc(outParamCount); + OutParamIndex.realloc(outParamCount); + + OutParam.getArray()[outParamCount - 1] = aOutParam; + OutParamIndex.getArray()[outParamCount - 1] = i; + } + } +} + + +// It would be desirable if every COM component could handle parameters of VT_BYREF be it +// in or out parameter. But that is not the case. When calling an ATL component that +// has a dual interface then note this: +// - in parameter can be VT_BYREF +// - in parameter of VARIANT: one can pass the exact type +// - out parameter: one must pass the exact type +// - out parameter of VARIANT: the referenced VARIANT must be VT_EMPTY +// - inout - the same as out +Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(DISPID dispID, + const Sequence< Any >& Params, + Sequence< sal_Int16 >& OutParamIndex, + Sequence< Any >& OutParam) + throw ( IllegalArgumentException, CannotConvertException, + InvocationTargetException, RuntimeException) +{ + Any ret; + HRESULT result; + + DISPPARAMS dispparams; + CComVariant varResult; + EXCEPINFO excepinfo; + unsigned int uArgErr; + sal_uInt32 i; + + o2u_attachCurrentThread(); + + // converting UNO parameters to OLE variants + dispparams.rgdispidNamedArgs = NULL; + dispparams.cArgs = Params.getLength(); + dispparams.cNamedArgs = 0; + + CComVariant* arArgs = NULL; + CComVariant* arRefArgs= NULL; // referenced arguments + + if (dispparams.cArgs == 0) + { + dispparams.rgvarg = NULL; + } + else + { + arArgs = new CComVariant[dispparams.cArgs]; + arRefArgs= new CComVariant[dispparams.cArgs]; + + // converting orginal parameters + // if the object uses ATL with a dual interface, then VT_VARIANT| VT_BYREF does not suffice +// prepareOutParams( orgArgs, dispparams.cArgs); + getParameterInfo(); + + for (i = 0; i < dispparams.cArgs; i++) + { + sal_Int32 revIndex= dispparams.cArgs - i -1; + arRefArgs[revIndex].byref=0; + // out param + if (m_seqCurrentParamTypes[i] & PARAMFLAG_FOUT && + ! (m_seqCurrentParamTypes[i] & PARAMFLAG_FIN) ) + { + VARTYPE type= m_seqCurrentVartypes[i] ^ VT_BYREF; + if( type == VT_VARIANT ) + { + arArgs[revIndex].vt= VT_VARIANT | VT_BYREF; + arArgs[revIndex].byref= &arRefArgs[revIndex]; + } + else + { + arRefArgs[revIndex].vt= type; + arArgs[revIndex].vt= m_seqCurrentVartypes[i]; + arArgs[revIndex].byref= &arRefArgs[revIndex].byref; + } + } + // in/out param + else if( m_seqCurrentParamTypes[i] & PARAMFLAG_FOUT&& + m_seqCurrentParamTypes[i] & PARAMFLAG_FIN) + { + VARTYPE type= m_seqCurrentVartypes[i] ^ VT_BYREF; + CComVariant var; + anyToVariant( &arRefArgs[revIndex], + Params.getConstArray()[i]); + + if( type == VT_VARIANT ) + { + arArgs[revIndex].vt= VT_VARIANT | VT_BYREF; + arArgs[revIndex].byref= &arRefArgs[revIndex]; + } + else + { + arArgs[revIndex].vt= arRefArgs[revIndex].vt | VT_BYREF; + arArgs[revIndex].byref= &arRefArgs[revIndex].byref; + } + } + // in/param + else if( m_seqCurrentParamTypes[i] & PARAMFLAG_FIN && + ! (m_seqCurrentParamTypes[i] & PARAMFLAG_FOUT)) + { + if( m_seqCurrentVartypes[i] & VT_BYREF) + anyToVariant( &arRefArgs[revIndex], + Params.getConstArray()[i]); + else + anyToVariant( &arArgs[revIndex], + Params.getConstArray()[i]); + } + + } + } + dispparams.rgvarg= arArgs; + // invoking OLE method + result = m_pDispatch->Invoke(dispID, + IID_NULL, + LOCALE_SYSTEM_DEFAULT, + DISPATCH_METHOD | DISPATCH_PROPERTYGET, + &dispparams, + &varResult, + &excepinfo, + &uArgErr); + + // converting return value and out parameter back to UNO + if (result == S_OK) + { + if ( m_seqCurrentParamTypes.getLength()) + { + // allocate space for the out param Sequence and indices Sequence + sal_Int32 outParamsCount= 0; // includes in/out parameter + for( sal_Int32 iparams=0; iparams < m_seqCurrentParamTypes.getLength(); iparams++) + { + if( m_seqCurrentParamTypes[iparams] & PARAMFLAG_FOUT) + outParamsCount++; + } + + OutParamIndex.realloc( outParamsCount); + OutParam.realloc( outParamsCount); + + sal_Int32 outParamIndex=0; + for( sal_Int32 i=0; i < m_seqCurrentParamTypes.getLength(); i ++) + { + if( m_seqCurrentParamTypes[i] & PARAMFLAG_FOUT) + { + OutParamIndex[outParamIndex]= i; + variantToAny( &arRefArgs[dispparams.cArgs - i -1], OutParam[outParamIndex] ); + outParamIndex++; + } + } + } + // Return value + variantToAny(&varResult, ret); + } + + // lookup error code + switch (result) + { + case S_OK: + break; + case DISP_E_BADPARAMCOUNT: + throw IllegalArgumentException(); + break; + case DISP_E_BADVARTYPE: + throw RuntimeException(); + break; + case DISP_E_EXCEPTION: + throw InvocationTargetException(); + break; + case DISP_E_MEMBERNOTFOUND: + throw IllegalArgumentException(); + break; + case DISP_E_NONAMEDARGS: + throw IllegalArgumentException(); + break; + case DISP_E_OVERFLOW: + throw CannotConvertException(L"call to OLE object failed", static_cast<XInterface*>( + static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::OUT_OF_RANGE, uArgErr); + break; + case DISP_E_PARAMNOTFOUND: + throw IllegalArgumentException(L"call to OLE object failed", static_cast<XInterface*>( + static_cast<XWeak*>(this)), uArgErr); + break; + case DISP_E_TYPEMISMATCH: + throw CannotConvertException(L"call to OLE object failed",static_cast<XInterface*>( + static_cast<XWeak*>(this)) , TypeClass_UNKNOWN, FailReason::UNKNOWN, uArgErr); + break; + case DISP_E_UNKNOWNINTERFACE: + throw RuntimeException() ; + break; + case DISP_E_UNKNOWNLCID: + throw RuntimeException() ; + break; + case DISP_E_PARAMNOTOPTIONAL: + throw CannotConvertException(L"call to OLE object failed", static_cast<XInterface*>( + static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::NO_DEFAULT_AVAILABLE, uArgErr); + break; + default: + throw RuntimeException(); + break; + } + + return ret; +} +// parameter is an array that contains the referenced parameters +// params is an array of VARIANTs that contains values which are referenced by +// the VARIANTS in DISPPARAMS::rgvarg +//sal_Bool IUnknownWrapper_Impl::prepareOutParams( VARIANT* params, sal_uInt32 count ) +//{ +// sal_Bool ret= sal_True; +// ITypeInfo* pType= getTypeInfo(); +// if(! pType ) +// return sal_False; +// // build the map of function names and their tlb index +// if( sal_False == isComTlbIndex()) +// buildComTlbIndex(); +// +// typedef TLBFuncIndexMap::const_iterator cit; +// cit itIndex= m_mapComFunc.find( m_usCurrentInvoke ); +// if( itIndex != m_mapComFunc.end()) +// { +// FUNCDESC* funcDesc= NULL; +// if( SUCCEEDED( pType->GetFuncDesc( itIndex->second, &funcDesc))) +// { +// m_seqCurrentParamTypes.realloc( funcDesc->cParams); +// // Examine each param +// for( sal_Int16 iparams= 0; iparams < funcDesc->cParams; iparams++) +// { +// sal_Int32 flags= funcDesc->lprgelemdescParam->paramdesc.wParamFlags; +// +// // out parameter +// if( flags & PARAMFLAG_FOUT && +// ! (flags & PARAMFLAG_FIN)) +// { +// m_seqCurrentParamTypes[ iparams]= (sal_Int32) OUT_PARAM; +// VariantClear( ¶ms[iparams] ); +// params[ iparams].byref=0; +// // Get the type +// VARTYPE paramType; +// if( getElementTypeDesc( & funcDesc->lprgelemdescParam[iparams].tdesc, paramType)) +// { +// // dispparams: VT_VARIANT |VT_BYREF , referenced Value: VT_EMPTY +// if( !( paramType & VT_ARRAY) && +// (paramType & VT_TYPEMASK) == VT_VARIANT) +// params[iparams].vt= VT_EMPTY; +// else +// params[iparams].vt= (paramType ^ VT_BYREF); +// } +// else +// ret= sal_False; +// } +// // in/out parameter +// else if(flags & PARAMFLAG_FIN && flags & PARAMFLAG_FOUT ) +// m_seqCurrentParamTypes[ iparams]= (sal_Int32) INOUT_PARAM; +// // in parameter +// else if(flags & PARAMFLAG_FIN && ! (flags & PARAMFLAG_FOUT )) +// m_seqCurrentParamTypes[ iparams]= (sal_Int32) IN_PARAM; +// } +// pType->ReleaseFuncDesc( funcDesc); +// } +// else +// ret= sal_False; +// } +// else +// ret= sal_False; +// +// return ret; +//} + +sal_Bool IUnknownWrapper_Impl::getParameterInfo() +{ + sal_Bool ret= sal_True; + ITypeInfo* pType= getTypeInfo(); + if(! pType ) + return sal_False; + // build the map of function names and their tlb index + if( sal_False == isComTlbIndex()) + buildComTlbIndex(); + + typedef TLBFuncIndexMap::const_iterator cit; + cit itIndex= m_mapComFunc.find( m_usCurrentInvoke ); + if( itIndex != m_mapComFunc.end()) + { + FUNCDESC* funcDesc= NULL; + if( SUCCEEDED( pType->GetFuncDesc( itIndex->second, &funcDesc))) + { + m_seqCurrentParamTypes.realloc( funcDesc->cParams); + m_seqCurrentVartypes.realloc( funcDesc->cParams); + // Examine each param + for( sal_Int16 iparams= 0; iparams < funcDesc->cParams; iparams++) + { + sal_Int32 flags= funcDesc->lprgelemdescParam[iparams].paramdesc.wParamFlags; + m_seqCurrentParamTypes[iparams]= flags & ( PARAMFLAG_FIN | PARAMFLAG_FOUT); + + if( ! getElementTypeDesc( & funcDesc->lprgelemdescParam[iparams].tdesc, + m_seqCurrentVartypes[iparams])) + ret= sal_False; + + if( ! ret) break; + } + pType->ReleaseFuncDesc( funcDesc); + } + else + ret= sal_False; + } + else + ret= sal_False; + + return ret; +} + +sal_Bool IUnknownWrapper_Impl::getElementTypeDesc( TYPEDESC *desc, VARTYPE& varType ) +{ + sal_Bool ret= sal_True; + VARTYPE _type; + + if( desc->vt == VT_PTR) + { + if( getElementTypeDesc( desc->lptdesc, _type)) + varType= _type | VT_BYREF; + else + ret= sal_False; + } + else if( desc->vt == VT_SAFEARRAY ) + { + if( getElementTypeDesc( desc->lptdesc, _type)) + varType= _type | VT_ARRAY; + else + sal_False; + } + else + { + varType= desc->vt; + } + return ret; +} + +sal_Bool IUnknownWrapper_Impl::buildComTlbIndex() +{ + sal_Bool ret= sal_True; + + ITypeInfo* pType= getTypeInfo(); + if( pType) + { + TYPEATTR* typeAttr= NULL; + if( SUCCEEDED( pType->GetTypeAttr( &typeAttr))) + { + for( long i= 0; i < typeAttr->cFuncs; i++) + { + FUNCDESC* funcDesc= NULL; + if( SUCCEEDED( pType->GetFuncDesc( i, &funcDesc))) + { + BSTR memberName= NULL; + unsigned int pcNames=0; + if( SUCCEEDED(pType->GetNames( funcDesc->memid, & memberName, 1, &pcNames))) + { + m_mapComFunc.insert( TLBFuncIndexMap::value_type( OUString( memberName), i)); + SysFreeString( memberName); + } + else + ret= sal_False; + pType->ReleaseFuncDesc( funcDesc); + } + else + ret=sal_False; + } + pType->ReleaseTypeAttr( typeAttr); + } + else + ret= sal_False; + } + else + ret= sal_False; + return ret; +} + +inline sal_Bool IUnknownWrapper_Impl::isComTlbIndex() +{ + if( m_mapComFunc.size()) + return sal_True; + return sal_False; +} + +ITypeInfo* IUnknownWrapper_Impl::getTypeInfo() +{ + HRESULT hr= S_OK; + if( !m_pDispatch) + return NULL; + + if( !m_spTypeInfo ) + { + LCID localId= GetUserDefaultLCID(); + CComPtr< ITypeInfo > spType; + if( SUCCEEDED( m_pDispatch->GetTypeInfo( 0, localId, &spType.p))) + m_spTypeInfo= spType; + } + return m_spTypeInfo; +} +} // end namespace + diff --git a/extensions/source/ole/oleobjw.hxx b/extensions/source/ole/oleobjw.hxx new file mode 100644 index 000000000000..dee2f35fc064 --- /dev/null +++ b/extensions/source/ole/oleobjw.hxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * $RCSfile: oleobjw.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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 __OLEOBJW_HXX +#define __OLEOBJW_HXX +#include "ole2uno.hxx" + +#include <tools/presys.h> +#include "stdafx.h" +#include <vector> +#include <hash_map> +#include <tools/postsys.h> + +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include <cppuhelper/implbase3.hxx> +#endif +#include <com/sun/star/lang/XInitialization.hpp> +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#include <typelib/typedescription.hxx> +#include "unoconversionutilities.hxx" + +using namespace cppu; +using namespace rtl; +using namespace std; +using namespace com::sun::star::lang; +using namespace com::sun::star::bridge; + +namespace ole_adapter +{ + + + +typedef hash_map<OUString, pair<DISPID, unsigned short>, hashOUString_Impl, equalOUString_Impl> DispIdMap; + +typedef hash_map<OUString, unsigned int, hashOUString_Impl, equalOUString_Impl> TLBFuncIndexMap; + +// This class wraps an IDispatch and maps XInvocation calls to IDispatch calls on the wrapped object. +// If m_TypeDescription is set then this class represents an UNO interface implemented in a COM component. +// The interface is not a real interface in terms of an abstract class but is realized through IDispatch. +class IUnknownWrapper_Impl : public WeakImplHelper3<XInvocation, XBridgeSupplier2, XInitialization>, + public UnoConversionUtilities<IUnknownWrapper_Impl> + +{ +public: + IUnknownWrapper_Impl(Reference<XMultiServiceFactory> &xFactory, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass); + + ~IUnknownWrapper_Impl(); + + // XIdlClassProvider +// virtual Sequence< Reference<XIdlClass > > getIdlClasses( void ); + + // XInvokation + virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection( ) throw(RuntimeException); + virtual Any SAL_CALL invoke( const OUString& aFunctionName, const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw(IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException); + virtual void SAL_CALL setValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException); + virtual Any SAL_CALL getValue( const OUString& aPropertyName ) throw(UnknownPropertyException, RuntimeException); + virtual sal_Bool SAL_CALL hasMethod( const OUString& aName ) throw(RuntimeException); + virtual sal_Bool SAL_CALL hasProperty( const OUString& aName ) throw(RuntimeException); + + // XBridgeSupplier2 + // This interface is implemented to provide a safe way to obtain the original + // IUnknown or IDispatch within the function anyToVariant. The function asks + // every UNO object for its XBridgeSupplier and if it is available uses it to convert + // the object with its own supplier. + virtual Any SAL_CALL createBridge( const Any& modelDepObject, const Sequence< sal_Int8 >& aProcessId, sal_Int16 sourceModelType, sal_Int16 destModelType ) throw(IllegalArgumentException, RuntimeException); + + // XInitialization + virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException); + + // XUnoTunnel ------------------------------------------------------------------------------------------ +// virtual sal_Int64 SAL_CALL getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw( RuntimeException); + + // Helper for XUnoTunnel -------------------------------------------------------------------------------- +// static Sequence<sal_Int8> getUnoTunnelId(); + + virtual Any invokeWithDispIdUnoTlb(DISPID dispID, const Sequence< Any >& Params, Sequence<sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam) throw (IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException); + // Is used for OleClient service + virtual Any invokeWithDispIdComTlb(DISPID dispID, + const Sequence< Any >& Params, + Sequence< sal_Int16 >& OutParamIndex, + Sequence< Any >& OutParam) + throw ( IllegalArgumentException, CannotConvertException, + InvocationTargetException, RuntimeException); + void processOutParameters( VARIANT* pOrgParams, + VARIANT* pResultParams, + sal_uInt32 n, + Sequence< sal_Int16 >& OutParamIndex, + Sequence< Any >& OutParam); + + virtual void setValueWithDispId(DISPID dispID, const Any& Value) throw ( UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException); + virtual Any getValueWithDispId(DISPID dispID) throw (UnknownPropertyException, RuntimeException ); + + + // UnoConversionUtilities ------------------------------------------------------------------------------- + virtual Reference<XInterface> createUnoWrapperInstance(); + virtual Reference<XInterface> createComWrapperInstance(); +protected: + + // These functions are for the case if an object of this class wraps an IDispatch + // object that implements UNO interfaces. In that case the member m_seqTypes + // is set through XInitialization::initialize. + void getMethodInfo( TypeDescription& methodDescription); + // used by get MethodInfo + TypeDescription getInterfaceMemberDescOfCurrentCall( ); + ITypeInfo* getTypeInfo(); + + + // Gets information about the parameter types ( VARTYPE) and mode ( in, out, in/out) + sal_Bool getParameterInfo(); + // analyses the type information provided by the COM component and saves the idizes of the + // out and in/out parameter in the member m_outIndizes +// sal_Bool prepareOutParams( VARIANT* params, sal_uInt32 count ); + // Builds up the complete vartype from a TYPEDESC, e.g VT_BSTR, VT_BYREF | VT_I4, VT_BYREF|VT_ARRAY|VT_I1 + sal_Bool getElementTypeDesc( TYPEDESC *desc, VARTYPE& varType ); + // Iterates over all functions and put the names and indices into a map (TLBFuncIndexMap) + sal_Bool buildComTlbIndex(); + // Determines whether the map m_mapComFunc has already been set up + sal_Bool isComTlbIndex(); + + // The information is necessary for getReturnType and getOutParameterType because they obtain + // the information for the current call on Invocation. + void setCurrentInvokeCall( const OUString& name){ m_usCurrentGet=L""; m_usCurrentInvoke= name;} + void setCurrentGetCall( const OUString& name){ m_usCurrentInvoke= L""; m_usCurrentGet= name;} + + // Finds out wheter the wrapped IDispatch is an JScript Object. This is is done by + // asking for the property "_environment". If it has the value "JScript" ( case insensitive) + // then the IDispatch is considered a JScript object. + sal_Bool isJScriptObject(); + // ------------------------------------------------------------------------------- + +// void processOutParameters( VARIANT* pOrgParams, +// VARIANT* pResultParams, +// sal_uInt32 n, +// Sequence< sal_Int16 >& OutParamIndex, +// Sequence< Any >& OutParam); + + + + DispIdMap::iterator getDispIdEntry(const OUString& name); + // If UNO interfaces are being implemented in JScript objects, VB or C++ COM objects + // and those are passed as parameter to a UNO interface function, then + // the IDispatch* are wrapped by objects of this class. Assuming that the functions + // implemented by the IDispatch object returns another UNO interface then + // it has to be wrapped to this type. But this is only possible if an object of this + // wrapper class knows what type it is represting. The member m_TypeDescription holds this + // information. + // m_TypeDescription is only useful when an object wrapps an IDispatch object that implements + // an UNO interface. The value is set during a call to XInitialization::initialize. + Sequence<Type> m_seqTypes; + IUnknown* m_pUnknown; + IDispatch* m_pDispatch; + DispIdMap m_dispIdMap; + Reference<XIdlClass>* m_pxIdlClass; + Mutex m_mutex; + + // see prepare OutParams + Sequence< sal_Int16 > m_seqOutIndizes; + // The name of the function being executed ( invoke) + OUString m_usCurrentInvoke; + // The name of the property being retrieved ( getValue) + OUString m_usCurrentGet; + // used by isJScriptObject + enum JScriptDetermination{ JScriptUndefined=0, NoJScript, IsJScript}; + JScriptDetermination m_eJScript; + // The map is filled by buildComTlbIndex and + TLBFuncIndexMap m_mapComFunc; + // Keeps the ITypeInfo obtained from IDispatch::GetTypeInfo + CComPtr< ITypeInfo > m_spTypeInfo; + // keeps the modes of parameters of the current function call + // These values correspond to Windows PARAMFLAGS constants ( PARAMFLAG_FIN, PARAMFLAG_FOUT) + // The Sequence contains only the in and out flag + Sequence< sal_Int32> m_seqCurrentParamTypes; + // contains the VARTYPES of the parameters of the current call + Sequence<sal_uInt16> m_seqCurrentVartypes; + +}; + +} // end namespace +#endif + diff --git a/extensions/source/ole/olethread.cxx b/extensions/source/ole/olethread.cxx new file mode 100644 index 000000000000..20347b314ccc --- /dev/null +++ b/extensions/source/ole/olethread.cxx @@ -0,0 +1,109 @@ +/************************************************************************* + * + * $RCSfile: olethread.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ +#if defined _MSC_VER && ( _MSC_VER >= 1200 ) +#define _WIN32_WINNT 0x0400 +#endif + +#include "ole2uno.hxx" + +#include <tools/presys.h> +#include <hash_map> +#include <tools/postsys.h> + +#include <vos/thread.hxx> + +using namespace vos; +using namespace std; + +namespace ole_adapter +{ +// CoInitializeEx * +typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInitEx)( LPVOID, DWORD); +// CoInitialize * +typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInit)( LPVOID); + +void o2u_attachCurrentThread() +{ + static OThreadData oleThreadData; + + if ((sal_Bool)oleThreadData.getData() != sal_True) + { + HINSTANCE inst= LoadLibrary( _T("ole32.dll")); + if( inst ) + { + HRESULT hr; + // Try DCOM + ptrCoInitEx initFuncEx= (ptrCoInitEx)GetProcAddress( inst, _T("CoInitializeEx")); + if( initFuncEx) + hr= initFuncEx( NULL, COINIT_MULTITHREADED); + // No DCOM, try COM + else + { + ptrCoInit initFunc= (ptrCoInit)GetProcAddress( inst,_T("CoInitialize")); + if( initFunc) + hr= initFunc( NULL); + } + } + oleThreadData.setData((void*)sal_True); + } +} + +} // end namespace diff --git a/extensions/source/ole/servprov.cxx b/extensions/source/ole/servprov.cxx new file mode 100644 index 000000000000..31b1f463b04c --- /dev/null +++ b/extensions/source/ole/servprov.cxx @@ -0,0 +1,898 @@ +/************************************************************************* + * + * $RCSfile: servprov.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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/mutex.hxx> + +#include "ole2uno.hxx" +#include "unoconversionutilities.hxx" +#include "servprov.hxx" + //#include <vos/xception.hxx> +#include "unoobjw.hxx" +#include "oleobjw.hxx" + + +using namespace std; +using namespace cppu; +using namespace rtl; +using namespace osl; +using namespace vos; +using namespace com::sun::star::lang; +using namespace com::sun::star::uno; +using namespace com::sun::star::bridge; +using namespace com::sun::star::bridge::ModelDependent; + + +//#define INVOCATION_SERVICE L"com.sun.star.script.Invocation" + +namespace ole_adapter +{ + +#include <initguid.h> +// prior 5.2 ( src569 ver m) +// {3ECF78F0-B149-11D2-8EBE-00105AD848AF} +//DEFINE_GUID(OID_ServiceManager, 0x3ECF78F0, 0xB149, 0x11d2, 0x8E, 0xBE, 0x00, 0x10, 0x5A, 0xD8, 0x48, 0xAF); + +// GUID used since 5.2 ( src569 m) +// {82154420-0FBF-11d4-8313-005004526AB4} +DEFINE_GUID(OID_ServiceManager, 0x82154420, 0xfbf, 0x11d4, 0x83, 0x13, 0x0, 0x50, 0x4, 0x52, 0x6a, 0xb4); + + + +static Reference<XMultiServiceFactory> xMultiServiceFactory; +static Reference<XRegistryKey> xRegistryKey; + +Reference<XMultiServiceFactory> o2u_getMultiServiceFactory() +{ + return xMultiServiceFactory; +} + +Reference<XRegistryKey> o2u_getRegistryKey() +{ + return xRegistryKey; +} + +extern OMutex globalWrapperMutex; +Reference<XSingleServiceFactory> getInvocationFactory() +{ + OGuard aGuard(globalWrapperMutex); + static Reference<XSingleServiceFactory> factory= Reference<XSingleServiceFactory>(o2u_getMultiServiceFactory()->createInstance( INVOCATION_SERVICE), UNO_QUERY); + return factory; +} + +/***************************************************************************** + + class implementation ProviderOleWrapper_Impl + +*****************************************************************************/ + +ProviderOleWrapper_Impl::ProviderOleWrapper_Impl(const Reference<XSingleServiceFactory>& xSFact, GUID* pGuid) + : m_xSingleServiceFactory(xSFact) +{ + m_guid = *pGuid; + + Reference<XInterface> xInt = o2u_getMultiServiceFactory()->createInstance(L"com.sun.star.bridge.OleBridgeSupplier2"); + + if (xInt.is()) + { + Any a= xInt->queryInterface( ::getCppuType( reinterpret_cast< + Reference< XBridgeSupplier2>* >(0))); + a >>= m_bridgeSupplier; + + } +} + +ProviderOleWrapper_Impl::~ProviderOleWrapper_Impl() +{ +} + +sal_Bool ProviderOleWrapper_Impl::registerClass() +{ + HRESULT hresult; + + o2u_attachCurrentThread(); + + hresult = CoRegisterClassObject( + m_guid, + this, + CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, + REGCLS_MULTIPLEUSE, + &m_factoryHandle); + + return (hresult == NOERROR); +} + +sal_Bool ProviderOleWrapper_Impl::deregisterClass() +{ + HRESULT hresult = CoRevokeClassObject(m_factoryHandle); + + return (hresult == NOERROR); +} + +STDMETHODIMP ProviderOleWrapper_Impl::QueryInterface(REFIID riid, void FAR* FAR* ppv) +{ + if(IsEqualIID(riid, IID_IUnknown)) + { + AddRef(); + *ppv = (IUnknown*) (IClassFactory*) this; + return NOERROR; + } + else if (IsEqualIID(riid, IID_IClassFactory)) + { + AddRef(); + *ppv = (IClassFactory*) this; + return NOERROR; + } + + *ppv = NULL; + return ResultFromScode(E_NOINTERFACE); +} + +STDMETHODIMP_(ULONG) ProviderOleWrapper_Impl::AddRef() +{ + return osl_incrementInterlockedCount( &m_refCount); +} + +STDMETHODIMP_(ULONG) ProviderOleWrapper_Impl::Release() +{ + MutexGuard aGuard( Mutex::getGlobalMutex()); + m_refCount--; + if (m_refCount == 0) + { + delete this; + } + + return m_refCount; +} + +STDMETHODIMP ProviderOleWrapper_Impl::CreateInstance(IUnknown FAR* punkOuter, + REFIID riid, + void FAR* FAR* ppv) +{ + HRESULT ret = ResultFromScode(E_UNEXPECTED); + punkOuter = NULL; + + Reference<XInterface> xInstance; + + if (m_xSingleServiceFactory.is()) + { + xInstance = m_xSingleServiceFactory->createInstance(); + + if (xInstance.is()) + { + Any usrAny(&xInstance, getCppuType( & xInstance)); + + sal_uInt8 arId[16]; + rtl_getGlobalProcessId( arId ); + Any oleAny = m_bridgeSupplier->createBridge(usrAny, + Sequence<sal_Int8>((sal_Int8*)arId, 16), + UNO, + OLE); + + + if (oleAny.getValueTypeClass() == getCppuType( (sal_uInt32 *)0).getTypeClass()) + { + VARIANT* pVariant = (VARIANT*)oleAny.getValue(); + + if ((pVariant->vt == VT_UNKNOWN) || (pVariant->vt == VT_DISPATCH)) + { + ret = pVariant->punkVal->QueryInterface(riid, ppv); + } + + VariantClear(pVariant); + CoTaskMemFree(pVariant); + } + } + } + + return ret; +} + +STDMETHODIMP ProviderOleWrapper_Impl::LockServer(int fLock) +{ + return NOERROR; +} + +/***************************************************************************** + + class implementation OneInstanceOleWrapper_Impl + +*****************************************************************************/ + +OneInstanceOleWrapper_Impl::OneInstanceOleWrapper_Impl(const Reference<XInterface>& xInst, GUID* pGuid) + : m_xInst(xInst) +{ + m_guid = *pGuid; + + Reference<XInterface> xInt = o2u_getMultiServiceFactory()->createInstance(L"com.sun.star.bridge.OleBridgeSupplier2"); + + if (xInt.is()) + { + Any a= xInt->queryInterface( getCppuType( + reinterpret_cast< Reference<XBridgeSupplier2>*>(0))); + a >>= m_bridgeSupplier; + } +} + +OneInstanceOleWrapper_Impl::~OneInstanceOleWrapper_Impl() +{ +} + +sal_Bool OneInstanceOleWrapper_Impl::registerClass() +{ + HRESULT hresult; + + o2u_attachCurrentThread(); + + hresult = CoRegisterClassObject( + m_guid, + this, + CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, + REGCLS_MULTIPLEUSE, + &m_factoryHandle); + + return (hresult == NOERROR); +} + +sal_Bool OneInstanceOleWrapper_Impl::deregisterClass() +{ + HRESULT hresult = CoRevokeClassObject(m_factoryHandle); + + return (hresult == NOERROR); +} + +STDMETHODIMP OneInstanceOleWrapper_Impl::QueryInterface(REFIID riid, void FAR* FAR* ppv) +{ + if(IsEqualIID(riid, IID_IUnknown)) + { + AddRef(); + *ppv = (IUnknown*) (IClassFactory*) this; + return NOERROR; + } + else if (IsEqualIID(riid, IID_IClassFactory)) + { + AddRef(); + *ppv = (IClassFactory*) this; + return NOERROR; + } + + *ppv = NULL; + return ResultFromScode(E_NOINTERFACE); +} + +STDMETHODIMP_(ULONG) OneInstanceOleWrapper_Impl::AddRef() +{ + return osl_incrementInterlockedCount( &m_refCount); +} + +STDMETHODIMP_(ULONG) OneInstanceOleWrapper_Impl::Release() +{ + + MutexGuard oGuard( Mutex::getGlobalMutex()); + m_refCount--; + if ( m_refCount == 0) + { + delete this; + } + + return m_refCount; +} + +STDMETHODIMP OneInstanceOleWrapper_Impl::CreateInstance(IUnknown FAR* punkOuter, + REFIID riid, + void FAR* FAR* ppv) +{ + HRESULT ret = ResultFromScode(E_UNEXPECTED); + punkOuter = NULL; + + if (m_xInst.is()) + { + Any usrAny(&m_xInst, getCppuType( &m_xInst)); + sal_uInt8 arId[16]; + rtl_getGlobalProcessId( arId); + Any oleAny = m_bridgeSupplier->createBridge(usrAny, + Sequence<sal_Int8>( (sal_Int8*)arId, 16), + UNO, + OLE); + + + if (oleAny.getValueTypeClass() == TypeClass_UNSIGNED_LONG) + { + VARIANT* pVariant = *(VARIANT**)oleAny.getValue(); + + if ((pVariant->vt == VT_UNKNOWN) || (pVariant->vt == VT_DISPATCH)) + { + ret = pVariant->punkVal->QueryInterface(riid, ppv); + } + + VariantClear(pVariant); + CoTaskMemFree(pVariant); + } + } + + return ret; +} + +STDMETHODIMP OneInstanceOleWrapper_Impl::LockServer(int fLock) +{ + return NOERROR; +} + + +/***************************************************************************** + + class implementation OleConverter_Impl2 + +*****************************************************************************/ + +OleConverter_Impl2::OleConverter_Impl2() + +{ +} + +// The XMultiServiceFactory is later set by XInitialization +OleConverter_Impl2::OleConverter_Impl2( sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass ): + UnoConversionUtilities<OleConverter_Impl2>( unoWrapperClass, comWrapperClass ) + +{ +} + +OleConverter_Impl2::~OleConverter_Impl2() +{ +} + +// XBridgeSupplier -------------------------------------------------------------- +Any SAL_CALL OleConverter_Impl2::createBridge(const Any& modelDepObject, + const Sequence< sal_Int8 >& ProcessId, + sal_Int16 sourceModelType, + sal_Int16 destModelType) + throw (IllegalArgumentException, + RuntimeException ) +{ + Any ret; + sal_uInt8 arId[16]; + rtl_getGlobalProcessId( arId ); + + Sequence< sal_Int8 > seqProcessId( (sal_Int8*)arId, 16); + + if ( seqProcessId == ProcessId) + { + if (sourceModelType == UNO) + { + if (destModelType == UNO) + { + // same model -> copy value only + ret = modelDepObject; + } + else if (destModelType == OLE) + { + // convert UNO any into variant + VARIANT* pVariant = (VARIANT*) CoTaskMemAlloc(sizeof(VARIANT)); + VariantInit( pVariant); + if (! anyToVariant( pVariant, modelDepObject)) + { + CoTaskMemFree(pVariant); + throw IllegalArgumentException(); + } + else + { + ret.setValue((void*) &pVariant, getCppuType((sal_uInt32*)0)); + } + } + else + throw IllegalArgumentException(); + } + else if (sourceModelType == OLE) + { + if (modelDepObject.getValueType() != getCppuType((sal_uInt32*)0)) + { + throw IllegalArgumentException(); + } + else if (destModelType == OLE) + { + // same model -> copy value only + VARIANT* pVariant = (VARIANT*) CoTaskMemAlloc(sizeof(VARIANT)); + + if (NOERROR != VariantCopy(pVariant, (VARIANT*)modelDepObject.getValue())) + { + CoTaskMemFree(pVariant); + throw(IllegalArgumentException()); + } + else + { + ret.setValue((void*) &pVariant, getCppuType((sal_uInt32*)0)); + } + } + else if (destModelType == UNO) + { + // convert variant into UNO any + VARIANT* pVariant = (VARIANT*)modelDepObject.getValue(); + + if (!variantToAny(pVariant, ret)) + { + throw IllegalArgumentException(); + } + } + else + throw IllegalArgumentException(); + + } + else + throw IllegalArgumentException(); + } + + return ret; +} + + +// XInitialize ------------------------------------------------------------------------------ +// the first argument is an XMultiServiceFactory if at all +void SAL_CALL OleConverter_Impl2::initialize( const Sequence< Any >& aArguments ) + throw(Exception, RuntimeException) +{ + if( aArguments.getLength() == 1 && aArguments[0].getValueTypeClass() == TypeClass_INTERFACE) + { + Reference < XInterface > xInt; + aArguments[0] >>= xInt; + Reference <XMultiServiceFactory> xMulti( xInt, UNO_QUERY); + m_xMultiServiceFactory= xMulti; + } +} + +// UnoConversionUtilities ------------------------------------------------------------------- +Reference< XInterface > OleConverter_Impl2::createUnoWrapperInstance() +{ + if( m_nUnoWrapperClass == INTERFACE_OLE_WRAPPER_IMPL) + { + Reference<XWeak> xWeak= static_cast<XWeak*>( new InterfaceOleWrapper_Impl( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); + } + else if( m_nUnoWrapperClass == UNO_OBJECT_WRAPPER_REMOTE_OPT) + { + Reference<XWeak> xWeak= static_cast<XWeak*>( new UnoObjectWrapperRemoteOpt( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); + } + else + return Reference<XInterface>(); +} + +Reference< XInterface > OleConverter_Impl2::createComWrapperInstance() +{ + Reference<XWeak> xWeak= static_cast<XWeak*>( new IUnknownWrapper_Impl( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); +} + + + +/***************************************************************************** + + class implementation OleClient_Impl + +*****************************************************************************/ + +OleClient_Impl::OleClient_Impl() +{ + Reference<XInterface> xInt = o2u_getMultiServiceFactory()->createInstance(L"com.sun.star.bridge.OleBridgeSupplier2"); + + if (xInt.is()) + { + Any a= xInt->queryInterface(getCppuType( + reinterpret_cast<Reference<XBridgeSupplier2>*>(0))); + a >>= m_bridgeSupplier; + } +} + +OleClient_Impl::~OleClient_Impl() +{ +} + +Sequence< OUString > SAL_CALL OleClient_Impl::getAvailableServiceNames() throw( RuntimeException ) +{ + Sequence< OUString > ret; + + return ret; +} + + +OUString OleClient_Impl::getImplementationName() +{ + return OUString(L"com.sun.star.comp.ole.OleClient"); +} + +Reference<XInterface> SAL_CALL OleClient_Impl::createInstance(const OUString& ServiceSpecifier) throw (Exception, RuntimeException ) +{ + Reference<XInterface> ret; + HRESULT result; + IUnknown* pUnknown = NULL; + CLSID classId; + + o2u_attachCurrentThread(); + + result = CLSIDFromProgID( + ServiceSpecifier.getStr(), //Pointer to the ProgID + &classId); //Pointer to the CLSID + + + if (result == NOERROR) + { + result = CoCreateInstance( + classId, //Class identifier (CLSID) of the object + NULL, //Pointer to whether object is or isn't part of an aggregate + CLSCTX_ALL, //Context for running executable code + IID_IUnknown, //Reference to the identifier of the interface + (void**)&pUnknown); //Address of output variable that receives + // the interface pointer requested in riid + } + + if (pUnknown != NULL) + { + Any any; + VARIANT variant; + + VariantInit(&variant); + + V_VT(&variant) = VT_UNKNOWN; + V_UNKNOWN(&variant) = pUnknown; + + pUnknown->AddRef(); + + if (variantToAny(&variant, any)) + { + if (any.getValueTypeClass() == TypeClass_INTERFACE) + { + ret = *(Reference<XInterface>*)any.getValue(); + } + } + + VariantClear(&variant); + } + + return ret; +} + +Reference<XInterface> SAL_CALL OleClient_Impl::createInstanceWithArguments(const OUString& ServiceSpecifier, const Sequence< Any >& Arguments) throw (Exception, RuntimeException) +{ + Reference<XInterface> ret; + HRESULT result; + IUnknown* pUnknown = NULL; + CLSID classId; + + o2u_attachCurrentThread(); + + result = CLSIDFromProgID( + ServiceSpecifier.getStr(), //Pointer to the ProgID + &classId); //Pointer to the CLSID + + + if (result == NOERROR) + { + result = CoCreateInstance( + classId, //Class identifier (CLSID) of the object + NULL, //Pointer to whether object is or isn't part of an aggregate + CLSCTX_LOCAL_SERVER, //Context for running executable code + IID_IUnknown, //Reference to the identifier of the interface + (void**)&pUnknown); //Address of output variable that receives + // the interface pointer requested in riid + } + + if (pUnknown != NULL) + { + Any any; + VARIANT variant; + + VariantInit(&variant); + + V_VT(&variant) = VT_UNKNOWN; + V_UNKNOWN(&variant) = pUnknown; + + pUnknown->AddRef(); + + if (variantToAny(&variant, any)) + { + if (any.getValueTypeClass() == TypeClass_INTERFACE) + { + ret = *(Reference<XInterface>*)any.getValue(); + } + } + + VariantClear(&variant); + } + + return ret; +} + +// UnoConversionUtilities ----------------------------------------------------------------------------- +Reference< XInterface > OleClient_Impl::createUnoWrapperInstance() +{ + if( m_nUnoWrapperClass == INTERFACE_OLE_WRAPPER_IMPL) + { + Reference<XWeak> xWeak= static_cast<XWeak*>( new InterfaceOleWrapper_Impl( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); + } + else if( m_nUnoWrapperClass == UNO_OBJECT_WRAPPER_REMOTE_OPT) + { + Reference<XWeak> xWeak= static_cast<XWeak*>( new UnoObjectWrapperRemoteOpt( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); + } + else + return Reference< XInterface>(); +} +// UnoConversionUtilities ----------------------------------------------------------------------------- +Reference< XInterface > OleClient_Impl::createComWrapperInstance( ) +{ + Reference<XWeak> xWeak= static_cast<XWeak*>( new IUnknownWrapper_Impl( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); +} + + + +/***************************************************************************** + + class implementation OleServer_Impl + +*****************************************************************************/ + +OleServer_Impl::OleServer_Impl() +{ + Reference<XInterface> xInt = o2u_getMultiServiceFactory()->createInstance(L"com.sun.star.bridge.OleBridgeSupplier2"); + + if (xInt.is()) + { + Any a= xInt->queryInterface( getCppuType( + reinterpret_cast< Reference<XBridgeSupplier2>*>(0))); + a >>= m_bridgeSupplier; + } + + sal_Bool ret = provideInstance(o2u_getMultiServiceFactory(), (GUID*)&OID_ServiceManager); +} + +OleServer_Impl::~OleServer_Impl() +{ + while (!m_wrapperList.empty()) + { + (*m_wrapperList.begin())->deregisterClass(); + (*m_wrapperList.begin())->Release(); + m_wrapperList.pop_front(); + } +} +// XInterface -------------------------------------------------- +Any SAL_CALL OleServer_Impl::queryInterface( const Type& aType ) throw(RuntimeException) +{ + Any a= ::cppu::queryInterface( aType, static_cast<XTypeProvider*>(this)); + if( a == Any()) + return OWeakObject::queryInterface( aType); + else + return a; +} +void SAL_CALL OleServer_Impl::acquire( ) throw(RuntimeException) +{ + OWeakObject::acquire(); +} +void SAL_CALL OleServer_Impl::release( ) throw (RuntimeException) +{ + OWeakObject::release(); +} + + +// XTypeProvider -------------------------------------------------- +Sequence< Type > SAL_CALL OleServer_Impl::getTypes( ) throw(RuntimeException) +{ + static OTypeCollection *pCollection = 0; + if( ! pCollection ) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if( ! pCollection ) + { + static OTypeCollection collection( + getCppuType(reinterpret_cast< Reference< XWeak>*>(0)), + getCppuType(reinterpret_cast< Reference< XTypeProvider>*>(0)) ); + pCollection = &collection; + } + } + return (*pCollection).getTypes(); +} +Sequence< sal_Int8 > SAL_CALL OleServer_Impl::getImplementationId() throw(RuntimeException) +{ + static OImplementationId *pId = 0; + if( ! pId ) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if( ! pId ) + { + static OImplementationId id( sal_False ); + pId = &id; + } + } + return (*pId).getImplementationId(); +} + + +sal_Bool OleServer_Impl::provideService(const Reference<XSingleServiceFactory>& xSFact, GUID* guid) +{ + sal_Bool ret = FALSE; + + IClassFactoryWrapper* pFac = new ProviderOleWrapper_Impl(xSFact, guid); + + pFac->AddRef(); + + m_wrapperList.push_back(pFac); + + return pFac->registerClass(); +} + +sal_Bool OleServer_Impl::provideInstance(const Reference<XInterface>& xInst, GUID* guid) +{ + sal_Bool ret = FALSE; + + IClassFactoryWrapper* pFac = new OneInstanceOleWrapper_Impl(xInst, guid); + + pFac->AddRef(); + m_wrapperList.push_back(pFac); + + return pFac->registerClass(); +} + + + +/***************************************************************************** + + functions to create the service providers + +*****************************************************************************/ + +Reference<XSingleServiceFactory> o2u_getConverterProvider2(const Reference<XMultiServiceFactory>& xMan, + const Reference<XRegistryKey>& xKey) +{ + static Reference<XSingleServiceFactory> ret = NULL; + + if (!ret.is()) + { + if (!xMultiServiceFactory.is()) xMultiServiceFactory = xMan; + + Sequence<OUString> seqServiceNames; + ret = createSingleFactory( xMan, L"com.sun.star.comp.ole.OleConverter2", + ConverterProvider_CreateInstance2, seqServiceNames ); + } + return ret; +} + +Reference<XSingleServiceFactory> o2u_getConverterProviderVar1(const Reference<XMultiServiceFactory>& xMan, + const Reference<XRegistryKey>& xKey) +{ + static Reference<XSingleServiceFactory> ret = NULL; + + if (!ret.is()) + { + if (!xMultiServiceFactory.is()) xMultiServiceFactory = xMan; + + Sequence<OUString> seqServiceNames; + ret = createSingleFactory( xMan, L"com.sun.star.comp.ole.OleConverterVar1", + ConverterProvider_CreateInstanceVar1, seqServiceNames ); + } + return ret; +} +Reference<XSingleServiceFactory> o2u_getClientProvider(const Reference<XMultiServiceFactory>& xMan, + const Reference<XRegistryKey>& xKey) +{ + static Reference<XSingleServiceFactory> ret = NULL; + + if (!ret.is()) + { + if (!xMultiServiceFactory.is()) xMultiServiceFactory = xMan; + Sequence<OUString> seqServiceNames; + ret = createSingleFactory( xMan, L"com.sun.star.comp.ole.OleClient", + OleClient_CreateInstance, seqServiceNames); + } + + return ret; +} + +Reference<XSingleServiceFactory> o2u_getServerProvider(const Reference<XMultiServiceFactory>& xMan, + const Reference<XRegistryKey>& xKey) +{ + static Reference<XSingleServiceFactory> ret = NULL; + + if (!ret.is()) + { + if (!xMultiServiceFactory.is()) xMultiServiceFactory = xMan; + Sequence<OUString> seqServiceNames; + ret = createOneInstanceFactory( xMan, L"com.sun.star.comp.ole.OleServer", + OleServer_CreateInstance, seqServiceNames); + } + + return ret; +} +// Creator functions -------------------- + +Reference<XInterface> SAL_CALL ConverterProvider_CreateInstance2( const Reference<XMultiServiceFactory> & xSMgr) + throw(Exception) +{ + Reference<XInterface> xService = *new OleConverter_Impl2(); + return xService; +} + +Reference<XInterface> SAL_CALL ConverterProvider_CreateInstanceVar1( const Reference<XMultiServiceFactory> & xSMgr) + throw(Exception) +{ + Reference<XInterface> xService = *new OleConverter_Impl2( UNO_OBJECT_WRAPPER_REMOTE_OPT, IUNKNOWN_WRAPPER_IMPL); + return xService; +} + +Reference<XInterface> SAL_CALL OleClient_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr) + throw(Exception) +{ + Reference<XInterface> xService = *new OleClient_Impl(); + return xService; +} + +Reference<XInterface> SAL_CALL OleServer_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr) + throw (Exception) +{ + Reference<XInterface > xService = *new OleServer_Impl(); + return xService; +} + + +} // end namespace diff --git a/extensions/source/ole/servprov.hxx b/extensions/source/ole/servprov.hxx new file mode 100644 index 000000000000..2d8c537446b9 --- /dev/null +++ b/extensions/source/ole/servprov.hxx @@ -0,0 +1,308 @@ +/************************************************************************* + * + * $RCSfile: servprov.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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 _SERVPROV_HXX +#define _SERVPROV_HXX + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif + +#include "ole2uno.hxx" +#include "unoconversionutilities.hxx" + + +using namespace com::sun::star::bridge; +using namespace cppu; +using namespace std; + +namespace ole_adapter +{ +Reference< XInterface> SAL_CALL ConverterProvider_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr) + throw( Exception); +Reference< XInterface> SAL_CALL ConverterProvider_CreateInstance2( const Reference<XMultiServiceFactory> & xSMgr) + throw( Exception); +Reference< XInterface> SAL_CALL ConverterProvider_CreateInstanceVar1( const Reference<XMultiServiceFactory> & xSMgr) + throw( Exception); +Reference<XInterface> SAL_CALL OleClient_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr) + throw( Exception); +Reference<XInterface> SAL_CALL OleServer_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr) + throw( Exception); +/***************************************************************************** + + class declaration IClassFactoryWrapper + + Specify abstract helper methods on class factories, which provide + UNO objects. These methods are used by objects of class OleServer_Impl, + to handle the OLE registration of different class factories. + +*****************************************************************************/ + +class IClassFactoryWrapper : public IClassFactory +{ +public: + + virtual sal_Bool registerClass() = 0; + virtual sal_Bool deregisterClass() = 0; +}; + +/***************************************************************************** + + class declaration ProviderOleWrapper_Impl + + Provides an UNO service provider as OLE class factory. Handle the + OLE registration by overloading the abstract methods from + IClassFactoryWrapper. + + Acts as a COM class factory. When IClassFactory::CreateInstance is being called + then it creates an service by help of the XSingleServiceFactory member and maps + maps it to a COM object. + +*****************************************************************************/ + +class ProviderOleWrapper_Impl : public IClassFactoryWrapper +{ +public: + + ProviderOleWrapper_Impl(const Reference<XSingleServiceFactory>& xSFactory, GUID* pGuid); + ~ProviderOleWrapper_Impl(); + + sal_Bool registerClass(); + sal_Bool deregisterClass(); + + /* IUnknown methods */ + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); + STDMETHOD_(ULONG, AddRef)(); + STDMETHOD_(ULONG, Release)(); + + /* IClassFactory methods */ + STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv); + STDMETHOD(LockServer)(int fLock); + +protected: + + oslInterlockedCount m_refCount; + Reference<XSingleServiceFactory> m_xSingleServiceFactory; + GUID m_guid; + DWORD m_factoryHandle; + Reference<XBridgeSupplier2> m_bridgeSupplier; +}; + +/***************************************************************************** + + class declaration OneInstanceOleWrapper_Impl + + Provides an single UNO object as OLE object. Handle the + OLE registration by overloading the abstract methods from + IClassFactoryWrapper. + + Acts as a COM class factory. When IClassFactory::CreateInstance is being called + then it maps the XInstance member it to a COM object. + +*****************************************************************************/ + +class OneInstanceOleWrapper_Impl : public IClassFactoryWrapper +{ +public: + + OneInstanceOleWrapper_Impl(const Reference<XInterface>& xInst, GUID* pGuid); + ~OneInstanceOleWrapper_Impl(); + + sal_Bool registerClass(); + sal_Bool deregisterClass(); + + /* IUnknown methods */ + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); + STDMETHOD_(ULONG, AddRef)(); + STDMETHOD_(ULONG, Release)(); + + /* IClassFactory methods */ + STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv); + STDMETHOD(LockServer)(int fLock); + +protected: + + //ORefCount m_refCount; + oslInterlockedCount m_refCount; + Reference<XInterface> m_xInst; + GUID m_guid; + DWORD m_factoryHandle; + Reference<XBridgeSupplier2> m_bridgeSupplier; +}; + +/***************************************************************************** + + class declaration OleConverter_Impl2 + + Implementation of the UNO service com.sun.star.bridge.OleBridgeSupplier2. + +*****************************************************************************/ + +// This class realizes the service com.sun.star.bridge.OleBridgeSupplier2 and +// com.sun.star.bridge.OleBridgeSupplierVar1. The class implements XBridgeSupplier2 +// instead of XBridgeSuppplier as done by class OleConverter_Impl. The XBridgeSupplier2 +// interface does not need a Maschine Id in its createBridge function anymore, +// If an UNO interface is to be converted then the member m_nUnoWrapperClass determines +// what wrapper class is to be used. There are currently InterfaceOleWrapper_Impl and +// UnoObjectWrapperRemoteOpt. The first is used for the OleBridgeSupplier2 and the +// latter for OleBridgeSupplierVar1. +// The m_nComWrapperClass specifies the class which is used as wrapper for COM interfaces. +// Currently there is only one class available ( IUnknownWrapper_Impl). +class OleConverter_Impl2 : public WeakImplHelper2<XBridgeSupplier2, XInitialization>, + public UnoConversionUtilities<OleConverter_Impl2> +{ +public: + OleConverter_Impl2(); + OleConverter_Impl2( sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass ); + virtual ~OleConverter_Impl2(); + + // XBridgeSupplier2 --------------------------------------------------- + + virtual Any SAL_CALL createBridge(const Any& modelDepObject, + const Sequence<sal_Int8>& ProcessId, + sal_Int16 sourceModelType, + sal_Int16 destModelType) + throw (IllegalArgumentException, RuntimeException); + + // XInitialization + virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException); + + // Abstract struct UnoConversionUtilities + virtual Reference< XInterface > createUnoWrapperInstance(); + virtual Reference< XInterface > createComWrapperInstance(); +}; + + +/***************************************************************************** + + class declaration OleClient_Impl + + Implementation of the UNO service com.sun.star.bridge.OleObjectFactory. + +*****************************************************************************/ + + +class OleClient_Impl : public WeakImplHelper1<XMultiServiceFactory>, + public UnoConversionUtilities<OleClient_Impl> +{ +public: + OleClient_Impl(); + ~OleClient_Impl(); + + // XMultiServiceFactory + virtual Reference<XInterface> SAL_CALL createInstance(const OUString& ServiceSpecifier) throw( Exception, RuntimeException); + virtual Reference<XInterface> SAL_CALL createInstanceWithArguments(const OUString& ServiceSpecifier, const Sequence< Any >& Arguments) throw (Exception, RuntimeException); + Sequence< OUString > SAL_CALL getAvailableServiceNames() throw (RuntimeException); + + // Abstract struct UnoConversionUtilities + virtual Reference< XInterface > createUnoWrapperInstance(); + virtual Reference< XInterface > createComWrapperInstance(); + + + OUString getImplementationName(); +protected: + + Reference<XBridgeSupplier2> m_bridgeSupplier; +}; + +/***************************************************************************** + + class declaration OleServer_Impl + + Implementation of the UNO service com.sun.star.bridge.OleApplicationRegistration. + Register the calling application as OLE automation server for + standard OLE object. The objects will be registered while instanciating + this implementation and deregistrated, if this implementation is destroyed. + +*****************************************************************************/ + +class OleServer_Impl : public OWeakObject, XTypeProvider +{ +public: + OleServer_Impl(); + ~OleServer_Impl(); + + // XInterface + virtual Any SAL_CALL queryInterface( const Type& aType ) throw(RuntimeException); + virtual void SAL_CALL acquire( ) throw (RuntimeException); + virtual void SAL_CALL release( ) throw (RuntimeException); + + // XTypeProvider + virtual Sequence< Type > SAL_CALL getTypes( ) throw(RuntimeException); + virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(RuntimeException); + +protected: + + sal_Bool provideService(const Reference<XSingleServiceFactory>& xMulFact, GUID* guid); + sal_Bool provideInstance(const Reference<XInterface>& xInst, GUID* guid); + + list< IClassFactoryWrapper* > m_wrapperList; + Reference< XBridgeSupplier2 > m_bridgeSupplier; +}; + +} // end namespace +#endif + + + diff --git a/extensions/source/ole/servreg.cxx b/extensions/source/ole/servreg.cxx new file mode 100644 index 000000000000..58d9c72501b9 --- /dev/null +++ b/extensions/source/ole/servreg.cxx @@ -0,0 +1,154 @@ +/************************************************************************* + * + * $RCSfile: servreg.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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 "ole2uno.hxx" + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + + + +using namespace rtl; +using namespace ole_adapter; + + +extern "C" void * SAL_CALL component_getFactory( + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +{ + void * pRet = 0; + + OUString aImplName( OUString::createFromAscii( pImplName ) ); + Reference< XSingleServiceFactory > xFactory; + if (pServiceManager && aImplName.equals( L"com.sun.star.comp.ole.OleConverter2" )) + { + xFactory= o2u_getConverterProvider2( + reinterpret_cast< XMultiServiceFactory*>(pServiceManager), + reinterpret_cast< XRegistryKey*>(pRegistryKey)); + } + else if (pServiceManager && aImplName.equals( L"com.sun.star.comp.ole.OleConverterVar1" )) + { + xFactory= o2u_getConverterProviderVar1( + reinterpret_cast< XMultiServiceFactory*>(pServiceManager), + reinterpret_cast< XRegistryKey*>(pRegistryKey)); + } + else if(pServiceManager && aImplName.equals(L"com.sun.star.comp.ole.OleClient")) + { + xFactory= o2u_getClientProvider( + reinterpret_cast< XMultiServiceFactory*>(pServiceManager), + reinterpret_cast< XRegistryKey*>(pRegistryKey)); + } + else if(pServiceManager && aImplName.equals(L"com.sun.star.comp.ole.OleServer")) + { + xFactory= o2u_getServerProvider( + reinterpret_cast< XMultiServiceFactory*>(pServiceManager), + reinterpret_cast< XRegistryKey*>(pRegistryKey)); + } + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + + return pRet; +} + + +extern "C" sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey ) +{ + if (pRegistryKey) + { + try + { + Reference<XRegistryKey> xNewKey = + reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(L"/com.sun.star.comp.ole.OleConverter2/UNO/SERVICES"); + xNewKey->createKey(L"com.sun.star.bridge.OleBridgeSupplier2"); + + xNewKey = + reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(L"/com.sun.star.comp.ole.OleConverterVar1/UNO/SERVICES"); + xNewKey->createKey(L"com.sun.star.bridge.OleBridgeSupplierVar1"); + + xNewKey = + reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(L"/com.sun.star.comp.ole.OleClient/UNO/SERVICES"); + xNewKey->createKey(L"com.sun.star.bridge.OleObjectFactory"); + + xNewKey = + reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(L"/com.sun.star.comp.ole.OleServer/UNO/SERVICES"); + xNewKey->createKey(L"com.sun.star.bridge.OleApplicationRegistration"); + + return sal_True; + } + catch (InvalidRegistryException &) + { + OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); + } + } + return sal_False; +} + +extern "C" void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + + diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx new file mode 100644 index 000000000000..11be00a3000d --- /dev/null +++ b/extensions/source/ole/unoconversionutilities.hxx @@ -0,0 +1,1574 @@ +/************************************************************************* + * + * $RCSfile: unoconversionutilities.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:41 $ + * + * 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 _UNO_CONVERSION_UTILITIES +#define _UNO_CONVERSION_UTILITIES + +#include <com/sun/star/script/XInvocationAdapterFactory.hpp> +#include <com/sun/star/script/XInvocationAdapterFactory2.hpp> + +#include <vos/mutex.hxx> +#include "ole2uno.hxx" + +// classes for wrapping uno objects +#define INTERFACE_OLE_WRAPPER_IMPL 1 +#define UNO_OBJECT_WRAPPER_REMOTE_OPT 2 + +#define INVOCATION_SERVICE L"com.sun.star.script.Invocation" + + +// classes for wrapping ole objects +#define IUNKNOWN_WRAPPER_IMPL 1 + +#define INTERFACE_ADAPTER_FACTORY L"com.sun.star.script.InvocationAdapterFactory" +// COM or JScript objects implementing UNO interfaces have to implement this interface as well +#define SUPPORTED_INTERFACES_PROP L"_implementedInterfaces" + +using namespace com::sun::star::script; +using namespace com::sun::star::beans; +using namespace vos; + +namespace ole_adapter +{ +extern OMutex globalWrapperMutex; +extern hash_map<sal_uInt32, sal_uInt32> AdapterToWrapperMap; +extern hash_map<sal_uInt32, sal_uInt32> WrapperToAdapterMap; + + // createUnoObjectWrapper gets a wrapper instance by calling createUnoWrapperInstance + // and initializes it via XInitialization. The wrapper object is required to implement + // XBridgeSupplier so that it can convert itself to IDispatch. + // class T: Deriving class ( must implement XInterface ) +template< class > +class UnoConversionUtilities +{ +public: + UnoConversionUtilities(): m_nUnoWrapperClass( INTERFACE_OLE_WRAPPER_IMPL), + m_nComWrapperClass( IUNKNOWN_WRAPPER_IMPL) + {} + UnoConversionUtilities( sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass ) + : m_nUnoWrapperClass( unoWrapperClass), m_nComWrapperClass( comWrapperClass) + {} + UnoConversionUtilities( Reference<XMultiServiceFactory> xFactory, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass ) + : m_xMultiServiceFactory( xFactory), m_nComWrapperClass( comWrapperClass), m_nUnoWrapperClass( unoWrapperClass) + {} + // converts only into oleautomation types, that is there is no VT_I1, VT_UI2, VT_UI4 + // a sal_Unicode character is converted into a BSTR + sal_Bool anyToVariant(VARIANT* pVariant, const Any& rAny); + SAFEARRAY* createUnoSequenceWrapper(const Any& rSeq); + IDispatch* createUnoObjectWrapper(const Any& rObj); + + sal_Bool variantToAny(const VARIANT* pVariant, Any& rAny, sal_Bool bReduceValueRange = sal_True); + sal_Bool variantToAny2( const VARIANTARG* pArg, Any& rAny, const Type& ptype, sal_Bool bReduceValueRange = sal_True); + Any createOleObjectWrapper(IUnknown* pUnknown); + Any createOleObjectWrapper(IUnknown* pUnknown, const Type& aType); + + + sal_Bool convertValueObject( const VARIANTARG *var, Any& any, sal_Bool& bHandled); + sal_Bool dispatchExObject2Sequence( const VARIANTARG* pvar, Any& anySeq, const Type& type); + + Sequence<Any> createOleArrayWrapperOfDim(SAFEARRAY* pArray, unsigned int dimCount, unsigned int actDim, long* index, VARTYPE type); + Sequence<Any> createOleArrayWrapper(SAFEARRAY* pArray, VARTYPE type); + +// SAFEARRAY* createUnoSequenceWrapper(const Any& rSeq); + + VARTYPE mapTypeClassToVartype( TypeClass type); + + Reference< XSingleServiceFactory > getInvocationFactory(); + + virtual Reference< XInterface > createUnoWrapperInstance()=0; + virtual Reference< XInterface > createComWrapperInstance()=0; + + static sal_Bool isJScriptArray(const VARIANT* pvar); + + + +// Attributes: +protected: + // This member determines what class is used to convert a UNO object + // or struct to a COM object. It is passed along to the o2u_anyToVariant + // function in the createBridge function implementation + sal_uInt8 m_nUnoWrapperClass; + sal_uInt8 m_nComWrapperClass; + + // This factory is set by calling XInitialization::initialize. + // If this ServiceManager is supplied then it is used to create all + // necessary services. + Reference<XMultiServiceFactory> m_xMultiServiceFactory; + Reference<XSingleServiceFactory> m_xInvocationFactory; + + +}; + +template<class T> +Reference< XSingleServiceFactory > UnoConversionUtilities<T>::getInvocationFactory() +{ + if( m_xInvocationFactory.is() ) + return Reference< XSingleServiceFactory >( m_xInvocationFactory ); + + if( m_xMultiServiceFactory.is() ) + m_xInvocationFactory= Reference<XSingleServiceFactory >( m_xMultiServiceFactory->createInstance( INVOCATION_SERVICE), UNO_QUERY); + else + m_xInvocationFactory= Reference<XSingleServiceFactory>( o2u_getMultiServiceFactory()->createInstance(INVOCATION_SERVICE ), UNO_QUERY); + + return m_xInvocationFactory; +} + +template<class T> +sal_Bool UnoConversionUtilities<T>::variantToAny2( const VARIANTARG* pArg, Any& rAny, const Type& ptype, sal_Bool bReduceValueRange /* = sal_True */) +{ + HRESULT hr; + sal_Bool retVal= sal_True; + + VARIANT var; + VariantInit( &var); + // There is no need to support indirect values, since they're not supported by UNO + if( FAILED(hr= VariantCopyInd( &var, const_cast<VARIANTARG*>(pArg)))) // remove VT_BYREF + return sal_False; + + sal_Bool bHandled= sal_False; + if( pArg->vt == VT_DISPATCH ) + { + convertValueObject( &var, rAny, bHandled); + if( bHandled) + OSL_ENSURE( rAny.getValueType() == ptype, "type in Value Object must tally with the type parameter"); + } + + + if( ! bHandled) + { + // convert into a variant type that is the equivalent to the type + // the sequence expects. Thus variantToAny produces the correct type + // E.g. An Array object contains VT_I4 and the sequence expects shorts + // than the vartype must be changed. The reason is, you can't specify the + // type in JavaScript and the script engine determines the type beeing used. + switch( ptype.getTypeClass()) + { + case TypeClass_CHAR: // could be: new Array( 12, 'w', "w") + if( pArg->vt == VT_BSTR) + { + if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_BSTR))) + rAny.setValue( (void*)V_BSTR( &var), ptype); + else + retVal= sal_False; + } + else if( pArg->vt == VT_I4 || + pArg->vt == VT_UI4 || + pArg->vt == VT_I2 || + pArg->vt == VT_UI2 || + pArg->vt == VT_I1 || + pArg->vt == VT_UI1) + { + if( SUCCEEDED( hr= VariantChangeType( &var, & var, 0, VT_UI2))) + rAny.setValue(& V_UI2( &var), ptype); + else + retVal= sal_False; + } + break; + case TypeClass_INTERFACE: // could also be an IUnknown + // if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_DISPATCH))) + // retVal= variantToAny(&var, rAny); + { + CComVariant varUnk; + if( SUCCEEDED( hr= VariantChangeType( &varUnk, &var, 0, VT_UNKNOWN))) + { + rAny = createOleObjectWrapper( varUnk.punkVal, ptype); + retVal = sal_True; + } + else + retVal= sal_False; + break; + } + case TypeClass_SERVICE: break; // meta construct + case TypeClass_STRUCT: + {// dispatch + CComVariant varUnk; + if( SUCCEEDED( hr= VariantChangeType( &varUnk, &var, 0, VT_UNKNOWN))) + { + rAny= createOleObjectWrapper( varUnk.punkVal, ptype); + retVal= sal_True; + } + else + retVal= sal_False; + break; + } + case TypeClass_TYPEDEF: break; + case TypeClass_UNION: break; + case TypeClass_ENUM: + if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_I4))) + { + rAny.setValue( (void*)&var.lVal, ptype); + retVal= sal_True; + } + else + retVal= sal_False; + break; + case TypeClass_EXCEPTION: break; + case TypeClass_ARRAY: break; // there's no Array at the moment + case TypeClass_SEQUENCE: + // There are different ways of receiving a sequence: + // 1: JScript, VARTYPE: VT_DISPATCH + // 2. VBScript simple arraysVT_VARIANT|VT_BYREF the referenced VARIANT contains + // a VT_ARRAY| <type> + // 3. VBSrcript multi dimensional arrays: VT_ARRAY|VT_BYREF + if( pArg->vt == VT_DISPATCH) + { + retVal= dispatchExObject2Sequence( pArg, rAny, ptype); + } + else + retVal= variantToAny(&var, rAny); + break; // maybe later ( convert to VT_ARRAY| ??? ) + case TypeClass_VOID: + rAny.setValue(NULL,Type()); + break; + + case TypeClass_ANY: // Any + // There could be a JScript Array that needs special handling + // If an Any is expected and this Any must contain a Sequence + // then we cannot figure out what element type is required. + // Therefore we convert to Sequence< Any > + if( pArg->vt == VT_DISPATCH && isJScriptArray( pArg)) + { + Sequence<Any> s; + retVal= dispatchExObject2Sequence( pArg, rAny, getCppuType(&s)); + } + else + retVal= variantToAny( &var, rAny); + break; + case TypeClass_UNKNOWN: break; + case TypeClass_BOOLEAN: // VARIANT could be VARIANT_BOOL or other + if(SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_BOOL))) + retVal= variantToAny(&var, rAny); + else + retVal= sal_False; + break; + case TypeClass_STRING: // UString + if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_BSTR))) + retVal= variantToAny(&var, rAny); + else + retVal= sal_False; + break; + case TypeClass_FLOAT: // float + if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_R4))) + retVal= variantToAny(&var, rAny); + else + retVal= sal_False; + break; + case TypeClass_DOUBLE: // double + if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_R8))) + retVal= variantToAny(&var, rAny ); + else + retVal= sal_False; + break; + case TypeClass_BYTE: // BYTE + if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_I1))) + retVal= variantToAny(&var, rAny); + else + retVal= sal_False; + break; + case TypeClass_SHORT: // INT16 + if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_I2))) + retVal= variantToAny(&var, rAny); + else + retVal= sal_False; + break; + case TypeClass_LONG: // INT32 + if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_I4))) + retVal= variantToAny(&var, rAny, bReduceValueRange); + else + retVal= sal_False; + break; + case TypeClass_HYPER: break; // INT64 + case TypeClass_UNSIGNED_SHORT: // UINT16 + if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_UI2))) + retVal= variantToAny(&var, rAny); + else + retVal= sal_False; + break; + case TypeClass_UNSIGNED_LONG: // UINT32 + if( SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_UI4))) + retVal= variantToAny(&var, rAny, bReduceValueRange); + else + retVal= sal_False; + break; + case TypeClass_UNSIGNED_HYPER: break;// UINT64 + case TypeClass_MODULE: break; // module + + default: + retVal= variantToAny(pArg, rAny); // hopfully delegating ;-) + break; + + } + } + return retVal; +} + + +template<class T> +sal_Bool UnoConversionUtilities<T>::anyToVariant(VARIANT* pVariant, const Any& rAny) +{ + sal_Bool ret = sal_False; + + switch (rAny.getValueTypeClass()) + { + case TypeClass_INTERFACE: // XInterfaceRef + { + Reference<XInterface> xInt( *(XInterface**)rAny.getValue()); + + V_VT(pVariant) = VT_DISPATCH; + V_DISPATCH(pVariant) = NULL; + + if (xInt.is()) + { + // check, wether the object provides OLE bridging or not + Reference<XBridgeSupplier2> XBridgeSup(xInt, UNO_QUERY); + sal_Bool bOwnService= sal_False; + if (XBridgeSup.is()) + { + // check if we try to convert our own OleConverter2 service + // If so we would run into a recursion!!! + T* pT= static_cast< T* >( this); + + Any anyXInt= pT->queryInterface( getCppuType( static_cast<Reference<XInterface>* >( 0) )); + Reference< XInterface > xIntThis; + + if( (anyXInt >>= xIntThis) && xInt != xIntThis) + { // not our own OleConverter_Impl2 + sal_uInt8 arId[16]; + rtl_getGlobalProcessId( arId); + Any oleAny = XBridgeSup->createBridge( + rAny, + Sequence<sal_Int8>( (sal_Int8*)arId, 16), + UNO, + OLE); + + if( oleAny.getValueType() == getCppuType( (sal_uInt32*)0)) + { + VARIANT* pTmpVariant = *(VARIANT**)oleAny.getValue(); + + VariantCopy(pVariant, pTmpVariant); + VariantClear(pTmpVariant); + CoTaskMemFree(pTmpVariant); + } + else + { + XBridgeSup = Reference<XBridgeSupplier2>(); + } + } + else + {// The object is our OleConverter_Impl2 !! + bOwnService= sal_True; + } + } + + if (!XBridgeSup.is() || bOwnService ) + { + V_DISPATCH(pVariant)= createUnoObjectWrapper( rAny); + } + } + ret = sal_True; + + break; + } + case TypeClass_SERVICE: // meta construct + break; + case TypeClass_STRUCT: // struct + V_VT(pVariant) = VT_DISPATCH; + V_DISPATCH(pVariant) = createUnoObjectWrapper(rAny); + ret = sal_True; + break; + case TypeClass_TYPEDEF: // typedef compiler construct ??? + break; + case TypeClass_UNION: // union + break; + case TypeClass_ENUM: // enumeration + V_VT(pVariant) = VT_I4; + V_I4(pVariant) = *(sal_Int32*)rAny.getValue(); + ret = sal_True; + break; + case TypeClass_EXCEPTION: // exception + break; + case TypeClass_ARRAY: // array not implemented + break; + case TypeClass_SEQUENCE: // sequence ??? SafeArray descriptor + { + SAFEARRAY* pArray = createUnoSequenceWrapper(rAny); + if (pArray) + { + V_VT(pVariant) = VT_ARRAY | VT_VARIANT; + V_ARRAY(pVariant) = pArray; + ret = sal_True; + } + break; + } + case TypeClass_VOID: // void + VariantClear(pVariant); + ret = sal_True; + break; + case TypeClass_ANY: // Any + break; + case TypeClass_UNKNOWN: // unknown type + break; + case TypeClass_BOOLEAN: // BOOL + { + V_VT(pVariant) = VT_BOOL; + V_BOOL( pVariant)= *(sal_Bool*) rAny.getValue() == sal_True? VARIANT_TRUE: VARIANT_FALSE; + ret = sal_True; + break; + } + case TypeClass_CHAR:// char + { + // Because VT_UI2 does not conform to oleautomation we convert into VT_I2 instead +// V_VT(pVariant) = VT_BSTR; +// sal_uInt16 _c = *(sal_uInt16*)rAny.getValue(); +// pVariant->bstrVal= SysAllocStringLen( &_c, 1); +// ret= pVariant->bstrVal ? sal_True : sal_False; + V_VT(pVariant) = VT_I2; + V_I2(pVariant) = *(sal_Int16*)rAny.getValue(); + ret = sal_True; + break; + } + case TypeClass_STRING: // UString + V_VT(pVariant) = VT_BSTR; + V_BSTR(pVariant) = SysAllocString( OUString(*(rtl_uString**)rAny.getValue())); + ret = sal_True; + break; + case TypeClass_FLOAT: // float + V_VT(pVariant) = VT_R4; + V_R4(pVariant) = *(float*)rAny.getValue(); + ret = sal_True; + break; + case TypeClass_DOUBLE: // double + V_VT(pVariant) = VT_R8; + V_R8(pVariant) = *(double*)rAny.getValue(); + ret = sal_True; + break; + case TypeClass_BYTE: // BYTE + // ole automation does not know a signed char but only unsigned char + V_VT(pVariant) = VT_UI1; + V_UI1(pVariant) = *(sal_uInt8*)rAny.getValue(); + ret= sal_False; + break; + case TypeClass_SHORT: // INT16 + V_VT(pVariant) = VT_I2; + V_I2(pVariant) = *(sal_Int16*)rAny.getValue(); + ret = sal_True; + break; + case TypeClass_LONG: // INT32 + V_VT(pVariant) = VT_I4; + V_I4(pVariant) = *(sal_Int32*)rAny.getValue(); + ret = sal_True; + break; + case TypeClass_HYPER: // INT64 + // V_VT(pVariant) = VT_CY; + // V_CY(pVariant).Lo = rAny.getINT64().p.loPart; + // V_CY(pVariant).Lo = rAny.getINT64().p.hiPart; + // ret = sal_True; + break; + //case TypeClass_UNSIGNED_OCTET: // ??? not implemented + // V_VT(pVariant) = VT_UI1; + // V_UI1(pVariant) = rAny.getBYTE(); + // ret = sal_True; + // break; + case TypeClass_UNSIGNED_SHORT: // UINT16 + V_VT(pVariant) = VT_I2; + V_I2(pVariant) = *(sal_Int16*)rAny.getValue(); + ret = sal_False; + break; + case TypeClass_UNSIGNED_LONG: // UINT32 + V_VT(pVariant) = VT_I4; + V_I4(pVariant) = *(sal_Int32*)rAny.getValue(); + ret = sal_False; + break; + case TypeClass_UNSIGNED_HYPER: // UINT64 + // V_VT(pVariant) = VT_UI8; + // V_UI8(pVariant) = rAny.getUINT64(); + // ret = sal_True; + break; + // case TypeClass_UNSIGNED_INT: // int not implemented + // break; + //case TypeClass_UNSIGNED_BYTE: + // V_VT(pVariant) = VT_UI1; + // V_UI1(pVariant) = rAny.getBYTE(); + // ret = sal_True; + // break; + case TypeClass_MODULE: // module + break; + default: + break; + } + + return ret; +} + +template<class T> +SAFEARRAY* UnoConversionUtilities<T>::createUnoSequenceWrapper(const Any& rSeq) +{ + SAFEARRAY* pArray = NULL; + sal_uInt32 n = 0; + + if( rSeq.getValueTypeClass() == TypeClass_SEQUENCE ) + { + uno_Sequence * punoSeq= *(uno_Sequence**) rSeq.getValue(); + + typelib_TypeDescriptionReference* pSeqTypeRef= rSeq.getValueTypeRef(); + typelib_TypeDescription* pSeqType= NULL; + TYPELIB_DANGER_GET( &pSeqType, pSeqTypeRef) + typelib_IndirectTypeDescription * pSeqIndDec= (typelib_IndirectTypeDescription*) pSeqType; +// typelib_IndirectTypeDescription * pSeqDec= (typelib_IndirectTypeDescription*)rSeq.getValueTypeDescriptionRef(); + + typelib_TypeDescriptionReference * pSeqElementTypeRef= pSeqIndDec->pType; + TYPELIB_DANGER_RELEASE( pSeqType) + + + + typelib_TypeDescription* pSeqElementDesc= NULL; + TYPELIB_DANGER_GET( &pSeqElementDesc, pSeqElementTypeRef) + sal_Int32 nElementSize= pSeqElementDesc->nSize; + n= punoSeq->nElements; + + SAFEARRAYBOUND rgsabound[1]; + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = n; + VARIANT oleElement; + long safeI[1]; + + pArray = SafeArrayCreate(VT_VARIANT, 1, rgsabound); + + Any unoElement; + // sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->pElements; + sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->elements; + + for (sal_uInt32 i = 0; i < n; i++) + { + unoElement.setValue( pSeqData + i * nElementSize, pSeqElementDesc); + VariantInit(&oleElement); + + if (anyToVariant(&oleElement, unoElement)) + { + safeI[0] = i; + SafeArrayPutElement(pArray, safeI, &oleElement); + } + + VariantClear(&oleElement); + } + TYPELIB_DANGER_RELEASE( pSeqElementDesc) + } + + return pArray; +} + +template<class T> +IDispatch* UnoConversionUtilities<T>::createUnoObjectWrapper(const Any& rObj) +{ + OGuard guard(globalWrapperMutex); + + IDispatch* pDispatch = NULL; + Reference<XInvocation> xInv; + Reference<XInterface> xInt; + + + // If the UNO object is already a wrapped COM object then + // of course the original IDispatch is returned. + if( rObj.getValueTypeClass() == TypeClass_INTERFACE) + { + if( rObj >>= xInt) + { + // can the object provide a Wrapper on its own + if( ! convertSelfToIDispatch( xInt, &pDispatch) ) + { + // figure out if the UNO object is a Wrapper through global maps + typedef hash_map<sal_uInt32,sal_uInt32>::iterator _IT; + _IT it= AdapterToWrapperMap.find( (sal_uInt32) xInt.get()); + if( it != AdapterToWrapperMap.end() ) + { + Reference<XInterface> xIntWrapper( (XInterface*)it->second); + convertSelfToIDispatch( xIntWrapper, &pDispatch); // should always work on the objects in the map + } + else + xInv= Reference<XInvocation>( xInt, UNO_QUERY); + } + } + } + + if (! pDispatch && !xInv.is()) + { + // static Reference<XSingleServiceFactory> xInvFactory(o2u_getMultiServiceFactory()->createInstance(INVOCATION_SERVICE),UNO_QUERY); + Reference<XSingleServiceFactory> xInvFactory= getInvocationFactory(); + if( xInvFactory.is()) + { + Sequence<Any> params(1); + params.getArray()[0] = rObj; + Reference<XInterface> xInt = xInvFactory->createInstanceWithArguments(params); + xInv= Reference<XInvocation>(xInt, UNO_QUERY); + } + } + + OSL_ENSURE(xInv.is() || pDispatch, "no invocation interface"); + if( !pDispatch) + { + Reference< XInterface > xIntWrapper= createUnoWrapperInstance(); + if( xIntWrapper.is()) + { + Reference< XInitialization > xInitWrapper( xIntWrapper, UNO_QUERY); + if( xInitWrapper.is() ) + { + VARTYPE vartype= getVarType( rObj); + + if( xInt.is()) + { + Any params[3]; + params[0] <<= xInv; + params[1] <<= xInt; + params[2] <<= vartype; + xInitWrapper->initialize( Sequence<Any>(params, 3)); + } + else + { + Any params[2]; + params[0] <<= xInv; + params[1] <<= vartype; + xInitWrapper->initialize( Sequence<Any>(params, 2)); + } + + // Get the IDispatch + // A wrapper is expected to implement XBridgeSupplier in order to + // convert itself to an IDispatch: + IDispatch* pDisp; + if( convertSelfToIDispatch( xIntWrapper, &pDisp)) + pDispatch= pDisp; + } + } + } + + return pDispatch; +} + +template<class T> +sal_Bool UnoConversionUtilities<T>::variantToAny( const VARIANT* pVariant, Any& rAny, + sal_Bool bReduceValueRange /* = sal_True */) +{ + sal_Bool ret = sal_False; + VARTYPE oleTypeFlags = V_VT(pVariant); + + if ((oleTypeFlags & VT_BYREF) != 0) + { + oleTypeFlags ^= VT_BYREF; + + if ((oleTypeFlags & VT_ARRAY) != 0) + { + oleTypeFlags ^= VT_ARRAY; + + Sequence<Any> unoSeq = createOleArrayWrapper(*V_ARRAYREF(pVariant), oleTypeFlags); + rAny.setValue( &unoSeq, getCppuType( &unoSeq)); + + ret = sal_True; + } + else + { + switch (oleTypeFlags) // conversion by reference + { + case VT_EMPTY: // jo + rAny.setValue(NULL, Type()); + ret= sal_True; + break; + case VT_NULL: + rAny.setValue(NULL, Type()); + ret = sal_True; + break; + case VT_I2: + rAny.setValue(V_I2REF(pVariant), getCppuType((sal_Int16*)0)); + ret = sal_True; + break; + case VT_I4: + rAny.setValue(V_I4REF(pVariant), getCppuType((sal_Int32*)0)); + ret = sal_True; + break; + case VT_R4: + rAny.setValue(V_R4REF(pVariant), getCppuType( (float*)0)); + ret = sal_True; + break; + case VT_R8: + rAny.setValue(V_R8REF(pVariant), getCppuType( (double*)0)); + ret = sal_True; + break; + case VT_CY: + // rAny.setHyper(*V_CYREF(pVariant)); + // ret = sal_True; + break; + case VT_DATE: + break; + case VT_BSTR: + { + OUString s(*V_BSTRREF(pVariant)); + rAny.setValue( &s, getCppuType( &s)); + ret = sal_True; + break; + } + case VT_DISPATCH: + { + IUnknown* pUnknown = NULL; + + if ((*V_DISPATCHREF(pVariant)) != NULL) + { + (*V_DISPATCHREF(pVariant))->QueryInterface(IID_IUnknown, (void**)&pUnknown); + } + + rAny = createOleObjectWrapper(pUnknown); + + if (pUnknown != NULL) + { + pUnknown->Release(); + } + + ret = sal_True; + break; + } + case VT_ERROR: + rAny.setValue(V_ERRORREF(pVariant), getCppuType( (sal_uInt32*)0)); + ret = sal_True; + break; + case VT_BOOL: + { + sal_Bool b= (*V_BOOLREF(pVariant)) == VARIANT_TRUE; + rAny.setValue( &b, getCppuType( &b)); + ret = sal_True; + break; + } + case VT_VARIANT: + { + if (V_VT(V_VARIANTREF(pVariant)) == VT_EMPTY) + { + rAny.setValue(NULL, Type()); + ret = sal_True; + } + else + { + ret = variantToAny(V_VARIANTREF(pVariant), rAny); + } + } + break; + case VT_UNKNOWN: + rAny = createOleObjectWrapper(*V_UNKNOWNREF(pVariant)); + ret = sal_True; + break; + case VT_I1: + rAny.setValue(V_I1REF(pVariant), getCppuType( (sal_Int8*)0)); + ret = sal_True; + break; + case VT_UI1: + // convert to sal_Int8 because there is no Type for sal_uInt8 + rAny.setValue(V_UI1REF(pVariant), getCppuType( (sal_Int8*)0)); + ret = sal_True; + break; + case VT_UI2: + rAny.setValue(V_UI2REF(pVariant), getCppuType( (sal_uInt16*)0)); + ret = sal_True; + break; + case VT_UI4: + rAny.setValue(V_UI4REF(pVariant), getCppuType( (sal_uInt32*)0)); + ret = sal_True; + break; + case VT_INT: + rAny.setValue(V_INTREF(pVariant), getCppuType( (sal_Int32*)0)); + ret = sal_True; + break; + case VT_UINT: + rAny.setValue(V_UINTREF(pVariant), getCppuType((sal_uInt32*)0)); + ret = sal_True; + break; + case VT_VOID: + rAny.setValue( NULL, Type()); + ret = sal_True; + break; + default: + break; + } + } + } + else + { + if ((oleTypeFlags & VT_ARRAY) > 0) + { + oleTypeFlags ^= VT_ARRAY; + + Sequence<Any> unoSeq = createOleArrayWrapper(V_ARRAY(pVariant), oleTypeFlags); + rAny.setValue( &unoSeq, getCppuType( &unoSeq)); + + ret = sal_True; + } + else + { + switch (oleTypeFlags) // conversion by value + { + case VT_EMPTY: // jo + rAny.setValue(NULL, Type()); + ret= sal_True; + break; + + case VT_NULL: + rAny.setValue(NULL, Type()); + ret = sal_True; + break; + case VT_I2: + rAny.setValue(&V_I2(pVariant), getCppuType( (sal_Int16*)0)); + ret = sal_True; + break; + case VT_I4: + rAny.setValue(&V_I4(pVariant), getCppuType( (sal_Int32*)0)); + // necessary for use in JavaScript ( see "reduceRange") + if( bReduceValueRange) + reduceRange( rAny); + ret = sal_True; + break; + case VT_R4: + rAny.setValue(&V_R4(pVariant), getCppuType( (float*)0)); + ret = sal_True; + break; + case VT_R8: + rAny.setValue(&V_R8(pVariant), getCppuType( (double*)0)); + ret = sal_True; + break; + case VT_CY: + // rAny.setHyper(V_CY(pVariant)); + // ret = sal_True; + break; + case VT_DATE: + break; + case VT_BSTR: + { + OUString b( V_BSTR(pVariant)); + rAny.setValue( &b, getCppuType( &b)); + ret = sal_True; + break; + } + case VT_DISPATCH: + { + IUnknown* pUnknown = NULL; + + if (V_DISPATCH(pVariant) != NULL) + { + V_DISPATCH(pVariant)->QueryInterface(IID_IUnknown, (void**)&pUnknown); + } + + rAny = createOleObjectWrapper(pUnknown); + + if (pUnknown != NULL) + { + pUnknown->Release(); + } + + ret = sal_True; + + break; + } + case VT_ERROR: + rAny.setValue(&V_ERROR(pVariant), getCppuType( (sal_uInt32*)0)); + ret = sal_True; + break; + case VT_BOOL: + { + sal_Bool b= V_BOOL(pVariant) == VARIANT_TRUE; + rAny.setValue( &b, getCppuType( &b)); + ret = sal_True; + break; + } + case VT_UNKNOWN: + rAny = createOleObjectWrapper(V_UNKNOWN(pVariant)); + ret = sal_True; + break; + case VT_I1: + rAny.setValue(&V_I1(pVariant), getCppuType((sal_Int8*)0)); + ret = sal_True; + break; + case VT_UI1: // there is no unsigned char in UNO + rAny.setValue((char*)&V_UI1(pVariant), getCppuType( (sal_Int8*)0)); + ret = sal_True; + break; + case VT_UI2: + rAny.setValue(&V_UI2(pVariant), getCppuType( (sal_uInt16*)0)); + ret = sal_True; + break; + case VT_UI4: + rAny.setValue(&V_UI4(pVariant), getCppuType( (sal_uInt32*)0)); + ret = sal_True; + break; + case VT_INT: + rAny.setValue(&V_INT(pVariant), getCppuType( (sal_Int32*)0)); + ret = sal_True; + break; + case VT_UINT: + rAny.setValue(&V_UINT(pVariant), getCppuType( (sal_uInt32*)0)); + ret = sal_True; + break; + case VT_VOID: + rAny.setValue( NULL, Type()); + ret = sal_True; + break; + default: + break; + } + } + } + + return ret; +} + +template<class T> +Any UnoConversionUtilities<T>::createOleObjectWrapper(IUnknown* pUnknown) +{ + Any ret; + + Reference<XInterface> xInt; + + if (pUnknown == NULL) + { + ret <<= xInt; + } + else + { + CComQIPtr<IUnoObjectWrapper> spUno( pUnknown); + if( spUno) + { + Reference<XInterface> xInt; + spUno->getOriginalUnoObject( &xInt); + ret <<= xInt; + } + else + { + Reference<XInterface> xInt= createComWrapperInstance(); + if( xInt.is()) + { + Reference<XInitialization> xInit( xInt, UNO_QUERY); + if( xInit.is()) + { + Any param; + param <<= (sal_uInt32) pUnknown; + xInit->initialize( Sequence<Any>(¶m, 1)); + } + } + ret<<= Reference<XInvocation>( xInt, UNO_QUERY); + } + } + + return ret; +} + +// if the object supports only one type then it does not have to implement the property +// SUPPORTER_INTERFACES_PROP ( define) +template<class T> +Any UnoConversionUtilities<T>::createOleObjectWrapper(IUnknown* pUnknown, const Type& aType) +{ + OGuard guard( globalWrapperMutex); + Any ret; + + Reference<XInterface> xInt; + + if (pUnknown == NULL) + { + if( aType.getTypeClass() == TypeClass_INTERFACE) + ret.setValue( &xInt, aType); + else if( aType.getTypeClass() == TypeClass_STRUCT) + ret.setValue( NULL, aType); + } + else + { + CComQIPtr<IUnoObjectWrapper> spUno( pUnknown); + if( spUno) + { + if( aType.getTypeClass() == TypeClass_INTERFACE) + { + Reference<XInterface> xInt; + spUno->getOriginalUnoObject( &xInt); + if( xInt.is()) + { + ret= xInt->queryInterface( aType); + } + + } + else if( aType.getTypeClass() == TypeClass_STRUCT) + { + Any any; + if( SUCCEEDED( spUno->getOriginalUnoStruct(&any))) + ret= any; + } + } + else + { + Reference<XInterface> xInt= createComWrapperInstance(); + if( xInt.is()) + { +// Reference<XInitialization> xInit( xInt, UNO_QUERY); +// if( xInit.is()) +// { +// Any params[2]; +// params[0] <<= (sal_uInt32) pUnknown; +// params[1] <<= aType; +// xInit->initialize( Sequence<Any>( params, 2)); +// } + + Reference<XInvocation> xInv( xInt, UNO_QUERY); + + Sequence<Type> seqTypes; + + // create the actual Interface of type "Type" + // If the type is XInvocation than we use the COM wrapper directly. + if( aType.getTypeName() == OUString::createFromAscii("com.sun.star.script.XInvocation")) + { + ret <<= xInv; + } + else + { + Reference< XInterface> xIntAdapterFac; + if( m_xMultiServiceFactory.is()) + { + xIntAdapterFac= m_xMultiServiceFactory->createInstance( INTERFACE_ADAPTER_FACTORY); + + } + else + { + xIntAdapterFac= o2u_getMultiServiceFactory()->createInstance( INTERFACE_ADAPTER_FACTORY); + } + + // We create an adapter object that does not only implement the required type but also + // all types that the COM object pretends to implement. An COM object must therefore + // support the property "_implementedInterfaces". If it does not an Adapter of param + // type +// Sequence<Type> seqTypes; + CComDispatchDriver disp( pUnknown); + if( disp) + { + CComVariant var; + if( SUCCEEDED( disp.GetPropertyByName( SUPPORTED_INTERFACES_PROP, &var))) + {// we exspect an array( SafeArray or IDispatch) of Strings. + Any anyNames; + if( variantToAny2( &var, anyNames, getCppuType( (Sequence<Any>*) 0))) + { + Sequence<Any> seqAny; + if( anyNames >>= seqAny) + { + seqTypes.realloc( seqAny.getLength()); + for( sal_Int32 i=0; i < seqAny.getLength(); i++) + { + OUString typeName; + seqAny[i] >>= typeName; + seqTypes[i]= Type( TypeClass_INTERFACE, typeName); + } + } + } + } + } + + Reference<XInterface> xIntAdapted; + if( seqTypes.getLength() >0) + { + Reference< XInvocationAdapterFactory2> xAdapterFac( xIntAdapterFac, UNO_QUERY); + if( xAdapterFac.is()) + xIntAdapted= xAdapterFac->createAdapter( xInv, seqTypes); + } + else + { + Reference<XInvocationAdapterFactory> xAdapterFac( xIntAdapterFac, UNO_QUERY); + if( xAdapterFac.is()) + xIntAdapted= xAdapterFac->createAdapter( xInv, aType); + } + if( xIntAdapted.is()) + { + ret= xIntAdapted->queryInterface( aType); + // Put the pointer to the wrapper object and the interface pointer of the adapted interface + // in a global map. Thus we can determine in a call to createUnoObjectWrapper whether the UNO + // object is a wrapped COM object. In that case we extract the original COM object rather than + // creating a wrapper around the UNO object. + typedef hash_map<sal_uInt32,sal_uInt32>::value_type VALUE; + AdapterToWrapperMap.insert( VALUE( (sal_uInt32) xIntAdapted.get(), (sal_uInt32) xInt.get())); + WrapperToAdapterMap.insert( VALUE( (sal_uInt32) xInt.get(), (sal_uInt32) xIntAdapted.get())); + + } + } + + // initialize the COM wrapper ( IUnknown + Type s) + Reference<XInitialization> xInit( xInt, UNO_QUERY); + if( xInit.is()) + { + Any params[2]; + params[0] <<= (sal_uInt32) pUnknown; + if( ! seqTypes.getLength() ) + { + params[1] <<= Sequence<Type>( &aType, 1); + } + else + { + params[1] <<= seqTypes; + } + + xInit->initialize( Sequence<Any>( params, 2)); + } + + } + } + } + + return ret; +} +// "convertValueObject" converts a JScriptValue object contained in "var" into +// an any. The type contained in the any is stipulated by a "type value" thas +// was set within the JScript script on the value object ( see JScriptValue). +template<class T> +sal_Bool UnoConversionUtilities<T>::convertValueObject( const VARIANTARG *var, Any& any, sal_Bool& bHandled) +{ + sal_Bool ret= sal_True; + bHandled= sal_False; + HRESULT hr= S_OK; + + if( var->vt == VT_DISPATCH) + { + CComPtr <IJScriptValueObject> spValue; + VARIANT_BOOL varBool; + CComBSTR bstrType; + CComVariant varValue; + + if( SUCCEEDED( var->pdispVal->QueryInterface( __uuidof( IJScriptValueObject), + reinterpret_cast<void**> (&spValue)))) + { + // Out Parameter -------------------------------------------------- + if( SUCCEEDED( hr= spValue->IsOutParam( &varBool) ) + && varBool == VARIANT_TRUE ) + {// no conversion necessary + bHandled= sal_True; + } + // In / Out Parameter --------------------------------------------- + else if( SUCCEEDED( hr= spValue->IsInOutParam( &varBool) ) + && varBool == VARIANT_TRUE) + { + if( SUCCEEDED( hr= spValue->GetValue( &bstrType, &varValue))) + { + if( variantToAny2( &varValue, any, getType( bstrType))) + { + bHandled= sal_True; + } + } //IJScriptValueObject::GetValue() + } // in/out parameter + // In Parameter + else + { + if( SUCCEEDED( hr= spValue->GetValue( &bstrType, &varValue))) + { + if( variantToAny2(&varValue, any, getType( bstrType))) + { + bHandled= sal_True; + } + } + } + + }// if IJScriptValueObject + }// if IDispatch + if( FAILED( hr) ) + ret= sal_False; + return ret; +} +template<class T> +sal_Bool UnoConversionUtilities<T>::dispatchExObject2Sequence( const VARIANTARG* pvar, Any& anySeq, const Type& type) +{ + sal_Bool retVal= TRUE; + + if( pvar->vt != VT_DISPATCH) return FALSE; + IDispatchEx* pdispEx; + HRESULT hr; + if( FAILED( hr= pvar->pdispVal->QueryInterface( IID_IDispatchEx, + reinterpret_cast<void**>( &pdispEx)))) return FALSE; + + DISPID dispid; + OUString sindex; + DISPPARAMS param= {0,0,0,0}; + VARIANT result; + VariantInit( & result); + OLECHAR* sLength= L"length"; + + // Get the length of the array. Can also be obtained throu GetNextDispID. The + // method only returns DISPIDs of the array data. Their names are like "0", "1" etc. + if( FAILED( hr= pdispEx->GetIDsOfNames(IID_NULL, &sLength , 1, LOCALE_USER_DEFAULT, &dispid))) + return FALSE; + if( FAILED( hr= pdispEx->InvokeEx(dispid, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, + ¶m, &result, NULL, NULL))) + return FALSE; + if( FAILED( VariantChangeType( &result, &result, 0, VT_I4))) + return FALSE; + long length= result.lVal; + VariantClear( &result); + + // get a few basic facts about the sequence, and reallocate: + // create the Sequences + // get the size of the elements + typelib_TypeDescription *pDesc= NULL; + type.getDescription( &pDesc); + + typelib_IndirectTypeDescription *pSeqDesc= reinterpret_cast<typelib_IndirectTypeDescription*>(pDesc); + typelib_TypeDescriptionReference *pSeqElemDescRef= pSeqDesc->pType; // type of the Sequence' elements + Type elemType( pSeqElemDescRef); + _typelib_TypeDescription* pSeqElemDesc=NULL; + TYPELIB_DANGER_GET( &pSeqElemDesc, pSeqElemDescRef) + sal_uInt32 nelementSize= pSeqElemDesc->nSize; + TYPELIB_DANGER_RELEASE( pSeqElemDesc) + + uno_Sequence *p_uno_Seq; + uno_sequence_construct( &p_uno_Seq, pDesc, NULL, length, cpp_acquire); + + typelib_TypeClass typeElement= pSeqDesc->pType->eTypeClass; + char *pArray= p_uno_Seq->elements; + + // Get All properties in the object, convert their values to the expected type and + // put them into the passed in sequence + for( sal_Int32 i= 0; i< length; i++) + { + OLECHAR* sindex = (sal_Unicode*)(const sal_Unicode*)OUString::valueOf( i); + + if( FAILED( hr= pdispEx->GetIDsOfNames(IID_NULL, &sindex , 1, LOCALE_USER_DEFAULT, &dispid))) + { + retVal= FALSE; + break; + } + if( FAILED( hr= pdispEx->InvokeEx(dispid, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, + ¶m, &result, NULL, NULL))) + { + retVal= FALSE; + break; + } + + // If the result is VT_DISPATCH than the Sequence's element type could be Sequence + // Look that up in the CoreReflection to make clear. + // That requires a recursiv conversion + Any any; + // Destination address within the out-Sequence "anySeq" where to copy the next converted element + void* pDest= (void*)(pArray + (i * nelementSize)); + + if( result.vt & VT_DISPATCH && typeElement == typelib_TypeClass_SEQUENCE) + { + if( variantToAny2( &result, any, elemType, sal_False) ) + { + // copy the converted VARIANT, that is a Sequence to the Sequence + uno_Sequence * p_unoSeq= *(uno_Sequence**)any.getValue(); + // just copy the pointer of the uno_Sequence + // nelementSize should be 4 !!!! + memcpy( pDest, &p_unoSeq, nelementSize); + osl_incrementInterlockedCount( &p_unoSeq->nRefCount); + } + else + { + retVal= FALSE; + break; + } + } + else // Element type is no Sequence -> do one conversion + { + if( variantToAny2( &result, any, elemType, sal_False) ) + { + + if( typeElement == typelib_TypeClass_ANY) + { + // copy the converted VARIANT to the Sequence + uno_type_assignData( pDest, pSeqElemDescRef , &any, pSeqElemDescRef,cpp_queryInterface, + cpp_acquire, cpp_release); + } + else + { + // type after conversion must be the element type of the sequence + OSL_ENSURE( (any.getValueTypeClass() == typeElement), "wrong conversion"); + uno_type_assignData( pDest, pSeqElemDescRef,const_cast<void*>( any.getValue()), any.getValueTypeRef(), + cpp_queryInterface, cpp_acquire, cpp_release); + } + } // if + else + { + retVal= FALSE; + break; + } + } // else + VariantClear(&result); + if( retVal == FALSE) + break; + } // for + VariantClear(&result); + uno_Sequence **pps= &p_uno_Seq; + anySeq.setValue( &p_uno_Seq, pDesc); + uno_destructData( &p_uno_Seq, pDesc, cpp_release); + typelib_typedescription_release( pDesc); + return retVal; +} +template<class T> +Sequence<Any> UnoConversionUtilities<T>::createOleArrayWrapperOfDim(SAFEARRAY* pArray, unsigned int dimCount, unsigned int actDim, long* index, VARTYPE type) +{ + HRESULT hr= S_OK; + long lBound; + long uBound; + long nCountElements; + + SafeArrayGetLBound(pArray, actDim + 1, &lBound); + SafeArrayGetUBound(pArray, actDim + 1, &uBound); + nCountElements= uBound - lBound +1; + + + Sequence<Any> anySeq(nCountElements); + Any* pUnoArray = anySeq.getArray(); + + for (index[actDim] = lBound; index[actDim] < nCountElements; index[actDim]++) + { + if (actDim < (dimCount - 1)) + { + Sequence<Any> element = createOleArrayWrapperOfDim(pArray, dimCount, actDim + 1, index, type); + + pUnoArray[index[actDim] - lBound].setValue(&element, getCppuType(&element)); + } + else + { + VARIANT variant; + + VariantInit(&variant); + + V_VT(&variant) = type; + + switch (type) + { + case VT_I2: + SafeArrayGetElement(pArray, index, &V_I2(&variant)); + break; + case VT_I4: + SafeArrayGetElement(pArray, index, &V_I4(&variant)); + break; + case VT_R4: + SafeArrayGetElement(pArray, index, &V_R4(&variant)); + break; + case VT_R8: + SafeArrayGetElement(pArray, index, &V_R8(&variant)); + break; + case VT_CY: + SafeArrayGetElement(pArray, index, &V_CY(&variant)); + break; + case VT_DATE: + SafeArrayGetElement(pArray, index, &V_DATE(&variant)); + break; + case VT_BSTR: + hr= SafeArrayGetElement(pArray, index, &V_BSTR(&variant)); + break; + case VT_DISPATCH: + SafeArrayGetElement(pArray, index, &V_DISPATCH(&variant)); + break; + case VT_ERROR: + SafeArrayGetElement(pArray, index, &V_ERROR(&variant)); + break; + case VT_BOOL: + SafeArrayGetElement(pArray, index, &V_BOOL(&variant)); + break; + case VT_VARIANT: + SafeArrayGetElement(pArray, index, &variant); + break; + case VT_UNKNOWN: + SafeArrayGetElement(pArray, index, &V_UNKNOWN(&variant)); + break; + case VT_I1: + SafeArrayGetElement(pArray, index, &V_I1(&variant)); + break; + case VT_UI1: + SafeArrayGetElement(pArray, index, &V_UI1(&variant)); + break; + case VT_UI2: + SafeArrayGetElement(pArray, index, &V_UI2(&variant)); + break; + case VT_UI4: + SafeArrayGetElement(pArray, index, &V_UI4(&variant)); + break; + default: + break; + } + + variantToAny(&variant, pUnoArray[index[actDim] - lBound], sal_False); + + VariantClear(&variant); + } + } + + return anySeq; +} +template<class T> +Sequence<Any> UnoConversionUtilities<T>::createOleArrayWrapper(SAFEARRAY* pArray, VARTYPE type) +{ + sal_uInt32 dim = SafeArrayGetDim(pArray); + + Sequence<Any> ret; + + if (dim > 0) + { + long * index = new long[dim]; + + for (unsigned int i = 0; i < dim; i++) + { + index[i] = 0; + } + + ret = createOleArrayWrapperOfDim(pArray, dim, 0, index, type); + + delete[] index; + } + + return ret; +} + +// If an VARIANT has the type VT_DISPATCH it can either be an JScript Array +// or some other object. This function finds out if it is such an array or +// not. Currently there's no way to make sure it's an array +// so we assume that when the object has a property "0" then it is an Array. +// An JScript has property like "0", "1", "2" etc. which represent the +// value at the corresponding index of the array +template<class T> +sal_Bool UnoConversionUtilities<T>::isJScriptArray(const VARIANT* rvar) +{ + OSL_ENSURE( rvar->vt == VT_DISPATCH, "param is not a VT_DISPATCH"); + HRESULT hr; + OLECHAR* sindex= L"0"; + DISPID id; + hr= rvar->pdispVal->GetIDsOfNames( IID_NULL, &sindex, 1, + LOCALE_USER_DEFAULT, &id); + + if( SUCCEEDED ( hr) ) + return sal_True; + return sal_False; +} + +template<class T> +VARTYPE UnoConversionUtilities<T>::mapTypeClassToVartype( TypeClass type) +{ + VARTYPE ret; + switch( type) + { + case TypeClass_INTERFACE: ret= VT_DISPATCH; + break; + case TypeClass_STRUCT: ret= VT_DISPATCH; + break; + case TypeClass_ENUM: ret= VT_I4; + break; + case TypeClass_SEQUENCE: ret= VT_ARRAY; + break; + case TypeClass_ANY: ret= VT_VARIANT; + break; + case TypeClass_BOOLEAN: ret= VT_BOOL; + break; + case TypeClass_CHAR: ret= VT_UI2; + break; + case TypeClass_STRING: ret= VT_BSTR; + break; + case TypeClass_FLOAT: ret= VT_R4; + break; + case TypeClass_DOUBLE: ret= VT_R8; + break; + case TypeClass_BYTE: ret= VT_I1; + break; + case TypeClass_SHORT: ret= VT_I2; + break; + case TypeClass_LONG: ret= VT_I4; + break; + case TypeClass_UNSIGNED_SHORT: ret= VT_UI2; + break; + case TypeClass_UNSIGNED_LONG: ret= VT_UI4; + break; + default: + ret= VT_EMPTY; + } + return ret; +} + + +// This function tries to the change the type of a value (contained in the Any) +// to the smallest possible that can hold the value. This is actually done only +// for types of VT_I4 (see o2u_variantToAny). The reason is the following: +// JavaScript passes integer values always as VT_I4. If there is a parameter or +// property of type any then the bridge converts the any's content according +// to "o2u_variantToAny". Because the VARTYPE is VT_I4 the value would be converted +// to TypeClass_LONG. Say the method XPropertySet::setPropertyValue( string name, any value) +// would be called on an object and the property actually is of TypeClass_SHORT. +// After conversion of the VARIANT parameter the Any would contain type +// TypeClass_LONG. Because the corereflection does not cast from long to short +// the "setPropertValue" would fail as the value has not the right type. + +// The corereflection does convert small integer types to bigger types. +// Therefore we can reduce the type if possible and avoid the above mentioned +// problem. + +// The function is not used when elements are to be converted for Sequences. + +#ifndef _REDUCE_RANGE +#define _REDUCE_RANGE +inline void reduceRange( Any& any) +{ + OSL_ASSERT( any.getValueTypeClass() == TypeClass_LONG); + + sal_Int32 value= *(sal_Int32*)any.getValue(); + if( value <= 0x7f && value >= -0x80) + {// -128 bis 127 + sal_Int8 charVal= static_cast<sal_Int8>( value); + any.setValue( &charVal, getCppuType( (sal_Int8*)0)); + } + else if( value <= 0x7fff && value >= -0x8000) + {// -32768 bis 32767 + sal_Int16 shortVal= static_cast<sal_Int16>( value); + any.setValue( &shortVal, getCppuType( (sal_Int16*)0)); + } +} +#endif +} // end namespace +#endif + diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx new file mode 100644 index 000000000000..c4b64082ee93 --- /dev/null +++ b/extensions/source/ole/unoobjw.cxx @@ -0,0 +1,2414 @@ +/************************************************************************* + * + * $RCSfile: unoobjw.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:40 $ + * + * 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 "ole2uno.hxx" + +#include <tools/presys.h> +#include <olectl.h> +#include <vector> +#include <list> +#include <hash_map> +#include "stdafx.h" +#include "comifaces.hxx" +#include <tools/postsys.h> + + +#include <vos/diagnose.hxx> +#include <vos/mutex.hxx> +#include <vos/refernce.hxx> +#include <tools/debug.hxx> + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#ifndef _COM_SUN_STAR_BEANS_METHODCONCEPT_HPP_ +#include <com/sun/star/beans/MethodConcept.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYCONCEPT_HPP_ +#include <com/sun/star/beans/PropertyConcept.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_FAILREASON_HPP_ +#include <com/sun/star/script/FailReason.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_PARAMINFO_HPP_ +#include <com/sun/star/reflection/ParamInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_XIDLARRAY_H_ +#include <com/sun/star/reflection/XIdlArray.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_FIELDACCESSMODE_HPP_ +#include <com/sun/star/reflection/FieldAccessMode.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_XIDLCLASS_HPP_ +#include <com/sun/star/reflection/XIdlClass.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_XIDLFIELD_HPP_ +#include <com/sun/star/reflection/XIdlField.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_PARAMMODE_HPP_ +#include <com/sun/star/reflection/ParamMode.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_METHODMODE_HPP_ +#include <com/sun/star/reflection/MethodMode.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_XIDLMEMBER_HPP_ +#include <com/sun/star/reflection/XIdlMember.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_XIDLREFLECTION_HPP_ +#include <com/sun/star/reflection/XIdlReflection.hpp> +#endif +#ifndef _COM_SUN_STAR_REFLECTION_XIDLMETHOD_HPP_ +#include <com/sun/star/reflection/XIdlMethod.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XEXACTNAME_HPP_ +#include <com/sun/star/beans/XExactName.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XEVENTATTACHER_HPP_ +#include <com/sun/star/script/XEventAttacher.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XEVENTATTACHERMANAGER_HPP_ +#include <com/sun/star/script/XEventAttacherManager.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_SCRIPTEVENT_HPP_ +#include <com/sun/star/script/ScriptEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XSCRIPTLISTENER_HPP_ +#include <com/sun/star/script/XScriptListener.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_SCRIPTEVENTDESCRIPTOR_HPP_ +#include <com/sun/star/script/ScriptEventDescriptor.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_ +#include <com/sun/star/lang/XEventListener.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_EVENTOBJECT_HPP_ +#include <com/sun/star/lang/EventObject.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XALLLISTENERADAPTERSERVICE_HPP_ +#include <com/sun/star/script/XAllListenerAdapterService.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XALLLISTENER_HPP_ +#include <com/sun/star/script/XAllListener.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_ALLEVENTOBJECT_HPP_ +#include <com/sun/star/script/AllEventObject.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_NOSUCHELEMENTEXCEPTION_HPP_ +#include <com/sun/star/container/NoSuchElementException.hpp> +#endif +#include <com/sun/star/beans/XMaterialHolder.hpp> + + +#ifndef _TYPELIB_TYPEDESCRIPTION_H_ +#include <uno/typedescription.h> +#endif +#ifndef _OSL_INTERLOCK_H_ +#include <osl/interlck.h> +#endif +#ifndef _COM_SUN_STAR_UNO_GENFUNC_H_ +#include <com/sun/star/uno/genfunc.h> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +#include "comifaces.hxx" +#include "jscriptclasses.hxx" +#include "oleobjw.hxx" +#include "unoobjw.hxx" +#include "servprov.hxx" + +using namespace vos; +using namespace std; +using namespace rtl; +using namespace osl; +using namespace cppu; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; +using namespace com::sun::star::container; +using namespace com::sun::star::script; +using namespace com::sun::star::lang; +using namespace com::sun::star::bridge::ModelDependent; + +#define INVOCATION_SERVICE L"com.sun.star.script.Invocation" +#define JSCRIPT_VALUE_FUNC L"_GetValueObject" +#define DISPID_JSCRIPT_VALUE_FUNC -1000l + + + +#if _MSC_VER < 1200 +extern "C" const GUID IID_IDispatchEx; +#endif + +namespace ole_adapter +{ +static sal_Bool writeBackOutParameter(VARIANTARG* pDest, VARIANT* pSource); +static sal_Bool writeBackOutParameter2( VARIANTARG* pDest, VARIANT* pSource); +//static const VARTYPE getVarType( const Any& val); +//static sal_Bool convertValueObject( const VARIANTARG *var, Any& any, sal_Bool& bHandled); +static HRESULT mapCannotConvertException( CannotConvertException e, unsigned int * puArgErr); + + + +/***************************************************************************** + + static objects + +*****************************************************************************/ + +OMutex globalWrapperMutex; +//static WrapperMap globalWrapperMap; + +/***************************************************************************** + + class implementation: InterfaceOleWrapper_Impl + +*****************************************************************************/ +InterfaceOleWrapper_Impl::InterfaceOleWrapper_Impl( Reference<XMultiServiceFactory>& xFactory, + sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass): + m_defaultValueType( 0), + UnoConversionUtilities<InterfaceOleWrapper_Impl>( xFactory, unoWrapperClass, comWrapperClass) +{ +} + +InterfaceOleWrapper_Impl::~InterfaceOleWrapper_Impl() +{ +} + +STDMETHODIMP InterfaceOleWrapper_Impl::QueryInterface(REFIID riid, LPVOID FAR * ppv) +{ + HRESULT ret= S_OK; + + if( !ppv) + return E_POINTER; + + if(IsEqualIID(riid, IID_IUnknown)) + { + AddRef(); + *ppv = (IUnknown*) (IDispatch*) this; + } + else if (IsEqualIID(riid, IID_IDispatch)) + { + AddRef(); + *ppv = (IDispatch*) this; + } + else if( IsEqualIID( riid, __uuidof( IUnoObjectWrapper))) + { + AddRef(); + *ppv= (IUnoObjectWrapper*) this; + } + else + ret= E_NOINTERFACE; +// else if (IsEqualIID(riid, IID_IDispatchEx)) +// { +// AddRef(); +// *ppv = (IDispatchEx*) this; +// return NOERROR; +// } +// else if (IsEqualIID(riid, IID_IConnectionPointContainer)) +// { +// AddRef(); +// *ppv = (IConnectionPointContainer*) this; +// return NOERROR; +// } +// + return ret; +} + +STDMETHODIMP_(ULONG) InterfaceOleWrapper_Impl::AddRef() +{ + return m_refCount.acquire(); +} + +STDMETHODIMP_(ULONG) InterfaceOleWrapper_Impl::Release() +{ + ULONG n; + + { + OGuard guard(globalWrapperMutex); + + n = m_refCount.release(); + } + + if (n == 0) + { + delete this; + } + + return n; +} + +// IUnoObjectWrapper -------------------------------------------------------- +STDMETHODIMP InterfaceOleWrapper_Impl::getWrapperXInterface( Reference<XInterface>* pXInt) +{ + *pXInt= Reference<XInterface>( static_cast<XWeak*>( this), UNO_QUERY); + return pXInt->is() ? S_OK : E_FAIL; +} +STDMETHODIMP InterfaceOleWrapper_Impl::getOriginalUnoObject( Reference<XInterface>* pXInt) +{ + *pXInt= m_xOrigin; + return S_OK; +} +STDMETHODIMP InterfaceOleWrapper_Impl::getOriginalUnoStruct( Any * pStruct) +{ + HRESULT ret= E_FAIL; + if( !m_xOrigin.is()) + { + Reference<XMaterialHolder> xMatHolder( m_xInvocation, UNO_QUERY); + if( xMatHolder.is()) + { + Any any = xMatHolder->getMaterial(); + if( any.getValueTypeClass() == TypeClass_STRUCT) + { + *pStruct= any; + ret= S_OK; + } + } + } + return ret; +} + +STDMETHODIMP InterfaceOleWrapper_Impl::GetTypeInfoCount( unsigned int * pctinfo ) +{ + return E_NOTIMPL ; +} + +STDMETHODIMP InterfaceOleWrapper_Impl::GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo ** pptinfo) +{ + return E_NOTIMPL; +} + +STDMETHODIMP InterfaceOleWrapper_Impl::GetIDsOfNames(REFIID riid, + OLECHAR ** rgszNames, + unsigned int cNames, + LCID lcid, + DISPID * rgdispid ) +{ + if( ! rgdispid) + return E_POINTER; + HRESULT ret = E_UNEXPECTED; + // ---------------------------------------- + if( ! wcscmp( *rgszNames, JSCRIPT_VALUE_FUNC)) + { + *rgdispid= DISPID_JSCRIPT_VALUE_FUNC; + return S_OK; + } + // ---------------------------------------- + if (m_xInvocation.is() && (cNames > 0)) + { + OUString name(rgszNames[0]); + NameToIdMap::iterator iter = m_nameToDispIdMap.find(name); + + if (iter == m_nameToDispIdMap.end()) + { + OUString exactName; + + if (m_xExactName.is()) + { + exactName = m_xExactName->getExactName(name); + } + else + { + exactName = name; + } + + MemberInfo d(0, exactName); + + if (m_xInvocation->hasProperty(exactName)) + { + d.flags |= DISPATCH_PROPERTYGET; + d.flags |= DISPATCH_PROPERTYPUT; + d.flags |= DISPATCH_PROPERTYPUTREF; + } + + if (m_xInvocation->hasMethod(exactName)) + { + d.flags |= DISPATCH_METHOD; + } + + if (d.flags != 0) + { + m_MemberInfos.push_back(d); + iter = m_nameToDispIdMap.insert(NameToIdMap::value_type(exactName, (DISPID)m_MemberInfos.size())).first; + + if (exactName != name) + { + iter = m_nameToDispIdMap.insert(NameToIdMap::value_type(name, (DISPID)m_MemberInfos.size())).first; + } + } + } + + if (iter == m_nameToDispIdMap.end()) + { + ret = ResultFromScode(DISP_E_UNKNOWNNAME); + } + else + { + *rgdispid = (*iter).second; + ret = ResultFromScode(S_OK); + } + } + + return ret; +} + +// "convertVARIANTARGS" converts VARIANTS to their respecting Any counterparts +// As parameter it uses some of the parameters passed to IDispatch::Invoke. These +// ar "id", "wFlags" and "pdispparams". The function handles special JavaScript +// cases where a VARIANT of type VT_DISPATCH is ambiguous and can represent +// an object, array ( JavaScript Array object), out ( Array) and in/out ( Array) +// parameter. Because all those VT_DISPATCH objects need a different conversion +// we have to find out what the object is supposed to be. The function does this +// by either using type information or by help of specialized JavaScript object. + +// A. Type Information +// ----------------------------------------------------------------------------- +// With the help of type information the kind of parameter can be exactly determined +// and an appropriate conversion can be choosen. A problem arises if a method expects +// an Any. Then the type info does not tell what the type of the value, that is kept +// by the any, should be. In this situation the decision wheter the param is a +// sequence or an object is made upon the fact if the object has a property "0" +// ( see function "isJScriptArray"). Since this is unsafe it is recommended to use +// the JScript value objects within a JScript script on such an occasion. + +// B. JavaScript Value Object ( class JScriptValue ) +// ----------------------------------------------------------------------------- +// A JScriptValue object is a COM object in that it implements IDispatch and the +// IJScriptValue object interface. Such objects are provided by all UNO wrapper +// objects used within a JScript script. To obtain an instance one has to call +// "_GetValueObject()" on an UNO wrapper object (class InterfaceOleWrapper_Impl). +// A value object is appropriately initialized within the script and passed as +// parameter to an UNO object method or property. The convertVARIANTARGS function +// can easily find out that a param is such an object by queriing for the +// IJScriptValue interface. By this interface one the type and kind ( out, in/out) +// can be determined and the right conversion can be applied. +// Using ValueObjects we spare us the effort of aquiring and examining type information +// in order to figure out what the an IDispatch parameter is meant for. + +// Normal JScript object parameter can be mixed with JScriptValue object. If an +// VARIANT contains an VT_DISPATCH that is no JScriptValue than the type information +// is used to find out about the reqired type. + +// out Parameter in Visual Basic have the type VT_BYREF | VT_VARIANT and if the bridge +// is used from C++ than the type is usually VT_BYREF |VT_xxx. Those parameter are converted +// and we don't go to the trouble of aquiring type information. +sal_Bool InterfaceOleWrapper_Impl::convertVARIANTARGS( DISPID id, unsigned short wFlags, DISPPARAMS* pdispparams, Sequence<Any>& rSeq) +{ + HRESULT hr; + if( pdispparams->cArgs == 0) + return TRUE; + sal_Bool convOk = TRUE; + + // iterate over all parameter and check for special JScript value objects that originated in this bridge. + // Those can be converted straight away. The index in the sequence "seqConvertedParams" matches the index in the + // DISPPARAMS.rgvarg array. If the value is true then the corresponding VARIANT has been converted + // and the any has been written to the Sequence that holds the converted values. + Sequence< sal_Bool > seqConvertedParams( pdispparams->cArgs); + rSeq.realloc( pdispparams->cArgs); + Any* pParams = rSeq.getArray(); + + sal_Bool allDispHandled= sal_True; + Any anyParam; + sal_Bool bHandled= sal_False; + + for( int i= 0; i < pdispparams->cArgs; i++) + { + if( sal_False == convertValueObject( &pdispparams->rgvarg[i], anyParam, bHandled) ) + { + convOk= sal_False; + break; + } + else if( bHandled) + {// a param is a JScriptValue and could be converted + pParams[pdispparams->cArgs - i - 1]= anyParam; + seqConvertedParams[i]= sal_True; + continue; + }// also take care of VBasic ( VT_BYREF) + else if( (pdispparams->rgvarg[i].vt & VT_DISPATCH )== VT_DISPATCH ) + allDispHandled= sal_False; + } + + if( ! convOk) + return sal_False; + // ---------------------- + + // If there is a VT_DISPATCH and it is no JScriptValue object then + // we need to know if it represents a Sequence, out or in/out parameter + // or an actual object. Therefore we obtain type information + try{ + Sequence<ParamMode> seqParamMode; + sal_Bool bTypesAvailable= sal_False; + Sequence< Type > seqParamTypes; + sal_Bool bIsMethod= sal_False; + + //only aquire type information if at least one of the parameter is IDispatch + // and has not been convert yet because it is no JScriptValue object + if( ! allDispHandled) + { + if( !m_xInvocation.is() )return FALSE; + Reference<XIntrospectionAccess> xIntroAccess= m_xInvocation->getIntrospection(); + if( !xIntroAccess.is()) return FALSE; + + // We need the name of the property or method to get its type description + // The name can be identified through the param "id" + // that is kept als value in the map m_nameToDispIdMap. + // Proplem: the Windows JScript engine sometimes changes small letters to capital + // letters as happens in xidlclass_obj.createObject( var) // in JScript. + // IDispatch::GetIdsOfNames is then called with "CreateObject" !!! + // m_nameToDispIdMap can contain several names for one DISPID but only one is + // the exact one. If there's no m_xExactName and therfore no exact name then + // there's only one entry in the map. + typedef NameToIdMap::const_iterator cit; + OUString sMemberName; + if( m_xExactName.is()) + { + for(cit ci1= m_nameToDispIdMap.begin(); ci1 != m_nameToDispIdMap.end(); ci1++) + { + if( (*ci1).second == id) // iterator is a pair< OUString, DISPID> + { + sMemberName= (*ci1).first; + sMemberName= m_xExactName->getExactName( sMemberName); + break; + } + } + } + else // the first match is certainly the only + { + for(cit ci1= m_nameToDispIdMap.begin(); ci1 != m_nameToDispIdMap.end(); ci1++) + { + if( (*ci1).second == id) // iterator is a pair< OUString, DISPID> + { + sMemberName= (*ci1).first; + break; + } + } + } + + if( sMemberName == L"") + return FALSE; + // Get the type description of the uno method or property + // Problem: In some cases DISPATCH_METHOD AND!!! DISPATCH_PROPERTYPUT or + // DISPATCH_PROPERTYGET can be set. That might + // be due to VBScript or JScript that can't differ what's what or it doesnt matter + // For that reaseon we can't use the wFlags param in Invoke + // The automation wrapper (this class (InterfaceOleWrapper_Impl) doesn't provide + // any type information currently. + try{ + // throws // NoSuchMethodException + Reference< XIdlMethod > spTypeMethod= xIntroAccess->getMethod( sMemberName, MethodConcept::ALL); + // ---------------- + Sequence< ParamInfo > seqInfos= spTypeMethod->getParameterInfos(); + Sequence< Reference< XIdlClass > > seqParamClasses= spTypeMethod->getParameterTypes(); + int count= min( seqParamClasses.getLength(), seqConvertedParams.getLength()); + + seqParamTypes.realloc( count); + seqParamMode.realloc( count); + // -------------------- + for( int i= 0; i < count ; i++) + { + seqParamTypes[i]= Type( seqParamClasses[count - 1 - i]->getTypeClass(), + seqParamClasses[count - 1 - i]->getName()); + + seqParamMode[i]= seqInfos[ count - 1 -i].aMode; + } + bTypesAvailable= sal_True; + bIsMethod= sal_True; + }catch(...) {} + + if( ! bTypesAvailable) + { + try{ + // throws NoSuchElementException + Property aProperty= xIntroAccess->getProperty( sMemberName, PropertyConcept::ATTRIBUTES); + seqParamTypes.realloc(1); + seqParamTypes[0]= aProperty.Type; + bTypesAvailable= sal_True; + }catch(...) {} + } + if( ! bTypesAvailable) + return FALSE; + } + + // used within the for loop. If the param is a IDispatch and the reqired parameter + // is an in/out parameter, then this uno wrapper is likely used in JScript. Then we + // extract Array[0] and put the value into varParam. At the end of the loop varParam + // is converted if it contains a value otherwise the VARIANT from + // DISPPARAMS is converted. + CComVariant varParam; + + // In this loop all params are converted except for those which are already converted + // by convertValueObject ( see above ). If a parameter is converted or is can be infered + // from the Sequence seqConvertedParams. Its values relate to the VARIANT params in DISPPARAMS + // at the same index. + for (int i = 0; convOk && (i < pdispparams->cArgs); i++) + { + if( seqConvertedParams[i] == sal_True) + continue; + sal_Bool bDoConversion= TRUE; + varParam.Clear(); + // Check for dispatch + // If the param is one and is not refereced ( VT_BYREF) then it could be an object + // from JScript like an Array used for Squences and out-params + if( pdispparams->rgvarg[i].vt == VT_DISPATCH ) + { + if( bIsMethod && seqParamMode[i] == ParamMode_INOUT) + { + // An INOUT-param in JSCript must be VT_DISPATCH since JScript Array objects are used + // for OUT-params. Index ( property) "0" contains the actual IN-param. + // It can also be an JScript Array or an other object (Interface). + // First get the IN-param at index "0" + IDispatch* pdisp= pdispparams->rgvarg[i].pdispVal; + + OLECHAR* sindex= L"0"; + DISPID id; + DISPPARAMS noParams= {0,0,0,0}; + if(SUCCEEDED( hr= pdisp->GetIDsOfNames( IID_NULL, &sindex, 1, LOCALE_USER_DEFAULT, &id))) + hr= pdisp->Invoke( id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, + &noParams, &varParam, NULL, NULL); + if( FAILED( hr)) + { + varParam.Clear(); + convOk= FALSE; break; + } + } + else if( bIsMethod && seqParamMode[i] == ParamMode_OUT) + { + // No conversion necessary. The VT_DISPATCH represents + // an Array in which the outparam is written on index 0 + bDoConversion= FALSE; + } + } + if( bDoConversion) + { + if( varParam.vt == VT_EMPTY) // then it was no in/out parameter + varParam= pdispparams->rgvarg[i]; + + Any theParam; + if( bTypesAvailable) + convOk= variantToAny2( & varParam,theParam, + seqParamTypes[i]); + else + convOk = variantToAny( & varParam, theParam); + + if( convOk) + pParams[pdispparams->cArgs - (i + 1)]= theParam; + } + + }// end for / iterating over all parameters + + + }catch(NoSuchMethodException e) + { + e; + convOk= FALSE; + }catch(RuntimeException e) + { + e; + convOk= FALSE; + }catch( NoSuchElementException e) + { + e; + convOk= FALSE; + } + catch(...) + { + convOk= FALSE; + } + return convOk; +} + +// XBridgeSupplier2 --------------------------------------------------- +// only bridges itself ( this instance of InterfaceOleWrapper_Impl)from UNO to IDispatch +// If sourceModelType is UNO than any UNO interface implemented by InterfaceOleWrapper_Impl +// can bridged to IDispatch ( if destModelType == OLE). The IDispatch is +// implemented by this class. +Any SAL_CALL InterfaceOleWrapper_Impl::createBridge(const Any& modelDepObject, + const Sequence<sal_Int8>& ProcessId, + sal_Int16 sourceModelType, + sal_Int16 destModelType) + throw (IllegalArgumentException, RuntimeException) +{ + + Any retAny; + if( sourceModelType == UNO && destModelType == OLE && + modelDepObject.getValueTypeClass() == TypeClass_INTERFACE ) + { + Reference<XInterface> xInt; + if( modelDepObject >>= xInt ) + { + if( xInt == Reference<XInterface>( static_cast<XWeak*>( this)), UNO_QUERY) + { + VARIANT *pVar= (VARIANT*)CoTaskMemAlloc( sizeof( VARIANT)); + if( pVar) + { + pVar->vt= VT_DISPATCH; + pVar->pdispVal= static_cast<IDispatch*>( this); + AddRef(); + + retAny<<= reinterpret_cast< sal_uInt32 >( pVar); + } + } + } + } + + return retAny; +} + +// XInterface ------------------------------------------------------ +void SAL_CALL InterfaceOleWrapper_Impl::acquire( ) throw() +{ + AddRef(); +} +void SAL_CALL InterfaceOleWrapper_Impl::release( ) throw() +{ + Release(); +} + + +// XInitialization -------------------------------------------------- +void SAL_CALL InterfaceOleWrapper_Impl::initialize( const Sequence< Any >& aArguments ) + throw(Exception, RuntimeException) +{ + switch( aArguments.getLength() ) + { + case 2: // the object wraps an UNO struct + aArguments[0] >>= m_xInvocation; + aArguments[1] >>= m_defaultValueType; + break; + case 3: // the object wraps an UNO interface + aArguments[0] >>= m_xInvocation; + aArguments[1] >>= m_xOrigin; + aArguments[2] >>= m_defaultValueType; + break; + } + + m_xExactName= Reference< XExactName> ( m_xOrigin, UNO_QUERY); + if( ! m_xExactName.is()) + { + m_xExactName= Reference<XExactName>( m_xInvocation, UNO_QUERY); + } + +} + +Reference< XInterface > InterfaceOleWrapper_Impl::createUnoWrapperInstance() +{ + Reference<XWeak> xWeak= static_cast<XWeak*>( new InterfaceOleWrapper_Impl( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); +} + +Reference<XInterface> InterfaceOleWrapper_Impl::createComWrapperInstance() +{ + Reference<XWeak> xWeak= static_cast<XWeak*>( new IUnknownWrapper_Impl( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); +} + + + +// "getType" is used in convertValueObject to map the string denoting the type +// to an actual Type object. +Type getType( const BSTR type) +{ + Type retType; + typelib_TypeDescription * pDesc= NULL; + OUString str( type); + typelib_typedescription_getByName( &pDesc, str.pData ); + if( pDesc) + { + retType= Type( pDesc->pWeakRef ); + typelib_typedescription_release( pDesc); + } + return retType; +} + + +static sal_Bool writeBackOutParameter2( VARIANTARG* pDest, VARIANT* pSource) +{ + sal_Bool ret = sal_False; + HRESULT hr; + + if( !(pDest->vt & VT_BYREF) && (pDest->vt == VT_DISPATCH) ) + { + CComPtr <IJScriptValueObject> spValue; + + // special Handling for a JScriptValue object + if( SUCCEEDED( pDest->pdispVal->QueryInterface( __uuidof( IJScriptValueObject), + reinterpret_cast<void**> (&spValue)))) + + { + VARIANT_BOOL varBool= VARIANT_FALSE; + if( SUCCEEDED( hr= spValue->IsOutParam( &varBool) ) + && varBool == VARIANT_TRUE || + SUCCEEDED(hr= spValue->IsInOutParam( &varBool) ) + && varBool == VARIANT_TRUE ) + { + if( SUCCEEDED( spValue->Set( CComVariant(), *pSource))) + ret= sal_True; + } + } + else// // no VT_BYREF but VT_DISPATCH -> JScript out param + { + // prepare DISPPARAMS for PROPERTYPUT operation + DISPID namedArgs = DISPID_PROPERTYPUT; + DISPPARAMS dispparamsPut; + dispparamsPut.rgdispidNamedArgs= &namedArgs; + dispparamsPut.cArgs = 1; + dispparamsPut.cNamedArgs = 1; + + CComBSTR bstrNullIndex= SysAllocString( L"0"); + if( bstrNullIndex) + { + CComPtr<IDispatchEx> pdispEx; + if( SUCCEEDED( hr= pDest->pdispVal->QueryInterface( IID_IDispatchEx, (void**)&pdispEx))) + { + DISPID dispid; + if( SUCCEEDED(hr= pdispEx->GetDispID( bstrNullIndex, fdexNameEnsure, &dispid))) + { + dispparamsPut.rgvarg= pSource; + if( SUCCEEDED( hr= pdispEx->InvokeEx(dispid, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, + &dispparamsPut, NULL, NULL, NULL))) + ret= sal_True; + } // if( bstrIndex) + } + } + } + } + else // The param can't be a JScript out-parameter ( an Array object), it could be a VBScript + { // param. The function checks itself for correct VBScript params + ret= writeBackOutParameter( pDest, pSource); + } + + + return ret; +} +// VisualBasic Script passes arguments as VT_VARIANT | VT_BYREF be it in or out parameter. +// Thus we are in charge of freeing an eventual value contained by the inner VARIANT +// Please note: VariantCopy doesn't free a VT_BYREF value +static sal_Bool writeBackOutParameter(VARIANTARG* pDest, VARIANT* pSource) +{ + HRESULT hr; + sal_Bool ret = FALSE; + // Out parameter must be VT_BYREF + if ((V_VT(pDest) & VT_BYREF) != 0 ) + { + VARTYPE oleTypeFlags = V_VT(pSource); + + // if caller accept VARIANT as out parameter, any value must be converted + if (V_VT(pDest) == (VT_VARIANT | VT_BYREF)) + { + if (oleTypeFlags == (VT_VARIANT | VT_BYREF)) + { + if (V_VARIANTREF(pSource) != NULL) + VariantCopy(V_VARIANTREF(pDest), V_VARIANTREF(pSource)); + ret = sal_True; + } + else + { + VariantCopy(V_VARIANTREF(pDest), pSource); + ret = sal_True; + } + } + else + { + // variantarg and variant must have same type + if ((V_VT(pDest) & oleTypeFlags) == oleTypeFlags) + { + if ((oleTypeFlags & VT_ARRAY) != 0) + { + // copy safearray + // if VT_ARRAY | VT_BYREF then VariantCopy doesn't destroy the array + if (*V_ARRAYREF(pDest) != NULL) + SafeArrayDestroy(*V_ARRAYREF(pDest)); + + if (SafeArrayCopy(V_ARRAY(pSource), V_ARRAYREF(pDest)) == NOERROR) + ret = sal_True; + } + else + { + // copy base type + switch (V_VT(pSource)) + { + case VT_I2: + *V_I2REF(pDest) = V_I2(pSource); + ret = sal_True; + break; + case VT_I4: + *V_I4REF(pDest) = V_I4(pSource); + ret = sal_True; + break; + case VT_R4: + *V_R4REF(pDest) = V_R4(pSource); + ret = sal_True; + break; + case VT_R8: + *V_R8REF(pDest) = V_R8(pSource); + ret = sal_True; + break; + case VT_CY: + *V_CYREF(pDest) = V_CY(pSource); + ret = sal_True; + break; + case VT_DATE: + *V_DATEREF(pDest) = V_DATE(pSource); + ret = sal_True; + break; + case VT_BSTR: + *V_BSTRREF(pDest) = SysAllocString(V_BSTR(pSource)); + ret = sal_True; + break; + case VT_DISPATCH: + if (*V_DISPATCHREF(pDest) != NULL) + (*V_DISPATCHREF(pDest))->Release(); + + *V_DISPATCHREF(pDest) = V_DISPATCH(pSource); + + if (*V_DISPATCHREF(pDest) != NULL) + (*V_DISPATCHREF(pDest))->AddRef(); + + ret = sal_True; + break; + case VT_ERROR: + *V_ERRORREF(pDest) = V_ERROR(pSource); + ret = sal_True; + break; + case VT_BOOL: + *V_BOOLREF(pDest) = V_BOOL(pSource); + ret = sal_True; + break; + case VT_UNKNOWN: + if (*V_UNKNOWNREF(pDest) != NULL) + (*V_UNKNOWNREF(pDest))->Release(); + + *V_UNKNOWNREF(pDest) = V_UNKNOWN(pSource); + + if (*V_UNKNOWNREF(pDest) != NULL) + (*V_UNKNOWNREF(pDest))->AddRef(); + + ret = sal_True; + break; + case VT_I1: + *V_I1REF(pDest) = V_I1(pSource); + ret = sal_True; + break; + case VT_UI1: + *V_UI1REF(pDest) = V_UI1(pSource); + ret = sal_True; + break; + case VT_UI2: + *V_UI2REF(pDest) = V_UI2(pSource); + ret = sal_True; + break; + case VT_UI4: + *V_UI4REF(pDest) = V_UI4(pSource); + ret = sal_True; + break; + case VT_INT: + *V_INTREF(pDest) = V_INT(pSource); + ret = sal_True; + break; + case VT_UINT: + *V_UINTREF(pDest) = V_UINT(pSource); + ret = sal_True; + break; + default: + break; + } + } + } + } + } + return ret; +} + + + +STDMETHODIMP InterfaceOleWrapper_Impl::Invoke(DISPID dispidMember, + REFIID riid, + LCID lcid, + unsigned short wFlags, + DISPPARAMS * pdispparams, + VARIANT * pvarResult, + EXCEPINFO * pexcepinfo, + unsigned int * puArgErr ) +{ + HRESULT ret = S_OK; + + sal_Bool bHandled= sal_False; + ret= InvokeGeneral( dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo, + puArgErr, bHandled); + if( bHandled) + return ret; + + if ((dispidMember > 0) && (dispidMember <= m_MemberInfos.size()) && m_xInvocation.is()) + { + MemberInfo d = m_MemberInfos[dispidMember - 1]; + DWORD flags = wFlags & d.flags; + + if (flags != 0) + { + if ((flags & DISPATCH_METHOD) != 0) + { + if (pdispparams->cNamedArgs > 0) + ret = DISP_E_NONAMEDARGS; + else + { + Sequence<Any> params; + if( convertVARIANTARGS(dispidMember, wFlags, pdispparams , params )) + { + ret= doInvoke( pdispparams, pvarResult, + pexcepinfo, puArgErr, d.name, params ); + } + else + ret = DISP_E_BADVARTYPE; + } + } + else if ((flags & DISPATCH_PROPERTYGET) != 0) + { + ret= doGetProperty( pdispparams, pvarResult, + pexcepinfo, d.name); + } + else if ((flags & DISPATCH_PROPERTYPUT || flags & DISPATCH_PROPERTYPUTREF) != 0) + { + if (pdispparams->cArgs != 1) + ret = DISP_E_BADPARAMCOUNT; + else + { + Sequence<Any> params; + if (convertVARIANTARGS(dispidMember, wFlags, pdispparams, params ) && (params.getLength() > 0)) + { + ret= doSetProperty( pdispparams, pvarResult, pexcepinfo, puArgErr, d.name, params); + } + else + ret = DISP_E_BADVARTYPE; + } + } + } + } + else + ret = DISP_E_MEMBERNOTFOUND; + + return ret; +} + +HRESULT InterfaceOleWrapper_Impl::doInvoke( DISPPARAMS * pdispparams, VARIANT * pvarResult, + EXCEPINFO * pexcepinfo, unsigned int * puArgErr, OUString& name, Sequence<Any>& params) +{ + + HRESULT ret= S_OK; + Sequence<INT16> outIndex; + Sequence<Any> outParams; + Any returnValue; + + if (pdispparams->cNamedArgs > 0) + return DISP_E_NONAMEDARGS; + + // invoke method and take care of exceptions + try + { + returnValue = m_xInvocation->invoke(name, + params, + outIndex, + outParams); + + // try to write back out parameter + if (outIndex.getLength() > 0) + { + const INT16* pOutIndex = outIndex.getConstArray(); + const Any* pOutParams = outParams.getConstArray(); + + for (UINT32 i = 0; i < outIndex.getLength(); i++) + { + VARIANT variant; + + VariantInit(&variant); + + // Currently a Sequence is converted to an SafeArray of VARIANTs. + anyToVariant( &variant, pOutParams[i]); + + // out parameter need special handling if they are VT_DISPATCH + // and used in JScript + int outindex= pOutIndex[i]; + writeBackOutParameter2(&(pdispparams->rgvarg[pdispparams->cArgs - 1 - outindex]), + &variant ); + + VariantClear(&variant); + } + } + + // write back return value + if ((pvarResult != NULL) && ! anyToVariant(pvarResult, returnValue)) + { + ret = DISP_E_BADVARTYPE; + } +// else +// { +// ret = NOERROR; +// } + } + catch(IllegalArgumentException e) + { + e; + ret = ResultFromScode(DISP_E_TYPEMISMATCH); + } + catch(CannotConvertException e) + { + ret= mapCannotConvertException( e, puArgErr); + } + catch(InvocationTargetException e) + { + if (pexcepinfo != NULL) + { + Any org = e.TargetException; + + pexcepinfo->wCode = UNO_2_OLE_EXCEPTIONCODE; + pexcepinfo->bstrSource = SysAllocString(L"any ONE component"); + pexcepinfo->bstrDescription = SysAllocString( + org.getValueType().getTypeName()); + } + ret = ResultFromScode(DISP_E_EXCEPTION); + } + catch( NoSuchMethodException e) + { + ret= DISP_E_MEMBERNOTFOUND; + } + catch( ... ) + { + ret= DISP_E_EXCEPTION; + } + return ret; +} + +HRESULT InterfaceOleWrapper_Impl::doGetProperty( DISPPARAMS * pdispparams, VARIANT * pvarResult, + EXCEPINFO * pexcepinfo, OUString& name) +{ + HRESULT ret= S_OK; + + Any value; + try + { + Any returnValue = m_xInvocation->getValue( name); + // write back return value + if (!anyToVariant(pvarResult, returnValue)) { + ret = DISP_E_BADVARTYPE; + } + } + catch(UnknownPropertyException e) + { + ret = DISP_E_MEMBERNOTFOUND; + } + catch( ... ) + { + ret= DISP_E_EXCEPTION; + } + return ret; +} + +HRESULT InterfaceOleWrapper_Impl::doSetProperty( DISPPARAMS * pdispparams, VARIANT * pvarResult, + EXCEPINFO * pexcepinfo, unsigned int * puArgErr, OUString& name, Sequence<Any> params) +{ + HRESULT ret= S_OK; + + try + { + m_xInvocation->setValue( name, params.getConstArray()[0]); + } + catch(UnknownPropertyException ) + { + ret = DISP_E_MEMBERNOTFOUND; + } + catch(CannotConvertException e) + { + ret= mapCannotConvertException( e, puArgErr); + } + catch(InvocationTargetException e) + { + if (pexcepinfo != NULL) + { + Any org = e.TargetException; + + pexcepinfo->wCode = UNO_2_OLE_EXCEPTIONCODE; + pexcepinfo->bstrSource = SysAllocString(L"any ONE component"); + pexcepinfo->bstrDescription = SysAllocString( + org.getValueType().getTypeName()); + } + ret = DISP_E_EXCEPTION; + } + catch( ... ) + { + ret= DISP_E_EXCEPTION; + } + return ret; +} + +HRESULT InterfaceOleWrapper_Impl::InvokeGeneral( DISPID dispidMember, unsigned short wFlags, + DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, + unsigned int * puArgErr, sal_Bool& bHandled) +{ + HRESULT ret= S_OK; +// DISPID_VALUE | The DEFAULT Value is required in JScript when the situation +// is that we put an object into an Array object ( out parameter). We have to return +// IDispatch otherwise the object cannot be accessed from the Script. + if( dispidMember == DISPID_VALUE && wFlags == DISPATCH_PROPERTYGET + && m_defaultValueType != VT_EMPTY && pvarResult != NULL) + { + bHandled= sal_True; + if( m_defaultValueType == VT_DISPATCH) + { + pvarResult->vt= VT_DISPATCH; + pvarResult->pdispVal= static_cast<IDispatch*>( this); + AddRef(); + ret= S_OK; + } + } +// --------- + // function: _GetValueObject + else if( dispidMember == DISPID_JSCRIPT_VALUE_FUNC) + { + bHandled= sal_True; + if( !pvarResult) + ret= E_POINTER; + CComObject< JScriptValue>* pValue; + if( SUCCEEDED( CComObject<JScriptValue>::CreateInstance( &pValue))) + { + pvarResult->vt= VT_UNKNOWN; + pvarResult->punkVal= pValue->GetUnknown(); + pvarResult->punkVal->AddRef(); + ret= S_OK; + } + else + ret= DISP_E_EXCEPTION; + } + return S_OK; +} + +STDMETHODIMP InterfaceOleWrapper_Impl::GetDispID(BSTR bstrName, DWORD grfdex, DISPID __RPC_FAR *pid) +{ + HRESULT ret = ResultFromScode(E_NOTIMPL); + + return ret; +} + +STDMETHODIMP InterfaceOleWrapper_Impl::InvokeEx( + /* [in] */ DISPID id, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [in] */ DISPPARAMS __RPC_FAR *pdp, + /* [out] */ VARIANT __RPC_FAR *pvarRes, + /* [out] */ EXCEPINFO __RPC_FAR *pei, + /* [unique][in] */ IServiceProvider __RPC_FAR *pspCaller) +{ + HRESULT ret = ResultFromScode(E_NOTIMPL); + + return ret; +} + + +STDMETHODIMP InterfaceOleWrapper_Impl::DeleteMemberByName( + /* [in] */ BSTR bstr, + /* [in] */ DWORD grfdex) +{ + HRESULT ret = ResultFromScode(E_NOTIMPL); + + return ret; +} + +STDMETHODIMP InterfaceOleWrapper_Impl::DeleteMemberByDispID(DISPID id) +{ + HRESULT ret = ResultFromScode(E_NOTIMPL); + + return ret; +} + +STDMETHODIMP InterfaceOleWrapper_Impl::GetMemberProperties( + /* [in] */ DISPID id, + /* [in] */ DWORD grfdexFetch, + /* [out] */ DWORD __RPC_FAR *pgrfdex) +{ + HRESULT ret = ResultFromScode(E_NOTIMPL); + + return ret; +} + +STDMETHODIMP InterfaceOleWrapper_Impl::GetMemberName( + /* [in] */ DISPID id, + /* [out] */ BSTR __RPC_FAR *pbstrName) +{ + HRESULT ret = ResultFromScode(E_NOTIMPL); + + return ret; +} + +STDMETHODIMP InterfaceOleWrapper_Impl::GetNextDispID( + /* [in] */ DWORD grfdex, + /* [in] */ DISPID id, + /* [out] */ DISPID __RPC_FAR *pid) +{ + HRESULT ret = ResultFromScode(E_NOTIMPL); + + return ret; +} + +STDMETHODIMP InterfaceOleWrapper_Impl::GetNameSpaceParent( + /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppunk) +{ + HRESULT ret = ResultFromScode(E_NOTIMPL); + + return ret; +} + +//STDMETHODIMP InterfaceOleWrapper_Impl::EnumConnectionPoints(IEnumConnectionPoints __RPC_FAR *__RPC_FAR *ppEnum) +//{ +// HRESULT ret = ResultFromScode(CONNECT_E_NOCONNECTION); +// +// (*ppEnum) = new EnumConnectionPoints_Impl(&m_rConnectionPoint, 1); +// +// return ret; +//} +// +//STDMETHODIMP InterfaceOleWrapper_Impl::FindConnectionPoint( +// /* [in] */ REFIID riid, +// /* [out] */ IConnectionPoint __RPC_FAR *__RPC_FAR *ppCP) +//{ +// HRESULT ret = ResultFromScode(S_OK); +// +// if (!m_rConnectionPoint.is()) +// { +// OGuard guard(globalWrapperMutex); +// +// if ((!m_rConnectionPoint.is()) && m_xOrigin.is() && m_xEventAttacher.is()) +// { +// ConnectionPoint_Impl* pConnectionPoint = new ConnectionPoint_Impl(m_xInvocation, m_xOrigin, m_xEventAttacher, this); +// +// m_rConnectionPoint = pConnectionPoint; +// } +// } +// +// *ppCP = m_rConnectionPoint.get(); +// +// (*ppCP)->AddRef(); +// +// return ret; +//} + +/***************************************************************************** + + class implementation: ConnectionPoint_Impl + +*****************************************************************************/ + + +//ConnectionPoint_Impl::ConnectionPoint_Impl(const Reference<XInvocation>& xInv, +// const Reference<XInterface>& xOrigin, +// const Reference<XEventAttacher>& xEventAttacher, +// IConnectionPointContainer* pContainer) +// : m_xInvocation(xInv) +// , m_xOrigin(xOrigin) +// , m_xEventAttacher(xEventAttacher) +// , m_rContainer(pContainer) +// , m_nextCookie(1) +//{ +//} +// +//ConnectionPoint_Impl::~ConnectionPoint_Impl() +//{ +//} +// +//STDMETHODIMP ConnectionPoint_Impl::QueryInterface(REFIID riid, LPVOID FAR * ppv) +//{ +// if(IsEqualIID(riid, IID_IUnknown)) +// { +// AddRef(); +// *ppv = (IUnknown*) (IConnectionPoint*) this; +// return NOERROR; +// } +// else if (IsEqualIID(riid, IID_IConnectionPoint)) +// { +// AddRef(); +// *ppv = (IConnectionPoint*) this; +// return NOERROR; +// } +// +// *ppv = NULL; +// +// return ResultFromScode(E_NOINTERFACE); +//} +// +//STDMETHODIMP_(ULONG) ConnectionPoint_Impl::AddRef() +//{ +// return m_refCount.acquire(); +//} +// +//STDMETHODIMP_(ULONG) ConnectionPoint_Impl::Release() +//{ +// +// ULONG n = m_refCount.release(); +// +// if (n == 0) +// { +// delete this; +// } +// +// return n; +//} +// +//STDMETHODIMP ConnectionPoint_Impl::GetConnectionInterface( IID __RPC_FAR *piid) +//{ +// HRESULT ret = ResultFromScode(S_OK); +// +// *piid = IID_IDispatch; +// +// return ret; +//} +// +//STDMETHODIMP ConnectionPoint_Impl::GetConnectionPointContainer(IConnectionPointContainer __RPC_FAR *__RPC_FAR *ppCPC) +//{ +// HRESULT ret = ResultFromScode(S_OK); +// +// *ppCPC = m_rContainer.get(); +// +// (*ppCPC)->AddRef(); +// +// return ret; +//} +// +//void ConnectionPoint_Impl::registerListener() +//{ +// Reference<XIntrospectionAccess> xAccess = m_xInvocation->getIntrospection(); +// +// if (xAccess.is()) +// { +// Sequence< Type > listeners = xAccess->getSupportedListeners(); +// Reference<XAllListener> xListener = this; +// +// for (sal_uInt32 i = 0; i < listeners.getLength(); i++) +// { +// GenListenerData data; + + // data.listenerType = OUString::createFromAscii( + // listeners.getConstArray()[i].getTypeName()); +// data.listenerType = listeners.getConstArray()[i].getTypeName(); +// +// try +// { +// data.xGenListener = m_xEventAttacher->attachListener(m_xOrigin, +// xListener, +// data.helper, +// data.listenerType, +// data.addListenerParam); +// +// m_xGenListenerList.push_back(data); +// } +// catch(IllegalArgumentException e) +// {e; +// } +// catch(IntrospectionException e) +// {e; +// } +// catch(CannotCreateAdapterException e) +// {e; +// } +// catch(ServiceNotRegisteredException e) +// {e; +// } +// } +// } +//} +// +//void ConnectionPoint_Impl::unregisterListener() +//{ +// Reference<XIntrospectionAccess> xAccess = m_xInvocation->getIntrospection(); +// +// if (xAccess.is()) +// { +// GenListenerDataList::iterator iter = m_xGenListenerList.begin(); +// +// while (iter != m_xGenListenerList.end()) +// { +// try +// { +// m_xEventAttacher->removeListener(m_xOrigin, +// (*iter).listenerType, +// (*iter).addListenerParam, +// (*iter).xGenListener); +// } +// catch(IllegalArgumentException e) +// {e; +// } +// catch(IntrospectionException e) +// {e; +// } +// +// iter++; +// } +// } +// +// m_xGenListenerList = GenListenerDataList(); +//} +// +//STDMETHODIMP ConnectionPoint_Impl::Advise(IUnknown __RPC_FAR *pUnkSink, DWORD __RPC_FAR *pdwCookie) +//{ +// HRESULT ret = ResultFromScode(CONNECT_E_CANNOTCONNECT); +// +// OGuard guard(globalWrapperMutex); +// +// IDispatch* pDispatch = NULL; +// +// if (pUnkSink->QueryInterface(IID_IDispatch, (void**) &pDispatch) == NOERROR) +// { +// *pdwCookie = m_nextCookie++; +// +// if (m_connection.size() == 0) +// { +// registerListener(); +// } +// +// m_connection.insert(ConnectionMap::value_type(*pdwCookie, OleRef<IDispatch>(pDispatch))); +// +// pDispatch->Release(); +// +// ret = ResultFromScode(S_OK); +// } +// +// return ret; +//} +// +//STDMETHODIMP ConnectionPoint_Impl::Unadvise(DWORD dwCookie) +//{ +// HRESULT ret = ResultFromScode(CONNECT_E_NOCONNECTION); +// +// OGuard guard(globalWrapperMutex); +// +// ConnectionMap::iterator iter = m_connection.find(dwCookie); +// +// if (iter != m_connection.end()) +// { +// m_connection.erase(iter); +// ret = ResultFromScode(S_OK); +// } +// +// if (m_connection.size() == 0) +// { +// unregisterListener(); +// } +// +// return ret; +//} +// +//STDMETHODIMP ConnectionPoint_Impl::EnumConnections(IEnumConnections __RPC_FAR *__RPC_FAR *ppEnum) +//{ +// HRESULT ret = ResultFromScode(S_OK); +// +// OGuard guard(globalWrapperMutex); +// +// CONNECTDATA* pConnection = NULL; +// UINT32 n = m_connection.size(); +// +// if (n > 0) +// { +// pConnection = new CONNECTDATA[n]; +// +// ConnectionMap::iterator iter = m_connection.begin(); +// UINT32 i = 0; +// +// while (iter != m_connection.end()) +// { +// (*iter).second->QueryInterface(IID_IUnknown, (void**)&(pConnection[i].pUnk)); +// pConnection[i].dwCookie = (*iter).first; +// +// i++; +// iter++; +// } +// +// *ppEnum = new EnumConnections_Impl(pConnection, n); +// +// for (i = 0; i < n; i++) +// { +// pConnection[i].pUnk->Release(); +// } +// +// delete[] pConnection; +// } +// else +// { +// *ppEnum = new EnumConnections_Impl(NULL, 0); +// } +// +// (*ppEnum)->AddRef(); +// +// return ret; +//} +// +// +// +// +//void SAL_CALL ConnectionPoint_Impl::disposing(const EventObject& Source) throw( RuntimeException) +//{ +//} +// +//void SAL_CALL ConnectionPoint_Impl::firing(const AllEventObject& Event) throw( RuntimeException) +//{ +// IEnumConnections* pEnum = NULL; +// +// EnumConnections(&pEnum); +// +// CONNECTDATA connection = {NULL, 0}; +// ULONG fetched = NULL; +// +// while (pEnum->Next(1, &connection, &fetched) == NOERROR) +// { +// IDispatch* pDispatch = NULL; +// +// if (connection.pUnk->QueryInterface(IID_IDispatch, (void**) &pDispatch) == NOERROR) +// { +// // getting dispid of event sink +// unsigned int flags = 0; +// HRESULT result; +// DISPID dispId; +// OLECHAR* oleNames[1]; +// +// oleNames[0] = (OLECHAR*)Event.MethodName.getStr(); +// +// result = pDispatch ->GetIDsOfNames(IID_NULL, +// oleNames, +// 1, +// LOCALE_SYSTEM_DEFAULT, +// &dispId); +// +// if (result == NOERROR) +// { +// DISPPARAMS dispparams; +// VARIANT varResult; +// EXCEPINFO excepinfo; +// unsigned int uArgErr; +// +// VariantInit(&varResult); +// +// // converting UNO parameters to OLE variants +// dispparams.rgdispidNamedArgs = NULL; +// dispparams.cArgs = Event.Arguments.getLength(); +// dispparams.cNamedArgs = 0; +// +// if (dispparams.cArgs == 0) +// { +// dispparams.rgvarg = NULL; +// } +// else +// { +// dispparams.rgvarg = (VARIANTARG*)malloc(sizeof(VARIANTARG) * dispparams.cArgs); +// +// for (UINT32 i = 0; i < dispparams.cArgs; i++) +// { +// o2u_anyToVariant(&(dispparams.rgvarg[i]), +// Event.Arguments.getConstArray()[dispparams.cArgs - (i + 1)]); +// } +// } +// +// // invoking OLE method +// result = pDispatch ->Invoke(dispId, +// IID_NULL, +// LOCALE_SYSTEM_DEFAULT, +// DISPATCH_METHOD, +// &dispparams, +// &varResult, +// &excepinfo, +// &uArgErr); +// +// +// // freeing allocated OLE parameters +// if (dispparams.cArgs > 0) +// { +// for (UINT32 i = 0; i < dispparams.cArgs; i++) +// { +// VariantClear(&(dispparams.rgvarg[i])); +// } +// free(dispparams.rgvarg); +// } +// +// VariantClear(&varResult); +// } +// +// // getting dispid of event sink +// oleNames[0] = L"EventRaised"; +// +// result = pDispatch ->GetIDsOfNames(IID_NULL, +// oleNames, +// 1, +// LOCALE_SYSTEM_DEFAULT, +// &dispId); +// +// if (result == NOERROR) +// { +// DISPPARAMS dispparams; +// VARIANT varResult; +// EXCEPINFO excepinfo; +// unsigned int uArgErr; +// +// VariantInit(&varResult); +// +// // converting UNO parameters to OLE variants +// dispparams.rgdispidNamedArgs = NULL; +// dispparams.cArgs = Event.Arguments.getLength() + 1; +// dispparams.cNamedArgs = 0; +// +// if (dispparams.cArgs == 0) +// { +// dispparams.rgvarg = NULL; +// } +// else +// { +// dispparams.rgvarg = (VARIANTARG*)malloc(sizeof(VARIANTARG) * dispparams.cArgs); +// +// for (UINT32 i = 0; i < (dispparams.cArgs - 1); i++) +// { +// o2u_anyToVariant(&(dispparams.rgvarg[i]), +// Event.Arguments.getConstArray()[dispparams.cArgs - (i + 2)]); +// } +// Any methodName( &Event.MethodName, getCppuType( &Event.MethodName)); +// +// o2u_anyToVariant(&(dispparams.rgvarg[i]), methodName); +// } +// +// // invoking OLE method +// result = pDispatch ->Invoke(dispId, +// IID_NULL, +// LOCALE_SYSTEM_DEFAULT, +// DISPATCH_METHOD, +// &dispparams, +// &varResult, +// &excepinfo, +// &uArgErr); +// +// +// // freeing allocated OLE parameters +// if (dispparams.cArgs > 0) +// { +// for (UINT32 i = 0; i < dispparams.cArgs; i++) +// { +// VariantClear(&(dispparams.rgvarg[i])); +// } +// free(dispparams.rgvarg); +// } +// +// VariantClear(&varResult); +// } +// +// pDispatch->Release(); +// } +// +// connection.pUnk->Release(); +// } +// +// pEnum->Release(); +//} + +//Any SAL_CALL ConnectionPoint_Impl::approveFiring(const AllEventObject& Event) throw( InvocationTargetException, RuntimeException) +//{ +// Any ret; +// +// return ret; +//} + +/***************************************************************************** + + class implementation: EnumConnections_Impl + +*****************************************************************************/ + + +//EnumConnections_Impl::EnumConnections_Impl(CONNECTDATA* pConnection, ULONG numOfConn) +//{ +// m_index = 0; +// m_numOfConn = numOfConn; +// +// if (m_numOfConn) +// { +// m_pConnection = new CONNECTDATA[m_numOfConn]; +// +// for (ULONG i = 0; i < m_numOfConn; i++) +// { +// m_pConnection[i] = pConnection[i]; +// m_pConnection[i].pUnk->AddRef(); +// } +// } +//} +// +//EnumConnections_Impl::~EnumConnections_Impl() +//{ +// for (ULONG i = 0; i < m_numOfConn; i++) +// { +// m_pConnection[i].pUnk->Release(); +// } +// +// if (m_numOfConn) +// { +// delete[] m_pConnection; +// } +//} +// +//STDMETHODIMP EnumConnections_Impl::QueryInterface(REFIID riid, LPVOID FAR * ppv) +//{ +// if(IsEqualIID(riid, IID_IUnknown)) +// { +// AddRef(); +// *ppv = (IUnknown*) (IEnumConnections *) this; +// return NOERROR; +// } +// else if (IsEqualIID(riid, IID_IEnumConnections )) +// { +// AddRef(); +// *ppv = (IEnumConnections *) this; +// return NOERROR; +// } +// +// *ppv = NULL; +// +// return ResultFromScode(E_NOINTERFACE); +//} +// +//STDMETHODIMP_(ULONG) EnumConnections_Impl::AddRef() +//{ +// return m_refCount.acquire(); +//} +// +//STDMETHODIMP_(ULONG) EnumConnections_Impl::Release() +//{ +// +// ULONG n = m_refCount.release(); +// +// if (n == 0) +// { +// delete this; +// } +// +// return n; +//} +// +//STDMETHODIMP EnumConnections_Impl::Next( +// /* [in] */ ULONG cConnections, +// /* [out] */ CONNECTDATA __RPC_FAR *rgcd, +// /* [out] */ ULONG __RPC_FAR *lpcFetched) +//{ +// HRESULT ret = ResultFromScode(S_FALSE); +// +// *lpcFetched = VOS_MIN(cConnections, m_numOfConn - m_index); +// +// for (ULONG i = 0; i < (*lpcFetched); i++) +// { +// rgcd[i] = m_pConnection[m_index + i]; +// rgcd[i].pUnk->AddRef(); +// } +// +// m_index += (*lpcFetched); +// +// if ((*lpcFetched) == cConnections) +// ret = ResultFromScode(S_OK); +// +// return ret; +//} +// +// +//STDMETHODIMP EnumConnections_Impl::Skip( +// /* [in] */ ULONG cConnections) +//{ +// HRESULT ret = ResultFromScode(S_OK); +// +// m_index = VOS_MIN(m_index + cConnections, m_numOfConn); +// +// return ret; +//} +// +//STDMETHODIMP EnumConnections_Impl::Reset( void) +//{ +// HRESULT ret = ResultFromScode(S_OK); +// +// m_index = 0; +// +// return ret; +//} +// +//STDMETHODIMP EnumConnections_Impl::Clone( +// /* [out] */ IEnumConnections __RPC_FAR *__RPC_FAR *ppEnum) +//{ +// HRESULT ret = ResultFromScode(S_OK); +// +// *ppEnum = new EnumConnections_Impl(m_pConnection, m_numOfConn); +// +// return ret; +//} + +/***************************************************************************** + + class implementation: EnumConnectionPoints_Impl + +*****************************************************************************/ + +//EnumConnectionPoints_Impl::EnumConnectionPoints_Impl(OleRef<IConnectionPoint>* pPoints, +// ULONG numOfPoints) +//{ +// m_index = 0; +// m_numOfPoints = numOfPoints; +// +// if (m_numOfPoints) +// { +// m_pPoints = new OleRef<IConnectionPoint>[m_numOfPoints]; +// +// for (ULONG i = 0; i < m_numOfPoints; i++) +// { +// m_pPoints[i] = pPoints[i]; +// } +// } +//} +// +//EnumConnectionPoints_Impl::~EnumConnectionPoints_Impl() +//{ +// if (m_numOfPoints) +// { +// delete[] m_pPoints; +// } +//} +// +//STDMETHODIMP EnumConnectionPoints_Impl::QueryInterface(REFIID riid, LPVOID FAR * ppv) +//{ +// if(IsEqualIID(riid, IID_IUnknown)) +// { +// AddRef(); +// *ppv = (IUnknown*) (IEnumConnectionPoints*) this; +// return NOERROR; +// } +// else if (IsEqualIID(riid, IID_IEnumConnectionPoints)) +// { +// AddRef(); +// *ppv = (IEnumConnectionPoints*) this; +// return NOERROR; +// } +// +// *ppv = NULL; +// +// return ResultFromScode(E_NOINTERFACE); +//} +// +//STDMETHODIMP_(ULONG) EnumConnectionPoints_Impl::AddRef() +//{ +// return m_refCount.acquire(); +//} +// +//STDMETHODIMP_(ULONG) EnumConnectionPoints_Impl::Release() +//{ +// +// ULONG n = m_refCount.release(); +// +// if (n == 0) +// { +// delete this; +// } +// +// return n; +//} +// +//STDMETHODIMP EnumConnectionPoints_Impl::Next( +// /* [in] */ ULONG cPoints, +// /* [out] */ IConnectionPoint __RPC_FAR *__RPC_FAR *rgpcn, +// /* [out] */ ULONG __RPC_FAR *lpcFetched) +//{ +// HRESULT ret = ResultFromScode(S_FALSE); +// +// *lpcFetched = VOS_MIN(cPoints, m_numOfPoints - m_index); +// +// for (ULONG i = 0; i < (*lpcFetched); i++) +// { +// rgpcn[i] = m_pPoints[m_index + i].get(); +// rgpcn[i]->AddRef(); +// } +// +// m_index += (*lpcFetched); +// +// if ((*lpcFetched) == cPoints) +// ret = ResultFromScode(S_OK); +// +// return ret; +//} +// +//STDMETHODIMP EnumConnectionPoints_Impl::Skip( +// /* [in] */ ULONG cPoints) +//{ +// HRESULT ret = ResultFromScode(S_OK); +// +// m_index = VOS_MIN(m_index + cPoints, m_numOfPoints); +// +// return ret; +//} +// +//STDMETHODIMP EnumConnectionPoints_Impl::Reset( void) +//{ +// HRESULT ret = ResultFromScode(S_OK); +// +// m_index = 0; +// +// return ret; +//} +// +//STDMETHODIMP EnumConnectionPoints_Impl::Clone( +// /* [out] */ IEnumConnectionPoints __RPC_FAR *__RPC_FAR *ppEnum) +//{ +// HRESULT ret = ResultFromScode(S_OK); +// +// *ppEnum = new EnumConnectionPoints_Impl(m_pPoints, m_numOfPoints); +// +// return ret; +//} + +/************************************************************************* + + UnoObjectWrapperRemoteOpt + +*************************************************************************/ +UnoObjectWrapperRemoteOpt::UnoObjectWrapperRemoteOpt( Reference<XMultiServiceFactory>& aFactory, + sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass): + InterfaceOleWrapper_Impl( aFactory, unoWrapperClass, comWrapperClass) + +{ +} +UnoObjectWrapperRemoteOpt::~UnoObjectWrapperRemoteOpt() +{ +} + +// UnoConversionUtilities +Reference< XInterface > UnoObjectWrapperRemoteOpt::createUnoWrapperInstance() +{ + Reference<XWeak> xWeak= static_cast<XWeak*>( new UnoObjectWrapperRemoteOpt( + m_xMultiServiceFactory, m_nUnoWrapperClass, m_nComWrapperClass)); + return Reference<XInterface>( xWeak, UNO_QUERY); +} + +STDMETHODIMP UnoObjectWrapperRemoteOpt::GetIDsOfNames ( REFIID riid, OLECHAR ** rgszNames, unsigned int cNames, + LCID lcid, DISPID * rgdispid ) +{ + static DISPID currentId= 1; + + if( ! rgdispid) + return E_POINTER; + HRESULT ret = E_UNEXPECTED; + // ---------------------------------------- + // _GetValueObject + if( ! wcscmp( *rgszNames, JSCRIPT_VALUE_FUNC)) + { + *rgdispid= DISPID_JSCRIPT_VALUE_FUNC; + return S_OK; + } + // ---------------------------------------- + if (m_xInvocation.is() && (cNames > 0)) + { + OUString name(rgszNames[0]); + // has this name been determined as "bad" + BadNameMap::iterator badIter= m_badNameMap.find( name); + if( badIter == m_badNameMap.end() ) + { + // name has not been bad before( member exists + typedef NameToIdMap::iterator ITnames; + pair< ITnames, bool > pair_id= m_nameToDispIdMap.insert( NameToIdMap::value_type(name, currentId++)); + // new ID inserted ? + if( pair_id.second ) + {// yes, now create MemberInfo and ad to IdToMemberInfoMap + MemberInfo d(0, name); + m_idToMemberInfoMap.insert( IdToMemberInfoMap::value_type( currentId - 1, d)); + } + + *rgdispid = pair_id.first->second; + ret = S_OK; + } + else + ret= DISP_E_UNKNOWNNAME; + } + return ret; +} + +STDMETHODIMP UnoObjectWrapperRemoteOpt::Invoke ( DISPID dispidMember, REFIID riid, LCID lcid, unsigned short wFlags, + DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, + unsigned int * puArgErr ) +{ + HRESULT ret = S_OK; + + sal_Bool bHandled= sal_False; + ret= InvokeGeneral( dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo, + puArgErr, bHandled); + if( bHandled) + return ret; + + if ( dispidMember > 0 && m_xInvocation.is()) + { + + IdToMemberInfoMap::iterator it_MemberInfo= m_idToMemberInfoMap.find( dispidMember); + if( it_MemberInfo != m_idToMemberInfoMap.end() ) + { + MemberInfo& info= it_MemberInfo->second; + + Sequence<Any> params; // holds converted any s + if( ! info.flags ) + { // DISPID called for the first time + if( wFlags == DISPATCH_METHOD ) + { + if( convertVARIANTARGS(dispidMember, wFlags, pdispparams, params )) + { + if( FAILED( ret= doInvoke( pdispparams, pvarResult, + pexcepinfo, puArgErr, info.name, params)) + && ret == DISP_E_MEMBERNOTFOUND) + { + // try to get the exact name + OUString exactName; + if (m_xExactName.is()) + { + exactName = m_xExactName->getExactName( info.name); + // invoke again + if( exactName.getLength() != 0) + { + if( SUCCEEDED( ret= doInvoke( pdispparams, pvarResult, + pexcepinfo, puArgErr, exactName, params))) + info.name= exactName; + } + } + } + if( SUCCEEDED( ret ) ) + info.flags= DISPATCH_METHOD; + + } // end if ( convertVARIANTARGS ) + else // convertVARIANTARGS failed + ret= DISP_E_BADVARTYPE; + } //if( wFlags == DISPATCH_METHOD ) + + else if( wFlags == DISPATCH_PROPERTYPUT || wFlags == DISPATCH_PROPERTYPUTREF) + { + if( convertVARIANTARGS(dispidMember, wFlags, pdispparams, params )) + { + if( FAILED( ret= doSetProperty( pdispparams, pvarResult, + pexcepinfo, puArgErr, info.name, params)) + && ret == DISP_E_MEMBERNOTFOUND) + { + // try to get the exact name + OUString exactName; + if (m_xExactName.is()) + { + exactName = m_xExactName->getExactName( info.name); + // invoke again + if( exactName.getLength() != 0) + { + if( SUCCEEDED( ret= doSetProperty( pdispparams, pvarResult, + pexcepinfo, puArgErr, exactName, params))) + info.name= exactName; + } + } + } + if( SUCCEEDED( ret ) ) + info.flags= DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYGET; + } // end if ( convertVARIANTARGS ) + else + ret= DISP_E_BADVARTYPE; + + } + + else if( wFlags == DISPATCH_PROPERTYGET) + { + if( FAILED( ret= doGetProperty( pdispparams, pvarResult, + pexcepinfo, info.name)) + && ret == DISP_E_MEMBERNOTFOUND) + { + // try to get the exact name + OUString exactName; + if (m_xExactName.is()) + { + exactName = m_xExactName->getExactName( info.name); + // invoke again + if( exactName.getLength() != 0) + { + if( SUCCEEDED( ret= doGetProperty( pdispparams, pvarResult, + pexcepinfo, exactName))) + info.name= exactName; + } + } + } + if( SUCCEEDED( ret ) ) + info.flags= DISPATCH_PROPERTYGET | DISPATCH_PROPERTYPUT; + } + else if( wFlags & DISPATCH_METHOD && + (wFlags & DISPATCH_PROPERTYPUT || wFlags & DISPATCH_PROPERTYPUTREF)) + { + + OUString exactName; + // convert params for DISPATCH_METHOD or DISPATCH_PROPERTYPUT + if( convertVARIANTARGS(dispidMember, wFlags, pdispparams, params )) + {// try first as method + if( FAILED( ret= doInvoke( pdispparams, pvarResult, + pexcepinfo, puArgErr, info.name, params)) + && ret == DISP_E_MEMBERNOTFOUND) + { + // try to get the exact name + if (m_xExactName.is()) + { + exactName = m_xExactName->getExactName( info.name); + // invoke again + if( exactName.getLength() != 0) + { + if( SUCCEEDED( ret= doInvoke( pdispparams, pvarResult, + pexcepinfo, puArgErr, exactName, params))) + info.name= exactName; + } + } + } + if( SUCCEEDED( ret ) ) + info.flags= DISPATCH_METHOD; + + // try as property + if( FAILED( ret) && pdispparams->cArgs == 1) + { + if( FAILED( ret= doSetProperty( pdispparams, pvarResult, + pexcepinfo, puArgErr, info.name, params)) + && ret == DISP_E_MEMBERNOTFOUND) + { + // try to get the exact name + if( exactName.getLength() != 0) + { + if( SUCCEEDED( ret= doSetProperty( pdispparams, pvarResult, + pexcepinfo, puArgErr, exactName, params))) + info.name= exactName; + } + } + if( SUCCEEDED( ret ) ) + info.flags= DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYGET; + } + } // end if ( convertVARIANTARGS ) + else + ret= DISP_E_BADVARTYPE; + } + else if( wFlags & DISPATCH_METHOD && wFlags & DISPATCH_PROPERTYGET) + { + OUString exactName; + if( convertVARIANTARGS(dispidMember, wFlags, pdispparams, params )) + { + if( FAILED( ret= doInvoke( pdispparams, pvarResult, + pexcepinfo, puArgErr, info.name, params)) + && ret == DISP_E_MEMBERNOTFOUND) + { + // try to get the exact name + if (m_xExactName.is()) + { + exactName = m_xExactName->getExactName( info.name); + // invoke again + if( exactName.getLength() != 0) + { + if( SUCCEEDED( ret= doInvoke( pdispparams, pvarResult, + pexcepinfo, puArgErr, exactName, params))) + info.name= exactName; + } + } + } + if( SUCCEEDED( ret ) ) + info.flags= DISPATCH_METHOD; + + } // end if ( convertVARIANTARGS ) + else + ret= DISP_E_BADVARTYPE; + + // try as property + if( FAILED( ret) && pdispparams->cArgs == 1) + { + if( FAILED( ret= doGetProperty( pdispparams, pvarResult, + pexcepinfo, info.name)) + && ret == DISP_E_MEMBERNOTFOUND) + { + if( exactName.getLength() != 0) + { + if( SUCCEEDED( ret= doSetProperty( pdispparams, pvarResult, + pexcepinfo, puArgErr, exactName, params))) + info.name= exactName; + } + } + if( SUCCEEDED( ret ) ) + info.flags= DISPATCH_PROPERTYGET; + } + } + + // update ínformation about this member + if( ret == DISP_E_MEMBERNOTFOUND) + { + // Remember the name as not existing + // and remove the MemberInfo + m_badNameMap[info.name]= sal_False; + m_idToMemberInfoMap.erase( it_MemberInfo); + } + } // if( ! info.flags ) + else // IdToMemberInfoMap contains a MemberInfo + { + if( wFlags & DISPATCH_METHOD && info.flags == DISPATCH_METHOD) + { + if( convertVARIANTARGS(dispidMember, wFlags, pdispparams, params )) + { + ret= doInvoke( pdispparams, pvarResult, + pexcepinfo, puArgErr, info.name, params); + } + else + ret= DISP_E_BADVARTYPE; + } + else if( (wFlags & DISPATCH_PROPERTYPUT || wFlags & DISPATCH_PROPERTYPUTREF ) && + info.flags & DISPATCH_PROPERTYPUT) + { + if( convertVARIANTARGS(dispidMember, wFlags, pdispparams, params )) + { + ret= doSetProperty( pdispparams, pvarResult, + pexcepinfo, puArgErr, info.name, params); + } + else + ret= DISP_E_BADVARTYPE; + } + else if( (wFlags & DISPATCH_PROPERTYGET) && ( info.flags & DISPATCH_PROPERTYGET)) + { + ret= doGetProperty( pdispparams, pvarResult, + pexcepinfo, info.name); + } + } + }// if( it_MemberInfo != m_idToMemberInfoMap.end() ) + else + ret= DISP_E_MEMBERNOTFOUND; + } + return ret; +} + +HRESULT UnoObjectWrapperRemoteOpt::methodInvoke( DISPID dispidMember, DISPPARAMS * pdispparams, VARIANT * pvarResult, + EXCEPINFO * pexcepinfo, unsigned int * puArgErr, Sequence<Any> params) +{ + return S_OK; +} + + +// The returned HRESULT is only appropriate for IDispatch::Invoke +static HRESULT mapCannotConvertException( CannotConvertException e, unsigned int * puArgErr) +{ + HRESULT ret; + sal_Bool bWriteIndex= sal_True; + + switch ( e.Reason) + { + case FailReason::OUT_OF_RANGE: + ret = DISP_E_OVERFLOW; + break; + case FailReason::IS_NOT_NUMBER: + ret = DISP_E_TYPEMISMATCH; + break; + case FailReason::IS_NOT_ENUM: + ret = DISP_E_TYPEMISMATCH; + break; + case FailReason::IS_NOT_BOOL: + ret = DISP_E_TYPEMISMATCH; + break; + case FailReason::NO_SUCH_INTERFACE: + ret = DISP_E_TYPEMISMATCH; + break; + case FailReason::SOURCE_IS_NO_DERIVED_TYPE: + ret = DISP_E_TYPEMISMATCH; + break; + case FailReason::TYPE_NOT_SUPPORTED: + ret = DISP_E_TYPEMISMATCH; + break; + case FailReason::INVALID: + ret = DISP_E_TYPEMISMATCH; + break; + case FailReason::NO_DEFAULT_AVAILABLE: + ret = DISP_E_BADPARAMCOUNT; + break; + case FailReason::UNKNOWN: + ret = E_UNEXPECTED; + break; + default: + ret = E_UNEXPECTED; + bWriteIndex= sal_False; + break; + } + + if( bWriteIndex && puArgErr != NULL) + *puArgErr = e.ArgumentIndex; + return ret; +} + +// The function maps the TypeClass of the any to VARTYPE: If +// the Any contains STRUCT or INTERFACE then the return value +// is VT_DISPATCH. The function is used from o2u_createUnoObjectWrapper +// and the result is put into the constructor of the uno - wrapper +// object. If a client asks the object for DISPID_VALUE and this +// funtion returned VT_DISPATCH then the IDispatch of the same +// object is being returned. +// See InterfaceOleWrapper_Impl::Invoke, InterfaceOleWrapper_Impl::m_defaultValueType +const VARTYPE getVarType( const Any& value) +{ + VARTYPE ret= VT_EMPTY; + + switch ( value.getValueTypeClass()) + { + case TypeClass_STRUCT: ret= VT_DISPATCH; break; + case TypeClass_INTERFACE: ret= VT_DISPATCH; break; + default: break; + } + return ret; +} + + + + +} // end namespace diff --git a/extensions/source/ole/unoobjw.hxx b/extensions/source/ole/unoobjw.hxx new file mode 100644 index 000000000000..cd8d6ee929b9 --- /dev/null +++ b/extensions/source/ole/unoobjw.hxx @@ -0,0 +1,505 @@ +/************************************************************************* + * + * $RCSfile: unoobjw.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:41 $ + * + * 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 _UNOOBJW_HXX +#define _UNOOBJW_HXX + +#include <com/sun/star/script/XAllListener.hpp> +#include <com/sun/star/script/XEventAttacher.hpp> +#include <com/sun/star/bridge/XBridgeSupplier2.hpp> +#include <com/sun/star/beans/XExactName.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <vos/refernce.hxx> +#include <tools/presys.h> +#include "stdafx.h" +#include "comifaces.hxx" +#include <tools/postsys.h> + +#include "ole2uno.hxx" +#include "unoconversionutilities.hxx" + + +using namespace std; +using namespace cppu; +using namespace com::sun::star::bridge; +namespace ole_adapter +{ + + + +struct hash_IUnknown_Impl +{ + size_t operator()(const IUnknown* p) const + { + return (size_t)p; + } +}; + +struct equal_to_IUnknown_Impl +{ + bool operator()(const IUnknown* s1, const IUnknown* s2) const + { + return s1 == s2; + } +}; + +typedef hash_map +< + IUnknown*, + Reference<XInterface>, + hash_IUnknown_Impl, + equal_to_IUnknown_Impl +> WrapperMap; + +typedef hash_map +< + DWORD, + OleRef<IDispatch>, + hash<DWORD>, + equal_to<DWORD> +> ConnectionMap; + +struct GenListenerData +{ + Any helper; + OUString listenerType; + OUString addListenerParam; + Reference<XEventListener> xGenListener; +}; + +typedef vector<GenListenerData> GenListenerDataList; + +struct MemberInfo +{ + MemberInfo() : flags(0), name() {} + MemberInfo(WORD f, const OUString& n) : flags(f), name(n) {} + + WORD flags; + OUString name; +}; + +typedef hash_map +< + OUString, + DISPID, + hashOUString_Impl, + equalOUString_Impl +> NameToIdMap; + +typedef hash_map +< + OUString, + sal_Bool, + hashOUString_Impl, + equalOUString_Impl +> BadNameMap; + +typedef hash_map +< + DISPID, + MemberInfo +> IdToMemberInfoMap; +/***************************************************************************** + + class declaration: EnumConnections_Impl + +*****************************************************************************/ + +//class EnumConnections_Impl : public IEnumConnections +//{ +//public: +// +// EnumConnections_Impl(CONNECTDATA* pConnection, ULONG numOfConn); +// ~EnumConnections_Impl(); +// +// /* IUnknown methods */ +// STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); +// STDMETHOD_(ULONG, AddRef)(); +// STDMETHOD_(ULONG, Release)(); +// +// /* IEnumConnections */ +// virtual /* [local] */ HRESULT STDMETHODCALLTYPE Next( +// /* [in] */ ULONG cConnections, +// /* [out] */ CONNECTDATA __RPC_FAR *rgcd, +// /* [out] */ ULONG __RPC_FAR *lpcFetched); +// +// virtual HRESULT STDMETHODCALLTYPE Skip( +// /* [in] */ ULONG cConnections); +// +// virtual HRESULT STDMETHODCALLTYPE Reset(void); +// +// virtual HRESULT STDMETHODCALLTYPE Clone( +// /* [out] */ IEnumConnections __RPC_FAR *__RPC_FAR *ppEnum); +// +//protected: +// +// vos::ORefCount m_refCount; +// CONNECTDATA* m_pConnection; +// ULONG m_numOfConn; +// ULONG m_index; +//}; + + +/***************************************************************************** + + class declaration: ConnectionPoint_Impl + +*****************************************************************************/ + + +//class ConnectionPoint_Impl : public IConnectionPoint +// , public WeakImplHelper1<XAllListener> +//{ +//public: +// +// ConnectionPoint_Impl(const Reference<XInvocation>& xInv, +// const Reference<XInterface>& xOrigin, +// const Reference<XEventAttacher>& xEventAttacher, +// IConnectionPointContainer* pContainer); +// +// ~ConnectionPoint_Impl(); +// +// /* IUnknown methods */ +// STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); +// STDMETHOD_(ULONG, AddRef)(); +// STDMETHOD_(ULONG, Release)(); +// +// /* IConnectionPoint */ +// virtual HRESULT STDMETHODCALLTYPE GetConnectionInterface( +// /* [out] */ IID __RPC_FAR *piid); +// +// virtual HRESULT STDMETHODCALLTYPE GetConnectionPointContainer( +// /* [out] */ IConnectionPointContainer __RPC_FAR *__RPC_FAR *ppCPC); +// +// virtual HRESULT STDMETHODCALLTYPE Advise( +// /* [in] */ IUnknown __RPC_FAR *pUnkSink, +// /* [out] */ DWORD __RPC_FAR *pdwCookie); +// +// virtual HRESULT STDMETHODCALLTYPE Unadvise( +// /* [in] */ DWORD dwCookie); +// +// virtual HRESULT STDMETHODCALLTYPE EnumConnections( +// /* [out] */ IEnumConnections __RPC_FAR *__RPC_FAR *ppEnum); +// +// +// +// /* XEventListener */ +// virtual void SAL_CALL disposing( const EventObject& Source ) throw(RuntimeException); +// +// /* XAllListener */ +// virtual void SAL_CALL firing( const AllEventObject& iaEvent ) throw(RuntimeException); +// virtual Any SAL_CALL approveFiring( const AllEventObject& aEvent ) throw(InvocationTargetException, RuntimeException); +// +// +//protected: +// +// void registerListener(); +// void unregisterListener(); +// +// vos::ORefCount m_refCount; +// Reference<XInvocation> m_xInvocation; +// Reference<XInterface> m_xOrigin; +// OleRef<IConnectionPointContainer> m_rContainer; +// ConnectionMap m_connection; +// DWORD m_nextCookie; +// Reference<XEventAttacher> m_xEventAttacher; +// GenListenerDataList m_xGenListenerList; +//}; + +/***************************************************************************** + + class declaration: EnumConnectionPoints_Impl + +*****************************************************************************/ + +//class EnumConnectionPoints_Impl : public IEnumConnectionPoints +//{ +//public: +// +// EnumConnectionPoints_Impl(OleRef<IConnectionPoint>* pPoints, ULONG numOfPoints); +// ~EnumConnectionPoints_Impl(); +// +// /* IUnknown methods */ +// STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); +// STDMETHOD_(ULONG, AddRef)(); +// STDMETHOD_(ULONG, Release)(); +// +// /* IEnumConnectionPoints */ +// virtual /* [local] */ HRESULT STDMETHODCALLTYPE Next( +// /* [in] */ ULONG cConnections, +// /* [out] */ IConnectionPoint __RPC_FAR *__RPC_FAR *rgpcn, +// /* [out] */ ULONG __RPC_FAR *lpcFetched); +// +// virtual HRESULT STDMETHODCALLTYPE Skip( +// /* [in] */ ULONG cConnections); +// +// virtual HRESULT STDMETHODCALLTYPE Reset(void); +// +// virtual HRESULT STDMETHODCALLTYPE Clone( +// /* [out] */ IEnumConnectionPoints __RPC_FAR *__RPC_FAR *ppEnum); +// +//protected: +// +// vos::ORefCount m_refCount; +// OleRef<IConnectionPoint>* m_pPoints; +// ULONG m_numOfPoints; +// ULONG m_index; +//}; + +/***************************************************************************** + + class declaration: InterfaceOleWrapper_Impl + +*****************************************************************************/ + +class InterfaceOleWrapper_Impl : public WeakImplHelper2<XBridgeSupplier2, XInitialization>, + public IDispatchEx, +// public IConnectionPointContainer, + public UnoConversionUtilities<InterfaceOleWrapper_Impl>, + public IUnoObjectWrapper +{ +public: + + + InterfaceOleWrapper_Impl(Reference<XMultiServiceFactory>& xFactory, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass); + ~InterfaceOleWrapper_Impl(); + + /* IUnknown methods */ + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj); + STDMETHOD_(ULONG, AddRef)(); + STDMETHOD_(ULONG, Release)(); + + /* IDispatch methods */ + STDMETHOD( GetTypeInfoCount )( unsigned int * pctinfo ); + STDMETHOD( GetTypeInfo )( unsigned int itinfo, LCID lcid, ITypeInfo ** pptinfo ); + STDMETHOD( GetIDsOfNames )( REFIID riid, OLECHAR ** rgszNames, unsigned int cNames, + LCID lcid, DISPID * rgdispid ); + STDMETHOD( Invoke )( DISPID dispidMember, REFIID riid, LCID lcid, unsigned short wFlags, + DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, + unsigned int * puArgErr ); + + /* IDispatchEx methods */ + + virtual HRESULT STDMETHODCALLTYPE GetDispID( + /* [in] */ BSTR bstrName, + /* [in] */ DWORD grfdex, + /* [out] */ DISPID __RPC_FAR *pid); + + virtual /* [local] */ HRESULT STDMETHODCALLTYPE InvokeEx( + /* [in] */ DISPID id, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [in] */ DISPPARAMS __RPC_FAR *pdp, + /* [out] */ VARIANT __RPC_FAR *pvarRes, + /* [out] */ EXCEPINFO __RPC_FAR *pei, + /* [unique][in] */ IServiceProvider __RPC_FAR *pspCaller); + + virtual HRESULT STDMETHODCALLTYPE DeleteMemberByName( + /* [in] */ BSTR bstr, + /* [in] */ DWORD grfdex); + + virtual HRESULT STDMETHODCALLTYPE DeleteMemberByDispID( + /* [in] */ DISPID id); + + virtual HRESULT STDMETHODCALLTYPE GetMemberProperties( + /* [in] */ DISPID id, + /* [in] */ DWORD grfdexFetch, + /* [out] */ DWORD __RPC_FAR *pgrfdex); + + virtual HRESULT STDMETHODCALLTYPE GetMemberName( + /* [in] */ DISPID id, + /* [out] */ BSTR __RPC_FAR *pbstrName); + + virtual HRESULT STDMETHODCALLTYPE GetNextDispID( + /* [in] */ DWORD grfdex, + /* [in] */ DISPID id, + /* [out] */ DISPID __RPC_FAR *pid); + + virtual HRESULT STDMETHODCALLTYPE GetNameSpaceParent( + /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppunk); + + /* IConnectionPointContainer */ +// virtual HRESULT STDMETHODCALLTYPE EnumConnectionPoints( +// /* [out] */ IEnumConnectionPoints __RPC_FAR *__RPC_FAR *ppEnum); +// +// virtual HRESULT STDMETHODCALLTYPE FindConnectionPoint( +// /* [in] */ REFIID riid, +// /* [out] */ IConnectionPoint __RPC_FAR *__RPC_FAR *ppCP); + + //XInterface ---------------------------------------------------------- + void SAL_CALL InterfaceOleWrapper_Impl::acquire( ) throw(); + void SAL_CALL InterfaceOleWrapper_Impl::release( ) throw(); + + // XBridgeSupplier2 --------------------------------------------------- + virtual Any SAL_CALL createBridge(const Any& modelDepObject, + const Sequence<sal_Int8>& ProcessId, + sal_Int16 sourceModelType, + sal_Int16 destModelType) + throw (IllegalArgumentException, RuntimeException); + + //XInitialization ----------------------------------------------------- + virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException); + + // IUnoObjectWrapper + STDMETHOD( getWrapperXInterface)( Reference<XInterface>* pXInt); + STDMETHOD( getOriginalUnoObject)( Reference<XInterface>* pXInt); + STDMETHOD( getOriginalUnoStruct)( Any * pStruct); + + // UnoConversionUtility +// virtual Reference< XSingleServiceFactory > getInvocationFactory(); + virtual Reference< XInterface > createUnoWrapperInstance(); + virtual Reference< XInterface > createComWrapperInstance(); + + +protected: + virtual HRESULT doInvoke( DISPPARAMS * pdispparams, VARIANT * pvarResult, + EXCEPINFO * pexcepinfo, unsigned int * puArgErr, OUString & name, Sequence<Any>& params); + + virtual HRESULT doGetProperty( DISPPARAMS * pdispparams, VARIANT * pvarResult, + EXCEPINFO * pexcepinfo, OUString & name ); + + virtual HRESULT doSetProperty( DISPPARAMS * pdispparams, VARIANT * pvarResult, + EXCEPINFO * pexcepinfo, unsigned int * puArgErr, OUString & name, Sequence<Any> params); + + virtual HRESULT InvokeGeneral( DISPID dispidMember, unsigned short wFlags, + DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, + unsigned int * puArgErr, sal_Bool& bHandled); + + sal_Bool convertVARIANTARGS( DISPID id, unsigned short wFlags, DISPPARAMS* pdispparams, + Sequence<Any>& rSeq); + + vos::ORefCount m_refCount; + Reference<XInvocation> m_xInvocation; + Reference<XExactName> m_xExactName; + Reference<XInterface> m_xOrigin; + Reference<XEventAttacher> m_xEventAttacher; + NameToIdMap m_nameToDispIdMap; + vector<MemberInfo> m_MemberInfos; + OleRef<IConnectionPoint> m_rConnectionPoint; + // This member is used to determine the default value + // denoted by DISPID_VALUE (0). For proper results in JavaScript + // we have to return the default value when we write an object + // as out parameter. That is, we get an JScript Array as parameter + // and put a wrapped object on index null. The array object tries + // to detect the default value. The wrapped object must then return + // its own IDispatch* otherwise we cannot access it within the script. + // see InterfaceOleWrapper_Impl::Invoke + VARTYPE m_defaultValueType; + +}; + +/***************************************************************************** + + class declaration: UnoObjectWrapperRemoteOpt + ( Uno Object Wrapper Remote Optimized) + This is the UNO wrapper used in the service com.sun.star.bridge.OleBridgeSupplierVar1. + Key features: + DISPIDs are passed out blindly. That is in GetIDsOfNames is no name checking carried out. + Only if Invoke fails the name is being checked. Moreover Invoke tries to figure out + if a call is made to a property or method if the flags are DISPATCH_METHOD | DISPATCH_PROPERTYPUT. + If something has been found out about a property or member than it is saved + in a MemberInfo structure hold by a IdToMemberInfoMap stl map. + +*****************************************************************************/ +class UnoObjectWrapperRemoteOpt: public InterfaceOleWrapper_Impl +{ +public: + UnoObjectWrapperRemoteOpt( Reference<XMultiServiceFactory>& aFactory, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass); + ~UnoObjectWrapperRemoteOpt(); + + STDMETHOD( GetIDsOfNames )( REFIID riid, OLECHAR ** rgszNames, unsigned int cNames, + LCID lcid, DISPID * rgdispid ); + STDMETHOD( Invoke )( DISPID dispidMember, REFIID riid, LCID lcid, unsigned short wFlags, + DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, + unsigned int * puArgErr ); + + // UnoConversionUtility + // If UNO interfaces are converted in methods of this class then + // they are always wrapped with instances of this class + virtual Reference< XInterface > createUnoWrapperInstance(); + +protected: + + HRESULT methodInvoke( DISPID dispidMember, DISPPARAMS * pdispparams, VARIANT * pvarResult, + EXCEPINFO * pexcepinfo, unsigned int * puArgErr, Sequence<Any> params); + // In GetIDsOfNames are blindly passed out, that is without verifying + // the name. If two names are passed in during different calls to + // GetIDsOfNames and the names differ only in their cases then different + // id's are passed out ( e.g. "doSomethingMethod" or "dosomethingmethod"). + // In Invoke the DISPID is remapped to the name passed to GetIDsOfNames + // and the name is used as parameter for XInvocation::invoke. If invoke + // fails because of a wrong name, then m_xExactName ( XExactName) is used + // to verify the name. The correct name is then inserted to m_MemberInfos + // ( vector<MemberInfo> ). During the next call to Invoke the right name + // is used. . + + + BadNameMap m_badNameMap; + + IdToMemberInfoMap m_idToMemberInfoMap; + +}; + + + +} // end namespace + +#endif diff --git a/extensions/source/plugin/base/context.cxx b/extensions/source/plugin/base/context.cxx new file mode 100644 index 000000000000..0ad3c7c1baed --- /dev/null +++ b/extensions/source/plugin/base/context.cxx @@ -0,0 +1,364 @@ +/************************************************************************* + * + * $RCSfile: context.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#if STLPORT_VERSION>=321 +#include <cstdarg> +#endif + +#include <plugin/impl.hxx> + +#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAGS_HPP_ +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ +#include <com/sun/star/frame/XComponentLoader.hpp> +#endif +#include <tools/fsys.hxx> +#include <tools/urlobj.hxx> + +#include <cppuhelper/implbase1.hxx> + +namespace ext_plug { + +class FileSink : public ::cppu::WeakAggImplHelper1< ::com::sun::star::io::XOutputStream > +{ +private: + Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + FILE* fp; + Reference< ::com::sun::star::plugin::XPlugin > m_xPlugin; + ::rtl::OUString m_aMIMEType; + ::rtl::OUString m_aTarget; + ::rtl::OUString m_aFileName; + +public: + FileSink( const Reference< ::com::sun::star::lang::XMultiServiceFactory > &, + const Reference< ::com::sun::star::plugin::XPlugin > & plugin, + const ::rtl::OUString& mimetype, + const ::rtl::OUString& target, + const Reference< ::com::sun::star::io::XActiveDataSource > & source ); + virtual ~FileSink(); + + // ::com::sun::star::io::XOutputStream + virtual void SAL_CALL writeBytes( const Sequence<sal_Int8>& ); + virtual void SAL_CALL flush(); + virtual void SAL_CALL closeOutput(); +}; + +} +using namespace ext_plug; + +class XPluginContext_Impl : public ::cppu::WeakAggImplHelper1< ::com::sun::star::plugin::XPluginContext > +{ + Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + rtl_TextEncoding m_aEncoding; +public: + + XPluginContext_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & ); + virtual ~XPluginContext_Impl(); + + + virtual ::rtl::OUString SAL_CALL getValue(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, ::com::sun::star::plugin::PluginVariable variable) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); + virtual void SAL_CALL getURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Reference< ::com::sun::star::lang::XEventListener > & listener) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); + virtual void SAL_CALL getURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); + virtual void SAL_CALL postURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file, const Reference< ::com::sun::star::lang::XEventListener > & listener) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); + virtual void SAL_CALL postURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); + virtual void SAL_CALL newStream(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& mimetype, const ::rtl::OUString& target, const Reference< ::com::sun::star::io::XActiveDataSource > & source) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); + virtual void SAL_CALL displayStatusText(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& message) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); + virtual ::rtl::OUString SAL_CALL getUserAgent(const Reference< ::com::sun::star::plugin::XPlugin > & plugin) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); +}; + +Reference< ::com::sun::star::plugin::XPluginContext > XPluginManager_Impl::createPluginContext() +{ + return new XPluginContext_Impl( m_xSMgr ); +} + +XPluginContext_Impl::XPluginContext_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ) + : m_xSMgr( rSMgr ), + m_aEncoding( gsl_getSystemTextEncoding() ) +{ +} + +XPluginContext_Impl::~XPluginContext_Impl() +{ +} + +::rtl::OUString XPluginContext_Impl::getValue( const Reference< ::com::sun::star::plugin::XPlugin > & plugin, ::com::sun::star::plugin::PluginVariable variable ) + throw( ::com::sun::star::plugin::PluginException, RuntimeException ) +{ + return ::rtl::OUString(); +} + + +void XPluginContext_Impl::getURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target) throw( ::com::sun::star::plugin::PluginException, RuntimeException ) +{ + Reference< XInterface > xInst = m_xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ); + if( ! xInst.is() ) + return; + + if( ! target.len() ) + { + INetURLObject aURL; + aURL.SetSmartProtocol( INET_PROT_FILE ); + aURL.SetSmartURL( ::rtl::OUStringToOString( url, m_aEncoding ) ); + + Reference< ::com::sun::star::lang::XMultiServiceFactory > xFact( m_xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.DataSourceFactory" ) ), UNO_QUERY ); + if ( xFact.is() ) + { + Sequence < Any > aArgs(1); + ::rtl::OUString aUURL( aURL.GetMainURL() ); + aArgs.getArray()[0] <<= aUURL; + ::rtl::OUString aProt( INetURLObject::GetScheme( aURL.GetProtocol() ) ); + Reference< ::com::sun::star::io::XActiveDataSource > aSource( xFact->createInstanceWithArguments( aProt, aArgs ), UNO_QUERY ); + if ( aSource.is() ) + { + // the mimetype cannot be specified + plugin->provideNewStream( ::rtl::OUString(), + aSource, + aUURL, + 0, 0, sal_False ); + } + } + return; + } + + Reference< ::com::sun::star::frame::XComponentLoader > xLoader( xInst, UNO_QUERY ); + XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( plugin ); + + if( xLoader.is() && pPlugin ) + { + ::com::sun::star::beans::PropertyValue aValue; + aValue.Name = ::rtl::OUString::createFromAscii( "Referer" ); + aValue.Value <<= pPlugin->getRefererURL(); + + Sequence< ::com::sun::star::beans::PropertyValue > aArgs( &aValue, 1 ); + Reference< ::com::sun::star::lang::XComponent > xComp = + xLoader->loadComponentFromURL( + url, + target, + ::com::sun::star::frame::FrameSearchFlag::PARENT | + ::com::sun::star::frame::FrameSearchFlag::SELF | + ::com::sun::star::frame::FrameSearchFlag::CHILDREN | + ::com::sun::star::frame::FrameSearchFlag::SIBLINGS | + ::com::sun::star::frame::FrameSearchFlag::TASKS | + ::com::sun::star::frame::FrameSearchFlag::CREATE, + aArgs + ); + } +} + +void XPluginContext_Impl::getURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Reference< ::com::sun::star::lang::XEventListener > & listener ) + throw( ::com::sun::star::plugin::PluginException, RuntimeException ) +{ + getURL( plugin, url, target ); + if( listener.is() ) + listener->disposing( ::com::sun::star::lang::EventObject() ); +} + +::rtl::OUString XPluginContext_Impl::getUserAgent(const Reference< ::com::sun::star::plugin::XPlugin > & plugin) + throw( ::com::sun::star::plugin::PluginException, RuntimeException ) +{ + return ::rtl::OUString::createFromAscii( "Mozilla 3.0" ); +} + +void XPluginContext_Impl::displayStatusText(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& message) + throw( ::com::sun::star::plugin::PluginException, RuntimeException ) +{ +} + +void XPluginContext_Impl::postURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file) + throw( ::com::sun::star::plugin::PluginException, RuntimeException ) +{ + Sequence< sal_Int8 > aBuf; + + if( file ) + { + String aFileName( (char*)buf.getConstArray(), m_aEncoding ); + INetURLObject aFilePath( aFileName ); + aFileName = aFilePath.PathToFileName(); + SvFileStream aStream( aFileName, STREAM_READ ); + if( aStream.IsOpen() ) + { + int nBytes = 0; + aStream.Seek( STREAM_SEEK_TO_END ); + aBuf = Sequence<sal_Int8>( nBytes = aStream.Tell() ); + aStream.Seek( STREAM_SEEK_TO_BEGIN ); + aStream.Read( aBuf.getArray(), nBytes ); + aStream.Close(); + DirEntry( aFileName ).Kill(); + } + } + + Reference< XInterface > xInst = m_xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ); + if( ! xInst.is() ) + return ; + + Reference< ::com::sun::star::frame::XComponentLoader > xLoader( xInst, UNO_QUERY ); + XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( plugin ); + if( xLoader.is() && pPlugin ) + { + ::com::sun::star::beans::PropertyValue aValues[2]; + aValues[0].Name = ::rtl::OUString::createFromAscii( "Referer" ); + aValues[0].Value <<= pPlugin->getRefererURL(); + + aValues[1].Name = ::rtl::OUString::createFromAscii( "PostString" ); + aValues[1].Value <<= ::rtl::OStringToOUString( (char*)( file ? aBuf : buf ).getConstArray(), m_aEncoding ); + Sequence< ::com::sun::star::beans::PropertyValue > aArgs( aValues, 2 ); + Reference< ::com::sun::star::lang::XComponent > xComp = + xLoader->loadComponentFromURL( + url, + target, + ::com::sun::star::frame::FrameSearchFlag::PARENT | + ::com::sun::star::frame::FrameSearchFlag::SELF | + ::com::sun::star::frame::FrameSearchFlag::CHILDREN | + ::com::sun::star::frame::FrameSearchFlag::SIBLINGS | + ::com::sun::star::frame::FrameSearchFlag::TASKS | + ::com::sun::star::frame::FrameSearchFlag::CREATE, + aArgs + ); + } +} + +void XPluginContext_Impl::postURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file, const Reference< ::com::sun::star::lang::XEventListener > & listener ) + throw( ::com::sun::star::plugin::PluginException, RuntimeException ) +{ + postURL( plugin, url, target, buf, file ); + if( listener.is() ) + listener->disposing( ::com::sun::star::lang::EventObject() ); +} + +void XPluginContext_Impl::newStream( const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& mimetype, const ::rtl::OUString& target, const Reference< ::com::sun::star::io::XActiveDataSource > & source ) + throw( ::com::sun::star::plugin::PluginException, RuntimeException ) +{ + FileSink* pNewSink = new FileSink( m_xSMgr, plugin, mimetype, target, source ); + pNewSink->acquire(); +} + + + +FileSink::FileSink( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr, const Reference< ::com::sun::star::plugin::XPlugin > & plugin, + const ::rtl::OUString& mimetype, + const ::rtl::OUString& target, const Reference< ::com::sun::star::io::XActiveDataSource > & source ) : + m_xSMgr( rSMgr ), + m_aMIMEType( mimetype ), + m_aTarget( target ), + m_xPlugin( plugin ) +{ + DirEntry aEntry; + m_aFileName = aEntry.TempName().GetFull(); + ::rtl::OString aFile = ::rtl::OUStringToOString( m_aFileName, gsl_getSystemTextEncoding() ); + fp = fopen( aFile.getStr() , "wb" ); + + Reference< ::com::sun::star::io::XActiveDataControl > xControl( source, UNO_QUERY ); + + source->setOutputStream( Reference< ::com::sun::star::io::XOutputStream > ( this ) ); + if( xControl.is() ) + xControl->start(); +} + +FileSink::~FileSink() +{ + DirEntry aEntry( m_aFileName ); + aEntry.Kill(); +} + +void FileSink::closeOutput() +{ + if( fp ) + fclose( fp ); + + Reference< XInterface > xInst = m_xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ); + Reference< ::com::sun::star::frame::XComponentLoader > xLoader( xInst, UNO_QUERY ); + XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( m_xPlugin ); + + if( xLoader.is() && pPlugin ) + { + ::com::sun::star::beans::PropertyValue aValue; + aValue.Name = ::rtl::OUString::createFromAscii( "Referer" ); + aValue.Value <<= pPlugin->getRefererURL(); + + Sequence< ::com::sun::star::beans::PropertyValue > aArgs( &aValue, 1 ); + Reference< ::com::sun::star::lang::XComponent > xComp = + xLoader->loadComponentFromURL( + m_aFileName, + m_aTarget, + ::com::sun::star::frame::FrameSearchFlag::PARENT | + ::com::sun::star::frame::FrameSearchFlag::SELF | + ::com::sun::star::frame::FrameSearchFlag::CHILDREN | + ::com::sun::star::frame::FrameSearchFlag::SIBLINGS | + ::com::sun::star::frame::FrameSearchFlag::TASKS | + ::com::sun::star::frame::FrameSearchFlag::CREATE, + aArgs + ); + } + release(); +} + +void FileSink::writeBytes( const Sequence<sal_Int8>& Buffer ) +{ + if( fp ) + fwrite( Buffer.getConstArray(), 1, Buffer.getLength(), fp ); +} + +void FileSink::flush() +{ + if( fp ) + fflush( fp ); +} diff --git a/extensions/source/plugin/base/evtlstnr.cxx b/extensions/source/plugin/base/evtlstnr.cxx new file mode 100644 index 000000000000..0579e7c09105 --- /dev/null +++ b/extensions/source/plugin/base/evtlstnr.cxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * $RCSfile: evtlstnr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#if STLPORT_VERSION>=321 +#include <cstdarg> +#endif + +#include <plugin/impl.hxx> + +PluginEventListener::PluginEventListener( XPlugin_Impl* pPlugin, + const char* url, + const char* normurl, + void* notifyData ) : + m_pPlugin( pPlugin ), + m_xPlugin( pPlugin ), + m_pUrl( strdup( url ) ), + m_pNormalizedUrl( strdup( normurl ) ), + m_pNotifyData( notifyData ) +{ +} + +PluginEventListener::~PluginEventListener() +{ + if( m_pUrl ) + free( m_pUrl ); + if( m_pNormalizedUrl ) + free( m_pNormalizedUrl ); +} + +void PluginEventListener::disposing( const ::com::sun::star::lang::EventObject& rEvt ) +{ + m_pPlugin->getPluginComm()-> + NPP_URLNotify( m_pPlugin->getNPPInstance(), + m_pUrl, + NPRES_DONE, + m_pNotifyData ); +} diff --git a/extensions/source/plugin/base/makefile.mk b/extensions/source/plugin/base/makefile.mk new file mode 100644 index 000000000000..56d73938ec1c --- /dev/null +++ b/extensions/source/plugin/base/makefile.mk @@ -0,0 +1,159 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ +# +# 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=plugin +TARGET=plbase +ENABLE_EXCEPTIONS=TRUE + +.INCLUDE : ..$/util$/makefile.pmk + +# --- Types ------------------------------------- + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb + +UNOUCROUT=$(OUT)$/inc$/$(PRJNAME) +INCPRE+=$(UNOUCROUT) + +# --- Types ------------------------------------- + +UNOTYPES=\ + com.sun.star.awt.PosSize \ + com.sun.star.awt.MouseButton \ + com.sun.star.awt.FocusChangeReason \ + com.sun.star.awt.KeyFunction \ + com.sun.star.awt.Key \ + com.sun.star.awt.KeyModifier \ + com.sun.star.awt.KeyGroup \ + com.sun.star.awt.XAdjustmentListener \ + com.sun.star.awt.XActionListener \ + com.sun.star.awt.XTextListener \ + com.sun.star.awt.XSpinListener \ + com.sun.star.awt.XItemListener \ + com.sun.star.awt.XVclContainerListener \ + com.sun.star.awt.XVclContainerPeer \ + com.sun.star.awt.XVclContainer \ + com.sun.star.awt.XVclWindowPeer \ + com.sun.star.awt.VclWindowPeerAttribute \ + com.sun.star.awt.XActivateListener \ + com.sun.star.awt.XTopWindowListener \ + com.sun.star.awt.XKeyListener \ + com.sun.star.awt.XTopWindow \ + com.sun.star.awt.XControl \ + com.sun.star.awt.XControlModel \ + com.sun.star.awt.XUnoControlContainer \ + com.sun.star.beans.PropertyValues \ + com.sun.star.beans.PropertyAttribute \ + com.sun.star.beans.XPropertySet \ + com.sun.star.beans.XMultiPropertySet \ + com.sun.star.beans.XFastPropertySet \ + com.sun.star.beans.XPropertyState \ + com.sun.star.beans.XPropertyAccess \ + com.sun.star.beans.XPropertyContainer \ + com.sun.star.beans.XPropertyChangeListener \ + com.sun.star.beans.XPropertyStateChangeListener \ + com.sun.star.plugin.PluginMode \ + com.sun.star.plugin.XPluginManager \ + com.sun.star.io.XConnectable \ + com.sun.star.io.XActiveDataSource \ + com.sun.star.io.XActiveDataSink \ + com.sun.star.io.XActiveDataControl \ + com.sun.star.io.XDataOutputStream \ + com.sun.star.io.XDataInputStream \ + com.sun.star.io.XObjectInputStream \ + com.sun.star.io.XMarkableStream \ + com.sun.star.lang.XServiceName \ + com.sun.star.lang.XServiceInfo \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.loader.XImplementationLoader \ + com.sun.star.container.XSet \ + com.sun.star.container.XNameAccess \ + com.sun.star.container.XIndexAccess \ + com.sun.star.frame.XComponentLoader \ + com.sun.star.frame.FrameSearchFlag \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XAggregation \ + com.sun.star.uno.XWeak + +# --- Files -------------------------------------------------------- + +SLOFILES= \ + $(SLO)$/plctrl.obj \ + $(SLO)$/service.obj \ + $(SLO)$/xplugin.obj \ + $(SLO)$/nfuncs.obj \ + $(SLO)$/manager.obj \ + $(SLO)$/context.obj \ + $(SLO)$/evtlstnr.obj \ + $(SLO)$/plcom.obj \ + $(SLO)$/multiplx.obj \ + $(SLO)$/plmodel.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +.INCLUDE : ..$/util$/target.pmk diff --git a/extensions/source/plugin/base/manager.cxx b/extensions/source/plugin/base/manager.cxx new file mode 100644 index 000000000000..1a6b14887759 --- /dev/null +++ b/extensions/source/plugin/base/manager.cxx @@ -0,0 +1,316 @@ +/************************************************************************* + * + * $RCSfile: manager.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#if STLPORT_VERSION>=321 +#include <cstdarg> +#endif + +#include <plugin/impl.hxx> +#include <osl/mutex.hxx> +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XEnumerationAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATION_HPP_ +#include <com/sun/star/container/XEnumeration.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XELEMENTACCESS_HPP_ +#include <com/sun/star/container/XElementAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_LOADER_XIMPLEMENTATIONLOADER_HPP_ +#include <com/sun/star/loader/XImplementationLoader.hpp> +#endif +#ifndef _COM_SUN_STAR_LOADER_CANNOTACTIVATEFACTORYEXCEPTION_HPP_ +#include <com/sun/star/loader/CannotActivateFactoryException.hpp> +#endif + +PluginManager* PluginManager::pManager = NULL; + +PluginManager& PluginManager::get() +{ + if( ! pManager ) + pManager = new PluginManager(); + return *pManager; +} + +void PluginManager::setServiceFactory( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory ) +{ + PluginManager& rManager = get(); + if( ! rManager.m_xSMgr.is() ) + rManager.m_xSMgr = xFactory; +} + +PluginManager::PluginManager() +{ +} + +PluginManager::~PluginManager() +{ +} + +const Sequence< ::rtl::OUString >& PluginManager::getAdditionalSearchPaths() +{ + static Sequence< ::rtl::OUString > aPaths; + + if( ! aPaths.getLength() ) + { + Reference< XInterface > xInst = get().m_xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Settings" ) ); + Reference< ::com::sun::star::container::XNameAccess > xAccess( xInst, UNO_QUERY ); + if( xAccess.is() ) + { + Any aValue = xAccess->getByName( ::rtl::OUString::createFromAscii( "PathSettings" ) ); + Reference< ::com::sun::star::beans::XPropertySet > xProp; + if( aValue.hasValue() ) + aValue >>= xProp; + if( xProp.is() ) + { + aValue = xProp->getPropertyValue( ::rtl::OUString::createFromAscii( "Plugins" ) ); + if( aValue.getValueType().getTypeClass() == TypeClass_STRING ) + + { + ::rtl::OUString sValue; + aValue >>= sValue; + sal_Int32 nTokens = sValue.getTokenCount(); + aPaths = Sequence< ::rtl::OUString >( nTokens ); + while( nTokens-- ) + aPaths.getArray()[nTokens] = sValue.getToken( nTokens ); + } + else if( aValue.getValueType().equals( ::getCppuType( (Sequence< ::rtl::OUString >*)0 ) ) ) + + { + Sequence< ::rtl::OUString > aArr; + aValue >>= aArr; + sal_Int32 nGlobalTokens = 0; + int i = 0; + for( i = 0; i < aArr.getLength(); i++ ) + nGlobalTokens += aArr.getConstArray()[i].getTokenCount(); + aPaths = Sequence< ::rtl::OUString >( nGlobalTokens ); + for( i = aArr.getLength()-1; i >= 0; i-- ) + { + sal_Int32 nTokens = aArr.getConstArray()[i].getTokenCount(); + while( nTokens-- ) + aPaths.getArray()[--nGlobalTokens] = + aArr.getConstArray()[i].getToken( nTokens ); + } + } + } + } + } + + return aPaths; +} + +//================================================================================================== +Reference< XInterface > SAL_CALL PluginManager_CreateInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ) throw( Exception ) +{ + Reference< XInterface > xService = *new XPluginManager_Impl( rSMgr ); + return xService; +} + +// ::com::sun::star::lang::XServiceInfo +::rtl::OUString XPluginManager_Impl::getImplementationName() throw( ) + +{ + return getImplementationName_Static(); + +} + +// ::com::sun::star::lang::XServiceInfo +sal_Bool XPluginManager_Impl::supportsService(const ::rtl::OUString& ServiceName) throw( ) +{ + Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames(); + const ::rtl::OUString * pArray = aSNL.getConstArray(); + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return sal_True; + return sal_False; +} + +// ::com::sun::star::lang::XServiceInfo +Sequence< ::rtl::OUString > XPluginManager_Impl::getSupportedServiceNames(void) throw( ) +{ + return getSupportedServiceNames_Static(); +} + +// XPluginManager_Impl +Sequence< ::rtl::OUString > XPluginManager_Impl::getSupportedServiceNames_Static(void) throw( ) +{ + Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS.getArray()[0] = ::rtl::OUString::createFromAscii( "com.sun.star.plugin.PluginManager" ); + return aSNS; +} + +XPluginManager_Impl::XPluginManager_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ) +: m_xSMgr( rSMgr ) +{ + PluginManager::setServiceFactory( rSMgr ); +} + +XPluginManager_Impl::~XPluginManager_Impl() +{ +} + +XPlugin_Impl* XPluginManager_Impl::getXPluginFromNPP( NPP instance ) +{ + ::std::list<XPlugin_Impl*>::iterator iter; + for( iter = PluginManager::get().getPlugins().begin(); + iter != PluginManager::get().getPlugins().end(); ++iter ) + { + if( (*iter)->getNPPInstance() == instance ) + return *iter; + } + + return NULL; +} + +XPlugin_Impl* XPluginManager_Impl::getPluginImplementation( const Reference< ::com::sun::star::plugin::XPlugin >& plugin ) +{ + ::std::list<XPlugin_Impl*>::iterator iter; + for( iter = PluginManager::get().getPlugins().begin(); + iter != PluginManager::get().getPlugins().end(); ++iter ) + { + if( plugin == Reference< ::com::sun::star::plugin::XPlugin >((*iter)) ) + return *iter; + } + + return NULL; +} + +XPlugin_Impl* XPluginManager_Impl::getFirstXPlugin() +{ + if( PluginManager::get().getPlugins().begin() == PluginManager::get().getPlugins().end() ) + return NULL; + + return *PluginManager::get().getPlugins().begin(); +} + +Reference< ::com::sun::star::plugin::XPlugin > XPluginManager_Impl::createPlugin( const Reference< ::com::sun::star::plugin::XPluginContext >& acontext, INT16 mode, const Sequence< ::rtl::OUString >& argn, const Sequence< ::rtl::OUString >& argv, const ::com::sun::star::plugin::PluginDescription& plugintype) + throw( RuntimeException,::com::sun::star::plugin::PluginException ) +{ + XPlugin_Impl* pImpl = new XPlugin_Impl( m_xSMgr ); + pImpl->setPluginContext( acontext ); + + PluginManager::get().getPlugins().push_back( pImpl ); + + pImpl->initInstance( plugintype, + argn, + argv, + mode ); + + return pImpl; +} + +Reference< ::com::sun::star::plugin::XPlugin > XPluginManager_Impl::createPluginFromURL( const Reference< ::com::sun::star::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< ::rtl::OUString >& argn, const Sequence< ::rtl::OUString >& argv, const Reference< ::com::sun::star::awt::XToolkit > & toolkit, const Reference< ::com::sun::star::awt::XWindowPeer > & parent, const ::rtl::OUString& url ) +{ + XPlugin_Impl* pImpl = new XPlugin_Impl( m_xSMgr ); + Reference< ::com::sun::star::plugin::XPlugin > xRef = pImpl; // festhalten... + + pImpl->setPluginContext( acontext ); + + PluginManager::get().getPlugins().push_back( pImpl ); + + int nDescr = -1; + Sequence< ::com::sun::star::plugin::PluginDescription > aDescrs = getPluginDescriptions(); + const ::com::sun::star::plugin::PluginDescription* pDescrs = aDescrs.getConstArray(); + + int nPos = url.lastIndexOf( (sal_Unicode)'.' ); + if( nPos != -1 ) + { + ::rtl::OUString aExt = url.copy( nPos ).toLowerCase(); + for( int i = 0; i < aDescrs.getLength(); i++ ) + { + if( pDescrs[ i ].Extension.equalsIgnoreCase( aExt ) != STRING_NOTFOUND ) + { + nDescr = i; + break; + } + } + } + + pImpl->initInstance( (nDescr != -1) ? pDescrs[ nDescr ] : ::com::sun::star::plugin::PluginDescription(), + argn, + argv, + mode ); + + pImpl->createPeer( toolkit, parent ); + + Reference< ::com::sun::star::beans::XPropertySet > xProperty( pImpl->getModel(), UNO_QUERY ); + if( xProperty.is() ) + { + Any aAny; + aAny <<= url; + xProperty->setPropertyValue( ::rtl::OUString::createFromAscii( "URL" ), aAny ); + } + + if( ! pImpl->getPluginComm() ) + { + pImpl->dispose(); + xRef = NULL; + } + + return xRef; +} + diff --git a/extensions/source/plugin/base/multiplx.cxx b/extensions/source/plugin/base/multiplx.cxx new file mode 100644 index 000000000000..d2ba82df78d7 --- /dev/null +++ b/extensions/source/plugin/base/multiplx.cxx @@ -0,0 +1,391 @@ +/************************************************************************* + * + * $RCSfile: multiplx.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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/diagnose.hxx> +#include <plugin/multiplx.hxx> + +// --------------------------------------------------------------------- +// class MRCListenerMultiplexerHelper +// --------------------------------------------------------------------- +MRCListenerMultiplexerHelper::MRCListenerMultiplexerHelper +( + const Reference< ::com::sun::star::awt::XWindow > & rControl + , const Reference< ::com::sun::star::awt::XWindow > & rPeer +) + : aListenerHolder( aMutex ) + , xPeer( rPeer ) + , xControl( Reference< ::com::sun::star::awt::XControl >( rControl, UNO_QUERY ) ) +{ +} + + +void MRCListenerMultiplexerHelper::setPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer ) +{ + ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); + if( xPeer != rPeer ) + { + if( xPeer.is() ) + { + // get all uiks from the listener added to the peer + Sequence<Type> aContainedTypes = aListenerHolder.getContainedTypes(); + const Type* pArray = aContainedTypes.getConstArray(); + sal_Int32 nCount = aContainedTypes.getLength(); + // loop over all listener types and remove the listeners from the peer + for( sal_Int32 i = 0; i < nCount; i++ ) + unadviseFromPeer( xPeer, pArray[i] ); + } + xPeer = rPeer; + if( xPeer.is() ) + { + // get all uiks from the listener added to the peer + Sequence<Type> aContainedTypes = aListenerHolder.getContainedTypes(); + const Type * pArray = aContainedTypes.getConstArray(); + sal_Int32 nCount = aContainedTypes.getLength(); + // loop over all listener types and add the listeners to the peer + for( sal_Int32 i = 0; i < nCount; i++ ) + adviseToPeer( xPeer, pArray[i] ); + } + } +} + +// MRCListenerMultiplexerHelper +void MRCListenerMultiplexerHelper::disposeAndClear() +{ + ::com::sun::star::lang::EventObject aEvt; + aEvt.Source = xControl; + aListenerHolder.disposeAndClear( aEvt ); +} + +// MRCListenerMultiplexerHelper +void MRCListenerMultiplexerHelper::adviseToPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type ) +{ + // add a listener to the source (peer) + if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0) ) + rPeer->addWindowListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0) ) + rPeer->addKeyListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0) ) + rPeer->addFocusListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0) ) + rPeer->addMouseListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0) ) + rPeer->addMouseMotionListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0) ) + rPeer->addPaintListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XTopWindowListener >*)0) ) + { + Reference< ::com::sun::star::awt::XTopWindow > xTop( rPeer, UNO_QUERY ); + if( xTop.is() ) + xTop->addTopWindowListener( this ); + } + else + { + VOS_ENSHURE( sal_False, "unknown listener" ); + } +} + +// MRCListenerMultiplexerHelper +void MRCListenerMultiplexerHelper::unadviseFromPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type ) +{ + // the last listener is removed, remove the listener from the source (peer) + if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0) ) + rPeer->removeWindowListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0) ) + rPeer->removeKeyListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0) ) + rPeer->removeFocusListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0) ) + rPeer->removeMouseListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0) ) + rPeer->removeMouseMotionListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0) ) + rPeer->removePaintListener( this ); + else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XTopWindowListener >*)0) ) + { + Reference< ::com::sun::star::awt::XTopWindow > xTop( rPeer, UNO_QUERY ); + if( xTop.is() ) + xTop->removeTopWindowListener( this ); + } + else + { + VOS_ENSHURE( sal_False, "unknown listener" ); + } +} + +// MRCListenerMultiplexerHelper +void MRCListenerMultiplexerHelper::advise( const Type & type, const Reference< XInterface > & listener) +{ + ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); + if( 1 == aListenerHolder.addInterface( type, listener ) ) + { + // the first listener is added + if( xPeer.is() ) + adviseToPeer( xPeer, type ); + } +} + +// MRCListenerMultiplexerHelper +void MRCListenerMultiplexerHelper::unadvise(const Type & type, const Reference< XInterface > & listener) +{ + ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); + ::cppu::OInterfaceContainerHelper * pCont = aListenerHolder.getContainer( type ); + if( pCont ) + { + if( 0 == pCont->removeInterface( listener ) && xPeer.is() ) + // the last listener is removed + unadviseFromPeer( xPeer, type ); + } +} + +// ::com::sun::star::lang::XEventListener +void MRCListenerMultiplexerHelper::disposing(const ::com::sun::star::lang::EventObject& ) +{ + ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); + // peer is disposed, clear the reference + xPeer = Reference< ::com::sun::star::awt::XWindow > (); +} + +#define MULTIPLEX( InterfaceName, MethodName, EventName ) \ +::cppu::OInterfaceContainerHelper * pCont; \ +pCont = aListenerHolder.getContainer( ::getCppuType((const Reference< InterfaceName >*)0) ); \ +if( pCont ) \ +{ \ + ::cppu::OInterfaceIteratorHelper aIt( *pCont ); \ + EventName aEvt = e; \ + /* Remark: The control is the event source not the peer. We must change */ \ + /* the source of the event */ \ + aEvt.Source = xControl;\ + /*.is the control not destroyed */ \ + if( aEvt.Source.is() ) \ + { \ + if( aIt.hasMoreElements() ) \ + { \ + InterfaceName * pListener = (InterfaceName *)aIt.next(); \ + try \ + { \ + pListener->MethodName( aEvt ); \ + } \ + catch( RuntimeException& ) \ + { \ + /* ignore all usr system exceptions from the listener */ \ + } \ + } \ + } \ +} + +// ::com::sun::star::awt::XFocusListener +void MRCListenerMultiplexerHelper::focusGained(const ::com::sun::star::awt::FocusEvent& e) +{ +/* + OInterfaceContainerHelper * pCont = aListenerHolder.getContainer( ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0) ); + if( pCont ) + { + OInterfaceIteratorHelper aIt( *pCont ); + ::com::sun::star::awt::FocusEvent aEvt = e; + // Reamark: The control is the event source not the peer. We must change + // the source of the event + xControl.queryHardRef( ((XInterface*)NULL)->getSmartUik(), aEvt.Source ); + //.is the control not destroyed + if( aEvt.Source.is() ) + { + if( aIt.hasMoreElements() ) + { + ::com::sun::star::awt::XFocusListener * pListener = (::com::sun::star::awt::XFocusListener *)aIt.next(); + TRY + { + pListener->focusGained( aEvt ); + } + CATCH( RuntimeException, e ) + { + // ignore all usr system exceptions from the listener + } + END_CATCH; + } + } + } +*/ + MULTIPLEX( ::com::sun::star::awt::XFocusListener, focusGained, ::com::sun::star::awt::FocusEvent ) +} + +// ::com::sun::star::awt::XFocusListener +void MRCListenerMultiplexerHelper::focusLost(const ::com::sun::star::awt::FocusEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XFocusListener, focusLost, ::com::sun::star::awt::FocusEvent ) +} + +// ::com::sun::star::awt::XWindowListener +void MRCListenerMultiplexerHelper::windowResized(const ::com::sun::star::awt::WindowEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowResized, ::com::sun::star::awt::WindowEvent ) +} + +// ::com::sun::star::awt::XWindowListener +void MRCListenerMultiplexerHelper::windowMoved(const ::com::sun::star::awt::WindowEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowMoved, ::com::sun::star::awt::WindowEvent ) +} + +// ::com::sun::star::awt::XWindowListener +void MRCListenerMultiplexerHelper::windowShown(const ::com::sun::star::lang::EventObject& e) +{ + MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowShown, ::com::sun::star::lang::EventObject ) +} + +// ::com::sun::star::awt::XWindowListener +void MRCListenerMultiplexerHelper::windowHidden(const ::com::sun::star::lang::EventObject& e) +{ + MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowHidden, ::com::sun::star::lang::EventObject ) +} + +// ::com::sun::star::awt::XKeyListener +void MRCListenerMultiplexerHelper::keyPressed(const ::com::sun::star::awt::KeyEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XKeyListener, keyPressed, ::com::sun::star::awt::KeyEvent ) +} + +// ::com::sun::star::awt::XKeyListener +void MRCListenerMultiplexerHelper::keyReleased(const ::com::sun::star::awt::KeyEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XKeyListener, keyReleased, ::com::sun::star::awt::KeyEvent ) +} + +// ::com::sun::star::awt::XMouseListener +void MRCListenerMultiplexerHelper::mousePressed(const ::com::sun::star::awt::MouseEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XMouseListener, mousePressed, ::com::sun::star::awt::MouseEvent ) +} + +// ::com::sun::star::awt::XMouseListener +void MRCListenerMultiplexerHelper::mouseReleased(const ::com::sun::star::awt::MouseEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XMouseListener, mouseReleased, ::com::sun::star::awt::MouseEvent ) +} + +// ::com::sun::star::awt::XMouseListener +void MRCListenerMultiplexerHelper::mouseEntered(const ::com::sun::star::awt::MouseEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XMouseListener, mouseEntered, ::com::sun::star::awt::MouseEvent ) +} + +// ::com::sun::star::awt::XMouseListener +void MRCListenerMultiplexerHelper::mouseExited(const ::com::sun::star::awt::MouseEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XMouseListener, mouseExited, ::com::sun::star::awt::MouseEvent ) +} + +// ::com::sun::star::awt::XMouseMotionListener +void MRCListenerMultiplexerHelper::mouseDragged(const ::com::sun::star::awt::MouseEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XMouseMotionListener, mouseDragged, ::com::sun::star::awt::MouseEvent ) +} + +// ::com::sun::star::awt::XMouseMotionListener +void MRCListenerMultiplexerHelper::mouseMoved(const ::com::sun::star::awt::MouseEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XMouseMotionListener, mouseMoved, ::com::sun::star::awt::MouseEvent ) +} + +// ::com::sun::star::awt::XPaintListener +void MRCListenerMultiplexerHelper::windowPaint(const ::com::sun::star::awt::PaintEvent& e) +{ + MULTIPLEX( ::com::sun::star::awt::XPaintListener, windowPaint, ::com::sun::star::awt::PaintEvent ) +} + +// ::com::sun::star::awt::XTopWindowListener +void MRCListenerMultiplexerHelper::windowOpened(const ::com::sun::star::lang::EventObject& e) +{ + MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowOpened, ::com::sun::star::lang::EventObject ) +} + +// ::com::sun::star::awt::XTopWindowListener +void MRCListenerMultiplexerHelper::windowClosing( const ::com::sun::star::lang::EventObject& e ) +{ + MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowClosing, ::com::sun::star::lang::EventObject ) +} + +// ::com::sun::star::awt::XTopWindowListener +void MRCListenerMultiplexerHelper::windowClosed( const ::com::sun::star::lang::EventObject& e ) +{ + MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowClosed, ::com::sun::star::lang::EventObject ) +} + +// ::com::sun::star::awt::XTopWindowListener +void MRCListenerMultiplexerHelper::windowMinimized( const ::com::sun::star::lang::EventObject& e ) +{ + MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowMinimized, ::com::sun::star::lang::EventObject ) +} + +// ::com::sun::star::awt::XTopWindowListener +void MRCListenerMultiplexerHelper::windowNormalized( const ::com::sun::star::lang::EventObject& e ) +{ + MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowNormalized, ::com::sun::star::lang::EventObject ) +} + +// ::com::sun::star::awt::XTopWindowListener +void MRCListenerMultiplexerHelper::windowActivated( const ::com::sun::star::lang::EventObject& e ) +{ + MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowActivated, ::com::sun::star::lang::EventObject ) +} + +// ::com::sun::star::awt::XTopWindowListener +void MRCListenerMultiplexerHelper::windowDeactivated( const ::com::sun::star::lang::EventObject& e ) +{ + MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowDeactivated, ::com::sun::star::lang::EventObject ) +} diff --git a/extensions/source/plugin/base/nfuncs.cxx b/extensions/source/plugin/base/nfuncs.cxx new file mode 100644 index 000000000000..b90c002e82b9 --- /dev/null +++ b/extensions/source/plugin/base/nfuncs.cxx @@ -0,0 +1,576 @@ +/************************************************************************* + * + * $RCSfile: nfuncs.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#if STLPORT_VERSION>=321 +#include <cstdarg> +#endif + +#include <stl/list> + +#ifdef USE_NAMESPACE +using namespace std; +#endif + + +#include <plugin/impl.hxx> + +// #define TRACE(x) DBG_ERROR( (x) ) +#define TRACE(x) + + +NPNetscapeFuncs aNPNFuncs = +{ + sizeof( NPNetscapeFuncs ), + (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR, + NPN_GetURL, + NPN_PostURL, + NPN_RequestRead, + NPN_NewStream, + NPN_Write, + NPN_DestroyStream, + NPN_Status, + NPN_UserAgent, + NPN_MemAlloc, + NPN_MemFree, + NPN_MemFlush, + NPN_ReloadPlugins, + NPN_GetJavaEnv, + NPN_GetJavaPeer, + NPN_GetURLNotify, + NPN_PostURLNotify, + NPN_GetValue, + NPN_SetValue, + NPN_InvalidateRect, + NPN_InvalidateRegion, + NPN_ForceRedraw +}; + +static ::rtl::OString normalizeURL( XPlugin_Impl* plugin, const ::rtl::OString& url ) +{ + ::rtl::OString aLoadURL; + if( url.indexOf( ":/" ) == -1 ) + { + aLoadURL = ::rtl::OUStringToOString( plugin->getCreationURL(), plugin->getTextEncoding() ); + int nPos; + if( ( nPos = aLoadURL.indexOf( "://" ) ) != -1 ) + { + if( url.getLength() && url.getStr()[ 0 ] == '/' || url.indexOf( '/' ) != -1 ) + { + // this means same server but new path + nPos = aLoadURL.indexOf( '/', nPos+3 ); + + if( nPos != -1 ) + aLoadURL = aLoadURL.copy( 0, url.getStr()[0] == '/' ? nPos : nPos+1 ); + } + else + { + // same server but new file + nPos = aLoadURL.lastIndexOf( '/' ); + aLoadURL = aLoadURL.copy( 0, nPos+1 ); + } + aLoadURL += url; + } + else + aLoadURL = url; + } + else + aLoadURL = url; + + return aLoadURL; +} + + +extern "C" { + + void* SAL_CALL NP_LOADDS NPN_MemAlloc( uint32 nBytes ) + { + TRACE( "NPN_MemAlloc" ); + void* pMem = malloc( nBytes ); + return pMem; + } + + void SAL_CALL NP_LOADDS NPN_MemFree( void* pMem ) + { + TRACE( "NPN_MemFree" ); + free( pMem ); + } + + uint32 SAL_CALL NP_LOADDS NPN_MemFlush( uint32 nSize ) + { + TRACE( "NPN_MemFlush" ); + return 0; + } + + NPError SAL_CALL NP_LOADDS NPN_DestroyStream( NPP instance, NPStream* stream, NPError reason ) + { + TRACE( "NPN_DestroyStream" ); + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( ! pImpl ) + return NPERR_INVALID_INSTANCE_ERROR; + + PluginStream* pStream = pImpl->getStreamFromNPStream( stream ); + if( pStream ) + delete pStream; + + return NPERR_NO_ERROR; + } + + const JRIEnvInterface** SAL_CALL NP_LOADDS NPN_GetJavaEnv() + { + TRACE( "NPN_GetJavaEnv" ); + // no java in this program + return NULL; + } + + void* SAL_CALL NP_LOADDS NPN_GetJavaPeer( NPP instance ) + { + TRACE( "NPN_GetJavaPeer" ); + return NULL; + } + + NPError SAL_CALL NP_LOADDS NPN_GetURL( NPP instance, const char* url, const char* window ) + { + TRACE( "NPN_GetURL" ); + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( ! pImpl ) + return NPERR_INVALID_INSTANCE_ERROR; + + ::rtl::OString aLoadURL = normalizeURL( pImpl, url ); + try + { + pImpl->enterPluginCallback(); + pImpl->getPluginContext()-> + getURL( pImpl, + ::rtl::OStringToOUString( aLoadURL, pImpl->getTextEncoding() ), + ::rtl::OStringToOUString( window, pImpl->getTextEncoding() ) + ); + pImpl->leavePluginCallback(); + } + catch( ::com::sun::star::plugin::PluginException& e ) + { + pImpl->leavePluginCallback(); + return e.ErrorCode; + } + + return NPERR_NO_ERROR; + } + + NPError SAL_CALL NP_LOADDS NPN_GetURLNotify( NPP instance, const char* url, const char* target, + void* notifyData ) + { + TRACE( "NPN_GetURLNotify" ); + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( ! pImpl ) + return NPERR_INVALID_INSTANCE_ERROR; + + ::rtl::OString aLoadURL = normalizeURL( pImpl, url ); + PluginEventListener* pListener = + new PluginEventListener( pImpl, url, aLoadURL.getStr(), notifyData ); + if( ! target || ! *target ) + { + // stream will be fed back to plugin, + // notify immediately after destruction of stream + pImpl->addPluginEventListener( pListener ); + pListener = NULL; + } + + try + { + pImpl->enterPluginCallback(); + pImpl->getPluginContext()-> + getURLNotify( pImpl, + ::rtl::OStringToOUString( aLoadURL, pImpl->getTextEncoding() ), + ::rtl::OStringToOUString( target, pImpl->getTextEncoding() ), + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > ( pListener ) ); + pImpl->leavePluginCallback(); + } + catch( ::com::sun::star::plugin::PluginException& e ) + { + pImpl->leavePluginCallback(); + return e.ErrorCode; + } + + return NPERR_NO_ERROR; + } + + NPError SAL_CALL NP_LOADDS NPN_NewStream( NPP instance, NPMIMEType type, const char* target, + NPStream** stream ) + // stream is a return value + { + TRACE( "NPN_NewStream" ); + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( ! pImpl ) + return NPERR_INVALID_INSTANCE_ERROR; + + PluginOutputStream* pStream = new PluginOutputStream( pImpl, + "", 0, 0 ); + *stream = pStream->getStream(); + + try + { + pImpl->enterPluginCallback(); + pImpl->getPluginContext()-> + newStream( + pImpl, + ::rtl::OStringToOUString( type, pImpl->getTextEncoding () ), + ::rtl::OStringToOUString( target, pImpl->getTextEncoding() ), + ::com::sun::star::uno::Reference< ::com::sun::star::io::XActiveDataSource > ( pStream->getOutputStream(), UNO_QUERY ) + ); + pImpl->leavePluginCallback(); + } + catch( ::com::sun::star::plugin::PluginException& e ) + { + pImpl->leavePluginCallback(); + return e.ErrorCode; + } + + return NPERR_NO_ERROR; + } + + NPError SAL_CALL NP_LOADDS NPN_PostURLNotify( NPP instance, const char* url, const char* target, uint32 len, const char* buf, NPBool file, void* notifyData ) + { + TRACE( "NPN_PostURLNotify" ); + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( ! pImpl ) + return NPERR_INVALID_INSTANCE_ERROR; + + ::com::sun::star::uno::Sequence<sal_Int8> Bytes( (sal_Int8*)buf, len ); + + ::rtl::OString aPostURL = normalizeURL( pImpl, url ); + PluginEventListener* pListener = + new PluginEventListener( pImpl, url, aPostURL.getStr(), notifyData ); + + if( ! target || ! *target ) + { + // stream will be fed back to plugin, + // notify immediately after destruction of stream + pImpl->addPluginEventListener( pListener ); + pListener = NULL; + } + + try + { + pImpl->enterPluginCallback(); + pImpl->getPluginContext()-> + postURLNotify( pImpl, + ::rtl::OStringToOUString( aPostURL, pImpl->getTextEncoding() ), + ::rtl::OStringToOUString( target, pImpl->getTextEncoding() ), + Bytes, + file, + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > ( pListener ) ); + pImpl->leavePluginCallback(); + } + catch( ::com::sun::star::plugin::PluginException& e ) + { + pImpl->leavePluginCallback(); + return e.ErrorCode; + } + + return NPERR_NO_ERROR; + } + + NPError SAL_CALL NP_LOADDS NPN_PostURL( NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file ) + { + TRACE( "NPN_PostURL" ); + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( ! pImpl ) + return NPERR_INVALID_INSTANCE_ERROR; + + ::com::sun::star::uno::Sequence<sal_Int8> Bytes( (sal_Int8*)buf, len ); + ::rtl::OString aPostURL = normalizeURL( pImpl, url ); + try + { + pImpl->enterPluginCallback(); + pImpl->getPluginContext()-> + postURL( pImpl, + ::rtl::OStringToOUString( aPostURL, pImpl->getTextEncoding() ), + ::rtl::OStringToOUString( window, pImpl->getTextEncoding () ), + Bytes, + file ); + pImpl->leavePluginCallback(); + } + catch( ::com::sun::star::plugin::PluginException& e ) + { + pImpl->leavePluginCallback(); + return e.ErrorCode; + } + + return NPERR_NO_ERROR; + } + + NPError SAL_CALL NP_LOADDS NPN_RequestRead( NPStream* stream, NPByteRange* rangeList ) + { + TRACE( "NPN_RequestRead" ); + if( ! rangeList ) + return NPERR_NO_ERROR; + + ::std::list<XPlugin_Impl*>& rList = PluginManager::get().getPlugins(); + ::std::list<XPlugin_Impl*>::iterator iter; + XPlugin_Impl* pPlugin = NULL; + PluginStream* pStream = NULL; + for( iter = rList.begin(); iter!= rList.end(); ++iter ) + if( ( pStream = (*iter)->getStreamFromNPStream( stream ) ) ) + { + pPlugin = *iter; + break; + } + if( ! pPlugin ) + return NPERR_INVALID_INSTANCE_ERROR; + if( ! pStream || pStream->getStreamType() != InputStream ) + return NPERR_FILE_NOT_FOUND; + + PluginInputStream* pInputStream = (PluginInputStream*)pStream; + sal_Int8* pBytes = NULL; + int nBytes = 0; + pPlugin->enterPluginCallback(); + while( rangeList ) + { + if( pBytes && nBytes < rangeList->length ) + { + delete pBytes; + pBytes = NULL; + } + if( ! pBytes ) + pBytes = new sal_Int8[ nBytes = rangeList->length ]; + int nRead = + pInputStream->read( rangeList->offset, pBytes, rangeList->length ); + int nPos = 0; + int nNow; + do + { + nNow = pPlugin->getPluginComm()-> + NPP_WriteReady( pPlugin->getNPPInstance(), + stream ); + pPlugin->getPluginComm()-> + NPP_Write( pPlugin->getNPPInstance(), + stream, + rangeList->offset + nPos, + nNow, + pBytes+nPos ); + nPos += nNow; + nRead -= nNow; + } while( nRead > 0 && nNow ); + rangeList = rangeList->next; + } + pPlugin->leavePluginCallback(); + + return NPERR_NO_ERROR; + } + + void SAL_CALL NP_LOADDS NPN_Status( NPP instance, const char* message ) + { + TRACE( "NPN_Status" ); + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( ! pImpl ) + return; + + try + { + pImpl->enterPluginCallback(); + pImpl->getPluginContext()-> + displayStatusText( pImpl, ::rtl::OStringToOUString( message, pImpl->getTextEncoding() ) ); + pImpl->leavePluginCallback(); + } + catch( ::com::sun::star::plugin::PluginException& ) + { + pImpl->leavePluginCallback(); + return; + } + } + + const char* SAL_CALL NP_LOADDS NPN_UserAgent( NPP instance ) + { + TRACE( "NPN_UserAgent" ); + static char* pAgent = strdup( "Mozilla" ); + + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( ! pImpl ) + return pAgent; + + ::rtl::OUString UserAgent; + try + { + pImpl->enterPluginCallback(); + UserAgent = pImpl->getPluginContext()-> + getUserAgent( pImpl ); + pImpl->leavePluginCallback(); + } + catch( ::com::sun::star::plugin::PluginException& ) + { + pImpl->leavePluginCallback(); + return pAgent; + } + + if( pAgent ) + free( pAgent ); + pAgent = strdup( ::rtl::OUStringToOString( UserAgent, pImpl->getTextEncoding() ).getStr() ); + + return pAgent; + } + +void SAL_CALL NP_LOADDS NPN_Version( int* major, int* minor, int* net_major, int* net_minor ) +{ + TRACE( "NPN_Version" ); + *major = 4; + *minor = 0; + *net_major = 4; + *net_minor = 5; +} + +int32 SAL_CALL NP_LOADDS NPN_Write( NPP instance, NPStream* stream, int32 len, + void* buffer ) +{ + TRACE( "NPN_Write" ); + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + if( ! pImpl ) + return 0; + + PluginStream* pStream = pImpl->getStreamFromNPStream( stream ); + if( ! pStream || pStream->getStreamType() != OutputStream ) + return 0; + + pImpl->enterPluginCallback(); + ::com::sun::star::uno::Sequence<sal_Int8> Bytes( (sal_Int8*)buffer, len ); + ((PluginOutputStream*)pStream)->getOutputStream()->writeBytes( Bytes ); + pImpl->leavePluginCallback(); + + return len; +} + + +NPError SAL_CALL NP_LOADDS NPN_GetValue( NPP instance, NPNVariable variable, void* value ) +{ + TRACE( "NPN_GetValue" ); + XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); + +#ifdef UNX + // some special unix variables + XPlugin_Impl* pInstance = pImpl ? pImpl : XPluginManager_Impl::getFirstXPlugin(); + if( ! pInstance ) + return NULL; + + switch( variable ) + { + case NPNVxDisplay: + *((Display**)value) = pInstance->getAppDisplay(); +#ifdef DEBUG + fprintf( stderr, "NPN_GetValue of display\n" ); +#endif + return NPERR_NO_ERROR; + break; + case NPNVxtAppContext: + *((XtAppContext*)value) = pInstance->getAppContext(); +#ifdef DEBUG + fprintf( stderr, "NPN_GetValue of application context\n" ); +#endif + return NPERR_NO_ERROR; + } +#endif + + if( ! pImpl ) + return 0; + + ::rtl::OUString aValue; + try + { + pImpl->enterPluginCallback(); + aValue = pImpl->getPluginContext()-> + getValue( pImpl, (::com::sun::star::plugin::PluginVariable)variable ); + pImpl->leavePluginCallback(); + } + catch( ::com::sun::star::plugin::PluginException& e ) + { + pImpl->leavePluginCallback(); + return e.ErrorCode; + } + + return NPERR_NO_ERROR; +} + +void SAL_CALL NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages) +{ + TRACE( "NPN_ReloadPlugins" ); +} + + +NPError SAL_CALL NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable, + void *value) +{ + TRACE( "NPN_SetValue" ); + return 0; +} + +void SAL_CALL NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect *invalidRect) +{ + TRACE( "NPN_InvalidateRect" ); +} + +void SAL_CALL NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion) +{ + TRACE( "NPN_InvalidateRegion" ); +} + +void SAL_CALL NP_LOADDS NPN_ForceRedraw(NPP instance) +{ + TRACE( "NPN_ForceRedraw" ); +} + +} diff --git a/extensions/source/plugin/base/plcom.cxx b/extensions/source/plugin/base/plcom.cxx new file mode 100644 index 000000000000..98a16023737e --- /dev/null +++ b/extensions/source/plugin/base/plcom.cxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * $RCSfile: plcom.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifdef SOLARIS +#include <limits> +#endif + +#if STLPORT_VERSION>=321 +#include <cstdarg> +#endif + +#include <tools/fsys.hxx> +#include <plugin/impl.hxx> + +PluginComm::PluginComm( const ::rtl::OString& rLibName ) : + m_nRefCount( 0 ), + m_aLibName( rLibName ) +{ + PluginManager::get().getPluginComms().push_back( this ); +} + +PluginComm::~PluginComm() +{ + PluginManager::get().getPluginComms().remove( this ); + while( m_aFilesToDelete.size() ) + { + String aFile = m_aFilesToDelete.front(); + m_aFilesToDelete.pop_front(); + DirEntry aEntry( aFile ); + aEntry.Kill(); + } +} diff --git a/extensions/source/plugin/base/plctrl.cxx b/extensions/source/plugin/base/plctrl.cxx new file mode 100644 index 000000000000..e65c47570e9b --- /dev/null +++ b/extensions/source/plugin/base/plctrl.cxx @@ -0,0 +1,373 @@ +/************************************************************************* + * + * $RCSfile: plctrl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 _COM_SUN_STAR_AWT_XADJUSTMENTLISTENER_HPP_ +#include <com/sun/star/awt/XAdjustmentListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XACTIONLISTENER_HPP_ +#include <com/sun/star/awt/XActionListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XTEXTLISTENER_HPP_ +#include <com/sun/star/awt/XTextListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XSPINLISTENER_HPP_ +#include <com/sun/star/awt/XSpinListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XITEMLISTENER_HPP_ +#include <com/sun/star/awt/XItemListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XVCLCONTAINERLISTENER_HPP_ +#include <com/sun/star/awt/XVclContainerListener.hpp> +#endif + +#include <plugin/plctrl.hxx> +#include <vcl/syschild.hxx> +#include <toolkit/helper/vclunohelper.hxx> + + +//-------------------------------------------------------------------------------------------------- +PluginControl_Impl::PluginControl_Impl() : + _pMultiplexer( NULL ) + , _bVisible( sal_False ) + , _bInDesignMode( sal_False ) + , _bEnable( sal_True ) + , _nX( 0 ) + , _nY( 0 ) + , _nWidth( 100 ) + , _nHeight( 100 ) + , _nFlags( WINDOW_POSSIZE_ALL ) +{ +} + +//-------------------------------------------------------------------------------------------------- +PluginControl_Impl::~PluginControl_Impl() +{ +} + +MRCListenerMultiplexerHelper* PluginControl_Impl::getMultiplexer() +{ + if( ! _pMultiplexer ) + _pMultiplexer = new MRCListenerMultiplexerHelper( this, _xPeerWindow ); + return _pMultiplexer; +} +//================================================================================================== +Reference< XInterface > PluginControl_Impl_NewInstance() +{ + return (::cppu::OWeakObject*)new PluginControl_Impl(); +} + +//-------------------------------------------------------------------------------------------------- + +void PluginControl_Impl::addEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) + throw( RuntimeException ) +{ + _aDisposeListeners.push_back( l ); +} + +//---- ::com::sun::star::lang::XComponent ---------------------------------------------------------------------------------- +void PluginControl_Impl::removeEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) + throw( RuntimeException ) +{ + _aDisposeListeners.remove( l ); +} + +//---- ::com::sun::star::lang::XComponent ---------------------------------------------------------------------------------- +void PluginControl_Impl::dispose(void) + throw( RuntimeException ) +{ + // send disposing events + ::com::sun::star::lang::EventObject aEvt; + if( getMultiplexer() ) + getMultiplexer()->disposeAndClear(); + + // release context + _xContext = Reference< XInterface > (); + releasePeer(); +} + + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) + throw( RuntimeException ) +{ + _nX = nX_ >=0 ? nX_ : 0; + _nY = nY_ >=0 ? nY_ : 0; + _nWidth = nWidth_ >=0 ? nWidth_ : 0; + _nHeight = nHeight_ >=0 ? nHeight_ : 0; + _nFlags = nFlags; + + if (_xPeerWindow.is()) + _xPeerWindow->setPosSize( _nX, _nY, _nWidth, _nHeight, nFlags ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +::com::sun::star::awt::Rectangle PluginControl_Impl::getPosSize(void) + throw( RuntimeException ) +{ + return _xPeerWindow->getPosSize(); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::setVisible( sal_Bool bVisible ) + throw( RuntimeException ) +{ + _bVisible = bVisible; + if (_xPeerWindow.is()) + _xPeerWindow->setVisible( _bVisible && !_bInDesignMode ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::setEnable( sal_Bool bEnable ) + throw( RuntimeException ) +{ + _bEnable = bEnable; + if (_xPeerWindow.is()) + _xPeerWindow->setEnable( _bEnable ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::setFocus(void) throw( RuntimeException ) +{ + if (_xPeerWindow.is()) + _xPeerWindow->setFocus(); +} + + +//-------------------------------------------------------------------------------------------------- +void PluginControl_Impl::releasePeer() +{ + if (_xPeer.is()) + { + _xParentWindow->removeFocusListener( this ); + _xPeerWindow->dispose(); + _pSysChild = NULL; + _xPeerWindow = Reference< ::com::sun::star::awt::XWindow > (); + _xPeer = Reference< ::com::sun::star::awt::XWindowPeer > (); + getMultiplexer()->setPeer( Reference< ::com::sun::star::awt::XWindow > () ); + } +} + +//---- ::com::sun::star::awt::XControl ------------------------------------------------------------------------------------ +void PluginControl_Impl::createPeer( const Reference< ::com::sun::star::awt::XToolkit > & xToolkit, const Reference< ::com::sun::star::awt::XWindowPeer > & xParentPeer ) + throw( RuntimeException ) +{ + if (_xPeer.is()) + { + DBG_ERROR( "### Peer is already set!" ); + return; + } + + _xParentPeer = xParentPeer; + _xParentWindow = Reference< ::com::sun::star::awt::XWindow > ( xParentPeer, UNO_QUERY ); + DBG_ASSERT( _xParentWindow.is(), "### no parent peer window!" ); + + Window* pImpl = VCLUnoHelper::GetWindow( xParentPeer ); + if (pImpl) + { + _pSysChild = new SystemChildWindow( pImpl, WB_CLIPCHILDREN ); +// _pSysChild->Show(); + if (pImpl->HasFocus()) + _pSysChild->GrabFocus(); + + // get peer + _xPeer = Reference< ::com::sun::star::awt::XWindowPeer > ( _pSysChild->GetComponentInterface() ); + _xPeerWindow = Reference< ::com::sun::star::awt::XWindow > ( _xPeer, UNO_QUERY ); + // !_BOTH_ MUST BE VALID! + DBG_ASSERT( (_xPeer.is() && _xPeerWindow.is()), "### no peer!" ); + + _xParentWindow->addFocusListener( this ); + _xPeerWindow->setPosSize( _nX, _nY, _nWidth, _nHeight, _nFlags ); + _xPeerWindow->setEnable( _bEnable ); + _xPeerWindow->setVisible( _bVisible && !_bInDesignMode ); + } + else + { + DBG_ERROR( "### cannot get implementation of parent peer!" ); + } + + getMultiplexer()->setPeer( _xPeerWindow ); +} + +//---- ::com::sun::star::awt::XControl ------------------------------------------------------------------------------------ +void PluginControl_Impl::setDesignMode( sal_Bool bOn ) + throw( RuntimeException ) +{ + _bInDesignMode = bOn; + if (_xPeerWindow.is()) + _xPeerWindow->setVisible( _bVisible && !_bInDesignMode ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::addPaintListener( const Reference< ::com::sun::star::awt::XPaintListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::removePaintListener( const Reference< ::com::sun::star::awt::XPaintListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::addWindowListener( const Reference< ::com::sun::star::awt::XWindowListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::removeWindowListener( const Reference< ::com::sun::star::awt::XWindowListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::addFocusListener( const Reference< ::com::sun::star::awt::XFocusListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::removeFocusListener( const Reference< ::com::sun::star::awt::XFocusListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::addKeyListener( const Reference< ::com::sun::star::awt::XKeyListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::removeKeyListener( const Reference< ::com::sun::star::awt::XKeyListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::addMouseListener( const Reference< ::com::sun::star::awt::XMouseListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::removeMouseListener( const Reference< ::com::sun::star::awt::XMouseListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::addMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0), l ); +} + +//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- +void PluginControl_Impl::removeMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l ) + throw( RuntimeException ) +{ + getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0), l ); +} + + +//---- ::com::sun::star::awt::XView --------------------------------------------------------------------------------------- +void PluginControl_Impl::draw( sal_Int32 x, sal_Int32 y ) + throw( RuntimeException ) +{ + // has to be done by further implementation of control +} + +//---- ::com::sun::star::awt::XView --------------------------------------------------------------------------------------- +void PluginControl_Impl::setZoom( float ZoomX, float ZoomY ) + throw( RuntimeException ) +{ + // has to be done by further implementation of control +} + +//---- ::com::sun::star::lang::XEventListener ------------------------------------------------------------------------------ +void PluginControl_Impl::disposing( const ::com::sun::star::lang::EventObject & rSource ) + throw( RuntimeException ) +{ +} +//---- ::com::sun::star::awt::XFocusListener ------------------------------------------------------------------------------ +void PluginControl_Impl::focusGained( const ::com::sun::star::awt::FocusEvent & rEvt ) + throw( RuntimeException ) +{ + if (_xPeerWindow.is()) + _xPeerWindow->setFocus(); +} +//---- ::com::sun::star::awt::XFocusListener ------------------------------------------------------------------------------ +void PluginControl_Impl::focusLost( const ::com::sun::star::awt::FocusEvent & rEvt ) + throw( RuntimeException ) +{ +} + diff --git a/extensions/source/plugin/base/plmodel.cxx b/extensions/source/plugin/base/plmodel.cxx new file mode 100644 index 000000000000..702699f36ad1 --- /dev/null +++ b/extensions/source/plugin/base/plmodel.cxx @@ -0,0 +1,243 @@ +/************************************************************************* + * + * $RCSfile: plmodel.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 <plugin/model.hxx> + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif + +using namespace com::sun::star::uno; + +//================================================================================================== +Reference< XInterface > SAL_CALL PluginModel_CreateInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & ) throw( Exception ) +{ + Reference< XInterface > xService = *new PluginModel(); + return xService; +} + +Any PluginModel::queryAggregation( const Type& type ) +{ + Any aRet( ::cppu::queryInterface( type, + static_cast< ::com::sun::star::lang::XComponent* >(this), + static_cast< ::com::sun::star::io::XPersistObject* >(this ), + static_cast< ::com::sun::star::awt::XControlModel* >(this), + static_cast< ::com::sun::star::beans::XPropertySet* >(this), + static_cast< ::com::sun::star::beans::XMultiPropertySet* >(this), + static_cast< ::com::sun::star::beans::XFastPropertySet* >(this) + ) ); + return aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( type ); +} + + +// ::com::sun::star::lang::XServiceInfo +::rtl::OUString PluginModel::getImplementationName() throw( ) + +{ + return getImplementationName_Static(); +} + +// ::com::sun::star::lang::XServiceInfo +sal_Bool PluginModel::supportsService(const ::rtl::OUString& ServiceName) throw( ) +{ + Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames(); + const ::rtl::OUString * pArray = aSNL.getConstArray(); + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return sal_True; + return sal_False; +} + +// ::com::sun::star::lang::XServiceInfo +Sequence< ::rtl::OUString > PluginModel::getSupportedServiceNames(void) throw( ) +{ + return getSupportedServiceNames_Static(); +} + +// XPluginManager_Impl +Sequence< ::rtl::OUString > PluginModel::getSupportedServiceNames_Static(void) throw( ) +{ + Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS.getArray()[0] = ::rtl::OUString::createFromAscii( "com.sun.star.plugin.PluginModel" ); + return aSNS; +} + + +static char* aCreationURL = "URL"; + +static ::osl::Mutex aPropertyMutex; + +static ::com::sun::star::beans::Property aProps[] = +{ + ::com::sun::star::beans::Property( + ::rtl::OUString::createFromAscii( aCreationURL ), + -1, + ::getCppuType((const ::rtl::OUString*)0), + ::com::sun::star::beans::PropertyAttribute::BOUND ) +}; + +PluginModel::PluginModel() : + BroadcasterHelperHolder( aPropertyMutex ), + OPropertySetHelper( m_aHelper ), + OPropertyArrayHelper( aProps, 1 ) +{ +} + +PluginModel::PluginModel(const ::rtl::OUString& rURL) : + BroadcasterHelperHolder( aPropertyMutex ), + OPropertySetHelper( m_aHelper ), + OPropertyArrayHelper( aProps, 1 ), + m_aCreationURL( rURL ) +{ +} + +PluginModel::~PluginModel() +{ +} + +Reference< ::com::sun::star::beans::XPropertySetInfo > PluginModel::getPropertySetInfo() +{ + static Reference< ::com::sun::star::beans::XPropertySetInfo > aInfo = + createPropertySetInfo( *this ); + return aInfo; +} + +::cppu::IPropertyArrayHelper& PluginModel::getInfoHelper() +{ + return *this; +} + +sal_Bool PluginModel::convertFastPropertyValue( Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ) +{ + if( rValue.getValueTypeClass() == typelib_TypeClass_STRING ) + + { + rConvertedValue = rValue; + rOldValue <<= m_aCreationURL; + return sal_True; + } + return sal_False; +} + +void PluginModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, + const Any& rValue ) + throw( ::com::sun::star::lang::IllegalArgumentException ) +{ + if( rValue.getValueTypeClass() == typelib_TypeClass_STRING ) + + { + rValue >>= m_aCreationURL; + } + else + throw ::com::sun::star::lang::IllegalArgumentException(); +} + +void PluginModel::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const +{ + rValue <<= m_aCreationURL; +} + +//---- ::com::sun::star::lang::XComponent ---------------------------------------------------------------------------------- +void PluginModel::addEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) +{ + m_aDisposeListeners.push_back( l ); +} + +//---- ::com::sun::star::lang::XComponent ---------------------------------------------------------------------------------- +void PluginModel::removeEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) +{ + m_aDisposeListeners.remove( l ); +} + +//---- ::com::sun::star::lang::XComponent ---------------------------------------------------------------------------------- +void PluginModel::dispose(void) +{ + // send disposing events + ::com::sun::star::lang::EventObject aEvt; + aEvt.Source = (::cppu::OWeakObject*)this; + ::std::list< Reference< ::com::sun::star::lang::XEventListener > > aLocalListeners = m_aDisposeListeners; + for( ::std::list< Reference< ::com::sun::star::lang::XEventListener > >::iterator it = aLocalListeners.begin(); + it != aLocalListeners.end(); ++it ) + (*it)->disposing( aEvt ); + + m_aDisposeListeners.clear(); + + disposing(); +} + + +// ::com::sun::star::io::XPersistObject +::rtl::OUString PluginModel::getServiceName() +{ + return ::rtl::OUString::createFromAscii( "com.sun.star.plugin.PluginModel" ); +} + +void PluginModel::write(const Reference< ::com::sun::star::io::XObjectOutputStream > & OutStream) +{ + OutStream->writeUTF( m_aCreationURL ); +} + +void PluginModel::read(const Reference< ::com::sun::star::io::XObjectInputStream > & InStream) +{ + m_aCreationURL = InStream->readUTF(); +} diff --git a/extensions/source/plugin/base/service.cxx b/extensions/source/plugin/base/service.cxx new file mode 100644 index 000000000000..09049a332690 --- /dev/null +++ b/extensions/source/plugin/base/service.cxx @@ -0,0 +1,206 @@ +/************************************************************************* + * + * $RCSfile: service.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#if STLPORT_VERSION>=321 +#include <cstdarg> +#endif + +#include <plugin/impl.hxx> +#include <tools/debug.hxx> +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_ +#include <com/sun/star/container/XSet.hpp> +#endif +#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_ +#include <com/sun/star/registry/XRegistryKey.hpp> +#endif + +#include <uno/dispatcher.h> // declaration of generic uno interface +#include <uno/mapping.hxx> // mapping stuff + +#include <cppuhelper/factory.hxx> + +using namespace cppu; + +//================================================================================================== +void registerPluginService( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMgr ) +{ + if (! xMgr.is()) + return; + + Reference< ::com::sun::star::container::XSet > xReg( xMgr, UNO_QUERY ); + if(xReg.is()) + { + Any aAny; + Reference< ::com::sun::star::lang::XSingleServiceFactory > xF; + xF = createSingleFactory( xMgr, PluginModel::getImplementationName_Static(), + + PluginModel_CreateInstance, + PluginModel::getSupportedServiceNames_Static() ); + aAny <<= xF; + xReg->insert( aAny ); + xF = createSingleFactory( xMgr, XPluginManager_Impl::getImplementationName_Static(), + + PluginManager_CreateInstance, + XPluginManager_Impl::getSupportedServiceNames_Static() ); + aAny <<= xF; + xReg->insert( aAny ); + } +} + +extern "C" { + void SAL_CALL component_getImplementationEnvironment( + const sal_Char** ppEnvTypeName, + uno_Environment** ppEnv ) + { + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; + } + + sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pXUnoKey ) + { + if( pXUnoKey ) + { + try + { + Reference< ::com::sun::star::registry::XRegistryKey > xKey( reinterpret_cast< ::com::sun::star::registry::XRegistryKey* >( pXUnoKey ) ); + + ::rtl::OUString aImplName = ::rtl::OUString::createFromAscii( "/" ); + aImplName += XPluginManager_Impl::getImplementationName_Static(); + aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/com.sun.star.plugin.PluginManager" ); + xKey->createKey( aImplName ); + + aImplName = ::rtl::OUString::createFromAscii( "/" ); + aImplName += PluginModel::getImplementationName_Static(); + aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/com.sun.star.plugin.PluginModel" ); + xKey->createKey( aImplName ); + + return sal_True; + } + catch( ::com::sun::star::registry::InvalidRegistryException& ) + { + } + } + return sal_False; + } + + void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, + void* pXUnoSMgr, + void* pXUnoKey + ) + { + void* pRet = 0; + + ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplementationName ) ); + + if( pXUnoSMgr ) + { + Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( + reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pXUnoSMgr ) + ); + Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory; + if( aImplName.equals( XPluginManager_Impl::getImplementationName_Static() ) ) + { + xFactory = ::cppu::createSingleFactory( + xMgr, aImplName, PluginManager_CreateInstance, + XPluginManager_Impl::getSupportedServiceNames_Static() ); + } + else if( aImplName.equals( PluginModel::getImplementationName_Static() ) ) + { + xFactory = ::cppu::createSingleFactory( + xMgr, aImplName, PluginModel_CreateInstance, + PluginModel::getSupportedServiceNames_Static() ); + } + if( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + return pRet; + } + +/** special registration procedure for the staroffice player */ + void SAL_CALL exService_getSmartFactory( const sal_Char* implementationName, const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr, Reference< ::com::sun::star::lang::XSingleServiceFactory > & xFactory ) + { + ::rtl::OUString aImplementationName( ::rtl::OUString::createFromAscii(implementationName)); + + if (aImplementationName == PluginModel::getImplementationName_Static() ) + + { + xFactory = createSingleFactory( rSMgr, aImplementationName, + PluginModel_CreateInstance, + PluginModel::getSupportedServiceNames_Static() ); + } + else if (aImplementationName == XPluginManager_Impl::getImplementationName_Static() ) + + { + xFactory = createSingleFactory( rSMgr, aImplementationName, + PluginManager_CreateInstance, + XPluginManager_Impl::getSupportedServiceNames_Static() ); + } + } +} /* extern "C" */ diff --git a/extensions/source/plugin/base/xplugin.cxx b/extensions/source/plugin/base/xplugin.cxx new file mode 100644 index 000000000000..b8692b7c656f --- /dev/null +++ b/extensions/source/plugin/base/xplugin.cxx @@ -0,0 +1,888 @@ +/************************************************************************* + * + * $RCSfile: xplugin.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 <string> // workaround for SUNPRO workshop include conflicts + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LOADER_XIMPLEMENTATIONLOADER_HPP_ +#include <com/sun/star/loader/XImplementationLoader.hpp> +#endif +#ifndef _COM_SUN_STAR_LOADER_CANNOTACTIVATEFACTORYEXCEPTION_HPP_ +#include <com/sun/star/loader/CannotActivateFactoryException.hpp> +#endif + +#include <plugin/impl.hxx> +#include <tools/fsys.hxx> + +#include <tools/urlobj.hxx> +#include <tools/string.hxx> +#include <vcl/svapp.hxx> +#include <vos/timer.hxx> + +#if STLPORT_VERSION>=321 +#include <cstdarg> +#endif + +class PluginDisposer : public ::vos::OTimer +{ +private: + XPlugin_Impl* m_pPlugin; + + virtual void SAL_CALL onShot(); +public: + PluginDisposer( XPlugin_Impl* pPlugin ) : + OTimer( ::vos::TTimeValue( 2, 0 ), + ::vos::TTimeValue( 2, 0 ) ), + m_pPlugin( pPlugin ) + { start(); } + ~PluginDisposer() {} +}; + +void PluginDisposer::onShot() +{ + if( m_pPlugin ) + { + if( m_pPlugin->isDisposable() ) + { + sal_uInt32 nEvent; + Application::PostUserEvent( nEvent, LINK( m_pPlugin, XPlugin_Impl, secondLevelDispose ), (void*)m_pPlugin ); + } + } + else + release(); +} + +//================================================================================================== + +//================================================================================================== +// const Reference< ::com::sun::star::reflection::XIdlClass > & XPlugin_Impl::staticGetIdlClass() +// { +// static Reference< ::com::sun::star::reflection::XIdlClass > aClass = createStandardClass( L"Plugin", +// OWeakAggObject::getStaticIdlClass(), 6, +// ::getCppuType((const ::com::sun::star::awt::XControl*)0), +// ::getCppuType((const ::com::sun::star::awt::XControlModel*)0), +// ::getCppuType((const ::com::sun::star::awt::XWindow*)0), +// ::getCppuType((const ::com::sun::star::lang::XComponent*)0), +// ::getCppuType((const ::com::sun::star::awt::XView*)0), +// ::getCppuType((const ::com::sun::star::plugin::XPlugin*)0) ); +// return aClass; +// } + +Any XPlugin_Impl::queryInterface( const Type& type ) + +{ + return OWeakAggObject::queryInterface( type ); +} + +Any XPlugin_Impl::queryAggregation( const Type& type ) +{ + Any aRet( ::cppu::queryInterface( type, static_cast< ::com::sun::star::plugin::XPlugin* >(this) ) ); + if( ! aRet.hasValue() ) + aRet = PluginControl_Impl::queryAggregation( type ); + return aRet; +} + + +XPlugin_Impl::XPlugin_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) : + m_xSMgr( rSMgr ), + PluginControl_Impl(), + m_pPluginComm( NULL ), + m_pArgn( NULL ), + m_pArgv( NULL ), + m_nArgs( 0 ), + m_aPluginMode( NP_FULL ), + m_nProvidingState( PROVIDING_NONE ), + m_nCalledFromPlugin( 0 ), + m_pDisposer( NULL ), + m_bIsDisposed( sal_False ), + m_aEncoding( gsl_getSystemTextEncoding() ) +{ + memset( &m_aInstance, 0, sizeof( m_aInstance ) ); + memset( &m_aNPWindow, 0, sizeof( m_aNPWindow ) ); +#ifdef UNX + m_aAppContext = NULL; + m_pDisplay = NULL; + memset( &m_aWSInfo, 0, sizeof( m_aWSInfo ) ); +#endif + + m_xModel = new PluginModel(); + Reference< ::com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); + xPS->addPropertyChangeListener( ::rtl::OUString(), this ); + + ::osl::Guard< ::osl::Mutex > aGuard( PluginManager::get().getPluginMutex() ); + PluginManager::get().getPlugins().push_back( this ); +} + +void XPlugin_Impl::destroyInstance() +{ + NPSavedData* pSavedData = NULL; + + destroyStreams(); + if( getPluginComm() ) + { + getPluginComm()->NPP_Destroy( getNPPInstance(), + &pSavedData ); + getPluginComm()->decRef(); + m_pPluginComm = NULL; + } + + if( m_nArgs > 0 ) + { + for( ; m_nArgs--; ) + { + free( (void*)m_pArgn[m_nArgs] ); + free( (void*)m_pArgv[m_nArgs] ); + } + delete m_pArgn; + delete m_pArgv; + } + while( m_aPEventListeners.size() ) + { + delete *m_aPEventListeners.begin(); + m_aPEventListeners.pop_front(); + } +} + +XPlugin_Impl::~XPlugin_Impl() +{ + destroyInstance(); +} + +void XPlugin_Impl::checkListeners( const char* normalizedURL ) +{ + if( ! normalizedURL ) + return; + + ::std::list<PluginEventListener*>::iterator iter; + for( iter = m_aPEventListeners.begin(); + iter != m_aPEventListeners.end(); + ++iter ) + { + if( ! strcmp( normalizedURL, (*iter)->getURL() ) || + ! strcmp( normalizedURL, (*iter)->getNormalizedURL() ) ) + { + (*iter)->disposing( ::com::sun::star::lang::EventObject() ); + delete *iter; + m_aPEventListeners.remove( *iter ); + return; + } + } +} + +IMPL_LINK( XPlugin_Impl, secondLevelDispose, XPlugin_Impl*, pThis ) +{ + // may have become undisposable between PostUserEvent and here + // or may have disposed and receive a second UserEvent + ::std::list<XPlugin_Impl*>& rList = PluginManager::get().getPlugins(); + ::std::list<XPlugin_Impl*>::iterator iter; + + { + ::osl::Guard< ::osl::Mutex > aGuard( PluginManager::get().getPluginMutex() ); + for( iter = rList.begin(); iter != rList.end(); ++iter ) + { + if( *iter == this ) + break; + } + if( iter == rList.end() || ! isDisposable() ) + return 0; + } + + if (m_pDisposer) + { + m_pDisposer->release(); + m_pDisposer = NULL; + } + + Reference< ::com::sun::star::plugin::XPlugin > xProtection( this ); + Reference< ::com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); + xPS->removePropertyChangeListener( ::rtl::OUString(), this ); + { + ::osl::Guard< ::osl::Mutex > aGuard( PluginManager::get().getPluginMutex() ); + rList.remove( this ); + } + m_aNPWindow.window = NULL; +#ifndef UNX + // acrobat does an unconditional XtParent on the windows widget + getPluginComm()-> + NPP_SetWindow( getNPPInstance(), &m_aNPWindow ); +#endif + destroyInstance(); + PluginControl_Impl::dispose(); + return 0; +} + +void XPlugin_Impl::dispose() +{ + if (m_bIsDisposed || !getPluginComm()) + return; + m_bIsDisposed = sal_True; + + if( isDisposable() ) + secondLevelDispose( this ); + else + { + m_pDisposer = new PluginDisposer( this ); + m_pDisposer->acquire(); + } +} + +void XPlugin_Impl::initInstance( const ::com::sun::star::plugin::PluginDescription& rDescription, + const Sequence< ::rtl::OUString >& argn, + const Sequence< ::rtl::OUString >& argv, + sal_Int16 mode ) +{ + m_aDescription = rDescription; + + // #69333# special for pdf + m_aPluginMode = mode; + if( m_aDescription.Mimetype.compareToAscii( "application/pdf" ) ) + m_aPluginMode = ::com::sun::star::plugin::PluginMode::FULL; + + m_nArgs = argn.getLength(); + m_pArgn = new const char*[m_nArgs]; + m_pArgv = new const char*[m_nArgs]; + const ::rtl::OUString* pUArgn = argn.getConstArray(); + const ::rtl::OUString* pUArgv = argv.getConstArray(); + for( int i = 0; i < m_nArgs; i++ ) + { + m_pArgn[i] = strdup( + ::rtl::OUStringToOString( pUArgn[i], m_aEncoding ).getStr() + ); + m_pArgv[i] = strdup( + ::rtl::OUStringToOString( pUArgv[i], m_aEncoding ).getStr() + ); + } +} + +void XPlugin_Impl::modelChanged() +{ + m_nProvidingState = PROVIDING_MODEL_UPDATE; + + // empty description is only set when created by createPluginFromURL + if( m_aDescription.Mimetype.getLength() ) + destroyInstance(); + + Reference< ::com::sun::star::plugin::XPluginManager > xPMgr( m_xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.plugin.PluginManager" ) ), UNO_QUERY ); + if( !xPMgr.is() ) + { + m_nProvidingState = PROVIDING_NONE; + return; + } + + int nDescr = -1; + Sequence< ::com::sun::star::plugin::PluginDescription > aDescrs = xPMgr->getPluginDescriptions(); + const ::com::sun::star::plugin::PluginDescription* pDescrs = aDescrs.getConstArray(); + + ::rtl::OUString aURL = getCreationURL(); + int nPos = aURL.lastIndexOf( (sal_Unicode)'.' ); + ::rtl::OUString aExt = aURL.copy( nPos ).toLowerCase(); + if( nPos != -1 ) + { + for( int i = 0; i < aDescrs.getLength(); i++ ) + { + ::rtl::OUString aThisExt = pDescrs[ i ].Extension.toLowerCase(); + if( aThisExt.indexOf( aExt ) != -1 ) + { + nDescr = i; + break; + } + } + } + + if( nDescr != -1 ) + { + INetURLObject aURL; + aURL.SetSmartProtocol( INET_PROT_FILE ); + aURL.SetSmartURL( ::rtl::OUStringToOString( getCreationURL(), m_aEncoding ) ); + + Reference< ::com::sun::star::lang::XMultiServiceFactory > xFact( m_xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.DataSourceFactory" ) ), UNO_QUERY ); + if ( xFact.is() ) + { + Sequence < Any > aArgs(1); + aArgs.getArray()[0] <<= ::rtl::OUString( aURL.GetMainURL() ); + ::rtl::OUString aProt( INetURLObject::GetScheme( aURL.GetProtocol() ) ); + Reference< ::com::sun::star::io::XActiveDataSource > xSource( xFact->createInstanceWithArguments( aProt, aArgs ), UNO_QUERY ); + if ( xSource.is() ) + { + m_aDescription = pDescrs[ nDescr ]; + provideNewStream( m_aDescription.Mimetype, + xSource, + getRefererURL(), + 0, 0, sal_False ); + } + } + } + m_nProvidingState = PROVIDING_NONE; +} + +::rtl::OUString XPlugin_Impl::getCreationURL() +{ + ::rtl::OUString aRet; + Reference< ::com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); + if( xPS.is() ) + { + Any aValue = xPS->getPropertyValue( ::rtl::OUString::createFromAscii( "URL" ) ); + aValue >>= aRet; + } + return aRet; +} + + +sal_Bool XPlugin_Impl::setModel( const Reference< ::com::sun::star::awt::XControlModel > & Model ) + throw( RuntimeException ) +{ + Reference< ::com::sun::star::beans::XPropertySet > xPS( Model, UNO_QUERY ); + if( ! xPS.is() ) + return sal_False; + + if( getCreationURL().getLength() ) + { + m_xModel = Model; + modelChanged(); + xPS->addPropertyChangeListener( ::rtl::OUString(), this ); + return sal_True; + } + return sal_False; +} + +void XPlugin_Impl::createPeer( const Reference< ::com::sun::star::awt::XToolkit > & xToolkit, const Reference< ::com::sun::star::awt::XWindowPeer > & Parent ) + throw( RuntimeException ) +{ + if( ! _xPeer.is() ) + { + if( ! Parent.is() ) + throw RuntimeException(); + PluginControl_Impl::createPeer( xToolkit, Parent ); + } +} + +void XPlugin_Impl::loadPlugin() +{ + ::std::list<PluginComm*>::iterator iter; + for( iter = PluginManager::get().getPluginComms().begin(); + iter != PluginManager::get().getPluginComms().end(); ++iter ) + { + if( ::rtl::OStringToOUString( (*iter)->getLibName(), m_aEncoding ) == m_aDescription.PluginName ) + { + setPluginComm( *iter ); + break; + } + } + const SystemEnvData* pEnvData = getSysChildSysData(); +#ifdef UNX + XSync( (Display*)pEnvData->pDisplay, False ); +#endif + if( ! getPluginComm() ) + { +#ifdef UNX + m_pDisplay = (Display*)pEnvData->pDisplay; + m_aAppContext = (XtAppContext)pEnvData->pAppContext; + // need a new PluginComm + PluginComm* pComm = new UnxPluginComm( ::rtl::OUStringToOString( m_aDescription.PluginName, gsl_getSystemTextEncoding() ) ); +#elif (defined WNT || defined OS2) + PluginComm* pComm = new PluginComm_Impl( m_aDescription.Mimetype, + m_aDescription.PluginName, + (HWND)pEnvData->hWnd ); +#endif + setPluginComm( pComm ); + } + + NPError aError = getPluginComm()-> + NPP_New( (char*)::rtl::OUStringToOString( m_aDescription.Mimetype, + m_aEncoding).getStr(), + getNPPInstance(), + m_aPluginMode, + m_nArgs, + (char**)(m_nArgs ? m_pArgn : NULL), + (char**)(m_nArgs ? m_pArgv : NULL), + NULL ); + +#ifdef UNX + XSync( (Display*)pEnvData->pDisplay, False ); +#endif +#ifdef UNX + m_aNPWindow.window = (void*)pEnvData->aWindow; + m_aNPWindow.ws_info = &m_aWSInfo; + + m_aWSInfo.type = NP_SETWINDOW; + m_aWSInfo.display = (Display*)pEnvData->pDisplay; + m_aWSInfo.visual = (Visual*)pEnvData->pVisual; + m_aWSInfo.colormap = (Colormap)pEnvData->aColormap; + m_aWSInfo.depth = pEnvData->nDepth; +#else + m_aNPWindow.window = (void*)pEnvData->hWnd; +#endif + ::com::sun::star::awt::Rectangle aPosSize = getPosSize(); + + m_aNPWindow.clipRect.top = 0; + m_aNPWindow.clipRect.left = 0; + m_aNPWindow.clipRect.bottom = 0; + m_aNPWindow.clipRect.right = 0; + m_aNPWindow.type = NPWindowTypeWindow; + + m_aNPWindow.x = aPosSize.X; + m_aNPWindow.y = aPosSize.Y; + m_aNPWindow.width = aPosSize.Width ? aPosSize.Width : 600; + m_aNPWindow.height = aPosSize.Height ? aPosSize.Height : 600; + + aError = getPluginComm()-> + NPP_SetWindow( getNPPInstance(), &m_aNPWindow ); +} + +void XPlugin_Impl::destroyStreams() +{ + // streams remove themselves from this list when deleted + while( m_aOutputStreams.size() ) + delete *m_aOutputStreams.begin(); + + // input streams are XOutputStreams, they cannot be simply deleted + ::std::list<PluginInputStream*> aLocalList( m_aInputStreams ); + for( ::std::list<PluginInputStream*>::iterator it = aLocalList.begin(); + it != aLocalList.end(); ++it ) + (*it)->setMode( -1 ); +} + +PluginStream* XPlugin_Impl::getStreamFromNPStream( NPStream* stream ) +{ + ::std::list<PluginInputStream*>::iterator iter; + for( iter = m_aInputStreams.begin(); iter != m_aInputStreams.end(); ++iter ) + if( (*iter)->getStream() == stream ) + return *iter; + + ::std::list<PluginOutputStream*>::iterator iter2; + for( iter2 = m_aOutputStreams.begin(); iter2 != m_aOutputStreams.end(); ++iter2 ) + if( (*iter2)->getStream() == stream ) + return *iter2; + + return NULL; +} + +sal_Bool XPlugin_Impl::provideNewStream(const ::rtl::OUString& mimetype, + const Reference< ::com::sun::star::io::XActiveDataSource > & stream, + const ::rtl::OUString& url, sal_Int32 length, + sal_Int32 lastmodified, sal_Bool isfile) + +{ + if( m_nProvidingState == PROVIDING_NONE ) + { + m_nProvidingState = PROVIDING_NOW; + Any aAny; + aAny <<= url; + Reference< ::com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); + xPS->setPropertyValue( ::rtl::OUString::createFromAscii( "URL" ), aAny ); + } + + m_nProvidingState = PROVIDING_NOW; + if( ! m_pPluginComm ) + loadPlugin(); + + ::rtl::OString aMIME; + if( mimetype.len() ) + aMIME = ::rtl::OUStringToOString( mimetype, m_aEncoding ); + else + // Notnagel + aMIME = ::rtl::OUStringToOString( m_aDescription.Mimetype, m_aEncoding ); + + ::rtl::OString aURL = ::rtl::OUStringToOString( url, m_aEncoding ); + + // check wether there is a notifylistener for this stream + // this means that the strema is created from the plugin + // via NPN_GetURLNotify or NPN_PostURLNotify + ::std::list<PluginEventListener*>::iterator iter; + for( iter = m_aPEventListeners.begin(); + iter != m_aPEventListeners.end(); + ++iter ) + { + if( (*iter)->getNormalizedURL() == aURL ) + { + aURL = (*iter)->getURL(); + break; + } + } + + if( iter == m_aPEventListeners.end() ) + { + // e.g. plugger.so does not like file:/// + if( ! aURL.compareTo( "file://", 7 ) ) + { + INetURLObject aPath( url ); + aURL = ::rtl::OUStringToOString( aPath.PathToFileName(), m_aEncoding ); + } + } + + PluginInputStream* pStream = new PluginInputStream( this, aURL.getStr(), + length, lastmodified ); + Reference< ::com::sun::star::io::XOutputStream > xNewStream( pStream ); + + if( iter != m_aPEventListeners.end() ) + pStream->getStream()->notifyData = (*iter)->getNotifyData(); + + uint16 stype = 0; + + // sal_False in the following statement should logically be isfile + // but e.g. the acrobat reader plugin does not WANT a file + // NP_ASFILE or NP_ASFILEONLY if the new stream is seekable + // the reason for this behaviour is unknown +#ifdef DEBUG + fprintf( stderr, "new stream \"%s\" of MIMEType \"%s\"\nfor plugin \"%s\"\n", aURL.getStr(), aMIME.getStr(), getPluginComm()->getLibName().getStr() ); + +#endif + if( ! m_pPluginComm->NPP_NewStream( &m_aInstance, (char*)aMIME.getStr(), + pStream->getStream(), sal_False, + &stype ) ) + { + getPluginComm()->NPP_SetWindow( getNPPInstance(), &m_aNPWindow ); +#ifdef DEBUG + char* pType; + switch( stype ) + { + case NP_NORMAL: pType = "NP_NORMAL";break; + case NP_SEEK: pType = "NP_SEEK";break; + case NP_ASFILE: pType = "NP_ASFILE";break; + case NP_ASFILEONLY: pType = "NP_ASFILEONLY";break; + default: pType = "unknown!!!"; + } + fprintf( stderr, "Plugin wants it in Mode %s\n", pType ); +#endif + if( isfile && stype == NP_ASFILEONLY ) + { + m_pPluginComm-> + NPP_StreamAsFile( &m_aInstance, + pStream->getStream(), + pStream->getStream()->url ); + m_nProvidingState = PROVIDING_NONE; + return sal_True; + } + + if( ! stream.is() ) + { + m_pPluginComm-> + NPP_DestroyStream( &m_aInstance, + pStream->getStream(), + NPRES_NETWORK_ERR ); + m_nProvidingState = PROVIDING_NONE; + throw RuntimeException(); + } + pStream->setMode( stype ); + Reference< ::com::sun::star::io::XConnectable > xConnectable( stream, UNO_QUERY ); + pStream->setPredecessor( xConnectable ); + if( xConnectable.is() ) + { + xConnectable->setSuccessor( static_cast< ::com::sun::star::io::XConnectable* >(pStream) ); + while( xConnectable->getPredecessor().is() ) + xConnectable = xConnectable->getPredecessor(); + } + stream->setOutputStream( xNewStream ); + pStream->setSource( stream ); + Reference< ::com::sun::star::io::XActiveDataControl > xController; + if( xConnectable.is() ) + xController = Reference< ::com::sun::star::io::XActiveDataControl >( xConnectable, UNO_QUERY ); + else + xController = Reference< ::com::sun::star::io::XActiveDataControl >( stream, UNO_QUERY ); + + if( xController.is() ) + xController->start(); + } + + m_nProvidingState = PROVIDING_NONE; + + return sal_False; +} + +void XPlugin_Impl::disposing( const ::com::sun::star::lang::EventObject& rSource ) +{ +} + +void XPlugin_Impl::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvent ) +{ + if( ! rEvent.PropertyName.compareToAscii( "URL" ) ) + { + ::rtl::OUString aStr; + rEvent.NewValue >>= aStr; + if( m_nProvidingState == PROVIDING_NONE ) + { + if( aStr != m_aURL ) + { + m_aURL = aStr; + modelChanged(); + } + } + } +} + +void XPlugin_Impl::setPluginContext( const Reference< ::com::sun::star::plugin::XPluginContext > & rContext ) +{ + m_rBrowserContext = rContext; +} + +void XPlugin_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) + throw( RuntimeException ) +{ +#ifdef DEBUG + fprintf( stderr, "XPlugin_Impl::setPosSize( %d, %d, %d, %d, %d )\n", + nX_, nY_, nWidth_, nHeight_, nFlags ); +#endif + + PluginControl_Impl::setPosSize(nX_, nY_, nWidth_, nHeight_, nFlags); + m_aNPWindow.x = nX_; + m_aNPWindow.y = nY_; + m_aNPWindow.width = nWidth_; + m_aNPWindow.height = nHeight_; + + if(getPluginComm()) + getPluginComm()->NPP_SetWindow( getNPPInstance(), &m_aNPWindow ); +} + +PluginStream::PluginStream( XPlugin_Impl* pPlugin, + const char* url, sal_uInt32 len, sal_uInt32 lastmod ) : + m_pPlugin( pPlugin ) +{ + memset( &m_aNPStream, 0, sizeof( m_aNPStream ) ); + m_aNPStream.url = strdup( url ); + m_aNPStream.end = len; + m_aNPStream.lastmodified = lastmod; +} + +PluginStream::~PluginStream() +{ + if( m_pPlugin && m_pPlugin->getPluginComm() ) + { + m_pPlugin->getPluginComm()->NPP_DestroyStream( m_pPlugin->getNPPInstance(), + &m_aNPStream, NPRES_DONE ); + m_pPlugin->checkListeners( m_aNPStream.url ); + m_pPlugin->getPluginComm()-> + NPP_SetWindow( m_pPlugin->getNPPInstance(), + m_pPlugin->getNPWindow()); + } + ::free( (void*)m_aNPStream.url ); +} + +PluginInputStream::PluginInputStream( XPlugin_Impl* pPlugin, + const char* url, + sal_uInt32 len, + sal_uInt32 lastmod ) : + PluginStream( pPlugin, url, len, lastmod ), + m_nMode( NP_NORMAL ), + m_nWritePos( 0 ) +{ + m_pPlugin->getInputStreams().push_back( this ); + DirEntry aEntry; + aEntry = aEntry.TempName(); + + // set correct extension, some plugins need that + DirEntry aName( String( m_aNPStream.url, m_pPlugin->getTextEncoding() ) ); + String aExtension = aName.GetExtension(); + if( aExtension.Len() ) + aEntry.SetExtension( aExtension ); + m_aFileStream.Open( aEntry.GetFull(), STREAM_READ | STREAM_WRITE ); + if( ! m_aFileStream.IsOpen() ) + { + // #74808# might be that the extension scrambled the whole filename + aEntry = aEntry.TempName(); + m_aFileStream.Open( aEntry.GetFull(), STREAM_READ | STREAM_WRITE ); + } +} + +PluginInputStream::~PluginInputStream() +{ + String aFile( m_aFileStream.GetFileName() ); + m_aFileStream.Close(); + if( m_pPlugin ) + { + ByteString aFileName( aFile, m_pPlugin->getTextEncoding() ); + if( m_pPlugin->getPluginComm() && m_nMode != -1 ) + // mode -1 means either an error occured, + // or the plugin is already disposing + { + m_pPlugin->getPluginComm()->addFileToDelete( aFile ); + if( m_nMode == NP_ASFILE ) + { + m_pPlugin->getPluginComm()-> + NPP_StreamAsFile( m_pPlugin->getNPPInstance(), + &m_aNPStream, + aFileName.GetBuffer() ); + } + m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin->getNPPInstance(), m_pPlugin->getNPWindow()); + m_pPlugin->getInputStreams().remove( this ); + } + else + DirEntry( m_aFileStream.GetFileName() ).Kill(); + } + else + DirEntry( m_aFileStream.GetFileName() ).Kill(); +} + +PluginStreamType PluginInputStream::getStreamType() +{ + return InputStream; +} + +void PluginInputStream::setMode( sal_uInt32 nMode ) +{ + m_nMode = nMode; + + // invalidation by plugin + if( m_nMode == -1 && m_pPlugin ) + { + m_pPlugin->getInputStreams().remove( this ); + m_pPlugin = NULL; + } +} + +void PluginInputStream::writeBytes( const Sequence<sal_Int8>& Buffer ) +{ + if( m_nMode == -1 ) + return; + + m_aFileStream.Seek( STREAM_SEEK_TO_END ); + m_aFileStream.Write( Buffer.getConstArray(), Buffer.getLength() ); + + int nPos = m_aFileStream.Tell(); + int nBytes = 0; + while( m_nMode != NP_SEEK && m_nMode != NP_ASFILEONLY && + ( nBytes = m_pPlugin->getPluginComm()-> + NPP_WriteReady( m_pPlugin->getNPPInstance(), + &m_aNPStream ) ) > 0 && + m_nWritePos < nPos ) + { + nBytes = nBytes > nPos - m_nWritePos ? nPos - m_nWritePos : nBytes; + + char* pBuffer = new char[ nBytes ]; + m_aFileStream.Seek( m_nWritePos ); + nBytes = m_aFileStream.Read( pBuffer, nBytes ); + + int nBytesRead = 0; + try + { + nBytesRead = m_pPlugin->getPluginComm()-> + NPP_Write( m_pPlugin->getNPPInstance(), + &m_aNPStream, + m_nWritePos, + nBytes, + pBuffer ); + delete pBuffer; + } + catch( ... ) + { + delete pBuffer; + return; + } + + if( nBytesRead < 0 ) + { + m_nMode = -1; + return; + } + + m_nWritePos += nBytesRead; + } + + m_pPlugin->getPluginComm()-> + NPP_SetWindow( m_pPlugin->getNPPInstance(), + m_pPlugin->getNPWindow()); +} + +void PluginInputStream::closeOutput() +{ + flush(); + m_xSource = Reference< ::com::sun::star::io::XActiveDataSource >(); +} + +sal_uInt32 PluginInputStream::read( sal_uInt32 offset, sal_Int8* buffer, sal_uInt32 size ) +{ + if( m_nMode != NP_SEEK ) + return 0; + + m_aFileStream.Seek( offset ); + int nBytes = m_aFileStream.Read( buffer, size ); + + return nBytes; +} + +void PluginInputStream::flush(void) +{ +} + +PluginOutputStream::PluginOutputStream( XPlugin_Impl* pPlugin, + const char* url, + sal_uInt32 len, + sal_uInt32 lastmod ) : + PluginStream( pPlugin, url, len, lastmod ), + m_xStream( pPlugin->getServiceManager()->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.io.DataOutputStream" ) ), UNO_QUERY ) +{ + m_pPlugin->getOutputStreams().push_back( this ); +} + +PluginOutputStream::~PluginOutputStream() +{ + m_pPlugin->getOutputStreams().remove( this ); +} + +PluginStreamType PluginOutputStream::getStreamType() +{ + return OutputStream; +} + diff --git a/extensions/source/plugin/inc/plugin/impl.hxx b/extensions/source/plugin/inc/plugin/impl.hxx new file mode 100644 index 000000000000..8027c0ec9e2e --- /dev/null +++ b/extensions/source/plugin/inc/plugin/impl.hxx @@ -0,0 +1,478 @@ +/************************************************************************* + * + * $RCSfile: impl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 __PLUGIN_SOURCE_MGR_IMPL_HXX +#define __PLUGIN_SOURCE_MGR_IMPL_HXX + +#ifdef SOLARIS +#include <limits> +#endif + +#include <cppuhelper/weak.hxx> + +#ifndef _COM_SUN_STAR_AWT_KEY_HPP_ +#include <com/sun/star/awt/Key.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_KEYFUNCTION_HPP_ +#include <com/sun/star/awt/KeyFunction.hpp> +#endif +#ifndef _COM_SUN_STAR_PLUGIN_PLUGINMODE_HPP_ +#include <com/sun/star/plugin/PluginMode.hpp> +#endif +#ifndef _COM_SUN_STAR_PLUGIN_PLUGINDESCRIPTION_HPP_ +#include <com/sun/star/plugin/PluginDescription.hpp> +#endif +#ifndef _COM_SUN_STAR_PLUGIN_PLUGINEXCEPTION_HPP_ +#include <com/sun/star/plugin/PluginException.hpp> +#endif +#ifndef _COM_SUN_STAR_PLUGIN_PLUGINVARIABLE_HPP_ +#include <com/sun/star/plugin/PluginVariable.hpp> +#endif +#ifndef _COM_SUN_STAR_PLUGIN_XPLUGIN_HPP_ +#include <com/sun/star/plugin/XPlugin.hpp> +#endif +#ifndef _COM_SUN_STAR_PLUGIN_XPLUGINMANAGER_HPP_ +#include <com/sun/star/plugin/XPluginManager.hpp> +#endif +#ifndef _COM_SUN_STAR_PLUGIN_XPLUGINCONTEXT_HPP_ +#include <com/sun/star/plugin/XPluginContext.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XCONNECTABLE_HPP_ +#include <com/sun/star/io/XConnectable.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_ +#include <com/sun/star/io/XOutputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XDATAOUTPUTSTREAM_HPP_ +#include <com/sun/star/io/XDataOutputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XACTIVEDATACONTROL_HPP_ +#include <com/sun/star/io/XActiveDataControl.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XDATAINPUTSTREAM_HPP_ +#include <com/sun/star/io/XDataInputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XMARKABLESTREAM_HPP_ +#include <com/sun/star/io/XMarkableStream.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ +#include <com/sun/star/io/XInputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XSTREAMLISTENER_HPP_ +#include <com/sun/star/io/XStreamListener.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_ +#include <com/sun/star/io/XActiveDataSink.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ +#include <com/sun/star/io/XActiveDataSource.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_ +#include <com/sun/star/lang/XServiceName.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_GRADIENTSTYLE_HPP_ +#include <com/sun/star/awt/GradientStyle.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_RASTEROPERATION_HPP_ +#include <com/sun/star/awt/RasterOperation.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_GRADIENT_HPP_ +#include <com/sun/star/awt/Gradient.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XGRAPHICS_HPP_ +#include <com/sun/star/awt/XGraphics.hpp> +#endif + +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase1.hxx> + +#ifdef WNT +#include <plugin/win/sysplug.hxx> +#else +#include <list> +#endif + +#ifdef OS2 +#include <plugin/os2/sysplug.hxx> +#endif + +#ifdef UNX +#include <plugin/unx/sysplug.hxx> +#endif + +#include <vcl/sysdata.hxx> +#include <vcl/syschild.hxx> +#include <plugin/plctrl.hxx> +#include <plugin/model.hxx> +#include <tools/link.hxx> +#include <tools/stream.hxx> + +using namespace com::sun::star::uno; + +#define PROVIDING_NONE 0 +#define PROVIDING_NOW 1 +#define PROVIDING_MODEL_UPDATE 2 + +class PluginStream; +class PluginInputStream; +class PluginOutputStream; +class XPlugin_Impl; +class PluginDisposer; +class PluginEventListener; + +class XPlugin_Impl : public ::com::sun::star::plugin::XPlugin, + public PluginControl_Impl, + public ::com::sun::star::beans::XPropertyChangeListener +{ +private: + Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + Reference< ::com::sun::star::plugin::XPluginContext > m_rBrowserContext; + + PluginComm* m_pPluginComm; + NPP_t m_aInstance; + NPWindow m_aNPWindow; + rtl_TextEncoding m_aEncoding; +#ifdef UNX + NPSetWindowCallbackStruct m_aWSInfo; + Display* m_pDisplay; + XtAppContext m_aAppContext; +#endif + + const char** m_pArgv; + const char** m_pArgn; + int m_nArgs; + + Reference< ::com::sun::star::awt::XControlModel > m_xModel; + + ::com::sun::star::plugin::PluginDescription m_aDescription; + sal_Int16 m_aPluginMode; + + int m_nProvidingState; + int m_nCalledFromPlugin; + PluginDisposer* m_pDisposer; + + ::std::list<PluginInputStream*> m_aInputStreams; + ::std::list<PluginOutputStream*> m_aOutputStreams; + ::std::list<PluginEventListener*> m_aPEventListeners; + ::rtl::OUString m_aURL; + + sal_Bool m_bIsDisposed; + + void init( const ::com::sun::star::plugin::PluginDescription& rDescription ); + void loadPlugin(); + void destroyInstance(); + void modelChanged(); + +public: + XPlugin_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ); + virtual ~XPlugin_Impl(); + + void destroyStreams(); + + ::std::list<PluginInputStream*>& getInputStreams() { return m_aInputStreams; } + ::std::list<PluginOutputStream*>& getOutputStreams() { return m_aOutputStreams; } + PluginComm* getPluginComm() { return m_pPluginComm; } + void setPluginComm( PluginComm* comm ) + { + if( ! m_pPluginComm ) + { + m_pPluginComm = comm; + m_pPluginComm->addRef(); + } + } +#ifdef UNX + Display* getAppDisplay() { return m_pDisplay; } + XtAppContext getAppContext() { return m_aAppContext; } +#endif + Reference< ::com::sun::star::lang::XMultiServiceFactory > getServiceManager() { return m_xSMgr; } + rtl_TextEncoding getTextEncoding() { return m_aEncoding; } + NPP getNPPInstance() { return &m_aInstance; } + NPWindow* getNPWindow() { return &m_aNPWindow; } + + void enterPluginCallback() { m_nCalledFromPlugin++; } + void leavePluginCallback() { m_nCalledFromPlugin--; } + sal_Bool isDisposable() { return m_nCalledFromPlugin < 1 ? sal_True : sal_False; } + DECL_LINK( secondLevelDispose, XPlugin_Impl* ); + + void addPluginEventListener( PluginEventListener* pListener ) + { m_aPEventListeners.push_back( pListener ); } + void checkListeners( const char* normalizedURL ); + + void initInstance( + const ::com::sun::star::plugin::PluginDescription& rDescription, + const Sequence< ::rtl::OUString >& argn, + const Sequence< ::rtl::OUString >& argv, + sal_Int16 mode ); + + const ::rtl::OUString& getRefererURL() { return m_aURL; } + ::rtl::OUString getCreationURL(); + + PluginStream* getStreamFromNPStream( NPStream* ); + + const SystemEnvData* getSysChildSysData() + { return _pSysChild->GetSystemData(); } + + const Reference< ::com::sun::star::plugin::XPluginContext > & getPluginContext() const + { return m_rBrowserContext; } + void setPluginContext( const Reference< ::com::sun::star::plugin::XPluginContext > & ); + + void secondLevelDispose(); + +// static const Reference< ::com::sun::star::reflection::XIdlClass > & staticGetIdlClass(); + + // XInterface + virtual Any SAL_CALL queryInterface( const Type& ); + virtual void SAL_CALL acquire() { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() { OWeakAggObject::release(); } + + // OWeakAggObject + virtual Any SAL_CALL queryAggregation( const Type& ); + + // PluginContol_Impl + virtual void SAL_CALL dispose(); + virtual void SAL_CALL createPeer( const Reference< ::com::sun::star::awt::XToolkit > & xToolkit, const Reference< ::com::sun::star::awt::XWindowPeer > & Parent) throw( RuntimeException ); + + virtual sal_Bool SAL_CALL setModel( const Reference< ::com::sun::star::awt::XControlModel > & Model ) throw( RuntimeException ); + virtual Reference< ::com::sun::star::awt::XControlModel > SAL_CALL getModel(void) const throw( RuntimeException ) + { return m_xModel; } + + virtual void SAL_CALL setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) throw( RuntimeException ); + + // ::com::sun::star::plugin::XPlugin + virtual sal_Bool SAL_CALL provideNewStream(const ::rtl::OUString& mimetype, const Reference< ::com::sun::star::io::XActiveDataSource > & stream, const ::rtl::OUString& url, sal_Int32 length, sal_Int32 lastmodified, sal_Bool isfile); + + // ::com::sun::star::beans::XPropertyChangeListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rSource ); + virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvent ); +}; + +class PluginManager +{ +private: + Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + ::std::list<PluginComm*> m_aPluginComms; + ::std::list<XPlugin_Impl*> m_aAllPlugins; + ::osl::Mutex m_aPluginMutex; + + static PluginManager* pManager; + + PluginManager(); + ~PluginManager(); +public: + + static PluginManager& get(); + static void setServiceFactory( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory ); + static const Sequence< ::rtl::OUString >& getAdditionalSearchPaths(); + + ::std::list<PluginComm*>& getPluginComms() { return m_aPluginComms; } + ::std::list<XPlugin_Impl*>& getPlugins() { return m_aAllPlugins; } + ::osl::Mutex& getPluginMutex() { return m_aPluginMutex; } +}; + +class XPluginManager_Impl : + public ::cppu::WeakAggImplHelper1< ::com::sun::star::plugin::XPluginManager > +{ + Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMgr; +public: + XPluginManager_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & ); + virtual ~XPluginManager_Impl(); + + static XPlugin_Impl* getXPluginFromNPP( NPP ); + static XPlugin_Impl* getFirstXPlugin(); + static XPlugin_Impl* getPluginImplementation( const Reference< ::com::sun::star::plugin::XPlugin >& plugin ); + + virtual Reference< ::com::sun::star::plugin::XPluginContext > SAL_CALL createPluginContext(); + + // has to be implemented per system + virtual Sequence< ::com::sun::star::plugin::PluginDescription > SAL_CALL getPluginDescriptions(void) throw( ); + + virtual Reference< ::com::sun::star::plugin::XPlugin > SAL_CALL createPlugin( const Reference< ::com::sun::star::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< ::rtl::OUString >& argn, const Sequence< ::rtl::OUString >& argv, const ::com::sun::star::plugin::PluginDescription& plugintype) throw( RuntimeException,::com::sun::star::plugin::PluginException ); + + virtual Reference< ::com::sun::star::plugin::XPlugin > SAL_CALL createPluginFromURL( const Reference< ::com::sun::star::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< ::rtl::OUString >& argn, const Sequence< ::rtl::OUString >& argv, const Reference< ::com::sun::star::awt::XToolkit > & toolkit, const Reference< ::com::sun::star::awt::XWindowPeer > & parent, const ::rtl::OUString& url ); + + virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw( ); + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(); + + Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ); + static Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ); + static ::rtl::OUString getImplementationName_Static() throw( ) + { + /** the soplayer uses this name in its source! maybe not after 5.2 */ + return ::rtl::OUString::createFromAscii( "com.sun.star.extensions.PluginManager" ); + } +}; +Reference< XInterface > SAL_CALL PluginManager_CreateInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & ) throw( Exception ); + +enum PluginStreamType { InputStream, OutputStream }; + +class PluginStream +{ +protected: + XPlugin_Impl* m_pPlugin; + NPStream m_aNPStream; +public: + PluginStream( XPlugin_Impl* pPlugin, + const char* url, sal_uInt32 len, sal_uInt32 lastmod ); + virtual ~PluginStream(); + + NPStream* getStream() { return &m_aNPStream; } + XPlugin_Impl* getPlugin() { return m_pPlugin; } + + virtual PluginStreamType getStreamType() = 0; +}; + +class PluginInputStream : + public PluginStream, + public ::cppu::WeakAggImplHelper2< + ::com::sun::star::io::XOutputStream, + ::com::sun::star::io::XConnectable + > +{ +private: + UINT32 m_nMode; + UINT32 m_nWritePos; + + Reference< ::com::sun::star::io::XActiveDataSource > m_xSource; + // hold a reference on input until closeOutput is called + + Reference< ::com::sun::star::io::XConnectable > m_xPredecessor; + Reference< ::com::sun::star::io::XConnectable > m_xSuccessor; + + SvFileStream m_aFileStream; +public: + PluginInputStream( XPlugin_Impl* pPlugin, + const char* url, UINT32 len, UINT32 lastmod ); + + PluginInputStream() : PluginStream( NULL, NULL, 0, 0 ) {} + + virtual ~PluginInputStream(); + + virtual PluginStreamType getStreamType(); + + void setMode( UINT32 nMode ); + UINT32 read( UINT32 offset, sal_Int8* buffer, UINT32 size ); + void setSource( const Reference< ::com::sun::star::io::XActiveDataSource >& xSource ) { m_xSource = xSource; } + + // XOutputStream + virtual void SAL_CALL writeBytes( const Sequence<sal_Int8>& ); + virtual void SAL_CALL flush(); + virtual void SAL_CALL closeOutput(); + + // XConnectable + virtual void SAL_CALL setPredecessor( const Reference< ::com::sun::star::io::XConnectable >& xPredecessor ) + { m_xPredecessor = xPredecessor; } + virtual Reference< ::com::sun::star::io::XConnectable > SAL_CALL getPredecessor() + { return m_xPredecessor; } + + virtual void SAL_CALL setSuccessor( const Reference< ::com::sun::star::io::XConnectable >& xSuccessor ) + { m_xSuccessor = xSuccessor; } + virtual Reference< ::com::sun::star::io::XConnectable > SAL_CALL getSuccessor() + { return m_xSuccessor; } +}; + +class PluginOutputStream : public PluginStream +{ +private: + Reference< ::com::sun::star::io::XOutputStream > m_xStream; +public: + PluginOutputStream( XPlugin_Impl* pPlugin, const char* url, + sal_uInt32 len, sal_uInt32 lastmod ); + virtual ~PluginOutputStream(); + + virtual PluginStreamType getStreamType(); + + Reference< ::com::sun::star::io::XOutputStream > & getOutputStream() { return m_xStream; } +}; + +class PluginEventListener : + public ::cppu::WeakAggImplHelper1< ::com::sun::star::lang::XEventListener > +{ +private: + XPlugin_Impl* m_pPlugin; + Reference< ::com::sun::star::plugin::XPlugin > m_xPlugin; // just to hold the plugin + char* m_pUrl; + char* m_pNormalizedUrl; + void* m_pNotifyData; +public: + PluginEventListener( XPlugin_Impl*, + const char* url, + const char* normurl, + void* notifyData ); + virtual ~PluginEventListener(); + + const char* getURL() { return m_pUrl; } + const char* getNormalizedURL() { return m_pNormalizedUrl; } + void* getNotifyData() { return m_pNotifyData; } + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ); +}; + +#endif diff --git a/extensions/source/plugin/inc/plugin/model.hxx b/extensions/source/plugin/inc/plugin/model.hxx new file mode 100644 index 000000000000..9b7c0b174f90 --- /dev/null +++ b/extensions/source/plugin/inc/plugin/model.hxx @@ -0,0 +1,187 @@ +/************************************************************************* + * + * $RCSfile: model.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 __PLUGIN_MODEL_HXX +#define __PLUGIN_MODEL_HXX + +#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_ +#include <com/sun/star/io/XObjectInputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XPERSISTOBJECT_HPP_ +#include <com/sun/star/io/XPersistObject.hpp> +#endif +#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_ +#include <com/sun/star/io/XObjectOutputStream.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_ +#include <com/sun/star/lang/XServiceName.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROLMODEL_HPP_ +#include <com/sun/star/awt/XControlModel.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROL_HPP_ +#include <com/sun/star/awt/XControl.hpp> +#endif + +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/weakagg.hxx> +#include <rtl/alloc.h> + +#include <stl/list> + +using namespace com::sun::star::uno; + +class BroadcasterHelperHolder +{ +protected: + ::cppu::OBroadcastHelper m_aHelper; +public: + BroadcasterHelperHolder( ::osl::Mutex& rMutex ) : + m_aHelper( rMutex ) {} + ~BroadcasterHelperHolder() {} + + ::cppu::OBroadcastHelper& getHelper() { return m_aHelper; } + +}; + +class PluginModel : public BroadcasterHelperHolder, + public ::cppu::OPropertySetHelper, + public ::cppu::OPropertyArrayHelper, + public ::cppu::OWeakAggObject, + public ::com::sun::star::lang::XComponent, + public ::com::sun::star::io::XPersistObject, + public ::com::sun::star::awt::XControlModel +{ + private: + ::rtl::OUString m_aCreationURL; + + ::std::list< Reference< ::com::sun::star::lang::XEventListener > > + m_aDisposeListeners; + public: + // these are here to force memory de/allocation to sal lib. + static void * SAL_CALL operator new( size_t nSize ) throw() + { return ::rtl_allocateMemory( nSize ); } + static void SAL_CALL operator delete( void * pMem ) throw() + { ::rtl_freeMemory( pMem ); } + + PluginModel(); + PluginModel( const ::rtl::OUString& ); + virtual ~PluginModel(); + + + const ::rtl::OUString& getCreationURL() { return m_aCreationURL; } + + // XInterface + virtual Any SAL_CALL queryInterface( const Type& rType ) + { return OWeakAggObject::queryInterface( rType ); } + virtual void SAL_CALL acquire() { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() { OWeakAggObject::release(); } + + virtual Any SAL_CALL queryAggregation( const Type& ); + + + // ::com::sun::star::lang::XTypeProvider + + // ::com::sun::star::lang::XServiceInfo + ::rtl::OUString SAL_CALL getImplementationName() throw( ); + + sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw( ); + Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ); + static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static(void) throw( ); + static ::rtl::OUString SAL_CALL getImplementationName_Static() throw( ) + { + /** the soplayer uses this name in its source! maybe not after 5.2 */ + return ::rtl::OUString::createFromAscii( "com.sun.star.extensions.PluginModel" ); + } + + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual sal_Bool SAL_CALL convertFastPropertyValue( Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, + const Any& rValue ) + throw( ::com::sun::star::lang::IllegalArgumentException ); + virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const; + virtual Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(); + + // ::com::sun::star::io::XPersistObject + virtual ::rtl::OUString SAL_CALL getServiceName(); + virtual void SAL_CALL write(const Reference< ::com::sun::star::io::XObjectOutputStream > & OutStream); + virtual void SAL_CALL read(const Reference< ::com::sun::star::io::XObjectInputStream > & InStream); + + // ::com::sun::star::lang::XComponent + virtual void SAL_CALL addEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ); + virtual void SAL_CALL removeEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ); + virtual void SAL_CALL dispose(); +}; +Reference< XInterface > SAL_CALL PluginModel_CreateInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & ) throw( Exception ); + +#endif // __PLUGIN_MODEL_HXX diff --git a/extensions/source/plugin/inc/plugin/multiplx.hxx b/extensions/source/plugin/inc/plugin/multiplx.hxx new file mode 100644 index 000000000000..890bbff168e3 --- /dev/null +++ b/extensions/source/plugin/inc/plugin/multiplx.hxx @@ -0,0 +1,249 @@ +/************************************************************************* + * + * $RCSfile: multiplx.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 _MRC_MULTIPLX_HXX +#define _MRC_MULTIPLX_HXX + +#ifndef _COM_SUN_STAR_AWT_XCONTROL_HPP_ +#include <com/sun/star/awt/XControl.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XKEYLISTENER_HPP_ +#include <com/sun/star/awt/XKeyListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XPAINTLISTENER_HPP_ +#include <com/sun/star/awt/XPaintListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_KEYEVENT_HPP_ +#include <com/sun/star/awt/KeyEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_KEYMODIFIER_HPP_ +#include <com/sun/star/awt/KeyModifier.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XMOUSEMOTIONLISTENER_HPP_ +#include <com/sun/star/awt/XMouseMotionListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FOCUSEVENT_HPP_ +#include <com/sun/star/awt/FocusEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XWINDOWLISTENER_HPP_ +#include <com/sun/star/awt/XWindowListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XACTIVATELISTENER_HPP_ +#include <com/sun/star/awt/XActivateListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_MOUSEEVENT_HPP_ +#include <com/sun/star/awt/MouseEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XTOPWINDOWLISTENER_HPP_ +#include <com/sun/star/awt/XTopWindowListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_PAINTEVENT_HPP_ +#include <com/sun/star/awt/PaintEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_INPUTEVENT_HPP_ +#include <com/sun/star/awt/InputEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_KEYGROUP_HPP_ +#include <com/sun/star/awt/KeyGroup.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_KEY_HPP_ +#include <com/sun/star/awt/Key.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_WINDOWEVENT_HPP_ +#include <com/sun/star/awt/WindowEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XMOUSELISTENER_HPP_ +#include <com/sun/star/awt/XMouseListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_KEYFUNCTION_HPP_ +#include <com/sun/star/awt/KeyFunction.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FOCUSCHANGEREASON_HPP_ +#include <com/sun/star/awt/FocusChangeReason.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_MOUSEBUTTON_HPP_ +#include <com/sun/star/awt/MouseButton.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XFOCUSLISTENER_HPP_ +#include <com/sun/star/awt/XFocusListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XTOPWINDOW_HPP_ +#include <com/sun/star/awt/XTopWindow.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ +#include <com/sun/star/awt/XWindow.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_ +#include <com/sun/star/awt/PosSize.hpp> +#endif + +#include <cppuhelper/implbase7.hxx> +#include <cppuhelper/interfacecontainer.hxx> + +using namespace com::sun::star::uno; + +struct MRCListenerMultiplexerHelper_Mutex +{ + ::osl::Mutex aMutex; +}; + +class MRCListenerMultiplexerHelper : + public MRCListenerMultiplexerHelper_Mutex, + + public ::cppu::WeakAggImplHelper7< + ::com::sun::star::awt::XFocusListener, + ::com::sun::star::awt::XWindowListener, + ::com::sun::star::awt::XKeyListener, + ::com::sun::star::awt::XMouseListener, + ::com::sun::star::awt::XMouseMotionListener, + ::com::sun::star::awt::XPaintListener, + ::com::sun::star::awt::XTopWindowListener > +{ +public: + /** + * Create a Multiplexer of XWindowEvents. + * + * @param rControl The control. All listeners think that this is the original + * broadcaster. + * @param rPeer The peer from which the original events are dispatched. Null is + * allowed. + */ + MRCListenerMultiplexerHelper( const Reference< ::com::sun::star::awt::XWindow > & rControl, const Reference< ::com::sun::star::awt::XWindow > & rPeer ); + + /** + * Remove all listeners from the previous set peer and add the needed listeners to rPeer. + * @param rPeer The peer from which the original events are dispatched. Null is + * allowed. + */ + void setPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer ); + + /** + * Remove all listeners and send a disposing message. + */ + void disposeAndClear(); + + /** + * Add the specified listener to the source. + */ + void advise( const Type& type, const Reference< XInterface > & listener); + /** + * Remove the specified listener from the source. + */ + void unadvise(const Type& type, const Reference< XInterface > & listener); + + // ::com::sun::star::lang::XEventListener + void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source); + // ::com::sun::star::awt::XFocusListener + void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e); + void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e); + // ::com::sun::star::awt::XWindowListener + void SAL_CALL windowResized(const ::com::sun::star::awt::WindowEvent& e); + void SAL_CALL windowMoved(const ::com::sun::star::awt::WindowEvent& e); + void SAL_CALL windowShown(const ::com::sun::star::lang::EventObject& e); + void SAL_CALL windowHidden(const ::com::sun::star::lang::EventObject& e); + // ::com::sun::star::awt::XKeyListener + void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& e ); + void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& e ); + // ::com::sun::star::awt::XMouseListener + void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& e); + void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& e); + void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& e); + void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& e); + // ::com::sun::star::awt::XMouseMotionListener + void SAL_CALL mouseDragged(const ::com::sun::star::awt::MouseEvent& e); + void SAL_CALL mouseMoved(const ::com::sun::star::awt::MouseEvent& e); + // ::com::sun::star::awt::XPaintListener + void SAL_CALL windowPaint(const ::com::sun::star::awt::PaintEvent& e); + // ::com::sun::star::awt::XTopWindowListener + void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e ); + void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& e ); + void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& e ); + void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& e ); + void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& e ); + void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& e ); + void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& e ); +protected: + /** + * Remove the listener with the uik rUik from the peer rPeer. + * @param rPeer the peer from which the listener is removed. + * @param rUik the listener uik, which specify the type of the listener. + */ + void adviseToPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type ); + /** + * Add the listener with the uik rUik to the peer rPeer. + * @param rPeer the peer to which the listener is added. + * @param rUik the listener uik, which specify the type of the listener. + */ + void unadviseFromPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type ); +private: + /** The source of the events. Normally this is the peer object.*/ + Reference< ::com::sun::star::awt::XWindow > xPeer; + WeakReference< ::com::sun::star::awt::XControl > xControl; + ::cppu::OMultiTypeInterfaceContainerHelper aListenerHolder; + + + MRCListenerMultiplexerHelper( const MRCListenerMultiplexerHelper & ); + MRCListenerMultiplexerHelper & operator = ( const MRCListenerMultiplexerHelper & ); +}; + +#endif // _MRC_MULTIPLX_HXX + + + diff --git a/extensions/source/plugin/inc/plugin/plcom.hxx b/extensions/source/plugin/inc/plugin/plcom.hxx new file mode 100644 index 000000000000..7ab958255111 --- /dev/null +++ b/extensions/source/plugin/inc/plugin/plcom.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * $RCSfile: plcom.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 __PLUGIN_INC_PLCOM_HXX +#define __PLUGIN_INC_PLCOM_HXX + +#include <tools/string.hxx> +#include <list> + +class PluginComm +{ +protected: + int m_nRefCount; + ::rtl::OString m_aLibName; + std::list< String > m_aFilesToDelete; +public: + PluginComm( const ::rtl::OString& rLibName ); + virtual ~PluginComm(); + + int getRefCount() { return m_nRefCount; } + void addRef() { m_nRefCount++; } + void decRef() { m_nRefCount--; if( ! m_nRefCount ) delete this; } + + const ::rtl::OString& getLibName() { return m_aLibName; } + void setLibName( const ::rtl::OString& rName ) { m_aLibName = rName; } + + void addFileToDelete( const String& filename ) + { m_aFilesToDelete.push_back( filename ); } + + virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ) = 0; + virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, + NPError reason ) = 0; + virtual void* NPP_GetJavaClass() = 0; + virtual NPError NPP_Initialize() = 0; + virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, + uint16 mode, int16 argc, + char* argn[], char* argv[], + NPSavedData *saved ) = 0; + virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, + NPStream* stream, + NPBool seekable, uint16* stype ) = 0; + virtual void NPP_Print( NPP instance, NPPrint* platformPrint ) = 0; + virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ) = 0; + virtual void NPP_Shutdown() = 0; + virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, + const char* fname ) = 0; + virtual void NPP_URLNotify( NPP instance, const char* url, + NPReason reason, void* notifyData ) = 0; + virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset, + int32 len, void* buffer ) = 0; + virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ) = 0; + virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void* value ) = 0; + virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, + void *value) = 0; +}; + +#endif diff --git a/extensions/source/plugin/inc/plugin/plctrl.hxx b/extensions/source/plugin/inc/plugin/plctrl.hxx new file mode 100644 index 000000000000..b94b782f29c9 --- /dev/null +++ b/extensions/source/plugin/inc/plugin/plctrl.hxx @@ -0,0 +1,276 @@ +/************************************************************************* + * + * $RCSfile: plctrl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 __PLCTRL_HXX +#define __PLCTRL_HXX + +#include <tools/debug.hxx> + +#include <cppuhelper/weak.hxx> +#include <plugin/multiplx.hxx> + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUES_HPP_ +#include <com/sun/star/beans/PropertyValues.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYSTATE_HPP_ +#include <com/sun/star/beans/PropertyState.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_ +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HPP_ +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XFASTPROPERTYSET_HPP_ +#include <com/sun/star/beans/XFastPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XVETOABLECHANGELISTENER_HPP_ +#include <com/sun/star/beans/XVetoableChangeListener.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_ +#include <com/sun/star/beans/XPropertyState.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATECHANGELISTENER_HPP_ +#include <com/sun/star/beans/XPropertyStateChangeListener.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTIESCHANGELISTENER_HPP_ +#include <com/sun/star/beans/XPropertiesChangeListener.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_ +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HPP_ +#include <com/sun/star/beans/XPropertyAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HPP_ +#include <com/sun/star/beans/XPropertyContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYSTATECHANGEEVENT_HPP_ +#include <com/sun/star/beans/PropertyStateChangeEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYCHANGEEVENT_HPP_ +#include <com/sun/star/beans/PropertyChangeEvent.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XVCLCONTAINERPEER_HPP_ +#include <com/sun/star/awt/XVclContainerPeer.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XVCLWINDOWPEER_HPP_ +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROLMODEL_HPP_ +#include <com/sun/star/awt/XControlModel.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XUNOCONTROLCONTAINER_HPP_ +#include <com/sun/star/awt/XUnoControlContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_ +#include <com/sun/star/awt/XControlContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_VCLWINDOWPEERATTRIBUTE_HPP_ +#include <com/sun/star/awt/VclWindowPeerAttribute.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XVCLCONTAINER_HPP_ +#include <com/sun/star/awt/XVclContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCONTROL_HPP_ +#include <com/sun/star/awt/XControl.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XTOPWINDOW_HPP_ +#include <com/sun/star/awt/XTopWindow.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ +#include <com/sun/star/awt/XWindow.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_ +#include <com/sun/star/awt/PosSize.hpp> +#endif + +#include <cppuhelper/implbase5.hxx> + +#include <list> + +using namespace com::sun::star::uno; + +class SystemChildWindow; + +//================================================================================================== +class PluginControl_Impl : public ::cppu::WeakAggImplHelper5< + ::com::sun::star::awt::XControl, + ::com::sun::star::awt::XControlModel, + ::com::sun::star::awt::XWindow, + ::com::sun::star::awt::XFocusListener, + ::com::sun::star::awt::XView > +{ +public: + // ::com::sun::star::awt::XControl + virtual void SAL_CALL setContext( const Reference< XInterface > & xContext ) throw( RuntimeException ) + { _xContext = xContext; } + virtual Reference< XInterface > SAL_CALL getContext() throw( RuntimeException ) + { return _xContext; } + + virtual sal_Bool SAL_CALL setModel( const Reference< ::com::sun::star::awt::XControlModel > & Model ) throw( RuntimeException ) + { DBG_ERROR( "### setModel() illegal on plugincontrol!" ); return sal_False; } + virtual Reference< ::com::sun::star::awt::XControlModel > SAL_CALL getModel() throw( RuntimeException ) + { return (::com::sun::star::awt::XControlModel*)this; } + + virtual Reference< ::com::sun::star::awt::XView > SAL_CALL getView() throw( RuntimeException ) + { return (::com::sun::star::awt::XView*)this; } + + virtual sal_Bool SAL_CALL isTransparent() throw( RuntimeException ) + { return sal_False; } + + virtual void SAL_CALL setDesignMode( sal_Bool bOn ) throw( RuntimeException ); + virtual sal_Bool SAL_CALL isDesignMode() throw( RuntimeException ) + { return _bInDesignMode; } + + virtual void SAL_CALL createPeer( const Reference< ::com::sun::star::awt::XToolkit > & xToolkit, const Reference< ::com::sun::star::awt::XWindowPeer > & Parent) throw( RuntimeException ); + virtual Reference< ::com::sun::star::awt::XWindowPeer > SAL_CALL getPeer() throw( RuntimeException ) + { return _xPeer; } + + // ::com::sun::star::awt::XWindow + virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw( RuntimeException ); + virtual void SAL_CALL setEnable( sal_Bool bEnable ) throw( RuntimeException ); + virtual void SAL_CALL setFocus(void) throw( RuntimeException ); + + virtual void SAL_CALL setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) throw( RuntimeException ); + virtual ::com::sun::star::awt::Rectangle SAL_CALL getPosSize(void) throw( RuntimeException ); + + virtual void SAL_CALL addWindowListener( const Reference< ::com::sun::star::awt::XWindowListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL removeWindowListener( const Reference< ::com::sun::star::awt::XWindowListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL addFocusListener( const Reference< ::com::sun::star::awt::XFocusListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL removeFocusListener( const Reference< ::com::sun::star::awt::XFocusListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL addKeyListener( const Reference< ::com::sun::star::awt::XKeyListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL removeKeyListener( const Reference< ::com::sun::star::awt::XKeyListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL addMouseListener( const Reference< ::com::sun::star::awt::XMouseListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL removeMouseListener( const Reference< ::com::sun::star::awt::XMouseListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL addMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL removeMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL addPaintListener( const Reference< ::com::sun::star::awt::XPaintListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL removePaintListener( const Reference< ::com::sun::star::awt::XPaintListener > & l ) throw( RuntimeException ); + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject & rSource ) throw( RuntimeException ); + // ::com::sun::star::awt::XFocusListener + virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent & rEvt ) throw( RuntimeException ); + virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent & rEvt ) throw( RuntimeException ); + + // ::com::sun::star::lang::XComponent + virtual void SAL_CALL addEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL removeEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) throw( RuntimeException ); + + virtual void SAL_CALL dispose() throw( RuntimeException ); + + // ::com::sun::star::awt::XView + virtual sal_Bool SAL_CALL setGraphics( const Reference< ::com::sun::star::awt::XGraphics > & aDevice ) throw( RuntimeException ) + { return sal_False; } + virtual Reference< ::com::sun::star::awt::XGraphics > SAL_CALL getGraphics(void) throw( RuntimeException ) + { return Reference< ::com::sun::star::awt::XGraphics > (); } + + virtual ::com::sun::star::awt::Size SAL_CALL getSize(void) throw( RuntimeException ) + { return ::com::sun::star::awt::Size(_nWidth, _nHeight); } + + virtual void SAL_CALL draw( sal_Int32 x, sal_Int32 y ) throw( RuntimeException ); + virtual void SAL_CALL setZoom( float ZoomX, float ZoomY ) throw( RuntimeException ); + +public: + PluginControl_Impl(); + virtual ~PluginControl_Impl(); + + MRCListenerMultiplexerHelper* getMultiplexer(); + +protected: + void releasePeer(); + +protected: + ::std::list< Reference< ::com::sun::star::lang::XEventListener > > _aDisposeListeners; + MRCListenerMultiplexerHelper* _pMultiplexer; + + Reference< XInterface > _xContext; + + sal_Int32 _nX; + sal_Int32 _nY; + sal_Int32 _nWidth; + sal_Int32 _nHeight; + sal_Int16 _nFlags; + + sal_Bool _bVisible; + sal_Bool _bInDesignMode; + sal_Bool _bEnable; + + SystemChildWindow* _pSysChild; + Reference< ::com::sun::star::awt::XWindowPeer > _xPeer; + Reference< ::com::sun::star::awt::XWindow > _xPeerWindow; + + Reference< ::com::sun::star::awt::XWindow > _xParentWindow; + Reference< ::com::sun::star::awt::XWindowPeer > _xParentPeer; +}; + +#endif + + diff --git a/extensions/source/plugin/inc/plugin/unx/sysplug.hxx b/extensions/source/plugin/inc/plugin/unx/sysplug.hxx new file mode 100644 index 000000000000..702312950a0a --- /dev/null +++ b/extensions/source/plugin/inc/plugin/unx/sysplug.hxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * $RCSfile: sysplug.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 __PLUGIN_INC_UNXPLUG_HXX +#define __PLUGIN_INC_UNXPLUG_HXX + +#include <cstdio> + +#include <prex.h> +#define XP_UNIX +#include <npsdk/npupp.h> +#include <npsdk/npapi.h> +#include <postx.h> + +#include <plugin/plcom.hxx> +#include <vcl/sysdata.hxx> + +class UnxPluginComm : public PluginComm +{ +private: + void* m_pLibrary; + NPPluginFuncs m_aFuncs; + BOOL m_bInit; +public: + UnxPluginComm( const ::rtl::OString& library ); + virtual ~UnxPluginComm(); + + virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); + virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, + NPError reason ); + virtual void* NPP_GetJavaClass(); + virtual NPError NPP_Initialize(); + virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, + uint16 mode, int16 argc, + char* argn[], char* argv[], NPSavedData *saved ); + virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, + NPStream* stream, + NPBool seekable, uint16* stype ); + virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); + virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); + virtual void NPP_Shutdown(); + virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, + const char* fname ); + virtual void NPP_URLNotify( NPP instance, const char* url, NPReason reason, + void* notifyData ); + virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset, + int32 len, void* buffer ); + virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ); + virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void* value ); + virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, + void *value); +}; + +#endif diff --git a/extensions/source/plugin/inc/plugin/win/sysplug.hxx b/extensions/source/plugin/inc/plugin/win/sysplug.hxx new file mode 100644 index 000000000000..e1a22c3ba0ce --- /dev/null +++ b/extensions/source/plugin/inc/plugin/win/sysplug.hxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * $RCSfile: sysplug.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 __PLUGIN_INC_WINPLUG_HXX +#define __PLUGIN_INC_WINPLUG_HXX + +#if _MSC_VER >= 1200 +#include <tools/prewin.h> +#else +#include <tools/presys.h> +#endif +#if STLPORT_VERSION < 321 +#include <list.h> +#include <map.h> +#include <algo.h> +#include <function.h> +#endif +#include <windows.h> +#include <tchar.h> +#include <winbase.h> +#if _MSC_VER >= 1200 +#include <tools/postwin.h> +#else +#include <tools/postsys.h> +#endif +#if STLPORT_VERSION >= 321 +#include <stl/list> +#include <stl/map> +#include <stl/algorithm> +#endif + +#pragma pack( push, 8 ) +#include <npsdk/npapi.h> +#include <npsdk/npupp.h> +#pragma pack( pop, 8 ) + +#include <plugin/plcom.hxx> + + +//================================================================================================== +class PluginComm_Impl + : public PluginComm +{ +public: + PluginComm_Impl( const rtl::OUString& rMIME, const rtl::OUString& rName, HWND hWnd ); + virtual ~PluginComm_Impl(); + +public: + virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); + virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ); + virtual void * NPP_GetJavaClass(); + virtual NPError NPP_Initialize(); + virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, + char* argn[], char* argv[], NPSavedData *saved ); + virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, + NPBool seekable, uint16* stype ); + virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); + virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); + virtual void NPP_Shutdown(); + virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ); + virtual void NPP_URLNotify( NPP instance, const char* url, + NPReason reason, void* notifyData ); + virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset, + int32 len, void* buffer ); + virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ); + virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void *ret_alue ); + virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, void *ret_alue ); + +private: + BOOL retrieveFunction( TCHAR* pName, void** ppFunc ) const; + +private: + HINSTANCE _plDLL; + + NPPluginFuncs _NPPfuncs; +}; + + +#endif + + diff --git a/extensions/source/plugin/unx/makefile.mk b/extensions/source/plugin/unx/makefile.mk new file mode 100644 index 000000000000..58a4c2353bc9 --- /dev/null +++ b/extensions/source/plugin/unx/makefile.mk @@ -0,0 +1,84 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ +# +# 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=plugin +TARGET=plunx +TARGETTYPE=CUI + +.INCLUDE : ..$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES=\ + $(SLO)$/sysplug.obj \ + $(SLO)$/unxmgr.obj + + +APP1DEF= $(MISC)$/$(TARGET).def + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +.INCLUDE : ..$/util$/target.pmk diff --git a/extensions/source/plugin/unx/sysplug.cxx b/extensions/source/plugin/unx/sysplug.cxx new file mode 100644 index 000000000000..fb8f7d0638de --- /dev/null +++ b/extensions/source/plugin/unx/sysplug.cxx @@ -0,0 +1,269 @@ +/************************************************************************* + * + * $RCSfile: sysplug.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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 <string> // workaround for SUNPRO workshop include conflicts + +#include <plugin/impl.hxx> + +#include <dlfcn.h> + +extern NPNetscapeFuncs aNPNFuncs; + +UnxPluginComm::UnxPluginComm( const ::rtl::OString& library ) : + PluginComm( library ), + m_pLibrary( NULL ), + m_bInit( FALSE ) +{ + m_pLibrary = dlopen( library.getStr(), RTLD_NOW ); + + // initialize plugin function table + memset( &m_aFuncs, 0, sizeof( m_aFuncs ) ); + m_aFuncs.size = sizeof( m_aFuncs ); + m_aFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; + + if( m_pLibrary ) + { + NPError (*initFunc)(NPNetscapeFuncs*, NPPluginFuncs* ); + NPError (*initPlugin)(); + + initFunc = (NPError(*)(NPNetscapeFuncs*,NPPluginFuncs*))dlsym( m_pLibrary, "NP_Initialize" ); + initPlugin = (NPError(*)())dlsym( m_pLibrary, "NPP_Initialize" ); +#ifdef DEBUG + if( ! initFunc ) + fprintf( stderr, "could not get Symbol NP_Initialize\n" ); + if( ! initPlugin ) + fprintf( stderr, "could not get Symbol NPP_Initialize\n" ); +#endif + if( initFunc && initPlugin ) + { + NPError aErr = initFunc( &aNPNFuncs, &m_aFuncs ); +#ifdef DEBUG + fprintf( stderr, "NP_Initialize returns %d\n", aErr ); +#endif + if( aErr ) + { + aErr = initPlugin(); +#ifdef DEBUG + fprintf( stderr, "NPP_Initialize returns %d\n", aErr ); +#endif + } + + m_aFuncs.newp = (NPP_NewUPP)dlsym( m_pLibrary, "NPP_New" ); + m_aFuncs.destroy = (NPP_DestroyUPP)dlsym( m_pLibrary, "NPP_Destroy" ); + m_aFuncs.setwindow = (NPP_SetWindowUPP)dlsym( m_pLibrary, "NPP_SetWindow" ); + m_aFuncs.newstream = (NPP_NewStreamUPP)dlsym( m_pLibrary, "NPP_NewStream" ); + m_aFuncs.destroystream = (NPP_DestroyStreamUPP)dlsym( m_pLibrary, "NPP_DestroyStream" ); + m_aFuncs.asfile = (NPP_StreamAsFileUPP)dlsym( m_pLibrary, "NPP_StreamAsFile" ); + m_aFuncs.writeready = (NPP_WriteReadyUPP)dlsym( m_pLibrary, "NPP_WriteReady" ); + m_aFuncs.write = (NPP_WriteUPP)dlsym( m_pLibrary, "NPP_Write" ); + m_aFuncs.print = (NPP_PrintUPP)dlsym( m_pLibrary, "NPP_Print" ); + m_aFuncs.event = NULL; + m_aFuncs.javaClass = NULL; + m_aFuncs.urlnotify = (NPP_URLNotifyUPP)dlsym( m_pLibrary, "NPP_URLNotify" ); + m_aFuncs.getvalue =(NPP_GetValueUPP)dlsym( m_pLibrary, "NPP_GetValue" ); + m_aFuncs.setvalue =(NPP_SetValueUPP)dlsym( m_pLibrary, "NPP_SetValue" ); + + m_bInit = TRUE; + } + } + if( ! m_bInit ) + { + dlclose( m_pLibrary ); + m_pLibrary = NULL; + } +} + +UnxPluginComm::~UnxPluginComm() +{ + if( m_bInit && m_pLibrary ) + { + NPP_ShutdownUPP pFunc = (NPP_ShutdownUPP)dlsym( m_pLibrary,"NPP_Shutdown"); + if( pFunc) + pFunc(); + dlclose( m_pLibrary ); + } +} + +//-------------------------------------------------------------------------------------------------- +NPError UnxPluginComm::NPP_Destroy( NPP instance, NPSavedData** save ) +{ + DBG_ASSERT( m_aFuncs.destroy, "### NPP_Destroy(): null pointer in NPP functions table!" ); + return (m_aFuncs.destroy + ? m_aFuncs.destroy( instance, save ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +NPError UnxPluginComm::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ) +{ + DBG_ASSERT( m_aFuncs.destroystream, "### NPP_DestroyStream(): null pointer in NPP functions table!" ); + return (m_aFuncs.destroystream + ? m_aFuncs.destroystream( instance, stream, reason ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +NPError UnxPluginComm::NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, + char* argn[], char* argv[], NPSavedData *saved ) +{ + DBG_ASSERT( m_aFuncs.newp, "### NPP_New(): null pointer in NPP functions table!" ); + return (m_aFuncs.newp + ? m_aFuncs.newp( pluginType, instance, mode, argc, argn, argv, saved ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +NPError UnxPluginComm::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, + NPBool seekable, uint16* stype ) +{ + DBG_ASSERT( m_aFuncs.newstream, "### NPP_NewStream(): null pointer in NPP functions table!" ); + return (m_aFuncs.newstream + ? m_aFuncs.newstream( instance, type, stream, seekable, stype ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +void UnxPluginComm::NPP_Print( NPP instance, NPPrint* platformPrint ) +{ + DBG_ASSERT( m_aFuncs.print, "### NPP_Print(): null pointer in NPP functions table!" ); + if (m_aFuncs.print) + m_aFuncs.print( instance, platformPrint ); +} + +//-------------------------------------------------------------------------------------------------- +NPError UnxPluginComm::NPP_SetWindow( NPP instance, NPWindow* window ) +{ + DBG_ASSERT( m_aFuncs.setwindow, "### NPP_SetWindow(): null pointer in NPP functions table!" ); + return (m_aFuncs.setwindow + ? m_aFuncs.setwindow( instance, window ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +void UnxPluginComm::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ) +{ + DBG_ASSERT( m_aFuncs.asfile, "### NPP_StreamAsFile(): null pointer in NPP functions table!" ); + if (m_aFuncs.asfile) + m_aFuncs.asfile( instance, stream, fname ); +} + +//-------------------------------------------------------------------------------------------------- +void UnxPluginComm::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData ) +{ + DBG_ASSERT( m_aFuncs.urlnotify, "### NPP_URLNotify(): null pointer in NPP functions table!" ); + if (m_aFuncs.urlnotify) + m_aFuncs.urlnotify( instance, url, reason, notifyData ); +} + +//-------------------------------------------------------------------------------------------------- +int32 UnxPluginComm::NPP_Write( NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer ) +{ + DBG_ASSERT( m_aFuncs.write, "### NPP_Write(): null pointer in NPP functions table!" ); + return (m_aFuncs.write + ? m_aFuncs.write( instance, stream, offset, len, buffer ) + : 0); +} + +//-------------------------------------------------------------------------------------------------- +int32 UnxPluginComm::NPP_WriteReady( NPP instance, NPStream* stream ) +{ + DBG_ASSERT( m_aFuncs.writeready, "### NPP_WriteReady(): null pointer in NPP functions table!" ); + return (m_aFuncs.writeready + ? m_aFuncs.writeready( instance, stream ) + : 0); +} + +//-------------------------------------------------------------------------------------------------- +NPError UnxPluginComm::NPP_GetValue( NPP instance, NPPVariable variable, void *ret_alue ) +{ + DBG_ASSERT( m_aFuncs.getvalue, "### NPP_GetValue(): null pointer in NPP functions table!" ); + return (m_aFuncs.getvalue + ? m_aFuncs.getvalue( instance, variable, ret_alue ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +NPError UnxPluginComm::NPP_SetValue( NPP instance, NPNVariable variable, void *ret_alue ) +{ + DBG_ASSERT( m_aFuncs.setvalue, "### NPP_SetValue(): null pointer in NPP functions table!" ); + return (m_aFuncs.setvalue + ? m_aFuncs.setvalue( instance, variable, ret_alue ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +void* UnxPluginComm::NPP_GetJavaClass() +{ + DBG_ERROR( "no java class available!" ); + return 0; +} + +//-------------------------------------------------------------------------------------------------- +NPError UnxPluginComm::NPP_Initialize() +{ + return NPERR_NO_ERROR; +} + +//-------------------------------------------------------------------------------------------------- +void UnxPluginComm::NPP_Shutdown() +{ +} + diff --git a/extensions/source/plugin/unx/unxmgr.cxx b/extensions/source/plugin/unx/unxmgr.cxx new file mode 100644 index 000000000000..cd70ecd37d27 --- /dev/null +++ b/extensions/source/plugin/unx/unxmgr.cxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * $RCSfile: unxmgr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ +#ifdef SOLARIS +#include <limits> +#endif + +#if STLPORT_VERSION>=321 +#include <cstdarg> +#endif + +#include <sys/stat.h> +#include <dlfcn.h> + +#include <vcl/svapp.hxx> +#include <plugin/impl.hxx> + +#include <dirent.h> + +// Unix specific implementation +static ::com::sun::star::plugin::PluginDescription** CheckPlugin( const ByteString& rPath, int& rDescriptions ) +{ + ::com::sun::star::plugin::PluginDescription** pRet = NULL; + rDescriptions = 0; + + struct stat aStat; + if( stat( rPath.GetBuffer(), &aStat ) ) + return NULL; + void *pLib = dlopen( rPath.GetBuffer(), RTLD_LAZY ); + if( ! pLib ) + return NULL; + + char*(*pNP_GetMIMEDescription)() = (char*(*)()) + dlsym( pLib, "NP_GetMIMEDescription" ); + if( pNP_GetMIMEDescription ) + { + ByteString aMIME = pNP_GetMIMEDescription(); + char cTok = ';'; + if( aMIME.GetTokenCount( ';' ) > 2 ) + cTok = ';'; + if( aMIME.GetTokenCount( ':' ) > 2 ) + cTok = ':'; + ByteString aExtension = aMIME.GetToken( 1, cTok ); + int nExtensions = aExtension.GetTokenCount( ',' ); + pRet = new ::com::sun::star::plugin::PluginDescription*[ nExtensions ]; + for( int i = 0; i < nExtensions; i++ ) + { + pRet[i] = new ::com::sun::star::plugin::PluginDescription; + pRet[i]->PluginName = String( rPath, gsl_getSystemTextEncoding() ); + pRet[i]->Mimetype = String( aMIME.GetToken( 0, cTok ), gsl_getSystemTextEncoding() ); + String aExt( RTL_CONSTASCII_USTRINGPARAM( "*." ) ); + aExt += String( aExtension.GetToken( i, ',' ).EraseLeadingChars().EraseTrailingChars(), gsl_getSystemTextEncoding() ); + pRet[i]->Extension = aExt; + pRet[i]->Description= String( aMIME.GetToken( 2, cTok ), gsl_getSystemTextEncoding() ); + } + rDescriptions = nExtensions; + } + // some libraries register atexit handlers when loaded + // (e.g. g++ made libraries register global destructors) + // not closing them does prevent them to be called when already unloaded +// dlclose( pLib ); + return pRet; +} + +Sequence< ::com::sun::star::plugin::PluginDescription > XPluginManager_Impl::getPluginDescriptions() +{ + static Sequence< ::com::sun::star::plugin::PluginDescription > aDescriptions; + static BOOL bHavePlugins = FALSE; + if( ! bHavePlugins ) + { + NAMESPACE_STD(list)< ::com::sun::star::plugin::PluginDescription* > aPlugins; + int i; + + // unix: search for plugins in /usr/lib/netscape/plugins, + // ~/.netscape/plugins und NPX_PLUGIN_PATH + // additionally: search in PluginsPath + + const char* pEnv = getenv( "HOME" ); + + String aSearchPath( RTL_CONSTASCII_USTRINGPARAM( "/usr/lib/netscape/plugins:" ) ); + aSearchPath += String( pEnv ? pEnv : "", gsl_getSystemTextEncoding() ); + aSearchPath += String( RTL_CONSTASCII_USTRINGPARAM( "/.netscape/plugins:" ) ); + pEnv = getenv( "NPX_PLUGIN_PATH" ); + aSearchPath += String( pEnv ? pEnv : "", gsl_getSystemTextEncoding() ); + + const Sequence< ::rtl::OUString >& rPaths = PluginManager::getAdditionalSearchPaths(); + for( i = 0; i < rPaths.getLength(); i++ ) + { + aSearchPath += ':'; + aSearchPath += String( rPaths.getConstArray()[i] ); + } + + + int nPaths = aSearchPath.GetTokenCount( ':' ); + for( i = 0; i < nPaths; i++ ) + { + ByteString aPath( aSearchPath.GetToken( i, ':' ), gsl_getSystemTextEncoding() ); + if( aPath.Len() ) + { + DIR* pDIR = opendir( aPath.GetBuffer() ); + struct dirent aEntry; + struct dirent* pEntry; + + while( pDIR && readdir_r( pDIR, &aEntry, &pEntry ) ) + { + struct stat aStat; + ByteString aFile( aPath ); + aFile += '/'; + aFile += aEntry.d_name; + if( ! stat( aFile.GetBuffer(), &aStat ) && + S_ISREG( aStat.st_mode ) && + ! strncmp( aEntry.d_name, "libnullplugin", 13 ) + ) + { + int nStructs; + ::com::sun::star::plugin::PluginDescription** pStructs = + CheckPlugin( aFile, nStructs ); + if( pStructs ) + { + for( int i = 0; i < nStructs; i++ ) + aPlugins.push_back( pStructs[i] ); + delete pStructs; + } + } + } + } + } + aDescriptions = Sequence< ::com::sun::star::plugin::PluginDescription >( aPlugins.size() ); + NAMESPACE_STD(list)< ::com::sun::star::plugin::PluginDescription* >::iterator iter; + for( iter = aPlugins.begin(), i=0; iter != aPlugins.end(); ++iter ,i++ ) + { + aDescriptions.getArray()[ i ] = **iter; + delete *iter; + } + aPlugins.clear(); + bHavePlugins = TRUE; + } + return aDescriptions; +} + diff --git a/extensions/source/plugin/util/makefile.mk b/extensions/source/plugin/util/makefile.mk new file mode 100644 index 000000000000..53daf359d4ca --- /dev/null +++ b/extensions/source/plugin/util/makefile.mk @@ -0,0 +1,125 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ +# +# 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=extensions +TARGET=pl +USE_DEFFILE=TRUE +GEN_HID=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files -------------------------------------------------------- + +LIB1TARGET = $(SLB)$/plall.lib +LIB1FILES = \ + $(SLB)$/plbase.lib \ + $(SHL1LINKLIB) + +SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX) + +.IF "$(GUI)" == "UNX" +SHL1LINKLIB = $(SLB)$/plunx.lib +.ENDIF + +.IF "$(GUI)" == "WNT" +SHL1LINKLIB = $(SLB)$/plwin.lib +SHL1OWNLIB = \ + version.lib \ + ole32.lib \ + advapi32.lib +.ENDIF + +.IF "$(GUI)" == "OS2" +SHL1LINKLIB = $(SLB)$/plos2.lib +.ENDIF + +SHL1STDLIBS=\ + $(SHL1OWNLIB) \ + $(VCLLIB) \ + $(TOOLSLIB) \ + $(TKLIB) \ + $(VOSLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(SALLIB) + +#SHL1DEPN= $(SLB)/sfx.lib $(L)$/itools.lib $(L)$/ivcl.lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def +SHL1IMPLIB = i$(TARGET) + +SHL1LIBS = $(LIB1TARGET) + + +DEF1NAME =$(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + + diff --git a/extensions/source/plugin/util/makefile.pmk b/extensions/source/plugin/util/makefile.pmk new file mode 100644 index 000000000000..3bec8dfc97ef --- /dev/null +++ b/extensions/source/plugin/util/makefile.pmk @@ -0,0 +1,69 @@ +#************************************************************************* +# +# $RCSfile: makefile.pmk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:51 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* +PDBTARGET=pl +NOUNODOC=true + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + + diff --git a/extensions/source/plugin/win/makefile.mk b/extensions/source/plugin/win/makefile.mk new file mode 100644 index 000000000000..5764e096aac4 --- /dev/null +++ b/extensions/source/plugin/win/makefile.mk @@ -0,0 +1,96 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ +# +# 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=plugin +TARGET=plwin +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- +.IF "$(GUI)" == "WNT" + +.INCLUDE : ..$/util$/makefile.pmk + +# --- Types ------------------------------------- + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb + +UNOUCROUT=$(OUT)$/inc$/$(PRJNAME) +INCPRE+=$(UNOUCROUT) + +# --- Types ------------------------------------- + +SLOFILES = $(SLO)$/winmgr.obj \ + $(SLO)$/sysplug.obj + +#SRCFILES = app.src + +.ENDIF +# ------------------------------------------------------------------ + + +.INCLUDE : target.mk +.INCLUDE : ..$/util$/target.pmk + + diff --git a/extensions/source/plugin/win/sysplug.cxx b/extensions/source/plugin/win/sysplug.cxx new file mode 100644 index 000000000000..f0f2dc889aa4 --- /dev/null +++ b/extensions/source/plugin/win/sysplug.cxx @@ -0,0 +1,300 @@ +/************************************************************************* + * + * $RCSfile: sysplug.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 <plugin/impl.hxx> + +#ifdef WNT +#if _MSC_VER >= 1200 +#include <tools/prewin.h> +#else +#include <tools/presys.h> +#endif +#endif +#if STLPORT_VERSION < 321 +#include <stl/map.h> +#endif +#include <windows.h> +#include <string.h> +#include <tchar.h> +#include <winreg.h> +#include <winbase.h> +#include <objbase.h> +#ifdef WNT +#if _MSC_VER >= 1200 +#include <tools/postwin.h> +#else +#include <tools/postsys.h> +#endif +#endif +#if STLPORT_VERSION >= 321 +#include <stl/list> +#include <stl/map> +#include <stl/algorithm> +#endif + +extern NPNetscapeFuncs aNPNFuncs; + +#include <tools/debug.hxx> + +using namespace rtl; + +//-------------------------------------------------------------------------------------------------- +PluginComm_Impl::PluginComm_Impl( const OUString& rMIME, const OUString& rName, HWND hWnd ) + : PluginComm( OUStringToOString( rName, RTL_TEXTENCODING_MS_1252 ) ) +{ + // initialize plugin function table + memset( &_NPPfuncs, 0, sizeof( _NPPfuncs ) ); +#ifdef UNICODE + _plDLL = ::LoadLibrary( rName.getStr() ); +#else + OString aStr( OUStringToOString( rName, RTL_TEXTENCODING_MS_1252 ) ); + _plDLL = ::LoadLibrary( aStr.getStr() ); +#endif + DBG_ASSERT( _plDLL, "### loading plugin dll failed!" ); + + NPError nErr; + NPError (WINAPI * pEntry)( NPPluginFuncs* ); + if (_plDLL && retrieveFunction( _T("NP_GetEntryPoints"), (void**)&pEntry )) + { + _NPPfuncs.size = sizeof( _NPPfuncs ); + _NPPfuncs.version = 0; + nErr = (*pEntry)( &_NPPfuncs ); + + DBG_ASSERT( nErr == NPERR_NO_ERROR, "### NP_GetEntryPoints() failed!" ); + DBG_ASSERT( (_NPPfuncs.version >> 8) >= NP_VERSION_MAJOR, + "### version failure!" ); + + NPError (WINAPI * pInit)( NPNetscapeFuncs* ); + if (nErr == NPERR_NO_ERROR && + (_NPPfuncs.version >> 8) >= NP_VERSION_MAJOR && + (retrieveFunction( _T("NP_Initialize"), (void**)&pInit ) || + retrieveFunction( _T("NP_PluginInit"), (void**)&pInit ))) + { + nErr = (*pInit)( &aNPNFuncs ); + DBG_ASSERT( nErr == NPERR_NO_ERROR, "### NP_Initialize() failed!" ); + +// WIN obsolete: called by NP_Initialize() +// nErr = NPP_Initialize(); +// DBG_ASSERT( nErr == NPERR_NO_ERROR, "### NPP_Initialize() failed!" ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +PluginComm_Impl::~PluginComm_Impl() +{ + if (_plDLL) + { +// NPP_Shutdown(); + + NPError (WINAPI * pShutdown)(); + if (retrieveFunction( _T("NP_Shutdown"), (void**)&pShutdown )) + { + NPError nErr = (*pShutdown)(); + DBG_ASSERT( nErr == NPERR_NO_ERROR, "### NP_Shutdown() failed!" ); + } + + BOOL bRet = ::FreeLibrary( _plDLL ); + DBG_ASSERT( bRet, "### unloading plugin dll failed!" ); + _plDLL = NULL; + } +} + +//-------------------------------------------------------------------------------------------------- +BOOL PluginComm_Impl::retrieveFunction( TCHAR* pName, void** ppFunc ) const +{ + if( ! _plDLL ) + return FALSE; + + *ppFunc = (void*)::GetProcAddress( _plDLL, pName ); + + return (*ppFunc != NULL); +} + +//-------------------------------------------------------------------------------------------------- +NPError PluginComm_Impl::NPP_Destroy( NPP instance, NPSavedData** save ) +{ + DBG_ASSERT( _NPPfuncs.destroy, "### NPP_Destroy(): null pointer in NPP functions table!" ); + return (_NPPfuncs.destroy + ? (*_NPPfuncs.destroy)( instance, save ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +NPError PluginComm_Impl::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ) +{ + DBG_ASSERT( _NPPfuncs.destroystream, "### NPP_DestroyStream(): null pointer in NPP functions table!" ); + return (_NPPfuncs.destroystream + ? (*_NPPfuncs.destroystream)( instance, stream, reason ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +NPError PluginComm_Impl::NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, + char* argn[], char* argv[], NPSavedData *saved ) +{ + DBG_ASSERT( _NPPfuncs.newp, "### NPP_New(): null pointer in NPP functions table!" ); + return (_NPPfuncs.newp + ? (*_NPPfuncs.newp)( pluginType, instance, mode, argc, argn, argv, saved ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +NPError PluginComm_Impl::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, + NPBool seekable, uint16* stype ) +{ + DBG_ASSERT( _NPPfuncs.newstream, "### NPP_NewStream(): null pointer in NPP functions table!" ); + return (_NPPfuncs.newstream + ? (*_NPPfuncs.newstream)( instance, type, stream, seekable, stype ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +void PluginComm_Impl::NPP_Print( NPP instance, NPPrint* platformPrint ) +{ + DBG_ASSERT( _NPPfuncs.print, "### NPP_Print(): null pointer in NPP functions table!" ); + if (_NPPfuncs.print) + (*_NPPfuncs.print)( instance, platformPrint ); +} + +//-------------------------------------------------------------------------------------------------- +NPError PluginComm_Impl::NPP_SetWindow( NPP instance, NPWindow* window ) +{ + DBG_ASSERT( _NPPfuncs.setwindow, "### NPP_SetWindow(): null pointer in NPP functions table!" ); + return (_NPPfuncs.setwindow + ? (*_NPPfuncs.setwindow)( instance, window ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +void PluginComm_Impl::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ) +{ + DBG_ASSERT( _NPPfuncs.asfile, "### NPP_StreamAsFile(): null pointer in NPP functions table!" ); + if (_NPPfuncs.asfile) + (*_NPPfuncs.asfile)( instance, stream, fname ); +} + +//-------------------------------------------------------------------------------------------------- +void PluginComm_Impl::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData ) +{ + DBG_ASSERT( _NPPfuncs.urlnotify, "### NPP_URLNotify(): null pointer in NPP functions table!" ); + if (_NPPfuncs.urlnotify) + (*_NPPfuncs.urlnotify)( instance, url, reason, notifyData ); +} + +//-------------------------------------------------------------------------------------------------- +int32 PluginComm_Impl::NPP_Write( NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer ) +{ + DBG_ASSERT( _NPPfuncs.write, "### NPP_Write(): null pointer in NPP functions table!" ); + return (_NPPfuncs.write + ? (*_NPPfuncs.write)( instance, stream, offset, len, buffer ) + : 0); +} + +//-------------------------------------------------------------------------------------------------- +int32 PluginComm_Impl::NPP_WriteReady( NPP instance, NPStream* stream ) +{ + DBG_ASSERT( _NPPfuncs.writeready, "### NPP_WriteReady(): null pointer in NPP functions table!" ); + return (_NPPfuncs.writeready + ? (*_NPPfuncs.writeready)( instance, stream ) + : 0); +} + +//-------------------------------------------------------------------------------------------------- +NPError PluginComm_Impl::NPP_GetValue( NPP instance, NPPVariable variable, void *ret_alue ) +{ + DBG_ASSERT( _NPPfuncs.getvalue, "### NPP_GetValue(): null pointer in NPP functions table!" ); + return (_NPPfuncs.getvalue + ? (*_NPPfuncs.getvalue)( instance, variable, ret_alue ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +NPError PluginComm_Impl::NPP_SetValue( NPP instance, NPNVariable variable, void *ret_alue ) +{ + DBG_ASSERT( _NPPfuncs.setvalue, "### NPP_SetValue(): null pointer in NPP functions table!" ); + return (_NPPfuncs.setvalue + ? (*_NPPfuncs.setvalue)( instance, variable, ret_alue ) + : NPERR_GENERIC_ERROR); +} + +//-------------------------------------------------------------------------------------------------- +void * PluginComm_Impl::NPP_GetJavaClass() +{ + DBG_ERROR( "no java class available!" ); + return 0; +} + +//-------------------------------------------------------------------------------------------------- +NPError PluginComm_Impl::NPP_Initialize() +{ + return NPERR_NO_ERROR; +} + +//-------------------------------------------------------------------------------------------------- +void PluginComm_Impl::NPP_Shutdown() +{ + NPP_ShutdownUPP pFunc; + if (retrieveFunction( _T("NPP_Shutdown"), (void**)&pFunc )) + (*pFunc)(); +} + + diff --git a/extensions/source/plugin/win/winmgr.cxx b/extensions/source/plugin/win/winmgr.cxx new file mode 100644 index 000000000000..a1a2b6abf44b --- /dev/null +++ b/extensions/source/plugin/win/winmgr.cxx @@ -0,0 +1,392 @@ +/************************************************************************* + * + * $RCSfile: winmgr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 <vcl/svapp.hxx> +#include <tools/fsys.hxx> +#include <osl/mutex.hxx> + +#include <rtl/string.hxx> +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> + +#include <plugin/impl.hxx> + +#ifdef WNT +#if _MSC_VER >= 1200 +#include <tools/prewin.h> +#else +#include <tools/presys.h> +#endif +#endif +#include <windows.h> +#include <string.h> +#include <tchar.h> +#include <winreg.h> +#include <winbase.h> +#include <objbase.h> +#ifdef WNT +#if _MSC_VER >= 1200 +#include <tools/postwin.h> +#else +#include <tools/postsys.h> +#endif +#endif +#if STLPORT_VERSION >= 321 +#include <stl/list> +#include <stl/map> +#include <stl/algorithm> +#else +#include <stl/map.h> +#endif + +using namespace rtl; +using namespace std; +using namespace osl; +using namespace com::sun::star::uno; +using namespace com::sun::star::plugin; + +typedef map< OString, OUString, less< OString > > PluginLocationMap; + + +//__________________________________________________________________________________________________ +static void addPluginsFromPath( const TCHAR * pPluginsPath, PluginLocationMap & rPlugins ) +{ + // append dll name pattern we are looking for + TCHAR arPluginsPath[MAX_PATH]; + arPluginsPath[0] = 0; + +#ifdef UNICODE + if (::rtl_ustr_indexOfStr( pPluginsPath, L"%programfiles%" ) == 0) + { + const char * p = ::getenv( "ProgramFiles" ); + if (p) + { + OUString aStr( OUString::createFromAscii( p ) ); + ::lstrcpy( arPluginsPath, aStr.getStr() ); + pPluginsPath += 14; + } + } +#else + if (::rtl_str_indexOfStr( pPluginsPath, "%programfiles%" ) == 0) + { + const char * p = ::getenv( "ProgramFiles" ); + if (p) + { + ::lstrcpy( arPluginsPath, p ); + pPluginsPath += 14; + } + } +#endif + ::lstrcat( arPluginsPath, pPluginsPath ); + ::lstrcat( arPluginsPath, _T("\\") ); + + TCHAR arPluginsPattern[MAX_PATH]; + ::lstrcpy( arPluginsPattern, arPluginsPath ); + ::lstrcat( arPluginsPattern, _T("NP*.DLL") ); + + WIN32_FIND_DATA aFindData; + HANDLE hFind = ::FindFirstFile( arPluginsPattern, &aFindData ); + + while (hFind != INVALID_HANDLE_VALUE) + { +#ifdef UNICODE + OString aStr( OUStringToOString( aFindData.cFileName, RTL_TEXTENCODING_MS_1252 ) ); + OString aName( aStr ); // cAsE? +#else + OString aName( aFindData.cFileName ); +#endif + aName.toLowerCase(); + + // no netscape default plugin anymore... + // and no double plugin dlls + if (!aName.equals( "npnul32.dll" ) && rPlugins.find( aName ) == rPlugins.end()) + { + TCHAR arComplete[MAX_PATH]; + ::lstrcpy( arComplete, arPluginsPath ); + ::lstrcat( arComplete, aFindData.cFileName ); + +#ifdef UNICODE + rPlugins[aName] = OUString( arComplete ); +#else + OUString aStr( OStringToOUString( arComplete, RTL_TEXTENCODING_MS_1252 ) ); + rPlugins[aName] = OUString( aStr.getStr() ); +#endif + } + + if (! ::FindNextFile( hFind, &aFindData )) + break; + } + + if (hFind != INVALID_HANDLE_VALUE) + ::FindClose( hFind ); +} +//__________________________________________________________________________________________________ +static void addPluginsFromPath( const OUString & rPath, PluginLocationMap & rPlugins ) +{ + TCHAR arPluginsPath[MAX_PATH]; + DWORD dwPluginsPathSize = sizeof(arPluginsPath); + +#ifdef UNICODE + ::lstrcpy( arPluginsPath, rPath.getStr() ); +#else + OString aStr( OUStringToOString( rPath, RTL_TEXTENCODING_MS_1252 ) ); + ::strcpy( arPluginsPath, aStr.getStr() ); +#endif + + addPluginsFromPath( arPluginsPath, rPlugins ); +} + + +//__________________________________________________________________________________________________ +static void add_IE_Plugins( PluginLocationMap & rPlugins ) +{ + HKEY hKey; + TCHAR arCurrent[MAX_PATH]; + DWORD dwType, dwCurrentSize = sizeof(arCurrent); + + if (::RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\IE4\\SETUP"), + 0, KEY_READ, &hKey ) == ERROR_SUCCESS) + { + if (::RegQueryValueEx( hKey, _T("Path"), NULL, &dwType, + (LPBYTE)arCurrent, &dwCurrentSize ) == ERROR_SUCCESS && + (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) + { + // add \\Plugins + ::lstrcat( arCurrent, _T("\\Plugins") ); + + addPluginsFromPath( arCurrent, rPlugins ); + } + ::RegCloseKey( hKey ); + } +} + +//__________________________________________________________________________________________________ +static void add_NS_Plugins( PluginLocationMap & rPlugins ) +{ + HKEY hKey1, hKey2; + TCHAR arCurrent[MAX_PATH]; + DWORD dwType, dwCurrentSize = sizeof(arCurrent); + + if (::RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("Software\\Netscape\\Netscape Navigator"), + 0, KEY_READ, &hKey1 ) == ERROR_SUCCESS) + { + if (::RegQueryValueEx( hKey1, _T("CurrentVersion"), NULL, &dwType, + (LPBYTE)arCurrent, &dwCurrentSize ) == ERROR_SUCCESS && + (dwType == REG_SZ || dwType == REG_EXPAND_SZ) && + ::RegOpenKeyEx( hKey1, ::lstrcat( arCurrent, _T("\\Main") ), + 0, KEY_READ, &hKey2 ) == ERROR_SUCCESS) + { + dwCurrentSize = sizeof(arCurrent); + if (::RegQueryValueEx( hKey2, _T("Plugins Directory"), NULL, &dwType, + (LPBYTE)arCurrent, &dwCurrentSize ) == ERROR_SUCCESS && + (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) + { + addPluginsFromPath( arCurrent, rPlugins ); + } + ::RegCloseKey( hKey2 ); + } + ::RegCloseKey( hKey1 ); + } +} + +//__________________________________________________________________________________________________ +static void add_SO_Plugins( PluginLocationMap & rPlugins ) +{ + const Sequence< OUString > & rPaths = PluginManager::getAdditionalSearchPaths(); + + const OUString * pPaths = rPaths.getConstArray(); + for ( UINT32 nPos = rPaths.getLength(); nPos--; ) + { + addPluginsFromPath( pPaths[nPos], rPlugins ); + } +} + +//__________________________________________________________________________________________________ +Sequence< PluginDescription > XPluginManager_Impl::getPluginDescriptions(void) throw() +{ + Guard< Mutex > aGuard( Mutex::getGlobalMutex() ); + static Sequence<PluginDescription > s_aDescriptions( 0 ); + static s_bInit = FALSE; + + if (! s_bInit) + { + // collect all distinct plugin dlls + PluginLocationMap aPlugins; + add_SO_Plugins( aPlugins ); + add_NS_Plugins( aPlugins ); + add_IE_Plugins( aPlugins ); + + // collect mime types of plugin dlls + for ( PluginLocationMap::iterator iPos( aPlugins.begin() ); + iPos != aPlugins.end(); + ++iPos ) + { + TCHAR arFileName[MAX_PATH]; + DWORD dwDummy, dwSize; + + // DLL name + OUString aName( (*iPos).second.getStr() ); + +#ifdef UNICODE + ::lstrcpy( arFileName, aName.getStr() ); +#else + OString aStr( OUStringToOString( aName, RTL_TEXTENCODING_MS_1252 ) ); + ::strcpy( arFileName, aStr.getStr() ); +#endif + dwSize = ::GetFileVersionInfoSize( arFileName, &dwDummy ); + + char * pVersionData = NULL; + if (dwSize && (pVersionData = new char[dwSize]) && + ::GetFileVersionInfo( arFileName, 0, dwSize, pVersionData )) + { + // optional comment + OUString aComment; + + TCHAR * pInfo, * pInfo2; + UINT nSize; + if (::VerQueryValue( pVersionData, _T("\\StringFileInfo\\040904E4\\ProductName"), + (void**)&pInfo, &nSize ) && pInfo) + { +#ifdef UNICODE + aComment.operator=( pInfo ); +#else + aComment.operator=( OStringToOUString( OString(pInfo), RTL_TEXTENCODING_MS_1252 ) ); +#endif + } + + // mandatory mime type and file extensions + if (::VerQueryValue( pVersionData, _T("\\StringFileInfo\\040904E4\\MIMEType"), + (void**)&pInfo, &nSize ) && pInfo && + ::VerQueryValue( pVersionData, _T("\\StringFileInfo\\040904E4\\FileExtents"), + (void**)&pInfo2, &nSize ) && pInfo2) + { +#ifdef UNICODE + OUString aExt( pInfo2 ); + OUString aMIME( pInfo ); +#else + OString aStr2( pInfo2 ); + OString aExt( aStr2 ); + OString aStr( pInfo ); + OString aMIME( aStr ); +#endif + aMIME.trim(); + + USHORT nToken = aExt.getTokenCount( '|' ); + USHORT nMToken = aMIME.getTokenCount( '|' ); + if (nToken != nMToken) + { + DBG_ERROR( "### mime type count differ to extension count!" ); + nToken = (nToken > nMToken ? nMToken : nToken); + } + + UINT32 nStart = s_aDescriptions.getLength(); + s_aDescriptions.realloc( nStart + nToken ); + PluginDescription* pDescriptions = s_aDescriptions.getArray(); + // for every MIME Type + for ( ; nToken--; ) + { + PluginDescription & rDescr = pDescriptions[nStart+nToken]; + rDescr.PluginName = aName; + rDescr.Description = aComment; + rDescr.Mimetype = OStringToOUString( aMIME.getToken( nToken, '|' ), RTL_TEXTENCODING_MS_1252 ); + + OUString aExtToken( OStringToOUString( aExt.getToken( nToken, '|' ), RTL_TEXTENCODING_MS_1252 ) ); + USHORT nPos = 0, nLen = aExtToken.getLength(); + OUString aExtensions( OUString::createFromAscii( nLen ? "*." : "*.*" ) ); + + for ( ; nPos < nLen; ++nPos ) + { + sal_Unicode c = aExtToken[nPos]; + switch (c) + { + case ',': + case ';': + aExtensions += OUString::createFromAscii( ";*." ); + case ' ': + break; + case '*': + if (nPos < (nLen-1) && aExtToken[ nPos+1 ] == '.') + { + ++nPos; + break; + } + default: + aExtensions += OUString( &c, 1 ); + } + } + rDescr.Extension = aExtensions; + } + } +#if DEBUG + else + DBG_ERROR( "### cannot get MIME type or extensions!" ); +#endif + } + if (pVersionData) + delete[] pVersionData; + } + + s_bInit = TRUE; + } + return s_aDescriptions; +} + + diff --git a/extensions/source/resource/exports.dxp b/extensions/source/resource/exports.dxp new file mode 100644 index 000000000000..9e59e94034a6 --- /dev/null +++ b/extensions/source/resource/exports.dxp @@ -0,0 +1,3 @@ +component_writeInfo +component_getImplementationEnvironment +component_getFactory diff --git a/extensions/source/resource/makefile.mk b/extensions/source/resource/makefile.mk new file mode 100644 index 000000000000..5d38e76d5757 --- /dev/null +++ b/extensions/source/resource/makefile.mk @@ -0,0 +1,133 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ +# +# 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=extensions +TARGET=res +LIBTARGET=NO +USE_LDUMP2=TRUE +USE_DEFFILE=TRUE +# NEW +NO_BSYMBOLIC=TRUE +# END NEW + +# --- Settings ----------------------------------------------------- +.INCLUDE : $(PRJ)$/util$/makefile.pmk + + +# --- Files -------------------------------------------------------- + +SLOFILES= $(SLO)$/resource.obj + +EXCEPTIONSFILES= $(SLO)$/resource.obj + +LIB1TARGET= $(SLB)$/$(TARGET).lib +LIB1OBJFILES= $(EXCEPTIONSFILES) + +SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX) + +# $(UNOLIB) \ +# NEW \ +# $(CPPULIB) \ +# $(CPPUHELPERLIB) \ +# END NEW \ + +SHL1STDLIBS= \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(SALLIB) \ + $(VCLLIB) \ + $(TOOLSLIB) + +SHL1DEPN= +SHL1IMPLIB= ires +SHL1LIBS= $(LIB1TARGET) +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +# NEW +UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb + +UNOTYPES=\ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.XServiceInfo \ + com.sun.star.reflection.InvocationTargetException \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.script.XInvocation \ + com.sun.star.script.XTypeConverter \ + com.sun.star.beans.XExactName +# END NEW + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/util$/target.pmk + diff --git a/extensions/source/resource/resource.cxx b/extensions/source/resource/resource.cxx new file mode 100644 index 000000000000..1c4eb79452e5 --- /dev/null +++ b/extensions/source/resource/resource.cxx @@ -0,0 +1,583 @@ +/************************************************************************* + * + * $RCSfile: resource.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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/mutex.hxx> +//#include <usr/ustring.hxx> +//#include <usr/factoryhlp.hxx> +//#include <usr/weak.hxx> + +//#include <smart/com/sun/star/lang/XServiceInfo.hxx> +//#include <smart/com/sun/star/script/XInvocation.hxx> +//#include <smart/com/sun/star/script/XTypeConverter.hxx> +//#include <smart/com/sun/star/beans/XExactName.hxx> + +// Changes from ...Ref to Reference< ... >, USR_QUERY -> UNO_QUERY, THROWS( ... ) -> throw( ... ), +// UsrAny -> Any, (BOOL -> sal_BOOL, ...), OUString -> OUString, put SAL_CALL infront of each interface method, +// UsrSystemException -> RuntimeException, const is removed from each interface method +// are done without comment +/**** NEW ****/ +#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type +#include <cppuhelper/factory.hxx> // helper for factories +#include <cppuhelper/implbase3.hxx> // helper for implementations + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/script/XTypeConverter.hpp> +#include <com/sun/star/reflection/InvocationTargetException.hpp> +#include <com/sun/star/beans/XExactName.hpp> + +/**** END NEW ****/ + +#include <tools/resmgr.hxx> +#include <tools/rcid.h> +#include <vcl/svapp.hxx> + +#include <rtl/ustring.hxx> + +#ifndef _VOS_NO_NAMESPACE +using namespace vos; +//using namespace usr; +using namespace rtl; +/**** NEW ****/ +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::registry; +using namespace com::sun::star::script; +using namespace com::sun::star::beans; +using namespace com::sun::star::reflection; +/**** END NEW ****/ +#endif + + +//------------------------------------------------------------------------ +//------------------------------------------------------------------------ +//------------------------------------------------------------------------ +//class ResourceService : public XInvocation +// , public XExactName +// , public XServiceInfo +// , public OWeakObject + +/**** NEW ****/ +class ResourceService : public cppu::WeakImplHelper3< XInvocation, XExactName, XServiceInfo > +/**** END NEW ****/ +{ +public: + ResourceService( const Reference< XMultiServiceFactory > & ); + ~ResourceService(); + + // XInterface + //BOOL queryInterface( Uik aUik, Reference< XInterface > & rOut ); + //void acquire() { OWeakObject::acquire(); } + //void release() { OWeakObject::release(); } + //void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + + // XIdlClassProvider + //Sequence< Reference< XIdlClass > > getIdlClasses(void); + + // XServiceInfo + OUString SAL_CALL getImplementationName() throw(); + BOOL SAL_CALL supportsService(const OUString& ServiceName) throw(); + Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw(); + + static Sequence< OUString > getSupportedServiceNames_Static(void) throw(); + static OUString getImplementationName_Static() throw() + { + return OUString::createFromAscii("com.sun.star.comp.extensions.ResourceService"); + } + + // XExactName + OUString SAL_CALL getExactName( const OUString & ApproximateName ); + + // XInvokation + Reference< XIntrospectionAccess > SAL_CALL getIntrospection(void) throw(RuntimeException); + Any SAL_CALL invoke(const OUString& FunctionName, const Sequence< Any >& Params, Sequence< INT16 >& OutParamIndex, Sequence< Any >& OutParam) throw(IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException); + void SAL_CALL setValue(const OUString& PropertyName, const Any& Value) throw(UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException); + Any SAL_CALL getValue(const OUString& PropertyName) throw(UnknownPropertyException, RuntimeException); + BOOL SAL_CALL hasMethod(const OUString& Name) throw(RuntimeException); + BOOL SAL_CALL hasProperty(const OUString& Name) throw(RuntimeException); +private: + Reference< XTypeConverter > getTypeConverter() const; + Reference< XInvocation > getDefaultInvocation() const; + //Reference< XIdlClass > getStaticIdlClass(); + + Reference< XMultiServiceFactory > xSMgr; + Reference< XInvocation > xDefaultInvocation; + Reference< XTypeConverter > xTypeConverter; + OUString aFileName; + ResMgr * pResMgr; +}; + + +ResourceService::ResourceService( const Reference< XMultiServiceFactory > & rSMgr ) + : xSMgr( rSMgr ) + , pResMgr( NULL ) +{ +} + +//----------------------------------------------------------------------------- +ResourceService::~ResourceService() +{ + delete pResMgr; +} + +//----------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL ResourceService_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw(Exception) +{ + Reference< XInterface > xService = (cppu::OWeakObject*)new ResourceService( rSMgr ); + return xService; +} + +//************************************************************************* +// DLLImplementationLoader::getStaticIdlClass() +// +//Reference< XIdlClass > ResourceService::getStaticIdlClass() +//{ +// // Global Method, must be guarded (multithreading) +// OGuard aGuard( OMutex::getGlobalMutex() ); +// { +// // use the standard class implementation of the usr library +// static Reference< XIdlClass > xClass = +// createStandardClass( getImplementationName_Static(), +// OWeakObject::getStaticIdlClass(), 2, +// XInvocation_Reference< get >lection(), +// XExactName_getReflection(), +// XServiceInfo_getReflection() +// ); +// return xClass; +// } +//} + +// Methoden von XInterface +//BOOL ResourceService::queryInterface( Uik aUik, Reference< XInterface > & rOut ) +//{ +// if( aUik == XInvocation::getSmartUik() ) +// rOut = (XInvocation*)this; +// else if( aUik == XExactName::getSmartUik() ) +// rOut = (XExactName*)this; +// else if( aUik == XServiceInfo::getSmartUik() ) +// rOut = (XServiceInfo *)this; +// else +// OWeakObject::queryInterface( aUik, rOut ); +// return rOut.is(); +//} +// +// XIdlClassProvider +//Sequence< XIdlClassRef > ResourceService::getIdlClasses() +//{ +// XIdlClassRef x = getStaticIdlClass(); +// return Sequence< XIdlClassRef >( &x, 1 ); +//} + + +// XServiceInfo +OUString ResourceService::getImplementationName() throw() +{ + return getImplementationName_Static(); +} + +// XServiceInfo +BOOL SAL_CALL ResourceService::supportsService(const OUString& ServiceName) throw() +{ + Sequence< OUString > aSNL = getSupportedServiceNames(); + const OUString * pArray = aSNL.getConstArray(); + for( INT32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return TRUE; + return FALSE; +} + +// XServiceInfo +Sequence< OUString > SAL_CALL ResourceService::getSupportedServiceNames(void) throw() +{ + return getSupportedServiceNames_Static(); +} + +// ResourceService +Sequence< OUString > ResourceService::getSupportedServiceNames_Static(void) throw() +{ + Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString::createFromAscii("com.sun.star.resource.VclStringResourceLoader"); + return aSNS; +} + +// ResourceService +Reference< XTypeConverter > ResourceService::getTypeConverter() const +{ + OGuard aGuard( Application::GetSolarMutex() ); + if( xSMgr.is() ) + { + Reference< XTypeConverter > xConv( xSMgr->createInstance( OUString::createFromAscii("com.sun.star.script.Converter" )), UNO_QUERY ); + ((ResourceService*)this)->xTypeConverter = xConv; + } + return xTypeConverter; +} + +// ResourceService +Reference< XInvocation > ResourceService::getDefaultInvocation() const +{ + OGuard aGuard( Application::GetSolarMutex() ); + /* führt zur Zeit noch zu einer rekursion + if( xSMgr.is() ) + { + Reference< XSingleServiceFactory > xFact( xSMgr->createInstance( OUString::createFromAscii("com.sun.star.script.Invocation") ), UNO_QUERY ); + if( xFact.is() ) + { + Sequence< Any > aArgs( 1 ); + Reference< XInterface > xThis( *this ); + aArgs.getArray()[0].set( &xThis, XInterface_Reference< get >lection() ); + Reference< XInvokation > xI( xFact->createInstanceWithArguments( aArgs ), UNO_QUERY ); + ((ResourceService*)this)->xDefaultInvocation = xI; + } + } + */ + return xDefaultInvocation; +} + +// XExactName +OUString SAL_CALL ResourceService::getExactName( const OUString & ApproximateName ) +{ + OUString aName( ApproximateName ); + aName = aName.toLowerCase(); + if( aName == OUString::createFromAscii("filename") ) + return OUString::createFromAscii("FileName"); + else if( aName == OUString::createFromAscii("getstring" )) + return OUString::createFromAscii("getString"); + else if( aName == OUString::createFromAscii("hasstring") ) + return OUString::createFromAscii("hasString"); + Reference< XExactName > xEN( getDefaultInvocation(), UNO_QUERY ); + if( xEN.is() ) + return xEN->getExactName( ApproximateName ); + return OUString(); +} + +// XInvokation +Reference< XIntrospectionAccess > SAL_CALL ResourceService::getIntrospection(void) + throw(RuntimeException) +{ + Reference< XInvocation > xI = getDefaultInvocation(); + if( xI.is() ) + return xI->getIntrospection(); + return Reference< XIntrospectionAccess >(); +} + +// XInvokation +Any SAL_CALL ResourceService::invoke +( + const OUString& FunctionName, + const Sequence< Any >& Params, + Sequence< INT16 >& OutParamIndex, + Sequence< Any >& OutParam +) + throw(IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException) +{ + if( FunctionName == OUString::createFromAscii("getString") || FunctionName == OUString::createFromAscii("hasString" )) + { + if( Params.getLength() != 1 ) + throw IllegalArgumentException(); + INT32 nId; + /**** NEW ****/ + if( !(Params.getConstArray()[0] >>= nId) ) + /**** END NEW ****/ + //if( Params.getConstArray()[0].getReflection()->getTypeClass() == TypeClass_LONG ) + // nId = Params.getConstArray()[0].getINT32(); + //else + { + Reference< XTypeConverter > xC = getTypeConverter(); + if( xC.is() ) + { + /**** NEW ****/ + xC->convertToSimpleType( Params.getConstArray()[0], TypeClass_LONG ) >>= nId; + /**** END NEW ****/ + //nId = xC->convertToSimpleType( Params.getConstArray()[0], TypeClass_LONG ).getINT32(); + } + else + throw CannotConvertException(); + } + if( nId > 0xFFFF || nId < 0 ) + throw IllegalArgumentException(); + + OGuard aGuard( Application::GetSolarMutex() ); + if( FunctionName == OUString::createFromAscii("getString" )) + { + if( !pResMgr ) + throw IllegalArgumentException(); + ResId aId( (USHORT)nId, pResMgr ); + aId.SetRT( RSC_STRING ); + if( pResMgr->IsAvailable( aId ) ) + { + String aStr( aId ); + /**** NEW ****/ +// return makeAny( StringToOUString( aStr, CHARSET_SYSTEM ) ); + return makeAny( OUString( aStr ) ); + /**** END NEW ****/ + //return Any( StringToOWString( aStr, CHARSET_SYSTEM ) ); + } + else + throw IllegalArgumentException(); + } + else //if( FunctionName == OUString::createFromAscii("hasString") ) + { + sal_Bool bRet = sal_False; + if( pResMgr ) + { + ResId aId( (USHORT)nId, pResMgr ); + aId.SetRT( RSC_STRING ); + bRet = pResMgr->IsAvailable( aId ); + } + //return UsrAny( bRet ); + /**** NEW ****/ + return Any( &bRet, getBooleanCppuType() ); + /**** END NEW ****/ + } + } + else + { + Reference< XInvocation > xI = getDefaultInvocation(); + if( xI.is() ) + return xI->invoke( FunctionName, Params, OutParamIndex, OutParam ); + else + throw IllegalArgumentException(); + } + return Any(); +} + +// XInvokation +void SAL_CALL ResourceService::setValue(const OUString& PropertyName, const Any& Value) + throw(UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException) +{ + if( PropertyName == OUString::createFromAscii("FileName") ) + { + OUString aName; + //if( Value.getReflection()->getTypeClass() == TypeClass_STRING ) + // aName = Value.getString(); + //else + /**** NEW ****/ + if( !(Value >>= aName) ) + /**** END NEW ****/ + { + Reference< XTypeConverter > xC = getTypeConverter(); + if( xC.is() ) + xC->convertToSimpleType( Value, TypeClass_STRING ) >>= aName; + //aName = xC->convertToSimpleType( Value, TypeClass_STRING ).getString(); + else + throw CannotConvertException(); + } + + OGuard aGuard( Application::GetSolarMutex() ); + aName = aName + OUString( OUString::valueOf( (INT32)SUPD ).getStr() ); +// ResMgr * pRM = ResMgr::CreateResMgr( OUStringToString( aName, CHARSET_SYSTEM ) ); + String aTmpString( aName ); + ByteString a( aTmpString, gsl_getSystemTextEncoding() ); + ResMgr * pRM = ResMgr::CreateResMgr( a.GetBuffer() ); + if( !pRM ) + throw InvocationTargetException(); + if( pResMgr ) + delete pResMgr; + pResMgr = pRM; + aFileName = aName; + } + else + { + Reference< XInvocation > xI = getDefaultInvocation(); + if( xI.is() ) + xI->setValue( PropertyName, Value ); + else + throw UnknownPropertyException(); + } +} + +// XInvokation +Any SAL_CALL ResourceService::getValue(const OUString& PropertyName) + throw(UnknownPropertyException, RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + if( PropertyName == OUString::createFromAscii("FileName" )) + return makeAny( aFileName ); + else + { + Reference< XInvocation > xI = getDefaultInvocation(); + if( xI.is() ) + return xI->getValue( PropertyName ); + else + throw UnknownPropertyException(); + } + return Any(); +} + +// XInvokation +BOOL SAL_CALL ResourceService::hasMethod(const OUString& Name) + throw(RuntimeException) +{ + if( Name == OUString::createFromAscii("getString") || Name == OUString::createFromAscii("hasString") ) + return TRUE; + else + { + Reference< XInvocation > xI = getDefaultInvocation(); + if( xI.is() ) + return xI->hasMethod( Name ); + else + return FALSE; + } +} + +// XInvokation +BOOL SAL_CALL ResourceService::hasProperty(const OUString& Name) + throw(RuntimeException) +{ + if( Name == OUString::createFromAscii("FileName") ) + return TRUE; + else + { + Reference< XInvocation > xI = getDefaultInvocation(); + if( xI.is() ) + return xI->hasProperty( Name ); + else + return FALSE; + } +} + + +extern "C" { + +// NEW: return the environment type name of the c++ compiler +void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//BOOL EXTERN_SERVICE_CALLTYPE exService_writeRegEntry( +// const UNO_INTERFACE(XRegistryKey)* xUnoKey) +sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, XRegistryKey * pRegistryKey ) +{ + //XRegistryKeyRef pRegistryKey; + //uno2smart(pRegistryKey, *xUnoKey); + /**** NEW ****/ + try + { + Reference< XRegistryKey > xNewKey = + /**** END NEW ****/ + pRegistryKey->createKey( + OUString::createFromAscii( "/" ) + ResourceService::getImplementationName_Static() + OUString::createFromAscii( "/UNO/SERVICES" ) ); + Sequence< OUString > aServices = ResourceService::getSupportedServiceNames_Static(); + for( INT32 i = 0; i < aServices.getLength(); i++ ) + xNewKey->createKey( aServices.getConstArray()[i]); + + return sal_True; + /**** NEW ****/ + } + catch (Exception &) + { + // not allowed to throw an exception over the c function. + //OSL_ENSHURE( sal_False, "Exception cannot register component!" ); + return sal_False; + } + /**** END NEW ****/ + +} + +//UNO_INTERFACE(XInterface) EXTERN_SERVICE_CALLTYPE exService_getFactory +//( +// const sal_Unicode* pImplName, +// const UNO_INTERFACE(XMultiServiceFactory)* pServiceManager, +// const UNO_INTERFACE(XRegistryKey)* +//) +void * SAL_CALL component_getFactory( + const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * /*pRegistryKey*/ ) +{ + //UNO_INTERFACE(XInterface) xUnoRet = {0, 0}; + //XInterfaceRef xRet; + //XMultiServiceFactoryRef xSMgr; + //OUString aImplementationName(pImplName); + //uno2smart(xSMgr, *xUnoFact); + //if (OUString(pImplName) == ResourceService::getpImplName_Static() ) + //{ + // xRet = createSingleFactory( pServiceManager, pImplName, + // ResourceService_CreateInstance, + // ResourceService::getSupportedServiceNames_Static() ); + //} + // + //if (xRet.is()) + //{ + // smart2uno(xRet, xUnoRet); + //} + //return xUnoRet; + + /**** NEW ****/ + void * pRet = 0; + if (!ResourceService::getImplementationName_Static().compareToAscii( pImplName ) ) + { + // create the factory + Reference< XSingleServiceFactory > xFactory = + cppu::createSingleFactory( + pServiceManager, ResourceService::getImplementationName_Static(), + ResourceService_CreateInstance, + ResourceService::getSupportedServiceNames_Static() ); + // acquire, because we return an interface pointer instead of a reference + xFactory->acquire(); + pRet = xFactory.get(); + } + return pRet; + /**** END NEW ****/ +} + +} + diff --git a/extensions/source/scanner/exports.dxp b/extensions/source/scanner/exports.dxp new file mode 100644 index 000000000000..9630d7e06768 --- /dev/null +++ b/extensions/source/scanner/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx new file mode 100644 index 000000000000..789a373b43b6 --- /dev/null +++ b/extensions/source/scanner/grid.cxx @@ -0,0 +1,642 @@ +/************************************************************************* + * + * $RCSfile: grid.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 <grid.hrc> +#include <cstdio> +#include <cmath> +#include <grid.hxx> + +ResId SaneResId( ULONG ); + +/*********************************************************************** + * + * GridWindow + * + ***********************************************************************/ + +// --------------------------------------------------------------------- + +GridWindow::GridWindow( + double* pXValues, double* pYValues, int nValues, + Window* pParent, BOOL bCutValues ) : + ModalDialog( pParent, SaneResId( GRID_DIALOG ) ), + m_aOKButton( this, SaneResId( GRID_DIALOG_OK_BTN ) ), + m_aCancelButton( this, SaneResId( GRID_DIALOG_CANCEL_BTN ) ), + m_aResetTypeBox( this, SaneResId( GRID_DIALOG_TYPE_BOX ) ), + m_aResetButton( this, SaneResId( GRID_DIALOG_RESET_BTN ) ), + m_aGridArea( 50, 15, 100, 100 ), + m_pXValues( pXValues ), + m_pOrigYValues( pYValues ), + m_nValues( nValues ), + m_pNewYValues( NULL ), + m_aIAOManager( this ), + m_pLeftMarker( NULL ), + m_pRightMarker( NULL ), + m_pDragMarker( NULL ), + m_aMarkerBitmap( Bitmap( SaneResId( GRID_DIALOG_HANDLE_BMP ) ), + Color( 255, 255, 255 ) ), + m_bCutValues( bCutValues ) +{ + USHORT nPos = m_aResetTypeBox.InsertEntry( String( SaneResId( RESET_TYPE_LINEAR_ASCENDING ) ) ); + m_aResetTypeBox.SetEntryData( nPos, (void *)RESET_TYPE_LINEAR_ASCENDING ); + + nPos = m_aResetTypeBox.InsertEntry( String( SaneResId( RESET_TYPE_LINEAR_DESCENDING ) ) ); + m_aResetTypeBox.SetEntryData( nPos, (void *)RESET_TYPE_LINEAR_DESCENDING ); + + nPos = m_aResetTypeBox.InsertEntry( String( SaneResId( RESET_TYPE_RESET ) ) ); + m_aResetTypeBox.SetEntryData( nPos, (void *)RESET_TYPE_RESET ); + + nPos = m_aResetTypeBox.InsertEntry( String( SaneResId( RESET_TYPE_EXPONENTIAL ) ) ); + m_aResetTypeBox.SetEntryData( nPos, (void *)RESET_TYPE_EXPONENTIAL ); + + m_aResetTypeBox.SelectEntryPos( 0 ); + + m_aResetButton.SetClickHdl( LINK( this, GridWindow, ClickButtonHdl ) ); + + SetMapMode( MapMode( MAP_PIXEL ) ); + Size aSize = GetOutputSizePixel(); + Size aBtnSize = m_aOKButton.GetOutputSizePixel(); + m_aGridArea.setWidth( aSize.Width() - aBtnSize.Width() - 80 ); + m_aGridArea.setHeight( aSize.Height() - 40 ); + + if( m_pOrigYValues && m_nValues ) + { + m_pNewYValues = new double[ m_nValues ]; + memcpy( m_pNewYValues, m_pOrigYValues, sizeof( double ) * m_nValues ); + } + + setBoundings( 0, 0, 1023, 1023 ); + computeExtremes(); + + m_pLeftMarker = new B2dIAOBitmapExReference( + &m_aIAOManager, + transform( findMinX(), findMinY() ), + &m_aMarkerBitmap, + m_aMarkerBitmap.GetSizePixel().Width()/2, + m_aMarkerBitmap.GetSizePixel().Height()/2 ); + m_pLeftMarker->SetHittable( TRUE ); + m_pRightMarker = new B2dIAOBitmapExReference( + &m_aIAOManager, + transform( findMaxX(), findMaxY() ), + &m_aMarkerBitmap, + m_aMarkerBitmap.GetSizePixel().Width()/2, + m_aMarkerBitmap.GetSizePixel().Height()/2 ); + m_pRightMarker->SetHittable( TRUE ); + + FreeResource(); +} + +// --------------------------------------------------------------------- + +GridWindow::~GridWindow() +{ + if( m_pNewYValues ) + delete m_pNewYValues; +} + +// --------------------------------------------------------------------- + +double GridWindow::findMinX() +{ + if( ! m_pXValues ) + return 0.0; + double fMin = m_pXValues[0]; + for( int i = 1; i < m_nValues; i++ ) + if( m_pXValues[ i ] < fMin ) + fMin = m_pXValues[ i ]; + return fMin; +} + +// --------------------------------------------------------------------- + +double GridWindow::findMinY() +{ + if( ! m_pNewYValues ) + return 0.0; + double fMin = m_pNewYValues[0]; + for( int i = 1; i < m_nValues; i++ ) + if( m_pNewYValues[ i ] < fMin ) + fMin = m_pNewYValues[ i ]; + return fMin; +} + +// --------------------------------------------------------------------- + +double GridWindow::findMaxX() +{ + if( ! m_pXValues ) + return 0.0; + double fMax = m_pXValues[0]; + for( int i = 1; i < m_nValues; i++ ) + if( m_pXValues[ i ] > fMax ) + fMax = m_pXValues[ i ]; + return fMax; +} + +// --------------------------------------------------------------------- + +double GridWindow::findMaxY() +{ + if( ! m_pNewYValues ) + return 0.0; + double fMax = m_pNewYValues[0]; + for( int i = 1; i < m_nValues; i++ ) + if( m_pNewYValues[ i ] > fMax ) + fMax = m_pNewYValues[ i ]; + return fMax; +} + +// --------------------------------------------------------------------- + +void GridWindow::computeExtremes() +{ + if( m_nValues && m_pXValues && m_pOrigYValues ) + { + m_fMaxX = m_fMinX = m_pXValues[0]; + m_fMaxY = m_fMinY = m_pOrigYValues[0]; + for( int i = 1; i < m_nValues; i++ ) + { + if( m_pXValues[ i ] > m_fMaxX ) + m_fMaxX = m_pXValues[ i ]; + else if( m_pXValues[ i ] < m_fMinX ) + m_fMinX = m_pXValues[ i ]; + if( m_pOrigYValues[ i ] > m_fMaxY ) + m_fMaxY = m_pOrigYValues[ i ]; + else if( m_pOrigYValues[ i ] < m_fMinY ) + m_fMinY = m_pOrigYValues[ i ]; + } + setBoundings( m_fMinX, m_fMinY, m_fMaxX, m_fMaxY ); + } +} + +// --------------------------------------------------------------------- + +Point GridWindow::transform( double x, double y ) +{ + Point aRet; + + aRet.X() = ( x - m_fMinX ) * + (double)m_aGridArea.GetWidth() / ( m_fMaxX - m_fMinX ) + + m_aGridArea.Left(); + aRet.Y() = + m_aGridArea.Bottom() - + ( y - m_fMinY ) * + (double)m_aGridArea.GetHeight() / ( m_fMaxY - m_fMinY ); + return aRet; +} + +// --------------------------------------------------------------------- + +void GridWindow::transform( const Point& rOriginal, double& x, double& y ) +{ + x = ( rOriginal.X() - m_aGridArea.Left() ) * (m_fMaxX - m_fMinX) / (double)m_aGridArea.GetWidth() + m_fMinX; + y = ( m_aGridArea.Bottom() - rOriginal.Y() ) * (m_fMaxY - m_fMinY) / (double)m_aGridArea.GetHeight() + m_fMinY; +} + +// --------------------------------------------------------------------- + +void GridWindow::drawPoint( double x, double y ) +{ + DrawPixel( transform( x, y ) ); +} + +// --------------------------------------------------------------------- + +void GridWindow::drawLine( double x1, double y1, double x2, double y2 ) +{ + DrawLine( transform( x1, y1 ), transform( x2, y2 ) ); +} + +// --------------------------------------------------------------------- + +void GridWindow::computeChunk( double fMin, double fMax, double& fChunkOut, double& fMinChunkOut ) +{ + // get a nice chunk size like 10, 100, 25 or such + fChunkOut = ( fMax - fMin ) / 6.0; + int logchunk = (int)log10( fChunkOut ); + int nChunk = (int)( fChunkOut / exp( (double)(logchunk-1) * M_LN10 ) ); + if( nChunk >= 75 ) + nChunk = 100; + else if( nChunk >= 35 ) + nChunk = 50; + else if ( nChunk > 20 ) + nChunk = 25; + else if ( nChunk >= 13 ) + nChunk = 20; + else if( nChunk > 5 ) + nChunk = 10; + else + nChunk = 5; + fChunkOut = (double) nChunk * exp( (double)(logchunk-1) * M_LN10 ); + // compute whole chunks fitting into fMin + nChunk = (int)( fMin / fChunkOut ); + fMinChunkOut = (double)nChunk * fChunkOut; + while( fMinChunkOut < fMin ) + fMinChunkOut += fChunkOut; +} + +// --------------------------------------------------------------------- + +void GridWindow::computeNew() +{ + // special case: only left and right markers + if( m_aIAOManager.GetIAOCount() == 2 ) + { + double xleft, yleft; + double xright, yright; + transform( m_pLeftMarker->GetBasePosition(), xleft, yleft ); + transform( m_pRightMarker->GetBasePosition(), xright, yright ); + double factor = (yright-yleft)/(xright-xleft); + for( int i = 0; i < m_nValues; i++ ) + { + m_pNewYValues[ i ] = yleft + ( m_pXValues[ i ] - xleft )*factor; + } + return; + } + + // X sort markers + int nMarkers = m_aIAOManager.GetIAOCount(); + int nSorted = 0; + B2dIAObject** pList = new B2dIAObject*[ nMarkers ]; + for( B2dIAObject* pMarker = m_aIAOManager.GetIAObjectList(); + pMarker; pMarker = pMarker->GetNext() ) + { + int n = nSorted; + for( int i = 0; i < nSorted; i++ ) + { + if( pList[ i ]->GetBasePosition().X() > pMarker->GetBasePosition().X() ) + { + for( n=nSorted; n > i; n-- ) + pList[ n ] = pList[ n-1 ]; + pList[ i ] = pMarker; + nSorted++; + break; + } + } + if( n >= nSorted ) + pList[ nSorted++ ] = pMarker; + } + + // get node arrays + double* nodex = new double[ nSorted ]; + double* nodey = new double[ nSorted ]; + int i; + + for( i = 0; i < nSorted; i++ ) + transform( pList[ i ]->GetBasePosition(), nodex[ i ], nodey[ i ] ); + + for( i = 0; i < m_nValues; i++ ) + { + double x = m_pXValues[ i ]; + m_pNewYValues[ i ] = interpolate( x, nodex, nodey, nSorted ); + if( m_bCutValues ) + { + if( m_pNewYValues[ i ] > m_fMaxY ) + m_pNewYValues[ i ] = m_fMaxY; + else if( m_pNewYValues[ i ] < m_fMinY ) + m_pNewYValues[ i ] = m_fMinY; + } + } + + delete nodex; + delete nodey; + delete pList; +} + +// --------------------------------------------------------------------- + +double GridWindow::interpolate( + double x, + double* pNodeX, + double* pNodeY, + int nNodes ) +{ + // compute Lagrange interpolation + double ret = 0; + for( int i = 0; i < nNodes; i++ ) + { + double sum = pNodeY[ i ]; + for( int n = 0; n < nNodes; n++ ) + { + if( n != i ) + { + sum *= x - pNodeX[ n ]; + sum /= pNodeX[ i ] - pNodeX[ n ]; + } + } + ret += sum; + } + return ret; +} + +// --------------------------------------------------------------------- + +void GridWindow::setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY ) +{ + m_fMinX = fMinX; + m_fMinY = fMinY; + m_fMaxX = fMaxX; + m_fMaxY = fMaxY; + + computeChunk( m_fMinX, m_fMaxX, m_fChunkX, m_fMinChunkX ); + computeChunk( m_fMinY, m_fMaxY, m_fChunkY, m_fMinChunkY ); +} + +// --------------------------------------------------------------------- + +void GridWindow::drawGrid() +{ + char pBuf[256]; + SetLineColor( Color( COL_BLACK ) ); + TextAlign aAlign = GetTextAlign(); + // draw vertical lines + for( double fX = m_fMinChunkX; fX < m_fMaxX; fX += m_fChunkX ) + { + drawLine( fX, m_fMinY, fX, m_fMaxY ); + // draw tickmarks + Point aPt = transform( fX, m_fMinY ); + sprintf( pBuf, "%g", fX ); + String aMark( pBuf, gsl_getSystemTextEncoding() ); + Size aTextSize( GetTextWidth( aMark ), GetTextHeight() ); + aPt.X() -= aTextSize.Width()/2; + aPt.Y() += aTextSize.Height()/2; + DrawText( aPt, aMark ); + } + // draw horizontal lines + for( double fY = m_fMinChunkY; fY < m_fMaxY; fY += m_fChunkY ) + { + drawLine( m_fMinX, fY, m_fMaxX, fY ); + // draw tickmarks + Point aPt = transform( m_fMinX, fY ); + sprintf( pBuf, "%g", fY ); + String aMark( pBuf, gsl_getSystemTextEncoding() ); + Size aTextSize( GetTextWidth( aMark ), GetTextHeight() ); + aPt.X() -= aTextSize.Width() + 2; + aPt.Y() -= aTextSize.Height()/2; + DrawText( aPt, aMark ); + } + + // draw boundings + drawLine( m_fMinX, m_fMinY, m_fMaxX, m_fMinY ); + drawLine( m_fMinX, m_fMaxY, m_fMaxX, m_fMaxY ); + drawLine( m_fMinX, m_fMinY, m_fMinX, m_fMaxY ); + drawLine( m_fMaxX, m_fMinY, m_fMaxX, m_fMaxY ); +} + +// --------------------------------------------------------------------- + +void GridWindow::drawOriginal() +{ + if( m_nValues && m_pXValues && m_pOrigYValues ) + { + SetLineColor( Color( COL_RED ) ); + for( int i = 0; i < m_nValues-1; i++ ) + { + drawLine( m_pXValues[ i ], m_pOrigYValues[ i ], + m_pXValues[ i+1 ], m_pOrigYValues[ i+1 ] ); + } + } +} + +// --------------------------------------------------------------------- + +void GridWindow::drawNew() +{ + if( m_nValues && m_pXValues && m_pNewYValues ) + { + SetClipRegion( m_aGridArea ); + SetLineColor( Color( COL_YELLOW ) ); + for( int i = 0; i < m_nValues-1; i++ ) + { + drawLine( m_pXValues[ i ], m_pNewYValues[ i ], + m_pXValues[ i+1 ], m_pNewYValues[ i+1 ] ); + } + SetClipRegion(); + } +} + +// --------------------------------------------------------------------- + +void GridWindow::Paint( const Rectangle& rRect ) +{ + ModalDialog::Paint( rRect ); + drawGrid(); + drawOriginal(); + drawNew(); + m_aIAOManager.UpdateDisplay(); +} + +// --------------------------------------------------------------------- + +void GridWindow::MouseMove( const MouseEvent& rEvt ) +{ + if( rEvt.GetButtons() == MOUSE_LEFT && m_pDragMarker ) + { + Point aPoint( rEvt.GetPosPixel() ); + if( m_pDragMarker == m_pLeftMarker || m_pDragMarker == m_pRightMarker ) + { + aPoint.X() = m_pDragMarker->GetBasePosition().X(); + } + if( aPoint.Y() < m_aGridArea.Top() ) + aPoint.Y() = m_aGridArea.Top(); + else if( aPoint.Y() > m_aGridArea.Bottom() ) + aPoint.Y() = m_aGridArea.Bottom(); + // avoid flicker + if( aPoint != m_pDragMarker->GetBasePosition() ) + { + m_pDragMarker->SetBasePosition( aPoint ); + m_aIAOManager.UpdateDisplay(); + } + } + ModalDialog::MouseMove( rEvt ); +} + +// --------------------------------------------------------------------- + +void GridWindow::MouseButtonUp( const MouseEvent& rEvt ) +{ + if( rEvt.GetButtons() == MOUSE_LEFT ) + { + if( m_pDragMarker ) + { + m_pDragMarker = NULL; + computeNew(); + Invalidate( m_aGridArea ); + Paint( m_aGridArea ); + } + } + + ModalDialog::MouseButtonUp( rEvt ); +} + +// --------------------------------------------------------------------- + +void GridWindow::MouseButtonDown( const MouseEvent& rEvt ) +{ + Point aPoint( rEvt.GetPosPixel() ); + B2dIAObject* pMarker = m_aIAOManager.GetIAObjectList(); + while( pMarker && ! pMarker->IsHit( aPoint ) ) + pMarker = pMarker->GetNext(); + + if( rEvt.GetButtons() == MOUSE_LEFT ) + { + // user wants to drag a button + if( pMarker ) + m_pDragMarker = (B2dIAOBitmapExReference*)pMarker; + } + else if( rEvt.GetButtons() == MOUSE_RIGHT ) + { + // user wants to add/delete a button + if( pMarker && pMarker != m_pLeftMarker && pMarker != m_pRightMarker ) + { + // delete marker under mouse + if( m_pDragMarker == pMarker ) + m_pDragMarker = NULL; + delete pMarker; + } + else if( ! pMarker ) + { + pMarker = new B2dIAOBitmapExReference( + &m_aIAOManager, + aPoint, + &m_aMarkerBitmap, + m_aMarkerBitmap.GetSizePixel().Width()/2, + m_aMarkerBitmap.GetSizePixel().Height()/2 ); + pMarker->SetHittable( TRUE ); + } + computeNew(); + Invalidate( m_aGridArea ); + Paint( m_aGridArea ); + } + ModalDialog::MouseButtonDown( rEvt ); +} + +// --------------------------------------------------------------------- + +IMPL_LINK( GridWindow, ClickButtonHdl, Button*, pButton ) +{ + if( pButton == &m_aResetButton ) + { + int nType = (int)m_aResetTypeBox.GetEntryData( m_aResetTypeBox.GetSelectEntryPos() ); + switch( nType ) + { + case RESET_TYPE_LINEAR_ASCENDING: + { + for( int i = 0; i < m_nValues; i++ ) + { + m_pNewYValues[ i ] = m_fMinY + (m_fMaxY-m_fMinY)/(m_fMaxX-m_fMinX)*(m_pXValues[i]-m_fMinX); + } + } + break; + case RESET_TYPE_LINEAR_DESCENDING: + { + for( int i = 0; i < m_nValues; i++ ) + { + m_pNewYValues[ i ] = m_fMaxY - (m_fMaxY-m_fMinY)/(m_fMaxX-m_fMinX)*(m_pXValues[i]-m_fMinX); + } + } + break; + case RESET_TYPE_RESET: + { + if( m_pOrigYValues && m_pNewYValues && m_nValues ) + memcpy( m_pNewYValues, m_pOrigYValues, m_nValues*sizeof(double) ); + } + break; + case RESET_TYPE_EXPONENTIAL: + { + for( int i = 0; i < m_nValues; i++ ) + { + m_pNewYValues[ i ] = m_fMinY + (m_fMaxY-m_fMinY)*(exp((m_pXValues[i]-m_fMinX)/(m_fMaxX-m_fMinX))-1.0)/(M_E-1.0); + } + } + break; + + default: + break; + } + int nMarkers = m_aIAOManager.GetIAOCount(); + B2dIAObject* pMarker = m_aIAOManager.GetIAObjectList(); + for( int i = 0 ; i < nMarkers; i++, pMarker = pMarker->GetNext() ) + { + // find nearest xvalue + double x, y; + transform( pMarker->GetBasePosition(), x, y ); + int nIndex = 0; + double delta = fabs( x-m_pXValues[0] ); + for( int n = 1; n < m_nValues; n++ ) + { + if( delta > fabs( x - m_pXValues[ n ] ) ) + { + delta = fabs( x - m_pXValues[ n ] ); + nIndex = n; + } + } + if( pMarker == m_pLeftMarker ) + pMarker->SetBasePosition( transform( m_fMinX, m_pNewYValues[ nIndex ] ) ); + else if( pMarker == m_pRightMarker ) + pMarker->SetBasePosition( transform( m_fMaxX, m_pNewYValues[ nIndex ] ) ); + else + pMarker->SetBasePosition( transform( m_pXValues[ nIndex ], m_pNewYValues[ nIndex ] ) ); + } + Invalidate( m_aGridArea ); + Paint(Rectangle()); + } + return 0; +} diff --git a/extensions/source/scanner/grid.hrc b/extensions/source/scanner/grid.hrc new file mode 100644 index 000000000000..512f55c11a89 --- /dev/null +++ b/extensions/source/scanner/grid.hrc @@ -0,0 +1,76 @@ +/************************************************************************* + * + * $RCSfile: grid.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 GRID_HRC +#define GRID_HRC + +#define GRID_DIALOG 1100 +#define GRID_DIALOG_OK_BTN 1 +#define GRID_DIALOG_CANCEL_BTN 2 +#define GRID_DIALOG_RESET_BTN 3 +#define GRID_DIALOG_TYPE_BOX 4 +#define GRID_DIALOG_HANDLE_BMP 5 + +#define RESET_TYPE_LINEAR_ASCENDING 10 +#define RESET_TYPE_LINEAR_DESCENDING 11 +#define RESET_TYPE_RESET 12 +#define RESET_TYPE_EXPONENTIAL 13 + +#endif diff --git a/extensions/source/scanner/grid.hxx b/extensions/source/scanner/grid.hxx new file mode 100644 index 000000000000..f5055dbeab94 --- /dev/null +++ b/extensions/source/scanner/grid.hxx @@ -0,0 +1,163 @@ +/************************************************************************* + * + * $RCSfile: grid.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 _EXTENSIONS_SCANNER_GRID_HXX +#define _EXTENSIONS_SCANNER_GRID_HXX + +#ifndef _SV_WINDOW_HXX +#include <vcl/window.hxx> +#endif +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#ifndef _SV_LSTBOX_HXX +#include <vcl/lstbox.hxx> +#endif +#ifndef _SV_DIALOG_HXX +#include <vcl/dialog.hxx> +#endif +#ifndef _B2D_MBASE_HXX +#include <goodies/b2dmbase.hxx> +#endif +#ifndef _B2D_MPNT_HXX +#include <goodies/b2dmbmp.hxx> +#endif + +class GridWindow : public ModalDialog +{ + Rectangle m_aGridArea; + + double m_fMinX; + double m_fMinY; + double m_fMaxX; + double m_fMaxY; + + double m_fChunkX; + double m_fMinChunkX; + double m_fChunkY; + double m_fMinChunkY; + + double* m_pXValues; + double* m_pOrigYValues; + int m_nValues; + double* m_pNewYValues; + + BOOL m_bCutValues; + + // stuff for handles + B2dIAOManager m_aIAOManager; + B2dIAOBitmapExReference* m_pLeftMarker; + B2dIAOBitmapExReference* m_pRightMarker; + B2dIAOBitmapExReference* m_pDragMarker; + + BitmapEx m_aMarkerBitmap; + + OKButton m_aOKButton; + CancelButton m_aCancelButton; + + ListBox m_aResetTypeBox; + PushButton m_aResetButton; + + + Point transform( double x, double y ); + void transform( const Point& rOriginal, double& x, double& y ); + + double findMinX(); + double findMinY(); + double findMaxX(); + double findMaxY(); + + void drawGrid(); + void drawOriginal(); + void drawNew(); + + void computeExtremes(); + void computeChunk( double fMin, double fMax, double& fChunkOut, double& fMinChunkOut ); + void computeNew(); + double interpolate( double x, double* pNodeX, double* pNodeY, int nNodes ); + + DECL_LINK( ClickButtonHdl, Button* ); + + virtual void MouseMove( const MouseEvent& ); + virtual void MouseButtonDown( const MouseEvent& ); + virtual void MouseButtonUp( const MouseEvent& ); +public: + GridWindow( double* pXValues, double* pYValues, int nValues, + Window* pParent, BOOL bCutValues = TRUE ); + ~GridWindow(); + + void setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY ); + double getMinX() { return m_fMinX; } + double getMinY() { return m_fMinY; } + double getMaxX() { return m_fMaxX; } + double getMaxY() { return m_fMaxY; } + + int countValues() { return m_nValues; } + double* getXValues() { return m_pXValues; } + double* getOrigYValues() { return m_pOrigYValues; } + double* getNewYValues() { return m_pNewYValues; } + + void drawPoint( double x, double y ); + void drawLine( double x1, double y1, double x2, double y2 ); + + virtual void Paint( const Rectangle& rRect ); +}; + +#endif // _EXTENSIONS_SCANNER_GRID_HXX diff --git a/extensions/source/scanner/grid.src b/extensions/source/scanner/grid.src new file mode 100644 index 000000000000..98b50fa48145 --- /dev/null +++ b/extensions/source/scanner/grid.src @@ -0,0 +1,211 @@ +/************************************************************************* + * + * $RCSfile: grid.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 <grid.hrc> + +ModalDialog GRID_DIALOG +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( 10 , 10 ) ; + Size = MAP_APPFONT ( 300, 200 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + + OKButton GRID_DIALOG_OK_BTN + { + Pos = MAP_APPFONT( 245, 5 ); + Size = MAP_APPFONT( 50, 15 ); + DefButton = TRUE; + }; + CancelButton GRID_DIALOG_CANCEL_BTN + { + Pos = MAP_APPFONT ( 245 , 25 ) ; + Size = MAP_APPFONT ( 50 , 15 ) ; + }; + ListBox GRID_DIALOG_TYPE_BOX + { + Border = TRUE ; + Dropdown = TRUE ; + Pos = MAP_APPFONT( 245, 45 ); + Size = MAP_APPFONT( 50, 130 ); + }; + PushButton GRID_DIALOG_RESET_BTN + { + Pos = MAP_APPFONT( 245, 65 ); + Size = MAP_APPFONT( 50, 15 ); + Text = "Setzen"; + Text [ English ] = "Set"; + Text[ english_us ] = "Set"; + Text[ portuguese ] = "Definir"; + Text[ russian ] = "Óñòàíîâèòü"; + Text[ greek ] = "Ïñéóìüò"; + Text[ dutch ] = "Zetten"; + Text[ french ] = "Restaurer"; + Text[ spanish ] = "Definir"; + Text[ italian ] = "Imposta"; + Text[ danish ] = "Definer"; + Text[ swedish ] = "Definiera"; + Text[ polish ] = "OsadŸ"; + Text[ portuguese_brazilian ] = "Set"; + Text[ japanese ] = "Ý’è"; + Text[ korean ] = "ÁöÁ¤"; + Text[ chinese_simplified ] = "É趨"; + Text[ chinese_traditional ] = "«ü©w"; + Text[ arabic ] = "ÊÚííä"; + Text[ turkish ] = "Tanýmla"; + }; + Bitmap GRID_DIALOG_HANDLE_BMP + { + File = "handle.bmp"; + }; + String RESET_TYPE_LINEAR_ASCENDING + { + Text = "Linear steigend"; + Text [ English ] = "Linear ascending"; + Text[ english_us ] = "Linear ascending"; + Text[ portuguese ] = "Linear crescente"; + Text[ russian ] = "Ëèíåéíîå âîçðàñòàíèå"; + Text[ greek ] = "ÃñáììéêÞ áýîçóç"; + Text[ dutch ] = "Lineair stijgend"; + Text[ french ] = "Croissance linéaire"; + Text[ spanish ] = "Lineal ascendente"; + Text[ italian ] = "Lineare crescente"; + Text[ danish ] = "Lineær stigende"; + Text[ swedish ] = "Linjärt stigande"; + Text[ polish ] = "Wzrastaj¹ce linearnie"; + Text[ portuguese_brazilian ] = "Linear ascending"; + Text[ japanese ] = "‚Ü‚Á‚·‚®ã¸"; + Text[ korean ] = "¿À¸§Â÷¼ø ¼±Çü"; + Text[ chinese_simplified ] = "ÏßÐÔÉÏÉý"; + Text[ chinese_traditional ] = "½u©Ê¤Wª@"; + Text[ arabic ] = "ÎØí ÊÕÇÚÏí"; + Text[ turkish ] = "Doðrusal artýþ"; + }; + String RESET_TYPE_LINEAR_DESCENDING + { + Text = "Linear fallend"; + Text [ English ] = "Linear descending"; + Text[ english_us ] = "Linear descending"; + Text[ portuguese ] = "Linear decrescente"; + Text[ russian ] = "Ëèíåéíîå óáûâàíèå"; + Text[ greek ] = "ÃñáììéêÞ ìåßùóç"; + Text[ dutch ] = "Lineair dalend"; + Text[ french ] = "Décroissance linéaire"; + Text[ spanish ] = "Lineal descendente"; + Text[ italian ] = "Lineare descrescente"; + Text[ danish ] = "Lineær faldende"; + Text[ swedish ] = "Linjärt fallande"; + Text[ polish ] = "Spadaj¹ce linearnie"; + Text[ portuguese_brazilian ] = "Linear descending"; + Text[ japanese ] = "‚Ü‚Á‚·‚®‰º~"; + Text[ korean ] = "³»¸²Â÷¼ø ¼±Çü"; + Text[ chinese_simplified ] = "ÏßÐÔϽµ"; + Text[ chinese_traditional ] = "½u©Ê¤U°"; + Text[ arabic ] = "ÎØí ÊäÇÒáí"; + Text[ turkish ] = "Doðrusal düþüþ"; + }; + String RESET_TYPE_RESET + { + Text = "Originalwerte"; + Text [ English ] = "Original values"; + Text[ english_us ] = "Original values"; + Text[ portuguese ] = "Valores originais"; + Text[ russian ] = "Èñõîäíûå çíà÷åíèÿ"; + Text[ greek ] = "Áñ÷éêÝò ôéìÝò"; + Text[ dutch ] = "Oorspronkelijke waarden"; + Text[ french ] = "Restaurer les valeurs d'origine"; + Text[ spanish ] = "Valores originales"; + Text[ italian ] = "Valori originali"; + Text[ danish ] = "Originalværdier"; + Text[ swedish ] = "Originalvärden"; + Text[ polish ] = "Wartoœci oryginalne"; + Text[ portuguese_brazilian ] = "Original values"; + Text[ japanese ] = "µØ¼ÞÅÙ’l"; + Text[ korean ] = "¿ø·¡°ª"; + Text[ chinese_simplified ] = "ÔʼÊýÖµ"; + Text[ chinese_traditional ] = "ì©lÈ"; + Text[ arabic ] = "ÇáÞíã ÇáÃÕáíÉ"; + Text[ turkish ] = "Asýl deðerler"; + }; + String RESET_TYPE_EXPONENTIAL + { + Text = "Exponentiell wachsend"; + Text [ English ] = "Exponential raise"; + Text[ english_us ] = "Exponential increasing"; + Text[ portuguese ] = "Exponencial crescente"; + Text[ russian ] = "Ýêñïîíåíöèàëüíîå âîçðàñòàíèå"; + Text[ greek ] = "ÅêèåôéêÞ áýîçóç"; + Text[ dutch ] = "Exponentiele groei"; + Text[ french ] = "Croissance exponentielle"; + Text[ spanish ] = "Exponencial aumentando"; + Text[ italian ] = "Esponenziale crescente"; + Text[ danish ] = "Eksponentiel vækst"; + Text[ swedish ] = "Exponentiellt växande"; + Text[ polish ] = "Rosn¹ce wyk³adniczo"; + Text[ portuguese_brazilian ] = "Exponential raise"; + Text[ japanese ] = "‹}Œƒ‚É‘‚â‚·"; + Text[ korean ] = "¿À¸§ Áö¼ö"; + Text[ chinese_simplified ] = "Ö¸ÊýÐÍÔö³¤"; + Text[ chinese_traditional ] = "¾¼Æ¦¡»¼¼W"; + Text[ arabic ] = "ÊÒÇíÏ ÃÓí"; + Text[ turkish ] = "Üstel artýþ"; + }; +}; diff --git a/extensions/source/scanner/makefile.mk b/extensions/source/scanner/makefile.mk new file mode 100644 index 000000000000..1e5742ecbb8d --- /dev/null +++ b/extensions/source/scanner/makefile.mk @@ -0,0 +1,147 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ +# +# 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=extensions +TARGET=scn +ENABLE_EXCEPTIONS=TRUE +PACKAGE=com$/sun$/star$/scanner +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb +USE_DEFFILE=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- UnoTypes ----------------------------------------------------- + +UNOTYPES=\ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XInterface \ + com.sun.star.uno.Exception \ + com.sun.star.uno.RuntimeException \ + com.sun.star.uno.XWeak \ + com.sun.star.awt.XBitmap \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.lang.EventObject \ + com.sun.star.registry.XImplementationRegistration \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.registry.XSimpleRegistry \ + com.sun.star.scanner.XScannerManager \ + com.sun.star.scanner.ScannerContext \ + com.sun.star.scanner.ScannerException + +# --- Files -------------------------------------------------------- + +SLOFILES=\ + $(SLO)$/scnserv.obj \ + $(SLO)$/scanner.obj + +.IF "$(GUI)"=="WNT" +SLOFILES+=\ + $(SLO)$/scanwin.obj +.ENDIF + +.IF "$(GUI)"=="UNX" +SLOFILES+=\ + $(SLO)$/sane.obj \ + $(SLO)$/sanedlg.obj \ + $(SLO)$/scanunx.obj \ + $(SLO)$/grid.obj + +SRCFILES=\ + sanedlg.src \ + grid.src + +RESLIB1NAME=san +RESLIB1SRSFILES= $(SRS)/scn.srs +RESLIB1DEPN= sanedlg.src sanedlg.hrc grid.src grid.hrc +.ENDIF + +SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(SALLIB) \ + $(ONELIB) \ + $(TOOLSLIB) \ + $(VCLLIB) \ + $(SVTOOLLIB) \ + $(GOODIESLIB) + +.IF "$(GUI)"=="UNX" +SHL1STDLIBS+=$(SVTOOLLIB) +.ENDIF + +SHL1DEF=$(MISC)$/$(SHL1TARGET).def +SHL1IMPLIB=i$(TARGET) +SHL1LIBS=$(SLB)$/$(TARGET).lib + +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE=exports.dxp + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/extensions/source/scanner/sane.cxx b/extensions/source/scanner/sane.cxx new file mode 100644 index 000000000000..afb3b2276c9c --- /dev/null +++ b/extensions/source/scanner/sane.cxx @@ -0,0 +1,979 @@ +/************************************************************************* + * + * $RCSfile: sane.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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/stream.hxx> +#include <sane.hxx> +#include <dlfcn.h> +#include <stdio.h> +#include <unistd.h> +#include <sys/time.h> +#include <sys/types.h> + +#if defined DEBUG || defined DBG_UTIL +#include <stdarg.h> +#define dump_state( a, b, c, d ) fprintf( stderr, a, b, c, d ); +#else +#define dump_state( a, b, c, d ) ; +#endif +inline void dbg_msg( char* pString, ... ) +{ +#if defined DEBUG || defined DBG_UTIL + va_list ap; + va_start( ap, pString ); + vfprintf( stderr, pString, ap ); + va_end( ap ); +#endif +} + +#define FAIL_SHUTDOWN_STATE( x, y, z ) \ + if( x != SANE_STATUS_GOOD ) \ + { \ + dump_state( "%s returned error %d (%s)\n", \ + y, x, p_strstatus( x ) ); \ + DeInit(); \ + return z; \ + } + +#define FAIL_STATE( x, y, z ) \ + if( x != SANE_STATUS_GOOD ) \ + { \ + dump_state( "%s returned error %d (%s)\n", \ + y, x, p_strstatus( x ) ); \ + return z; \ + } + +#define DUMP_STATE( x, y ) \ + if( x != SANE_STATUS_GOOD ) \ + { \ + dump_state( "%s returned error %d (%s)\n", \ + y, x, p_strstatus( x ) ); \ + } + +#define CHECK_STATE( x, y ) \ + if( x != SANE_STATUS_GOOD ) \ + { \ + dump_state( "%s returned error %d (%s)\n", \ + y, x, p_strstatus( x ) ); \ + } \ + else + +int Sane::nRefCount = 0; +void* Sane::pSaneLib = 0; +SANE_Int Sane::nVersion = 0; +SANE_Device** Sane::ppDevices = 0; +int Sane::nDevices = 0; + +SANE_Status (*Sane::p_init)( SANE_Int*, + SANE_Auth_Callback ) = 0; +void (*Sane::p_exit)() = 0; +SANE_Status (*Sane::p_get_devices)( const SANE_Device***, + SANE_Bool ) = 0; +SANE_Status (*Sane::p_open)( SANE_String_Const, SANE_Handle ) = 0; +void (*Sane::p_close)( SANE_Handle ) = 0; +const SANE_Option_Descriptor* (*Sane::p_get_option_descriptor)( + SANE_Handle, SANE_Int ) = 0; +SANE_Status (*Sane::p_control_option)( SANE_Handle, SANE_Int, + SANE_Action, void*, + SANE_Int* ) = 0; +SANE_Status (*Sane::p_get_parameters)( SANE_Handle, + SANE_Parameters* ) = 0; +SANE_Status (*Sane::p_start)( SANE_Handle ) = 0; +SANE_Status (*Sane::p_read)( SANE_Handle, SANE_Byte*, SANE_Int, + SANE_Int* ) = 0; +void (*Sane::p_cancel)( SANE_Handle ) = 0; +SANE_Status (*Sane::p_set_io_mode)( SANE_Handle, SANE_Bool ) = 0; +SANE_Status (*Sane::p_get_select_fd)( SANE_Handle, SANE_Int* ) = 0; +const SANE_String_Const (*Sane::p_strstatus)( SANE_Status ) = 0; + +static BOOL bSaneSymbolLoadFailed = FALSE; + +inline void* Sane::LoadSymbol( char* pSymbolname ) +{ + void *pRet = dlsym( pSaneLib, pSymbolname ); + if( ! pRet ) + { + fprintf( stderr, "Could not load symbol %s: %s\n", + pSymbolname, dlerror() ); + bSaneSymbolLoadFailed = TRUE; + } + return pRet; +} + +SANE_Status Sane::ControlOption( int nOption, SANE_Action nAction, + void* pData ) +{ + SANE_Status nStatus = SANE_STATUS_GOOD; + SANE_Int nInfo = 0; + + nStatus = p_control_option( maHandle, (SANE_Int)nOption, + nAction, pData, &nInfo ); + DUMP_STATE( nStatus, "sane_control_option" ); +#ifdef DEBUG + if( nStatus != SANE_STATUS_GOOD ) + { + char* pAction = "Unknown"; + switch( nAction ) + { + case SANE_ACTION_GET_VALUE: + pAction = "SANE_ACTION_GET_VALUE";break; + case SANE_ACTION_SET_VALUE: + pAction = "SANE_ACTION_SET_VALUE";break; + case SANE_ACTION_SET_AUTO: + pAction = "SANE_ACTION_SET_AUTO";break; + } + dbg_msg( "Option: \"%s\" action: %s\n", + ByteString( GetOptionName( nOption ), gsl_getSystemTextEncoding() ).GetBuffer(), + pAction ); + } +#endif +// if( nInfo & ( SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS ) ) + if( nInfo & SANE_INFO_RELOAD_OPTIONS ) + ReloadOptions(); + return nStatus; +} + +Sane::Sane() : + maHandle( 0 ), + mppOptions( 0 ), + mnOptions( 0 ), + mnDevice( -1 ) +{ + if( ! nRefCount || ! pSaneLib ) + Init(); + nRefCount++; +}; + +Sane::~Sane() +{ + if( IsOpen() ) + Close(); + nRefCount--; + if( ! nRefCount && pSaneLib ) + DeInit(); +} + +void Sane::Init() +{ + pSaneLib = dlopen( "libsane.so", RTLD_LAZY ); + if( pSaneLib ) + { + bSaneSymbolLoadFailed = FALSE; + p_init = (SANE_Status(*)(SANE_Int*, SANE_Auth_Callback )) + LoadSymbol( "sane_init" ); + p_exit = (void(*)()) + LoadSymbol( "sane_exit" ); + p_get_devices = (SANE_Status(*)(const SANE_Device***, + SANE_Bool )) + LoadSymbol( "sane_get_devices" ); + p_open = (SANE_Status(*)(SANE_String_Const, SANE_Handle )) + LoadSymbol( "sane_open" ); + p_close = (void(*)(SANE_Handle)) + LoadSymbol( "sane_close" ); + p_get_option_descriptor = (const SANE_Option_Descriptor*(*)(SANE_Handle, + SANE_Int)) + LoadSymbol( "sane_get_option_descriptor" ); + p_control_option = (SANE_Status(*)(SANE_Handle, SANE_Int, + SANE_Action, void*, SANE_Int*)) + LoadSymbol( "sane_control_option" ); + p_get_parameters = (SANE_Status(*)(SANE_Handle,SANE_Parameters*)) + LoadSymbol( "sane_get_parameters" ); + p_start = (SANE_Status(*)(SANE_Handle)) + LoadSymbol( "sane_start" ); + p_read = (SANE_Status(*)(SANE_Handle, SANE_Byte*, + SANE_Int, SANE_Int* )) + LoadSymbol( "sane_read" ); + p_cancel = (void(*)(SANE_Handle)) + LoadSymbol( "sane_cancel" ); + p_set_io_mode = (SANE_Status(*)(SANE_Handle, SANE_Bool)) + LoadSymbol( "sane_set_io_mode" ); + p_get_select_fd = (SANE_Status(*)(SANE_Handle, SANE_Int*)) + LoadSymbol( "sane_get_select_fd" ); + p_strstatus = (const SANE_String_Const(*)(SANE_Status)) + LoadSymbol( "sane_strstatus" ); + if( bSaneSymbolLoadFailed ) + DeInit(); + else + { + SANE_Status nStatus = p_init( &nVersion, 0 ); + FAIL_SHUTDOWN_STATE( nStatus, "sane_init", ); + nStatus = p_get_devices( (const SANE_Device***)&ppDevices, + SANE_FALSE ); + FAIL_SHUTDOWN_STATE( nStatus, "sane_get_devices", ); + for( nDevices = 0 ; ppDevices[ nDevices ]; nDevices++ ); + } + } +#if defined DEBUG || defined DBG_UTIL + else + fprintf( stderr, "libsane.so could not be opened: %s\n", + dlerror() ); +#endif +} + +void Sane::DeInit() +{ + if( pSaneLib ) + { + p_exit(); + dlclose( pSaneLib ); + pSaneLib = 0; + } +} + +void Sane::ReloadDevices() +{ + if( IsOpen() ) + Close(); + DeInit(); + Init(); +} + +void Sane::ReloadOptions() +{ + if( ! IsOpen() ) + return; + + SANE_Option_Descriptor* pZero = (SANE_Option_Descriptor*) + p_get_option_descriptor( maHandle, 0 ); + SANE_Word pOptions[2]; + SANE_Status nStatus = p_control_option( maHandle, 0, SANE_ACTION_GET_VALUE, + (void*)pOptions, NULL ); + if( nStatus != SANE_STATUS_GOOD ) + fprintf( stderr, "Error: sane driver returned %s while reading number of options !\n", p_strstatus( nStatus ) ); + + mnOptions = pOptions[ 0 ]; + if( pZero->size > sizeof( SANE_Word ) ) + fprintf( stderr, "driver returned numer of options with larger size tha SANE_Word !!!\n" ); + if( mppOptions ) + delete mppOptions; + mppOptions = (const SANE_Option_Descriptor**)new SANE_Option_Descriptor*[ mnOptions ]; + mppOptions[ 0 ] = (SANE_Option_Descriptor*)pZero; + for( int i = 1; i < mnOptions; i++ ) + mppOptions[ i ] = (SANE_Option_Descriptor*) + p_get_option_descriptor( maHandle, i ); + + CheckConsistency( NULL, TRUE ); + + maReloadOptionsLink.Call( this ); +} + +BOOL Sane::Open( const char* name ) +{ + int i; + + SANE_Status nStatus = p_open( (SANE_String_Const)name, &maHandle ); + FAIL_STATE( nStatus, "sane_open", FALSE ); + + ReloadOptions(); + + if( mnDevice == -1 ) + { + ByteString aDevice( name ); + for( i = 0; i < nDevices; i++ ) + { + if( aDevice.Equals( ppDevices[i]->name ) ) + { + mnDevice = i; + break; + } + } + } + + return TRUE; +} + +BOOL Sane::Open( int n ) +{ + if( n >= 0 && n < nDevices ) + { + mnDevice = n; + return Open( (char*)ppDevices[n]->name ); + } + return FALSE; +} + +void Sane::Close() +{ + if( maHandle ) + { + p_close( maHandle ); + delete mppOptions; + mppOptions = 0; + maHandle = 0; + mnDevice = -1; + } +} + +void Sane::Stop() +{ + if( maHandle ) + { + int nDevice = mnDevice; + Close(); + Open( nDevice ); + } +} + +int Sane::GetOptionByName( const char* rName ) +{ + int i; + ByteString aOption( rName ); + for( i = 0; i < mnOptions; i++ ) + { + if( mppOptions[i]->name && aOption.Equals( mppOptions[i]->name ) ) + return i; + } + return -1; +} + +BOOL Sane::GetOptionValue( int n, BOOL& rRet ) +{ + if( ! maHandle || mppOptions[n]->type != SANE_TYPE_BOOL ) + return FALSE; + SANE_Word nRet; + SANE_Status nStatus = ControlOption( n, SANE_ACTION_GET_VALUE, &nRet ); + if( nStatus != SANE_STATUS_GOOD ) + return FALSE; + + rRet = nRet; + return TRUE; +} + +BOOL Sane::GetOptionValue( int n, ByteString& rRet ) +{ + BOOL bSuccess = FALSE; + if( ! maHandle || mppOptions[n]->type != SANE_TYPE_STRING ) + return FALSE; + char* pRet = new char[mppOptions[n]->size+1]; + SANE_Status nStatus = ControlOption( n, SANE_ACTION_GET_VALUE, pRet ); + if( nStatus == SANE_STATUS_GOOD ) + { + bSuccess = TRUE; + rRet = pRet; + } + delete pRet; + return bSuccess; +} + +BOOL Sane::GetOptionValue( int n, double& rRet, int nElement ) +{ + BOOL bSuccess = FALSE; + + if( ! maHandle || ( mppOptions[n]->type != SANE_TYPE_INT && + mppOptions[n]->type != SANE_TYPE_FIXED ) ) + return FALSE; + + SANE_Word* pRet = new SANE_Word[mppOptions[n]->size/sizeof(SANE_Word)]; + SANE_Status nStatus = ControlOption( n, SANE_ACTION_GET_VALUE, pRet ); + if( nStatus == SANE_STATUS_GOOD ) + { + bSuccess = TRUE; + if( mppOptions[n]->type == SANE_TYPE_INT ) + rRet = (double)pRet[ nElement ]; + else + rRet = SANE_UNFIX( pRet[nElement] ); + } + delete pRet; + return bSuccess; +} + +BOOL Sane::GetOptionValue( int n, double* pSet ) +{ + if( ! maHandle || ! ( mppOptions[n]->type == SANE_TYPE_FIXED || + mppOptions[n]->type == SANE_TYPE_INT ) ) + return FALSE; + + SANE_Word* pFixedSet = new SANE_Word[mppOptions[n]->size/sizeof(SANE_Word)]; + SANE_Status nStatus = ControlOption( n, SANE_ACTION_GET_VALUE, pFixedSet ); + if( nStatus != SANE_STATUS_GOOD ) + { + delete pFixedSet; + return FALSE; + } + for( int i = 0; i <mppOptions[n]->size/sizeof(SANE_Word); i++ ) + { + if( mppOptions[n]->type == SANE_TYPE_FIXED ) + pSet[i] = SANE_UNFIX( pFixedSet[i] ); + else + pSet[i] = (double) pFixedSet[i]; + } + delete pFixedSet; + return TRUE; +} + +BOOL Sane::SetOptionValue( int n, BOOL bSet ) +{ + if( ! maHandle || mppOptions[n]->type != SANE_TYPE_BOOL ) + return FALSE; + SANE_Word nRet = bSet ? SANE_TRUE : SANE_FALSE; + SANE_Status nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, &nRet ); + if( nStatus != SANE_STATUS_GOOD ) + return FALSE; + return TRUE; +} + +BOOL Sane::SetOptionValue( int n, const String& rSet ) +{ + if( ! maHandle || mppOptions[n]->type != SANE_TYPE_STRING ) + return FALSE; + ByteString aSet( rSet, gsl_getSystemTextEncoding() ); + SANE_Status nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, (void*)aSet.GetBuffer() ); + if( nStatus != SANE_STATUS_GOOD ) + return FALSE; + return TRUE; +} + +BOOL Sane::SetOptionValue( int n, double fSet, int nElement ) +{ + BOOL bSuccess = FALSE; + + if( ! maHandle || ( mppOptions[n]->type != SANE_TYPE_INT && + mppOptions[n]->type != SANE_TYPE_FIXED ) ) + return FALSE; + + SANE_Status nStatus; + if( mppOptions[n]->size/sizeof(SANE_Word) > 1 ) + { + SANE_Word* pSet = new SANE_Word[mppOptions[n]->size/sizeof(SANE_Word)]; + nStatus = ControlOption( n, SANE_ACTION_GET_VALUE, pSet ); + if( nStatus == SANE_STATUS_GOOD ) + { + pSet[nElement] = mppOptions[n]->type == SANE_TYPE_INT ? + (SANE_Word)fSet : SANE_FIX( fSet ); + nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, pSet ); + } + delete pSet; + } + else + { + SANE_Word nSetTo = + mppOptions[n]->type == SANE_TYPE_INT ? + nSetTo = (SANE_Word)fSet : nSetTo = SANE_FIX( fSet ); + + nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, &nSetTo ); + if( nStatus == SANE_STATUS_GOOD ) + bSuccess = TRUE; + } + return bSuccess; +} + +BOOL Sane::SetOptionValue( int n, double* pSet ) +{ + if( ! maHandle || ( mppOptions[n]->type != SANE_TYPE_INT && + mppOptions[n]->type != SANE_TYPE_FIXED ) ) + return FALSE; + SANE_Word* pFixedSet = new SANE_Word[mppOptions[n]->size/sizeof(SANE_Word)]; + for( int i = 0; i <mppOptions[n]->size/sizeof(SANE_Word); i++ ) + { + if( mppOptions[n]->type == SANE_TYPE_FIXED ) + pFixedSet[i] = SANE_FIX( pSet[i] ); + else + pFixedSet[i] = (SANE_Word)pSet[i]; + } + SANE_Status nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, pFixedSet ); + delete pFixedSet; + if( nStatus != SANE_STATUS_GOOD ) + return FALSE; + return TRUE; +} + +enum FrameStyleType { + FrameStyle_BW, FrameStyle_Gray, FrameStyle_RGB, FrameStyle_Separated +}; + +#define BYTE_BUFFER_SIZE 32768 + +static inline UINT8 _ReadValue( FILE* fp, int depth ) +{ + if( depth == 16 ) + { + UINT16 nWord; + // data always come in native byte order ! + // 16 bits is not really supported by backends as of now + // e.g. UMAX Astra 1200S delivers 16 bit but in BIGENDIAN + // against SANE documentation (xscanimage gets the same result + // as we do + fread( &nWord, 1, 2, fp ); + return (UINT8)( nWord / 256 ); + } + UINT8 nByte; + fread( &nByte, 1, 1, fp ); + return nByte; +} + +BOOL Sane::CheckConsistency( const char* pMes, BOOL bInit ) +{ + static SANE_Option_Descriptor** pDescArray = NULL; + static SANE_Option_Descriptor* pZero = NULL; + + if( bInit ) + { + pDescArray = (SANE_Option_Descriptor**)mppOptions; + if( mppOptions ) + pZero = (SANE_Option_Descriptor*)mppOptions[0]; + return TRUE; + } + + BOOL bConsistent = TRUE; + + if( pDescArray != mppOptions ) + bConsistent = FALSE; + if( pZero != mppOptions[0] ) + bConsistent = FALSE; + + if( ! bConsistent ) + dbg_msg( "Sane is not consistent. (%s)\n", pMes ); + + return bConsistent; +} + +BOOL Sane::Start( BitmapTransporter& rBitmap ) +{ + int nStream = 0, nLine = 0, i = 0; + SANE_Parameters aParams; + FrameStyleType eType = FrameStyle_Gray; + BOOL bSuccess = TRUE; + BOOL bWidthSet = FALSE; + + if( ! maHandle ) + return FALSE; + + BYTE* pBuffer = NULL; + + SANE_Status nStatus = SANE_STATUS_GOOD; + + rBitmap.lock(); + SvMemoryStream& aConverter = rBitmap.getStream(); + aConverter.Seek( 0 ); + aConverter.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + + // write bitmap stream header + aConverter << 'B' << 'M'; + aConverter << (ULONG) 0; + aConverter << (ULONG) 0; + aConverter << (ULONG) 60; + + // write BITMAPINFOHEADER + aConverter << (UINT32)40; + aConverter << (UINT32)0; // fill in width later + aConverter << (UINT32)0; // fill in height later + aConverter << (UINT16)1; + // create header for 24 bits + // correct later if necessary + aConverter << (UINT16)24; + aConverter << (UINT32)0; + aConverter << (UINT32)0; + aConverter << (UINT32)0; + aConverter << (UINT32)0; + aConverter << (UINT32)0; + aConverter << (UINT32)0; + + for( nStream=0; nStream < 3 && bSuccess ; nStream++ ) + { + nStatus = p_start( maHandle ); + DUMP_STATE( nStatus, "sane_start" ); + CheckConsistency( "sane_start" ); + if( nStatus == SANE_STATUS_GOOD ) + { + nStatus = p_get_parameters( maHandle, &aParams ); + DUMP_STATE( nStatus, "sane_get_parameters" ); + CheckConsistency( "sane_get_parameters" ); +#if defined DEBUG || defined DBG_UTIL + char* ppFormats[] = { "SANE_FRAME_GRAY", "SANE_FRAME_RGB", + "SANE_FRAME_RED", "SANE_FRAME_GREEN", + "SANE_FRAME_BLUE", "Unknown !!!" }; + fprintf( stderr, "Parameters for frame %d:\n", nStream ); + if( aParams.format < 0 || aParams.format > 4 ) + aParams.format = (SANE_Frame)5; + fprintf( stderr, "format: %s\n", ppFormats[ (int)aParams.format ] ); + fprintf( stderr, "last_frame: %s\n", aParams.last_frame ? "TRUE" : "FALSE" ); + fprintf( stderr, "depth: %d\n", (int)aParams.depth ); + fprintf( stderr, "pixels_per_line: %d\n", (int)aParams.pixels_per_line ); + fprintf( stderr, "bytes_per_line: %d\n", (int)aParams.bytes_per_line ); +#endif + if( ! pBuffer ) + { + pBuffer = new BYTE[ BYTE_BUFFER_SIZE < 4*aParams.bytes_per_line ? 4*aParams.bytes_per_line : BYTE_BUFFER_SIZE ]; + } + + if( aParams.last_frame ) + nStream=3; + + switch( aParams.format ) + { + case SANE_FRAME_GRAY: + eType = FrameStyle_Gray; + if( aParams.depth == 1 ) + eType = FrameStyle_BW; + break; + case SANE_FRAME_RGB: + eType = FrameStyle_RGB; + break; + case SANE_FRAME_RED: + case SANE_FRAME_GREEN: + case SANE_FRAME_BLUE: + eType = FrameStyle_Separated; + break; + default: + fprintf( stderr, "Warning: unknown frame style !!!\n" ); + } + + BOOL bSynchronousRead = TRUE; + + // should be fail safe, but ... ?? + nStatus = p_set_io_mode( maHandle, SANE_FALSE ); + CheckConsistency( "sane_set_io_mode" ); + if( nStatus != SANE_STATUS_GOOD ) + { + bSynchronousRead = FALSE; + nStatus = p_set_io_mode( maHandle, SANE_TRUE ); + CheckConsistency( "sane_set_io_mode" ); +#if defined DEBUG || defined DBG_UTIL + if( nStatus != SANE_STATUS_GOOD ) + // what ?!? + fprintf( stderr, "Sane::Start: driver is confused\n" ); +#endif + } + + SANE_Int nLen=0; + SANE_Int fd = 0; + + if( ! bSynchronousRead ) + { + nStatus = p_get_select_fd( maHandle, &fd ); + DUMP_STATE( nStatus, "sane_get_select_fd" ); + CheckConsistency( "sane_get_select_fd" ); + if( nStatus != SANE_STATUS_GOOD ) + bSynchronousRead = TRUE; + } + FILE* pFrame = tmpfile(); + if( ! pFrame ) + { + bSuccess = FALSE; + break; + } + do { + if( ! bSynchronousRead ) + { + fd_set fdset; + struct timeval tv; + + FD_ZERO( &fdset ); + FD_SET( (int)fd, &fdset ); + tv.tv_sec = 5; + tv.tv_usec = 0; + if( select( fd+1, &fdset, NULL, NULL, &tv ) == 0 ) + fprintf( stderr, "Timout on sane_read descriptor\n" ); + } + nLen = 0; + nStatus = p_read( maHandle, pBuffer, BYTE_BUFFER_SIZE, &nLen ); + CheckConsistency( "sane_read" ); + if( nLen && ( nStatus == SANE_STATUS_GOOD || + nStatus == SANE_STATUS_EOF ) ) + { + fwrite( pBuffer, 1, nLen, pFrame ); + } + else + DUMP_STATE( nStatus, "sane_read" ); + } while( nStatus == SANE_STATUS_GOOD ); + if( nStatus != SANE_STATUS_EOF ) + { + fclose( pFrame ); + bSuccess = FALSE; + break; + } + + int nFrameLength = ftell( pFrame ); + fseek( pFrame, 0, SEEK_SET ); + UINT32 nWidth = (UINT32) aParams.pixels_per_line; + UINT32 nHeight = (UINT32) (nFrameLength / aParams.bytes_per_line); + if( ! bWidthSet ) + { +#ifdef DEBUG + fprintf( stderr, "set dimensions to %d, %d\n", nWidth, nHeight ); +#endif + aConverter.Seek( 18 ); + aConverter << nWidth; + aConverter << nHeight; + bWidthSet = TRUE; + } + aConverter.Seek(60); + + if( eType == FrameStyle_BW ) + { + aConverter.Seek( 10 ); + aConverter << (ULONG)64; + aConverter.Seek( 28 ); + aConverter << (UINT16) 1; + aConverter.Seek( 54 ); + // write color table + aConverter << (UINT32)0; + aConverter << (UINT16)0xffff; + aConverter << (UINT8)0xff; + aConverter << (UINT8)0; + aConverter.Seek( 64 ); + } + else if( eType == FrameStyle_Gray ) + { + aConverter.Seek( 10 ); + aConverter << (ULONG)1084; + aConverter.Seek( 28 ); + aConverter << (UINT16) 8; + aConverter.Seek( 54 ); + // write color table + for( nLine = 0; nLine < 256; nLine++ ) + { + aConverter << (UINT8)nLine; + aConverter << (UINT8)nLine; + aConverter << (UINT8)nLine; + aConverter << (UINT8)0; + } + aConverter.Seek( 1084 ); + } + + for( nLine = nHeight-1; + nLine >= 0; nLine-- ) + { + fseek( pFrame, nLine * aParams.bytes_per_line, SEEK_SET ); + if( eType == FrameStyle_BW || + ( eType == FrameStyle_Gray && aParams.depth == 8 ) + ) + { + fread( pBuffer, 1, aParams.bytes_per_line, pFrame ); + aConverter.Write( pBuffer, aParams.bytes_per_line ); + } + else if( eType == FrameStyle_Gray ) + { + for( i = 0; i < (aParams.pixels_per_line); i++ ) + { + UINT8 nGray = _ReadValue( pFrame, aParams.depth ); + aConverter << nGray; + } + } + else if( eType == FrameStyle_RGB ) + { + for( i = 0; i < (aParams.pixels_per_line); i++ ) + { + UINT8 nRed, nGreen, nBlue; + nRed = _ReadValue( pFrame, aParams.depth ); + nGreen = _ReadValue( pFrame, aParams.depth ); + nBlue = _ReadValue( pFrame, aParams.depth ); + aConverter << nBlue; + aConverter << nGreen; + aConverter << nRed; + } + } + else if( eType == FrameStyle_Separated ) + { + for( i = 0; i < (aParams.pixels_per_line); i++ ) + { + UINT8 nValue = _ReadValue( pFrame, aParams.depth ); + switch( aParams.format ) + { + case SANE_FRAME_RED: + aConverter.SeekRel( 2 ); + aConverter << nValue; + break; + case SANE_FRAME_GREEN: + aConverter.SeekRel( 1 ); + aConverter << nValue; + aConverter.SeekRel( 1 ); + break; + case SANE_FRAME_BLUE: + aConverter << nValue; + aConverter.SeekRel( 2 ); + break; + } + } + } + int nGap = aConverter.Tell() & 3; + if( nGap ) + aConverter.SeekRel( 4-nGap ); + } + fclose( pFrame ); // deletes tmpfile + if( eType != FrameStyle_Separated ) + break; + } + else + bSuccess = FALSE; + } + // get stream length + aConverter.Seek( STREAM_SEEK_TO_END ); + int nPos = aConverter.Tell(); + + aConverter.Seek( 2 ); + aConverter << (ULONG) nPos+1; + aConverter.Seek( 0 ); + + rBitmap.unlock(); + + if( bSuccess ) + { + // only cancel a successful operation + // sane disrupts memory else + p_cancel( maHandle ); + CheckConsistency( "sane_cancel" ); + } + if( pBuffer ) + delete pBuffer; + + ReloadOptions(); + + + dbg_msg( "Sane::Start returns with %s\n", bSuccess ? "TRUE" : "FALSE" ); + + return bSuccess; +} + +int Sane::GetRange( int n, double*& rpDouble ) +{ + if( mppOptions[n]->constraint_type != SANE_CONSTRAINT_RANGE && + mppOptions[n]->constraint_type != SANE_CONSTRAINT_WORD_LIST ) + { + return -1; + } + + rpDouble = 0; + int nItems, i; + BOOL bIsFixed = mppOptions[n]->type == SANE_TYPE_FIXED ? TRUE : FALSE; + + dbg_msg( "Sane::GetRange of option %s ", mppOptions[n]->name ); + if(mppOptions[n]->constraint_type == SANE_CONSTRAINT_RANGE ) + { + double fMin, fMax, fQuant; + if( bIsFixed ) + { + fMin = SANE_UNFIX( mppOptions[n]->constraint.range->min ); + fMax = SANE_UNFIX( mppOptions[n]->constraint.range->max ); + fQuant = SANE_UNFIX( mppOptions[n]->constraint.range->quant ); + } + else + { + fMin = (double)mppOptions[n]->constraint.range->min; + fMax = (double)mppOptions[n]->constraint.range->max; + fQuant = (double)mppOptions[n]->constraint.range->quant; + } + if( fQuant != 0.0 ) + { + dbg_msg( "quantum range [ %lg ; %lg ; %lg ]\n", + fMin, fQuant, fMax ); + nItems = (int)((fMax - fMin)/fQuant)+1; + rpDouble = new double[ nItems ]; + double fValue = fMin; + for( i = 0; i < nItems; i++, fValue += fQuant ) + rpDouble[i] = fValue; + rpDouble[ nItems-1 ] = fMax; + return nItems; + } + else + { + dbg_msg( "normal range [ %lg %lg ]\n", + fMin, fMax ); + rpDouble = new double[2]; + rpDouble[0] = fMin; + rpDouble[1] = fMax; + return 0; + } + } + else + { + nItems = mppOptions[n]->constraint.word_list[0]; + rpDouble = new double[nItems]; + for( i=0; i<nItems; i++ ) + { + rpDouble[i] = bIsFixed ? + SANE_UNFIX( mppOptions[n]->constraint.word_list[i+1] ) : + (double)mppOptions[n]->constraint.word_list[i+1]; + } + dbg_msg( "worlist [ %lg ... %lg ]\n", + rpDouble[ 0 ], rpDouble[ nItems-1 ] ); + return nItems; + } + + return -1; +} + +static char *ppUnits[] = { + "", + "[Pixel]", + "[Bit]", + "[mm]", + "[DPI]", + "[%]", + "[usec]" +}; + +String Sane::GetOptionUnitName( int n ) +{ + String aText; + SANE_Unit nUnit = mppOptions[n]->unit; + if( nUnit < 0 || nUnit > sizeof( ppUnits )/sizeof( ppUnits[0] ) ) + aText = String::CreateFromAscii( "[unknown units]" ); + else + aText = String( ppUnits[ nUnit ], gsl_getSystemTextEncoding() ); + return aText; +} + +BOOL Sane::ActivateButtonOption( int n ) +{ + SANE_Status nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, NULL ); + if( nStatus != SANE_STATUS_GOOD ) + return FALSE; + return TRUE; +} diff --git a/extensions/source/scanner/sane.hxx b/extensions/source/scanner/sane.hxx new file mode 100644 index 000000000000..12a6d52554ca --- /dev/null +++ b/extensions/source/scanner/sane.hxx @@ -0,0 +1,232 @@ +/************************************************************************* + * + * $RCSfile: sane.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 _SANE_HXX +#define _SANE_HXX + +#include <tools/string.hxx> +#include <vcl/bitmap.hxx> +#include <sane/sane.h> +#include <scanner.hxx> + +// --------------------- +// - BitmapTransporter - +// --------------------- + +class BitmapTransporter : public OWeakObject, AWT::XBitmap +{ + SvMemoryStream m_aStream; + vos::OMutex m_aProtector; + +public: + + BitmapTransporter() {} + virtual ~BitmapTransporter() {} + + + // XInterface + virtual ANY SAL_CALL queryInterface( const Type & rType ) throw( RuntimeException ); + virtual void SAL_CALL acquire() throw( RuntimeException ) { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw( RuntimeException ) { OWeakObject::release(); } + + virtual AWT::Size SAL_CALL getSize(); + virtual SEQ( sal_Int8 ) SAL_CALL getDIB(); + virtual SEQ( sal_Int8 ) SAL_CALL getMaskDIB() { return SEQ( sal_Int8 )(); } + + // Misc + void lock() { m_aProtector.acquire(); } + void unlock() { m_aProtector.release(); } + SvMemoryStream& getStream() { return m_aStream; } +}; + +// -------- +// - Sane - +// -------- + +class Sane +{ +private: + static int nRefCount; + static void* pSaneLib; + + static SANE_Status (*p_init)( SANE_Int*, + SANE_Auth_Callback ); + static void (*p_exit)(); + static SANE_Status (*p_get_devices)( const SANE_Device***, + SANE_Bool ); + static SANE_Status (*p_open)( SANE_String_Const, SANE_Handle ); + static void (*p_close)( SANE_Handle ); + static const SANE_Option_Descriptor* (*p_get_option_descriptor)( + SANE_Handle, SANE_Int ); + static SANE_Status (*p_control_option)( SANE_Handle, SANE_Int, + SANE_Action, void*, + SANE_Int* ); + static SANE_Status (*p_get_parameters)( SANE_Handle, + SANE_Parameters* ); + static SANE_Status (*p_start)( SANE_Handle ); + static SANE_Status (*p_read)( SANE_Handle, SANE_Byte*, SANE_Int, + SANE_Int* ); + static void (*p_cancel)( SANE_Handle ); + static SANE_Status (*p_set_io_mode)( SANE_Handle, SANE_Bool ); + static SANE_Status (*p_get_select_fd)( SANE_Handle, SANE_Int* ); + static const SANE_String_Const (*p_strstatus)( SANE_Status ); + + static SANE_Int nVersion; + static SANE_Device** ppDevices; + static int nDevices; + + const SANE_Option_Descriptor** mppOptions; + int mnOptions; + int mnDevice; + SANE_Handle maHandle; + + Link maReloadOptionsLink; + + inline void* LoadSymbol( char* ); + void Init(); + void DeInit(); + void Stop(); + + SANE_Status ControlOption( int, SANE_Action, void* ); + + BOOL CheckConsistency( const char*, BOOL bInit = FALSE ); + +public: + Sane(); + ~Sane(); + + static BOOL IsSane() + { return pSaneLib ? TRUE : FALSE; } + BOOL IsOpen() + { return maHandle ? TRUE : FALSE; } + static int CountDevices() + { return nDevices; } + static String GetName( int n ) + { return String( ppDevices[n]->name, gsl_getSystemTextEncoding() ); } + static String GetVendor( int n ) + { return String( ppDevices[n]->vendor, gsl_getSystemTextEncoding() ); } + static String GetModel( int n ) + { return String( ppDevices[n]->model, gsl_getSystemTextEncoding() ); } + static String GetType( int n ) + { return String( ppDevices[n]->type, gsl_getSystemTextEncoding() ); } + + String GetOptionName( int n ) + { return String( (char*)mppOptions[n]->name, gsl_getSystemTextEncoding() ); } + String GetOptionTitle( int n ) + { return String( (char*)mppOptions[n]->title, gsl_getSystemTextEncoding() ); } + SANE_Value_Type GetOptionType( int n ) + { return mppOptions[n]->type; } + SANE_Unit GetOptionUnit( int n ) + { return mppOptions[n]->unit; } + String GetOptionUnitName( int n ); + SANE_Int GetOptionCap( int n ) + { return mppOptions[n]->cap; } + SANE_Constraint_Type GetOptionConstraintType( int n ) + { return mppOptions[n]->constraint_type; } + const char** GetStringConstraint( int n ) + { return (const char**)mppOptions[n]->constraint.string_list; } + int GetRange( int, double*& ); + + inline int GetOptionElements( int n ); + int GetOptionByName( const char* ); + BOOL GetOptionValue( int, BOOL& ); + BOOL GetOptionValue( int, ByteString& ); + BOOL GetOptionValue( int, double&, int nElement = 0 ); + BOOL GetOptionValue( int, double* ); + + BOOL SetOptionValue( int, BOOL ); + BOOL SetOptionValue( int, const String& ); + BOOL SetOptionValue( int, double, int nElement = 0 ); + BOOL SetOptionValue( int, double* ); + + BOOL ActivateButtonOption( int ); + + int CountOptions() { return mnOptions; } + int GetDeviceNumber() { return mnDevice; } + + BOOL Open( const char* ); + BOOL Open( int ); + void Close(); + void ReloadDevices(); + void ReloadOptions(); + + BOOL Start( BitmapTransporter& ); + + inline Link SetReloadOptionsHdl( const Link& rLink ); +}; + +inline int Sane::GetOptionElements( int n ) +{ + if( mppOptions[n]->type == SANE_TYPE_FIXED || + mppOptions[n]->type == SANE_TYPE_INT ) + { + return mppOptions[n]->size/sizeof( SANE_Word ); + } + return 1; +} + +inline Link Sane::SetReloadOptionsHdl( const Link& rLink ) +{ + Link aRet = maReloadOptionsLink; + maReloadOptionsLink = rLink; + return aRet; +} + +#endif diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx new file mode 100644 index 000000000000..71199cf2506a --- /dev/null +++ b/extensions/source/scanner/sanedlg.cxx @@ -0,0 +1,1364 @@ +/************************************************************************* + * + * $RCSfile: sanedlg.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 <stdio.h> +#include <stdlib.h> + +#include <vcl/config.hxx> +#include <vcl/msgbox.hxx> +#include <sanedlg.hxx> +#include <sanedlg.hrc> +#include <grid.hxx> + +#define USE_SAVE_STATE +#undef SAVE_ALL_STATES + +ResId SaneResId( ULONG nID ) +{ + static ResMgr* pResMgr = ResMgr::CreateResMgr( "san" MAKE_NUMSTR(SUPD) ); + return ResId( nID, pResMgr ); +} + +SaneDlg::SaneDlg( Window* pParent, Sane& rSane ) : + ModalDialog( pParent, SaneResId( RID_SANE_DIALOG ) ), + mrSane( rSane ), + mpRange( 0 ), + maMapMode( MAP_APPFONT ), + mbIsDragging( FALSE ), + mbDragDrawn( FALSE ), + maOKButton( this, SaneResId( RID_SCAN_OK ) ), + maCancelButton( this, SaneResId( RID_SCAN_CANCEL ) ), + maPreviewButton( this, SaneResId( RID_PREVIEW_BTN ) ), + maDeviceInfoButton( this, SaneResId( RID_DEVICEINFO_BTN ) ), + maPreviewBox( this, SaneResId( RID_PREVIEW_BOX ) ), + maAreaBox( this, SaneResId( RID_SCANAREA_BOX ) ), + maDeviceBoxTxt( this, SaneResId( RID_DEVICE_BOX_TXT ) ), + maScanLeftTxt( this, SaneResId( RID_SCAN_LEFT_TXT ) ), + maScanTopTxt( this, SaneResId( RID_SCAN_TOP_TXT ) ), + maRightTxt( this, SaneResId( RID_SCAN_RIGHT_TXT ) ), + maBottomTxt( this, SaneResId( RID_SCAN_BOTTOM_TXT ) ), + maReslTxt( this, SaneResId( RID_SCAN_RESOLUTION_TXT ) ), + maOptionTitle( this, SaneResId( RID_SCAN_OPTIONTITLE_TXT ) ), + maOptionsTxt( this, SaneResId( RID_SCAN_OPTION_TXT ) ), + maOptionDescTxt( this, SaneResId( RID_SCAN_OPTION_DESC_TXT ) ), + maVectorTxt( this, SaneResId( RID_SCAN_NUMERIC_VECTOR_TXT ) ), + maLeftField( this, SaneResId( RID_SCAN_LEFT_BOX ) ), + maTopField( this, SaneResId( RID_SCAN_TOP_BOX ) ), + maRightField( this, SaneResId( RID_SCAN_RIGHT_BOX ) ), + maBottomField( this, SaneResId( RID_SCAN_BOTTOM_BOX ) ), + maDeviceBox( this, SaneResId( RID_DEVICE_BOX ) ), + maOptionBox( this, SaneResId( RID_SCAN_OPTION_BOX ) ), + maReslBox( this, SaneResId( RID_SCAN_RESOLUTION_BOX ) ), + maBoolCheckBox( this, SaneResId( RID_SCAN_BOOL_OPTION_BOX ) ), + maStringEdit( this, SaneResId( RID_SCAN_STRING_OPTION_EDT ) ), + maQuantumRangeBox( this, SaneResId( RID_SCAN_QUANTUM_RANGE_BOX ) ), + maStringRangeBox( this, SaneResId( RID_SCAN_STRING_RANGE_BOX ) ), + maNumericEdit( this, SaneResId( RID_SCAN_NUMERIC_OPTION_EDT ) ), + maButtonOption( this, SaneResId( RID_SCAN_BUTTON_OPTION_BTN ) ), + maVectorBox( this, SaneResId( RID_SCAN_NUMERIC_VECTOR_BOX ) ), + maAdvancedBox( this, SaneResId( RID_SCAN_ADVANCED_BOX ) ), + maAdvancedTxt( this, SaneResId( RID_SCAN_ADVANCED_TXT ) ) +{ + if( Sane::IsSane() ) + { + InitDevices(); // opens first sane device + DisableOption(); + InitFields(); + } + + maDeviceInfoButton.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) ); + maPreviewButton.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) ); + maButtonOption.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) ); + maDeviceBox.SetSelectHdl( LINK( this, SaneDlg, SelectHdl ) ); + maOptionBox.SetSelectHdl( LINK( this, SaneDlg, OptionsBoxSelectHdl ) ); + maOKButton.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) ); + maCancelButton.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) ); + maBoolCheckBox.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) ); + maStringEdit.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) ); + maNumericEdit.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) ); + maVectorBox.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) ); + maReslBox.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) ); + maStringRangeBox.SetSelectHdl( LINK( this, SaneDlg, SelectHdl ) ); + maQuantumRangeBox.SetSelectHdl( LINK( this, SaneDlg, SelectHdl ) ); + maLeftField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) ); + maRightField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) ); + maTopField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) ); + maBottomField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) ); + maAdvancedBox.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) ); + + maOldLink = mrSane.SetReloadOptionsHdl( LINK( this, SaneDlg, ReloadSaneOptionsHdl ) ); + + maOptionBox.SetNodeBitmaps( + Bitmap( SaneResId( RID_SCAN_BITMAP_PLUS ) ), + Bitmap( SaneResId( RID_SCAN_BITMAP_MINUS ) ) + ); + maOptionBox.SetWindowBits( WB_HASLINES | + WB_HASBUTTONS | + WB_NOINITIALSELECTION | + WB_HASBUTTONSATROOT | + WB_HASLINESATROOT + ); + FreeResource(); +} + +SaneDlg::~SaneDlg() +{ +} + +short SaneDlg::Execute() +{ + if( ! Sane::IsSane() ) + { + ErrorBox aErrorBox( NULL, WB_OK | WB_DEF_OK, + String( SaneResId( RID_SANE_NOSANELIB_TXT ) ) ); + aErrorBox.Execute(); + return FALSE; + } + LoadState(); + return ModalDialog::Execute(); +} + +void SaneDlg::InitDevices() +{ + if( ! Sane::IsSane() ) + return; + + if( mrSane.IsOpen() ) + mrSane.Close(); + mrSane.ReloadDevices(); + maDeviceBox.Clear(); + for( int i = 0; i < Sane::CountDevices(); i++ ) + maDeviceBox.InsertEntry( Sane::GetName( i ) ); + if( Sane::CountDevices() ) + { + mrSane.Open( 0 ); + maDeviceBox.SelectEntry( Sane::GetName( 0 ) ); + + } +} + +void SaneDlg::InitFields() +{ + if( ! Sane::IsSane() ) + return; + + int nOption, i, n, nValue; + double fValue; + BOOL bSuccess = FALSE; + char *ppSpecialOptions[] = { + "resolution", + "tl-x", + "tl-y", + "br-x", + "br-y", + "preview" + }; + + maReslBox.Clear(); + maMinTopLeft = Point( 0, 0 ); + maMaxBottomRight = Point( PREVIEW_WIDTH, PREVIEW_HEIGHT ); + + if( ! mrSane.IsOpen() ) + return; + + // set Resolution + nOption = mrSane.GetOptionByName( "resolution" ); + if( nOption != -1 ) + { + double fRes; + + bSuccess = mrSane.GetOptionValue( nOption, fRes ); + if( bSuccess ) + { + maReslBox.Enable( TRUE ); + + maReslBox.SetValue( (long)fRes ); + double *pDouble = NULL; + nValue = mrSane.GetRange( nOption, pDouble ); + if( nValue > -1 ) + { + if( nValue ) + { + maReslBox.SetMin( (long)pDouble[0] ); + maReslBox.SetMax( (long)pDouble[ nValue-1 ] ); + for( i=0; i<nValue; i++ ) + { + if( i == 0 || i == nValue-1 || ! ( ((int)pDouble[i]) % 20) ) + maReslBox.InsertValue( (long)pDouble[i] ); + } + } + else + { + maReslBox.SetMin( (long)pDouble[0] ); + maReslBox.SetMax( (long)pDouble[1] ); + maReslBox.InsertValue( (long)pDouble[0] ); + maReslBox.InsertValue( (long)pDouble[1] ); + } + if( pDouble ) + delete pDouble; + } + else + maReslBox.Enable( FALSE ); + } + } + else + maReslBox.Enable( FALSE ); + + // set scan area + for( i = 0; i < 4; i++ ) + { + char *pOptionName; + MetricField* pField; + switch( i ) + { + case 0: + pOptionName = "tl-x"; + pField = &maLeftField; + break; + case 1: + pOptionName = "tl-y"; + pField = &maTopField; + break; + case 2: + pOptionName = "br-x"; + pField = &maRightField; + break; + case 3: + pOptionName = "br-y"; + pField = &maBottomField; + } + nOption = mrSane.GetOptionByName( pOptionName ); + bSuccess = FALSE; + if( nOption != -1 ) + { + bSuccess = mrSane.GetOptionValue( nOption, fValue, 0 ); + if( bSuccess ) + { + if( mrSane.GetOptionUnit( nOption ) == SANE_UNIT_MM ) + { + pField->SetUnit( FUNIT_MM ); + pField->SetValue( (int)fValue, FUNIT_MM ); + } + else // SANE_UNIT_PIXEL + { + pField->SetValue( (int)fValue, FUNIT_CUSTOM ); + pField->SetCustomUnitText( String::CreateFromAscii( "Pixel" ) ); + } + switch( i ) { + case 0: maTopLeft.X() = (int)fValue;break; + case 1: maTopLeft.Y() = (int)fValue;break; + case 2: maBottomRight.X() = (int)fValue;break; + case 3: maBottomRight.Y() = (int)fValue;break; + } + } + double *pDouble = NULL; + nValue = mrSane.GetRange( nOption, pDouble ); + if( nValue > -1 ) + { + if( pDouble ) + { + pField->SetMin( (long)pDouble[0] ); + if( nValue ) + pField->SetMax( (long)pDouble[ nValue-1 ] ); + else + pField->SetMax( (long)pDouble[ 1 ] ); + delete pDouble; + } + switch( i ) { + case 0: maMinTopLeft.X() = pField->GetMin();break; + case 1: maMinTopLeft.Y() = pField->GetMin();break; + case 2: maMaxBottomRight.X() = pField->GetMax();break; + case 3: maMaxBottomRight.Y() = pField->GetMax();break; + } + } + else + { + switch( i ) { + case 0: maMinTopLeft.X() = (int)fValue;break; + case 1: maMinTopLeft.Y() = (int)fValue;break; + case 2: maMaxBottomRight.X() = (int)fValue;break; + case 3: maMaxBottomRight.Y() = (int)fValue;break; + } + } + pField->Enable( TRUE ); + } + else + pField->Enable( FALSE ); + } + maTopLeft = GetPixelPos( maTopLeft ); + maBottomRight = GetPixelPos( maBottomRight ); + maPreviewRect = Rectangle( maTopLeft, + Size( maBottomRight.X() - maTopLeft.X(), + maBottomRight.Y() - maTopLeft.Y() ) + ); + // fill OptionBox + maOptionBox.Clear(); + SvLBoxEntry* pParentEntry = 0; + BOOL bGroupRejected = FALSE; + for( i = 1; i < mrSane.CountOptions(); i++ ) + { + String aOption=mrSane.GetOptionName( i ); + BOOL bInsertAdvanced = + mrSane.GetOptionCap( i ) & SANE_CAP_ADVANCED && + ! maAdvancedBox.IsChecked() ? FALSE : TRUE; + if( mrSane.GetOptionType( i ) == SANE_TYPE_GROUP ) + { + if( bInsertAdvanced ) + { + aOption = mrSane.GetOptionTitle( i ); + pParentEntry = maOptionBox.InsertEntry( aOption ); + bGroupRejected = FALSE; + } + else + bGroupRejected = TRUE; + } + else if( aOption.Len() && + ! ( mrSane.GetOptionCap( i ) & + ( + SANE_CAP_HARD_SELECT | + SANE_CAP_INACTIVE + ) ) && + bInsertAdvanced && ! bGroupRejected ) + { + BOOL bIsSpecial = FALSE; + for( n = 0; !bIsSpecial && + n < sizeof(ppSpecialOptions)/sizeof(ppSpecialOptions[0]); n++ ) + { + if( aOption.EqualsAscii( ppSpecialOptions[n] ) ) + bIsSpecial=TRUE; + } + if( ! bIsSpecial ) + { + if( pParentEntry ) + maOptionBox.InsertEntry( aOption, pParentEntry ); + else + maOptionBox.InsertEntry( aOption ); + } + } + } +} + +IMPL_LINK( SaneDlg, ClickBtnHdl, Button*, pButton ) +{ + if( mrSane.IsOpen() ) + { + if( pButton == &maDeviceInfoButton ) + { + String aString( SaneResId( RID_SANE_DEVICEINFO_TXT ) ); + String aSR( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ); + aString.SearchAndReplace( aSR, Sane::GetName( mrSane.GetDeviceNumber() ) ); + aString.SearchAndReplace( aSR, Sane::GetVendor( mrSane.GetDeviceNumber() ) ); + aString.SearchAndReplace( aSR, Sane::GetModel( mrSane.GetDeviceNumber() ) ); + aString.SearchAndReplace( aSR, Sane::GetType( mrSane.GetDeviceNumber() ) ); + InfoBox aInfoBox( this, aString ); + aInfoBox.Execute(); + } + else if( pButton == &maPreviewButton ) + AcquirePreview(); + else if( pButton == &maBoolCheckBox ) + { + mrSane.SetOptionValue( mnCurrentOption, + maBoolCheckBox.IsChecked() ? + (BOOL)TRUE : (BOOL)FALSE ); + } + else if( pButton == &maButtonOption ) + { + mrSane.ActivateButtonOption( mnCurrentOption ); + } + else if( pButton == &maAdvancedBox ) + { + ReloadSaneOptionsHdl( NULL ); + } + } + if( pButton == &maOKButton ) + { + double fRes = (double)maReslBox.GetValue(); + SetAdjustedNumericalValue( "resolution", fRes ); + mrSane.SetReloadOptionsHdl( maOldLink ); + UpdateScanArea( TRUE ); + SaveState(); + EndDialog( mrSane.IsOpen() ? 1 : 0 ); + } + else if( pButton == &maCancelButton ) + { + mrSane.SetReloadOptionsHdl( maOldLink ); + mrSane.Close(); + EndDialog( 0 ); + } + return 0; +} + +IMPL_LINK( SaneDlg, SelectHdl, ListBox*, pListBox ) +{ + if( pListBox == &maDeviceBox && Sane::IsSane() && Sane::CountDevices() ) + { + String aNewDevice = maDeviceBox.GetSelectEntry(); + int nNumber; + if( aNewDevice.Equals( Sane::GetName( nNumber = mrSane.GetDeviceNumber() ) ) ) + { + mrSane.Close(); + mrSane.Open( nNumber ); + InitFields(); + } + } + if( mrSane.IsOpen() ) + { + if( pListBox == &maQuantumRangeBox ) + { + ByteString aValue( maQuantumRangeBox.GetSelectEntry(), gsl_getSystemTextEncoding() ); + double fValue = atof( aValue.GetBuffer() ); + mrSane.SetOptionValue( mnCurrentOption, fValue, mnCurrentElement ); + } + else if( pListBox == &maStringRangeBox ) + { + mrSane.SetOptionValue( mnCurrentOption, maStringRangeBox.GetSelectEntry() ); + } + } + return 0; +} + +IMPL_LINK( SaneDlg, OptionsBoxSelectHdl, SvTreeListBox*, pBox ) +{ + if( pBox == &maOptionBox && Sane::IsSane() ) + { + String aOption = + maOptionBox.GetEntryText( maOptionBox.FirstSelected() ); + int nOption = mrSane.GetOptionByName( ByteString( aOption, gsl_getSystemTextEncoding() ).GetBuffer() ); + if( nOption != -1 && nOption != mnCurrentOption ) + { + DisableOption(); + mnCurrentOption = nOption; + maOptionTitle.SetText( mrSane.GetOptionTitle( mnCurrentOption ) ); + SANE_Value_Type nType = mrSane.GetOptionType( mnCurrentOption ); + SANE_Constraint_Type nConstraint; + switch( nType ) + { + case SANE_TYPE_BOOL: EstablishBoolOption();break; + case SANE_TYPE_STRING: + nConstraint = mrSane.GetOptionConstraintType( mnCurrentOption ); + if( nConstraint == SANE_CONSTRAINT_STRING_LIST ) + EstablishStringRange(); + else + EstablishStringOption(); + break; + case SANE_TYPE_FIXED: + case SANE_TYPE_INT: + { + nConstraint = mrSane.GetOptionConstraintType( mnCurrentOption ); + mnCurrentElement = 0; + if( nConstraint == SANE_CONSTRAINT_RANGE || + nConstraint == SANE_CONSTRAINT_WORD_LIST ) + EstablishQuantumRange(); + else + { + mfMin = mfMax = 0.0; + EstablishNumericOption(); + } + int nElements = mrSane.GetOptionElements( mnCurrentOption ); + if( nElements > 1 ) + { + if( nElements <= 10 ) + { + maVectorBox.SetValue( 1 ); + maVectorBox.SetMin( 1 ); + maVectorBox.SetMax( + mrSane.GetOptionElements( mnCurrentOption ) ); + maVectorBox.Show( TRUE ); + maVectorTxt.Show( TRUE ); + } + else + { + double* x = new double[ nElements ]; + double* y = new double[ nElements ]; + for( int i = 0; i < nElements; i++ ) + { + x[ i ] = (double)i; + mrSane.GetOptionValue( mnCurrentOption, x[i], i ); + } + GridWindow aGrid( x, y, nElements, this ); + aGrid.SetText( mrSane.GetOptionName( mnCurrentOption ) ); + aGrid.setBoundings( 0, mfMin, nElements, mfMax ); + aGrid.Execute(); + + delete x; + delete y; + } + } + } + break; + case SANE_TYPE_BUTTON: + EstablishButtonOption(); + break; + default: break; + } + } + } + return 0; +} + +IMPL_LINK( SaneDlg, ModifyHdl, Edit*, pEdit ) +{ + if( mrSane.IsOpen() ) + { + if( pEdit == &maStringEdit ) + { + mrSane.SetOptionValue( mnCurrentOption, maStringEdit.GetText() ); + } + else if( pEdit == &maReslBox ) + { + double fRes = (double)maReslBox.GetValue(); + int nOption = mrSane.GetOptionByName( "resolution" ); + if( nOption != -1 ) + { + double* pDouble = NULL; + int nValues = mrSane.GetRange( nOption, pDouble ); + if( nValues > 0 ) + { + int i; + for( i = 0; i < nValues; i++ ) + { + if( fRes == pDouble[i] ) + break; + } + if( i >= nValues ) + fRes = pDouble[0]; + } + else if( nValues == 0 ) + { + if( fRes < pDouble[ 0 ] ) + fRes = pDouble[ 0 ]; + if( fRes > pDouble[ 1 ] ) + fRes = pDouble[ 1 ]; + } + maReslBox.SetValue( (ULONG)fRes ); + } + } + else if( pEdit == &maNumericEdit ) + { + double fValue; + char pBuf[256]; + ByteString aContents( maNumericEdit.GetText(), gsl_getSystemTextEncoding() ); + fValue = atof( aContents.GetBuffer() ); + if( mfMin != mfMax && ( fValue < mfMin || fValue > mfMax ) ) + { + if( fValue < mfMin ) + fValue = mfMin; + else if( fValue > mfMax ) + fValue = mfMax; + sprintf( pBuf, "%g", fValue ); + maNumericEdit.SetText( String( pBuf, gsl_getSystemTextEncoding() ) ); + } + mrSane.SetOptionValue( mnCurrentOption, fValue, mnCurrentElement ); + } + else if( pEdit == &maVectorBox ) + { + char pBuf[256]; + mnCurrentElement = maVectorBox.GetValue()-1; + double fValue; + mrSane.GetOptionValue( mnCurrentOption, fValue, mnCurrentElement ); + sprintf( pBuf, "%g", fValue ); + String aValue( pBuf, gsl_getSystemTextEncoding() ); + maNumericEdit.SetText( aValue ); + maQuantumRangeBox.SelectEntry( aValue ); + } + else if( pEdit == &maTopField ) + { + Point aPoint( 0, maTopField.GetValue() ); + aPoint = GetPixelPos( aPoint ); + maTopLeft.Y() = aPoint.Y(); + DrawDrag(); + } + else if( pEdit == &maLeftField ) + { + Point aPoint( maLeftField.GetValue(), 0 ); + aPoint = GetPixelPos( aPoint ); + maTopLeft.X() = aPoint.X(); + DrawDrag(); + } + else if( pEdit == &maBottomField ) + { + Point aPoint( 0, maBottomField.GetValue() ); + aPoint = GetPixelPos( aPoint ); + maBottomRight.Y() = aPoint.Y(); + DrawDrag(); + } + else if( pEdit == &maRightField ) + { + Point aPoint( maRightField.GetValue(), 0 ); + aPoint = GetPixelPos( aPoint ); + maBottomRight.X() = aPoint.X(); + DrawDrag(); + } + } + return 0; +} + +IMPL_LINK( SaneDlg, ReloadSaneOptionsHdl, Sane*, pSane ) +{ + mnCurrentOption = -1; + mnCurrentElement = 0; + DisableOption(); + InitFields(); + Rectangle aDummyRect( Point( 0, 0 ), GetSizePixel() ); + Paint( aDummyRect ); + return 0; +} + +void SaneDlg::AcquirePreview() +{ + if( ! mrSane.IsOpen() ) + return; + + UpdateScanArea( TRUE ); + // set small resolution for preview + double fResl = (double)maReslBox.GetValue(); + SetAdjustedNumericalValue( "resolution", 30.0 ); + + int nOption = mrSane.GetOptionByName( "preview" ); + if( nOption == -1 ) + { + String aString( SaneResId( RID_SANE_NORESOLUTIONOPTION_TXT ) ); + WarningBox aBox( this, WB_OK_CANCEL | WB_DEF_OK, aString ); + if( aBox.Execute() == RET_CANCEL ) + return; + } + else + mrSane.SetOptionValue( nOption, (BOOL)TRUE ); + + BitmapTransporter aTransporter; + if( ! mrSane.Start( aTransporter ) ) + { + ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, + String( SaneResId( RID_SANE_SCANERROR_TXT ) ) ); + aErrorBox.Execute(); + } + else + { +#ifdef DEBUG + aTransporter.getStream().Seek( STREAM_SEEK_TO_END ); + fprintf( stderr, "Previewbitmapstream contains %d bytes\n", aTransporter.getStream().Tell() ); +#endif + aTransporter.getStream().Seek( STREAM_SEEK_TO_BEGIN ); + maPreviewBitmap.Read( aTransporter.getStream(), TRUE ); + } + + SetAdjustedNumericalValue( "resolution", fResl ); + maReslBox.SetValue( (ULONG)fResl ); + + maPreviewRect = Rectangle( maTopLeft, + Size( maBottomRight.X() - maTopLeft.X(), + maBottomRight.Y() - maTopLeft.Y() ) + ); + Paint( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); +} + +void SaneDlg::Paint( const Rectangle& rRect ) +{ + SetMapMode( maMapMode ); + SetFillColor( Color( COL_WHITE ) ); + SetLineColor( Color( COL_WHITE ) ); + DrawRect( Rectangle( Point( PREVIEW_UPPER_LEFT, PREVIEW_UPPER_TOP ), + Size( PREVIEW_WIDTH, PREVIEW_HEIGHT ) ) ); + SetMapMode( MapMode( MAP_PIXEL ) ); + // check for sane values + DrawBitmap( maPreviewRect.TopLeft(), maPreviewRect.GetSize(), + maPreviewBitmap ); + + mbDragDrawn = FALSE; + DrawDrag(); + + ModalDialog::Paint( rRect ); +} + +void SaneDlg::DisableOption() +{ + maBoolCheckBox.Show( FALSE ); + maStringEdit.Show( FALSE ); + maNumericEdit.Show( FALSE ); + maQuantumRangeBox.Show( FALSE ); + maStringRangeBox.Show( FALSE ); + maButtonOption.Show( FALSE ); + maVectorBox.Show( FALSE ); + maVectorTxt.Show( FALSE ); + maOptionDescTxt.Show( FALSE ); +} + +void SaneDlg::EstablishBoolOption() +{ + BOOL bSuccess, bValue; + + bSuccess = mrSane.GetOptionValue( mnCurrentOption, bValue ); + if( bSuccess ) + { + maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) ); + maOptionDescTxt.Show( TRUE ); + maBoolCheckBox.Check( bValue ); + maBoolCheckBox.Show( TRUE ); + } +} + +void SaneDlg::EstablishStringOption() +{ + BOOL bSuccess; + ByteString aValue; + + bSuccess = mrSane.GetOptionValue( mnCurrentOption, aValue ); + if( bSuccess ) + { + maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) ); + maOptionDescTxt.Show( TRUE ); + maStringEdit.SetText( String( aValue, gsl_getSystemTextEncoding() ) ); + maStringEdit.Show( TRUE ); + } +} + +void SaneDlg::EstablishStringRange() +{ + const char** ppStrings = mrSane.GetStringConstraint( mnCurrentOption ); + maStringRangeBox.Clear(); + for( int i = 0; ppStrings[i] != 0; i++ ) + maStringRangeBox.InsertEntry( String( ppStrings[i], gsl_getSystemTextEncoding() ) ); + ByteString aValue; + mrSane.GetOptionValue( mnCurrentOption, aValue ); + maStringRangeBox.SelectEntry( String( aValue, gsl_getSystemTextEncoding() ) ); + maStringRangeBox.Show( TRUE ); + maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) ); + maOptionDescTxt.Show( TRUE ); +} + +void SaneDlg::EstablishQuantumRange() +{ + if( mpRange ) + { + delete mpRange; + mpRange = 0; + } + int nValues = mrSane.GetRange( mnCurrentOption, mpRange ); + if( nValues == 0 ) + { + mfMin = mpRange[ 0 ]; + mfMax = mpRange[ 1 ]; + delete mpRange; + mpRange = 0; + EstablishNumericOption(); + } + else if( nValues > 0 ) + { + char pBuf[ 256 ]; + maQuantumRangeBox.Clear(); + mfMin = mpRange[ 0 ]; + mfMax = mpRange[ nValues-1 ]; + for( int i = 0; i < nValues; i++ ) + { + sprintf( pBuf, "%g", mpRange[ i ] ); + maQuantumRangeBox.InsertEntry( String( pBuf, gsl_getSystemTextEncoding() ) ); + } + double fValue; + if( mrSane.GetOptionValue( mnCurrentOption, fValue, mnCurrentElement ) ) + { + sprintf( pBuf, "%g", fValue ); + maQuantumRangeBox.SelectEntry( String( pBuf, gsl_getSystemTextEncoding() ) ); + } + maQuantumRangeBox.Show( TRUE ); + String aText( mrSane.GetOptionName( mnCurrentOption ) ); + aText += ' '; + aText += mrSane.GetOptionUnitName( mnCurrentOption ); + maOptionDescTxt.SetText( aText ); + maOptionDescTxt.Show( TRUE ); + } +} + +void SaneDlg::EstablishNumericOption() +{ + BOOL bSuccess; + double fValue; + + bSuccess = mrSane.GetOptionValue( mnCurrentOption, fValue ); + if( ! bSuccess ) + return; + + char pBuf[256]; + String aText( mrSane.GetOptionName( mnCurrentOption ) ); + aText += ' '; + aText += mrSane.GetOptionUnitName( mnCurrentOption ); + if( mfMin != mfMax ) + { + sprintf( pBuf, " < %g ; %g >", mfMin, mfMax ); + aText += String( pBuf, gsl_getSystemTextEncoding() ); + } + maOptionDescTxt.SetText( aText ); + maOptionDescTxt.Show( TRUE ); + sprintf( pBuf, "%g", fValue ); + maNumericEdit.SetText( String( pBuf, gsl_getSystemTextEncoding() ) ); + maNumericEdit.Show( TRUE ); +} + +void SaneDlg::EstablishButtonOption() +{ + maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) ); + maOptionDescTxt.Show( TRUE ); + maButtonOption.Show( TRUE ); +} + +#define RECT_SIZE_PIX 7 + +void SaneDlg::MouseMove( const MouseEvent& rMEvt ) +{ + if( mbIsDragging ) + { + Point aMousePos = rMEvt.GetPosPixel(); + // move into valid area + Point aLogicPos = GetLogicPos( aMousePos ); + aMousePos = GetPixelPos( aLogicPos ); + switch( meDragDirection ) + { + case TopLeft: maTopLeft = aMousePos; break; + case Top: maTopLeft.Y() = aMousePos.Y(); break; + case TopRight: + maTopLeft.Y() = aMousePos.Y(); + maBottomRight.X() = aMousePos.X(); + break; + case Right: maBottomRight.X() = aMousePos.X(); break; + case BottomRight: maBottomRight = aMousePos; break; + case Bottom: maBottomRight.Y() = aMousePos.Y(); break; + case BottomLeft: + maTopLeft.X() = aMousePos.X(); + maBottomRight.Y() = aMousePos.Y(); + break; + case Left: maTopLeft.X() = aMousePos.X(); break; + default: break; + } + int nSwap; + if( maTopLeft.X() > maBottomRight.X() ) + { + nSwap = maTopLeft.X(); + maTopLeft.X() = maBottomRight.X(); + maBottomRight.X() = nSwap; + } + if( maTopLeft.Y() > maBottomRight.Y() ) + { + nSwap = maTopLeft.Y(); + maTopLeft.Y() = maBottomRight.Y(); + maBottomRight.Y() = nSwap; + } + DrawDrag(); + UpdateScanArea( FALSE ); + } + ModalDialog::MouseMove( rMEvt ); +} + +void SaneDlg::MouseButtonDown( const MouseEvent& rMEvt ) +{ + Point aMousePixel = rMEvt.GetPosPixel(); + + if( ! mbIsDragging ) + { + int nMiddleX = ( maBottomRight.X() - maTopLeft.X() ) / 2 - RECT_SIZE_PIX/2 + maTopLeft.X(); + int nMiddleY = ( maBottomRight.Y() - maTopLeft.Y() ) / 2 - RECT_SIZE_PIX/2 + maTopLeft.Y(); + if( aMousePixel.Y() >= maTopLeft.Y() && + aMousePixel.Y() < maTopLeft.Y() + RECT_SIZE_PIX ) + { + if( aMousePixel.X() >= maTopLeft.X() && + aMousePixel.X() < maTopLeft.X() + RECT_SIZE_PIX ) + { + meDragDirection = TopLeft; + aMousePixel = maTopLeft; + mbIsDragging = TRUE; + } + else if( aMousePixel.X() >= nMiddleX && + aMousePixel.X() < nMiddleX + RECT_SIZE_PIX ) + { + meDragDirection = Top; + aMousePixel.Y() = maTopLeft.Y(); + mbIsDragging = TRUE; + } + else if( aMousePixel.X() > maBottomRight.X() - RECT_SIZE_PIX && + aMousePixel.X() <= maBottomRight.X() ) + { + meDragDirection = TopRight; + aMousePixel = Point( maBottomRight.X(), maTopLeft.Y() ); + mbIsDragging = TRUE; + } + } + else if( aMousePixel.Y() >= nMiddleY && + aMousePixel.Y() < nMiddleY + RECT_SIZE_PIX ) + { + if( aMousePixel.X() >= maTopLeft.X() && + aMousePixel.X() < maTopLeft.X() + RECT_SIZE_PIX ) + { + meDragDirection = Left; + aMousePixel.X() = maTopLeft.X(); + mbIsDragging = TRUE; + } + else if( aMousePixel.X() > maBottomRight.X() - RECT_SIZE_PIX && + aMousePixel.X() <= maBottomRight.X() ) + { + meDragDirection = Right; + aMousePixel.X() = maBottomRight.X(); + mbIsDragging = TRUE; + } + } + else if( aMousePixel.Y() <= maBottomRight.Y() && + aMousePixel.Y() > maBottomRight.Y() - RECT_SIZE_PIX ) + { + if( aMousePixel.X() >= maTopLeft.X() && + aMousePixel.X() < maTopLeft.X() + RECT_SIZE_PIX ) + { + meDragDirection = BottomLeft; + aMousePixel = Point( maTopLeft.X(), maBottomRight.Y() ); + mbIsDragging = TRUE; + } + else if( aMousePixel.X() >= nMiddleX && + aMousePixel.X() < nMiddleX + RECT_SIZE_PIX ) + { + meDragDirection = Bottom; + aMousePixel.Y() = maBottomRight.Y(); + mbIsDragging = TRUE; + } + else if( aMousePixel.X() > maBottomRight.X() - RECT_SIZE_PIX && + aMousePixel.X() <= maBottomRight.X() ) + { + meDragDirection = BottomRight; + aMousePixel = maBottomRight; + mbIsDragging = TRUE; + } + } + } + if( mbIsDragging ) + { + SetPointerPosPixel( aMousePixel ); + DrawDrag(); + } + ModalDialog::MouseButtonDown( rMEvt ); +} + +void SaneDlg::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if( mbIsDragging ) + { + UpdateScanArea( TRUE ); + } + mbIsDragging = FALSE; + + ModalDialog::MouseButtonUp( rMEvt ); +} + +void SaneDlg::DrawRectangles( Point& rUL, Point& rBR ) +{ + int nMiddleX, nMiddleY; + Point aBL, aUR; + + aUR = Point( rBR.X(), rUL.Y() ); + aBL = Point( rUL.X(), rBR.Y() ); + nMiddleX = ( rBR.X() - rUL.X() ) / 2 + rUL.X(); + nMiddleY = ( rBR.Y() - rUL.Y() ) / 2 + rUL.Y(); + + DrawLine( rUL, aBL ); + DrawLine( aBL, rBR ); + DrawLine( rBR, aUR ); + DrawLine( aUR, rUL ); + DrawRect( Rectangle( rUL, Size( RECT_SIZE_PIX,RECT_SIZE_PIX ) ) ); + DrawRect( Rectangle( aBL, Size( RECT_SIZE_PIX, -RECT_SIZE_PIX ) ) ); + DrawRect( Rectangle( rBR, Size( -RECT_SIZE_PIX, -RECT_SIZE_PIX ) ) ); + DrawRect( Rectangle( aUR, Size( -RECT_SIZE_PIX, RECT_SIZE_PIX ) ) ); + DrawRect( Rectangle( Point( nMiddleX - RECT_SIZE_PIX/2, rUL.Y() ), Size( RECT_SIZE_PIX, RECT_SIZE_PIX ) ) ); + DrawRect( Rectangle( Point( nMiddleX - RECT_SIZE_PIX/2, rBR.Y() ), Size( RECT_SIZE_PIX, -RECT_SIZE_PIX ) ) ); + DrawRect( Rectangle( Point( rUL.X(), nMiddleY - RECT_SIZE_PIX/2 ), Size( RECT_SIZE_PIX, RECT_SIZE_PIX ) ) ); + DrawRect( Rectangle( Point( rBR.X(), nMiddleY - RECT_SIZE_PIX/2 ), Size( -RECT_SIZE_PIX, RECT_SIZE_PIX ) ) ); +} + +void SaneDlg::DrawDrag() +{ + static Point aLastUL, aLastBR; + + RasterOp eROP = GetRasterOp(); + SetRasterOp( ROP_INVERT ); + SetMapMode( MapMode( MAP_PIXEL ) ); + + if( mbDragDrawn ) + DrawRectangles( aLastUL, aLastBR ); + + aLastUL = maTopLeft; + aLastBR = maBottomRight; + DrawRectangles( maTopLeft, maBottomRight ); + + mbDragDrawn = TRUE; + SetRasterOp( eROP ); + SetMapMode( maMapMode ); +} + +Point SaneDlg::GetPixelPos( const Point& rIn ) +{ + Point aConvert( + ( ( rIn.X() * PREVIEW_WIDTH ) / + ( maMaxBottomRight.X() - maMinTopLeft.X() ) ) + + PREVIEW_UPPER_LEFT, + ( ( rIn.Y() * PREVIEW_HEIGHT ) + / ( maMaxBottomRight.Y() - maMinTopLeft.Y() ) ) + + PREVIEW_UPPER_TOP ); + + return LogicToPixel( aConvert, maMapMode ); +} + +Point SaneDlg::GetLogicPos( const Point& rIn ) +{ + Point aConvert = PixelToLogic( rIn, maMapMode ); + aConvert.X() -= PREVIEW_UPPER_LEFT; + aConvert.Y() -= PREVIEW_UPPER_TOP; + if( aConvert.X() < 0 ) + aConvert.X() = 0; + if( aConvert.X() >= PREVIEW_WIDTH ) + aConvert.X() = PREVIEW_WIDTH-1; + if( aConvert.Y() < 0 ) + aConvert.Y() = 0; + if( aConvert.Y() >= PREVIEW_HEIGHT ) + aConvert.Y() = PREVIEW_HEIGHT-1; + + aConvert.X() *= ( maMaxBottomRight.X() - maMinTopLeft.X() ); + aConvert.X() /= PREVIEW_WIDTH; + aConvert.Y() *= ( maMaxBottomRight.Y() - maMinTopLeft.Y() ); + aConvert.Y() /= PREVIEW_HEIGHT; + return aConvert; +} + +void SaneDlg::UpdateScanArea( BOOL bSend ) +{ + Point aUL = GetLogicPos( maTopLeft ); + Point aBR = GetLogicPos( maBottomRight ); + + maLeftField.SetValue( aUL.X() ); + maTopField.SetValue( aUL.Y() ); + maRightField.SetValue( aBR.X() ); + maBottomField.SetValue( aBR.Y() ); + + if( ! bSend ) + return; + + if( mrSane.IsOpen() ) + { + SetAdjustedNumericalValue( "tl-x", (double)aUL.X() ); + SetAdjustedNumericalValue( "tl-y", (double)aUL.Y() ); + SetAdjustedNumericalValue( "br-x", (double)aBR.X() ); + SetAdjustedNumericalValue( "br-y", (double)aBR.Y() ); + } +} + +BOOL SaneDlg::LoadState() +{ +#ifdef USE_SAVE_STATE + int i; + + if( ! Sane::IsSane() ) + return FALSE; + + const char* pEnv = getenv("HOME"); + String aFileName( pEnv ? pEnv : "", gsl_getSystemTextEncoding() ); + aFileName += String( RTL_CONSTASCII_USTRINGPARAM( "/.so_sane_state" ) ); + Config aConfig( aFileName ); + if( ! aConfig.HasGroup( "SANE" ) ) + return FALSE; + + aConfig.SetGroup( "SANE" ); + ByteString aString = aConfig.ReadKey( "SO_LastSaneDevice" ); + for( i = 0; i < Sane::CountDevices() && ! aString.Equals( ByteString( Sane::GetName( i ), gsl_getSystemTextEncoding() ) ); i++ ) ; + if( i == Sane::CountDevices() ) + return FALSE; + + mrSane.Close(); + mrSane.Open( aString.GetBuffer() ); + + DisableOption(); + InitFields(); + + if( mrSane.IsOpen() ) + { + int iMax = aConfig.GetKeyCount(); + for( i = 0; i < iMax; i++ ) + { + aString = aConfig.GetKeyName( i ); + ByteString aValue = aConfig.ReadKey( i ); + int nOption = mrSane.GetOptionByName( aString.GetBuffer() ); + if( nOption != -1 ) + { + if( aValue.CompareTo( "BOOL=", 5 ) == COMPARE_EQUAL ) + { + aValue.Erase( 0, 5 ); + BOOL aBOOL = (BOOL)aValue.ToInt32(); + mrSane.SetOptionValue( nOption, aBOOL ); + } + else if( aValue.CompareTo( "STRING=", 7 ) == COMPARE_EQUAL ) + { + aValue.Erase( 0, 7 ); + mrSane.SetOptionValue( nOption, String( aValue, gsl_getSystemTextEncoding() ) ); + } + else if( aValue.CompareTo( "NUMERIC=", 8 ) == COMPARE_EQUAL ) + { + aValue.Erase( 0, 8 ); + int nMax = aValue.GetTokenCount( ':' ); + double fValue=0.0; + for( int n = 0; n < nMax ; n++ ) + { + ByteString aSub = aValue.GetToken( n, ':' ); + sscanf( aSub.GetBuffer(), "%lg", &fValue ); + SetAdjustedNumericalValue( aString.GetBuffer(), fValue, n ); + } + } + } + } + } + + DisableOption(); + InitFields(); + + return TRUE; +#else + return FALSE; +#endif +} + +void SaneDlg::SaveState() +{ +#ifdef USE_SAVE_STATE + if( ! Sane::IsSane() ) + return; + + const char* pEnv = getenv( "HOME" ); + String aFileName( pEnv ? pEnv : "", gsl_getSystemTextEncoding() ); + aFileName.AppendAscii( "/.so_sane_state" ); + + Config aConfig( aFileName ); + aConfig.DeleteGroup( "SANE" ); + aConfig.SetGroup( "SANE" ); + aConfig.WriteKey( "SO_LastSANEDevice", ByteString( maDeviceBox.GetSelectEntry(), RTL_TEXTENCODING_UTF8 ) ); + +#ifdef SAVE_ALL_STATES + for( int i = 1; i < mrSane.CountOptions(); i++ ) + { + String aOption=mrSane.GetOptionName( i ); + SANE_Value_Type nType = mrSane.GetOptionType( i ); + switch( nType ) + { + case SANE_TYPE_BOOL: + { + BOOL bValue; + if( mrSane.GetOptionValue( i, bValue ) ) + { + ByteString aString( "BOOL=" ); + aString += (ULONG)bValue; + aConfig.WriteKey( aOption, aString ); + } + } + break; + case SANE_TYPE_STRING: + { + String aString( "STRING=" ); + String aValue; + if( mrSane.GetOptionValue( i, aValue ) ) + { + aString += aValue; + aConfig.WriteKey( aOption, aString ); + } + } + break; + case SANE_TYPE_FIXED: + case SANE_TYPE_INT: + { + String aString( "NUMERIC=" ); + double fValue; + char buf[256]; + for( int n = 0; n < mrSane.GetOptionElements( i ); n++ ) + { + if( ! mrSane.GetOptionValue( i, fValue, n ) ) + break; + if( n > 0 ) + aString += ":"; + sprintf( buf, "%lg", fValue ); + aString += buf; + } + if( n >= mrSane.GetOptionElements( i ) ) + aConfig.WriteKey( aOption, aString ); + } + break; + default: + break; + } + } +#else + static char* pSaveOptions[] = { + "resolution", + "tl-x", + "tl-y", + "br-x", + "br-y" + }; + for( int i = 0; + i < (sizeof(pSaveOptions)/sizeof(pSaveOptions[0])); + i++ ) + { + ByteString aOption = pSaveOptions[i]; + int nOption = mrSane.GetOptionByName( pSaveOptions[i] ); + if( nOption > -1 ) + { + SANE_Value_Type nType = mrSane.GetOptionType( nOption ); + switch( nType ) + { + case SANE_TYPE_BOOL: + { + BOOL bValue; + if( mrSane.GetOptionValue( nOption, bValue ) ) + { + ByteString aString( "BOOL=" ); + aString += (ULONG)bValue; + aConfig.WriteKey( aOption, aString ); + } + } + break; + case SANE_TYPE_STRING: + { + ByteString aString( "STRING=" ); + ByteString aValue; + if( mrSane.GetOptionValue( nOption, aValue ) ) + { + aString += aValue; + aConfig.WriteKey( aOption, aString ); + } + } + break; + case SANE_TYPE_FIXED: + case SANE_TYPE_INT: + { + ByteString aString( "NUMERIC=" ); + double fValue; + char buf[256]; + for( int n = 0; n < mrSane.GetOptionElements( nOption ); n++ ) + { + if( ! mrSane.GetOptionValue( nOption, fValue, n ) ) + break; + if( n > 0 ) + aString += ":"; + sprintf( buf, "%lg", fValue ); + aString += buf; + } + if( n >= mrSane.GetOptionElements( nOption ) ) + aConfig.WriteKey( aOption, aString ); + } + break; + default: + break; + } + } + } +#endif +#endif +} + +BOOL SaneDlg::SetAdjustedNumericalValue( + const char* pOption, + double fValue, + int nElement ) +{ + int nOption; + if( ! Sane::IsSane() || ! mrSane.IsOpen() || ( nOption = mrSane.GetOptionByName( pOption ) ) == -1 ) + return FALSE; + + if( nElement < 0 || nElement >= mrSane.GetOptionElements( nOption ) ) + return FALSE; + + double* pValues = NULL; + int nValues; + if( ( nValues = mrSane.GetRange( nOption, pValues ) ) < 0 ) + return FALSE; + +#ifdef DEBUG + fprintf( stderr, "SaneDlg::SetAdjustedNumericalValue( \"%s\", %lg ) ", + pOption, fValue ); +#endif + + if( nValues ) + { + int nNearest = 0; + double fNearest = 1e6; + for( int i = 0; i < nValues; i++ ) + { + if( fabs( fValue - pValues[ i ] ) < fNearest ) + { + fNearest = fabs( fValue - pValues[ i ] ); + nNearest = i; + } + } + fValue = pValues[ nNearest ]; + } + else + { + if( fValue < pValues[0] ) + fValue = pValues[0]; + if( fValue > pValues[1] ) + fValue = pValues[1]; + } + delete pValues; + mrSane.SetOptionValue( nOption, fValue, nElement ); +#ifdef DEBUG + fprintf( stderr, "yields %lg\n", fValue ); +#endif + + + return TRUE; +} diff --git a/extensions/source/scanner/sanedlg.hrc b/extensions/source/scanner/sanedlg.hrc new file mode 100644 index 000000000000..328387dbb86b --- /dev/null +++ b/extensions/source/scanner/sanedlg.hrc @@ -0,0 +1,116 @@ +/************************************************************************* + * + * $RCSfile: sanedlg.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 _SVT_SANEDLG_HRC +#define _SVT_SANEDLG_HRC + +#define RID_SANE_DIALOG 1000 +#define RID_SCAN_OK 1 +#define RID_SCAN_CANCEL 2 +#define RID_DEVICEINFO_BTN 3 +#define RID_PREVIEW_BOX 4 +#define RID_DEVICE_BOX_TXT 5 +#define RID_DEVICE_BOX 6 +#define RID_SCANAREA_BOX 7 +#define RID_SCAN_LEFT_TXT 8 +#define RID_SCAN_LEFT_BOX 9 +#define RID_SCAN_TOP_BOX 10 +#define RID_SCAN_TOP_TXT 11 +#define RID_SCAN_RIGHT_TXT 12 +#define RID_SCAN_RIGHT_BOX 13 +#define RID_SCAN_BOTTOM_TXT 14 +#define RID_SCAN_BOTTOM_BOX 15 +#define RID_SCAN_RESOLUTION_TXT 16 +#define RID_SCAN_RESOLUTION_BOX 17 +#define RID_PREVIEW_BTN 18 +#define RID_SCAN_OPTION_BOX 19 +#define RID_SCAN_OPTIONTITLE_TXT 20 +#define RID_SCAN_OPTION_DESC_TXT 21 +#define RID_SCAN_BOOL_OPTION_BOX 22 +#define RID_SCAN_OPTION_TXT 23 +#define RID_SCAN_STRING_OPTION_EDT 24 +#define RID_SCAN_QUANTUM_RANGE_BOX 25 +#define RID_SCAN_STRING_RANGE_BOX 26 +#define RID_SCAN_NUMERIC_OPTION_EDT 27 +#define RID_SCAN_BUTTON_OPTION_BTN 28 +#define RID_SCAN_NUMERIC_VECTOR_BOX 29 +#define RID_SCAN_NUMERIC_VECTOR_TXT 30 +#define RID_SCAN_BITMAP_PLUS 31 +#define RID_SCAN_BITMAP_MINUS 32 +#define RID_SCAN_ADVANCED_BOX 33 +#define RID_SCAN_ADVANCED_TXT 34 + +#define RID_SANE_DEVICEINFO_TXT 1001 +#define RID_SANE_SCANERROR_TXT 1002 +#define RID_SANE_NORESOLUTIONOPTION_TXT 1003 +#define RID_SANE_NOSANELIB_TXT 1004 + +#define SCAN_AREA_TOP 17 +#define SCAN_AREA_LEFT 8 +#define PREVIEW_UPPER_LEFT SCAN_AREA_LEFT +#define PREVIEW_UPPER_TOP SCAN_AREA_TOP + 80 +#define PREVIEW_WIDTH 113 +#define PREVIEW_HEIGHT 160 +#define PREVIEW_BOTTOM PREVIEW_UPPER_TOP + PREVIEW_HEIGHT +#define PREVIEW_RIGHT PREVIEW_UPPER_LEFT + PREVIEW_WIDTH +#define SECOND_COLUMN PREVIEW_WIDTH + 20 +#define THIRD_COLUMN SECOND_COLUMN + 135 + +#endif diff --git a/extensions/source/scanner/sanedlg.hxx b/extensions/source/scanner/sanedlg.hxx new file mode 100644 index 000000000000..0dae3a433075 --- /dev/null +++ b/extensions/source/scanner/sanedlg.hxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * $RCSfile: sanedlg.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 _SVT_SANEDLG_HXX +#define _SVT_SANEDLG_HXX + +#ifndef _SV_DIALOG_HXX +#include <vcl/dialog.hxx> +#endif +#ifndef _SV_CONFIG_HXX +#include <vcl/config.hxx> +#endif +#ifndef _SV_LSTBOX_HXX +#include <vcl/lstbox.hxx> +#endif +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#ifndef _SV_FIXED_HXX +#include <vcl/fixed.hxx> +#endif +#ifndef _SV_GROUP_HXX +#include <vcl/group.hxx> +#endif +#ifndef _SV_FIELD_HXX +#include <vcl/field.hxx> +#endif +#ifndef _SV_EDIT_HXX +#include <vcl/edit.hxx> +#endif +#include <svtools/svtreebx.hxx> + +#include <sane.hxx> + +class SaneDlg : public ModalDialog +{ +private: + enum DragDirection { TopLeft, Top, TopRight, Right, BottomRight, Bottom, + BottomLeft, Left }; + + Sane& mrSane; + Bitmap maPreviewBitmap; + Rectangle maPreviewRect; + Point maTopLeft, maBottomRight; + Point maMinTopLeft, maMaxBottomRight; + BOOL mbIsDragging; + int mnDragMode; + BOOL mbDragDrawn; + DragDirection meDragDirection; + + MapMode maMapMode; + + Link maOldLink; + + OKButton maOKButton; + CancelButton maCancelButton; + PushButton maDeviceInfoButton; + PushButton maPreviewButton; + PushButton maButtonOption; + + FixedText maOptionsTxt; + FixedText maOptionTitle; + FixedText maOptionDescTxt; + FixedText maVectorTxt; + + FixedText maScanLeftTxt; + MetricField maLeftField; + FixedText maScanTopTxt; + MetricField maTopField; + FixedText maRightTxt; + MetricField maRightField; + FixedText maBottomTxt; + MetricField maBottomField; + + FixedText maDeviceBoxTxt; + ListBox maDeviceBox; + FixedText maReslTxt; + NumericBox maReslBox; + FixedText maAdvancedTxt; + CheckBox maAdvancedBox; + + NumericField maVectorBox; + ListBox maQuantumRangeBox; + ListBox maStringRangeBox; + + GroupBox maPreviewBox; + GroupBox maAreaBox; + + CheckBox maBoolCheckBox; + + Edit maStringEdit; + Edit maNumericEdit; + + SvTreeListBox maOptionBox; + + int mnCurrentOption; + int mnCurrentElement; + double* mpRange; + double mfMin, mfMax; + + DECL_LINK( ClickBtnHdl, Button* ); + DECL_LINK( SelectHdl, ListBox* ); + DECL_LINK( ModifyHdl, Edit* ); + DECL_LINK( ReloadSaneOptionsHdl, Sane* ); + DECL_LINK( OptionsBoxSelectHdl, SvTreeListBox* ); + + void SaveState(); + BOOL LoadState(); + + void InitDevices(); + void InitFields(); + void AcquirePreview(); + void DisableOption(); + void EstablishBoolOption(); + void EstablishStringOption(); + void EstablishStringRange(); + void EstablishQuantumRange(); + void EstablishNumericOption(); + void EstablishButtonOption(); + + void DrawRectangles( Point&, Point& ); + void DrawDrag(); + Point GetPixelPos( const Point& ); + Point GetLogicPos( const Point& ); + void UpdateScanArea( BOOL ); + + // helper + BOOL SetAdjustedNumericalValue( const char* pOption, double fValue, int nElement = 0 ); + + virtual void Paint( const Rectangle& ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); +public: + SaneDlg( Window*, Sane& ); + ~SaneDlg(); + + virtual short Execute(); +}; + + +#endif diff --git a/extensions/source/scanner/sanedlg.src b/extensions/source/scanner/sanedlg.src new file mode 100644 index 000000000000..3b864e693637 --- /dev/null +++ b/extensions/source/scanner/sanedlg.src @@ -0,0 +1,700 @@ +/************************************************************************* + * + * $RCSfile: sanedlg.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 <sanedlg.hrc> +ModalDialog RID_SANE_DIALOG +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( 10 , 10 ) ; + Size = MAP_APPFONT ( THIRD_COLUMN + 60 , 268 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + Text = "Scanner" ; + Text [ English ] = "Scanner" ; + OKButton RID_SCAN_OK + { + Pos = MAP_APPFONT ( THIRD_COLUMN , 6 ) ; + Size = MAP_APPFONT ( 55 , 14 ) ; + DefButton = TRUE; + }; + CancelButton RID_SCAN_CANCEL + { + Pos = MAP_APPFONT ( THIRD_COLUMN , 25 ) ; + Size = MAP_APPFONT ( 55 , 14 ) ; + }; + PushButton RID_DEVICEINFO_BTN + { + Pos = MAP_APPFONT ( THIRD_COLUMN , 44 ) ; + Size = MAP_APPFONT ( 55 , 22 ) ; + Text = "Geräte-\n~information" ; + Text [ English ] = "Device ~info" ; + Text [ english_us ] = "About\n Dev~ice" ; + Text [ portuguese_brazilian ] = "Gerõteinformation" ; + Text [ swedish ] = "Apparat\n~information" ; + Text [ danish ] = "Information\n om enheden" ; + Text [ italian ] = "Informazione\napparecchiatura" ; + Text [ spanish ] = "Información sobre\n ~dispositivo" ; + Text [ french ] = "Information sur le ~périphérique" ; + Text [ dutch ] = "Info over\n~apparaat" ; + Text [ portuguese ] = "~Informação sobre\nperiféricos" ; + Text[ chinese_simplified ] = "É豸\nÐÅÏ¢(~I)"; + Text[ russian ] = "Èíôîðìàöèÿ îá\nóñòðîéñòâå"; + Text[ polish ] = "Informacja \no urz¹dzeniu"; + Text[ japanese ] = "ÃÞÊÞ²½\nî•ñ(~I)"; + Text[ chinese_traditional ] = "³]³Æ»¡©ú¸ê®Æ(~I)"; + Text[ arabic ] = "ãÚáæãÇÊ\nÇáÌåÇÒ"; + Text[ dutch ] = "Info over\n~apparaat"; + Text[ chinese_simplified ] = "É豸\nÐÅÏ¢(~I)"; + Text[ greek ] = "Ðëçñïöïñßåò\nóõóêåõÞò"; + Text[ korean ] = "ÀåÄ¡ Á¤º¸(~I)"; + Text[ turkish ] = "Cihaz hakkýnda"; + }; + PushButton RID_PREVIEW_BTN + { + Pos = MAP_APPFONT ( THIRD_COLUMN , 71 ) ; + Size = MAP_APPFONT ( 55 , 22 ) ; + Text = "~Vorschau\nerstellen" ; + Text [ English ] = "Acquire\npre~view" ; + Text [ english_us ] = "Create\nPreview" ; + Text [ portuguese_brazilian ] = "Vorschau\nerstellen" ; + Text [ swedish ] = "S~kapa\nförhandsvisning" ; + Text [ danish ] = "Opret\neksempel" ; + Text [ italian ] = "Crea\nanteprima" ; + Text [ spanish ] = "Crear\n~Previsualización" ; + Text [ french ] = "Créer\nun ~aperçu" ; + Text [ dutch ] = "~Voorbeeld\nmaken" ; + Text [ portuguese ] = "Criar\n~previsualização" ; + Text[ chinese_simplified ] = "Éú³É\nÔ¤ÊÓ"; + Text[ russian ] = "Ñîçäàòü\n ïðîñìîòð"; + Text[ polish ] = "Utwórz\n podgl¹d"; + Text[ japanese ] = "ÌßÚËÞ°\nì¬"; + Text[ chinese_traditional ] = "¥Í¦¨\n¹wµø"; + Text[ arabic ] = "ÅäÔÇÁ\nãÚÇíäÉ"; + Text[ dutch ] = "~Voorbeeld\nmaken"; + Text[ chinese_simplified ] = "Éú³É\nÔ¤ÊÓ"; + Text[ greek ] = "Äçìéïõñãßá\nðñïåðéóêüðçóçò"; + Text[ korean ] = "¹Ì¸® º¸±â\nÀÛ¼º"; + Text[ turkish ] = "Önizleme\noluþtur"; + Text[ language_user1 ] = " "; + }; + GroupBox RID_PREVIEW_BOX + { + Pos = MAP_APPFONT ( PREVIEW_UPPER_LEFT - 5 , PREVIEW_UPPER_TOP - 8 ) ; + Size = MAP_APPFONT ( PREVIEW_WIDTH + 10 , PREVIEW_HEIGHT + 14 ) ; + Text = "Vorschau" ; + Text [ English ] = "Preview" ; + Text [ portuguese ] = "Previsualizar" ; + Text [ english_us ] = "Preview" ; + Text [ portuguese_brazilian ] = "Vorschau" ; + Text [ swedish ] = "Förhandsvisning" ; + Text [ danish ] = "Eksempel" ; + Text [ italian ] = "Anteprima" ; + Text [ spanish ] = "Previsualización" ; + Text [ french ] = "Aperçu" ; + Text [ dutch ] = "Voorbeeld" ; + Text[ chinese_simplified ] = "Ô¤ÊÓ"; + Text[ russian ] = "Ïðîñìîòð"; + Text[ polish ] = "Podgl¹d"; + Text[ japanese ] = "ÌßÚËÞ°"; + Text[ chinese_traditional ] = "¹wµø"; + Text[ arabic ] = "ãÚÇíäÉ"; + Text[ dutch ] = "Voorbeeld"; + Text[ chinese_simplified ] = "Ô¤ÊÓ"; + Text[ greek ] = "Ðñïåðéóêüðçóç"; + Text[ korean ] = "¹Ì¸® º¸±â"; + Text[ turkish ] = "Önizleme"; + }; + GroupBox RID_SCANAREA_BOX + { + Pos = MAP_APPFONT ( SCAN_AREA_LEFT - 5 , SCAN_AREA_TOP - 12 ) ; + Size = MAP_APPFONT ( PREVIEW_WIDTH + 10 , 78 ) ; + Text = "Scanbereich" ; + Text [ English ] = "Scan area" ; + Text [ english_us ] = "Scan area" ; + Text [ portuguese_brazilian ] = "Scanbereich" ; + Text [ swedish ] = "Skanningsområde" ; + Text [ danish ] = "Scanområde" ; + Text [ italian ] = "Area di scansione" ; + Text [ spanish ] = "Área de escaneado" ; + Text [ french ] = "Zone à scanner" ; + Text [ dutch ] = "Scanbereik" ; + Text [ portuguese ] = "Área de digitalização" ; + Text[ chinese_simplified ] = "ɨÃèÇøÓò"; + Text[ russian ] = "Îáëàñòü ñêàíèðîâàíèÿ"; + Text[ polish ] = "Obszar skanowania"; + Text[ japanese ] = "½·¬Ý”͈Í"; + Text[ chinese_traditional ] = "±½´y°Ï°ì"; + Text[ arabic ] = "äØÇÞ ÇáãÓÍ ÇáÖæÆí"; + Text[ dutch ] = "Scanbereik"; + Text[ chinese_simplified ] = "ɨÃèÇøÓò"; + Text[ greek ] = "Ðåñéï÷Þ óÜñùóçò"; + Text[ korean ] = "½ºÄµ ¿µ¿ª"; + Text[ turkish ] = "Tarama alaný"; + }; + FixedText RID_SCAN_LEFT_TXT + { + Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP ) ; + Size = MAP_APPFONT ( 50 , 8 ) ; + Text = "~Links:" ; + Text [ English ] = "~Left:" ; + Text [ portuguese ] = "~Esquerda:" ; + Text [ english_us ] = "Left:" ; + Text [ portuguese_brazilian ] = "Links:" ; + Text [ swedish ] = "~Vänster:" ; + Text [ danish ] = "Venstre:" ; + Text [ italian ] = "A ~sinistra:" ; + Text [ spanish ] = "I~zquierda:" ; + Text [ french ] = "À gauche :" ; + Text [ dutch ] = "~Links:" ; + Text[ chinese_simplified ] = "×ó:"; + Text[ russian ] = "Ñëåâà:"; + Text[ polish ] = "Z lewej:"; + Text[ japanese ] = "¶:"; + Text[ chinese_traditional ] = "¥ª¡G"; + Text[ arabic ] = "íÓÇÑ:"; + Text[ dutch ] = "~Links:"; + Text[ chinese_simplified ] = "×ó:"; + Text[ greek ] = "ÁñéóôåñÜ:"; + Text[ korean ] = "¿ÞÂÊ:"; + Text[ turkish ] = "Sol:"; + }; + MetricField RID_SCAN_LEFT_BOX + { + Spin = TRUE ; + Repeat = TRUE ; + Border = TRUE ; + Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP - 2 ) ; + Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ; + }; + FixedText RID_SCAN_TOP_TXT + { + Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP + 17 ) ; + Size = MAP_APPFONT ( 50 , 8 ) ; + Text = "~Oben:" ; + Text [ English ] = "~Top:" ; + Text [ english_us ] = "Top:" ; + Text [ portuguese_brazilian ] = "Oben:" ; + Text [ swedish ] = "Öv~erst:" ; + Text [ danish ] = "Top:" ; + Text [ italian ] = "In ~alto:" ; + Text [ spanish ] = "~Arriba:" ; + Text [ french ] = "En haut :" ; + Text [ dutch ] = "~Boven:" ; + Text [ portuguese ] = "Em ~cima:" ; + Text[ chinese_simplified ] = "ÉÏ:"; + Text[ russian ] = "Ñâåðõó:"; + Text[ polish ] = "W górze:"; + Text[ japanese ] = "ã:"; + Text[ chinese_traditional ] = "¤W¡G"; + Text[ arabic ] = "ÃÚáì:"; + Text[ dutch ] = "~Boven:"; + Text[ chinese_simplified ] = "ÉÏ:"; + Text[ greek ] = "ÐÜíù:"; + Text[ korean ] = "À§:"; + Text[ turkish ] = "Üst:"; + Text[ language_user1 ] = " "; + }; + MetricField RID_SCAN_TOP_BOX + { + Spin = TRUE ; + Repeat = TRUE ; + Border = TRUE ; + Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP + 15 ) ; + Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ; + }; + FixedText RID_SCAN_RIGHT_TXT + { + Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP + 34 ) ; + Size = MAP_APPFONT ( 50 , 8 ) ; + Text = "~Rechts:" ; + Text [ English ] = "~Right:" ; + Text [ english_us ] = "Right:" ; + Text [ portuguese_brazilian ] = "Rechts:" ; + Text [ swedish ] = "~Höger:" ; + Text [ danish ] = "Højre:" ; + Text [ italian ] = "A ~destra:" ; + Text [ spanish ] = "~Derecha:" ; + Text [ french ] = "À droite :" ; + Text [ dutch ] = "~Rechts:" ; + Text [ portuguese ] = "~Direita:" ; + Text[ chinese_simplified ] = "ÓÒ:"; + Text[ russian ] = "Ñïðàâà:"; + Text[ polish ] = "Z prawej:"; + Text[ japanese ] = "‰E:"; + Text[ chinese_traditional ] = "¥k¡G"; + Text[ arabic ] = "íãíä:"; + Text[ dutch ] = "~Rechts:"; + Text[ chinese_simplified ] = "ÓÒ:"; + Text[ greek ] = "ÄåîéÜ:"; + Text[ korean ] = "¿À¸¥ÂÊ:"; + Text[ turkish ] = "Sað:"; + Text[ language_user1 ] = " "; + }; + MetricField RID_SCAN_RIGHT_BOX + { + Spin = TRUE ; + Repeat = TRUE ; + Border = TRUE ; + Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP + 32 ) ; + Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ; + }; + FixedText RID_SCAN_BOTTOM_TXT + { + Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP + 51 ) ; + Size = MAP_APPFONT ( 50 , 8 ) ; + Text = "~Unten:" ; + Text [ English ] = "~Bottom:" ; + Text [ english_us ] = "Bottom:" ; + Text [ portuguese_brazilian ] = "Unten:" ; + Text [ swedish ] = "~Underst:" ; + Text [ danish ] = "Bund:" ; + Text [ italian ] = "In ~basso:" ; + Text [ spanish ] = "~Abajo:" ; + Text [ french ] = "En bas :" ; + Text [ dutch ] = "~Beneden:" ; + Text [ portuguese ] = "Em ~baixo:" ; + Text[ chinese_simplified ] = "ÏÂ:"; + Text[ russian ] = "Ñíèçó:"; + Text[ polish ] = "W dole:"; + Text[ japanese ] = "‰º:"; + Text[ chinese_traditional ] = "¤U¡G"; + Text[ arabic ] = "ÃÓÝá:"; + Text[ dutch ] = "~Beneden:"; + Text[ chinese_simplified ] = "ÏÂ:"; + Text[ greek ] = "ÊÜôù:"; + Text[ korean ] = "¾Æ·¡:"; + Text[ turkish ] = "Alt:"; + }; + MetricField RID_SCAN_BOTTOM_BOX + { + Spin = TRUE ; + Repeat = TRUE ; + Border = TRUE ; + Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP + 49 ) ; + Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ; + }; + FixedText RID_DEVICE_BOX_TXT + { + Pos = MAP_APPFONT ( SECOND_COLUMN , 8 ) ; + Size = MAP_APPFONT ( 70 , 8 ) ; + Text = "Verwendetes ~Gerät:" ; + Text [ English ] = "~Scanning device:" ; + Text [ english_us ] = "Device used:" ; + Text [ portuguese_brazilian ] = "Verwendetes Gerõt:" ; + Text [ swedish ] = "A~nvänd enhet:" ; + Text [ danish ] = "Brugt enhed:" ; + Text [ italian ] = "Apparecchiatura usata:" ; + Text [ spanish ] = "Dispositivo ~utilizado:" ; + Text [ french ] = "Périphérique utilisé :" ; + Text [ dutch ] = "~Gebruikte apparatuur:" ; + Text [ portuguese ] = "~Periférico usado:" ; + Text[ chinese_simplified ] = "ʹÓõÄÉ豸:"; + Text[ russian ] = "Èñïîëüçóåìîå óñòðîéñòâî:"; + Text[ polish ] = "Zastosowane urz¹dzenie:"; + Text[ japanese ] = "Žg—p’†‚ÌÃÞÊÞ²½:"; + Text[ chinese_traditional ] = "¨Ï¥Îªº³]³Æ¡G"; + Text[ arabic ] = "ÇáÌåÇÒ ÇáãÓÊÎÏã:"; + Text[ dutch ] = "~Gebruikte apparatuur:"; + Text[ chinese_simplified ] = "ʹÓõÄÉ豸:"; + Text[ greek ] = "×ñçóéìïðïéïýçìåíç óõóêåõÞ:"; + Text[ korean ] = "»ç¿ëÇÑ ÀåÄ¡:"; + Text[ turkish ] = "Kullanýlan cihaz:"; + }; + ListBox RID_DEVICE_BOX + { + Border = TRUE ; + Dropdown = TRUE ; + Sort = TRUE ; + Pos = MAP_APPFONT ( SECOND_COLUMN + 70 , 6 ) ; + Size = MAP_APPFONT ( 60 , 80 ) ; + }; + FixedText RID_SCAN_RESOLUTION_TXT + { + Pos = MAP_APPFONT ( SECOND_COLUMN , 25 ) ; + Size = MAP_APPFONT ( 70 , 8 ) ; + Text = "Auflösung [~DPI]" ; + Text [ English ] = "Resolution [~DPI]:" ; + Text [ english_us ] = "Resolution [~DPI]" ; + Text [ portuguese_brazilian ] = "Aufl÷sung [DPI]:" ; + Text [ swedish ] = "Upplösning [~DPI]:" ; + Text [ danish ] = "Opløsning [~DPI]:" ; + Text [ italian ] = "Risoluzione [~DPI]:" ; + Text [ spanish ] = "Resolución [~DPI]:" ; + Text [ french ] = "Résolution [~DPI]" ; + Text [ dutch ] = "Resolutie [~DPI]:" ; + Text [ portuguese ] = "Resolução [~DPI]:" ; + Text[ chinese_simplified ] = "·Ö±æÂÊ[DPI]"; + Text[ russian ] = "Ðàçðåøåíèå [DPI]:"; + Text[ polish ] = "Rozdzielczoœæ [~DPI]:"; + Text[ japanese ] = "‰ð‘œ [DPI]"; + Text[ greek ] = "ÁíÜëõóç [~DPI]:"; + Text[ korean ] = "ÇØ»óµµ [DPI]:(~D)"; + Text[ chinese_traditional ] = "¸ÑªR«× [~DPI]"; + Text[ arabic ] = "ÇÓÊÈÇäÉ [~DPI]"; + Text[ turkish ] = "Çözünürlük [~DPI]"; + }; + NumericBox RID_SCAN_RESOLUTION_BOX + { + Dropdown = TRUE ; + Pos = MAP_APPFONT ( SECOND_COLUMN + 70 , 23 ) ; + Size = MAP_APPFONT ( 60 , 80 ) ; + }; + FixedText RID_SCAN_ADVANCED_TXT + { + Pos = MAP_APPFONT ( SECOND_COLUMN , 40 ) ; + Size = MAP_APPFONT ( 120 , 8 ) ; + Text = "Er~weiterte Optionen anzeigen" ; + Text [ English ] = "Sho~w advanced options" ; + Text [ portuguese ] = "Mostrar opções a~vançadas" ; + Text [ english_us ] = "Show advanced options" ; + Text [ portuguese_brazilian ] = "Erweiterte Optionen anzeigen" ; + Text [ swedish ] = "Vi~sa utökade alternativ" ; + Text [ danish ] = "Vis avancerede funktioner" ; + Text [ italian ] = "Mostra opzioni avanzate" ; + Text [ spanish ] = "Mostrar otras ~opciones" ; + Text [ french ] = "Afficher les options avancées" ; + Text [ dutch ] = "~Verdere opties weergeven" ; + Text[ chinese_simplified ] = "ÏÔʾ¸ß¼¶Ñ¡Ïî"; + Text[ russian ] = "Ïîêàçàòü ðàñøèðåííûå ïàðàìåòðû"; + Text[ polish ] = "Poka¿ opcje zaawansowane"; + Text[ japanese ] = "Ú×µÌß¼®Ý‚Ì•\\Ž¦"; + Text[ chinese_traditional ] = "Åã¥Ü¶i¶¥¿ï¶µ"; + Text[ arabic ] = "ÅÙåÇÑ ÇáÎíÇÑÇÊ ÇáãÊÞÏãÉ"; + Text[ dutch ] = "~Verdere opties weergeven"; + Text[ chinese_simplified ] = "ÏÔʾ¸ß¼¶Ñ¡Ïî"; + Text[ greek ] = "ÅìöÜíéóç åðéðëÝïí åðéëïãþí"; + Text[ korean ] = "È®ÀåµÈ ¿É¼Ç Ç¥½Ã"; + Text[ turkish ] = "Ek seçenekleri görüntüle"; + }; + CheckBox RID_SCAN_ADVANCED_BOX + { + Check = FALSE ; + Pos = MAP_APPFONT ( SECOND_COLUMN + 120 , 40 ) ; + Size = MAP_APPFONT ( 8 , 8 ) ; + }; + FixedText RID_SCAN_OPTION_TXT + { + Pos = MAP_APPFONT ( SECOND_COLUMN , 54 ) ; + Size = MAP_APPFONT ( 130 , 8 ) ; + Text = "Optionen:" ; + Text [ English ] = "Options:" ; + Text [ portuguese ] = "Opções:" ; + Text [ english_us ] = "Options:" ; + Text [ portuguese_brazilian ] = "Optionen:" ; + Text [ swedish ] = "Alternativ:" ; + Text [ danish ] = "Indstillinger:" ; + Text [ italian ] = "Opzioni:" ; + Text [ spanish ] = "Opciones:" ; + Text [ french ] = "Options :" ; + Text [ dutch ] = "Opties:" ; + Text[ chinese_simplified ] = "Ñ¡Ïî:"; + Text[ russian ] = "Ïàðàìåòðû:"; + Text[ polish ] = "Opcje:"; + Text[ japanese ] = "µÌß¼®Ý:"; + Text[ chinese_traditional ] = "¿ï¶µ¡G"; + Text[ arabic ] = "ÇáÎíÇÑÇÊ:"; + Text[ dutch ] = "Opties:"; + Text[ chinese_simplified ] = "Ñ¡Ïî:"; + Text[ greek ] = "ÅðéëïãÝò:"; + Text[ korean ] = "¿É¼Ç:"; + Text[ turkish ] = "Seçenekler:"; + Text[ language_user1 ] = " "; + }; + Control RID_SCAN_OPTION_BOX + { + Border = TRUE ; + Pos = MAP_APPFONT ( SECOND_COLUMN , 63 ) ; + Size = MAP_APPFONT ( 130 , 102 ) ; + }; + FixedText RID_SCAN_OPTIONTITLE_TXT + { + WordBreak = TRUE ; + Border = TRUE ; + Pos = MAP_APPFONT ( SECOND_COLUMN , 170 ) ; + Size = MAP_APPFONT ( 130 , 50 ) ; + }; + FixedText RID_SCAN_OPTION_DESC_TXT + { + Pos = MAP_APPFONT ( SECOND_COLUMN , 225 ) ; + Size = MAP_APPFONT ( 120 , 8 ) ; + }; + CheckBox RID_SCAN_BOOL_OPTION_BOX + { + Pos = MAP_APPFONT ( SECOND_COLUMN + 120 , 225 ) ; + Size = MAP_APPFONT ( 8 , 8 ) ; + }; + Edit RID_SCAN_STRING_OPTION_EDT + { + Border = TRUE ; + Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ; + Size = MAP_APPFONT ( 130 , 12 ) ; + }; + ListBox RID_SCAN_QUANTUM_RANGE_BOX + { + Border = TRUE ; + Dropdown = TRUE ; + Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ; + Size = MAP_APPFONT ( 130 , 80 ) ; + }; + ListBox RID_SCAN_STRING_RANGE_BOX + { + Border = TRUE ; + Dropdown = TRUE ; + Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ; + Size = MAP_APPFONT ( 130 , 80 ) ; + }; + Edit RID_SCAN_NUMERIC_OPTION_EDT + { + Border = TRUE ; + Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ; + Size = MAP_APPFONT ( 130 , 12 ) ; + }; + FixedText RID_SCAN_NUMERIC_VECTOR_TXT + { + Pos = MAP_APPFONT ( SECOND_COLUMN , 253 ) ; + Size = MAP_APPFONT ( 90 , 8 ) ; + Text = "Vektorelement" ; + Text [ English ] = "Element of vector" ; + Text [ english_us ] = "Vector element" ; + Text [ portuguese_brazilian ] = "Vektorelement" ; + Text [ swedish ] = "Vektorelement" ; + Text [ danish ] = "Vektorelement" ; + Text [ italian ] = "Elemento vettoriale" ; + Text [ spanish ] = "Elemento vectorial" ; + Text [ french ] = "Élément vectoriel" ; + Text [ dutch ] = "Vectorelement" ; + Text [ portuguese ] = "Elemento vectorial" ; + Text[ chinese_simplified ] = "ʸÁ¿Í¼¼þ"; + Text[ russian ] = "Âåêòîðíûé ýëåìåíò"; + Text[ polish ] = "Element wektorowy"; + Text[ japanese ] = "ÍÞ¸À—v‘f"; + Text[ chinese_traditional ] = "¦V¶q¹Ï¥ó"; + Text[ arabic ] = "ÚäÕÑ Vector"; + Text[ dutch ] = "Vectorelement"; + Text[ chinese_simplified ] = "ʸÁ¿Í¼¼þ"; + Text[ greek ] = "Óôïé÷åßï äéáíýóìáôïò"; + Text[ korean ] = "º¤ÅÍ ¿ä¼Ò"; + Text[ turkish ] = "Vektör öðesi"; + }; + NumericField RID_SCAN_NUMERIC_VECTOR_BOX + { + Border = TRUE ; + Spin = TRUE ; + Repeat = TRUE ; + Pos = MAP_APPFONT ( SECOND_COLUMN + 90 , 251 ) ; + Size = MAP_APPFONT ( 40 , 12 ) ; + }; + PushButton RID_SCAN_BUTTON_OPTION_BTN + { + Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ; + Size = MAP_APPFONT ( 130 , 14 ) ; + Text = "Setzen" ; + Text [ English ] = "Set" ; + Text [ english_us ] = "Set" ; + Text [ portuguese_brazilian ] = "Setzen" ; + Text [ swedish ] = "Definiera" ; + Text [ danish ] = "Definer" ; + Text [ italian ] = "Imposta" ; + Text [ spanish ] = "Definir" ; + Text [ french ] = "Appliquer" ; + Text [ dutch ] = "Overnemen" ; + Text [ portuguese ] = "Definir" ; + Text[ chinese_simplified ] = "É趨"; + Text[ russian ] = "Óñòàíîâèòü"; + Text[ polish ] = "OsadŸ"; + Text[ japanese ] = "Ý’è"; + Text[ chinese_traditional ] = "³]©w"; + Text[ arabic ] = "ÊÚííä"; + Text[ dutch ] = "Overnemen"; + Text[ chinese_simplified ] = "É趨"; + Text[ greek ] = "Ïñéóìüò"; + Text[ korean ] = "¼³Á¤"; + Text[ turkish ] = "Tanýmla"; + }; + Bitmap RID_SCAN_BITMAP_PLUS + { + File = "plus.bmp" ; + }; + Bitmap RID_SCAN_BITMAP_MINUS + { + File = "minus.bmp" ; + }; + Text [ english_us ] = "Scanner" ; + Text [ portuguese_brazilian ] = "Scanner" ; + Text [ swedish ] = "Skanner" ; + Text [ danish ] = "Scanner" ; + Text [ italian ] = "Scanner" ; + Text [ spanish ] = "Escáner" ; + Text [ french ] = "Scanner" ; + Text [ dutch ] = "Scanner" ; + Text [ portuguese ] = "Digitalizador" ; + Text[ chinese_simplified ] = "ɨÃè»ú"; + Text[ russian ] = "Ñêàíåð"; + Text[ polish ] = "Skaner"; + Text[ japanese ] = "½·¬Å°"; + Text[ chinese_traditional ] = "±½´y»ö"; + Text[ arabic ] = "ãÇÓÍÉ ÖæÆíÉ"; + Text[ dutch ] = "Scanner"; + Text[ chinese_simplified ] = "ɨÃè»ú"; + Text[ greek ] = "ÓáñùôÞò"; + Text[ korean ] = "½ºÄ³³Ê"; + Text[ turkish ] = "Tarayýcý"; +}; +String RID_SANE_DEVICEINFO_TXT +{ + Text = "Gerät: %s\nHersteller: %s\nModell: %s\nTyp: %s" ; + Text [ English ] = "Device: %s\nVendor: %s\nModel: %s\nType: %s" ; + Text [ english_us ] = "Device: %s\nVendor: %s\nModel: %s\nType: %s" ; + Text [ portuguese_brazilian ] = "Gerõt: %s\nHersteller: %s\nModell: %s\nTyp: %s" ; + Text [ swedish ] = "Enhet: %s\nTillverkare: %s\nModell: %s\nTyp: %s" ; + Text [ danish ] = "Enhed: %s\nForhandler: %s\nModel: %s\nType: %s" ; + Text [ italian ] = "Apparecchiatura: %s\nProduttore: %s\nModello: %s\nTipo: %s" ; + Text [ spanish ] = "Dispositivo: %s\nFabricante: %s\nModelo: %s\nTipo: %s" ; + Text [ french ] = "Périphérique : %s\nFabricant : %s\nModèle : %s\nType : %s" ; + Text [ dutch ] = "Apparaat: %s\nProducent: %s\nModel: %s\nType: %s" ; + Text [ portuguese ] = "Periférico: %s\nFabricante: %s\nModelo: %s\nTipo: %s" ; + Text[ chinese_simplified ] = "É豸: %s\nÖÆÔìÉÌ: %s\nÐͺÅ: %s\nÀàÐÍ: %s"; + Text[ russian ] = "Óñòðîéñòâî: %s\nÈçãîòîâèòåëü: %s\nÌîäåëü: %s\nÒèï: %s"; + Text[ polish ] = "Urz¹dzenie: %s\nProducent: %s\nModel: %s\nTyp: %s"; + Text[ japanese ] = "ÃÞÊÞ²½: %s\n»‘¢Œ³: %s\nÓÃÞÙ: %s\nÀ²Ìß: %s"; + Text[ chinese_traditional ] = "³]³Æ¡G%s\n»s³y°Ó¡G%s\n«¬¸¹¡G%s\nÃþ«¬¡G%s"; + Text[ arabic ] = "ÇáÌåÇÒ: \n%sÇáãäÊÌ: \n%sÇáØÑÇÒ: %s\nÇáäæÚ: %s"; + Text[ dutch ] = "Apparaat: %s\nProducent: %s\nModel: %s\nType: %s"; + Text[ chinese_simplified ] = "É豸: %s\nÖÆÔìÉÌ: %s\nÐͺÅ: %s\nÀàÐÍ: %s"; + Text[ greek ] = "ÓõóêåõÞ: %s\nÊáôáóêåõáóôÞò: %s\nÌïíôÝëï: %s\nÔýðïò: %s"; + Text[ korean ] = "ÀåÄ¡: %s\nÁ¦Á¶¾÷ü: %s\n¸ðµ¨: %s\nÀ¯Çü: %s"; + Text[ turkish ] = "Cihaz: %s\nÜretici: %s\nModel: %s\nTip: %s"; +}; +String RID_SANE_SCANERROR_TXT +{ + Text = "Während des Scans ist ein Fehler aufgetreten." ; + Text [ English ] = "An error occured during scanning." ; + Text [ portuguese ] = "Surgiu um erro durante a digitalização." ; + Text [ english_us ] = "An error occurred while scanning." ; + Text [ portuguese_brazilian ] = "Wõhrend des Scans ist ein Fehler aufgetreten." ; + Text [ swedish ] = "Ett fel uppstod när Du skannade." ; + Text [ danish ] = "Der opstod en fejl under scanning." ; + Text [ italian ] = "Durante la scansione si è verificato un errore." ; + Text [ spanish ] = "Se ha producido un error durante el escaneado." ; + Text [ french ] = "Une erreur s'est produite durant la digitalisation." ; + Text [ dutch ] = "Tijdens het scannen is er een fout opgetreden." ; + Text[ chinese_simplified ] = "ÔÚɨÃèʱ·¢Éú´íÎó¡£"; + Text[ russian ] = "Âî âðåìÿ ñêàíèðîâàíèÿ ïðîèçîøëà îøèáêà."; + Text[ polish ] = "Podczas skanowania wyst¹pi³ b³¹d."; + Text[ japanese ] = "½·¬Ý’†‚É´×°”¶¡"; + Text[ chinese_traditional ] = "¦b±½´y®Éµo¥Í¤@Ó¿ù»~¡C"; + Text[ arabic ] = "ÍÏË ÎØà ÃËäÇÁ ÚãáíÉ ÇáãÓÍ ÇáÖæÆí."; + Text[ dutch ] = "Tijdens het scannen is er een fout opgetreden."; + Text[ chinese_simplified ] = "ÔÚɨÃèʱ·¢Éú´íÎó¡£"; + Text[ greek ] = "ÐáñïõóéÜóôçêå óöÜëìá êáôÜ ôçí óÜñùóç."; + Text[ korean ] = "½ºÄµÇÒ ¶§ ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù."; + Text[ turkish ] = "Tarama sýrasýnda hata oluþtu."; +}; +String RID_SANE_NORESOLUTIONOPTION_TXT +{ + Text = "Das Gerät ist nicht auf die Erzeugung einer Vorschau eingerichtet. Statt dessen wird als Vorschau ein normaler Scan verwendet. Dieser kann deutlich länger dauern." ; + Text [ English ] = "The device does not offer a preview option. Therefore the preview will be acquired by a normal scan which can consume considerable time." ; + Text [ portuguese ] = "O aparelho não oferece a possibilidade da previsualização. Por esta razão, será usada uma digitalização normal como previsualização. Isto poderá levar algum tempo." ; + Text [ english_us ] = "The device does not offer a preview option. Therefore, a normal scan will be used as a preview instead. This may take a considerable amount of time." ; + Text [ portuguese_brazilian ] = "Das Gerõt ist nicht auf die Erzeugung einer Vorschau eingerichtet. Statt dessen wird als Vorschau ein normaler Scan verwendet. Dieser kann deutlich lõnger dauern." ; + Text [ swedish ] = "Enheten är inte inställd för att skapa en förhandsvisning. I stället används en vanlig skanning som förhandsvisning. Detta kan ta betydligt längre tid." ; + Text [ danish ] = "Enheden er ikke indstillet til at kunne oprette eksempler. Istedet bruges et almindelig scan som eksempel. Dette kan komme til at vare betydelig længere tid." ; + Text [ italian ] = "L'apparecchiatura non è impostata per la creazione di un'anteprima. Al suo posto viene usata come anteprima una normale scansione. Ciò può richiedere molto più tempo." ; + Text [ spanish ] = "El dispositivo no está preparado para ofrecer opción de previsualización. En lugar de esta se utilizará un escaneado normal, que puede tardar considerablemente más." ; + Text [ french ] = "Le périphérique utilisé ne permet pas de créer un aperçu. Il permet uniquement une digitalisation normale en guise d'aperçu, ce qui peut durer nettement plus longtemps." ; + Text [ dutch ] = "Het apparaat is niet ingesteld op het maken van een voorbeeld. In plaats daarvan wordt gebruik gemaakt van een normale scan als voorbeeld. Dit kan beduidend langer duren." ; + Text[ chinese_simplified ] = "Õâ¸öÉ豸ûÓÐÔ¤ÊÓ¹¦ÄÜ¡£²ÉÓÃÆÕͨµÄɨÃ跽ʽԤÊÓ¿ÉÄÜÐèÒª½Ï³¤µÄʱ¼ä¡£"; + Text[ russian ] = "Óñòðîéñòâî íå íàñòðîåíî íà ñîçäàíèå ïðåäâàðèòåëüíîãî ïðîñìîòðà. Âìåñòî ýòîãî èñïîëüçóåòñÿ â êà÷åñòâå ïðåäâàðèòåëüíîãî ïðîñìîòðà îáû÷íîå ñêàíèðîâàíèå. Ýòîò ïðîöåññ ïðîäëèòñÿ çíà÷èòåëüíî äîëüøå."; + Text[ polish ] = "To urz¹dzenie nie mo¿e utworzyæ podgl¹du. Zamiast tego zostanie zastosowany jako podgl¹d normalny tryb przegl¹du. To mo¿e trochê d³u¿ej potrwaæ."; + Text[ japanese ] = "‚±‚ÌÃÞÊÞ²½‚ÍÌßÚËÞ°‚Ì쬂ɂ͓K‚µ‚Ä‚¢‚Ü‚¹‚ñB‚»‚Ì‚©‚í‚è‚É•’ʂ̽·¬Ý‚ªÌßÚËÞ°‚Æ‚µ‚ÄŽg—p‚³‚ê‚Ü‚·‚ªAŽžŠÔ‚ª‚©‚©‚è‚Ü‚·B"; + Text[ chinese_traditional ] = "³oÓ³]³Æ¨S¦³³]©w¹wµø¥\\¯à¡C¦]¦¹±Ä¥Î´¶³qªº±½´y¤è¦¡¹wµø·|»Ýn¸ûªøªº®É¶¡¡C"; + Text[ arabic ] = "ÇáÌåÇÒ ÛíÑ ãõÚÏ áÅäÔÇÁ ãÚÇíäÉ. ÈÏáÇð ãä åÐÇ¡ ÓæÝ íÊã ÇÓÊÎÏÇã ãÓÍ ÚÇÏí ßãÚÇíäÉ. íãßä Ãä íÓÊÛÑÞ Ðáß ÝÊÑÉ ÃØæá ÈßËíÑ."; + Text[ dutch ] = "Het apparaat is niet ingesteld op het maken van een voorbeeld. In plaats daarvan wordt gebruik gemaakt van een normale scan als voorbeeld. Dit kan beduidend langer duren."; + Text[ chinese_simplified ] = "Õâ¸öÉ豸ûÓÐÔ¤ÊÓ¹¦ÄÜ¡£²ÉÓÃÆÕͨµÄɨÃ跽ʽԤÊÓ¿ÉÄÜÐèÒª½Ï³¤µÄʱ¼ä¡£"; + Text[ greek ] = "Ç óõóêåõÞ äåí Ý÷åé ñõèìéóôåß ãéá ôçí åìöÜíéóç ðñïåðéóêüðçóçò. Áíôß áõôïý ÷ñçóéìïðïéåßôáé ìéá êáíïíéêÞ óÜñùóç. Ç äéáäéêáóßá áõôÞ ìðïñåß íá áñãÞóåé ðåñéóóüôåñï."; + Text[ korean ] = "ÀåÄ¡°¡ ¹Ì¸® º¸±â ¿É¼ÇÀ» Á¦°øÇÏÁö ¾Ê½À´Ï´Ù. ±× ´ë½Å º¸Åë ½ºÄµÀÌ ¹Ì¸® º¸±â·Î ÀÌ¿ëµÉ °ÍÀÔ´Ï´Ù. ÀÌ ½ºÄµÀº ½Ã°£ÀÌ ÈξÀ ´õ ¿À·¡ °É¸± ¼ö ÀÖ½À´Ï´Ù."; + Text[ turkish ] = "Cihaz önizleme iþlevine desteklemiyor. Bunun yerine önizleme olarak normal bir tarama görüntüsü kullanýlacak. Bu iþlem daha fazla zaman alabilir."; +}; +String RID_SANE_NOSANELIB_TXT +{ + Text = "Das SANE Interface konnte nicht initialisiert werden. Es kann kein Scanvorgang stattfinden." ; + Text [ English ] = "The SANE interface could not be initialized. Scanning is not possible." ; + Text [ portuguese ] = "Impossível inicializar a interface SANE. Impossível iniciar o processo de digitalização." ; + Text [ english_us ] = "The SANE interface could not be initialized. Scanning is not possible." ; + Text [ portuguese_brazilian ] = "Das SANE Interface konnte nicht initialisiert werden. Es kann kein Scanvorgang stattfinden." ; + Text [ swedish ] = "SANE-gränssnittet kunde inte initialiseras. Det är inte möjligt att skanna." ; + Text [ danish ] = "Det var ikke muligt at initialisere SANE-grænsefladen. Scanning er ikke mulig." ; + Text [ italian ] = "Non è stato possibile inizializzare l'interfaccia SANE. Non è possibile eseguire lo scanning." ; + Text [ spanish ] = "La interfaz SANE no se pudo inicializar. No se puede realizar ningún proceso de digitalización." ; + Text [ french ] = "L'interface SANE n'a pas pu être initialisée. Impossible de scanner." ; + Text [ dutch ] = "Het SANE interface kon niet worden geïnitialiseerd. Scannen is niet mogelijk." ; + Text[ chinese_simplified ] = "ÎÞ·¨³õʼ»¯ SANE ½çÃæ¡£ÎÞ·¨Ö´ÐÐɨÃè×÷Òµ¡£"; + Text[ russian ] = "Èíòåðôåéñ SANE íå óäåòñÿ èíèöèàëèçèðîâàòü. Ïðîöåññ ñêàíèðîâàíèÿ íåâîçìîæåí."; + Text[ polish ] = "Interfejsu SANE nie mo¿na zainincjowaæ. Skanowanie niemo¿liwe."; + Text[ japanese ] = "‚±‚ÌSANE²ÝÀ°Ìª²½‚͉Šú‰»‚Å‚«‚Ü‚¹‚ñB½·¬ÝŽÀs‚Í•s‰Â”\\‚Å‚·B"; + Text[ chinese_traditional ] = "µLªkªì©l¤Æ SANE ¬É±¡CµLªk°õ¦æ±½´y§@·~¡C"; + Text[ arabic ] = "ÊÚÐÑ ÊËÈíÊ ÇáæÇÌåÉ SANE. áåÐÇ ÝÅäå ãä ÛíÑ Çáããßä ÅÌÑÇÁ ÚãáíÉ ÇáãÓÍ ÇáÖæÆí."; + Text[ dutch ] = "Het SANE interface kon niet worden geïnitialiseerd. Scannen is niet mogelijk."; + Text[ chinese_simplified ] = "ÎÞ·¨³õʼ»¯ SANE ½çÃæ¡£ÎÞ·¨Ö´ÐÐɨÃè×÷Òµ¡£"; + Text[ greek ] = "Äåí Þôáí äõíáôüí íá ãßíåé áíáãíþñéóç ôçò äéáóýíäåóçò SANE. Áäýíáôïí íá ãßíåé óÜñùóç."; + Text[ korean ] = "SANE ÀÎÅÍÆäÀ̽º¸¦ ÃʱâÈÇÏÁö ¸øÇØ ½ºÄµ°úÁ¤À» ÁøÇàÇÒ ¼ö ¾ø½À´Ï´Ù."; + Text[ turkish ] = "SANE arabirimi baþlatýlamadý. Tarama iþlemi yürütülemez."; +}; diff --git a/extensions/source/scanner/scanner.cxx b/extensions/source/scanner/scanner.cxx new file mode 100644 index 000000000000..d25d418ff951 --- /dev/null +++ b/extensions/source/scanner/scanner.cxx @@ -0,0 +1,162 @@ +/************************************************************************* + * + * $RCSfile: scanner.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 <scanner.hxx> + +// ------------------ +// - ScannerManager - +// ------------------ + +REF( XInterface ) SAL_CALL ScannerManager_CreateInstance( const REF( com::sun::star::lang::XMultiServiceFactory )& rxFactory ) throw ( Exception ) +{ + return *( new ScannerManager() ); +} + +// ----------------------------------------------------------------------------- + +ScannerManager::ScannerManager() : + mpData( NULL ) +{ +} + +// ----------------------------------------------------------------------------- + +ScannerManager::~ScannerManager() +{ + DestroyData(); +} + +// ----------------------------------------------------------------------------- + +ANY SAL_CALL ScannerManager::queryInterface( const Type& rType ) throw( RuntimeException ) +{ + const ANY aRet( cppu::queryInterface( rType, + static_cast< XScannerManager* >( this ), + static_cast< AWT::XBitmap* >( this ) ) ); + + return( aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ) ); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL ScannerManager::acquire() throw( RuntimeException ) +{ + OWeakObject::acquire(); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL ScannerManager::release() throw( RuntimeException ) +{ + OWeakObject::release(); +} + +// ----------------------------------------------------------------------------- + +SEQ( sal_Int8 ) SAL_CALL ScannerManager::getMaskDIB() +{ + return SEQ( sal_Int8 )(); +} + +// ----------------------------------------------------------------------------- + +OUString ScannerManager::getImplementationName() throw () +{ + return getImplementationName_Static(); +} + +// ----------------------------------------------------------------------------- + +OUString ScannerManager::getImplementationName_Static() throw() +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.scanner.ScannerManager" ) ); +} + +// ----------------------------------------------------------------------------- + +SEQ( OUString ) ScannerManager::getSupportedServiceNames() throw () +{ + return getSupportedServiceNames_Static(); +} + +// ----------------------------------------------------------------------------- + +SEQ( OUString ) ScannerManager::getSupportedServiceNames_Static() throw () +{ + SEQ( OUString ) aSNS( 1 ); + + aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.scanner.ScannerManager" ) ); + + return aSNS; +} + +// ----------------------------------------------------------------------------- + +BOOL ScannerManager::supportsService( const OUString& ServiceName ) throw () +{ + SEQ( OUString ) aSNL( getSupportedServiceNames() ); + const OUString* pArray = aSNL.getConstArray(); + + for( INT32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return TRUE; + + return FALSE; +} diff --git a/extensions/source/scanner/scanner.hxx b/extensions/source/scanner/scanner.hxx new file mode 100644 index 000000000000..dea0584fce4e --- /dev/null +++ b/extensions/source/scanner/scanner.hxx @@ -0,0 +1,172 @@ +/************************************************************************* + * + * $RCSfile: scanner.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 _EXT_SCANNER_HXX +#define _EXT_SCANNER_HXX + +#ifndef _STREAM_HXX +#include <tools/stream.hxx> +#endif +#ifndef _VOS_MUTEX_HXX_ +#include <vos/mutex.hxx> +#endif +#ifndef __RTL_USTRING_ +#include <rtl/ustring> +#endif +#ifndef _CPPUHELPER_WEAK_HXX_ +#include <cppuhelper/weak.hxx> +#endif +#ifndef _CPPUHELPER_WEAK_HXX_ +#include <cppuhelper/weak.hxx> +#endif +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif +#ifndef __COM_SUN_STAR_AWT_XBITMAP_HPP +#include <com/sun/star/awt/XBitmap.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_ +#include <com/sun/star/lang/XEventListener.hpp> +#endif +#ifndef __COM_SUN_STAR_LANG_EVENTOBJECT_HPP +#include <com/sun/star/lang/EventObject.hpp> +#endif +#ifndef _COM_SUN_STAR_SCANNER_XSCANNERMANAGER_HPP_ +#include <com/sun/star/scanner/XScannerManager.hpp> +#endif +#ifndef _COM_SUN_STAR_SCANNER_SCANNEREXCEPTION_HPP_ +#include <com/sun/star/scanner/ScannerException.hpp> +#endif + +using namespace rtl; +using namespace cppu; +using namespace com::sun::star::uno; +using namespace com::sun::star::scanner; + +// ----------- +// - Defines - +// ----------- + +#define REF( _def_Obj ) Reference< _def_Obj > +#define SEQ( _def_Obj ) Sequence< _def_Obj > +#define ANY Any +#define AWT com::sun::star::awt + +// ------------------ +// - ScannerManager - +// ------------------ + +class ScannerManager : public OWeakObject, XScannerManager, AWT::XBitmap +{ +protected: + + vos::OMutex maProtector; + void* mpData; + + void DestroyData(); + +public: + + ScannerManager(); + virtual ~ScannerManager(); + + // XInterface + virtual ANY SAL_CALL queryInterface( const Type & rType ) throw( RuntimeException ); + virtual void SAL_CALL acquire() throw( RuntimeException ); + virtual void SAL_CALL release() throw( RuntimeException ); + + // XScannerManager + virtual SEQ( ScannerContext ) SAL_CALL getAvailableScanners(); + virtual BOOL SAL_CALL configureScanner( ScannerContext& scanner_context ) throw( ScannerException ); + virtual void SAL_CALL startScan( const ScannerContext& scanner_context, const REF( com::sun::star::lang::XEventListener )& rxListener ) throw( ScannerException ); + virtual ScanError SAL_CALL getError( const ScannerContext& scanner_context ) throw( ScannerException ); + virtual REF( AWT::XBitmap ) SAL_CALL getBitmap( const ScannerContext& scanner_context ) throw( ScannerException ); + + // XBitmap + virtual AWT::Size SAL_CALL getSize(); + virtual SEQ( sal_Int8 ) SAL_CALL getDIB(); + virtual SEQ( sal_Int8 ) SAL_CALL getMaskDIB(); + + // Misc + OUString getImplementationName() throw(); + static OUString getImplementationName_Static() throw(); + Sequence< OUString > getSupportedServiceNames() throw(); + static Sequence< OUString > getSupportedServiceNames_Static() throw(); + BOOL supportsService( const OUString& ServiceName ) throw(); + + void Lock() { maProtector.acquire(); } + void Unlock() { maProtector.release(); } + + void* GetData() const { return mpData; } + void SetData( void* pData ) { DestroyData(); mpData = pData; } +}; + +// ----------------------------------------------------------------------------- + +REF( XInterface ) SAL_CALL ScannerManager_CreateInstance( const REF( com::sun::star::lang::XMultiServiceFactory )& rxFactory ) throw( Exception ); + +#endif diff --git a/extensions/source/scanner/scanunx.cxx b/extensions/source/scanner/scanunx.cxx new file mode 100644 index 000000000000..383c9ee202d0 --- /dev/null +++ b/extensions/source/scanner/scanunx.cxx @@ -0,0 +1,305 @@ +/************************************************************************* + * + * $RCSfile: scanunx.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 <scanner.hxx> +#include <sanedlg.hxx> +#include <vos/thread.hxx> +#include <tools/list.hxx> + +// ----------------------------------------------------------------------------- + +ANY SAL_CALL BitmapTransporter::queryInterface( const Type& rType ) throw( RuntimeException ) +{ + const ANY aRet( cppu::queryInterface( rType, static_cast< AWT::XBitmap* >( this ) ) ); + + return( aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ) ); +} + +// ----------------------------------------------------------------------------- + +AWT::Size BitmapTransporter::getSize() +{ + vos::OGuard aGuard( m_aProtector ); + int nPreviousPos = m_aStream.Tell(); + AWT::Size aRet; + + // ensure that there is at least a header + m_aStream.Seek( STREAM_SEEK_TO_END ); + int nLen = m_aStream.Tell(); + if( nLen > 15 ) + { + m_aStream.Seek( 4 ); + m_aStream >> aRet.Width >> aRet.Height; + } + else + aRet.Width = aRet.Height = 0; + + m_aStream.Seek( nPreviousPos ); + + return aRet; +} + +// ----------------------------------------------------------------------------- + +SEQ( sal_Int8 ) BitmapTransporter::getDIB() +{ + vos::OGuard aGuard( m_aProtector ); + int nPreviousPos = m_aStream.Tell(); + + // create return value + m_aStream.Seek( STREAM_SEEK_TO_END ); + int nBytes = m_aStream.Tell(); + m_aStream.Seek( 0 ); + + SEQ( sal_Int8 ) aValue( nBytes ); + m_aStream.Read( aValue.getArray(), nBytes ); + m_aStream.Seek( nPreviousPos ); + + return aValue; +} + +// -------------- +// - SaneHolder - +// -------------- + +struct SaneHolder +{ + Sane m_aSane; + REF( AWT::XBitmap ) m_xBitmap; + vos::OMutex m_aProtector; + ScanError m_nError; +}; + +DECLARE_LIST( SaneHolderList, SaneHolder* ); + +static SaneHolderList allSanes; +static vos::OMutex aSaneProtector; + +// ----------------- +// - ScannerThread - +// ----------------- + +class ScannerThread : public vos::OThread +{ + SaneHolder* m_pHolder; + REF( com::sun::star::lang::XEventListener ) m_xListener; + ScannerManager* m_pManager; // just for the disposing call + + virtual void run(); + virtual void onTerminated() { delete this; } +public: + ScannerThread( SaneHolder* pHolder, + const REF( com::sun::star::lang::XEventListener )& listener, + ScannerManager* pManager ) + : m_pHolder( pHolder ), m_xListener( listener ), m_pManager( pManager ) {} + virtual ~ScannerThread() {} +}; + +// ----------------------------------------------------------------------------- + +void ScannerThread::run() +{ + vos::OGuard aGuard( m_pHolder->m_aProtector ); + REF( XInterface ) aIf( static_cast< OWeakObject* >( new BitmapTransporter ) ); + + m_pHolder->m_xBitmap = REF( AWT::XBitmap )( aIf, UNO_QUERY ); + + if( m_pHolder->m_aSane.IsOpen() ) + { + int nOption = m_pHolder->m_aSane.GetOptionByName( "preview" ); + if( nOption != -1 ) + m_pHolder->m_aSane.SetOptionValue( nOption, (BOOL)FALSE ); + + m_pHolder->m_nError = + m_pHolder->m_aSane.Start( *(BitmapTransporter*)&m_pHolder->m_xBitmap ) ? + ScanError_ScanErrorNone : ScanError_ScanCanceled; + } + else + m_pHolder->m_nError = ScanError_ScannerNotAvailable; + + m_xListener->disposing( com::sun::star::lang::EventObject( REF( XInterface )( static_cast< OWeakObject* >( m_pManager ) ) ) ); +} + +// ------------------ +// - ScannerManager - +// ------------------ + +void ScannerManager::DestroyData() +{ + // unused +} + +// ----------------------------------------------------------------------------- + +AWT::Size ScannerManager::getSize() +{ + AWT::Size aRet; + aRet.Width = aRet.Height = 0; + return aRet; +} + +// ----------------------------------------------------------------------------- + +SEQ( sal_Int8 ) ScannerManager::getDIB() +{ + return SEQ( sal_Int8 )(); +} + +// ----------------------------------------------------------------------------- + +SEQ( ScannerContext ) ScannerManager::getAvailableScanners() +{ + vos::OGuard aGuard( aSaneProtector ); + + if( ! allSanes.Count() ) + { + SaneHolder* pSaneHolder = new SaneHolder; + pSaneHolder->m_nError = ScanError_ScanErrorNone; + if( Sane::IsSane() ) + allSanes.Insert( pSaneHolder ); + else + delete pSaneHolder; + } + + if( Sane::IsSane() ) + { + SEQ( ScannerContext ) aRet(1); + aRet.getArray()[0].ScannerName = ::rtl::OUString::createFromAscii( "SANE" ); + aRet.getArray()[0].InternalData = 0; + return aRet; + } + + return SEQ( ScannerContext )(); +} + +// ----------------------------------------------------------------------------- + +BOOL ScannerManager::configureScanner( ScannerContext& scanner_context ) throw( ScannerException ) +{ + vos::OGuard aGuard( aSaneProtector ); + + if( scanner_context.InternalData < 0 || scanner_context.InternalData >= allSanes.Count() ) + throw ScannerException( + ::rtl::OUString::createFromAscii( "Scanner does not exist" ), + REF( XScannerManager )( this ), + ScanError_InvalidContext + ); + SaneDlg aDlg( NULL, allSanes.GetObject( scanner_context.InternalData )->m_aSane ); + return (BOOL)aDlg.Execute(); +} + +// ----------------------------------------------------------------------------- + +void ScannerManager::startScan( const ScannerContext& scanner_context, + const REF( com::sun::star::lang::XEventListener )& listener ) throw( ScannerException ) +{ + vos::OGuard aGuard( aSaneProtector ); + + if( scanner_context.InternalData < 0 || scanner_context.InternalData >= allSanes.Count() ) + throw ScannerException( + ::rtl::OUString::createFromAscii( "Scanner does not exist" ), + REF( XScannerManager )( this ), + ScanError_InvalidContext + ); + SaneHolder* pHolder = allSanes.GetObject( scanner_context.InternalData ); + + ScannerThread* pThread = new ScannerThread( pHolder, listener, this ); + pThread->create(); +} + +// ----------------------------------------------------------------------------- + +ScanError ScannerManager::getError( const ScannerContext& scanner_context ) throw( ScannerException ) +{ + vos::OGuard aGuard( aSaneProtector ); + + if( scanner_context.InternalData < 0 || scanner_context.InternalData >= allSanes.Count() ) + throw ScannerException( + ::rtl::OUString::createFromAscii( "Scanner does not exist" ), + REF( XScannerManager )( this ), + ScanError_InvalidContext + ); + + SaneHolder* pHolder = allSanes.GetObject( scanner_context.InternalData ); + + return pHolder->m_nError; +} + +// ----------------------------------------------------------------------------- + +REF( AWT::XBitmap ) ScannerManager::getBitmap( const ScannerContext& scanner_context ) throw( ScannerException ) +{ + vos::OGuard aGuard( aSaneProtector ); + + if( scanner_context.InternalData < 0 || scanner_context.InternalData >= allSanes.Count() ) + throw ScannerException( + ::rtl::OUString::createFromAscii( "Scanner does not exist" ), + REF( XScannerManager )( this ), + ScanError_InvalidContext + ); + SaneHolder* pHolder = allSanes.GetObject( scanner_context.InternalData ); + + vos::OGuard aProtGuard( pHolder->m_aProtector ); + + REF( AWT::XBitmap ) xRet( pHolder->m_xBitmap ); + pHolder->m_xBitmap = REF( AWT::XBitmap )(); + + return xRet; +} diff --git a/extensions/source/scanner/scanwin.cxx b/extensions/source/scanner/scanwin.cxx new file mode 100644 index 000000000000..5d6891df24b2 --- /dev/null +++ b/extensions/source/scanner/scanwin.cxx @@ -0,0 +1,852 @@ +/************************************************************************* + * + * $RCSfile: scanwin.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 <math.h> +#include <tools/svwin.h> +#include <tools/stream.hxx> +#include <vos/mutex.hxx> +#include <vos/module.hxx> +#include <vcl/svapp.hxx> +#include <vcl/wrkwin.hxx> +#include <vcl/sysdata.hxx> +#include <vcl/salbtype.hxx> +#include "scanner.hxx" +#include "twain/twain.h" + +// ----------- +// - Defines - +// ----------- + +#define TWAIN_SELECT 0x00000001UL +#define TWAIN_ACQUIRE 0x00000002UL +#define TWAIN_TERMINATE 0xFFFFFFFFUL + +#define TWAIN_EVENT_NONE 0x00000000UL +#define TWAIN_EVENT_QUIT 0x00000001UL +#define TWAIN_EVENT_SCANNING 0x00000002UL +#define TWAIN_EVENT_XFER 0x00000004UL + +#define PFUNC (*pDSM) +#define PTWAINMSG MSG* +#define FIXTODOUBLE( nFix ) ((double)nFix.Whole+(double)nFix.Frac/65536.) +#define FIXTOLONG( nFix ) ((long)floor(FIXTODOUBLE(nFix)+0.5)) + +#if defined WIN +#define TWAIN_LIBNAME "TWAIN.DLL" +#define TWAIN_FUNCNAME "DSM_Entry" +#elif defined WNT +#define TWAIN_LIBNAME "TWAIN_32.DLL" +#define TWAIN_FUNCNAME "DSM_Entry" +#endif + +// -------------- +// - TwainState - +// -------------- + +enum TwainState +{ + TWAIN_STATE_NONE = 0, + TWAIN_STATE_SCANNING = 1, + TWAIN_STATE_DONE = 2, + TWAIN_STATE_CANCELED = 3 +}; + +// ------------ +// - ImpTwain - +// ------------ + +class ImpTwain +{ + ScannerManager* mpMgr; + TW_IDENTITY aAppIdent; + TW_IDENTITY aSrcIdent; + Link aNotifyLink; + DSMENTRYPROC pDSM; + NAMESPACE_VOS( OModule )* pMod; + ULONG nCurState; + + void ImplCreate(); + void ImplOpenSourceManager(); + void ImplOpenSource(); + BOOL ImplEnableSource(); + void ImplXfer(); + void ImplFallback( ULONG nEvent ); + + DECL_LINK( ImplFallbackHdl, void* ); + DECL_LINK( ImplDestroyHdl, void* ); + +public: + + HWND hTwainWnd; + HHOOK hTwainHook; + + BOOL ImplHandleMsg( void* pMsg ); + +public: + + ImpTwain( ScannerManager* pMgr, const Link& rNotifyLink ); + ~ImpTwain(); + + void Destroy(); + + BOOL SelectSource(); + BOOL InitXfer(); +}; + +// --------- +// - Procs - +// --------- + +static ImpTwain* pImpTwainInstance = NULL; + +// ------------------------------------------------------------------------- + +LRESULT CALLBACK TwainWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) +{ + return DefWindowProc( hWnd, nMsg, nPar1, nPar2 ); +} + +// ------------------------------------------------------------------------- + +LRESULT CALLBACK TwainMsgProc( int nCode, WPARAM wParam, LPARAM lParam ) +{ + MSG* pMsg = (MSG*) lParam; + + if( ( nCode < 0 ) || + ( pImpTwainInstance->hTwainWnd != pMsg->hwnd ) || + !pImpTwainInstance->ImplHandleMsg( (void*) lParam ) ) + { + return CallNextHookEx( pImpTwainInstance->hTwainHook, nCode, wParam, lParam ); + } + else + { + pMsg->message = WM_USER; + pMsg->lParam = 0; + + return 0; + } +} + +// ----------------------------------------------------------------------------- + +ImpTwain::ImpTwain( ScannerManager* pMgr, const Link& rNotifyLink ) : + mpMgr ( pMgr ), + aNotifyLink ( rNotifyLink ), + pDSM ( NULL ), + pMod ( NULL ), + hTwainWnd ( 0 ), + hTwainHook ( 0 ), + nCurState ( 1 ) +{ + pImpTwainInstance = this; + + aAppIdent.Id = 0; + aAppIdent.Version.MajorNum = 1; + aAppIdent.Version.MinorNum = 0; + aAppIdent.Version.Language = TWLG_USA; + aAppIdent.Version.Country = TWCY_USA; + aAppIdent.ProtocolMajor = TWON_PROTOCOLMAJOR; + aAppIdent.ProtocolMinor = TWON_PROTOCOLMINOR; + aAppIdent.SupportedGroups = DG_IMAGE | DG_CONTROL; + strcpy( aAppIdent.Version.Info, "StarOffice" ); + strcpy( aAppIdent.Manufacturer, "Sun Microsystems"); + strcpy( aAppIdent.ProductFamily,"Office"); + strcpy( aAppIdent.ProductName, "StarOffice"); + + HWND hParentWnd = HWND_DESKTOP; + WNDCLASS aWc = { 0, &TwainWndProc, 0, sizeof( WNDCLASS ), GetModuleHandle( NULL ), + NULL, NULL, NULL, NULL, "TwainClass" }; + + RegisterClass( &aWc ); + hTwainWnd = CreateWindowEx( WS_EX_TOPMOST, aWc.lpszClassName, "TWAIN", 0, 0, 0, 0, 0, hParentWnd, NULL, aWc.hInstance, 0 ); + hTwainHook = SetWindowsHookEx( WH_GETMESSAGE, &TwainMsgProc, NULL, GetCurrentThreadId() ); +} + +// ----------------------------------------------------------------------------- + +ImpTwain::~ImpTwain() +{ +} + +// ----------------------------------------------------------------------------- + +void ImpTwain::Destroy() +{ + ImplFallback( TWAIN_EVENT_NONE ); + Application::PostUserEvent( LINK( this, ImpTwain, ImplDestroyHdl ), NULL ); +} + +// ----------------------------------------------------------------------------- + +BOOL ImpTwain::SelectSource() +{ + TW_UINT16 nRet = TWRC_FAILURE; + + ImplOpenSourceManager(); + + if( 3 == nCurState ) + { + TW_IDENTITY aIdent; + + aIdent.Id = 0, aIdent.ProductName[ 0 ] = '\0'; + aNotifyLink.Call( (void*) TWAIN_EVENT_SCANNING ); + nRet = PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_USERSELECT, &aIdent ); + } + + ImplFallback( TWAIN_EVENT_QUIT ); + + return( nRet == TWRC_SUCCESS || nRet == TWRC_CANCEL ); +} + +// ----------------------------------------------------------------------------- + +BOOL ImpTwain::InitXfer() +{ + BOOL bRet = FALSE; + + ImplOpenSourceManager(); + + if( 3 == nCurState ) + { + ImplOpenSource(); + + if( 4 == nCurState ) + bRet = ImplEnableSource(); + } + + if( !bRet ) + ImplFallback( TWAIN_EVENT_QUIT ); + + return bRet; +} + +// ----------------------------------------------------------------------------- + +void ImpTwain::ImplOpenSourceManager() +{ + if( 1 == nCurState ) + { + pMod = new ::vos::OModule( ::rtl::OUString() ); + + if( pMod->load( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( TWAIN_LIBNAME ) ) ) ) + { + nCurState = 2; + + if( ( ( pDSM = (DSMENTRYPROC) pMod->getSymbol( String( RTL_CONSTASCII_USTRINGPARAM( TWAIN_FUNCNAME ) ) ) ) != NULL ) && + ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_PARENT, MSG_OPENDSM, &hTwainWnd ) == TWRC_SUCCESS ) ) + { + nCurState = 3; + } + } + else + { + delete pMod; + pMod = NULL; + } + } +} + +// ----------------------------------------------------------------------------- + +void ImpTwain::ImplOpenSource() +{ + if( 3 == nCurState ) + { + if( ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETDEFAULT, &aSrcIdent ) == TWRC_SUCCESS ) && + ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, &aSrcIdent ) == TWRC_SUCCESS ) ) + { + TW_CAPABILITY aCap = { CAP_XFERCOUNT, TWON_ONEVALUE, GlobalAlloc( GHND, sizeof( TW_ONEVALUE ) ) }; + TW_ONEVALUE* pVal = (TW_ONEVALUE*) GlobalLock( aCap.hContainer ); + + pVal->ItemType = TWTY_INT16, pVal->Item = 1; + GlobalUnlock( aCap.hContainer ); + PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_CAPABILITY, MSG_SET, &aCap ); + GlobalFree( aCap.hContainer ); + nCurState = 4; + } + } +} + +// ----------------------------------------------------------------------------- + +BOOL ImpTwain::ImplEnableSource() +{ + BOOL bRet = FALSE; + + if( 4 == nCurState ) + { + TW_USERINTERFACE aUI = { TRUE, TRUE, hTwainWnd }; + + aNotifyLink.Call( (void*) TWAIN_EVENT_SCANNING ); + nCurState = 5; + + if( PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_USERINTERFACE, MSG_ENABLEDS, &aUI ) == TWRC_SUCCESS ) + bRet = TRUE; + else + nCurState = 4; + } + + return bRet; +} + +// ----------------------------------------------------------------------------- + +BOOL ImpTwain::ImplHandleMsg( void* pMsg ) +{ + TW_UINT16 nRet; + PTWAINMSG pMess = (PTWAINMSG) pMsg; + TW_EVENT aEvt = { pMess, MSG_NULL }; + + nRet = PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT, &aEvt ); + + if( aEvt.TWMessage != MSG_NULL ) + { + switch( aEvt.TWMessage ) + { + case MSG_XFERREADY: + { + ULONG nEvent = TWAIN_EVENT_QUIT; + + if( 5 == nCurState ) + { + nCurState = 6; + ImplXfer(); + + if( mpMgr && mpMgr->GetData() ) + nEvent = TWAIN_EVENT_XFER; + } + + ImplFallback( nEvent ); + } + break; + + case MSG_CLOSEDSREQ: + ImplFallback( TWAIN_EVENT_QUIT ); + break; + + default: + break; + } + } + else + nRet = TWRC_NOTDSEVENT; + + return( TWRC_DSEVENT == nRet ); +} + +// ----------------------------------------------------------------------------- + +void ImpTwain::ImplXfer() +{ + if( nCurState == 6 ) + { + TW_IMAGEINFO aInfo; + TW_UINT32 hDIB = 0; + long nWidth, nHeight, nXRes, nYRes; + + if( PFUNC( &aAppIdent, &aSrcIdent, DG_IMAGE, DAT_IMAGEINFO, MSG_GET, &aInfo ) == TWRC_SUCCESS ) + { + nWidth = aInfo.ImageWidth; + nHeight = aInfo.ImageLength; + nXRes = FIXTOLONG( aInfo.XResolution ); + nYRes = FIXTOLONG( aInfo.YResolution ); + } + else + nWidth = nHeight = nXRes = nYRes = -1L; + + switch( PFUNC( &aAppIdent, &aSrcIdent, DG_IMAGE, DAT_IMAGENATIVEXFER, MSG_GET, &hDIB ) ) + { + case( TWRC_CANCEL ): + nCurState = 7; + break; + + case( TWRC_XFERDONE ): + { + if( mpMgr && hDIB ) + { + if( ( nXRes != -1 ) && ( nYRes != - 1 ) && ( nWidth != - 1 ) && ( nHeight != - 1 ) ) + { + // set resolution of bitmap + BITMAPINFOHEADER* pBIH = (BITMAPINFOHEADER*) GlobalLock( (HGLOBAL) hDIB ); + static const double fFactor = 100.0 / 2.54; + + pBIH->biXPelsPerMeter = FRound( fFactor * nXRes ); + pBIH->biYPelsPerMeter = FRound( fFactor * nYRes ); + + GlobalUnlock( (HGLOBAL) hDIB ); + } + + mpMgr->SetData( (void*)(long) hDIB ); + } + else + GlobalFree( (HGLOBAL) hDIB ); + + nCurState = 7; + } + break; + + default: + break; + } + } +} + +// ----------------------------------------------------------------------------- + +void ImpTwain::ImplFallback( ULONG nEvent ) +{ + Application::PostUserEvent( LINK( this, ImpTwain, ImplFallbackHdl ), (void*) nEvent ); +} + +// ----------------------------------------------------------------------------- + +IMPL_LINK( ImpTwain, ImplFallbackHdl, void*, pData ) +{ + const ULONG nEvent = (ULONG) pData; + BOOL bFallback = TRUE; + + switch( nCurState ) + { + case( 7 ): + case( 6 ): + { + TW_PENDINGXFERS aXfers; + + if( PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_PENDINGXFERS, MSG_ENDXFER, &aXfers ) == TWRC_SUCCESS ) + { + if( aXfers.Count != 0 ) + PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_PENDINGXFERS, MSG_RESET, &aXfers ); + } + + nCurState = 5; + } + break; + + case( 5 ): + { + TW_USERINTERFACE aUI = { TRUE, TRUE, hTwainWnd }; + + PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_USERINTERFACE, MSG_DISABLEDS, &aUI ); + nCurState = 4; + } + break; + + case( 4 ): + { + PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, &aSrcIdent ); + nCurState = 3; + } + break; + + case( 3 ): + { + PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_PARENT, MSG_CLOSEDSM, &hTwainWnd ); + nCurState = 2; + } + break; + + case( 2 ): + { + delete pMod; + pMod = NULL; + nCurState = 1; + } + break; + + default: + { + if( nEvent != TWAIN_EVENT_NONE ) + aNotifyLink.Call( (void*) nEvent ); + + bFallback = FALSE; + } + break; + } + + if( bFallback ) + ImplFallback( nEvent ); + + return 0L; +} + +// ----------------------------------------------------------------------------- + +IMPL_LINK( ImpTwain, ImplDestroyHdl, void*, p ) +{ + if( hTwainWnd ) + DestroyWindow( hTwainWnd ); + + if( hTwainHook ) + UnhookWindowsHookEx( hTwainHook ); + + delete this; + pImpTwainInstance = NULL; + + return 0L; +} + +// --------- +// - Twain - +// --------- + +class Twain +{ + ScannerManager* mpMgr; + REF( com::sun::star::lang::XEventListener ) mxListener; + ImpTwain* mpImpTwain; + TwainState meState; + + DECL_LINK( ImpNotifyHdl, ImpTwain* ); + +public: + + Twain(); + ~Twain(); + + BOOL SelectSource(); + BOOL PerformTransfer( ScannerManager* pMgr, + const REF( com::sun::star::lang::XEventListener )& rxListener ); + + TwainState GetState() const { return meState; } +}; + +// ------------------------------------------------------------------------ + +Twain::Twain() : + mpMgr ( NULL ), + mpImpTwain ( NULL ), + meState ( TWAIN_STATE_NONE ) +{ +} + +// ------------------------------------------------------------------------ + +Twain::~Twain() +{ + if( mpImpTwain ) + mpImpTwain->Destroy(); +} + +// ------------------------------------------------------------------------ + +BOOL Twain::SelectSource() +{ + BOOL bRet; + + if( !mpImpTwain ) + { + meState = TWAIN_STATE_NONE; + mpImpTwain = new ImpTwain( mpMgr, LINK( this, Twain, ImpNotifyHdl ) ); + bRet = mpImpTwain->SelectSource(); + } + else + bRet = FALSE; + + return bRet; +} + +// ------------------------------------------------------------------------ + +BOOL Twain::PerformTransfer( ScannerManager* pMgr, const REF( com::sun::star::lang::XEventListener )& rxListener ) +{ + BOOL bRet; + + if( pMgr && !mpImpTwain ) + { + mpMgr = pMgr; + mxListener = rxListener; + meState = TWAIN_STATE_NONE; + mpImpTwain = new ImpTwain( mpMgr, LINK( this, Twain, ImpNotifyHdl ) ); + bRet = mpImpTwain->InitXfer(); + } + else + bRet = FALSE; + + return bRet; +} + +// ------------------------------------------------------------------------ + +IMPL_LINK( Twain, ImpNotifyHdl, ImpTwain*, nEvent ) +{ + switch( (ULONG)(void*) nEvent ) + { + case( TWAIN_EVENT_SCANNING ): + meState = TWAIN_STATE_SCANNING; + break; + + case( TWAIN_EVENT_QUIT ): + { + if( meState != TWAIN_STATE_DONE ) + meState = TWAIN_STATE_CANCELED; + + mpImpTwain->Destroy(); + mpImpTwain = NULL; + + if( mpMgr && mxListener.is() ) + mxListener->disposing( com::sun::star::lang::EventObject( REF( XInterface )( static_cast< OWeakObject* >( mpMgr ) ) ) ); + + mxListener = REF( com::sun::star::lang::XEventListener )(); + } + break; + + case( TWAIN_EVENT_XFER ): + { + if( mpImpTwain ) + { + meState = ( ( mpMgr && mpMgr->GetData() ) ? TWAIN_STATE_DONE : TWAIN_STATE_CANCELED ); + + mpImpTwain->Destroy(); + mpImpTwain = NULL; + + if( mpMgr && mxListener.is() ) + mxListener->disposing( com::sun::star::lang::EventObject( REF( XInterface )( static_cast< OWeakObject* >( mpMgr ) ) ) ); + } + + mxListener = REF( com::sun::star::lang::XEventListener )(); + } + break; + + default: + break; + } + + return 0L; +} + +// ----------- +// - statics - +// ----------- + +static Twain aTwain; + +// ------------------ +// - ScannerManager - +// ------------------ + +void ScannerManager::DestroyData() +{ + if( mpData ) + { + GlobalFree( (HGLOBAL)(long) mpData ); + mpData = NULL; + } +} + +// ----------------------------------------------------------------------------- + +AWT::Size ScannerManager::getSize() +{ + AWT::Size aRet; + HGLOBAL hDIB = (HGLOBAL)(long) mpData; + + if( hDIB ) + { + BITMAPINFOHEADER* pBIH = (BITMAPINFOHEADER*) GlobalLock( hDIB ); + + if( pBIH ) + { + aRet.Width = pBIH->biWidth; + aRet.Height = pBIH->biHeight; + } + else + aRet.Width = aRet.Height = 0; + + GlobalUnlock( hDIB ); + } + else + aRet.Width = aRet.Height = 0; + + return aRet; +} + +// ----------------------------------------------------------------------------- + +SEQ( sal_Int8 ) ScannerManager::getDIB() +{ + SEQ( sal_Int8 ) aRet; + + if( mpData ) + { + HGLOBAL hDIB = (HGLOBAL)(long) mpData; + const sal_uInt32 nDIBSize = GlobalSize( hDIB ); + sal_uInt32 nSize = sizeof( BITMAPFILEHEADER) + nDIBSize; + BITMAPINFOHEADER* pBIH = (BITMAPINFOHEADER*) GlobalLock( hDIB ); + + if( pBIH ) + { + sal_uInt32 nColEntries; + + switch( pBIH->biBitCount ) + { + case( 1 ): + case( 4 ): + case( 8 ): + nColEntries = pBIH->biClrUsed ? pBIH->biClrUsed : ( 1 << pBIH->biBitCount ); + break; + + case( 24 ): + nColEntries = pBIH->biClrUsed ? pBIH->biClrUsed : 0; + break; + + case( 16 ): + case( 32 ): + { + nColEntries = pBIH->biClrUsed; + + if( pBIH->biCompression == BI_BITFIELDS ) + nColEntries += 3; + } + break; + + default: + nColEntries = 0; + break; + } + + aRet = SEQ( sal_Int8 )( sizeof( BITMAPFILEHEADER ) + nDIBSize ); + + sal_Int8* pBuf = aRet.getArray(); + SvMemoryStream* pMemStm = new SvMemoryStream( (char*) pBuf, sizeof( BITMAPFILEHEADER ), STREAM_WRITE ); + + *pMemStm << 'B' << 'M' << (sal_uInt32) 0 << (sal_uInt32) 0; + *pMemStm << (sal_uInt32) ( sizeof( BITMAPFILEHEADER ) + pBIH->biSize + ( nColEntries * sizeof( RGBQUAD ) ) ); + + delete pMemStm; + HMEMCPY( pBuf + sizeof( BITMAPFILEHEADER ), pBIH, nDIBSize ); + } + + GlobalUnlock( hDIB ); + DestroyData(); + } + + return aRet; +} + +// ----------------------------------------------------------------------------- + +SEQ( ScannerContext ) SAL_CALL ScannerManager::getAvailableScanners() +{ + vos::OGuard aGuard( maProtector ); + SEQ( ScannerContext ) aRet( 1 ); + + aRet.getArray()[0].ScannerName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TWAIN" ) ); + aRet.getArray()[0].InternalData = 0; + + return aRet; +} + +// ----------------------------------------------------------------------------- + +BOOL SAL_CALL ScannerManager::configureScanner( ScannerContext& rContext ) throw( ScannerException ) +{ + vos::OGuard aGuard( maProtector ); + REF( XScannerManager ) xThis( this ); + + if( rContext.InternalData != 0 || rContext.ScannerName != ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TWAIN" ) ) ) + throw ScannerException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scanner does not exist" ) ), xThis, ScanError_InvalidContext ); + + DestroyData(); + + return aTwain.SelectSource(); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL ScannerManager::startScan( const ScannerContext& rContext, const REF( com::sun::star::lang::XEventListener )& rxListener ) throw( ScannerException ) +{ + vos::OGuard aGuard( maProtector ); + REF( XScannerManager ) xThis( this ); + + if( rContext.InternalData != 0 || rContext.ScannerName != ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TWAIN" ) ) ) + throw ScannerException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scanner does not exist" ) ), xThis, ScanError_InvalidContext ); + + DestroyData(); + + aTwain.PerformTransfer( this, rxListener ); +} + +// ----------------------------------------------------------------------------- + +ScanError SAL_CALL ScannerManager::getError( const ScannerContext& rContext ) throw( ScannerException ) +{ + vos::OGuard aGuard( maProtector ); + ScanError eError; + REF( XScannerManager ) xThis( this ); + + if( rContext.InternalData != 0 || rContext.ScannerName != ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TWAIN" ) ) ) + throw ScannerException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scanner does not exist" ) ), xThis, ScanError_InvalidContext ); + + if( aTwain.GetState() == TWAIN_STATE_CANCELED ) + eError = ScanError_ScanCanceled; + else + eError = ScanError_ScanErrorNone; + + return eError; +} + +// ----------------------------------------------------------------------------- + +REF( AWT::XBitmap ) SAL_CALL ScannerManager::getBitmap( const ScannerContext& rContext ) throw( ScannerException ) +{ + vos::OGuard aGuard( maProtector ); + return REF( AWT::XBitmap )( this ); +} diff --git a/extensions/source/scanner/scnserv.cxx b/extensions/source/scanner/scnserv.cxx new file mode 100644 index 000000000000..aab55a7bdd43 --- /dev/null +++ b/extensions/source/scanner/scnserv.cxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * $RCSfile: scnserv.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#include <cppuhelper/factory.hxx> +#include <uno/mapping.hxx> +#include "scanner.hxx" + +#include <com/sun/star/registry/XRegistryKey.hpp> + +using namespace com::sun::star::registry; + +// ------------------------------------------ +// - component_getImplementationEnvironment - +// ------------------------------------------ + +extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvTypeName, uno_Environment** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +// ----------------------- +// - component_writeInfo - +// ----------------------- + +extern "C" sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) +{ + sal_Bool bRet = sal_False; + + if( pRegistryKey ) + { + try + { + ::rtl::OUString aImplName( '/' ); + + aImplName += ScannerManager::getImplementationName_Static(); + aImplName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES/" ) ); + aImplName += ScannerManager::getImplementationName_Static(); + + REF( XRegistryKey ) xNewKey1( static_cast< XRegistryKey* >( pRegistryKey )->createKey( aImplName ) ); + + bRet = sal_True; + } + catch( InvalidRegistryException& ) + { + OSL_ENSHURE( sal_False, "### InvalidRegistryException!" ); + } + } + + return bRet; +} + +// ------------------------ +// - component_getFactory - +// ------------------------ + +extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey ) +{ + REF( ::com::sun::star::lang::XSingleServiceFactory ) xFactory; + void* pRet = 0; + + if( ::rtl::OUString::createFromAscii( pImplName ) == ScannerManager::getImplementationName_Static() ) + { + xFactory = REF( ::com::sun::star::lang::XSingleServiceFactory )( ::cppu::createSingleFactory( + static_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager ), + ScannerManager::getImplementationName_Static(), + ScannerManager_CreateInstance, + ScannerManager::getSupportedServiceNames_Static() ) ); + } + + if( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + + return pRet; +} diff --git a/extensions/source/scanner/twain.cxx b/extensions/source/scanner/twain.cxx new file mode 100644 index 000000000000..9fdffa7790f5 --- /dev/null +++ b/extensions/source/scanner/twain.cxx @@ -0,0 +1,563 @@ +/************************************************************************* + * + * $RCSfile: twain.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 <string.h> +#include <math.h> + +#if defined( WNT ) || defined (WIN) +#include <tools/svwin.h> +#endif +#ifdef OS2 +#include <tools/svpm.h> +#endif // OS2 +#include <vos/module.hxx> +#include <tools/stream.hxx> +#include <vcl/svapp.hxx> +#include <vcl/wrkwin.hxx> +#include <vcl/sysdata.hxx> +#include "twain.hxx" + +// ----------- +// - Defines - +// ----------- + +#define PFUNC (*pDSM) +#define FIXTODOUBLE( nFix ) ((double)nFix.Whole+(double)nFix.Frac/65536.) +#define FIXTOLONG( nFix ) ((long)floor(FIXTODOUBLE(nFix)+0.5)) + +#if defined WIN +#define TWAIN_LIBNAME "TWAIN.DLL" +#define TWAIN_FUNCNAME "DSM_Entry" +#elif defined WNT +#define TWAIN_LIBNAME "TWAIN_32.DLL" +#define TWAIN_FUNCNAME "DSM_Entry" +#elif defined OS2 +#define TWAIN_LIBNAME "twain" +#define TWAIN_FUNCNAME "DSM_ENTRY" +#endif + +// ----------- +// - Statics - +// ----------- + +static ImpTwain* pImpTwainInstance = NULL; + +// --------- +// - Procs - +// --------- + +#ifdef OS2 + + #define PTWAINMSG QMSG* + + MRESULT EXPENTRY TwainWndProc( HWND hWnd, ULONG nMsg, MPARAM nParam1, MPARAM nParam2 ) + { + return (MRESULT) TRUE; + } + + +#else // OS2 + + #define PTWAINMSG MSG* + + // ------------------------------------------------------------------------- + + LRESULT CALLBACK TwainWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) + { + return DefWindowProc( hWnd, nMsg, nPar1, nPar2 ); + } + + // ------------------------------------------------------------------------- + + LRESULT CALLBACK TwainMsgProc( int nCode, WPARAM wParam, LPARAM lParam ) + { + MSG* pMsg = (MSG*) lParam; + + if( ( nCode < 0 ) || + ( pImpTwainInstance->hTwainWnd != pMsg->hwnd ) || + !pImpTwainInstance->ImplHandleMsg( (void*) lParam ) ) + { + return CallNextHookEx( pImpTwainInstance->hTwainHook, nCode, wParam, lParam ); + } + else + { + pMsg->message = WM_USER; + pMsg->lParam = 0; + + return 0; + } + } + +#endif // OS2 + +// ------------ +// - ImpTwain - +// ------------ + +ImpTwain::ImpTwain( const Link& rNotifyLink ) : + aNotifyLink ( rNotifyLink ), + pDSM ( NULL ), + pMod ( NULL ), + hTwainWnd ( 0 ), + hTwainHook ( 0 ), + nCurState ( 1 ) +{ + pImpTwainInstance = this; + + aAppIdent.Id = 0; + aAppIdent.Version.MajorNum = 1; + aAppIdent.Version.MinorNum = 0; + aAppIdent.Version.Language = TWLG_USA; + aAppIdent.Version.Country = TWCY_USA; + aAppIdent.ProtocolMajor = TWON_PROTOCOLMAJOR; + aAppIdent.ProtocolMinor = TWON_PROTOCOLMINOR; + aAppIdent.SupportedGroups = DG_IMAGE | DG_CONTROL; + strcpy( aAppIdent.Version.Info, "StarOffice" ); + strcpy( aAppIdent.Manufacturer, "Sun Microsystems"); + strcpy( aAppIdent.ProductFamily,"Office"); + strcpy( aAppIdent.ProductName, "StarOffice"); + +#ifdef OS2 + + hAB = Sysdepen::GethAB(); + ImplFallback( TWAIN_EVENT_QUIT ); + // hTwainWnd = WinCreateWindow( HWND_DESKTOP, WC_FRAME, "dummy", 0, 0, 0, 0, 0, HWND_DESKTOP, HWND_BOTTOM, 0, 0, 0 ); + +#else + + HWND hParentWnd = HWND_DESKTOP; + WNDCLASS aWc = { 0, &TwainWndProc, 0, sizeof( WNDCLASS ), GetModuleHandle( NULL ), + NULL, NULL, NULL, NULL, "TwainClass" }; + + RegisterClass( &aWc ); + hTwainWnd = CreateWindowEx( WS_EX_TOPMOST, aWc.lpszClassName, "TWAIN", 0, 0, 0, 0, 0, hParentWnd, NULL, aWc.hInstance, 0 ); + hTwainHook = SetWindowsHookEx( WH_GETMESSAGE, &TwainMsgProc, NULL, GetCurrentThreadId() ); + +#endif +} + +// ----------------------------------------------------------------------------- + +ImpTwain::~ImpTwain() +{ +} + +// ----------------------------------------------------------------------------- + +void ImpTwain::Destroy() +{ + ImplFallback( TWAIN_EVENT_NONE ); + Application::PostUserEvent( LINK( this, ImpTwain, ImplDestroyHdl ), NULL ); +} + +// ----------------------------------------------------------------------------- + +BOOL ImpTwain::SelectSource() +{ + TW_UINT16 nRet = TWRC_FAILURE; + + if( !!aBitmap ) + aBitmap = Bitmap(); + + ImplOpenSourceManager(); + + if( 3 == nCurState ) + { + TW_IDENTITY aIdent; + + aIdent.Id = 0, aIdent.ProductName[ 0 ] = '\0'; + aNotifyLink.Call( (void*) TWAIN_EVENT_SCANNING ); + nRet = PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_USERSELECT, &aIdent ); + } + + ImplFallback( TWAIN_EVENT_QUIT ); + + return( nRet == TWRC_SUCCESS || nRet == TWRC_CANCEL ); +} + +// ----------------------------------------------------------------------------- + +BOOL ImpTwain::InitXfer() +{ + BOOL bRet = FALSE; + + if( !!aBitmap ) + aBitmap = Bitmap(); + + ImplOpenSourceManager(); + + if( 3 == nCurState ) + { + ImplOpenSource(); + + if( 4 == nCurState ) + bRet = ImplEnableSource(); + } + + if( !bRet ) + ImplFallback( TWAIN_EVENT_QUIT ); + + return bRet; +} + +// ----------------------------------------------------------------------------- + +Bitmap ImpTwain::GetXferBitmap() +{ + Bitmap aRet( aBitmap ); + aBitmap = Bitmap(); + return aRet; +} + +// ----------------------------------------------------------------------------- + +void ImpTwain::ImplOpenSourceManager() +{ + if( 1 == nCurState ) + { + pMod = new NAMESPACE_VOS( OModule )(); + + if( pMod->load( TWAIN_LIBNAME ) ) + { + nCurState = 2; + + if( ( ( pDSM = (DSMENTRYPROC) pMod->getSymbol( TWAIN_FUNCNAME ) ) != NULL ) && + ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_PARENT, MSG_OPENDSM, &hTwainWnd ) == TWRC_SUCCESS ) ) + { + nCurState = 3; + } + } + else + { + delete pMod; + pMod = NULL; + } + } +} + +// ----------------------------------------------------------------------------- + +void ImpTwain::ImplOpenSource() +{ + if( 3 == nCurState ) + { + if( ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETDEFAULT, &aSrcIdent ) == TWRC_SUCCESS ) && + ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, &aSrcIdent ) == TWRC_SUCCESS ) ) + { +#ifdef OS2 + + // negotiate capabilities + +#else + + TW_CAPABILITY aCap = { CAP_XFERCOUNT, TWON_ONEVALUE, GlobalAlloc( GHND, sizeof( TW_ONEVALUE ) ) }; + TW_ONEVALUE* pVal = (TW_ONEVALUE*) GlobalLock( aCap.hContainer ); + + pVal->ItemType = TWTY_INT16, pVal->Item = 1; + GlobalUnlock( aCap.hContainer ); + PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_CAPABILITY, MSG_SET, &aCap ); + GlobalFree( aCap.hContainer ); +#endif + + nCurState = 4; + } + } +} + +// ----------------------------------------------------------------------------- + +BOOL ImpTwain::ImplEnableSource() +{ + BOOL bRet = FALSE; + + if( 4 == nCurState ) + { + TW_USERINTERFACE aUI = { TRUE, TRUE, hTwainWnd }; + + aNotifyLink.Call( (void*) TWAIN_EVENT_SCANNING ); + nCurState = 5; + + if( PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_USERINTERFACE, MSG_ENABLEDS, &aUI ) == TWRC_SUCCESS ) + bRet = TRUE; + else + nCurState = 4; + } + + return bRet; +} + +// ----------------------------------------------------------------------------- + +BOOL ImpTwain::ImplHandleMsg( void* pMsg ) +{ + TW_UINT16 nRet; + PTWAINMSG pMess = (PTWAINMSG) pMsg; + TW_EVENT aEvt = { pMess, MSG_NULL }; + + nRet = PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT, &aEvt ); + + if( aEvt.TWMessage != MSG_NULL ) + { + switch( aEvt.TWMessage ) + { + case MSG_XFERREADY: + { + ULONG nEvent = TWAIN_EVENT_QUIT; + + if( 5 == nCurState ) + { + nCurState = 6; + ImplXfer(); + + if( !!aBitmap ) + nEvent = TWAIN_EVENT_XFER; + } + + ImplFallback( nEvent ); + } + break; + + case MSG_CLOSEDSREQ: + ImplFallback( TWAIN_EVENT_QUIT ); + break; + + default: + break; + } + } + else + nRet = TWRC_NOTDSEVENT; + + return( TWRC_DSEVENT == nRet ); +} + +// ----------------------------------------------------------------------------- + +void ImpTwain::ImplXfer() +{ + if( nCurState == 6 ) + { + TW_IMAGEINFO aInfo; + TW_UINT32 hDIB = 0; + long nWidth = aInfo.ImageWidth; + long nHeight = aInfo.ImageLength; + long nXRes = FIXTOLONG( aInfo.XResolution ); + long nYRes = FIXTOLONG( aInfo.YResolution ); + + if( PFUNC( &aAppIdent, &aSrcIdent, DG_IMAGE, DAT_IMAGEINFO, MSG_GET, &aInfo ) == TWRC_SUCCESS ) + { + nWidth = aInfo.ImageWidth; + nHeight = aInfo.ImageLength; + nXRes = FIXTOLONG( aInfo.XResolution ); + nYRes = FIXTOLONG( aInfo.YResolution ); + } + else + nWidth = nHeight = nXRes = nYRes = -1L; + + switch( PFUNC( &aAppIdent, &aSrcIdent, DG_IMAGE, DAT_IMAGENATIVEXFER, MSG_GET, &hDIB ) ) + { + case( TWRC_CANCEL ): + nCurState = 7; + break; + + case( TWRC_XFERDONE ): + { +#ifdef OS2 + + // get OS/2-Bitmap + +#else // OS2 + const ULONG nSize = GlobalSize( (HGLOBAL) hDIB ); + char* pBuf = (char*) GlobalLock( (HGLOBAL) hDIB ); + + if( pBuf ) + { + SvMemoryStream aMemStm; + aMemStm.SetBuffer( pBuf, nSize, FALSE, nSize ); + aBitmap.Read( aMemStm, FALSE ); + GlobalUnlock( (HGLOBAL) hDIB ); + } + + GlobalFree( (HGLOBAL) hDIB ); +#endif // OS2 + + // set resolution of bitmap if neccessary + if ( ( nXRes != -1 ) && ( nYRes != - 1 ) && ( nWidth != - 1 ) && ( nHeight != - 1 ) ) + { + const MapMode aMapMode( MAP_100TH_INCH, Point(), Fraction( 100, nXRes ), Fraction( 100, nYRes ) ); + aBitmap.SetPrefMapMode( aMapMode ); + aBitmap.SetPrefSize( Size( nWidth, nHeight ) ); + } + + nCurState = 7; + } + break; + + default: + break; + } + } +} + +// ----------------------------------------------------------------------------- + +void ImpTwain::ImplFallback( ULONG nEvent ) +{ + Application::PostUserEvent( LINK( this, ImpTwain, ImplFallbackHdl ), (void*) nEvent ); +} + +// ----------------------------------------------------------------------------- + +IMPL_LINK( ImpTwain, ImplFallbackHdl, void*, pData ) +{ + const ULONG nEvent = (ULONG) pData; + BOOL bFallback = TRUE; + + switch( nCurState ) + { + case( 7 ): + case( 6 ): + { + TW_PENDINGXFERS aXfers; + + if( PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_PENDINGXFERS, MSG_ENDXFER, &aXfers ) == TWRC_SUCCESS ) + { + if( aXfers.Count != 0 ) + PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_PENDINGXFERS, MSG_RESET, &aXfers ); + } + + nCurState = 5; + } + break; + + case( 5 ): + { + TW_USERINTERFACE aUI = { TRUE, TRUE, hTwainWnd }; + + PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_USERINTERFACE, MSG_DISABLEDS, &aUI ); + nCurState = 4; + } + break; + + case( 4 ): + { + PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, &aSrcIdent ); + nCurState = 3; + } + break; + + case( 3 ): + { + PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_PARENT, MSG_CLOSEDSM, &hTwainWnd ); + nCurState = 2; + } + break; + + case( 2 ): + { + delete pMod; + pMod = NULL; + nCurState = 1; + } + break; + + default: + { + if( nEvent != TWAIN_EVENT_NONE ) + aNotifyLink.Call( (void*) nEvent ); + + bFallback = FALSE; + } + break; + } + + if( bFallback ) + ImplFallback( nEvent ); + + return 0L; +} + +// ----------------------------------------------------------------------------- + +IMPL_LINK( ImpTwain, ImplDestroyHdl, void*, p ) +{ +#ifdef OS2 + + if( hWndTwain ) + WinDestroyWindow( hWndTwain ); + + // unset hook + +#else + + if( hTwainWnd ) + DestroyWindow( hTwainWnd ); + + if( hTwainHook ) + UnhookWindowsHookEx( hTwainHook ); + +#endif + + delete this; + pImpTwainInstance = NULL; + + return 0L; +} diff --git a/extensions/source/scanner/twain.hxx b/extensions/source/scanner/twain.hxx new file mode 100644 index 000000000000..53f36024f3a0 --- /dev/null +++ b/extensions/source/scanner/twain.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * $RCSfile: twain.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:52 $ + * + * 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 _TWAIN_HXX +#define _TWAIN_HXX + +#include <vos/module.hxx> +#include <vcl/bitmap.hxx> +#include "twain/twain.h" + + +// ----------- +// - Defines - +// ----------- + +#define TWAIN_SELECT 0x00000001UL +#define TWAIN_ACQUIRE 0x00000002UL +#define TWAIN_TERMINATE 0xFFFFFFFFUL + +#define TWAIN_EVENT_NONE 0x00000000UL +#define TWAIN_EVENT_QUIT 0x00000001UL +#define TWAIN_EVENT_SCANNING 0x00000002UL +#define TWAIN_EVENT_XFER 0x00000004UL + +// ------------ +// - ImpTwain - +// ------------ + +class ImpTwain +{ + TW_IDENTITY aAppIdent; + TW_IDENTITY aSrcIdent; + Link aNotifyLink; + Bitmap aBitmap; + DSMENTRYPROC pDSM; + NAMESPACE_VOS( OModule )* pMod; + ULONG nCurState; + + void ImplCreate(); + void ImplOpenSourceManager(); + void ImplOpenSource(); + BOOL ImplEnableSource(); + void ImplXfer(); + void ImplFallback( ULONG nEvent ); + + DECL_LINK( ImplFallbackHdl, void* ); + DECL_LINK( ImplDestroyHdl, void* ); + +public: + + BOOL ImplHandleMsg( void* pMsg ); + +#ifdef OS2 + HAB hAB; + HWND hTwainWnd; + long hTwainHook; +#else + HWND hTwainWnd; + HHOOK hTwainHook; +#endif + +public: + + ImpTwain( const Link& rNotifyLink ); + ~ImpTwain(); + + void Destroy(); + + BOOL SelectSource(); + BOOL InitXfer(); + Bitmap GetXferBitmap(); +}; + +#endif // _TWAIN_HXX diff --git a/extensions/source/svg/makefile.mk b/extensions/source/svg/makefile.mk new file mode 100644 index 000000000000..9ea4ee0bd6a0 --- /dev/null +++ b/extensions/source/svg/makefile.mk @@ -0,0 +1,134 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:53 $ +# +# 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=extensions +TARGET=svg + +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb +ENABLE_EXCEPTIONS=TRUE +USE_DEFFILE=TRUE + +# --- Settings ---------------------------------- + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Types ------------------------------------- + +UNOTYPES=\ + com.sun.star.uno.RuntimeException \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XInterface \ + com.sun.star.uno.XWeak \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.io.XInputStream \ + com.sun.star.io.XOutputStream \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.XInitialization \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.loader.XImplementationLoader \ + com.sun.star.registry.XImplementationRegistration \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.registry.XSimpleRegistry \ + com.sun.star.xml.sax.XDocumentHandler \ + com.sun.star.xml.sax.XExtendedDocumentHandler \ + com.sun.star.svg.XSVGPrinter \ + com.sun.star.svg.XSVGWriter + +# --- Files ------------------------------------- + +CXXFILES= svgprinter.cxx \ + svguno.cxx \ + svgaction.cxx \ + svgwriter.cxx + +SLOFILES= $(SLO)$/svgprinter.obj \ + $(SLO)$/svguno.obj \ + $(SLO)$/svgwriter.obj \ + $(SLO)$/svgaction.obj + +# --- Library ----------------------------------- + +SHL1TARGET=$(TARGET)$(UPD)$(DLLPOSTFIX) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(SALLIB) \ + $(VCLLIB) \ + $(SVLLIB) \ + $(ONELIB) \ + $(TOOLSLIB) \ + $(XMLOFFLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(SHL1TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE=exports.dxp + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/extensions/source/svg/svgaction.cxx b/extensions/source/svg/svgaction.cxx new file mode 100644 index 000000000000..45ba9ca1c6ec --- /dev/null +++ b/extensions/source/svg/svgaction.cxx @@ -0,0 +1,1412 @@ +/************************************************************************* + * + * $RCSfile: svgaction.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:53 $ + * + * 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 "svgaction.hxx" +#include <vcl/virdev.hxx> +#include <vcl/cvtgrf.hxx> +#include <vcl/metric.hxx> + +// ----------- +// - Defines - +// ----------- + +// #define _SVG_WRITE_TSPAN +// #define _SVG_WRITE_STRIKEOUT + +// ----------- +// - statics - +// ----------- + +static const char aXMLElemSVG[] = "svg"; +static const char aXMLElemG[] = "g"; +static const char aXMLElemDefs[] = "defs"; +static const char aXMLElemClipPath[] = "clipPath"; +static const char aXMLElemLine[] = "line"; +static const char aXMLElemRect[] = "rect"; +static const char aXMLElemEllipse[] = "ellipse"; +static const char aXMLElemPath[] = "path"; +static const char aXMLElemPolygon[] = "polygon"; +static const char aXMLElemPolyLine[] = "polyline"; +static const char aXMLElemText[] = "text"; +static const char aXMLElemTSpan[] = "tspan"; +static const char aXMLElemImage[] = "image"; + +static const char aXMLAttrTransform[] = "transform"; +static const char aXMLAttrStyle[] = "style"; +static const char aXMLAttrId[] = "id"; + +static const char aXMLAttrD[] = "d"; +static const char aXMLAttrX[] = "x"; +static const char aXMLAttrY[] = "y"; +static const char aXMLAttrX1[] = "x1"; +static const char aXMLAttrY1[] = "y1"; +static const char aXMLAttrX2[] = "x2"; +static const char aXMLAttrY2[] = "y2"; +static const char aXMLAttrCX[] = "cx"; +static const char aXMLAttrCY[] = "cy"; +static const char aXMLAttrRX[] = "rx"; +static const char aXMLAttrRY[] = "ry"; +static const char aXMLAttrWidth[] = "width"; +static const char aXMLAttrHeight[] = "height"; +static const char aXMLAttrPoints[] = "points"; +static const char aXMLAttrXLinkHRef[] = "xlink:href"; + +static const sal_Unicode pBase64[] = +{ + //0 1 2 3 4 5 6 7 + 'A','B','C','D','E','F','G','H', // 0 + 'I','J','K','L','M','N','O','P', // 1 + 'Q','R','S','T','U','V','W','X', // 2 + 'Y','Z','a','b','c','d','e','f', // 3 + 'g','h','i','j','k','l','m','n', // 4 + 'o','p','q','r','s','t','u','v', // 5 + 'w','x','y','z','0','1','2','3', // 6 + '4','5','6','7','8','9','+','/' // 7 +}; + +// -------------- +// - FastString - +// -------------- + +FastString::FastString( sal_uInt32 nInitLen, sal_uInt32 nIncrement ) : + mnBufLen( nInitLen ), + mnCurLen( 0 ), + mnBufInc( nIncrement ), + mpBuffer( new sal_Unicode[ nInitLen * sizeof( sal_Unicode ) ] ), + mnPartPos( 0 ) +{ + DBG_ASSERT( nInitLen, "invalid initial length" ); + DBG_ASSERT( nIncrement, "invalid increment" ); +} + +// ----------------------------------------------------------------------------- + +FastString::FastString( sal_Char* pBufferForBase64Encoding, sal_uInt32 nBufLen ) : + mnBufInc( 2048 ), + mnPartPos( 0 ) +{ + DBG_ASSERT( pBufferForBase64Encoding && nBufLen, "invalid arguments" ); + + const sal_uInt32 nQuadCount = nBufLen / 3; + const sal_uInt32 nRest = nBufLen % 3; + + if( nQuadCount || nRest ) + { + mnBufLen = mnCurLen = ( ( nQuadCount + ( nRest ? 1 : 0 ) ) << 2 ); + mpBuffer = new sal_Unicode[ mnBufLen * sizeof( sal_Unicode ) ]; + + sal_Char* pTmpSrc = pBufferForBase64Encoding; + sal_Unicode* pTmpDst = mpBuffer; + + for( sal_uInt32 i = 0, nCharCount = 0; i < nQuadCount; i++ ) + { + const sal_Int32 nA = *pTmpSrc++; + const sal_Int32 nB = *pTmpSrc++; + const sal_Int32 nC = *pTmpSrc++; + + *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ]; + *pTmpDst++ = pBase64[ ( ( nA << 4 ) & 0x30 ) + ( ( nB >> 4 ) & 0xf ) ]; + *pTmpDst++ = pBase64[ ( ( nB << 2 ) & 0x3c ) + ( ( nC >> 6 ) & 0x3 ) ]; + *pTmpDst++ = pBase64[ nC & 0x3f ]; + } + + if( 1 == nRest ) + { + const sal_Int32 nA = *pTmpSrc; + + *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ]; + *pTmpDst++ = pBase64[ ( nA << 4 ) & 0x30 ]; + *pTmpDst++ = '='; + *pTmpDst = '='; + } + else if( 2 == nRest ) + { + const sal_Int32 nA = *pTmpSrc++; + const sal_Int32 nB = *pTmpSrc; + + *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ]; + *pTmpDst++ = pBase64[ ( ( nA << 4 ) & 0x30 ) + ( ( nB >> 4 ) & 0xf ) ]; + *pTmpDst++ = pBase64[ ( nB << 2 ) & 0x3c ]; + *pTmpDst = '='; + } + } + else + { + mpBuffer = new sal_Unicode[ ( mnBufLen = 1 ) * sizeof( sal_Unicode ) ]; + mnCurLen = 0; + } +} + +// ----------------------------------------------------------------------------- + +FastString::~FastString() +{ + delete[] mpBuffer; +} + +// ----------------------------------------------------------------------------- + +FastString& FastString::operator+=( const NMSP_RTL::OUString& rStr ) +{ + if( rStr.getLength() ) + { + if( ( mnCurLen + rStr.getLength() ) > mnBufLen ) + { + const sal_uInt32 nNewBufLen = ( mnBufLen + ( ( ( mnCurLen + rStr.getLength() ) - mnBufLen ) / mnBufInc + 1 ) * mnBufInc ); + sal_Unicode* pNewBuffer = new sal_Unicode[ nNewBufLen * sizeof( sal_Unicode ) ]; + + HMEMCPY( pNewBuffer, mpBuffer, mnBufLen * sizeof( sal_Unicode ) ); + delete[] mpBuffer; + mpBuffer = pNewBuffer; + mnBufLen = nNewBufLen; + } + + HMEMCPY( mpBuffer + mnCurLen, rStr.getStr(), rStr.getLength() * sizeof( sal_Unicode ) ); + mnCurLen += rStr.getLength(); + + if( maString.getLength() ) + maString = NMSP_RTL::OUString(); + } + + return *this; +} + +// ----------------------------------------------------------------------------- + +const NMSP_RTL::OUString& FastString::GetString() const +{ + if( !maString.getLength() && mnCurLen ) + ( (FastString*) this )->maString = NMSP_RTL::OUString( mpBuffer, mnCurLen ); + + return maString; +} + +// ----------------------------------------------------------------------------- + +sal_Bool FastString::GetFirstPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString ) +{ + const sal_uInt32 nLength = Min( mnCurLen, nPartLen ); + + mnPartPos = 0; + + if( nLength ) + { + rPartString = NMSP_RTL::OUString( mpBuffer, nLength ); + mnPartPos = nLength; + } + + return( rPartString.getLength() > 0 ); +} + +// ----------------------------------------------------------------------------- + +sal_Bool FastString::GetNextPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString ) +{ + if( mnPartPos < mnCurLen ) + { + const sal_uInt32 nLength = Min( mnCurLen - mnPartPos, nPartLen ); + rPartString = NMSP_RTL::OUString( mpBuffer + mnPartPos, nLength ); + mnPartPos += nLength; + } + else + rPartString = NMSP_RTL::OUString(); + + return( rPartString.getLength() > 0 ); +} + +// ---------------------- +// - SVGAttributeWriter - +// ---------------------- + +SVGAttributeWriter::SVGAttributeWriter( SVGActionWriter& rParent, SvXMLExport& rExport ) : + mrParent( rParent ), + mrExport( rExport ), + mpElemFont( NULL ), + mpElemPaint( NULL ) +{ +} + +// ----------------------------------------------------------------------------- + +SVGAttributeWriter::~SVGAttributeWriter() +{ + delete mpElemPaint; + delete mpElemFont; +} + +// ----------------------------------------------------------------------------- + +NMSP_RTL::OUString SVGAttributeWriter::GetFontStyle( const Font& rFont ) +{ + FastString aStyle; + + // font family + aStyle += B2UCONST( "font-family:" ); + aStyle += NMSP_RTL::OUString( UniString( rFont.GetName() ) ); + + // font size + const Size aFontSize( mrParent.GetVDev().LogicToLogic( Size( 0, rFont.GetHeight() ), mrParent.GetVDev().GetMapMode(), MAP_POINT ) ); + + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "font-size:" ); + aStyle += NMSP_RTL::OUString::valueOf( aFontSize.Height() ); + + if( !mrParent.HasDoublePoints() ) + aStyle += B2UCONST( "pt" ); + + // font style + if( rFont.GetItalic() != ITALIC_NONE ) + { + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "font-style:" ); + + if( rFont.GetItalic() == ITALIC_OBLIQUE ) + aStyle += B2UCONST( "oblique" ); + else + aStyle += B2UCONST( "italic" ); + } + + // font weight + sal_Int32 nFontWeight; + + switch( rFont.GetWeight() ) + { + case WEIGHT_THIN: nFontWeight = 100; break; + case WEIGHT_ULTRALIGHT: nFontWeight = 200; break; + case WEIGHT_LIGHT: nFontWeight = 300; break; + case WEIGHT_SEMILIGHT: nFontWeight = 400; break; + case WEIGHT_NORMAL: nFontWeight = 400; break; + case WEIGHT_MEDIUM: nFontWeight = 500; break; + case WEIGHT_SEMIBOLD: nFontWeight = 600; break; + case WEIGHT_BOLD: nFontWeight = 700; break; + case WEIGHT_ULTRABOLD: nFontWeight = 800; break; + case WEIGHT_BLACK: nFontWeight = 900; break; + default: nFontWeight = 400; break; + } + + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "font-weight:" ); + aStyle += NMSP_RTL::OUString::valueOf( nFontWeight ); + + // !!! + // font-variant + // font-stretch + // font-size-adjust + +#ifdef _SVG_WRITE_STRIKEOUT + + if( rFont.GetUnderline() != UNDERLINE_NONE || rFont.GetStrikeout() != STRIKEOUT_NONE ) + { + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "text-decoration:" ); + + if( rFont.GetUnderline() != UNDERLINE_NONE ) + aStyle += B2UCONST( " underline" ); + + if( rFont.GetStrikeout() != STRIKEOUT_NONE ) + aStyle += B2UCONST( " line-trough" ); + } + +#else // _SVG_WRITE_STRIKEOUT + + if( rFont.GetUnderline() != UNDERLINE_NONE ) + { + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "text-decoration:" ); + aStyle += B2UCONST( "underline" ); + } + +#endif // _SVG_WRITE_STRIKEOUT + + return aStyle.GetString(); +} + +// ----------------------------------------------------------------------------- + +NMSP_RTL::OUString SVGAttributeWriter::GetPaintStyle( const Color& rLineColor, const Color& rFillColor ) +{ + FastString aStyle; + + // line color + aStyle += B2UCONST( "stroke:" ); + + if( rLineColor.GetTransparency() == 255 ) + aStyle += B2UCONST( "none" ); + else + { + // line color value in rgb + aStyle += B2UCONST( "rgb(" ); + aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rLineColor.GetRed() ); + aStyle += B2UCONST( "," ); + aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rLineColor.GetGreen() ); + aStyle += B2UCONST( "," ); + aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rLineColor.GetBlue() ); + aStyle += B2UCONST( ")" ); + + // line color opacity in percent if neccessary + if( rLineColor.GetTransparency() ) + { + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "stroke-opacity:" ); + aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) ( ( 255 - (double) rLineColor.GetTransparency() ) / 2.55 ) ); + aStyle += B2UCONST( "%" ); + } + } + + // fill color + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "fill:" ); + + if( rFillColor.GetTransparency() == 255 ) + aStyle += B2UCONST( "none" ); + else + { + // fill color value in rgb + aStyle += B2UCONST( "rgb(" ); + aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rFillColor.GetRed() ); + aStyle += B2UCONST( "," ); + aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rFillColor.GetGreen() ); + aStyle += B2UCONST( "," ); + aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rFillColor.GetBlue() ); + aStyle += B2UCONST( ")" ); + + // fill color opacity in percent if neccessary + if( rFillColor.GetTransparency() ) + { + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "fill-opacity:" ); + aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) ( ( 255 - (double) rFillColor.GetTransparency() ) / 2.55 ) ); + aStyle += B2UCONST( "%" ); + } + } + + return aStyle.GetString(); +} + +// ----------------------------------------------------------------------------- + +void SVGAttributeWriter::SetFontAttr( const Font& rFont ) +{ + if( !mpElemFont || ( rFont != maCurFont ) ) + { + delete mpElemPaint, mpElemPaint = NULL; + delete mpElemFont; + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, GetFontStyle( maCurFont = rFont ) ); + mpElemFont = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, TRUE, TRUE ); + } +} + +// ----------------------------------------------------------------------------- + +void SVGAttributeWriter::SetPaintAttr( const Color& rLineColor, const Color& rFillColor ) +{ + if( !mpElemPaint || ( rLineColor != maCurLineColor ) || ( rFillColor != maCurFillColor ) ) + { + delete mpElemPaint; + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, GetPaintStyle( maCurLineColor = rLineColor, maCurFillColor = rFillColor ) ); + mpElemPaint = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, TRUE, TRUE ); + } +} + +// ------------------- +// - SVGActionWriter - +// ------------------- + +SVGActionWriter::SVGActionWriter( SvXMLExport& rExport, const GDIMetaFile& rMtf, + VirtualDevice* pParentVDev, sal_Bool bWriteDoublePoints ) : + mrExport( rExport ), + mrMtf( rMtf ), + mpContext( NULL ), + mbClipAttrChanged( sal_False ), + mnCurClipId( 1 ), + mbDoublePoints( bWriteDoublePoints ) +{ + if( pParentVDev ) + { + mpVDev = pParentVDev; + mbDestroyVDev = sal_False; + maTargetMapMode = mpVDev->GetMapMode(); + } + else + { + mpVDev = new VirtualDevice; + mpVDev->EnableOutput( sal_False ); + mbDestroyVDev = sal_True; + maTargetMapMode = MAP_100TH_MM; + } + + mpVDev->Push(); + mpVDev->SetMapMode( mrMtf.GetPrefMapMode() ); + ImplWriteActions( mrMtf ); + mpVDev->Pop(); +} + +// ----------------------------------------------------------------------------- + +SVGActionWriter::~SVGActionWriter() +{ + DBG_ASSERT( !mpContext, "Not all contexts are closed" ); + + if( mbDestroyVDev ) + delete mpVDev; +} + +// ----------------------------------------------------------------------------- + +long SVGActionWriter::ImplMap( sal_Int32 nVal ) const +{ + return ImplMap( Size( nVal, nVal ) ).Width(); +} + +// ----------------------------------------------------------------------------- + +Point SVGActionWriter::ImplMap( const Point& rPt ) const +{ + return mpVDev->LogicToLogic( rPt, mpVDev->GetMapMode(), maTargetMapMode ); +} + +// ----------------------------------------------------------------------------- + +Size SVGActionWriter::ImplMap( const Size& rSz ) const +{ + return mpVDev->LogicToLogic( rSz, mpVDev->GetMapMode(), maTargetMapMode ); +} + +// ----------------------------------------------------------------------------- + +NMSP_RTL::OUString SVGActionWriter::GetValueString( sal_Int32 nVal, sal_Bool bDoublePoints ) +{ + if( !bDoublePoints ) + return NMSP_RTL::OUString::valueOf( nVal ); + else + { + const double fPoints = nVal * 72.0 / 2540.0; + const sal_Int32 nInt = (sal_Int32) fPoints; + + return( ( NMSP_RTL::OUString::valueOf( nInt ) += + NMSP_RTL::OUString::valueOf( (sal_Unicode) '.' ) ) += + NMSP_RTL::OUString::valueOf( labs( (sal_Int32) ( ( fPoints - nInt ) * 100.0 ) ) ) ); + } +} + +// ----------------------------------------------------------------------------- + +void SVGActionWriter::ImplWriteLine( const Point& rPt1, const Point& rPt2, const Color* pLineColor, + const NMSP_RTL::OUString* pStyle ) +{ + const Point aPt1( ImplMap( rPt1 ) ); + const Point aPt2( ImplMap( rPt2 ) ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX1, GetValueString( aPt1.X(), mbDoublePoints ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY1, GetValueString( aPt1.Y(), mbDoublePoints ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX2, GetValueString( aPt2.X(), mbDoublePoints ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY2, GetValueString( aPt2.Y(), mbDoublePoints ) ); + + // add additional style if requested + if( pStyle ) + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle ); + + if( pLineColor ) + { + // !!! mrExport.AddAttribute( XML_NAMESPACE_NONE, ... ) + DBG_ERROR( "SVGActionWriter::ImplWriteLine: Line color not implemented" ); + } + + { + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemLine, TRUE, TRUE ); + } +} + +// ----------------------------------------------------------------------------- + +void SVGActionWriter::ImplWriteRect( const Rectangle& rRect, long nRadX, long nRadY, + const NMSP_RTL::OUString* pStyle ) +{ + const Rectangle aRect( ImplMap( rRect ) ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, GetValueString( aRect.Left(), mbDoublePoints ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aRect.Top(), mbDoublePoints ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, GetValueString( aRect.GetWidth(), mbDoublePoints ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, GetValueString( aRect.GetHeight(), mbDoublePoints ) ); + + if( nRadX ) + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRX, GetValueString( ImplMap( nRadX ), mbDoublePoints ) ); + + if( nRadY ) + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRY, GetValueString( ImplMap( nRadY ), mbDoublePoints ) ); + + // add additional style if requested + if( pStyle ) + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle ); + + { + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemRect, TRUE, TRUE ); + } +} + +// ----------------------------------------------------------------------------- + +void SVGActionWriter::ImplWriteEllipse( const Point& rCenter, long nRadX, long nRadY, + const NMSP_RTL::OUString* pStyle ) +{ + const Point aCenter( ImplMap( rCenter ) ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCX, GetValueString( aCenter.X(), mbDoublePoints ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCY, GetValueString( aCenter.Y(), mbDoublePoints ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRX, GetValueString( ImplMap( nRadX ), mbDoublePoints ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRY, GetValueString( ImplMap( nRadY ), mbDoublePoints ) ); + + // add additional style if requested + if( pStyle ) + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle ); + + { + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemEllipse, TRUE, TRUE ); + } +} + +// ----------------------------------------------------------------------------- + +void SVGActionWriter::ImplWritePolygon( const Polygon& rPoly, sal_Bool bLineOnly, + const NMSP_RTL::OUString* pStyle ) +{ + if( rPoly.GetSize() ) + { + FastString aStyle; + FastString aPoints; + USHORT i = 0, nSize = rPoly.GetSize(); + const NMSP_RTL::OUString aBlank( B2UCONST( " " ) ); + + // points + while( i < nSize ) + { + const Point aPolyPoint( ImplMap( rPoly[ i ] ) ); + + aPoints += GetValueString( aPolyPoint.X(), mbDoublePoints ); + aPoints += B2UCONST( "," ); + aPoints += GetValueString( aPolyPoint.Y(), mbDoublePoints ); + + if( ++i < nSize ) + aPoints += aBlank; + } + + // style + if( bLineOnly ) + { + aStyle += B2UCONST( "fill:none" ); + + if( pStyle ) + { + aStyle += B2UCONST( ";" ); + aStyle += *pStyle; + } + } + else if( pStyle ) + aStyle += *pStyle; + + // add point attribute + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrPoints, aPoints.GetString() ); + + // add style attribute + if( aStyle.GetLength() ) + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aStyle.GetString() ); + + { + // write polyline/polygon element + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, bLineOnly ? aXMLElemPolyLine : aXMLElemPolygon, TRUE, TRUE ); + } + } +} + +// ----------------------------------------------------------------------------- + +void SVGActionWriter::ImplWritePolyPolygon( const PolyPolygon& rPolyPoly, sal_Bool bLineOnly, + const NMSP_RTL::OUString* pStyle ) +{ + if( rPolyPoly.Count() ) + { + if( rPolyPoly.Count() == 1 ) + ImplWritePolygon( rPolyPoly[ 0 ], bLineOnly, pStyle ); + else if( bLineOnly ) + { + for( long i = 0, nCount = rPolyPoly.Count(); i < nCount; i++ ) + ImplWritePolygon( rPolyPoly[ i ], sal_False, pStyle ); + } + else + { + FastString aPathData; + const NMSP_RTL::OUString aBlank( B2UCONST( " " ) ); + const NMSP_RTL::OUString aComma( B2UCONST( "," ) ); + Point aPolyPoint; + + for( long i = 0, nCount = rPolyPoly.Count(); i < nCount; i++ ) + { + const Polygon& rPoly = rPolyPoly[ i ]; + USHORT n = 1, nSize = rPoly.GetSize(); + + if( nSize > 1 ) + { + aPathData += B2UCONST( "M " ); + aPathData += GetValueString( ( aPolyPoint = ImplMap( rPoly[ 0 ] ) ).X(), mbDoublePoints ); + aPathData += aComma; + aPathData += GetValueString( aPolyPoint.Y(), mbDoublePoints ); + aPathData += B2UCONST( " L " ); + + while( n < nSize ) + { + aPathData += GetValueString( ( aPolyPoint = ImplMap( rPoly[ n ] ) ).X(), mbDoublePoints ); + aPathData += aComma; + aPathData += GetValueString( aPolyPoint.Y(), mbDoublePoints ); + + if( ++n < nSize ) + aPathData += aBlank; + } + + aPathData += B2UCONST( " Z" ); + + if( i < ( nCount - 1 ) ) + aPathData += aBlank; + } + } + + // add style attribute + if( pStyle && pStyle->getLength() ) + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle ); + + // add path data attribute + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrD, aPathData.GetString() ); + + { + // write polyline/polygon element + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemPath, TRUE, TRUE ); + } + } + } +} + +// ----------------------------------------------------------------------------- + +void SVGActionWriter::ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const Gradient& rGradient, + const NMSP_RTL::OUString* pStyle ) +{ + if( rPolyPoly.Count() ) + { + SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, TRUE, TRUE ); + FastString aClipId; + FastString aClipStyle; + + aClipId += B2UCONST( "clip" ); + aClipId += NMSP_RTL::OUString::valueOf( ImplGetNextClipId() ); + + { + SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, TRUE, TRUE ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aClipId.GetString() ); + + { + SvXMLElementExport aElemClipPath( mrExport, XML_NAMESPACE_NONE, aXMLElemClipPath, TRUE, TRUE ); + ImplWritePolyPolygon( rPolyPoly, sal_False ); + } + } + + // create new context with clippath set + aClipStyle += B2UCONST( "clip-path:URL(#" ); + aClipStyle += aClipId.GetString(); + aClipStyle += B2UCONST( ")" ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aClipStyle.GetString() ); + + { + GDIMetaFile aTmpMtf; + SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, TRUE, TRUE ); + + mpVDev->AddGradientActions( rPolyPoly.GetBoundRect(), rGradient, aTmpMtf ); + ImplWriteActions( aTmpMtf, pStyle ); + } + } +} + +// ----------------------------------------------------------------------------- + +void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText, + const long* pDXArray, long nWidth, + const NMSP_RTL::OUString* pStyle ) +{ + String aText( rText ); aText.EraseLeadingChars( ' ' ); + UINT32 nLen = aText.Len(), i; + + if( nLen ) + { + Size aNormSize; + long* pOwnArray; + long* pDX; + + // get text sizes + if( pDXArray ) + { + pOwnArray = NULL; +#ifdef _SVG_UNO3 + aNormSize = Size( mpVDev->GetTextWidth( aText ), 0 ); +#else + aNormSize = mpVDev->GetTextSize( aText ); +#endif + pDX = (long*) pDXArray; + } + else + { + pOwnArray = new long[ nLen ]; +#ifdef _SVG_UNO3 + aNormSize = Size( mpVDev->GetTextArray( aText, pOwnArray ), 0 ); +#else + aNormSize = mpVDev->GetTextArray( aText, pOwnArray ); +#endif + pDX = pOwnArray; + } + + if( nLen > 1 ) + { +#ifdef _SVG_UNO3 + aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextWidth( aText.GetChar( nLen - 1 ) ); +#else + aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextSize( aText[ (USHORT) ( nLen - 1 ) ] ).Width(); +#endif + + if( nWidth && aNormSize.Width() && ( nWidth != aNormSize.Width() ) ) + { + const double fFactor = (double) nWidth / aNormSize.Width(); + + for( i = 0; i < ( nLen - 1 ); i++ ) + pDX[ i ] = FRound( pDX[ i ] * fFactor ); + } + } + + FastString aStyle; + const Font& rFont = mpVDev->GetFont(); + const FontMetric aMetric( mpVDev->GetFontMetric() ); + Point aBaseLinePos( rPos ); + + // leading whitespaces erased? => adjust position + if( nLen < rText.Len() ) + { +#ifdef _SVG_UNO3 + aBaseLinePos.X() += mpVDev->GetTextWidth( ' ' ) * ( rText.Len() - nLen ); +#else + aBaseLinePos.X() += mpVDev->GetTextSize( ' ' ).Width() * ( rText.Len() - nLen ); +#endif + } + + // always adjust text position to match baseline alignment + switch( rFont.GetAlign() ) + { + case( ALIGN_TOP ): + aBaseLinePos.Y() += aMetric.GetAscent(); + break; + + case( ALIGN_BOTTOM ): + aBaseLinePos.Y() -= aMetric.GetDescent(); + break; + + default: + break; + } + + // get mapped text position + const Point aPt( ImplMap( aBaseLinePos ) ); + + // add additional style if requested + if( pStyle && pStyle->getLength() ) + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle ); + + // write text element +#ifdef _SVG_WRITE_TSPAN + if( pDXArray ) + { + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, TRUE, TRUE ); + FastString aTSpanX; + const NMSP_RTL::OUString aSpace( ' ' ); + long i, nX, nCount; + + aTSpanX += GetValueString( aPt.X(), mbDoublePoints ); + aTSpanX += aSpace; + + for( i = 0, nX = aPt.X(), nCount = ( nLen - 1 ); i < nCount; ) + { + aTSpanX += GetValueString( aPt.X() + pDX[ i++ ], mbDoublePoints ); + aTSpanX += aSpace; + } + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, aTSpanX.GetString() ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aPt.Y(), mbDoublePoints ) ); + + { + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemTSpan, TRUE, TRUE ); + mrExport.GetDocHandler()->characters( NMSP_RTL::OUString( UniString( aText ) ) ); + } + } + else +#endif // _SVG_WRITE_TSPAN + { + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, GetValueString( aPt.X(), mbDoublePoints ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aPt.Y(), mbDoublePoints ) ); + + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, TRUE, TRUE ); + mrExport.GetDocHandler()->characters( NMSP_RTL::OUString( UniString( aText ) ) ); + } +#ifndef _SVG_WRITE_STRIKEOUT + + // write strikeout if neccessary + if( rFont.GetStrikeout() ) + { + const long nYStrikeoutPos = aBaseLinePos.Y() - FRound( aMetric.GetAscent() * 0.26 ); + const long nStrikeoutHeight = Max( (long) FRound( aMetric.GetLineHeight() * 0.05 ), (long) 1 ); + Polygon aPoly( 4 ); + + aPoly[ 0 ].X() = aBaseLinePos.X(); aPoly[ 0 ].Y() = nYStrikeoutPos - ( nStrikeoutHeight >> 1 ); + aPoly[ 1 ].X() = aBaseLinePos.X() + aNormSize.Width() - 1; aPoly[ 1 ].Y() = aPoly[ 0 ].Y(); + aPoly[ 2 ].X() = aPoly[ 1 ].X(); aPoly[ 2 ].Y() = aPoly[ 0 ].Y() + nStrikeoutHeight - 1; + aPoly[ 3 ].X() = aPoly[ 0 ].X(); aPoly[ 3 ].Y() = aPoly[ 2 ].Y(); + + ImplWritePolygon( aPoly, FALSE ); + } + +#endif // _SVG_WRITE_STRIKEOUT + + delete[] pOwnArray; + } +} + +// ----------------------------------------------------------------------------- + +void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx, + const Point& rPt, const Size& rSz, + const Point& rSrcPt, const Size& rSrcSz, + const NMSP_RTL::OUString* pStyle ) +{ + if( !!rBmpEx ) + { + BitmapEx aBmpEx( rBmpEx ); + Point aPoint = Point(); + const Rectangle aBmpRect( aPoint, rBmpEx.GetSizePixel() ); + const Rectangle aSrcRect( rSrcPt, rSrcSz ); + + if( aSrcRect != aBmpRect ) + aBmpEx.Crop( aSrcRect ); + + if( !!aBmpEx ) + { + SvMemoryStream aOStm( 65535, 65535 ); + + if( GraphicConverter::Export( aOStm, rBmpEx, CVT_PNG ) == ERRCODE_NONE ) + { + const Point aPt( ImplMap( rPt ) ); + const Size aSz( ImplMap( rSz ) ); + FastString aImageData( (sal_Char*) aOStm.GetData(), aOStm.Tell() ); +#ifndef _SVG_UNO3 + XExtendedDocumentHandlerRef xExtDocHandler( mrExport.GetDocHandler(), USR_QUERY ); +#else + REF( NMSP_SAX::XExtendedDocumentHandler ) xExtDocHandler( mrExport.GetDocHandler(), NMSP_UNO::UNO_QUERY ); +#endif + + if( xExtDocHandler.is() ) + { + static const sal_uInt32 nPartLen = 64; + const NMSP_RTL::OUString aSpace( ' ' ); + const NMSP_RTL::OUString aLineFeed( NMSP_RTL::OUString::valueOf( (sal_Unicode) 0x0a ) ); + NMSP_RTL::OUString aString; + NMSP_RTL::OUString aImageString; + + aString = aLineFeed; + aString += B2UCONST( "<" ); + aString += NMSP_RTL::OUString::createFromAscii( aXMLElemImage ); + aString += aSpace; + + aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrX ); + aString += B2UCONST( "=\"" ); + aString += GetValueString( aPt.X(), mbDoublePoints ); + aString += B2UCONST( "\" " ); + + aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrY ); + aString += B2UCONST( "=\"" ); + aString += GetValueString( aPt.Y(), mbDoublePoints ); + aString += B2UCONST( "\" " ); + + aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrWidth ); + aString += B2UCONST( "=\"" ); + aString += GetValueString( aSz.Width(), mbDoublePoints ); + aString += B2UCONST( "\" " ); + + aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrHeight ); + aString += B2UCONST( "=\"" ); + aString += GetValueString( aSz.Height(), mbDoublePoints ); + aString += B2UCONST( "\" " ); + + aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrXLinkHRef ); + aString += B2UCONST( "=\"data:image/png;base64," ); + + if( aImageData.GetFirstPartString( nPartLen, aImageString ) ) + { + xExtDocHandler->unknown( aString += aImageString ); + + while( aImageData.GetNextPartString( nPartLen, aImageString ) ) + { + xExtDocHandler->unknown( aLineFeed ); + xExtDocHandler->unknown( aImageString ); + } + } + + xExtDocHandler->unknown( B2UCONST( "\"/>" ) ); + } + } + } + } +} + +// ----------------------------------------------------------------------------- + +void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, const NMSP_RTL::OUString* pStyle ) +{ + ImplAcquireContext(); + + for( ULONG i = 0, nCount = rMtf.GetActionCount(); i < nCount; i++ ) + { + const MetaAction* pAction = rMtf.GetAction( i ); + const USHORT nType = pAction->GetType(); + + switch( nType ) + { + case( META_PIXEL_ACTION ): + { + const MetaPixelAction* pA = (const MetaPixelAction*) pAction; + + mpContext->SetPaintAttr( pA->GetColor(), pA->GetColor() ); + ImplWriteLine( pA->GetPoint(), pA->GetPoint(), &pA->GetColor(), pStyle ); + } + break; + + case( META_POINT_ACTION ): + { + const MetaPointAction* pA = (const MetaPointAction*) pAction; + + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() ); + ImplWriteLine( pA->GetPoint(), pA->GetPoint(), NULL, pStyle ); + } + break; + + case( META_LINE_ACTION ): + { + const MetaLineAction* pA = (const MetaLineAction*) pAction; + + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() ); + ImplWriteLine( pA->GetStartPoint(), pA->GetEndPoint(), NULL, pStyle ); + } + break; + + case( META_RECT_ACTION ): + { + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteRect( ( (const MetaRectAction*) pAction )->GetRect(), 0, 0, pStyle ); + } + break; + + case( META_ROUNDRECT_ACTION ): + { + const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pAction; + + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound(), pStyle ); + } + break; + + case( META_ELLIPSE_ACTION ): + { + const MetaEllipseAction* pA = (const MetaEllipseAction*) pAction; + const Rectangle& rRect = pA->GetRect(); + + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteEllipse( rRect.Center(), rRect.GetWidth() >> 1, rRect.GetHeight() >> 1, pStyle ); + } + break; + + case( META_ARC_ACTION ): + case( META_PIE_ACTION ): + case( META_CHORD_ACTION ): + case( META_POLYGON_ACTION ): + { + Polygon aPoly; + + switch( nType ) + { + case( META_ARC_ACTION ): + { + const MetaArcAction* pA = (const MetaArcAction*) pAction; + aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_ARC ); + } + break; + + case( META_PIE_ACTION ): + { + const MetaPieAction* pA = (const MetaPieAction*) pAction; + aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_PIE ); + } + break; + + case( META_CHORD_ACTION ): + { + const MetaChordAction* pA = (const MetaChordAction*) pAction; + aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_CHORD ); + } + break; + + case( META_POLYGON_ACTION ): + aPoly = ( (const MetaPolygonAction*) pAction )->GetPolygon(); + break; + } + + if( aPoly.GetSize() ) + { + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWritePolygon( aPoly, sal_False, pStyle ); + } + } + break; + + case( META_POLYLINE_ACTION ): + { + const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pAction; + const Polygon& rPoly = pA->GetPolygon(); + + if( rPoly.GetSize() ) + { + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWritePolygon( rPoly, sal_True, pStyle ); + } + } + break; + + case( META_POLYPOLYGON_ACTION ): + { + const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*) pAction; + const PolyPolygon& rPolyPoly = pA->GetPolyPolygon(); + + if( rPolyPoly.Count() ) + { + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWritePolyPolygon( rPolyPoly, sal_False, pStyle ); + } + } + break; + + case( META_GRADIENT_ACTION ): + { + const MetaGradientAction* pA = (const MetaGradientAction*) pAction; + GDIMetaFile aTmpMtf; + + mpVDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf ); + ImplWriteActions( aTmpMtf, pStyle ); + } + break; + + case( META_GRADIENTEX_ACTION ): + { + const MetaGradientExAction* pA = (const MetaGradientExAction*) pAction; + ImplWriteGradientEx( pA->GetPolyPolygon(), pA->GetGradient(), pStyle ); + } + break; + + case META_HATCH_ACTION: + { + const MetaHatchAction* pA = (const MetaHatchAction*) pAction; + GDIMetaFile aTmpMtf; + + mpVDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf ); + ImplWriteActions( aTmpMtf, pStyle ); + } + break; + + case( META_TRANSPARENT_ACTION ): + { + // !!! + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + DBG_ERROR( "META_TRANSPARENT_ACTION not supported" ); + } + break; + + case( META_FLOATTRANSPARENT_ACTION ): + { + // !!! + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + DBG_ERROR( "META_FLOATTRANSPARENT_ACTION not supported" ); + } + break; + + case( META_EPS_ACTION ): + { + const MetaEPSAction* pA = (const MetaEPSAction*) pAction; + const GDIMetaFile aGDIMetaFile( pA->GetSubstitute() ); + sal_Bool bFound = sal_False; + + for( ULONG i = 0, nCount = aGDIMetaFile.GetActionCount(); ( i < nCount ) && !bFound; i++ ) + { + const MetaAction* pSubstAct = aGDIMetaFile.GetAction( i ); + + if( pSubstAct->GetType() == META_BMPSCALE_ACTION ) + { + bFound = sal_True; + const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*) pAction; + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteBmp( pBmpScaleAction->GetBitmap(), + pBmpScaleAction->GetPoint(), pBmpScaleAction->GetSize(), + Point(), pBmpScaleAction->GetBitmap().GetSizePixel(), pStyle ); + } + } + } + break; + + case( META_COMMENT_ACTION ): + { + const MetaCommentAction* pA = (const MetaCommentAction*) pAction; + String aSkipComment; + +#ifndef _SVG_UNO3 + if( pA->GetComment().ICompare( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) +#else + if( pA->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) +#endif + { + const MetaGradientExAction* pGradAction = NULL; + sal_Bool bDone = sal_False; + + while( !bDone && ( ++i < nCount ) ) + { + pAction = rMtf.GetAction( i ); + + if( pAction->GetType() == META_GRADIENTEX_ACTION ) + pGradAction = (const MetaGradientExAction*) pAction; + else if( ( pAction->GetType() == META_COMMENT_ACTION ) && +#ifndef _SVG_UNO3 + ( ( (const MetaCommentAction*) pAction )->GetComment().ICompare( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) + +#else + ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) +#endif + { + bDone = sal_True; + } + } + + if( pGradAction ) + ImplWriteGradientEx( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), pStyle ); + } + } + break; + + case( META_BMP_ACTION ): + { + const MetaBmpAction* pA = (const MetaBmpAction*) pAction; + + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteBmp( pA->GetBitmap(), + pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmap().GetSizePixel() ), + Point(), pA->GetBitmap().GetSizePixel(), pStyle ); + } + break; + + case( META_BMPSCALE_ACTION ): + { + const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pAction; + + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteBmp( pA->GetBitmap(), + pA->GetPoint(), pA->GetSize(), + Point(), pA->GetBitmap().GetSizePixel(), pStyle ); + } + break; + + case( META_BMPSCALEPART_ACTION ): + { + const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pAction; + + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteBmp( pA->GetBitmap(), + pA->GetDestPoint(), pA->GetDestSize(), + pA->GetSrcPoint(), pA->GetSrcSize(), pStyle ); + } + break; + + case( META_BMPEX_ACTION ): + { + const MetaBmpExAction* pA = (const MetaBmpExAction*) pAction; + + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteBmp( pA->GetBitmapEx(), + pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmapEx().GetSizePixel() ), + Point(), pA->GetBitmapEx().GetSizePixel(), pStyle ); + } + break; + + case( META_BMPEXSCALE_ACTION ): + { + const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pAction; + + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteBmp( pA->GetBitmapEx(), + pA->GetPoint(), pA->GetSize(), + Point(), pA->GetBitmapEx().GetSizePixel(), pStyle ); + } + break; + + case( META_BMPEXSCALEPART_ACTION ): + { + const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pAction; + + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteBmp( pA->GetBitmapEx(), + pA->GetDestPoint(), pA->GetDestSize(), + pA->GetSrcPoint(), pA->GetSrcSize(), pStyle ); + } + break; + + case( META_TEXT_ACTION ): + { + const MetaTextAction* pA = (const MetaTextAction*) pAction; + + mpContext->SetFontAttr( mpVDev->GetFont() ); + mpContext->SetPaintAttr( COL_TRANSPARENT, mpVDev->GetFont().GetColor() ); + ImplWriteText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ), NULL, 0, pStyle ); + } + break; + + case( META_TEXTRECT_ACTION ): + { + const MetaTextRectAction* pA = (const MetaTextRectAction*) pAction; + + mpContext->SetFontAttr( mpVDev->GetFont() ); + mpContext->SetPaintAttr( COL_TRANSPARENT, mpVDev->GetFont().GetColor() ); + ImplWriteText( pA->GetRect().TopLeft(), pA->GetText(), NULL, 0, pStyle ); + } + break; + + case( META_TEXTARRAY_ACTION ): + { + const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pAction; + const Point aPos( ImplMap( pA->GetPoint() ) ); + + mpContext->SetFontAttr( mpVDev->GetFont() ); + mpContext->SetPaintAttr( COL_TRANSPARENT, mpVDev->GetFont().GetColor() ); + ImplWriteText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ), pA->GetDXArray(), 0, pStyle ); + } + break; + + case( META_STRETCHTEXT_ACTION ): + { + const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pAction; + + mpContext->SetFontAttr( mpVDev->GetFont() ); + mpContext->SetPaintAttr( COL_TRANSPARENT, mpVDev->GetFont().GetColor() ); + ImplWriteText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ), NULL, pA->GetWidth(), pStyle ); + } + break; + + case( META_CLIPREGION_ACTION ): + case( META_ISECTRECTCLIPREGION_ACTION ): + case( META_ISECTREGIONCLIPREGION_ACTION ): + case( META_MOVECLIPREGION_ACTION ): + { + ( (MetaAction*) pAction )->Execute( mpVDev ); + mbClipAttrChanged = sal_True; + } + break; + + case( META_REFPOINT_ACTION ): + case( META_MAPMODE_ACTION ): + case( META_LINECOLOR_ACTION ): + case( META_FILLCOLOR_ACTION ): + case( META_TEXTLINECOLOR_ACTION ): + case( META_TEXTFILLCOLOR_ACTION ): + case( META_TEXTCOLOR_ACTION ): + case( META_TEXTALIGN_ACTION ): + case( META_FONT_ACTION ): + case( META_PUSH_ACTION ): + case( META_POP_ACTION ): + { + ( (MetaAction*) pAction )->Execute( mpVDev ); + } + break; + + case( META_RASTEROP_ACTION ): + case( META_MASK_ACTION ): + case( META_MASKSCALE_ACTION ): + case( META_MASKSCALEPART_ACTION ): + case( META_WALLPAPER_ACTION ): + case( META_TEXTLINE_ACTION ): + { + // !!! >>> we don't want to support these actions + } + break; + + default: + DBG_ERROR( "SVGActionWriter::ImplWriteActions: unsupported MetaAction #" ); + break; + } + } + + ImplReleaseContext(); +} diff --git a/extensions/source/svg/svgaction.hxx b/extensions/source/svg/svgaction.hxx new file mode 100644 index 000000000000..7fa159450a72 --- /dev/null +++ b/extensions/source/svg/svgaction.hxx @@ -0,0 +1,196 @@ +/************************************************************************* + * + * $RCSfile: svgaction.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:53 $ + * + * 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 _SVGACTION_HXX +#define _SVGACTION_HXX + +#include "svgcom.hxx" + +// -------------- +// - FastString - +// -------------- + +class FastString +{ +private: + + NMSP_RTL::OUString maString; + sal_Unicode* mpBuffer; + sal_uInt32 mnBufLen; + sal_uInt32 mnCurLen; + sal_uInt32 mnBufInc; + sal_uInt32 mnPartPos; + +public: + + FastString( sal_uInt32 nInitLen = 2048, sal_uInt32 nIncrement = 2048 ); + FastString( sal_Char* pBufferForBase64Encoding, sal_uInt32 nBufLen ); + ~FastString(); + + FastString& operator+=( const NMSP_RTL::OUString& rStr ); + + const NMSP_RTL::OUString& GetString() const; + sal_Bool GetFirstPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString ); + sal_Bool GetNextPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString ); + + sal_uInt32 GetLength() const { return mnCurLen; } + void Clear() { mnCurLen = 0, maString = NMSP_RTL::OUString(); } +}; + +// ---------------------- +// - SVGAttributeWriter - +// ---------------------- + +class SVGActionWriter; + +class SVGAttributeWriter +{ +private: + + Font maCurFont; + Color maCurLineColor; + Color maCurFillColor; + SVGActionWriter& mrParent; + SvXMLExport& mrExport; + SvXMLElementExport* mpElemFont; + SvXMLElementExport* mpElemPaint; + + SVGAttributeWriter(); + +public: + + SVGAttributeWriter( SVGActionWriter& rParent, SvXMLExport& rExport ); + virtual ~SVGAttributeWriter(); + + NMSP_RTL::OUString GetFontStyle( const Font& rFont ); + NMSP_RTL::OUString GetPaintStyle( const Color& rLineColor, const Color& rFillColor ); + + void SetFontAttr( const Font& rFont ); + void SetPaintAttr( const Color& rLineColor, const Color& rFillColor ); +}; + +// ------------------- +// - SVGActionWriter - +// ------------------- + +class SVGAttributeWriter; +class SvXMLExport; +class GDIMetaFile; + +class SVGActionWriter +{ +private: + + Stack maContextStack; + SvXMLExport& mrExport; + const GDIMetaFile& mrMtf; + SVGAttributeWriter* mpContext; + VirtualDevice* mpVDev; + MapMode maTargetMapMode; + sal_Int32 mnCurClipId; + sal_Bool mbDestroyVDev; + sal_Bool mbPaintAttrChanged; + sal_Bool mbFontAttrChanged; + sal_Bool mbClipAttrChanged; + sal_Bool mbDoublePoints; + + SVGAttributeWriter* ImplAcquireContext() { maContextStack.Push( mpContext = new SVGAttributeWriter( *this, mrExport ) ); return mpContext; } + void ImplReleaseContext() { delete (SVGAttributeWriter*) maContextStack.Pop(); mpContext = (SVGAttributeWriter*) maContextStack.Top(); } + + long ImplMap( sal_Int32 nVal ) const; + Point ImplMap( const Point& rPt ) const; + Size ImplMap( const Size& rSz ) const; + inline Rectangle ImplMap( const Rectangle& rRect ) const { return Rectangle( ImplMap( rRect.TopLeft() ), ImplMap( rRect.GetSize() ) ); } + + void ImplWriteLine( const Point& rPt1, const Point& rPt2, const Color* pLineColor = NULL, const NMSP_RTL::OUString* pStyle = NULL ); + void ImplWriteRect( const Rectangle& rRect, long nRadX = 0, long nRadY = 0, const NMSP_RTL::OUString* pStyle = NULL ); + void ImplWriteEllipse( const Point& rCenter, long nRadX, long nRadY, const NMSP_RTL::OUString* pStyle = NULL ); + void ImplWritePolygon( const Polygon& rPoly, sal_Bool bLineOnly, const NMSP_RTL::OUString* pStyle = NULL ); + void ImplWritePolyPolygon( const PolyPolygon& rPolyPoly, sal_Bool bLineOnly, const NMSP_RTL::OUString* pStyle = NULL ); + void ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const Gradient& rGradient, const NMSP_RTL::OUString* pStyle = NULL ); + void ImplWriteText( const Point& rPos, const String& rText, const long* pDXArray, long nWidth, const NMSP_RTL::OUString* pStyle = NULL ); + void ImplWriteBmp( const BitmapEx& rBmpEx, const Point& rPt, const Size& rSz, const Point& rSrcPt, const Size& rSrcSz, const NMSP_RTL::OUString* pStyle = NULL ); + + void ImplCheckFontAttributes(); + void ImplCheckPaintAttributes(); + + void ImplWriteActions( const GDIMetaFile& rMtf, const NMSP_RTL::OUString* pStyle = NULL ); + + sal_Int32 ImplGetNextClipId() { return mnCurClipId++; } + + SVGActionWriter(); + +public: + + static NMSP_RTL::OUString GetValueString( sal_Int32 nVal, sal_Bool bDoublePoints ); + +public: + + SVGActionWriter( SvXMLExport& rExport, const GDIMetaFile& rMtf, + VirtualDevice* pParentVDev = NULL, + sal_Bool bWriteDoublePoints = sal_False ); + virtual ~SVGActionWriter(); + + const VirtualDevice& GetVDev() const { return *mpVDev; } + BOOL HasDoublePoints() const { return mbDoublePoints; } +}; + +#endif diff --git a/extensions/source/svg/svgcom.hxx b/extensions/source/svg/svgcom.hxx new file mode 100644 index 000000000000..4827e95255fe --- /dev/null +++ b/extensions/source/svg/svgcom.hxx @@ -0,0 +1,144 @@ +/************************************************************************* + * + * $RCSfile: svgcom.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:53 $ + * + * 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 _SVGCOM_HXX +#define _SVGCOM_HXX + +#ifndef _CPPUHELPER_WEAK_HXX_ +#include <cppuhelper/weak.hxx> +#endif +#ifndef __RTL_USTRING_ +#include <rtl/ustring> +#endif +#ifndef _DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _STREAM_HXX +#include <tools/stream.hxx> +#endif +#ifndef _STRING_HXX +#include <tools/string.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef _STACK_HXX +#include <tools/stack.hxx> +#endif +#ifndef _SALBTYPE_HXX +#include <vcl/salbtype.hxx> +#endif +#ifndef _GDIMTF_HXX +#include <vcl/gdimtf.hxx> +#endif +#ifndef _METAACT_HXX +#include <vcl/metaact.hxx> +#endif + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> +#include <com/sun/star/svg/XSVGWriter.hpp> +#include <com/sun/star/svg/XSVGPrinter.hpp> + +#ifndef _XMLOFF_XMLEXP_HXX +#include <xmloff/xmlexp.hxx> +#endif +#ifndef _XMLOFF_NMSPMAP_HXX +#include <xmloff/nmspmap.hxx> +#endif + +// ----------------------------------------------------------------------------- + +#if SUPD >= 583 +#define _SVG_UNO3 1 +#else +#undef _SVG_UNO3 +#endif + +// ----------------------------------------------------------------------------- + +#define NMSP_CPPU cppu +#define NMSP_RTL rtl +#define NMSP_UNO com::sun::star::uno +#define NMSP_LANG com::sun::star::lang +#define NMSP_SAX com::sun::star::xml::sax +#define NMSP_SVG com::sun::star::svg +#define NMSP_REGISTRY com::sun::star::registry + + +#define REF( _def_Obj ) NMSP_UNO::Reference< _def_Obj > +#define SEQ( _def_Obj ) NMSP_UNO::Sequence< _def_Obj > +#define ANY NMSP_UNO::Any +#ifdef _SVG_UNO3 +#define B2UCONST( _def_pChar ) (NMSP_RTL::OUString(RTL_CONSTASCII_USTRINGPARAM(_def_pChar ))) +#else +#define B2UCONST( _def_pChar ) (NMSP_RTL::OUString::createFromAscii(_def_pChar)) +#endif + +#endif // _SYNCCOM_HXX diff --git a/extensions/source/svg/svgprinter.cxx b/extensions/source/svg/svgprinter.cxx new file mode 100644 index 000000000000..02cff8e4d25b --- /dev/null +++ b/extensions/source/svg/svgprinter.cxx @@ -0,0 +1,364 @@ +/************************************************************************* + * + * $RCSfile: svgprinter.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:53 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#define _RMPRINTER_EXT + +#include "svgprinter.hxx" +#include "svgaction.hxx" +#include <uno/mapping.hxx> +#include <vcl/print.hxx> +#include <vcl/virdev.hxx> + +static const char aXMLElemSVG[] = "svg"; +static const char aXMLElemMetaSVG[] = "staroffice:svgElementMeta"; +static const char aXMLElemDesc[] = "desc"; +static const char aXMLElemMeta[] = "metadata"; +static const char aXMLElemRect[] = "rect"; + +static const char aXMLAttrMetaSVGOuter[] = "isOuterElement"; +static const char aXMLAttrMetaSVGPage[] = "isPageElement"; +static const char aXMLAttrViewBox[] = "viewBox"; +static const char aXMLAttrX[] = "x"; +static const char aXMLAttrY[] = "y"; +static const char aXMLAttrWidth[] = "width"; +static const char aXMLAttrHeight[] = "height"; + +// ---------------- +// - SVGMtfExport - +// ---------------- + +class SVGPrinterExport : public SvXMLExport +{ +private: + + Printer maPrinter; + VirtualDevice* mpVDev; + SvXMLElementExport* mpOuterElement; + sal_uInt32 mnPage; + + SVGPrinterExport(); + + SvXMLElementExport* ImplCreateSVGElement( const JobSetup& rSetup, Size& rOutputSize ); + void ImplWriteMetaAttr( sal_Bool bOuter, sal_Bool bPage ); + +protected: + + virtual void _ExportMeta() {} + virtual void _ExportStyles( BOOL bUsed ) {} + virtual void _ExportAutoStyles() {} + virtual void _ExportContent() {} + virtual void _ExportMasterStyles() {} + virtual ULONG exportDoc( const char *pClass = 0 ) { return 0; } + +public: + +#ifndef _SVG_UNO3 + SVGPrinterExport( const XDocumentHandlerRef rxHandler, const JobSetup& rSetup, + const NMSP_RTL::OUString& rJobName, sal_uInt32 nCopies, sal_Bool bCollate ); +#else + SVGPrinterExport( const REF( NMSP_SAX::XDocumentHandler )& rxHandler, const JobSetup& rSetup, + const NMSP_RTL::OUString& rJobName, sal_uInt32 nCopies, sal_Bool bCollate ); +#endif + virtual ~SVGPrinterExport(); + + virtual void writePage( const JobSetup& rJobSetup, const GDIMetaFile& rMtf ); +}; + +// ----------------------------------------------------------------------------- + +#ifndef _SVG_UNO3 +SVGPrinterExport::SVGPrinterExport( const XDocumentHandlerRef rxHandler, const JobSetup& rSetup, + const NMSP_RTL::OUString& rJobName, sal_uInt32 nCopies, sal_Bool bCollate ) : +#else +SVGPrinterExport::SVGPrinterExport( const REF( NMSP_SAX::XDocumentHandler )& rxHandler, const JobSetup& rSetup, + const NMSP_RTL::OUString& rJobName, sal_uInt32 nCopies, sal_Bool bCollate ) : +#endif + SvXMLExport( NMSP_RTL::OUString(), rxHandler ), + mpVDev( NULL ), + mnPage( 0 ) +{ + maPrinter.SetJobSetup( rSetup ); + + GetDocHandler()->startDocument(); + +#ifndef _SVG_UNO3 + XExtendedDocumentHandlerRef xExtDocHandler( GetDocHandler(), USR_QUERY ); +#else + REF( NMSP_SAX::XExtendedDocumentHandler ) xExtDocHandler( GetDocHandler(), NMSP_UNO::UNO_QUERY ); +#endif + + if( xExtDocHandler.is() ) + { + NMSP_RTL::OUString aString; + const NMSP_RTL::OUString aLineFeed( NMSP_RTL::OUString::valueOf( (sal_Unicode) 0x0a ) ); + + // intro + xExtDocHandler->unknown( ( aString = B2UCONST( "<!DOCTYPE svg SYSTEM \"svg-19990812.dtd\" [" ) ) += aLineFeed ); + xExtDocHandler->unknown( ( aString = B2UCONST( "<!ELEMENT metadata (#PCDATA | staroffice:svgElementMeta)*> " ) += aLineFeed ) ); + xExtDocHandler->unknown( ( aString = B2UCONST( "<!ELEMENT staroffice:svgElementMeta ANY> " ) += aLineFeed ) ); + xExtDocHandler->unknown( ( aString = B2UCONST( "<!ATTLIST staroffice:svgElementMeta " ) += aLineFeed ) ); + + // ATTLIST + xExtDocHandler->unknown( ( aString = B2UCONST( "isOuterElement (true | false) \"false\" " ) += aLineFeed ) ); + xExtDocHandler->unknown( ( aString = B2UCONST( "isPageElement (true | false) \"true\"" ) += aLineFeed ) ); + + // end of intro + xExtDocHandler->unknown( ( aString = B2UCONST( ">" ) += aLineFeed ) ); + xExtDocHandler->unknown( ( aString = B2UCONST( "]>" ) ) ); + } + + // create outer element + Size aOutputSize; + + mpOuterElement = ImplCreateSVGElement( rSetup, aOutputSize ); + + // write description + SvXMLElementExport* pDescElem = new SvXMLElementExport( *this, XML_NAMESPACE_NONE, aXMLElemDesc, TRUE, TRUE ); + NMSP_RTL::OUString aDesc( B2UCONST( "document name: " ) ); + + GetDocHandler()->characters( aDesc += rJobName ); + delete pDescElem; + + // write meta attributes + ImplWriteMetaAttr( TRUE, FALSE ); +} + +// ----------------------------------------------------------------------------- + +SVGPrinterExport::~SVGPrinterExport() +{ + delete mpOuterElement; + GetDocHandler()->endDocument(); + delete mpVDev; +} + +// ----------------------------------------------------------------------------- + +SvXMLElementExport* SVGPrinterExport::ImplCreateSVGElement( const JobSetup& rSetup, Size& rOutputSize ) +{ + NMSP_RTL::OUString aAttr; + + delete mpVDev; + mpVDev = new VirtualDevice; + mpVDev->EnableOutput( FALSE ); + mpVDev->SetMapMode( MAP_100TH_MM ); + maPrinter.SetJobSetup( rSetup ); + + rOutputSize = maPrinter.PixelToLogic( maPrinter.GetOutputSizePixel(), mpVDev->GetMapMode() ); + + aAttr = SVGActionWriter::GetValueString( rOutputSize.Width(), sal_True ); + AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, aAttr ); + + aAttr = SVGActionWriter::GetValueString( rOutputSize.Height(), sal_True ); + AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, aAttr ); + + aAttr = B2UCONST( "0.0 0.0 " ); + aAttr += SVGActionWriter::GetValueString( rOutputSize.Width(), sal_True ); + aAttr += B2UCONST( " " ); + aAttr += SVGActionWriter::GetValueString( rOutputSize.Height(), sal_True ); + AddAttribute( XML_NAMESPACE_NONE, aXMLAttrViewBox, aAttr ); + + return( new SvXMLElementExport( *this, XML_NAMESPACE_NONE, aXMLElemSVG, TRUE, TRUE ) ); +} + +// ----------------------------------------------------------------------------- + +void SVGPrinterExport::ImplWriteMetaAttr( sal_Bool bOuter, sal_Bool bPage ) +{ + SvXMLElementExport aMetaData( *this, XML_NAMESPACE_NONE, aXMLElemMeta, TRUE, TRUE ); + NMSP_RTL::OUString aAttr; + + aAttr = bOuter ? B2UCONST( "true" ) : B2UCONST( "false" ); + AddAttribute( XML_NAMESPACE_NONE, aXMLAttrMetaSVGOuter, aAttr ); + + aAttr = bPage ? B2UCONST( "true" ) : B2UCONST( "false" ); + AddAttribute( XML_NAMESPACE_NONE, aXMLAttrMetaSVGPage, aAttr ); + + { + delete( new SvXMLElementExport( *this, XML_NAMESPACE_NONE, aXMLElemMetaSVG, TRUE, TRUE ) ); + } +} + +// ----------------------------------------------------------------------------- + +void SVGPrinterExport::writePage( const JobSetup& rSetup, const GDIMetaFile& rMtf ) +{ + Size aOutputSize; + NMSP_RTL::OUString aAttr; + SvXMLElementExport* pPageElem = ImplCreateSVGElement( rSetup, aOutputSize ); + + // write description + SvXMLElementExport* pDescElem = new SvXMLElementExport( *this, XML_NAMESPACE_NONE, aXMLElemDesc, TRUE, TRUE ); + NMSP_RTL::OUString aDesc( B2UCONST( "page: " ) ); + + GetDocHandler()->characters( aDesc += NMSP_RTL::OUString::valueOf( (sal_Int32) ++mnPage ) ); + delete pDescElem; + + // write meta attributes + ImplWriteMetaAttr( FALSE, TRUE ); + + // write dummy rect element + aAttr = B2UCONST( "0.0" ); + AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, aAttr ); + AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, aAttr ); + + aAttr = SVGActionWriter::GetValueString( aOutputSize.Width(), sal_True ); + AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, aAttr ); + + aAttr = SVGActionWriter::GetValueString( aOutputSize.Height(), sal_True ); + AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, aAttr ); + + delete( new SvXMLElementExport( *this, XML_NAMESPACE_NONE, aXMLElemRect, TRUE, TRUE ) ); + delete( new SVGActionWriter( *this, rMtf, mpVDev, TRUE ) ); + + delete pPageElem; +} + +// -------------- +// - SVGPrinter - +// -------------- + +SVGPrinter::SVGPrinter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) : + mxFact( rxMgr ), + mpWriter( NULL ) +{ +} + +// ----------------------------------------------------------------------------- + +SVGPrinter::~SVGPrinter() +{ + delete mpWriter; +} + +// ----------------------------------------------------------------------------- + + +ANY SAL_CALL SVGPrinter::queryInterface( const NMSP_UNO::Type & rType ) throw( NMSP_UNO::RuntimeException ) +{ + const ANY aRet( NMSP_CPPU::queryInterface( rType, static_cast< NMSP_SVG::XSVGPrinter* >( this ) ) ); + + return( aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ) ); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGPrinter::acquire() throw( NMSP_UNO::RuntimeException ) +{ + OWeakObject::acquire(); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGPrinter::release() throw( NMSP_UNO::RuntimeException ) +{ + OWeakObject::release(); +} + +// ----------------------------------------------------------------------------- + +sal_Bool SAL_CALL SVGPrinter::startJob( const REF( NMSP_SAX::XDocumentHandler )& rxHandler, + const SEQ( sal_Int8 )& rJobSetupSeq, + const NMSP_RTL::OUString& rJobName, + sal_uInt32 nCopies, sal_Bool bCollate ) throw( NMSP_UNO::RuntimeException ) +{ + const sal_Bool bRet = ( mpWriter == NULL ); + + if( bRet ) + { + SvMemoryStream aMemStm( (char*) rJobSetupSeq.getConstArray(), rJobSetupSeq.getLength(), STREAM_READ ); + JobSetup aJobSetup; + + aMemStm.SetCompressMode( COMPRESSMODE_FULL ); + aMemStm >> aJobSetup; + +#ifndef _SVG_UNO3 + NMSP_UNO::Mapping ecpptosmart( CPPU_CURRENT_LANGUAGE_BINDING_NAME, "smart" ); + XDocumentHandlerRef xDocumentHandler( (XDocumentHandler*) ecpptosmart.mapInterface( rxHandler.get(), getCppuType( &rxHandler ) ) ); + xDocumentHandler->release(); +#else + const REF( NMSP_SAX::XDocumentHandler ) xDocumentHandler( rxHandler ); +#endif + + mpWriter = new SVGPrinterExport( xDocumentHandler, aJobSetup, rJobName, nCopies, bCollate ); + } + + return bRet; +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGPrinter::printPage( const SEQ( sal_Int8 )& rPrintPage ) throw( NMSP_UNO::RuntimeException ) +{ + SvMemoryStream aMemStm( (char*) rPrintPage.getConstArray(), rPrintPage.getLength(), STREAM_READ ); + PrinterPage aPage; + + aMemStm.SetCompressMode( COMPRESSMODE_FULL ); + aMemStm >> aPage; + mpWriter->writePage( aPage.GetJobSetup(), *aPage.GetGDIMetaFile() ); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGPrinter::endJob() throw( NMSP_UNO::RuntimeException ) +{ + delete mpWriter, mpWriter = NULL; +} diff --git a/extensions/source/svg/svgprinter.hxx b/extensions/source/svg/svgprinter.hxx new file mode 100644 index 000000000000..a26baa0abd94 --- /dev/null +++ b/extensions/source/svg/svgprinter.hxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * $RCSfile: svgprinter.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:53 $ + * + * 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 _SVGPRINTER_HXX +#define _SVGPRINTER_HXX + +#include "svgcom.hxx" + +// ------------- +// - SVGWriter - +// ------------- + +class SVGPrinterExport; + +class SVGPrinter : public NMSP_CPPU::OWeakObject, NMSP_SVG::XSVGPrinter +{ +private: + + REF( NMSP_LANG::XMultiServiceFactory ) mxFact; + SVGPrinterExport* mpWriter; + + SVGPrinter(); + +public: + + SVGPrinter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ); + virtual ~SVGPrinter(); + + // XInterface + virtual ANY SAL_CALL queryInterface( const NMSP_UNO::Type & rType ) throw( NMSP_UNO::RuntimeException ); + virtual void SAL_CALL acquire() throw( NMSP_UNO::RuntimeException ); + virtual void SAL_CALL release() throw( NMSP_UNO::RuntimeException ); + + // XSVGPrinter + virtual sal_Bool SAL_CALL startJob( const REF( NMSP_SAX::XDocumentHandler )& rxHandler, + const SEQ( sal_Int8 )& rJobSetup, + const NMSP_RTL::OUString& rJobName, + sal_uInt32 nCopies, sal_Bool bCollate ) throw( NMSP_UNO::RuntimeException ); + virtual void SAL_CALL printPage( const SEQ( sal_Int8 )& rPrintPage ) throw( NMSP_UNO::RuntimeException ); + virtual void SAL_CALL endJob() throw( NMSP_UNO::RuntimeException ); +}; + +#endif diff --git a/extensions/source/svg/svguno.cxx b/extensions/source/svg/svguno.cxx new file mode 100644 index 000000000000..0d2f9b63474e --- /dev/null +++ b/extensions/source/svg/svguno.cxx @@ -0,0 +1,167 @@ +/************************************************************************* + * + * $RCSfile: svguno.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:53 $ + * + * 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 "svgcom.hxx" +#include "svgwriter.hxx" +#include "svgprinter.hxx" + +#include <cppuhelper/factory.hxx> +#include <uno/mapping.hxx> + +// ------------------- +// - factory methods - +// ------------------- + +#if SUPD>=590 +static REF( NMSP_UNO::XInterface ) SAL_CALL create_SVGWriter( const REF( NMSP_LANG::XMultiServiceFactory )& rxFact ) +#else +static REF( NMSP_UNO::XInterface ) create_SVGWriter( const REF( NMSP_LANG::XMultiServiceFactory )& rxFact ) +#endif +{ + return REF( NMSP_UNO::XInterface )( *new SVGWriter( rxFact ) ); +} + +// ----------------------------------------------------------------------------- + +#if SUPD>=590 +static REF( NMSP_UNO::XInterface ) SAL_CALL create_SVGPrinter( const REF( NMSP_LANG::XMultiServiceFactory )& rxFact ) +#else +static REF( NMSP_UNO::XInterface ) create_SVGPrinter( const REF( NMSP_LANG::XMultiServiceFactory )& rxFact ) +#endif +{ + return REF( NMSP_UNO::XInterface )( *new SVGPrinter( rxFact ) ); +} + +// ------------------------------------------ +// - component_getImplementationEnvironment - +// ------------------------------------------ + +extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +// ----------------------- +// - component_writeInfo - +// ----------------------- + +extern "C" sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) +{ + sal_Bool bRet = sal_False; + + if( pRegistryKey ) + { + try + { + REF( NMSP_REGISTRY::XRegistryKey ) xNewKey1( + static_cast< NMSP_REGISTRY::XRegistryKey* >( pRegistryKey )->createKey( + B2UCONST( "/com.sun.star.comp.extensions.SVGWriter/UNO/SERVICES/com.sun.star.svg.SVGWriter" ) ) ); + REF( NMSP_REGISTRY::XRegistryKey ) xNewKey2( + static_cast< NMSP_REGISTRY::XRegistryKey* >( pRegistryKey )->createKey( + B2UCONST( "/com.sun.star.comp.extensions.SVGPrinter/UNO/SERVICES/com.sun.star.svg.SVGPrinter" ) ) ); + + bRet = sal_True; + } + catch( NMSP_REGISTRY::InvalidRegistryException& ) + { + OSL_ENSHURE( sal_False, "### InvalidRegistryException!" ); + } + } + + return bRet; +} + +// ------------------------ +// - component_getFactory - +// ------------------------ + +extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey ) +{ + REF( NMSP_LANG::XSingleServiceFactory ) xFactory; + void* pRet = 0; + + if( rtl_str_compare( pImplName, "com.sun.star.comp.extensions.SVGWriter" ) == 0 ) + { + const NMSP_RTL::OUString aServiceName( B2UCONST( "com.sun.star.svg.SVGWriter" ) ); + + xFactory = REF( NMSP_LANG::XSingleServiceFactory )( NMSP_CPPU::createSingleFactory( + reinterpret_cast< NMSP_LANG::XMultiServiceFactory* >( pServiceManager ), + B2UCONST( "com.sun.star.comp.extensions.SVGWriter" ), + create_SVGWriter, SEQ( NMSP_RTL::OUString )( &aServiceName, 1 ) ) ); + } + else if( rtl_str_compare( pImplName, "com.sun.star.comp.extensions.SVGPrinter" ) == 0 ) + { + const NMSP_RTL::OUString aServiceName( B2UCONST( "com.sun.star.svg.SVGPrinter" ) ); + + xFactory = REF( NMSP_LANG::XSingleServiceFactory )( NMSP_CPPU::createSingleFactory( + reinterpret_cast< NMSP_LANG::XMultiServiceFactory* >( pServiceManager ), + B2UCONST( "com.sun.star.comp.extensions.SVGPrinter" ), + create_SVGPrinter, SEQ( NMSP_RTL::OUString )( &aServiceName, 1 ) ) ); + } + + if( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + + return pRet; +} diff --git a/extensions/source/svg/svgwriter.cxx b/extensions/source/svg/svgwriter.cxx new file mode 100644 index 000000000000..b6db93a46e75 --- /dev/null +++ b/extensions/source/svg/svgwriter.cxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * $RCSfile: svgwriter.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:53 $ + * + * 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 "svgwriter.hxx" +#include "svgaction.hxx" +#include <uno/mapping.hxx> + +// ---------------- +// - SVGMtfExport - +// ---------------- + +class SVGMtfExport : public SvXMLExport +{ +private: + + SVGMtfExport(); + +protected: + + virtual void _ExportMeta() {} + virtual void _ExportStyles( BOOL bUsed ) {} + virtual void _ExportAutoStyles() {} + virtual void _ExportContent() {} + virtual void _ExportMasterStyles() {} + virtual ULONG exportDoc( const char *pClass = 0 ) { return 0; } + +public: + +#ifndef _SVG_UNO3 + SVGMtfExport( XDocumentHandlerRef& rXHandler ); +#else + SVGMtfExport( const REF( NMSP_SAX::XDocumentHandler )& rxHandler ); +#endif + virtual ~SVGMtfExport(); + + virtual void writeMtf( const GDIMetaFile& rMtf ); +}; + +// ----------------------------------------------------------------------------- + +#ifndef _SVG_UNO3 +SVGMtfExport::SVGMtfExport( XDocumentHandlerRef& rxHandler ) : +#else +SVGMtfExport::SVGMtfExport( const REF( NMSP_SAX::XDocumentHandler )& rxHandler ) : +#endif + SvXMLExport( NMSP_RTL::OUString(), rxHandler ) +{ + GetDocHandler()->startDocument(); +} + +// ----------------------------------------------------------------------------- + +SVGMtfExport::~SVGMtfExport() +{ + GetDocHandler()->endDocument(); +} + +// ----------------------------------------------------------------------------- + +void SVGMtfExport::writeMtf( const GDIMetaFile& rMtf ) +{ + const Size aSize( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_MM ) ); + NMSP_RTL::OUString aAttr; +#ifndef _SVG_UNO3 + XExtendedDocumentHandlerRef xExtDocHandler( GetDocHandler(), USR_QUERY ); +#else + REF( NMSP_SAX::XExtendedDocumentHandler ) xExtDocHandler( GetDocHandler(), NMSP_UNO::UNO_QUERY ); +#endif + + if( xExtDocHandler.is() ) + xExtDocHandler->unknown( B2UCONST( "<!DOCTYPE svg SYSTEM \"svg-19990812.dtd\">" ) ); + + aAttr = NMSP_RTL::OUString::valueOf( aSize.Width() ); + aAttr += B2UCONST( "mm" ); + AddAttribute( XML_NAMESPACE_NONE, "width", aAttr ); + + aAttr = NMSP_RTL::OUString::valueOf( aSize.Height() ); + aAttr += B2UCONST( "mm" ); + AddAttribute( XML_NAMESPACE_NONE, "height", aAttr ); + + aAttr = B2UCONST( "0 0 " ); + aAttr += NMSP_RTL::OUString::valueOf( aSize.Width() * 100L ); + aAttr += B2UCONST( " " ); + aAttr += NMSP_RTL::OUString::valueOf( aSize.Height() * 100L ); + AddAttribute( XML_NAMESPACE_NONE, "viewBox", aAttr ); + + { + SvXMLElementExport aSVG( *this, XML_NAMESPACE_NONE, "svg", TRUE, TRUE ); + SVGActionWriter* pWriter = new SVGActionWriter( *this, rMtf ); + + delete pWriter; + } +} + +// ------------- +// - SVGWriter - +// ------------- + +SVGWriter::SVGWriter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) : + mxFact( rxMgr ) +{ +} + +// ----------------------------------------------------------------------------- + +SVGWriter::~SVGWriter() +{ +} + +// ----------------------------------------------------------------------------- + + +ANY SAL_CALL SVGWriter::queryInterface( const NMSP_UNO::Type & rType ) throw( NMSP_UNO::RuntimeException ) +{ + const ANY aRet( NMSP_CPPU::queryInterface( rType, static_cast< NMSP_SVG::XSVGWriter* >( this ) ) ); + + return( aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ) ); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGWriter::acquire() throw( NMSP_UNO::RuntimeException ) +{ + OWeakObject::acquire(); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGWriter::release() throw( NMSP_UNO::RuntimeException ) +{ + OWeakObject::release(); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGWriter::write( const REF( NMSP_SAX::XDocumentHandler )& rxDocHandler, + const SEQ( sal_Int8 )& rMtfSeq ) throw( NMSP_UNO::RuntimeException ) +{ + SvMemoryStream aMemStm( (char*) rMtfSeq.getConstArray(), rMtfSeq.getLength(), STREAM_READ ); + GDIMetaFile aMtf; + + aMemStm.SetCompressMode( COMPRESSMODE_FULL ); + aMemStm >> aMtf; + +#ifndef _SVG_UNO3 + NMSP_UNO::Mapping ecpptosmart( CPPU_CURRENT_LANGUAGE_BINDING_NAME, "smart" ); + XDocumentHandlerRef xDocumentHandler( (XDocumentHandler*)ecpptosmart.mapInterface( rxDocHandler.get(), getCppuType(&rxDocHandler)) ); + xDocumentHandler->release(); +#else + const REF( NMSP_SAX::XDocumentHandler ) xDocumentHandler( rxDocHandler ); +#endif + + SVGMtfExport* pWriter = new SVGMtfExport( xDocumentHandler ); + pWriter->writeMtf( aMtf ); + delete pWriter; +} diff --git a/extensions/source/svg/svgwriter.hxx b/extensions/source/svg/svgwriter.hxx new file mode 100644 index 000000000000..51912d04cd5b --- /dev/null +++ b/extensions/source/svg/svgwriter.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * $RCSfile: svgwriter.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:53 $ + * + * 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 _SVGWRITER_HXX +#define _SVGWRITER_HXX + +#include "svgcom.hxx" + +// ------------- +// - SVGWriter - +// ------------- + +class SVGWriter : public NMSP_CPPU::OWeakObject, NMSP_SVG::XSVGWriter +{ +private: + + REF( NMSP_LANG::XMultiServiceFactory ) mxFact; + + SVGWriter(); + +public: + + SVGWriter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ); + virtual ~SVGWriter(); + + // XInterface + virtual ANY SAL_CALL queryInterface( const NMSP_UNO::Type & rType ) throw( NMSP_UNO::RuntimeException ); + virtual void SAL_CALL acquire() throw( NMSP_UNO::RuntimeException ); + virtual void SAL_CALL release() throw( NMSP_UNO::RuntimeException ); + + // XSVGWriter + virtual void SAL_CALL write( const REF( NMSP_SAX::XDocumentHandler )& rxDocHandler, + const SEQ( sal_Int8 )& rMtfSeq ) throw( NMSP_UNO::RuntimeException ); +}; + +#endif diff --git a/extensions/source/xmlextract/makefile.mk b/extensions/source/xmlextract/makefile.mk new file mode 100644 index 000000000000..1cd16b971e6f --- /dev/null +++ b/extensions/source/xmlextract/makefile.mk @@ -0,0 +1,125 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:54 $ +# +# 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=extensions +TARGET=xmx + +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb +ENABLE_EXCEPTIONS=TRUE +USE_DEFFILE=TRUE + +# --- Settings ---------------------------------- + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Types ------------------------------------- + +UNOTYPES=\ + com.sun.star.uno.RuntimeException \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XInterface \ + com.sun.star.uno.XWeak \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.io.XInputStream \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.XInitialization \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.loader.XImplementationLoader \ + com.sun.star.registry.XImplementationRegistration \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.registry.XSimpleRegistry \ + com.sun.star.io.XXMLExtractor + +# --- Files ------------------------------------- + +SLOFILES= $(SLO)$/xmxuno.obj \ + $(SLO)$/xmxtrct.obj + +# --- Library ----------------------------------- + +SHL1TARGET=$(TARGET)$(UPD)$(DLLPOSTFIX) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(UNOTOOLSLIB) \ + $(VOSLIB) \ + $(SALLIB) \ + $(VCLLIB) \ + $(SVLLIB) \ + $(ONELIB) \ + $(SO2LIB) \ + $(SOTLIB) \ + $(TOOLSLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(SHL1TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE=exports.dxp + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/extensions/source/xmlextract/xmxcom.hxx b/extensions/source/xmlextract/xmxcom.hxx new file mode 100644 index 000000000000..627b01f7d65c --- /dev/null +++ b/extensions/source/xmlextract/xmxcom.hxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * $RCSfile: xmxcom.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:54 $ + * + * 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 _XMXCOM_HXX +#define _XMXCOM_HXX + +#ifndef _CPPUHELPER_WEAK_HXX_ +#include <cppuhelper/weak.hxx> +#endif +#ifndef __RTL_USTRING_ +#include <rtl/ustring> +#endif +#ifndef _DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _STREAM_HXX +#include <tools/stream.hxx> +#endif +#ifndef _STRING_HXX +#include <tools/string.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XXMLExtractor.hpp> + +// ----------------------------------------------------------------------------- + +#define NMSP_CPPU ::cppu +#define NMSP_RTL ::rtl +#define NMSP_UNO ::com::sun::star::uno +#define NMSP_LANG ::com::sun::star::lang +#define NMSP_IO ::com::sun::star::io +#define NMSP_REGISTRY ::com::sun::star::registry + + +#define REF( _def_Obj ) NMSP_UNO::Reference< _def_Obj > +#define SEQ( _def_Obj ) NMSP_UNO::Sequence< _def_Obj > +#define ANY NMSP_UNO::Any +#define B2UCONST( _def_pChar ) (NMSP_RTL::OUString(RTL_CONSTASCII_USTRINGPARAM(_def_pChar ))) + +#endif // _XMXCOM_HXX diff --git a/extensions/source/xmlextract/xmxtrct.cxx b/extensions/source/xmlextract/xmxtrct.cxx new file mode 100644 index 000000000000..cac9e41e7033 --- /dev/null +++ b/extensions/source/xmlextract/xmxtrct.cxx @@ -0,0 +1,221 @@ +/************************************************************************* + * + * $RCSfile: xmxtrct.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:54 $ + * + * 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 "xmxtrct.hxx" + +#include <rtl/memory.h> +#include <tools/zcodec.hxx> +#include <unotools/streamhelper.hxx> +#include <so3/svstor.hxx> + +// ---------------- +// - XMXLockBytes - +// ---------------- + +class XMXLockBytes : public SvLockBytes +{ + REF( NMSP_IO::XInputStream ) mxIStm; + SEQ( sal_Int8 ) maSeq; + + XMXLockBytes(); + +public: + + XMXLockBytes( const REF( NMSP_IO::XInputStream )& rxIStm ); + virtual ~XMXLockBytes(); + + virtual ErrCode ReadAt( sal_uInt32 nPos, void* pBuffer, sal_uInt32 nCount, sal_uInt32* pRead ) const; + virtual ErrCode WriteAt( sal_uInt32 nPos, const void* pBuffer, sal_uInt32 nCount, sal_uInt32* pWritten ); + virtual ErrCode Flush() const; + virtual ErrCode SetSize( sal_uInt32 nSize ); + virtual ErrCode Stat( SvLockBytesStat*, SvLockBytesStatFlag ) const; +}; + +// ------------------------------------------------------------------------ + +XMXLockBytes::XMXLockBytes( const REF( NMSP_IO::XInputStream )& rxIStm ) : + mxIStm( rxIStm ) +{ + if( mxIStm.is() ) + { + const sal_uInt32 nBytesToRead = 65535; + sal_uInt32 nRead; + + do + { + SEQ( sal_Int8 ) aReadSeq; + + nRead = mxIStm->readSomeBytes( aReadSeq, nBytesToRead ); + + if( nRead ) + { + const sal_uInt32 nOldLength = maSeq.getLength(); + maSeq.realloc( nOldLength + nRead ); + rtl_copyMemory( maSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() ); + } + } + while( nBytesToRead == nRead ); + } +} + +// ------------------------------------------------------------------------ + +XMXLockBytes::~XMXLockBytes() +{ +} + +// ------------------------------------------------------------------------ + +ErrCode XMXLockBytes::ReadAt( sal_uInt32 nPos, void* pBuffer, sal_uInt32 nCount, sal_uInt32* pRead ) const +{ + const sal_uInt32 nSeqLen = maSeq.getLength(); + ErrCode nErr = ERRCODE_NONE; + + if( nPos < nSeqLen ) + { + if( ( nPos + nCount ) > nSeqLen ) + nCount = nSeqLen - nPos; + + rtl_copyMemory( pBuffer, maSeq.getConstArray() + nPos, nCount ); + *pRead = nCount; + } + else + *pRead = 0UL; + + return nErr; +} + +// ------------------------------------------------------------------------ + +ErrCode XMXLockBytes::WriteAt( sal_uInt32 nPos, const void* pBuffer, sal_uInt32 nCount, sal_uInt32* pWritten ) +{ + return ERRCODE_IO_CANTWRITE; +} + +// ------------------------------------------------------------------------ + +ErrCode XMXLockBytes::Flush() const +{ + return ERRCODE_NONE; +} + +// ------------------------------------------------------------------------ + +ErrCode XMXLockBytes::SetSize( sal_uInt32 nSize ) +{ + return ERRCODE_IO_CANTWRITE; +} + +// ------------------------------------------------------------------------ + +ErrCode XMXLockBytes::Stat( SvLockBytesStat* pStat, SvLockBytesStatFlag eFlag ) const +{ + pStat->nSize = maSeq.getLength(); + return ERRCODE_NONE; +} + +// ---------------- +// - XMLExtractor - +// ---------------- + +XMLExtractor::XMLExtractor( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) : + mxFact( rxMgr ) +{ +} + +// ----------------------------------------------------------------------------- + +XMLExtractor::~XMLExtractor() +{ +} + +// ----------------------------------------------------------------------------- + +REF( NMSP_IO::XInputStream ) SAL_CALL XMLExtractor::extract( const REF( NMSP_IO::XInputStream )& rxIStm ) throw( NMSP_UNO::RuntimeException ) +{ + REF( NMSP_IO::XInputStream ) xRet; + + if( rxIStm.is() ) + { + SvStream aIStm( new XMXLockBytes( rxIStm ) ); + SvStorageRef aStorage( new SvStorage( aIStm ) ); + const String aStmName( String::CreateFromAscii( "XMLFormat" ) ); + + if( !aStorage->GetError() && aStorage->IsStream( aStmName )) + { + SvStorageStreamRef xStream( aStorage->OpenStream( aStmName ) ); + + if( xStream.Is() ) + { + SvMemoryStream* pMemStm = new SvMemoryStream( 65535, 65535 ); + ZCodec aCodec; + + aCodec.BeginCompression( ZCODEC_BEST_COMPRESSION ); + aCodec.Decompress( *xStream, *pMemStm ); + aCodec.EndCompression(); + + xRet = new ::utl::OInputStreamHelper( new SvLockBytes( pMemStm, TRUE ), 65535 ); + } + } + } + + return xRet; +} diff --git a/extensions/source/xmlextract/xmxtrct.hxx b/extensions/source/xmlextract/xmxtrct.hxx new file mode 100644 index 000000000000..f1e099bf9498 --- /dev/null +++ b/extensions/source/xmlextract/xmxtrct.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * $RCSfile: xmxtrct.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:54 $ + * + * 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 _XMXTRCT_HXX +#define _XMXTRCT_HXX + +#include "xmxcom.hxx" + +// ---------------- +// - XMLExtractor - +// ---------------- + +class XMLExtractor : public ::cppu::WeakImplHelper1< NMSP_IO::XXMLExtractor > +{ +private: + + REF( NMSP_LANG::XMultiServiceFactory ) mxFact; + + XMLExtractor(); + +public: + + XMLExtractor( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ); + virtual ~XMLExtractor(); + + // XXMLExtractor + virtual REF( NMSP_IO::XInputStream ) SAL_CALL extract( const REF( NMSP_IO::XInputStream )& rxIStm ) throw( NMSP_UNO::RuntimeException ); +}; + +#endif diff --git a/extensions/source/xmlextract/xmxuno.cxx b/extensions/source/xmlextract/xmxuno.cxx new file mode 100644 index 000000000000..fb9bff62b97e --- /dev/null +++ b/extensions/source/xmlextract/xmxuno.cxx @@ -0,0 +1,131 @@ +/************************************************************************* + * + * $RCSfile: xmxuno.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:54 $ + * + * 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 "xmxcom.hxx" +#include "xmxtrct.hxx" +#include <osl/diagnose.h> +#include <cppuhelper/factory.hxx> +#include <uno/mapping.hxx> + +// ------------------- +// - factory methods - +// ------------------- + +static REF( NMSP_UNO::XInterface ) SAL_CALL create_XMLExtractor( const REF( NMSP_LANG::XMultiServiceFactory )& rxFact ) +{ + return REF( NMSP_UNO::XInterface )( *new XMLExtractor( rxFact ) ); +} + +extern "C" +{ +//================================================================================================== +void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} +//================================================================================================== +sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, void * pRegistryKey ) +{ + if (pRegistryKey) + { + try + { + REF( NMSP_REGISTRY::XRegistryKey ) xNewKey( + reinterpret_cast< NMSP_REGISTRY::XRegistryKey * >( pRegistryKey )->createKey( + NMSP_RTL::OUString( RTL_CONSTASCII_USTRINGPARAM("/com.sun.star.comp.io.XMLExtractor/UNO/SERVICES/com.sun.star.io.XMLExtractor") ) ) ); + + return sal_True; + } + catch (NMSP_REGISTRY::InvalidRegistryException &) + { + OSL_ENSHURE( sal_False, "### InvalidRegistryException!" ); + } + } + return sal_False; +} +//================================================================================================== +void * SAL_CALL component_getFactory( + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +{ + void * pRet = 0; + + if (rtl_str_compare( pImplName, "com.sun.star.comp.io.XMLExtractor" ) == 0) + { + NMSP_RTL::OUString aServiceName( B2UCONST( "com.sum.star.io.XMLExtractor" ) ); + + REF( NMSP_LANG::XSingleServiceFactory ) xFactory( NMSP_CPPU::createSingleFactory( + reinterpret_cast< NMSP_LANG::XMultiServiceFactory * >( pServiceManager ), + NMSP_RTL::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.io.XMLExtractor") ), + create_XMLExtractor, + SEQ( NMSP_RTL::OUString )( &aServiceName, 1 ) ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} +} |