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

Generated by: LCOV version 1.11