Files
libreoffice/sd/source/ui/app/sdmod.cxx

242 lines
7.1 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
#include <unotools/pathoptions.hxx>
#include <svl/languageoptions.hxx>
2000-11-10 15:53:19 +00:00
#include <unotools/ucbstreamhelper.hxx>
2000-09-18 16:07:07 +00:00
#include <tools/urlobj.hxx>
2002-07-26 07:32:44 +00:00
#include <vcl/virdev.hxx>
2000-09-18 16:07:07 +00:00
#include <sfx2/app.hxx>
#include <vcl/status.hxx>
#include <svl/intitem.hxx>
2000-09-18 16:07:07 +00:00
#include <sfx2/msg.hxx>
#include <sfx2/objface.hxx>
2002-07-26 07:32:44 +00:00
#include <sfx2/printer.hxx>
2000-09-18 16:07:07 +00:00
#include <svx/pszctrl.hxx>
#include <svx/zoomctrl.hxx>
#include <svx/modctrl.hxx>
#include <svl/zforlist.hxx>
2001-06-19 14:07:14 +00:00
#include <comphelper/processfactory.hxx>
2001-08-20 10:04:49 +00:00
#include <svtools/ehdl.hxx>
2000-09-18 16:07:07 +00:00
#include <svx/svxids.hrc>
2009-12-10 23:06:35 +01:00
#include <svl/srchitem.hxx>
#include <svx/svxerr.hxx>
2000-09-18 16:07:07 +00:00
#include <svx/xmlsecctrl.hxx>
2001-08-20 10:04:49 +00:00
#include "sderror.hxx"
2000-09-18 16:07:07 +00:00
#include "sdmod.hxx"
#include "sdresid.hxx"
#include "optsitem.hxx"
#include "DrawDocShell.hxx"
2000-09-18 16:07:07 +00:00
#include "drawdoc.hxx"
#include "app.hrc"
#include "glob.hrc"
#include "strings.hrc"
#include "res_bmp.hrc"
#include "cfgids.hxx"
#include "tools/SdGlobalResourceContainer.hxx"
2000-09-18 16:07:07 +00:00
TYPEINIT1( SdModule, SfxModule );
2000-09-18 16:07:07 +00:00
#define SdModule
#include "sdslots.hxx"
SFX_IMPL_INTERFACE(SdModule, SfxModule, SdResId(STR_APPLICATIONOBJECTBAR))
{
SFX_STATUSBAR_REGISTRATION(SdResId(RID_DRAW_STATUSBAR));
2000-09-18 16:07:07 +00:00
}
// Ctor
SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 )
: SfxModule( SfxApplication::CreateResManager("sd"), sal_False,
pFact1, pFact2, NULL ),
2001-01-19 18:15:28 +00:00
pTransferClip(NULL),
pTransferDrag(NULL),
pTransferSelection(NULL),
2000-09-18 16:07:07 +00:00
pImpressOptions(NULL),
pDrawOptions(NULL),
pSearchItem(NULL),
pNumberFormatter( NULL ),
bWaterCan(sal_False),
mpResourceContainer(new ::sd::SdGlobalResourceContainer())
2000-09-18 16:07:07 +00:00
{
SetName( OUString( "StarDraw" ) ); // Do not translate!
pSearchItem = new SvxSearchItem(SID_SEARCH_ITEM);
2000-09-18 16:07:07 +00:00
pSearchItem->SetAppFlag(SVX_SEARCHAPP_DRAW);
2000-09-28 17:05:36 +00:00
StartListening( *SFX_APP() );
2011-05-17 21:38:52 +01:00
SvxErrorHandler::ensure();
2001-08-20 10:04:49 +00:00
mpErrorHdl = new SfxErrorHandler( RID_SD_ERRHDL,
ERRCODE_AREA_SD,
ERRCODE_AREA_SD_END,
GetResMgr() );
2002-07-26 07:32:44 +00:00
// Create a new ref device and (by calling SetReferenceDevice())
// set its resolution to 600 DPI. This leads to a visually better
// formatting of text in small sizes (6 point and below.)
VirtualDevice* pDevice = new VirtualDevice;
mpVirtualRefDevice = pDevice;
pDevice->SetMapMode( MAP_100TH_MM );
pDevice->SetReferenceDevice ( VirtualDevice::REFDEV_MODE06 );
2000-09-18 16:07:07 +00:00
}
// Dtor
2000-09-18 16:07:07 +00:00
SdModule::~SdModule()
{
delete pSearchItem;
2002-07-26 07:32:44 +00:00
2001-06-19 14:07:14 +00:00
if( pNumberFormatter )
delete pNumberFormatter;
CWS-TOOLING: integrate CWS appleremote02 2009-01-11 00:33:34 +0100 ericb r266127 : #i97925# start the presentation if and only if an Impress document is focused 2009-01-10 00:02:19 +0100 ericb r266124 : #i96978# cosmetic changes 2009-01-09 23:56:02 +0100 ericb r266123 : #i96978# simplify the code, and make the remote work in windowed mode 2009-01-08 21:25:52 +0100 ericb r266040 : #i96978# avoid to add the eventlistener several times 2009-01-08 14:54:38 +0100 ericb r266013 : #i96978# keep the MEDIA_COMMAND_VOLUME cases for QUARTZ only for the moment 2009-01-08 14:49:17 +0100 ericb r266011 : #i96978# fix wrong comments 2009-01-03 01:42:02 +0100 cloph r265848 : CWS-TOOLING: rebase CWS appleremote02 -> DEV300_m38 (manually, module was left out when using the tooling) 2008-12-30 00:11:30 +0100 ericb r265827 : CWS-TOOLING: rebase CWS appleremote02 to trunk@265758 (milestone: DEV300:m38) 2008-12-29 21:42:14 +0100 ericb r265825 : #i96978# comment the menu in appleremote02 2008-12-29 10:30:40 +0100 ericb r265816 : #i97195# remove the event listener in the dtor 2008-12-23 23:39:55 +0100 ericb r265794 : #i96978# cleanup 2008-12-23 08:49:49 +0100 ericb r265771 : #i96978# add MEDIA_COMMAND_VOLUME_UP and MEDIA_COMMAND_VOLUME_DOWN and the kRemoteButtonMenu (temporarly) 2008-12-23 08:47:27 +0100 ericb r265769 : #i96978# add all cases, for future use 2008-12-20 13:38:25 +0100 ericb r265743 : #i96978# fix a potential breaker (causing warning) 2008-12-20 12:22:15 +0100 ericb r265742 : #i97195# implement the new event listener + callback in Impress, to detect play 2008-12-20 12:20:42 +0100 ericb r265741 : #i97195# add the event listener in SdModule 2008-12-20 12:19:02 +0100 ericb r265740 : #i97195# add the nCommand for MEDIA_COMMAND_PLAY 2008-12-14 18:32:52 +0100 ericb r265456 : #i96978# add the possibility to switch the way to send the PLAY event in debug mode (will be removed once i97195 will be fixed) 2008-12-08 22:18:29 +0100 ericb r265050 : #i96978# removing Carbon dependancy and simplify 2008-12-07 19:54:18 +0100 ericb r264966 : #i96978# implement the new MEDIA_COMMAND events in salinst 2008-12-07 19:53:10 +0100 ericb r264965 : #i96978# add new event type for the Apple Remote on Mac OS X 2008-12-07 19:51:21 +0100 ericb r264964 : #i96978# add gotoLastSlide with MEDIA_COMMAND events (was missing) 2008-12-07 19:46:35 +0100 ericb r264962 : #i96992# fix an error when building with debug enabled 2008-12-07 19:45:04 +0100 ericb r264961 : #i96978# Implement a new event mangement for the Apple remote 2008-12-07 18:59:58 +0100 ericb r264957 : #i96554# fix wrong argument causing warnings 2008-12-07 18:57:56 +0100 ericb r264956 : #i96554# fix wrong argument type 2008-12-07 18:55:22 +0100 ericb r264955 : #i96978# adding a new event type
2009-01-20 15:57:31 +00:00
::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
if( pDocShell )
{
::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
if (pViewShell)
{
// Removing our event listener
Application::RemoveEventListener( LINK( this, SdModule, EventListenerHdl ) );
}
}
2002-07-26 07:32:44 +00:00
CWS-TOOLING: integrate CWS impress178 2009-10-16 19:54:41 +0200 sj r276995 : removed warning 2009-10-16 17:46:12 +0200 sj r276993 : #i103757# applied patch (fixed crash if model changes) 2009-10-16 16:06:07 +0200 sj r276985 : CWS-TOOLING: rebase CWS impress178 to branches/OOO320@276942 (milestone: OOO320:m2) 2009-10-08 13:51:23 +0200 sj r276790 : #i105654# fixed closing of line geometry 2009-10-07 17:26:56 +0200 sj r276762 : #i105606# fixed object shadow 2009-10-07 17:25:39 +0200 sj r276761 : minor improvements 2009-10-07 11:48:26 +0200 af r276745 : #i103047# Prevent context menu of LayoutMenu from being shown when user clicks on background. 2009-10-07 11:33:59 +0200 af r276743 : #i99866# Set position of the design control manually. 2009-10-06 17:18:23 +0200 sj r276721 : minor improvements 2009-10-05 18:34:23 +0200 sj r276692 : #105606# fixed fontsize problem 2009-10-05 17:26:21 +0200 af r276691 : #i105354# Never process more than one request in a row. 2009-10-02 13:24:25 +0200 af r276639 : #i94242# Taking insertion position of slide sorter correctly into account. 2009-10-01 13:46:47 +0200 aw r276602 : #i102224# some Polygon/PolyPolygon usages in SVMConverter ignored the possible curve status of tools::Polygon; added at least an AdaptiveSubdivide 2009-10-01 12:33:56 +0200 aw r276588 : #i102224# ImplWritePolyPolygon killed the curve information at the PolyPolygon by NOT copying the flags 2009-09-30 17:48:56 +0200 aw r276567 : #i102224# removed GetSimple() from Polygon and PolyPolygon, replaced completely with AdaptiveSubdivide 2009-09-30 15:45:46 +0200 aw r276559 : #i102048# secured primitive creation for dimension lines with linestyle none 2009-09-30 14:56:41 +0200 af r276556 : #i105471# Reordered statements in ~SdModule. 2009-09-30 14:47:12 +0200 aw r276555 : #i105373# corrected curve ignoring places in MetaFile export
2009-10-27 15:01:25 +00:00
mpResourceContainer.reset();
// Mark the module in the global AppData structure as deleted.
SdModule** ppShellPointer = (SdModule**)GetAppData(SHL_DRAW);
if (ppShellPointer != NULL)
(*ppShellPointer) = NULL;
2001-08-20 10:04:49 +00:00
delete mpErrorHdl;
delete static_cast< VirtualDevice* >( mpVirtualRefDevice );
2000-09-18 16:07:07 +00:00
}
/// get notifications
void SdModule::Notify( SfxBroadcaster&, const SfxHint& rHint )
2000-09-28 17:05:36 +00:00
{
if( rHint.ISA( SfxSimpleHint ) &&
( (SfxSimpleHint&) rHint ).GetId() == SFX_HINT_DEINITIALIZING )
{
delete pImpressOptions, pImpressOptions = NULL;
delete pDrawOptions, pDrawOptions = NULL;
}
}
2000-09-18 16:07:07 +00:00
/// Return options
2000-09-18 16:07:07 +00:00
SdOptions* SdModule::GetSdOptions(DocumentType eDocType)
{
SdOptions* pOptions = NULL;
if (eDocType == DOCUMENT_TYPE_DRAW)
{
if (!pDrawOptions)
2000-09-28 17:05:36 +00:00
pDrawOptions = new SdOptions( SDCFG_DRAW );
2000-09-18 16:07:07 +00:00
pOptions = pDrawOptions;
}
else if (eDocType == DOCUMENT_TYPE_IMPRESS)
{
if (!pImpressOptions)
2000-09-28 17:05:36 +00:00
pImpressOptions = new SdOptions( SDCFG_IMPRESS );
2000-09-18 16:07:07 +00:00
pOptions = pImpressOptions;
}
if( pOptions )
{
sal_uInt16 nMetric = pOptions->GetMetric();
2000-09-18 16:07:07 +00:00
::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
2000-09-18 16:07:07 +00:00
SdDrawDocument* pDoc = NULL;
if (pDocSh)
pDoc = pDocSh->GetDoc();
if( nMetric != 0xffff && pDoc && eDocType == pDoc->GetDocumentType() )
PutItem( SfxUInt16Item( SID_ATTR_METRIC, nMetric ) );
}
return(pOptions);
}
/**
* Open and return option stream for internal options;
* if the stream is opened for reading but does not exist, an 'empty'
* RefObject is returned
*/
SvStorageStreamRef SdModule::GetOptionStream( const OUString& rOptionName,
2000-09-18 16:07:07 +00:00
SdOptionStreamMode eMode )
{
::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
2000-09-18 16:07:07 +00:00
SvStorageStreamRef xStm;
if( pDocSh )
{
DocumentType eType = pDocSh->GetDoc()->GetDocumentType();
if( !xOptionStorage.Is() )
{
2000-11-10 15:53:19 +00:00
INetURLObject aURL( SvtPathOptions().GetUserConfigPath() );
2000-09-18 16:07:07 +00:00
aURL.Append( OUString( "drawing.cfg" ) );
2000-11-10 15:53:19 +00:00
SvStream* pStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE );
2000-11-10 15:53:19 +00:00
if( pStm )
xOptionStorage = new SvStorage( pStm, sal_True );
2000-09-18 16:07:07 +00:00
}
OUString aStmName;
2000-09-18 16:07:07 +00:00
if( DOCUMENT_TYPE_DRAW == eType )
aStmName = "Draw_";
2000-09-18 16:07:07 +00:00
else
aStmName = "Impress_";
2000-09-18 16:07:07 +00:00
aStmName += rOptionName;
if( SD_OPTION_STORE == eMode || xOptionStorage->IsContained( aStmName ) )
xStm = xOptionStorage->OpenSotStream( aStmName );
2000-09-18 16:07:07 +00:00
}
return xStm;
}
2001-06-19 14:07:14 +00:00
SvNumberFormatter* SdModule::GetNumberFormatter()
{
if( !pNumberFormatter )
pNumberFormatter = new SvNumberFormatter( ::comphelper::getProcessComponentContext(), LANGUAGE_SYSTEM );
2001-06-19 14:07:14 +00:00
return pNumberFormatter;
}
2000-09-18 16:07:07 +00:00
OutputDevice* SdModule::GetVirtualRefDevice (void)
2002-07-26 07:32:44 +00:00
{
return mpVirtualRefDevice;
2002-07-26 07:32:44 +00:00
}
/** This method is deprecated and only an alias to
* <member>GetVirtualRefDevice()</member>. The given argument is ignored.
*/
OutputDevice* SdModule::GetRefDevice (::sd::DrawDocShell& )
2002-07-26 07:32:44 +00:00
{
return GetVirtualRefDevice();
2002-07-26 07:32:44 +00:00
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */