LCOV - code coverage report
Current view: top level - writerfilter/source/ooxml - OOXMLParserState.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 120 120 100.0 %
Date: 2015-06-13 12:38:46 Functions: 29 29 100.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 <stdio.h>
      21             : #include <iostream>
      22             : #include "OOXMLParserState.hxx"
      23             : 
      24             : namespace writerfilter {
      25             : namespace ooxml
      26             : {
      27             : /*
      28             :   class OOXMLParserState
      29             : */
      30             : 
      31       10530 : OOXMLParserState::OOXMLParserState() :
      32             :     mbInSectionGroup(false),
      33             :     mbInParagraphGroup(false),
      34             :     mbInCharacterGroup(false),
      35             :     mbLastParagraphInSection(false),
      36             :     mbForwardEvents(true),
      37             :     mnContexts(0),
      38             :     mnHandle(0),
      39             :     mpDocument(nullptr),
      40             :     inTxbxContent(false),
      41             :     savedInParagraphGroup(false),
      42             :     savedInCharacterGroup(false),
      43       10530 :     savedLastParagraphInSection(false)
      44             : {
      45       10530 : }
      46             : 
      47       21060 : OOXMLParserState::~OOXMLParserState()
      48             : {
      49       21060 : }
      50             : 
      51        1874 : void OOXMLParserState::setLastParagraphInSection(bool bLastParagraphInSection)
      52             : {
      53        1874 :     mbLastParagraphInSection = bLastParagraphInSection;
      54        1874 : }
      55             : 
      56             : 
      57             : 
      58        6537 : void OOXMLParserState::setInSectionGroup(bool bInSectionGroup)
      59             : {
      60        6537 :     mbInSectionGroup = bInSectionGroup;
      61        6537 : }
      62             : 
      63             : 
      64       56820 : void OOXMLParserState::setInParagraphGroup(bool bInParagraphGroup)
      65             : {
      66       56820 :     mbInParagraphGroup = bInParagraphGroup;
      67       56820 : }
      68             : 
      69             : 
      70      136814 : void OOXMLParserState::setInCharacterGroup(bool bInCharacterGroup)
      71             : {
      72      136814 :     mbInCharacterGroup = bInCharacterGroup;
      73      136814 : }
      74             : 
      75       11534 : void OOXMLParserState::setForwardEvents(bool bForwardEvents)
      76             : {
      77       11534 :     mbForwardEvents = bForwardEvents;
      78       11534 : }
      79             : 
      80             : 
      81       28475 : const std::string OOXMLParserState::getHandle() const
      82             : {
      83             :     char sBuffer[256];
      84             : 
      85       28475 :     snprintf(sBuffer, sizeof(sBuffer), "%u", mnHandle);
      86             : 
      87       28475 :     return sBuffer;
      88             : }
      89             : 
      90       26661 : void OOXMLParserState::setHandle()
      91             : {
      92       26661 :     mnHandle = mnContexts;
      93       26661 : }
      94             : 
      95       10530 : void OOXMLParserState::setDocument(OOXMLDocumentImpl* pDocument)
      96             : {
      97       10530 :     mpDocument = pDocument;
      98       10530 : }
      99             : 
     100             : 
     101       10574 : void OOXMLParserState::setXNoteId(const sal_Int32 nId)
     102             : {
     103       10574 :     mpDocument->setXNoteId(nId);
     104       10574 : }
     105             : 
     106         502 : sal_Int32 OOXMLParserState::getXNoteId() const
     107             : {
     108         502 :     return mpDocument->getXNoteId();
     109             : }
     110             : 
     111        1702 : const OUString & OOXMLParserState::getTarget() const
     112             : {
     113        1702 :     return mpDocument->getTarget();
     114             : }
     115             : 
     116       68408 : void OOXMLParserState::resolveCharacterProperties(Stream & rStream)
     117             : {
     118       68408 :     if (mpCharacterProps.get() != nullptr)
     119             :     {
     120       23358 :         rStream.props(mpCharacterProps);
     121       23358 :         mpCharacterProps.reset(new OOXMLPropertySetImpl());
     122             :     }
     123       68408 : }
     124             : 
     125        1441 : void OOXMLParserState::setCharacterProperties(OOXMLPropertySet::Pointer_t pProps)
     126             : {
     127        1441 :     if (mpCharacterProps.get() == nullptr)
     128         392 :         mpCharacterProps = pProps;
     129             :     else
     130        1049 :         mpCharacterProps->add(pProps);
     131        1441 : }
     132             : 
     133        7945 : void OOXMLParserState::setCellProperties(OOXMLPropertySet::Pointer_t pProps)
     134             : {
     135        7945 :     if (!mCellProps.empty())
     136             :     {
     137        7945 :         OOXMLPropertySet::Pointer_t & rCellProps = mCellProps.top();
     138             : 
     139        7945 :         if (rCellProps.get() == nullptr)
     140         537 :             rCellProps = pProps;
     141             :         else
     142        7408 :             rCellProps->add(pProps);
     143             :     }
     144        7945 : }
     145             : 
     146        2302 : void OOXMLParserState::setRowProperties(OOXMLPropertySet::Pointer_t pProps)
     147             : {
     148        2302 :     if (!mRowProps.empty())
     149             :     {
     150        2302 :         OOXMLPropertySet::Pointer_t & rRowProps = mRowProps.top();
     151             : 
     152        2302 :         if (rRowProps.get() == nullptr)
     153         359 :             rRowProps = pProps;
     154             :         else
     155        1943 :             rRowProps->add(pProps);
     156             :     }
     157        2302 : }
     158             : 
     159        7971 : void OOXMLParserState::resolveCellProperties(Stream & rStream)
     160             : {
     161        7971 :     if (!mCellProps.empty())
     162             :     {
     163        7971 :         OOXMLPropertySet::Pointer_t & rCellProps = mCellProps.top();
     164             : 
     165        7971 :         if (rCellProps.get() != nullptr)
     166             :         {
     167        7953 :             rStream.props(rCellProps);
     168        7953 :             rCellProps.reset(new OOXMLPropertySetImpl());
     169             :         }
     170             :     }
     171        7971 : }
     172             : 
     173        2840 : void OOXMLParserState::resolveRowProperties(Stream & rStream)
     174             : {
     175        2840 :     if (!mRowProps.empty())
     176             :     {
     177        2840 :         OOXMLPropertySet::Pointer_t & rRowProps = mRowProps.top();
     178             : 
     179        2840 :         if (rRowProps.get() != nullptr)
     180             :         {
     181        2345 :             rStream.props(rRowProps);
     182        2345 :             rRowProps.reset(new OOXMLPropertySetImpl());
     183             :         }
     184             :     }
     185        2840 : }
     186             : 
     187        2840 : void OOXMLParserState::resolveTableProperties(Stream & rStream)
     188             : {
     189        2840 :     if (!mTableProps.empty())
     190             :     {
     191        2840 :         OOXMLPropertySet::Pointer_t & rTableProps = mTableProps.top();
     192             : 
     193        2840 :         if (rTableProps.get() != nullptr)
     194             :         {
     195        2840 :             rStream.props(rTableProps);
     196             :             // Don't clean the table props to send them again for each row
     197             :             // This mimics the behaviour from RTF tokenizer.
     198             :         }
     199             :     }
     200        2840 : }
     201             : 
     202        1614 : void OOXMLParserState::setTableProperties(OOXMLPropertySet::Pointer_t pProps)
     203             : {
     204        1614 :     if (!mTableProps.empty())
     205             :     {
     206        1132 :         OOXMLPropertySet::Pointer_t & rTableProps = mTableProps.top();
     207        1132 :         if (rTableProps.get() == nullptr)
     208         539 :             rTableProps = pProps;
     209             :         else
     210         593 :             rTableProps->add(pProps);
     211             :     }
     212        1614 : }
     213             : 
     214         539 : void OOXMLParserState::startTable()
     215             : {
     216         539 :     OOXMLPropertySet::Pointer_t pCellProps;
     217        1078 :     OOXMLPropertySet::Pointer_t pRowProps;
     218        1078 :     OOXMLPropertySet::Pointer_t pTableProps;
     219             : 
     220         539 :     mCellProps.push(pCellProps);
     221         539 :     mRowProps.push(pRowProps);
     222        1078 :     mTableProps.push(pTableProps);
     223         539 : }
     224             : 
     225         539 : void OOXMLParserState::endTable()
     226             : {
     227         539 :     mCellProps.pop();
     228         539 :     mRowProps.pop();
     229         539 :     mTableProps.pop();
     230         539 : }
     231             : 
     232     2025968 : void OOXMLParserState::incContextCount()
     233             : {
     234     2025968 :     mnContexts++;
     235     2025968 : }
     236             : 
     237         518 : void OOXMLParserState::startTxbxContent()
     238             : {
     239             :     SAL_WARN_IF(inTxbxContent, "writerfilter", "Nested w:txbxContent");
     240             : 
     241         518 :     inTxbxContent = true;
     242             :     // Do not save and reset section group state, it'd cause a new page.
     243             : //    savedInSectionGroup = mbInSectionGroup;
     244         518 :     savedInParagraphGroup = mbInParagraphGroup;
     245         518 :     savedInCharacterGroup = mbInCharacterGroup;
     246         518 :     savedLastParagraphInSection = mbLastParagraphInSection;
     247             : //    mbInSectionGroup = false;
     248         518 :     mbInParagraphGroup = false;
     249         518 :     mbInCharacterGroup = false;
     250         518 :     mbLastParagraphInSection = false;
     251         518 : }
     252             : 
     253         518 : void OOXMLParserState::endTxbxContent()
     254             : {
     255         518 :     if( !inTxbxContent )
     256             :     {
     257             :         SAL_WARN( "writerfilter", "Non-matching closing w:txbxContent" );
     258         519 :         return;
     259             :     }
     260             : //    mbInSectionGroup = savedInSectionGroup;
     261         517 :     mbInParagraphGroup = savedInParagraphGroup;
     262         517 :     mbInCharacterGroup = savedInCharacterGroup;
     263         517 :     mbLastParagraphInSection = savedLastParagraphInSection;
     264         517 :     inTxbxContent = false;
     265             : }
     266             : 
     267          72 : }}
     268             : 
     269             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11