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

Generated by: LCOV version 1.10