LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmlfmt.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 378 434 87.1 %
Date: 2015-06-13 12:38:46 Functions: 68 88 77.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 <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           2 : 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             :     explicit SwXMLConditionParser_Impl( const OUString& rInp );
      75             : 
      76           2 :     bool IsValid() const { return 0 != nCondition; }
      77             : 
      78           2 :     sal_uInt32 GetCondition() const { return nCondition; }
      79           2 :     sal_uInt32 GetSubCondition() const { return nSubCondition; }
      80             : };
      81             : 
      82           8 : inline bool SwXMLConditionParser_Impl::SkipWS()
      83             : {
      84          16 :     while( nPos < nLength && ' ' == sInput[nPos] )
      85           0 :         nPos++;
      86           8 :     return true;
      87             : }
      88             : 
      89           6 : inline bool SwXMLConditionParser_Impl::MatchChar( sal_Unicode c )
      90             : {
      91           6 :     bool bRet = false;
      92           6 :     if( nPos < nLength && c == sInput[nPos] )
      93             :     {
      94           4 :         nPos++;
      95           4 :         bRet = true;
      96             :     }
      97           6 :     return bRet;
      98             : }
      99             : 
     100           2 : inline bool SwXMLConditionParser_Impl::MatchName( OUString& rName )
     101             : {
     102           2 :     OUStringBuffer sBuffer( nLength );
     103          57 :     while( nPos < nLength &&
     104          38 :            ( ('a' <= sInput[nPos] && sInput[nPos] <= 'z') ||
     105           3 :               '-' == sInput[nPos] ) )
     106             :     {
     107          17 :         sBuffer.append( sInput[nPos] );
     108          17 :         nPos++;
     109             :     }
     110           2 :     rName = sBuffer.makeStringAndClear();
     111           2 :     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           2 : SwXMLConditionParser_Impl::SwXMLConditionParser_Impl( const OUString& rInp ) :
     130             :     sInput( rInp ),
     131             :     nCondition( 0 ),
     132             :     nSubCondition( 0 ),
     133             :     nPos( 0 ),
     134           2 :     nLength( rInp.getLength() )
     135             : {
     136           2 :     OUString sFunc;
     137           2 :     bool bHasSub = false;
     138           2 :     sal_uInt32 nSub = 0;
     139           6 :     bool bOK = SkipWS() && MatchName( sFunc ) && SkipWS() &&
     140           6 :                MatchChar( '(' ) && SkipWS() && MatchChar( ')' ) && SkipWS();
     141           2 :     if( bOK && MatchChar( '=' ) )
     142             :     {
     143           0 :         bOK = SkipWS() && MatchNumber( nSub ) && SkipWS();
     144           0 :         bHasSub = true;
     145             :     }
     146             : 
     147           2 :     bOK &= nPos == nLength;
     148             : 
     149           2 :     if( bOK )
     150             :     {
     151           2 :         if( IsXMLToken( sFunc, XML_ENDNOTE ) && !bHasSub )
     152           0 :             nCondition = PARA_IN_ENDNOTE;
     153           2 :         else if( IsXMLToken( sFunc, XML_FOOTER ) && !bHasSub )
     154           0 :             nCondition = PARA_IN_FOOTER;
     155           2 :         else if( IsXMLToken( sFunc, XML_FOOTNOTE ) && !bHasSub )
     156           0 :             nCondition = PARA_IN_FOOTENOTE;
     157           2 :         else if( IsXMLToken( sFunc, XML_HEADER ) && !bHasSub )
     158           0 :             nCondition = PARA_IN_HEADER;
     159           4 :         else if( IsXMLToken( sFunc, XML_LIST_LEVEL) &&
     160           2 :                 nSub >=1 && nSub <= MAXLEVEL )
     161             :         {
     162           0 :             nCondition = PARA_IN_LIST;
     163           0 :             nSubCondition = nSub-1;
     164             :         }
     165           4 :         else if( IsXMLToken( sFunc, XML_OUTLINE_LEVEL) &&
     166           2 :                  nSub >=1 && nSub <= MAXLEVEL )
     167             :         {
     168           0 :             nCondition = PARA_IN_OUTLINE;
     169           0 :             nSubCondition = nSub-1;
     170             :         }
     171           2 :         else if( IsXMLToken( sFunc, XML_SECTION ) && !bHasSub )
     172             :         {
     173           0 :             nCondition = PARA_IN_SECTION;
     174             :         }
     175           2 :         else if( IsXMLToken( sFunc, XML_TABLE ) && !bHasSub )
     176             :         {
     177           1 :             nCondition = PARA_IN_TABLEBODY;
     178             :         }
     179           1 :         else if( IsXMLToken( sFunc, XML_TABLE_HEADER ) && !bHasSub )
     180             :         {
     181           1 :             nCondition = PARA_IN_TABLEHEAD;
     182             :         }
     183           0 :         else if( IsXMLToken( sFunc, XML_TEXT_BOX ) && !bHasSub )
     184             :         {
     185           0 :             nCondition = PARA_IN_FRAME;
     186             :         }
     187           2 :     }
     188           2 : }
     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           2 :     bool IsValid() const { return 0 != nCondition; }
     208             : 
     209           2 :     sal_uInt32 GetCondition() const { return nCondition; }
     210           2 :     sal_uInt32 GetSubCondition() const { return nSubCondition; }
     211           2 :     const OUString& GetApplyStyle() const { return sApplyStyle; }
     212             : };
     213             : 
     214           2 : 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           2 :     nSubCondition( 0 )
     221             : {
     222           2 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     223           6 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
     224             :     {
     225           4 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
     226           8 :         OUString aLocalName;
     227             :         const sal_uInt16 nPrefix =
     228           4 :             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
     229           4 :                                                             &aLocalName );
     230           8 :         const OUString& rValue = xAttrList->getValueByIndex( i );
     231             : 
     232             :         // TODO: use a map here
     233           4 :         if( XML_NAMESPACE_STYLE == nPrefix )
     234             :         {
     235           4 :             if( IsXMLToken( aLocalName, XML_CONDITION ) )
     236             :             {
     237           2 :                 SwXMLConditionParser_Impl aCondParser( rValue );
     238           2 :                 if( aCondParser.IsValid() )
     239             :                 {
     240           2 :                     nCondition = aCondParser.GetCondition();
     241           2 :                     nSubCondition = aCondParser.GetSubCondition();
     242           2 :                 }
     243             :             }
     244           2 :             else if( IsXMLToken( aLocalName, XML_APPLY_STYLE_NAME ) )
     245             :             {
     246           2 :                 sApplyStyle = rValue;
     247             :             }
     248             :         }
     249           4 :     }
     250           2 : }
     251             : 
     252           4 : SwXMLConditionContext_Impl::~SwXMLConditionContext_Impl()
     253             : {
     254           4 : }
     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       11925 : TYPEINIT1( SwXMLTextStyleContext_Impl, XMLTextStyleContext );
     288             : 
     289         657 : uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
     290             : {
     291         657 :     uno::Reference < style::XStyle > xNewStyle;
     292             : 
     293         657 :     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         657 :         xNewStyle = XMLTextStyleContext::Create();
     308             :     }
     309             : 
     310         657 :     return xNewStyle;
     311             : }
     312             : 
     313        5799 : 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        5799 :     pConditions( 0 )
     320             : {
     321        5799 : }
     322             : 
     323       17397 : SwXMLTextStyleContext_Impl::~SwXMLTextStyleContext_Impl()
     324             : {
     325        5799 :     if( pConditions )
     326             :     {
     327           4 :         while( !pConditions->empty() )
     328             :         {
     329           2 :             SwXMLConditionContext_Impl *pCond = &*pConditions->back();
     330           2 :             pConditions->pop_back();
     331           2 :             pCond->ReleaseRef();
     332             :         }
     333           1 :         delete pConditions;
     334             :     }
     335       11598 : }
     336             : 
     337        6800 : SvXMLImportContext *SwXMLTextStyleContext_Impl::CreateChildContext(
     338             :         sal_uInt16 nPrefix,
     339             :         const OUString& rLocalName,
     340             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     341             : {
     342        6800 :     SvXMLImportContext *pContext = 0;
     343             : 
     344        6800 :     if( XML_NAMESPACE_STYLE == nPrefix && IsXMLToken( rLocalName, XML_MAP ) )
     345             :     {
     346             :         SwXMLConditionContext_Impl *pCond =
     347           2 :             new SwXMLConditionContext_Impl( GetImport(), nPrefix,
     348           2 :                                             rLocalName, xAttrList );
     349           2 :         if( pCond->IsValid() )
     350             :         {
     351           2 :             if( !pConditions )
     352           1 :                pConditions = new SwXMLConditions_Impl;
     353           2 :             pConditions->push_back( pCond );
     354           2 :             pCond->AddFirstRef();
     355             :         }
     356           2 :         pContext = pCond;
     357             :     }
     358             : 
     359        6800 :     if( !pContext )
     360             :         pContext = XMLTextStyleContext::CreateChildContext( nPrefix, rLocalName,
     361        6798 :                                                           xAttrList );
     362             : 
     363        6800 :     return pContext;
     364             : }
     365             : 
     366        3665 : void SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
     367             : {
     368        3665 :     XMLTextStyleContext::Finish( bOverwrite );
     369             : 
     370        3665 :     if( !pConditions || XML_STYLE_FAMILY_TEXT_PARAGRAPH != GetFamily() )
     371        7328 :         return;
     372             : 
     373           1 :     uno::Reference < style::XStyle > xStyle = GetStyle();
     374           1 :     if( !xStyle.is() )
     375           0 :         return;
     376             : 
     377           1 :     const SwXStyle* pStyle = 0;
     378           2 :     uno::Reference<lang::XUnoTunnel> xStyleTunnel( xStyle, uno::UNO_QUERY);
     379           1 :     if( xStyleTunnel.is() )
     380             :     {
     381             :         pStyle = reinterpret_cast< SwXStyle * >(
     382           1 :                 sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId() )));
     383             :     }
     384           1 :     if( !pStyle )
     385           0 :         return;
     386             : 
     387           1 :     const SwDoc *pDoc = pStyle->GetDoc();
     388             : 
     389           1 :     SwTextFormatColl *pColl = pDoc->FindTextFormatCollByName( pStyle->GetStyleName() );
     390             :     OSL_ENSURE( pColl, "Text collection not found" );
     391           1 :     if( !pColl || RES_CONDTXTFMTCOLL != pColl->Which() )
     392           0 :         return;
     393             : 
     394           1 :     const size_t nCount = pConditions->size();
     395           2 :     OUString sName;
     396           3 :     for( size_t i = 0; i < nCount; i++ )
     397             :     {
     398           2 :         const SwXMLConditionContext_Impl *pCond = (*pConditions)[i];
     399             :         const OUString aDisplayName(
     400           2 :             GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
     401           4 :                 pCond->GetApplyStyle() ) );
     402             :         SwStyleNameMapper::FillUIName(aDisplayName,
     403             :                                       sName,
     404             :                                       nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL,
     405           2 :                                       true);
     406           2 :         SwTextFormatColl* pCondColl = pDoc->FindTextFormatCollByName( sName );
     407             :         OSL_ENSURE( pCondColl,
     408             :             "SwXMLItemSetStyleContext_Impl::ConnectConditions: cond coll missing" );
     409           2 :         if( pCondColl )
     410             :         {
     411           2 :             SwCollCondition aCond( pCondColl, pCond->GetCondition(),
     412           4 :                                               pCond->GetSubCondition() );
     413           2 :             static_cast<SwConditionTextFormatColl*>(pColl)->InsertCondition( aCond );
     414             :         }
     415           3 :     }
     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        1798 :     SwXMLImport& GetSwImport() { return static_cast<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         991 :     SfxItemSet *GetItemSet() { return pItemSet; }
     465             : 
     466           8 :     const OUString& GetMasterPageName() const { return sMasterPageName; }
     467         104 :     bool HasMasterPageName() const { return bHasMasterPageName; }
     468             : 
     469           8 :     bool IsPageDescConnected() const { return bPageDescConnected; }
     470             :     void ConnectPageDesc();
     471             : 
     472             :     bool ResolveDataStyleName();
     473             : };
     474             : 
     475        1802 : void SwXMLItemSetStyleContext_Impl::SetAttribute( sal_uInt16 nPrefixKey,
     476             :                                            const OUString& rLocalName,
     477             :                                            const OUString& rValue )
     478             : {
     479        1802 :     if( XML_NAMESPACE_STYLE == nPrefixKey )
     480             :     {
     481        1802 :         if ( IsXMLToken( rLocalName, XML_MASTER_PAGE_NAME ) )
     482             :         {
     483           9 :             sMasterPageName = rValue;
     484           9 :             bHasMasterPageName = true;
     485             :         }
     486        1793 :         else if ( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
     487             :         {
     488             :             // if we have a valid data style name
     489           5 :             if (!rValue.isEmpty())
     490             :             {
     491           5 :                 sDataStyleName = rValue;
     492           5 :                 bDataStyleIsResolved = false;   // needs to be resolved
     493             :             }
     494             :         }
     495             :         else
     496             :         {
     497        1788 :             SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
     498             :         }
     499             :     }
     500             :     else
     501             :     {
     502           0 :         SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
     503             :     }
     504        1802 : }
     505             : 
     506         891 : 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         891 :     SvXMLImportContext *pContext = 0;
     514             : 
     515         891 :     SwDoc* pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
     516             : 
     517         891 :     SfxItemPool& rItemPool = pDoc->GetAttrPool();
     518         891 :     switch( GetFamily() )
     519             :     {
     520             :     case XML_STYLE_FAMILY_TABLE_TABLE:
     521         102 :         pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
     522         102 :         break;
     523             :     case XML_STYLE_FAMILY_TABLE_COLUMN:
     524         292 :         pItemSet = new SfxItemSet( rItemPool, RES_FRM_SIZE, RES_FRM_SIZE, 0 );
     525         292 :         break;
     526             :     case XML_STYLE_FAMILY_TABLE_ROW:
     527          72 :         pItemSet = new SfxItemSet( rItemPool, aTableLineSetRange );
     528          72 :         break;
     529             :     case XML_STYLE_FAMILY_TABLE_CELL:
     530         425 :         pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
     531         425 :         break;
     532             :     default:
     533             :         OSL_ENSURE( false,
     534             :         "SwXMLItemSetStyleContext_Impl::CreateItemSetContext: unknown family" );
     535           0 :         break;
     536             :     }
     537         891 :     if( pItemSet )
     538         891 :         pContext = GetSwImport().CreateTableItemImportContext(
     539         891 :                                 nPrefix, rLName, xAttrList, GetFamily(),
     540        2673 :                                 *pItemSet );
     541         891 :     if( !pContext )
     542             :     {
     543           0 :         delete pItemSet;
     544           0 :         pItemSet = 0;
     545             :     }
     546             : 
     547         891 :     return pContext;
     548             : }
     549             : 
     550        3948 : TYPEINIT1( SwXMLItemSetStyleContext_Impl, SvXMLStyleContext );
     551             : 
     552         891 : 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         891 :     bDataStyleIsResolved( true )
     564             : {
     565         891 : }
     566             : 
     567        2673 : SwXMLItemSetStyleContext_Impl::~SwXMLItemSetStyleContext_Impl()
     568             : {
     569         891 :     delete pItemSet;
     570        1782 : }
     571             : 
     572         425 : void SwXMLItemSetStyleContext_Impl::CreateAndInsert( bool bOverwrite )
     573             : {
     574         425 :     if( pTextStyle )
     575           8 :         pTextStyle->CreateAndInsert( bOverwrite );
     576         425 : }
     577             : 
     578         907 : SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateChildContext(
     579             :         sal_uInt16 nPrefix,
     580             :         const OUString& rLocalName,
     581             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     582             : {
     583         907 :     SvXMLImportContext *pContext = 0;
     584             : 
     585         907 :     if( XML_NAMESPACE_STYLE == nPrefix )
     586             :     {
     587        2619 :         if( IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) ||
     588        1318 :             IsXMLToken( rLocalName, XML_TABLE_COLUMN_PROPERTIES ) ||
     589        1861 :             IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) ||
     590         441 :             IsXMLToken( rLocalName, XML_TABLE_CELL_PROPERTIES ) )
     591             :         {
     592         891 :             pContext = CreateItemSetContext( nPrefix, rLocalName, xAttrList );
     593             :         }
     594          24 :         else if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) ||
     595           8 :                  IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ))
     596             :         {
     597          16 :             if( !pTextStyle )
     598             :             {
     599           8 :                 SvXMLAttributeList *pTmp = new SvXMLAttributeList;
     600           8 :                 const OUString aStr = GetImport().GetNamespaceMap().GetQNameByKey(
     601          16 :                     nPrefix, GetXMLToken(XML_NAME) );
     602           8 :                 pTmp->AddAttribute( aStr, GetName() );
     603          16 :                 uno::Reference <xml::sax::XAttributeList> xTmpAttrList = pTmp;
     604             :                 pTextStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), nPrefix,
     605           8 :                                  rLocalName, xTmpAttrList, XML_STYLE_FAMILY_TEXT_PARAGRAPH, rStyles );
     606           8 :                 pTextStyle->StartElement( xTmpAttrList );
     607          16 :                 rStyles.AddStyle( *pTextStyle );
     608             :             }
     609          16 :             pContext = pTextStyle->CreateChildContext( nPrefix, rLocalName, xAttrList );
     610             :         }
     611             :     }
     612             : 
     613         907 :     if( !pContext )
     614             :         pContext = SvXMLStyleContext::CreateChildContext( nPrefix, rLocalName,
     615           0 :                                                           xAttrList );
     616             : 
     617         907 :     return pContext;
     618             : }
     619             : 
     620           8 : void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
     621             : {
     622           8 :     if( bPageDescConnected || !HasMasterPageName() )
     623           0 :         return;
     624           8 :     bPageDescConnected = true;
     625             : 
     626           8 :     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           8 :     OUString sName = GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_MASTER_PAGE,
     631          16 :                                              GetMasterPageName() );
     632             :     SwStyleNameMapper::FillUIName( sName,
     633             :                                    sName,
     634             :                                    nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC,
     635           8 :                                    true);
     636           8 :     SwPageDesc *pPageDesc = pDoc->FindPageDesc(sName);
     637           8 :     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           8 :     if( !pPageDesc )
     647           0 :         return;
     648             : 
     649           8 :     if( !pItemSet )
     650             :     {
     651           0 :         SfxItemPool& rItemPool = pDoc->GetAttrPool();
     652           0 :         pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
     653             :     }
     654             : 
     655             :     const SfxPoolItem *pItem;
     656           8 :     SwFormatPageDesc *pFormatPageDesc = 0;
     657           8 :     if( SfxItemState::SET == pItemSet->GetItemState( RES_PAGEDESC, false,
     658           8 :                                                 &pItem ) )
     659             :     {
     660           1 :          if( static_cast<const SwFormatPageDesc *>(pItem)->GetPageDesc() != pPageDesc )
     661           1 :             pFormatPageDesc = new SwFormatPageDesc( *static_cast<const SwFormatPageDesc *>(pItem) );
     662             :     }
     663             :     else
     664           7 :         pFormatPageDesc = new SwFormatPageDesc();
     665             : 
     666           8 :     if( pFormatPageDesc )
     667             :     {
     668           8 :         pFormatPageDesc->RegisterToPageDesc( *pPageDesc );
     669           8 :         pItemSet->Put( *pFormatPageDesc );
     670           8 :         delete pFormatPageDesc;
     671           8 :     }
     672             : }
     673             : 
     674         498 : bool SwXMLItemSetStyleContext_Impl::ResolveDataStyleName()
     675             : {
     676             :     // resolve, if not already done
     677         498 :     if (! bDataStyleIsResolved)
     678             :     {
     679             :         // get the format key
     680             :         sal_Int32 nFormat =
     681           4 :             GetImport().GetTextImport()->GetDataStyleKey(sDataStyleName);
     682             : 
     683             :         // if the key is valid, insert Item into ItemSet
     684           4 :         if( -1 != nFormat )
     685             :         {
     686           4 :             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           4 :             SwTableBoxNumFormat aNumFormatItem(nFormat);
     694           4 :             pItemSet->Put(aNumFormatItem);
     695             :         }
     696             : 
     697             :         // now resolved
     698           4 :         bDataStyleIsResolved = true;
     699           4 :         return true;
     700             :     }
     701             :     else
     702             :     {
     703             :         // was already resolved; nothing to do
     704         494 :         return false;
     705             :     }
     706             : }
     707             : 
     708             : class SwXMLStylesContext_Impl : public SvXMLStylesContext
     709             : {
     710        7659 :     SwXMLImport& GetSwImport() { return static_cast<SwXMLImport&>(GetImport()); }
     711       20354 :     const SwXMLImport& GetSwImport() const
     712       20354 :             { return static_cast<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        9553 : SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleStyleChildContext(
     750             :         sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
     751             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     752             : {
     753        9553 :     SvXMLStyleContext *pStyle = 0;
     754             : 
     755        9553 :     switch( nFamily )
     756             :     {
     757             :     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
     758             :         pStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), nPrefix,
     759        5791 :                             rLocalName, xAttrList, nFamily, *this );
     760        5791 :         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         891 :                             rLocalName, xAttrList, *this, nFamily  );
     767         891 :         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         583 :         pStyle = new XMLTextShapeStyleContext( GetImport(), nPrefix,
     772         583 :                             rLocalName, xAttrList, *this, nFamily );
     773         583 :         break;
     774             :     default:
     775             :         pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily,
     776             :                                                                    nPrefix,
     777             :                                                               rLocalName,
     778        2288 :                                                               xAttrList );
     779        2288 :         break;
     780             :     }
     781             : 
     782        9553 :     return pStyle;
     783             : }
     784             : 
     785        1464 : SvXMLStyleContext *SwXMLStylesContext_Impl::CreateDefaultStyleStyleChildContext(
     786             :         sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
     787             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     788             : {
     789        1464 :     SvXMLStyleContext *pStyle = 0;
     790             : 
     791        1464 :     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        1016 :         pStyle = new XMLTextStyleContext( GetImport(), nPrefix, rLocalName,
     797             :                                           xAttrList, *this, nFamily,
     798        1016 :                                           true );
     799        1016 :         break;
     800             :     case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
     801             :         // There are no writer specific defaults for graphic styles!
     802         342 :         pStyle = new XMLGraphicsDefaultStyle( GetImport(), nPrefix,
     803         342 :                             rLocalName, xAttrList, *this );
     804         342 :         break;
     805             :     default:
     806             :         pStyle = SvXMLStylesContext::CreateDefaultStyleStyleChildContext( nFamily,
     807             :                                                                    nPrefix,
     808             :                                                               rLocalName,
     809         106 :                                                               xAttrList );
     810         106 :         break;
     811             :     }
     812             : 
     813        1464 :     return pStyle;
     814             : }
     815             : 
     816         977 : 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         977 :     SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList, bAuto )
     821             : {
     822         977 : }
     823             : 
     824        1954 : SwXMLStylesContext_Impl::~SwXMLStylesContext_Impl()
     825             : {
     826        1954 : }
     827             : 
     828       20354 : bool SwXMLStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const
     829             : {
     830       20354 :     const SwXMLImport& rSwImport = GetSwImport();
     831       20354 :     const sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
     832             : 
     833       20354 :     bool bIns = true;
     834       20354 :     switch( nFamily )
     835             :     {
     836             :     case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
     837       11525 :         bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PARA) != 0;
     838       11525 :         break;
     839             :     case XML_STYLE_FAMILY_TEXT_TEXT:
     840        3237 :         bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_CHAR) != 0;
     841        3237 :         break;
     842             :     case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
     843         642 :         bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_FRAME) != 0;
     844         642 :         break;
     845             :     case XML_STYLE_FAMILY_TEXT_LIST:
     846        1038 :         bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PSEUDO) != 0;
     847        1038 :         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        7347 :         bIns = !(rSwImport.IsInsertMode() || rSwImport.IsStylesOnlyMode() ||
     854        7347 :                  rSwImport.IsBlockMode());
     855        3912 :         break;
     856             :     default:
     857           0 :         bIns = SvXMLStylesContext::InsertStyleFamily( nFamily );
     858           0 :         break;
     859             :     }
     860             : 
     861       20354 :     return bIns;
     862             : }
     863             : 
     864       43797 : rtl::Reference < SvXMLImportPropertyMapper > SwXMLStylesContext_Impl::GetImportPropertyMapper(
     865             :         sal_uInt16 nFamily ) const
     866             : {
     867       43797 :     rtl::Reference < SvXMLImportPropertyMapper > xMapper;
     868       43797 :     if( nFamily == XML_STYLE_FAMILY_TABLE_TABLE )
     869         621 :         xMapper = XMLTextImportHelper::CreateTableDefaultExtPropMapper(
     870        1242 :             const_cast<SwXMLStylesContext_Impl*>( this )->GetImport() );
     871       43176 :     else if( nFamily == XML_STYLE_FAMILY_TABLE_ROW )
     872         674 :         xMapper = XMLTextImportHelper::CreateTableRowDefaultExtPropMapper(
     873        1348 :             const_cast<SwXMLStylesContext_Impl*>( this )->GetImport() );
     874             :     else
     875       42502 :         xMapper = SvXMLStylesContext::GetImportPropertyMapper( nFamily );
     876       43797 :     return xMapper;
     877             : }
     878             : 
     879       10181 : uno::Reference < container::XNameContainer > SwXMLStylesContext_Impl::GetStylesContainer(
     880             :                                                 sal_uInt16 nFamily ) const
     881             : {
     882       10181 :     uno::Reference < container::XNameContainer > xStyles;
     883       10181 :     if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
     884         428 :         xStyles = const_cast<SvXMLImport *>(&GetImport())->GetTextImport()->GetFrameStyles();
     885             :     else
     886        9753 :         xStyles = SvXMLStylesContext::GetStylesContainer( nFamily );
     887             : 
     888       10181 :     return xStyles;
     889             : }
     890             : 
     891        1471 : OUString SwXMLStylesContext_Impl::GetServiceName( sal_uInt16 nFamily ) const
     892             : {
     893        1471 :     if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
     894          38 :         return OUString( "com.sun.star.style.FrameStyle" );
     895             : 
     896        1433 :     return SvXMLStylesContext::GetServiceName( nFamily );
     897             : }
     898             : 
     899         977 : void SwXMLStylesContext_Impl::EndElement()
     900             : {
     901         977 :     GetSwImport().InsertStyles( IsAutomaticStyle() );
     902         977 : }
     903             : 
     904             : class SwXMLMasterStylesContext_Impl : public XMLTextMasterStylesContext
     905             : {
     906             : protected:
     907             :     virtual bool InsertStyleFamily( sal_uInt16 nFamily ) const SAL_OVERRIDE;
     908             : 
     909         688 :     SwXMLImport& GetSwImport() { return static_cast<SwXMLImport&>(GetImport()); }
     910        1184 :     const SwXMLImport& GetSwImport() const
     911        1184 :             { return static_cast<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         344 : SwXMLMasterStylesContext_Impl::SwXMLMasterStylesContext_Impl(
     928             :         SwXMLImport& rImport, sal_uInt16 nPrfx,
     929             :         const OUString& rLName ,
     930             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList ) :
     931         344 :     XMLTextMasterStylesContext( rImport, nPrfx, rLName, xAttrList )
     932             : {
     933         344 : }
     934             : 
     935         688 : SwXMLMasterStylesContext_Impl::~SwXMLMasterStylesContext_Impl()
     936             : {
     937         688 : }
     938             : 
     939        1184 : bool SwXMLMasterStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const
     940             : {
     941             :     bool bIns;
     942             : 
     943        1184 :     const SwXMLImport& rSwImport = GetSwImport();
     944        1184 :     const sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
     945        1184 :     if( XML_STYLE_FAMILY_MASTER_PAGE == nFamily )
     946        1184 :         bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PAGE) != 0;
     947             :     else
     948           0 :         bIns = XMLTextMasterStylesContext::InsertStyleFamily( nFamily );
     949             : 
     950        1184 :     return bIns;
     951             : }
     952             : 
     953         344 : void SwXMLMasterStylesContext_Impl::EndElement()
     954             : {
     955         344 :     FinishStyles( !GetSwImport().IsInsertMode() );
     956         344 :     GetSwImport().FinishStyles();
     957         344 : }
     958             : 
     959         977 : 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         977 :                                        xAttrList, bAuto );
     967         977 :     if( bAuto )
     968         632 :         SetAutoStyles( pContext );
     969             :     else
     970         345 :         SetStyles( pContext );
     971             : 
     972         977 :     return pContext;
     973             : }
     974             : 
     975         344 : 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         344 :                                           xAttrList );
     982         344 :     SetMasterStyles( pContext );
     983             : 
     984         344 :     return pContext;
     985             : }
     986             : 
     987         977 : void SwXMLImport::InsertStyles( bool bAuto )
     988             : {
     989         977 :     if( bAuto && GetAutoStyles() )
     990         632 :         GetAutoStyles()->CopyAutoStylesToDoc();
     991         977 :     if( !bAuto && GetStyles() )
     992         345 :         GetStyles()->CopyStylesToDoc( !IsInsertMode(), false );
     993         977 : }
     994             : 
     995         344 : void SwXMLImport::FinishStyles()
     996             : {
     997         344 :     if( GetStyles() )
     998         344 :         GetStyles()->FinishStyles( !IsInsertMode() );
     999         344 : }
    1000             : 
    1001         353 : void SwXMLImport::UpdateTextCollConditions( SwDoc *pDoc )
    1002             : {
    1003         353 :     if( !pDoc )
    1004           0 :         pDoc = SwImport::GetDocFromXMLImport( *this );
    1005             : 
    1006         353 :     const SwTextFormatColls& rColls = *pDoc->GetTextFormatColls();
    1007         353 :     const size_t nCount = rColls.size();
    1008        4757 :     for( size_t i=0; i < nCount; ++i )
    1009             :     {
    1010        4404 :         SwTextFormatColl *pColl = rColls[i];
    1011        4404 :         if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() )
    1012             :         {
    1013             :             const SwFormatCollConditions& rConditions =
    1014         349 :                 static_cast<const SwConditionTextFormatColl *>(pColl)->GetCondColls();
    1015         349 :             bool bSendModify = false;
    1016         350 :             for( size_t j=0; j < rConditions.size() && !bSendModify; ++j )
    1017             :             {
    1018           1 :                 const SwCollCondition& rCond = rConditions[j];
    1019           1 :                 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           1 :                     bSendModify = true;
    1026           1 :                     break;
    1027             :                 }
    1028             :             }
    1029         349 :             if( bSendModify )
    1030             :             {
    1031           1 :                 SwCondCollCondChg aMsg( pColl );
    1032           1 :                 pColl->ModifyNotification( &aMsg, &aMsg );
    1033             :             }
    1034             :         }
    1035             :     }
    1036         353 : }
    1037             : 
    1038         987 : bool SwXMLImport::FindAutomaticStyle(
    1039             :         sal_uInt16 nFamily,
    1040             :         const OUString& rName,
    1041             :         const SfxItemSet **ppItemSet,
    1042             :         OUString *pParent ) const
    1043             : {
    1044         987 :     SwXMLItemSetStyleContext_Impl *pStyle = 0;
    1045         987 :     if( GetAutoStyles() )
    1046             :     {
    1047        1974 :         pStyle = const_cast<SwXMLItemSetStyleContext_Impl*>(PTR_CAST( SwXMLItemSetStyleContext_Impl,
    1048             :               GetAutoStyles()->
    1049             :                     FindStyleChildContext( nFamily, rName,
    1050         987 :                                            true ) ) );
    1051         987 :         if( pStyle )
    1052             :         {
    1053         987 :             if( ppItemSet )
    1054             :             {
    1055        2070 :                 if( XML_STYLE_FAMILY_TABLE_TABLE == pStyle->GetFamily() &&
    1056         995 :                     pStyle->HasMasterPageName() &&
    1057           8 :                     !pStyle->IsPageDescConnected() )
    1058           8 :                     pStyle->ConnectPageDesc();
    1059         987 :                 (*ppItemSet) = pStyle->GetItemSet();
    1060             : 
    1061             :                 // resolve data style name late
    1062        1485 :                 if( XML_STYLE_FAMILY_TABLE_CELL == pStyle->GetFamily() &&
    1063         498 :                     pStyle->ResolveDataStyleName() )
    1064             :                 {
    1065           4 :                     (*ppItemSet) = pStyle->GetItemSet();
    1066             :                 }
    1067             : 
    1068             :             }
    1069             : 
    1070         987 :             if( pParent )
    1071           0 :                 *pParent = pStyle->GetParentName();
    1072             :         }
    1073             :     }
    1074             : 
    1075         987 :     return pStyle != 0;
    1076         177 : }
    1077             : 
    1078             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11