LCOV - code coverage report
Current view: top level - sfx2/source/dialog - newstyle.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 37 2.7 %
Date: 2015-06-13 12:38:46 Functions: 2 10 20.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 <comphelper/string.hxx>
      21             : 
      22             : #include <svl/style.hxx>
      23             : 
      24             : #include <sfx2/newstyle.hxx>
      25             : #include "dialog.hrc"
      26             : #include <sfx2/sfxresid.hxx>
      27             : #include <vcl/layout.hxx>
      28             : 
      29             : // PRIVATE METHODES ------------------------------------------------------
      30             : 
      31           0 : IMPL_LINK( SfxNewStyleDlg, OKHdl, Control *, pControl )
      32             : {
      33             :     (void)pControl; //unused
      34           0 :     const OUString aName( m_pColBox->GetText() );
      35           0 :     SfxStyleSheetBase* pStyle = rPool.Find( aName, rPool.GetSearchFamily(), SFXSTYLEBIT_ALL );
      36           0 :     if ( pStyle )
      37             :     {
      38           0 :         if ( !pStyle->IsUserDefined() )
      39             :         {
      40           0 :             ScopedVclPtrInstance<MessageDialog>::Create( this, SfxResId( STR_POOL_STYLE_NAME ), VCL_MESSAGE_INFO )->Execute();
      41           0 :             return 0;
      42             :         }
      43             : 
      44           0 :         if ( RET_YES == aQueryOverwriteBox->Execute() )
      45           0 :             EndDialog( RET_OK );
      46             :     }
      47             :     else
      48           0 :         EndDialog( RET_OK );
      49             : 
      50           0 :     return 0;
      51             : }
      52             : 
      53           0 : IMPL_LINK( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox )
      54             : {
      55           0 :     m_pOKBtn->Enable( !comphelper::string::remove(pBox->GetText(), ' ').isEmpty() );
      56           0 :     return 0;
      57             : }
      58             : 
      59           0 : SfxNewStyleDlg::SfxNewStyleDlg( vcl::Window* pParent, SfxStyleSheetBasePool& rInPool )
      60             :     : ModalDialog(pParent, "CreateStyleDialog", "sfx/ui/newstyle.ui")
      61             :     , aQueryOverwriteBox(VclPtr<MessageDialog>::Create(this, SfxResId(STR_QUERY_OVERWRITE),
      62             :                                            VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO))
      63           0 :     , rPool(rInPool)
      64             : {
      65           0 :     get(m_pColBox, "stylename");
      66           0 :     m_pColBox->set_width_request(m_pColBox->approximate_char_width() * 25);
      67           0 :     m_pColBox->set_height_request(m_pColBox->GetTextHeight() * 10);
      68           0 :     get(m_pOKBtn, "ok");
      69             : 
      70           0 :     m_pOKBtn->SetClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
      71           0 :     m_pColBox->SetModifyHdl(LINK(this, SfxNewStyleDlg, ModifyHdl));
      72           0 :     m_pColBox->SetDoubleClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
      73             : 
      74           0 :     SfxStyleSheetBase *pStyle = rPool.First();
      75           0 :     while ( pStyle )
      76             :     {
      77           0 :         m_pColBox->InsertEntry(pStyle->GetName());
      78           0 :         pStyle = rPool.Next();
      79             :     }
      80           0 : }
      81             : 
      82           0 : SfxNewStyleDlg::~SfxNewStyleDlg()
      83             : {
      84           0 :     disposeOnce();
      85           0 : }
      86             : 
      87           0 : void SfxNewStyleDlg::dispose()
      88             : {
      89           0 :     aQueryOverwriteBox.disposeAndClear();
      90           0 :     m_pColBox.clear();
      91           0 :     m_pOKBtn.clear();
      92           0 :     ModalDialog::dispose();
      93         648 : }
      94             : 
      95             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11