LCOV - code coverage report
Current view: top level - sc/source/filter/xml - xmlstyli.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 521 0.0 %
Date: 2014-04-14 Functions: 0 71 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10