LCOV - code coverage report
Current view: top level - sc/source/filter/xml - xmlannoi.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 83 0.0 %
Date: 2014-04-14 Functions: 0 11 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 "xmlannoi.hxx"
      21             : #include "xmlimprt.hxx"
      22             : #include "xmlconti.hxx"
      23             : #include "XMLTableShapeImportHelper.hxx"
      24             : 
      25             : #include <xmloff/xmltkmap.hxx>
      26             : #include <xmloff/nmspmap.hxx>
      27             : #include <xmloff/xmlnmspe.hxx>
      28             : #include <xmloff/xmltoken.hxx>
      29             : 
      30             : using namespace com::sun::star;
      31             : using namespace xmloff::token;
      32             : 
      33           0 : ScXMLAnnotationData::ScXMLAnnotationData() :
      34             :     mbUseShapePos( false ),
      35           0 :     mbShown( false )
      36             : {
      37           0 : }
      38             : 
      39           0 : ScXMLAnnotationData::~ScXMLAnnotationData()
      40             : {
      41           0 : }
      42             : 
      43           0 : ScXMLAnnotationContext::ScXMLAnnotationContext( ScXMLImport& rImport,
      44             :                                       sal_uInt16 nPrfx,
      45             :                                       const OUString& rLName,
      46             :                                       const uno::Reference<xml::sax::XAttributeList>& xAttrList,
      47             :                                       ScXMLAnnotationData& rAnnotationData,
      48             :                                       ScXMLTableRowCellContext* pTempCellContext) :
      49             :     SvXMLImportContext( rImport, nPrfx, rLName ),
      50             :     mrAnnotationData( rAnnotationData ),
      51             :     pCellContext(pTempCellContext),
      52           0 :     pShapeContext(NULL)
      53             : {
      54           0 :     uno::Reference<drawing::XShapes> xLocalShapes (GetScImport().GetTables().GetCurrentXShapes());
      55           0 :     if (xLocalShapes.is())
      56             :     {
      57           0 :         XMLTableShapeImportHelper* pTableShapeImport = (XMLTableShapeImportHelper*)GetScImport().GetShapeImport().get();
      58           0 :         pTableShapeImport->SetAnnotation(this);
      59           0 :         pShapeContext = GetScImport().GetShapeImport()->CreateGroupChildContext(
      60           0 :             GetScImport(), nPrfx, rLName, xAttrList, xLocalShapes, true);
      61             :     }
      62             : 
      63           0 :     pCellContext = pTempCellContext;
      64           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
      65           0 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableAnnotationAttrTokenMap();
      66           0 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
      67             :     {
      68           0 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
      69           0 :         OUString aLocalName;
      70           0 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
      71           0 :                                             sAttrName, &aLocalName );
      72           0 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
      73             : 
      74           0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
      75             :         {
      76             :             case XML_TOK_TABLE_ANNOTATION_ATTR_AUTHOR:
      77             :             {
      78           0 :                 maAuthorBuffer = sValue;
      79             :             }
      80           0 :             break;
      81             :             case XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE:
      82             :             {
      83           0 :                 maCreateDateBuffer = sValue;
      84             :             }
      85           0 :             break;
      86             :             case XML_TOK_TABLE_ANNOTATION_ATTR_CREATE_DATE_STRING:
      87             :             {
      88           0 :                 maCreateDateStringBuffer = sValue;
      89             :             }
      90           0 :             break;
      91             :             case XML_TOK_TABLE_ANNOTATION_ATTR_DISPLAY:
      92             :             {
      93           0 :                 mrAnnotationData.mbShown = IsXMLToken(sValue, XML_TRUE);
      94             :             }
      95           0 :             break;
      96             :             case XML_TOK_TABLE_ANNOTATION_ATTR_X:
      97             :             {
      98           0 :                 mrAnnotationData.mbUseShapePos = true;
      99             :             }
     100           0 :             break;
     101             :             case XML_TOK_TABLE_ANNOTATION_ATTR_Y:
     102             :             {
     103           0 :                 mrAnnotationData.mbUseShapePos = true;
     104             :             }
     105           0 :             break;
     106             :         }
     107           0 :     }
     108           0 : }
     109             : 
     110           0 : ScXMLAnnotationContext::~ScXMLAnnotationContext()
     111             : {
     112           0 : }
     113             : 
     114           0 : void ScXMLAnnotationContext::StartElement(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList)
     115             : {
     116           0 :     if (pShapeContext)
     117           0 :         pShapeContext->StartElement(xAttrList);
     118           0 : }
     119             : 
     120           0 : SvXMLImportContext *ScXMLAnnotationContext::CreateChildContext( sal_uInt16 nPrefix,
     121             :                                             const OUString& rLName,
     122             :                                             const ::com::sun::star::uno::Reference<
     123             :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
     124             : {
     125           0 :     SvXMLImportContext *pContext = 0;
     126             : 
     127           0 :     if( XML_NAMESPACE_DC == nPrefix )
     128             :     {
     129           0 :         if( IsXMLToken( rLName, XML_CREATOR ) )
     130             :             pContext = new ScXMLContentContext(GetScImport(), nPrefix,
     131           0 :                                             rLName, xAttrList, maAuthorBuffer);
     132           0 :         else if( IsXMLToken( rLName, XML_DATE ) )
     133             :             pContext = new ScXMLContentContext(GetScImport(), nPrefix,
     134           0 :                                             rLName, xAttrList, maCreateDateBuffer);
     135             :     }
     136           0 :     else if( XML_NAMESPACE_META == nPrefix )
     137             :     {
     138           0 :         if( IsXMLToken( rLName, XML_DATE_STRING ) )
     139             :             pContext = new ScXMLContentContext(GetScImport(), nPrefix,
     140           0 :                                             rLName, xAttrList, maCreateDateStringBuffer);
     141             :     }
     142             : 
     143           0 :     if( !pContext && pShapeContext )
     144           0 :         pContext = pShapeContext->CreateChildContext(nPrefix, rLName, xAttrList);
     145             : 
     146           0 :     if( !pContext )
     147           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     148             : 
     149           0 :     return pContext;
     150             : }
     151             : 
     152           0 : void ScXMLAnnotationContext::Characters( const OUString& rChars )
     153             : {
     154           0 :     maTextBuffer.append(rChars);
     155           0 : }
     156             : 
     157           0 : void ScXMLAnnotationContext::EndElement()
     158             : {
     159           0 :     if (pShapeContext)
     160             :     {
     161           0 :         pShapeContext->EndElement();
     162           0 :         delete pShapeContext;
     163           0 :         pShapeContext = NULL;
     164             :     }
     165             : 
     166           0 :     mrAnnotationData.maAuthor = maAuthorBuffer.makeStringAndClear();
     167           0 :     mrAnnotationData.maCreateDate = maCreateDateBuffer.makeStringAndClear();
     168           0 :     if (mrAnnotationData.maCreateDate.isEmpty())
     169           0 :         mrAnnotationData.maCreateDate = maCreateDateStringBuffer.makeStringAndClear();
     170           0 :     mrAnnotationData.maSimpleText = maTextBuffer.makeStringAndClear();
     171             : 
     172           0 :     XMLTableShapeImportHelper* pTableShapeImport = (XMLTableShapeImportHelper*)GetScImport().GetShapeImport().get();
     173           0 :     pTableShapeImport->SetAnnotation(NULL);
     174           0 : }
     175             : 
     176           0 : void ScXMLAnnotationContext::SetShape( const uno::Reference< drawing::XShape >& rxShape, const uno::Reference< drawing::XShapes >& rxShapes,
     177             :                                        const OUString& rStyleName, const OUString& rTextStyle )
     178             : {
     179           0 :     mrAnnotationData.mxShape = rxShape;
     180           0 :     mrAnnotationData.mxShapes = rxShapes;
     181           0 :     mrAnnotationData.maStyleName = rStyleName;
     182           0 :     mrAnnotationData.maTextStyle = rTextStyle;
     183           0 : }
     184             : 
     185           0 : void ScXMLAnnotationContext::AddContentStyle( sal_uInt16 nFamily, const OUString& rName, const ESelection& rSelection )
     186             : {
     187           0 :     mrAnnotationData.maContentStyles.push_back( ScXMLAnnotationStyleEntry( nFamily, rName, rSelection ) );
     188           0 : }
     189             : 
     190             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10