2001-02-16 13:14:51 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: xmldlg_import.cxx,v $
|
|
|
|
*
|
2001-09-28 13:56:15 +00:00
|
|
|
* $Revision: 1.20 $
|
2001-02-16 13:14:51 +00:00
|
|
|
*
|
2001-09-28 13:56:15 +00:00
|
|
|
* last change: $Author: tbe $ $Date: 2001-09-28 14:56:15 $
|
2001-02-16 13:14:51 +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 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>
|
2001-09-19 12:43:18 +00:00
|
|
|
#include <osl/mutex.hxx>
|
2001-02-16 13:14:51 +00:00
|
|
|
|
|
|
|
#include <rtl/ustrbuf.hxx>
|
|
|
|
|
2001-04-04 13:35:09 +00:00
|
|
|
#include <xmlscript/xml_import.hxx>
|
2001-02-27 11:45:17 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2001-02-16 13:14:51 +00:00
|
|
|
|
|
|
|
#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>
|
|
|
|
|
2001-02-20 15:51:32 +00:00
|
|
|
#include <com/sun/star/script/XScriptEventsSupplier.hpp>
|
|
|
|
#include <com/sun/star/script/ScriptEventDescriptor.hpp>
|
|
|
|
|
2001-02-16 13:14:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace xmlscript
|
|
|
|
{
|
|
|
|
|
2001-02-20 15:51:32 +00:00
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
void EventElement::endElement()
|
|
|
|
throw (xml::sax::SAXException, RuntimeException)
|
|
|
|
{
|
2001-08-07 09:55:47 +00:00
|
|
|
static_cast< ControlElement * >( _pParent )->_events.push_back( this );
|
2001-02-20 15:51:32 +00:00
|
|
|
}
|
2001-02-16 13:14:51 +00:00
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
ControlElement::ControlElement(
|
|
|
|
OUString const & rLocalName,
|
|
|
|
Reference< xml::sax2::XExtendedAttributes > const & xAttributes,
|
|
|
|
ElementBase * pParent, DialogImport * pImport )
|
2001-03-14 15:39:59 +00:00
|
|
|
SAL_THROW( () )
|
2001-08-07 09:55:47 +00:00
|
|
|
: ElementBase( XMLNS_DIALOGS_UID, rLocalName, xAttributes, pParent, pImport )
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
|
|
|
if (_pParent)
|
|
|
|
{
|
|
|
|
// inherit position
|
|
|
|
_nBasePosX = static_cast< ControlElement * >( _pParent )->_nBasePosX;
|
|
|
|
_nBasePosY = static_cast< ControlElement * >( _pParent )->_nBasePosY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_nBasePosX = 0;
|
|
|
|
_nBasePosY = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-02-20 13:05:25 +00:00
|
|
|
Reference< xml::XImportContext > ControlElement::getStyle(
|
|
|
|
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
2001-02-20 13:05:25 +00:00
|
|
|
OUString aStyleId( xAttributes->getValueByUidName(
|
2001-02-16 13:14:51 +00:00
|
|
|
XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("style-id") ) ) );
|
|
|
|
if (aStyleId.getLength())
|
|
|
|
{
|
|
|
|
return _pImport->getStyle( aStyleId );
|
|
|
|
}
|
|
|
|
return Reference< xml::XImportContext >();
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-02-20 13:05:25 +00:00
|
|
|
OUString ControlElement::getControlId(
|
|
|
|
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
2001-02-20 13:05:25 +00:00
|
|
|
OUString aId( xAttributes->getValueByUidName(
|
2001-02-16 13:14:51 +00:00
|
|
|
XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("id") ) ) );
|
|
|
|
if (! aId.getLength())
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
2001-02-20 13:05:25 +00:00
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("missing id attribute!") ),
|
2001-02-16 13:14:51 +00:00
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
return aId;
|
|
|
|
}
|
|
|
|
|
|
|
|
//##################################################################################################
|
|
|
|
|
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
bool StyleElement::importTextColorStyle(
|
|
|
|
Reference< beans::XPropertySet > const & xProps )
|
|
|
|
{
|
2001-05-04 12:17:40 +00:00
|
|
|
if ((_inited & 0x2) != 0)
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
2001-05-04 12:17:40 +00:00
|
|
|
if ((_hasValue & 0x2) != 0)
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
|
|
|
xProps->setPropertyValue(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ), makeAny( _textColor ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2001-05-04 12:17:40 +00:00
|
|
|
_inited |= 0x2;
|
2001-02-16 13:14:51 +00:00
|
|
|
|
|
|
|
if (getLongAttr( &_textColor,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("text-color") ), _xAttributes ))
|
|
|
|
{
|
2001-05-04 12:17:40 +00:00
|
|
|
_hasValue |= 0x2;
|
2001-02-16 13:14:51 +00:00
|
|
|
xProps->setPropertyValue(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ), makeAny( _textColor ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-05-04 12:17:40 +00:00
|
|
|
bool StyleElement::importFillColorStyle(
|
|
|
|
Reference< beans::XPropertySet > const & xProps )
|
|
|
|
{
|
|
|
|
if ((_inited & 0x10) != 0)
|
|
|
|
{
|
|
|
|
if ((_hasValue & 0x10) != 0)
|
|
|
|
{
|
|
|
|
xProps->setPropertyValue(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ), makeAny( _fillColor ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
_inited |= 0x10;
|
|
|
|
|
|
|
|
if (getLongAttr( &_fillColor,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("fill-color") ), _xAttributes ))
|
|
|
|
{
|
|
|
|
_hasValue |= 0x10;
|
|
|
|
xProps->setPropertyValue(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ), makeAny( _fillColor ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-02-16 13:14:51 +00:00
|
|
|
bool StyleElement::importBackgroundColorStyle(
|
|
|
|
Reference< beans::XPropertySet > const & xProps )
|
|
|
|
{
|
2001-05-04 12:17:40 +00:00
|
|
|
if ((_inited & 0x1) != 0)
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
2001-05-04 12:17:40 +00:00
|
|
|
if ((_hasValue & 0x1) != 0)
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
|
|
|
xProps->setPropertyValue(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2001-05-04 12:17:40 +00:00
|
|
|
_inited |= 0x1;
|
2001-02-16 13:14:51 +00:00
|
|
|
|
|
|
|
if (getLongAttr( &_backgroundColor,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("background-color") ), _xAttributes ))
|
|
|
|
{
|
2001-05-04 12:17:40 +00:00
|
|
|
_hasValue |= 0x1;
|
2001-02-16 13:14:51 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//##################################################################################################
|
|
|
|
|
|
|
|
//__________________________________________________________________________________________________
|
2001-04-04 13:35:09 +00:00
|
|
|
bool ImportContext::importStringProperty(
|
2001-02-16 13:14:51 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-04-04 13:35:09 +00:00
|
|
|
bool ImportContext::importDoubleProperty(
|
2001-02-21 19:49:30 +00:00
|
|
|
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.toDouble() ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-04-04 13:35:09 +00:00
|
|
|
bool ImportContext::importBooleanProperty(
|
2001-02-16 13:14:51 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-04-04 13:35:09 +00:00
|
|
|
bool ImportContext::importLongProperty(
|
2001-02-16 13:14:51 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-04-04 13:35:09 +00:00
|
|
|
bool ImportContext::importLongProperty(
|
2001-02-20 13:05:25 +00:00
|
|
|
sal_Int32 nOffset,
|
|
|
|
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 ) + nOffset ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-04-04 13:35:09 +00:00
|
|
|
bool ImportContext::importShortProperty(
|
2001-02-16 13:14:51 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-04-04 13:35:09 +00:00
|
|
|
bool ImportContext::importAlignProperty(
|
2001-02-20 13:05:25 +00:00
|
|
|
OUString const & rPropName, OUString const & rAttrName,
|
|
|
|
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
|
|
|
|
{
|
|
|
|
OUString aAlign( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) );
|
|
|
|
if (aAlign.getLength())
|
|
|
|
{
|
|
|
|
sal_Int16 nAlign;
|
|
|
|
if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left") ))
|
|
|
|
{
|
|
|
|
nAlign = 0;
|
|
|
|
}
|
|
|
|
else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("center") ))
|
|
|
|
{
|
|
|
|
nAlign = 1;
|
|
|
|
}
|
|
|
|
else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right") ))
|
|
|
|
{
|
|
|
|
nAlign = 2;
|
|
|
|
}
|
|
|
|
else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
|
|
|
|
{
|
|
|
|
nAlign = 0; // default
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("invalid align value!") ),
|
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
|
2001-02-21 19:49:30 +00:00
|
|
|
_xControlModel->setPropertyValue( rPropName, makeAny( nAlign ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-04-04 13:35:09 +00:00
|
|
|
bool ImportContext::importDateFormatProperty(
|
2001-02-21 19:49:30 +00:00
|
|
|
OUString const & rPropName, OUString const & rAttrName,
|
|
|
|
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
|
|
|
|
{
|
|
|
|
OUString aFormat( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) );
|
|
|
|
if (aFormat.getLength())
|
|
|
|
{
|
|
|
|
sal_Int16 nFormat;
|
2001-03-01 10:22:45 +00:00
|
|
|
if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 0;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short_YY") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 1;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short_YYYY") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 2;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_long") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 3;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_DDMMYY") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 4;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_MMDDYY") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 5;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYMMDD") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 6;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_DDMMYYYY") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 7;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_MMDDYYYY") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 8;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYYYMMDD") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 9;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYMMDD_DIN5008") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 10;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYYYMMDD_DIN5008") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 11;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("invalid date-format value!") ),
|
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
|
|
|
|
_xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-04-04 13:35:09 +00:00
|
|
|
bool ImportContext::importTimeFormatProperty(
|
2001-02-21 19:49:30 +00:00
|
|
|
OUString const & rPropName, OUString const & rAttrName,
|
|
|
|
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
|
|
|
|
{
|
|
|
|
OUString aFormat( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) );
|
|
|
|
if (aFormat.getLength())
|
|
|
|
{
|
|
|
|
sal_Int16 nFormat;
|
2001-03-01 10:22:45 +00:00
|
|
|
if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("24h_short") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 0;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("24h_long") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 1;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("12h_short") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 2;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("12h_long") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 3;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Duration_short") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 4;
|
|
|
|
}
|
2001-03-01 10:22:45 +00:00
|
|
|
else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Duration_long") ))
|
2001-02-21 19:49:30 +00:00
|
|
|
{
|
|
|
|
nFormat = 5;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("invalid time-format value!") ),
|
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
|
|
|
|
_xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) );
|
2001-02-20 13:05:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-05-04 12:17:40 +00:00
|
|
|
bool ImportContext::importOrientationProperty(
|
|
|
|
OUString const & rPropName, OUString const & rAttrName,
|
|
|
|
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
|
|
|
|
{
|
|
|
|
OUString aOrient( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) );
|
|
|
|
if (aOrient.getLength())
|
|
|
|
{
|
|
|
|
sal_Int32 nOrient;
|
|
|
|
if (aOrient.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("horizontal") ))
|
|
|
|
{
|
|
|
|
nOrient = 0;
|
|
|
|
}
|
|
|
|
else if (aOrient.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("vertical") ))
|
|
|
|
{
|
|
|
|
nOrient = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("invalid orientation value!") ),
|
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
|
|
|
|
_xControlModel->setPropertyValue( rPropName, makeAny( nOrient ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2001-08-07 09:55:47 +00:00
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
struct StringTriple
|
|
|
|
{
|
|
|
|
char const * first;
|
|
|
|
char const * second;
|
|
|
|
char const * third;
|
|
|
|
};
|
|
|
|
static StringTriple const s_aEventTranslations[] =
|
|
|
|
{
|
|
|
|
// from xmloff/source/forms/formevents.cxx
|
2001-09-28 13:56:15 +00:00
|
|
|
// 28.09.2001 tbe added on-adjustmentvaluechange
|
2001-08-07 09:55:47 +00:00
|
|
|
{ "com.sun.star.form.XApproveActionListener", "approveAction", "on-approveaction" },
|
|
|
|
{ "com.sun.star.awt.XActionListener", "actionPerformed", "on-performaction" },
|
|
|
|
{ "com.sun.star.form.XChangeListener", "changed", "on-change" },
|
|
|
|
{ "com.sun.star.awt.XTextListener", "textChanged", "on-textchange" },
|
|
|
|
{ "com.sun.star.awt.XItemListener", "itemStateChanged", "on-itemstatechange" },
|
|
|
|
{ "com.sun.star.awt.XFocusListener", "focusGained", "on-focus" },
|
|
|
|
{ "com.sun.star.awt.XFocusListener", "focusLost", "on-blur" },
|
|
|
|
{ "com.sun.star.awt.XKeyListener", "keyPressed", "on-keydown" },
|
|
|
|
{ "com.sun.star.awt.XKeyListener", "keyReleased", "on-keyup" },
|
|
|
|
{ "com.sun.star.awt.XMouseListener", "mouseEntered", "on-mouseover" },
|
|
|
|
{ "com.sun.star.awt.XMouseMotionListener", "mouseDragged", "on-mousedrag" },
|
|
|
|
{ "com.sun.star.awt.XMouseMotionListener", "mouseMoved", "on-mousemove" },
|
|
|
|
{ "com.sun.star.awt.XMouseListener", "mousePressed", "on-mousedown" },
|
|
|
|
{ "com.sun.star.awt.XMouseListener", "mouseReleased", "on-mouseup" },
|
|
|
|
{ "com.sun.star.awt.XMouseListener", "mouseExited", "on-mouseout" },
|
|
|
|
{ "com.sun.star.form.XResetListener", "approveReset", "on-approvereset" },
|
|
|
|
{ "com.sun.star.form.XResetListener", "resetted", "on-reset" },
|
|
|
|
{ "com.sun.star.form.XSubmitListener", "approveSubmit", "on-submit" },
|
|
|
|
{ "com.sun.star.form.XUpdateListener", "approveUpdate", "on-approveupdate" },
|
|
|
|
{ "com.sun.star.form.XUpdateListener", "updated", "on-update" },
|
|
|
|
{ "com.sun.star.form.XLoadListener", "loaded", "on-load" },
|
|
|
|
{ "com.sun.star.form.XLoadListener", "reloading", "on-startreload" },
|
|
|
|
{ "com.sun.star.form.XLoadListener", "reloaded", "on-reload" },
|
|
|
|
{ "com.sun.star.form.XLoadListener", "unloading", "on-startunload" },
|
|
|
|
{ "com.sun.star.form.XLoadListener", "unloaded", "on-unload" },
|
|
|
|
{ "com.sun.star.form.XConfirmDeleteListener", "confirmDelete", "on-confirmdelete" },
|
|
|
|
{ "com.sun.star.sdb.XRowSetApproveListener", "approveRowChange", "on-approverowchange" },
|
|
|
|
{ "com.sun.star.sdbc.XRowSetListener", "rowChanged", "on-rowchange" },
|
|
|
|
{ "com.sun.star.sdb.XRowSetApproveListener", "approveCursorMove", "on-approvecursormove" },
|
|
|
|
{ "com.sun.star.sdbc.XRowSetListener", "cursorMoved", "on-cursormove" },
|
|
|
|
{ "com.sun.star.form.XDatabaseParameterListener", "approveParameter", "on-supplyparameter" },
|
|
|
|
{ "com.sun.star.sdb.XSQLErrorListener", "errorOccured", "on-error" },
|
2001-09-28 13:56:15 +00:00
|
|
|
{ "com.sun.star.awt.XAdjustmentListener", "adjustmentValueChanged", "on-adjustmentvaluechange" },
|
2001-08-07 09:55:47 +00:00
|
|
|
{ 0, 0, 0 }
|
|
|
|
};
|
|
|
|
extern StringTriple const * const g_pEventTranslations;
|
|
|
|
StringTriple const * const g_pEventTranslations = s_aEventTranslations;
|
|
|
|
|
2001-05-04 12:17:40 +00:00
|
|
|
//__________________________________________________________________________________________________
|
2001-04-04 13:35:09 +00:00
|
|
|
void ImportContext::importEvents(
|
2001-08-07 09:55:47 +00:00
|
|
|
vector< Reference< xml::XImportContext > > const & rEvents )
|
2001-04-04 13:35:09 +00:00
|
|
|
{
|
|
|
|
Reference< script::XScriptEventsSupplier > xSupplier( _xControlModel, UNO_QUERY );
|
|
|
|
if (xSupplier.is())
|
|
|
|
{
|
|
|
|
Reference< container::XNameContainer > xEvents( xSupplier->getEvents() );
|
|
|
|
if (xEvents.is())
|
|
|
|
{
|
|
|
|
for ( size_t nPos = 0; nPos < rEvents.size(); ++nPos )
|
|
|
|
{
|
|
|
|
script::ScriptEventDescriptor descr;
|
2001-08-07 09:55:47 +00:00
|
|
|
|
|
|
|
EventElement * pEventElement = static_cast< EventElement * >( rEvents[ nPos ].get() );
|
|
|
|
sal_Int32 nUid = pEventElement->getUid();
|
|
|
|
OUString aLocalName( pEventElement->getLocalName() );
|
|
|
|
Reference< xml::sax2::XExtendedAttributes > xAttributes( pEventElement->getAttributes() );
|
|
|
|
|
|
|
|
// nowadays script events
|
|
|
|
if (XMLNS_SCRIPT_UID == nUid)
|
2001-04-04 13:35:09 +00:00
|
|
|
{
|
2001-08-07 09:55:47 +00:00
|
|
|
if (!getStringAttr( &descr.ScriptType,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("language") ),
|
|
|
|
xAttributes, XMLNS_SCRIPT_UID ) ||
|
|
|
|
!getStringAttr( &descr.ScriptCode,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("macro-name") ),
|
|
|
|
xAttributes, XMLNS_SCRIPT_UID ))
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("missing language or macro-name attribute(s) of event!") ),
|
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString aLocation;
|
|
|
|
if (getStringAttr( &aLocation, OUString( RTL_CONSTASCII_USTRINGPARAM("location") ),
|
|
|
|
xAttributes, XMLNS_SCRIPT_UID ))
|
|
|
|
{
|
|
|
|
// prepend location
|
|
|
|
OUStringBuffer buf( 48 );
|
|
|
|
buf.append( aLocation );
|
|
|
|
buf.append( (sal_Unicode)':' );
|
|
|
|
buf.append( descr.ScriptCode );
|
|
|
|
descr.ScriptCode = buf.makeStringAndClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// script:event element
|
|
|
|
if (aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
|
|
|
|
{
|
|
|
|
OUString aEventName;
|
|
|
|
if (! getStringAttr( &aEventName,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("event-name") ),
|
|
|
|
xAttributes, XMLNS_SCRIPT_UID ))
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("missing event-name attribute!") ),
|
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// lookup in table
|
|
|
|
OString str( OUStringToOString( aEventName, RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
StringTriple const * p = g_pEventTranslations;
|
|
|
|
while (p->first)
|
|
|
|
{
|
|
|
|
if (0 == ::rtl_str_compare( p->third, str.getStr() ))
|
|
|
|
{
|
|
|
|
descr.ListenerType = OUString( p->first, ::rtl_str_getLength( p->first ), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
descr.EventMethod = OUString( p->second, ::rtl_str_getLength( p->second ), RTL_TEXTENCODING_ASCII_US );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! p->first)
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("no matching event-name found!") ),
|
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // script:listener-event element
|
|
|
|
{
|
|
|
|
OSL_ASSERT( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("listener-event") ) );
|
|
|
|
|
|
|
|
if (!getStringAttr( &descr.ListenerType,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("listener-type") ),
|
|
|
|
xAttributes, XMLNS_SCRIPT_UID ) ||
|
|
|
|
!getStringAttr( &descr.EventMethod,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("listener-method") ),
|
|
|
|
xAttributes, XMLNS_SCRIPT_UID ))
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type or listener-method attribute(s)!") ),
|
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
// optional listener param
|
|
|
|
getStringAttr(
|
|
|
|
&descr.AddListenerParam,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("listener-param") ),
|
|
|
|
xAttributes, XMLNS_SCRIPT_UID );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // deprecated dlg:event element
|
|
|
|
{
|
|
|
|
OSL_ASSERT( XMLNS_DIALOGS_UID == nUid && aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ) );
|
|
|
|
|
|
|
|
if (!getStringAttr( &descr.ListenerType,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("listener-type") ),
|
|
|
|
xAttributes, XMLNS_DIALOGS_UID ) ||
|
|
|
|
!getStringAttr( &descr.EventMethod,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("event-method") ),
|
|
|
|
xAttributes, XMLNS_DIALOGS_UID ))
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type or event-method attribute(s)!") ),
|
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
|
|
|
|
getStringAttr(
|
|
|
|
&descr.ScriptType,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("script-type") ),
|
|
|
|
xAttributes, XMLNS_DIALOGS_UID );
|
|
|
|
getStringAttr(
|
|
|
|
&descr.ScriptCode,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("script-code") ),
|
|
|
|
xAttributes, XMLNS_DIALOGS_UID );
|
|
|
|
getStringAttr(
|
|
|
|
&descr.AddListenerParam,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("param") ),
|
|
|
|
xAttributes, XMLNS_DIALOGS_UID );
|
2001-04-04 13:35:09 +00:00
|
|
|
}
|
|
|
|
|
2001-08-07 09:55:47 +00:00
|
|
|
OUStringBuffer buf( 48 );
|
2001-04-04 13:35:09 +00:00
|
|
|
buf.append( descr.ListenerType );
|
|
|
|
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("::") );
|
|
|
|
buf.append( descr.EventMethod );
|
|
|
|
xEvents->insertByName( buf.makeStringAndClear(), makeAny( descr ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
2001-02-16 13:14:51 +00:00
|
|
|
void ControlImportContext::importDefaults(
|
2001-02-20 13:05:25 +00:00
|
|
|
sal_Int32 nBaseX, sal_Int32 nBaseY,
|
2001-02-16 13:14:51 +00:00
|
|
|
Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
|
|
|
|
{
|
2001-02-28 17:22:08 +00:00
|
|
|
_xControlModel->setPropertyValue(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ),
|
|
|
|
makeAny( _aId ) );
|
|
|
|
|
2001-03-07 13:57:38 +00:00
|
|
|
importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("TabIndex") ),
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("tab-index") ),
|
|
|
|
xAttributes );
|
2001-02-28 17:22:08 +00:00
|
|
|
|
2001-02-21 19:49:30 +00:00
|
|
|
sal_Bool bDisable;
|
|
|
|
if (getBoolAttr( &bDisable, OUString( RTL_CONSTASCII_USTRINGPARAM("disabled") ), xAttributes ) &&
|
|
|
|
bDisable)
|
|
|
|
{
|
|
|
|
_xControlModel->setPropertyValue(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ), makeAny( sal_False ) );
|
|
|
|
}
|
|
|
|
|
2001-02-20 13:05:25 +00:00
|
|
|
if (!importLongProperty( nBaseX,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ),
|
2001-02-16 13:14:51 +00:00
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("left") ),
|
|
|
|
xAttributes ) ||
|
2001-02-20 13:05:25 +00:00
|
|
|
!importLongProperty( nBaseY,
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ),
|
2001-02-16 13:14:51 +00:00
|
|
|
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("Printable") ),
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("printable") ),
|
|
|
|
xAttributes );
|
2001-03-07 13:57:38 +00:00
|
|
|
|
|
|
|
sal_Int32 nLong;
|
|
|
|
if (! getLongAttr( &nLong, OUString( RTL_CONSTASCII_USTRINGPARAM("page") ), xAttributes ))
|
|
|
|
{
|
|
|
|
nLong = 0;
|
|
|
|
}
|
|
|
|
_xControlModel->setPropertyValue(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ),
|
|
|
|
makeAny( nLong ) );
|
|
|
|
|
|
|
|
importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ),
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("tag") ),
|
|
|
|
xAttributes );
|
2001-03-22 14:43:07 +00:00
|
|
|
importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ),
|
2001-04-04 13:35:09 +00:00
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("help-text") ),
|
|
|
|
xAttributes );
|
|
|
|
importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ),
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("help-url") ),
|
2001-03-22 14:43:07 +00:00
|
|
|
xAttributes );
|
2001-02-20 15:51:32 +00:00
|
|
|
}
|
2001-02-16 13:14:51 +00:00
|
|
|
|
|
|
|
//##################################################################################################
|
|
|
|
|
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
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)
|
|
|
|
{
|
2001-08-07 09:55:47 +00:00
|
|
|
return _nUid;
|
2001-02-16 13:14:51 +00:00
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
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(
|
2001-08-07 09:55:47 +00:00
|
|
|
sal_Int32 nUid, OUString const & rLocalName,
|
2001-02-16 13:14:51 +00:00
|
|
|
Reference< xml::sax2::XExtendedAttributes > const & xAttributes,
|
|
|
|
ElementBase * pParent, DialogImport * pImport )
|
2001-03-14 15:39:59 +00:00
|
|
|
SAL_THROW( () )
|
|
|
|
: _pImport( pImport )
|
2001-02-16 13:14:51 +00:00
|
|
|
, _pParent( pParent )
|
2001-08-07 09:55:47 +00:00
|
|
|
, _nUid( nUid )
|
2001-03-14 15:39:59 +00:00
|
|
|
, _aLocalName( rLocalName )
|
|
|
|
, _xAttributes( xAttributes )
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
|
|
|
_pImport->acquire();
|
|
|
|
|
|
|
|
if (_pParent)
|
|
|
|
{
|
|
|
|
_pParent->acquire();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
ElementBase::~ElementBase()
|
2001-03-14 15:39:59 +00:00
|
|
|
SAL_THROW( () )
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
|
|
|
_pImport->release();
|
|
|
|
|
|
|
|
if (_pParent)
|
|
|
|
{
|
|
|
|
_pParent->release();
|
|
|
|
}
|
2001-02-27 11:45:17 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
OString aStr( OUStringToOString( _aLocalName, RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
OSL_TRACE( "ElementBase::~ElementBase(): %s\n", aStr.getStr() );
|
|
|
|
#endif
|
2001-02-16 13:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//##################################################################################################
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
2001-02-27 11:45:17 +00:00
|
|
|
if (XMLNS_DIALOGS_UID != nUid)
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
|
|
|
|
Reference< XInterface >(), Any() );
|
|
|
|
}
|
2001-03-14 15:39:59 +00:00
|
|
|
// window
|
|
|
|
else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("window") ))
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
2001-03-14 15:39:59 +00:00
|
|
|
return new WindowElement( rLocalName, xAttributes, 0, this );
|
2001-02-16 13:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw xml::sax::SAXException(
|
2001-03-14 15:39:59 +00:00
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("illegal root element (expected window) given: ") ) +
|
2001-02-16 13:14:51 +00:00
|
|
|
rLocalName, Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
}
|
2001-02-27 11:45:17 +00:00
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
DialogImport::~DialogImport()
|
2001-03-14 15:39:59 +00:00
|
|
|
SAL_THROW( () )
|
2001-02-27 11:45:17 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
OSL_TRACE( "DialogImport::~DialogImport().\n" );
|
|
|
|
#endif
|
|
|
|
}
|
2001-09-19 12:43:18 +00:00
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
Reference< util::XNumberFormatsSupplier > const & DialogImport::getNumberFormatsSupplier()
|
|
|
|
{
|
|
|
|
if (! _xSupplier.is())
|
|
|
|
{
|
|
|
|
Reference< XComponentContext > xContext( getComponentContext() );
|
|
|
|
Reference< util::XNumberFormatsSupplier > xSupplier( xContext->getServiceManager()->createInstanceWithContext(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatsSupplier") ), xContext ), UNO_QUERY );
|
|
|
|
|
|
|
|
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
|
|
|
if (! _xSupplier.is())
|
|
|
|
{
|
|
|
|
_xSupplier = xSupplier;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _xSupplier;
|
|
|
|
}
|
2001-02-16 13:14:51 +00:00
|
|
|
|
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
void DialogImport::addStyle(
|
|
|
|
OUString const & rStyleId,
|
|
|
|
Reference< xml::XImportContext > const & xStyle )
|
2001-03-14 15:39:59 +00:00
|
|
|
SAL_THROW( () )
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
|
|
|
_styleNames.push_back( rStyleId );
|
|
|
|
_styles.push_back( xStyle );
|
|
|
|
}
|
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
Reference< xml::XImportContext > DialogImport::getStyle(
|
|
|
|
OUString const & rStyleId ) const
|
2001-03-14 15:39:59 +00:00
|
|
|
SAL_THROW( () )
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
|
|
|
for ( size_t nPos = 0; nPos < _styleNames.size(); ++nPos )
|
|
|
|
{
|
|
|
|
if (_styleNames[ nPos ] == rStyleId)
|
|
|
|
{
|
|
|
|
return _styles[ nPos ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//##################################################################################################
|
|
|
|
|
|
|
|
//==================================================================================================
|
2001-03-28 09:50:37 +00:00
|
|
|
Reference< xml::sax::XDocumentHandler > SAL_CALL importDialogModel(
|
2001-09-19 07:46:35 +00:00
|
|
|
Reference< container::XNameContainer > const & xDialogModel,
|
|
|
|
Reference< XComponentContext > const & xContext )
|
2001-03-14 15:39:59 +00:00
|
|
|
SAL_THROW( (Exception) )
|
2001-02-16 13:14:51 +00:00
|
|
|
{
|
2001-02-27 11:45:17 +00:00
|
|
|
NameSpaceUid arNamespaceUids[] = {
|
2001-08-07 09:55:47 +00:00
|
|
|
NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_URI) ), XMLNS_DIALOGS_UID ),
|
|
|
|
NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ), XMLNS_SCRIPT_UID )
|
|
|
|
/* ,
|
|
|
|
NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_URI) ), XMLNS_LIBRARY_UID ),
|
|
|
|
NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_XLINK_URI) ), XMLNS_XLINK_UID )
|
|
|
|
*/
|
2001-02-16 13:14:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return ::xmlscript::createDocumentHandler(
|
|
|
|
arNamespaceUids, sizeof(arNamespaceUids) / sizeof(NameSpaceUid),
|
|
|
|
-1 /* unknown namespace id */,
|
2001-09-19 07:46:35 +00:00
|
|
|
static_cast< xml::XImporter * >( new DialogImport( xContext, xDialogModel ) ) );
|
2001-02-16 13:14:51 +00:00
|
|
|
}
|
|
|
|
|
2001-08-24 10:16:43 +00:00
|
|
|
}
|