LCOV - code coverage report
Current view: top level - xmloff/source/draw - ximppage.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 135 274 49.3 %
Date: 2014-04-11 Functions: 10 28 35.7 %
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/geometry/RealPoint2D.hpp>
      21             : #include <com/sun/star/text/XTextCursor.hpp>
      22             : #include <com/sun/star/util/DateTime.hpp>
      23             : #include <cppuhelper/implbase1.hxx>
      24             : #include <sax/tools/converter.hxx>
      25             : #include "XMLNumberStylesImport.hxx"
      26             : #include <xmloff/xmlstyle.hxx>
      27             : #include <xmloff/xmltoken.hxx>
      28             : #include <xmloff/xmlnmspe.hxx>
      29             : #include "ximppage.hxx"
      30             : #include "ximpshap.hxx"
      31             : #include "animimp.hxx"
      32             : #include "XMLStringBufferImportContext.hxx"
      33             : #include <xmloff/xmlictxt.hxx>
      34             : #include "ximpstyl.hxx"
      35             : #include <xmloff/prstylei.hxx>
      36             : #include "PropertySetMerger.hxx"
      37             : 
      38             : #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
      39             : #include <xmloff/xmluconv.hxx>
      40             : 
      41             : using namespace ::com::sun::star;
      42             : using namespace ::xmloff::token;
      43             : using namespace ::com::sun::star::uno;
      44             : using namespace ::com::sun::star::lang;
      45             : using namespace ::com::sun::star::text;
      46             : using namespace ::com::sun::star::util;
      47             : using namespace ::com::sun::star::beans;
      48             : using namespace ::com::sun::star::drawing;
      49             : using namespace ::com::sun::star::container;
      50             : using namespace ::com::sun::star::office;
      51             : using namespace ::com::sun::star::xml::sax;
      52             : using namespace ::com::sun::star::geometry;
      53             : 
      54           0 : class DrawAnnotationContext : public SvXMLImportContext
      55             : {
      56             : 
      57             : public:
      58             :     DrawAnnotationContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName,const Reference< xml::sax::XAttributeList>& xAttrList, const Reference< XAnnotationAccess >& xAnnotationAccess );
      59             : 
      60             :     virtual SvXMLImportContext * CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
      61             :     virtual void EndElement() SAL_OVERRIDE;
      62             : 
      63             : private:
      64             :     Reference< XAnnotation > mxAnnotation;
      65             :     Reference< XTextCursor > mxCursor;
      66             : 
      67             :     OUStringBuffer maAuthorBuffer;
      68             :     OUStringBuffer maDateBuffer;
      69             : };
      70             : 
      71           0 : DrawAnnotationContext::DrawAnnotationContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName,const Reference< xml::sax::XAttributeList>& xAttrList, const Reference< XAnnotationAccess >& xAnnotationAccess )
      72             : : SvXMLImportContext( rImport, nPrfx, rLocalName )
      73           0 : , mxAnnotation( xAnnotationAccess->createAndInsertAnnotation() )
      74             : {
      75           0 :     if( mxAnnotation.is() )
      76             :     {
      77           0 :         sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
      78             : 
      79           0 :         RealPoint2D aPosition;
      80           0 :         RealSize2D aSize;
      81             : 
      82           0 :         for(sal_Int16 i=0; i < nAttrCount; i++)
      83             :         {
      84           0 :             OUString sValue( xAttrList->getValueByIndex( i ) );
      85           0 :             OUString sAttrName( xAttrList->getNameByIndex( i ) );
      86           0 :             OUString aLocalName;
      87           0 :             switch( GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ) )
      88             :             {
      89             :             case XML_NAMESPACE_SVG:
      90           0 :                 if( IsXMLToken( aLocalName, XML_X ) )
      91             :                 {
      92             :                     sal_Int32 x;
      93           0 :                     GetImport().GetMM100UnitConverter().convertMeasureToCore(
      94           0 :                             x, sValue);
      95           0 :                     aPosition.X = static_cast<double>(x) / 100.0;
      96             :                 }
      97           0 :                 else if( IsXMLToken( aLocalName, XML_Y ) )
      98             :                 {
      99             :                     sal_Int32 y;
     100           0 :                     GetImport().GetMM100UnitConverter().convertMeasureToCore(
     101           0 :                             y, sValue);
     102           0 :                     aPosition.Y = static_cast<double>(y) / 100.0;
     103             :                 }
     104           0 :                 else if( IsXMLToken( aLocalName, XML_WIDTH ) )
     105             :                 {
     106             :                     sal_Int32 w;
     107           0 :                     GetImport().GetMM100UnitConverter().convertMeasureToCore(
     108           0 :                             w, sValue);
     109           0 :                     aSize.Width = static_cast<double>(w) / 100.0;
     110             :                 }
     111           0 :                 else if( IsXMLToken( aLocalName, XML_HEIGHT ) )
     112             :                 {
     113             :                     sal_Int32 h;
     114           0 :                     GetImport().GetMM100UnitConverter().convertMeasureToCore(
     115           0 :                             h, sValue);
     116           0 :                     aSize.Height = static_cast<double>(h) / 100.0;
     117             :                 }
     118           0 :                 break;
     119             :             default:
     120           0 :                 break;
     121             :             }
     122           0 :         }
     123             : 
     124           0 :         mxAnnotation->setPosition( aPosition );
     125           0 :         mxAnnotation->setSize( aSize );
     126             :     }
     127           0 : }
     128             : 
     129           0 : SvXMLImportContext * DrawAnnotationContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList )
     130             : {
     131           0 :     SvXMLImportContext * pContext = NULL;
     132             : 
     133           0 :     if( mxAnnotation.is() )
     134             :     {
     135           0 :         if( XML_NAMESPACE_DC == nPrefix )
     136             :         {
     137           0 :             if( IsXMLToken( rLocalName, XML_CREATOR ) )
     138           0 :                 pContext = new XMLStringBufferImportContext(GetImport(), nPrefix, rLocalName, maAuthorBuffer);
     139           0 :             else if( IsXMLToken( rLocalName, XML_DATE ) )
     140           0 :                 pContext = new XMLStringBufferImportContext(GetImport(), nPrefix, rLocalName, maDateBuffer);
     141             :         }
     142             :         else
     143             :         {
     144             :             // create text cursor on demand
     145           0 :             if( !mxCursor.is() )
     146             :             {
     147           0 :                 uno::Reference< text::XText > xText( mxAnnotation->getTextRange() );
     148           0 :                 if( xText.is() )
     149             :                 {
     150           0 :                     UniReference < XMLTextImportHelper > xTxtImport = GetImport().GetTextImport();
     151           0 :                     mxCursor = xText->createTextCursor();
     152           0 :                     if( mxCursor.is() )
     153           0 :                         xTxtImport->SetCursor( mxCursor );
     154           0 :                 }
     155             :             }
     156             : 
     157             :             // if we have a text cursor, lets  try to import some text
     158           0 :             if( mxCursor.is() )
     159             :             {
     160           0 :                 pContext = GetImport().GetTextImport()->CreateTextChildContext( GetImport(), nPrefix, rLocalName, xAttrList );
     161             :             }
     162             :         }
     163             :     }
     164             : 
     165             :     // call parent for content
     166           0 :     if(!pContext)
     167           0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
     168             : 
     169           0 :     return pContext;
     170             : }
     171             : 
     172           0 : void DrawAnnotationContext::EndElement()
     173             : {
     174           0 :     if(mxCursor.is())
     175             :     {
     176             :         // delete addition newline
     177           0 :         const OUString aEmpty;
     178           0 :         mxCursor->gotoEnd( sal_False );
     179           0 :         mxCursor->goLeft( 1, sal_True );
     180           0 :         mxCursor->setString( aEmpty );
     181             : 
     182             :         // reset cursor
     183           0 :         GetImport().GetTextImport()->ResetCursor();
     184             :     }
     185             : 
     186           0 :     if( mxAnnotation.is() )
     187             :     {
     188           0 :         mxAnnotation->setAuthor( maAuthorBuffer.makeStringAndClear() );
     189             : 
     190           0 :         util::DateTime aDateTime;
     191           0 :         if (::sax::Converter::parseDateTime(aDateTime, 0,
     192           0 :                 maDateBuffer.makeStringAndClear()))
     193             :         {
     194           0 :             mxAnnotation->setDateTime(aDateTime);
     195             :         }
     196             :     }
     197           0 : }
     198             : 
     199           0 : TYPEINIT1( SdXMLGenericPageContext, SvXMLImportContext );
     200             : 
     201         120 : SdXMLGenericPageContext::SdXMLGenericPageContext(
     202             :     SvXMLImport& rImport,
     203             :     sal_uInt16 nPrfx, const OUString& rLocalName,
     204             :     const Reference< xml::sax::XAttributeList>& xAttrList,
     205             :     Reference< drawing::XShapes >& rShapes)
     206             : : SvXMLImportContext( rImport, nPrfx, rLocalName )
     207             : , mxShapes( rShapes )
     208         120 : , mxAnnotationAccess( rShapes, UNO_QUERY )
     209             : {
     210         120 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     211             : 
     212         429 :     for(sal_Int16 i=0; i < nAttrCount; i++)
     213             :     {
     214         309 :         OUString sAttrName = xAttrList->getNameByIndex( i );
     215         618 :         OUString aLocalName;
     216         309 :         sal_uInt16 nPrefix = GetSdImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
     217         309 :         if( (nPrefix == XML_NAMESPACE_DRAW) && IsXMLToken( aLocalName, XML_NAV_ORDER ) )
     218             :         {
     219           0 :             msNavOrder = xAttrList->getValueByIndex( i );
     220           0 :             break;
     221             :         }
     222         309 :     }
     223         120 : }
     224             : 
     225         120 : SdXMLGenericPageContext::~SdXMLGenericPageContext()
     226             : {
     227         120 : }
     228             : 
     229         120 : void SdXMLGenericPageContext::StartElement( const Reference< ::com::sun::star::xml::sax::XAttributeList >& )
     230             : {
     231         120 :     GetImport().GetShapeImport()->pushGroupForSorting( mxShapes );
     232             : 
     233         120 :     if( GetImport().IsFormsSupported() )
     234         120 :         GetImport().GetFormImport()->startPage( Reference< drawing::XDrawPage >::query( mxShapes ) );
     235         120 : }
     236             : 
     237         424 : SvXMLImportContext* SdXMLGenericPageContext::CreateChildContext( sal_uInt16 nPrefix,
     238             :     const OUString& rLocalName,
     239             :     const Reference< xml::sax::XAttributeList>& xAttrList )
     240             : {
     241         424 :     SvXMLImportContext* pContext = 0L;
     242             : 
     243         424 :     if( nPrefix == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_ANIMATIONS ) )
     244             :     {
     245           0 :         pContext = new XMLAnimationsContext( GetImport(), nPrefix, rLocalName, xAttrList );
     246             :     }
     247         424 :     else if( nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_FORMS ) )
     248             :     {
     249           4 :         if( GetImport().IsFormsSupported() )
     250           4 :             pContext = GetImport().GetFormImport()->createOfficeFormsContext( GetImport(), nPrefix, rLocalName );
     251             :     }
     252         420 :     else if( ((nPrefix == XML_NAMESPACE_OFFICE) || (nPrefix == XML_NAMESPACE_OFFICE_EXT)) && IsXMLToken( rLocalName, XML_ANNOTATION ) )
     253             :     {
     254           0 :         if( mxAnnotationAccess.is() )
     255           0 :             pContext = new DrawAnnotationContext( GetImport(), nPrefix, rLocalName, xAttrList, mxAnnotationAccess );
     256             :     }
     257             :     else
     258             :     {
     259             :         // call GroupChildContext function at common ShapeImport
     260         420 :         pContext = GetImport().GetShapeImport()->CreateGroupChildContext(
     261         840 :             GetImport(), nPrefix, rLocalName, xAttrList, mxShapes);
     262             :     }
     263             : 
     264             :     // call parent when no own context was created
     265         424 :     if(!pContext)
     266           0 :         pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
     267             : 
     268         424 :     return pContext;
     269             : }
     270             : 
     271         120 : void SdXMLGenericPageContext::EndElement()
     272             : {
     273         120 :     GetImport().GetShapeImport()->popGroupAndSort();
     274             : 
     275         120 :     if( GetImport().IsFormsSupported() )
     276         120 :         GetImport().GetFormImport()->endPage();
     277             : 
     278         120 :     if( !maUseHeaderDeclName.isEmpty() || !maUseFooterDeclName.isEmpty() || !maUseDateTimeDeclName.isEmpty() )
     279             :     {
     280             :         try
     281             :         {
     282           0 :             Reference <beans::XPropertySet> xSet(mxShapes, uno::UNO_QUERY_THROW );
     283           0 :             Reference< beans::XPropertySetInfo > xInfo( xSet->getPropertySetInfo() );
     284             : 
     285           0 :             if( !maUseHeaderDeclName.isEmpty() )
     286             :             {
     287           0 :                 const OUString aStrHeaderTextProp( "HeaderText" );
     288           0 :                 if( xInfo->hasPropertyByName( aStrHeaderTextProp ) )
     289           0 :                     xSet->setPropertyValue( aStrHeaderTextProp,
     290           0 :                                             makeAny( GetSdImport().GetHeaderDecl( maUseHeaderDeclName ) ) );
     291             :             }
     292             : 
     293           0 :             if( !maUseFooterDeclName.isEmpty() )
     294             :             {
     295           0 :                 const OUString aStrFooterTextProp( "FooterText" );
     296           0 :                 if( xInfo->hasPropertyByName( aStrFooterTextProp ) )
     297           0 :                     xSet->setPropertyValue( aStrFooterTextProp,
     298           0 :                                         makeAny( GetSdImport().GetFooterDecl( maUseFooterDeclName ) ) );
     299             :             }
     300             : 
     301           0 :             if( !maUseDateTimeDeclName.isEmpty() )
     302             :             {
     303           0 :                 const OUString aStrDateTimeTextProp( "DateTimeText" );
     304           0 :                 if( xInfo->hasPropertyByName( aStrDateTimeTextProp ) )
     305             :                 {
     306             :                     sal_Bool bFixed;
     307           0 :                     OUString aDateTimeFormat;
     308           0 :                     const OUString aText( GetSdImport().GetDateTimeDecl( maUseDateTimeDeclName, bFixed, aDateTimeFormat ) );
     309             : 
     310           0 :                     xSet->setPropertyValue("IsDateTimeFixed",
     311           0 :                                         makeAny( bFixed ) );
     312             : 
     313           0 :                     if( bFixed )
     314             :                     {
     315           0 :                         xSet->setPropertyValue( aStrDateTimeTextProp, makeAny( aText ) );
     316             :                     }
     317           0 :                     else if( !aDateTimeFormat.isEmpty() )
     318             :                     {
     319           0 :                         const SdXMLStylesContext* pStyles = dynamic_cast< const SdXMLStylesContext* >( GetSdImport().GetShapeImport()->GetStylesContext() );
     320           0 :                         if( !pStyles )
     321           0 :                             pStyles = dynamic_cast< const SdXMLStylesContext* >( GetSdImport().GetShapeImport()->GetAutoStylesContext() );
     322             : 
     323           0 :                         if( pStyles )
     324             :                         {
     325             :                             const SdXMLNumberFormatImportContext* pSdNumStyle =
     326           0 :                                 dynamic_cast< const SdXMLNumberFormatImportContext* >( pStyles->FindStyleChildContext( XML_STYLE_FAMILY_DATA_STYLE, aDateTimeFormat, true ) );
     327             : 
     328           0 :                             if( pSdNumStyle )
     329             :                             {
     330           0 :                                 xSet->setPropertyValue("DateTimeFormat",
     331           0 :                                                                     makeAny( pSdNumStyle->GetDrawKey() ) );
     332             :                             }
     333             :                         }
     334           0 :                     }
     335           0 :                 }
     336           0 :             }
     337             :         }
     338           0 :         catch(const uno::Exception&)
     339             :         {
     340             :             OSL_FAIL("xmloff::SdXMLGenericPageContext::EndElement(), unexpected exception cought!");
     341             :         }
     342             :     }
     343             : 
     344         120 :     SetNavigationOrder();
     345         120 : }
     346             : 
     347         120 : void SdXMLGenericPageContext::SetStyle( OUString& rStyleName )
     348             : {
     349             :     // set PageProperties?
     350         120 :     if(!rStyleName.isEmpty())
     351             :     {
     352             :         try
     353             :         {
     354         108 :             const SvXMLImportContext* pContext = GetSdImport().GetShapeImport()->GetAutoStylesContext();
     355             : 
     356         108 :             if( pContext && pContext->ISA( SvXMLStyleContext ) )
     357             :             {
     358         108 :                 const SdXMLStylesContext* pStyles = (SdXMLStylesContext*)pContext;
     359         108 :                 if(pStyles)
     360             :                 {
     361             :                     const SvXMLStyleContext* pStyle = pStyles->FindStyleChildContext(
     362         108 :                         XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, rStyleName);
     363             : 
     364         108 :                     if(pStyle && pStyle->ISA(XMLPropStyleContext))
     365             :                     {
     366         108 :                         XMLPropStyleContext* pPropStyle = (XMLPropStyleContext*)pStyle;
     367             : 
     368         108 :                         Reference <beans::XPropertySet> xPropSet1(mxShapes, uno::UNO_QUERY);
     369         108 :                         if(xPropSet1.is())
     370             :                         {
     371         108 :                             Reference< beans::XPropertySet > xPropSet( xPropSet1 );
     372         216 :                             Reference< beans::XPropertySet > xBackgroundSet;
     373             : 
     374         216 :                             const OUString aBackground("Background");
     375         108 :                             if( xPropSet1->getPropertySetInfo()->hasPropertyByName( aBackground ) )
     376             :                             {
     377          73 :                                 Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() );
     378          73 :                                 if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) )
     379             :                                 {
     380          73 :                                     Reference< lang::XMultiServiceFactory > xServiceFact(GetSdImport().GetModel(), uno::UNO_QUERY);
     381          73 :                                     if(xServiceFact.is())
     382             :                                     {
     383         146 :                                         xBackgroundSet = Reference< beans::XPropertySet >::query(
     384          73 :                                             xServiceFact->createInstance(
     385         146 :                                             OUString("com.sun.star.drawing.Background")));
     386          73 :                                     }
     387             :                                 }
     388             : 
     389          73 :                                 if( xBackgroundSet.is() )
     390          73 :                                     xPropSet = PropertySetMerger_CreateInstance( xPropSet1, xBackgroundSet );
     391             :                             }
     392             : 
     393         108 :                             if(xPropSet.is())
     394             :                             {
     395         108 :                                 pPropStyle->FillPropertySet(xPropSet);
     396             : 
     397         108 :                                 if( xBackgroundSet.is() )
     398          73 :                                     xPropSet1->setPropertyValue( aBackground, uno::makeAny( xBackgroundSet ) );
     399         108 :                             }
     400         108 :                         }
     401             :                     }
     402             :                 }
     403             :             }
     404             :         }
     405           0 :         catch (const uno::Exception&)
     406             :         {
     407             :             OSL_FAIL( "SdXMLGenericPageContext::SetStyle(): uno::Exception caught!" );
     408             :         }
     409             :     }
     410         120 : }
     411             : 
     412          85 : void SdXMLGenericPageContext::SetLayout()
     413             : {
     414             :     // set PresentationPageLayout?
     415          85 :     if(GetSdImport().IsImpress() && !maPageLayoutName.isEmpty())
     416             :     {
     417          29 :         sal_Int32 nType = -1;
     418             : 
     419          29 :         const SvXMLImportContext* pContext = GetSdImport().GetShapeImport()->GetStylesContext();
     420             : 
     421          29 :         if( pContext && pContext->ISA( SvXMLStyleContext ) )
     422             :         {
     423          12 :             const SdXMLStylesContext* pStyles = (SdXMLStylesContext*)pContext;
     424          12 :             if(pStyles)
     425             :             {
     426          12 :                 const SvXMLStyleContext* pStyle = pStyles->FindStyleChildContext( XML_STYLE_FAMILY_SD_PRESENTATIONPAGELAYOUT_ID, maPageLayoutName);
     427             : 
     428          12 :                 if(pStyle && pStyle->ISA(SdXMLPresentationPageLayoutContext))
     429             :                 {
     430          12 :                     SdXMLPresentationPageLayoutContext* pLayout = (SdXMLPresentationPageLayoutContext*)pStyle;
     431          12 :                     nType = pLayout->GetTypeId();
     432             :                 }
     433             :             }
     434             : 
     435             :         }
     436          29 :         if( -1 == nType )
     437             :         {
     438          17 :             Reference< container::XNameAccess > xPageLayouts( GetSdImport().getPageLayouts() );
     439          17 :             if( xPageLayouts.is() )
     440             :             {
     441          17 :                 if( xPageLayouts->hasByName( maPageLayoutName ) )
     442          17 :                     xPageLayouts->getByName( maPageLayoutName ) >>= nType;
     443          17 :             }
     444             : 
     445             :         }
     446             : 
     447          29 :         if( -1 != nType )
     448             :         {
     449          29 :             Reference <beans::XPropertySet> xPropSet(mxShapes, uno::UNO_QUERY);
     450          29 :             if(xPropSet.is())
     451             :             {
     452          29 :                 OUString aPropName("Layout");
     453          58 :                 Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
     454          29 :                 if( xInfo.is() && xInfo->hasPropertyByName( aPropName ) )
     455          58 :                     xPropSet->setPropertyValue(aPropName, uno::makeAny( (sal_Int16)nType ) );
     456          29 :             }
     457             :         }
     458             :     }
     459          85 : }
     460             : 
     461          85 : void SdXMLGenericPageContext::DeleteAllShapes()
     462             : {
     463             :     // now delete all up-to-now contained shapes; they have been created
     464             :     // when setting the presentation page layout.
     465         422 :     while(mxShapes->getCount())
     466             :     {
     467         252 :         Reference< drawing::XShape > xShape;
     468         504 :         uno::Any aAny(mxShapes->getByIndex(0L));
     469             : 
     470         252 :         aAny >>= xShape;
     471             : 
     472         252 :         if(xShape.is())
     473             :         {
     474         252 :             mxShapes->remove(xShape);
     475             :         }
     476         252 :     }
     477          85 : }
     478             : 
     479          57 : void SdXMLGenericPageContext::SetPageMaster( OUString& rsPageMasterName )
     480             : {
     481          57 :     if( GetSdImport().GetShapeImport()->GetStylesContext() )
     482             :     {
     483             :         // look for PageMaster with this name
     484             : 
     485             :         // #80012# GetStylesContext() replaced with GetAutoStylesContext()
     486          57 :         const SvXMLStylesContext* pAutoStyles = GetSdImport().GetShapeImport()->GetAutoStylesContext();
     487             : 
     488          57 :         const SvXMLStyleContext* pStyle = pAutoStyles ? pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_SD_PAGEMASTERCONEXT_ID, rsPageMasterName) : NULL;
     489             : 
     490          57 :         if(pStyle && pStyle->ISA(SdXMLPageMasterContext))
     491             :         {
     492          57 :             const SdXMLPageMasterContext* pPageMaster = (SdXMLPageMasterContext*)pStyle;
     493          57 :             const SdXMLPageMasterStyleContext* pPageMasterContext = pPageMaster->GetPageMasterStyle();
     494             : 
     495          57 :             if(pPageMasterContext)
     496             :             {
     497          57 :                 Reference< drawing::XDrawPage > xMasterPage(GetLocalShapesContext(), uno::UNO_QUERY);
     498          57 :                 if(xMasterPage.is())
     499             :                 {
     500             :                     // set sizes for this masterpage
     501          57 :                     Reference <beans::XPropertySet> xPropSet(xMasterPage, uno::UNO_QUERY);
     502          57 :                     if(xPropSet.is())
     503             :                     {
     504          57 :                         uno::Any aAny;
     505             : 
     506          57 :                         aAny <<= pPageMasterContext->GetBorderBottom();
     507          57 :                         xPropSet->setPropertyValue("BorderBottom", aAny);
     508             : 
     509          57 :                         aAny <<= pPageMasterContext->GetBorderLeft();
     510          57 :                         xPropSet->setPropertyValue("BorderLeft", aAny);
     511             : 
     512          57 :                         aAny <<= pPageMasterContext->GetBorderRight();
     513          57 :                         xPropSet->setPropertyValue("BorderRight", aAny);
     514             : 
     515          57 :                         aAny <<= pPageMasterContext->GetBorderTop();
     516          57 :                         xPropSet->setPropertyValue("BorderTop", aAny);
     517             : 
     518          57 :                         aAny <<= pPageMasterContext->GetWidth();
     519          57 :                         xPropSet->setPropertyValue("Width", aAny);
     520             : 
     521          57 :                         aAny <<= pPageMasterContext->GetHeight();
     522          57 :                         xPropSet->setPropertyValue("Height", aAny);
     523             : 
     524          57 :                         aAny <<= pPageMasterContext->GetOrientation();
     525          57 :                         xPropSet->setPropertyValue("Orientation", aAny);
     526          57 :                     }
     527          57 :                 }
     528             :             }
     529             :         }
     530             : 
     531             :     }
     532          57 : }
     533             : 
     534           0 : class XoNavigationOrderAccess : public ::cppu::WeakImplHelper1< XIndexAccess >
     535             : {
     536             : public:
     537             :     XoNavigationOrderAccess( std::vector< Reference< XShape > >& rShapes );
     538             : 
     539             :     // XIndexAccess
     540             :     virtual sal_Int32 SAL_CALL getCount(  ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     541             :     virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     542             : 
     543             :     // XElementAccess
     544             :     virtual Type SAL_CALL getElementType(  ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     545             :     virtual sal_Bool SAL_CALL hasElements(  ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     546             : 
     547             : private:
     548             :     std::vector< Reference< XShape > > maShapes;
     549             : };
     550             : 
     551           0 : XoNavigationOrderAccess::XoNavigationOrderAccess( std::vector< Reference< XShape > >& rShapes )
     552             : {
     553           0 :     maShapes.swap( rShapes );
     554           0 : }
     555             : 
     556             : // XIndexAccess
     557           0 : sal_Int32 SAL_CALL XoNavigationOrderAccess::getCount(  ) throw (RuntimeException, std::exception)
     558             : {
     559           0 :     return static_cast< sal_Int32 >( maShapes.size() );
     560             : }
     561             : 
     562           0 : Any SAL_CALL XoNavigationOrderAccess::getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception)
     563             : {
     564           0 :     if( (Index < 0) || (Index > getCount()) )
     565           0 :         throw IndexOutOfBoundsException();
     566             : 
     567           0 :     return Any( maShapes[Index] );
     568             : }
     569             : 
     570             : // XElementAccess
     571           0 : Type SAL_CALL XoNavigationOrderAccess::getElementType(  ) throw (RuntimeException, std::exception)
     572             : {
     573           0 :     return cppu::UnoType<XShape>::get();
     574             : }
     575             : 
     576           0 : sal_Bool SAL_CALL XoNavigationOrderAccess::hasElements(  ) throw (RuntimeException, std::exception)
     577             : {
     578           0 :     return maShapes.empty() ? sal_False : sal_True;
     579             : }
     580             : 
     581         120 : void SdXMLGenericPageContext::SetNavigationOrder()
     582             : {
     583         120 :     if( !msNavOrder.isEmpty() ) try
     584             :     {
     585             :         sal_uInt32 nIndex;
     586           0 :         const sal_uInt32 nCount = static_cast< sal_uInt32 >( mxShapes->getCount() );
     587           0 :         std::vector< Reference< XShape > > aShapes( nCount );
     588             : 
     589           0 :         ::comphelper::UnoInterfaceToUniqueIdentifierMapper& rIdMapper = GetSdImport().getInterfaceToIdentifierMapper();
     590           0 :         SvXMLTokenEnumerator aEnumerator( msNavOrder );
     591           0 :         OUString sId;
     592           0 :         for( nIndex = 0; nIndex < nCount; ++nIndex )
     593             :         {
     594           0 :             if( !aEnumerator.getNextToken(sId) )
     595           0 :                 break;
     596             : 
     597           0 :             aShapes[nIndex] = Reference< XShape >( rIdMapper.getReference( sId ), UNO_QUERY );
     598             :         }
     599             : 
     600           0 :         for( nIndex = 0; nIndex < nCount; ++nIndex )
     601             :         {
     602           0 :             if( !aShapes[nIndex].is() )
     603             :             {
     604             :                 OSL_FAIL("xmloff::SdXMLGenericPageContext::SetNavigationOrder(), draw:nav-order attribute incomplete!");
     605             :                 // todo: warning?
     606         120 :                 return;
     607             :             }
     608             :         }
     609             : 
     610           0 :         Reference< XPropertySet > xSet( mxShapes, UNO_QUERY_THROW );
     611           0 :         xSet->setPropertyValue("NavigationOrder", Any( Reference< XIndexAccess >( new XoNavigationOrderAccess( aShapes ) ) ) );
     612             :     }
     613           0 :     catch(const uno::Exception&)
     614             :     {
     615             :         OSL_FAIL("xmloff::SdXMLGenericPageContext::SetNavigationOrder(), unexpected exception cought while importing shape navigation order!");
     616             :     }
     617             : }
     618             : 
     619             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10