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_sfx2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <sot/object.hxx> 32*cdf0e10cSrcweir #include <tools/stream.hxx> 33*cdf0e10cSrcweir #include <vcl/splitwin.hxx> 34*cdf0e10cSrcweir #include <svl/itemset.hxx> 35*cdf0e10cSrcweir #ifndef GCC 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <sfx2/frmdescr.hxx> 39*cdf0e10cSrcweir #include <sfx2/app.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir DBG_NAME(SfxFrameDescriptor); 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #define VERSION (sal_uInt16) 3 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir struct SfxFrameDescriptor_Impl 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir Wallpaper* pWallpaper; 48*cdf0e10cSrcweir SfxItemSet* pArgs; 49*cdf0e10cSrcweir sal_Bool bEditable; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir SfxFrameDescriptor_Impl() : pWallpaper( NULL ), pArgs( NULL ), bEditable( sal_True ) {} 52*cdf0e10cSrcweir ~SfxFrameDescriptor_Impl() 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir delete pWallpaper; 55*cdf0e10cSrcweir delete pArgs; 56*cdf0e10cSrcweir } 57*cdf0e10cSrcweir }; 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir SfxFrameDescriptor::SfxFrameDescriptor() : 60*cdf0e10cSrcweir aMargin( -1, -1 ), 61*cdf0e10cSrcweir nWidth( 0L ), 62*cdf0e10cSrcweir eScroll( ScrollingAuto ), 63*cdf0e10cSrcweir eSizeSelector( SIZE_ABS ), 64*cdf0e10cSrcweir nHasBorder( BORDER_YES ), 65*cdf0e10cSrcweir nItemId( 0 ), 66*cdf0e10cSrcweir bResizeHorizontal( sal_True ), 67*cdf0e10cSrcweir bResizeVertical( sal_True ), 68*cdf0e10cSrcweir bHasUI( sal_True ), 69*cdf0e10cSrcweir bReadOnly( sal_False ) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir DBG_CTOR(SfxFrameDescriptor, 0); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir pImp = new SfxFrameDescriptor_Impl; 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir SfxFrameDescriptor::~SfxFrameDescriptor() 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir DBG_DTOR(SfxFrameDescriptor, 0); 79*cdf0e10cSrcweir delete pImp; 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir SfxItemSet* SfxFrameDescriptor::GetArgs() 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir if( !pImp->pArgs ) 85*cdf0e10cSrcweir pImp->pArgs = new SfxAllItemSet( SFX_APP()->GetPool() ); 86*cdf0e10cSrcweir return pImp->pArgs; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir void SfxFrameDescriptor::SetURL( const String& rURL ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir aURL = INetURLObject(rURL); 92*cdf0e10cSrcweir SetActualURL( aURL ); 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir void SfxFrameDescriptor::SetURL( const INetURLObject& rURL ) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir aURL = rURL.GetMainURL( INetURLObject::DECODE_TO_IURI ); 98*cdf0e10cSrcweir SetActualURL( aURL ); 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir void SfxFrameDescriptor::SetActualURL( const String& rURL ) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir aActualURL = INetURLObject(rURL); 104*cdf0e10cSrcweir if ( pImp->pArgs ) 105*cdf0e10cSrcweir pImp->pArgs->ClearItem(); 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir void SfxFrameDescriptor::SetActualURL( const INetURLObject& rURL ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir SetActualURL(String(rURL.GetMainURL( INetURLObject::DECODE_TO_IURI ))); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir void SfxFrameDescriptor::SetEditable( sal_Bool bSet ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir pImp->bEditable = bSet; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir sal_Bool SfxFrameDescriptor::IsEditable() const 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir return pImp->bEditable; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir sal_Bool SfxFrameDescriptor::CompareOriginal( SfxFrameDescriptor& rDescr ) const 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir if( aURL != rDescr.aURL ) 126*cdf0e10cSrcweir return sal_False; 127*cdf0e10cSrcweir else 128*cdf0e10cSrcweir return sal_True; 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir sal_Bool SfxFrameDescriptor::CheckContent() const 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir sal_Bool bRet = !( aURL == aActualURL ); 134*cdf0e10cSrcweir return bRet; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir void SfxFrameDescriptor::UnifyContent( sal_Bool bTakeActual ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir if ( bTakeActual ) 140*cdf0e10cSrcweir aURL = aActualURL; 141*cdf0e10cSrcweir else 142*cdf0e10cSrcweir aActualURL = aURL; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir SfxFrameDescriptor* SfxFrameDescriptor::Clone( sal_Bool bWithIds ) const 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir SfxFrameDescriptor *pFrame = new SfxFrameDescriptor; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir pFrame->aURL = aURL; 150*cdf0e10cSrcweir pFrame->aActualURL = aActualURL; 151*cdf0e10cSrcweir pFrame->aName = aName; 152*cdf0e10cSrcweir pFrame->aMargin = aMargin; 153*cdf0e10cSrcweir pFrame->nWidth = nWidth; 154*cdf0e10cSrcweir pFrame->eSizeSelector = eSizeSelector; 155*cdf0e10cSrcweir pFrame->eScroll = eScroll; 156*cdf0e10cSrcweir pFrame->bResizeHorizontal = bResizeHorizontal; 157*cdf0e10cSrcweir pFrame->bResizeVertical = bResizeVertical; 158*cdf0e10cSrcweir pFrame->nHasBorder = nHasBorder; 159*cdf0e10cSrcweir pFrame->bHasUI = bHasUI; 160*cdf0e10cSrcweir pFrame->SetReadOnly( IsReadOnly() ); 161*cdf0e10cSrcweir pFrame->SetEditable( IsEditable() ); 162*cdf0e10cSrcweir if ( pImp->pWallpaper ) 163*cdf0e10cSrcweir pFrame->pImp->pWallpaper = new Wallpaper( *pImp->pWallpaper ); 164*cdf0e10cSrcweir if( pImp->pArgs ) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir // Aktuell ist im Clone von SfxAllItemSets noch ein Bug... 167*cdf0e10cSrcweir pFrame->pImp->pArgs = new SfxAllItemSet( SFX_APP()->GetPool() ); 168*cdf0e10cSrcweir pFrame->pImp->pArgs->Put(*pImp->pArgs); 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir if ( bWithIds ) 172*cdf0e10cSrcweir pFrame->nItemId = nItemId; 173*cdf0e10cSrcweir else 174*cdf0e10cSrcweir pFrame->nItemId = 0; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir return pFrame; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir sal_uInt16 SfxFrameDescriptor::GetWinBits() const 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir sal_uInt16 nBits = 0; 182*cdf0e10cSrcweir if ( eSizeSelector == SIZE_REL ) 183*cdf0e10cSrcweir nBits |= SWIB_RELATIVESIZE; 184*cdf0e10cSrcweir if ( eSizeSelector == SIZE_PERCENT ) 185*cdf0e10cSrcweir nBits |= SWIB_PERCENTSIZE; 186*cdf0e10cSrcweir if ( !IsResizable() ) 187*cdf0e10cSrcweir nBits |= SWIB_FIXED; 188*cdf0e10cSrcweir if ( !nWidth ) 189*cdf0e10cSrcweir nBits |= SWIB_INVISIBLE; 190*cdf0e10cSrcweir return nBits; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir sal_Bool SfxFrameDescriptor::HasFrameBorder() const 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir return (nHasBorder & BORDER_YES) != 0; 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir long SfxFrameDescriptor::GetSize() const 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir return nWidth; 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir void SfxFrameDescriptor::TakeProperties( const SfxFrameProperties& rProp ) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir aURL = aActualURL = INetURLObject(rProp.aURL); 206*cdf0e10cSrcweir aName = rProp.aName; 207*cdf0e10cSrcweir aMargin.Width() = rProp.lMarginWidth; 208*cdf0e10cSrcweir aMargin.Height() = rProp.lMarginHeight; 209*cdf0e10cSrcweir nWidth = rProp.lSize; 210*cdf0e10cSrcweir eScroll = rProp.eScroll; 211*cdf0e10cSrcweir eSizeSelector = rProp.eSizeSelector; 212*cdf0e10cSrcweir nHasBorder = rProp.bHasBorder ? BORDER_YES : BORDER_NO; 213*cdf0e10cSrcweir if ( rProp.bBorderSet ) 214*cdf0e10cSrcweir nHasBorder |= BORDER_SET; 215*cdf0e10cSrcweir bResizeHorizontal = bResizeVertical = rProp.bResizable; 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir void SfxFrameDescriptor::SetWallpaper( const Wallpaper& rWallpaper ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir DELETEZ( pImp->pWallpaper ); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir if ( rWallpaper.GetStyle() != WALLPAPER_NULL ) 223*cdf0e10cSrcweir pImp->pWallpaper = new Wallpaper( rWallpaper ); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir const Wallpaper* SfxFrameDescriptor::GetWallpaper() const 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir return pImp->pWallpaper; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir sal_uInt16 SfxFrameDescriptor::GetItemPos() const 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir return USHRT_MAX; 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir SfxFrameProperties::SfxFrameProperties( const SfxFrameDescriptor *pD ) 238*cdf0e10cSrcweir : aURL( pD->GetURL().GetMainURL( INetURLObject::DECODE_TO_IURI ) ) 239*cdf0e10cSrcweir , aName( pD->GetName() ) 240*cdf0e10cSrcweir , lMarginWidth( pD->GetMargin().Width() ) 241*cdf0e10cSrcweir , lMarginHeight( pD->GetMargin().Height() ) 242*cdf0e10cSrcweir , lSize( pD->GetWidth() ) 243*cdf0e10cSrcweir , lSetSize( SIZE_NOT_SET ) 244*cdf0e10cSrcweir , lFrameSpacing( SPACING_NOT_SET ) 245*cdf0e10cSrcweir , lInheritedFrameSpacing( SPACING_NOT_SET ) 246*cdf0e10cSrcweir , eScroll( pD->GetScrollingMode() ) 247*cdf0e10cSrcweir , eSizeSelector( pD->GetSizeSelector() ) 248*cdf0e10cSrcweir , eSetSizeSelector( SIZE_REL ) 249*cdf0e10cSrcweir , bHasBorder( pD->HasFrameBorder() ) 250*cdf0e10cSrcweir , bBorderSet( pD->IsFrameBorderSet() ) 251*cdf0e10cSrcweir , bResizable( pD->IsResizable() ) 252*cdf0e10cSrcweir , bSetResizable( sal_False ) 253*cdf0e10cSrcweir , bIsRootSet( sal_False ) 254*cdf0e10cSrcweir , bIsInColSet( sal_False ) 255*cdf0e10cSrcweir , bHasBorderInherited( sal_False ) 256*cdf0e10cSrcweir , pFrame( pD->Clone() ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir bBorderSet = sal_True; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir SfxFrameProperties& SfxFrameProperties::operator =( 262*cdf0e10cSrcweir const SfxFrameProperties &rProp ) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir aURL = rProp.aURL; 265*cdf0e10cSrcweir aName = rProp.aName; 266*cdf0e10cSrcweir lMarginWidth = rProp.lMarginWidth; 267*cdf0e10cSrcweir lMarginHeight = rProp.lMarginHeight; 268*cdf0e10cSrcweir lSize = rProp.lSize; 269*cdf0e10cSrcweir lSetSize = rProp.lSetSize; 270*cdf0e10cSrcweir lFrameSpacing = rProp.lFrameSpacing; 271*cdf0e10cSrcweir lInheritedFrameSpacing = rProp.lInheritedFrameSpacing; 272*cdf0e10cSrcweir eScroll = rProp.eScroll; 273*cdf0e10cSrcweir eSizeSelector = rProp.eSizeSelector; 274*cdf0e10cSrcweir eSetSizeSelector = rProp.eSetSizeSelector; 275*cdf0e10cSrcweir bHasBorder = rProp.bHasBorder; 276*cdf0e10cSrcweir bBorderSet = rProp.bBorderSet; 277*cdf0e10cSrcweir bResizable = rProp.bResizable; 278*cdf0e10cSrcweir bSetResizable = rProp.bSetResizable; 279*cdf0e10cSrcweir bIsRootSet = rProp.bIsRootSet; 280*cdf0e10cSrcweir bIsInColSet = rProp.bIsInColSet; 281*cdf0e10cSrcweir bHasBorderInherited = rProp.bHasBorderInherited; 282*cdf0e10cSrcweir pFrame = rProp.pFrame->Clone(); 283*cdf0e10cSrcweir return *this; 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir int SfxFrameProperties::operator ==( const SfxFrameProperties& rProp ) const 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir return aURL == rProp.aURL && aName == rProp.aName && lMarginWidth == rProp.lMarginWidth && lMarginHeight == rProp.lMarginHeight && 289*cdf0e10cSrcweir lSize == rProp.lSize && eScroll == rProp.eScroll && eSizeSelector == rProp.eSizeSelector && 290*cdf0e10cSrcweir lSetSize == rProp.lSetSize && lFrameSpacing == rProp.lFrameSpacing && eSetSizeSelector == rProp.eSetSizeSelector && 291*cdf0e10cSrcweir bHasBorder == rProp.bHasBorder && bBorderSet == rProp.bBorderSet && 292*cdf0e10cSrcweir bResizable == rProp.bResizable && bSetResizable == rProp.bSetResizable; 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir TYPEINIT1(SfxFrameDescriptorItem, SfxPoolItem); 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir SfxFrameDescriptorItem::~SfxFrameDescriptorItem() 298*cdf0e10cSrcweir {} 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir int SfxFrameDescriptorItem::operator==( const SfxPoolItem& rAttr ) const 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir return aProperties == ((SfxFrameDescriptorItem&)rAttr).aProperties; 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir // ----------------------------------------------------------------------- 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir SfxPoolItem* SfxFrameDescriptorItem::Clone( SfxItemPool* ) const 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir return new SfxFrameDescriptorItem( *this ); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir //------------------------------------------------------------------------ 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir SfxItemPresentation SfxFrameDescriptorItem::GetPresentation 317*cdf0e10cSrcweir ( 318*cdf0e10cSrcweir SfxItemPresentation /*ePres*/, 319*cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/, 320*cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/, 321*cdf0e10cSrcweir XubString& rText, 322*cdf0e10cSrcweir const IntlWrapper * 323*cdf0e10cSrcweir ) const 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir rText.Erase(); 326*cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE; 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir 330