summaryrefslogtreecommitdiff
path: root/sw/source/ui/dbui
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2009-12-01 17:50:41 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2009-12-01 17:50:41 +0000
commit4f0d2859107bc02e3b62fbc2acc42c1af706c7da (patch)
tree83527d821c0c8fe815eb027268e666509bab10ab /sw/source/ui/dbui
parent4a3821a109cb04769de35dee54c10633410015d0 (diff)
parentf71bb16fc284f022a844b575a8db75be7a4aafb1 (diff)
chartshapes: merge with DEV300 m62
Diffstat (limited to 'sw/source/ui/dbui')
-rw-r--r--sw/source/ui/dbui/dbinsdlg.cxx8
-rw-r--r--sw/source/ui/dbui/dbmgr.cxx48
-rw-r--r--sw/source/ui/dbui/mailmergehelper.cxx12
-rw-r--r--sw/source/ui/dbui/makefile.mk1
-rw-r--r--sw/source/ui/dbui/mmgreetingspage.cxx67
-rw-r--r--sw/source/ui/dbui/mmlayoutpage.cxx2
-rw-r--r--sw/source/ui/dbui/mmoutputpage.cxx4
7 files changed, 103 insertions, 39 deletions
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index 07e9b0a0eec0..cb815a93f1a6 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -1131,7 +1131,9 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
for( n = 0; n < nCols; ++n )
{
if( aRbHeadlColnms.IsChecked() )
- rSh.SwEditShell::Insert( aColFlds[ n ]->sColumn );
+ {
+ rSh.SwEditShell::Insert2( aColFlds[ n ]->sColumn );
+ }
rSh.GoNextCell();
}
}
@@ -1227,7 +1229,9 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
{
rtl::OUString sVal = xColumn->getString();
if(!xColumn->wasNull())
- rSh.SwEditShell::Insert( sVal );
+ {
+ rSh.SwEditShell::Insert2( sVal );
+ }
}
}
catch(Exception&
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index 93fad7cb699d..603af1c31111 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -701,7 +701,7 @@ void SwNewDBMgr::ImportDBEntry(SwWrtShell* pSh)
if (i < nLength - 1)
sStr += '\t';
}
- pSh->SwEditShell::Insert(sStr);
+ pSh->SwEditShell::Insert2(sStr);
pSh->SwFEShell::SplitNode(); // Zeilenvorschub
}
}
@@ -932,9 +932,9 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView,
do {
nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
{
- SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, pSh->GetView().GetViewFrame()->GetObjectShell()));
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), pSh->GetView().GetViewFrame()->GetObjectShell()));
pSh->ViewShell::UpdateFlds();
- SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, pSh->GetView().GetViewFrame()->GetObjectShell()));
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), pSh->GetView().GetViewFrame()->GetObjectShell()));
++rOpt.nMergeAct;
// launch MailMergeEvent if required
@@ -1455,9 +1455,9 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
SwDoc* pWorkDoc = ((SwDocShell*)(&xWorkDocSh))->GetDoc();
SwNewDBMgr* pOldDBMgr = pWorkDoc->GetNewDBMgr();
pWorkDoc->SetNewDBMgr( this );
- SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, xWorkDocSh));
+ 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, xWorkDocSh));
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), xWorkDocSh));
// alle versteckten Felder/Bereiche entfernen
pWorkDoc->RemoveInvisibleContent();
@@ -2858,7 +2858,7 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
aDescriptor[daCursor] <<= xResSet;
SfxObjectShellRef xDocShell = rSh.GetView().GetViewFrame()->GetObjectShell();
- SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, xDocShell));
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xDocShell));
{
//copy rSh to aTempFile
::rtl::OUString sTempURL;
@@ -2924,7 +2924,7 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
//remove the temporary file
SWUnoHelper::UCB_DeleteFile( sTempURL );
}
- SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, rSh.GetView().GetViewFrame()->GetObjectShell()));
+ 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;
@@ -3248,18 +3248,21 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
SwWrtShell& rWorkShell = pWorkView->GetWrtShell();
pWorkView->AttrChangedNotify( &rWorkShell );//Damit SelectShell gerufen wird.
- // merge the data
- SwDoc* pWorkDoc = rWorkShell.GetDoc();
- SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
- pWorkDoc->SetNewDBMgr( this );
- pWorkDoc->EmbedAllLinks();
- if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds())
- rWorkShell.Undo();
- // create a layout
- rWorkShell.CalcLayout();
- SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
+ // merge the data
+ SwDoc* pWorkDoc = rWorkShell.GetDoc();
+ SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr();
+ pWorkDoc->SetNewDBMgr( this );
+ pWorkDoc->EmbedAllLinks();
+ if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds())
+ rWorkShell.Undo();
+ // #i69485# lock fields to prevent access to the result set while calculating layout
+ rWorkShell.LockExpFlds();
+ // 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, rWorkShell.GetView().GetViewFrame()->GetObjectShell()));
+ 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();
@@ -3284,11 +3287,13 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo );
pTargetShell->GetDoc()->MakePageDesc( sNewPageDescName );
SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName );
- if(pSourcePageDesc && pTargetPageDesc)
+ const SwPageDesc* pWorkPageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc );
+
+ if(pWorkPageDesc && pTargetPageDesc)
{
- pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, sal_False );
+ pTargetDoc->CopyPageDesc( *pWorkPageDesc, *pTargetPageDesc, sal_False );
sModifiedStartingPageDesc = sNewPageDescName;
- lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo );
+ lcl_CopyFollowPageDesc( *pTargetShell, *pWorkPageDesc, *pTargetPageDesc, nDocNo );
}
}
if(nDocNo == 1 || bPageStylesWithHeaderFooter)
@@ -3396,4 +3401,3 @@ void SwConnectionDisposedListener_Impl::disposing( const EventObject& rSource )
}
}
}
-
diff --git a/sw/source/ui/dbui/mailmergehelper.cxx b/sw/source/ui/dbui/mailmergehelper.cxx
index 0fff9f762131..0423137cc3c3 100644
--- a/sw/source/ui/dbui/mailmergehelper.cxx
+++ b/sw/source/ui/dbui/mailmergehelper.cxx
@@ -627,8 +627,16 @@ SwMergeAddressItem SwAddressIterator::Next()
aRet.bIsColumn = true;
xub_StrLen nClose = sAddress.Search('>');
DBG_ASSERT(nClose != STRING_NOTFOUND, "closing '>' not found");
- aRet.sText = sAddress.Copy(1, nClose - 1);
- sAddress.Erase(0, nClose + 1);
+ if( nClose != STRING_NOTFOUND )
+ {
+ aRet.sText = sAddress.Copy(1, nClose - 1);
+ sAddress.Erase(0, nClose + 1);
+ }
+ else
+ {
+ aRet.sText = sAddress.Copy(1, 1);
+ sAddress.Erase(0, 1);
+ }
}
else
{
diff --git a/sw/source/ui/dbui/makefile.mk b/sw/source/ui/dbui/makefile.mk
index b1aa16f694c3..40d6807c2ead 100644
--- a/sw/source/ui/dbui/makefile.mk
+++ b/sw/source/ui/dbui/makefile.mk
@@ -79,6 +79,7 @@ EXCEPTIONSFILES= \
$(SLO)$/mmaddressblockpage.obj \
$(SLO)$/mmconfigitem.obj \
$(SLO)$/mmlayoutpage.obj \
+ $(SLO)$/mmgreetingspage.obj \
$(SLO)$/mmoutputpage.obj
SLOFILES = \
diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx b/sw/source/ui/dbui/mmgreetingspage.cxx
index e2fcf188a3b3..03bd61021306 100644
--- a/sw/source/ui/dbui/mmgreetingspage.cxx
+++ b/sw/source/ui/dbui/mmgreetingspage.cxx
@@ -42,6 +42,7 @@
#include <vcl/msgbox.hxx>
#include <mmgreetingspage.hrc>
#include <dbui.hrc>
+#include <com/sun/star/sdb/XColumn.hpp>
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <helpid.h>
@@ -117,6 +118,7 @@ IMPL_LINK(SwGreetingsHandler, IndividualHdl_Impl, CheckBox*, EMPTYARG)
m_pWizard->UpdateRoadmap();
m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
}
+ UpdatePreview();
return 0;
}
/*-- 30.04.2004 10:42:57---------------------------------------------------
@@ -133,12 +135,12 @@ IMPL_LINK(SwGreetingsHandler, GreetingHdl_Impl, PushButton*, pButton)
{
ListBox* pToInsert = pButton == m_pMalePB ? m_pMaleLB : m_pFemaleLB;
pToInsert->SelectEntryPos(pToInsert->InsertEntry(pDlg->GetAddress()));
- UpdatePreview();
if(m_bIsTabPage)
{
m_pWizard->UpdateRoadmap();
m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
}
+ UpdatePreview();
}
delete pDlg;
return 0;
@@ -182,9 +184,54 @@ IMPL_LINK(SwMailMergeGreetingsPage, GreetingSelectHdl_Impl, ListBox*, EMPTYARG)
-----------------------------------------------------------------------*/
void SwMailMergeGreetingsPage::UpdatePreview()
{
- String sPreview = m_aFemaleLB.GetSelectEntry();
- sPreview += '\n';
- sPreview += m_aMaleLB.GetSelectEntry();
+ //find out which type of greeting should be selected:
+ bool bFemale = false;
+ bool bNoValue = !m_pFemaleColumnLB->IsEnabled();
+ if( !bNoValue )
+ {
+ ::rtl::OUString sFemaleValue = m_aFemaleFieldCB.GetText();
+ ::rtl::OUString sFemaleColumn = m_aFemaleColumnLB.GetSelectEntry();
+ Reference< sdbcx::XColumnsSupplier > xColsSupp( m_pWizard->GetConfigItem().GetResultSet(), UNO_QUERY);
+ Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0;
+ if(sFemaleValue.getLength() && sFemaleColumn.getLength() &&
+ xColAccess.is() &&
+ xColAccess->hasByName(sFemaleColumn))
+ {
+ //get the content and exchange it in the address string
+ Any aCol = xColAccess->getByName(sFemaleColumn);
+ Reference< sdb::XColumn > xColumn;
+ aCol >>= xColumn;
+ if(xColumn.is())
+ {
+ try
+ {
+ ::rtl::OUString sFemaleColumnValue = xColumn->getString();
+ bFemale = sFemaleColumnValue == sFemaleValue;
+ //bNoValue = !sFemaleColumnValue.getLength();
+ if( !bNoValue )
+ {
+ //no last name value marks the greeting also als neutral
+ SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
+ ::rtl::OUString sLastNameColumn = rConfig.GetAssignedColumn(MM_PART_LASTNAME);
+ if ( xColAccess->hasByName(sLastNameColumn) )
+ {
+ aCol = xColAccess->getByName(sLastNameColumn);
+ aCol >>= xColumn;
+ ::rtl::OUString sLastNameColumnValue = xColumn->getString();
+ bNoValue = !sLastNameColumnValue.getLength();
+ }
+ }
+ }
+ catch( sdbc::SQLException& )
+ {
+ DBG_ERROR("SQLException caught");
+ }
+ }
+ }
+ }
+
+ String sPreview = bFemale ? m_aFemaleLB.GetSelectEntry() :
+ bNoValue ? m_aNeutralCB.GetText() : m_aMaleLB.GetSelectEntry();
sPreview = SwAddressPreview::FillData(sPreview, m_pWizard->GetConfigItem());
m_aPreviewWIN.SetAddress(sPreview);
@@ -284,6 +331,12 @@ SwMailMergeGreetingsPage::SwMailMergeGreetingsPage( SwMailMergeWizard* _pParent)
Link aLBoxLink = LINK(this, SwMailMergeGreetingsPage, GreetingSelectHdl_Impl);
m_aFemaleLB.SetSelectHdl(aLBoxLink);
m_aMaleLB.SetSelectHdl(aLBoxLink);
+ m_aFemaleColumnLB.SetSelectHdl(aLBoxLink);
+ m_aFemaleFieldCB.SetSelectHdl(aLBoxLink);
+ m_aFemaleFieldCB.SetModifyHdl(aLBoxLink);
+ m_aNeutralCB.SetSelectHdl(aLBoxLink);
+ m_aNeutralCB.SetModifyHdl(aLBoxLink);
+
Link aDataLink = LINK(this, SwMailMergeGreetingsPage, InsertDataHdl_Impl);
m_aPrevSetIB.SetClickHdl(aDataLink);
m_aNextSetIB.SetClickHdl(aDataLink);
@@ -348,13 +401,9 @@ sal_Bool SwMailMergeGreetingsPage::commitPage( CommitPageReason )
{
const SwDBData& rDBData = rConfig.GetCurrentDBData();
Sequence< ::rtl::OUString> aAssignment = rConfig.GetColumnAssignment( rDBData );
- sal_Int32 nPos = m_aFemaleColumnLB.GetSelectEntryPos();
if(aAssignment.getLength() <= MM_PART_GENDER)
aAssignment.realloc(MM_PART_GENDER + 1);
- if( nPos > 0 )
- aAssignment[MM_PART_GENDER] = m_aFemaleColumnLB.GetSelectEntry();
- else
- aAssignment[MM_PART_GENDER] = ::rtl::OUString();
+ aAssignment[MM_PART_GENDER] = m_aFemaleColumnLB.GetSelectEntry();
rConfig.SetColumnAssignment( rDBData, aAssignment );
}
if(m_aFemaleFieldCB.GetText() != m_aFemaleFieldCB.GetSavedValue())
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index cd04ebeb2e59..ddb37e3c8eeb 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -614,8 +614,6 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
sCondition += String(rFemaleGenderValue);
sCondition.AppendAscii("\" OR NOT ");
sCondition += String(sNameColumnBase);
- sHideParagraphsExpression += '!';
- sHideParagraphsExpression += sNameColumnBase;
break;
case SwMailMergeConfigItem::NEUTRAL:
sCondition = sNameColumnBase;
diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx
index 72fc1e122a8e..eb1f75d57979 100644
--- a/sw/source/ui/dbui/mmoutputpage.cxx
+++ b/sw/source/ui/dbui/mmoutputpage.cxx
@@ -1000,14 +1000,14 @@ IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG)
}
SfxObjectShell* pObjSh = pTargetView->GetViewFrame()->GetObjectShell();
- SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, pObjSh));
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), pObjSh));
rSh.GetNewDBMgr()->SetMergeType( DBMGR_MERGE_DOCUMENTS );
SfxDispatcher *pDis = pTargetView->GetViewFrame()->GetDispatcher();
SfxBoolItem aMergeSilent(SID_SILENT, sal_False);
m_pWizard->enableButtons(WZB_CANCEL, sal_False);
pDis->Execute(SID_PRINTDOCDIRECT,
SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aMergeSilent, 0L);
- SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, pObjSh));
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), pObjSh));
pTargetView->SetMailMergeConfigItem(0, 0, sal_False);
m_pWizard->enableButtons(WZB_CANCEL, sal_True);