LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLTextShapeStyleContext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 75 0.0 %
Date: 2014-04-14 Functions: 0 16 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 <tools/debug.hxx>
      21             : #include <com/sun/star/document/XEventsSupplier.hpp>
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include <xmloff/xmltoken.hxx>
      24             : #include "XMLTextPropertySetContext.hxx"
      25             : #include <xmloff/xmlimp.hxx>
      26             : #include <xmloff/XMLEventsImportContext.hxx>
      27             : #include "XMLShapePropertySetContext.hxx"
      28             : #include "XMLTextColumnsContext.hxx"
      29             : #include "XMLBackgroundImageContext.hxx"
      30             : #include <xmloff/txtprmap.hxx>
      31             : 
      32             : #include <xmloff/XMLTextShapeStyleContext.hxx>
      33             : 
      34             : using namespace ::com::sun::star::document;
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::com::sun::star::xml::sax;
      37             : using namespace ::com::sun::star::style;
      38             : using namespace ::com::sun::star::beans;
      39             : using namespace ::xmloff::token;
      40             : 
      41             : class XMLTextShapePropertySetContext_Impl : public XMLShapePropertySetContext
      42             : {
      43             : public:
      44             :     XMLTextShapePropertySetContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx,
      45             :         const OUString& rLName,
      46             :         const Reference< XAttributeList >& xAttrList,
      47             :                  sal_uInt32 nFamily,
      48             :         ::std::vector< XMLPropertyState > &rProps,
      49             :         const UniReference < SvXMLImportPropertyMapper > &rMap );
      50             : 
      51             :     virtual ~XMLTextShapePropertySetContext_Impl();
      52             : 
      53             :     using SvXMLPropertySetContext::CreateChildContext;
      54             :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
      55             :         const OUString& rLocalName,
      56             :         const Reference< XAttributeList >& xAttrList,
      57             :         ::std::vector< XMLPropertyState > &rProperties,
      58             :         const XMLPropertyState& rProp) SAL_OVERRIDE;
      59             : };
      60             : 
      61           0 : XMLTextShapePropertySetContext_Impl::XMLTextShapePropertySetContext_Impl(
      62             :                  SvXMLImport& rImport, sal_uInt16 nPrfx,
      63             :                  const OUString& rLName,
      64             :                  const Reference< XAttributeList > & xAttrList,
      65             :                  sal_uInt32 nFamily,
      66             :                  ::std::vector< XMLPropertyState > &rProps,
      67             :                  const UniReference < SvXMLImportPropertyMapper > &rMap ) :
      68             :     XMLShapePropertySetContext( rImport, nPrfx, rLName, xAttrList, nFamily,
      69           0 :                                 rProps, rMap )
      70             : {
      71           0 : }
      72             : 
      73           0 : XMLTextShapePropertySetContext_Impl::~XMLTextShapePropertySetContext_Impl()
      74             : {
      75           0 : }
      76             : 
      77           0 : SvXMLImportContext *XMLTextShapePropertySetContext_Impl::CreateChildContext(
      78             :                    sal_uInt16 nPrefix,
      79             :                    const OUString& rLocalName,
      80             :                    const Reference< XAttributeList > & xAttrList,
      81             :                    ::std::vector< XMLPropertyState > &rProperties,
      82             :                    const XMLPropertyState& rProp )
      83             : {
      84           0 :     SvXMLImportContext *pContext = 0;
      85             : 
      86           0 :     switch( mxMapper->getPropertySetMapper()
      87           0 :                     ->GetEntryContextId( rProp.mnIndex ) )
      88             :     {
      89             :     case CTF_TEXTCOLUMNS:
      90           0 :         pContext = new XMLTextColumnsContext( GetImport(), nPrefix,
      91             :                                                    rLocalName, xAttrList, rProp,
      92           0 :                                                    rProperties );
      93           0 :         break;
      94             : 
      95             :     case CTF_BACKGROUND_URL:
      96             :         DBG_ASSERT( rProp.mnIndex >= 3 &&
      97             :                     CTF_BACKGROUND_TRANSPARENCY ==
      98             :                         mxMapper->getPropertySetMapper()
      99             :                         ->GetEntryContextId( rProp.mnIndex-3 ) &&
     100             :                     CTF_BACKGROUND_POS  == mxMapper->getPropertySetMapper()
     101             :                         ->GetEntryContextId( rProp.mnIndex-2 ) &&
     102             :                     CTF_BACKGROUND_FILTER  == mxMapper->getPropertySetMapper()
     103             :                         ->GetEntryContextId( rProp.mnIndex-1 ),
     104             :                     "invalid property map!");
     105             :         pContext =
     106           0 :             new XMLBackgroundImageContext( GetImport(), nPrefix,
     107             :                                            rLocalName, xAttrList,
     108             :                                            rProp,
     109             :                                            rProp.mnIndex-2,
     110             :                                            rProp.mnIndex-1,
     111             :                                            rProp.mnIndex-3,
     112           0 :                                            rProperties );
     113           0 :         break;
     114             :     }
     115             : 
     116           0 :     if( !pContext )
     117             :         pContext = XMLShapePropertySetContext::CreateChildContext(
     118           0 :                         nPrefix, rLocalName, xAttrList, rProperties, rProp );
     119             : 
     120           0 :     return pContext;
     121             : }
     122             : 
     123           0 : void XMLTextShapeStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
     124             :                                         const OUString& rLocalName,
     125             :                                         const OUString& rValue )
     126             : {
     127           0 :     if( XML_NAMESPACE_STYLE == nPrefixKey &&
     128           0 :         IsXMLToken( rLocalName, XML_AUTO_UPDATE ) )
     129             :     {
     130           0 :           if( IsXMLToken( rValue, XML_TRUE ) )
     131           0 :             bAutoUpdate = true;
     132             :     }
     133             :     else
     134             :     {
     135           0 :         XMLShapeStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
     136             :     }
     137           0 : }
     138             : 
     139           0 : TYPEINIT1( XMLTextShapeStyleContext, XMLShapeStyleContext );
     140             : 
     141           0 : XMLTextShapeStyleContext::XMLTextShapeStyleContext( SvXMLImport& rImport,
     142             :         sal_uInt16 nPrfx, const OUString& rLName,
     143             :         const Reference< XAttributeList > & xAttrList,
     144             :         SvXMLStylesContext& rStyles, sal_uInt16 nFamily,
     145             :         bool /*bDefaultStyle*/ ) :
     146             :     XMLShapeStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles,
     147             :                           nFamily ),
     148             :     sIsAutoUpdate( "IsAutoUpdate" ),
     149           0 :     bAutoUpdate( false )
     150             : {
     151           0 : }
     152             : 
     153           0 : XMLTextShapeStyleContext::~XMLTextShapeStyleContext()
     154             : {
     155           0 : }
     156             : 
     157           0 : SvXMLImportContext *XMLTextShapeStyleContext::CreateChildContext(
     158             :         sal_uInt16 nPrefix,
     159             :         const OUString& rLocalName,
     160             :         const Reference< XAttributeList > & xAttrList )
     161             : {
     162           0 :     SvXMLImportContext *pContext = 0;
     163             : 
     164           0 :     if( XML_NAMESPACE_STYLE == nPrefix )
     165             :     {
     166           0 :         sal_uInt32 nFamily = 0;
     167           0 :         if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
     168           0 :             nFamily = XML_TYPE_PROP_TEXT;
     169           0 :         else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
     170           0 :             nFamily = XML_TYPE_PROP_PARAGRAPH;
     171           0 :         else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
     172           0 :             nFamily = XML_TYPE_PROP_GRAPHIC;
     173           0 :         if( nFamily )
     174             :         {
     175             :             UniReference < SvXMLImportPropertyMapper > xImpPrMap =
     176           0 :                 GetStyles()->GetImportPropertyMapper( GetFamily() );
     177           0 :             if( xImpPrMap.is() )
     178             :             {
     179             :                 pContext = new XMLTextShapePropertySetContext_Impl(
     180           0 :                         GetImport(), nPrefix, rLocalName, xAttrList, nFamily,
     181           0 :                         GetProperties(), xImpPrMap );
     182           0 :             }
     183             :         }
     184             :     }
     185           0 :     else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
     186           0 :               IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
     187             :     {
     188             :         // create and remember events import context
     189             :         // (for delayed processing of events)
     190           0 :         pContext = new XMLEventsImportContext( GetImport(), nPrefix,
     191           0 :                                                    rLocalName);
     192           0 :         xEventContext = pContext;
     193             :     }
     194             : 
     195           0 :     if( !pContext )
     196             :         pContext = XMLShapeStyleContext::CreateChildContext( nPrefix, rLocalName,
     197           0 :                                                           xAttrList );
     198             : 
     199           0 :     return pContext;
     200             : }
     201             : 
     202           0 : void XMLTextShapeStyleContext::CreateAndInsert( bool bOverwrite )
     203             : {
     204           0 :     XMLShapeStyleContext::CreateAndInsert( bOverwrite );
     205           0 :     Reference < XStyle > xStyle = GetStyle();
     206           0 :     if( !xStyle.is() || !(bOverwrite || IsNew()) )
     207           0 :         return;
     208             : 
     209           0 :     Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
     210             :     Reference< XPropertySetInfo > xPropSetInfo =
     211           0 :                 xPropSet->getPropertySetInfo();
     212           0 :     if( xPropSetInfo->hasPropertyByName( sIsAutoUpdate ) )
     213             :     {
     214           0 :         Any aAny;
     215           0 :         sal_Bool bTmp = bAutoUpdate;
     216           0 :         aAny.setValue( &bTmp, ::getBooleanCppuType() );
     217           0 :         xPropSet->setPropertyValue( sIsAutoUpdate, aAny );
     218             :     }
     219             : 
     220             :     // tell the style about it's events (if applicable)
     221           0 :     if( xEventContext.Is() )
     222             :     {
     223             :         // set event suppplier and release reference to context
     224           0 :         Reference<XEventsSupplier> xEventsSupplier(xStyle, UNO_QUERY);
     225           0 :         ((XMLEventsImportContext *)&xEventContext)->SetEvents(xEventsSupplier);
     226           0 :         xEventContext = 0;
     227           0 :     }
     228             : }
     229             : 
     230           0 : void XMLTextShapeStyleContext::Finish( bool bOverwrite )
     231             : {
     232           0 :     XMLPropStyleContext::Finish( bOverwrite );
     233           0 : }
     234             : 
     235             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10