LCOV - code coverage report
Current view: top level - xmloff/source/text - txtsecte.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 71 0.0 %
Date: 2014-04-14 Functions: 0 3 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             : 
      21             : #include <xmloff/txtparae.hxx>
      22             : #include <rtl/ustring.hxx>
      23             : #include <rtl/ustrbuf.hxx>
      24             : 
      25             : #include <vector>
      26             : 
      27             : 
      28             : #include <com/sun/star/lang/XServiceInfo.hpp>
      29             : #include <com/sun/star/container/XIndexReplace.hpp>
      30             : 
      31             : #include <com/sun/star/beans/XPropertySet.hpp>
      32             : #include <com/sun/star/beans/PropertyValue.hpp>
      33             : #include <com/sun/star/beans/PropertyValues.hpp>
      34             : #include <com/sun/star/beans/PropertyState.hpp>
      35             : #include <com/sun/star/text/XText.hpp>
      36             : #include <com/sun/star/text/XTextSection.hpp>
      37             : #include <com/sun/star/text/SectionFileLink.hpp>
      38             : #include <com/sun/star/container/XNamed.hpp>
      39             : #include <com/sun/star/text/XDocumentIndex.hpp>
      40             : #include <xmloff/xmlnmspe.hxx>
      41             : #include <xmloff/families.hxx>
      42             : #include <xmloff/xmluconv.hxx>
      43             : #include <xmloff/nmspmap.hxx>
      44             : #include <xmloff/xmlexp.hxx>
      45             : #include <xmloff/xmltkmap.hxx>
      46             : #include "XMLTextNumRuleInfo.hxx"
      47             : #include "XMLSectionExport.hxx"
      48             : #include "XMLRedlineExport.hxx"
      49             : #include "MultiPropertySetHelper.hxx"
      50             : 
      51             : using namespace ::com::sun::star;
      52             : using namespace ::com::sun::star::text;
      53             : using namespace ::com::sun::star::uno;
      54             : using namespace ::std;
      55             : 
      56             : using ::com::sun::star::beans::XPropertySet;
      57             : using ::com::sun::star::beans::PropertyValue;
      58             : using ::com::sun::star::beans::PropertyValues;
      59             : using ::com::sun::star::beans::PropertyState;
      60             : using ::com::sun::star::container::XIndexReplace;
      61             : using ::com::sun::star::container::XNamed;
      62             : using ::com::sun::star::lang::XServiceInfo;
      63             : 
      64           0 : void XMLTextParagraphExport::exportListAndSectionChange(
      65             :     Reference<XTextSection> & rPrevSection,
      66             :     const Reference<XTextContent> & rNextSectionContent,
      67             :     const XMLTextNumRuleInfo& rPrevRule,
      68             :     const XMLTextNumRuleInfo& rNextRule,
      69             :     bool bAutoStyles)
      70             : {
      71           0 :     Reference<XTextSection> xNextSection;
      72             : 
      73             :     // first: get current XTextSection
      74           0 :     Reference<XPropertySet> xPropSet(rNextSectionContent, UNO_QUERY);
      75           0 :     if (xPropSet.is())
      76             :     {
      77           0 :         if (xPropSet->getPropertySetInfo()->hasPropertyByName(sTextSection))
      78             :         {
      79           0 :             xPropSet->getPropertyValue(sTextSection) >>= xNextSection;
      80             :         }
      81             :         // else: no current section
      82             :     }
      83             : 
      84             :     exportListAndSectionChange(rPrevSection, xNextSection,
      85           0 :                                rPrevRule, rNextRule, bAutoStyles);
      86           0 : }
      87             : 
      88           0 : void XMLTextParagraphExport::exportListAndSectionChange(
      89             :     Reference<XTextSection> & rPrevSection,
      90             :     MultiPropertySetHelper& rPropSetHelper,
      91             :     sal_Int16 nTextSectionId,
      92             :     const Reference<XTextContent> & rNextSectionContent,
      93             :     const XMLTextNumRuleInfo& rPrevRule,
      94             :     const XMLTextNumRuleInfo& rNextRule,
      95             :     bool bAutoStyles)
      96             : {
      97           0 :     Reference<XTextSection> xNextSection;
      98             : 
      99             :     // first: get current XTextSection
     100           0 :     Reference<XPropertySet> xPropSet(rNextSectionContent, UNO_QUERY);
     101           0 :     if (xPropSet.is())
     102             :     {
     103           0 :         if( !rPropSetHelper.checkedProperties() )
     104           0 :             rPropSetHelper.hasProperties( xPropSet->getPropertySetInfo() );
     105           0 :         if( rPropSetHelper.hasProperty( nTextSectionId ))
     106             :         {
     107             :             xNextSection.set(rPropSetHelper.getValue( nTextSectionId , xPropSet,
     108           0 :                 true ), uno::UNO_QUERY);
     109             :         }
     110             :         // else: no current section
     111             :     }
     112             : 
     113             :     exportListAndSectionChange(rPrevSection, xNextSection,
     114           0 :                                rPrevRule, rNextRule, bAutoStyles);
     115           0 : }
     116             : 
     117           0 : void XMLTextParagraphExport::exportListAndSectionChange(
     118             :     Reference<XTextSection> & rPrevSection,
     119             :     const Reference<XTextSection> & rNextSection,
     120             :     const XMLTextNumRuleInfo& rPrevRule,
     121             :     const XMLTextNumRuleInfo& rNextRule,
     122             :     bool bAutoStyles)
     123             : {
     124             :     // old != new? -> maybe we have to start or end a new section
     125           0 :     if (rPrevSection != rNextSection)
     126             :     {
     127             :         // a new section started, or an old one gets closed!
     128             : 
     129             :         // close old list
     130           0 :         XMLTextNumRuleInfo aEmptyNumRuleInfo;
     131           0 :         if ( !bAutoStyles )
     132           0 :             exportListChange(rPrevRule, aEmptyNumRuleInfo);
     133             : 
     134             :         // Build stacks of old and new sections
     135             :         // Sections on top of mute sections should not be on the stack
     136           0 :         vector< Reference<XTextSection> > aOldStack;
     137           0 :         Reference<XTextSection> aCurrent(rPrevSection);
     138           0 :         while(aCurrent.is())
     139             :         {
     140             :             // if we have a mute section, ignore all its children
     141             :             // (all previous ones)
     142           0 :             if (pSectionExport->IsMuteSection(aCurrent))
     143           0 :                 aOldStack.clear();
     144             : 
     145           0 :             aOldStack.push_back(aCurrent);
     146           0 :             aCurrent.set(aCurrent->getParentSection());
     147             :         }
     148             : 
     149           0 :         vector< Reference<XTextSection> > aNewStack;
     150           0 :         aCurrent.set(rNextSection);
     151           0 :         sal_Bool bMute = sal_False;
     152           0 :         while(aCurrent.is())
     153             :         {
     154             :             // if we have a mute section, ignore all its children
     155             :             // (all previous ones)
     156           0 :             if (pSectionExport->IsMuteSection(aCurrent))
     157             :             {
     158           0 :                 aNewStack.clear();
     159           0 :                 bMute = sal_True;
     160             :             }
     161             : 
     162           0 :             aNewStack.push_back(aCurrent);
     163           0 :             aCurrent.set(aCurrent->getParentSection());
     164             :         }
     165             : 
     166             :         // compare the two stacks
     167             :         vector<Reference<XTextSection> > ::reverse_iterator aOld =
     168           0 :             aOldStack.rbegin();
     169             :         vector<Reference<XTextSection> > ::reverse_iterator aNew =
     170           0 :             aNewStack.rbegin();
     171             :         // compare bottom sections and skip equal section
     172           0 :         while ( (aOld != aOldStack.rend()) &&
     173           0 :                 (aNew != aNewStack.rend()) &&
     174           0 :                 (*aOld) == (*aNew) )
     175             :         {
     176           0 :             ++aOld;
     177           0 :             ++aNew;
     178             :         }
     179             : 
     180             :         // close all elements of aOld ...
     181             :         // (order: newest to oldest)
     182           0 :         if (aOld != aOldStack.rend())
     183             :         {
     184             :             vector<Reference<XTextSection> > ::iterator aOldForward(
     185           0 :                 aOldStack.begin());
     186           0 :             while ((aOldForward != aOldStack.end()) &&
     187           0 :                    (*aOldForward != *aOld))
     188             :             {
     189           0 :                 if ( !bAutoStyles && (NULL != pRedlineExport) )
     190           0 :                     pRedlineExport->ExportStartOrEndRedline(*aOldForward,
     191           0 :                                                                 sal_False);
     192           0 :                 pSectionExport->ExportSectionEnd(*aOldForward, bAutoStyles);
     193           0 :                 ++aOldForward;
     194             :             }
     195           0 :             if (aOldForward != aOldStack.end())
     196             :             {
     197           0 :                 if ( !bAutoStyles && (NULL != pRedlineExport) )
     198           0 :                     pRedlineExport->ExportStartOrEndRedline(*aOldForward,
     199           0 :                                                             sal_False);
     200           0 :                 pSectionExport->ExportSectionEnd(*aOldForward, bAutoStyles);
     201             :             }
     202             :         }
     203             : 
     204             :         // ...then open all of aNew
     205             :         // (order: oldest to newest)
     206           0 :         while (aNew != aNewStack.rend())
     207             :         {
     208           0 :             if ( !bAutoStyles && (NULL != pRedlineExport) )
     209           0 :                 pRedlineExport->ExportStartOrEndRedline(*aNew, sal_True);
     210           0 :             pSectionExport->ExportSectionStart(*aNew, bAutoStyles);
     211           0 :             ++aNew;
     212             :         }
     213             : 
     214             :         // start new list
     215           0 :         if ( !bAutoStyles && !bMute )
     216           0 :             exportListChange(aEmptyNumRuleInfo, rNextRule);
     217             :     }
     218             :     else
     219             :     {
     220             :         // list change, if sections have not changed
     221           0 :         if ( !bAutoStyles )
     222           0 :             exportListChange(rPrevRule, rNextRule);
     223             :     }
     224             : 
     225             :     // save old section (old numRule gets saved in calling method)
     226           0 :     rPrevSection.set(rNextSection);
     227           0 : }
     228             : 
     229             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10