LCOV - code coverage report
Current view: top level - sw/source/ui/web - wview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 69 127 54.3 %
Date: 2012-08-25 Functions: 14 16 87.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 71 260 27.3 %

           Branch data     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/templdlg.hxx>
      24                 :            : #include <svx/srchdlg.hxx>
      25                 :            : #include <basic/sbxobj.hxx>
      26                 :            : #include <uivwimp.hxx>
      27                 :            : #include <svx/fmshell.hxx>
      28                 :            : #include <svx/extrusionbar.hxx>
      29                 :            : #include <svx/fontworkbar.hxx>
      30                 :            : 
      31                 :            : #include <sfx2/objface.hxx>
      32                 :            : #include <swmodule.hxx>
      33                 :            : #include <unotxvw.hxx>
      34                 :            : #include <swtypes.hxx>
      35                 :            : #include <cmdid.h>
      36                 :            : #include <globals.hrc>
      37                 :            : #include <wrtsh.hxx>
      38                 :            : #include <edtwin.hxx>
      39                 :            : #include <wgrfsh.hxx>
      40                 :            : #include <wfrmsh.hxx>
      41                 :            : #include <wolesh.hxx>
      42                 :            : #include <wtabsh.hxx>
      43                 :            : #include <wlistsh.hxx>
      44                 :            : #include <wformsh.hxx>
      45                 :            : #include <wtextsh.hxx>
      46                 :            : #include <barcfg.hxx>
      47                 :            : #include <doc.hxx>
      48                 :            : 
      49                 :            : // EIGENTLICH nicht moeglich !!
      50                 :            : #include <beziersh.hxx>
      51                 :            : #include <drawsh.hxx>
      52                 :            : #include <drwtxtsh.hxx>
      53                 :            : #include <annotsh.hxx>
      54                 :            : 
      55                 :            : #include <wview.hxx>
      56                 :            : #include <wdocsh.hxx>
      57                 :            : #include <web.hrc>
      58                 :            : #include <shells.hrc>
      59                 :            : 
      60                 :            : #define SwWebView
      61                 :            : #define Frames
      62                 :            : #define Graphics
      63                 :            : #define OLEObjects
      64                 :            : #define Controls
      65                 :            : #define Text
      66                 :            : #define Frame
      67                 :            : #define Graphic
      68                 :            : #define Object
      69                 :            : #define Draw
      70                 :            : #define DrawText
      71                 :            : #define TextInTable
      72                 :            : #define ListInText
      73                 :            : #define ListInTable
      74                 :            : #define Page
      75                 :            : #include <swslots.hxx>
      76                 :            : 
      77                 :            : 
      78 [ +  - ][ +  - ]:         77 : SFX_IMPL_NAMED_VIEWFACTORY(SwWebView, "Default")
      79                 :            : {
      80                 :         73 :     SFX_VIEW_REGISTRATION(SwWebDocShell);
      81                 :         73 : }
      82                 :            : 
      83 [ +  + ][ +  - ]:       1283 : SFX_IMPL_INTERFACE( SwWebView, SwView, SW_RES(RID_WEBTOOLS_TOOLBOX) )
         [ +  - ][ +  - ]
      84                 :            : {
      85                 :         73 :     SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
      86                 :         73 :     SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
      87         [ +  - ]:         73 :     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
      88                 :            :                                 SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
      89         [ +  - ]:         73 :                                 SW_RES(RID_WEBTOOLS_TOOLBOX) );
      90                 :         73 : }
      91                 :            : 
      92 [ +  + ][ +  + ]:      13582 : TYPEINIT1(SwWebView,SwView)
      93                 :            : 
      94                 :          4 : SwWebView::SwWebView(SfxViewFrame* _pFrame, SfxViewShell* _pShell) :
      95                 :          4 :     SwView(_pFrame, _pShell)
      96                 :            : {
      97                 :          4 : }
      98                 :            : 
      99                 :          4 : SwWebView::~SwWebView()
     100                 :            : {
     101         [ -  + ]:          8 : }
     102                 :            : 
     103                 :          8 : void SwWebView::SelectShell()
     104                 :            : {
     105                 :            :     // Entscheidung, ob UpdateTable gerufen werden muss
     106                 :          8 :     sal_Bool bUpdateTable = sal_False;
     107                 :          8 :     const SwFrmFmt* pCurTableFmt = GetWrtShell().GetTableFmt();
     108 [ #  # ][ -  + ]:          8 :     if(pCurTableFmt && pCurTableFmt != GetLastTblFrmFmt())
                 [ -  + ]
     109                 :            :     {
     110                 :          0 :         bUpdateTable = sal_True; // kann erst spaeter ausgefuehrt werden
     111                 :            :     }
     112                 :          8 :     SetLastTblFrmFmt(pCurTableFmt);
     113                 :            :     //SEL_TBL und SEL_TBL_CELLS koennen verodert sein!
     114                 :          8 :     int nNewSelectionType = (GetWrtShell().GetSelectionType()
     115                 :          8 :                                 & ~nsSelectionType::SEL_TBL_CELLS);
     116                 :            : 
     117                 :          8 :     int _nSelectionType = GetSelectionType();
     118         [ +  + ]:          8 :     if ( nNewSelectionType == _nSelectionType )
     119                 :            :     {
     120                 :          4 :         GetViewFrame()->GetBindings().InvalidateAll( sal_False );
     121 [ -  + ][ +  - ]:          4 :         if ( _nSelectionType & nsSelectionType::SEL_OLE ||
     122                 :            :              _nSelectionType & nsSelectionType::SEL_GRF )
     123                 :            :             //Fuer Grafiken und OLE kann sich natuerlich das Verb aendern!
     124                 :          0 :             ImpSetVerb( nNewSelectionType );
     125                 :            :     }
     126                 :            :     else
     127                 :            :     {
     128                 :          4 :         SfxDispatcher &rDispatcher = *GetViewFrame()->GetDispatcher();
     129         [ +  - ]:          4 :         SwToolbarConfigItem *pBarCfg = SW_MOD()->GetWebToolbarConfig();
     130                 :            : 
     131         [ -  + ]:          4 :         if( GetCurShell() )
     132                 :            :         {
     133         [ #  # ]:          0 :             rDispatcher.Flush();        // alle gecachten Shells wirklich loeschen
     134                 :            : 
     135                 :            :             //Zur alten Selektion merken welche Toolbar sichtbar war
     136         [ #  # ]:          0 :             sal_Int32 nId = rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT );
     137         [ #  # ]:          0 :             if ( nId )
     138         [ #  # ]:          0 :                 pBarCfg->SetTopToolbar( _nSelectionType, nId );
     139                 :            : 
     140                 :            :             SfxShell *pSfxShell;
     141                 :            :             sal_uInt16 i;
     142                 :          0 :             for ( i = 0; sal_True; ++i )
     143                 :            :             {
     144         [ #  # ]:          0 :                 pSfxShell = rDispatcher.GetShell( i );
     145 [ #  # ][ #  # ]:          0 :                 if ( !( pSfxShell->ISA( SwBaseShell ) ||
                 [ #  # ]
     146 [ #  # ][ #  # ]:          0 :                     pSfxShell->ISA( SwDrawTextShell ) || pSfxShell->ISA( SwAnnotationShell ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     147                 :          0 :                     break;
     148                 :            :             }
     149         [ #  # ]:          0 :             pSfxShell = rDispatcher.GetShell( --i );
     150                 :            :             OSL_ENSURE( pSfxShell, "My Shell ist lost in space" );
     151         [ #  # ]:          0 :             rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE);
     152                 :            :         }
     153                 :            : 
     154                 :          4 :         sal_Bool bInitFormShell = sal_False;
     155         [ +  - ]:          4 :         if( !GetFormShell() )
     156                 :            :         {
     157                 :          4 :             bInitFormShell = sal_True;
     158 [ +  - ][ +  - ]:          4 :             SetFormShell( new FmFormShell( this ) );
     159         [ +  - ]:          4 :             rDispatcher.Push( *GetFormShell() );
     160                 :            :         }
     161                 :            : 
     162                 :          4 :         sal_Bool bSetExtInpCntxt = sal_False;
     163                 :          4 :         _nSelectionType = nNewSelectionType;
     164                 :          4 :         SetSelectionType( _nSelectionType );
     165                 :            :         ShellModes eShellMode;
     166                 :            : 
     167         [ -  + ]:          4 :         if ( _nSelectionType & nsSelectionType::SEL_OLE )
     168                 :            :         {
     169                 :          0 :             eShellMode = SHELL_MODE_OBJECT;
     170 [ #  # ][ #  # ]:          0 :             SetShell( new SwWebOleShell( *this ));
     171         [ #  # ]:          0 :             rDispatcher.Push( *GetCurShell() );
     172                 :            :         }
     173 [ +  - ][ -  + ]:          4 :         else if ( _nSelectionType & nsSelectionType::SEL_FRM
     174                 :            :             || _nSelectionType & nsSelectionType::SEL_GRF)
     175                 :            :         {
     176                 :          0 :             eShellMode = SHELL_MODE_FRAME;
     177 [ #  # ][ #  # ]:          0 :             SetShell( new SwWebFrameShell( *this ));
     178         [ #  # ]:          0 :             rDispatcher.Push( *GetCurShell() );
     179         [ #  # ]:          0 :             if(_nSelectionType & nsSelectionType::SEL_GRF )
     180                 :            :             {
     181                 :          0 :                 eShellMode = SHELL_MODE_GRAPHIC;
     182 [ #  # ][ #  # ]:          0 :                 SetShell( new SwWebGrfShell( *this ));
     183         [ #  # ]:          0 :                 rDispatcher.Push( *GetCurShell() );
     184                 :            :             }
     185                 :            :         }
     186         [ -  + ]:          4 :         else if ( _nSelectionType & nsSelectionType::SEL_FRM )
     187                 :            :         {
     188                 :          0 :             eShellMode = SHELL_MODE_FRAME;
     189 [ #  # ][ #  # ]:          0 :             SetShell( new SwWebFrameShell( *this ));
     190         [ #  # ]:          0 :             rDispatcher.Push( *GetCurShell() );
     191                 :            :         }
     192         [ -  + ]:          4 :         else if ( _nSelectionType & nsSelectionType::SEL_DRW )
     193                 :            :         {
     194                 :          0 :             eShellMode = SHELL_MODE_DRAW;
     195 [ #  # ][ #  # ]:          0 :             SetShell( new svx::ExtrusionBar( this ) );
     196         [ #  # ]:          0 :             rDispatcher.Push( *GetCurShell() );
     197                 :            : 
     198                 :          0 :             eShellMode = SHELL_MODE_DRAW;
     199 [ #  # ][ #  # ]:          0 :             SetShell( new svx::FontworkBar( this ) );
     200         [ #  # ]:          0 :             rDispatcher.Push( *GetCurShell() );
     201                 :            : 
     202 [ #  # ][ #  # ]:          0 :             SetShell( new SwDrawShell( *this ));
     203         [ #  # ]:          0 :             rDispatcher.Push( *GetCurShell() );
     204         [ #  # ]:          0 :             if ( _nSelectionType & nsSelectionType::SEL_BEZ )
     205                 :            :             {
     206                 :          0 :                 eShellMode = SHELL_MODE_BEZIER;
     207 [ #  # ][ #  # ]:          0 :                 SetShell( new SwBezierShell( *this ));
     208         [ #  # ]:          0 :                 rDispatcher.Push( *GetCurShell() );
     209                 :            :             }
     210                 :            : 
     211                 :            :         }
     212         [ -  + ]:          4 :         else if ( _nSelectionType & nsSelectionType::SEL_DRW_FORM )
     213                 :            :         {
     214                 :          0 :             eShellMode = SHELL_MODE_DRAW_FORM;
     215 [ #  # ][ #  # ]:          0 :             SetShell( new SwWebDrawFormShell( *this ));
     216                 :            : 
     217         [ #  # ]:          0 :             rDispatcher.Push( *GetCurShell() );
     218                 :            :         }
     219         [ -  + ]:          4 :         else if ( _nSelectionType & nsSelectionType::SEL_DRW_TXT )
     220                 :            :         {
     221                 :          0 :             eShellMode = SHELL_MODE_DRAWTEXT;
     222 [ #  # ][ #  # ]:          0 :             rDispatcher.Push( *(new SwBaseShell( *this )) );
                 [ #  # ]
     223 [ #  # ][ #  # ]:          0 :             SetShell( new SwDrawTextShell( *this ));
     224         [ #  # ]:          0 :             rDispatcher.Push( *GetCurShell() );
     225                 :            :         }
     226         [ -  + ]:          4 :         else if ( _nSelectionType & nsSelectionType::SEL_POSTIT )
     227                 :            :         {
     228                 :          0 :             eShellMode = SHELL_MODE_POSTIT;
     229 [ #  # ][ #  # ]:          0 :             SetShell( new SwAnnotationShell( *this ) );
     230         [ #  # ]:          0 :             rDispatcher.Push( *GetCurShell() );
     231                 :            :         }
     232                 :            :         else
     233                 :            :         {
     234                 :          4 :             bSetExtInpCntxt = sal_True;
     235                 :          4 :             eShellMode = SHELL_MODE_TEXT;
     236         [ -  + ]:          4 :             if ( _nSelectionType & nsSelectionType::SEL_NUM )
     237                 :            :             {
     238                 :          0 :                 eShellMode = SHELL_MODE_LIST_TEXT;
     239 [ #  # ][ #  # ]:          0 :                 SetShell( new SwWebListShell( *this ));
     240         [ #  # ]:          0 :                 rDispatcher.Push( *GetCurShell() );
     241                 :            :             }
     242 [ +  - ][ +  - ]:          4 :             SetShell( new SwWebTextShell(*this));
     243         [ +  - ]:          4 :             rDispatcher.Push( *GetCurShell() );
     244         [ -  + ]:          4 :             if ( _nSelectionType & nsSelectionType::SEL_TBL )
     245                 :            :             {
     246                 :            :                 eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
     247         [ #  # ]:          0 :                                                         : SHELL_MODE_TABLE_TEXT;
     248 [ #  # ][ #  # ]:          0 :                 SetShell( new SwWebTableShell( *this ));
     249         [ #  # ]:          0 :                 rDispatcher.Push( *GetCurShell() );
     250                 :            :             }
     251                 :            :         }
     252         [ +  - ]:          4 :         ImpSetVerb( _nSelectionType );
     253         [ +  - ]:          4 :         GetViewImpl()->SetShellMode(eShellMode);
     254                 :            : 
     255 [ +  - ][ +  - ]:          4 :         if( !GetDocShell()->IsReadOnly() )
                 [ +  - ]
     256                 :            :         {
     257 [ +  - ][ +  - ]:          4 :             if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
         [ -  + ][ -  + ]
     258                 :          0 :                 bSetExtInpCntxt = sal_False;
     259                 :            : 
     260 [ +  - ][ +  - ]:          4 :             InputContext aCntxt( GetEditWin().GetInputContext() );
     261                 :            :             aCntxt.SetOptions( bSetExtInpCntxt
     262                 :          4 :                                 ? (aCntxt.GetOptions() |
     263                 :            :                                         ( INPUTCONTEXT_TEXT |
     264                 :            :                                             INPUTCONTEXT_EXTTEXTINPUT ))
     265                 :          0 :                                 : (aCntxt.GetOptions() & ~
     266                 :            :                                         ( INPUTCONTEXT_TEXT |
     267         [ +  - ]:          8 :                                             INPUTCONTEXT_EXTTEXTINPUT )) );
     268 [ +  - ][ +  - ]:          4 :             GetEditWin().SetInputContext( aCntxt );
     269                 :            :         }
     270                 :            : 
     271                 :            :         //Zur neuen Selektion die Toolbar aktivieren, die auch beim letzten Mal
     272                 :            :         //aktiviert war
     273                 :            :         //Vorher muss ein Flush() sein, betrifft aber lt. MBA nicht das UI und ist
     274                 :            :         //kein Performance-Problem
     275                 :            :         // TODO/LATER: maybe now the Flush() command is superfluous?!
     276         [ +  - ]:          4 :         rDispatcher.Flush();
     277                 :            : 
     278         [ +  - ]:          4 :         Point aPnt = GetEditWin().GetPointerPosPixel();
     279         [ +  - ]:          4 :         aPnt = GetEditWin().PixelToLogic(aPnt);
     280         [ +  - ]:          4 :         GetEditWin().UpdatePointer(aPnt);
     281                 :            : 
     282 [ +  - ][ +  - ]:          4 :         if ( bInitFormShell && GetWrtShell().GetDrawView() )
         [ +  - ][ +  - ]
     283 [ +  - ][ +  - ]:         12 :             GetFormShell()->SetView( PTR_CAST( FmFormView,
         [ +  - ][ +  - ]
     284         [ +  - ]:         12 :                                                 GetWrtShell().GetDrawView()));
           [ +  -  +  - ]
                 [ +  - ]
     285                 :            : 
     286                 :            : 
     287                 :            :     }
     288                 :          8 :     GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
     289                 :            : 
     290                 :            :     //Guenstiger Zeitpunkt fuer die Kommunikation mit OLE-Objekten?
     291         [ -  + ]:          8 :     if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
     292                 :          0 :         GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
     293                 :            : 
     294                 :            :     //jetzt das Tabellen-Update
     295         [ -  + ]:          8 :     if(bUpdateTable)
     296                 :          0 :         GetWrtShell().UpdateTable();
     297                 :          8 : }
     298                 :            : 
     299                 :            : 
     300                 :            : 
     301                 :            : 
     302                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10