LCOV - code coverage report
Current view: top level - cui/source/tabpages - tphatch.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 421 0.0 %
Date: 2012-08-25 Functions: 0 24 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1082 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <tools/shl.hxx>
      30                 :            : #include <tools/urlobj.hxx>
      31                 :            : #include <vcl/msgbox.hxx>
      32                 :            : #include <unotools/pathoptions.hxx>
      33                 :            : #include <sfx2/app.hxx>
      34                 :            : #include <sfx2/module.hxx>
      35                 :            : #include <sfx2/filedlghelper.hxx>
      36                 :            : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
      37                 :            : 
      38                 :            : #define _SVX_TPHATCH_CXX
      39                 :            : 
      40                 :            : #include <cuires.hrc>
      41                 :            : #include "tabarea.hrc"
      42                 :            : #include "helpid.hrc"
      43                 :            : #include "svx/xattr.hxx"
      44                 :            : #include <svx/xpool.hxx>
      45                 :            : #include <svx/xtable.hxx>
      46                 :            : #include "svx/drawitem.hxx"
      47                 :            : #include "cuitabarea.hxx"
      48                 :            : #include "defdlgname.hxx"
      49                 :            : #include <svx/svxdlg.hxx>
      50                 :            : #include <dialmgr.hxx>
      51                 :            : #include "svx/dlgutil.hxx"
      52                 :            : #include <svx/dialmgr.hxx>
      53                 :            : #include "paragrph.hrc"
      54                 :            : #include <svx/dialogs.hrc>
      55                 :            : 
      56                 :          0 : SvxHatchTabPage::SvxHatchTabPage
      57                 :            : (
      58                 :            :     Window* pParent,
      59                 :            :     const SfxItemSet& rInAttrs
      60                 :            : ) :
      61                 :            : 
      62                 :          0 :     SvxTabPage          ( pParent, CUI_RES( RID_SVXPAGE_HATCH ), rInAttrs ),
      63                 :            : 
      64         [ #  # ]:          0 :     aFtDistance         ( this, CUI_RES( FT_LINE_DISTANCE ) ),
      65         [ #  # ]:          0 :     aMtrDistance        ( this, CUI_RES( MTR_FLD_DISTANCE ) ),
      66         [ #  # ]:          0 :     aFtAngle            ( this, CUI_RES( FT_LINE_ANGLE ) ),
      67         [ #  # ]:          0 :     aMtrAngle           ( this, CUI_RES( MTR_FLD_ANGLE ) ),
      68         [ #  # ]:          0 :     aCtlAngle           ( this, CUI_RES( CTL_ANGLE ),
      69                 :            :                                     RP_RB, 200, 80, CS_ANGLE ),
      70         [ #  # ]:          0 :     aFlProp             ( this, CUI_RES( FL_PROP ) ),
      71         [ #  # ]:          0 :     aFtLineType         ( this, CUI_RES( FT_LINE_TYPE ) ),
      72         [ #  # ]:          0 :     aLbLineType         ( this, CUI_RES( LB_LINE_TYPE ) ),
      73         [ #  # ]:          0 :     aFtLineColor        ( this, CUI_RES( FT_LINE_COLOR ) ),
      74         [ #  # ]:          0 :     aLbLineColor        ( this, CUI_RES( LB_LINE_COLOR ) ),
      75         [ #  # ]:          0 :     aLbHatchings        ( this, CUI_RES( LB_HATCHINGS ) ),
      76         [ #  # ]:          0 :     aCtlPreview         ( this, CUI_RES( CTL_PREVIEW ) ),
      77         [ #  # ]:          0 :     aBtnAdd             ( this, CUI_RES( BTN_ADD ) ),
      78         [ #  # ]:          0 :     aBtnModify          ( this, CUI_RES( BTN_MODIFY ) ),
      79         [ #  # ]:          0 :     aBtnDelete          ( this, CUI_RES( BTN_DELETE ) ),
      80         [ #  # ]:          0 :     aBtnLoad            ( this, CUI_RES( BTN_LOAD ) ),
      81         [ #  # ]:          0 :     aBtnSave            ( this, CUI_RES( BTN_SAVE ) ),
      82                 :            : 
      83                 :            :     rOutAttrs           ( rInAttrs ),
      84                 :            : 
      85                 :          0 :     pXPool              ( (XOutdevItemPool*) rInAttrs.GetPool() ),
      86                 :            :     aXFStyleItem        ( XFILL_HATCH ),
      87                 :            :     aXHatchItem         ( String(), XHatch() ),
      88                 :            :     aXFillAttr          ( pXPool ),
      89 [ #  # ][ #  # ]:          0 :     rXFSet              ( aXFillAttr.GetItemSet() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      90                 :            : 
      91                 :            : {
      92         [ #  # ]:          0 :     FreeResource();
      93                 :            : 
      94                 :            :     // this page needs ExchangeSupport
      95                 :          0 :     SetExchangeSupport();
      96                 :            : 
      97                 :            :     // adjust metric
      98         [ #  # ]:          0 :     FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
      99                 :            : 
     100         [ #  # ]:          0 :     switch ( eFUnit )
     101                 :            :     {
     102                 :            :         case FUNIT_M:
     103                 :            :         case FUNIT_KM:
     104                 :          0 :             eFUnit = FUNIT_MM;
     105                 :          0 :             break;
     106                 :            :         default: ;//prevent warning
     107                 :            :     }
     108         [ #  # ]:          0 :     SetFieldUnit( aMtrDistance, eFUnit );
     109                 :            : 
     110                 :            :     // determine PoolUnit
     111                 :          0 :     SfxItemPool* pPool = rOutAttrs.GetPool();
     112                 :            :     DBG_ASSERT( pPool, "Wo ist der Pool?" );
     113         [ #  # ]:          0 :     ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH );
     114                 :            : 
     115                 :            :     // setting the output device
     116         [ #  # ]:          0 :     rXFSet.Put( aXFStyleItem );
     117         [ #  # ]:          0 :     rXFSet.Put( aXHatchItem );
     118         [ #  # ]:          0 :     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
     119                 :            : 
     120         [ #  # ]:          0 :     aLbHatchings.SetSelectHdl( LINK( this, SvxHatchTabPage, ChangeHatchHdl_Impl ) );
     121                 :            : 
     122         [ #  # ]:          0 :     Link aLink = LINK( this, SvxHatchTabPage, ModifiedHdl_Impl );
     123                 :          0 :     aMtrDistance.SetModifyHdl( aLink );
     124                 :          0 :     aMtrAngle.SetModifyHdl( aLink );
     125                 :          0 :     aLbLineType.SetSelectHdl( aLink );
     126                 :          0 :     aLbLineColor.SetSelectHdl( aLink );
     127                 :            : 
     128         [ #  # ]:          0 :     aBtnAdd.SetClickHdl( LINK( this, SvxHatchTabPage, ClickAddHdl_Impl ) );
     129                 :            :     aBtnModify.SetClickHdl(
     130         [ #  # ]:          0 :         LINK( this, SvxHatchTabPage, ClickModifyHdl_Impl ) );
     131                 :            :     aBtnDelete.SetClickHdl(
     132         [ #  # ]:          0 :         LINK( this, SvxHatchTabPage, ClickDeleteHdl_Impl ) );
     133         [ #  # ]:          0 :     aBtnLoad.SetClickHdl( LINK( this, SvxHatchTabPage, ClickLoadHdl_Impl ) );
     134         [ #  # ]:          0 :     aBtnSave.SetClickHdl( LINK( this, SvxHatchTabPage, ClickSaveHdl_Impl ) );
     135                 :            : 
     136 [ #  # ][ #  # ]:          0 :     aCtlPreview.SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
     137                 :            : 
     138 [ #  # ][ #  # ]:          0 :     aCtlPreview.SetAccessibleName(String(CUI_RES(STR_EXAMPLE)));
         [ #  # ][ #  # ]
     139 [ #  # ][ #  # ]:          0 :     aLbHatchings.SetAccessibleName( String(CUI_RES(STR_LB_HATCHINGSTYLE)) );
         [ #  # ][ #  # ]
     140         [ #  # ]:          0 :     aCtlAngle.SetAccessibleRelationMemberOf( &aFlProp );
     141         [ #  # ]:          0 :     aLbHatchings.SetAccessibleRelationMemberOf( &aFlProp );
     142         [ #  # ]:          0 :     aBtnAdd.SetAccessibleRelationMemberOf( &aFlProp );
     143         [ #  # ]:          0 :     aBtnModify.SetAccessibleRelationMemberOf( &aFlProp );
     144         [ #  # ]:          0 :     aBtnDelete.SetAccessibleRelationMemberOf( &aFlProp );
     145         [ #  # ]:          0 :     aLbHatchings.SetAccessibleRelationLabeledBy(&aLbHatchings);
     146                 :          0 : }
     147                 :            : 
     148                 :            : // -----------------------------------------------------------------------
     149                 :            : 
     150                 :          0 : void SvxHatchTabPage::Construct()
     151                 :            : {
     152                 :          0 :     aLbLineColor.Fill( pColorList );
     153                 :          0 :     aLbHatchings.Fill( pHatchingList );
     154                 :          0 : }
     155                 :            : 
     156                 :            : // -----------------------------------------------------------------------
     157                 :            : 
     158                 :          0 : void SvxHatchTabPage::ActivatePage( const SfxItemSet& rSet )
     159                 :            : {
     160                 :            :     sal_uInt16 nPos;
     161                 :            :     sal_uInt16 nCount;
     162                 :            : 
     163         [ #  # ]:          0 :     if( *pDlgType == 0 ) // area dialog
     164                 :            :     {
     165                 :          0 :         *pbAreaTP = sal_False;
     166                 :            : 
     167         [ #  # ]:          0 :         if( pColorList.is() )
     168                 :            :         {
     169                 :            :             // ColorList
     170 [ #  # ][ #  # ]:          0 :             if( *pnColorListState & CT_CHANGED ||
     171                 :            :                 *pnColorListState & CT_MODIFIED )
     172                 :            :             {
     173         [ #  # ]:          0 :                 if( *pnColorListState & CT_CHANGED )
     174 [ #  # ][ #  # ]:          0 :                     pColorList = ( (SvxAreaTabDialog*) GetParentDialog() )->GetNewColorList();
                 [ #  # ]
     175                 :            : 
     176                 :            :                 // LbLineColor
     177         [ #  # ]:          0 :                 nPos = aLbLineColor.GetSelectEntryPos();
     178         [ #  # ]:          0 :                 aLbLineColor.Clear();
     179         [ #  # ]:          0 :                 aLbLineColor.Fill( pColorList );
     180         [ #  # ]:          0 :                 nCount = aLbLineColor.GetEntryCount();
     181         [ #  # ]:          0 :                 if( nCount == 0 )
     182                 :            :                     ; // this case should not occur
     183         [ #  # ]:          0 :                 else if( nCount <= nPos )
     184         [ #  # ]:          0 :                     aLbLineColor.SelectEntryPos( 0 );
     185                 :            :                 else
     186         [ #  # ]:          0 :                     aLbLineColor.SelectEntryPos( nPos );
     187                 :            : 
     188         [ #  # ]:          0 :                 ModifiedHdl_Impl( this );
     189                 :            :             }
     190                 :            : 
     191                 :            :             // determining (possibly cutting) the name
     192                 :            :             // and displaying it in the GroupBox
     193 [ #  # ][ #  # ]:          0 :             String          aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
                 [ #  # ]
     194 [ #  # ][ #  # ]:          0 :             INetURLObject   aURL( pHatchingList->GetPath() );
     195                 :            : 
     196 [ #  # ][ #  # ]:          0 :             aURL.Append( pHatchingList->GetName() );
     197                 :            :             DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     198                 :            : 
     199 [ #  # ][ #  # ]:          0 :             if ( aURL.getBase().getLength() > 18 )
     200                 :            :             {
     201 [ #  # ][ #  # ]:          0 :                 aString += String(aURL.getBase()).Copy( 0, 15 );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     202         [ #  # ]:          0 :                 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
     203                 :            :             }
     204                 :            :             else
     205 [ #  # ][ #  # ]:          0 :                 aString += String(aURL.getBase());
         [ #  # ][ #  # ]
     206                 :            : 
     207 [ #  # ][ #  # ]:          0 :             if( *pPageType == PT_HATCH && *pPos != LISTBOX_ENTRY_NOTFOUND )
     208                 :            :             {
     209         [ #  # ]:          0 :                 aLbHatchings.SelectEntryPos( *pPos );
     210                 :            :             }
     211                 :            :             // colors could have been deleted
     212         [ #  # ]:          0 :             ChangeHatchHdl_Impl( this );
     213                 :            : 
     214                 :          0 :             *pPageType = PT_HATCH;
     215 [ #  # ][ #  # ]:          0 :             *pPos = LISTBOX_ENTRY_NOTFOUND;
     216                 :            :         }
     217                 :            :     }
     218                 :            : 
     219                 :          0 :     rXFSet.Put ( ( XFillColorItem& )    rSet.Get(XATTR_FILLCOLOR) );
     220                 :          0 :     rXFSet.Put ( ( XFillBackgroundItem&)rSet.Get(XATTR_FILLBACKGROUND) );
     221                 :          0 :     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
     222                 :          0 :     aCtlPreview.Invalidate();
     223                 :          0 : }
     224                 :            : 
     225                 :            : // -----------------------------------------------------------------------
     226                 :            : 
     227                 :          0 : int SvxHatchTabPage::DeactivatePage( SfxItemSet* _pSet )
     228                 :            : {
     229         [ #  # ]:          0 :     if ( CheckChanges_Impl() == -1L )
     230                 :          0 :         return KEEP_PAGE;
     231                 :            : 
     232         [ #  # ]:          0 :     if( _pSet )
     233                 :          0 :         FillItemSet( *_pSet );
     234                 :            : 
     235                 :          0 :     return LEAVE_PAGE;
     236                 :            : }
     237                 :            : 
     238                 :            : // -----------------------------------------------------------------------
     239                 :            : 
     240                 :          0 : long SvxHatchTabPage::CheckChanges_Impl()
     241                 :            : {
     242 [ #  # ][ #  # ]:          0 :     if( aMtrDistance.GetText()           != aMtrDistance.GetSavedValue() ||
         [ #  # ][ #  #  
          #  #  #  #  #  
              # ][ #  # ]
           [ #  #  #  # ]
     243 [ #  # ][ #  # ]:          0 :         aMtrAngle.GetText()              != aMtrAngle.GetSavedValue() ||
         [ #  # ][ #  # ]
                 [ #  # ]
     244         [ #  # ]:          0 :         aLbLineType.GetSelectEntryPos()  != aLbLineType.GetSavedValue()  ||
     245         [ #  # ]:          0 :         aLbLineColor.GetSelectEntryPos() != aLbLineColor.GetSavedValue() ||
     246         [ #  # ]:          0 :         aLbHatchings.GetSelectEntryPos() != aLbHatchings.GetSavedValue() )
     247                 :            :     {
     248         [ #  # ]:          0 :         ResMgr& rMgr = CUI_MGR();
     249         [ #  # ]:          0 :         Image aWarningBoxImage = WarningBox::GetStandardImage();
     250         [ #  # ]:          0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     251                 :            :         DBG_ASSERT(pFact, "Dialogdiet fail!");
     252                 :            :         AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( GetParentDialog(), RID_SVXDLG_MESSBOX,
     253         [ #  # ]:          0 :                                                         SVX_RESSTR( RID_SVXSTR_HATCH ),
     254         [ #  # ]:          0 :                                                         CUI_RESSTR( RID_SVXSTR_ASK_CHANGE_HATCH ),
     255 [ #  # ][ #  # ]:          0 :                                                         &aWarningBoxImage );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     256                 :            :         DBG_ASSERT(aMessDlg, "Dialogdiet fail!");
     257                 :            :         aMessDlg->SetButtonText( MESS_BTN_1,
     258 [ #  # ][ #  # ]:          0 :                                 String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) );
                 [ #  # ]
     259                 :            :         aMessDlg->SetButtonText( MESS_BTN_2,
     260 [ #  # ][ #  # ]:          0 :                                 String( ResId( RID_SVXSTR_ADD, rMgr ) ) );
                 [ #  # ]
     261                 :            : 
     262         [ #  # ]:          0 :         short nRet = aMessDlg->Execute();
     263                 :            : 
     264   [ #  #  #  # ]:          0 :         switch( nRet )
     265                 :            :         {
     266                 :            :             case RET_BTN_1:
     267                 :            :             {
     268         [ #  # ]:          0 :                 ClickModifyHdl_Impl( this );
     269                 :            :             }
     270                 :          0 :             break;
     271                 :            : 
     272                 :            :             case RET_BTN_2:
     273                 :            :             {
     274         [ #  # ]:          0 :                 ClickAddHdl_Impl( this );
     275                 :            :             }
     276                 :          0 :             break;
     277                 :            : 
     278                 :            :             case RET_CANCEL:
     279                 :          0 :             break;
     280                 :            :         }
     281 [ #  # ][ #  # ]:          0 :         delete aMessDlg;
                 [ #  # ]
     282                 :            :     }
     283                 :            : 
     284                 :          0 :     sal_uInt16 nPos = aLbHatchings.GetSelectEntryPos();
     285         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     286                 :          0 :         *pPos = nPos;
     287                 :          0 :     return 0L;
     288                 :            : }
     289                 :            : 
     290                 :            : // -----------------------------------------------------------------------
     291                 :            : 
     292                 :          0 : sal_Bool SvxHatchTabPage::FillItemSet( SfxItemSet& rSet )
     293                 :            : {
     294 [ #  # ][ #  # ]:          0 :     if( *pDlgType == 0 && *pbAreaTP == sal_False ) // area dialog
     295                 :            :     {
     296         [ #  # ]:          0 :         if( *pPageType == PT_HATCH )
     297                 :            :         {
     298                 :            :             // CheckChanges(); <-- duplicate inquiry ?
     299                 :            : 
     300                 :          0 :             XHatch* pXHatch = NULL;
     301         [ #  # ]:          0 :             String  aString;
     302         [ #  # ]:          0 :             sal_uInt16  nPos = aLbHatchings.GetSelectEntryPos();
     303         [ #  # ]:          0 :             if( nPos != LISTBOX_ENTRY_NOTFOUND )
     304                 :            :             {
     305 [ #  # ][ #  # ]:          0 :                 pXHatch = new XHatch( pHatchingList->GetHatch( nPos )->GetHatch() );
     306 [ #  # ][ #  # ]:          0 :                 aString = aLbHatchings.GetSelectEntry();
                 [ #  # ]
     307                 :            :             }
     308                 :            :             // gradient has been (unidentifiedly) passed
     309                 :            :             else
     310                 :            :             {
     311                 :          0 :                 pXHatch = new XHatch( aLbLineColor.GetSelectEntryColor(),
     312         [ #  # ]:          0 :                                  (XHatchStyle) aLbLineType.GetSelectEntryPos(),
     313                 :          0 :                                  GetCoreValue( aMtrDistance, ePoolUnit ),
     314 [ #  # ][ #  # ]:          0 :                                  static_cast<long>(aMtrAngle.GetValue() * 10) );
         [ #  # ][ #  # ]
                 [ #  # ]
     315                 :            :             }
     316                 :            :             DBG_ASSERT( pXHatch, "XHatch konnte nicht erzeugt werden" );
     317 [ #  # ][ #  # ]:          0 :             rSet.Put( XFillStyleItem( XFILL_HATCH ) );
                 [ #  # ]
     318 [ #  # ][ #  # ]:          0 :             rSet.Put( XFillHatchItem( aString, *pXHatch ) );
                 [ #  # ]
     319                 :            : 
     320         [ #  # ]:          0 :             delete pXHatch;
     321                 :            :         }
     322                 :            :     }
     323                 :          0 :     return sal_True;
     324                 :            : }
     325                 :            : 
     326                 :            : // -----------------------------------------------------------------------
     327                 :            : 
     328                 :          0 : void SvxHatchTabPage::Reset( const SfxItemSet& rSet )
     329                 :            : {
     330                 :          0 :     ChangeHatchHdl_Impl( this );
     331                 :            : 
     332                 :            :     // determine button state
     333         [ #  # ]:          0 :     if( pHatchingList->Count() )
     334                 :            :     {
     335                 :          0 :         aBtnModify.Enable();
     336                 :          0 :         aBtnDelete.Enable();
     337                 :          0 :         aBtnSave.Enable();
     338                 :            :     }
     339                 :            :     else
     340                 :            :     {
     341                 :          0 :         aBtnModify.Disable();
     342                 :          0 :         aBtnDelete.Disable();
     343                 :          0 :         aBtnSave.Disable();
     344                 :            :     }
     345                 :            : 
     346                 :          0 :     rXFSet.Put ( ( XFillColorItem& )    rSet.Get(XATTR_FILLCOLOR) );
     347                 :          0 :     rXFSet.Put ( ( XFillBackgroundItem&)rSet.Get(XATTR_FILLBACKGROUND) );
     348                 :          0 :     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
     349                 :          0 :     aCtlPreview.Invalidate();
     350                 :          0 : }
     351                 :            : 
     352                 :            : // -----------------------------------------------------------------------
     353                 :            : 
     354                 :          0 : SfxTabPage* SvxHatchTabPage::Create( Window* pWindow,
     355                 :            :                 const SfxItemSet& rSet )
     356                 :            : {
     357         [ #  # ]:          0 :     return new SvxHatchTabPage( pWindow, rSet );
     358                 :            : }
     359                 :            : 
     360                 :            : //------------------------------------------------------------------------
     361                 :            : 
     362                 :          0 : IMPL_LINK( SvxHatchTabPage, ModifiedHdl_Impl, void *, p )
     363                 :            : {
     364         [ #  # ]:          0 :     if( p == &aMtrAngle )
     365                 :            :     {
     366 [ #  # ][ #  #  :          0 :         switch( aMtrAngle.GetValue() )
          #  #  #  #  #  
                   #  # ]
     367                 :            :         {
     368         [ #  # ]:          0 :             case 135: aCtlAngle.SetActualRP( RP_LT ); break;
     369         [ #  # ]:          0 :             case  90: aCtlAngle.SetActualRP( RP_MT ); break;
     370         [ #  # ]:          0 :             case  45: aCtlAngle.SetActualRP( RP_RT ); break;
     371         [ #  # ]:          0 :             case 180: aCtlAngle.SetActualRP( RP_LM ); break;
     372         [ #  # ]:          0 :             case   0: aCtlAngle.SetActualRP( RP_RM ); break;
     373         [ #  # ]:          0 :             case 225: aCtlAngle.SetActualRP( RP_LB ); break;
     374         [ #  # ]:          0 :             case 270: aCtlAngle.SetActualRP( RP_MB ); break;
     375         [ #  # ]:          0 :             case 315: aCtlAngle.SetActualRP( RP_RB ); break;
     376         [ #  # ]:          0 :             default:  aCtlAngle.SetActualRP( RP_MM ); break;
     377                 :            :         }
     378                 :            :     }
     379                 :            : 
     380                 :          0 :     XHatch aXHatch( aLbLineColor.GetSelectEntryColor(),
     381         [ #  # ]:          0 :                     (XHatchStyle) aLbLineType.GetSelectEntryPos(),
     382                 :            :                     GetCoreValue( aMtrDistance, ePoolUnit ),
     383 [ #  # ][ #  # ]:          0 :                     static_cast<long>(aMtrAngle.GetValue() * 10) );
         [ #  # ][ #  # ]
     384                 :            : 
     385 [ #  # ][ #  # ]:          0 :     rXFSet.Put( XFillHatchItem( String(), aXHatch ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     386         [ #  # ]:          0 :     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
     387                 :            : 
     388         [ #  # ]:          0 :     aCtlPreview.Invalidate();
     389                 :            : 
     390                 :          0 :     return 0L;
     391                 :            : }
     392                 :            : 
     393                 :            : //------------------------------------------------------------------------
     394                 :            : 
     395                 :          0 : IMPL_LINK_NOARG(SvxHatchTabPage, ChangeHatchHdl_Impl)
     396                 :            : {
     397                 :          0 :     XHatch* pHatch = NULL;
     398                 :          0 :     int nPos = aLbHatchings.GetSelectEntryPos();
     399                 :            : 
     400         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     401                 :          0 :         pHatch = new XHatch( ( (XHatchEntry*) pHatchingList->GetHatch( nPos ) )->GetHatch() );
     402                 :            :     else
     403                 :            :     {
     404                 :          0 :         const SfxPoolItem* pPoolItem = NULL;
     405 [ #  # ][ #  # ]:          0 :         if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLSTYLE ), sal_True, &pPoolItem ) )
                 [ #  # ]
     406                 :            :         {
     407 [ #  # ][ #  # ]:          0 :             if( ( XFILL_HATCH == (XFillStyle) ( ( const XFillStyleItem* ) pPoolItem )->GetValue() ) &&
                 [ #  # ]
     408 [ #  # ][ #  # ]:          0 :                 ( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLHATCH ), sal_True, &pPoolItem ) ) )
     409                 :            :             {
     410 [ #  # ][ #  # ]:          0 :                 pHatch = new XHatch( ( ( const XFillHatchItem* ) pPoolItem )->GetHatchValue() );
     411                 :            :             }
     412                 :            :         }
     413         [ #  # ]:          0 :         if( !pHatch )
     414                 :            :         {
     415         [ #  # ]:          0 :             aLbHatchings.SelectEntryPos( 0 );
     416         [ #  # ]:          0 :             nPos = aLbHatchings.GetSelectEntryPos();
     417         [ #  # ]:          0 :             if( nPos != LISTBOX_ENTRY_NOTFOUND )
     418 [ #  # ][ #  # ]:          0 :                 pHatch = new XHatch( ( (XHatchEntry*) pHatchingList->GetHatch( nPos ) )->GetHatch() );
     419                 :            :         }
     420                 :            :     }
     421         [ #  # ]:          0 :     if( pHatch )
     422                 :            :     {
     423                 :            :         aLbLineType.SelectEntryPos(
     424                 :          0 :             sal::static_int_cast< sal_uInt16 >( pHatch->GetHatchStyle() ) );
     425                 :            :         // if the entry is not in the listbox
     426                 :            :         // the color is added temporarily
     427                 :          0 :         aLbLineColor.SetNoSelection();
     428         [ #  # ]:          0 :         aLbLineColor.SelectEntry( pHatch->GetColor() );
     429         [ #  # ]:          0 :         if( aLbLineColor.GetSelectEntryCount() == 0 )
     430                 :            :         {
     431         [ #  # ]:          0 :             aLbLineColor.InsertEntry( pHatch->GetColor(), String() );
     432         [ #  # ]:          0 :             aLbLineColor.SelectEntry( pHatch->GetColor() );
     433                 :            :         }
     434                 :          0 :         SetMetricValue( aMtrDistance, pHatch->GetDistance(), ePoolUnit );
     435                 :          0 :         aMtrAngle.SetValue( pHatch->GetAngle() / 10 );
     436                 :            : 
     437   [ #  #  #  #  :          0 :         switch( aMtrAngle.GetValue() )
             #  #  #  #  
                      # ]
     438                 :            :         {
     439                 :          0 :             case 135: aCtlAngle.SetActualRP( RP_LT ); break;
     440                 :          0 :             case  90: aCtlAngle.SetActualRP( RP_MT ); break;
     441                 :          0 :             case  45: aCtlAngle.SetActualRP( RP_RT ); break;
     442                 :          0 :             case 180: aCtlAngle.SetActualRP( RP_LM ); break;
     443                 :          0 :             case   0: aCtlAngle.SetActualRP( RP_RM ); break;
     444                 :          0 :             case 225: aCtlAngle.SetActualRP( RP_LB ); break;
     445                 :          0 :             case 270: aCtlAngle.SetActualRP( RP_MB ); break;
     446                 :          0 :             case 315: aCtlAngle.SetActualRP( RP_RB ); break;
     447                 :          0 :             default:  aCtlAngle.SetActualRP( RP_MM ); break;
     448                 :            :         }
     449                 :            : 
     450                 :            :         // fill ItemSet and pass it on to aCtlPreview
     451 [ #  # ][ #  # ]:          0 :         rXFSet.Put( XFillHatchItem( String(), *pHatch ) );
                 [ #  # ]
     452                 :          0 :         aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
     453                 :            : 
     454                 :          0 :         aCtlPreview.Invalidate();
     455                 :          0 :         delete pHatch;
     456                 :            :     }
     457                 :          0 :     aMtrDistance.SaveValue();
     458                 :          0 :     aMtrAngle.SaveValue();
     459                 :          0 :     aLbLineType.SaveValue();
     460                 :          0 :     aLbLineColor.SaveValue();
     461                 :          0 :     aLbHatchings.SaveValue();
     462                 :            : 
     463                 :          0 :     return 0L;
     464                 :            : }
     465                 :            : 
     466                 :            : //------------------------------------------------------------------------
     467                 :            : 
     468                 :          0 : IMPL_LINK_NOARG(SvxHatchTabPage, ClickAddHdl_Impl)
     469                 :            : {
     470         [ #  # ]:          0 :     ResMgr& rMgr = CUI_MGR();
     471 [ #  # ][ #  # ]:          0 :     String aNewName( SVX_RES( RID_SVXSTR_HATCH ) );
     472 [ #  # ][ #  # ]:          0 :     String aDesc( CUI_RES( RID_SVXSTR_DESC_HATCH ) );
     473         [ #  # ]:          0 :     String aName;
     474                 :            : 
     475         [ #  # ]:          0 :     long nCount = pHatchingList->Count();
     476                 :          0 :     long j = 1;
     477                 :          0 :     sal_Bool bDifferent = sal_False;
     478                 :            : 
     479         [ #  # ]:          0 :     while( !bDifferent )
     480                 :            :     {
     481         [ #  # ]:          0 :         aName  = aNewName;
     482         [ #  # ]:          0 :         aName += sal_Unicode(' ');
     483 [ #  # ][ #  # ]:          0 :         aName += UniString::CreateFromInt32( j++ );
                 [ #  # ]
     484                 :          0 :         bDifferent = sal_True;
     485                 :            : 
     486 [ #  # ][ #  # ]:          0 :         for( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     487 [ #  # ][ #  # ]:          0 :             if( aName == pHatchingList->GetHatch( i )->GetName() )
                 [ #  # ]
     488                 :          0 :                 bDifferent = sal_False;
     489                 :            :     }
     490                 :            : 
     491         [ #  # ]:          0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     492                 :            :     DBG_ASSERT(pFact, "Dialogdiet fail!");
     493 [ #  # ][ #  # ]:          0 :     AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc );
     494                 :            :     DBG_ASSERT(pDlg, "Dialogdiet fail!");
     495                 :          0 :     WarningBox*    pWarnBox = NULL;
     496                 :          0 :     sal_uInt16         nError   = RID_SVXSTR_WARN_NAME_DUPLICATE;
     497                 :            : 
     498 [ #  # ][ #  # ]:          0 :     while( pDlg->Execute() == RET_OK )
     499                 :            :     {
     500         [ #  # ]:          0 :         pDlg->GetName( aName );
     501                 :            : 
     502                 :          0 :         bDifferent = sal_True;
     503                 :            : 
     504 [ #  # ][ #  # ]:          0 :         for( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     505 [ #  # ][ #  # ]:          0 :             if( aName == pHatchingList->GetHatch( i )->GetName() )
                 [ #  # ]
     506                 :          0 :                 bDifferent = sal_False;
     507                 :            : 
     508         [ #  # ]:          0 :         if( bDifferent ) {
     509                 :          0 :             nError = 0;
     510                 :          0 :             break;
     511                 :            :         }
     512                 :            : 
     513         [ #  # ]:          0 :         if( !pWarnBox )
     514                 :            :         {
     515                 :          0 :             pWarnBox = new WarningBox( GetParentDialog(),
     516                 :            :                                        WinBits( WB_OK_CANCEL ),
     517 [ #  # ][ #  # ]:          0 :                                        String( ResId( nError, rMgr ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     518         [ #  # ]:          0 :             pWarnBox->SetHelpId( HID_WARN_NAME_DUPLICATE );
     519                 :            :         }
     520                 :            : 
     521 [ #  # ][ #  # ]:          0 :         if( pWarnBox->Execute() != RET_OK )
     522                 :          0 :             break;
     523                 :            :     }
     524 [ #  # ][ #  # ]:          0 :     delete pDlg;
     525 [ #  # ][ #  # ]:          0 :     delete pWarnBox;
     526                 :            : 
     527         [ #  # ]:          0 :     if( !nError )
     528                 :            :     {
     529                 :          0 :         XHatch aXHatch( aLbLineColor.GetSelectEntryColor(),
     530         [ #  # ]:          0 :                         (XHatchStyle) aLbLineType.GetSelectEntryPos(),
     531                 :            :                         GetCoreValue( aMtrDistance, ePoolUnit ),
     532 [ #  # ][ #  # ]:          0 :                         static_cast<long>(aMtrAngle.GetValue() * 10) );
         [ #  # ][ #  # ]
     533 [ #  # ][ #  # ]:          0 :         XHatchEntry* pEntry = new XHatchEntry( aXHatch, aName );
     534                 :            : 
     535         [ #  # ]:          0 :         pHatchingList->Insert( pEntry, nCount );
     536                 :            : 
     537         [ #  # ]:          0 :         aLbHatchings.Append( pEntry );
     538                 :            : 
     539 [ #  # ][ #  # ]:          0 :         aLbHatchings.SelectEntryPos( aLbHatchings.GetEntryCount() - 1 );
     540                 :            : 
     541                 :            : #ifdef WNT
     542                 :            :         // hack: #31355# W.P.
     543                 :            :         Rectangle aRect( aLbHatchings.GetPosPixel(), aLbHatchings.GetSizePixel() );
     544                 :            :         if( sal_True ) {                // ??? overlapped with pDlg
     545                 :            :                                     // and srolling
     546                 :            :             Invalidate( aRect );
     547                 :            :         }
     548                 :            : #endif
     549                 :            : 
     550                 :          0 :         *pnHatchingListState |= CT_MODIFIED;
     551                 :            : 
     552         [ #  # ]:          0 :         ChangeHatchHdl_Impl( this );
     553                 :            :     }
     554                 :            : 
     555                 :            :     // determine button state
     556 [ #  # ][ #  # ]:          0 :     if( pHatchingList->Count() )
     557                 :            :     {
     558         [ #  # ]:          0 :         aBtnModify.Enable();
     559         [ #  # ]:          0 :         aBtnDelete.Enable();
     560         [ #  # ]:          0 :         aBtnSave.Enable();
     561                 :            :     }
     562 [ #  # ][ #  # ]:          0 :     return 0L;
                 [ #  # ]
     563                 :            : }
     564                 :            : 
     565                 :            : //------------------------------------------------------------------------
     566                 :            : 
     567                 :          0 : IMPL_LINK_NOARG(SvxHatchTabPage, ClickModifyHdl_Impl)
     568                 :            : {
     569                 :          0 :     sal_uInt16 nPos = aLbHatchings.GetSelectEntryPos();
     570                 :            : 
     571         [ #  # ]:          0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
     572                 :            :     {
     573         [ #  # ]:          0 :         ResMgr& rMgr = CUI_MGR();
     574 [ #  # ][ #  # ]:          0 :         String aNewName( SVX_RES( RID_SVXSTR_HATCH ) );
     575 [ #  # ][ #  # ]:          0 :         String aDesc( CUI_RES( RID_SVXSTR_DESC_HATCH ) );
     576 [ #  # ][ #  # ]:          0 :         String aName( pHatchingList->GetHatch( nPos )->GetName() );
     577         [ #  # ]:          0 :         String aOldName = aName;
     578                 :            : 
     579         [ #  # ]:          0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     580                 :            :         DBG_ASSERT(pFact, "Dialogdiet fail!");
     581 [ #  # ][ #  # ]:          0 :         AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc );
     582                 :            :         DBG_ASSERT(pDlg, "Dialogdiet fail!");
     583                 :            : 
     584         [ #  # ]:          0 :         long nCount = pHatchingList->Count();
     585                 :          0 :         sal_Bool bDifferent = sal_False;
     586                 :          0 :         sal_Bool bLoop = sal_True;
     587 [ #  # ][ #  # ]:          0 :         while( bLoop && pDlg->Execute() == RET_OK )
         [ #  # ][ #  # ]
     588                 :            :         {
     589         [ #  # ]:          0 :             pDlg->GetName( aName );
     590                 :          0 :             bDifferent = sal_True;
     591                 :            : 
     592 [ #  # ][ #  # ]:          0 :             for( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     593                 :            :             {
     594 [ #  # ][ #  # ]:          0 :                 if( aName == pHatchingList->GetHatch( i )->GetName() &&
         [ #  # ][ #  # ]
                 [ #  # ]
     595         [ #  # ]:          0 :                     aName != aOldName )
     596                 :          0 :                     bDifferent = sal_False;
     597                 :            :             }
     598                 :            : 
     599         [ #  # ]:          0 :             if( bDifferent )
     600                 :            :             {
     601                 :          0 :                 bLoop = sal_False;
     602                 :          0 :                 XHatch aXHatch( aLbLineColor.GetSelectEntryColor(),
     603         [ #  # ]:          0 :                                 (XHatchStyle) aLbLineType.GetSelectEntryPos(),
     604                 :            :                                  GetCoreValue( aMtrDistance, ePoolUnit ),
     605 [ #  # ][ #  # ]:          0 :                                 static_cast<long>(aMtrAngle.GetValue() * 10) );
         [ #  # ][ #  # ]
     606                 :            : 
     607 [ #  # ][ #  # ]:          0 :                 XHatchEntry* pEntry = new XHatchEntry( aXHatch, aName );
     608                 :            : 
     609 [ #  # ][ #  # ]:          0 :                 delete pHatchingList->Replace( pEntry, nPos );
                 [ #  # ]
     610                 :            : 
     611         [ #  # ]:          0 :                 aLbHatchings.Modify( pEntry, nPos );
     612                 :            : 
     613         [ #  # ]:          0 :                 aLbHatchings.SelectEntryPos( nPos );
     614                 :            : 
     615                 :            :                 // save values for changes recognition (-> method)
     616         [ #  # ]:          0 :                 aMtrDistance.SaveValue();
     617         [ #  # ]:          0 :                 aMtrAngle.SaveValue();
     618         [ #  # ]:          0 :                 aLbLineType.SaveValue();
     619         [ #  # ]:          0 :                 aLbLineColor.SaveValue();
     620         [ #  # ]:          0 :                 aLbHatchings.SaveValue();
     621                 :            : 
     622                 :          0 :                 *pnHatchingListState |= CT_MODIFIED;
     623                 :            :             }
     624                 :            :             else
     625                 :            :             {
     626 [ #  # ][ #  # ]:          0 :                 WarningBox aBox( GetParentDialog(), WinBits( WB_OK ),String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
         [ #  # ][ #  # ]
     627         [ #  # ]:          0 :                 aBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
     628 [ #  # ][ #  # ]:          0 :                 aBox.Execute();
     629                 :            :             }
     630                 :            :         }
     631 [ #  # ][ #  # ]:          0 :         delete( pDlg );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     632                 :            :     }
     633                 :          0 :     return 0L;
     634                 :            : }
     635                 :            : 
     636                 :            : //------------------------------------------------------------------------
     637                 :            : 
     638                 :          0 : IMPL_LINK_NOARG(SvxHatchTabPage, ClickDeleteHdl_Impl)
     639                 :            : {
     640                 :          0 :     sal_uInt16 nPos = aLbHatchings.GetSelectEntryPos();
     641                 :            : 
     642         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     643                 :            :     {
     644                 :            :         QueryBox aQueryBox( GetParentDialog(), WinBits( WB_YES_NO | WB_DEF_NO ),
     645 [ #  # ][ #  # ]:          0 :             String( CUI_RES( RID_SVXSTR_ASK_DEL_HATCH ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     646                 :            : 
     647 [ #  # ][ #  # ]:          0 :         if( aQueryBox.Execute() == RET_YES )
     648                 :            :         {
     649 [ #  # ][ #  # ]:          0 :             delete pHatchingList->Remove( nPos );
                 [ #  # ]
     650         [ #  # ]:          0 :             aLbHatchings.RemoveEntry( nPos );
     651         [ #  # ]:          0 :             aLbHatchings.SelectEntryPos( 0 );
     652                 :            : 
     653         [ #  # ]:          0 :             aCtlPreview.Invalidate();
     654                 :            : 
     655         [ #  # ]:          0 :             ChangeHatchHdl_Impl( this );
     656                 :            : 
     657                 :          0 :             *pnHatchingListState |= CT_MODIFIED;
     658         [ #  # ]:          0 :         }
     659                 :            :     }
     660                 :            :     // determine button state
     661         [ #  # ]:          0 :     if( !pHatchingList->Count() )
     662                 :            :     {
     663                 :          0 :         aBtnModify.Disable();
     664                 :          0 :         aBtnDelete.Disable();
     665                 :          0 :         aBtnSave.Disable();
     666                 :            :     }
     667                 :          0 :     return 0L;
     668                 :            : }
     669                 :            : 
     670                 :            : // -----------------------------------------------------------------------
     671                 :            : 
     672                 :          0 : IMPL_LINK_NOARG(SvxHatchTabPage, ClickLoadHdl_Impl)
     673                 :            : {
     674                 :          0 :     ResMgr& rMgr = CUI_MGR();
     675                 :          0 :     sal_uInt16 nReturn = RET_YES;
     676                 :            : 
     677         [ #  # ]:          0 :     if ( *pnHatchingListState & CT_MODIFIED )
     678                 :            :     {
     679                 :            :         nReturn = WarningBox( GetParentDialog(), WinBits( WB_YES_NO_CANCEL ),
     680 [ #  # ][ #  # ]:          0 :             String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     681                 :            : 
     682         [ #  # ]:          0 :         if ( nReturn == RET_YES )
     683                 :          0 :             pHatchingList->Save();
     684                 :            :     }
     685                 :            : 
     686         [ #  # ]:          0 :     if ( nReturn != RET_CANCEL )
     687                 :            :     {
     688                 :            :         ::sfx2::FileDialogHelper aDlg(
     689                 :            :             com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
     690         [ #  # ]:          0 :             0 );
     691         [ #  # ]:          0 :         String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soh" ) );
     692         [ #  # ]:          0 :         aDlg.AddFilter( aStrFilterType, aStrFilterType );
     693 [ #  # ][ #  # ]:          0 :         INetURLObject aFile( SvtPathOptions().GetPalettePath() );
         [ #  # ][ #  # ]
                 [ #  # ]
     694 [ #  # ][ #  # ]:          0 :         aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
     695                 :            : 
     696 [ #  # ][ #  # ]:          0 :         if( aDlg.Execute() == ERRCODE_NONE )
     697                 :            :         {
     698 [ #  # ][ #  # ]:          0 :             INetURLObject aURL( aDlg.GetPath() );
         [ #  # ][ #  # ]
     699         [ #  # ]:          0 :             INetURLObject aPathURL( aURL );
     700                 :            : 
     701         [ #  # ]:          0 :             aPathURL.removeSegment();
     702         [ #  # ]:          0 :             aPathURL.removeFinalSlash();
     703                 :            : 
     704                 :            :             XHatchListRef pHatchList = XPropertyList::CreatePropertyList(
     705 [ #  # ][ #  # ]:          0 :                 XHATCH_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), pXPool )->AsHatchList();
         [ #  # ][ #  # ]
                 [ #  # ]
     706 [ #  # ][ #  # ]:          0 :             pHatchList->SetName( aURL.getName() );
         [ #  # ][ #  # ]
     707 [ #  # ][ #  # ]:          0 :             if( pHatchList->Load() )
     708                 :            :             {
     709         [ #  # ]:          0 :                 pHatchingList = pHatchList;
     710 [ #  # ][ #  # ]:          0 :                 ( (SvxAreaTabDialog*) GetParentDialog() )->SetNewHatchingList( pHatchingList );
     711                 :            : 
     712         [ #  # ]:          0 :                 aLbHatchings.Clear();
     713         [ #  # ]:          0 :                 aLbHatchings.Fill( pHatchingList );
     714         [ #  # ]:          0 :                 Reset( rOutAttrs );
     715                 :            : 
     716 [ #  # ][ #  # ]:          0 :                 pHatchingList->SetName( aURL.getName() );
         [ #  # ][ #  # ]
     717                 :            : 
     718                 :            :                 // determining (and possibly cutting) the name
     719                 :            :                 // and displaying it in the GroupBox
     720         [ #  # ]:          0 :                 String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
     721         [ #  # ]:          0 :                 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
     722                 :            : 
     723 [ #  # ][ #  # ]:          0 :                 if ( aURL.getBase().getLength() > 18 )
     724                 :            :                 {
     725 [ #  # ][ #  # ]:          0 :                     aString += String(aURL.getBase()).Copy( 0, 15 );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     726         [ #  # ]:          0 :                     aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
     727                 :            :                 }
     728                 :            :                 else
     729 [ #  # ][ #  # ]:          0 :                     aString += String(aURL.getBase());
         [ #  # ][ #  # ]
     730                 :            : 
     731                 :          0 :                 *pnHatchingListState |= CT_CHANGED;
     732         [ #  # ]:          0 :                 *pnHatchingListState &= ~CT_MODIFIED;
     733                 :            :             }
     734                 :            :             else
     735                 :            :                 ErrorBox( GetParentDialog(), WinBits( WB_OK ),
     736 [ #  # ][ #  # ]:          0 :                     String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     737 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     738                 :            :     }
     739                 :            : 
     740                 :            :     // determine button state
     741         [ #  # ]:          0 :     if ( pHatchingList->Count() )
     742                 :            :     {
     743                 :          0 :         aBtnModify.Enable();
     744                 :          0 :         aBtnDelete.Enable();
     745                 :          0 :         aBtnSave.Enable();
     746                 :            :     }
     747                 :            :     else
     748                 :            :     {
     749                 :          0 :         aBtnModify.Disable();
     750                 :          0 :         aBtnDelete.Disable();
     751                 :          0 :         aBtnSave.Disable();
     752                 :            :     }
     753                 :          0 :     return 0L;
     754                 :            : }
     755                 :            : 
     756                 :            : // -----------------------------------------------------------------------
     757                 :            : 
     758                 :          0 : IMPL_LINK_NOARG(SvxHatchTabPage, ClickSaveHdl_Impl)
     759                 :            : {
     760                 :            :     ::sfx2::FileDialogHelper aDlg(
     761         [ #  # ]:          0 :         com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
     762         [ #  # ]:          0 :     String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soh" ) );
     763         [ #  # ]:          0 :     aDlg.AddFilter( aStrFilterType, aStrFilterType );
     764                 :            : 
     765 [ #  # ][ #  # ]:          0 :     INetURLObject aFile( SvtPathOptions().GetPalettePath() );
         [ #  # ][ #  # ]
                 [ #  # ]
     766                 :            :     DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     767                 :            : 
     768         [ #  # ]:          0 :     if( pHatchingList->GetName().Len() )
     769                 :            :     {
     770 [ #  # ][ #  # ]:          0 :         aFile.Append( pHatchingList->GetName() );
     771                 :            : 
     772 [ #  # ][ #  # ]:          0 :         if( aFile.getExtension().isEmpty() )
     773         [ #  # ]:          0 :             aFile.SetExtension(rtl::OUString("soh"));
     774                 :            :     }
     775                 :            : 
     776 [ #  # ][ #  # ]:          0 :     aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
     777 [ #  # ][ #  # ]:          0 :     if ( aDlg.Execute() == ERRCODE_NONE )
     778                 :            :     {
     779 [ #  # ][ #  # ]:          0 :         INetURLObject aURL( aDlg.GetPath() );
         [ #  # ][ #  # ]
     780         [ #  # ]:          0 :         INetURLObject aPathURL( aURL );
     781                 :            : 
     782         [ #  # ]:          0 :         aPathURL.removeSegment();
     783         [ #  # ]:          0 :         aPathURL.removeFinalSlash();
     784                 :            : 
     785 [ #  # ][ #  # ]:          0 :         pHatchingList->SetName( aURL.getName() );
         [ #  # ][ #  # ]
     786 [ #  # ][ #  # ]:          0 :         pHatchingList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
     787                 :            : 
     788 [ #  # ][ #  # ]:          0 :         if( pHatchingList->Save() )
     789                 :            :         {
     790                 :            :             // determining (and possibly cutting) the name
     791                 :            :             // and displaying it in the GroupBox
     792 [ #  # ][ #  # ]:          0 :             String aString( CUI_RES( RID_SVXSTR_TABLE ) );
     793         [ #  # ]:          0 :             aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
     794                 :            : 
     795 [ #  # ][ #  # ]:          0 :             if ( aURL.getBase().getLength() > 18 )
     796                 :            :             {
     797 [ #  # ][ #  # ]:          0 :                 aString += String(aURL.getBase()).Copy( 0, 15 );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     798         [ #  # ]:          0 :                 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
     799                 :            :             }
     800                 :            :             else
     801 [ #  # ][ #  # ]:          0 :                 aString += String(aURL.getBase());
         [ #  # ][ #  # ]
     802                 :            : 
     803                 :          0 :             *pnHatchingListState |= CT_SAVED;
     804         [ #  # ]:          0 :             *pnHatchingListState &= ~CT_MODIFIED;
     805                 :            :         }
     806                 :            :         else
     807                 :            :         {
     808                 :            :             ErrorBox( GetParentDialog(), WinBits( WB_OK ),
     809 [ #  # ][ #  # ]:          0 :                 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     810 [ #  # ][ #  # ]:          0 :         }
     811                 :            :     }
     812                 :            : 
     813 [ #  # ][ #  # ]:          0 :     return 0L;
                 [ #  # ]
     814                 :            : }
     815                 :            : 
     816                 :            : //------------------------------------------------------------------------
     817                 :            : 
     818                 :          0 : void SvxHatchTabPage::PointChanged( Window* pWindow, RECT_POINT eRcPt )
     819                 :            : {
     820         [ #  # ]:          0 :     if( pWindow == &aCtlAngle )
     821                 :            :     {
     822   [ #  #  #  #  :          0 :         switch( eRcPt )
          #  #  #  #  #  
                      # ]
     823                 :            :         {
     824                 :          0 :             case RP_LT: aMtrAngle.SetValue( 135 ); break;
     825                 :          0 :             case RP_MT: aMtrAngle.SetValue( 90 );  break;
     826                 :          0 :             case RP_RT: aMtrAngle.SetValue( 45 );  break;
     827                 :          0 :             case RP_LM: aMtrAngle.SetValue( 180 ); break;
     828                 :          0 :             case RP_RM: aMtrAngle.SetValue( 0 );   break;
     829                 :          0 :             case RP_LB: aMtrAngle.SetValue( 225 ); break;
     830                 :          0 :             case RP_MB: aMtrAngle.SetValue( 270 ); break;
     831                 :          0 :             case RP_RB: aMtrAngle.SetValue( 315 ); break;
     832                 :          0 :             case RP_MM: break;
     833                 :            :         }
     834                 :          0 :         ModifiedHdl_Impl( this );
     835                 :            :     }
     836                 :          0 : }
     837                 :            : 
     838                 :            : 
     839                 :          0 : void SvxHatchTabPage::DataChanged( const DataChangedEvent& rDCEvt )
     840                 :            : {
     841 [ #  # ][ #  # ]:          0 :     if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
                 [ #  # ]
     842         [ #  # ]:          0 :         aCtlPreview.SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
     843                 :            : 
     844                 :          0 :     SvxTabPage::DataChanged( rDCEvt );
     845                 :          0 : }
     846                 :            : 
     847                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10