LCOV - code coverage report
Current view: top level - xmlscript/source/xmldlg_imexp - xmldlg_export.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 251 705 35.6 %
Date: 2014-11-03 Functions: 19 27 70.4 %
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          16 : Reference< xml::sax::XAttributeList > Style::createElement()
      74             : {
      75          16 :     ElementDescriptor * pStyle = new ElementDescriptor( XMLNS_DIALOGS_PREFIX ":style" );
      76             : 
      77             :     // style-id
      78          16 :     pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":style-id", _id );
      79             : 
      80             :     // background-color
      81          16 :     if (_set & 0x1)
      82             :     {
      83          16 :         pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":background-color", "0x" + OUString::number(_backgroundColor,16));
      84             :     }
      85             : 
      86             :     // text-color
      87          16 :     if (_set & 0x2)
      88             :     {
      89          12 :         pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":text-color", "0x" + OUString::number(_textColor,16));
      90             :     }
      91             : 
      92             :     // textline-color
      93          16 :     if (_set & 0x20)
      94             :     {
      95           0 :         pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":textline-color", "0x" + OUString::number(_textLineColor,16));
      96             :     }
      97             : 
      98             :     // fill-color
      99          16 :     if (_set & 0x10)
     100             :     {
     101           0 :         pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":fill-color", "0x" + OUString::number(_fillColor,16));
     102             :     }
     103             : 
     104             :     // border
     105          16 :     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          16 :     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          16 :     if (_set & 0x8)
     150             :     {
     151          12 :         awt::FontDescriptor def_descr;
     152             : 
     153             :         // dialog:font-name CDATA #IMPLIED
     154          12 :         if (def_descr.Name != _descr.Name)
     155             :         {
     156          12 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-name", _descr.Name );
     157             :         }
     158             :         // dialog:font-height %numeric; #IMPLIED
     159          12 :         if (def_descr.Height != _descr.Height)
     160             :         {
     161          12 :             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-height", OUString::number( _descr.Height ) );
     162             :         }
     163             :         // dialog:font-width %numeric; #IMPLIED
     164          12 :         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          12 :         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          12 :         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          12 :         if (def_descr.CharSet != _descr.CharSet)
     203             :         {
     204          12 :             switch (_descr.CharSet)
     205             :             {
     206             :             case awt::CharSet::ANSI:
     207          12 :                 pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":font-charset", "ansi" );
     208          12 :                 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          12 :         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          12 :         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          12 :         if (def_descr.Weight != _descr.Weight)
     264             :         {
     265          12 :             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          12 :         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          12 :         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          12 :         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          12 :         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          12 :         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          12 :         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          12 :         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          12 :         switch (_fontRelief)
     413             :         {
     414             :         case awt::FontRelief::NONE: // dont export default
     415          12 :             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          12 :         switch (_fontEmphasisMark)
     428             :         {
     429             :         case awt::FontEmphasisMark::NONE: // dont export default
     430          12 :             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          12 :         }
     453             :     }
     454             : 
     455          16 :     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         106 : Any ElementDescriptor::readProp( OUString const & rPropName )
     489             : {
     490         106 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     491             :     {
     492          32 :         return _xProps->getPropertyValue( rPropName );
     493             :     }
     494          74 :     return Any();
     495             : }
     496             : 
     497         110 : void ElementDescriptor::readStringAttr(
     498             :     OUString const & rPropName, OUString const & rAttrName )
     499             : {
     500         110 :     if (beans::PropertyState_DEFAULT_VALUE !=
     501         110 :         _xPropState->getPropertyState( rPropName ))
     502             :     {
     503          10 :         Any a( _xProps->getPropertyValue( rPropName ) );
     504          20 :         OUString v;
     505          10 :         if (a >>= v)
     506          10 :             addAttribute( rAttrName, v );
     507             :         else
     508          10 :             SAL_WARN( "xmlscript.xmldlg", "### unexpected property type!" );
     509             :     }
     510         110 : }
     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() == cppu::UnoType<util::Date>::get())
     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() == cppu::UnoType<util::Time>::get())
     606             :         {
     607           0 :             util::Time aUTime;
     608           0 :             if (a >>= aUTime)
     609             :             {
     610           0 :                 ::tools::Time aTTime(aUTime);
     611           0 :                 addAttribute( rAttrName, OUString::number( aTTime.GetTime() / ::tools::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          18 : void ElementDescriptor::readAlignAttr( OUString const & rPropName, OUString const & rAttrName )
     659             : {
     660          18 :     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          18 : }
     685             : 
     686           6 : void ElementDescriptor::readVerticalAlignAttr( OUString const & rPropName, OUString const & rAttrName )
     687             : {
     688           6 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     689             :     {
     690           6 :         Any a( _xProps->getPropertyValue( rPropName ) );
     691           6 :         if (a.getValueTypeClass() == TypeClass_ENUM && a.getValueType() == cppu::UnoType<style::VerticalAlignment>::get())
     692             :         {
     693             :             style::VerticalAlignment eAlign;
     694           6 :             a >>= eAlign;
     695           6 :             switch (eAlign)
     696             :             {
     697             :             case style::VerticalAlignment_TOP:
     698           0 :                 addAttribute( rAttrName, "top" );
     699           0 :                 break;
     700             :             case style::VerticalAlignment_MIDDLE:
     701           6 :                 addAttribute( rAttrName, "center" );
     702           6 :                 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           6 :             OSL_FAIL( "### unexpected property type!" );
     713             :     }
     714           6 : }
     715             : 
     716          16 : void ElementDescriptor::readImageURLAttr( OUString const & rPropName, OUString const & rAttrName )
     717             : {
     718          16 :     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          16 : }
     738             : 
     739           2 : void ElementDescriptor::readImageAlignAttr( OUString const & rPropName, OUString const & rAttrName )
     740             : {
     741           2 :     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           2 : }
     769             : 
     770           6 : void ElementDescriptor::readImagePositionAttr( OUString const & rPropName, OUString const & rAttrName )
     771             : {
     772           6 :     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
     773             :     {
     774           6 :         Any a( _xProps->getPropertyValue( rPropName ) );
     775           6 :         if (a.getValueTypeClass() == TypeClass_SHORT)
     776             :         {
     777           6 :             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           6 :                 addAttribute( rAttrName, "top-center" );
     802           6 :                 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           6 :         }
     823             :     }
     824           6 : }
     825             : 
     826           2 : void ElementDescriptor::readButtonTypeAttr( OUString const & rPropName, OUString const & rAttrName )
     827             : {
     828           2 :     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           2 : }
     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           8 : void ElementDescriptor::readLineEndFormatAttr( OUString const & rPropName, OUString const & rAttrName )
     879             : {
     880           8 :     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           8 : }
     903             : 
     904          18 : void ElementDescriptor::readDataAwareAttr( OUString const & rAttrName )
     905             : {
     906          18 :     Reference< lang::XMultiServiceFactory > xFac;
     907          18 :     if ( _xDocument.is() )
     908          18 :         xFac.set( _xDocument, uno::UNO_QUERY );
     909             : 
     910          36 :     Reference< form::binding::XBindableValue > xBinding( _xProps, UNO_QUERY );
     911             : 
     912          18 :     if ( xFac.is() && xBinding.is() && rAttrName.equals( XMLNS_DIALOGS_PREFIX ":linked-cell" ) )
     913             :     {
     914             :         try
     915             :         {
     916           6 :             Reference< beans::XPropertySet > xConvertor( xFac->createInstance( "com.sun.star.table.CellAddressConversion" ), uno::UNO_QUERY );
     917          12 :         Reference< beans::XPropertySet > xBindable( xBinding->getValueBinding(), UNO_QUERY );
     918           6 :             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           6 :             }
     931             :         }
     932           0 :         catch( uno::Exception& )
     933             :         {
     934             :         }
     935             :     }
     936          36 :     Reference< form::binding::XListEntrySink > xEntrySink( _xProps, UNO_QUERY );
     937          18 :     if ( xEntrySink.is() && rAttrName.equals( XMLNS_DIALOGS_PREFIX ":source-cell-range" ) )
     938             :     {
     939           4 :         Reference< beans::XPropertySet > xListSource( xEntrySink->getListEntrySource(), UNO_QUERY );
     940           4 :         if ( xListSource.is() )
     941             :         {
     942             :             try
     943             :             {
     944           2 :                 Reference< beans::XPropertySet > xConvertor( xFac->createInstance( "com.sun.star.table.CellRangeAddressConversion" ), uno::UNO_QUERY );
     945             : 
     946           2 :                 table::CellRangeAddress aAddress;
     947           2 :                 xListSource->getPropertyValue( "CellRange" ) >>= aAddress;
     948             : 
     949           4 :                 OUString sAddress;
     950           2 :                 xConvertor->setPropertyValue( "Address", makeAny( aAddress ) );
     951           2 :                 xConvertor->getPropertyValue( "PersistentRepresentation" ) >>= sAddress;
     952             :                 SAL_INFO("xmlscript.xmldlg","**** cell range source list " << sAddress );
     953           2 :                 if ( !sAddress.isEmpty() )
     954           4 :                     addAttribute( rAttrName, sAddress );
     955             :             }
     956           0 :             catch( uno::Exception& )
     957             :             {
     958             :             }
     959           4 :         }
     960          18 :     }
     961          18 : }
     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() == cppu::UnoType<view::SelectionType>::get())
     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          10 : void ElementDescriptor::readScrollableSettings()
     997             : {
     998             :     readLongAttr( "ScrollHeight",
     999          10 :                   XMLNS_DIALOGS_PREFIX ":scrollheight" );
    1000             :     readLongAttr( "ScrollWidth",
    1001          10 :                   XMLNS_DIALOGS_PREFIX ":scrollwidth" );
    1002             :     readLongAttr( "ScrollTop",
    1003          10 :                   XMLNS_DIALOGS_PREFIX ":scrolltop" );
    1004             :     readLongAttr( "ScrollLeft",
    1005          10 :                   XMLNS_DIALOGS_PREFIX ":scrollleft" );
    1006             :     readBoolAttr( "HScroll",
    1007          10 :                   XMLNS_DIALOGS_PREFIX ":hscroll" );
    1008             :     readBoolAttr( "VScroll",
    1009          10 :                   XMLNS_DIALOGS_PREFIX ":vscroll" );
    1010          10 : }
    1011             : 
    1012          28 : void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible )
    1013             : {
    1014          28 :     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             :     // incoming 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          56 :     Reference< lang::XServiceInfo > xSrvInfo( _xProps, UNO_QUERY );
    1027          28 :     if ( xSrvInfo.is() && xSrvInfo->supportsService( "com.sun.star.form.FormComponent" ) )
    1028             :     {
    1029           6 :         Reference< io::XPersistObject > xPersist( _xProps, UNO_QUERY );
    1030           6 :         if ( xPersist.is() )
    1031             :         {
    1032           6 :             OUString sCtrlName = xPersist->getServiceName();
    1033           6 :             if ( !sCtrlName.isEmpty() )
    1034           6 :                     addAttribute( XMLNS_DIALOGS_PREFIX ":control-implementation", sCtrlName );
    1035           6 :         }
    1036             :     }
    1037          28 :     addAttribute( XMLNS_DIALOGS_PREFIX ":id", * reinterpret_cast< const OUString * >( a.getValue() ) );
    1038          28 :     readShortAttr( "TabIndex", XMLNS_DIALOGS_PREFIX ":tab-index" );
    1039             : 
    1040          28 :     bool bEnabled = false;
    1041          28 :     if (_xProps->getPropertyValue( "Enabled" ) >>= bEnabled)
    1042             :     {
    1043          28 :         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          28 :     bool bVisible = true;
    1054          28 :     if (supportVisible) try
    1055             :     {
    1056          18 :         if (_xProps->getPropertyValue("EnableVisible" ) >>= bVisible)
    1057             :         {
    1058             : 
    1059             :             // only write out the non default case
    1060          18 :             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          28 :     a = _xProps->getPropertyValue( "PositionX" );
    1072          28 :     if (a.getValueTypeClass() == TypeClass_LONG)
    1073             :     {
    1074          28 :         addAttribute( XMLNS_DIALOGS_PREFIX ":left", OUString::number( *(sal_Int32 const *)a.getValue() ) );
    1075             :     }
    1076          28 :     a = _xProps->getPropertyValue( "PositionY" );
    1077          28 :     if (a.getValueTypeClass() == TypeClass_LONG)
    1078             :     {
    1079          28 :         addAttribute( XMLNS_DIALOGS_PREFIX ":top", OUString::number( *(sal_Int32 const *)a.getValue() ) );
    1080             :     }
    1081          28 :     a = _xProps->getPropertyValue( "Width" );
    1082          28 :     if (a.getValueTypeClass() == TypeClass_LONG)
    1083             :     {
    1084          28 :         addAttribute( XMLNS_DIALOGS_PREFIX ":width", OUString::number( *(sal_Int32 const *)a.getValue() ) );
    1085             :     }
    1086          28 :     a = _xProps->getPropertyValue( "Height" );
    1087          28 :     if (a.getValueTypeClass() == TypeClass_LONG)
    1088             :     {
    1089          28 :         addAttribute( XMLNS_DIALOGS_PREFIX ":height", OUString::number( *(sal_Int32 const *)a.getValue() ) );
    1090             :     }
    1091             : 
    1092          28 :     if (supportPrintable)
    1093             :     {
    1094          18 :         readBoolAttr( "Printable", XMLNS_DIALOGS_PREFIX ":printable" );
    1095             :     }
    1096          28 :     readLongAttr( "Step", XMLNS_DIALOGS_PREFIX ":page" );
    1097          28 :     readStringAttr( "Tag", XMLNS_DIALOGS_PREFIX ":tag" );
    1098          28 :     readStringAttr( "HelpText", XMLNS_DIALOGS_PREFIX ":help-text" );
    1099          56 :     readStringAttr( "HelpURL", XMLNS_DIALOGS_PREFIX ":help-url" );
    1100          28 : }
    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          28 : void ElementDescriptor::readEvents()
    1111             : {
    1112          28 :     Reference< script::XScriptEventsSupplier > xSupplier( _xProps, UNO_QUERY );
    1113          28 :     if (xSupplier.is())
    1114             :     {
    1115          28 :         Reference< container::XNameContainer > xEvents( xSupplier->getEvents() );
    1116          28 :         if (xEvents.is())
    1117             :         {
    1118          28 :             Sequence< OUString > aNames( xEvents->getElementNames() );
    1119          28 :             OUString const * pNames = aNames.getConstArray();
    1120          28 :             for ( sal_Int32 nPos = 0; nPos < aNames.getLength(); ++nPos )
    1121             :             {
    1122           0 :                 script::ScriptEventDescriptor descr;
    1123           0 :                 if (xEvents->getByName( pNames[ nPos ] ) >>= descr)
    1124             :                 {
    1125             :                     SAL_WARN_IF( descr.ListenerType.isEmpty() ||
    1126             :                                 descr.EventMethod.isEmpty() ||
    1127             :                                 descr.ScriptCode.isEmpty() ||
    1128             :                                 descr.ScriptType.isEmpty() , "xmlscript.xmldlg", "### invalid event descr!" );
    1129             : 
    1130           0 :                     OUString aEventName;
    1131             : 
    1132           0 :                     if (descr.AddListenerParam.isEmpty())
    1133             :                     {
    1134             :                         // detection of event-name
    1135           0 :                         OString listenerType( OUStringToOString( descr.ListenerType, RTL_TEXTENCODING_ASCII_US ) );
    1136           0 :                         OString eventMethod( OUStringToOString( descr.EventMethod, RTL_TEXTENCODING_ASCII_US ) );
    1137           0 :                         StringTriple const * p = g_pEventTranslations;
    1138           0 :                         while (p->first)
    1139             :                         {
    1140           0 :                             if (0 == ::rtl_str_compare( p->second, eventMethod.getStr() ) &&
    1141           0 :                                 0 == ::rtl_str_compare( p->first, listenerType.getStr() ))
    1142             :                             {
    1143           0 :                                 aEventName = OUString( p->third, ::rtl_str_getLength( p->third ), RTL_TEXTENCODING_ASCII_US );
    1144           0 :                                 break;
    1145             :                             }
    1146           0 :                             ++p;
    1147           0 :                         }
    1148             :                     }
    1149             : 
    1150             :                     ElementDescriptor * pElem;
    1151           0 :                     Reference< xml::sax::XAttributeList > xElem;
    1152             : 
    1153           0 :                     if (!aEventName.isEmpty()) // script:event
    1154             :                     {
    1155           0 :                         pElem = new ElementDescriptor( XMLNS_SCRIPT_PREFIX ":event" );
    1156           0 :                         xElem = pElem;
    1157             : 
    1158           0 :                         pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":event-name", aEventName );
    1159             :                     }
    1160             :                     else // script:listener-event
    1161             :                     {
    1162           0 :                         pElem = new ElementDescriptor( XMLNS_SCRIPT_PREFIX ":listener-event" );
    1163           0 :                         xElem = pElem;
    1164             : 
    1165           0 :                         pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":listener-type", descr.ListenerType );
    1166           0 :                         pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":listener-method", descr.EventMethod );
    1167             : 
    1168           0 :                         if (!descr.AddListenerParam.isEmpty())
    1169             :                         {
    1170           0 :                             pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":listener-param", descr.AddListenerParam );
    1171             :                         }
    1172             :                     }
    1173           0 :                     if ( descr.ScriptType == "StarBasic" )
    1174             :                     {
    1175             :                         // separate optional location
    1176           0 :                         sal_Int32 nIndex = descr.ScriptCode.indexOf( (sal_Unicode)':' );
    1177           0 :                         if (nIndex >= 0)
    1178             :                         {
    1179           0 :                             pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":location", descr.ScriptCode.copy( 0, nIndex ) );
    1180           0 :                             pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":macro-name", descr.ScriptCode.copy( nIndex +1 ) );
    1181             :                         }
    1182             :                         else
    1183             :                         {
    1184           0 :                             pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":macro-name", descr.ScriptCode );
    1185             :                         }
    1186             :                     }
    1187             :                     else
    1188             :                     {
    1189           0 :                         pElem->addAttribute(XMLNS_SCRIPT_PREFIX ":macro-name", descr.ScriptCode );
    1190             :                     }
    1191             : 
    1192             :                     // language
    1193           0 :                     pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":language", descr.ScriptType );
    1194             : 
    1195           0 :                     addSubElement( xElem );
    1196             :                 }
    1197             :                 else
    1198             :                 {
    1199             :                     SAL_WARN( "xmlscript.xmldlg", "### unexpected event type in container!" );
    1200             :                 }
    1201          28 :             }
    1202          28 :         }
    1203          28 :     }
    1204          28 : }
    1205             : 
    1206          12 : inline bool equalFont( Style const & style1, Style const & style2 )
    1207             : {
    1208          12 :     awt::FontDescriptor const & f1 = style1._descr;
    1209          12 :     awt::FontDescriptor const & f2 = style2._descr;
    1210             :     return (
    1211          24 :         f1.Name == f2.Name &&
    1212          24 :         f1.Height == f2.Height &&
    1213          24 :         f1.Width == f2.Width &&
    1214          24 :         f1.StyleName == f2.StyleName &&
    1215          24 :         f1.Family == f2.Family &&
    1216          24 :         f1.CharSet == f2.CharSet &&
    1217          12 :         f1.Pitch == f2.CharSet &&
    1218           0 :         f1.CharacterWidth == f2.CharacterWidth &&
    1219           0 :         f1.Weight == f2.Weight &&
    1220           0 :         f1.Slant == f2.Slant &&
    1221           0 :         f1.Underline == f2.Underline &&
    1222           0 :         f1.Strikeout == f2.Strikeout &&
    1223           0 :         f1.Orientation == f2.Orientation &&
    1224           0 :         (f1.Kerning != sal_False) == (f2.Kerning != sal_False) &&
    1225           0 :         (f1.WordLineMode != sal_False) == (f2.WordLineMode != sal_False) &&
    1226           0 :         f1.Type == f2.Type &&
    1227          12 :         style1._fontRelief == style2._fontRelief &&
    1228           0 :         style1._fontEmphasisMark == style2._fontEmphasisMark
    1229          12 :         );
    1230             : }
    1231             : 
    1232          16 : OUString StyleBag::getStyleId( Style const & rStyle )
    1233             : {
    1234          16 :     if (! rStyle._set) // nothin set
    1235             :     {
    1236           0 :         return OUString(); // everything default: no need to export a specific style
    1237             :     }
    1238             : 
    1239             :     // lookup existing style
    1240          40 :     for ( size_t nStylesPos = 0; nStylesPos < _styles.size(); ++nStylesPos )
    1241             :     {
    1242          24 :         Style * pStyle = _styles[ nStylesPos ];
    1243             : 
    1244          24 :         short demanded_defaults = ~rStyle._set & rStyle._all;
    1245             :         // test, if defaults are not set
    1246          36 :         if ((~pStyle->_set & demanded_defaults) == demanded_defaults &&
    1247          12 :             (rStyle._set & (pStyle->_all & ~pStyle->_set)) == 0)
    1248             :         {
    1249          12 :             short bset = rStyle._set & pStyle->_set;
    1250          24 :             if ((bset & 0x1) &&
    1251          12 :                 rStyle._backgroundColor != pStyle->_backgroundColor)
    1252           0 :                 continue;
    1253          24 :             if ((bset & 0x2) &&
    1254          12 :                 rStyle._textColor != pStyle->_textColor)
    1255           0 :                 continue;
    1256          12 :             if ((bset & 0x20) &&
    1257           0 :                 rStyle._textLineColor != pStyle->_textLineColor)
    1258           0 :                 continue;
    1259          12 :             if ((bset & 0x10) &&
    1260           0 :                 rStyle._fillColor != pStyle->_fillColor)
    1261           0 :                 continue;
    1262          12 :             if ((bset & 0x4) &&
    1263           0 :                 (rStyle._border != pStyle->_border ||
    1264           0 :                  (rStyle._border == BORDER_SIMPLE_COLOR &&
    1265           0 :                   rStyle._borderColor != pStyle->_borderColor)))
    1266           0 :                 continue;
    1267          24 :             if ((bset & 0x8) &&
    1268          12 :                 !equalFont( rStyle, *pStyle ))
    1269          12 :                 continue;
    1270           0 :             if ((bset & 0x40) &&
    1271           0 :                 rStyle._visualEffect != pStyle->_visualEffect)
    1272           0 :                 continue;
    1273             : 
    1274             :             // merge in
    1275           0 :             short bnset = rStyle._set & ~pStyle->_set;
    1276           0 :             if (bnset & 0x1)
    1277           0 :                 pStyle->_backgroundColor = rStyle._backgroundColor;
    1278           0 :             if (bnset & 0x2)
    1279           0 :                 pStyle->_textColor = rStyle._textColor;
    1280           0 :             if (bnset & 0x20)
    1281           0 :                 pStyle->_textLineColor = rStyle._textLineColor;
    1282           0 :             if (bnset & 0x10)
    1283           0 :                 pStyle->_fillColor = rStyle._fillColor;
    1284           0 :             if (bnset & 0x4) {
    1285           0 :                 pStyle->_border = rStyle._border;
    1286           0 :                 pStyle->_borderColor = rStyle._borderColor;
    1287             :             }
    1288           0 :             if (bnset & 0x8) {
    1289           0 :                 pStyle->_descr = rStyle._descr;
    1290           0 :                 pStyle->_fontRelief = rStyle._fontRelief;
    1291           0 :                 pStyle->_fontEmphasisMark = rStyle._fontEmphasisMark;
    1292             :             }
    1293           0 :             if (bnset & 0x40)
    1294           0 :                 pStyle->_visualEffect = rStyle._visualEffect;
    1295             : 
    1296           0 :             pStyle->_all |= rStyle._all;
    1297           0 :             pStyle->_set |= rStyle._set;
    1298             : 
    1299           0 :             return pStyle->_id;
    1300             :         }
    1301             :     }
    1302             : 
    1303             :     // no appr style found, append new
    1304          16 :     Style * pStyle = new Style( rStyle );
    1305          16 :     pStyle->_id = OUString::number( _styles.size() );
    1306          16 :     _styles.push_back( pStyle );
    1307          16 :     return pStyle->_id;
    1308             : }
    1309             : 
    1310          20 : StyleBag::~StyleBag()
    1311             : {
    1312          26 :     for ( size_t nPos = 0; nPos < _styles.size(); ++nPos )
    1313             :     {
    1314          16 :         delete _styles[ nPos ];
    1315             :     }
    1316          10 : }
    1317             : 
    1318          10 : void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
    1319             : {
    1320          10 :     if (! _styles.empty())
    1321             :     {
    1322           4 :         OUString aStylesName( XMLNS_DIALOGS_PREFIX ":styles" );
    1323           4 :         xOut->ignorableWhitespace( OUString() );
    1324           4 :         xOut->startElement( aStylesName, Reference< xml::sax::XAttributeList >() );
    1325             :         // export styles
    1326          20 :         for ( size_t nPos = 0; nPos < _styles.size(); ++nPos )
    1327             :         {
    1328          16 :             Reference< xml::sax::XAttributeList > xAttr( _styles[ nPos ]->createElement() );
    1329          16 :             static_cast< ElementDescriptor * >( xAttr.get() )->dump( xOut.get() );
    1330          16 :         }
    1331           4 :         xOut->ignorableWhitespace( OUString() );
    1332           4 :         xOut->endElement( aStylesName );
    1333             :     }
    1334          10 : }
    1335             : 
    1336          10 : void SAL_CALL exportDialogModel(
    1337             :     Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
    1338             :     Reference< container::XNameContainer > const & xDialogModel,
    1339             :     Reference< frame::XModel > const & xDocument )
    1340             : {
    1341          10 :     StyleBag all_styles;
    1342             :     // window
    1343          20 :     Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY );
    1344             :     OSL_ASSERT( xProps.is() );
    1345          20 :     Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY );
    1346             :     OSL_ASSERT( xPropState.is() );
    1347             : 
    1348          10 :     ElementDescriptor * pElem = new ElementDescriptor( xProps, xPropState, XMLNS_DIALOGS_PREFIX ":bulletinboard", xDocument );
    1349          20 :     Reference< xml::sax::XAttributeList > xElem( pElem );
    1350          10 :     pElem->readBullitinBoard( &all_styles );
    1351             : 
    1352          10 :     xOut->startDocument();
    1353             : 
    1354             :     OUString aDocTypeStr(
    1355             :         "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
    1356          20 :         " \"dialog.dtd\">" );
    1357          10 :     xOut->unknown( aDocTypeStr );
    1358          10 :     xOut->ignorableWhitespace( OUString() );
    1359             : 
    1360          20 :     OUString aWindowName( XMLNS_DIALOGS_PREFIX ":window" );
    1361          10 :     ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName, xDocument );
    1362          20 :     Reference< xml::sax::XAttributeList > xWindow( pWindow );
    1363          10 :     pWindow->readDialogModel( &all_styles );
    1364          10 :     xOut->ignorableWhitespace( OUString() );
    1365          10 :     xOut->startElement( aWindowName, xWindow );
    1366             :      // dump out events
    1367          10 :     pWindow->dumpSubElements( xOut.get() );
    1368             :     // dump out stylebag
    1369          10 :     all_styles.dump( xOut );
    1370             : 
    1371          10 :     if ( xDialogModel->getElementNames().getLength() )
    1372             :     {
    1373             :         // open up bulletinboard
    1374          10 :         OUString aBBoardName( XMLNS_DIALOGS_PREFIX ":bulletinboard" );
    1375          10 :         xOut->ignorableWhitespace( OUString() );
    1376          10 :         xOut->startElement( aBBoardName, xElem );
    1377             : 
    1378          10 :         pElem->dumpSubElements( xOut.get() );
    1379             :         // end bulletinboard
    1380          10 :         xOut->ignorableWhitespace( OUString() );
    1381          10 :         xOut->endElement( aBBoardName );
    1382             :     }
    1383             : 
    1384             :     // end window
    1385          10 :     xOut->ignorableWhitespace( OUString() );
    1386          10 :     xOut->endElement( aWindowName );
    1387             : 
    1388          20 :     xOut->endDocument();
    1389          10 : }
    1390             : 
    1391             : }
    1392             : 
    1393             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10