LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/filter/xml - xmlstyli.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 408 521 78.3 %
Date: 2013-07-09 Functions: 55 73 75.3 %
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         101 : ScXMLCellImportPropertyMapper::ScXMLCellImportPropertyMapper(
      77             :         const UniReference< XMLPropertySetMapper >& rMapper,
      78             :         SvXMLImport& rImportP) :
      79         101 :     SvXMLImportPropertyMapper( rMapper, rImportP )
      80             : {
      81         101 : }
      82             : 
      83         202 : ScXMLCellImportPropertyMapper::~ScXMLCellImportPropertyMapper()
      84             : {
      85         202 : }
      86             : 
      87         785 : 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         785 :     SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex);
      95         785 :     XMLPropertyState* pAllPaddingProperty(NULL);
      96         785 :     XMLPropertyState* pPadding[4] = { NULL, NULL, NULL, NULL };
      97         785 :     XMLPropertyState* pNewPadding[4] = { NULL, NULL, NULL, NULL };
      98         785 :     XMLPropertyState* pAllBorderProperty = NULL;
      99         785 :     XMLPropertyState* pBorders[4] = { NULL, NULL, NULL, NULL };
     100         785 :     XMLPropertyState* pNewBorders[4] = { NULL, NULL, NULL, NULL };
     101         785 :     XMLPropertyState* pAllBorderWidthProperty = NULL;
     102         785 :     XMLPropertyState* pBorderWidths[4] = { NULL, NULL, NULL, NULL };
     103         785 :     XMLPropertyState* pDiagBorders[2] = { 0 };
     104         785 :     XMLPropertyState* pOldDiagBorderWidths[2] = { 0 };      // old attribute names without "s"
     105         785 :     XMLPropertyState* pDiagBorderWidths[2] = { 0 };
     106             : 
     107         785 :     ::std::vector< XMLPropertyState >::iterator endproperty(rProperties.end());
     108        4588 :     for (::std::vector< XMLPropertyState >::iterator aIter =  rProperties.begin();
     109             :         aIter != endproperty; ++aIter)
     110             :     {
     111        3803 :         XMLPropertyState*property = &(*aIter);
     112        3803 :         if (property->mnIndex != -1)
     113             :         {
     114        3795 :             sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex);
     115        3795 :             switch (nContextID)
     116             :             {
     117           2 :                 case CTF_SC_ALLPADDING                  : pAllPaddingProperty = &*property; break;
     118          20 :                 case CTF_SC_LEFTPADDING                 : pPadding[XML_LINE_LEFT] = &*property; break;
     119          20 :                 case CTF_SC_RIGHTPADDING                : pPadding[XML_LINE_RIGHT] = &*property; break;
     120          20 :                 case CTF_SC_TOPPADDING                  : pPadding[XML_LINE_TOP] = &*property; break;
     121          20 :                 case CTF_SC_BOTTOMPADDING               : pPadding[XML_LINE_BOTTOM] = &*property; break;
     122          32 :                 case CTF_SC_ALLBORDER                   : pAllBorderProperty = &*property; break;
     123          92 :                 case CTF_SC_LEFTBORDER                  : pBorders[XML_LINE_LEFT] = &*property; break;
     124          92 :                 case CTF_SC_RIGHTBORDER                 : pBorders[XML_LINE_RIGHT] = &*property; break;
     125          92 :                 case CTF_SC_TOPBORDER                   : pBorders[XML_LINE_TOP] = &*property; break;
     126          92 :                 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           9 :                 case CTF_SC_DIAGONALTLBR                : pDiagBorders[XML_LINE_TLBR] = &*property; break;
     133           9 :                 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         785 :     if (pAllBorderWidthProperty)
     145          12 :         pAllBorderWidthProperty->mnIndex = -1;
     146         785 :     if (pAllBorderProperty)
     147          32 :         pAllBorderProperty->mnIndex = -1;
     148         785 :     if (pAllPaddingProperty)
     149           2 :         pAllPaddingProperty->mnIndex = -1;
     150             : 
     151        3925 :     for (i = 0; i < 4; ++i)
     152             :     {
     153        3140 :         if (pAllPaddingProperty && !pPadding[i])
     154           8 :             pNewPadding[i] = new XMLPropertyState(maPropMapper->FindEntryIndex(aPaddingCTF[i]), pAllPaddingProperty->maValue);
     155        3140 :         if (pAllBorderProperty && !pBorders[i])
     156             :         {
     157         128 :             pNewBorders[i] = new XMLPropertyState(maPropMapper->FindEntryIndex(aBorderCTF[i]), pAllBorderProperty->maValue);
     158         128 :             pBorders[i] = pNewBorders[i];
     159             :         }
     160        3140 :         if( !pBorderWidths[i] )
     161        3140 :             pBorderWidths[i] = pAllBorderWidthProperty;
     162             :         else
     163           0 :             pBorderWidths[i]->mnIndex = -1;
     164        3140 :         if( pBorders[i] )
     165             :         {
     166         496 :             table::BorderLine2 aBorderLine;
     167         496 :             pBorders[i]->maValue >>= aBorderLine;
     168         496 :             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        2355 :     for( i = 0; i < 2; ++i )
     183             :     {
     184        1570 :         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        3925 :     for (i = 0; i < 4; ++i)
     205             :     {
     206        3140 :         if (pNewPadding[i])
     207             :         {
     208           8 :             rProperties.push_back(*pNewPadding[i]);
     209           8 :             delete pNewPadding[i];
     210             :         }
     211        3140 :         if (pNewBorders[i])
     212             :         {
     213         128 :             rProperties.push_back(*pNewBorders[i]);
     214         128 :             delete pNewBorders[i];
     215             :         }
     216             :     }
     217         785 : }
     218             : 
     219          75 : ScXMLRowImportPropertyMapper::ScXMLRowImportPropertyMapper(
     220             :         const UniReference< XMLPropertySetMapper >& rMapper,
     221             :         SvXMLImport& rImportP) :
     222          75 :     SvXMLImportPropertyMapper( rMapper, rImportP )
     223             : {
     224          75 : }
     225             : 
     226         150 : ScXMLRowImportPropertyMapper::~ScXMLRowImportPropertyMapper()
     227             : {
     228         150 : }
     229             : 
     230         138 : void ScXMLRowImportPropertyMapper::finished(::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const
     231             : {
     232         138 :     SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex);
     233         138 :     XMLPropertyState* pHeight(NULL);
     234         138 :     XMLPropertyState* pOptimalHeight(NULL);
     235         138 :     XMLPropertyState* pPageBreak(NULL);
     236         138 :     ::std::vector< XMLPropertyState >::iterator endproperty(rProperties.end());
     237         542 :     for (::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
     238             :         aIter != endproperty; ++aIter)
     239             :     {
     240         404 :         XMLPropertyState* property = &(*aIter);
     241         404 :         if (property->mnIndex != -1)
     242             :         {
     243         404 :             sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex);
     244         404 :             switch (nContextID)
     245             :             {
     246         133 :                 case CTF_SC_ROWHEIGHT                   : pHeight = property; break;
     247         133 :                 case CTF_SC_ROWOPTIMALHEIGHT            : pOptimalHeight = property; break;
     248         138 :                 case CTF_SC_ROWBREAKBEFORE              : pPageBreak = property; break;
     249             :             }
     250             :         }
     251             :     }
     252         138 :     if (pPageBreak)
     253             :     {
     254         138 :         if(!(::cppu::any2bool(pPageBreak->maValue)))
     255         138 :             pPageBreak->mnIndex = -1;
     256             :     }
     257         138 :     if (pOptimalHeight)
     258             :     {
     259         133 :         if (::cppu::any2bool(pOptimalHeight->maValue))
     260             :         {
     261         113 :             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         113 :                 pOptimalHeight->maValue = pHeight->maValue;
     266         113 :                 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), ::cppu::bool2any( false )));
     275             :     }
     276             :     // don't access pointers to rProperties elements after push_back!
     277         138 : }
     278             : 
     279         588 : 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 );
     296             : };
     297             : 
     298         294 : 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         294 :                rProps, rMap )
     307             : {
     308         294 : }
     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          33 :     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          11 : ScXMLMapContext::ScXMLMapContext(SvXMLImport& rImport, sal_uInt16 nPrfx,
     368             :             const OUString& rLName, const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     369          11 :     : SvXMLImportContext( rImport, nPrfx, rLName )
     370             : {
     371          11 :     sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
     372          44 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     373             :     {
     374          33 :         const OUString& rAttrName(xAttrList->getNameByIndex( i ));
     375          66 :         OUString aLocalName;
     376          33 :         sal_uInt16 nPrefix(GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ));
     377          66 :         const OUString& rValue(xAttrList->getValueByIndex( i ));
     378             : 
     379             :         // TODO: use a map here
     380          33 :         if( XML_NAMESPACE_STYLE == nPrefix )
     381             :         {
     382          33 :             if( IsXMLToken(aLocalName, XML_CONDITION ) )
     383          11 :                 msCondition = rValue;
     384          22 :             else if( IsXMLToken(aLocalName, XML_APPLY_STYLE_NAME ) )
     385          11 :                 msApplyStyle = GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TABLE_CELL, rValue);
     386          11 :             else if ( IsXMLToken(aLocalName, XML_BASE_CELL_ADDRESS ) )
     387          11 :                 msBaseCell = rValue;
     388             :         }
     389          33 :     }
     390          11 : }
     391             : 
     392          11 : ScCondFormatEntry* ScXMLMapContext::CreateConditionEntry()
     393             : {
     394          22 :     OUString aCondition, aConditionNmsp;
     395          11 :     FormulaGrammar::Grammar eGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
     396          11 :     GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eGrammar, msCondition );
     397          11 :     bool bHasNmsp = aCondition.getLength() < msCondition.getLength();
     398             : 
     399             :     // parse a condition from the attribute string
     400          22 :     ScXMLConditionParseResult aParseResult;
     401          11 :     ScXMLConditionHelper::parseCondition( aParseResult, aCondition, 0 );
     402             : 
     403          11 :     if( !bHasNmsp )
     404             :     {
     405             :         // the attribute does not contain a namespace: try to find a namespace of an external grammar
     406          11 :         FormulaGrammar::Grammar eNewGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
     407          11 :         GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eNewGrammar, aCondition, true );
     408          11 :         if( eNewGrammar != FormulaGrammar::GRAM_EXTERNAL )
     409          11 :             eGrammar = eNewGrammar;
     410             :     }
     411             : 
     412          11 :     ScConditionMode eMode = ScConditionEntry::GetModeFromApi(aParseResult.meOperator);
     413          22 :     OUString aNmsp1, aNmsp2;
     414          11 :     ScDocument* pDoc = GetScImport().GetDocument();
     415             : 
     416             :     ScCondFormatEntry* pEntry =  new ScCondFormatEntry(eMode, aParseResult.maOperand1, aParseResult.maOperand2, pDoc, ScAddress(), msApplyStyle,
     417          11 :                                                     aNmsp1, aNmsp2, eGrammar, eGrammar);
     418             : 
     419          11 :     pEntry->SetSrcString(msBaseCell);
     420          22 :     return pEntry;
     421             : }
     422             : 
     423          22 : ScXMLMapContext::~ScXMLMapContext()
     424             : {
     425          22 : }
     426             : 
     427        2844 : void XMLTableStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
     428             :                                         const OUString& rLocalName,
     429             :                                         const OUString& rValue )
     430             : {
     431             :     // TODO: use a map here
     432        2844 :     if( IsXMLToken(rLocalName, XML_DATA_STYLE_NAME ) )
     433         137 :         sDataStyleName = rValue;
     434        2707 :     else if ( IsXMLToken(rLocalName, XML_MASTER_PAGE_NAME ) )
     435          77 :         sPageStyle = rValue;
     436             :     else
     437        2630 :         XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
     438        2844 : }
     439             : 
     440           0 : TYPEINIT1( XMLTableStyleContext, XMLPropStyleContext );
     441             : 
     442        1050 : 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        1050 :     mbDeleteCondFormat(true)
     454             : {
     455        1050 : }
     456             : 
     457        3150 : XMLTableStyleContext::~XMLTableStyleContext()
     458             : {
     459        1050 :     if(mbDeleteCondFormat)
     460        1047 :         delete mpCondFormat;
     461        2100 : }
     462             : 
     463        1133 : SvXMLImportContext *XMLTableStyleContext::CreateChildContext(
     464             :         sal_uInt16 nPrefix,
     465             :         const OUString& rLocalName,
     466             :         const uno::Reference< XAttributeList > & xAttrList )
     467             : {
     468        1133 :     SvXMLImportContext *pContext(NULL);
     469             : 
     470        2266 :     if( (XML_NAMESPACE_STYLE == nPrefix) &&
     471        1133 :         IsXMLToken(rLocalName, XML_MAP ) )
     472             :     {
     473          11 :         if(!mpCondFormat)
     474           3 :             mpCondFormat = new ScConditionalFormat( 0, GetScImport().GetDocument() );
     475          11 :         ScXMLMapContext* pMapContext = new ScXMLMapContext(GetImport(), nPrefix, rLocalName, xAttrList);
     476          11 :         pContext = pMapContext;
     477          11 :         mpCondFormat->AddEntry(pMapContext->CreateConditionEntry());
     478             :     }
     479        2244 :     else if ( ( XML_NAMESPACE_STYLE == nPrefix) &&
     480        1122 :         IsXMLToken(rLocalName, XML_TABLE_CELL_PROPERTIES ) )
     481             :     {
     482             :         UniReference < SvXMLImportPropertyMapper > xImpPrMap =
     483         294 :             ((SvXMLStylesContext *)GetStyles())->GetImportPropertyMapper(
     484         294 :                 GetFamily() );
     485         294 :         if( xImpPrMap.is() )
     486         294 :             pContext = new XMLTableCellPropsContext( GetImport(), nPrefix,
     487             :                 rLocalName, xAttrList,
     488             :                 XML_TYPE_PROP_TABLE_CELL,
     489         294 :                 GetProperties(),
     490         588 :                 xImpPrMap );
     491             :     }
     492             : 
     493        1133 :     if (!pContext)
     494             :         pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName,
     495         828 :                                                            xAttrList );
     496        1133 :     return pContext;
     497             : }
     498             : 
     499         217 : void XMLTableStyleContext::ApplyCondFormat( uno::Sequence<table::CellRangeAddress> xCellRanges )
     500             : {
     501         217 :     if(!mpCondFormat || GetScImport().HasNewCondFormatData())
     502         428 :         return;
     503             : 
     504           3 :     ScRangeList aRangeList;
     505           3 :     sal_Int32 nRanges = xCellRanges.getLength();
     506           6 :     for(sal_Int32 i = 0; i < nRanges; ++i)
     507             :     {
     508           3 :         table::CellRangeAddress aAddress = xCellRanges[i];
     509           3 :         ScRange aRange( aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet, aAddress.EndColumn, aAddress.EndRow, aAddress.Sheet );
     510           3 :         aRangeList.Join( aRange, false );
     511             :     }
     512             : 
     513           3 :     ScDocument* pDoc = GetScImport().GetDocument();
     514           3 :     SCTAB nTab = GetScImport().GetTables().GetCurrentSheet();
     515           3 :     ScConditionalFormatList* pFormatList = pDoc->GetCondFormList(nTab);
     516           6 :     for(ScConditionalFormatList::iterator itr = pFormatList->begin(), itrEnd = pFormatList->end();
     517             :                     itr != itrEnd; ++itr)
     518             :     {
     519           3 :         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           6 :     if(mpCondFormat && mbDeleteCondFormat)
     536             :     {
     537           3 :         sal_uLong nIndex = pDoc->AddCondFormat(mpCondFormat, nTab );
     538           3 :         mpCondFormat->SetKey(nIndex);
     539           3 :         mpCondFormat->AddRange(aRangeList);
     540             : 
     541           3 :         pDoc->AddCondFormatData( aRangeList, nTab, nIndex );
     542           3 :         mbDeleteCondFormat = false;
     543           3 :     }
     544             : 
     545             : 
     546             : }
     547             : 
     548        3141 : void XMLTableStyleContext::FillPropertySet(
     549             :     const uno::Reference< XPropertySet > & rPropSet )
     550             : {
     551        3141 :     if (!IsDefaultStyle())
     552             :     {
     553        3066 :         if (GetFamily() == XML_STYLE_FAMILY_TABLE_CELL)
     554             :         {
     555         645 :             if (!bParentSet)
     556             :             {
     557         638 :                 AddProperty(CTF_SC_CELLSTYLE, uno::makeAny(GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TABLE_CELL, GetParentName() )));
     558         638 :                 bParentSet = true;
     559             :             }
     560         645 :             sal_Int32 nNumFmt = GetNumberFormat();
     561         645 :             if (nNumFmt >= 0)
     562         137 :                 AddProperty(CTF_SC_NUMBERFORMAT, uno::makeAny(nNumFmt));
     563             :         }
     564        2421 :         else if (GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE)
     565             :         {
     566         168 :             if (!sPageStyle.isEmpty())
     567         168 :                 AddProperty(CTF_SC_MASTERPAGENAME, uno::makeAny(GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_MASTER_PAGE, sPageStyle )));
     568             :         }
     569             :     }
     570        3141 :     XMLPropStyleContext::FillPropertySet(rPropSet);
     571        3141 : }
     572             : 
     573          75 : void XMLTableStyleContext::SetDefaults()
     574             : {
     575          75 :     if ((GetFamily() == XML_STYLE_FAMILY_TABLE_CELL) && GetImport().GetModel().is())
     576             :     {
     577          75 :         uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetImport().GetModel(), uno::UNO_QUERY);
     578          75 :         if (xMultiServiceFactory.is())
     579             :         {
     580          75 :             uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance("com.sun.star.sheet.Defaults"), uno::UNO_QUERY);
     581          75 :             if (xProperties.is())
     582          75 :                 FillPropertySet(xProperties);
     583          75 :         }
     584             :     }
     585          75 : }
     586             : 
     587         943 : void XMLTableStyleContext::AddProperty(const sal_Int16 nContextID, const uno::Any& rValue)
     588             : {
     589         943 :     XMLPropertyState* property = FindProperty(nContextID);
     590         943 :     if (property)
     591          91 :         property->mnIndex = -1; // #i46996# remove old property, so it isn't double
     592         943 :     sal_Int32 nIndex(static_cast<XMLTableStylesContext *>(pStyles)->GetIndex(nContextID));
     593             :     OSL_ENSURE(nIndex != -1, "Property not found in Map");
     594         943 :     XMLPropertyState aPropState(nIndex, rValue);
     595         943 :     GetProperties().push_back(aPropState); // has to be insertes in a sort order later
     596         943 : }
     597             : 
     598         943 : XMLPropertyState* XMLTableStyleContext::FindProperty(const sal_Int16 nContextID)
     599             : {
     600         943 :     XMLPropertyState* pRet = NULL;
     601         943 :     UniReference < XMLPropertySetMapper > xPrMap;
     602             :     UniReference < SvXMLImportPropertyMapper > xImpPrMap =
     603        1886 :         pStyles->GetImportPropertyMapper( GetFamily() );
     604             :     OSL_ENSURE( xImpPrMap.is(), "There is the import prop mapper" );
     605         943 :     if( xImpPrMap.is() )
     606         943 :         xPrMap = xImpPrMap->getPropertySetMapper();
     607         943 :     if( xPrMap.is() )
     608             :     {
     609         943 :         ::std::vector< XMLPropertyState >::iterator endproperty(GetProperties().end());
     610         943 :         ::std::vector< XMLPropertyState >::iterator aIter(GetProperties().begin());
     611        4823 :         while(!pRet && aIter != endproperty)
     612             :         {
     613        2937 :             XMLPropertyState* property = &(*aIter);
     614        2937 :             if (property->mnIndex != -1 && xPrMap->GetEntryContextId(property->mnIndex) == nContextID)
     615             :             {
     616          91 :                 pRet = property;
     617             :             }
     618             :             else
     619        2846 :                 ++aIter;
     620             :         }
     621             :     }
     622        1886 :     return pRet;
     623             : }
     624             : 
     625         862 : sal_Int32 XMLTableStyleContext::GetNumberFormat()
     626             : {
     627         862 :     if (nNumberFormat < 0 && !sDataStyleName.isEmpty())
     628             :     {
     629             :         const SvXMLNumFormatContext* pStyle = static_cast<const SvXMLNumFormatContext*>(
     630         137 :             pStyles->FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, sal_True));
     631             : 
     632         137 :         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, sal_True));
     638             :             else
     639             :             {
     640             :                 OSL_FAIL("not possible to get style");
     641             :             }
     642             :         }
     643         137 :         if (pStyle)
     644         137 :             nNumberFormat = const_cast<SvXMLNumFormatContext*>(pStyle)->GetKey();
     645             :     }
     646         862 :     return nNumberFormat;
     647             : }
     648             : 
     649             : // ----------------------------------------------------------------------------
     650             : 
     651        1042 : SvXMLStyleContext *XMLTableStylesContext::CreateStyleStyleChildContext(
     652             :         sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
     653             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     654             : {
     655             :     SvXMLStyleContext *pStyle;
     656             :     // use own wrapper for text and paragraph, to record style usage
     657        1042 :     if (nFamily == XML_STYLE_FAMILY_TEXT_PARAGRAPH || nFamily == XML_STYLE_FAMILY_TEXT_TEXT)
     658          41 :         pStyle = new ScCellTextStyleContext( GetImport(), nPrefix, rLocalName,
     659          41 :                                             xAttrList, *this, nFamily );
     660             :     else
     661             :         pStyle = SvXMLStylesContext::CreateStyleStyleChildContext(
     662        1001 :                     nFamily, nPrefix, rLocalName, xAttrList );
     663             : 
     664        1042 :     if (!pStyle)
     665             :     {
     666         975 :         switch( nFamily )
     667             :         {
     668             :         case XML_STYLE_FAMILY_TABLE_CELL:
     669             :         case XML_STYLE_FAMILY_TABLE_COLUMN:
     670             :         case XML_STYLE_FAMILY_TABLE_ROW:
     671             :         case XML_STYLE_FAMILY_TABLE_TABLE:
     672             :             pStyle = new XMLTableStyleContext( GetScImport(), nPrefix, rLocalName,
     673         975 :                                                xAttrList, *this, nFamily );
     674         975 :             break;
     675             :         }
     676             :     }
     677             : 
     678        1042 :     return pStyle;
     679             : }
     680             : 
     681          92 : SvXMLStyleContext *XMLTableStylesContext::CreateDefaultStyleStyleChildContext(
     682             :         sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
     683             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     684             : {
     685             :     SvXMLStyleContext *pStyle(SvXMLStylesContext::CreateDefaultStyleStyleChildContext( nFamily, nPrefix,
     686             :                                                             rLocalName,
     687          92 :                                                             xAttrList ));
     688          92 :     if (!pStyle)
     689             :     {
     690          92 :         switch( nFamily )
     691             :         {
     692             :             case XML_STYLE_FAMILY_TABLE_CELL:
     693             :                 pStyle = new XMLTableStyleContext( GetScImport(), nPrefix, rLocalName,
     694          75 :                                             xAttrList, *this, nFamily, sal_True);
     695          75 :             break;
     696             :             case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
     697          17 :                 pStyle = new XMLGraphicsDefaultStyle( GetScImport(), nPrefix, rLocalName,
     698          17 :                                             xAttrList, *this);
     699          17 :             break;
     700             :         }
     701             :     }
     702             : 
     703          92 :     return pStyle;
     704             : }
     705             : 
     706         226 : XMLTableStylesContext::XMLTableStylesContext( SvXMLImport& rImport,
     707             :         sal_uInt16 nPrfx ,
     708             :         const OUString& rLName ,
     709             :         const uno::Reference< XAttributeList > & xAttrList,
     710             :         const bool bTempAutoStyles ) :
     711             :     SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ),
     712             :     sCellStyleServiceName( OUString( "com.sun.star.style.CellStyle" )),
     713             :     sColumnStyleServiceName( OUString( XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME )),
     714             :     sRowStyleServiceName( OUString( XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME )),
     715             :     sTableStyleServiceName( OUString( XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME )),
     716             :     nNumberFormatIndex(-1),
     717             :     nConditionalFormatIndex(-1),
     718             :     nCellStyleIndex(-1),
     719             :     nMasterPageNameIndex(-1),
     720         226 :     bAutoStyles(bTempAutoStyles)
     721             : {
     722         226 : }
     723             : 
     724         452 : XMLTableStylesContext::~XMLTableStylesContext()
     725             : {
     726         452 : }
     727             : 
     728         226 : void XMLTableStylesContext::EndElement()
     729             : {
     730         226 :     SvXMLStylesContext::EndElement();
     731         226 :     if (bAutoStyles)
     732         150 :         GetImport().GetTextImport()->SetAutoStyles( this );
     733             :     else
     734          76 :         ((ScXMLImport&)GetImport()).InsertStyles();
     735         226 : }
     736             : 
     737             : UniReference < SvXMLImportPropertyMapper >
     738        6831 :     XMLTableStylesContext::GetImportPropertyMapper(
     739             :                     sal_uInt16 nFamily ) const
     740             : {
     741        6831 :     UniReference < SvXMLImportPropertyMapper > xMapper(SvXMLStylesContext::GetImportPropertyMapper(nFamily));
     742             : 
     743        6831 :     if (!xMapper.is())
     744             :     {
     745        5892 :         switch( nFamily )
     746             :         {
     747             :             case XML_STYLE_FAMILY_TABLE_CELL:
     748             :             {
     749        2891 :                 if( !xCellImpPropMapper.is() )
     750             :                 {
     751         404 :                     ((XMLTableStylesContext *)this)->xCellImpPropMapper =
     752         404 :                         new ScXMLCellImportPropertyMapper( GetScImport().GetCellStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
     753         101 :                     xCellImpPropMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(const_cast<SvXMLImport&>(GetImport()), const_cast<XMLFontStylesContext*>(GetScImport().GetFontDecls())));
     754             :                 }
     755        2891 :                 xMapper = xCellImpPropMapper;
     756             :             }
     757        2891 :             break;
     758             :             case XML_STYLE_FAMILY_TABLE_COLUMN:
     759             :             {
     760         381 :                 if( !xColumnImpPropMapper.is() )
     761         300 :                     ((XMLTableStylesContext *)this)->xColumnImpPropMapper =
     762         300 :                         new SvXMLImportPropertyMapper( GetScImport().GetColumnStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
     763         381 :                 xMapper = xColumnImpPropMapper;
     764             :             }
     765         381 :              break;
     766             :             case XML_STYLE_FAMILY_TABLE_ROW:
     767             :             {
     768        2132 :                 if( !xRowImpPropMapper.is() )
     769         300 :                     ((XMLTableStylesContext *)this)->xRowImpPropMapper =
     770         300 :                         new ScXMLRowImportPropertyMapper( GetScImport().GetRowStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
     771        2132 :                 xMapper = xRowImpPropMapper;
     772             :             }
     773        2132 :              break;
     774             :             case XML_STYLE_FAMILY_TABLE_TABLE:
     775             :             {
     776         488 :                 if( !xTableImpPropMapper.is() )
     777         300 :                     ((XMLTableStylesContext *)this)->xTableImpPropMapper =
     778         300 :                         new SvXMLImportPropertyMapper( GetScImport().GetTableStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
     779         488 :                 xMapper = xTableImpPropMapper;
     780             :             }
     781         488 :              break;
     782             :         }
     783             :     }
     784             : 
     785        6831 :     return xMapper;
     786             : }
     787             : 
     788             : uno::Reference < XNameContainer >
     789         856 :         XMLTableStylesContext::GetStylesContainer( sal_uInt16 nFamily ) const
     790             : {
     791         856 :     uno::Reference < XNameContainer > xStyles(SvXMLStylesContext::GetStylesContainer(nFamily));
     792         856 :     if (!xStyles.is())
     793             :     {
     794         856 :         OUString sName;
     795         856 :         switch( nFamily )
     796             :         {
     797             :             case XML_STYLE_FAMILY_TABLE_TABLE:
     798             :             {
     799           0 :                 if( xTableStyles.is() )
     800           0 :                     xStyles.set(xTableStyles);
     801             :                 else
     802           0 :                     sName =
     803           0 :                         OUString( OUString( "TableStyles" ));
     804             :             }
     805           0 :             break;
     806             :             case XML_STYLE_FAMILY_TABLE_CELL:
     807             :             {
     808         856 :                 if( xCellStyles.is() )
     809         780 :                     xStyles.set(xCellStyles);
     810             :                 else
     811         152 :                     sName =
     812          76 :                         OUString( OUString( "CellStyles" ));
     813             :             }
     814         856 :             break;
     815             :             case XML_STYLE_FAMILY_TABLE_COLUMN:
     816             :             {
     817           0 :                 if( xColumnStyles.is() )
     818           0 :                     xStyles.set(xColumnStyles);
     819             :                 else
     820           0 :                     sName =
     821           0 :                         OUString( OUString( "ColumnStyles" ));
     822             :             }
     823           0 :             break;
     824             :             case XML_STYLE_FAMILY_TABLE_ROW:
     825             :             {
     826           0 :                 if( xRowStyles.is() )
     827           0 :                     xStyles.set(xRowStyles);
     828             :                 else
     829           0 :                     sName =
     830           0 :                         OUString( OUString( "RowStyles" ));
     831             :             }
     832           0 :             break;
     833             :         }
     834         856 :         if( !xStyles.is() && !sName.isEmpty() && GetScImport().GetModel().is() )
     835             :         {
     836             :             uno::Reference< XStyleFamiliesSupplier > xFamiliesSupp(
     837          76 :                                             GetScImport().GetModel(), UNO_QUERY );
     838          76 :             if (xFamiliesSupp.is())
     839             :             {
     840          76 :                 uno::Reference< XNameAccess > xFamilies(xFamiliesSupp->getStyleFamilies());
     841             : 
     842             :                 try
     843             :                 {
     844          76 :                     xStyles.set(xFamilies->getByName( sName ), uno::UNO_QUERY);
     845             :                 }
     846           0 :                 catch ( uno::Exception& )
     847             :                 {
     848             :                     // #i97680# Named table/column/row styles aren't supported, getByName will throw an exception.
     849             :                     // For better interoperability, these styles should then be handled as automatic styles.
     850             :                     // For now, NULL is returned (and the style is ignored).
     851             :                 }
     852          76 :                 switch( nFamily )
     853             :                 {
     854             :                 case XML_STYLE_FAMILY_TABLE_TABLE:
     855           0 :                     ((XMLTableStylesContext *)this)->xTableStyles.set(xStyles);
     856           0 :                     break;
     857             :                 case XML_STYLE_FAMILY_TABLE_CELL:
     858          76 :                     ((XMLTableStylesContext *)this)->xCellStyles.set(xStyles);
     859          76 :                     break;
     860             :                 case XML_STYLE_FAMILY_TABLE_COLUMN:
     861           0 :                     ((XMLTableStylesContext *)this)->xColumnStyles.set(xStyles);
     862           0 :                     break;
     863             :                 case XML_STYLE_FAMILY_TABLE_ROW:
     864           0 :                     ((XMLTableStylesContext *)this)->xRowStyles.set(xStyles);
     865           0 :                     break;
     866          76 :                 }
     867          76 :             }
     868         856 :         }
     869             :     }
     870             : 
     871         856 :     return xStyles;
     872             : }
     873             : 
     874          53 : OUString XMLTableStylesContext::GetServiceName( sal_uInt16 nFamily ) const
     875             : {
     876          53 :     OUString sServiceName(SvXMLStylesContext::GetServiceName(nFamily));
     877          53 :     if (sServiceName.isEmpty())
     878             :     {
     879          53 :         switch( nFamily )
     880             :         {
     881             :         case XML_STYLE_FAMILY_TABLE_COLUMN:
     882           0 :             sServiceName = sColumnStyleServiceName;
     883           0 :             break;
     884             :         case XML_STYLE_FAMILY_TABLE_ROW:
     885           0 :             sServiceName = sRowStyleServiceName;
     886           0 :             break;
     887             :         case XML_STYLE_FAMILY_TABLE_CELL:
     888          53 :             sServiceName = sCellStyleServiceName;
     889          53 :             break;
     890             :         case XML_STYLE_FAMILY_TABLE_TABLE:
     891           0 :             sServiceName = sTableStyleServiceName;
     892           0 :             break;
     893             :         }
     894             :     }
     895          53 :     return sServiceName;
     896             : }
     897             : 
     898         943 : sal_Int32 XMLTableStylesContext::GetIndex(const sal_Int16 nContextID)
     899             : {
     900         943 :     if (nContextID == CTF_SC_CELLSTYLE)
     901             :     {
     902         638 :         if (nCellStyleIndex == -1)
     903             :             nCellStyleIndex =
     904         101 :                 GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID);
     905         638 :         return nCellStyleIndex;
     906             :     }
     907         305 :     else if (nContextID == CTF_SC_NUMBERFORMAT)
     908             :     {
     909         137 :         if (nNumberFormatIndex == -1)
     910             :             nNumberFormatIndex =
     911          82 :                 GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID);
     912         137 :         return nNumberFormatIndex;
     913             :     }
     914         168 :     else if (nContextID == CTF_SC_IMPORT_MAP)
     915             :     {
     916           0 :         if (nConditionalFormatIndex == -1)
     917             :             nConditionalFormatIndex =
     918           0 :                 GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID);
     919           0 :         return nConditionalFormatIndex;
     920             :     }
     921         168 :     else if (nContextID == CTF_SC_MASTERPAGENAME)
     922             :     {
     923         168 :         if (nMasterPageNameIndex == -1)
     924             :                 nMasterPageNameIndex =
     925          75 :                 GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_TABLE)->getPropertySetMapper()->FindEntryIndex(nContextID);
     926         168 :         return nMasterPageNameIndex;
     927             :     }
     928             :     else
     929           0 :         return -1;
     930             : }
     931             : 
     932             : // ---------------------------------------------------------------------------
     933           0 : TYPEINIT1( ScXMLMasterStylesContext, SvXMLStylesContext );
     934             : 
     935         312 : sal_Bool ScXMLMasterStylesContext::InsertStyleFamily( sal_uInt16 ) const
     936             : {
     937         312 :     return sal_True;
     938             : }
     939             : 
     940          75 : ScXMLMasterStylesContext::ScXMLMasterStylesContext(
     941             :         SvXMLImport& rImport,
     942             :         sal_uInt16 nPrfx, const OUString& rLName,
     943             :         const uno::Reference< XAttributeList > & xAttrList ) :
     944          75 :     SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList )
     945             : {
     946          75 : }
     947             : 
     948         150 : ScXMLMasterStylesContext::~ScXMLMasterStylesContext()
     949             : {
     950         150 : }
     951             : 
     952         156 : SvXMLStyleContext *ScXMLMasterStylesContext::CreateStyleChildContext(
     953             :         sal_uInt16 nPrefix,
     954             :         const OUString& rLocalName,
     955             :         const uno::Reference< XAttributeList > & xAttrList )
     956             : {
     957         156 :     SvXMLStyleContext *pContext(0);
     958             : 
     959         312 :     if( (XML_NAMESPACE_STYLE == nPrefix) &&
     960         312 :         IsXMLToken(rLocalName, XML_MASTER_PAGE) &&
     961         156 :          InsertStyleFamily( XML_STYLE_FAMILY_MASTER_PAGE ) )
     962             :         pContext = new ScMasterPageContext(
     963         156 :                         GetImport(), nPrefix, rLocalName, xAttrList,
     964         156 :                         !GetImport().GetTextImport()->IsInsertMode() );
     965             : 
     966             :     // any other style will be ignored here!
     967             : 
     968         156 :     return pContext;
     969             : }
     970             : 
     971           0 : SvXMLStyleContext *ScXMLMasterStylesContext::CreateStyleStyleChildContext(
     972             :         sal_uInt16 /* nFamily */,
     973             :         sal_uInt16 /* nPrefix */,
     974             :         const OUString& /* rLocalName */,
     975             :         const uno::Reference< XAttributeList > & /* xAttrList */ )
     976             : {
     977           0 :     return 0;
     978             : }
     979             : 
     980          75 : void ScXMLMasterStylesContext::EndElement()
     981             : {
     982          75 :     FinishStyles(sal_True);
     983          75 : }
     984             : 
     985           0 : TYPEINIT1( ScMasterPageContext, XMLTextMasterPageContext );
     986             : 
     987         156 : ScMasterPageContext::ScMasterPageContext( SvXMLImport& rImport,
     988             :         sal_uInt16 nPrfx, const OUString& rLName,
     989             :         const uno::Reference< XAttributeList > & xAttrList,
     990             :         bool bOverwrite ) :
     991             :     XMLTextMasterPageContext( rImport, nPrfx, rLName, xAttrList, bOverwrite ),
     992             :     bContainsRightHeader(false),
     993         156 :     bContainsRightFooter(false)
     994             : {
     995         156 : }
     996             : 
     997         312 : ScMasterPageContext::~ScMasterPageContext()
     998             : {
     999         312 : }
    1000             : 
    1001         604 : SvXMLImportContext *ScMasterPageContext::CreateChildContext(
    1002             :         sal_uInt16 nPrefix,
    1003             :         const OUString& rLocalName,
    1004             :         const uno::Reference< XAttributeList > & xAttrList )
    1005             : {
    1006         604 :     return XMLTextMasterPageContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
    1007             : }
    1008             : 
    1009         604 : SvXMLImportContext *ScMasterPageContext::CreateHeaderFooterContext(
    1010             :             sal_uInt16 nPrefix,
    1011             :             const OUString& rLocalName,
    1012             :             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
    1013             :             const sal_Bool bFooter,
    1014             :             const sal_Bool bLeft,
    1015             :             const sal_Bool /*bFirst*/ )
    1016             : {
    1017         604 :     if (!bLeft)
    1018             :     {
    1019         312 :         if (bFooter)
    1020         156 :             bContainsRightFooter = sal_True;
    1021             :         else
    1022         156 :             bContainsRightHeader = sal_True;
    1023             :     }
    1024         604 :     if (!xPropSet.is())
    1025         156 :         xPropSet.set(GetStyle(), UNO_QUERY );
    1026         604 :     return new XMLTableHeaderFooterContext( GetImport(),
    1027             :                                                 nPrefix, rLocalName,
    1028             :                                                 xAttrList,
    1029             :                                                 xPropSet,
    1030         604 :                                                 bFooter, bLeft );
    1031             : }
    1032             : 
    1033           0 : void ScMasterPageContext::ClearContent(const OUString& rContent)
    1034             : {
    1035           0 :     if (!xPropSet.is())
    1036           0 :         xPropSet.set(GetStyle(), UNO_QUERY );
    1037             : 
    1038           0 :     if (xPropSet.is())
    1039             :     {
    1040           0 :         uno::Reference < sheet::XHeaderFooterContent > xHeaderFooterContent(xPropSet->getPropertyValue( rContent ), uno::UNO_QUERY);
    1041           0 :         if (xHeaderFooterContent.is())
    1042             :         {
    1043           0 :             xHeaderFooterContent->getLeftText()->setString(sEmpty);
    1044           0 :             xHeaderFooterContent->getCenterText()->setString(sEmpty);
    1045           0 :             xHeaderFooterContent->getRightText()->setString(sEmpty);
    1046           0 :             xPropSet->setPropertyValue( rContent, uno::makeAny(xHeaderFooterContent) );
    1047           0 :         }
    1048             :     }
    1049           0 : }
    1050             : 
    1051         156 : void ScMasterPageContext::Finish( sal_Bool bOverwrite )
    1052             : {
    1053         156 :     XMLTextMasterPageContext::Finish(bOverwrite);
    1054         156 :     if (!bContainsRightFooter)
    1055           0 :         ClearContent(OUString(SC_UNO_PAGE_RIGHTFTRCON));
    1056         156 :     if (!bContainsRightHeader)
    1057           0 :         ClearContent(OUString(SC_UNO_PAGE_RIGHTHDRCON));
    1058         156 : }
    1059             : 
    1060             : // ---------------------------------------------------------------------------
    1061             : 
    1062          41 : ScCellTextStyleContext::ScCellTextStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
    1063             :             const OUString& rLName, const uno::Reference<xml::sax::XAttributeList> & xAttrList,
    1064             :             SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle ) :
    1065             :     XMLTextStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle ),
    1066          41 :     nLastSheet(-1)
    1067             : {
    1068          41 : }
    1069             : 
    1070          82 : ScCellTextStyleContext::~ScCellTextStyleContext()
    1071             : {
    1072          82 : }
    1073             : 
    1074         109 : void ScCellTextStyleContext::FillPropertySet( const uno::Reference<beans::XPropertySet>& xPropSet )
    1075             : {
    1076         109 :     XMLTextStyleContext::FillPropertySet( xPropSet );
    1077             : 
    1078         109 :     ScXMLImport& rXMLImport = GetScImport();
    1079             : 
    1080         109 :     ScCellTextCursor* pCellImp = ScCellTextCursor::getImplementation( xPropSet );
    1081         109 :     if (pCellImp)
    1082             :     {
    1083           0 :         ScAddress aPos = pCellImp->GetCellObj().GetPosition();
    1084           0 :         if ( aPos.Tab() != nLastSheet )
    1085             :         {
    1086           0 :             ESelection aSel = pCellImp->GetSelection();
    1087             : 
    1088           0 :             ScSheetSaveData* pSheetData = ScModelObj::getImplementation(GetImport().GetModel())->GetSheetSaveData();
    1089           0 :             pSheetData->AddTextStyle( GetName(), aPos, aSel );
    1090             : 
    1091           0 :             nLastSheet = aPos.Tab();
    1092             :         }
    1093             :     }
    1094         109 :     else if ( rXMLImport.GetTables().GetCurrentSheet() != nLastSheet )
    1095             :     {
    1096         103 :         ScDrawTextCursor* pDrawImp = ScDrawTextCursor::getImplementation( xPropSet );
    1097         103 :         if (pDrawImp)
    1098             :         {
    1099           7 :             XMLTableShapeImportHelper* pTableShapeImport = (XMLTableShapeImportHelper*)GetScImport().GetShapeImport().get();
    1100           7 :             ScXMLAnnotationContext* pAnnotationContext = pTableShapeImport->GetAnnotationContext();
    1101           7 :             if (pAnnotationContext)
    1102             :             {
    1103           7 :                 pAnnotationContext->AddContentStyle( GetFamily(), GetName(), pDrawImp->GetSelection() );
    1104           7 :                 nLastSheet = rXMLImport.GetTables().GetCurrentSheet();
    1105             :             }
    1106             :         }
    1107             : 
    1108             :         // if it's a different shape, BlockSheet is called from XMLTableShapeImportHelper::finishShape
    1109             :         // formatted text in page headers/footers can be ignored
    1110             :     }
    1111         202 : }
    1112             : 
    1113             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10