LCOV - code coverage report
Current view: top level - xmlscript/source/xmldlg_imexp - exp_share.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 43 0.0 %
Date: 2014-04-14 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 :     Style( short all_ ) SAL_THROW(())
      57             :         : _backgroundColor(0)
      58             :         , _textColor(0)
      59             :         , _textLineColor(0)
      60             :         , _border(0)
      61             :         , _borderColor(0)
      62             :         , _fontRelief(css::awt::FontRelief::NONE)
      63             :         , _fontEmphasisMark(css::awt::FontEmphasisMark::NONE)
      64             :         , _fillColor(0)
      65             :         , _visualEffect(0)
      66             :         , _all(all_)
      67           0 :         , _set(0)
      68             :     {
      69           0 :     }
      70             : 
      71             :     css::uno::Reference< css::xml::sax::XAttributeList > createElement();
      72             : };
      73           0 : class StyleBag
      74             : {
      75             :     ::std::vector< Style * > _styles;
      76             : 
      77             : public:
      78             :     ~StyleBag() SAL_THROW(());
      79             : 
      80             :     OUString getStyleId( Style const & rStyle ) SAL_THROW(());
      81             : 
      82             :     void dump( css::uno::Reference< css::xml::sax::XExtendedDocumentHandler >
      83             :                const & xOut );
      84             : };
      85             : 
      86           0 : class ElementDescriptor
      87             :     : public ::xmlscript::XMLElement
      88             : {
      89             :     css::uno::Reference< css::beans::XPropertySet > _xProps;
      90             :     css::uno::Reference< css::beans::XPropertyState > _xPropState;
      91             :     css::uno::Reference< css::frame::XModel > _xDocument;
      92             : 
      93             : public:
      94           0 :     inline ElementDescriptor(
      95             :         css::uno::Reference< css::beans::XPropertySet > const & xProps,
      96             :         css::uno::Reference< css::beans::XPropertyState > const & xPropState,
      97             :         OUString const & name, css::uno::Reference< css::frame::XModel > const & xDocument )
      98             :         SAL_THROW(())
      99             :         : XMLElement( name )
     100             :         , _xProps( xProps )
     101             :         , _xPropState( xPropState )
     102           0 :         , _xDocument( xDocument )
     103           0 :         {}
     104           0 :     inline ElementDescriptor(
     105             :         OUString const & name )
     106             :         SAL_THROW(())
     107           0 :         : XMLElement( name )
     108           0 :         {}
     109             : 
     110             :     template<typename T>
     111             :     inline void read(
     112             :         OUString const & propName, OUString const & attrName,
     113             :         bool forceAttribute = false );
     114             : 
     115             :     template<typename T>
     116             :     inline bool readProp( T * ret, OUString const & rPropName );
     117             :     css::uno::Any readProp( OUString const & rPropName );
     118             :     void readScrollableSettings();
     119             :     void readDefaults( bool supportPrintable = true, bool supportVisible = true );
     120             :     void readStringAttr(
     121             :         OUString const & rPropName, OUString const & rAttrName );
     122           0 :     inline void readDoubleAttr(
     123             :         OUString const & rPropName, OUString const & rAttrName )
     124           0 :         { read<double>( rPropName, rAttrName ); }
     125           0 :     inline void readLongAttr(
     126             :         OUString const & rPropName, OUString const & rAttrName,
     127             :         bool forceAttribute = false )
     128           0 :         { read<sal_Int32>( rPropName, rAttrName, forceAttribute ); }
     129             :     void readHexLongAttr(
     130             :         OUString const & rPropName, OUString const & rAttrName );
     131           0 :     inline void readShortAttr(
     132             :         OUString const & rPropName, OUString const & rAttrName )
     133           0 :         { read<sal_Int32>( rPropName, rAttrName ); }
     134             :     inline void readBoolAttr(
     135             :         OUString const & rPropName, OUString const & rAttrName );
     136             : 
     137             :     void readAlignAttr(
     138             :         OUString const & rPropName, OUString const & rAttrName );
     139             :     void readVerticalAlignAttr(
     140             :         OUString const & rPropName, OUString const & rAttrName );
     141             :     void readImageURLAttr(
     142             :         OUString const & rPropName, OUString const & rAttrName );
     143             :     void readImageAlignAttr(
     144             :         OUString const & rPropName, OUString const & rAttrName );
     145             :     void readImagePositionAttr(
     146             :         OUString const & rPropName, OUString const & rAttrName );
     147             :     void readDateAttr(
     148             :         OUString const & rPropName, OUString const & rAttrName );
     149             :     void readDateFormatAttr(
     150             :         OUString const & rPropName, OUString const & rAttrName );
     151             :     void readTimeAttr(
     152             :         OUString const & rPropName, OUString const & rAttrName );
     153             :     void readTimeFormatAttr(
     154             :         OUString const & rPropName, OUString const & rAttrName );
     155             :     void readOrientationAttr(
     156             :         OUString const & rPropName, OUString const & rAttrName );
     157             :     void readButtonTypeAttr(
     158             :         OUString const & rPropName, OUString const & rAttrName );
     159             :     void readLineEndFormatAttr(
     160             :         OUString const & rPropName, OUString const & rAttrName );
     161             :     void readSelectionTypeAttr(
     162             :         OUString const & rPropName, OUString const & rAttrName );
     163             :     void readDataAwareAttr(
     164             :         OUString const & rAttrName );
     165           0 :     inline void addBoolAttr(
     166             :         OUString const & rAttrName, bool bValue )
     167           0 :         { addAttribute( rAttrName, OUString::boolean(bValue) ); }
     168             :     void addNumberFormatAttr(
     169             :         css::uno::Reference< css::beans::XPropertySet >
     170             :         const & xFormatProperties );
     171             : 
     172             :     void readEvents() SAL_THROW( (css::uno::Exception) );
     173             :     void readDialogModel( StyleBag * all_styles )
     174             :         SAL_THROW( (css::uno::Exception) );
     175             :     void readBullitinBoard( StyleBag * all_styles )
     176             :         SAL_THROW( (css::uno::Exception) );
     177             :     void readMultiPageModel( StyleBag * all_styles )
     178             :         SAL_THROW( (css::uno::Exception) );
     179             :     void readFrameModel( StyleBag * all_styles )
     180             :         SAL_THROW( (css::uno::Exception) );
     181             :     void readPageModel( StyleBag * all_styles )
     182             :         SAL_THROW( (css::uno::Exception) );
     183             :     void readButtonModel( StyleBag * all_styles )
     184             :         SAL_THROW( (css::uno::Exception) );
     185             :     void readEditModel( StyleBag * all_styles )
     186             :         SAL_THROW( (css::uno::Exception) );
     187             :     void readCheckBoxModel( StyleBag * all_styles )
     188             :         SAL_THROW( (css::uno::Exception) );
     189             :     void readRadioButtonModel( StyleBag * all_styles )
     190             :         SAL_THROW( (css::uno::Exception) );
     191             :     void readComboBoxModel( StyleBag * all_styles )
     192             :         SAL_THROW( (css::uno::Exception) );
     193             :     void readCurrencyFieldModel( StyleBag * all_styles )
     194             :         SAL_THROW( (css::uno::Exception) );
     195             :     void readDateFieldModel( StyleBag * all_styles )
     196             :         SAL_THROW( (css::uno::Exception) );
     197             :     void readFileControlModel( StyleBag * all_styles )
     198             :         SAL_THROW( (css::uno::Exception) );
     199             :     void readTreeControlModel( StyleBag * all_styles )
     200             :         SAL_THROW( (css::uno::Exception) );
     201             :     void readFixedTextModel( StyleBag * all_styles )
     202             :         SAL_THROW( (css::uno::Exception) );
     203             :     void readGroupBoxModel( StyleBag * all_styles )
     204             :         SAL_THROW( (css::uno::Exception) );
     205             :     void readImageControlModel( StyleBag * all_styles )
     206             :         SAL_THROW( (css::uno::Exception) );
     207             :     void readListBoxModel( StyleBag * all_styles )
     208             :         SAL_THROW( (css::uno::Exception) );
     209             :     void readNumericFieldModel( StyleBag * all_styles )
     210             :         SAL_THROW( (css::uno::Exception) );
     211             :     void readPatternFieldModel( StyleBag * all_styles )
     212             :         SAL_THROW( (css::uno::Exception) );
     213             :     void readFormattedFieldModel( StyleBag * all_styles )
     214             :         SAL_THROW( (css::uno::Exception) );
     215             :     void readTimeFieldModel( StyleBag * all_styles )
     216             :         SAL_THROW( (css::uno::Exception) );
     217             :     void readFixedLineModel( StyleBag * all_styles )
     218             :         SAL_THROW( (css::uno::Exception) );
     219             :     void readProgressBarModel( StyleBag * all_styles )
     220             :         SAL_THROW( (css::uno::Exception) );
     221             :     void readScrollBarModel( StyleBag * all_styles )
     222             :         SAL_THROW( (css::uno::Exception) );
     223             :     void readSpinButtonModel( StyleBag * all_styles )
     224             :         SAL_THROW( (css::uno::Exception) );
     225             :     void readFixedHyperLinkModel( StyleBag * all_styles )
     226             :         SAL_THROW( (css::uno::Exception) );
     227             : };
     228             : 
     229             : template<typename T>
     230           0 : inline void ElementDescriptor::read(
     231             :     OUString const & propName, OUString const & attrName,
     232             :     bool forceAttribute )
     233             : {
     234           0 :     if (forceAttribute ||
     235             :         css::beans::PropertyState_DEFAULT_VALUE !=
     236           0 :         _xPropState->getPropertyState( propName ))
     237             :     {
     238           0 :         css::uno::Any a( _xProps->getPropertyValue( propName ) );
     239           0 :         T v = T();
     240           0 :         if (a >>= v)
     241           0 :             addAttribute( attrName, OUString::number(v) );
     242             :         else
     243           0 :             OSL_FAIL( "### unexpected property type!" );
     244             :     }
     245           0 : }
     246             : 
     247             : template<>
     248           0 : inline void ElementDescriptor::read<sal_Bool>(
     249             :     OUString const & propName, OUString const & attrName,
     250             :     bool forceAttribute )
     251             : {
     252           0 :     if (forceAttribute ||
     253             :         css::beans::PropertyState_DEFAULT_VALUE !=
     254           0 :         _xPropState->getPropertyState( propName ))
     255             :     {
     256           0 :         css::uno::Any a( _xProps->getPropertyValue( propName ) );
     257             :         bool v;
     258           0 :         if (a >>= v)
     259           0 :             addAttribute( attrName, OUString::boolean(v) );
     260             :         else
     261           0 :             OSL_FAIL( "### unexpected property type!" );
     262             :     }
     263           0 : }
     264             : 
     265           0 : inline void ElementDescriptor::readBoolAttr(
     266             :     OUString const & rPropName, OUString const & rAttrName )
     267             : {
     268           0 :     read<sal_Bool>( rPropName, rAttrName );
     269           0 : }
     270             : 
     271             : template<typename T>
     272           0 : inline bool ElementDescriptor::readProp(
     273             :     T * ret, OUString const & rPropName )
     274             : {
     275           0 :     _xProps->getPropertyValue( rPropName ) >>= *ret;
     276             :     return css::beans::PropertyState_DEFAULT_VALUE !=
     277           0 :         _xPropState->getPropertyState( rPropName );
     278             : }
     279             : 
     280             : }
     281             : 
     282             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10