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