LCOV - code coverage report
Current view: top level - sw/source/ui/index - swuiidxmrk.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 895 0.0 %
Date: 2014-04-14 Functions: 0 87 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 "swuiidxmrk.hxx"
      21             : #include <hintids.hxx>
      22             : #include <helpid.h>
      23             : #include <comphelper/processfactory.hxx>
      24             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      25             : #include <com/sun/star/beans/PropertyValue.hpp>
      26             : #include <com/sun/star/beans/XPropertySet.hpp>
      27             : #include <com/sun/star/frame/Bibliography.hpp>
      28             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      29             : #include <com/sun/star/i18n/IndexEntrySupplier.hpp>
      30             : #include <com/sun/star/util/SearchOptions.hpp>
      31             : #include <com/sun/star/util/SearchFlags.hpp>
      32             : #include <svl/stritem.hxx>
      33             : #include <vcl/layout.hxx>
      34             : #include <vcl/msgbox.hxx>
      35             : #include <sfx2/dispatch.hxx>
      36             : #include <svl/eitem.hxx>
      37             : #include <unotools/textsearch.hxx>
      38             : #include <editeng/scripttypeitem.hxx>
      39             : #include <svl/itemset.hxx>
      40             : #include <editeng/langitem.hxx>
      41             : #include "editeng/unolingu.hxx"
      42             : #include <swtypes.hxx>
      43             : #include <idxmrk.hxx>
      44             : #include <txttxmrk.hxx>
      45             : #include <wrtsh.hxx>
      46             : #include <view.hxx>
      47             : #include <multmrk.hxx>
      48             : #include <swundo.hxx>
      49             : #include <cmdid.h>
      50             : #include <app.hrc>
      51             : #include <index.hrc>
      52             : #include <../../core/uibase/index/idxmrk.hrc>
      53             : #include <swmodule.hxx>
      54             : #include <fldmgr.hxx>
      55             : #include <fldbas.hxx>
      56             : #include <utlui.hrc>
      57             : #include <swcont.hxx>
      58             : #include <svl/cjkoptions.hxx>
      59             : #include <ndtxt.hxx>
      60             : #include <breakit.hxx>
      61             : #include <SwRewriter.hxx>
      62             : 
      63             : #include <unomid.h>
      64             : 
      65             : #define POS_CONTENT 0
      66             : #define POS_INDEX   1
      67             : 
      68             : static sal_Int32  nTypePos = 1; // TOX_INDEX as standard
      69             : static sal_uInt16 nKey1Pos = USHRT_MAX;
      70             : 
      71             : static sal_uInt16 nKey2Pos = USHRT_MAX;
      72             : 
      73             : using namespace com::sun::star;
      74             : using namespace com::sun::star::i18n;
      75             : using namespace com::sun::star::lang;
      76             : using namespace com::sun::star::util;
      77             : using namespace ::comphelper;
      78             : using namespace ::com::sun::star;
      79             : 
      80             : /*--------------------------------------------------------------------
      81             :      Description:   dialog to insert a directory selection
      82             :  --------------------------------------------------------------------*/
      83           0 : SwIndexMarkPane::SwIndexMarkPane(Dialog &rDialog, sal_Bool bNewDlg,
      84             :     SwWrtShell& rWrtShell)
      85             :     : m_rDialog(rDialog)
      86             :     , bDel(false)
      87             :     , bNewMark(bNewDlg)
      88             :     , bSelected(sal_False)
      89             :     , bPhoneticED0_ChangedByUser(sal_False)
      90             :     , bPhoneticED1_ChangedByUser(sal_False)
      91             :     , bPhoneticED2_ChangedByUser(sal_False)
      92             :     , nLangForPhoneticReading(LANGUAGE_CHINESE_SIMPLIFIED)
      93             :     , bIsPhoneticReadingEnabled(sal_False)
      94             :     , xExtendedIndexEntrySupplier(NULL)
      95             :     , pTOXMgr(0)
      96           0 :     , pSh(&rWrtShell)
      97             : {
      98           0 :     rDialog.get(m_pFrame, "frame");
      99           0 :     rDialog.get(m_pTypeFT, "typeft");
     100           0 :     rDialog.get(m_pTypeDCB, "typecb");
     101           0 :     rDialog.get(m_pNewBT, "new");
     102           0 :     m_pNewBT->SetAccessibleRelationMemberOf(m_pFrame->get_label_widget());
     103           0 :     rDialog.get(m_pEntryED, "entryed");
     104           0 :     rDialog.get(m_pPhoneticFT0, "phonetic0ft");
     105           0 :     rDialog.get(m_pPhoneticED0, "phonetic0ed");
     106           0 :     rDialog.get(m_pKey1FT, "key1ft");
     107           0 :     rDialog.get(m_pKey1DCB, "key1cb");
     108           0 :     rDialog.get(m_pPhoneticFT1, "phonetic1ft");
     109           0 :     rDialog.get(m_pPhoneticED1, "phonetic1ed");
     110           0 :     rDialog.get(m_pKey2FT, "key2ft");
     111           0 :     rDialog.get(m_pKey2DCB, "key2cb");
     112           0 :     rDialog.get(m_pPhoneticFT2, "phonetic2ft");
     113           0 :     rDialog.get(m_pPhoneticED2, "phonetic2ed");
     114           0 :     rDialog.get(m_pLevelFT, "levelft");
     115           0 :     rDialog.get(m_pLevelNF, "levelnf");
     116           0 :     rDialog.get(m_pMainEntryCB, "mainentrycb");
     117           0 :     rDialog.get(m_pApplyToAllCB, "applytoallcb");
     118           0 :     rDialog.get(m_pSearchCaseSensitiveCB, "searchcasesensitivecb");
     119           0 :     rDialog.get(m_pSearchCaseWordOnlyCB, "searchcasewordonlycb");
     120           0 :     rDialog.get(m_pCloseBT, "close");
     121           0 :     rDialog.get(m_pDelBT, "delete");
     122           0 :     rDialog.get(m_pPrevSameBT, "first");
     123           0 :     rDialog.get(m_pNextSameBT, "last");
     124           0 :     rDialog.get(m_pPrevBT, "previous");
     125           0 :     rDialog.get(m_pNextBT, "next");
     126             : 
     127           0 :     if (SvtCJKOptions().IsCJKFontEnabled())
     128             :     {
     129           0 :         uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
     130             : 
     131           0 :         xExtendedIndexEntrySupplier = i18n::IndexEntrySupplier::create(xContext);
     132             : 
     133           0 :         m_pPhoneticFT0->Show();
     134           0 :         m_pPhoneticED0->Show();
     135           0 :         m_pPhoneticFT1->Show();
     136           0 :         m_pPhoneticED1->Show();
     137           0 :         m_pPhoneticFT2->Show();
     138           0 :         m_pPhoneticED2->Show();
     139             :     }
     140             : 
     141           0 :     rDialog.SetText( SW_RESSTR( bNewMark ? STR_IDXMRK_INSERT : STR_IDXMRK_EDIT));
     142             : 
     143           0 :     m_pDelBT->SetClickHdl(LINK(this,SwIndexMarkPane,        DelHdl));
     144           0 :     m_pPrevBT->SetClickHdl(LINK(this,SwIndexMarkPane,       PrevHdl));
     145           0 :     m_pPrevSameBT->SetClickHdl(LINK(this,SwIndexMarkPane,   PrevSameHdl));
     146           0 :     m_pNextBT->SetClickHdl(LINK(this,SwIndexMarkPane,       NextHdl));
     147           0 :     m_pNextSameBT->SetClickHdl(LINK(this,SwIndexMarkPane,   NextSameHdl));
     148           0 :     m_pTypeDCB->SetSelectHdl(LINK(this,SwIndexMarkPane,     ModifyHdl));
     149           0 :     m_pKey1DCB->SetModifyHdl(LINK(this,SwIndexMarkPane,      KeyDCBModifyHdl));
     150           0 :     m_pKey2DCB->SetModifyHdl(LINK(this,SwIndexMarkPane,     KeyDCBModifyHdl));
     151           0 :     m_pCloseBT->SetClickHdl(LINK(this,SwIndexMarkPane,     CloseHdl));
     152           0 :     m_pEntryED->SetModifyHdl(LINK(this,SwIndexMarkPane,     ModifyHdl));
     153           0 :     m_pNewBT->SetClickHdl(LINK(this, SwIndexMarkPane,       NewUserIdxHdl));
     154           0 :     m_pApplyToAllCB->SetClickHdl(LINK(this, SwIndexMarkPane, SearchTypeHdl));
     155           0 :     m_pPhoneticED0->SetModifyHdl(LINK(this,SwIndexMarkPane, PhoneticEDModifyHdl));
     156           0 :     m_pPhoneticED1->SetModifyHdl(LINK(this,SwIndexMarkPane, PhoneticEDModifyHdl));
     157           0 :     m_pPhoneticED2->SetModifyHdl(LINK(this,SwIndexMarkPane, PhoneticEDModifyHdl));
     158             : 
     159           0 :     if(bNewMark)
     160             :     {
     161           0 :         m_pDelBT->Hide();
     162           0 :         rDialog.get(m_pOKBT, "insert");
     163             :     }
     164             :     else
     165             :     {
     166           0 :         m_pNewBT->Hide();
     167           0 :         rDialog.get(m_pOKBT, "ok");
     168             :     }
     169           0 :     m_pOKBT->Show();
     170           0 :     m_pOKBT->SetClickHdl(LINK(this, SwIndexMarkPane, InsertHdl));
     171             : 
     172           0 :     m_pEntryED->GrabFocus();
     173           0 : }
     174             : 
     175             : /*--------------------------------------------------------------------
     176             :      Description: Newly initialise controls with the new selection
     177             :  --------------------------------------------------------------------*/
     178           0 : void SwIndexMarkPane::InitControls()
     179             : {
     180             :     OSL_ENSURE(pSh && pTOXMgr, "no shell?");
     181             :     // contents index
     182           0 :     const SwTOXType* pType = pTOXMgr->GetTOXType(TOX_CONTENT, 0);
     183             :     OSL_ENSURE(pType, "Kein Verzeichnistyp !!");
     184           0 :     OUString sTmpTypeSelection;
     185           0 :     if(m_pTypeDCB->GetSelectEntryCount())
     186           0 :         sTmpTypeSelection = m_pTypeDCB->GetSelectEntry();
     187           0 :     m_pTypeDCB->Clear();
     188           0 :     m_pTypeDCB->InsertEntry(pType->GetTypeName());
     189             : 
     190             :     // keyword index
     191           0 :     pType = pTOXMgr->GetTOXType(TOX_INDEX, 0);
     192             :     OSL_ENSURE(pType, "Kein Verzeichnistyp !!");
     193           0 :     m_pTypeDCB->InsertEntry(pType->GetTypeName());
     194             : 
     195             :     // user index
     196           0 :     sal_uInt16 nCount = pSh->GetTOXTypeCount(TOX_USER);
     197           0 :     for( sal_uInt16 i = 0; i < nCount; ++i )
     198           0 :         m_pTypeDCB->InsertEntry( pSh->GetTOXType(TOX_USER, i)->GetTypeName() );
     199             : 
     200             :     // read keywords primary
     201           0 :     std::vector<OUString> aArr;
     202           0 :     nCount = pSh->GetTOIKeys( TOI_PRIMARY, aArr );
     203           0 :     std::sort(aArr.begin(), aArr.end());
     204           0 :     for (std::vector<OUString>::iterator it = aArr.begin(); it != aArr.end(); ++it)
     205           0 :         m_pKey1DCB->InsertEntry( *it );
     206             : 
     207             :     // read keywords secondary
     208           0 :     nCount = pSh->GetTOIKeys( TOI_SECONDARY, aArr );
     209           0 :     std::sort(aArr.begin(), aArr.end());
     210           0 :     for (std::vector<OUString>::iterator it = aArr.begin(); it != aArr.end(); ++it)
     211           0 :         m_pKey2DCB->InsertEntry( *it );
     212             : 
     213           0 :     UpdateLanguageDependenciesForPhoneticReading();
     214             : 
     215             :     // current entry
     216           0 :     const SwTOXMark* pMark = pTOXMgr->GetCurTOXMark();
     217           0 :     if( pMark && !bNewMark)
     218             :     {
     219             :         // Controls-Handling
     220             : 
     221             :         // only if there are more than one
     222             :         // if equal it lands at the same entry
     223           0 :         pSh->SttCrsrMove();
     224             : 
     225             :         const SwTOXMark* pMoveMark;
     226           0 :         bool bShow = false;
     227             : 
     228           0 :         pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_PRV );
     229           0 :         if( pMoveMark != pMark )
     230           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_NXT ), bShow = true;
     231           0 :         m_pPrevBT->Enable( pMoveMark != pMark );
     232           0 :         pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_NXT );
     233           0 :         if( pMoveMark != pMark )
     234           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_PRV ), bShow = true;
     235           0 :         m_pNextBT->Enable( pMoveMark != pMark );
     236           0 :         if( bShow )
     237             :         {
     238           0 :             m_pPrevBT->Show();
     239           0 :             m_pNextBT->Show();
     240           0 :             bShow = false;
     241             :         }
     242             : 
     243           0 :         pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_SAME_PRV );
     244           0 :         if( pMoveMark != pMark )
     245           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_SAME_NXT ), bShow = true;
     246           0 :         m_pPrevSameBT->Enable( pMoveMark != pMark );
     247           0 :         pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_SAME_NXT );
     248           0 :         if( pMoveMark != pMark )
     249           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_SAME_PRV ), bShow = true;
     250           0 :         m_pNextSameBT->Enable( pMoveMark != pMark );
     251           0 :         if( bShow )
     252             :         {
     253           0 :             m_pNextSameBT->Show();
     254           0 :             m_pPrevSameBT->Show();
     255             :         }
     256           0 :         pSh->EndCrsrMove();
     257             : 
     258           0 :         m_pTypeFT->Show();
     259             : 
     260           0 :         m_pTypeDCB->Enable(false);
     261           0 :         m_pTypeFT->Enable(false);
     262             : 
     263           0 :         UpdateDialog();
     264             :     }
     265             :     else
     266             :     {   // display current selection (first element) ????
     267           0 :         if (pSh->GetCrsrCnt() < 2)
     268             :         {
     269           0 :             bSelected = !pSh->HasSelection();
     270           0 :             aOrgStr = pSh->GetView().GetSelectionTextParam(true, false);
     271           0 :             m_pEntryED->SetText(aOrgStr);
     272             : 
     273             :             //to include all equal entries may only be allowed in the body and even there
     274             :             //only when a simple selection exists
     275           0 :             const sal_uInt16 nFrmType = pSh->GetFrmType(0,sal_True);
     276           0 :             m_pApplyToAllCB->Show();
     277           0 :             m_pSearchCaseSensitiveCB->Show();
     278           0 :             m_pSearchCaseWordOnlyCB->Show();
     279           0 :             m_pApplyToAllCB->Enable(!aOrgStr.isEmpty() &&
     280           0 :                 0 == (nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FLY_ANY )));
     281           0 :             SearchTypeHdl(m_pApplyToAllCB);
     282             :         }
     283             : 
     284             :         // index type is default
     285           0 :         if( !sTmpTypeSelection.isEmpty() &&
     286           0 :             LISTBOX_ENTRY_NOTFOUND != m_pTypeDCB->GetEntryPos( sTmpTypeSelection ) )
     287           0 :             m_pTypeDCB->SelectEntry(sTmpTypeSelection);
     288             :         else
     289           0 :             m_pTypeDCB->SelectEntry(m_pTypeDCB->GetEntry(nTypePos));
     290           0 :         ModifyHdl(m_pTypeDCB);
     291           0 :     }
     292           0 : }
     293             : 
     294           0 : void    SwIndexMarkPane::UpdateLanguageDependenciesForPhoneticReading()
     295             : {
     296             :     //no phonetic reading if no global cjk support
     297           0 :     if( !xExtendedIndexEntrySupplier.is() )
     298             :     {
     299           0 :         bIsPhoneticReadingEnabled = sal_False;
     300           0 :         return;
     301             :     }
     302           0 :     bIsPhoneticReadingEnabled = sal_True;
     303             : 
     304             :     //get the current language
     305           0 :     if(!bNewMark) //if dialog is opened to iterate existing marks
     306             :     {
     307             :         OSL_ENSURE(pTOXMgr, "need TOXMgr");
     308           0 :         if(!pTOXMgr)
     309           0 :             return;
     310           0 :         SwTOXMark* pMark = pTOXMgr->GetCurTOXMark();
     311             :         OSL_ENSURE(pMark, "need current SwTOXMark");
     312           0 :         if(!pMark)
     313           0 :             return;
     314           0 :         SwTxtTOXMark* pTxtTOXMark = pMark->GetTxtTOXMark();
     315             :         OSL_ENSURE(pTxtTOXMark, "need current SwTxtTOXMark");
     316           0 :         if(!pTxtTOXMark)
     317           0 :             return;
     318           0 :         const SwTxtNode* pTxtNode = pTxtTOXMark->GetpTxtNd();
     319             :         OSL_ENSURE(pTxtNode, "need current SwTxtNode");
     320           0 :         if(!pTxtNode)
     321           0 :             return;
     322           0 :         sal_Int32 nTextIndex = *pTxtTOXMark->GetStart();
     323           0 :         nLangForPhoneticReading = pTxtNode->GetLang( nTextIndex );
     324             :     }
     325             :     else //if dialog is opened to create a new mark
     326             :     {
     327             :         sal_uInt16 nWhich;
     328           0 :         switch(pSh->GetScriptType())
     329             :         {
     330           0 :             case SCRIPTTYPE_ASIAN: nWhich = RES_CHRATR_CJK_LANGUAGE; break;
     331           0 :             case SCRIPTTYPE_COMPLEX:nWhich = RES_CHRATR_CTL_LANGUAGE; break;
     332           0 :             default:nWhich = RES_CHRATR_LANGUAGE; break;
     333             :         }
     334           0 :         SfxItemSet aLangSet(pSh->GetAttrPool(), nWhich, nWhich);
     335           0 :         pSh->GetCurAttr(aLangSet);
     336           0 :         nLangForPhoneticReading = ((const SvxLanguageItem&)aLangSet.Get(nWhich)).GetLanguage();
     337             :     }
     338             : 
     339             : }
     340             : 
     341           0 : OUString SwIndexMarkPane::GetDefaultPhoneticReading( const OUString& rText )
     342             : {
     343           0 :     if( !bIsPhoneticReadingEnabled )
     344           0 :         return OUString();
     345             : 
     346           0 :     return xExtendedIndexEntrySupplier->getPhoneticCandidate(rText, LanguageTag::convertToLocale( nLangForPhoneticReading ));
     347             : }
     348             : 
     349             : /* --------------------------------------------------
     350             :     Change the content of m_pEntryED if text is selected
     351             :  --------------------------------------------------*/
     352           0 : void    SwIndexMarkPane::Activate()
     353             : {
     354             :     // display current selection (first element) ????
     355           0 :     if(bNewMark)
     356             :     {
     357           0 :         if (pSh->GetCrsrCnt() < 2)
     358             :         {
     359           0 :             bSelected = !pSh->HasSelection();
     360           0 :             aOrgStr = pSh->GetView().GetSelectionTextParam(true, false);
     361           0 :             m_pEntryED->SetText(aOrgStr);
     362             : 
     363             :             //to include all equal entries may only be allowed in the body and even there
     364             :             //only when a simple selection exists
     365           0 :             const sal_uInt16 nFrmType = pSh->GetFrmType(0,sal_True);
     366           0 :             m_pApplyToAllCB->Show();
     367           0 :             m_pSearchCaseSensitiveCB->Show();
     368           0 :             m_pSearchCaseWordOnlyCB->Show();
     369           0 :             m_pApplyToAllCB->Enable(!aOrgStr.isEmpty() &&
     370           0 :                 0 == (nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FLY_ANY )));
     371           0 :             SearchTypeHdl(m_pApplyToAllCB);
     372             :         }
     373           0 :         ModifyHdl(m_pTypeDCB);
     374             :     }
     375           0 : }
     376             : 
     377             : /*--------------------------------------------------------------------
     378             :      Description:   evaluate Ok-Button
     379             :  --------------------------------------------------------------------*/
     380           0 : void SwIndexMarkPane::Apply()
     381             : {
     382           0 :     InsertUpdate();
     383           0 :     if(bSelected)
     384           0 :         pSh->ResetSelect(0, sal_False);
     385           0 : }
     386             : 
     387             : /*--------------------------------------------------------------------
     388             :     Description: apply changes
     389             :  --------------------------------------------------------------------*/
     390           0 : void SwIndexMarkPane::InsertUpdate()
     391             : {
     392           0 :     pSh->StartUndo(bDel ? UNDO_INDEX_ENTRY_DELETE : UNDO_INDEX_ENTRY_INSERT);
     393           0 :     pSh->StartAllAction();
     394             : 
     395           0 :     SwRewriter aRewriter;
     396             : 
     397           0 :     if( bNewMark )
     398             :     {
     399           0 :         InsertMark();
     400             : 
     401           0 :         if ( pTOXMgr->GetCurTOXMark())
     402           0 :             aRewriter.AddRule(UndoArg1, pTOXMgr->GetCurTOXMark()->GetText());
     403             :     }
     404           0 :     else if( !pSh->HasReadonlySel() )
     405             :     {
     406           0 :         if ( pTOXMgr->GetCurTOXMark())
     407             :             aRewriter.AddRule(UndoArg1,
     408           0 :                               pTOXMgr->GetCurTOXMark()->GetText());
     409             : 
     410           0 :         if( bDel )
     411           0 :             pTOXMgr->DeleteTOXMark();
     412           0 :         else if( pTOXMgr->GetCurTOXMark() )
     413           0 :             UpdateMark();
     414             :     }
     415             : 
     416           0 :     pSh->EndAllAction();
     417           0 :     pSh->EndUndo(bDel ? UNDO_INDEX_ENTRY_DELETE : UNDO_INDEX_ENTRY_INSERT);
     418             : 
     419           0 :     if((nTypePos = m_pTypeDCB->GetEntryPos(m_pTypeDCB->GetSelectEntry())) == LISTBOX_ENTRY_NOTFOUND)
     420           0 :         nTypePos = 0;
     421             : 
     422           0 :     nKey1Pos = m_pKey1DCB->GetEntryPos(m_pKey1DCB->GetText());
     423           0 :     nKey2Pos = m_pKey2DCB->GetEntryPos(m_pKey2DCB->GetText());
     424           0 : }
     425             : 
     426             : /*--------------------------------------------------------------------
     427             :      Description:   insert mark
     428             :  --------------------------------------------------------------------*/
     429           0 : static void lcl_SelectSameStrings(SwWrtShell& rSh, sal_Bool bWordOnly, sal_Bool bCaseSensitive)
     430             : {
     431           0 :     rSh.Push();
     432             : 
     433             :     SearchOptions aSearchOpt(
     434             :                         SearchAlgorithms_ABSOLUTE,
     435             :                         ( bWordOnly ? SearchFlags::NORM_WORD_ONLY : 0 ),
     436             :                         rSh.GetSelTxt(), OUString(),
     437           0 :                         GetAppLanguageTag().getLocale(),
     438             :                         0, 0, 0,
     439             :                         (bCaseSensitive
     440             :                             ? 0
     441           0 :                             : static_cast<int>(TransliterationModules_IGNORE_CASE)) );
     442             : 
     443           0 :     rSh.ClearMark();
     444             :     sal_Bool bCancel;
     445             : 
     446             :     //todo/mba: assuming that notes should not be searched
     447           0 :     sal_Bool bSearchInNotes = sal_False;
     448             :     rSh.Find( aSearchOpt,  bSearchInNotes, DOCPOS_START, DOCPOS_END, bCancel,
     449           0 :                         (FindRanges)(FND_IN_SELALL|FND_IN_BODYONLY), sal_False );
     450           0 : }
     451             : 
     452           0 : void SwIndexMarkPane::InsertMark()
     453             : {
     454           0 :     sal_Int32 nPos = m_pTypeDCB->GetEntryPos(m_pTypeDCB->GetSelectEntry());
     455             :     TOXTypes eType = nPos == POS_CONTENT ? TOX_CONTENT :
     456           0 :                         nPos == POS_INDEX ? TOX_INDEX : TOX_USER;
     457             : 
     458           0 :     SwTOXMarkDescription aDesc(eType);
     459             : 
     460           0 :     const int nLevel = m_pLevelNF->Denormalize(m_pLevelNF->GetValue());
     461           0 :     switch(nPos)
     462             :     {
     463           0 :         case POS_CONTENT : break;
     464             :         case POS_INDEX:     // keyword index mark
     465             :         {
     466           0 :             UpdateKeyBoxes();
     467           0 :             aDesc.SetPrimKey(m_pKey1DCB->GetText());
     468           0 :             aDesc.SetSecKey(m_pKey2DCB->GetText());
     469           0 :             aDesc.SetMainEntry(m_pMainEntryCB->IsChecked());
     470           0 :             aDesc.SetPhoneticReadingOfAltStr(m_pPhoneticED0->GetText());
     471           0 :             aDesc.SetPhoneticReadingOfPrimKey(m_pPhoneticED1->GetText());
     472           0 :             aDesc.SetPhoneticReadingOfSecKey(m_pPhoneticED2->GetText());
     473             :         }
     474           0 :         break;
     475             :         default:            // Userdefined index mark
     476             :         {
     477           0 :             aDesc.SetTOUName(m_pTypeDCB->GetSelectEntry());
     478             :         }
     479             :     }
     480           0 :     if (aOrgStr != m_pEntryED->GetText())
     481           0 :         aDesc.SetAltStr(m_pEntryED->GetText());
     482           0 :     sal_Bool bApplyAll = m_pApplyToAllCB->IsChecked();
     483           0 :     sal_Bool bWordOnly = m_pSearchCaseWordOnlyCB->IsChecked();
     484           0 :     sal_Bool bCaseSensitive = m_pSearchCaseSensitiveCB->IsChecked();
     485             : 
     486           0 :     pSh->StartAllAction();
     487             :     // all equal strings have to be selected here so that the
     488             :     // entry is apllied to all equal strings
     489           0 :     if(bApplyAll)
     490             :     {
     491           0 :         lcl_SelectSameStrings(*pSh, bWordOnly, bCaseSensitive);
     492             :     }
     493           0 :     aDesc.SetLevel(nLevel);
     494           0 :     SwTOXMgr aMgr(pSh);
     495           0 :     aMgr.InsertTOXMark(aDesc);
     496           0 :     if(bApplyAll)
     497           0 :         pSh->Pop(sal_False);
     498             : 
     499           0 :     pSh->EndAllAction();
     500           0 : }
     501             : 
     502             : /*--------------------------------------------------------------------
     503             :      Description:   update mark
     504             :  --------------------------------------------------------------------*/
     505           0 : void SwIndexMarkPane::UpdateMark()
     506             : {
     507           0 :     OUString  aAltText(m_pEntryED->GetText());
     508           0 :     OUString* pAltText = aOrgStr != m_pEntryED->GetText() ? &aAltText : 0;
     509             :     //empty alternative texts are not allowed
     510           0 :     if(pAltText && pAltText->isEmpty())
     511           0 :         return;
     512             : 
     513           0 :     UpdateKeyBoxes();
     514             : 
     515           0 :     sal_Int32 nPos = m_pTypeDCB->GetEntryPos(m_pTypeDCB->GetSelectEntry());
     516           0 :     TOXTypes eType = TOX_USER;
     517           0 :     if(POS_CONTENT == nPos)
     518           0 :         eType = TOX_CONTENT;
     519           0 :     else if(POS_INDEX == nPos)
     520           0 :         eType = TOX_INDEX;
     521             : 
     522           0 :     SwTOXMarkDescription aDesc(eType);
     523           0 :     aDesc.SetLevel( static_cast< int >(m_pLevelNF->GetValue()) );
     524           0 :     if(pAltText)
     525           0 :         aDesc.SetAltStr(*pAltText);
     526             : 
     527           0 :     OUString  aPrim(m_pKey1DCB->GetText());
     528           0 :     if(!aPrim.isEmpty())
     529           0 :         aDesc.SetPrimKey(aPrim);
     530           0 :     OUString  aSec(m_pKey2DCB->GetText());
     531           0 :     if(!aSec.isEmpty())
     532           0 :         aDesc.SetSecKey(aSec);
     533             : 
     534           0 :     if(eType == TOX_INDEX)
     535             :     {
     536           0 :         aDesc.SetPhoneticReadingOfAltStr(m_pPhoneticED0->GetText());
     537           0 :         aDesc.SetPhoneticReadingOfPrimKey(m_pPhoneticED1->GetText());
     538           0 :         aDesc.SetPhoneticReadingOfSecKey(m_pPhoneticED2->GetText());
     539             :     }
     540           0 :     aDesc.SetMainEntry(m_pMainEntryCB->IsVisible() && m_pMainEntryCB->IsChecked());
     541           0 :     pTOXMgr->UpdateTOXMark(aDesc);
     542             : }
     543             : 
     544             : /*--------------------------------------------------------------------
     545             :     Description: insert new keys
     546             :  --------------------------------------------------------------------*/
     547           0 : void SwIndexMarkPane::UpdateKeyBoxes()
     548             : {
     549           0 :     OUString aKey(m_pKey1DCB->GetText());
     550           0 :     sal_Int32 nPos = m_pKey1DCB->GetEntryPos(aKey);
     551             : 
     552           0 :     if(nPos == COMBOBOX_ENTRY_NOTFOUND && !aKey.isEmpty())
     553             :     {   // create new key
     554           0 :         m_pKey1DCB->InsertEntry(aKey);
     555             :     }
     556             : 
     557           0 :     aKey = m_pKey2DCB->GetText();
     558           0 :     nPos = m_pKey2DCB->GetEntryPos(aKey);
     559             : 
     560           0 :     if(nPos == COMBOBOX_ENTRY_NOTFOUND && !aKey.isEmpty())
     561             :     {   // create new key
     562           0 :         m_pKey2DCB->InsertEntry(aKey);
     563           0 :     }
     564           0 : }
     565             : 
     566           0 : class SwNewUserIdxDlg : public ModalDialog
     567             : {
     568             :     OKButton*        m_pOKPB;
     569             :     Edit*            m_pNameED;
     570             : 
     571             :     SwIndexMarkPane* m_pDlg;
     572             : 
     573             :     DECL_LINK( ModifyHdl, Edit*);
     574             : 
     575             :     public:
     576           0 :         SwNewUserIdxDlg(SwIndexMarkPane* pPane)
     577           0 :             : ModalDialog(&(pPane->GetDialog()), "NewUserIndexDialog",
     578             :                 "modules/swriter/ui/newuserindexdialog.ui")
     579           0 :             , m_pDlg(pPane)
     580             :             {
     581           0 :                 get(m_pOKPB, "ok");
     582           0 :                 get(m_pNameED, "entry");
     583           0 :                 m_pNameED->SetModifyHdl(LINK(this, SwNewUserIdxDlg, ModifyHdl));
     584           0 :                 m_pOKPB->Enable(false);
     585           0 :                 m_pNameED->GrabFocus();
     586           0 :             }
     587             : 
     588             :     virtual void    Apply();
     589           0 :     OUString  GetName(){return m_pNameED->GetText();}
     590             : };
     591           0 : void SwNewUserIdxDlg::Apply()
     592             : {
     593           0 : }
     594             : 
     595           0 : IMPL_LINK( SwNewUserIdxDlg, ModifyHdl, Edit*, pEdit)
     596             : {
     597           0 :     m_pOKPB->Enable(!pEdit->GetText().isEmpty() && !m_pDlg->IsTOXType(pEdit->GetText()));
     598           0 :     return 0;
     599             : }
     600             : 
     601           0 : IMPL_LINK_NOARG(SwIndexMarkPane, NewUserIdxHdl)
     602             : {
     603           0 :     SwNewUserIdxDlg* pDlg = new SwNewUserIdxDlg(this);
     604           0 :     if(RET_OK == pDlg->Execute())
     605             :     {
     606           0 :         OUString sNewName(pDlg->GetName());
     607           0 :         m_pTypeDCB->InsertEntry(sNewName);
     608           0 :         m_pTypeDCB->SelectEntry(sNewName);
     609             :     }
     610           0 :     delete pDlg;
     611           0 :     return 0;
     612             : }
     613             : 
     614           0 : IMPL_LINK( SwIndexMarkPane, SearchTypeHdl, CheckBox*, pBox)
     615             : {
     616           0 :     sal_Bool bEnable = pBox->IsChecked() && pBox->IsEnabled();
     617           0 :     m_pSearchCaseWordOnlyCB->Enable(bEnable);
     618           0 :     m_pSearchCaseSensitiveCB->Enable(bEnable);
     619           0 :     return 0;
     620             : }
     621             : 
     622           0 : IMPL_LINK( SwIndexMarkPane, InsertHdl, Button *, pButton )
     623             : {
     624           0 :     Apply();
     625             :     //close the dialog if only one entry is available
     626           0 :     if(!bNewMark && !m_pPrevBT->IsVisible() && !m_pNextBT->IsVisible())
     627           0 :         CloseHdl(pButton);
     628           0 :     return 0;
     629             : }
     630             : 
     631           0 : IMPL_LINK_NOARG(SwIndexMarkPane, CloseHdl)
     632             : {
     633           0 :     if(bNewMark)
     634             :     {
     635           0 :         sal_uInt16 nSlot = FN_INSERT_IDX_ENTRY_DLG;
     636             :         SfxViewFrame::Current()->GetDispatcher()->Execute(nSlot,
     637           0 :                     SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD);
     638             :     }
     639             :     else
     640             :     {
     641           0 :         m_rDialog.EndDialog(RET_CANCEL);
     642             :     }
     643           0 :     return 0;
     644             : }
     645             : 
     646             : /*--------------------------------------------------------------------
     647             :      Description:   select index type only when inserting
     648             :  --------------------------------------------------------------------*/
     649           0 : IMPL_LINK( SwIndexMarkPane, ModifyHdl, ListBox *, pBox )
     650             : {
     651           0 :     if (m_pTypeDCB == pBox)
     652             :     {
     653             :         // set index type
     654           0 :         sal_Int32 nPos = m_pTypeDCB->GetEntryPos(m_pTypeDCB->GetSelectEntry());
     655           0 :         sal_Bool bLevelEnable = sal_False,
     656           0 :              bKeyEnable   = sal_False,
     657           0 :              bSetKey2     = sal_False,
     658           0 :              bKey2Enable  = sal_False,
     659           0 :             bEntryHasText   = sal_False,
     660           0 :             bKey1HasText    = sal_False,
     661           0 :             bKey2HasText    = sal_False;
     662           0 :         if(nPos == POS_INDEX)
     663             :         {
     664           0 :             if(!m_pEntryED->GetText().isEmpty())
     665           0 :                 bEntryHasText = sal_True;
     666           0 :             m_pPhoneticED0->SetText(GetDefaultPhoneticReading(m_pEntryED->GetText()));
     667             : 
     668           0 :             bKeyEnable = sal_True;
     669           0 :             m_pKey1DCB->SetText(m_pKey1DCB->GetEntry(nKey1Pos));
     670           0 :             m_pPhoneticED1->SetText(GetDefaultPhoneticReading(m_pKey1DCB->GetText()));
     671           0 :             if(!m_pKey1DCB->GetText().isEmpty())
     672             :             {
     673           0 :                 bKey1HasText = bSetKey2 = bKey2Enable = sal_True;
     674           0 :                 m_pKey2DCB->SetText(m_pKey2DCB->GetEntry(nKey2Pos));
     675           0 :                 m_pPhoneticED2->SetText(GetDefaultPhoneticReading(m_pKey2DCB->GetText()));
     676           0 :                 if(!m_pKey2DCB->GetText().isEmpty())
     677           0 :                     bKey2HasText = sal_True;
     678             :             }
     679             :         }
     680             :         else
     681             :         {
     682           0 :             bLevelEnable = sal_True;
     683           0 :             m_pLevelNF->SetMax(MAXLEVEL);
     684           0 :             m_pLevelNF->SetValue(m_pLevelNF->Normalize(0));
     685           0 :             bSetKey2 = sal_True;
     686             :         }
     687           0 :         m_pLevelFT->Show(bLevelEnable);
     688           0 :         m_pLevelNF->Show(bLevelEnable);
     689           0 :         m_pMainEntryCB->Show(nPos == POS_INDEX);
     690             : 
     691           0 :         m_pKey1FT->Enable(bKeyEnable);
     692           0 :         m_pKey1DCB->Enable(bKeyEnable);
     693           0 :         if ( bSetKey2 )
     694             :         {
     695           0 :             m_pKey2DCB->Enable(bKey2Enable);
     696           0 :             m_pKey2FT->Enable(bKey2Enable);
     697             :         }
     698           0 :         m_pPhoneticFT0->Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
     699           0 :         m_pPhoneticED0->Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
     700           0 :         m_pPhoneticFT1->Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
     701           0 :         m_pPhoneticED1->Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
     702           0 :         m_pPhoneticFT2->Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
     703           0 :         m_pPhoneticED2->Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
     704             :     }
     705             :     else //m_pEntryED  !!m_pEntryED is not a ListBox but a Edit
     706             :     {
     707           0 :         bool bHasText = (!m_pEntryED->GetText().isEmpty());
     708           0 :         if(!bHasText)
     709             :         {
     710           0 :             m_pPhoneticED0->SetText(OUString());
     711           0 :             bPhoneticED0_ChangedByUser = sal_False;
     712             :         }
     713           0 :         else if(!bPhoneticED0_ChangedByUser)
     714           0 :             m_pPhoneticED0->SetText(GetDefaultPhoneticReading(m_pEntryED->GetText()));
     715             : 
     716           0 :         m_pPhoneticFT0->Enable(bHasText&&bIsPhoneticReadingEnabled);
     717           0 :         m_pPhoneticED0->Enable(bHasText&&bIsPhoneticReadingEnabled);
     718             :     }
     719           0 :     m_pOKBT->Enable(!pSh->HasReadonlySel() &&
     720           0 :         (!m_pEntryED->GetText().isEmpty() || pSh->GetCrsrCnt(sal_False)));
     721           0 :     return 0;
     722             : }
     723             : 
     724           0 : IMPL_LINK_NOARG_INLINE_START(SwIndexMarkPane, NextHdl)
     725             : {
     726           0 :     InsertUpdate();
     727           0 :     pTOXMgr->NextTOXMark();
     728           0 :     UpdateDialog();
     729           0 :     return 0;
     730             : }
     731           0 : IMPL_LINK_NOARG_INLINE_END(SwIndexMarkPane, NextHdl)
     732             : 
     733           0 : IMPL_LINK_NOARG_INLINE_START(SwIndexMarkPane, NextSameHdl)
     734             : {
     735           0 :     InsertUpdate();
     736           0 :     pTOXMgr->NextTOXMark(sal_True);
     737           0 :     UpdateDialog();
     738           0 :     return 0;
     739             : }
     740           0 : IMPL_LINK_NOARG_INLINE_END(SwIndexMarkPane, NextSameHdl)
     741             : 
     742           0 : IMPL_LINK_NOARG_INLINE_START(SwIndexMarkPane, PrevHdl)
     743             : {
     744           0 :     InsertUpdate();
     745           0 :     pTOXMgr->PrevTOXMark();
     746           0 :     UpdateDialog();
     747           0 :     return 0;
     748             : }
     749           0 : IMPL_LINK_NOARG_INLINE_END(SwIndexMarkPane, PrevHdl)
     750             : 
     751           0 : IMPL_LINK_NOARG_INLINE_START(SwIndexMarkPane, PrevSameHdl)
     752             : {
     753           0 :     InsertUpdate();
     754           0 :     pTOXMgr->PrevTOXMark(sal_True);
     755           0 :     UpdateDialog();
     756             : 
     757           0 :     return 0;
     758             : }
     759           0 : IMPL_LINK_NOARG_INLINE_END(SwIndexMarkPane, PrevSameHdl)
     760             : 
     761           0 : IMPL_LINK_NOARG(SwIndexMarkPane, DelHdl)
     762             : {
     763           0 :     bDel = sal_True;
     764           0 :     InsertUpdate();
     765           0 :     bDel = sal_False;
     766             : 
     767           0 :     if(pTOXMgr->GetCurTOXMark())
     768           0 :         UpdateDialog();
     769             :     else
     770             :     {
     771           0 :         CloseHdl(m_pCloseBT);
     772           0 :         SfxViewFrame::Current()->GetBindings().Invalidate(FN_EDIT_IDX_ENTRY_DLG);
     773             :     }
     774           0 :     return 0;
     775             : }
     776             : 
     777             : /*--------------------------------------------------------------------
     778             :      Description: renew dialog view
     779             :  --------------------------------------------------------------------*/
     780           0 : void SwIndexMarkPane::UpdateDialog()
     781             : {
     782             :     OSL_ENSURE(pSh && pTOXMgr, "no shell?");
     783           0 :     SwTOXMark* pMark = pTOXMgr->GetCurTOXMark();
     784             :     OSL_ENSURE(pMark, "no current marker");
     785           0 :     if(!pMark)
     786           0 :         return;
     787             : 
     788           0 :     SwViewShell::SetCareWin(&m_rDialog);
     789             : 
     790           0 :     aOrgStr = pMark->GetText();
     791           0 :     m_pEntryED->SetText(aOrgStr);
     792             : 
     793             :     // set index type
     794           0 :     sal_Bool bLevelEnable = sal_True,
     795           0 :          bKeyEnable   = sal_False,
     796           0 :          bKey2Enable  = sal_False,
     797           0 :          bEntryHasText  = sal_False,
     798           0 :          bKey1HasText   = sal_False,
     799           0 :          bKey2HasText   = sal_False;
     800             : 
     801           0 :     TOXTypes eCurType = pMark->GetTOXType()->GetType();
     802           0 :     if(TOX_INDEX == eCurType)
     803             :     {
     804           0 :         bLevelEnable = sal_False;
     805           0 :         bKeyEnable = sal_True;
     806           0 :         bKey1HasText = bKey2Enable = !pMark->GetPrimaryKey().isEmpty();
     807           0 :         bKey2HasText = !pMark->GetSecondaryKey().isEmpty();
     808           0 :         bEntryHasText = !pMark->GetText().isEmpty();
     809           0 :         m_pKey1DCB->SetText( pMark->GetPrimaryKey() );
     810           0 :         m_pKey2DCB->SetText( pMark->GetSecondaryKey() );
     811           0 :         m_pPhoneticED0->SetText( pMark->GetTextReading() );
     812           0 :         m_pPhoneticED1->SetText( pMark->GetPrimaryKeyReading() );
     813           0 :         m_pPhoneticED2->SetText( pMark->GetSecondaryKeyReading() );
     814           0 :         m_pMainEntryCB->Check(pMark->IsMainEntry());
     815             :     }
     816           0 :     else if(TOX_CONTENT == eCurType || TOX_USER == eCurType)
     817             :     {
     818           0 :         m_pLevelNF->SetValue(m_pLevelNF->Normalize(pMark->GetLevel()));
     819             :     }
     820           0 :     m_pKey1FT->Enable(bKeyEnable);
     821           0 :     m_pKey1DCB->Enable(bKeyEnable);
     822           0 :     m_pLevelNF->SetMax(MAXLEVEL);
     823           0 :     m_pLevelFT->Show(bLevelEnable);
     824           0 :     m_pLevelNF->Show(bLevelEnable);
     825           0 :     m_pMainEntryCB->Show(!bLevelEnable);
     826           0 :     m_pKey2FT->Enable(bKey2Enable);
     827           0 :     m_pKey2DCB->Enable(bKey2Enable);
     828             : 
     829           0 :     UpdateLanguageDependenciesForPhoneticReading();
     830           0 :     m_pPhoneticFT0->Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
     831           0 :     m_pPhoneticED0->Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
     832           0 :     m_pPhoneticFT1->Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
     833           0 :     m_pPhoneticED1->Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
     834           0 :     m_pPhoneticFT2->Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
     835           0 :     m_pPhoneticED2->Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
     836             : 
     837             :     // set index type
     838           0 :     m_pTypeDCB->SelectEntry(pMark->GetTOXType()->GetTypeName());
     839             : 
     840             :     // set Next - Prev - Buttons
     841           0 :     pSh->SttCrsrMove();
     842           0 :     if( m_pPrevBT->IsVisible() )
     843             :     {
     844           0 :         const SwTOXMark* pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_PRV );
     845           0 :         if( pMoveMark != pMark )
     846           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_NXT );
     847           0 :         m_pPrevBT->Enable( pMoveMark != pMark );
     848           0 :         pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_NXT );
     849           0 :         if( pMoveMark != pMark )
     850           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_PRV );
     851           0 :         m_pNextBT->Enable( pMoveMark != pMark );
     852             :     }
     853             : 
     854           0 :     if( m_pPrevSameBT->IsVisible() )
     855             :     {
     856           0 :         const SwTOXMark* pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_SAME_PRV );
     857           0 :         if( pMoveMark != pMark )
     858           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_SAME_NXT );
     859           0 :         m_pPrevSameBT->Enable( pMoveMark != pMark );
     860           0 :         pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_SAME_NXT );
     861           0 :         if( pMoveMark != pMark )
     862           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_SAME_PRV );
     863           0 :         m_pNextSameBT->Enable( pMoveMark != pMark );
     864             :     }
     865             : 
     866           0 :     sal_Bool bEnable = !pSh->HasReadonlySel();
     867           0 :     m_pOKBT->Enable( bEnable );
     868           0 :     m_pDelBT->Enable( bEnable );
     869           0 :     m_pEntryED->SetReadOnly( !bEnable );
     870           0 :     m_pLevelNF->SetReadOnly( !bEnable );
     871           0 :     m_pKey1DCB->SetReadOnly( !bEnable );
     872           0 :     m_pKey2DCB->SetReadOnly( !bEnable );
     873             : 
     874           0 :     pSh->SelectTxtAttr( RES_TXTATR_TOXMARK, pMark->GetTxtTOXMark() );
     875             :     // we need the point at the start of the attribut
     876           0 :     pSh->SwapPam();
     877             : 
     878           0 :     pSh->EndCrsrMove();
     879             : }
     880             : 
     881             : /*--------------------------------------------------------------------
     882             :      Remind whether the edit boxes for Phonetic reading are changed manually
     883             :  --------------------------------------------------------------------*/
     884           0 : IMPL_LINK( SwIndexMarkPane, PhoneticEDModifyHdl, Edit *, pEdit )
     885             : {
     886           0 :     if (m_pPhoneticED0 == pEdit)
     887             :     {
     888           0 :         bPhoneticED0_ChangedByUser = !pEdit->GetText().isEmpty();
     889             :     }
     890           0 :     else if (m_pPhoneticED1 == pEdit)
     891             :     {
     892           0 :         bPhoneticED1_ChangedByUser = !pEdit->GetText().isEmpty();
     893             :     }
     894           0 :     else if (m_pPhoneticED2 == pEdit)
     895             :     {
     896           0 :         bPhoneticED2_ChangedByUser = !pEdit->GetText().isEmpty();
     897             :     }
     898           0 :     return 0;
     899             : }
     900             : 
     901             : /*--------------------------------------------------------------------
     902             :      Description: Enable Disable of the 2nd key
     903             :  --------------------------------------------------------------------*/
     904           0 : IMPL_LINK( SwIndexMarkPane, KeyDCBModifyHdl, ComboBox *, pBox )
     905             : {
     906           0 :     if (m_pKey1DCB == pBox)
     907             :     {
     908           0 :         sal_Bool bEnable = !pBox->GetText().isEmpty();
     909           0 :         if(!bEnable)
     910             :         {
     911           0 :             m_pKey2DCB->SetText(OUString());
     912           0 :             m_pPhoneticED1->SetText(OUString());
     913           0 :             m_pPhoneticED2->SetText(OUString());
     914           0 :             bPhoneticED1_ChangedByUser = sal_False;
     915           0 :             bPhoneticED2_ChangedByUser = sal_False;
     916             :         }
     917             :         else
     918             :         {
     919           0 :             if(pBox->IsInDropDown())
     920             :             {
     921             :                 //reset bPhoneticED1_ChangedByUser if a completely new string is selected
     922           0 :                 bPhoneticED1_ChangedByUser = sal_False;
     923             :             }
     924           0 :             if(!bPhoneticED1_ChangedByUser)
     925           0 :                 m_pPhoneticED1->SetText(GetDefaultPhoneticReading(pBox->GetText()));
     926             :         }
     927           0 :         m_pKey2DCB->Enable(bEnable);
     928           0 :         m_pKey2FT->Enable(bEnable);
     929             :     }
     930           0 :     else if (m_pKey2DCB == pBox)
     931             :     {
     932           0 :         if(pBox->GetText().isEmpty())
     933             :         {
     934           0 :             m_pPhoneticED2->SetText(OUString());
     935           0 :             bPhoneticED2_ChangedByUser = sal_False;
     936             :         }
     937             :         else
     938             :         {
     939           0 :             if(pBox->IsInDropDown())
     940             :             {
     941             :                 //reset bPhoneticED1_ChangedByUser if a completely new string is selected
     942           0 :                 bPhoneticED2_ChangedByUser = sal_False;
     943             :             }
     944           0 :             if(!bPhoneticED2_ChangedByUser)
     945           0 :                 m_pPhoneticED2->SetText(GetDefaultPhoneticReading(pBox->GetText()));
     946             :         }
     947             :     }
     948           0 :     bool    bKey1HasText    = (!m_pKey1DCB->GetText().isEmpty());
     949           0 :     bool    bKey2HasText    = (!m_pKey2DCB->GetText().isEmpty());
     950             : 
     951           0 :     m_pPhoneticFT1->Enable(bKey1HasText && bIsPhoneticReadingEnabled);
     952           0 :     m_pPhoneticED1->Enable(bKey1HasText && bIsPhoneticReadingEnabled);
     953           0 :     m_pPhoneticFT2->Enable(bKey2HasText && bIsPhoneticReadingEnabled);
     954           0 :     m_pPhoneticED2->Enable(bKey2HasText && bIsPhoneticReadingEnabled);
     955             : 
     956           0 :     return 0;
     957             : }
     958             : 
     959             : /*--------------------------------------------------
     960             :  overload dtor
     961             : --------------------------------------------------*/
     962           0 : SwIndexMarkPane::~SwIndexMarkPane()
     963             : {
     964           0 :     delete pTOXMgr;
     965           0 :     SwViewShell::SetCareWin( 0 );
     966           0 : }
     967             : 
     968           0 : void    SwIndexMarkPane::ReInitDlg(SwWrtShell& rWrtShell, SwTOXMark* pCurTOXMark)
     969             : {
     970           0 :     pSh = &rWrtShell;
     971           0 :     delete pTOXMgr;
     972           0 :     pTOXMgr = new SwTOXMgr(pSh);
     973           0 :     if(pCurTOXMark)
     974             :     {
     975           0 :         for(sal_uInt16 i = 0; i < pTOXMgr->GetTOXMarkCount(); i++)
     976           0 :             if(pTOXMgr->GetTOXMark(i) == pCurTOXMark)
     977             :             {
     978           0 :                 pTOXMgr->SetCurTOXMark(i);
     979           0 :                 break;
     980             :             }
     981             :     }
     982           0 :     InitControls();
     983           0 : }
     984             : 
     985           0 : SwIndexMarkFloatDlg::SwIndexMarkFloatDlg(SfxBindings* _pBindings,
     986             :     SfxChildWindow* pChild, Window *pParent,
     987             :     SfxChildWinInfo* pInfo, sal_Bool bNew)
     988             :     : SfxModelessDialog(_pBindings, pChild, pParent, "IndexEntryDialog", "modules/swriter/ui/indexentry.ui")
     989           0 :     , m_aContent(*this, bNew, *::GetActiveWrtShell())
     990             : {
     991           0 :     m_aContent.ReInitDlg(*::GetActiveWrtShell());
     992           0 :     Initialize(pInfo);
     993           0 : }
     994             : 
     995           0 : void SwIndexMarkFloatDlg::Activate()
     996             : {
     997           0 :     SfxModelessDialog::Activate();
     998           0 :     m_aContent.Activate();
     999           0 : }
    1000             : 
    1001           0 : void SwIndexMarkFloatDlg::ReInitDlg(SwWrtShell& rWrtShell)
    1002             : {
    1003           0 :     m_aContent.ReInitDlg( rWrtShell );
    1004           0 : }
    1005             : 
    1006           0 : SwIndexMarkModalDlg::SwIndexMarkModalDlg(Window *pParent, SwWrtShell& rSh, SwTOXMark* pCurTOXMark)
    1007             :     : SvxStandardDialog(pParent, "IndexEntryDialog", "modules/swriter/ui/indexentry.ui")
    1008           0 :     , m_aContent(*this, sal_False, rSh)
    1009             : {
    1010           0 :     m_aContent.ReInitDlg(rSh, pCurTOXMark);
    1011           0 : }
    1012             : 
    1013           0 : void SwIndexMarkModalDlg::Apply()
    1014             : {
    1015           0 :     m_aContent.Apply();
    1016           0 : }
    1017             : 
    1018             : class SwCreateAuthEntryDlg_Impl : public ModalDialog
    1019             : {
    1020             :     FixedText*      pFixedTexts[AUTH_FIELD_END];
    1021             :     ListBox*        pTypeListBox;
    1022             :     ComboBox*       pIdentifierBox;
    1023             :     Edit*           pEdits[AUTH_FIELD_END];
    1024             : 
    1025             :     OKButton*       m_pOKBT;
    1026             : 
    1027             :     Link            aShortNameCheckLink;
    1028             : 
    1029             :     SwWrtShell&     rWrtSh;
    1030             : 
    1031             :     sal_Bool            m_bNewEntryMode;
    1032             :     sal_Bool            m_bNameAllowed;
    1033             : 
    1034             :     DECL_LINK(IdentifierHdl, ComboBox*);
    1035             :     DECL_LINK(ShortNameHdl, Edit*);
    1036             :     DECL_LINK(EnableHdl, ListBox* pBox);
    1037             : 
    1038             : public:
    1039             :     SwCreateAuthEntryDlg_Impl(Window* pParent,
    1040             :                             const OUString pFields[],
    1041             :                             SwWrtShell& rSh,
    1042             :                             sal_Bool bNewEntry,
    1043             :                             bool bCreate);
    1044             :     virtual ~SwCreateAuthEntryDlg_Impl();
    1045             : 
    1046             :     OUString        GetEntryText(ToxAuthorityField eField) const;
    1047             : 
    1048           0 :     void            SetCheckNameHdl(const Link& rLink) {aShortNameCheckLink = rLink;}
    1049             : 
    1050             : };
    1051             : 
    1052             : struct TextInfo
    1053             : {
    1054             :     ToxAuthorityField nToxField;
    1055             :     const char* pHelpId;
    1056             : };
    1057             : 
    1058             : static const TextInfo aTextInfoArr[] =
    1059             : {
    1060             :     {AUTH_FIELD_IDENTIFIER,      HID_AUTH_FIELD_IDENTIFIER      },
    1061             :     {AUTH_FIELD_AUTHORITY_TYPE,  HID_AUTH_FIELD_AUTHORITY_TYPE  },
    1062             :     {AUTH_FIELD_AUTHOR,          HID_AUTH_FIELD_AUTHOR          },
    1063             :     {AUTH_FIELD_TITLE,           HID_AUTH_FIELD_TITLE           },
    1064             :     {AUTH_FIELD_YEAR,            HID_AUTH_FIELD_YEAR            },
    1065             :     {AUTH_FIELD_PUBLISHER,       HID_AUTH_FIELD_PUBLISHER       },
    1066             :     {AUTH_FIELD_ADDRESS,         HID_AUTH_FIELD_ADDRESS         },
    1067             :     {AUTH_FIELD_ISBN,            HID_AUTH_FIELD_ISBN            },
    1068             :     {AUTH_FIELD_CHAPTER,         HID_AUTH_FIELD_CHAPTER         },
    1069             :     {AUTH_FIELD_PAGES,           HID_AUTH_FIELD_PAGES           },
    1070             :     {AUTH_FIELD_EDITOR,          HID_AUTH_FIELD_EDITOR          },
    1071             :     {AUTH_FIELD_EDITION,         HID_AUTH_FIELD_EDITION         },
    1072             :     {AUTH_FIELD_BOOKTITLE,       HID_AUTH_FIELD_BOOKTITLE       },
    1073             :     {AUTH_FIELD_VOLUME,          HID_AUTH_FIELD_VOLUME          },
    1074             :     {AUTH_FIELD_HOWPUBLISHED,    HID_AUTH_FIELD_HOWPUBLISHED    },
    1075             :     {AUTH_FIELD_ORGANIZATIONS,   HID_AUTH_FIELD_ORGANIZATIONS   },
    1076             :     {AUTH_FIELD_INSTITUTION,     HID_AUTH_FIELD_INSTITUTION     },
    1077             :     {AUTH_FIELD_SCHOOL,          HID_AUTH_FIELD_SCHOOL          },
    1078             :     {AUTH_FIELD_REPORT_TYPE,     HID_AUTH_FIELD_REPORT_TYPE     },
    1079             :     {AUTH_FIELD_MONTH,           HID_AUTH_FIELD_MONTH           },
    1080             :     {AUTH_FIELD_JOURNAL,         HID_AUTH_FIELD_JOURNAL         },
    1081             :     {AUTH_FIELD_NUMBER,          HID_AUTH_FIELD_NUMBER          },
    1082             :     {AUTH_FIELD_SERIES,          HID_AUTH_FIELD_SERIES          },
    1083             :     {AUTH_FIELD_ANNOTE,          HID_AUTH_FIELD_ANNOTE          },
    1084             :     {AUTH_FIELD_NOTE,            HID_AUTH_FIELD_NOTE            },
    1085             :     {AUTH_FIELD_URL,             HID_AUTH_FIELD_URL             },
    1086             :     {AUTH_FIELD_CUSTOM1,         HID_AUTH_FIELD_CUSTOM1         },
    1087             :     {AUTH_FIELD_CUSTOM2,         HID_AUTH_FIELD_CUSTOM2         },
    1088             :     {AUTH_FIELD_CUSTOM3,         HID_AUTH_FIELD_CUSTOM3         },
    1089             :     {AUTH_FIELD_CUSTOM4,         HID_AUTH_FIELD_CUSTOM4         },
    1090             :     {AUTH_FIELD_CUSTOM5,         HID_AUTH_FIELD_CUSTOM5         }
    1091             : };
    1092             : 
    1093             : sal_Bool SwAuthorMarkPane::bIsFromComponent = sal_True;
    1094             : 
    1095           0 : SwAuthorMarkPane::SwAuthorMarkPane(Dialog &rDialog, sal_Bool bNewDlg)
    1096             :     : m_rDialog(rDialog)
    1097             :     , bNewEntry(bNewDlg)
    1098             :     , bBibAccessInitialized(sal_False)
    1099           0 :     , pSh(0)
    1100             : {
    1101           0 :     m_rDialog.get(m_pFromComponentRB, "frombibliography");
    1102           0 :     m_rDialog.get(m_pFromDocContentRB, "fromdocument");
    1103           0 :     m_rDialog.get(m_pAuthorFI, "author");
    1104           0 :     m_rDialog.get(m_pTitleFI, "title");
    1105           0 :     m_rDialog.get(m_pEntryED, "entryed");
    1106           0 :     m_rDialog.get(m_pEntryLB, "entrylb");
    1107             :     m_rDialog.get(m_pActionBT,
    1108           0 :         bNewEntry ? OString("insert") : OString("modify"));
    1109           0 :     m_pActionBT->Show(true);
    1110           0 :     m_rDialog.get(m_pCloseBT, "close");
    1111           0 :     m_rDialog.get(m_pCreateEntryPB, "new");
    1112           0 :     m_rDialog.get(m_pEditEntryPB, "edit");
    1113             : 
    1114           0 :     m_pFromComponentRB->Show(bNewEntry);
    1115           0 :     m_pFromDocContentRB->Show(bNewEntry);
    1116           0 :     m_pFromComponentRB->Check(bIsFromComponent);
    1117           0 :     m_pFromDocContentRB->Check(!bIsFromComponent);
    1118             : 
    1119           0 :     m_pActionBT->SetClickHdl(LINK(this,SwAuthorMarkPane, InsertHdl));
    1120           0 :     m_pCloseBT->SetClickHdl(LINK(this,SwAuthorMarkPane, CloseHdl));
    1121           0 :     m_pCreateEntryPB->SetClickHdl(LINK(this,SwAuthorMarkPane, CreateEntryHdl));
    1122           0 :     m_pEditEntryPB->SetClickHdl(LINK(this,SwAuthorMarkPane, CreateEntryHdl));
    1123           0 :     m_pFromComponentRB->SetClickHdl(LINK(this,SwAuthorMarkPane, ChangeSourceHdl));
    1124           0 :     m_pFromDocContentRB->SetClickHdl(LINK(this,SwAuthorMarkPane, ChangeSourceHdl));
    1125           0 :     m_pEntryED->SetModifyHdl(LINK(this,SwAuthorMarkPane, EditModifyHdl));
    1126             : 
    1127             :     m_rDialog.SetText(SW_RESSTR(
    1128           0 :                     bNewEntry ? STR_AUTHMRK_INSERT : STR_AUTHMRK_EDIT));
    1129             : 
    1130           0 :     m_pEntryED->Show(!bNewEntry);
    1131           0 :     m_pEntryLB->Show(bNewEntry);
    1132           0 :     if(bNewEntry)
    1133             :     {
    1134           0 :         m_pEntryLB->SetSelectHdl(LINK(this, SwAuthorMarkPane, CompEntryHdl));
    1135             :     }
    1136           0 : }
    1137             : 
    1138           0 : void    SwAuthorMarkPane::ReInitDlg(SwWrtShell& rWrtShell)
    1139             : {
    1140           0 :     pSh = &rWrtShell;
    1141           0 :     InitControls();
    1142           0 : }
    1143             : 
    1144           0 : IMPL_LINK_NOARG(SwAuthorMarkPane, CloseHdl)
    1145             : {
    1146           0 :     if(bNewEntry)
    1147             :     {
    1148           0 :         sal_uInt16 nSlot = FN_INSERT_AUTH_ENTRY_DLG;
    1149             :         SfxViewFrame::Current()->GetDispatcher()->Execute(nSlot,
    1150           0 :                     SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD);
    1151             :     }
    1152             :     else
    1153             :     {
    1154           0 :         m_rDialog.EndDialog(RET_CANCEL);
    1155             :     }
    1156           0 :     return 0;
    1157             : }
    1158             : 
    1159           0 : static OUString lcl_FindColumnEntry(const beans::PropertyValue* pFields, sal_Int32 nLen, const OUString& rColumnTitle)
    1160             : {
    1161           0 :     for(sal_Int32 i = 0; i < nLen; i++)
    1162             :     {
    1163           0 :         OUString sRet;
    1164           0 :         if(pFields[i].Name == rColumnTitle &&
    1165           0 :             (pFields[i].Value >>= sRet))
    1166             :         {
    1167           0 :             return sRet;
    1168             :         }
    1169           0 :     }
    1170           0 :     return OUString();
    1171             : }
    1172             : 
    1173           0 : IMPL_LINK( SwAuthorMarkPane, CompEntryHdl, ListBox*, pBox)
    1174             : {
    1175           0 :     const OUString sEntry(pBox->GetSelectEntry());
    1176           0 :     if(bIsFromComponent)
    1177             :     {
    1178           0 :         if(xBibAccess.is() && !sEntry.isEmpty())
    1179             :         {
    1180           0 :             if(xBibAccess->hasByName(sEntry))
    1181             :             {
    1182           0 :                 uno::Any aEntry(xBibAccess->getByName(sEntry));
    1183           0 :                 uno::Sequence<beans::PropertyValue> aFieldProps;
    1184           0 :                 if(aEntry >>= aFieldProps)
    1185             :                 {
    1186           0 :                     const beans::PropertyValue* pProps = aFieldProps.getConstArray();
    1187           0 :                     for(sal_Int32 i = 0; i < AUTH_FIELD_END && i < aFieldProps.getLength(); i++)
    1188             :                     {
    1189           0 :                         m_sFields[i] = lcl_FindColumnEntry(
    1190           0 :                                 pProps, aFieldProps.getLength(), m_sColumnTitles[i]);
    1191             :                     }
    1192           0 :                 }
    1193             :             }
    1194             :         }
    1195             :     }
    1196             :     else
    1197             :     {
    1198           0 :         if(!sEntry.isEmpty())
    1199             :         {
    1200             :             const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
    1201           0 :                                         pSh->GetFldType(RES_AUTHORITY, OUString());
    1202           0 :             const SwAuthEntry*  pEntry = pFType ? pFType->GetEntryByIdentifier(sEntry) : 0;
    1203           0 :             for(int i = 0; i < AUTH_FIELD_END; i++)
    1204           0 :                 m_sFields[i] = pEntry ?
    1205           0 :                             pEntry->GetAuthorField((ToxAuthorityField)i) : OUString();
    1206             :         }
    1207             :     }
    1208           0 :     if (pBox->GetSelectEntry().isEmpty())
    1209             :     {
    1210           0 :         for(int i = 0; i < AUTH_FIELD_END; i++)
    1211           0 :             m_sFields[i] = OUString();
    1212             :     }
    1213           0 :     m_pAuthorFI->SetText(m_sFields[AUTH_FIELD_AUTHOR]);
    1214           0 :     m_pTitleFI->SetText(m_sFields[AUTH_FIELD_TITLE]);
    1215           0 :     return 0;
    1216             : }
    1217             : 
    1218           0 : IMPL_LINK_NOARG(SwAuthorMarkPane, InsertHdl)
    1219             : {
    1220             :     //insert or update the SwAuthorityField...
    1221           0 :     if(pSh)
    1222             :     {
    1223           0 :         bool bDifferent = false;
    1224             :         OSL_ENSURE(!m_sFields[AUTH_FIELD_IDENTIFIER].isEmpty() , "No Id is set!");
    1225             :         OSL_ENSURE(!m_sFields[AUTH_FIELD_AUTHORITY_TYPE].isEmpty() , "No authority type is set!");
    1226             :         //check if the entry already exists with different content
    1227             :         const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
    1228           0 :                                         pSh->GetFldType(RES_AUTHORITY, OUString());
    1229             :         const SwAuthEntry*  pEntry = pFType ?
    1230           0 :                 pFType->GetEntryByIdentifier( m_sFields[AUTH_FIELD_IDENTIFIER])
    1231           0 :                 : 0;
    1232           0 :         if(pEntry)
    1233             :         {
    1234           0 :             for(int i = 0; i < AUTH_FIELD_END && !bDifferent; i++)
    1235           0 :                 bDifferent |= m_sFields[i] != pEntry->GetAuthorField((ToxAuthorityField)i);
    1236           0 :             if(bDifferent)
    1237             :             {
    1238           0 :                 QueryBox aQuery(&m_rDialog, SW_RES(DLG_CHANGE_AUTH_ENTRY));
    1239           0 :                 if(RET_YES != aQuery.Execute())
    1240           0 :                     return 0;
    1241             :             }
    1242             :         }
    1243             : 
    1244           0 :         SwFldMgr aMgr(pSh);
    1245           0 :         OUString sFields;
    1246           0 :         for(int i = 0; i < AUTH_FIELD_END; i++)
    1247             :         {
    1248           0 :             sFields += m_sFields[i] + OUString(TOX_STYLE_DELIMITER);
    1249             :         }
    1250           0 :         if(bNewEntry)
    1251             :         {
    1252           0 :             if(bDifferent)
    1253             :             {
    1254           0 :                 SwAuthEntry aNewData;
    1255           0 :                 for(int i = 0; i < AUTH_FIELD_END; i++)
    1256           0 :                     aNewData.SetAuthorField((ToxAuthorityField)i, m_sFields[i]);
    1257           0 :                 pSh->ChangeAuthorityData(&aNewData);
    1258             :             }
    1259           0 :             SwInsertFld_Data aData(TYP_AUTHORITY, 0, sFields, OUString(), 0 );
    1260           0 :             aMgr.InsertFld( aData );
    1261             :         }
    1262           0 :         else if(aMgr.GetCurFld())
    1263             :         {
    1264           0 :             aMgr.UpdateCurFld(0, sFields, OUString());
    1265           0 :         }
    1266             :     }
    1267           0 :     if(!bNewEntry)
    1268           0 :         CloseHdl(0);
    1269           0 :     return 0;
    1270             : }
    1271             : 
    1272           0 : IMPL_LINK(SwAuthorMarkPane, CreateEntryHdl, PushButton*, pButton)
    1273             : {
    1274           0 :     bool bCreate = pButton == m_pCreateEntryPB;
    1275           0 :     OUString sOldId = m_sCreatedEntry[0];
    1276           0 :     for(int i = 0; i < AUTH_FIELD_END; i++)
    1277           0 :         m_sCreatedEntry[i] = bCreate ? OUString() : m_sFields[i];
    1278             :     SwCreateAuthEntryDlg_Impl aDlg(pButton,
    1279             :                 bCreate ? m_sCreatedEntry : m_sFields,
    1280           0 :                 *pSh, bNewEntry, bCreate);
    1281           0 :     if(bNewEntry)
    1282             :     {
    1283           0 :         aDlg.SetCheckNameHdl(LINK(this, SwAuthorMarkPane, IsEntryAllowedHdl));
    1284             :     }
    1285           0 :     if(RET_OK == aDlg.Execute())
    1286             :     {
    1287           0 :         if(bCreate && !sOldId.isEmpty())
    1288             :         {
    1289           0 :             m_pEntryLB->RemoveEntry(sOldId);
    1290             :         }
    1291           0 :         for(int i = 0; i < AUTH_FIELD_END; i++)
    1292             :         {
    1293           0 :             m_sFields[i] = aDlg.GetEntryText((ToxAuthorityField)i);
    1294           0 :             m_sCreatedEntry[i] = m_sFields[i];
    1295             :         }
    1296           0 :         if(bNewEntry && !m_pFromDocContentRB->IsChecked())
    1297             :         {
    1298           0 :             m_pFromDocContentRB->Check(true);
    1299           0 :             ChangeSourceHdl(m_pFromDocContentRB);
    1300             :         }
    1301           0 :         if(bCreate)
    1302             :         {
    1303             :             OSL_ENSURE(LISTBOX_ENTRY_NOTFOUND ==
    1304             :                         m_pEntryLB->GetEntryPos(m_sFields[AUTH_FIELD_IDENTIFIER]),
    1305             :                         "entry exists!");
    1306           0 :             m_pEntryLB->InsertEntry(m_sFields[AUTH_FIELD_IDENTIFIER]);
    1307           0 :             m_pEntryLB->SelectEntry(m_sFields[AUTH_FIELD_IDENTIFIER]);
    1308             :         }
    1309           0 :         m_pEntryED->SetText(m_sFields[AUTH_FIELD_IDENTIFIER]);
    1310           0 :         m_pAuthorFI->SetText(m_sFields[AUTH_FIELD_AUTHOR]);
    1311           0 :         m_pTitleFI->SetText(m_sFields[AUTH_FIELD_TITLE]);
    1312           0 :         m_pActionBT->Enable();
    1313             :     }
    1314           0 :     return 0;
    1315             : }
    1316             : 
    1317           0 : IMPL_LINK(SwAuthorMarkPane, ChangeSourceHdl, RadioButton*, pButton)
    1318             : {
    1319           0 :     sal_Bool bFromComp = (pButton == m_pFromComponentRB);
    1320           0 :     bIsFromComponent = bFromComp;
    1321           0 :     m_pCreateEntryPB->Enable(!bIsFromComponent);
    1322           0 :     m_pEntryLB->Clear();
    1323           0 :     if(bIsFromComponent)
    1324             :     {
    1325           0 :         if(!bBibAccessInitialized)
    1326             :         {
    1327           0 :             uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
    1328           0 :             xBibAccess = frame::Bibliography::create( xContext );
    1329           0 :             uno::Reference< beans::XPropertySet >  xPropSet(xBibAccess, uno::UNO_QUERY);
    1330           0 :             OUString uPropName("BibliographyDataFieldNames");
    1331           0 :             if(xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName(uPropName))
    1332             :             {
    1333           0 :                 uno::Any aNames = xPropSet->getPropertyValue(uPropName);
    1334           0 :                 uno::Sequence<beans::PropertyValue> aSeq;
    1335           0 :                 if( aNames >>= aSeq)
    1336             :                 {
    1337           0 :                     const beans::PropertyValue* pArr = aSeq.getConstArray();
    1338           0 :                     for(sal_Int32 i = 0; i < aSeq.getLength(); i++)
    1339             :                     {
    1340           0 :                         OUString sTitle = pArr[i].Name;
    1341           0 :                         sal_Int16 nField = 0;
    1342           0 :                         pArr[i].Value >>= nField;
    1343           0 :                         if(nField >= 0 && nField < AUTH_FIELD_END)
    1344           0 :                             m_sColumnTitles[nField] = sTitle;
    1345           0 :                     }
    1346           0 :                 }
    1347             :             }
    1348           0 :             bBibAccessInitialized = sal_True;
    1349             :         }
    1350           0 :         if(xBibAccess.is())
    1351             :         {
    1352           0 :             uno::Sequence<OUString> aIdentifiers = xBibAccess->getElementNames();
    1353           0 :             const OUString* pNames = aIdentifiers.getConstArray();
    1354           0 :             for(sal_Int32 i = 0; i < aIdentifiers.getLength(); i++)
    1355             :             {
    1356           0 :                 m_pEntryLB->InsertEntry(pNames[i]);
    1357           0 :             }
    1358             :         }
    1359             :     }
    1360             :     else
    1361             :     {
    1362             :         const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
    1363           0 :                                     pSh->GetFldType(RES_AUTHORITY, OUString());
    1364           0 :         if(pFType)
    1365             :         {
    1366           0 :             std::vector<OUString> aIds;
    1367           0 :             pFType->GetAllEntryIdentifiers( aIds );
    1368           0 :             for(size_t n = 0; n < aIds.size(); ++n)
    1369           0 :                 m_pEntryLB->InsertEntry(aIds[n]);
    1370             :         }
    1371           0 :         if(!m_sCreatedEntry[AUTH_FIELD_IDENTIFIER].isEmpty())
    1372           0 :             m_pEntryLB->InsertEntry(m_sCreatedEntry[AUTH_FIELD_IDENTIFIER]);
    1373             :     }
    1374           0 :     m_pEntryLB->SelectEntryPos(0);
    1375           0 :     CompEntryHdl(m_pEntryLB);
    1376           0 :     return 0;
    1377             : }
    1378             : 
    1379           0 : IMPL_LINK(SwAuthorMarkPane, EditModifyHdl, Edit*, pEdit)
    1380             : {
    1381           0 :     Link aAllowed = LINK(this, SwAuthorMarkPane, IsEntryAllowedHdl);
    1382           0 :     long nResult = aAllowed.Call(pEdit);
    1383           0 :     m_pActionBT->Enable(nResult > 0);
    1384           0 :     if(nResult)
    1385             :     {
    1386           0 :         OUString sEntry(pEdit->GetText());
    1387           0 :         m_sFields[AUTH_FIELD_IDENTIFIER] = sEntry;
    1388           0 :         m_sCreatedEntry[AUTH_FIELD_IDENTIFIER] = sEntry;
    1389             :     }
    1390           0 :     return 0;
    1391             : };
    1392             : 
    1393           0 : IMPL_LINK(SwAuthorMarkPane, IsEntryAllowedHdl, Edit*, pEdit)
    1394             : {
    1395           0 :     OUString sEntry = pEdit->GetText();
    1396           0 :     sal_Bool bAllowed = sal_False;
    1397           0 :     if(!sEntry.isEmpty())
    1398             :     {
    1399           0 :         if(m_pEntryLB->GetEntryPos(sEntry) != LISTBOX_ENTRY_NOTFOUND)
    1400           0 :             return 0;
    1401           0 :         else if(bIsFromComponent)
    1402             :         {
    1403             :             const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
    1404           0 :                                         pSh->GetFldType(RES_AUTHORITY, OUString());
    1405           0 :             bAllowed = !pFType || !pFType->GetEntryByIdentifier(sEntry);
    1406             :         }
    1407             :         else
    1408             :         {
    1409           0 :             bAllowed = !xBibAccess.is() || !xBibAccess->hasByName(sEntry);
    1410             :         }
    1411             :     }
    1412           0 :     return bAllowed;
    1413             : }
    1414             : 
    1415           0 : void SwAuthorMarkPane::InitControls()
    1416             : {
    1417             :     OSL_ENSURE(pSh, "no shell?");
    1418           0 :     SwField* pField = pSh->GetCurFld();
    1419             :     OSL_ENSURE(bNewEntry || pField, "no current marker");
    1420           0 :     if(bNewEntry)
    1421             :     {
    1422           0 :         ChangeSourceHdl(m_pFromComponentRB->IsChecked() ? m_pFromComponentRB : m_pFromDocContentRB);
    1423           0 :         m_pCreateEntryPB->Enable(!m_pFromComponentRB->IsChecked());
    1424           0 :         if(!m_pFromComponentRB->IsChecked() && !m_sCreatedEntry[0].isEmpty())
    1425           0 :             for(int i = 0; i < AUTH_FIELD_END; i++)
    1426           0 :                 m_sFields[i] = m_sCreatedEntry[i];
    1427             :     }
    1428           0 :     if(bNewEntry || !pField || pField->GetTyp()->Which() != RES_AUTHORITY)
    1429           0 :         return;
    1430             : 
    1431           0 :     const SwAuthEntry* pEntry = ((SwAuthorityFieldType*)pField->GetTyp())->
    1432           0 :             GetEntryByHandle(((SwAuthorityField*)pField)->GetHandle());
    1433             : 
    1434             :     OSL_ENSURE(pEntry, "No authority entry found");
    1435           0 :     if(!pEntry)
    1436           0 :         return;
    1437           0 :     for(int i = 0; i < AUTH_FIELD_END; i++)
    1438           0 :         m_sFields[i] = pEntry->GetAuthorField((ToxAuthorityField)i);
    1439             : 
    1440           0 :     m_pEntryED->SetText(pEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER));
    1441           0 :     m_pAuthorFI->SetText(pEntry->GetAuthorField(AUTH_FIELD_AUTHOR));
    1442           0 :     m_pTitleFI->SetText(pEntry->GetAuthorField(AUTH_FIELD_TITLE));
    1443             : }
    1444             : 
    1445           0 : void SwAuthorMarkPane::Activate()
    1446             : {
    1447           0 :     m_pActionBT->Enable(!pSh->HasReadonlySel());
    1448           0 : }
    1449             : 
    1450           0 : SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(Window* pParent,
    1451             :         const OUString pFields[],
    1452             :         SwWrtShell& rSh,
    1453             :         sal_Bool bNewEntry,
    1454             :         bool bCreate)
    1455             :     : ModalDialog(pParent, "CreateAuthorEntryDialog", "modules/swriter/ui/createauthorentry.ui")
    1456             : 
    1457             :     ,
    1458             : 
    1459             :     pTypeListBox(0),
    1460             :     pIdentifierBox(0),
    1461             :     rWrtSh(rSh),
    1462             :     m_bNewEntryMode(bNewEntry),
    1463           0 :     m_bNameAllowed(sal_True)
    1464             : {
    1465           0 :     get(m_pOKBT, "ok");
    1466             : 
    1467           0 :     VclGrid *pLeft = get<VclGrid>("leftgrid");
    1468           0 :     VclGrid *pRight = get<VclGrid>("rightgrid");
    1469             : 
    1470           0 :     bool bLeft = true;
    1471           0 :     sal_Int32 nLeftRow(0), nRightRow(0);
    1472           0 :     for(int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
    1473             :     {
    1474           0 :         const TextInfo aCurInfo = aTextInfoArr[nIndex];
    1475             : 
    1476           0 :         pFixedTexts[nIndex] = new FixedText(bLeft ? pLeft : pRight, WB_VCENTER);
    1477             : 
    1478           0 :         pFixedTexts[nIndex]->set_grid_left_attach(0);
    1479           0 :         pFixedTexts[nIndex]->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
    1480           0 :         pFixedTexts[nIndex]->SetText(SW_RES(STR_AUTH_FIELD_START + aCurInfo.nToxField));
    1481           0 :         pFixedTexts[nIndex]->Show();
    1482           0 :         pEdits[nIndex] = 0;
    1483           0 :         if( AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField )
    1484             :         {
    1485           0 :             pTypeListBox = new ListBox(bLeft ? pLeft : pRight, WB_DROPDOWN|WB_BORDER|WB_VCENTER);
    1486           0 :             for(int j = 0; j < AUTH_TYPE_END; j++)
    1487           0 :                 pTypeListBox->InsertEntry(SW_RESSTR(STR_AUTH_TYPE_START + j));
    1488           0 :             if(!pFields[aCurInfo.nToxField].isEmpty())
    1489             :             {
    1490           0 :                 pTypeListBox->SelectEntryPos(pFields[aCurInfo.nToxField].toInt32());
    1491             :             }
    1492           0 :             pTypeListBox->set_grid_left_attach(1);
    1493           0 :             pTypeListBox->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
    1494           0 :             pTypeListBox->set_hexpand(true);
    1495           0 :             pTypeListBox->Show();
    1496           0 :             pTypeListBox->SetSelectHdl(LINK(this, SwCreateAuthEntryDlg_Impl, EnableHdl));
    1497           0 :             pTypeListBox->SetHelpId(aCurInfo.pHelpId);
    1498           0 :             pFixedTexts[nIndex]->set_mnemonic_widget(pTypeListBox);
    1499             :         }
    1500           0 :         else if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField && !m_bNewEntryMode)
    1501             :         {
    1502           0 :             pIdentifierBox = new ComboBox(bLeft ? pLeft : pRight, WB_BORDER|WB_DROPDOWN|WB_VCENTER);
    1503             : 
    1504             :             pIdentifierBox->SetSelectHdl(LINK(this,
    1505           0 :                                     SwCreateAuthEntryDlg_Impl, IdentifierHdl));
    1506             : 
    1507             :             const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
    1508           0 :                                         rSh.GetFldType(RES_AUTHORITY, OUString());
    1509           0 :             if(pFType)
    1510             :             {
    1511           0 :                 std::vector<OUString> aIds;
    1512           0 :                 pFType->GetAllEntryIdentifiers( aIds );
    1513           0 :                 for(size_t n = 0; n < aIds.size(); ++n)
    1514           0 :                     pIdentifierBox->InsertEntry(aIds[n]);
    1515             :             }
    1516           0 :             pIdentifierBox->SetText(pFields[aCurInfo.nToxField]);
    1517           0 :             pIdentifierBox->set_grid_left_attach(1);
    1518           0 :             pIdentifierBox->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
    1519           0 :             pIdentifierBox->set_hexpand(true);
    1520           0 :             pIdentifierBox->Show();
    1521           0 :             pIdentifierBox->SetHelpId(aCurInfo.pHelpId);
    1522           0 :             pFixedTexts[nIndex]->set_mnemonic_widget(pIdentifierBox);
    1523             :         }
    1524             :         else
    1525             :         {
    1526           0 :             pEdits[nIndex] = new Edit(bLeft ? pLeft : pRight, WB_BORDER|WB_VCENTER);
    1527           0 :             pEdits[nIndex]->SetWidthInChars(14);
    1528           0 :             pEdits[nIndex]->set_grid_left_attach(1);
    1529           0 :             pEdits[nIndex]->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
    1530           0 :             pEdits[nIndex]->set_hexpand(true);
    1531           0 :             pEdits[nIndex]->SetText(pFields[aCurInfo.nToxField]);
    1532           0 :             pEdits[nIndex]->Show();
    1533           0 :             pEdits[nIndex]->SetHelpId(aCurInfo.pHelpId);
    1534           0 :             if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
    1535             :             {
    1536           0 :                 pEdits[nIndex]->SetModifyHdl(LINK(this, SwCreateAuthEntryDlg_Impl, ShortNameHdl));
    1537           0 :                 m_bNameAllowed = !pFields[nIndex].isEmpty();
    1538           0 :                 if(!bCreate)
    1539             :                 {
    1540           0 :                     pFixedTexts[nIndex]->Enable(false);
    1541           0 :                     pEdits[nIndex]->Enable(false);
    1542             :                 }
    1543             :             }
    1544           0 :             pFixedTexts[nIndex]->set_mnemonic_widget(pEdits[nIndex]);
    1545             :         }
    1546           0 :         if(bLeft)
    1547           0 :             ++nLeftRow;
    1548             :         else
    1549           0 :             ++nRightRow;
    1550           0 :         bLeft = !bLeft;
    1551             :     }
    1552           0 :     EnableHdl(pTypeListBox);
    1553           0 : }
    1554             : 
    1555           0 : SwCreateAuthEntryDlg_Impl::~SwCreateAuthEntryDlg_Impl()
    1556             : {
    1557           0 :     for(int i = 0; i < AUTH_FIELD_END; i++)
    1558             :     {
    1559           0 :         delete pFixedTexts[i];
    1560           0 :         delete pEdits[i];
    1561             :     }
    1562           0 :     delete pTypeListBox;
    1563           0 :     delete pIdentifierBox;
    1564           0 : }
    1565             : 
    1566           0 : OUString  SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField) const
    1567             : {
    1568           0 :     if( AUTH_FIELD_AUTHORITY_TYPE == eField )
    1569             :     {
    1570             :         OSL_ENSURE(pTypeListBox, "No ListBox");
    1571           0 :         return OUString::number(pTypeListBox->GetSelectEntryPos());
    1572             :     }
    1573             : 
    1574           0 :     if( AUTH_FIELD_IDENTIFIER == eField && !m_bNewEntryMode)
    1575             :     {
    1576             :         OSL_ENSURE(pIdentifierBox, "No ComboBox");
    1577           0 :         return pIdentifierBox->GetText();
    1578             :     }
    1579             : 
    1580           0 :     for(int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
    1581             :     {
    1582           0 :         const TextInfo aCurInfo = aTextInfoArr[nIndex];
    1583           0 :         if(aCurInfo.nToxField == eField)
    1584             :         {
    1585           0 :             return pEdits[nIndex]->GetText();
    1586             :         }
    1587             :     }
    1588             : 
    1589           0 :     return OUString();
    1590             : }
    1591             : 
    1592           0 : IMPL_LINK(SwCreateAuthEntryDlg_Impl, IdentifierHdl, ComboBox*, pBox)
    1593             : {
    1594             :     const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
    1595           0 :                                 rWrtSh.GetFldType(RES_AUTHORITY, OUString());
    1596           0 :     if(pFType)
    1597             :     {
    1598             :         const SwAuthEntry* pEntry = pFType->GetEntryByIdentifier(
    1599           0 :                                                         pBox->GetText());
    1600           0 :         if(pEntry)
    1601             :         {
    1602           0 :             for(int i = 0; i < AUTH_FIELD_END; i++)
    1603             :             {
    1604           0 :                 const TextInfo aCurInfo = aTextInfoArr[i];
    1605           0 :                 if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
    1606           0 :                     continue;
    1607           0 :                 if(AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField)
    1608             :                     pTypeListBox->SelectEntry(
    1609           0 :                                 pEntry->GetAuthorField(aCurInfo.nToxField));
    1610             :                 else
    1611           0 :                     pEdits[i]->SetText(
    1612           0 :                                 pEntry->GetAuthorField(aCurInfo.nToxField));
    1613             :             }
    1614             :         }
    1615             :     }
    1616           0 :     return 0;
    1617             : }
    1618             : 
    1619           0 : IMPL_LINK(SwCreateAuthEntryDlg_Impl, ShortNameHdl, Edit*, pEdit)
    1620             : {
    1621           0 :     if(aShortNameCheckLink.IsSet())
    1622             :     {
    1623           0 :         sal_Bool bEnable = 0 != aShortNameCheckLink.Call(pEdit);
    1624           0 :         m_bNameAllowed |= bEnable;
    1625           0 :         m_pOKBT->Enable(pTypeListBox->GetSelectEntryCount() && bEnable);
    1626             :     }
    1627           0 :     return 0;
    1628             : }
    1629             : 
    1630           0 : IMPL_LINK(SwCreateAuthEntryDlg_Impl, EnableHdl, ListBox*, pBox)
    1631             : {
    1632           0 :     m_pOKBT->Enable(m_bNameAllowed && pBox->GetSelectEntryCount());
    1633           0 :     return 0;
    1634             : };
    1635             : 
    1636           0 : SwAuthMarkFloatDlg::SwAuthMarkFloatDlg(SfxBindings* _pBindings,
    1637             :                                    SfxChildWindow* pChild,
    1638             :                                    Window *pParent,
    1639             :                                 SfxChildWinInfo* pInfo,
    1640             :                                    sal_Bool bNew)
    1641             :     : SfxModelessDialog(_pBindings, pChild, pParent,
    1642             :         "BibliographyEntryDialog", "modules/swriter/ui/bibliographyentry.ui")
    1643           0 :     , m_aContent(*this, bNew)
    1644             : {
    1645           0 :     Initialize(pInfo);
    1646           0 :     SwWrtShell* pWrtShell = ::GetActiveWrtShell();
    1647             :     OSL_ENSURE(pWrtShell, "No shell?");
    1648           0 :     m_aContent.ReInitDlg(*pWrtShell);
    1649           0 : }
    1650             : 
    1651           0 : void SwAuthMarkFloatDlg::Activate()
    1652             : {
    1653           0 :     SfxModelessDialog::Activate();
    1654           0 :     m_aContent.Activate();
    1655           0 : }
    1656             : 
    1657           0 : void SwAuthMarkFloatDlg::ReInitDlg(SwWrtShell& rWrtShell)
    1658             : {
    1659           0 :     m_aContent.ReInitDlg( rWrtShell );
    1660           0 : }
    1661             : 
    1662           0 : SwAuthMarkModalDlg::SwAuthMarkModalDlg(Window *pParent, SwWrtShell& rSh)
    1663             :     : SvxStandardDialog(pParent, "BibliographyEntryDialog",
    1664             :         "modules/swriter/ui/bibliographyentry.ui")
    1665           0 :     , m_aContent(*this, sal_False)
    1666             : {
    1667           0 :     m_aContent.ReInitDlg(rSh);
    1668           0 : }
    1669             : 
    1670           0 : void SwAuthMarkModalDlg::Apply()
    1671             : {
    1672           0 :     m_aContent.InsertHdl(0);
    1673           0 : }
    1674             : 
    1675             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10