LCOV - code coverage report
Current view: top level - xmlscript/source/xmldlg_imexp - exp_share.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 33 0.0 %
Date: 2012-08-25 Functions: 0 20 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 48 0.0 %

           Branch data     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 "common.hxx"
      21                 :            : #include "misc.hxx"
      22                 :            : #include <xmlscript/xmldlg_imexp.hxx>
      23                 :            : #include <xmlscript/xml_helper.hxx>
      24                 :            : #include <osl/diagnose.h>
      25                 :            : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      26                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      27                 :            : #include <com/sun/star/beans/XPropertyState.hpp>
      28                 :            : #include <com/sun/star/awt/FontDescriptor.hpp>
      29                 :            : #include <com/sun/star/awt/FontEmphasisMark.hpp>
      30                 :            : #include <com/sun/star/awt/FontRelief.hpp>
      31                 :            : #include <vector>
      32                 :            : 
      33                 :            : 
      34                 :            : namespace css = ::com::sun::star;
      35                 :            : 
      36                 :            : namespace xmlscript
      37                 :            : {
      38                 :            : 
      39                 :          0 : struct Style
      40                 :            : {
      41                 :            :     sal_uInt32 _backgroundColor;
      42                 :            :     sal_uInt32 _textColor;
      43                 :            :     sal_uInt32 _textLineColor;
      44                 :            :     sal_Int16 _border;
      45                 :            :     sal_Int32 _borderColor;
      46                 :            :     css::awt::FontDescriptor _descr;
      47                 :            :     sal_uInt16 _fontRelief;
      48                 :            :     sal_uInt16 _fontEmphasisMark;
      49                 :            :     sal_uInt32 _fillColor;
      50                 :            :     sal_Int16 _visualEffect;
      51                 :            : 
      52                 :            :     // current highest mask: 0x40
      53                 :            :     short _all;
      54                 :            :     short _set;
      55                 :            : 
      56                 :            :     ::rtl::OUString _id;
      57                 :            : 
      58                 :          0 :     inline Style( short all_ ) SAL_THROW(())
      59                 :            :         : _fontRelief( css::awt::FontRelief::NONE )
      60                 :            :         , _fontEmphasisMark( css::awt::FontEmphasisMark::NONE )
      61                 :            :         , _all( all_ )
      62                 :          0 :         , _set( 0 )
      63                 :          0 :         {}
      64                 :            : 
      65                 :            :     css::uno::Reference< css::xml::sax::XAttributeList > createElement();
      66                 :            : };
      67                 :          0 : class StyleBag
      68                 :            : {
      69                 :            :     ::std::vector< Style * > _styles;
      70                 :            : 
      71                 :            : public:
      72                 :            :     ~StyleBag() SAL_THROW(());
      73                 :            : 
      74                 :            :     ::rtl::OUString getStyleId( Style const & rStyle ) SAL_THROW(());
      75                 :            : 
      76                 :            :     void dump( css::uno::Reference< css::xml::sax::XExtendedDocumentHandler >
      77                 :            :                const & xOut );
      78                 :            : };
      79                 :            : 
      80         [ #  # ]:          0 : class ElementDescriptor
      81                 :            :     : public ::xmlscript::XMLElement
      82                 :            : {
      83                 :            :     css::uno::Reference< css::beans::XPropertySet > _xProps;
      84                 :            :     css::uno::Reference< css::beans::XPropertyState > _xPropState;
      85                 :            :     css::uno::Reference< css::frame::XModel > _xDocument;
      86                 :            : 
      87                 :            : public:
      88                 :          0 :     inline ElementDescriptor(
      89                 :            :         css::uno::Reference< css::beans::XPropertySet > const & xProps,
      90                 :            :         css::uno::Reference< css::beans::XPropertyState > const & xPropState,
      91                 :            :         ::rtl::OUString const & name, css::uno::Reference< css::frame::XModel > const & xDocument )
      92                 :            :         SAL_THROW(())
      93                 :            :         : XMLElement( name )
      94                 :            :         , _xProps( xProps )
      95                 :            :         , _xPropState( xPropState )
      96                 :          0 :         , _xDocument( xDocument )
      97                 :          0 :         {}
      98                 :          0 :     inline ElementDescriptor(
      99                 :            :         ::rtl::OUString const & name )
     100                 :            :         SAL_THROW(())
     101                 :          0 :         : XMLElement( name )
     102                 :          0 :         {}
     103                 :            : 
     104                 :            :     template<typename T>
     105                 :            :     inline void read(
     106                 :            :         ::rtl::OUString const & propName, ::rtl::OUString const & attrName,
     107                 :            :         bool forceAttribute = false );
     108                 :            : 
     109                 :            :     template<typename T>
     110                 :            :     inline bool readProp( T * ret, ::rtl::OUString const & rPropName );
     111                 :            :     css::uno::Any readProp( ::rtl::OUString const & rPropName );
     112                 :            :     void readDefaults( bool supportPrintable = true, bool supportVisible = true );
     113                 :            :     void readStringAttr(
     114                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     115                 :          0 :     inline void readDoubleAttr(
     116                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName )
     117                 :          0 :         { read<double>( rPropName, rAttrName ); }
     118                 :          0 :     inline void readLongAttr(
     119                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
     120                 :            :         bool forceAttribute = false )
     121                 :          0 :         { read<sal_Int32>( rPropName, rAttrName, forceAttribute ); }
     122                 :            :     void readHexLongAttr(
     123                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     124                 :          0 :     inline void readShortAttr(
     125                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName )
     126                 :          0 :         { read<sal_Int32>( rPropName, rAttrName ); }
     127                 :          0 :     inline void readBoolAttr(
     128                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName )
     129                 :          0 :         { read<sal_Bool>( rPropName, rAttrName ); }
     130                 :            : 
     131                 :            :     void readAlignAttr(
     132                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     133                 :            :     void readVerticalAlignAttr(
     134                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     135                 :            :     void readImageURLAttr(
     136                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     137                 :            :     void readImageAlignAttr(
     138                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     139                 :            :     void readImagePositionAttr(
     140                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     141                 :            :     void readDateFormatAttr(
     142                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     143                 :            :     void readTimeFormatAttr(
     144                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     145                 :            :     void readOrientationAttr(
     146                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     147                 :            :     void readButtonTypeAttr(
     148                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     149                 :            :     void readLineEndFormatAttr(
     150                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     151                 :            :     void readSelectionTypeAttr(
     152                 :            :         ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
     153                 :            :     void readDataAwareAttr(
     154                 :            :         ::rtl::OUString const & rAttrName );
     155                 :          0 :     inline void addBoolAttr(
     156                 :            :         ::rtl::OUString const & rAttrName, sal_Bool bValue )
     157         [ #  # ]:          0 :         { addAttribute( rAttrName, ::rtl::OUString::valueOf(bValue) ); }
     158                 :            :     void addNumberFormatAttr(
     159                 :            :         css::uno::Reference< css::beans::XPropertySet >
     160                 :            :         const & xFormatProperties );
     161                 :            : 
     162                 :            :     void readEvents() SAL_THROW( (css::uno::Exception) );
     163                 :            :     void readDialogModel( StyleBag * all_styles )
     164                 :            :         SAL_THROW( (css::uno::Exception) );
     165                 :            :     void readBullitinBoard( StyleBag * all_styles )
     166                 :            :         SAL_THROW( (css::uno::Exception) );
     167                 :            :     void readMultiPageModel( StyleBag * all_styles )
     168                 :            :         SAL_THROW( (css::uno::Exception) );
     169                 :            :     void readFrameModel( StyleBag * all_styles )
     170                 :            :         SAL_THROW( (css::uno::Exception) );
     171                 :            :     void readPageModel( StyleBag * all_styles )
     172                 :            :         SAL_THROW( (css::uno::Exception) );
     173                 :            :     void readButtonModel( StyleBag * all_styles )
     174                 :            :         SAL_THROW( (css::uno::Exception) );
     175                 :            :     void readEditModel( StyleBag * all_styles )
     176                 :            :         SAL_THROW( (css::uno::Exception) );
     177                 :            :     void readCheckBoxModel( StyleBag * all_styles )
     178                 :            :         SAL_THROW( (css::uno::Exception) );
     179                 :            :     void readRadioButtonModel( StyleBag * all_styles )
     180                 :            :         SAL_THROW( (css::uno::Exception) );
     181                 :            :     void readComboBoxModel( StyleBag * all_styles )
     182                 :            :         SAL_THROW( (css::uno::Exception) );
     183                 :            :     void readCurrencyFieldModel( StyleBag * all_styles )
     184                 :            :         SAL_THROW( (css::uno::Exception) );
     185                 :            :     void readDateFieldModel( StyleBag * all_styles )
     186                 :            :         SAL_THROW( (css::uno::Exception) );
     187                 :            :     void readFileControlModel( StyleBag * all_styles )
     188                 :            :         SAL_THROW( (css::uno::Exception) );
     189                 :            :     void readTreeControlModel( StyleBag * all_styles )
     190                 :            :         SAL_THROW( (css::uno::Exception) );
     191                 :            :     void readFixedTextModel( StyleBag * all_styles )
     192                 :            :         SAL_THROW( (css::uno::Exception) );
     193                 :            :     void readGroupBoxModel( StyleBag * all_styles )
     194                 :            :         SAL_THROW( (css::uno::Exception) );
     195                 :            :     void readImageControlModel( StyleBag * all_styles )
     196                 :            :         SAL_THROW( (css::uno::Exception) );
     197                 :            :     void readListBoxModel( StyleBag * all_styles )
     198                 :            :         SAL_THROW( (css::uno::Exception) );
     199                 :            :     void readNumericFieldModel( StyleBag * all_styles )
     200                 :            :         SAL_THROW( (css::uno::Exception) );
     201                 :            :     void readPatternFieldModel( StyleBag * all_styles )
     202                 :            :         SAL_THROW( (css::uno::Exception) );
     203                 :            :     void readFormattedFieldModel( StyleBag * all_styles )
     204                 :            :         SAL_THROW( (css::uno::Exception) );
     205                 :            :     void readTimeFieldModel( StyleBag * all_styles )
     206                 :            :         SAL_THROW( (css::uno::Exception) );
     207                 :            :     void readFixedLineModel( StyleBag * all_styles )
     208                 :            :         SAL_THROW( (css::uno::Exception) );
     209                 :            :     void readProgressBarModel( StyleBag * all_styles )
     210                 :            :         SAL_THROW( (css::uno::Exception) );
     211                 :            :     void readScrollBarModel( StyleBag * all_styles )
     212                 :            :         SAL_THROW( (css::uno::Exception) );
     213                 :            :     void readSpinButtonModel( StyleBag * all_styles )
     214                 :            :         SAL_THROW( (css::uno::Exception) );
     215                 :            :     void readFixedHyperLinkModel( StyleBag * all_styles )
     216                 :            :         SAL_THROW( (css::uno::Exception) );
     217                 :            : };
     218                 :            : 
     219                 :            : template<typename T>
     220                 :          0 : inline void ElementDescriptor::read(
     221                 :            :     ::rtl::OUString const & propName, ::rtl::OUString const & attrName,
     222                 :            :     bool forceAttribute )
     223                 :            : {
     224 [ #  # ][ #  # ]:          0 :     if (forceAttribute ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     225                 :            :         css::beans::PropertyState_DEFAULT_VALUE !=
     226                 :            :         _xPropState->getPropertyState( propName ))
     227                 :            :     {
     228 [ #  # ][ #  # ]:          0 :         css::uno::Any a( _xProps->getPropertyValue( propName ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     229                 :          0 :         T v = T();
     230 [ #  # ][ #  # ]:          0 :         if (a >>= v)
                 [ #  # ]
     231 [ #  # ][ #  # ]:          0 :             addAttribute( attrName, ::rtl::OUString::valueOf(v) );
                 [ #  # ]
     232                 :            :         else
     233                 :          0 :             OSL_FAIL( "### unexpected property type!" );
     234                 :            :     }
     235                 :          0 : }
     236                 :            : 
     237                 :            : template<typename T>
     238                 :          0 : inline bool ElementDescriptor::readProp(
     239                 :            :     T * ret, ::rtl::OUString const & rPropName )
     240                 :            : {
     241         [ #  # ]:          0 :     _xProps->getPropertyValue( rPropName ) >>= *ret;
     242                 :            :     return css::beans::PropertyState_DEFAULT_VALUE !=
     243                 :          0 :         _xPropState->getPropertyState( rPropName );
     244                 :            : }
     245                 :            : 
     246                 :            : }
     247                 :            : 
     248                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10