LCOV - code coverage report
Current view: top level - xmlscript/source/xmldlg_imexp - xmldlg_import.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 281 774 36.3 %
Date: 2014-04-11 Functions: 42 60 70.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "imp_share.hxx"
      21             : #include "xml_import.hxx"
      22             : 
      23             : #include <com/sun/star/awt/CharSet.hpp>
      24             : #include <com/sun/star/awt/FontFamily.hpp>
      25             : #include <com/sun/star/awt/FontPitch.hpp>
      26             : #include <com/sun/star/awt/FontSlant.hpp>
      27             : #include <com/sun/star/awt/FontStrikeout.hpp>
      28             : #include <com/sun/star/awt/FontType.hpp>
      29             : #include <com/sun/star/awt/FontUnderline.hpp>
      30             : #include <com/sun/star/awt/FontWeight.hpp>
      31             : #include <com/sun/star/awt/FontWidth.hpp>
      32             : #include <com/sun/star/awt/ImagePosition.hpp>
      33             : #include <com/sun/star/awt/LineEndFormat.hpp>
      34             : #include <com/sun/star/awt/PushButtonType.hpp>
      35             : #include <com/sun/star/awt/VisualEffect.hpp>
      36             : #include <com/sun/star/style/VerticalAlignment.hpp>
      37             : #include <com/sun/star/util/Date.hpp>
      38             : #include <com/sun/star/util/Time.hpp>
      39             : #include <tools/date.hxx>
      40             : #include <tools/time.hxx>
      41             : 
      42             : #include <com/sun/star/script/XScriptEventsSupplier.hpp>
      43             : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      44             : 
      45             : #include <com/sun/star/view/SelectionType.hpp>
      46             : #include <com/sun/star/lang/XServiceInfo.hpp>
      47             : #include <com/sun/star/form/binding/XBindableValue.hpp>
      48             : #include <com/sun/star/form/binding/XValueBinding.hpp>
      49             : #include <com/sun/star/form/binding/XListEntrySink.hpp>
      50             : #include <com/sun/star/beans/NamedValue.hpp>
      51             : #include <com/sun/star/table/CellAddress.hpp>
      52             : #include <com/sun/star/table/CellRangeAddress.hpp>
      53             : #include <com/sun/star/document/XGraphicObjectResolver.hpp>
      54             : #include <com/sun/star/document/XStorageBasedDocument.hpp>
      55             : #include <com/sun/star/script/DocumentScriptLibraryContainer.hpp>
      56             : #include <com/sun/star/script/vba/XVBACompatibility.hpp>
      57             : #include <com/sun/star/util/NumberFormatsSupplier.hpp>
      58             : 
      59             : using namespace ::com::sun::star;
      60             : using namespace ::com::sun::star::uno;
      61             : using namespace ::com::sun::star::frame;
      62             : 
      63             : namespace xmlscript
      64             : {
      65             : 
      66           0 : void EventElement::endElement()
      67             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
      68             : {
      69           0 :     static_cast< ControlElement * >( _pParent )->_events.push_back( this );
      70           0 : }
      71             : 
      72          17 : ControlElement::ControlElement(
      73             :     OUString const & rLocalName,
      74             :     Reference< xml::input::XAttributes > const & xAttributes,
      75             :     ElementBase * pParent, DialogImport * pImport )
      76             :     SAL_THROW(())
      77             :     : ElementBase(
      78          17 :         pImport->XMLNS_DIALOGS_UID, rLocalName, xAttributes, pParent, pImport )
      79             : {
      80          17 :     if (_pParent)
      81             :     {
      82             :         // inherit position
      83          13 :         _nBasePosX = static_cast< ControlElement * >( _pParent )->_nBasePosX;
      84          13 :         _nBasePosY = static_cast< ControlElement * >( _pParent )->_nBasePosY;
      85             :     }
      86             :     else
      87             :     {
      88           4 :         _nBasePosX = 0;
      89           4 :         _nBasePosY = 0;
      90             :     }
      91          17 : }
      92             : 
      93          12 : Reference< xml::input::XElement > ControlElement::getStyle(
      94             :     Reference< xml::input::XAttributes > const & xAttributes )
      95             : {
      96          12 :     OUString aStyleId( xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID,"style-id" ) );
      97          12 :     if (!aStyleId.isEmpty())
      98             :     {
      99           8 :         return _pImport->getStyle( aStyleId );
     100             :     }
     101           4 :     return Reference< xml::input::XElement >();
     102             : }
     103             : 
     104          12 : OUString ControlElement::getControlId(
     105             :     Reference< xml::input::XAttributes > const & xAttributes )
     106             : {
     107          12 :     OUString aId( xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, "id" ) );
     108          12 :     if (aId.isEmpty())
     109             :     {
     110           0 :         throw xml::sax::SAXException( "missing id attribute!", Reference< XInterface >(), Any() );
     111             :     }
     112          12 :     return aId;
     113             : }
     114             : 
     115           3 : OUString ControlElement::getControlModelName(
     116             :     OUString const& rDefaultModel,
     117             :     Reference< xml::input::XAttributes > const & xAttributes )
     118             : {
     119           3 :     OUString aModel;
     120           3 :     aModel = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, "control-implementation");
     121           3 :     if (aModel.isEmpty())
     122           0 :         aModel = rDefaultModel;
     123           3 :     return aModel;
     124             : }
     125             : 
     126           8 : bool StyleElement::importTextColorStyle(
     127             :     Reference< beans::XPropertySet > const & xProps )
     128             : {
     129           8 :     if ((_inited & 0x2) != 0)
     130             :     {
     131           0 :         if ((_hasValue & 0x2) != 0)
     132             :         {
     133           0 :             xProps->setPropertyValue("TextColor", makeAny( _textColor ) );
     134           0 :             return true;
     135             :         }
     136           0 :         return false;
     137             :     }
     138           8 :     _inited |= 0x2;
     139             : 
     140           8 :     if (getLongAttr( &_textColor, "text-color", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     141             :     {
     142           6 :         _hasValue |= 0x2;
     143           6 :         xProps->setPropertyValue( "TextColor", makeAny( _textColor ) );
     144           6 :         return true;
     145             :     }
     146           2 :     return false;
     147             : }
     148             : 
     149           8 : bool StyleElement::importTextLineColorStyle(
     150             :     Reference< beans::XPropertySet > const & xProps )
     151             : {
     152           8 :     if ((_inited & 0x20) != 0)
     153             :     {
     154           0 :         if ((_hasValue & 0x20) != 0)
     155             :         {
     156           0 :             xProps->setPropertyValue( "TextLineColor", makeAny( _textLineColor ) );
     157           0 :             return true;
     158             :         }
     159           0 :         return false;
     160             :     }
     161           8 :     _inited |= 0x20;
     162             : 
     163           8 :     if (getLongAttr( &_textLineColor, "textline-color", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     164             :     {
     165           0 :         _hasValue |= 0x20;
     166           0 :         xProps->setPropertyValue( "TextLineColor", makeAny( _textLineColor ) );
     167           0 :         return true;
     168             :     }
     169           8 :     return false;
     170             : }
     171             : 
     172           0 : bool StyleElement::importFillColorStyle(
     173             :     Reference< beans::XPropertySet > const & xProps )
     174             : {
     175           0 :     if ((_inited & 0x10) != 0)
     176             :     {
     177           0 :         if ((_hasValue & 0x10) != 0)
     178             :         {
     179           0 :             xProps->setPropertyValue( "FillColor", makeAny( _fillColor ) );
     180           0 :             return true;
     181             :         }
     182           0 :         return false;
     183             :     }
     184           0 :     _inited |= 0x10;
     185             : 
     186           0 :     if (getLongAttr( &_fillColor, "fill-color", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     187             :     {
     188           0 :         _hasValue |= 0x10;
     189           0 :         xProps->setPropertyValue( "FillColor", makeAny( _fillColor ) );
     190           0 :         return true;
     191             :     }
     192           0 :     return false;
     193             : }
     194             : 
     195           8 : bool StyleElement::importBackgroundColorStyle(
     196             :     Reference< beans::XPropertySet > const & xProps )
     197             : {
     198           8 :     if ((_inited & 0x1) != 0)
     199             :     {
     200           0 :         if ((_hasValue & 0x1) != 0)
     201             :         {
     202           0 :             xProps->setPropertyValue( "BackgroundColor", makeAny( _backgroundColor ) );
     203           0 :             return true;
     204             :         }
     205           0 :         return false;
     206             :     }
     207           8 :     _inited |= 0x1;
     208             : 
     209           8 :     if (getLongAttr( &_backgroundColor, "background-color", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     210             :     {
     211           8 :         _hasValue |= 0x1;
     212           8 :         xProps->setPropertyValue( "BackgroundColor", makeAny( _backgroundColor ) );
     213           8 :         return true;
     214             :     }
     215           0 :     return false;
     216             : }
     217             : 
     218           3 : bool StyleElement::importBorderStyle(
     219             :     Reference< beans::XPropertySet > const & xProps )
     220             : {
     221           3 :     if ((_inited & 0x4) != 0)
     222             :     {
     223           0 :         if ((_hasValue & 0x4) != 0)
     224             :         {
     225           0 :             xProps->setPropertyValue( "Border", makeAny( _border == BORDER_SIMPLE_COLOR ? BORDER_SIMPLE : _border ) );
     226           0 :             if (_border == BORDER_SIMPLE_COLOR)
     227           0 :                 xProps->setPropertyValue( "BorderColor", makeAny(_borderColor) );
     228           0 :             return true;
     229             :         }
     230           0 :         return false;
     231             :     }
     232           3 :     _inited |= 0x4;
     233             : 
     234           3 :     OUString aValue;
     235           3 :     if (getStringAttr(&aValue, "border", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     236             :         {
     237           0 :         if ( aValue == "none" )
     238           0 :             _border = BORDER_NONE;
     239           0 :         else if ( aValue == "3d" )
     240           0 :             _border = BORDER_3D;
     241           0 :         else if ( aValue == "simple" )
     242           0 :             _border = BORDER_SIMPLE;
     243             :         else {
     244           0 :             _border = BORDER_SIMPLE_COLOR;
     245           0 :             _borderColor = toInt32(aValue);
     246             :         }
     247             : 
     248           0 :         _hasValue |= 0x4;
     249           0 :         importBorderStyle(xProps); // write values
     250             :     }
     251           3 :     return false;
     252             : }
     253             : 
     254           2 : bool StyleElement::importVisualEffectStyle(
     255             :     Reference<beans::XPropertySet> const & xProps )
     256             : {
     257           2 :     if ((_inited & 0x40) != 0)
     258             :     {
     259           0 :         if ((_hasValue & 0x40) != 0)
     260             :         {
     261           0 :             xProps->setPropertyValue( "VisualEffect", makeAny(_visualEffect) );
     262           0 :             return true;
     263             :         }
     264           0 :         return false;
     265             :     }
     266           2 :     _inited |= 0x40;
     267             : 
     268           2 :     OUString aValue;
     269           2 :     if (getStringAttr( &aValue, "look", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     270             :     {
     271           0 :         if ( aValue == "none" )
     272             :         {
     273           0 :             _visualEffect = awt::VisualEffect::NONE;
     274             :         }
     275           0 :         else if ( aValue == "3d" )
     276             :         {
     277           0 :             _visualEffect = awt::VisualEffect::LOOK3D;
     278             :         }
     279           0 :         else if ( aValue == "simple" )
     280             :         {
     281           0 :             _visualEffect = awt::VisualEffect::FLAT;
     282             :         }
     283             :         else
     284             :             OSL_ASSERT( false );
     285             : 
     286           0 :         _hasValue |= 0x40;
     287           0 :         xProps->setPropertyValue( "VisualEffect", makeAny(_visualEffect) );
     288             :     }
     289           2 :     return false;
     290             : }
     291             : 
     292           6 : void StyleElement::setFontProperties(
     293             :     Reference< beans::XPropertySet > const & xProps )
     294             : {
     295           6 :     xProps->setPropertyValue("FontDescriptor", makeAny( _descr ) );
     296           6 :     xProps->setPropertyValue("FontEmphasisMark", makeAny( _fontEmphasisMark ) );
     297           6 :     xProps->setPropertyValue("FontRelief", makeAny( _fontRelief ) );
     298           6 : }
     299             : 
     300           8 : bool StyleElement::importFontStyle(
     301             :     Reference< beans::XPropertySet > const & xProps )
     302             : {
     303           8 :     if ((_inited & 0x8) != 0)
     304             :     {
     305           0 :         if ((_hasValue & 0x8) != 0)
     306             :         {
     307           0 :             setFontProperties( xProps );
     308           0 :             return true;
     309             :         }
     310           0 :         return false;
     311             :     }
     312           8 :     _inited |= 0x8;
     313             : 
     314           8 :     OUString aValue;
     315             :     bool bFontImport;
     316             : 
     317             :     // dialog:font-name CDATA #IMPLIED
     318           8 :     bFontImport = getStringAttr( &_descr.Name, "font-name", _xAttributes, _pImport->XMLNS_DIALOGS_UID );
     319             : 
     320             :     // dialog:font-height %numeric; #IMPLIED
     321           8 :     if (getStringAttr( &aValue, "font-height", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     322             :     {
     323           6 :         _descr.Height = (sal_Int16)toInt32( aValue );
     324           6 :         bFontImport = true;
     325             :     }
     326             :     // dialog:font-width %numeric; #IMPLIED
     327           8 :     if (getStringAttr(&aValue, "font-width", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     328             :     {
     329           0 :         _descr.Width = (sal_Int16)toInt32( aValue );
     330           0 :         bFontImport = true;
     331             :     }
     332             :     // dialog:font-stylename CDATA #IMPLIED
     333           8 :     bFontImport |= getStringAttr( &_descr.StyleName, "font-stylename", _xAttributes, _pImport->XMLNS_DIALOGS_UID );
     334             : 
     335             :     // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
     336           8 :     if (getStringAttr(&aValue, "font-family", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     337             :     {
     338           0 :         if ( aValue == "decorative" )
     339             :         {
     340           0 :             _descr.Family = awt::FontFamily::DECORATIVE;
     341             :         }
     342           0 :         else if ( aValue == "modern" )
     343             :         {
     344           0 :             _descr.Family = awt::FontFamily::MODERN;
     345             :         }
     346           0 :         else if ( aValue == "roman" )
     347             :         {
     348           0 :             _descr.Family = awt::FontFamily::ROMAN;
     349             :         }
     350           0 :         else if ( aValue == "script" )
     351             :         {
     352           0 :             _descr.Family = awt::FontFamily::SCRIPT;
     353             :         }
     354           0 :         else if ( aValue == "swiss" )
     355             :         {
     356           0 :             _descr.Family = awt::FontFamily::SWISS;
     357             :         }
     358           0 :         else if ( aValue == "system" )
     359             :         {
     360           0 :             _descr.Family = awt::FontFamily::SYSTEM;
     361             :         }
     362             :         else
     363             :         {
     364           0 :             throw xml::sax::SAXException("invalid font-family style!", Reference< XInterface >(), Any() );
     365             :         }
     366           0 :         bFontImport = true;
     367             :     }
     368             : 
     369             :     // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
     370           8 :     if (getStringAttr(&aValue, "font-charset", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     371             :     {
     372           6 :         if ( aValue == "ansi" )
     373             :         {
     374           6 :             _descr.CharSet = awt::CharSet::ANSI;
     375             :         }
     376           0 :         else if ( aValue == "mac" )
     377             :         {
     378           0 :             _descr.CharSet = awt::CharSet::MAC;
     379             :         }
     380           0 :         else if ( aValue == "ibmpc_437" )
     381             :         {
     382           0 :             _descr.CharSet = awt::CharSet::IBMPC_437;
     383             :         }
     384           0 :         else if ( aValue == "ibmpc_850" )
     385             :         {
     386           0 :             _descr.CharSet = awt::CharSet::IBMPC_850;
     387             :         }
     388           0 :         else if ( aValue == "ibmpc_860" )
     389             :         {
     390           0 :             _descr.CharSet = awt::CharSet::IBMPC_860;
     391             :         }
     392           0 :         else if ( aValue == "ibmpc_861" )
     393             :         {
     394           0 :             _descr.CharSet = awt::CharSet::IBMPC_861;
     395             :         }
     396           0 :         else if ( aValue == "ibmpc_863" )
     397             :         {
     398           0 :             _descr.CharSet = awt::CharSet::IBMPC_863;
     399             :         }
     400           0 :         else if ( aValue == "ibmpc_865" )
     401             :         {
     402           0 :             _descr.CharSet = awt::CharSet::IBMPC_865;
     403             :         }
     404           0 :         else if ( aValue == "system" )
     405             :         {
     406           0 :             _descr.CharSet = awt::CharSet::SYSTEM;
     407             :         }
     408           0 :         else if ( aValue == "symbol" )
     409             :         {
     410           0 :             _descr.CharSet = awt::CharSet::SYMBOL;
     411             :         }
     412             :         else
     413             :         {
     414           0 :             throw xml::sax::SAXException("invalid font-charset style!", Reference< XInterface >(), Any() );
     415             :         }
     416           6 :         bFontImport = true;
     417             :     }
     418             : 
     419             :     // dialog:font-pitch "(fixed|variable)" #IMPLIED
     420           8 :     if (getStringAttr( &aValue, "font-pitch", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     421             :     {
     422           0 :         if ( aValue == "fixed" )
     423             :         {
     424           0 :             _descr.Pitch = awt::FontPitch::FIXED;
     425             :         }
     426           0 :         else if ( aValue == "variable" )
     427             :         {
     428           0 :             _descr.Pitch = awt::FontPitch::VARIABLE;
     429             :         }
     430             :         else
     431             :         {
     432           0 :             throw xml::sax::SAXException("invalid font-pitch style!", Reference< XInterface >(), Any() );
     433             :         }
     434           0 :         bFontImport = true;
     435             :     }
     436             : 
     437             :     // dialog:font-charwidth CDATA #IMPLIED
     438           8 :     if (getStringAttr( &aValue, "font-charwidth", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     439             :     {
     440           0 :         _descr.CharacterWidth = aValue.toFloat();
     441           0 :         bFontImport = true;
     442             :     }
     443             :     // dialog:font-weight CDATA #IMPLIED
     444           8 :     if (getStringAttr( &aValue, "font-weight", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     445             :     {
     446           6 :         _descr.Weight = aValue.toFloat();
     447           6 :         bFontImport = true;
     448             :     }
     449             : 
     450             :     // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
     451           8 :     if (getStringAttr( &aValue, "font-slant", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     452             :     {
     453           0 :         if ( aValue == "oblique" )
     454             :         {
     455           0 :             _descr.Slant = awt::FontSlant_OBLIQUE;
     456             :         }
     457           0 :         else if ( aValue == "italic" )
     458             :         {
     459           0 :             _descr.Slant = awt::FontSlant_ITALIC;
     460             :         }
     461           0 :         else if ( aValue == "reverse_oblique" )
     462             :         {
     463           0 :             _descr.Slant = awt::FontSlant_REVERSE_OBLIQUE;
     464             :         }
     465           0 :         else if ( aValue == "reverse_italic" )
     466             :         {
     467           0 :             _descr.Slant = awt::FontSlant_REVERSE_ITALIC;
     468             :         }
     469             :         else
     470             :         {
     471           0 :             throw xml::sax::SAXException("invalid font-slant style!", Reference< XInterface >(), Any() );
     472             :         }
     473           0 :         bFontImport = true;
     474             :     }
     475             : 
     476             :     // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
     477           8 :     if (getStringAttr( &aValue, "font-underline", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     478             :     {
     479           0 :         if ( aValue == "single" )
     480             :         {
     481           0 :             _descr.Underline = awt::FontUnderline::SINGLE;
     482             :         }
     483           0 :         else if ( aValue == "double" )
     484             :         {
     485           0 :             _descr.Underline = awt::FontUnderline::DOUBLE;
     486             :         }
     487           0 :         else if ( aValue == "dotted" )
     488             :         {
     489           0 :             _descr.Underline = awt::FontUnderline::DOTTED;
     490             :         }
     491           0 :         else if ( aValue == "dash" )
     492             :         {
     493           0 :             _descr.Underline = awt::FontUnderline::DASH;
     494             :         }
     495           0 :         else if ( aValue == "longdash" )
     496             :         {
     497           0 :             _descr.Underline = awt::FontUnderline::LONGDASH;
     498             :         }
     499           0 :         else if ( aValue == "dashdot" )
     500             :         {
     501           0 :             _descr.Underline = awt::FontUnderline::DASHDOT;
     502             :         }
     503           0 :         else if ( aValue == "dashdotdot" )
     504             :         {
     505           0 :             _descr.Underline = awt::FontUnderline::DASHDOTDOT;
     506             :         }
     507           0 :         else if ( aValue == "smallwave" )
     508             :         {
     509           0 :             _descr.Underline = awt::FontUnderline::SMALLWAVE;
     510             :         }
     511           0 :         else if ( aValue == "wave" )
     512             :         {
     513           0 :             _descr.Underline = awt::FontUnderline::WAVE;
     514             :         }
     515           0 :         else if ( aValue == "doublewave" )
     516             :         {
     517           0 :             _descr.Underline = awt::FontUnderline::DOUBLEWAVE;
     518             :         }
     519           0 :         else if ( aValue == "bold" )
     520             :         {
     521           0 :             _descr.Underline = awt::FontUnderline::BOLD;
     522             :         }
     523           0 :         else if ( aValue == "bolddotted" )
     524             :         {
     525           0 :             _descr.Underline = awt::FontUnderline::BOLDDOTTED;
     526             :         }
     527           0 :         else if ( aValue == "bolddash" )
     528             :         {
     529           0 :             _descr.Underline = awt::FontUnderline::BOLDDASH;
     530             :         }
     531           0 :         else if ( aValue == "boldlongdash" )
     532             :         {
     533           0 :             _descr.Underline = awt::FontUnderline::BOLDLONGDASH;
     534             :         }
     535           0 :         else if ( aValue == "bolddashdot" )
     536             :         {
     537           0 :             _descr.Underline = awt::FontUnderline::BOLDDASHDOT;
     538             :         }
     539           0 :         else if ( aValue == "bolddashdotdot" )
     540             :         {
     541           0 :             _descr.Underline = awt::FontUnderline::BOLDDASHDOTDOT;
     542             :         }
     543           0 :         else if ( aValue == "boldwave" )
     544             :         {
     545           0 :             _descr.Underline = awt::FontUnderline::BOLDWAVE;
     546             :         }
     547             :         else
     548             :         {
     549           0 :             throw xml::sax::SAXException("invalid font-underline style!", Reference< XInterface >(), Any() );
     550             :         }
     551           0 :         bFontImport = true;
     552             :     }
     553             : 
     554             :     // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
     555           8 :     if (getStringAttr( &aValue, "font-strikeout", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     556             :     {
     557           0 :         if ( aValue == "single" )
     558             :         {
     559           0 :             _descr.Strikeout = awt::FontStrikeout::SINGLE;
     560             :         }
     561           0 :         else if ( aValue == "double" )
     562             :         {
     563           0 :             _descr.Strikeout = awt::FontStrikeout::DOUBLE;
     564             :         }
     565           0 :         else if ( aValue == "bold" )
     566             :         {
     567           0 :             _descr.Strikeout = awt::FontStrikeout::BOLD;
     568             :         }
     569           0 :         else if ( aValue == "slash" )
     570             :         {
     571           0 :             _descr.Strikeout = awt::FontStrikeout::SLASH;
     572             :         }
     573           0 :         else if ( aValue == "x" )
     574             :         {
     575           0 :             _descr.Strikeout = awt::FontStrikeout::X;
     576             :         }
     577             :         else
     578             :         {
     579           0 :             throw xml::sax::SAXException( "invalid font-strikeout style!" , Reference< XInterface >(), Any() );
     580             :         }
     581           0 :         bFontImport = true;
     582             :     }
     583             : 
     584             :     // dialog:font-orientation CDATA #IMPLIED
     585           8 :     if (getStringAttr( &aValue, "font-orientation", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     586             :     {
     587           0 :         _descr.Orientation = aValue.toFloat();
     588           0 :         bFontImport = true;
     589             :     }
     590             :     // dialog:font-kerning %boolean; #IMPLIED
     591           8 :     bFontImport |= getBoolAttr( &_descr.Kerning, "font-kerning", _xAttributes, _pImport->XMLNS_DIALOGS_UID );
     592             :     // dialog:font-wordlinemode %boolean; #IMPLIED
     593           8 :     bFontImport |= getBoolAttr( &_descr.WordLineMode,"font-wordlinemode", _xAttributes, _pImport->XMLNS_DIALOGS_UID );
     594             : 
     595             :     // dialog:font-type "(raster|device|scalable)" #IMPLIED
     596           8 :     if (getStringAttr( &aValue, "font-type", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     597             :     {
     598           0 :         if ( aValue == "raster" )
     599             :         {
     600           0 :             _descr.Type = awt::FontType::RASTER;
     601             :         }
     602           0 :         else if ( aValue == "device" )
     603             :         {
     604           0 :             _descr.Type = awt::FontType::DEVICE;
     605             :         }
     606           0 :         else if ( aValue == "scalable" )
     607             :         {
     608           0 :             _descr.Type = awt::FontType::SCALABLE;
     609             :         }
     610             :         else
     611             :         {
     612           0 :             throw xml::sax::SAXException( "invalid font-type style!", Reference< XInterface >(), Any() );
     613             :         }
     614           0 :         bFontImport = true;
     615             :     }
     616             : 
     617             :     // additional properties which are not part of the FontDescriptor struct
     618             :     // dialog:font-relief (none|embossed|engraved) #IMPLIED
     619           8 :     if (getStringAttr( &aValue, "font-relief", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     620             :     {
     621           0 :         if ( aValue == "none" )
     622             :         {
     623           0 :             _fontRelief = awt::FontRelief::NONE;
     624             :         }
     625           0 :         else if ( aValue == "embossed" )
     626             :         {
     627           0 :             _fontRelief = awt::FontRelief::EMBOSSED;
     628             :         }
     629           0 :         else if ( aValue == "engraved" )
     630             :         {
     631           0 :             _fontRelief = awt::FontRelief::ENGRAVED;
     632             :         }
     633             :         else
     634             :         {
     635           0 :             throw xml::sax::SAXException("invalid font-relief style!", Reference< XInterface >(), Any() );
     636             :         }
     637           0 :         bFontImport = true;
     638             :     }
     639             :     // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
     640           8 :     if (getStringAttr(&aValue, "font-emphasismark", _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     641             :     {
     642           0 :         if ( aValue == "none" )
     643             :         {
     644           0 :             _fontEmphasisMark = awt::FontEmphasisMark::NONE;
     645             :         }
     646           0 :         else if ( aValue == "dot" )
     647             :         {
     648           0 :             _fontEmphasisMark = awt::FontEmphasisMark::DOT;
     649             :         }
     650           0 :         else if ( aValue == "circle" )
     651             :         {
     652           0 :             _fontEmphasisMark = awt::FontEmphasisMark::CIRCLE;
     653             :         }
     654           0 :         else if ( aValue == "disc" )
     655             :         {
     656           0 :             _fontEmphasisMark = awt::FontEmphasisMark::DISC;
     657             :         }
     658           0 :         else if ( aValue == "accent" )
     659             :         {
     660           0 :             _fontEmphasisMark = awt::FontEmphasisMark::ACCENT;
     661             :         }
     662           0 :         else if ( aValue == "above" )
     663             :         {
     664           0 :             _fontEmphasisMark = awt::FontEmphasisMark::ABOVE;
     665             :         }
     666           0 :         else if ( aValue == "below" )
     667             :         {
     668           0 :             _fontEmphasisMark = awt::FontEmphasisMark::BELOW;
     669             :         }
     670             :         else
     671             :         {
     672           0 :             throw xml::sax::SAXException( "invalid font-emphasismark style!", Reference< XInterface >(), Any() );
     673             :         }
     674           0 :         bFontImport = true;
     675             :     }
     676             : 
     677           8 :     if (bFontImport)
     678             :     {
     679           6 :         _hasValue |= 0x8;
     680           6 :         setFontProperties( xProps );
     681             :     }
     682             : 
     683           8 :     return bFontImport;
     684             : }
     685             : 
     686          48 : bool ImportContext::importStringProperty(
     687             :     OUString const & rPropName, OUString const & rAttrName,
     688             :     Reference< xml::input::XAttributes > const & xAttributes )
     689             : {
     690             :     OUString aValue(
     691          48 :         xAttributes->getValueByUidName(
     692          48 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
     693          48 :     if (!aValue.isEmpty())
     694             :     {
     695           5 :         _xControlModel->setPropertyValue( rPropName, makeAny( aValue ) );
     696           5 :         return true;
     697             :     }
     698          43 :     return false;
     699             : }
     700             : 
     701           0 : bool ImportContext::importDoubleProperty(
     702             :     OUString const & rPropName, OUString const & rAttrName,
     703             :     Reference< xml::input::XAttributes > const & xAttributes )
     704             : {
     705             :     OUString aValue(
     706           0 :         xAttributes->getValueByUidName(
     707           0 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
     708           0 :     if (!aValue.isEmpty())
     709             :     {
     710           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( aValue.toDouble() ) );
     711           0 :         return true;
     712             :     }
     713           0 :     return false;
     714             : }
     715             : 
     716          70 : bool ImportContext::importBooleanProperty(
     717             :     OUString const & rPropName, OUString const & rAttrName,
     718             :     Reference< xml::input::XAttributes > const & xAttributes )
     719             : {
     720             :     sal_Bool bBool;
     721          70 :     if (getBoolAttr(
     722          70 :             &bBool, rAttrName, xAttributes, _pImport->XMLNS_DIALOGS_UID ))
     723             :     {
     724          18 :         _xControlModel->setPropertyValue( rPropName, makeAny( bBool ) );
     725          18 :         return true;
     726             :     }
     727          52 :     return false;
     728             : }
     729             : 
     730          41 : bool ImportContext::importLongProperty(
     731             :     OUString const & rPropName, OUString const & rAttrName,
     732             :     Reference< xml::input::XAttributes > const & xAttributes )
     733             : {
     734             :     OUString aValue(
     735          41 :         xAttributes->getValueByUidName(
     736          41 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
     737          41 :     if (!aValue.isEmpty())
     738             :     {
     739          24 :         _xControlModel->setPropertyValue( rPropName, makeAny( toInt32( aValue ) ) );
     740          24 :         return true;
     741             :     }
     742          17 :     return false;
     743             : }
     744             : 
     745          24 : bool ImportContext::importLongProperty(
     746             :     sal_Int32 nOffset,
     747             :     OUString const & rPropName, OUString const & rAttrName,
     748             :     Reference< xml::input::XAttributes > const & xAttributes )
     749             : {
     750             :     OUString aValue(
     751          24 :         xAttributes->getValueByUidName(
     752          24 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
     753          24 :     if (!aValue.isEmpty())
     754             :     {
     755          24 :         _xControlModel->setPropertyValue( rPropName, makeAny( toInt32( aValue ) + nOffset ) );
     756          24 :         return true;
     757             :     }
     758           0 :     return false;
     759             : }
     760             : 
     761           0 : bool ImportContext::importHexLongProperty(
     762             :     OUString const & rPropName, OUString const & rAttrName,
     763             :     Reference< xml::input::XAttributes > const & xAttributes )
     764             : {
     765             :     OUString aValue(
     766           0 :         xAttributes->getValueByUidName(
     767           0 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
     768           0 :     if (!aValue.isEmpty())
     769             :     {
     770           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( toInt32( aValue ) ) );
     771           0 :         return true;
     772             :     }
     773           0 :     return false;
     774             : }
     775             : 
     776          18 : bool ImportContext::importShortProperty(
     777             :     OUString const & rPropName, OUString const & rAttrName,
     778             :     Reference< xml::input::XAttributes > const & xAttributes )
     779             : {
     780             :     OUString aValue(
     781          18 :         xAttributes->getValueByUidName(
     782          18 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
     783          18 :     if (!aValue.isEmpty())
     784             :     {
     785           9 :         _xControlModel->setPropertyValue( rPropName, makeAny( (sal_Int16)toInt32( aValue ) ) );
     786           9 :         return true;
     787             :     }
     788           9 :     return false;
     789             : }
     790             : 
     791           8 : bool ImportContext::importAlignProperty(
     792             :     OUString const & rPropName, OUString const & rAttrName,
     793             :     Reference< xml::input::XAttributes > const & xAttributes )
     794             : {
     795             :     OUString aAlign(
     796           8 :         xAttributes->getValueByUidName(
     797           8 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
     798           8 :     if (!aAlign.isEmpty())
     799             :     {
     800             :         sal_Int16 nAlign;
     801           0 :         if ( aAlign == "left" )
     802             :         {
     803           0 :             nAlign = 0;
     804             :         }
     805           0 :         else if ( aAlign == "center" )
     806             :         {
     807           0 :             nAlign = 1;
     808             :         }
     809           0 :         else if ( aAlign == "right" )
     810             :         {
     811           0 :             nAlign = 2;
     812             :         }
     813           0 :         else if ( aAlign == "none" )
     814             :         {
     815           0 :             nAlign = 0; // default
     816             :         }
     817             :         else
     818             :         {
     819           0 :             throw xml::sax::SAXException("invalid align value!", Reference< XInterface >(), Any() );
     820             :         }
     821             : 
     822           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( nAlign ) );
     823           0 :         return true;
     824             :     }
     825           8 :     return false;
     826             : }
     827             : 
     828           3 : bool ImportContext::importVerticalAlignProperty(
     829             :     OUString const & rPropName, OUString const & rAttrName,
     830             :     Reference< xml::input::XAttributes > const & xAttributes )
     831             : {
     832             :     OUString aAlign(
     833           3 :         xAttributes->getValueByUidName(
     834           3 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
     835           3 :     if (!aAlign.isEmpty())
     836             :     {
     837             :         style::VerticalAlignment eAlign;
     838             : 
     839           3 :         if ( aAlign == "top" )
     840             :         {
     841           0 :             eAlign = style::VerticalAlignment_TOP;
     842             :         }
     843           3 :         else if ( aAlign == "center" )
     844             :         {
     845           3 :             eAlign = style::VerticalAlignment_MIDDLE;
     846             :         }
     847           0 :         else if ( aAlign == "bottom" )
     848             :         {
     849           0 :             eAlign = style::VerticalAlignment_BOTTOM;
     850             :         }
     851             :         else
     852             :         {
     853           0 :             throw xml::sax::SAXException( "invalid vertical align value!", Reference< XInterface >(), Any() );
     854             :         }
     855             : 
     856           3 :         _xControlModel->setPropertyValue( rPropName, makeAny( eAlign ) );
     857           3 :         return true;
     858             :     }
     859           0 :     return false;
     860             : }
     861             : 
     862           7 : bool ImportContext::importImageURLProperty(
     863             :     OUString const & rPropName, OUString const & rAttrName,
     864             :     Reference< xml::input::XAttributes > const & xAttributes )
     865             : {
     866           7 :     OUString sURL = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, rAttrName );
     867           7 :     if ( !sURL.isEmpty() )
     868             :     {
     869           0 :         Reference< document::XStorageBasedDocument > xDocStorage( _pImport->getDocOwner(), UNO_QUERY );
     870             : 
     871           0 :         uno::Reference< document::XGraphicObjectResolver > xGraphicResolver;
     872           0 :         if ( xDocStorage.is() )
     873             :         {
     874           0 :             uno::Sequence< Any > aArgs( 1 );
     875           0 :             aArgs[ 0 ] <<= xDocStorage->getDocumentStorage();
     876             :             xGraphicResolver.set(
     877           0 :                 _pImport->getComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.comp.Svx.GraphicImportHelper" , aArgs, _pImport->getComponentContext() ),
     878           0 :                 UNO_QUERY );
     879           0 :             if ( xGraphicResolver.is() )
     880             :             {
     881           0 :                 OUString aTmp("vnd.sun.star.Package:");
     882           0 :                 aTmp += sURL;
     883             :                 try
     884             :                 {
     885           0 :                     aTmp = xGraphicResolver->resolveGraphicObjectURL( aTmp );
     886           0 :                     if ( !aTmp.isEmpty() )
     887           0 :                         sURL = aTmp;
     888             :                 }
     889           0 :                 catch( const uno::Exception& )
     890             :                 {
     891           0 :                     return false;
     892           0 :                 }
     893             : 
     894           0 :             }
     895             :         }
     896           0 :         if ( !sURL.isEmpty() )
     897             :         {
     898           0 :             Reference< beans::XPropertySet > xProps( getControlModel(), UNO_QUERY );
     899           0 :             if ( xProps.is() )
     900             :             {
     901           0 :                 xProps->setPropertyValue( rPropName, makeAny( sURL ) );
     902           0 :                 return true;
     903           0 :             }
     904           0 :         }
     905             :     }
     906           7 :     return false;
     907             : }
     908             : 
     909           5 : bool ImportContext::importDataAwareProperty(
     910             :         OUString const & rPropName,
     911             :         Reference<xml::input::XAttributes> const & xAttributes )
     912             : {
     913           5 :     OUString sLinkedCell;
     914          10 :     OUString sCellRange;
     915           5 :     if ( rPropName.equals( "linked-cell" ) )
     916           3 :        sLinkedCell = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, rPropName );
     917           5 :     if ( rPropName.equals( "source-cell-range" ) )
     918           2 :         sCellRange = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, rPropName );
     919           5 :     bool bRes = false;
     920          10 :     Reference< lang::XMultiServiceFactory > xFac( _pImport->getDocOwner(), UNO_QUERY );
     921           5 :     if ( xFac.is() && ( !sLinkedCell.isEmpty() ||  !sCellRange.isEmpty() ) )
     922             :     {
     923             :         // Set up Celllink
     924           1 :         if ( !sLinkedCell.isEmpty() )
     925             :         {
     926           0 :             Reference< form::binding::XBindableValue > xBindable( getControlModel(), uno::UNO_QUERY );
     927           0 :             Reference< beans::XPropertySet > xConvertor( xFac->createInstance( "com.sun.star.table.CellAddressConversion" ), uno::UNO_QUERY );
     928           0 :             if ( xBindable.is() && xConvertor.is() )
     929             :             {
     930           0 :                 table::CellAddress aAddress;
     931           0 :                 xConvertor->setPropertyValue( "PersistentRepresentation" , uno::makeAny( sLinkedCell ) );
     932           0 :                 xConvertor->getPropertyValue( "Address" ) >>= aAddress;
     933           0 :                 beans::NamedValue aArg1;
     934           0 :                 aArg1.Name = "BoundCell";
     935           0 :                 aArg1.Value <<= aAddress;
     936             : 
     937           0 :                 uno::Sequence< uno::Any > aArgs(1);
     938           0 :                 aArgs[ 0 ]  <<= aArg1;
     939             : 
     940           0 :                 uno::Reference< form::binding::XValueBinding > xBinding( xFac->createInstanceWithArguments( "com.sun.star.table.CellValueBinding" , aArgs ), uno::UNO_QUERY );
     941           0 :                 xBindable->setValueBinding( xBinding );
     942           0 :                 bRes = true;
     943           0 :             }
     944             :         }
     945             :         // Set up CelllRange
     946           1 :         if ( !sCellRange.isEmpty() )
     947             :         {
     948           1 :             Reference< form::binding::XListEntrySink  > xListEntrySink( getControlModel(), uno::UNO_QUERY );
     949           2 :             Reference< beans::XPropertySet > xConvertor( xFac->createInstance( "com.sun.star.table.CellRangeAddressConversion" ), uno::UNO_QUERY );
     950           1 :             if ( xListEntrySink.is() && xConvertor.is() )
     951             :             {
     952           1 :                 table::CellRangeAddress aAddress;
     953           1 :                 xConvertor->setPropertyValue( "PersistentRepresentation" , uno::makeAny( sCellRange ) );
     954           1 :                 xConvertor->getPropertyValue( "Address" ) >>= aAddress;
     955           1 :                 beans::NamedValue aArg1;
     956           1 :                 aArg1.Name = "CellRange";
     957           1 :                 aArg1.Value <<= aAddress;
     958             : 
     959           2 :                 uno::Sequence< uno::Any > aArgs(1);
     960           1 :                 aArgs[ 0 ]  <<= aArg1;
     961             : 
     962           2 :                 uno::Reference< form::binding::XListEntrySource > xSource( xFac->createInstanceWithArguments( "com.sun.star.table.CellRangeListSource" , aArgs ), uno::UNO_QUERY );
     963           1 :                 xListEntrySink->setListEntrySource( xSource );
     964           2 :                 bRes = true;
     965           1 :             }
     966             :         }
     967             :     }
     968          10 :     return bRes;
     969             : }
     970             : 
     971           1 : bool ImportContext::importImageAlignProperty(
     972             :     OUString const & rPropName, OUString const & rAttrName,
     973             :     Reference< xml::input::XAttributes > const & xAttributes )
     974             : {
     975             :     OUString aAlign(
     976           1 :         xAttributes->getValueByUidName(
     977           1 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
     978           1 :     if (!aAlign.isEmpty())
     979             :     {
     980             :         sal_Int16 nAlign;
     981           0 :         if ( aAlign == "left" )
     982             :         {
     983           0 :             nAlign = 0;
     984             :         }
     985           0 :         else if ( aAlign == "top" )
     986             :         {
     987           0 :             nAlign = 1;
     988             :         }
     989           0 :         else if ( aAlign == "right" )
     990             :         {
     991           0 :             nAlign = 2;
     992             :         }
     993           0 :         else if ( aAlign == "bottom" )
     994             :         {
     995           0 :             nAlign = 3;
     996             :         }
     997             :         else
     998             :         {
     999           0 :             throw xml::sax::SAXException( "invalid image align value!", Reference< XInterface >(), Any() );
    1000             :         }
    1001             : 
    1002           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( nAlign ) );
    1003           0 :         return true;
    1004             :     }
    1005           1 :     return false;
    1006             : }
    1007             : 
    1008           3 : bool ImportContext::importImagePositionProperty(
    1009             :     OUString const & rPropName, OUString const & rAttrName,
    1010             :     Reference< xml::input::XAttributes > const & xAttributes )
    1011             : {
    1012             :     OUString aPosition(
    1013           3 :         xAttributes->getValueByUidName(
    1014           3 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
    1015           3 :     if (!aPosition.isEmpty())
    1016             :     {
    1017             :         sal_Int16 nPosition;
    1018           3 :         if ( aPosition == "left-top" )
    1019             :         {
    1020           0 :             nPosition = awt::ImagePosition::LeftTop;
    1021             :         }
    1022           3 :         else if ( aPosition == "left-center" )
    1023             :         {
    1024           0 :             nPosition = awt::ImagePosition::LeftCenter;
    1025             :         }
    1026           3 :         else if ( aPosition == "left-bottom" )
    1027             :         {
    1028           0 :             nPosition = awt::ImagePosition::LeftBottom;
    1029             :         }
    1030           3 :         else if ( aPosition == "right-top" )
    1031             :         {
    1032           0 :             nPosition = awt::ImagePosition::RightTop;
    1033             :         }
    1034           3 :         else if ( aPosition == "right-center" )
    1035             :         {
    1036           0 :             nPosition = awt::ImagePosition::RightCenter;
    1037             :         }
    1038           3 :         else if ( aPosition == "right-bottom" )
    1039             :         {
    1040           0 :             nPosition = awt::ImagePosition::RightBottom;
    1041             :         }
    1042           3 :         else if ( aPosition == "top-left" )
    1043             :         {
    1044           0 :             nPosition = awt::ImagePosition::AboveLeft;
    1045             :         }
    1046           3 :         else if ( aPosition == "top-center" )
    1047             :         {
    1048           3 :             nPosition = awt::ImagePosition::AboveCenter;
    1049             :         }
    1050           0 :         else if ( aPosition == "top-right" )
    1051             :         {
    1052           0 :             nPosition = awt::ImagePosition::AboveRight;
    1053             :         }
    1054           0 :         else if ( aPosition == "bottom-left" )
    1055             :         {
    1056           0 :             nPosition = awt::ImagePosition::BelowLeft;
    1057             :         }
    1058           0 :         else if ( aPosition == "bottom-center" )
    1059             :         {
    1060           0 :             nPosition = awt::ImagePosition::BelowCenter;
    1061             :         }
    1062           0 :         else if ( aPosition == "bottom-right" )
    1063             :         {
    1064           0 :             nPosition = awt::ImagePosition::BelowRight;
    1065             :         }
    1066           0 :         else if ( aPosition == "center" )
    1067             :         {
    1068           0 :             nPosition = awt::ImagePosition::Centered;
    1069             :         }
    1070             :         else
    1071             :         {
    1072           0 :             throw xml::sax::SAXException( "invalid image position value!", Reference< XInterface >(), Any() );
    1073             :         }
    1074             : 
    1075           3 :         _xControlModel->setPropertyValue( rPropName, makeAny( nPosition ) );
    1076           3 :         return true;
    1077             :     }
    1078           0 :     return false;
    1079             : }
    1080             : 
    1081           1 : bool ImportContext::importButtonTypeProperty(
    1082             :     OUString const & rPropName, OUString const & rAttrName,
    1083             :     Reference< xml::input::XAttributes > const & xAttributes )
    1084             : {
    1085             :     OUString buttonType(
    1086           1 :         xAttributes->getValueByUidName(
    1087           1 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
    1088           1 :     if (!buttonType.isEmpty())
    1089             :     {
    1090             :         sal_Int16 nButtonType;
    1091           0 :         if ( buttonType == "standard" )
    1092             :         {
    1093           0 :             nButtonType = awt::PushButtonType_STANDARD;
    1094             :         }
    1095           0 :         else if ( buttonType == "ok" )
    1096             :         {
    1097           0 :             nButtonType = awt::PushButtonType_OK;
    1098             :         }
    1099           0 :         else if ( buttonType == "cancel" )
    1100             :         {
    1101           0 :             nButtonType = awt::PushButtonType_CANCEL;
    1102             :         }
    1103           0 :         else if ( buttonType == "help" )
    1104             :         {
    1105           0 :             nButtonType = awt::PushButtonType_HELP;
    1106             :         }
    1107             :         else
    1108             :         {
    1109           0 :             throw xml::sax::SAXException( "invalid button-type value!", Reference< XInterface >(), Any() );
    1110             :         }
    1111             : 
    1112           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( nButtonType ) );
    1113           0 :         return true;
    1114             :     }
    1115           1 :     return false;
    1116             : }
    1117             : 
    1118           0 : bool ImportContext::importDateFormatProperty(
    1119             :     OUString const & rPropName, OUString const & rAttrName,
    1120             :     Reference< xml::input::XAttributes > const & xAttributes )
    1121             : {
    1122             :     OUString aFormat(
    1123           0 :         xAttributes->getValueByUidName(
    1124           0 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
    1125           0 :     if (!aFormat.isEmpty())
    1126             :     {
    1127             :         sal_Int16 nFormat;
    1128           0 :         if ( aFormat == "system_short" )
    1129             :         {
    1130           0 :             nFormat = 0;
    1131             :         }
    1132           0 :         else if ( aFormat == "system_short_YY" )
    1133             :         {
    1134           0 :             nFormat = 1;
    1135             :         }
    1136           0 :         else if ( aFormat == "system_short_YYYY" )
    1137             :         {
    1138           0 :             nFormat = 2;
    1139             :         }
    1140           0 :         else if ( aFormat == "system_long" )
    1141             :         {
    1142           0 :             nFormat = 3;
    1143             :         }
    1144           0 :         else if ( aFormat == "short_DDMMYY" )
    1145             :         {
    1146           0 :             nFormat = 4;
    1147             :         }
    1148           0 :         else if ( aFormat == "short_MMDDYY" )
    1149             :         {
    1150           0 :             nFormat = 5;
    1151             :         }
    1152           0 :         else if ( aFormat == "short_YYMMDD" )
    1153             :         {
    1154           0 :             nFormat = 6;
    1155             :         }
    1156           0 :         else if ( aFormat == "short_DDMMYYYY" )
    1157             :         {
    1158           0 :             nFormat = 7;
    1159             :         }
    1160           0 :         else if ( aFormat == "short_MMDDYYYY" )
    1161             :         {
    1162           0 :             nFormat = 8;
    1163             :         }
    1164           0 :         else if ( aFormat == "short_YYYYMMDD" )
    1165             :         {
    1166           0 :             nFormat = 9;
    1167             :         }
    1168           0 :         else if ( aFormat == "short_YYMMDD_DIN5008" )
    1169             :         {
    1170           0 :             nFormat = 10;
    1171             :         }
    1172           0 :         else if ( aFormat == "short_YYYYMMDD_DIN5008" )
    1173             :         {
    1174           0 :             nFormat = 11;
    1175             :         }
    1176             :         else
    1177             :         {
    1178           0 :             throw xml::sax::SAXException( "invalid date-format value!", Reference< XInterface >(), Any() );
    1179             :         }
    1180             : 
    1181           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) );
    1182           0 :         return true;
    1183             :     }
    1184           0 :     return false;
    1185             : }
    1186             : 
    1187           0 : bool ImportContext::importTimeProperty(
    1188             :     OUString const & rPropName, OUString const & rAttrName,
    1189             :     Reference< xml::input::XAttributes > const & xAttributes )
    1190             : {
    1191             :     OUString aValue(
    1192           0 :         xAttributes->getValueByUidName(
    1193           0 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
    1194           0 :     if (!aValue.isEmpty())
    1195             :     {
    1196           0 :         ::Time aTTime(toInt32( aValue ) * ::Time::nanoPerCenti);
    1197           0 :         util::Time aUTime(aTTime.GetUNOTime());
    1198           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( aUTime ) );
    1199           0 :         return true;
    1200             :     }
    1201           0 :     return false;
    1202             : }
    1203             : 
    1204           0 : bool ImportContext::importDateProperty(
    1205             :     OUString const & rPropName, OUString const & rAttrName,
    1206             :     Reference< xml::input::XAttributes > const & xAttributes )
    1207             : {
    1208             :     OUString aValue(
    1209           0 :         xAttributes->getValueByUidName(
    1210           0 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
    1211           0 :     if (!aValue.isEmpty())
    1212             :     {
    1213           0 :         ::Date aTDate(toInt32( aValue ));
    1214           0 :         util::Date aUDate(aTDate.GetUNODate());
    1215           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( aUDate ) );
    1216           0 :         return true;
    1217             :     }
    1218           0 :     return false;
    1219             : }
    1220             : 
    1221           0 : bool ImportContext::importTimeFormatProperty(
    1222             :     OUString const & rPropName, OUString const & rAttrName,
    1223             :     Reference< xml::input::XAttributes > const & xAttributes )
    1224             : {
    1225             :     OUString aFormat(
    1226           0 :         xAttributes->getValueByUidName(
    1227           0 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
    1228           0 :     if (!aFormat.isEmpty())
    1229             :     {
    1230             :         sal_Int16 nFormat;
    1231           0 :         if ( aFormat == "24h_short" )
    1232             :         {
    1233           0 :             nFormat = 0;
    1234             :         }
    1235           0 :         else if ( aFormat == "24h_long" )
    1236             :         {
    1237           0 :             nFormat = 1;
    1238             :         }
    1239           0 :         else if ( aFormat == "12h_short" )
    1240             :         {
    1241           0 :             nFormat = 2;
    1242             :         }
    1243           0 :         else if ( aFormat == "12h_long" )
    1244             :         {
    1245           0 :             nFormat = 3;
    1246             :         }
    1247           0 :         else if ( aFormat == "Duration_short" )
    1248             :         {
    1249           0 :             nFormat = 4;
    1250             :         }
    1251           0 :         else if ( aFormat == "Duration_long" )
    1252             :         {
    1253           0 :             nFormat = 5;
    1254             :         }
    1255             :         else
    1256             :         {
    1257           0 :             throw xml::sax::SAXException( "invalid time-format value!", Reference< XInterface >(), Any() );
    1258             :         }
    1259             : 
    1260           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) );
    1261           0 :         return true;
    1262             :     }
    1263           0 :     return false;
    1264             : }
    1265             : 
    1266           0 : bool ImportContext::importOrientationProperty(
    1267             :     OUString const & rPropName, OUString const & rAttrName,
    1268             :     Reference< xml::input::XAttributes > const & xAttributes )
    1269             : {
    1270             :     OUString aOrient(
    1271           0 :         xAttributes->getValueByUidName(
    1272           0 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
    1273           0 :     if (!aOrient.isEmpty())
    1274             :     {
    1275             :         sal_Int32 nOrient;
    1276           0 :         if ( aOrient == "horizontal" )
    1277             :         {
    1278           0 :             nOrient = 0;
    1279             :         }
    1280           0 :         else if ( aOrient == "vertical" )
    1281             :         {
    1282           0 :             nOrient = 1;
    1283             :         }
    1284             :         else
    1285             :         {
    1286           0 :             throw xml::sax::SAXException( "invalid orientation value!", Reference< XInterface >(), Any() );
    1287             :         }
    1288             : 
    1289           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( nOrient ) );
    1290           0 :         return true;
    1291             :     }
    1292           0 :     return false;
    1293             : }
    1294             : 
    1295           3 : bool ImportContext::importLineEndFormatProperty(
    1296             :     OUString const & rPropName, OUString const & rAttrName,
    1297             :     Reference< xml::input::XAttributes > const & xAttributes )
    1298             : {
    1299             :     OUString aFormat(
    1300           3 :         xAttributes->getValueByUidName(
    1301           3 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
    1302           3 :     if (!aFormat.isEmpty())
    1303             :     {
    1304             :         sal_Int16 nFormat;
    1305           0 :         if ( aFormat == "carriage-return" )
    1306             :         {
    1307           0 :             nFormat = awt::LineEndFormat::CARRIAGE_RETURN;
    1308             :         }
    1309           0 :         else if ( aFormat == "line-feed" )
    1310             :         {
    1311           0 :             nFormat = awt::LineEndFormat::LINE_FEED;
    1312             :         }
    1313           0 :         else if ( aFormat == "carriage-return-line-feed" )
    1314             :         {
    1315           0 :             nFormat = awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED;
    1316             :         }
    1317             :         else
    1318             :         {
    1319           0 :             throw xml::sax::SAXException( "invalid line end format value!", Reference< XInterface >(), Any() );
    1320             :         }
    1321             : 
    1322           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) );
    1323           0 :         return true;
    1324             :     }
    1325           3 :     return false;
    1326             : }
    1327             : 
    1328           0 : bool ImportContext::importSelectionTypeProperty(
    1329             :     OUString const & rPropName, OUString const & rAttrName,
    1330             :     Reference< xml::input::XAttributes > const & xAttributes )
    1331             : {
    1332             :     OUString aSelectionType(
    1333           0 :         xAttributes->getValueByUidName(
    1334           0 :             _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
    1335           0 :     if (!aSelectionType.isEmpty())
    1336             :     {
    1337             :         view::SelectionType eSelectionType;
    1338             : 
    1339           0 :         if ( aSelectionType == "none" )
    1340             :         {
    1341           0 :             eSelectionType = view::SelectionType_NONE;
    1342             :         }
    1343           0 :         else if ( aSelectionType == "single" )
    1344             :         {
    1345           0 :             eSelectionType = view::SelectionType_SINGLE;
    1346             :         }
    1347           0 :         else if ( aSelectionType == "multi" )
    1348             :         {
    1349           0 :             eSelectionType = view::SelectionType_MULTI;
    1350             :         }
    1351           0 :         else  if ( aSelectionType == "range" )
    1352             :         {
    1353           0 :             eSelectionType = view::SelectionType_RANGE;
    1354             :         }
    1355             :         else
    1356             :         {
    1357           0 :             throw xml::sax::SAXException( "invalid selection type value!", Reference< XInterface >(), Any() );
    1358             :         }
    1359             : 
    1360           0 :         _xControlModel->setPropertyValue( rPropName, makeAny( eSelectionType ) );
    1361           0 :         return true;
    1362             :     }
    1363           0 :     return false;
    1364             : }
    1365             : 
    1366             : struct StringTriple
    1367             : {
    1368             :     char const * first;
    1369             :     char const * second;
    1370             :     char const * third;
    1371             : };
    1372             : static StringTriple const s_aEventTranslations[] =
    1373             : {
    1374             :     // from xmloff/source/forms/formevents.cxx
    1375             :     // 28.09.2001 tbe added on-adjustmentvaluechange
    1376             :     { "com.sun.star.form.XApproveActionListener", "approveAction", "on-approveaction" },
    1377             :     { "com.sun.star.awt.XActionListener", "actionPerformed", "on-performaction" },
    1378             :     { "com.sun.star.form.XChangeListener", "changed", "on-change" },
    1379             :     { "com.sun.star.awt.XTextListener", "textChanged", "on-textchange" },
    1380             :     { "com.sun.star.awt.XItemListener", "itemStateChanged", "on-itemstatechange" },
    1381             :     { "com.sun.star.awt.XFocusListener", "focusGained", "on-focus" },
    1382             :     { "com.sun.star.awt.XFocusListener", "focusLost", "on-blur" },
    1383             :     { "com.sun.star.awt.XKeyListener", "keyPressed", "on-keydown" },
    1384             :     { "com.sun.star.awt.XKeyListener", "keyReleased", "on-keyup" },
    1385             :     { "com.sun.star.awt.XMouseListener", "mouseEntered", "on-mouseover" },
    1386             :     { "com.sun.star.awt.XMouseMotionListener", "mouseDragged", "on-mousedrag" },
    1387             :     { "com.sun.star.awt.XMouseMotionListener", "mouseMoved", "on-mousemove" },
    1388             :     { "com.sun.star.awt.XMouseListener", "mousePressed", "on-mousedown" },
    1389             :     { "com.sun.star.awt.XMouseListener", "mouseReleased", "on-mouseup" },
    1390             :     { "com.sun.star.awt.XMouseListener", "mouseExited", "on-mouseout" },
    1391             :     { "com.sun.star.form.XResetListener", "approveReset", "on-approvereset" },
    1392             :     { "com.sun.star.form.XResetListener", "resetted", "on-reset" },
    1393             :     { "com.sun.star.form.XSubmitListener", "approveSubmit", "on-submit" },
    1394             :     { "com.sun.star.form.XUpdateListener", "approveUpdate", "on-approveupdate" },
    1395             :     { "com.sun.star.form.XUpdateListener", "updated", "on-update" },
    1396             :     { "com.sun.star.form.XLoadListener", "loaded", "on-load" },
    1397             :     { "com.sun.star.form.XLoadListener", "reloading", "on-startreload" },
    1398             :     { "com.sun.star.form.XLoadListener", "reloaded", "on-reload" },
    1399             :     { "com.sun.star.form.XLoadListener", "unloading", "on-startunload" },
    1400             :     { "com.sun.star.form.XLoadListener", "unloaded", "on-unload" },
    1401             :     { "com.sun.star.form.XConfirmDeleteListener", "confirmDelete", "on-confirmdelete" },
    1402             :     { "com.sun.star.sdb.XRowSetApproveListener", "approveRowChange", "on-approverowchange" },
    1403             :     { "com.sun.star.sdbc.XRowSetListener", "rowChanged", "on-rowchange" },
    1404             :     { "com.sun.star.sdb.XRowSetApproveListener", "approveCursorMove", "on-approvecursormove" },
    1405             :     { "com.sun.star.sdbc.XRowSetListener", "cursorMoved", "on-cursormove" },
    1406             :     { "com.sun.star.form.XDatabaseParameterListener", "approveParameter", "on-supplyparameter" },
    1407             :     { "com.sun.star.sdb.XSQLErrorListener", "errorOccured", "on-error" },
    1408             :     { "com.sun.star.awt.XAdjustmentListener", "adjustmentValueChanged", "on-adjustmentvaluechange" },
    1409             :     { 0, 0, 0 }
    1410             : };
    1411             : extern StringTriple const * const g_pEventTranslations;
    1412             : StringTriple const * const g_pEventTranslations = s_aEventTranslations;
    1413             : 
    1414          12 : void ImportContext::importEvents(
    1415             :     ::std::vector< Reference< xml::input::XElement > > const & rEvents )
    1416             : {
    1417             :     Reference< script::XScriptEventsSupplier > xSupplier(
    1418          12 :         _xControlModel, UNO_QUERY );
    1419          12 :     if (xSupplier.is())
    1420             :     {
    1421          12 :         Reference< container::XNameContainer > xEvents( xSupplier->getEvents() );
    1422          12 :         if (xEvents.is())
    1423             :         {
    1424          12 :             for ( size_t nPos = 0; nPos < rEvents.size(); ++nPos )
    1425             :             {
    1426           0 :                 script::ScriptEventDescriptor descr;
    1427             : 
    1428           0 :                 EventElement * pEventElement = static_cast< EventElement * >( rEvents[ nPos ].get() );
    1429           0 :                 sal_Int32 nUid = pEventElement->getUid();
    1430           0 :                 OUString aLocalName( pEventElement->getLocalName() );
    1431           0 :                 Reference< xml::input::XAttributes > xAttributes( pEventElement->getAttributes() );
    1432             : 
    1433             :                 // nowadays script events
    1434           0 :                 if (_pImport->XMLNS_SCRIPT_UID == nUid)
    1435             :                 {
    1436           0 :                     if (!getStringAttr( &descr.ScriptType, "language"  , xAttributes, _pImport->XMLNS_SCRIPT_UID ) ||
    1437           0 :                         !getStringAttr( &descr.ScriptCode, "macro-name", xAttributes, _pImport->XMLNS_SCRIPT_UID ))
    1438             :                     {
    1439           0 :                         throw xml::sax::SAXException( "missing language or macro-name attribute(s) of event!", Reference< XInterface >(), Any() );
    1440             :                     }
    1441           0 :                     if ( descr.ScriptType == "StarBasic" )
    1442             :                     {
    1443           0 :                         OUString aLocation;
    1444           0 :                         if (getStringAttr( &aLocation, "location", xAttributes, _pImport->XMLNS_SCRIPT_UID ))
    1445             :                         {
    1446             :                             // prepend location
    1447           0 :                             descr.ScriptCode = aLocation + ":" + descr.ScriptCode;
    1448           0 :                         }
    1449             :                     }
    1450           0 :                     else if ( descr.ScriptType == "Script" )
    1451             :                     {
    1452             :                         // Check if there is a protocol, if not assume
    1453             :                         // this is an early scripting framework url ( without
    1454             :                         // the protocol ) and fix it up!!
    1455           0 :                         if ( descr.ScriptCode.indexOf( ':' ) == -1 )
    1456             :                         {
    1457           0 :                             descr.ScriptCode = "vnd.sun.start.script:" + descr.ScriptCode;
    1458             :                         }
    1459             :                     }
    1460             : 
    1461             :                     // script:event element
    1462           0 :                     if ( aLocalName == "event" )
    1463             :                     {
    1464           0 :                         OUString aEventName;
    1465           0 :                         if (! getStringAttr( &aEventName, "event-name", xAttributes, _pImport->XMLNS_SCRIPT_UID ))
    1466             :                         {
    1467           0 :                             throw xml::sax::SAXException( "missing event-name attribute!", Reference< XInterface >(), Any() );
    1468             :                         }
    1469             : 
    1470             :                         // lookup in table
    1471           0 :                         OString str( OUStringToOString( aEventName, RTL_TEXTENCODING_ASCII_US ) );
    1472           0 :                         StringTriple const * p = g_pEventTranslations;
    1473           0 :                         while (p->first)
    1474             :                         {
    1475           0 :                             if (0 == ::rtl_str_compare( p->third, str.getStr() ))
    1476             :                             {
    1477           0 :                                 descr.ListenerType = OUString(
    1478             :                                     p->first, ::rtl_str_getLength( p->first ),
    1479           0 :                                     RTL_TEXTENCODING_ASCII_US );
    1480           0 :                                 descr.EventMethod = OUString(
    1481             :                                     p->second, ::rtl_str_getLength( p->second ),
    1482           0 :                                     RTL_TEXTENCODING_ASCII_US );
    1483           0 :                                 break;
    1484             :                             }
    1485           0 :                             ++p;
    1486             :                         }
    1487             : 
    1488           0 :                         if (! p->first)
    1489             :                         {
    1490           0 :                             throw xml::sax::SAXException( "no matching event-name found!", Reference< XInterface >(), Any() );
    1491           0 :                         }
    1492             :                     }
    1493             :                     else // script:listener-event element
    1494             :                     {
    1495             :                         SAL_WARN_IF( aLocalName != "listener-event", "xmlscript.xmldlg", "aLocalName != listener-event" );
    1496             : 
    1497           0 :                         if (!getStringAttr( &descr.ListenerType, "listener-type"  , xAttributes, _pImport->XMLNS_SCRIPT_UID ) ||
    1498           0 :                             !getStringAttr( &descr.EventMethod , "listener-method", xAttributes, _pImport->XMLNS_SCRIPT_UID ))
    1499             :                         {
    1500           0 :                             throw xml::sax::SAXException("missing listener-type or listener-method attribute(s)!", Reference< XInterface >(), Any() );
    1501             :                         }
    1502             :                         // optional listener param
    1503           0 :                         getStringAttr( &descr.AddListenerParam,  "listener-param", xAttributes, _pImport->XMLNS_SCRIPT_UID );
    1504             :                     }
    1505             :                 }
    1506             :                 else // deprecated dlg:event element
    1507             :                 {
    1508             :                     SAL_WARN_IF( _pImport->XMLNS_DIALOGS_UID != nUid || aLocalName != "event", "xmlscript.xmldlg", "_pImport->XMLNS_DIALOGS_UID != nUid || aLocalName != \"event\"" );
    1509             : 
    1510           0 :                     if (!getStringAttr( &descr.ListenerType, "listener-type", xAttributes, _pImport->XMLNS_DIALOGS_UID ) ||
    1511           0 :                         !getStringAttr( &descr.EventMethod,  "event-method",  xAttributes, _pImport->XMLNS_DIALOGS_UID ))
    1512             :                     {
    1513           0 :                         throw xml::sax::SAXException("missing listener-type or event-method attribute(s)!", Reference< XInterface >(), Any() );
    1514             :                     }
    1515             : 
    1516           0 :                     getStringAttr( &descr.ScriptType, "script-type", xAttributes, _pImport->XMLNS_DIALOGS_UID );
    1517           0 :                     getStringAttr( &descr.ScriptCode, "script-code", xAttributes, _pImport->XMLNS_DIALOGS_UID );
    1518           0 :                     getStringAttr( &descr.AddListenerParam, "param", xAttributes, _pImport->XMLNS_DIALOGS_UID );
    1519             :                 }
    1520             : 
    1521           0 :                 xEvents->insertByName( descr.ListenerType + "::" + descr.EventMethod, makeAny( descr ) );
    1522           0 :             }
    1523          12 :         }
    1524          12 :     }
    1525          12 : }
    1526           4 : void ImportContext::importScollableSettings(
    1527             :     Reference< xml::input::XAttributes > const & _xAttributes )
    1528             : {
    1529             :     importLongProperty( OUString( "ScrollHeight" ),
    1530             :                         OUString( "scrollheight" ),
    1531           4 :                         _xAttributes );
    1532             :     importLongProperty( OUString( "ScrollWidth" ),
    1533             :                         OUString( "scrollwidth" ),
    1534           4 :                         _xAttributes );
    1535             :     importLongProperty( OUString( "ScrollTop" ),
    1536             :                         OUString( "scrolltop" ),
    1537           4 :                         _xAttributes );
    1538             :     importLongProperty( OUString( "ScrollLeft" ),
    1539             :                         OUString( "scrollleft" ),
    1540           4 :                         _xAttributes );
    1541             :     importBooleanProperty( OUString( "HScroll" ),
    1542             :                            OUString( "hscroll" ),
    1543           4 :                            _xAttributes );
    1544             :     importBooleanProperty( OUString( "VScroll" ),
    1545             :                            OUString( "vscroll" ),
    1546           4 :                            _xAttributes );
    1547           4 : }
    1548             : 
    1549          12 : void ImportContext::importDefaults(
    1550             :     sal_Int32 nBaseX, sal_Int32 nBaseY,
    1551             :     Reference< xml::input::XAttributes > const & xAttributes,
    1552             :     bool supportPrintable )
    1553             : {
    1554          12 :     _xControlModel->setPropertyValue( "Name", makeAny( _aId ) );
    1555             : 
    1556          12 :     importShortProperty( "TabIndex", "tab-index", xAttributes );
    1557             : 
    1558          12 :     sal_Bool bDisable = sal_False;
    1559          12 :     if (getBoolAttr( &bDisable,"disabled", xAttributes, _pImport->XMLNS_DIALOGS_UID ) && bDisable)
    1560             :     {
    1561           0 :         _xControlModel->setPropertyValue( "Enabled", makeAny( sal_False ) );
    1562             :     }
    1563             : 
    1564          12 :     sal_Bool bVisible = sal_True;
    1565          12 :     if (getBoolAttr( &bVisible, "visible", xAttributes, _pImport->XMLNS_DIALOGS_UID ) && !bVisible)
    1566             :     {
    1567             :     try
    1568             :     {
    1569           0 :             _xControlModel->setPropertyValue( "EnableVisible", makeAny( sal_False ) );
    1570             :     }
    1571           0 :     catch( Exception& )
    1572             :     {
    1573             :         DBG_UNHANDLED_EXCEPTION();
    1574             :     }
    1575             :     }
    1576             : 
    1577          96 :     if (!importLongProperty( nBaseX, "PositionX", "left", xAttributes ) ||
    1578          84 :         !importLongProperty( nBaseY, "PositionY", "top",  xAttributes ) ||
    1579         132 :         !importLongProperty( "Width", "width", xAttributes ) ||
    1580          48 :         !importLongProperty( "Height", "height", xAttributes ))
    1581             :     {
    1582           0 :         throw xml::sax::SAXException( "missing pos size attribute(s)!", Reference< XInterface >(), Any() );
    1583             :     }
    1584             : 
    1585          12 :     if (supportPrintable)
    1586             :     {
    1587           8 :         importBooleanProperty("Printable", "printable", xAttributes );
    1588             :     }
    1589             : 
    1590             :     sal_Int32 nLong;
    1591          12 :     if (! getLongAttr( &nLong, "page", xAttributes, _pImport->XMLNS_DIALOGS_UID ))
    1592             :     {
    1593          12 :         nLong = 0;
    1594             :     }
    1595          12 :     _xControlModel->setPropertyValue( "Step", makeAny( nLong ) );
    1596             : 
    1597          12 :     importStringProperty("Tag", "tag", xAttributes );
    1598          12 :     importStringProperty( "HelpText", "help-text", xAttributes );
    1599          12 :     importStringProperty( "HelpURL", "help-url", xAttributes );
    1600          12 : }
    1601             : 
    1602           0 : Reference< xml::input::XElement > ElementBase::getParent()
    1603             :     throw (RuntimeException, std::exception)
    1604             : {
    1605           0 :     return static_cast< xml::input::XElement * >( _pParent );
    1606             : }
    1607             : 
    1608           0 : OUString ElementBase::getLocalName()
    1609             :     throw (RuntimeException, std::exception)
    1610             : {
    1611           0 :     return _aLocalName;
    1612             : }
    1613             : 
    1614           0 : sal_Int32 ElementBase::getUid()
    1615             :     throw (RuntimeException, std::exception)
    1616             : {
    1617           0 :     return _nUid;
    1618             : }
    1619             : 
    1620           1 : Reference< xml::input::XAttributes > ElementBase::getAttributes()
    1621             :     throw (RuntimeException, std::exception)
    1622             : {
    1623           1 :     return _xAttributes;
    1624             : }
    1625             : 
    1626           0 : void ElementBase::ignorableWhitespace(
    1627             :     OUString const & /*rWhitespaces*/ )
    1628             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
    1629             : {
    1630             :     // not used
    1631           0 : }
    1632             : 
    1633          78 : void ElementBase::characters( OUString const & /*rChars*/ )
    1634             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
    1635             : {
    1636             :     // not used, all characters ignored
    1637          78 : }
    1638             : 
    1639          12 : void ElementBase::endElement()
    1640             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
    1641             : {
    1642          12 : }
    1643             : 
    1644           0 : void ElementBase::processingInstruction(
    1645             :     OUString const & /*Target*/, OUString const & /*Data*/ )
    1646             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
    1647             : {
    1648           0 : }
    1649             : 
    1650           0 : Reference< xml::input::XElement > ElementBase::startChildElement(
    1651             :     sal_Int32 /*nUid*/, OUString const & /*rLocalName*/,
    1652             :     Reference< xml::input::XAttributes > const & /*xAttributes*/ )
    1653             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
    1654             : {
    1655           0 :     throw xml::sax::SAXException( "unexpected element!", Reference< XInterface >(), Any() );
    1656             : }
    1657             : 
    1658          32 : ElementBase::ElementBase(
    1659             :     sal_Int32 nUid, OUString const & rLocalName,
    1660             :     Reference< xml::input::XAttributes > const & xAttributes,
    1661             :     ElementBase * pParent, DialogImport * pImport )
    1662             :     SAL_THROW(())
    1663             :     : _pImport( pImport )
    1664             :     , _pParent( pParent )
    1665             :     , _nUid( nUid )
    1666             :     , _aLocalName( rLocalName )
    1667          32 :     , _xAttributes( xAttributes )
    1668             : {
    1669          32 :     _pImport->acquire();
    1670             : 
    1671          32 :     if (_pParent)
    1672             :     {
    1673          28 :         _pParent->acquire();
    1674             :     }
    1675          32 : }
    1676          38 : ElementBase::~ElementBase()
    1677             :     SAL_THROW(())
    1678             : {
    1679          17 :     _pImport->release();
    1680             : 
    1681          17 :     if (_pParent)
    1682             :     {
    1683          15 :         _pParent->release();
    1684             :     }
    1685             : 
    1686             : #if OSL_DEBUG_LEVEL > 1
    1687             :     OString aStr( OUStringToOString(
    1688             :                              _aLocalName, RTL_TEXTENCODING_ASCII_US ) );
    1689             :     SAL_INFO("xmlscript.xmldlg", "ElementBase::~ElementBase(): " << aStr.getStr() );
    1690             : #endif
    1691          21 : }
    1692             : 
    1693             : // XRoot
    1694             : 
    1695           4 : void DialogImport::startDocument(
    1696             :     Reference< xml::input::XNamespaceMapping > const & xNamespaceMapping )
    1697             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
    1698             : {
    1699           4 :     XMLNS_DIALOGS_UID = xNamespaceMapping->getUidByUri( XMLNS_DIALOGS_URI );
    1700           4 :     XMLNS_SCRIPT_UID = xNamespaceMapping->getUidByUri( XMLNS_SCRIPT_URI );
    1701           4 : }
    1702             : 
    1703           4 : void DialogImport::endDocument()
    1704             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
    1705             : {
    1706             :     // ignored
    1707           4 : }
    1708             : 
    1709           0 : void DialogImport::processingInstruction(
    1710             :     OUString const & /*rTarget*/, OUString const & /*rData*/ )
    1711             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
    1712             : {
    1713             :     // ignored for now: xxx todo
    1714           0 : }
    1715             : 
    1716           4 : void DialogImport::setDocumentLocator(
    1717             :     Reference< xml::sax::XLocator > const & /*xLocator*/ )
    1718             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
    1719             : {
    1720             :     // ignored for now: xxx todo
    1721           4 : }
    1722             : 
    1723           4 : Reference< xml::input::XElement > DialogImport::startRootElement(
    1724             :     sal_Int32 nUid, OUString const & rLocalName,
    1725             :     Reference< xml::input::XAttributes > const & xAttributes )
    1726             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
    1727             : {
    1728           4 :     if (XMLNS_DIALOGS_UID != nUid)
    1729             :     {
    1730           0 :         throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
    1731             :     }
    1732             :     // window
    1733           4 :     else if ( rLocalName == "window" )
    1734             :     {
    1735           8 :         return new WindowElement( rLocalName, xAttributes, 0, this );
    1736             :     }
    1737             :     else
    1738             :     {
    1739           0 :         throw xml::sax::SAXException( "illegal root element (expected window) given: " + rLocalName, Reference< XInterface >(), Any() );
    1740             :     }
    1741             : }
    1742             : 
    1743           4 : DialogImport::~DialogImport()
    1744             :     SAL_THROW(())
    1745             : {
    1746             : #if OSL_DEBUG_LEVEL > 1
    1747             :     SAL_INFO("xmlscript.xmldlg", "DialogImport::~DialogImport()." );
    1748             : #endif
    1749           4 : }
    1750             : 
    1751           0 : Reference< util::XNumberFormatsSupplier > const & DialogImport::getNumberFormatsSupplier()
    1752             : {
    1753           0 :     if (! _xSupplier.is())
    1754             :     {
    1755           0 :         Reference< util::XNumberFormatsSupplier > xSupplier = util::NumberFormatsSupplier::createWithDefaultLocale( getComponentContext() );
    1756             : 
    1757           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
    1758           0 :         if (! _xSupplier.is())
    1759             :         {
    1760           0 :             _xSupplier = xSupplier;
    1761           0 :         }
    1762             :     }
    1763           0 :     return _xSupplier;
    1764             : }
    1765             : 
    1766           8 : void DialogImport::addStyle(
    1767             :     OUString const & rStyleId,
    1768             :     Reference< xml::input::XElement > const & xStyle )
    1769             :     SAL_THROW(())
    1770             : {
    1771           8 :     (*_pStyleNames).push_back( rStyleId );
    1772           8 :     (*_pStyles).push_back( xStyle );
    1773           8 : }
    1774             : 
    1775           8 : Reference< xml::input::XElement > DialogImport::getStyle(
    1776             :     OUString const & rStyleId ) const
    1777             :     SAL_THROW(())
    1778             : {
    1779          20 :     for ( size_t nPos = 0; nPos < (*_pStyleNames).size(); ++nPos )
    1780             :     {
    1781          20 :         if ( (*_pStyleNames)[ nPos ] == rStyleId)
    1782             :         {
    1783           8 :             return (*_pStyles)[ nPos ];
    1784             :         }
    1785             :     }
    1786           0 :     return 0;
    1787             : }
    1788             : 
    1789           4 : Reference< xml::sax::XDocumentHandler > SAL_CALL importDialogModel(
    1790             :     Reference< container::XNameContainer > const & xDialogModel,
    1791             :     Reference< XComponentContext > const & xContext,
    1792             :     Reference< XModel > const & xDocument )
    1793             :     SAL_THROW( (Exception) )
    1794             : {
    1795             :     // single set of styles and stylenames apply to all containees
    1796           4 :     :: boost::shared_ptr< ::std::vector< OUString > > pStyleNames( new ::std::vector< OUString > );
    1797           8 :     :: boost::shared_ptr< ::std::vector< css::uno::Reference< css::xml::input::XElement > > > pStyles( new ::std::vector< css::uno::Reference< css::xml::input::XElement > > );
    1798             :      return ::xmlscript::createDocumentHandler(
    1799             :          static_cast< xml::input::XRoot * >(
    1800           8 :             new DialogImport( xContext, xDialogModel, pStyleNames, pStyles, xDocument ) ) );
    1801             : }
    1802             : }
    1803             : 
    1804             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10