LCOV - code coverage report
Current view: top level - libreoffice/cui/source/tabpages - tplneend.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 317 0.3 %
Date: 2012-12-17 Functions: 2 26 7.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10