LCOV - code coverage report
Current view: top level - xmloff/source/style - xmlnume.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 351 422 83.2 %
Date: 2014-04-11 Functions: 9 10 90.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      22             : #include <com/sun/star/style/NumberingType.hpp>
      23             : #include <com/sun/star/style/XStyle.hpp>
      24             : #include <com/sun/star/container/XNameContainer.hpp>
      25             : #include <com/sun/star/container/XIndexReplace.hpp>
      26             : #include <com/sun/star/awt/XBitmap.hpp>
      27             : #include <com/sun/star/awt/FontDescriptor.hpp>
      28             : #include <com/sun/star/text/HoriOrientation.hpp>
      29             : #include <com/sun/star/text/VertOrientation.hpp>
      30             : #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
      31             : #include <com/sun/star/text/PositionAndSpaceMode.hpp>
      32             : #include <com/sun/star/text/LabelFollow.hpp>
      33             : #include <com/sun/star/beans/PropertyValue.hpp>
      34             : #include <com/sun/star/beans/XPropertySet.hpp>
      35             : 
      36             : #include <rtl/ustrbuf.hxx>
      37             : 
      38             : #include <tools/debug.hxx>
      39             : 
      40             : #include <sax/tools/converter.hxx>
      41             : 
      42             : #include <xmloff/nmspmap.hxx>
      43             : #include <xmloff/xmlnmspe.hxx>
      44             : #include <xmloff/xmltoken.hxx>
      45             : #include <xmloff/xmluconv.hxx>
      46             : #include "fonthdl.hxx"
      47             : #include <xmloff/XMLTextListAutoStylePool.hxx>
      48             : #include <xmloff/xmlnume.hxx>
      49             : #include <xmloff/xmlexp.hxx>
      50             : #include <tools/fontenum.hxx>
      51             : 
      52             : 
      53             : 
      54             : using namespace ::com::sun::star;
      55             : using namespace ::com::sun::star::uno;
      56             : using namespace ::com::sun::star::style;
      57             : using namespace ::com::sun::star::text;
      58             : using namespace ::com::sun::star::container;
      59             : using namespace ::com::sun::star::beans;
      60             : using namespace ::xmloff::token;
      61             : 
      62         105 : void SvxXMLNumRuleExport::exportLevelStyles( const uno::Reference< ::com::sun::star::container::XIndexReplace > & xNumRule,
      63             :                                              bool bOutline )
      64             : {
      65         105 :     sal_Int32 nCount = xNumRule ->getCount();
      66        1155 :     for( sal_Int32 i=0; i<nCount; i++ )
      67             :     {
      68        1050 :         uno::Any aEntry( xNumRule->getByIndex( i ) );
      69        2100 :         uno::Sequence<beans::PropertyValue> aSeq;
      70        1050 :         if( aEntry >>= aSeq )
      71             :         {
      72        1050 :             exportLevelStyle( i, aSeq, bOutline );
      73             :         }
      74        1050 :     }
      75         105 : }
      76             : 
      77        1050 : void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel,
      78             :                                     const uno::Sequence<beans::PropertyValue>& rProps,
      79             :                                     bool bOutline )
      80             : {
      81        1050 :     sal_Int16 eType = NumberingType::CHAR_SPECIAL;
      82             : 
      83        1050 :     sal_Int16 eAdjust = HoriOrientation::LEFT;
      84        2100 :     OUString sPrefix, sSuffix;
      85        2100 :     OUString sTextStyleName;
      86        1050 :     sal_Bool bHasColor = sal_False;
      87        1050 :     sal_Int32 nColor = 0;
      88        1050 :     sal_Int32 nSpaceBefore = 0, nMinLabelWidth = 0, nMinLabelDist = 0;
      89             : 
      90        1050 :     sal_Int16 nStartValue = 1, nDisplayLevels = 1, nBullRelSize = 0;
      91             : 
      92        1050 :     sal_Unicode cBullet = 0xf095;
      93        2100 :     OUString sBulletFontName, sBulletFontStyleName ;
      94        1050 :     FontFamily eBulletFontFamily = FAMILY_DONTKNOW;
      95        1050 :     FontPitch eBulletFontPitch = PITCH_DONTKNOW;
      96        1050 :     rtl_TextEncoding eBulletFontEncoding = RTL_TEXTENCODING_DONTKNOW;
      97             : 
      98        2100 :     OUString sImageURL;
      99        2100 :     uno::Reference< ::com::sun::star::awt::XBitmap >  xBitmap;
     100        1050 :     sal_Int32 nImageWidth = 0, nImageHeight = 0;
     101        1050 :     sal_Int16 eImageVertOrient = VertOrientation::LINE_CENTER;
     102             : 
     103        1050 :     sal_Int16 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION;
     104        1050 :     sal_Int16 eLabelFollowedBy = LabelFollow::LISTTAB;
     105        1050 :     sal_Int32 nListtabStopPosition( 0 );
     106        1050 :     sal_Int32 nFirstLineIndent( 0 );
     107        1050 :     sal_Int32 nIndentAt( 0 );
     108             : 
     109        1050 :     const sal_Int32 nCount = rProps.getLength();
     110        1050 :     const beans::PropertyValue* pPropArray = rProps.getConstArray();
     111       14271 :     for( sal_Int32 i=0; i<nCount; i++ )
     112             :     {
     113       13221 :         const beans::PropertyValue& rProp = pPropArray[i];
     114             : 
     115       13221 :         if( rProp.Name == "NumberingType" )
     116             :         {
     117        1050 :             rProp.Value >>= eType;
     118             :         }
     119       12171 :         else if( rProp.Name == "Prefix" )
     120             :         {
     121        1050 :             rProp.Value >>= sPrefix;
     122             :         }
     123       11121 :         else if( rProp.Name == "Suffix" )
     124             :         {
     125        1050 :             rProp.Value >>= sSuffix;
     126             :         }
     127       10071 :         else if( rProp.Name == "BulletChar" )
     128             :         {
     129         407 :             OUString sValue;
     130         407 :             rProp.Value >>= sValue;
     131         407 :             if( !sValue.isEmpty() )
     132             :             {
     133         407 :                 cBullet = (sal_Unicode)sValue[0];
     134         407 :             }
     135             :         }
     136        9664 :         else if( rProp.Name == "BulletRelSize" )
     137             :         {
     138         430 :             rProp.Value >>= nBullRelSize;
     139             :         }
     140        9234 :         else if( rProp.Name == "Adjust" )
     141             :         {
     142        1050 :             sal_Int16 nValue = 0;
     143        1050 :             rProp.Value >>= nValue;
     144        1050 :             eAdjust = nValue;
     145             :         }
     146        8184 :         else if( rProp.Name == "BulletFont" )
     147             :         {
     148         408 :             awt::FontDescriptor rFDesc;
     149         408 :             if( rProp.Value >>= rFDesc )
     150             :             {
     151         408 :                 sBulletFontName = rFDesc.Name;
     152         408 :                 sBulletFontStyleName = rFDesc.StyleName;
     153         408 :                 eBulletFontFamily = static_cast< FontFamily >( rFDesc.Family );
     154         408 :                 eBulletFontPitch = static_cast< FontPitch >( rFDesc.Pitch );
     155         408 :                 eBulletFontEncoding = (rtl_TextEncoding)rFDesc.CharSet;
     156         408 :             }
     157             :         }
     158        7776 :         else if( rProp.Name == "GraphicURL" )
     159             :         {
     160           0 :             rProp.Value >>= sImageURL;
     161             :         }
     162        7776 :         else if( rProp.Name == "GraphicBitmap" )
     163             :         {
     164           0 :             rProp.Value >>= xBitmap;
     165             :         }
     166        7776 :         else if( rProp.Name == "BulletColor" )
     167             :         {
     168         430 :             rProp.Value >>= nColor;
     169         430 :             bHasColor = sal_True;
     170             :         }
     171        7346 :         else  if( rProp.Name == "StartWith" )
     172             :         {
     173        1050 :             rProp.Value >>= nStartValue;
     174             :         }
     175        6296 :         else  if( rProp.Name == "LeftMargin" )
     176             :         {
     177         430 :             rProp.Value >>= nSpaceBefore;
     178             :         }
     179        5866 :         else  if( rProp.Name == "FirstLineOffset" )
     180             :         {
     181         430 :             rProp.Value >>= nMinLabelWidth;
     182             :         }
     183        5436 :         else  if( rProp.Name == "SymbolTextDistance" )
     184             :         {
     185         430 :             rProp.Value >>= nMinLabelDist;
     186             :         }
     187        5006 :         else if( rProp.Name == "ParentNumbering" )
     188             :         {
     189         620 :             rProp.Value >>= nDisplayLevels;
     190         620 :             if( nDisplayLevels > nLevel+1 )
     191          45 :                 nDisplayLevels = static_cast<sal_Int16>( nLevel )+1;
     192             :         }
     193        4386 :         else if( rProp.Name == "CharStyleName" )
     194             :         {
     195         620 :             rProp.Value >>= sTextStyleName;
     196             :         }
     197        3766 :         else if( rProp.Name == "GraphicSize" )
     198             :         {
     199         430 :             awt::Size aSize;
     200         430 :             if( rProp.Value >>= aSize )
     201             :             {
     202         430 :                 nImageWidth = aSize.Width;
     203         430 :                 nImageHeight = aSize.Height;
     204             :             }
     205             :         }
     206        3336 :         else if( rProp.Name == "VertOrient" )
     207             :         {
     208           0 :             sal_Int16 nValue = 0;
     209           0 :             rProp.Value >>= nValue;
     210           0 :             eImageVertOrient = nValue;
     211             :         }
     212        3336 :         else if( rProp.Name == "PositionAndSpaceMode" )
     213             :         {
     214         620 :             sal_Int16 nValue = 0;
     215         620 :             rProp.Value >>= nValue;
     216         620 :             ePosAndSpaceMode = nValue;
     217             :         }
     218        2716 :         else if( rProp.Name == "LabelFollowedBy" )
     219             :         {
     220         620 :             sal_Int16 nValue = 0;
     221         620 :             rProp.Value >>= nValue;
     222         620 :             eLabelFollowedBy = nValue;
     223             :         }
     224        2096 :         else if( rProp.Name == "ListtabStopPosition" )
     225             :         {
     226         620 :             rProp.Value >>= nListtabStopPosition;
     227             :         }
     228        1476 :         else if( rProp.Name == "FirstLineIndent" )
     229             :         {
     230         620 :             rProp.Value >>= nFirstLineIndent;
     231             :         }
     232         856 :         else if( rProp.Name == "IndentAt" )
     233             :         {
     234         620 :             rProp.Value >>= nIndentAt;
     235             :         }
     236             :     }
     237             : 
     238        1250 :     if( bOutline && (NumberingType::CHAR_SPECIAL == eType ||
     239         200 :                      NumberingType::BITMAP == eType) )
     240             :     {
     241             :         DBG_ASSERT( !bOutline,
     242             :            "SvxXMLNumRuleExport::exportLevelStyle: invalid style for outline" );
     243        1050 :         return;
     244             :     }
     245             : 
     246        1050 :     GetExport().CheckAttrList();
     247             : 
     248             :     // text:level
     249        2100 :     OUStringBuffer sTmp;
     250        1050 :     sTmp.append( nLevel + 1 );
     251        1050 :     GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_LEVEL, sTmp.makeStringAndClear() );
     252             :     // #i110694#: no style-name on list-level-style-image
     253             :     // #i116149#: neither prefix/suffix
     254        1050 :     if (NumberingType::BITMAP != eType)
     255             :     {
     256        1050 :         if (!sTextStyleName.isEmpty())
     257             :         {
     258          62 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
     259         124 :                     GetExport().EncodeStyleName( sTextStyleName ) );
     260             :         }
     261        1050 :         if (!sPrefix.isEmpty())
     262             :         {
     263           0 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NUM_PREFIX,
     264           0 :                     sPrefix );
     265             :         }
     266        1050 :         if (!sSuffix.isEmpty())
     267             :         {
     268         420 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NUM_SUFFIX,
     269         420 :                     sSuffix );
     270             :         }
     271             :     }
     272             : 
     273        1050 :     enum XMLTokenEnum eElem = XML_LIST_LEVEL_STYLE_NUMBER;
     274        1050 :     if( NumberingType::CHAR_SPECIAL == eType )
     275             :     {
     276             :         // <text:list-level-style-bullet>
     277         407 :         eElem = XML_LIST_LEVEL_STYLE_BULLET;
     278             : 
     279         407 :         if( cBullet )
     280             :         {
     281         407 :             if( cBullet < ' ' )
     282             :             {
     283           0 :                 cBullet = 0xF000 + 149;
     284             :             }
     285             :             // text:bullet-char="..."
     286         407 :             sTmp.append( cBullet );
     287         407 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_BULLET_CHAR,
     288         814 :                           sTmp.makeStringAndClear() );
     289             :         }
     290             :         else
     291             :         {
     292             :             // If 'cBullet' is zero, XML_BULLET_CHAR must exist with blank.
     293           0 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_BULLET_CHAR, "");
     294             :         }
     295             :     }
     296         643 :     else if( NumberingType::BITMAP == eType )
     297             :     {
     298             :         // <text:list-level-style-image>
     299             : 
     300           0 :         eElem = XML_LIST_LEVEL_STYLE_IMAGE;
     301             : 
     302             : 
     303           0 :         if( !sImageURL.isEmpty() )
     304             :         {
     305           0 :             OUString sURL( GetExport().AddEmbeddedGraphicObject( sImageURL ) );
     306           0 :             if( !sURL.isEmpty() )
     307             :             {
     308           0 :                 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL );
     309             : 
     310           0 :                 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
     311           0 :                 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
     312           0 :                 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
     313           0 :             }
     314             :         }
     315             :         else
     316             :         {
     317             :             DBG_ASSERT( !xBitmap.is(),
     318             :                         "embedded images are not supported by now" );
     319             :         }
     320             :     }
     321             :     else
     322             :     {
     323             :         // <text:list-level-style-number> or <text:outline-level-style>
     324         643 :         if( bOutline )
     325         200 :             eElem = XML_OUTLINE_LEVEL_STYLE;
     326             :         else
     327         443 :             eElem = XML_LIST_LEVEL_STYLE_NUMBER;
     328             : 
     329         643 :         GetExport().GetMM100UnitConverter().convertNumFormat( sTmp, eType );
     330         643 :         GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
     331        1286 :                                        sTmp.makeStringAndClear() );
     332         643 :         GetExport().GetMM100UnitConverter().convertNumLetterSync( sTmp, eType );
     333         643 :         if( !sTmp.isEmpty() )
     334           0 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     335             :                                       XML_NUM_LETTER_SYNC,
     336           0 :                                            sTmp.makeStringAndClear() );
     337             : 
     338         643 :         if( nStartValue != 1 )
     339             :         {
     340          22 :             sTmp.append( (sal_Int32)nStartValue );
     341          22 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
     342          44 :                           sTmp.makeStringAndClear() );
     343             :         }
     344         643 :         if( nDisplayLevels > 1 && NumberingType::NUMBER_NONE != eType )
     345             :         {
     346          16 :             sTmp.append( (sal_Int32)nDisplayLevels );
     347          16 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_DISPLAY_LEVELS,
     348          32 :                           sTmp.makeStringAndClear() );
     349             :         }
     350             :     }
     351             : 
     352             :     {
     353        1050 :         SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, eElem,
     354        1050 :                                   true, true );
     355             : 
     356        2100 :         OUStringBuffer sBuffer;
     357        1050 :         if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
     358             :         {
     359         430 :             nSpaceBefore += nMinLabelWidth;
     360         430 :             nMinLabelWidth = -nMinLabelWidth;
     361         430 :             if( nSpaceBefore != 0 )
     362             :             {
     363         390 :                 GetExport().GetMM100UnitConverter().convertMeasureToXML(
     364         780 :                         sBuffer, nSpaceBefore );
     365         390 :                 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_SPACE_BEFORE,
     366         780 :                               sBuffer.makeStringAndClear() );
     367             :             }
     368         430 :             if( nMinLabelWidth != 0 )
     369             :             {
     370         390 :                 GetExport().GetMM100UnitConverter().convertMeasureToXML(
     371         780 :                         sBuffer, nMinLabelWidth );
     372         390 :                 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_WIDTH,
     373         780 :                               sBuffer.makeStringAndClear() );
     374             :             }
     375         430 :             if( nMinLabelDist > 0 )
     376             :             {
     377           0 :                 GetExport().GetMM100UnitConverter().convertMeasureToXML(
     378           0 :                         sBuffer, nMinLabelDist );
     379           0 :                 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_DISTANCE,
     380           0 :                               sBuffer.makeStringAndClear() );
     381             :             }
     382             :         }
     383             :         /* Check, if properties for position-and-space-mode LABEL_ALIGNMENT
     384             :            are allowed to be exported. (#i89178#)
     385             :         */
     386         620 :         else if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT &&
     387             :                   mbExportPositionAndSpaceModeLabelAlignment )
     388             :         {
     389         620 :             GetExport().AddAttribute( XML_NAMESPACE_TEXT,
     390             :                                       XML_LIST_LEVEL_POSITION_AND_SPACE_MODE,
     391         620 :                                       XML_LABEL_ALIGNMENT );
     392             :         }
     393        1050 :         if( HoriOrientation::LEFT != eAdjust )
     394             :         {
     395          96 :             enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
     396          96 :             switch( eAdjust )
     397             :             {
     398          96 :             case HoriOrientation::RIGHT:    eValue = XML_END;   break;
     399           0 :             case HoriOrientation::CENTER:   eValue = XML_CENTER;    break;
     400             :             }
     401          96 :             if( eValue != XML_TOKEN_INVALID )
     402          96 :                 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_TEXT_ALIGN, eValue );
     403             :         }
     404             : 
     405        1050 :         if( NumberingType::BITMAP == eType )
     406             :         {
     407           0 :             enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
     408           0 :             switch( eImageVertOrient )
     409             :             {
     410             :             case VertOrientation::BOTTOM:   // yes, its OK: BOTTOM means that the baseline
     411             :                                     // hits the frame at its topmost position
     412             :             case VertOrientation::LINE_TOP:
     413             :             case VertOrientation::CHAR_TOP:
     414           0 :                 eValue = XML_TOP;
     415           0 :                 break;
     416             :             case VertOrientation::CENTER:
     417             :             case VertOrientation::LINE_CENTER:
     418             :             case VertOrientation::CHAR_CENTER:
     419           0 :                 eValue = XML_MIDDLE;
     420           0 :                 break;
     421             :             case VertOrientation::TOP:      // yes, its OK: TOP means that the baseline
     422             :                                     // hits the frame at its bottommost position
     423             :             case VertOrientation::LINE_BOTTOM:
     424             :             case VertOrientation::CHAR_BOTTOM:
     425           0 :                 eValue = XML_BOTTOM;
     426           0 :                 break;
     427             :             }
     428           0 :             if( eValue != XML_TOKEN_INVALID )
     429           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_VERTICAL_POS, eValue );
     430             : 
     431           0 :             eValue = XML_TOKEN_INVALID;
     432           0 :             switch( eImageVertOrient )
     433             :             {
     434             :             case VertOrientation::TOP:
     435             :             case VertOrientation::CENTER:
     436             :             case VertOrientation::BOTTOM:
     437           0 :                 eValue = XML_BASELINE;
     438           0 :                 break;
     439             :             case VertOrientation::LINE_TOP:
     440             :             case VertOrientation::LINE_CENTER:
     441             :             case VertOrientation::LINE_BOTTOM:
     442           0 :                 eValue = XML_LINE;
     443           0 :                 break;
     444             :             case VertOrientation::CHAR_TOP:
     445             :             case VertOrientation::CHAR_CENTER:
     446             :             case VertOrientation::CHAR_BOTTOM:
     447           0 :                 eValue = XML_CHAR;
     448           0 :                 break;
     449             :             }
     450           0 :             if( eValue != XML_TOKEN_INVALID )
     451           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_VERTICAL_REL, eValue );
     452             : 
     453           0 :             if( nImageWidth > 0 )
     454             :             {
     455           0 :                 GetExport().GetMM100UnitConverter().convertMeasureToXML(
     456           0 :                         sBuffer, nImageWidth );
     457           0 :                 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_WIDTH,
     458           0 :                               sBuffer.makeStringAndClear() );
     459             :             }
     460             : 
     461           0 :             if( nImageHeight > 0 )
     462             :             {
     463           0 :                 GetExport().GetMM100UnitConverter().convertMeasureToXML(
     464           0 :                         sBuffer, nImageHeight );
     465           0 :                 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_HEIGHT,
     466           0 :                               sBuffer.makeStringAndClear() );
     467             :             }
     468             :         }
     469             : 
     470             :         {
     471        1050 :             SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_STYLE,
     472        1050 :                                       XML_LIST_LEVEL_PROPERTIES, true, true );
     473             : 
     474             :             /* Check, if properties for position-and-space-mode LABEL_ALIGNMENT
     475             :                are allowed to be exported. (#i89178#)
     476             :             */
     477        1050 :             if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT &&
     478             :                  mbExportPositionAndSpaceModeLabelAlignment )
     479             :             {
     480         620 :                 enum XMLTokenEnum eValue = XML_LISTTAB;
     481         620 :                 if ( eLabelFollowedBy == LabelFollow::SPACE )
     482             :                 {
     483           0 :                     eValue = XML_SPACE;
     484             :                 }
     485         620 :                 else if ( eLabelFollowedBy == LabelFollow::NOTHING )
     486             :                 {
     487           0 :                     eValue = XML_NOTHING;
     488             :                 }
     489         620 :                 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
     490         620 :                                           XML_LABEL_FOLLOWED_BY, eValue );
     491             : 
     492        1240 :                 if ( eLabelFollowedBy == LabelFollow::LISTTAB &&
     493         620 :                      nListtabStopPosition > 0 )
     494             :                 {
     495         620 :                     GetExport().GetMM100UnitConverter().convertMeasureToXML(
     496        1240 :                             sBuffer, nListtabStopPosition );
     497         620 :                     GetExport().AddAttribute( XML_NAMESPACE_TEXT,
     498             :                                               XML_LIST_TAB_STOP_POSITION,
     499        1240 :                                               sBuffer.makeStringAndClear() );
     500             :                 }
     501             : 
     502         620 :                 if ( nFirstLineIndent != 0 )
     503             :                 {
     504         620 :                     GetExport().GetMM100UnitConverter().convertMeasureToXML(
     505        1240 :                             sBuffer, nFirstLineIndent );
     506         620 :                     GetExport().AddAttribute( XML_NAMESPACE_FO,
     507             :                                               XML_TEXT_INDENT,
     508        1240 :                                               sBuffer.makeStringAndClear() );
     509             :                 }
     510             : 
     511         620 :                 if ( nIndentAt != 0 )
     512             :                 {
     513         618 :                     GetExport().GetMM100UnitConverter().convertMeasureToXML(
     514        1236 :                             sBuffer, nIndentAt );
     515         618 :                     GetExport().AddAttribute( XML_NAMESPACE_FO,
     516             :                                               XML_MARGIN_LEFT,
     517        1236 :                                               sBuffer.makeStringAndClear() );
     518             :                 }
     519             : 
     520         620 :                 SvXMLElementExport aLabelAlignmentElement( GetExport(), XML_NAMESPACE_STYLE,
     521             :                                              XML_LIST_LEVEL_LABEL_ALIGNMENT,
     522         620 :                                              true, true );
     523        1050 :             }
     524             :         }
     525             : 
     526        1050 :         if( NumberingType::CHAR_SPECIAL == eType )
     527             :         {
     528         407 :             if( !sBulletFontName.isEmpty() )
     529             :             {
     530             :                 OUString sStyleName =
     531         407 :                     GetExport().GetFontAutoStylePool()->Find(
     532             :                         sBulletFontName, sBulletFontStyleName,
     533             :                         eBulletFontFamily, eBulletFontPitch,
     534         814 :                         eBulletFontEncoding );
     535             : 
     536         407 :                 if( !sStyleName.isEmpty() )
     537             :                 {
     538           0 :                         GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     539             :                                                   XML_FONT_NAME,
     540           0 :                                                   sStyleName );
     541             :                 }
     542             :                 else
     543             :                 {
     544         407 :                     Any aAny;
     545         814 :                     OUString sTemp;
     546             : 
     547             :                     const SvXMLUnitConverter& rUnitConv =
     548         407 :                         GetExport().GetMM100UnitConverter();
     549         814 :                     XMLFontFamilyNamePropHdl aFamilyNameHdl;
     550         407 :                     aAny <<= sBulletFontName;
     551         407 :                     if( aFamilyNameHdl.exportXML( sTemp, aAny, rUnitConv ) )
     552         407 :                         GetExport().AddAttribute( XML_NAMESPACE_FO,
     553         407 :                                                   XML_FONT_FAMILY, sTemp );
     554             : 
     555         407 :                     if( !sBulletFontStyleName.isEmpty() )
     556           0 :                         GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     557             :                                                   XML_FONT_STYLE_NAME,
     558           0 :                                                   sBulletFontStyleName );
     559             : 
     560         814 :                     XMLFontFamilyPropHdl aFamilyHdl;
     561         407 :                     aAny <<= (sal_Int16)eBulletFontFamily;
     562         407 :                     if( aFamilyHdl.exportXML( sTemp, aAny, rUnitConv  ) )
     563           8 :                         GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     564             :                                                   XML_FONT_FAMILY_GENERIC,
     565           8 :                                                   sTemp );
     566             : 
     567         814 :                     XMLFontPitchPropHdl aPitchHdl;
     568         407 :                     aAny <<= (sal_Int16)eBulletFontPitch;
     569         407 :                     if( aPitchHdl.exportXML( sTemp, aAny, rUnitConv  ) )
     570           6 :                         GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     571           6 :                                                   XML_FONT_PITCH, sTemp );
     572             : 
     573         814 :                     XMLFontEncodingPropHdl aEncHdl;
     574         407 :                     aAny <<= (sal_Int16)eBulletFontEncoding;
     575         407 :                     if( aEncHdl.exportXML( sTemp, aAny, rUnitConv  ) )
     576          10 :                         GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     577         417 :                                                   XML_FONT_CHARSET, sTemp );
     578         407 :                 }
     579             :             }
     580             :         }
     581        1050 :         if( NumberingType::BITMAP != eType )
     582             :         {
     583             :             // fo:color = "#..."
     584        1050 :             if( bHasColor )
     585             :             {
     586         430 :                 if (0xffffffff == static_cast<sal_uInt32>(nColor))
     587             :                 {
     588         390 :                     GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_USE_WINDOW_FONT_COLOR, XML_TRUE );
     589             :                 }
     590             :                 else
     591             :                 {
     592          40 :                     ::sax::Converter::convertColor( sBuffer, nColor );
     593          40 :                     GetExport().AddAttribute( XML_NAMESPACE_FO, XML_COLOR,
     594          80 :                                   sBuffer.makeStringAndClear() );
     595             :                 }
     596             :             }
     597             :             // fo:height="...%"
     598        1050 :             if( nBullRelSize )
     599             :             {
     600         430 :                 ::sax::Converter::convertPercent( sTmp, nBullRelSize );
     601         430 :                 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_FONT_SIZE,
     602         860 :                               sTmp.makeStringAndClear() );
     603             :             }
     604             :         }
     605        1050 :         if( GetExport().GetAttrList().getLength() > 0 )
     606             :         {
     607         448 :             SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_STYLE,
     608         448 :                                       XML_TEXT_PROPERTIES, true, true );
     609             :         }
     610        1050 :         if( NumberingType::BITMAP == eType && !sImageURL.isEmpty() )
     611             :         {
     612             :             // optional office:binary-data
     613           0 :             GetExport().AddEmbeddedGraphicObjectAsBase64( sImageURL );
     614        1050 :         }
     615        1050 :     }
     616             : }
     617             : 
     618             : 
     619          85 : void SvxXMLNumRuleExport::AddListStyleAttributes()
     620             : {
     621          85 : }
     622             : 
     623             : 
     624        1324 : SvxXMLNumRuleExport::SvxXMLNumRuleExport( SvXMLExport& rExp ) :
     625             :     rExport( rExp ),
     626             :     sNumberingRules( "NumberingRules" ),
     627             :     sIsPhysical( "IsPhysical" ),
     628             :     sIsContinuousNumbering( "IsContinuousNumbering" ),
     629             :     // Let list style creation depend on Load/Save option "ODF format version" (#i89178#)
     630        1324 :     mbExportPositionAndSpaceModeLabelAlignment( true )
     631             : {
     632        1324 :     switch ( GetExport().getDefaultVersion() )
     633             :     {
     634             :         case SvtSaveOptions::ODFVER_010:
     635             :         case SvtSaveOptions::ODFVER_011:
     636             :         {
     637           0 :             mbExportPositionAndSpaceModeLabelAlignment = false;
     638             :         }
     639           0 :         break;
     640             :         default: // ODFVER_UNKNOWN or ODFVER_012
     641             :         {
     642        1324 :             mbExportPositionAndSpaceModeLabelAlignment = true;
     643             :         }
     644             :     }
     645        1324 : }
     646             : 
     647        1319 : SvxXMLNumRuleExport::~SvxXMLNumRuleExport()
     648             : {
     649        1319 : }
     650             : 
     651          85 : void SvxXMLNumRuleExport::exportNumberingRule(
     652             :         const OUString& rName, bool bIsHidden,
     653             :         const Reference< XIndexReplace >& rNumRule )
     654             : {
     655          85 :     Reference< XPropertySet > xPropSet( rNumRule, UNO_QUERY );
     656         170 :     Reference< XPropertySetInfo > xPropSetInfo;
     657          85 :     if( xPropSet.is() )
     658          42 :            xPropSetInfo = xPropSet->getPropertySetInfo();
     659             : 
     660          85 :     GetExport().CheckAttrList();
     661             : 
     662             :     // style:name="..."
     663          85 :     if( !rName.isEmpty() )
     664             :     {
     665          85 :         bool bEncoded = false;
     666          85 :         GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NAME,
     667         170 :                           GetExport().EncodeStyleName( rName, &bEncoded ) );
     668          85 :         if( bEncoded )
     669           9 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_DISPLAY_NAME,
     670           9 :                                  rName);
     671             :     }
     672             : 
     673             :     // style:hidden="..."
     674          85 :     if ( bIsHidden && GetExport( ).getDefaultVersion( ) == SvtSaveOptions::ODFVER_LATEST )
     675           0 :         GetExport( ).AddAttribute( XML_NAMESPACE_STYLE, XML_HIDDEN, "true" );
     676             : 
     677             :     // text:consecutive-numbering="..."
     678          85 :     sal_Bool bContNumbering = sal_False;
     679         127 :     if( xPropSetInfo.is() &&
     680          42 :         xPropSetInfo->hasPropertyByName( sIsContinuousNumbering ) )
     681             :     {
     682          42 :         Any aAny( xPropSet->getPropertyValue( sIsContinuousNumbering ) );
     683          42 :         bContNumbering = *(sal_Bool *)aAny.getValue();
     684             :     }
     685          85 :     if( bContNumbering )
     686           0 :         GetExport().AddAttribute( XML_NAMESPACE_TEXT,
     687           0 :                                   XML_CONSECUTIVE_NUMBERING, XML_TRUE );
     688             : 
     689             :     // other application specific attributes
     690          85 :     AddListStyleAttributes();
     691             : 
     692             :     {
     693          85 :         SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_LIST_STYLE ,
     694          85 :                                   true, true );
     695          85 :         exportLevelStyles( rNumRule );
     696          85 :     }
     697          85 : }
     698             : 
     699         252 : bool SvxXMLNumRuleExport::exportStyle( const Reference< XStyle >& rStyle )
     700             : {
     701         252 :     Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
     702         504 :     Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
     703             : 
     704         504 :     Any aAny;
     705             : 
     706             :     // Don't export styles that aren't existing really. This may be the
     707             :     // case for StarOffice Writer's pool styles.
     708         252 :     if( xPropSetInfo->hasPropertyByName( sIsPhysical ) )
     709             :     {
     710         252 :         aAny = xPropSet->getPropertyValue( sIsPhysical );
     711         252 :         if( !*(sal_Bool *)aAny.getValue() )
     712         210 :             return false;
     713             :     }
     714             : 
     715          42 :     aAny = xPropSet->getPropertyValue( sNumberingRules );
     716          84 :     Reference<XIndexReplace> xNumRule;
     717          42 :     aAny >>= xNumRule;
     718             : 
     719          84 :     OUString sName = rStyle->getName();
     720             : 
     721          42 :     sal_Bool bHidden = sal_False;
     722          42 :     if ( xPropSetInfo->hasPropertyByName( "Hidden" ) )
     723             :     {
     724          42 :         aAny = xPropSet->getPropertyValue( "Hidden" );
     725          42 :         aAny >>= bHidden;
     726             :     }
     727             : 
     728          42 :     exportNumberingRule( sName, bHidden, xNumRule );
     729             : 
     730         294 :     return true;
     731             : }
     732             : 
     733          20 : void SvxXMLNumRuleExport::exportOutline()
     734             : {
     735          20 :     Reference< XChapterNumberingSupplier > xCNSupplier( GetExport().GetModel(),
     736          20 :                                                         UNO_QUERY );
     737             :     DBG_ASSERT( xCNSupplier.is(), "no chapter numbering supplier" );
     738             : 
     739          20 :     if( xCNSupplier.is() )
     740             :     {
     741          20 :         Reference< XIndexReplace > xNumRule( xCNSupplier->getChapterNumberingRules() );
     742             :         DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" );
     743             : 
     744          20 :         if( xNumRule.is() )
     745             :         {
     746             :             /* Outline style has property style:name since ODF 1.2
     747             :                Thus, export this property and adjust fix for issue #i69627# (#i90780#)
     748             :             */
     749          20 :             OUString sOutlineStyleName;
     750             :             {
     751             :                 Reference<XPropertySet> xNumRulePropSet(
     752          20 :                     xCNSupplier->getChapterNumberingRules(), UNO_QUERY );
     753          20 :                 if (xNumRulePropSet.is())
     754             :                 {
     755          20 :                     const OUString sName( "Name" );
     756          20 :                     xNumRulePropSet->getPropertyValue( sName ) >>= sOutlineStyleName;
     757          20 :                 }
     758             :             }
     759             :             const SvtSaveOptions::ODFDefaultVersion nODFVersion =
     760          20 :                                                 GetExport().getDefaultVersion();
     761          40 :             if ( ( nODFVersion == SvtSaveOptions::ODFVER_010 ||
     762          20 :                    nODFVersion == SvtSaveOptions::ODFVER_011 ) &&
     763           0 :                  GetExport().writeOutlineStyleAsNormalListStyle() )
     764             :             {
     765           0 :                 exportNumberingRule( sOutlineStyleName, false, xNumRule );
     766             :             }
     767             :             else
     768             :             {
     769          20 :                 if ( nODFVersion != SvtSaveOptions::ODFVER_010 &&
     770             :                      nODFVersion != SvtSaveOptions::ODFVER_011 )
     771             :                 {
     772             :                     // style:name="..."
     773          20 :                     GetExport().CheckAttrList();
     774          20 :                     if ( !sOutlineStyleName.isEmpty() )
     775             :                      {
     776          20 :                         bool bEncoded = false;
     777          20 :                         GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NAME,
     778          20 :                                         GetExport().EncodeStyleName( sOutlineStyleName,
     779          40 :                                                                      &bEncoded ) );
     780          20 :                         if( bEncoded )
     781           0 :                             GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     782             :                                                       XML_DISPLAY_NAME,
     783           0 :                                                       sOutlineStyleName );
     784             :                     }
     785             :                 }
     786          20 :                 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT,
     787          20 :                                           XML_OUTLINE_STYLE, true, true );
     788          20 :                 exportLevelStyles( xNumRule, true );
     789          20 :             }
     790          20 :         }
     791          20 :     }
     792          20 : }
     793             : 
     794          21 : void SvxXMLNumRuleExport::exportStyles( bool bUsed,
     795             :                                         XMLTextListAutoStylePool *pPool,
     796             :                                         bool bExportChapterNumbering )
     797             : {
     798          21 :     if( bExportChapterNumbering )
     799          20 :         exportOutline();
     800             : 
     801          21 :     Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetExport().GetModel(), UNO_QUERY );
     802             :     DBG_ASSERT( xFamiliesSupp.is(), "No XStyleFamiliesSupplier from XModel for export!" );
     803          21 :     if( xFamiliesSupp.is() )
     804             :     {
     805          21 :         Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
     806             :         DBG_ASSERT( xFamiliesSupp.is(), "getStyleFamilies() from XModel failed for export!" );
     807             : 
     808          21 :         if( xFamilies.is() )
     809             :         {
     810          21 :             const OUString aNumberStyleName( "NumberingStyles" );
     811             : 
     812          42 :             Reference< XIndexAccess > xStyles;
     813          21 :             if( xFamilies->hasByName( aNumberStyleName ) )
     814             :             {
     815          21 :                 xFamilies->getByName( aNumberStyleName ) >>= xStyles;
     816             : 
     817             :                 DBG_ASSERT( xStyles.is(), "Style not found for export!" );
     818             : 
     819          21 :                 if( xStyles.is() )
     820             :                 {
     821          21 :                     const sal_Int32 nStyles = xStyles->getCount();
     822             : 
     823         273 :                     for( sal_Int32 i=0; i < nStyles; i++ )
     824             :                     {
     825         252 :                         Reference< XStyle > xStyle;
     826         252 :                         xStyles->getByIndex( i ) >>= xStyle;
     827             : 
     828         252 :                         if( !bUsed || xStyle->isInUse() )
     829             :                         {
     830         252 :                             exportStyle( xStyle );
     831         252 :                             if( pPool )
     832         252 :                                 pPool->RegisterName( xStyle->getName() );
     833             :                         }
     834         252 :                     }
     835             :                 }
     836          21 :             }
     837          21 :         }
     838          21 :     }
     839          21 : }
     840             : 
     841             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10