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

Generated by: LCOV version 1.10