1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir #include <swtypes.hxx> 27cdf0e10cSrcweir #include <mailmergehelper.hxx> 28cdf0e10cSrcweir #include <svtools/stdctrl.hxx> 29cdf0e10cSrcweir #include <mmconfigitem.hxx> 30cdf0e10cSrcweir #ifndef _DOCSH_HXX 31cdf0e10cSrcweir #include <docsh.hxx> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx> 34cdf0e10cSrcweir #include <sfx2/docfile.hxx> 35cdf0e10cSrcweir #include <sfx2/app.hxx> 36cdf0e10cSrcweir #include <sfx2/fcontnr.hxx> 37cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 38cdf0e10cSrcweir #include <com/sun/star/sdb/XColumn.hpp> 39cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 40cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" 41cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePicker.hpp> 42cdf0e10cSrcweir #include "com/sun/star/mail/MailServiceProvider.hpp" 43cdf0e10cSrcweir #include "com/sun/star/mail/XSmtpService.hpp" 44cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 45cdf0e10cSrcweir #include <vcl/msgbox.hxx> 46cdf0e10cSrcweir #ifndef _PASSWD_HXX 47cdf0e10cSrcweir #include <sfx2/passwd.hxx> 48cdf0e10cSrcweir #endif 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include <dbui.hrc> 51cdf0e10cSrcweir 52cdf0e10cSrcweir using namespace ::com::sun::star; 53cdf0e10cSrcweir using namespace ::com::sun::star::uno; 54cdf0e10cSrcweir using namespace ::com::sun::star::container; 55cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 56cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 57cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 58cdf0e10cSrcweir 59cdf0e10cSrcweir using rtl::OUString; 60cdf0e10cSrcweir 61cdf0e10cSrcweir //using ::rtl::OUString; 62cdf0e10cSrcweir 63cdf0e10cSrcweir namespace SwMailMergeHelper 64cdf0e10cSrcweir { 65cdf0e10cSrcweir 66cdf0e10cSrcweir /*-- 14.06.2004 12:29:19--------------------------------------------------- 67cdf0e10cSrcweir 68cdf0e10cSrcweir -----------------------------------------------------------------------*/ 69cdf0e10cSrcweir String CallSaveAsDialog(String& rFilter) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir ErrCode nRet; 72cdf0e10cSrcweir String sFactory(String::CreateFromAscii(SwDocShell::Factory().GetShortName())); 73cdf0e10cSrcweir ::sfx2::FileDialogHelper aDialog( ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, 74cdf0e10cSrcweir 0, 75cdf0e10cSrcweir sFactory ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir String sRet; 78cdf0e10cSrcweir nRet = aDialog.Execute(); 79cdf0e10cSrcweir if(ERRCODE_NONE == nRet) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir uno::Reference < ui::dialogs::XFilePicker > xFP = aDialog.GetFilePicker(); 82cdf0e10cSrcweir sRet = xFP->getFiles().getConstArray()[0]; 83cdf0e10cSrcweir rFilter = aDialog.GetRealFilter(); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir return sRet; 86cdf0e10cSrcweir } 87cdf0e10cSrcweir /*-- 20.08.2004 09:39:18--------------------------------------------------- 88cdf0e10cSrcweir simple address check: check for '@' 89cdf0e10cSrcweir for at least one '.' after the '@' 90cdf0e10cSrcweir and for at least to characters before and after the dot 91cdf0e10cSrcweir -----------------------------------------------------------------------*/ 92cdf0e10cSrcweir bool CheckMailAddress( const ::rtl::OUString& rMailAddress ) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir String sAddress(rMailAddress); 95cdf0e10cSrcweir if(!(sAddress.GetTokenCount('@') == 2)) 96cdf0e10cSrcweir return false; 97cdf0e10cSrcweir sAddress = sAddress.GetToken(1, '@'); 98cdf0e10cSrcweir if(sAddress.GetTokenCount('.') < 2) 99cdf0e10cSrcweir return false; 100cdf0e10cSrcweir if(sAddress.GetToken( 0, '.').Len() < 2 || sAddress.GetToken( 1, '.').Len() < 2) 101cdf0e10cSrcweir return false; 102cdf0e10cSrcweir return true; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir /*-- 28.12.2004 10:16:02--------------------------------------------------- 106cdf0e10cSrcweir 107cdf0e10cSrcweir -----------------------------------------------------------------------*/ 108cdf0e10cSrcweir uno::Reference< mail::XSmtpService > ConnectToSmtpServer( 109cdf0e10cSrcweir SwMailMergeConfigItem& rConfigItem, 110cdf0e10cSrcweir uno::Reference< mail::XMailService >& rxInMailService, 111cdf0e10cSrcweir const String& rInMailServerPassword, 112cdf0e10cSrcweir const String& rOutMailServerPassword, 113cdf0e10cSrcweir Window* pDialogParentWindow ) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir uno::Reference< mail::XSmtpService > xSmtpServer; 116cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory> rMgr = ::comphelper::getProcessServiceFactory(); 117cdf0e10cSrcweir if (rMgr.is()) 118cdf0e10cSrcweir try 119cdf0e10cSrcweir { 120cdf0e10cSrcweir uno::Reference< mail::XMailServiceProvider > xMailServiceProvider = 121cdf0e10cSrcweir mail::MailServiceProvider::create(getCurrentCmpCtx(rMgr)); 122cdf0e10cSrcweir xSmtpServer = uno::Reference< mail::XSmtpService > ( 123cdf0e10cSrcweir xMailServiceProvider->create( 124cdf0e10cSrcweir mail::MailServiceType_SMTP 125cdf0e10cSrcweir ), uno::UNO_QUERY); 126cdf0e10cSrcweir 127cdf0e10cSrcweir uno::Reference< mail::XConnectionListener> xConnectionListener(new SwConnectionListener()); 128cdf0e10cSrcweir 129cdf0e10cSrcweir if(rConfigItem.IsAuthentication() && rConfigItem.IsSMTPAfterPOP()) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir uno::Reference< mail::XMailService > xInMailService = 132cdf0e10cSrcweir xMailServiceProvider->create( 133cdf0e10cSrcweir rConfigItem.IsInServerPOP() ? 134cdf0e10cSrcweir mail::MailServiceType_POP3 : mail::MailServiceType_IMAP); 135cdf0e10cSrcweir //authenticate at the POP or IMAP server first 136cdf0e10cSrcweir String sPasswd = rConfigItem.GetInServerPassword(); 137cdf0e10cSrcweir if(rInMailServerPassword.Len()) 138cdf0e10cSrcweir sPasswd = rInMailServerPassword; 139cdf0e10cSrcweir uno::Reference<mail::XAuthenticator> xAuthenticator = 140cdf0e10cSrcweir new SwAuthenticator( 141cdf0e10cSrcweir rConfigItem.GetInServerUserName(), 142cdf0e10cSrcweir sPasswd, 143cdf0e10cSrcweir pDialogParentWindow); 144cdf0e10cSrcweir 145cdf0e10cSrcweir xInMailService->addConnectionListener(xConnectionListener); 146cdf0e10cSrcweir //check connection 147cdf0e10cSrcweir uno::Reference< uno::XCurrentContext> xConnectionContext = 148cdf0e10cSrcweir new SwConnectionContext( 149cdf0e10cSrcweir rConfigItem.GetInServerName(), 150cdf0e10cSrcweir rConfigItem.GetInServerPort(), 151cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "Insecure" )); 152cdf0e10cSrcweir xInMailService->connect(xConnectionContext, xAuthenticator); 153cdf0e10cSrcweir rxInMailService = xInMailService; 154cdf0e10cSrcweir } 155cdf0e10cSrcweir uno::Reference< mail::XAuthenticator> xAuthenticator; 156cdf0e10cSrcweir if(rConfigItem.IsAuthentication() && 157cdf0e10cSrcweir !rConfigItem.IsSMTPAfterPOP() && 158cdf0e10cSrcweir rConfigItem.GetMailUserName().getLength()) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir String sPasswd = rConfigItem.GetMailPassword(); 161cdf0e10cSrcweir if(rOutMailServerPassword.Len()) 162cdf0e10cSrcweir sPasswd = rOutMailServerPassword; 163cdf0e10cSrcweir xAuthenticator = 164cdf0e10cSrcweir new SwAuthenticator(rConfigItem.GetMailUserName(), 165cdf0e10cSrcweir sPasswd, 166cdf0e10cSrcweir pDialogParentWindow); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir else 169cdf0e10cSrcweir xAuthenticator = new SwAuthenticator(); 170cdf0e10cSrcweir //just to check if the server exists 171cdf0e10cSrcweir xSmtpServer->getSupportedConnectionTypes(); 172cdf0e10cSrcweir //check connection 173cdf0e10cSrcweir 174cdf0e10cSrcweir uno::Reference< uno::XCurrentContext> xConnectionContext = 175cdf0e10cSrcweir new SwConnectionContext( 176cdf0e10cSrcweir rConfigItem.GetMailServer(), 177cdf0e10cSrcweir rConfigItem.GetMailPort(), 178cdf0e10cSrcweir ::rtl::OUString::createFromAscii( rConfigItem.IsSecureConnection() ? "Ssl" : "Insecure")); 179cdf0e10cSrcweir xSmtpServer->connect(xConnectionContext, xAuthenticator); 180cdf0e10cSrcweir rxInMailService = uno::Reference< mail::XMailService >( xSmtpServer, uno::UNO_QUERY ); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir catch(uno::Exception& ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir DBG_ERROR("exception caught"); 185cdf0e10cSrcweir } 186cdf0e10cSrcweir return xSmtpServer; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir 190cdf0e10cSrcweir } //namespace 191cdf0e10cSrcweir 192cdf0e10cSrcweir /*-- 06.04.2004 10:31:27--------------------------------------------------- 193cdf0e10cSrcweir 194cdf0e10cSrcweir -----------------------------------------------------------------------*/ 195cdf0e10cSrcweir SwBoldFixedInfo::SwBoldFixedInfo(Window* pParent, const ResId& rResId) : 196cdf0e10cSrcweir FixedInfo(pParent, rResId) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir Font aFont = GetFont(); 199cdf0e10cSrcweir aFont.SetWeight( WEIGHT_BOLD ); 200cdf0e10cSrcweir SetFont( aFont ); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir /*-- 06.04.2004 10:31:27--------------------------------------------------- 203cdf0e10cSrcweir 204cdf0e10cSrcweir -----------------------------------------------------------------------*/ 205cdf0e10cSrcweir SwBoldFixedInfo::~SwBoldFixedInfo() 206cdf0e10cSrcweir { 207cdf0e10cSrcweir } 208cdf0e10cSrcweir struct SwAddressPreview_Impl 209cdf0e10cSrcweir { 210cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aAdresses; 211cdf0e10cSrcweir sal_uInt16 nRows; 212cdf0e10cSrcweir sal_uInt16 nColumns; 213cdf0e10cSrcweir sal_uInt16 nSelectedAddress; 214cdf0e10cSrcweir bool bEnableScrollBar; 215cdf0e10cSrcweir 216cdf0e10cSrcweir SwAddressPreview_Impl() : 217cdf0e10cSrcweir nRows(1), 218cdf0e10cSrcweir nColumns(1), 219cdf0e10cSrcweir nSelectedAddress(0), 220cdf0e10cSrcweir bEnableScrollBar(false) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir } 223cdf0e10cSrcweir }; 224cdf0e10cSrcweir /*-- 27.04.2004 14:01:22--------------------------------------------------- 225cdf0e10cSrcweir 226cdf0e10cSrcweir -----------------------------------------------------------------------*/ 227cdf0e10cSrcweir SwAddressPreview::SwAddressPreview(Window* pParent, const ResId rResId) : 228cdf0e10cSrcweir Window( pParent, rResId ), 229cdf0e10cSrcweir aVScrollBar(this, WB_VSCROLL), 230cdf0e10cSrcweir pImpl(new SwAddressPreview_Impl()) 231cdf0e10cSrcweir { 232cdf0e10cSrcweir aVScrollBar.SetScrollHdl(LINK(this, SwAddressPreview, ScrollHdl)); 233cdf0e10cSrcweir Size aSize(GetOutputSizePixel()); 234cdf0e10cSrcweir Size aScrollSize(aVScrollBar.GetSizePixel()); 235cdf0e10cSrcweir aScrollSize.Height() = aSize.Height(); 236cdf0e10cSrcweir aVScrollBar.SetSizePixel(aScrollSize); 237cdf0e10cSrcweir Point aSrollPos(aSize.Width() - aScrollSize.Width(), 0); 238cdf0e10cSrcweir aVScrollBar.SetPosPixel(aSrollPos); 239cdf0e10cSrcweir Show(); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir /*-- 27.04.2004 14:01:22--------------------------------------------------- 242cdf0e10cSrcweir 243cdf0e10cSrcweir -----------------------------------------------------------------------*/ 244cdf0e10cSrcweir SwAddressPreview::~SwAddressPreview() 245cdf0e10cSrcweir { 246cdf0e10cSrcweir } 247cdf0e10cSrcweir /*-- 25.06.2004 11:50:55--------------------------------------------------- 248cdf0e10cSrcweir 249cdf0e10cSrcweir -----------------------------------------------------------------------*/ 250cdf0e10cSrcweir IMPL_LINK(SwAddressPreview, ScrollHdl, ScrollBar*, EMPTYARG) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir Invalidate(); 253cdf0e10cSrcweir return 0; 254cdf0e10cSrcweir } 255cdf0e10cSrcweir /*-- 27.04.2004 14:01:22--------------------------------------------------- 256cdf0e10cSrcweir 257cdf0e10cSrcweir -----------------------------------------------------------------------*/ 258cdf0e10cSrcweir void SwAddressPreview::AddAddress(const ::rtl::OUString& rAddress) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir pImpl->aAdresses.push_back(rAddress); 261cdf0e10cSrcweir UpdateScrollBar(); 262cdf0e10cSrcweir } 263cdf0e10cSrcweir /*-- 27.04.2004 14:01:23--------------------------------------------------- 264cdf0e10cSrcweir 265cdf0e10cSrcweir -----------------------------------------------------------------------*/ 266cdf0e10cSrcweir void SwAddressPreview::SetAddress(const ::rtl::OUString& rAddress) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir pImpl->aAdresses.clear(); 269cdf0e10cSrcweir pImpl->aAdresses.push_back(rAddress); 270cdf0e10cSrcweir aVScrollBar.Show(sal_False); 271cdf0e10cSrcweir Invalidate(); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir /*-- 27.04.2004 14:01:23--------------------------------------------------- 274cdf0e10cSrcweir 275cdf0e10cSrcweir -----------------------------------------------------------------------*/ 276cdf0e10cSrcweir sal_uInt16 SwAddressPreview::GetSelectedAddress()const 277cdf0e10cSrcweir { 278cdf0e10cSrcweir DBG_ASSERT(pImpl->nSelectedAddress < pImpl->aAdresses.size(), "selection invalid"); 279cdf0e10cSrcweir return pImpl->nSelectedAddress; 280cdf0e10cSrcweir } 281cdf0e10cSrcweir /*-- 25.06.2004 10:32:48--------------------------------------------------- 282cdf0e10cSrcweir 283cdf0e10cSrcweir -----------------------------------------------------------------------*/ 284cdf0e10cSrcweir void SwAddressPreview::SelectAddress(sal_uInt16 nSelect) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir DBG_ASSERT(pImpl->nSelectedAddress < pImpl->aAdresses.size(), "selection invalid"); 287cdf0e10cSrcweir pImpl->nSelectedAddress = nSelect; 288cdf0e10cSrcweir // now make it visible.. 289cdf0e10cSrcweir sal_uInt16 nSelectRow = nSelect / pImpl->nColumns; 290cdf0e10cSrcweir sal_uInt16 nStartRow = (sal_uInt16)aVScrollBar.GetThumbPos(); 291cdf0e10cSrcweir if( (nSelectRow < nStartRow) || (nSelectRow >= (nStartRow + pImpl->nRows) )) 292cdf0e10cSrcweir aVScrollBar.SetThumbPos( nSelectRow ); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir /*-- 25.06.2004 11:00:40--------------------------------------------------- 295cdf0e10cSrcweir 296cdf0e10cSrcweir -----------------------------------------------------------------------*/ 297cdf0e10cSrcweir void SwAddressPreview::Clear() 298cdf0e10cSrcweir { 299cdf0e10cSrcweir pImpl->aAdresses.clear(); 300cdf0e10cSrcweir pImpl->nSelectedAddress = 0; 301cdf0e10cSrcweir UpdateScrollBar(); 302cdf0e10cSrcweir } 303cdf0e10cSrcweir /*-- 28.04.2004 12:05:50--------------------------------------------------- 304cdf0e10cSrcweir 305cdf0e10cSrcweir -----------------------------------------------------------------------*/ 306cdf0e10cSrcweir void SwAddressPreview::ReplaceSelectedAddress(const ::rtl::OUString& rNew) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir pImpl->aAdresses[pImpl->nSelectedAddress] = rNew; 309cdf0e10cSrcweir Invalidate(); 310cdf0e10cSrcweir } 311cdf0e10cSrcweir /*-- 25.06.2004 11:30:41--------------------------------------------------- 312cdf0e10cSrcweir 313cdf0e10cSrcweir -----------------------------------------------------------------------*/ 314cdf0e10cSrcweir void SwAddressPreview::RemoveSelectedAddress() 315cdf0e10cSrcweir { 316cdf0e10cSrcweir pImpl->aAdresses.erase(pImpl->aAdresses.begin() + pImpl->nSelectedAddress); 317cdf0e10cSrcweir if(pImpl->nSelectedAddress) 318cdf0e10cSrcweir --pImpl->nSelectedAddress; 319cdf0e10cSrcweir UpdateScrollBar(); 320cdf0e10cSrcweir Invalidate(); 321cdf0e10cSrcweir } 322cdf0e10cSrcweir /*-- 27.04.2004 14:01:23--------------------------------------------------- 323cdf0e10cSrcweir 324cdf0e10cSrcweir -----------------------------------------------------------------------*/ 325cdf0e10cSrcweir void SwAddressPreview::SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir pImpl->nRows = nRows; 328cdf0e10cSrcweir pImpl->nColumns = nColumns; 329cdf0e10cSrcweir UpdateScrollBar(); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir /*-- 25.06.2004 13:54:03--------------------------------------------------- 332cdf0e10cSrcweir 333cdf0e10cSrcweir -----------------------------------------------------------------------*/ 334cdf0e10cSrcweir void SwAddressPreview::EnableScrollBar(bool bEnable) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir pImpl->bEnableScrollBar = bEnable; 337cdf0e10cSrcweir } 338cdf0e10cSrcweir /*-- 25.06.2004 11:55:52--------------------------------------------------- 339cdf0e10cSrcweir 340cdf0e10cSrcweir -----------------------------------------------------------------------*/ 341cdf0e10cSrcweir void SwAddressPreview::UpdateScrollBar() 342cdf0e10cSrcweir { 343cdf0e10cSrcweir if(pImpl->nColumns) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir aVScrollBar.SetVisibleSize(pImpl->nRows); 346cdf0e10cSrcweir sal_uInt16 nResultingRows = (sal_uInt16)(pImpl->aAdresses.size() + pImpl->nColumns - 1) / pImpl->nColumns; 347cdf0e10cSrcweir ++nResultingRows; 348cdf0e10cSrcweir aVScrollBar.Show(pImpl->bEnableScrollBar && nResultingRows > pImpl->nRows); 349cdf0e10cSrcweir aVScrollBar.SetRange(Range(0, nResultingRows)); 350cdf0e10cSrcweir if(aVScrollBar.GetThumbPos() > nResultingRows) 351cdf0e10cSrcweir aVScrollBar.SetThumbPos(nResultingRows); 352cdf0e10cSrcweir } 353cdf0e10cSrcweir } 354cdf0e10cSrcweir /*-- 27.04.2004 14:01:23--------------------------------------------------- 355cdf0e10cSrcweir 356cdf0e10cSrcweir -----------------------------------------------------------------------*/ 357cdf0e10cSrcweir void SwAddressPreview::Paint(const Rectangle&) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir const StyleSettings& rSettings = GetSettings().GetStyleSettings(); 360cdf0e10cSrcweir SetFillColor(rSettings.GetWindowColor()); 361cdf0e10cSrcweir SetLineColor( Color(COL_TRANSPARENT) ); 362cdf0e10cSrcweir DrawRect( Rectangle(Point(0, 0), GetOutputSizePixel()) ); 363cdf0e10cSrcweir Color aPaintColor(IsEnabled() ? rSettings.GetWindowTextColor() : rSettings.GetDisableColor()); 364cdf0e10cSrcweir SetLineColor(aPaintColor); 365cdf0e10cSrcweir Font aFont(GetFont()); 366cdf0e10cSrcweir aFont.SetColor(aPaintColor); 367cdf0e10cSrcweir SetFont(aFont); 368cdf0e10cSrcweir 369cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 370cdf0e10cSrcweir sal_uInt16 nStartRow = 0; 371cdf0e10cSrcweir if(aVScrollBar.IsVisible()) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir aSize.Width() -= aVScrollBar.GetSizePixel().Width(); 374cdf0e10cSrcweir nStartRow = (sal_uInt16)aVScrollBar.GetThumbPos(); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir Size aPartSize( aSize.Width()/pImpl->nColumns, aSize.Height()/pImpl->nRows ); 377cdf0e10cSrcweir aPartSize.Width() -= 2; 378cdf0e10cSrcweir aPartSize.Height() -= 2; 379cdf0e10cSrcweir 380cdf0e10cSrcweir sal_uInt16 nAddress = nStartRow * pImpl->nColumns; 381cdf0e10cSrcweir const sal_uInt16 nNumAddresses = static_cast< sal_uInt16 >(pImpl->aAdresses.size()); 382cdf0e10cSrcweir for(sal_uInt16 nRow = 0; nRow < pImpl->nRows ; ++nRow) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir for(sal_uInt16 nCol = 0; nCol < pImpl->nColumns; ++nCol) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir if(nAddress >= nNumAddresses) 387cdf0e10cSrcweir break; 388cdf0e10cSrcweir Point aPos(nCol * aPartSize.Width(), (nRow) * aPartSize.Height()); 389cdf0e10cSrcweir aPos.Move(1,1); 390cdf0e10cSrcweir bool bIsSelected = nAddress == pImpl->nSelectedAddress; 391cdf0e10cSrcweir if((pImpl->nColumns * pImpl->nRows) == 1) 392cdf0e10cSrcweir bIsSelected = false; 393cdf0e10cSrcweir ::rtl::OUString adr(pImpl->aAdresses[nAddress]); 394cdf0e10cSrcweir DrawText_Impl(adr,aPos,aPartSize,bIsSelected); 395cdf0e10cSrcweir ++nAddress; 396cdf0e10cSrcweir } 397cdf0e10cSrcweir } 398cdf0e10cSrcweir SetClipRegion(); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir /*-- 07.06.2004 15:44:15--------------------------------------------------- 402cdf0e10cSrcweir 403cdf0e10cSrcweir -----------------------------------------------------------------------*/ 404cdf0e10cSrcweir void SwAddressPreview::MouseButtonDown( const MouseEvent& rMEvt ) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir Window::MouseButtonDown(rMEvt); 407cdf0e10cSrcweir if(rMEvt.IsLeft() && ( pImpl->nRows || pImpl->nColumns)) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir //determine the selected address 410cdf0e10cSrcweir const Point& rMousePos = rMEvt.GetPosPixel(); 411cdf0e10cSrcweir Size aSize(GetOutputSizePixel()); 412cdf0e10cSrcweir Size aPartSize( aSize.Width()/pImpl->nColumns, aSize.Height()/pImpl->nRows ); 413cdf0e10cSrcweir sal_uInt32 nRow = rMousePos.Y() / aPartSize.Height() ; 414cdf0e10cSrcweir if(aVScrollBar.IsVisible()) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir nRow += (sal_uInt16)aVScrollBar.GetThumbPos(); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir sal_uInt32 nCol = rMousePos.X() / aPartSize.Width(); 419cdf0e10cSrcweir sal_uInt32 nSelect = nRow * pImpl->nColumns + nCol; 420cdf0e10cSrcweir 421cdf0e10cSrcweir if( nSelect < pImpl->aAdresses.size() && 422cdf0e10cSrcweir pImpl->nSelectedAddress != (sal_uInt16)nSelect) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir pImpl->nSelectedAddress = (sal_uInt16)nSelect; 425cdf0e10cSrcweir m_aSelectHdl.Call(this); 426cdf0e10cSrcweir } 427cdf0e10cSrcweir Invalidate(); 428cdf0e10cSrcweir } 429cdf0e10cSrcweir } 430cdf0e10cSrcweir /*-- 01.07.2004 12:33:59--------------------------------------------------- 431cdf0e10cSrcweir 432cdf0e10cSrcweir -----------------------------------------------------------------------*/ 433cdf0e10cSrcweir void SwAddressPreview::KeyInput( const KeyEvent& rKEvt ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode(); 436cdf0e10cSrcweir if(pImpl->nRows || pImpl->nColumns) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir sal_uInt32 nSelectedRow = (pImpl->nSelectedAddress + 1)/ pImpl->nColumns; 439cdf0e10cSrcweir sal_uInt32 nSelectedColumn = pImpl->nSelectedAddress % nSelectedRow; 440cdf0e10cSrcweir switch(nKey) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir case KEY_UP: 443cdf0e10cSrcweir if(nSelectedRow) 444cdf0e10cSrcweir --nSelectedRow; 445cdf0e10cSrcweir break; 446cdf0e10cSrcweir case KEY_DOWN: 447cdf0e10cSrcweir if(pImpl->aAdresses.size() > sal_uInt32(pImpl->nSelectedAddress + pImpl->nColumns)) 448cdf0e10cSrcweir ++nSelectedRow; 449cdf0e10cSrcweir break; 450cdf0e10cSrcweir case KEY_LEFT: 451cdf0e10cSrcweir if(nSelectedColumn) 452cdf0e10cSrcweir --nSelectedColumn; 453cdf0e10cSrcweir break; 454cdf0e10cSrcweir case KEY_RIGHT: 455cdf0e10cSrcweir if(nSelectedColumn < sal_uInt32(pImpl->nColumns - 1) && 456cdf0e10cSrcweir pImpl->aAdresses.size() - 1 > pImpl->nSelectedAddress ) 457cdf0e10cSrcweir ++nSelectedColumn; 458cdf0e10cSrcweir break; 459cdf0e10cSrcweir } 460cdf0e10cSrcweir sal_uInt32 nSelect = nSelectedRow * pImpl->nColumns + nSelectedColumn; 461cdf0e10cSrcweir if( nSelect < pImpl->aAdresses.size() && 462cdf0e10cSrcweir pImpl->nSelectedAddress != (sal_uInt16)nSelect) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir pImpl->nSelectedAddress = (sal_uInt16)nSelect; 465cdf0e10cSrcweir m_aSelectHdl.Call(this); 466cdf0e10cSrcweir Invalidate(); 467cdf0e10cSrcweir } 468cdf0e10cSrcweir } 469cdf0e10cSrcweir else 470cdf0e10cSrcweir Window::KeyInput(rKEvt); 471cdf0e10cSrcweir } 472cdf0e10cSrcweir /*-- 05.07.2004 12:02:28--------------------------------------------------- 473cdf0e10cSrcweir 474cdf0e10cSrcweir -----------------------------------------------------------------------*/ 475cdf0e10cSrcweir void SwAddressPreview::StateChanged( StateChangedType nStateChange ) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir if(nStateChange == STATE_CHANGE_ENABLE) 478cdf0e10cSrcweir Invalidate(); 479cdf0e10cSrcweir Window::StateChanged(nStateChange); 480cdf0e10cSrcweir } 481cdf0e10cSrcweir /*-- 27.04.2004 14:01:23--------------------------------------------------- 482cdf0e10cSrcweir 483cdf0e10cSrcweir -----------------------------------------------------------------------*/ 484cdf0e10cSrcweir void SwAddressPreview::DrawText_Impl( 485cdf0e10cSrcweir const ::rtl::OUString& rAddress, const Point& rTopLeft, const Size& rSize, bool bIsSelected) 486cdf0e10cSrcweir { 487cdf0e10cSrcweir SetClipRegion( Region( Rectangle(rTopLeft, rSize)) ); 488cdf0e10cSrcweir if(bIsSelected) 489cdf0e10cSrcweir { 490cdf0e10cSrcweir //selection rectangle 491cdf0e10cSrcweir SetFillColor(Color(COL_TRANSPARENT)); 492cdf0e10cSrcweir DrawRect(Rectangle(rTopLeft, rSize)); 493cdf0e10cSrcweir } 494cdf0e10cSrcweir sal_Int32 nHeight = GetTextHeight(); 495cdf0e10cSrcweir String sAddress(rAddress); 496cdf0e10cSrcweir sal_uInt16 nTokens = sAddress.GetTokenCount('\n'); 497cdf0e10cSrcweir Point aStart = rTopLeft; 498cdf0e10cSrcweir //put it away from the border 499cdf0e10cSrcweir aStart.Move( 2, 2); 500cdf0e10cSrcweir for(sal_uInt16 nToken = 0; nToken < nTokens; nToken++) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir DrawText( aStart, sAddress.GetToken(nToken, '\n') ); 503cdf0e10cSrcweir aStart.Y() += nHeight; 504cdf0e10cSrcweir } 505cdf0e10cSrcweir } 506cdf0e10cSrcweir /*-- 29.04.2004 11:24:47--------------------------------------------------- 507cdf0e10cSrcweir 508cdf0e10cSrcweir -----------------------------------------------------------------------*/ 509cdf0e10cSrcweir String SwAddressPreview::FillData( 510cdf0e10cSrcweir const ::rtl::OUString& rAddress, 511cdf0e10cSrcweir SwMailMergeConfigItem& rConfigItem, 512cdf0e10cSrcweir const Sequence< ::rtl::OUString>* pAssignments) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir //find the column names in the address string (with name assignment!) and 515cdf0e10cSrcweir //exchange the placeholder (like <Firstname>) with the database content 516cdf0e10cSrcweir //unassigned columns are expanded to <not assigned> 517cdf0e10cSrcweir Reference< XColumnsSupplier > xColsSupp( rConfigItem.GetResultSet(), UNO_QUERY); 518cdf0e10cSrcweir Reference <XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0; 519cdf0e10cSrcweir Sequence< ::rtl::OUString> aAssignment = pAssignments ? 520cdf0e10cSrcweir *pAssignments : 521cdf0e10cSrcweir rConfigItem.GetColumnAssignment( 522cdf0e10cSrcweir rConfigItem.GetCurrentDBData() ); 523cdf0e10cSrcweir const ::rtl::OUString* pAssignment = aAssignment.getConstArray(); 524cdf0e10cSrcweir const ResStringArray& rDefHeaders = rConfigItem.GetDefaultAddressHeaders(); 525cdf0e10cSrcweir String sAddress(rAddress); 526cdf0e10cSrcweir String sNotAssigned(SW_RES(STR_NOTASSIGNED)); 527cdf0e10cSrcweir sNotAssigned.Insert('<', 0); 528cdf0e10cSrcweir sNotAssigned += '>'; 529cdf0e10cSrcweir 530cdf0e10cSrcweir sal_Bool bIncludeCountry = rConfigItem.IsIncludeCountry(); 531cdf0e10cSrcweir const ::rtl::OUString rExcludeCountry = rConfigItem.GetExcludeCountry(); 532cdf0e10cSrcweir bool bSpecialReplacementForCountry = (!bIncludeCountry || rExcludeCountry.getLength()); 533cdf0e10cSrcweir String sCountryColumn; 534cdf0e10cSrcweir if( bSpecialReplacementForCountry ) 535cdf0e10cSrcweir { 536cdf0e10cSrcweir sCountryColumn = rDefHeaders.GetString(MM_PART_COUNTRY); 537cdf0e10cSrcweir Sequence< ::rtl::OUString> aSpecialAssignment = 538cdf0e10cSrcweir rConfigItem.GetColumnAssignment( rConfigItem.GetCurrentDBData() ); 539cdf0e10cSrcweir if(aSpecialAssignment.getLength() > MM_PART_COUNTRY && aSpecialAssignment[MM_PART_COUNTRY].getLength()) 540cdf0e10cSrcweir sCountryColumn = aSpecialAssignment[MM_PART_COUNTRY]; 541cdf0e10cSrcweir } 542cdf0e10cSrcweir 543cdf0e10cSrcweir SwAddressIterator aIter(sAddress); 544cdf0e10cSrcweir sAddress.Erase(); 545cdf0e10cSrcweir while(aIter.HasMore()) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir SwMergeAddressItem aItem = aIter.Next(); 548cdf0e10cSrcweir if(aItem.bIsColumn) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir //get the default column name 551cdf0e10cSrcweir 552cdf0e10cSrcweir //find the appropriate assignment 553cdf0e10cSrcweir String sConvertedColumn = aItem.sText; 554cdf0e10cSrcweir for(sal_uInt16 nColumn = 0; 555cdf0e10cSrcweir nColumn < rDefHeaders.Count() && nColumn < aAssignment.getLength(); 556cdf0e10cSrcweir ++nColumn) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir if(rDefHeaders.GetString(nColumn) == aItem.sText && 559cdf0e10cSrcweir pAssignment[nColumn].getLength()) 560cdf0e10cSrcweir { 561cdf0e10cSrcweir sConvertedColumn = pAssignment[nColumn]; 562cdf0e10cSrcweir break; 563cdf0e10cSrcweir } 564cdf0e10cSrcweir } 565cdf0e10cSrcweir if(sConvertedColumn.Len() && 566cdf0e10cSrcweir xColAccess.is() && 567cdf0e10cSrcweir xColAccess->hasByName(sConvertedColumn)) 568cdf0e10cSrcweir { 569cdf0e10cSrcweir //get the content and exchange it in the address string 570cdf0e10cSrcweir Any aCol = xColAccess->getByName(sConvertedColumn); 571cdf0e10cSrcweir Reference< XColumn > xColumn; 572cdf0e10cSrcweir aCol >>= xColumn; 573cdf0e10cSrcweir if(xColumn.is()) 574cdf0e10cSrcweir { 575cdf0e10cSrcweir try 576cdf0e10cSrcweir { 577cdf0e10cSrcweir ::rtl::OUString sReplace = xColumn->getString(); 578cdf0e10cSrcweir 579cdf0e10cSrcweir if( bSpecialReplacementForCountry && sCountryColumn == sConvertedColumn ) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir if( rExcludeCountry.getLength() && sReplace != rExcludeCountry ) 582cdf0e10cSrcweir aItem.sText = sReplace; 583cdf0e10cSrcweir else 584cdf0e10cSrcweir aItem.sText.Erase(); 585cdf0e10cSrcweir } 586cdf0e10cSrcweir else 587cdf0e10cSrcweir { 588cdf0e10cSrcweir aItem.sText = sReplace; 589cdf0e10cSrcweir } 590cdf0e10cSrcweir } 591cdf0e10cSrcweir catch( sdbc::SQLException& ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir DBG_ERROR("SQLException caught"); 594cdf0e10cSrcweir } 595cdf0e10cSrcweir } 596cdf0e10cSrcweir } 597cdf0e10cSrcweir else 598cdf0e10cSrcweir { 599cdf0e10cSrcweir aItem.sText = sNotAssigned; 600cdf0e10cSrcweir } 601cdf0e10cSrcweir 602cdf0e10cSrcweir } 603cdf0e10cSrcweir sAddress += aItem.sText; 604cdf0e10cSrcweir } 605cdf0e10cSrcweir return sAddress; 606cdf0e10cSrcweir } 607cdf0e10cSrcweir 608cdf0e10cSrcweir /*-- 11.05.2004 15:42:08--------------------------------------------------- 609cdf0e10cSrcweir 610cdf0e10cSrcweir -----------------------------------------------------------------------*/ 611cdf0e10cSrcweir SwMergeAddressItem SwAddressIterator::Next() 612cdf0e10cSrcweir { 613cdf0e10cSrcweir //currently the string may either start with a '<' then it's a column 614cdf0e10cSrcweir //otherwise it's simple text maybe containing a return 615cdf0e10cSrcweir SwMergeAddressItem aRet; 616cdf0e10cSrcweir if(sAddress.Len()) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir if(sAddress.GetChar(0) == '<') 619cdf0e10cSrcweir { 620cdf0e10cSrcweir aRet.bIsColumn = true; 621cdf0e10cSrcweir xub_StrLen nClose = sAddress.Search('>'); 622cdf0e10cSrcweir DBG_ASSERT(nClose != STRING_NOTFOUND, "closing '>' not found"); 623cdf0e10cSrcweir if( nClose != STRING_NOTFOUND ) 624cdf0e10cSrcweir { 625cdf0e10cSrcweir aRet.sText = sAddress.Copy(1, nClose - 1); 626cdf0e10cSrcweir sAddress.Erase(0, nClose + 1); 627cdf0e10cSrcweir } 628cdf0e10cSrcweir else 629cdf0e10cSrcweir { 630cdf0e10cSrcweir aRet.sText = sAddress.Copy(1, 1); 631cdf0e10cSrcweir sAddress.Erase(0, 1); 632cdf0e10cSrcweir } 633cdf0e10cSrcweir } 634cdf0e10cSrcweir else 635cdf0e10cSrcweir { 636cdf0e10cSrcweir xub_StrLen nOpen = sAddress.Search('<'); 637cdf0e10cSrcweir xub_StrLen nReturn = sAddress.Search('\n'); 638cdf0e10cSrcweir if(nReturn == 0) 639cdf0e10cSrcweir { 640cdf0e10cSrcweir aRet.bIsReturn = true; 641cdf0e10cSrcweir aRet.sText = '\n'; 642cdf0e10cSrcweir sAddress.Erase(0, 1); 643cdf0e10cSrcweir } 644cdf0e10cSrcweir else if(STRING_NOTFOUND == nOpen && STRING_NOTFOUND == nReturn) 645cdf0e10cSrcweir { 646cdf0e10cSrcweir nOpen = sAddress.Len(); 647cdf0e10cSrcweir aRet.sText = sAddress; 648cdf0e10cSrcweir sAddress.Erase(); 649cdf0e10cSrcweir } 650cdf0e10cSrcweir else 651cdf0e10cSrcweir { 652cdf0e10cSrcweir xub_StrLen nTarget = ::std::min(nOpen, nReturn); 653cdf0e10cSrcweir aRet.sText = sAddress.Copy(0, nTarget); 654cdf0e10cSrcweir sAddress.Erase(0, nTarget); 655cdf0e10cSrcweir } 656cdf0e10cSrcweir } 657cdf0e10cSrcweir } 658cdf0e10cSrcweir return aRet; 659cdf0e10cSrcweir 660cdf0e10cSrcweir } 661cdf0e10cSrcweir /*-- 21.05.2004 10:36:20--------------------------------------------------- 662cdf0e10cSrcweir 663cdf0e10cSrcweir -----------------------------------------------------------------------*/ 664cdf0e10cSrcweir SwAuthenticator::~SwAuthenticator() 665cdf0e10cSrcweir { 666cdf0e10cSrcweir } 667cdf0e10cSrcweir /*-- 21.05.2004 10:36:20--------------------------------------------------- 668cdf0e10cSrcweir 669cdf0e10cSrcweir -----------------------------------------------------------------------*/ 670cdf0e10cSrcweir OUString SwAuthenticator::getUserName( ) throw (RuntimeException) 671cdf0e10cSrcweir { 672cdf0e10cSrcweir return m_aUserName; 673cdf0e10cSrcweir } 674cdf0e10cSrcweir /*-- 21.05.2004 10:36:20--------------------------------------------------- 675cdf0e10cSrcweir 676cdf0e10cSrcweir -----------------------------------------------------------------------*/ 677cdf0e10cSrcweir OUString SwAuthenticator::getPassword( ) throw (RuntimeException) 678cdf0e10cSrcweir { 679cdf0e10cSrcweir if(m_aUserName.getLength() && !m_aPassword.getLength() && m_pParentWindow) 680cdf0e10cSrcweir { 681cdf0e10cSrcweir SfxPasswordDialog* pPasswdDlg = 682cdf0e10cSrcweir new SfxPasswordDialog( m_pParentWindow ); 683cdf0e10cSrcweir pPasswdDlg->SetMinLen( 0 ); 684cdf0e10cSrcweir if(RET_OK == pPasswdDlg->Execute()) 685cdf0e10cSrcweir m_aPassword = pPasswdDlg->GetPassword(); 686cdf0e10cSrcweir } 687cdf0e10cSrcweir return m_aPassword; 688cdf0e10cSrcweir } 689cdf0e10cSrcweir /*-- 25.08.2004 12:53:03--------------------------------------------------- 690cdf0e10cSrcweir 691cdf0e10cSrcweir -----------------------------------------------------------------------*/ 692cdf0e10cSrcweir SwConnectionContext::SwConnectionContext( 693cdf0e10cSrcweir const ::rtl::OUString& rMailServer, sal_Int16 nPort, 694cdf0e10cSrcweir const ::rtl::OUString& rConnectionType) : 695cdf0e10cSrcweir m_sMailServer(rMailServer), 696cdf0e10cSrcweir m_nPort(nPort), 697cdf0e10cSrcweir m_sConnectionType(rConnectionType) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir } 700cdf0e10cSrcweir /*-- 25.08.2004 12:53:03--------------------------------------------------- 701cdf0e10cSrcweir 702cdf0e10cSrcweir -----------------------------------------------------------------------*/ 703cdf0e10cSrcweir SwConnectionContext::~SwConnectionContext() 704cdf0e10cSrcweir { 705cdf0e10cSrcweir } 706cdf0e10cSrcweir /*-- 25.08.2004 12:53:03--------------------------------------------------- 707cdf0e10cSrcweir 708cdf0e10cSrcweir -----------------------------------------------------------------------*/ 709cdf0e10cSrcweir uno::Any SwConnectionContext::getValueByName( const ::rtl::OUString& rName ) 710cdf0e10cSrcweir throw (uno::RuntimeException) 711cdf0e10cSrcweir { 712cdf0e10cSrcweir uno::Any aRet; 713cdf0e10cSrcweir if( !rName.compareToAscii( "ServerName" )) 714cdf0e10cSrcweir aRet <<= m_sMailServer; 715cdf0e10cSrcweir else if( !rName.compareToAscii( "Port" )) 716cdf0e10cSrcweir aRet <<= (sal_Int32) m_nPort; 717cdf0e10cSrcweir else if( !rName.compareToAscii( "ConnectionType" )) 718cdf0e10cSrcweir aRet <<= m_sConnectionType; 719cdf0e10cSrcweir return aRet; 720cdf0e10cSrcweir } 721cdf0e10cSrcweir /*-- 21.05.2004 10:45:33--------------------------------------------------- 722cdf0e10cSrcweir 723cdf0e10cSrcweir -----------------------------------------------------------------------*/ 724cdf0e10cSrcweir SwConnectionListener::~SwConnectionListener() 725cdf0e10cSrcweir { 726cdf0e10cSrcweir } 727cdf0e10cSrcweir /*-- 21.05.2004 10:45:33--------------------------------------------------- 728cdf0e10cSrcweir 729cdf0e10cSrcweir -----------------------------------------------------------------------*/ 730cdf0e10cSrcweir void SwConnectionListener::connected(const lang::EventObject& /*aEvent*/) 731cdf0e10cSrcweir throw (uno::RuntimeException) 732cdf0e10cSrcweir { 733cdf0e10cSrcweir //OSL_ENSURE(false, "Connection opened"); 734cdf0e10cSrcweir } 735cdf0e10cSrcweir /*-- 21.05.2004 10:45:33--------------------------------------------------- 736cdf0e10cSrcweir 737cdf0e10cSrcweir -----------------------------------------------------------------------*/ 738cdf0e10cSrcweir void SwConnectionListener::disconnected(const lang::EventObject& /*aEvent*/) 739cdf0e10cSrcweir throw (uno::RuntimeException) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir //OSL_ENSURE(false, "Connection closed"); 742cdf0e10cSrcweir } 743cdf0e10cSrcweir /*-- 21.05.2004 10:45:33--------------------------------------------------- 744cdf0e10cSrcweir 745cdf0e10cSrcweir -----------------------------------------------------------------------*/ 746cdf0e10cSrcweir void SwConnectionListener::disposing(const lang::EventObject& /*aEvent*/) 747cdf0e10cSrcweir throw(uno::RuntimeException) 748cdf0e10cSrcweir { 749cdf0e10cSrcweir } 750cdf0e10cSrcweir /*-- 21.05.2004 10:17:22--------------------------------------------------- 751cdf0e10cSrcweir 752cdf0e10cSrcweir -----------------------------------------------------------------------*/ 753cdf0e10cSrcweir uno::Reference< uno::XComponentContext> getCurrentCmpCtx( 754cdf0e10cSrcweir uno::Reference<lang::XMultiServiceFactory> rSrvMgr) 755cdf0e10cSrcweir { 756cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet = 757cdf0e10cSrcweir uno::Reference< beans::XPropertySet>(rSrvMgr, uno::UNO_QUERY); 758cdf0e10cSrcweir Any aAny = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii("DefaultContext")); 759cdf0e10cSrcweir uno::Reference< uno::XComponentContext> rCmpCtx; 760cdf0e10cSrcweir aAny >>= rCmpCtx; 761cdf0e10cSrcweir return rCmpCtx; 762cdf0e10cSrcweir } 763cdf0e10cSrcweir /*-- 13.07.2004 09:07:01--------------------------------------------------- 764cdf0e10cSrcweir 765cdf0e10cSrcweir -----------------------------------------------------------------------*/ 766cdf0e10cSrcweir SwMailTransferable::SwMailTransferable(const rtl::OUString& rBody, const rtl::OUString& rMimeType) : 767cdf0e10cSrcweir cppu::WeakComponentImplHelper2< datatransfer::XTransferable, beans::XPropertySet >(m_aMutex), 768cdf0e10cSrcweir m_aMimeType( rMimeType ), 769cdf0e10cSrcweir m_sBody( rBody ), 770cdf0e10cSrcweir m_bIsBody( true ) 771cdf0e10cSrcweir { 772cdf0e10cSrcweir } 773cdf0e10cSrcweir /*-- 13.07.2004 09:07:01--------------------------------------------------- 774cdf0e10cSrcweir 775cdf0e10cSrcweir -----------------------------------------------------------------------*/ 776cdf0e10cSrcweir SwMailTransferable::SwMailTransferable(const rtl::OUString& rURL, 777cdf0e10cSrcweir const rtl::OUString& rName, const rtl::OUString& rMimeType) : 778cdf0e10cSrcweir cppu::WeakComponentImplHelper2< datatransfer::XTransferable, beans::XPropertySet >(m_aMutex), 779cdf0e10cSrcweir m_aMimeType( rMimeType ), 780cdf0e10cSrcweir m_aURL(rURL), 781cdf0e10cSrcweir m_aName( rName ), 782cdf0e10cSrcweir m_bIsBody( false ) 783cdf0e10cSrcweir { 784cdf0e10cSrcweir } 785cdf0e10cSrcweir /*-- 13.07.2004 09:07:08--------------------------------------------------- 786cdf0e10cSrcweir 787cdf0e10cSrcweir -----------------------------------------------------------------------*/ 788cdf0e10cSrcweir SwMailTransferable::~SwMailTransferable() 789cdf0e10cSrcweir { 790cdf0e10cSrcweir } 791cdf0e10cSrcweir /*-- 13.07.2004 09:07:08--------------------------------------------------- 792cdf0e10cSrcweir 793cdf0e10cSrcweir -----------------------------------------------------------------------*/ 794cdf0e10cSrcweir uno::Any SwMailTransferable::getTransferData( const datatransfer::DataFlavor& /*aFlavor*/ ) 795cdf0e10cSrcweir throw (datatransfer::UnsupportedFlavorException, 796cdf0e10cSrcweir io::IOException, uno::RuntimeException) 797cdf0e10cSrcweir { 798cdf0e10cSrcweir uno::Any aRet; 799cdf0e10cSrcweir if( m_bIsBody ) 800cdf0e10cSrcweir aRet <<= ::rtl::OUString(m_sBody); 801cdf0e10cSrcweir else 802cdf0e10cSrcweir { 803cdf0e10cSrcweir Sequence<sal_Int8> aData; 804cdf0e10cSrcweir SfxMedium aMedium( m_aURL, STREAM_STD_READ, sal_False ); 805cdf0e10cSrcweir SvStream* pStream = aMedium.GetInStream(); 806cdf0e10cSrcweir if ( aMedium.GetErrorCode() == ERRCODE_NONE && pStream) 807cdf0e10cSrcweir { 808cdf0e10cSrcweir pStream->Seek(STREAM_SEEK_TO_END); 809cdf0e10cSrcweir aData.realloc(pStream->Tell()); 810cdf0e10cSrcweir pStream->Seek(0); 811cdf0e10cSrcweir sal_Int8 * pData = aData.getArray(); 812cdf0e10cSrcweir pStream->Read( pData, aData.getLength() ); 813cdf0e10cSrcweir } 814cdf0e10cSrcweir aRet <<= aData; 815cdf0e10cSrcweir } 816cdf0e10cSrcweir return aRet; 817cdf0e10cSrcweir } 818cdf0e10cSrcweir /*-- 13.07.2004 09:07:08--------------------------------------------------- 819cdf0e10cSrcweir 820cdf0e10cSrcweir -----------------------------------------------------------------------*/ 821cdf0e10cSrcweir uno::Sequence< datatransfer::DataFlavor > SwMailTransferable::getTransferDataFlavors( ) 822cdf0e10cSrcweir throw (uno::RuntimeException) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir uno::Sequence< datatransfer::DataFlavor > aRet(1); 825cdf0e10cSrcweir aRet[0].MimeType = m_aMimeType; 826cdf0e10cSrcweir if( m_bIsBody ) 827cdf0e10cSrcweir { 828cdf0e10cSrcweir aRet[0].DataType = getCppuType((::rtl::OUString*)0); 829cdf0e10cSrcweir } 830cdf0e10cSrcweir else 831cdf0e10cSrcweir { 832cdf0e10cSrcweir aRet[0].HumanPresentableName = m_aName; 833cdf0e10cSrcweir aRet[0].DataType = getCppuType((uno::Sequence<sal_Int8>*)0); 834cdf0e10cSrcweir } 835cdf0e10cSrcweir return aRet; 836cdf0e10cSrcweir } 837cdf0e10cSrcweir /*-- 13.07.2004 09:07:08--------------------------------------------------- 838cdf0e10cSrcweir 839cdf0e10cSrcweir -----------------------------------------------------------------------*/ 840cdf0e10cSrcweir sal_Bool SwMailTransferable::isDataFlavorSupported( 841cdf0e10cSrcweir const datatransfer::DataFlavor& aFlavor ) 842cdf0e10cSrcweir throw (uno::RuntimeException) 843cdf0e10cSrcweir { 844cdf0e10cSrcweir return (aFlavor.MimeType == ::rtl::OUString(m_aMimeType)); 845cdf0e10cSrcweir } 846cdf0e10cSrcweir /*-- 28.04.2004 09:52:05--------------------------------------------------- 847cdf0e10cSrcweir 848cdf0e10cSrcweir -----------------------------------------------------------------------*/ 849cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SwMailTransferable::getPropertySetInfo( ) throw(uno::RuntimeException) 850cdf0e10cSrcweir { 851cdf0e10cSrcweir return uno::Reference< beans::XPropertySetInfo >(); 852cdf0e10cSrcweir } 853cdf0e10cSrcweir /*-- 28.04.2004 09:52:05--------------------------------------------------- 854cdf0e10cSrcweir 855cdf0e10cSrcweir -----------------------------------------------------------------------*/ 856cdf0e10cSrcweir void SwMailTransferable::setPropertyValue( const ::rtl::OUString& , const uno::Any& ) 857cdf0e10cSrcweir throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, 858cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 859cdf0e10cSrcweir { 860cdf0e10cSrcweir } 861cdf0e10cSrcweir /*-- 28.04.2004 09:52:05--------------------------------------------------- 862cdf0e10cSrcweir 863cdf0e10cSrcweir -----------------------------------------------------------------------*/ 864cdf0e10cSrcweir uno::Any SwMailTransferable::getPropertyValue( const ::rtl::OUString& rPropertyName ) 865cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 866cdf0e10cSrcweir { 867cdf0e10cSrcweir uno::Any aRet; 868cdf0e10cSrcweir if( rPropertyName.equalsAscii( "URL" ) ) 869cdf0e10cSrcweir aRet <<= m_aURL; 870cdf0e10cSrcweir return aRet; 871cdf0e10cSrcweir } 872cdf0e10cSrcweir /*-- 28.04.2004 09:52:05--------------------------------------------------- 873cdf0e10cSrcweir 874cdf0e10cSrcweir -----------------------------------------------------------------------*/ 875cdf0e10cSrcweir void SwMailTransferable::addPropertyChangeListener( 876cdf0e10cSrcweir const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) 877cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 878cdf0e10cSrcweir { 879cdf0e10cSrcweir } 880cdf0e10cSrcweir /*-- 28.04.2004 09:52:05--------------------------------------------------- 881cdf0e10cSrcweir 882cdf0e10cSrcweir -----------------------------------------------------------------------*/ 883cdf0e10cSrcweir void SwMailTransferable::removePropertyChangeListener( 884cdf0e10cSrcweir const ::rtl::OUString&, 885cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& ) 886cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 887cdf0e10cSrcweir { 888cdf0e10cSrcweir } 889cdf0e10cSrcweir /*-- 28.04.2004 09:52:05--------------------------------------------------- 890cdf0e10cSrcweir 891cdf0e10cSrcweir -----------------------------------------------------------------------*/ 892cdf0e10cSrcweir void SwMailTransferable::addVetoableChangeListener( 893cdf0e10cSrcweir const ::rtl::OUString&, 894cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& ) 895cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 896cdf0e10cSrcweir { 897cdf0e10cSrcweir } 898cdf0e10cSrcweir /*-- 28.04.2004 09:52:05--------------------------------------------------- 899cdf0e10cSrcweir 900cdf0e10cSrcweir -----------------------------------------------------------------------*/ 901cdf0e10cSrcweir void SwMailTransferable::removeVetoableChangeListener( 902cdf0e10cSrcweir const ::rtl::OUString& , 903cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& ) 904cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 905cdf0e10cSrcweir { 906cdf0e10cSrcweir } 907cdf0e10cSrcweir 908cdf0e10cSrcweir /*-- 22.06.2004 16:46:05--------------------------------------------------- 909cdf0e10cSrcweir 910cdf0e10cSrcweir -----------------------------------------------------------------------*/ 911cdf0e10cSrcweir SwMailMessage::SwMailMessage() : 912cdf0e10cSrcweir cppu::WeakComponentImplHelper1< mail::XMailMessage>(m_aMutex) 913cdf0e10cSrcweir { 914cdf0e10cSrcweir } 915cdf0e10cSrcweir /*-- 22.06.2004 16:46:06--------------------------------------------------- 916cdf0e10cSrcweir 917cdf0e10cSrcweir -----------------------------------------------------------------------*/ 918cdf0e10cSrcweir SwMailMessage::~SwMailMessage() 919cdf0e10cSrcweir { 920cdf0e10cSrcweir } 921cdf0e10cSrcweir /*-- 02.07.2007 16:00:07--------------------------------------------------- 922cdf0e10cSrcweir 923cdf0e10cSrcweir -----------------------------------------------------------------------*/ 924cdf0e10cSrcweir ::rtl::OUString SwMailMessage::getSenderName() throw (uno::RuntimeException) 925cdf0e10cSrcweir { 926cdf0e10cSrcweir return m_sSenderName; 927cdf0e10cSrcweir } 928cdf0e10cSrcweir /*-- 22.06.2004 16:46:06--------------------------------------------------- 929cdf0e10cSrcweir 930cdf0e10cSrcweir -----------------------------------------------------------------------*/ 931cdf0e10cSrcweir ::rtl::OUString SwMailMessage::getSenderAddress() throw (uno::RuntimeException) 932cdf0e10cSrcweir { 933cdf0e10cSrcweir return m_sSenderAddress; 934cdf0e10cSrcweir } 935cdf0e10cSrcweir /*-- 22.06.2004 16:46:06--------------------------------------------------- 936cdf0e10cSrcweir 937cdf0e10cSrcweir -----------------------------------------------------------------------*/ 938cdf0e10cSrcweir ::rtl::OUString SwMailMessage::getReplyToAddress() throw (uno::RuntimeException) 939cdf0e10cSrcweir { 940cdf0e10cSrcweir return m_sReplyToAddress; 941cdf0e10cSrcweir } 942cdf0e10cSrcweir /*-- 22.06.2004 16:46:07--------------------------------------------------- 943cdf0e10cSrcweir 944cdf0e10cSrcweir -----------------------------------------------------------------------*/ 945cdf0e10cSrcweir void SwMailMessage::setReplyToAddress( const ::rtl::OUString& _replytoaddress ) throw (uno::RuntimeException) 946cdf0e10cSrcweir { 947cdf0e10cSrcweir m_sReplyToAddress = _replytoaddress; 948cdf0e10cSrcweir } 949cdf0e10cSrcweir /*-- 22.06.2004 16:46:07--------------------------------------------------- 950cdf0e10cSrcweir 951cdf0e10cSrcweir -----------------------------------------------------------------------*/ 952cdf0e10cSrcweir ::rtl::OUString SwMailMessage::getSubject() throw (uno::RuntimeException) 953cdf0e10cSrcweir { 954cdf0e10cSrcweir return m_sSubject; 955cdf0e10cSrcweir } 956cdf0e10cSrcweir /*-- 22.06.2004 16:46:07--------------------------------------------------- 957cdf0e10cSrcweir 958cdf0e10cSrcweir -----------------------------------------------------------------------*/ 959cdf0e10cSrcweir void SwMailMessage::setSubject( const ::rtl::OUString& _subject ) throw (uno::RuntimeException) 960cdf0e10cSrcweir { 961cdf0e10cSrcweir m_sSubject = _subject; 962cdf0e10cSrcweir } 963cdf0e10cSrcweir /*-- 13.07.2004 09:57:18--------------------------------------------------- 964cdf0e10cSrcweir 965cdf0e10cSrcweir -----------------------------------------------------------------------*/ 966cdf0e10cSrcweir uno::Reference< datatransfer::XTransferable > SwMailMessage::getBody() throw (uno::RuntimeException) 967cdf0e10cSrcweir { 968cdf0e10cSrcweir return m_xBody; 969cdf0e10cSrcweir } 970cdf0e10cSrcweir /*-- 13.07.2004 09:57:18--------------------------------------------------- 971cdf0e10cSrcweir 972cdf0e10cSrcweir -----------------------------------------------------------------------*/ 973cdf0e10cSrcweir void SwMailMessage::setBody( 974cdf0e10cSrcweir const uno::Reference< datatransfer::XTransferable >& rBody ) 975cdf0e10cSrcweir throw (uno::RuntimeException) 976cdf0e10cSrcweir { 977cdf0e10cSrcweir m_xBody = rBody; 978cdf0e10cSrcweir } 979cdf0e10cSrcweir /*-- 22.06.2004 16:46:08--------------------------------------------------- 980cdf0e10cSrcweir 981cdf0e10cSrcweir -----------------------------------------------------------------------*/ 982cdf0e10cSrcweir void SwMailMessage::addRecipient( const ::rtl::OUString& rRecipientAddress ) 983cdf0e10cSrcweir throw (uno::RuntimeException) 984cdf0e10cSrcweir { 985cdf0e10cSrcweir m_aRecipients.realloc(m_aRecipients.getLength() + 1); 986cdf0e10cSrcweir m_aRecipients[m_aRecipients.getLength() - 1] = rRecipientAddress; 987cdf0e10cSrcweir } 988cdf0e10cSrcweir /*-- 22.06.2004 16:46:09--------------------------------------------------- 989cdf0e10cSrcweir 990cdf0e10cSrcweir -----------------------------------------------------------------------*/ 991cdf0e10cSrcweir void SwMailMessage::addCcRecipient( const ::rtl::OUString& rRecipientAddress ) 992cdf0e10cSrcweir throw (uno::RuntimeException) 993cdf0e10cSrcweir { 994cdf0e10cSrcweir m_aCcRecipients.realloc(m_aCcRecipients.getLength() + 1); 995cdf0e10cSrcweir m_aCcRecipients[m_aCcRecipients.getLength() - 1] = rRecipientAddress; 996cdf0e10cSrcweir 997cdf0e10cSrcweir } 998cdf0e10cSrcweir /*-- 22.06.2004 16:46:09--------------------------------------------------- 999cdf0e10cSrcweir 1000cdf0e10cSrcweir -----------------------------------------------------------------------*/ 1001cdf0e10cSrcweir void SwMailMessage::addBccRecipient( const ::rtl::OUString& rRecipientAddress ) throw (uno::RuntimeException) 1002cdf0e10cSrcweir { 1003cdf0e10cSrcweir m_aBccRecipients.realloc(m_aBccRecipients.getLength() + 1); 1004cdf0e10cSrcweir m_aBccRecipients[m_aBccRecipients.getLength() - 1] = rRecipientAddress; 1005cdf0e10cSrcweir } 1006cdf0e10cSrcweir /*-- 22.06.2004 16:46:09--------------------------------------------------- 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir -----------------------------------------------------------------------*/ 1009cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SwMailMessage::getRecipients( ) throw (uno::RuntimeException) 1010cdf0e10cSrcweir { 1011cdf0e10cSrcweir return m_aRecipients; 1012cdf0e10cSrcweir } 1013cdf0e10cSrcweir /*-- 22.06.2004 16:46:10--------------------------------------------------- 1014cdf0e10cSrcweir 1015cdf0e10cSrcweir -----------------------------------------------------------------------*/ 1016cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SwMailMessage::getCcRecipients( ) throw (uno::RuntimeException) 1017cdf0e10cSrcweir { 1018cdf0e10cSrcweir return m_aCcRecipients; 1019cdf0e10cSrcweir } 1020cdf0e10cSrcweir /*-- 22.06.2004 16:46:10--------------------------------------------------- 1021cdf0e10cSrcweir 1022cdf0e10cSrcweir -----------------------------------------------------------------------*/ 1023cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SwMailMessage::getBccRecipients( ) throw (uno::RuntimeException) 1024cdf0e10cSrcweir { 1025cdf0e10cSrcweir return m_aBccRecipients; 1026cdf0e10cSrcweir } 1027cdf0e10cSrcweir /*-- 13.07.2004 09:59:48--------------------------------------------------- 1028cdf0e10cSrcweir 1029cdf0e10cSrcweir -----------------------------------------------------------------------*/ 1030cdf0e10cSrcweir void SwMailMessage::addAttachment( const mail::MailAttachment& rMailAttachment ) 1031cdf0e10cSrcweir throw (uno::RuntimeException) 1032cdf0e10cSrcweir { 1033cdf0e10cSrcweir m_aAttachments.realloc(m_aAttachments.getLength() + 1); 1034cdf0e10cSrcweir m_aAttachments[m_aAttachments.getLength() - 1] = rMailAttachment; 1035cdf0e10cSrcweir } 1036cdf0e10cSrcweir /*-- 13.07.2004 09:59:48--------------------------------------------------- 1037cdf0e10cSrcweir 1038cdf0e10cSrcweir -----------------------------------------------------------------------*/ 1039cdf0e10cSrcweir uno::Sequence< mail::MailAttachment > SwMailMessage::getAttachments( ) 1040cdf0e10cSrcweir throw (uno::RuntimeException) 1041cdf0e10cSrcweir { 1042cdf0e10cSrcweir return m_aAttachments; 1043cdf0e10cSrcweir } 1044