1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: backgrnd.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
38 // include ---------------------------------------------------------------
39 #include <svtools/pathoptions.hxx>
40 #include <svtools/intitem.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <tools/urlobj.hxx>
43 #include <sfx2/objsh.hxx>
44 #include <sfx2/docfile.hxx>
45 #include <svtools/wallitem.hxx>
46 #include <svtools/cntwall.hxx>
48 #include <sfx2/cntids.hrc>
51 #define _SVX_BACKGRND_CXX
53 #include <svx/dialogs.hrc>
54 #include "backgrnd.hrc"
55 #include <svx/svxitems.hrc>
60 // Tabellenhintergrund
61 #define TBL_DEST_CELL 0
62 #define TBL_DEST_ROW 1
63 #define TBL_DEST_TBL 2
65 #include <svx/brshitem.hxx>
66 #include "backgrnd.hxx"
68 #include <svx/xtable.hxx>
69 #include "opengrf.hxx"
72 #include "drawitem.hxx"
73 #include <svx/dialmgr.hxx>
74 #include "htmlmode.hxx"
75 #ifndef _SVT_CONTROLDIMS_HRC_
76 #include <svtools/controldims.hrc>
78 #include <svx/svxids.hrc> //CHINA001
79 #include "flagsdef.hxx" //CHINA001
80 #include <svtools/intitem.hxx> //CHINA001
81 #include <sfx2/request.hxx> //CHINA001
82 using namespace ::com::sun::star
;
83 // static ----------------------------------------------------------------
85 static USHORT pRanges
[] =
87 SID_VIEW_FLD_PIC
, SID_VIEW_FLD_PIC
,
88 SID_ATTR_BRUSH
, SID_ATTR_BRUSH
,
89 SID_ATTR_BRUSH_CHAR
, SID_ATTR_BRUSH_CHAR
,
93 struct SvxBackgroundTable_Impl
95 SvxBrushItem
* pCellBrush
;
96 SvxBrushItem
* pRowBrush
;
97 SvxBrushItem
* pTableBrush
;
103 SvxBackgroundTable_Impl() :
104 pCellBrush(NULL
), pRowBrush(NULL
), pTableBrush(NULL
),
105 nCellWhich(0), nRowWhich(0), nTableWhich(0) {}
108 struct SvxBackgroundPara_Impl
110 SvxBrushItem
* pParaBrush
;
111 SvxBrushItem
* pCharBrush
;
115 SvxBackgroundPara_Impl() :
116 pParaBrush(NULL
), pCharBrush(NULL
) {}
119 struct SvxBackgroundPage_Impl
122 BOOL bIsImportDlgInExecute
;
124 SvxBackgroundPage_Impl() :
125 pLoadTimer(NULL
), bIsImportDlgInExecute(FALSE
) {}
127 /* -----------------------------15.08.2002 12:21------------------------------
129 ---------------------------------------------------------------------------*/
130 inline BYTE
lcl_PercentToTransparency(long nPercent
)
132 //0xff must not be returned!
133 return BYTE(nPercent
? (50 + 0xfe * nPercent
) / 100 : 0);
135 inline BYTE
lcl_TransparencyToPercent(BYTE nTrans
)
137 return (nTrans
* 100 + 127) / 254;
139 void lcl_SetTransparency(SvxBrushItem
& rBrush
, long nTransparency
)
141 uno::Any aTransparency
;
142 aTransparency
<<= (sal_Int8
)nTransparency
;
143 rBrush
.PutValue(aTransparency
, MID_GRAPHIC_TRANSPARENCY
);
145 //-------------------------------------------------------------------------
151 USHORT
GetItemId_Impl( ValueSet
& rValueSet
, const Color
& rCol
)
154 USHORT nCount
= rValueSet
.GetItemCount();
157 while ( !bFound
&& n
<= nCount
)
159 Color aValCol
= rValueSet
.GetItemColor(n
);
161 bFound
= ( aValCol
.GetRed() == rCol
.GetRed()
162 && aValCol
.GetGreen() == rCol
.GetGreen()
163 && aValCol
.GetBlue() == rCol
.GetBlue() );
168 return bFound
? n
: 0;
171 // class BackgroundPreview -----------------------------------------------
175 Vorschaufenster f"ur Brush oder Bitmap
178 class BackgroundPreviewImpl
: public Window
181 BackgroundPreviewImpl( Window
* pParent
,
182 const ResId
& rResId
, BOOL bIsBmpPreview
);
183 ~BackgroundPreviewImpl();
185 void NotifyChange( const Color
& rColor
);
186 void NotifyChange( const Bitmap
* pBitmap
);
189 virtual void Paint( const Rectangle
& rRect
);
190 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
201 //-----------------------------------------------------------------------
203 BackgroundPreviewImpl::BackgroundPreviewImpl
214 Window( pParent
, rResId
),
216 bIsBmp ( bIsBmpPreview
),
218 aDrawRect( Point(0,0), GetOutputSizePixel() ),
222 SetBorderStyle(WINDOW_BORDER_MONO
);
226 //-----------------------------------------------------------------------
228 BackgroundPreviewImpl::~BackgroundPreviewImpl()
238 //-----------------------------------------------------------------------
239 void BackgroundPreviewImpl::NotifyChange( const Color
& rColor
)
243 const static Color
aTranspCol( COL_TRANSPARENT
);
245 nTransparency
= lcl_TransparencyToPercent( rColor
.GetTransparency() );
247 SetFillColor( rColor
== aTranspCol
? GetSettings().GetStyleSettings().GetFieldColor() : (Color
) rColor
.GetRGBColor() );
252 //-----------------------------------------------------------------------
254 void BackgroundPreviewImpl::NotifyChange( const Bitmap
* pNewBitmap
)
260 if ( bIsBmp
&& (pNewBitmap
|| pBitmap
) )
262 if ( pNewBitmap
&& pBitmap
)
263 *pBitmap
= *pNewBitmap
;
264 else if ( pNewBitmap
&& !pBitmap
)
265 pBitmap
= new Bitmap( *pNewBitmap
);
266 else if ( !pNewBitmap
)
271 Size aSize
= GetOutputSizePixel();
272 // InnerSize == Size without one pixel border
273 Size aInnerSize
= aSize
;
274 aInnerSize
.Width() -= 2;
275 aInnerSize
.Height() -= 2;
276 aDrawSize
= pBitmap
->GetSizePixel();
278 // bitmap bigger than preview window?
279 if ( aDrawSize
.Width() > aInnerSize
.Width() )
281 aDrawSize
.Height() = aDrawSize
.Height() * aInnerSize
.Width() / aDrawSize
.Width();
282 if ( aDrawSize
.Height() > aInnerSize
.Height() )
284 aDrawSize
.Width() = aDrawSize
.Height();
285 aDrawSize
.Height() = aInnerSize
.Height();
288 aDrawSize
.Width() = aInnerSize
.Width();
290 else if ( aDrawSize
.Height() > aInnerSize
.Height() )
292 aDrawSize
.Width() = aDrawSize
.Width() * aInnerSize
.Height() / aDrawSize
.Height();
293 if ( aDrawSize
.Width() > aInnerSize
.Width() )
295 aDrawSize
.Height() = aDrawSize
.Width();
296 aDrawSize
.Width() = aInnerSize
.Width();
299 aDrawSize
.Height() = aInnerSize
.Height();
302 aDrawPos
.X() = (aSize
.Width() - aDrawSize
.Width()) / 2;
303 aDrawPos
.Y() = (aSize
.Height() - aDrawSize
.Height()) / 2;
305 Invalidate( aDrawRect
);
310 //-----------------------------------------------------------------------
312 void BackgroundPreviewImpl::Paint( const Rectangle
& )
314 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
315 SetBackground(Wallpaper(rStyleSettings
.GetWindowColor()));
318 SetFillColor( Color(COL_TRANSPARENT
) );
319 DrawRect( aDrawRect
);
323 DrawBitmap( aDrawPos
, aDrawSize
, *pBitmap
);
326 Size aSize
= GetOutputSizePixel();
327 DrawLine( Point(0,0), Point(aSize
.Width(),aSize
.Height()) );
328 DrawLine( Point(0,aSize
.Height()), Point(aSize
.Width(),0) );
332 /* -----------------------------27.02.2002 11:07------------------------------
334 ---------------------------------------------------------------------------*/
335 void BackgroundPreviewImpl::DataChanged( const DataChangedEvent
& rDCEvt
)
337 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
338 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
342 Window::DataChanged( rDCEvt
);
345 // class SvxBackgroundTabPage --------------------------------------------
347 #define HDL(hdl) LINK(this,SvxBackgroundTabPage,hdl)
349 SvxBackgroundTabPage::SvxBackgroundTabPage( Window
* pParent
,
350 const SfxItemSet
& rCoreSet
) :
356 SvxTabPage( pParent
, SVX_RES( RID_SVXPAGE_BACKGROUND
), rCoreSet
),
358 aBorderWin ( this, SVX_RES(CT_BORDER
) ),
359 aBackgroundColorSet ( &aBorderWin
, SVX_RES( SET_BGDCOLOR
) ),
360 aBackgroundColorBox ( this, SVX_RES( GB_BGDCOLOR
) ),
361 pPreviewWin1 ( new BackgroundPreviewImpl(
362 this, SVX_RES( WIN_PREVIEW1
), FALSE
) ),
363 aColTransFT ( this, SVX_RES( FT_COL_TRANS
) ),
364 aColTransMF ( this, SVX_RES( MF_COL_TRANS
) ),
365 aBtnBrowse ( this, SVX_RES( BTN_BROWSE
) ),
366 aBtnLink ( this, SVX_RES( BTN_LINK
) ),
367 aBtnPreview ( this, SVX_RES( BTN_PREVIEW
) ),
368 aFtFile ( this, SVX_RES( FT_FILE
) ),
369 aGbFile ( this, SVX_RES( GB_FILE
) ),
370 aBtnPosition ( this, SVX_RES( BTN_POSITION
) ),
371 aBtnArea ( this, SVX_RES( BTN_AREA
) ),
372 aBtnTile ( this, SVX_RES( BTN_TILE
) ),
373 aWndPosition ( this, SVX_RES( WND_POSITION
), RP_MM
),
374 aGbPosition ( this, SVX_RES( GB_POSITION
) ),
375 aGraphTransFL ( this, SVX_RES( FL_GRAPH_TRANS
) ),
376 aGraphTransMF ( this, SVX_RES( MF_GRAPH_TRANS
) ),
377 pPreviewWin2 ( new BackgroundPreviewImpl(
378 this, SVX_RES( WIN_PREVIEW2
), TRUE
) ),
379 aSelectTxt ( this, SVX_RES( FT_SELECTOR
) ),
380 aLbSelect ( this, SVX_RES( LB_SELECTOR
) ),
381 aStrBrowse ( SVX_RES( STR_BROWSE
) ),
382 aStrUnlinked ( SVX_RES( STR_UNLINKED
) ),
383 aTblDesc ( this, SVX_RES( FT_TBL_DESC
) ),
384 aTblLBox ( this, SVX_RES( LB_TBL_BOX
) ),
385 aParaLBox ( this, SVX_RES( LB_PARA_BOX
) ),
387 bAllowShowSelector ( TRUE
),
388 bIsGraphicValid ( FALSE
),
391 bColTransparency ( FALSE
),
392 bGraphTransparency ( FALSE
),
394 pPageImpl ( new SvxBackgroundPage_Impl
),
396 pTableBck_Impl ( NULL
),
397 pParaBck_Impl ( NULL
)
400 // diese Page braucht ExchangeSupport
401 SetExchangeSupport();
403 const SfxPoolItem
* pItem
;
404 SfxObjectShell
* pShell
;
406 if ( SFX_ITEM_SET
== rCoreSet
.GetItemState( SID_HTML_MODE
, FALSE
, &pItem
)
407 || ( 0 != ( pShell
= SfxObjectShell::Current()) &&
408 0 != ( pItem
= pShell
->GetItem( SID_HTML_MODE
) ) ) )
410 nHtmlMode
= ((SfxUInt16Item
*)pItem
)->GetValue();
413 FillColorValueSets_Impl();
415 aBackgroundColorSet
.SetSelectHdl( HDL(BackgroundColorHdl_Impl
) );
419 //------------------------------------------------------------------------
421 SvxBackgroundTabPage::~SvxBackgroundTabPage()
430 delete pPageImpl
->pLoadTimer
;
436 delete pTableBck_Impl
->pCellBrush
;
437 delete pTableBck_Impl
->pRowBrush
;
438 delete pTableBck_Impl
->pTableBrush
;
439 delete pTableBck_Impl
;
444 delete pParaBck_Impl
->pParaBrush
;
445 delete pParaBck_Impl
->pCharBrush
;
446 delete pParaBck_Impl
;
450 //------------------------------------------------------------------------
452 USHORT
* SvxBackgroundTabPage::GetRanges()
456 gibt den Bereich der Which-Werte zur"uck
463 //------------------------------------------------------------------------
465 SfxTabPage
* SvxBackgroundTabPage::Create( Window
* pParent
,
466 const SfxItemSet
& rAttrSet
)
470 Create-Methode f"ur den TabDialog
474 return ( new SvxBackgroundTabPage( pParent
, rAttrSet
) );
477 //------------------------------------------------------------------------
479 void SvxBackgroundTabPage::Reset( const SfxItemSet
& rSet
)
486 // os: So ein Unsinn! Irgendwo laesst sich so ein Item immer finden,
487 // es muss aber im rSet vorhanden sein!
488 // const SfxPoolItem* pX = GetOldItem( rSet, SID_VIEW_FLD_PIC );
489 // if( pX && pX->ISA(SfxWallpaperItem))
490 if(SFX_ITEM_AVAILABLE
<= rSet
.GetItemState(GetWhich(SID_VIEW_FLD_PIC
), FALSE
))
492 ResetFromWallpaperItem( rSet
);
496 // Zustand des Vorschau-Buttons durch UserData persistent
497 String aUserData
= GetUserData();
498 aBtnPreview
.Check( aUserData
.Len() && sal_Unicode('1') == aUserData
.GetChar( 0 ) );
500 // nach Reset kein ShowSelector() mehr aufrufen d"urfen
501 bAllowShowSelector
= FALSE
;
504 // Input-BrushItem besorgen und auswerten
505 const SvxBrushItem
* pBgdAttr
= NULL
;
506 USHORT nSlot
= SID_ATTR_BRUSH
;
507 const SfxPoolItem
* pItem
;
508 USHORT nDestValue
= USHRT_MAX
;
510 if ( SFX_ITEM_SET
== rSet
.GetItemState( SID_BACKGRND_DESTINATION
,
513 nDestValue
= ((const SfxUInt16Item
*)pItem
)->GetValue();
514 aTblLBox
.SelectEntryPos(nDestValue
);
516 switch ( nDestValue
)
519 nSlot
= SID_ATTR_BRUSH
;
522 nSlot
= SID_ATTR_BRUSH_ROW
;
525 nSlot
= SID_ATTR_BRUSH_TABLE
;
529 else if( SFX_ITEM_SET
== rSet
.GetItemState(
530 SID_PARA_BACKGRND_DESTINATION
, FALSE
, &pItem
) )
532 nDestValue
= ((const SfxUInt16Item
*)pItem
)->GetValue();
533 // ist gerade Zeichen aktiviert?
534 USHORT nParaSel
= aParaLBox
.GetSelectEntryPos();
537 // dann war das ein "Standard" - Aufruf
538 nDestValue
= nParaSel
;
540 aParaLBox
.SelectEntryPos(nDestValue
);
542 switch ( nDestValue
)
545 nSlot
= SID_ATTR_BRUSH
;
548 nSlot
= SID_ATTR_BRUSH_CHAR
;
552 //#111173# the destination item is missing when the parent style has been changed
553 if(USHRT_MAX
== nDestValue
&& (aParaLBox
.IsVisible()||aTblLBox
.IsVisible()))
555 USHORT nWhich
= GetWhich( nSlot
);
557 if ( rSet
.GetItemState( nWhich
, FALSE
) >= SFX_ITEM_AVAILABLE
)
558 pBgdAttr
= (const SvxBrushItem
*)&( rSet
.Get( nWhich
) );
564 FillControls_Impl(*pBgdAttr
, aUserData
);
565 aBgdColor
= ( (SvxBrushItem
*)pBgdAttr
)->GetColor();
571 aLbSelect
.SelectEntryPos( 0 );
574 const SfxPoolItem
* pOld
= GetOldItem( rSet
, SID_ATTR_BRUSH
);
577 aBgdColor
= ( (SvxBrushItem
*)pOld
)->GetColor();
580 if ( nDestValue
!= USHRT_MAX
)
582 if(aTblLBox
.IsVisible())
584 USHORT nValue
= aTblLBox
.GetSelectEntryPos();
586 if ( pTableBck_Impl
)
588 DELETEZ( pTableBck_Impl
->pCellBrush
);
589 DELETEZ( pTableBck_Impl
->pRowBrush
);
590 DELETEZ( pTableBck_Impl
->pTableBrush
);
593 pTableBck_Impl
= new SvxBackgroundTable_Impl();
595 pTableBck_Impl
->nActPos
= nValue
;
597 nWhich
= GetWhich( SID_ATTR_BRUSH
);
598 if ( rSet
.GetItemState( nWhich
, FALSE
) >= SFX_ITEM_AVAILABLE
)
600 pBgdAttr
= (const SvxBrushItem
*)&( rSet
.Get( nWhich
) );
601 pTableBck_Impl
->pCellBrush
= new SvxBrushItem(*pBgdAttr
);
603 pTableBck_Impl
->nCellWhich
= nWhich
;
605 if ( rSet
.GetItemState( SID_ATTR_BRUSH_ROW
, FALSE
) >= SFX_ITEM_AVAILABLE
)
607 pBgdAttr
= (const SvxBrushItem
*)&( rSet
.Get( SID_ATTR_BRUSH_ROW
) );
608 pTableBck_Impl
->pRowBrush
= new SvxBrushItem(*pBgdAttr
);
610 pTableBck_Impl
->nRowWhich
= SID_ATTR_BRUSH_ROW
;
612 if ( rSet
.GetItemState( SID_ATTR_BRUSH_TABLE
, FALSE
) >= SFX_ITEM_AVAILABLE
)
614 pBgdAttr
= (const SvxBrushItem
*)&( rSet
.Get( SID_ATTR_BRUSH_TABLE
) );
615 pTableBck_Impl
->pTableBrush
= new SvxBrushItem(*pBgdAttr
);
617 pTableBck_Impl
->nTableWhich
= SID_ATTR_BRUSH_TABLE
;
619 TblDestinationHdl_Impl(&aTblLBox
);
620 aTblLBox
.SaveValue();
624 USHORT nValue
= aParaLBox
.GetSelectEntryPos();
628 delete pParaBck_Impl
->pParaBrush
;
629 delete pParaBck_Impl
->pCharBrush
;
632 pParaBck_Impl
= new SvxBackgroundPara_Impl();
634 pParaBck_Impl
->nActPos
= nValue
;
636 nWhich
= GetWhich( SID_ATTR_BRUSH
);
637 if ( rSet
.GetItemState( nWhich
, FALSE
) >= SFX_ITEM_AVAILABLE
)
639 pBgdAttr
= (const SvxBrushItem
*)&( rSet
.Get( nWhich
) );
640 pParaBck_Impl
->pParaBrush
= new SvxBrushItem(*pBgdAttr
);
643 nWhich
= GetWhich( SID_ATTR_BRUSH_CHAR
);
644 SfxItemState eState
= rSet
.GetItemState( nWhich
, TRUE
);
645 eState
= rSet
.GetItemState( nWhich
, FALSE
);
646 if ( rSet
.GetItemState( nWhich
, TRUE
) > SFX_ITEM_AVAILABLE
)
648 pBgdAttr
= (const SvxBrushItem
*)&( rSet
.Get( nWhich
) );
649 pParaBck_Impl
->pCharBrush
= new SvxBrushItem(*pBgdAttr
);
652 pParaBck_Impl
->pCharBrush
= new SvxBrushItem(SID_ATTR_BRUSH_CHAR
);
654 ParaDestinationHdl_Impl(&aParaLBox
);
655 aParaLBox
.SaveValue();
660 if(!aLbSelect
.IsVisible() && !aTblLBox
.IsVisible() && !aParaLBox
.IsVisible())
662 long nY(LogicToPixel(Point(11,14), MAP_APPFONT
).X());
663 long nX(LogicToPixel(Point(11,14), MAP_APPFONT
).Y());
664 Point
aPos(aBorderWin
.GetPosPixel());
667 aBorderWin
.SetPosPixel(aPos
);
668 aPos
= pPreviewWin1
->GetPosPixel();
670 pPreviewWin1
->SetPosPixel(aPos
);
671 aBackgroundColorBox
.Hide();
676 void SvxBackgroundTabPage::ResetFromWallpaperItem( const SfxItemSet
& rSet
)
680 // Zustand des Vorschau-Buttons durch UserData persistent
681 String aUserData
= GetUserData();
682 aBtnPreview
.Check( aUserData
.Len() && sal_Unicode('1') == aUserData
.GetChar( 0 ) );
684 // Input-BrushItem besorgen und auswerten
685 const SvxBrushItem
* pBgdAttr
= NULL
;
686 USHORT nSlot
= SID_VIEW_FLD_PIC
;
687 USHORT nWhich
= GetWhich( nSlot
);
688 SvxBrushItem
* pTemp
= 0;
689 const CntWallpaperItem
* pItem
= 0;
691 if ( rSet
.GetItemState( nWhich
, FALSE
) >= SFX_ITEM_AVAILABLE
)
693 pItem
= (const CntWallpaperItem
*)&rSet
.Get( nWhich
);
694 pTemp
= new SvxBrushItem( *pItem
, nWhich
);
702 FillControls_Impl(*pBgdAttr
, aUserData
);
703 // Auch bei Anzeige der Grafik, soll die Brush erhalten bleiben
704 if( aBgdColor
!= pBgdAttr
->GetColor() )
706 aBgdColor
= pBgdAttr
->GetColor();
707 USHORT nCol
= GetItemId_Impl( aBackgroundColorSet
, aBgdColor
);
708 aBackgroundColorSet
.SelectItem( nCol
);
709 pPreviewWin1
->NotifyChange( aBgdColor
);
714 aLbSelect
.SelectEntryPos( 0 );
717 const SfxPoolItem
* pOld
= GetOldItem( rSet
, SID_VIEW_FLD_PIC
);
719 aBgdColor
= Color( ((CntWallpaperItem
*)pOld
)->GetColor() );
722 // We now have always a link to the background
724 aBtnLink
.Check( TRUE
);
725 aBtnLink
.Show( FALSE
);
726 // if( !pItem || !pItem->GetWallpaper(FALSE).IsBitmap() )
734 //------------------------------------------------------------------------
736 void SvxBackgroundTabPage::FillUserData()
740 Beim Destruieren einer SfxTabPage wird diese virtuelle Methode gerufen,
741 damit die TabPage interne Informationen sichern kann.
743 In diesem Fall wird der Zustand des Vorschau-Buttons gesichert.
747 SetUserData( String( aBtnPreview
.IsChecked() ? sal_Unicode('1') : sal_Unicode('0') ) );
750 //------------------------------------------------------------------------
752 BOOL
SvxBackgroundTabPage::FillItemSet( SfxItemSet
& rCoreSet
)
759 if ( pPageImpl
->pLoadTimer
&& pPageImpl
->pLoadTimer
->IsActive() )
761 pPageImpl
->pLoadTimer
->Stop();
762 LoadTimerHdl_Impl( pPageImpl
->pLoadTimer
);
764 // os: So ein Unsinn! Irgendwo laesst sich so ein Item immer finden,
765 // es muss aber im rSet vorhanden sein!
767 // const SfxPoolItem* pX = GetOldItem( rCoreSet, SID_VIEW_FLD_PIC );
768 // if( pX && pX->ISA(SfxWallpaperItem))
769 if(SFX_ITEM_AVAILABLE
<= rCoreSet
.GetItemState(GetWhich(SID_VIEW_FLD_PIC
), FALSE
))
770 return FillItemSetWithWallpaperItem( rCoreSet
, SID_VIEW_FLD_PIC
);
772 BOOL bModified
= FALSE
;
773 USHORT nSlot
= SID_ATTR_BRUSH
;
775 if ( aTblLBox
.IsVisible() )
777 switch( aTblLBox
.GetSelectEntryPos() )
780 nSlot
= SID_ATTR_BRUSH
;
783 nSlot
= SID_ATTR_BRUSH_ROW
;
786 nSlot
= SID_ATTR_BRUSH_TABLE
;
790 else if(aParaLBox
.GetData() == &aParaLBox
)
792 switch(aParaLBox
.GetSelectEntryPos())
795 nSlot
= SID_ATTR_BRUSH
;
798 nSlot
= SID_ATTR_BRUSH_CHAR
;
802 USHORT nWhich
= GetWhich( nSlot
);
804 const SfxPoolItem
* pOld
= GetOldItem( rCoreSet
, nSlot
);
805 SfxItemState eOldItemState
= rCoreSet
.GetItemState(nSlot
, FALSE
);
806 const SfxItemSet
& rOldSet
= GetItemSet();
808 BOOL bGraphTransparencyChanged
= bGraphTransparency
&& (aGraphTransMF
.GetText() != aGraphTransMF
.GetSavedValue());
811 const SvxBrushItem
& rOldItem
= (const SvxBrushItem
&)*pOld
;
812 SvxGraphicPosition eOldPos
= rOldItem
.GetGraphicPos();
813 const BOOL bIsBrush
= ( 0 == aLbSelect
.GetSelectEntryPos() );
815 // transparency has to be set if enabled, the color not already set to "No fill" and
816 if( bColTransparency
&&
817 aBgdColor
.GetTransparency() < 0xff)
819 aBgdColor
.SetTransparency(lcl_PercentToTransparency(static_cast<long>(aColTransMF
.GetValue())));
821 if ( ( (GPOS_NONE
== eOldPos
) && bIsBrush
)
822 || ( (GPOS_NONE
!= eOldPos
) && !bIsBrush
) ) // Brush <-> Bitmap gewechselt?
824 // Hintergrund-Art wurde nicht gewechselt:
826 if ( (GPOS_NONE
== eOldPos
) || !aLbSelect
.IsVisible() )
829 if ( rOldItem
.GetColor() != aBgdColor
||
830 (SFX_ITEM_AVAILABLE
>= eOldItemState
&& !aBackgroundColorSet
.IsNoSelection()))
833 rCoreSet
.Put( SvxBrushItem( aBgdColor
, nWhich
) );
835 else if ( SFX_ITEM_DEFAULT
== rOldSet
.GetItemState( nWhich
, FALSE
) )
836 rCoreSet
.ClearItem( nWhich
);
840 // Bitmap-Behandlung:
842 SvxGraphicPosition eNewPos
= GetGraphicPosition_Impl();
843 const BOOL bIsLink
= aBtnLink
.IsChecked();
844 const BOOL bWasLink
= (NULL
!= rOldItem
.GetGraphicLink() );
847 if ( !bIsLink
&& !bIsGraphicValid
)
848 bIsGraphicValid
= LoadLinkedGraphic_Impl();
850 if ( bGraphTransparencyChanged
||
852 || bIsLink
!= bWasLink
853 || ( bWasLink
&& *rOldItem
.GetGraphicLink()
855 || ( !bWasLink
&& rOldItem
.GetGraphic()->GetBitmap()
856 != aBgdGraphic
.GetBitmap() )
861 SvxBrushItem
aTmpBrush(nWhich
);
864 aTmpBrush
= SvxBrushItem( aBgdGraphicPath
,
870 aTmpBrush
= SvxBrushItem( aBgdGraphic
,
873 lcl_SetTransparency(aTmpBrush
, static_cast<long>(aGraphTransMF
.GetValue()));
875 rCoreSet
.Put(aTmpBrush
);
877 else if ( SFX_ITEM_DEFAULT
== rOldSet
.GetItemState( nWhich
, FALSE
) )
878 rCoreSet
.ClearItem( nWhich
);
881 else // Brush <-> Bitmap gewechselt!
884 rCoreSet
.Put( SvxBrushItem( aBgdColor
, nWhich
) );
887 SvxBrushItem
* pTmpBrush
= 0;
888 if ( aBtnLink
.IsChecked() )
890 pTmpBrush
= new SvxBrushItem( aBgdGraphicPath
,
892 GetGraphicPosition_Impl(),
897 if ( !bIsGraphicValid
)
898 bIsGraphicValid
= LoadLinkedGraphic_Impl();
900 if ( bIsGraphicValid
)
901 pTmpBrush
= new SvxBrushItem( aBgdGraphic
,
902 GetGraphicPosition_Impl(),
907 lcl_SetTransparency(*pTmpBrush
, static_cast<long>(aGraphTransMF
.GetValue()));
908 rCoreSet
.Put(*pTmpBrush
);
912 bModified
= ( bIsBrush
|| aBtnLink
.IsChecked() || bIsGraphicValid
);
915 else if ( SID_ATTR_BRUSH_CHAR
== nSlot
&& aBgdColor
!= Color( COL_WHITE
) )
917 rCoreSet
.Put( SvxBrushItem( aBgdColor
, nWhich
) );
921 if( aTblLBox
.IsVisible() )
923 // Der aktuelle Zustand wurde bereits geputtet
924 if( nSlot
!= SID_ATTR_BRUSH
&& pTableBck_Impl
->pCellBrush
)
926 const SfxPoolItem
* pOldCell
=
927 GetOldItem( rCoreSet
, SID_ATTR_BRUSH
);
929 if ( *pTableBck_Impl
->pCellBrush
!= *pOldCell
)
931 rCoreSet
.Put( *pTableBck_Impl
->pCellBrush
);
936 if( nSlot
!= SID_ATTR_BRUSH_ROW
&& pTableBck_Impl
->pRowBrush
)
938 const SfxPoolItem
* pOldRow
=
939 GetOldItem( rCoreSet
, SID_ATTR_BRUSH_ROW
);
941 if ( *pTableBck_Impl
->pRowBrush
!= *pOldRow
)
943 rCoreSet
.Put( *pTableBck_Impl
->pRowBrush
);
948 if( nSlot
!= SID_ATTR_BRUSH_TABLE
&& pTableBck_Impl
->pTableBrush
)
950 const SfxPoolItem
* pOldTable
=
951 GetOldItem( rCoreSet
, SID_ATTR_BRUSH_TABLE
);
953 if ( *pTableBck_Impl
->pTableBrush
!= *pOldTable
)
955 rCoreSet
.Put( *pTableBck_Impl
->pTableBrush
);
960 if( aTblLBox
.GetSavedValue() != aTblLBox
.GetSelectEntryPos() )
962 rCoreSet
.Put( SfxUInt16Item( SID_BACKGRND_DESTINATION
,
963 aTblLBox
.GetSelectEntryPos() ) );
967 else if(aParaLBox
.GetData() == &aParaLBox
)
969 // Der aktuelle Zustand wurde bereits geputtet
970 if( nSlot
!= SID_ATTR_BRUSH
&& aParaLBox
.IsVisible()) // nicht im Suchen-Format-Dialog
972 const SfxPoolItem
* pOldPara
=
973 GetOldItem( rCoreSet
, SID_ATTR_BRUSH
);
975 if ( *pParaBck_Impl
->pParaBrush
!= *pOldPara
)
977 rCoreSet
.Put( *pParaBck_Impl
->pParaBrush
);
982 if( nSlot
!= SID_ATTR_BRUSH_CHAR
)
984 const SfxPoolItem
* pOldChar
=
985 GetOldItem( rCoreSet
, SID_ATTR_BRUSH_CHAR
);
986 DBG_ASSERT(pParaBck_Impl
, "pParaBck_Impl == NULL ?");
988 //#111173# crash report shows that pParaBck_Impl can be NULL, the cause is unknown
990 (*pParaBck_Impl
->pCharBrush
!= *pOldChar
||
991 *pParaBck_Impl
->pCharBrush
!= SvxBrushItem(SID_ATTR_BRUSH_CHAR
)))
993 rCoreSet
.Put( *pParaBck_Impl
->pCharBrush
);
998 if( aParaLBox
.GetSavedValue() != aParaLBox
.GetSelectEntryPos() )
1000 rCoreSet
.Put( SfxUInt16Item( SID_BACKGRND_DESTINATION
,
1001 aParaLBox
.GetSelectEntryPos() ) );
1008 BOOL
SvxBackgroundTabPage::FillItemSetWithWallpaperItem( SfxItemSet
& rCoreSet
, USHORT nSlot
)
1010 USHORT nWhich
= GetWhich( nSlot
);
1011 const SfxPoolItem
* pOld
= GetOldItem( rCoreSet
, nSlot
);
1012 const SfxItemSet
& rOldSet
= GetItemSet();
1013 DBG_ASSERT(pOld
,"FillItemSetWithWallpaperItem: Item not found");
1015 SvxBrushItem
rOldItem( (const CntWallpaperItem
&)*pOld
, nWhich
);
1016 SvxGraphicPosition eOldPos
= rOldItem
.GetGraphicPos();
1017 const BOOL bIsBrush
= ( 0 == aLbSelect
.GetSelectEntryPos() );
1018 BOOL bModified
= FALSE
;
1020 if ( ( (GPOS_NONE
== eOldPos
) && bIsBrush
)
1021 || ( (GPOS_NONE
!= eOldPos
) && !bIsBrush
) ) // Brush <-> Bitmap gewechselt?
1023 // Hintergrund-Art wurde nicht gewechselt:
1025 if ( (GPOS_NONE
== eOldPos
) || !aLbSelect
.IsVisible() )
1027 // Brush-Behandlung:
1028 if ( rOldItem
.GetColor() != aBgdColor
)
1031 CntWallpaperItem
aItem( nWhich
);
1032 aItem
.SetColor( aBgdColor
);
1033 rCoreSet
.Put( aItem
);
1035 else if ( SFX_ITEM_DEFAULT
== rOldSet
.GetItemState( nWhich
, FALSE
) )
1036 rCoreSet
.ClearItem( nWhich
);
1040 // Bitmap-Behandlung:
1041 SvxGraphicPosition eNewPos
= GetGraphicPosition_Impl();
1043 int bBitmapChanged
= ( ( eNewPos
!= eOldPos
) ||
1044 ( *rOldItem
.GetGraphicLink() != aBgdGraphicPath
) );
1045 int bBrushChanged
= ( rOldItem
.GetColor() != aBgdColor
);
1046 if( bBitmapChanged
|| bBrushChanged
)
1050 CntWallpaperItem
aItem( nWhich
);
1051 WallpaperStyle eWallStyle
= SvxBrushItem::GraphicPos2WallpaperStyle(eNewPos
);
1052 aItem
.SetStyle( sal::static_int_cast
< USHORT
>( eWallStyle
) );
1053 aItem
.SetColor( aBgdColor
);
1054 aItem
.SetBitmapURL( aBgdGraphicPath
);
1055 rCoreSet
.Put( aItem
);
1057 else if ( SFX_ITEM_DEFAULT
== rOldSet
.GetItemState( nWhich
, FALSE
) )
1058 rCoreSet
.ClearItem( nWhich
);
1061 else // Brush <-> Bitmap gewechselt!
1063 CntWallpaperItem
aItem( nWhich
);
1066 aItem
.SetColor( aBgdColor
);
1067 rCoreSet
.Put( aItem
);
1071 WallpaperStyle eWallStyle
=
1072 SvxBrushItem::GraphicPos2WallpaperStyle( GetGraphicPosition_Impl() );
1073 aItem
.SetStyle( sal::static_int_cast
< USHORT
>( eWallStyle
) );
1074 aItem
.SetColor( aBgdColor
);
1075 aItem
.SetBitmapURL( aBgdGraphicPath
);
1076 rCoreSet
.Put( aItem
);
1084 //-----------------------------------------------------------------------
1086 int SvxBackgroundTabPage::DeactivatePage( SfxItemSet
* _pSet
)
1090 virtuelle Methode, wird beim Deaktivieren gerufen
1094 if ( pPageImpl
->bIsImportDlgInExecute
)
1098 FillItemSet( *_pSet
);
1103 //-----------------------------------------------------------------------
1105 void SvxBackgroundTabPage::PointChanged( Window
* , RECT_POINT
)
1112 // muss implementiert werden, damit Position-Control funktioniert
1115 //-----------------------------------------------------------------------
1117 void SvxBackgroundTabPage::ShowSelector()
1124 if( bAllowShowSelector
)
1128 aLbSelect
.SetSelectHdl( HDL(SelectHdl_Impl
) );
1129 aBtnLink
.SetClickHdl( HDL(FileClickHdl_Impl
) );
1130 aBtnPreview
.SetClickHdl( HDL(FileClickHdl_Impl
) );
1131 aBtnBrowse
.SetClickHdl( HDL(BrowseHdl_Impl
) );
1132 aBtnArea
.SetClickHdl( HDL(RadioClickHdl_Impl
) );
1133 aBtnTile
.SetClickHdl( HDL(RadioClickHdl_Impl
) );
1134 aBtnPosition
.SetClickHdl( HDL(RadioClickHdl_Impl
) );
1136 // Verz"ogertes Laden "uber Timer (wg. UI-Update)
1137 pPageImpl
->pLoadTimer
= new Timer
;
1138 pPageImpl
->pLoadTimer
->SetTimeout( 500 ); // 500ms verz"ogern
1139 pPageImpl
->pLoadTimer
->SetTimeoutHdl(
1140 LINK( this, SvxBackgroundTabPage
, LoadTimerHdl_Impl
) );
1142 bAllowShowSelector
= FALSE
;
1144 if(nHtmlMode
& HTMLMODE_ON
)
1146 if(!(nHtmlMode
& HTMLMODE_GRAPH_POS
))
1147 aBtnPosition
.Enable(FALSE
);
1148 aBtnArea
.Enable(FALSE
);
1153 //------------------------------------------------------------------------
1156 void SvxBackgroundTabPage::RaiseLoadError_Impl()
1163 SfxErrorContext
aContext( ERRCTX_SVX_BACKGROUND
,
1169 ErrorHandler::HandleError(
1170 *new StringErrorInfo( ERRCODE_SVX_GRAPHIC_NOTREADABLE
,
1171 aBgdGraphicPath
) );
1174 //------------------------------------------------------------------------
1176 BOOL
SvxBackgroundTabPage::LoadLinkedGraphic_Impl()
1183 BOOL bResult
= ( aBgdGraphicPath
.Len() > 0 ) &&
1184 ( GRFILTER_OK
== LoadGraphic( aBgdGraphicPath
,
1190 //------------------------------------------------------------------------
1193 void SvxBackgroundTabPage::FillColorValueSets_Impl()
1197 F"ullen des Farb-Sets
1201 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
1202 const SfxPoolItem
* pItem
= NULL
;
1203 XColorTable
* pColorTable
= NULL
;
1204 const Size aSize15x15
= Size( 15, 15 );
1205 FASTBOOL bOwn
= FALSE
;
1207 if ( pDocSh
&& ( 0 != ( pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
) ) ) )
1208 pColorTable
= ( (SvxColorTableItem
*)pItem
)->GetColorTable();
1213 pColorTable
= new XColorTable( SvtPathOptions().GetPalettePath() );
1219 long nCount
= pColorTable
->Count();
1220 XColorEntry
* pEntry
= NULL
;
1221 Color
aColWhite( COL_WHITE
);
1222 String
aStrWhite( SVX_RES( RID_SVXITEMS_COLOR_WHITE
) );
1223 WinBits nBits
= ( aBackgroundColorSet
.GetStyle() | WB_ITEMBORDER
| WB_NAMEFIELD
| WB_NONEFIELD
);
1224 aBackgroundColorSet
.SetText( String( SVX_RES( RID_SVXSTR_TRANSPARENT
) ) );
1225 aBackgroundColorSet
.SetStyle( nBits
);
1226 for ( i
= 0; i
< nCount
; i
++ )
1228 pEntry
= pColorTable
->GetColor(i
);
1229 aBackgroundColorSet
.InsertItem( i
+ 1, pEntry
->GetColor(), pEntry
->GetName() );
1234 aBackgroundColorSet
.InsertItem( i
+ 1, aColWhite
, aStrWhite
);
1240 aBackgroundColorSet
.SetStyle( nBits
| WB_VSCROLL
);
1247 aBackgroundColorSet
.SetColCount( 10 );
1248 aBackgroundColorSet
.SetLineCount( 10 );
1249 aBackgroundColorSet
.CalcWindowSizePixel( aSize15x15
);
1253 //------------------------------------------------------------------------
1257 //------------------------------------------------------------------------
1259 void SvxBackgroundTabPage::ShowColorUI_Impl()
1263 Die Controls f"ur das Einstellen der Grafik ausblenden und die
1264 Controls f"ur die Farbeinstellung einblenden.
1268 if( !aBackgroundColorSet
.IsVisible() )
1270 aBackgroundColorSet
.Show();
1271 aBackgroundColorBox
.Show();
1273 pPreviewWin1
->Show();
1279 aBtnPosition
.Hide();
1282 aWndPosition
.Hide();
1284 pPreviewWin2
->Hide();
1285 aGraphTransFL
.Show(FALSE
);
1286 aGraphTransMF
.Show(FALSE
);
1287 if(bColTransparency
)
1295 //------------------------------------------------------------------------
1297 void SvxBackgroundTabPage::ShowBitmapUI_Impl()
1301 Die Controls f"ur die Farbeinstellung ausblenden und die
1302 Controls f"ur das Einstellen der Grafik einblenden.
1306 if ( aLbSelect
.IsVisible() &&
1308 aBackgroundColorSet
.IsVisible()
1309 || !aBtnBrowse
.IsVisible() ) )
1311 aBackgroundColorSet
.Hide();
1312 aBackgroundColorBox
.Hide();
1314 pPreviewWin1
->Hide();
1318 if ( !bLinkOnly
&& ! nHtmlMode
& HTMLMODE_ON
)
1322 aBtnPosition
.Show();
1325 aWndPosition
.Show();
1327 pPreviewWin2
->Show();
1328 if(bGraphTransparency
)
1330 aGraphTransFL
.Show();
1331 aGraphTransMF
.Show();
1333 aColTransFT
.Show(FALSE
);
1334 aColTransMF
.Show(FALSE
);
1338 //------------------------------------------------------------------------
1340 void SvxBackgroundTabPage::SetGraphicPosition_Impl( SvxGraphicPosition ePos
)
1344 Die Controls f"ur die Grafikposition einstellen.
1353 aWndPosition
.Disable();
1360 aWndPosition
.Disable();
1366 aBtnPosition
.Check();
1367 aWndPosition
.Enable();
1368 RECT_POINT eNewPos
= RP_MM
;
1372 case GPOS_MM
: break;
1373 case GPOS_LT
: eNewPos
= RP_LT
; break;
1374 case GPOS_MT
: eNewPos
= RP_MT
; break;
1375 case GPOS_RT
: eNewPos
= RP_RT
; break;
1376 case GPOS_LM
: eNewPos
= RP_LM
; break;
1377 case GPOS_RM
: eNewPos
= RP_RM
; break;
1378 case GPOS_LB
: eNewPos
= RP_LB
; break;
1379 case GPOS_MB
: eNewPos
= RP_MB
; break;
1380 case GPOS_RB
: eNewPos
= RP_RB
; break;
1381 default: ;//prevent warning
1383 aWndPosition
.SetActualRP( eNewPos
);
1387 aWndPosition
.Invalidate();
1390 //------------------------------------------------------------------------
1392 SvxGraphicPosition
SvxBackgroundTabPage::GetGraphicPosition_Impl()
1396 Die Position der Grafik zur"uckgeben.
1400 if ( aBtnTile
.IsChecked() )
1402 else if ( aBtnArea
.IsChecked() )
1406 switch ( aWndPosition
.GetActualRP() )
1408 case RP_LT
: return GPOS_LT
;
1409 case RP_MT
: return GPOS_MT
;
1410 case RP_RT
: return GPOS_RT
;
1411 case RP_LM
: return GPOS_LM
;
1412 case RP_MM
: return GPOS_MM
;
1413 case RP_RM
: return GPOS_RM
;
1414 case RP_LB
: return GPOS_LB
;
1415 case RP_MB
: return GPOS_MB
;
1416 case RP_RB
: return GPOS_RB
;
1422 //-----------------------------------------------------------------------
1424 //-----------------------------------------------------------------------
1426 IMPL_LINK( SvxBackgroundTabPage
, BackgroundColorHdl_Impl
, ValueSet
*, EMPTYARG
)
1428 Handler, called when color selection is changed
1431 USHORT nItemId
= aBackgroundColorSet
.GetSelectItemId();
1432 Color aColor
= nItemId
? ( aBackgroundColorSet
.GetItemColor( nItemId
) ) : Color( COL_TRANSPARENT
);
1434 pPreviewWin1
->NotifyChange( aBgdColor
);
1435 BOOL bEnableTransp
= aBgdColor
.GetTransparency() < 0xff;
1436 aColTransFT
.Enable(bEnableTransp
);
1437 aColTransMF
.Enable(bEnableTransp
);
1441 //------------------------------------------------------------------------
1443 IMPL_LINK( SvxBackgroundTabPage
, SelectHdl_Impl
, ListBox
*, EMPTYARG
)
1450 if ( 0 == aLbSelect
.GetSelectEntryPos() )
1453 aParaLBox
.Enable(); // Zeichenhintergrund kann keine Bitmap sein
1457 ShowBitmapUI_Impl();
1458 aParaLBox
.Enable(FALSE
);// Zeichenhintergrund kann keine Bitmap sein
1463 //------------------------------------------------------------------------
1465 IMPL_LINK( SvxBackgroundTabPage
, FileClickHdl_Impl
, CheckBox
*, pBox
)
1472 if ( &aBtnLink
== pBox
)
1474 if ( aBtnLink
.IsChecked() )
1476 INetURLObject
aObj( aBgdGraphicPath
);
1478 if ( aObj
.GetProtocol() == INET_PROT_FILE
)
1479 aFilePath
= aObj
.getFSysPath( INetURLObject::FSYS_DETECT
);
1481 aFilePath
= aBgdGraphicPath
;
1482 aFtFile
.SetText( aFilePath
);
1485 aFtFile
.SetText( aStrUnlinked
);
1487 else if ( &aBtnPreview
== pBox
)
1489 if ( aBtnPreview
.IsChecked() )
1491 if ( !bIsGraphicValid
)
1492 bIsGraphicValid
= LoadLinkedGraphic_Impl();
1494 if ( bIsGraphicValid
)
1496 Bitmap aBmp
= aBgdGraphic
.GetBitmap();
1497 pPreviewWin2
->NotifyChange( &aBmp
);
1501 if ( aBgdGraphicPath
.Len() > 0 ) // nur bei gelinkter Grafik
1502 RaiseLoadError_Impl(); // ein Fehler
1503 pPreviewWin2
->NotifyChange( NULL
);
1507 pPreviewWin2
->NotifyChange( NULL
);
1512 //------------------------------------------------------------------------
1514 IMPL_LINK( SvxBackgroundTabPage
, RadioClickHdl_Impl
, RadioButton
*, pBtn
)
1521 if ( pBtn
== &aBtnPosition
)
1523 if ( !aWndPosition
.IsEnabled() )
1525 aWndPosition
.Enable();
1526 aWndPosition
.Invalidate();
1529 else if ( aWndPosition
.IsEnabled() )
1531 aWndPosition
.Disable();
1532 aWndPosition
.Invalidate();
1537 //------------------------------------------------------------------------
1539 IMPL_LINK( SvxBackgroundTabPage
, BrowseHdl_Impl
, PushButton
* , EMPTYARG
)
1543 Handler, gerufen durch das Dr"ucken des Durchsuchen-Buttons.
1544 Grafik/Einf"ugen-Dialog erzeugen, Pfad setzen und starten.
1548 if ( pPageImpl
->pLoadTimer
->IsActive() )
1550 BOOL bHtml
= 0 != ( nHtmlMode
& HTMLMODE_ON
);
1552 pImportDlg
= new SvxOpenGraphicDialog( aStrBrowse
);
1553 if ( bHtml
|| bLinkOnly
)
1554 pImportDlg
->EnableLink(sal_False
);
1555 pImportDlg
->SetPath( aBgdGraphicPath
, aBtnLink
.IsChecked() );
1557 pPageImpl
->bIsImportDlgInExecute
= TRUE
;
1558 short nErr
= pImportDlg
->Execute();
1559 pPageImpl
->bIsImportDlgInExecute
= FALSE
;
1565 // wenn Verkn"upfen nicht gecheckt ist und die Vorschau auch nicht,
1566 // dann die Vorschau aktivieren, damit der Anwender sieht,
1567 // welche Grafik er ausgew"ahlt hat
1568 if ( !aBtnLink
.IsChecked() && !aBtnPreview
.IsChecked() )
1569 aBtnPreview
.Check( TRUE
);
1570 // timer-verz"ogertes Laden der Grafik
1571 pPageImpl
->pLoadTimer
->Start();
1574 DELETEZ( pImportDlg
);
1578 //-----------------------------------------------------------------------
1580 IMPL_LINK( SvxBackgroundTabPage
, LoadTimerHdl_Impl
, Timer
* , pTimer
)
1584 Verz"ogertes Laden der Grafik.
1585 Grafik wird nur dann geladen, wenn sie unterschiedlich zur
1586 aktuellen Grafik ist.
1590 if ( pTimer
== pPageImpl
->pLoadTimer
)
1592 pPageImpl
->pLoadTimer
->Stop();
1596 INetURLObject
aOld( aBgdGraphicPath
);
1597 INetURLObject
aNew( pImportDlg
->GetPath() );
1598 if ( !aBgdGraphicPath
.Len() || aNew
!= aOld
)
1600 // neue Datei gew"ahlt
1601 aBgdGraphicPath
= pImportDlg
->GetPath();
1602 aBgdGraphicFilter
= pImportDlg
->GetCurrentFilter();
1603 BOOL bLink
= ( nHtmlMode
& HTMLMODE_ON
) || bLinkOnly
? TRUE
: pImportDlg
->IsAsLink();
1604 aBtnLink
.Check( bLink
);
1607 if ( aBtnPreview
.IsChecked() )
1609 if( !pImportDlg
->GetGraphic(aBgdGraphic
) )
1611 bIsGraphicValid
= TRUE
;
1615 aBgdGraphicFilter
.Erase();
1616 aBgdGraphicPath
.Erase();
1617 bIsGraphicValid
= FALSE
;
1621 bIsGraphicValid
= FALSE
; // Grafik erst beim Preview-Click laden
1623 if ( aBtnPreview
.IsChecked() && bIsGraphicValid
)
1625 Bitmap aBmp
= aBgdGraphic
.GetBitmap();
1626 pPreviewWin2
->NotifyChange( &aBmp
);
1629 pPreviewWin2
->NotifyChange( NULL
);
1632 FileClickHdl_Impl( &aBtnLink
);
1633 DELETEZ( pImportDlg
);
1639 //-----------------------------------------------------------------------
1641 void SvxBackgroundTabPage::ShowTblControl()
1648 aTblLBox
.SetSelectHdl( HDL(TblDestinationHdl_Impl
) );
1649 aTblLBox
.SelectEntryPos(0);
1654 //-----------------------------------------------------------------------
1656 void SvxBackgroundTabPage::ShowParaControl(BOOL bCharOnly
)
1658 aParaLBox
.SetSelectHdl(HDL(ParaDestinationHdl_Impl
));
1659 aParaLBox
.SelectEntryPos(0);
1665 aParaLBox
.SetData(&aParaLBox
); // hier erkennt man, dass dieser Mode eingeschaltet ist
1667 //-----------------------------------------------------------------------
1669 IMPL_LINK( SvxBackgroundTabPage
, TblDestinationHdl_Impl
, ListBox
*, pBox
)
1676 USHORT nSelPos
= pBox
->GetSelectEntryPos();
1677 if( pTableBck_Impl
&& pTableBck_Impl
->nActPos
!= nSelPos
)
1679 SvxBrushItem
** pActItem
= new (SvxBrushItem
*);
1681 switch(pTableBck_Impl
->nActPos
)
1684 *pActItem
= pTableBck_Impl
->pCellBrush
;
1685 nWhich
= pTableBck_Impl
->nCellWhich
;
1688 *pActItem
= pTableBck_Impl
->pRowBrush
;
1689 nWhich
= pTableBck_Impl
->nRowWhich
;
1692 *pActItem
= pTableBck_Impl
->pTableBrush
;
1693 nWhich
= pTableBck_Impl
->nTableWhich
;
1696 pTableBck_Impl
->nActPos
= nSelPos
;
1698 *pActItem
= new SvxBrushItem(nWhich
);
1699 if(0 == aLbSelect
.GetSelectEntryPos()) // Brush ausgewaehlt
1701 **pActItem
= SvxBrushItem( aBgdColor
, nWhich
);
1705 SvxGraphicPosition eNewPos
= GetGraphicPosition_Impl();
1706 const BOOL bIsLink
= aBtnLink
.IsChecked();
1708 if ( !bIsLink
&& !bIsGraphicValid
)
1709 bIsGraphicValid
= LoadLinkedGraphic_Impl();
1712 **pActItem
= SvxBrushItem( aBgdGraphicPath
,
1715 (*pActItem
)->Which() );
1717 **pActItem
= SvxBrushItem( aBgdGraphic
,
1719 (*pActItem
)->Which() );
1724 *pActItem
= pTableBck_Impl
->pCellBrush
;
1726 nWhich
= pTableBck_Impl
->nCellWhich
;
1730 if((nHtmlMode
& HTMLMODE_ON
) && !(nHtmlMode
& HTMLMODE_SOME_STYLES
))
1731 aLbSelect
.Disable();
1732 *pActItem
= pTableBck_Impl
->pRowBrush
;
1733 nWhich
= pTableBck_Impl
->nRowWhich
;
1737 *pActItem
= pTableBck_Impl
->pTableBrush
;
1739 nWhich
= pTableBck_Impl
->nTableWhich
;
1742 String aUserData
= GetUserData();
1744 *pActItem
= new SvxBrushItem(nWhich
);
1745 FillControls_Impl(**pActItem
, aUserData
);
1751 //-----------------------------------------------------------------------
1753 IMPL_LINK( SvxBackgroundTabPage
, ParaDestinationHdl_Impl
, ListBox
*, pBox
)
1755 USHORT nSelPos
= pBox
->GetSelectEntryPos();
1756 if( pParaBck_Impl
&& pParaBck_Impl
->nActPos
!= nSelPos
)
1758 SvxBrushItem
** pActItem
= new (SvxBrushItem
*);
1759 switch(pParaBck_Impl
->nActPos
)
1761 case PARA_DEST_PARA
:
1762 *pActItem
= pParaBck_Impl
->pParaBrush
;
1764 case PARA_DEST_CHAR
:
1765 *pActItem
= pParaBck_Impl
->pCharBrush
;
1768 pParaBck_Impl
->nActPos
= nSelPos
;
1769 if(0 == aLbSelect
.GetSelectEntryPos()) // Brush ausgewaehlt
1771 USHORT nWhich
= (*pActItem
)->Which();
1772 **pActItem
= SvxBrushItem( aBgdColor
, nWhich
);
1776 SvxGraphicPosition eNewPos
= GetGraphicPosition_Impl();
1777 const BOOL bIsLink
= aBtnLink
.IsChecked();
1779 if ( !bIsLink
&& !bIsGraphicValid
)
1780 bIsGraphicValid
= LoadLinkedGraphic_Impl();
1783 **pActItem
= SvxBrushItem( aBgdGraphicPath
,
1786 (*pActItem
)->Which() );
1788 **pActItem
= SvxBrushItem( aBgdGraphic
,
1790 (*pActItem
)->Which() );
1794 case PARA_DEST_PARA
:
1795 *pActItem
= pParaBck_Impl
->pParaBrush
;
1798 case PARA_DEST_CHAR
:
1800 *pActItem
= pParaBck_Impl
->pCharBrush
;
1801 aLbSelect
.Enable(FALSE
);
1805 String aUserData
= GetUserData();
1806 FillControls_Impl(**pActItem
, aUserData
);
1812 //-----------------------------------------------------------------------
1814 void SvxBackgroundTabPage::FillControls_Impl( const SvxBrushItem
& rBgdAttr
,
1815 const String
& rUserData
)
1822 SvxGraphicPosition ePos
= rBgdAttr
.GetGraphicPos();
1823 const Color
& rColor
= rBgdAttr
.GetColor();
1824 if(bColTransparency
)
1826 aColTransMF
.SetValue(lcl_TransparencyToPercent(rColor
.GetTransparency()));
1827 aColTransMF
.SaveValue();
1828 BOOL bEnableTransp
= rColor
.GetTransparency() < 0xff;
1829 aColTransFT
.Enable(bEnableTransp
);
1830 aColTransMF
.Enable(bEnableTransp
);
1831 //the default setting should be "no transparency"
1833 aColTransMF
.SetValue(0);
1836 if ( GPOS_NONE
== ePos
|| !aLbSelect
.IsVisible() )
1838 aLbSelect
.SelectEntryPos( 0 );
1840 Color
aTrColor( COL_TRANSPARENT
);
1843 USHORT nCol
= ( aTrColor
!= aBgdColor
) ?
1844 GetItemId_Impl( aBackgroundColorSet
, aBgdColor
) : 0;
1846 if( aTrColor
!= aBgdColor
&& nCol
== 0)
1848 aBackgroundColorSet
.SetNoSelection();
1852 aBackgroundColorSet
.SelectItem( nCol
);
1855 pPreviewWin1
->NotifyChange( aBgdColor
);
1856 if ( aLbSelect
.IsVisible() ) // Grafikteil initialisieren
1858 aBgdGraphicFilter
.Erase();
1859 aBgdGraphicPath
.Erase();
1861 if ( !rUserData
.Len() )
1862 aBtnPreview
.Check( FALSE
);
1863 aBtnLink
.Check( FALSE
);
1865 pPreviewWin2
->NotifyChange( NULL
);
1866 SetGraphicPosition_Impl( GPOS_TILED
); // Kacheln als Default
1871 const String
* pStrLink
= rBgdAttr
.GetGraphicLink();
1872 const String
* pStrFilter
= rBgdAttr
.GetGraphicFilter();
1874 aLbSelect
.SelectEntryPos( 1 );
1875 ShowBitmapUI_Impl();
1880 INetURLObject
aObj( *pStrLink
);
1881 DBG_ASSERT( aObj
.GetProtocol() != INET_PROT_NOT_VALID
, "Invalid URL!" );
1883 aBgdGraphicPath
= *pStrLink
;
1884 aBtnLink
.Check( TRUE
);
1889 aBgdGraphicPath
.Erase();
1890 aBtnLink
.Check( FALSE
);
1894 if(bGraphTransparency
)
1896 const GraphicObject
* pObject
= rBgdAttr
.GetGraphicObject(SfxObjectShell::Current());
1898 aGraphTransMF
.SetValue(lcl_TransparencyToPercent(pObject
->GetAttr().GetTransparency()));
1900 aGraphTransMF
.SetValue(0);
1901 aGraphTransMF
.SaveValue();
1904 FileClickHdl_Impl( &aBtnLink
);
1907 aBgdGraphicFilter
= *pStrFilter
;
1909 aBgdGraphicFilter
.Erase();
1911 if ( !pStrLink
|| aBtnPreview
.IsChecked() )
1913 // Grafik ist im Item vorhanden und muss nicht
1916 const Graphic
* pGraphic
=
1917 rBgdAttr
.GetGraphic( SfxObjectShell::Current() );
1919 if ( !pGraphic
&& aBtnPreview
.IsChecked() )
1920 bIsGraphicValid
= LoadLinkedGraphic_Impl();
1921 else if ( pGraphic
)
1923 aBgdGraphic
= *pGraphic
;
1924 bIsGraphicValid
= TRUE
;
1926 if ( !rUserData
.Len() )
1927 aBtnPreview
.Check();
1931 RaiseLoadError_Impl();
1932 bIsGraphicValid
= FALSE
;
1934 if ( !rUserData
.Len() )
1935 aBtnPreview
.Check( FALSE
);
1939 if ( aBtnPreview
.IsChecked() && bIsGraphicValid
)
1941 Bitmap aBmp
= aBgdGraphic
.GetBitmap();
1942 pPreviewWin2
->NotifyChange( &aBmp
);
1945 pPreviewWin2
->NotifyChange( NULL
);
1947 SetGraphicPosition_Impl( ePos
);
1950 /* -----------------------------09.08.2002 14:04------------------------------
1952 ---------------------------------------------------------------------------*/
1953 void SvxBackgroundTabPage::EnableTransparency(BOOL bColor
, BOOL bGraphic
)
1955 bColTransparency
= bColor
;
1956 bGraphTransparency
= bGraphic
;
1964 Size
aRectSize(aWndPosition
.GetSizePixel());
1965 Point
aRectPos(aWndPosition
.GetPosPixel());
1966 Point
aFLPos(aGraphTransFL
.GetPosPixel());
1967 Size
aTmp(LogicToPixel(Size(RSC_SP_FLGR_SPACE_Y
, RSC_SP_FLGR_SPACE_Y
), MAP_APPFONT
));
1968 long nRectHeight
= aFLPos
.Y() - aRectPos
.Y() - aTmp
.Height();
1969 aRectSize
.Height() = nRectHeight
;
1970 aWndPosition
.SetSizePixel(aRectSize
);
1971 aWndPosition
.Invalidate();
1975 void SvxBackgroundTabPage::PageCreated (SfxAllItemSet aSet
) //add CHINA001
1977 SFX_ITEMSET_ARG (&aSet
,pFlagItem
,SfxUInt32Item
,SID_FLAG_TYPE
,sal_False
);
1980 UINT32 nFlags
=pFlagItem
->GetValue();
1981 if ( ( nFlags
& SVX_SHOW_TBLCTL
) == SVX_SHOW_TBLCTL
)
1983 if ( ( nFlags
& SVX_SHOW_PARACTL
) == SVX_SHOW_PARACTL
)
1985 if ( ( nFlags
& SVX_SHOW_SELECTOR
) == SVX_SHOW_SELECTOR
)
1987 if ( ( nFlags
& SVX_ENABLE_TRANSPARENCY
) == SVX_ENABLE_TRANSPARENCY
)
1988 EnableTransparency(TRUE
, TRUE
);