Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/drawing/FillStyle.hpp>
21 : #include <unotools/pathoptions.hxx>
22 : #include <vcl/builder.hxx>
23 : #include <vcl/msgbox.hxx>
24 : #include <vcl/settings.hxx>
25 : #include <tools/urlobj.hxx>
26 : #include <sfx2/dialoghelper.hxx>
27 : #include <sfx2/objsh.hxx>
28 : #include <sfx2/docfile.hxx>
29 : #include <svl/cntwall.hxx>
30 : #include <sfx2/cntids.hrc>
31 : #include <svx/dialogs.hrc>
32 :
33 : #include <cuires.hrc>
34 : #include <svx/dialmgr.hxx>
35 : #include <editeng/memberids.hrc>
36 : #include <editeng/editrids.hrc>
37 : #include <editeng/eerdll.hxx>
38 :
39 : // table background
40 : #define TBL_DEST_CELL 0
41 : #define TBL_DEST_ROW 1
42 : #define TBL_DEST_TBL 2
43 :
44 : #include <editeng/brushitem.hxx>
45 : #include "backgrnd.hxx"
46 :
47 : #include <svx/xtable.hxx>
48 : #include <sfx2/opengrf.hxx>
49 : #include <svx/svxerr.hxx>
50 : #include <svx/drawitem.hxx>
51 : #include <dialmgr.hxx>
52 : #include <sfx2/htmlmode.hxx>
53 : #include <svtools/controldims.hrc>
54 : #include <svx/flagsdef.hxx>
55 : #include <svl/intitem.hxx>
56 : #include <sfx2/request.hxx>
57 : #include <svtools/grfmgr.hxx>
58 : #include <boost/scoped_ptr.hpp>
59 :
60 : using namespace ::com::sun::star;
61 : // static ----------------------------------------------------------------
62 :
63 : static const sal_uInt16 pRanges[] =
64 : {
65 : SID_VIEW_FLD_PIC, SID_VIEW_FLD_PIC,
66 : SID_ATTR_BRUSH, SID_ATTR_BRUSH,
67 : SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR,
68 : 0
69 : };
70 :
71 : struct SvxBackgroundTable_Impl
72 : {
73 : SvxBrushItem* pCellBrush;
74 : SvxBrushItem* pRowBrush;
75 : SvxBrushItem* pTableBrush;
76 : sal_uInt16 nCellWhich;
77 : sal_uInt16 nRowWhich;
78 : sal_uInt16 nTableWhich;
79 : sal_Int32 nActPos;
80 :
81 0 : SvxBackgroundTable_Impl()
82 : : pCellBrush(NULL)
83 : , pRowBrush(NULL)
84 : , pTableBrush(NULL)
85 : , nCellWhich(0)
86 : , nRowWhich(0)
87 : , nTableWhich(0)
88 0 : , nActPos(0)
89 0 : {}
90 : };
91 :
92 : struct SvxBackgroundPara_Impl
93 : {
94 : SvxBrushItem* pParaBrush;
95 : SvxBrushItem* pCharBrush;
96 :
97 : sal_Int32 nActPos;
98 :
99 0 : SvxBackgroundPara_Impl()
100 : : pParaBrush(NULL)
101 : , pCharBrush(NULL)
102 0 : , nActPos(LISTBOX_ENTRY_NOTFOUND)
103 0 : {}
104 :
105 : };
106 :
107 : struct SvxBackgroundPage_Impl
108 : {
109 : Timer* pLoadTimer;
110 : bool bIsImportDlgInExecute;
111 :
112 0 : SvxBackgroundPage_Impl()
113 : : pLoadTimer(NULL)
114 0 : , bIsImportDlgInExecute(false)
115 0 : {}
116 : };
117 :
118 0 : static inline sal_uInt8 lcl_PercentToTransparency(long nPercent)
119 : {
120 : //0xff must not be returned!
121 0 : return sal_uInt8(nPercent ? (50 + 0xfe * nPercent) / 100 : 0);
122 : }
123 0 : static inline sal_uInt8 lcl_TransparencyToPercent(sal_uInt8 nTrans)
124 : {
125 0 : return (nTrans * 100 + 127) / 254;
126 : }
127 0 : static void lcl_SetTransparency(SvxBrushItem& rBrush, long nTransparency)
128 : {
129 0 : uno::Any aTransparency;
130 0 : aTransparency <<= (sal_Int8)nTransparency;
131 0 : rBrush.PutValue(aTransparency, MID_GRAPHIC_TRANSPARENCY);
132 0 : }
133 :
134 : /// Returns the fill style of the currently selected entry.
135 0 : static drawing::FillStyle lcl_getFillStyle(ListBox* pLbSelect)
136 : {
137 0 : return (drawing::FillStyle)reinterpret_cast<sal_uLong>(pLbSelect->GetEntryData(pLbSelect->GetSelectEntryPos()));
138 : }
139 :
140 : // Selects the entry matching the specified fill style.
141 0 : static void lcl_setFillStyle(ListBox* pLbSelect, drawing::FillStyle eStyle)
142 : {
143 0 : for (int i = 0; i < pLbSelect->GetEntryCount(); ++i)
144 0 : if ((drawing::FillStyle)reinterpret_cast<sal_uLong>(pLbSelect->GetEntryData(i)) == eStyle)
145 : {
146 0 : pLbSelect->SelectEntryPos(i);
147 0 : return;
148 : }
149 : }
150 :
151 :
152 0 : sal_uInt16 GetItemId_Impl( ValueSet& rValueSet, const Color& rCol )
153 : {
154 0 : bool bFound = false;
155 0 : sal_uInt16 nCount = rValueSet.GetItemCount();
156 0 : sal_uInt16 n = 1;
157 :
158 0 : while ( !bFound && n <= nCount )
159 : {
160 0 : Color aValCol = rValueSet.GetItemColor(n);
161 :
162 0 : bFound = ( aValCol.GetRed() == rCol.GetRed()
163 0 : && aValCol.GetGreen() == rCol.GetGreen()
164 0 : && aValCol.GetBlue() == rCol.GetBlue() );
165 :
166 0 : if ( !bFound )
167 0 : n++;
168 : }
169 0 : return bFound ? n : 0;
170 : }
171 :
172 : // class BackgroundPreview -----------------------------------------------
173 :
174 : /* [Description]
175 :
176 : preview window for brush or bitmap
177 : */
178 :
179 : class BackgroundPreviewImpl : public vcl::Window
180 : {
181 : public:
182 : BackgroundPreviewImpl(vcl::Window* pParent);
183 : void setBmp(bool bBmp);
184 : virtual ~BackgroundPreviewImpl();
185 :
186 : void NotifyChange( const Color& rColor );
187 : void NotifyChange( const Bitmap* pBitmap );
188 :
189 : protected:
190 : virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
191 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
192 : virtual void Resize() SAL_OVERRIDE;
193 :
194 : private:
195 :
196 : void recalcDrawPos();
197 :
198 : bool bIsBmp;
199 : Bitmap* pBitmap;
200 : Point aDrawPos;
201 : Size aDrawSize;
202 : Rectangle aDrawRect;
203 : sal_uInt8 nTransparency;
204 : };
205 :
206 0 : BackgroundPreviewImpl::BackgroundPreviewImpl(vcl::Window* pParent)
207 : : Window(pParent, WB_BORDER)
208 : , bIsBmp(false)
209 : , pBitmap(NULL)
210 0 : , aDrawRect(Point(0,0), GetOutputSizePixel())
211 0 : , nTransparency(0)
212 : {
213 0 : SetBorderStyle(WindowBorderStyle::MONO);
214 0 : Paint(aDrawRect);
215 0 : }
216 :
217 0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeBackgroundPreview(vcl::Window *pParent, VclBuilder::stringmap &)
218 : {
219 0 : return new BackgroundPreviewImpl(pParent);
220 : }
221 :
222 0 : void BackgroundPreviewImpl::setBmp(bool bBmp)
223 : {
224 0 : bIsBmp = bBmp;
225 0 : Invalidate();
226 0 : }
227 :
228 :
229 :
230 0 : BackgroundPreviewImpl::~BackgroundPreviewImpl()
231 : {
232 0 : delete pBitmap;
233 0 : }
234 :
235 :
236 0 : void BackgroundPreviewImpl::NotifyChange( const Color& rColor )
237 : {
238 0 : if ( !bIsBmp )
239 : {
240 0 : const static Color aTranspCol( COL_TRANSPARENT );
241 :
242 0 : nTransparency = lcl_TransparencyToPercent( rColor.GetTransparency() );
243 :
244 0 : SetFillColor( rColor == aTranspCol ? GetSettings().GetStyleSettings().GetFieldColor() : Color(rColor.GetRGBColor()) );
245 0 : Paint( aDrawRect );
246 : }
247 0 : }
248 :
249 :
250 :
251 0 : void BackgroundPreviewImpl::NotifyChange( const Bitmap* pNewBitmap )
252 : {
253 0 : if ( bIsBmp && (pNewBitmap || pBitmap) )
254 : {
255 0 : if ( pNewBitmap && pBitmap )
256 0 : *pBitmap = *pNewBitmap;
257 0 : else if ( pNewBitmap && !pBitmap )
258 0 : pBitmap = new Bitmap( *pNewBitmap );
259 0 : else if ( !pNewBitmap )
260 0 : DELETEZ( pBitmap );
261 :
262 0 : recalcDrawPos();
263 :
264 0 : Invalidate( aDrawRect );
265 0 : Update();
266 : }
267 0 : }
268 :
269 0 : void BackgroundPreviewImpl::recalcDrawPos()
270 : {
271 0 : if ( pBitmap )
272 : {
273 0 : Size aSize = GetOutputSizePixel();
274 : // InnerSize == Size without one pixel border
275 0 : Size aInnerSize = aSize;
276 0 : aInnerSize.Width() -= 2;
277 0 : aInnerSize.Height() -= 2;
278 0 : aDrawSize = pBitmap->GetSizePixel();
279 :
280 : // bitmap bigger than preview window?
281 0 : if ( aDrawSize.Width() > aInnerSize.Width() )
282 : {
283 0 : aDrawSize.Height() = aDrawSize.Height() * aInnerSize.Width() / aDrawSize.Width();
284 0 : if ( aDrawSize.Height() > aInnerSize.Height() )
285 : {
286 0 : aDrawSize.Width() = aDrawSize.Height();
287 0 : aDrawSize.Height() = aInnerSize.Height();
288 : }
289 : else
290 0 : aDrawSize.Width() = aInnerSize.Width();
291 : }
292 0 : else if ( aDrawSize.Height() > aInnerSize.Height() )
293 : {
294 0 : aDrawSize.Width() = aDrawSize.Width() * aInnerSize.Height() / aDrawSize.Height();
295 0 : if ( aDrawSize.Width() > aInnerSize.Width() )
296 : {
297 0 : aDrawSize.Height() = aDrawSize.Width();
298 0 : aDrawSize.Width() = aInnerSize.Width();
299 : }
300 : else
301 0 : aDrawSize.Height() = aInnerSize.Height();
302 : }
303 :
304 0 : aDrawPos.X() = (aSize.Width() - aDrawSize.Width()) / 2;
305 0 : aDrawPos.Y() = (aSize.Height() - aDrawSize.Height()) / 2;
306 : }
307 0 : }
308 :
309 0 : void BackgroundPreviewImpl::Resize()
310 : {
311 0 : Window::Resize();
312 0 : aDrawRect = Rectangle(Point(0,0), GetOutputSizePixel());
313 0 : recalcDrawPos();
314 0 : }
315 :
316 :
317 :
318 0 : void BackgroundPreviewImpl::Paint( const Rectangle& )
319 : {
320 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
321 0 : SetBackground(Wallpaper(rStyleSettings.GetWindowColor()));
322 0 : SetLineColor();
323 0 : if(bIsBmp)
324 0 : SetFillColor( Color(COL_TRANSPARENT) );
325 0 : DrawRect( aDrawRect );
326 0 : if ( bIsBmp )
327 : {
328 0 : if ( pBitmap )
329 0 : DrawBitmap( aDrawPos, aDrawSize, *pBitmap );
330 : else
331 : {
332 0 : Size aSize = GetOutputSizePixel();
333 0 : DrawLine( Point(0,0), Point(aSize.Width(),aSize.Height()) );
334 0 : DrawLine( Point(0,aSize.Height()), Point(aSize.Width(),0) );
335 : }
336 : }
337 0 : }
338 :
339 0 : void BackgroundPreviewImpl::DataChanged( const DataChangedEvent& rDCEvt )
340 : {
341 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
342 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
343 : {
344 0 : Invalidate();
345 : }
346 0 : Window::DataChanged( rDCEvt );
347 0 : }
348 :
349 : // class SvxBackgroundTabPage --------------------------------------------
350 :
351 : #define HDL(hdl) LINK(this,SvxBackgroundTabPage,hdl)
352 :
353 0 : SvxBackgroundTabPage::SvxBackgroundTabPage(vcl::Window* pParent, const SfxItemSet& rCoreSet)
354 : : SvxTabPage(pParent, "BackgroundPage", "cui/ui/backgroundpage.ui", rCoreSet)
355 : , nHtmlMode(0)
356 : , bAllowShowSelector(true)
357 : , bIsGraphicValid(false)
358 : , bLinkOnly(false)
359 : , bColTransparency(false)
360 : , bGraphTransparency(false)
361 0 : , pPageImpl(new SvxBackgroundPage_Impl)
362 : , pImportDlg(NULL)
363 : , pTableBck_Impl(NULL)
364 0 : , pParaBck_Impl(NULL)
365 : {
366 0 : get(m_pAsGrid, "asgrid");
367 0 : get(m_pSelectTxt, "asft");
368 0 : get(m_pLbSelect, "selectlb");
369 0 : get(m_pTblDesc, "forft");
370 0 : get(m_pTblLBox, "tablelb");
371 0 : get(m_pParaLBox, "paralb");
372 :
373 0 : get(m_pBackGroundColorFrame, "backgroundcolorframe");
374 0 : get(m_pBackgroundColorSet, "backgroundcolorset");
375 0 : get(m_pPreviewWin1, "preview1");
376 :
377 0 : get(m_pColTransFT, "transparencyft");
378 0 : get(m_pColTransMF, "transparencymf");
379 0 : get(m_pBtnPreview, "showpreview");
380 :
381 0 : get(m_pBitmapContainer, "graphicgrid");
382 0 : get(m_pFileFrame, "fileframe");
383 0 : get(m_pBtnBrowse, "browse");
384 0 : get(m_pBtnLink, "link");
385 0 : get(m_pFtUnlinked, "unlinkedft");
386 0 : get(m_pFtFile, "fileft");
387 :
388 0 : get(m_pTypeFrame, "typeframe");
389 0 : get(m_pBtnPosition, "positionrb");
390 0 : get(m_pBtnArea, "arearb");
391 0 : get(m_pBtnTile, "tilerb");
392 0 : get(m_pWndPosition, "windowpos");
393 :
394 0 : get(m_pGraphTransFrame, "graphtransframe");
395 0 : get(m_pGraphTransMF, "graphtransmf");
396 :
397 0 : get(m_pPreviewWin2, "preview2");
398 0 : m_pPreviewWin2->setBmp(true);
399 :
400 : // this page needs ExchangeSupport
401 0 : SetExchangeSupport();
402 :
403 : const SfxPoolItem* pItem;
404 : SfxObjectShell* pShell;
405 :
406 0 : if ( SfxItemState::SET == rCoreSet.GetItemState( SID_HTML_MODE, false, &pItem )
407 0 : || ( 0 != ( pShell = SfxObjectShell::Current()) &&
408 0 : 0 != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
409 : {
410 0 : nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
411 : }
412 :
413 0 : FillColorValueSets_Impl();
414 :
415 0 : m_pBackgroundColorSet->SetSelectHdl( HDL(BackgroundColorHdl_Impl) );
416 0 : m_pBackgroundColorSet->SetStyle(m_pBackgroundColorSet->GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD);
417 0 : m_pBackgroundColorSet->SetText(SVX_RESSTR(RID_SVXSTR_TRANSPARENT));
418 0 : }
419 :
420 :
421 :
422 0 : SvxBackgroundTabPage::~SvxBackgroundTabPage()
423 : {
424 0 : delete pPageImpl->pLoadTimer;
425 0 : delete pPageImpl;
426 0 : delete pImportDlg;
427 :
428 0 : if( pTableBck_Impl)
429 : {
430 0 : delete pTableBck_Impl->pCellBrush;
431 0 : delete pTableBck_Impl->pRowBrush;
432 0 : delete pTableBck_Impl->pTableBrush;
433 0 : delete pTableBck_Impl;
434 : }
435 :
436 0 : if(pParaBck_Impl)
437 : {
438 0 : delete pParaBck_Impl->pParaBrush;
439 0 : delete pParaBck_Impl->pCharBrush;
440 0 : delete pParaBck_Impl;
441 : }
442 0 : }
443 :
444 :
445 :
446 0 : const sal_uInt16* SvxBackgroundTabPage::GetRanges()
447 :
448 : /* [Description]
449 :
450 : returns the area of the which-values
451 : */
452 :
453 : {
454 0 : return pRanges;
455 : }
456 :
457 :
458 :
459 0 : SfxTabPage* SvxBackgroundTabPage::Create( vcl::Window* pParent,
460 : const SfxItemSet* rAttrSet )
461 :
462 : /* [Description]
463 :
464 : create method for the TabDialog
465 : */
466 :
467 : {
468 0 : return ( new SvxBackgroundTabPage( pParent, *rAttrSet ) );
469 : }
470 :
471 :
472 :
473 0 : void SvxBackgroundTabPage::Reset( const SfxItemSet* rSet )
474 : {
475 : // os: Such a nonsense! One will always find such an item somewhere,
476 : // but it must be existing in the rSet!
477 : // const SfxPoolItem* pX = GetOldItem( rSet, SID_VIEW_FLD_PIC );
478 : // if( pX && pX->ISA(SfxWallpaperItem))
479 0 : if(SfxItemState::DEFAULT <= rSet->GetItemState(GetWhich(SID_VIEW_FLD_PIC), false))
480 : {
481 0 : ResetFromWallpaperItem( *rSet );
482 0 : return;
483 : }
484 :
485 : // condition of the preview button is persistent due to UserData
486 0 : OUString aUserData = GetUserData();
487 0 : m_pBtnPreview->Check( !aUserData.isEmpty() && '1' == aUserData[0] );
488 :
489 : // don't be allowed to call ShowSelector() after reset anymore
490 0 : bAllowShowSelector = false;
491 :
492 :
493 : // get and evaluate Input-BrushItem
494 0 : const SvxBrushItem* pBgdAttr = NULL;
495 0 : sal_uInt16 nSlot = SID_ATTR_BRUSH;
496 : const SfxPoolItem* pItem;
497 0 : sal_uInt16 nDestValue = USHRT_MAX;
498 :
499 0 : if ( SfxItemState::SET == rSet->GetItemState( SID_BACKGRND_DESTINATION,
500 0 : false, &pItem ) )
501 : {
502 0 : nDestValue = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
503 0 : m_pTblLBox->SelectEntryPos(nDestValue);
504 :
505 0 : switch ( nDestValue )
506 : {
507 : case TBL_DEST_CELL:
508 0 : nSlot = SID_ATTR_BRUSH;
509 0 : break;
510 : case TBL_DEST_ROW:
511 0 : nSlot = SID_ATTR_BRUSH_ROW;
512 0 : break;
513 : case TBL_DEST_TBL:
514 0 : nSlot = SID_ATTR_BRUSH_TABLE;
515 0 : break;
516 : }
517 : }
518 0 : else if( SfxItemState::SET == rSet->GetItemState(
519 0 : SID_PARA_BACKGRND_DESTINATION, false, &pItem ) )
520 : {
521 0 : nDestValue = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
522 : // character activated?
523 0 : sal_Int32 nParaSel = m_pParaLBox->GetSelectEntryPos();
524 0 : if(1 == nParaSel)
525 : {
526 : // then it was a "standard"-call
527 0 : nDestValue = nParaSel;
528 : }
529 0 : m_pParaLBox->SelectEntryPos(nDestValue);
530 :
531 0 : switch ( nDestValue )
532 : {
533 : case PARA_DEST_PARA:
534 0 : nSlot = SID_ATTR_BRUSH;
535 0 : break;
536 : case PARA_DEST_CHAR:
537 0 : nSlot = SID_ATTR_BRUSH_CHAR;
538 0 : break;
539 : }
540 : }
541 : //#111173# the destination item is missing when the parent style has been changed
542 0 : if(USHRT_MAX == nDestValue && (m_pParaLBox->IsVisible()||m_pTblLBox->IsVisible()))
543 0 : nDestValue = 0;
544 0 : sal_uInt16 nWhich = GetWhich( nSlot );
545 :
546 0 : if ( rSet->GetItemState( nWhich, false ) >= SfxItemState::DEFAULT )
547 0 : pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( nWhich ) ));
548 :
549 0 : m_pBtnTile->Check();
550 :
551 0 : if ( pBgdAttr )
552 : {
553 0 : FillControls_Impl(*pBgdAttr, aUserData);
554 0 : aBgdColor = ( (SvxBrushItem*)pBgdAttr )->GetColor();
555 : }
556 : else
557 : {
558 0 : m_pSelectTxt->Hide();
559 0 : m_pLbSelect->Hide();
560 0 : lcl_setFillStyle(m_pLbSelect, drawing::FillStyle_SOLID);
561 0 : ShowColorUI_Impl();
562 :
563 0 : const SfxPoolItem* pOld = GetOldItem( *rSet, SID_ATTR_BRUSH );
564 :
565 0 : if ( pOld )
566 0 : aBgdColor = static_cast<const SvxBrushItem*>(pOld)->GetColor();
567 : }
568 :
569 0 : if ( nDestValue != USHRT_MAX )
570 : {
571 0 : if(m_pTblLBox->IsVisible())
572 : {
573 0 : sal_Int32 nValue = m_pTblLBox->GetSelectEntryPos();
574 :
575 0 : if ( pTableBck_Impl )
576 : {
577 0 : DELETEZ( pTableBck_Impl->pCellBrush);
578 0 : DELETEZ( pTableBck_Impl->pRowBrush);
579 0 : DELETEZ( pTableBck_Impl->pTableBrush);
580 : }
581 : else
582 0 : pTableBck_Impl = new SvxBackgroundTable_Impl();
583 :
584 0 : pTableBck_Impl->nActPos = nValue;
585 :
586 0 : nWhich = GetWhich( SID_ATTR_BRUSH );
587 0 : if ( rSet->GetItemState( nWhich, false ) >= SfxItemState::DEFAULT )
588 : {
589 0 : pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( nWhich ) ));
590 0 : pTableBck_Impl->pCellBrush = new SvxBrushItem(*pBgdAttr);
591 : }
592 0 : pTableBck_Impl->nCellWhich = nWhich;
593 :
594 0 : if ( rSet->GetItemState( SID_ATTR_BRUSH_ROW, false ) >= SfxItemState::DEFAULT )
595 : {
596 0 : pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( SID_ATTR_BRUSH_ROW ) ));
597 0 : pTableBck_Impl->pRowBrush = new SvxBrushItem(*pBgdAttr);
598 : }
599 0 : pTableBck_Impl->nRowWhich = SID_ATTR_BRUSH_ROW;
600 :
601 0 : if ( rSet->GetItemState( SID_ATTR_BRUSH_TABLE, false ) >= SfxItemState::DEFAULT )
602 : {
603 0 : pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( SID_ATTR_BRUSH_TABLE ) ));
604 0 : pTableBck_Impl->pTableBrush = new SvxBrushItem(*pBgdAttr);
605 : }
606 0 : pTableBck_Impl->nTableWhich = SID_ATTR_BRUSH_TABLE;
607 :
608 0 : TblDestinationHdl_Impl(m_pTblLBox);
609 0 : m_pTblLBox->SaveValue();
610 : }
611 : else
612 : {
613 0 : sal_Int32 nValue = m_pParaLBox->GetSelectEntryPos();
614 :
615 0 : if ( pParaBck_Impl )
616 : {
617 0 : delete pParaBck_Impl->pParaBrush;
618 0 : delete pParaBck_Impl->pCharBrush;
619 : }
620 : else
621 0 : pParaBck_Impl = new SvxBackgroundPara_Impl();
622 :
623 0 : pParaBck_Impl->nActPos = nValue;
624 :
625 0 : nWhich = GetWhich( SID_ATTR_BRUSH );
626 0 : if ( rSet->GetItemState( nWhich, false ) >= SfxItemState::DEFAULT )
627 : {
628 0 : pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( nWhich ) ));
629 0 : pParaBck_Impl->pParaBrush = new SvxBrushItem(*pBgdAttr);
630 : }
631 :
632 0 : nWhich = GetWhich( SID_ATTR_BRUSH_CHAR );
633 0 : rSet->GetItemState( nWhich, true );
634 0 : rSet->GetItemState( nWhich, false );
635 0 : if ( rSet->GetItemState( nWhich, true ) > SfxItemState::DEFAULT )
636 : {
637 0 : pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( nWhich ) ));
638 0 : pParaBck_Impl->pCharBrush = new SvxBrushItem(*pBgdAttr);
639 : }
640 : else
641 0 : pParaBck_Impl->pCharBrush = new SvxBrushItem(SID_ATTR_BRUSH_CHAR);
642 :
643 0 : ParaDestinationHdl_Impl(m_pParaLBox);
644 0 : m_pParaLBox->SaveValue();
645 : }
646 0 : }
647 : }
648 :
649 0 : void SvxBackgroundTabPage::ResetFromWallpaperItem( const SfxItemSet& rSet )
650 : {
651 0 : ShowSelector();
652 :
653 : // condition of the preview button is persistent due to UserData
654 0 : OUString aUserData = GetUserData();
655 0 : m_pBtnPreview->Check( !aUserData.isEmpty() && '1' == aUserData[0] );
656 :
657 : // get and evaluate Input-BrushItem
658 0 : const SvxBrushItem* pBgdAttr = NULL;
659 0 : sal_uInt16 nSlot = SID_VIEW_FLD_PIC;
660 0 : sal_uInt16 nWhich = GetWhich( nSlot );
661 0 : boost::scoped_ptr<SvxBrushItem> pTemp;
662 :
663 0 : if ( rSet.GetItemState( nWhich, false ) >= SfxItemState::DEFAULT )
664 : {
665 0 : const CntWallpaperItem* pItem = static_cast<const CntWallpaperItem*>(&rSet.Get( nWhich ));
666 0 : pTemp.reset(new SvxBrushItem( *pItem, nWhich ));
667 0 : pBgdAttr = pTemp.get();
668 : }
669 :
670 0 : m_pBtnTile->Check();
671 :
672 0 : if ( pBgdAttr )
673 : {
674 0 : FillControls_Impl(*pBgdAttr, aUserData);
675 : // brush shall be kept when showing the graphic, too
676 0 : if( aBgdColor != pBgdAttr->GetColor() )
677 : {
678 0 : aBgdColor = pBgdAttr->GetColor();
679 0 : sal_uInt16 nCol = GetItemId_Impl(*m_pBackgroundColorSet, aBgdColor);
680 0 : m_pBackgroundColorSet->SelectItem( nCol );
681 0 : m_pPreviewWin1->NotifyChange( aBgdColor );
682 : }
683 : }
684 : else
685 : {
686 0 : lcl_setFillStyle(m_pLbSelect, drawing::FillStyle_SOLID);
687 0 : ShowColorUI_Impl();
688 :
689 0 : const SfxPoolItem* pOld = GetOldItem( rSet, SID_VIEW_FLD_PIC );
690 0 : if ( pOld )
691 0 : aBgdColor = Color( static_cast<const CntWallpaperItem*>(pOld)->GetColor() );
692 : }
693 :
694 : // We now have always a link to the background
695 0 : bLinkOnly = true;
696 0 : m_pBtnLink->Check( true );
697 0 : m_pBtnLink->Show( false );
698 0 : }
699 :
700 :
701 :
702 :
703 :
704 0 : void SvxBackgroundTabPage::FillUserData()
705 :
706 : /* [Description]
707 :
708 : When destroying a SfxTabPage this virtual method is called,
709 : so that the TabPage can save internal information.
710 :
711 : In this case the condition of the preview button is saved.
712 : */
713 :
714 : {
715 0 : SetUserData( m_pBtnPreview->IsChecked() ? OUString('1') : OUString('0') );
716 0 : }
717 :
718 :
719 :
720 0 : bool SvxBackgroundTabPage::FillItemSet( SfxItemSet* rCoreSet )
721 : {
722 0 : if ( pPageImpl->pLoadTimer && pPageImpl->pLoadTimer->IsActive() )
723 : {
724 0 : pPageImpl->pLoadTimer->Stop();
725 0 : LoadTimerHdl_Impl( pPageImpl->pLoadTimer );
726 : }
727 : // os: Such a nonsense! One will always find such an item somewhere,
728 : // but it must be existing in the rSet!
729 :
730 : // const SfxPoolItem* pX = GetOldItem( rCoreSet, SID_VIEW_FLD_PIC );
731 : // if( pX && pX->ISA(SfxWallpaperItem))
732 0 : if(SfxItemState::DEFAULT <= rCoreSet->GetItemState(GetWhich(SID_VIEW_FLD_PIC), false))
733 0 : return FillItemSetWithWallpaperItem( *rCoreSet, SID_VIEW_FLD_PIC );
734 :
735 0 : bool bModified = false;
736 0 : sal_uInt16 nSlot = SID_ATTR_BRUSH;
737 :
738 0 : if ( m_pTblLBox->IsVisible() )
739 : {
740 0 : switch( m_pTblLBox->GetSelectEntryPos() )
741 : {
742 : case TBL_DEST_CELL:
743 0 : nSlot = SID_ATTR_BRUSH;
744 0 : break;
745 : case TBL_DEST_ROW:
746 0 : nSlot = SID_ATTR_BRUSH_ROW;
747 0 : break;
748 : case TBL_DEST_TBL:
749 0 : nSlot = SID_ATTR_BRUSH_TABLE;
750 0 : break;
751 : }
752 : }
753 0 : else if (m_pParaLBox->GetData() == m_pParaLBox)
754 : {
755 0 : switch(m_pParaLBox->GetSelectEntryPos())
756 : {
757 : case PARA_DEST_PARA:
758 0 : nSlot = SID_ATTR_BRUSH;
759 0 : break;
760 : case PARA_DEST_CHAR:
761 0 : nSlot = SID_ATTR_BRUSH_CHAR;
762 0 : break;
763 : }
764 : }
765 0 : sal_uInt16 nWhich = GetWhich( nSlot );
766 :
767 0 : const SfxPoolItem* pOld = GetOldItem( *rCoreSet, nSlot );
768 0 : SfxItemState eOldItemState = rCoreSet->GetItemState(nSlot, false);
769 0 : const SfxItemSet& rOldSet = GetItemSet();
770 :
771 0 : bool bGraphTransparencyChanged = bGraphTransparency && m_pGraphTransMF->IsValueChangedFromSaved();
772 0 : if ( pOld )
773 : {
774 0 : const SvxBrushItem& rOldItem = static_cast<const SvxBrushItem&>(*pOld);
775 0 : SvxGraphicPosition eOldPos = rOldItem.GetGraphicPos();
776 0 : const bool bIsBrush = ( drawing::FillStyle_SOLID == lcl_getFillStyle(m_pLbSelect) );
777 :
778 : // transparency has to be set if enabled, the color not already set to "No fill" and
779 0 : if( bColTransparency &&
780 0 : aBgdColor.GetTransparency() < 0xff)
781 : {
782 0 : aBgdColor.SetTransparency(lcl_PercentToTransparency(static_cast<long>(m_pColTransMF->GetValue())));
783 : }
784 0 : if ( ( (GPOS_NONE == eOldPos) && bIsBrush )
785 0 : || ( (GPOS_NONE != eOldPos) && !bIsBrush ) ) // Brush <-> Bitmap changed?
786 : {
787 : // background art hasn't been changed:
788 :
789 0 : if ( (GPOS_NONE == eOldPos) || !m_pLbSelect->IsVisible() )
790 : {
791 : // Brush-treatment:
792 0 : if ( rOldItem.GetColor() != aBgdColor ||
793 0 : (SfxItemState::DEFAULT >= eOldItemState && !m_pBackgroundColorSet->IsNoSelection()))
794 : {
795 0 : bModified = true;
796 0 : rCoreSet->Put( SvxBrushItem( aBgdColor, nWhich ) );
797 : }
798 0 : else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
799 0 : rCoreSet->ClearItem( nWhich );
800 : }
801 : else
802 : {
803 : // Bitmap-treatment:
804 :
805 0 : SvxGraphicPosition eNewPos = GetGraphicPosition_Impl();
806 0 : const bool bIsLink = m_pBtnLink->IsChecked();
807 0 : const bool bWasLink = (NULL != rOldItem.GetGraphicLink() );
808 :
809 :
810 0 : if ( !bIsLink && !bIsGraphicValid )
811 0 : bIsGraphicValid = LoadLinkedGraphic_Impl();
812 :
813 0 : if ( bGraphTransparencyChanged ||
814 : eNewPos != eOldPos
815 0 : || bIsLink != bWasLink
816 0 : || ( bWasLink && rOldItem.GetGraphicLink()
817 0 : != aBgdGraphicPath )
818 0 : || ( !bWasLink && rOldItem.GetGraphic()->GetBitmap()
819 0 : != aBgdGraphic.GetBitmap() )
820 : )
821 : {
822 0 : bModified = true;
823 :
824 0 : SvxBrushItem aTmpBrush(nWhich);
825 0 : if ( bIsLink )
826 : {
827 0 : aTmpBrush = SvxBrushItem( aBgdGraphicPath,
828 : aBgdGraphicFilter,
829 : eNewPos,
830 0 : nWhich );
831 : }
832 : else
833 0 : aTmpBrush = SvxBrushItem( aBgdGraphic,
834 : eNewPos,
835 0 : nWhich );
836 0 : lcl_SetTransparency(aTmpBrush, static_cast<long>(m_pGraphTransMF->GetValue()));
837 :
838 0 : rCoreSet->Put(aTmpBrush);
839 : }
840 0 : else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
841 0 : rCoreSet->ClearItem( nWhich );
842 0 : }
843 : }
844 : else // Brush <-> Bitmap changed!
845 : {
846 0 : if ( bIsBrush )
847 : {
848 0 : rCoreSet->Put( SvxBrushItem( aBgdColor, nWhich ) );
849 : }
850 : else
851 : {
852 0 : boost::scoped_ptr<SvxBrushItem> pTmpBrush;
853 0 : if ( m_pBtnLink->IsChecked() )
854 : {
855 : pTmpBrush.reset(new SvxBrushItem( aBgdGraphicPath,
856 : aBgdGraphicFilter,
857 : GetGraphicPosition_Impl(),
858 0 : nWhich ));
859 : }
860 : else
861 : {
862 0 : if ( !bIsGraphicValid )
863 0 : bIsGraphicValid = LoadLinkedGraphic_Impl();
864 :
865 0 : if ( bIsGraphicValid )
866 : pTmpBrush.reset(new SvxBrushItem( aBgdGraphic,
867 : GetGraphicPosition_Impl(),
868 0 : nWhich ));
869 : }
870 0 : if(pTmpBrush)
871 : {
872 0 : lcl_SetTransparency(*pTmpBrush, static_cast<long>(m_pGraphTransMF->GetValue()));
873 0 : rCoreSet->Put(*pTmpBrush);
874 0 : }
875 : }
876 0 : bModified = ( bIsBrush || m_pBtnLink->IsChecked() || bIsGraphicValid );
877 : }
878 : }
879 0 : else if ( SID_ATTR_BRUSH_CHAR == nSlot && aBgdColor != Color( COL_WHITE ) )
880 : {
881 0 : rCoreSet->Put( SvxBrushItem( aBgdColor, nWhich ) );
882 0 : bModified = true;
883 : }
884 :
885 0 : if( m_pTblLBox->IsVisible() )
886 : {
887 : // the current condition has already been put
888 0 : if( nSlot != SID_ATTR_BRUSH && pTableBck_Impl->pCellBrush)
889 : {
890 : const SfxPoolItem* pOldCell =
891 0 : GetOldItem( *rCoreSet, SID_ATTR_BRUSH );
892 :
893 0 : if ( *pTableBck_Impl->pCellBrush != *pOldCell )
894 : {
895 0 : rCoreSet->Put( *pTableBck_Impl->pCellBrush );
896 0 : bModified |= true;
897 : }
898 : }
899 :
900 0 : if( nSlot != SID_ATTR_BRUSH_ROW && pTableBck_Impl->pRowBrush)
901 : {
902 : const SfxPoolItem* pOldRow =
903 0 : GetOldItem( *rCoreSet, SID_ATTR_BRUSH_ROW );
904 :
905 0 : if ( *pTableBck_Impl->pRowBrush != *pOldRow )
906 : {
907 0 : rCoreSet->Put( *pTableBck_Impl->pRowBrush );
908 0 : bModified |= true;
909 : }
910 : }
911 :
912 0 : if( nSlot != SID_ATTR_BRUSH_TABLE && pTableBck_Impl->pTableBrush)
913 : {
914 : const SfxPoolItem* pOldTable =
915 0 : GetOldItem( *rCoreSet, SID_ATTR_BRUSH_TABLE );
916 :
917 0 : if ( *pTableBck_Impl->pTableBrush != *pOldTable )
918 : {
919 0 : rCoreSet->Put( *pTableBck_Impl->pTableBrush );
920 0 : bModified |= true;
921 : }
922 : }
923 :
924 0 : if( m_pTblLBox->IsValueChangedFromSaved() )
925 : {
926 : rCoreSet->Put( SfxUInt16Item( SID_BACKGRND_DESTINATION,
927 0 : m_pTblLBox->GetSelectEntryPos() ) );
928 0 : bModified |= true;
929 : }
930 : }
931 0 : else if (m_pParaLBox->GetData() == m_pParaLBox)
932 : {
933 : // the current condition has already been put
934 0 : if( nSlot != SID_ATTR_BRUSH && m_pParaLBox->IsVisible()) // not in search format dialog
935 : {
936 : const SfxPoolItem* pOldPara =
937 0 : GetOldItem( *rCoreSet, SID_ATTR_BRUSH );
938 :
939 0 : if ( *pParaBck_Impl->pParaBrush != *pOldPara )
940 : {
941 0 : rCoreSet->Put( *pParaBck_Impl->pParaBrush );
942 0 : bModified |= true;
943 : }
944 : }
945 :
946 0 : if( nSlot != SID_ATTR_BRUSH_CHAR )
947 : {
948 : const SfxPoolItem* pOldChar =
949 0 : GetOldItem( *rCoreSet, SID_ATTR_BRUSH_CHAR );
950 : DBG_ASSERT(pParaBck_Impl, "pParaBck_Impl == NULL ?");
951 0 : if ( pOldChar &&
952 : //#111173# crash report shows that pParaBck_Impl can be NULL, the cause is unknown
953 0 : pParaBck_Impl &&
954 0 : (*pParaBck_Impl->pCharBrush != *pOldChar ||
955 0 : *pParaBck_Impl->pCharBrush != SvxBrushItem(SID_ATTR_BRUSH_CHAR)))
956 : {
957 0 : rCoreSet->Put( *pParaBck_Impl->pCharBrush );
958 0 : bModified |= true;
959 : }
960 : }
961 :
962 0 : if( m_pParaLBox->IsValueChangedFromSaved() )
963 : {
964 : rCoreSet->Put( SfxUInt16Item( SID_BACKGRND_DESTINATION,
965 0 : m_pParaLBox->GetSelectEntryPos() ) );
966 0 : bModified |= true;
967 : }
968 : }
969 0 : return bModified;
970 : }
971 :
972 0 : bool SvxBackgroundTabPage::FillItemSetWithWallpaperItem( SfxItemSet& rCoreSet, sal_uInt16 nSlot)
973 : {
974 0 : sal_uInt16 nWhich = GetWhich( nSlot );
975 0 : const SfxPoolItem* pOld = GetOldItem( rCoreSet, nSlot );
976 : DBG_ASSERT(pOld,"FillItemSetWithWallpaperItem: Item not found");
977 0 : if (!pOld)
978 0 : return false;
979 0 : const SfxItemSet& rOldSet = GetItemSet();
980 :
981 0 : SvxBrushItem rOldItem( static_cast<const CntWallpaperItem&>(*pOld), nWhich );
982 0 : SvxGraphicPosition eOldPos = rOldItem.GetGraphicPos();
983 0 : const bool bIsBrush = ( drawing::FillStyle_SOLID == lcl_getFillStyle(m_pLbSelect) );
984 0 : bool bModified = false;
985 :
986 0 : if ( ( (GPOS_NONE == eOldPos) && bIsBrush )
987 0 : || ( (GPOS_NONE != eOldPos) && !bIsBrush ) ) // Brush <-> Bitmap changed?
988 : {
989 : // background art hasn't been changed
990 :
991 0 : if ( (GPOS_NONE == eOldPos) || !m_pLbSelect->IsVisible() )
992 : {
993 : // Brush-treatment:
994 0 : if ( rOldItem.GetColor() != aBgdColor )
995 : {
996 0 : bModified = true;
997 0 : CntWallpaperItem aItem( nWhich );
998 0 : aItem.SetColor( aBgdColor );
999 0 : rCoreSet.Put( aItem );
1000 : }
1001 0 : else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1002 0 : rCoreSet.ClearItem( nWhich );
1003 : }
1004 : else
1005 : {
1006 : // Bitmap-treatment:
1007 0 : SvxGraphicPosition eNewPos = GetGraphicPosition_Impl();
1008 :
1009 0 : bool bBitmapChanged = ( ( eNewPos != eOldPos ) ||
1010 0 : ( rOldItem.GetGraphicLink() != aBgdGraphicPath ) );
1011 0 : bool bBrushChanged = ( rOldItem.GetColor() != aBgdColor );
1012 0 : if( bBitmapChanged || bBrushChanged )
1013 : {
1014 0 : bModified = true;
1015 :
1016 0 : CntWallpaperItem aItem( nWhich );
1017 0 : WallpaperStyle eWallStyle = SvxBrushItem::GraphicPos2WallpaperStyle(eNewPos);
1018 0 : aItem.SetStyle( sal::static_int_cast< sal_uInt16 >( eWallStyle ) );
1019 0 : aItem.SetColor( aBgdColor );
1020 0 : aItem.SetBitmapURL( aBgdGraphicPath );
1021 0 : rCoreSet.Put( aItem );
1022 : }
1023 0 : else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1024 0 : rCoreSet.ClearItem( nWhich );
1025 0 : }
1026 : }
1027 : else // Brush <-> Bitmap changed!
1028 : {
1029 0 : CntWallpaperItem aItem( nWhich );
1030 0 : if ( bIsBrush )
1031 : {
1032 0 : aItem.SetColor( aBgdColor );
1033 0 : rCoreSet.Put( aItem );
1034 : }
1035 : else
1036 : {
1037 : WallpaperStyle eWallStyle =
1038 0 : SvxBrushItem::GraphicPos2WallpaperStyle( GetGraphicPosition_Impl() );
1039 0 : aItem.SetStyle( sal::static_int_cast< sal_uInt16 >( eWallStyle ) );
1040 0 : aItem.SetColor( aBgdColor );
1041 0 : aItem.SetBitmapURL( aBgdGraphicPath );
1042 0 : rCoreSet.Put( aItem );
1043 : }
1044 :
1045 0 : bModified = true;
1046 : }
1047 0 : return bModified;
1048 : }
1049 :
1050 :
1051 :
1052 0 : int SvxBackgroundTabPage::DeactivatePage( SfxItemSet* _pSet )
1053 :
1054 : /* [Description]
1055 :
1056 : virtual method; is called on deactivation
1057 : */
1058 :
1059 : {
1060 0 : if ( pPageImpl->bIsImportDlgInExecute )
1061 0 : return KEEP_PAGE;
1062 :
1063 0 : if ( _pSet )
1064 0 : FillItemSet( _pSet );
1065 :
1066 0 : return LEAVE_PAGE;
1067 : }
1068 :
1069 :
1070 :
1071 0 : void SvxBackgroundTabPage::PointChanged( vcl::Window* , RECT_POINT )
1072 : {
1073 : // has to be implemented so that position control can work
1074 0 : }
1075 :
1076 :
1077 :
1078 0 : void SvxBackgroundTabPage::ShowSelector()
1079 : {
1080 0 : if( bAllowShowSelector)
1081 : {
1082 0 : m_pAsGrid->Show();
1083 0 : m_pSelectTxt->Show();
1084 0 : m_pLbSelect->Show();
1085 0 : m_pLbSelect->SetSelectHdl( HDL(SelectHdl_Impl) );
1086 0 : m_pBtnLink->SetClickHdl( HDL(FileClickHdl_Impl) );
1087 0 : m_pBtnPreview->SetClickHdl( HDL(FileClickHdl_Impl) );
1088 0 : m_pBtnBrowse->SetClickHdl( HDL(BrowseHdl_Impl) );
1089 0 : m_pBtnArea->SetClickHdl( HDL(RadioClickHdl_Impl) );
1090 0 : m_pBtnTile->SetClickHdl( HDL(RadioClickHdl_Impl) );
1091 0 : m_pBtnPosition->SetClickHdl( HDL(RadioClickHdl_Impl) );
1092 :
1093 : // delayed loading via timer (because of UI-Update)
1094 0 : pPageImpl->pLoadTimer = new Timer;
1095 0 : pPageImpl->pLoadTimer->SetTimeout( 500 );
1096 : pPageImpl->pLoadTimer->SetTimeoutHdl(
1097 0 : LINK( this, SvxBackgroundTabPage, LoadTimerHdl_Impl ) );
1098 :
1099 0 : bAllowShowSelector = false;
1100 :
1101 0 : if(nHtmlMode & HTMLMODE_ON)
1102 : {
1103 0 : m_pBtnArea->Enable(false);
1104 : }
1105 : }
1106 0 : }
1107 :
1108 :
1109 :
1110 :
1111 0 : void SvxBackgroundTabPage::RaiseLoadError_Impl()
1112 : {
1113 : SfxErrorContext aContext( ERRCTX_SVX_BACKGROUND,
1114 : OUString(),
1115 : this,
1116 : RID_SVXERRCTX,
1117 0 : &CUI_MGR() );
1118 :
1119 : ErrorHandler::HandleError(
1120 : *new StringErrorInfo( ERRCODE_SVX_GRAPHIC_NOTREADABLE,
1121 0 : aBgdGraphicPath ) );
1122 0 : }
1123 :
1124 :
1125 :
1126 0 : bool SvxBackgroundTabPage::LoadLinkedGraphic_Impl()
1127 : {
1128 0 : bool bResult = ( !aBgdGraphicPath.isEmpty() ) &&
1129 : ( GRFILTER_OK == GraphicFilter::LoadGraphic( aBgdGraphicPath,
1130 : aBgdGraphicFilter,
1131 0 : aBgdGraphic ) );
1132 0 : return bResult;
1133 : }
1134 :
1135 :
1136 :
1137 :
1138 0 : void SvxBackgroundTabPage::FillColorValueSets_Impl()
1139 : {
1140 0 : SfxObjectShell* pDocSh = SfxObjectShell::Current();
1141 0 : const SfxPoolItem* pItem = NULL;
1142 0 : XColorListRef pColorTable = NULL;
1143 0 : if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) )
1144 : {
1145 0 : pColorTable = static_cast<const SvxColorListItem*>(pItem)->GetColorList();
1146 : }
1147 :
1148 0 : if ( !pColorTable.is() )
1149 0 : pColorTable = XColorList::CreateStdColorList();
1150 :
1151 0 : if ( pColorTable.is() )
1152 : {
1153 0 : m_pBackgroundColorSet->Clear();
1154 0 : m_pBackgroundColorSet->addEntriesForXColorList(*pColorTable);
1155 : }
1156 :
1157 0 : const WinBits nBits(m_pBackgroundColorSet->GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD);
1158 0 : m_pBackgroundColorSet->SetStyle(nBits);
1159 0 : m_pBackgroundColorSet->SetColCount(m_pBackgroundColorSet->getColumnCount());
1160 0 : }
1161 :
1162 :
1163 :
1164 :
1165 :
1166 :
1167 :
1168 0 : void SvxBackgroundTabPage::ShowColorUI_Impl()
1169 :
1170 : /* [Description]
1171 :
1172 : Hide the controls for editing the bitmap
1173 : and show the controls for color settings instead.
1174 : */
1175 :
1176 : {
1177 0 : if (!m_pBackGroundColorFrame->IsVisible())
1178 : {
1179 0 : HideBitmapUI_Impl();
1180 0 : m_pBackGroundColorFrame->Show();
1181 :
1182 0 : if(bColTransparency)
1183 : {
1184 0 : m_pColTransFT->Show();
1185 0 : m_pColTransMF->Show();
1186 : }
1187 : }
1188 0 : }
1189 :
1190 0 : void SvxBackgroundTabPage::HideColorUI_Impl()
1191 : {
1192 0 : m_pBackGroundColorFrame->Hide();
1193 0 : }
1194 :
1195 :
1196 :
1197 0 : void SvxBackgroundTabPage::ShowBitmapUI_Impl()
1198 :
1199 : /* [Description]
1200 :
1201 : Hide the controls for color settings
1202 : and show controls for editing the bitmap instead.
1203 : */
1204 :
1205 : {
1206 0 : if (m_pLbSelect->IsVisible() &&
1207 0 : (m_pBackGroundColorFrame->IsVisible() || !m_pFileFrame->IsVisible()))
1208 : {
1209 0 : HideColorUI_Impl();
1210 :
1211 :
1212 0 : m_pBitmapContainer->Show();
1213 :
1214 0 : m_pFileFrame->Show();
1215 0 : m_pBtnLink->Show(!bLinkOnly && !(nHtmlMode & HTMLMODE_ON));
1216 :
1217 0 : m_pTypeFrame->Show();
1218 :
1219 0 : m_pPreviewWin2->Show();
1220 0 : m_pBtnPreview->Show();
1221 :
1222 0 : m_pGraphTransFrame->Show(bGraphTransparency);
1223 0 : m_pColTransFT->Show(false);
1224 0 : m_pColTransMF->Show(false);
1225 : }
1226 0 : }
1227 :
1228 0 : void SvxBackgroundTabPage::HideBitmapUI_Impl()
1229 : {
1230 0 : m_pBitmapContainer->Hide();
1231 0 : m_pFileFrame->Hide();
1232 0 : m_pTypeFrame->Hide();
1233 0 : m_pPreviewWin2->Hide();
1234 0 : m_pBtnPreview->Hide();
1235 0 : m_pGraphTransFrame->Hide();
1236 0 : }
1237 :
1238 0 : void SvxBackgroundTabPage::SetGraphicPosition_Impl( SvxGraphicPosition ePos )
1239 : {
1240 0 : switch ( ePos )
1241 : {
1242 : case GPOS_AREA:
1243 : {
1244 0 : m_pBtnArea->Check();
1245 0 : m_pWndPosition->Disable();
1246 : }
1247 0 : break;
1248 :
1249 : case GPOS_TILED:
1250 : {
1251 0 : m_pBtnTile->Check();
1252 0 : m_pWndPosition->Disable();
1253 : }
1254 0 : break;
1255 :
1256 : default:
1257 : {
1258 0 : m_pBtnPosition->Check();
1259 0 : m_pWndPosition->Enable();
1260 0 : RECT_POINT eNewPos = RP_MM;
1261 :
1262 0 : switch ( ePos )
1263 : {
1264 0 : case GPOS_MM: break;
1265 0 : case GPOS_LT: eNewPos = RP_LT; break;
1266 0 : case GPOS_MT: eNewPos = RP_MT; break;
1267 0 : case GPOS_RT: eNewPos = RP_RT; break;
1268 0 : case GPOS_LM: eNewPos = RP_LM; break;
1269 0 : case GPOS_RM: eNewPos = RP_RM; break;
1270 0 : case GPOS_LB: eNewPos = RP_LB; break;
1271 0 : case GPOS_MB: eNewPos = RP_MB; break;
1272 0 : case GPOS_RB: eNewPos = RP_RB; break;
1273 : default: ;//prevent warning
1274 : }
1275 0 : m_pWndPosition->SetActualRP( eNewPos );
1276 : }
1277 0 : break;
1278 : }
1279 0 : m_pWndPosition->Invalidate();
1280 0 : }
1281 :
1282 :
1283 :
1284 0 : SvxGraphicPosition SvxBackgroundTabPage::GetGraphicPosition_Impl()
1285 : {
1286 0 : if ( m_pBtnTile->IsChecked() )
1287 0 : return GPOS_TILED;
1288 0 : else if ( m_pBtnArea->IsChecked() )
1289 0 : return GPOS_AREA;
1290 : else
1291 : {
1292 0 : switch ( m_pWndPosition->GetActualRP() )
1293 : {
1294 0 : case RP_LT: return GPOS_LT;
1295 0 : case RP_MT: return GPOS_MT;
1296 0 : case RP_RT: return GPOS_RT;
1297 0 : case RP_LM: return GPOS_LM;
1298 0 : case RP_MM: return GPOS_MM;
1299 0 : case RP_RM: return GPOS_RM;
1300 0 : case RP_LB: return GPOS_LB;
1301 0 : case RP_MB: return GPOS_MB;
1302 0 : case RP_RB: return GPOS_RB;
1303 : }
1304 : }
1305 0 : return GPOS_MM;
1306 : }
1307 :
1308 :
1309 : // Handler
1310 :
1311 :
1312 0 : IMPL_LINK_NOARG(SvxBackgroundTabPage, BackgroundColorHdl_Impl)
1313 : /*
1314 : Handler, called when color selection is changed
1315 : */
1316 : {
1317 0 : sal_uInt16 nItemId = m_pBackgroundColorSet->GetSelectItemId();
1318 0 : Color aColor = nItemId ? ( m_pBackgroundColorSet->GetItemColor( nItemId ) ) : Color( COL_TRANSPARENT );
1319 0 : aBgdColor = aColor;
1320 0 : m_pPreviewWin1->NotifyChange( aBgdColor );
1321 0 : bool bEnableTransp = aBgdColor.GetTransparency() < 0xff;
1322 0 : m_pColTransFT->Enable(bEnableTransp);
1323 0 : m_pColTransMF->Enable(bEnableTransp);
1324 0 : return 0;
1325 : }
1326 :
1327 :
1328 :
1329 0 : IMPL_LINK_NOARG(SvxBackgroundTabPage, SelectHdl_Impl)
1330 : {
1331 0 : if ( drawing::FillStyle_SOLID == lcl_getFillStyle(m_pLbSelect) )
1332 : {
1333 0 : ShowColorUI_Impl();
1334 0 : m_pParaLBox->Enable(); // drawing background can't be a bitmap
1335 : }
1336 : else
1337 : {
1338 0 : ShowBitmapUI_Impl();
1339 0 : m_pParaLBox->Enable(false); // drawing background can't be a bitmap
1340 : }
1341 0 : return 0;
1342 : }
1343 :
1344 :
1345 :
1346 0 : IMPL_LINK( SvxBackgroundTabPage, FileClickHdl_Impl, CheckBox*, pBox )
1347 : {
1348 0 : if (m_pBtnLink == pBox)
1349 : {
1350 0 : if ( m_pBtnLink->IsChecked() )
1351 : {
1352 0 : m_pFtUnlinked->Hide();
1353 0 : INetURLObject aObj( aBgdGraphicPath );
1354 0 : OUString aFilePath;
1355 0 : if ( aObj.GetProtocol() == INET_PROT_FILE )
1356 0 : aFilePath = aObj.getFSysPath( INetURLObject::FSYS_DETECT );
1357 : else
1358 0 : aFilePath = aBgdGraphicPath;
1359 0 : m_pFtFile->SetText( aFilePath );
1360 0 : m_pFtFile->Show();
1361 : }
1362 : else
1363 : {
1364 0 : m_pFtUnlinked->Show();
1365 0 : m_pFtFile->Hide();
1366 : }
1367 : }
1368 0 : else if (m_pBtnPreview == pBox)
1369 : {
1370 0 : if ( m_pBtnPreview->IsChecked() )
1371 : {
1372 0 : if ( !bIsGraphicValid )
1373 0 : bIsGraphicValid = LoadLinkedGraphic_Impl();
1374 :
1375 0 : if ( bIsGraphicValid )
1376 : {
1377 0 : Bitmap aBmp = aBgdGraphic.GetBitmap();
1378 0 : m_pPreviewWin2->NotifyChange( &aBmp );
1379 : }
1380 : else
1381 : {
1382 0 : if ( !aBgdGraphicPath.isEmpty() ) // only for linked bitmap
1383 0 : RaiseLoadError_Impl();
1384 0 : m_pPreviewWin2->NotifyChange( NULL );
1385 : }
1386 : }
1387 : else
1388 0 : m_pPreviewWin2->NotifyChange( NULL );
1389 : }
1390 0 : return 0;
1391 : }
1392 :
1393 :
1394 :
1395 0 : IMPL_LINK( SvxBackgroundTabPage, RadioClickHdl_Impl, RadioButton*, pBtn )
1396 : {
1397 0 : if (pBtn == m_pBtnPosition)
1398 : {
1399 0 : if ( !m_pWndPosition->IsEnabled() )
1400 : {
1401 0 : m_pWndPosition->Enable();
1402 0 : m_pWndPosition->Invalidate();
1403 : }
1404 : }
1405 0 : else if ( m_pWndPosition->IsEnabled() )
1406 : {
1407 0 : m_pWndPosition->Disable();
1408 0 : m_pWndPosition->Invalidate();
1409 : }
1410 0 : return 0;
1411 : }
1412 :
1413 0 : IMPL_LINK_NOARG(SvxBackgroundTabPage, BrowseHdl_Impl)
1414 :
1415 : /* [Description]
1416 :
1417 : Handler, called by pressing the browse button.
1418 : Create graphic/insert dialog, set path and start.
1419 : */
1420 :
1421 : {
1422 0 : if ( pPageImpl->pLoadTimer->IsActive() )
1423 0 : return 0;
1424 0 : bool bHtml = 0 != ( nHtmlMode & HTMLMODE_ON );
1425 :
1426 0 : OUString aStrBrowse(get<vcl::Window>("findgraphicsft")->GetText());
1427 0 : pImportDlg = new SvxOpenGraphicDialog( aStrBrowse );
1428 0 : if ( bHtml || bLinkOnly )
1429 0 : pImportDlg->EnableLink(false);
1430 0 : pImportDlg->SetPath( aBgdGraphicPath, m_pBtnLink->IsChecked() );
1431 :
1432 0 : pPageImpl->bIsImportDlgInExecute = true;
1433 0 : short nErr = pImportDlg->Execute();
1434 0 : pPageImpl->bIsImportDlgInExecute = false;
1435 :
1436 0 : if( !nErr )
1437 : {
1438 0 : if ( bHtml )
1439 0 : m_pBtnLink->Check();
1440 : // if link isn't checked and preview isn't, either,
1441 : // activate preview, so that the user sees which
1442 : // graphic he has chosen
1443 0 : if ( !m_pBtnLink->IsChecked() && !m_pBtnPreview->IsChecked() )
1444 0 : m_pBtnPreview->Check( true );
1445 : // timer-delayed loading of the graphic
1446 0 : pPageImpl->pLoadTimer->Start();
1447 : }
1448 : else
1449 0 : DELETEZ( pImportDlg );
1450 0 : return 0;
1451 : }
1452 :
1453 :
1454 :
1455 0 : IMPL_LINK( SvxBackgroundTabPage, LoadTimerHdl_Impl, Timer* , pTimer )
1456 :
1457 : /* [Description]
1458 :
1459 : Delayed loading of the graphic.
1460 : Graphic is only loaded, if it's
1461 : different to the current graphic.
1462 : */
1463 :
1464 : {
1465 0 : if ( pTimer == pPageImpl->pLoadTimer )
1466 : {
1467 0 : pPageImpl->pLoadTimer->Stop();
1468 :
1469 0 : if ( pImportDlg )
1470 : {
1471 0 : INetURLObject aOld( aBgdGraphicPath );
1472 0 : INetURLObject aNew( pImportDlg->GetPath() );
1473 0 : if ( aBgdGraphicPath.isEmpty() || aNew != aOld )
1474 : {
1475 : // new file chosen
1476 0 : aBgdGraphicPath = pImportDlg->GetPath();
1477 0 : aBgdGraphicFilter = pImportDlg->GetCurrentFilter();
1478 0 : bool bLink = ( nHtmlMode & HTMLMODE_ON ) || bLinkOnly ? sal_True : pImportDlg->IsAsLink();
1479 0 : m_pBtnLink->Check( bLink );
1480 0 : m_pBtnLink->Enable();
1481 :
1482 0 : if ( m_pBtnPreview->IsChecked() )
1483 : {
1484 0 : if( !pImportDlg->GetGraphic(aBgdGraphic) )
1485 : {
1486 0 : bIsGraphicValid = true;
1487 : }
1488 : else
1489 : {
1490 0 : aBgdGraphicFilter = "";
1491 0 : aBgdGraphicPath = "";
1492 0 : bIsGraphicValid = false;
1493 : }
1494 : }
1495 : else
1496 0 : bIsGraphicValid = false; // load graphic not until preview click
1497 :
1498 0 : if ( m_pBtnPreview->IsChecked() && bIsGraphicValid )
1499 : {
1500 0 : Bitmap aBmp = aBgdGraphic.GetBitmap();
1501 0 : m_pPreviewWin2->NotifyChange( &aBmp );
1502 : }
1503 : else
1504 0 : m_pPreviewWin2->NotifyChange( NULL );
1505 : }
1506 :
1507 0 : FileClickHdl_Impl(m_pBtnLink);
1508 0 : DELETEZ( pImportDlg );
1509 : }
1510 : }
1511 0 : return 0;
1512 : }
1513 :
1514 :
1515 :
1516 0 : void SvxBackgroundTabPage::ShowTblControl()
1517 : {
1518 0 : m_pTblLBox->SetSelectHdl( HDL(TblDestinationHdl_Impl) );
1519 0 : m_pTblLBox->SelectEntryPos(0);
1520 0 : m_pTblDesc->Show();
1521 0 : m_pTblLBox->Show();
1522 0 : m_pAsGrid->Show();
1523 0 : }
1524 :
1525 :
1526 :
1527 0 : void SvxBackgroundTabPage::ShowParaControl(bool bCharOnly)
1528 : {
1529 0 : m_pParaLBox->SetSelectHdl(HDL(ParaDestinationHdl_Impl));
1530 0 : m_pParaLBox->SelectEntryPos(0);
1531 0 : if (!bCharOnly)
1532 : {
1533 0 : m_pTblDesc->Show();
1534 0 : m_pParaLBox->Show();
1535 0 : m_pAsGrid->Show();
1536 : }
1537 0 : m_pParaLBox->SetData(m_pParaLBox); // here it can be recognized that this mode is turned on
1538 0 : }
1539 :
1540 :
1541 0 : IMPL_LINK( SvxBackgroundTabPage, TblDestinationHdl_Impl, ListBox*, pBox )
1542 : {
1543 0 : sal_Int32 nSelPos = pBox->GetSelectEntryPos();
1544 0 : if( pTableBck_Impl && pTableBck_Impl->nActPos != nSelPos)
1545 : {
1546 0 : boost::scoped_ptr<SvxBrushItem> xItemHolder;
1547 0 : SvxBrushItem* pActItem = NULL;
1548 0 : sal_uInt16 nWhich = 0;
1549 0 : switch(pTableBck_Impl->nActPos)
1550 : {
1551 : case TBL_DEST_CELL:
1552 0 : pActItem = pTableBck_Impl->pCellBrush;
1553 0 : nWhich = pTableBck_Impl->nCellWhich;
1554 0 : break;
1555 : case TBL_DEST_ROW:
1556 0 : pActItem = pTableBck_Impl->pRowBrush;
1557 0 : nWhich = pTableBck_Impl->nRowWhich;
1558 0 : break;
1559 : case TBL_DEST_TBL:
1560 0 : pActItem = pTableBck_Impl->pTableBrush;
1561 0 : nWhich = pTableBck_Impl->nTableWhich;
1562 0 : break;
1563 : default:
1564 0 : pActItem = NULL;
1565 0 : break;
1566 : }
1567 0 : pTableBck_Impl->nActPos = nSelPos;
1568 0 : if(!pActItem)
1569 : {
1570 0 : xItemHolder.reset(new SvxBrushItem(nWhich));
1571 0 : pActItem = xItemHolder.get();
1572 : }
1573 0 : if(drawing::FillStyle_SOLID == lcl_getFillStyle(m_pLbSelect)) // brush selected
1574 : {
1575 0 : *pActItem = SvxBrushItem( aBgdColor, nWhich );
1576 : }
1577 : else
1578 : {
1579 0 : SvxGraphicPosition eNewPos = GetGraphicPosition_Impl();
1580 0 : const bool bIsLink = m_pBtnLink->IsChecked();
1581 :
1582 0 : if ( !bIsLink && !bIsGraphicValid )
1583 0 : bIsGraphicValid = LoadLinkedGraphic_Impl();
1584 :
1585 0 : if ( bIsLink )
1586 0 : *pActItem = SvxBrushItem( aBgdGraphicPath,
1587 : aBgdGraphicFilter,
1588 : eNewPos,
1589 0 : pActItem->Which() );
1590 : else
1591 0 : *pActItem = SvxBrushItem( aBgdGraphic,
1592 : eNewPos,
1593 0 : pActItem->Which() );
1594 : }
1595 0 : switch(nSelPos)
1596 : {
1597 : case TBL_DEST_CELL:
1598 0 : pActItem = pTableBck_Impl->pCellBrush;
1599 0 : m_pLbSelect->Enable();
1600 0 : nWhich = pTableBck_Impl->nCellWhich;
1601 0 : break;
1602 : case TBL_DEST_ROW:
1603 0 : if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & HTMLMODE_SOME_STYLES))
1604 0 : m_pLbSelect->Disable();
1605 0 : pActItem = pTableBck_Impl->pRowBrush;
1606 0 : nWhich = pTableBck_Impl->nRowWhich;
1607 0 : break;
1608 : case TBL_DEST_TBL:
1609 0 : pActItem = pTableBck_Impl->pTableBrush;
1610 0 : m_pLbSelect->Enable();
1611 0 : nWhich = pTableBck_Impl->nTableWhich;
1612 0 : break;
1613 : default:
1614 : // The item will be new'ed again below, but that will be the
1615 : // default item then, not an existing modified one.
1616 0 : xItemHolder.reset();
1617 0 : pActItem = NULL;
1618 0 : break;
1619 : }
1620 0 : OUString aUserData = GetUserData();
1621 0 : if (!pActItem)
1622 : {
1623 0 : xItemHolder.reset(new SvxBrushItem(nWhich));
1624 0 : pActItem = xItemHolder.get();
1625 : }
1626 0 : FillControls_Impl(*pActItem, aUserData);
1627 : }
1628 0 : return 0;
1629 : }
1630 :
1631 :
1632 :
1633 0 : IMPL_LINK( SvxBackgroundTabPage, ParaDestinationHdl_Impl, ListBox*, pBox )
1634 : {
1635 0 : sal_Int32 nSelPos = pBox->GetSelectEntryPos();
1636 0 : if( pParaBck_Impl && pParaBck_Impl->nActPos != nSelPos)
1637 : {
1638 0 : SvxBrushItem* pActItem = NULL;
1639 0 : switch(pParaBck_Impl->nActPos)
1640 : {
1641 : case PARA_DEST_PARA:
1642 0 : pActItem = pParaBck_Impl->pParaBrush;
1643 0 : break;
1644 : case PARA_DEST_CHAR:
1645 0 : pActItem = pParaBck_Impl->pCharBrush;
1646 0 : break;
1647 : default:
1648 : /* we assert here because the rest of the code expect pActItem to be non NULL */
1649 : assert(false);
1650 0 : return 0;
1651 : }
1652 0 : pParaBck_Impl->nActPos = nSelPos;
1653 0 : if(drawing::FillStyle_SOLID == lcl_getFillStyle(m_pLbSelect)) // brush selected
1654 : {
1655 0 : sal_uInt16 nWhich = pActItem->Which();
1656 0 : *pActItem = SvxBrushItem( aBgdColor, nWhich );
1657 : }
1658 : else
1659 : {
1660 0 : SvxGraphicPosition eNewPos = GetGraphicPosition_Impl();
1661 0 : const bool bIsLink = m_pBtnLink->IsChecked();
1662 :
1663 0 : if ( !bIsLink && !bIsGraphicValid )
1664 0 : bIsGraphicValid = LoadLinkedGraphic_Impl();
1665 :
1666 0 : if ( bIsLink )
1667 0 : *pActItem = SvxBrushItem( aBgdGraphicPath,
1668 : aBgdGraphicFilter,
1669 : eNewPos,
1670 0 : pActItem->Which() );
1671 : else
1672 0 : *pActItem = SvxBrushItem( aBgdGraphic,
1673 : eNewPos,
1674 0 : pActItem->Which() );
1675 : }
1676 0 : switch(nSelPos)
1677 : {
1678 : case PARA_DEST_PARA:
1679 0 : pActItem = pParaBck_Impl->pParaBrush;
1680 0 : m_pLbSelect->Enable();
1681 0 : break;
1682 : case PARA_DEST_CHAR:
1683 : {
1684 0 : pActItem = pParaBck_Impl->pCharBrush;
1685 0 : m_pLbSelect->Enable(false);
1686 : }
1687 0 : break;
1688 : }
1689 0 : OUString aUserData = GetUserData();
1690 0 : FillControls_Impl(*pActItem, aUserData);
1691 : }
1692 0 : return 0;
1693 : }
1694 :
1695 :
1696 :
1697 0 : void SvxBackgroundTabPage::FillControls_Impl( const SvxBrushItem& rBgdAttr,
1698 : const OUString& rUserData )
1699 : {
1700 0 : SvxGraphicPosition ePos = rBgdAttr.GetGraphicPos();
1701 0 : const Color& rColor = rBgdAttr.GetColor();
1702 0 : if(bColTransparency)
1703 : {
1704 0 : m_pColTransMF->SetValue(lcl_TransparencyToPercent(rColor.GetTransparency()));
1705 0 : m_pColTransMF->SaveValue();
1706 0 : bool bEnableTransp = rColor.GetTransparency() < 0xff;
1707 0 : m_pColTransFT->Enable(bEnableTransp);
1708 0 : m_pColTransMF->Enable(bEnableTransp);
1709 : //the default setting should be "no transparency"
1710 0 : if(!bEnableTransp)
1711 0 : m_pColTransMF->SetValue(0);
1712 : }
1713 :
1714 0 : if ( GPOS_NONE == ePos || !m_pLbSelect->IsVisible() )
1715 : {
1716 0 : lcl_setFillStyle(m_pLbSelect, drawing::FillStyle_SOLID);
1717 0 : ShowColorUI_Impl();
1718 0 : Color aTrColor( COL_TRANSPARENT );
1719 0 : aBgdColor = rColor;
1720 :
1721 0 : sal_uInt16 nCol = ( aTrColor != aBgdColor ) ?
1722 0 : GetItemId_Impl(*m_pBackgroundColorSet, aBgdColor) : 0;
1723 :
1724 0 : if( aTrColor != aBgdColor && nCol == 0)
1725 : {
1726 0 : m_pBackgroundColorSet->SetNoSelection();
1727 : }
1728 : else
1729 : {
1730 0 : m_pBackgroundColorSet->SelectItem( nCol );
1731 : }
1732 :
1733 0 : m_pPreviewWin1->NotifyChange( aBgdColor );
1734 :
1735 0 : if ( m_pLbSelect->IsVisible() ) // initialize graphic part
1736 : {
1737 0 : aBgdGraphicFilter = "";
1738 0 : aBgdGraphicPath = "";
1739 :
1740 0 : if ( rUserData.isEmpty() )
1741 0 : m_pBtnPreview->Check( false );
1742 0 : m_pBtnLink->Check( false );
1743 0 : m_pBtnLink->Disable();
1744 0 : m_pPreviewWin2->NotifyChange( NULL );
1745 0 : SetGraphicPosition_Impl( GPOS_TILED ); // tiles as default
1746 : }
1747 : }
1748 : else
1749 : {
1750 0 : const OUString aStrLink = rBgdAttr.GetGraphicLink();
1751 0 : const OUString aStrFilter = rBgdAttr.GetGraphicFilter();
1752 :
1753 0 : lcl_setFillStyle(m_pLbSelect, drawing::FillStyle_BITMAP);
1754 0 : ShowBitmapUI_Impl();
1755 :
1756 0 : if ( !aStrLink.isEmpty() )
1757 : {
1758 : #ifdef DBG_UTIL
1759 : INetURLObject aObj( aStrLink );
1760 : DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
1761 : #endif
1762 0 : aBgdGraphicPath = aStrLink;
1763 0 : m_pBtnLink->Check( true );
1764 0 : m_pBtnLink->Enable();
1765 : }
1766 : else
1767 : {
1768 0 : aBgdGraphicPath = "";
1769 0 : m_pBtnLink->Check( false );
1770 0 : m_pBtnLink->Disable();
1771 : }
1772 :
1773 0 : if(bGraphTransparency)
1774 : {
1775 0 : const GraphicObject* pObject = rBgdAttr.GetGraphicObject();
1776 0 : if(pObject)
1777 0 : m_pGraphTransMF->SetValue(lcl_TransparencyToPercent(pObject->GetAttr().GetTransparency()));
1778 : else
1779 0 : m_pGraphTransMF->SetValue(0);
1780 0 : m_pGraphTransMF->SaveValue();
1781 : }
1782 :
1783 0 : FileClickHdl_Impl(m_pBtnLink);
1784 :
1785 0 : aBgdGraphicFilter = aStrFilter;
1786 :
1787 0 : if ( aStrLink.isEmpty() || m_pBtnPreview->IsChecked() )
1788 : {
1789 : // Graphic exists in the item and doesn't have
1790 : // to be loaded:
1791 :
1792 0 : const Graphic* pGraphic = rBgdAttr.GetGraphic();
1793 :
1794 0 : if ( !pGraphic && m_pBtnPreview->IsChecked() )
1795 0 : bIsGraphicValid = LoadLinkedGraphic_Impl();
1796 0 : else if ( pGraphic )
1797 : {
1798 0 : aBgdGraphic = *pGraphic;
1799 0 : bIsGraphicValid = true;
1800 :
1801 0 : if ( rUserData.isEmpty() )
1802 0 : m_pBtnPreview->Check();
1803 : }
1804 : else
1805 : {
1806 0 : RaiseLoadError_Impl();
1807 0 : bIsGraphicValid = false;
1808 :
1809 0 : if ( rUserData.isEmpty() )
1810 0 : m_pBtnPreview->Check( false );
1811 : }
1812 : }
1813 :
1814 0 : if ( m_pBtnPreview->IsChecked() && bIsGraphicValid )
1815 : {
1816 0 : Bitmap aBmp = aBgdGraphic.GetBitmap();
1817 0 : m_pPreviewWin2->NotifyChange( &aBmp );
1818 : }
1819 : else
1820 0 : m_pPreviewWin2->NotifyChange( NULL );
1821 :
1822 0 : SetGraphicPosition_Impl( ePos );
1823 : }
1824 0 : }
1825 :
1826 0 : void SvxBackgroundTabPage::EnableTransparency(bool bColor, bool bGraphic)
1827 : {
1828 0 : bColTransparency = bColor;
1829 0 : bGraphTransparency = bGraphic;
1830 0 : m_pColTransFT->Show(bColor);
1831 0 : m_pColTransMF->Show(bColor);
1832 0 : }
1833 :
1834 0 : void SvxBackgroundTabPage::PageCreated(const SfxAllItemSet& aSet)
1835 : {
1836 0 : SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,false);
1837 :
1838 0 : if (pFlagItem)
1839 : {
1840 0 : sal_uInt32 nFlags=pFlagItem->GetValue();
1841 0 : if ( ( nFlags & SVX_SHOW_TBLCTL ) == SVX_SHOW_TBLCTL )
1842 0 : ShowTblControl();
1843 0 : if ( ( nFlags & SVX_SHOW_PARACTL ) == SVX_SHOW_PARACTL )
1844 0 : ShowParaControl();
1845 0 : if ( ( nFlags & SVX_SHOW_SELECTOR ) == SVX_SHOW_SELECTOR )
1846 0 : ShowSelector();
1847 0 : if ( ( nFlags & SVX_ENABLE_TRANSPARENCY ) == SVX_ENABLE_TRANSPARENCY )
1848 0 : EnableTransparency(true, true);
1849 : }
1850 0 : }
1851 :
1852 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|