LCOV - code coverage report
Current view: top level - sd/source/ui/app - sdpopup.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 149 0.0 %
Date: 2014-04-14 Functions: 0 5 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/eeitem.hxx>
      21             : 
      22             : #include <editeng/editeng.hxx>
      23             : #include <editeng/flditem.hxx>
      24             : #include <svl/zforlist.hxx>
      25             : #include <sfx2/objsh.hxx>
      26             : #include <sfx2/docfile.hxx>
      27             : #include <unotools/useroptions.hxx>
      28             : 
      29             : #include "strings.hrc"
      30             : #include "sdpopup.hxx"
      31             : #include "sdresid.hxx"
      32             : #include "sdmod.hxx"
      33             : #include "drawdoc.hxx"
      34             : #include "DrawDocShell.hxx"
      35             : 
      36             : /*
      37             :  * Popup menu for editing of field command
      38             :  */
      39           0 : SdFieldPopup::SdFieldPopup( const SvxFieldData* pInField, LanguageType eLanguage ) :
      40             :         PopupMenu   (),
      41           0 :         pField      ( pInField )
      42             : {
      43           0 :     Fill( eLanguage );
      44           0 : }
      45             : 
      46           0 : SdFieldPopup::~SdFieldPopup()
      47             : {
      48           0 : }
      49             : 
      50           0 : void SdFieldPopup::Fill( LanguageType eLanguage )
      51             : {
      52           0 :     sal_uInt16 nID = 1;
      53           0 :     sal_uInt16 nStyle = MIB_RADIOCHECK | MIB_AUTOCHECK;
      54           0 :     InsertItem( nID++, SD_RESSTR( STR_FIX ), nStyle );
      55           0 :     InsertItem( nID++, SD_RESSTR( STR_VAR ), nStyle );
      56           0 :     InsertSeparator();
      57             : 
      58           0 :     if( pField->ISA( SvxDateField ) )
      59             :     {
      60           0 :         const SvxDateField* pDateField = (const SvxDateField*) pField;
      61           0 :         SvxDateField aDateField( *pDateField );
      62             : 
      63           0 :         if( pDateField->GetType() == SVXDATETYPE_FIX )
      64           0 :             CheckItem( 1 );
      65             :         else
      66           0 :             CheckItem( 2 );
      67             : 
      68             :         //SVXDATEFORMAT_APPDEFAULT,     // is not used
      69             :         //SVXDATEFORMAT_SYSTEM,         // is not used
      70           0 :         InsertItem( nID++, SD_RESSTR( STR_STANDARD_SMALL ), nStyle );
      71           0 :         InsertItem( nID++, SD_RESSTR( STR_STANDARD_BIG ), nStyle );
      72             : 
      73           0 :         SvNumberFormatter* pNumberFormatter = SD_MOD()->GetNumberFormatter();
      74           0 :         aDateField.SetFormat( SVXDATEFORMAT_A );    // 13.02.96
      75           0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
      76           0 :         aDateField.SetFormat( SVXDATEFORMAT_B );    // 13.02.1996
      77           0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
      78           0 :         aDateField.SetFormat( SVXDATEFORMAT_C );    // 13.Feb 1996
      79           0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
      80             : 
      81           0 :         aDateField.SetFormat( SVXDATEFORMAT_D );    // 13.Februar 1996
      82           0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
      83           0 :         aDateField.SetFormat( SVXDATEFORMAT_E );    // Die, 13.Februar 1996
      84           0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
      85           0 :         aDateField.SetFormat( SVXDATEFORMAT_F );    // Dienstag, 13.Februar 1996
      86           0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
      87             : 
      88           0 :         CheckItem( (sal_uInt16) ( pDateField->GetFormat() ) + 1 ); // - 2 + 3 !
      89             :     }
      90           0 :     else if( pField->ISA( SvxExtTimeField ) )
      91             :     {
      92           0 :         const SvxExtTimeField* pTimeField = (const SvxExtTimeField*) pField;
      93           0 :         SvxExtTimeField aTimeField( *pTimeField );
      94             : 
      95           0 :         if( pTimeField->GetType() == SVXTIMETYPE_FIX )
      96           0 :             CheckItem( 1 );
      97             :         else
      98           0 :             CheckItem( 2 );
      99             : 
     100             :         //SVXTIMEFORMAT_APPDEFAULT,     // is not used
     101             :         //SVXTIMEFORMAT_SYSTEM,         // is not used
     102           0 :         InsertItem( nID++, SD_RESSTR( STR_STANDARD_NORMAL ), nStyle );
     103             : 
     104           0 :         SvNumberFormatter* pNumberFormatter = SD_MOD()->GetNumberFormatter();
     105           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_24_HM );    // 13:49
     106           0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
     107           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_24_HMS );   // 13:49:38
     108           0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
     109           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_24_HMSH );  // 13:49:38.78
     110           0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
     111             : 
     112           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_12_HM );    // 01:49
     113           0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
     114           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_12_HMS );   // 01:49:38
     115           0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
     116           0 :         aTimeField.SetFormat( SVXTIMEFORMAT_12_HMSH );  // 01:49:38.78
     117           0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
     118             :         //SVXTIMEFORMAT_AM_HM,  // 01:49 PM
     119             :         //SVXTIMEFORMAT_AM_HMS, // 01:49:38 PM
     120             :         //SVXTIMEFORMAT_AM_HMSH // 01:49:38.78 PM
     121             : 
     122           0 :         CheckItem( (sal_uInt16) ( pTimeField->GetFormat() ) + 1 ); // - 2 + 3 !
     123             :     }
     124           0 :     else if( pField->ISA( SvxExtFileField ) )
     125             :     {
     126           0 :         const SvxExtFileField* pFileField = (const SvxExtFileField*) pField;
     127             :         //SvxExtFileField aFileField( *pFileField );
     128             : 
     129           0 :         if( pFileField->GetType() == SVXFILETYPE_FIX )
     130           0 :             CheckItem( 1 );
     131             :         else
     132           0 :             CheckItem( 2 );
     133             : 
     134           0 :         InsertItem( nID++, SD_RESSTR( STR_FILEFORMAT_NAME_EXT ), nStyle );
     135           0 :         InsertItem( nID++, SD_RESSTR( STR_FILEFORMAT_FULLPATH ), nStyle );
     136           0 :         InsertItem( nID++, SD_RESSTR( STR_FILEFORMAT_PATH ), nStyle );
     137           0 :         InsertItem( nID++, SD_RESSTR( STR_FILEFORMAT_NAME ), nStyle );
     138             : 
     139           0 :         CheckItem( (sal_uInt16) ( pFileField->GetFormat() ) + 3 );
     140             :     }
     141           0 :     else if( pField->ISA( SvxAuthorField ) )
     142             :     {
     143           0 :         const SvxAuthorField* pAuthorField = (const SvxAuthorField*) pField;
     144           0 :         SvxAuthorField aAuthorField( *pAuthorField );
     145             : 
     146           0 :         if( pAuthorField->GetType() == SVXAUTHORTYPE_FIX )
     147           0 :             CheckItem( 1 );
     148             :         else
     149           0 :             CheckItem( 2 );
     150             : 
     151           0 :         for( sal_uInt16 i = 0; i < 4; i++ )
     152             :         {
     153           0 :             aAuthorField.SetFormat( (SvxAuthorFormat) i );
     154           0 :             InsertItem( nID++, aAuthorField.GetFormatted(), nStyle );
     155             :         }
     156           0 :         CheckItem( (sal_uInt16) ( pAuthorField->GetFormat() ) + 3 );
     157             :     }
     158           0 : }
     159             : 
     160             : /**
     161             :  * Returns a new field, owned by caller.
     162             :  * Returns NULL if nothing changed.
     163             :  */
     164           0 : SvxFieldData* SdFieldPopup::GetField()
     165             : {
     166           0 :     SvxFieldData* pNewField = NULL;
     167           0 :     sal_uInt16 nCount = GetItemCount();
     168             : 
     169           0 :     if( pField->ISA( SvxDateField ) )
     170             :     {
     171           0 :         const SvxDateField* pDateField = (const SvxDateField*) pField;
     172             :         SvxDateType   eType;
     173             :         SvxDateFormat eFormat;
     174             :         sal_uInt16 i;
     175             : 
     176           0 :         if( IsItemChecked( 1 ) )
     177           0 :             eType = SVXDATETYPE_FIX;
     178             :         else
     179           0 :             eType = SVXDATETYPE_VAR;
     180             : 
     181           0 :         for( i = 3; i <= nCount; i++ )
     182             :         {
     183           0 :             if( IsItemChecked( i ) )
     184           0 :                 break;
     185             :         }
     186           0 :         eFormat = (SvxDateFormat) ( i - 1 );
     187             : 
     188           0 :         if( pDateField->GetFormat() != eFormat ||
     189           0 :             pDateField->GetType() != eType )
     190             :         {
     191           0 :             pNewField = new SvxDateField( *pDateField );
     192           0 :             ( (SvxDateField*) pNewField )->SetType( eType );
     193           0 :             ( (SvxDateField*) pNewField )->SetFormat( eFormat );
     194             : 
     195           0 :             if( (pDateField->GetType() == SVXDATETYPE_VAR) && (eType == SVXDATETYPE_FIX) )
     196             :             {
     197           0 :                 Date aDate( Date::SYSTEM );
     198           0 :                 ( (SvxDateField*) pNewField )->SetFixDate( aDate );
     199             :             }
     200             :         }
     201             :     }
     202           0 :     else if( pField->ISA( SvxExtTimeField ) )
     203             :     {
     204           0 :         const SvxExtTimeField* pTimeField = (const SvxExtTimeField*) pField;
     205             :         SvxTimeType   eType;
     206             :         SvxTimeFormat eFormat;
     207             :         sal_uInt16 i;
     208             : 
     209           0 :         if( IsItemChecked( 1 ) )
     210           0 :             eType = SVXTIMETYPE_FIX;
     211             :         else
     212           0 :             eType = SVXTIMETYPE_VAR;
     213             : 
     214           0 :         for( i = 3; i <= nCount; i++ )
     215             :         {
     216           0 :             if( IsItemChecked( i ) )
     217           0 :                 break;
     218             :         }
     219           0 :         eFormat = (SvxTimeFormat) ( i - 1 );
     220             : 
     221           0 :         if( pTimeField->GetFormat() != eFormat ||
     222           0 :             pTimeField->GetType() != eType )
     223             :         {
     224           0 :             pNewField = new SvxExtTimeField( *pTimeField );
     225           0 :             ( (SvxExtTimeField*) pNewField )->SetType( eType );
     226           0 :             ( (SvxExtTimeField*) pNewField )->SetFormat( eFormat );
     227             : 
     228           0 :             if( (pTimeField->GetType() == SVXTIMETYPE_VAR) && (eType == SVXTIMETYPE_FIX) )
     229             :             {
     230           0 :                 Time aTime( Time::SYSTEM );
     231           0 :                 ( (SvxExtTimeField*) pNewField )->SetFixTime( aTime );
     232             :             }
     233             : 
     234             :         }
     235             :     }
     236           0 :     else if( pField->ISA( SvxExtFileField ) )
     237             :     {
     238           0 :         const SvxExtFileField* pFileField = (const SvxExtFileField*) pField;
     239             :         SvxFileType   eType;
     240             :         SvxFileFormat eFormat;
     241             :         sal_uInt16 i;
     242             : 
     243           0 :         if( IsItemChecked( 1 ) )
     244           0 :             eType = SVXFILETYPE_FIX;
     245             :         else
     246           0 :             eType = SVXFILETYPE_VAR;
     247             : 
     248           0 :         for( i = 3; i <= nCount; i++ )
     249             :         {
     250           0 :             if( IsItemChecked( i ) )
     251           0 :                 break;
     252             :         }
     253           0 :         eFormat = (SvxFileFormat) ( i - 3 );
     254             : 
     255           0 :         if( pFileField->GetFormat() != eFormat ||
     256           0 :             pFileField->GetType() != eType )
     257             :         {
     258           0 :             ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell,
     259             :                 SfxObjectShell::Current() );
     260             : 
     261           0 :             if( pDocSh )
     262             :             {
     263           0 :                 SvxExtFileField aFileField( *pFileField );
     264             : 
     265           0 :                 OUString aName;
     266           0 :                 if( pDocSh->HasName() )
     267           0 :                     aName = pDocSh->GetMedium()->GetName();
     268             : 
     269             :                 // Get current filename, not the one stored in the old field
     270           0 :                 pNewField = new SvxExtFileField( aName );
     271           0 :                 ( (SvxExtFileField*) pNewField )->SetType( eType );
     272           0 :                 ( (SvxExtFileField*) pNewField )->SetFormat( eFormat );
     273             :             }
     274             :         }
     275             :     }
     276           0 :     else if( pField->ISA( SvxAuthorField ) )
     277             :     {
     278           0 :         const SvxAuthorField* pAuthorField = (const SvxAuthorField*) pField;
     279             :         SvxAuthorType   eType;
     280             :         SvxAuthorFormat eFormat;
     281             :         sal_uInt16 i;
     282             : 
     283           0 :         if( IsItemChecked( 1 ) )
     284           0 :             eType = SVXAUTHORTYPE_FIX;
     285             :         else
     286           0 :             eType = SVXAUTHORTYPE_VAR;
     287             : 
     288           0 :         for( i = 3; i <= nCount; i++ )
     289             :         {
     290           0 :             if( IsItemChecked( i ) )
     291           0 :                 break;
     292             :         }
     293           0 :         eFormat = (SvxAuthorFormat) ( i - 3 );
     294             : 
     295           0 :         if( pAuthorField->GetFormat() != eFormat ||
     296           0 :             pAuthorField->GetType() != eType )
     297             :         {
     298             :             // Get current state of address, not the old one
     299           0 :             SvtUserOptions aUserOptions;
     300           0 :             pNewField = new SvxAuthorField( aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() );
     301           0 :             ( (SvxAuthorField*) pNewField )->SetType( eType );
     302           0 :             ( (SvxAuthorField*) pNewField )->SetFormat( eFormat );
     303             :         }
     304             :     }
     305           0 :     return( pNewField );
     306             : }
     307             : 
     308             : 
     309             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10