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

Generated by: LCOV version 1.10