LCOV - code coverage report
Current view: top level - sw/source/ui/utlui - swrenamexnameddlg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 36 0.0 %
Date: 2014-04-14 Functions: 0 5 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 <../../core/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( 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             :     , m_sRemoveWarning(SW_RESSTR(STR_REMOVE_WARNING))
      60             :     , xNamed(xN)
      61           0 :     , xNameAccess(xNA)
      62             : {
      63           0 :     get(m_pNewNameED, "entry");
      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 : IMPL_LINK_NOARG(SwRenameXNamedDlg, OkHdl)
      78             : {
      79             :     try
      80             :     {
      81           0 :         xNamed->setName(m_pNewNameED->GetText());
      82             :     }
      83           0 :     catch (const uno::RuntimeException&)
      84             :     {
      85             :         OSL_FAIL("name wasn't changed");
      86             :     }
      87           0 :     EndDialog(RET_OK);
      88           0 :     return 0;
      89             : }
      90             : 
      91           0 : IMPL_LINK(SwRenameXNamedDlg, ModifyHdl, NoSpaceEdit*, pEdit)
      92             : {
      93           0 :     OUString sTmp(pEdit->GetText());
      94             : 
      95             :     // prevent from pasting illegal characters
      96           0 :     const sal_Int32 nLen = sTmp.getLength();
      97           0 :     OUString sMsg;
      98           0 :     for(sal_Int32 i = 0; i < pEdit->GetForbiddenChars().getLength(); ++i)
      99             :     {
     100           0 :         const sal_Int32 nTmpLen = sTmp.getLength();
     101           0 :         sTmp = comphelper::string::remove(sTmp, pEdit->GetForbiddenChars()[i]);
     102           0 :         if(sTmp.getLength() != nTmpLen)
     103           0 :             sMsg += OUString(pEdit->GetForbiddenChars()[i]);
     104             :     }
     105           0 :     if(sTmp.getLength() != nLen)
     106             :     {
     107           0 :         pEdit->SetText(sTmp);
     108           0 :         InfoBox(this, m_sRemoveWarning + sMsg).Execute();
     109             :     }
     110             : 
     111           0 :     m_pOk->Enable(!sTmp.isEmpty()
     112           0 :                   && !xNameAccess->hasByName(sTmp)
     113           0 :                   && (!xSecondAccess.is() || !xSecondAccess->hasByName(sTmp))
     114           0 :                   && (!xThirdAccess.is() || !xThirdAccess->hasByName(sTmp))
     115           0 :                  );
     116           0 :     return 0;
     117             : }
     118             : 
     119             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10