LCOV - code coverage report
Current view: top level - sc/source/filter/xml - xmlstyli.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 390 521 74.9 %
Date: 2014-04-11 Functions: 53 71 74.6 %
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 "xmlstyli.hxx"
      21             : #include <xmloff/nmspmap.hxx>
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include <xmloff/xmlimppr.hxx>
      24             : #include <xmloff/families.hxx>
      25             : #include <xmloff/xmlnumfi.hxx>
      26             : #include <xmloff/XMLGraphicsDefaultStyle.hxx>
      27             : #include <xmloff/xmltoken.hxx>
      28             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      29             : #include <com/sun/star/container/XNameContainer.hpp>
      30             : #include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
      31             : #include <com/sun/star/table/BorderLine2.hpp>
      32             : #include <comphelper/extract.hxx>
      33             : #include <xmloff/xmlprcon.hxx>
      34             : #include <xmloff/xmluconv.hxx>
      35             : #include "XMLTableHeaderFooterContext.hxx"
      36             : #include "XMLConverter.hxx"
      37             : #include "XMLTableShapeImportHelper.hxx"
      38             : #include "sheetdata.hxx"
      39             : #include "xmlannoi.hxx"
      40             : #include "textuno.hxx"
      41             : #include "cellsuno.hxx"
      42             : 
      43             : #include "docuno.hxx"
      44             : #include "unonames.hxx"
      45             : #include "document.hxx"
      46             : #include "conditio.hxx"
      47             : #include "svl/intitem.hxx"
      48             : #include "rangelst.hxx"
      49             : #include "rangeutl.hxx"
      50             : #include "docfunc.hxx"
      51             : #include "markdata.hxx"
      52             : #include "docpool.hxx"
      53             : #include "scitems.hxx"
      54             : #include "patattr.hxx"
      55             : 
      56             : #define XML_LINE_LEFT 0
      57             : #define XML_LINE_RIGHT 1
      58             : #define XML_LINE_TOP 2
      59             : #define XML_LINE_BOTTOM 3
      60             : 
      61             : #define XML_LINE_TLBR 0
      62             : #define XML_LINE_BLTR 1
      63             : 
      64             : using namespace ::com::sun::star;
      65             : using namespace ::com::sun::star::xml::sax;
      66             : using namespace ::com::sun::star::style;
      67             : using namespace ::com::sun::star::frame;
      68             : using namespace ::com::sun::star::beans;
      69             : using namespace ::com::sun::star::container;
      70             : using namespace xmloff::token;
      71             : using namespace ::formula;
      72             : 
      73             : using com::sun::star::uno::Reference;
      74             : using com::sun::star::uno::UNO_QUERY;
      75             : 
      76         142 : ScXMLCellImportPropertyMapper::ScXMLCellImportPropertyMapper(
      77             :         const UniReference< XMLPropertySetMapper >& rMapper,
      78             :         SvXMLImport& rImportP) :
      79         142 :     SvXMLImportPropertyMapper( rMapper, rImportP )
      80             : {
      81         142 : }
      82             : 
      83         284 : ScXMLCellImportPropertyMapper::~ScXMLCellImportPropertyMapper()
      84             : {
      85         284 : }
      86             : 
      87        1284 : void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const
      88             : {
      89             :     static const sal_Int16 aPaddingCTF[4] = { CTF_SC_LEFTPADDING, CTF_SC_RIGHTPADDING,
      90             :                                             CTF_SC_TOPPADDING, CTF_SC_BOTTOMPADDING };
      91             :     static const sal_Int16 aBorderCTF[4] = { CTF_SC_LEFTBORDER, CTF_SC_RIGHTBORDER,
      92             :                                             CTF_SC_TOPBORDER, CTF_SC_BOTTOMBORDER };
      93             : 
      94        1284 :     SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex);
      95        1284 :     XMLPropertyState* pAllPaddingProperty(NULL);
      96        1284 :     XMLPropertyState* pPadding[4] = { NULL, NULL, NULL, NULL };
      97        1284 :     XMLPropertyState* pNewPadding[4] = { NULL, NULL, NULL, NULL };
      98        1284 :     XMLPropertyState* pAllBorderProperty = NULL;
      99        1284 :     XMLPropertyState* pBorders[4] = { NULL, NULL, NULL, NULL };
     100        1284 :     XMLPropertyState* pNewBorders[4] = { NULL, NULL, NULL, NULL };
     101        1284 :     XMLPropertyState* pAllBorderWidthProperty = NULL;
     102        1284 :     XMLPropertyState* pBorderWidths[4] = { NULL, NULL, NULL, NULL };
     103        1284 :     XMLPropertyState* pDiagBorders[2] = { 0 };
     104        1284 :     XMLPropertyState* pOldDiagBorderWidths[2] = { 0 };      // old attribute names without "s"
     105        1284 :     XMLPropertyState* pDiagBorderWidths[2] = { 0 };
     106             : 
     107        1284 :     ::std::vector< XMLPropertyState >::iterator endproperty(rProperties.end());
     108        9478 :     for (::std::vector< XMLPropertyState >::iterator aIter =  rProperties.begin();
     109             :         aIter != endproperty; ++aIter)
     110             :     {
     111        8194 :         XMLPropertyState*property = &(*aIter);
     112        8194 :         if (property->mnIndex != -1)
     113             :         {
     114        8136 :             sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex);
     115        8136 :             switch (nContextID)
     116             :             {
     117          11 :                 case CTF_SC_ALLPADDING                  : pAllPaddingProperty = &*property; break;
     118          39 :                 case CTF_SC_LEFTPADDING                 : pPadding[XML_LINE_LEFT] = &*property; break;
     119          39 :                 case CTF_SC_RIGHTPADDING                : pPadding[XML_LINE_RIGHT] = &*property; break;
     120          39 :                 case CTF_SC_TOPPADDING                  : pPadding[XML_LINE_TOP] = &*property; break;
     121          39 :                 case CTF_SC_BOTTOMPADDING               : pPadding[XML_LINE_BOTTOM] = &*property; break;
     122          56 :                 case CTF_SC_ALLBORDER                   : pAllBorderProperty = &*property; break;
     123         166 :                 case CTF_SC_LEFTBORDER                  : pBorders[XML_LINE_LEFT] = &*property; break;
     124         166 :                 case CTF_SC_RIGHTBORDER                 : pBorders[XML_LINE_RIGHT] = &*property; break;
     125         166 :                 case CTF_SC_TOPBORDER                   : pBorders[XML_LINE_TOP] = &*property; break;
     126         166 :                 case CTF_SC_BOTTOMBORDER                : pBorders[XML_LINE_BOTTOM] = &*property; break;
     127          12 :                 case CTF_SC_ALLBORDERWIDTH              : pAllBorderWidthProperty = &*property; break;
     128           0 :                 case CTF_SC_LEFTBORDERWIDTH             : pBorderWidths[XML_LINE_LEFT] = &*property; break;
     129           0 :                 case CTF_SC_RIGHTBORDERWIDTH            : pBorderWidths[XML_LINE_RIGHT] = &*property; break;
     130           0 :                 case CTF_SC_TOPBORDERWIDTH              : pBorderWidths[XML_LINE_TOP] = &*property; break;
     131           0 :                 case CTF_SC_BOTTOMBORDERWIDTH           : pBorderWidths[XML_LINE_BOTTOM] = &*property; break;
     132          45 :                 case CTF_SC_DIAGONALTLBR                : pDiagBorders[XML_LINE_TLBR] = &*property; break;
     133          45 :                 case CTF_SC_DIAGONALBLTR                : pDiagBorders[XML_LINE_BLTR] = &*property; break;
     134           0 :                 case CTF_SC_DIAGONALTLBRWIDTH           : pOldDiagBorderWidths[XML_LINE_TLBR] = &*property; break;
     135           0 :                 case CTF_SC_DIAGONALTLBRWIDTHS          : pDiagBorderWidths[XML_LINE_TLBR] = &*property; break;
     136           0 :                 case CTF_SC_DIAGONALBLTRWIDTH           : pOldDiagBorderWidths[XML_LINE_BLTR] = &*property; break;
     137           0 :                 case CTF_SC_DIAGONALBLTRWIDTHS          : pDiagBorderWidths[XML_LINE_BLTR] = &*property; break;
     138             :             }
     139             :         }
     140             :     }
     141             :     sal_uInt16 i;
     142             : 
     143             :     // #i27594#; copy Value, but don't insert
     144        1284 :     if (pAllBorderWidthProperty)
     145          12 :         pAllBorderWidthProperty->mnIndex = -1;
     146        1284 :     if (pAllBorderProperty)
     147          56 :         pAllBorderProperty->mnIndex = -1;
     148        1284 :     if (pAllPaddingProperty)
     149          11 :         pAllPaddingProperty->mnIndex = -1;
     150             : 
     151        6420 :     for (i = 0; i < 4; ++i)
     152             :     {
     153        5136 :         if (pAllPaddingProperty && !pPadding[i])
     154          44 :             pNewPadding[i] = new XMLPropertyState(maPropMapper->FindEntryIndex(aPaddingCTF[i]), pAllPaddingProperty->maValue);
     155        5136 :         if (pAllBorderProperty && !pBorders[i])
     156             :         {
     157         224 :             pNewBorders[i] = new XMLPropertyState(maPropMapper->FindEntryIndex(aBorderCTF[i]), pAllBorderProperty->maValue);
     158         224 :             pBorders[i] = pNewBorders[i];
     159             :         }
     160        5136 :         if( !pBorderWidths[i] )
     161        5136 :             pBorderWidths[i] = pAllBorderWidthProperty;
     162             :         else
     163           0 :             pBorderWidths[i]->mnIndex = -1;
     164        5136 :         if( pBorders[i] )
     165             :         {
     166         888 :             table::BorderLine2 aBorderLine;
     167         888 :             pBorders[i]->maValue >>= aBorderLine;
     168         888 :             if( pBorderWidths[i] )
     169             :             {
     170             :                 // Merge style:border-line-width values to fo:border values. Do
     171             :                 // not override fo:border line width or line style with an
     172             :                 // empty value!
     173          48 :                 table::BorderLine2 aBorderLineWidth;
     174          48 :                 pBorderWidths[i]->maValue >>= aBorderLineWidth;
     175          48 :                 aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
     176          48 :                 aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
     177          48 :                 aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
     178          48 :                 pBorders[i]->maValue <<= aBorderLine;
     179             :             }
     180             :         }
     181             :     }
     182        3852 :     for( i = 0; i < 2; ++i )
     183             :     {
     184        2568 :         if( pDiagBorders[i] && ( pDiagBorderWidths[i] || pOldDiagBorderWidths[i] ) )
     185             :         {
     186           0 :             table::BorderLine2 aBorderLine;
     187           0 :             pDiagBorders[i]->maValue >>= aBorderLine;
     188           0 :             table::BorderLine2 aBorderLineWidth;
     189           0 :             if (pDiagBorderWidths[i])
     190           0 :                 pDiagBorderWidths[i]->maValue >>= aBorderLineWidth;     // prefer new attribute
     191             :             else
     192           0 :                 pOldDiagBorderWidths[i]->maValue >>= aBorderLineWidth;
     193           0 :             aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
     194           0 :             aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
     195           0 :             aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
     196           0 :             pDiagBorders[i]->maValue <<= aBorderLine;
     197           0 :             if (pDiagBorderWidths[i])
     198           0 :                 pDiagBorderWidths[i]->mnIndex = -1;
     199           0 :             if (pOldDiagBorderWidths[i])
     200           0 :                 pOldDiagBorderWidths[i]->mnIndex = -1;      // reset mnIndex for old and new attribute if both are present
     201             :         }
     202             :     }
     203             : 
     204        6420 :     for (i = 0; i < 4; ++i)
     205             :     {
     206        5136 :         if (pNewPadding[i])
     207             :         {
     208          44 :             rProperties.push_back(*pNewPadding[i]);
     209          44 :             delete pNewPadding[i];
     210             :         }
     211        5136 :         if (pNewBorders[i])
     212             :         {
     213         224 :             rProperties.push_back(*pNewBorders[i]);
     214         224 :             delete pNewBorders[i];
     215             :         }
     216             :     }
     217        1284 : }
     218             : 
     219         107 : ScXMLRowImportPropertyMapper::ScXMLRowImportPropertyMapper(
     220             :         const UniReference< XMLPropertySetMapper >& rMapper,
     221             :         SvXMLImport& rImportP) :
     222         107 :     SvXMLImportPropertyMapper( rMapper, rImportP )
     223             : {
     224         107 : }
     225             : 
     226         214 : ScXMLRowImportPropertyMapper::~ScXMLRowImportPropertyMapper()
     227             : {
     228         214 : }
     229             : 
     230         202 : void ScXMLRowImportPropertyMapper::finished(::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const
     231             : {
     232         202 :     SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex);
     233         202 :     XMLPropertyState* pHeight(NULL);
     234         202 :     XMLPropertyState* pOptimalHeight(NULL);
     235         202 :     XMLPropertyState* pPageBreak(NULL);
     236         202 :     ::std::vector< XMLPropertyState >::iterator endproperty(rProperties.end());
     237         798 :     for (::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
     238             :         aIter != endproperty; ++aIter)
     239             :     {
     240         596 :         XMLPropertyState* property = &(*aIter);
     241         596 :         if (property->mnIndex != -1)
     242             :         {
     243         596 :             sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex);
     244         596 :             switch (nContextID)
     245             :             {
     246         197 :                 case CTF_SC_ROWHEIGHT                   : pHeight = property; break;
     247         197 :                 case CTF_SC_ROWOPTIMALHEIGHT            : pOptimalHeight = property; break;
     248         202 :                 case CTF_SC_ROWBREAKBEFORE              : pPageBreak = property; break;
     249             :             }
     250             :         }
     251             :     }
     252         202 :     if (pPageBreak)
     253             :     {
     254         202 :         if(!(::cppu::any2bool(pPageBreak->maValue)))
     255         202 :             pPageBreak->mnIndex = -1;
     256             :     }
     257         202 :     if (pOptimalHeight)
     258             :     {
     259         197 :         if (::cppu::any2bool(pOptimalHeight->maValue))
     260             :         {
     261         172 :             if (pHeight)
     262             :             {
     263             :                 // set the stored height, but keep "optimal" flag:
     264             :                 // pass the height value as OptimalHeight property (only allowed while loading!)
     265         172 :                 pOptimalHeight->maValue = pHeight->maValue;
     266         172 :                 pHeight->mnIndex = -1;
     267             :             }
     268             :             else
     269           0 :                 pOptimalHeight->mnIndex = -1;
     270             :         }
     271             :     }
     272           5 :     else if (pHeight)
     273             :     {
     274           0 :         rProperties.push_back(XMLPropertyState(maPropMapper->FindEntryIndex(CTF_SC_ROWOPTIMALHEIGHT), css::uno::Any(false)));
     275             :     }
     276             :     // don't access pointers to rProperties elements after push_back!
     277         202 : }
     278             : 
     279         950 : class XMLTableCellPropsContext : public SvXMLPropertySetContext
     280             : {
     281             :     using SvXMLPropertySetContext::CreateChildContext;
     282             :     public:
     283             :         XMLTableCellPropsContext(
     284             :              SvXMLImport& rImport, sal_uInt16 nPrfx,
     285             :              const OUString& rLName,
     286             :              const uno::Reference< xml::sax::XAttributeList >& xAttrList,
     287             :              sal_uInt32 nFamily,
     288             :              ::std::vector< XMLPropertyState > &rProps,
     289             :              const UniReference < SvXMLImportPropertyMapper > &rMap);
     290             : 
     291             :         virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
     292             :             const OUString& rLocalName,
     293             :             const uno::Reference< xml::sax::XAttributeList >& xAttrList,
     294             :            ::std::vector< XMLPropertyState > &rProperties,
     295             :            const XMLPropertyState& rProp ) SAL_OVERRIDE;
     296             : };
     297             : 
     298         475 : XMLTableCellPropsContext::XMLTableCellPropsContext(
     299             :              SvXMLImport& rImport, sal_uInt16 nPrfx,
     300             :              const OUString& rLName,
     301             :              const uno::Reference< xml::sax::XAttributeList >& xAttrList,
     302             :              sal_uInt32 nFamily,
     303             :              ::std::vector< XMLPropertyState > &rProps,
     304             :              const UniReference < SvXMLImportPropertyMapper > &rMap)
     305             :           : SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFamily,
     306         475 :                rProps, rMap )
     307             : {
     308         475 : }
     309             : 
     310           0 : SvXMLImportContext* XMLTableCellPropsContext::CreateChildContext( sal_uInt16 nPrefix,
     311             :             const OUString& rLocalName,
     312             :             const uno::Reference< xml::sax::XAttributeList >& xAttrList,
     313             :            ::std::vector< XMLPropertyState > &rProperties,
     314             :            const XMLPropertyState& rProp )
     315             : {
     316             :     // no need for a custom context or indeed a SvXMLTokenMap to grab just the
     317             :     // single attribute ( href ) that we are interested in.
     318             :     // still though, we will check namesspaces etc.
     319           0 :     if ( ( XML_NAMESPACE_STYLE == nPrefix) &&
     320           0 :         IsXMLToken(rLocalName, XML_HYPERLINK ) )
     321             :     {
     322           0 :         OUString sURL;
     323           0 :         for ( int i=0; i<xAttrList->getLength(); ++i )
     324             :         {
     325           0 :             OUString aLocalName;
     326           0 :             OUString sName = xAttrList->getNameByIndex(i);
     327           0 :             sal_uInt16 nPrfx = GetImport().GetNamespaceMap().GetKeyByAttrName( sName,
     328           0 :                                                             &aLocalName );
     329           0 :             if ( nPrfx == XML_NAMESPACE_XLINK )
     330             :             {
     331           0 :                 if ( IsXMLToken( aLocalName, XML_HREF ) )
     332             :                 {
     333           0 :                     sURL = xAttrList->getValueByIndex(i);
     334           0 :                     break;
     335             :                 }
     336             :             }
     337           0 :         }
     338           0 :         if ( !sURL.isEmpty() )
     339             :         {
     340           0 :             XMLPropertyState aProp( rProp );
     341           0 :             aProp.maValue <<=  sURL;
     342           0 :             rProperties.push_back( aProp );
     343           0 :         }
     344             :     }
     345           0 :     return SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName, xAttrList, rProperties, rProp );
     346             : }
     347             : 
     348             : class ScXMLMapContext : public SvXMLImportContext
     349             : {
     350             :     OUString msApplyStyle;
     351             :     OUString msCondition;
     352             :     OUString msBaseCell;
     353             : 
     354             :     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     355          99 :     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
     356             : public:
     357             : 
     358             :     ScXMLMapContext(
     359             :             SvXMLImport& rImport, sal_uInt16 nPrfx,
     360             :             const OUString& rLName,
     361             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList );
     362             :     virtual ~ScXMLMapContext();
     363             : 
     364             :     ScCondFormatEntry* CreateConditionEntry();
     365             : };
     366             : 
     367          33 : ScXMLMapContext::ScXMLMapContext(SvXMLImport& rImport, sal_uInt16 nPrfx,
     368             :             const OUString& rLName, const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     369          33 :     : SvXMLImportContext( rImport, nPrfx, rLName )
     370             : {
     371          33 :     sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
     372         132 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     373             :     {
     374          99 :         const OUString& rAttrName(xAttrList->getNameByIndex( i ));
     375         198 :         OUString aLocalName;
     376          99 :         sal_uInt16 nPrefix(GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ));
     377         198 :         const OUString& rValue(xAttrList->getValueByIndex( i ));
     378             : 
     379             :         // TODO: use a map here
     380          99 :         if( XML_NAMESPACE_STYLE == nPrefix )
     381             :         {
     382          99 :             if( IsXMLToken(aLocalName, XML_CONDITION ) )
     383          33 :                 msCondition = rValue;
     384          66 :             else if( IsXMLToken(aLocalName, XML_APPLY_STYLE_NAME ) )
     385          33 :                 msApplyStyle = GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TABLE_CELL, rValue);
     386          33 :             else if ( IsXMLToken(aLocalName, XML_BASE_CELL_ADDRESS ) )
     387          33 :                 msBaseCell = rValue;
     388             :         }
     389          99 :     }
     390          33 : }
     391             : 
     392          33 : ScCondFormatEntry* ScXMLMapContext::CreateConditionEntry()
     393             : {
     394          66 :     OUString aCondition, aConditionNmsp;
     395          33 :     FormulaGrammar::Grammar eGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
     396          33 :     GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eGrammar, msCondition );
     397          33 :     bool bHasNmsp = aCondition.getLength() < msCondition.getLength();
     398             : 
     399             :     // parse a condition from the attribute string
     400          66 :     ScXMLConditionParseResult aParseResult;
     401          33 :     ScXMLConditionHelper::parseCondition( aParseResult, aCondition, 0 );
     402             : 
     403          33 :     if( !bHasNmsp )
     404             :     {
     405             :         // the attribute does not contain a namespace: try to find a namespace of an external grammar
     406          33 :         FormulaGrammar::Grammar eNewGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
     407          33 :         GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eNewGrammar, aCondition, true );
     408          33 :         if( eNewGrammar != FormulaGrammar::GRAM_EXTERNAL )
     409          33 :             eGrammar = eNewGrammar;
     410             :     }
     411             : 
     412          33 :     ScConditionMode eMode = ScConditionEntry::GetModeFromApi(aParseResult.meOperator);
     413          66 :     OUString aNmsp1, aNmsp2;
     414          33 :     ScDocument* pDoc = GetScImport().GetDocument();
     415             : 
     416             :     ScCondFormatEntry* pEntry =  new ScCondFormatEntry(eMode, aParseResult.maOperand1, aParseResult.maOperand2, pDoc, ScAddress(), msApplyStyle,
     417          33 :                                                     aNmsp1, aNmsp2, eGrammar, eGrammar);
     418             : 
     419          33 :     pEntry->SetSrcString(msBaseCell);
     420          66 :     return pEntry;
     421             : }
     422             : 
     423          66 : ScXMLMapContext::~ScXMLMapContext()
     424             : {
     425          66 : }
     426             : 
     427        4481 : void XMLTableStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
     428             :                                         const OUString& rLocalName,
     429             :                                         const OUString& rValue )
     430             : {
     431             :     // TODO: use a map here
     432        4481 :     if( IsXMLToken(rLocalName, XML_DATA_STYLE_NAME ) )
     433         266 :         sDataStyleName = rValue;
     434        4215 :     else if ( IsXMLToken(rLocalName, XML_MASTER_PAGE_NAME ) )
     435         111 :         sPageStyle = rValue;
     436             :     else
     437        4104 :         XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
     438        4481 : }
     439             : 
     440           0 : TYPEINIT1( XMLTableStyleContext, XMLPropStyleContext );
     441             : 
     442        1625 : XMLTableStyleContext::XMLTableStyleContext( ScXMLImport& rImport,
     443             :         sal_uInt16 nPrfx, const OUString& rLName,
     444             :         const uno::Reference< XAttributeList > & xAttrList,
     445             :         SvXMLStylesContext& rStyles, sal_uInt16 nFamily, bool bDefaultStyle ) :
     446             :     XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle ),
     447             :     sDataStyleName(),
     448             :     pStyles(&rStyles),
     449             :     nNumberFormat(-1),
     450             :     nLastSheet(-1),
     451             :     bParentSet(false),
     452             :     mpCondFormat(NULL),
     453        1625 :     mbDeleteCondFormat(true)
     454             : {
     455        1625 : }
     456             : 
     457        4875 : XMLTableStyleContext::~XMLTableStyleContext()
     458             : {
     459        1625 :     if(mbDeleteCondFormat)
     460        1625 :         delete mpCondFormat;
     461        3250 : }
     462             : 
     463        1821 : SvXMLImportContext *XMLTableStyleContext::CreateChildContext(
     464             :         sal_uInt16 nPrefix,
     465             :         const OUString& rLocalName,
     466             :         const uno::Reference< XAttributeList > & xAttrList )
     467             : {
     468        1821 :     SvXMLImportContext *pContext(NULL);
     469             : 
     470        3642 :     if( (XML_NAMESPACE_STYLE == nPrefix) &&
     471        1821 :         IsXMLToken(rLocalName, XML_MAP ) )
     472             :     {
     473          33 :         if(!mpCondFormat)
     474           9 :             mpCondFormat = new ScConditionalFormat( 0, GetScImport().GetDocument() );
     475          33 :         ScXMLMapContext* pMapContext = new ScXMLMapContext(GetImport(), nPrefix, rLocalName, xAttrList);
     476          33 :         pContext = pMapContext;
     477          33 :         mpCondFormat->AddEntry(pMapContext->CreateConditionEntry());
     478             :     }
     479        3576 :     else if ( ( XML_NAMESPACE_STYLE == nPrefix) &&
     480        1788 :         IsXMLToken(rLocalName, XML_TABLE_CELL_PROPERTIES ) )
     481             :     {
     482             :         UniReference < SvXMLImportPropertyMapper > xImpPrMap =
     483         475 :             ((SvXMLStylesContext *)GetStyles())->GetImportPropertyMapper(
     484         475 :                 GetFamily() );
     485         475 :         if( xImpPrMap.is() )
     486         475 :             pContext = new XMLTableCellPropsContext( GetImport(), nPrefix,
     487             :                 rLocalName, xAttrList,
     488             :                 XML_TYPE_PROP_TABLE_CELL,
     489         475 :                 GetProperties(),
     490         950 :                 xImpPrMap );
     491             :     }
     492             : 
     493        1821 :     if (!pContext)
     494             :         pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName,
     495        1313 :                                                            xAttrList );
     496        1821 :     return pContext;
     497             : }
     498             : 
     499         459 : void XMLTableStyleContext::ApplyCondFormat( uno::Sequence<table::CellRangeAddress> xCellRanges )
     500             : {
     501         459 :     if(!mpCondFormat || GetScImport().HasNewCondFormatData())
     502         918 :         return;
     503             : 
     504           0 :     ScRangeList aRangeList;
     505           0 :     sal_Int32 nRanges = xCellRanges.getLength();
     506           0 :     for(sal_Int32 i = 0; i < nRanges; ++i)
     507             :     {
     508           0 :         table::CellRangeAddress aAddress = xCellRanges[i];
     509           0 :         ScRange aRange( aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet, aAddress.EndColumn, aAddress.EndRow, aAddress.Sheet );
     510           0 :         aRangeList.Join( aRange, false );
     511             :     }
     512             : 
     513           0 :     ScDocument* pDoc = GetScImport().GetDocument();
     514           0 :     SCTAB nTab = GetScImport().GetTables().GetCurrentSheet();
     515           0 :     ScConditionalFormatList* pFormatList = pDoc->GetCondFormList(nTab);
     516           0 :     for(ScConditionalFormatList::iterator itr = pFormatList->begin(), itrEnd = pFormatList->end();
     517             :                     itr != itrEnd; ++itr)
     518             :     {
     519           0 :         if(itr->EqualEntries(*mpCondFormat))
     520             :         {
     521           0 :             ScRangeList& rRangeList = itr->GetRangeList();
     522           0 :             sal_uInt32 nCondId = itr->GetKey();
     523           0 :             size_t n = aRangeList.size();
     524           0 :             for(size_t i = 0; i < n; ++i)
     525             :             {
     526           0 :                 const ScRange* pRange = aRangeList[i];
     527           0 :                 rRangeList.Join(*pRange);
     528             :             }
     529             : 
     530           0 :             pDoc->AddCondFormatData( aRangeList, nTab, nCondId );
     531           0 :             return;
     532             :         }
     533             :     }
     534             : 
     535           0 :     if(mpCondFormat && mbDeleteCondFormat)
     536             :     {
     537           0 :         sal_uLong nIndex = pDoc->AddCondFormat(mpCondFormat, nTab );
     538           0 :         mpCondFormat->SetKey(nIndex);
     539           0 :         mpCondFormat->AddRange(aRangeList);
     540             : 
     541           0 :         pDoc->AddCondFormatData( aRangeList, nTab, nIndex );
     542           0 :         mbDeleteCondFormat = false;
     543           0 :     }
     544             : 
     545             : 
     546             : }
     547             : 
     548        4505 : void XMLTableStyleContext::FillPropertySet(
     549             :     const uno::Reference< XPropertySet > & rPropSet )
     550             : {
     551        4505 :     if (!IsDefaultStyle())
     552             :     {
     553        4398 :         if (GetFamily() == XML_STYLE_FAMILY_TABLE_CELL)
     554             :         {
     555        1078 :             if (!bParentSet)
     556             :             {
     557        1013 :                 AddProperty(CTF_SC_CELLSTYLE, uno::makeAny(GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TABLE_CELL, GetParentName() )));
     558        1013 :                 bParentSet = true;
     559             :             }
     560        1078 :             sal_Int32 nNumFmt = GetNumberFormat();
     561        1078 :             if (nNumFmt >= 0)
     562         292 :                 AddProperty(CTF_SC_NUMBERFORMAT, uno::makeAny(nNumFmt));
     563             :         }
     564        3320 :         else if (GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE)
     565             :         {
     566         221 :             if (!sPageStyle.isEmpty())
     567         221 :                 AddProperty(CTF_SC_MASTERPAGENAME, uno::makeAny(GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_MASTER_PAGE, sPageStyle )));
     568             :         }
     569             :     }
     570        4505 :     XMLPropStyleContext::FillPropertySet(rPropSet);
     571        4505 : }
     572             : 
     573         107 : void XMLTableStyleContext::SetDefaults()
     574             : {
     575         107 :     if ((GetFamily() == XML_STYLE_FAMILY_TABLE_CELL) && GetImport().GetModel().is())
     576             :     {
     577         107 :         uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetImport().GetModel(), uno::UNO_QUERY);
     578         107 :         if (xMultiServiceFactory.is())
     579             :         {
     580         107 :             uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance("com.sun.star.sheet.Defaults"), uno::UNO_QUERY);
     581         107 :             if (xProperties.is())
     582         107 :                 FillPropertySet(xProperties);
     583         107 :         }
     584             :     }
     585         107 : }
     586             : 
     587        1526 : void XMLTableStyleContext::AddProperty(const sal_Int16 nContextID, const uno::Any& rValue)
     588             : {
     589        1526 :     XMLPropertyState* property = FindProperty(nContextID);
     590        1526 :     if (property)
     591         137 :         property->mnIndex = -1; // #i46996# remove old property, so it isn't double
     592        1526 :     sal_Int32 nIndex(static_cast<XMLTableStylesContext *>(pStyles)->GetIndex(nContextID));
     593             :     OSL_ENSURE(nIndex != -1, "Property not found in Map");
     594        1526 :     XMLPropertyState aPropState(nIndex, rValue);
     595        1526 :     GetProperties().push_back(aPropState); // has to be insertes in a sort order later
     596        1526 : }
     597             : 
     598        1526 : XMLPropertyState* XMLTableStyleContext::FindProperty(const sal_Int16 nContextID)
     599             : {
     600        1526 :     XMLPropertyState* pRet = NULL;
     601        1526 :     UniReference < XMLPropertySetMapper > xPrMap;
     602             :     UniReference < SvXMLImportPropertyMapper > xImpPrMap =
     603        3052 :         pStyles->GetImportPropertyMapper( GetFamily() );
     604             :     OSL_ENSURE( xImpPrMap.is(), "There is the import prop mapper" );
     605        1526 :     if( xImpPrMap.is() )
     606        1526 :         xPrMap = xImpPrMap->getPropertySetMapper();
     607        1526 :     if( xPrMap.is() )
     608             :     {
     609        1526 :         ::std::vector< XMLPropertyState >::iterator endproperty(GetProperties().end());
     610        1526 :         ::std::vector< XMLPropertyState >::iterator aIter(GetProperties().begin());
     611       10418 :         while(!pRet && aIter != endproperty)
     612             :         {
     613        7366 :             XMLPropertyState* property = &(*aIter);
     614        7366 :             if (property->mnIndex != -1 && xPrMap->GetEntryContextId(property->mnIndex) == nContextID)
     615             :             {
     616         137 :                 pRet = property;
     617             :             }
     618             :             else
     619        7229 :                 ++aIter;
     620             :         }
     621             :     }
     622        3052 :     return pRet;
     623             : }
     624             : 
     625        1645 : sal_Int32 XMLTableStyleContext::GetNumberFormat()
     626             : {
     627        1645 :     if (nNumberFormat < 0 && !sDataStyleName.isEmpty())
     628             :     {
     629             :         const SvXMLNumFormatContext* pStyle = static_cast<const SvXMLNumFormatContext*>(
     630         266 :             pStyles->FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, true));
     631             : 
     632         266 :         if (!pStyle)
     633             :         {
     634           0 :             XMLTableStylesContext* pMyStyles = static_cast<XMLTableStylesContext*>(GetScImport().GetStyles());
     635           0 :             if (pMyStyles)
     636             :                 pStyle = static_cast<const SvXMLNumFormatContext*>(
     637           0 :                     pMyStyles->FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, true));
     638             :             else
     639             :             {
     640             :                 OSL_FAIL("not possible to get style");
     641             :             }
     642             :         }
     643         266 :         if (pStyle)
     644         266 :             nNumberFormat = const_cast<SvXMLNumFormatContext*>(pStyle)->GetKey();
     645             :     }
     646        1645 :     return nNumberFormat;
     647             : }
     648             : 
     649        1634 : SvXMLStyleContext *XMLTableStylesContext::CreateStyleStyleChildContext(
     650             :         sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
     651             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     652             : {
     653             :     SvXMLStyleContext *pStyle;
     654             :     // use own wrapper for text and paragraph, to record style usage
     655        1634 :     if (nFamily == XML_STYLE_FAMILY_TEXT_PARAGRAPH || nFamily == XML_STYLE_FAMILY_TEXT_TEXT)
     656          74 :         pStyle = new ScCellTextStyleContext( GetImport(), nPrefix, rLocalName,
     657          74 :                                             xAttrList, *this, nFamily );
     658             :     else
     659             :         pStyle = SvXMLStylesContext::CreateStyleStyleChildContext(
     660        1560 :                     nFamily, nPrefix, rLocalName, xAttrList );
     661             : 
     662        1634 :     if (!pStyle)
     663             :     {
     664        1518 :         switch( nFamily )
     665             :         {
     666             :         case XML_STYLE_FAMILY_TABLE_CELL:
     667             :         case XML_STYLE_FAMILY_TABLE_COLUMN:
     668             :         case XML_STYLE_FAMILY_TABLE_ROW:
     669             :         case XML_STYLE_FAMILY_TABLE_TABLE:
     670             :             pStyle = new XMLTableStyleContext( GetScImport(), nPrefix, rLocalName,
     671        1518 :                                                xAttrList, *this, nFamily );
     672        1518 :             break;
     673             :         }
     674             :     }
     675             : 
     676        1634 :     return pStyle;
     677             : }
     678             : 
     679         136 : SvXMLStyleContext *XMLTableStylesContext::CreateDefaultStyleStyleChildContext(
     680             :         sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
     681             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     682             : {
     683             :     SvXMLStyleContext *pStyle(SvXMLStylesContext::CreateDefaultStyleStyleChildContext( nFamily, nPrefix,
     684             :                                                             rLocalName,
     685         136 :                                                             xAttrList ));
     686         136 :     if (!pStyle)
     687             :     {
     688         136 :         switch( nFamily )
     689             :         {
     690             :             case XML_STYLE_FAMILY_TABLE_CELL:
     691             :                 pStyle = new XMLTableStyleContext( GetScImport(), nPrefix, rLocalName,
     692         107 :                                             xAttrList, *this, nFamily, true);
     693         107 :             break;
     694             :             case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
     695          29 :                 pStyle = new XMLGraphicsDefaultStyle( GetScImport(), nPrefix, rLocalName,
     696          29 :                                             xAttrList, *this);
     697          29 :             break;
     698             :         }
     699             :     }
     700             : 
     701         136 :     return pStyle;
     702             : }
     703             : 
     704         322 : XMLTableStylesContext::XMLTableStylesContext( SvXMLImport& rImport,
     705             :         sal_uInt16 nPrfx ,
     706             :         const OUString& rLName ,
     707             :         const uno::Reference< XAttributeList > & xAttrList,
     708             :         const bool bTempAutoStyles ) :
     709             :     SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ),
     710             :     sCellStyleServiceName( OUString( "com.sun.star.style.CellStyle" )),
     711             :     sColumnStyleServiceName( OUString( XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME )),
     712             :     sRowStyleServiceName( OUString( XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME )),
     713             :     sTableStyleServiceName( OUString( XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME )),
     714             :     nNumberFormatIndex(-1),
     715             :     nConditionalFormatIndex(-1),
     716             :     nCellStyleIndex(-1),
     717             :     nMasterPageNameIndex(-1),
     718         322 :     bAutoStyles(bTempAutoStyles)
     719             : {
     720         322 : }
     721             : 
     722         644 : XMLTableStylesContext::~XMLTableStylesContext()
     723             : {
     724         644 : }
     725             : 
     726         322 : void XMLTableStylesContext::EndElement()
     727             : {
     728         322 :     SvXMLStylesContext::EndElement();
     729         322 :     if (bAutoStyles)
     730         214 :         GetImport().GetTextImport()->SetAutoStyles( this );
     731             :     else
     732         108 :         ((ScXMLImport&)GetImport()).InsertStyles();
     733         322 : }
     734             : 
     735             : UniReference < SvXMLImportPropertyMapper >
     736       10288 :     XMLTableStylesContext::GetImportPropertyMapper(
     737             :                     sal_uInt16 nFamily ) const
     738             : {
     739       10288 :     UniReference < SvXMLImportPropertyMapper > xMapper(SvXMLStylesContext::GetImportPropertyMapper(nFamily));
     740             : 
     741       10288 :     if (!xMapper.is())
     742             :     {
     743        8809 :         switch( nFamily )
     744             :         {
     745             :             case XML_STYLE_FAMILY_TABLE_CELL:
     746             :             {
     747        4657 :                 if( !xCellImpPropMapper.is() )
     748             :                 {
     749         568 :                     ((XMLTableStylesContext *)this)->xCellImpPropMapper =
     750         568 :                         new ScXMLCellImportPropertyMapper( GetScImport().GetCellStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
     751         142 :                     xCellImpPropMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(const_cast<SvXMLImport&>(GetImport())));
     752             :                 }
     753        4657 :                 xMapper = xCellImpPropMapper;
     754             :             }
     755        4657 :             break;
     756             :             case XML_STYLE_FAMILY_TABLE_COLUMN:
     757             :             {
     758         570 :                 if( !xColumnImpPropMapper.is() )
     759         428 :                     ((XMLTableStylesContext *)this)->xColumnImpPropMapper =
     760         428 :                         new SvXMLImportPropertyMapper( GetScImport().GetColumnStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
     761         570 :                 xMapper = xColumnImpPropMapper;
     762             :             }
     763         570 :              break;
     764             :             case XML_STYLE_FAMILY_TABLE_ROW:
     765             :             {
     766        2921 :                 if( !xRowImpPropMapper.is() )
     767         428 :                     ((XMLTableStylesContext *)this)->xRowImpPropMapper =
     768         428 :                         new ScXMLRowImportPropertyMapper( GetScImport().GetRowStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
     769        2921 :                 xMapper = xRowImpPropMapper;
     770             :             }
     771        2921 :              break;
     772             :             case XML_STYLE_FAMILY_TABLE_TABLE:
     773             :             {
     774         661 :                 if( !xTableImpPropMapper.is() )
     775         428 :                     ((XMLTableStylesContext *)this)->xTableImpPropMapper =
     776         428 :                         new SvXMLImportPropertyMapper( GetScImport().GetTableStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
     777         661 :                 xMapper = xTableImpPropMapper;
     778             :             }
     779         661 :              break;
     780             :         }
     781             :     }
     782             : 
     783       10288 :     return xMapper;
     784             : }
     785             : 
     786             : uno::Reference < XNameContainer >
     787        1238 :         XMLTableStylesContext::GetStylesContainer( sal_uInt16 nFamily ) const
     788             : {
     789        1238 :     uno::Reference < XNameContainer > xStyles(SvXMLStylesContext::GetStylesContainer(nFamily));
     790        1238 :     if (!xStyles.is())
     791             :     {
     792        1238 :         OUString sName;
     793        1238 :         switch( nFamily )
     794             :         {
     795             :             case XML_STYLE_FAMILY_TABLE_TABLE:
     796             :             {
     797           0 :                 if( xTableStyles.is() )
     798           0 :                     xStyles.set(xTableStyles);
     799             :                 else
     800           0 :                     sName =
     801           0 :                         OUString( OUString( "TableStyles" ));
     802             :             }
     803           0 :             break;
     804             :             case XML_STYLE_FAMILY_TABLE_CELL:
     805             :             {
     806        1238 :                 if( xCellStyles.is() )
     807        1130 :                     xStyles.set(xCellStyles);
     808             :                 else
     809         216 :                     sName =
     810         108 :                         OUString( OUString( "CellStyles" ));
     811             :             }
     812        1238 :             break;
     813             :             case XML_STYLE_FAMILY_TABLE_COLUMN:
     814             :             {
     815           0 :                 if( xColumnStyles.is() )
     816           0 :                     xStyles.set(xColumnStyles);
     817             :                 else
     818           0 :                     sName =
     819           0 :                         OUString( OUString( "ColumnStyles" ));
     820             :             }
     821           0 :             break;
     822             :             case XML_STYLE_FAMILY_TABLE_ROW:
     823             :             {
     824           0 :                 if( xRowStyles.is() )
     825           0 :                     xStyles.set(xRowStyles);
     826             :                 else
     827           0 :                     sName =
     828           0 :                         OUString( OUString( "RowStyles" ));
     829             :             }
     830           0 :             break;
     831             :         }
     832        1238 :         if( !xStyles.is() && !sName.isEmpty() && GetScImport().GetModel().is() )
     833             :         {
     834             :             uno::Reference< XStyleFamiliesSupplier > xFamiliesSupp(
     835         108 :                                             GetScImport().GetModel(), UNO_QUERY );
     836         108 :             if (xFamiliesSupp.is())
     837             :             {
     838         108 :                 uno::Reference< XNameAccess > xFamilies(xFamiliesSupp->getStyleFamilies());
     839             : 
     840             :                 try
     841             :                 {
     842         108 :                     xStyles.set(xFamilies->getByName( sName ), uno::UNO_QUERY);
     843             :                 }
     844           0 :                 catch ( uno::Exception& )
     845             :                 {
     846             :                     // #i97680# Named table/column/row styles aren't supported, getByName will throw an exception.
     847             :                     // For better interoperability, these styles should then be handled as automatic styles.
     848             :                     // For now, NULL is returned (and the style is ignored).
     849             :                 }
     850         108 :                 switch( nFamily )
     851             :                 {
     852             :                 case XML_STYLE_FAMILY_TABLE_TABLE:
     853           0 :                     ((XMLTableStylesContext *)this)->xTableStyles.set(xStyles);
     854           0 :                     break;
     855             :                 case XML_STYLE_FAMILY_TABLE_CELL:
     856         108 :                     ((XMLTableStylesContext *)this)->xCellStyles.set(xStyles);
     857         108 :                     break;
     858             :                 case XML_STYLE_FAMILY_TABLE_COLUMN:
     859           0 :                     ((XMLTableStylesContext *)this)->xColumnStyles.set(xStyles);
     860           0 :                     break;
     861             :                 case XML_STYLE_FAMILY_TABLE_ROW:
     862           0 :                     ((XMLTableStylesContext *)this)->xRowStyles.set(xStyles);
     863           0 :                     break;
     864         108 :                 }
     865         108 :             }
     866        1238 :         }
     867             :     }
     868             : 
     869        1238 :     return xStyles;
     870             : }
     871             : 
     872          84 : OUString XMLTableStylesContext::GetServiceName( sal_uInt16 nFamily ) const
     873             : {
     874          84 :     OUString sServiceName(SvXMLStylesContext::GetServiceName(nFamily));
     875          84 :     if (sServiceName.isEmpty())
     876             :     {
     877          84 :         switch( nFamily )
     878             :         {
     879             :         case XML_STYLE_FAMILY_TABLE_COLUMN:
     880           0 :             sServiceName = sColumnStyleServiceName;
     881           0 :             break;
     882             :         case XML_STYLE_FAMILY_TABLE_ROW:
     883           0 :             sServiceName = sRowStyleServiceName;
     884           0 :             break;
     885             :         case XML_STYLE_FAMILY_TABLE_CELL:
     886          84 :             sServiceName = sCellStyleServiceName;
     887          84 :             break;
     888             :         case XML_STYLE_FAMILY_TABLE_TABLE:
     889           0 :             sServiceName = sTableStyleServiceName;
     890           0 :             break;
     891             :         }
     892             :     }
     893          84 :     return sServiceName;
     894             : }
     895             : 
     896        1526 : sal_Int32 XMLTableStylesContext::GetIndex(const sal_Int16 nContextID)
     897             : {
     898        1526 :     if (nContextID == CTF_SC_CELLSTYLE)
     899             :     {
     900        1013 :         if (nCellStyleIndex == -1)
     901             :             nCellStyleIndex =
     902         142 :                 GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID);
     903        1013 :         return nCellStyleIndex;
     904             :     }
     905         513 :     else if (nContextID == CTF_SC_NUMBERFORMAT)
     906             :     {
     907         292 :         if (nNumberFormatIndex == -1)
     908             :             nNumberFormatIndex =
     909         122 :                 GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID);
     910         292 :         return nNumberFormatIndex;
     911             :     }
     912         221 :     else if (nContextID == CTF_SC_IMPORT_MAP)
     913             :     {
     914           0 :         if (nConditionalFormatIndex == -1)
     915             :             nConditionalFormatIndex =
     916           0 :                 GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID);
     917           0 :         return nConditionalFormatIndex;
     918             :     }
     919         221 :     else if (nContextID == CTF_SC_MASTERPAGENAME)
     920             :     {
     921         221 :         if (nMasterPageNameIndex == -1)
     922             :                 nMasterPageNameIndex =
     923         107 :                 GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_TABLE)->getPropertySetMapper()->FindEntryIndex(nContextID);
     924         221 :         return nMasterPageNameIndex;
     925             :     }
     926             :     else
     927           0 :         return -1;
     928             : }
     929             : 
     930             : 
     931           0 : TYPEINIT1( ScXMLMasterStylesContext, SvXMLStylesContext );
     932             : 
     933         462 : bool ScXMLMasterStylesContext::InsertStyleFamily( sal_uInt16 ) const
     934             : {
     935         462 :     return true;
     936             : }
     937             : 
     938         107 : ScXMLMasterStylesContext::ScXMLMasterStylesContext(
     939             :         SvXMLImport& rImport,
     940             :         sal_uInt16 nPrfx, const OUString& rLName,
     941             :         const uno::Reference< XAttributeList > & xAttrList ) :
     942         107 :     SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList )
     943             : {
     944         107 : }
     945             : 
     946         214 : ScXMLMasterStylesContext::~ScXMLMasterStylesContext()
     947             : {
     948         214 : }
     949             : 
     950         231 : SvXMLStyleContext *ScXMLMasterStylesContext::CreateStyleChildContext(
     951             :         sal_uInt16 nPrefix,
     952             :         const OUString& rLocalName,
     953             :         const uno::Reference< XAttributeList > & xAttrList )
     954             : {
     955         231 :     SvXMLStyleContext *pContext(0);
     956             : 
     957         462 :     if( (XML_NAMESPACE_STYLE == nPrefix) &&
     958         462 :         IsXMLToken(rLocalName, XML_MASTER_PAGE) &&
     959         231 :          InsertStyleFamily( XML_STYLE_FAMILY_MASTER_PAGE ) )
     960             :         pContext = new ScMasterPageContext(
     961         231 :                         GetImport(), nPrefix, rLocalName, xAttrList,
     962         231 :                         !GetImport().GetTextImport()->IsInsertMode() );
     963             : 
     964             :     // any other style will be ignored here!
     965             : 
     966         231 :     return pContext;
     967             : }
     968             : 
     969           0 : SvXMLStyleContext *ScXMLMasterStylesContext::CreateStyleStyleChildContext(
     970             :         sal_uInt16 /* nFamily */,
     971             :         sal_uInt16 /* nPrefix */,
     972             :         const OUString& /* rLocalName */,
     973             :         const uno::Reference< XAttributeList > & /* xAttrList */ )
     974             : {
     975           0 :     return 0;
     976             : }
     977             : 
     978         107 : void ScXMLMasterStylesContext::EndElement()
     979             : {
     980         107 :     FinishStyles(true);
     981         107 : }
     982             : 
     983           0 : TYPEINIT1( ScMasterPageContext, XMLTextMasterPageContext );
     984             : 
     985         231 : ScMasterPageContext::ScMasterPageContext( SvXMLImport& rImport,
     986             :         sal_uInt16 nPrfx, const OUString& rLName,
     987             :         const uno::Reference< XAttributeList > & xAttrList,
     988             :         bool bOverwrite ) :
     989             :     XMLTextMasterPageContext( rImport, nPrfx, rLName, xAttrList, bOverwrite ),
     990             :     bContainsRightHeader(false),
     991         231 :     bContainsRightFooter(false)
     992             : {
     993         231 : }
     994             : 
     995         462 : ScMasterPageContext::~ScMasterPageContext()
     996             : {
     997         462 : }
     998             : 
     999         904 : SvXMLImportContext *ScMasterPageContext::CreateChildContext(
    1000             :         sal_uInt16 nPrefix,
    1001             :         const OUString& rLocalName,
    1002             :         const uno::Reference< XAttributeList > & xAttrList )
    1003             : {
    1004         904 :     return XMLTextMasterPageContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
    1005             : }
    1006             : 
    1007         904 : SvXMLImportContext *ScMasterPageContext::CreateHeaderFooterContext(
    1008             :             sal_uInt16 nPrefix,
    1009             :             const OUString& rLocalName,
    1010             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
    1011             :             const bool bFooter,
    1012             :             const bool bLeft,
    1013             :             const bool /*bFirst*/ )
    1014             : {
    1015         904 :     if (!bLeft)
    1016             :     {
    1017         462 :         if (bFooter)
    1018         231 :             bContainsRightFooter = true;
    1019             :         else
    1020         231 :             bContainsRightHeader = true;
    1021             :     }
    1022         904 :     if (!xPropSet.is())
    1023         231 :         xPropSet.set(GetStyle(), UNO_QUERY );
    1024         904 :     return new XMLTableHeaderFooterContext( GetImport(),
    1025             :                                                 nPrefix, rLocalName,
    1026             :                                                 xAttrList,
    1027             :                                                 xPropSet,
    1028         904 :                                                 bFooter, bLeft );
    1029             : }
    1030             : 
    1031           0 : void ScMasterPageContext::ClearContent(const OUString& rContent)
    1032             : {
    1033           0 :     if (!xPropSet.is())
    1034           0 :         xPropSet.set(GetStyle(), UNO_QUERY );
    1035             : 
    1036           0 :     if (xPropSet.is())
    1037             :     {
    1038           0 :         uno::Reference < sheet::XHeaderFooterContent > xHeaderFooterContent(xPropSet->getPropertyValue( rContent ), uno::UNO_QUERY);
    1039           0 :         if (xHeaderFooterContent.is())
    1040             :         {
    1041           0 :             xHeaderFooterContent->getLeftText()->setString(sEmpty);
    1042           0 :             xHeaderFooterContent->getCenterText()->setString(sEmpty);
    1043           0 :             xHeaderFooterContent->getRightText()->setString(sEmpty);
    1044           0 :             xPropSet->setPropertyValue( rContent, uno::makeAny(xHeaderFooterContent) );
    1045           0 :         }
    1046             :     }
    1047           0 : }
    1048             : 
    1049         231 : void ScMasterPageContext::Finish( bool bOverwrite )
    1050             : {
    1051         231 :     XMLTextMasterPageContext::Finish(bOverwrite);
    1052         231 :     if (!bContainsRightFooter)
    1053           0 :         ClearContent(OUString(SC_UNO_PAGE_RIGHTFTRCON));
    1054         231 :     if (!bContainsRightHeader)
    1055           0 :         ClearContent(OUString(SC_UNO_PAGE_RIGHTHDRCON));
    1056         231 : }
    1057             : 
    1058          74 : ScCellTextStyleContext::ScCellTextStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
    1059             :             const OUString& rLName, const uno::Reference<xml::sax::XAttributeList> & xAttrList,
    1060             :             SvXMLStylesContext& rStyles, sal_uInt16 nFamily, bool bDefaultStyle ) :
    1061             :     XMLTextStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle ),
    1062          74 :     nLastSheet(-1)
    1063             : {
    1064          74 : }
    1065             : 
    1066         148 : ScCellTextStyleContext::~ScCellTextStyleContext()
    1067             : {
    1068         148 : }
    1069             : 
    1070         219 : void ScCellTextStyleContext::FillPropertySet( const uno::Reference<beans::XPropertySet>& xPropSet )
    1071             : {
    1072         219 :     XMLTextStyleContext::FillPropertySet( xPropSet );
    1073             : 
    1074         219 :     ScXMLImport& rXMLImport = GetScImport();
    1075             : 
    1076         219 :     ScCellTextCursor* pCellImp = ScCellTextCursor::getImplementation( xPropSet );
    1077         219 :     if (pCellImp)
    1078             :     {
    1079           0 :         ScAddress aPos = pCellImp->GetCellObj().GetPosition();
    1080           0 :         if ( aPos.Tab() != nLastSheet )
    1081             :         {
    1082           0 :             ESelection aSel = pCellImp->GetSelection();
    1083             : 
    1084           0 :             ScSheetSaveData* pSheetData = ScModelObj::getImplementation(GetImport().GetModel())->GetSheetSaveData();
    1085           0 :             pSheetData->AddTextStyle( GetName(), aPos, aSel );
    1086             : 
    1087           0 :             nLastSheet = aPos.Tab();
    1088             :         }
    1089             :     }
    1090         219 :     else if ( rXMLImport.GetTables().GetCurrentSheet() != nLastSheet )
    1091             :     {
    1092         188 :         ScDrawTextCursor* pDrawImp = ScDrawTextCursor::getImplementation( xPropSet );
    1093         188 :         if (pDrawImp)
    1094             :         {
    1095          15 :             XMLTableShapeImportHelper* pTableShapeImport = (XMLTableShapeImportHelper*)GetScImport().GetShapeImport().get();
    1096          15 :             ScXMLAnnotationContext* pAnnotationContext = pTableShapeImport->GetAnnotationContext();
    1097          15 :             if (pAnnotationContext)
    1098             :             {
    1099          15 :                 pAnnotationContext->AddContentStyle( GetFamily(), GetName(), pDrawImp->GetSelection() );
    1100          15 :                 nLastSheet = rXMLImport.GetTables().GetCurrentSheet();
    1101             :             }
    1102             :         }
    1103             : 
    1104             :         // if it's a different shape, BlockSheet is called from XMLTableShapeImportHelper::finishShape
    1105             :         // formatted text in page headers/footers can be ignored
    1106             :     }
    1107         219 : }
    1108             : 
    1109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10