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