diff options
-rw-r--r-- | xmlscript/inc/xmlscript/xml_helper.hxx | 109 | ||||
-rw-r--r-- | xmlscript/inc/xmlscript/xmldlg_imexp.hxx | 89 | ||||
-rw-r--r-- | xmlscript/source/xml_helper/makefile.mk | 84 | ||||
-rw-r--r-- | xmlscript/source/xml_helper/xml_byteseq.cxx | 204 | ||||
-rw-r--r-- | xmlscript/source/xml_helper/xml_impctx.cxx | 917 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/exp_share.hxx | 224 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/imp_share.hxx | 489 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/makefile.mk | 86 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx | 328 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_export.cxx | 969 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx | 606 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_import.cxx | 834 | ||||
-rw-r--r-- | xmlscript/test/imexp.cxx | 392 | ||||
-rw-r--r-- | xmlscript/test/makefile.mk | 121 | ||||
-rw-r--r-- | xmlscript/test/test.xml | 35 | ||||
-rw-r--r-- | xmlscript/util/makefile.mk | 106 | ||||
-rw-r--r-- | xmlscript/util/target.pmk | 70 |
17 files changed, 5663 insertions, 0 deletions
diff --git a/xmlscript/inc/xmlscript/xml_helper.hxx b/xmlscript/inc/xmlscript/xml_helper.hxx new file mode 100644 index 000000000000..44f573858c4c --- /dev/null +++ b/xmlscript/inc/xmlscript/xml_helper.hxx @@ -0,0 +1,109 @@ +/************************************************************************* + * + * $RCSfile: xml_helper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:47 $ + * + * 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 _XMLSCRIPT_XML_HELPER_HXX_ +#define _XMLSCRIPT_XML_HELPER_HXX_ + +#include <rtl/byteseq.hxx> + +#include <com/sun/star/xml/XImporter.hpp> +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> + +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> + + +namespace xmlscript +{ + +struct NameSpaceUid +{ + ::rtl::OUString sURI; + sal_Int32 nUid; + + NameSpaceUid( ::rtl::OUString const & sURI_, sal_Int32 nUid_ ) + : sURI( sURI_ ) + , nUid( nUid_ ) + {} +}; + +//================================================================================================== +::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > +SAL_CALL createDocumentHandler( + NameSpaceUid const * pNamespaceUids, sal_Int32 nNameSpaceUids, + sal_Int32 nUnknownNamespaceUid, + ::com::sun::star::uno::Reference< ::com::sun::star::xml::XImporter > const & xImporter, + bool bSingleThreadedUse = true ) + throw (); + +//================================================================================================== +::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > +SAL_CALL createInputStream( + ::rtl::ByteSequence const & rInData ) + throw (); +//================================================================================================== +::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > +SAL_CALL createOutputStream( + ::rtl::ByteSequence * pOutData ) + throw (); + +}; + +#endif diff --git a/xmlscript/inc/xmlscript/xmldlg_imexp.hxx b/xmlscript/inc/xmlscript/xmldlg_imexp.hxx new file mode 100644 index 000000000000..9641c6547162 --- /dev/null +++ b/xmlscript/inc/xmlscript/xmldlg_imexp.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * $RCSfile: xmldlg_imexp.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:47 $ + * + * 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 _XMLSCRIPT_XMLDLG_IMEXP_HXX_ +#define _XMLSCRIPT_XMLDLG_IMEXP_HXX_ + +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> + + +namespace xmlscript +{ + +#define XMLNS_DIALOGS_URI "http://openoffice.org/2000/dialog" +#define XMLNS_DIALOGS_UID 1 +#define XMLNS_DIALOGS_PREFIX "dlg" + + +//================================================================================================== +void exportDialogModel( + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > const & xDialogModel, + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut ) + throw (::com::sun::star::uno::Exception); + +//================================================================================================== +::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > importDialogModel( + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > const & xDialogModel ) + throw (::com::sun::star::uno::Exception); + +}; + +#endif diff --git a/xmlscript/source/xml_helper/makefile.mk b/xmlscript/source/xml_helper/makefile.mk new file mode 100644 index 000000000000..b86b0aeae15e --- /dev/null +++ b/xmlscript/source/xml_helper/makefile.mk @@ -0,0 +1,84 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: dbo $ $Date: 2001-02-16 14:14:47 $ +# +# 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=xmlscript +TARGET=xml_helper +NO_BSYMBOLIC=TRUE +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +#----------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/xml_impctx.obj \ + $(SLO)$/xml_byteseq.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : $(PRJ)$/util$/target.pmk +.INCLUDE : target.mk diff --git a/xmlscript/source/xml_helper/xml_byteseq.cxx b/xmlscript/source/xml_helper/xml_byteseq.cxx new file mode 100644 index 000000000000..07914aa4933e --- /dev/null +++ b/xmlscript/source/xml_helper/xml_byteseq.cxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * $RCSfile: xml_byteseq.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:47 $ + * + * 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 <rtl/memory.h> + +#include <cppuhelper/implbase1.hxx> +#include <xmlscript/xml_helper.hxx> + + +using namespace rtl; +using namespace osl; +using namespace com::sun::star; +using namespace com::sun::star::uno; + + +namespace xmlscript +{ + +//================================================================================================== +class BSeqInputStream + : public ::cppu::WeakImplHelper1< io::XInputStream > +{ + ByteSequence _seq; + sal_Int32 _nPos; + +public: + inline BSeqInputStream( ByteSequence const & rSeq ) + throw () + : _seq( rSeq ) + , _nPos( 0 ) + {} + + // XInputStream + virtual sal_Int32 SAL_CALL readBytes( + Sequence< sal_Int8 > & rData, sal_Int32 nBytesToRead ) + throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException); + virtual sal_Int32 SAL_CALL readSomeBytes( + Sequence< sal_Int8 > & rData, sal_Int32 nMaxBytesToRead ) + throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException); + virtual void SAL_CALL skipBytes( + sal_Int32 nBytesToSkip ) + throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException); + virtual sal_Int32 SAL_CALL available() + throw (io::NotConnectedException, io::IOException, RuntimeException); + virtual void SAL_CALL closeInput() + throw (io::NotConnectedException, io::IOException, RuntimeException); +}; +//__________________________________________________________________________________________________ +sal_Int32 BSeqInputStream::readBytes( + Sequence< sal_Int8 > & rData, sal_Int32 nBytesToRead ) + throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException) +{ + nBytesToRead = ((nBytesToRead > _seq.getLength() - _nPos) + ? _seq.getLength() - _nPos + : nBytesToRead); + + ByteSequence aBytes( _seq.getConstArray() + _nPos, nBytesToRead ); + rData = toUnoSequence( aBytes ); + _nPos += nBytesToRead; + return nBytesToRead; +} +//__________________________________________________________________________________________________ +sal_Int32 BSeqInputStream::readSomeBytes( + Sequence< sal_Int8 > & rData, sal_Int32 nMaxBytesToRead ) + throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException) +{ + return readBytes( rData, nMaxBytesToRead ); +} +//__________________________________________________________________________________________________ +void BSeqInputStream::skipBytes( + sal_Int32 nBytesToSkip ) + throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException) +{ +} +//__________________________________________________________________________________________________ +sal_Int32 BSeqInputStream::available() + throw (io::NotConnectedException, io::IOException, RuntimeException) +{ + return (_seq.getLength() - _nPos); +} +//__________________________________________________________________________________________________ +void BSeqInputStream::closeInput() + throw (io::NotConnectedException, io::IOException, RuntimeException) +{ +} + +//################################################################################################## + +//================================================================================================== +class BSeqOutputStream + : public ::cppu::WeakImplHelper1< io::XOutputStream > +{ + ByteSequence * _seq; + +public: + inline BSeqOutputStream( ByteSequence * seq ) + throw () + : _seq( seq ) + {} + + // XOutputStream + virtual void SAL_CALL writeBytes( + Sequence< sal_Int8 > const & rData ) + throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException); + virtual void SAL_CALL flush() + throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException); + virtual void SAL_CALL closeOutput() + throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException); +}; +//__________________________________________________________________________________________________ +void BSeqOutputStream::writeBytes( Sequence< sal_Int8 > const & rData ) + throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException) +{ + sal_Int32 nPos = _seq->getLength(); + _seq->realloc( nPos + rData.getLength() ); + ::rtl_copyMemory( (char *)_seq->getArray() + nPos, + (char const *)rData.getConstArray(), + rData.getLength() ); +} +//__________________________________________________________________________________________________ +void BSeqOutputStream::flush() + throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException) +{ +} +//__________________________________________________________________________________________________ +void BSeqOutputStream::closeOutput() + throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException) +{ +} + +//################################################################################################## + +//================================================================================================== +Reference< io::XInputStream > SAL_CALL createInputStream( ByteSequence const & rInData ) + throw () +{ + return new BSeqInputStream( rInData ); +} + +//================================================================================================== +Reference< io::XOutputStream > SAL_CALL createOutputStream( ByteSequence * pOutData ) + throw () +{ + return new BSeqOutputStream( pOutData ); +} + +}; diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx new file mode 100644 index 000000000000..1283de92981c --- /dev/null +++ b/xmlscript/source/xml_helper/xml_impctx.cxx @@ -0,0 +1,917 @@ +/************************************************************************* + * + * $RCSfile: xml_impctx.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:47 $ + * + * 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 <vector> +#include <hash_map> + +#include <osl/diagnose.h> +#include <osl/mutex.hxx> + +#include <rtl/ustrbuf.hxx> + +#include <cppuhelper/implbase1.hxx> +#include <xmlscript/xml_helper.hxx> + +#include <com/sun/star/xml/sax2/XExtendedAttributes.hpp> + +using namespace rtl; +using namespace osl; +using namespace com::sun::star; +using namespace com::sun::star::uno; + + +namespace xmlscript +{ + +typedef ::std::hash_map< OUString, sal_Int32, OUStringHash > t_OUString2LongMap; +typedef ::std::hash_map< sal_Int32, OUString > t_Long2OUStringMap; + +struct PrefixEntry +{ + ::std::vector< sal_Int32 > _Uids; + + inline PrefixEntry() throw () + { _Uids.reserve( 4 ); } +}; + +typedef ::std::hash_map< OUString, PrefixEntry *, OUStringHash > t_OUString2PrefixMap; + +struct ContextEntry +{ + Reference< xml::XImportContext > _xContext; + ::std::vector< OUString > _prefixes; + + inline ContextEntry() + { _prefixes.reserve( 2 ); } +}; +typedef ::std::vector< ContextEntry * > t_ContextVector; + +class ExtendedAttributes; + +//============================================================================================== +struct MGuard +{ + Mutex * _pMutex; + MGuard( Mutex * pMutex = 0 ) + : _pMutex( pMutex ) + { if (_pMutex) _pMutex->acquire(); } + ~MGuard() + { if (_pMutex) _pMutex->release(); } +}; + +//============================================================================================== +class DocumentHandlerImpl + : public ::cppu::WeakImplHelper1< xml::sax::XDocumentHandler > +{ + friend class ExtendedAttributes; + + Reference< xml::XImporter > _xImporter; + + t_OUString2LongMap _URI2Uid; + t_Long2OUStringMap _Uid2URI; + + sal_Int32 _nUnknownNamespaceUid; + OUString _sXMLNS_URI_UNKNOWN; + OUString _sXMLNS_PREFIX_UNKNOWN; + OUString _sXMLNS; + + OUString _aLastURI_lookup; + sal_Int32 _nLastURI_lookup; + + t_OUString2PrefixMap _prefixes; + OUString _aLastPrefix_lookup; + sal_Int32 _nLastPrefix_lookup; + + t_ContextVector _contexts; + sal_Int32 _nSkipElements; + + Mutex * _pMutex; + + inline sal_Int32 getUidByURI( + OUString const & rURI ) + throw (); + inline OUString getURIByUid( + sal_Int32 nUid ) + throw (); + + inline sal_Int32 getUidByPrefix( + OUString const & rPrefix ) + throw (); + inline void pushPrefix( + OUString const & rPrefix, OUString const & rURI ) + throw (); + inline void popPrefix( + OUString const & rPrefix ) + throw (); + inline void getElementName( + OUString const & rQName, sal_Int32 * pUid, OUString * pLocalName ) + throw (); +public: + DocumentHandlerImpl( + const NameSpaceUid * pNamespaceUids, sal_Int32 nNameSpaceUids, + sal_Int32 nUnknownNamespaceUid, + Reference< xml::XImporter > const & xImporter, + bool bSingleThreadedUse ) + throw (); + virtual ~DocumentHandlerImpl() + throw (); + + // XDocumentHandler + virtual void SAL_CALL startDocument() + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endDocument() + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL startElement( + OUString const & rQElementName, Reference< xml::sax::XAttributeList > const & xAttribs ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endElement( + OUString const & rQElementName ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL characters( + OUString const & rChars ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL ignorableWhitespace( + OUString const & rWhitespaces ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL processingInstruction( + OUString const & rTarget, OUString const & rData ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL setDocumentLocator( + Reference< xml::sax::XLocator > const & xLocator ) + throw (xml::sax::SAXException, RuntimeException); +}; + +//__________________________________________________________________________________________________ +DocumentHandlerImpl::DocumentHandlerImpl( + const NameSpaceUid * pNamespaceUids, sal_Int32 nNameSpaceUids, + sal_Int32 nUnknownNamespaceUid, + Reference< xml::XImporter > const & xImporter, + bool bSingleThreadedUse ) + throw () + : _xImporter( xImporter ) + , _nUnknownNamespaceUid( nUnknownNamespaceUid ) + , _sXMLNS_URI_UNKNOWN( RTL_CONSTASCII_USTRINGPARAM("<<< unknown URI >>>") ) + , _sXMLNS_PREFIX_UNKNOWN( RTL_CONSTASCII_USTRINGPARAM("<<< unknown prefix >>>") ) + , _sXMLNS( RTL_CONSTASCII_USTRINGPARAM("xmlns") ) + , _nLastURI_lookup( nUnknownNamespaceUid ) + , _aLastURI_lookup( RTL_CONSTASCII_USTRINGPARAM("<<< unknown URI >>>") ) + , _nLastPrefix_lookup( nUnknownNamespaceUid ) + , _aLastPrefix_lookup( RTL_CONSTASCII_USTRINGPARAM("<<< unknown URI >>>") ) + , _nSkipElements( 0 ) + , _pMutex( 0 ) +{ + _contexts.reserve( 10 ); + + if (! bSingleThreadedUse) + { + _pMutex = new Mutex(); + } + + for ( sal_Int32 nPos = nNameSpaceUids; nPos--; ) + { + const NameSpaceUid & rEntry = pNamespaceUids[ nPos ]; + // default namespace has empty string as URI + _URI2Uid[ rEntry.sURI ] = rEntry.nUid; + _Uid2URI[ rEntry.nUid ] = rEntry.sURI; + } +} +//__________________________________________________________________________________________________ +DocumentHandlerImpl::~DocumentHandlerImpl() + throw () +{ + if (_pMutex) + { + delete _pMutex; +#ifndef _DEBUG + _pMutex = 0; +#endif + } +} +//__________________________________________________________________________________________________ +inline sal_Int32 DocumentHandlerImpl::getUidByURI( + OUString const & rURI ) + throw () +{ + if (_nLastURI_lookup == _nUnknownNamespaceUid || _aLastURI_lookup != rURI) + { + t_OUString2LongMap::const_iterator iFind( _URI2Uid.find( rURI ) ); + if (iFind != _URI2Uid.end()) // id found + { + _nLastURI_lookup = iFind->second; + _aLastURI_lookup = rURI; + } + else + { + _nLastURI_lookup = _nUnknownNamespaceUid; + _aLastURI_lookup = _sXMLNS_URI_UNKNOWN; + } + } + return _nLastURI_lookup; +} +//__________________________________________________________________________________________________ +inline OUString DocumentHandlerImpl::getURIByUid( sal_Int32 nUid ) + throw () +{ + if (nUid != _nLastURI_lookup) + { + t_Long2OUStringMap::const_iterator iFind( _Uid2URI.find( nUid ) ); + if (iFind != _Uid2URI.end()) + { + _aLastURI_lookup = iFind->second; + _nLastURI_lookup = nUid; + } + else + { + _nLastURI_lookup = _nUnknownNamespaceUid; + _aLastURI_lookup = _sXMLNS_URI_UNKNOWN; + } + } + return _aLastURI_lookup; +} +//__________________________________________________________________________________________________ +inline sal_Int32 DocumentHandlerImpl::getUidByPrefix( + OUString const & rPrefix ) + throw () +{ + // commonly the last added prefix is used often for several tags... good guess + if (_nLastPrefix_lookup == _nUnknownNamespaceUid || _aLastPrefix_lookup != rPrefix) + { + t_OUString2PrefixMap::const_iterator iFind( _prefixes.find( rPrefix ) ); + if (iFind != _prefixes.end()) + { + const PrefixEntry & rPrefixEntry = *iFind->second; + OSL_ASSERT( ! rPrefixEntry._Uids.empty() ); + _nLastPrefix_lookup = rPrefixEntry._Uids.back(); + _aLastPrefix_lookup = rPrefix; + } + else + { + _nLastPrefix_lookup = _nUnknownNamespaceUid; + _aLastPrefix_lookup = _sXMLNS_PREFIX_UNKNOWN; + } + } + return _nLastPrefix_lookup; +} +//__________________________________________________________________________________________________ +inline void DocumentHandlerImpl::pushPrefix( + OUString const & rPrefix, OUString const & rURI ) + throw () +{ + // lookup id for URI + sal_Int32 nUid = getUidByURI( rURI ); + + // mark prefix with id + t_OUString2PrefixMap::const_iterator iFind( _prefixes.find( rPrefix ) ); + if (iFind == _prefixes.end()) // unused prefix + { + PrefixEntry * pEntry = new PrefixEntry(); + pEntry->_Uids.push_back( nUid ); // latest id for prefix + _prefixes[ rPrefix ] = pEntry; + } + else + { + PrefixEntry * pEntry = iFind->second; + OSL_ASSERT( ! pEntry->_Uids.empty() ); + pEntry->_Uids.push_back( nUid ); + } + + _aLastPrefix_lookup = rPrefix; + _nLastPrefix_lookup = nUid; +} +//__________________________________________________________________________________________________ +inline void DocumentHandlerImpl::popPrefix( + OUString const & rPrefix ) + throw () +{ + t_OUString2PrefixMap::iterator iFind( _prefixes.find( rPrefix ) ); + if (iFind != _prefixes.end()) // unused prefix + { + PrefixEntry * pEntry = iFind->second; + pEntry->_Uids.pop_back(); // pop last id for prefix + if (pEntry->_Uids.empty()) // erase prefix key + { + _prefixes.erase( iFind ); + delete pEntry; + } + } + + _nLastPrefix_lookup = _nUnknownNamespaceUid; + _aLastPrefix_lookup = _sXMLNS_PREFIX_UNKNOWN; +} +//__________________________________________________________________________________________________ +inline void DocumentHandlerImpl::getElementName( + OUString const & rQName, sal_Int32 * pUid, OUString * pLocalName ) + throw () +{ + sal_Int32 nColonPos = rQName.indexOf( (sal_Unicode)':' ); + *pLocalName = (nColonPos >= 0 ? rQName.copy( nColonPos +1 ) : rQName); + *pUid = getUidByPrefix( nColonPos >= 0 ? rQName.copy( 0, nColonPos ) : OUString() ); +} + +//================================================================================================== +class ExtendedAttributes + : public ::cppu::WeakImplHelper1< xml::sax2::XExtendedAttributes > +{ + sal_Int32 _nAttributes; + sal_Int32 * _pUids; + OUString * _pPrefixes; + OUString * _pLocalNames; + OUString * _pQNames; + OUString * _pValues; + + DocumentHandlerImpl * _pHandler; + +public: + inline ExtendedAttributes( + sal_Int32 nAttributes, + sal_Int32 * pUids, OUString * pPrefixes, OUString * pLocalNames, OUString * pQNames, + Reference< xml::sax::XAttributeList > const & xAttributeList, + DocumentHandlerImpl * pHandler ) + throw (); + virtual ~ExtendedAttributes() + throw (); + + // XAttributes + virtual sal_Int32 SAL_CALL getIndexByQName( + OUString const & rQName ) + throw (RuntimeException); + virtual sal_Int32 SAL_CALL getIndexByName( + OUString const & rURI, OUString const & rLocalName ) + throw (RuntimeException); + virtual sal_Int32 SAL_CALL getLength() + throw (RuntimeException); + virtual OUString SAL_CALL getLocalNameByIndex( + sal_Int32 nIndex ) + throw (RuntimeException); + virtual OUString SAL_CALL getQNameByIndex( + sal_Int32 nIndex ) + throw (RuntimeException); + virtual OUString SAL_CALL getTypeByIndex( + sal_Int32 nIndex ) + throw (RuntimeException); + virtual OUString SAL_CALL getTypeByName( + OUString const & rURI, OUString const & rLocalName ) + throw (RuntimeException); + virtual OUString SAL_CALL getURIByIndex( + sal_Int32 nIndex ) + throw (RuntimeException); + virtual OUString SAL_CALL getValueByIndex( + sal_Int32 nIndex ) + throw (RuntimeException); + virtual OUString SAL_CALL getValueByQName( + OUString const & rQName ) + throw (RuntimeException); + virtual OUString SAL_CALL getValueByName( + OUString const & rURI, OUString const & rLocalName ) + throw (RuntimeException); + + // XExtendedAttributes + virtual sal_Int32 SAL_CALL getIndexByUidName( + sal_Int32 nUid, OUString const & rLocalName ) + throw (RuntimeException); + virtual OUString SAL_CALL getTypeByUidName( + sal_Int32 nUid, OUString const & rLocalName ) + throw (RuntimeException); + virtual sal_Int32 SAL_CALL getUidByIndex( + sal_Int32 nIndex ) + throw (RuntimeException); + virtual OUString SAL_CALL getValueByUidName( + sal_Int32 nUid, OUString const & rLocalName ) + throw (RuntimeException); +}; +//__________________________________________________________________________________________________ +inline ExtendedAttributes::ExtendedAttributes( + sal_Int32 nAttributes, + sal_Int32 * pUids, OUString * pPrefixes, OUString * pLocalNames, OUString * pQNames, + Reference< xml::sax::XAttributeList > const & xAttributeList, + DocumentHandlerImpl * pHandler ) + throw () + : _nAttributes( nAttributes ) + , _pUids( pUids ) + , _pPrefixes( pPrefixes ) + , _pLocalNames( pLocalNames ) + , _pQNames( pQNames ) + , _pValues( new OUString[ nAttributes ] ) + , _pHandler( pHandler ) +{ + _pHandler->acquire(); + + for ( sal_Int16 nPos = 0; nPos < nAttributes; ++nPos ) + { + _pValues[ nPos ] = xAttributeList->getValueByIndex( nPos ); + } +} +//__________________________________________________________________________________________________ +ExtendedAttributes::~ExtendedAttributes() + throw () +{ + _pHandler->release(); + + delete [] _pUids; + delete [] _pPrefixes; + delete [] _pLocalNames; + delete [] _pQNames; + delete [] _pValues; +} + + +//################################################################################################## + + +// XDocumentHandler +//__________________________________________________________________________________________________ +void DocumentHandlerImpl::startDocument() + throw (xml::sax::SAXException, RuntimeException) +{ + _xImporter->startDocument(); +} +//__________________________________________________________________________________________________ +void DocumentHandlerImpl::endDocument() + throw (xml::sax::SAXException, RuntimeException) +{ + _xImporter->endDocument(); +} +//__________________________________________________________________________________________________ +void DocumentHandlerImpl::startElement( + OUString const & rQElementName, Reference< xml::sax::XAttributeList > const & xAttribs ) + throw (xml::sax::SAXException, RuntimeException) +{ + Reference< xml::XImportContext > xCurrentContext; + + sal_Int32 nUid; + OUString aLocalName; + + sal_Int16 nAttribs = xAttribs->getLength(); + + ContextEntry * pContextEntry = new ContextEntry(); + + // save all namespace ids + sal_Int32 * pUids = new sal_Int32[ nAttribs ]; + OUString * pPrefixes = new OUString[ nAttribs ]; + OUString * pLocalNames = new OUString[ nAttribs ]; + OUString * pQNames = new OUString[ nAttribs ]; + + { // guard start: + MGuard aGuard( _pMutex ); + if (_nSkipElements) // currently skipping elements and waiting for end tags? + { + ++_nSkipElements; // wait for another end tag +#ifdef _DEBUG + OString aQName( OUStringToOString( rQElementName, RTL_TEXTENCODING_ASCII_US ) ); + OSL_TRACE( "### no context given on createChildContext() => ignoring element \"%s\" ...", aQName.getStr() ); +#endif + return; + } + + // first recognize all xmlns attributes + sal_Int16 nPos; + for ( nPos = 0; nPos < nAttribs; ++nPos ) + { + // mark attribute to be collected further on with attribute's uid and current prefix + pUids[ nPos ] = _nUnknownNamespaceUid +1; // modified + + pQNames[ nPos ] = xAttribs->getNameByIndex( nPos ); + OUString const & rQAttributeName = pQNames[ nPos ]; + + if (rQAttributeName.compareTo( _sXMLNS, 5 ) == 0) + { + if (rQAttributeName.getLength() == 5) // set default namespace + { + OUString aDefNamespacePrefix; + pushPrefix( aDefNamespacePrefix, xAttribs->getValueByIndex( nPos ) ); + pContextEntry->_prefixes.push_back( aDefNamespacePrefix ); + pUids[ nPos ] = _nUnknownNamespaceUid; + pPrefixes[ nPos ] = _sXMLNS; + pLocalNames[ nPos ] = aDefNamespacePrefix; + } + else if ((sal_Unicode)':' == rQAttributeName[ 5 ]) // set prefix + { + OUString aPrefix( rQAttributeName.copy( 6 ) ); + pushPrefix( aPrefix, xAttribs->getValueByIndex( nPos ) ); + pContextEntry->_prefixes.push_back( aPrefix ); + pUids[ nPos ] = _nUnknownNamespaceUid; + pPrefixes[ nPos ] = _sXMLNS; + pLocalNames[ nPos ] = aPrefix; + } + // else just a name starting with xmlns: no prefix + } + } + + // now read out attribute prefixes (all namespace prefixes have been set) + for ( nPos = 0; nPos < nAttribs; ++nPos ) + { + if (pUids[ nPos ] != _nUnknownNamespaceUid) // no namespace attribute + { + OUString const & rQAttributeName = pQNames[ nPos ]; + OSL_ENSURE( rQAttributeName.compareToAscii( "xmlns:", 6 ) != 0, "### unexpected xmlns!" ); + + // collect attribute's uid and current prefix + sal_Int32 nColonPos = rQAttributeName.indexOf( (sal_Unicode)':' ); + if (nColonPos >= 0) + { + pPrefixes[ nPos ] = rQAttributeName.copy( 0, nColonPos ); + pLocalNames[ nPos ] = rQAttributeName.copy( nColonPos +1 ); + } + else + { + pPrefixes[ nPos ] = OUString(); + pLocalNames[ nPos ] = rQAttributeName; + // leave local names unmodified + } + pUids[ nPos ] = getUidByPrefix( pPrefixes[ nPos ] ); + } + } + + getElementName( rQElementName, &nUid, &aLocalName ); + + // create new child context and append to list + if (! _contexts.empty()) + { + xCurrentContext = _contexts.back()->_xContext; + } + } // :guard end + + // wrap for XAttributeList to act like sax2 XExtendedAttributes + // ownership of arrays belongs to attribute list + Reference< xml::sax2::XExtendedAttributes > xAttributes( static_cast< xml::sax2::XExtendedAttributes * >( + new ExtendedAttributes( nAttribs, pUids, pPrefixes, pLocalNames, pQNames, xAttribs, this ) ) ); + + pContextEntry->_xContext = (xCurrentContext.is() + ? xCurrentContext->createChildContext( nUid, aLocalName, xAttributes ) + : _xImporter->createRootContext( nUid, aLocalName, xAttributes ) ); + + { + MGuard aGuard( _pMutex ); + if (pContextEntry->_xContext.is()) + { + _contexts.push_back( pContextEntry ); + } + else + { + ++_nSkipElements; +#ifdef _DEBUG + OString aQName( OUStringToOString( rQElementName, RTL_TEXTENCODING_ASCII_US ) ); + OSL_TRACE( "### no context given on createChildContext() => ignoring element \"%s\" ...", aQName.getStr() ); +#endif + } + } +} +//__________________________________________________________________________________________________ +void DocumentHandlerImpl::endElement( + OUString const & rQElementName ) + throw (xml::sax::SAXException, RuntimeException) +{ + Reference< xml::XImportContext > xCurrentContext; + { + MGuard aGuard( _pMutex ); + if (_nSkipElements) + { + --_nSkipElements; +#ifdef _DEBUG + OString aQName( OUStringToOString( rQElementName, RTL_TEXTENCODING_ASCII_US ) ); + OSL_TRACE( "### received endElement() for \"%s\".", aQName.getStr() ); +#endif + return; + } + + // popping context + OSL_ASSERT( ! _contexts.empty() ); + ContextEntry * pEntry = _contexts.back(); + xCurrentContext = pEntry->_xContext; + +#ifdef _DEBUG + sal_Int32 nUid; + OUString aLocalName; + getElementName( rQElementName, &nUid, &aLocalName ); + OSL_ASSERT( xCurrentContext->getLocalName() == aLocalName ); + OSL_ASSERT( xCurrentContext->getUid() == nUid ); +#endif + + // pop prefixes + for ( sal_Int32 nPos = pEntry->_prefixes.size(); nPos--; ) + { + popPrefix( pEntry->_prefixes[ nPos ] ); + } + _contexts.pop_back(); + delete pEntry; + } + xCurrentContext->endElement(); +} +//__________________________________________________________________________________________________ +void DocumentHandlerImpl::characters( + OUString const & rChars ) + throw (xml::sax::SAXException, RuntimeException) +{ + Reference< xml::XImportContext > xCurrentContext; + { + MGuard aGuard( _pMutex ); + if (! _contexts.empty()) + xCurrentContext = _contexts.back()->_xContext; + } + if (xCurrentContext.is()) + xCurrentContext->characters( rChars ); +} +//__________________________________________________________________________________________________ +void DocumentHandlerImpl::ignorableWhitespace( + OUString const & rWhitespaces ) + throw (xml::sax::SAXException, RuntimeException) +{ + Reference< xml::XImportContext > xCurrentContext; + { + MGuard aGuard( _pMutex ); + if (! _contexts.empty()) + xCurrentContext = _contexts.back()->_xContext; + } + if (xCurrentContext.is()) + xCurrentContext->ignorableWhitespace( rWhitespaces ); +} +//__________________________________________________________________________________________________ +void DocumentHandlerImpl::processingInstruction( + OUString const & rTarget, OUString const & rData ) + throw (xml::sax::SAXException, RuntimeException) +{ + _xImporter->processingInstruction( rTarget, rData ); +} +//__________________________________________________________________________________________________ +void DocumentHandlerImpl::setDocumentLocator( + Reference< xml::sax::XLocator > const & xLocator ) + throw (xml::sax::SAXException, RuntimeException) +{ + _xImporter->setDocumentLocator( xLocator ); +} + + +//################################################################################################## + + +// XAttributes +//__________________________________________________________________________________________________ +sal_Int32 ExtendedAttributes::getIndexByQName( + OUString const & rQName ) + throw (RuntimeException) +{ + for ( sal_Int32 nPos = _nAttributes; nPos--; ) + { + if (_pQNames[ nPos ] == rQName) + { + return nPos; + } + } + return -1; +} +//__________________________________________________________________________________________________ +sal_Int32 ExtendedAttributes::getIndexByName( + OUString const & rURI, OUString const & rLocalName ) + throw (RuntimeException) +{ + sal_Int32 nUid; + { + MGuard aGuard( _pHandler->_pMutex ); + nUid = _pHandler->getUidByURI( rURI ); + } + for ( sal_Int32 nPos = _nAttributes; nPos--; ) + { + if (_pUids[ nPos ] == nUid && _pLocalNames[ nPos ] == rLocalName) + { + return nPos; + } + } + return -1; +} +//__________________________________________________________________________________________________ +sal_Int32 ExtendedAttributes::getLength() + throw (RuntimeException) +{ + return _nAttributes; +} +//__________________________________________________________________________________________________ +OUString ExtendedAttributes::getLocalNameByIndex( + sal_Int32 nIndex ) + throw (RuntimeException) +{ + return _pLocalNames[ nIndex ]; +} +//__________________________________________________________________________________________________ +OUString ExtendedAttributes::getQNameByIndex( + sal_Int32 nIndex ) + throw (RuntimeException) +{ + OSL_ASSERT( nIndex < _nAttributes ); + return _pQNames[ nIndex ]; +} +//__________________________________________________________________________________________________ +OUString ExtendedAttributes::getTypeByIndex( + sal_Int32 nIndex ) + throw (RuntimeException) +{ + OSL_ASSERT( nIndex < _nAttributes ); + // xxx todo what about prefixed types? + return OUString(); +} +//__________________________________________________________________________________________________ +OUString ExtendedAttributes::getTypeByName( + OUString const & rURI, OUString const & rLocalName ) + throw (RuntimeException) +{ + // xxx todo +// sal_Int32 nUid; +// { +// MGuard aGuard( _pHandler->_pMutex ); +// nUid = _pHandler->getUidByURI( rURI ); +// } +// for ( sal_Int32 nPos = _nAttributes; nPos--; ) +// { +// if (_pUids[ nPos ] == nUid && _pLocalNames[ nPos ] == rLocalName) +// { +// return _xAttributeList->getTypeByIndex( (sal_Int16)nPos ); +// } +// } + return OUString(); +} +//__________________________________________________________________________________________________ +OUString ExtendedAttributes::getURIByIndex( + sal_Int32 nIndex ) + throw (RuntimeException) +{ + OSL_ASSERT( nIndex < _nAttributes ); + MGuard aGuard( _pHandler->_pMutex ); + return _pHandler->getURIByUid( _pUids[ nIndex ] ); +} +//__________________________________________________________________________________________________ +OUString ExtendedAttributes::getValueByIndex( + sal_Int32 nIndex ) + throw (RuntimeException) +{ + return _pValues[ nIndex ]; +} +//__________________________________________________________________________________________________ +OUString ExtendedAttributes::getValueByQName( + OUString const & rQName ) + throw (RuntimeException) +{ + for ( sal_Int32 nPos = _nAttributes; nPos--; ) + { + if (_pQNames[ nPos ] == rQName) + { + return _pValues[ nPos ]; + } + } + return OUString(); +} +//__________________________________________________________________________________________________ +OUString ExtendedAttributes::getValueByName( + OUString const & rURI, OUString const & rLocalName ) + throw (RuntimeException) +{ + sal_Int32 nUid; + { + MGuard aGuard( _pHandler->_pMutex ); + nUid = _pHandler->getUidByURI( rURI ); + } + for ( sal_Int32 nPos = _nAttributes; nPos--; ) + { + if (_pUids[ nPos ] == nUid && _pLocalNames[ nPos ] == rLocalName) + { + return _pValues[ nPos ]; + } + } + return OUString(); +} + +// XExtendedAttributes +//__________________________________________________________________________________________________ +sal_Int32 ExtendedAttributes::getIndexByUidName( + sal_Int32 nUid, OUString const & rLocalName ) + throw (RuntimeException) +{ + for ( sal_Int32 nPos = _nAttributes; nPos--; ) + { + if (_pUids[ nPos ] == nUid && _pLocalNames[ nPos ] == rLocalName) + { + return nPos; + } + } + return -1; +} +//__________________________________________________________________________________________________ +OUString ExtendedAttributes::getTypeByUidName( + sal_Int32 nUid, OUString const & rLocalName ) + throw (RuntimeException) +{ + // xxx todo +// for ( sal_Int32 nPos = _nAttributes; nPos--; ) +// { +// if (_pUids[ nPos ] == nUid && _pLocalNames[ nPos ] == rLocalName) +// { +// } +// } + return OUString(); +} +//__________________________________________________________________________________________________ +sal_Int32 ExtendedAttributes::getUidByIndex( + sal_Int32 nIndex ) + throw (RuntimeException) +{ + return _pUids[ nIndex ]; +} +//__________________________________________________________________________________________________ +OUString ExtendedAttributes::getValueByUidName( + sal_Int32 nUid, OUString const & rLocalName ) + throw (RuntimeException) +{ + for ( sal_Int32 nPos = _nAttributes; nPos--; ) + { + if (_pUids[ nPos ] == nUid && _pLocalNames[ nPos ] == rLocalName) + { + return _pValues[ nPos ]; + } + } + return OUString(); +} + + +//################################################################################################## + + +//================================================================================================== +Reference< xml::sax::XDocumentHandler > SAL_CALL createDocumentHandler( + NameSpaceUid const * pNamespaceUids, sal_Int32 nNameSpaceUids, + sal_Int32 nUnknownNamespaceUid, + Reference< xml::XImporter > const & xImporter, + bool bSingleThreadedUse ) + throw () +{ + Reference< xml::sax::XDocumentHandler > xRet; + + OSL_ASSERT( xImporter.is() ); + if (xImporter.is()) + { + DocumentHandlerImpl * pImpl = new DocumentHandlerImpl( + pNamespaceUids, nNameSpaceUids, nUnknownNamespaceUid, + xImporter, bSingleThreadedUse ); + + xRet = static_cast< xml::sax::XDocumentHandler * >( pImpl ); + } + + return xRet; +} + +}; diff --git a/xmlscript/source/xmldlg_imexp/exp_share.hxx b/xmlscript/source/xmldlg_imexp/exp_share.hxx new file mode 100644 index 000000000000..db7245eb6315 --- /dev/null +++ b/xmlscript/source/xmldlg_imexp/exp_share.hxx @@ -0,0 +1,224 @@ +/************************************************************************* + * + * $RCSfile: exp_share.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:48 $ + * + * 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 <hash_map> +#include <vector> + +#include <xmlscript/xmldlg_imexp.hxx> + +#include <osl/diagnose.h> +#include <cppuhelper/implbase1.hxx> + +#include <com/sun/star/xml/sax/XAttributeList.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/awt/FontDescriptor.hpp> + + +using namespace ::rtl; +using namespace ::std; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace xmlscript +{ + +struct Style +{ + sal_uInt32 _backgroundColor; + sal_uInt32 _textColor; + sal_Int16 _border; + awt::FontDescriptor _descr; + short _set; + + OUString _id; + + Style() + : _set( 0 ) + {} + + Reference< xml::sax::XAttributeList > createElement(); +}; +class StyleBag +{ + vector< Style * > _styles; +public: + ~StyleBag(); + + OUString getStyleId( Style const & rStyle ) + throw (); + + void dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut ); +}; + +class ElementDescriptor + : public ::cppu::WeakImplHelper1< xml::sax::XAttributeList > +{ + Reference< beans::XPropertySet > _xProps; + Reference< beans::XPropertyState > _xPropState; + + OUString _name; + vector< OUString > _attrNames; + vector< OUString > _attrValues; + + vector< Reference< xml::sax::XAttributeList > > _subElems; + +public: + inline ElementDescriptor( + Reference< beans::XPropertySet > const & xProps, + Reference< beans::XPropertyState > const & xPropState, + OUString const & name ) + throw () + : _xProps( xProps ) + , _xPropState( xPropState ) + , _name( name ) + {} + inline ElementDescriptor( + OUString const & name ) + throw () + : _name( name ) + {} + + // + void addSubElem( Reference< xml::sax::XAttributeList > const & xElem ); + inline Reference< xml::sax::XAttributeList > getSubElemAt( sal_Int32 nIndex ) + { return _subElems[ nIndex ]; } + void dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut ); + // + Any readProp( OUString const & rPropName ); + // + void readDefaults(); + // + void readStringAttr( OUString const & rPropName, OUString const & rAttrName ); + void readLongAttr( OUString const & rPropName, OUString const & rAttrName ); + void readHexLongAttr( OUString const & rPropName, OUString const & rAttrName ); + void readShortAttr( OUString const & rPropName, OUString const & rAttrName ); + void readBoolAttr( OUString const & rPropName, OUString const & rAttrName ); + // + inline void addAttr( OUString const & rAttrName, OUString const & rValue ); + inline void addBoolAttr( OUString const & rAttrName, sal_Bool bValue ); + + // + void readButtonModel( StyleBag * all_styles ) + throw (Exception); + void readEditModel( StyleBag * all_styles ) + throw (Exception); + void readCheckBoxModel( StyleBag * all_styles ) + throw (Exception); + void readRadioButtonModel( StyleBag * all_styles ) + throw (Exception); + void readComboBoxModel( StyleBag * all_styles ) + throw (Exception); + void readCurrencyFieldModel( StyleBag * all_styles ) + throw (Exception); + void readDateFieldModel( StyleBag * all_styles ) + throw (Exception); + void readFileControlModel( StyleBag * all_styles ) + throw (Exception); + void readFixedTextModel( StyleBag * all_styles ) + throw (Exception); + void readGroupBoxModel( StyleBag * all_styles ) + throw (Exception); + void readImageControlModel( StyleBag * all_styles ) + throw (Exception); + void readListBoxModel( StyleBag * all_styles ) + throw (Exception); + void readNumericFieldModel( StyleBag * all_styles ) + throw (Exception); + void readPatternFieldModel( StyleBag * all_styles ) + throw (Exception); + void readTimeFieldModel( StyleBag * all_styles ) + throw (Exception); + void readContainerModel( StyleBag * all_styles ) + throw (Exception); + + // XAttributeList + virtual sal_Int16 SAL_CALL getLength() + throw (RuntimeException); + virtual OUString SAL_CALL getNameByIndex( sal_Int16 nPos ) + throw (RuntimeException); + virtual OUString SAL_CALL getTypeByIndex( sal_Int16 nPos ) + throw (RuntimeException); + virtual OUString SAL_CALL getTypeByName( OUString const & rName ) + throw (RuntimeException); + virtual OUString SAL_CALL getValueByIndex( sal_Int16 nPos ) + throw (RuntimeException); + virtual OUString SAL_CALL getValueByName( OUString const & rName ) + throw (RuntimeException); +}; +//__________________________________________________________________________________________________ +inline void ElementDescriptor::addAttr( OUString const & rAttrName, OUString const & rValue ) +{ + _attrNames.push_back( rAttrName ); + _attrValues.push_back( rValue ); +} +//__________________________________________________________________________________________________ +inline void ElementDescriptor::addBoolAttr( OUString const & rAttrName, sal_Bool bValue ) +{ + addAttr( rAttrName, + (bValue + ? OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) + : OUString( RTL_CONSTASCII_USTRINGPARAM("false") )) ); +} + +//################################################################################################## + + +}; diff --git a/xmlscript/source/xmldlg_imexp/imp_share.hxx b/xmlscript/source/xmldlg_imexp/imp_share.hxx new file mode 100644 index 000000000000..df6156d417f1 --- /dev/null +++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx @@ -0,0 +1,489 @@ +/************************************************************************* + * + * $RCSfile: imp_share.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:48 $ + * + * 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 <vector> + +#include <xmlscript/xmldlg_imexp.hxx> + +#include <cppuhelper/implbase1.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/FontDescriptor.hpp> + +#include <com/sun/star/xml/sax2/XExtendedAttributes.hpp> +#include <com/sun/star/xml/XImportContext.hpp> +#include <com/sun/star/xml/XImporter.hpp> + + +using namespace ::rtl; +using namespace ::std; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace xmlscript +{ +// +inline sal_Int32 toInt32( OUString const & rStr ) +{ + sal_Int32 nVal; + if (rStr.getLength() > 2 && rStr[ 0 ] == '0' && rStr[ 1 ] == 'x') + { + nVal = rStr.toInt32( 16 ); + } + else + { + nVal = rStr.toInt32(); + } + return nVal; +} +inline bool getBoolAttr( + sal_Bool * pRet, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) +{ + OUString aValue( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) ); + if (aValue.getLength()) + { + if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("true") )) + { + *pRet = sal_True; + return true; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("false") )) + { + *pRet = sal_False; + return true; + } + else + { + throw xml::sax::SAXException( + rAttrName + OUString( RTL_CONSTASCII_USTRINGPARAM(": no boolean value (true|false)!") ), + Reference< XInterface >(), Any() ); + } + } + return false; +} +inline bool getStringAttr( + OUString * pRet, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) +{ + *pRet = xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ); + return (pRet->getLength() > 0); +} +inline bool getLongAttr( + sal_Int32 * pRet, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) +{ + OUString aValue( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) ); + if (aValue.getLength()) + { + *pRet = toInt32( aValue ); + return true; + } + return false; +} +// + +//================================================================================================== +struct DialogImport + : public ::cppu::WeakImplHelper1< xml::XImporter > +{ + vector< OUString > _styleNames; + vector< Reference< xml::XImportContext > > _styles; + +public: + Reference< container::XNameContainer > _xDialogModel; + Reference< lang::XMultiServiceFactory > _xDialogModelFactory; + + void addStyle( + OUString const & rStyleId, + Reference< xml::XImportContext > const & xStyle ) + throw (); + Reference< xml::XImportContext > getStyle( + OUString const & rStyleId ) const + throw (); + + inline DialogImport( + Reference< container::XNameContainer > const & xDialogModel ) + : _xDialogModel( xDialogModel ) + , _xDialogModelFactory( xDialogModel, UNO_QUERY ) + {} + + // XImporter + virtual void SAL_CALL startDocument() + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endDocument() + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL processingInstruction( + OUString const & rTarget, OUString const & rData ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL setDocumentLocator( + Reference< xml::sax::XLocator > const & xLocator ) + throw (xml::sax::SAXException, RuntimeException); + virtual Reference< xml::XImportContext > SAL_CALL createRootContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); +}; + +//================================================================================================== +class ElementBase + : public ::cppu::WeakImplHelper1< xml::XImportContext > +{ +public: + OUString _aLocalName; + Reference< xml::sax2::XExtendedAttributes > _xAttributes; + + ElementBase * _pParent; + DialogImport * _pImport; + + ElementBase( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw (); + virtual ~ElementBase() + throw (); + + // XImportContext + virtual Reference< xml::XImportContext > SAL_CALL getParent() + throw (RuntimeException); + virtual OUString SAL_CALL getLocalName() + throw (RuntimeException); + virtual sal_Int32 SAL_CALL getUid() + throw (RuntimeException); + virtual Reference< xml::sax2::XExtendedAttributes > SAL_CALL getAttributes() + throw (RuntimeException); + virtual void SAL_CALL ignorableWhitespace( + OUString const & rWhitespaces ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL characters( OUString const & rChars ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endElement() + throw (xml::sax::SAXException, RuntimeException); + virtual Reference< xml::XImportContext > SAL_CALL createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); +}; + +//================================================================================================== +class StylesElement + : public ElementBase +{ +public: + virtual Reference< xml::XImportContext > SAL_CALL createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); + + StylesElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : ElementBase( rLocalName, xAttributes, pParent, pImport ) + {} +}; +//================================================================================================== +class StyleElement + : public ElementBase +{ + sal_Int32 _backgroundColor; + sal_Int32 _textColor; + sal_Int16 _border; + awt::FontDescriptor _descr; + + short _inited, _hasValue; + +public: + virtual Reference< xml::XImportContext > SAL_CALL createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endElement() + throw (xml::sax::SAXException, RuntimeException); + + bool importTextColorStyle( + Reference< beans::XPropertySet > const & xProps ); + bool importBackgroundColorStyle( + Reference< beans::XPropertySet > const & xProps ); + bool importFontStyle( + Reference< beans::XPropertySet > const & xProps ); + bool importBorderStyle( + Reference< beans::XPropertySet > const & xProps ); + + StyleElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : ElementBase( rLocalName, xAttributes, pParent, pImport ) + , _inited( 0 ) + , _hasValue( 0 ) + {} +}; +//================================================================================================== +class MenuPopupElement + : public ElementBase +{ + vector< OUString > _itemValues; + vector< sal_Int16 > _itemSelected; +public: + Sequence< OUString > getItemValues(); + Sequence< sal_Int16 > getSelectedItems(); + + virtual Reference< xml::XImportContext > SAL_CALL createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); + + MenuPopupElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : ElementBase( rLocalName, xAttributes, pParent, pImport ) + {} +}; + +//================================================================================================== +class ControlElement + : public ElementBase +{ +protected: + sal_Int32 _nBasePosX, _nBasePosY; + + OUString getControlId(); + Reference< xml::XImportContext > getStyle(); + +public: + + ControlElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw (); +}; +//================================================================================================== +class ControlImportContext +{ + DialogImport * _pImport; + OUString _aId; + + Reference< beans::XPropertySet > _xControlModel; + +public: + inline ControlImportContext( DialogImport * pImport, + OUString const & rId, OUString const & rControlName ) + : _pImport( pImport ) + , _aId( rId ) + , _xControlModel( pImport->_xDialogModelFactory->createInstance( rControlName ), UNO_QUERY ) + { OSL_ASSERT( _xControlModel.is() ); } + inline ~ControlImportContext() + { _pImport->_xDialogModel->insertByName( _aId, makeAny( Reference< awt::XControlModel >::query( _xControlModel ) ) ); } + + inline Reference< beans::XPropertySet > getControlModel() + { return _xControlModel; } + + void importDefaults( + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); + + bool importStringProperty( + OUString const & rPropName, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); + bool importBooleanProperty( + OUString const & rPropName, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); + bool importShortProperty( + OUString const & rPropName, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); + bool importLongProperty( + OUString const & rPropName, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); +}; + +//================================================================================================== +class WindowElement + : public ControlElement +{ +public: + virtual Reference< xml::XImportContext > SAL_CALL createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endElement() + throw (xml::sax::SAXException, RuntimeException); + + WindowElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : ControlElement( rLocalName, xAttributes, pParent, pImport ) + {} +}; +//================================================================================================== +class BulletinBoardElement + : public ControlElement +{ +public: + virtual Reference< xml::XImportContext > SAL_CALL createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endElement() + throw (xml::sax::SAXException, RuntimeException); + + BulletinBoardElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : ControlElement( rLocalName, xAttributes, pParent, pImport ) + {} +}; +//================================================================================================== +class ButtonElement + : public ControlElement +{ +public: + virtual Reference< xml::XImportContext > SAL_CALL createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endElement() + throw (xml::sax::SAXException, RuntimeException); + + ButtonElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : ControlElement( rLocalName, xAttributes, pParent, pImport ) + {} +}; +//================================================================================================== +class CheckBoxElement + : public ControlElement +{ +public: + virtual Reference< xml::XImportContext > SAL_CALL createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endElement() + throw (xml::sax::SAXException, RuntimeException); + + CheckBoxElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : ControlElement( rLocalName, xAttributes, pParent, pImport ) + {} +}; +//================================================================================================== +class ComboBoxElement + : public ControlElement +{ + Reference< xml::XImportContext > _popup; +public: + virtual Reference< xml::XImportContext > SAL_CALL createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endElement() + throw (xml::sax::SAXException, RuntimeException); + + ComboBoxElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : ControlElement( rLocalName, xAttributes, pParent, pImport ) + {} +}; +//================================================================================================== +class MenuListElement + : public ControlElement +{ + Reference< xml::XImportContext > _popup; +public: + virtual Reference< xml::XImportContext > SAL_CALL createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException); + virtual void SAL_CALL endElement() + throw (xml::sax::SAXException, RuntimeException); + + MenuListElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : ControlElement( rLocalName, xAttributes, pParent, pImport ) + {} +}; + +}; diff --git a/xmlscript/source/xmldlg_imexp/makefile.mk b/xmlscript/source/xmldlg_imexp/makefile.mk new file mode 100644 index 000000000000..a161f70db7c6 --- /dev/null +++ b/xmlscript/source/xmldlg_imexp/makefile.mk @@ -0,0 +1,86 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: dbo $ $Date: 2001-02-16 14:14:48 $ +# +# 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=xmlscript +TARGET=xmldlg_imexp +NO_BSYMBOLIC=TRUE +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +#----------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/xmldlg_import.obj \ + $(SLO)$/xmldlg_impmodels.obj \ + $(SLO)$/xmldlg_export.obj \ + $(SLO)$/xmldlg_expmodels.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : $(PRJ)$/util$/target.pmk +.INCLUDE : target.mk diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx new file mode 100644 index 000000000000..f06edf4fc062 --- /dev/null +++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx @@ -0,0 +1,328 @@ +/************************************************************************* + * + * $RCSfile: xmldlg_expmodels.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:48 $ + * + * 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 "exp_share.hxx" + +namespace xmlscript +{ + +//__________________________________________________________________________________________________ +void ElementDescriptor::readButtonModel( StyleBag * all_styles ) + throw (Exception) +{ + // collect styles + Style aStyle; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor ) + aStyle._set |= 0x1; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor ) + aStyle._set |= 0x2; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ) ) >>= aStyle._descr ) + aStyle._set |= 0x8; + if (aStyle._set) + { + addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), + all_styles->getStyleId( aStyle ) ); + } + + // collect elements + readDefaults(); + + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultButton") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":default") ) ); + + readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) ); +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readCheckBoxModel( StyleBag * all_styles ) + throw (Exception) +{ + // collect styles + Style aStyle; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._backgroundColor ) + aStyle._set |= 0x2; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ) ) >>= aStyle._descr ) + aStyle._set |= 0x8; + if (aStyle._set) + { + addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), + all_styles->getStyleId( aStyle ) ); + } + + // collect elements + readDefaults(); + + readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) ); + + sal_Bool bTriState = sal_False; + if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TriState") ) ) >>= bTriState) && bTriState) + { + addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tristate") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) ); + } + sal_Int16 nState; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ) ) >>= nState) + { + switch (nState) + { + case 0: + addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checked") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) ); + break; + case 1: + addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checked") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) ); + break; + default: + OSL_ENSURE( bTriState, "### detected tristate value, but TriState is not set!" ); + } + } +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readComboBoxModel( StyleBag * all_styles ) + throw (Exception) +{ + // collect styles + Style aStyle; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor ) + aStyle._set |= 0x1; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor ) + aStyle._set |= 0x2; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("Border") ) ) >>= aStyle._border ) + aStyle._set |= 0x4; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ) ) >>= aStyle._descr ) + aStyle._set |= 0x8; + if (aStyle._set) + { + addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), + all_styles->getStyleId( aStyle ) ); + } + + // collect elements + readDefaults(); + + readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) ); + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Autocomplete") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":autocomplete") ) ); + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) ); + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Dropdown") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spin-button") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MaxTextLen") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":max-textlen") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linecount") ) ); + + // string item list + Sequence< OUString > itemValues; + if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ) ) >>= itemValues) && + itemValues.getLength() > 0) + { + ElementDescriptor * popup = new ElementDescriptor( + _xProps, _xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menupopup") ) ); + + OUString const * pItemValues = itemValues.getConstArray(); + for ( sal_Int32 nPos = 0; nPos < itemValues.getLength(); ++nPos ) + { + ElementDescriptor * item = new ElementDescriptor( + _xProps, _xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menuitem") ) ); + item->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ), + pItemValues[ nPos ] ); + popup->addSubElem( item ); + } + + addSubElem( popup ); + } +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readListBoxModel( StyleBag * all_styles ) + throw (Exception) +{ + // collect styles + Style aStyle; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor ) + aStyle._set |= 0x1; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor ) + aStyle._set |= 0x2; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("Border") ) ) >>= aStyle._border ) + aStyle._set |= 0x4; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ) ) >>= aStyle._descr ) + aStyle._set |= 0x8; + if (aStyle._set) + { + addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), + all_styles->getStyleId( aStyle ) ); + } + + // collect elements + readDefaults(); + + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiSelection") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multiselection") ) ); + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) ); + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Dropdown") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spin-button") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linecount") ) ); + + // string item list + Sequence< OUString > itemValues; + if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ) ) >>= itemValues) && + itemValues.getLength() > 0) + { + ElementDescriptor * popup = new ElementDescriptor( + _xProps, _xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menupopup") ) ); + + OUString const * pItemValues = itemValues.getConstArray(); + sal_Int32 nPos; + for ( nPos = 0; nPos < itemValues.getLength(); ++nPos ) + { + ElementDescriptor * item = new ElementDescriptor( + _xProps, _xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menuitem") ) ); + item->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ), + pItemValues[ nPos ] ); + popup->addSubElem( item ); + } + + Sequence< sal_Int16 > selected; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ) ) >>= selected) + { + sal_Int16 const * pSelected = selected.getConstArray(); + for ( nPos = selected.getLength(); nPos--; ) + { + ElementDescriptor * item = static_cast< ElementDescriptor * >( + popup->getSubElemAt( pSelected[ nPos ] ).get() ); + item->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":selected") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) ); + } + } + + addSubElem( popup ); + } +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readEditModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readCurrencyFieldModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readDateFieldModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readFileControlModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readFixedTextModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readGroupBoxModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readImageControlModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readNumericFieldModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readPatternFieldModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readTimeFieldModel( StyleBag * all_styles ) + throw (Exception) +{ +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readContainerModel( StyleBag * all_styles ) + throw (Exception) +{ +} + +}; diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx new file mode 100644 index 000000000000..761dff53f2f9 --- /dev/null +++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx @@ -0,0 +1,969 @@ +/************************************************************************* + * + * $RCSfile: xmldlg_export.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:48 $ + * + * 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 "exp_share.hxx" + +#include <rtl/ustrbuf.hxx> + +#include <com/sun/star/awt/CharSet.hpp> +#include <com/sun/star/awt/FontFamily.hpp> +#include <com/sun/star/awt/FontPitch.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/awt/FontStrikeout.hpp> +#include <com/sun/star/awt/FontType.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontWidth.hpp> + +#include <com/sun/star/lang/XServiceInfo.hpp> + + +namespace xmlscript +{ + +//__________________________________________________________________________________________________ +Reference< xml::sax::XAttributeList > Style::createElement() +{ + ElementDescriptor * pStyle = new ElementDescriptor( + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style") ) ); + + // style-id + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), _id ); + + // background-color + if ((_set & 0x1) != 0) + { + OUStringBuffer buf( 16 ); + buf.append( (sal_Unicode)'0' ); + buf.append( (sal_Unicode)'x' ); + buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_backgroundColor, 16 ) ); + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":background-color") ), + buf.makeStringAndClear() ); + } + + // text-color + if ((_set & 0x2) != 0) + { + OUStringBuffer buf( 16 ); + buf.append( (sal_Unicode)'0' ); + buf.append( (sal_Unicode)'x' ); + buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textColor, 16 ) ); + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text-color") ), + buf.makeStringAndClear() ); + } + + // border + if ((_set & 0x4) != 0) + { + switch (_border) + { + case 0: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":border") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("none") ) ); + break; + case 1: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":border") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("3d") ) ); + break; + case 2: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":border") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("simple") ) ); + break; + default: + OSL_ENSURE( 0, "### unexpected border value!" ); + } + } + + // font- + if ((_set & 0x8) != 0) + { + awt::FontDescriptor def_descr; + + // dialog:font-name CDATA #IMPLIED + if (def_descr.Name != _descr.Name) + { + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-name") ), + _descr.Name ); + } + // dialog:font-height %numeric; #IMPLIED + if (def_descr.Height != _descr.Height) + { + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-height") ), + OUString::valueOf( (sal_Int32)_descr.Height ) ); + } + // dialog:font-width %numeric; #IMPLIED + if (def_descr.Width != _descr.Width) + { + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-width") ), + OUString::valueOf( (sal_Int32)_descr.Width ) ); + } + // dialog:font-stylename CDATA #IMPLIED + if (def_descr.StyleName != _descr.StyleName) + { + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-stylename") ), + _descr.StyleName ); + } + // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED + if (def_descr.Family != _descr.Family) + { + switch (_descr.Family) + { + case awt::FontFamily::DECORATIVE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("decorative") ) ); + break; + case awt::FontFamily::MODERN: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("modern") ) ); + break; + case awt::FontFamily::ROMAN: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("roman") ) ); + break; + case awt::FontFamily::SCRIPT: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("script") ) ); + break; + case awt::FontFamily::SWISS: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("swiss") ) ); + break; + case awt::FontFamily::SYSTEM: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("system") ) ); + break; + } + } + // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED + if (def_descr.CharSet != _descr.CharSet) + { + switch (_descr.CharSet) + { + case awt::CharSet::ANSI: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("ansi") ) ); + break; + case awt::CharSet::MAC: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("mac") ) ); + break; + case awt::CharSet::IBMPC_437: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_437") ) ); + break; + case awt::CharSet::IBMPC_850: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_850") ) ); + break; + case awt::CharSet::IBMPC_860: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_860") ) ); + break; + case awt::CharSet::IBMPC_861: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_861") ) ); + break; + case awt::CharSet::IBMPC_863: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_863") ) ); + break; + case awt::CharSet::IBMPC_865: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_865") ) ); + break; + case awt::CharSet::SYSTEM: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("system") ) ); + break; + case awt::CharSet::SYMBOL: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("symbol") ) ); + break; + } + } + // dialog:font-pitch "(fixed|variable)" #IMPLIED + if (def_descr.Pitch != _descr.Pitch) + { + switch (_descr.Pitch) + { + case awt::FontPitch::FIXED: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-pitch") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("fixed") ) ); + break; + case awt::FontPitch::VARIABLE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-pitch") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("variable") ) ); + break; + } + } + // dialog:font-charwidth CDATA #IMPLIED + if (def_descr.CharacterWidth != _descr.CharacterWidth) + { + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charwidth") ), + OUString::valueOf( (float)_descr.CharacterWidth ) ); + } + // dialog:font-weight CDATA #IMPLIED + if (def_descr.Weight != _descr.Weight) + { + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-weight") ), + OUString::valueOf( (float)_descr.Weight ) ); + } + // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED + if (def_descr.Slant != _descr.Slant) + { + switch (_descr.Slant) + { + case awt::FontSlant_OBLIQUE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("oblique") ) ); + break; + case awt::FontSlant_ITALIC: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("italic") ) ); + break; + case awt::FontSlant_REVERSE_OBLIQUE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("reverse_oblique") ) ); + break; + case awt::FontSlant_REVERSE_ITALIC: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("reverse_italic") ) ); + break; + } + } + // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED + if (def_descr.Underline != _descr.Underline) + { + switch (_descr.Underline) + { + case awt::FontUnderline::SINGLE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) ); + break; + case awt::FontUnderline::DOUBLE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) ); + break; + case awt::FontUnderline::DOTTED: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("dotted") ) ); + break; + case awt::FontUnderline::DASH: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("dash") ) ); + break; + case awt::FontUnderline::LONGDASH: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("longdash") ) ); + break; + case awt::FontUnderline::DASHDOT: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("dashdot") ) ); + break; + case awt::FontUnderline::DASHDOTDOT: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("dashdotdot") ) ); + break; + case awt::FontUnderline::SMALLWAVE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("smallwave") ) ); + break; + case awt::FontUnderline::WAVE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("wave") ) ); + break; + case awt::FontUnderline::DOUBLEWAVE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("doublewave") ) ); + break; + case awt::FontUnderline::BOLD: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("bold") ) ); + break; + case awt::FontUnderline::BOLDDOTTED: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("bolddotted") ) ); + break; + case awt::FontUnderline::BOLDDASH: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("bolddash") ) ); + break; + case awt::FontUnderline::BOLDLONGDASH: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("boldlongdash") ) ); + break; + case awt::FontUnderline::BOLDDASHDOT: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("bolddashdot") ) ); + break; + case awt::FontUnderline::BOLDDASHDOTDOT: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("bolddashdotdot") ) ); + break; + case awt::FontUnderline::BOLDWAVE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("boldwave") ) ); + break; + } + } + // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED + if (def_descr.Strikeout != _descr.Strikeout) + { + switch (_descr.Strikeout) + { + case awt::FontStrikeout::SINGLE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) ); + break; + case awt::FontStrikeout::DOUBLE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) ); + break; + case awt::FontStrikeout::BOLD: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("bold") ) ); + break; + case awt::FontStrikeout::SLASH: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("slash") ) ); + break; + case awt::FontStrikeout::X: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) ); + break; + } + } + // dialog:font-orientation CDATA #IMPLIED + if (def_descr.Orientation != _descr.Orientation) + { + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-orientation") ), + OUString::valueOf( (float)_descr.Orientation ) ); + } + // dialog:font-kerning %boolean; #IMPLIED + if ((def_descr.Kerning != sal_False) != (_descr.Kerning != sal_False)) + { + pStyle->addBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-kerning") ), + _descr.Kerning ); + } + // dialog:font-wordlinemode %boolean; #IMPLIED + if ((def_descr.WordLineMode != sal_False) != (_descr.WordLineMode != sal_False)) + { + pStyle->addBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-wordlinemode") ), + _descr.WordLineMode ); + } + // dialog:font-type "(raster|device|scalable)" #IMPLIED + if (def_descr.Type != _descr.Type) + { + switch (_descr.Type) + { + case awt::FontType::RASTER: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("raster") ) ); + break; + case awt::FontType::DEVICE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("device") ) ); + break; + case awt::FontType::SCALABLE: + pStyle->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("scalable") ) ); + break; + } + } + } + + return pStyle; +} + +//################################################################################################## + +// XAttributeList +//__________________________________________________________________________________________________ +sal_Int16 ElementDescriptor::getLength() + throw (RuntimeException) +{ + return _attrNames.size(); +} +//__________________________________________________________________________________________________ +OUString ElementDescriptor::getNameByIndex( sal_Int16 nPos ) + throw (RuntimeException) +{ + OSL_ASSERT( (size_t)nPos < _attrNames.size() ); + return _attrNames[ nPos ]; +} +//__________________________________________________________________________________________________ +OUString ElementDescriptor::getTypeByIndex( sal_Int16 nPos ) + throw (RuntimeException) +{ + OSL_ASSERT( (size_t)nPos < _attrNames.size() ); + // xxx todo + return OUString(); +} +//__________________________________________________________________________________________________ +OUString ElementDescriptor::getTypeByName( OUString const & rName ) + throw (RuntimeException) +{ + // xxx todo + return OUString(); +} +//__________________________________________________________________________________________________ +OUString ElementDescriptor::getValueByIndex( sal_Int16 nPos ) + throw (RuntimeException) +{ + OSL_ASSERT( (size_t)nPos < _attrNames.size() ); + return _attrValues[ nPos ]; +} +//__________________________________________________________________________________________________ +OUString ElementDescriptor::getValueByName( OUString const & rName ) + throw (RuntimeException) +{ + for ( size_t nPos = 0; nPos < _attrNames.size(); ++nPos ) + { + if (_attrNames[ nPos ] == rName) + { + return _attrValues[ nPos ]; + } + } + return OUString(); +} + +// +//__________________________________________________________________________________________________ +Any ElementDescriptor::readProp( OUString const & rPropName ) +{ + if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) + { + return _xProps->getPropertyValue( rPropName ); + } + return Any(); +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readStringAttr( OUString const & rPropName, OUString const & rAttrName ) +{ + if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) + { + Any a( _xProps->getPropertyValue( rPropName ) ); + if (a.getValueTypeClass() == TypeClass_STRING) + { + addAttr( rAttrName, * reinterpret_cast< const OUString * >( a.getValue() ) ); + } + } +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readLongAttr( OUString const & rPropName, OUString const & rAttrName ) +{ + if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) + { + Any a( _xProps->getPropertyValue( rPropName ) ); + if (a.getValueTypeClass() == TypeClass_LONG) + { + addAttr( rAttrName, OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue() ) ); + } + } +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readHexLongAttr( OUString const & rPropName, OUString const & rAttrName ) +{ + if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) + { + Any a( _xProps->getPropertyValue( rPropName ) ); + if (a.getValueTypeClass() == TypeClass_LONG) + { + OUStringBuffer buf( 16 ); + buf.append( (sal_Unicode)'0' ); + buf.append( (sal_Unicode)'x' ); + buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue(), 16 ) ); + addAttr( rAttrName, buf.makeStringAndClear() ); + } + } +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readShortAttr( OUString const & rPropName, OUString const & rAttrName ) +{ + if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) + { + Any a( _xProps->getPropertyValue( rPropName ) ); + if (a.getValueTypeClass() == TypeClass_SHORT) + { + addAttr( rAttrName, OUString::valueOf( (sal_Int32)*(sal_Int16 *)a.getValue() ) ); + } + } +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readBoolAttr( OUString const & rPropName, OUString const & rAttrName ) +{ + if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) + { + Any a( _xProps->getPropertyValue( rPropName ) ); + if (a.getValueTypeClass() == TypeClass_BOOLEAN) + { + addBoolAttr( rAttrName, * reinterpret_cast< const sal_Bool * >( a.getValue() ) ); + } + } +} +//__________________________________________________________________________________________________ +void ElementDescriptor::readDefaults() +{ + sal_Bool bEnabled; + if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ) ) >>= bEnabled) + { + if (! bEnabled) + { + addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":disabled") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) ); + } + } + else + { + OSL_ENSURE( 0, "unexpected property type for \"Enabled\": not bool!" ); + } + + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":printable") ) ); + readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) ); + + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":left") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":top") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":width") ) ); + readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ) ); +} + +//################################################################################################## + +inline bool equals( awt::FontDescriptor const & f1, awt::FontDescriptor const & f2 ) +{ + return (f1.Name == f2.Name && + f1.Height == f2.Height && + f1.Width == f2.Width && + f1.StyleName == f2.StyleName && + f1.Family == f2.Family && + f1.CharSet == f2.CharSet && + f1.Pitch == f2.CharSet && + f1.CharacterWidth == f2.CharacterWidth && + f1.Weight == f2.Weight && + f1.Slant == f2.Slant && + f1.Underline == f2.Underline && + f1.Strikeout == f2.Strikeout && + f1.Orientation == f2.Orientation && + (f1.Kerning != sal_False) == (f2.Kerning != sal_False) && + (f1.WordLineMode != sal_False) == (f2.WordLineMode != sal_False) && + f1.Type == f2.Type); +} +//__________________________________________________________________________________________________ +OUString StyleBag::getStyleId( Style const & rStyle ) + throw () +{ + if (! rStyle._set) // nothin set + { + return OUString(); // everything default: no need to export a specific style + } + + // lookup existing style + for ( size_t nStylesPos = 0; nStylesPos < _styles.size(); ++nStylesPos ) + { + Style * pStyle = _styles[ nStylesPos ]; + + if ((rStyle._set & pStyle->_set & 0x1) != 0 && + rStyle._backgroundColor != pStyle->_backgroundColor) + { + continue; + } + if ((rStyle._set & pStyle->_set & 0x2) != 0 && + rStyle._textColor != pStyle->_textColor) + { + continue; + } + if ((rStyle._set & pStyle->_set & 0x4) != 0 && + rStyle._border != pStyle->_border) + { + continue; + } + if ((rStyle._set & pStyle->_set & 0x8) != 0 && + !equals( rStyle._descr, pStyle->_descr)) + { + continue; + } + + // merge in + if ((rStyle._set & !pStyle->_set & 0x1) != 0) + { + pStyle->_backgroundColor = rStyle._backgroundColor; + } + if ((rStyle._set & !pStyle->_set & 0x2) != 0) + { + pStyle->_textColor = rStyle._textColor; + } + if ((rStyle._set & !pStyle->_set & 0x4) != 0) + { + pStyle->_border = rStyle._border; + } + if ((rStyle._set & !pStyle->_set & 0x8) != 0) + { + pStyle->_descr = rStyle._descr; + } + + return pStyle->_id; + } + + // no appr style found, append new + Style * pStyle = new Style( rStyle ); + pStyle->_id = OUString::valueOf( (sal_Int32)_styles.size() ); + _styles.push_back( pStyle ); + return pStyle->_id; +} +//__________________________________________________________________________________________________ +StyleBag::~StyleBag() +{ + for ( size_t nPos = 0; nPos < _styles.size(); ++nPos ) + { + delete _styles[ nPos ]; + } +} +//__________________________________________________________________________________________________ +void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut ) +{ + if (! _styles.empty()) + { + OUString aStylesName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":styles") ); + xOut->ignorableWhitespace( OUString() ); + xOut->startElement( aStylesName, Reference< xml::sax::XAttributeList >() ); + // export styles + for ( size_t nPos = 0; nPos < _styles.size(); ++nPos ) + { + Reference< xml::sax::XAttributeList > xAttr( _styles[ nPos ]->createElement() ); + static_cast< ElementDescriptor * >( xAttr.get() )->dump( xOut ); + } + xOut->ignorableWhitespace( OUString() ); + xOut->endElement( aStylesName ); + } +} + +//################################################################################################## + +//__________________________________________________________________________________________________ +void ElementDescriptor::addSubElem( Reference< xml::sax::XAttributeList > const & xElem ) +{ + _subElems.push_back( xElem ); +} +//__________________________________________________________________________________________________ +void ElementDescriptor::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut ) +{ + xOut->ignorableWhitespace( OUString() ); + xOut->startElement( _name, static_cast< xml::sax::XAttributeList * >( this ) ); + // write sub elements + for ( size_t nPos = 0; nPos < _subElems.size(); ++nPos ) + { + ElementDescriptor * pElem = static_cast< ElementDescriptor * >( _subElems[ nPos ].get() ); + pElem->dump( xOut ); + } + // + xOut->ignorableWhitespace( OUString() ); + xOut->endElement( _name ); +} + +//================================================================================================== +void exportDialogModel( + Reference< container::XNameContainer > const & xDialogModel, + Reference< xml::sax::XExtendedDocumentHandler > const & xOut ) + throw (Exception) +{ + StyleBag all_styles; + vector< Reference< xml::sax::XAttributeList > > all_elements; + + // read out all props + + Sequence< OUString > aElements( xDialogModel->getElementNames() ); + OUString const * pElements = aElements.getConstArray(); + + sal_Int32 nPos; + for ( nPos = 0; nPos < aElements.getLength(); ++nPos ) + { + OUString const & rName = pElements[ nPos ]; + + Any aControlModel( xDialogModel->getByName( rName ) ); + Reference< beans::XPropertySet > xProps; + OSL_VERIFY( aControlModel >>= xProps ); + if (! xProps.is()) + continue; + Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); + OSL_ASSERT( xPropState.is() ); + if (! xPropState.is()) + continue; + Reference< lang::XServiceInfo > xServiceInfo( xProps, UNO_QUERY ); + OSL_ASSERT( xServiceInfo.is() ); + if (! xServiceInfo.is()) + continue; + Sequence< OUString > aServiceNames( xServiceInfo->getSupportedServiceNames() ); + OSL_ASSERT( aServiceNames.getLength() == 1 ); + if (aServiceNames.getLength() != 1) + continue; + OUString aControlType( aServiceNames[ 0 ] ); + +// OSL_VERIFY( xProps->getPropertyValue( +// OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultControl") ) ) >>= aControlType ); + + ElementDescriptor * pElem; + Reference< xml::sax::XAttributeList > xElem; + + if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlButtonModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readButtonModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checkbox") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readCheckBoxModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":combobox") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readComboBoxModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menulist") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readListBoxModel( &all_styles ); + } + + + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readRadioButtonModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlEditModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readEditModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlCurrencyFieldModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readCurrencyFieldModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlDateFieldModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readDateFieldModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readFileControlModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readFixedTextModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readGroupBoxModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readImageControlModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlNumericFieldModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readNumericFieldModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlPatternFieldModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readPatternFieldModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlTimeFieldModel") )) + { + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readTimeFieldModel( &all_styles ); + } + else if (aControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlContainerModel") )) + { + OSL_ENSURE( 0, "### ???" ); + // what to do ? + pElem = new ElementDescriptor( + xProps, xPropState, + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":") ) ); + xElem = static_cast< xml::sax::XAttributeList * >( pElem ); + pElem->readContainerModel( &all_styles ); + } + else + { + throw Exception( + OUString( RTL_CONSTASCII_USTRINGPARAM("unknown control type: ") ) + aControlType, + Reference< XInterface >() ); + } + + OSL_ASSERT( xElem.is() ); + if (xElem.is()) + { + pElem->addAttr( + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), + rName ); + all_elements.push_back( xElem ); + } + } + + if (! all_elements.empty()) // dump out + { + // window + Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY ); + OSL_ASSERT( xProps.is() ); + Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); + OSL_ASSERT( xPropState.is() ); + + OUString aWindowName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":window") ); + ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName ); + Reference< xml::sax::XAttributeList > xWindow( pWindow ); + pWindow->addAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_DIALOGS_PREFIX) ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_URI) ) ); + pWindow->readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":label") ) ); + pWindow->readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":width") ) ); + pWindow->readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ) ); + xOut->ignorableWhitespace( OUString() ); + xOut->startElement( aWindowName, xWindow ); + + // dump out stylebag + all_styles.dump( xOut ); + + if (! all_elements.empty()) + { + // open up bulletinboard + OUString aBBoardName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") ); + xOut->ignorableWhitespace( OUString() ); + xOut->startElement( aBBoardName, Reference< xml::sax::XAttributeList >() ); + + // export control elements + for ( size_t nPos = 0; nPos < all_elements.size(); ++nPos ) + { + ElementDescriptor * pElem = static_cast< ElementDescriptor * >( all_elements[ nPos ].get() ); + pElem->dump( xOut ); + } + + // end bulletinboard + xOut->ignorableWhitespace( OUString() ); + xOut->endElement( aBBoardName ); + } + + // end window + xOut->ignorableWhitespace( OUString() ); + xOut->endElement( aWindowName ); + } +} + +}; diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx new file mode 100644 index 000000000000..1d9399b1a03b --- /dev/null +++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx @@ -0,0 +1,606 @@ +/************************************************************************* + * + * $RCSfile: xmldlg_impmodels.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:48 $ + * + * 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 "imp_share.hxx" + +#include <com/sun/star/beans/XPropertySet.hpp> + + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace xmlscript +{ + +//################################################################################################## + +// menupopup +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > MenuPopupElement::createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + if (XMLNS_DIALOGS_UID != nUid) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), + Reference< XInterface >(), Any() ); + } + // menuitem + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("menuitem") )) + { + OUString aValue( xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("value") ) ) ); + OSL_ENSURE( aValue.getLength(), "### menuitem has no value?" ); + if (aValue.getLength()) + { + _itemValues.push_back( aValue ); + + OUString aSel( xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("selected") ) ) ); + if (aSel.getLength() && aSel.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("true") )) + { + _itemSelected.push_back( _itemValues.size() -1 ); + } + } + return new ElementBase( rLocalName, xAttributes, this, _pImport ); + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected menuitem!") ), + Reference< XInterface >(), Any() ); + } +} +//__________________________________________________________________________________________________ +Sequence< OUString > MenuPopupElement::getItemValues() +{ + Sequence< OUString > aRet( _itemValues.size() ); + OUString * pRet = aRet.getArray(); + for ( size_t nPos = _itemValues.size(); nPos--; ) + { + pRet[ nPos ] = _itemValues[ nPos ]; + } + return aRet; +} +//__________________________________________________________________________________________________ +Sequence< sal_Int16 > MenuPopupElement::getSelectedItems() +{ + Sequence< sal_Int16 > aRet( _itemSelected.size() ); + sal_Int16 * pRet = aRet.getArray(); + for ( size_t nPos = _itemSelected.size(); nPos--; ) + { + pRet[ nPos ] = _itemSelected[ nPos ]; + } + return aRet; +} + +//################################################################################################## + +// menulist +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > MenuListElement::createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + if (XMLNS_DIALOGS_UID != nUid) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), + Reference< XInterface >(), Any() ); + } + // menupopup + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("menupopup") )) + { + _popup = new MenuPopupElement( rLocalName, xAttributes, this, _pImport ); + return _popup; + } +// // event +// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) +// { +// return new EventElement( rLocalName, xAttributes, this, _pImport ); +// } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ), + Reference< XInterface >(), Any() ); + } +} +//__________________________________________________________________________________________________ +void MenuListElement::endElement() + throw (xml::sax::SAXException, RuntimeException) +{ + ControlImportContext ctx( + _pImport, getControlId(), + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ); + Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); + + Reference< xml::XImportContext > xStyle( getStyle() ); + if (xStyle.is()) + { + StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () ); + pStyle->importBackgroundColorStyle( xControlModel ); + pStyle->importTextColorStyle( xControlModel ); + pStyle->importBorderStyle( xControlModel ); + pStyle->importFontStyle( xControlModel ); + } + + ctx.importDefaults( _xAttributes ); + + ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiSelection") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("multiselection") ), + _xAttributes ); + ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Dropdown") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("spin-button") ), + _xAttributes ); + ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("linecount") ), + _xAttributes ); + + MenuPopupElement * p = static_cast< MenuPopupElement * >( _popup.get() ); + Reference< beans::XPropertySet > xProps( xControlModel ); + xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ), + makeAny( p->getItemValues() ) ); + xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ), + makeAny( p->getSelectedItems() ) ); +} +//################################################################################################## + +// combobox +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > ComboBoxElement::createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + if (XMLNS_DIALOGS_UID != nUid) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), + Reference< XInterface >(), Any() ); + } + // menupopup + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("menupopup") )) + { + _popup = new MenuPopupElement( rLocalName, xAttributes, this, _pImport ); + return _popup; + } +// // event +// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) +// { +// return new EventElement( rLocalName, xAttributes, this, _pImport ); +// } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ), + Reference< XInterface >(), Any() ); + } +} +//__________________________________________________________________________________________________ +void ComboBoxElement::endElement() + throw (xml::sax::SAXException, RuntimeException) +{ + ControlImportContext ctx( + _pImport, getControlId(), + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ); + Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); + + Reference< xml::XImportContext > xStyle( getStyle() ); + if (xStyle.is()) + { + StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () ); + pStyle->importBackgroundColorStyle( xControlModel ); + pStyle->importTextColorStyle( xControlModel ); + pStyle->importBorderStyle( xControlModel ); + pStyle->importFontStyle( xControlModel ); + } + + ctx.importDefaults( _xAttributes ); + + ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ), + _xAttributes ); + ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Autocomplete") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("autocomplete") ), + _xAttributes ); + ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Dropdown") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("spin-button") ), + _xAttributes ); + ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MaxTextLen") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("max-textlen") ), + _xAttributes ); + ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("linecount") ), + _xAttributes ); + + MenuPopupElement * p = static_cast< MenuPopupElement * >( _popup.get() ); + Reference< beans::XPropertySet > xProps( xControlModel ); + xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ), + makeAny( p->getItemValues() ) ); + + ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), + _xAttributes ); +} + +//################################################################################################## + +// checkbox +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > CheckBoxElement::createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + if (XMLNS_DIALOGS_UID != nUid) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), + Reference< XInterface >(), Any() ); + } +// // event +// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) +// { +// return new EventElement( rLocalName, xAttributes, this, _pImport ); +// } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ), + Reference< XInterface >(), Any() ); + } +} +//__________________________________________________________________________________________________ +void CheckBoxElement::endElement() + throw (xml::sax::SAXException, RuntimeException) +{ + ControlImportContext ctx( + _pImport, getControlId(), + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ); + Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); + + Reference< xml::XImportContext > xStyle( getStyle() ); + if (xStyle.is()) + { + StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () ); + pStyle->importTextColorStyle( xControlModel ); + pStyle->importFontStyle( xControlModel ); + } + + ctx.importDefaults( _xAttributes ); + + ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), + _xAttributes ); + + sal_Bool bTriState = sal_False; + if (getBoolAttr( &bTriState, OUString( RTL_CONSTASCII_USTRINGPARAM("tristate") ), _xAttributes )) + { + xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("TriState") ), + makeAny( bTriState ) ); + } + sal_Bool bChecked = sal_False; + if (getBoolAttr( &bChecked, OUString( RTL_CONSTASCII_USTRINGPARAM("checked") ), _xAttributes )) + { + // has "checked" attribute + sal_Int16 nVal = (bChecked ? 1 : 0); + xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ), + makeAny( nVal ) ); + } + else + { + sal_Int16 nVal = (bTriState ? 2 : 0); + xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ), + makeAny( nVal ) ); + } +} + +//################################################################################################## + +// button +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > ButtonElement::createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + if (XMLNS_DIALOGS_UID != nUid) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), + Reference< XInterface >(), Any() ); + } +// // event +// else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) +// { +// return new EventElement( rLocalName, xAttributes, this, _pImport ); +// } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ), + Reference< XInterface >(), Any() ); + } +} +//__________________________________________________________________________________________________ +void ButtonElement::endElement() + throw (xml::sax::SAXException, RuntimeException) +{ + ControlImportContext ctx( + _pImport, getControlId(), + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ); + + Reference< xml::XImportContext > xStyle( getStyle() ); + if (xStyle.is()) + { + StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () ); + Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() ); + pStyle->importBackgroundColorStyle( xControlModel ); + pStyle->importTextColorStyle( xControlModel ); + pStyle->importFontStyle( xControlModel ); + } + + ctx.importDefaults( _xAttributes ); + + ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), + _xAttributes ); + ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultButton") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("default") ), + _xAttributes ); +} + +//################################################################################################## + +// bulletinboard +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > BulletinBoardElement::createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + if (XMLNS_DIALOGS_UID != nUid) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), + Reference< XInterface >(), Any() ); + } + // button + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("button") )) + { + return new ButtonElement( rLocalName, xAttributes, this, _pImport ); + } + // checkbox + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("checkbox") )) + { + return new CheckBoxElement( rLocalName, xAttributes, this, _pImport ); + } + // combobox + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("combobox") )) + { + return new ComboBoxElement( rLocalName, xAttributes, this, _pImport ); + } + // listbox + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("menulist") )) + { + return new MenuListElement( rLocalName, xAttributes, this, _pImport ); + } + + // bulletinboard + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bulletinboard") )) + { + return new BulletinBoardElement( rLocalName, xAttributes, this, _pImport ); + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected styles, bulletinboard or bulletinboard element, not: ") ) + rLocalName, + Reference< XInterface >(), Any() ); + } +} +//__________________________________________________________________________________________________ +void BulletinBoardElement::endElement() + throw (xml::sax::SAXException, RuntimeException) +{ + OUString aValue( _xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("left") ) ) ); + if (aValue.getLength()) + { + _nBasePosX += toInt32( aValue ); + } + aValue = _xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("top") ) ); + if (aValue.getLength()) + { + _nBasePosY += toInt32( aValue ); + } +} + +//################################################################################################## + +// style +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > StyleElement::createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected sub elements of style!") ), + Reference< XInterface >(), Any() ); +} +//__________________________________________________________________________________________________ +void StyleElement::endElement() + throw (xml::sax::SAXException, RuntimeException) +{ + Reference< xml::sax2::XExtendedAttributes > xStyle; + OUString aStyleId( _xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("style-id") ) ) ); + if (aStyleId.getLength()) + { + _pImport->addStyle( aStyleId, this ); + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("missing style-id attribute!") ), + Reference< XInterface >(), Any() ); + } +} + +//################################################################################################## + +// styles +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > StylesElement::createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + if (XMLNS_DIALOGS_UID != nUid) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), + Reference< XInterface >(), Any() ); + } + // style + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("style") )) + { + return new StyleElement( rLocalName, xAttributes, this, _pImport ); + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected style element!") ), + Reference< XInterface >(), Any() ); + } +} + +//################################################################################################## + +// window +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > WindowElement::createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + if (XMLNS_DIALOGS_UID != nUid) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), + Reference< XInterface >(), Any() ); + } + // styles + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("styles") )) + { + return new StylesElement( rLocalName, xAttributes, this, _pImport ); + } + // bulletinboard + else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bulletinboard") )) + { + return new BulletinBoardElement( rLocalName, xAttributes, this, _pImport ); + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("expected styles ot bulletinboard element!") ), + Reference< XInterface >(), Any() ); + } +} +//__________________________________________________________________________________________________ +void WindowElement::endElement() + throw (xml::sax::SAXException, RuntimeException) +{ + Reference< beans::XPropertySet > xProps( _pImport->_xDialogModel, UNO_QUERY ); + OSL_ASSERT( xProps.is() ); + + OUString aValue( _xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("width") ) ) ); + if (aValue.getLength()) + { + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), + makeAny( aValue.toInt32() ) ); + } + aValue = _xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("height") ) ); + if (aValue.getLength()) + { + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), + makeAny( aValue.toInt32() ) ); + } + aValue = _xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("label") ) ); + if (aValue.getLength()) + { + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), + makeAny( aValue ) ); + } +} + +}; diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx new file mode 100644 index 000000000000..1fb0907d3ec8 --- /dev/null +++ b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx @@ -0,0 +1,834 @@ +/************************************************************************* + * + * $RCSfile: xmldlg_import.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:48 $ + * + * 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 "imp_share.hxx" + +#include <osl/diagnose.h> +#include <osl/mutex.hxx> + +#include <rtl/ustrbuf.hxx> + +#include <xmlscript/xml_helper.hxx> + +#include <com/sun/star/awt/CharSet.hpp> +#include <com/sun/star/awt/FontFamily.hpp> +#include <com/sun/star/awt/FontPitch.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/awt/FontStrikeout.hpp> +#include <com/sun/star/awt/FontType.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontWidth.hpp> + + +using namespace ::osl; + +namespace xmlscript +{ + +//__________________________________________________________________________________________________ +ControlElement::ControlElement( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : ElementBase( rLocalName, xAttributes, pParent, pImport ) +{ + if (_pParent) + { + // inherit position + _nBasePosX = static_cast< ControlElement * >( _pParent )->_nBasePosX; + _nBasePosY = static_cast< ControlElement * >( _pParent )->_nBasePosY; + } + else + { + _nBasePosX = 0; + _nBasePosY = 0; + } +} +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > ControlElement::getStyle() +{ + OUString aStyleId( _xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("style-id") ) ) ); + if (aStyleId.getLength()) + { + return _pImport->getStyle( aStyleId ); + } + return Reference< xml::XImportContext >(); +} +//__________________________________________________________________________________________________ +OUString ControlElement::getControlId() +{ + OUString aId( _xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("id") ) ) ); + if (! aId.getLength()) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("missing id element for button!") ), + Reference< XInterface >(), Any() ); + } + return aId; +} + +//################################################################################################## + +//__________________________________________________________________________________________________ +bool StyleElement::importTextColorStyle( + Reference< beans::XPropertySet > const & xProps ) +{ + if ((_inited & 0x1) != 0) + { + if ((_hasValue & 0x1) != 0) + { + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ), makeAny( _textColor ) ); + return true; + } + return false; + } + _inited |= 0x1; + + if (getLongAttr( &_textColor, + OUString( RTL_CONSTASCII_USTRINGPARAM("text-color") ), _xAttributes )) + { + _hasValue |= 0x1; + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ), makeAny( _textColor ) ); + return true; + } + return false; +} +//__________________________________________________________________________________________________ +bool StyleElement::importBackgroundColorStyle( + Reference< beans::XPropertySet > const & xProps ) +{ + if ((_inited & 0x2) != 0) + { + if ((_hasValue & 0x2) != 0) + { + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor ) ); + return true; + } + return false; + } + _inited |= 0x2; + + if (getLongAttr( &_backgroundColor, + OUString( RTL_CONSTASCII_USTRINGPARAM("background-color") ), _xAttributes )) + { + _hasValue |= 0x2; + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor ) ); + return true; + } + return false; +} +//__________________________________________________________________________________________________ +bool StyleElement::importBorderStyle( + Reference< beans::XPropertySet > const & xProps ) +{ + if ((_inited & 0x4) != 0) + { + if ((_hasValue & 0x4) != 0) + { + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("Border") ), makeAny( _border ) ); + return true; + } + return false; + } + _inited |= 0x4; + + OUString aValue; + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("border") ), _xAttributes )) + { + if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") )) + { + _border = 0; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("3d") )) + { + _border = 1; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("simple") )) + { + _border = 2; + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("invalid border value!") ), + Reference< XInterface >(), Any() ); + } + + _hasValue |= 0x4; + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("Border") ), makeAny( _border ) ); + } + return false; +} +//__________________________________________________________________________________________________ +bool StyleElement::importFontStyle( + Reference< beans::XPropertySet > const & xProps ) +{ + if ((_inited & 0x8) != 0) + { + if ((_hasValue & 0x8) != 0) + { + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ), makeAny( _descr ) ); + return true; + } + return false; + } + _inited |= 0x8; + + OUString aValue; + bool bFontImport; + + // dialog:font-name CDATA #IMPLIED + bFontImport = getStringAttr( &_descr.Name, OUString( RTL_CONSTASCII_USTRINGPARAM("font-name") ), _xAttributes ); + + // dialog:font-height %numeric; #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-height") ), _xAttributes )) + { + _descr.Height = (sal_Int16)toInt32( aValue ); + bFontImport = true; + } + // dialog:font-width %numeric; #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-width") ), _xAttributes )) + { + _descr.Width = (sal_Int16)toInt32( aValue ); + bFontImport = true; + } + // dialog:font-stylename CDATA #IMPLIED + bFontImport |= getStringAttr( &_descr.StyleName, OUString( RTL_CONSTASCII_USTRINGPARAM("font-stylename") ), _xAttributes ); + + // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-family") ), _xAttributes )) + { + if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("decorative") )) + { + _descr.Family = awt::FontFamily::DECORATIVE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("modern") )) + { + _descr.Family = awt::FontFamily::MODERN; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("roman") )) + { + _descr.Family = awt::FontFamily::ROMAN; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("script") )) + { + _descr.Family = awt::FontFamily::SCRIPT; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("swiss") )) + { + _descr.Family = awt::FontFamily::SWISS; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system") )) + { + _descr.Family = awt::FontFamily::SYSTEM; + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-family style!") ), + Reference< XInterface >(), Any() ); + } + bFontImport = true; + } + + // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-charset") ), _xAttributes )) + { + if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ansi") )) + { + _descr.CharSet = awt::CharSet::ANSI; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("mac") )) + { + _descr.CharSet = awt::CharSet::MAC; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_437") )) + { + _descr.CharSet = awt::CharSet::IBMPC_437; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_850") )) + { + _descr.CharSet = awt::CharSet::IBMPC_850; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_860") )) + { + _descr.CharSet = awt::CharSet::IBMPC_860; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_861") )) + { + _descr.CharSet = awt::CharSet::IBMPC_861; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_863") )) + { + _descr.CharSet = awt::CharSet::IBMPC_863; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_865") )) + { + _descr.CharSet = awt::CharSet::IBMPC_865; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system") )) + { + _descr.CharSet = awt::CharSet::SYSTEM; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("symbol") )) + { + _descr.CharSet = awt::CharSet::SYMBOL; + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-charset style!") ), + Reference< XInterface >(), Any() ); + } + bFontImport = true; + } + + // dialog:font-pitch "(fixed|variable)" #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-pitch") ), _xAttributes )) + { + if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("fixed") )) + { + _descr.Pitch = awt::FontPitch::FIXED; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("variable") )) + { + _descr.Pitch = awt::FontPitch::VARIABLE; + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-pitch style!") ), + Reference< XInterface >(), Any() ); + } + bFontImport = true; + } + + // dialog:font-charwidth CDATA #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-charwidth") ), _xAttributes )) + { + _descr.CharacterWidth = aValue.toFloat(); + bFontImport = true; + } + // dialog:font-weight CDATA #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-weight") ), _xAttributes )) + { + _descr.Weight = aValue.toFloat(); + bFontImport = true; + } + + // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-slant") ), _xAttributes )) + { + if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("oblique") )) + { + _descr.Slant = awt::FontSlant_OBLIQUE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("italic") )) + { + _descr.Slant = awt::FontSlant_ITALIC; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("reverse_oblique") )) + { + _descr.Slant = awt::FontSlant_REVERSE_OBLIQUE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("reverse_italic") )) + { + _descr.Slant = awt::FontSlant_REVERSE_ITALIC; + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-slant style!") ), + Reference< XInterface >(), Any() ); + } + bFontImport = true; + } + + // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-underline") ), _xAttributes )) + { + if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") )) + { + _descr.Underline = awt::FontUnderline::SINGLE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("double") )) + { + _descr.Underline = awt::FontUnderline::DOUBLE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dotted") )) + { + _descr.Underline = awt::FontUnderline::DOTTED; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dash") )) + { + _descr.Underline = awt::FontUnderline::DASH; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("longdash") )) + { + _descr.Underline = awt::FontUnderline::LONGDASH; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dashdot") )) + { + _descr.Underline = awt::FontUnderline::DASHDOT; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dashdotdot") )) + { + _descr.Underline = awt::FontUnderline::DASHDOTDOT; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("smallwave") )) + { + _descr.Underline = awt::FontUnderline::SMALLWAVE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("wave") )) + { + _descr.Underline = awt::FontUnderline::WAVE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("doublewave") )) + { + _descr.Underline = awt::FontUnderline::DOUBLEWAVE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bold") )) + { + _descr.Underline = awt::FontUnderline::BOLD; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddotted") )) + { + _descr.Underline = awt::FontUnderline::BOLDDOTTED; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddash") )) + { + _descr.Underline = awt::FontUnderline::BOLDDASH; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("boldlongdash") )) + { + _descr.Underline = awt::FontUnderline::BOLDLONGDASH; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddashdot") )) + { + _descr.Underline = awt::FontUnderline::BOLDDASHDOT; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddashdotdot") )) + { + _descr.Underline = awt::FontUnderline::BOLDDASHDOTDOT; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("boldwave") )) + { + _descr.Underline = awt::FontUnderline::BOLDWAVE; + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-underline style!") ), + Reference< XInterface >(), Any() ); + } + bFontImport = true; + } + + // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-strikeout") ), _xAttributes )) + { + if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") )) + { + _descr.Strikeout = awt::FontStrikeout::SINGLE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("double") )) + { + _descr.Strikeout = awt::FontStrikeout::DOUBLE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bold") )) + { + _descr.Strikeout = awt::FontStrikeout::BOLD; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("slash") )) + { + _descr.Strikeout = awt::FontStrikeout::SLASH; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("x") )) + { + _descr.Strikeout = awt::FontStrikeout::X; + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-strikeout style!") ), + Reference< XInterface >(), Any() ); + } + bFontImport = true; + } + + // dialog:font-orientation CDATA #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-orientation") ), _xAttributes )) + { + _descr.Orientation = aValue.toFloat(); + bFontImport = true; + } + // dialog:font-kerning %boolean; #IMPLIED + bFontImport |= getBoolAttr( &_descr.Kerning, OUString( RTL_CONSTASCII_USTRINGPARAM("font-kerning") ), _xAttributes ); + // dialog:font-wordlinemode %boolean; #IMPLIED + bFontImport |= getBoolAttr( &_descr.WordLineMode, OUString( RTL_CONSTASCII_USTRINGPARAM("font-wordlinemode") ), _xAttributes ); + + // dialog:font-type "(raster|device|scalable)" #IMPLIED + if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-type") ), _xAttributes )) + { + if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raster") )) + { + _descr.Type = awt::FontType::RASTER; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("device") )) + { + _descr.Type = awt::FontType::DEVICE; + } + else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("scalable") )) + { + _descr.Type = awt::FontType::SCALABLE; + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-type style!") ), + Reference< XInterface >(), Any() ); + } + bFontImport = true; + } + + if (bFontImport) + { + _hasValue |= 0x8; + xProps->setPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ), makeAny( _descr ) ); + } + + return bFontImport; +} + +//################################################################################################## + +//__________________________________________________________________________________________________ +bool ControlImportContext::importStringProperty( + OUString const & rPropName, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) +{ + OUString aValue( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) ); + if (aValue.getLength()) + { + _xControlModel->setPropertyValue( rPropName, makeAny( aValue ) ); + return true; + } + return false; +} +//__________________________________________________________________________________________________ +bool ControlImportContext::importBooleanProperty( + OUString const & rPropName, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) +{ + sal_Bool bBool; + if (getBoolAttr( &bBool, rAttrName, xAttributes )) + { + _xControlModel->setPropertyValue( rPropName, makeAny( bBool ) ); + return true; + } + return false; +} +//__________________________________________________________________________________________________ +bool ControlImportContext::importLongProperty( + OUString const & rPropName, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) +{ + OUString aValue( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) ); + if (aValue.getLength()) + { + _xControlModel->setPropertyValue( rPropName, makeAny( toInt32( aValue ) ) ); + return true; + } + return false; +} +//__________________________________________________________________________________________________ +bool ControlImportContext::importShortProperty( + OUString const & rPropName, OUString const & rAttrName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) +{ + OUString aValue( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) ); + if (aValue.getLength()) + { + _xControlModel->setPropertyValue( rPropName, makeAny( (sal_Int16)toInt32( aValue ) ) ); + return true; + } + return false; +} +//__________________________________________________________________________________________________ +void ControlImportContext::importDefaults( + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) +{ + if (!importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("left") ), + xAttributes ) || + !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("top") ), + xAttributes ) || + !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("width") ), + xAttributes ) || + !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("height") ), + xAttributes )) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("missing pos size attribute(s)!") ), + Reference< XInterface >(), Any() ); + } + + importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("default") ), + xAttributes ); + importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("printable") ), + xAttributes ); + importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ), + xAttributes ); +} + +//################################################################################################## + +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > ElementBase::getParent() + throw (RuntimeException) +{ + return static_cast< xml::XImportContext * >( _pParent ); +} +//__________________________________________________________________________________________________ +OUString ElementBase::getLocalName() + throw (RuntimeException) +{ + return _aLocalName; +} +//__________________________________________________________________________________________________ +sal_Int32 ElementBase::getUid() + throw (RuntimeException) +{ + return XMLNS_DIALOGS_UID; +} +//__________________________________________________________________________________________________ +Reference< xml::sax2::XExtendedAttributes > ElementBase::getAttributes() + throw (RuntimeException) +{ + return _xAttributes; +} +//__________________________________________________________________________________________________ +void ElementBase::ignorableWhitespace( + OUString const & rWhitespaces ) + throw (xml::sax::SAXException, RuntimeException) +{ + // not used +} +//__________________________________________________________________________________________________ +void ElementBase::characters( OUString const & rChars ) + throw (xml::sax::SAXException, RuntimeException) +{ + // not used, all characters ignored +} +//__________________________________________________________________________________________________ +void ElementBase::endElement() + throw (xml::sax::SAXException, RuntimeException) +{ +} +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > ElementBase::createChildContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected element!") ), + Reference< XInterface >(), Any() ); +} + +//__________________________________________________________________________________________________ +ElementBase::ElementBase( + OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + ElementBase * pParent, DialogImport * pImport ) + throw () + : _aLocalName( rLocalName ) + , _xAttributes( xAttributes ) + , _pParent( pParent ) + , _pImport( pImport ) +{ + _pImport->acquire(); + + if (_pParent) + { + _pParent->acquire(); + } +} +//__________________________________________________________________________________________________ +ElementBase::~ElementBase() + throw () +{ + _pImport->release(); + + if (_pParent) + { + _pParent->release(); + } +} + +//################################################################################################## + +// XImporter +//__________________________________________________________________________________________________ +void DialogImport::startDocument() + throw (xml::sax::SAXException, RuntimeException) +{ + // ignored +} +//__________________________________________________________________________________________________ +void DialogImport::endDocument() + throw (xml::sax::SAXException, RuntimeException) +{ + // ignored +} +//__________________________________________________________________________________________________ +void DialogImport::processingInstruction( + OUString const & rTarget, OUString const & rData ) + throw (xml::sax::SAXException, RuntimeException) +{ + // ignored for now: xxx todo +} +//__________________________________________________________________________________________________ +void DialogImport::setDocumentLocator( + Reference< xml::sax::XLocator > const & xLocator ) + throw (xml::sax::SAXException, RuntimeException) +{ + // ignored for now: xxx todo +} +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > DialogImport::createRootContext( + sal_Int32 nUid, OUString const & rLocalName, + Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + throw (xml::sax::SAXException, RuntimeException) +{ + if (nUid == XMLNS_DIALOGS_UID && + rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("window") )) + { + return new WindowElement( rLocalName, xAttributes, 0, this ); + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("illegal root element given for dialog: ") ) + + rLocalName, Reference< XInterface >(), Any() ); + } +} + +//__________________________________________________________________________________________________ +void DialogImport::addStyle( + OUString const & rStyleId, + Reference< xml::XImportContext > const & xStyle ) + throw () +{ + _styleNames.push_back( rStyleId ); + _styles.push_back( xStyle ); +} +//__________________________________________________________________________________________________ +Reference< xml::XImportContext > DialogImport::getStyle( + OUString const & rStyleId ) const + throw () +{ + for ( size_t nPos = 0; nPos < _styleNames.size(); ++nPos ) + { + if (_styleNames[ nPos ] == rStyleId) + { + return _styles[ nPos ]; + } + } + return 0; +} + +//################################################################################################## + +//================================================================================================== +Reference< xml::sax::XDocumentHandler > importDialogModel( + Reference< container::XNameContainer > const & xDialogModel ) + throw (Exception) +{ + NameSpaceUid arNamespaceUids[] = + { + NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_URI) ), XMLNS_DIALOGS_UID ) + }; + + return ::xmlscript::createDocumentHandler( + arNamespaceUids, sizeof(arNamespaceUids) / sizeof(NameSpaceUid), + -1 /* unknown namespace id */, + static_cast< xml::XImporter * >( new DialogImport( xDialogModel ) ) ); +} + +}; diff --git a/xmlscript/test/imexp.cxx b/xmlscript/test/imexp.cxx new file mode 100644 index 000000000000..3471e8bfed51 --- /dev/null +++ b/xmlscript/test/imexp.cxx @@ -0,0 +1,392 @@ +/************************************************************************* + * + * $RCSfile: imexp.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-02-16 14:14:49 $ + * + * 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 <xmlscript/xmldlg_imexp.hxx> +#include <xmlscript/xml_helper.hxx> + +#include <cppuhelper/servicefactory.hxx> +#include <cppuhelper/implbase2.hxx> + +#include <comphelper/processfactory.hxx> +#include <comphelper/regpathhelper.hxx> + +#include <tools/debug.hxx> +#include <vcl/svapp.hxx> +#include <svtools/unoiface.hxx> // InitExtToolkit + +#include <com/sun/star/io/XActiveDataSource.hpp> + +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <com/sun/star/registry/XSimpleRegistry.hpp> +#include <com/sun/star/registry/XImplementationRegistration.hpp> + +#include <com/sun/star/xml/sax/XParser.hpp> +#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> + +#include <com/sun/star/awt/XToolkit.hpp> +#include <com/sun/star/awt/XControlModel.hpp> + +#include <com/sun/star/container/XNameContainer.hpp> + + +using namespace ::rtl; +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + + + +//----------------------------------------- +// The document handler, which is needed for the saxparser +// The Documenthandler for reading sax +//----------------------------------------- +class ErrorHandler : + public WeakImplHelper2< xml::sax::XEntityResolver , xml::sax::XErrorHandler > +{ +public: + ErrorHandler() + {} + +public: // Error handler + virtual void SAL_CALL error(const Any& aSAXParseException) throw (xml::sax::SAXException, RuntimeException) + { + OSL_ENSURE( 0, "Error !\n" ); + Exception exc; + OSL_VERIFY( aSAXParseException >>= exc ); + throw exc; + } + virtual void SAL_CALL fatalError(const Any& aSAXParseException) throw (xml::sax::SAXException, RuntimeException) + { + OSL_ENSURE( 0, "Fatal Error !\n" ); + Exception exc; + OSL_VERIFY( aSAXParseException >>= exc ); + throw exc; + } + virtual void SAL_CALL warning(const Any& aSAXParseException) throw (xml::sax::SAXException, RuntimeException) + { + OSL_ENSURE( 0, "Warning !\n" ); + Exception exc; + OSL_VERIFY( aSAXParseException >>= exc ); + throw exc; + } + + virtual xml::sax::InputSource SAL_CALL resolveEntity( + const OUString& sPublicId, + const OUString& sSystemId) + throw (xml::sax::SAXException,RuntimeException) + { + OSL_ENSURE( 0, "not impl !\n" ); + return xml::sax::InputSource(); + } +}; + + + +Reference< lang::XMultiServiceFactory > createApplicationServiceManager() +{ + Reference< lang::XMultiServiceFactory > xReturn = createServiceFactory(); + + try + { + + if ( xReturn.is() ) + { + Reference< lang::XInitialization > xInit ( xReturn, UNO_QUERY ) ; + if ( xInit.is() ) + { + OUString localRegistry = ::comphelper::getPathToUserRegistry(); + OUString systemRegistry = ::comphelper::getPathToSystemRegistry(); + + Reference< registry::XSimpleRegistry > xLocalRegistry( + xReturn->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.registry.SimpleRegistry") ) ), UNO_QUERY ); + Reference< registry::XSimpleRegistry > xSystemRegistry( + xReturn->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.SimpleRegistry") ) ), UNO_QUERY ); + if ( xLocalRegistry.is() && (localRegistry.getLength() > 0) ) + { + try + { + xLocalRegistry->open( localRegistry, sal_False, sal_True); + } + catch ( registry::InvalidRegistryException& ) + { + } + + if ( !xLocalRegistry->isValid() ) + xLocalRegistry->open(localRegistry, sal_True, sal_True); + } + + if ( xSystemRegistry.is() && (systemRegistry.getLength() > 0) ) + xSystemRegistry->open( systemRegistry, sal_True, sal_False); + + if ( (xLocalRegistry.is() && xLocalRegistry->isValid()) && + (xSystemRegistry.is() && xSystemRegistry->isValid()) ) + { + Sequence< Any > seqAnys(2); + seqAnys[0] <<= xLocalRegistry ; + seqAnys[1] <<= xSystemRegistry ; + + Reference < registry::XSimpleRegistry > xReg( + xReturn->createInstanceWithArguments( + OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.NestedRegistry")), seqAnys ), UNO_QUERY ); + + seqAnys = Sequence< Any >( 1 ); + seqAnys[0] <<= xReg; + if ( xReg.is() ) + xInit->initialize( seqAnys ); + } + } + else + { + xReturn = Reference< lang::XMultiServiceFactory >(); + } + } + + Reference < registry::XImplementationRegistration > xReg( + xReturn->createInstance( OUString::createFromAscii( "com.sun.star.registry.ImplementationRegistration" ) ), + UNO_QUERY ); + +#ifdef SAL_W32 + OUString aDllName = OUString::createFromAscii( "sax.dll" ); +#else + OUString aDllName = OUString::createFromAscii( "libsax.so" ); +#endif + xReg->registerImplementation( + OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), + aDllName, Reference< registry::XSimpleRegistry > () ); +#ifdef SAL_W32 + aDllName = OUString::createFromAscii( "tk" ); + aDllName += OUString::valueOf( (sal_Int32)SUPD ); + aDllName += OUString::createFromAscii( "mi.dll" ); +#else + aDllName = OUString::createFromAscii( "libtk" ); + aDllName += OUString::valueOf( (sal_Int32)SUPD ); + aDllName += OUString::createFromAscii( ".so" ); +#endif + xReg->registerImplementation( + OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), + aDllName, Reference< registry::XSimpleRegistry > () ); + + } + + catch( Exception& rExc ) + { + OString aStr( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( 0, aStr.getStr() ); + } + + return xReturn ; +} + + +// ----------------------------------------------------------------------- + +Reference< container::XNameContainer > importFile( + char const * fname, + Reference< lang::XMultiServiceFactory > const & xSMgr ) +{ + Reference< xml::sax::XParser > xParser( xSMgr->createInstance( + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ) ), UNO_QUERY ); + if (xParser.is()) + { + ErrorHandler * pHandler = new ErrorHandler(); + xParser->setErrorHandler( (xml::sax::XErrorHandler *)pHandler ); + xParser->setEntityResolver( (xml::sax::XEntityResolver *)pHandler ); + + Reference< container::XNameContainer > xModel( xSMgr->createInstance( + OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel") ) ), UNO_QUERY ); + OSL_ASSERT( xModel.is() ); + xParser->setDocumentHandler( ::xmlscript::importDialogModel( xModel ) ); + + // create the input stream + FILE *f = ::fopen( fname, "rb" ); + if (f) + { + ::fseek( f, 0 ,SEEK_END ); + int nLength = ::ftell( f ); + ::fseek( f, 0, SEEK_SET ); + + ByteSequence seqIn( nLength ); + ::fread( seqIn.getArray(), nLength, 1, f ); + ::fclose( f ); + + xml::sax::InputSource source; + source.aInputStream = ::xmlscript::createInputStream( seqIn ); + source.sSystemId = OUString::createFromAscii( fname ); + + // start parsing + xParser->parseStream( source ); + return xModel; + } + else + { + OSL_ENSURE( 0, "### Cannot read file!\n" ); + } + } + else + { + OSL_ENSURE( 0, "### couln't create sax-parser component\n" ); + } + return Reference< container::XNameContainer >(); +} + +bool exportToFile( + char const * fname, + Reference< container::XNameContainer > const & xModel, + Reference< lang::XMultiServiceFactory > const & xSMgr ) +{ + Reference< xml::sax::XExtendedDocumentHandler > xHandler( + xSMgr->createInstance( + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ) ), UNO_QUERY ); + OSL_ASSERT( xHandler.is() ); + if (! xHandler.is()) + { + OSL_ENSURE( 0, "### couln't create sax-writer component\n" ); + return false; + } + + ByteSequence seq; + Reference< io::XActiveDataSource > xSource( xHandler, UNO_QUERY ); + xSource->setOutputStream( ::xmlscript::createOutputStream( &seq ) ); + + xHandler->startDocument(); + + ::xmlscript::exportDialogModel( + xModel, + Reference< xml::sax::XExtendedDocumentHandler >::query( xHandler ) ); + + xHandler->endDocument(); + + FILE * f = ::fopen( fname, "w" ); + ::fwrite( seq.getConstArray(), 1 ,seq.getLength(), f ); + ::fflush( f ); + ::fclose( f ); + return true; +} + + + +class MyApp : public Application +{ +public: + void Main(); +}; + +MyApp aMyApp; + +// ----------------------------------------------------------------------- + +void MyApp::Main() +{ + if( GetCommandLineParamCount() < 1) + { + OSL_ENSURE( 0, "usage: imexp inputfile [outputfile]\n" ); + return; + } + + Reference< lang::XMultiServiceFactory > xMSF = createApplicationServiceManager(); + + try + { + ::comphelper::setProcessServiceFactory( xMSF ); + InitExtVclToolkit(); + Application::RegisterUnoServices(); + + Reference< awt::XToolkit> xToolkit( xMSF->createInstance( + OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.ExtToolkit" ) ) ), UNO_QUERY ); + + // import dialog + OString aParam1( OUStringToOString( OUString( GetCommandLineParam( 0 ) ), RTL_TEXTENCODING_ASCII_US ) ); + Reference< container::XNameContainer > xImport( importFile( aParam1.getStr(), xMSF ) ); + + if (GetCommandLineParamCount() == 2) + { + // write and read again dialogs + OString aParam2( OUStringToOString( OUString( GetCommandLineParam( 1 ) ), RTL_TEXTENCODING_ASCII_US ) ); + exportToFile( aParam2.getStr(), xImport, xMSF ); + // re-import + xImport = importFile( aParam2.getStr(), xMSF ); + } + + Reference< awt::XControl > xDlg( xMSF->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialog" ) ) ), UNO_QUERY ); + xDlg->setModel( Reference< awt::XControlModel >::query( xImport ) ); + xDlg->createPeer( xToolkit, NULL ); + Reference< awt::XDialog > xD( xDlg, UNO_QUERY ); + xD->execute(); + } + catch (uno::Exception & rExc) + { + OString aStr( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( 0, aStr.getStr() ); + } + + Reference< lang::XComponent > xComp( xMSF, UNO_QUERY ); + if (xComp.is()) + { + xComp->dispose(); + } +} + diff --git a/xmlscript/test/makefile.mk b/xmlscript/test/makefile.mk new file mode 100644 index 000000000000..e43a83507e9e --- /dev/null +++ b/xmlscript/test/makefile.mk @@ -0,0 +1,121 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: dbo $ $Date: 2001-02-16 14:14:49 $ +# +# 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=xmlscript +TARGET=imexp +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE + + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files -------------------------------------------------------- + +CXXFILES= \ + imexp.cxx + +OBJFILES= \ + $(OBJ)$/imexp.obj + +APP1TARGET=$(TARGET) +APP1OBJS=$(OBJFILES) +APP1STDLIBS= \ + $(TOOLSLIB) \ + $(SOTLIB) \ + $(SVTOOLLIB) \ + $(COMPHELPERLIB) \ + $(VCLLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SALLIB) \ + ixmlscript.lib + +APP1DEF= $(MISC)$/imexp.def + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + +# ------------------------------------------------------------------ +# Windows +# ------------------------------------------------------------------ + +.IF "$(GUI)" == "WIN" + +$(MISC)$/imexp.def: makefile.mk + echo NAME imexp >$@ + echo DESCRIPTION 'XML dialogs im-/ exporter' >>$@ + echo EXETYPE WINDOWS >>$@ + echo STUB 'winSTUB.EXE' >>$@ + echo PROTMODE >>$@ + echo CODE PRELOAD MOVEABLE DISCARDABLE >>$@ + echo DATA PRELOAD MOVEABLE MULTIPLE >>$@ + echo HEAPSIZE 8192 >>$@ + echo STACKSIZE 32768 >>$@ + +.ENDIF diff --git a/xmlscript/test/test.xml b/xmlscript/test/test.xml new file mode 100644 index 000000000000..f682936f7fc3 --- /dev/null +++ b/xmlscript/test/test.xml @@ -0,0 +1,35 @@ +<window xmlns="http://openoffice.org/2000/dialog" + xmlns:dlg="http://openoffice.org/2000/dialog" + + label="Test-Dialog" height="400" width="400"> + +<dlg:styles> + <dlg:style style-id="bla" background-color="0xffffff" dlg:text-color="255"/> + <dlg:style style-id="bla2" background-color="0xff00ff" dlg:text-color="255193873"/> + <dlg:style style-id="bla3" background-color="0" dlg:text-color="0xffffff" font-name="Arial" font-height="24"/> +</dlg:styles> + + <dlg:bulletinboard xmlns:ns="http://www.fake"> + <button dlg:id="button1" ns:value="hallo" dlg:left="50" ns:top="50" width="50" height="50" + style-id="bla3" + xmlns:ns="http://openoffice.org/2000/dialog"/> + <button dlg:id="button3" ns:value="hallo2" dlg:left="250" ns:top="50" width="50" height="50" + style-id="bla" + xmlns:ns="http://openoffice.org/2000/dialog"/> + <checkbox id="check1" value="check one" checked="true" left="50" top="150" width="50" height="50"/> + <menulist id="list1" multiselection="true" left="150" top="150" width="50" height="50"> + <menupopup> + <menuitem value="item1"/> + <menuitem value="item2" selected="true"/> + <menuitem value="item3" selected="true"/> + </menupopup> + </menulist> + <combobox id="combo1" value="combotext" left="50" top="250" width="50" height="50" spin-button="true"> + <menupopup> + <menuitem value="Citem1"/> + <menuitem value="Citem2" selected="true"/> + </menupopup> + </combobox> + </dlg:bulletinboard> + +</window> diff --git a/xmlscript/util/makefile.mk b/xmlscript/util/makefile.mk new file mode 100644 index 000000000000..e55fa3d1af4b --- /dev/null +++ b/xmlscript/util/makefile.mk @@ -0,0 +1,106 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: dbo $ $Date: 2001-02-16 14:14: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=xmlscript +TARGET=xmlscript +NO_BSYMBOLIC=TRUE +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +#------------------------------------------------------------------- + +LIB1TARGET= $(SLB)$/$(TARGET)all.lib + +LIB1FILES= \ + $(SLB)$/xml_helper.lib \ + $(SLB)$/xmldlg_imexp.lib + +SHL1TARGET= $(TARGET) + +SHL1LIBS= \ + $(LIB1TARGET) + +SHL1STDLIBS= \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEFLIB1NAME= $(TARGET)all +DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + +$(MISC)$/$(SHL1TARGET).flt : makefile.mk + echo __CT >>$@ diff --git a/xmlscript/util/target.pmk b/xmlscript/util/target.pmk new file mode 100644 index 000000000000..5c6efa925995 --- /dev/null +++ b/xmlscript/util/target.pmk @@ -0,0 +1,70 @@ +#************************************************************************* +# +# $RCSfile: target.pmk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: dbo $ $Date: 2001-02-16 14:14: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 "$(debug)" != "" + +# msvc++: no inlining +.IF "$(COM)" == "MSC" +CFLAGS += /Ob0 +.ENDIF + +.ENDIF + |