LCOV - code coverage report
Current view: top level - libreoffice/xmlscript/source/xmldlg_imexp - exp_share.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 33 0.0 %
Date: 2012-12-27 Functions: 0 20 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "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 xmlscript
      35             : {
      36             : 
      37           0 : struct Style
      38             : {
      39             :     sal_uInt32 _backgroundColor;
      40             :     sal_uInt32 _textColor;
      41             :     sal_uInt32 _textLineColor;
      42             :     sal_Int16 _border;
      43             :     sal_Int32 _borderColor;
      44             :     css::awt::FontDescriptor _descr;
      45             :     sal_uInt16 _fontRelief;
      46             :     sal_uInt16 _fontEmphasisMark;
      47             :     sal_uInt32 _fillColor;
      48             :     sal_Int16 _visualEffect;
      49             : 
      50             :     // current highest mask: 0x40
      51             :     short _all;
      52             :     short _set;
      53             : 
      54             :     OUString _id;
      55             : 
      56           0 :     inline Style( short all_ ) SAL_THROW(())
      57             :         : _fontRelief( css::awt::FontRelief::NONE )
      58             :         , _fontEmphasisMark( css::awt::FontEmphasisMark::NONE )
      59             :         , _all( all_ )
      60           0 :         , _set( 0 )
      61           0 :         {}
      62             : 
      63             :     css::uno::Reference< css::xml::sax::XAttributeList > createElement();
      64             : };
      65           0 : class StyleBag
      66             : {
      67             :     ::std::vector< Style * > _styles;
      68             : 
      69             : public:
      70             :     ~StyleBag() SAL_THROW(());
      71             : 
      72             :     OUString getStyleId( Style const & rStyle ) SAL_THROW(());
      73             : 
      74             :     void dump( css::uno::Reference< css::xml::sax::XExtendedDocumentHandler >
      75             :                const & xOut );
      76             : };
      77             : 
      78           0 : class ElementDescriptor
      79             :     : public ::xmlscript::XMLElement
      80             : {
      81             :     css::uno::Reference< css::beans::XPropertySet > _xProps;
      82             :     css::uno::Reference< css::beans::XPropertyState > _xPropState;
      83             :     css::uno::Reference< css::frame::XModel > _xDocument;
      84             : 
      85             : public:
      86           0 :     inline ElementDescriptor(
      87             :         css::uno::Reference< css::beans::XPropertySet > const & xProps,
      88             :         css::uno::Reference< css::beans::XPropertyState > const & xPropState,
      89             :         OUString const & name, css::uno::Reference< css::frame::XModel > const & xDocument )
      90             :         SAL_THROW(())
      91             :         : XMLElement( name )
      92             :         , _xProps( xProps )
      93             :         , _xPropState( xPropState )
      94           0 :         , _xDocument( xDocument )
      95           0 :         {}
      96           0 :     inline ElementDescriptor(
      97             :         OUString const & name )
      98             :         SAL_THROW(())
      99           0 :         : XMLElement( name )
     100           0 :         {}
     101             : 
     102             :     template<typename T>
     103             :     inline void read(
     104             :         OUString const & propName, OUString const & attrName,
     105             :         bool forceAttribute = false );
     106             : 
     107             :     template<typename T>
     108             :     inline bool readProp( T * ret, OUString const & rPropName );
     109             :     css::uno::Any readProp( OUString const & rPropName );
     110             :     void readScrollableSettings();
     111             :     void readDefaults( bool supportPrintable = true, bool supportVisible = true );
     112             :     void readStringAttr(
     113             :         OUString const & rPropName, OUString const & rAttrName );
     114           0 :     inline void readDoubleAttr(
     115             :         OUString const & rPropName, OUString const & rAttrName )
     116           0 :         { read<double>( rPropName, rAttrName ); }
     117           0 :     inline void readLongAttr(
     118             :         OUString const & rPropName, OUString const & rAttrName,
     119             :         bool forceAttribute = false )
     120           0 :         { read<sal_Int32>( rPropName, rAttrName, forceAttribute ); }
     121             :     void readHexLongAttr(
     122             :         OUString const & rPropName, OUString const & rAttrName );
     123           0 :     inline void readShortAttr(
     124             :         OUString const & rPropName, OUString const & rAttrName )
     125           0 :         { read<sal_Int32>( rPropName, rAttrName ); }
     126           0 :     inline void readBoolAttr(
     127             :         OUString const & rPropName, OUString const & rAttrName )
     128           0 :         { read<sal_Bool>( rPropName, rAttrName ); }
     129             : 
     130             :     void readAlignAttr(
     131             :         OUString const & rPropName, OUString const & rAttrName );
     132             :     void readVerticalAlignAttr(
     133             :         OUString const & rPropName, OUString const & rAttrName );
     134             :     void readImageURLAttr(
     135             :         OUString const & rPropName, OUString const & rAttrName );
     136             :     void readImageAlignAttr(
     137             :         OUString const & rPropName, OUString const & rAttrName );
     138             :     void readImagePositionAttr(
     139             :         OUString const & rPropName, OUString const & rAttrName );
     140             :     void readDateFormatAttr(
     141             :         OUString const & rPropName, OUString const & rAttrName );
     142             :     void readTimeFormatAttr(
     143             :         OUString const & rPropName, OUString const & rAttrName );
     144             :     void readOrientationAttr(
     145             :         OUString const & rPropName, OUString const & rAttrName );
     146             :     void readButtonTypeAttr(
     147             :         OUString const & rPropName, OUString const & rAttrName );
     148             :     void readLineEndFormatAttr(
     149             :         OUString const & rPropName, OUString const & rAttrName );
     150             :     void readSelectionTypeAttr(
     151             :         OUString const & rPropName, OUString const & rAttrName );
     152             :     void readDataAwareAttr(
     153             :         OUString const & rAttrName );
     154           0 :     inline void addBoolAttr(
     155             :         OUString const & rAttrName, sal_Bool bValue )
     156           0 :         { addAttribute( rAttrName, OUString::valueOf(bValue) ); }
     157             :     void addNumberFormatAttr(
     158             :         css::uno::Reference< css::beans::XPropertySet >
     159             :         const & xFormatProperties );
     160             : 
     161             :     void readEvents() SAL_THROW( (css::uno::Exception) );
     162             :     void readDialogModel( StyleBag * all_styles )
     163             :         SAL_THROW( (css::uno::Exception) );
     164             :     void readBullitinBoard( StyleBag * all_styles )
     165             :         SAL_THROW( (css::uno::Exception) );
     166             :     void readMultiPageModel( StyleBag * all_styles )
     167             :         SAL_THROW( (css::uno::Exception) );
     168             :     void readFrameModel( StyleBag * all_styles )
     169             :         SAL_THROW( (css::uno::Exception) );
     170             :     void readPageModel( StyleBag * all_styles )
     171             :         SAL_THROW( (css::uno::Exception) );
     172             :     void readButtonModel( StyleBag * all_styles )
     173             :         SAL_THROW( (css::uno::Exception) );
     174             :     void readEditModel( StyleBag * all_styles )
     175             :         SAL_THROW( (css::uno::Exception) );
     176             :     void readCheckBoxModel( StyleBag * all_styles )
     177             :         SAL_THROW( (css::uno::Exception) );
     178             :     void readRadioButtonModel( StyleBag * all_styles )
     179             :         SAL_THROW( (css::uno::Exception) );
     180             :     void readComboBoxModel( StyleBag * all_styles )
     181             :         SAL_THROW( (css::uno::Exception) );
     182             :     void readCurrencyFieldModel( StyleBag * all_styles )
     183             :         SAL_THROW( (css::uno::Exception) );
     184             :     void readDateFieldModel( StyleBag * all_styles )
     185             :         SAL_THROW( (css::uno::Exception) );
     186             :     void readFileControlModel( StyleBag * all_styles )
     187             :         SAL_THROW( (css::uno::Exception) );
     188             :     void readTreeControlModel( StyleBag * all_styles )
     189             :         SAL_THROW( (css::uno::Exception) );
     190             :     void readFixedTextModel( StyleBag * all_styles )
     191             :         SAL_THROW( (css::uno::Exception) );
     192             :     void readGroupBoxModel( StyleBag * all_styles )
     193             :         SAL_THROW( (css::uno::Exception) );
     194             :     void readImageControlModel( StyleBag * all_styles )
     195             :         SAL_THROW( (css::uno::Exception) );
     196             :     void readListBoxModel( StyleBag * all_styles )
     197             :         SAL_THROW( (css::uno::Exception) );
     198             :     void readNumericFieldModel( StyleBag * all_styles )
     199             :         SAL_THROW( (css::uno::Exception) );
     200             :     void readPatternFieldModel( StyleBag * all_styles )
     201             :         SAL_THROW( (css::uno::Exception) );
     202             :     void readFormattedFieldModel( StyleBag * all_styles )
     203             :         SAL_THROW( (css::uno::Exception) );
     204             :     void readTimeFieldModel( StyleBag * all_styles )
     205             :         SAL_THROW( (css::uno::Exception) );
     206             :     void readFixedLineModel( StyleBag * all_styles )
     207             :         SAL_THROW( (css::uno::Exception) );
     208             :     void readProgressBarModel( StyleBag * all_styles )
     209             :         SAL_THROW( (css::uno::Exception) );
     210             :     void readScrollBarModel( StyleBag * all_styles )
     211             :         SAL_THROW( (css::uno::Exception) );
     212             :     void readSpinButtonModel( StyleBag * all_styles )
     213             :         SAL_THROW( (css::uno::Exception) );
     214             :     void readFixedHyperLinkModel( StyleBag * all_styles )
     215             :         SAL_THROW( (css::uno::Exception) );
     216             : };
     217             : 
     218             : template<typename T>
     219           0 : inline void ElementDescriptor::read(
     220             :     OUString const & propName, OUString const & attrName,
     221             :     bool forceAttribute )
     222             : {
     223           0 :     if (forceAttribute ||
     224             :         css::beans::PropertyState_DEFAULT_VALUE !=
     225             :         _xPropState->getPropertyState( propName ))
     226             :     {
     227           0 :         css::uno::Any a( _xProps->getPropertyValue( propName ) );
     228           0 :         T v = T();
     229           0 :         if (a >>= v)
     230           0 :             addAttribute( attrName, OUString::valueOf(v) );
     231             :         else
     232           0 :             OSL_FAIL( "### unexpected property type!" );
     233             :     }
     234           0 : }
     235             : 
     236             : template<typename T>
     237           0 : inline bool ElementDescriptor::readProp(
     238             :     T * ret, OUString const & rPropName )
     239             : {
     240           0 :     _xProps->getPropertyValue( rPropName ) >>= *ret;
     241             :     return css::beans::PropertyState_DEFAULT_VALUE !=
     242           0 :         _xPropState->getPropertyState( rPropName );
     243             : }
     244             : 
     245             : }
     246             : 
     247             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10