xref: /trunk/main/cui/source/tabpages/backgrnd.cxx (revision 2ee96f1cdb99d49425d866b1ec4c5567f37285e6)
1*2ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2ee96f1cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2ee96f1cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2ee96f1cSAndrew Rist  * distributed with this work for additional information
6*2ee96f1cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2ee96f1cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2ee96f1cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2ee96f1cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2ee96f1cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2ee96f1cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2ee96f1cSAndrew Rist  * software distributed under the License is distributed on an
15*2ee96f1cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2ee96f1cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2ee96f1cSAndrew Rist  * specific language governing permissions and limitations
18*2ee96f1cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2ee96f1cSAndrew Rist  *************************************************************/
21*2ee96f1cSAndrew Rist 
22*2ee96f1cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
29cdf0e10cSrcweir #include <svl/intitem.hxx>
30cdf0e10cSrcweir #include <vcl/msgbox.hxx>
31cdf0e10cSrcweir #include <tools/urlobj.hxx>
32cdf0e10cSrcweir #include <sfx2/objsh.hxx>
33cdf0e10cSrcweir #include <sfx2/docfile.hxx>
34cdf0e10cSrcweir #include <svtools/wallitem.hxx>
35cdf0e10cSrcweir #include <svl/cntwall.hxx>
36cdf0e10cSrcweir #include <sfx2/cntids.hrc>
37cdf0e10cSrcweir #include <svx/dialogs.hrc>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #define _SVX_BACKGRND_CXX
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <cuires.hrc>
42cdf0e10cSrcweir #include "backgrnd.hrc"
43cdf0e10cSrcweir #include <svx/dialmgr.hxx>
44cdf0e10cSrcweir #include <editeng/memberids.hrc>
45cdf0e10cSrcweir #include <editeng/editrids.hrc>
46cdf0e10cSrcweir #include <editeng/eerdll.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir // Tabellenhintergrund
49cdf0e10cSrcweir #define TBL_DEST_CELL   0
50cdf0e10cSrcweir #define TBL_DEST_ROW    1
51cdf0e10cSrcweir #define TBL_DEST_TBL    2
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #include <editeng/brshitem.hxx>
54cdf0e10cSrcweir #include "backgrnd.hxx"
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include <svx/xtable.hxx>
57cdf0e10cSrcweir #include <sfx2/opengrf.hxx>
58cdf0e10cSrcweir #include <svx/svxerr.hxx>
59cdf0e10cSrcweir #include <svx/drawitem.hxx>
60cdf0e10cSrcweir #include <dialmgr.hxx>
61cdf0e10cSrcweir #include <svx/htmlmode.hxx>
62cdf0e10cSrcweir #include <svtools/controldims.hrc>
63cdf0e10cSrcweir #include <svx/flagsdef.hxx> //CHINA001
64cdf0e10cSrcweir #include <svl/intitem.hxx> //CHINA001
65cdf0e10cSrcweir #include <sfx2/request.hxx> //CHINA001
66cdf0e10cSrcweir using namespace ::com::sun::star;
67cdf0e10cSrcweir // static ----------------------------------------------------------------
68cdf0e10cSrcweir 
69cdf0e10cSrcweir static sal_uInt16 pRanges[] =
70cdf0e10cSrcweir {
71cdf0e10cSrcweir     SID_VIEW_FLD_PIC, SID_VIEW_FLD_PIC,
72cdf0e10cSrcweir     SID_ATTR_BRUSH, SID_ATTR_BRUSH,
73cdf0e10cSrcweir     SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR,
74cdf0e10cSrcweir     0
75cdf0e10cSrcweir };
76cdf0e10cSrcweir 
77cdf0e10cSrcweir struct SvxBackgroundTable_Impl
78cdf0e10cSrcweir {
79cdf0e10cSrcweir     SvxBrushItem*   pCellBrush;
80cdf0e10cSrcweir     SvxBrushItem*   pRowBrush;
81cdf0e10cSrcweir     SvxBrushItem*   pTableBrush;
82cdf0e10cSrcweir     sal_uInt16          nCellWhich;
83cdf0e10cSrcweir     sal_uInt16          nRowWhich;
84cdf0e10cSrcweir     sal_uInt16          nTableWhich;
85cdf0e10cSrcweir     sal_uInt16          nActPos;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     SvxBackgroundTable_Impl() :
88cdf0e10cSrcweir         pCellBrush(NULL), pRowBrush(NULL), pTableBrush(NULL),
89cdf0e10cSrcweir         nCellWhich(0), nRowWhich(0), nTableWhich(0) {}
90cdf0e10cSrcweir };
91cdf0e10cSrcweir 
92cdf0e10cSrcweir struct SvxBackgroundPara_Impl
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     SvxBrushItem*   pParaBrush;
95cdf0e10cSrcweir     SvxBrushItem*   pCharBrush;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     sal_uInt16          nActPos;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     SvxBackgroundPara_Impl() :
100cdf0e10cSrcweir         pParaBrush(NULL), pCharBrush(NULL) {}
101cdf0e10cSrcweir };
102cdf0e10cSrcweir 
103cdf0e10cSrcweir struct SvxBackgroundPage_Impl
104cdf0e10cSrcweir {
105cdf0e10cSrcweir     Timer*          pLoadTimer;
106cdf0e10cSrcweir     sal_Bool            bIsImportDlgInExecute;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     SvxBackgroundPage_Impl() :
109cdf0e10cSrcweir         pLoadTimer(NULL), bIsImportDlgInExecute(sal_False) {}
110cdf0e10cSrcweir };
111cdf0e10cSrcweir /* -----------------------------15.08.2002 12:21------------------------------
112cdf0e10cSrcweir 
113cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
114cdf0e10cSrcweir inline sal_uInt8 lcl_PercentToTransparency(long nPercent)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir     //0xff must not be returned!
117cdf0e10cSrcweir     return sal_uInt8(nPercent ? (50 + 0xfe * nPercent) / 100 : 0);
118cdf0e10cSrcweir }
119cdf0e10cSrcweir inline sal_uInt8 lcl_TransparencyToPercent(sal_uInt8 nTrans)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir     return (nTrans * 100 + 127) / 254;
122cdf0e10cSrcweir }
123cdf0e10cSrcweir void lcl_SetTransparency(SvxBrushItem& rBrush, long nTransparency)
124cdf0e10cSrcweir {
125cdf0e10cSrcweir     uno::Any aTransparency;
126cdf0e10cSrcweir     aTransparency <<= (sal_Int8)nTransparency;
127cdf0e10cSrcweir     rBrush.PutValue(aTransparency, MID_GRAPHIC_TRANSPARENCY);
128cdf0e10cSrcweir }
129cdf0e10cSrcweir //-------------------------------------------------------------------------
130cdf0e10cSrcweir 
131cdf0e10cSrcweir /*  [Beschreibung]
132cdf0e10cSrcweir 
133cdf0e10cSrcweir */
134cdf0e10cSrcweir 
135cdf0e10cSrcweir sal_uInt16 GetItemId_Impl( ValueSet& rValueSet, const Color& rCol )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir     sal_Bool    bFound = sal_False;
138cdf0e10cSrcweir     sal_uInt16  nCount = rValueSet.GetItemCount();
139cdf0e10cSrcweir     sal_uInt16  n      = 1;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     while ( !bFound && n <= nCount )
142cdf0e10cSrcweir     {
143cdf0e10cSrcweir         Color aValCol = rValueSet.GetItemColor(n);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir         bFound = (   aValCol.GetRed()   == rCol.GetRed()
146cdf0e10cSrcweir                   && aValCol.GetGreen() == rCol.GetGreen()
147cdf0e10cSrcweir                   && aValCol.GetBlue()  == rCol.GetBlue() );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir         if ( !bFound )
150cdf0e10cSrcweir             n++;
151cdf0e10cSrcweir     }
152cdf0e10cSrcweir     return bFound ? n : 0;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir // class BackgroundPreview -----------------------------------------------
156cdf0e10cSrcweir 
157cdf0e10cSrcweir /*  [Beschreibung]
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     Vorschaufenster f"ur Brush oder Bitmap
160cdf0e10cSrcweir */
161cdf0e10cSrcweir 
162cdf0e10cSrcweir class BackgroundPreviewImpl : public Window
163cdf0e10cSrcweir {
164cdf0e10cSrcweir public:
165cdf0e10cSrcweir     BackgroundPreviewImpl( Window* pParent,
166cdf0e10cSrcweir                            const ResId& rResId, sal_Bool bIsBmpPreview );
167cdf0e10cSrcweir     ~BackgroundPreviewImpl();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     void            NotifyChange( const Color&  rColor );
170cdf0e10cSrcweir     void            NotifyChange( const Bitmap* pBitmap );
171cdf0e10cSrcweir 
172cdf0e10cSrcweir protected:
173cdf0e10cSrcweir     virtual void    Paint( const Rectangle& rRect );
174cdf0e10cSrcweir     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir private:
177cdf0e10cSrcweir     const sal_Bool      bIsBmp;
178cdf0e10cSrcweir     Bitmap*         pBitmap;
179cdf0e10cSrcweir     Point           aDrawPos;
180cdf0e10cSrcweir     Size            aDrawSize;
181cdf0e10cSrcweir     Rectangle       aDrawRect;
182cdf0e10cSrcweir     sal_uInt8            nTransparency;
183cdf0e10cSrcweir };
184cdf0e10cSrcweir 
185cdf0e10cSrcweir //-----------------------------------------------------------------------
186cdf0e10cSrcweir 
187cdf0e10cSrcweir BackgroundPreviewImpl::BackgroundPreviewImpl
188cdf0e10cSrcweir (
189cdf0e10cSrcweir     Window* pParent,
190cdf0e10cSrcweir     const ResId& rResId,
191cdf0e10cSrcweir     sal_Bool bIsBmpPreview
192cdf0e10cSrcweir ) :
193cdf0e10cSrcweir 
194cdf0e10cSrcweir /*  [Beschreibung]
195cdf0e10cSrcweir 
196cdf0e10cSrcweir */
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     Window( pParent, rResId ),
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     bIsBmp   ( bIsBmpPreview ),
201cdf0e10cSrcweir     pBitmap  ( NULL ),
202cdf0e10cSrcweir     aDrawRect( Point(0,0), GetOutputSizePixel() ),
203cdf0e10cSrcweir     nTransparency(0)
204cdf0e10cSrcweir 
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     SetBorderStyle(WINDOW_BORDER_MONO);
207cdf0e10cSrcweir     Paint( aDrawRect );
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir //-----------------------------------------------------------------------
211cdf0e10cSrcweir 
212cdf0e10cSrcweir BackgroundPreviewImpl::~BackgroundPreviewImpl()
213cdf0e10cSrcweir 
214cdf0e10cSrcweir /*  [Beschreibung]
215cdf0e10cSrcweir 
216cdf0e10cSrcweir */
217cdf0e10cSrcweir 
218cdf0e10cSrcweir {
219cdf0e10cSrcweir     delete pBitmap;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
222cdf0e10cSrcweir //-----------------------------------------------------------------------
223cdf0e10cSrcweir void BackgroundPreviewImpl::NotifyChange( const Color& rColor )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir     if ( !bIsBmp )
226cdf0e10cSrcweir     {
227cdf0e10cSrcweir         const static Color aTranspCol( COL_TRANSPARENT );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir         nTransparency = lcl_TransparencyToPercent( rColor.GetTransparency() );
230cdf0e10cSrcweir 
231cdf0e10cSrcweir         SetFillColor( rColor == aTranspCol ? GetSettings().GetStyleSettings().GetFieldColor() : (Color) rColor.GetRGBColor() );
232cdf0e10cSrcweir         Paint( aDrawRect );
233cdf0e10cSrcweir     }
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir //-----------------------------------------------------------------------
237cdf0e10cSrcweir 
238cdf0e10cSrcweir void BackgroundPreviewImpl::NotifyChange( const Bitmap* pNewBitmap )
239cdf0e10cSrcweir /*  [Beschreibung]
240cdf0e10cSrcweir 
241cdf0e10cSrcweir */
242cdf0e10cSrcweir 
243cdf0e10cSrcweir {
244cdf0e10cSrcweir     if ( bIsBmp && (pNewBitmap || pBitmap) )
245cdf0e10cSrcweir     {
246cdf0e10cSrcweir         if ( pNewBitmap && pBitmap )
247cdf0e10cSrcweir             *pBitmap = *pNewBitmap;
248cdf0e10cSrcweir         else if ( pNewBitmap && !pBitmap )
249cdf0e10cSrcweir             pBitmap = new Bitmap( *pNewBitmap );
250cdf0e10cSrcweir         else if ( !pNewBitmap )
251cdf0e10cSrcweir             DELETEZ( pBitmap );
252cdf0e10cSrcweir 
253cdf0e10cSrcweir         if ( pBitmap )
254cdf0e10cSrcweir         {
255cdf0e10cSrcweir             Size aSize = GetOutputSizePixel();
256cdf0e10cSrcweir             // InnerSize == Size without one pixel border
257cdf0e10cSrcweir             Size aInnerSize = aSize;
258cdf0e10cSrcweir             aInnerSize.Width() -= 2;
259cdf0e10cSrcweir             aInnerSize.Height() -= 2;
260cdf0e10cSrcweir             aDrawSize = pBitmap->GetSizePixel();
261cdf0e10cSrcweir 
262cdf0e10cSrcweir             // bitmap bigger than preview window?
263cdf0e10cSrcweir             if ( aDrawSize.Width() > aInnerSize.Width() )
264cdf0e10cSrcweir             {
265cdf0e10cSrcweir                 aDrawSize.Height() = aDrawSize.Height() * aInnerSize.Width() / aDrawSize.Width();
266cdf0e10cSrcweir                 if ( aDrawSize.Height() > aInnerSize.Height() )
267cdf0e10cSrcweir                 {
268cdf0e10cSrcweir                     aDrawSize.Width() = aDrawSize.Height();
269cdf0e10cSrcweir                     aDrawSize.Height() = aInnerSize.Height();
270cdf0e10cSrcweir                 }
271cdf0e10cSrcweir                 else
272cdf0e10cSrcweir                     aDrawSize.Width() = aInnerSize.Width();
273cdf0e10cSrcweir             }
274cdf0e10cSrcweir             else if ( aDrawSize.Height() > aInnerSize.Height() )
275cdf0e10cSrcweir             {
276cdf0e10cSrcweir                 aDrawSize.Width() = aDrawSize.Width() * aInnerSize.Height() / aDrawSize.Height();
277cdf0e10cSrcweir                 if ( aDrawSize.Width() > aInnerSize.Width() )
278cdf0e10cSrcweir                 {
279cdf0e10cSrcweir                     aDrawSize.Height() = aDrawSize.Width();
280cdf0e10cSrcweir                     aDrawSize.Width() = aInnerSize.Width();
281cdf0e10cSrcweir                 }
282cdf0e10cSrcweir                 else
283cdf0e10cSrcweir                     aDrawSize.Height() = aInnerSize.Height();
284cdf0e10cSrcweir             }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir             aDrawPos.X() = (aSize.Width()  - aDrawSize.Width())  / 2;
287cdf0e10cSrcweir             aDrawPos.Y() = (aSize.Height() - aDrawSize.Height()) / 2;
288cdf0e10cSrcweir         }
289cdf0e10cSrcweir         Invalidate( aDrawRect );
290cdf0e10cSrcweir         Update();
291cdf0e10cSrcweir     }
292cdf0e10cSrcweir }
293cdf0e10cSrcweir 
294cdf0e10cSrcweir //-----------------------------------------------------------------------
295cdf0e10cSrcweir 
296cdf0e10cSrcweir void BackgroundPreviewImpl::Paint( const Rectangle& )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
299cdf0e10cSrcweir     SetBackground(Wallpaper(rStyleSettings.GetWindowColor()));
300cdf0e10cSrcweir     SetLineColor();
301cdf0e10cSrcweir     if(bIsBmp)
302cdf0e10cSrcweir         SetFillColor( Color(COL_TRANSPARENT) );
303cdf0e10cSrcweir     DrawRect( aDrawRect );
304cdf0e10cSrcweir     if ( bIsBmp )
305cdf0e10cSrcweir     {
306cdf0e10cSrcweir         if ( pBitmap )
307cdf0e10cSrcweir             DrawBitmap( aDrawPos, aDrawSize, *pBitmap );
308cdf0e10cSrcweir         else
309cdf0e10cSrcweir         {
310cdf0e10cSrcweir             Size aSize = GetOutputSizePixel();
311cdf0e10cSrcweir             DrawLine( Point(0,0),               Point(aSize.Width(),aSize.Height()) );
312cdf0e10cSrcweir             DrawLine( Point(0,aSize.Height()),  Point(aSize.Width(),0) );
313cdf0e10cSrcweir         }
314cdf0e10cSrcweir     }
315cdf0e10cSrcweir }
316cdf0e10cSrcweir /* -----------------------------27.02.2002 11:07------------------------------
317cdf0e10cSrcweir 
318cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
319cdf0e10cSrcweir void BackgroundPreviewImpl::DataChanged( const DataChangedEvent& rDCEvt )
320cdf0e10cSrcweir {
321cdf0e10cSrcweir     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
322cdf0e10cSrcweir          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
323cdf0e10cSrcweir     {
324cdf0e10cSrcweir         Invalidate();
325cdf0e10cSrcweir     }
326cdf0e10cSrcweir     Window::DataChanged( rDCEvt );
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir // class SvxBackgroundTabPage --------------------------------------------
330cdf0e10cSrcweir 
331cdf0e10cSrcweir #define HDL(hdl) LINK(this,SvxBackgroundTabPage,hdl)
332cdf0e10cSrcweir 
333cdf0e10cSrcweir SvxBackgroundTabPage::SvxBackgroundTabPage( Window* pParent,
334cdf0e10cSrcweir                                             const SfxItemSet& rCoreSet ) :
335cdf0e10cSrcweir 
336cdf0e10cSrcweir /*  [Beschreibung]
337cdf0e10cSrcweir 
338cdf0e10cSrcweir */
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     SvxTabPage( pParent, CUI_RES( RID_SVXPAGE_BACKGROUND ), rCoreSet ),
341cdf0e10cSrcweir 
342cdf0e10cSrcweir     aSelectTxt          ( this, CUI_RES( FT_SELECTOR ) ),
343cdf0e10cSrcweir     aLbSelect           ( this, CUI_RES( LB_SELECTOR ) ),
344cdf0e10cSrcweir     aStrBrowse          ( CUI_RES( STR_BROWSE ) ),
345cdf0e10cSrcweir     aStrUnlinked        ( CUI_RES( STR_UNLINKED ) ),
346cdf0e10cSrcweir     aTblDesc            ( this, CUI_RES( FT_TBL_DESC ) ),
347cdf0e10cSrcweir     aTblLBox            ( this, CUI_RES( LB_TBL_BOX ) ),
348cdf0e10cSrcweir     aParaLBox           ( this, CUI_RES( LB_PARA_BOX ) ),
349cdf0e10cSrcweir 
350cdf0e10cSrcweir     aBorderWin          ( this, CUI_RES(CT_BORDER) ),
351cdf0e10cSrcweir     aBackgroundColorSet ( &aBorderWin, CUI_RES( SET_BGDCOLOR ) ),
352cdf0e10cSrcweir     aBackgroundColorBox ( this, CUI_RES( GB_BGDCOLOR ) ),
353cdf0e10cSrcweir     pPreviewWin1        ( new BackgroundPreviewImpl( this, CUI_RES( WIN_PREVIEW1 ), sal_False ) ),
354cdf0e10cSrcweir 
355cdf0e10cSrcweir     aColTransFT         ( this, CUI_RES( FT_COL_TRANS ) ),
356cdf0e10cSrcweir     aColTransMF         ( this, CUI_RES( MF_COL_TRANS ) ),
357cdf0e10cSrcweir     aBtnPreview         ( this, CUI_RES( BTN_PREVIEW ) ),
358cdf0e10cSrcweir     aGbFile             ( this, CUI_RES( GB_FILE ) ),
359cdf0e10cSrcweir     aBtnBrowse          ( this, CUI_RES( BTN_BROWSE ) ),
360cdf0e10cSrcweir     aBtnLink            ( this, CUI_RES( BTN_LINK ) ),
361cdf0e10cSrcweir     aGbPosition         ( this, CUI_RES( GB_POSITION ) ),
362cdf0e10cSrcweir     aBtnPosition        ( this, CUI_RES( BTN_POSITION ) ),
363cdf0e10cSrcweir     aBtnArea            ( this, CUI_RES( BTN_AREA ) ),
364cdf0e10cSrcweir     aBtnTile            ( this, CUI_RES( BTN_TILE ) ),
365cdf0e10cSrcweir     aWndPosition        ( this, CUI_RES( WND_POSITION ), RP_MM ),
366cdf0e10cSrcweir     aFtFile             ( this, CUI_RES( FT_FILE ) ),
367cdf0e10cSrcweir     aGraphTransFL       ( this, CUI_RES( FL_GRAPH_TRANS ) ),
368cdf0e10cSrcweir     aGraphTransMF       ( this, CUI_RES( MF_GRAPH_TRANS ) ),
369cdf0e10cSrcweir     pPreviewWin2        ( new BackgroundPreviewImpl(
370cdf0e10cSrcweir                             this, CUI_RES( WIN_PREVIEW2 ), sal_True ) ),
371cdf0e10cSrcweir 
372cdf0e10cSrcweir     nHtmlMode           ( 0 ),
373cdf0e10cSrcweir     bAllowShowSelector  ( sal_True ),
374cdf0e10cSrcweir     bIsGraphicValid     ( sal_False ),
375cdf0e10cSrcweir     bLinkOnly           ( sal_False ),
376cdf0e10cSrcweir     bResized            ( sal_False ),
377cdf0e10cSrcweir     bColTransparency    ( sal_False ),
378cdf0e10cSrcweir     bGraphTransparency  ( sal_False ),
379cdf0e10cSrcweir 
380cdf0e10cSrcweir     pPageImpl           ( new SvxBackgroundPage_Impl ),
381cdf0e10cSrcweir     pImportDlg          ( NULL ),
382cdf0e10cSrcweir     pTableBck_Impl      ( NULL ),
383cdf0e10cSrcweir     pParaBck_Impl       ( NULL )
384cdf0e10cSrcweir 
385cdf0e10cSrcweir {
386cdf0e10cSrcweir     // diese Page braucht ExchangeSupport
387cdf0e10cSrcweir     SetExchangeSupport();
388cdf0e10cSrcweir 
389cdf0e10cSrcweir     const SfxPoolItem* pItem;
390cdf0e10cSrcweir     SfxObjectShell* pShell;
391cdf0e10cSrcweir 
392cdf0e10cSrcweir     if ( SFX_ITEM_SET == rCoreSet.GetItemState( SID_HTML_MODE, sal_False, &pItem )
393cdf0e10cSrcweir          || ( 0 != ( pShell = SfxObjectShell::Current()) &&
394cdf0e10cSrcweir               0 != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
395cdf0e10cSrcweir     {
396cdf0e10cSrcweir         nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
397cdf0e10cSrcweir     }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir     FillColorValueSets_Impl();
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     aBackgroundColorSet.SetSelectHdl( HDL(BackgroundColorHdl_Impl) );
402cdf0e10cSrcweir     FreeResource();
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     aBtnBrowse.SetAccessibleRelationMemberOf(&aGbFile);
405cdf0e10cSrcweir     aWndPosition.SetAccessibleRelationMemberOf(&aGbPosition);
406cdf0e10cSrcweir     aWndPosition.SetAccessibleRelationLabeledBy(&aBtnPosition);
407cdf0e10cSrcweir     aBackgroundColorSet.SetAccessibleRelationLabeledBy(&aBackgroundColorBox);
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir //------------------------------------------------------------------------
411cdf0e10cSrcweir 
412cdf0e10cSrcweir SvxBackgroundTabPage::~SvxBackgroundTabPage()
413cdf0e10cSrcweir 
414cdf0e10cSrcweir /*  [Beschreibung]
415cdf0e10cSrcweir 
416cdf0e10cSrcweir */
417cdf0e10cSrcweir 
418cdf0e10cSrcweir {
419cdf0e10cSrcweir     delete pPreviewWin1;
420cdf0e10cSrcweir     delete pPreviewWin2;
421cdf0e10cSrcweir     delete pPageImpl->pLoadTimer;
422cdf0e10cSrcweir     delete pPageImpl;
423cdf0e10cSrcweir     delete pImportDlg;
424cdf0e10cSrcweir 
425cdf0e10cSrcweir     if( pTableBck_Impl)
426cdf0e10cSrcweir     {
427cdf0e10cSrcweir         delete pTableBck_Impl->pCellBrush;
428cdf0e10cSrcweir         delete pTableBck_Impl->pRowBrush;
429cdf0e10cSrcweir         delete pTableBck_Impl->pTableBrush;
430cdf0e10cSrcweir         delete pTableBck_Impl;
431cdf0e10cSrcweir     }
432cdf0e10cSrcweir 
433cdf0e10cSrcweir     if(pParaBck_Impl)
434cdf0e10cSrcweir     {
435cdf0e10cSrcweir         delete pParaBck_Impl->pParaBrush;
436cdf0e10cSrcweir         delete pParaBck_Impl->pCharBrush;
437cdf0e10cSrcweir         delete pParaBck_Impl;
438cdf0e10cSrcweir     }
439cdf0e10cSrcweir }
440cdf0e10cSrcweir 
441cdf0e10cSrcweir //------------------------------------------------------------------------
442cdf0e10cSrcweir 
443cdf0e10cSrcweir sal_uInt16* SvxBackgroundTabPage::GetRanges()
444cdf0e10cSrcweir 
445cdf0e10cSrcweir /*  [Beschreibung]
446cdf0e10cSrcweir 
447cdf0e10cSrcweir     gibt den Bereich der Which-Werte zur"uck
448cdf0e10cSrcweir */
449cdf0e10cSrcweir 
450cdf0e10cSrcweir {
451cdf0e10cSrcweir     return pRanges;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir //------------------------------------------------------------------------
455cdf0e10cSrcweir 
456cdf0e10cSrcweir SfxTabPage* SvxBackgroundTabPage::Create( Window* pParent,
457cdf0e10cSrcweir                                           const SfxItemSet& rAttrSet )
458cdf0e10cSrcweir 
459cdf0e10cSrcweir /*  [Beschreibung]
460cdf0e10cSrcweir 
461cdf0e10cSrcweir     Create-Methode f"ur den TabDialog
462cdf0e10cSrcweir */
463cdf0e10cSrcweir 
464cdf0e10cSrcweir {
465cdf0e10cSrcweir     return ( new SvxBackgroundTabPage( pParent, rAttrSet ) );
466cdf0e10cSrcweir }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir //------------------------------------------------------------------------
469cdf0e10cSrcweir 
470cdf0e10cSrcweir void SvxBackgroundTabPage::Reset( const SfxItemSet& rSet )
471cdf0e10cSrcweir 
472cdf0e10cSrcweir /*  [Beschreibung]
473cdf0e10cSrcweir 
474cdf0e10cSrcweir */
475cdf0e10cSrcweir 
476cdf0e10cSrcweir {
477cdf0e10cSrcweir // os: So ein Unsinn! Irgendwo laesst sich so ein Item immer finden,
478cdf0e10cSrcweir //      es muss aber im rSet vorhanden sein!
479cdf0e10cSrcweir //  const SfxPoolItem* pX = GetOldItem( rSet, SID_VIEW_FLD_PIC );
480cdf0e10cSrcweir //  if( pX && pX->ISA(SfxWallpaperItem))
481cdf0e10cSrcweir     if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(GetWhich(SID_VIEW_FLD_PIC), sal_False))
482cdf0e10cSrcweir     {
483cdf0e10cSrcweir         ResetFromWallpaperItem( rSet );
484cdf0e10cSrcweir         return;
485cdf0e10cSrcweir     }
486cdf0e10cSrcweir 
487cdf0e10cSrcweir     // Zustand des Vorschau-Buttons durch UserData persistent
488cdf0e10cSrcweir     String aUserData = GetUserData();
489cdf0e10cSrcweir     aBtnPreview.Check( aUserData.Len() && sal_Unicode('1') == aUserData.GetChar( 0 ) );
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     // nach Reset kein ShowSelector() mehr aufrufen d"urfen
492cdf0e10cSrcweir     bAllowShowSelector = sal_False;
493cdf0e10cSrcweir 
494cdf0e10cSrcweir 
495cdf0e10cSrcweir     // Input-BrushItem besorgen und auswerten
496cdf0e10cSrcweir     const SvxBrushItem* pBgdAttr = NULL;
497cdf0e10cSrcweir     sal_uInt16 nSlot = SID_ATTR_BRUSH;
498cdf0e10cSrcweir     const SfxPoolItem* pItem;
499cdf0e10cSrcweir     sal_uInt16 nDestValue = USHRT_MAX;
500cdf0e10cSrcweir 
501cdf0e10cSrcweir     if ( SFX_ITEM_SET == rSet.GetItemState( SID_BACKGRND_DESTINATION,
502cdf0e10cSrcweir                                             sal_False, &pItem ) )
503cdf0e10cSrcweir     {
504cdf0e10cSrcweir         nDestValue = ((const SfxUInt16Item*)pItem)->GetValue();
505cdf0e10cSrcweir         aTblLBox.SelectEntryPos(nDestValue);
506cdf0e10cSrcweir 
507cdf0e10cSrcweir         switch ( nDestValue )
508cdf0e10cSrcweir         {
509cdf0e10cSrcweir             case TBL_DEST_CELL:
510cdf0e10cSrcweir                 nSlot = SID_ATTR_BRUSH;
511cdf0e10cSrcweir             break;
512cdf0e10cSrcweir             case TBL_DEST_ROW:
513cdf0e10cSrcweir                 nSlot = SID_ATTR_BRUSH_ROW;
514cdf0e10cSrcweir             break;
515cdf0e10cSrcweir             case TBL_DEST_TBL:
516cdf0e10cSrcweir                 nSlot = SID_ATTR_BRUSH_TABLE;
517cdf0e10cSrcweir             break;
518cdf0e10cSrcweir         }
519cdf0e10cSrcweir     }
520cdf0e10cSrcweir     else if( SFX_ITEM_SET == rSet.GetItemState(
521cdf0e10cSrcweir                 SID_PARA_BACKGRND_DESTINATION, sal_False, &pItem ) )
522cdf0e10cSrcweir     {
523cdf0e10cSrcweir         nDestValue = ((const SfxUInt16Item*)pItem)->GetValue();
524cdf0e10cSrcweir         // ist gerade Zeichen aktiviert?
525cdf0e10cSrcweir         sal_uInt16 nParaSel  = aParaLBox.GetSelectEntryPos();
526cdf0e10cSrcweir         if(1 == nParaSel)
527cdf0e10cSrcweir         {
528cdf0e10cSrcweir             // dann war das ein "Standard" - Aufruf
529cdf0e10cSrcweir             nDestValue = nParaSel;
530cdf0e10cSrcweir         }
531cdf0e10cSrcweir         aParaLBox.SelectEntryPos(nDestValue);
532cdf0e10cSrcweir 
533cdf0e10cSrcweir         switch ( nDestValue )
534cdf0e10cSrcweir         {
535cdf0e10cSrcweir             case PARA_DEST_PARA:
536cdf0e10cSrcweir                 nSlot = SID_ATTR_BRUSH;
537cdf0e10cSrcweir             break;
538cdf0e10cSrcweir             case PARA_DEST_CHAR:
539cdf0e10cSrcweir                 nSlot = SID_ATTR_BRUSH_CHAR;
540cdf0e10cSrcweir             break;
541cdf0e10cSrcweir         }
542cdf0e10cSrcweir     }
543cdf0e10cSrcweir     //#111173# the destination item is missing when the parent style has been changed
544cdf0e10cSrcweir     if(USHRT_MAX == nDestValue && (aParaLBox.IsVisible()||aTblLBox.IsVisible()))
545cdf0e10cSrcweir         nDestValue = 0;
546cdf0e10cSrcweir     sal_uInt16 nWhich = GetWhich( nSlot );
547cdf0e10cSrcweir 
548cdf0e10cSrcweir     if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE )
549cdf0e10cSrcweir         pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) );
550cdf0e10cSrcweir 
551cdf0e10cSrcweir     aBtnTile.Check();
552cdf0e10cSrcweir 
553cdf0e10cSrcweir     if ( pBgdAttr )
554cdf0e10cSrcweir     {
555cdf0e10cSrcweir         FillControls_Impl(*pBgdAttr, aUserData);
556cdf0e10cSrcweir         aBgdColor = ( (SvxBrushItem*)pBgdAttr )->GetColor();
557cdf0e10cSrcweir     }
558cdf0e10cSrcweir     else
559cdf0e10cSrcweir     {
560cdf0e10cSrcweir         aSelectTxt.Hide();
561cdf0e10cSrcweir         aLbSelect.Hide();
562cdf0e10cSrcweir         aLbSelect.SelectEntryPos( 0 );
563cdf0e10cSrcweir         ShowColorUI_Impl();
564cdf0e10cSrcweir 
565cdf0e10cSrcweir         const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_BRUSH );
566cdf0e10cSrcweir 
567cdf0e10cSrcweir         if ( pOld )
568cdf0e10cSrcweir             aBgdColor = ( (SvxBrushItem*)pOld )->GetColor();
569cdf0e10cSrcweir     }
570cdf0e10cSrcweir 
571cdf0e10cSrcweir     if ( nDestValue != USHRT_MAX )
572cdf0e10cSrcweir     {
573cdf0e10cSrcweir         if(aTblLBox.IsVisible())
574cdf0e10cSrcweir         {
575cdf0e10cSrcweir             sal_uInt16 nValue = aTblLBox.GetSelectEntryPos();
576cdf0e10cSrcweir 
577cdf0e10cSrcweir             if ( pTableBck_Impl )
578cdf0e10cSrcweir             {
579cdf0e10cSrcweir                 DELETEZ( pTableBck_Impl->pCellBrush);
580cdf0e10cSrcweir                 DELETEZ( pTableBck_Impl->pRowBrush);
581cdf0e10cSrcweir                 DELETEZ( pTableBck_Impl->pTableBrush);
582cdf0e10cSrcweir             }
583cdf0e10cSrcweir             else
584cdf0e10cSrcweir                 pTableBck_Impl = new SvxBackgroundTable_Impl();
585cdf0e10cSrcweir 
586cdf0e10cSrcweir             pTableBck_Impl->nActPos = nValue;
587cdf0e10cSrcweir 
588cdf0e10cSrcweir             nWhich = GetWhich( SID_ATTR_BRUSH );
589cdf0e10cSrcweir             if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE )
590cdf0e10cSrcweir             {
591cdf0e10cSrcweir                 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) );
592cdf0e10cSrcweir                 pTableBck_Impl->pCellBrush = new SvxBrushItem(*pBgdAttr);
593cdf0e10cSrcweir             }
594cdf0e10cSrcweir             pTableBck_Impl->nCellWhich = nWhich;
595cdf0e10cSrcweir 
596cdf0e10cSrcweir             if ( rSet.GetItemState( SID_ATTR_BRUSH_ROW, sal_False ) >= SFX_ITEM_AVAILABLE )
597cdf0e10cSrcweir             {
598cdf0e10cSrcweir                 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( SID_ATTR_BRUSH_ROW ) );
599cdf0e10cSrcweir                 pTableBck_Impl->pRowBrush = new SvxBrushItem(*pBgdAttr);
600cdf0e10cSrcweir             }
601cdf0e10cSrcweir             pTableBck_Impl->nRowWhich = SID_ATTR_BRUSH_ROW;
602cdf0e10cSrcweir 
603cdf0e10cSrcweir             if ( rSet.GetItemState( SID_ATTR_BRUSH_TABLE, sal_False ) >= SFX_ITEM_AVAILABLE )
604cdf0e10cSrcweir             {
605cdf0e10cSrcweir                 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( SID_ATTR_BRUSH_TABLE ) );
606cdf0e10cSrcweir                 pTableBck_Impl->pTableBrush = new SvxBrushItem(*pBgdAttr);
607cdf0e10cSrcweir             }
608cdf0e10cSrcweir             pTableBck_Impl->nTableWhich = SID_ATTR_BRUSH_TABLE;
609cdf0e10cSrcweir 
610cdf0e10cSrcweir             TblDestinationHdl_Impl(&aTblLBox);
611cdf0e10cSrcweir             aTblLBox.SaveValue();
612cdf0e10cSrcweir         }
613cdf0e10cSrcweir         else
614cdf0e10cSrcweir         {
615cdf0e10cSrcweir             sal_uInt16 nValue = aParaLBox.GetSelectEntryPos();
616cdf0e10cSrcweir 
617cdf0e10cSrcweir             if ( pParaBck_Impl )
618cdf0e10cSrcweir             {
619cdf0e10cSrcweir                 delete pParaBck_Impl->pParaBrush;
620cdf0e10cSrcweir                 delete pParaBck_Impl->pCharBrush;
621cdf0e10cSrcweir             }
622cdf0e10cSrcweir             else
623cdf0e10cSrcweir                 pParaBck_Impl = new SvxBackgroundPara_Impl();
624cdf0e10cSrcweir 
625cdf0e10cSrcweir             pParaBck_Impl->nActPos = nValue;
626cdf0e10cSrcweir 
627cdf0e10cSrcweir             nWhich = GetWhich( SID_ATTR_BRUSH );
628cdf0e10cSrcweir             if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE )
629cdf0e10cSrcweir             {
630cdf0e10cSrcweir                 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) );
631cdf0e10cSrcweir                 pParaBck_Impl->pParaBrush = new SvxBrushItem(*pBgdAttr);
632cdf0e10cSrcweir             }
633cdf0e10cSrcweir 
634cdf0e10cSrcweir             nWhich = GetWhich( SID_ATTR_BRUSH_CHAR );
635cdf0e10cSrcweir             SfxItemState eState = rSet.GetItemState( nWhich, sal_True );
636cdf0e10cSrcweir             eState = rSet.GetItemState( nWhich, sal_False );
637cdf0e10cSrcweir             if ( rSet.GetItemState( nWhich, sal_True ) > SFX_ITEM_AVAILABLE )
638cdf0e10cSrcweir             {
639cdf0e10cSrcweir                 pBgdAttr = (const SvxBrushItem*)&( rSet.Get( nWhich ) );
640cdf0e10cSrcweir                 pParaBck_Impl->pCharBrush = new SvxBrushItem(*pBgdAttr);
641cdf0e10cSrcweir             }
642cdf0e10cSrcweir             else
643cdf0e10cSrcweir                 pParaBck_Impl->pCharBrush = new SvxBrushItem(SID_ATTR_BRUSH_CHAR);
644cdf0e10cSrcweir 
645cdf0e10cSrcweir             ParaDestinationHdl_Impl(&aParaLBox);
646cdf0e10cSrcweir             aParaLBox.SaveValue();
647cdf0e10cSrcweir         }
648cdf0e10cSrcweir     }
649cdf0e10cSrcweir     if(!bResized)
650cdf0e10cSrcweir     {
651cdf0e10cSrcweir         if(!aLbSelect.IsVisible() && !aTblLBox.IsVisible() && !aParaLBox.IsVisible())
652cdf0e10cSrcweir         {
653cdf0e10cSrcweir             long nY(LogicToPixel(Point(11,14), MAP_APPFONT).X());
654cdf0e10cSrcweir             long nX(LogicToPixel(Point(11,14), MAP_APPFONT).Y());
655cdf0e10cSrcweir             Point aPos(aBorderWin.GetPosPixel());
656cdf0e10cSrcweir             aPos.X() = nX;
657cdf0e10cSrcweir             aPos.Y() = nY;
658cdf0e10cSrcweir             aBorderWin.SetPosPixel(aPos);
659cdf0e10cSrcweir             aPos = pPreviewWin1->GetPosPixel();
660cdf0e10cSrcweir             aPos.Y()  = nY;
661cdf0e10cSrcweir             pPreviewWin1->SetPosPixel(aPos);
662cdf0e10cSrcweir             aBackgroundColorBox.Hide();
663cdf0e10cSrcweir             aBackgroundColorSet.SetAccessibleRelationLabeledBy(&aBackgroundColorSet);
664cdf0e10cSrcweir         }
665cdf0e10cSrcweir     }
666cdf0e10cSrcweir }
667cdf0e10cSrcweir 
668cdf0e10cSrcweir void SvxBackgroundTabPage::ResetFromWallpaperItem( const SfxItemSet& rSet )
669cdf0e10cSrcweir {
670cdf0e10cSrcweir     ShowSelector();
671cdf0e10cSrcweir 
672cdf0e10cSrcweir     // Zustand des Vorschau-Buttons durch UserData persistent
673cdf0e10cSrcweir     String aUserData = GetUserData();
674cdf0e10cSrcweir     aBtnPreview.Check( aUserData.Len() && sal_Unicode('1') == aUserData.GetChar( 0 ) );
675cdf0e10cSrcweir 
676cdf0e10cSrcweir     // Input-BrushItem besorgen und auswerten
677cdf0e10cSrcweir     const SvxBrushItem* pBgdAttr = NULL;
678cdf0e10cSrcweir     sal_uInt16 nSlot = SID_VIEW_FLD_PIC;
679cdf0e10cSrcweir     sal_uInt16 nWhich = GetWhich( nSlot );
680cdf0e10cSrcweir     SvxBrushItem* pTemp = 0;
681cdf0e10cSrcweir     const CntWallpaperItem* pItem = 0;
682cdf0e10cSrcweir 
683cdf0e10cSrcweir     if ( rSet.GetItemState( nWhich, sal_False ) >= SFX_ITEM_AVAILABLE )
684cdf0e10cSrcweir     {
685cdf0e10cSrcweir         pItem = (const CntWallpaperItem*)&rSet.Get( nWhich );
686cdf0e10cSrcweir         pTemp = new SvxBrushItem( *pItem, nWhich );
687cdf0e10cSrcweir         pBgdAttr = pTemp;
688cdf0e10cSrcweir     }
689cdf0e10cSrcweir 
690cdf0e10cSrcweir     aBtnTile.Check();
691cdf0e10cSrcweir 
692cdf0e10cSrcweir     if ( pBgdAttr )
693cdf0e10cSrcweir     {
694cdf0e10cSrcweir         FillControls_Impl(*pBgdAttr, aUserData);
695cdf0e10cSrcweir         // Auch bei Anzeige der Grafik, soll die Brush erhalten bleiben
696cdf0e10cSrcweir         if( aBgdColor != pBgdAttr->GetColor() )
697cdf0e10cSrcweir         {
698cdf0e10cSrcweir             aBgdColor = pBgdAttr->GetColor();
699cdf0e10cSrcweir             sal_uInt16 nCol = GetItemId_Impl( aBackgroundColorSet, aBgdColor );
700cdf0e10cSrcweir             aBackgroundColorSet.SelectItem( nCol );
701cdf0e10cSrcweir             pPreviewWin1->NotifyChange( aBgdColor );
702cdf0e10cSrcweir         }
703cdf0e10cSrcweir     }
704cdf0e10cSrcweir     else
705cdf0e10cSrcweir     {
706cdf0e10cSrcweir         aLbSelect.SelectEntryPos( 0 );
707cdf0e10cSrcweir         ShowColorUI_Impl();
708cdf0e10cSrcweir 
709cdf0e10cSrcweir         const SfxPoolItem* pOld = GetOldItem( rSet, SID_VIEW_FLD_PIC );
710cdf0e10cSrcweir         if ( pOld )
711cdf0e10cSrcweir             aBgdColor = Color( ((CntWallpaperItem*)pOld)->GetColor() );
712cdf0e10cSrcweir     }
713cdf0e10cSrcweir 
714cdf0e10cSrcweir     // We now have always a link to the background
715cdf0e10cSrcweir     bLinkOnly = sal_True;
716cdf0e10cSrcweir     aBtnLink.Check( sal_True );
717cdf0e10cSrcweir     aBtnLink.Show( sal_False );
718cdf0e10cSrcweir //  if( !pItem || !pItem->GetWallpaper(sal_False).IsBitmap() )
719cdf0e10cSrcweir //      aBtnLink.Check();
720cdf0e10cSrcweir 
721cdf0e10cSrcweir     delete pTemp;
722cdf0e10cSrcweir }
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 
725cdf0e10cSrcweir 
726cdf0e10cSrcweir //------------------------------------------------------------------------
727cdf0e10cSrcweir 
728cdf0e10cSrcweir void SvxBackgroundTabPage::FillUserData()
729cdf0e10cSrcweir 
730cdf0e10cSrcweir /*  [Beschreibung]
731cdf0e10cSrcweir 
732cdf0e10cSrcweir     Beim Destruieren einer SfxTabPage wird diese virtuelle Methode gerufen,
733cdf0e10cSrcweir     damit die TabPage interne Informationen sichern kann.
734cdf0e10cSrcweir 
735cdf0e10cSrcweir     In diesem Fall wird der Zustand des Vorschau-Buttons gesichert.
736cdf0e10cSrcweir */
737cdf0e10cSrcweir 
738cdf0e10cSrcweir {
739cdf0e10cSrcweir     SetUserData( String( aBtnPreview.IsChecked() ? sal_Unicode('1') : sal_Unicode('0') ) );
740cdf0e10cSrcweir }
741cdf0e10cSrcweir 
742cdf0e10cSrcweir //------------------------------------------------------------------------
743cdf0e10cSrcweir 
744cdf0e10cSrcweir sal_Bool SvxBackgroundTabPage::FillItemSet( SfxItemSet& rCoreSet )
745cdf0e10cSrcweir 
746cdf0e10cSrcweir /*  [Beschreibung]
747cdf0e10cSrcweir 
748cdf0e10cSrcweir */
749cdf0e10cSrcweir 
750cdf0e10cSrcweir {
751cdf0e10cSrcweir     if ( pPageImpl->pLoadTimer && pPageImpl->pLoadTimer->IsActive() )
752cdf0e10cSrcweir     {
753cdf0e10cSrcweir         pPageImpl->pLoadTimer->Stop();
754cdf0e10cSrcweir         LoadTimerHdl_Impl( pPageImpl->pLoadTimer );
755cdf0e10cSrcweir     }
756cdf0e10cSrcweir // os: So ein Unsinn! Irgendwo laesst sich so ein Item immer finden,
757cdf0e10cSrcweir //      es muss aber im rSet vorhanden sein!
758cdf0e10cSrcweir 
759cdf0e10cSrcweir //  const SfxPoolItem* pX = GetOldItem( rCoreSet, SID_VIEW_FLD_PIC );
760cdf0e10cSrcweir //  if( pX && pX->ISA(SfxWallpaperItem))
761cdf0e10cSrcweir     if(SFX_ITEM_AVAILABLE <= rCoreSet.GetItemState(GetWhich(SID_VIEW_FLD_PIC), sal_False))
762cdf0e10cSrcweir         return FillItemSetWithWallpaperItem( rCoreSet, SID_VIEW_FLD_PIC );
763cdf0e10cSrcweir 
764cdf0e10cSrcweir     sal_Bool bModified = sal_False;
765cdf0e10cSrcweir     sal_uInt16 nSlot = SID_ATTR_BRUSH;
766cdf0e10cSrcweir 
767cdf0e10cSrcweir     if ( aTblLBox.IsVisible() )
768cdf0e10cSrcweir     {
769cdf0e10cSrcweir         switch( aTblLBox.GetSelectEntryPos() )
770cdf0e10cSrcweir         {
771cdf0e10cSrcweir             case TBL_DEST_CELL:
772cdf0e10cSrcweir                 nSlot = SID_ATTR_BRUSH;
773cdf0e10cSrcweir             break;
774cdf0e10cSrcweir             case TBL_DEST_ROW:
775cdf0e10cSrcweir                 nSlot = SID_ATTR_BRUSH_ROW;
776cdf0e10cSrcweir             break;
777cdf0e10cSrcweir             case TBL_DEST_TBL:
778cdf0e10cSrcweir                 nSlot = SID_ATTR_BRUSH_TABLE;
779cdf0e10cSrcweir             break;
780cdf0e10cSrcweir         }
781cdf0e10cSrcweir     }
782cdf0e10cSrcweir     else if(aParaLBox.GetData() == &aParaLBox)
783cdf0e10cSrcweir     {
784cdf0e10cSrcweir         switch(aParaLBox.GetSelectEntryPos())
785cdf0e10cSrcweir         {
786cdf0e10cSrcweir             case PARA_DEST_PARA:
787cdf0e10cSrcweir                 nSlot = SID_ATTR_BRUSH;
788cdf0e10cSrcweir             break;
789cdf0e10cSrcweir             case PARA_DEST_CHAR:
790cdf0e10cSrcweir                 nSlot = SID_ATTR_BRUSH_CHAR;
791cdf0e10cSrcweir             break;
792cdf0e10cSrcweir         }
793cdf0e10cSrcweir     }
794cdf0e10cSrcweir     sal_uInt16 nWhich = GetWhich( nSlot );
795cdf0e10cSrcweir 
796cdf0e10cSrcweir     const SfxPoolItem* pOld = GetOldItem( rCoreSet, nSlot );
797cdf0e10cSrcweir     SfxItemState eOldItemState = rCoreSet.GetItemState(nSlot, sal_False);
798cdf0e10cSrcweir     const SfxItemSet& rOldSet = GetItemSet();
799cdf0e10cSrcweir 
800cdf0e10cSrcweir     sal_Bool bGraphTransparencyChanged = bGraphTransparency && (aGraphTransMF.GetText() != aGraphTransMF.GetSavedValue());
801cdf0e10cSrcweir     if ( pOld )
802cdf0e10cSrcweir     {
803cdf0e10cSrcweir         const SvxBrushItem& rOldItem    = (const SvxBrushItem&)*pOld;
804cdf0e10cSrcweir         SvxGraphicPosition  eOldPos     = rOldItem.GetGraphicPos();
805cdf0e10cSrcweir         const sal_Bool          bIsBrush    = ( 0 == aLbSelect.GetSelectEntryPos() );
806cdf0e10cSrcweir 
807cdf0e10cSrcweir         // transparency has to be set if enabled, the color not already set to "No fill" and
808cdf0e10cSrcweir         if( bColTransparency &&
809cdf0e10cSrcweir             aBgdColor.GetTransparency() < 0xff)
810cdf0e10cSrcweir         {
811cdf0e10cSrcweir             aBgdColor.SetTransparency(lcl_PercentToTransparency(static_cast<long>(aColTransMF.GetValue())));
812cdf0e10cSrcweir         }
813cdf0e10cSrcweir         if (   ( (GPOS_NONE == eOldPos) && bIsBrush  )
814cdf0e10cSrcweir             || ( (GPOS_NONE != eOldPos) && !bIsBrush ) ) // Brush <-> Bitmap gewechselt?
815cdf0e10cSrcweir         {
816cdf0e10cSrcweir             // Hintergrund-Art wurde nicht gewechselt:
817cdf0e10cSrcweir 
818cdf0e10cSrcweir             if ( (GPOS_NONE == eOldPos) || !aLbSelect.IsVisible() )
819cdf0e10cSrcweir             {
820cdf0e10cSrcweir                 // Brush-Behandlung:
821cdf0e10cSrcweir                 if ( rOldItem.GetColor() != aBgdColor ||
822cdf0e10cSrcweir                         (SFX_ITEM_AVAILABLE >= eOldItemState && !aBackgroundColorSet.IsNoSelection()))
823cdf0e10cSrcweir                 {
824cdf0e10cSrcweir                     bModified = sal_True;
825cdf0e10cSrcweir                     rCoreSet.Put( SvxBrushItem( aBgdColor, nWhich ) );
826cdf0e10cSrcweir                 }
827cdf0e10cSrcweir                 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
828cdf0e10cSrcweir                     rCoreSet.ClearItem( nWhich );
829cdf0e10cSrcweir             }
830cdf0e10cSrcweir             else
831cdf0e10cSrcweir             {
832cdf0e10cSrcweir                 // Bitmap-Behandlung:
833cdf0e10cSrcweir 
834cdf0e10cSrcweir                 SvxGraphicPosition  eNewPos  = GetGraphicPosition_Impl();
835cdf0e10cSrcweir                 const sal_Bool          bIsLink  = aBtnLink.IsChecked();
836cdf0e10cSrcweir                 const sal_Bool          bWasLink = (NULL != rOldItem.GetGraphicLink() );
837cdf0e10cSrcweir 
838cdf0e10cSrcweir 
839cdf0e10cSrcweir                 if ( !bIsLink && !bIsGraphicValid )
840cdf0e10cSrcweir                     bIsGraphicValid = LoadLinkedGraphic_Impl();
841cdf0e10cSrcweir 
842cdf0e10cSrcweir                 if (    bGraphTransparencyChanged ||
843cdf0e10cSrcweir                         eNewPos != eOldPos
844cdf0e10cSrcweir                     || bIsLink != bWasLink
845cdf0e10cSrcweir                     || ( bWasLink  &&    *rOldItem.GetGraphicLink()
846cdf0e10cSrcweir                                       != aBgdGraphicPath )
847cdf0e10cSrcweir                     || ( !bWasLink &&    rOldItem.GetGraphic()->GetBitmap()
848cdf0e10cSrcweir                                       != aBgdGraphic.GetBitmap() )
849cdf0e10cSrcweir                    )
850cdf0e10cSrcweir                 {
851cdf0e10cSrcweir                     bModified = sal_True;
852cdf0e10cSrcweir 
853cdf0e10cSrcweir                     SvxBrushItem aTmpBrush(nWhich);
854cdf0e10cSrcweir                     if ( bIsLink )
855cdf0e10cSrcweir                     {
856cdf0e10cSrcweir                         aTmpBrush = SvxBrushItem( aBgdGraphicPath,
857cdf0e10cSrcweir                                                 aBgdGraphicFilter,
858cdf0e10cSrcweir                                                 eNewPos,
859cdf0e10cSrcweir                                                 nWhich );
860cdf0e10cSrcweir                     }
861cdf0e10cSrcweir                     else
862cdf0e10cSrcweir                         aTmpBrush = SvxBrushItem( aBgdGraphic,
863cdf0e10cSrcweir                                         eNewPos,
864cdf0e10cSrcweir                                         nWhich );
865cdf0e10cSrcweir                     lcl_SetTransparency(aTmpBrush, static_cast<long>(aGraphTransMF.GetValue()));
866cdf0e10cSrcweir 
867cdf0e10cSrcweir                     rCoreSet.Put(aTmpBrush);
868cdf0e10cSrcweir                 }
869cdf0e10cSrcweir                 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
870cdf0e10cSrcweir                     rCoreSet.ClearItem( nWhich );
871cdf0e10cSrcweir             }
872cdf0e10cSrcweir         }
873cdf0e10cSrcweir         else // Brush <-> Bitmap gewechselt!
874cdf0e10cSrcweir         {
875cdf0e10cSrcweir             if ( bIsBrush )
876cdf0e10cSrcweir                 rCoreSet.Put( SvxBrushItem( aBgdColor, nWhich ) );
877cdf0e10cSrcweir             else
878cdf0e10cSrcweir             {
879cdf0e10cSrcweir                 SvxBrushItem* pTmpBrush = 0;
880cdf0e10cSrcweir                 if ( aBtnLink.IsChecked() )
881cdf0e10cSrcweir                 {
882cdf0e10cSrcweir                     pTmpBrush = new SvxBrushItem( aBgdGraphicPath,
883cdf0e10cSrcweir                                                 aBgdGraphicFilter,
884cdf0e10cSrcweir                                                 GetGraphicPosition_Impl(),
885cdf0e10cSrcweir                                                 nWhich );
886cdf0e10cSrcweir                 }
887cdf0e10cSrcweir                 else
888cdf0e10cSrcweir                 {
889cdf0e10cSrcweir                     if ( !bIsGraphicValid )
890cdf0e10cSrcweir                         bIsGraphicValid = LoadLinkedGraphic_Impl();
891cdf0e10cSrcweir 
892cdf0e10cSrcweir                     if ( bIsGraphicValid )
893cdf0e10cSrcweir                         pTmpBrush = new SvxBrushItem( aBgdGraphic,
894cdf0e10cSrcweir                                                     GetGraphicPosition_Impl(),
895cdf0e10cSrcweir                                                     nWhich );
896cdf0e10cSrcweir                 }
897cdf0e10cSrcweir                 if(pTmpBrush)
898cdf0e10cSrcweir                 {
899cdf0e10cSrcweir                     lcl_SetTransparency(*pTmpBrush, static_cast<long>(aGraphTransMF.GetValue()));
900cdf0e10cSrcweir                     rCoreSet.Put(*pTmpBrush);
901cdf0e10cSrcweir                     delete pTmpBrush;
902cdf0e10cSrcweir                 }
903cdf0e10cSrcweir             }
904cdf0e10cSrcweir             bModified = ( bIsBrush || aBtnLink.IsChecked() || bIsGraphicValid );
905cdf0e10cSrcweir         }
906cdf0e10cSrcweir     }
907cdf0e10cSrcweir     else if ( SID_ATTR_BRUSH_CHAR == nSlot && aBgdColor != Color( COL_WHITE ) )
908cdf0e10cSrcweir     {
909cdf0e10cSrcweir         rCoreSet.Put( SvxBrushItem( aBgdColor, nWhich ) );
910cdf0e10cSrcweir         bModified = sal_True;
911cdf0e10cSrcweir     }
912cdf0e10cSrcweir 
913cdf0e10cSrcweir     if( aTblLBox.IsVisible() )
914cdf0e10cSrcweir     {
915cdf0e10cSrcweir         // Der aktuelle Zustand wurde bereits geputtet
916cdf0e10cSrcweir         if( nSlot != SID_ATTR_BRUSH && pTableBck_Impl->pCellBrush)
917cdf0e10cSrcweir         {
918cdf0e10cSrcweir             const SfxPoolItem* pOldCell =
919cdf0e10cSrcweir                 GetOldItem( rCoreSet, SID_ATTR_BRUSH );
920cdf0e10cSrcweir 
921cdf0e10cSrcweir             if ( *pTableBck_Impl->pCellBrush != *pOldCell )
922cdf0e10cSrcweir             {
923cdf0e10cSrcweir                 rCoreSet.Put( *pTableBck_Impl->pCellBrush );
924cdf0e10cSrcweir                 bModified |= sal_True;
925cdf0e10cSrcweir             }
926cdf0e10cSrcweir         }
927cdf0e10cSrcweir 
928cdf0e10cSrcweir         if( nSlot != SID_ATTR_BRUSH_ROW && pTableBck_Impl->pRowBrush)
929cdf0e10cSrcweir         {
930cdf0e10cSrcweir             const SfxPoolItem* pOldRow =
931cdf0e10cSrcweir                 GetOldItem( rCoreSet, SID_ATTR_BRUSH_ROW );
932cdf0e10cSrcweir 
933cdf0e10cSrcweir             if ( *pTableBck_Impl->pRowBrush != *pOldRow )
934cdf0e10cSrcweir             {
935cdf0e10cSrcweir                 rCoreSet.Put( *pTableBck_Impl->pRowBrush );
936cdf0e10cSrcweir                 bModified |= sal_True;
937cdf0e10cSrcweir             }
938cdf0e10cSrcweir         }
939cdf0e10cSrcweir 
940cdf0e10cSrcweir         if( nSlot != SID_ATTR_BRUSH_TABLE && pTableBck_Impl->pTableBrush)
941cdf0e10cSrcweir         {
942cdf0e10cSrcweir             const SfxPoolItem* pOldTable =
943cdf0e10cSrcweir                 GetOldItem( rCoreSet, SID_ATTR_BRUSH_TABLE );
944cdf0e10cSrcweir 
945cdf0e10cSrcweir             if ( *pTableBck_Impl->pTableBrush != *pOldTable )
946cdf0e10cSrcweir             {
947cdf0e10cSrcweir                 rCoreSet.Put( *pTableBck_Impl->pTableBrush );
948cdf0e10cSrcweir                 bModified |= sal_True;
949cdf0e10cSrcweir             }
950cdf0e10cSrcweir         }
951cdf0e10cSrcweir 
952cdf0e10cSrcweir         if( aTblLBox.GetSavedValue() != aTblLBox.GetSelectEntryPos() )
953cdf0e10cSrcweir         {
954cdf0e10cSrcweir             rCoreSet.Put( SfxUInt16Item( SID_BACKGRND_DESTINATION,
955cdf0e10cSrcweir                                          aTblLBox.GetSelectEntryPos() ) );
956cdf0e10cSrcweir             bModified |= sal_True;
957cdf0e10cSrcweir         }
958cdf0e10cSrcweir     }
959cdf0e10cSrcweir     else if(aParaLBox.GetData() == &aParaLBox)
960cdf0e10cSrcweir     {
961cdf0e10cSrcweir         // Der aktuelle Zustand wurde bereits geputtet
962cdf0e10cSrcweir         if( nSlot != SID_ATTR_BRUSH && aParaLBox.IsVisible()) // nicht im Suchen-Format-Dialog
963cdf0e10cSrcweir         {
964cdf0e10cSrcweir             const SfxPoolItem* pOldPara =
965cdf0e10cSrcweir                 GetOldItem( rCoreSet, SID_ATTR_BRUSH );
966cdf0e10cSrcweir 
967cdf0e10cSrcweir             if ( *pParaBck_Impl->pParaBrush != *pOldPara )
968cdf0e10cSrcweir             {
969cdf0e10cSrcweir                 rCoreSet.Put( *pParaBck_Impl->pParaBrush );
970cdf0e10cSrcweir                 bModified |= sal_True;
971cdf0e10cSrcweir             }
972cdf0e10cSrcweir         }
973cdf0e10cSrcweir 
974cdf0e10cSrcweir         if( nSlot != SID_ATTR_BRUSH_CHAR )
975cdf0e10cSrcweir         {
976cdf0e10cSrcweir             const SfxPoolItem* pOldChar =
977cdf0e10cSrcweir                 GetOldItem( rCoreSet, SID_ATTR_BRUSH_CHAR );
978cdf0e10cSrcweir             DBG_ASSERT(pParaBck_Impl, "pParaBck_Impl == NULL ?");
979cdf0e10cSrcweir             if ( pOldChar &&
980cdf0e10cSrcweir                     //#111173#  crash report shows that pParaBck_Impl can be NULL, the cause is unknown
981cdf0e10cSrcweir                     pParaBck_Impl &&
982cdf0e10cSrcweir                         (*pParaBck_Impl->pCharBrush != *pOldChar ||
983cdf0e10cSrcweir                 *pParaBck_Impl->pCharBrush != SvxBrushItem(SID_ATTR_BRUSH_CHAR)))
984cdf0e10cSrcweir             {
985cdf0e10cSrcweir                 rCoreSet.Put( *pParaBck_Impl->pCharBrush );
986cdf0e10cSrcweir                 bModified |= sal_True;
987cdf0e10cSrcweir             }
988cdf0e10cSrcweir         }
989cdf0e10cSrcweir 
990cdf0e10cSrcweir         if( aParaLBox.GetSavedValue() != aParaLBox.GetSelectEntryPos() )
991cdf0e10cSrcweir         {
992cdf0e10cSrcweir             rCoreSet.Put( SfxUInt16Item( SID_BACKGRND_DESTINATION,
993cdf0e10cSrcweir                                          aParaLBox.GetSelectEntryPos() ) );
994cdf0e10cSrcweir             bModified |= sal_True;
995cdf0e10cSrcweir         }
996cdf0e10cSrcweir     }
997cdf0e10cSrcweir     return bModified;
998cdf0e10cSrcweir }
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir sal_Bool SvxBackgroundTabPage::FillItemSetWithWallpaperItem( SfxItemSet& rCoreSet, sal_uInt16 nSlot)
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir     sal_uInt16 nWhich = GetWhich( nSlot );
1003cdf0e10cSrcweir     const SfxPoolItem* pOld = GetOldItem( rCoreSet, nSlot );
1004cdf0e10cSrcweir     const SfxItemSet& rOldSet = GetItemSet();
1005cdf0e10cSrcweir     DBG_ASSERT(pOld,"FillItemSetWithWallpaperItem: Item not found");
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir     SvxBrushItem        rOldItem( (const CntWallpaperItem&)*pOld, nWhich );
1008cdf0e10cSrcweir     SvxGraphicPosition  eOldPos     = rOldItem.GetGraphicPos();
1009cdf0e10cSrcweir     const sal_Bool          bIsBrush    = ( 0 == aLbSelect.GetSelectEntryPos() );
1010cdf0e10cSrcweir     sal_Bool                bModified = sal_False;
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir     if (   ( (GPOS_NONE == eOldPos) && bIsBrush  )
1013cdf0e10cSrcweir         || ( (GPOS_NONE != eOldPos) && !bIsBrush ) ) // Brush <-> Bitmap gewechselt?
1014cdf0e10cSrcweir     {
1015cdf0e10cSrcweir         // Hintergrund-Art wurde nicht gewechselt:
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir         if ( (GPOS_NONE == eOldPos) || !aLbSelect.IsVisible() )
1018cdf0e10cSrcweir         {
1019cdf0e10cSrcweir             // Brush-Behandlung:
1020cdf0e10cSrcweir             if ( rOldItem.GetColor() != aBgdColor )
1021cdf0e10cSrcweir             {
1022cdf0e10cSrcweir                 bModified = sal_True;
1023cdf0e10cSrcweir                 CntWallpaperItem aItem( nWhich );
1024cdf0e10cSrcweir                 aItem.SetColor( aBgdColor );
1025cdf0e10cSrcweir                 rCoreSet.Put( aItem );
1026cdf0e10cSrcweir             }
1027cdf0e10cSrcweir             else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
1028cdf0e10cSrcweir                 rCoreSet.ClearItem( nWhich );
1029cdf0e10cSrcweir         }
1030cdf0e10cSrcweir         else
1031cdf0e10cSrcweir         {
1032cdf0e10cSrcweir             // Bitmap-Behandlung:
1033cdf0e10cSrcweir             SvxGraphicPosition  eNewPos  = GetGraphicPosition_Impl();
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir             int bBitmapChanged = ( ( eNewPos != eOldPos ) ||
1036cdf0e10cSrcweir                                    ( *rOldItem.GetGraphicLink() != aBgdGraphicPath ) );
1037cdf0e10cSrcweir             int bBrushChanged = ( rOldItem.GetColor() != aBgdColor );
1038cdf0e10cSrcweir             if( bBitmapChanged || bBrushChanged )
1039cdf0e10cSrcweir             {
1040cdf0e10cSrcweir                 bModified = sal_True;
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir                 CntWallpaperItem aItem( nWhich );
1043cdf0e10cSrcweir                 WallpaperStyle eWallStyle = SvxBrushItem::GraphicPos2WallpaperStyle(eNewPos);
1044cdf0e10cSrcweir                 aItem.SetStyle( sal::static_int_cast< sal_uInt16 >( eWallStyle ) );
1045cdf0e10cSrcweir                 aItem.SetColor( aBgdColor );
1046cdf0e10cSrcweir                 aItem.SetBitmapURL( aBgdGraphicPath );
1047cdf0e10cSrcweir                 rCoreSet.Put( aItem );
1048cdf0e10cSrcweir             }
1049cdf0e10cSrcweir             else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
1050cdf0e10cSrcweir                 rCoreSet.ClearItem( nWhich );
1051cdf0e10cSrcweir         }
1052cdf0e10cSrcweir     }
1053cdf0e10cSrcweir     else // Brush <-> Bitmap gewechselt!
1054cdf0e10cSrcweir     {
1055cdf0e10cSrcweir         CntWallpaperItem aItem( nWhich );
1056cdf0e10cSrcweir         if ( bIsBrush )
1057cdf0e10cSrcweir         {
1058cdf0e10cSrcweir             aItem.SetColor( aBgdColor );
1059cdf0e10cSrcweir             rCoreSet.Put( aItem );
1060cdf0e10cSrcweir         }
1061cdf0e10cSrcweir         else
1062cdf0e10cSrcweir         {
1063cdf0e10cSrcweir             WallpaperStyle eWallStyle =
1064cdf0e10cSrcweir                 SvxBrushItem::GraphicPos2WallpaperStyle( GetGraphicPosition_Impl() );
1065cdf0e10cSrcweir             aItem.SetStyle( sal::static_int_cast< sal_uInt16 >( eWallStyle ) );
1066cdf0e10cSrcweir             aItem.SetColor( aBgdColor );
1067cdf0e10cSrcweir             aItem.SetBitmapURL( aBgdGraphicPath );
1068cdf0e10cSrcweir             rCoreSet.Put( aItem );
1069cdf0e10cSrcweir         }
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir         bModified = sal_True;
1072cdf0e10cSrcweir     }
1073cdf0e10cSrcweir     return bModified;
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir //-----------------------------------------------------------------------
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir int SvxBackgroundTabPage::DeactivatePage( SfxItemSet* _pSet )
1079cdf0e10cSrcweir 
1080cdf0e10cSrcweir /*  [Beschreibung]
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir     virtuelle Methode, wird beim Deaktivieren gerufen
1083cdf0e10cSrcweir */
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir     if ( pPageImpl->bIsImportDlgInExecute )
1087cdf0e10cSrcweir         return KEEP_PAGE;
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir     if ( _pSet )
1090cdf0e10cSrcweir         FillItemSet( *_pSet );
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir     return LEAVE_PAGE;
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir //-----------------------------------------------------------------------
1096cdf0e10cSrcweir 
1097cdf0e10cSrcweir void SvxBackgroundTabPage::PointChanged( Window* , RECT_POINT  )
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir /*  [Beschreibung]
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir */
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir     // muss implementiert werden, damit Position-Control funktioniert
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir //-----------------------------------------------------------------------
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir void SvxBackgroundTabPage::ShowSelector()
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir /*  [Beschreibung]
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir */
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir     if( bAllowShowSelector)
1117cdf0e10cSrcweir     {
1118cdf0e10cSrcweir         aSelectTxt.Show();
1119cdf0e10cSrcweir         aLbSelect.Show();
1120cdf0e10cSrcweir         aLbSelect.SetSelectHdl( HDL(SelectHdl_Impl) );
1121cdf0e10cSrcweir         aBtnLink.SetClickHdl( HDL(FileClickHdl_Impl) );
1122cdf0e10cSrcweir         aBtnPreview.SetClickHdl( HDL(FileClickHdl_Impl) );
1123cdf0e10cSrcweir         aBtnBrowse.SetClickHdl( HDL(BrowseHdl_Impl) );
1124cdf0e10cSrcweir         aBtnArea.SetClickHdl( HDL(RadioClickHdl_Impl) );
1125cdf0e10cSrcweir         aBtnTile.SetClickHdl( HDL(RadioClickHdl_Impl) );
1126cdf0e10cSrcweir         aBtnPosition.SetClickHdl( HDL(RadioClickHdl_Impl) );
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir         // Verz"ogertes Laden "uber Timer (wg. UI-Update)
1129cdf0e10cSrcweir         pPageImpl->pLoadTimer = new Timer;
1130cdf0e10cSrcweir         pPageImpl->pLoadTimer->SetTimeout( 500 ); // 500ms verz"ogern
1131cdf0e10cSrcweir         pPageImpl->pLoadTimer->SetTimeoutHdl(
1132cdf0e10cSrcweir             LINK( this, SvxBackgroundTabPage, LoadTimerHdl_Impl ) );
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir         bAllowShowSelector = sal_False;
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir         if(nHtmlMode & HTMLMODE_ON)
1137cdf0e10cSrcweir         {
1138cdf0e10cSrcweir             if(!(nHtmlMode & HTMLMODE_GRAPH_POS))
1139cdf0e10cSrcweir                 aBtnPosition.Enable(sal_False);
1140cdf0e10cSrcweir             aBtnArea.Enable(sal_False);
1141cdf0e10cSrcweir         }
1142cdf0e10cSrcweir     }
1143cdf0e10cSrcweir }
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir //------------------------------------------------------------------------
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir void SvxBackgroundTabPage::RaiseLoadError_Impl()
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir /*  [Beschreibung]
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir */
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir {
1155cdf0e10cSrcweir     SfxErrorContext aContext( ERRCTX_SVX_BACKGROUND,
1156cdf0e10cSrcweir                               String(),
1157cdf0e10cSrcweir                               this,
1158cdf0e10cSrcweir                               RID_SVXERRCTX,
1159cdf0e10cSrcweir                               &CUI_MGR() );
1160cdf0e10cSrcweir 
1161cdf0e10cSrcweir     ErrorHandler::HandleError(
1162cdf0e10cSrcweir         *new StringErrorInfo( ERRCODE_SVX_GRAPHIC_NOTREADABLE,
1163cdf0e10cSrcweir                               aBgdGraphicPath ) );
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir //------------------------------------------------------------------------
1167cdf0e10cSrcweir 
1168cdf0e10cSrcweir sal_Bool SvxBackgroundTabPage::LoadLinkedGraphic_Impl()
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir /*  [Beschreibung]
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir */
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir     sal_Bool bResult = ( aBgdGraphicPath.Len() > 0 ) &&
1176cdf0e10cSrcweir                    ( GRFILTER_OK == GraphicFilter::LoadGraphic( aBgdGraphicPath,
1177cdf0e10cSrcweir                                                  aBgdGraphicFilter,
1178cdf0e10cSrcweir                                                  aBgdGraphic ) );
1179cdf0e10cSrcweir     return bResult;
1180cdf0e10cSrcweir }
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir //------------------------------------------------------------------------
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir void SvxBackgroundTabPage::FillColorValueSets_Impl()
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir /*  [Beschreibung]
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir     F"ullen des Farb-Sets
1190cdf0e10cSrcweir */
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir {
1193cdf0e10cSrcweir     SfxObjectShell* pDocSh = SfxObjectShell::Current();
1194cdf0e10cSrcweir     const SfxPoolItem* pItem = NULL;
1195cdf0e10cSrcweir     XColorTable* pColorTable = NULL;
1196cdf0e10cSrcweir     const Size aSize15x15 = Size( 15, 15 );
1197cdf0e10cSrcweir     FASTBOOL bOwn = sal_False;
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir     if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) )
1200cdf0e10cSrcweir         pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir     if ( !pColorTable )
1203cdf0e10cSrcweir     {
1204cdf0e10cSrcweir         bOwn = sal_True;
1205cdf0e10cSrcweir         pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() );
1206cdf0e10cSrcweir     }
1207cdf0e10cSrcweir 
1208cdf0e10cSrcweir     if ( pColorTable )
1209cdf0e10cSrcweir     {
1210cdf0e10cSrcweir         short i = 0;
1211cdf0e10cSrcweir         long nCount = pColorTable->Count();
1212cdf0e10cSrcweir         XColorEntry* pEntry = NULL;
1213cdf0e10cSrcweir         Color aColWhite( COL_WHITE );
1214cdf0e10cSrcweir         String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) );
1215cdf0e10cSrcweir         WinBits nBits = ( aBackgroundColorSet.GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD );
1216cdf0e10cSrcweir         aBackgroundColorSet.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
1217cdf0e10cSrcweir         aBackgroundColorSet.SetStyle( nBits );
1218cdf0e10cSrcweir         aBackgroundColorSet.SetAccessibleName(aBackgroundColorBox.GetText());
1219cdf0e10cSrcweir         for ( i = 0; i < nCount; i++ )
1220cdf0e10cSrcweir         {
1221cdf0e10cSrcweir             pEntry = pColorTable->GetColor(i);
1222cdf0e10cSrcweir             aBackgroundColorSet.InsertItem( i + 1, pEntry->GetColor(), pEntry->GetName() );
1223cdf0e10cSrcweir         }
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir         while ( i < 80 )
1226cdf0e10cSrcweir         {
1227cdf0e10cSrcweir             aBackgroundColorSet.InsertItem( i + 1, aColWhite, aStrWhite );
1228cdf0e10cSrcweir             i++;
1229cdf0e10cSrcweir         }
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir         if ( nCount > 80 )
1232cdf0e10cSrcweir         {
1233cdf0e10cSrcweir             aBackgroundColorSet.SetStyle( nBits | WB_VSCROLL );
1234cdf0e10cSrcweir         }
1235cdf0e10cSrcweir     }
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir     if ( bOwn )
1238cdf0e10cSrcweir         delete pColorTable;
1239cdf0e10cSrcweir 
1240cdf0e10cSrcweir     aBackgroundColorSet.SetColCount( 10 );
1241cdf0e10cSrcweir     aBackgroundColorSet.SetLineCount( 10 );
1242cdf0e10cSrcweir     aBackgroundColorSet.CalcWindowSizePixel( aSize15x15 );
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir }
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir //------------------------------------------------------------------------
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir //------------------------------------------------------------------------
1251cdf0e10cSrcweir 
1252cdf0e10cSrcweir void SvxBackgroundTabPage::ShowColorUI_Impl()
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir /*  [Beschreibung]
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir     Die Controls f"ur das Einstellen der Grafik ausblenden und die
1257cdf0e10cSrcweir     Controls f"ur die Farbeinstellung einblenden.
1258cdf0e10cSrcweir */
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir {
1261cdf0e10cSrcweir     if( !aBackgroundColorSet.IsVisible() )
1262cdf0e10cSrcweir     {
1263cdf0e10cSrcweir         aBackgroundColorSet.Show();
1264cdf0e10cSrcweir         aBackgroundColorBox.Show();
1265cdf0e10cSrcweir         aBorderWin.Show();
1266cdf0e10cSrcweir         pPreviewWin1->Show();
1267cdf0e10cSrcweir         aBtnBrowse.Hide();
1268cdf0e10cSrcweir         aFtFile.Hide();
1269cdf0e10cSrcweir         aBtnLink.Hide();
1270cdf0e10cSrcweir         aBtnPreview.Hide();
1271cdf0e10cSrcweir         aGbFile.Hide();
1272cdf0e10cSrcweir         aBtnPosition.Hide();
1273cdf0e10cSrcweir         aBtnArea.Hide();
1274cdf0e10cSrcweir         aBtnTile.Hide();
1275cdf0e10cSrcweir         aWndPosition.Hide();
1276cdf0e10cSrcweir         aGbPosition.Hide();
1277cdf0e10cSrcweir         pPreviewWin2->Hide();
1278cdf0e10cSrcweir         aGraphTransFL.Show(sal_False);
1279cdf0e10cSrcweir         aGraphTransMF.Show(sal_False);
1280cdf0e10cSrcweir         if(bColTransparency)
1281cdf0e10cSrcweir         {
1282cdf0e10cSrcweir             aColTransFT.Show();
1283cdf0e10cSrcweir             aColTransMF.Show();
1284cdf0e10cSrcweir         }
1285cdf0e10cSrcweir     }
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir //------------------------------------------------------------------------
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir void SvxBackgroundTabPage::ShowBitmapUI_Impl()
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir /*  [Beschreibung]
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir     Die Controls f"ur die Farbeinstellung ausblenden und die
1295cdf0e10cSrcweir     Controls f"ur das Einstellen der Grafik einblenden.
1296cdf0e10cSrcweir */
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir {
1299cdf0e10cSrcweir     if ( aLbSelect.IsVisible() &&
1300cdf0e10cSrcweir          (
1301cdf0e10cSrcweir         aBackgroundColorSet.IsVisible()
1302cdf0e10cSrcweir          || !aBtnBrowse.IsVisible() ) )
1303cdf0e10cSrcweir     {
1304cdf0e10cSrcweir         aBackgroundColorSet.Hide();
1305cdf0e10cSrcweir         aBackgroundColorBox.Hide();
1306cdf0e10cSrcweir         aBorderWin.Hide();
1307cdf0e10cSrcweir         pPreviewWin1->Hide();
1308cdf0e10cSrcweir         aBtnBrowse.Show();
1309cdf0e10cSrcweir         aFtFile.Show();
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir         if ( !bLinkOnly && ! nHtmlMode & HTMLMODE_ON )
1312cdf0e10cSrcweir             aBtnLink.Show();
1313cdf0e10cSrcweir         aBtnPreview.Show();
1314cdf0e10cSrcweir         aGbFile.Show();
1315cdf0e10cSrcweir         aBtnPosition.Show();
1316cdf0e10cSrcweir         aBtnArea.Show();
1317cdf0e10cSrcweir         aBtnTile.Show();
1318cdf0e10cSrcweir         aWndPosition.Show();
1319cdf0e10cSrcweir         aGbPosition.Show();
1320cdf0e10cSrcweir         pPreviewWin2->Show();
1321cdf0e10cSrcweir         if(bGraphTransparency)
1322cdf0e10cSrcweir         {
1323cdf0e10cSrcweir             aGraphTransFL.Show();
1324cdf0e10cSrcweir             aGraphTransMF.Show();
1325cdf0e10cSrcweir         }
1326cdf0e10cSrcweir         aColTransFT.Show(sal_False);
1327cdf0e10cSrcweir         aColTransMF.Show(sal_False);
1328cdf0e10cSrcweir     }
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir //------------------------------------------------------------------------
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir void SvxBackgroundTabPage::SetGraphicPosition_Impl( SvxGraphicPosition ePos )
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir /*  [Beschreibung]
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir     Die Controls f"ur die Grafikposition einstellen.
1338cdf0e10cSrcweir */
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir     switch ( ePos )
1342cdf0e10cSrcweir     {
1343cdf0e10cSrcweir         case GPOS_AREA:
1344cdf0e10cSrcweir         {
1345cdf0e10cSrcweir             aBtnArea.Check();
1346cdf0e10cSrcweir             aWndPosition.Disable();
1347cdf0e10cSrcweir         }
1348cdf0e10cSrcweir         break;
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir         case GPOS_TILED:
1351cdf0e10cSrcweir         {
1352cdf0e10cSrcweir             aBtnTile.Check();
1353cdf0e10cSrcweir             aWndPosition.Disable();
1354cdf0e10cSrcweir         }
1355cdf0e10cSrcweir         break;
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir         default:
1358cdf0e10cSrcweir         {
1359cdf0e10cSrcweir             aBtnPosition.Check();
1360cdf0e10cSrcweir             aWndPosition.Enable();
1361cdf0e10cSrcweir             RECT_POINT eNewPos = RP_MM;
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir             switch ( ePos )
1364cdf0e10cSrcweir             {
1365cdf0e10cSrcweir                 case GPOS_MM:   break;
1366cdf0e10cSrcweir                 case GPOS_LT:   eNewPos = RP_LT; break;
1367cdf0e10cSrcweir                 case GPOS_MT:   eNewPos = RP_MT; break;
1368cdf0e10cSrcweir                 case GPOS_RT:   eNewPos = RP_RT; break;
1369cdf0e10cSrcweir                 case GPOS_LM:   eNewPos = RP_LM; break;
1370cdf0e10cSrcweir                 case GPOS_RM:   eNewPos = RP_RM; break;
1371cdf0e10cSrcweir                 case GPOS_LB:   eNewPos = RP_LB; break;
1372cdf0e10cSrcweir                 case GPOS_MB:   eNewPos = RP_MB; break;
1373cdf0e10cSrcweir                 case GPOS_RB:   eNewPos = RP_RB; break;
1374cdf0e10cSrcweir                 default: ;//prevent warning
1375cdf0e10cSrcweir             }
1376cdf0e10cSrcweir             aWndPosition.SetActualRP( eNewPos );
1377cdf0e10cSrcweir         }
1378cdf0e10cSrcweir         break;
1379cdf0e10cSrcweir     }
1380cdf0e10cSrcweir     aWndPosition.Invalidate();
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir 
1383cdf0e10cSrcweir //------------------------------------------------------------------------
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir SvxGraphicPosition SvxBackgroundTabPage::GetGraphicPosition_Impl()
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir /*  [Beschreibung]
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir     Die Position der Grafik zur"uckgeben.
1390cdf0e10cSrcweir */
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir {
1393cdf0e10cSrcweir     if ( aBtnTile.IsChecked() )
1394cdf0e10cSrcweir         return GPOS_TILED;
1395cdf0e10cSrcweir     else if ( aBtnArea.IsChecked() )
1396cdf0e10cSrcweir         return GPOS_AREA;
1397cdf0e10cSrcweir     else
1398cdf0e10cSrcweir     {
1399cdf0e10cSrcweir         switch ( aWndPosition.GetActualRP() )
1400cdf0e10cSrcweir         {
1401cdf0e10cSrcweir             case RP_LT: return GPOS_LT;
1402cdf0e10cSrcweir             case RP_MT: return GPOS_MT;
1403cdf0e10cSrcweir             case RP_RT: return GPOS_RT;
1404cdf0e10cSrcweir             case RP_LM: return GPOS_LM;
1405cdf0e10cSrcweir             case RP_MM: return GPOS_MM;
1406cdf0e10cSrcweir             case RP_RM: return GPOS_RM;
1407cdf0e10cSrcweir             case RP_LB: return GPOS_LB;
1408cdf0e10cSrcweir             case RP_MB: return GPOS_MB;
1409cdf0e10cSrcweir             case RP_RB: return GPOS_RB;
1410cdf0e10cSrcweir         }
1411cdf0e10cSrcweir     }
1412cdf0e10cSrcweir     return GPOS_MM;
1413cdf0e10cSrcweir }
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir //-----------------------------------------------------------------------
1416cdf0e10cSrcweir // Handler
1417cdf0e10cSrcweir //-----------------------------------------------------------------------
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir IMPL_LINK( SvxBackgroundTabPage, BackgroundColorHdl_Impl, ValueSet*, EMPTYARG )
1420cdf0e10cSrcweir /*
1421cdf0e10cSrcweir     Handler, called when color selection is changed
1422cdf0e10cSrcweir */
1423cdf0e10cSrcweir {
1424cdf0e10cSrcweir     sal_uInt16 nItemId = aBackgroundColorSet.GetSelectItemId();
1425cdf0e10cSrcweir     Color aColor = nItemId ? ( aBackgroundColorSet.GetItemColor( nItemId ) ) : Color( COL_TRANSPARENT );
1426cdf0e10cSrcweir     aBgdColor = aColor;
1427cdf0e10cSrcweir     pPreviewWin1->NotifyChange( aBgdColor );
1428cdf0e10cSrcweir     sal_Bool bEnableTransp = aBgdColor.GetTransparency() < 0xff;
1429cdf0e10cSrcweir     aColTransFT.Enable(bEnableTransp);
1430cdf0e10cSrcweir     aColTransMF.Enable(bEnableTransp);
1431cdf0e10cSrcweir     return 0;
1432cdf0e10cSrcweir }
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir //------------------------------------------------------------------------
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir IMPL_LINK( SvxBackgroundTabPage, SelectHdl_Impl, ListBox*, EMPTYARG )
1437cdf0e10cSrcweir 
1438cdf0e10cSrcweir /*  [Beschreibung]
1439cdf0e10cSrcweir 
1440cdf0e10cSrcweir */
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir {
1443cdf0e10cSrcweir     if ( 0 == aLbSelect.GetSelectEntryPos() )
1444cdf0e10cSrcweir     {
1445cdf0e10cSrcweir         ShowColorUI_Impl();
1446cdf0e10cSrcweir         aParaLBox.Enable(); // Zeichenhintergrund kann keine Bitmap sein
1447cdf0e10cSrcweir     }
1448cdf0e10cSrcweir     else
1449cdf0e10cSrcweir     {
1450cdf0e10cSrcweir         ShowBitmapUI_Impl();
1451cdf0e10cSrcweir         aParaLBox.Enable(sal_False);// Zeichenhintergrund kann keine Bitmap sein
1452cdf0e10cSrcweir     }
1453cdf0e10cSrcweir     return 0;
1454cdf0e10cSrcweir }
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir //------------------------------------------------------------------------
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir IMPL_LINK( SvxBackgroundTabPage, FileClickHdl_Impl, CheckBox*, pBox )
1459cdf0e10cSrcweir 
1460cdf0e10cSrcweir /*  [Beschreibung]
1461cdf0e10cSrcweir 
1462cdf0e10cSrcweir */
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir {
1465cdf0e10cSrcweir     if ( &aBtnLink == pBox )
1466cdf0e10cSrcweir     {
1467cdf0e10cSrcweir         if ( aBtnLink.IsChecked() )
1468cdf0e10cSrcweir         {
1469cdf0e10cSrcweir             INetURLObject aObj( aBgdGraphicPath );
1470cdf0e10cSrcweir             String aFilePath;
1471cdf0e10cSrcweir             if ( aObj.GetProtocol() == INET_PROT_FILE )
1472cdf0e10cSrcweir                 aFilePath = aObj.getFSysPath( INetURLObject::FSYS_DETECT );
1473cdf0e10cSrcweir             else
1474cdf0e10cSrcweir                 aFilePath = aBgdGraphicPath;
1475cdf0e10cSrcweir             aFtFile.SetText( aFilePath );
1476cdf0e10cSrcweir         }
1477cdf0e10cSrcweir         else
1478cdf0e10cSrcweir             aFtFile.SetText( aStrUnlinked );
1479cdf0e10cSrcweir     }
1480cdf0e10cSrcweir     else if ( &aBtnPreview == pBox )
1481cdf0e10cSrcweir     {
1482cdf0e10cSrcweir         if ( aBtnPreview.IsChecked() )
1483cdf0e10cSrcweir         {
1484cdf0e10cSrcweir             if ( !bIsGraphicValid )
1485cdf0e10cSrcweir                 bIsGraphicValid = LoadLinkedGraphic_Impl();
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir             if ( bIsGraphicValid )
1488cdf0e10cSrcweir             {
1489cdf0e10cSrcweir                 Bitmap aBmp = aBgdGraphic.GetBitmap();
1490cdf0e10cSrcweir                 pPreviewWin2->NotifyChange( &aBmp );
1491cdf0e10cSrcweir             }
1492cdf0e10cSrcweir             else
1493cdf0e10cSrcweir             {
1494cdf0e10cSrcweir                 if ( aBgdGraphicPath.Len() > 0 ) // nur bei gelinkter Grafik
1495cdf0e10cSrcweir                     RaiseLoadError_Impl();       // ein Fehler
1496cdf0e10cSrcweir                 pPreviewWin2->NotifyChange( NULL );
1497cdf0e10cSrcweir             }
1498cdf0e10cSrcweir         }
1499cdf0e10cSrcweir         else
1500cdf0e10cSrcweir             pPreviewWin2->NotifyChange( NULL );
1501cdf0e10cSrcweir     }
1502cdf0e10cSrcweir     return 0;
1503cdf0e10cSrcweir }
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir //------------------------------------------------------------------------
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir IMPL_LINK( SvxBackgroundTabPage, RadioClickHdl_Impl, RadioButton*, pBtn )
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir /*  [Beschreibung]
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir */
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir {
1514cdf0e10cSrcweir     if ( pBtn == &aBtnPosition )
1515cdf0e10cSrcweir     {
1516cdf0e10cSrcweir         if ( !aWndPosition.IsEnabled() )
1517cdf0e10cSrcweir         {
1518cdf0e10cSrcweir             aWndPosition.Enable();
1519cdf0e10cSrcweir             aWndPosition.Invalidate();
1520cdf0e10cSrcweir         }
1521cdf0e10cSrcweir     }
1522cdf0e10cSrcweir     else if ( aWndPosition.IsEnabled() )
1523cdf0e10cSrcweir     {
1524cdf0e10cSrcweir         aWndPosition.Disable();
1525cdf0e10cSrcweir         aWndPosition.Invalidate();
1526cdf0e10cSrcweir     }
1527cdf0e10cSrcweir     return 0;
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir 
1530cdf0e10cSrcweir //------------------------------------------------------------------------
1531cdf0e10cSrcweir 
1532cdf0e10cSrcweir IMPL_LINK( SvxBackgroundTabPage, BrowseHdl_Impl, PushButton* , EMPTYARG )
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir /*  [Beschreibung]
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir     Handler, gerufen durch das Dr"ucken des Durchsuchen-Buttons.
1537cdf0e10cSrcweir     Grafik/Einf"ugen-Dialog erzeugen, Pfad setzen und starten.
1538cdf0e10cSrcweir */
1539cdf0e10cSrcweir 
1540cdf0e10cSrcweir {
1541cdf0e10cSrcweir     if ( pPageImpl->pLoadTimer->IsActive() )
1542cdf0e10cSrcweir         return 0;
1543cdf0e10cSrcweir     sal_Bool bHtml = 0 != ( nHtmlMode & HTMLMODE_ON );
1544cdf0e10cSrcweir 
1545cdf0e10cSrcweir     pImportDlg = new SvxOpenGraphicDialog( aStrBrowse );
1546cdf0e10cSrcweir     if ( bHtml || bLinkOnly )
1547cdf0e10cSrcweir         pImportDlg->EnableLink(sal_False);
1548cdf0e10cSrcweir     pImportDlg->SetPath( aBgdGraphicPath, aBtnLink.IsChecked() );
1549cdf0e10cSrcweir 
1550cdf0e10cSrcweir     pPageImpl->bIsImportDlgInExecute = sal_True;
1551cdf0e10cSrcweir     short nErr = pImportDlg->Execute();
1552cdf0e10cSrcweir     pPageImpl->bIsImportDlgInExecute = sal_False;
1553cdf0e10cSrcweir 
1554cdf0e10cSrcweir     if( !nErr )
1555cdf0e10cSrcweir     {
1556cdf0e10cSrcweir         if ( bHtml )
1557cdf0e10cSrcweir             aBtnLink.Check();
1558cdf0e10cSrcweir         // wenn Verkn"upfen nicht gecheckt ist und die Vorschau auch nicht,
1559cdf0e10cSrcweir         // dann die Vorschau aktivieren, damit der Anwender sieht,
1560cdf0e10cSrcweir         // welche Grafik er ausgew"ahlt hat
1561cdf0e10cSrcweir         if ( !aBtnLink.IsChecked() && !aBtnPreview.IsChecked() )
1562cdf0e10cSrcweir             aBtnPreview.Check( sal_True );
1563cdf0e10cSrcweir         // timer-verz"ogertes Laden der Grafik
1564cdf0e10cSrcweir         pPageImpl->pLoadTimer->Start();
1565cdf0e10cSrcweir     }
1566cdf0e10cSrcweir     else
1567cdf0e10cSrcweir         DELETEZ( pImportDlg );
1568cdf0e10cSrcweir     return 0;
1569cdf0e10cSrcweir }
1570cdf0e10cSrcweir 
1571cdf0e10cSrcweir //-----------------------------------------------------------------------
1572cdf0e10cSrcweir 
1573cdf0e10cSrcweir IMPL_LINK( SvxBackgroundTabPage, LoadTimerHdl_Impl, Timer* , pTimer )
1574cdf0e10cSrcweir 
1575cdf0e10cSrcweir /*  [Beschreibung]
1576cdf0e10cSrcweir 
1577cdf0e10cSrcweir     Verz"ogertes Laden der Grafik.
1578cdf0e10cSrcweir     Grafik wird nur dann geladen, wenn sie unterschiedlich zur
1579cdf0e10cSrcweir     aktuellen Grafik ist.
1580cdf0e10cSrcweir */
1581cdf0e10cSrcweir 
1582cdf0e10cSrcweir {
1583cdf0e10cSrcweir     if ( pTimer == pPageImpl->pLoadTimer )
1584cdf0e10cSrcweir     {
1585cdf0e10cSrcweir         pPageImpl->pLoadTimer->Stop();
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir         if ( pImportDlg )
1588cdf0e10cSrcweir         {
1589cdf0e10cSrcweir             INetURLObject aOld( aBgdGraphicPath );
1590cdf0e10cSrcweir             INetURLObject aNew( pImportDlg->GetPath() );
1591cdf0e10cSrcweir             if ( !aBgdGraphicPath.Len() || aNew != aOld )
1592cdf0e10cSrcweir             {
1593cdf0e10cSrcweir                 // neue Datei gew"ahlt
1594cdf0e10cSrcweir                 aBgdGraphicPath   = pImportDlg->GetPath();
1595cdf0e10cSrcweir                 aBgdGraphicFilter = pImportDlg->GetCurrentFilter();
1596cdf0e10cSrcweir                 sal_Bool bLink = ( nHtmlMode & HTMLMODE_ON ) || bLinkOnly ? sal_True : pImportDlg->IsAsLink();
1597cdf0e10cSrcweir                 aBtnLink.Check( bLink );
1598cdf0e10cSrcweir                 aBtnLink.Enable();
1599cdf0e10cSrcweir 
1600cdf0e10cSrcweir                 if ( aBtnPreview.IsChecked() )
1601cdf0e10cSrcweir                 {
1602cdf0e10cSrcweir                     if( !pImportDlg->GetGraphic(aBgdGraphic) )
1603cdf0e10cSrcweir                     {
1604cdf0e10cSrcweir                         bIsGraphicValid = sal_True;
1605cdf0e10cSrcweir                     }
1606cdf0e10cSrcweir                     else
1607cdf0e10cSrcweir                     {
1608cdf0e10cSrcweir                         aBgdGraphicFilter.Erase();
1609cdf0e10cSrcweir                         aBgdGraphicPath.Erase();
1610cdf0e10cSrcweir                         bIsGraphicValid = sal_False;
1611cdf0e10cSrcweir                     }
1612cdf0e10cSrcweir                 }
1613cdf0e10cSrcweir                 else
1614cdf0e10cSrcweir                     bIsGraphicValid = sal_False; // Grafik erst beim Preview-Click laden
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir                 if ( aBtnPreview.IsChecked() && bIsGraphicValid )
1617cdf0e10cSrcweir                 {
1618cdf0e10cSrcweir                     Bitmap aBmp = aBgdGraphic.GetBitmap();
1619cdf0e10cSrcweir                     pPreviewWin2->NotifyChange( &aBmp );
1620cdf0e10cSrcweir                 }
1621cdf0e10cSrcweir                 else
1622cdf0e10cSrcweir                     pPreviewWin2->NotifyChange( NULL );
1623cdf0e10cSrcweir             }
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir             FileClickHdl_Impl( &aBtnLink );
1626cdf0e10cSrcweir             DELETEZ( pImportDlg );
1627cdf0e10cSrcweir         }
1628cdf0e10cSrcweir     }
1629cdf0e10cSrcweir     return 0;
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir //-----------------------------------------------------------------------
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir void SvxBackgroundTabPage::ShowTblControl()
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir /*  [Beschreibung]
1637cdf0e10cSrcweir 
1638cdf0e10cSrcweir */
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir {
1641cdf0e10cSrcweir     aTblLBox            .SetSelectHdl( HDL(TblDestinationHdl_Impl) );
1642cdf0e10cSrcweir     aTblLBox            .SelectEntryPos(0);
1643cdf0e10cSrcweir     aTblDesc.Show();
1644cdf0e10cSrcweir     aTblLBox.Show();
1645cdf0e10cSrcweir }
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir //-----------------------------------------------------------------------
1648cdf0e10cSrcweir 
1649cdf0e10cSrcweir void SvxBackgroundTabPage::ShowParaControl(sal_Bool bCharOnly)
1650cdf0e10cSrcweir {
1651cdf0e10cSrcweir     aParaLBox.SetSelectHdl(HDL(ParaDestinationHdl_Impl));
1652cdf0e10cSrcweir     aParaLBox.SelectEntryPos(0);
1653cdf0e10cSrcweir     if(!bCharOnly)
1654cdf0e10cSrcweir     {
1655cdf0e10cSrcweir         aTblDesc.Show();
1656cdf0e10cSrcweir         aParaLBox.Show();
1657cdf0e10cSrcweir     }
1658cdf0e10cSrcweir     aParaLBox.SetData(&aParaLBox); // hier erkennt man, dass dieser Mode eingeschaltet ist
1659cdf0e10cSrcweir }
1660cdf0e10cSrcweir //-----------------------------------------------------------------------
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir IMPL_LINK( SvxBackgroundTabPage, TblDestinationHdl_Impl, ListBox*, pBox )
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir /*  [Beschreibung]
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir */
1667cdf0e10cSrcweir 
1668cdf0e10cSrcweir {
1669cdf0e10cSrcweir     sal_uInt16 nSelPos = pBox->GetSelectEntryPos();
1670cdf0e10cSrcweir     if( pTableBck_Impl && pTableBck_Impl->nActPos != nSelPos)
1671cdf0e10cSrcweir     {
1672cdf0e10cSrcweir         SvxBrushItem** pActItem = new (SvxBrushItem*);
1673cdf0e10cSrcweir         sal_uInt16 nWhich = 0;
1674cdf0e10cSrcweir         switch(pTableBck_Impl->nActPos)
1675cdf0e10cSrcweir         {
1676cdf0e10cSrcweir             case TBL_DEST_CELL:
1677cdf0e10cSrcweir                 *pActItem = pTableBck_Impl->pCellBrush;
1678cdf0e10cSrcweir                 nWhich = pTableBck_Impl->nCellWhich;
1679cdf0e10cSrcweir             break;
1680cdf0e10cSrcweir             case TBL_DEST_ROW:
1681cdf0e10cSrcweir                 *pActItem = pTableBck_Impl->pRowBrush;
1682cdf0e10cSrcweir                 nWhich = pTableBck_Impl->nRowWhich;
1683cdf0e10cSrcweir             break;
1684cdf0e10cSrcweir             case TBL_DEST_TBL:
1685cdf0e10cSrcweir                 *pActItem = pTableBck_Impl->pTableBrush;
1686cdf0e10cSrcweir                 nWhich = pTableBck_Impl->nTableWhich;
1687cdf0e10cSrcweir             break;
1688cdf0e10cSrcweir         }
1689cdf0e10cSrcweir         pTableBck_Impl->nActPos = nSelPos;
1690cdf0e10cSrcweir         if(!*pActItem)
1691cdf0e10cSrcweir             *pActItem = new SvxBrushItem(nWhich);
1692cdf0e10cSrcweir         if(0 == aLbSelect.GetSelectEntryPos())  // Brush ausgewaehlt
1693cdf0e10cSrcweir         {
1694cdf0e10cSrcweir             **pActItem = SvxBrushItem( aBgdColor, nWhich );
1695cdf0e10cSrcweir         }
1696cdf0e10cSrcweir         else
1697cdf0e10cSrcweir         {
1698cdf0e10cSrcweir                 SvxGraphicPosition  eNewPos  = GetGraphicPosition_Impl();
1699cdf0e10cSrcweir                 const sal_Bool          bIsLink  = aBtnLink.IsChecked();
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir                 if ( !bIsLink && !bIsGraphicValid )
1702cdf0e10cSrcweir                     bIsGraphicValid = LoadLinkedGraphic_Impl();
1703cdf0e10cSrcweir 
1704cdf0e10cSrcweir                 if ( bIsLink )
1705cdf0e10cSrcweir                     **pActItem = SvxBrushItem( aBgdGraphicPath,
1706cdf0e10cSrcweir                                                 aBgdGraphicFilter,
1707cdf0e10cSrcweir                                                 eNewPos,
1708cdf0e10cSrcweir                                                 (*pActItem)->Which() );
1709cdf0e10cSrcweir                 else
1710cdf0e10cSrcweir                     **pActItem = SvxBrushItem( aBgdGraphic,
1711cdf0e10cSrcweir                                                 eNewPos,
1712cdf0e10cSrcweir                                                 (*pActItem)->Which() );
1713cdf0e10cSrcweir         }
1714cdf0e10cSrcweir         switch(nSelPos)
1715cdf0e10cSrcweir         {
1716cdf0e10cSrcweir             case TBL_DEST_CELL:
1717cdf0e10cSrcweir                 *pActItem = pTableBck_Impl->pCellBrush;
1718cdf0e10cSrcweir                 aLbSelect.Enable();
1719cdf0e10cSrcweir                 nWhich = pTableBck_Impl->nCellWhich;
1720cdf0e10cSrcweir             break;
1721cdf0e10cSrcweir             case TBL_DEST_ROW:
1722cdf0e10cSrcweir             {
1723cdf0e10cSrcweir                 if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & HTMLMODE_SOME_STYLES))
1724cdf0e10cSrcweir                     aLbSelect.Disable();
1725cdf0e10cSrcweir                 *pActItem = pTableBck_Impl->pRowBrush;
1726cdf0e10cSrcweir                 nWhich = pTableBck_Impl->nRowWhich;
1727cdf0e10cSrcweir             }
1728cdf0e10cSrcweir             break;
1729cdf0e10cSrcweir             case TBL_DEST_TBL:
1730cdf0e10cSrcweir                 *pActItem = pTableBck_Impl->pTableBrush;
1731cdf0e10cSrcweir                 aLbSelect.Enable();
1732cdf0e10cSrcweir                 nWhich = pTableBck_Impl->nTableWhich;
1733cdf0e10cSrcweir             break;
1734cdf0e10cSrcweir         }
1735cdf0e10cSrcweir         String aUserData = GetUserData();
1736cdf0e10cSrcweir         if(!*pActItem)
1737cdf0e10cSrcweir             *pActItem = new SvxBrushItem(nWhich);
1738cdf0e10cSrcweir         FillControls_Impl(**pActItem, aUserData);
1739cdf0e10cSrcweir         delete pActItem;
1740cdf0e10cSrcweir     }
1741cdf0e10cSrcweir     return 0;
1742cdf0e10cSrcweir }
1743cdf0e10cSrcweir 
1744cdf0e10cSrcweir //-----------------------------------------------------------------------
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir IMPL_LINK( SvxBackgroundTabPage, ParaDestinationHdl_Impl, ListBox*, pBox )
1747cdf0e10cSrcweir {
1748cdf0e10cSrcweir     sal_uInt16 nSelPos = pBox->GetSelectEntryPos();
1749cdf0e10cSrcweir     if( pParaBck_Impl && pParaBck_Impl->nActPos != nSelPos)
1750cdf0e10cSrcweir     {
1751cdf0e10cSrcweir         SvxBrushItem** pActItem = new (SvxBrushItem*);
1752cdf0e10cSrcweir         switch(pParaBck_Impl->nActPos)
1753cdf0e10cSrcweir         {
1754cdf0e10cSrcweir             case PARA_DEST_PARA:
1755cdf0e10cSrcweir                 *pActItem = pParaBck_Impl->pParaBrush;
1756cdf0e10cSrcweir             break;
1757cdf0e10cSrcweir             case PARA_DEST_CHAR:
1758cdf0e10cSrcweir                 *pActItem = pParaBck_Impl->pCharBrush;
1759cdf0e10cSrcweir             break;
1760cdf0e10cSrcweir         }
1761cdf0e10cSrcweir         pParaBck_Impl->nActPos = nSelPos;
1762cdf0e10cSrcweir         if(0 == aLbSelect.GetSelectEntryPos())  // Brush ausgewaehlt
1763cdf0e10cSrcweir         {
1764cdf0e10cSrcweir             sal_uInt16 nWhich = (*pActItem)->Which();
1765cdf0e10cSrcweir             **pActItem = SvxBrushItem( aBgdColor, nWhich );
1766cdf0e10cSrcweir         }
1767cdf0e10cSrcweir         else
1768cdf0e10cSrcweir         {
1769cdf0e10cSrcweir                 SvxGraphicPosition  eNewPos  = GetGraphicPosition_Impl();
1770cdf0e10cSrcweir                 const sal_Bool          bIsLink  = aBtnLink.IsChecked();
1771cdf0e10cSrcweir 
1772cdf0e10cSrcweir                 if ( !bIsLink && !bIsGraphicValid )
1773cdf0e10cSrcweir                     bIsGraphicValid = LoadLinkedGraphic_Impl();
1774cdf0e10cSrcweir 
1775cdf0e10cSrcweir                 if ( bIsLink )
1776cdf0e10cSrcweir                     **pActItem = SvxBrushItem( aBgdGraphicPath,
1777cdf0e10cSrcweir                                                 aBgdGraphicFilter,
1778cdf0e10cSrcweir                                                 eNewPos,
1779cdf0e10cSrcweir                                                 (*pActItem)->Which() );
1780cdf0e10cSrcweir                 else
1781cdf0e10cSrcweir                     **pActItem = SvxBrushItem( aBgdGraphic,
1782cdf0e10cSrcweir                                                 eNewPos,
1783cdf0e10cSrcweir                                                 (*pActItem)->Which() );
1784cdf0e10cSrcweir         }
1785cdf0e10cSrcweir         switch(nSelPos)
1786cdf0e10cSrcweir         {
1787cdf0e10cSrcweir             case PARA_DEST_PARA:
1788cdf0e10cSrcweir                 *pActItem = pParaBck_Impl->pParaBrush;
1789cdf0e10cSrcweir                 aLbSelect.Enable();
1790cdf0e10cSrcweir             break;
1791cdf0e10cSrcweir             case PARA_DEST_CHAR:
1792cdf0e10cSrcweir             {
1793cdf0e10cSrcweir                 *pActItem = pParaBck_Impl->pCharBrush;
1794cdf0e10cSrcweir                 aLbSelect.Enable(sal_False);
1795cdf0e10cSrcweir             }
1796cdf0e10cSrcweir             break;
1797cdf0e10cSrcweir         }
1798cdf0e10cSrcweir         String aUserData = GetUserData();
1799cdf0e10cSrcweir         FillControls_Impl(**pActItem, aUserData);
1800cdf0e10cSrcweir         delete pActItem;
1801cdf0e10cSrcweir     }
1802cdf0e10cSrcweir     return 0;
1803cdf0e10cSrcweir }
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir //-----------------------------------------------------------------------
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir void SvxBackgroundTabPage::FillControls_Impl( const SvxBrushItem& rBgdAttr,
1808cdf0e10cSrcweir                                               const String& rUserData )
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir /*  [Beschreibung]
1811cdf0e10cSrcweir 
1812cdf0e10cSrcweir */
1813cdf0e10cSrcweir 
1814cdf0e10cSrcweir {
1815cdf0e10cSrcweir     SvxGraphicPosition  ePos = rBgdAttr.GetGraphicPos();
1816cdf0e10cSrcweir     const Color& rColor = rBgdAttr.GetColor();
1817cdf0e10cSrcweir     if(bColTransparency)
1818cdf0e10cSrcweir     {
1819cdf0e10cSrcweir         aColTransMF.SetValue(lcl_TransparencyToPercent(rColor.GetTransparency()));
1820cdf0e10cSrcweir         aColTransMF.SaveValue();
1821cdf0e10cSrcweir         sal_Bool bEnableTransp = rColor.GetTransparency() < 0xff;
1822cdf0e10cSrcweir         aColTransFT.Enable(bEnableTransp);
1823cdf0e10cSrcweir         aColTransMF.Enable(bEnableTransp);
1824cdf0e10cSrcweir         //the default setting should be "no transparency"
1825cdf0e10cSrcweir         if(!bEnableTransp)
1826cdf0e10cSrcweir             aColTransMF.SetValue(0);
1827cdf0e10cSrcweir     }
1828cdf0e10cSrcweir 
1829cdf0e10cSrcweir     if ( GPOS_NONE == ePos || !aLbSelect.IsVisible() )
1830cdf0e10cSrcweir     {
1831cdf0e10cSrcweir         aLbSelect.SelectEntryPos( 0 );
1832cdf0e10cSrcweir         ShowColorUI_Impl();
1833cdf0e10cSrcweir         Color aTrColor( COL_TRANSPARENT );
1834cdf0e10cSrcweir         aBgdColor = rColor;
1835cdf0e10cSrcweir 
1836cdf0e10cSrcweir         sal_uInt16 nCol = ( aTrColor != aBgdColor ) ?
1837cdf0e10cSrcweir             GetItemId_Impl( aBackgroundColorSet, aBgdColor ) : 0;
1838cdf0e10cSrcweir 
1839cdf0e10cSrcweir         if( aTrColor != aBgdColor && nCol == 0)
1840cdf0e10cSrcweir         {
1841cdf0e10cSrcweir             aBackgroundColorSet.SetNoSelection();
1842cdf0e10cSrcweir         }
1843cdf0e10cSrcweir         else
1844cdf0e10cSrcweir         {
1845cdf0e10cSrcweir             aBackgroundColorSet.SelectItem( nCol );
1846cdf0e10cSrcweir         }
1847cdf0e10cSrcweir 
1848cdf0e10cSrcweir         pPreviewWin1->NotifyChange( aBgdColor );
1849cdf0e10cSrcweir         if ( aLbSelect.IsVisible() ) // Grafikteil initialisieren
1850cdf0e10cSrcweir         {
1851cdf0e10cSrcweir             aBgdGraphicFilter.Erase();
1852cdf0e10cSrcweir             aBgdGraphicPath.Erase();
1853cdf0e10cSrcweir 
1854cdf0e10cSrcweir             if ( !rUserData.Len() )
1855cdf0e10cSrcweir                 aBtnPreview.Check( sal_False );
1856cdf0e10cSrcweir             aBtnLink.Check( sal_False );
1857cdf0e10cSrcweir             aBtnLink.Disable();
1858cdf0e10cSrcweir             pPreviewWin2->NotifyChange( NULL );
1859cdf0e10cSrcweir             SetGraphicPosition_Impl( GPOS_TILED );  // Kacheln als Default
1860cdf0e10cSrcweir         }
1861cdf0e10cSrcweir     }
1862cdf0e10cSrcweir     else
1863cdf0e10cSrcweir     {
1864cdf0e10cSrcweir         const String*   pStrLink   = rBgdAttr.GetGraphicLink();
1865cdf0e10cSrcweir         const String*   pStrFilter = rBgdAttr.GetGraphicFilter();
1866cdf0e10cSrcweir 
1867cdf0e10cSrcweir         aLbSelect.SelectEntryPos( 1 );
1868cdf0e10cSrcweir         ShowBitmapUI_Impl();
1869cdf0e10cSrcweir 
1870cdf0e10cSrcweir         if ( pStrLink )
1871cdf0e10cSrcweir         {
1872cdf0e10cSrcweir #ifdef DBG_UTIL
1873cdf0e10cSrcweir             INetURLObject aObj( *pStrLink );
1874cdf0e10cSrcweir             DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
1875cdf0e10cSrcweir #endif
1876cdf0e10cSrcweir             aBgdGraphicPath = *pStrLink;
1877cdf0e10cSrcweir             aBtnLink.Check( sal_True );
1878cdf0e10cSrcweir             aBtnLink.Enable();
1879cdf0e10cSrcweir         }
1880cdf0e10cSrcweir         else
1881cdf0e10cSrcweir         {
1882cdf0e10cSrcweir             aBgdGraphicPath.Erase();
1883cdf0e10cSrcweir             aBtnLink.Check( sal_False );
1884cdf0e10cSrcweir             aBtnLink.Disable();
1885cdf0e10cSrcweir         }
1886cdf0e10cSrcweir 
1887cdf0e10cSrcweir         if(bGraphTransparency)
1888cdf0e10cSrcweir         {
1889cdf0e10cSrcweir             const GraphicObject* pObject = rBgdAttr.GetGraphicObject();
1890cdf0e10cSrcweir             if(pObject)
1891cdf0e10cSrcweir                 aGraphTransMF.SetValue(lcl_TransparencyToPercent(pObject->GetAttr().GetTransparency()));
1892cdf0e10cSrcweir             else
1893cdf0e10cSrcweir                 aGraphTransMF.SetValue(0);
1894cdf0e10cSrcweir             aGraphTransMF.SaveValue();
1895cdf0e10cSrcweir         }
1896cdf0e10cSrcweir 
1897cdf0e10cSrcweir         FileClickHdl_Impl( &aBtnLink );
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir         if ( pStrFilter )
1900cdf0e10cSrcweir             aBgdGraphicFilter = *pStrFilter;
1901cdf0e10cSrcweir         else
1902cdf0e10cSrcweir             aBgdGraphicFilter.Erase();
1903cdf0e10cSrcweir 
1904cdf0e10cSrcweir         if ( !pStrLink || aBtnPreview.IsChecked() )
1905cdf0e10cSrcweir         {
1906cdf0e10cSrcweir             // Grafik ist im Item vorhanden und muss nicht
1907cdf0e10cSrcweir             // geladen werden:
1908cdf0e10cSrcweir 
1909cdf0e10cSrcweir             const Graphic* pGraphic = rBgdAttr.GetGraphic();
1910cdf0e10cSrcweir 
1911cdf0e10cSrcweir             if ( !pGraphic && aBtnPreview.IsChecked() )
1912cdf0e10cSrcweir                 bIsGraphicValid = LoadLinkedGraphic_Impl();
1913cdf0e10cSrcweir             else if ( pGraphic )
1914cdf0e10cSrcweir             {
1915cdf0e10cSrcweir                 aBgdGraphic = *pGraphic;
1916cdf0e10cSrcweir                 bIsGraphicValid = sal_True;
1917cdf0e10cSrcweir 
1918cdf0e10cSrcweir                 if ( !rUserData.Len() )
1919cdf0e10cSrcweir                     aBtnPreview.Check();
1920cdf0e10cSrcweir             }
1921cdf0e10cSrcweir             else
1922cdf0e10cSrcweir             {
1923cdf0e10cSrcweir                 RaiseLoadError_Impl();
1924cdf0e10cSrcweir                 bIsGraphicValid = sal_False;
1925cdf0e10cSrcweir 
1926cdf0e10cSrcweir                 if ( !rUserData.Len() )
1927cdf0e10cSrcweir                     aBtnPreview.Check( sal_False );
1928cdf0e10cSrcweir             }
1929cdf0e10cSrcweir         }
1930cdf0e10cSrcweir 
1931cdf0e10cSrcweir         if ( aBtnPreview.IsChecked() && bIsGraphicValid )
1932cdf0e10cSrcweir         {
1933cdf0e10cSrcweir             Bitmap aBmp = aBgdGraphic.GetBitmap();
1934cdf0e10cSrcweir             pPreviewWin2->NotifyChange( &aBmp );
1935cdf0e10cSrcweir         }
1936cdf0e10cSrcweir         else
1937cdf0e10cSrcweir             pPreviewWin2->NotifyChange( NULL );
1938cdf0e10cSrcweir 
1939cdf0e10cSrcweir         SetGraphicPosition_Impl( ePos );
1940cdf0e10cSrcweir     }
1941cdf0e10cSrcweir }
1942cdf0e10cSrcweir /* -----------------------------09.08.2002 14:04------------------------------
1943cdf0e10cSrcweir 
1944cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1945cdf0e10cSrcweir void SvxBackgroundTabPage::EnableTransparency(sal_Bool bColor, sal_Bool bGraphic)
1946cdf0e10cSrcweir {
1947cdf0e10cSrcweir     bColTransparency  = bColor;
1948cdf0e10cSrcweir     bGraphTransparency = bGraphic;
1949cdf0e10cSrcweir     if(bColor)
1950cdf0e10cSrcweir     {
1951cdf0e10cSrcweir         aColTransFT.Show();
1952cdf0e10cSrcweir         aColTransMF.Show();
1953cdf0e10cSrcweir     }
1954cdf0e10cSrcweir     if(bGraphic)
1955cdf0e10cSrcweir     {
1956cdf0e10cSrcweir         Size aRectSize(aWndPosition.GetSizePixel());
1957cdf0e10cSrcweir         Point aRectPos(aWndPosition.GetPosPixel());
1958cdf0e10cSrcweir         Point aFLPos(aGraphTransFL.GetPosPixel());
1959cdf0e10cSrcweir         Size aTmp(LogicToPixel(Size(RSC_SP_FLGR_SPACE_Y, RSC_SP_FLGR_SPACE_Y), MAP_APPFONT));
1960cdf0e10cSrcweir         long nRectHeight = aFLPos.Y() - aRectPos.Y() - aTmp.Height();
1961cdf0e10cSrcweir         aRectSize.Height() = nRectHeight;
1962cdf0e10cSrcweir         aWndPosition.SetSizePixel(aRectSize);
1963cdf0e10cSrcweir         aWndPosition.Invalidate();
1964cdf0e10cSrcweir     }
1965cdf0e10cSrcweir }
1966cdf0e10cSrcweir 
1967cdf0e10cSrcweir void SvxBackgroundTabPage::PageCreated (SfxAllItemSet aSet) //add CHINA001
1968cdf0e10cSrcweir {
1969cdf0e10cSrcweir     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
1970cdf0e10cSrcweir     if (pFlagItem)
1971cdf0e10cSrcweir     {
1972cdf0e10cSrcweir         sal_uInt32 nFlags=pFlagItem->GetValue();
1973cdf0e10cSrcweir         if ( ( nFlags & SVX_SHOW_TBLCTL ) == SVX_SHOW_TBLCTL )
1974cdf0e10cSrcweir             ShowTblControl();
1975cdf0e10cSrcweir         if ( ( nFlags & SVX_SHOW_PARACTL ) == SVX_SHOW_PARACTL )
1976cdf0e10cSrcweir             ShowParaControl();
1977cdf0e10cSrcweir         if ( ( nFlags & SVX_SHOW_SELECTOR ) == SVX_SHOW_SELECTOR )
1978cdf0e10cSrcweir             ShowSelector();
1979cdf0e10cSrcweir         if ( ( nFlags & SVX_ENABLE_TRANSPARENCY ) == SVX_ENABLE_TRANSPARENCY )
1980cdf0e10cSrcweir             EnableTransparency(sal_True, sal_True);
1981cdf0e10cSrcweir     }
1982cdf0e10cSrcweir }
1983