LCOV - code coverage report
Current view: top level - sw/source/ui/utlui - swrenamexnameddlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 36 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 10 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 <swtypes.hxx>
      21             : #include <globals.hrc>
      22             : 
      23             : #include <utlui.hrc>
      24             : #include <../../uibase/utlui/unotools.hrc>
      25             : #include <unoprnms.hxx>
      26             : #include <osl/diagnose.h>
      27             : #include <vcl/msgbox.hxx>
      28             : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
      29             : #include <com/sun/star/view/XScreenCursor.hpp>
      30             : #include <com/sun/star/view/DocumentZoomType.hpp>
      31             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      32             : #include <com/sun/star/style/XStyle.hpp>
      33             : #include <com/sun/star/frame/XFrame.hpp>
      34             : #include <com/sun/star/text/XText.hpp>
      35             : #include <com/sun/star/text/XTextDocument.hpp>
      36             : #include <com/sun/star/awt/PosSize.hpp>
      37             : #include <com/sun/star/view/XViewSettingsSupplier.hpp>
      38             : #include <com/sun/star/container/XNameContainer.hpp>
      39             : #include <comphelper/processfactory.hxx>
      40             : #include <comphelper/string.hxx>
      41             : #include <sfx2/dispatch.hxx>
      42             : #include <svl/stritem.hxx>
      43             : #include <shellio.hxx>
      44             : #include <docsh.hxx>
      45             : #include <view.hxx>
      46             : #include <wrtsh.hxx>
      47             : #include <swmodule.hxx>
      48             : #include <unocrsr.hxx>
      49             : 
      50             : #include "swrenamexnameddlg.hxx"
      51             : 
      52             : using namespace ::com::sun::star;
      53             : 
      54           0 : SwRenameXNamedDlg::SwRenameXNamedDlg( vcl::Window* pWin,
      55             :             uno::Reference< container::XNamed > & xN,
      56             :             uno::Reference< container::XNameAccess > & xNA )
      57             :     : ModalDialog(pWin, "RenameObjectDialog",
      58             :         "modules/swriter/ui/renameobjectdialog.ui")
      59             :     , xNamed(xN)
      60           0 :     , xNameAccess(xNA)
      61             : {
      62           0 :     get(m_pNewNameED, "entry");
      63           0 :     m_pNewNameED->SetTextFilter(&m_aTextFilter);
      64           0 :     get(m_pOk, "ok");
      65             : 
      66           0 :     OUString sTmp(GetText());
      67           0 :     m_pNewNameED->SetText(xNamed->getName());
      68           0 :     m_pNewNameED->SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
      69           0 :     sTmp += xNamed->getName();
      70           0 :     SetText(sTmp);
      71             : 
      72           0 :     m_pOk->SetClickHdl(LINK(this, SwRenameXNamedDlg, OkHdl));
      73           0 :     m_pNewNameED->SetModifyHdl(LINK(this, SwRenameXNamedDlg, ModifyHdl));
      74           0 :     m_pOk->Enable(false);
      75           0 : }
      76             : 
      77           0 : SwRenameXNamedDlg::~SwRenameXNamedDlg()
      78             : {
      79           0 :     disposeOnce();
      80           0 : }
      81             : 
      82           0 : void SwRenameXNamedDlg::dispose()
      83             : {
      84           0 :     m_pNewNameED.clear();
      85           0 :     m_pOk.clear();
      86           0 :     ModalDialog::dispose();
      87           0 : }
      88             : 
      89           0 : IMPL_LINK_NOARG(SwRenameXNamedDlg, OkHdl)
      90             : {
      91             :     try
      92             :     {
      93           0 :         xNamed->setName(m_pNewNameED->GetText());
      94             :     }
      95           0 :     catch (const uno::RuntimeException&)
      96             :     {
      97             :         OSL_FAIL("name wasn't changed");
      98             :     }
      99           0 :     EndDialog(RET_OK);
     100           0 :     return 0;
     101             : }
     102             : 
     103           0 : IMPL_LINK(SwRenameXNamedDlg, ModifyHdl, Edit*, pEdit)
     104             : {
     105           0 :     OUString sTmp(pEdit->GetText());
     106             : 
     107           0 :     m_pOk->Enable(!sTmp.isEmpty()
     108           0 :                   && !xNameAccess->hasByName(sTmp)
     109           0 :                   && (!xSecondAccess.is() || !xSecondAccess->hasByName(sTmp))
     110           0 :                   && (!xThirdAccess.is() || !xThirdAccess->hasByName(sTmp))
     111           0 :                  );
     112           0 :     return 0;
     113           0 : }
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11