LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/cui/source/tabpages - tplneend.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 316 0.0 %
Date: 2013-07-09 Functions: 0 26 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10