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

Generated by: LCOV version 1.10