LCOV - code coverage report
Current view: top level - cui/source/tabpages - backgrnd.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 881 0.0 %
Date: 2014-04-14 Functions: 0 65 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10