LCOV - code coverage report
Current view: top level - sd/source/ui/app - sdmod.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 86 0.0 %
Date: 2014-04-14 Functions: 0 20 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 <unotools/pathoptions.hxx>
      21             : #include <svl/languageoptions.hxx>
      22             : #include <unotools/ucbstreamhelper.hxx>
      23             : #include <tools/urlobj.hxx>
      24             : #include <vcl/virdev.hxx>
      25             : #include <sfx2/app.hxx>
      26             : #include <vcl/status.hxx>
      27             : #include <svl/intitem.hxx>
      28             : #include <sfx2/msg.hxx>
      29             : #include <sfx2/objface.hxx>
      30             : #include <sfx2/printer.hxx>
      31             : #include <svx/pszctrl.hxx>
      32             : #include <svx/zoomctrl.hxx>
      33             : #include <svx/modctrl.hxx>
      34             : #include <svl/zforlist.hxx>
      35             : #include <comphelper/processfactory.hxx>
      36             : #include <svtools/ehdl.hxx>
      37             : 
      38             : #include <svx/svxids.hrc>
      39             : #include <svl/srchitem.hxx>
      40             : #include <svx/svxerr.hxx>
      41             : 
      42             : #include <svx/xmlsecctrl.hxx>
      43             : 
      44             : #include "sderror.hxx"
      45             : #include "sdmod.hxx"
      46             : #include "sdresid.hxx"
      47             : #include "optsitem.hxx"
      48             : #include "DrawDocShell.hxx"
      49             : #include "drawdoc.hxx"
      50             : #include "app.hrc"
      51             : #include "glob.hrc"
      52             : #include "strings.hrc"
      53             : #include "res_bmp.hrc"
      54             : #include "cfgids.hxx"
      55             : #include "tools/SdGlobalResourceContainer.hxx"
      56             : 
      57           0 : TYPEINIT1( SdModule, SfxModule );
      58             : 
      59             : #define SdModule
      60             : #include "sdslots.hxx"
      61             : 
      62             : 
      63           0 : SFX_IMPL_INTERFACE(SdModule, SfxModule, SdResId(STR_APPLICATIONOBJECTBAR))
      64             : {
      65           0 :     SFX_STATUSBAR_REGISTRATION(SdResId(RID_DRAW_STATUSBAR));
      66           0 : }
      67             : 
      68             : // Ctor
      69           0 : SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 )
      70             : :   SfxModule( SfxApplication::CreateResManager("sd"), false,
      71             :                   pFact1, pFact2, NULL ),
      72             :     pTransferClip(NULL),
      73             :     pTransferDrag(NULL),
      74             :     pTransferSelection(NULL),
      75             :     pImpressOptions(NULL),
      76             :     pDrawOptions(NULL),
      77             :     pSearchItem(NULL),
      78             :     pNumberFormatter( NULL ),
      79             :     bWaterCan(sal_False),
      80           0 :     mpResourceContainer(new ::sd::SdGlobalResourceContainer())
      81             : {
      82           0 :     SetName( OUString( "StarDraw" ) );  // Do not translate!
      83           0 :     pSearchItem = new SvxSearchItem(SID_SEARCH_ITEM);
      84           0 :     pSearchItem->SetAppFlag(SVX_SEARCHAPP_DRAW);
      85           0 :     StartListening( *SFX_APP() );
      86           0 :     SvxErrorHandler::ensure();
      87             :     mpErrorHdl = new SfxErrorHandler( RID_SD_ERRHDL,
      88             :                                          ERRCODE_AREA_SD,
      89             :                                          ERRCODE_AREA_SD_END,
      90           0 :                                          GetResMgr() );
      91             : 
      92             :     // Create a new ref device and (by calling SetReferenceDevice())
      93             :     // set its resolution to 600 DPI.  This leads to a visually better
      94             :     // formatting of text in small sizes (6 point and below.)
      95           0 :     VirtualDevice* pDevice = new VirtualDevice;
      96           0 :     mpVirtualRefDevice = pDevice;
      97           0 :     pDevice->SetMapMode( MAP_100TH_MM );
      98           0 :     pDevice->SetReferenceDevice ( VirtualDevice::REFDEV_MODE06 );
      99           0 : }
     100             : 
     101             : // Dtor
     102           0 : SdModule::~SdModule()
     103             : {
     104           0 :     delete pSearchItem;
     105             : 
     106           0 :     if( pNumberFormatter )
     107           0 :         delete pNumberFormatter;
     108             : 
     109           0 :     ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
     110           0 :     if( pDocShell )
     111             :     {
     112           0 :         ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
     113           0 :         if (pViewShell)
     114             :         {
     115             :             // Removing our event listener
     116           0 :             Application::RemoveEventListener( LINK( this, SdModule, EventListenerHdl ) );
     117             :         }
     118             :     }
     119             : 
     120           0 :     mpResourceContainer.reset();
     121             : 
     122             :     // Mark the module in the global AppData structure as deleted.
     123           0 :     SdModule** ppShellPointer = (SdModule**)GetAppData(SHL_DRAW);
     124           0 :     if (ppShellPointer != NULL)
     125           0 :         (*ppShellPointer) = NULL;
     126             : 
     127           0 :     delete mpErrorHdl;
     128           0 :     delete static_cast< VirtualDevice* >( mpVirtualRefDevice );
     129           0 : }
     130             : 
     131             : /// get notifications
     132           0 : void SdModule::Notify( SfxBroadcaster&, const SfxHint& rHint )
     133             : {
     134           0 :     if( rHint.ISA( SfxSimpleHint ) &&
     135           0 :         ( (SfxSimpleHint&) rHint ).GetId() == SFX_HINT_DEINITIALIZING )
     136             :     {
     137           0 :         delete pImpressOptions, pImpressOptions = NULL;
     138           0 :         delete pDrawOptions, pDrawOptions = NULL;
     139             :     }
     140           0 : }
     141             : 
     142             : /// Return options
     143           0 : SdOptions* SdModule::GetSdOptions(DocumentType eDocType)
     144             : {
     145           0 :     SdOptions* pOptions = NULL;
     146             : 
     147           0 :     if (eDocType == DOCUMENT_TYPE_DRAW)
     148             :     {
     149           0 :         if (!pDrawOptions)
     150           0 :             pDrawOptions = new SdOptions( SDCFG_DRAW );
     151             : 
     152           0 :         pOptions = pDrawOptions;
     153             :     }
     154           0 :     else if (eDocType == DOCUMENT_TYPE_IMPRESS)
     155             :     {
     156           0 :         if (!pImpressOptions)
     157           0 :             pImpressOptions = new SdOptions( SDCFG_IMPRESS );
     158             : 
     159           0 :         pOptions = pImpressOptions;
     160             :     }
     161           0 :     if( pOptions )
     162             :     {
     163           0 :         sal_uInt16 nMetric = pOptions->GetMetric();
     164             : 
     165           0 :         ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
     166           0 :         SdDrawDocument* pDoc = NULL;
     167           0 :         if (pDocSh)
     168           0 :             pDoc = pDocSh->GetDoc();
     169             : 
     170           0 :         if( nMetric != 0xffff && pDoc && eDocType == pDoc->GetDocumentType() )
     171           0 :             PutItem( SfxUInt16Item( SID_ATTR_METRIC, nMetric ) );
     172             :     }
     173             : 
     174           0 :     return(pOptions);
     175             : }
     176             : 
     177             : /**
     178             :  * Open and return option stream for internal options;
     179             :  * if the stream is opened for reading but does not exist, an 'empty'
     180             :  * RefObject is returned
     181             :  */
     182           0 : SvStorageStreamRef SdModule::GetOptionStream( const OUString& rOptionName,
     183             :                                               SdOptionStreamMode eMode )
     184             : {
     185           0 :     ::sd::DrawDocShell*     pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
     186           0 :     SvStorageStreamRef  xStm;
     187             : 
     188           0 :     if( pDocSh )
     189             :     {
     190           0 :         DocumentType    eType = pDocSh->GetDoc()->GetDocumentType();
     191             : 
     192           0 :         if( !xOptionStorage.Is() )
     193             :         {
     194           0 :             INetURLObject aURL( SvtPathOptions().GetUserConfigPath() );
     195             : 
     196           0 :             aURL.Append( OUString( "drawing.cfg" ) );
     197             : 
     198           0 :             SvStream* pStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE );
     199             : 
     200           0 :             if( pStm )
     201           0 :                 xOptionStorage = new SvStorage( pStm, true );
     202             :         }
     203             : 
     204           0 :         OUString        aStmName;
     205             : 
     206           0 :         if( DOCUMENT_TYPE_DRAW == eType )
     207           0 :             aStmName = "Draw_";
     208             :         else
     209           0 :             aStmName = "Impress_";
     210             : 
     211           0 :         aStmName += rOptionName;
     212             : 
     213           0 :         if( SD_OPTION_STORE == eMode || xOptionStorage->IsContained( aStmName ) )
     214           0 :             xStm = xOptionStorage->OpenSotStream( aStmName );
     215             :     }
     216             : 
     217           0 :     return xStm;
     218             : }
     219             : 
     220           0 : SvNumberFormatter* SdModule::GetNumberFormatter()
     221             : {
     222           0 :     if( !pNumberFormatter )
     223           0 :         pNumberFormatter = new SvNumberFormatter( ::comphelper::getProcessComponentContext(), LANGUAGE_SYSTEM );
     224             : 
     225           0 :     return pNumberFormatter;
     226             : }
     227             : 
     228           0 : OutputDevice* SdModule::GetVirtualRefDevice (void)
     229             : {
     230           0 :     return mpVirtualRefDevice;
     231             : }
     232             : 
     233             : /** This method is deprecated and only an alias to
     234             :  *   <member>GetVirtualRefDevice()</member>.  The given argument is ignored.
     235             :  */
     236           0 : OutputDevice* SdModule::GetRefDevice (::sd::DrawDocShell& )
     237             : {
     238           0 :     return GetVirtualRefDevice();
     239           0 : }
     240             : 
     241             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10