LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/xml - xmlfmt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 204 427 47.8 %
Date: 2012-12-27 Functions: 48 86 55.8 %
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 <rtl/ustrbuf.hxx>
      21             : 
      22             : #include <xmloff/nmspmap.hxx>
      23             : #include <format.hxx>
      24             : #include <fmtcol.hxx>
      25             : #include <hints.hxx>
      26             : #include <poolfmt.hxx>
      27             : #include <charfmt.hxx>
      28             : #include <paratr.hxx>
      29             : #include <doc.hxx>
      30             : #include "docary.hxx"
      31             : #include "unostyle.hxx"
      32             : #include "fmtpdsc.hxx"
      33             : #include "pagedesc.hxx"
      34             : #include <xmloff/xmlnmspe.hxx>
      35             : #include <xmloff/i18nmap.hxx>
      36             : #include <xmloff/xmltkmap.hxx>
      37             : #include "xmlitem.hxx"
      38             : #include <xmloff/xmlstyle.hxx>
      39             : #include <xmloff/txtstyli.hxx>
      40             : #include <xmloff/txtimp.hxx>
      41             : #include <xmloff/families.hxx>
      42             : #include <xmloff/XMLTextMasterStylesContext.hxx>
      43             : #include <xmloff/XMLTextShapeStyleContext.hxx>
      44             : #include <xmloff/XMLGraphicsDefaultStyle.hxx>
      45             : #include "xmlimp.hxx"
      46             : #include "xmltbli.hxx"
      47             : #include "cellatr.hxx"
      48             : #include <SwStyleNameMapper.hxx>
      49             : #include <xmloff/attrlist.hxx>
      50             : #include <unotxdoc.hxx>
      51             : #include <docsh.hxx>
      52             : 
      53             : 
      54             : using namespace ::com::sun::star;
      55             : using ::rtl::OUString;
      56             : using ::rtl::OUStringBuffer;
      57             : using namespace ::xmloff::token;
      58             : 
      59           0 : class SwXMLConditionParser_Impl
      60             : {
      61             :     OUString sInput;
      62             : 
      63             :     sal_uInt32 nCondition;
      64             :     sal_uInt32 nSubCondition;
      65             : 
      66             :     sal_Int32 nPos;
      67             :     sal_Int32 nLength;
      68             : 
      69             :     inline sal_Bool SkipWS();
      70             :     inline sal_Bool MatchChar( sal_Unicode c );
      71             :     inline sal_Bool MatchName( OUString& rName );
      72             :     inline sal_Bool MatchNumber( sal_uInt32& rNumber );
      73             : 
      74             : public:
      75             : 
      76             :     SwXMLConditionParser_Impl( const OUString& rInp );
      77             : 
      78           0 :     sal_Bool IsValid() const { return 0 != nCondition; }
      79             : 
      80           0 :     sal_uInt32 GetCondition() const { return nCondition; }
      81           0 :     sal_uInt32 GetSubCondition() const { return nSubCondition; }
      82             : };
      83             : 
      84           0 : inline sal_Bool SwXMLConditionParser_Impl::SkipWS()
      85             : {
      86           0 :     while( nPos < nLength && ' ' == sInput[nPos] )
      87           0 :         nPos++;
      88           0 :     return sal_True;
      89             : }
      90             : 
      91           0 : inline sal_Bool SwXMLConditionParser_Impl::MatchChar( sal_Unicode c )
      92             : {
      93           0 :     sal_Bool bRet = sal_False;
      94           0 :     if( nPos < nLength && c == sInput[nPos] )
      95             :     {
      96           0 :         nPos++;
      97           0 :         bRet = sal_True;
      98             :     }
      99           0 :     return bRet;
     100             : }
     101             : 
     102           0 : inline sal_Bool SwXMLConditionParser_Impl::MatchName( OUString& rName )
     103             : {
     104           0 :     OUStringBuffer sBuffer( nLength );
     105           0 :     while( nPos < nLength &&
     106           0 :            ( ('a' <= sInput[nPos] && sInput[nPos] <= 'z') ||
     107           0 :               '-' == sInput[nPos] ) )
     108             :     {
     109           0 :         sBuffer.append( sInput[nPos] );
     110           0 :         nPos++;
     111             :     }
     112           0 :     rName = sBuffer.makeStringAndClear();
     113           0 :     return !rName.isEmpty();
     114             : }
     115             : 
     116           0 : inline sal_Bool SwXMLConditionParser_Impl::MatchNumber( sal_uInt32& rNumber )
     117             : {
     118           0 :     OUStringBuffer sBuffer( nLength );
     119           0 :     while( nPos < nLength && '0' <= sInput[nPos] && sInput[nPos] <= '9' )
     120             :     {
     121           0 :         sBuffer.append( sInput[nPos] );
     122           0 :         nPos++;
     123             :     }
     124             : 
     125           0 :     OUString sNum( sBuffer.makeStringAndClear() );
     126           0 :     if( !sNum.isEmpty() )
     127           0 :         rNumber = sNum.toInt32();
     128           0 :     return !sNum.isEmpty();
     129             : }
     130             : 
     131           0 : SwXMLConditionParser_Impl::SwXMLConditionParser_Impl( const OUString& rInp ) :
     132             :     sInput( rInp ),
     133             :     nCondition( 0 ),
     134             :     nSubCondition( 0 ),
     135             :     nPos( 0 ),
     136           0 :     nLength( rInp.getLength() )
     137             : {
     138           0 :     OUString sFunc;
     139           0 :     sal_Bool bHasSub = sal_False;
     140           0 :     sal_uInt32 nSub = 0;
     141           0 :     sal_Bool bOK = SkipWS() && MatchName( sFunc ) && SkipWS() &&
     142           0 :                MatchChar( '(' ) && SkipWS() && MatchChar( ')' ) && SkipWS();
     143           0 :     if( bOK && MatchChar( '=' ) )
     144             :     {
     145           0 :         bOK = SkipWS() && MatchNumber( nSub ) && SkipWS();
     146           0 :         bHasSub = sal_True;
     147             :     }
     148             : 
     149           0 :     bOK &= nPos == nLength;
     150             : 
     151           0 :     if( bOK )
     152             :     {
     153           0 :         if( IsXMLToken( sFunc, XML_ENDNOTE ) && !bHasSub )
     154           0 :             nCondition = PARA_IN_ENDNOTE;
     155           0 :         else if( IsXMLToken( sFunc, XML_FOOTER ) && !bHasSub )
     156           0 :             nCondition = PARA_IN_FOOTER;
     157           0 :         else if( IsXMLToken( sFunc, XML_FOOTNOTE ) && !bHasSub )
     158           0 :             nCondition = PARA_IN_FOOTENOTE;
     159           0 :         else if( IsXMLToken( sFunc, XML_HEADER ) && !bHasSub )
     160           0 :             nCondition = PARA_IN_HEADER;
     161           0 :         else if( IsXMLToken( sFunc, XML_LIST_LEVEL) &&
     162             :                 nSub >=1 && nSub <= MAXLEVEL )
     163             :         {
     164           0 :             nCondition = PARA_IN_LIST;
     165           0 :             nSubCondition = nSub-1;
     166             :         }
     167           0 :         else if( IsXMLToken( sFunc, XML_OUTLINE_LEVEL) &&
     168             :                  nSub >=1 && nSub <= MAXLEVEL )
     169             :         {
     170           0 :             nCondition = PARA_IN_OUTLINE;
     171           0 :             nSubCondition = nSub-1;
     172             :         }
     173           0 :         else if( IsXMLToken( sFunc, XML_SECTION ) && !bHasSub )
     174             :         {
     175           0 :             nCondition = PARA_IN_SECTION;
     176             :         }
     177           0 :         else if( IsXMLToken( sFunc, XML_TABLE ) && !bHasSub )
     178             :         {
     179           0 :             nCondition = PARA_IN_TABLEBODY;
     180             :         }
     181           0 :         else if( IsXMLToken( sFunc, XML_TABLE_HEADER ) && !bHasSub )
     182             :         {
     183           0 :             nCondition = PARA_IN_TABLEHEAD;
     184             :         }
     185           0 :         else if( IsXMLToken( sFunc, XML_TEXT_BOX ) && !bHasSub )
     186             :         {
     187           0 :             nCondition = PARA_IN_FRAME;
     188             :         }
     189           0 :     }
     190           0 : }
     191             : 
     192             : // ---------------------------------------------------------------------
     193             : 
     194             : class SwXMLConditionContext_Impl : public SvXMLImportContext
     195             : {
     196             :     sal_uInt32 nCondition;
     197             :     sal_uInt32 nSubCondition;
     198             : 
     199             :     OUString sApplyStyle;
     200             : 
     201             :     void ParseCondition( const OUString& rCond );
     202             : 
     203             : public:
     204             : 
     205             :     SwXMLConditionContext_Impl(
     206             :             SvXMLImport& rImport, sal_uInt16 nPrfx,
     207             :             const OUString& rLName,
     208             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList );
     209             :     virtual ~SwXMLConditionContext_Impl();
     210             : 
     211             :     TYPEINFO();
     212             : 
     213           0 :     sal_Bool IsValid() const { return 0 != nCondition; }
     214             : 
     215           0 :     sal_uInt32 GetCondition() const { return nCondition; }
     216           0 :     sal_uInt32 GetSubCondition() const { return nSubCondition; }
     217           0 :     const OUString& GetApplyStyle() const { return sApplyStyle; }
     218             : };
     219             : 
     220           0 : SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
     221             :             SvXMLImport& rImport, sal_uInt16 nPrfx,
     222             :             const OUString& rLName,
     223             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList ) :
     224             :     SvXMLImportContext( rImport, nPrfx, rLName ),
     225             :     nCondition( 0 ),
     226           0 :     nSubCondition( 0 )
     227             : {
     228           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     229           0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
     230             :     {
     231           0 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
     232           0 :         OUString aLocalName;
     233             :         sal_uInt16 nPrefix =
     234           0 :             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
     235           0 :                                                             &aLocalName );
     236           0 :         const OUString& rValue = xAttrList->getValueByIndex( i );
     237             : 
     238             :         // TODO: use a map here
     239           0 :         if( XML_NAMESPACE_STYLE == nPrefix )
     240             :         {
     241           0 :             if( IsXMLToken( aLocalName, XML_CONDITION ) )
     242             :             {
     243           0 :                 SwXMLConditionParser_Impl aCondParser( rValue );
     244           0 :                 if( aCondParser.IsValid() )
     245             :                 {
     246           0 :                     nCondition = aCondParser.GetCondition();
     247           0 :                     nSubCondition = aCondParser.GetSubCondition();
     248           0 :                 }
     249             :             }
     250           0 :             else if( IsXMLToken( aLocalName, XML_APPLY_STYLE_NAME ) )
     251             :             {
     252           0 :                 sApplyStyle = rValue;
     253             :             }
     254             :         }
     255           0 :     }
     256           0 : }
     257             : 
     258           0 : SwXMLConditionContext_Impl::~SwXMLConditionContext_Impl()
     259             : {
     260           0 : }
     261             : 
     262           0 : TYPEINIT1( SwXMLConditionContext_Impl, XMLTextStyleContext );
     263             : 
     264             : // ---------------------------------------------------------------------
     265             : 
     266             : typedef std::vector<SwXMLConditionContext_Impl*> SwXMLConditions_Impl;
     267             : 
     268             : class SwXMLTextStyleContext_Impl : public XMLTextStyleContext
     269             : {
     270             :     SwXMLConditions_Impl    *pConditions;
     271             : 
     272             : protected:
     273             : 
     274             :     virtual uno::Reference < style::XStyle > Create();
     275             : 
     276             : public:
     277             : 
     278             :     TYPEINFO();
     279             : 
     280             :     SwXMLTextStyleContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
     281             :             const OUString& rLName,
     282             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList,
     283             :             sal_uInt16 nFamily,
     284             :             SvXMLStylesContext& rStyles );
     285             :     virtual ~SwXMLTextStyleContext_Impl();
     286             : 
     287             :     virtual SvXMLImportContext *CreateChildContext(
     288             :             sal_uInt16 nPrefix,
     289             :             const OUString& rLocalName,
     290             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList );
     291             : 
     292             :     virtual void Finish( sal_Bool bOverwrite );
     293             : };
     294             : 
     295          90 : TYPEINIT1( SwXMLTextStyleContext_Impl, XMLTextStyleContext );
     296             : 
     297          27 : uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
     298             : {
     299          27 :     uno::Reference < style::XStyle > xNewStyle;
     300             : 
     301          27 :     if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() )
     302             :     {
     303           0 :         uno::Reference< lang::XMultiServiceFactory > xFactory( GetImport().GetModel(),
     304           0 :                                                     uno::UNO_QUERY );
     305           0 :         if( xFactory.is() )
     306             :         {
     307             :             OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM(
     308           0 :                         "com.sun.star.style.ConditionalParagraphStyle" ) );
     309             :             uno::Reference < uno::XInterface > xIfc =
     310           0 :                 xFactory->createInstance( sServiceName );
     311           0 :             if( xIfc.is() )
     312           0 :                 xNewStyle = uno::Reference < style::XStyle >( xIfc, uno::UNO_QUERY );
     313           0 :         }
     314             :     }
     315             :     else
     316             :     {
     317          27 :         xNewStyle = XMLTextStyleContext::Create();
     318             :     }
     319             : 
     320          27 :     return xNewStyle;
     321             : }
     322             : 
     323         172 : SwXMLTextStyleContext_Impl::SwXMLTextStyleContext_Impl( SwXMLImport& rImport,
     324             :         sal_uInt16 nPrfx, const OUString& rLName,
     325             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList,
     326             :         sal_uInt16 nFamily,
     327             :         SvXMLStylesContext& rStyles ) :
     328             :     XMLTextStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily ),
     329         172 :     pConditions( 0 )
     330             : {
     331         172 : }
     332             : 
     333         516 : SwXMLTextStyleContext_Impl::~SwXMLTextStyleContext_Impl()
     334             : {
     335         172 :     if( pConditions )
     336             :     {
     337           0 :         while( !pConditions->empty() )
     338             :         {
     339           0 :             SwXMLConditionContext_Impl *pCond = &*pConditions->back();
     340           0 :             pConditions->pop_back();
     341           0 :             pCond->ReleaseRef();
     342             :         }
     343           0 :         delete pConditions;
     344             :     }
     345         344 : }
     346             : 
     347         239 : SvXMLImportContext *SwXMLTextStyleContext_Impl::CreateChildContext(
     348             :         sal_uInt16 nPrefix,
     349             :         const OUString& rLocalName,
     350             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     351             : {
     352         239 :     SvXMLImportContext *pContext = 0;
     353             : 
     354         239 :     if( XML_NAMESPACE_STYLE == nPrefix && IsXMLToken( rLocalName, XML_MAP ) )
     355             :     {
     356             :         SwXMLConditionContext_Impl *pCond =
     357           0 :             new SwXMLConditionContext_Impl( GetImport(), nPrefix,
     358           0 :                                             rLocalName, xAttrList );
     359           0 :         if( pCond->IsValid() )
     360             :         {
     361           0 :             if( !pConditions )
     362           0 :                pConditions = new SwXMLConditions_Impl;
     363           0 :             pConditions->push_back( pCond );
     364           0 :             pCond->AddRef();
     365             :         }
     366           0 :         pContext = pCond;
     367             :     }
     368             : 
     369         239 :     if( !pContext )
     370             :         pContext = XMLTextStyleContext::CreateChildContext( nPrefix, rLocalName,
     371         239 :                                                           xAttrList );
     372             : 
     373         239 :     return pContext;
     374             : }
     375             : 
     376         151 : void SwXMLTextStyleContext_Impl::Finish( sal_Bool bOverwrite )
     377             : {
     378         151 :     XMLTextStyleContext::Finish( bOverwrite );
     379             : 
     380         151 :     if( !pConditions || XML_STYLE_FAMILY_TEXT_PARAGRAPH != GetFamily() )
     381             :         return;
     382             : 
     383           0 :     uno::Reference < style::XStyle > xStyle = GetStyle();
     384           0 :     if( !xStyle.is() )
     385             :         return;
     386             : 
     387           0 :     const SwXStyle* pStyle = 0;
     388           0 :     uno::Reference<lang::XUnoTunnel> xStyleTunnel( xStyle, uno::UNO_QUERY);
     389           0 :     if( xStyleTunnel.is() )
     390             :     {
     391             :         pStyle = reinterpret_cast< SwXStyle * >(
     392           0 :                 sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId() )));
     393             :     }
     394           0 :     if( !pStyle )
     395             :         return;
     396             : 
     397           0 :     const SwDoc *pDoc = pStyle->GetDoc();
     398             : 
     399           0 :     SwTxtFmtColl *pColl = pDoc->FindTxtFmtCollByName( pStyle->GetStyleName() );
     400             :     OSL_ENSURE( pColl, "Text collection not found" );
     401           0 :     if( !pColl || RES_CONDTXTFMTCOLL != pColl->Which() )
     402             :         return;
     403             : 
     404           0 :     sal_uInt16 nCount = pConditions->size();
     405           0 :     String aString;
     406           0 :     OUString sName;
     407           0 :     for( sal_uInt16 i = 0; i < nCount; i++ )
     408             :     {
     409           0 :         const SwXMLConditionContext_Impl *pCond = (*pConditions)[i];
     410             :         OUString aDisplayName(
     411           0 :             GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
     412           0 :                 pCond->GetApplyStyle() ) );
     413             :         SwStyleNameMapper::FillUIName( aDisplayName,
     414             :                                       aString,
     415             :                                       nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL,
     416           0 :                                       true);
     417           0 :         sName = aString;
     418           0 :         SwTxtFmtColl* pCondColl = pDoc->FindTxtFmtCollByName( sName );
     419             :         OSL_ENSURE( pCondColl,
     420             :             "SwXMLItemSetStyleContext_Impl::ConnectConditions: cond coll missing" );
     421           0 :         if( pCondColl )
     422             :         {
     423             :             SwCollCondition aCond( pCondColl, pCond->GetCondition(),
     424           0 :                                               pCond->GetSubCondition() );
     425           0 :             ((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond );
     426             :         }
     427           0 :     }
     428             : }
     429             : 
     430             : // ---------------------------------------------------------------------
     431             : 
     432             : class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext
     433             : {
     434             :     OUString                sMasterPageName;
     435             :     SfxItemSet              *pItemSet;
     436             :     SwXMLTextStyleContext_Impl *pTextStyle;
     437             :     SvXMLStylesContext      &rStyles;
     438             : 
     439             :     OUString                sDataStyleName;
     440             : 
     441             :     sal_Bool                bHasMasterPageName : 1;
     442             :     sal_Bool                bPageDescConnected : 1;
     443             :     sal_Bool                bDataStyleIsResolved;
     444             : 
     445             :     SvXMLImportContext *CreateItemSetContext(
     446             :             sal_uInt16 nPrefix,
     447             :             const OUString& rLName,
     448             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList);
     449             : 
     450             : protected:
     451             : 
     452             :     virtual void SetAttribute( sal_uInt16 nPrefixKey,
     453             :                                const OUString& rLocalName,
     454             :                                const OUString& rValue );
     455             : 
     456             :     const SwXMLImport& GetSwImport() const
     457             :             { return (const SwXMLImport&)GetImport(); }
     458          38 :     SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
     459             : 
     460             : public:
     461             : 
     462             :     TYPEINFO();
     463             : 
     464             :     SwXMLItemSetStyleContext_Impl(
     465             :             SwXMLImport& rImport, sal_uInt16 nPrfx,
     466             :             const OUString& rLName,
     467             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList,
     468             :             SvXMLStylesContext& rStylesC,
     469             :             sal_uInt16 nFamily);
     470             :     virtual ~SwXMLItemSetStyleContext_Impl();
     471             : 
     472             :        virtual void CreateAndInsert( sal_Bool bOverwrite );
     473             :     virtual SvXMLImportContext *CreateChildContext(
     474             :             sal_uInt16 nPrefix,
     475             :             const OUString& rLocalName,
     476             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList );
     477             : 
     478             :     // The item set may be empty!
     479          19 :     SfxItemSet *GetItemSet() { return pItemSet; }
     480             :     const SfxItemSet *GetItemSet() const { return pItemSet; }
     481             : 
     482           0 :     const OUString& GetMasterPageName() const { return sMasterPageName; }
     483           1 :     sal_Bool HasMasterPageName() const { return bHasMasterPageName; }
     484             : 
     485           0 :     sal_Bool IsPageDescConnected() const { return bPageDescConnected; }
     486             :     void ConnectPageDesc();
     487             : 
     488             :     sal_Bool ResolveDataStyleName();
     489             : };
     490             : 
     491          38 : void SwXMLItemSetStyleContext_Impl::SetAttribute( sal_uInt16 nPrefixKey,
     492             :                                            const OUString& rLocalName,
     493             :                                            const OUString& rValue )
     494             : {
     495          38 :     if( XML_NAMESPACE_STYLE == nPrefixKey )
     496             :     {
     497          38 :         if ( IsXMLToken( rLocalName, XML_MASTER_PAGE_NAME ) )
     498             :         {
     499           0 :             sMasterPageName = rValue;
     500           0 :             bHasMasterPageName = sal_True;
     501             :         }
     502          38 :         else if ( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
     503             :         {
     504             :             // if we have a valid data style name
     505           0 :             if (!rValue.isEmpty())
     506             :             {
     507           0 :                 sDataStyleName = rValue;
     508           0 :                 bDataStyleIsResolved = sal_False;   // needs to be resolved
     509             :             }
     510             :         }
     511             :         else
     512             :         {
     513          38 :             SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
     514             :         }
     515             :     }
     516             :     else
     517             :     {
     518           0 :         SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
     519             :     }
     520          38 : }
     521             : 
     522          19 : SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext(
     523             :         sal_uInt16 nPrefix, const OUString& rLName,
     524             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     525             : {
     526             :     OSL_ENSURE( !pItemSet,
     527             :             "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: item set exists" );
     528             : 
     529          19 :     SvXMLImportContext *pContext = 0;
     530             : 
     531          19 :     SwDoc* pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
     532             : 
     533          19 :     SfxItemPool& rItemPool = pDoc->GetAttrPool();
     534          19 :     switch( GetFamily() )
     535             :     {
     536             :     case XML_STYLE_FAMILY_TABLE_TABLE:
     537           1 :         pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
     538           1 :         break;
     539             :     case XML_STYLE_FAMILY_TABLE_COLUMN:
     540           1 :         pItemSet = new SfxItemSet( rItemPool, RES_FRM_SIZE, RES_FRM_SIZE, 0 );
     541           1 :         break;
     542             :     case XML_STYLE_FAMILY_TABLE_ROW:
     543           0 :         pItemSet = new SfxItemSet( rItemPool, aTableLineSetRange );
     544           0 :         break;
     545             :     case XML_STYLE_FAMILY_TABLE_CELL:
     546          17 :         pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
     547          17 :         break;
     548             :     default:
     549             :         OSL_ENSURE( !this,
     550             :         "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: unknown family" );
     551           0 :         break;
     552             :     }
     553          19 :     if( pItemSet )
     554          19 :         pContext = GetSwImport().CreateTableItemImportContext(
     555          19 :                                 nPrefix, rLName, xAttrList, GetFamily(),
     556          57 :                                 *pItemSet );
     557          19 :     if( !pContext )
     558             :     {
     559           0 :         delete pItemSet;
     560           0 :         pItemSet = 0;
     561             :     }
     562             : 
     563          19 :     return pContext;
     564             : }
     565             : 
     566          76 : TYPEINIT1( SwXMLItemSetStyleContext_Impl, SvXMLStyleContext );
     567             : 
     568          19 : SwXMLItemSetStyleContext_Impl::SwXMLItemSetStyleContext_Impl( SwXMLImport& rImport,
     569             :         sal_uInt16 nPrfx, const OUString& rLName,
     570             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList,
     571             :         SvXMLStylesContext& rStylesC,
     572             :         sal_uInt16 nFamily ) :
     573             :     SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList, nFamily ),
     574             :     pItemSet( 0 ),
     575             :     pTextStyle( 0 ),
     576             :     rStyles( rStylesC ),
     577             :     bHasMasterPageName( sal_False ),
     578             :     bPageDescConnected( sal_False ),
     579          19 :     bDataStyleIsResolved( sal_True )
     580             : {
     581          19 : }
     582             : 
     583          57 : SwXMLItemSetStyleContext_Impl::~SwXMLItemSetStyleContext_Impl()
     584             : {
     585          19 :     delete pItemSet;
     586          38 : }
     587             : 
     588          17 : void SwXMLItemSetStyleContext_Impl::CreateAndInsert( sal_Bool bOverwrite )
     589             : {
     590          17 :     if( pTextStyle )
     591           0 :         pTextStyle->CreateAndInsert( bOverwrite );
     592          17 : }
     593             : 
     594          19 : SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateChildContext(
     595             :         sal_uInt16 nPrefix,
     596             :         const OUString& rLocalName,
     597             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     598             : {
     599          19 :     SvXMLImportContext *pContext = 0;
     600             : 
     601          19 :     if( XML_NAMESPACE_STYLE == nPrefix )
     602             :     {
     603          71 :         if( IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) ||
     604          18 :             IsXMLToken( rLocalName, XML_TABLE_COLUMN_PROPERTIES ) ||
     605          17 :             IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) ||
     606          17 :             IsXMLToken( rLocalName, XML_TABLE_CELL_PROPERTIES ) )
     607             :         {
     608          19 :             pContext = CreateItemSetContext( nPrefix, rLocalName, xAttrList );
     609             :         }
     610           0 :         else if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) ||
     611           0 :                  IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ))
     612             :         {
     613           0 :             if( !pTextStyle )
     614             :             {
     615           0 :                 SvXMLAttributeList *pTmp = new SvXMLAttributeList;
     616           0 :                 OUString aStr = GetImport().GetNamespaceMap().GetQNameByKey( nPrefix, GetXMLToken(XML_NAME) );
     617           0 :                 pTmp->AddAttribute( aStr, GetName() );
     618           0 :                 uno::Reference <xml::sax::XAttributeList> xTmpAttrList = pTmp;
     619             :                 pTextStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), nPrefix,
     620           0 :                                  rLocalName, xTmpAttrList, XML_STYLE_FAMILY_TEXT_PARAGRAPH, rStyles );
     621           0 :                 pTextStyle->StartElement( xTmpAttrList );
     622           0 :                 rStyles.AddStyle( *pTextStyle );
     623             :             }
     624           0 :             pContext = pTextStyle->CreateChildContext( nPrefix, rLocalName, xAttrList );
     625             :         }
     626             :     }
     627             : 
     628          19 :     if( !pContext )
     629             :         pContext = SvXMLStyleContext::CreateChildContext( nPrefix, rLocalName,
     630           0 :                                                           xAttrList );
     631             : 
     632          19 :     return pContext;
     633             : }
     634             : 
     635           0 : void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
     636             : {
     637           0 :     if( bPageDescConnected || !HasMasterPageName() )
     638             :         return;
     639           0 :     bPageDescConnected = sal_True;
     640             : 
     641           0 :     SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
     642             : 
     643           0 :     String sName;
     644             :     // #i40788# - first determine the display name of the page style,
     645             :     // then map this name to the corresponding user interface name.
     646           0 :     sName = GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_MASTER_PAGE,
     647           0 :                                              GetMasterPageName() );
     648             :     SwStyleNameMapper::FillUIName( sName,
     649             :                                    sName,
     650             :                                    nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC,
     651           0 :                                    true);
     652           0 :     SwPageDesc *pPageDesc = pDoc->FindPageDescByName( sName );
     653           0 :     if( !pPageDesc )
     654             :     {
     655             :         // If the page style is a pool style, then we maybe have to create it
     656             :         // first if it hasn't been used by now.
     657           0 :         sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
     658           0 :         if( USHRT_MAX != nPoolId )
     659           0 :             pPageDesc = pDoc->GetPageDescFromPool( nPoolId, false );
     660             :     }
     661             : 
     662           0 :     if( !pPageDesc )
     663             :         return;
     664             : 
     665           0 :     if( !pItemSet )
     666             :     {
     667           0 :         SfxItemPool& rItemPool = pDoc->GetAttrPool();
     668           0 :         pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
     669             :     }
     670             : 
     671             :     const SfxPoolItem *pItem;
     672           0 :     SwFmtPageDesc *pFmtPageDesc = 0;
     673           0 :     if( SFX_ITEM_SET == pItemSet->GetItemState( RES_PAGEDESC, sal_False,
     674           0 :                                                 &pItem ) )
     675             :     {
     676           0 :          if( ((SwFmtPageDesc *)pItem)->GetPageDesc() != pPageDesc )
     677           0 :             pFmtPageDesc = new SwFmtPageDesc( *(SwFmtPageDesc *)pItem );
     678             :     }
     679             :     else
     680           0 :         pFmtPageDesc = new SwFmtPageDesc();
     681             : 
     682           0 :     if( pFmtPageDesc )
     683             :     {
     684           0 :         pFmtPageDesc->RegisterToPageDesc( *pPageDesc );
     685           0 :         pItemSet->Put( *pFmtPageDesc );
     686           0 :         delete pFmtPageDesc;
     687           0 :     }
     688             : }
     689             : 
     690          17 : sal_Bool SwXMLItemSetStyleContext_Impl::ResolveDataStyleName()
     691             : {
     692             :     // resolve, if not already done
     693          17 :     if (! bDataStyleIsResolved)
     694             :     {
     695             :         // get the format key
     696             :         sal_Int32 nFormat =
     697           0 :             GetImport().GetTextImport()->GetDataStyleKey(sDataStyleName);
     698             : 
     699             :         // if the key is valid, insert Item into ItemSet
     700           0 :         if( -1 != nFormat )
     701             :         {
     702           0 :             if( !pItemSet )
     703             :             {
     704           0 :                 SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
     705             : 
     706           0 :                 SfxItemPool& rItemPool = pDoc->GetAttrPool();
     707           0 :                 pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
     708             :             }
     709           0 :             SwTblBoxNumFormat aNumFormatItem(nFormat);
     710           0 :             pItemSet->Put(aNumFormatItem);
     711             :         }
     712             : 
     713             :         // now resolved
     714           0 :         bDataStyleIsResolved = sal_True;
     715           0 :         return sal_True;
     716             :     }
     717             :     else
     718             :     {
     719             :         // was already resolved; nothing to do
     720          17 :         return sal_False;
     721             :     }
     722             : }
     723             : 
     724             : // ---------------------------------------------------------------------
     725             : //
     726             : class SwXMLStylesContext_Impl : public SvXMLStylesContext
     727             : {
     728             :     SwXMLItemSetStyleContext_Impl *GetSwStyle( sal_uInt16 i ) const;
     729             : 
     730         242 :     SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
     731         777 :     const SwXMLImport& GetSwImport() const
     732         777 :             { return (const SwXMLImport&)GetImport(); }
     733             : 
     734             : protected:
     735             : 
     736             :     virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
     737             :         sal_uInt16 nPrefix, const OUString& rLocalName,
     738             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList );
     739             :     virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
     740             :         sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
     741             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList );
     742             :     // HACK
     743             :     virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
     744             :         sal_uInt16 nFamily ) const;
     745             : 
     746             :     virtual uno::Reference < container::XNameContainer >
     747             :         GetStylesContainer( sal_uInt16 nFamily ) const;
     748             :     virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const;
     749             :     // HACK
     750             : 
     751             : public:
     752             : 
     753             :     TYPEINFO();
     754             : 
     755             :     SwXMLStylesContext_Impl(
     756             :             SwXMLImport& rImport, sal_uInt16 nPrfx,
     757             :             const OUString& rLName ,
     758             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList,
     759             :             sal_Bool bAuto );
     760             :     virtual ~SwXMLStylesContext_Impl();
     761             : 
     762             :     virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const;
     763             : 
     764             :     virtual void EndElement();
     765             : };
     766             : 
     767           0 : TYPEINIT1( SwXMLStylesContext_Impl, SvXMLStylesContext );
     768             : 
     769             : inline SwXMLItemSetStyleContext_Impl *SwXMLStylesContext_Impl::GetSwStyle(
     770             :         sal_uInt16 i ) const
     771             : {
     772             :     return PTR_CAST( SwXMLItemSetStyleContext_Impl, GetStyle( i ) );
     773             : }
     774             : 
     775         234 : SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleStyleChildContext(
     776             :         sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
     777             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     778             : {
     779         234 :     SvXMLStyleContext *pStyle = 0;
     780             : 
     781         234 :     switch( nFamily )
     782             :     {
     783             :     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
     784             :         pStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), nPrefix,
     785         172 :                             rLocalName, xAttrList, nFamily, *this );
     786         172 :         break;
     787             :     case XML_STYLE_FAMILY_TABLE_TABLE:
     788             :     case XML_STYLE_FAMILY_TABLE_COLUMN:
     789             :     case XML_STYLE_FAMILY_TABLE_ROW:
     790             :     case XML_STYLE_FAMILY_TABLE_CELL:
     791             :         pStyle = new SwXMLItemSetStyleContext_Impl( GetSwImport(), nPrefix,
     792          19 :                             rLocalName, xAttrList, *this, nFamily  );
     793          19 :         break;
     794             :     case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
     795             :         // As long as there are no element items, we can use the text
     796             :         // style class.
     797           8 :         pStyle = new XMLTextShapeStyleContext( GetImport(), nPrefix,
     798           8 :                             rLocalName, xAttrList, *this, nFamily );
     799           8 :         break;
     800             :     default:
     801             :         pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily,
     802             :                                                                    nPrefix,
     803             :                                                               rLocalName,
     804          35 :                                                               xAttrList );
     805          35 :         break;
     806             :     }
     807             : 
     808         234 :     return pStyle;
     809             : }
     810             : 
     811          68 : SvXMLStyleContext *SwXMLStylesContext_Impl::CreateDefaultStyleStyleChildContext(
     812             :         sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
     813             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     814             : {
     815          68 :     SvXMLStyleContext *pStyle = 0;
     816             : 
     817          68 :     switch( nFamily )
     818             :     {
     819             :     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
     820             :     case XML_STYLE_FAMILY_TABLE_TABLE:
     821             :     case XML_STYLE_FAMILY_TABLE_ROW:
     822          51 :         pStyle = new XMLTextStyleContext( GetImport(), nPrefix, rLocalName,
     823             :                                           xAttrList, *this, nFamily,
     824          51 :                                           sal_True );
     825          51 :         break;
     826             :     case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
     827             :         // There are no writer specific defaults for graphic styles!
     828          17 :         pStyle = new XMLGraphicsDefaultStyle( GetImport(), nPrefix,
     829          17 :                             rLocalName, xAttrList, *this );
     830          17 :         break;
     831             :     default:
     832             :         pStyle = SvXMLStylesContext::CreateDefaultStyleStyleChildContext( nFamily,
     833             :                                                                    nPrefix,
     834             :                                                               rLocalName,
     835           0 :                                                               xAttrList );
     836           0 :         break;
     837             :     }
     838             : 
     839          68 :     return pStyle;
     840             : }
     841             : 
     842             : 
     843          51 : SwXMLStylesContext_Impl::SwXMLStylesContext_Impl(
     844             :         SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
     845             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList,
     846             :         sal_Bool bAuto ) :
     847          51 :     SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList, bAuto )
     848             : {
     849          51 : }
     850             : 
     851         102 : SwXMLStylesContext_Impl::~SwXMLStylesContext_Impl()
     852             : {
     853         102 : }
     854             : 
     855         777 : sal_Bool SwXMLStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const
     856             : {
     857         777 :     const SwXMLImport& rSwImport = GetSwImport();
     858         777 :     sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
     859             : 
     860         777 :     sal_Bool bIns = sal_True;
     861         777 :     switch( nFamily )
     862             :     {
     863             :     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
     864         453 :         bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PARA) != 0;
     865         453 :         break;
     866             :     case XML_STYLE_FAMILY_TEXT_TEXT:
     867          87 :         bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_CHAR) != 0;
     868          87 :         break;
     869             :     case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
     870           9 :         bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_FRAME) != 0;
     871           9 :         break;
     872             :     case XML_STYLE_FAMILY_TEXT_LIST:
     873          24 :         bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PSEUDO) != 0;
     874          24 :         break;
     875             :     case XML_STYLE_FAMILY_TEXT_OUTLINE:
     876             :     case XML_STYLE_FAMILY_TEXT_FOOTNOTECONFIG:
     877             :     case XML_STYLE_FAMILY_TEXT_ENDNOTECONFIG:
     878             :     case XML_STYLE_FAMILY_TEXT_LINENUMBERINGCONFIG:
     879             :     case XML_STYLE_FAMILY_TEXT_BIBLIOGRAPHYCONFIG:
     880         408 :         bIns = !(rSwImport.IsInsertMode() || rSwImport.IsStylesOnlyMode() ||
     881         408 :                  rSwImport.IsBlockMode());
     882         204 :         break;
     883             :     default:
     884           0 :         bIns = SvXMLStylesContext::InsertStyleFamily( nFamily );
     885           0 :         break;
     886             :     }
     887             : 
     888         777 :     return bIns;
     889             : }
     890             : 
     891        1009 : UniReference < SvXMLImportPropertyMapper > SwXMLStylesContext_Impl::GetImportPropertyMapper(
     892             :         sal_uInt16 nFamily ) const
     893             : {
     894        1009 :     UniReference < SvXMLImportPropertyMapper > xMapper;
     895        1009 :     if( nFamily == XML_STYLE_FAMILY_TABLE_TABLE )
     896             :         xMapper = XMLTextImportHelper::CreateTableDefaultExtPropMapper(
     897          34 :             const_cast<SwXMLStylesContext_Impl*>( this )->GetImport() );
     898         975 :     else if( nFamily == XML_STYLE_FAMILY_TABLE_ROW )
     899             :         xMapper = XMLTextImportHelper::CreateTableRowDefaultExtPropMapper(
     900          34 :             const_cast<SwXMLStylesContext_Impl*>( this )->GetImport() );
     901             :     else
     902         941 :         xMapper = SvXMLStylesContext::GetImportPropertyMapper( nFamily );
     903        1009 :     return xMapper;
     904             : }
     905             : 
     906         366 : uno::Reference < container::XNameContainer > SwXMLStylesContext_Impl::GetStylesContainer(
     907             :                                                 sal_uInt16 nFamily ) const
     908             : {
     909         366 :     uno::Reference < container::XNameContainer > xStyles;
     910         366 :     if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
     911           6 :         xStyles = ((SvXMLImport *)&GetImport())->GetTextImport()->GetFrameStyles();
     912             :     else
     913         360 :         xStyles = SvXMLStylesContext::GetStylesContainer( nFamily );
     914             : 
     915         366 :     return xStyles;
     916             : }
     917             : 
     918          48 : OUString SwXMLStylesContext_Impl::GetServiceName( sal_uInt16 nFamily ) const
     919             : {
     920          48 :     String sServiceName;
     921          48 :     if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
     922           0 :         sServiceName = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.FrameStyle") );
     923             :     else
     924          48 :         sServiceName = SvXMLStylesContext::GetServiceName( nFamily );
     925             : 
     926          48 :     return sServiceName;
     927             : }
     928             : 
     929          51 : void SwXMLStylesContext_Impl::EndElement()
     930             : {
     931          51 :     GetSwImport().InsertStyles( IsAutomaticStyle() );
     932          51 : }
     933             : 
     934             : // ---------------------------------------------------------------------
     935             : //
     936             : class SwXMLMasterStylesContext_Impl : public XMLTextMasterStylesContext
     937             : {
     938             : protected:
     939             :     virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const;
     940             : 
     941          34 :     SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
     942          56 :     const SwXMLImport& GetSwImport() const
     943          56 :             { return (const SwXMLImport&)GetImport(); }
     944             : 
     945             : public:
     946             : 
     947             :     TYPEINFO();
     948             : 
     949             :     SwXMLMasterStylesContext_Impl(
     950             :             SwXMLImport& rImport, sal_uInt16 nPrfx,
     951             :             const OUString& rLName ,
     952             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList );
     953             :     virtual ~SwXMLMasterStylesContext_Impl();
     954             :     virtual void EndElement();
     955             : };
     956             : 
     957           0 : TYPEINIT1( SwXMLMasterStylesContext_Impl, XMLTextMasterStylesContext );
     958             : 
     959          17 : SwXMLMasterStylesContext_Impl::SwXMLMasterStylesContext_Impl(
     960             :         SwXMLImport& rImport, sal_uInt16 nPrfx,
     961             :         const OUString& rLName ,
     962             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList ) :
     963          17 :     XMLTextMasterStylesContext( rImport, nPrfx, rLName, xAttrList )
     964             : {
     965          17 : }
     966             : 
     967          34 : SwXMLMasterStylesContext_Impl::~SwXMLMasterStylesContext_Impl()
     968             : {
     969          34 : }
     970             : 
     971          56 : sal_Bool SwXMLMasterStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const
     972             : {
     973             :     sal_Bool bIns;
     974             : 
     975          56 :     const SwXMLImport& rSwImport = GetSwImport();
     976          56 :     sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
     977          56 :     if( XML_STYLE_FAMILY_MASTER_PAGE == nFamily )
     978          56 :         bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PAGE) != 0;
     979             :     else
     980           0 :         bIns = XMLTextMasterStylesContext::InsertStyleFamily( nFamily );
     981             : 
     982          56 :     return bIns;
     983             : }
     984             : 
     985          17 : void SwXMLMasterStylesContext_Impl::EndElement()
     986             : {
     987          17 :     FinishStyles( !GetSwImport().IsInsertMode() );
     988          17 :     GetSwImport().FinishStyles();
     989          17 : }
     990             : // ---------------------------------------------------------------------
     991             : 
     992          51 : SvXMLImportContext *SwXMLImport::CreateStylesContext(
     993             :         const OUString& rLocalName,
     994             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList,
     995             :         sal_Bool bAuto )
     996             : {
     997             :     SvXMLStylesContext *pContext =
     998             :         new SwXMLStylesContext_Impl( *this, XML_NAMESPACE_OFFICE, rLocalName,
     999          51 :                                        xAttrList, bAuto );
    1000          51 :     if( bAuto )
    1001          34 :         SetAutoStyles( pContext );
    1002             :     else
    1003          17 :         SetStyles( pContext );
    1004             : 
    1005          51 :     return pContext;
    1006             : }
    1007             : 
    1008          17 : SvXMLImportContext *SwXMLImport::CreateMasterStylesContext(
    1009             :         const OUString& rLocalName,
    1010             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
    1011             : {
    1012             :     SvXMLStylesContext *pContext =
    1013             :         new SwXMLMasterStylesContext_Impl( *this, XML_NAMESPACE_OFFICE, rLocalName,
    1014          17 :                                           xAttrList );
    1015          17 :     SetMasterStyles( pContext );
    1016             : 
    1017          17 :     return pContext;
    1018             : }
    1019             : 
    1020          51 : void SwXMLImport::InsertStyles( sal_Bool bAuto )
    1021             : {
    1022          51 :     if( bAuto && GetAutoStyles() )
    1023          34 :         GetAutoStyles()->CopyAutoStylesToDoc();
    1024          51 :     if( !bAuto && GetStyles() )
    1025          17 :         GetStyles()->CopyStylesToDoc( !IsInsertMode(), sal_False );
    1026          51 : }
    1027             : 
    1028          17 : void SwXMLImport::FinishStyles()
    1029             : {
    1030          17 :     if( GetStyles() )
    1031          17 :         GetStyles()->FinishStyles( !IsInsertMode() );
    1032          17 : }
    1033             : 
    1034          17 : void SwXMLImport::UpdateTxtCollConditions( SwDoc *pDoc )
    1035             : {
    1036          17 :     if( !pDoc )
    1037           0 :         pDoc = SwImport::GetDocFromXMLImport( *this );
    1038             : 
    1039          17 :     const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls();
    1040          17 :     sal_uInt16 nCount = rColls.size();
    1041         185 :     for( sal_uInt16 i=0; i < nCount; i++ )
    1042             :     {
    1043         168 :         SwTxtFmtColl *pColl = rColls[i];
    1044         168 :         if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() )
    1045             :         {
    1046             :             const SwFmtCollConditions& rConditions =
    1047          17 :                 ((const SwConditionTxtFmtColl *)pColl)->GetCondColls();
    1048          17 :             sal_Bool bSendModify = sal_False;
    1049          17 :             for( sal_uInt16 j=0; j < rConditions.size() && !bSendModify; j++ )
    1050             :             {
    1051           0 :                 const SwCollCondition& rCond = rConditions[j];
    1052           0 :                 switch( rCond.GetCondition() )
    1053             :                 {
    1054             :                 case PARA_IN_TABLEHEAD:
    1055             :                 case PARA_IN_TABLEBODY:
    1056             :                 case PARA_IN_FOOTER:
    1057             :                 case PARA_IN_HEADER:
    1058           0 :                     bSendModify = sal_True;
    1059           0 :                     break;
    1060             :                 }
    1061             :             }
    1062          17 :             if( bSendModify )
    1063             :             {
    1064           0 :                 SwCondCollCondChg aMsg( pColl );
    1065           0 :                 pColl->ModifyNotification( &aMsg, &aMsg );
    1066             :             }
    1067             :         }
    1068             :     }
    1069          17 : }
    1070             : 
    1071          19 : sal_Bool SwXMLImport::FindAutomaticStyle(
    1072             :         sal_uInt16 nFamily,
    1073             :         const OUString& rName,
    1074             :         const SfxItemSet **ppItemSet,
    1075             :         OUString *pParent ) const
    1076             : {
    1077          19 :     SwXMLItemSetStyleContext_Impl *pStyle = 0;
    1078          19 :     if( GetAutoStyles() )
    1079             :     {
    1080          57 :         pStyle = PTR_CAST( SwXMLItemSetStyleContext_Impl,
    1081             :               GetAutoStyles()->
    1082             :                     FindStyleChildContext( nFamily, rName,
    1083          57 :                                            sal_True ) );
    1084          19 :         if( pStyle )
    1085             :         {
    1086          19 :             if( ppItemSet )
    1087             :             {
    1088          20 :                 if( XML_STYLE_FAMILY_TABLE_TABLE == pStyle->GetFamily() &&
    1089           1 :                     pStyle->HasMasterPageName() &&
    1090           0 :                     !pStyle->IsPageDescConnected() )
    1091           0 :                     pStyle->ConnectPageDesc();
    1092          19 :                 (*ppItemSet) = pStyle->GetItemSet();
    1093             : 
    1094             :                 // resolve data style name late
    1095          36 :                 if( XML_STYLE_FAMILY_TABLE_CELL == pStyle->GetFamily() &&
    1096          17 :                     pStyle->ResolveDataStyleName() )
    1097             :                 {
    1098           0 :                     (*ppItemSet) = pStyle->GetItemSet();
    1099             :                 }
    1100             : 
    1101             :             }
    1102             : 
    1103          19 :             if( pParent )
    1104           0 :                 *pParent = pStyle->GetParentName();
    1105             :         }
    1106             :     }
    1107             : 
    1108          19 :     return pStyle != 0;
    1109             : }
    1110             : 
    1111             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10