LCOV - code coverage report
Current view: top level - xmloff/source/style - xmlaustp.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 155 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 <com/sun/star/container/XIndexReplace.hpp>
      21             : #include <tools/debug.hxx>
      22             : #include "impastpl.hxx"
      23             : #include <xmloff/xmlaustp.hxx>
      24             : #include <xmloff/families.hxx>
      25             : #include <xmloff/xmlnmspe.hxx>
      26             : #include <xmloff/xmltoken.hxx>
      27             : #include <xmloff/xmlexp.hxx>
      28             : #include <xmloff/XMLTextListAutoStylePool.hxx>
      29             : 
      30             : #include <xmloff/PageMasterStyleMap.hxx>
      31             : #include "PageMasterExportPropMapper.hxx"
      32             : #include "XMLBackgroundImageExport.hxx"
      33             : 
      34             : 
      35             : using namespace ::std;
      36             : 
      37             : using namespace ::com::sun::star;
      38             : using namespace ::xmloff::token;
      39             : 
      40             : 
      41             : namespace
      42             : {
      43           0 :     static void lcl_exportDataStyle( SvXMLExport& _rExport, const UniReference< XMLPropertySetMapper >& _rxMapper,
      44             :         const XMLPropertyState& _rProperty )
      45             :     {
      46             :         DBG_ASSERT( _rxMapper.is(), "xmloff::lcl_exportDataStyle: invalid property mapper!" );
      47             :         // obtain the data style name
      48           0 :         OUString sDataStyleName;
      49           0 :         _rProperty.maValue >>= sDataStyleName;
      50             :         DBG_ASSERT( !sDataStyleName.isEmpty(), "xmloff::lcl_exportDataStyle: invalid property value for the data style name!" );
      51             : 
      52             :         // add the attribute
      53             :         _rExport.AddAttribute(
      54           0 :             _rxMapper->GetEntryNameSpace( _rProperty.mnIndex ),
      55           0 :             _rxMapper->GetEntryXMLName( _rProperty.mnIndex ),
      56           0 :             sDataStyleName );
      57           0 :     }
      58             : }
      59             : 
      60           0 : void SvXMLAutoStylePoolP::exportStyleAttributes(
      61             :         SvXMLAttributeList&,
      62             :         sal_Int32 nFamily,
      63             :         const vector< XMLPropertyState >& rProperties,
      64             :         const SvXMLExportPropertyMapper& rPropExp,
      65             :         const SvXMLUnitConverter&,
      66             :         const SvXMLNamespaceMap&
      67             :         ) const
      68             : {
      69           0 :     if ( XML_STYLE_FAMILY_CONTROL_ID == nFamily )
      70             :     {   // it's a control-related style
      71           0 :         UniReference< XMLPropertySetMapper > aPropertyMapper = rPropExp.getPropertySetMapper();
      72             : 
      73           0 :         for (   vector< XMLPropertyState >::const_iterator pProp = rProperties.begin();
      74           0 :                 pProp != rProperties.end();
      75             :                 ++pProp
      76             :             )
      77             :         {
      78           0 :             if  (   ( pProp->mnIndex > -1 )
      79           0 :                 &&  ( CTF_FORMS_DATA_STYLE == aPropertyMapper->GetEntryContextId( pProp->mnIndex ) )
      80             :                 )
      81             :             {   // it's the data-style for a grid column
      82           0 :                 lcl_exportDataStyle( GetExport(), aPropertyMapper, *pProp );
      83             :             }
      84           0 :         }
      85             :     }
      86             : 
      87           0 :     if( (XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily) || (XML_STYLE_FAMILY_SD_PRESENTATION_ID == nFamily) )
      88             :     {   // it's a graphics style
      89           0 :         UniReference< XMLPropertySetMapper > aPropertyMapper = rPropExp.getPropertySetMapper();
      90             :         DBG_ASSERT(aPropertyMapper.is(), "SvXMLAutoStylePoolP::exportStyleAttributes: invalid property set mapper!");
      91             : 
      92           0 :         sal_Bool bFoundControlShapeDataStyle = sal_False;
      93           0 :         sal_Bool bFoundNumberingRulesName = sal_False;
      94             : 
      95           0 :         for (   vector< XMLPropertyState >::const_iterator pProp = rProperties.begin();
      96           0 :                 pProp != rProperties.end();
      97             :                 ++pProp
      98             :             )
      99             :         {
     100           0 :             if (pProp->mnIndex > -1)
     101             :             {   // it's a valid property
     102           0 :                 switch( aPropertyMapper->GetEntryContextId(pProp->mnIndex) )
     103             :                 {
     104             :                 case CTF_SD_CONTROL_SHAPE_DATA_STYLE:
     105             :                     {   // it's the control shape data style property
     106             : 
     107           0 :                         if (bFoundControlShapeDataStyle)
     108             :                         {
     109             :                             OSL_FAIL("SvXMLAutoStylePoolP::exportStyleAttributes: found two properties with the ControlShapeDataStyle context id!");
     110             :                             // already added the attribute for the first occurrence
     111           0 :                             break;
     112             :                         }
     113             : 
     114           0 :                         lcl_exportDataStyle( GetExport(), aPropertyMapper, *pProp );
     115             : 
     116             :                         // check if there is another property with the special context id we're handling here
     117           0 :                         bFoundControlShapeDataStyle = sal_True;
     118           0 :                         break;
     119             :                     }
     120             :                 case CTF_SD_NUMBERINGRULES_NAME:
     121             :                     {
     122           0 :                         if (bFoundNumberingRulesName)
     123             :                         {
     124             :                             OSL_FAIL("SvXMLAutoStylePoolP::exportStyleAttributes: found two properties with the numbering rules name context id!");
     125             :                             // already added the attribute for the first occurrence
     126           0 :                             break;
     127             :                         }
     128             : 
     129           0 :                         uno::Reference< container::XIndexReplace > xNumRule;
     130           0 :                         pProp->maValue >>= xNumRule;
     131           0 :                         if( xNumRule.is() && (xNumRule->getCount() > 0 ) )
     132             :                         {
     133           0 :                             const OUString sName(((XMLTextListAutoStylePool*)&GetExport().GetTextParagraphExport()->GetListAutoStylePool())->Add( xNumRule ));
     134             : 
     135           0 :                             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_LIST_STYLE_NAME, GetExport().EncodeStyleName( sName ) );
     136             :                         }
     137             : 
     138           0 :                         bFoundNumberingRulesName = sal_True;
     139           0 :                         break;
     140             :                     }
     141             :                 }
     142             :             }
     143           0 :         }
     144             :     }
     145             : 
     146           0 :     if( nFamily == XML_STYLE_FAMILY_PAGE_MASTER )
     147             :     {
     148           0 :         for( vector< XMLPropertyState >::const_iterator pProp = rProperties.begin(); pProp != rProperties.end(); ++pProp )
     149             :         {
     150           0 :             if (pProp->mnIndex > -1)
     151             :             {
     152           0 :                 UniReference< XMLPropertySetMapper > aPropMapper = rPropExp.getPropertySetMapper();
     153           0 :                 sal_Int32 nIndex = pProp->mnIndex;
     154           0 :                 sal_Int16 nContextID = aPropMapper->GetEntryContextId( nIndex );
     155           0 :                 switch( nContextID )
     156             :                 {
     157             :                     case CTF_PM_PAGEUSAGE:
     158             :                     {
     159           0 :                         OUString sValue;
     160           0 :                         const XMLPropertyHandler* pPropHdl = aPropMapper->GetPropertyHandler( nIndex );
     161           0 :                         if( pPropHdl &&
     162           0 :                             pPropHdl->exportXML( sValue, pProp->maValue,
     163           0 :                                                  GetExport().GetMM100UnitConverter() ) &&
     164           0 :                             ( ! IsXMLToken( sValue, XML_ALL ) ) )
     165             :                         {
     166           0 :                             GetExport().AddAttribute( aPropMapper->GetEntryNameSpace( nIndex ), aPropMapper->GetEntryXMLName( nIndex ), sValue );
     167           0 :                         }
     168             :                     }
     169           0 :                     break;
     170           0 :                 }
     171             :             }
     172             :         }
     173             :     }
     174           0 : }
     175             : 
     176           0 : void SvXMLAutoStylePoolP::exportStyleContent(
     177             :         const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > &,
     178             :         sal_Int32 nFamily,
     179             :         const vector< XMLPropertyState >& rProperties,
     180             :         const SvXMLExportPropertyMapper& rPropExp,
     181             :         const SvXMLUnitConverter&,
     182             :         const SvXMLNamespaceMap&
     183             :         ) const
     184             : {
     185           0 :     if( nFamily == XML_STYLE_FAMILY_PAGE_MASTER )
     186             :     {
     187           0 :         sal_Int32       nHeaderStartIndex(-1);
     188           0 :         sal_Int32       nHeaderEndIndex(-1);
     189           0 :         sal_Int32       nFooterStartIndex(-1);
     190           0 :         sal_Int32       nFooterEndIndex(-1);
     191           0 :         sal_Bool        bHeaderStartIndex(sal_False);
     192           0 :         sal_Bool        bHeaderEndIndex(sal_False);
     193           0 :         sal_Bool        bFooterStartIndex(sal_False);
     194           0 :         sal_Bool        bFooterEndIndex(sal_False);
     195             : 
     196           0 :         UniReference< XMLPropertySetMapper > aPropMapper = rPropExp.getPropertySetMapper();
     197             : 
     198           0 :         sal_Int32 nIndex(0);
     199           0 :         while(nIndex < aPropMapper->GetEntryCount())
     200             :         {
     201           0 :             switch( aPropMapper->GetEntryContextId( nIndex ) & CTF_PM_FLAGMASK )
     202             :             {
     203             :                 case CTF_PM_HEADERFLAG:
     204             :                 {
     205           0 :                     if (!bHeaderStartIndex)
     206             :                     {
     207           0 :                         nHeaderStartIndex = nIndex;
     208           0 :                         bHeaderStartIndex = sal_True;
     209             :                     }
     210           0 :                     if (bFooterStartIndex && !bFooterEndIndex)
     211             :                     {
     212           0 :                         nFooterEndIndex = nIndex;
     213           0 :                         bFooterEndIndex = sal_True;
     214             :                     }
     215             :                 }
     216           0 :                 break;
     217             :                 case CTF_PM_FOOTERFLAG:
     218             :                 {
     219           0 :                     if (!bFooterStartIndex)
     220             :                     {
     221           0 :                         nFooterStartIndex = nIndex;
     222           0 :                         bFooterStartIndex = sal_True;
     223             :                     }
     224           0 :                     if (bHeaderStartIndex && !bHeaderEndIndex)
     225             :                     {
     226           0 :                         nHeaderEndIndex = nIndex;
     227           0 :                         bHeaderEndIndex = sal_True;
     228             :                     }
     229             :                 }
     230           0 :                 break;
     231             :             }
     232           0 :             nIndex++;
     233             :         }
     234           0 :         if (!bHeaderEndIndex)
     235           0 :             nHeaderEndIndex = nIndex;
     236           0 :         if (!bFooterEndIndex)
     237           0 :             nFooterEndIndex = nIndex;
     238             : 
     239             :         // export header style element
     240             :         {
     241             :             SvXMLElementExport aElem(
     242           0 :                 GetExport(), XML_NAMESPACE_STYLE, XML_HEADER_STYLE,
     243           0 :                 true, true );
     244             : 
     245             :             rPropExp.exportXML(
     246           0 :                 GetExport(), rProperties,
     247           0 :                 nHeaderStartIndex, nHeaderEndIndex, XML_EXPORT_FLAG_IGN_WS);
     248             :         }
     249             : 
     250             :         // export footer style
     251             :         {
     252             :             SvXMLElementExport aElem(
     253           0 :                 GetExport(), XML_NAMESPACE_STYLE, XML_FOOTER_STYLE,
     254           0 :                 true, true );
     255             : 
     256             :             rPropExp.exportXML(
     257           0 :                 GetExport(), rProperties,
     258           0 :                 nFooterStartIndex, nFooterEndIndex, XML_EXPORT_FLAG_IGN_WS);
     259           0 :         }
     260             :     }
     261           0 : }
     262             : 
     263           0 : SvXMLAutoStylePoolP::SvXMLAutoStylePoolP( SvXMLExport& rExport )
     264             : {
     265           0 :     pImpl = new SvXMLAutoStylePoolP_Impl( rExport );
     266           0 : }
     267             : 
     268           0 : SvXMLAutoStylePoolP::~SvXMLAutoStylePoolP()
     269             : {
     270           0 :     delete pImpl;
     271           0 : }
     272             : 
     273           0 : SvXMLExport& SvXMLAutoStylePoolP::GetExport() const
     274             : {
     275           0 :     return pImpl->GetExport();
     276             : }
     277             : 
     278             : // TODO: romove this
     279           0 : void SvXMLAutoStylePoolP::AddFamily(
     280             :         sal_Int32 nFamily,
     281             :         const OUString& rStrName,
     282             :         SvXMLExportPropertyMapper* pMapper,
     283             :         const OUString& aStrPrefix,
     284             :         bool bAsFamily )
     285             : {
     286           0 :     UniReference <SvXMLExportPropertyMapper> xTmp = pMapper;
     287           0 :     AddFamily( nFamily, rStrName, xTmp, aStrPrefix, bAsFamily );
     288           0 : }
     289             : 
     290           0 : void SvXMLAutoStylePoolP::AddFamily(
     291             :         sal_Int32 nFamily,
     292             :         const OUString& rStrName,
     293             :         const UniReference < SvXMLExportPropertyMapper > & rMapper,
     294             :         const OUString& rStrPrefix,
     295             :         bool bAsFamily )
     296             : {
     297           0 :     pImpl->AddFamily( nFamily, rStrName, rMapper, rStrPrefix, bAsFamily );
     298           0 : }
     299             : 
     300           0 : void  SvXMLAutoStylePoolP::SetFamilyPropSetMapper(
     301             :         sal_Int32 nFamily,
     302             :         const UniReference < SvXMLExportPropertyMapper > & rMapper )
     303             : {
     304           0 :     pImpl->SetFamilyPropSetMapper( nFamily, rMapper );
     305           0 : }
     306             : 
     307           0 : void SvXMLAutoStylePoolP::RegisterName( sal_Int32 nFamily,
     308             :                                          const OUString& rName )
     309             : {
     310           0 :     pImpl->RegisterName( nFamily, rName );
     311           0 : }
     312             : 
     313           0 : void SvXMLAutoStylePoolP::GetRegisteredNames(
     314             :     uno::Sequence<sal_Int32>& rFamilies,
     315             :     uno::Sequence<OUString>& rNames )
     316             : {
     317           0 :     pImpl->GetRegisteredNames( rFamilies, rNames );
     318           0 : }
     319             : 
     320           0 : void SvXMLAutoStylePoolP::RegisterNames(
     321             :     uno::Sequence<sal_Int32>& aFamilies,
     322             :     uno::Sequence<OUString>& aNames )
     323             : {
     324             :     DBG_ASSERT( aFamilies.getLength() == aNames.getLength(),
     325             :                 "aFamilies != aNames" );
     326             : 
     327             :     // iterate over sequence(s) and call RegisterName(..) for each pair
     328           0 :     const sal_Int32* pFamilies = aFamilies.getConstArray();
     329           0 :     const OUString* pNames = aNames.getConstArray();
     330           0 :     sal_Int32 nCount = min( aFamilies.getLength(), aNames.getLength() );
     331           0 :     for( sal_Int32 n = 0; n < nCount; n++ )
     332           0 :         RegisterName( pFamilies[n], pNames[n] );
     333           0 : }
     334             : 
     335           0 : OUString SvXMLAutoStylePoolP::Add( sal_Int32 nFamily,
     336             :                                   const vector< XMLPropertyState >& rProperties )
     337             : {
     338           0 :     OUString sEmpty;
     339           0 :     OUString sName;
     340           0 :     pImpl->Add(sName, nFamily, sEmpty, rProperties );
     341           0 :     return sName;
     342             : }
     343             : 
     344           0 : OUString SvXMLAutoStylePoolP::Add( sal_Int32 nFamily,
     345             :                                   const OUString& rParent,
     346             :                                   const vector< XMLPropertyState >& rProperties, bool bDontSeek )
     347             : {
     348           0 :     OUString sName;
     349           0 :     pImpl->Add(sName, nFamily, rParent, rProperties, bDontSeek);
     350           0 :     return sName;
     351             : }
     352             : 
     353           0 : bool SvXMLAutoStylePoolP::Add(OUString& rName, sal_Int32 nFamily, const OUString& rParent, const ::std::vector< XMLPropertyState >& rProperties )
     354             : {
     355           0 :     return pImpl->Add(rName, nFamily, rParent, rProperties);
     356             : }
     357             : 
     358           0 : bool SvXMLAutoStylePoolP::AddNamed( const OUString& rName, sal_Int32 nFamily, const OUString& rParent,
     359             :                                         const ::std::vector< XMLPropertyState >& rProperties )
     360             : 
     361             : {
     362           0 :     return pImpl->AddNamed(rName, nFamily, rParent, rProperties);
     363             : }
     364             : 
     365           0 : OUString SvXMLAutoStylePoolP::Find( sal_Int32 nFamily,
     366             :                                    const OUString& rParent,
     367             :                                    const vector< XMLPropertyState >& rProperties ) const
     368             : {
     369           0 :     return pImpl->Find( nFamily, rParent, rProperties );
     370             : }
     371             : 
     372           0 : void SvXMLAutoStylePoolP::exportXML( sal_Int32 nFamily,
     373             :     const uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > &,
     374             :     const SvXMLUnitConverter&,
     375             :     const SvXMLNamespaceMap&
     376             :     ) const
     377             : {
     378             :     pImpl->exportXML( nFamily,
     379           0 :                       GetExport().GetDocHandler(),
     380           0 :                       GetExport().GetMM100UnitConverter(),
     381           0 :                       GetExport().GetNamespaceMap(),
     382           0 :                       this);
     383           0 : }
     384             : 
     385           0 : void SvXMLAutoStylePoolP::ClearEntries()
     386             : {
     387           0 :     pImpl->ClearEntries();
     388           0 : }
     389             : 
     390             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10