office-gobmx/sd/source/ui/app/sdmod.cxx
Kurt Zenker 923a1bac3e INTEGRATION: CWS pchfix04 (1.32.6); FILE MERGED
2007/02/05 09:11:51 os 1.32.6.3: #i73604# usage of ITEMID_* removed
2007/02/05 08:38:54 os 1.32.6.2: #i73604# usage of ITEMID_* removed
2007/01/19 10:49:55 hjs 1.32.6.1: #i73650# warning free with pch
2007-05-10 14:25:05 +00:00

381 lines
11 KiB
C++

/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: sdmod.cxx,v $
*
* $Revision: 1.34 $
*
* last change: $Author: kz $ $Date: 2007-05-10 15:25:05 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
#include <svtools/pathoptions.hxx>
#endif
#ifndef _SVTOOLS_LANGUAGEOPTIONS_HXX
#include <svtools/languageoptions.hxx>
#endif
#ifndef _UNOTOOLS_UCBSTREAMHELPER_HXX
#include <unotools/ucbstreamhelper.hxx>
#endif
#ifndef _URLOBJ_HXX
#include <tools/urlobj.hxx>
#endif
#ifndef _SV_VIRDEV_HXX
#include <vcl/virdev.hxx>
#endif
#ifndef _SFXAPP_HXX //autogen
#include <sfx2/app.hxx>
#endif
#ifndef _SV_STATUS_HXX //autogen
#include <vcl/status.hxx>
#endif
#ifndef _SFXINTITEM_HXX //autogen
#include <svtools/intitem.hxx>
#endif
#ifndef _SFXMSG_HXX //autogen
#include <sfx2/msg.hxx>
#endif
#ifndef _SFXOBJFACE_HXX //autogen
#include <sfx2/objface.hxx>
#endif
#ifndef _SFX_PRINTER_HXX
#include <sfx2/printer.hxx>
#endif
#ifndef _SVX_PSZCTRL_HXX //autogen
#include <svx/pszctrl.hxx>
#endif
#ifndef _SVX_ZOOMCTRL_HXX //autogen
#include <svx/zoomctrl.hxx>
#endif
#ifndef _SVX_MODCTRL_HXX //autogen
#include <svx/modctrl.hxx>
#endif
#ifndef _ZFORLIST_HXX
#include <svtools/zforlist.hxx>
#endif
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
#ifndef _EHDL_HXX
#include <svtools/ehdl.hxx>
#endif
#include <svx/svxids.hrc>
#include <sfx2/srchitem.hxx>
#include <svx/svxerr.hxx>
#include <svx/xmlsecctrl.hxx>
#define _SD_DLL // fuer SD_MOD()
#include "sderror.hxx"
#include "sdmod.hxx"
#include "sddll.hxx"
#include "sdresid.hxx"
#include "optsitem.hxx"
#ifndef SD_DRAW_DOC_SHELL_HXX
#include "DrawDocShell.hxx"
#endif
#include "drawdoc.hxx"
#include "app.hrc"
#include "glob.hrc"
#include "strings.hrc"
#include "res_bmp.hrc"
#include "cfgids.hxx"
#include "tools/SdGlobalResourceContainer.hxx"
TYPEINIT1( SdModule, SfxModule );
#define SdModule
#include "sdslots.hxx"
SFX_IMPL_INTERFACE(SdModule, SfxModule, SdResId(STR_APPLICATIONOBJECTBAR))
{
SFX_STATUSBAR_REGISTRATION(SdResId(RID_DRAW_STATUSBAR));
}
/*************************************************************************
|*
|* Ctor
|*
\************************************************************************/
SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 )
: SfxModule( SfxApplication::CreateResManager("sd"), FALSE,
pFact1, pFact2, NULL ),
pTransferClip(NULL),
pTransferDrag(NULL),
pTransferSelection(NULL),
pImpressOptions(NULL),
pDrawOptions(NULL),
pSearchItem(NULL),
pNumberFormatter( NULL ),
bWaterCan(FALSE),
mpResourceContainer(new ::sd::SdGlobalResourceContainer())
{
SetName( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "StarDraw" ) ) ); // Nicht uebersetzen!
pSearchItem = new SvxSearchItem(SID_SEARCH_ITEM);
pSearchItem->SetAppFlag(SVX_SEARCHAPP_DRAW);
StartListening( *SFX_APP() );
SvxErrorHandler::Get();
mpErrorHdl = new SfxErrorHandler( RID_SD_ERRHDL,
ERRCODE_AREA_SD,
ERRCODE_AREA_SD_END,
GetResMgr() );
// 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 );
}
/*************************************************************************
|*
|* Dtor
|*
\************************************************************************/
SdModule::~SdModule()
{
delete pSearchItem;
if( pNumberFormatter )
delete pNumberFormatter;
delete mpErrorHdl;
delete static_cast< VirtualDevice* >( mpVirtualRefDevice );
}
/*************************************************************************
|*
|* Statusbar erzeugen
|*
\************************************************************************/
#define AUTOSIZE_WIDTH 180
#define TEXT_WIDTH(s) rStatusBar.GetTextWidth((s))
void SdModule::FillStatusBar(StatusBar& rStatusBar)
{
// Hinweis
rStatusBar.InsertItem( SID_CONTEXT, TEXT_WIDTH( String().Fill( 30, 'x' ) ), // vorher 52
SIB_IN | SIB_LEFT | SIB_AUTOSIZE );
// Groesse und Position
rStatusBar.InsertItem( SID_ATTR_SIZE, SvxPosSizeStatusBarControl::GetDefItemWidth(rStatusBar), // vorher 42
SIB_IN | SIB_USERDRAW );
// SIB_AUTOSIZE | SIB_LEFT | SIB_OWNERDRAW );
// Massstab
rStatusBar.InsertItem( SID_ATTR_ZOOM, SvxZoomStatusBarControl::GetDefItemWidth(rStatusBar), SIB_IN | SIB_CENTER );
/*
// Einfuege- / Uberschreibmodus
rStatusBar.InsertItem( SID_ATTR_INSERT, TEXT_WIDTH( "EINFG" ),
SIB_IN | SIB_CENTER );
// Selektionsmodus
rStatusBar.InsertItem( SID_STATUS_SELMODE, TEXT_WIDTH( "ERG" ),
SIB_IN | SIB_CENTER );
*/
// Dokument geaendert
rStatusBar.InsertItem( SID_DOC_MODIFIED, SvxModifyControl::GetDefItemWidth(rStatusBar) );
// signatures
rStatusBar.InsertItem( SID_SIGNATURE, XmlSecStatusBarControl::GetDefItemWidth( rStatusBar ), SIB_USERDRAW );
rStatusBar.SetHelpId(SID_SIGNATURE, SID_SIGNATURE);
// Seite
rStatusBar.InsertItem( SID_STATUS_PAGE, TEXT_WIDTH( String().Fill( 24, 'X' ) ),
SIB_IN | SIB_LEFT );
// Praesentationslayout
rStatusBar.InsertItem( SID_STATUS_LAYOUT, TEXT_WIDTH( String().Fill( 10, 'X' ) ),
SIB_IN | SIB_LEFT | SIB_AUTOSIZE );
}
/*************************************************************************
|*
|* get notifications
|*
\************************************************************************/
void SdModule::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
if( rHint.ISA( SfxSimpleHint ) &&
( (SfxSimpleHint&) rHint ).GetId() == SFX_HINT_DEINITIALIZING )
{
delete pImpressOptions, pImpressOptions = NULL;
delete pDrawOptions, pDrawOptions = NULL;
}
}
/*************************************************************************
|*
|* Optionen zurueckgeben
|*
\************************************************************************/
SdOptions* SdModule::GetSdOptions(DocumentType eDocType)
{
SdOptions* pOptions = NULL;
if (eDocType == DOCUMENT_TYPE_DRAW)
{
if (!pDrawOptions)
pDrawOptions = new SdOptions( SDCFG_DRAW );
pOptions = pDrawOptions;
}
else if (eDocType == DOCUMENT_TYPE_IMPRESS)
{
if (!pImpressOptions)
pImpressOptions = new SdOptions( SDCFG_IMPRESS );
pOptions = pImpressOptions;
}
if( pOptions )
{
UINT16 nMetric = pOptions->GetMetric();
::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
SdDrawDocument* pDoc = NULL;
if (pDocSh)
pDoc = pDocSh->GetDoc();
if( nMetric != 0xffff && pDoc && eDocType == pDoc->GetDocumentType() )
PutItem( SfxUInt16Item( SID_ATTR_METRIC, nMetric ) );
}
return(pOptions);
}
/*************************************************************************
|*
|* Optionen-Stream fuer interne Options oeffnen und zurueckgeben;
|* falls der Stream zum Lesen geoeffnet wird, aber noch nicht
|* angelegt wurde, wird ein 'leeres' RefObject zurueckgegeben
|*
\************************************************************************/
SvStorageStreamRef SdModule::GetOptionStream( const String& rOptionName,
SdOptionStreamMode eMode )
{
::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
SvStorageStreamRef xStm;
if( pDocSh )
{
DocumentType eType = pDocSh->GetDoc()->GetDocumentType();
String aStmName;
if( !xOptionStorage.Is() )
{
INetURLObject aURL( SvtPathOptions().GetUserConfigPath() );
aURL.Append( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "drawing.cfg" ) ) );
SvStream* pStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE );
if( pStm )
xOptionStorage = new SvStorage( pStm, TRUE );
}
if( DOCUMENT_TYPE_DRAW == eType )
aStmName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Draw_" ) );
else
aStmName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Impress_" ) );
aStmName += rOptionName;
if( SD_OPTION_STORE == eMode || xOptionStorage->IsContained( aStmName ) )
xStm = xOptionStorage->OpenSotStream( aStmName );
}
return xStm;
}
/*************************************************************************
|*
\************************************************************************/
SvNumberFormatter* SdModule::GetNumberFormatter()
{
if( !pNumberFormatter )
pNumberFormatter = new SvNumberFormatter( ::comphelper::getProcessServiceFactory(), LANGUAGE_SYSTEM );
return pNumberFormatter;
}
/*************************************************************************
|*
\************************************************************************/
OutputDevice* SdModule::GetVirtualRefDevice (void)
{
return mpVirtualRefDevice;
}
/** This method is deprecated and only an alias to
<member>GetVirtualRefDevice()</member>. The given argument is ignored.
*/
OutputDevice* SdModule::GetRefDevice (::sd::DrawDocShell& )
{
return GetVirtualRefDevice();
}
/*************************************************************************
|*
\************************************************************************/
::com::sun::star::text::WritingMode SdModule::GetDefaultWritingMode() const
{
/*
const SvtLanguageOptions aLanguageOptions;
return( aLanguageOptions.IsCTLFontEnabled() ?
::com::sun::star::text::WritingMode_RL_TB :
::com::sun::star::text::WritingMode_LR_TB );
*/
return ::com::sun::star::text::WritingMode_LR_TB;
}