LCOV - code coverage report
Current view: top level - sd/source/ui/app - sdpopup.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 149 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 340 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <editeng/eeitem.hxx>
      30                 :            : 
      31                 :            : #include <editeng/editeng.hxx>
      32                 :            : #include <editeng/flditem.hxx>
      33                 :            : #include <svl/zforlist.hxx>
      34                 :            : #include <sfx2/objsh.hxx>
      35                 :            : #include <sfx2/docfile.hxx>
      36                 :            : #include <unotools/useroptions.hxx>
      37                 :            : 
      38                 :            : #include "strings.hrc"
      39                 :            : #include "sdpopup.hxx"
      40                 :            : #include "sdresid.hxx"
      41                 :            : #include "sdmod.hxx"
      42                 :            : #include "drawdoc.hxx"
      43                 :            : #include "DrawDocShell.hxx"
      44                 :            : 
      45                 :            : /*************************************************************************
      46                 :            : |*
      47                 :            : |* PopupMenu zum Bearbeiten von Feldbefehlen
      48                 :            : |*
      49                 :            : \************************************************************************/
      50                 :            : 
      51                 :          0 : SdFieldPopup::SdFieldPopup( const SvxFieldData* pInField, LanguageType eLanguage ) :
      52                 :            :         PopupMenu   (),
      53                 :          0 :         pField      ( pInField )
      54                 :            : {
      55         [ #  # ]:          0 :     Fill( eLanguage );
      56                 :          0 : }
      57                 :            : 
      58                 :            : /*************************************************************************
      59                 :            : |*
      60                 :            : |* Dtor
      61                 :            : |*
      62                 :            : \************************************************************************/
      63                 :            : 
      64                 :          0 : SdFieldPopup::~SdFieldPopup()
      65                 :            : {
      66         [ #  # ]:          0 : }
      67                 :            : 
      68                 :            : /*************************************************************************
      69                 :            : |*
      70                 :            : |* Fill
      71                 :            : |*
      72                 :            : \************************************************************************/
      73                 :            : 
      74                 :          0 : void SdFieldPopup::Fill( LanguageType eLanguage )
      75                 :            : {
      76                 :          0 :     sal_uInt16 nID = 1;
      77                 :          0 :     sal_uInt16 nStyle = MIB_RADIOCHECK | MIB_AUTOCHECK;
      78 [ #  # ][ #  # ]:          0 :     InsertItem( nID++, String( SdResId( STR_FIX ) ), nStyle );
                 [ #  # ]
      79 [ #  # ][ #  # ]:          0 :     InsertItem( nID++, String( SdResId( STR_VAR ) ), nStyle );
                 [ #  # ]
      80                 :          0 :     InsertSeparator();
      81                 :            : 
      82         [ #  # ]:          0 :     if( pField->ISA( SvxDateField ) )
      83                 :            :     {
      84                 :          0 :         const SvxDateField* pDateField = (const SvxDateField*) pField;
      85         [ #  # ]:          0 :         SvxDateField aDateField( *pDateField );
      86                 :            : 
      87         [ #  # ]:          0 :         if( pDateField->GetType() == SVXDATETYPE_FIX )
      88         [ #  # ]:          0 :             CheckItem( 1 );
      89                 :            :         else
      90         [ #  # ]:          0 :             CheckItem( 2 );
      91                 :            : 
      92                 :            :         //SVXDATEFORMAT_APPDEFAULT,     // Wird nicht benutzt
      93                 :            :         //SVXDATEFORMAT_SYSTEM,         // Wird nicht benutzt
      94 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, String( SdResId( STR_STANDARD_SMALL ) ), nStyle );
         [ #  # ][ #  # ]
      95 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, String( SdResId( STR_STANDARD_BIG ) ), nStyle );
         [ #  # ][ #  # ]
      96                 :            : 
      97 [ #  # ][ #  # ]:          0 :         SvNumberFormatter* pNumberFormatter = SD_MOD()->GetNumberFormatter();
      98                 :          0 :         aDateField.SetFormat( SVXDATEFORMAT_A );    // 13.02.96
      99 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     100                 :          0 :         aDateField.SetFormat( SVXDATEFORMAT_B );    // 13.02.1996
     101 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     102                 :          0 :         aDateField.SetFormat( SVXDATEFORMAT_C );    // 13.Feb 1996
     103 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     104                 :            : 
     105                 :          0 :         aDateField.SetFormat( SVXDATEFORMAT_D );    // 13.Februar 1996
     106 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     107                 :          0 :         aDateField.SetFormat( SVXDATEFORMAT_E );    // Die, 13.Februar 1996
     108 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     109                 :          0 :         aDateField.SetFormat( SVXDATEFORMAT_F );    // Dienstag, 13.Februar 1996
     110 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     111                 :            : 
     112 [ #  # ][ #  # ]:          0 :         CheckItem( (sal_uInt16) ( pDateField->GetFormat() ) + 1 ); // - 2 + 3 !
     113                 :            :     }
     114         [ #  # ]:          0 :     else if( pField->ISA( SvxExtTimeField ) )
     115                 :            :     {
     116                 :          0 :         const SvxExtTimeField* pTimeField = (const SvxExtTimeField*) pField;
     117         [ #  # ]:          0 :         SvxExtTimeField aTimeField( *pTimeField );
     118                 :            : 
     119         [ #  # ]:          0 :         if( pTimeField->GetType() == SVXTIMETYPE_FIX )
     120         [ #  # ]:          0 :             CheckItem( 1 );
     121                 :            :         else
     122         [ #  # ]:          0 :             CheckItem( 2 );
     123                 :            : 
     124                 :            :         //SVXTIMEFORMAT_APPDEFAULT,     // Wird nicht benutzt
     125                 :            :         //SVXTIMEFORMAT_SYSTEM,         // Wird nicht benutzt
     126 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, String( SdResId( STR_STANDARD_NORMAL ) ), nStyle );
         [ #  # ][ #  # ]
     127                 :            : 
     128 [ #  # ][ #  # ]:          0 :         SvNumberFormatter* pNumberFormatter = SD_MOD()->GetNumberFormatter();
     129                 :          0 :         aTimeField.SetFormat( SVXTIMEFORMAT_24_HM );    // 13:49
     130 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     131                 :          0 :         aTimeField.SetFormat( SVXTIMEFORMAT_24_HMS );   // 13:49:38
     132 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     133                 :          0 :         aTimeField.SetFormat( SVXTIMEFORMAT_24_HMSH );  // 13:49:38.78
     134 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     135                 :            : 
     136                 :          0 :         aTimeField.SetFormat( SVXTIMEFORMAT_12_HM );    // 01:49
     137 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     138                 :          0 :         aTimeField.SetFormat( SVXTIMEFORMAT_12_HMS );   // 01:49:38
     139 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     140                 :          0 :         aTimeField.SetFormat( SVXTIMEFORMAT_12_HMSH );  // 01:49:38.78
     141 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, aTimeField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
         [ #  # ][ #  # ]
     142                 :            :         //SVXTIMEFORMAT_AM_HM,  // 01:49 PM
     143                 :            :         //SVXTIMEFORMAT_AM_HMS, // 01:49:38 PM
     144                 :            :         //SVXTIMEFORMAT_AM_HMSH // 01:49:38.78 PM
     145                 :            : 
     146 [ #  # ][ #  # ]:          0 :         CheckItem( (sal_uInt16) ( pTimeField->GetFormat() ) + 1 ); // - 2 + 3 !
     147                 :            :     }
     148         [ #  # ]:          0 :     else if( pField->ISA( SvxExtFileField ) )
     149                 :            :     {
     150                 :          0 :         const SvxExtFileField* pFileField = (const SvxExtFileField*) pField;
     151                 :            :         //SvxExtFileField aFileField( *pFileField );
     152                 :            : 
     153         [ #  # ]:          0 :         if( pFileField->GetType() == SVXFILETYPE_FIX )
     154                 :          0 :             CheckItem( 1 );
     155                 :            :         else
     156                 :          0 :             CheckItem( 2 );
     157                 :            : 
     158 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, String( SdResId( STR_FILEFORMAT_NAME_EXT ) ), nStyle );
                 [ #  # ]
     159 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, String( SdResId( STR_FILEFORMAT_FULLPATH ) ), nStyle );
                 [ #  # ]
     160 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, String( SdResId( STR_FILEFORMAT_PATH ) ), nStyle );
                 [ #  # ]
     161 [ #  # ][ #  # ]:          0 :         InsertItem( nID++, String( SdResId( STR_FILEFORMAT_NAME ) ), nStyle );
                 [ #  # ]
     162                 :            : 
     163                 :          0 :         CheckItem( (sal_uInt16) ( pFileField->GetFormat() ) + 3 );
     164                 :            :     }
     165         [ #  # ]:          0 :     else if( pField->ISA( SvxAuthorField ) )
     166                 :            :     {
     167                 :          0 :         const SvxAuthorField* pAuthorField = (const SvxAuthorField*) pField;
     168         [ #  # ]:          0 :         SvxAuthorField aAuthorField( *pAuthorField );
     169                 :            : 
     170         [ #  # ]:          0 :         if( pAuthorField->GetType() == SVXAUTHORTYPE_FIX )
     171         [ #  # ]:          0 :             CheckItem( 1 );
     172                 :            :         else
     173         [ #  # ]:          0 :             CheckItem( 2 );
     174                 :            : 
     175         [ #  # ]:          0 :         for( sal_uInt16 i = 0; i < 4; i++ )
     176                 :            :         {
     177                 :          0 :             aAuthorField.SetFormat( (SvxAuthorFormat) i );
     178 [ #  # ][ #  # ]:          0 :             InsertItem( nID++, aAuthorField.GetFormatted(), nStyle );
         [ #  # ][ #  # ]
     179                 :            :         }
     180 [ #  # ][ #  # ]:          0 :         CheckItem( (sal_uInt16) ( pAuthorField->GetFormat() ) + 3 );
     181                 :            :     }
     182                 :          0 : }
     183                 :            : 
     184                 :            : /*************************************************************************
     185                 :            : |*
     186                 :            : |* Gibt das neue Feld zurueck, gehoert dem Caller.
     187                 :            : |* Liefert NULL, wenn sich nichts geaendert hat.
     188                 :            : |*
     189                 :            : \************************************************************************/
     190                 :            : 
     191                 :          0 : SvxFieldData* SdFieldPopup::GetField()
     192                 :            : {
     193                 :          0 :     SvxFieldData* pNewField = NULL;
     194                 :          0 :     sal_uInt16 nCount = GetItemCount();
     195                 :            : 
     196         [ #  # ]:          0 :     if( pField->ISA( SvxDateField ) )
     197                 :            :     {
     198                 :          0 :         const SvxDateField* pDateField = (const SvxDateField*) pField;
     199                 :            :         SvxDateType   eType;
     200                 :            :         SvxDateFormat eFormat;
     201                 :            :         sal_uInt16 i;
     202                 :            : 
     203         [ #  # ]:          0 :         if( IsItemChecked( 1 ) )
     204                 :          0 :             eType = SVXDATETYPE_FIX;
     205                 :            :         else
     206                 :          0 :             eType = SVXDATETYPE_VAR;
     207                 :            : 
     208         [ #  # ]:          0 :         for( i = 3; i <= nCount; i++ )
     209                 :            :         {
     210         [ #  # ]:          0 :             if( IsItemChecked( i ) )
     211                 :          0 :                 break;
     212                 :            :         }
     213                 :          0 :         eFormat = (SvxDateFormat) ( i - 1 );
     214                 :            : 
     215   [ #  #  #  # ]:          0 :         if( pDateField->GetFormat() != eFormat ||
                 [ #  # ]
     216                 :          0 :             pDateField->GetType() != eType )
     217                 :            :         {
     218         [ #  # ]:          0 :             pNewField = new SvxDateField( *pDateField );
     219                 :          0 :             ( (SvxDateField*) pNewField )->SetType( eType );
     220                 :          0 :             ( (SvxDateField*) pNewField )->SetFormat( eFormat );
     221                 :            : 
     222 [ #  # ][ #  # ]:          0 :             if( (pDateField->GetType() == SVXDATETYPE_VAR) && (eType == SVXDATETYPE_FIX) )
                 [ #  # ]
     223                 :            :             {
     224         [ #  # ]:          0 :                 Date aDate( Date::SYSTEM );
     225                 :          0 :                 ( (SvxDateField*) pNewField )->SetFixDate( aDate );
     226                 :            :             }
     227                 :            :         }
     228                 :            :     }
     229         [ #  # ]:          0 :     else if( pField->ISA( SvxExtTimeField ) )
     230                 :            :     {
     231                 :          0 :         const SvxExtTimeField* pTimeField = (const SvxExtTimeField*) pField;
     232                 :            :         SvxTimeType   eType;
     233                 :            :         SvxTimeFormat eFormat;
     234                 :            :         sal_uInt16 i;
     235                 :            : 
     236         [ #  # ]:          0 :         if( IsItemChecked( 1 ) )
     237                 :          0 :             eType = SVXTIMETYPE_FIX;
     238                 :            :         else
     239                 :          0 :             eType = SVXTIMETYPE_VAR;
     240                 :            : 
     241         [ #  # ]:          0 :         for( i = 3; i <= nCount; i++ )
     242                 :            :         {
     243         [ #  # ]:          0 :             if( IsItemChecked( i ) )
     244                 :          0 :                 break;
     245                 :            :         }
     246                 :          0 :         eFormat = (SvxTimeFormat) ( i - 1 );
     247                 :            : 
     248   [ #  #  #  # ]:          0 :         if( pTimeField->GetFormat() != eFormat ||
                 [ #  # ]
     249                 :          0 :             pTimeField->GetType() != eType )
     250                 :            :         {
     251         [ #  # ]:          0 :             pNewField = new SvxExtTimeField( *pTimeField );
     252                 :          0 :             ( (SvxExtTimeField*) pNewField )->SetType( eType );
     253                 :          0 :             ( (SvxExtTimeField*) pNewField )->SetFormat( eFormat );
     254                 :            : 
     255 [ #  # ][ #  # ]:          0 :             if( (pTimeField->GetType() == SVXTIMETYPE_VAR) && (eType == SVXTIMETYPE_FIX) )
                 [ #  # ]
     256                 :            :             {
     257         [ #  # ]:          0 :                 Time aTime( Time::SYSTEM );
     258                 :          0 :                 ( (SvxExtTimeField*) pNewField )->SetFixTime( aTime );
     259                 :            :             }
     260                 :            : 
     261                 :            :         }
     262                 :            :     }
     263         [ #  # ]:          0 :     else if( pField->ISA( SvxExtFileField ) )
     264                 :            :     {
     265                 :          0 :         const SvxExtFileField* pFileField = (const SvxExtFileField*) pField;
     266                 :            :         SvxFileType   eType;
     267                 :            :         SvxFileFormat eFormat;
     268                 :            :         sal_uInt16 i;
     269                 :            : 
     270         [ #  # ]:          0 :         if( IsItemChecked( 1 ) )
     271                 :          0 :             eType = SVXFILETYPE_FIX;
     272                 :            :         else
     273                 :          0 :             eType = SVXFILETYPE_VAR;
     274                 :            : 
     275         [ #  # ]:          0 :         for( i = 3; i <= nCount; i++ )
     276                 :            :         {
     277         [ #  # ]:          0 :             if( IsItemChecked( i ) )
     278                 :          0 :                 break;
     279                 :            :         }
     280                 :          0 :         eFormat = (SvxFileFormat) ( i - 3 );
     281                 :            : 
     282   [ #  #  #  # ]:          0 :         if( pFileField->GetFormat() != eFormat ||
                 [ #  # ]
     283                 :          0 :             pFileField->GetType() != eType )
     284                 :            :         {
     285 [ #  # ][ #  # ]:          0 :             ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell,
     286                 :            :                 SfxObjectShell::Current() );
     287                 :            : 
     288         [ #  # ]:          0 :             if( pDocSh )
     289                 :            :             {
     290         [ #  # ]:          0 :                 SvxExtFileField aFileField( *pFileField );
     291                 :            : 
     292         [ #  # ]:          0 :                 String aName;
     293         [ #  # ]:          0 :                 if( pDocSh->HasName() )
     294 [ #  # ][ #  # ]:          0 :                     aName = pDocSh->GetMedium()->GetName();
     295                 :            : 
     296                 :            :                 // Get current filename, not the one stored in the old field
     297 [ #  # ][ #  # ]:          0 :                 pNewField = new SvxExtFileField( aName );
                 [ #  # ]
     298                 :          0 :                 ( (SvxExtFileField*) pNewField )->SetType( eType );
     299 [ #  # ][ #  # ]:          0 :                 ( (SvxExtFileField*) pNewField )->SetFormat( eFormat );
     300                 :            :             }
     301                 :            :         }
     302                 :            :     }
     303         [ #  # ]:          0 :     else if( pField->ISA( SvxAuthorField ) )
     304                 :            :     {
     305                 :          0 :         const SvxAuthorField* pAuthorField = (const SvxAuthorField*) pField;
     306                 :            :         SvxAuthorType   eType;
     307                 :            :         SvxAuthorFormat eFormat;
     308                 :            :         sal_uInt16 i;
     309                 :            : 
     310         [ #  # ]:          0 :         if( IsItemChecked( 1 ) )
     311                 :          0 :             eType = SVXAUTHORTYPE_FIX;
     312                 :            :         else
     313                 :          0 :             eType = SVXAUTHORTYPE_VAR;
     314                 :            : 
     315         [ #  # ]:          0 :         for( i = 3; i <= nCount; i++ )
     316                 :            :         {
     317         [ #  # ]:          0 :             if( IsItemChecked( i ) )
     318                 :          0 :                 break;
     319                 :            :         }
     320                 :          0 :         eFormat = (SvxAuthorFormat) ( i - 3 );
     321                 :            : 
     322   [ #  #  #  # ]:          0 :         if( pAuthorField->GetFormat() != eFormat ||
                 [ #  # ]
     323                 :          0 :             pAuthorField->GetType() != eType )
     324                 :            :         {
     325                 :            :             // Get current state of address, not the old one
     326         [ #  # ]:          0 :             SvtUserOptions aUserOptions;
     327 [ #  # ][ #  # ]:          0 :             pNewField = new SvxAuthorField( aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() );
         [ #  # ][ #  # ]
                 [ #  # ]
     328                 :          0 :             ( (SvxAuthorField*) pNewField )->SetType( eType );
     329         [ #  # ]:          0 :             ( (SvxAuthorField*) pNewField )->SetFormat( eFormat );
     330                 :            :         }
     331                 :            :     }
     332                 :          0 :     return( pNewField );
     333                 :            : }
     334                 :            : 
     335                 :            : 
     336                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10