LCOV - code coverage report
Current view: top level - sw/source/ui/index - swuiidxmrk.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 898 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 88 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 FrmTypeFlags 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 :                 !(nFrmType & ( FrmTypeFlags::HEADER | FrmTypeFlags::FOOTER | FrmTypeFlags::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 :         SwTextTOXMark* pTextTOXMark = pMark->GetTextTOXMark();
     310             :         OSL_ENSURE(pTextTOXMark, "need current SwTextTOXMark");
     311           0 :         if(!pTextTOXMark)
     312           0 :             return;
     313           0 :         const SwTextNode* pTextNode = pTextTOXMark->GetpTextNd();
     314             :         OSL_ENSURE(pTextNode, "need current SwTextNode");
     315           0 :         if(!pTextNode)
     316           0 :             return;
     317           0 :         sal_Int32 nTextIndex = pTextTOXMark->GetStart();
     318           0 :         nLangForPhoneticReading = pTextNode->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 SvtScriptType::ASIAN: nWhich = RES_CHRATR_CJK_LANGUAGE; break;
     326           0 :             case SvtScriptType::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 = static_cast<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 FrmTypeFlags 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 :                 !(nFrmType & ( FrmTypeFlags::HEADER | FrmTypeFlags::FOOTER | FrmTypeFlags::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.GetSelText(), 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             : class SwNewUserIdxDlg : public ModalDialog
     548             : {
     549             :     VclPtr<OKButton>        m_pOKPB;
     550             :     VclPtr<Edit>            m_pNameED;
     551             : 
     552             :     SwIndexMarkPane* m_pDlg;
     553             : 
     554             :     DECL_LINK( ModifyHdl, Edit*);
     555             : 
     556             :     public:
     557           0 :         explicit 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           0 :     virtual ~SwNewUserIdxDlg() { disposeOnce(); }
     569           0 :     virtual void dispose() SAL_OVERRIDE
     570             :     {
     571           0 :         m_pOKPB.clear();
     572           0 :         m_pNameED.clear();
     573           0 :         ModalDialog::dispose();
     574           0 :     }
     575             : 
     576           0 :     OUString  GetName(){return m_pNameED->GetText();}
     577             : };
     578             : 
     579           0 : IMPL_LINK( SwNewUserIdxDlg, ModifyHdl, Edit*, pEdit)
     580             : {
     581           0 :     m_pOKPB->Enable(!pEdit->GetText().isEmpty() && !m_pDlg->IsTOXType(pEdit->GetText()));
     582           0 :     return 0;
     583             : }
     584             : 
     585           0 : IMPL_LINK_NOARG(SwIndexMarkPane, NewUserIdxHdl)
     586             : {
     587           0 :     ScopedVclPtrInstance< SwNewUserIdxDlg > pDlg(this);
     588           0 :     if(RET_OK == pDlg->Execute())
     589             :     {
     590           0 :         OUString sNewName(pDlg->GetName());
     591           0 :         m_pTypeDCB->InsertEntry(sNewName);
     592           0 :         m_pTypeDCB->SelectEntry(sNewName);
     593             :     }
     594           0 :     return 0;
     595             : }
     596             : 
     597           0 : IMPL_LINK( SwIndexMarkPane, SearchTypeHdl, CheckBox*, pBox)
     598             : {
     599           0 :     bool bEnable = pBox->IsChecked() && pBox->IsEnabled();
     600           0 :     m_pSearchCaseWordOnlyCB->Enable(bEnable);
     601           0 :     m_pSearchCaseSensitiveCB->Enable(bEnable);
     602           0 :     return 0;
     603             : }
     604             : 
     605           0 : IMPL_LINK( SwIndexMarkPane, InsertHdl, Button *, pButton )
     606             : {
     607           0 :     Apply();
     608             :     //close the dialog if only one entry is available
     609           0 :     if(!bNewMark && !m_pPrevBT->IsVisible() && !m_pNextBT->IsVisible())
     610           0 :         CloseHdl(pButton);
     611           0 :     return 0;
     612             : }
     613             : 
     614           0 : IMPL_LINK_NOARG(SwIndexMarkPane, CloseHdl)
     615             : {
     616           0 :     if(bNewMark)
     617             :     {
     618           0 :         sal_uInt16 nSlot = FN_INSERT_IDX_ENTRY_DLG;
     619             :         SfxViewFrame::Current()->GetDispatcher()->Execute(nSlot,
     620           0 :                     SfxCallMode::ASYNCHRON|SfxCallMode::RECORD);
     621             :     }
     622             :     else
     623             :     {
     624           0 :         m_rDialog.EndDialog(RET_CANCEL);
     625             :     }
     626           0 :     return 0;
     627             : }
     628             : 
     629             : // select index type only when inserting
     630           0 : IMPL_LINK( SwIndexMarkPane, ModifyHdl, ListBox *, pBox )
     631             : {
     632           0 :     if (m_pTypeDCB == pBox)
     633             :     {
     634             :         // set index type
     635           0 :         sal_Int32 nPos = m_pTypeDCB->GetEntryPos(m_pTypeDCB->GetSelectEntry());
     636           0 :         bool bLevelEnable = false,
     637           0 :              bKeyEnable   = false,
     638           0 :              bSetKey2     = false,
     639           0 :              bKey2Enable  = false,
     640           0 :              bEntryHasText   = false,
     641           0 :              bKey1HasText    = false,
     642           0 :              bKey2HasText    = false;
     643           0 :         if(nPos == POS_INDEX)
     644             :         {
     645           0 :             if(!m_pEntryED->GetText().isEmpty())
     646           0 :                 bEntryHasText = true;
     647           0 :             m_pPhoneticED0->SetText(GetDefaultPhoneticReading(m_pEntryED->GetText()));
     648             : 
     649           0 :             bKeyEnable = true;
     650           0 :             m_pKey1DCB->SetText(m_pKey1DCB->GetEntry(nKey1Pos));
     651           0 :             m_pPhoneticED1->SetText(GetDefaultPhoneticReading(m_pKey1DCB->GetText()));
     652           0 :             if(!m_pKey1DCB->GetText().isEmpty())
     653             :             {
     654           0 :                 bKey1HasText = bSetKey2 = bKey2Enable = true;
     655           0 :                 m_pKey2DCB->SetText(m_pKey2DCB->GetEntry(nKey2Pos));
     656           0 :                 m_pPhoneticED2->SetText(GetDefaultPhoneticReading(m_pKey2DCB->GetText()));
     657           0 :                 if(!m_pKey2DCB->GetText().isEmpty())
     658           0 :                     bKey2HasText = true;
     659             :             }
     660             :         }
     661             :         else
     662             :         {
     663           0 :             bLevelEnable = true;
     664           0 :             m_pLevelNF->SetMax(MAXLEVEL);
     665           0 :             m_pLevelNF->SetValue(m_pLevelNF->Normalize(0));
     666           0 :             bSetKey2 = true;
     667             :         }
     668           0 :         m_pLevelFT->Show(bLevelEnable);
     669           0 :         m_pLevelNF->Show(bLevelEnable);
     670           0 :         m_pMainEntryCB->Show(nPos == POS_INDEX);
     671             : 
     672           0 :         m_pKey1FT->Enable(bKeyEnable);
     673           0 :         m_pKey1DCB->Enable(bKeyEnable);
     674           0 :         if ( bSetKey2 )
     675             :         {
     676           0 :             m_pKey2DCB->Enable(bKey2Enable);
     677           0 :             m_pKey2FT->Enable(bKey2Enable);
     678             :         }
     679           0 :         m_pPhoneticFT0->Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
     680           0 :         m_pPhoneticED0->Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
     681           0 :         m_pPhoneticFT1->Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
     682           0 :         m_pPhoneticED1->Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
     683           0 :         m_pPhoneticFT2->Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
     684           0 :         m_pPhoneticED2->Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
     685             :     }
     686             :     else //m_pEntryED  !!m_pEntryED is not a ListBox but a Edit
     687             :     {
     688           0 :         bool bHasText = (!m_pEntryED->GetText().isEmpty());
     689           0 :         if(!bHasText)
     690             :         {
     691           0 :             m_pPhoneticED0->SetText(OUString());
     692           0 :             bPhoneticED0_ChangedByUser = false;
     693             :         }
     694           0 :         else if(!bPhoneticED0_ChangedByUser)
     695           0 :             m_pPhoneticED0->SetText(GetDefaultPhoneticReading(m_pEntryED->GetText()));
     696             : 
     697           0 :         m_pPhoneticFT0->Enable(bHasText&&bIsPhoneticReadingEnabled);
     698           0 :         m_pPhoneticED0->Enable(bHasText&&bIsPhoneticReadingEnabled);
     699             :     }
     700           0 :     m_pOKBT->Enable(!pSh->HasReadonlySel() &&
     701           0 :         (!m_pEntryED->GetText().isEmpty() || pSh->GetCrsrCnt(false)));
     702           0 :     return 0;
     703             : }
     704             : 
     705           0 : IMPL_LINK_NOARG(SwIndexMarkPane, NextHdl)
     706             : {
     707           0 :     InsertUpdate();
     708           0 :     pTOXMgr->NextTOXMark();
     709           0 :     UpdateDialog();
     710           0 :     return 0;
     711             : }
     712             : 
     713           0 : IMPL_LINK_NOARG(SwIndexMarkPane, NextSameHdl)
     714             : {
     715           0 :     InsertUpdate();
     716           0 :     pTOXMgr->NextTOXMark(true);
     717           0 :     UpdateDialog();
     718           0 :     return 0;
     719             : }
     720             : 
     721           0 : IMPL_LINK_NOARG(SwIndexMarkPane, PrevHdl)
     722             : {
     723           0 :     InsertUpdate();
     724           0 :     pTOXMgr->PrevTOXMark();
     725           0 :     UpdateDialog();
     726           0 :     return 0;
     727             : }
     728             : 
     729           0 : IMPL_LINK_NOARG(SwIndexMarkPane, PrevSameHdl)
     730             : {
     731           0 :     InsertUpdate();
     732           0 :     pTOXMgr->PrevTOXMark(true);
     733           0 :     UpdateDialog();
     734             : 
     735           0 :     return 0;
     736             : }
     737             : 
     738           0 : IMPL_LINK_NOARG(SwIndexMarkPane, DelHdl)
     739             : {
     740           0 :     bDel = true;
     741           0 :     InsertUpdate();
     742           0 :     bDel = false;
     743             : 
     744           0 :     if(pTOXMgr->GetCurTOXMark())
     745           0 :         UpdateDialog();
     746             :     else
     747             :     {
     748           0 :         CloseHdl(m_pCloseBT);
     749           0 :         SfxViewFrame::Current()->GetBindings().Invalidate(FN_EDIT_IDX_ENTRY_DLG);
     750             :     }
     751           0 :     return 0;
     752             : }
     753             : 
     754             : // renew dialog view
     755           0 : void SwIndexMarkPane::UpdateDialog()
     756             : {
     757             :     OSL_ENSURE(pSh && pTOXMgr, "no shell?");
     758           0 :     SwTOXMark* pMark = pTOXMgr->GetCurTOXMark();
     759             :     OSL_ENSURE(pMark, "no current marker");
     760           0 :     if(!pMark)
     761           0 :         return;
     762             : 
     763           0 :     SwViewShell::SetCareWin(&m_rDialog);
     764             : 
     765           0 :     aOrgStr = pMark->GetText();
     766           0 :     m_pEntryED->SetText(aOrgStr);
     767             : 
     768             :     // set index type
     769           0 :     bool bLevelEnable = true,
     770           0 :          bKeyEnable   = false,
     771           0 :          bKey2Enable  = false,
     772           0 :          bEntryHasText  = false,
     773           0 :          bKey1HasText   = false,
     774           0 :          bKey2HasText   = false;
     775             : 
     776           0 :     TOXTypes eCurType = pMark->GetTOXType()->GetType();
     777           0 :     if(TOX_INDEX == eCurType)
     778             :     {
     779           0 :         bLevelEnable = false;
     780           0 :         bKeyEnable = true;
     781           0 :         bKey1HasText = bKey2Enable = !pMark->GetPrimaryKey().isEmpty();
     782           0 :         bKey2HasText = !pMark->GetSecondaryKey().isEmpty();
     783           0 :         bEntryHasText = !pMark->GetText().isEmpty();
     784           0 :         m_pKey1DCB->SetText( pMark->GetPrimaryKey() );
     785           0 :         m_pKey2DCB->SetText( pMark->GetSecondaryKey() );
     786           0 :         m_pPhoneticED0->SetText( pMark->GetTextReading() );
     787           0 :         m_pPhoneticED1->SetText( pMark->GetPrimaryKeyReading() );
     788           0 :         m_pPhoneticED2->SetText( pMark->GetSecondaryKeyReading() );
     789           0 :         m_pMainEntryCB->Check(pMark->IsMainEntry());
     790             :     }
     791           0 :     else if(TOX_CONTENT == eCurType || TOX_USER == eCurType)
     792             :     {
     793           0 :         m_pLevelNF->SetValue(m_pLevelNF->Normalize(pMark->GetLevel()));
     794             :     }
     795           0 :     m_pKey1FT->Enable(bKeyEnable);
     796           0 :     m_pKey1DCB->Enable(bKeyEnable);
     797           0 :     m_pLevelNF->SetMax(MAXLEVEL);
     798           0 :     m_pLevelFT->Show(bLevelEnable);
     799           0 :     m_pLevelNF->Show(bLevelEnable);
     800           0 :     m_pMainEntryCB->Show(!bLevelEnable);
     801           0 :     m_pKey2FT->Enable(bKey2Enable);
     802           0 :     m_pKey2DCB->Enable(bKey2Enable);
     803             : 
     804           0 :     UpdateLanguageDependenciesForPhoneticReading();
     805           0 :     m_pPhoneticFT0->Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
     806           0 :     m_pPhoneticED0->Enable(bKeyEnable&&bEntryHasText&&bIsPhoneticReadingEnabled);
     807           0 :     m_pPhoneticFT1->Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
     808           0 :     m_pPhoneticED1->Enable(bKeyEnable&&bKey1HasText&&bIsPhoneticReadingEnabled);
     809           0 :     m_pPhoneticFT2->Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
     810           0 :     m_pPhoneticED2->Enable(bKeyEnable&&bKey2HasText&&bIsPhoneticReadingEnabled);
     811             : 
     812             :     // set index type
     813           0 :     m_pTypeDCB->SelectEntry(pMark->GetTOXType()->GetTypeName());
     814             : 
     815             :     // set Next - Prev - Buttons
     816           0 :     pSh->SttCrsrMove();
     817           0 :     if( m_pPrevBT->IsVisible() )
     818             :     {
     819           0 :         const SwTOXMark* pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_PRV );
     820           0 :         if( pMoveMark != pMark )
     821           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_NXT );
     822           0 :         m_pPrevBT->Enable( pMoveMark != pMark );
     823           0 :         pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_NXT );
     824           0 :         if( pMoveMark != pMark )
     825           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_PRV );
     826           0 :         m_pNextBT->Enable( pMoveMark != pMark );
     827             :     }
     828             : 
     829           0 :     if( m_pPrevSameBT->IsVisible() )
     830             :     {
     831           0 :         const SwTOXMark* pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_SAME_PRV );
     832           0 :         if( pMoveMark != pMark )
     833           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_SAME_NXT );
     834           0 :         m_pPrevSameBT->Enable( pMoveMark != pMark );
     835           0 :         pMoveMark = &pSh->GotoTOXMark( *pMark, TOX_SAME_NXT );
     836           0 :         if( pMoveMark != pMark )
     837           0 :             pSh->GotoTOXMark( *pMoveMark, TOX_SAME_PRV );
     838           0 :         m_pNextSameBT->Enable( pMoveMark != pMark );
     839             :     }
     840             : 
     841           0 :     bool bEnable = !pSh->HasReadonlySel();
     842           0 :     m_pOKBT->Enable( bEnable );
     843           0 :     m_pDelBT->Enable( bEnable );
     844           0 :     m_pEntryED->SetReadOnly( !bEnable );
     845           0 :     m_pLevelNF->SetReadOnly( !bEnable );
     846           0 :     m_pKey1DCB->SetReadOnly( !bEnable );
     847           0 :     m_pKey2DCB->SetReadOnly( !bEnable );
     848             : 
     849           0 :     pSh->SelectTextAttr( RES_TXTATR_TOXMARK, pMark->GetTextTOXMark() );
     850             :     // we need the point at the start of the attribute
     851           0 :     pSh->SwapPam();
     852             : 
     853           0 :     pSh->EndCrsrMove();
     854             : }
     855             : 
     856             : // Remind whether the edit boxes for Phonetic reading are changed manually
     857           0 : IMPL_LINK( SwIndexMarkPane, PhoneticEDModifyHdl, Edit *, pEdit )
     858             : {
     859           0 :     if (m_pPhoneticED0 == pEdit)
     860             :     {
     861           0 :         bPhoneticED0_ChangedByUser = !pEdit->GetText().isEmpty();
     862             :     }
     863           0 :     else if (m_pPhoneticED1 == pEdit)
     864             :     {
     865           0 :         bPhoneticED1_ChangedByUser = !pEdit->GetText().isEmpty();
     866             :     }
     867           0 :     else if (m_pPhoneticED2 == pEdit)
     868             :     {
     869           0 :         bPhoneticED2_ChangedByUser = !pEdit->GetText().isEmpty();
     870             :     }
     871           0 :     return 0;
     872             : }
     873             : 
     874             : // Enable Disable of the 2nd key
     875           0 : IMPL_LINK( SwIndexMarkPane, KeyDCBModifyHdl, ComboBox *, pBox )
     876             : {
     877           0 :     if (m_pKey1DCB == pBox)
     878             :     {
     879           0 :         bool bEnable = !pBox->GetText().isEmpty();
     880           0 :         if(!bEnable)
     881             :         {
     882           0 :             m_pKey2DCB->SetText(OUString());
     883           0 :             m_pPhoneticED1->SetText(OUString());
     884           0 :             m_pPhoneticED2->SetText(OUString());
     885           0 :             bPhoneticED1_ChangedByUser = false;
     886           0 :             bPhoneticED2_ChangedByUser = false;
     887             :         }
     888             :         else
     889             :         {
     890           0 :             if(pBox->IsInDropDown())
     891             :             {
     892             :                 //reset bPhoneticED1_ChangedByUser if a completely new string is selected
     893           0 :                 bPhoneticED1_ChangedByUser = false;
     894             :             }
     895           0 :             if(!bPhoneticED1_ChangedByUser)
     896           0 :                 m_pPhoneticED1->SetText(GetDefaultPhoneticReading(pBox->GetText()));
     897             :         }
     898           0 :         m_pKey2DCB->Enable(bEnable);
     899           0 :         m_pKey2FT->Enable(bEnable);
     900             :     }
     901           0 :     else if (m_pKey2DCB == pBox)
     902             :     {
     903           0 :         if(pBox->GetText().isEmpty())
     904             :         {
     905           0 :             m_pPhoneticED2->SetText(OUString());
     906           0 :             bPhoneticED2_ChangedByUser = false;
     907             :         }
     908             :         else
     909             :         {
     910           0 :             if(pBox->IsInDropDown())
     911             :             {
     912             :                 //reset bPhoneticED1_ChangedByUser if a completely new string is selected
     913           0 :                 bPhoneticED2_ChangedByUser = false;
     914             :             }
     915           0 :             if(!bPhoneticED2_ChangedByUser)
     916           0 :                 m_pPhoneticED2->SetText(GetDefaultPhoneticReading(pBox->GetText()));
     917             :         }
     918             :     }
     919           0 :     bool    bKey1HasText    = (!m_pKey1DCB->GetText().isEmpty());
     920           0 :     bool    bKey2HasText    = (!m_pKey2DCB->GetText().isEmpty());
     921             : 
     922           0 :     m_pPhoneticFT1->Enable(bKey1HasText && bIsPhoneticReadingEnabled);
     923           0 :     m_pPhoneticED1->Enable(bKey1HasText && bIsPhoneticReadingEnabled);
     924           0 :     m_pPhoneticFT2->Enable(bKey2HasText && bIsPhoneticReadingEnabled);
     925           0 :     m_pPhoneticED2->Enable(bKey2HasText && bIsPhoneticReadingEnabled);
     926             : 
     927           0 :     return 0;
     928             : }
     929             : 
     930           0 : SwIndexMarkPane::~SwIndexMarkPane()
     931             : {
     932           0 :     delete pTOXMgr;
     933           0 :     SwViewShell::SetCareWin( 0 );
     934           0 : }
     935             : 
     936           0 : void    SwIndexMarkPane::ReInitDlg(SwWrtShell& rWrtShell, SwTOXMark* pCurTOXMark)
     937             : {
     938           0 :     pSh = &rWrtShell;
     939           0 :     delete pTOXMgr;
     940           0 :     pTOXMgr = new SwTOXMgr(pSh);
     941           0 :     if(pCurTOXMark)
     942             :     {
     943           0 :         for(sal_uInt16 i = 0; i < pTOXMgr->GetTOXMarkCount(); i++)
     944           0 :             if(pTOXMgr->GetTOXMark(i) == pCurTOXMark)
     945             :             {
     946           0 :                 pTOXMgr->SetCurTOXMark(i);
     947           0 :                 break;
     948             :             }
     949             :     }
     950           0 :     InitControls();
     951           0 : }
     952             : 
     953           0 : SwIndexMarkFloatDlg::SwIndexMarkFloatDlg(SfxBindings* _pBindings,
     954             :     SfxChildWindow* pChild, vcl::Window *pParent,
     955             :     SfxChildWinInfo* pInfo, bool bNew)
     956             :     : SfxModelessDialog(_pBindings, pChild, pParent, "IndexEntryDialog", "modules/swriter/ui/indexentry.ui")
     957           0 :     , m_aContent(*this, bNew, *::GetActiveWrtShell())
     958             : {
     959           0 :     m_aContent.ReInitDlg(*::GetActiveWrtShell());
     960           0 :     Initialize(pInfo);
     961           0 : }
     962             : 
     963           0 : void SwIndexMarkFloatDlg::Activate()
     964             : {
     965           0 :     SfxModelessDialog::Activate();
     966           0 :     m_aContent.Activate();
     967           0 : }
     968             : 
     969           0 : void SwIndexMarkFloatDlg::ReInitDlg(SwWrtShell& rWrtShell)
     970             : {
     971           0 :     m_aContent.ReInitDlg( rWrtShell );
     972           0 : }
     973             : 
     974           0 : SwIndexMarkModalDlg::SwIndexMarkModalDlg(vcl::Window *pParent, SwWrtShell& rSh, SwTOXMark* pCurTOXMark)
     975             :     : SvxStandardDialog(pParent, "IndexEntryDialog", "modules/swriter/ui/indexentry.ui")
     976           0 :     , m_aContent(*this, false, rSh)
     977             : {
     978           0 :     m_aContent.ReInitDlg(rSh, pCurTOXMark);
     979           0 : }
     980             : 
     981           0 : void SwIndexMarkModalDlg::Apply()
     982             : {
     983           0 :     m_aContent.Apply();
     984           0 : }
     985             : 
     986             : class SwCreateAuthEntryDlg_Impl : public ModalDialog
     987             : {
     988             :     VclPtr<FixedText>      pFixedTexts[AUTH_FIELD_END];
     989             :     VclPtr<ListBox>        pTypeListBox;
     990             :     VclPtr<ComboBox>       pIdentifierBox;
     991             :     VclPtr<Edit>           pEdits[AUTH_FIELD_END];
     992             : 
     993             :     VclPtr<OKButton>       m_pOKBT;
     994             : 
     995             :     Link<>          aShortNameCheckLink;
     996             : 
     997             :     SwWrtShell&     rWrtSh;
     998             : 
     999             :     bool            m_bNewEntryMode;
    1000             :     bool            m_bNameAllowed;
    1001             : 
    1002             :     DECL_LINK(IdentifierHdl, ComboBox*);
    1003             :     DECL_LINK(ShortNameHdl, Edit*);
    1004             :     DECL_LINK(EnableHdl, ListBox* pBox);
    1005             : 
    1006             : public:
    1007             :     SwCreateAuthEntryDlg_Impl(vcl::Window* pParent,
    1008             :                             const OUString pFields[],
    1009             :                             SwWrtShell& rSh,
    1010             :                             bool bNewEntry,
    1011             :                             bool bCreate);
    1012             :     virtual ~SwCreateAuthEntryDlg_Impl();
    1013             :     virtual void    dispose() SAL_OVERRIDE;
    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 = static_cast<const SwAuthorityFieldType*>(
    1170           0 :                                         pSh->GetFieldType(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].clear();
    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 = static_cast<const SwAuthorityFieldType*>(
    1197           0 :                                         pSh->GetFieldType(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 :                 ScopedVclPtrInstance< 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 :         SwFieldMgr aMgr(pSh);
    1214           0 :         OUString sFields;
    1215           0 :         for(int i = 0; i < AUTH_FIELD_END; i++)
    1216             :         {
    1217           0 :             sFields += m_sFields[i] + OUStringLiteral1<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 :             SwInsertField_Data aData(TYP_AUTHORITY, 0, sFields, OUString(), 0 );
    1229           0 :             aMgr.InsertField( aData );
    1230             :         }
    1231           0 :         else if(aMgr.GetCurField())
    1232             :         {
    1233           0 :             aMgr.UpdateCurField(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             :     ScopedVclPtrInstance<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 = static_cast<const SwAuthorityFieldType*>(
    1332           0 :                                     pSh->GetFieldType(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 = static_cast<const SwAuthorityFieldType*>(
    1373           0 :                                         pSh->GetFieldType(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->GetCurField();
    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 = static_cast<SwAuthorityFieldType*>(pField->GetTyp())->
    1401           0 :             GetEntryByHandle(static_cast<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] = VclPtr<FixedText>::Create(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 = VclPtr<ListBox>::Create(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 = VclPtr<ComboBox>::Create(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 = static_cast<const SwAuthorityFieldType*>(
    1477           0 :                                         rSh.GetFieldType(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] = VclPtr<Edit>::Create(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 :     disposeOnce();
    1527           0 : }
    1528             : 
    1529           0 : void SwCreateAuthEntryDlg_Impl::dispose()
    1530             : {
    1531           0 :     for(int i = 0; i < AUTH_FIELD_END; i++)
    1532             :     {
    1533           0 :         pFixedTexts[i].disposeAndClear();
    1534           0 :         pEdits[i].disposeAndClear();
    1535             :     }
    1536           0 :     pTypeListBox.disposeAndClear();
    1537           0 :     pIdentifierBox.disposeAndClear();
    1538           0 :     m_pOKBT.clear();
    1539           0 :     ModalDialog::dispose();
    1540           0 : }
    1541             : 
    1542           0 : OUString  SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField) const
    1543             : {
    1544           0 :     if( AUTH_FIELD_AUTHORITY_TYPE == eField )
    1545             :     {
    1546             :         OSL_ENSURE(pTypeListBox, "No ListBox");
    1547           0 :         return OUString::number(pTypeListBox->GetSelectEntryPos());
    1548             :     }
    1549             : 
    1550           0 :     if( AUTH_FIELD_IDENTIFIER == eField && !m_bNewEntryMode)
    1551             :     {
    1552             :         OSL_ENSURE(pIdentifierBox, "No ComboBox");
    1553           0 :         return pIdentifierBox->GetText();
    1554             :     }
    1555             : 
    1556           0 :     for(int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
    1557             :     {
    1558           0 :         const TextInfo aCurInfo = aTextInfoArr[nIndex];
    1559           0 :         if(aCurInfo.nToxField == eField)
    1560             :         {
    1561           0 :             return pEdits[nIndex]->GetText();
    1562             :         }
    1563             :     }
    1564             : 
    1565           0 :     return OUString();
    1566             : }
    1567             : 
    1568           0 : IMPL_LINK(SwCreateAuthEntryDlg_Impl, IdentifierHdl, ComboBox*, pBox)
    1569             : {
    1570             :     const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
    1571           0 :                                 rWrtSh.GetFieldType(RES_AUTHORITY, OUString()));
    1572           0 :     if(pFType)
    1573             :     {
    1574             :         const SwAuthEntry* pEntry = pFType->GetEntryByIdentifier(
    1575           0 :                                                         pBox->GetText());
    1576           0 :         if(pEntry)
    1577             :         {
    1578           0 :             for(int i = 0; i < AUTH_FIELD_END; i++)
    1579             :             {
    1580           0 :                 const TextInfo aCurInfo = aTextInfoArr[i];
    1581           0 :                 if(AUTH_FIELD_IDENTIFIER == aCurInfo.nToxField)
    1582           0 :                     continue;
    1583           0 :                 if(AUTH_FIELD_AUTHORITY_TYPE == aCurInfo.nToxField)
    1584             :                     pTypeListBox->SelectEntry(
    1585           0 :                                 pEntry->GetAuthorField(aCurInfo.nToxField));
    1586             :                 else
    1587           0 :                     pEdits[i]->SetText(
    1588           0 :                                 pEntry->GetAuthorField(aCurInfo.nToxField));
    1589             :             }
    1590             :         }
    1591             :     }
    1592           0 :     return 0;
    1593             : }
    1594             : 
    1595           0 : IMPL_LINK(SwCreateAuthEntryDlg_Impl, ShortNameHdl, Edit*, pEdit)
    1596             : {
    1597           0 :     if(aShortNameCheckLink.IsSet())
    1598             :     {
    1599           0 :         bool bEnable = 0 != aShortNameCheckLink.Call(pEdit);
    1600           0 :         m_bNameAllowed |= bEnable;
    1601           0 :         m_pOKBT->Enable(pTypeListBox->GetSelectEntryCount() && bEnable);
    1602             :     }
    1603           0 :     return 0;
    1604             : }
    1605             : 
    1606           0 : IMPL_LINK(SwCreateAuthEntryDlg_Impl, EnableHdl, ListBox*, pBox)
    1607             : {
    1608           0 :     m_pOKBT->Enable(m_bNameAllowed && pBox->GetSelectEntryCount());
    1609           0 :     return 0;
    1610             : };
    1611             : 
    1612           0 : SwAuthMarkFloatDlg::SwAuthMarkFloatDlg(SfxBindings* _pBindings,
    1613             :                                    SfxChildWindow* pChild,
    1614             :                                    vcl::Window *pParent,
    1615             :                                    SfxChildWinInfo* pInfo,
    1616             :                                    bool bNew)
    1617             :     : SfxModelessDialog(_pBindings, pChild, pParent,
    1618             :         "BibliographyEntryDialog", "modules/swriter/ui/bibliographyentry.ui")
    1619           0 :     , m_aContent(*this, bNew)
    1620             : {
    1621           0 :     Initialize(pInfo);
    1622           0 :     SwWrtShell* pWrtShell = ::GetActiveWrtShell();
    1623             :     OSL_ENSURE(pWrtShell, "No shell?");
    1624           0 :     m_aContent.ReInitDlg(*pWrtShell);
    1625           0 : }
    1626             : 
    1627           0 : void SwAuthMarkFloatDlg::Activate()
    1628             : {
    1629           0 :     SfxModelessDialog::Activate();
    1630           0 :     m_aContent.Activate();
    1631           0 : }
    1632             : 
    1633           0 : void SwAuthMarkFloatDlg::ReInitDlg(SwWrtShell& rWrtShell)
    1634             : {
    1635           0 :     m_aContent.ReInitDlg( rWrtShell );
    1636           0 : }
    1637             : 
    1638           0 : SwAuthMarkModalDlg::SwAuthMarkModalDlg(vcl::Window *pParent, SwWrtShell& rSh)
    1639             :     : SvxStandardDialog(pParent, "BibliographyEntryDialog",
    1640             :         "modules/swriter/ui/bibliographyentry.ui")
    1641           0 :     , m_aContent(*this, false)
    1642             : {
    1643           0 :     m_aContent.ReInitDlg(rSh);
    1644           0 : }
    1645             : 
    1646           0 : void SwAuthMarkModalDlg::Apply()
    1647             : {
    1648           0 :     m_aContent.InsertHdl(0);
    1649           0 : }
    1650             : 
    1651             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11