1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10*5b190011SAndrew Rist * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5b190011SAndrew Rist * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19*5b190011SAndrew Rist * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 27cdf0e10cSrcweir #include <svl/languageoptions.hxx> 28cdf0e10cSrcweir #ifndef _UNOTOOLS_UCBSTREAMHELPER_HXX 29cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir #include <tools/urlobj.hxx> 32cdf0e10cSrcweir #include <vcl/virdev.hxx> 33cdf0e10cSrcweir #include <sfx2/app.hxx> 34cdf0e10cSrcweir #include <vcl/status.hxx> 35cdf0e10cSrcweir #include <svl/intitem.hxx> 36cdf0e10cSrcweir #include <sfx2/msg.hxx> 37cdf0e10cSrcweir #include <sfx2/objface.hxx> 38cdf0e10cSrcweir #include <sfx2/printer.hxx> 39cdf0e10cSrcweir #include <svx/pszctrl.hxx> 40cdf0e10cSrcweir #include <svx/zoomctrl.hxx> 41cdf0e10cSrcweir #include <svx/modctrl.hxx> 42cdf0e10cSrcweir #include <svl/zforlist.hxx> 43cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 44cdf0e10cSrcweir #include <svtools/ehdl.hxx> 45cdf0e10cSrcweir 46cdf0e10cSrcweir #include <svx/svxids.hrc> 47cdf0e10cSrcweir #include <svl/srchitem.hxx> 48cdf0e10cSrcweir #include <svx/svxerr.hxx> 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include <svx/xmlsecctrl.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir 53cdf0e10cSrcweir #define _SD_DLL // fuer SD_MOD() 54cdf0e10cSrcweir #include "sderror.hxx" 55cdf0e10cSrcweir #include "sdmod.hxx" 56cdf0e10cSrcweir #include "sddll.hxx" 57cdf0e10cSrcweir #include "sdresid.hxx" 58cdf0e10cSrcweir #include "optsitem.hxx" 59cdf0e10cSrcweir #include "DrawDocShell.hxx" 60cdf0e10cSrcweir #include "drawdoc.hxx" 61cdf0e10cSrcweir #include "app.hrc" 62cdf0e10cSrcweir #include "glob.hrc" 63cdf0e10cSrcweir #include "strings.hrc" 64cdf0e10cSrcweir #include "res_bmp.hrc" 65cdf0e10cSrcweir #include "cfgids.hxx" 66cdf0e10cSrcweir #include "tools/SdGlobalResourceContainer.hxx" 67cdf0e10cSrcweir 68cdf0e10cSrcweir TYPEINIT1( SdModule, SfxModule ); 69cdf0e10cSrcweir 70cdf0e10cSrcweir #define SdModule 71cdf0e10cSrcweir #include "sdslots.hxx" 72cdf0e10cSrcweir 73cdf0e10cSrcweir 74cdf0e10cSrcweir SFX_IMPL_INTERFACE(SdModule, SfxModule, SdResId(STR_APPLICATIONOBJECTBAR)) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir SFX_STATUSBAR_REGISTRATION(SdResId(RID_DRAW_STATUSBAR)); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir /************************************************************************* 80cdf0e10cSrcweir |* 81cdf0e10cSrcweir |* Ctor 82cdf0e10cSrcweir |* 83cdf0e10cSrcweir \************************************************************************/ 84cdf0e10cSrcweir 85cdf0e10cSrcweir SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 ) 86cdf0e10cSrcweir : SfxModule( SfxApplication::CreateResManager("sd"), sal_False, 87cdf0e10cSrcweir pFact1, pFact2, NULL ), 88cdf0e10cSrcweir pTransferClip(NULL), 89cdf0e10cSrcweir pTransferDrag(NULL), 90cdf0e10cSrcweir pTransferSelection(NULL), 91cdf0e10cSrcweir pImpressOptions(NULL), 92cdf0e10cSrcweir pDrawOptions(NULL), 93cdf0e10cSrcweir pSearchItem(NULL), 94cdf0e10cSrcweir pNumberFormatter( NULL ), 95cdf0e10cSrcweir bWaterCan(sal_False), 96cdf0e10cSrcweir mpResourceContainer(new ::sd::SdGlobalResourceContainer()) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir SetName( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "StarDraw" ) ) ); // Nicht uebersetzen! 99cdf0e10cSrcweir pSearchItem = new SvxSearchItem(SID_SEARCH_ITEM); 100cdf0e10cSrcweir pSearchItem->SetAppFlag(SVX_SEARCHAPP_DRAW); 101cdf0e10cSrcweir StartListening( *SFX_APP() ); 102cdf0e10cSrcweir SvxErrorHandler::Get(); 103cdf0e10cSrcweir mpErrorHdl = new SfxErrorHandler( RID_SD_ERRHDL, 104cdf0e10cSrcweir ERRCODE_AREA_SD, 105cdf0e10cSrcweir ERRCODE_AREA_SD_END, 106cdf0e10cSrcweir GetResMgr() ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir // Create a new ref device and (by calling SetReferenceDevice()) 109cdf0e10cSrcweir // set its resolution to 600 DPI. This leads to a visually better 110cdf0e10cSrcweir // formatting of text in small sizes (6 point and below.) 111cdf0e10cSrcweir VirtualDevice* pDevice = new VirtualDevice; 112cdf0e10cSrcweir mpVirtualRefDevice = pDevice; 113cdf0e10cSrcweir pDevice->SetMapMode( MAP_100TH_MM ); 114cdf0e10cSrcweir pDevice->SetReferenceDevice ( VirtualDevice::REFDEV_MODE06 ); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir 118cdf0e10cSrcweir 119cdf0e10cSrcweir /************************************************************************* 120cdf0e10cSrcweir |* 121cdf0e10cSrcweir |* Dtor 122cdf0e10cSrcweir |* 123cdf0e10cSrcweir \************************************************************************/ 124cdf0e10cSrcweir 125cdf0e10cSrcweir SdModule::~SdModule() 126cdf0e10cSrcweir { 127cdf0e10cSrcweir delete pSearchItem; 128cdf0e10cSrcweir 129cdf0e10cSrcweir if( pNumberFormatter ) 130cdf0e10cSrcweir delete pNumberFormatter; 131cdf0e10cSrcweir 132cdf0e10cSrcweir ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); 133cdf0e10cSrcweir if( pDocShell ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir ::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); 136cdf0e10cSrcweir if (pViewShell) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir // Removing our event listener 139cdf0e10cSrcweir Application::RemoveEventListener( LINK( this, SdModule, EventListenerHdl ) ); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir mpResourceContainer.reset(); 144cdf0e10cSrcweir 145cdf0e10cSrcweir // Mark the module in the global AppData structure as deleted. 146cdf0e10cSrcweir SdModule** ppShellPointer = (SdModule**)GetAppData(SHL_DRAW); 147cdf0e10cSrcweir if (ppShellPointer != NULL) 148cdf0e10cSrcweir (*ppShellPointer) = NULL; 149cdf0e10cSrcweir 150cdf0e10cSrcweir delete mpErrorHdl; 151cdf0e10cSrcweir delete static_cast< VirtualDevice* >( mpVirtualRefDevice ); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir 155cdf0e10cSrcweir /************************************************************************* 156cdf0e10cSrcweir |* 157cdf0e10cSrcweir |* get notifications 158cdf0e10cSrcweir |* 159cdf0e10cSrcweir \************************************************************************/ 160cdf0e10cSrcweir 161cdf0e10cSrcweir void SdModule::Notify( SfxBroadcaster&, const SfxHint& rHint ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir if( rHint.ISA( SfxSimpleHint ) && 164cdf0e10cSrcweir ( (SfxSimpleHint&) rHint ).GetId() == SFX_HINT_DEINITIALIZING ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir delete pImpressOptions, pImpressOptions = NULL; 167cdf0e10cSrcweir delete pDrawOptions, pDrawOptions = NULL; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir /************************************************************************* 172cdf0e10cSrcweir |* 173cdf0e10cSrcweir |* Optionen zurueckgeben 174cdf0e10cSrcweir |* 175cdf0e10cSrcweir \************************************************************************/ 176cdf0e10cSrcweir 177cdf0e10cSrcweir SdOptions* SdModule::GetSdOptions(DocumentType eDocType) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir SdOptions* pOptions = NULL; 180cdf0e10cSrcweir 181cdf0e10cSrcweir if (eDocType == DOCUMENT_TYPE_DRAW) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir if (!pDrawOptions) 184cdf0e10cSrcweir pDrawOptions = new SdOptions( SDCFG_DRAW ); 185cdf0e10cSrcweir 186cdf0e10cSrcweir pOptions = pDrawOptions; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir else if (eDocType == DOCUMENT_TYPE_IMPRESS) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir if (!pImpressOptions) 191cdf0e10cSrcweir pImpressOptions = new SdOptions( SDCFG_IMPRESS ); 192cdf0e10cSrcweir 193cdf0e10cSrcweir pOptions = pImpressOptions; 194cdf0e10cSrcweir } 195cdf0e10cSrcweir if( pOptions ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir sal_uInt16 nMetric = pOptions->GetMetric(); 198cdf0e10cSrcweir 199cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() ); 200cdf0e10cSrcweir SdDrawDocument* pDoc = NULL; 201cdf0e10cSrcweir if (pDocSh) 202cdf0e10cSrcweir pDoc = pDocSh->GetDoc(); 203cdf0e10cSrcweir 204cdf0e10cSrcweir if( nMetric != 0xffff && pDoc && eDocType == pDoc->GetDocumentType() ) 205cdf0e10cSrcweir PutItem( SfxUInt16Item( SID_ATTR_METRIC, nMetric ) ); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir return(pOptions); 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir /************************************************************************* 212cdf0e10cSrcweir |* 213cdf0e10cSrcweir |* Optionen-Stream fuer interne Options oeffnen und zurueckgeben; 214cdf0e10cSrcweir |* falls der Stream zum Lesen geoeffnet wird, aber noch nicht 215cdf0e10cSrcweir |* angelegt wurde, wird ein 'leeres' RefObject zurueckgegeben 216cdf0e10cSrcweir |* 217cdf0e10cSrcweir \************************************************************************/ 218cdf0e10cSrcweir 219cdf0e10cSrcweir SvStorageStreamRef SdModule::GetOptionStream( const String& rOptionName, 220cdf0e10cSrcweir SdOptionStreamMode eMode ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() ); 223cdf0e10cSrcweir SvStorageStreamRef xStm; 224cdf0e10cSrcweir 225cdf0e10cSrcweir if( pDocSh ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir DocumentType eType = pDocSh->GetDoc()->GetDocumentType(); 228cdf0e10cSrcweir String aStmName; 229cdf0e10cSrcweir 230cdf0e10cSrcweir if( !xOptionStorage.Is() ) 231cdf0e10cSrcweir { 232cdf0e10cSrcweir INetURLObject aURL( SvtPathOptions().GetUserConfigPath() ); 233cdf0e10cSrcweir 234cdf0e10cSrcweir aURL.Append( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "drawing.cfg" ) ) ); 235cdf0e10cSrcweir 236cdf0e10cSrcweir SvStream* pStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READWRITE ); 237cdf0e10cSrcweir 238cdf0e10cSrcweir if( pStm ) 239cdf0e10cSrcweir xOptionStorage = new SvStorage( pStm, sal_True ); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir 242cdf0e10cSrcweir if( DOCUMENT_TYPE_DRAW == eType ) 243cdf0e10cSrcweir aStmName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Draw_" ) ); 244cdf0e10cSrcweir else 245cdf0e10cSrcweir aStmName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Impress_" ) ); 246cdf0e10cSrcweir 247cdf0e10cSrcweir aStmName += rOptionName; 248cdf0e10cSrcweir 249cdf0e10cSrcweir if( SD_OPTION_STORE == eMode || xOptionStorage->IsContained( aStmName ) ) 250cdf0e10cSrcweir xStm = xOptionStorage->OpenSotStream( aStmName ); 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir return xStm; 254cdf0e10cSrcweir } 255cdf0e10cSrcweir 256cdf0e10cSrcweir /************************************************************************* 257cdf0e10cSrcweir |* 258cdf0e10cSrcweir \************************************************************************/ 259cdf0e10cSrcweir 260cdf0e10cSrcweir SvNumberFormatter* SdModule::GetNumberFormatter() 261cdf0e10cSrcweir { 262cdf0e10cSrcweir if( !pNumberFormatter ) 263cdf0e10cSrcweir pNumberFormatter = new SvNumberFormatter( ::comphelper::getProcessServiceFactory(), LANGUAGE_SYSTEM ); 264cdf0e10cSrcweir 265cdf0e10cSrcweir return pNumberFormatter; 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir /************************************************************************* 269cdf0e10cSrcweir |* 270cdf0e10cSrcweir \************************************************************************/ 271cdf0e10cSrcweir 272cdf0e10cSrcweir OutputDevice* SdModule::GetVirtualRefDevice (void) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir return mpVirtualRefDevice; 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir /** This method is deprecated and only an alias to 278cdf0e10cSrcweir <member>GetVirtualRefDevice()</member>. The given argument is ignored. 279cdf0e10cSrcweir */ 280cdf0e10cSrcweir OutputDevice* SdModule::GetRefDevice (::sd::DrawDocShell& ) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir return GetVirtualRefDevice(); 283cdf0e10cSrcweir } 284