LCOV - code coverage report
Current view: top level - cui/source/tabpages - tplneend.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 311 0.0 %
Date: 2012-08-25 Functions: 0 24 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 778 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/filedlghelper.hxx>
      35                 :            : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
      36                 :            : 
      37                 :            : #define _SVX_TPLNEEND_CXX
      38                 :            : 
      39                 :            : #include <cuires.hrc>
      40                 :            : #include "tabline.hrc"
      41                 :            : #include "helpid.hrc"
      42                 :            : #include <svx/dialmgr.hxx>
      43                 :            : #include <svx/svdobj.hxx>
      44                 :            : #include <svx/svdopath.hxx>
      45                 :            : #include "svx/drawitem.hxx"
      46                 :            : #include <svx/xpool.hxx>
      47                 :            : #include <svx/xtable.hxx>
      48                 :            : #include "cuitabline.hxx"
      49                 :            : #include <svx/svxdlg.hxx>
      50                 :            : #include <dialmgr.hxx>
      51                 :            : #include "svx/dlgutil.hxx"
      52                 :            : #include <basegfx/range/b2drange.hxx>
      53                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      54                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      55                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      56                 :            : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      57                 :            : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      58                 :            : #include <svx/dialogs.hrc>
      59                 :            : 
      60                 :            : #define XOUT_WIDTH    150
      61                 :            : 
      62                 :          0 : SvxLineEndDefTabPage::SvxLineEndDefTabPage
      63                 :            : (
      64                 :            :     Window* pParent,
      65                 :            :     const SfxItemSet& rInAttrs
      66                 :            : ) :
      67                 :            : 
      68                 :          0 :     SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_LINEEND_DEF ), rInAttrs ),
      69                 :            : 
      70         [ #  # ]:          0 :     aFlTip              ( this, CUI_RES( FL_TIP ) ),
      71         [ #  # ]:          0 :     aFTTitle            ( this, CUI_RES( FT_TITLE ) ),
      72         [ #  # ]:          0 :     aEdtName            ( this, CUI_RES( EDT_NAME ) ),
      73         [ #  # ]:          0 :     aFTLineEndStyle     ( this, CUI_RES( FT_LINE_END_STYLE ) ),
      74         [ #  # ]:          0 :     aLbLineEnds         ( this, CUI_RES( LB_LINEENDS ) ),
      75         [ #  # ]:          0 :     aBtnAdd             ( this, CUI_RES( BTN_ADD ) ),
      76         [ #  # ]:          0 :     aBtnModify          ( this, CUI_RES( BTN_MODIFY ) ),
      77         [ #  # ]:          0 :     aBtnDelete          ( this, CUI_RES( BTN_DELETE ) ),
      78         [ #  # ]:          0 :     aBtnLoad            ( this, CUI_RES( BTN_LOAD ) ),
      79         [ #  # ]:          0 :     aBtnSave            ( this, CUI_RES( BTN_SAVE ) ),
      80         [ #  # ]:          0 :     aFiTip              ( this, CUI_RES( FI_TIP ) ),
      81         [ #  # ]:          0 :     aCtlPreview         ( this, CUI_RES( CTL_PREVIEW ) ),
      82                 :            : 
      83                 :            :     rOutAttrs           ( rInAttrs ),
      84                 :            :     pPolyObj( NULL ),
      85                 :            : 
      86                 :          0 :     pXPool              ( (XOutdevItemPool*) rInAttrs.GetPool() ),
      87                 :            :     aXLStyle            ( XLINE_SOLID ),
      88                 :            :     aXWidth             ( XOUT_WIDTH ),
      89                 :            :     aXColor             ( String(), COL_BLACK ),
      90                 :            :     aXLineAttr          ( pXPool ),
      91                 :          0 :     rXLSet              ( aXLineAttr.GetItemSet() ),
      92 [ #  # ][ #  # ]:          0 :     pLineEndList( NULL )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      93                 :            : {
      94         [ #  # ]:          0 :     FreeResource();
      95                 :            : 
      96                 :            :     // this page needs ExchangeSupport
      97                 :          0 :     SetExchangeSupport();
      98                 :            : 
      99         [ #  # ]:          0 :     rXLSet.Put( aXLStyle );
     100         [ #  # ]:          0 :     rXLSet.Put( aXWidth );
     101         [ #  # ]:          0 :     rXLSet.Put( aXColor );
     102 [ #  # ][ #  # ]:          0 :     rXLSet.Put( XLineStartWidthItem( aCtlPreview.GetOutputSize().Height()  / 2 ) );
         [ #  # ][ #  # ]
     103 [ #  # ][ #  # ]:          0 :     rXLSet.Put( XLineEndWidthItem( aCtlPreview.GetOutputSize().Height() / 2 ) );
         [ #  # ][ #  # ]
     104                 :            : 
     105                 :            :     // #i34740#
     106         [ #  # ]:          0 :     aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet());
     107                 :            : 
     108                 :            :     aBtnAdd.SetClickHdl(
     109         [ #  # ]:          0 :         LINK( this, SvxLineEndDefTabPage, ClickAddHdl_Impl ) );
     110                 :            :     aBtnModify.SetClickHdl(
     111         [ #  # ]:          0 :         LINK( this, SvxLineEndDefTabPage, ClickModifyHdl_Impl ) );
     112                 :            :     aBtnDelete.SetClickHdl(
     113         [ #  # ]:          0 :         LINK( this, SvxLineEndDefTabPage, ClickDeleteHdl_Impl ) );
     114                 :            :     aBtnLoad.SetClickHdl(
     115         [ #  # ]:          0 :         LINK( this, SvxLineEndDefTabPage, ClickLoadHdl_Impl ) );
     116                 :            :     aBtnSave.SetClickHdl(
     117         [ #  # ]:          0 :         LINK( this, SvxLineEndDefTabPage, ClickSaveHdl_Impl ) );
     118                 :            : 
     119                 :            :     aLbLineEnds.SetSelectHdl(
     120         [ #  # ]:          0 :         LINK( this, SvxLineEndDefTabPage, SelectLineEndHdl_Impl ) );
     121                 :            : 
     122         [ #  # ]:          0 :     aBtnAdd.SetAccessibleRelationMemberOf(&aFlTip);
     123         [ #  # ]:          0 :     aBtnModify.SetAccessibleRelationMemberOf(&aFlTip);
     124         [ #  # ]:          0 :     aBtnDelete.SetAccessibleRelationMemberOf(&aFlTip);
     125                 :          0 : }
     126                 :            : 
     127                 :            : //------------------------------------------------------------------------
     128                 :            : 
     129 [ #  # ][ #  # ]:          0 : SvxLineEndDefTabPage::~SvxLineEndDefTabPage()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     130                 :            : {
     131         [ #  # ]:          0 : }
     132                 :            : 
     133                 :            : // -----------------------------------------------------------------------
     134                 :            : 
     135                 :          0 : void SvxLineEndDefTabPage::Construct()
     136                 :            : {
     137                 :          0 :     aLbLineEnds.Fill( pLineEndList );
     138                 :            : 
     139                 :          0 :     bool bCreateArrowPossible = true;
     140                 :            : 
     141         [ #  # ]:          0 :     if( !pPolyObj )
     142                 :            :     {
     143                 :          0 :         bCreateArrowPossible = false;
     144                 :            :     }
     145         [ #  # ]:          0 :     else if( !pPolyObj->ISA( SdrPathObj ) )
     146                 :            :     {
     147         [ #  # ]:          0 :         SdrObjTransformInfoRec aInfoRec;
     148         [ #  # ]:          0 :         pPolyObj->TakeObjInfo( aInfoRec );
     149                 :          0 :         SdrObject* pNewObj = 0;
     150         [ #  # ]:          0 :         if( aInfoRec.bCanConvToPath )
     151         [ #  # ]:          0 :             pNewObj = pPolyObj->ConvertToPolyObj( sal_True, sal_False );
     152                 :            : 
     153 [ #  # ][ #  # ]:          0 :         bCreateArrowPossible = pNewObj && pNewObj->ISA( SdrPathObj );
         [ #  # ][ #  # ]
     154         [ #  # ]:          0 :         SdrObject::Free( pNewObj );
     155                 :            :     }
     156                 :            : 
     157         [ #  # ]:          0 :     if( !bCreateArrowPossible )
     158                 :          0 :         aBtnAdd.Disable();
     159                 :          0 : }
     160                 :            : 
     161                 :            : // -----------------------------------------------------------------------
     162                 :            : 
     163                 :          0 : void SvxLineEndDefTabPage::ActivatePage( const SfxItemSet& )
     164                 :            : {
     165         [ #  # ]:          0 :     if( *pDlgType == 0 ) // area dialog
     166                 :            :     {
     167                 :            :         // ActivatePage() is called before the dialog receives PageCreated() !!!
     168         [ #  # ]:          0 :         if( pLineEndList.is() )
     169                 :            :         {
     170         [ #  # ]:          0 :             if( *pPosLineEndLb != LISTBOX_ENTRY_NOTFOUND )
     171                 :            :             {
     172         [ #  # ]:          0 :                 aLbLineEnds.SelectEntryPos( *pPosLineEndLb );
     173         [ #  # ]:          0 :                 SelectLineEndHdl_Impl( this );
     174                 :            :             }
     175 [ #  # ][ #  # ]:          0 :             INetURLObject   aURL( pLineEndList->GetPath() );
     176                 :            : 
     177 [ #  # ][ #  # ]:          0 :             aURL.Append( pLineEndList->GetName() );
     178                 :            :             DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     179                 :          0 :             *pPageType = 0; // 3
     180         [ #  # ]:          0 :             *pPosLineEndLb = LISTBOX_ENTRY_NOTFOUND;
     181                 :            :         }
     182                 :            :     }
     183                 :          0 : }
     184                 :            : 
     185                 :            : // -----------------------------------------------------------------------
     186                 :            : 
     187                 :          0 : int SvxLineEndDefTabPage::DeactivatePage( SfxItemSet* _pSet )
     188                 :            : {
     189                 :          0 :     CheckChanges_Impl();
     190                 :            : 
     191         [ #  # ]:          0 :     if( _pSet )
     192                 :          0 :         FillItemSet( *_pSet );
     193                 :            : 
     194                 :          0 :     return( LEAVE_PAGE );
     195                 :            : }
     196                 :            : 
     197                 :            : // -----------------------------------------------------------------------
     198                 :            : 
     199                 :          0 : void SvxLineEndDefTabPage::CheckChanges_Impl()
     200                 :            : {
     201                 :          0 :     sal_uInt16 nPos = aLbLineEnds.GetSelectEntryPos();
     202                 :            : 
     203         [ #  # ]:          0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
     204                 :            :     {
     205         [ #  # ]:          0 :         String aString = aEdtName.GetText();
     206                 :            : 
     207 [ #  # ][ #  # ]:          0 :         if( aString != aLbLineEnds.GetSelectEntry() )
         [ #  # ][ #  # ]
     208                 :            :         {
     209                 :            :             QueryBox aQueryBox( GetParentDialog(), WinBits( WB_YES_NO | WB_DEF_NO ),
     210 [ #  # ][ #  # ]:          0 :                 CUI_RESSTR( RID_SVXSTR_ASK_CHANGE_LINEEND ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     211                 :            : 
     212 [ #  # ][ #  # ]:          0 :             if ( aQueryBox.Execute() == RET_YES )
     213 [ #  # ][ #  # ]:          0 :                 ClickModifyHdl_Impl( this );
     214         [ #  # ]:          0 :         }
     215                 :            :     }
     216                 :          0 :     nPos = aLbLineEnds.GetSelectEntryPos();
     217                 :            : 
     218         [ #  # ]:          0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
     219                 :          0 :         *pPosLineEndLb = nPos;
     220                 :          0 : }
     221                 :            : 
     222                 :            : // -----------------------------------------------------------------------
     223                 :            : 
     224                 :          0 : sal_Bool SvxLineEndDefTabPage::FillItemSet( SfxItemSet& rSet )
     225                 :            : {
     226         [ #  # ]:          0 :     if( *pDlgType == 0 ) // line dialog
     227                 :            :     {
     228         [ #  # ]:          0 :         if( *pPageType == 3 )
     229                 :            :         {
     230                 :          0 :             CheckChanges_Impl();
     231                 :            : 
     232                 :          0 :             long nPos = aLbLineEnds.GetSelectEntryPos();
     233                 :          0 :             XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
     234                 :            : 
     235         [ #  # ]:          0 :             rSet.Put( XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ) );
     236         [ #  # ]:          0 :             rSet.Put( XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ) );
     237                 :            :         }
     238                 :            :     }
     239                 :          0 :     return( sal_True );
     240                 :            : }
     241                 :            : 
     242                 :            : // -----------------------------------------------------------------------
     243                 :            : 
     244                 :          0 : void SvxLineEndDefTabPage::Reset( const SfxItemSet& )
     245                 :            : {
     246                 :          0 :     aLbLineEnds.SelectEntryPos( 0 );
     247                 :            : 
     248                 :            :     // Update lineend
     249         [ #  # ]:          0 :     if( pLineEndList->Count() > 0 )
     250                 :            :     {
     251                 :          0 :         int nPos = aLbLineEnds.GetSelectEntryPos();
     252                 :            : 
     253                 :          0 :         XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
     254                 :            : 
     255         [ #  # ]:          0 :         aEdtName.SetText( aLbLineEnds.GetSelectEntry() );
     256                 :            : 
     257 [ #  # ][ #  # ]:          0 :         rXLSet.Put( XLineStartItem( String(), pEntry->GetLineEnd() ) );
                 [ #  # ]
     258 [ #  # ][ #  # ]:          0 :         rXLSet.Put( XLineEndItem( String(), pEntry->GetLineEnd() ) );
                 [ #  # ]
     259                 :            : 
     260                 :            :         // #i34740#
     261                 :          0 :         aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet());
     262                 :            : 
     263                 :          0 :         aCtlPreview.Invalidate();
     264                 :            :     }
     265                 :            : 
     266                 :            :     // determine button state
     267         [ #  # ]:          0 :     if( pLineEndList->Count() )
     268                 :            :     {
     269                 :          0 :         aBtnModify.Enable();
     270                 :          0 :         aBtnDelete.Enable();
     271                 :          0 :         aBtnSave.Enable();
     272                 :            :     }
     273                 :            :     else
     274                 :            :     {
     275                 :          0 :         aBtnModify.Disable();
     276                 :          0 :         aBtnDelete.Disable();
     277                 :          0 :         aBtnSave.Disable();
     278                 :            :     }
     279                 :          0 : }
     280                 :            : 
     281                 :            : // -----------------------------------------------------------------------
     282                 :            : 
     283                 :          0 : SfxTabPage* SvxLineEndDefTabPage::Create( Window* pWindow,
     284                 :            :                 const SfxItemSet& rSet )
     285                 :            : {
     286         [ #  # ]:          0 :     return( new SvxLineEndDefTabPage( pWindow, rSet ) );
     287                 :            : }
     288                 :            : 
     289                 :            : //------------------------------------------------------------------------
     290                 :            : 
     291                 :          0 : IMPL_LINK_NOARG(SvxLineEndDefTabPage, SelectLineEndHdl_Impl)
     292                 :            : {
     293         [ #  # ]:          0 :     if( pLineEndList->Count() > 0 )
     294                 :            :     {
     295                 :          0 :         int nPos = aLbLineEnds.GetSelectEntryPos();
     296                 :            : 
     297                 :          0 :         XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
     298                 :            : 
     299         [ #  # ]:          0 :         aEdtName.SetText( aLbLineEnds.GetSelectEntry() );
     300                 :            : 
     301 [ #  # ][ #  # ]:          0 :         rXLSet.Put( XLineStartItem( String(), pEntry->GetLineEnd() ) );
                 [ #  # ]
     302 [ #  # ][ #  # ]:          0 :         rXLSet.Put( XLineEndItem( String(), pEntry->GetLineEnd() ) );
                 [ #  # ]
     303                 :            : 
     304                 :            :         // #i34740#
     305                 :          0 :         aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet());
     306                 :            : 
     307                 :          0 :         aCtlPreview.Invalidate();
     308                 :            : 
     309                 :            :         // Is not set before, in order to only take the new style,
     310                 :            :         // if there is an entry selected in the ListBox
     311                 :          0 :         *pPageType = 3;
     312                 :            :     }
     313                 :          0 :     return( 0L );
     314                 :            : }
     315                 :            : 
     316                 :            : //------------------------------------------------------------------------
     317                 :            : 
     318                 :          0 : long SvxLineEndDefTabPage::ChangePreviewHdl_Impl( void* )
     319                 :            : {
     320                 :          0 :     aCtlPreview.Invalidate();
     321                 :          0 :     return( 0L );
     322                 :            : }
     323                 :            : 
     324                 :            : //------------------------------------------------------------------------
     325                 :            : 
     326                 :          0 : IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickModifyHdl_Impl)
     327                 :            : {
     328                 :          0 :     sal_uInt16 nPos = aLbLineEnds.GetSelectEntryPos();
     329                 :            : 
     330         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     331                 :            :     {
     332         [ #  # ]:          0 :         ResMgr& rMgr = CUI_MGR();
     333         [ #  # ]:          0 :         String aDesc( ResId( RID_SVXSTR_DESC_LINEEND, rMgr ) );
     334         [ #  # ]:          0 :         String aName( aEdtName.GetText() );
     335         [ #  # ]:          0 :         long nCount = pLineEndList->Count();
     336                 :          0 :         sal_Bool bDifferent = sal_True;
     337                 :            : 
     338                 :            :         // check whether the name is existing already
     339 [ #  # ][ #  # ]:          0 :         for ( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     340 [ #  # ][ #  # ]:          0 :             if ( aName == pLineEndList->GetLineEnd( i )->GetName() )
                 [ #  # ]
     341                 :          0 :                 bDifferent = sal_False;
     342                 :            : 
     343                 :            :         // if yes, repeat and demand a new name
     344         [ #  # ]:          0 :         if ( !bDifferent )
     345                 :            :         {
     346                 :            :             WarningBox aWarningBox( GetParentDialog(), WinBits( WB_OK ),
     347 [ #  # ][ #  # ]:          0 :                 String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
         [ #  # ][ #  # ]
     348         [ #  # ]:          0 :             aWarningBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
     349         [ #  # ]:          0 :             aWarningBox.Execute();
     350                 :            : 
     351         [ #  # ]:          0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     352                 :            :             DBG_ASSERT(pFact, "Dialogdiet fail!");
     353 [ #  # ][ #  # ]:          0 :             AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc );
     354                 :            :             DBG_ASSERT(pDlg, "Dialogdiet fail!");
     355                 :          0 :             sal_Bool bLoop = sal_True;
     356                 :            : 
     357 [ #  # ][ #  # ]:          0 :             while( !bDifferent && bLoop && pDlg->Execute() == RET_OK )
         [ #  # ][ #  # ]
                 [ #  # ]
     358                 :            :             {
     359         [ #  # ]:          0 :                 pDlg->GetName( aName );
     360                 :          0 :                 bDifferent = sal_True;
     361                 :            : 
     362 [ #  # ][ #  # ]:          0 :                 for( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     363                 :            :                 {
     364 [ #  # ][ #  # ]:          0 :                     if( aName == pLineEndList->GetLineEnd( i )->GetName() )
                 [ #  # ]
     365                 :          0 :                         bDifferent = sal_False;
     366                 :            :                 }
     367                 :            : 
     368         [ #  # ]:          0 :                 if( bDifferent )
     369                 :          0 :                     bLoop = sal_False;
     370                 :            :                 else
     371         [ #  # ]:          0 :                     aWarningBox.Execute();
     372                 :            :             }
     373 [ #  # ][ #  # ]:          0 :             delete( pDlg );
                 [ #  # ]
     374                 :            :         }
     375                 :            : 
     376                 :            :         // if not existing, enter the entry
     377         [ #  # ]:          0 :         if( bDifferent )
     378                 :            :         {
     379         [ #  # ]:          0 :             XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
     380                 :            : 
     381         [ #  # ]:          0 :             pEntry->SetName( aName );
     382         [ #  # ]:          0 :             aEdtName.SetText( aName );
     383                 :            : 
     384 [ #  # ][ #  # ]:          0 :             aLbLineEnds.Modify( pEntry, nPos, pLineEndList->GetBitmap( nPos ) );
     385         [ #  # ]:          0 :             aLbLineEnds.SelectEntryPos( nPos );
     386                 :            : 
     387                 :          0 :             *pnLineEndListState |= CT_MODIFIED;
     388                 :            : 
     389                 :          0 :             *pPageType = 3;
     390 [ #  # ][ #  # ]:          0 :         }
     391                 :            :     }
     392                 :          0 :     return( 0L );
     393                 :            : }
     394                 :            : 
     395                 :            : //------------------------------------------------------------------------
     396                 :            : 
     397                 :          0 : IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl)
     398                 :            : {
     399         [ #  # ]:          0 :     if( pPolyObj )
     400                 :            :     {
     401                 :            :         const SdrObject* pNewObj;
     402                 :          0 :         SdrObject* pConvPolyObj = NULL;
     403                 :            : 
     404 [ #  # ][ #  # ]:          0 :         if( pPolyObj->ISA( SdrPathObj ) )
                 [ #  # ]
     405                 :            :         {
     406                 :          0 :             pNewObj = pPolyObj;
     407                 :            :         }
     408                 :            :         else
     409                 :            :         {
     410         [ #  # ]:          0 :             SdrObjTransformInfoRec aInfoRec;
     411         [ #  # ]:          0 :             pPolyObj->TakeObjInfo( aInfoRec );
     412                 :            : 
     413         [ #  # ]:          0 :             if( aInfoRec.bCanConvToPath )
     414                 :            :             {
     415         [ #  # ]:          0 :                 pNewObj = pConvPolyObj = pPolyObj->ConvertToPolyObj( sal_True, sal_False );
     416                 :            : 
     417 [ #  # ][ #  # ]:          0 :                 if( !pNewObj || !pNewObj->ISA( SdrPathObj ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     418                 :          0 :                     return( 0L ); // cancel, additional safety, which
     419                 :            :                             // has no use for group objects though.
     420                 :            :             }
     421                 :          0 :             else return( 0L ); // cancel
     422                 :            :         }
     423                 :            : 
     424         [ #  # ]:          0 :         basegfx::B2DPolyPolygon aNewPolyPolygon(((SdrPathObj*)pNewObj)->GetPathPoly());
     425         [ #  # ]:          0 :         basegfx::B2DRange aNewRange(basegfx::tools::getRange(aNewPolyPolygon));
     426                 :            : 
     427                 :            :         // normalize
     428                 :            :         aNewPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(
     429 [ #  # ][ #  # ]:          0 :             -aNewRange.getMinX(), -aNewRange.getMinY()));
         [ #  # ][ #  # ]
                 [ #  # ]
     430                 :            : 
     431         [ #  # ]:          0 :         SdrObject::Free( pConvPolyObj );
     432                 :            : 
     433                 :            :         XLineEndEntry* pEntry;
     434                 :            : 
     435         [ #  # ]:          0 :         ResMgr& rMgr = CUI_MGR();
     436 [ #  # ][ #  # ]:          0 :         String aNewName( SVX_RES( RID_SVXSTR_LINEEND ) );
     437         [ #  # ]:          0 :         String aDesc( ResId( RID_SVXSTR_DESC_LINEEND, rMgr ) );
     438         [ #  # ]:          0 :         String aName;
     439                 :            : 
     440         [ #  # ]:          0 :         long nCount = pLineEndList->Count();
     441                 :          0 :         long j = 1;
     442                 :          0 :         sal_Bool bDifferent = sal_False;
     443                 :            : 
     444         [ #  # ]:          0 :         while ( !bDifferent )
     445                 :            :         {
     446         [ #  # ]:          0 :             aName = aNewName;
     447         [ #  # ]:          0 :             aName += sal_Unicode(' ');
     448 [ #  # ][ #  # ]:          0 :             aName += UniString::CreateFromInt32( j++ );
                 [ #  # ]
     449                 :          0 :             bDifferent = sal_True;
     450                 :            : 
     451 [ #  # ][ #  # ]:          0 :             for( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     452 [ #  # ][ #  # ]:          0 :                 if ( aName == pLineEndList->GetLineEnd( i )->GetName() )
                 [ #  # ]
     453                 :          0 :                     bDifferent = sal_False;
     454                 :            :         }
     455                 :            : 
     456         [ #  # ]:          0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     457                 :            :         DBG_ASSERT(pFact, "Dialogdiet fail!");
     458 [ #  # ][ #  # ]:          0 :         AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc );
     459                 :            :         DBG_ASSERT(pDlg, "Dialogdiet fail!");
     460                 :          0 :         sal_Bool bLoop = sal_True;
     461                 :            : 
     462 [ #  # ][ #  # ]:          0 :         while ( bLoop && pDlg->Execute() == RET_OK )
         [ #  # ][ #  # ]
     463                 :            :         {
     464         [ #  # ]:          0 :             pDlg->GetName( aName );
     465                 :          0 :             bDifferent = sal_True;
     466                 :            : 
     467 [ #  # ][ #  # ]:          0 :             for( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     468                 :            :             {
     469 [ #  # ][ #  # ]:          0 :                 if( aName == pLineEndList->GetLineEnd( i )->GetName() )
                 [ #  # ]
     470                 :          0 :                     bDifferent = sal_False;
     471                 :            :             }
     472                 :            : 
     473         [ #  # ]:          0 :             if( bDifferent )
     474                 :            :             {
     475                 :          0 :                 bLoop = sal_False;
     476 [ #  # ][ #  # ]:          0 :                 pEntry = new XLineEndEntry( aNewPolyPolygon, aName );
     477                 :            : 
     478         [ #  # ]:          0 :                 long nLineEndCount = pLineEndList->Count();
     479         [ #  # ]:          0 :                 pLineEndList->Insert( pEntry, nLineEndCount );
     480         [ #  # ]:          0 :                 Bitmap* pBitmap = pLineEndList->GetBitmap( nLineEndCount );
     481                 :            : 
     482                 :            :                 // add to the ListBox
     483         [ #  # ]:          0 :                 aLbLineEnds.Append( pEntry, pBitmap );
     484 [ #  # ][ #  # ]:          0 :                 aLbLineEnds.SelectEntryPos( aLbLineEnds.GetEntryCount() - 1 );
     485                 :            : 
     486                 :          0 :                 *pnLineEndListState |= CT_MODIFIED;
     487                 :            : 
     488         [ #  # ]:          0 :                 SelectLineEndHdl_Impl( this );
     489                 :            :             }
     490                 :            :             else
     491                 :            :             {
     492 [ #  # ][ #  # ]:          0 :                 WarningBox aBox( GetParentDialog(), WinBits( WB_OK ),String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
         [ #  # ][ #  # ]
     493         [ #  # ]:          0 :                 aBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
     494 [ #  # ][ #  # ]:          0 :                 aBox.Execute();
     495                 :            :             }
     496                 :            :         }
     497 [ #  # ][ #  # ]:          0 :         delete pDlg;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     498                 :            :     }
     499                 :            :     else
     500                 :          0 :         aBtnAdd.Disable();
     501                 :            : 
     502                 :            :     // determine button state
     503         [ #  # ]:          0 :     if ( pLineEndList->Count() )
     504                 :            :     {
     505                 :          0 :         aBtnModify.Enable();
     506                 :          0 :         aBtnDelete.Enable();
     507                 :          0 :         aBtnSave.Enable();
     508                 :            :     }
     509                 :          0 :     return( 0L );
     510                 :            : }
     511                 :            : 
     512                 :            : //------------------------------------------------------------------------
     513                 :            : 
     514                 :          0 : IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickDeleteHdl_Impl)
     515                 :            : {
     516                 :          0 :     sal_uInt16 nPos = aLbLineEnds.GetSelectEntryPos();
     517                 :            : 
     518         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     519                 :            :     {
     520                 :            :         QueryBox aQueryBox( GetParentDialog(), WinBits( WB_YES_NO | WB_DEF_NO ),
     521 [ #  # ][ #  # ]:          0 :             String( CUI_RES( RID_SVXSTR_ASK_DEL_LINEEND ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     522                 :            : 
     523 [ #  # ][ #  # ]:          0 :         if ( aQueryBox.Execute() == RET_YES )
     524                 :            :         {
     525 [ #  # ][ #  # ]:          0 :             delete pLineEndList->Remove( nPos );
                 [ #  # ]
     526         [ #  # ]:          0 :             aLbLineEnds.RemoveEntry( nPos );
     527         [ #  # ]:          0 :             aLbLineEnds.SelectEntryPos( 0 );
     528                 :            : 
     529         [ #  # ]:          0 :             SelectLineEndHdl_Impl( this );
     530                 :          0 :             *pPageType = 0; // LineEnd shall not be taken over
     531                 :            : 
     532                 :          0 :             *pnLineEndListState |= CT_MODIFIED;
     533                 :            : 
     534         [ #  # ]:          0 :             ChangePreviewHdl_Impl( this );
     535         [ #  # ]:          0 :         }
     536                 :            :     }
     537                 :            :     // determine button state
     538         [ #  # ]:          0 :     if( !pLineEndList->Count() )
     539                 :            :     {
     540                 :          0 :         aBtnModify.Disable();
     541                 :          0 :         aBtnDelete.Disable();
     542                 :          0 :         aBtnSave.Disable();
     543                 :            :     }
     544                 :          0 :     return( 0L );
     545                 :            : }
     546                 :            : 
     547                 :            : //------------------------------------------------------------------------
     548                 :            : 
     549                 :          0 : IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickLoadHdl_Impl)
     550                 :            : {
     551                 :          0 :     ResMgr& rMgr = CUI_MGR();
     552                 :          0 :     sal_uInt16 nReturn = RET_YES;
     553                 :            : 
     554         [ #  # ]:          0 :     if ( *pnLineEndListState & CT_MODIFIED )
     555                 :            :     {
     556                 :            :         nReturn = WarningBox( GetParentDialog(), WinBits( WB_YES_NO_CANCEL ),
     557 [ #  # ][ #  # ]:          0 :             String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     558                 :            : 
     559         [ #  # ]:          0 :         if ( nReturn == RET_YES )
     560                 :          0 :             pLineEndList->Save();
     561                 :            :     }
     562                 :            : 
     563         [ #  # ]:          0 :     if ( nReturn != RET_CANCEL )
     564                 :            :     {
     565                 :            :         ::sfx2::FileDialogHelper aDlg(
     566                 :            :             com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
     567         [ #  # ]:          0 :             0 );
     568         [ #  # ]:          0 :         String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soe" ) );
     569         [ #  # ]:          0 :         aDlg.AddFilter( aStrFilterType, aStrFilterType );
     570 [ #  # ][ #  # ]:          0 :         INetURLObject aFile( SvtPathOptions().GetPalettePath() );
         [ #  # ][ #  # ]
                 [ #  # ]
     571 [ #  # ][ #  # ]:          0 :         aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
     572                 :            : 
     573 [ #  # ][ #  # ]:          0 :         if( aDlg.Execute() == ERRCODE_NONE )
     574                 :            :         {
     575 [ #  # ][ #  # ]:          0 :             INetURLObject aURL( aDlg.GetPath() );
         [ #  # ][ #  # ]
     576         [ #  # ]:          0 :             INetURLObject aPathURL( aURL );
     577                 :            : 
     578         [ #  # ]:          0 :             aPathURL.removeSegment();
     579         [ #  # ]:          0 :             aPathURL.removeFinalSlash();
     580                 :            : 
     581                 :            :             XLineEndListRef pLeList = XPropertyList::CreatePropertyList(
     582 [ #  # ][ #  # ]:          0 :                 XLINE_END_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), pXPool )->AsLineEndList();
         [ #  # ][ #  # ]
                 [ #  # ]
     583 [ #  # ][ #  # ]:          0 :             pLeList->SetName( aURL.getName() );
         [ #  # ][ #  # ]
     584 [ #  # ][ #  # ]:          0 :             if( pLeList->Load() )
     585                 :            :             {
     586         [ #  # ]:          0 :                 pLineEndList = pLeList;
     587 [ #  # ][ #  # ]:          0 :                 ( (SvxLineTabDialog*) GetParentDialog() )->SetNewLineEndList( pLineEndList );
     588         [ #  # ]:          0 :                 aLbLineEnds.Clear();
     589         [ #  # ]:          0 :                 aLbLineEnds.Fill( pLineEndList );
     590         [ #  # ]:          0 :                 Reset( rOutAttrs );
     591                 :            : 
     592 [ #  # ][ #  # ]:          0 :                 pLineEndList->SetName( aURL.getName() );
         [ #  # ][ #  # ]
     593                 :            : 
     594                 :          0 :                 *pnLineEndListState |= CT_CHANGED;
     595                 :          0 :                 *pnLineEndListState &= ~CT_MODIFIED;
     596                 :            :             }
     597                 :            :             else
     598                 :            :                 ErrorBox( GetParentDialog(), WinBits( WB_OK ),
     599 [ #  # ][ #  # ]:          0 :                     String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     600 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     601                 :            :     }
     602                 :            : 
     603                 :            :     // determine button state
     604         [ #  # ]:          0 :     if ( pLineEndList->Count() )
     605                 :            :     {
     606                 :          0 :         aBtnModify.Enable();
     607                 :          0 :         aBtnDelete.Enable();
     608                 :          0 :         aBtnSave.Enable();
     609                 :            :     }
     610                 :            :     else
     611                 :            :     {
     612                 :          0 :         aBtnModify.Disable();
     613                 :          0 :         aBtnDelete.Disable();
     614                 :          0 :         aBtnSave.Disable();
     615                 :            :     }
     616                 :          0 :     return( 0L );
     617                 :            : }
     618                 :            : 
     619                 :            : //------------------------------------------------------------------------
     620                 :            : 
     621                 :          0 : IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickSaveHdl_Impl)
     622                 :            : {
     623                 :            :     ::sfx2::FileDialogHelper aDlg(
     624         [ #  # ]:          0 :         com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
     625         [ #  # ]:          0 :     String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soe" ) );
     626         [ #  # ]:          0 :     aDlg.AddFilter( aStrFilterType, aStrFilterType );
     627                 :            : 
     628 [ #  # ][ #  # ]:          0 :     INetURLObject aFile( SvtPathOptions().GetPalettePath() );
         [ #  # ][ #  # ]
                 [ #  # ]
     629                 :            :     DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     630                 :            : 
     631         [ #  # ]:          0 :     if( pLineEndList->GetName().Len() )
     632                 :            :     {
     633 [ #  # ][ #  # ]:          0 :         aFile.Append( pLineEndList->GetName() );
     634                 :            : 
     635 [ #  # ][ #  # ]:          0 :         if( aFile.getExtension().isEmpty() )
     636         [ #  # ]:          0 :             aFile.SetExtension(rtl::OUString("soe"));
     637                 :            :     }
     638                 :            : 
     639 [ #  # ][ #  # ]:          0 :     aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
     640 [ #  # ][ #  # ]:          0 :     if ( aDlg.Execute() == ERRCODE_NONE )
     641                 :            :     {
     642 [ #  # ][ #  # ]:          0 :         INetURLObject   aURL( aDlg.GetPath() );
         [ #  # ][ #  # ]
     643         [ #  # ]:          0 :         INetURLObject   aPathURL( aURL );
     644                 :            : 
     645         [ #  # ]:          0 :         aPathURL.removeSegment();
     646         [ #  # ]:          0 :         aPathURL.removeFinalSlash();
     647                 :            : 
     648 [ #  # ][ #  # ]:          0 :         pLineEndList->SetName( aURL.getName() );
         [ #  # ][ #  # ]
     649 [ #  # ][ #  # ]:          0 :         pLineEndList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
     650                 :            : 
     651 [ #  # ][ #  # ]:          0 :         if( pLineEndList->Save() )
     652                 :            :         {
     653                 :          0 :             *pnLineEndListState |= CT_SAVED;
     654                 :          0 :             *pnLineEndListState &= ~CT_MODIFIED;
     655                 :            :         }
     656                 :            :         else
     657                 :            :         {
     658                 :            :             ErrorBox( GetParentDialog(), WinBits( WB_OK ),
     659 [ #  # ][ #  # ]:          0 :                 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     660 [ #  # ][ #  # ]:          0 :         }
     661                 :            :     }
     662 [ #  # ][ #  # ]:          0 :     return( 0L );
                 [ #  # ]
     663                 :            : }
     664                 :            : 
     665                 :          0 : void SvxLineEndDefTabPage::DataChanged( const DataChangedEvent& rDCEvt )
     666                 :            : {
     667                 :          0 :     SfxTabPage::DataChanged( rDCEvt );
     668                 :            : 
     669 [ #  # ][ #  # ]:          0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
                 [ #  # ]
     670                 :            :     {
     671                 :          0 :         sal_uInt16 nOldSelect = aLbLineEnds.GetSelectEntryPos();
     672                 :          0 :         aLbLineEnds.Clear();
     673                 :          0 :         aLbLineEnds.Fill( pLineEndList );
     674                 :          0 :         aLbLineEnds.SelectEntryPos( nOldSelect );
     675                 :            :     }
     676                 :          0 : }
     677                 :            : 
     678                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10