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

Generated by: LCOV version 1.11