LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - scendlg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 91 0.0 %
Date: 2014-04-14 Functions: 0 9 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             : 
      21             : #undef SC_DLLIMPLEMENTATION
      22             : 
      23             : #include "scitems.hxx"
      24             : #include <comphelper/string.hxx>
      25             : #include <svx/drawitem.hxx>
      26             : #include <svx/xtable.hxx>
      27             : #include <sfx2/objsh.hxx>
      28             : #include <unotools/useroptions.hxx>
      29             : #include <vcl/msgbox.hxx>
      30             : #include <unotools/localedatawrapper.hxx>
      31             : 
      32             : #include "global.hxx"
      33             : #include "globstr.hrc"
      34             : #include "tabvwsh.hxx"
      35             : #include "viewdata.hxx"
      36             : #include "document.hxx"
      37             : #include "scresid.hxx"
      38             : #include "scendlg.hxx"
      39             : 
      40           0 : ScNewScenarioDlg::ScNewScenarioDlg( Window* pParent, const OUString& rName, bool bEdit, bool bSheetProtected)
      41             : 
      42             :     : ModalDialog(pParent, "ScenarioDialog",
      43             :         "modules/scalc/ui/scenariodialog.ui")
      44             :     , aDefScenarioName(rName)
      45           0 :     , bIsEdit(bEdit)
      46             : {
      47           0 :     get(m_pEdName, "name");
      48           0 :     get(m_pEdComment, "comment");
      49           0 :     Size aSize(m_pEdComment->LogicToPixel(Size(183, 46), MAP_APPFONT));
      50           0 :     m_pEdComment->set_width_request(aSize.Width());
      51           0 :     m_pEdComment->set_height_request(aSize.Height());
      52           0 :     get(m_pCbShowFrame, "showframe");
      53           0 :     get(m_pLbColor, "bordercolor");
      54           0 :     get(m_pCbTwoWay, "copyback");
      55           0 :     get(m_pCbCopyAll, "copysheet");
      56           0 :     get(m_pCbProtect, "preventchanges");
      57           0 :     get(m_pBtnOk, "ok");
      58             : 
      59           0 :     if (bIsEdit)
      60           0 :         SetText(get<FixedText>("alttitle")->GetText());
      61             : 
      62           0 :     SfxObjectShell* pDocSh = SfxObjectShell::Current();
      63           0 :     if ( pDocSh )
      64             :     {
      65           0 :         const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
      66           0 :         if ( pItem )
      67             :         {
      68           0 :             XColorListRef pColorList = ((SvxColorListItem*)pItem)->GetColorList();
      69           0 :             if (pColorList.is())
      70             :             {
      71           0 :                 m_pLbColor->SetUpdateMode( false );
      72           0 :                 long nCount = pColorList->Count();
      73           0 :                 for ( long n=0; n<nCount; n++ )
      74             :                 {
      75           0 :                     XColorEntry* pEntry = pColorList->GetColor(n);
      76           0 :                     m_pLbColor->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
      77             :                 }
      78           0 :                 m_pLbColor->SetUpdateMode( true );
      79           0 :             }
      80             :         }
      81             :     }
      82             : 
      83           0 :     SvtUserOptions aUserOpt;
      84             : 
      85           0 :     OUString sCreatedBy(get<FixedText>("createdft")->GetText());
      86           0 :     OUString sOn(get<FixedText>("onft")->GetText());
      87             : 
      88           0 :     OUString aComment(sCreatedBy + " " + aUserOpt.GetFirstName() + " " +aUserOpt.GetLastName()
      89           0 :               + ", " + sOn + " " + ScGlobal::GetpLocaleData()->getDate(Date(Date::SYSTEM))
      90           0 :               + ", " + ScGlobal::GetpLocaleData()->getTime(Time(Time::SYSTEM)));
      91             : 
      92           0 :     m_pEdComment->SetText(aComment);
      93           0 :     m_pEdName->SetText(rName);
      94           0 :     m_pBtnOk->SetClickHdl( LINK( this, ScNewScenarioDlg, OkHdl ) );
      95           0 :     m_pCbShowFrame->SetClickHdl( LINK( this, ScNewScenarioDlg, EnableHdl ) );
      96             : 
      97           0 :     m_pLbColor->SelectEntry( Color( COL_LIGHTGRAY ) );
      98           0 :     m_pCbShowFrame->Check(true);
      99           0 :     m_pCbTwoWay->Check(true);
     100           0 :     m_pCbCopyAll->Check(false);
     101           0 :     m_pCbProtect->Check(true);
     102             : 
     103           0 :     if (bIsEdit)
     104           0 :         m_pCbCopyAll->Enable(false);
     105             :     // If the Sheet is protected then we disable the Scenario Protect input
     106             :     // and default it to true above. Note we are in 'Add' mode here as: if
     107             :     // Sheet && scenario protection are true, then we cannot edit this dialog.
     108           0 :     if (bSheetProtected)
     109           0 :         m_pCbProtect->Enable(false);
     110           0 : }
     111             : 
     112           0 : void ScNewScenarioDlg::GetScenarioData( OUString& rName, OUString& rComment,
     113             :                                         Color& rColor, sal_uInt16& rFlags ) const
     114             : {
     115           0 :     rComment = m_pEdComment->GetText();
     116           0 :     rName    = m_pEdName->GetText();
     117             : 
     118           0 :     if (rName.isEmpty())
     119           0 :         rName = aDefScenarioName;
     120             : 
     121           0 :     rColor = m_pLbColor->GetSelectEntryColor();
     122           0 :     sal_uInt16 nBits = 0;
     123           0 :     if (m_pCbShowFrame->IsChecked())
     124           0 :         nBits |= SC_SCENARIO_SHOWFRAME;
     125           0 :     if (m_pCbTwoWay->IsChecked())
     126           0 :         nBits |= SC_SCENARIO_TWOWAY;
     127           0 :     if (m_pCbCopyAll->IsChecked())
     128           0 :         nBits |= SC_SCENARIO_COPYALL;
     129           0 :     if (m_pCbProtect->IsChecked())
     130           0 :         nBits |= SC_SCENARIO_PROTECT;
     131           0 :     rFlags = nBits;
     132           0 : }
     133             : 
     134           0 : void ScNewScenarioDlg::SetScenarioData( const OUString& rName, const OUString& rComment,
     135             :                                         const Color& rColor, sal_uInt16 nFlags )
     136             : {
     137           0 :     m_pEdComment->SetText(rComment);
     138           0 :     m_pEdName->SetText(rName);
     139           0 :     m_pLbColor->SelectEntry(rColor);
     140             : 
     141           0 :     m_pCbShowFrame->Check ( (nFlags & SC_SCENARIO_SHOWFRAME)  != 0 );
     142           0 :     EnableHdl(m_pCbShowFrame);
     143           0 :     m_pCbTwoWay->Check    ( (nFlags & SC_SCENARIO_TWOWAY)     != 0 );
     144             :     //  CopyAll nicht
     145           0 :     m_pCbProtect->Check    ( (nFlags & SC_SCENARIO_PROTECT)     != 0 );
     146           0 : }
     147             : 
     148           0 : IMPL_LINK_NOARG(ScNewScenarioDlg, OkHdl)
     149             : {
     150           0 :     OUString      aName = comphelper::string::strip(m_pEdName->GetText(), ' ');
     151           0 :     ScDocument* pDoc    = ((ScTabViewShell*)SfxViewShell::Current())->GetViewData()->GetDocument();
     152             : 
     153           0 :     m_pEdName->SetText( aName );
     154             : 
     155           0 :     if ( !pDoc->ValidTabName( aName ) )
     156             :     {
     157           0 :         InfoBox( this, ScGlobal::GetRscString( STR_INVALIDTABNAME ) ).Execute();
     158           0 :         m_pEdName->GrabFocus();
     159             :     }
     160           0 :     else if ( !bIsEdit && !pDoc->ValidNewTabName( aName ) )
     161             :     {
     162           0 :         InfoBox( this, ScGlobal::GetRscString( STR_NEWTABNAMENOTUNIQUE ) ).Execute();
     163           0 :         m_pEdName->GrabFocus();
     164             :     }
     165             :     else
     166           0 :         EndDialog( RET_OK );
     167           0 :     return 0;
     168             : 
     169             :     //! beim Editieren testen, ob eine andere Tabelle den Namen hat!
     170             : }
     171             : 
     172           0 : IMPL_LINK( ScNewScenarioDlg, EnableHdl, CheckBox *, pBox )
     173             : {
     174           0 :     if (pBox == m_pCbShowFrame)
     175           0 :         m_pLbColor->Enable( m_pCbShowFrame->IsChecked() );
     176           0 :     return 0;
     177           0 : }
     178             : 
     179             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10