LCOV - code coverage report
Current view: top level - sc/source/filter/xml - xmlstyli.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 405 521 77.7 %
Date: 2015-06-13 12:38:46 Functions: 56 73 76.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11