LCOV - code coverage report
Current view: top level - sw/source/ui/dbui - dbinsdlg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1019 0.0 %
Date: 2014-04-14 Functions: 0 39 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "dbinsdlg.hxx"
      21             : 
      22             : #include <float.h>
      23             : 
      24             : #include <hintids.hxx>
      25             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      26             : #include <com/sun/star/container/XNameAccess.hpp>
      27             : #include <com/sun/star/sdbc/XDataSource.hpp>
      28             : #include <com/sun/star/sdbc/XRow.hpp>
      29             : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      30             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      31             : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      32             : #include <com/sun/star/sdb/CommandType.hpp>
      33             : #include <com/sun/star/sdb/XColumn.hpp>
      34             : #include <com/sun/star/sdb/XDatabaseAccess.hpp>
      35             : #include <com/sun/star/sdbc/DataType.hpp>
      36             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      37             : #include <com/sun/star/beans/XPropertySet.hpp>
      38             : #include <com/sun/star/util/NumberFormatter.hpp>
      39             : #include <com/sun/star/util/XNumberFormatTypes.hpp>
      40             : #include <com/sun/star/sdbc/XRowSet.hpp>
      41             : #include <comphelper/processfactory.hxx>
      42             : #include <editeng/langitem.hxx>
      43             : #include <svl/numuno.hxx>
      44             : #include <svl/stritem.hxx>
      45             : #include <vcl/msgbox.hxx>
      46             : #include <vcl/svapp.hxx>
      47             : #include <vcl/mnemonic.hxx>
      48             : #include <svl/style.hxx>
      49             : #include <svl/zformat.hxx>
      50             : #include <sfx2/htmlmode.hxx>
      51             : #include <editeng/unolingu.hxx>
      52             : #include <sfx2/app.hxx>
      53             : #include <svl/itemset.hxx>
      54             : #include <editeng/brushitem.hxx>
      55             : #include <editeng/boxitem.hxx>
      56             : #include <svx/rulritem.hxx>
      57             : #include <swdbtoolsclient.hxx>
      58             : #include <tabledlg.hxx>
      59             : #include <fmtclds.hxx>
      60             : #include <tabcol.hxx>
      61             : #include <uiitems.hxx>
      62             : #include <viewopt.hxx>
      63             : #include <uitool.hxx>
      64             : #include <wrtsh.hxx>
      65             : #include <wview.hxx>
      66             : #include <docsh.hxx>
      67             : #include <dbmgr.hxx>
      68             : #include <tblafmt.hxx>
      69             : #include <cellatr.hxx>
      70             : #include <swtable.hxx>
      71             : #include <dbfld.hxx>
      72             : #include <fmtcol.hxx>
      73             : #include <section.hxx>
      74             : #include <swwait.hxx>
      75             : #include <modcfg.hxx>
      76             : #include <swmodule.hxx>
      77             : #include <poolfmt.hxx>
      78             : #include <crsskip.hxx>
      79             : 
      80             : #include <dbui.hrc>
      81             : 
      82             : #include <cmdid.h>
      83             : #include <helpid.h>
      84             : #include <cfgid.h>
      85             : #include <SwStyleNameMapper.hxx>
      86             : #include <comphelper/uno3.hxx>
      87             : #include "tabsh.hxx"
      88             : #include "swabstdlg.hxx"
      89             : #include "table.hrc"
      90             : #include <unomid.h>
      91             : #include <IDocumentMarkAccess.hxx>
      92             : 
      93             : #include <boost/scoped_ptr.hpp>
      94             : 
      95             : namespace swui
      96             : {
      97             :     SwAbstractDialogFactory * GetFactory();
      98             : }
      99             : 
     100             : using namespace ::com::sun::star;
     101             : using namespace ::com::sun::star::beans;
     102             : using namespace ::com::sun::star::container;
     103             : using namespace ::com::sun::star::lang;
     104             : using namespace ::com::sun::star::sdb;
     105             : using namespace ::com::sun::star::sdbc;
     106             : using namespace ::com::sun::star::sdbcx;
     107             : using namespace ::com::sun::star::uno;
     108             : 
     109             : const char cDBFldStart  = '<';
     110             : const char cDBFldEnd    = '>';
     111             : 
     112             : // Helper structure for adding database rows as fields or text
     113             : struct _DB_Column
     114             : {
     115             :     enum ColType { DB_FILLTEXT, DB_COL_FIELD, DB_COL_TEXT, DB_SPLITPARA } eColType;
     116             : 
     117             :     union {
     118             :         OUString* pText;
     119             :         SwField* pField;
     120             :         sal_uLong nFormat;
     121             :     } DB_ColumnData;
     122             :     const SwInsDBColumn* pColInfo;
     123             : 
     124           0 :     _DB_Column()
     125             :     {
     126           0 :         pColInfo = 0;
     127           0 :         DB_ColumnData.pText = 0;
     128           0 :         eColType = DB_SPLITPARA;
     129           0 :     }
     130             : 
     131           0 :     _DB_Column( const OUString& rTxt )
     132             :     {
     133           0 :         pColInfo = 0;
     134           0 :         DB_ColumnData.pText = new OUString( rTxt );
     135           0 :         eColType = DB_FILLTEXT;
     136           0 :     }
     137             : 
     138           0 :     _DB_Column( const SwInsDBColumn& rInfo, sal_uLong nFormat )
     139             :     {
     140           0 :         pColInfo = &rInfo;
     141           0 :         DB_ColumnData.nFormat = nFormat;
     142           0 :         eColType = DB_COL_TEXT;
     143           0 :     }
     144             : 
     145           0 :     _DB_Column( const SwInsDBColumn& rInfo, SwDBField& rFld )
     146             :     {
     147           0 :         pColInfo = &rInfo;
     148           0 :         DB_ColumnData.pField = &rFld;
     149           0 :         eColType = DB_COL_FIELD;
     150           0 :     }
     151             : 
     152           0 :     ~_DB_Column()
     153             :     {
     154           0 :         if( DB_COL_FIELD == eColType )
     155           0 :             delete DB_ColumnData.pField;
     156           0 :         else if( DB_FILLTEXT == eColType )
     157           0 :             delete DB_ColumnData.pText;
     158           0 :     }
     159             : };
     160             : 
     161             : struct _DB_ColumnConfigData
     162             : {
     163             :     SwInsDBColumns aDBColumns;
     164             :     OUString sSource, sTable, sEdit, sTblList, sTmplNm, sTAutoFmtNm;
     165             :     sal_Bool bIsTable : 1,
     166             :          bIsField : 1,
     167             :          bIsHeadlineOn : 1,
     168             :          bIsEmptyHeadln : 1;
     169             : 
     170           0 :     _DB_ColumnConfigData()
     171           0 :     {
     172           0 :         bIsTable = bIsHeadlineOn = sal_True;
     173           0 :         bIsField = bIsEmptyHeadln = sal_False;
     174           0 :     }
     175             : 
     176             :     ~_DB_ColumnConfigData();
     177             : private:
     178             :     _DB_ColumnConfigData( const _DB_ColumnConfigData& );
     179             :     _DB_ColumnConfigData& operator =( const _DB_ColumnConfigData& );
     180             : };
     181             : 
     182           0 : bool SwInsDBColumn::operator<( const SwInsDBColumn& rCmp ) const
     183             : {
     184           0 :     return 0 > GetAppCollator().compareString( sColumn, rCmp.sColumn );
     185             : }
     186             : 
     187           0 : SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView,
     188             :         Reference<XDataSource> xDataSource,
     189             :         Reference<sdbcx::XColumnsSupplier> xColSupp,
     190             :         const SwDBData& rData )
     191             :     : SfxModalDialog(rView.GetWindow(), "InsertDbColumnsDialog",
     192             :         "modules/swriter/ui/insertdbcolumnsdialog.ui")
     193             :     , ConfigItem("Office.Writer/InsertData/DataSet",
     194             :         CONFIG_MODE_DELAYED_UPDATE)
     195             :     , aDBData(rData)
     196             :     , sNoTmpl(SW_RESSTR(SW_STR_NONE))
     197             :     , pView(&rView)
     198             :     , pTAutoFmt(0)
     199             :     , pTblSet(0)
     200           0 :     , pRep(0)
     201             : {
     202           0 :     get(m_pRbAsTable, "astable");
     203           0 :     get(m_pRbAsField, "asfields");
     204           0 :     get(m_pRbAsText, "astext");
     205           0 :     get(m_pHeadFrame, "dbframe");
     206           0 :     get(m_pLbTblDbColumn, "tabledbcols");
     207           0 :     get(m_pLbTxtDbColumn, "tabletxtcols");
     208           0 :     m_pLbTblDbColumn->SetDropDownLineCount(8);
     209           0 :     m_pLbTxtDbColumn->SetDropDownLineCount(8);
     210           0 :     get(m_pFormatFrame, "formatframe");
     211           0 :     get(m_pRbDbFmtFromDb, "fromdatabase");
     212           0 :     get(m_pRbDbFmtFromUsr, "userdefined");
     213           0 :     get(m_pLbDbFmtFromUsr, "numformat");
     214           0 :     aOldNumFmtLnk = m_pLbDbFmtFromUsr->GetSelectHdl();
     215           0 :     get(m_pIbDbcolToEdit, "toedit");
     216           0 :     get(m_pEdDbText, "textview");
     217           0 :     m_pEdDbText->set_width_request(m_pEdDbText->approximate_char_width() * 46);
     218           0 :     get(m_pFtDbParaColl, "parastylelabel");
     219           0 :     get(m_pLbDbParaColl, "parastyle");
     220           0 :     m_pLbDbParaColl->SetStyle(m_pLbDbParaColl->GetStyle() | WB_SORT);
     221           0 :     get(m_pIbDbcolAllTo, "oneright");
     222           0 :     get(m_pIbDbcolOneTo, "allright");
     223           0 :     get(m_pIbDbcolOneFrom, "oneleft");
     224           0 :     get(m_pIbDbcolAllFrom, "allleft");
     225           0 :     get(m_pFtTableCol, "tablecolft");
     226           0 :     get(m_pLbTableCol, "tablecols");
     227           0 :     m_pLbTableCol->SetDropDownLineCount(8);
     228           0 :     get(m_pCbTableHeadon, "tableheading");
     229           0 :     get(m_pRbHeadlColnms, "columnname");
     230           0 :     get(m_pRbHeadlEmpty, "rowonly");
     231           0 :     get(m_pPbTblFormat, "tableformat");
     232           0 :     get(m_pPbTblAutofmt, "autoformat");
     233             : 
     234           0 :     nGBFmtLen = m_pFormatFrame->get_label().getLength();
     235             : 
     236           0 :     if(xColSupp.is())
     237             :     {
     238           0 :         SwWrtShell& rSh = pView->GetWrtShell();
     239           0 :         SvNumberFormatter* pNumFmtr = rSh.GetNumberFormatter();
     240           0 :         SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj( pNumFmtr );
     241           0 :         Reference< util::XNumberFormatsSupplier >  xDocNumFmtsSupplier = pNumFmt;
     242           0 :         Reference< util::XNumberFormats > xDocNumberFormats = xDocNumFmtsSupplier->getNumberFormats();
     243           0 :         Reference< util::XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
     244             : 
     245           0 :         Reference<XPropertySet> xSourceProps(xDataSource, UNO_QUERY);
     246           0 :         Reference< util::XNumberFormats > xNumberFormats;
     247           0 :         if(xSourceProps.is())
     248             :         {
     249           0 :             Any aFormats = xSourceProps->getPropertyValue("NumberFormatsSupplier");
     250           0 :             if(aFormats.hasValue())
     251             :             {
     252           0 :                 Reference< util::XNumberFormatsSupplier> xSuppl;
     253           0 :                 aFormats >>= xSuppl;
     254           0 :                 if(xSuppl.is())
     255             :                 {
     256           0 :                     xNumberFormats = xSuppl->getNumberFormats(  );
     257           0 :                 }
     258           0 :             }
     259             :         }
     260           0 :         Reference <XNameAccess> xCols = xColSupp->getColumns();
     261           0 :         Sequence<OUString> aColNames = xCols->getElementNames();
     262           0 :         const OUString* pColNames = aColNames.getConstArray();
     263           0 :         long nCount = aColNames.getLength();
     264           0 :         for (long n = 0; n < nCount; n++)
     265             :         {
     266           0 :             SwInsDBColumn* pNew = new SwInsDBColumn( pColNames[n], (sal_uInt16)n );
     267           0 :             Any aCol = xCols->getByName(pColNames[n]);
     268           0 :             Reference <XPropertySet> xCol;
     269           0 :             aCol >>= xCol;
     270           0 :             Any aType = xCol->getPropertyValue("Type");
     271           0 :             sal_Int32 eDataType = 0;
     272           0 :             aType >>= eDataType;
     273           0 :             switch(eDataType)
     274             :             {
     275             :                 case DataType::BIT:
     276             :                 case DataType::BOOLEAN:
     277             :                 case DataType::TINYINT:
     278             :                 case DataType::SMALLINT:
     279             :                 case DataType::INTEGER:
     280             :                 case DataType::BIGINT:
     281             :                 case DataType::FLOAT:
     282             :                 case DataType::REAL:
     283             :                 case DataType::DOUBLE:
     284             :                 case DataType::NUMERIC:
     285             :                 case DataType::DECIMAL:
     286             :                 case DataType::DATE:
     287             :                 case DataType::TIME:
     288             :                 case DataType::TIMESTAMP:
     289             :                 {
     290           0 :                     pNew->bHasFmt = sal_True;
     291           0 :                     Any aFormat = xCol->getPropertyValue("FormatKey");
     292           0 :                     if(aFormat.hasValue())
     293             :                     {
     294           0 :                         sal_Int32 nFmt = 0;
     295           0 :                         aFormat >>= nFmt;
     296           0 :                         if(xNumberFormats.is())
     297             :                         {
     298             :                             try
     299             :                             {
     300           0 :                                 Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFmt );
     301           0 :                                 Any aFormatVal = xNumProps->getPropertyValue("FormatString");
     302           0 :                                 Any aLocale = xNumProps->getPropertyValue("Locale");
     303           0 :                                 OUString sFormat;
     304           0 :                                 aFormatVal >>= sFormat;
     305           0 :                                 lang::Locale aLoc;
     306           0 :                                 aLocale >>= aLoc;
     307           0 :                                 long nKey = xDocNumberFormats->queryKey( sFormat, aLoc, sal_True);
     308           0 :                                 if(nKey < 0)
     309             :                                 {
     310           0 :                                     nKey = xDocNumberFormats->addNew( sFormat, aLoc );
     311             :                                 }
     312           0 :                                 pNew->nDBNumFmt = nKey;
     313             :                             }
     314           0 :                             catch (const Exception&)
     315             :                             {
     316             :                                 OSL_FAIL("illegal number format key");
     317             :                             }
     318             :                         }
     319             :                     }
     320             :                     else
     321             :                     {
     322           0 :                         pNew->nDBNumFmt = SwNewDBMgr::GetDbtoolsClient().getDefaultNumberFormat(xCol,
     323           0 :                                 xDocNumberFormatTypes, LanguageTag( rSh.GetCurLang() ).getLocale());
     324           0 :                     }
     325             : 
     326             :                 }
     327           0 :                 break;
     328             :             }
     329           0 :             if( !aDBColumns.insert( pNew ).second )
     330             :             {
     331             :                 OSL_ENSURE( !this, "Spaltenname mehrfach vergeben?" );
     332           0 :                 delete pNew;
     333             :             }
     334           0 :         }
     335             :     }
     336             : 
     337             :     // fill paragraph templates-ListBox
     338             :     {
     339           0 :         SfxStyleSheetBasePool* pPool = pView->GetDocShell()->GetStyleSheetPool();
     340           0 :         pPool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
     341           0 :         m_pLbDbParaColl->InsertEntry( sNoTmpl );
     342             : 
     343           0 :         const SfxStyleSheetBase* pBase = pPool->First();
     344           0 :         while( pBase )
     345             :         {
     346           0 :             m_pLbDbParaColl->InsertEntry( pBase->GetName() );
     347           0 :             pBase = pPool->Next();
     348             :         }
     349           0 :         m_pLbDbParaColl->SelectEntryPos( 0 );
     350             :     }
     351             : 
     352             :     // when the cursor is inside of a table, table must NEVER be selectable
     353           0 :     if( pView->GetWrtShell().GetTableFmt() )
     354             :     {
     355           0 :         m_pRbAsTable->Enable( false );
     356           0 :         m_pRbAsField->Check( true );
     357           0 :         m_pRbDbFmtFromDb->Check( true );
     358             :     }
     359             :     else
     360             :     {
     361           0 :         m_pRbAsTable->Check( true );
     362           0 :         m_pRbDbFmtFromDb->Check( true );
     363           0 :         m_pIbDbcolOneFrom->Enable( false );
     364           0 :         m_pIbDbcolAllFrom->Enable( false );
     365             :     }
     366             : 
     367           0 :     m_pRbAsTable->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
     368           0 :     m_pRbAsField->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
     369           0 :     m_pRbAsText->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
     370             : 
     371           0 :     m_pRbDbFmtFromDb->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl ));
     372           0 :     m_pRbDbFmtFromUsr->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl ));
     373             : 
     374           0 :     m_pPbTblFormat->SetClickHdl(LINK(this, SwInsertDBColAutoPilot, TblFmtHdl ));
     375           0 :     m_pPbTblAutofmt->SetClickHdl(LINK(this, SwInsertDBColAutoPilot, AutoFmtHdl ));
     376             : 
     377           0 :     m_pIbDbcolAllTo->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
     378           0 :     m_pIbDbcolOneTo->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
     379           0 :     m_pIbDbcolOneFrom->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
     380           0 :     m_pIbDbcolAllFrom->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
     381           0 :     m_pIbDbcolToEdit->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
     382             : 
     383           0 :     m_pCbTableHeadon->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl ));
     384           0 :     m_pRbHeadlColnms->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl ));
     385           0 :     m_pRbHeadlEmpty->SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl ));
     386             : 
     387           0 :     m_pLbTxtDbColumn->SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
     388           0 :     m_pLbTblDbColumn->SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
     389           0 :     m_pLbDbFmtFromUsr->SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
     390           0 :     m_pLbTableCol->SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
     391             : 
     392           0 :     m_pLbTxtDbColumn->SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
     393           0 :     m_pLbTblDbColumn->SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
     394           0 :     m_pLbTableCol->SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
     395             : 
     396           0 :     for( sal_uInt16 n = 0; n < aDBColumns.size(); ++n )
     397             :     {
     398           0 :         const OUString& rS = aDBColumns[ n ]->sColumn;
     399           0 :         m_pLbTblDbColumn->InsertEntry( rS, n );
     400           0 :         m_pLbTxtDbColumn->InsertEntry( rS, n );
     401             :     }
     402           0 :     m_pLbTxtDbColumn->SelectEntryPos( 0 );
     403           0 :     m_pLbTblDbColumn->SelectEntryPos( 0 );
     404             : 
     405             :     // read configuration
     406           0 :     Load();
     407             : 
     408             :     // lock size to widest config
     409           0 :     m_pHeadFrame->set_width_request(m_pHeadFrame->get_preferred_size().Width());
     410             :     // initialise Controls:
     411           0 :     PageHdl( m_pRbAsTable->IsChecked() ? m_pRbAsTable : m_pRbAsField );
     412           0 : }
     413             : 
     414           0 : SwInsertDBColAutoPilot::~SwInsertDBColAutoPilot()
     415             : {
     416           0 :     delete pTblSet;
     417           0 :     delete pRep;
     418             : 
     419           0 :     delete pTAutoFmt;
     420           0 : }
     421             : 
     422           0 : IMPL_LINK( SwInsertDBColAutoPilot, PageHdl, Button*, pButton )
     423             : {
     424           0 :     bool bShowTbl = pButton == m_pRbAsTable;
     425             : 
     426           0 :     OUString sTxt(pButton->GetText());
     427           0 :     m_pHeadFrame->set_label(MnemonicGenerator::EraseAllMnemonicChars(sTxt));
     428             : 
     429           0 :     m_pLbTxtDbColumn->Show( !bShowTbl );
     430           0 :     m_pIbDbcolToEdit->Show( !bShowTbl );
     431           0 :     m_pEdDbText->Show( !bShowTbl );
     432           0 :     m_pFtDbParaColl->Show( !bShowTbl );
     433           0 :     m_pLbDbParaColl->Show( !bShowTbl );
     434             : 
     435           0 :     m_pLbTblDbColumn->Show( bShowTbl );
     436           0 :     m_pIbDbcolAllTo->Show( bShowTbl );
     437           0 :     m_pIbDbcolOneTo->Show( bShowTbl );
     438           0 :     m_pIbDbcolOneFrom->Show( bShowTbl );
     439           0 :     m_pIbDbcolAllFrom->Show( bShowTbl );
     440           0 :     m_pFtTableCol->Show( bShowTbl );
     441           0 :     m_pLbTableCol->Show( bShowTbl );
     442           0 :     m_pCbTableHeadon->Show( bShowTbl );
     443           0 :     m_pRbHeadlColnms->Show( bShowTbl );
     444           0 :     m_pRbHeadlEmpty->Show( bShowTbl );
     445           0 :     m_pPbTblFormat->Show( bShowTbl );
     446           0 :     m_pPbTblAutofmt->Show( bShowTbl );
     447             : 
     448           0 :     if( bShowTbl )
     449           0 :         m_pPbTblFormat->Enable( 0 != m_pLbTableCol->GetEntryCount() );
     450             : 
     451           0 :     SelectHdl( bShowTbl ? m_pLbTblDbColumn : m_pLbTxtDbColumn );
     452             : 
     453           0 :     return 0;
     454             : }
     455             : 
     456           0 : IMPL_LINK( SwInsertDBColAutoPilot, DBFormatHdl, Button*, pButton )
     457             : {
     458           0 :     ListBox& rBox = m_pRbAsTable->IsChecked()
     459           0 :                         ? ( 0 == m_pLbTableCol->GetEntryData( 0 )
     460             :                             ? *m_pLbTblDbColumn
     461             :                             : *m_pLbTableCol )
     462           0 :                         : *m_pLbTxtDbColumn;
     463             : 
     464           0 :     SwInsDBColumn aSrch( rBox.GetSelectEntry(), 0 );
     465           0 :     SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch );
     466             : 
     467           0 :     sal_Bool bFromDB = m_pRbDbFmtFromDb == pButton;
     468           0 :     (*it)->bIsDBFmt = bFromDB;
     469           0 :     m_pLbDbFmtFromUsr->Enable( !bFromDB );
     470             : 
     471           0 :     return 0;
     472             : }
     473             : 
     474           0 : IMPL_LINK( SwInsertDBColAutoPilot, TblToFromHdl, Button*, pButton )
     475             : {
     476           0 :     sal_Bool bChgEnable = sal_True, bEnableTo = sal_True, bEnableFrom = sal_True;
     477           0 :     m_pLbTblDbColumn->SetUpdateMode( false );
     478           0 :     m_pLbTableCol->SetUpdateMode( false );
     479             : 
     480           0 :     if( pButton == m_pIbDbcolAllTo )
     481             :     {
     482           0 :         bEnableTo = sal_False;
     483             : 
     484           0 :         sal_Int32 n, nInsPos = m_pLbTableCol->GetSelectEntryPos(),
     485           0 :                nCnt = m_pLbTblDbColumn->GetEntryCount();
     486           0 :         if( LISTBOX_APPEND == nInsPos )
     487           0 :             for( n = 0; n < nCnt; ++n )
     488             :                 m_pLbTableCol->InsertEntry( m_pLbTblDbColumn->GetEntry( n ),
     489           0 :                                             LISTBOX_APPEND );
     490             :         else
     491           0 :             for( n = 0; n < nCnt; ++n, ++nInsPos )
     492           0 :                 m_pLbTableCol->InsertEntry( m_pLbTblDbColumn->GetEntry( n ), nInsPos );
     493           0 :         m_pLbTblDbColumn->Clear();
     494           0 :         m_pLbTableCol->SelectEntryPos( nInsPos );
     495           0 :         m_pLbTblDbColumn->SelectEntryPos( LISTBOX_APPEND );
     496             :     }
     497           0 :     else if( pButton == m_pIbDbcolOneTo &&
     498           0 :             LISTBOX_ENTRY_NOTFOUND != m_pLbTblDbColumn->GetSelectEntryPos() )
     499             :     {
     500           0 :         sal_Int32 nInsPos = m_pLbTableCol->GetSelectEntryPos(),
     501           0 :                nDelPos = m_pLbTblDbColumn->GetSelectEntryPos(),
     502           0 :                nTopPos = m_pLbTblDbColumn->GetTopEntry();
     503           0 :         m_pLbTableCol->InsertEntry( m_pLbTblDbColumn->GetEntry( nDelPos ), nInsPos );
     504           0 :         m_pLbTblDbColumn->RemoveEntry( nDelPos );
     505             : 
     506           0 :         m_pLbTableCol->SelectEntryPos( nInsPos );
     507           0 :         if( nDelPos >= m_pLbTblDbColumn->GetEntryCount() )
     508           0 :             nDelPos = m_pLbTblDbColumn->GetEntryCount() - 1;
     509           0 :         m_pLbTblDbColumn->SelectEntryPos( nDelPos );
     510           0 :         m_pLbTblDbColumn->SetTopEntry( nTopPos );
     511             : 
     512           0 :         bEnableTo = 0 != m_pLbTblDbColumn->GetEntryCount();
     513             :     }
     514           0 :     else if( pButton == m_pIbDbcolOneFrom )
     515             :     {
     516           0 :         if( LISTBOX_ENTRY_NOTFOUND != m_pLbTableCol->GetSelectEntryPos() )
     517             :         {
     518             :             sal_Int32 nInsPos,
     519           0 :                     nDelPos = m_pLbTableCol->GetSelectEntryPos(),
     520           0 :                     nTopPos = m_pLbTableCol->GetTopEntry();
     521             : 
     522             :             // look for the right InsertPos!!
     523           0 :             SwInsDBColumn aSrch( m_pLbTableCol->GetEntry( nDelPos ), 0 );
     524           0 :             SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch );
     525           0 :             if( it == aDBColumns.begin() || (it+1) == aDBColumns.end() )
     526           0 :                 nInsPos = it - aDBColumns.begin();
     527             :             else
     528             :             {
     529           0 :                 nInsPos = LISTBOX_ENTRY_NOTFOUND;
     530           0 :                 while( ++it != aDBColumns.end() &&
     531             :                         LISTBOX_ENTRY_NOTFOUND == (nInsPos = m_pLbTblDbColumn->
     532           0 :                         GetEntryPos( OUString( (*it)->sColumn ))) )
     533             :                     ;
     534             :             }
     535             : 
     536           0 :             m_pLbTblDbColumn->InsertEntry( aSrch.sColumn, nInsPos );
     537           0 :             m_pLbTableCol->RemoveEntry( nDelPos );
     538             : 
     539           0 :             if( nInsPos >= m_pLbTblDbColumn->GetEntryCount() )
     540           0 :                 nInsPos = m_pLbTblDbColumn->GetEntryCount() - 1;
     541           0 :             m_pLbTblDbColumn->SelectEntryPos( nInsPos );
     542             : 
     543           0 :             if( nDelPos >= m_pLbTableCol->GetEntryCount() )
     544           0 :                 nDelPos = m_pLbTableCol->GetEntryCount() - 1;
     545           0 :             m_pLbTableCol->SelectEntryPos( nDelPos );
     546           0 :             m_pLbTableCol->SetTopEntry( nTopPos );
     547             :         }
     548             :         else
     549           0 :             bEnableTo = 0 != m_pLbTblDbColumn->GetEntryCount();
     550             : 
     551           0 :         bEnableFrom = 0 != m_pLbTableCol->GetEntryCount();
     552             :     }
     553           0 :     else if( pButton == m_pIbDbcolAllFrom )
     554             :     {
     555           0 :         bEnableFrom = sal_False;
     556             : 
     557           0 :         m_pLbTblDbColumn->Clear();
     558           0 :         m_pLbTableCol->Clear();
     559           0 :         for( sal_uInt16 n = 0; n < aDBColumns.size(); ++n )
     560           0 :             m_pLbTblDbColumn->InsertEntry( aDBColumns[ n ]->sColumn, n );
     561           0 :         m_pLbTblDbColumn->SelectEntryPos( 0 );
     562             :     }
     563           0 :     else if( pButton == m_pIbDbcolToEdit )
     564             :     {
     565           0 :         bChgEnable = sal_False;
     566             :         // move data to Edit:
     567           0 :         OUString aFld( m_pLbTxtDbColumn->GetSelectEntry() );
     568           0 :         if( !aFld.isEmpty() )
     569             :         {
     570           0 :             OUString aStr( m_pEdDbText->GetText() );
     571           0 :             sal_uInt16 nPos = (sal_uInt16)m_pEdDbText->GetSelection().Min();
     572           0 :             sal_uInt16 nSel = sal_uInt16(m_pEdDbText->GetSelection().Max()) - nPos;
     573           0 :             if( nSel )
     574             :                 // first delete the existing selection
     575           0 :                 aStr = aStr.replaceAt( nPos, nSel, "" );
     576             : 
     577           0 :             aFld = OUString(cDBFldStart) + aFld + OUString(cDBFldEnd);
     578           0 :             if( !aStr.isEmpty() )
     579             :             {
     580           0 :                 if( nPos )                          // one blank in front
     581             :                 {
     582           0 :                     sal_Unicode c = aStr[ nPos-1 ];
     583           0 :                     if( '\n' != c && '\r' != c )
     584           0 :                         aFld = " " + aFld;
     585             :                 }
     586           0 :                 if( nPos < aStr.getLength() )             // one blank behind
     587             :                 {
     588           0 :                     sal_Unicode c = aStr[ nPos ];
     589           0 :                     if( '\n' != c && '\r' != c )
     590           0 :                         aFld += " ";
     591             :                 }
     592             :             }
     593             : 
     594           0 :             aStr = aStr.replaceAt( nPos, 0, aFld );
     595           0 :             m_pEdDbText->SetText( aStr );
     596           0 :             nPos = nPos + aFld.getLength();
     597           0 :             m_pEdDbText->SetSelection( Selection( nPos ));
     598           0 :         }
     599             :     }
     600             : 
     601           0 :     if( bChgEnable )
     602             :     {
     603           0 :         m_pIbDbcolOneTo->Enable( bEnableTo );
     604           0 :         m_pIbDbcolAllTo->Enable( bEnableTo );
     605           0 :         m_pIbDbcolOneFrom->Enable( bEnableFrom );
     606           0 :         m_pIbDbcolAllFrom->Enable( bEnableFrom );
     607             : 
     608           0 :         m_pRbDbFmtFromDb->Enable( false );
     609           0 :         m_pRbDbFmtFromUsr->Enable( false );
     610           0 :         m_pLbDbFmtFromUsr->Enable( false );
     611             : 
     612           0 :         m_pPbTblFormat->Enable( bEnableFrom );
     613             :     }
     614           0 :     m_pLbTblDbColumn->SetUpdateMode( true );
     615           0 :     m_pLbTableCol->SetUpdateMode( true );
     616             : 
     617           0 :     return 0;
     618             : }
     619             : 
     620           0 : IMPL_LINK( SwInsertDBColAutoPilot, DblClickHdl, ListBox*, pBox )
     621             : {
     622           0 :     Button* pButton = 0;
     623           0 :     if( pBox == m_pLbTxtDbColumn )
     624           0 :         pButton = m_pIbDbcolToEdit;
     625           0 :     else if( pBox == m_pLbTblDbColumn && m_pIbDbcolOneTo->IsEnabled() )
     626           0 :         pButton = m_pIbDbcolOneTo;
     627           0 :     else if( pBox == m_pLbTableCol && m_pIbDbcolOneFrom->IsEnabled() )
     628           0 :         pButton = m_pIbDbcolOneFrom;
     629             : 
     630           0 :     if( pButton )
     631           0 :         TblToFromHdl( pButton );
     632             : 
     633           0 :     return 0;
     634             : }
     635             : 
     636           0 : IMPL_LINK( SwInsertDBColAutoPilot, TblFmtHdl, PushButton*, pButton )
     637             : {
     638           0 :     SwWrtShell& rSh = pView->GetWrtShell();
     639           0 :     bool bNewSet = false;
     640           0 :     if( !pTblSet )
     641             :     {
     642           0 :         bNewSet = true;
     643           0 :         pTblSet = new SfxItemSet( rSh.GetAttrPool(), SwuiGetUITableAttrRange() );
     644             : 
     645             :         // At first acquire the simple attributes
     646           0 :         pTblSet->Put( SfxStringItem( FN_PARAM_TABLE_NAME, rSh.GetUniqueTblName() ));
     647           0 :         pTblSet->Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, 1 ) );
     648             : 
     649             :         pTblSet->Put( SfxUInt16Item( SID_BACKGRND_DESTINATION,
     650           0 :                                     rSh.GetViewOptions()->GetTblDest() ));
     651             : 
     652           0 :         SvxBrushItem aBrush( RES_BACKGROUND );
     653           0 :         pTblSet->Put( aBrush );
     654           0 :         pTblSet->Put( aBrush, SID_ATTR_BRUSH_ROW );
     655           0 :         pTblSet->Put( aBrush, SID_ATTR_BRUSH_TABLE );
     656             : 
     657           0 :         SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
     658             :             // table variant, when multiple table cells are selected
     659           0 :         aBoxInfo.SetTable( true );
     660             :             // always show gap field
     661           0 :         aBoxInfo.SetDist( true);
     662             :             // set minimum size in tables and paragraphs
     663           0 :         aBoxInfo.SetMinDist( false );
     664             :             // always set default-gap
     665           0 :         aBoxInfo.SetDefDist( MIN_BORDER_DIST );
     666             :             // Single lines can have DontCare-status only in tables
     667           0 :         aBoxInfo.SetValid( VALID_DISABLE, true );
     668           0 :         pTblSet->Put( aBoxInfo );
     669             : 
     670           0 :         SwGetCurColNumPara aPara;
     671           0 :         const sal_uInt16 nNum = rSh.GetCurColNum( &aPara );
     672             :         long nWidth;
     673             : 
     674           0 :         if( nNum )
     675             :         {
     676           0 :             nWidth = aPara.pPrtRect->Width();
     677           0 :             const SwFmtCol& rCol = aPara.pFrmFmt->GetCol();
     678           0 :             const SwColumns& rCols = rCol.GetColumns();
     679             : 
     680             :             // initialise nStart und nEnd for nNum == 0
     681           0 :             long nWidth1 = 0,
     682           0 :                 nStart1 = 0,
     683           0 :                 nEnd1 = nWidth;
     684           0 :             for( sal_uInt16 i = 0; i < nNum; ++i )
     685             :             {
     686           0 :                 const SwColumn* pCol = &rCols[i];
     687           0 :                 nStart1 = pCol->GetLeft() + nWidth1;
     688           0 :                 nWidth1 += (long)rCol.CalcColWidth( i, (sal_uInt16)nWidth );
     689           0 :                 nEnd1 = nWidth1 - pCol->GetRight();
     690             :             }
     691           0 :             if(nStart1 || nEnd1 != nWidth)
     692           0 :                 nWidth = nEnd1 - nStart1;
     693             :         }
     694             :         else
     695             :             nWidth = rSh.GetAnyCurRect(
     696           0 :                                 FRMTYPE_FLY_ANY & rSh.GetFrmType( 0, sal_True )
     697             :                                               ? RECT_FLY_PRT_EMBEDDED
     698           0 :                                               : RECT_PAGE_PRT ).Width();
     699             : 
     700           0 :         SwTabCols aTabCols;
     701           0 :         aTabCols.SetRight( nWidth );
     702           0 :         aTabCols.SetRightMax( nWidth );
     703           0 :         pRep = new SwTableRep( aTabCols );
     704           0 :         pRep->SetAlign( text::HoriOrientation::NONE );
     705           0 :         pRep->SetSpace( nWidth );
     706           0 :         pRep->SetWidth( nWidth );
     707           0 :         pRep->SetWidthPercent( 100 );
     708           0 :         pTblSet->Put( SwPtrItem( FN_TABLE_REP, pRep ));
     709             : 
     710             :         pTblSet->Put( SfxUInt16Item( SID_HTML_MODE,
     711           0 :                     ::GetHtmlMode( pView->GetDocShell() )));
     712             :     }
     713             : 
     714           0 :     if( m_pLbTableCol->GetEntryCount() != pRep->GetAllColCount() )
     715             :     {
     716             :         // Number of columns has changed: then the TabCols have to be adjusted
     717           0 :         long nWidth = pRep->GetWidth();
     718           0 :         sal_Int32 nCols = m_pLbTableCol->GetEntryCount() - 1;
     719           0 :         SwTabCols aTabCols( nCols );
     720           0 :         aTabCols.SetRight( nWidth  );
     721           0 :         aTabCols.SetRightMax( nWidth );
     722           0 :         if( nCols )
     723           0 :             for( sal_uInt16 n = 0, nStep = (sal_uInt16)(nWidth / (nCols+1)), nW = nStep;
     724           0 :                     n < nCols; ++n, nW = nW + nStep )
     725             :             {
     726           0 :                 aTabCols.Insert( nW, sal_False, n );
     727             :             }
     728           0 :         delete pRep;
     729           0 :         pRep = new SwTableRep( aTabCols );
     730           0 :         pRep->SetAlign( text::HoriOrientation::NONE );
     731           0 :         pRep->SetSpace( nWidth );
     732           0 :         pRep->SetWidth( nWidth );
     733           0 :         pRep->SetWidthPercent( 100 );
     734           0 :         pTblSet->Put( SwPtrItem( FN_TABLE_REP, pRep ));
     735             :     }
     736             : 
     737           0 :     SwAbstractDialogFactory* pFact = swui::GetFactory();
     738             :     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     739             : 
     740           0 :     boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTableTabDlg(pButton, rSh.GetAttrPool(), pTblSet, &rSh));
     741             :     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     742           0 :     if( RET_OK == pDlg->Execute() )
     743           0 :         pTblSet->Put( *pDlg->GetOutputItemSet() );
     744           0 :     else if( bNewSet )
     745             :     {
     746           0 :         delete pTblSet, pTblSet = 0;
     747           0 :         delete pRep, pRep = 0;
     748             :     }
     749             : 
     750           0 :     return 0;
     751             : }
     752             : 
     753           0 : IMPL_LINK( SwInsertDBColAutoPilot, AutoFmtHdl, PushButton*, pButton )
     754             : {
     755           0 :     SwAbstractDialogFactory* pFact = swui::GetFactory();
     756             :     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     757             : 
     758           0 :     boost::scoped_ptr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(pButton, pView->GetWrtShellPtr(), sal_False, pTAutoFmt));
     759             :     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     760           0 :     if( RET_OK == pDlg->Execute())
     761           0 :         pDlg->FillAutoFmtOfIndex( pTAutoFmt );
     762           0 :     return 0;
     763             : }
     764             : 
     765           0 : IMPL_LINK( SwInsertDBColAutoPilot, SelectHdl, ListBox*, pBox )
     766             : {
     767           0 :     ListBox* pGetBox = pBox == m_pLbDbFmtFromUsr
     768           0 :                             ? ( m_pRbAsTable->IsChecked()
     769           0 :                                     ? ( 0 == m_pLbTableCol->GetEntryData( 0 )
     770             :                                         ? m_pLbTblDbColumn
     771             :                                         : m_pLbTableCol )
     772             :                                     : m_pLbTxtDbColumn )
     773           0 :                             : pBox;
     774             : 
     775           0 :     SwInsDBColumn aSrch( pGetBox->GetSelectEntry(), 0 );
     776           0 :     SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch );
     777             : 
     778           0 :     if( pBox == m_pLbDbFmtFromUsr )
     779             :     {
     780           0 :         if( !aSrch.sColumn.isEmpty() )
     781             :         {
     782           0 :             aOldNumFmtLnk.Call( pBox );
     783           0 :             (*it)->nUsrNumFmt = m_pLbDbFmtFromUsr->GetFormat();
     784             :         }
     785             :     }
     786             :     else
     787             :     {
     788             :         // set the selected FieldName at the FormatGroupBox, so that
     789             :         // it's clear what field is configured by the format!
     790           0 :         OUString sTxt( m_pFormatFrame->get_label().copy( 0, nGBFmtLen ));
     791           0 :         if( aSrch.sColumn.isEmpty() )
     792             :         {
     793           0 :             m_pRbDbFmtFromDb->Enable( false );
     794           0 :             m_pRbDbFmtFromUsr->Enable( false );
     795           0 :             m_pLbDbFmtFromUsr->Enable( false );
     796             :         }
     797             :         else
     798             :         {
     799           0 :             sal_Bool bEnableFmt = (*it)->bHasFmt;
     800           0 :             m_pRbDbFmtFromDb->Enable( bEnableFmt );
     801           0 :             m_pRbDbFmtFromUsr->Enable( bEnableFmt );
     802             : 
     803           0 :             if( bEnableFmt )
     804             :             {
     805           0 :                 sTxt = sTxt + " ("  + aSrch.sColumn + ")";
     806             :             }
     807             : 
     808           0 :             sal_Bool bIsDBFmt = (*it)->bIsDBFmt;
     809           0 :             m_pRbDbFmtFromDb->Check( bIsDBFmt );
     810           0 :             m_pRbDbFmtFromUsr->Check( !bIsDBFmt );
     811           0 :             m_pLbDbFmtFromUsr->Enable( !bIsDBFmt );
     812           0 :             if( !bIsDBFmt )
     813           0 :                 m_pLbDbFmtFromUsr->SetDefFormat( (*it)->nUsrNumFmt );
     814             :         }
     815             : 
     816           0 :         m_pFormatFrame->set_label(sTxt);
     817             : 
     818             :         // to know later on, what ListBox was the "active", a Flag
     819             :         // is remembered in the 1st entry
     820           0 :         void* pPtr = pBox == m_pLbTableCol ? m_pLbTableCol : 0;
     821           0 :         m_pLbTableCol->SetEntryData( 0, pPtr );
     822             :     }
     823           0 :     return 0;
     824             : }
     825             : 
     826           0 : IMPL_LINK( SwInsertDBColAutoPilot, HeaderHdl, Button*, pButton )
     827             : {
     828           0 :     if( pButton == m_pCbTableHeadon )
     829             :     {
     830           0 :         sal_Bool bEnable = m_pCbTableHeadon->IsChecked();
     831             : 
     832           0 :         m_pRbHeadlColnms->Enable( bEnable );
     833           0 :         m_pRbHeadlEmpty->Enable( bEnable );
     834             :     }
     835           0 :     return 0;
     836             : }
     837             : 
     838           0 : static void lcl_InsTextInArr( const OUString& rTxt, _DB_Columns& rColArr )
     839             : {
     840             :     _DB_Column* pNew;
     841           0 :     sal_Int32 nSttPos = 0, nFndPos;
     842           0 :     while( -1 != ( nFndPos = rTxt.indexOf( '\x0A', nSttPos )) )
     843             :     {
     844           0 :         if( 1 < nFndPos )
     845             :         {
     846           0 :             pNew = new _DB_Column( rTxt.copy( nSttPos, nFndPos -1 ) );
     847           0 :             rColArr.push_back( pNew );
     848             :         }
     849           0 :         pNew = new _DB_Column;
     850           0 :         rColArr.push_back( pNew );
     851           0 :         nSttPos = nFndPos + 1;
     852             :     }
     853           0 :     if( nSttPos < rTxt.getLength() )
     854             :     {
     855           0 :         pNew = new _DB_Column( rTxt.copy( nSttPos ) );
     856           0 :         rColArr.push_back( pNew );
     857             :     }
     858           0 : }
     859             : 
     860           0 : bool SwInsertDBColAutoPilot::SplitTextToColArr( const OUString& rTxt,
     861             :                                 _DB_Columns& rColArr,
     862             :                                 sal_Bool bInsField )
     863             : {
     864             :     // create each of the database columns from the text again
     865             :     // and then save in an array
     866             :     // database columns are in <> and must be present in the columns' array:
     867           0 :     OUString sTxt( rTxt );
     868           0 :     sal_Int32 nFndPos, nEndPos, nSttPos = 0;
     869             : 
     870           0 :     while( -1 != ( nFndPos = sTxt.indexOf( cDBFldStart, nSttPos )))
     871             :     {
     872           0 :         nSttPos = nFndPos + 1;
     873           0 :         if( -1 != ( nEndPos = sTxt.indexOf( cDBFldEnd, nSttPos+1 )))
     874             :         {
     875             :             // Text in <> brackets found: what is it:
     876           0 :             SwInsDBColumn aSrch( sTxt.copy( nSttPos, nEndPos - nSttPos ), 0);
     877           0 :             SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch );
     878           0 :             if( it != aDBColumns.end() )
     879             :             {
     880             :                 // that is a valid field
     881             :                 // so surely the text "before":
     882           0 :                 const SwInsDBColumn& rFndCol = **it;
     883             : 
     884             :                 _DB_Column* pNew;
     885             : 
     886           0 :                 if( 1 < nSttPos )
     887             :                 {
     888           0 :                     ::lcl_InsTextInArr( sTxt.copy( 0, nSttPos-1 ), rColArr );
     889           0 :                     sTxt = sTxt.copy( nSttPos-1 );
     890             :                 }
     891             : 
     892           0 :                 sTxt = sTxt.copy( rFndCol.sColumn.getLength() + 2 );
     893           0 :                 nSttPos = 0;
     894             : 
     895           0 :                 sal_uInt16 nSubType = 0;
     896             :                 sal_uLong nFormat;
     897           0 :                 if( rFndCol.bHasFmt )
     898             :                 {
     899           0 :                     if( rFndCol.bIsDBFmt )
     900           0 :                         nFormat =  rFndCol.nDBNumFmt;
     901             :                     else
     902             :                     {
     903           0 :                         nFormat = rFndCol.nUsrNumFmt;
     904           0 :                         nSubType = nsSwExtendedSubType::SUB_OWN_FMT;
     905             :                     }
     906             :                 }
     907             :                 else
     908           0 :                     nFormat = 0;
     909             : 
     910           0 :                 if( bInsField )
     911             :                 {
     912           0 :                     SwWrtShell& rSh = pView->GetWrtShell();
     913             :                     SwDBFieldType aFldType( rSh.GetDoc(), aSrch.sColumn,
     914           0 :                                             aDBData );
     915             :                     pNew = new _DB_Column( rFndCol, *new SwDBField(
     916           0 :                             (SwDBFieldType*)rSh.InsertFldType( aFldType ),
     917           0 :                                                             nFormat ) );
     918           0 :                     if( nSubType )
     919           0 :                         pNew->DB_ColumnData.pField->SetSubType( nSubType );
     920             :                 }
     921             :                 else
     922           0 :                     pNew = new _DB_Column( rFndCol, nFormat );
     923             : 
     924           0 :                 rColArr.push_back( pNew );
     925           0 :             }
     926             :         }
     927             :     }
     928             : 
     929             :     // don't forget the last text
     930           0 :     if( !sTxt.isEmpty() )
     931           0 :         ::lcl_InsTextInArr( sTxt, rColArr );
     932             : 
     933           0 :     return !rColArr.empty();
     934             : }
     935             : 
     936           0 : void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
     937             :     Reference< XDataSource> xSource,
     938             :     Reference< XConnection> xConnection,
     939             :     Reference< sdbc::XResultSet > xResultSet )
     940             : {
     941           0 :     const Any* pSelection = rSelection.getLength() ? rSelection.getConstArray() : 0;
     942           0 :     SwWrtShell& rSh = pView->GetWrtShell();
     943             : 
     944             :     //with the drag and drop interface no result set is initially available
     945           0 :     sal_Bool bDisposeResultSet = sal_False;
     946             :     // we don't have a cursor, so we have to create our own RowSet
     947           0 :     if ( !xResultSet.is() )
     948             :     {
     949           0 :         xResultSet = SwNewDBMgr::createCursor(aDBData.sDataSource,aDBData.sCommand,aDBData.nCommandType,xConnection);
     950           0 :         bDisposeResultSet = xResultSet.is();
     951             :     }
     952             : 
     953           0 :     Reference< sdbc::XRow > xRow(xResultSet, UNO_QUERY);
     954           0 :     if ( !xRow.is() )
     955           0 :         return;
     956             : 
     957           0 :     rSh.StartAllAction();
     958           0 :     sal_Bool bUndo = rSh.DoesUndo();
     959           0 :     if( bUndo )
     960           0 :         rSh.StartUndo( UNDO_EMPTY );
     961             : 
     962           0 :     sal_Bool bAsTable = m_pRbAsTable->IsChecked();
     963           0 :     SvNumberFormatter& rNumFmtr = *rSh.GetNumberFormatter();
     964             : 
     965           0 :     if( rSh.HasSelection() )
     966           0 :         rSh.DelRight();
     967             : 
     968           0 :     boost::scoped_ptr<SwWait> pWait;
     969             : 
     970           0 :     Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
     971           0 :     Reference <XNameAccess> xCols = xColsSupp->getColumns();
     972             : 
     973             :     do{                                 // middle checked loop!!
     974           0 :     if( bAsTable )          // Daten als Tabelle einfuegen
     975             :     {
     976           0 :         rSh.DoUndo( sal_False );
     977             : 
     978           0 :         sal_Int32 nCols = m_pLbTableCol->GetEntryCount();
     979           0 :         sal_uInt16 nRows = 0;
     980           0 :         if( m_pCbTableHeadon->IsChecked() )
     981           0 :             nRows++;
     982             : 
     983           0 :         if( pSelection )
     984           0 :             nRows = nRows + (sal_uInt16)rSelection.getLength();
     985             :         else
     986           0 :             ++nRows;
     987             : 
     988             :         // prepare the array for the selected columns
     989           0 :         std::vector<SwInsDBColumn*> aColFlds;
     990           0 :         for( sal_Int32 n = 0; n < nCols; ++n )
     991             :         {
     992           0 :             SwInsDBColumn aSrch( m_pLbTableCol->GetEntry( n ), 0 );
     993           0 :             SwInsDBColumns::const_iterator it = aDBColumns.find( &aSrch );
     994           0 :             if (it != aDBColumns.end())
     995           0 :                 aColFlds.push_back(*it);
     996             :             else {
     997             :                 OSL_ENSURE( !this, "database column not found" );
     998             :             }
     999           0 :         }
    1000             : 
    1001           0 :         if( static_cast<size_t>(nCols) != aColFlds.size() )
    1002             :         {
    1003             :             OSL_ENSURE( !this, "not all database columns found" );
    1004           0 :             nCols = static_cast<sal_Int32>(aColFlds.size());
    1005             :         }
    1006             : 
    1007           0 :         if(!nRows || !nCols)
    1008             :         {
    1009             :             OSL_ENSURE( !this, "wrong parameters" );
    1010           0 :             break;
    1011             :         }
    1012             : 
    1013           0 :         const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
    1014             : 
    1015           0 :         sal_Bool bHTML = 0 != (::GetHtmlMode( pView->GetDocShell() ) & HTMLMODE_ON);
    1016             :         rSh.InsertTable(
    1017           0 :             pModOpt->GetInsTblFlags(bHTML),
    1018           0 :             nRows, nCols, text::HoriOrientation::FULL, (pSelection ? pTAutoFmt : 0) );
    1019           0 :         rSh.MoveTable( GetfnTablePrev(), GetfnTableStart() );
    1020             : 
    1021           0 :         if( pSelection && pTblSet )
    1022           0 :             SetTabSet();
    1023             : 
    1024           0 :         SfxItemSet aTblSet( rSh.GetAttrPool(), RES_BOXATR_FORMAT,
    1025           0 :                                                 RES_BOXATR_VALUE );
    1026           0 :         sal_Bool bIsAutoUpdateCells = rSh.IsAutoUpdateCells();
    1027           0 :         rSh.SetAutoUpdateCells( sal_False );
    1028             : 
    1029           0 :         if( m_pCbTableHeadon->IsChecked() )
    1030             :         {
    1031           0 :             for( sal_Int32 n = 0; n < nCols; ++n )
    1032             :             {
    1033           0 :                 if( m_pRbHeadlColnms->IsChecked() )
    1034             :                 {
    1035           0 :                     rSh.SwEditShell::Insert2( aColFlds[ n ]->sColumn );
    1036             :                 }
    1037           0 :                 rSh.GoNextCell();
    1038             :             }
    1039             :         }
    1040             :         else
    1041           0 :             rSh.SetRowsToRepeat( 0 );
    1042             : 
    1043           0 :         for( sal_Int32 i = 0 ; ; ++i )
    1044             :         {
    1045           0 :             bool bBreak = false;
    1046             :             try
    1047             :             {
    1048           0 :                 if(pSelection)
    1049             :                 {
    1050           0 :                     sal_Int32 nPos = 0;
    1051           0 :                     pSelection[i] >>= nPos;
    1052           0 :                     bBreak = !xResultSet->absolute(nPos);
    1053             :                 }
    1054           0 :                 else if(!i)
    1055           0 :                     bBreak = !xResultSet->first();
    1056             :             }
    1057           0 :             catch (const Exception&)
    1058             :             {
    1059           0 :                 bBreak = true;
    1060             :             }
    1061           0 :             if(bBreak)
    1062           0 :                 break;
    1063             : 
    1064           0 :             for( sal_Int32 n = 0; n < nCols; ++n )
    1065             :             {
    1066             :                 // at the very first time, NO GoNextCell, because we're
    1067             :                 // already in it. Also no GoNextCell after the Insert,
    1068             :                 // because an empty line is added at the end.
    1069           0 :                 if( i || n )
    1070           0 :                     rSh.GoNextCell();
    1071             : 
    1072           0 :                 const SwInsDBColumn* pEntry = aColFlds[ n ];
    1073             : 
    1074           0 :                 Reference< XColumn > xColumn;
    1075           0 :                 xCols->getByName(pEntry->sColumn) >>= xColumn;
    1076           0 :                 Reference< XPropertySet > xColumnProps( xColumn, UNO_QUERY );
    1077           0 :                 sal_Int32 eDataType = 0;
    1078           0 :                 if( xColumnProps.is() )
    1079             :                 {
    1080           0 :                     Any aType = xColumnProps->getPropertyValue("Type");
    1081           0 :                     aType >>= eDataType;
    1082             :                 }
    1083             :                 try
    1084             :                 {
    1085           0 :                     if( pEntry->bHasFmt )
    1086             :                     {
    1087             :                         SwTblBoxNumFormat aNumFmt(
    1088             :                                         pEntry->bIsDBFmt ? pEntry->nDBNumFmt
    1089           0 :                                                          : pEntry->nUsrNumFmt );
    1090           0 :                         aTblSet.Put(aNumFmt);
    1091           0 :                         if( xColumn.is() )
    1092             :                         {
    1093           0 :                             double fVal = xColumn->getDouble();
    1094           0 :                             if( xColumn->wasNull() )
    1095           0 :                                 aTblSet.ClearItem( RES_BOXATR_VALUE );
    1096             :                             else
    1097             :                             {
    1098           0 :                                 if(rNumFmtr.GetType(aNumFmt.GetValue()) & NUMBERFORMAT_DATE)
    1099             :                                 {
    1100           0 :                                     ::Date aStandard(1,1,1900);
    1101           0 :                                     if (*rNumFmtr.GetNullDate() != aStandard)
    1102           0 :                                         fVal += (aStandard - *rNumFmtr.GetNullDate());
    1103             :                                 }
    1104           0 :                                 aTblSet.Put( SwTblBoxValue( fVal ));
    1105             :                             }
    1106             :                         }
    1107             :                         else
    1108           0 :                             aTblSet.ClearItem( RES_BOXATR_VALUE );
    1109           0 :                         rSh.SetTblBoxFormulaAttrs( aTblSet );
    1110             :                     }
    1111             :                     //#i60207# don't insert binary data as string - creates a loop
    1112           0 :                     else if( DataType::BINARY       == eDataType ||
    1113           0 :                              DataType::VARBINARY    == eDataType ||
    1114           0 :                              DataType::LONGVARBINARY== eDataType ||
    1115           0 :                              DataType::SQLNULL      == eDataType ||
    1116           0 :                              DataType::OTHER        == eDataType ||
    1117           0 :                              DataType::OBJECT       == eDataType ||
    1118           0 :                              DataType::DISTINCT     == eDataType ||
    1119           0 :                              DataType::STRUCT       == eDataType ||
    1120           0 :                              DataType::ARRAY        == eDataType ||
    1121           0 :                              DataType::BLOB         == eDataType ||
    1122           0 :                              DataType::CLOB         == eDataType ||
    1123           0 :                              DataType::REF          == eDataType
    1124             :                              )
    1125             :                     {
    1126             :                         // do nothing
    1127             :                     }
    1128             :                     else
    1129             :                     {
    1130           0 :                         OUString sVal =  xColumn->getString();
    1131           0 :                         if(!xColumn->wasNull())
    1132             :                         {
    1133           0 :                             rSh.SwEditShell::Insert2( sVal );
    1134           0 :                         }
    1135             :                     }
    1136             :                 }
    1137           0 :                 catch (const Exception& rExcept)
    1138             :                 {
    1139             :                     OSL_FAIL(OUStringToOString(rExcept.Message, osl_getThreadTextEncoding()).getStr());
    1140             :                     (void)rExcept;
    1141             :                 }
    1142           0 :             }
    1143             : 
    1144           0 :             if( !pSelection )
    1145             :             {
    1146           0 :                 if ( !xResultSet->next() )
    1147           0 :                     break;
    1148             :             }
    1149           0 :             else if( i+1 >= rSelection.getLength() )
    1150           0 :                 break;
    1151             : 
    1152           0 :             if( 10 == i )
    1153           0 :                 pWait.reset(new SwWait( *pView->GetDocShell(), true ));
    1154           0 :         }
    1155             : 
    1156           0 :         rSh.MoveTable( GetfnTableCurr(), GetfnTableStart() );
    1157           0 :         if( !pSelection && ( pTblSet || pTAutoFmt ))
    1158             :         {
    1159           0 :             if( pTblSet )
    1160           0 :                 SetTabSet();
    1161             : 
    1162           0 :             if( pTAutoFmt )
    1163           0 :                 rSh.SetTableAutoFmt( *pTAutoFmt );
    1164             :         }
    1165           0 :         rSh.SetAutoUpdateCells( bIsAutoUpdateCells );
    1166             :     }
    1167             :     else                            // add data as fields/text
    1168             :     {
    1169           0 :         _DB_Columns aColArr;
    1170           0 :         if( SplitTextToColArr( m_pEdDbText->GetText(), aColArr, m_pRbAsField->IsChecked() ) )
    1171             :         {
    1172             :             // now for each data set, we can iterate over the array
    1173             :             // and add the data
    1174             : 
    1175           0 :             if( !rSh.IsSttPara() )
    1176           0 :                 rSh.SwEditShell::SplitNode();
    1177           0 :             if( !rSh.IsEndPara() )
    1178             :             {
    1179           0 :                 rSh.SwEditShell::SplitNode();
    1180           0 :                 rSh.SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
    1181             :             }
    1182             : 
    1183           0 :             rSh.DoUndo( sal_False );
    1184             : 
    1185           0 :             SwTxtFmtColl* pColl = 0;
    1186             :             {
    1187           0 :                 OUString sTmplNm( m_pLbDbParaColl->GetSelectEntry() );
    1188           0 :                 if( sNoTmpl != sTmplNm )
    1189             :                 {
    1190           0 :                     pColl = rSh.FindTxtFmtCollByName( sTmplNm );
    1191           0 :                     if( !pColl )
    1192             :                     {
    1193           0 :                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmplNm, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
    1194           0 :                         if( USHRT_MAX != nId )
    1195           0 :                             pColl = rSh.GetTxtCollFromPool( nId );
    1196             :                         else
    1197           0 :                             pColl = rSh.MakeTxtFmtColl( sTmplNm );
    1198             :                     }
    1199           0 :                     rSh.SetTxtFmtColl( pColl );
    1200           0 :                 }
    1201             :             }
    1202             : 
    1203             :             // for adding as fields -> insert a "NextField" after
    1204             :             // every data set
    1205           0 :             SwDBFormatData aDBFormatData;
    1206           0 :             Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
    1207           0 :             aDBFormatData.xFormatter = Reference<util::XNumberFormatter>(util::NumberFormatter::create(xContext), UNO_QUERY_THROW) ;
    1208             : 
    1209           0 :             Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
    1210           0 :             if(xSourceProps.is())
    1211             :             {
    1212           0 :               Any aFormats = xSourceProps->getPropertyValue("NumberFormatsSupplier");
    1213           0 :               if(aFormats.hasValue())
    1214             :               {
    1215           0 :                   Reference< util::XNumberFormatsSupplier> xSuppl;
    1216           0 :                   aFormats >>= xSuppl;
    1217           0 :                   if(xSuppl.is())
    1218             :                   {
    1219           0 :                         Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
    1220           0 :                         Any aNull = xSettings->getPropertyValue("NullDate");
    1221           0 :                         aNull >>= aDBFormatData.aNullDate;
    1222           0 :                         if(aDBFormatData.xFormatter.is())
    1223           0 :                             aDBFormatData.xFormatter->attachNumberFormatsSupplier(xSuppl);
    1224           0 :                   }
    1225           0 :               }
    1226             :             }
    1227           0 :             aDBFormatData.aLocale = LanguageTag( rSh.GetCurLang() ).getLocale();
    1228             :             SwDBNextSetField aNxtDBFld( (SwDBNextSetFieldType*)rSh.
    1229           0 :                                         GetFldType( 0, RES_DBNEXTSETFLD ),
    1230           0 :                                         OUString("1"), aEmptyOUStr, aDBData );
    1231             : 
    1232           0 :             bool bSetCrsr = true;
    1233           0 :             sal_uInt16 n = 0, nCols = aColArr.size();
    1234           0 :             ::sw::mark::IMark* pMark = NULL;
    1235           0 :             for( sal_Int32 i = 0 ; ; ++i )
    1236             :             {
    1237           0 :                 bool bBreak = false;
    1238             :                 try
    1239             :                 {
    1240           0 :                     if(pSelection)
    1241             :                     {
    1242           0 :                         sal_Int32 nPos = 0;
    1243           0 :                         pSelection[i] >>= nPos;
    1244           0 :                         bBreak = !xResultSet->absolute(nPos);
    1245             :                     }
    1246           0 :                     else if(!i)
    1247           0 :                         bBreak = !xResultSet->first();
    1248             :                 }
    1249           0 :                 catch (const Exception&)
    1250             :                 {
    1251           0 :                     bBreak = true;
    1252             :                 }
    1253             : 
    1254           0 :                 if(bBreak)
    1255           0 :                     break;
    1256             : 
    1257           0 :                 for( n = 0; n < nCols; ++n )
    1258             :                 {
    1259           0 :                     _DB_Column* pDBCol = &aColArr[ n ];
    1260           0 :                     OUString sIns;
    1261           0 :                     switch( pDBCol->eColType )
    1262             :                     {
    1263             :                     case _DB_Column::DB_FILLTEXT:
    1264           0 :                         sIns =  *pDBCol->DB_ColumnData.pText;
    1265           0 :                         break;
    1266             : 
    1267             :                     case _DB_Column::DB_SPLITPARA:
    1268           0 :                         rSh.SplitNode();
    1269             :                         // when the template is not the same as the follow template,
    1270             :                         // the selected has to be set newly
    1271           0 :                         if( pColl && &pColl->GetNextTxtFmtColl() != pColl )
    1272           0 :                             rSh.SetTxtFmtColl( pColl );
    1273           0 :                         break;
    1274             : 
    1275             :                     case _DB_Column::DB_COL_FIELD:
    1276             :                         {
    1277             :                             SwDBField *const pFld = static_cast<SwDBField *>(
    1278           0 :                                 pDBCol->DB_ColumnData.pField->CopyField());
    1279           0 :                             double nValue = DBL_MAX;
    1280             : 
    1281           0 :                             Reference< XPropertySet > xColumnProps;
    1282           0 :                             xCols->getByName(pDBCol->pColInfo->sColumn) >>= xColumnProps;
    1283             : 
    1284             :                             pFld->SetExpansion( SwNewDBMgr::GetDBField(
    1285             :                                                 xColumnProps,
    1286             :                                                 aDBFormatData,
    1287           0 :                                                 &nValue ) );
    1288           0 :                             if( DBL_MAX != nValue )
    1289             :                             {
    1290           0 :                                 Any aType = xColumnProps->getPropertyValue("Type");
    1291           0 :                                 sal_Int32 eDataType = 0;
    1292           0 :                                 aType >>= eDataType;
    1293           0 :                                 if( DataType::DATE == eDataType  || DataType::TIME == eDataType  ||
    1294           0 :                                     DataType::TIMESTAMP  == eDataType)
    1295             : 
    1296             :                                 {
    1297           0 :                                     ::Date aStandard(1,1,1900);
    1298             :                                     ::Date aCompare(aDBFormatData.aNullDate.Day ,
    1299             :                                                     aDBFormatData.aNullDate.Month,
    1300           0 :                                                     aDBFormatData.aNullDate.Year);
    1301           0 :                                     if(aStandard != aCompare)
    1302           0 :                                         nValue += (aStandard - aCompare);
    1303             :                                 }
    1304           0 :                                 pFld->ChgValue( nValue, true );
    1305             :                             }
    1306           0 :                             pFld->SetInitialized();
    1307             : 
    1308           0 :                             rSh.Insert( *pFld );
    1309           0 :                             delete pFld;
    1310             :                         }
    1311           0 :                         break;
    1312             : 
    1313             :                     case _DB_Column::DB_COL_TEXT:
    1314             :                         {
    1315           0 :                             double nValue = DBL_MAX;
    1316           0 :                             Reference< XPropertySet > xColumnProps;
    1317           0 :                             xCols->getByName(pDBCol->pColInfo->sColumn) >>= xColumnProps;
    1318           0 :                             sIns = SwNewDBMgr::GetDBField(
    1319             :                                                 xColumnProps,
    1320             :                                                 aDBFormatData,
    1321           0 :                                                 &nValue );
    1322           0 :                             if( pDBCol->DB_ColumnData.nFormat &&
    1323           0 :                                 DBL_MAX != nValue )
    1324             :                             {
    1325             :                                 Color* pCol;
    1326           0 :                                 if(rNumFmtr.GetType(pDBCol->DB_ColumnData.nFormat) & NUMBERFORMAT_DATE)
    1327             :                                 {
    1328           0 :                                     ::Date aStandard(1,1,1900);
    1329           0 :                                     if (*rNumFmtr.GetNullDate() != aStandard)
    1330           0 :                                         nValue += (aStandard - *rNumFmtr.GetNullDate());
    1331             :                                 }
    1332             :                                 rNumFmtr.GetOutputString( nValue,
    1333             :                                             pDBCol->DB_ColumnData.nFormat,
    1334           0 :                                             sIns, &pCol );
    1335           0 :                             }
    1336             :                         }
    1337           0 :                         break;
    1338             :                     }
    1339             : 
    1340           0 :                     if( !sIns.isEmpty() )
    1341             :                     {
    1342           0 :                         rSh.Insert( sIns );
    1343             : 
    1344           0 :                         if( bSetCrsr)
    1345             :                         {
    1346             :                             // to the beginning and set a mark, so that
    1347             :                             // the cursor can be set to the initial position
    1348             :                             // at the end.
    1349             : 
    1350             :                             rSh.SwCrsrShell::MovePara(
    1351           0 :                                     GetfnParaCurr(), GetfnParaStart() );
    1352             :                             pMark = rSh.SetBookmark(
    1353             :                                     KeyCode(),
    1354             :                                     OUString(),
    1355           0 :                                     OUString(), IDocumentMarkAccess::UNO_BOOKMARK );
    1356             :                             rSh.SwCrsrShell::MovePara(
    1357           0 :                                     GetfnParaCurr(), GetfnParaEnd() );
    1358           0 :                             bSetCrsr = false;
    1359             :                         }
    1360             :                     }
    1361           0 :                 }
    1362             : 
    1363           0 :                 if( !pSelection )
    1364             :                 {
    1365           0 :                     sal_Bool bNext = xResultSet->next();
    1366           0 :                     if(!bNext)
    1367           0 :                         break;
    1368             :                 }
    1369           0 :                 else if( i+1 >= rSelection.getLength() )
    1370           0 :                     break;
    1371             : 
    1372           0 :                 if( m_pRbAsField->IsChecked() )
    1373           0 :                     rSh.Insert( aNxtDBFld );
    1374             : 
    1375           0 :                 if( !rSh.IsSttPara() )
    1376           0 :                     rSh.SwEditShell::SplitNode();
    1377             : 
    1378           0 :                 if( 10 == i )
    1379           0 :                     pWait.reset(new SwWait( *pView->GetDocShell(), true ));
    1380           0 :             }
    1381             : 
    1382           0 :             if( !bSetCrsr && pMark != NULL)
    1383             :             {
    1384           0 :                 rSh.SetMark();
    1385           0 :                 rSh.GotoMark( pMark );
    1386           0 :                 rSh.getIDocumentMarkAccess()->deleteMark( pMark );
    1387           0 :                 break;
    1388           0 :             }
    1389           0 :         }
    1390             :     }
    1391             :     // write configuration
    1392           0 :     Commit();
    1393             :     }while( false );                    // middle checked loop
    1394             : 
    1395           0 :     if( bUndo )
    1396             :     {
    1397           0 :         rSh.DoUndo( sal_True );
    1398           0 :         rSh.AppendUndoForInsertFromDB( bAsTable );
    1399           0 :         rSh.EndUndo( UNDO_EMPTY );
    1400             :     }
    1401           0 :     rSh.ClearMark();
    1402           0 :     rSh.EndAllAction();
    1403             : 
    1404           0 :     if ( bDisposeResultSet )
    1405           0 :         ::comphelper::disposeComponent(xResultSet);
    1406             : }
    1407             : 
    1408           0 : void SwInsertDBColAutoPilot::SetTabSet()
    1409             : {
    1410           0 :     SwWrtShell& rSh = pView->GetWrtShell();
    1411             :     const SfxPoolItem* pItem;
    1412             : 
    1413           0 :     if( pTAutoFmt )
    1414             :     {
    1415           0 :         if( pTAutoFmt->IsFrame() )
    1416             :         {
    1417             :             // border is from AutoFormat
    1418           0 :             pTblSet->ClearItem( RES_BOX );
    1419           0 :             pTblSet->ClearItem( SID_ATTR_BORDER_INNER );
    1420             :         }
    1421           0 :         if( pTAutoFmt->IsBackground() )
    1422             :         {
    1423           0 :             pTblSet->ClearItem( RES_BACKGROUND );
    1424           0 :             pTblSet->ClearItem( SID_ATTR_BRUSH_ROW );
    1425           0 :             pTblSet->ClearItem( SID_ATTR_BRUSH_TABLE );
    1426             :         }
    1427             :     }
    1428             :     else
    1429             :     {
    1430             :         // remove the defaults again, it makes no sense to set them
    1431           0 :         SvxBrushItem aBrush( RES_BACKGROUND );
    1432             :         static const sal_uInt16 aIds[3] =
    1433             :             { RES_BACKGROUND, SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE };
    1434           0 :         for( int i = 0; i < 3; ++i )
    1435           0 :             if( SFX_ITEM_SET == pTblSet->GetItemState( aIds[ i ],
    1436           0 :                 false, &pItem ) && *pItem == aBrush )
    1437           0 :                 pTblSet->ClearItem( aIds[ i ] );
    1438             :     }
    1439             : 
    1440           0 :     if( SFX_ITEM_SET == pTblSet->GetItemState( FN_PARAM_TABLE_NAME, false,
    1441           0 :         &pItem ) && ((const SfxStringItem*)pItem)->GetValue() ==
    1442           0 :                     rSh.GetTableFmt()->GetName() )
    1443           0 :         pTblSet->ClearItem( FN_PARAM_TABLE_NAME );
    1444             : 
    1445           0 :     rSh.MoveTable( GetfnTableCurr(), GetfnTableStart() );
    1446           0 :     rSh.SetMark();
    1447           0 :     rSh.MoveTable( GetfnTableCurr(), GetfnTableEnd() );
    1448             : 
    1449           0 :     ItemSetToTableParam( *pTblSet, rSh );
    1450             : 
    1451           0 :     rSh.ClearMark();
    1452           0 :     rSh.MoveTable( GetfnTableCurr(), GetfnTableStart() );
    1453           0 : }
    1454             : 
    1455           0 : _DB_ColumnConfigData::~_DB_ColumnConfigData() {}
    1456             : 
    1457           0 : static Sequence<OUString> lcl_createSourceNames(const OUString& rNodeName)
    1458             : {
    1459           0 :     Sequence<OUString> aSourceNames(11);
    1460           0 :     OUString* pNames = aSourceNames.getArray();
    1461           0 :     pNames[0] = rNodeName + "/DataSource";
    1462           0 :     pNames[1] = rNodeName + "/Command";
    1463           0 :     pNames[2] = rNodeName + "/CommandType";
    1464           0 :     pNames[3] = rNodeName + "/ColumnsToText";
    1465           0 :     pNames[4] = rNodeName + "/ColumnsToTable";
    1466           0 :     pNames[5] = rNodeName + "/ParaStyle";
    1467           0 :     pNames[6] = rNodeName + "/TableAutoFormat";
    1468           0 :     pNames[7] = rNodeName + "/IsTable";
    1469           0 :     pNames[8] = rNodeName + "/IsField";
    1470           0 :     pNames[9] = rNodeName + "/IsHeadlineOn";
    1471           0 :     pNames[10] = rNodeName + "/IsEmptyHeadline";
    1472           0 :     return aSourceNames;
    1473             : }
    1474             : 
    1475           0 : static Sequence<OUString> lcl_CreateSubNames(const OUString& rSubNodeName)
    1476             : {
    1477           0 :     Sequence<OUString> aSubSourceNames(6);
    1478           0 :     OUString* pNames = aSubSourceNames.getArray();
    1479           0 :     pNames[0] = rSubNodeName + "/ColumnName";
    1480           0 :     pNames[1] = rSubNodeName + "/ColumnIndex";
    1481           0 :     pNames[2] = rSubNodeName + "/IsNumberFormat";
    1482           0 :     pNames[3] = rSubNodeName + "/IsNumberFormatFromDataBase";
    1483           0 :     pNames[4] = rSubNodeName + "/NumberFormat";
    1484           0 :     pNames[5] = rSubNodeName + "/NumberFormatLocale";
    1485           0 :     return aSubSourceNames;
    1486             : }
    1487             : 
    1488           0 : static OUString lcl_CreateUniqueName(const Sequence<OUString>& aNames)
    1489             : {
    1490           0 :     sal_Int32 nIdx = aNames.getLength();
    1491           0 :     const OUString* pNames = aNames.getConstArray();
    1492           0 :     OUString sTest("_");
    1493           0 :     OUString sRet;
    1494             :     while(true)
    1495             :     {
    1496           0 :         sRet = sTest; sRet += OUString::number(nIdx++);
    1497           0 :         bool bFound = false;
    1498           0 :         for(sal_Int32 i = 0; i < aNames.getLength(); i++)
    1499             :         {
    1500           0 :             if(pNames[i] == sRet)
    1501             :             {
    1502           0 :                 bFound = true;
    1503           0 :                 break;
    1504             :             }
    1505             :         }
    1506           0 :         if(!bFound)
    1507           0 :             break;
    1508             :     }
    1509           0 :     return sRet;
    1510             : }
    1511             : 
    1512           0 : void SwInsertDBColAutoPilot::Notify( const ::com::sun::star::uno::Sequence< OUString >&  ) {}
    1513             : 
    1514           0 : void SwInsertDBColAutoPilot::Commit()
    1515             : {
    1516           0 :     Sequence <OUString> aNames = GetNodeNames(OUString());
    1517           0 :     const OUString* pNames = aNames.getArray();
    1518             :     //remove entries that contain this data source + table at first
    1519           0 :     for(sal_Int32 nNode = 0; nNode < aNames.getLength(); nNode++)
    1520             :     {
    1521           0 :         Sequence<OUString> aSourceNames(2);
    1522           0 :         OUString* pSourceNames = aSourceNames.getArray();
    1523           0 :         pSourceNames[0] = pNames[nNode];
    1524           0 :         pSourceNames[0] += "/DataSource";
    1525           0 :         pSourceNames[1] = pNames[nNode];
    1526           0 :         pSourceNames[1] += "/Command";
    1527           0 :         Sequence<Any> aSourceProperties = GetProperties(aSourceNames);
    1528           0 :         const Any* pSourceProps = aSourceProperties.getArray();
    1529           0 :         OUString sSource, sCommand;
    1530           0 :         pSourceProps[0] >>= sSource;
    1531           0 :         pSourceProps[1] >>= sCommand;
    1532           0 :         if(sSource.equals(aDBData.sDataSource) && sCommand.equals(aDBData.sCommand))
    1533             :         {
    1534           0 :             Sequence<OUString> aElements(1);
    1535           0 :             aElements.getArray()[0] = pNames[nNode];
    1536           0 :             ClearNodeElements(OUString(), aElements);
    1537             :         }
    1538           0 :     }
    1539             : 
    1540           0 :     aNames = GetNodeNames(OUString());
    1541           0 :     OUString sNewNode = lcl_CreateUniqueName(aNames);
    1542           0 :     Sequence<OUString> aNodeNames = lcl_createSourceNames(sNewNode);
    1543           0 :     Sequence<PropertyValue> aValues(aNodeNames.getLength());
    1544           0 :     PropertyValue* pValues = aValues.getArray();
    1545           0 :     const OUString* pNodeNames = aNodeNames.getConstArray();
    1546           0 :     OUString sSlash("/");
    1547           0 :     for(sal_Int32 i = 0; i < aNodeNames.getLength(); i++)
    1548             :     {
    1549           0 :         pValues[i].Name = sSlash;
    1550           0 :         pValues[i].Name += pNodeNames[i];
    1551             :     }
    1552             : 
    1553           0 :     pValues[0].Value <<= OUString(aDBData.sDataSource);
    1554           0 :     pValues[1].Value <<= OUString(aDBData.sCommand);
    1555           0 :     pValues[2].Value <<= aDBData.nCommandType;
    1556           0 :     pValues[3].Value <<= OUString(m_pEdDbText->GetText());
    1557             : 
    1558           0 :     OUString sTmp;
    1559           0 :     for( sal_uInt16 n = 0, nCnt = m_pLbTableCol->GetEntryCount(); n < nCnt; ++n )
    1560           0 :         (sTmp += m_pLbTableCol->GetEntry(n)) += "\x0a";
    1561             : 
    1562           0 :     if (!sTmp.isEmpty())
    1563           0 :         pValues[4].Value <<= sTmp;
    1564             : 
    1565           0 :     if( sNoTmpl != (sTmp = m_pLbDbParaColl->GetSelectEntry()) )
    1566           0 :         pValues[5].Value <<= sTmp;
    1567             : 
    1568           0 :     if( pTAutoFmt )
    1569           0 :         pValues[6].Value <<= OUString(pTAutoFmt->GetName());
    1570             : 
    1571           0 :     const Type& rBoolType = ::getBooleanCppuType();
    1572           0 :     sal_Bool bTmp = m_pRbAsTable->IsChecked();
    1573           0 :     pValues[7].Value.setValue(&bTmp, rBoolType);
    1574             : 
    1575           0 :     bTmp = m_pRbAsField->IsChecked();
    1576           0 :     pValues[8].Value.setValue(&bTmp, rBoolType);
    1577             : 
    1578           0 :     bTmp = m_pCbTableHeadon->IsChecked();
    1579           0 :     pValues[9].Value.setValue(&bTmp, rBoolType);
    1580             : 
    1581           0 :     bTmp = m_pRbHeadlEmpty->IsChecked();
    1582           0 :     pValues[10].Value.setValue(&bTmp, rBoolType);
    1583             : 
    1584           0 :     SetSetProperties(OUString(), aValues);
    1585             : 
    1586           0 :     sNewNode += "/ColumnSet";
    1587           0 :     OUString sDelim("/__");
    1588             : 
    1589           0 :     LanguageType ePrevLang = (LanguageType)-1;
    1590           0 :     OUString sPrevLang;
    1591             : 
    1592           0 :     SvNumberFormatter& rNFmtr = *pView->GetWrtShell().GetNumberFormatter();
    1593           0 :     for(sal_uInt16 nCol = 0; nCol < aDBColumns.size(); nCol++)
    1594             :     {
    1595           0 :         OUString sColumnNode = sNewNode;
    1596           0 :          SwInsDBColumn* pColumn = aDBColumns[nCol];
    1597           0 :         OUString sColumnInsertNode(sColumnNode);
    1598           0 :         sColumnInsertNode += sDelim;
    1599           0 :         if( nCol < 100 )
    1600           0 :             sColumnInsertNode += "0";
    1601           0 :         if( nCol < 10 )
    1602           0 :             sColumnInsertNode += "0";
    1603           0 :         sColumnInsertNode += OUString::number(  nCol );
    1604             : 
    1605           0 :         Sequence <OUString> aSubNodeNames = lcl_CreateSubNames(sColumnInsertNode);
    1606           0 :         Sequence<PropertyValue> aSubValues(aSubNodeNames.getLength());
    1607           0 :         PropertyValue* pSubValues = aSubValues.getArray();
    1608           0 :         const OUString* pSubNodeNames = aSubNodeNames.getConstArray();
    1609             :         sal_Int32 i;
    1610             : 
    1611           0 :         for( i = 0; i < aSubNodeNames.getLength(); i++)
    1612           0 :             pSubValues[i].Name = pSubNodeNames[i];
    1613           0 :         pSubValues[0].Value <<= pColumn->sColumn;
    1614           0 :         pSubValues[1].Value <<= i;
    1615             : 
    1616           0 :         sal_Bool bVal = pColumn->bHasFmt;
    1617           0 :         pSubValues[2].Value.setValue(&bVal, rBoolType);
    1618           0 :         bVal = pColumn->bIsDBFmt;
    1619           0 :         pSubValues[3].Value.setValue(&bVal, rBoolType);
    1620             : 
    1621           0 :         SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sTmp );
    1622           0 :         const SvNumberformat* pNF = rNFmtr.GetEntry( pColumn->nUsrNumFmt );
    1623             :         LanguageType eLang;
    1624           0 :         if( pNF )
    1625             :         {
    1626           0 :             pSubValues[4].Value <<= OUString(pNF->GetFormatstring());
    1627           0 :             eLang = pNF->GetLanguage();
    1628             :         }
    1629             :         else
    1630             :         {
    1631           0 :             pSubValues[4].Value <<= sTmp;
    1632           0 :             eLang = GetAppLanguage();
    1633             :         }
    1634             : 
    1635           0 :         if( eLang != ePrevLang )
    1636             :         {
    1637           0 :             sPrevLang = LanguageTag::convertToBcp47( eLang );
    1638           0 :             ePrevLang = eLang;
    1639             :         }
    1640             : 
    1641           0 :         pSubValues[5].Value <<=  sPrevLang;
    1642           0 :         SetSetProperties(sColumnNode, aSubValues);
    1643           0 :     }
    1644           0 : }
    1645             : 
    1646           0 : void SwInsertDBColAutoPilot::Load()
    1647             : {
    1648           0 :     Sequence <OUString> aNames = GetNodeNames(OUString());
    1649           0 :     const OUString* pNames = aNames.getArray();
    1650           0 :     SvNumberFormatter& rNFmtr = *pView->GetWrtShell().GetNumberFormatter();
    1651           0 :     for(sal_Int32 nNode = 0; nNode < aNames.getLength(); nNode++)
    1652             :     {
    1653             :         //search for entries with the appropriate data source and table
    1654           0 :         Sequence<OUString> aSourceNames = lcl_createSourceNames(pNames[nNode]);
    1655             : 
    1656           0 :         Sequence< Any> aDataSourceProps = GetProperties(aSourceNames);
    1657           0 :         const Any* pDataSourceProps = aDataSourceProps.getConstArray();
    1658           0 :         OUString sSource, sCommand;
    1659             :         sal_Int16 nCommandType;
    1660           0 :         pDataSourceProps[0] >>= sSource;
    1661           0 :         pDataSourceProps[1] >>= sCommand;
    1662           0 :         pDataSourceProps[2] >>= nCommandType;
    1663           0 :         if(sSource.equals(aDBData.sDataSource) && sCommand.equals(aDBData.sCommand))
    1664             :         {
    1665           0 :             _DB_ColumnConfigData* pNewData = new _DB_ColumnConfigData;
    1666           0 :             pNewData->sSource = sSource;
    1667           0 :             pNewData->sTable = sCommand;
    1668             : 
    1669           0 :             pDataSourceProps[3] >>= pNewData->sEdit;
    1670           0 :             pDataSourceProps[4] >>= pNewData->sTblList;
    1671           0 :             pDataSourceProps[5] >>= pNewData->sTmplNm;
    1672           0 :             pDataSourceProps[6] >>= pNewData->sTAutoFmtNm;
    1673           0 :             if(pDataSourceProps[7].hasValue())
    1674           0 :                 pNewData->bIsTable = *(sal_Bool*)pDataSourceProps[7].getValue();
    1675           0 :             if(pDataSourceProps[8].hasValue())
    1676           0 :                  pNewData->bIsField = *(sal_Bool*)pDataSourceProps[8].getValue();
    1677           0 :             if(pDataSourceProps[9].hasValue())
    1678           0 :                  pNewData->bIsHeadlineOn = *(sal_Bool*)pDataSourceProps[9].getValue();
    1679           0 :             if(pDataSourceProps[10].hasValue())
    1680           0 :                  pNewData->bIsEmptyHeadln = *(sal_Bool*)pDataSourceProps[10].getValue();
    1681             : 
    1682           0 :             OUString sSubNodeName(pNames[nNode]);
    1683           0 :             sSubNodeName += "/ColumnSet/";
    1684           0 :             Sequence <OUString> aSubNames = GetNodeNames(sSubNodeName);
    1685           0 :             const OUString* pSubNames = aSubNames.getConstArray();
    1686           0 :             for(sal_Int32 nSub = 0; nSub < aSubNames.getLength(); nSub++)
    1687             :             {
    1688           0 :                 OUString sSubSubNodeName(sSubNodeName);
    1689           0 :                 sSubSubNodeName += pSubNames[nSub];
    1690           0 :                 Sequence <OUString> aSubNodeNames = lcl_CreateSubNames(sSubSubNodeName);
    1691           0 :                 Sequence< Any> aSubProps = GetProperties(aSubNodeNames);
    1692           0 :                 const Any* pSubProps = aSubProps.getConstArray();
    1693             : 
    1694           0 :                 OUString sColumn;
    1695           0 :                 pSubProps[0] >>= sColumn;
    1696             :                 //check for existance of the loaded column name
    1697           0 :                 bool bFound = false;
    1698           0 :                 for(sal_uInt16 nRealColumn = 0; nRealColumn < aDBColumns.size(); nRealColumn++)
    1699             :                 {
    1700           0 :                     if(aDBColumns[nRealColumn]->sColumn == sColumn)
    1701             :                     {
    1702           0 :                         bFound = true;
    1703           0 :                         break;
    1704             :                     }
    1705             :                 }
    1706           0 :                 if(!bFound)
    1707           0 :                     continue;
    1708           0 :                 sal_Int16 nIndex = 0;
    1709           0 :                 pSubProps[1] >>= nIndex;
    1710           0 :                 SwInsDBColumn* pInsDBColumn = new SwInsDBColumn(sColumn, nIndex);
    1711           0 :                 if(pSubProps[2].hasValue())
    1712           0 :                     pInsDBColumn->bHasFmt = *(sal_Bool*)pSubProps[2].getValue();
    1713           0 :                 if(pSubProps[3].hasValue())
    1714           0 :                     pInsDBColumn->bIsDBFmt = *(sal_Bool*)pSubProps[3].getValue();
    1715             : 
    1716           0 :                 pSubProps[4] >>= pInsDBColumn->sUsrNumFmt;
    1717           0 :                 OUString sNumberFormatLocale;
    1718           0 :                 pSubProps[5] >>= sNumberFormatLocale;
    1719             : 
    1720             :                 /* XXX Earlier versions wrote a Country-Language string in
    1721             :                  * SwInsertDBColAutoPilot::Commit() that here was read as
    1722             :                  * Language-Country with 2 characters copied to language,
    1723             :                  * 1 character separator and unconditionally 2 characters read
    1724             :                  * as country. So for 'DE-de' and locales that have similar
    1725             :                  * case-insensitive equal language/country combos that may have
    1726             :                  * worked, for all others not. FIXME if you need to read old
    1727             :                  * data that you were never able to read before. */
    1728           0 :                 pInsDBColumn->eUsrNumFmtLng = LanguageTag::convertToLanguageType( sNumberFormatLocale );
    1729             : 
    1730             :                 pInsDBColumn->nUsrNumFmt = rNFmtr.GetEntryKey( pInsDBColumn->sUsrNumFmt,
    1731           0 :                                                         pInsDBColumn->eUsrNumFmtLng );
    1732             : 
    1733           0 :                 pNewData->aDBColumns.insert(pInsDBColumn);
    1734           0 :             }
    1735           0 :             sal_Int32 n = 0;
    1736           0 :             OUString sTmp( pNewData->sTblList );
    1737           0 :             if( !sTmp.isEmpty() )
    1738             :             {
    1739           0 :                 do {
    1740           0 :                     OUString sEntry( sTmp.getToken( 0, '\x0a', n ) );
    1741             :                     //preselect column - if they still exist!
    1742           0 :                     if(m_pLbTblDbColumn->GetEntryPos(sEntry) != LISTBOX_ENTRY_NOTFOUND)
    1743             :                     {
    1744           0 :                         m_pLbTableCol->InsertEntry( sEntry );
    1745           0 :                         m_pLbTblDbColumn->RemoveEntry( sEntry );
    1746           0 :                     }
    1747           0 :                 } while( n < sTmp.getLength() );
    1748             : 
    1749           0 :                 if( !m_pLbTblDbColumn->GetEntryCount() )
    1750             :                 {
    1751           0 :                     m_pIbDbcolAllTo->Enable( false );
    1752           0 :                     m_pIbDbcolOneTo->Enable( false );
    1753             :                 }
    1754           0 :                 m_pIbDbcolOneFrom->Enable( true );
    1755           0 :                 m_pIbDbcolAllFrom->Enable( true );
    1756             :             }
    1757           0 :             m_pEdDbText->SetText( pNewData->sEdit );
    1758             : 
    1759           0 :             sTmp = pNewData->sTmplNm;
    1760           0 :             if( !sTmp.isEmpty() )
    1761           0 :                 m_pLbDbParaColl->SelectEntry( sTmp );
    1762             :             else
    1763           0 :                 m_pLbDbParaColl->SelectEntryPos( 0 );
    1764             : 
    1765           0 :             delete pTAutoFmt, pTAutoFmt = 0;
    1766           0 :             sTmp = pNewData->sTAutoFmtNm;
    1767           0 :             if( !sTmp.isEmpty() )
    1768             :             {
    1769             :                 // then load the AutoFmt file and look for Autoformat first
    1770           0 :                 SwTableAutoFmtTbl aAutoFmtTbl;
    1771           0 :                 aAutoFmtTbl.Load();
    1772           0 :                 for( sal_uInt16 nAutoFmt = aAutoFmtTbl.size(); nAutoFmt; )
    1773           0 :                     if( sTmp == aAutoFmtTbl[ --nAutoFmt ].GetName() )
    1774             :                     {
    1775           0 :                         pTAutoFmt = new SwTableAutoFmt( aAutoFmtTbl[ nAutoFmt ] );
    1776           0 :                         break;
    1777           0 :                     }
    1778             :             }
    1779             : 
    1780           0 :             m_pRbAsTable->Check( pNewData->bIsTable );
    1781           0 :             m_pRbAsField->Check( pNewData->bIsField );
    1782           0 :             m_pRbAsText->Check( !pNewData->bIsTable && !pNewData->bIsField );
    1783             : 
    1784           0 :             m_pCbTableHeadon->Check( pNewData->bIsHeadlineOn );
    1785           0 :             m_pRbHeadlColnms->Check( !pNewData->bIsEmptyHeadln );
    1786           0 :             m_pRbHeadlEmpty->Check( pNewData->bIsEmptyHeadln );
    1787           0 :             HeaderHdl(m_pCbTableHeadon);
    1788             : 
    1789             :             // now copy the user defined Numberformat strings to the
    1790             :             // Shell. Then only these are available as ID
    1791           0 :             for( n = 0; n < (sal_Int32) aDBColumns.size() ; ++n )
    1792             :             {
    1793           0 :                 SwInsDBColumn& rSet = *aDBColumns[ n ];
    1794           0 :                 for( sal_uInt16 m = 0; m < pNewData->aDBColumns.size() ; ++m )
    1795             :                 {
    1796           0 :                     SwInsDBColumn& rGet = *pNewData->aDBColumns[ m ];
    1797           0 :                     if(rGet.sColumn == rSet.sColumn)
    1798             :                     {
    1799           0 :                         if( rGet.bHasFmt && !rGet.bIsDBFmt )
    1800             :                         {
    1801           0 :                             rSet.bIsDBFmt = sal_False;
    1802             :                             rSet.nUsrNumFmt = rNFmtr.GetEntryKey( rGet.sUsrNumFmt,
    1803           0 :                                                                     rGet.eUsrNumFmtLng );
    1804           0 :                             if( NUMBERFORMAT_ENTRY_NOT_FOUND == rSet.nUsrNumFmt )
    1805             :                             {
    1806             :                                 sal_Int32 nCheckPos;
    1807             :                                 short nType;
    1808             :                                 rNFmtr.PutEntry( rGet.sUsrNumFmt, nCheckPos, nType,
    1809           0 :                                                 rSet.nUsrNumFmt, rGet.eUsrNumFmtLng );
    1810             :                             }
    1811             :                         }
    1812           0 :                         break;
    1813             :                     }
    1814             :                 }
    1815             :             }
    1816             : 
    1817             :             // when the cursor is inside of a table, table must NEVER be selectable
    1818           0 :             if( !m_pRbAsTable->IsEnabled() && m_pRbAsTable->IsChecked() )
    1819           0 :                 m_pRbAsField->Check( true );
    1820           0 :             delete pNewData;
    1821           0 :             break;
    1822             :         }
    1823           0 :     }
    1824           0 : }
    1825             : 
    1826             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10