LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/utlui - swrenamexnameddlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 37 0.0 %
Date: 2012-12-27 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 <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             : 
      53             : using namespace ::com::sun::star;
      54             : using ::rtl::OUString;
      55             : 
      56           0 : SwRenameXNamedDlg::SwRenameXNamedDlg( Window* pWin,
      57             :             uno::Reference< container::XNamed > & xN,
      58             :             uno::Reference< container::XNameAccess > & xNA ) :
      59             :     ModalDialog(pWin, SW_RES(DLG_RENAME_XNAMED)),
      60             :    aNameFL(this, SW_RES(FL_NAME)),
      61             :     aNewNameFT(this, SW_RES(FT_NEW_NAME)),
      62             :    aNewNameED(this, SW_RES(ED_NEW_NAME)),
      63             :    aOk(this, SW_RES(PB_OK)),
      64             :    aCancel(this, SW_RES(PB_CANCEL)),
      65             :    aHelp(this, SW_RES(PB_HELP)),
      66             :    xNamed(xN),
      67           0 :    xNameAccess(xNA)
      68             : {
      69           0 :     FreeResource();
      70           0 :     sRemoveWarning = String(SW_RES(STR_REMOVE_WARNING));
      71             : 
      72           0 :     String sTmp(GetText());
      73           0 :     aNewNameED.SetText(xNamed->getName());
      74           0 :     aNewNameED.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
      75           0 :     sTmp += String(xNamed->getName());
      76           0 :     SetText(sTmp);
      77             : 
      78           0 :     aOk.SetClickHdl(LINK(this, SwRenameXNamedDlg, OkHdl));
      79           0 :     aNewNameED.SetModifyHdl(LINK(this, SwRenameXNamedDlg, ModifyHdl));
      80           0 :     aOk.Enable(sal_False);
      81           0 : }
      82             : 
      83           0 : IMPL_LINK_NOARG(SwRenameXNamedDlg, OkHdl)
      84             : {
      85             :     try
      86             :     {
      87           0 :         xNamed->setName(aNewNameED.GetText());
      88             :     }
      89           0 :     catch (const uno::RuntimeException&)
      90             :     {
      91             :         OSL_FAIL("name wasn't changed");
      92             :     }
      93           0 :     EndDialog(RET_OK);
      94           0 :     return 0;
      95             : }
      96             : 
      97           0 : IMPL_LINK(SwRenameXNamedDlg, ModifyHdl, NoSpaceEdit*, pEdit)
      98             : {
      99           0 :     String sTmp(pEdit->GetText());
     100             : 
     101             :     // prevent from pasting illegal characters
     102           0 :     sal_uInt16 nLen = sTmp.Len();
     103           0 :     String sMsg;
     104           0 :     for(sal_uInt16 i = 0; i < pEdit->GetForbiddenChars().Len(); i++)
     105             :     {
     106           0 :         sal_uInt16 nTmpLen = sTmp.Len();
     107           0 :         sTmp = comphelper::string::remove(sTmp, pEdit->GetForbiddenChars().GetChar(i));
     108           0 :         if(sTmp.Len() != nTmpLen)
     109           0 :             sMsg += pEdit->GetForbiddenChars().GetChar(i);
     110             :     }
     111           0 :     if(sTmp.Len() != nLen)
     112             :     {
     113           0 :         pEdit->SetText(sTmp);
     114           0 :         String sWarning(sRemoveWarning);
     115           0 :         sWarning += sMsg;
     116           0 :         InfoBox(this, sWarning).Execute();
     117             :     }
     118             : 
     119           0 :     aOk.Enable(sTmp.Len() && !xNameAccess->hasByName(sTmp)
     120           0 :     && (!xSecondAccess.is() || !xSecondAccess->hasByName(sTmp))
     121           0 :     && (!xThirdAccess.is() || !xThirdAccess->hasByName(sTmp))
     122           0 :     );
     123           0 :     return 0;
     124             : }
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10