LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmlfmt.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 260 435 59.8 %
Date: 2014-04-11 Functions: 51 86 59.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10