1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <editeng/itemtype.hxx> 33*cdf0e10cSrcweir #include <unosett.hxx> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include "swtypes.hxx" 36*cdf0e10cSrcweir #include "cmdid.h" 37*cdf0e10cSrcweir #include "uiitems.hxx" 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include "utlui.hrc" 40*cdf0e10cSrcweir #include "attrdesc.hrc" 41*cdf0e10cSrcweir #ifndef _UNOMID_H 42*cdf0e10cSrcweir #include <unomid.h> 43*cdf0e10cSrcweir #endif 44*cdf0e10cSrcweir #include <numrule.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir using namespace ::com::sun::star; 47*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir // Breitenangaben der Fussnotenlinien, mit TabPage abstimmen 50*cdf0e10cSrcweir static const sal_uInt16 __FAR_DATA nFtnLines[] = { 51*cdf0e10cSrcweir 0, 52*cdf0e10cSrcweir 10, 53*cdf0e10cSrcweir 50, 54*cdf0e10cSrcweir 80, 55*cdf0e10cSrcweir 100, 56*cdf0e10cSrcweir 150 57*cdf0e10cSrcweir }; 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir #define FTN_LINE_STYLE_COUNT 5 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir SwPageFtnInfoItem::SwPageFtnInfoItem( const sal_uInt16 nId, SwPageFtnInfo& rInfo) : 63*cdf0e10cSrcweir SfxPoolItem( nId ), 64*cdf0e10cSrcweir aFtnInfo(rInfo) 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir SwPageFtnInfoItem::SwPageFtnInfoItem( const SwPageFtnInfoItem& rItem ) : 70*cdf0e10cSrcweir SfxPoolItem( rItem ), 71*cdf0e10cSrcweir aFtnInfo(rItem.GetPageFtnInfo()) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir SwPageFtnInfoItem::~SwPageFtnInfoItem() 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir SfxPoolItem* SwPageFtnInfoItem::Clone( SfxItemPool * /*pPool*/ ) const 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir return new SwPageFtnInfoItem( *this ); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir int SwPageFtnInfoItem::operator==( const SfxPoolItem& rAttr ) const 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir DBG_ASSERT( Which() == rAttr.Which(), "keine gleichen Attribute" ); 90*cdf0e10cSrcweir return ( aFtnInfo == ((SwPageFtnInfoItem&)rAttr).GetPageFtnInfo()); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir SfxItemPresentation SwPageFtnInfoItem::GetPresentation 95*cdf0e10cSrcweir ( 96*cdf0e10cSrcweir SfxItemPresentation ePres, 97*cdf0e10cSrcweir SfxMapUnit eCoreUnit, 98*cdf0e10cSrcweir SfxMapUnit ePresUnit, 99*cdf0e10cSrcweir String& rText, 100*cdf0e10cSrcweir const IntlWrapper* pIntl 101*cdf0e10cSrcweir ) const 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir switch ( ePres ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE: 106*cdf0e10cSrcweir rText.Erase(); 107*cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE; 108*cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS: 109*cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE: 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir sal_uInt16 nHght = (sal_uInt16) GetPageFtnInfo().GetHeight(); 112*cdf0e10cSrcweir if ( nHght ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir rText = SW_RESSTR( STR_MAX_FTN_HEIGHT ); 115*cdf0e10cSrcweir rText += ' '; 116*cdf0e10cSrcweir rText += ::GetMetricText( nHght, eCoreUnit, ePresUnit, pIntl ); 117*cdf0e10cSrcweir rText += ::GetSvxString( ::GetMetricId( ePresUnit ) ); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir return ePres; 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir default:; //prevent warning 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir /* -----------------------------26.04.01 12:25-------------------------------- 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 128*cdf0e10cSrcweir sal_Bool SwPageFtnInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir sal_Bool bRet = sal_True; 131*cdf0e10cSrcweir switch(nMemberId & ~CONVERT_TWIPS) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir case MID_FTN_HEIGHT : rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetHeight());break; 134*cdf0e10cSrcweir case MID_LINE_WEIGHT : rVal <<= (sal_Int16)TWIP_TO_MM100_UNSIGNED(aFtnInfo.GetLineWidth());break; 135*cdf0e10cSrcweir case MID_LINE_COLOR : rVal <<= (sal_Int32)aFtnInfo.GetLineColor().GetColor();break; 136*cdf0e10cSrcweir case MID_LINE_RELWIDTH : 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir Fraction aTmp( 100, 1 ); 139*cdf0e10cSrcweir aTmp *= aFtnInfo.GetWidth(); 140*cdf0e10cSrcweir rVal <<= (sal_Int8)(long)aTmp; 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir break; 143*cdf0e10cSrcweir case MID_LINE_ADJUST : rVal <<= (sal_Int16)aFtnInfo.GetAdj();break;//text::HorizontalAdjust 144*cdf0e10cSrcweir case MID_LINE_TEXT_DIST : rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetTopDist());break; 145*cdf0e10cSrcweir case MID_LINE_FOOTNOTE_DIST: rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetBottomDist());break; 146*cdf0e10cSrcweir default: 147*cdf0e10cSrcweir bRet = sal_False; 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir return bRet; 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir /* -----------------------------26.04.01 12:26-------------------------------- 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 154*cdf0e10cSrcweir sal_Bool SwPageFtnInfoItem::PutValue(const Any& rVal, sal_uInt8 nMemberId) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir sal_Int32 nSet32 = 0; 157*cdf0e10cSrcweir sal_Bool bRet = sal_True; 158*cdf0e10cSrcweir switch(nMemberId & ~CONVERT_TWIPS) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir case MID_LINE_COLOR : 161*cdf0e10cSrcweir rVal >>= nSet32; 162*cdf0e10cSrcweir aFtnInfo.SetLineColor(nSet32); 163*cdf0e10cSrcweir break; 164*cdf0e10cSrcweir case MID_FTN_HEIGHT: 165*cdf0e10cSrcweir case MID_LINE_TEXT_DIST : 166*cdf0e10cSrcweir case MID_LINE_FOOTNOTE_DIST: 167*cdf0e10cSrcweir rVal >>= nSet32; 168*cdf0e10cSrcweir if(nSet32 < 0) 169*cdf0e10cSrcweir bRet = sal_False; 170*cdf0e10cSrcweir else 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir nSet32 = MM100_TO_TWIP(nSet32); 173*cdf0e10cSrcweir switch(nMemberId & ~CONVERT_TWIPS) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir case MID_FTN_HEIGHT: aFtnInfo.SetHeight(nSet32); break; 176*cdf0e10cSrcweir case MID_LINE_TEXT_DIST: aFtnInfo.SetTopDist(nSet32);break; 177*cdf0e10cSrcweir case MID_LINE_FOOTNOTE_DIST: aFtnInfo.SetBottomDist(nSet32);break; 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir break; 181*cdf0e10cSrcweir case MID_LINE_WEIGHT : 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir sal_Int16 nSet = 0; 184*cdf0e10cSrcweir rVal >>= nSet; 185*cdf0e10cSrcweir if(nSet >= 0) 186*cdf0e10cSrcweir aFtnInfo.SetLineWidth(MM100_TO_TWIP(nSet)); 187*cdf0e10cSrcweir else 188*cdf0e10cSrcweir bRet = sal_False; 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir break; 191*cdf0e10cSrcweir case MID_LINE_RELWIDTH : 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir sal_Int8 nSet = 0; 194*cdf0e10cSrcweir rVal >>= nSet; 195*cdf0e10cSrcweir if(nSet < 0) 196*cdf0e10cSrcweir bRet = sal_False; 197*cdf0e10cSrcweir else 198*cdf0e10cSrcweir aFtnInfo.SetWidth(Fraction(nSet, 100)); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir break; 201*cdf0e10cSrcweir case MID_LINE_ADJUST : 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir sal_Int16 nSet = 0; 204*cdf0e10cSrcweir rVal >>= nSet; 205*cdf0e10cSrcweir if(nSet >= 0 && nSet < 3) //text::HorizontalAdjust 206*cdf0e10cSrcweir aFtnInfo.SetAdj((SwFtnAdj)nSet); 207*cdf0e10cSrcweir else 208*cdf0e10cSrcweir bRet = sal_False; 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir break; 211*cdf0e10cSrcweir default: 212*cdf0e10cSrcweir bRet = sal_False; 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir return bRet; 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir SwPtrItem::SwPtrItem( const sal_uInt16 nId, void* pPtr ) : 218*cdf0e10cSrcweir SfxPoolItem( nId ), 219*cdf0e10cSrcweir pMisc(pPtr) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir /*-------------------------------------------------------------------- 224*cdf0e10cSrcweir Beschreibung: Copy-Konstruktor 225*cdf0e10cSrcweir --------------------------------------------------------------------*/ 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir SwPtrItem::SwPtrItem( const SwPtrItem& rItem ) : SfxPoolItem( rItem ) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir pMisc = rItem.pMisc; 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir /*-------------------------------------------------------------------- 234*cdf0e10cSrcweir Beschreibung: Clonen 235*cdf0e10cSrcweir --------------------------------------------------------------------*/ 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir SfxPoolItem* SwPtrItem::Clone( SfxItemPool * /*pPool*/ ) const 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir return new SwPtrItem( *this ); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir /*-------------------------------------------------------------------- 244*cdf0e10cSrcweir Beschreibung: 245*cdf0e10cSrcweir --------------------------------------------------------------------*/ 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir int SwPtrItem::operator==( const SfxPoolItem& rAttr ) const 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); 251*cdf0e10cSrcweir const SwPtrItem& rItem = (SwPtrItem&)rAttr; 252*cdf0e10cSrcweir return ( pMisc == rItem.pMisc ); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir /*-----------------12.11.97 12:55------------------------------- 257*cdf0e10cSrcweir SwUINumRuleItem fuer die NumTabPages der FormatNumRule/Stylisten 258*cdf0e10cSrcweir ---------------------------------------------------------------*/ 259*cdf0e10cSrcweir SwUINumRuleItem::SwUINumRuleItem( const SwNumRule& rRul, const sal_uInt16 nId ) 260*cdf0e10cSrcweir : SfxPoolItem( nId ), pRule( new SwNumRule( rRul ) ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem& rItem ) 265*cdf0e10cSrcweir : SfxPoolItem( rItem ), 266*cdf0e10cSrcweir pRule( new SwNumRule( *rItem.pRule )) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir SwUINumRuleItem::~SwUINumRuleItem() 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir delete pRule; 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir SfxPoolItem* SwUINumRuleItem::Clone( SfxItemPool * /*pPool*/ ) const 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir return new SwUINumRuleItem( *this ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir int SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); 284*cdf0e10cSrcweir return *pRule == *((SwUINumRuleItem&)rAttr).pRule; 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir sal_Bool SwUINumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir uno::Reference< container::XIndexReplace >xRules = new SwXNumberingRules(*pRule); 290*cdf0e10cSrcweir rVal.setValue(&xRules, ::getCppuType((uno::Reference< container::XIndexReplace>*)0)); 291*cdf0e10cSrcweir return sal_True; 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir sal_Bool SwUINumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir uno::Reference< container::XIndexReplace> xRulesRef; 296*cdf0e10cSrcweir if(rVal >>= xRulesRef) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir uno::Reference< lang::XUnoTunnel > xTunnel(xRulesRef, uno::UNO_QUERY); 299*cdf0e10cSrcweir SwXNumberingRules* pSwXRules = xTunnel.is() ? reinterpret_cast<SwXNumberingRules*>( 300*cdf0e10cSrcweir xTunnel->getSomething(SwXNumberingRules::getUnoTunnelId())) : 0; 301*cdf0e10cSrcweir if(pSwXRules) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir *pRule = *pSwXRules->GetNumRule(); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir return sal_True; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir /* -----------------17.06.98 17:43------------------- 309*cdf0e10cSrcweir * 310*cdf0e10cSrcweir * --------------------------------------------------*/ 311*cdf0e10cSrcweir SwBackgroundDestinationItem::SwBackgroundDestinationItem(sal_uInt16 _nWhich, sal_uInt16 nValue) : 312*cdf0e10cSrcweir SfxUInt16Item(_nWhich, nValue) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir /* -----------------17.06.98 17:44------------------- 316*cdf0e10cSrcweir * 317*cdf0e10cSrcweir * --------------------------------------------------*/ 318*cdf0e10cSrcweir SfxPoolItem* SwBackgroundDestinationItem::Clone( SfxItemPool * /*pPool*/ ) const 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir return new SwBackgroundDestinationItem(Which(), GetValue()); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir 325