LCOV - code coverage report
Current view: top level - sw/source/core/uibase/web - wview.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 129 0.0 %
Date: 2014-04-14 Functions: 0 18 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 <sfx2/msg.hxx>
      21             : #include <svl/srchitem.hxx>
      22             : #include <sfx2/dispatch.hxx>
      23             : #include <sfx2/infobar.hxx>
      24             : #include <sfx2/templdlg.hxx>
      25             : #include <svx/srchdlg.hxx>
      26             : #include <basic/sbxobj.hxx>
      27             : #include <uivwimp.hxx>
      28             : #include <svx/fmshell.hxx>
      29             : #include <svx/extrusionbar.hxx>
      30             : #include <svx/fontworkbar.hxx>
      31             : 
      32             : #include <sfx2/objface.hxx>
      33             : #include <swmodule.hxx>
      34             : #include <unotxvw.hxx>
      35             : #include <swtypes.hxx>
      36             : #include <cmdid.h>
      37             : #include <globals.hrc>
      38             : #include <wrtsh.hxx>
      39             : #include <edtwin.hxx>
      40             : #include <wgrfsh.hxx>
      41             : #include <wfrmsh.hxx>
      42             : #include <wolesh.hxx>
      43             : #include <wtabsh.hxx>
      44             : #include <wlistsh.hxx>
      45             : #include <wformsh.hxx>
      46             : #include <wtextsh.hxx>
      47             : #include <barcfg.hxx>
      48             : #include <doc.hxx>
      49             : 
      50             : // TECHNICALLY not possible !!
      51             : #include <beziersh.hxx>
      52             : #include <drawsh.hxx>
      53             : #include <drwtxtsh.hxx>
      54             : #include <annotsh.hxx>
      55             : 
      56             : #include <wview.hxx>
      57             : #include <wdocsh.hxx>
      58             : #include <web.hrc>
      59             : #include <shells.hrc>
      60             : 
      61             : #define SwWebView
      62             : #define Text
      63             : #define TextInTable
      64             : #define ListInText
      65             : #define ListInTable
      66             : #include <swslots.hxx>
      67             : 
      68           0 : SFX_IMPL_NAMED_VIEWFACTORY(SwWebView, "Default")
      69             : {
      70           0 :     SFX_VIEW_REGISTRATION(SwWebDocShell);
      71           0 : }
      72             : 
      73           0 : SFX_IMPL_INTERFACE( SwWebView, SwView, SW_RES(RID_WEBTOOLS_TOOLBOX) )
      74             : {
      75           0 :     SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
      76           0 :     SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
      77           0 :     SFX_CHILDWINDOW_REGISTRATION(SfxInfoBarContainerChild::GetChildWindowId());
      78           0 :     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
      79             :                                 SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
      80           0 :                                 SW_RES(RID_WEBTOOLS_TOOLBOX) );
      81           0 : }
      82             : 
      83           0 : TYPEINIT1(SwWebView,SwView)
      84             : 
      85           0 : SwWebView::SwWebView(SfxViewFrame* _pFrame, SfxViewShell* _pShell) :
      86           0 :     SwView(_pFrame, _pShell)
      87             : {
      88           0 : }
      89             : 
      90           0 : SwWebView::~SwWebView()
      91             : {
      92           0 : }
      93             : 
      94           0 : void SwWebView::SelectShell()
      95             : {
      96             :     // Decision whether UpdateTable must be called
      97           0 :     bool bUpdateTable = false;
      98           0 :     const SwFrmFmt* pCurTableFmt = GetWrtShell().GetTableFmt();
      99           0 :     if(pCurTableFmt && pCurTableFmt != GetLastTblFrmFmt())
     100             :     {
     101           0 :         bUpdateTable = true; // can only be executed later
     102             :     }
     103           0 :     SetLastTblFrmFmt(pCurTableFmt);
     104             :     //SEL_TBL and SEL_TBL_CELLS can be ored!
     105           0 :     int nNewSelectionType = (GetWrtShell().GetSelectionType()
     106           0 :                                 & ~nsSelectionType::SEL_TBL_CELLS);
     107             : 
     108           0 :     int _nSelectionType = GetSelectionType();
     109           0 :     if ( nNewSelectionType == _nSelectionType )
     110             :     {
     111           0 :         GetViewFrame()->GetBindings().InvalidateAll( false );
     112           0 :         if ( _nSelectionType & nsSelectionType::SEL_OLE ||
     113           0 :              _nSelectionType & nsSelectionType::SEL_GRF )
     114             :             //The verb may of course change for graphics and OLE!
     115           0 :             ImpSetVerb( nNewSelectionType );
     116             :     }
     117             :     else
     118             :     {
     119           0 :         SfxDispatcher &rDispatcher = *GetViewFrame()->GetDispatcher();
     120           0 :         SwToolbarConfigItem *pBarCfg = SW_MOD()->GetWebToolbarConfig();
     121             : 
     122           0 :         if( GetCurShell() )
     123             :         {
     124           0 :             rDispatcher.Flush();        // really delete all cached shells
     125             : 
     126             :             //Additional to the old selection remember which toolbar was visible.
     127           0 :             sal_Int32 nId = rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT );
     128           0 :             if ( nId )
     129           0 :                 pBarCfg->SetTopToolbar( _nSelectionType, nId );
     130             : 
     131             :             SfxShell *pSfxShell;
     132             :             sal_uInt16 i;
     133           0 :             for ( i = 0; true; ++i )
     134             :             {
     135           0 :                 pSfxShell = rDispatcher.GetShell( i );
     136           0 :                 if ( !( pSfxShell->ISA( SwBaseShell ) ||
     137           0 :                     pSfxShell->ISA( SwDrawTextShell ) || pSfxShell->ISA( SwAnnotationShell ) ) )
     138           0 :                     break;
     139             :             }
     140           0 :             pSfxShell = rDispatcher.GetShell( --i );
     141             :             OSL_ENSURE( pSfxShell, "My Shell ist lost in space" );
     142           0 :             rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE);
     143             :         }
     144             : 
     145           0 :         bool bInitFormShell = false;
     146           0 :         if( !GetFormShell() )
     147             :         {
     148           0 :             bInitFormShell = true;
     149           0 :             SetFormShell( new FmFormShell( this ) );
     150           0 :             rDispatcher.Push( *GetFormShell() );
     151             :         }
     152             : 
     153           0 :         bool bSetExtInpCntxt = false;
     154           0 :         _nSelectionType = nNewSelectionType;
     155           0 :         SetSelectionType( _nSelectionType );
     156             :         ShellModes eShellMode;
     157             : 
     158           0 :         if ( _nSelectionType & nsSelectionType::SEL_OLE )
     159             :         {
     160           0 :             eShellMode = SHELL_MODE_OBJECT;
     161           0 :             SetShell( new SwWebOleShell( *this ));
     162           0 :             rDispatcher.Push( *GetCurShell() );
     163             :         }
     164           0 :         else if ( _nSelectionType & nsSelectionType::SEL_FRM
     165           0 :             || _nSelectionType & nsSelectionType::SEL_GRF)
     166             :         {
     167           0 :             eShellMode = SHELL_MODE_FRAME;
     168           0 :             SetShell( new SwWebFrameShell( *this ));
     169           0 :             rDispatcher.Push( *GetCurShell() );
     170           0 :             if(_nSelectionType & nsSelectionType::SEL_GRF )
     171             :             {
     172           0 :                 eShellMode = SHELL_MODE_GRAPHIC;
     173           0 :                 SetShell( new SwWebGrfShell( *this ));
     174           0 :                 rDispatcher.Push( *GetCurShell() );
     175             :             }
     176             :         }
     177           0 :         else if ( _nSelectionType & nsSelectionType::SEL_FRM )
     178             :         {
     179           0 :             eShellMode = SHELL_MODE_FRAME;
     180           0 :             SetShell( new SwWebFrameShell( *this ));
     181           0 :             rDispatcher.Push( *GetCurShell() );
     182             :         }
     183           0 :         else if ( _nSelectionType & nsSelectionType::SEL_DRW )
     184             :         {
     185           0 :             eShellMode = SHELL_MODE_DRAW;
     186           0 :             SetShell( new svx::ExtrusionBar( this ) );
     187           0 :             rDispatcher.Push( *GetCurShell() );
     188             : 
     189           0 :             SetShell( new svx::FontworkBar( this ) );
     190           0 :             rDispatcher.Push( *GetCurShell() );
     191             : 
     192           0 :             SetShell( new SwDrawShell( *this ));
     193           0 :             rDispatcher.Push( *GetCurShell() );
     194           0 :             if ( _nSelectionType & nsSelectionType::SEL_BEZ )
     195             :             {
     196           0 :                 eShellMode = SHELL_MODE_BEZIER;
     197           0 :                 SetShell( new SwBezierShell( *this ));
     198           0 :                 rDispatcher.Push( *GetCurShell() );
     199             :             }
     200             : 
     201             :         }
     202           0 :         else if ( _nSelectionType & nsSelectionType::SEL_DRW_FORM )
     203             :         {
     204           0 :             eShellMode = SHELL_MODE_DRAW_FORM;
     205           0 :             SetShell( new SwWebDrawFormShell( *this ));
     206             : 
     207           0 :             rDispatcher.Push( *GetCurShell() );
     208             :         }
     209           0 :         else if ( _nSelectionType & nsSelectionType::SEL_DRW_TXT )
     210             :         {
     211           0 :             eShellMode = SHELL_MODE_DRAWTEXT;
     212           0 :             rDispatcher.Push( *(new SwBaseShell( *this )) );
     213           0 :             SetShell( new SwDrawTextShell( *this ));
     214           0 :             rDispatcher.Push( *GetCurShell() );
     215             :         }
     216           0 :         else if ( _nSelectionType & nsSelectionType::SEL_POSTIT )
     217             :         {
     218           0 :             eShellMode = SHELL_MODE_POSTIT;
     219           0 :             SetShell( new SwAnnotationShell( *this ) );
     220           0 :             rDispatcher.Push( *GetCurShell() );
     221             :         }
     222             :         else
     223             :         {
     224           0 :             bSetExtInpCntxt = true;
     225           0 :             eShellMode = SHELL_MODE_TEXT;
     226           0 :             if ( _nSelectionType & nsSelectionType::SEL_NUM )
     227             :             {
     228           0 :                 eShellMode = SHELL_MODE_LIST_TEXT;
     229           0 :                 SetShell( new SwWebListShell( *this ));
     230           0 :                 rDispatcher.Push( *GetCurShell() );
     231             :             }
     232           0 :             SetShell( new SwWebTextShell(*this));
     233           0 :             rDispatcher.Push( *GetCurShell() );
     234           0 :             if ( _nSelectionType & nsSelectionType::SEL_TBL )
     235             :             {
     236             :                 eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
     237           0 :                                                         : SHELL_MODE_TABLE_TEXT;
     238           0 :                 SetShell( new SwWebTableShell( *this ));
     239           0 :                 rDispatcher.Push( *GetCurShell() );
     240             :             }
     241             :         }
     242           0 :         ImpSetVerb( _nSelectionType );
     243           0 :         GetViewImpl()->SetShellMode(eShellMode);
     244             : 
     245           0 :         if( !GetDocShell()->IsReadOnly() )
     246             :         {
     247           0 :             if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
     248           0 :                 bSetExtInpCntxt = false;
     249             : 
     250           0 :             InputContext aCntxt( GetEditWin().GetInputContext() );
     251             :             aCntxt.SetOptions( bSetExtInpCntxt
     252           0 :                                 ? (aCntxt.GetOptions() |
     253             :                                         ( INPUTCONTEXT_TEXT |
     254             :                                             INPUTCONTEXT_EXTTEXTINPUT ))
     255           0 :                                 : (aCntxt.GetOptions() & ~
     256             :                                         ( INPUTCONTEXT_TEXT |
     257           0 :                                             INPUTCONTEXT_EXTTEXTINPUT )) );
     258           0 :             GetEditWin().SetInputContext( aCntxt );
     259             :         }
     260             : 
     261             :         //Additional to the selection enable the toolbar, which was
     262             :         //activated last time
     263             :         //Before must be a Flush(), but concerns according to MBA not the
     264             :         //user interface and is not a performance issue.
     265             :         // TODO/LATER: maybe now the Flush() command is superfluous?!
     266           0 :         rDispatcher.Flush();
     267             : 
     268           0 :         Point aPnt = GetEditWin().GetPointerPosPixel();
     269           0 :         aPnt = GetEditWin().PixelToLogic(aPnt);
     270           0 :         GetEditWin().UpdatePointer(aPnt);
     271             : 
     272           0 :         if ( bInitFormShell && GetWrtShell().GetDrawView() )
     273           0 :             GetFormShell()->SetView( PTR_CAST( FmFormView,
     274           0 :                                                 GetWrtShell().GetDrawView()));
     275             : 
     276             :     }
     277           0 :     GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
     278             : 
     279             :     //Opportune time for the communication with OLE objects?
     280           0 :     if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
     281           0 :         GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
     282             : 
     283             :     //now the table update
     284           0 :     if(bUpdateTable)
     285           0 :         GetWrtShell().UpdateTable();
     286           0 : }
     287             : 
     288             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10