Files
libreoffice/sw/source/ui/dbui/dbmgr.cxx

2968 lines
118 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 16:15:01 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:15:01 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:15:01 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 16:15:01 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 16:15:01 +00:00
*
************************************************************************/
2000-09-18 16:15:01 +00:00
#include <cstdarg>
#include <stdio.h>
#include <unotxdoc.hxx>
#include <com/sun/star/text/NotePrintMode.hpp>
#include <sfx2/app.hxx>
2000-11-13 07:32:00 +00:00
#include <com/sun/star/sdb/CommandType.hpp>
#include <com/sun/star/sdb/XDocumentDataSource.hpp>
2000-10-27 10:26:20 +00:00
#include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/util/NumberFormatter.hpp>
#include <com/sun/star/sdb/DatabaseContext.hpp>
2000-12-01 10:45:55 +00:00
#include <com/sun/star/sdb/XCompletedConnection.hpp>
#include <com/sun/star/sdb/XCompletedExecution.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/text/MailMergeEvent.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/task/InteractionHandler.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
#include <com/sun/star/uno/XNamingService.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <sfx2/fcontnr.hxx>
#include <sfx2/filedlghelper.hxx>
2000-10-27 10:26:20 +00:00
#include <sfx2/viewfrm.hxx>
#include <dbconfig.hxx>
#include <swdbtoolsclient.hxx>
#include <pagedesc.hxx>
2000-09-18 16:15:01 +00:00
#include <vcl/lstbox.hxx>
2000-11-06 08:30:33 +00:00
#include <unotools/tempfile.hxx>
#include <unotools/pathoptions.hxx>
#include <svl/urihelper.hxx>
#include <svl/zforlist.hxx>
#include <svl/zformat.hxx>
#include <svl/stritem.hxx>
#include <svl/eitem.hxx>
2009-08-14 13:56:56 +00:00
#include <vcl/oldprintadaptor.hxx>
2000-09-18 16:15:01 +00:00
#include <sfx2/docfile.hxx>
#include <sfx2/progress.hxx>
#include <sfx2/dispatch.hxx>
2009-12-15 21:55:40 +01:00
#include <svl/mailenum.hxx>
2002-11-29 11:14:12 +00:00
#include <cmdid.h>
2000-09-18 16:15:01 +00:00
#include <swmodule.hxx>
#include <view.hxx>
#include <docsh.hxx>
#include <edtwin.hxx>
#include <wrtsh.hxx>
#include <fldbas.hxx>
#include <initui.hxx>
#include <swundo.hxx>
#include <flddat.hxx>
#include <modcfg.hxx>
#include <shellio.hxx>
#include <dbui.hxx>
#include <dbmgr.hxx>
#include <doc.hxx>
#include <swwait.hxx>
#include <swunohelper.hxx>
2000-09-18 16:15:01 +00:00
#include <dbui.hrc>
#include <globals.hrc>
#include <statstr.hrc>
#include <mmconfigitem.hxx>
2000-09-18 16:15:01 +00:00
#include <sfx2/request.hxx>
#include <hintids.hxx>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/sdbc/XRowSet.hpp>
2000-09-18 16:15:01 +00:00
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
#include <com/sun/star/sdb/XColumn.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/ResultSetType.hpp>
#include <com/sun/star/mail/MailAttachment.hpp>
#include <comphelper/componentcontext.hxx>
2000-10-20 13:18:07 +00:00
#include <comphelper/processfactory.hxx>
#include <comphelper/property.hxx>
#include <comphelper/string.hxx>
#include <comphelper/types.hxx>
#include <mailmergehelper.hxx>
#include <maildispatcher.hxx>
2010-01-13 22:25:07 +01:00
#include <svtools/htmlcfg.hxx>
#include <i18npool/mslangid.hxx>
2000-09-18 16:15:01 +00:00
#include <com/sun/star/util/XNumberFormatTypes.hpp>
#include <editeng/langitem.hxx>
#include <svl/numuno.hxx>
2000-11-13 07:32:00 +00:00
#include <unomailmerge.hxx>
2000-11-13 07:32:00 +00:00
#include <sfx2/event.hxx>
#include <vcl/msgbox.hxx>
#include <svx/dataaccessdescriptor.hxx>
#include <osl/mutex.hxx>
#include <rtl/textenc.h>
#include <ndindex.hxx>
#include <pam.hxx>
#include <swcrsr.hxx>
#include <swevent.hxx>
#include <osl/file.hxx>
#include <swabstdlg.hxx>
#include <fmthdft.hxx>
#include <envelp.hrc>
#include <memory>
#include <vector>
#include <unomid.h>
#include <section.hxx>
2000-09-18 16:15:01 +00:00
using namespace ::osl;
using namespace ::svx;
2000-10-27 10:26:20 +00:00
using namespace ::com::sun::star;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::ui::dialogs;
2000-09-18 16:15:01 +00:00
#define DB_SEP_SPACE 0
#define DB_SEP_TAB 1
#define DB_SEP_RETURN 2
#define DB_SEP_NEWLINE 3
const sal_Char cCursor[] = "Cursor";
const sal_Char cCommand[] = "Command";
const sal_Char cCommandType[] = "CommandType";
const sal_Char cDataSourceName[] = "DataSourceName";
const sal_Char cSelection[] = "Selection";
const sal_Char cActiveConnection[] = "ActiveConnection";
2000-09-18 16:15:01 +00:00
// -----------------------------------------------------------------------------
// Use nameless namespace to avoid to rubbish the global namespace
// -----------------------------------------------------------------------------
namespace
{
bool lcl_getCountFromResultSet( sal_Int32& rCount, const uno::Reference<XResultSet>& xResultSet )
{
uno::Reference<XPropertySet> xPrSet(xResultSet, UNO_QUERY);
if(xPrSet.is())
{
try
{
sal_Bool bFinal = sal_False;
Any aFinal = xPrSet->getPropertyValue(C2U("IsRowCountFinal"));
aFinal >>= bFinal;
if(!bFinal)
{
xResultSet->last();
xResultSet->first();
}
Any aCount = xPrSet->getPropertyValue(C2U("RowCount"));
if( aCount >>= rCount )
return true;
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
}
}
return false;
}
2011-02-25 22:33:34 +01:00
// copy compatibility options
void lcl_CopyCompatibilityOptions( SwWrtShell& rSourceShell, SwWrtShell& rTargetShell)
{
IDocumentSettingAccess* pIDsa = rSourceShell.getIDocumentSettingAccess();
rTargetShell.SetParaSpaceMax( pIDsa->get(IDocumentSettingAccess::PARA_SPACE_MAX));
rTargetShell.SetParaSpaceMaxAtPages(pIDsa->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES));
rTargetShell.SetTabCompat( pIDsa->get(IDocumentSettingAccess::TAB_COMPAT));
rTargetShell.SetAddExtLeading( pIDsa->get(IDocumentSettingAccess::ADD_EXT_LEADING));
rTargetShell.SetUseVirDev( pIDsa->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE));
rTargetShell.SetAddParaSpacingToTableCells( pIDsa->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS));
rTargetShell.SetUseFormerLineSpacing( pIDsa->get(IDocumentSettingAccess::OLD_LINE_SPACING));
rTargetShell.SetUseFormerObjectPositioning( pIDsa->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS));
rTargetShell.SetConsiderWrapOnObjPos( pIDsa->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION));
rTargetShell.SetUseFormerTextWrapping( pIDsa->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING));
}
}
class SwConnectionDisposedListener_Impl : public cppu::WeakImplHelper1
< lang::XEventListener >
{
SwNewDBMgr& rDBMgr;
virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
public:
SwConnectionDisposedListener_Impl(SwNewDBMgr& rMgr);
~SwConnectionDisposedListener_Impl();
};
2010-10-11 17:38:56 -05:00
struct SwNewDBMgr_Impl
{
SwDSParam* pMergeData;
AbstractMailMergeDlg* pMergeDialog;
uno::Reference<lang::XEventListener> xDisposeListener;
SwNewDBMgr_Impl(SwNewDBMgr& rDBMgr)
:pMergeData(0)
,pMergeDialog(0)
,xDisposeListener(new SwConnectionDisposedListener_Impl(rDBMgr))
{}
};
void lcl_InitNumberFormatter(SwDSParam& rParam, uno::Reference<XDataSource> xSource)
{
uno::Reference<XComponentContext> xContext = ::comphelper::getProcessComponentContext();
rParam.xFormatter = uno::Reference<util::XNumberFormatter>(util::NumberFormatter::create(xContext), UNO_QUERY);
if(!xSource.is())
xSource = SwNewDBMgr::getDataSourceAsParent(rParam.xConnection, rParam.sDataSource);
uno::Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
if(xSourceProps.is())
{
Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
if(aFormats.hasValue())
{
uno::Reference<XNumberFormatsSupplier> xSuppl;
aFormats >>= xSuppl;
if(xSuppl.is())
{
uno::Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
Any aNull = xSettings->getPropertyValue(C2U("NullDate"));
aNull >>= rParam.aNullDate;
if(rParam.xFormatter.is())
rParam.xFormatter->attachNumberFormatsSupplier(xSuppl);
}
}
}
}
2000-09-18 16:15:01 +00:00
sal_Bool lcl_MoveAbsolute(SwDSParam* pParam, long nAbsPos)
2000-09-18 16:15:01 +00:00
{
sal_Bool bRet = sal_False;
2000-09-18 16:15:01 +00:00
try
{
if(pParam->bScrollable)
{
bRet = pParam->xResultSet->absolute( nAbsPos );
}
else
{
OSL_FAIL("no absolute positioning available");
2000-09-18 16:15:01 +00:00
}
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
2000-09-18 16:15:01 +00:00
{
}
return bRet;
}
sal_Bool lcl_GetColumnCnt(SwDSParam* pParam,
const String& rColumnName, long nLanguage, rtl::OUString& rResult, double* pNumber)
2000-09-18 16:15:01 +00:00
{
uno::Reference< XColumnsSupplier > xColsSupp( pParam->xResultSet, UNO_QUERY );
uno::Reference<XNameAccess> xCols;
try
{
xCols = xColsSupp->getColumns();
}
2011-06-15 23:56:45 +01:00
catch(const lang::DisposedException&)
{
}
if(!xCols.is() || !xCols->hasByName(rColumnName))
return sal_False;
2000-09-18 16:15:01 +00:00
Any aCol = xCols->getByName(rColumnName);
uno::Reference< XPropertySet > xColumnProps;
aCol >>= xColumnProps;
2000-09-18 16:15:01 +00:00
SwDBFormatData aFormatData;
if(!pParam->xFormatter.is())
{
uno::Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(
pParam->xConnection,pParam->sDataSource);
lcl_InitNumberFormatter(*pParam, xSource );
}
2000-09-18 16:15:01 +00:00
aFormatData.aNullDate = pParam->aNullDate;
aFormatData.xFormatter = pParam->xFormatter;
MsLangId::convertLanguageToLocale( (LanguageType)nLanguage, aFormatData.aLocale );
2000-09-18 16:15:01 +00:00
rResult = SwNewDBMgr::GetDBField( xColumnProps, aFormatData, pNumber);
return sal_True;
2000-09-18 16:15:01 +00:00
};
2010-10-11 17:38:56 -05:00
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Description: import data
2000-09-18 16:15:01 +00:00
--------------------------------------------------------------------*/
sal_Bool SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc )
2000-11-13 07:32:00 +00:00
{
SetMergeType( rMergeDesc.nMergeType );
2000-11-13 07:32:00 +00:00
2010-10-20 15:36:15 +01:00
OSL_ENSURE(!bInMerge && !pImpl->pMergeData, "merge already activated!");
2000-11-13 07:32:00 +00:00
SwDBData aData;
aData.nCommandType = CommandType::TABLE;
uno::Reference<XResultSet> xResSet;
2001-06-26 13:35:16 +00:00
Sequence<Any> aSelection;
uno::Reference< XConnection> xConnection;
aData.sDataSource = rMergeDesc.rDescriptor.getDataSource();
rMergeDesc.rDescriptor[daCommand] >>= aData.sCommand;
rMergeDesc.rDescriptor[daCommandType] >>= aData.nCommandType;
if ( rMergeDesc.rDescriptor.has(daCursor) )
rMergeDesc.rDescriptor[daCursor] >>= xResSet;
if ( rMergeDesc.rDescriptor.has(daSelection) )
rMergeDesc.rDescriptor[daSelection] >>= aSelection;
if ( rMergeDesc.rDescriptor.has(daConnection) )
rMergeDesc.rDescriptor[daConnection] >>= xConnection;
if(aData.sDataSource.isEmpty() || aData.sCommand.isEmpty() || !xResSet.is())
2000-11-13 07:32:00 +00:00
{
return sal_False;
2000-11-13 07:32:00 +00:00
}
pImpl->pMergeData = new SwDSParam(aData, xResSet, aSelection);
SwDSParam* pTemp = FindDSData(aData, sal_False);
if(pTemp)
*pTemp = *pImpl->pMergeData;
else
{
2011-02-25 22:33:34 +01:00
// calls from the calculator may have added a connection with an invalid commandtype
//"real" data base connections added here have to re-use the already available
//DSData and set the correct CommandType
SwDBData aTempData(aData);
aData.nCommandType = -1;
pTemp = FindDSData(aData, sal_False);
if(pTemp)
*pTemp = *pImpl->pMergeData;
else
{
SwDSParam* pInsert = new SwDSParam(*pImpl->pMergeData);
aDataSourceParams.push_back(pInsert);
try
{
uno::Reference<XComponent> xComponent(pInsert->xConnection, UNO_QUERY);
if(xComponent.is())
xComponent->addEventListener(pImpl->xDisposeListener);
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
}
}
}
if(!pImpl->pMergeData->xConnection.is())
pImpl->pMergeData->xConnection = xConnection;
// add an XEventListener
try{
//set to start position
if(pImpl->pMergeData->aSelection.getLength())
{
sal_Int32 nPos = 0;
pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] >>= nPos;
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute( nPos );
pImpl->pMergeData->CheckEndOfDB();
if(pImpl->pMergeData->nSelectionIndex >= pImpl->pMergeData->aSelection.getLength())
pImpl->pMergeData->bEndOfDB = sal_True;
}
else
{
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first();
pImpl->pMergeData->CheckEndOfDB();
}
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
pImpl->pMergeData->bEndOfDB = sal_True;
pImpl->pMergeData->CheckEndOfDB();
OSL_FAIL("exception in MergeNew()");
}
uno::Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,aData.sDataSource);
lcl_InitNumberFormatter(*pImpl->pMergeData, xSource);
2000-11-13 07:32:00 +00:00
rMergeDesc.rSh.ChgDBData(aData);
bInMerge = sal_True;
2000-11-13 07:32:00 +00:00
if (IsInitDBFields())
{
// with database fields without DB-Name, use DB-Name from Doc
2012-01-13 00:20:39 -05:00
std::vector<String> aDBNames;
aDBNames.push_back(String());
SwDBData aInsertData = rMergeDesc.rSh.GetDBData();
String sDBName = aInsertData.sDataSource;
sDBName += DB_DELIM;
sDBName += (String)aInsertData.sCommand;
sDBName += DB_DELIM;
sDBName += String::CreateFromInt32(aInsertData.nCommandType);
rMergeDesc.rSh.ChangeDBFields( aDBNames, sDBName);
SetInitDBFields(sal_False);
2000-11-13 07:32:00 +00:00
}
sal_Bool bRet = sal_True;
switch(rMergeDesc.nMergeType)
2000-11-13 07:32:00 +00:00
{
case DBMGR_MERGE:
bRet = Merge(&rMergeDesc.rSh);
2000-11-13 07:32:00 +00:00
break;
2009-09-01 08:22:04 +00:00
case DBMGR_MERGE_MAILMERGE: // printing merge from 'old' merge dialog or from UNO-component
2000-11-13 07:32:00 +00:00
case DBMGR_MERGE_MAILING:
case DBMGR_MERGE_MAILFILES:
case DBMGR_MERGE_SINGLE_FILE:
// save files and send them as e-Mail if required
bRet = MergeMailFiles(&rMergeDesc.rSh,
rMergeDesc);
2000-11-13 07:32:00 +00:00
break;
2010-10-20 15:36:15 +01:00
default:
// insert selected entries
// (was: InsertRecord)
ImportFromConnection(&rMergeDesc.rSh);
2000-11-13 07:32:00 +00:00
break;
}
EndMerge();
return bRet;
}
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Description: import data
2000-09-18 16:15:01 +00:00
--------------------------------------------------------------------*/
sal_Bool SwNewDBMgr::Merge(SwWrtShell* pSh)
2000-09-18 16:15:01 +00:00
{
pSh->StartAllAction();
pSh->ViewShell::UpdateFlds(sal_True);
2000-09-18 16:15:01 +00:00
pSh->SetModified();
pSh->EndAllAction();
return sal_True;
2000-09-18 16:15:01 +00:00
}
void SwNewDBMgr::ImportFromConnection( SwWrtShell* pSh )
{
if(pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB)
2000-09-18 16:15:01 +00:00
{
{
pSh->StartAllAction();
pSh->StartUndo(UNDO_EMPTY);
sal_Bool bGroupUndo(pSh->DoesGroupUndo());
pSh->DoGroupUndo(sal_False);
2000-09-18 16:15:01 +00:00
if( pSh->HasSelection() )
pSh->DelRight();
SwWait *pWait = 0;
{
sal_uLong i = 0;
2000-09-18 16:15:01 +00:00
do {
ImportDBEntry(pSh);
if( 10 == ++i )
pWait = new SwWait( *pSh->GetView().GetDocShell(), sal_True);
2000-09-18 16:15:01 +00:00
} while(ToNextMergeRecord());
}
pSh->DoGroupUndo(bGroupUndo);
pSh->EndUndo(UNDO_EMPTY);
2000-09-18 16:15:01 +00:00
pSh->EndAllAction();
delete pWait;
}
}
}
String lcl_FindColumn(const String& sFormatStr,sal_uInt16 &nUsedPos, sal_uInt8 &nSeparator)
2000-09-18 16:15:01 +00:00
{
String sReturn;
sal_uInt16 nLen = sFormatStr.Len();
2000-09-18 16:15:01 +00:00
nSeparator = 0xff;
while(nUsedPos < nLen && nSeparator == 0xff)
{
sal_Unicode cAkt = sFormatStr.GetChar(nUsedPos);
switch(cAkt)
{
case ',':
nSeparator = DB_SEP_SPACE;
break;
case ';':
nSeparator = DB_SEP_RETURN;
break;
case ':':
nSeparator = DB_SEP_TAB;
break;
case '#':
nSeparator = DB_SEP_NEWLINE;
break;
default:
sReturn += cAkt;
}
nUsedPos++;
}
return sReturn;
}
void SwNewDBMgr::ImportDBEntry(SwWrtShell* pSh)
{
if(pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB)
2000-09-18 16:15:01 +00:00
{
uno::Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
String sFormatStr;
sal_uInt16 nFmtLen = sFormatStr.Len();
2000-09-18 16:15:01 +00:00
if( nFmtLen )
{
const char cSpace = ' ';
const char cTab = '\t';
sal_uInt16 nUsedPos = 0;
sal_uInt8 nSeparator;
2000-09-18 16:15:01 +00:00
String sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator);
while( sColumn.Len() )
{
if(!xCols->hasByName(sColumn))
return;
Any aCol = xCols->getByName(sColumn);
uno::Reference< XPropertySet > xColumnProp;
aCol >>= xColumnProp;
2000-09-18 16:15:01 +00:00
if(xColumnProp.is())
{
SwDBFormatData aDBFormat;
String sInsert = GetDBField( xColumnProp, aDBFormat);
if( DB_SEP_SPACE == nSeparator )
sInsert += cSpace;
else if( DB_SEP_TAB == nSeparator)
sInsert += cTab;
pSh->Insert(sInsert);
if( DB_SEP_RETURN == nSeparator)
pSh->SplitNode();
else if(DB_SEP_NEWLINE == nSeparator)
pSh->InsertLineBreak();
}
else
{
// column not found -> show error
rtl::OUStringBuffer sInsert;
sInsert.append('?').append(sColumn).append('?');
pSh->Insert(sInsert.makeStringAndClear());
2000-09-18 16:15:01 +00:00
}
sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator);
}
pSh->SplitNode();
}
else
{
String sStr;
2001-09-04 11:40:59 +00:00
Sequence<rtl::OUString> aColNames = xCols->getElementNames();
const rtl::OUString* pColNames = aColNames.getConstArray();
2000-09-18 16:15:01 +00:00
long nLength = aColNames.getLength();
for(long i = 0; i < nLength; i++)
{
Any aCol = xCols->getByName(pColNames[i]);
uno::Reference< XPropertySet > xColumnProp;
aCol >>= xColumnProp;
2000-09-18 16:15:01 +00:00
SwDBFormatData aDBFormat;
sStr += GetDBField( xColumnProp, aDBFormat);
if (i < nLength - 1)
sStr += '\t';
}
CWS-TOOLING: integrate CWS odfmetadata3 2009-09-11 Michael Stahl merge DEV300_m58 2009-09-07 Michael Stahl SwFmtFld::Modify(): do nothing on RES_OBJECTDYING 2009-08-27 Michael Stahl #i91565#, #i91566#: TextPortionEnumerationTest.java: add test document 2009-08-27 Michael Stahl #i91565#, #i91566#: add complex test: TextPortionEnumerationTest.java 2009-08-27 Michael Stahl CLiteral::initialize(): zero-length literals probably not an error 2009-08-27 Michael Stahl #i91565#, #i91566#: offapi: new InContentMetadata and MetadataField services adapt TextPortion for InContentMetadata 2009-08-27 Michael Stahl #i91564#: xmloff: load/store xml:id and RDFa for text:bookmark(-start). 2009-08-27 Michael Stahl #i91564#: sw core: add support for xml:id at bookmarks: sw::mark::Bookmark: derive from Metadatable. SwHistoryBookmark, SaveBookmark: store a MetadatableUndo. ndcopy.cxx: lcl_CopyBookmarks(): copy the xml:id. SwXBookmark: derive from MetadatableMixin. 2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: refactor ruby import so nested meta(-field) works: remove XMLRubyHint_Impl. XMLImpRubyContext_Impl::~XMLImpRubyContext_Impl(): insert ruby directly. 2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: fix text:meta(-field) import/export: new XMLTextParagraphExport::exportTextField() overload for XTextField. CreateAndInsertMark(): set xml:id after insertion. fix meta(-field) service names, bugs etc. 2009-08-27 Michael Stahl #i91565#, #i91566#: sw text formatting: paint background of meta(-field) body: SwFont: add member m_nMetaCount. txttypes.hxx: add POR_META. atrstck.cxx: handle RES_TXTATR_META(FIELD). itrform2.cxx: SwTxtFormatter::WhichTxtPor(): create new class SwMetaPortion. 2009-08-27 Michael Stahl #i91566#: sw text formatting: display meta-field prefix and suffix: SwAttrIter::GetAttr(): replace with call to GetTxtAttrForCharAt(). SwTxtFormatter::NewExtraPortion(): handle meta-field prefix. SwTxtFormatter: new member m_nHintEndIndex. SwTxtFormatter::WhichFirstPortion(): call TryNewNoLengthPortion(). SwTxtFormatter::TryNewNoLengthPortion(): new; handle suffix of meta-field. SwTxtFormatter::UnderFlow(): UGLY HACK: decrement m_nHintEndIndex. SwFldPortion: add flag m_bNoLength: portion has zero length (for suffix). 2009-08-27 Michael Stahl #i91565#, #i91566#: extend text:meta(-field) uno wrapper with XText interface: unoobj.hxx: new CursorType CURSOR_META. unoobj2.cxx: refactor SwXText implementation to ensure that when the SwXText belongs to a SwXMeta, content is always inserted inside the meta(-field). unoobj.cxx: new SwXTextCursor::ForceIntoMeta(): cursor stays in meta(-field). unometa.hxx: SwXMeta implements XText, forwarding to a member SwXMetaText. DocInsertStringSplitCR(), SwX*::attachToRange(), SwX*::DeleteAndInsert(): use FORCEHINTEXPAND hack to ensure insert into the meta(-field) at the end. 2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) uno wrapper to sw: fmtmeta.hxx, fmtatr2.cxx: new class sw::MetaField, new sw::MetaFieldManager. doc.hxx, docnew.cxx: new SwDoc::GetMetaFieldManager(). unocoll.hxx,.cxx: new SW_SERVICE_FIELDTYPE_METAFIELD, SW_SERVICE_TYPE_META. unomap.hxx,.cxx: new PROPERTY_MAP_METAFIELD. unoprnms.hxx: new UNO_NAME_META. unoport.hxx: new PORTION_META; add "InContentMetadata" prop to SwXTextPortion. new unometa.hxx: new class SwXMeta and SwXMetaField. unofield.cxx: SwXFieldEnumeration: include meta-fields. unoportenum.cxx: handle RES_TXTATR_META(FIELD) by using a portion list stack. unotext.cxx: SwXText::insertTextContent(): handle meta(-field) as attribute. 2009-08-27 Michael Stahl #i91565#, #i91566#: ndhints.cxx: remove sort number from SwTxtAttrNesting 2009-08-27 Michael Stahl #i91565#, #i91566#: add support for hints with end and CH_TXTATR to sw core: doc.hxx, docedt.cxx: replace SwDoc::Delete(), DeleteAndJoin(), ReplaceRange() with wrappers that split at left-overlapped end+CH_TXTATR hints. txatbase.hxx: new member SwTxtAttr::m_bHasDummyChar. ndtxt.hxx: rename SwTxtNode::GetTxtAttr() to GetTxtAttrForCharAt(). ndtxt.cxx: SwTxtNode::CopyText(): copy end+CH_TXTATR hints iff copy CH_TXTATR. txtatr2.cxx, thints.cxx: SwTxtMeta gets a CH_TXTATR. 2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) to sw core: txatbase.hxx: new member SwTxtAttr::m_bNesting. hintids.hxx: new ids RES_TXTATR_META, RES_TXTATR_METAFIELD. txtatr.hxx: new base class SwTxtAttrNesting. new hint SwTxtMeta. SwTxtRuby derives from SwTxtAttrNesting. txtinet.hxx: SwTxtINetFmt derives from SwTxtAttrNesting. new header fmtmeta.hxx: new pool item SwFmtMeta. new class sw::Meta. ndhints.hxx, thints.cxx: new method SwpHints::TryInsertNesting(). thints.cxx: refactoring: BuildPortions() no longer handles Ruby/Hyperlink, but TryInsertNesting(), which also handles meta(-field). SwTxtNode::InsertItem(): check if the hint is actually inserted. ndhints.cxx: sort nesting hints based on sort number. ndtxt.cxx: lcl_CopyHint(): handle copy of meta/meta-field. 2009-08-27 Michael Stahl enable expanding hints with m_bLockExpandFlag set: add new InsertFlag: INS_FORCEHINTEXPAND. add new SetAttrMode: SETATTR_FORCEHINTEXPAND. rename SwEditShell::Insert() to Insert2() because changed signature fails to compile when SwWrtShell tries to overwrite these non-virtual members... SwWrtShell::Insert() sets FOCEHINTEXPAND if range was selected/deleted. adapt SwUndoInsert to store flags. 2009-08-27 Michael Stahl change formal parameters of item insertion methods to type SetAttrMode 2009-08-27 Michael Stahl fix incorrect resetting of text attributes in SwUndoInsSection, SwUndoInserts 2009-08-27 Michael Stahl clean up SwTxtNode::CutImpl() and lcl_CopyHint() 2009-08-27 Michael Stahl rename SwDoc::Copy() to CopyRange(), and _Copy() to CopyImpl() 2009-08-27 Michael Stahl rename SwNodes::Move() to MoveRange(), and remove unused parameter 2009-08-27 Michael Stahl rename SwDoc::Move() to MoveRange()/MoveNodeRange() 2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertString(), and remove sal_Unicode variant 2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertPoolItem()/InsertItemSet()/InsertSwSection() 2009-08-27 Michael Stahl rename SwDoc::Replace() to ReplaceRange() 2009-08-27 Michael Stahl remove SwDoc::Overwrite() sal_Unicode variant 2009-08-27 Michael Stahl split up SwDoc::DeleteAndJoin(): factor out DeleteAndJoinWithRedline() 2009-08-27 Michael Stahl rename overloaded SwDoc::Delete() to DeleteRange()/DeleteTOXMark() 2009-08-27 Michael Stahl rename SwTxtNode::Copy() to CopyText() 2009-08-27 Michael Stahl rename SwTxtNode::Cut() to CutText(), and _Cut() to CutImpl() 2009-08-27 Michael Stahl rename SwTxtNode::Delete() to DeleteAttribute()/DeleteAttributes() 2009-08-27 Michael Stahl rename SwTxtNode::Replace() to ReplaceText(), and remove the xub_Unicode variant 2009-08-27 Michael Stahl rename SwTxtNode::Erase() to EraseText() 2009-08-27 Michael Stahl rename SwTxtNode::Insert() to InsertText(), and remove the xub_Unicode variant 2009-08-27 Michael Stahl clean up SwTxtNode::Update() 2009-08-27 Michael Stahl remove SwTxtAttr::RemoveFromPool() and make destructor non-public, to be invoked by new method SwTxtAttr::Destroy() 2009-08-27 Michael Stahl ensure that SwDoc::Insert() for item (set) returns success indicator: replace SwRegHistory constructor with method InsertItems(), returning bool. refactor InsAttr() so that it checks if InsertItems() succeeds. 2009-08-27 Michael Stahl move SwXTextPortionEnumeration from unoobj.hxx to unoport.hxx 2009-08-27 Michael Stahl add missing SolarMutex in SwXTextPortion methods 2009-08-27 Michael Stahl SwXTextPortion: new member m_xTextField (so the TextField property need not be returned indirectly via SwUnoCursorHelper). factor out function CreateSwXTextField(). 2009-08-27 Michael Stahl SwXTextPortion: remove PORTION_CONTROL_CHAR and implementation of XTextField 2009-08-27 Michael Stahl remove obsolete hint SwTxtHardBlank and formats SwFmtHardBlank/SwFmtSoftHyph 2009-08-27 Michael Stahl clean up SwTxtAttr and friends: remove many accessor methods for obsolete (due to autofmt) char format items. remove unused flag SwTxtAttr::m_bDontMergeAttr. MakeRedlineTxtAttr() now dedicated function, no longer calls MakeTxtAttr(). 2009-08-27 Michael Stahl remove obsolete attribute SwTxt2Lines 2009-08-27 Michael Stahl SwXTextPortionEnumeration: finish refactoring CreatePortions change ExportHints so it always returns a text portion for hint w/ CH_TXTATR. remove special case for handling end of paragraph. unfortunately had to refactor the fieldmarks export as well (got in the way). 2009-08-27 Michael Stahl SwXTextPortionEnumeration: refactor CreatePortions: frames export extract function ExportFrames() from CreatePortions(). remove (un)dead code that calls evil MovePara(fnParaCurr, fnParaEnd) 2009-08-27 Michael Stahl clean up SwXParaFrameEnumeration 2009-08-27 Michael Stahl CollectFrameAtNode: replace SwDependArr with STL based FrameDependList_t 2009-08-27 Michael Stahl SwXTextPortionEnumeration: tweak refmark/toxmark export so ExportHints returns the portion for point marks 2009-08-27 Michael Stahl clean up SwXTextPortionEnumeration: prefix members, remove casts, replace SvWeirdArray with STL, etc. make CreatePortions() method a function, and remove lots of members. extract fieldmarks function from CreatePortions. 2009-08-27 Michael Stahl remove FOREACHUNOPAM_START/END macros 2009-08-27 Michael Stahl clean up SwXTextPortion: prefix members, remove casts, etc. remove SwXRubyPortion: replace it with another SwXTextPortion constructor 2009-08-27 Michael Stahl #i102541# SwXReferenceMark::InsertRefMark(): use flag SETATTR_DONTEXPAND 2009-08-27 Michael Stahl rename SwTxtNode::Insert to SwTxtNode::InsertHint, and fix constness in SwTxtNode::InsertItem 2009-08-27 Michael Stahl turn SwTxtNode::MakeTxtAttr() methods into global functions in ndhints.hxx 2009-08-27 Michael Stahl remove obsolete sw/inc/bookmrk.hxx 2009-08-27 Michael Stahl pam.cxx: fix ComparePosition functions (returned wrong result in one case) 2009-08-27 Michael Stahl #i103613# only import RDF metadata on normal open of a document 2009-09-11 kz CWS-TOOLING: integrate CWS impress176 2009-09-08 20:18:24 +0200 sj r275957 : fixed warning (shadowed variable) 2009-09-08 18:02:05 +0200 cl r275948 : #i104315# added missing tab pages 2009-09-08 17:35:18 +0200 cl r275947 : #i104866# fixed angle import 2009-09-08 17:32:53 +0200 cl r275946 : #i104841# fixed angle import 2009-09-08 17:01:25 +0200 cl r275943 : #i103935# fixed the SID_EVENTCONFIG mess 2009-09-08 14:32:57 +0200 sj r275928 : #i104685# only comments 2009-09-07 12:37:36 +0200 sj r275886 : #i104683# fixed import of bold/italic attributes for normal text shapes 2009-09-04 15:07:46 +0200 sj r275808 : #104689# fixed bullet color problem 2009-09-03 15:25:07 +0200 sj r275753 : #160200# added vertical alignment of table cells 2009-09-11 kz CWS-TOOLING: integrate CWS dv14 2009-09-10 15:16:32 +0200 sg r276035 : #160513# updated wfs scheme to accept ports 2009-09-10 07:41:47 +0200 dv r276019 : #i104942# Better renaming algorithmen 2009-08-31 13:41:11 +0200 dv r275604 : #160505# Setting APP1PRODUCTNAME must not overwrite APP1PRODUCTDEF 2009-09-11 kz CWS-TOOLING: integrate CWS jl131 2009-09-02 16:42:40 +0200 jl r275720 : #i97896# 2009-08-31 13:01:53 +0200 jl r275599 : CWS-TOOLING: rebase CWS jl131 to trunk@275331 (milestone: DEV300:m56) 2009-07-31 14:35:30 +0200 jl r274531 : CWS-TOOLING: rebase CWS jl131 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 14:20:32 +0200 jl r274272 : #i79839# better error text when trying to modify shared layer without having write permission, eg. unopkg add --shared, unopkg remove --shared, unopkg reinstall --shared 2009-07-22 16:38:02 +0200 jl r274252 : #i97896# localize error message for lock file 2009-07-22 16:37:22 +0200 jl r274251 : #i80462# unprecise wording in updatedialog 2009-07-22 16:36:06 +0200 jl r274250 : #i97896# localize error message for lock file 2009-07-22 16:35:20 +0200 jl r274249 : #i97896# localize error message for lock file 2009-07-22 15:07:30 +0200 jl r274242 : #i98873# minimum java version is 1.5 since OOo 3.0 2009-09-11 kz CWS-TOOLING: integrate CWS changehc 2009-08-31 19:38:50 +0200 pl r275633 : remove dbug printf 2009-08-31 17:41:50 +0200 pl r275623 : CWS-TOOLING: rebase CWS changehc to trunk@275331 (milestone: DEV300:m56) 2009-07-15 19:45:46 +0200 pl r274028 : #i35482# use HC flag to decide high contrast mode 2009-07-15 17:40:52 +0200 pl r274020 : #i35482# use HC flag to decide high contrast mode 2009-07-15 17:39:50 +0200 pl r274019 : #i35482# update autohc correctly in MergeSystemSettings 2009-07-15 17:38:57 +0200 pl r274018 : #i35482# update autohc correctly in MergeSystemSettings 2009-09-11 kz CWS-TOOLING: integrate CWS notes10 2009-08-24 07:25:57 +0200 mod r275287 : 2009-07-26 02:38:32 +0200 mod r274343 : #i#i103645# 2009-07-26 02:01:53 +0200 mod r274342 : #i103645# 2009-07-26 01:52:42 +0200 mod r274341 : #i103490# 2009-07-22 08:31:48 +0200 mod r274215 : #i103373# 2009-07-15 00:55:11 +0200 mod r273987 : #i101419# 2009-07-14 07:07:55 +0200 mod r273956 : #i101419# 2009-07-14 07:07:43 +0200 mod r273955 : #i101419# 2009-07-14 07:02:10 +0200 mod r273954 : changes from notes9 2009-07-14 06:14:25 +0200 mod r273953 : #i103476# 2009-09-11 kz CWS-TOOLING: integrate CWS ab70 2009-09-10 15:12:54 +0200 jsk r276034 : #i85434# - mandatory automatic update test 2009-09-10 15:11:06 +0200 jsk r276033 : #i85434# - mandatory automatic update test 2009-09-02 09:49:24 +0200 ab r275698 : #i85434# Dialog Import 2009-09-11 kz CWS-TOOLING: integrate CWS hb32bugs02 2009-09-02 Henning Brinkmann #i102420# revert changes 2009-08-26 Henning Brinkmann merged DEV300_m56 2009-08-19 Henning Brinkmann merged DEV300_m55 2009-08-14 Henning Brinkmann merged changes from wntmsci12 2009-08-12 Henning Brinkmann Implemented NoSpaceEdit constructor and destructor in .cxx to allow compile with debug on wntmsci12. 2009-08-12 Henning Brinkmann Added some SW_DLLPUBLIC to make compilable on wntmsci12. 2009-08-11 Henning Brinkmann #i102420# dbg_out: surround output for SwNodes with <nodes-array>. 2009-08-10 Henning Brinkmann #i102420# rewritten debug output for SwNodes. 2009-08-07 Henning Brinkmann #i102420# debug _MoveNodes: output the destination, too. Break after two iterations. 2009-08-07 Henning Brinkmann #i102420# _MoveNodes: Additionally check if destination index is inside source => false Check if current range was already handled => loop Debug output current range 2009-08-06 Henning Brinkmann merged DEV300_m54 2009-08-06 Henning Brinkmann added master fix 2009-08-06 Henning Brinkmann debug output for SwNodeRange 2009-08-04 Henning Brinkmann #i102844# robustness: check for NULL pointer to prevent crash 2009-08-03 Henning Brinkmann #i103475# applied patch and verified 2009-08-03 Henning Brinkmann Removed code preventing build of sw with DEBUG. 2009-09-11 convert-repo update tags 2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300 2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree. 2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23 2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite 2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix 2009-09-10 kz CWS-TOOLING: integrate CWS mh232 2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch 2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD 2009-08-26 03:11:20 +0200 mh r275383 : #i39230 2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field 2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name 2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl 2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam 2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613# 2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3 2009-09-10 kz CWS-TOOLING: integrate CWS tkr24 2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT 2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping> 2009-09-11 convert-repo update tags 2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300 2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree. 2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23 2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite 2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix 2009-09-10 kz CWS-TOOLING: integrate CWS mh232 2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch 2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD 2009-08-26 03:11:20 +0200 mh r275383 : #i39230 2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field 2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name 2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl 2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam 2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613# 2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3 2009-09-10 kz CWS-TOOLING: integrate CWS tkr24 2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT 2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping>
2009-09-11 14:29:45 +00:00
pSh->SwEditShell::Insert2(sStr);
pSh->SwFEShell::SplitNode(); // line feed
2000-09-18 16:15:01 +00:00
}
}
}
2010-10-11 17:38:56 -05:00
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Description: fill Listbox with tablelist
2000-09-18 16:15:01 +00:00
--------------------------------------------------------------------*/
sal_Bool SwNewDBMgr::GetTableNames(ListBox* pListBox, const String& rDBName)
2000-09-18 16:15:01 +00:00
{
sal_Bool bRet = sal_False;
2000-09-18 16:15:01 +00:00
String sOldTableName(pListBox->GetSelectEntry());
pListBox->Clear();
SwDSParam* pParam = FindDSConnection(rDBName, sal_False);
uno::Reference< XConnection> xConnection;
if(pParam && pParam->xConnection.is())
xConnection = pParam->xConnection;
else
2002-10-24 12:48:08 +00:00
{
rtl::OUString sDBName(rDBName);
if ( !sDBName.isEmpty() )
xConnection = RegisterConnection( sDBName );
2002-10-24 12:48:08 +00:00
}
2000-09-18 16:15:01 +00:00
if(xConnection.is())
{
uno::Reference<XTablesSupplier> xTSupplier = uno::Reference<XTablesSupplier>(xConnection, UNO_QUERY);
2000-09-18 16:15:01 +00:00
if(xTSupplier.is())
{
uno::Reference<XNameAccess> xTbls = xTSupplier->getTables();
2001-09-04 11:40:59 +00:00
Sequence<rtl::OUString> aTbls = xTbls->getElementNames();
const rtl::OUString* pTbls = aTbls.getConstArray();
2000-09-18 16:15:01 +00:00
for(long i = 0; i < aTbls.getLength(); i++)
{
sal_uInt16 nEntry = pListBox->InsertEntry(pTbls[i]);
pListBox->SetEntryData(nEntry, (void*)0);
}
2000-09-18 16:15:01 +00:00
}
uno::Reference<XQueriesSupplier> xQSupplier = uno::Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
2000-09-18 16:15:01 +00:00
if(xQSupplier.is())
{
uno::Reference<XNameAccess> xQueries = xQSupplier->getQueries();
2001-09-04 11:40:59 +00:00
Sequence<rtl::OUString> aQueries = xQueries->getElementNames();
const rtl::OUString* pQueries = aQueries.getConstArray();
2000-09-18 16:15:01 +00:00
for(long i = 0; i < aQueries.getLength(); i++)
{
sal_uInt16 nEntry = pListBox->InsertEntry(pQueries[i]);
pListBox->SetEntryData(nEntry, (void*)1);
}
2000-09-18 16:15:01 +00:00
}
if (sOldTableName.Len())
pListBox->SelectEntry(sOldTableName);
bRet = sal_True;
2000-09-18 16:15:01 +00:00
}
return bRet;
}
/*--------------------------------------------------------------------
Description: fill Listbox with column names of a database
2000-09-18 16:15:01 +00:00
--------------------------------------------------------------------*/
sal_Bool SwNewDBMgr::GetColumnNames(ListBox* pListBox,
const String& rDBName, const String& rTableName, sal_Bool bAppend)
2000-09-18 16:15:01 +00:00
{
if (!bAppend)
pListBox->Clear();
SwDBData aData;
aData.sDataSource = rDBName;
aData.sCommand = rTableName;
aData.nCommandType = -1;
SwDSParam* pParam = FindDSData(aData, sal_False);
uno::Reference< XConnection> xConnection;
if(pParam && pParam->xConnection.is())
xConnection = pParam->xConnection;
else
2002-10-24 12:48:08 +00:00
{
rtl::OUString sDBName(rDBName);
xConnection = RegisterConnection( sDBName );
}
uno::Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
2000-09-18 16:15:01 +00:00
if(xColsSupp.is())
{
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
2001-09-04 11:40:59 +00:00
const Sequence<rtl::OUString> aColNames = xCols->getElementNames();
const rtl::OUString* pColNames = aColNames.getConstArray();
2000-09-18 16:15:01 +00:00
for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
{
pListBox->InsertEntry(pColNames[nCol]);
}
::comphelper::disposeComponent( xColsSupp );
2000-09-18 16:15:01 +00:00
}
return(sal_True);
2000-09-18 16:15:01 +00:00
}
sal_Bool SwNewDBMgr::GetColumnNames(ListBox* pListBox,
uno::Reference< XConnection> xConnection,
const String& rTableName, sal_Bool bAppend)
{
if (!bAppend)
pListBox->Clear();
uno::Reference< XColumnsSupplier> xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
if(xColsSupp.is())
{
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
2001-09-04 11:40:59 +00:00
const Sequence<rtl::OUString> aColNames = xCols->getElementNames();
const rtl::OUString* pColNames = aColNames.getConstArray();
for(int nCol = 0; nCol < aColNames.getLength(); nCol++)
{
pListBox->InsertEntry(pColNames[nCol]);
}
::comphelper::disposeComponent( xColsSupp );
}
return(sal_True);
}
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Description: CTOR
2000-09-18 16:15:01 +00:00
--------------------------------------------------------------------*/
SwNewDBMgr::SwNewDBMgr() :
nMergeType(DBMGR_INSERT),
bInitDBFields(sal_False),
bInMerge(sal_False),
bMergeSilent(sal_False),
bMergeLock(sal_False),
pImpl(new SwNewDBMgr_Impl(*this)),
pMergeEvtSrc(NULL)
2000-09-18 16:15:01 +00:00
{
}
SwNewDBMgr::~SwNewDBMgr()
{
for(sal_uInt16 nPos = 0; nPos < aDataSourceParams.size(); nPos++)
{
SwDSParam* pParam = &aDataSourceParams[nPos];
if(pParam->xConnection.is())
{
try
{
uno::Reference<XComponent> xComp(pParam->xConnection, UNO_QUERY);
if(xComp.is())
xComp->dispose();
}
2011-06-15 23:56:45 +01:00
catch(const RuntimeException&)
{
//may be disposed already since multiple entries may have used the same connection
}
}
}
delete pImpl;
2000-09-18 16:15:01 +00:00
}
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Description: save bulk letters as single documents
2000-09-18 16:15:01 +00:00
--------------------------------------------------------------------*/
String lcl_FindUniqueName(SwWrtShell* pTargetShell, const String& rStartingPageDesc, sal_uLong nDocNo )
{
do
{
String sTest = rStartingPageDesc;
sTest += String::CreateFromInt32( nDocNo );
if( !pTargetShell->FindPageDescByName( sTest ) )
return sTest;
++nDocNo;
}while(true);
}
2010-10-11 17:38:56 -05:00
void lcl_CopyDynamicDefaults( const SwDoc& rSource, SwDoc& rTarget )
{
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101 Conflicts: starmath/inc/applicat.hxx starmath/inc/dialog.hxx starmath/inc/document.hxx starmath/inc/edit.hxx starmath/inc/format.hxx starmath/inc/node.hxx starmath/inc/parse.hxx starmath/inc/rect.hxx starmath/inc/smdll.hxx starmath/inc/smmod.hxx starmath/inc/starmath.hrc starmath/inc/symbol.hxx starmath/inc/toolbox.hxx starmath/inc/utility.hxx starmath/inc/view.hxx starmath/prj/build.lst starmath/qa/cppunit/version.map starmath/sdi/smslots.sdi starmath/source/accessibility.cxx starmath/source/cfgitem.cxx starmath/source/cfgitem.hxx starmath/source/config.cxx starmath/source/dialog.cxx starmath/source/document.cxx starmath/source/edit.cxx starmath/source/format.cxx starmath/source/makefile.mk starmath/source/math_pch.cxx starmath/source/mathmlexport.cxx starmath/source/mathmlimport.cxx starmath/source/mathtype.cxx starmath/source/node.cxx starmath/source/parse.cxx starmath/source/rect.cxx starmath/source/register.cxx starmath/source/smdetect.cxx starmath/source/smdll.cxx starmath/source/smmod.cxx starmath/source/smres.src starmath/source/symbol.cxx starmath/source/toolbox.cxx starmath/source/unomodel.cxx starmath/source/utility.cxx starmath/source/view.cxx sw/JunitTest_sw_unoapi.mk sw/Library_swd.mk sw/Makefile sw/inc/IDocumentFieldsAccess.hxx sw/inc/IDocumentSettingAccess.hxx sw/inc/IDocumentUndoRedo.hxx sw/inc/IShellCursorSupplier.hxx sw/inc/SwUndoField.hxx sw/inc/acmplwrd.hxx sw/inc/authfld.hxx sw/inc/bparr.hxx sw/inc/calbck.hxx sw/inc/calc.hxx sw/inc/ccoll.hxx sw/inc/cellatr.hxx sw/inc/cellfml.hxx sw/inc/chpfld.hxx sw/inc/cmdid.h sw/inc/crsrsh.hxx sw/inc/crstate.hxx sw/inc/dbfld.hxx sw/inc/dbmgr.hxx sw/inc/dcontact.hxx sw/inc/ddefld.hxx sw/inc/doc.hxx sw/inc/docary.hxx sw/inc/docsh.hxx sw/inc/docstat.hxx sw/inc/docstyle.hxx sw/inc/docufld.hxx sw/inc/editsh.hxx sw/inc/errhdl.hxx sw/inc/expfld.hxx sw/inc/fchrfmt.hxx sw/inc/fesh.hxx sw/inc/fldbas.hxx sw/inc/flddat.hxx sw/inc/flddropdown.hxx sw/inc/flypos.hxx sw/inc/fmtanchr.hxx sw/inc/fmtautofmt.hxx sw/inc/fmtclds.hxx sw/inc/fmtcnct.hxx sw/inc/fmtcol.hxx sw/inc/fmtfsize.hxx sw/inc/fmtftn.hxx sw/inc/fmtftntx.hxx sw/inc/fmthdft.hxx sw/inc/fmtinfmt.hxx sw/inc/fmtline.hxx sw/inc/fmtornt.hxx sw/inc/fmtpdsc.hxx sw/inc/fmtruby.hxx sw/inc/fmtsrnd.hxx sw/inc/fmturl.hxx sw/inc/fmtwrapinfluenceonobjpos.hxx sw/inc/format.hxx sw/inc/frmatr.hxx sw/inc/frmfmt.hxx sw/inc/grfatr.hxx sw/inc/helpid.h sw/inc/hintids.hxx sw/inc/hints.hxx sw/inc/htmltbl.hxx sw/inc/inetfld.hxx sw/inc/io.hxx sw/inc/iodetect.hxx sw/inc/itabenum.hxx sw/inc/ndarr.hxx sw/inc/ndgrf.hxx sw/inc/ndindex.hxx sw/inc/ndnotxt.hxx sw/inc/ndole.hxx sw/inc/ndtxt.hxx sw/inc/ndtyp.hxx sw/inc/node.hxx sw/inc/numrule.hxx sw/inc/pagedesc.hxx sw/inc/pagepreviewlayout.hxx sw/inc/pam.hxx sw/inc/paratr.hxx sw/inc/poolfmt.awk sw/inc/poolfmt.hxx sw/inc/printdata.hxx sw/inc/reffld.hxx sw/inc/shellio.hxx sw/inc/shellres.hxx sw/inc/swabstdlg.hxx sw/inc/swatrset.hxx sw/inc/swerror.h sw/inc/swprtopt.hxx sw/inc/swtable.hxx sw/inc/swtypes.hxx sw/inc/tblafmt.hxx sw/inc/tgrditem.hxx sw/inc/tox.hxx sw/inc/undobj.hxx sw/inc/unocoll.hxx sw/inc/unoframe.hxx sw/inc/unoprnms.hxx sw/inc/usrfld.hxx sw/inc/viewopt.hxx sw/inc/viewsh.hxx sw/inc/viscrs.hxx sw/prj/build.lst sw/qa/complex/accessibility/makefile.mk sw/qa/core/Test-BigPtrArray.cxx sw/qa/core/makefile.mk sw/sdi/makefile.mk sw/source/core/access/makefile.mk sw/source/core/access/textmarkuphelper.cxx sw/source/core/attr/calbck.cxx sw/source/core/attr/cellatr.cxx sw/source/core/attr/fmtwrapinfluenceonobjpos.cxx sw/source/core/attr/format.cxx sw/source/core/attr/hints.cxx sw/source/core/bastyp/calc.cxx sw/source/core/bastyp/init.cxx sw/source/core/bastyp/makefile.mk sw/source/core/bastyp/swcache.cxx sw/source/core/crsr/bookmrk.cxx sw/source/core/crsr/callnk.cxx sw/source/core/crsr/crsrsh.cxx sw/source/core/crsr/crstrvl.cxx sw/source/core/crsr/findattr.cxx sw/source/core/crsr/findcoll.cxx sw/source/core/crsr/makefile.mk sw/source/core/crsr/pam.cxx sw/source/core/crsr/swcrsr.cxx sw/source/core/crsr/trvltbl.cxx sw/source/core/crsr/unocrsr.cxx sw/source/core/crsr/viscrs.cxx sw/source/core/doc/acmplwrd.cxx sw/source/core/doc/doc.cxx sw/source/core/doc/docbm.cxx sw/source/core/doc/doccomp.cxx sw/source/core/doc/docdesc.cxx sw/source/core/doc/docdraw.cxx sw/source/core/doc/docedt.cxx sw/source/core/doc/docfld.cxx sw/source/core/doc/docfly.cxx sw/source/core/doc/docfmt.cxx sw/source/core/doc/docftn.cxx sw/source/core/doc/docglbl.cxx sw/source/core/doc/docglos.cxx sw/source/core/doc/doclay.cxx sw/source/core/doc/docnew.cxx sw/source/core/doc/docnum.cxx sw/source/core/doc/docredln.cxx sw/source/core/doc/docruby.cxx sw/source/core/doc/docsort.cxx sw/source/core/doc/docstat.cxx sw/source/core/doc/doctxm.cxx sw/source/core/doc/fmtcol.cxx sw/source/core/doc/gctable.cxx sw/source/core/doc/htmltbl.cxx sw/source/core/doc/makefile.mk sw/source/core/doc/number.cxx sw/source/core/doc/poolfmt.cxx sw/source/core/doc/tblafmt.cxx sw/source/core/doc/tblcpy.cxx sw/source/core/doc/tblrwcl.cxx sw/source/core/docnode/makefile.mk sw/source/core/docnode/ndcopy.cxx sw/source/core/docnode/ndnum.cxx sw/source/core/docnode/ndsect.cxx sw/source/core/docnode/ndtbl.cxx sw/source/core/docnode/ndtbl1.cxx sw/source/core/docnode/node.cxx sw/source/core/docnode/node2lay.cxx sw/source/core/docnode/nodes.cxx sw/source/core/docnode/section.cxx sw/source/core/docnode/swbaslnk.cxx sw/source/core/draw/dcontact.cxx sw/source/core/draw/dflyobj.cxx sw/source/core/draw/drawdoc.cxx sw/source/core/draw/dview.cxx sw/source/core/draw/makefile.mk sw/source/core/edit/autofmt.cxx sw/source/core/edit/edattr.cxx sw/source/core/edit/eddel.cxx sw/source/core/edit/edfcol.cxx sw/source/core/edit/edfld.cxx sw/source/core/edit/edfldexp.cxx sw/source/core/edit/edfmt.cxx sw/source/core/edit/edglss.cxx sw/source/core/edit/editsh.cxx sw/source/core/edit/edlingu.cxx sw/source/core/edit/ednumber.cxx sw/source/core/edit/edsect.cxx sw/source/core/edit/edtab.cxx sw/source/core/edit/edtox.cxx sw/source/core/edit/edundo.cxx sw/source/core/edit/makefile.mk sw/source/core/except/dbgloop.cxx sw/source/core/except/errhdl.cxx sw/source/core/fields/authfld.cxx sw/source/core/fields/cellfml.cxx sw/source/core/fields/chpfld.cxx sw/source/core/fields/dbfld.cxx sw/source/core/fields/ddefld.cxx sw/source/core/fields/ddetbl.cxx sw/source/core/fields/docufld.cxx sw/source/core/fields/expfld.cxx sw/source/core/fields/fldbas.cxx sw/source/core/fields/flddat.cxx sw/source/core/fields/flddropdown.cxx sw/source/core/fields/macrofld.cxx sw/source/core/fields/makefile.mk sw/source/core/fields/reffld.cxx sw/source/core/fields/scrptfld.cxx sw/source/core/fields/tblcalc.cxx sw/source/core/fields/usrfld.cxx sw/source/core/frmedt/fecopy.cxx sw/source/core/frmedt/fedesc.cxx sw/source/core/frmedt/fefly1.cxx sw/source/core/frmedt/feshview.cxx sw/source/core/frmedt/fetab.cxx sw/source/core/frmedt/fews.cxx sw/source/core/frmedt/makefile.mk sw/source/core/frmedt/tblsel.cxx sw/source/core/graphic/grfatr.cxx sw/source/core/inc/SwUndoFmt.hxx sw/source/core/inc/SwUndoTOXChange.hxx sw/source/core/inc/anchoredobjectposition.hxx sw/source/core/inc/dbgloop.hxx sw/source/core/inc/drawfont.hxx sw/source/core/inc/flowfrm.hxx sw/source/core/inc/frame.hxx sw/source/core/inc/frmtool.hxx sw/source/core/inc/layact.hxx sw/source/core/inc/layfrm.hxx sw/source/core/inc/notxtfrm.hxx sw/source/core/inc/rolbck.hxx sw/source/core/inc/rootfrm.hxx sw/source/core/inc/scriptinfo.hxx sw/source/core/inc/swblocks.hxx sw/source/core/inc/swcache.hxx sw/source/core/inc/tabfrm.hxx sw/source/core/inc/txmsrt.hxx sw/source/core/inc/undoflystrattr.hxx sw/source/core/inc/viewimp.hxx sw/source/core/layout/atrfrm.cxx sw/source/core/layout/calcmove.cxx sw/source/core/layout/dbg_lay.cxx sw/source/core/layout/findfrm.cxx sw/source/core/layout/flowfrm.cxx sw/source/core/layout/fly.cxx sw/source/core/layout/flycnt.cxx sw/source/core/layout/flyincnt.cxx sw/source/core/layout/flylay.cxx sw/source/core/layout/frmtool.cxx sw/source/core/layout/ftnfrm.cxx sw/source/core/layout/layact.cxx sw/source/core/layout/laycache.cxx sw/source/core/layout/makefile.mk sw/source/core/layout/objectformatter.cxx sw/source/core/layout/pagechg.cxx sw/source/core/layout/pagedesc.cxx sw/source/core/layout/paintfrm.cxx sw/source/core/layout/sectfrm.cxx sw/source/core/layout/tabfrm.cxx sw/source/core/layout/trvlfrm.cxx sw/source/core/layout/unusedf.cxx sw/source/core/layout/wsfrm.cxx sw/source/core/makefile.mk sw/source/core/objectpositioning/anchoredobjectposition.cxx sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx sw/source/core/objectpositioning/makefile.mk sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx sw/source/core/objectpositioning/tolayoutanchoredobjectposition.cxx sw/source/core/ole/ndole.cxx sw/source/core/para/makefile.mk sw/source/core/para/paratr.cxx sw/source/core/sw3io/makefile.mk sw/source/core/sw3io/sw3convert.cxx sw/source/core/swg/SwXMLTextBlocks.cxx sw/source/core/swg/makefile.mk sw/source/core/swg/swblocks.cxx sw/source/core/table/swnewtable.cxx sw/source/core/table/swtable.cxx sw/source/core/text/EnhancedPDFExportHelper.cxx sw/source/core/text/atrstck.cxx sw/source/core/text/frmcrsr.cxx sw/source/core/text/frmform.cxx sw/source/core/text/itrcrsr.cxx sw/source/core/text/itrform2.cxx sw/source/core/text/makefile.mk sw/source/core/text/porlay.cxx sw/source/core/text/pormulti.cxx sw/source/core/text/txtfld.cxx sw/source/core/text/txtfrm.cxx sw/source/core/text/txtio.cxx sw/source/core/tox/makefile.mk sw/source/core/tox/txmsrt.cxx sw/source/core/txtnode/fmtatr2.cxx sw/source/core/txtnode/fntcache.cxx sw/source/core/txtnode/fntcap.cxx sw/source/core/txtnode/makefile.mk sw/source/core/txtnode/ndhints.cxx sw/source/core/txtnode/ndtxt.cxx sw/source/core/txtnode/swfont.cxx sw/source/core/txtnode/thints.cxx sw/source/core/txtnode/txtatr2.cxx sw/source/core/txtnode/txtedt.cxx sw/source/core/undo/SwUndoField.cxx sw/source/core/undo/SwUndoPageDesc.cxx sw/source/core/undo/SwUndoTOXChange.cxx sw/source/core/undo/docundo.cxx sw/source/core/undo/makefile.mk sw/source/core/undo/rolbck.cxx sw/source/core/undo/unbkmk.cxx sw/source/core/undo/undel.cxx sw/source/core/undo/undobj.cxx sw/source/core/undo/undobj1.cxx sw/source/core/undo/unfmco.cxx sw/source/core/undo/unins.cxx sw/source/core/undo/unnum.cxx sw/source/core/undo/unoutl.cxx sw/source/core/undo/unredln.cxx sw/source/core/undo/unsect.cxx sw/source/core/undo/unsort.cxx sw/source/core/undo/unspnd.cxx sw/source/core/undo/untbl.cxx sw/source/core/unocore/makefile.mk sw/source/core/unocore/swunohelper.cxx sw/source/core/unocore/unobkm.cxx sw/source/core/unocore/unocoll.cxx sw/source/core/unocore/unocrsrhelper.cxx sw/source/core/unocore/unodraw.cxx sw/source/core/unocore/unofield.cxx sw/source/core/unocore/unoframe.cxx sw/source/core/unocore/unomap.cxx sw/source/core/unocore/unoprnms.cxx sw/source/core/unocore/unoredlines.cxx sw/source/core/unocore/unosett.cxx sw/source/core/unocore/unosrch.cxx sw/source/core/unocore/unostyle.cxx sw/source/core/unocore/unotbl.cxx sw/source/core/view/vdraw.cxx sw/source/core/view/viewimp.cxx sw/source/core/view/viewpg.cxx sw/source/core/view/viewsh.cxx sw/source/core/view/vnew.cxx sw/source/core/view/vprint.cxx sw/source/filter/ascii/ascatr.cxx sw/source/filter/ascii/makefile.mk sw/source/filter/ascii/wrtasc.cxx sw/source/filter/basflt/fltini.cxx sw/source/filter/basflt/iodetect.cxx sw/source/filter/basflt/makefile.mk sw/source/filter/html/SwAppletImpl.cxx sw/source/filter/html/css1atr.cxx sw/source/filter/html/htmlatr.cxx sw/source/filter/html/htmlbas.cxx sw/source/filter/html/htmlcss1.cxx sw/source/filter/html/htmlfly.cxx sw/source/filter/html/htmlftn.cxx sw/source/filter/html/htmlgrin.cxx sw/source/filter/html/htmlnum.cxx sw/source/filter/html/htmlplug.cxx sw/source/filter/html/htmltab.cxx sw/source/filter/html/makefile.mk sw/source/filter/html/parcss1.cxx sw/source/filter/html/svxcss1.cxx sw/source/filter/html/swhtml.cxx sw/source/filter/inc/msfilter.hxx sw/source/filter/inc/wrtswtbl.hxx sw/source/filter/rtf/makefile.mk sw/source/filter/rtf/rtffly.cxx sw/source/filter/rtf/rtfnum.cxx sw/source/filter/rtf/rtftbl.cxx sw/source/filter/rtf/swparrtf.cxx sw/source/filter/rtf/swparrtf.hxx sw/source/filter/writer/makefile.mk sw/source/filter/writer/writer.cxx sw/source/filter/writer/wrt_fn.cxx sw/source/filter/writer/wrtswtbl.cxx sw/source/filter/ww1/fltshell.cxx sw/source/filter/ww1/makefile.mk sw/source/filter/ww1/w1class.cxx sw/source/filter/ww1/w1class.hxx sw/source/filter/ww1/w1filter.cxx sw/source/filter/ww1/w1par.cxx sw/source/filter/ww1/w1sprm.cxx sw/source/filter/ww1/w1struct.hxx sw/source/filter/ww8/README-rtf.txt sw/source/filter/ww8/attributeoutputbase.hxx sw/source/filter/ww8/docxattributeoutput.cxx sw/source/filter/ww8/docxattributeoutput.hxx sw/source/filter/ww8/docxexport.cxx sw/source/filter/ww8/docxexport.hxx sw/source/filter/ww8/docxexportfilter.cxx sw/source/filter/ww8/dump/dump8.cxx sw/source/filter/ww8/dump/dump8a.cxx sw/source/filter/ww8/dump/msvbasic.cxx sw/source/filter/ww8/dump/msvbasic.hxx sw/source/filter/ww8/dump/ww8darr.cxx sw/source/filter/ww8/dump/ww8darr.hxx sw/source/filter/ww8/dump/ww8dout.cxx sw/source/filter/ww8/dump/ww8dout.hxx sw/source/filter/ww8/dump/ww8scan.cxx sw/source/filter/ww8/dump/ww8scan.hxx sw/source/filter/ww8/dump/ww8struc.hxx sw/source/filter/ww8/makefile.mk sw/source/filter/ww8/rtfattributeoutput.cxx sw/source/filter/ww8/rtfattributeoutput.hxx sw/source/filter/ww8/rtfexport.cxx sw/source/filter/ww8/rtfexport.hxx sw/source/filter/ww8/rtfexportfilter.cxx sw/source/filter/ww8/rtfexportfilter.hxx sw/source/filter/ww8/rtfimportfilter.cxx sw/source/filter/ww8/rtfimportfilter.hxx sw/source/filter/ww8/rtfsdrexport.cxx sw/source/filter/ww8/rtfsdrexport.hxx sw/source/filter/ww8/writerhelper.cxx sw/source/filter/ww8/writerwordglue.cxx sw/source/filter/ww8/wrtw8esh.cxx sw/source/filter/ww8/wrtw8nds.cxx sw/source/filter/ww8/wrtw8num.cxx sw/source/filter/ww8/wrtw8sty.cxx sw/source/filter/ww8/wrtww8.cxx sw/source/filter/ww8/wrtww8.hxx sw/source/filter/ww8/wrtww8gr.cxx sw/source/filter/ww8/ww8atr.cxx sw/source/filter/ww8/ww8attributeoutput.hxx sw/source/filter/ww8/ww8graf.cxx sw/source/filter/ww8/ww8graf.hxx sw/source/filter/ww8/ww8graf2.cxx sw/source/filter/ww8/ww8par.cxx sw/source/filter/ww8/ww8par.hxx sw/source/filter/ww8/ww8par2.cxx sw/source/filter/ww8/ww8par3.cxx sw/source/filter/ww8/ww8par5.cxx sw/source/filter/ww8/ww8par6.cxx sw/source/filter/ww8/ww8scan.cxx sw/source/filter/ww8/ww8scan.hxx sw/source/filter/ww8/ww8struc.hxx sw/source/filter/xml/makefile.mk sw/source/filter/xml/xmlimpit.cxx sw/source/filter/xml/xmltble.cxx sw/source/filter/xml/xmltbli.cxx sw/source/ui/app/appenv.cxx sw/source/ui/app/apphdl.cxx sw/source/ui/app/applab.cxx sw/source/ui/app/appopt.cxx sw/source/ui/app/docsh.cxx sw/source/ui/app/docsh2.cxx sw/source/ui/app/docshini.cxx sw/source/ui/app/docst.cxx sw/source/ui/app/docstyle.cxx sw/source/ui/app/makefile.mk sw/source/ui/app/mn.src sw/source/ui/app/swmodul1.cxx sw/source/ui/cctrl/makefile.mk sw/source/ui/cctrl/swlbox.cxx sw/source/ui/chrdlg/break.cxx sw/source/ui/chrdlg/ccoll.cxx sw/source/ui/chrdlg/chardlg.cxx sw/source/ui/chrdlg/drpcps.cxx sw/source/ui/chrdlg/makefile.mk sw/source/ui/chrdlg/numpara.cxx sw/source/ui/chrdlg/pardlg.cxx sw/source/ui/chrdlg/swuiccoll.cxx sw/source/ui/config/barcfg.cxx sw/source/ui/config/caption.cxx sw/source/ui/config/cfgitems.cxx sw/source/ui/config/fontcfg.cxx sw/source/ui/config/mailconfigpage.cxx sw/source/ui/config/makefile.mk sw/source/ui/config/modcfg.cxx sw/source/ui/config/optcomp.cxx sw/source/ui/config/optload.cxx sw/source/ui/config/optpage.cxx sw/source/ui/config/prtopt.cxx sw/source/ui/config/uinums.cxx sw/source/ui/config/usrpref.cxx sw/source/ui/config/viewopt.cxx sw/source/ui/dbui/dbinsdlg.cxx sw/source/ui/dbui/dbmgr.cxx sw/source/ui/dbui/dbtree.cxx sw/source/ui/dbui/makefile.mk sw/source/ui/dbui/mmaddressblockpage.cxx sw/source/ui/dbui/mmdocselectpage.cxx sw/source/ui/dbui/mmoutputpage.cxx sw/source/ui/dbui/swdbtoolsclient.cxx sw/source/ui/dialog/abstract.cxx sw/source/ui/dialog/ascfldlg.cxx sw/source/ui/dialog/macassgn.cxx sw/source/ui/dialog/makefile.mk sw/source/ui/dialog/regionsw.cxx sw/source/ui/dialog/swdlgfact.cxx sw/source/ui/dialog/swdlgfact.hxx sw/source/ui/dialog/uiregionsw.cxx sw/source/ui/dochdl/gloshdl.cxx sw/source/ui/dochdl/makefile.mk sw/source/ui/dochdl/swdtflvr.cxx sw/source/ui/docvw/PostItMgr.cxx sw/source/ui/docvw/SidebarWin.cxx sw/source/ui/docvw/edtdd.cxx sw/source/ui/docvw/edtwin.cxx sw/source/ui/docvw/edtwin2.cxx sw/source/ui/docvw/edtwin3.cxx sw/source/ui/docvw/makefile.mk sw/source/ui/docvw/romenu.cxx sw/source/ui/docvw/romenu.hxx sw/source/ui/docvw/srcedtw.cxx sw/source/ui/envelp/envfmt.cxx sw/source/ui/envelp/envimg.cxx sw/source/ui/envelp/envlop1.cxx sw/source/ui/envelp/envprt.cxx sw/source/ui/envelp/label1.cxx sw/source/ui/envelp/labfmt.cxx sw/source/ui/envelp/labprt.cxx sw/source/ui/envelp/mailmrge.cxx sw/source/ui/envelp/makefile.mk sw/source/ui/fldui/flddb.cxx sw/source/ui/fldui/flddinf.cxx sw/source/ui/fldui/flddok.cxx sw/source/ui/fldui/fldedt.cxx sw/source/ui/fldui/fldfunc.cxx sw/source/ui/fldui/fldmgr.cxx sw/source/ui/fldui/fldpage.cxx sw/source/ui/fldui/fldref.cxx sw/source/ui/fldui/fldtdlg.cxx sw/source/ui/fldui/fldvar.cxx sw/source/ui/fldui/fldwrap.cxx sw/source/ui/fldui/inpdlg.cxx sw/source/ui/fldui/makefile.mk sw/source/ui/fmtui/makefile.mk sw/source/ui/fmtui/tmpdlg.cxx sw/source/ui/frmdlg/colmgr.cxx sw/source/ui/frmdlg/column.cxx sw/source/ui/frmdlg/cption.cxx sw/source/ui/frmdlg/frmdlg.cxx sw/source/ui/frmdlg/frmmgr.cxx sw/source/ui/frmdlg/frmpage.cxx sw/source/ui/frmdlg/makefile.mk sw/source/ui/frmdlg/wrap.cxx sw/source/ui/globdoc/makefile.mk sw/source/ui/inc/bmpwin.hxx sw/source/ui/inc/colmgr.hxx sw/source/ui/inc/column.hxx sw/source/ui/inc/envimg.hxx sw/source/ui/inc/envlop.hxx sw/source/ui/inc/frmpage.hxx sw/source/ui/inc/inputwin.hxx sw/source/ui/inc/javaedit.hxx sw/source/ui/inc/num.hxx sw/source/ui/inc/optpage.hxx sw/source/ui/inc/regionsw.hxx sw/source/ui/inc/split.hxx sw/source/ui/inc/swlbox.hxx sw/source/ui/inc/swmn_tmpl.hrc sw/source/ui/inc/swuiidxmrk.hxx sw/source/ui/inc/tabsh.hxx sw/source/ui/inc/toxmgr.hxx sw/source/ui/inc/uiitems.hxx sw/source/ui/inc/view.hxx sw/source/ui/inc/workctrl.hxx sw/source/ui/inc/wrap.hxx sw/source/ui/inc/wrtsh.hxx sw/source/ui/index/cnttab.cxx sw/source/ui/index/makefile.mk sw/source/ui/index/toxmgr.cxx sw/source/ui/lingu/hhcwrp.cxx sw/source/ui/lingu/makefile.mk sw/source/ui/lingu/olmenu.cxx sw/source/ui/misc/bookmark.cxx sw/source/ui/misc/docfnote.cxx sw/source/ui/misc/glosbib.cxx sw/source/ui/misc/glosdoc.cxx sw/source/ui/misc/glshell.cxx sw/source/ui/misc/insfnote.cxx sw/source/ui/misc/linenum.cxx sw/source/ui/misc/makefile.mk sw/source/ui/misc/num.cxx sw/source/ui/misc/numberingtypelistbox.cxx sw/source/ui/misc/outline.cxx sw/source/ui/misc/pgfnote.cxx sw/source/ui/misc/pggrid.cxx sw/source/ui/misc/redlndlg.cxx sw/source/ui/misc/srtdlg.cxx sw/source/ui/misc/swmodalredlineacceptdlg.cxx sw/source/ui/ribbar/conarc.cxx sw/source/ui/ribbar/drawbase.cxx sw/source/ui/ribbar/inputwin.cxx sw/source/ui/ribbar/inputwin.src sw/source/ui/ribbar/makefile.mk sw/source/ui/ribbar/tbxanchr.cxx sw/source/ui/ribbar/workctrl.cxx sw/source/ui/ribbar/workctrl.src sw/source/ui/shells/annotsh.cxx sw/source/ui/shells/basesh.cxx sw/source/ui/shells/beziersh.cxx sw/source/ui/shells/drawdlg.cxx sw/source/ui/shells/drwbassh.cxx sw/source/ui/shells/drwtxtex.cxx sw/source/ui/shells/drwtxtsh.cxx sw/source/ui/shells/frmsh.cxx sw/source/ui/shells/grfsh.cxx sw/source/ui/shells/grfshex.cxx sw/source/ui/shells/makefile.mk sw/source/ui/shells/tabsh.cxx sw/source/ui/shells/textfld.cxx sw/source/ui/shells/textglos.cxx sw/source/ui/shells/textsh.cxx sw/source/ui/shells/textsh1.cxx sw/source/ui/shells/txtattr.cxx sw/source/ui/shells/txtcrsr.cxx sw/source/ui/shells/txtnum.cxx sw/source/ui/table/convert.cxx sw/source/ui/table/instable.cxx sw/source/ui/table/makefile.mk sw/source/ui/table/swtablerep.cxx sw/source/ui/table/tabledlg.cxx sw/source/ui/table/tablemgr.cxx sw/source/ui/table/tablepg.hxx sw/source/ui/table/tautofmt.cxx sw/source/ui/uiview/formatclipboard.cxx sw/source/ui/uiview/makefile.mk sw/source/ui/uiview/pview.cxx sw/source/ui/uiview/pview.src sw/source/ui/uiview/scroll.cxx sw/source/ui/uiview/srcview.cxx sw/source/ui/uiview/swcli.cxx sw/source/ui/uiview/uivwimp.cxx sw/source/ui/uiview/view.cxx sw/source/ui/uiview/view1.cxx sw/source/ui/uiview/view2.cxx sw/source/ui/uiview/viewcoll.cxx sw/source/ui/uiview/viewdlg2.cxx sw/source/ui/uiview/viewling.cxx sw/source/ui/uiview/viewmdi.cxx sw/source/ui/uiview/viewport.cxx sw/source/ui/uiview/viewprt.cxx sw/source/ui/uiview/viewsrch.cxx sw/source/ui/uiview/viewtab.cxx sw/source/ui/uno/SwXDocumentSettings.cxx sw/source/ui/uno/SwXPrintPreviewSettings.cxx sw/source/ui/uno/SwXPrintPreviewSettings.hxx sw/source/ui/uno/unoatxt.cxx sw/source/ui/uno/unomod.cxx sw/source/ui/uno/unotxdoc.cxx sw/source/ui/uno/unotxvw.cxx sw/source/ui/utlui/attrdesc.cxx sw/source/ui/utlui/content.cxx sw/source/ui/utlui/glbltree.cxx sw/source/ui/utlui/initui.cxx sw/source/ui/utlui/makefile.mk sw/source/ui/utlui/navipi.cxx sw/source/ui/utlui/navipi.src sw/source/ui/utlui/numfmtlb.cxx sw/source/ui/utlui/prcntfld.cxx sw/source/ui/utlui/uiitems.cxx sw/source/ui/utlui/uitool.cxx sw/source/ui/utlui/unotools.cxx sw/source/ui/utlui/viewlayoutctrl.cxx sw/source/ui/utlui/zoomctrl.cxx sw/source/ui/vba/makefile.mk sw/source/ui/vba/service.cxx sw/source/ui/web/makefile.mk sw/source/ui/wrtsh/makefile.mk sw/source/ui/wrtsh/wrtsh1.cxx sw/source/ui/wrtsh/wrtsh2.cxx sw/source/ui/wrtsh/wrtsh4.cxx sw/source/ui/wrtsh/wrtundo.cxx sw/util/hidother.src sw/util/makefile.mk sw/util/msword.map
2011-03-14 16:51:14 +00:00
sal_uInt16 aRangeOfDefaults[] = {
RES_FRMATR_BEGIN, RES_FRMATR_END-1,
RES_CHRATR_BEGIN, RES_CHRATR_END-1,
RES_PARATR_BEGIN, RES_PARATR_END-1,
RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
0
};
SfxItemSet aNewDefaults( rTarget.GetAttrPool(), aRangeOfDefaults );
sal_uInt16 nWhich;
sal_uInt16 nRange = 0;
while( aRangeOfDefaults[nRange] != 0)
{
for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich )
{
const SfxPoolItem& rSourceAttr = rSource.GetDefault( nWhich );
if( rSourceAttr != rTarget.GetDefault( nWhich ) )
aNewDefaults.Put( rSourceAttr );
}
nRange += 2;
}
if( aNewDefaults.Count() )
rTarget.SetDefault( aNewDefaults );
}
2010-10-11 17:38:56 -05:00
void lcl_CopyFollowPageDesc(
SwWrtShell& rTargetShell,
const SwPageDesc& rSourcePageDesc,
const SwPageDesc& rTargetPageDesc,
const sal_uLong nDocNo )
{
//now copy the follow page desc, too
const SwPageDesc* pFollowPageDesc = rSourcePageDesc.GetFollow();
String sFollowPageDesc = pFollowPageDesc->GetName();
if( sFollowPageDesc != rSourcePageDesc.GetName() )
{
SwDoc* pTargetDoc = rTargetShell.GetDoc();
String sNewFollowPageDesc = lcl_FindUniqueName(&rTargetShell, sFollowPageDesc, nDocNo );
sal_uInt16 nNewDesc = pTargetDoc->MakePageDesc( sNewFollowPageDesc );
SwPageDesc& rTargetFollowPageDesc = pTargetDoc->GetPageDesc( nNewDesc );
pTargetDoc->CopyPageDesc( *pFollowPageDesc, rTargetFollowPageDesc, sal_False );
SwPageDesc aDesc( rTargetPageDesc );
aDesc.SetFollow( &rTargetFollowPageDesc );
pTargetDoc->ChgPageDesc( rTargetPageDesc.GetName(), aDesc );
}
}
2000-09-18 16:15:01 +00:00
void lcl_RemoveSectionLinks( SwWrtShell& rWorkShell )
{
//reset all links of the sections of synchronized labels
sal_uInt16 nSections = rWorkShell.GetSectionFmtCount();
for( sal_uInt16 nSection = 0; nSection < nSections; ++nSection )
{
SwSectionData aSectionData( *rWorkShell.GetSectionFmt( nSection ).GetSection() );
if( aSectionData.GetType() == FILE_LINK_SECTION )
{
aSectionData.SetType( CONTENT_SECTION );
aSectionData.SetLinkFileName( String() );
rWorkShell.UpdateSection( nSection, aSectionData );
}
}
rWorkShell.SetLabelDoc( sal_False );
}
sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
const SwMergeDescriptor& rMergeDescriptor)
2000-09-18 16:15:01 +00:00
{
//check if the doc is synchronized and contains at least one linked section
sal_Bool bSynchronizedDoc = pSourceShell->IsLabelDoc() && pSourceShell->GetSectionFmtCount() > 1;
sal_Bool bLoop = sal_True;
sal_Bool bEMail = rMergeDescriptor.nMergeType == DBMGR_MERGE_MAILING;
const bool bAsSingleFile = rMergeDescriptor.nMergeType == DBMGR_MERGE_SINGLE_FILE;
2000-09-18 16:15:01 +00:00
::rtl::Reference< MailDispatcher > xMailDispatcher;
::rtl::OUString sBodyMimeType;
rtl_TextEncoding eEncoding = ::osl_getThreadTextEncoding();
2000-09-18 16:15:01 +00:00
if(bEMail)
{
xMailDispatcher.set( new MailDispatcher(rMergeDescriptor.xSmtpServer));
if(!rMergeDescriptor.bSendAsAttachment && rMergeDescriptor.bSendAsHTML)
{
2010-10-27 11:38:46 +01:00
sBodyMimeType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("text/html; charset="));
sBodyMimeType += ::rtl::OUString::createFromAscii(
rtl_getBestMimeCharsetFromTextEncoding( eEncoding ));
2011-05-20 09:06:56 +01:00
SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
eEncoding = rHtmlOptions.GetTextEncoding();
2000-09-18 16:15:01 +00:00
}
else
sBodyMimeType =
2010-10-27 11:38:46 +01:00
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("text/plain; charset=UTF-8; format=flowed"));
2000-09-18 16:15:01 +00:00
}
uno::Reference< XPropertySet > xColumnProp;
2000-09-18 16:15:01 +00:00
{
sal_Bool bColumnName = sEMailAddrFld.Len() > 0;
2000-09-18 16:15:01 +00:00
if (bColumnName)
{
uno::Reference< XColumnsSupplier > xColsSupp( pImpl->pMergeData->xResultSet, UNO_QUERY );
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
2000-09-18 16:15:01 +00:00
if(!xCols->hasByName(sEMailAddrFld))
return sal_False;
2000-09-18 16:15:01 +00:00
Any aCol = xCols->getByName(sEMailAddrFld);
aCol >>= xColumnProp;
2000-09-18 16:15:01 +00:00
}
SfxDispatcher* pSfxDispatcher = pSourceShell->GetView().GetViewFrame()->GetDispatcher();
SwDocShell* pSourrceDocSh = pSourceShell->GetView().GetDocShell();
pSfxDispatcher->Execute( pSourrceDocSh->HasName() ? SID_SAVEDOC : SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
// has document been saved successfully?
if( !pSourrceDocSh->IsModified() )
2000-09-18 16:15:01 +00:00
{
SfxMedium* pOrig = pSourceShell->GetView().GetDocShell()->GetMedium();
String sSourceDocumentURL(pOrig->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ));
2000-09-18 16:15:01 +00:00
const SfxFilter* pSfxFlt = SwIoSystem::GetFileFilter(
sSourceDocumentURL, ::aEmptyStr );
const SfxFilter* pStoreToFilter = pSfxFlt;
SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
const String* pStoreToFilterOptions = 0;
// if a save_to filter is set then use it - otherwise use the default
if( bEMail && !rMergeDescriptor.bSendAsAttachment )
{
rtl::OUString sExtension = rMergeDescriptor.bSendAsHTML ? rtl::OUString("html") : rtl::OUString("txt");
pStoreToFilter = pFilterContainer->GetFilter4Extension(sExtension, SFX_FILTER_EXPORT);
}
else if( rMergeDescriptor.sSaveToFilter.Len())
{
const SfxFilter* pFilter =
pFilterContainer->GetFilter4FilterName( rMergeDescriptor.sSaveToFilter );
if(pFilter)
{
pStoreToFilter = pFilter;
if(rMergeDescriptor.sSaveToFilterOptions.Len())
pStoreToFilterOptions = &rMergeDescriptor.sSaveToFilterOptions;
}
}
bCancel = sal_False;
2000-09-18 16:15:01 +00:00
// in case of creating a single resulting file this has to be created here
SwWrtShell* pTargetShell = 0;
// the shell will be explicitly closed at the end of the method, but it is
// still more safe to use SfxObjectShellLock here
SfxObjectShellLock xTargetDocShell;
2009-09-01 08:22:04 +00:00
SwView* pTargetView = 0;
std::auto_ptr< utl::TempFile > aTempFile;
String sModifiedStartingPageDesc;
String sStartingPageDesc;
sal_uInt16 nStartingPageNo = 0;
bool bPageStylesWithHeaderFooter = false;
if(bAsSingleFile || rMergeDescriptor.bCreateSingleFile)
{
// create a target docshell to put the merged document into
xTargetDocShell = new SwDocShell( SFX_CREATE_MODE_STANDARD );
xTargetDocShell->DoInitNew( 0 );
SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
2009-09-01 08:22:04 +00:00
pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
//initiate SelectShell() to create sub shells
pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() );
pTargetShell = pTargetView->GetWrtShellPtr();
//copy the styles from the source to the target document
SwgReaderOption aOpt;
aOpt.SetTxtFmts( sal_True );
aOpt.SetFrmFmts( sal_True );
aOpt.SetPageDescs( sal_True );
aOpt.SetNumRules( sal_True );
aOpt.SetMerge( sal_False );
pTargetView->GetDocShell()->LoadStylesFromFile(
sSourceDocumentURL, aOpt, sal_True );
//determine the page style and number used at the start of the source document
pSourceShell->SttEndDoc(sal_True);
nStartingPageNo = pSourceShell->GetVirtPageNum();
sStartingPageDesc = sModifiedStartingPageDesc = pSourceShell->GetPageDesc(
pSourceShell->GetCurPageDesc()).GetName();
2011-02-25 22:33:34 +01:00
// copy compatibility options
lcl_CopyCompatibilityOptions( *pSourceShell, *pTargetShell);
// #72821# copy dynamic defaults
lcl_CopyDynamicDefaults( *pSourceShell->GetDoc(), *pTargetShell->GetDoc() );
// #i72517#
const SwPageDesc* pSourcePageDesc = pSourceShell->FindPageDescByName( sStartingPageDesc );
const SwFrmFmt& rMaster = pSourcePageDesc->GetMaster();
bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() ||
rMaster.GetFooter().IsActive();
}
2008-10-01 06:46:01 +00:00
PrintMonitor aPrtMonDlg(&pSourceShell->GetView().GetEditWin(), PrintMonitor::MONITOR_TYPE_PRINT);
aPrtMonDlg.aDocName.SetText(pSourceShell->GetView().GetDocShell()->GetTitle(22));
2000-09-18 16:15:01 +00:00
aPrtMonDlg.aCancel.SetClickHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
if (!IsMergeSilent())
aPrtMonDlg.Show();
2000-09-18 16:15:01 +00:00
// Progress, to prohibit KeyInputs
SfxProgress aProgress(pSourrceDocSh, ::aEmptyStr, 1);
2000-09-18 16:15:01 +00:00
2010-10-20 15:36:15 +01:00
// lock all dispatchers
SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst(pSourrceDocSh);
2000-09-18 16:15:01 +00:00
while (pViewFrm)
{
pViewFrm->GetDispatcher()->Lock(sal_True);
pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourrceDocSh);
2000-09-18 16:15:01 +00:00
}
sal_uLong nDocNo = 1;
2000-09-18 16:15:01 +00:00
long nStartRow, nEndRow;
// collect temporary files
::std::vector< String> aFilesToRemove;
do
{
nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
2000-09-18 16:15:01 +00:00
{
String sPath(sSubject);
String sAddress;
if( !bEMail && bColumnName )
2000-09-18 16:15:01 +00:00
{
SwDBFormatData aDBFormat;
aDBFormat.xFormatter = pImpl->pMergeData->xFormatter;
aDBFormat.aNullDate = pImpl->pMergeData->aNullDate;
2000-09-18 16:15:01 +00:00
sAddress = GetDBField( xColumnProp, aDBFormat);
if (!sAddress.Len())
sAddress = '_';
sPath += sAddress;
}
// create a new temporary file name - only done once in case of bCreateSingleFile
if( 1 == nDocNo || (!rMergeDescriptor.bCreateSingleFile && !bAsSingleFile) )
{
INetURLObject aEntry(sPath);
String sLeading;
//#i97667# if the name is from a database field then it will be used _as is_
if( sAddress.Len() )
sLeading = sAddress;
else
sLeading = aEntry.GetBase();
aEntry.removeSegment();
sPath = aEntry.GetMainURL( INetURLObject::NO_DECODE );
String sExt(comphelper::string::stripStart(pStoreToFilter->GetDefaultExtension(), '*'));
aTempFile = std::auto_ptr< utl::TempFile >(
new utl::TempFile(sLeading,&sExt,&sPath ));
if( bAsSingleFile )
aTempFile->EnableKillingFile();
}
2000-09-18 16:15:01 +00:00
if( !aTempFile->IsValid() )
2000-09-18 16:15:01 +00:00
{
ErrorHandler::HandleError( ERRCODE_IO_NOTSUPPORTED );
bLoop = sal_False;
bCancel = sal_True;
2000-09-18 16:15:01 +00:00
}
else
{
INetURLObject aTempFileURL(aTempFile->GetURL());
aPrtMonDlg.aPrinter.SetText( aTempFileURL.GetBase() );
2000-09-18 16:15:01 +00:00
String sStat(SW_RES(STR_STATSTR_LETTER)); // Brief
sStat += ' ';
sStat += String::CreateFromInt32( nDocNo );
2000-09-18 16:15:01 +00:00
aPrtMonDlg.aPrintInfo.SetText(sStat);
// computation time for Save-Monitor:
for (sal_uInt16 i = 0; i < 10; i++)
2000-09-18 16:15:01 +00:00
Application::Reschedule();
// Create and save new document
// The SfxObjectShell will be closed explicitly later but it is more safe to use SfxObjectShellLock here
SfxObjectShellLock xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
SfxMedium* pWorkMed = new SfxMedium( sSourceDocumentURL, STREAM_STD_READ );
pWorkMed->SetFilter( pSfxFlt );
2000-09-18 16:15:01 +00:00
if (xWorkDocSh->DoLoad(pWorkMed))
2000-09-18 16:15:01 +00:00
{
//create a view frame for the document
SfxViewFrame* pWorkFrame = SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 );
//request the layout calculation
SwWrtShell& rWorkShell =
static_cast< SwView* >(pWorkFrame->GetViewShell())->GetWrtShell();
rWorkShell.CalcLayout();
SwDoc* pWorkDoc = ((SwDocShell*)(&xWorkDocSh))->GetDoc();
SwNewDBMgr* pOldDBMgr = pWorkDoc->GetNewDBMgr();
pWorkDoc->SetNewDBMgr( this );
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), xWorkDocSh));
pWorkDoc->UpdateFlds(NULL, false);
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), xWorkDocSh));
2000-09-18 16:15:01 +00:00
pWorkDoc->RemoveInvisibleContent();
2000-09-18 16:15:01 +00:00
// launch MailMergeEvent if required
const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc();
if(pEvtSrc)
{
uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc );
text::MailMergeEvent aEvt( xRef, xWorkDocSh->GetModel() );
pEvtSrc->LaunchMailMergeEvent( aEvt );
}
if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile )
{
2010-10-20 15:36:15 +01:00
OSL_ENSURE( pTargetShell, "no target shell available!" );
// copy created file into the target document
rWorkShell.ConvertFieldsToText();
rWorkShell.SetNumberingRestart();
if( bSynchronizedDoc )
{
lcl_RemoveSectionLinks( rWorkShell );
}
// insert the document into the target document
rWorkShell.SttEndDoc(sal_False);
rWorkShell.SttEndDoc(sal_True);
rWorkShell.SelAll();
pTargetShell->SwCrsrShell::SttEndDoc( sal_False );
//#i72517# the headers and footers are still those from the source - update in case of fields inside header/footer
if( !nDocNo && bPageStylesWithHeaderFooter )
pTargetShell->GetView().GetDocShell()->_LoadStyles( *rWorkShell.GetView().GetDocShell(), sal_True );
//#i72517# put the styles to the target document
//if the source uses headers or footers each new copy need to copy a new page styles
if(bPageStylesWithHeaderFooter)
{
//create a new pagestyle
//copy the pagedesc from the current document to the new document and change the name of the to-be-applied style
SwDoc* pTargetDoc = pTargetShell->GetDoc();
SwPageDesc* pSourcePageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc );
String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
pTargetDoc->MakePageDesc( sNewPageDescName );
SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
if(pSourcePageDesc && pTargetPageDesc)
{
pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, sal_False );
sModifiedStartingPageDesc = sNewPageDescName;
lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo );
}
}
if(nDocNo > 1)
pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
else
pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
2010-10-20 15:36:15 +01:00
OSL_ENSURE(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
//#i51359# add a second paragraph in case there's only one
{
SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
SwPosition aTestPos( aIdx );
SwCursor aTestCrsr(aTestPos,0,false);
if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
{
//append a paragraph
pWorkDoc->AppendTxtNode( aTestPos );
}
}
pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
//convert fields in page styles (header/footer - has to be done after the first document has been pasted
if(1 == nDocNo)
{
pTargetShell->CalcLayout();
pTargetShell->ConvertFieldsToText();
}
}
else
2000-09-18 16:15:01 +00:00
{
String sFileURL = aTempFileURL.GetMainURL( INetURLObject::NO_DECODE );
SfxMedium* pDstMed = new SfxMedium(
sFileURL,
STREAM_STD_READWRITE );
pDstMed->SetFilter( pStoreToFilter );
if(pDstMed->GetItemSet())
{
if(pStoreToFilterOptions )
pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions));
if(rMergeDescriptor.aSaveToFilterData.getLength())
pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData)));
}
CWS-TOOLING: integrate CWS os121 2008-11-28 13:44:51 +0100 os r264551 : Copy Hyperlink Location added 2008-11-28 13:36:20 +0100 os r264547 : Copy Hyperlink Location added 2008-11-25 15:43:53 +0100 os r264311 : label of EditHyperlink fixed 2008-11-25 15:42:42 +0100 os r264310 : use ResetAttr to remove hyperlink 2008-11-25 10:08:02 +0100 os r264276 : edit/remove hyperlink names fixed 2008-11-11 15:47:22 +0100 os r263565 : typo fixed 2008-11-10 18:46:00 +0100 os r263536 : CWS-TOOLING: rebase CWS os121 to trunk@263288 (milestone: DEV300:m35) 2008-11-07 15:34:41 +0100 os r263422 : #i6191# accept/reject changes;#i7311# remove hyperlink 2008-11-07 15:34:05 +0100 os r263421 : #i6191# accept/reject changes;#i7311# remove hyperlink 2008-11-06 17:26:18 +0100 os r263402 : #i43971# words from online help documents must not be added to AutoCompletion 2008-11-06 16:08:27 +0100 os r263397 : #i6191# accept/reject changes added to context menu 2008-11-06 16:07:49 +0100 os r263396 : #i6191# accept/reject changes added to context menu 2008-11-06 16:07:16 +0100 os r263395 : #i6191# accept/reject changes added to context menu 2008-11-06 16:06:18 +0100 os r263394 : #i6191# accept/reject changes added to context menu 2008-10-30 14:31:32 +0100 os r262826 : #i84980# less options changed to fewer options 2008-10-30 11:44:41 +0100 os r262824 : #i95624# don't add paragraph numbering in getString() 2008-10-27 10:46:04 +0100 os r262665 : #i88235# SvCheckListBox::SelectEntryPos() paints a CheckBox to the wrong device if page is not visible, yet - call moved to ::Reset() 2008-10-24 15:49:27 +0200 os r262648 : #i77230# make repeating headers the default 2008-10-23 16:49:42 +0200 os r262625 : #i95350# RTL output of table window fixed 2008-10-23 15:37:40 +0200 os r262623 : #i76723# RTL related patch removed - it is now done by vcl 2008-10-22 14:05:58 +0200 os r262601 : #b6297019#,#i49754# LoadStyles: restore outline settings 2008-10-22 14:05:17 +0200 os r262600 : #b6297019#,#i49754# LoadStyles: restore outline settings 2008-10-20 15:39:18 +0200 os r262323 : #i95059# border attribute: which id of SID_ATTR_BORDER_INNER fixed 2008-10-20 09:30:28 +0200 os r262305 : #i95123# conflict css::util::Color and ::Color solved 2008-10-17 11:44:16 +0200 os r262280 : #i93714# merge to PDF: convert fields to text before export 2008-10-17 10:30:11 +0200 os r262275 : #i94364# 2008-10-17 10:11:56 +0200 os r262274 : +i94536# default font ListBoxes: prevent entry duplication if 'Back' button is pressed
2008-12-09 07:49:49 +00:00
//convert fields to text if we are exporting to PDF
//this prevents a second merge while updating the fields in SwXTextDocument::getRendererCount()
if( pStoreToFilter && pStoreToFilter->GetFilterName().EqualsAscii("writer_pdf_Export"))
rWorkShell.ConvertFieldsToText();
xWorkDocSh->DoSaveAs(*pDstMed);
xWorkDocSh->DoSaveCompleted(pDstMed);
if( xWorkDocSh->GetError() )
{
// error message ??
ErrorHandler::HandleError( xWorkDocSh->GetError() );
bCancel = sal_True;
bLoop = sal_False;
}
if( bEMail )
{
SwDBFormatData aDBFormat;
aDBFormat.xFormatter = pImpl->pMergeData->xFormatter;
aDBFormat.aNullDate = pImpl->pMergeData->aNullDate;
String sMailAddress = GetDBField( xColumnProp, aDBFormat);
if(!SwMailMergeHelper::CheckMailAddress( sMailAddress ))
{
OSL_FAIL("invalid e-Mail address in database column");
}
else
{
2010-11-24 09:26:00 +00:00
SwMailMessage* pMessage = new SwMailMessage;
uno::Reference< mail::XMailMessage > xMessage = pMessage;
if(rMergeDescriptor.pMailMergeConfigItem->IsMailReplyTo())
pMessage->setReplyToAddress(rMergeDescriptor.pMailMergeConfigItem->GetMailReplyTo());
pMessage->addRecipient( sMailAddress );
pMessage->SetSenderAddress( rMergeDescriptor.pMailMergeConfigItem->GetMailAddress() );
::rtl::OUString sBody;
if(rMergeDescriptor.bSendAsAttachment)
{
sBody = rMergeDescriptor.sMailBody;
mail::MailAttachment aAttach;
aAttach.Data = new SwMailTransferable(
sFileURL,
rMergeDescriptor.sAttachmentName,
pStoreToFilter->GetMimeType());
aAttach.ReadableName = rMergeDescriptor.sAttachmentName;
pMessage->addAttachment( aAttach );
}
else
{
{
//read in the temporary file and use it as mail body
SfxMedium aMedium( sFileURL, STREAM_READ);
SvStream* pInStream = aMedium.GetInStream();
2010-10-20 15:36:15 +01:00
OSL_ENSURE(pInStream, "no output file created?");
if(pInStream)
{
pInStream->SetStreamCharSet( eEncoding );
2011-11-01 22:38:51 +00:00
rtl::OString sLine;
sal_Bool bDone = pInStream->ReadLine( sLine );
while ( bDone )
{
sBody += rtl::OStringToOUString(sLine, eEncoding);
sBody += ::rtl::OUString('\n');
bDone = pInStream->ReadLine( sLine );
}
}
}
}
pMessage->setSubject( rMergeDescriptor.sSubject );
uno::Reference< datatransfer::XTransferable> xBody =
new SwMailTransferable(
sBody,
sBodyMimeType);
pMessage->setBody( xBody );
if(rMergeDescriptor.aCopiesTo.getLength())
{
const ::rtl::OUString* pCopies = rMergeDescriptor.aCopiesTo.getConstArray();
for( sal_Int32 nToken = 0; nToken < rMergeDescriptor.aCopiesTo.getLength(); ++nToken)
pMessage->addCcRecipient( pCopies[nToken] );
}
if(rMergeDescriptor.aBlindCopiesTo.getLength())
{
const ::rtl::OUString* pCopies = rMergeDescriptor.aBlindCopiesTo.getConstArray();
for( sal_Int32 nToken = 0; nToken < rMergeDescriptor.aBlindCopiesTo.getLength(); ++nToken)
pMessage->addBccRecipient( pCopies[nToken] );
}
xMailDispatcher->enqueueMailMessage( xMessage );
if(!xMailDispatcher->isStarted())
xMailDispatcher->start();
//schedule for removal
aFilesToRemove.push_back(sFileURL);
}
}
2000-09-18 16:15:01 +00:00
}
pWorkDoc->SetNewDBMgr( pOldDBMgr );
2000-09-18 16:15:01 +00:00
}
xWorkDocSh->DoClose();
2000-09-18 16:15:01 +00:00
}
}
nDocNo++;
nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
} while( !bCancel &&
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
aPrtMonDlg.Show( sal_False );
// save the single output document
if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile)
{
2009-09-01 08:22:04 +00:00
if( rMergeDescriptor.nMergeType != DBMGR_MERGE_MAILMERGE )
{
2010-10-20 15:36:15 +01:00
OSL_ENSURE( aTempFile.get(), "Temporary file not available" );
2009-09-01 08:22:04 +00:00
INetURLObject aTempFileURL(bAsSingleFile ? sSubject : aTempFile->GetURL());
SfxMedium* pDstMed = new SfxMedium(
aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ),
STREAM_STD_READWRITE );
2009-09-01 08:22:04 +00:00
pDstMed->SetFilter( pStoreToFilter );
if(pDstMed->GetItemSet())
{
if(pStoreToFilterOptions )
pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions));
if(rMergeDescriptor.aSaveToFilterData.getLength())
pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData)));
}
2009-09-01 08:22:04 +00:00
xTargetDocShell->DoSaveAs(*pDstMed);
xTargetDocShell->DoSaveCompleted(pDstMed);
if( xTargetDocShell->GetError() )
{
// error message ??
ErrorHandler::HandleError( xTargetDocShell->GetError() );
bLoop = sal_False;
2009-09-01 08:22:04 +00:00
}
}
else if( pTargetView ) // must be available!
{
2009-09-01 08:22:04 +00:00
//print the target document
#if OSL_DEBUG_LEVEL > 1
sal_Bool _bVal;
sal_Int16 _nVal;
rtl::OUString _sVal;
const beans::PropertyValue* pDbgPrintOptions = rMergeDescriptor.aPrintOptions.getConstArray();
for( sal_Int32 nOption = 0; nOption < rMergeDescriptor.aPrintOptions.getLength(); ++nOption)
{
rtl::OUString aName( pDbgPrintOptions[nOption].Name );
uno::Any aVal( pDbgPrintOptions[nOption].Value );
aVal >>= _bVal;
aVal >>= _nVal;
aVal >>= _sVal;
}
#endif
// printing should be done synchronously otherwise the document
// might already become invalid during the process
uno::Sequence< beans::PropertyValue > aOptions( rMergeDescriptor.aPrintOptions );
const sal_Int32 nOpts = aOptions.getLength();
aOptions.realloc( nOpts + 1 );
2010-10-27 11:38:46 +01:00
aOptions[ nOpts ].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Wait"));
2009-09-01 08:22:04 +00:00
aOptions[ nOpts ].Value <<= sal_True ;
// move print options
const beans::PropertyValue* pPrintOptions = rMergeDescriptor.aPrintOptions.getConstArray();
for( sal_Int32 nOption = 0; nOption < rMergeDescriptor.aPrintOptions.getLength(); ++nOption)
{
if( pPrintOptions[nOption].Name == "CopyCount" || pPrintOptions[nOption].Name == "FileName"
|| pPrintOptions[nOption].Name == "Collate" || pPrintOptions[nOption].Name == "Pages"
|| pPrintOptions[nOption].Name == "Wait" )
2009-09-01 08:22:04 +00:00
{
aOptions.realloc( nOpts + 1 );
aOptions[ nOpts ].Name = pPrintOptions[nOption].Name;
aOptions[ nOpts ].Value = pPrintOptions[nOption].Value ;
}
}
pTargetView->ExecPrint( aOptions, IsMergeSilent(), rMergeDescriptor.bPrintAsync );
}
xTargetDocShell->DoClose();
}
//remove the temporary files
::std::vector<String>::iterator aFileIter;
for(aFileIter = aFilesToRemove.begin();
2011-05-16 19:45:52 +02:00
aFileIter != aFilesToRemove.end(); ++aFileIter)
SWUnoHelper::UCB_DeleteFile( *aFileIter );
2010-10-20 15:36:15 +01:00
// unlock all dispatchers
pViewFrm = SfxViewFrame::GetFirst(pSourrceDocSh);
2000-09-18 16:15:01 +00:00
while (pViewFrm)
{
pViewFrm->GetDispatcher()->Lock(sal_False);
pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourrceDocSh);
2000-09-18 16:15:01 +00:00
}
SW_MOD()->SetView(&pSourceShell->GetView());
2000-09-18 16:15:01 +00:00
}
nMergeType = DBMGR_INSERT;
}
if(bEMail)
{
xMailDispatcher->stop();
xMailDispatcher->shutdown();
}
2000-09-18 16:15:01 +00:00
return bLoop;
}
IMPL_LINK_INLINE_START( SwNewDBMgr, PrtCancelHdl, Button *, pButton )
{
pButton->GetParent()->Hide();
bCancel = sal_True;
2000-09-18 16:15:01 +00:00
return 0;
}
IMPL_LINK_INLINE_END( SwNewDBMgr, PrtCancelHdl, Button *, pButton )
/*--------------------------------------------------------------------
Description: determine the column's Numberformat and transfer
to the forwarded Formatter, if applicable.
2000-09-18 16:15:01 +00:00
--------------------------------------------------------------------*/
sal_uLong SwNewDBMgr::GetColumnFmt( const String& rDBName,
2000-09-18 16:15:01 +00:00
const String& rTableName,
const String& rColNm,
SvNumberFormatter* pNFmtr,
long nLanguage )
{
sal_uLong nRet = 0;
2000-09-18 16:15:01 +00:00
if(pNFmtr)
{
uno::Reference< XDataSource> xSource;
uno::Reference< XConnection> xConnection;
sal_Bool bUseMergeData = sal_False;
uno::Reference< XColumnsSupplier> xColsSupp;
CWS-TOOLING: integrate CWS os132 2009-07-21 15:24:18 +0200 os r274201 : #i103696# SwXTextPortion/SwXParagraph excluded 2009-07-15 13:19:17 +0200 os r274007 : #i103564# typo 2009-07-15 13:09:30 +0200 os r274005 : #i103564# SwFrames::hasElements 2009-07-15 13:02:16 +0200 os r274003 : #i103564# SwXBookmark::getPropertySetInfo fixed 2009-06-26 10:11:00 +0200 os r273395 : CWS-TOOLING: rebase CWS os132 to trunk@272827 (milestone: DEV300:m50) 2009-06-23 08:52:24 +0200 os r273256 : #i102764# patch: attribute ListBoxes correctly handled in ::Reset() 2009-06-23 08:51:31 +0200 os r273255 : #i102764# ResetColor() added to remove background color 2009-06-22 14:57:38 +0200 os r273233 : #i102619# prevent access to already destroyed shell 2009-06-18 13:26:51 +0200 os r273112 : #i99508# ::insertTextContent: re-route to ::attach() 2009-06-18 10:59:53 +0200 os r273107 : #i85405# patch to enable 'Print grid' CheckBox correctly 2009-06-18 10:54:02 +0200 os r273106 : #i85133# dispose connection in GetColumnFmt to prevent connection locking 2009-06-18 10:24:31 +0200 os r273104 : #99535# ExportGraphic changed 2009-06-18 10:24:03 +0200 os r273103 : #99535# ExportGraphic changed 2009-06-18 10:23:11 +0200 os r273102 : #i102841# redlining mode switches to insert mode (cmc) 2009-06-17 14:05:42 +0200 os r273070 : #i102111# do not save already saved HTML documents before switching to source veiw 2009-06-17 13:18:20 +0200 os r273063 : #i101825# set rembered start position at the real start not at the initial start 2009-06-17 08:24:10 +0200 os r273048 : #99535# no dierect access to the file picker interface 2009-06-16 15:00:12 +0200 os r273020 : #i99937# notification of user options changes re-introduced 2009-06-15 14:36:03 +0200 os r272987 : #i98032# unreplaced text in protected areas must not be attributed either 2009-06-15 14:20:26 +0200 os r272985 : #i98032# replace list has to be initialised 2009-06-04 13:29:02 +0200 os r272624 : #i97810# set focus into column page 2009-06-04 11:01:14 +0200 os r272617 : #i98164# dialog resize to ease localisation 2009-06-04 10:59:44 +0200 os r272616 : #i98164# dialog resize to ease localisation 2009-05-28 16:05:03 +0200 os r272413 : #i98172# ConvertFieldsToText: take care of tabs with attributes 2009-05-28 11:12:45 +0200 os r272385 : #i59361# dialog controls resized 2009-05-28 11:03:14 +0200 os r272383 : #i59174# dialog controls moved
2009-08-06 12:44:16 +00:00
bool bDisposeConnection = false;
if(pImpl->pMergeData &&
pImpl->pMergeData->sDataSource.equals(rDBName) && pImpl->pMergeData->sCommand.equals(rTableName))
{
xConnection = pImpl->pMergeData->xConnection;
xSource = SwNewDBMgr::getDataSourceAsParent(xConnection,rDBName);
bUseMergeData = sal_True;
xColsSupp = xColsSupp.query( pImpl->pMergeData->xResultSet );
}
if(!xConnection.is())
{
SwDBData aData;
aData.sDataSource = rDBName;
aData.sCommand = rTableName;
aData.nCommandType = -1;
SwDSParam* pParam = FindDSData(aData, sal_False);
if(pParam && pParam->xConnection.is())
{
xConnection = pParam->xConnection;
xColsSupp = xColsSupp.query( pParam->xResultSet );
}
else
2002-10-24 12:48:08 +00:00
{
rtl::OUString sDBName(rDBName);
xConnection = RegisterConnection( sDBName );
CWS-TOOLING: integrate CWS os132 2009-07-21 15:24:18 +0200 os r274201 : #i103696# SwXTextPortion/SwXParagraph excluded 2009-07-15 13:19:17 +0200 os r274007 : #i103564# typo 2009-07-15 13:09:30 +0200 os r274005 : #i103564# SwFrames::hasElements 2009-07-15 13:02:16 +0200 os r274003 : #i103564# SwXBookmark::getPropertySetInfo fixed 2009-06-26 10:11:00 +0200 os r273395 : CWS-TOOLING: rebase CWS os132 to trunk@272827 (milestone: DEV300:m50) 2009-06-23 08:52:24 +0200 os r273256 : #i102764# patch: attribute ListBoxes correctly handled in ::Reset() 2009-06-23 08:51:31 +0200 os r273255 : #i102764# ResetColor() added to remove background color 2009-06-22 14:57:38 +0200 os r273233 : #i102619# prevent access to already destroyed shell 2009-06-18 13:26:51 +0200 os r273112 : #i99508# ::insertTextContent: re-route to ::attach() 2009-06-18 10:59:53 +0200 os r273107 : #i85405# patch to enable 'Print grid' CheckBox correctly 2009-06-18 10:54:02 +0200 os r273106 : #i85133# dispose connection in GetColumnFmt to prevent connection locking 2009-06-18 10:24:31 +0200 os r273104 : #99535# ExportGraphic changed 2009-06-18 10:24:03 +0200 os r273103 : #99535# ExportGraphic changed 2009-06-18 10:23:11 +0200 os r273102 : #i102841# redlining mode switches to insert mode (cmc) 2009-06-17 14:05:42 +0200 os r273070 : #i102111# do not save already saved HTML documents before switching to source veiw 2009-06-17 13:18:20 +0200 os r273063 : #i101825# set rembered start position at the real start not at the initial start 2009-06-17 08:24:10 +0200 os r273048 : #99535# no dierect access to the file picker interface 2009-06-16 15:00:12 +0200 os r273020 : #i99937# notification of user options changes re-introduced 2009-06-15 14:36:03 +0200 os r272987 : #i98032# unreplaced text in protected areas must not be attributed either 2009-06-15 14:20:26 +0200 os r272985 : #i98032# replace list has to be initialised 2009-06-04 13:29:02 +0200 os r272624 : #i97810# set focus into column page 2009-06-04 11:01:14 +0200 os r272617 : #i98164# dialog resize to ease localisation 2009-06-04 10:59:44 +0200 os r272616 : #i98164# dialog resize to ease localisation 2009-05-28 16:05:03 +0200 os r272413 : #i98172# ConvertFieldsToText: take care of tabs with attributes 2009-05-28 11:12:45 +0200 os r272385 : #i59361# dialog controls resized 2009-05-28 11:03:14 +0200 os r272383 : #i59174# dialog controls moved
2009-08-06 12:44:16 +00:00
bDisposeConnection = true;
2002-10-24 12:48:08 +00:00
}
if(bUseMergeData)
pImpl->pMergeData->xConnection = xConnection;
}
bool bDispose = !xColsSupp.is();
if(bDispose)
{
xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
}
if(xColsSupp.is())
{
uno::Reference<XNameAccess> xCols;
try
{
xCols = xColsSupp->getColumns();
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
OSL_FAIL("Exception in getColumns()");
}
2001-07-20 09:07:05 +00:00
if(!xCols.is() || !xCols->hasByName(rColNm))
return nRet;
Any aCol = xCols->getByName(rColNm);
uno::Reference< XPropertySet > xColumn;
aCol >>= xColumn;
nRet = GetColumnFmt(xSource, xConnection, xColumn, pNFmtr, nLanguage);
if(bDispose)
{
::comphelper::disposeComponent( xColsSupp );
}
CWS-TOOLING: integrate CWS os132 2009-07-21 15:24:18 +0200 os r274201 : #i103696# SwXTextPortion/SwXParagraph excluded 2009-07-15 13:19:17 +0200 os r274007 : #i103564# typo 2009-07-15 13:09:30 +0200 os r274005 : #i103564# SwFrames::hasElements 2009-07-15 13:02:16 +0200 os r274003 : #i103564# SwXBookmark::getPropertySetInfo fixed 2009-06-26 10:11:00 +0200 os r273395 : CWS-TOOLING: rebase CWS os132 to trunk@272827 (milestone: DEV300:m50) 2009-06-23 08:52:24 +0200 os r273256 : #i102764# patch: attribute ListBoxes correctly handled in ::Reset() 2009-06-23 08:51:31 +0200 os r273255 : #i102764# ResetColor() added to remove background color 2009-06-22 14:57:38 +0200 os r273233 : #i102619# prevent access to already destroyed shell 2009-06-18 13:26:51 +0200 os r273112 : #i99508# ::insertTextContent: re-route to ::attach() 2009-06-18 10:59:53 +0200 os r273107 : #i85405# patch to enable 'Print grid' CheckBox correctly 2009-06-18 10:54:02 +0200 os r273106 : #i85133# dispose connection in GetColumnFmt to prevent connection locking 2009-06-18 10:24:31 +0200 os r273104 : #99535# ExportGraphic changed 2009-06-18 10:24:03 +0200 os r273103 : #99535# ExportGraphic changed 2009-06-18 10:23:11 +0200 os r273102 : #i102841# redlining mode switches to insert mode (cmc) 2009-06-17 14:05:42 +0200 os r273070 : #i102111# do not save already saved HTML documents before switching to source veiw 2009-06-17 13:18:20 +0200 os r273063 : #i101825# set rembered start position at the real start not at the initial start 2009-06-17 08:24:10 +0200 os r273048 : #99535# no dierect access to the file picker interface 2009-06-16 15:00:12 +0200 os r273020 : #i99937# notification of user options changes re-introduced 2009-06-15 14:36:03 +0200 os r272987 : #i98032# unreplaced text in protected areas must not be attributed either 2009-06-15 14:20:26 +0200 os r272985 : #i98032# replace list has to be initialised 2009-06-04 13:29:02 +0200 os r272624 : #i97810# set focus into column page 2009-06-04 11:01:14 +0200 os r272617 : #i98164# dialog resize to ease localisation 2009-06-04 10:59:44 +0200 os r272616 : #i98164# dialog resize to ease localisation 2009-05-28 16:05:03 +0200 os r272413 : #i98172# ConvertFieldsToText: take care of tabs with attributes 2009-05-28 11:12:45 +0200 os r272385 : #i59361# dialog controls resized 2009-05-28 11:03:14 +0200 os r272383 : #i59174# dialog controls moved
2009-08-06 12:44:16 +00:00
if(bDisposeConnection)
{
::comphelper::disposeComponent( xConnection );
}
}
else
nRet = pNFmtr->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM );
}
return nRet;
}
sal_uLong SwNewDBMgr::GetColumnFmt( uno::Reference< XDataSource> xSource,
uno::Reference< XConnection> xConnection,
uno::Reference< XPropertySet> xColumn,
SvNumberFormatter* pNFmtr,
long nLanguage )
{
2011-02-25 22:33:34 +01:00
// set the NumberFormat in the doc if applicable
sal_uLong nRet = 0;
if(!xSource.is())
{
uno::Reference<XChild> xChild(xConnection, UNO_QUERY);
if ( xChild.is() )
xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
}
if(xSource.is() && xConnection.is() && xColumn.is() && pNFmtr)
2000-09-18 16:15:01 +00:00
{
SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj( pNFmtr );
uno::Reference< util::XNumberFormatsSupplier > xDocNumFmtsSupplier = pNumFmt;
uno::Reference< XNumberFormats > xDocNumberFormats = xDocNumFmtsSupplier->getNumberFormats();
uno::Reference< XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
2000-09-18 16:15:01 +00:00
com::sun::star::lang::Locale aLocale( MsLangId::convertLanguageToLocale( (LanguageType)nLanguage ));
2000-09-18 16:15:01 +00:00
//get the number formatter of the data source
uno::Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
uno::Reference< XNumberFormats > xNumberFormats;
2000-09-18 16:15:01 +00:00
if(xSourceProps.is())
{
Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
if(aFormats.hasValue())
{
uno::Reference<XNumberFormatsSupplier> xSuppl;
aFormats >>= xSuppl;
2000-09-18 16:15:01 +00:00
if(xSuppl.is())
{
xNumberFormats = xSuppl->getNumberFormats();
}
}
}
bool bUseDefault = true;
try
2000-09-18 16:15:01 +00:00
{
Any aFormatKey = xColumn->getPropertyValue(C2U("FormatKey"));
if(aFormatKey.hasValue())
2000-09-18 16:15:01 +00:00
{
sal_Int32 nFmt = 0;
aFormatKey >>= nFmt;
if(xNumberFormats.is())
{
try
{
uno::Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFmt );
Any aFormatString = xNumProps->getPropertyValue(C2U("FormatString"));
Any aLocaleVal = xNumProps->getPropertyValue(C2U("Locale"));
rtl::OUString sFormat;
aFormatString >>= sFormat;
lang::Locale aLoc;
aLocaleVal >>= aLoc;
nFmt = xDocNumberFormats->queryKey( sFormat, aLoc, sal_False );
if(NUMBERFORMAT_ENTRY_NOT_FOUND == sal::static_int_cast< sal_uInt32, sal_Int32>(nFmt))
nFmt = xDocNumberFormats->addNew( sFormat, aLoc );
nRet = nFmt;
bUseDefault = false;
}
catch(const Exception&)
{
OSL_FAIL("illegal number format key");
}
2000-09-18 16:15:01 +00:00
}
}
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
OSL_FAIL("no FormatKey property found");
}
if(bUseDefault)
nRet = SwNewDBMgr::GetDbtoolsClient().getDefaultNumberFormat(xColumn, xDocNumberFormatTypes, aLocale);
2000-09-18 16:15:01 +00:00
}
return nRet;
}
2000-09-18 16:15:01 +00:00
sal_Int32 SwNewDBMgr::GetColumnType( const String& rDBName,
const String& rTableName,
const String& rColNm )
{
sal_Int32 nRet = DataType::SQLNULL;
SwDBData aData;
aData.sDataSource = rDBName;
aData.sCommand = rTableName;
aData.nCommandType = -1;
SwDSParam* pParam = FindDSData(aData, sal_False);
uno::Reference< XConnection> xConnection;
uno::Reference< XColumnsSupplier > xColsSupp;
bool bDispose = false;
if(pParam && pParam->xConnection.is())
{
xConnection = pParam->xConnection;
xColsSupp = uno::Reference< XColumnsSupplier >( pParam->xResultSet, UNO_QUERY );
}
else
2002-10-24 12:48:08 +00:00
{
rtl::OUString sDBName(rDBName);
xConnection = RegisterConnection( sDBName );
}
if( !xColsSupp.is() )
{
xColsSupp = SwNewDBMgr::GetColumnSupplier(xConnection, rTableName);
bDispose = true;
}
2000-09-18 16:15:01 +00:00
if(xColsSupp.is())
{
uno::Reference<XNameAccess> xCols = xColsSupp->getColumns();
2000-09-18 16:15:01 +00:00
if(xCols->hasByName(rColNm))
{
Any aCol = xCols->getByName(rColNm);
uno::Reference<XPropertySet> xCol;
aCol >>= xCol;
Any aType = xCol->getPropertyValue(rtl::OUString("Type"));
2000-09-18 16:15:01 +00:00
aType >>= nRet;
}
if(bDispose)
::comphelper::disposeComponent( xColsSupp );
2000-09-18 16:15:01 +00:00
}
return nRet;
}
uno::Reference< sdbc::XConnection> SwNewDBMgr::GetConnection(const String& rDataSource,
uno::Reference<XDataSource>& rxSource)
2000-09-18 16:15:01 +00:00
{
Reference< sdbc::XConnection> xConnection;
Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
try
2000-09-18 16:15:01 +00:00
{
Reference<XCompletedConnection> xComplConnection(SwNewDBMgr::GetDbtoolsClient().getDataSource(rDataSource, xContext),UNO_QUERY);
if ( xComplConnection.is() )
2000-09-18 16:15:01 +00:00
{
rxSource.set(xComplConnection,UNO_QUERY);
Reference< XInteractionHandler > xHandler( InteractionHandler::createWithParent(xContext, 0), UNO_QUERY_THROW );
xConnection = xComplConnection->connectWithCompletion( xHandler );
2000-09-18 16:15:01 +00:00
}
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
}
2000-09-18 16:15:01 +00:00
return xConnection;
}
uno::Reference< sdbcx::XColumnsSupplier> SwNewDBMgr::GetColumnSupplier(uno::Reference<sdbc::XConnection> xConnection,
2000-09-18 16:15:01 +00:00
const String& rTableOrQuery,
sal_uInt8 eTableOrQuery)
2000-09-18 16:15:01 +00:00
{
Reference< sdbcx::XColumnsSupplier> xRet;
try
2000-09-18 16:15:01 +00:00
{
if(eTableOrQuery == SW_DB_SELECT_UNKNOWN)
2000-09-18 16:15:01 +00:00
{
//search for a table with the given command name
Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
if(xTSupplier.is())
{
Reference<XNameAccess> xTbls = xTSupplier->getTables();
eTableOrQuery = xTbls->hasByName(rTableOrQuery) ?
SW_DB_SELECT_TABLE : SW_DB_SELECT_QUERY;
}
2000-09-18 16:15:01 +00:00
}
sal_Int32 nCommandType = SW_DB_SELECT_TABLE == eTableOrQuery ?
CommandType::TABLE : CommandType::QUERY;
Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
Reference<XRowSet> xRowSet(
xMgr->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY);
::rtl::OUString sDataSource;
Reference<XDataSource> xSource = SwNewDBMgr::getDataSourceAsParent(xConnection, sDataSource);
Reference<XPropertySet> xSourceProperties(xSource, UNO_QUERY);
if(xSourceProperties.is())
2000-09-18 16:15:01 +00:00
{
xSourceProperties->getPropertyValue(C2U("Name")) >>= sDataSource;
2000-09-18 16:15:01 +00:00
}
Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
xRowProperties->setPropertyValue(C2U("DataSourceName"), makeAny(sDataSource));
xRowProperties->setPropertyValue(C2U("Command"), makeAny(::rtl::OUString(rTableOrQuery)));
xRowProperties->setPropertyValue(C2U("CommandType"), makeAny(nCommandType));
xRowProperties->setPropertyValue(C2U("FetchSize"), makeAny((sal_Int32)10));
xRowProperties->setPropertyValue(C2U("ActiveConnection"), makeAny(xConnection));
xRowSet->execute();
xRet = Reference<XColumnsSupplier>( xRowSet, UNO_QUERY );
2000-09-18 16:15:01 +00:00
}
2011-06-15 23:56:45 +01:00
catch(const uno::Exception&)
{
OSL_FAIL("Exception in SwDBMgr::GetColumnSupplier");
}
2000-09-18 16:15:01 +00:00
return xRet;
}
String SwNewDBMgr::GetDBField(uno::Reference<XPropertySet> xColumnProps,
2000-09-18 16:15:01 +00:00
const SwDBFormatData& rDBFormatData,
double* pNumber)
{
uno::Reference< XColumn > xColumn(xColumnProps, UNO_QUERY);
2000-09-18 16:15:01 +00:00
String sRet;
2010-10-20 15:36:15 +01:00
OSL_ENSURE(xColumn.is(), "SwNewDBMgr::::ImportDBField: illegal arguments");
2000-09-18 16:15:01 +00:00
if(!xColumn.is())
return sRet;
Any aType = xColumnProps->getPropertyValue(C2U("Type"));
sal_Int32 eDataType = 0;
2000-09-18 16:15:01 +00:00
aType >>= eDataType;
switch(eDataType)
{
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
try
{
sRet = xColumn->getString();
}
2011-06-15 23:56:45 +01:00
catch(const SQLException&)
{
}
2000-09-18 16:15:01 +00:00
break;
case DataType::BIT:
case DataType::BOOLEAN:
2000-09-18 16:15:01 +00:00
case DataType::TINYINT:
case DataType::SMALLINT:
case DataType::INTEGER:
case DataType::BIGINT:
case DataType::FLOAT:
case DataType::REAL:
case DataType::DOUBLE:
case DataType::NUMERIC:
case DataType::DECIMAL:
case DataType::DATE:
case DataType::TIME:
case DataType::TIMESTAMP:
{
try
{
SwDbtoolsClient& aClient = SwNewDBMgr::GetDbtoolsClient();
sRet = aClient.getFormattedValue(
2000-09-18 16:15:01 +00:00
xColumnProps,
rDBFormatData.xFormatter,
rDBFormatData.aLocale,
rDBFormatData.aNullDate);
2000-09-18 16:15:01 +00:00
if (pNumber)
{
double fVal = xColumn->getDouble();
if(!xColumn->wasNull())
{
*pNumber = fVal;
}
}
2000-09-18 16:15:01 +00:00
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
2000-09-18 16:15:01 +00:00
{
OSL_FAIL("exception caught");
2000-09-18 16:15:01 +00:00
}
}
break;
2010-10-20 15:36:15 +01:00
}
2000-09-18 16:15:01 +00:00
return sRet;
}
2010-10-11 17:38:56 -05:00
2010-10-20 15:36:15 +01:00
// releases the merge data source table or query after merge is completed
2000-09-18 16:15:01 +00:00
void SwNewDBMgr::EndMerge()
{
2010-10-20 15:36:15 +01:00
OSL_ENSURE(bInMerge, "merge is not active");
bInMerge = sal_False;
delete pImpl->pMergeData;
pImpl->pMergeData = 0;
2000-09-18 16:15:01 +00:00
}
2010-10-11 17:38:56 -05:00
2010-10-20 15:36:15 +01:00
// checks if a desired data source table or query is open
sal_Bool SwNewDBMgr::IsDataSourceOpen(const String& rDataSource,
const String& rTableOrQuery, sal_Bool bMergeOnly)
2000-09-18 16:15:01 +00:00
{
if(pImpl->pMergeData)
2000-09-18 16:15:01 +00:00
{
return !bMergeLock &&
((rDataSource == (String)pImpl->pMergeData->sDataSource &&
rTableOrQuery == (String)pImpl->pMergeData->sCommand)
||(!rDataSource.Len() && !rTableOrQuery.Len()))
&&
pImpl->pMergeData->xResultSet.is();
2000-09-18 16:15:01 +00:00
}
else if(!bMergeOnly)
{
SwDBData aData;
aData.sDataSource = rDataSource;
aData.sCommand = rTableOrQuery;
aData.nCommandType = -1;
SwDSParam* pFound = FindDSData(aData, sal_False);
return (pFound && pFound->xResultSet.is());
}
return sal_False;
2000-09-18 16:15:01 +00:00
}
2010-10-11 17:38:56 -05:00
2010-10-20 15:36:15 +01:00
// read column data at a specified position
sal_Bool SwNewDBMgr::GetColumnCnt(const String& rSourceName, const String& rTableName,
2000-09-18 16:15:01 +00:00
const String& rColumnName, sal_uInt32 nAbsRecordId,
long nLanguage,
rtl::OUString& rResult, double* pNumber)
2000-09-18 16:15:01 +00:00
{
sal_Bool bRet = sal_False;
SwDSParam* pFound = 0;
2000-09-18 16:15:01 +00:00
//check if it's the merge data source
if(pImpl->pMergeData &&
rSourceName == (String)pImpl->pMergeData->sDataSource &&
rTableName == (String)pImpl->pMergeData->sCommand)
2000-09-18 16:15:01 +00:00
{
pFound = pImpl->pMergeData;
}
else
{
SwDBData aData;
aData.sDataSource = rSourceName;
aData.sCommand = rTableName;
aData.nCommandType = -1;
pFound = FindDSData(aData, sal_False);
}
if (!pFound)
return sal_False;
//check validity of supplied record Id
if(pFound->aSelection.getLength())
{
//the destination has to be an element of the selection
const Any* pSelection = pFound->aSelection.getConstArray();
sal_Bool bFound = sal_False;
for(sal_Int32 nPos = 0; !bFound && nPos < pFound->aSelection.getLength(); nPos++)
{
sal_Int32 nSelection = 0;
pSelection[nPos] >>= nSelection;
if(nSelection == static_cast<sal_Int32>(nAbsRecordId))
bFound = sal_True;
}
if(!bFound)
return sal_False;
}
if(pFound->xResultSet.is() && !pFound->bAfterSelection)
{
2001-12-11 10:24:42 +00:00
sal_Int32 nOldRow = 0;
try
{
nOldRow = pFound->xResultSet->getRow();
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
2001-12-11 10:24:42 +00:00
{
return sal_False;
2001-12-11 10:24:42 +00:00
}
2000-09-18 16:15:01 +00:00
//position to the desired index
sal_Bool bMove = sal_True;
if ( nOldRow != static_cast<sal_Int32>(nAbsRecordId) )
bMove = lcl_MoveAbsolute(pFound, nAbsRecordId);
2000-09-18 16:15:01 +00:00
if(bMove)
{
bRet = lcl_GetColumnCnt(pFound, rColumnName, nLanguage, rResult, pNumber);
2000-09-18 16:15:01 +00:00
}
if ( nOldRow != static_cast<sal_Int32>(nAbsRecordId) )
bMove = lcl_MoveAbsolute(pFound, nOldRow);
2000-09-18 16:15:01 +00:00
}
return bRet;
}
2010-10-11 17:38:56 -05:00
2010-10-20 15:36:15 +01:00
// reads the column data at the current position
sal_Bool SwNewDBMgr::GetMergeColumnCnt(const String& rColumnName, sal_uInt16 nLanguage,
rtl::OUString &rResult, double *pNumber, sal_uInt32 * /*pFormat*/)
2000-09-18 16:15:01 +00:00
{
if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is() || pImpl->pMergeData->bAfterSelection )
{
rResult = rtl::OUString();
return sal_False;
}
2000-09-18 16:15:01 +00:00
sal_Bool bRet = lcl_GetColumnCnt(pImpl->pMergeData, rColumnName, nLanguage, rResult, pNumber);
2000-09-18 16:15:01 +00:00
return bRet;
}
sal_Bool SwNewDBMgr::ToNextMergeRecord()
2000-09-18 16:15:01 +00:00
{
2010-10-20 15:36:15 +01:00
OSL_ENSURE(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
return ToNextRecord(pImpl->pMergeData);
}
sal_Bool SwNewDBMgr::ToNextRecord(
const String& rDataSource, const String& rCommand, sal_Int32 /*nCommandType*/)
{
SwDSParam* pFound = 0;
if(pImpl->pMergeData &&
rDataSource == (String)pImpl->pMergeData->sDataSource &&
rCommand == (String)pImpl->pMergeData->sCommand)
pFound = pImpl->pMergeData;
else
{
SwDBData aData;
aData.sDataSource = rDataSource;
aData.sCommand = rCommand;
aData.nCommandType = -1;
pFound = FindDSData(aData, sal_False);
}
return ToNextRecord(pFound);
}
sal_Bool SwNewDBMgr::ToNextRecord(SwDSParam* pParam)
{
sal_Bool bRet = sal_True;
2001-10-16 10:10:55 +00:00
if(!pParam || !pParam->xResultSet.is() || pParam->bEndOfDB ||
(pParam->aSelection.getLength() && pParam->aSelection.getLength() <= pParam->nSelectionIndex))
{
if(pParam)
pParam->CheckEndOfDB();
return sal_False;
}
2000-09-18 16:15:01 +00:00
try
{
if(pParam->aSelection.getLength())
2000-11-13 07:32:00 +00:00
{
sal_Int32 nPos = 0;
pParam->aSelection.getConstArray()[ pParam->nSelectionIndex++ ] >>= nPos;
pParam->bEndOfDB = !pParam->xResultSet->absolute( nPos );
pParam->CheckEndOfDB();
bRet = !pParam->bEndOfDB;
if(pParam->nSelectionIndex >= pParam->aSelection.getLength())
pParam->bEndOfDB = sal_True;
2000-11-13 07:32:00 +00:00
}
2000-09-18 16:15:01 +00:00
else
{
sal_Int32 nBefore = pParam->xResultSet->getRow();
pParam->bEndOfDB = !pParam->xResultSet->next();
if( !pParam->bEndOfDB && nBefore == pParam->xResultSet->getRow())
{
//next returned true but it didn't move
pParam->bEndOfDB = sal_True;
}
pParam->CheckEndOfDB();
bRet = !pParam->bEndOfDB;
++pParam->nSelectionIndex;
2000-09-18 16:15:01 +00:00
}
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
2000-09-18 16:15:01 +00:00
{
}
return bRet;
2000-09-18 16:15:01 +00:00
}
2010-10-20 15:36:15 +01:00
/* ------------------------------------------------------------------------
2000-09-18 16:15:01 +00:00
synchronized labels contain a next record field at their end
to assure that the next page can be created in mail merge
the cursor position must be validated
---------------------------------------------------------------------------*/
sal_Bool SwNewDBMgr::ExistsNextRecord() const
2000-09-18 16:15:01 +00:00
{
return pImpl->pMergeData && !pImpl->pMergeData->bEndOfDB;
2000-09-18 16:15:01 +00:00
}
sal_uInt32 SwNewDBMgr::GetSelectedRecordId()
{
sal_uInt32 nRet = 0;
2010-10-20 15:36:15 +01:00
OSL_ENSURE(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is())
return sal_False;
2000-09-18 16:15:01 +00:00
try
{
nRet = pImpl->pMergeData->xResultSet->getRow();
2000-09-18 16:15:01 +00:00
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
2000-09-18 16:15:01 +00:00
{
}
return nRet;
}
sal_Bool SwNewDBMgr::ToRecordId(sal_Int32 nSet)
{
2010-10-20 15:36:15 +01:00
OSL_ENSURE(pImpl->pMergeData && pImpl->pMergeData->xResultSet.is(), "no data source in merge");
if(!pImpl->pMergeData || !pImpl->pMergeData->xResultSet.is()|| nSet < 0)
return sal_False;
sal_Bool bRet = sal_False;
sal_Int32 nAbsPos = nSet;
2000-09-18 16:15:01 +00:00
if(nAbsPos >= 0)
{
bRet = lcl_MoveAbsolute(pImpl->pMergeData, nAbsPos);
pImpl->pMergeData->bEndOfDB = !bRet;
pImpl->pMergeData->CheckEndOfDB();
2000-09-18 16:15:01 +00:00
}
return bRet;
}
sal_Bool SwNewDBMgr::OpenDataSource(const String& rDataSource, const String& rTableOrQuery,
sal_Int32 nCommandType, bool bCreate)
2000-09-18 16:15:01 +00:00
{
SwDBData aData;
aData.sDataSource = rDataSource;
aData.sCommand = rTableOrQuery;
aData.nCommandType = nCommandType;
SwDSParam* pFound = FindDSData(aData, sal_True);
uno::Reference< XDataSource> xSource;
2000-09-18 16:15:01 +00:00
if(pFound->xResultSet.is())
return sal_True;
SwDSParam* pParam = FindDSConnection(rDataSource, sal_False);
uno::Reference< XConnection> xConnection;
if(pParam && pParam->xConnection.is())
pFound->xConnection = pParam->xConnection;
else if(bCreate)
2002-10-24 12:48:08 +00:00
{
rtl::OUString sDataSource(rDataSource);
pFound->xConnection = RegisterConnection( sDataSource );
}
2000-09-18 16:15:01 +00:00
if(pFound->xConnection.is())
{
try
{
uno::Reference< sdbc::XDatabaseMetaData > xMetaData = pFound->xConnection->getMetaData();
try
{
pFound->bScrollable = xMetaData
2000-09-18 16:15:01 +00:00
->supportsResultSetType((sal_Int32)ResultSetType::SCROLL_INSENSITIVE);
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
2011-02-25 22:33:34 +01:00
// DB driver may not be ODBC 3.0 compliant
pFound->bScrollable = sal_True;
}
2000-09-18 16:15:01 +00:00
pFound->xStatement = pFound->xConnection->createStatement();
2001-09-04 11:40:59 +00:00
rtl::OUString aQuoteChar = xMetaData->getIdentifierQuoteString();
rtl::OUString sStatement(C2U("SELECT * FROM "));
sStatement = C2U("SELECT * FROM ");
sStatement += aQuoteChar;
sStatement += rTableOrQuery;
sStatement += aQuoteChar;
pFound->xResultSet = pFound->xStatement->executeQuery( sStatement );
2000-09-18 16:15:01 +00:00
//after executeQuery the cursor must be positioned
pFound->bEndOfDB = !pFound->xResultSet->next();
pFound->bAfterSelection = sal_False;
pFound->CheckEndOfDB();
++pFound->nSelectionIndex;
2000-09-18 16:15:01 +00:00
}
2011-06-15 23:56:45 +01:00
catch (const Exception&)
2000-09-18 16:15:01 +00:00
{
pFound->xResultSet = 0;
pFound->xStatement = 0;
pFound->xConnection = 0;
}
}
return pFound->xResultSet.is();
}
uno::Reference< XConnection> SwNewDBMgr::RegisterConnection(rtl::OUString& rDataSource)
{
SwDSParam* pFound = SwNewDBMgr::FindDSConnection(rDataSource, sal_True);
uno::Reference< XDataSource> xSource;
if(!pFound->xConnection.is())
{
pFound->xConnection = SwNewDBMgr::GetConnection(rDataSource, xSource );
try
{
uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
if(xComponent.is())
xComponent->addEventListener(pImpl->xDisposeListener);
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
}
}
return pFound->xConnection;
}
2000-09-18 16:15:01 +00:00
sal_uInt32 SwNewDBMgr::GetSelectedRecordId(
const String& rDataSource, const String& rTableOrQuery, sal_Int32 nCommandType)
2000-09-18 16:15:01 +00:00
{
sal_uInt32 nRet = 0xffffffff;
2000-09-18 16:15:01 +00:00
//check for merge data source first
if(pImpl->pMergeData && rDataSource == (String)pImpl->pMergeData->sDataSource &&
rTableOrQuery == (String)pImpl->pMergeData->sCommand &&
(nCommandType == -1 || nCommandType == pImpl->pMergeData->nCommandType) &&
pImpl->pMergeData->xResultSet.is())
2000-09-18 16:15:01 +00:00
nRet = GetSelectedRecordId();
else
{
SwDBData aData;
aData.sDataSource = rDataSource;
aData.sCommand = rTableOrQuery;
aData.nCommandType = nCommandType;
SwDSParam* pFound = FindDSData(aData, sal_False);
2000-09-18 16:15:01 +00:00
if(pFound && pFound->xResultSet.is())
{
try
{ //if a selection array is set the current row at the result set may not be set yet
if(pFound->aSelection.getLength())
{
sal_Int32 nSelIndex = pFound->nSelectionIndex;
if(nSelIndex >= pFound->aSelection.getLength())
nSelIndex = pFound->aSelection.getLength() -1;
pFound->aSelection.getConstArray()[nSelIndex] >>= nRet;
}
else
nRet = pFound->xResultSet->getRow();
2000-09-18 16:15:01 +00:00
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
}
2000-09-18 16:15:01 +00:00
}
}
return nRet;
}
2010-10-20 15:36:15 +01:00
// close all data sources - after fields were updated
void SwNewDBMgr::CloseAll(sal_Bool bIncludingMerge)
2000-09-18 16:15:01 +00:00
{
//the only thing done here is to reset the selection index
//all connections stay open
for(sal_uInt16 nPos = 0; nPos < aDataSourceParams.size(); nPos++)
{
SwDSParam* pParam = &aDataSourceParams[nPos];
if(bIncludingMerge || pParam != pImpl->pMergeData)
{
pParam->nSelectionIndex = 0;
pParam->bAfterSelection = sal_False;
pParam->bEndOfDB = sal_False;
try
{
if(!bInMerge && pParam->xResultSet.is())
pParam->xResultSet->first();
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{}
}
}
2000-09-18 16:15:01 +00:00
}
SwDSParam* SwNewDBMgr::FindDSData(const SwDBData& rData, sal_Bool bCreate)
2000-09-18 16:15:01 +00:00
{
//prefer merge data if available
if(pImpl->pMergeData && rData.sDataSource == pImpl->pMergeData->sDataSource &&
rData.sCommand == pImpl->pMergeData->sCommand &&
(rData.nCommandType == -1 || rData.nCommandType == pImpl->pMergeData->nCommandType ||
(bCreate && pImpl->pMergeData->nCommandType == -1)))
{
return pImpl->pMergeData;
}
2000-09-18 16:15:01 +00:00
SwDSParam* pFound = 0;
for(sal_uInt16 nPos = aDataSourceParams.size(); nPos; nPos--)
2000-09-18 16:15:01 +00:00
{
SwDSParam* pParam = &aDataSourceParams[nPos - 1];
if(rData.sDataSource == pParam->sDataSource &&
rData.sCommand == pParam->sCommand &&
(rData.nCommandType == -1 || rData.nCommandType == pParam->nCommandType ||
(bCreate && pParam->nCommandType == -1)))
2000-09-18 16:15:01 +00:00
{
2011-02-25 22:33:34 +01:00
// calls from the calculator may add a connection with an invalid commandtype
//later added "real" data base connections have to re-use the already available
//DSData and set the correct CommandType
if(bCreate && pParam->nCommandType == -1)
pParam->nCommandType = rData.nCommandType;
2000-09-18 16:15:01 +00:00
pFound = pParam;
break;
}
}
if(bCreate)
{
if(!pFound)
{
pFound = new SwDSParam(rData);
aDataSourceParams.push_back(pFound);
try
{
uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
if(xComponent.is())
xComponent->addEventListener(pImpl->xDisposeListener);
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
}
2000-09-18 16:15:01 +00:00
}
}
return pFound;
}
SwDSParam* SwNewDBMgr::FindDSConnection(const rtl::OUString& rDataSource, sal_Bool bCreate)
{
//prefer merge data if available
if(pImpl->pMergeData && rDataSource == pImpl->pMergeData->sDataSource )
{
return pImpl->pMergeData;
}
SwDSParam* pFound = 0;
for(sal_uInt16 nPos = 0; nPos < aDataSourceParams.size(); nPos++)
{
SwDSParam* pParam = &aDataSourceParams[nPos];
if(rDataSource == pParam->sDataSource)
{
pFound = pParam;
break;
}
}
if(bCreate && !pFound)
{
SwDBData aData;
aData.sDataSource = rDataSource;
pFound = new SwDSParam(aData);
aDataSourceParams.push_back(pFound);
try
{
uno::Reference<XComponent> xComponent(pFound->xConnection, UNO_QUERY);
if(xComponent.is())
xComponent->addEventListener(pImpl->xDisposeListener);
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
}
}
return pFound;
}
const SwDBData& SwNewDBMgr::GetAddressDBName()
2000-09-18 16:15:01 +00:00
{
return SW_MOD()->GetDBConfig()->GetAddressSource();
2000-09-18 16:15:01 +00:00
}
2001-09-04 11:40:59 +00:00
Sequence<rtl::OUString> SwNewDBMgr::GetExistingDatabaseNames()
2000-09-18 16:15:01 +00:00
{
Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
return xDBContext->getElementNames();
2000-09-18 16:15:01 +00:00
}
String SwNewDBMgr::LoadAndRegisterDataSource()
{
sfx2::FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
String sHomePath(SvtPathOptions().GetWorkPath());
aDlgHelper.SetDisplayDirectory( sHomePath );
Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
String sFilterAll(SW_RES(STR_FILTER_ALL));
String sFilterAllData(SW_RES(STR_FILTER_ALL_DATA));
String sFilterSXB(SW_RES(STR_FILTER_SXB));
String sFilterSXC(SW_RES(STR_FILTER_SXC));
String sFilterDBF(SW_RES(STR_FILTER_DBF));
String sFilterXLS(SW_RES(STR_FILTER_XLS));
String sFilterTXT(SW_RES(STR_FILTER_TXT));
String sFilterCSV(SW_RES(STR_FILTER_CSV));
#ifdef WNT
String sFilterMDB(SW_RES(STR_FILTER_MDB));
2008-10-01 06:46:01 +00:00
String sFilterACCDB(SW_RES(STR_FILTER_ACCDB));
#endif
xFltMgr->appendFilter( sFilterAll, C2U("*") );
xFltMgr->appendFilter( sFilterAllData, C2U("*.ods;*.sxc;*.dbf;*.xls;*.txt;*.csv"));
xFltMgr->appendFilter( sFilterSXB, C2U("*.odb") );
xFltMgr->appendFilter( sFilterSXC, C2U("*.ods;*.sxc") );
xFltMgr->appendFilter( sFilterDBF, C2U("*.dbf") );
xFltMgr->appendFilter( sFilterXLS, C2U("*.xls") );
xFltMgr->appendFilter( sFilterTXT, C2U("*.txt") );
xFltMgr->appendFilter( sFilterCSV, C2U("*.csv") );
#ifdef WNT
xFltMgr->appendFilter( sFilterMDB, C2U("*.mdb") );
2008-10-01 06:46:01 +00:00
xFltMgr->appendFilter( sFilterACCDB, C2U("*.accdb") );
#endif
xFltMgr->setCurrentFilter( sFilterAll ) ;
String sFind;
bool bTextConnection = false;
if( ERRCODE_NONE == aDlgHelper.Execute() )
{
String sURL = xFP->getFiles().getConstArray()[0];
//data sources have to be registered depending on their extensions
INetURLObject aURL( sURL );
String sExt( aURL.GetExtension() );
Any aURLAny;
Any aTableFilterAny;
Any aSuppressVersionsAny;
Any aInfoAny;
INetURLObject aTempURL(aURL);
bool bStore = true;
if(sExt.EqualsAscii("odb"))
{
bStore = false;
}
else if(sExt.EqualsIgnoreCaseAscii("sxc")
|| sExt.EqualsIgnoreCaseAscii("ods")
|| sExt.EqualsIgnoreCaseAscii("xls"))
{
rtl::OUString sDBURL(C2U("sdbc:calc:"));
sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
aURLAny <<= sDBURL;
}
else if(sExt.EqualsIgnoreCaseAscii("dbf"))
{
aTempURL.removeSegment();
aTempURL.removeFinalSlash();
rtl::OUString sDBURL(C2U("sdbc:dbase:"));
sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
aURLAny <<= sDBURL;
//set the filter to the file name without extension
Sequence<rtl::OUString> aFilters(1);
rtl::OUString sTmp(aURL.getBase());
aFilters[0] = aURL.getBase();
aTableFilterAny <<= aFilters;
}
else if(sExt.EqualsIgnoreCaseAscii("csv") || sExt.EqualsIgnoreCaseAscii("txt"))
{
aTempURL.removeSegment();
aTempURL.removeFinalSlash();
rtl::OUString sDBURL(C2U("sdbc:flat:"));
//only the 'path' has to be added
sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
aURLAny <<= sDBURL;
bTextConnection = true;
//set the filter to the file name without extension
Sequence<rtl::OUString> aFilters(1);
rtl::OUString sTmp(aURL.getBase());
aFilters[0] = aURL.getBase();
aTableFilterAny <<= aFilters;
}
#ifdef WNT
else if(sExt.EqualsIgnoreCaseAscii("mdb"))
{
rtl::OUString sDBURL(C2U("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="));
sDBURL += aTempURL.PathToFileName();
aURLAny <<= sDBURL;
aSuppressVersionsAny <<= makeAny(true);
}
2008-10-01 06:46:01 +00:00
else if(sExt.EqualsIgnoreCaseAscii("accdb"))
{
rtl::OUString sDBURL(C2U("sdbc:ado:PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE="));
sDBURL += aTempURL.PathToFileName();
aURLAny <<= sDBURL;
aSuppressVersionsAny <<= makeAny(true);
}
#endif
try
{
Reference<XMultiServiceFactory> xMgr( ::comphelper::getProcessServiceFactory() );
Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
Reference<XSingleServiceFactory> xFact( xDBContext, UNO_QUERY);
String sNewName = INetURLObject::decode( aURL.getName(),
INET_HEX_ESCAPE,
INetURLObject::DECODE_UNAMBIGUOUS,
RTL_TEXTENCODING_UTF8 );
xub_StrLen nExtLen = static_cast< xub_StrLen >(aURL.GetExtension().getLength());
sNewName.Erase( sNewName.Len() - nExtLen - 1, nExtLen + 1 );
//find a unique name if sNewName already exists
sFind = sNewName;
sal_Int32 nIndex = 0;
while(xDBContext->hasByName(sFind))
{
sFind = sNewName;
sFind += String::CreateFromInt32(++nIndex);
}
Reference<XInterface> xNewInstance;
if(!bStore)
{
//odb-file
Any aDataSource = xDBContext->getByName(aTempURL.GetMainURL(INetURLObject::NO_DECODE));
aDataSource >>= xNewInstance;
}
else
{
xNewInstance = xFact->createInstance();
Reference<XPropertySet> xDataProperties(xNewInstance, UNO_QUERY);
if(aURLAny.hasValue())
xDataProperties->setPropertyValue(C2U("URL"), aURLAny);
if(aTableFilterAny.hasValue())
xDataProperties->setPropertyValue(C2U("TableFilter"), aTableFilterAny);
if(aSuppressVersionsAny.hasValue())
xDataProperties->setPropertyValue(C2U("SuppressVersionColumns"), aSuppressVersionsAny);
if(aInfoAny.hasValue())
xDataProperties->setPropertyValue(C2U("Info"), aInfoAny);
if( bTextConnection )
{
uno::Reference < ui::dialogs::XExecutableDialog > xSettingsDlg(
xMgr->createInstance( C2U( "com.sun.star.sdb.TextConnectionSettings" ) ), uno::UNO_QUERY);
if( xSettingsDlg->execute() )
{
uno::Any aSettings = xDataProperties->getPropertyValue( C2U( "Settings" ) );
uno::Reference < beans::XPropertySet > xDSSettings;
aSettings >>= xDSSettings;
::comphelper::copyProperties(
uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY ),
xDSSettings );
xDSSettings->setPropertyValue( C2U("Extension"), uno::makeAny( ::rtl::OUString( sExt )));
}
}
Reference<XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW);
Reference<XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW);
String sOutputExt = rtl::OUString(".odb");
String sTmpName;
{
utl::TempFile aTempFile(sNewName , &sOutputExt, &sHomePath);
aTempFile.EnableKillingFile(sal_True);
sTmpName = aTempFile.GetURL();
}
xStore->storeAsURL(sTmpName, Sequence< PropertyValue >());
}
Reference<XNamingService> xNaming(xDBContext, UNO_QUERY);
xNaming->registerObject( sFind, xNewInstance );
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
}
}
return sFind;
}
2000-11-13 07:32:00 +00:00
void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
const Sequence<PropertyValue>& rProperties,
sal_Bool bWithDataSourceBrowser)
2000-11-13 07:32:00 +00:00
{
2001-02-16 13:58:11 +00:00
//prevent second call
if(pImpl->pMergeDialog)
2001-02-16 13:58:11 +00:00
return ;
2001-09-04 11:40:59 +00:00
rtl::OUString sDataSource, sDataTableOrQuery;
Sequence<Any> aSelection;
sal_Int32 nCmdType = CommandType::TABLE;
uno::Reference< XConnection> xConnection;
ODataAccessDescriptor aDescriptor(rProperties);
sDataSource = aDescriptor.getDataSource();
OSL_VERIFY(aDescriptor[daCommand] >>= sDataTableOrQuery);
OSL_VERIFY(aDescriptor[daCommandType] >>= nCmdType);
if ( aDescriptor.has(daSelection) )
aDescriptor[daSelection] >>= aSelection;
if ( aDescriptor.has(daConnection) )
aDescriptor[daConnection] >>= xConnection;
if(sDataSource.isEmpty() || sDataTableOrQuery.isEmpty())
2000-11-13 07:32:00 +00:00
{
OSL_FAIL("PropertyValues missing or unset");
2000-11-13 07:32:00 +00:00
return;
}
//always create a connection for the dialog and dispose it after the dialog has been closed
SwDSParam* pFound = 0;
if(!xConnection.is())
{
xConnection = SwNewDBMgr::RegisterConnection(sDataSource);
pFound = FindDSConnection(sDataSource, sal_True);
}
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2010-10-20 15:36:15 +01:00
OSL_ENSURE(pFact, "Dialogdiet fail!");
pImpl->pMergeDialog = pFact->CreateMailMergeDlg( DLG_MAILMERGE,
&rSh.GetView().GetViewFrame()->GetWindow(), rSh,
sDataSource,
sDataTableOrQuery,
nCmdType,
xConnection,
bWithDataSourceBrowser ? 0 : &aSelection);
2010-10-20 15:36:15 +01:00
OSL_ENSURE(pImpl->pMergeDialog, "Dialogdiet fail!");
if(pImpl->pMergeDialog->Execute() == RET_OK)
2000-11-13 07:32:00 +00:00
{
aDescriptor[daSelection] <<= pImpl->pMergeDialog->GetSelection();
uno::Reference<XResultSet> xResSet = pImpl->pMergeDialog->GetResultSet();
if(xResSet.is())
aDescriptor[daCursor] <<= xResSet;
// SfxObjectShellRef is ok, since there should be no control over the document lifetime here
SfxObjectShellRef xDocShell = rSh.GetView().GetViewFrame()->GetObjectShell();
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xDocShell));
{
//copy rSh to aTempFile
::rtl::OUString sTempURL;
const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
rtl::OUString(FILTER_XML),
SwDocShell::Factory().GetFilterContainer() );
try
{
uno::Sequence< beans::PropertyValue > aValues(1);
beans::PropertyValue* pValues = aValues.getArray();
pValues[0].Name = C2U("FilterName");
pValues[0].Value <<= ::rtl::OUString(pSfxFlt->GetFilterName());
uno::Reference< frame::XStorable > xStore( xDocShell->GetModel(), uno::UNO_QUERY);
sTempURL = URIHelper::SmartRel2Abs( INetURLObject(), utl::TempFile::CreateTempName() );
xStore->storeToURL( sTempURL, aValues );
}
2011-06-15 23:56:45 +01:00
catch(const uno::Exception&)
{
}
if( xDocShell->GetError() )
{
// error message ??
ErrorHandler::HandleError( xDocShell->GetError() );
}
else
{
// the shell will be explicitly closed, but it is more safe to use SfxObjectShellLock here
// especially for the case that the loading has failed
SfxObjectShellLock xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
SfxMedium* pWorkMed = new SfxMedium( sTempURL, STREAM_STD_READ );
pWorkMed->SetFilter( pSfxFlt );
if( xWorkDocSh->DoLoad(pWorkMed) )
{
SfxViewFrame *pFrame = SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 );
SwView *pView = (SwView*) pFrame->GetViewShell();
pView->AttrChangedNotify( &pView->GetWrtShell() );// in order for SelectShell to be called
//set the current DBMgr
SwDoc* pWorkDoc = pView->GetWrtShell().GetDoc();
SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
pWorkDoc->SetNewDBMgr( this );
SwMergeDescriptor aMergeDesc( pImpl->pMergeDialog->GetMergeType(), pView->GetWrtShell(), aDescriptor );
aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter();
aMergeDesc.bCreateSingleFile = !pImpl->pMergeDialog->IsSaveIndividualDocs();
if( !aMergeDesc.bCreateSingleFile && pImpl->pMergeDialog->IsGenerateFromDataBase() )
{
aMergeDesc.sAddressFromColumn = pImpl->pMergeDialog->GetColumnName();
aMergeDesc.sSubject = pImpl->pMergeDialog->GetPath();
}
MergeNew(aMergeDesc);
pWorkDoc->SetNewDBMgr( pWorkDBMgr );
//close the temporary file
uno::Reference< util::XCloseable > xClose( xWorkDocSh->GetModel(), uno::UNO_QUERY );
if (xClose.is())
{
try
{
//! 'sal_True' -> transfer ownership to vetoing object if vetoed!
//! I.e. now that object is responsible for closing the model and doc shell.
xClose->close( sal_True );
}
2011-06-15 23:56:45 +01:00
catch (const uno::Exception&)
{
}
}
}
}
//remove the temporary file
SWUnoHelper::UCB_DeleteFile( sTempURL );
}
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), rSh.GetView().GetViewFrame()->GetObjectShell()));
// reset the cursor inside
xResSet = NULL;
aDescriptor[daCursor] <<= xResSet;
2000-11-13 07:32:00 +00:00
}
if(pFound)
{
for(sal_uInt16 nPos = 0; nPos < aDataSourceParams.size(); nPos++)
{
SwDSParam* pParam = &aDataSourceParams[nPos];
if(pParam == pFound)
{
try
{
uno::Reference<XComponent> xComp(pParam->xConnection, UNO_QUERY);
if(xComp.is())
xComp->dispose();
}
2011-06-15 23:56:45 +01:00
catch(const RuntimeException&)
{
//may be disposed already since multiple entries may have used the same connection
}
break;
}
//pFound doesn't need to be removed/deleted -
//this has been done by the SwConnectionDisposedListener_Impl already
}
}
DELETEZ(pImpl->pMergeDialog);
2000-11-13 07:32:00 +00:00
}
void SwNewDBMgr::InsertText(SwWrtShell& rSh,
const Sequence< PropertyValue>& rProperties)
{
2001-09-04 11:40:59 +00:00
rtl::OUString sDataSource, sDataTableOrQuery;
uno::Reference<XResultSet> xResSet;
Sequence<Any> aSelection;
2000-11-13 07:32:00 +00:00
sal_Int16 nCmdType = CommandType::TABLE;
const PropertyValue* pValues = rProperties.getConstArray();
uno::Reference< XConnection> xConnection;
2000-11-13 07:32:00 +00:00
for(sal_Int32 nPos = 0; nPos < rProperties.getLength(); nPos++)
{
if ( pValues[nPos].Name == cDataSourceName )
2000-11-13 07:32:00 +00:00
pValues[nPos].Value >>= sDataSource;
else if ( pValues[nPos].Name == cCommand )
2000-11-13 07:32:00 +00:00
pValues[nPos].Value >>= sDataTableOrQuery;
else if ( pValues[nPos].Name == cCursor )
2000-11-13 07:32:00 +00:00
pValues[nPos].Value >>= xResSet;
else if ( pValues[nPos].Name == cSelection )
2000-11-13 07:32:00 +00:00
pValues[nPos].Value >>= aSelection;
else if ( pValues[nPos].Name == cCommandType )
2000-11-13 07:32:00 +00:00
pValues[nPos].Value >>= nCmdType;
else if ( pValues[nPos].Name == cActiveConnection )
pValues[nPos].Value >>= xConnection;
2000-11-13 07:32:00 +00:00
}
if(sDataSource.isEmpty() || sDataTableOrQuery.isEmpty() || !xResSet.is())
2000-11-13 07:32:00 +00:00
{
OSL_FAIL("PropertyValues missing or unset");
2000-11-13 07:32:00 +00:00
return;
}
Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
uno::Reference<XDataSource> xSource;
uno::Reference<XChild> xChild(xConnection, UNO_QUERY);
if(xChild.is())
xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
if(!xSource.is())
xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(sDataSource, xContext);
uno::Reference< XColumnsSupplier > xColSupp( xResSet, UNO_QUERY );
SwDBData aDBData;
aDBData.sDataSource = sDataSource;
aDBData.sCommand = sDataTableOrQuery;
aDBData.nCommandType = nCmdType;
2000-11-13 07:32:00 +00:00
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2010-10-20 15:36:15 +01:00
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
AbstractSwInsertDBColAutoPilot* pDlg = pFact->CreateSwInsertDBColAutoPilot( rSh.GetView(),
xSource,
xColSupp,
aDBData,
DLG_AP_INSERT_DB_SEL );
2010-10-20 15:36:15 +01:00
OSL_ENSURE(pDlg, "Dialogdiet fail!");
2000-11-13 07:32:00 +00:00
if( RET_OK == pDlg->Execute() )
{
2001-09-04 11:40:59 +00:00
rtl::OUString sDummy;
if(!xConnection.is())
xConnection = xSource->getConnection(sDummy, sDummy);
2001-05-21 12:45:09 +00:00
try
{
pDlg->DataToDoc( aSelection , xSource, xConnection, xResSet);
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
2001-05-21 12:45:09 +00:00
{
OSL_FAIL("exception caught");
2001-05-21 12:45:09 +00:00
}
2000-11-13 07:32:00 +00:00
}
delete pDlg;
}
SwDbtoolsClient* SwNewDBMgr::pDbtoolsClient = NULL;
SwDbtoolsClient& SwNewDBMgr::GetDbtoolsClient()
{
if ( !pDbtoolsClient )
pDbtoolsClient = new SwDbtoolsClient;
return *pDbtoolsClient;
}
void SwNewDBMgr::RemoveDbtoolsClient()
{
delete pDbtoolsClient;
pDbtoolsClient = 0;
}
uno::Reference<XDataSource> SwNewDBMgr::getDataSourceAsParent(const uno::Reference< XConnection>& _xConnection,const ::rtl::OUString& _sDataSourceName)
{
uno::Reference<XDataSource> xSource;
try
{
uno::Reference<XChild> xChild(_xConnection, UNO_QUERY);
if ( xChild.is() )
xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY);
if ( !xSource.is() )
xSource = SwNewDBMgr::GetDbtoolsClient().getDataSource(_sDataSourceName, ::comphelper::getProcessComponentContext());
}
catch(const Exception&)
{
OSL_FAIL("exception in getDataSourceAsParent caught");
}
return xSource;
}
uno::Reference<XResultSet> SwNewDBMgr::createCursor(const ::rtl::OUString& _sDataSourceName,
const ::rtl::OUString& _sCommand,
sal_Int32 _nCommandType,
const uno::Reference<XConnection>& _xConnection
)
{
uno::Reference<XResultSet> xResultSet;
try
{
uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
if( xMgr.is() )
{
uno::Reference<XInterface> xInstance = xMgr->createInstance(
C2U( "com.sun.star.sdb.RowSet" ));
uno::Reference<XPropertySet> xRowSetPropSet(xInstance, UNO_QUERY);
if(xRowSetPropSet.is())
{
xRowSetPropSet->setPropertyValue(C2U("DataSourceName"), makeAny(_sDataSourceName));
xRowSetPropSet->setPropertyValue(C2U("ActiveConnection"), makeAny(_xConnection));
xRowSetPropSet->setPropertyValue(C2U("Command"), makeAny(_sCommand));
xRowSetPropSet->setPropertyValue(C2U("CommandType"), makeAny(_nCommandType));
uno::Reference< XCompletedExecution > xRowSet(xInstance, UNO_QUERY);
if ( xRowSet.is() )
{
uno::Reference< XInteractionHandler > xHandler( InteractionHandler::createWithParent(comphelper::getComponentContext(xMgr), 0), UNO_QUERY_THROW );
xRowSet->executeWithCompletion(xHandler);
}
xResultSet = uno::Reference<XResultSet>(xRowSet, UNO_QUERY);
}
}
}
catch(const Exception&)
{
OSL_FAIL("Caught exception while creating a new RowSet!");
}
return xResultSet;
}
2010-10-11 17:38:56 -05:00
2010-10-20 15:36:15 +01:00
// merge all data into one resulting document and return the number of merged documents
sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
SwView& rSourceView )
{
// check the availability of all data in the config item
uno::Reference< XResultSet> xResultSet = rMMConfig.GetResultSet();
if(!xResultSet.is())
return false;
bInMerge = sal_True;
sal_Int32 nRet = 0;
pImpl->pMergeData = new SwDSParam(
rMMConfig.GetCurrentDBData(), xResultSet, rMMConfig.GetSelection());
try{
//set to start position
if(pImpl->pMergeData->aSelection.getLength())
{
sal_Int32 nPos = 0;
pImpl->pMergeData->aSelection.getConstArray()[ pImpl->pMergeData->nSelectionIndex++ ] >>= nPos;
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->absolute( nPos );
pImpl->pMergeData->CheckEndOfDB();
if(pImpl->pMergeData->nSelectionIndex >= pImpl->pMergeData->aSelection.getLength())
pImpl->pMergeData->bEndOfDB = sal_True;
}
else
{
pImpl->pMergeData->bEndOfDB = !pImpl->pMergeData->xResultSet->first();
pImpl->pMergeData->CheckEndOfDB();
}
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
pImpl->pMergeData->bEndOfDB = sal_True;
pImpl->pMergeData->CheckEndOfDB();
OSL_FAIL("exception in MergeNew()");
}
//bCancel is set from the PrintMonitor
bCancel = sal_False;
CreateMonitor aMonitorDlg(&rSourceView.GetEditWin());
aMonitorDlg.SetCancelHdl(LINK(this, SwNewDBMgr, PrtCancelHdl));
if (!IsMergeSilent())
{
aMonitorDlg.Show();
aMonitorDlg.Invalidate();
aMonitorDlg.Update();
// the print monitor needs some time to act
for( sal_uInt16 i = 0; i < 25; i++)
Application::Reschedule();
}
SwWrtShell& rSourceShell = rSourceView.GetWrtShell();
sal_Bool bSynchronizedDoc = rSourceShell.IsLabelDoc() && rSourceShell.GetSectionFmtCount() > 1;
//save the settings of the first
rSourceShell.SttEndDoc(sal_True);
sal_uInt16 nStartingPageNo = rSourceShell.GetVirtPageNum();
String sModifiedStartingPageDesc;
String sStartingPageDesc = sModifiedStartingPageDesc = rSourceShell.GetPageDesc(
rSourceShell.GetCurPageDesc()).GetName();
try
{
// create a target docshell to put the merged document into
SfxObjectShellRef xTargetDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
xTargetDocShell->DoInitNew( 0 );
SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
//the created window has to be located at the same position as the source window
Window& rTargetWindow = pTargetFrame->GetFrame().GetWindow();
Window& rSourceWindow = rSourceView.GetViewFrame()->GetFrame().GetWindow();
rTargetWindow.SetPosPixel(rSourceWindow.GetPosPixel());
SwView* pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
rMMConfig.SetTargetView(pTargetView);
//initiate SelectShell() to create sub shells
pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() );
SwWrtShell* pTargetShell = pTargetView->GetWrtShellPtr();
// #i63806#
const SwPageDesc* pSourcePageDesc = rSourceShell.FindPageDescByName( sStartingPageDesc );
const SwFrmFmt& rMaster = pSourcePageDesc->GetMaster();
bool bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() ||
rMaster.GetFooter().IsActive();
2011-02-25 22:33:34 +01:00
// copy compatibility options
lcl_CopyCompatibilityOptions( rSourceShell, *pTargetShell);
// #72821# copy dynamic defaults
lcl_CopyDynamicDefaults( *rSourceShell.GetDoc(), *pTargetShell->GetDoc() );
long nStartRow, nEndRow;
sal_uLong nDocNo = 1;
sal_Int32 nDocCount = 0;
if( !IsMergeSilent() && lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) )
aMonitorDlg.SetTotalCount( nDocCount );
do
{
nStartRow = pImpl->pMergeData->xResultSet->getRow();
if (!IsMergeSilent())
{
aMonitorDlg.SetCurrentPosition( nDocNo );
aMonitorDlg.Invalidate();
aMonitorDlg.Update();
// the print monitor needs some time to act
for( sal_uInt16 i = 0; i < 25; i++)
Application::Reschedule();
}
// copy the source document
// the copy will be closed later, but it is more safe to use SfxObjectShellLock here
SfxObjectShellLock xWorkDocSh;
if(nDocNo == 1 )
{
uno::Reference< util::XCloneable > xClone( rSourceView.GetDocShell()->GetModel(), uno::UNO_QUERY);
uno::Reference< lang::XUnoTunnel > xWorkDocShell( xClone->createClone(), uno::UNO_QUERY);
SwXTextDocument* pWorkModel = reinterpret_cast<SwXTextDocument*>(xWorkDocShell->getSomething(SwXTextDocument::getUnoTunnelId()));
xWorkDocSh = pWorkModel->GetDocShell();
}
else
{
xWorkDocSh = rSourceView.GetDocShell()->GetDoc()->CreateCopy(true);
}
//create a ViewFrame
SwView* pWorkView = static_cast< SwView* >( SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 )->GetViewShell() );
SwWrtShell& rWorkShell = pWorkView->GetWrtShell();
pWorkView->AttrChangedNotify( &rWorkShell );// in order for SelectShell to be called
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
// merge the data
SwDoc* pWorkDoc = rWorkShell.GetDoc();
SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
pWorkDoc->SetNewDBMgr( this );
pWorkDoc->EmbedAllLinks();
SwUndoId nLastUndoId(UNDO_EMPTY);
if (rWorkShell.GetLastUndoInfo(0, & nLastUndoId))
{
if (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId)
{
rWorkShell.Undo();
}
}
2009-10-09 15:11:54 +02:00
// #i69485# lock fields to prevent access to the result set while calculating layout
rWorkShell.LockExpFlds();
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
// create a layout
rWorkShell.CalcLayout();
rWorkShell.UnlockExpFlds();
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
rWorkShell.ViewShell::UpdateFlds();
SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
// strip invisible content and convert fields to text
rWorkShell.RemoveInvisibleContent();
rWorkShell.ConvertFieldsToText();
rWorkShell.SetNumberingRestart();
if( bSynchronizedDoc )
{
lcl_RemoveSectionLinks( rWorkShell );
}
// insert the document into the target document
rWorkShell.SttEndDoc(sal_False);
rWorkShell.SttEndDoc(sal_True);
rWorkShell.SelAll();
pTargetShell->SttEndDoc(sal_False);
//#i63806# put the styles to the target document
//if the source uses headers or footers each new copy need to copy a new page styles
if(bPageStylesWithHeaderFooter)
{
//create a new pagestyle
//copy the pagedesc from the current document to the new document and change the name of the to-be-applied style
2009-09-01 03:54:53 +00:00
SwDoc* pTargetDoc = pTargetShell->GetDoc();
String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
pTargetShell->GetDoc()->MakePageDesc( sNewPageDescName );
SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
const SwPageDesc* pWorkPageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc );
CWS-TOOLING: integrate CWS os133 2009-08-17 11:57:21 +0200 od r275041 : #i41413# correction of fix - check, if <Last Name> assignment exist before accessing database 2009-08-13 16:08:34 +0200 tbo r274949 : #i100286# removed from workaround 2009-08-05 10:57:28 +0200 os r274642 : #103994# prevent crash after field undo 2009-08-05 07:58:30 +0200 os r274635 : #103994# prevent crash after field undo 2009-08-04 10:38:40 +0200 os r274611 : #i41413# warnings fixed 2009-08-04 09:34:50 +0200 os r274604 : #103233# unnecessary local variable removed 2009-08-04 09:34:21 +0200 os r274603 : #103233# GetPosition() removed, again 2009-07-27 13:51:58 +0200 os r274362 : CWS-TOOLING: rebase CWS os133 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 12:18:51 +0200 os r274267 : #i41413# salutation preview fixed 2009-07-22 13:55:02 +0200 os r274235 : #i69458# lock expression fields while calculating layout 2009-07-22 10:54:25 +0200 os r274225 : #i103506# page descriptor has to be copied from the working document, not from the source document 2009-07-07 16:01:50 +0200 os r273802 : #i103305# Shift+Ctrl+A should work for single selected drawing objects 2009-07-07 15:36:09 +0200 os r273801 : #ii103137# text:display inversion fixed 2009-07-01 14:19:36 +0200 os r273580 : #103233# access field position directly instead of a text node iteration 2009-06-28 20:05:18 +0200 tbo r273450 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:04:20 +0200 tbo r273449 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-28 20:03:37 +0200 tbo r273448 : #100285# exchange PDF1/2TBO with HID_FILTER_PDF_INITIAL_VIEW/USER_INTERFACE 2009-06-26 13:58:46 +0200 os r273409 : #i20268# misleading CheckBox name changed and function inverted 2009-06-26 13:33:12 +0200 os r273405 : #i52699# twip convrsion of line width for text documents added 2009-06-26 12:42:47 +0200 os r273399 : #i102967# Gender field name: accept first entry 2009-06-26 12:38:53 +0200 os r273398 : #i103121# caption position in all OLEs can only be below 2009-06-25 14:42:42 +0200 os r273382 : #i99848# member m_xText is not always set 2009-06-25 12:38:30 +0200 os r273377 : #i100285# HelpIds added 2009-06-23 16:01:42 +0200 os r273285 : #i103021# BulletId is a unicode character
2009-08-26 11:47:12 +00:00
2009-09-01 03:54:53 +00:00
if(pWorkPageDesc && pTargetPageDesc)
{
2009-09-01 03:54:53 +00:00
pTargetDoc->CopyPageDesc( *pWorkPageDesc, *pTargetPageDesc, sal_False );
sModifiedStartingPageDesc = sNewPageDescName;
2009-09-01 03:54:53 +00:00
lcl_CopyFollowPageDesc( *pTargetShell, *pWorkPageDesc, *pTargetPageDesc, nDocNo );
}
}
if(nDocNo == 1 || bPageStylesWithHeaderFooter)
{
pTargetView->GetDocShell()->_LoadStyles( *rSourceView.GetDocShell(), sal_True );
}
if(nDocNo > 1)
{
pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
}
else
{
pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
}
sal_uInt16 nPageCountBefore = pTargetShell->GetPageCnt();
2010-10-20 15:36:15 +01:00
OSL_ENSURE(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
//#i51359# add a second paragraph in case there's only one
{
SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
SwPosition aTestPos( aIdx );
SwCursor aTestCrsr(aTestPos,0,false);
if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
{
//append a paragraph
pWorkDoc->AppendTxtNode( aTestPos );
}
}
pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
//convert fields in page styles (header/footer - has to be done after the first document has been pasted
if(1 == nDocNo)
{
pTargetShell->CalcLayout();
pTargetShell->ConvertFieldsToText();
}
//add the document info to the config item
SwDocMergeInfo aMergeInfo;
aMergeInfo.nStartPageInTarget = nPageCountBefore;
//#i72820# calculate layout to be able to find the correct page index
pTargetShell->CalcLayout();
aMergeInfo.nEndPageInTarget = pTargetShell->GetPageCnt();
aMergeInfo.nDBRow = nStartRow;
rMMConfig.AddMergedDocument( aMergeInfo );
++nRet;
// the print monitor needs some time to act
for( sal_uInt16 i = 0; i < 25; i++)
Application::Reschedule();
//restore the ole DBMgr
pWorkDoc->SetNewDBMgr( pWorkDBMgr );
//now the temporary document should be closed
SfxObjectShellRef xDocSh(pWorkView->GetDocShell());
xDocSh->DoClose();
nEndRow = pImpl->pMergeData->xResultSet->getRow();
++nDocNo;
} while( !bCancel &&
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
//deselect all, go out of the frame and go to the beginning of the document
Point aPt(LONG_MIN, LONG_MIN);
pTargetShell->SelectObj(aPt, SW_LEAVE_FRAME);
if (pTargetShell->IsSelFrmMode())
{
pTargetShell->UnSelectFrm();
pTargetShell->LeaveSelFrmMode();
}
pTargetShell->EnterStdMode();
pTargetShell->SttDoc();
2010-10-20 15:36:15 +01:00
}
2011-06-15 23:56:45 +01:00
catch(const Exception&)
{
OSL_FAIL("exception caught in SwNewDBMgr::MergeDocuments");
}
DELETEZ(pImpl->pMergeData);
bInMerge = sal_False;
return nRet;
}
2010-10-11 17:38:56 -05:00
SwConnectionDisposedListener_Impl::SwConnectionDisposedListener_Impl(SwNewDBMgr& rMgr) :
rDBMgr(rMgr)
2010-10-11 17:38:56 -05:00
{
};
SwConnectionDisposedListener_Impl::~SwConnectionDisposedListener_Impl()
2010-10-11 17:38:56 -05:00
{
};
void SwConnectionDisposedListener_Impl::disposing( const EventObject& rSource )
throw (RuntimeException)
{
::SolarMutexGuard aGuard;
uno::Reference<XConnection> xSource(rSource.Source, UNO_QUERY);
for(sal_uInt16 nPos = rDBMgr.aDataSourceParams.size(); nPos; nPos--)
{
SwDSParam* pParam = &rDBMgr.aDataSourceParams[nPos - 1];
if(pParam->xConnection.is() &&
(xSource == pParam->xConnection))
{
rDBMgr.aDataSourceParams.erase(rDBMgr.aDataSourceParams.begin() + nPos - 1);
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */