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

Generated by: LCOV version 1.10