LCOV - code coverage report
Current view: top level - cui/source/dialogs - postdlg.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 101 0.0 %
Date: 2014-04-11 Functions: 0 16 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/date.hxx>
      22             : #include <tools/time.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <vcl/msgbox.hxx>
      25             : #include <vcl/settings.hxx>
      26             : #include <svl/itempool.hxx>
      27             : #include <svl/itemset.hxx>
      28             : #include <unotools/useroptions.hxx>
      29             : #include <unotools/localedatawrapper.hxx>
      30             : #include <comphelper/processfactory.hxx>
      31             : #include <svx/svxids.hrc>
      32             : 
      33             : #include <cuires.hrc>
      34             : #include <svx/postattr.hxx>
      35             : #include "postdlg.hxx"
      36             : #include <dialmgr.hxx>
      37             : 
      38             : #include "helpid.hrc"
      39             : 
      40             : // class SvxPostItDialog -------------------------------------------------
      41             : 
      42           0 : SvxPostItDialog::SvxPostItDialog(Window* pParent, const SfxItemSet& rCoreSet,
      43             :     bool bPrevNext)
      44             :     : SfxModalDialog(pParent, "CommentDialog", "cui/ui/comment.ui")
      45             :     , rSet(rCoreSet)
      46           0 :     , pOutSet(0)
      47             : {
      48           0 :     get(m_pLastEditFT, "lastedit");
      49           0 :     get(m_pInsertAuthor, "insertauthor");
      50           0 :     get(m_pAuthorBtn, "author");
      51           0 :     get(m_pOKBtn, "ok");
      52           0 :     get(m_pPrevBtn, "previous");
      53           0 :     get(m_pNextBtn, "next");
      54           0 :     get(m_pEditED, "edit");
      55             : 
      56           0 :     m_pPrevBtn->SetClickHdl( LINK( this, SvxPostItDialog, PrevHdl ) );
      57           0 :     m_pNextBtn->SetClickHdl( LINK( this, SvxPostItDialog, NextHdl ) );
      58           0 :     m_pAuthorBtn->SetClickHdl( LINK( this, SvxPostItDialog, Stamp ) );
      59           0 :     m_pOKBtn->SetClickHdl( LINK( this, SvxPostItDialog, OKHdl ) );
      60             : 
      61           0 :     Font aFont( m_pEditED->GetFont() );
      62           0 :     aFont.SetWeight( WEIGHT_LIGHT );
      63           0 :     m_pEditED->SetFont( aFont );
      64             : 
      65           0 :     sal_Bool bNew = sal_True;
      66           0 :     sal_uInt16 nWhich = 0;
      67             : 
      68           0 :     if ( !bPrevNext )
      69             :     {
      70           0 :         m_pPrevBtn->Hide();
      71           0 :         m_pNextBtn->Hide();
      72             :     }
      73             : 
      74           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR );
      75           0 :     OUString aAuthorStr, aDateStr;
      76             : 
      77           0 :     if ( rSet.GetItemState( nWhich, true ) >= SFX_ITEM_AVAILABLE )
      78             :     {
      79           0 :         bNew = sal_False;
      80             :         const SvxPostItAuthorItem& rAuthor =
      81           0 :             (const SvxPostItAuthorItem&)rSet.Get( nWhich );
      82           0 :         aAuthorStr = rAuthor.GetValue();
      83             :     }
      84             :     else
      85           0 :         aAuthorStr = SvtUserOptions().GetID();
      86             : 
      87           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE );
      88             : 
      89           0 :     if ( rSet.GetItemState( nWhich, true ) >= SFX_ITEM_AVAILABLE )
      90             :     {
      91             :         const SvxPostItDateItem& rDate =
      92           0 :             (const SvxPostItDateItem&)rSet.Get( nWhich );
      93           0 :         aDateStr = rDate.GetValue();
      94             :     }
      95             :     else
      96             :     {
      97           0 :         const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
      98           0 :         aDateStr = rLocaleWrapper.getDate( Date( Date::SYSTEM ) );
      99             :     }
     100             : 
     101           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT );
     102             : 
     103           0 :     OUString aTextStr;
     104           0 :     if ( rSet.GetItemState( nWhich, true ) >= SFX_ITEM_AVAILABLE )
     105             :     {
     106             :         const SvxPostItTextItem& rText =
     107           0 :             (const SvxPostItTextItem&)rSet.Get( nWhich );
     108           0 :         aTextStr = rText.GetValue();
     109             :     }
     110             : 
     111           0 :     ShowLastAuthor(aAuthorStr, aDateStr);
     112             : 
     113             :     //lock to initial .ui placeholder size before replacing contents
     114           0 :     Size aSize(m_pEditED->get_preferred_size());
     115           0 :     m_pEditED->set_width_request(aSize.Width());
     116           0 :     m_pEditED->set_height_request(aSize.Height());
     117             : 
     118           0 :     m_pEditED->SetText(convertLineEnd(aTextStr, GetSystemLineEnd()));
     119             : 
     120           0 :     if (!bNew)
     121           0 :         SetText( get<FixedText>("alttitle")->GetText() );
     122           0 : }
     123             : 
     124             : 
     125             : 
     126           0 : SvxPostItDialog::~SvxPostItDialog()
     127             : {
     128           0 :     delete pOutSet;
     129           0 :     pOutSet = 0;
     130           0 : }
     131             : 
     132             : 
     133             : 
     134           0 : void SvxPostItDialog::ShowLastAuthor(const OUString& rAuthor, const OUString& rDate)
     135             : {
     136           0 :     OUString sTxt( rAuthor );
     137           0 :     sTxt += ", ";
     138           0 :     sTxt += rDate;
     139           0 :     m_pLastEditFT->SetText( sTxt );
     140           0 : }
     141             : 
     142             : 
     143             : 
     144           0 : sal_uInt16* SvxPostItDialog::GetRanges()
     145             : {
     146             :     static sal_uInt16 pRanges[] =
     147             :     {
     148             :         SID_ATTR_POSTIT_AUTHOR,
     149             :         SID_ATTR_POSTIT_TEXT,
     150             :         0
     151             :     };
     152           0 :     return pRanges;
     153             : }
     154             : 
     155             : 
     156             : 
     157           0 : void SvxPostItDialog::EnableTravel(sal_Bool bNext, sal_Bool bPrev)
     158             : {
     159           0 :     m_pPrevBtn->Enable(bPrev);
     160           0 :     m_pNextBtn->Enable(bNext);
     161           0 : }
     162             : 
     163             : 
     164             : 
     165           0 : IMPL_LINK_NOARG_INLINE_START(SvxPostItDialog, PrevHdl)
     166             : {
     167           0 :     aPrevHdlLink.Call( this );
     168           0 :     return 0;
     169             : }
     170           0 : IMPL_LINK_NOARG_INLINE_END(SvxPostItDialog, PrevHdl)
     171             : 
     172             : 
     173             : 
     174           0 : IMPL_LINK_NOARG_INLINE_START(SvxPostItDialog, NextHdl)
     175             : {
     176           0 :     aNextHdlLink.Call( this );
     177           0 :     return 0;
     178             : }
     179           0 : IMPL_LINK_NOARG_INLINE_END(SvxPostItDialog, NextHdl)
     180             : 
     181             : 
     182             : 
     183           0 : IMPL_LINK_NOARG(SvxPostItDialog, Stamp)
     184             : {
     185           0 :     Date aDate( Date::SYSTEM );
     186           0 :     Time aTime( Time::SYSTEM );
     187           0 :     OUString aTmp( SvtUserOptions().GetID() );
     188           0 :     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
     189           0 :     OUString aStr( m_pEditED->GetText() );
     190           0 :     aStr += "\n---- ";
     191             : 
     192           0 :     if ( !aTmp.isEmpty() )
     193             :     {
     194           0 :         aStr += aTmp;
     195           0 :         aStr += ", ";
     196             :     }
     197           0 :     aStr += rLocaleWrapper.getDate(aDate);
     198           0 :     aStr += ", ";
     199           0 :     aStr += rLocaleWrapper.getTime(aTime, false, false);
     200           0 :     aStr += " ----\n";
     201             : 
     202           0 :     aStr = convertLineEnd(aStr, GetSystemLineEnd());
     203             : 
     204           0 :     m_pEditED->SetText(aStr);
     205           0 :     sal_Int32 nLen = aStr.getLength();
     206           0 :     m_pEditED->GrabFocus();
     207           0 :     m_pEditED->SetSelection( Selection( nLen, nLen ) );
     208           0 :     return 0;
     209             : }
     210             : 
     211             : 
     212             : 
     213           0 : IMPL_LINK_NOARG(SvxPostItDialog, OKHdl)
     214             : {
     215           0 :     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
     216           0 :     pOutSet = new SfxItemSet( rSet );
     217             :     pOutSet->Put( SvxPostItAuthorItem( SvtUserOptions().GetID(),
     218           0 :                                          rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR ) ) );
     219             :     pOutSet->Put( SvxPostItDateItem( rLocaleWrapper.getDate( Date( Date::SYSTEM ) ),
     220           0 :                                      rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE ) ) );
     221           0 :     pOutSet->Put( SvxPostItTextItem( m_pEditED->GetText(),
     222           0 :                                      rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT ) ) );
     223           0 :     EndDialog( RET_OK );
     224           0 :     return 0;
     225           0 : }
     226             : 
     227             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10