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

Generated by: LCOV version 1.10