2000-12-06 16:32:01 +00:00
/*************************************************************************
*
* $ RCSfile : layerimport . cxx , v $
*
2001-05-28 14:04:18 +00:00
* $ Revision : 1.13 $
2000-12-06 16:32:01 +00:00
*
2001-05-28 14:04:18 +00:00
* last change : $ Author : fs $ $ Date : 2001 - 05 - 28 15 : 04 : 18 $
2000-12-06 16:32:01 +00:00
*
* 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 EXPRESS 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 _XMLOFF_FORMS_LAYERIMPORT_HXX_
# include "layerimport.hxx"
# endif
# ifndef _XMLOFF_FORMENUMS_HXX_
# include "formenums.hxx"
# endif
# ifndef _XMLOFF_FORMS_ELEMENTIMPORT_HXX_
# include "elementimport.hxx"
# endif
2001-03-20 12:39:58 +00:00
# ifndef _XMLOFF_FORMS_OFFICEFORMS_HXX_
# include "officeforms.hxx"
# endif
2000-12-06 16:32:01 +00:00
# ifndef _XMLOFF_FORMS_STRINGS_HXX_
# include "strings.hxx"
# endif
# ifndef _XMLOFF_XMLICTXT_HXX
# include "xmlictxt.hxx"
# endif
2000-12-18 14:14:35 +00:00
# ifndef _XMLOFF_XMLSTYLE_HXX
# include "xmlstyle.hxx"
# endif
# ifndef _XMLOFF_FAMILIES_HXX_
# include "families.hxx"
# endif
# ifndef _XMLOFF_PROPERTYSETMAPPER_HXX
# include "xmlprmap.hxx"
# endif
2001-01-02 14:58:22 +00:00
# ifndef _XMLOFF_XMLIMP_HXX
# include "xmlimp.hxx"
# endif
# ifndef _XMLOFF_EVENTIMPORTHELPER_HXX
# include "XMLEventImportHelper.hxx"
# endif
2000-12-18 14:14:35 +00:00
# ifndef _XMLOFF_XMLIMPPR_HXX
# include "xmlimppr.hxx"
# endif
2001-05-28 13:59:18 +00:00
# ifndef _XMLOFF_XMLNUMFI_HXX
# include "xmlnumfi.hxx"
# endif
# ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
# include <com/sun/star/util/XNumberFormatsSupplier.hpp>
# endif
2000-12-06 16:32:01 +00:00
# ifndef _COM_SUN_STAR_FORM_FORMSUBMITENCODING_HPP_
# include <com/sun/star/form/FormSubmitEncoding.hpp>
# endif
# ifndef _COM_SUN_STAR_FORM_FORMSUBMITMETHOD_HPP_
# include <com/sun/star/form/FormSubmitMethod.hpp>
# endif
# ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
# include <com/sun/star/sdb/CommandType.hpp>
# endif
# ifndef _COM_SUN_STAR_FORM_NAVIGATIONBARMODE_HPP_
# include <com/sun/star/form/NavigationBarMode.hpp>
# endif
# ifndef _COM_SUN_STAR_FORM_TABULATORCYCLE_HPP_
# include <com/sun/star/form/TabulatorCycle.hpp>
# endif
# ifndef _COM_SUN_STAR_FORM_FORMBUTTONTYPE_HPP_
# include <com/sun/star/form/FormButtonType.hpp>
# endif
# ifndef _COM_SUN_STAR_FORM_LISTSOURCETYPE_HPP_
# include <com/sun/star/form/ListSourceType.hpp>
# endif
# ifndef _SV_WINTYPES_HXX
# include <vcl/wintypes.hxx> // for check states
# endif
# ifndef _COMPHELPER_PROCESSFACTORY_HXX_
# include <comphelper/processfactory.hxx>
# endif
# ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_
# include <com/sun/star/form/XFormsSupplier.hpp>
# endif
2001-05-28 13:59:18 +00:00
# ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
# include <com/sun/star/lang/Locale.hpp>
# endif
2000-12-18 14:14:35 +00:00
# ifndef _XMLOFF_FORMS_CONTROLPROPERTYHDL_HXX_
# include "controlpropertyhdl.hxx"
# endif
# ifndef _XMLOFF_FORMS_CONTROLPROPERTYMAP_HXX_
# include "controlpropertymap.hxx"
# endif
2001-01-02 14:58:22 +00:00
# ifndef _XMLOFF_FORMS_FORMEVENTS_HXX_
# include "formevents.hxx"
# endif
2000-12-18 14:14:35 +00:00
SV_IMPL_REF ( SvXMLStylesContext ) ;
2000-12-06 16:32:01 +00:00
//.........................................................................
namespace xmloff
{
//.........................................................................
using namespace : : com : : sun : : star : : uno ;
using namespace : : com : : sun : : star : : lang ;
using namespace : : com : : sun : : star : : beans ;
using namespace : : com : : sun : : star : : container ;
using namespace : : com : : sun : : star : : drawing ;
using namespace : : com : : sun : : star : : xml ;
2001-05-28 13:59:18 +00:00
using namespace : : com : : sun : : star : : util ;
2000-12-06 16:32:01 +00:00
using namespace : : com : : sun : : star : : form ;
using namespace : : com : : sun : : star : : sdb ;
//=====================================================================
//= OFormLayerXMLImport_Impl
//=====================================================================
//---------------------------------------------------------------------
OFormLayerXMLImport_Impl : : OFormLayerXMLImport_Impl ( SvXMLImport & _rImporter )
: m_rImporter ( _rImporter )
2001-05-28 13:59:18 +00:00
, m_pAutoStyles ( NULL )
2000-12-06 16:32:01 +00:00
{
// build the attribute2property map
// string properties which are exported as attributes
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_NAME ) , PROPERTY_NAME ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_IMAGE_DATA ) , PROPERTY_IMAGEURL ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_LABEL ) , PROPERTY_LABEL ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_TARGET_LOCATION ) , PROPERTY_TARGETURL ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_TITLE ) , PROPERTY_TITLE ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_TARGET_FRAME ) , PROPERTY_TARGETFRAME , " _blank " ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getDatabaseAttributeName ( DA_DATA_FIELD ) , PROPERTY_DATAFIELD ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faCommand ) , PROPERTY_COMMAND ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faDatasource ) , PROPERTY_DATASOURCENAME ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faFilter ) , PROPERTY_FILTER ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addStringProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faOrder ) , PROPERTY_ORDER ) ;
// properties not added because they're already present in another form
OSL_ENSURE (
0 = = : : rtl : : OUString : : createFromAscii ( OAttributeMetaData : : getCommonControlAttributeName ( CCA_TARGET_LOCATION ) ) . compareToAscii (
OAttributeMetaData : : getFormAttributeName ( faAction ) ) ,
" OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl: invalid attribute names (1)! " ) ;
// if this fails, we would have to add a translation from faAction->PROPERTY_TARGETURL
// We did not because we already have one CCA_TARGET_LOCATION->PROPERTY_TARGETURL,
// and CCA_TARGET_LOCATION and faAction should be represented by the same attribute
OSL_ENSURE (
0 = = : : rtl : : OUString : : createFromAscii ( OAttributeMetaData : : getCommonControlAttributeName ( CCA_NAME ) ) . compareToAscii (
OAttributeMetaData : : getFormAttributeName ( faName ) ) ,
" OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl: invalid attribute names (2)! " ) ;
// the same for faName, CCA_NAME and PROPERTY_NAME
// boolean properties which are exported as attributes
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_CURRENT_SELECTED ) , PROPERTY_STATE , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_DISABLED ) , PROPERTY_ENABLED , sal_False , sal_True ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_DROPDOWN ) , PROPERTY_DROPDOWN , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_PRINTABLE ) , PROPERTY_PRINTABLE , sal_True ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_READONLY ) , PROPERTY_READONLY , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_SELECTED ) , PROPERTY_DEFAULT_STATE , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_TAB_STOP ) , PROPERTY_TABSTOP , sal_True ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getDatabaseAttributeName ( DA_CONVERT_EMPTY ) , PROPERTY_EMPTY_IS_NULL , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getSpecialAttributeName ( SCA_VALIDATION ) , PROPERTY_STRICTFORMAT , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getSpecialAttributeName ( SCA_MULTI_LINE ) , PROPERTY_MULTILINE , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getSpecialAttributeName ( SCA_AUTOMATIC_COMPLETION ) , PROPERTY_AUTOCOMPLETE , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getSpecialAttributeName ( SCA_MULTIPLE ) , PROPERTY_MULTISELECTION , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getSpecialAttributeName ( SCA_DEFAULT_BUTTON ) , PROPERTY_DEFAULTBUTTON , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getSpecialAttributeName ( SCA_IS_TRISTATE ) , PROPERTY_TRISTATE , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faAllowDeletes ) , PROPERTY_ALLOWDELETES , sal_True ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faAllowInserts ) , PROPERTY_ALLOWINSERTS , sal_True ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faAllowUpdates ) , PROPERTY_ALLOWUPDATES , sal_True ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faApplyFilter ) , PROPERTY_APPLYFILTER , sal_False ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faEscapeProcessing ) , PROPERTY_ESCAPEPROCESSING , sal_True ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addBooleanProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faIgnoreResult ) , PROPERTY_IGNORERESULT , sal_False ) ;
// the int16 attributes
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addInt16Property (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_MAX_LENGTH ) , PROPERTY_MAXTEXTLENGTH , 0 ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addInt16Property (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_SIZE ) , PROPERTY_LINECOUNT , 5 ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addInt16Property (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_TAB_INDEX ) , PROPERTY_TABINDEX , 0 ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addInt16Property (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getDatabaseAttributeName ( DA_BOUND_COLUMN ) , PROPERTY_BOUNDCOLUMN , 0 ) ;
// the enum attributes
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addEnumProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getCommonControlAttributeName ( CCA_BUTTON_TYPE ) , PROPERTY_BUTTONTYPE ,
FormButtonType_PUSH , OEnumMapper : : getEnumMap ( OEnumMapper : : epButtonType ) ,
& : : getCppuType ( static_cast < FormButtonType * > ( NULL ) ) ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addEnumProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getDatabaseAttributeName ( DA_LIST_SOURCE_TYPE ) , PROPERTY_LISTSOURCETYPE ,
ListSourceType_VALUELIST , OEnumMapper : : getEnumMap ( OEnumMapper : : epListSourceType ) ,
& : : getCppuType ( static_cast < ListSourceType * > ( NULL ) ) ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addEnumProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getSpecialAttributeName ( SCA_STATE ) , PROPERTY_DEFAULT_STATE , STATE_NOCHECK ,
2001-02-28 15:42:16 +00:00
OEnumMapper : : getEnumMap ( OEnumMapper : : epCheckState ) ,
& : : getCppuType ( static_cast < sal_Int16 * > ( NULL ) ) ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addEnumProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getSpecialAttributeName ( SCA_CURRENT_STATE ) , PROPERTY_STATE , STATE_NOCHECK ,
2001-02-28 15:42:16 +00:00
OEnumMapper : : getEnumMap ( OEnumMapper : : epCheckState ) ,
& : : getCppuType ( static_cast < sal_Int16 * > ( NULL ) ) ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addEnumProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faEnctype ) , PROPERTY_SUBMIT_ENCODING ,
FormSubmitEncoding_URL , OEnumMapper : : getEnumMap ( OEnumMapper : : epSubmitEncoding ) ,
& : : getCppuType ( static_cast < FormSubmitEncoding * > ( NULL ) ) ) ;
2001-03-20 07:05:15 +00:00
# if SUPD<628
// for compatibility:
m_aAttributeMetaData . addEnumProperty (
" enc-type " , PROPERTY_SUBMIT_ENCODING ,
FormSubmitEncoding_URL , OEnumMapper : : getEnumMap ( OEnumMapper : : epSubmitEncoding ) ,
& : : getCppuType ( static_cast < FormSubmitEncoding * > ( NULL ) ) ) ;
# endif
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addEnumProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faMethod ) , PROPERTY_SUBMIT_METHOD ,
FormSubmitMethod_GET , OEnumMapper : : getEnumMap ( OEnumMapper : : epSubmitMethod ) ,
& : : getCppuType ( static_cast < FormSubmitMethod * > ( NULL ) ) ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addEnumProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faCommandType ) , PROPERTY_COMMAND_TYPE ,
CommandType : : COMMAND , OEnumMapper : : getEnumMap ( OEnumMapper : : epCommandType ) ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addEnumProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faNavigationMode ) , PROPERTY_NAVIGATION ,
NavigationBarMode_NONE , OEnumMapper : : getEnumMap ( OEnumMapper : : epNavigationType ) ,
& : : getCppuType ( static_cast < NavigationBarMode * > ( NULL ) ) ) ;
2000-12-12 11:01:05 +00:00
m_aAttributeMetaData . addEnumProperty (
2000-12-06 16:32:01 +00:00
OAttributeMetaData : : getFormAttributeName ( faTabbingCycle ) , PROPERTY_CYCLE ,
TabulatorCycle_RECORDS , OEnumMapper : : getEnumMap ( OEnumMapper : : epTabCyle ) ,
& : : getCppuType ( static_cast < TabulatorCycle * > ( NULL ) ) ) ;
2000-12-13 09:40:15 +00:00
2001-01-02 14:58:22 +00:00
// initialize our style map
2001-05-28 13:59:18 +00:00
m_xPropertyHandlerFactory = new OControlPropertyHandlerFactory ( ) ;
2000-12-18 14:14:35 +00:00
: : vos : : ORef < XMLPropertySetMapper > xStylePropertiesMapper = new XMLPropertySetMapper ( aControlStyleProperties , m_xPropertyHandlerFactory . getBodyPtr ( ) ) ;
m_xImportMapper = new SvXMLImportPropertyMapper ( xStylePropertiesMapper . getBodyPtr ( ) ) ;
// 'initialize'
2000-12-13 09:40:15 +00:00
m_aCurrentPageIds = m_aControlIds . end ( ) ;
2000-12-06 16:32:01 +00:00
}
//---------------------------------------------------------------------
OFormLayerXMLImport_Impl : : ~ OFormLayerXMLImport_Impl ( )
{
// outlined to allow forward declaration of OAttribute2Property in the header
2001-05-28 13:59:18 +00:00
if ( m_pAutoStyles )
m_pAutoStyles - > ReleaseRef ( ) ;
}
//---------------------------------------------------------------------
void OFormLayerXMLImport_Impl : : setAutoStyleContext ( SvXMLStylesContext * _pNewContext )
{
OSL_ENSURE ( ! m_pAutoStyles , " OFormLayerXMLImport_Impl::setAutoStyleContext: not to be called twice! " ) ;
m_pAutoStyles = _pNewContext ;
if ( m_pAutoStyles )
m_pAutoStyles - > AddRef ( ) ;
}
//---------------------------------------------------------------------
void OFormLayerXMLImport_Impl : : applyControlNumberStyle ( const Reference < XPropertySet > & _rxControlModel , const : : rtl : : OUString & _rControlNumerStyleName )
{
OSL_ENSURE ( _rxControlModel . is ( ) & & ( 0 ! = _rControlNumerStyleName . getLength ( ) ) ,
" OFormLayerXMLImport_Impl::applyControlNumberStyle: invalid arguments (this will crash)! " ) ;
OSL_ENSURE ( m_pAutoStyles , " OFormLayerXMLImport_Impl::applyControlNumberStyle: have no auto style context! " ) ;
if ( ! m_pAutoStyles )
{
m_pAutoStyles = m_rImporter . GetShapeImport ( ) - > GetAutoStylesContext ( ) ;
if ( m_pAutoStyles )
m_pAutoStyles - > AddRef ( ) ;
}
if ( m_pAutoStyles )
{
const SvXMLStyleContext * pStyle = m_pAutoStyles - > FindStyleChildContext ( XML_STYLE_FAMILY_DATA_STYLE , _rControlNumerStyleName ) ;
if ( pStyle )
{
const SvXMLNumFormatContext * pDataStyle = static_cast < const SvXMLNumFormatContext * > ( pStyle ) ;
: : rtl : : OUString sFormatDescription ;
Locale aFormatLocale ;
const_cast < SvXMLNumFormatContext * > ( pDataStyle ) - > GetFormat ( sFormatDescription , aFormatLocale ) ;
// set this format at the control model
try
{
// the models number format supplier and formats
Reference < XNumberFormatsSupplier > xFormatsSupplier ;
_rxControlModel - > getPropertyValue ( PROPERTY_FORMATSSUPPLIER ) > > = xFormatsSupplier ;
Reference < XNumberFormats > xFormats ;
if ( xFormatsSupplier . is ( ) )
xFormats = xFormatsSupplier - > getNumberFormats ( ) ;
OSL_ENSURE ( xFormats . is ( ) , " OFormLayerXMLImport_Impl::applyControlNumberStyle: could not obtain the controls number formats! " ) ;
// obtain a key
if ( xFormats . is ( ) )
{
sal_Int32 nFormatKey = xFormats - > queryKey ( sFormatDescription , aFormatLocale , sal_False ) ;
if ( - 1 = = nFormatKey )
{ // not yet available -> add it
nFormatKey = xFormats - > addNew ( sFormatDescription , aFormatLocale ) ;
}
OSL_ENSURE ( - 1 ! = nFormatKey , " OFormLayerXMLImport_Impl::applyControlNumberStyle: could not obtain a format key! " ) ;
// set the format on the control model
_rxControlModel - > setPropertyValue ( PROPERTY_FORMATKEY , makeAny ( nFormatKey ) ) ;
}
}
catch ( const Exception & )
{
OSL_ENSURE ( sal_False , " OFormLayerXMLImport_Impl::applyControlNumberStyle: couldn't set the format! " ) ;
}
}
else
OSL_ENSURE ( sal_False , " OFormLayerXMLImport_Impl::applyControlNumberStyle: did not find the style with the given name! " ) ;
}
2000-12-06 16:32:01 +00:00
}
//---------------------------------------------------------------------
2000-12-12 11:01:05 +00:00
IControlIdMap & OFormLayerXMLImport_Impl : : getControlIdMap ( )
{
return * this ;
}
//---------------------------------------------------------------------
OAttribute2Property & OFormLayerXMLImport_Impl : : getAttributeMap ( )
{
return m_aAttributeMetaData ;
}
//---------------------------------------------------------------------
Reference < XMultiServiceFactory > OFormLayerXMLImport_Impl : : getServiceFactory ( )
{
return : : comphelper : : getProcessServiceFactory ( ) ;
}
//---------------------------------------------------------------------
SvXMLImport & OFormLayerXMLImport_Impl : : getGlobalContext ( )
{
return m_rImporter ;
}
2001-01-24 08:34:40 +00:00
//---------------------------------------------------------------------
void OFormLayerXMLImport_Impl : : enterEventContext ( )
{
// install our own translation table. We need to disable the other tables because of name conflicts.
m_rImporter . GetEventImport ( ) . PushTranslationTable ( ) ;
m_rImporter . GetEventImport ( ) . AddTranslationTable ( g_pFormsEventTranslation ) ;
}
//---------------------------------------------------------------------
void OFormLayerXMLImport_Impl : : leaveEventContext ( )
{
// install the original event tables.
m_rImporter . GetEventImport ( ) . PopTranslationTable ( ) ;
}
2000-12-12 11:01:05 +00:00
//---------------------------------------------------------------------
void OFormLayerXMLImport_Impl : : registerControlId ( const Reference < XPropertySet > & _rxControl , const : : rtl : : OUString & _rId )
{
2000-12-13 09:40:15 +00:00
OSL_ENSURE ( m_aCurrentPageIds ! = m_aControlIds . end ( ) , " OFormLayerXMLImport_Impl::registerControlId: no current page! " ) ;
2000-12-12 11:01:05 +00:00
OSL_ENSURE ( _rId . getLength ( ) , " OFormLayerXMLImport_Impl::registerControlId: invalid (empty) control id! " ) ;
2000-12-13 09:40:15 +00:00
OSL_ENSURE ( m_aCurrentPageIds - > second . end ( ) = = m_aCurrentPageIds - > second . find ( _rId ) , " OFormLayerXMLImport_Impl::registerControlId: control id already used! " ) ;
m_aCurrentPageIds - > second [ _rId ] = _rxControl ;
2000-12-12 11:01:05 +00:00
}
//---------------------------------------------------------------------
void OFormLayerXMLImport_Impl : : registerControlReferences ( const Reference < XPropertySet > & _rxControl , const : : rtl : : OUString & _rReferringControls )
{
OSL_ENSURE ( _rReferringControls . getLength ( ) , " OFormLayerXMLImport_Impl::registerControlReferences: invalid (empty) control id list! " ) ;
OSL_ENSURE ( _rxControl . is ( ) , " OFormLayerXMLImport_Impl::registerControlReferences: invalid (NULL) control! " ) ;
m_aControlReferences . push_back ( ControlReference ( _rxControl , _rReferringControls ) ) ;
}
2000-12-18 14:14:35 +00:00
//---------------------------------------------------------------------
2001-02-01 08:46:47 +00:00
: : vos : : ORef < SvXMLImportPropertyMapper > OFormLayerXMLImport_Impl : : getStylePropertyMapper ( ) const
2000-12-18 14:14:35 +00:00
{
2001-02-01 08:46:47 +00:00
return m_xImportMapper ;
2000-12-18 14:14:35 +00:00
}
2000-12-12 11:01:05 +00:00
//---------------------------------------------------------------------
void OFormLayerXMLImport_Impl : : startPage ( const Reference < XDrawPage > & _rxDrawPage )
2000-12-06 16:32:01 +00:00
{
m_xForms . clear ( ) ;
2000-12-12 11:01:05 +00:00
OSL_ENSURE ( _rxDrawPage . is ( ) , " OFormLayerXMLImport_Impl::startPage: NULL page! " ) ;
2000-12-06 16:32:01 +00:00
Reference < XFormsSupplier > xFormsSupp ( _rxDrawPage , UNO_QUERY ) ;
2000-12-12 11:01:05 +00:00
OSL_ENSURE ( xFormsSupp . is ( ) , " OFormLayerXMLImport_Impl::startPage: invalid draw page (no XFormsSupplier)! " ) ;
2000-12-06 16:32:01 +00:00
if ( ! xFormsSupp . is ( ) )
return ;
m_xForms = Reference < XNameContainer > ( xFormsSupp - > getForms ( ) , UNO_QUERY ) ;
2000-12-12 11:01:05 +00:00
OSL_ENSURE ( m_xForms . is ( ) , " OFormLayerXMLImport_Impl::startPage: invalid forms collection! " ) ;
2000-12-13 09:40:15 +00:00
// add a new entry to our page map
: : std : : pair < MapDrawPage2MapIterator , bool > aPagePosition =
m_aControlIds . insert ( MapDrawPage2Map : : value_type ( _rxDrawPage , MapString2PropertySet ( ) ) ) ;
OSL_ENSURE ( aPagePosition . second , " OFormLayerXMLImport_Impl::startPage: already imported this page! " ) ;
m_aCurrentPageIds = aPagePosition . first ;
2000-12-12 11:01:05 +00:00
}
//---------------------------------------------------------------------
void OFormLayerXMLImport_Impl : : endPage ( )
{
OSL_ENSURE ( m_xForms . is ( ) , " OFormLayerXMLImport_Impl::endPage: sure you called startPage before? " ) ;
// do some knittings for the controls which are referring to each other
try
{
static const sal_Unicode s_nSeparator = ' , ' ;
: : rtl : : OUString sReferring ;
: : rtl : : OUString sCurrentReferring ;
: : rtl : : OUString sSeparator ( & s_nSeparator , 1 ) ;
Reference < XPropertySet > xCurrentReferring ;
sal_Int32 nSeparator , nPrevSep ;
for ( ConstControlReferenceArrayIterator aReferences = m_aControlReferences . begin ( ) ;
aReferences ! = m_aControlReferences . end ( ) ;
+ + aReferences
)
{
// the list of control ids is comma separated
// in a list of n ids there are only n-1 separators ... have to catch this last id
// -> normalize the list
sReferring = aReferences - > sReferringControls ;
sReferring + = sSeparator ;
nPrevSep = - 1 ;
while ( - 1 ! = ( nSeparator = sReferring . indexOf ( s_nSeparator , nPrevSep + 1 ) ) )
{
sCurrentReferring = sReferring . copy ( nPrevSep + 1 , nSeparator - nPrevSep - 1 ) ;
xCurrentReferring = lookupControlId ( sCurrentReferring ) ;
if ( xCurrentReferring . is ( ) )
// if this condition fails, this is an error, but lookupControlId should have asserted this ...
xCurrentReferring - > setPropertyValue ( PROPERTY_CONTROLLABEL , makeAny ( aReferences - > xReferredControl ) ) ;
nPrevSep = nSeparator ;
}
}
}
catch ( Exception & )
{
OSL_ENSURE ( sal_False , " OFormLayerXMLImport_Impl::endPage: unable to knit the control references (caught an exception)! " ) ;
}
2001-01-02 14:58:22 +00:00
// now that we have all children of the forms collection, attach the events
Reference < XIndexAccess > xIndexContainer ( m_xForms , UNO_QUERY ) ;
if ( xIndexContainer . is ( ) )
ODefaultEventAttacherManager : : setEvents ( xIndexContainer ) ;
2000-12-13 09:40:15 +00:00
// clear the structures for the control references.
2000-12-12 11:01:05 +00:00
m_aControlReferences . clear ( ) ;
2000-12-13 09:40:15 +00:00
// and no we have no current page anymore
m_aCurrentPageIds = m_aControlIds . end ( ) ;
2000-12-12 11:01:05 +00:00
}
//---------------------------------------------------------------------
Reference < XPropertySet > OFormLayerXMLImport_Impl : : lookupControlId ( const : : rtl : : OUString & _rControlId )
{
2000-12-13 09:40:15 +00:00
OSL_ENSURE ( m_aCurrentPageIds ! = m_aControlIds . end ( ) , " OFormLayerXMLImport_Impl::lookupControlId: no current page! " ) ;
Reference < XPropertySet > xReturn ;
if ( m_aCurrentPageIds ! = m_aControlIds . end ( ) )
{
ConstMapString2PropertySetIterator aPos = m_aCurrentPageIds - > second . find ( _rControlId ) ;
if ( m_aCurrentPageIds - > second . end ( ) ! = aPos )
xReturn = aPos - > second ;
else
OSL_ENSURE ( sal_False , " OFormLayerXMLImport_Impl::lookupControlId: invalid control id (did not find it)! " ) ;
}
return xReturn ;
2000-12-06 16:32:01 +00:00
}
2001-03-20 12:39:58 +00:00
//---------------------------------------------------------------------
SvXMLImportContext * OFormLayerXMLImport_Impl : : createOfficeFormsContext (
SvXMLImport & _rImport ,
sal_uInt16 _nPrefix ,
const rtl : : OUString & _rLocalName )
{
return new OFormsRootImport ( _rImport , _nPrefix , _rLocalName ) ;
}
2000-12-06 16:32:01 +00:00
//---------------------------------------------------------------------
SvXMLImportContext * OFormLayerXMLImport_Impl : : createContext ( const sal_uInt16 _nPrefix , const rtl : : OUString & _rLocalName ,
const Reference < sax : : XAttributeList > & _rxAttribs )
{
2000-12-12 11:01:05 +00:00
OSL_ENSURE ( m_xForms . is ( ) , " OFormLayerXMLImport_Impl::createContext: have no forms collection (did you use startPage?)! " ) ;
2000-12-06 16:32:01 +00:00
OSL_ENSURE ( 0 = = _rLocalName . compareToAscii ( " form " ) , " OFormLayerXMLImport_Impl::createContext: don't know the element name (must be \" form \" )! " ) ;
if ( ! m_xForms . is ( ) | | ( 0 ! = _rLocalName . compareToAscii ( " form " ) ) )
{
return new SvXMLImportContext ( m_rImporter , _nPrefix , _rLocalName ) ;
}
2001-01-02 14:58:22 +00:00
return new OFormImport ( * this , * this , _nPrefix , _rLocalName , m_xForms ) ;
2000-12-06 16:32:01 +00:00
}
2000-12-13 09:40:15 +00:00
//---------------------------------------------------------------------
void OFormLayerXMLImport_Impl : : seekPage ( const Reference < XDrawPage > & _rxDrawPage )
{
OSL_ENSURE ( m_aCurrentPageIds = = m_aControlIds . end ( ) , " OFormLayerXMLImport_Impl::seekPage: importing another page currently! This will smash your import! " ) ;
m_aCurrentPageIds = m_aControlIds . find ( _rxDrawPage ) ;
OSL_ENSURE ( m_aCurrentPageIds ! = m_aControlIds . end ( ) , " OFormLayerXMLImport_Impl::seekPage: did not find the given page (perhaps it has not been imported, yet?)! " ) ;
}
2000-12-06 16:32:01 +00:00
//.........................................................................
} // namespace xmloff
//.........................................................................
/*************************************************************************
* history :
* $ Log : not supported by cvs2svn $
2001-05-28 14:04:18 +00:00
* Revision 1.12 2001 / 05 / 28 14 : 59 : 18 fs
* # 86712 # added control number style related functionality
*
2001-05-28 13:59:18 +00:00
* Revision 1.11 2001 / 03 / 20 13 : 39 : 58 fs
* # 83970 # + createOfficeFormsContext
*
2001-03-20 12:39:58 +00:00
* Revision 1.10 2001 / 03 / 20 08 : 05 : 15 fs
* # 85514 # added an attribute to the map for compatibility to old ( buggy ) files
*
2001-03-20 07:05:15 +00:00
* Revision 1.9 2001 / 02 / 28 16 : 42 : 16 fs
* State / DefaultState are int16 - properties
*
2001-02-28 15:42:16 +00:00
* Revision 1.8 2001 / 02 / 01 09 : 46 : 47 fs
* no own style handling anymore - the shape exporter is responsible for our styles now
*
2001-02-01 08:46:47 +00:00
* Revision 1.7 2001 / 01 / 24 09 : 34 : 40 fs
* + enter - / leaveEventContext
*
2001-01-24 08:34:40 +00:00
* Revision 1.6 2001 / 01 / 02 15 : 58 : 22 fs
* event ex - & import
*
2001-01-02 14:58:22 +00:00
* Revision 1.5 2000 / 12 / 19 12 : 13 : 57 fs
* some changes . . . now the exported styles are XSL conform
*
2000-12-19 11:13:57 +00:00
* Revision 1.4 2000 / 12 / 18 15 : 14 : 35 fs
* some changes . . . now exporting / importing styles
*
2000-12-18 14:14:35 +00:00
* Revision 1.3 2000 / 12 / 13 10 : 40 : 15 fs
* new import related implementations - at this version , we should be able to import everything we export ( which is all except events and styles )
*
2000-12-13 09:40:15 +00:00
* Revision 1.2 2000 / 12 / 12 12 : 01 : 05 fs
* new implementations for the import - still under construction
*
2000-12-12 11:01:05 +00:00
* Revision 1.1 2000 / 12 / 06 17 : 31 : 31 fs
* initial checkin - implementations for formlayer import / export - still under construction
*
2000-12-06 16:32:01 +00:00
*
* Revision 1.0 04.12 .00 15 : 48 : 46 fs
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */