LCOV - code coverage report
Current view: top level - cui/source/dialogs - postdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 112 0.0 %
Date: 2012-08-25 Functions: 0 14 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 350 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 <tools/shl.hxx>
      30                 :            : #include <tools/date.hxx>
      31                 :            : #include <tools/time.hxx>
      32                 :            : #include <vcl/svapp.hxx>
      33                 :            : #include <vcl/msgbox.hxx>
      34                 :            : #include <svl/itempool.hxx>
      35                 :            : #include <svl/itemset.hxx>
      36                 :            : #include <unotools/useroptions.hxx>
      37                 :            : #include <unotools/localedatawrapper.hxx>
      38                 :            : #include <comphelper/processfactory.hxx>
      39                 :            : #include <svx/svxids.hrc>   // SID_ATTR_...
      40                 :            : #include <svx/dialogs.hrc>  // RID_SVXDLG_POSTIT
      41                 :            : 
      42                 :            : #define _SVX_POSTDLG_CXX
      43                 :            : 
      44                 :            : #include <cuires.hrc>
      45                 :            : #include "postdlg.hrc"
      46                 :            : #include <svx/postattr.hxx>
      47                 :            : #include "postdlg.hxx"
      48                 :            : #include <dialmgr.hxx>
      49                 :            : 
      50                 :            : #include "helpid.hrc"
      51                 :            : 
      52                 :            : // static ----------------------------------------------------------------
      53                 :            : 
      54                 :            : static sal_uInt16 pRanges[] =
      55                 :            : {
      56                 :            :     SID_ATTR_POSTIT_AUTHOR,
      57                 :            :     SID_ATTR_POSTIT_TEXT,
      58                 :            :     0
      59                 :            : };
      60                 :            : 
      61                 :            : // class SvxPostItDialog -------------------------------------------------
      62                 :            : 
      63                 :          0 : SvxPostItDialog::SvxPostItDialog( Window* pParent,
      64                 :            :                                   const SfxItemSet& rCoreSet,
      65                 :            :                                   sal_Bool bPrevNext,
      66                 :            :                                   sal_Bool bRedline ) :
      67                 :            : 
      68                 :          0 :     SfxModalDialog( pParent, CUI_RES( RID_SVXDLG_POSTIT ) ),
      69                 :            : 
      70         [ #  # ]:          0 :     aPostItFL       ( this, CUI_RES( FL_POSTIT ) ),
      71         [ #  # ]:          0 :     aLastEditLabelFT( this, CUI_RES( FT_LASTEDITLABEL ) ),
      72         [ #  # ]:          0 :     aLastEditFT     ( this, CUI_RES( FT_LASTEDIT ) ),
      73         [ #  # ]:          0 :     aEditFT         ( this, CUI_RES( FT_EDIT ) ),
      74         [ #  # ]:          0 :     aEditED         ( this, CUI_RES( ED_EDIT ) ),
      75         [ #  # ]:          0 :     aAuthorFT       ( this, CUI_RES( FT_AUTHOR) ),
      76         [ #  # ]:          0 :     aAuthorBtn      ( this, CUI_RES( BTN_AUTHOR ) ),
      77         [ #  # ]:          0 :     aOKBtn          ( this, CUI_RES( BTN_POST_OK ) ),
      78         [ #  # ]:          0 :     aCancelBtn      ( this, CUI_RES( BTN_POST_CANCEL ) ),
      79         [ #  # ]:          0 :     aHelpBtn        ( this, CUI_RES( BTN_POST_HELP ) ),
      80         [ #  # ]:          0 :     aPrevBtn        ( this, CUI_RES( BTN_PREV ) ),
      81         [ #  # ]:          0 :     aNextBtn        ( this, CUI_RES( BTN_NEXT ) ),
      82                 :            : 
      83                 :            :     rSet        ( rCoreSet ),
      84 [ #  # ][ #  # ]:          0 :     pOutSet     ( 0 )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      85                 :            : 
      86                 :            : {
      87         [ #  # ]:          0 :     if (bRedline)   // HelpIDs for redlining
      88                 :            :     {
      89         [ #  # ]:          0 :         SetHelpId(HID_REDLINING_DLG);
      90         [ #  # ]:          0 :         aEditED.SetHelpId(HID_REDLINING_EDIT);
      91         [ #  # ]:          0 :         aPrevBtn.SetHelpId(HID_REDLINING_PREV);
      92         [ #  # ]:          0 :         aNextBtn.SetHelpId(HID_REDLINING_NEXT);
      93                 :            :     }
      94                 :            : 
      95         [ #  # ]:          0 :     aPrevBtn.SetClickHdl( LINK( this, SvxPostItDialog, PrevHdl ) );
      96         [ #  # ]:          0 :     aNextBtn.SetClickHdl( LINK( this, SvxPostItDialog, NextHdl ) );
      97         [ #  # ]:          0 :     aAuthorBtn.SetClickHdl( LINK( this, SvxPostItDialog, Stamp ) );
      98         [ #  # ]:          0 :     aOKBtn.SetClickHdl( LINK( this, SvxPostItDialog, OKHdl ) );
      99                 :            : 
     100         [ #  # ]:          0 :     Font aFont( aEditED.GetFont() );
     101         [ #  # ]:          0 :     aFont.SetWeight( WEIGHT_LIGHT );
     102         [ #  # ]:          0 :     aEditED.SetFont( aFont );
     103                 :            : 
     104                 :          0 :     sal_Bool bNew = sal_True;
     105                 :          0 :     sal_uInt16 nWhich            = 0;
     106                 :            : 
     107         [ #  # ]:          0 :     if ( !bPrevNext )
     108                 :            :     {
     109         [ #  # ]:          0 :         aPrevBtn.Hide();
     110         [ #  # ]:          0 :         aNextBtn.Hide();
     111                 :            :     }
     112                 :            : 
     113         [ #  # ]:          0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR );
     114 [ #  # ][ #  # ]:          0 :     String aAuthorStr, aDateStr;
     115                 :            : 
     116 [ #  # ][ #  # ]:          0 :     if ( rSet.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
     117                 :            :     {
     118                 :          0 :         bNew = sal_False;
     119                 :            :         const SvxPostItAuthorItem& rAuthor =
     120         [ #  # ]:          0 :             (const SvxPostItAuthorItem&)rSet.Get( nWhich );
     121         [ #  # ]:          0 :         aAuthorStr = rAuthor.GetValue();
     122                 :            :     }
     123                 :            :     else
     124 [ #  # ][ #  # ]:          0 :         aAuthorStr = SvtUserOptions().GetID();
         [ #  # ][ #  # ]
     125                 :            : 
     126         [ #  # ]:          0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE );
     127                 :            : 
     128 [ #  # ][ #  # ]:          0 :     if ( rSet.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
     129                 :            :     {
     130                 :            :         const SvxPostItDateItem& rDate =
     131         [ #  # ]:          0 :             (const SvxPostItDateItem&)rSet.Get( nWhich );
     132         [ #  # ]:          0 :         aDateStr = rDate.GetValue();
     133                 :            :     }
     134                 :            :     else
     135                 :            :     {
     136 [ #  # ][ #  # ]:          0 :         LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
         [ #  # ][ #  # ]
     137 [ #  # ][ #  # ]:          0 :         aDateStr = aLocaleWrapper.getDate( Date( Date::SYSTEM ) );
         [ #  # ][ #  # ]
     138                 :            :     }
     139                 :            : 
     140         [ #  # ]:          0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT );
     141                 :            : 
     142                 :          0 :     rtl::OUString aTextStr;
     143 [ #  # ][ #  # ]:          0 :     if ( rSet.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
     144                 :            :     {
     145                 :            :         const SvxPostItTextItem& rText =
     146         [ #  # ]:          0 :             (const SvxPostItTextItem&)rSet.Get( nWhich );
     147         [ #  # ]:          0 :         aTextStr = rText.GetValue();
     148                 :            :     }
     149                 :            : 
     150         [ #  # ]:          0 :     ShowLastAuthor(aAuthorStr, aDateStr);
     151 [ #  # ][ #  # ]:          0 :     aEditED.SetText(convertLineEnd(aTextStr, GetSystemLineEnd()));
         [ #  # ][ #  # ]
     152                 :            : 
     153         [ #  # ]:          0 :     if ( !bNew )
     154 [ #  # ][ #  # ]:          0 :         SetText( CUI_RESSTR( STR_NOTIZ_EDIT ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     155                 :            :     else
     156                 :            :         // create newly
     157 [ #  # ][ #  # ]:          0 :         SetText( CUI_RESSTR( STR_NOTIZ_INSERT ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     158                 :            : 
     159         [ #  # ]:          0 :     FreeResource();
     160                 :            : 
     161         [ #  # ]:          0 :     aEditED.SetAccessibleRelationLabeledBy(&aEditFT);
     162         [ #  # ]:          0 :     aEditED.SetAccessibleRelationMemberOf(&aPostItFL);
     163 [ #  # ][ #  # ]:          0 :     aAuthorBtn.SetAccessibleRelationMemberOf(&aPostItFL);
         [ #  # ][ #  # ]
     164                 :          0 : }
     165                 :            : 
     166                 :            : // -----------------------------------------------------------------------
     167                 :            : 
     168 [ #  # ][ #  # ]:          0 : SvxPostItDialog::~SvxPostItDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     169                 :            : {
     170 [ #  # ][ #  # ]:          0 :     delete pOutSet;
     171                 :          0 :     pOutSet = 0;
     172         [ #  # ]:          0 : }
     173                 :            : 
     174                 :            : // -----------------------------------------------------------------------
     175                 :            : 
     176                 :          0 : void SvxPostItDialog::ShowLastAuthor(const String& rAuthor, const String& rDate)
     177                 :            : {
     178         [ #  # ]:          0 :     String sTxt( rAuthor );
     179         [ #  # ]:          0 :     sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
     180         [ #  # ]:          0 :     sTxt += rDate;
     181 [ #  # ][ #  # ]:          0 :     aLastEditFT.SetText( sTxt );
     182                 :          0 : }
     183                 :            : 
     184                 :            : // -----------------------------------------------------------------------
     185                 :            : 
     186                 :          0 : sal_uInt16* SvxPostItDialog::GetRanges()
     187                 :            : {
     188                 :          0 :     return pRanges;
     189                 :            : }
     190                 :            : 
     191                 :            : // -----------------------------------------------------------------------
     192                 :            : 
     193                 :          0 : void SvxPostItDialog::EnableTravel(sal_Bool bNext, sal_Bool bPrev)
     194                 :            : {
     195                 :          0 :     aPrevBtn.Enable(bPrev);
     196                 :          0 :     aNextBtn.Enable(bNext);
     197                 :          0 : }
     198                 :            : 
     199                 :            : // -----------------------------------------------------------------------
     200                 :            : 
     201                 :          0 : IMPL_LINK_NOARG_INLINE_START(SvxPostItDialog, PrevHdl)
     202                 :            : {
     203                 :          0 :     aPrevHdlLink.Call( this );
     204                 :          0 :     return 0;
     205                 :            : }
     206                 :          0 : IMPL_LINK_NOARG_INLINE_END(SvxPostItDialog, PrevHdl)
     207                 :            : 
     208                 :            : // -----------------------------------------------------------------------
     209                 :            : 
     210                 :          0 : IMPL_LINK_NOARG_INLINE_START(SvxPostItDialog, NextHdl)
     211                 :            : {
     212                 :          0 :     aNextHdlLink.Call( this );
     213                 :          0 :     return 0;
     214                 :            : }
     215                 :          0 : IMPL_LINK_NOARG_INLINE_END(SvxPostItDialog, NextHdl)
     216                 :            : 
     217                 :            : // -----------------------------------------------------------------------
     218                 :            : 
     219                 :          0 : IMPL_LINK_NOARG(SvxPostItDialog, Stamp)
     220                 :            : {
     221         [ #  # ]:          0 :     Date aDate( Date::SYSTEM );
     222         [ #  # ]:          0 :     Time aTime( Time::SYSTEM );
     223 [ #  # ][ #  # ]:          0 :     String aTmp( SvtUserOptions().GetID() );
         [ #  # ][ #  # ]
     224 [ #  # ][ #  # ]:          0 :     LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
         [ #  # ][ #  # ]
     225         [ #  # ]:          0 :     String aStr( aEditED.GetText() );
     226         [ #  # ]:          0 :     aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\n---- " ) );
     227                 :            : 
     228         [ #  # ]:          0 :     if ( aTmp.Len() > 0 )
     229                 :            :     {
     230         [ #  # ]:          0 :         aStr += aTmp;
     231         [ #  # ]:          0 :         aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
     232                 :            :     }
     233 [ #  # ][ #  # ]:          0 :     aStr += aLocaleWrapper.getDate(aDate);
     234         [ #  # ]:          0 :     aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
     235 [ #  # ][ #  # ]:          0 :     aStr += aLocaleWrapper.getTime(aTime, sal_False, sal_False);
     236         [ #  # ]:          0 :     aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " ----\n" ) );
     237                 :            : 
     238 [ #  # ][ #  # ]:          0 :     aStr = convertLineEnd(aStr, GetSystemLineEnd());
                 [ #  # ]
     239                 :            : 
     240         [ #  # ]:          0 :     aEditED.SetText(aStr);
     241                 :          0 :     xub_StrLen nLen = aStr.Len();
     242         [ #  # ]:          0 :     aEditED.GrabFocus();
     243         [ #  # ]:          0 :     aEditED.SetSelection( Selection( nLen, nLen ) );
     244 [ #  # ][ #  # ]:          0 :     return 0;
                 [ #  # ]
     245                 :            : }
     246                 :            : 
     247                 :            : // -----------------------------------------------------------------------
     248                 :            : 
     249                 :          0 : IMPL_LINK_NOARG(SvxPostItDialog, OKHdl)
     250                 :            : {
     251 [ #  # ][ #  # ]:          0 :     LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
         [ #  # ][ #  # ]
     252 [ #  # ][ #  # ]:          0 :     pOutSet = new SfxItemSet( rSet );
     253                 :            :     pOutSet->Put( SvxPostItAuthorItem( SvtUserOptions().GetID(),
     254 [ #  # ][ #  # ]:          0 :                                          rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     255                 :            :     pOutSet->Put( SvxPostItDateItem( aLocaleWrapper.getDate( Date( Date::SYSTEM ) ),
     256 [ #  # ][ #  # ]:          0 :                                      rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     257                 :            :     pOutSet->Put( SvxPostItTextItem( aEditED.GetText(),
     258 [ #  # ][ #  # ]:          0 :                                      rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     259         [ #  # ]:          0 :     EndDialog( RET_OK );
     260         [ #  # ]:          0 :     return 0;
     261                 :            : }
     262                 :            : 
     263                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10