LCOV - code coverage report
Current view: top level - libreoffice/basctl/source/basicide - basides2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 118 0.0 %
Date: 2012-12-27 Functions: 0 11 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 "docsignature.hxx"
      21             : 
      22             : #include <basic/sbx.hxx>
      23             : #include "basicrenderable.hxx"
      24             : 
      25             : #include <com/sun/star/frame/XTitle.hpp>
      26             : 
      27             : #include <basidesh.hxx>
      28             : #include <basidesh.hrc>
      29             : #include <baside2.hxx>
      30             : #include <basdoc.hxx>
      31             : #include <basobj.hxx>
      32             : #include <vcl/texteng.hxx>
      33             : #include <vcl/textview.hxx>
      34             : #include <vcl/xtextedt.hxx>
      35             : #include <tools/diagnose_ex.h>
      36             : #include <sfx2/childwin.hxx>
      37             : #include <sfx2/dispatch.hxx>
      38             : #include <sfx2/sfxdefs.hxx>
      39             : #include <sfx2/signaturestate.hxx>
      40             : #include <com/sun/star/container/XNameContainer.hpp>
      41             : #include <com/sun/star/container/XNamed.hpp>
      42             : #include <com/sun/star/lang/XServiceInfo.hpp>
      43             : 
      44             : namespace basctl
      45             : {
      46             : 
      47             : using namespace ::com::sun::star;
      48             : using namespace ::com::sun::star::uno;
      49             : 
      50           0 : Reference< view::XRenderable > Shell::GetRenderable()
      51             : {
      52           0 :     return Reference<view::XRenderable>( new Renderable(pCurWin) );
      53             : }
      54             : 
      55           0 : sal_Bool Shell::HasSelection( sal_Bool /* bText */ ) const
      56             : {
      57           0 :     if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
      58             :     {
      59           0 :         TextView* pEditView = pMCurWin->GetEditView();
      60           0 :         if ( pEditView && pEditView->HasSelection() )
      61           0 :             return true;
      62             :     }
      63           0 :     return false;
      64             : }
      65             : 
      66           0 : String Shell::GetSelectionText( sal_Bool bWholeWord )
      67             : {
      68           0 :     String aText;
      69           0 :     if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
      70             :     {
      71           0 :         if (TextView* pEditView = pMCurWin->GetEditView())
      72             :         {
      73           0 :             if ( bWholeWord && !pEditView->HasSelection() )
      74             :             {
      75           0 :                 aText = pEditView->GetTextEngine()->GetWord( pEditView->GetSelection().GetEnd() );
      76             :             }
      77             :             else
      78             :             {
      79           0 :                 TextSelection aSel = pEditView->GetSelection();
      80           0 :                 if ( !bWholeWord || ( aSel.GetStart().GetPara() == aSel.GetEnd().GetPara() ) )
      81           0 :                     aText = pEditView->GetSelected();
      82             :             }
      83             :         }
      84             :     }
      85           0 :     return aText;
      86             : }
      87             : 
      88           0 : SfxPrinter* Shell::GetPrinter( sal_Bool bCreate )
      89             : {
      90           0 :     if ( pCurWin )
      91             :     {
      92           0 :         DocShell* pDocShell = (DocShell*)GetViewFrame()->GetObjectShell();
      93             :         DBG_ASSERT( pDocShell, "DocShell ?!" );
      94           0 :         return pDocShell->GetPrinter( bCreate );
      95             :     }
      96           0 :     return 0;
      97             : }
      98             : 
      99           0 : sal_uInt16 Shell::SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags, bool )
     100             : {
     101             :     (void)nDiffFlags;
     102           0 :     DocShell* pDocShell = (DocShell*)GetViewFrame()->GetObjectShell();
     103             :     DBG_ASSERT( pDocShell, "DocShell ?!" );
     104           0 :     pDocShell->SetPrinter( pNewPrinter );
     105           0 :     return 0;
     106             : }
     107             : 
     108           0 : void Shell::SetMDITitle()
     109             : {
     110           0 :     OUStringBuffer aTitleBuf;
     111           0 :     if ( !m_aCurLibName.isEmpty() )
     112             :     {
     113           0 :         LibraryLocation eLocation = m_aCurDocument.getLibraryLocation( m_aCurLibName );
     114           0 :         aTitleBuf.append(m_aCurDocument.getTitle(eLocation));
     115           0 :         aTitleBuf.append('.');
     116           0 :         aTitleBuf.append(m_aCurLibName);
     117             :     }
     118             :     else
     119           0 :         aTitleBuf.append(IDE_RESSTR(RID_STR_ALL));
     120             : 
     121           0 :     DocumentSignature aCurSignature( m_aCurDocument );
     122           0 :     if ( aCurSignature.getScriptingSignatureState() == SIGNATURESTATE_SIGNATURES_OK )
     123             :     {
     124           0 :         aTitleBuf.append(' ');
     125           0 :         aTitleBuf.append(IDE_RESSTR(RID_STR_SIGNED));
     126           0 :         aTitleBuf.append(' ');
     127             :     }
     128           0 :     OUString aTitle(aTitleBuf.makeStringAndClear());
     129             : 
     130           0 :     SfxViewFrame* pViewFrame = GetViewFrame();
     131           0 :     if ( pViewFrame )
     132             :     {
     133           0 :         SfxObjectShell* pShell = pViewFrame->GetObjectShell();
     134           0 :         if ( pShell && !pShell->GetTitle( SFX_TITLE_CAPTION ).Equals(aTitle) )
     135             :         {
     136           0 :             pShell->SetTitle( aTitle );
     137           0 :             pShell->SetModified(false);
     138             :         }
     139             : 
     140           0 :         css::uno::Reference< css::frame::XController > xController = GetController ();
     141           0 :         css::uno::Reference< css::frame::XTitle >      xTitle      (xController, css::uno::UNO_QUERY);
     142           0 :         if (xTitle.is ())
     143           0 :             xTitle->setTitle (aTitle);
     144           0 :     }
     145           0 : }
     146             : 
     147           0 : ModulWindow* Shell::CreateBasWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rModName )
     148             : {
     149           0 :     bCreatingWindow = true;
     150             : 
     151           0 :     sal_uLong nKey = 0;
     152           0 :     ModulWindow* pWin = 0;
     153             : 
     154           0 :     OUString aLibName( rLibName );
     155           0 :     OUString aModName( rModName );
     156             : 
     157           0 :     if ( aLibName.isEmpty() )
     158           0 :         aLibName = "Standard" ;
     159             : 
     160           0 :     uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
     161             : 
     162           0 :     if ( aModName.isEmpty() )
     163           0 :         aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
     164             : 
     165             :     // maybe there's an suspended one?
     166           0 :     pWin = FindBasWin( rDocument, aLibName, aModName, false, true );
     167             : 
     168           0 :     if ( !pWin )
     169             :     {
     170           0 :         OUString aModule;
     171           0 :         bool bSuccess = false;
     172           0 :         if ( rDocument.hasModule( aLibName, aModName ) )
     173           0 :             bSuccess = rDocument.getModule( aLibName, aModName, aModule );
     174             :         else
     175           0 :             bSuccess = rDocument.createModule( aLibName, aModName, true, aModule );
     176             : 
     177           0 :         if ( bSuccess )
     178             :         {
     179           0 :             pWin = FindBasWin( rDocument, aLibName, aModName, false, true );
     180           0 :             if( !pWin )
     181             :             {
     182             :                 // new module window
     183           0 :                 if (!pModulLayout)
     184           0 :                     pModulLayout.reset(new ModulWindowLayout(&GetViewFrame()->GetWindow(), aObjectCatalog));
     185           0 :                 pWin = new ModulWindow(pModulLayout.get(), rDocument, aLibName, aModName, aModule);
     186           0 :                 nKey = InsertWindowInTable( pWin );
     187             :             }
     188             :             else // we've gotten called recursively ( via listener from createModule above ), get outta here
     189           0 :                 return pWin;
     190           0 :         }
     191             :     }
     192             :     else
     193             :     {
     194           0 :         pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED );
     195           0 :         nKey = GetWindowId( pWin );
     196             :         DBG_ASSERT( nKey, "CreateBasWin: Kein Key- Fenster nicht gefunden!" );
     197             :     }
     198           0 :     if( nKey && xLib.is() && rDocument.isInVBAMode() )
     199             :     {
     200             :         // display a nice friendly name in the ObjectModule tab,
     201             :         // combining the objectname and module name, e.g. Sheet1 ( Financials )
     202           0 :         OUString sObjName;
     203           0 :         ModuleInfoHelper::getObjectName( xLib, rModName, sObjName );
     204           0 :         if( !sObjName.isEmpty() )
     205             :         {
     206           0 :             OUStringBuffer aModNameBuf(aModName);
     207           0 :             aModNameBuf.append(' ');
     208           0 :             aModNameBuf.append('(');
     209           0 :             aModNameBuf.append(sObjName);
     210           0 :             aModNameBuf.append(')');
     211           0 :             aModName = aModNameBuf.makeStringAndClear();
     212           0 :         }
     213             :     }
     214           0 :     pTabBar->InsertPage( (sal_uInt16)nKey, aModName );
     215           0 :     pTabBar->Sort();
     216           0 :     pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar );
     217           0 :     if ( !pCurWin )
     218           0 :         SetCurWindow( pWin, false, false );
     219             : 
     220           0 :     bCreatingWindow = false;
     221           0 :     return pWin;
     222             : }
     223             : 
     224           0 : ModulWindow* Shell::FindBasWin (
     225             :     ScriptDocument const& rDocument,
     226             :     OUString const& rLibName, OUString const& rName,
     227             :     bool bCreateIfNotExist, bool bFindSuspended
     228             : )
     229             : {
     230           0 :     if (BaseWindow* pWin = FindWindow(rDocument, rLibName, rName, TYPE_MODULE, bFindSuspended))
     231           0 :         return static_cast<ModulWindow*>(pWin);
     232           0 :     return bCreateIfNotExist ? CreateBasWin(rDocument, rLibName, rName) : 0;
     233             : }
     234             : 
     235           0 : void Shell::Move()
     236             : {
     237           0 :     if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
     238           0 :         pMCurWin->FrameWindowMoved();
     239           0 : }
     240             : 
     241           0 : void Shell::ShowCursor( bool bOn )
     242             : {
     243           0 :     if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
     244           0 :         pMCurWin->ShowCursor(bOn);
     245           0 : }
     246             : 
     247             : // only if basic window above:
     248           0 : void Shell::ExecuteBasic( SfxRequest& rReq )
     249             : {
     250           0 :     if (dynamic_cast<ModulWindow*>(pCurWin))
     251             :     {
     252           0 :         pCurWin->ExecuteCommand( rReq );
     253           0 :         if (nShellCount)
     254           0 :             CheckWindows();
     255             :     }
     256           0 : }
     257             : 
     258             : } // namespace basctl
     259             : 
     260             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10