1190118d0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3190118d0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4190118d0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5190118d0SAndrew Rist * distributed with this work for additional information 6190118d0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7190118d0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8190118d0SAndrew Rist * "License"); you may not use this file except in compliance 9190118d0SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13190118d0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14190118d0SAndrew Rist * software distributed under the License is distributed on an 15190118d0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16190118d0SAndrew Rist * KIND, either express or implied. See the License for the 17190118d0SAndrew Rist * specific language governing permissions and limitations 18190118d0SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20190118d0SAndrew Rist *************************************************************/ 21190118d0SAndrew Rist 22190118d0SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_editeng.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #define PROPERTY_NONE 0 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp> 30cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <vcl/svapp.hxx> 33cdf0e10cSrcweir #include <vos/mutex.hxx> 34cdf0e10cSrcweir #include <vcl/graph.hxx> 35cdf0e10cSrcweir #include <svtools/grfmgr.hxx> 36cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 37cdf0e10cSrcweir #include <rtl/uuid.h> 38cdf0e10cSrcweir #include <rtl/memory.h> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <editeng/brshitem.hxx> 41cdf0e10cSrcweir #include <editeng/unoprnms.hxx> 42cdf0e10cSrcweir #include <editeng/numitem.hxx> 43cdf0e10cSrcweir #include <editeng/eeitem.hxx> 44cdf0e10cSrcweir #include <editeng/unotext.hxx> 45cdf0e10cSrcweir #include <editeng/numitem.hxx> 46cdf0e10cSrcweir #include <editeng/unofdesc.hxx> 47cdf0e10cSrcweir #include <editeng/unonrule.hxx> 48cdf0e10cSrcweir #include <editeng/editids.hrc> 49cdf0e10cSrcweir 50cdf0e10cSrcweir using ::rtl::OUString; 51cdf0e10cSrcweir using ::com::sun::star::util::XCloneable; 52cdf0e10cSrcweir using ::com::sun::star::ucb::XAnyCompare; 53cdf0e10cSrcweir 54cdf0e10cSrcweir 55cdf0e10cSrcweir using namespace ::vos; 56cdf0e10cSrcweir using namespace ::std; 57cdf0e10cSrcweir using namespace ::com::sun::star; 58cdf0e10cSrcweir using namespace ::com::sun::star::uno; 59cdf0e10cSrcweir using namespace ::com::sun::star::lang; 60cdf0e10cSrcweir using namespace ::com::sun::star::container; 61cdf0e10cSrcweir 62cdf0e10cSrcweir const SvxAdjust aUnoToSvxAdjust[] = 63cdf0e10cSrcweir { 64cdf0e10cSrcweir SVX_ADJUST_LEFT, 65cdf0e10cSrcweir SVX_ADJUST_RIGHT, 66cdf0e10cSrcweir SVX_ADJUST_CENTER, 67cdf0e10cSrcweir SVX_ADJUST_LEFT, 68cdf0e10cSrcweir SVX_ADJUST_LEFT, 69cdf0e10cSrcweir SVX_ADJUST_LEFT, 70cdf0e10cSrcweir SVX_ADJUST_BLOCK 71cdf0e10cSrcweir }; 72cdf0e10cSrcweir 73cdf0e10cSrcweir const unsigned short aSvxToUnoAdjust[] = 74cdf0e10cSrcweir { 75cdf0e10cSrcweir text::HoriOrientation::LEFT, 76cdf0e10cSrcweir text::HoriOrientation::RIGHT, 77cdf0e10cSrcweir text::HoriOrientation::FULL, 78cdf0e10cSrcweir text::HoriOrientation::CENTER, 79cdf0e10cSrcweir text::HoriOrientation::FULL, 80cdf0e10cSrcweir text::HoriOrientation::LEFT 81cdf0e10cSrcweir }; 82cdf0e10cSrcweir 83cdf0e10cSrcweir SvxAdjust ConvertUnoAdjust( unsigned short nAdjust ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir DBG_ASSERT( nAdjust <= 7, "Enum hat sich geaendert! [CL]" ); 86cdf0e10cSrcweir return aUnoToSvxAdjust[nAdjust]; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir unsigned short ConvertUnoAdjust( SvxAdjust eAdjust ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir DBG_ASSERT( eAdjust <= 6, "Enum hat sich geaendert! [CL]" ); 92cdf0e10cSrcweir return aSvxToUnoAdjust[eAdjust]; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir /****************************************************************** 96cdf0e10cSrcweir * SvxUnoNumberingRules 97cdf0e10cSrcweir ******************************************************************/ 98cdf0e10cSrcweir 99cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SvxUnoNumberingRules ); 100cdf0e10cSrcweir 101cdf0e10cSrcweir SvxUnoNumberingRules::SvxUnoNumberingRules( const SvxNumRule& rRule ) throw() 102cdf0e10cSrcweir : maRule( rRule ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir SvxUnoNumberingRules::~SvxUnoNumberingRules() throw() 107cdf0e10cSrcweir { 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir //XIndexReplace 111cdf0e10cSrcweir void SAL_CALL SvxUnoNumberingRules::replaceByIndex( sal_Int32 Index, const uno::Any& Element ) 112cdf0e10cSrcweir throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir if( Index < 0 || Index >= maRule.GetLevelCount() ) 117cdf0e10cSrcweir throw IndexOutOfBoundsException(); 118cdf0e10cSrcweir 119cdf0e10cSrcweir Sequence< beans::PropertyValue > aSeq; 120cdf0e10cSrcweir 121cdf0e10cSrcweir if( !( Element >>= aSeq) ) 122cdf0e10cSrcweir throw IllegalArgumentException(); 123cdf0e10cSrcweir setNumberingRuleByIndex( aSeq, Index ); 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir // XIndexAccess 127cdf0e10cSrcweir sal_Int32 SAL_CALL SvxUnoNumberingRules::getCount() throw( RuntimeException ) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir return maRule.GetLevelCount(); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir Any SAL_CALL SvxUnoNumberingRules::getByIndex( sal_Int32 Index ) 135cdf0e10cSrcweir throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir if( Index < 0 || Index >= maRule.GetLevelCount() ) 140cdf0e10cSrcweir throw IndexOutOfBoundsException(); 141cdf0e10cSrcweir 142cdf0e10cSrcweir return Any( getNumberingRuleByIndex(Index) ); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir //XElementAccess 146cdf0e10cSrcweir Type SAL_CALL SvxUnoNumberingRules::getElementType() 147cdf0e10cSrcweir throw( RuntimeException ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir return ::getCppuType(( const Sequence< beans::PropertyValue >*)0); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoNumberingRules::hasElements() throw( RuntimeException ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir return sal_True; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir // XAnyCompare 158cdf0e10cSrcweir sal_Int16 SAL_CALL SvxUnoNumberingRules::compare( const Any& rAny1, const Any& rAny2 ) throw(RuntimeException) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir return SvxUnoNumberingRules::Compare( rAny1, rAny2 ); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir // XCloneable 164cdf0e10cSrcweir Reference< XCloneable > SAL_CALL SvxUnoNumberingRules::createClone( ) throw (RuntimeException) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir return new SvxUnoNumberingRules(maRule); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir // XServiceInfo 170cdf0e10cSrcweir sal_Char pSvxUnoNumberingRulesService[sizeof("com.sun.star.text.NumberingRules")] = "com.sun.star.text.NumberingRules"; 171cdf0e10cSrcweir 172cdf0e10cSrcweir OUString SAL_CALL SvxUnoNumberingRules::getImplementationName( ) throw(RuntimeException) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoNumberingRules" ) ); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoNumberingRules::supportsService( const OUString& ServiceName ) throw(RuntimeException) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSvxUnoNumberingRulesService ) ); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir Sequence< OUString > SAL_CALL SvxUnoNumberingRules::getSupportedServiceNames( ) throw(RuntimeException) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoNumberingRulesService ) ); 185cdf0e10cSrcweir Sequence< OUString > aSeq( &aService, 1 ); 186cdf0e10cSrcweir return aSeq; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir Sequence<beans::PropertyValue> SvxUnoNumberingRules::getNumberingRuleByIndex( sal_Int32 nIndex) const throw() 190cdf0e10cSrcweir { 191cdf0e10cSrcweir // NumberingRule aRule; 192cdf0e10cSrcweir const SvxNumberFormat& rFmt = maRule.GetLevel((sal_uInt16) nIndex); 193cdf0e10cSrcweir sal_uInt16 nIdx = 0; 194cdf0e10cSrcweir 195cdf0e10cSrcweir const int nProps = 15; 196cdf0e10cSrcweir beans::PropertyValue* pArray = new beans::PropertyValue[nProps]; 197cdf0e10cSrcweir 198cdf0e10cSrcweir Any aVal; 199cdf0e10cSrcweir { 200cdf0e10cSrcweir aVal <<= rFmt.GetNumberingType(); 201cdf0e10cSrcweir beans::PropertyValue aAlignProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_NUMBERINGTYPE)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 202cdf0e10cSrcweir pArray[nIdx++] = aAlignProp; 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir { 206cdf0e10cSrcweir SvxAdjust eAdj = rFmt.GetNumAdjust(); 207cdf0e10cSrcweir aVal <<= ConvertUnoAdjust(eAdj); 208cdf0e10cSrcweir pArray[nIdx++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_ADJUST)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir { 212cdf0e10cSrcweir aVal <<= OUString(rFmt.GetPrefix()); 213cdf0e10cSrcweir beans::PropertyValue aPrefixProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_PREFIX)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 214cdf0e10cSrcweir pArray[nIdx++] = aPrefixProp; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir { 218cdf0e10cSrcweir aVal <<= OUString(rFmt.GetSuffix()); 219cdf0e10cSrcweir beans::PropertyValue aSuffixProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_SUFFIX)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 220cdf0e10cSrcweir pArray[nIdx++] = aSuffixProp; 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir { 224cdf0e10cSrcweir sal_Unicode nCode = rFmt.GetBulletChar(); 225cdf0e10cSrcweir OUString aStr( &nCode, 1 ); 226cdf0e10cSrcweir aVal <<= aStr; 227cdf0e10cSrcweir beans::PropertyValue aBulletProp( OUString(RTL_CONSTASCII_USTRINGPARAM("BulletChar")), -1, aVal, beans::PropertyState_DIRECT_VALUE); 228cdf0e10cSrcweir pArray[nIdx++] = aBulletProp; 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir if( rFmt.GetBulletFont() ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir awt::FontDescriptor aDesc; 234cdf0e10cSrcweir SvxUnoFontDescriptor::ConvertFromFont( *rFmt.GetBulletFont(), aDesc ); 235cdf0e10cSrcweir aVal.setValue(&aDesc, ::getCppuType((const awt::FontDescriptor*)0)); 236cdf0e10cSrcweir pArray[nIdx++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_FONT)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir { 240cdf0e10cSrcweir const SvxBrushItem* pBrush = rFmt.GetBrush(); 241cdf0e10cSrcweir if(pBrush && pBrush->GetGraphicObject()) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir const GraphicObject* pGrafObj = pBrush->GetGraphicObject(); 244cdf0e10cSrcweir OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); 245cdf0e10cSrcweir aURL += OUString::createFromAscii( pGrafObj->GetUniqueID().GetBuffer() ); 246cdf0e10cSrcweir 247cdf0e10cSrcweir aVal <<= aURL; 248cdf0e10cSrcweir const beans::PropertyValue aGraphicProp( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")), -1, aVal, beans::PropertyState_DIRECT_VALUE); 249cdf0e10cSrcweir pArray[nIdx++] = aGraphicProp; 250cdf0e10cSrcweir } 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir { 254cdf0e10cSrcweir const Size aSize( rFmt.GetGraphicSize() ); 255cdf0e10cSrcweir const awt::Size aUnoSize( aSize.Width(), aSize.Height() ); 256cdf0e10cSrcweir aVal <<= aUnoSize; 257cdf0e10cSrcweir const beans::PropertyValue aGraphicSizeProp(OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicSize")), -1, aVal, beans::PropertyState_DIRECT_VALUE ); 258cdf0e10cSrcweir pArray[nIdx++] = aGraphicSizeProp; 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir aVal <<= (sal_Int16)rFmt.GetStart(); 262cdf0e10cSrcweir pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_START_WITH)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 263cdf0e10cSrcweir 264cdf0e10cSrcweir aVal <<= (sal_Int32)rFmt.GetAbsLSpace(); 265cdf0e10cSrcweir pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 266cdf0e10cSrcweir 267cdf0e10cSrcweir aVal <<= (sal_Int32)rFmt.GetFirstLineOffset(); 268cdf0e10cSrcweir pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 269cdf0e10cSrcweir 270cdf0e10cSrcweir pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolTextDistance")), -1, aVal, beans::PropertyState_DIRECT_VALUE); 271cdf0e10cSrcweir 272cdf0e10cSrcweir aVal <<= (sal_Int32)rFmt.GetBulletColor().GetColor(); 273cdf0e10cSrcweir pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 274cdf0e10cSrcweir 275cdf0e10cSrcweir aVal <<= (sal_Int16)rFmt.GetBulletRelSize(); 276cdf0e10cSrcweir pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE)), -1, aVal, beans::PropertyState_DIRECT_VALUE); 277cdf0e10cSrcweir 278cdf0e10cSrcweir DBG_ASSERT( nIdx <= nProps, "FixMe: Array uebergelaufen!!!! [CL]" ); 279cdf0e10cSrcweir Sequence< beans::PropertyValue> aSeq(pArray, nIdx); 280cdf0e10cSrcweir 281cdf0e10cSrcweir delete [] pArray; 282cdf0e10cSrcweir return aSeq; 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir void SvxUnoNumberingRules::setNumberingRuleByIndex( const Sequence< beans::PropertyValue >& rProperties, sal_Int32 nIndex) 286cdf0e10cSrcweir throw( RuntimeException, IllegalArgumentException ) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir SvxNumberFormat aFmt(maRule.GetLevel( (sal_uInt16)nIndex )); 289cdf0e10cSrcweir const beans::PropertyValue* pPropArray = rProperties.getConstArray(); 290cdf0e10cSrcweir for(int i = 0; i < rProperties.getLength(); i++) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir const beans::PropertyValue& rProp = pPropArray[i]; 293cdf0e10cSrcweir const OUString& rPropName = rProp.Name; 294cdf0e10cSrcweir const Any& aVal = rProp.Value; 295cdf0e10cSrcweir 296cdf0e10cSrcweir if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_NUMBERINGTYPE))) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir sal_Int16 nSet = sal_Int16(); 299cdf0e10cSrcweir aVal >>= nSet; 300cdf0e10cSrcweir 30194a565f3SAndre Fischer // There is no reason to limit numbering types. 30294a565f3SAndre Fischer if ( nSet>=0 ) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir aFmt.SetNumberingType(nSet); 305cdf0e10cSrcweir continue; 306cdf0e10cSrcweir } 307cdf0e10cSrcweir } 308cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_PREFIX))) 309cdf0e10cSrcweir { 310cdf0e10cSrcweir OUString aPrefix; 311cdf0e10cSrcweir if( aVal >>= aPrefix ) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir aFmt.SetPrefix(aPrefix); 314cdf0e10cSrcweir continue; 315cdf0e10cSrcweir } 316cdf0e10cSrcweir } 317cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_SUFFIX))) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir OUString aSuffix; 320cdf0e10cSrcweir if( aVal >>= aSuffix ) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir aFmt.SetSuffix(aSuffix); 323cdf0e10cSrcweir continue; 324cdf0e10cSrcweir } 325cdf0e10cSrcweir } 326cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLETID))) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir sal_Int16 nSet = sal_Int16(); 329cdf0e10cSrcweir if( aVal >>= nSet ) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir if(nSet < 0x100) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir aFmt.SetBulletChar(nSet); 334cdf0e10cSrcweir continue; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir } 337cdf0e10cSrcweir } 338cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("BulletChar"))) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir OUString aStr; 341cdf0e10cSrcweir if( aVal >>= aStr ) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir if(aStr.getLength()) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir aFmt.SetBulletChar(aStr[0]); 346cdf0e10cSrcweir } 347cdf0e10cSrcweir else 348cdf0e10cSrcweir { 349cdf0e10cSrcweir aFmt.SetBulletChar(0); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir continue; 352cdf0e10cSrcweir } 353cdf0e10cSrcweir } 354cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_ADJUST))) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir sal_Int16 nAdjust = sal_Int16(); 357cdf0e10cSrcweir if( aVal >>= nAdjust ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir aFmt.SetNumAdjust(ConvertUnoAdjust( (unsigned short)nAdjust )); 360cdf0e10cSrcweir continue; 361cdf0e10cSrcweir } 362cdf0e10cSrcweir } 363cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_FONT))) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir awt::FontDescriptor aDesc; 366cdf0e10cSrcweir if( aVal >>= aDesc ) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir Font aFont; 369cdf0e10cSrcweir SvxUnoFontDescriptor::ConvertToFont( aDesc, aFont ); 370cdf0e10cSrcweir aFmt.SetBulletFont(&aFont); 371cdf0e10cSrcweir continue; 372cdf0e10cSrcweir } 373cdf0e10cSrcweir } 374cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Graphic"))) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir Reference< awt::XBitmap > xBmp; 377cdf0e10cSrcweir if( aVal >>= xBmp ) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir Graphic aGraf( VCLUnoHelper::GetBitmap( xBmp ) ); 380cdf0e10cSrcweir SvxBrushItem aBrushItem(aGraf, GPOS_AREA, SID_ATTR_BRUSH); 381cdf0e10cSrcweir aFmt.SetGraphicBrush( &aBrushItem ); 382cdf0e10cSrcweir continue; 383cdf0e10cSrcweir } 384cdf0e10cSrcweir } 385cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("GraphicURL"))) 386cdf0e10cSrcweir { 387cdf0e10cSrcweir OUString aURL; 388cdf0e10cSrcweir if( aVal >>= aURL ) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) ); 391cdf0e10cSrcweir SvxBrushItem aBrushItem( aGrafObj, GPOS_AREA, SID_ATTR_BRUSH ); 392cdf0e10cSrcweir aFmt.SetGraphicBrush( &aBrushItem ); 393cdf0e10cSrcweir continue; 394cdf0e10cSrcweir } 395cdf0e10cSrcweir } 396cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("GraphicSize"))) 397cdf0e10cSrcweir { 398cdf0e10cSrcweir awt::Size aUnoSize; 399cdf0e10cSrcweir if( aVal >>= aUnoSize ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir aFmt.SetGraphicSize( Size( aUnoSize.Width, aUnoSize.Height ) ); 402cdf0e10cSrcweir continue; 403cdf0e10cSrcweir } 404cdf0e10cSrcweir } 405cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_START_WITH))) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir sal_Int16 nStart = sal_Int16(); 408cdf0e10cSrcweir if( aVal >>= nStart ) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir aFmt.SetStart( nStart ); 411cdf0e10cSrcweir continue; 412cdf0e10cSrcweir } 413cdf0e10cSrcweir } 414cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN))) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir sal_Int32 nMargin = 0; 417cdf0e10cSrcweir if( aVal >>= nMargin ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir aFmt.SetAbsLSpace((sal_uInt16)nMargin); 420cdf0e10cSrcweir continue; 421cdf0e10cSrcweir } 422cdf0e10cSrcweir } 423cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET))) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir sal_Int32 nMargin = 0; 426cdf0e10cSrcweir if( aVal >>= nMargin ) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir aFmt.SetFirstLineOffset((sal_uInt16)nMargin); 429cdf0e10cSrcweir continue; 430cdf0e10cSrcweir } 431cdf0e10cSrcweir } 432cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SymbolTextDistance"))) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir sal_Int32 nTextDistance = 0; 435cdf0e10cSrcweir if( aVal >>= nTextDistance ) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir aFmt.SetCharTextDistance((sal_uInt16)nTextDistance); 438cdf0e10cSrcweir continue; 439cdf0e10cSrcweir } 440cdf0e10cSrcweir } 441cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR))) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir sal_Int32 nColor = 0; 444cdf0e10cSrcweir if( aVal >>= nColor ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir aFmt.SetBulletColor( (Color) nColor ); 447cdf0e10cSrcweir continue; 448cdf0e10cSrcweir } 449cdf0e10cSrcweir } 450cdf0e10cSrcweir else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE))) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir sal_Int16 nSize = sal_Int16(); 453cdf0e10cSrcweir if( aVal >>= nSize ) 454cdf0e10cSrcweir { 455*6de4612aSArmin Le Grand // [Bug 120650] the slide content corrupt when open in Aoo 456*6de4612aSArmin Le Grand if ((nSize>250)||(nSize<=0)) 457*6de4612aSArmin Le Grand { 458*6de4612aSArmin Le Grand nSize = 100; 459*6de4612aSArmin Le Grand } 460*6de4612aSArmin Le Grand 461cdf0e10cSrcweir aFmt.SetBulletRelSize( (short)nSize ); 462cdf0e10cSrcweir continue; 463cdf0e10cSrcweir } 464cdf0e10cSrcweir } 465cdf0e10cSrcweir else 466cdf0e10cSrcweir { 467cdf0e10cSrcweir continue; 468cdf0e10cSrcweir } 469cdf0e10cSrcweir 470cdf0e10cSrcweir throw IllegalArgumentException(); 471cdf0e10cSrcweir } 472cdf0e10cSrcweir 473cdf0e10cSrcweir // check that we always have a brush item for bitmap numbering 474cdf0e10cSrcweir if( aFmt.GetNumberingType() == SVX_NUM_BITMAP ) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir if( NULL == aFmt.GetBrush() ) 477cdf0e10cSrcweir { 478cdf0e10cSrcweir GraphicObject aGrafObj; 479cdf0e10cSrcweir SvxBrushItem aBrushItem( aGrafObj, GPOS_AREA, SID_ATTR_BRUSH ); 480cdf0e10cSrcweir aFmt.SetGraphicBrush( &aBrushItem ); 481cdf0e10cSrcweir } 482cdf0e10cSrcweir } 483cdf0e10cSrcweir maRule.SetLevel( (sal_uInt16)nIndex, aFmt ); 484cdf0e10cSrcweir } 485cdf0e10cSrcweir 486cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 487cdf0e10cSrcweir 488cdf0e10cSrcweir const SvxNumRule& SvxGetNumRule( Reference< XIndexReplace > xRule ) throw( IllegalArgumentException ) 489cdf0e10cSrcweir { 490cdf0e10cSrcweir SvxUnoNumberingRules* pRule = SvxUnoNumberingRules::getImplementation( xRule ); 491cdf0e10cSrcweir if( pRule == NULL ) 492cdf0e10cSrcweir throw IllegalArgumentException(); 493cdf0e10cSrcweir 494cdf0e10cSrcweir return pRule->getNumRule(); 495cdf0e10cSrcweir } 496cdf0e10cSrcweir 497cdf0e10cSrcweir bool SvxGetNumRule( Reference< XIndexReplace > xRule, SvxNumRule& rNumRule ) 498cdf0e10cSrcweir { 499cdf0e10cSrcweir SvxUnoNumberingRules* pRule = SvxUnoNumberingRules::getImplementation( xRule ); 500cdf0e10cSrcweir if( pRule ) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir rNumRule = pRule->getNumRule(); 503cdf0e10cSrcweir } 504cdf0e10cSrcweir else if( xRule.is() ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir try 507cdf0e10cSrcweir { 508cdf0e10cSrcweir pRule = new SvxUnoNumberingRules( rNumRule ); 509cdf0e10cSrcweir 510cdf0e10cSrcweir Reference< XIndexReplace > xDestRule( pRule ); 511cdf0e10cSrcweir 512cdf0e10cSrcweir const sal_Int32 nCount = min( xRule->getCount(), xDestRule->getCount() ); 513cdf0e10cSrcweir sal_Int32 nLevel; 514cdf0e10cSrcweir for( nLevel = 0; nLevel < nCount; nLevel++ ) 515cdf0e10cSrcweir { 516cdf0e10cSrcweir xDestRule->replaceByIndex( nLevel, xRule->getByIndex( nLevel ) ); 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir rNumRule = pRule->getNumRule(); 520cdf0e10cSrcweir } 521cdf0e10cSrcweir catch( Exception& ) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir return false; 524cdf0e10cSrcweir } 525cdf0e10cSrcweir } 526cdf0e10cSrcweir else 527cdf0e10cSrcweir { 528cdf0e10cSrcweir return false; 529cdf0e10cSrcweir } 530cdf0e10cSrcweir 531cdf0e10cSrcweir return true; 532cdf0e10cSrcweir } 533cdf0e10cSrcweir 534cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 535cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::container::XIndexReplace > SvxCreateNumRule( const SvxNumRule* pRule ) throw() 536cdf0e10cSrcweir { 537cdf0e10cSrcweir DBG_ASSERT( pRule, "No default SvxNumRule!" ); 538cdf0e10cSrcweir if( pRule ) 539cdf0e10cSrcweir { 540cdf0e10cSrcweir return new SvxUnoNumberingRules( *pRule ); 541cdf0e10cSrcweir } 542cdf0e10cSrcweir else 543cdf0e10cSrcweir { 544cdf0e10cSrcweir SvxNumRule aDefaultRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, 10 , sal_False); 545cdf0e10cSrcweir return new SvxUnoNumberingRules( aDefaultRule ); 546cdf0e10cSrcweir } 547cdf0e10cSrcweir } 548cdf0e10cSrcweir 549cdf0e10cSrcweir 550cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 551cdf0e10cSrcweir 552cdf0e10cSrcweir class SvxUnoNumberingRulesCompare : public ::cppu::WeakAggImplHelper1< XAnyCompare > 553cdf0e10cSrcweir { 554cdf0e10cSrcweir public: 555cdf0e10cSrcweir virtual sal_Int16 SAL_CALL compare( const Any& Any1, const Any& Any2 ) throw(RuntimeException); 556cdf0e10cSrcweir }; 557cdf0e10cSrcweir 558cdf0e10cSrcweir sal_Int16 SAL_CALL SvxUnoNumberingRulesCompare::compare( const Any& Any1, const Any& Any2 ) throw(RuntimeException) 559cdf0e10cSrcweir { 560cdf0e10cSrcweir return SvxUnoNumberingRules::Compare( Any1, Any2 ); 561cdf0e10cSrcweir } 562cdf0e10cSrcweir 563cdf0e10cSrcweir sal_Int16 SvxUnoNumberingRules::Compare( const Any& Any1, const Any& Any2 ) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir Reference< XIndexReplace > x1( Any1, UNO_QUERY ), x2( Any2, UNO_QUERY ); 566cdf0e10cSrcweir if( x1.is() && x2.is() ) 567cdf0e10cSrcweir { 568cdf0e10cSrcweir if( x1.get() == x2.get() ) 569cdf0e10cSrcweir return 0; 570cdf0e10cSrcweir 571cdf0e10cSrcweir SvxUnoNumberingRules* pRule1 = SvxUnoNumberingRules::getImplementation( x1 ); 572cdf0e10cSrcweir if( pRule1 ) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir SvxUnoNumberingRules* pRule2 = SvxUnoNumberingRules::getImplementation( x2 ); 575cdf0e10cSrcweir if( pRule2 ) 576cdf0e10cSrcweir { 577cdf0e10cSrcweir const SvxNumRule& rRule1 = pRule1->getNumRule(); 578cdf0e10cSrcweir const SvxNumRule& rRule2 = pRule2->getNumRule(); 579cdf0e10cSrcweir 580cdf0e10cSrcweir const sal_uInt16 nLevelCount1 = rRule1.GetLevelCount(); 581cdf0e10cSrcweir const sal_uInt16 nLevelCount2 = rRule2.GetLevelCount(); 582cdf0e10cSrcweir 583cdf0e10cSrcweir if( nLevelCount1 == 0 || nLevelCount2 == 0 ) 584cdf0e10cSrcweir return -1; 585cdf0e10cSrcweir 586cdf0e10cSrcweir for( sal_uInt16 i = 0; (i < nLevelCount1) && (i < nLevelCount2); i++ ) 587cdf0e10cSrcweir { 588cdf0e10cSrcweir if( rRule1.GetLevel(i) != rRule2.GetLevel(i) ) 589cdf0e10cSrcweir return -1; 590cdf0e10cSrcweir } 591cdf0e10cSrcweir return 0; 592cdf0e10cSrcweir } 593cdf0e10cSrcweir } 594cdf0e10cSrcweir } 595cdf0e10cSrcweir 596cdf0e10cSrcweir return -1; 597cdf0e10cSrcweir } 598cdf0e10cSrcweir 599cdf0e10cSrcweir Reference< XAnyCompare > SvxCreateNumRuleCompare() throw() 600cdf0e10cSrcweir { 601cdf0e10cSrcweir return new SvxUnoNumberingRulesCompare(); 602cdf0e10cSrcweir } 603cdf0e10cSrcweir 604cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace > SvxCreateNumRule() throw() 605cdf0e10cSrcweir { 606cdf0e10cSrcweir SvxNumRule aTempRule( 0, 10, false ); 607cdf0e10cSrcweir return SvxCreateNumRule( &aTempRule ); 608cdf0e10cSrcweir } 609