LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - dlgfield.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 173 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 12 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 <editeng/editeng.hxx>
      21             : #include <editeng/eeitem.hxx>
      22             : #include <editeng/flditem.hxx>
      23             : #include <svl/zforlist.hxx>
      24             : #include <sfx2/objsh.hxx>
      25             : #include <sfx2/docfile.hxx>
      26             : #include <svl/itemset.hxx>
      27             : #include <editeng/langitem.hxx>
      28             : #include <unotools/useroptions.hxx>
      29             : 
      30             : #include "strings.hrc"
      31             : #include "sdattr.hxx"
      32             : #include "sdresid.hxx"
      33             : #include "sdmod.hxx"
      34             : #include "dlgfield.hxx"
      35             : #include "drawdoc.hxx"
      36             : #include "DrawDocShell.hxx"
      37             : 
      38             : /**
      39             :  * dialog to edit field commands
      40             :  */
      41           0 : SdModifyFieldDlg::SdModifyFieldDlg( vcl::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet ) :
      42             :     ModalDialog ( pWindow, "EditFieldsDialog", "modules/simpress/ui/dlgfield.ui" ),
      43             :     maInputSet  ( rSet ),
      44           0 :     pField      ( pInField )
      45             : {
      46           0 :     get(m_pRbtFix, "fixedRB");
      47           0 :     get(m_pRbtVar, "varRB");
      48           0 :     get(m_pLbLanguage, "languageLB");
      49           0 :     get(m_pLbFormat, "formatLB");
      50             : 
      51           0 :     m_pLbLanguage->SetLanguageList( SvxLanguageListFlags::ALL|SvxLanguageListFlags::ONLY_KNOWN, false );
      52           0 :     m_pLbLanguage->SetSelectHdl( LINK( this, SdModifyFieldDlg, LanguageChangeHdl ) );
      53           0 :     FillControls();
      54           0 : }
      55             : 
      56           0 : SdModifyFieldDlg::~SdModifyFieldDlg()
      57             : {
      58           0 :     disposeOnce();
      59           0 : }
      60             : 
      61           0 : void SdModifyFieldDlg::dispose()
      62             : {
      63           0 :     m_pRbtFix.clear();
      64           0 :     m_pRbtVar.clear();
      65           0 :     m_pLbLanguage.clear();
      66           0 :     m_pLbFormat.clear();
      67           0 :     ModalDialog::dispose();
      68           0 : }
      69             : 
      70             : 
      71             : /**
      72             :  * Returns the new field, owned by caller.
      73             :  * Returns NULL if nothing has changed.
      74             :  */
      75           0 : SvxFieldData* SdModifyFieldDlg::GetField()
      76             : {
      77           0 :     SvxFieldData* pNewField = NULL;
      78             : 
      79           0 :     if( m_pRbtFix->IsValueChangedFromSaved() ||
      80           0 :         m_pRbtVar->IsValueChangedFromSaved() ||
      81           0 :         m_pLbFormat->IsValueChangedFromSaved() )
      82             :     {
      83           0 :         if( pField->ISA( SvxDateField ) )
      84             :         {
      85           0 :             const SvxDateField* pDateField = static_cast<const SvxDateField*>(pField);
      86             :             SvxDateType   eType;
      87             :             SvxDateFormat eFormat;
      88             : 
      89           0 :             if( m_pRbtFix->IsChecked() )
      90           0 :                 eType = SVXDATETYPE_FIX;
      91             :             else
      92           0 :                 eType = SVXDATETYPE_VAR;
      93             : 
      94           0 :             eFormat = (SvxDateFormat) ( m_pLbFormat->GetSelectEntryPos() + 2 );
      95             : 
      96           0 :             pNewField = new SvxDateField( *pDateField );
      97           0 :             static_cast<SvxDateField*>( pNewField )->SetType( eType );
      98           0 :             static_cast<SvxDateField*>( pNewField )->SetFormat( eFormat );
      99             :         }
     100           0 :         else if( pField->ISA( SvxExtTimeField ) )
     101             :         {
     102           0 :             const SvxExtTimeField* pTimeField = static_cast<const SvxExtTimeField*>( pField );
     103             :             SvxTimeType   eType;
     104             :             SvxTimeFormat eFormat;
     105             : 
     106           0 :             if( m_pRbtFix->IsChecked() )
     107           0 :                 eType = SVXTIMETYPE_FIX;
     108             :             else
     109           0 :                 eType = SVXTIMETYPE_VAR;
     110             : 
     111           0 :             eFormat = (SvxTimeFormat) ( m_pLbFormat->GetSelectEntryPos() + 2 );
     112             : 
     113           0 :             pNewField = new SvxExtTimeField( *pTimeField );
     114           0 :             static_cast<SvxExtTimeField*>( pNewField )->SetType( eType );
     115           0 :             static_cast<SvxExtTimeField*>( pNewField )->SetFormat( eFormat );
     116             :         }
     117           0 :         else if( pField->ISA( SvxExtFileField ) )
     118             :         {
     119           0 :             const SvxExtFileField* pFileField = static_cast<const SvxExtFileField*>( pField );
     120             :             SvxFileType   eType;
     121             :             SvxFileFormat eFormat;
     122             : 
     123           0 :             if( m_pRbtFix->IsChecked() )
     124           0 :                 eType = SVXFILETYPE_FIX;
     125             :             else
     126           0 :                 eType = SVXFILETYPE_VAR;
     127             : 
     128           0 :             eFormat = (SvxFileFormat) ( m_pLbFormat->GetSelectEntryPos() );
     129             : 
     130           0 :             ::sd::DrawDocShell* pDocSh = PTR_CAST( ::sd::DrawDocShell,
     131             :                                                SfxObjectShell::Current() );
     132             : 
     133           0 :             if( pDocSh )
     134             :             {
     135           0 :                 SvxExtFileField aFileField( *pFileField );
     136             : 
     137           0 :                 OUString aName;
     138           0 :                 if( pDocSh->HasName() )
     139           0 :                     aName = pDocSh->GetMedium()->GetName();
     140             : 
     141             :                 // Get current filename, not the one stored in the old field
     142           0 :                 pNewField = new SvxExtFileField( aName );
     143           0 :                 static_cast<SvxExtFileField*>( pNewField )->SetType( eType );
     144           0 :                 static_cast<SvxExtFileField*>( pNewField )->SetFormat( eFormat );
     145             :             }
     146             :         }
     147           0 :         else if( pField->ISA( SvxAuthorField ) )
     148             :         {
     149             :             SvxAuthorType   eType;
     150             :             SvxAuthorFormat eFormat;
     151             : 
     152           0 :             if( m_pRbtFix->IsChecked() )
     153           0 :                 eType = SVXAUTHORTYPE_FIX;
     154             :             else
     155           0 :                 eType = SVXAUTHORTYPE_VAR;
     156             : 
     157           0 :             eFormat = (SvxAuthorFormat) ( m_pLbFormat->GetSelectEntryPos() );
     158             : 
     159             :             // Get current state of address, not the old one
     160           0 :             SvtUserOptions aUserOptions;
     161           0 :             pNewField = new SvxAuthorField( aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() );
     162           0 :             static_cast<SvxAuthorField*>( pNewField )->SetType( eType );
     163           0 :             static_cast<SvxAuthorField*>( pNewField )->SetFormat( eFormat );
     164             :         }
     165             :     }
     166             : 
     167           0 :     return pNewField;
     168             : }
     169             : 
     170           0 : void SdModifyFieldDlg::FillFormatList()
     171             : {
     172           0 :     LanguageType eLangType = m_pLbLanguage->GetSelectLanguage();
     173             : 
     174           0 :     m_pLbFormat->Clear();
     175             : 
     176           0 :     if( pField->ISA( SvxDateField ) )
     177             :     {
     178           0 :         const SvxDateField* pDateField = static_cast<const SvxDateField*>( pField );
     179           0 :         SvxDateField aDateField( *pDateField );
     180             : 
     181             :         //SVXDATEFORMAT_APPDEFAULT,     // not used
     182             :         //SVXDATEFORMAT_SYSTEM,         // not used
     183           0 :         m_pLbFormat->InsertEntry( SD_RESSTR( STR_STANDARD_SMALL ) );
     184           0 :         m_pLbFormat->InsertEntry( SD_RESSTR( STR_STANDARD_BIG ) );
     185             : 
     186           0 :         SvNumberFormatter* pNumberFormatter = SD_MOD()->GetNumberFormatter();
     187           0 :         aDateField.SetFormat( SVXDATEFORMAT_A );    // 13.02.96
     188           0 :         m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
     189           0 :         aDateField.SetFormat( SVXDATEFORMAT_B );    // 13.02.1996
     190           0 :         m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
     191           0 :         aDateField.SetFormat( SVXDATEFORMAT_C );    // 13.Feb 1996
     192           0 :         m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
     193           0 :         aDateField.SetFormat( SVXDATEFORMAT_D );    // 13.Februar 1996
     194           0 :         m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
     195           0 :         aDateField.SetFormat( SVXDATEFORMAT_E );    // Die, 13.Februar 1996
     196           0 :         m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
     197           0 :         aDateField.SetFormat( SVXDATEFORMAT_F );    // Dienstag, 13.Februar 1996
     198           0 :         m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
     199             : 
     200           0 :         m_pLbFormat->SelectEntryPos( (sal_uInt16) ( pDateField->GetFormat() - 2 ) );
     201             :     }
     202           0 :     else if( pField->ISA( SvxExtTimeField ) )
     203             :     {
     204           0 :         const SvxExtTimeField* pTimeField = static_cast<const SvxExtTimeField*>( pField );
     205           0 :         SvxExtTimeField aTimeField( *pTimeField );
     206             : 
     207             :         //SVXTIMEFORMAT_APPDEFAULT,     // not used
     208             :         //SVXTIMEFORMAT_SYSTEM,         // not used
     209           0 :         m_pLbFormat->InsertEntry( SD_RESSTR( STR_STANDARD_NORMAL ) );
     210             : 
     211           0 :         SvNumberFormatter* pNumberFormatter = SD_MOD()->GetNumberFormatter();
     212           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_24_HM );    // 13:49
     213           0 :         m_pLbFormat->InsertEntry( aTimeField.GetFormatted( *pNumberFormatter, eLangType ) );
     214           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_24_HMS );   // 13:49:38
     215           0 :         m_pLbFormat->InsertEntry( aTimeField.GetFormatted( *pNumberFormatter, eLangType ) );
     216           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_24_HMSH );  // 13:49:38.78
     217           0 :         m_pLbFormat->InsertEntry( aTimeField.GetFormatted( *pNumberFormatter, eLangType ) );
     218           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_12_HM );    // 01:49
     219           0 :         m_pLbFormat->InsertEntry( aTimeField.GetFormatted( *pNumberFormatter, eLangType ) );
     220           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_12_HMS );   // 01:49:38
     221           0 :         m_pLbFormat->InsertEntry( aTimeField.GetFormatted( *pNumberFormatter, eLangType ) );
     222           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_12_HMSH );  // 01:49:38.78
     223           0 :         m_pLbFormat->InsertEntry( aTimeField.GetFormatted( *pNumberFormatter, eLangType ) );
     224             :         //SVXTIMEFORMAT_AM_HM,  // 01:49 PM
     225             :         //SVXTIMEFORMAT_AM_HMS, // 01:49:38 PM
     226             :         //SVXTIMEFORMAT_AM_HMSH // 01:49:38.78 PM
     227             : 
     228           0 :         m_pLbFormat->SelectEntryPos( (sal_uInt16) ( pTimeField->GetFormat() - 2 ) );
     229             :     }
     230           0 :     else if( pField->ISA( SvxExtFileField ) )
     231             :     {
     232           0 :         const SvxExtFileField* pFileField = static_cast<const SvxExtFileField*>( pField );
     233           0 :         SvxExtFileField aFileField( *pFileField );
     234             : 
     235           0 :         m_pLbFormat->InsertEntry( SD_RESSTR( STR_FILEFORMAT_NAME_EXT ) );
     236           0 :         m_pLbFormat->InsertEntry( SD_RESSTR( STR_FILEFORMAT_FULLPATH ) );
     237           0 :         m_pLbFormat->InsertEntry( SD_RESSTR( STR_FILEFORMAT_PATH ) );
     238           0 :         m_pLbFormat->InsertEntry( SD_RESSTR( STR_FILEFORMAT_NAME ) );
     239             : 
     240           0 :         m_pLbFormat->SelectEntryPos( (sal_uInt16) ( pFileField->GetFormat() ) );
     241             :     }
     242           0 :     else if( pField->ISA( SvxAuthorField ) )
     243             :     {
     244           0 :         const SvxAuthorField* pAuthorField = static_cast<const SvxAuthorField*>( pField );
     245           0 :         SvxAuthorField aAuthorField( *pAuthorField );
     246             : 
     247           0 :         for( sal_uInt16 i = 0; i < 4; i++ )
     248             :         {
     249           0 :             aAuthorField.SetFormat( (SvxAuthorFormat) i );
     250           0 :             m_pLbFormat->InsertEntry( aAuthorField.GetFormatted() );
     251             :         }
     252             : 
     253           0 :         m_pLbFormat->SelectEntryPos( (sal_uInt16) ( pAuthorField->GetFormat() ) );
     254             : 
     255             :     }
     256             : 
     257           0 : }
     258             : 
     259           0 : void SdModifyFieldDlg::FillControls()
     260             : {
     261           0 :     m_pLbFormat->Clear();
     262             : 
     263           0 :     if( pField->ISA( SvxDateField ) )
     264             :     {
     265           0 :         const SvxDateField* pDateField = static_cast<const SvxDateField*>(pField);
     266           0 :         SvxDateField aDateField( *pDateField );
     267             : 
     268           0 :         if( pDateField->GetType() == SVXDATETYPE_FIX )
     269           0 :             m_pRbtFix->Check();
     270             :         else
     271           0 :             m_pRbtVar->Check();
     272             :     }
     273           0 :     else if( pField->ISA( SvxExtTimeField ) )
     274             :     {
     275           0 :         const SvxExtTimeField* pTimeField = static_cast<const SvxExtTimeField*>(pField);
     276           0 :         SvxExtTimeField aTimeField( *pTimeField );
     277             : 
     278           0 :         if( pTimeField->GetType() == SVXTIMETYPE_FIX )
     279           0 :             m_pRbtFix->Check();
     280             :         else
     281           0 :             m_pRbtVar->Check();
     282             :     }
     283           0 :     else if( pField->ISA( SvxExtFileField ) )
     284             :     {
     285           0 :         const SvxExtFileField* pFileField = static_cast<const SvxExtFileField*>(pField);
     286           0 :         SvxExtFileField aFileField( *pFileField );
     287             : 
     288           0 :         if( pFileField->GetType() == SVXFILETYPE_FIX )
     289           0 :             m_pRbtFix->Check();
     290             :         else
     291           0 :             m_pRbtVar->Check();
     292             :     }
     293           0 :     else if( pField->ISA( SvxAuthorField ) )
     294             :     {
     295           0 :         const SvxAuthorField* pAuthorField = static_cast<const SvxAuthorField*>(pField);
     296           0 :         SvxAuthorField aAuthorField( *pAuthorField );
     297             : 
     298           0 :         if( pAuthorField->GetType() == SVXAUTHORTYPE_FIX )
     299           0 :             m_pRbtFix->Check();
     300             :         else
     301           0 :             m_pRbtVar->Check();
     302             :     }
     303           0 :     m_pRbtFix->SaveValue();
     304           0 :     m_pRbtVar->SaveValue();
     305             : 
     306             :     const SfxPoolItem* pItem;
     307           0 :     if( SfxItemState::SET == maInputSet.GetItemState(EE_CHAR_LANGUAGE, true, &pItem ) )
     308           0 :         m_pLbLanguage->SelectLanguage( static_cast<const SvxLanguageItem*>(pItem)->GetLanguage() );
     309             : 
     310           0 :     m_pLbLanguage->SaveValue();
     311             : 
     312           0 :     FillFormatList();
     313           0 :     m_pLbFormat->SaveValue();
     314           0 : }
     315             : 
     316           0 : IMPL_LINK_NOARG(SdModifyFieldDlg, LanguageChangeHdl)
     317             : {
     318           0 :     FillFormatList();
     319             : 
     320           0 :     return 0L;
     321             : }
     322             : 
     323           0 : SfxItemSet SdModifyFieldDlg::GetItemSet()
     324             : {
     325           0 :     SfxItemSet aOutput( *maInputSet.GetPool(), EE_CHAR_LANGUAGE, EE_CHAR_LANGUAGE_CTL );
     326             : 
     327           0 :     if( m_pLbLanguage->IsValueChangedFromSaved() )
     328             :     {
     329           0 :         LanguageType eLangType = m_pLbLanguage->GetSelectLanguage();
     330           0 :         SvxLanguageItem aItem( eLangType, EE_CHAR_LANGUAGE );
     331           0 :         aOutput.Put( aItem );
     332             : 
     333           0 :         SvxLanguageItem aItemCJK( eLangType, EE_CHAR_LANGUAGE_CJK );
     334           0 :         aOutput.Put( aItemCJK );
     335             : 
     336           0 :         SvxLanguageItem aItemCTL( eLangType, EE_CHAR_LANGUAGE_CTL );
     337           0 :         aOutput.Put( aItemCTL );
     338             :     }
     339             : 
     340           0 :     return aOutput;
     341           0 : }
     342             : 
     343             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11