LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/editeng/source/items - frmitems.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 961 2004 48.0 %
Date: 2013-07-09 Functions: 186 270 68.9 %
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 <com/sun/star/uno/Any.hxx>
      21             : #include <com/sun/star/drawing/LineStyle.hpp>
      22             : #include <com/sun/star/script/Converter.hpp>
      23             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      24             : #include <com/sun/star/table/ShadowLocation.hpp>
      25             : #include <com/sun/star/table/TableBorder.hpp>
      26             : #include <com/sun/star/table/ShadowFormat.hpp>
      27             : #include <com/sun/star/table/CellRangeAddress.hpp>
      28             : #include <com/sun/star/table/CellContentType.hpp>
      29             : #include <com/sun/star/table/TableOrientation.hpp>
      30             : #include <com/sun/star/util/SortField.hpp>
      31             : #include <com/sun/star/util/SortFieldType.hpp>
      32             : #include <com/sun/star/table/BorderLine2.hpp>
      33             : #include <com/sun/star/table/BorderLineStyle.hpp>
      34             : #include <com/sun/star/table/CellOrientation.hpp>
      35             : #include <com/sun/star/table/CellAddress.hpp>
      36             : #include <com/sun/star/style/PageStyleLayout.hpp>
      37             : #include <com/sun/star/style/BreakType.hpp>
      38             : #include <com/sun/star/style/GraphicLocation.hpp>
      39             : #include <com/sun/star/awt/Rectangle.hpp>
      40             : #include <com/sun/star/awt/Selection.hpp>
      41             : #include <com/sun/star/awt/Size.hpp>
      42             : #include <com/sun/star/text/WritingMode2.hpp>
      43             : #include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
      44             : #include <com/sun/star/drawing/ShadingPattern.hpp>
      45             : 
      46             : #include <unotools/ucbstreamhelper.hxx>
      47             : #include <limits.h>
      48             : #include <comphelper/processfactory.hxx>
      49             : #include <svtools/grfmgr.hxx>
      50             : #include <tools/urlobj.hxx>
      51             : #include <comphelper/types.hxx>
      52             : #include <svl/memberid.hrc>
      53             : #include <svl/cntwall.hxx>
      54             : #include <svtools/borderhelper.hxx>
      55             : #include <rtl/ustring.hxx>
      56             : #include <rtl/ustrbuf.hxx>
      57             : #include <vcl/graphicfilter.hxx>
      58             : #include <editeng/editids.hrc>
      59             : #include <editeng/editrids.hrc>
      60             : #include <editeng/pbinitem.hxx>
      61             : #include <editeng/sizeitem.hxx>
      62             : #include <editeng/lrspitem.hxx>
      63             : #include <editeng/ulspitem.hxx>
      64             : #include <editeng/prntitem.hxx>
      65             : #include <editeng/opaqitem.hxx>
      66             : #include <editeng/protitem.hxx>
      67             : #include <editeng/shaditem.hxx>
      68             : #include <editeng/boxitem.hxx>
      69             : #include <editeng/formatbreakitem.hxx>
      70             : #include <editeng/keepitem.hxx>
      71             : #include <editeng/lineitem.hxx>
      72             : #include <editeng/brushitem.hxx>
      73             : #include <editeng/frmdiritem.hxx>
      74             : #include <editeng/itemtype.hxx>
      75             : #include <editeng/eerdll.hxx>
      76             : #include <editeng/unoprnms.hxx>
      77             : #include <editeng/memberids.hrc>
      78             : #include <editeng/editerr.hxx>
      79             : 
      80             : using namespace ::editeng;
      81             : using namespace ::rtl;
      82             : using namespace ::com::sun::star;
      83             : using namespace ::com::sun::star::drawing;
      84             : using namespace ::com::sun::star::table::BorderLineStyle;
      85             : 
      86             : 
      87             : // Conversion for UNO
      88             : #define TWIP_TO_MM100(TWIP)     ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
      89             : #define MM100_TO_TWIP(MM100)    ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
      90             : #define TWIP_TO_MM100_UNSIGNED(TWIP)     ((((TWIP)*127L+36L)/72L))
      91             : #define MM100_TO_TWIP_UNSIGNED(MM100)    ((((MM100)*72L+63L)/127L))
      92             : 
      93             : /*
      94             : SvxBorderLine is not an SfxPoolItem, and has no Store/Create serialization/deserialization methods.
      95             : Since border line information needs to be serialized by the table autoformat code, these file-local
      96             : methods are defined to encapsulate the necessary serialization logic.
      97             : */
      98             : namespace
      99             : {
     100             :     /// Item version for saved border lines. The old version saves the line without style information.
     101             :     const int BORDER_LINE_OLD_VERSION = 0;
     102             :     /// Item version for saved border lies. The new version includes line style.
     103             :     const int BORDER_LINE_WITH_STYLE_VERSION = 1;
     104             : 
     105             :     /// Store a border line to a stream.
     106         716 :     SvStream& StoreBorderLine(SvStream &stream, const SvxBorderLine &l, sal_uInt16 version)
     107             :     {
     108         716 :         stream << l.GetColor()
     109        1432 :                << l.GetOutWidth()
     110        1432 :                << l.GetInWidth()
     111        1432 :                << l.GetDistance();
     112             : 
     113         716 :         if (version >= BORDER_LINE_WITH_STYLE_VERSION)
     114         716 :                stream << static_cast<sal_uInt16>(l.GetBorderLineStyle());
     115             : 
     116         716 :         return stream;
     117             :     }
     118             : 
     119             :     /// Creates a border line from a stream.
     120         308 :     SvxBorderLine CreateBorderLine(SvStream &stream, sal_uInt16 version)
     121             :     {
     122             :         sal_uInt16 nOutline, nInline, nDistance;
     123         308 :         sal_uInt16 nStyle = NONE;
     124         308 :         Color aColor;
     125         308 :         stream >> aColor >> nOutline >> nInline >> nDistance;
     126             : 
     127         308 :         if (version >= BORDER_LINE_WITH_STYLE_VERSION)
     128           0 :             stream >> nStyle;
     129             : 
     130         308 :         SvxBorderLine border(&aColor);
     131         308 :         border.GuessLinesWidths(nStyle, nOutline, nInline, nDistance);
     132         308 :         return border;
     133             :     }
     134             : 
     135             :     /// Retrieves a BORDER_LINE_* version from a BOX_BORDER_* version.
     136        1024 :     sal_uInt16 BorderLineVersionFromBoxVersion(sal_uInt16 boxVersion)
     137             :     {
     138        1024 :         return (boxVersion >= BOX_BORDER_STYLE_VERSION)? BORDER_LINE_WITH_STYLE_VERSION : BORDER_LINE_OLD_VERSION;
     139             :     }
     140             : }
     141             : 
     142        4310 : TYPEINIT1_FACTORY(SvxPaperBinItem, SfxByteItem, new SvxPaperBinItem(0));
     143        6956 : TYPEINIT1_FACTORY(SvxSizeItem, SfxPoolItem, new SvxSizeItem(0));
     144      567813 : TYPEINIT1_FACTORY(SvxLRSpaceItem, SfxPoolItem, new SvxLRSpaceItem(0));
     145      490260 : TYPEINIT1_FACTORY(SvxULSpaceItem, SfxPoolItem, new SvxULSpaceItem(0));
     146        2784 : TYPEINIT1_FACTORY(SvxPrintItem, SfxBoolItem, new SvxPrintItem(0));
     147        2807 : TYPEINIT1_FACTORY(SvxOpaqueItem, SfxBoolItem, new SvxOpaqueItem(0));
     148        5780 : TYPEINIT1_FACTORY(SvxProtectItem, SfxPoolItem, new SvxProtectItem(0));
     149       16485 : TYPEINIT1_FACTORY(SvxBrushItem, SfxPoolItem, new SvxBrushItem(0));
     150        4652 : TYPEINIT1_FACTORY(SvxShadowItem, SfxPoolItem, new SvxShadowItem(0));
     151       49223 : TYPEINIT1_FACTORY(SvxBoxItem, SfxPoolItem, new SvxBoxItem(0));
     152        5610 : TYPEINIT1_FACTORY(SvxBoxInfoItem, SfxPoolItem, new SvxBoxInfoItem(0));
     153        6894 : TYPEINIT1_FACTORY(SvxFmtBreakItem, SfxEnumItem, new SvxFmtBreakItem(SVX_BREAK_NONE, 0));
     154        3049 : TYPEINIT1_FACTORY(SvxFmtKeepItem, SfxBoolItem, new SvxFmtKeepItem(sal_False, 0));
     155       13297 : TYPEINIT1_FACTORY(SvxLineItem, SfxPoolItem, new SvxLineItem(0));
     156      346077 : TYPEINIT1_FACTORY(SvxFrameDirectionItem, SfxUInt16Item, new SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP, 0));
     157             : 
     158             : // class SvxPaperBinItem ------------------------------------------------
     159             : 
     160          16 : SfxPoolItem* SvxPaperBinItem::Clone( SfxItemPool* ) const
     161             : {
     162          16 :     return new SvxPaperBinItem( *this );
     163             : }
     164             : 
     165             : // -----------------------------------------------------------------------
     166             : 
     167           0 : SvStream& SvxPaperBinItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
     168             : {
     169           0 :     rStrm << GetValue();
     170           0 :     return rStrm;
     171             : }
     172             : 
     173             : // -----------------------------------------------------------------------
     174             : 
     175           0 : SfxPoolItem* SvxPaperBinItem::Create( SvStream& rStrm, sal_uInt16 ) const
     176             : {
     177             :     sal_Int8 nBin;
     178           0 :     rStrm >> nBin;
     179           0 :     return new SvxPaperBinItem( Which(), nBin );
     180             : }
     181             : 
     182             : // -----------------------------------------------------------------------
     183             : 
     184           0 : SfxItemPresentation SvxPaperBinItem::GetPresentation
     185             : (
     186             :     SfxItemPresentation ePres,
     187             :     SfxMapUnit          /*eCoreUnit*/,
     188             :     SfxMapUnit          /*ePresUnit*/,
     189             :     OUString&           rText, const IntlWrapper *
     190             : )   const
     191             : {
     192           0 :     switch ( ePres )
     193             :     {
     194             :         case SFX_ITEM_PRESENTATION_NONE:
     195           0 :             rText = OUString();
     196           0 :             return SFX_ITEM_PRESENTATION_NONE;
     197             : 
     198             :         case SFX_ITEM_PRESENTATION_NAMELESS:
     199           0 :             rText = OUString::number( GetValue() );
     200           0 :             return SFX_ITEM_PRESENTATION_NAMELESS;
     201             : 
     202             :         case SFX_ITEM_PRESENTATION_COMPLETE:
     203             :         {
     204           0 :             sal_uInt8 nValue = GetValue();
     205             : 
     206           0 :             if ( PAPERBIN_PRINTER_SETTINGS == nValue )
     207           0 :                 rText = EE_RESSTR(RID_SVXSTR_PAPERBIN_SETTINGS);
     208             :             else
     209             :             {
     210           0 :                 rText = EE_RESSTR(RID_SVXSTR_PAPERBIN) + " " + OUString::number( nValue );
     211             :             }
     212           0 :             return SFX_ITEM_PRESENTATION_COMPLETE;
     213             :         }
     214             :         //no break necessary
     215             :         default: ;//prevent warning
     216             :     }
     217             : 
     218           0 :     return SFX_ITEM_PRESENTATION_NONE;
     219             : }
     220             : 
     221             : // class SvxSizeItem -----------------------------------------------------
     222             : 
     223        7220 : SvxSizeItem::SvxSizeItem( const sal_uInt16 nId, const Size& rSize ) :
     224             : 
     225             :     SfxPoolItem( nId ),
     226             : 
     227        7220 :     aSize( rSize )
     228             : {
     229        7220 : }
     230             : 
     231             : // -----------------------------------------------------------------------
     232         205 : bool SvxSizeItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     233             : {
     234         205 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     235         205 :     nMemberId &= ~CONVERT_TWIPS;
     236             : 
     237         205 :     awt::Size aTmp(aSize.Width(), aSize.Height());
     238         205 :     if( bConvert )
     239             :     {
     240          96 :         aTmp.Height = TWIP_TO_MM100(aTmp.Height);
     241          96 :         aTmp.Width = TWIP_TO_MM100(aTmp.Width);
     242             :     }
     243             : 
     244         205 :     switch( nMemberId )
     245             :     {
     246         114 :         case MID_SIZE_SIZE:  rVal <<= aTmp; break;
     247          25 :         case MID_SIZE_WIDTH: rVal <<= aTmp.Width; break;
     248          66 :         case MID_SIZE_HEIGHT: rVal <<= aTmp.Height;  break;
     249           0 :         default: OSL_FAIL("Wrong MemberId!"); return false;
     250             :     }
     251             : 
     252         205 :     return true;
     253             : }
     254             : // -----------------------------------------------------------------------
     255        1495 : bool SvxSizeItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     256             : {
     257        1495 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     258        1495 :     nMemberId &= ~CONVERT_TWIPS;
     259             : 
     260        1495 :     switch( nMemberId )
     261             :     {
     262             :         case MID_SIZE_SIZE:
     263             :         {
     264         140 :             awt::Size aTmp;
     265         140 :             if( rVal >>= aTmp )
     266             :             {
     267         140 :                 if(bConvert)
     268             :                 {
     269          31 :                     aTmp.Height = MM100_TO_TWIP(aTmp.Height);
     270          31 :                     aTmp.Width = MM100_TO_TWIP(aTmp.Width);
     271             :                 }
     272         140 :                 aSize = Size( aTmp.Width, aTmp.Height );
     273             :             }
     274             :             else
     275             :             {
     276           0 :                 return false;
     277             :             }
     278             :         }
     279         140 :         break;
     280             :         case MID_SIZE_WIDTH:
     281             :         {
     282         443 :             sal_Int32 nVal = 0;
     283         443 :             if(!(rVal >>= nVal ))
     284           0 :                 return false;
     285             : 
     286         443 :             aSize.Width() = bConvert ? MM100_TO_TWIP(nVal) : nVal;
     287             :         }
     288         443 :         break;
     289             :         case MID_SIZE_HEIGHT:
     290             :         {
     291         912 :             sal_Int32 nVal = 0;
     292         912 :             if(!(rVal >>= nVal))
     293           0 :                 return true;
     294             : 
     295         912 :             aSize.Height() = bConvert ? MM100_TO_TWIP(nVal) : nVal;
     296             :         }
     297         912 :         break;
     298             :         default: OSL_FAIL("Wrong MemberId!");
     299           0 :             return false;
     300             :     }
     301        1495 :     return true;
     302             : }
     303             : 
     304             : // -----------------------------------------------------------------------
     305             : 
     306        1329 : SvxSizeItem::SvxSizeItem( const sal_uInt16 nId ) :
     307             : 
     308        1329 :     SfxPoolItem( nId )
     309             : {
     310        1329 : }
     311             : 
     312             : // -----------------------------------------------------------------------
     313             : 
     314        2626 : int SvxSizeItem::operator==( const SfxPoolItem& rAttr ) const
     315             : {
     316             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
     317             : 
     318        2626 :     return ( aSize == ( (SvxSizeItem&)rAttr ).GetSize() );
     319             : }
     320             : 
     321             : // -----------------------------------------------------------------------
     322             : 
     323       14805 : SfxPoolItem* SvxSizeItem::Clone( SfxItemPool* ) const
     324             : {
     325       14805 :     return new SvxSizeItem( *this );
     326             : }
     327             : 
     328             : //------------------------------------------------------------------------
     329             : 
     330           0 : SfxItemPresentation SvxSizeItem::GetPresentation
     331             : (
     332             :     SfxItemPresentation ePres,
     333             :     SfxMapUnit          eCoreUnit,
     334             :     SfxMapUnit          ePresUnit,
     335             :     OUString&           rText, const IntlWrapper *pIntl
     336             : )   const
     337             : {
     338           0 :     OUString cpDelimTmp(cpDelim);
     339           0 :     switch ( ePres )
     340             :     {
     341             :         case SFX_ITEM_PRESENTATION_NONE:
     342           0 :             rText = OUString();
     343           0 :             return SFX_ITEM_PRESENTATION_NONE;
     344             : 
     345             :         case SFX_ITEM_PRESENTATION_NAMELESS:
     346           0 :             rText = GetMetricText( aSize.Width(), eCoreUnit, ePresUnit, pIntl ) +
     347           0 :                     cpDelimTmp +
     348           0 :                     GetMetricText( aSize.Height(), eCoreUnit, ePresUnit, pIntl );
     349           0 :             return SFX_ITEM_PRESENTATION_NAMELESS;
     350             : 
     351             :         case SFX_ITEM_PRESENTATION_COMPLETE:
     352           0 :             rText = EE_RESSTR(RID_SVXITEMS_SIZE_WIDTH) +
     353           0 :                     GetMetricText( aSize.Width(), eCoreUnit, ePresUnit, pIntl ) +
     354           0 :                     EE_RESSTR(GetMetricId(ePresUnit)) +
     355           0 :                     cpDelimTmp +
     356           0 :                     EE_RESSTR(RID_SVXITEMS_SIZE_HEIGHT) +
     357           0 :                     GetMetricText( aSize.Height(), eCoreUnit, ePresUnit, pIntl ) +
     358           0 :                     EE_RESSTR(GetMetricId(ePresUnit));
     359           0 :             return SFX_ITEM_PRESENTATION_COMPLETE;
     360             :         //no break necessary
     361             :         default: ;//prevent warning
     362             : 
     363             :     }
     364           0 :     return SFX_ITEM_PRESENTATION_NONE;
     365             : }
     366             : 
     367             : // -----------------------------------------------------------------------
     368             : 
     369           0 : SvStream& SvxSizeItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
     370             : {
     371             :     //#fdo39428 SvStream no longer supports operator<<(long)
     372           0 :     rStrm << sal::static_int_cast<sal_Int32>(aSize.Width());
     373           0 :     rStrm << sal::static_int_cast<sal_Int32>(aSize.Height());
     374           0 :     return rStrm;
     375             : }
     376             : 
     377             : // -----------------------------------------------------------------------
     378             : 
     379           0 : bool SvxSizeItem::ScaleMetrics( long nMult, long nDiv )
     380             : {
     381           0 :     aSize.Width() = Scale( aSize.Width(), nMult, nDiv );
     382           0 :     aSize.Height() = Scale( aSize.Height(), nMult, nDiv );
     383           0 :     return true;
     384             : }
     385             : 
     386             : // -----------------------------------------------------------------------
     387             : 
     388           0 : bool SvxSizeItem::HasMetrics() const
     389             : {
     390           0 :     return true;
     391             : }
     392             : 
     393             : // -----------------------------------------------------------------------
     394             : 
     395           0 : SfxPoolItem* SvxSizeItem::Create( SvStream& rStrm, sal_uInt16 ) const
     396             : {
     397             :     //#fdo39428 SvStream no longer supports operator>>(long&)
     398           0 :     sal_Int32 nWidth(0), nHeight(0);
     399           0 :     rStrm >> nWidth >> nHeight;
     400             : 
     401           0 :     SvxSizeItem* pAttr = new SvxSizeItem( Which() );
     402           0 :     pAttr->SetSize(Size(nWidth, nHeight));
     403             : 
     404           0 :     return pAttr;
     405             : }
     406             : 
     407             : // class SvxLRSpaceItem --------------------------------------------------
     408             : 
     409        8025 : SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId ) :
     410             : 
     411             :     SfxPoolItem( nId ),
     412             : 
     413             :     nFirstLineOfst  ( 0 ),
     414             :     nTxtLeft        ( 0 ),
     415             :     nLeftMargin     ( 0 ),
     416             :     nRightMargin    ( 0 ),
     417             :     nPropFirstLineOfst( 100 ),
     418             :     nPropLeftMargin( 100 ),
     419             :     nPropRightMargin( 100 ),
     420        8025 :     bAutoFirst      ( 0 )
     421             : {
     422        8025 : }
     423             : 
     424             : // -----------------------------------------------------------------------
     425             : 
     426        2233 : SvxLRSpaceItem::SvxLRSpaceItem( const long nLeft, const long nRight,
     427             :                                 const long nTLeft, const short nOfset,
     428             :                                 const sal_uInt16 nId ) :
     429             : 
     430             :     SfxPoolItem( nId ),
     431             : 
     432             :     nFirstLineOfst  ( nOfset ),
     433             :     nTxtLeft        ( nTLeft ),
     434             :     nLeftMargin     ( nLeft ),
     435             :     nRightMargin    ( nRight ),
     436             :     nPropFirstLineOfst( 100 ),
     437             :     nPropLeftMargin( 100 ),
     438             :     nPropRightMargin( 100 ),
     439        2233 :     bAutoFirst      ( 0 )
     440             : {
     441        2233 : }
     442             : 
     443             : // -----------------------------------------------------------------------
     444         701 : bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     445             : {
     446         701 :     bool bRet = true;
     447         701 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     448         701 :     nMemberId &= ~CONVERT_TWIPS;
     449         701 :     switch( nMemberId )
     450             :     {
     451             :         // now all signed
     452             :         case MID_L_MARGIN:
     453          83 :             rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nLeftMargin) : nLeftMargin);
     454          83 :             break;
     455             : 
     456             :         case MID_TXT_LMARGIN :
     457         159 :             rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nTxtLeft) : nTxtLeft);
     458         159 :         break;
     459             :         case MID_R_MARGIN:
     460         234 :             rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nRightMargin) : nRightMargin);
     461         234 :             break;
     462             :         case MID_L_REL_MARGIN:
     463          17 :             rVal <<= (sal_Int16)nPropLeftMargin;
     464          17 :         break;
     465             :         case MID_R_REL_MARGIN:
     466          17 :             rVal <<= (sal_Int16)nPropRightMargin;
     467          17 :         break;
     468             : 
     469             :         case MID_FIRST_LINE_INDENT:
     470         161 :             rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nFirstLineOfst) : nFirstLineOfst);
     471         161 :             break;
     472             : 
     473             :         case MID_FIRST_LINE_REL_INDENT:
     474          13 :             rVal <<= (sal_Int16)(nPropFirstLineOfst);
     475          13 :             break;
     476             : 
     477             :         case MID_FIRST_AUTO:
     478          17 :             rVal = Bool2Any(IsAutoFirst());
     479          17 :             break;
     480             : 
     481             :         default:
     482           0 :             bRet = false;
     483             :             OSL_FAIL("unknown MemberId");
     484             :     }
     485         701 :     return bRet;
     486             : }
     487             : 
     488             : // -----------------------------------------------------------------------
     489        3934 : bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     490             : {
     491        3934 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     492        3934 :     nMemberId &= ~CONVERT_TWIPS;
     493        3934 :     sal_Int32 nVal = 0;
     494        3934 :     if( nMemberId != MID_FIRST_AUTO &&
     495        3894 :             nMemberId != MID_L_REL_MARGIN && nMemberId != MID_R_REL_MARGIN)
     496        3892 :         if(!(rVal >>= nVal))
     497           0 :             return sal_False;
     498             : 
     499        3934 :     switch( nMemberId )
     500             :     {
     501             :         case MID_L_MARGIN:
     502         976 :             SetLeft((sal_Int32)bConvert ? MM100_TO_TWIP(nVal) : nVal);
     503         976 :             break;
     504             : 
     505             :         case MID_TXT_LMARGIN :
     506         884 :             SetTxtLeft((sal_Int32)bConvert ? MM100_TO_TWIP(nVal) : nVal);
     507         884 :         break;
     508             : 
     509             :         case MID_R_MARGIN:
     510        1664 :             SetRight((sal_Int32)    bConvert ? MM100_TO_TWIP(nVal) : nVal);
     511        1664 :             break;
     512             :         case MID_L_REL_MARGIN:
     513             :         case MID_R_REL_MARGIN:
     514             :         {
     515           4 :             sal_Int32 nRel = 0;
     516           4 :             if((rVal >>= nRel) && nRel >= 0 && nRel < USHRT_MAX)
     517             :             {
     518           4 :                 if(MID_L_REL_MARGIN== nMemberId)
     519           2 :                     nPropLeftMargin = (sal_uInt16)nRel;
     520             :                 else
     521           2 :                     nPropRightMargin = (sal_uInt16)nRel;
     522             :             }
     523             :             else
     524           0 :                 return false;
     525             :         }
     526           4 :         break;
     527             :         case MID_FIRST_LINE_INDENT     :
     528         368 :             SetTxtFirstLineOfst((short)(bConvert ?  MM100_TO_TWIP(nVal) : nVal));
     529         368 :             break;
     530             : 
     531             :         case MID_FIRST_LINE_REL_INDENT:
     532           0 :             SetPropTxtFirstLineOfst ( (sal_uInt16)nVal );
     533           0 :             break;
     534             : 
     535             :         case MID_FIRST_AUTO:
     536          38 :             SetAutoFirst( Any2Bool(rVal) );
     537          38 :             break;
     538             : 
     539             :         default:
     540             :             OSL_FAIL("unknown MemberId");
     541           0 :             return false;
     542             :     }
     543        3934 :     return true;
     544             : }
     545             : 
     546             : // -----------------------------------------------------------------------
     547             : 
     548             : // Adapt nLeftMargin and nTxtLeft.
     549             : 
     550        2774 : void SvxLRSpaceItem::AdjustLeft()
     551             : {
     552        2774 :     if ( 0 > nFirstLineOfst )
     553         457 :         nLeftMargin = nTxtLeft + nFirstLineOfst;
     554             :     else
     555        2317 :         nLeftMargin = nTxtLeft;
     556        2774 : }
     557             : 
     558             : // -----------------------------------------------------------------------
     559             : 
     560       37579 : int SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const
     561             : {
     562             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
     563             : 
     564             :     return (
     565       55481 :         nLeftMargin == ((SvxLRSpaceItem&)rAttr).GetLeft()  &&
     566       32410 :         nRightMargin == ((SvxLRSpaceItem&)rAttr).GetRight() &&
     567       27800 :         nFirstLineOfst == ((SvxLRSpaceItem&)rAttr).GetTxtFirstLineOfst() &&
     568       26584 :         nPropLeftMargin == ((SvxLRSpaceItem&)rAttr).GetPropLeft()  &&
     569       26578 :         nPropRightMargin == ((SvxLRSpaceItem&)rAttr).GetPropRight() &&
     570       64151 :         nPropFirstLineOfst == ((SvxLRSpaceItem&)rAttr).GetPropTxtFirstLineOfst() &&
     571       50865 :         bAutoFirst == ((SvxLRSpaceItem&)rAttr).IsAutoFirst() );
     572             : }
     573             : 
     574             : // -----------------------------------------------------------------------
     575             : 
     576       14811 : SfxPoolItem* SvxLRSpaceItem::Clone( SfxItemPool* ) const
     577             : {
     578       14811 :     return new SvxLRSpaceItem( *this );
     579             : }
     580             : 
     581             : //------------------------------------------------------------------------
     582             : 
     583           0 : SfxItemPresentation SvxLRSpaceItem::GetPresentation
     584             : (
     585             :     SfxItemPresentation ePres,
     586             :     SfxMapUnit          eCoreUnit,
     587             :     SfxMapUnit          ePresUnit,
     588             :     OUString&           rText, const IntlWrapper* pIntl
     589             : )   const
     590             : {
     591           0 :     switch ( ePres )
     592             :     {
     593             :         case SFX_ITEM_PRESENTATION_NONE:
     594           0 :             rText = OUString();
     595           0 :             return SFX_ITEM_PRESENTATION_NONE;
     596             :         case SFX_ITEM_PRESENTATION_NAMELESS:
     597             :         {
     598           0 :             if ( 100 != nPropLeftMargin )
     599           0 :                 rText = OUString::number( nPropLeftMargin ) + "%";
     600             :             else
     601           0 :                 rText = GetMetricText( (long)nLeftMargin,
     602           0 :                                        eCoreUnit, ePresUnit, pIntl );
     603           0 :             rText += OUString(cpDelim);
     604           0 :             if ( 100 != nPropFirstLineOfst )
     605           0 :                 rText = rText + OUString::number( nPropFirstLineOfst ) + "%";
     606             :             else
     607           0 :                 rText += GetMetricText( (long)nFirstLineOfst,
     608           0 :                                         eCoreUnit, ePresUnit, pIntl );
     609           0 :             rText += OUString(cpDelim);
     610           0 :             if ( 100 != nRightMargin )
     611           0 :                 rText = rText + OUString::number( nRightMargin ) + "%";
     612             :             else
     613           0 :                 rText += GetMetricText( (long)nRightMargin,
     614           0 :                                         eCoreUnit, ePresUnit, pIntl );
     615           0 :             return SFX_ITEM_PRESENTATION_NAMELESS;
     616             :         }
     617             :         case SFX_ITEM_PRESENTATION_COMPLETE:
     618             :         {
     619           0 :             rText = EE_RESSTR(RID_SVXITEMS_LRSPACE_LEFT);
     620           0 :             if ( 100 != nPropLeftMargin )
     621           0 :                 rText += OUString::number( nPropLeftMargin ) + "%";
     622             :             else
     623             :             {
     624           0 :                 rText = rText +
     625           0 :                         GetMetricText( (long)nLeftMargin, eCoreUnit, ePresUnit, pIntl ) +
     626           0 :                         EE_RESSTR(GetMetricId(ePresUnit));
     627             :             }
     628           0 :             rText += OUString(cpDelim);
     629           0 :             if ( 100 != nPropFirstLineOfst || nFirstLineOfst )
     630             :             {
     631           0 :                 rText += EE_RESSTR(RID_SVXITEMS_LRSPACE_FLINE);
     632           0 :                 if ( 100 != nPropFirstLineOfst )
     633           0 :                     rText = rText + OUString::number( nPropFirstLineOfst ) + "%";
     634             :                 else
     635             :                 {
     636           0 :                     rText = rText +
     637             :                             GetMetricText( (long)nFirstLineOfst,
     638           0 :                                             eCoreUnit, ePresUnit, pIntl ) +
     639           0 :                             EE_RESSTR(GetMetricId(ePresUnit));
     640             :                 }
     641           0 :                 rText += OUString(cpDelim);
     642             :             }
     643           0 :             rText += EE_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT);
     644           0 :             if ( 100 != nPropRightMargin )
     645           0 :                 rText = rText + OUString::number( nPropRightMargin ) + "%";
     646             :             else
     647             :             {
     648           0 :                 rText = rText +
     649             :                         GetMetricText( (long)nRightMargin,
     650           0 :                                        eCoreUnit, ePresUnit, pIntl ) +
     651           0 :                         EE_RESSTR(GetMetricId(ePresUnit));
     652             :             }
     653           0 :             return SFX_ITEM_PRESENTATION_COMPLETE;
     654             :         }
     655             :         default: ;//prevent warning
     656             :     }
     657           0 :     return SFX_ITEM_PRESENTATION_NONE;
     658             : }
     659             : 
     660             : // -----------------------------------------------------------------------
     661             : 
     662             : // BulletFI: Before 501 in the Outliner the bullet was not on the position of
     663             : // the FI, so in older documents one must set FI to 0.
     664             : #define BULLETLR_MARKER 0x599401FE
     665             : 
     666           0 : SvStream& SvxLRSpaceItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
     667             : {
     668           0 :     short nSaveFI = nFirstLineOfst;
     669           0 :     ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( 0 );  // nLeftMargin is manipulated together with this, see Create()
     670             : 
     671           0 :     sal_uInt16 nMargin = 0;
     672           0 :     if( nLeftMargin > 0 )
     673           0 :         nMargin = sal_uInt16( nLeftMargin );
     674           0 :     rStrm << nMargin;
     675           0 :     rStrm << nPropLeftMargin;
     676           0 :     if( nRightMargin > 0 )
     677           0 :         nMargin = sal_uInt16( nRightMargin );
     678             :     else
     679           0 :         nMargin = 0;
     680           0 :     rStrm << nMargin;
     681           0 :     rStrm << nPropRightMargin;
     682           0 :     rStrm << nFirstLineOfst;
     683           0 :     rStrm << nPropFirstLineOfst;
     684           0 :     if( nTxtLeft > 0 )
     685           0 :         nMargin = sal_uInt16( nTxtLeft );
     686             :     else
     687           0 :         nMargin = 0;
     688           0 :     rStrm << nMargin;
     689           0 :     if( nItemVersion >= LRSPACE_AUTOFIRST_VERSION )
     690             :     {
     691           0 :         sal_Int8 nAutoFirst = bAutoFirst ? 1 : 0;
     692           0 :         if( nItemVersion >= LRSPACE_NEGATIVE_VERSION &&
     693           0 :             ( nLeftMargin < 0 || nRightMargin < 0 || nTxtLeft < 0 ) )
     694           0 :             nAutoFirst |= 0x80;
     695           0 :         rStrm << nAutoFirst;
     696             : 
     697             :         // From 6.0 onwards, do not write Magic numbers...
     698             :         DBG_ASSERT( rStrm.GetVersion() <= SOFFICE_FILEFORMAT_50, "Change File format SvxLRSpaceItem!" );
     699           0 :         rStrm << (sal_uInt32) BULLETLR_MARKER;
     700           0 :         rStrm << nSaveFI;
     701             : 
     702           0 :         if( 0x80 & nAutoFirst )
     703             :         {
     704           0 :             rStrm << static_cast<sal_Int32>(nLeftMargin);
     705           0 :             rStrm << static_cast<sal_Int32>(nRightMargin);
     706             :         }
     707             :     }
     708             : 
     709           0 :     ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( nSaveFI );
     710             : 
     711           0 :     return rStrm;
     712             : }
     713             : 
     714             : // -----------------------------------------------------------------------
     715             : 
     716           0 : SfxPoolItem* SvxLRSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
     717             : {
     718             :     sal_uInt16 left, prpleft, right, prpright, prpfirstline, txtleft;
     719             :     short firstline;
     720           0 :     sal_Int8 autofirst = 0;
     721             : 
     722           0 :     if ( nVersion >= LRSPACE_AUTOFIRST_VERSION )
     723             :     {
     724           0 :         rStrm >> left >> prpleft >> right >> prpright >> firstline >>
     725           0 :                  prpfirstline >> txtleft >> autofirst;
     726             : 
     727           0 :         sal_uInt32 nPos = rStrm.Tell();
     728             :         sal_uInt32 nMarker;
     729           0 :         rStrm >> nMarker;
     730           0 :         if ( nMarker == BULLETLR_MARKER )
     731             :         {
     732           0 :             rStrm >> firstline;
     733           0 :             if ( firstline < 0 )
     734           0 :                 left = left + static_cast<sal_uInt16>(firstline);   // see below: txtleft = ...
     735             :         }
     736             :         else
     737           0 :             rStrm.Seek( nPos );
     738             :     }
     739           0 :     else if ( nVersion == LRSPACE_TXTLEFT_VERSION )
     740             :     {
     741           0 :         rStrm >> left >> prpleft >> right >> prpright >> firstline >>
     742           0 :                  prpfirstline >> txtleft;
     743             :     }
     744           0 :     else if ( nVersion == LRSPACE_16_VERSION )
     745             :     {
     746           0 :         rStrm >> left >> prpleft >> right >> prpright >> firstline >>
     747           0 :                  prpfirstline;
     748             :     }
     749             :     else
     750             :     {
     751             :         sal_Int8 nL, nR, nFL;
     752           0 :         rStrm >> left >> nL >> right >> nR >> firstline >> nFL;
     753           0 :         prpleft = (sal_uInt16)nL;
     754           0 :         prpright = (sal_uInt16)nR;
     755           0 :         prpfirstline = (sal_uInt16)nFL;
     756             :     }
     757             : 
     758           0 :     txtleft = firstline >= 0 ? left : left - firstline;
     759           0 :     SvxLRSpaceItem* pAttr = new SvxLRSpaceItem( Which() );
     760             : 
     761           0 :     pAttr->nLeftMargin = left;
     762           0 :     pAttr->nPropLeftMargin = prpleft;
     763           0 :     pAttr->nRightMargin = right;
     764           0 :     pAttr->nPropRightMargin = prpright;
     765           0 :     pAttr->nFirstLineOfst = firstline;
     766           0 :     pAttr->nPropFirstLineOfst = prpfirstline;
     767           0 :     pAttr->nTxtLeft = txtleft;
     768           0 :     pAttr->bAutoFirst = autofirst & 0x01;
     769           0 :     if( nVersion >= LRSPACE_NEGATIVE_VERSION && ( autofirst & 0x80 ) )
     770             :     {
     771             :         sal_Int32 nMargin;
     772           0 :         rStrm >> nMargin;
     773           0 :         pAttr->nLeftMargin = nMargin;
     774           0 :         pAttr->nTxtLeft = firstline >= 0 ? nMargin : nMargin - firstline;
     775           0 :         rStrm >> nMargin;
     776           0 :         pAttr->nRightMargin = nMargin;
     777             :     }
     778           0 :     return pAttr;
     779             : }
     780             : 
     781             : // -----------------------------------------------------------------------
     782             : 
     783        9824 : sal_uInt16 SvxLRSpaceItem::GetVersion( sal_uInt16 nFileVersion ) const
     784             : {
     785             :     return (nFileVersion == SOFFICE_FILEFORMAT_31)
     786             :                ? LRSPACE_TXTLEFT_VERSION
     787        9824 :                : LRSPACE_NEGATIVE_VERSION;
     788             : }
     789             : 
     790             : // -----------------------------------------------------------------------
     791             : 
     792           0 : bool SvxLRSpaceItem::ScaleMetrics( long nMult, long nDiv )
     793             : {
     794           0 :     nFirstLineOfst = (short)Scale( nFirstLineOfst, nMult, nDiv );
     795           0 :     nTxtLeft = Scale( nTxtLeft, nMult, nDiv );
     796           0 :     nLeftMargin = Scale( nLeftMargin, nMult, nDiv );
     797           0 :     nRightMargin = Scale( nRightMargin, nMult, nDiv );
     798           0 :     return true;
     799             : }
     800             : 
     801             : // -----------------------------------------------------------------------
     802             : 
     803           0 : bool SvxLRSpaceItem::HasMetrics() const
     804             : {
     805           0 :     return true;
     806             : }
     807             : 
     808             : // class SvxULSpaceItem --------------------------------------------------
     809             : 
     810        4820 : SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId )
     811             :     : SfxPoolItem(nId)
     812             :     , nUpper(0)
     813             :     , nLower(0)
     814             :     , bContext(false)
     815             :     , nPropUpper(100)
     816        4820 :     , nPropLower(100)
     817             : {
     818        4820 : }
     819             : 
     820             : // -----------------------------------------------------------------------
     821             : 
     822        4036 : SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp, const sal_uInt16 nLow,
     823             :                                 const sal_uInt16 nId )
     824             :     : SfxPoolItem(nId)
     825             :     , nUpper(nUp)
     826             :     , nLower(nLow)
     827             :     , bContext(false)
     828             :     , nPropUpper(100)
     829        4036 :     , nPropLower(100)
     830             : {
     831        4036 : }
     832             : 
     833             : // -----------------------------------------------------------------------
     834         801 : bool    SvxULSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     835             : {
     836         801 :     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     837         801 :     nMemberId &= ~CONVERT_TWIPS;
     838         801 :     switch( nMemberId )
     839             :     {
     840             :         // now all signed
     841             :         case 0:
     842             :         {
     843           0 :             ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale;
     844           0 :             aUpperLowerMarginScale.Upper = (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nUpper) : nUpper);
     845           0 :             aUpperLowerMarginScale.Lower = (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nLower) : nPropUpper);
     846           0 :             aUpperLowerMarginScale.ScaleUpper = (sal_Int16)nPropUpper;
     847           0 :             aUpperLowerMarginScale.ScaleLower = (sal_Int16)nPropLower;
     848           0 :             rVal <<= aUpperLowerMarginScale;
     849           0 :             break;
     850             :         }
     851         300 :         case MID_UP_MARGIN: rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nUpper) : nUpper); break;
     852         298 :         case MID_LO_MARGIN: rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nLower) : nLower); break;
     853          71 :         case MID_CTX_MARGIN: rVal <<= bContext; break;
     854          66 :         case MID_UP_REL_MARGIN: rVal <<= (sal_Int16) nPropUpper; break;
     855          66 :         case MID_LO_REL_MARGIN: rVal <<= (sal_Int16) nPropLower; break;
     856             :     }
     857         801 :     return true;
     858             : }
     859             : 
     860             : // -----------------------------------------------------------------------
     861        5858 : bool SvxULSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     862             : {
     863        5858 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     864        5858 :     nMemberId &= ~CONVERT_TWIPS;
     865        5858 :     sal_Int32 nVal = 0;
     866        5858 :     sal_Bool bVal = 0;
     867        5858 :     switch( nMemberId )
     868             :     {
     869             :         case 0:
     870             :         {
     871           0 :             ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale;
     872           0 :             if ( !(rVal >>= aUpperLowerMarginScale ))
     873           0 :                 return false;
     874             :             {
     875           0 :                 SetUpper((sal_uInt16)(bConvert ? MM100_TO_TWIP( aUpperLowerMarginScale.Upper ) : aUpperLowerMarginScale.Upper));
     876           0 :                 SetLower((sal_uInt16)(bConvert ? MM100_TO_TWIP( aUpperLowerMarginScale.Lower ) : aUpperLowerMarginScale.Lower));
     877           0 :                 if( aUpperLowerMarginScale.ScaleUpper > 1 )
     878           0 :                     nPropUpper = aUpperLowerMarginScale.ScaleUpper;
     879           0 :                 if( aUpperLowerMarginScale.ScaleLower > 1 )
     880           0 :                     nPropUpper = aUpperLowerMarginScale.ScaleLower;
     881             :             }
     882             :         }
     883             : 
     884             :         case MID_UP_MARGIN :
     885        2617 :             if(!(rVal >>= nVal) || nVal < 0)
     886           0 :                 return false;
     887        2617 :             SetUpper((sal_uInt16)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
     888        2617 :             break;
     889             :         case MID_LO_MARGIN :
     890        2808 :             if(!(rVal >>= nVal) || nVal < 0)
     891           0 :                 return false;
     892        2808 :             SetLower((sal_uInt16)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
     893        2808 :             break;
     894             :         case MID_CTX_MARGIN :
     895         429 :             if (!(rVal >>= bVal))
     896           0 :                 return false;
     897         429 :             SetContextValue(bVal);
     898         429 :             break;
     899             :         case MID_UP_REL_MARGIN:
     900             :         case MID_LO_REL_MARGIN:
     901             :         {
     902           4 :             sal_Int32 nRel = 0;
     903           4 :             if((rVal >>= nRel) && nRel > 1 )
     904             :             {
     905           4 :                 if(MID_UP_REL_MARGIN == nMemberId)
     906           2 :                     nPropUpper = (sal_uInt16)nRel;
     907             :                 else
     908           2 :                     nPropLower = (sal_uInt16)nRel;
     909             :             }
     910             :             else
     911           0 :                 return false;
     912             :         }
     913           4 :         break;
     914             : 
     915             :         default:
     916             :             OSL_FAIL("unknown MemberId");
     917           0 :             return false;
     918             :     }
     919        5858 :     return true;
     920             : }
     921             : 
     922             : // -----------------------------------------------------------------------
     923             : 
     924       63849 : int SvxULSpaceItem::operator==( const SfxPoolItem& rAttr ) const
     925             : {
     926             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
     927             : 
     928       85024 :     return ( nUpper == ( (SvxULSpaceItem&)rAttr ).nUpper &&
     929       33033 :              nLower == ( (SvxULSpaceItem&)rAttr ).nLower &&
     930       23666 :              bContext == ( (SvxULSpaceItem&)rAttr ).bContext &&
     931       87465 :              nPropUpper == ( (SvxULSpaceItem&)rAttr ).nPropUpper &&
     932       75657 :              nPropLower == ( (SvxULSpaceItem&)rAttr ).nPropLower );
     933             : }
     934             : 
     935             : // -----------------------------------------------------------------------
     936             : 
     937       15852 : SfxPoolItem* SvxULSpaceItem::Clone( SfxItemPool* ) const
     938             : {
     939       15852 :     return new SvxULSpaceItem( *this );
     940             : }
     941             : 
     942             : //------------------------------------------------------------------------
     943             : 
     944           0 : SfxItemPresentation SvxULSpaceItem::GetPresentation
     945             : (
     946             :     SfxItemPresentation ePres,
     947             :     SfxMapUnit          eCoreUnit,
     948             :     SfxMapUnit          ePresUnit,
     949             :     OUString&           rText, const IntlWrapper *pIntl
     950             : )   const
     951             : {
     952           0 :     switch ( ePres )
     953             :     {
     954             :         case SFX_ITEM_PRESENTATION_NONE:
     955           0 :             rText = OUString();
     956           0 :             return SFX_ITEM_PRESENTATION_NONE;
     957             :         case SFX_ITEM_PRESENTATION_NAMELESS:
     958             :         {
     959           0 :             if ( 100 != nPropUpper )
     960           0 :                 rText = OUString::number( nPropUpper ) + "%";
     961             :             else
     962           0 :                 rText = GetMetricText( (long)nUpper, eCoreUnit, ePresUnit, pIntl );
     963           0 :             rText += OUString(cpDelim);
     964           0 :             if ( 100 != nPropLower )
     965           0 :                 rText += OUString::number( nPropLower ) + "%";
     966             :             else
     967           0 :                 rText += GetMetricText( (long)nLower, eCoreUnit, ePresUnit, pIntl );
     968           0 :             return SFX_ITEM_PRESENTATION_NAMELESS;
     969             :         }
     970             :         case SFX_ITEM_PRESENTATION_COMPLETE:
     971             :         {
     972           0 :             rText = EE_RESSTR(RID_SVXITEMS_ULSPACE_UPPER);
     973           0 :             if ( 100 != nPropUpper )
     974           0 :                 rText += OUString::number( nPropUpper ) + "%";
     975             :             else
     976             :             {
     977           0 :                 rText = rText +
     978           0 :                         GetMetricText( (long)nUpper, eCoreUnit, ePresUnit, pIntl ) +
     979           0 :                         EE_RESSTR(GetMetricId(ePresUnit));
     980             :             }
     981           0 :             rText = rText + OUString(cpDelim) + EE_RESSTR(RID_SVXITEMS_ULSPACE_LOWER);
     982           0 :             if ( 100 != nPropLower )
     983           0 :                 rText += OUString::number( nPropLower ) + "%";
     984             :             else
     985             :             {
     986           0 :                 rText = rText +
     987           0 :                         GetMetricText( (long)nLower, eCoreUnit, ePresUnit, pIntl ) +
     988           0 :                         EE_RESSTR(GetMetricId(ePresUnit));
     989             :             }
     990           0 :             return SFX_ITEM_PRESENTATION_COMPLETE;
     991             :         }
     992             :         default: ;//prevent warning
     993             :     }
     994           0 :     return SFX_ITEM_PRESENTATION_NONE;
     995             : }
     996             : 
     997             : // -----------------------------------------------------------------------
     998             : 
     999           0 : SvStream& SvxULSpaceItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
    1000             : {
    1001           0 :     rStrm << GetUpper()
    1002           0 :           << GetPropUpper()
    1003           0 :           << GetLower()
    1004           0 :           << GetPropLower();
    1005           0 :     return rStrm;
    1006             : }
    1007             : 
    1008             : // -----------------------------------------------------------------------
    1009             : 
    1010           0 : SfxPoolItem* SvxULSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
    1011             : {
    1012           0 :     sal_uInt16 upper, lower, nPL = 0, nPU = 0;
    1013             : 
    1014           0 :     if ( nVersion == ULSPACE_16_VERSION )
    1015           0 :         rStrm >> upper >> nPU >> lower >> nPL;
    1016             :     else
    1017             :     {
    1018             :         sal_Int8 nU, nL;
    1019           0 :         rStrm >> upper >> nU >> lower >> nL;
    1020           0 :         nPL = (sal_uInt16)nL;
    1021           0 :         nPU = (sal_uInt16)nU;
    1022             :     }
    1023             : 
    1024           0 :     SvxULSpaceItem* pAttr = new SvxULSpaceItem( Which() );
    1025           0 :     pAttr->SetUpperValue( upper );
    1026           0 :     pAttr->SetLowerValue( lower );
    1027           0 :     pAttr->SetPropUpper( nPU );
    1028           0 :     pAttr->SetPropLower( nPL );
    1029           0 :     return pAttr;
    1030             : }
    1031             : 
    1032             : // -----------------------------------------------------------------------
    1033             : 
    1034        4912 : sal_uInt16 SvxULSpaceItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
    1035             : {
    1036        4912 :     return ULSPACE_16_VERSION;
    1037             : }
    1038             : 
    1039             : // -----------------------------------------------------------------------
    1040             : 
    1041           0 : bool SvxULSpaceItem::ScaleMetrics( long nMult, long nDiv )
    1042             : {
    1043           0 :     nUpper = (sal_uInt16)Scale( nUpper, nMult, nDiv );
    1044           0 :     nLower = (sal_uInt16)Scale( nLower, nMult, nDiv );
    1045           0 :     return true;
    1046             : }
    1047             : 
    1048             : // -----------------------------------------------------------------------
    1049             : 
    1050           0 : bool SvxULSpaceItem::HasMetrics() const
    1051             : {
    1052           0 :     return true;
    1053             : }
    1054             : 
    1055             : // class SvxPrintItem ----------------------------------------------------
    1056             : 
    1057           1 : SfxPoolItem* SvxPrintItem::Clone( SfxItemPool* ) const
    1058             : {
    1059           1 :     return new SvxPrintItem( *this );
    1060             : }
    1061             : 
    1062             : // -----------------------------------------------------------------------
    1063             : 
    1064           0 : SvStream& SvxPrintItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
    1065             : {
    1066           0 :     rStrm << (sal_Int8)GetValue();
    1067           0 :     return rStrm;
    1068             : }
    1069             : 
    1070             : // -----------------------------------------------------------------------
    1071             : 
    1072           0 : SfxPoolItem* SvxPrintItem::Create( SvStream& rStrm, sal_uInt16 ) const
    1073             : {
    1074             :     sal_Int8 bIsPrint;
    1075           0 :     rStrm >> bIsPrint;
    1076           0 :     return new SvxPrintItem( Which(), sal_Bool( bIsPrint != 0 ) );
    1077             : }
    1078             : 
    1079             : //------------------------------------------------------------------------
    1080             : 
    1081           0 : SfxItemPresentation SvxPrintItem::GetPresentation
    1082             : (
    1083             :     SfxItemPresentation ePres,
    1084             :     SfxMapUnit          /*eCoreUnit*/,
    1085             :     SfxMapUnit          /*ePresUnit*/,
    1086             :     OUString&           rText, const IntlWrapper *
    1087             : )   const
    1088             : {
    1089           0 :     switch ( ePres )
    1090             :     {
    1091             :         case SFX_ITEM_PRESENTATION_NONE:
    1092           0 :             rText = OUString();
    1093           0 :             return ePres;
    1094             : 
    1095             :         case SFX_ITEM_PRESENTATION_NAMELESS:
    1096             :         case SFX_ITEM_PRESENTATION_COMPLETE:
    1097             :         {
    1098           0 :             sal_uInt16 nId = RID_SVXITEMS_PRINT_FALSE;
    1099             : 
    1100           0 :             if ( GetValue() )
    1101           0 :                 nId = RID_SVXITEMS_PRINT_TRUE;
    1102           0 :             rText = EE_RESSTR(nId);
    1103           0 :             return ePres;
    1104             :         }
    1105             :         default: ;//prevent warning
    1106             :     }
    1107           0 :     return SFX_ITEM_PRESENTATION_NONE;
    1108             : }
    1109             : 
    1110             : // class SvxOpaqueItem ---------------------------------------------------
    1111             : 
    1112          35 : SfxPoolItem* SvxOpaqueItem::Clone( SfxItemPool* ) const
    1113             : {
    1114          35 :     return new SvxOpaqueItem( *this );
    1115             : }
    1116             : 
    1117             : // -----------------------------------------------------------------------
    1118             : 
    1119           0 : SvStream& SvxOpaqueItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
    1120             : {
    1121           0 :     rStrm << (sal_Int8)GetValue();
    1122           0 :     return rStrm;
    1123             : }
    1124             : 
    1125             : // -----------------------------------------------------------------------
    1126             : 
    1127           0 : SfxPoolItem* SvxOpaqueItem::Create( SvStream& rStrm, sal_uInt16 ) const
    1128             : {
    1129             :     sal_Int8 bIsOpaque;
    1130           0 :     rStrm >> bIsOpaque;
    1131           0 :     return new SvxOpaqueItem( Which(), sal_Bool( bIsOpaque != 0 ) );
    1132             : }
    1133             : 
    1134             : //------------------------------------------------------------------------
    1135             : 
    1136           0 : SfxItemPresentation SvxOpaqueItem::GetPresentation
    1137             : (
    1138             :     SfxItemPresentation ePres,
    1139             :     SfxMapUnit          /*eCoreUnit*/,
    1140             :     SfxMapUnit          /*ePresUnit*/,
    1141             :     OUString&           rText, const IntlWrapper *
    1142             : )   const
    1143             : {
    1144           0 :     switch ( ePres )
    1145             :     {
    1146             :         case SFX_ITEM_PRESENTATION_NONE:
    1147           0 :             rText = OUString();
    1148           0 :             return ePres;
    1149             : 
    1150             :         case SFX_ITEM_PRESENTATION_NAMELESS:
    1151             :         case SFX_ITEM_PRESENTATION_COMPLETE:
    1152             :         {
    1153           0 :             sal_uInt16 nId = RID_SVXITEMS_OPAQUE_FALSE;
    1154             : 
    1155           0 :             if ( GetValue() )
    1156           0 :                 nId = RID_SVXITEMS_OPAQUE_TRUE;
    1157           0 :             rText = EE_RESSTR(nId);
    1158           0 :             return ePres;
    1159             :         }
    1160             :         default: ;//prevent warning
    1161             :     }
    1162           0 :     return SFX_ITEM_PRESENTATION_NONE;
    1163             : }
    1164             : 
    1165             : // class SvxProtectItem --------------------------------------------------
    1166             : 
    1167         239 : int SvxProtectItem::operator==( const SfxPoolItem& rAttr ) const
    1168             : {
    1169             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
    1170             : 
    1171         384 :     return ( bCntnt == ( (SvxProtectItem&)rAttr ).bCntnt &&
    1172         384 :              bSize  == ( (SvxProtectItem&)rAttr ).bSize  &&
    1173         384 :              bPos   == ( (SvxProtectItem&)rAttr ).bPos );
    1174             : }
    1175             : 
    1176           7 : bool SvxProtectItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
    1177             : {
    1178           7 :     nMemberId &= ~CONVERT_TWIPS;
    1179             :     sal_Bool bValue;
    1180           7 :     switch(nMemberId)
    1181             :     {
    1182           7 :         case MID_PROTECT_CONTENT :  bValue = bCntnt; break;
    1183           0 :         case MID_PROTECT_SIZE    :  bValue = bSize; break;
    1184           0 :         case MID_PROTECT_POSITION:  bValue = bPos; break;
    1185             :         default:
    1186             :             OSL_FAIL("Wrong MemberId");
    1187           0 :             return false;
    1188             :     }
    1189             : 
    1190           7 :     rVal = Bool2Any( bValue );
    1191           7 :     return true;
    1192             : }
    1193             : 
    1194           3 : bool    SvxProtectItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
    1195             : {
    1196           3 :     nMemberId &= ~CONVERT_TWIPS;
    1197           3 :     sal_Bool bVal( Any2Bool(rVal) );
    1198           3 :     switch(nMemberId)
    1199             :     {
    1200           3 :         case MID_PROTECT_CONTENT :  bCntnt = bVal;  break;
    1201           0 :         case MID_PROTECT_SIZE    :  bSize  = bVal;  break;
    1202           0 :         case MID_PROTECT_POSITION:  bPos   = bVal;  break;
    1203             :         default:
    1204             :             OSL_FAIL("Wrong MemberId");
    1205           0 :             return false;
    1206             :     }
    1207           3 :     return true;
    1208             : }
    1209             : 
    1210             : // -----------------------------------------------------------------------
    1211             : 
    1212         777 : SfxPoolItem* SvxProtectItem::Clone( SfxItemPool* ) const
    1213             : {
    1214         777 :     return new SvxProtectItem( *this );
    1215             : }
    1216             : 
    1217             : //------------------------------------------------------------------------
    1218             : 
    1219           0 : SfxItemPresentation SvxProtectItem::GetPresentation
    1220             : (
    1221             :     SfxItemPresentation ePres,
    1222             :     SfxMapUnit          /*eCoreUnit*/,
    1223             :     SfxMapUnit          /*ePresUnit*/,
    1224             :     OUString&           rText, const IntlWrapper *
    1225             : )   const
    1226             : {
    1227           0 :     switch ( ePres )
    1228             :     {
    1229             :         case SFX_ITEM_PRESENTATION_NONE:
    1230           0 :             rText = OUString();
    1231           0 :             return ePres;
    1232             : 
    1233             :         case SFX_ITEM_PRESENTATION_NAMELESS:
    1234             :         case SFX_ITEM_PRESENTATION_COMPLETE:
    1235             :         {
    1236           0 :             sal_uInt16 nId = RID_SVXITEMS_PROT_CONTENT_FALSE;
    1237             : 
    1238           0 :             if ( bCntnt )
    1239           0 :                 nId = RID_SVXITEMS_PROT_CONTENT_TRUE;
    1240           0 :             rText = EE_RESSTR(nId) + OUString(cpDelim);
    1241           0 :             nId = RID_SVXITEMS_PROT_SIZE_FALSE;
    1242             : 
    1243           0 :             if ( bSize )
    1244           0 :                 nId = RID_SVXITEMS_PROT_SIZE_TRUE;
    1245           0 :             rText = rText + EE_RESSTR(nId) + OUString(cpDelim);
    1246           0 :             nId = RID_SVXITEMS_PROT_POS_FALSE;
    1247             : 
    1248           0 :             if ( bPos )
    1249           0 :                 nId = RID_SVXITEMS_PROT_POS_TRUE;
    1250           0 :             rText += EE_RESSTR(nId);
    1251           0 :             return ePres;
    1252             :         }
    1253             :         default: ;//prevent warning
    1254             :     }
    1255           0 :     return SFX_ITEM_PRESENTATION_NONE;
    1256             : }
    1257             : 
    1258             : // -----------------------------------------------------------------------
    1259             : 
    1260           0 : SvStream& SvxProtectItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
    1261             : {
    1262           0 :     sal_Int8 cProt = 0;
    1263           0 :     if( IsPosProtected() )   cProt |= 0x01;
    1264           0 :     if( IsSizeProtected() )  cProt |= 0x02;
    1265           0 :     if( IsCntntProtected() ) cProt |= 0x04;
    1266           0 :     rStrm << (sal_Int8) cProt;
    1267           0 :     return rStrm;
    1268             : }
    1269             : 
    1270             : // -----------------------------------------------------------------------
    1271             : 
    1272           0 : SfxPoolItem* SvxProtectItem::Create( SvStream& rStrm, sal_uInt16 ) const
    1273             : {
    1274             :     sal_Int8 cFlags;
    1275           0 :     rStrm >> cFlags;
    1276           0 :     SvxProtectItem* pAttr = new SvxProtectItem( Which() );
    1277           0 :     pAttr->SetPosProtect( sal_Bool( ( cFlags & 0x01 ) != 0 ) );
    1278           0 :     pAttr->SetSizeProtect( sal_Bool(  ( cFlags & 0x02 ) != 0 ) );
    1279           0 :     pAttr->SetCntntProtect( sal_Bool(  ( cFlags & 0x04 ) != 0 ) );
    1280           0 :     return pAttr;
    1281             : }
    1282             : 
    1283             : // class SvxShadowItem ---------------------------------------------------
    1284             : 
    1285         687 : SvxShadowItem::SvxShadowItem( const sal_uInt16 nId,
    1286             :                  const Color *pColor, const sal_uInt16 nW,
    1287             :                  const SvxShadowLocation eLoc ) :
    1288             :     SfxEnumItemInterface( nId ),
    1289             :     aShadowColor(COL_GRAY),
    1290             :     nWidth      ( nW ),
    1291         687 :     eLocation   ( eLoc )
    1292             : {
    1293         687 :     if ( pColor )
    1294           0 :         aShadowColor = *pColor;
    1295         687 : }
    1296             : 
    1297             : // -----------------------------------------------------------------------
    1298          87 : bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
    1299             : {
    1300          87 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
    1301          87 :     nMemberId &= ~CONVERT_TWIPS;
    1302             : 
    1303          87 :     table::ShadowFormat aShadow;
    1304          87 :     table::ShadowLocation eSet = table::ShadowLocation_NONE;
    1305          87 :     switch( eLocation )
    1306             :     {
    1307           0 :         case SVX_SHADOW_TOPLEFT    : eSet = table::ShadowLocation_TOP_LEFT    ; break;
    1308           0 :         case SVX_SHADOW_TOPRIGHT   : eSet = table::ShadowLocation_TOP_RIGHT   ; break;
    1309           1 :         case SVX_SHADOW_BOTTOMLEFT : eSet = table::ShadowLocation_BOTTOM_LEFT ; break;
    1310           9 :         case SVX_SHADOW_BOTTOMRIGHT: eSet = table::ShadowLocation_BOTTOM_RIGHT; break;
    1311             :         default: ;//prevent warning
    1312             :     }
    1313          87 :     aShadow.Location = eSet;
    1314          87 :     aShadow.ShadowWidth =   bConvert ? TWIP_TO_MM100_UNSIGNED(nWidth) : nWidth;
    1315          87 :     aShadow.IsTransparent = aShadowColor.GetTransparency() > 0;
    1316          87 :     aShadow.Color = aShadowColor.GetRGBColor();
    1317             : 
    1318          87 :     switch ( nMemberId )
    1319             :     {
    1320           0 :         case MID_LOCATION: rVal <<= aShadow.Location; break;
    1321           0 :         case MID_WIDTH: rVal <<= aShadow.ShadowWidth; break;
    1322           0 :         case MID_TRANSPARENT: rVal <<= aShadow.IsTransparent; break;
    1323           0 :         case MID_BG_COLOR: rVal <<= aShadow.Color; break;
    1324          87 :         case 0: rVal <<= aShadow; break;
    1325           0 :         default: OSL_FAIL("Wrong MemberId!"); return false;
    1326             :     }
    1327             : 
    1328          87 :     return true;
    1329             : }
    1330             : // -----------------------------------------------------------------------
    1331          43 : bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
    1332             : {
    1333          43 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
    1334          43 :     nMemberId &= ~CONVERT_TWIPS;
    1335             : 
    1336          43 :     table::ShadowFormat aShadow;
    1337          43 :     uno::Any aAny;
    1338          43 :     bool bRet = QueryValue( aAny, bConvert ? CONVERT_TWIPS : 0 ) && ( aAny >>= aShadow );
    1339          43 :     switch ( nMemberId )
    1340             :     {
    1341             :         case MID_LOCATION:
    1342             :         {
    1343           0 :             bRet = (rVal >>= aShadow.Location);
    1344           0 :             if ( !bRet )
    1345             :             {
    1346           0 :                 sal_Int16 nVal = 0;
    1347           0 :                 bRet = (rVal >>= nVal);
    1348           0 :                 aShadow.Location = (table::ShadowLocation) nVal;
    1349             :             }
    1350             : 
    1351           0 :             break;
    1352             :         }
    1353             : 
    1354           0 :         case MID_WIDTH: rVal >>= aShadow.ShadowWidth; break;
    1355           0 :         case MID_TRANSPARENT: rVal >>= aShadow.IsTransparent; break;
    1356           0 :         case MID_BG_COLOR: rVal >>= aShadow.Color; break;
    1357          43 :         case 0: rVal >>= aShadow; break;
    1358           0 :         default: OSL_FAIL("Wrong MemberId!"); return sal_False;
    1359             :     }
    1360             : 
    1361          43 :     if ( bRet )
    1362             :     {
    1363             : //      SvxShadowLocation eSet = SVX_SHADOW_NONE;
    1364          43 :         switch( aShadow.Location )
    1365             :         {
    1366           2 :             case table::ShadowLocation_TOP_LEFT    : eLocation = SVX_SHADOW_TOPLEFT; break;
    1367           1 :             case table::ShadowLocation_TOP_RIGHT   : eLocation = SVX_SHADOW_TOPRIGHT; break;
    1368           1 :             case table::ShadowLocation_BOTTOM_LEFT : eLocation = SVX_SHADOW_BOTTOMLEFT ; break;
    1369          20 :             case table::ShadowLocation_BOTTOM_RIGHT: eLocation = SVX_SHADOW_BOTTOMRIGHT; break;
    1370             :             default: ;//prevent warning
    1371             :         }
    1372             : 
    1373          43 :         nWidth = bConvert ? MM100_TO_TWIP(aShadow.ShadowWidth) : aShadow.ShadowWidth;
    1374          43 :         Color aSet(aShadow.Color);
    1375          43 :         aSet.SetTransparency(aShadow.IsTransparent ? 0xff : 0);
    1376          43 :         aShadowColor = aSet;
    1377             :     }
    1378             : 
    1379          43 :     return bRet;
    1380             : }
    1381             : 
    1382             : // -----------------------------------------------------------------------
    1383             : 
    1384        8402 : int SvxShadowItem::operator==( const SfxPoolItem& rAttr ) const
    1385             : {
    1386             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
    1387             : 
    1388       16754 :     return ( ( aShadowColor == ( (SvxShadowItem&)rAttr ).aShadowColor ) &&
    1389       16751 :              ( nWidth    == ( (SvxShadowItem&)rAttr ).GetWidth() ) &&
    1390       16751 :              ( eLocation == ( (SvxShadowItem&)rAttr ).GetLocation() ) );
    1391             : }
    1392             : 
    1393             : // -----------------------------------------------------------------------
    1394             : 
    1395          80 : SfxPoolItem* SvxShadowItem::Clone( SfxItemPool* ) const
    1396             : {
    1397          80 :     return new SvxShadowItem( *this );
    1398             : }
    1399             : 
    1400             : // -----------------------------------------------------------------------
    1401             : 
    1402       24563 : sal_uInt16 SvxShadowItem::CalcShadowSpace( sal_uInt16 nShadow ) const
    1403             : {
    1404       24563 :     sal_uInt16 nSpace = 0;
    1405             : 
    1406       24563 :     switch ( nShadow )
    1407             :     {
    1408             :         case SHADOW_TOP:
    1409       13772 :             if ( eLocation == SVX_SHADOW_TOPLEFT ||
    1410        6885 :                  eLocation == SVX_SHADOW_TOPRIGHT  )
    1411           3 :                 nSpace = nWidth;
    1412        6887 :             break;
    1413             : 
    1414             :         case SHADOW_BOTTOM:
    1415       13771 :             if ( eLocation == SVX_SHADOW_BOTTOMLEFT ||
    1416        6885 :                  eLocation == SVX_SHADOW_BOTTOMRIGHT  )
    1417          22 :                 nSpace = nWidth;
    1418        6886 :             break;
    1419             : 
    1420             :         case SHADOW_LEFT:
    1421       10788 :             if ( eLocation == SVX_SHADOW_TOPLEFT ||
    1422        5393 :                  eLocation == SVX_SHADOW_BOTTOMLEFT )
    1423           3 :                 nSpace = nWidth;
    1424        5395 :             break;
    1425             : 
    1426             :         case SHADOW_RIGHT:
    1427       10789 :             if ( eLocation == SVX_SHADOW_TOPRIGHT ||
    1428        5394 :                  eLocation == SVX_SHADOW_BOTTOMRIGHT )
    1429          22 :                 nSpace = nWidth;
    1430        5395 :             break;
    1431             : 
    1432             :         default:
    1433             :             OSL_FAIL( "wrong shadow" );
    1434             :     }
    1435       24563 :     return nSpace;
    1436             : }
    1437             : 
    1438             : //------------------------------------------------------------------------
    1439             : 
    1440           0 : SfxItemPresentation SvxShadowItem::GetPresentation
    1441             : (
    1442             :     SfxItemPresentation ePres,
    1443             :     SfxMapUnit          eCoreUnit,
    1444             :     SfxMapUnit          ePresUnit,
    1445             :     OUString&           rText, const IntlWrapper *pIntl
    1446             : )   const
    1447             : {
    1448           0 :     switch ( ePres )
    1449             :     {
    1450             :         case SFX_ITEM_PRESENTATION_NONE:
    1451           0 :             rText = OUString();
    1452           0 :             return ePres;
    1453             : 
    1454             :         case SFX_ITEM_PRESENTATION_NAMELESS:
    1455             :         {
    1456           0 :             rText = ::GetColorString( aShadowColor ) + OUString(cpDelim);
    1457           0 :             sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
    1458             : 
    1459           0 :             if ( aShadowColor.GetTransparency() )
    1460           0 :                 nId = RID_SVXITEMS_TRANSPARENT_TRUE;
    1461           0 :             rText = rText +
    1462           0 :                     EE_RESSTR(nId) +
    1463           0 :                     OUString(cpDelim) +
    1464           0 :                     GetMetricText( (long)nWidth, eCoreUnit, ePresUnit, pIntl ) +
    1465           0 :                     OUString(cpDelim) +
    1466           0 :                     EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + eLocation);
    1467           0 :             return ePres;
    1468             :         }
    1469             :         case SFX_ITEM_PRESENTATION_COMPLETE:
    1470             :         {
    1471           0 :             rText = EE_RESSTR(RID_SVXITEMS_SHADOW_COMPLETE) +
    1472           0 :                     ::GetColorString( aShadowColor ) +
    1473           0 :                     OUString(cpDelim);
    1474             : 
    1475           0 :             sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
    1476           0 :             if ( aShadowColor.GetTransparency() )
    1477           0 :                 nId = RID_SVXITEMS_TRANSPARENT_TRUE;
    1478           0 :             rText = rText +
    1479           0 :                     EE_RESSTR(nId) +
    1480           0 :                     OUString(cpDelim) +
    1481           0 :                     GetMetricText( (long)nWidth, eCoreUnit, ePresUnit, pIntl ) +
    1482           0 :                     EE_RESSTR(GetMetricId(ePresUnit)) +
    1483           0 :                     OUString(cpDelim) +
    1484           0 :                     EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + eLocation);
    1485           0 :             return ePres;
    1486             :         }
    1487             :         default: ;//prevent warning
    1488             :     }
    1489           0 :     return SFX_ITEM_PRESENTATION_NONE;
    1490             : }
    1491             : 
    1492             : // -----------------------------------------------------------------------
    1493             : 
    1494           0 : SvStream& SvxShadowItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
    1495             : {
    1496           0 :     rStrm << (sal_Int8) GetLocation()
    1497           0 :           << (sal_uInt16) GetWidth()
    1498           0 :           << (sal_Bool)(aShadowColor.GetTransparency() > 0)
    1499           0 :           << GetColor()
    1500           0 :           << GetColor()
    1501           0 :           << (sal_Int8)(aShadowColor.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
    1502           0 :     return rStrm;
    1503             : }
    1504             : 
    1505             : // -----------------------------------------------------------------------
    1506             : 
    1507           0 : bool SvxShadowItem::ScaleMetrics( long nMult, long nDiv )
    1508             : {
    1509           0 :     nWidth = (sal_uInt16)Scale( nWidth, nMult, nDiv );
    1510           0 :     return true;
    1511             : }
    1512             : 
    1513             : // -----------------------------------------------------------------------
    1514             : 
    1515           0 : bool SvxShadowItem::HasMetrics() const
    1516             : {
    1517           0 :     return true;
    1518             : }
    1519             : 
    1520             : // -----------------------------------------------------------------------
    1521             : 
    1522           0 : SfxPoolItem* SvxShadowItem::Create( SvStream& rStrm, sal_uInt16 ) const
    1523             : {
    1524             :     sal_Int8 cLoc;
    1525             :     sal_uInt16 _nWidth;
    1526             :     sal_Bool bTrans;
    1527           0 :     Color aColor;
    1528           0 :     Color aFillColor;
    1529             :     sal_Int8 nStyle;
    1530           0 :     rStrm >> cLoc >> _nWidth
    1531           0 :           >> bTrans >> aColor >> aFillColor >> nStyle;
    1532           0 :     aColor.SetTransparency(bTrans ? 0xff : 0);
    1533           0 :     return new SvxShadowItem( Which(), &aColor, _nWidth, (SvxShadowLocation)cLoc );
    1534             : }
    1535             : 
    1536             : // -----------------------------------------------------------------------
    1537             : 
    1538           0 : sal_uInt16 SvxShadowItem::GetValueCount() const
    1539             : {
    1540           0 :     return SVX_SHADOW_END;  // SVX_SHADOW_BOTTOMRIGHT + 1
    1541             : }
    1542             : 
    1543             : // -----------------------------------------------------------------------
    1544             : 
    1545           0 : OUString SvxShadowItem::GetValueTextByPos( sal_uInt16 nPos ) const
    1546             : {
    1547             :     DBG_ASSERT( nPos < SVX_SHADOW_END, "enum overflow!" );
    1548           0 :     return EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + nPos );
    1549             : }
    1550             : 
    1551             : // -----------------------------------------------------------------------
    1552             : 
    1553           0 : sal_uInt16 SvxShadowItem::GetEnumValue() const
    1554             : {
    1555           0 :     return (sal_uInt16)GetLocation();
    1556             : }
    1557             : 
    1558             : // -----------------------------------------------------------------------
    1559             : 
    1560           0 : void SvxShadowItem::SetEnumValue( sal_uInt16 nVal )
    1561             : {
    1562           0 :     SetLocation( (const SvxShadowLocation)nVal );
    1563           0 : }
    1564             : 
    1565             : // class SvxBoxItem ------------------------------------------------------
    1566             : 
    1567       20232 : SvxBoxItem::SvxBoxItem( const SvxBoxItem& rCpy ) :
    1568             : 
    1569             :     SfxPoolItem ( rCpy ),
    1570             :     nTopDist    ( rCpy.nTopDist ),
    1571             :     nBottomDist ( rCpy.nBottomDist ),
    1572             :     nLeftDist   ( rCpy.nLeftDist ),
    1573       20232 :     nRightDist  ( rCpy.nRightDist )
    1574             : 
    1575             : {
    1576       20232 :     pTop    = rCpy.GetTop()     ? new SvxBorderLine( *rCpy.GetTop() )    : 0;
    1577       20232 :     pBottom = rCpy.GetBottom()  ? new SvxBorderLine( *rCpy.GetBottom() ) : 0;
    1578       20232 :     pLeft   = rCpy.GetLeft()    ? new SvxBorderLine( *rCpy.GetLeft() )   : 0;
    1579       20232 :     pRight  = rCpy.GetRight()   ? new SvxBorderLine( *rCpy.GetRight() )  : 0;
    1580       20232 : }
    1581             : 
    1582             : // -----------------------------------------------------------------------
    1583             : 
    1584        7195 : SvxBoxItem::SvxBoxItem( const sal_uInt16 nId ) :
    1585             :     SfxPoolItem( nId ),
    1586             : 
    1587             :     pTop        ( 0 ),
    1588             :     pBottom     ( 0 ),
    1589             :     pLeft       ( 0 ),
    1590             :     pRight      ( 0 ),
    1591             :     nTopDist    ( 0 ),
    1592             :     nBottomDist ( 0 ),
    1593             :     nLeftDist   ( 0 ),
    1594        7195 :     nRightDist  ( 0 )
    1595             : 
    1596             : {
    1597        7195 : }
    1598             : 
    1599             : // -----------------------------------------------------------------------
    1600             : 
    1601       70609 : SvxBoxItem::~SvxBoxItem()
    1602             : {
    1603       26946 :     delete pTop;
    1604       26946 :     delete pBottom;
    1605       26946 :     delete pLeft;
    1606       26946 :     delete pRight;
    1607       43663 : }
    1608             : 
    1609             : // -----------------------------------------------------------------------
    1610             : 
    1611        1298 : SvxBoxItem& SvxBoxItem::operator=( const SvxBoxItem& rBox )
    1612             : {
    1613        1298 :     nTopDist = rBox.nTopDist;
    1614        1298 :     nBottomDist = rBox.nBottomDist;
    1615        1298 :     nLeftDist = rBox.nLeftDist;
    1616        1298 :     nRightDist = rBox.nRightDist;
    1617        1298 :     SetLine( rBox.GetTop(), BOX_LINE_TOP );
    1618        1298 :     SetLine( rBox.GetBottom(), BOX_LINE_BOTTOM );
    1619        1298 :     SetLine( rBox.GetLeft(), BOX_LINE_LEFT );
    1620        1298 :     SetLine( rBox.GetRight(), BOX_LINE_RIGHT );
    1621        1298 :     return *this;
    1622             : }
    1623             : 
    1624             : // -----------------------------------------------------------------------
    1625             : 
    1626     1387607 : inline sal_Bool CmpBrdLn( const SvxBorderLine* pBrd1, const SvxBorderLine* pBrd2 )
    1627             : {
    1628             :     sal_Bool bRet;
    1629     1387607 :     if( 0 != pBrd1 ?  0 == pBrd2 : 0 != pBrd2 )
    1630       72550 :         bRet = sal_False;
    1631             :     else
    1632     1315057 :         if( !pBrd1 )
    1633     1208078 :             bRet = sal_True;
    1634             :         else
    1635      106979 :             bRet = (*pBrd1 == *pBrd2);
    1636     1387607 :     return bRet;
    1637             : }
    1638             : 
    1639             : // -----------------------------------------------------------------------
    1640             : 
    1641      334931 : int SvxBoxItem::operator==( const SfxPoolItem& rAttr ) const
    1642             : {
    1643             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
    1644             : 
    1645             :     return (
    1646      660752 :         ( nTopDist == ( (SvxBoxItem&)rAttr ).nTopDist ) &&
    1647      650881 :         ( nBottomDist == ( (SvxBoxItem&)rAttr ).nBottomDist )   &&
    1648      644671 :         ( nLeftDist == ( (SvxBoxItem&)rAttr ).nLeftDist )   &&
    1649      638823 :         ( nRightDist == ( (SvxBoxItem&)rAttr ).nRightDist ) &&
    1650      560549 :         CmpBrdLn( pTop, ( (SvxBoxItem&)rAttr ).GetTop() )           &&
    1651      462697 :         CmpBrdLn( pBottom, ( (SvxBoxItem&)rAttr ).GetBottom() )     &&
    1652      767084 :         CmpBrdLn( pLeft, ( (SvxBoxItem&)rAttr ).GetLeft() )         &&
    1653      545724 :         CmpBrdLn( pRight, ( (SvxBoxItem&)rAttr ).GetRight() ) );
    1654             : }
    1655             : 
    1656             : // -----------------------------------------------------------------------
    1657        1420 : table::BorderLine2 SvxBoxItem::SvxLineToLine(const SvxBorderLine* pLine, sal_Bool bConvert)
    1658             : {
    1659        1420 :     table::BorderLine2 aLine;
    1660        1420 :     if(pLine)
    1661             :     {
    1662         801 :         aLine.Color          = pLine->GetColor().GetColor() ;
    1663         801 :         aLine.InnerLineWidth = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetInWidth() ): pLine->GetInWidth() );
    1664         801 :         aLine.OuterLineWidth = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetOutWidth()): pLine->GetOutWidth() );
    1665         801 :         aLine.LineDistance   = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetDistance()): pLine->GetDistance() );
    1666         801 :         aLine.LineStyle      = pLine->GetBorderLineStyle();
    1667         801 :         aLine.LineWidth      = sal_uInt32( bConvert ? TWIP_TO_MM100( pLine->GetWidth( ) ) : pLine->GetWidth( ) );
    1668             :     }
    1669             :     else
    1670         619 :         aLine.Color          = aLine.InnerLineWidth = aLine.OuterLineWidth = aLine.LineDistance  = 0;
    1671        1420 :     return aLine;
    1672             : }
    1673             : // -----------------------------------------------------------------------
    1674        1048 : bool SvxBoxItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId  ) const
    1675             : {
    1676        1048 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
    1677        1048 :     table::BorderLine2 aRetLine;
    1678        1048 :     sal_uInt16 nDist = 0;
    1679        1048 :     sal_Bool bDistMember = sal_False;
    1680        1048 :     nMemberId &= ~CONVERT_TWIPS;
    1681        1048 :     switch(nMemberId)
    1682             :     {
    1683             :         case 0:
    1684             :         {
    1685             :             // 4 Borders and 5 distances
    1686           0 :             uno::Sequence< uno::Any > aSeq( 9 );
    1687           0 :             aSeq[0] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetLeft(), bConvert) );
    1688           0 :             aSeq[1] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetRight(), bConvert) );
    1689           0 :             aSeq[2] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetBottom(), bConvert) );
    1690           0 :             aSeq[3] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetTop(), bConvert) );
    1691           0 :             aSeq[4] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( GetDistance()) : GetDistance()));
    1692           0 :             aSeq[5] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nTopDist ) : nTopDist ));
    1693           0 :             aSeq[6] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nBottomDist ) : nBottomDist ));
    1694           0 :             aSeq[7] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nLeftDist ) : nLeftDist ));
    1695           0 :             aSeq[8] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nRightDist ) : nRightDist ));
    1696           0 :             rVal = uno::makeAny( aSeq );
    1697           0 :             return sal_True;
    1698             :         }
    1699             :         case MID_LEFT_BORDER:
    1700             :         case LEFT_BORDER:
    1701         170 :             aRetLine = SvxBoxItem::SvxLineToLine(GetLeft(), bConvert);
    1702         170 :             break;
    1703             :         case MID_RIGHT_BORDER:
    1704             :         case RIGHT_BORDER:
    1705         161 :             aRetLine = SvxBoxItem::SvxLineToLine(GetRight(), bConvert);
    1706         161 :             break;
    1707             :         case MID_BOTTOM_BORDER:
    1708             :         case BOTTOM_BORDER:
    1709         161 :             aRetLine = SvxBoxItem::SvxLineToLine(GetBottom(), bConvert);
    1710         161 :             break;
    1711             :         case MID_TOP_BORDER:
    1712             :         case TOP_BORDER:
    1713         344 :             aRetLine = SvxBoxItem::SvxLineToLine(GetTop(), bConvert);
    1714         344 :             break;
    1715             :         case BORDER_DISTANCE:
    1716           9 :             nDist = GetDistance();
    1717           9 :             bDistMember = sal_True;
    1718           9 :             break;
    1719             :         case TOP_BORDER_DISTANCE:
    1720          49 :             nDist = nTopDist;
    1721          49 :             bDistMember = sal_True;
    1722          49 :             break;
    1723             :         case BOTTOM_BORDER_DISTANCE:
    1724          48 :             nDist = nBottomDist;
    1725          48 :             bDistMember = sal_True;
    1726          48 :             break;
    1727             :         case LEFT_BORDER_DISTANCE:
    1728          57 :             nDist = nLeftDist;
    1729          57 :             bDistMember = sal_True;
    1730          57 :             break;
    1731             :         case RIGHT_BORDER_DISTANCE:
    1732          48 :             nDist = nRightDist;
    1733          48 :             bDistMember = sal_True;
    1734          48 :             break;
    1735             :     }
    1736             : 
    1737        1048 :     if( bDistMember )
    1738         211 :         rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nDist) : nDist);
    1739             :     else
    1740         837 :         rVal <<= aRetLine;
    1741             : 
    1742        1048 :     return true;
    1743             : }
    1744             : 
    1745             : namespace
    1746             : {
    1747             : 
    1748             : sal_Bool
    1749        5921 : lcl_lineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert, sal_Bool bGuessWidth)
    1750             : {
    1751        5921 :     rSvxLine.SetColor(   Color(rLine.Color));
    1752        5921 :     if ( bGuessWidth )
    1753             :     {
    1754        1513 :         rSvxLine.GuessLinesWidths( rSvxLine.GetBorderLineStyle(),
    1755        2572 :                 sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.OuterLineWidth) : rLine.OuterLineWidth  ),
    1756        2572 :                 sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.InnerLineWidth) : rLine.InnerLineWidth  ),
    1757        8170 :                 sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.LineDistance )  : rLine.LineDistance  ));
    1758             :     }
    1759             : 
    1760        5921 :     sal_Bool bRet = !rSvxLine.isEmpty();
    1761        5921 :     return bRet;
    1762             : }
    1763             : 
    1764             : }
    1765             : 
    1766             : // -----------------------------------------------------------------------
    1767          36 : sal_Bool SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
    1768             : {
    1769          36 :     return lcl_lineToSvxLine(rLine, rSvxLine, bConvert, sal_True);
    1770             : }
    1771             : 
    1772             : sal_Bool
    1773        5885 : SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine2& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
    1774             : {
    1775             :     SvxBorderStyle const nStyle =
    1776       11770 :         (rLine.LineStyle < 0 || BORDER_LINE_STYLE_MAX < rLine.LineStyle)
    1777             :         ? SOLID     // default
    1778       11192 :         : rLine.LineStyle;
    1779             : 
    1780        5885 :     rSvxLine.SetBorderLineStyle( nStyle );
    1781             : 
    1782        5885 :     sal_Bool bGuessWidth = sal_True;
    1783        5885 :     if ( rLine.LineWidth )
    1784             :     {
    1785        4458 :         rSvxLine.SetWidth( bConvert? MM100_TO_TWIP_UNSIGNED( rLine.LineWidth ) : rLine.LineWidth );
    1786             :         // fdo#46112: double does not necessarily mean symmetric
    1787             :         // for backwards compatibility
    1788          64 :         bGuessWidth = (DOUBLE == nStyle) &&
    1789        4508 :             (rLine.InnerLineWidth > 0) && (rLine.OuterLineWidth > 0);
    1790             :     }
    1791             : 
    1792        5885 :     return lcl_lineToSvxLine(rLine, rSvxLine, bConvert, bGuessWidth);
    1793             : }
    1794             : 
    1795             : // -----------------------------------------------------------------------
    1796             : 
    1797             : namespace
    1798             : {
    1799             : 
    1800             : bool
    1801        5693 : lcl_extractBorderLine(const uno::Any& rAny, table::BorderLine2& rLine)
    1802             : {
    1803        5693 :     if (rAny >>= rLine)
    1804        5693 :         return true;
    1805             : 
    1806           0 :     table::BorderLine aBorderLine;
    1807           0 :     if (rAny >>= aBorderLine)
    1808             :     {
    1809           0 :         rLine.Color = aBorderLine.Color;
    1810           0 :         rLine.InnerLineWidth = aBorderLine.InnerLineWidth;
    1811           0 :         rLine.OuterLineWidth = aBorderLine.OuterLineWidth;
    1812           0 :         rLine.LineDistance = aBorderLine.LineDistance;
    1813           0 :         rLine.LineStyle = table::BorderLineStyle::SOLID;
    1814           0 :         return true;
    1815             :     }
    1816             : 
    1817           0 :     return false;
    1818             : }
    1819             : 
    1820             : template<typename Item>
    1821             : bool
    1822           0 : lcl_setLine(const uno::Any& rAny, Item& rItem, sal_uInt16 nLine, const bool bConvert)
    1823             : {
    1824           0 :     bool bDone = false;
    1825           0 :     table::BorderLine2 aBorderLine;
    1826           0 :     if (lcl_extractBorderLine(rAny, aBorderLine))
    1827             :     {
    1828           0 :         SvxBorderLine aLine;
    1829           0 :         bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
    1830           0 :         rItem.SetLine( bSet ? &aLine : NULL, nLine);
    1831           0 :         bDone = true;
    1832             :     }
    1833           0 :     return bDone;
    1834             : }
    1835             : 
    1836             : }
    1837             : 
    1838        9309 : bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
    1839             : {
    1840        9309 :     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
    1841        9309 :     sal_uInt16 nLine = BOX_LINE_TOP;
    1842        9309 :     sal_Bool bDistMember = sal_False;
    1843        9309 :     nMemberId &= ~CONVERT_TWIPS;
    1844        9309 :     switch(nMemberId)
    1845             :     {
    1846             :         case 0:
    1847             :         {
    1848           0 :             uno::Sequence< uno::Any > aSeq;
    1849           0 :             if (( rVal >>= aSeq ) && ( aSeq.getLength() == 9 ))
    1850             :             {
    1851             :                 // 4 Borders and 5 distances
    1852           0 :                 const sal_uInt16 aBorders[] = { BOX_LINE_LEFT, BOX_LINE_RIGHT, BOX_LINE_BOTTOM, BOX_LINE_TOP };
    1853           0 :                 for (int n(0); n != SAL_N_ELEMENTS(aBorders); ++n)
    1854             :                 {
    1855           0 :                     if (!lcl_setLine(aSeq[n], *this, aBorders[n], bConvert))
    1856           0 :                         return sal_False;
    1857             :                 }
    1858             : 
    1859             :                 // WTH are the borders and the distances saved in different order?
    1860           0 :                 sal_uInt16 nLines[4] = { BOX_LINE_TOP, BOX_LINE_BOTTOM, BOX_LINE_LEFT, BOX_LINE_RIGHT };
    1861           0 :                 for ( sal_Int32 n = 4; n < 9; n++ )
    1862             :                 {
    1863           0 :                     sal_Int32 nDist = 0;
    1864           0 :                     if ( aSeq[n] >>= nDist )
    1865             :                     {
    1866           0 :                         if( bConvert )
    1867           0 :                             nDist = MM100_TO_TWIP(nDist);
    1868           0 :                         if ( n == 4 )
    1869           0 :                             SetDistance( sal_uInt16( nDist ));
    1870             :                         else
    1871           0 :                             SetDistance( sal_uInt16( nDist ), nLines[n-5] );
    1872             :                     }
    1873             :                     else
    1874           0 :                         return sal_False;
    1875             :                 }
    1876             : 
    1877           0 :                 return sal_True;
    1878             :             }
    1879             :             else
    1880           0 :                 return sal_False;
    1881             :         }
    1882             :         case LEFT_BORDER_DISTANCE:
    1883         943 :             bDistMember = sal_True;
    1884             :         case LEFT_BORDER:
    1885             :         case MID_LEFT_BORDER:
    1886        2304 :             nLine = BOX_LINE_LEFT;
    1887        2304 :             break;
    1888             :         case RIGHT_BORDER_DISTANCE:
    1889         943 :             bDistMember = sal_True;
    1890             :         case RIGHT_BORDER:
    1891             :         case MID_RIGHT_BORDER:
    1892        2300 :             nLine = BOX_LINE_RIGHT;
    1893        2300 :             break;
    1894             :         case BOTTOM_BORDER_DISTANCE:
    1895         958 :             bDistMember = sal_True;
    1896             :         case BOTTOM_BORDER:
    1897             :         case MID_BOTTOM_BORDER:
    1898        2331 :             nLine = BOX_LINE_BOTTOM;
    1899        2331 :             break;
    1900             :         case TOP_BORDER_DISTANCE:
    1901         949 :             bDistMember = sal_True;
    1902             :         case TOP_BORDER:
    1903             :         case MID_TOP_BORDER:
    1904        2343 :             nLine = BOX_LINE_TOP;
    1905        2343 :             break;
    1906             :         case LINE_STYLE:
    1907             :             {
    1908             :                 drawing::LineStyle eDrawingStyle;
    1909          31 :                 rVal >>= eDrawingStyle;
    1910          31 :                 editeng::SvxBorderStyle eBorderStyle = NONE;
    1911          31 :                 switch ( eDrawingStyle )
    1912             :                 {
    1913             :                     default:
    1914             :                     case drawing::LineStyle_NONE:
    1915          14 :                         break;
    1916             :                     case drawing::LineStyle_SOLID:
    1917          17 :                         eBorderStyle = SOLID;
    1918          17 :                         break;
    1919             :                     case drawing::LineStyle_DASH:
    1920           0 :                         eBorderStyle = DASHED;
    1921           0 :                         break;
    1922             :                 }
    1923             : 
    1924             :                 // Set the line style on all borders
    1925          31 :                 const sal_uInt16 aBorders[] = { BOX_LINE_LEFT, BOX_LINE_RIGHT, BOX_LINE_BOTTOM, BOX_LINE_TOP };
    1926         155 :                 for (int n(0); n != SAL_N_ELEMENTS(aBorders); ++n)
    1927             :                 {
    1928         124 :                     editeng::SvxBorderLine* pLine = const_cast< editeng::SvxBorderLine* >( GetLine( aBorders[n] ) );
    1929         124 :                     if( pLine )
    1930         124 :                         pLine->SetBorderLineStyle( eBorderStyle );
    1931             :                 }
    1932          31 :                 return sal_True;
    1933             :             }
    1934             :             break;
    1935             :         case LINE_WIDTH:
    1936             :             {
    1937             :                 // Set the line width on all borders
    1938           0 :                 long nWidth(0);
    1939           0 :                 rVal >>= nWidth;
    1940           0 :                 if( bConvert )
    1941           0 :                     nWidth = MM100_TO_TWIP( nWidth );
    1942             : 
    1943             :                 // Set the line Width on all borders
    1944           0 :                 const sal_uInt16 aBorders[] = { BOX_LINE_LEFT, BOX_LINE_RIGHT, BOX_LINE_BOTTOM, BOX_LINE_TOP };
    1945           0 :                 for (int n(0); n != SAL_N_ELEMENTS(aBorders); ++n)
    1946             :                 {
    1947           0 :                     editeng::SvxBorderLine* pLine = const_cast< editeng::SvxBorderLine* >( GetLine( aBorders[n] ) );
    1948           0 :                     if( pLine )
    1949           0 :                         pLine->SetWidth( nWidth );
    1950             :                 }
    1951             :             }
    1952           0 :             return sal_True;
    1953             :     }
    1954             : 
    1955        9278 :     if( bDistMember || nMemberId == BORDER_DISTANCE )
    1956             :     {
    1957        3793 :         sal_Int32 nDist = 0;
    1958        3793 :         if(!(rVal >>= nDist))
    1959           0 :             return sal_False;
    1960             : 
    1961        3793 :         if(nDist >= 0)
    1962             :         {
    1963        3793 :             if( bConvert )
    1964        3793 :                 nDist = MM100_TO_TWIP(nDist);
    1965        3793 :             if( nMemberId == BORDER_DISTANCE )
    1966           0 :                 SetDistance( sal_uInt16( nDist ));
    1967             :             else
    1968        3793 :                 SetDistance( sal_uInt16( nDist ), nLine );
    1969        3793 :         }
    1970             :     }
    1971             :     else
    1972             :     {
    1973        5485 :         SvxBorderLine aLine;
    1974        5485 :         if( !rVal.hasValue() )
    1975           0 :             return sal_False;
    1976             : 
    1977        5485 :         table::BorderLine2 aBorderLine;
    1978        5485 :         if( lcl_extractBorderLine(rVal, aBorderLine) )
    1979             :         {
    1980             :             // usual struct
    1981             :         }
    1982           0 :         else if (rVal.getValueTypeClass() == uno::TypeClass_SEQUENCE )
    1983             :         {
    1984             :             // serialization for basic macro recording
    1985             :             uno::Reference < script::XTypeConverter > xConverter
    1986           0 :                     ( script::Converter::create(::comphelper::getProcessComponentContext()) );
    1987           0 :             uno::Sequence < uno::Any > aSeq;
    1988           0 :             uno::Any aNew;
    1989           0 :             try { aNew = xConverter->convertTo( rVal, ::getCppuType((const uno::Sequence < uno::Any >*)0) ); }
    1990           0 :             catch (const uno::Exception&) {}
    1991             : 
    1992           0 :             aNew >>= aSeq;
    1993           0 :             if (aSeq.getLength() >= 4 && aSeq.getLength() <= 6)
    1994             :             {
    1995           0 :                 sal_Int32 nVal = 0;
    1996           0 :                 if ( aSeq[0] >>= nVal )
    1997           0 :                     aBorderLine.Color = nVal;
    1998           0 :                 if ( aSeq[1] >>= nVal )
    1999           0 :                     aBorderLine.InnerLineWidth = (sal_Int16) nVal;
    2000           0 :                 if ( aSeq[2] >>= nVal )
    2001           0 :                     aBorderLine.OuterLineWidth = (sal_Int16) nVal;
    2002           0 :                 if ( aSeq[3] >>= nVal )
    2003           0 :                     aBorderLine.LineDistance = (sal_Int16) nVal;
    2004           0 :                 if (aSeq.getLength() >= 5) // fdo#40874 added fields
    2005             :                 {
    2006           0 :                     if (aSeq[4] >>= nVal)
    2007             :                     {
    2008           0 :                         aBorderLine.LineStyle = nVal;
    2009             :                     }
    2010           0 :                     if (aSeq.getLength() >= 6)
    2011             :                     {
    2012           0 :                         if (aSeq[5] >>= nVal)
    2013             :                         {
    2014           0 :                             aBorderLine.LineWidth = nVal;
    2015             :                         }
    2016             :                     }
    2017             :                 }
    2018             :             }
    2019             :             else
    2020           0 :                 return sal_False;
    2021             :         }
    2022             :         else
    2023           0 :             return sal_False;
    2024             : 
    2025        5485 :         sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
    2026        5485 :         SetLine(bSet ? &aLine : 0, nLine);
    2027             :     }
    2028             : 
    2029        9278 :     return sal_True;
    2030             : }
    2031             : 
    2032             : // -----------------------------------------------------------------------
    2033             : 
    2034       14891 : SfxPoolItem* SvxBoxItem::Clone( SfxItemPool* ) const
    2035             : {
    2036       14891 :     return new SvxBoxItem( *this );
    2037             : }
    2038             : 
    2039             : //------------------------------------------------------------------------
    2040             : 
    2041           0 : SfxItemPresentation SvxBoxItem::GetPresentation
    2042             : (
    2043             :     SfxItemPresentation ePres,
    2044             :     SfxMapUnit          eCoreUnit,
    2045             :     SfxMapUnit          ePresUnit,
    2046             :     OUString&           rText, const IntlWrapper *pIntl
    2047             : )   const
    2048             : {
    2049           0 :     OUString cpDelimTmp = OUString(cpDelim);
    2050           0 :     switch ( ePres )
    2051             :     {
    2052             :         case SFX_ITEM_PRESENTATION_NONE:
    2053           0 :             rText = OUString();
    2054           0 :             return SFX_ITEM_PRESENTATION_NONE;
    2055             : 
    2056             :         case SFX_ITEM_PRESENTATION_NAMELESS:
    2057             :         {
    2058           0 :             rText = OUString();
    2059             : 
    2060           0 :             if ( pTop )
    2061             :             {
    2062           0 :                 rText = pTop->GetValueString( eCoreUnit, ePresUnit, pIntl ) + cpDelimTmp;
    2063             :             }
    2064           0 :             if( !(pTop && pBottom && pLeft && pRight &&
    2065           0 :                   *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight) )
    2066             :             {
    2067           0 :                 if ( pBottom )
    2068             :                 {
    2069           0 :                     rText = rText + pBottom->GetValueString( eCoreUnit, ePresUnit, pIntl ) + cpDelimTmp;
    2070             :                 }
    2071           0 :                 if ( pLeft )
    2072             :                 {
    2073           0 :                     rText = rText + pLeft->GetValueString( eCoreUnit, ePresUnit, pIntl ) + cpDelimTmp;
    2074             :                 }
    2075           0 :                 if ( pRight )
    2076             :                 {
    2077           0 :                     rText = rText + pRight->GetValueString( eCoreUnit, ePresUnit, pIntl ) + cpDelimTmp;
    2078             :                 }
    2079             :             }
    2080           0 :             rText += GetMetricText( (long)nTopDist, eCoreUnit, ePresUnit, pIntl );
    2081           0 :             if( nTopDist != nBottomDist || nTopDist != nLeftDist ||
    2082           0 :                 nTopDist != nRightDist )
    2083             :             {
    2084           0 :                 rText = rText +
    2085           0 :                         cpDelimTmp +
    2086             :                         GetMetricText( (long)nBottomDist, eCoreUnit,
    2087           0 :                                         ePresUnit, pIntl ) +
    2088           0 :                         cpDelimTmp +
    2089           0 :                         GetMetricText( (long)nLeftDist, eCoreUnit, ePresUnit, pIntl ) +
    2090           0 :                         cpDelimTmp +
    2091             :                         GetMetricText( (long)nRightDist, eCoreUnit,
    2092           0 :                                         ePresUnit, pIntl );
    2093             :             }
    2094           0 :             return SFX_ITEM_PRESENTATION_NAMELESS;
    2095             :         }
    2096             :         case SFX_ITEM_PRESENTATION_COMPLETE:
    2097             :         {
    2098           0 :             if( !(pTop || pBottom || pLeft || pRight) )
    2099             :             {
    2100           0 :                 rText = EE_RESSTR(RID_SVXITEMS_BORDER_NONE) + cpDelimTmp;
    2101             :             }
    2102             :             else
    2103             :             {
    2104           0 :                 rText = EE_RESSTR(RID_SVXITEMS_BORDER_COMPLETE);
    2105           0 :                 if( pTop && pBottom && pLeft && pRight &&
    2106           0 :                     *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight )
    2107             :                 {
    2108           0 :                     rText += pTop->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True ) + cpDelimTmp;
    2109             :                 }
    2110             :                 else
    2111             :                 {
    2112           0 :                     if ( pTop )
    2113             :                     {
    2114           0 :                         rText = rText +
    2115           0 :                                 EE_RESSTR(RID_SVXITEMS_BORDER_TOP) +
    2116           0 :                                 pTop->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True ) +
    2117           0 :                                 cpDelimTmp;
    2118             :                     }
    2119           0 :                     if ( pBottom )
    2120             :                     {
    2121           0 :                         rText = rText +
    2122           0 :                                 EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM) +
    2123           0 :                                 pBottom->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True ) +
    2124           0 :                                 cpDelimTmp;
    2125             :                     }
    2126           0 :                     if ( pLeft )
    2127             :                     {
    2128           0 :                         rText = rText +
    2129           0 :                                 EE_RESSTR(RID_SVXITEMS_BORDER_LEFT) +
    2130           0 :                                 pLeft->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True ) +
    2131           0 :                                 cpDelimTmp;
    2132             :                     }
    2133           0 :                     if ( pRight )
    2134             :                     {
    2135           0 :                         rText = rText +
    2136           0 :                                 EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT) +
    2137           0 :                                 pRight->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True ) +
    2138           0 :                                 cpDelimTmp;
    2139             :                     }
    2140             :                 }
    2141             :             }
    2142             : 
    2143           0 :             rText += EE_RESSTR(RID_SVXITEMS_BORDER_DISTANCE);
    2144           0 :             if( nTopDist == nBottomDist && nTopDist == nLeftDist &&
    2145           0 :                 nTopDist == nRightDist )
    2146             :             {
    2147           0 :                 rText = rText +
    2148             :                         GetMetricText( (long)nTopDist, eCoreUnit,
    2149           0 :                                             ePresUnit, pIntl ) +
    2150           0 :                         EE_RESSTR(GetMetricId(ePresUnit));
    2151             :             }
    2152             :             else
    2153             :             {
    2154           0 :                 rText = rText +
    2155           0 :                         EE_RESSTR(RID_SVXITEMS_BORDER_TOP) +
    2156             :                         GetMetricText( (long)nTopDist, eCoreUnit,
    2157           0 :                                         ePresUnit, pIntl ) +
    2158           0 :                         EE_RESSTR(GetMetricId(ePresUnit)) +
    2159           0 :                         cpDelimTmp +
    2160           0 :                         EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM) +
    2161             :                         GetMetricText( (long)nBottomDist, eCoreUnit,
    2162           0 :                                         ePresUnit, pIntl ) +
    2163           0 :                         EE_RESSTR(GetMetricId(ePresUnit)) +
    2164           0 :                         cpDelimTmp +
    2165           0 :                         EE_RESSTR(RID_SVXITEMS_BORDER_LEFT) +
    2166             :                         GetMetricText( (long)nLeftDist, eCoreUnit,
    2167           0 :                                         ePresUnit, pIntl ) +
    2168           0 :                         EE_RESSTR(GetMetricId(ePresUnit)) +
    2169           0 :                         cpDelimTmp +
    2170           0 :                         EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT) +
    2171             :                         GetMetricText( (long)nRightDist, eCoreUnit,
    2172           0 :                                         ePresUnit, pIntl ) +
    2173           0 :                         EE_RESSTR(GetMetricId(ePresUnit));
    2174             :             }
    2175           0 :             return SFX_ITEM_PRESENTATION_COMPLETE;
    2176             :         }
    2177             :         default: ;//prevent warning
    2178             :     }
    2179           0 :     return SFX_ITEM_PRESENTATION_NONE;
    2180             : }
    2181             : 
    2182             : // -----------------------------------------------------------------------
    2183             : 
    2184         528 : SvStream& SvxBoxItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
    2185             : {
    2186         528 :     rStrm << (sal_uInt16) GetDistance();
    2187             :     const SvxBorderLine* pLine[ 4 ];    // top, left, right, bottom
    2188         528 :     pLine[ 0 ] = GetTop();
    2189         528 :     pLine[ 1 ] = GetLeft();
    2190         528 :     pLine[ 2 ] = GetRight();
    2191         528 :     pLine[ 3 ] = GetBottom();
    2192             : 
    2193        2640 :     for( int i = 0; i < 4; i++ )
    2194             :     {
    2195        2112 :         const SvxBorderLine* l = pLine[ i ];
    2196        2112 :         if( l )
    2197             :         {
    2198         716 :             rStrm << static_cast<sal_Int8>(i);
    2199         716 :             StoreBorderLine(rStrm, *l, BorderLineVersionFromBoxVersion(nItemVersion));
    2200             :         }
    2201             :     }
    2202         528 :     sal_Int8 cLine = 4;
    2203        1056 :     if( nItemVersion >= BOX_4DISTS_VERSION &&
    2204        1056 :         !(nTopDist == nLeftDist &&
    2205         528 :           nTopDist == nRightDist &&
    2206         528 :           nTopDist == nBottomDist) )
    2207             :     {
    2208           0 :         cLine |= 0x10;
    2209             :     }
    2210             : 
    2211         528 :     rStrm << cLine;
    2212             : 
    2213         528 :     if( nItemVersion >= BOX_4DISTS_VERSION && (cLine & 0x10) != 0 )
    2214             :     {
    2215           0 :         rStrm << (sal_uInt16)nTopDist
    2216           0 :               << (sal_uInt16)nLeftDist
    2217           0 :               << (sal_uInt16)nRightDist
    2218           0 :               << (sal_uInt16)nBottomDist;
    2219             :     }
    2220             : 
    2221         528 :     return rStrm;
    2222             : }
    2223             : 
    2224             : // -----------------------------------------------------------------------
    2225             : 
    2226         530 : sal_uInt16 SvxBoxItem::GetVersion( sal_uInt16 nFFVer ) const
    2227             : {
    2228             :     DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
    2229             :             SOFFICE_FILEFORMAT_40==nFFVer ||
    2230             :             SOFFICE_FILEFORMAT_50==nFFVer,
    2231             :             "SvxBoxItem: Gibt es ein neues Fileformat?" );
    2232         530 :     return SOFFICE_FILEFORMAT_31==nFFVer ||
    2233         530 :            SOFFICE_FILEFORMAT_40==nFFVer ? 0 : BOX_BORDER_STYLE_VERSION;
    2234             : }
    2235             : 
    2236             : // -----------------------------------------------------------------------
    2237             : 
    2238           0 : bool SvxBoxItem::ScaleMetrics( long nMult, long nDiv )
    2239             : {
    2240           0 :     if ( pTop )     pTop->ScaleMetrics( nMult, nDiv );
    2241           0 :     if ( pBottom )  pBottom->ScaleMetrics( nMult, nDiv );
    2242           0 :     if ( pLeft )    pLeft->ScaleMetrics( nMult, nDiv );
    2243           0 :     if ( pRight )   pRight->ScaleMetrics( nMult, nDiv );
    2244           0 :     nTopDist = (sal_uInt16)Scale( nTopDist, nMult, nDiv );
    2245           0 :     nBottomDist = (sal_uInt16)Scale( nBottomDist, nMult, nDiv );
    2246           0 :     nLeftDist = (sal_uInt16)Scale( nLeftDist, nMult, nDiv );
    2247           0 :     nRightDist = (sal_uInt16)Scale( nRightDist, nMult, nDiv );
    2248           0 :     return true;
    2249             : }
    2250             : 
    2251             : // -----------------------------------------------------------------------
    2252             : 
    2253           0 : bool SvxBoxItem::HasMetrics() const
    2254             : {
    2255           0 :     return true;
    2256             : }
    2257             : 
    2258             : // -----------------------------------------------------------------------
    2259             : 
    2260         256 : SfxPoolItem* SvxBoxItem::Create( SvStream& rStrm, sal_uInt16 nIVersion ) const
    2261             : {
    2262             :     sal_uInt16 nDistance;
    2263         256 :     rStrm >> nDistance;
    2264         256 :     SvxBoxItem* pAttr = new SvxBoxItem( Which() );
    2265             : 
    2266             :     sal_uInt16 aLineMap[4] = { BOX_LINE_TOP, BOX_LINE_LEFT,
    2267         256 :                            BOX_LINE_RIGHT, BOX_LINE_BOTTOM };
    2268             : 
    2269             :     sal_Int8 cLine;
    2270             :     while( true )
    2271             :     {
    2272         564 :         rStrm >> cLine;
    2273             : 
    2274         564 :         if( cLine > 3 )
    2275         256 :             break;
    2276             : 
    2277         308 :         SvxBorderLine aBorder = CreateBorderLine(rStrm, BorderLineVersionFromBoxVersion(nIVersion));
    2278         308 :         pAttr->SetLine( &aBorder, aLineMap[cLine] );
    2279             :     }
    2280             : 
    2281         256 :     if( nIVersion >= BOX_4DISTS_VERSION && (cLine&0x10) != 0 )
    2282             :     {
    2283           0 :         for( sal_uInt16 i=0; i < 4; i++ )
    2284             :         {
    2285             :             sal_uInt16 nDist;
    2286           0 :             rStrm >> nDist;
    2287           0 :             pAttr->SetDistance( nDist, aLineMap[i] );
    2288           0 :         }
    2289             :     }
    2290             :     else
    2291             :     {
    2292         256 :         pAttr->SetDistance( nDistance );
    2293             :     }
    2294             : 
    2295         564 :     return pAttr;
    2296             : }
    2297             : 
    2298             : // -----------------------------------------------------------------------
    2299             : 
    2300       18712 : const SvxBorderLine *SvxBoxItem::GetLine( sal_uInt16 nLine ) const
    2301             : {
    2302       18712 :     const SvxBorderLine *pRet = 0;
    2303             : 
    2304       18712 :     switch ( nLine )
    2305             :     {
    2306             :         case BOX_LINE_TOP:
    2307        4228 :             pRet = pTop;
    2308        4228 :             break;
    2309             :         case BOX_LINE_BOTTOM:
    2310        4234 :             pRet = pBottom;
    2311        4234 :             break;
    2312             :         case BOX_LINE_LEFT:
    2313        5050 :             pRet = pLeft;
    2314        5050 :             break;
    2315             :         case BOX_LINE_RIGHT:
    2316        5200 :             pRet = pRight;
    2317        5200 :             break;
    2318             :         default:
    2319             :             OSL_FAIL( "wrong line" );
    2320           0 :             break;
    2321             :     }
    2322             : 
    2323       18712 :     return pRet;
    2324             : }
    2325             : 
    2326             : // -----------------------------------------------------------------------
    2327             : 
    2328       31773 : void SvxBoxItem::SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine )
    2329             : {
    2330       31773 :     SvxBorderLine* pTmp = pNew ? new SvxBorderLine( *pNew ) : 0;
    2331             : 
    2332       31773 :     switch ( nLine )
    2333             :     {
    2334             :         case BOX_LINE_TOP:
    2335        7909 :             delete pTop;
    2336        7909 :             pTop = pTmp;
    2337        7909 :             break;
    2338             :         case BOX_LINE_BOTTOM:
    2339        8044 :             delete pBottom;
    2340        8044 :             pBottom = pTmp;
    2341        8044 :             break;
    2342             :         case BOX_LINE_LEFT:
    2343        7445 :             delete pLeft;
    2344        7445 :             pLeft = pTmp;
    2345        7445 :             break;
    2346             :         case BOX_LINE_RIGHT:
    2347        8375 :             delete pRight;
    2348        8375 :             pRight = pTmp;
    2349        8375 :             break;
    2350             :         default:
    2351           0 :             delete pTmp;
    2352             :             OSL_FAIL( "wrong line" );
    2353             :     }
    2354       31773 : }
    2355             : 
    2356             : // -----------------------------------------------------------------------
    2357             : 
    2358         606 : sal_uInt16 SvxBoxItem::GetDistance() const
    2359             : {
    2360             :     // The smallest distance that is not 0 will be returned.
    2361         606 :     sal_uInt16 nDist = nTopDist;
    2362         606 :     if( nBottomDist && (!nDist || nBottomDist < nDist) )
    2363           0 :         nDist = nBottomDist;
    2364         606 :     if( nLeftDist && (!nDist || nLeftDist < nDist) )
    2365           1 :         nDist = nLeftDist;
    2366         606 :     if( nRightDist && (!nDist || nRightDist < nDist) )
    2367           1 :         nDist = nRightDist;
    2368             : 
    2369         606 :     return nDist;
    2370             : }
    2371             : 
    2372             : // -----------------------------------------------------------------------
    2373             : 
    2374       30180 : sal_uInt16 SvxBoxItem::GetDistance( sal_uInt16 nLine ) const
    2375             : {
    2376       30180 :     sal_uInt16 nDist = 0;
    2377       30180 :     switch ( nLine )
    2378             :     {
    2379             :         case BOX_LINE_TOP:
    2380        6814 :             nDist = nTopDist;
    2381        6814 :             break;
    2382             :         case BOX_LINE_BOTTOM:
    2383       11549 :             nDist = nBottomDist;
    2384       11549 :             break;
    2385             :         case BOX_LINE_LEFT:
    2386        6168 :             nDist = nLeftDist;
    2387        6168 :             break;
    2388             :         case BOX_LINE_RIGHT:
    2389        5649 :             nDist = nRightDist;
    2390        5649 :             break;
    2391             :         default:
    2392             :             OSL_FAIL( "wrong line" );
    2393             :     }
    2394             : 
    2395       30180 :     return nDist;
    2396             : }
    2397             : 
    2398             : // -----------------------------------------------------------------------
    2399             : 
    2400       11658 : void SvxBoxItem::SetDistance( sal_uInt16 nNew, sal_uInt16 nLine )
    2401             : {
    2402       11658 :     switch ( nLine )
    2403             :     {
    2404             :         case BOX_LINE_TOP:
    2405        2955 :             nTopDist = nNew;
    2406        2955 :             break;
    2407             :         case BOX_LINE_BOTTOM:
    2408        2967 :             nBottomDist = nNew;
    2409        2967 :             break;
    2410             :         case BOX_LINE_LEFT:
    2411        2885 :             nLeftDist = nNew;
    2412        2885 :             break;
    2413             :         case BOX_LINE_RIGHT:
    2414        2851 :             nRightDist = nNew;
    2415        2851 :             break;
    2416             :         default:
    2417             :             OSL_FAIL( "wrong line" );
    2418             :     }
    2419       11658 : }
    2420             : 
    2421             : // -----------------------------------------------------------------------
    2422             : 
    2423       35442 : sal_uInt16 SvxBoxItem::CalcLineSpace( sal_uInt16 nLine, sal_Bool bIgnoreLine ) const
    2424             : {
    2425       35442 :     SvxBorderLine* pTmp = 0;
    2426       35442 :     sal_uInt16 nDist = 0;
    2427       35442 :     switch ( nLine )
    2428             :     {
    2429             :     case BOX_LINE_TOP:
    2430       12043 :         pTmp = pTop;
    2431       12043 :         nDist = nTopDist;
    2432       12043 :         break;
    2433             :     case BOX_LINE_BOTTOM:
    2434       12047 :         pTmp = pBottom;
    2435       12047 :         nDist = nBottomDist;
    2436       12047 :         break;
    2437             :     case BOX_LINE_LEFT:
    2438        5676 :         pTmp = pLeft;
    2439        5676 :         nDist = nLeftDist;
    2440        5676 :         break;
    2441             :     case BOX_LINE_RIGHT:
    2442        5676 :         pTmp = pRight;
    2443        5676 :         nDist = nRightDist;
    2444        5676 :         break;
    2445             :     default:
    2446             :         OSL_FAIL( "wrong line" );
    2447             :     }
    2448             : 
    2449       35442 :     if( pTmp )
    2450             :     {
    2451        6922 :         nDist = nDist + (sal_uInt16)(pTmp->GetOutWidth()) + (sal_uInt16)(pTmp->GetInWidth()) + (sal_uInt16)(pTmp->GetDistance());
    2452             :     }
    2453       28520 :     else if( !bIgnoreLine )
    2454       24353 :         nDist = 0;
    2455       35442 :     return nDist;
    2456             : }
    2457             : 
    2458             : // class SvxBoxInfoItem --------------------------------------------------
    2459             : 
    2460       14296 : SvxBoxInfoItem::SvxBoxInfoItem( const sal_uInt16 nId ) :
    2461             :     SfxPoolItem( nId ),
    2462             :     pHori   ( 0 ),
    2463             :     pVert   ( 0 ),
    2464             :     mbEnableHor( false ),
    2465             :     mbEnableVer( false ),
    2466       14296 :     nDefDist( 0 )
    2467             : {
    2468       14296 :     bDist = bMinDist = sal_False;
    2469       14296 :     ResetFlags();
    2470       14296 : }
    2471             : 
    2472             : // -----------------------------------------------------------------------
    2473             : 
    2474       22581 : SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem& rCpy ) :
    2475             :     SfxPoolItem( rCpy ),
    2476             :     mbEnableHor( rCpy.mbEnableHor ),
    2477       22581 :     mbEnableVer( rCpy.mbEnableVer )
    2478             : {
    2479       22581 :     pHori       = rCpy.GetHori() ? new SvxBorderLine( *rCpy.GetHori() ) : 0;
    2480       22581 :     pVert       = rCpy.GetVert() ? new SvxBorderLine( *rCpy.GetVert() ) : 0;
    2481       22581 :     bDist       = rCpy.IsDist();
    2482       22581 :     bMinDist    = rCpy.IsMinDist();
    2483       22581 :     nValidFlags = rCpy.nValidFlags;
    2484       22581 :     nDefDist    = rCpy.GetDefDist();
    2485       22581 : }
    2486             : 
    2487             : // -----------------------------------------------------------------------
    2488             : 
    2489       97713 : SvxBoxInfoItem::~SvxBoxInfoItem()
    2490             : {
    2491       36671 :     delete pHori;
    2492       36671 :     delete pVert;
    2493       61042 : }
    2494             : 
    2495             : // -----------------------------------------------------------------------
    2496             : 
    2497         444 : SvxBoxInfoItem &SvxBoxInfoItem::operator=( const SvxBoxInfoItem& rCpy )
    2498             : {
    2499         444 :     delete pHori;
    2500         444 :     delete pVert;
    2501         444 :     pHori       = rCpy.GetHori() ? new SvxBorderLine( *rCpy.GetHori() ) : 0;
    2502         444 :     pVert       = rCpy.GetVert() ? new SvxBorderLine( *rCpy.GetVert() ) : 0;
    2503         444 :     mbEnableHor = rCpy.mbEnableHor;
    2504         444 :     mbEnableVer = rCpy.mbEnableVer;
    2505         444 :     bDist       = rCpy.IsDist();
    2506         444 :     bMinDist    = rCpy.IsMinDist();
    2507         444 :     nValidFlags = rCpy.nValidFlags;
    2508         444 :     nDefDist    = rCpy.GetDefDist();
    2509         444 :     return *this;
    2510             : }
    2511             : 
    2512             : // -----------------------------------------------------------------------
    2513             : 
    2514        2601 : int SvxBoxInfoItem::operator==( const SfxPoolItem& rAttr ) const
    2515             : {
    2516        2601 :     SvxBoxInfoItem& rBoxInfo = (SvxBoxInfoItem&)rAttr;
    2517             : 
    2518             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
    2519             : 
    2520        2601 :     return (   mbEnableHor               == rBoxInfo.mbEnableHor
    2521        2601 :             && mbEnableVer               == rBoxInfo.mbEnableVer
    2522        2601 :             && bDist                     == rBoxInfo.IsDist()
    2523        2601 :             && bMinDist                  == rBoxInfo.IsMinDist()
    2524        2601 :             && nValidFlags               == rBoxInfo.nValidFlags
    2525        2601 :             && nDefDist                  == rBoxInfo.GetDefDist()
    2526        2601 :             && CmpBrdLn( pHori, rBoxInfo.GetHori() )
    2527        5188 :             && CmpBrdLn( pVert, rBoxInfo.GetVert() )
    2528        2601 :            );
    2529             : }
    2530             : 
    2531             : // -----------------------------------------------------------------------
    2532             : 
    2533        1487 : void SvxBoxInfoItem::SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine )
    2534             : {
    2535        1487 :     SvxBorderLine* pTmp = pNew ? new SvxBorderLine( *pNew ) : 0;
    2536             : 
    2537        1487 :     if ( BOXINFO_LINE_HORI == nLine )
    2538             :     {
    2539         762 :         delete pHori;
    2540         762 :         pHori = pTmp;
    2541             :     }
    2542         725 :     else if ( BOXINFO_LINE_VERT == nLine )
    2543             :     {
    2544         725 :         delete pVert;
    2545         725 :         pVert = pTmp;
    2546             :     }
    2547             :     else
    2548             :     {
    2549           0 :         delete pTmp;
    2550             :         OSL_FAIL( "wrong line" );
    2551             :     }
    2552        1487 : }
    2553             : 
    2554             : // -----------------------------------------------------------------------
    2555             : 
    2556       22559 : SfxPoolItem* SvxBoxInfoItem::Clone( SfxItemPool* ) const
    2557             : {
    2558       22559 :     return new SvxBoxInfoItem( *this );
    2559             : }
    2560             : 
    2561             : //------------------------------------------------------------------------
    2562             : 
    2563           0 : SfxItemPresentation SvxBoxInfoItem::GetPresentation
    2564             : (
    2565             :     SfxItemPresentation /*ePres*/,
    2566             :     SfxMapUnit          /*eCoreUnit*/,
    2567             :     SfxMapUnit          /*ePresUnit*/,
    2568             :     OUString&           rText, const IntlWrapper *
    2569             : )   const
    2570             : {
    2571           0 :     rText = OUString();
    2572           0 :     return SFX_ITEM_PRESENTATION_NONE;
    2573             : }
    2574             : 
    2575             : // -----------------------------------------------------------------------
    2576             : 
    2577           0 : SvStream& SvxBoxInfoItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
    2578             : {
    2579           0 :     sal_Int8 cFlags = 0;
    2580             : 
    2581           0 :     if ( IsTable() )
    2582           0 :         cFlags |= 0x01;
    2583           0 :     if ( IsDist() )
    2584           0 :         cFlags |= 0x02;
    2585           0 :     if ( IsMinDist() )
    2586           0 :         cFlags |= 0x04;
    2587           0 :     rStrm << (sal_Int8)   cFlags
    2588           0 :           << (sal_uInt16) GetDefDist();
    2589             :     const SvxBorderLine* pLine[ 2 ];
    2590           0 :     pLine[ 0 ] = GetHori();
    2591           0 :     pLine[ 1 ] = GetVert();
    2592             : 
    2593           0 :     for( int i = 0; i < 2; i++ )
    2594             :     {
    2595           0 :         const SvxBorderLine* l = pLine[ i ];
    2596           0 :         if( l )
    2597             :         {
    2598           0 :             rStrm << (char) i
    2599           0 :                   << l->GetColor()
    2600           0 :                   << (short) l->GetOutWidth()
    2601           0 :                   << (short) l->GetInWidth()
    2602           0 :                   << (short) l->GetDistance();
    2603             :         }
    2604             :     }
    2605           0 :     rStrm << (char) 2;
    2606           0 :     return rStrm;
    2607             : }
    2608             : 
    2609             : // -----------------------------------------------------------------------
    2610             : 
    2611           0 : bool SvxBoxInfoItem::ScaleMetrics( long nMult, long nDiv )
    2612             : {
    2613           0 :     if ( pHori ) pHori->ScaleMetrics( nMult, nDiv );
    2614           0 :     if ( pVert ) pVert->ScaleMetrics( nMult, nDiv );
    2615           0 :     nDefDist = (sal_uInt16)Scale( nDefDist, nMult, nDiv );
    2616           0 :     return true;
    2617             : }
    2618             : 
    2619             : // -----------------------------------------------------------------------
    2620             : 
    2621           0 : bool SvxBoxInfoItem::HasMetrics() const
    2622             : {
    2623           0 :     return true;
    2624             : }
    2625             : 
    2626             : // -----------------------------------------------------------------------
    2627             : 
    2628           0 : SfxPoolItem* SvxBoxInfoItem::Create( SvStream& rStrm, sal_uInt16 ) const
    2629             : {
    2630             :     sal_Int8 cFlags;
    2631             :     sal_uInt16 _nDefDist;
    2632           0 :     rStrm >> cFlags >> _nDefDist;
    2633             : 
    2634           0 :     SvxBoxInfoItem* pAttr = new SvxBoxInfoItem( Which() );
    2635             : 
    2636           0 :     pAttr->SetTable  ( ( cFlags & 0x01 ) != 0 );
    2637           0 :     pAttr->SetDist   ( ( cFlags & 0x02 ) != 0 );
    2638           0 :     pAttr->SetMinDist( ( cFlags & 0x04 ) != 0 );
    2639           0 :     pAttr->SetDefDist( _nDefDist );
    2640             : 
    2641             :     while( true )
    2642             :     {
    2643             :         sal_Int8 cLine;
    2644           0 :         rStrm >> cLine;
    2645             : 
    2646           0 :         if( cLine > 1 )
    2647           0 :             break;
    2648             :         short nOutline, nInline, nDistance;
    2649           0 :         Color aColor;
    2650           0 :         rStrm >> aColor >> nOutline >> nInline >> nDistance;
    2651           0 :         SvxBorderLine aBorder( &aColor );
    2652           0 :         aBorder.GuessLinesWidths(NONE, nOutline, nInline, nDistance);
    2653             : 
    2654           0 :         switch( cLine )
    2655             :         {
    2656           0 :             case 0: pAttr->SetLine( &aBorder, BOXINFO_LINE_HORI ); break;
    2657           0 :             case 1: pAttr->SetLine( &aBorder, BOXINFO_LINE_VERT ); break;
    2658             :         }
    2659             :     }
    2660           0 :     return pAttr;
    2661             : }
    2662             : 
    2663             : // -----------------------------------------------------------------------
    2664             : 
    2665       14314 : void SvxBoxInfoItem::ResetFlags()
    2666             : {
    2667       14314 :     nValidFlags = 0x7F; // all valid except Disable
    2668       14314 : }
    2669             : 
    2670           0 : bool SvxBoxInfoItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId  ) const
    2671             : {
    2672           0 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
    2673           0 :     table::BorderLine2 aRetLine;
    2674           0 :     sal_Int16 nVal=0;
    2675           0 :     sal_Bool bIntMember = sal_False;
    2676           0 :     nMemberId &= ~CONVERT_TWIPS;
    2677           0 :     switch(nMemberId)
    2678             :     {
    2679             :         case 0:
    2680             :         {
    2681             :             // 2 BorderLines, flags, valid flags and distance
    2682           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq( 5 );
    2683           0 :             aSeq[0] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pHori, bConvert) );
    2684           0 :             aSeq[1] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pVert, bConvert) );
    2685           0 :             if ( IsTable() )
    2686           0 :                 nVal |= 0x01;
    2687           0 :             if ( IsDist() )
    2688           0 :                 nVal |= 0x02;
    2689           0 :             if ( IsMinDist() )
    2690           0 :                 nVal |= 0x04;
    2691           0 :             aSeq[2] = ::com::sun::star::uno::makeAny( nVal );
    2692           0 :             nVal = nValidFlags;
    2693           0 :             aSeq[3] = ::com::sun::star::uno::makeAny( nVal );
    2694           0 :             aSeq[4] = ::com::sun::star::uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist()) );
    2695           0 :             rVal = ::com::sun::star::uno::makeAny( aSeq );
    2696           0 :             return sal_True;
    2697             :         }
    2698             : 
    2699             :         case MID_HORIZONTAL:
    2700           0 :             aRetLine = SvxBoxItem::SvxLineToLine( pHori, bConvert);
    2701           0 :             break;
    2702             :         case MID_VERTICAL:
    2703           0 :             aRetLine = SvxBoxItem::SvxLineToLine( pVert, bConvert);
    2704           0 :             break;
    2705             :         case MID_FLAGS:
    2706           0 :             bIntMember = sal_True;
    2707           0 :             if ( IsTable() )
    2708           0 :                 nVal |= 0x01;
    2709           0 :             if ( IsDist() )
    2710           0 :                 nVal |= 0x02;
    2711           0 :             if ( IsMinDist() )
    2712           0 :                 nVal |= 0x04;
    2713           0 :             rVal <<= nVal;
    2714           0 :             break;
    2715             :         case MID_VALIDFLAGS:
    2716           0 :             bIntMember = sal_True;
    2717           0 :             nVal = nValidFlags;
    2718           0 :             rVal <<= nVal;
    2719           0 :             break;
    2720             :         case MID_DISTANCE:
    2721           0 :             bIntMember = sal_True;
    2722           0 :             rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist());
    2723           0 :             break;
    2724           0 :         default: OSL_FAIL("Wrong MemberId!"); return false;
    2725             :     }
    2726             : 
    2727           0 :     if( !bIntMember )
    2728           0 :         rVal <<= aRetLine;
    2729             : 
    2730           0 :     return true;
    2731             : }
    2732             : 
    2733             : // -----------------------------------------------------------------------
    2734             : 
    2735           0 : bool SvxBoxInfoItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
    2736             : {
    2737           0 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
    2738           0 :     nMemberId &= ~CONVERT_TWIPS;
    2739             :     sal_Bool bRet;
    2740           0 :     switch(nMemberId)
    2741             :     {
    2742             :         case 0:
    2743             :         {
    2744           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq;
    2745           0 :             if (( rVal >>= aSeq ) && ( aSeq.getLength() == 5 ))
    2746             :             {
    2747             :                 // 2 BorderLines, flags, valid flags and distance
    2748           0 :                 if (!lcl_setLine(aSeq[0], *this, BOXINFO_LINE_HORI, bConvert))
    2749           0 :                     return sal_False;
    2750           0 :                 if (!lcl_setLine(aSeq[1], *this, BOXINFO_LINE_VERT, bConvert))
    2751           0 :                     return sal_False;
    2752             : 
    2753           0 :                 sal_Int16 nFlags( 0 );
    2754           0 :                 sal_Int32 nVal( 0 );
    2755           0 :                 if ( aSeq[2] >>= nFlags )
    2756             :                 {
    2757           0 :                     SetTable  ( ( nFlags & 0x01 ) != 0 );
    2758           0 :                     SetDist   ( ( nFlags & 0x02 ) != 0 );
    2759           0 :                     SetMinDist( ( nFlags & 0x04 ) != 0 );
    2760             :                 }
    2761             :                 else
    2762           0 :                     return sal_False;
    2763           0 :                 if ( aSeq[3] >>= nFlags )
    2764           0 :                     nValidFlags = (sal_uInt8)nFlags;
    2765             :                 else
    2766           0 :                     return sal_False;
    2767           0 :                 if (( aSeq[4] >>= nVal ) && ( nVal >= 0 ))
    2768             :                 {
    2769           0 :                     if( bConvert )
    2770           0 :                         nVal = MM100_TO_TWIP(nVal);
    2771           0 :                     SetDefDist( (sal_uInt16)nVal );
    2772             :                 }
    2773             :             }
    2774           0 :             return sal_True;
    2775             :         }
    2776             : 
    2777             :         case MID_HORIZONTAL:
    2778             :         case MID_VERTICAL:
    2779             :         {
    2780           0 :             if( !rVal.hasValue() )
    2781           0 :                 return sal_False;
    2782             : 
    2783           0 :             table::BorderLine2 aBorderLine;
    2784           0 :             if( lcl_extractBorderLine(rVal, aBorderLine) )
    2785             :             {
    2786             :                 // usual struct
    2787             :             }
    2788           0 :             else if (rVal.getValueTypeClass() == uno::TypeClass_SEQUENCE )
    2789             :             {
    2790             :                 // serialization for basic macro recording
    2791           0 :                 uno::Reference < script::XTypeConverter > xConverter( script::Converter::create(::comphelper::getProcessComponentContext()) );
    2792           0 :                 uno::Any aNew;
    2793           0 :                 uno::Sequence < uno::Any > aSeq;
    2794           0 :                 try { aNew = xConverter->convertTo( rVal, ::getCppuType((const uno::Sequence < uno::Any >*)0) ); }
    2795           0 :                 catch (const uno::Exception&) {}
    2796             : 
    2797           0 :                 if ((aNew >>= aSeq) &&
    2798           0 :                     aSeq.getLength() >= 4  && aSeq.getLength() <= 6)
    2799             :                 {
    2800           0 :                     sal_Int32 nVal = 0;
    2801           0 :                     if ( aSeq[0] >>= nVal )
    2802           0 :                         aBorderLine.Color = nVal;
    2803           0 :                     if ( aSeq[1] >>= nVal )
    2804           0 :                         aBorderLine.InnerLineWidth = (sal_Int16) nVal;
    2805           0 :                     if ( aSeq[2] >>= nVal )
    2806           0 :                         aBorderLine.OuterLineWidth = (sal_Int16) nVal;
    2807           0 :                     if ( aSeq[3] >>= nVal )
    2808           0 :                         aBorderLine.LineDistance = (sal_Int16) nVal;
    2809           0 :                     if (aSeq.getLength() >= 5) // fdo#40874 added fields
    2810             :                     {
    2811           0 :                         if (aSeq[4] >>= nVal)
    2812             :                         {
    2813           0 :                             aBorderLine.LineStyle = nVal;
    2814             :                         }
    2815           0 :                         if (aSeq.getLength() >= 6)
    2816             :                         {
    2817           0 :                             if (aSeq[5] >>= nVal)
    2818             :                             {
    2819           0 :                                 aBorderLine.LineWidth = nVal;
    2820             :                             }
    2821             :                         }
    2822             :                     }
    2823             :                 }
    2824             :                 else
    2825           0 :                     return sal_False;
    2826             :             }
    2827           0 :             else if (rVal.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < sal_Int16 >*)0) )
    2828             :             {
    2829             :                 // serialization for basic macro recording
    2830           0 :                 ::com::sun::star::uno::Sequence < sal_Int16 > aSeq;
    2831           0 :                 rVal >>= aSeq;
    2832           0 :                 if (aSeq.getLength() >= 4 && aSeq.getLength() <= 6)
    2833             :                 {
    2834           0 :                     aBorderLine.Color = aSeq[0];
    2835           0 :                     aBorderLine.InnerLineWidth = aSeq[1];
    2836           0 :                     aBorderLine.OuterLineWidth = aSeq[2];
    2837           0 :                     aBorderLine.LineDistance = aSeq[3];
    2838           0 :                     if (aSeq.getLength() >= 5) // fdo#40874 added fields
    2839             :                     {
    2840           0 :                         aBorderLine.LineStyle = aSeq[4];
    2841           0 :                         if (aSeq.getLength() >= 6)
    2842             :                         {
    2843           0 :                             aBorderLine.LineWidth = aSeq[5];
    2844             :                         }
    2845             :                     }
    2846             :                 }
    2847             :                 else
    2848           0 :                     return sal_False;
    2849             :             }
    2850             :             else
    2851           0 :                 return sal_False;
    2852             : 
    2853           0 :             SvxBorderLine aLine;
    2854           0 :             sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
    2855           0 :             if ( bSet )
    2856           0 :                 SetLine( &aLine, nMemberId == MID_HORIZONTAL ? BOXINFO_LINE_HORI : BOXINFO_LINE_VERT );
    2857           0 :             break;
    2858             :         }
    2859             :         case MID_FLAGS:
    2860             :         {
    2861           0 :             sal_Int16 nFlags = sal_Int16();
    2862           0 :             bRet = (rVal >>= nFlags);
    2863           0 :             if ( bRet )
    2864             :             {
    2865           0 :                 SetTable  ( ( nFlags & 0x01 ) != 0 );
    2866           0 :                 SetDist   ( ( nFlags & 0x02 ) != 0 );
    2867           0 :                 SetMinDist( ( nFlags & 0x04 ) != 0 );
    2868             :             }
    2869             : 
    2870           0 :             break;
    2871             :         }
    2872             :         case MID_VALIDFLAGS:
    2873             :         {
    2874           0 :             sal_Int16 nFlags = sal_Int16();
    2875           0 :             bRet = (rVal >>= nFlags);
    2876           0 :             if ( bRet )
    2877           0 :                 nValidFlags = (sal_uInt8)nFlags;
    2878           0 :             break;
    2879             :         }
    2880             :         case MID_DISTANCE:
    2881             :         {
    2882           0 :             sal_Int32 nVal = 0;
    2883           0 :             bRet = (rVal >>= nVal);
    2884           0 :             if ( bRet && nVal>=0 )
    2885             :             {
    2886           0 :                 if( bConvert )
    2887           0 :                     nVal = MM100_TO_TWIP(nVal);
    2888           0 :                 SetDefDist( (sal_uInt16)nVal );
    2889             :             }
    2890           0 :             break;
    2891             :         }
    2892           0 :         default: OSL_FAIL("Wrong MemberId!"); return sal_False;
    2893             :     }
    2894             : 
    2895           0 :     return sal_True;
    2896             : }
    2897             : 
    2898             : // class SvxFmtBreakItem -------------------------------------------------
    2899             : 
    2900         152 : int SvxFmtBreakItem::operator==( const SfxPoolItem& rAttr ) const
    2901             : {
    2902             :     DBG_ASSERT( SfxPoolItem::operator==( rAttr ), "unequal types" );
    2903             : 
    2904         152 :     return GetValue() == ( (SvxFmtBreakItem&)rAttr ).GetValue();
    2905             : }
    2906             : 
    2907             : //------------------------------------------------------------------------
    2908             : 
    2909           0 : SfxItemPresentation SvxFmtBreakItem::GetPresentation
    2910             : (
    2911             :     SfxItemPresentation ePres,
    2912             :     SfxMapUnit          /*eCoreUnit*/,
    2913             :     SfxMapUnit          /*ePresUnit*/,
    2914             :     OUString&           rText, const IntlWrapper *
    2915             : )   const
    2916             : {
    2917           0 :     switch ( ePres )
    2918             :     {
    2919             :         case SFX_ITEM_PRESENTATION_NONE:
    2920           0 :             rText = OUString();
    2921           0 :             return SFX_ITEM_PRESENTATION_NONE;
    2922             : 
    2923             :         case SFX_ITEM_PRESENTATION_NAMELESS:
    2924             :         case SFX_ITEM_PRESENTATION_COMPLETE:
    2925           0 :             rText = GetValueTextByPos( GetValue() );
    2926           0 :             return ePres;
    2927             :         default: ;//prevent warning
    2928             :     }
    2929           0 :     return SFX_ITEM_PRESENTATION_NONE;
    2930             : }
    2931             : 
    2932             : // -----------------------------------------------------------------------
    2933             : 
    2934           0 : OUString SvxFmtBreakItem::GetValueTextByPos( sal_uInt16 nPos ) const
    2935             : {
    2936             :     DBG_ASSERT( nPos < SVX_BREAK_END, "enum overflow!" );
    2937           0 :     return EE_RESSTR(RID_SVXITEMS_BREAK_BEGIN + nPos);
    2938             : }
    2939             : 
    2940             : // -----------------------------------------------------------------------
    2941          14 : bool SvxFmtBreakItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
    2942             : {
    2943          14 :     style::BreakType eBreak = style::BreakType_NONE;
    2944          14 :     switch ( (SvxBreak)GetValue() )
    2945             :     {
    2946           0 :         case SVX_BREAK_COLUMN_BEFORE:   eBreak = style::BreakType_COLUMN_BEFORE; break;
    2947           1 :         case SVX_BREAK_COLUMN_AFTER:    eBreak = style::BreakType_COLUMN_AFTER ; break;
    2948           0 :         case SVX_BREAK_COLUMN_BOTH:     eBreak = style::BreakType_COLUMN_BOTH  ; break;
    2949           6 :         case SVX_BREAK_PAGE_BEFORE:     eBreak = style::BreakType_PAGE_BEFORE  ; break;
    2950           0 :         case SVX_BREAK_PAGE_AFTER:      eBreak = style::BreakType_PAGE_AFTER   ; break;
    2951           0 :         case SVX_BREAK_PAGE_BOTH:       eBreak = style::BreakType_PAGE_BOTH    ; break;
    2952             :         default: ;//prevent warning
    2953             :     }
    2954          14 :     rVal <<= eBreak;
    2955          14 :     return true;
    2956             : }
    2957             : // -----------------------------------------------------------------------
    2958          34 : bool SvxFmtBreakItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
    2959             : {
    2960             :     style::BreakType nBreak;
    2961             : 
    2962          34 :     if(!(rVal >>= nBreak))
    2963             :     {
    2964           0 :         sal_Int32 nValue = 0;
    2965           0 :         if(!(rVal >>= nValue))
    2966           0 :             return sal_False;
    2967             : 
    2968           0 :         nBreak = (style::BreakType) nValue;
    2969             :     }
    2970             : 
    2971          34 :     SvxBreak eBreak = SVX_BREAK_NONE;
    2972          34 :     switch( nBreak )
    2973             :     {
    2974           1 :         case style::BreakType_COLUMN_BEFORE:    eBreak = SVX_BREAK_COLUMN_BEFORE; break;
    2975           1 :         case style::BreakType_COLUMN_AFTER: eBreak = SVX_BREAK_COLUMN_AFTER;  break;
    2976           0 :         case style::BreakType_COLUMN_BOTH:      eBreak = SVX_BREAK_COLUMN_BOTH;   break;
    2977          32 :         case style::BreakType_PAGE_BEFORE:      eBreak = SVX_BREAK_PAGE_BEFORE;   break;
    2978           0 :         case style::BreakType_PAGE_AFTER:       eBreak = SVX_BREAK_PAGE_AFTER;    break;
    2979           0 :         case style::BreakType_PAGE_BOTH:        eBreak = SVX_BREAK_PAGE_BOTH;     break;
    2980             :         default: ;//prevent warning
    2981             :     }
    2982          34 :     SetValue((sal_uInt16) eBreak);
    2983             : 
    2984          34 :     return true;
    2985             : }
    2986             : 
    2987             : // -----------------------------------------------------------------------
    2988             : 
    2989         111 : SfxPoolItem* SvxFmtBreakItem::Clone( SfxItemPool* ) const
    2990             : {
    2991         111 :     return new SvxFmtBreakItem( *this );
    2992             : }
    2993             : 
    2994             : // -----------------------------------------------------------------------
    2995             : 
    2996           0 : SvStream& SvxFmtBreakItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
    2997             : {
    2998           0 :     rStrm << (sal_Int8)GetValue();
    2999           0 :     if( FMTBREAK_NOAUTO > nItemVersion )
    3000           0 :         rStrm << (sal_Int8)0x01;
    3001           0 :     return rStrm;
    3002             : }
    3003             : 
    3004             : // -----------------------------------------------------------------------
    3005             : 
    3006           0 : sal_uInt16 SvxFmtBreakItem::GetVersion( sal_uInt16 nFFVer ) const
    3007             : {
    3008             :     DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
    3009             :             SOFFICE_FILEFORMAT_40==nFFVer ||
    3010             :             SOFFICE_FILEFORMAT_50==nFFVer,
    3011             :             "SvxFmtBreakItem: Is there a new file format? ");
    3012             :     return SOFFICE_FILEFORMAT_31==nFFVer ||
    3013           0 :            SOFFICE_FILEFORMAT_40==nFFVer ? 0 : FMTBREAK_NOAUTO;
    3014             : }
    3015             : 
    3016             : // -----------------------------------------------------------------------
    3017             : 
    3018           0 : SfxPoolItem* SvxFmtBreakItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
    3019             : {
    3020             :     sal_Int8 eBreak, bDummy;
    3021           0 :     rStrm >> eBreak;
    3022           0 :     if( FMTBREAK_NOAUTO > nVersion )
    3023           0 :         rStrm >> bDummy;
    3024           0 :     return new SvxFmtBreakItem( (const SvxBreak)eBreak, Which() );
    3025             : }
    3026             : 
    3027             : // -----------------------------------------------------------------------
    3028             : 
    3029           0 : sal_uInt16 SvxFmtBreakItem::GetValueCount() const
    3030             : {
    3031           0 :     return SVX_BREAK_END;   // SVX_BREAK_PAGE_BOTH + 1
    3032             : }
    3033             : 
    3034             : // class SvxFmtKeepItem -------------------------------------------------
    3035             : 
    3036        1205 : SfxPoolItem* SvxFmtKeepItem::Clone( SfxItemPool* ) const
    3037             : {
    3038        1205 :     return new SvxFmtKeepItem( *this );
    3039             : }
    3040             : 
    3041             : // -----------------------------------------------------------------------
    3042             : 
    3043           0 : SvStream& SvxFmtKeepItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
    3044             : {
    3045           0 :     rStrm << (sal_Int8)GetValue();
    3046           0 :     return rStrm;
    3047             : }
    3048             : 
    3049             : // -----------------------------------------------------------------------
    3050             : 
    3051           0 : SfxPoolItem* SvxFmtKeepItem::Create( SvStream& rStrm, sal_uInt16 ) const
    3052             : {
    3053             :     sal_Int8 bIsKeep;
    3054           0 :     rStrm >> bIsKeep;
    3055           0 :     return new SvxFmtKeepItem( sal_Bool( bIsKeep != 0 ), Which() );
    3056             : }
    3057             : 
    3058             : //------------------------------------------------------------------------
    3059             : 
    3060           0 : SfxItemPresentation SvxFmtKeepItem::GetPresentation
    3061             : (
    3062             :     SfxItemPresentation ePres,
    3063             :     SfxMapUnit          /*eCoreUnit*/,
    3064             :     SfxMapUnit          /*ePresUnit*/,
    3065             :     OUString&           rText, const IntlWrapper *
    3066             :     ) const
    3067             : {
    3068           0 :     switch ( ePres )
    3069             :     {
    3070             :         case SFX_ITEM_PRESENTATION_NONE:
    3071           0 :             rText = OUString();
    3072           0 :             return ePres;
    3073             : 
    3074             :         case SFX_ITEM_PRESENTATION_NAMELESS:
    3075             :         case SFX_ITEM_PRESENTATION_COMPLETE:
    3076             :         {
    3077           0 :             sal_uInt16 nId = RID_SVXITEMS_FMTKEEP_FALSE;
    3078             : 
    3079           0 :             if ( GetValue() )
    3080           0 :                 nId = RID_SVXITEMS_FMTKEEP_TRUE;
    3081           0 :             rText = EE_RESSTR(nId);
    3082           0 :             return ePres;
    3083             :         }
    3084             :         default: ;//prevent warning
    3085             :     }
    3086           0 :     return SFX_ITEM_PRESENTATION_NONE;
    3087             : }
    3088             : 
    3089             : // class SvxLineItem ------------------------------------------------------
    3090             : 
    3091        7835 : SvxLineItem::SvxLineItem( const sal_uInt16 nId ) :
    3092             : 
    3093             :     SfxPoolItem ( nId ),
    3094             : 
    3095        7835 :     pLine( NULL )
    3096             : {
    3097        7835 : }
    3098             : 
    3099             : // -----------------------------------------------------------------------
    3100             : 
    3101         557 : SvxLineItem::SvxLineItem( const SvxLineItem& rCpy ) :
    3102             : 
    3103         557 :     SfxPoolItem ( rCpy )
    3104             : {
    3105         557 :     pLine = rCpy.GetLine() ? new SvxBorderLine( *rCpy.GetLine() ) : 0;
    3106         557 : }
    3107             : 
    3108             : // -----------------------------------------------------------------------
    3109             : 
    3110       20821 : SvxLineItem::~SvxLineItem()
    3111             : {
    3112        7998 :     delete pLine;
    3113       12823 : }
    3114             : 
    3115             : // -----------------------------------------------------------------------
    3116             : 
    3117         512 : SvxLineItem& SvxLineItem::operator=( const SvxLineItem& rLine )
    3118             : {
    3119         512 :     SetLine( rLine.GetLine() );
    3120             : 
    3121         512 :     return *this;
    3122             : }
    3123             : 
    3124             : // -----------------------------------------------------------------------
    3125             : 
    3126      389717 : int SvxLineItem::operator==( const SfxPoolItem& rAttr ) const
    3127             : {
    3128             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
    3129             : 
    3130      389717 :     return CmpBrdLn( pLine, ((SvxLineItem&)rAttr).GetLine() );
    3131             : }
    3132             : 
    3133             : // -----------------------------------------------------------------------
    3134             : 
    3135         493 : SfxPoolItem* SvxLineItem::Clone( SfxItemPool* ) const
    3136             : {
    3137         493 :     return new SvxLineItem( *this );
    3138             : }
    3139             : 
    3140         260 : bool SvxLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemId ) const
    3141             : {
    3142         260 :     sal_Bool bConvert = 0!=(nMemId&CONVERT_TWIPS);
    3143         260 :     nMemId &= ~CONVERT_TWIPS;
    3144         260 :     if ( nMemId == 0 )
    3145             :     {
    3146         260 :         rVal <<= uno::makeAny( SvxBoxItem::SvxLineToLine(pLine, bConvert) );
    3147         260 :         return true;
    3148             :     }
    3149           0 :     else if ( pLine )
    3150             :     {
    3151           0 :         switch ( nMemId )
    3152             :         {
    3153           0 :             case MID_FG_COLOR:      rVal <<= sal_Int32(pLine->GetColor().GetColor()); break;
    3154           0 :             case MID_OUTER_WIDTH:   rVal <<= sal_Int32(pLine->GetOutWidth());   break;
    3155           0 :             case MID_INNER_WIDTH:   rVal <<= sal_Int32(pLine->GetInWidth( ));   break;
    3156           0 :             case MID_DISTANCE:      rVal <<= sal_Int32(pLine->GetDistance());   break;
    3157             :             default:
    3158             :                 OSL_FAIL( "Wrong MemberId" );
    3159           0 :                 return false;
    3160             :         }
    3161             :     }
    3162             : 
    3163           0 :     return true;
    3164             : }
    3165             : 
    3166             : // -----------------------------------------------------------------------
    3167             : 
    3168         208 : bool SvxLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemId )
    3169             : {
    3170         208 :     sal_Bool bConvert = 0!=(nMemId&CONVERT_TWIPS);
    3171         208 :     nMemId &= ~CONVERT_TWIPS;
    3172         208 :     sal_Int32 nVal = 0;
    3173         208 :     if ( nMemId == 0 )
    3174             :     {
    3175         208 :         table::BorderLine2 aLine;
    3176         208 :         if ( lcl_extractBorderLine(rVal, aLine) )
    3177             :         {
    3178         208 :             if ( !pLine )
    3179         208 :                 pLine = new SvxBorderLine;
    3180         208 :             if( !SvxBoxItem::LineToSvxLine(aLine, *pLine, bConvert) )
    3181         205 :                 DELETEZ( pLine );
    3182         208 :             return true;
    3183             :         }
    3184           0 :         return false;
    3185             :     }
    3186           0 :     else if ( rVal >>= nVal )
    3187             :     {
    3188           0 :         if ( !pLine )
    3189           0 :             pLine = new SvxBorderLine;
    3190             : 
    3191           0 :         switch ( nMemId )
    3192             :         {
    3193           0 :             case MID_FG_COLOR:      pLine->SetColor( Color(nVal) ); break;
    3194             :             case MID_LINE_STYLE:
    3195           0 :                 pLine->SetBorderLineStyle(static_cast<SvxBorderStyle>(nVal));
    3196           0 :             break;
    3197             :             default:
    3198             :                 OSL_FAIL( "Wrong MemberId" );
    3199           0 :                 return sal_False;
    3200             :         }
    3201             : 
    3202           0 :         return true;
    3203             :     }
    3204             : 
    3205           0 :     return false;
    3206             : }
    3207             : 
    3208             : //------------------------------------------------------------------------
    3209             : 
    3210           0 : SfxItemPresentation SvxLineItem::GetPresentation
    3211             : (
    3212             :     SfxItemPresentation ePres,
    3213             :     SfxMapUnit          eCoreUnit,
    3214             :     SfxMapUnit          ePresUnit,
    3215             :     OUString&           rText, const IntlWrapper *pIntl
    3216             : )   const
    3217             : {
    3218           0 :     rText = OUString();
    3219             : 
    3220           0 :     switch ( ePres )
    3221             :     {
    3222             :         case SFX_ITEM_PRESENTATION_NONE:
    3223           0 :             return SFX_ITEM_PRESENTATION_NONE;
    3224             :         case SFX_ITEM_PRESENTATION_NAMELESS:
    3225             :         case SFX_ITEM_PRESENTATION_COMPLETE:
    3226             :         {
    3227           0 :             if ( pLine )
    3228           0 :                 rText = pLine->GetValueString( eCoreUnit, ePresUnit, pIntl,
    3229           0 :                     (SFX_ITEM_PRESENTATION_COMPLETE == ePres) );
    3230           0 :             return ePres;
    3231             :         }
    3232             :         default: ;//prevent warning
    3233             :     }
    3234           0 :     return SFX_ITEM_PRESENTATION_NONE;
    3235             : }
    3236             : 
    3237             : // -----------------------------------------------------------------------
    3238             : 
    3239        1056 : SvStream& SvxLineItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
    3240             : {
    3241        1056 :     if( pLine )
    3242             :     {
    3243           0 :         rStrm << pLine->GetColor()
    3244           0 :               << (short)pLine->GetOutWidth()
    3245           0 :               << (short)pLine->GetInWidth()
    3246           0 :               << (short)pLine->GetDistance();
    3247             :     }
    3248             :     else
    3249        1056 :         rStrm << Color() << (short)0 << (short)0 << (short)0;
    3250        1056 :     return rStrm;
    3251             : }
    3252             : 
    3253             : // -----------------------------------------------------------------------
    3254             : 
    3255           0 : bool SvxLineItem::ScaleMetrics( long nMult, long nDiv )
    3256             : {
    3257           0 :     if ( pLine ) pLine->ScaleMetrics( nMult, nDiv );
    3258           0 :     return true;
    3259             : }
    3260             : 
    3261             : // -----------------------------------------------------------------------
    3262             : 
    3263           0 : bool SvxLineItem::HasMetrics() const
    3264             : {
    3265           0 :     return true;
    3266             : }
    3267             : 
    3268             : // -----------------------------------------------------------------------
    3269             : 
    3270         512 : SfxPoolItem* SvxLineItem::Create( SvStream& rStrm, sal_uInt16 ) const
    3271             : {
    3272         512 :     SvxLineItem* _pLine = new SvxLineItem( Which() );
    3273             :     short        nOutline, nInline, nDistance;
    3274         512 :     Color        aColor;
    3275             : 
    3276         512 :     rStrm >> aColor >> nOutline >> nInline >> nDistance;
    3277         512 :     if( nOutline )
    3278             :     {
    3279           0 :         SvxBorderLine aLine( &aColor );
    3280           0 :         aLine.GuessLinesWidths(NONE, nOutline, nInline, nDistance);
    3281           0 :         _pLine->SetLine( &aLine );
    3282             :     }
    3283         512 :     return _pLine;
    3284             : }
    3285             : 
    3286             : // -----------------------------------------------------------------------
    3287             : 
    3288         709 : void SvxLineItem::SetLine( const SvxBorderLine* pNew )
    3289             : {
    3290         709 :     delete pLine;
    3291         709 :     pLine = pNew ? new SvxBorderLine( *pNew ) : 0;
    3292         709 : }
    3293             : 
    3294             : // class SvxBrushItem ----------------------------------------------------
    3295             : 
    3296             : #define LOAD_GRAPHIC    ((sal_uInt16)0x0001)
    3297             : #define LOAD_LINK       ((sal_uInt16)0x0002)
    3298             : #define LOAD_FILTER     ((sal_uInt16)0x0004)
    3299             : 
    3300             : // class SvxBrushItem_Impl -----------------------------------------------
    3301             : 
    3302             : class SvxBrushItem_Impl
    3303             : {
    3304             : public:
    3305             :     GraphicObject*  pGraphicObject;
    3306             :     sal_Int8        nGraphicTransparency; //contains a percentage value which is
    3307             :                                           //copied to the GraphicObject when necessary
    3308             :     Link            aDoneLink;
    3309             :     SvStream*       pStream;
    3310             : 
    3311        7009 :     SvxBrushItem_Impl( GraphicObject* p ) : pGraphicObject( p ), nGraphicTransparency(0), pStream(0) {}
    3312             : };
    3313             : 
    3314             : // -----------------------------------------------------------------------
    3315             : 
    3316         456 : void SvxBrushItem::SetDoneLink( const Link& rLink )
    3317             : {
    3318         456 :     pImpl->aDoneLink = rLink;
    3319         456 : }
    3320             : 
    3321             : // -----------------------------------------------------------------------
    3322             : 
    3323        2349 : SvxBrushItem::SvxBrushItem( sal_uInt16 _nWhich ) :
    3324             : 
    3325             :     SfxPoolItem( _nWhich ),
    3326             : 
    3327             :     aColor           ( COL_TRANSPARENT ),
    3328             :     nShadingValue    ( ShadingPattern::CLEAR ),
    3329        2349 :     pImpl            ( new SvxBrushItem_Impl( 0 ) ),
    3330             :     pStrLink         ( NULL ),
    3331             :     pStrFilter       ( NULL ),
    3332             :     eGraphicPos      ( GPOS_NONE ),
    3333        4698 :     bLoadAgain       ( sal_True )
    3334             : 
    3335             : {
    3336        2349 : }
    3337             : 
    3338             : // -----------------------------------------------------------------------
    3339             : 
    3340        1621 : SvxBrushItem::SvxBrushItem( const Color& rColor, sal_uInt16 _nWhich) :
    3341             : 
    3342             :     SfxPoolItem( _nWhich ),
    3343             : 
    3344             :     aColor            ( rColor ),
    3345             :     nShadingValue     ( ShadingPattern::CLEAR ),
    3346        1621 :     pImpl             ( new SvxBrushItem_Impl( 0 ) ),
    3347             :     pStrLink          ( NULL ),
    3348             :     pStrFilter        ( NULL ),
    3349             :     eGraphicPos       ( GPOS_NONE ),
    3350        3242 :     bLoadAgain        ( sal_True )
    3351             : 
    3352             : {
    3353        1621 : }
    3354             : 
    3355             : // -----------------------------------------------------------------------
    3356             : 
    3357           0 : SvxBrushItem::SvxBrushItem( const Graphic& rGraphic, SvxGraphicPosition ePos,
    3358             :                             sal_uInt16 _nWhich ) :
    3359             : 
    3360             :     SfxPoolItem( _nWhich ),
    3361             : 
    3362             :     aColor            ( COL_TRANSPARENT ),
    3363             :     nShadingValue     ( ShadingPattern::CLEAR ),
    3364           0 :     pImpl             ( new SvxBrushItem_Impl( new GraphicObject( rGraphic ) ) ),
    3365             :     pStrLink          ( NULL ),
    3366             :     pStrFilter        ( NULL ),
    3367             :     eGraphicPos       ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
    3368           0 :     bLoadAgain        ( sal_True )
    3369             : 
    3370             : {
    3371             :     DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
    3372           0 : }
    3373             : 
    3374             : // -----------------------------------------------------------------------
    3375             : 
    3376           0 : SvxBrushItem::SvxBrushItem( const GraphicObject& rGraphicObj,
    3377             :                             SvxGraphicPosition ePos, sal_uInt16 _nWhich ) :
    3378             : 
    3379             :     SfxPoolItem( _nWhich ),
    3380             : 
    3381             :     aColor            ( COL_TRANSPARENT ),
    3382             :     nShadingValue     ( ShadingPattern::CLEAR ),
    3383           0 :     pImpl             ( new SvxBrushItem_Impl( new GraphicObject( rGraphicObj ) ) ),
    3384             :     pStrLink          ( NULL ),
    3385             :     pStrFilter        ( NULL ),
    3386             :     eGraphicPos       ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
    3387           0 :     bLoadAgain        ( sal_True )
    3388             : 
    3389             : {
    3390             :     DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
    3391           0 : }
    3392             : 
    3393             : // -----------------------------------------------------------------------
    3394             : 
    3395           9 : SvxBrushItem::SvxBrushItem(
    3396             :     const String& rLink, const String& rFilter,
    3397             :     SvxGraphicPosition ePos, sal_uInt16 _nWhich ) :
    3398             : 
    3399             :     SfxPoolItem( _nWhich ),
    3400             : 
    3401             :     aColor            ( COL_TRANSPARENT ),
    3402             :     nShadingValue     ( ShadingPattern::CLEAR ),
    3403           9 :     pImpl             ( new SvxBrushItem_Impl( NULL ) ),
    3404           9 :     pStrLink          ( new String( rLink ) ),
    3405           9 :     pStrFilter        ( new String( rFilter ) ),
    3406             :     eGraphicPos       ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
    3407          36 :     bLoadAgain        ( sal_True )
    3408             : 
    3409             : {
    3410             :     DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
    3411           9 : }
    3412             : 
    3413             : // -----------------------------------------------------------------------
    3414             : 
    3415         256 : SvxBrushItem::SvxBrushItem( SvStream& rStream, sal_uInt16 nVersion,
    3416             :                             sal_uInt16 _nWhich ) :
    3417             : 
    3418             :     SfxPoolItem( _nWhich ),
    3419             : 
    3420             :     aColor            ( COL_TRANSPARENT ),
    3421             :     nShadingValue     ( ShadingPattern::CLEAR ),
    3422         256 :     pImpl             ( new SvxBrushItem_Impl( NULL ) ),
    3423             :     pStrLink          ( NULL ),
    3424             :     pStrFilter        ( NULL ),
    3425         512 :     eGraphicPos       ( GPOS_NONE )
    3426             : 
    3427             : {
    3428             :     sal_Bool bTrans;
    3429         256 :     Color aTempColor;
    3430         256 :     Color aTempFillColor;
    3431             :     sal_Int8 nStyle;
    3432             : 
    3433         256 :     rStream >> bTrans;
    3434         256 :     rStream >> aTempColor;
    3435         256 :     rStream >> aTempFillColor;
    3436         256 :     rStream >> nStyle;
    3437             : 
    3438         256 :     switch ( nStyle )
    3439             :     {
    3440             :         case 8://BRUSH_25:
    3441             :         {
    3442           0 :             sal_uInt32  nRed    = aTempColor.GetRed();
    3443           0 :             sal_uInt32  nGreen  = aTempColor.GetGreen();
    3444           0 :             sal_uInt32  nBlue   = aTempColor.GetBlue();
    3445           0 :             nRed   += (sal_uInt32)(aTempFillColor.GetRed())*2;
    3446           0 :             nGreen += (sal_uInt32)(aTempFillColor.GetGreen())*2;
    3447           0 :             nBlue  += (sal_uInt32)(aTempFillColor.GetBlue())*2;
    3448           0 :             aColor = Color( (sal_Int8)(nRed/3), (sal_Int8)(nGreen/3), (sal_Int8)(nBlue/3) );
    3449             :         }
    3450           0 :         break;
    3451             : 
    3452             :         case 9://BRUSH_50:
    3453             :         {
    3454           0 :             sal_uInt32  nRed    = aTempColor.GetRed();
    3455           0 :             sal_uInt32  nGreen  = aTempColor.GetGreen();
    3456           0 :             sal_uInt32  nBlue   = aTempColor.GetBlue();
    3457           0 :             nRed   += (sal_uInt32)(aTempFillColor.GetRed());
    3458           0 :             nGreen += (sal_uInt32)(aTempFillColor.GetGreen());
    3459           0 :             nBlue  += (sal_uInt32)(aTempFillColor.GetBlue());
    3460           0 :             aColor = Color( (sal_Int8)(nRed/2), (sal_Int8)(nGreen/2), (sal_Int8)(nBlue/2) );
    3461             :         }
    3462           0 :         break;
    3463             : 
    3464             :         case 10://BRUSH_75:
    3465             :         {
    3466           0 :             sal_uInt32  nRed    = aTempColor.GetRed()*2;
    3467           0 :             sal_uInt32  nGreen  = aTempColor.GetGreen()*2;
    3468           0 :             sal_uInt32  nBlue   = aTempColor.GetBlue()*2;
    3469           0 :             nRed   += (sal_uInt32)(aTempFillColor.GetRed());
    3470           0 :             nGreen += (sal_uInt32)(aTempFillColor.GetGreen());
    3471           0 :             nBlue  += (sal_uInt32)(aTempFillColor.GetBlue());
    3472           0 :             aColor = Color( (sal_Int8)(nRed/3), (sal_Int8)(nGreen/3), (sal_Int8)(nBlue/3) );
    3473             :         }
    3474           0 :         break;
    3475             : 
    3476             :         case 0://BRUSH_NULL:
    3477           4 :             aColor = Color( COL_TRANSPARENT );
    3478           4 :         break;
    3479             : 
    3480             :         default:
    3481         252 :             aColor = aTempColor;
    3482             :     }
    3483             : 
    3484         256 :     if ( nVersion >= BRUSH_GRAPHIC_VERSION )
    3485             :     {
    3486         256 :         sal_uInt16 nDoLoad = 0;
    3487             :         sal_Int8 nPos;
    3488             : 
    3489         256 :         rStream >> nDoLoad;
    3490             : 
    3491         256 :         if ( nDoLoad & LOAD_GRAPHIC )
    3492             :         {
    3493           0 :             Graphic aGraphic;
    3494             : 
    3495           0 :             rStream >> aGraphic;
    3496           0 :             pImpl->pGraphicObject = new GraphicObject( aGraphic );
    3497             : 
    3498           0 :             if( SVSTREAM_FILEFORMAT_ERROR == rStream.GetError() )
    3499             :             {
    3500           0 :                 rStream.ResetError();
    3501             :                 rStream.SetError( ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT|
    3502           0 :                                   ERRCODE_WARNING_MASK  );
    3503           0 :             }
    3504             :         }
    3505             : 
    3506         256 :         if ( nDoLoad & LOAD_LINK )
    3507             :         {
    3508             :             // UNICODE: rStream >> aRel;
    3509           0 :             String aRel = rStream.ReadUniOrByteString(rStream.GetStreamCharSet());
    3510             : 
    3511             :             // TODO/MBA: how can we get a BaseURL here?!
    3512             :             OSL_FAIL("No BaseURL!");
    3513           0 :             String aAbs = INetURLObject::GetAbsURL( String(), aRel );
    3514             :             DBG_ASSERT( aAbs.Len(), "Invalid URL!" );
    3515           0 :             pStrLink = new String( aAbs );
    3516             :         }
    3517             : 
    3518         256 :         if ( nDoLoad & LOAD_FILTER )
    3519             :         {
    3520           0 :             pStrFilter = new String;
    3521             :             // UNICODE: rStream >> *pStrFilter;
    3522           0 :             *pStrFilter = rStream.ReadUniOrByteString(rStream.GetStreamCharSet());
    3523             :         }
    3524             : 
    3525         256 :         rStream >> nPos;
    3526             : 
    3527         256 :         eGraphicPos = (SvxGraphicPosition)nPos;
    3528             :     }
    3529         256 : }
    3530             : 
    3531             : // -----------------------------------------------------------------------
    3532             : 
    3533        2774 : SvxBrushItem::SvxBrushItem( const SvxBrushItem& rItem ) :
    3534             : 
    3535        2774 :     SfxPoolItem( rItem.Which() ),
    3536             :     nShadingValue     ( ShadingPattern::CLEAR ),
    3537        2774 :     pImpl             ( new SvxBrushItem_Impl( NULL ) ),
    3538             :     pStrLink          ( NULL ),
    3539             :     pStrFilter        ( NULL ),
    3540             :     eGraphicPos       ( GPOS_NONE ),
    3541        5548 :     bLoadAgain        ( sal_True )
    3542             : 
    3543             : {
    3544        2774 :     *this = rItem;
    3545        2774 : }
    3546             : 
    3547             : // -----------------------------------------------------------------------
    3548             : 
    3549       17368 : SvxBrushItem::~SvxBrushItem()
    3550             : {
    3551        6778 :     delete pImpl->pGraphicObject;
    3552        6778 :     delete pImpl;
    3553        6778 :     delete pStrLink;
    3554        6778 :     delete pStrFilter;
    3555       10590 : }
    3556             : 
    3557             : // -----------------------------------------------------------------------
    3558             : 
    3559         530 : sal_uInt16 SvxBrushItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
    3560             : {
    3561         530 :     return BRUSH_GRAPHIC_VERSION;
    3562             : }
    3563             : 
    3564             : // -----------------------------------------------------------------------
    3565          21 : static inline sal_Int8 lcl_PercentToTransparency(long nPercent)
    3566             : {
    3567             :     //0xff must not be returned!
    3568          21 :     return sal_Int8(nPercent ? (50 + 0xfe * nPercent) / 100 : 0);
    3569             : }
    3570           3 : static inline sal_Int8 lcl_TransparencyToPercent(sal_Int32 nTrans)
    3571             : {
    3572           3 :     return (sal_Int8)((nTrans * 100 + 127) / 254);
    3573             : }
    3574             : 
    3575         378 : bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
    3576             : {
    3577         378 :     nMemberId &= ~CONVERT_TWIPS;
    3578         378 :     switch( nMemberId)
    3579             :     {
    3580             :         case MID_BACK_COLOR:
    3581         124 :             rVal <<= (sal_Int32)( aColor.GetColor() );
    3582         124 :         break;
    3583             :         case MID_BACK_COLOR_R_G_B:
    3584           0 :             rVal <<= (sal_Int32)( aColor.GetRGBColor() );
    3585           0 :         break;
    3586             :         case MID_BACK_COLOR_TRANSPARENCY:
    3587           3 :             rVal <<= lcl_TransparencyToPercent(aColor.GetTransparency());
    3588           3 :         break;
    3589             :         case MID_GRAPHIC_POSITION:
    3590          52 :             rVal <<= (style::GraphicLocation)(sal_Int16)eGraphicPos;
    3591          52 :         break;
    3592             : 
    3593             :         case MID_GRAPHIC:
    3594             :             SAL_WARN( "editeng.items", "not implemented" );
    3595           0 :         break;
    3596             : 
    3597             :         case MID_GRAPHIC_TRANSPARENT:
    3598         100 :             rVal = Bool2Any( aColor.GetTransparency() == 0xff );
    3599         100 :         break;
    3600             : 
    3601             :         case MID_GRAPHIC_URL:
    3602             :         {
    3603          41 :             OUString sLink;
    3604          41 :             if ( pStrLink )
    3605           3 :                 sLink = *pStrLink;
    3606          38 :             else if( pImpl->pGraphicObject )
    3607             :             {
    3608             :                 OUString sPrefix(
    3609           4 :                     UNO_NAME_GRAPHOBJ_URLPREFIX);
    3610             :                 OUString sId(OStringToOUString(
    3611             :                     pImpl->pGraphicObject->GetUniqueID(),
    3612           8 :                     RTL_TEXTENCODING_ASCII_US));
    3613           8 :                 sLink = sPrefix + sId;
    3614             :             }
    3615          41 :             rVal <<= sLink;
    3616             :         }
    3617          41 :         break;
    3618             : 
    3619             :         case MID_GRAPHIC_FILTER:
    3620             :         {
    3621          49 :             OUString sFilter;
    3622          49 :             if ( pStrFilter )
    3623          12 :                 sFilter = *pStrFilter;
    3624          49 :             rVal <<= sFilter;
    3625             :         }
    3626          49 :         break;
    3627             : 
    3628             :         case MID_GRAPHIC_TRANSPARENCY:
    3629           0 :             rVal <<= pImpl->nGraphicTransparency;
    3630           0 :         break;
    3631             : 
    3632             :         case MID_SHADING_VALUE:
    3633             :         {
    3634           9 :             rVal <<= (sal_Int32)(nShadingValue);
    3635             :         }
    3636           9 :         break;
    3637             :     }
    3638             : 
    3639         378 :     return true;
    3640             : }
    3641             : 
    3642             : // -----------------------------------------------------------------------
    3643             : 
    3644        1373 : bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
    3645             : {
    3646        1373 :     nMemberId &= ~CONVERT_TWIPS;
    3647        1373 :     switch( nMemberId)
    3648             :     {
    3649             :         case MID_BACK_COLOR:
    3650             :         case MID_BACK_COLOR_R_G_B:
    3651             :         {
    3652         632 :             sal_Int32 nCol = 0;
    3653         632 :             if ( !( rVal >>= nCol ) )
    3654           0 :                 return sal_False;
    3655         632 :             if(MID_BACK_COLOR_R_G_B == nMemberId)
    3656             :             {
    3657           0 :                 nCol = COLORDATA_RGB( nCol );
    3658           0 :                 nCol += aColor.GetColor() & 0xff000000;
    3659             :             }
    3660         632 :             aColor = Color( nCol );
    3661             :         }
    3662         632 :         break;
    3663             :         case MID_BACK_COLOR_TRANSPARENCY:
    3664             :         {
    3665          10 :             sal_Int32 nTrans = 0;
    3666          10 :             if ( !( rVal >>= nTrans ) || nTrans < 0 || nTrans > 100 )
    3667           0 :                 return sal_False;
    3668          10 :             aColor.SetTransparency(lcl_PercentToTransparency(nTrans));
    3669             :         }
    3670          10 :         break;
    3671             : 
    3672             :         case MID_GRAPHIC_POSITION:
    3673             :         {
    3674             :             style::GraphicLocation eLocation;
    3675         174 :             if ( !( rVal>>=eLocation ) )
    3676             :             {
    3677           0 :                 sal_Int32 nValue = 0;
    3678           0 :                 if ( !( rVal >>= nValue ) )
    3679           0 :                     return sal_False;
    3680           0 :                 eLocation = (style::GraphicLocation)nValue;
    3681             :             }
    3682         174 :             SetGraphicPos( (SvxGraphicPosition)(sal_uInt16)eLocation );
    3683             :         }
    3684         174 :         break;
    3685             : 
    3686             :         case MID_GRAPHIC:
    3687             :             SAL_WARN( "editeng.items", "not implemented" );
    3688           0 :         break;
    3689             : 
    3690             :         case MID_GRAPHIC_TRANSPARENT:
    3691         201 :             aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 );
    3692         201 :         break;
    3693             : 
    3694             :         case MID_GRAPHIC_URL:
    3695             :         {
    3696         173 :             if ( rVal.getValueType() == ::getCppuType( (OUString*)0 ) )
    3697             :             {
    3698         173 :                 OUString sLink;
    3699         173 :                 rVal >>= sLink;
    3700         173 :                 if( sLink.startsWith( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) )
    3701             :                 {
    3702             :                     OSL_FAIL( "package urls aren't implemented" );
    3703             :                 }
    3704         173 :                 else if( sLink.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX ) )
    3705             :                 {
    3706           6 :                     DELETEZ( pStrLink );
    3707           6 :                     String sTmp( sLink );
    3708             :                     OString sId(OUStringToOString(sTmp.Copy(
    3709             :                         sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX)-1),
    3710          12 :                         RTL_TEXTENCODING_ASCII_US));
    3711           6 :                     GraphicObject *pOldGrfObj = pImpl->pGraphicObject;
    3712           6 :                     pImpl->pGraphicObject = new GraphicObject( sId );
    3713           6 :                     ApplyGraphicTransparency_Impl();
    3714          12 :                     delete pOldGrfObj;
    3715             :                 }
    3716             :                 else
    3717             :                 {
    3718         167 :                     SetGraphicLink(sLink);
    3719             :                 }
    3720         173 :                 if ( !sLink.isEmpty() && eGraphicPos == GPOS_NONE )
    3721           3 :                     eGraphicPos = GPOS_MM;
    3722         170 :                 else if( sLink.isEmpty() )
    3723         164 :                     eGraphicPos = GPOS_NONE;
    3724             :             }
    3725             :         }
    3726         173 :         break;
    3727             : 
    3728             :         case MID_GRAPHIC_FILTER:
    3729             :         {
    3730         173 :             if( rVal.getValueType() == ::getCppuType( (OUString*)0 ) )
    3731             :             {
    3732         173 :                 OUString sLink;
    3733         173 :                 rVal >>= sLink;
    3734         173 :                 SetGraphicFilter( sLink );
    3735             :             }
    3736             :         }
    3737         173 :         break;
    3738             :         case MID_GRAPHIC_TRANSPARENCY :
    3739             :         {
    3740           0 :             sal_Int32 nTmp = 0;
    3741           0 :             rVal >>= nTmp;
    3742           0 :             if(nTmp >= 0 && nTmp <= 100)
    3743             :             {
    3744           0 :                 pImpl->nGraphicTransparency = sal_Int8(nTmp);
    3745           0 :                 if(pImpl->pGraphicObject)
    3746           0 :                     ApplyGraphicTransparency_Impl();
    3747             :             }
    3748             :         }
    3749           0 :         break;
    3750             : 
    3751             :         case MID_SHADING_VALUE:
    3752             :         {
    3753          10 :             sal_uInt32 nVal = 0;
    3754          10 :             if (!(rVal >>= nVal))
    3755           0 :                 return false;
    3756             : 
    3757          10 :             SetShadingValue( nVal );
    3758             :         }
    3759          10 :         break;
    3760             :     }
    3761             : 
    3762        1373 :     return true;
    3763             : }
    3764             : 
    3765             : // -----------------------------------------------------------------------
    3766             : 
    3767           0 : SfxItemPresentation SvxBrushItem::GetPresentation
    3768             : (
    3769             :     SfxItemPresentation ePres,
    3770             :     SfxMapUnit          /*eCoreUnit*/,
    3771             :     SfxMapUnit          /*ePresUnit*/,
    3772             :     OUString&           rText, const IntlWrapper *
    3773             :     ) const
    3774             : {
    3775           0 :     switch ( ePres )
    3776             :     {
    3777             :         case SFX_ITEM_PRESENTATION_NONE:
    3778           0 :             rText = OUString();
    3779           0 :             return ePres;
    3780             : 
    3781             :         case SFX_ITEM_PRESENTATION_NAMELESS:
    3782             :         case SFX_ITEM_PRESENTATION_COMPLETE:
    3783             :         {
    3784           0 :             if ( GPOS_NONE  == eGraphicPos )
    3785             :             {
    3786           0 :                 rText = ::GetColorString( aColor ) + OUString(cpDelim);
    3787           0 :                 sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
    3788             : 
    3789           0 :                 if ( aColor.GetTransparency() )
    3790           0 :                     nId = RID_SVXITEMS_TRANSPARENT_TRUE;
    3791           0 :                 rText += EE_RESSTR(nId);
    3792             :             }
    3793             :             else
    3794             :             {
    3795           0 :                 rText = EE_RESSTR(RID_SVXITEMS_GRAPHIC);
    3796             :             }
    3797             : 
    3798           0 :             return ePres;
    3799             :         }
    3800             :         default: ;//prevent warning
    3801             :     }
    3802             : 
    3803           0 :     return SFX_ITEM_PRESENTATION_NONE;
    3804             : }
    3805             : 
    3806             : // -----------------------------------------------------------------------
    3807             : 
    3808        3658 : SvxBrushItem& SvxBrushItem::operator=( const SvxBrushItem& rItem )
    3809             : {
    3810        3658 :     aColor = rItem.aColor;
    3811        3658 :     eGraphicPos = rItem.eGraphicPos;
    3812             : 
    3813        3658 :     DELETEZ( pImpl->pGraphicObject );
    3814        3658 :     DELETEZ( pStrLink );
    3815        3658 :     DELETEZ( pStrFilter );
    3816             : 
    3817        3658 :     if ( GPOS_NONE != eGraphicPos )
    3818             :     {
    3819         223 :         if ( rItem.pStrLink )
    3820          91 :             pStrLink = new String( *rItem.pStrLink );
    3821         223 :         if ( rItem.pStrFilter )
    3822         195 :             pStrFilter = new String( *rItem.pStrFilter );
    3823         223 :         if ( rItem.pImpl->pGraphicObject )
    3824             :         {
    3825         132 :             pImpl->pGraphicObject = new GraphicObject( *rItem.pImpl->pGraphicObject );
    3826             :         }
    3827             :     }
    3828             : 
    3829        3658 :     nShadingValue = rItem.nShadingValue;
    3830             : 
    3831        3658 :     pImpl->nGraphicTransparency = rItem.pImpl->nGraphicTransparency;
    3832        3658 :     return *this;
    3833             : }
    3834             : 
    3835             : // -----------------------------------------------------------------------
    3836             : 
    3837      206586 : int SvxBrushItem::operator==( const SfxPoolItem& rAttr ) const
    3838             : {
    3839             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
    3840             : 
    3841      206586 :     SvxBrushItem& rCmp = (SvxBrushItem&)rAttr;
    3842      405610 :     sal_Bool bEqual = ( aColor == rCmp.aColor && eGraphicPos == rCmp.eGraphicPos &&
    3843      405610 :         pImpl->nGraphicTransparency == rCmp.pImpl->nGraphicTransparency);
    3844             : 
    3845      206586 :     if ( bEqual )
    3846             :     {
    3847      199024 :         if ( GPOS_NONE != eGraphicPos )
    3848             :         {
    3849         150 :             if ( !rCmp.pStrLink )
    3850          99 :                 bEqual = !pStrLink;
    3851             :             else
    3852          51 :                 bEqual = pStrLink && ( *pStrLink == *rCmp.pStrLink );
    3853             : 
    3854         150 :             if ( bEqual )
    3855             :             {
    3856         150 :                 if ( !rCmp.pStrFilter )
    3857          13 :                     bEqual = !pStrFilter;
    3858             :                 else
    3859         137 :                     bEqual = pStrFilter && ( *pStrFilter == *rCmp.pStrFilter );
    3860             :             }
    3861             : 
    3862         150 :             if ( bEqual && !rCmp.pStrLink )
    3863             :             {
    3864          91 :                 if ( !rCmp.pImpl->pGraphicObject )
    3865           0 :                     bEqual = !pImpl->pGraphicObject;
    3866             :                 else
    3867         182 :                     bEqual = pImpl->pGraphicObject &&
    3868         182 :                              ( *pImpl->pGraphicObject == *rCmp.pImpl->pGraphicObject );
    3869             :             }
    3870             :         }
    3871             : 
    3872      199024 :         if (bEqual)
    3873             :         {
    3874      198999 :             bEqual = nShadingValue == rCmp.nShadingValue;
    3875             :         }
    3876             :     }
    3877             : 
    3878      206586 :     return bEqual;
    3879             : }
    3880             : 
    3881             : // -----------------------------------------------------------------------
    3882             : 
    3883        2559 : SfxPoolItem* SvxBrushItem::Clone( SfxItemPool* ) const
    3884             : {
    3885        2559 :     return new SvxBrushItem( *this );
    3886             : }
    3887             : 
    3888             : // -----------------------------------------------------------------------
    3889             : 
    3890         256 : SfxPoolItem* SvxBrushItem::Create( SvStream& rStream, sal_uInt16 nVersion ) const
    3891             : {
    3892         256 :     return new SvxBrushItem( rStream, nVersion, Which() );
    3893             : }
    3894             : 
    3895             : // -----------------------------------------------------------------------
    3896             : 
    3897         528 : SvStream& SvxBrushItem::Store( SvStream& rStream , sal_uInt16 /*nItemVersion*/ ) const
    3898             : {
    3899         528 :     rStream << (sal_Bool)sal_False;
    3900         528 :     rStream << aColor;
    3901         528 :     rStream << aColor;
    3902         528 :     rStream << (sal_Int8)(aColor.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
    3903             : 
    3904         528 :     sal_uInt16 nDoLoad = 0;
    3905             : 
    3906         528 :     if ( pImpl->pGraphicObject && !pStrLink )
    3907           0 :         nDoLoad |= LOAD_GRAPHIC;
    3908         528 :     if ( pStrLink )
    3909           0 :         nDoLoad |= LOAD_LINK;
    3910         528 :     if ( pStrFilter )
    3911           0 :         nDoLoad |= LOAD_FILTER;
    3912         528 :     rStream << nDoLoad;
    3913             : 
    3914         528 :     if ( pImpl->pGraphicObject && !pStrLink )
    3915           0 :         rStream << pImpl->pGraphicObject->GetGraphic();
    3916         528 :     if ( pStrLink )
    3917             :     {
    3918             :         OSL_FAIL("No BaseURL!");
    3919             :         // TODO/MBA: how to get a BaseURL?!
    3920           0 :         String aRel = INetURLObject::GetRelURL( String(), *pStrLink );
    3921             :         // UNICODE: rStream << aRel;
    3922           0 :         rStream.WriteUniOrByteString(aRel, rStream.GetStreamCharSet());
    3923             :     }
    3924         528 :     if ( pStrFilter )
    3925             :     {
    3926             :         // UNICODE: rStream << *pStrFilter;
    3927           0 :         rStream.WriteUniOrByteString(*pStrFilter, rStream.GetStreamCharSet());
    3928             :     }
    3929         528 :     rStream << (sal_Int8)eGraphicPos;
    3930         528 :     return rStream;
    3931             : }
    3932             : 
    3933             : // -----------------------------------------------------------------------
    3934             : 
    3935           0 : void SvxBrushItem::PurgeMedium() const
    3936             : {
    3937           0 :     DELETEZ( pImpl->pStream );
    3938           0 : }
    3939             : 
    3940             : // -----------------------------------------------------------------------
    3941        2404 : const GraphicObject* SvxBrushItem::GetGraphicObject() const
    3942             : {
    3943        2404 :     if ( bLoadAgain && pStrLink && !pImpl->pGraphicObject )
    3944             :     // when graphics already loaded, use as a cache
    3945             :     {
    3946             :         // only with "valid" names - empty names now allowed
    3947           8 :         if( pStrLink->Len() )
    3948             :         {
    3949           4 :             pImpl->pStream = utl::UcbStreamHelper::CreateStream( *pStrLink, STREAM_STD_READ );
    3950           4 :             if( pImpl->pStream && !pImpl->pStream->GetError() )
    3951             :             {
    3952           0 :                 Graphic aGraphic;
    3953             :                 int nRes;
    3954           0 :                 pImpl->pStream->Seek( STREAM_SEEK_TO_BEGIN );
    3955           0 :                 nRes = GraphicFilter::GetGraphicFilter().
    3956             :                     ImportGraphic( aGraphic, *pStrLink, *pImpl->pStream,
    3957           0 :                                    GRFILTER_FORMAT_DONTKNOW, NULL, GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG );
    3958             : 
    3959           0 :                 if( nRes != GRFILTER_OK )
    3960             :                 {
    3961           0 :                     const_cast < SvxBrushItem*> (this)->bLoadAgain = sal_False;
    3962             :                 }
    3963             :                 else
    3964             :                 {
    3965           0 :                     pImpl->pGraphicObject = new GraphicObject;
    3966           0 :                     pImpl->pGraphicObject->SetGraphic( aGraphic );
    3967           0 :                     const_cast < SvxBrushItem*> (this)->ApplyGraphicTransparency_Impl();
    3968           0 :                 }
    3969             :             }
    3970             :             else
    3971             :             {
    3972           4 :                 const_cast < SvxBrushItem*> (this)->bLoadAgain = sal_False;
    3973             :             }
    3974             :         }
    3975             :     }
    3976             : 
    3977        2404 :     return pImpl->pGraphicObject;
    3978             : }
    3979             : 
    3980             : // -----------------------------------------------------------------------
    3981             : 
    3982         613 : const Graphic* SvxBrushItem::GetGraphic() const
    3983             : {
    3984         613 :     const GraphicObject* pGrafObj = GetGraphicObject();
    3985         613 :     return( pGrafObj ? &( pGrafObj->GetGraphic() ) : NULL );
    3986             : }
    3987             : 
    3988             : // -----------------------------------------------------------------------
    3989             : 
    3990         174 : void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew )
    3991             : {
    3992         174 :     eGraphicPos = eNew;
    3993             : 
    3994         174 :     if ( GPOS_NONE == eGraphicPos )
    3995             :     {
    3996         164 :         DELETEZ( pImpl->pGraphicObject );
    3997         164 :         DELETEZ( pStrLink );
    3998         164 :         DELETEZ( pStrFilter );
    3999             :     }
    4000             :     else
    4001             :     {
    4002          10 :         if ( !pImpl->pGraphicObject && !pStrLink )
    4003             :         {
    4004           3 :             pImpl->pGraphicObject = new GraphicObject; // Creating a dummy
    4005             :         }
    4006             :     }
    4007         174 : }
    4008             : 
    4009             : // -----------------------------------------------------------------------
    4010             : 
    4011           9 : void SvxBrushItem::SetGraphic( const Graphic& rNew )
    4012             : {
    4013           9 :     if ( !pStrLink )
    4014             :     {
    4015           5 :         if ( pImpl->pGraphicObject )
    4016           5 :             pImpl->pGraphicObject->SetGraphic( rNew );
    4017             :         else
    4018           0 :             pImpl->pGraphicObject = new GraphicObject( rNew );
    4019             : 
    4020           5 :         ApplyGraphicTransparency_Impl();
    4021             : 
    4022           5 :         if ( GPOS_NONE == eGraphicPos )
    4023           0 :             eGraphicPos = GPOS_MM; // None would be brush, then Default: middle
    4024             :     }
    4025             :     else
    4026             :     {
    4027             :         OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
    4028             :     }
    4029           9 : }
    4030             : 
    4031             : // -----------------------------------------------------------------------
    4032             : 
    4033           0 : void SvxBrushItem::SetGraphicObject( const GraphicObject& rNewObj )
    4034             : {
    4035           0 :     if ( !pStrLink )
    4036             :     {
    4037           0 :         if ( pImpl->pGraphicObject )
    4038           0 :             *pImpl->pGraphicObject = rNewObj;
    4039             :         else
    4040           0 :             pImpl->pGraphicObject = new GraphicObject( rNewObj );
    4041             : 
    4042           0 :         ApplyGraphicTransparency_Impl();
    4043             : 
    4044           0 :         if ( GPOS_NONE == eGraphicPos )
    4045           0 :             eGraphicPos = GPOS_MM; // None would be brush, then Default: middle
    4046             :     }
    4047             :     else
    4048             :     {
    4049             :         OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
    4050             :     }
    4051           0 : }
    4052             : 
    4053             : // -----------------------------------------------------------------------
    4054             : 
    4055         167 : void SvxBrushItem::SetGraphicLink( const String& rNew )
    4056             : {
    4057         167 :     if ( !rNew.Len() )
    4058         164 :         DELETEZ( pStrLink );
    4059             :     else
    4060             :     {
    4061           3 :         if ( pStrLink )
    4062           0 :             *pStrLink = rNew;
    4063             :         else
    4064           3 :             pStrLink = new String( rNew );
    4065             : 
    4066           3 :         DELETEZ( pImpl->pGraphicObject );
    4067             :     }
    4068         167 : }
    4069             : 
    4070             : // -----------------------------------------------------------------------
    4071             : 
    4072         173 : void SvxBrushItem::SetGraphicFilter( const String& rNew )
    4073             : {
    4074         173 :     if ( !rNew.Len() )
    4075         165 :         DELETEZ( pStrFilter );
    4076             :     else
    4077             :     {
    4078           8 :         if ( pStrFilter )
    4079           3 :             *pStrFilter = rNew;
    4080             :         else
    4081           5 :             pStrFilter = new String( rNew );
    4082             :     }
    4083         173 : }
    4084             : 
    4085          10 : void SvxBrushItem::SetShadingValue( const sal_uInt32 nNew )
    4086             : {
    4087          10 :     nShadingValue = nNew;
    4088          10 : }
    4089             : 
    4090             : //static
    4091           0 : SvxGraphicPosition SvxBrushItem::WallpaperStyle2GraphicPos( WallpaperStyle eStyle )
    4092             : {
    4093             :     SvxGraphicPosition eResult;
    4094             :     // The switch is not the fastest, but the safest
    4095           0 :     switch( eStyle )
    4096             :     {
    4097           0 :         case WALLPAPER_NULL: eResult = GPOS_NONE; break;
    4098           0 :         case WALLPAPER_TILE: eResult = GPOS_TILED; break;
    4099           0 :         case WALLPAPER_CENTER: eResult = GPOS_MM; break;
    4100           0 :         case WALLPAPER_SCALE: eResult = GPOS_AREA; break;
    4101           0 :         case WALLPAPER_TOPLEFT: eResult = GPOS_LT; break;
    4102           0 :         case WALLPAPER_TOP: eResult = GPOS_MT; break;
    4103           0 :         case WALLPAPER_TOPRIGHT: eResult = GPOS_RT; break;
    4104           0 :         case WALLPAPER_LEFT: eResult = GPOS_LM; break;
    4105           0 :         case WALLPAPER_RIGHT: eResult = GPOS_RM; break;
    4106           0 :         case WALLPAPER_BOTTOMLEFT: eResult = GPOS_LB; break;
    4107           0 :         case WALLPAPER_BOTTOM: eResult = GPOS_MB; break;
    4108           0 :         case WALLPAPER_BOTTOMRIGHT: eResult = GPOS_RB; break;
    4109           0 :         default: eResult = GPOS_NONE;
    4110             :     }
    4111           0 :     return eResult;
    4112             : };
    4113             : 
    4114             : //static
    4115           0 : WallpaperStyle SvxBrushItem::GraphicPos2WallpaperStyle( SvxGraphicPosition ePos )
    4116             : {
    4117             :     WallpaperStyle eResult;
    4118           0 :     switch( ePos )
    4119             :     {
    4120           0 :         case GPOS_NONE: eResult = WALLPAPER_NULL; break;
    4121           0 :         case GPOS_TILED: eResult = WALLPAPER_TILE; break;
    4122           0 :         case GPOS_MM: eResult = WALLPAPER_CENTER; break;
    4123           0 :         case GPOS_AREA: eResult = WALLPAPER_SCALE; break;
    4124           0 :         case GPOS_LT: eResult = WALLPAPER_TOPLEFT; break;
    4125           0 :         case GPOS_MT: eResult = WALLPAPER_TOP; break;
    4126           0 :         case GPOS_RT: eResult = WALLPAPER_TOPRIGHT; break;
    4127           0 :         case GPOS_LM: eResult = WALLPAPER_LEFT; break;
    4128           0 :         case GPOS_RM: eResult = WALLPAPER_RIGHT; break;
    4129           0 :         case GPOS_LB: eResult = WALLPAPER_BOTTOMLEFT; break;
    4130           0 :         case GPOS_MB: eResult = WALLPAPER_BOTTOM; break;
    4131           0 :         case GPOS_RB: eResult = WALLPAPER_BOTTOMRIGHT; break;
    4132           0 :         default: eResult = WALLPAPER_NULL;
    4133             :     }
    4134           0 :     return eResult;
    4135             : }
    4136             : 
    4137           0 : SvxBrushItem::SvxBrushItem( const CntWallpaperItem& rItem, sal_uInt16 _nWhich ) :
    4138             :     SfxPoolItem    ( _nWhich ),
    4139             :     nShadingValue  ( ShadingPattern::CLEAR ),
    4140           0 :     pImpl          ( new SvxBrushItem_Impl( 0 ) ),
    4141             :     pStrLink       ( 0),
    4142             :     pStrFilter     ( 0),
    4143           0 :     bLoadAgain     ( sal_True )
    4144             : {
    4145           0 :     aColor = rItem.GetColor();
    4146             : 
    4147           0 :     if (!rItem.GetBitmapURL().isEmpty())
    4148             :     {
    4149           0 :         pStrLink    = new String( rItem.GetBitmapURL() );
    4150           0 :         SetGraphicPos( WallpaperStyle2GraphicPos((WallpaperStyle)rItem.GetStyle() ) );
    4151             :     }
    4152           0 : }
    4153             : 
    4154          11 : void  SvxBrushItem::ApplyGraphicTransparency_Impl()
    4155             : {
    4156             :     DBG_ASSERT(pImpl->pGraphicObject, "no GraphicObject available" );
    4157          11 :     if(pImpl->pGraphicObject)
    4158             :     {
    4159          11 :         GraphicAttr aAttr(pImpl->pGraphicObject->GetAttr());
    4160             :         aAttr.SetTransparency(lcl_PercentToTransparency(
    4161          11 :                             pImpl->nGraphicTransparency));
    4162          11 :         pImpl->pGraphicObject->SetAttr(aAttr);
    4163             :     }
    4164          11 : }
    4165             : 
    4166             : // class SvxFrameDirectionItem ----------------------------------------------
    4167             : 
    4168       16208 : SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue ,
    4169             :                                             sal_uInt16 _nWhich )
    4170       16208 :     : SfxUInt16Item( _nWhich, (sal_uInt16)nValue )
    4171             : {
    4172       16208 : }
    4173             : 
    4174       83090 : SvxFrameDirectionItem::~SvxFrameDirectionItem()
    4175             : {
    4176       83090 : }
    4177             : 
    4178       60619 : int SvxFrameDirectionItem::operator==( const SfxPoolItem& rCmp ) const
    4179             : {
    4180             :     DBG_ASSERT( SfxPoolItem::operator==(rCmp), "unequal types" );
    4181             : 
    4182       60619 :     return GetValue() == ((SvxFrameDirectionItem&)rCmp).GetValue();
    4183             : }
    4184             : 
    4185       33280 : SfxPoolItem* SvxFrameDirectionItem::Clone( SfxItemPool * ) const
    4186             : {
    4187       33280 :     return new SvxFrameDirectionItem( *this );
    4188             : }
    4189             : 
    4190           0 : SfxPoolItem* SvxFrameDirectionItem::Create( SvStream & rStrm, sal_uInt16 /*nVer*/ ) const
    4191             : {
    4192             :     sal_uInt16 nValue;
    4193           0 :     rStrm >> nValue;
    4194           0 :     return new SvxFrameDirectionItem( (SvxFrameDirection)nValue, Which() );
    4195             : }
    4196             : 
    4197         186 : SvStream& SvxFrameDirectionItem::Store( SvStream & rStrm, sal_uInt16 /*nIVer*/ ) const
    4198             : {
    4199         186 :     sal_uInt16 nValue = GetValue();
    4200         186 :     rStrm << nValue;
    4201         186 :     return rStrm;
    4202             : }
    4203             : 
    4204        5098 : sal_uInt16 SvxFrameDirectionItem::GetVersion( sal_uInt16 nFVer ) const
    4205             : {
    4206        5098 :     return SOFFICE_FILEFORMAT_50 > nFVer ? USHRT_MAX : 0;
    4207             : }
    4208             : 
    4209           0 : SfxItemPresentation SvxFrameDirectionItem::GetPresentation(
    4210             :     SfxItemPresentation ePres,
    4211             :     SfxMapUnit          /*eCoreUnit*/,
    4212             :     SfxMapUnit          /*ePresUnit*/,
    4213             :     OUString&           rText, const IntlWrapper *) const
    4214             : {
    4215           0 :     SfxItemPresentation eRet = ePres;
    4216           0 :     switch( ePres )
    4217             :     {
    4218             :     case SFX_ITEM_PRESENTATION_NONE:
    4219           0 :         rText = OUString();
    4220           0 :         break;
    4221             : 
    4222             :     case SFX_ITEM_PRESENTATION_NAMELESS:
    4223             :     case SFX_ITEM_PRESENTATION_COMPLETE:
    4224           0 :         rText = EE_RESSTR( RID_SVXITEMS_FRMDIR_BEGIN + GetValue() );
    4225           0 :         break;
    4226             : 
    4227             :     default:
    4228           0 :         eRet = SFX_ITEM_PRESENTATION_NONE;
    4229             :     }
    4230           0 :     return eRet;
    4231             : }
    4232             : 
    4233       11667 : bool SvxFrameDirectionItem::PutValue( const com::sun::star::uno::Any& rVal,
    4234             :                                              sal_uInt8 )
    4235             : {
    4236       11667 :     sal_Int16 nVal = sal_Int16();
    4237       11667 :     sal_Bool bRet = ( rVal >>= nVal );
    4238       11667 :     if( bRet )
    4239             :     {
    4240             :         // translate WritingDirection2 constants into SvxFrameDirection
    4241       11667 :         switch( nVal )
    4242             :         {
    4243             :             case text::WritingMode2::LR_TB:
    4244         852 :                 SetValue( FRMDIR_HORI_LEFT_TOP );
    4245         852 :                 break;
    4246             :             case text::WritingMode2::RL_TB:
    4247          10 :                 SetValue( FRMDIR_HORI_RIGHT_TOP );
    4248          10 :                 break;
    4249             :             case text::WritingMode2::TB_RL:
    4250           5 :                 SetValue( FRMDIR_VERT_TOP_RIGHT );
    4251           5 :                 break;
    4252             :             case text::WritingMode2::TB_LR:
    4253           0 :                 SetValue( FRMDIR_VERT_TOP_LEFT );
    4254           0 :                 break;
    4255             :             case text::WritingMode2::PAGE:
    4256       10648 :                 SetValue( FRMDIR_ENVIRONMENT );
    4257       10648 :                 break;
    4258             :             default:
    4259         152 :                 bRet = false;
    4260         152 :                 break;
    4261             :         }
    4262             :     }
    4263             : 
    4264       11667 :     return bRet;
    4265             : }
    4266             : 
    4267         220 : bool SvxFrameDirectionItem::QueryValue( com::sun::star::uno::Any& rVal,
    4268             :                                             sal_uInt8 ) const
    4269             : {
    4270             :     // translate SvxFrameDirection into WritingDirection2
    4271             :     sal_Int16 nVal;
    4272         220 :     bool bRet = true;
    4273         220 :     switch( GetValue() )
    4274             :     {
    4275             :         case FRMDIR_HORI_LEFT_TOP:
    4276         142 :             nVal = text::WritingMode2::LR_TB;
    4277         142 :             break;
    4278             :         case FRMDIR_HORI_RIGHT_TOP:
    4279           8 :             nVal = text::WritingMode2::RL_TB;
    4280           8 :             break;
    4281             :         case FRMDIR_VERT_TOP_RIGHT:
    4282           4 :             nVal = text::WritingMode2::TB_RL;
    4283           4 :             break;
    4284             :         case FRMDIR_VERT_TOP_LEFT:
    4285           0 :             nVal = text::WritingMode2::TB_LR;
    4286           0 :             break;
    4287             :         case FRMDIR_ENVIRONMENT:
    4288          66 :             nVal = text::WritingMode2::PAGE;
    4289          66 :             break;
    4290             :         default:
    4291             :             OSL_FAIL("Unknown SvxFrameDirection value!");
    4292           0 :             bRet = false;
    4293           0 :             break;
    4294             :     }
    4295             : 
    4296             :     // return value + error state
    4297         220 :     if( bRet )
    4298             :     {
    4299         220 :         rVal <<= nVal;
    4300             :     }
    4301         220 :     return bRet;
    4302         267 : }
    4303             : 
    4304             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10