LCOV - code coverage report
Current view: top level - sw/source/ui/utlui - unotools.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 280 0.0 %
Date: 2012-08-25 Functions: 0 14 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 847 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <swtypes.hxx>
      31                 :            : #include <globals.hrc>
      32                 :            : #include <misc.hrc>
      33                 :            : 
      34                 :            : #include <utlui.hrc>
      35                 :            : #include <unotools.hrc>
      36                 :            : #include <unotools.hxx>
      37                 :            : #include <unoprnms.hxx>
      38                 :            : #include <osl/diagnose.h>
      39                 :            : #include <vcl/msgbox.hxx>
      40                 :            : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
      41                 :            : #include <com/sun/star/view/XScreenCursor.hpp>
      42                 :            : #include <com/sun/star/view/DocumentZoomType.hpp>
      43                 :            : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      44                 :            : #include <com/sun/star/style/XStyle.hpp>
      45                 :            : #include <com/sun/star/text/XTextDocument.hpp>
      46                 :            : #include <com/sun/star/awt/PosSize.hpp>
      47                 :            : #include <com/sun/star/view/XViewSettingsSupplier.hpp>
      48                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      49                 :            : #include <com/sun/star/frame/XLayoutManager.hpp>
      50                 :            : #include <comphelper/processfactory.hxx>
      51                 :            : #include <sfx2/dispatch.hxx>
      52                 :            : #include <svl/stritem.hxx>
      53                 :            : #include <shellio.hxx>
      54                 :            : #include <docsh.hxx>
      55                 :            : #include <view.hxx>
      56                 :            : #include <wrtsh.hxx>
      57                 :            : #include <swmodule.hxx>
      58                 :            : #include <TextCursorHelper.hxx>
      59                 :            : #include <unocrsr.hxx>
      60                 :            : #include <doc.hxx>
      61                 :            : 
      62                 :            : #include <unomid.h>
      63                 :            : 
      64                 :            : using namespace ::com::sun::star;
      65                 :            : using ::rtl::OUString;
      66                 :            : 
      67                 :            : const sal_Char cFrameControl[] = "com.sun.star.frame.FrameControl";
      68                 :            : const sal_Char cFactory[] = "private:factory/swriter";
      69                 :            : 
      70                 :            : sal_Bool SwOneExampleFrame::bShowServiceNotAvailableMessage = sal_True;
      71                 :            : 
      72                 :          0 : SwOneExampleFrame::SwOneExampleFrame( Window& rWin,
      73                 :            :                                         sal_uInt32 nFlags,
      74                 :            :                                         const Link* pInitializedLink,
      75                 :            :                                         String* pURL ) :
      76                 :            :     aTopWindow( rWin.GetParent(), 0, this ),
      77                 :            :     rWindow(rWin),
      78                 :            :     aMenuRes(SW_RES(RES_FRMEX_MENU)),
      79         [ #  # ]:          0 :     pModuleView(SW_MOD()->GetView()),
      80                 :            :     nStyleFlags(nFlags),
      81                 :            :     bIsInitialized(sal_False),
      82 [ #  # ][ #  # ]:          0 :     bServiceAvailable(sal_False)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      83                 :            : {
      84 [ #  # ][ #  # ]:          0 :     if(pURL && pURL->Len())
                 [ #  # ]
      85         [ #  # ]:          0 :         sArgumentURL = *pURL;
      86                 :            : 
      87         [ #  # ]:          0 :     aTopWindow.SetPaintTransparent(sal_True);
      88 [ #  # ][ #  # ]:          0 :     aTopWindow.SetPosSizePixel(rWin.GetPosPixel(), rWin.GetSizePixel());
                 [ #  # ]
      89         [ #  # ]:          0 :     aTopWindow.SetZOrder( &rWin, WINDOW_ZORDER_FIRST );
      90                 :            : 
      91         [ #  # ]:          0 :     if( pInitializedLink )
      92                 :          0 :         aInitializedLink = *pInitializedLink;
      93                 :            : 
      94                 :            :     // the controller is asynchronously set
      95         [ #  # ]:          0 :     aLoadedTimer.SetTimeoutHdl(LINK(this, SwOneExampleFrame, TimeoutHdl));
      96         [ #  # ]:          0 :     aLoadedTimer.SetTimeout(200);
      97                 :            : 
      98         [ #  # ]:          0 :     rWin.Enable(sal_False);
      99         [ #  # ]:          0 :     CreateControl();
     100                 :            : 
     101         [ #  # ]:          0 :     aTopWindow.Show();
     102                 :          0 : }
     103                 :            : 
     104                 :          0 : void SwOneExampleFrame::CreateErrorMessage(Window* pParent)
     105                 :            : {
     106         [ #  # ]:          0 :     if(SwOneExampleFrame::bShowServiceNotAvailableMessage)
     107                 :            :     {
     108         [ #  # ]:          0 :         String sInfo(SW_RES(STR_SERVICE_UNAVAILABLE));
     109         [ #  # ]:          0 :         sInfo += rtl::OUString(cFrameControl);
     110 [ #  # ][ #  # ]:          0 :         InfoBox(pParent, sInfo).Execute();
                 [ #  # ]
     111         [ #  # ]:          0 :         SwOneExampleFrame::bShowServiceNotAvailableMessage = sal_False;
     112                 :            :     }
     113                 :          0 : }
     114                 :            : 
     115 [ #  # ][ #  # ]:          0 : SwOneExampleFrame::~SwOneExampleFrame()
         [ #  # ][ #  # ]
     116                 :            : {
     117         [ #  # ]:          0 :     DisposeControl();
     118                 :          0 : }
     119                 :            : 
     120                 :          0 : void    SwOneExampleFrame::CreateControl()
     121                 :            : {
     122         [ #  # ]:          0 :     if(_xControl.is())
     123                 :          0 :         return ;
     124                 :            :     uno::Reference< lang::XMultiServiceFactory >
     125         [ #  # ]:          0 :                                     xMgr = comphelper::getProcessServiceFactory();
     126 [ #  # ][ #  # ]:          0 :     uno::Reference< uno::XInterface >  xInst = xMgr->createInstance( C2U("com.sun.star.frame.FrameControl") );
                 [ #  # ]
     127 [ #  # ][ #  # ]:          0 :     _xControl = uno::Reference< awt::XControl >(xInst, uno::UNO_QUERY);
     128         [ #  # ]:          0 :     if(_xControl.is())
     129                 :            :     {
     130         [ #  # ]:          0 :         uno::Reference< awt::XWindowPeer >  xParent( rWindow.GetComponentInterface() );
     131                 :            : 
     132 [ #  # ][ #  # ]:          0 :         uno::Reference< awt::XToolkit >  xToolkit( xMgr->createInstance( C2U("com.sun.star.awt.Toolkit") ), uno::UNO_QUERY );
         [ #  # ][ #  # ]
     133         [ #  # ]:          0 :         if(xToolkit.is())
     134                 :            :         {
     135 [ #  # ][ #  # ]:          0 :             _xControl->createPeer( xToolkit, xParent );
     136                 :            : 
     137         [ #  # ]:          0 :             uno::Reference< awt::XWindow >  xWin( _xControl, uno::UNO_QUERY );
     138 [ #  # ][ #  # ]:          0 :             xWin->setVisible( sal_False );
     139                 :          0 :             Size aWinSize(rWindow.GetOutputSizePixel());
     140 [ #  # ][ #  # ]:          0 :             xWin->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE );
     141                 :            : 
     142         [ #  # ]:          0 :             uno::Reference< beans::XPropertySet >  xPrSet(xInst, uno::UNO_QUERY);
     143                 :          0 :             uno::Any aURL;
     144                 :            :             // create new doc
     145                 :          0 :             rtl::OUString sTempURL(cFactory);
     146         [ #  # ]:          0 :             if(sArgumentURL.Len())
     147         [ #  # ]:          0 :                 sTempURL = sArgumentURL;
     148         [ #  # ]:          0 :             aURL <<= sTempURL;
     149                 :            : 
     150         [ #  # ]:          0 :             uno::Sequence<beans::PropertyValue> aSeq(3);
     151         [ #  # ]:          0 :             beans::PropertyValue* pValues = aSeq.getArray();
     152         [ #  # ]:          0 :             pValues[0].Name = C2U("ReadOnly");
     153                 :          0 :             sal_Bool bTrue = sal_True;
     154         [ #  # ]:          0 :             pValues[0].Value.setValue(&bTrue, ::getBooleanCppuType());
     155         [ #  # ]:          0 :             pValues[1].Name = C2U("OpenFlags");
     156 [ #  # ][ #  # ]:          0 :             pValues[1].Value <<= C2U("-RB");
     157         [ #  # ]:          0 :             pValues[2].Name = C2U("Referer");
     158 [ #  # ][ #  # ]:          0 :             pValues[2].Value <<= C2U("private:user");
     159                 :          0 :             uno::Any aArgs;
     160         [ #  # ]:          0 :             aArgs.setValue(&aSeq, ::getCppuType((uno::Sequence<beans::PropertyValue>*)0));
     161                 :            : 
     162 [ #  # ][ #  # ]:          0 :             xPrSet->setPropertyValue( C2U("LoaderArguments"), aArgs );
                 [ #  # ]
     163                 :            :             //save and set readonly???
     164                 :            : 
     165 [ #  # ][ #  # ]:          0 :             xPrSet->setPropertyValue(C2U("ComponentURL"), aURL);
                 [ #  # ]
     166                 :            : 
     167         [ #  # ]:          0 :             aLoadedTimer.Start();
     168         [ #  # ]:          0 :             bServiceAvailable = sal_True;
     169                 :          0 :         }
     170                 :          0 :     }
     171                 :            : }
     172                 :            : 
     173                 :          0 : void    SwOneExampleFrame::DisposeControl()
     174                 :            : {
     175                 :          0 :     _xCursor = 0;
     176         [ #  # ]:          0 :     if(_xControl.is())
     177                 :          0 :         _xControl->dispose();
     178                 :          0 :     _xControl = 0;
     179                 :          0 :     _xModel = 0;
     180                 :          0 :     _xController = 0;
     181                 :          0 : }
     182                 :            : 
     183                 :          0 : IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer )
     184                 :            : {
     185         [ #  # ]:          0 :     if(!_xControl.is())
     186                 :          0 :         return 0;
     187                 :            : 
     188                 :            :     // now get the model
     189         [ #  # ]:          0 :     uno::Reference< beans::XPropertySet >  xPrSet(_xControl, uno::UNO_QUERY);
     190 [ #  # ][ #  # ]:          0 :     uno::Any aFrame = xPrSet->getPropertyValue(C2U("Frame"));
                 [ #  # ]
     191                 :          0 :     uno::Reference< frame::XFrame >  xFrm;
     192         [ #  # ]:          0 :     aFrame >>= xFrm;
     193                 :            : 
     194         [ #  # ]:          0 :     uno::Reference< beans::XPropertySet > xPropSet( xFrm, uno::UNO_QUERY );
     195         [ #  # ]:          0 :     if ( xPropSet.is() )
     196                 :            :     {
     197                 :            :         try
     198                 :            :         {
     199                 :          0 :             uno::Reference< frame::XLayoutManager > xLayoutManager;
     200 [ #  # ][ #  # ]:          0 :             uno::Any aValue = xPropSet->getPropertyValue(C2U("LayoutManager"));
                 [ #  # ]
     201         [ #  # ]:          0 :             aValue >>= xLayoutManager;
     202         [ #  # ]:          0 :             if ( xLayoutManager.is() )
     203 [ #  # ][ #  # ]:          0 :                 xLayoutManager->setVisible( sal_False );
                 [ #  # ]
     204                 :            :         }
     205         [ #  # ]:          0 :         catch (const uno::Exception&)
     206                 :            :         {
     207                 :            :         }
     208                 :            :     }
     209                 :            : 
     210 [ #  # ][ #  # ]:          0 :     _xController = xFrm->getController();
                 [ #  # ]
     211         [ #  # ]:          0 :     if(_xController.is())
     212                 :            :     {
     213 [ #  # ][ #  # ]:          0 :         _xModel = _xController->getModel();
                 [ #  # ]
     214                 :            :         //now the ViewOptions should be set properly
     215         [ #  # ]:          0 :         uno::Reference< view::XViewSettingsSupplier >  xSettings(_xController, uno::UNO_QUERY);
     216 [ #  # ][ #  # ]:          0 :         uno::Reference< beans::XPropertySet >  xViewProps = xSettings->getViewSettings();
     217                 :            : 
     218                 :          0 :         sal_Bool bTrue = sal_True;
     219                 :          0 :         sal_Bool bFalse = sal_False;
     220         [ #  # ]:          0 :         uno::Any aTrueSet( &bTrue, ::getBooleanCppuType() );
     221         [ #  # ]:          0 :         uno::Any aFalseSet( &bFalse, ::getBooleanCppuType() );
     222                 :            : 
     223         [ #  # ]:          0 :         if( !bIsInitialized )
     224                 :            :         {
     225 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_BREAKS)), aFalseSet);
                 [ #  # ]
     226 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_DRAWINGS)), aTrueSet);
                 [ #  # ]
     227 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_FIELD_COMMANDS)), aFalseSet);
                 [ #  # ]
     228 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_GRAPHICS)), aTrueSet);
                 [ #  # ]
     229 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_HIDDEN_PARAGRAPHS)), aFalseSet);
                 [ #  # ]
     230 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_HIDDEN_TEXT)), aFalseSet);
                 [ #  # ]
     231 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_HORI_RULER)), aFalseSet);
                 [ #  # ]
     232 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_PARA_BREAKS)), aFalseSet);
                 [ #  # ]
     233 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_PROTECTED_SPACES)), aFalseSet);
                 [ #  # ]
     234 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_SOFT_HYPHENS)), aFalseSet);
                 [ #  # ]
     235 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_SPACES)), aFalseSet);
                 [ #  # ]
     236 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_TABLES)), aTrueSet);
                 [ #  # ]
     237 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_TABSTOPS)), aFalseSet);
                 [ #  # ]
     238 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_VERT_RULER)), aFalseSet);
                 [ #  # ]
     239                 :            : 
     240         [ #  # ]:          0 :             if(0 ==(nStyleFlags&EX_SHOW_ONLINE_LAYOUT))
     241                 :            :             {
     242                 :          0 :                 uno::Any aZoom;
     243         [ #  # ]:          0 :                 aZoom <<= (sal_Int16)view::DocumentZoomType::PAGE_WIDTH_EXACT;
     244 [ #  # ][ #  # ]:          0 :                 xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom);
                 [ #  # ]
     245                 :            :             }
     246                 :            :             else
     247                 :            :             {
     248                 :          0 :                 uno::Any aZoom;
     249         [ #  # ]:          0 :                 aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE;
     250 [ #  # ][ #  # ]:          0 :                 xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom);
                 [ #  # ]
     251                 :            : 
     252                 :          0 :                 sal_Int16 nZoomValue = 50;
     253         [ #  # ]:          0 :                 if(EX_SHOW_BUSINESS_CARDS == nStyleFlags)
     254                 :            :                 {
     255                 :          0 :                     nZoomValue = 80;
     256                 :            :                 }
     257         [ #  # ]:          0 :                 aZoom <<= nZoomValue;
     258 [ #  # ][ #  # ]:          0 :                 xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)), aZoom);
                 [ #  # ]
     259                 :            :             }
     260                 :            :             // set onlinelayout property behind setting the zoom
     261 [ #  # ][ #  # ]:          0 :             xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_ONLINE_LAYOUT)),
     262 [ #  # ][ #  # ]:          0 :                     (nStyleFlags&EX_SHOW_ONLINE_LAYOUT) ? aTrueSet : aFalseSet );
     263                 :          0 :             bIsInitialized = sal_True;
     264                 :            :         }
     265                 :            : 
     266         [ #  # ]:          0 :         uno::Reference< text::XTextDocument >  xDoc(_xModel, uno::UNO_QUERY);
     267 [ #  # ][ #  # ]:          0 :         uno::Reference< text::XText >  xText = xDoc->getText();
     268 [ #  # ][ #  # ]:          0 :         _xCursor = xText->createTextCursor();
                 [ #  # ]
     269                 :            : 
     270                 :            :         //From here, a cursor is defined, which goes trough the template,
     271                 :            :         //and overwrites the template words where it is necessary.
     272                 :            : 
     273         [ #  # ]:          0 :         uno::Reference< lang::XUnoTunnel> xTunnel( _xCursor, uno::UNO_QUERY);
     274         [ #  # ]:          0 :         if( xTunnel.is() )
     275                 :            :         {
     276         [ #  # ]:          0 :             OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>( xTunnel->getSomething(
     277 [ #  # ][ #  # ]:          0 :                                         OTextCursorHelper::getUnoTunnelId() ));
     278         [ #  # ]:          0 :             if( pCrsr )
     279                 :            :             {
     280 [ #  # ][ #  # ]:          0 :                 SwEditShell* pSh = pCrsr->GetDoc()->GetEditShell();
     281                 :            : 
     282         [ #  # ]:          0 :                 do
     283                 :            :                 {
     284 [ #  # ][ #  # ]:          0 :                   if (pSh->GetCurWord() == String("HEADING1"))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     285                 :            :                   {
     286 [ #  # ][ #  # ]:          0 :                     pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING1));
         [ #  # ][ #  # ]
     287                 :            :                   }
     288 [ #  # ][ #  # ]:          0 :                   else if (pSh->GetCurWord() == String("ENTRY1"))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     289                 :            :                   {
     290 [ #  # ][ #  # ]:          0 :                     pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY1));
         [ #  # ][ #  # ]
     291                 :            :                   }
     292 [ #  # ][ #  # ]:          0 :                   else if (pSh->GetCurWord() == String("HEADING11"))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     293                 :            :                   {
     294 [ #  # ][ #  # ]:          0 :                     pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING11));
         [ #  # ][ #  # ]
     295                 :            :                   }
     296 [ #  # ][ #  # ]:          0 :                   else if (pSh->GetCurWord() == String("ENTRY11"))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     297                 :            :                   {
     298 [ #  # ][ #  # ]:          0 :                     pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY11));
         [ #  # ][ #  # ]
     299                 :            :                   }
     300 [ #  # ][ #  # ]:          0 :                   else if (pSh->GetCurWord() == String("HEADING12"))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     301                 :            :                   {
     302 [ #  # ][ #  # ]:          0 :                     pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING12));
         [ #  # ][ #  # ]
     303                 :            :                   }
     304 [ #  # ][ #  # ]:          0 :                   else if (pSh->GetCurWord() == String("ENTRY12"))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     305                 :            :                   {
     306 [ #  # ][ #  # ]:          0 :                     pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY12));
         [ #  # ][ #  # ]
     307                 :            :                   }
     308 [ #  # ][ #  # ]:          0 :                   else if (pSh->GetCurWord() == String("TABLE1"))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     309                 :            :                   {
     310 [ #  # ][ #  # ]:          0 :                     pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_TABLE1));
         [ #  # ][ #  # ]
     311                 :            :                   }
     312 [ #  # ][ #  # ]:          0 :                   else if (pSh->GetCurWord() == String("IMAGE1"))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     313                 :            :                   {
     314 [ #  # ][ #  # ]:          0 :                     pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_IMAGE1));
         [ #  # ][ #  # ]
     315                 :            :                   }
     316                 :            :                   else
     317                 :            :                   {;}
     318                 :            :                 }
     319         [ #  # ]:          0 :                 while(pSh->Right(sal_uInt16(1), sal_uInt16(1), sal_True) == sal_True);
     320                 :            :             }
     321                 :            :         }
     322                 :            : 
     323         [ #  # ]:          0 :         uno::Reference< beans::XPropertySet >  xCrsrProp(_xCursor, uno::UNO_QUERY);
     324         [ #  # ]:          0 :         uno::Any aPageStyle = xCrsrProp->getPropertyValue(
     325 [ #  # ][ #  # ]:          0 :                                             rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_PAGE_STYLE_NAME)));
     326                 :          0 :         OUString sPageStyle;
     327                 :          0 :         aPageStyle >>= sPageStyle;
     328                 :            : 
     329         [ #  # ]:          0 :         uno::Reference< style::XStyleFamiliesSupplier >  xSSupp( xDoc, uno::UNO_QUERY);
     330 [ #  # ][ #  # ]:          0 :         uno::Reference< container::XNameAccess >  xStyles = xSSupp->getStyleFamilies();
     331 [ #  # ][ #  # ]:          0 :         uno::Any aPFamily = xStyles->getByName( C2U("PageStyles" ) );
                 [ #  # ]
     332                 :          0 :         uno::Reference< container::XNameContainer >  xPFamily;
     333                 :            : 
     334   [ #  #  #  # ]:          0 :         if( 0 == (EX_SHOW_DEFAULT_PAGE == nStyleFlags)
         [ #  # ][ #  # ]
     335         [ #  # ]:          0 :                 && (aPFamily >>= xPFamily) && !sPageStyle.isEmpty() )
     336                 :            :         {
     337 [ #  # ][ #  # ]:          0 :             uno::Any aPStyle = xPFamily->getByName( sPageStyle );
     338                 :          0 :             uno::Reference< style::XStyle >  xPStyle;
     339         [ #  # ]:          0 :             aPStyle >>= xPStyle;
     340         [ #  # ]:          0 :             uno::Reference< beans::XPropertySet >  xPProp(xPStyle, uno::UNO_QUERY);
     341 [ #  # ][ #  # ]:          0 :             uno::Any aSize = xPProp->getPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SIZE)));
                 [ #  # ]
     342                 :          0 :             awt::Size aPSize;
     343         [ #  # ]:          0 :             aSize >>= aPSize;
     344                 :            :             //TODO: set page width to card width
     345                 :          0 :             aPSize.Width = 10000;
     346         [ #  # ]:          0 :             aSize.setValue(&aPSize, ::getCppuType((awt::Size*)0));
     347 [ #  # ][ #  # ]:          0 :             xPProp->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SIZE)), aSize);
                 [ #  # ]
     348                 :            : 
     349         [ #  # ]:          0 :             uno::Any aZero; aZero <<= (sal_Int32)0;
     350 [ #  # ][ #  # ]:          0 :             xPProp->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_LEFT_MARGIN)), aZero);
                 [ #  # ]
     351 [ #  # ][ #  # ]:          0 :             xPProp->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_RIGHT_MARGIN)), aZero);
                 [ #  # ]
     352                 :            :         }
     353                 :            : 
     354                 :            :         // can only be done here - the SFX changes the ScrollBar values
     355 [ #  # ][ #  # ]:          0 :         xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_HORI_SCROLL_BAR )), aFalseSet);
                 [ #  # ]
     356 [ #  # ][ #  # ]:          0 :         xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SHOW_VERT_SCROLL_BAR )), aFalseSet);
                 [ #  # ]
     357                 :            : 
     358 [ #  # ][ #  # ]:          0 :         if( aInitializedLink.IsSet() )
     359                 :            :         {
     360         [ #  # ]:          0 :             rWindow.Enable(sal_False, sal_True);
     361         [ #  # ]:          0 :                aInitializedLink.Call(this);
     362                 :            :         }
     363                 :            : 
     364         [ #  # ]:          0 :         uno::Reference< text::XTextViewCursorSupplier >  xCrsrSupp(_xController, uno::UNO_QUERY);
     365 [ #  # ][ #  # ]:          0 :         uno::Reference< view::XScreenCursor >  xScrCrsr(xCrsrSupp->getViewCursor(), uno::UNO_QUERY);
                 [ #  # ]
     366         [ #  # ]:          0 :         if(xScrCrsr.is())
     367 [ #  # ][ #  # ]:          0 :             xScrCrsr->screenUp();
     368                 :            : 
     369         [ #  # ]:          0 :         uno::Reference< awt::XWindow >  xWin( _xControl, uno::UNO_QUERY );
     370 [ #  # ][ #  # ]:          0 :         xWin->setVisible( sal_True );
     371         [ #  # ]:          0 :         rWindow.Show();
     372                 :            : 
     373         [ #  # ]:          0 :         if( xTunnel.is() )
     374                 :            :         {
     375         [ #  # ]:          0 :             OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>( xTunnel->getSomething(
     376 [ #  # ][ #  # ]:          0 :                                         OTextCursorHelper::getUnoTunnelId() ));
     377         [ #  # ]:          0 :             if( pCrsr )
     378                 :            :             {
     379 [ #  # ][ #  # ]:          0 :                 SwEditShell* pSh = pCrsr->GetDoc()->GetEditShell();
     380         [ #  # ]:          0 :                 if( pSh->ActionCount() )
     381                 :            :                 {
     382         [ #  # ]:          0 :                     pSh->EndAllAction();
     383         [ #  # ]:          0 :                     pSh->UnlockPaint();
     384                 :            :                 }
     385                 :            :             }
     386                 :            :         }
     387                 :            : 
     388         [ #  # ]:          0 :         SW_MOD()->SetView(pModuleView);
     389                 :            :     }
     390                 :            :     else
     391         [ #  # ]:          0 :         pTimer->Start();
     392                 :          0 :     return 0;
     393                 :            : }
     394                 :            : 
     395                 :          0 : void SwOneExampleFrame::ClearDocument( sal_Bool bStartUpdateTimer )
     396                 :            : {
     397         [ #  # ]:          0 :     uno::Reference< lang::XUnoTunnel> xTunnel( _xCursor, uno::UNO_QUERY);
     398         [ #  # ]:          0 :     if( xTunnel.is() )
     399                 :            :     {
     400         [ #  # ]:          0 :         OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>(xTunnel->getSomething(
     401 [ #  # ][ #  # ]:          0 :                                         OTextCursorHelper::getUnoTunnelId()) );
     402         [ #  # ]:          0 :         if( pCrsr )
     403                 :            :         {
     404         [ #  # ]:          0 :             SwDoc* pDoc = pCrsr->GetDoc();
     405         [ #  # ]:          0 :             SwEditShell* pSh = pDoc->GetEditShell();
     406         [ #  # ]:          0 :             pSh->LockPaint();
     407         [ #  # ]:          0 :             pSh->StartAllAction();
     408         [ #  # ]:          0 :             pDoc->ClearDoc();
     409                 :            : 
     410 [ #  # ][ #  # ]:          0 :             if( aLoadedTimer.IsActive() || !bStartUpdateTimer )
                 [ #  # ]
     411                 :            :             {
     412         [ #  # ]:          0 :                 pSh->EndAllAction();
     413         [ #  # ]:          0 :                 pSh->UnlockPaint();
     414                 :            :             }
     415         [ #  # ]:          0 :             if( bStartUpdateTimer )
     416         [ #  # ]:          0 :                 aLoadedTimer.Start();
     417                 :            :         }
     418                 :            :         else
     419                 :            :         {
     420 [ #  # ][ #  # ]:          0 :             _xCursor->gotoStart(sal_False);
     421 [ #  # ][ #  # ]:          0 :             _xCursor->gotoEnd(sal_True);
     422 [ #  # ][ #  # ]:          0 :             _xCursor->setString(OUString());
     423                 :            :         }
     424                 :          0 :     }
     425                 :          0 : }
     426                 :            : 
     427                 :            : static const sal_Int16 nZoomValues[] =
     428                 :            : {
     429                 :            :     20,
     430                 :            :     40,
     431                 :            :     50,
     432                 :            :     75,
     433                 :            :     100
     434                 :            : };
     435                 :            : 
     436                 :            : #define ITEM_UP     100
     437                 :            : #define ITEM_DOWN   200
     438                 :            : #define ITEM_ZOOM   300
     439                 :            : 
     440                 :          0 : void SwOneExampleFrame::CreatePopup(const Point& rPt)
     441                 :            : {
     442         [ #  # ]:          0 :     PopupMenu aPop;
     443         [ #  # ]:          0 :     PopupMenu aSubPop1;
     444                 :          0 :     ResStringArray& rArr = aMenuRes.GetMenuArray();
     445                 :            : 
     446 [ #  # ][ #  # ]:          0 :     aPop.InsertItem(ITEM_UP,   rArr.GetString(rArr.FindIndex(ST_MENU_UP )));
         [ #  # ][ #  # ]
                 [ #  # ]
     447 [ #  # ][ #  # ]:          0 :     aPop.InsertItem(ITEM_DOWN, rArr.GetString(rArr.FindIndex(ST_MENU_DOWN )));
         [ #  # ][ #  # ]
                 [ #  # ]
     448                 :            : 
     449         [ #  # ]:          0 :     Link aSelLk = LINK(this, SwOneExampleFrame, PopupHdl );
     450                 :          0 :     aPop.SetSelectHdl(aSelLk);
     451         [ #  # ]:          0 :     if(EX_SHOW_ONLINE_LAYOUT == nStyleFlags)
     452                 :            :     {
     453 [ #  # ][ #  # ]:          0 :         aPop.InsertItem(ITEM_ZOOM, rArr.GetString(rArr.FindIndex(ST_MENU_ZOOM   )));
         [ #  # ][ #  # ]
                 [ #  # ]
     454                 :            : 
     455         [ #  # ]:          0 :         uno::Reference< view::XViewSettingsSupplier >  xSettings(_xController, uno::UNO_QUERY);
     456 [ #  # ][ #  # ]:          0 :         uno::Reference< beans::XPropertySet >  xViewProps = xSettings->getViewSettings();
     457                 :            : 
     458 [ #  # ][ #  # ]:          0 :         uno::Any aZoom = xViewProps->getPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)));
                 [ #  # ]
     459                 :          0 :         sal_Int16 nZoom = 0;
     460                 :          0 :         aZoom >>= nZoom;
     461                 :            : 
     462         [ #  # ]:          0 :         for (sal_uInt16 i = 0;
     463                 :            :                 i < (sizeof(nZoomValues)/sizeof(nZoomValues[0])); ++i)
     464                 :            :         {
     465         [ #  # ]:          0 :             String sTemp;
     466 [ #  # ][ #  # ]:          0 :             sTemp = String::CreateFromInt32(nZoomValues[i]);
                 [ #  # ]
     467         [ #  # ]:          0 :             sTemp += rtl::OUString(" %");
     468         [ #  # ]:          0 :             aSubPop1.InsertItem( ITEM_ZOOM + i + 1, sTemp);
     469         [ #  # ]:          0 :             if(nZoom == nZoomValues[i])
     470         [ #  # ]:          0 :                 aSubPop1.CheckItem(ITEM_ZOOM + i + 1);
     471         [ #  # ]:          0 :         }
     472         [ #  # ]:          0 :         aPop.SetPopupMenu( ITEM_ZOOM, &aSubPop1 );
     473                 :          0 :         aSubPop1.SetSelectHdl(aSelLk);
     474                 :            :     }
     475 [ #  # ][ #  # ]:          0 :     aPop.Execute( &aTopWindow, rPt );
                 [ #  # ]
     476                 :            : 
     477                 :          0 : }
     478                 :            : 
     479                 :          0 : IMPL_LINK(SwOneExampleFrame, PopupHdl, Menu*, pMenu )
     480                 :            : {
     481                 :          0 :     sal_uInt16 nId = pMenu->GetCurItemId();
     482 [ #  # ][ #  # ]:          0 :     if ((nId > ITEM_ZOOM) &&
     483                 :            :         (nId <= (ITEM_ZOOM + (sizeof(nZoomValues)/sizeof(nZoomValues[0])))))
     484                 :            :     {
     485                 :          0 :         sal_Int16 nZoom = nZoomValues[nId - ITEM_ZOOM - 1];
     486         [ #  # ]:          0 :         uno::Reference< view::XViewSettingsSupplier >  xSettings(_xController, uno::UNO_QUERY);
     487 [ #  # ][ #  # ]:          0 :         uno::Reference< beans::XPropertySet >  xViewProps = xSettings->getViewSettings();
     488                 :            : 
     489                 :          0 :         uno::Any aZoom;
     490         [ #  # ]:          0 :         aZoom <<= nZoom;
     491 [ #  # ][ #  # ]:          0 :         xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)), aZoom);
                 [ #  # ]
     492         [ #  # ]:          0 :         aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE;
     493 [ #  # ][ #  # ]:          0 :         xViewProps->setPropertyValue(rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom);
                 [ #  # ]
     494                 :            :     }
     495 [ #  # ][ #  # ]:          0 :     else if(ITEM_UP == nId || ITEM_DOWN == nId)
     496                 :            :     {
     497         [ #  # ]:          0 :         uno::Reference< text::XTextViewCursorSupplier >  xCrsrSupp(_xController, uno::UNO_QUERY);
     498 [ #  # ][ #  # ]:          0 :         uno::Reference< view::XScreenCursor >  xScrCrsr(xCrsrSupp->getViewCursor(), uno::UNO_QUERY);
                 [ #  # ]
     499         [ #  # ]:          0 :         if(ITEM_UP == nId)
     500 [ #  # ][ #  # ]:          0 :             xScrCrsr->screenUp();
     501                 :            :         else
     502 [ #  # ][ #  # ]:          0 :             xScrCrsr->screenDown();
     503                 :            :     }
     504                 :          0 :     return 0;
     505                 :            : };
     506                 :            : 
     507                 :          0 : SwFrmCtrlWindow::SwFrmCtrlWindow(Window* pParent, WinBits nBits,
     508                 :            :                                 SwOneExampleFrame*  pFrame) :
     509                 :            :     Window(pParent, nBits),
     510                 :          0 :     pExampleFrame(pFrame)
     511                 :            : {
     512                 :          0 : }
     513                 :            : 
     514                 :          0 : void SwFrmCtrlWindow::Command( const CommandEvent& rCEvt )
     515                 :            : {
     516      [ #  #  # ]:          0 :     switch ( rCEvt.GetCommand() )
     517                 :            :     {
     518                 :            :         case COMMAND_CONTEXTMENU:
     519                 :            :         {
     520                 :            :             //#125881# quickly clicking crashes because the control is not fully initialized
     521         [ #  # ]:          0 :             if(pExampleFrame->GetController().is())
     522                 :          0 :                 pExampleFrame->CreatePopup(rCEvt.GetMousePosPixel());
     523                 :            :         }
     524                 :          0 :         break;
     525                 :            :         case COMMAND_WHEEL:
     526                 :            :         case COMMAND_STARTAUTOSCROLL:
     527                 :            :         case COMMAND_AUTOSCROLL:
     528                 :          0 :         break;
     529                 :            :         default:;
     530                 :            :     }
     531                 :          0 : }
     532                 :            : 
     533                 :          0 : MenuResource::MenuResource(const ResId& rResId) :
     534                 :            :     Resource(rResId),
     535         [ #  # ]:          0 :     aMenuArray(ResId(1,*rResId.GetResMgr()))
     536                 :            : {
     537         [ #  # ]:          0 :     FreeResource();
     538                 :          0 : }
     539                 :            : 
     540                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10