LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/draw - XMLGraphicsDefaultStyle.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 38 39 97.4 %
Date: 2012-12-27 Functions: 8 10 80.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 <com/sun/star/lang/XMultiServiceFactory.hpp>
      21             : #include <xmloff/xmlimp.hxx>
      22             : #include <xmloff/nmspmap.hxx>
      23             : #include "xmloff/xmlnmspe.hxx"
      24             : #include <xmloff/xmltoken.hxx>
      25             : 
      26             : #include <xmloff/families.hxx>
      27             : #include "XMLShapePropertySetContext.hxx"
      28             : #include <xmloff/XMLGraphicsDefaultStyle.hxx>
      29             : 
      30             : using ::rtl::OUString;
      31             : using ::rtl::OUStringBuffer;
      32             : 
      33             : using namespace ::com::sun::star;
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::lang;
      36             : using namespace ::com::sun::star::beans;
      37             : using namespace ::com::sun::star::xml::sax;
      38             : 
      39             : using ::xmloff::token::IsXMLToken;
      40             : using ::xmloff::token::XML_TEXT_PROPERTIES;
      41             : using ::xmloff::token::XML_GRAPHIC_PROPERTIES;
      42             : using ::xmloff::token::XML_PARAGRAPH_PROPERTIES;
      43             : 
      44             : // ---------------------------------------------------------------------
      45             : 
      46           6 : TYPEINIT1( XMLGraphicsDefaultStyle, XMLPropStyleContext );
      47             : 
      48          20 : XMLGraphicsDefaultStyle::XMLGraphicsDefaultStyle( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const Reference< XAttributeList >& xAttrList, SvXMLStylesContext& rStyles )
      49          20 : : XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, XML_STYLE_FAMILY_SD_GRAPHICS_ID, sal_True )
      50             : {
      51          20 : }
      52             : 
      53          40 : XMLGraphicsDefaultStyle::~XMLGraphicsDefaultStyle()
      54             : {
      55          40 : }
      56             : 
      57          59 : SvXMLImportContext *XMLGraphicsDefaultStyle::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList > & xAttrList )
      58             : {
      59          59 :     SvXMLImportContext *pContext = 0;
      60             : 
      61          59 :     if( XML_NAMESPACE_STYLE == nPrefix )
      62             :     {
      63          59 :         sal_uInt32 nFamily = 0;
      64          59 :         if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
      65          20 :             nFamily = XML_TYPE_PROP_TEXT;
      66          39 :         else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
      67          20 :             nFamily = XML_TYPE_PROP_PARAGRAPH;
      68          19 :         else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
      69          19 :             nFamily = XML_TYPE_PROP_GRAPHIC;
      70          59 :         if( nFamily )
      71             :         {
      72          59 :             UniReference < SvXMLImportPropertyMapper > xImpPrMap = GetStyles()->GetImportPropertyMapper( GetFamily() );
      73          59 :             if( xImpPrMap.is() )
      74          59 :                 pContext = new XMLShapePropertySetContext( GetImport(), nPrefix, rLocalName, xAttrList, nFamily, GetProperties(), xImpPrMap );
      75             :         }
      76             :     }
      77             : 
      78          59 :     if( !pContext )
      79           0 :         pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
      80             : 
      81          59 :     return pContext;
      82             : }
      83             : 
      84             : // This method is called for every default style
      85          20 : void XMLGraphicsDefaultStyle::SetDefaults()
      86             : {
      87          20 :     Reference< XMultiServiceFactory > xFact( GetImport().GetModel(), UNO_QUERY );
      88          20 :     if( !xFact.is() )
      89             :         return;
      90             : 
      91          20 :     Reference< XPropertySet > xDefaults( xFact->createInstance( "com.sun.star.drawing.Defaults" ), UNO_QUERY );
      92          20 :     if( !xDefaults.is() )
      93             :         return;
      94             :                                             // SJ: #i114750#
      95          20 :     sal_Bool bWordWrapDefault = sal_True;   // initializing with correct odf fo:wrap-option default
      96          20 :     sal_Int32 nUPD( 0 );
      97          20 :     sal_Int32 nBuild( 0 );
      98          20 :     const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
      99          20 :     if ( bBuildIdFound && (
     100             :         ((nUPD >= 600) &&  (nUPD < 700))
     101             :         ||
     102             :         ((nUPD == 300) && (nBuild <= 9535))
     103             :         ||
     104             :         ((nUPD > 300) && (nUPD <= 330))
     105             :     ) )
     106           4 :         bWordWrapDefault = sal_False;
     107             : 
     108          20 :     const OUString sTextWordWrap( "TextWordWrap" );
     109          20 :     Reference< XPropertySetInfo > xInfo( xDefaults->getPropertySetInfo() );
     110          20 :     if ( xInfo->hasPropertyByName( sTextWordWrap ) )
     111          20 :         xDefaults->setPropertyValue( sTextWordWrap, Any( bWordWrapDefault ) );
     112             : 
     113          20 :     FillPropertySet( xDefaults );
     114             : }
     115             : 
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10