LCOV - code coverage report
Current view: top level - xmlscript/source/xmldlg_imexp - xmldlg_export.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 705 0.0 %
Date: 2014-04-14 Functions: 0 27 0.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 "exp_share.hxx"
      21             : 
      22             : #include <rtl/ustrbuf.hxx>
      23             : #include <tools/diagnose_ex.h>
      24             : 
      25             : #include <com/sun/star/awt/CharSet.hpp>
      26             : #include <com/sun/star/awt/FontFamily.hpp>
      27             : #include <com/sun/star/awt/FontPitch.hpp>
      28             : #include <com/sun/star/awt/FontSlant.hpp>
      29             : #include <com/sun/star/awt/FontStrikeout.hpp>
      30             : #include <com/sun/star/awt/FontType.hpp>
      31             : #include <com/sun/star/awt/FontUnderline.hpp>
      32             : #include <com/sun/star/awt/FontWeight.hpp>
      33             : #include <com/sun/star/awt/FontWidth.hpp>
      34             : #include <com/sun/star/awt/ImagePosition.hpp>
      35             : #include <com/sun/star/awt/LineEndFormat.hpp>
      36             : #include <com/sun/star/awt/PushButtonType.hpp>
      37             : #include <com/sun/star/awt/VisualEffect.hpp>
      38             : #include <com/sun/star/util/Date.hpp>
      39             : #include <com/sun/star/util/Time.hpp>
      40             : #include <tools/date.hxx>
      41             : #include <tools/time.hxx>
      42             : 
      43             : #include <com/sun/star/io/XPersistObject.hpp>
      44             : 
      45             : #include <com/sun/star/script/XScriptEventsSupplier.hpp>
      46             : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      47             : 
      48             : #include <com/sun/star/style/VerticalAlignment.hpp>
      49             : 
      50             : #include <com/sun/star/lang/XServiceInfo.hpp>
      51             : #include <com/sun/star/lang/Locale.hpp>
      52             : #include <com/sun/star/util/NumberFormat.hpp>
      53             : 
      54             : #include <com/sun/star/view/SelectionType.hpp>
      55             : 
      56             : #include <com/sun/star/form/binding/XListEntrySink.hpp>
      57             : #include <com/sun/star/form/binding/XBindableValue.hpp>
      58             : #include <com/sun/star/form/binding/XValueBinding.hpp>
      59             : #include <com/sun/star/table/CellAddress.hpp>
      60             : #include <com/sun/star/table/CellRangeAddress.hpp>
      61             : #include <com/sun/star/document/XStorageBasedDocument.hpp>
      62             : #include <com/sun/star/document/GraphicObjectResolver.hpp>
      63             : 
      64             : #include <comphelper/processfactory.hxx>
      65             : #include <i18nlangtag/languagetag.hxx>
      66             : 
      67             : using namespace ::com::sun::star;
      68             : using namespace ::com::sun::star::uno;
      69             : 
      70             : namespace xmlscript
      71             : {
      72             : 
      73           0 : Reference< xml::sax::XAttributeList > Style::createElement()
      74             : {
      75           0 :     ElementDescriptor * pStyle = new ElementDescriptor( XMLNS_DIALOGS_PREFIX ":style" );
      76             : 
      77             :     // style-id
      78           0 :     pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":style-id", _id );
      79             : 
      80             :     // background-color
      81           0 :     if (_set & 0x1)
      82             :     {
      83           0 :         pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":background-color", "0x" + OUString::number(_backgroundColor,16));
      84             :     }
      85             : 
      86             :     // text-color
      87           0 :     if (_set & 0x2)
      88             :     {
      89           0 :         pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":text-color", "0x" + OUString::number(_textColor,16));
      90             :     }
      91             : 
      92             :     // textline-color
      93           0 :     if (_set & 0x20)
      94             :     {
      95           0 :         pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":textline-color", "0x" + OUString::number(_textLineColor,16));
      96             :     }
      97             : 
      98             :     // fill-color
      99           0 :     if (_set & 0x10)
     100             :     {
     101           0 :         pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":fill-color", "0x" + OUString::number(_fillColor,16));
     102             :     }
     103             : 
     104             :     // border
     105           0 :     if (_set & 0x4)
     106             :     {
     107           0 :         switch (_border)
     108             :         {
     109             :         case BORDER_NONE:
     110           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":border", "none" );
     111           0 :             break;
     112             :         case BORDER_3D:
     113           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":border", "3d" );
     114           0 :             break;
     115             :         case BORDER_SIMPLE:
     116           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":border", "simple" );
     117           0 :             break;
     118             :         case BORDER_SIMPLE_COLOR: {
     119           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":border", "0x" + OUString::number(_borderColor,16));
     120           0 :             break;
     121             :         }
     122             :         default:
     123             :             SAL_WARN( "xmlscript.xmldlg", "### unexpected border value!" );
     124           0 :             break;
     125             :         }
     126             :     }
     127             : 
     128             :     // visual effect (look)
     129           0 :     if (_set & 0x40)
     130             :     {
     131           0 :         switch (_visualEffect)
     132             :         {
     133             :         case awt::VisualEffect::NONE:
     134           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":look", "none" );
     135           0 :             break;
     136             :         case awt::VisualEffect::LOOK3D:
     137           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":look", "3d" );
     138           0 :             break;
     139             :         case awt::VisualEffect::FLAT:
     140           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":look", "simple" );
     141           0 :             break;
     142             :         default:
     143             :             SAL_WARN( "xmlscript.xmldlg", "### unexpected visual effect value!" );
     144           0 :             break;
     145             :         }
     146             :     }
     147             : 
     148             :     // font-
     149           0 :     if (_set & 0x8)
     150             :     {
     151           0 :         awt::FontDescriptor def_descr;
     152             : 
     153             :         // dialog:font-name CDATA #IMPLIED
     154           0 :         if (def_descr.Name != _descr.Name)
     155             :         {
     156           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-name", _descr.Name );
     157             :         }
     158             :         // dialog:font-height %numeric; #IMPLIED
     159           0 :         if (def_descr.Height != _descr.Height)
     160             :         {
     161           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-height", OUString::number( _descr.Height ) );
     162             :         }
     163             :         // dialog:font-width %numeric; #IMPLIED
     164           0 :         if (def_descr.Width != _descr.Width)
     165             :         {
     166           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-width", OUString::number( _descr.Width ) );
     167             :         }
     168             :         // dialog:font-stylename CDATA #IMPLIED
     169           0 :         if (def_descr.StyleName != _descr.StyleName)
     170             :         {
     171           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-stylename", _descr.StyleName );
     172             :         }
     173             :         // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
     174           0 :         if (def_descr.Family != _descr.Family)
     175             :         {
     176           0 :             switch (_descr.Family)
     177             :             {
     178             :             case awt::FontFamily::DECORATIVE:
     179           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-family", "decorative" );
     180           0 :                 break;
     181             :             case awt::FontFamily::MODERN:
     182           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-family", "modern" );
     183           0 :                 break;
     184             :             case awt::FontFamily::ROMAN:
     185           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-family", "roman" );
     186           0 :                 break;
     187             :             case awt::FontFamily::SCRIPT:
     188           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-family", "script" );
     189           0 :                 break;
     190             :             case awt::FontFamily::SWISS:
     191           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-family", "swiss" );
     192           0 :                 break;
     193             :             case awt::FontFamily::SYSTEM:
     194           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-family", "system" );
     195           0 :                 break;
     196             :             default:
     197             :                 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-family!" );
     198           0 :                 break;
     199             :             }
     200             :         }
     201             :         // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
     202           0 :         if (def_descr.CharSet != _descr.CharSet)
     203             :         {
     204           0 :             switch (_descr.CharSet)
     205             :             {
     206             :             case awt::CharSet::ANSI:
     207           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "ansi" );
     208           0 :                 break;
     209             :             case awt::CharSet::MAC:
     210           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "mac" );
     211           0 :                 break;
     212             :             case awt::CharSet::IBMPC_437:
     213           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "ibmpc_437" );
     214           0 :                 break;
     215             :             case awt::CharSet::IBMPC_850:
     216           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "ibmpc_850" );
     217           0 :                 break;
     218             :             case awt::CharSet::IBMPC_860:
     219           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "ibmpc_860" );
     220           0 :                 break;
     221             :             case awt::CharSet::IBMPC_861:
     222           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "ibmpc_861" );
     223           0 :                 break;
     224             :             case awt::CharSet::IBMPC_863:
     225           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "ibmpc_863" );
     226           0 :                 break;
     227             :             case awt::CharSet::IBMPC_865:
     228           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "ibmpc_865" );
     229           0 :                 break;
     230             :             case awt::CharSet::SYSTEM:
     231           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "system" );
     232           0 :                 break;
     233             :             case awt::CharSet::SYMBOL:
     234           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "symbol" );
     235           0 :                 break;
     236             :             default:
     237             :                 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-charset!" );
     238           0 :                 break;
     239             :             }
     240             :         }
     241             :         // dialog:font-pitch "(fixed|variable)" #IMPLIED
     242           0 :         if (def_descr.Pitch != _descr.Pitch)
     243             :         {
     244           0 :             switch (_descr.Pitch)
     245             :             {
     246             :             case awt::FontPitch::FIXED:
     247           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-pitch", "fixed" );
     248           0 :                 break;
     249             :             case awt::FontPitch::VARIABLE:
     250           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-pitch", "variable" );
     251           0 :                 break;
     252             :             default:
     253             :                 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-pitch!" );
     254           0 :                 break;
     255             :             }
     256             :         }
     257             :         // dialog:font-charwidth CDATA #IMPLIED
     258           0 :         if (def_descr.CharacterWidth != _descr.CharacterWidth)
     259             :         {
     260           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charwidth", OUString::number( (float)_descr.CharacterWidth ) );
     261             :         }
     262             :         // dialog:font-weight CDATA #IMPLIED
     263           0 :         if (def_descr.Weight != _descr.Weight)
     264             :         {
     265           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-weight", OUString::number( (float)_descr.Weight ) );
     266             :         }
     267             :         // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
     268           0 :         if (def_descr.Slant != _descr.Slant)
     269             :         {
     270           0 :             switch (_descr.Slant)
     271             :             {
     272             :             case awt::FontSlant_OBLIQUE:
     273           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-slant", "oblique" );
     274           0 :                 break;
     275             :             case awt::FontSlant_ITALIC:
     276           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-slant", "italic" );
     277           0 :                 break;
     278             :             case awt::FontSlant_REVERSE_OBLIQUE:
     279           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-slant", "reverse_oblique" );
     280           0 :                 break;
     281             :             case awt::FontSlant_REVERSE_ITALIC:
     282           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-slant", "reverse_italic" );
     283           0 :                 break;
     284             :             default:
     285             :                 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-slant!" );
     286           0 :                 break;
     287             :             }
     288             :         }
     289             :         // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
     290           0 :         if (def_descr.Underline != _descr.Underline)
     291             :         {
     292           0 :             switch (_descr.Underline)
     293             :             {
     294             :             case awt::FontUnderline::SINGLE:
     295           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "single" );
     296           0 :                 break;
     297             :             case awt::FontUnderline::DOUBLE:
     298           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "double" );
     299           0 :                 break;
     300             :             case awt::FontUnderline::DOTTED:
     301           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "dotted" );
     302           0 :                 break;
     303             :             case awt::FontUnderline::DASH:
     304           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "dash" );
     305           0 :                 break;
     306             :             case awt::FontUnderline::LONGDASH:
     307           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "longdash" );
     308           0 :                 break;
     309             :             case awt::FontUnderline::DASHDOT:
     310           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "dashdot" );
     311           0 :                 break;
     312             :             case awt::FontUnderline::DASHDOTDOT:
     313           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "dashdotdot" );
     314           0 :                 break;
     315             :             case awt::FontUnderline::SMALLWAVE:
     316           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "smallwave" );
     317           0 :                 break;
     318             :             case awt::FontUnderline::WAVE:
     319           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "wave" );
     320           0 :                 break;
     321             :             case awt::FontUnderline::DOUBLEWAVE:
     322           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "doublewave" );
     323           0 :                 break;
     324             :             case awt::FontUnderline::BOLD:
     325           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "bold" );
     326           0 :                 break;
     327             :             case awt::FontUnderline::BOLDDOTTED:
     328           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "bolddotted" );
     329           0 :                 break;
     330             :             case awt::FontUnderline::BOLDDASH:
     331           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "bolddash" );
     332           0 :                 break;
     333             :             case awt::FontUnderline::BOLDLONGDASH:
     334           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "boldlongdash" );
     335           0 :                 break;
     336             :             case awt::FontUnderline::BOLDDASHDOT:
     337           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "bolddashdot" );
     338           0 :                 break;
     339             :             case awt::FontUnderline::BOLDDASHDOTDOT:
     340           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "bolddashdotdot" );
     341           0 :                 break;
     342             :             case awt::FontUnderline::BOLDWAVE:
     343           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-underline", "boldwave" );
     344           0 :                 break;
     345             :             default:
     346             :                 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-underline!" );
     347           0 :                 break;
     348             :             }
     349             :         }
     350             :         // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
     351           0 :         if (def_descr.Strikeout != _descr.Strikeout)
     352             :         {
     353           0 :             switch (_descr.Strikeout)
     354             :             {
     355             :             case awt::FontStrikeout::SINGLE:
     356           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-strikeout", "single" );
     357           0 :                 break;
     358             :             case awt::FontStrikeout::DOUBLE:
     359           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-strikeout", "double" );
     360           0 :                 break;
     361             :             case awt::FontStrikeout::BOLD:
     362           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-strikeout", "bold" );
     363           0 :                 break;
     364             :             case awt::FontStrikeout::SLASH:
     365           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-strikeout", "slash" );
     366           0 :                 break;
     367             :             case awt::FontStrikeout::X:
     368           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-strikeout", "x" );
     369           0 :                 break;
     370             :             default:
     371             :                 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-strikeout!" );
     372           0 :                 break;
     373             :             }
     374             :         }
     375             :         // dialog:font-orientation CDATA #IMPLIED
     376           0 :         if (def_descr.Orientation != _descr.Orientation)
     377             :         {
     378           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-orientation", OUString::number( (float)_descr.Orientation ) );
     379             :         }
     380             :         // dialog:font-kerning %boolean; #IMPLIED
     381           0 :         if ((def_descr.Kerning != sal_False) != (_descr.Kerning != sal_False))
     382             :         {
     383           0 :             pStyle->addBoolAttr( XMLNS_DIALOGS_PREFIX ":font-kerning", _descr.Kerning );
     384             :         }
     385             :         // dialog:font-wordlinemode %boolean; #IMPLIED
     386           0 :         if ((def_descr.WordLineMode != sal_False) != (_descr.WordLineMode != sal_False))
     387             :         {
     388           0 :             pStyle->addBoolAttr( XMLNS_DIALOGS_PREFIX ":font-wordlinemode", _descr.WordLineMode );
     389             :         }
     390             :         // dialog:font-type "(raster|device|scalable)" #IMPLIED
     391           0 :         if (def_descr.Type != _descr.Type)
     392             :         {
     393           0 :             switch (_descr.Type)
     394             :             {
     395             :             case awt::FontType::RASTER:
     396           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-type", "raster" );
     397           0 :                 break;
     398             :             case awt::FontType::DEVICE:
     399           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-type", "device" );
     400           0 :                 break;
     401             :             case awt::FontType::SCALABLE:
     402           0 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-type", "scalable" );
     403           0 :                 break;
     404             :             default:
     405             :                 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-type!" );
     406           0 :                 break;
     407             :             }
     408             :         }
     409             : 
     410             :         // additional attributes not in FontDescriptor struct
     411             :         // dialog:font-relief (none|embossed|engraved) #IMPLIED
     412           0 :         switch (_fontRelief)
     413             :         {
     414             :         case awt::FontRelief::NONE: // dont export default
     415           0 :             break;
     416             :         case awt::FontRelief::EMBOSSED:
     417           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-relief", "embossed" );
     418           0 :             break;
     419             :         case awt::FontRelief::ENGRAVED:
     420           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-relief", "engraved" );
     421           0 :             break;
     422             :         default:
     423             :             SAL_WARN( "xmlscript.xmldlg", "### unexpected font-relief!" );
     424           0 :             break;
     425             :         }
     426             :         // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
     427           0 :         switch (_fontEmphasisMark)
     428             :         {
     429             :         case awt::FontEmphasisMark::NONE: // dont export default
     430           0 :             break;
     431             :         case awt::FontEmphasisMark::DOT:
     432           0 :             pStyle->addAttribute(XMLNS_DIALOGS_PREFIX ":font-emphasismark", "dot" );
     433           0 :             break;
     434             :         case awt::FontEmphasisMark::CIRCLE:
     435           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-emphasismark", "circle" );
     436           0 :             break;
     437             :         case awt::FontEmphasisMark::DISC:
     438           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-emphasismark", "disc" );
     439           0 :             break;
     440             :         case awt::FontEmphasisMark::ACCENT:
     441           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-emphasismark", "accent" );
     442           0 :             break;
     443             :         case awt::FontEmphasisMark::ABOVE:
     444           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-emphasismark", "above" );
     445           0 :             break;
     446             :         case awt::FontEmphasisMark::BELOW:
     447           0 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-emphasismark", "below" );
     448           0 :             break;
     449             :         default:
     450             :             SAL_WARN( "xmlscript.xmldlg", "### unexpected font-emphasismark!" );
     451           0 :             break;
     452           0 :         }
     453             :     }
     454             : 
     455           0 :     return pStyle;
     456             : }
     457             : 
     458           0 : void ElementDescriptor::addNumberFormatAttr(
     459             :     Reference< beans::XPropertySet > const & xFormatProperties )
     460             : {
     461           0 :     Reference< beans::XPropertyState > xState( xFormatProperties, UNO_QUERY );
     462           0 :     OUString sFormat;
     463           0 :     lang::Locale locale;
     464           0 :     OSL_VERIFY( xFormatProperties->getPropertyValue( "FormatString" ) >>= sFormat );
     465           0 :     OSL_VERIFY( xFormatProperties->getPropertyValue( "Locale" ) >>= locale );
     466             : 
     467           0 :     addAttribute(XMLNS_DIALOGS_PREFIX ":format-code", sFormat );
     468             : 
     469             :     // format-locale
     470           0 :     LanguageTag aLanguageTag( locale);
     471           0 :     OUString aStr;
     472           0 :     if (aLanguageTag.isIsoLocale())
     473             :     {
     474             :         // Old style "lll;CC" for compatibility, I really don't know what may
     475             :         // consume this.
     476           0 :         if (aLanguageTag.getCountry().isEmpty())
     477           0 :             aStr = aLanguageTag.getLanguage();
     478             :         else
     479           0 :             aStr = aLanguageTag.getLanguage() + ";" + aLanguageTag.getCountry();
     480             :     }
     481             :     else
     482             :     {
     483           0 :         aStr = aLanguageTag.getBcp47( false);
     484             :     }
     485           0 :     addAttribute( XMLNS_DIALOGS_PREFIX ":format-locale", aStr );
     486           0 : }
     487             : 
     488           0 : Any ElementDescriptor::readProp( OUString const & rPropName )
     489             : {
     490           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     491             :     {
     492           0 :         return _xProps->getPropertyValue( rPropName );
     493             :     }
     494           0 :     return Any();
     495             : }
     496             : 
     497           0 : void ElementDescriptor::readStringAttr(
     498             :     OUString const & rPropName, OUString const & rAttrName )
     499             : {
     500           0 :     if (beans::PropertyState_DEFAULT_VALUE !=
     501           0 :         _xPropState->getPropertyState( rPropName ))
     502             :     {
     503           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     504           0 :         OUString v;
     505           0 :         if (a >>= v)
     506           0 :             addAttribute( rAttrName, v );
     507             :         else
     508           0 :             SAL_WARN( "xmlscript.xmldlg", "### unexpected property type!" );
     509             :     }
     510           0 : }
     511             : 
     512           0 : void ElementDescriptor::readHexLongAttr( OUString const & rPropName, OUString const & rAttrName )
     513             : {
     514           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     515             :     {
     516           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     517           0 :         if (a.getValueTypeClass() == TypeClass_LONG)
     518             :         {
     519           0 :             addAttribute( rAttrName, "0x" + OUString::number((sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue(),16)  );
     520           0 :         }
     521             :     }
     522           0 : }
     523             : 
     524           0 : void ElementDescriptor::readDateFormatAttr( OUString const & rPropName, OUString const & rAttrName )
     525             : {
     526           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     527             :     {
     528           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     529           0 :         if (a.getValueTypeClass() == TypeClass_SHORT)
     530             :         {
     531           0 :             switch (*(sal_Int16 const *)a.getValue())
     532             :             {
     533             :             case 0:
     534           0 :                 addAttribute( rAttrName, "system_short" );
     535           0 :                 break;
     536             :             case 1:
     537           0 :                 addAttribute( rAttrName, "system_short_YY" );
     538           0 :                 break;
     539             :             case 2:
     540           0 :                 addAttribute( rAttrName, "system_short_YYYY" );
     541           0 :                 break;
     542             :             case 3:
     543           0 :                 addAttribute( rAttrName, "system_long" );
     544           0 :                 break;
     545             :             case 4:
     546           0 :                 addAttribute( rAttrName, "short_DDMMYY" );
     547           0 :                 break;
     548             :             case 5:
     549           0 :                 addAttribute( rAttrName, "short_MMDDYY" );
     550           0 :                 break;
     551             :             case 6:
     552           0 :                 addAttribute( rAttrName, "short_YYMMDD" );
     553           0 :                 break;
     554             :             case 7:
     555           0 :                 addAttribute( rAttrName, "short_DDMMYYYY" );
     556           0 :                 break;
     557             :             case 8:
     558           0 :                 addAttribute( rAttrName, "short_MMDDYYYY" );
     559           0 :                 break;
     560             :             case 9:
     561           0 :                 addAttribute( rAttrName, "short_YYYYMMDD" );
     562           0 :                 break;
     563             :             case 10:
     564           0 :                 addAttribute( rAttrName, "short_YYMMDD_DIN5008" );
     565           0 :                 break;
     566             :             case 11:
     567           0 :                 addAttribute( rAttrName, "short_YYYYMMDD_DIN5008" );
     568           0 :                 break;
     569             :             default:
     570             :                 SAL_WARN( "xmlscript.xmldlg", "### unexpected date format!" );
     571           0 :                 break;
     572             :             }
     573             :         }
     574             :         else
     575           0 :             OSL_FAIL( "### unexpected property type!" );
     576             :     }
     577           0 : }
     578             : 
     579           0 : void ElementDescriptor::readDateAttr( OUString const & rPropName, OUString const & rAttrName )
     580             : {
     581           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     582             :     {
     583           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     584           0 :         if (a.getValueTypeClass() == TypeClass_STRUCT && a.getValueType() == ::getCppuType( (util::Date*)0 ))
     585             :         {
     586           0 :             util::Date aUDate;
     587           0 :             if (a >>= aUDate)
     588             :             {
     589           0 :                 ::Date aTDate(aUDate);
     590           0 :                 addAttribute( rAttrName, OUString::number( aTDate.GetDate() ) );
     591             :             }
     592             :             else
     593             :                 OSL_FAIL( "### internal error" );
     594             :         }
     595             :         else
     596           0 :             OSL_FAIL( "### unexpected property type!" );
     597             :     }
     598           0 : }
     599             : 
     600           0 : void ElementDescriptor::readTimeAttr( OUString const & rPropName, OUString const & rAttrName )
     601             : {
     602           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     603             :     {
     604           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     605           0 :         if (a.getValueTypeClass() == TypeClass_STRUCT && a.getValueType() == ::getCppuType( (util::Time*)0 ))
     606             :         {
     607           0 :             util::Time aUTime;
     608           0 :             if (a >>= aUTime)
     609             :             {
     610           0 :                 ::Time aTTime(aUTime);
     611           0 :                 addAttribute( rAttrName, OUString::number( aTTime.GetTime() / ::Time::nanoPerCenti ) );
     612             :             }
     613             :             else
     614             :                 OSL_FAIL( "### internal error" );
     615             :         }
     616             :         else
     617           0 :             OSL_FAIL( "### unexpected property type!" );
     618             :     }
     619           0 : }
     620             : 
     621           0 : void ElementDescriptor::readTimeFormatAttr( OUString const & rPropName, OUString const & rAttrName )
     622             : {
     623           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     624             :     {
     625           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     626           0 :         if (a.getValueTypeClass() == TypeClass_SHORT)
     627             :         {
     628           0 :             switch (*(sal_Int16 const *)a.getValue())
     629             :             {
     630             :             case 0:
     631           0 :                 addAttribute( rAttrName, "24h_short" );
     632           0 :                 break;
     633             :             case 1:
     634           0 :                 addAttribute( rAttrName, "24h_long" );
     635           0 :                 break;
     636             :             case 2:
     637           0 :                 addAttribute( rAttrName, "12h_short" );
     638           0 :                 break;
     639             :             case 3:
     640           0 :                 addAttribute( rAttrName, "12h_long" );
     641           0 :                 break;
     642             :             case 4:
     643           0 :                 addAttribute( rAttrName, "Duration_short" );
     644           0 :                 break;
     645             :             case 5:
     646           0 :                 addAttribute( rAttrName, "Duration_long" );
     647           0 :                 break;
     648             :             default:
     649             :                 SAL_WARN( "xmlscript.xmldlg", "### unexpected time format!" );
     650           0 :                 break;
     651             :             }
     652             :         }
     653             :         else
     654           0 :             OSL_FAIL( "### unexpected property type!" );
     655             :     }
     656           0 : }
     657             : 
     658           0 : void ElementDescriptor::readAlignAttr( OUString const & rPropName, OUString const & rAttrName )
     659             : {
     660           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     661             :     {
     662           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     663           0 :         if (a.getValueTypeClass() == TypeClass_SHORT)
     664             :         {
     665           0 :             switch (*(sal_Int16 const *)a.getValue())
     666             :             {
     667             :             case 0:
     668           0 :                 addAttribute( rAttrName, "left" );
     669           0 :                 break;
     670             :             case 1:
     671           0 :                 addAttribute( rAttrName, "center" );
     672           0 :                 break;
     673             :             case 2:
     674           0 :                 addAttribute( rAttrName, "right" );
     675           0 :                 break;
     676             :             default:
     677             :                 SAL_WARN( "xmlscript.xmldlg", "### illegal alignment value!" );
     678           0 :                 break;
     679             :             }
     680             :         }
     681             :         else
     682           0 :             OSL_FAIL( "### unexpected property type!" );
     683             :     }
     684           0 : }
     685             : 
     686           0 : void ElementDescriptor::readVerticalAlignAttr( OUString const & rPropName, OUString const & rAttrName )
     687             : {
     688           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     689             :     {
     690           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     691           0 :         if (a.getValueTypeClass() == TypeClass_ENUM && a.getValueType() == ::getCppuType( (style::VerticalAlignment*)0 ))
     692             :         {
     693             :             style::VerticalAlignment eAlign;
     694           0 :             a >>= eAlign;
     695           0 :             switch (eAlign)
     696             :             {
     697             :             case style::VerticalAlignment_TOP:
     698           0 :                 addAttribute( rAttrName, "top" );
     699           0 :                 break;
     700             :             case style::VerticalAlignment_MIDDLE:
     701           0 :                 addAttribute( rAttrName, "center" );
     702           0 :                 break;
     703             :             case style::VerticalAlignment_BOTTOM:
     704           0 :                 addAttribute( rAttrName, "bottom" );
     705           0 :                 break;
     706             :             default:
     707             :                 SAL_WARN( "xmlscript.xmldlg", "### illegal vertical alignment value!" );
     708           0 :                 break;
     709             :             }
     710             :         }
     711             :         else
     712           0 :             OSL_FAIL( "### unexpected property type!" );
     713             :     }
     714           0 : }
     715             : 
     716           0 : void ElementDescriptor::readImageURLAttr( OUString const & rPropName, OUString const & rAttrName )
     717             : {
     718           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     719             :     {
     720           0 :         OUString sURL;
     721           0 :         _xProps->getPropertyValue( rPropName ) >>= sURL;
     722             : 
     723           0 :         if ( sURL.startsWith( XMLSCRIPT_GRAPHOBJ_URLPREFIX ) )
     724             :         {
     725           0 :             Reference< document::XStorageBasedDocument > xDocStorage( _xDocument, UNO_QUERY );
     726           0 :             if ( xDocStorage.is() )
     727             :             {
     728           0 :                 Reference<XComponentContext> xContext = ::comphelper::getProcessComponentContext();
     729             :                 uno::Reference< document::XGraphicObjectResolver > xGraphicResolver =
     730           0 :                     document::GraphicObjectResolver::createWithStorage( xContext, xDocStorage->getDocumentStorage() );
     731           0 :                 sURL = xGraphicResolver->resolveGraphicObjectURL( sURL );
     732           0 :             }
     733             :         }
     734           0 :         if ( !sURL.isEmpty() )
     735           0 :                 addAttribute( rAttrName, sURL );
     736             :     }
     737           0 : }
     738             : 
     739           0 : void ElementDescriptor::readImageAlignAttr( OUString const & rPropName, OUString const & rAttrName )
     740             : {
     741           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     742             :     {
     743           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     744           0 :         if (a.getValueTypeClass() == TypeClass_SHORT)
     745             :         {
     746           0 :             switch (*(sal_Int16 const *)a.getValue())
     747             :             {
     748             :             case 0:
     749           0 :                 addAttribute( rAttrName, "left" );
     750           0 :                 break;
     751             :             case 1:
     752           0 :                 addAttribute( rAttrName, "top" );
     753           0 :                 break;
     754             :             case 2:
     755           0 :                 addAttribute( rAttrName, "right" );
     756           0 :                 break;
     757             :             case 3:
     758           0 :                 addAttribute( rAttrName, "bottom" );
     759           0 :                 break;
     760             :             default:
     761             :                 SAL_WARN( "xmlscript.xmldlg", "### illegal image alignment value!" );
     762           0 :                 break;
     763             :             }
     764             :         }
     765             :         else
     766           0 :             OSL_FAIL( "### unexpected property type!" );
     767             :     }
     768           0 : }
     769             : 
     770           0 : void ElementDescriptor::readImagePositionAttr( OUString const & rPropName, OUString const & rAttrName )
     771             : {
     772           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     773             :     {
     774           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     775           0 :         if (a.getValueTypeClass() == TypeClass_SHORT)
     776             :         {
     777           0 :             switch (*(sal_Int16 const *)a.getValue())
     778             :             {
     779             :             case awt::ImagePosition::LeftTop:
     780           0 :                 addAttribute( rAttrName, "left-top" );
     781           0 :                 break;
     782             :             case awt::ImagePosition::LeftCenter:
     783           0 :                 addAttribute( rAttrName, "left-center" );
     784           0 :                 break;
     785             :             case awt::ImagePosition::LeftBottom:
     786           0 :                 addAttribute( rAttrName, "left-bottom" );
     787           0 :                 break;
     788             :             case awt::ImagePosition::RightTop:
     789           0 :                 addAttribute( rAttrName, "right-top" );
     790           0 :                 break;
     791             :             case awt::ImagePosition::RightCenter:
     792           0 :                 addAttribute( rAttrName, "right-center" );
     793           0 :                 break;
     794             :             case awt::ImagePosition::RightBottom:
     795           0 :                 addAttribute( rAttrName, "right-bottom" );
     796           0 :                 break;
     797             :             case awt::ImagePosition::AboveLeft:
     798           0 :                 addAttribute( rAttrName, "top-left" );
     799           0 :                 break;
     800             :             case awt::ImagePosition::AboveCenter:
     801           0 :                 addAttribute( rAttrName, "top-center" );
     802           0 :                 break;
     803             :             case awt::ImagePosition::AboveRight:
     804           0 :                 addAttribute( rAttrName, "top-right" );
     805           0 :                 break;
     806             :             case awt::ImagePosition::BelowLeft:
     807           0 :                 addAttribute( rAttrName, "bottom-left" );
     808           0 :                 break;
     809             :             case awt::ImagePosition::BelowCenter:
     810           0 :                 addAttribute( rAttrName, "bottom-center" );
     811           0 :                 break;
     812             :             case awt::ImagePosition::BelowRight:
     813           0 :                 addAttribute( rAttrName, "bottom-right" );
     814           0 :                 break;
     815             :             case awt::ImagePosition::Centered:
     816           0 :                 addAttribute( rAttrName, "center" );
     817           0 :                 break;
     818             :             default:
     819             :                 SAL_WARN( "xmlscript.xmldlg", "### illegal image position value!" );
     820           0 :                 break;
     821             :             }
     822           0 :         }
     823             :     }
     824           0 : }
     825             : 
     826           0 : void ElementDescriptor::readButtonTypeAttr( OUString const & rPropName, OUString const & rAttrName )
     827             : {
     828           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     829             :     {
     830           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     831           0 :         if (a.getValueTypeClass() == TypeClass_SHORT)
     832             :         {
     833           0 :             switch (*(sal_Int16 const *)a.getValue())
     834             :             {
     835             :             case awt::PushButtonType_STANDARD:
     836           0 :                 addAttribute( rAttrName, "standard" );
     837           0 :                 break;
     838             :             case awt::PushButtonType_OK:
     839           0 :                 addAttribute( rAttrName, "ok" );
     840           0 :                 break;
     841             :             case awt::PushButtonType_CANCEL:
     842           0 :                 addAttribute( rAttrName, "cancel" );
     843           0 :                 break;
     844             :             case awt::PushButtonType_HELP:
     845           0 :                 addAttribute( rAttrName, "help" );
     846           0 :                 break;
     847             :             default:
     848             :                 SAL_WARN( "xmlscript.xmldlg", "### illegal button-type value!" );
     849           0 :                 break;
     850             :             }
     851           0 :         }
     852             :     }
     853           0 : }
     854             : 
     855           0 : void ElementDescriptor::readOrientationAttr( OUString const & rPropName, OUString const & rAttrName )
     856             : {
     857           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     858             :     {
     859           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     860           0 :         if (a.getValueTypeClass() == TypeClass_LONG)
     861             :         {
     862           0 :             switch (*(sal_Int32 const *)a.getValue())
     863             :             {
     864             :             case 0:
     865           0 :                 addAttribute( rAttrName, "horizontal" );
     866           0 :                 break;
     867             :             case 1:
     868           0 :                 addAttribute( rAttrName, "vertical" );
     869           0 :                 break;
     870             :             default:
     871             :                 SAL_WARN( "xmlscript.xmldlg", "### illegal orientation value!" );
     872           0 :                 break;
     873             :             }
     874           0 :         }
     875             :     }
     876           0 : }
     877             : 
     878           0 : void ElementDescriptor::readLineEndFormatAttr( OUString const & rPropName, OUString const & rAttrName )
     879             : {
     880           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     881             :     {
     882           0 :         Any a( _xProps->getPropertyValue( rPropName ) );
     883           0 :         if (a.getValueTypeClass() == TypeClass_SHORT)
     884             :         {
     885           0 :             switch (*(sal_Int16 const *)a.getValue())
     886             :             {
     887             :             case awt::LineEndFormat::CARRIAGE_RETURN:
     888           0 :                 addAttribute( rAttrName, "carriage-return" );
     889           0 :                 break;
     890             :             case awt::LineEndFormat::LINE_FEED:
     891           0 :                 addAttribute( rAttrName, "line-feed" );
     892           0 :                 break;
     893             :             case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED:
     894           0 :                 addAttribute( rAttrName, "carriage-return-line-feed" );
     895           0 :                 break;
     896             :             default:
     897             :                 SAL_WARN( "xmlscript.xmldlg", "### illegal line end format value!" );
     898           0 :                 break;
     899             :             }
     900           0 :         }
     901             :     }
     902           0 : }
     903             : 
     904           0 : void ElementDescriptor::readDataAwareAttr( OUString const & rAttrName )
     905             : {
     906           0 :     Reference< lang::XMultiServiceFactory > xFac;
     907           0 :     if ( _xDocument.is() )
     908           0 :         xFac.set( _xDocument, uno::UNO_QUERY );
     909             : 
     910           0 :     Reference< form::binding::XBindableValue > xBinding( _xProps, UNO_QUERY );
     911             : 
     912           0 :     if ( xFac.is() && xBinding.is() && rAttrName.equals( XMLNS_DIALOGS_PREFIX ":linked-cell" ) )
     913             :     {
     914             :         try
     915             :         {
     916           0 :             Reference< beans::XPropertySet > xConvertor( xFac->createInstance( "com.sun.star.table.CellAddressConversion" ), uno::UNO_QUERY );
     917           0 :         Reference< beans::XPropertySet > xBindable( xBinding->getValueBinding(), UNO_QUERY );
     918           0 :             if ( xBindable.is() )
     919             :             {
     920           0 :                 table::CellAddress aAddress;
     921           0 :                 xBindable->getPropertyValue( "BoundCell" ) >>= aAddress;
     922           0 :                 xConvertor->setPropertyValue( "Address", makeAny( aAddress ) );
     923           0 :                 OUString sAddress;
     924           0 :                 xConvertor->getPropertyValue( "PersistentRepresentation" ) >>= sAddress;
     925           0 :                 if ( !sAddress.isEmpty() )
     926           0 :                     addAttribute( rAttrName, sAddress );
     927             : 
     928           0 :                 SAL_INFO("xmlscript.xmldlg", "*** Bindable value " << sAddress );
     929             : 
     930           0 :             }
     931             :         }
     932           0 :         catch( uno::Exception& )
     933             :         {
     934             :         }
     935             :     }
     936           0 :     Reference< form::binding::XListEntrySink > xEntrySink( _xProps, UNO_QUERY );
     937           0 :     if ( xEntrySink.is() && rAttrName.equals( XMLNS_DIALOGS_PREFIX ":source-cell-range" ) )
     938             :     {
     939           0 :         Reference< beans::XPropertySet > xListSource( xEntrySink->getListEntrySource(), UNO_QUERY );
     940           0 :         if ( xListSource.is() )
     941             :         {
     942             :             try
     943             :             {
     944           0 :                 Reference< beans::XPropertySet > xConvertor( xFac->createInstance( "com.sun.star.table.CellRangeAddressConversion" ), uno::UNO_QUERY );
     945             : 
     946           0 :                 table::CellRangeAddress aAddress;
     947           0 :                 xListSource->getPropertyValue( "CellRange" ) >>= aAddress;
     948             : 
     949           0 :                 OUString sAddress;
     950           0 :                 xConvertor->setPropertyValue( "Address", makeAny( aAddress ) );
     951           0 :                 xConvertor->getPropertyValue( "PersistentRepresentation" ) >>= sAddress;
     952             :                 SAL_INFO("xmlscript.xmldlg","**** cell range source list " << sAddress );
     953           0 :                 if ( !sAddress.isEmpty() )
     954           0 :                     addAttribute( rAttrName, sAddress );
     955             :             }
     956           0 :             catch( uno::Exception& )
     957             :             {
     958             :             }
     959           0 :         }
     960           0 :     }
     961           0 : }
     962             : 
     963           0 : void ElementDescriptor::readSelectionTypeAttr( OUString const & rPropName, OUString const & rAttrName )
     964             : {
     965           0 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     966             :     {
     967           0 :         Any aSelectionType ( _xProps->getPropertyValue( rPropName ) );
     968             : 
     969           0 :         if (aSelectionType.getValueTypeClass() == TypeClass_ENUM && aSelectionType.getValueType() == ::getCppuType( (::view::SelectionType*)0 ))
     970             :         {
     971             :             ::view::SelectionType eSelectionType;
     972           0 :             aSelectionType >>= eSelectionType;
     973             : 
     974           0 :             switch (eSelectionType)
     975             :             {
     976             :                 case ::view::SelectionType_NONE:
     977           0 :                     addAttribute( rAttrName, "none" );
     978           0 :                     break;
     979             :                 case ::view::SelectionType_SINGLE:
     980           0 :                     addAttribute( rAttrName, "single" );
     981           0 :                     break;
     982             :                 case ::view::SelectionType_MULTI:
     983           0 :                     addAttribute( rAttrName, "multi" );
     984           0 :                     break;
     985             :                 case ::view::SelectionType_RANGE:
     986           0 :                     addAttribute( rAttrName, "range" );
     987           0 :                     break;
     988             :                 default:
     989             :                     SAL_WARN( "xmlscript.xmldlg", "### illegal selection type value!" );
     990           0 :                     break;
     991             :             }
     992           0 :         }
     993             :     }
     994           0 : }
     995             : 
     996           0 : void ElementDescriptor::readScrollableSettings()
     997             : {
     998             :     readLongAttr( "ScrollHeight",
     999           0 :                   XMLNS_DIALOGS_PREFIX ":scrollheight" );
    1000             :     readLongAttr( "ScrollWidth",
    1001           0 :                   XMLNS_DIALOGS_PREFIX ":scrollwidth" );
    1002             :     readLongAttr( "ScrollTop",
    1003           0 :                   XMLNS_DIALOGS_PREFIX ":scrolltop" );
    1004             :     readLongAttr( "ScrollLeft",
    1005           0 :                   XMLNS_DIALOGS_PREFIX ":scrollleft" );
    1006             :     readBoolAttr( "HScroll",
    1007           0 :                   XMLNS_DIALOGS_PREFIX ":hscroll" );
    1008             :     readBoolAttr( "VScroll",
    1009           0 :                   XMLNS_DIALOGS_PREFIX ":vscroll" );
    1010           0 : }
    1011             : 
    1012           0 : void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible )
    1013             : {
    1014           0 :     Any a( _xProps->getPropertyValue( "Name" ) );
    1015             : 
    1016             :     // The following is a hack to allow 'form' controls to override the default
    1017             :     // control supported by dialogs. This should work well for both vba support and
    1018             :     // normal openoffice ( when normal 'Dialogs' decide to support form control models )
    1019             :     // In the future VBA support might require custom models ( and not the just the form
    1020             :     // variant of a control that we currently use ) In this case the door is still open,
    1021             :     // we just need to define a new way for the 'ServiceName' to be extracted from the
    1022             :     // incomming model. E.g. the use of supporting service
    1023             :     // "com.sun.star.form.FormComponent", 'ServiceName' and XPersistObject
    1024             :     // is only an implementation detail here, in the future some other
    1025             :     // method ( perhaps a custom prop ) could be used instead.
    1026           0 :     Reference< lang::XServiceInfo > xSrvInfo( _xProps, UNO_QUERY );
    1027           0 :     if ( xSrvInfo.is() && xSrvInfo->supportsService( "com.sun.star.form.FormComponent" ) )
    1028             :     {
    1029           0 :         Reference< io::XPersistObject > xPersist( _xProps, UNO_QUERY );
    1030           0 :         if ( xPersist.is() )
    1031             :         {
    1032           0 :             OUString sCtrlName = xPersist->getServiceName();
    1033           0 :             if ( !sCtrlName.isEmpty() )
    1034           0 :                     addAttribute( XMLNS_DIALOGS_PREFIX ":control-implementation", sCtrlName );
    1035           0 :         }
    1036             :     }
    1037           0 :     addAttribute( XMLNS_DIALOGS_PREFIX ":id", * reinterpret_cast< const OUString * >( a.getValue() ) );
    1038           0 :     readShortAttr( "TabIndex", XMLNS_DIALOGS_PREFIX ":tab-index" );
    1039             : 
    1040           0 :     bool bEnabled = false;
    1041           0 :     if (_xProps->getPropertyValue( "Enabled" ) >>= bEnabled)
    1042             :     {
    1043           0 :         if (! bEnabled)
    1044             :         {
    1045           0 :             addAttribute( XMLNS_DIALOGS_PREFIX ":disabled", "true" );
    1046             :         }
    1047             :     }
    1048             :     else
    1049             :     {
    1050             :         SAL_WARN( "xmlscript.xmldlg", "unexpected property type for \"Enabled\": not bool!" );
    1051             :     }
    1052             : 
    1053           0 :     bool bVisible = true;
    1054           0 :     if (supportVisible) try
    1055             :     {
    1056           0 :         if (_xProps->getPropertyValue("EnableVisible" ) >>= bVisible)
    1057             :         {
    1058             : 
    1059             :             // only write out the non default case
    1060           0 :             if (! bVisible)
    1061             :             {
    1062           0 :                 addAttribute( XMLNS_DIALOGS_PREFIX ":visible", "false" );
    1063             :             }
    1064             :         }
    1065             :     }
    1066           0 :     catch( Exception& )
    1067             :     {
    1068             :         DBG_UNHANDLED_EXCEPTION();
    1069             :     }
    1070             :     // force writing of pos/size
    1071           0 :     a = _xProps->getPropertyValue( "PositionX" );
    1072           0 :     if (a.getValueTypeClass() == TypeClass_LONG)
    1073             :     {
    1074           0 :         addAttribute( XMLNS_DIALOGS_PREFIX ":left", OUString::number( *(sal_Int32 const *)a.getValue() ) );
    1075             :     }
    1076           0 :     a = _xProps->getPropertyValue( "PositionY" );
    1077           0 :     if (a.getValueTypeClass() == TypeClass_LONG)
    1078             :     {
    1079           0 :         addAttribute( XMLNS_DIALOGS_PREFIX ":top", OUString::number( *(sal_Int32 const *)a.getValue() ) );
    1080             :     }
    1081           0 :     a = _xProps->getPropertyValue( "Width" );
    1082           0 :     if (a.getValueTypeClass() == TypeClass_LONG)
    1083             :     {
    1084           0 :         addAttribute( XMLNS_DIALOGS_PREFIX ":width", OUString::number( *(sal_Int32 const *)a.getValue() ) );
    1085             :     }
    1086           0 :     a = _xProps->getPropertyValue( "Height" );
    1087           0 :     if (a.getValueTypeClass() == TypeClass_LONG)
    1088             :     {
    1089           0 :         addAttribute( XMLNS_DIALOGS_PREFIX ":height", OUString::number( *(sal_Int32 const *)a.getValue() ) );
    1090             :     }
    1091             : 
    1092           0 :     if (supportPrintable)
    1093             :     {
    1094           0 :         readBoolAttr( "Printable", XMLNS_DIALOGS_PREFIX ":printable" );
    1095             :     }
    1096           0 :     readLongAttr( "Step", XMLNS_DIALOGS_PREFIX ":page" );
    1097           0 :     readStringAttr( "Tag", XMLNS_DIALOGS_PREFIX ":tag" );
    1098           0 :     readStringAttr( "HelpText", XMLNS_DIALOGS_PREFIX ":help-text" );
    1099           0 :     readStringAttr( "HelpURL", XMLNS_DIALOGS_PREFIX ":help-url" );
    1100           0 : }
    1101             : 
    1102             : struct StringTriple
    1103             : {
    1104             :     char const * first;
    1105             :     char const * second;
    1106             :     char const * third;
    1107             : };
    1108             : extern StringTriple const * const g_pEventTranslations;
    1109             : 
    1110           0 : void ElementDescriptor::readEvents()
    1111             :     SAL_THROW( (Exception) )
    1112             : {
    1113           0 :     Reference< script::XScriptEventsSupplier > xSupplier( _xProps, UNO_QUERY );
    1114           0 :     if (xSupplier.is())
    1115             :     {
    1116           0 :         Reference< container::XNameContainer > xEvents( xSupplier->getEvents() );
    1117           0 :         if (xEvents.is())
    1118             :         {
    1119           0 :             Sequence< OUString > aNames( xEvents->getElementNames() );
    1120           0 :             OUString const * pNames = aNames.getConstArray();
    1121           0 :             for ( sal_Int32 nPos = 0; nPos < aNames.getLength(); ++nPos )
    1122             :             {
    1123           0 :                 script::ScriptEventDescriptor descr;
    1124           0 :                 if (xEvents->getByName( pNames[ nPos ] ) >>= descr)
    1125             :                 {
    1126             :                     SAL_WARN_IF( descr.ListenerType.isEmpty() ||
    1127             :                                 descr.EventMethod.isEmpty() ||
    1128             :                                 descr.ScriptCode.isEmpty() ||
    1129             :                                 descr.ScriptType.isEmpty() , "xmlscript.xmldlg", "### invalid event descr!" );
    1130             : 
    1131           0 :                     OUString aEventName;
    1132             : 
    1133           0 :                     if (descr.AddListenerParam.isEmpty())
    1134             :                     {
    1135             :                         // detection of event-name
    1136           0 :                         OString listenerType( OUStringToOString( descr.ListenerType, RTL_TEXTENCODING_ASCII_US ) );
    1137           0 :                         OString eventMethod( OUStringToOString( descr.EventMethod, RTL_TEXTENCODING_ASCII_US ) );
    1138           0 :                         StringTriple const * p = g_pEventTranslations;
    1139           0 :                         while (p->first)
    1140             :                         {
    1141           0 :                             if (0 == ::rtl_str_compare( p->second, eventMethod.getStr() ) &&
    1142           0 :                                 0 == ::rtl_str_compare( p->first, listenerType.getStr() ))
    1143             :                             {
    1144           0 :                                 aEventName = OUString( p->third, ::rtl_str_getLength( p->third ), RTL_TEXTENCODING_ASCII_US );
    1145           0 :                                 break;
    1146             :                             }
    1147           0 :                             ++p;
    1148           0 :                         }
    1149             :                     }
    1150             : 
    1151             :                     ElementDescriptor * pElem;
    1152           0 :                     Reference< xml::sax::XAttributeList > xElem;
    1153             : 
    1154           0 :                     if (!aEventName.isEmpty()) // script:event
    1155             :                     {
    1156           0 :                         pElem = new ElementDescriptor( XMLNS_SCRIPT_PREFIX ":event" );
    1157           0 :                         xElem = pElem;
    1158             : 
    1159           0 :                         pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":event-name", aEventName );
    1160             :                     }
    1161             :                     else // script:listener-event
    1162             :                     {
    1163           0 :                         pElem = new ElementDescriptor( XMLNS_SCRIPT_PREFIX ":listener-event" );
    1164           0 :                         xElem = pElem;
    1165             : 
    1166           0 :                         pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":listener-type", descr.ListenerType );
    1167           0 :                         pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":listener-method", descr.EventMethod );
    1168             : 
    1169           0 :                         if (!descr.AddListenerParam.isEmpty())
    1170             :                         {
    1171           0 :                             pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":listener-param", descr.AddListenerParam );
    1172             :                         }
    1173             :                     }
    1174           0 :                     if ( descr.ScriptType == "StarBasic" )
    1175             :                     {
    1176             :                         // separate optional location
    1177           0 :                         sal_Int32 nIndex = descr.ScriptCode.indexOf( (sal_Unicode)':' );
    1178           0 :                         if (nIndex >= 0)
    1179             :                         {
    1180           0 :                             pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":location", descr.ScriptCode.copy( 0, nIndex ) );
    1181           0 :                             pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":macro-name", descr.ScriptCode.copy( nIndex +1 ) );
    1182             :                         }
    1183             :                         else
    1184             :                         {
    1185           0 :                             pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":macro-name", descr.ScriptCode );
    1186             :                         }
    1187             :                     }
    1188             :                     else
    1189             :                     {
    1190           0 :                         pElem->addAttribute(XMLNS_SCRIPT_PREFIX ":macro-name", descr.ScriptCode );
    1191             :                     }
    1192             : 
    1193             :                     // language
    1194           0 :                     pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":language", descr.ScriptType );
    1195             : 
    1196           0 :                     addSubElement( xElem );
    1197             :                 }
    1198             :                 else
    1199             :                 {
    1200             :                     SAL_WARN( "xmlscript.xmldlg", "### unexpected event type in container!" );
    1201             :                 }
    1202           0 :             }
    1203           0 :         }
    1204           0 :     }
    1205           0 : }
    1206             : 
    1207           0 : inline bool equalFont( Style const & style1, Style const & style2 )
    1208             : {
    1209           0 :     awt::FontDescriptor const & f1 = style1._descr;
    1210           0 :     awt::FontDescriptor const & f2 = style2._descr;
    1211             :     return (
    1212           0 :         f1.Name == f2.Name &&
    1213           0 :         f1.Height == f2.Height &&
    1214           0 :         f1.Width == f2.Width &&
    1215           0 :         f1.StyleName == f2.StyleName &&
    1216           0 :         f1.Family == f2.Family &&
    1217           0 :         f1.CharSet == f2.CharSet &&
    1218           0 :         f1.Pitch == f2.CharSet &&
    1219           0 :         f1.CharacterWidth == f2.CharacterWidth &&
    1220           0 :         f1.Weight == f2.Weight &&
    1221           0 :         f1.Slant == f2.Slant &&
    1222           0 :         f1.Underline == f2.Underline &&
    1223           0 :         f1.Strikeout == f2.Strikeout &&
    1224           0 :         f1.Orientation == f2.Orientation &&
    1225           0 :         (f1.Kerning != sal_False) == (f2.Kerning != sal_False) &&
    1226           0 :         (f1.WordLineMode != sal_False) == (f2.WordLineMode != sal_False) &&
    1227           0 :         f1.Type == f2.Type &&
    1228           0 :         style1._fontRelief == style2._fontRelief &&
    1229           0 :         style1._fontEmphasisMark == style2._fontEmphasisMark
    1230           0 :         );
    1231             : }
    1232           0 : OUString StyleBag::getStyleId( Style const & rStyle )
    1233             :     SAL_THROW(())
    1234             : {
    1235           0 :     if (! rStyle._set) // nothin set
    1236             :     {
    1237           0 :         return OUString(); // everything default: no need to export a specific style
    1238             :     }
    1239             : 
    1240             :     // lookup existing style
    1241           0 :     for ( size_t nStylesPos = 0; nStylesPos < _styles.size(); ++nStylesPos )
    1242             :     {
    1243           0 :         Style * pStyle = _styles[ nStylesPos ];
    1244             : 
    1245           0 :         short demanded_defaults = ~rStyle._set & rStyle._all;
    1246             :         // test, if defaults are not set
    1247           0 :         if ((~pStyle->_set & demanded_defaults) == demanded_defaults &&
    1248           0 :             (rStyle._set & (pStyle->_all & ~pStyle->_set)) == 0)
    1249             :         {
    1250           0 :             short bset = rStyle._set & pStyle->_set;
    1251           0 :             if ((bset & 0x1) &&
    1252           0 :                 rStyle._backgroundColor != pStyle->_backgroundColor)
    1253           0 :                 continue;
    1254           0 :             if ((bset & 0x2) &&
    1255           0 :                 rStyle._textColor != pStyle->_textColor)
    1256           0 :                 continue;
    1257           0 :             if ((bset & 0x20) &&
    1258           0 :                 rStyle._textLineColor != pStyle->_textLineColor)
    1259           0 :                 continue;
    1260           0 :             if ((bset & 0x10) &&
    1261           0 :                 rStyle._fillColor != pStyle->_fillColor)
    1262           0 :                 continue;
    1263           0 :             if ((bset & 0x4) &&
    1264           0 :                 (rStyle._border != pStyle->_border ||
    1265           0 :                  (rStyle._border == BORDER_SIMPLE_COLOR &&
    1266           0 :                   rStyle._borderColor != pStyle->_borderColor)))
    1267           0 :                 continue;
    1268           0 :             if ((bset & 0x8) &&
    1269           0 :                 !equalFont( rStyle, *pStyle ))
    1270           0 :                 continue;
    1271           0 :             if ((bset & 0x40) &&
    1272           0 :                 rStyle._visualEffect != pStyle->_visualEffect)
    1273           0 :                 continue;
    1274             : 
    1275             :             // merge in
    1276           0 :             short bnset = rStyle._set & ~pStyle->_set;
    1277           0 :             if (bnset & 0x1)
    1278           0 :                 pStyle->_backgroundColor = rStyle._backgroundColor;
    1279           0 :             if (bnset & 0x2)
    1280           0 :                 pStyle->_textColor = rStyle._textColor;
    1281           0 :             if (bnset & 0x20)
    1282           0 :                 pStyle->_textLineColor = rStyle._textLineColor;
    1283           0 :             if (bnset & 0x10)
    1284           0 :                 pStyle->_fillColor = rStyle._fillColor;
    1285           0 :             if (bnset & 0x4) {
    1286           0 :                 pStyle->_border = rStyle._border;
    1287           0 :                 pStyle->_borderColor = rStyle._borderColor;
    1288             :             }
    1289           0 :             if (bnset & 0x8) {
    1290           0 :                 pStyle->_descr = rStyle._descr;
    1291           0 :                 pStyle->_fontRelief = rStyle._fontRelief;
    1292           0 :                 pStyle->_fontEmphasisMark = rStyle._fontEmphasisMark;
    1293             :             }
    1294           0 :             if (bnset & 0x40)
    1295           0 :                 pStyle->_visualEffect = rStyle._visualEffect;
    1296             : 
    1297           0 :             pStyle->_all |= rStyle._all;
    1298           0 :             pStyle->_set |= rStyle._set;
    1299             : 
    1300           0 :             return pStyle->_id;
    1301             :         }
    1302             :     }
    1303             : 
    1304             :     // no appr style found, append new
    1305           0 :     Style * pStyle = new Style( rStyle );
    1306           0 :     pStyle->_id = OUString::number( _styles.size() );
    1307           0 :     _styles.push_back( pStyle );
    1308           0 :     return pStyle->_id;
    1309             : }
    1310           0 : StyleBag::~StyleBag() SAL_THROW(())
    1311             : {
    1312           0 :     for ( size_t nPos = 0; nPos < _styles.size(); ++nPos )
    1313             :     {
    1314           0 :         delete _styles[ nPos ];
    1315             :     }
    1316           0 : }
    1317           0 : void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
    1318             : {
    1319           0 :     if (! _styles.empty())
    1320             :     {
    1321           0 :         OUString aStylesName( XMLNS_DIALOGS_PREFIX ":styles" );
    1322           0 :         xOut->ignorableWhitespace( OUString() );
    1323           0 :         xOut->startElement( aStylesName, Reference< xml::sax::XAttributeList >() );
    1324             :         // export styles
    1325           0 :         for ( size_t nPos = 0; nPos < _styles.size(); ++nPos )
    1326             :         {
    1327           0 :             Reference< xml::sax::XAttributeList > xAttr( _styles[ nPos ]->createElement() );
    1328           0 :             static_cast< ElementDescriptor * >( xAttr.get() )->dump( xOut.get() );
    1329           0 :         }
    1330           0 :         xOut->ignorableWhitespace( OUString() );
    1331           0 :         xOut->endElement( aStylesName );
    1332             :     }
    1333           0 : }
    1334             : 
    1335           0 : void SAL_CALL exportDialogModel(
    1336             :     Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
    1337             :     Reference< container::XNameContainer > const & xDialogModel,
    1338             :     Reference< frame::XModel > const & xDocument )
    1339             :     SAL_THROW( (Exception) )
    1340             : {
    1341           0 :     StyleBag all_styles;
    1342             :     // window
    1343           0 :     Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY );
    1344             :     OSL_ASSERT( xProps.is() );
    1345           0 :     Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY );
    1346             :     OSL_ASSERT( xPropState.is() );
    1347             : 
    1348           0 :     ElementDescriptor * pElem = new ElementDescriptor( xProps, xPropState, XMLNS_DIALOGS_PREFIX ":bulletinboard", xDocument );
    1349           0 :     Reference< xml::sax::XAttributeList > xElem( pElem );
    1350           0 :     pElem->readBullitinBoard( &all_styles );
    1351             : 
    1352           0 :     xOut->startDocument();
    1353             : 
    1354             :     OUString aDocTypeStr(
    1355             :         "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
    1356           0 :         " \"dialog.dtd\">" );
    1357           0 :     xOut->unknown( aDocTypeStr );
    1358           0 :     xOut->ignorableWhitespace( OUString() );
    1359             : 
    1360           0 :     OUString aWindowName( XMLNS_DIALOGS_PREFIX ":window" );
    1361           0 :     ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName, xDocument );
    1362           0 :     Reference< xml::sax::XAttributeList > xWindow( pWindow );
    1363           0 :     pWindow->readDialogModel( &all_styles );
    1364           0 :     xOut->ignorableWhitespace( OUString() );
    1365           0 :     xOut->startElement( aWindowName, xWindow );
    1366             :      // dump out events
    1367           0 :     pWindow->dumpSubElements( xOut.get() );
    1368             :     // dump out stylebag
    1369           0 :     all_styles.dump( xOut );
    1370             : 
    1371           0 :     if ( xDialogModel->getElementNames().getLength() )
    1372             :     {
    1373             :         // open up bulletinboard
    1374           0 :         OUString aBBoardName( XMLNS_DIALOGS_PREFIX ":bulletinboard" );
    1375           0 :         xOut->ignorableWhitespace( OUString() );
    1376           0 :         xOut->startElement( aBBoardName, xElem );
    1377             : 
    1378           0 :         pElem->dumpSubElements( xOut.get() );
    1379             :         // end bulletinboard
    1380           0 :         xOut->ignorableWhitespace( OUString() );
    1381           0 :         xOut->endElement( aBBoardName );
    1382             :     }
    1383             : 
    1384             :     // end window
    1385           0 :     xOut->ignorableWhitespace( OUString() );
    1386           0 :     xOut->endElement( aWindowName );
    1387             : 
    1388           0 :     xOut->endDocument();
    1389           0 : }
    1390             : 
    1391             : }
    1392             : 
    1393             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10