LCOV - code coverage report
Current view: top level - xmloff/source/draw - ximpbody.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 152 0.0 %
Date: 2014-04-14 Functions: 0 9 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 "ximpbody.hxx"
      21             : #include <xmloff/prstylei.hxx>
      22             : #include "ximpnote.hxx"
      23             : #include <com/sun/star/drawing/XDrawPage.hpp>
      24             : #include <com/sun/star/drawing/XDrawPages.hpp>
      25             : #include <com/sun/star/container/XNamed.hpp>
      26             : #include <com/sun/star/presentation/XPresentationPage.hpp>
      27             : #include "ximpstyl.hxx"
      28             : #include <com/sun/star/drawing/XMasterPageTarget.hpp>
      29             : #include <com/sun/star/beans/XPropertySet.hpp>
      30             : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
      31             : 
      32             : #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
      33             : #include <xmloff/xmluconv.hxx>
      34             : #include <xmloff/xmlprmap.hxx>
      35             : #include <xmloff/families.hxx>
      36             : #include "ximpshow.hxx"
      37             : #include "PropertySetMerger.hxx"
      38             : #include "animationimport.hxx"
      39             : 
      40             : using namespace ::com::sun::star;
      41             : 
      42           0 : SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport,
      43             :     sal_uInt16 nPrfx, const OUString& rLocalName,
      44             :     const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
      45             :     uno::Reference< drawing::XShapes >& rShapes)
      46             : :   SdXMLGenericPageContext( rImport, nPrfx, rLocalName, xAttrList, rShapes )
      47           0 : ,   mbHadSMILNodes( false )
      48             : {
      49           0 :     bool bHaveXmlId( false );
      50           0 :     OUString sXmlId;
      51             : 
      52           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
      53             : 
      54           0 :     for(sal_Int16 i=0; i < nAttrCount; i++)
      55             :     {
      56           0 :         OUString sAttrName = xAttrList->getNameByIndex( i );
      57           0 :         OUString aLocalName;
      58           0 :         sal_uInt16 nPrefix = GetSdImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
      59           0 :         OUString sValue = xAttrList->getValueByIndex( i );
      60           0 :         const SvXMLTokenMap& rAttrTokenMap = GetSdImport().GetDrawPageAttrTokenMap();
      61             : 
      62           0 :         switch(rAttrTokenMap.Get(nPrefix, aLocalName))
      63             :         {
      64             :             case XML_TOK_DRAWPAGE_NAME:
      65             :             {
      66           0 :                 maName = sValue;
      67           0 :                 break;
      68             :             }
      69             :             case XML_TOK_DRAWPAGE_STYLE_NAME:
      70             :             {
      71           0 :                 maStyleName = sValue;
      72           0 :                 break;
      73             :             }
      74             :             case XML_TOK_DRAWPAGE_MASTER_PAGE_NAME:
      75             :             {
      76           0 :                 maMasterPageName = sValue;
      77           0 :                 break;
      78             :             }
      79             :             case XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME:
      80             :             {
      81           0 :                 maPageLayoutName =  sValue;
      82           0 :                 break;
      83             :             }
      84             :             case XML_TOK_DRAWPAGE_USE_HEADER_NAME:
      85             :             {
      86           0 :                 maUseHeaderDeclName =  sValue;
      87           0 :                 break;
      88             :             }
      89             :             case XML_TOK_DRAWPAGE_USE_FOOTER_NAME:
      90             :             {
      91           0 :                 maUseFooterDeclName =  sValue;
      92           0 :                 break;
      93             :             }
      94             :             case XML_TOK_DRAWPAGE_USE_DATE_TIME_NAME:
      95             :             {
      96           0 :                 maUseDateTimeDeclName =  sValue;
      97           0 :                 break;
      98             :             }
      99             :             case XML_TOK_DRAWPAGE_DRAWID:
     100             :             {
     101           0 :                 if (!bHaveXmlId) { sXmlId = sValue; }
     102             :             }
     103           0 :             break;
     104             :             case XML_TOK_DRAWPAGE_XMLID:
     105             :             {
     106           0 :                 sXmlId = sValue;
     107           0 :                 bHaveXmlId = true;
     108             :             }
     109           0 :             break;
     110             :             case XML_TOK_DRAWPAGE_HREF:
     111             :             {
     112           0 :                 maHREF = sValue;
     113           0 :                 break;
     114             :             }
     115             :         }
     116           0 :     }
     117             : 
     118           0 :     if (!sXmlId.isEmpty())
     119             :     {
     120           0 :         uno::Reference< uno::XInterface > const xRef( rShapes.get() );
     121           0 :         GetImport().getInterfaceToIdentifierMapper().registerReference(
     122           0 :             sXmlId, xRef );
     123             :     }
     124           0 :     GetImport().GetShapeImport()->startPage( rShapes );
     125             : 
     126           0 :     uno::Reference< drawing::XDrawPage > xShapeDrawPage(rShapes, uno::UNO_QUERY);
     127             : 
     128             :     // set PageName?
     129           0 :     if(!maName.isEmpty())
     130             :     {
     131           0 :         if(xShapeDrawPage.is())
     132             :         {
     133           0 :             uno::Reference < container::XNamed > xNamed(xShapeDrawPage, uno::UNO_QUERY);
     134           0 :             if(xNamed.is())
     135           0 :                 xNamed->setName(maName);
     136             :         }
     137             :     }
     138             : 
     139             :     // set MasterPage?
     140           0 :     if(!maMasterPageName.isEmpty())
     141             :     {
     142             :         // #85906# Code for setting masterpage needs complete rework
     143             :         // since GetSdImport().GetMasterStylesContext() gives always ZERO
     144             :         // because of content/style file split. Now the nechanism is to
     145             :         // compare the wanted masterpage-name with the existing masterpages
     146             :         // which were loaded and created in the styles section loading.
     147           0 :         uno::Reference< drawing::XDrawPages > xMasterPages(GetSdImport().GetLocalMasterPages(), uno::UNO_QUERY);
     148           0 :         uno::Reference < drawing::XMasterPageTarget > xDrawPage(rShapes, uno::UNO_QUERY);
     149           0 :         uno::Reference< drawing::XDrawPage > xMasterPage;
     150             : 
     151           0 :         if(xDrawPage.is() && xMasterPages.is())
     152             :         {
     153           0 :             sal_Bool bDone(sal_False);
     154             :             OUString sDisplayName( rImport.GetStyleDisplayName(
     155           0 :                             XML_STYLE_FAMILY_MASTER_PAGE, maMasterPageName ) );
     156             : 
     157           0 :             for(sal_Int32 a = 0; !bDone && a < xMasterPages->getCount(); a++)
     158             :             {
     159           0 :                 uno::Any aAny(xMasterPages->getByIndex(a));
     160           0 :                 aAny >>= xMasterPage;
     161             : 
     162           0 :                 if(xMasterPage.is())
     163             :                 {
     164           0 :                     uno::Reference < container::XNamed > xMasterNamed(xMasterPage, uno::UNO_QUERY);
     165           0 :                     if(xMasterNamed.is())
     166             :                     {
     167           0 :                         OUString sMasterPageName = xMasterNamed->getName();
     168             : 
     169           0 :                         if(!sMasterPageName.isEmpty() && sMasterPageName.equals(sDisplayName))
     170             :                         {
     171           0 :                             xDrawPage->setMasterPage(xMasterPage);
     172           0 :                             bDone = sal_True;
     173           0 :                         }
     174           0 :                     }
     175             :                 }
     176           0 :             }
     177             : 
     178           0 :             DBG_ASSERT( bDone, "xmloff::SdXMLDrawPageContext::SdXMLDrawPageContext(), could not find a slide master!" );
     179           0 :         }
     180             :     }
     181             : 
     182           0 :     SetStyle( maStyleName );
     183             : 
     184           0 :     if( !maHREF.isEmpty() )
     185             :     {
     186           0 :         uno::Reference< beans::XPropertySet > xProps( xShapeDrawPage, uno::UNO_QUERY );
     187           0 :         if( xProps.is() )
     188             :         {
     189           0 :             sal_Int32 nIndex = maHREF.lastIndexOf( (sal_Unicode)'#' );
     190           0 :             if( nIndex != -1 )
     191             :             {
     192           0 :                 OUString aFileName( maHREF.copy( 0, nIndex ) );
     193           0 :                 OUString aBookmarkName( maHREF.copy( nIndex+1 ) );
     194             : 
     195           0 :                 maHREF = GetImport().GetAbsoluteReference( aFileName );
     196           0 :                 maHREF += OUString(static_cast<sal_Unicode>('#'));
     197           0 :                 maHREF += aBookmarkName;
     198             :             }
     199             : 
     200           0 :             xProps->setPropertyValue("BookmarkURL", uno::makeAny( maHREF ) );
     201           0 :         }
     202             :     }
     203             : 
     204           0 :     SetLayout();
     205             : 
     206           0 :     DeleteAllShapes();
     207           0 : }
     208             : 
     209           0 : SdXMLDrawPageContext::~SdXMLDrawPageContext()
     210             : {
     211           0 : }
     212             : 
     213           0 : SvXMLImportContext *SdXMLDrawPageContext::CreateChildContext( sal_uInt16 nPrefix,
     214             :     const OUString& rLocalName,
     215             :     const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
     216             : {
     217           0 :     SvXMLImportContext *pContext = 0L;
     218           0 :     const SvXMLTokenMap& rTokenMap = GetSdImport().GetDrawPageElemTokenMap();
     219             : 
     220             :     // some special objects inside draw:page context
     221           0 :     switch(rTokenMap.Get(nPrefix, rLocalName))
     222             :     {
     223             :         case XML_TOK_DRAWPAGE_NOTES:
     224             :         {
     225           0 :             if( GetSdImport().IsImpress() )
     226             :             {
     227             :                 // get notes page
     228           0 :                 uno::Reference< presentation::XPresentationPage > xPresPage(GetLocalShapesContext(), uno::UNO_QUERY);
     229           0 :                 if(xPresPage.is())
     230             :                 {
     231           0 :                     uno::Reference< drawing::XDrawPage > xNotesDrawPage(xPresPage->getNotesPage(), uno::UNO_QUERY);
     232           0 :                     if(xNotesDrawPage.is())
     233             :                     {
     234           0 :                         uno::Reference< drawing::XShapes > xNewShapes(xNotesDrawPage, uno::UNO_QUERY);
     235           0 :                         if(xNewShapes.is())
     236             :                         {
     237             :                             // presentation:notes inside draw:page context
     238           0 :                             pContext = new SdXMLNotesContext( GetSdImport(), nPrefix, rLocalName, xAttrList, xNewShapes);
     239           0 :                         }
     240           0 :                     }
     241           0 :                 }
     242             :             }
     243           0 :             break;
     244             :         }
     245             :         case XML_TOK_DRAWPAGE_PAR:
     246             :         case XML_TOK_DRAWPAGE_SEQ:
     247             :         {
     248           0 :             if( GetSdImport().IsImpress() )
     249             :             {
     250           0 :                 uno::Reference< animations::XAnimationNodeSupplier > xNodeSupplier(GetLocalShapesContext(), uno::UNO_QUERY);
     251           0 :                 if(xNodeSupplier.is())
     252             :                 {
     253           0 :                     pContext = new xmloff::AnimationNodeContext( xNodeSupplier->getAnimationNode(), GetSdImport(), nPrefix, rLocalName, xAttrList );
     254           0 :                     mbHadSMILNodes = true;
     255           0 :                 }
     256             :             }
     257           0 :             break;
     258             :         }
     259             :     }
     260             : 
     261             :     // call parent when no own context was created
     262           0 :     if(!pContext)
     263           0 :         pContext = SdXMLGenericPageContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
     264             : 
     265           0 :     return pContext;
     266             : }
     267             : 
     268           0 : void SdXMLDrawPageContext::EndElement()
     269             : {
     270           0 :     SdXMLGenericPageContext::EndElement();
     271           0 :     GetImport().GetShapeImport()->endPage(GetLocalShapesContext());
     272             : 
     273           0 :     if( mbHadSMILNodes )
     274             :     {
     275           0 :         uno::Reference< animations::XAnimationNodeSupplier > xNodeSupplier(GetLocalShapesContext(), uno::UNO_QUERY);
     276           0 :         uno::Reference< beans::XPropertySet > xPageProps( GetLocalShapesContext(), uno::UNO_QUERY );
     277           0 :         if(xNodeSupplier.is())
     278           0 :             xmloff::AnimationNodeContext::postProcessRootNode( GetSdImport(), xNodeSupplier->getAnimationNode(), xPageProps );
     279             :     }
     280           0 : }
     281             : 
     282           0 : SdXMLBodyContext::SdXMLBodyContext( SdXMLImport& rImport,
     283             :     sal_uInt16 nPrfx, const OUString& rLocalName )
     284           0 : :   SvXMLImportContext( rImport, nPrfx, rLocalName )
     285             : {
     286           0 : }
     287             : 
     288           0 : SdXMLBodyContext::~SdXMLBodyContext()
     289             : {
     290           0 : }
     291             : 
     292           0 : SvXMLImportContext *SdXMLBodyContext::CreateChildContext(
     293             :     sal_uInt16 nPrefix,
     294             :     const OUString& rLocalName,
     295             :     const uno::Reference< xml::sax::XAttributeList>& xAttrList )
     296             : {
     297           0 :     SvXMLImportContext *pContext = 0L;
     298           0 :     const SvXMLTokenMap& rTokenMap = GetSdImport().GetBodyElemTokenMap();
     299             : 
     300           0 :     switch(rTokenMap.Get(nPrefix, rLocalName))
     301             :     {
     302             :         case XML_TOK_BODY_HEADER_DECL:
     303             :         case XML_TOK_BODY_FOOTER_DECL:
     304             :         case XML_TOK_BODY_DATE_TIME_DECL:
     305             :         {
     306           0 :             pContext = new SdXMLHeaderFooterDeclContext( GetImport(), nPrefix, rLocalName, xAttrList );
     307           0 :             break;
     308             :         }
     309             :         case XML_TOK_BODY_PAGE:
     310             :         {
     311             :             // only read the first page in preview mode
     312           0 :             if( (GetSdImport().GetNewPageCount() == 0) || !GetSdImport().IsPreview() )
     313             :             {
     314             :                 // import this page
     315           0 :                 uno::Reference< drawing::XDrawPage > xNewDrawPage;
     316           0 :                 uno::Reference< drawing::XDrawPages > xDrawPages(GetSdImport().GetLocalDrawPages(), uno::UNO_QUERY);
     317             : 
     318           0 :                 if( !xDrawPages.is() )
     319           0 :                     break;
     320             : 
     321           0 :                 if(GetSdImport().GetNewPageCount() + 1 > xDrawPages->getCount())
     322             :                 {
     323             :                     // new page, create and insert
     324           0 :                     xNewDrawPage = xDrawPages->insertNewByIndex(xDrawPages->getCount());
     325             :                 }
     326             :                 else
     327             :                 {
     328             :                     // existing page, use it
     329           0 :                     uno::Any aAny(xDrawPages->getByIndex(GetSdImport().GetNewPageCount()));
     330           0 :                     aAny >>= xNewDrawPage;
     331             :                 }
     332             : 
     333             :                 // increment global import page counter
     334           0 :                 GetSdImport().IncrementNewPageCount();
     335             : 
     336           0 :                 if(xNewDrawPage.is())
     337             :                 {
     338           0 :                     uno::Reference< drawing::XShapes > xNewShapes(xNewDrawPage, uno::UNO_QUERY);
     339           0 :                     if(xNewShapes.is())
     340             :                     {
     341             :                         // draw:page inside office:body context
     342             :                         pContext = new SdXMLDrawPageContext(GetSdImport(), nPrefix, rLocalName, xAttrList,
     343           0 :                             xNewShapes);
     344           0 :                     }
     345           0 :                 }
     346             :             }
     347           0 :             break;
     348             :         }
     349             :         case XML_TOK_BODY_SETTINGS:
     350             :         {
     351           0 :             pContext = new SdXMLShowsContext( GetSdImport(), nPrefix, rLocalName, xAttrList );
     352             :         }
     353             :     }
     354             : 
     355             :     // call parent when no own context was created
     356           0 :     if(!pContext)
     357           0 :         pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
     358             : 
     359           0 :     return pContext;
     360             : }
     361             : 
     362             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10