Files
libreoffice/sw/source/ui/misc/glossary.cxx

1172 lines
41 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:15:01 +00:00
#include <hintids.hxx>
#include <vcl/menu.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/help.hxx>
#include <svl/stritem.hxx>
#include <unotools/pathoptions.hxx>
#include <unotools/lingucfg.hxx>
2000-09-18 16:15:01 +00:00
#include <sfx2/request.hxx>
#include <sfx2/fcontnr.hxx>
#include <svx/svxdlg.hxx>
#include <svx/dialogs.hrc>
#include <editeng/acorrcfg.hxx>
#include <sfx2/viewfrm.hxx>
2000-09-18 16:15:01 +00:00
#include <unocrsr.hxx>
#include <unotools.hxx>
2000-10-20 13:18:07 +00:00
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
2000-09-18 16:15:01 +00:00
#include <ucbhelper/content.hxx>
#include <com/sun/star/text/AutoTextContainer.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <svl/urihelper.hxx>
2000-09-18 16:15:01 +00:00
#include <unotools/charclass.hxx>
#include "svtools/treelistentry.hxx"
2000-09-18 16:15:01 +00:00
#include <swwait.hxx>
#include <swtypes.hxx>
#include <wrtsh.hxx>
#include <view.hxx>
#include <basesh.hxx>
#include <glossary.hxx>
#include <gloshdl.hxx>
#include <glosbib.hxx>
#include <initui.hxx> // for ::GetGlossaries()
2000-09-18 16:15:01 +00:00
#include <glosdoc.hxx>
#include <macassgn.hxx>
#include <swevent.hxx>
#include <docsh.hxx>
#include <shellio.hxx>
#include <cmdid.h>
#include <helpid.h>
#include <swerror.h>
#include <globals.hrc>
#include <misc.hrc>
#include <glossary.hrc>
#include <swmodule.hxx>
#include <sfx2/filedlghelper.hxx>
2000-09-18 16:15:01 +00:00
#include "access.hrc"
2000-09-18 16:15:01 +00:00
using namespace ::com::sun::star;
2001-05-28 14:03:34 +00:00
using namespace ::com::sun::star::lang;
2000-09-18 16:15:01 +00:00
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::ui::dialogs;
2000-10-20 13:18:07 +00:00
using namespace ::comphelper;
using namespace ::ucbhelper;
using ::rtl::OUString;
using namespace ::sfx2;
2000-09-18 16:15:01 +00:00
static String lcl_GetValidShortCut( const String& rName )
{
const sal_uInt16 nSz = rName.Len();
if ( 0 == nSz )
return rName;
sal_uInt16 nStart = 1;
while( rName.GetChar( nStart-1 ) == ' ' && nStart < nSz )
nStart++;
String aBuf = rtl::OUString(rName.GetChar(nStart-1));
for( ; nStart < nSz; ++nStart )
{
if( rName.GetChar( nStart-1 ) == ' ' && rName.GetChar( nStart ) != ' ')
aBuf += rName.GetChar( nStart );
}
return aBuf;
}
2000-09-18 16:15:01 +00:00
struct GroupUserData
{
String sGroupName;
sal_uInt16 nPathIdx;
bool bReadonly;
2000-09-18 16:15:01 +00:00
GroupUserData()
: nPathIdx(0),
bReadonly(false) {}
2000-09-18 16:15:01 +00:00
};
/*------------------------------------------------------------------------
Description: dialog for new block name
2000-09-18 16:15:01 +00:00
------------------------------------------------------------------------*/
class SwNewGlosNameDlg : public ModalDialog
{
FixedText aNNFT;
Edit aNewName;
FixedText aNSFT;
NoSpaceEdit aNewShort;
OKButton aOk;
CancelButton aCancel;
FixedText aONFT;
Edit aOldName;
FixedText aOSFT;
Edit aOldShort;
FixedLine aFL;
2000-09-18 16:15:01 +00:00
protected:
DECL_LINK( Modify, Edit * );
DECL_LINK(Rename, void *);
2000-09-18 16:15:01 +00:00
public:
SwNewGlosNameDlg( Window* pParent,
const String& rOldName,
const String& rOldShort );
String GetNewName() const { return aNewName.GetText(); }
String GetNewShort() const { return aNewShort.GetText(); }
};
SwNewGlosNameDlg::SwNewGlosNameDlg(Window* pParent,
const String& rOldName,
const String& rOldShort ) :
ModalDialog( pParent, SW_RES( DLG_RENAME_GLOS ) ),
aNNFT (this, SW_RES( FT_NN )),
aNewName(this, SW_RES( ED_NN )),
aNSFT (this, SW_RES( FT_NS )),
aNewShort(this,SW_RES( ED_NS )),
2000-09-18 16:15:01 +00:00
aOk (this, SW_RES( BT_OKNEW)),
aCancel (this, SW_RES( BT_CANCEL)),
aONFT (this, SW_RES( FT_ON )),
aOldName(this, SW_RES( ED_ON )),
aOSFT (this, SW_RES( FT_OS )),
2011-02-21 18:43:22 +01:00
aOldShort(this,SW_RES( ED_OS )),
aFL (this, SW_RES( FL_NN ))
2000-09-18 16:15:01 +00:00
{
FreeResource();
aOldName.SetText( rOldName );
aOldShort.SetText( rOldShort );
aNewName.SetModifyHdl(LINK(this, SwNewGlosNameDlg, Modify ));
aNewShort.SetModifyHdl(LINK(this, SwNewGlosNameDlg, Modify ));
aOk.SetClickHdl(LINK(this, SwNewGlosNameDlg, Rename ));
aNewName.GrabFocus();
}
/*------------------------------------------------------------------------
Description: query / set currently set group
2000-09-18 16:15:01 +00:00
------------------------------------------------------------------------*/
String SwGlossaryDlg::GetCurrGroup()
{
if( ::GetCurrGlosGroup() && ::GetCurrGlosGroup()->Len() )
return *(::GetCurrGlosGroup());
2000-09-18 16:15:01 +00:00
return SwGlossaries::GetDefName();
}
void SwGlossaryDlg::SetActGroup(const String &rGrp)
{
if( !::GetCurrGlosGroup() )
::SetCurrGlosGroup( new String );
*(::GetCurrGlosGroup()) = rGrp;
2000-09-18 16:15:01 +00:00
}
SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame,
SwGlossaryHdl * pGlosHdl, SwWrtShell *pWrtShell)
: SvxStandardDialog(&pViewFrame->GetWindow(), "AutoTextDialog",
"modules/swriter/ui/autotext.ui")
, sReadonlyPath(SW_RESSTR(STR_READONLY_PATH))
, pExampleFrame(0)
, pGlossaryHdl(pGlosHdl)
, bResume(false)
, bSelection(pWrtShell->IsSelection())
, bReadOnly(false)
, bIsOld(false)
, bIsDocReadOnly(false)
, pSh(pWrtShell)
2000-09-18 16:15:01 +00:00
{
get(m_pInsertTipCB, "inserttip");
get(m_pNameED, "name");
get(m_pShortNameLbl, "shortnameft");
get(m_pShortNameEdit, "shortname");
get(m_pCategoryBox, "category");
get(m_pFileRelCB, "relfile");
get(m_pNetRelCB, "relnet");
get(m_pInsertBtn, "insert");
get(m_pBibBtn, "categories");
get(m_pPathBtn, "path");
get(m_pExampleWIN, "example");
get(m_pEditBtn, "autotext");
2008-12-15 12:01:46 +00:00
SvtLinguConfig aLocalLinguConfig;
// initialise static-pointer
if( !::GetCurrGlosGroup() )
::SetCurrGlosGroup(new String);
2000-09-18 16:15:01 +00:00
PopupMenu *pMenu = m_pEditBtn->GetPopupMenu();
assert(pMenu);
2000-09-18 16:15:01 +00:00
pMenu->SetActivateHdl(LINK(this,SwGlossaryDlg,EnableHdl));
pMenu->SetSelectHdl(LINK(this,SwGlossaryDlg,MenuHdl));
m_pEditBtn->SetSelectHdl(LINK(this,SwGlossaryDlg,EditHdl));
m_pPathBtn->SetClickHdl(LINK(this, SwGlossaryDlg, PathHdl));
2000-09-18 16:15:01 +00:00
m_pNameED->SetModifyHdl(LINK(this,SwGlossaryDlg,NameModify));
m_pShortNameEdit->SetModifyHdl(LINK(this,SwGlossaryDlg,NameModify));
2000-09-18 16:15:01 +00:00
m_pCategoryBox->SetDoubleClickHdl(LINK(this,SwGlossaryDlg, NameDoubleClick));
m_pCategoryBox->SetSelectHdl(LINK(this,SwGlossaryDlg,GrpSelect));
m_pBibBtn->SetClickHdl(LINK(this,SwGlossaryDlg,BibHdl));
2000-09-18 16:15:01 +00:00
m_pInsertBtn->SetClickHdl(LINK(this,SwGlossaryDlg,InsertHdl));
2000-09-18 16:15:01 +00:00
ShowPreview();
2000-09-18 16:15:01 +00:00
bIsDocReadOnly = pSh->GetView().GetDocShell()->IsReadOnly() ||
pSh->HasReadonlySel();
if( bIsDocReadOnly )
m_pInsertBtn->Enable(sal_False);
m_pNameED->GrabFocus();
m_pCategoryBox->SetStyle(m_pCategoryBox->GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL|WB_VSCROLL|WB_CLIPCHILDREN|WB_SORT);
m_pCategoryBox->GetModel()->SetSortMode(SortAscending);
m_pCategoryBox->SetHighlightRange(); // select over full width
m_pCategoryBox->SetNodeDefaultImages( );
2000-09-18 16:15:01 +00:00
Init();
}
SwGlossaryDlg::~SwGlossaryDlg()
{
m_pCategoryBox->Clear();
2000-09-18 16:15:01 +00:00
delete pExampleFrame;
}
2010-10-12 17:05:15 +01:00
2000-09-18 16:15:01 +00:00
/*------------------------------------------------------------------------
Description: select new group
2000-09-18 16:15:01 +00:00
------------------------------------------------------------------------*/
IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox )
{
SvTreeListEntry* pEntry = pBox->FirstSelected();
2000-09-18 16:15:01 +00:00
if(!pEntry)
return 0;
SvTreeListEntry* pParent = pBox->GetParent(pEntry) ? pBox->GetParent(pEntry) : pEntry;
2000-09-18 16:15:01 +00:00
GroupUserData* pGroupData = (GroupUserData*)pParent->GetUserData();
String *pGlosGroup = ::GetCurrGlosGroup();
(*pGlosGroup) = pGroupData->sGroupName;
(*pGlosGroup) += GLOS_DELIM;
(*pGlosGroup) += OUString::number(pGroupData->nPathIdx);
pGlossaryHdl->SetCurGroup(*pGlosGroup);
// set current text block
2000-09-18 16:15:01 +00:00
bReadOnly = pGlossaryHdl->IsReadOnly();
EnableShortName( !bReadOnly );
m_pEditBtn->Enable(!bReadOnly);
2000-09-18 16:15:01 +00:00
bIsOld = pGlossaryHdl->IsOld();
if( pParent != pEntry)
{
OUString aName(pBox->GetEntryText(pEntry));
m_pNameED->SetText(aName);
m_pShortNameEdit->SetText(*(String*)pEntry->GetUserData());
2000-09-18 16:15:01 +00:00
pEntry = pBox->GetParent(pEntry);
m_pInsertBtn->Enable( !bIsDocReadOnly);
ShowAutoText(*::GetCurrGlosGroup(), m_pShortNameEdit->GetText());
2000-09-18 16:15:01 +00:00
}
else
ShowAutoText(aEmptyStr, aEmptyStr);
// update controls
NameModify(m_pShortNameEdit);
2002-06-27 07:47:17 +00:00
if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
{
SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_SET_ACT_GLOSSARY );
String sTemp(*::GetCurrGlosGroup());
// the zeroth path is not being recorded!
2002-06-27 07:47:17 +00:00
if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
sTemp = sTemp.GetToken(0, GLOS_DELIM);
aReq.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY, sTemp));
aReq.Done();
}
2000-09-18 16:15:01 +00:00
return 0;
}
void SwGlossaryDlg::Apply()
{
const String aGlosName(m_pShortNameEdit->GetText());
2000-09-18 16:15:01 +00:00
if(aGlosName.Len()) pGlossaryHdl->InsertGlossary(aGlosName);
2002-06-27 07:47:17 +00:00
if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
{
SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_INSERT_GLOSSARY );
String sTemp(*::GetCurrGlosGroup());
// the zeroth path is not being recorded!
2002-06-27 07:47:17 +00:00
if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
sTemp = sTemp.GetToken(0, GLOS_DELIM);
aReq.AppendItem(SfxStringItem(FN_INSERT_GLOSSARY, sTemp));
aReq.AppendItem(SfxStringItem(FN_PARAM_1, aGlosName));
aReq.Done();
}
2000-09-18 16:15:01 +00:00
}
2010-10-12 17:05:15 +01:00
void SwGlossaryDlg::EnableShortName(sal_Bool bOn)
2000-09-18 16:15:01 +00:00
{
m_pShortNameLbl->Enable(bOn);
m_pShortNameEdit->Enable(bOn);
2000-09-18 16:15:01 +00:00
}
/* --------------------------------------------------
* does the title exist in the selected group?
2000-09-18 16:15:01 +00:00
* --------------------------------------------------*/
SvTreeListEntry* SwGlossaryDlg::DoesBlockExist(const String& rBlock,
2000-09-18 16:15:01 +00:00
const String& rShort)
{
// look for possible entry in TreeListBox
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
if(pEntry)
2000-09-18 16:15:01 +00:00
{
if(m_pCategoryBox->GetParent(pEntry))
pEntry = m_pCategoryBox->GetParent(pEntry);
sal_uInt32 nChildCount = m_pCategoryBox->GetChildCount( pEntry );
for(sal_uInt32 i = 0; i < nChildCount; i++)
2000-09-18 16:15:01 +00:00
{
SvTreeListEntry* pChild = m_pCategoryBox->GetEntry( pEntry, i );
if(rBlock == m_pCategoryBox->GetEntryText(pChild) &&
(!rShort.Len() || rShort == *(String*)pChild->GetUserData()))
{
return pChild;
}
2000-09-18 16:15:01 +00:00
}
}
return 0;
}
IMPL_LINK( SwGlossaryDlg, NameModify, Edit *, pEdit )
{
String aName(m_pNameED->GetText());
bool bNameED = pEdit == m_pNameED;
2000-09-18 16:15:01 +00:00
if( !aName.Len() )
{
if(bNameED)
m_pShortNameEdit->SetText(aName);
m_pInsertBtn->Enable(sal_False);
2000-09-18 16:15:01 +00:00
return 0;
}
String sShortSearch;
if(!bNameED)
sShortSearch = pEdit->GetText();
bool bNotFound = !DoesBlockExist(aName, sShortSearch);
2000-09-18 16:15:01 +00:00
if(bNameED)
{
// did the text get in to the Listbbox in the Edit with a click?
2000-09-18 16:15:01 +00:00
if(bNotFound)
{
m_pShortNameEdit->SetText( lcl_GetValidShortCut( aName ) );
2000-09-18 16:15:01 +00:00
EnableShortName();
}
else
{
m_pShortNameEdit->SetText(pGlossaryHdl->GetGlossaryShortName(aName));
2000-09-18 16:15:01 +00:00
EnableShortName(!bReadOnly);
}
m_pInsertBtn->Enable(!bNotFound && !bIsDocReadOnly);
2000-09-18 16:15:01 +00:00
}
else
{
//ShortNameEdit
if(!bNotFound)
{
sal_Bool bEnable = !bNotFound;
bEnable &= !bIsDocReadOnly;
m_pInsertBtn->Enable(bEnable);
2000-09-18 16:15:01 +00:00
}
}
return 0;
}
IMPL_LINK_INLINE_START( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, pBox )
{
SvTreeListEntry* pEntry = pBox->FirstSelected();
2000-09-18 16:15:01 +00:00
if(pBox->GetParent(pEntry) && !bIsDocReadOnly)
EndDialog( RET_OK );
return 0;
}
IMPL_LINK_INLINE_END( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, pBox )
2000-09-18 16:15:01 +00:00
IMPL_LINK( SwGlossaryDlg, EnableHdl, Menu *, pMn )
{
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
const String aEditText(m_pNameED->GetText());
const bool bHasEntry = aEditText.Len() && !m_pShortNameEdit->GetText().isEmpty();
const bool bExists = 0 != DoesBlockExist(aEditText, m_pShortNameEdit->GetText());
const bool bIsGroup = pEntry && !m_pCategoryBox->GetParent(pEntry);
pMn->EnableItem("new", bSelection && bHasEntry && !bExists);
pMn->EnableItem("newtext", bSelection && bHasEntry && !bExists);
pMn->EnableItem("copy", bExists && !bIsGroup);
pMn->EnableItem("replace", bSelection && bExists && !bIsGroup && !bIsOld );
pMn->EnableItem("replacetext", bSelection && bExists && !bIsGroup && !bIsOld );
pMn->EnableItem("edit", bExists && !bIsGroup );
pMn->EnableItem("rename", bExists && !bIsGroup );
pMn->EnableItem("delete", bExists && !bIsGroup );
pMn->EnableItem("macro", bExists && !bIsGroup && !bIsOld &&
2000-09-18 16:15:01 +00:00
!pGlossaryHdl->IsReadOnly() );
pMn->EnableItem("import", bIsGroup && !bIsOld && !pGlossaryHdl->IsReadOnly() );
2000-09-18 16:15:01 +00:00
return 1;
}
IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn )
{
OString sItemIdent(pMn->GetCurItemIdent());
2000-09-18 16:15:01 +00:00
if (sItemIdent == "replace")
2000-09-18 16:15:01 +00:00
{
pGlossaryHdl->NewGlossary(m_pNameED->GetText(),
m_pShortNameEdit->GetText(),
false, false);
}
else if (sItemIdent == "replacetext")
{
pGlossaryHdl->NewGlossary(m_pNameED->GetText(),
m_pShortNameEdit->GetText(),
false, true);
}
else if (sItemIdent == "new" || sItemIdent == "newtext")
{
bool bNoAttr = sItemIdent == "newtext";
const String aStr(m_pNameED->GetText());
const String aShortName(m_pShortNameEdit->GetText());
if(pGlossaryHdl->HasShortName(aShortName))
2000-09-18 16:15:01 +00:00
{
InfoBox(this, SW_RES(MSG_DOUBLE_SHORTNAME)).Execute();
m_pShortNameEdit->SetSelection(Selection(0, SELECTION_MAX));
m_pShortNameEdit->GrabFocus();
return 1;
}
if(pGlossaryHdl->NewGlossary(aStr, aShortName, sal_False, bNoAttr ))
{
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
if(m_pCategoryBox->GetParent(pEntry))
pEntry = m_pCategoryBox->GetParent(pEntry);
2000-09-18 16:15:01 +00:00
SvTreeListEntry* pChild = m_pCategoryBox->InsertEntry(aStr, pEntry);
pChild->SetUserData(new String(aShortName));
m_pNameED->SetText(aStr);
m_pShortNameEdit->SetText(aShortName);
NameModify(m_pNameED); // for toggling the buttons
2000-09-18 16:15:01 +00:00
if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
{
SfxRequest aReq(pSh->GetView().GetViewFrame(), FN_NEW_GLOSSARY);
String sTemp(*::GetCurrGlosGroup());
// the zeroth path is not being recorded!
if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
sTemp = sTemp.GetToken(0, GLOS_DELIM);
aReq.AppendItem(SfxStringItem(FN_NEW_GLOSSARY, sTemp));
aReq.AppendItem(SfxStringItem(FN_PARAM_1, aShortName));
aReq.AppendItem(SfxStringItem(FN_PARAM_2, aStr));
aReq.Done();
2000-09-18 16:15:01 +00:00
}
}
}
else if (sItemIdent == "copy")
{
pGlossaryHdl->CopyToClipboard(*pSh, m_pShortNameEdit->GetText());
}
else if (sItemIdent == "rename")
{
m_pShortNameEdit->SetText(pGlossaryHdl->GetGlossaryShortName(m_pNameED->GetText()));
SwNewGlosNameDlg* pNewNameDlg = new SwNewGlosNameDlg(this, m_pNameED->GetText(),
m_pShortNameEdit->GetText() );
if( RET_OK == pNewNameDlg->Execute() &&
pGlossaryHdl->Rename( m_pShortNameEdit->GetText(),
pNewNameDlg->GetNewShort(),
pNewNameDlg->GetNewName()))
2000-09-18 16:15:01 +00:00
{
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
SvTreeListEntry* pNewEntry = m_pCategoryBox->InsertEntry(
pNewNameDlg->GetNewName(), m_pCategoryBox->GetParent(pEntry));
pNewEntry->SetUserData(new String(pNewNameDlg->GetNewShort()));
delete (String*)pEntry->GetUserData();
m_pCategoryBox->GetModel()->Remove(pEntry);
m_pCategoryBox->Select(pNewEntry);
m_pCategoryBox->MakeVisible(pNewEntry);
2000-09-18 16:15:01 +00:00
}
GrpSelect(m_pCategoryBox);
delete pNewNameDlg;
}
else if (sItemIdent == "delete")
{
QueryBox aQuery(this, SW_RES(MSG_QUERY_DELETE));
if(RET_YES == aQuery.Execute())
2000-09-18 16:15:01 +00:00
{
const String aShortName(m_pShortNameEdit->GetText());
const String aTitle(m_pNameED->GetText());
if(aTitle.Len() && pGlossaryHdl->DelGlossary(aShortName))
{
SvTreeListEntry* pChild = DoesBlockExist(aTitle, aShortName);
OSL_ENSURE(pChild, "entry not found!");
SvTreeListEntry* pParent = m_pCategoryBox->GetParent(pChild);
m_pCategoryBox->Select(pParent);
m_pCategoryBox->GetModel()->Remove(pChild);
m_pNameED->SetText(OUString());
NameModify(m_pNameED);
2000-09-18 16:15:01 +00:00
}
}
}
else if (sItemIdent == "macro")
{
SfxItemSet aSet( pSh->GetAttrPool(), RES_FRMMACRO, RES_FRMMACRO, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );
SvxMacro aStart(aEmptyStr, aEmptyStr, STARBASIC);
SvxMacro aEnd(aEmptyStr, aEmptyStr, STARBASIC);
pGlossaryHdl->GetMacros(m_pShortNameEdit->GetText(), aStart, aEnd );
SvxMacroItem aItem(RES_FRMMACRO);
if( aStart.HasMacro() )
aItem.SetMacro( SW_EVENT_START_INS_GLOSSARY, aStart );
if( aEnd.HasMacro() )
aItem.SetMacro( SW_EVENT_END_INS_GLOSSARY, aEnd );
aSet.Put( aItem );
aSet.Put( SwMacroAssignDlg::AddEvents( MACASSGN_AUTOTEXT ) );
const SfxPoolItem* pItem;
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( this, aSet,
pSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(), SID_EVENTCONFIG );
if ( pMacroDlg && pMacroDlg->Execute() == RET_OK &&
SFX_ITEM_SET == pMacroDlg->GetOutputItemSet()->GetItemState( RES_FRMMACRO, sal_False, &pItem ) )
2000-09-18 16:15:01 +00:00
{
const SvxMacroTableDtor& rTbl = ((SvxMacroItem*)pItem)->GetMacroTable();
pGlossaryHdl->SetMacros( m_pShortNameEdit->GetText(),
rTbl.Get( SW_EVENT_START_INS_GLOSSARY ),
rTbl.Get( SW_EVENT_END_INS_GLOSSARY ) );
2000-09-18 16:15:01 +00:00
}
delete pMacroDlg;
}
else if (sItemIdent == "import")
{
// call the FileOpenDialog do find WinWord - Files with templates
FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
SvtPathOptions aPathOpt;
xFP->setDisplayDirectory(aPathOpt.GetWorkPath() );
uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
SfxFilterMatcher aMatcher( rtl::OUString::createFromAscii(SwDocShell::Factory().GetShortName()) );
SfxFilterMatcherIter aIter( aMatcher );
const SfxFilter* pFilter = aIter.First();
while ( pFilter )
2000-09-18 16:15:01 +00:00
{
if( pFilter->GetUserData() == FILTER_WW8 )
2000-09-18 16:15:01 +00:00
{
xFltMgr->appendFilter( pFilter->GetUIName(),
pFilter->GetWildcard().getGlob() );
xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ;
2000-09-18 16:15:01 +00:00
}
CWS-TOOLING: integrate CWS mba32issues01 2009-05-05 18:23:27 +0200 mba r271547 : apply diffs from m45->m47 for all files moved from dialog to cui 2009-05-05 18:22:02 +0200 mba r271545 : apply diffs from m45->m47 for all files moved from dialog to cui 2009-05-05 18:16:42 +0200 mba r271544 : apply diffs from m45->m47 for all files moved from dialog to cui 2009-04-29 19:35:58 +0200 mba r271392 : #i73672#: unify commands for inserting special characters 2009-04-29 18:01:27 +0200 mba r271391 : #i101337#: missing string resources 2009-04-29 18:01:10 +0200 mba r271390 : #i101337#: missing string resources 2009-04-29 15:42:47 +0200 mba r271380 : concurrency problem in multithreaded dmake due to missing dependency 2009-04-28 17:36:03 +0200 tbo r271336 : #i99432# 2009-04-28 13:57:52 +0200 mba r271322 : #i101302#: ctor might be called with pSet=0 2009-04-22 19:32:39 +0200 tbo r271138 : #i99432# 2009-04-09 14:46:03 +0200 mba r270709 : make sendreportw32.cxx compile with pch 2009-04-06 16:05:07 +0200 mba r270568 : #i99432#: some tweaks for build order 2009-04-06 15:38:52 +0200 mba r270558 : typo 2009-04-06 13:36:19 +0200 mba r270542 : #i99432#: split of localization also 2009-04-06 13:19:06 +0200 mba r270539 : #i99432#: split up srs files also 2009-04-03 17:57:59 +0200 mba r270513 : #i99432#: split dialog folder into two 2009-04-03 17:56:46 +0200 mba r270512 : #i99432#: split dialog folder into two 2009-04-01 22:15:00 +0200 mba r270364 : warnings on Linux 2009-04-01 22:10:44 +0200 mba r270363 : warnings on Linux 2009-04-01 21:43:54 +0200 mba r270362 : warning fixed 2009-04-01 21:41:27 +0200 mba r270361 : warning on Linux fixed 2009-04-01 21:35:44 +0200 mba r270360 : warning fixed 2009-04-01 20:19:59 +0200 mba r270358 : warning found on Linux fixed 2009-04-01 19:23:38 +0200 mba r270354 : warning due to missing eof 2009-04-01 18:56:25 +0200 mba r270352 : linking problem fixed that appeared only on mac 2009-04-01 18:41:30 +0200 mba r270350 : warnings discovered on Linux fixed 2009-04-01 18:34:28 +0200 mba r270349 : some fixes for warnings and include problems discoverd after resync and build on mac 2009-04-01 14:08:22 +0200 mba r270328 : CWS-TOOLING: rebase CWS mba32issues01 to trunk@270033 (milestone: DEV300:m45) 2009-03-04 18:13:35 +0100 mba r268858 : #i99432#: more dialogs moved to cui 2009-03-04 17:47:41 +0100 mba r268854 : #i99432#: more dialogs moved to cui 2009-03-04 17:32:39 +0100 mba r268851 : warning fixed 2009-03-04 12:59:26 +0100 mba r268814 : #i99432#: more dialogs moved to cui 2009-03-04 11:49:03 +0100 mba r268802 : #i99432#: CharmapDialog moved to cui 2009-03-04 10:46:00 +0100 mba r268795 : #i99432#: CharmapDialog moved to cui 2009-03-04 10:43:50 +0100 mba r268794 : #i99432#: CharmapDialog moved to cui 2009-03-04 10:00:29 +0100 mba r268792 : #i99432#: CharmapDialog moved to cui 2009-03-04 10:00:03 +0100 mba r268791 : #i99432#: CharmapDialog moved to cui 2009-03-04 09:59:43 +0100 mba r268790 : #i99432#: CharmapDialog moved to cui 2009-03-04 09:58:51 +0100 mba r268789 : #i99432#: CharmapDialog moved to cui 2009-03-04 09:58:16 +0100 mba r268788 : #i99432#: CharmapDialog moved to cui 2009-03-03 16:33:14 +0100 mba r268763 : #i99465#: new SfxAbstractDialog interface and creation methods 2009-03-03 16:32:28 +0100 mba r268762 : #i99432#: some tabpages moved to cui 2009-03-03 16:32:09 +0100 mba r268761 : #i99432#: some tabpages moved to cui 2009-03-03 16:29:40 +0100 mba r268760 : #i99465#: new SfxAbstractDialog interface and creation methods 2009-03-03 16:29:08 +0100 mba r268759 : #i99432#: MacroAssignment page moved to cui 2009-03-03 16:28:41 +0100 mba r268758 : #i99432#: MacroAssignment page moved to cui 2009-03-03 16:28:18 +0100 mba r268757 : #i99465#: new SfxAbstractDialog interface and creation methods 2009-03-03 16:27:36 +0100 mba r268756 : #i99465#: replace FN_SYMBOL by SID_CHARMAP 2009-03-03 16:27:02 +0100 mba r268755 : #i99465#: new SfxAbstractDialog interface and creation methods 2009-03-03 16:26:23 +0100 mba r268754 : #i99465#: new SfxAbstractDialog interface and creation methods 2009-03-03 16:25:30 +0100 mba r268753 : #i99465#: new SfxAbstractDialog interface and creation methods 2009-03-03 16:24:49 +0100 mba r268752 : #i99465#: new SfxAbstractDialog interface and creation methods 2009-03-03 16:24:35 +0100 mba r268751 : #i99432#: MacroAssignment page moved to cui 2009-03-03 16:23:20 +0100 mba r268750 : #i99465#: new SfxAbstractDialog interface and creation methods 2009-03-03 16:23:04 +0100 mba r268749 : #i99432#: MacroAssignment page moved to cui 2009-03-03 16:21:56 +0100 mba r268748 : #i99465#: new SfxAbstractDialog interface and creation methods 2009-03-03 16:18:39 +0100 mba r268747 : #i99432#: MacroAssignment page moved to cui 2009-03-03 16:13:14 +0100 mba r268745 : #i99465#: replace FN_SYMBOL by SID_CHARMAP 2009-03-03 16:02:54 +0100 mba r268738 : #i99432#: moved MacroAssignment TabPage from sfx2 2009-03-03 14:57:58 +0100 mba r268729 : #i99465#: transport return value via ItemSet 2009-03-03 00:08:10 +0100 mba r268701 : #i99432#: move acccfg to cuilib 2009-03-03 00:07:32 +0100 mba r268700 : #i99432#: move acccfg to cuilib 2009-03-03 00:02:01 +0100 mba r268699 : #i99432#: move acccfg to cuilib 2009-03-03 00:01:38 +0100 mba r268698 : #i99432#: move acccfg to cuilib 2009-03-03 00:01:11 +0100 mba r268697 : #i99432#: move acccfg to cuilib 2009-03-03 00:00:40 +0100 mba r268696 : #i99432#: move acccfg to cuilib 2009-03-03 00:00:06 +0100 mba r268695 : #i99432#: replace SfxAbstractSingleTabDialog by SfxAbstractDialog 2009-03-02 23:59:22 +0100 mba r268694 : #i99432#: move acccfg to cuilib 2009-03-02 23:57:19 +0100 mba r268693 : #i99432#: move acccfg to svx 2009-03-02 23:56:14 +0100 mba r268692 : #i99432#: replace SfxAbstractSingleTabDialog by SfxAbstractDialog 2009-03-02 23:49:37 +0100 mba r268691 : #i99785#: consolidate dialogs library 2009-03-02 17:26:40 +0100 mba r268683 : #i99785#: consolidate dialogs library 2009-03-02 17:24:28 +0100 mba r268682 : i99465#: consolidate slot for InsertSymbol command 2009-03-02 17:22:29 +0100 mba r268681 : #i99785#: consolidate dialogs library 2009-03-02 17:18:11 +0100 mba r268680 : i99432#: move accelconfig and macroassignment to cui 2009-03-02 17:08:30 +0100 mba r268679 : #i99785#: consolidate dialogs library 2009-03-02 17:06:57 +0100 mba r268678 : #i99785#: consolidate dialogs library 2009-03-02 17:06:30 +0100 mba r268677 : #i99785#: consolidate dialogs library 2009-03-02 17:05:02 +0100 mba r268676 : #i99785#: consolidate dialogs library 2009-03-02 17:04:35 +0100 mba r268675 : #i99785#: consolidate dialogs library 2009-03-02 16:47:53 +0100 mba r268673 : i99432#: move accelconfig and macroassignment to cui 2009-03-02 16:45:17 +0100 mba r268671 : i99432#: move accelconfig and macroassignment to cui 2009-03-02 16:39:59 +0100 mba r268670 : i99432#: move accelconfig and macroassignment to cui 2009-03-02 16:38:59 +0100 mba r268668 : i99432#: move accelconfig and macroassignment to cui 2009-03-02 16:38:28 +0100 mba r268667 : i99432#: move accelconfig and macroassignment to cui 2009-03-02 16:36:06 +0100 mba r268666 : i99432#: move accelconfig and macroassignment to cui 2009-03-02 16:29:50 +0100 mba r268663 : i99432#: move accelconfig and macroassignment to cui 2009-03-02 16:24:00 +0100 mba r268659 : i99432#: move accelconfig and macroassignment to cui 2009-03-02 16:23:31 +0100 mba r268658 : i99432#: move accelconfig and macroassignment to cui 2009-03-02 16:22:41 +0100 mba r268657 : i99432#: move accelconfig and macroassignment to cui 2009-02-25 16:57:26 +0100 mba r268453 : obsolete 2009-02-17 10:50:51 +0100 mba r267846 : obsolete 2009-02-12 16:33:54 +0100 mba r267676 : #i96834#: warning fixed 2009-02-11 19:28:47 +0100 mba r267626 : #i91978#: unused code 2009-02-11 18:37:47 +0100 mba r267625 : metafile output, fixes for 3 layer office 2009-02-11 12:56:28 +0100 mba r267593 : selective trees; incomplete build lists; metafile output
2009-05-06 10:59:57 +00:00
pFilter = aIter.Next();
2000-09-18 16:15:01 +00:00
}
if( aDlgHelper.Execute() == ERRCODE_NONE )
2000-09-18 16:15:01 +00:00
{
if( pGlossaryHdl->ImportGlossaries( xFP->getFiles().getConstArray()[0] ))
Init();
else
2000-09-18 16:15:01 +00:00
{
InfoBox(this, SW_RES( MSG_NO_GLOSSARIES )).Execute();
2000-09-18 16:15:01 +00:00
}
}
}
else
{
return 0;
2000-09-18 16:15:01 +00:00
}
return 1;
}
2010-10-12 17:05:15 +01:00
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Description: dialog manage regions
2000-09-18 16:15:01 +00:00
--------------------------------------------------------------------*/
IMPL_LINK_NOARG(SwGlossaryDlg, BibHdl)
2000-09-18 16:15:01 +00:00
{
SwGlossaries* pGloss = ::GetGlossaries();
if( pGloss->IsGlosPathErr() )
pGloss->ShowError();
else
{
//check if at least one glossary path is write enabled
2000-10-06 12:41:54 +00:00
SvtPathOptions aPathOpt;
String sGlosPath( aPathOpt.GetAutoTextPath() );
sal_uInt16 nPaths = comphelper::string::getTokenCount(sGlosPath, ';');
bool bIsWritable = false;
for(sal_uInt16 nPath = 0; nPath < nPaths; nPath++)
2000-09-18 16:15:01 +00:00
{
String sPath = URIHelper::SmartRel2Abs(
INetURLObject(), sGlosPath.GetToken(nPath, ';'),
URIHelper::GetMaybeFileHdl());
2000-09-18 16:15:01 +00:00
try
{
Content aTestContent( sPath,
uno::Reference< XCommandEnvironment >(),
comphelper::getProcessComponentContext() );
2012-12-22 20:40:04 +01:00
Any aAny = aTestContent.getPropertyValue( "IsReadOnly" );
2000-09-18 16:15:01 +00:00
if(aAny.hasValue())
{
bIsWritable = !*(sal_Bool*)aAny.getValue();
}
}
2011-11-22 09:06:06 +00:00
catch (const Exception&)
{
}
2000-09-18 16:15:01 +00:00
if(bIsWritable)
break;
}
if(bIsWritable)
{
SwGlossaryGroupDlg *pDlg = new SwGlossaryGroupDlg( this, pGloss->GetPathArray(), pGlossaryHdl );
if ( RET_OK == pDlg->Execute() )
{
Init();
//if new groups were created - select one of them
String sNewGroup = pDlg->GetCreatedGroupName();
SvTreeListEntry* pEntry = m_pCategoryBox->First();
2000-09-18 16:15:01 +00:00
while(sNewGroup.Len() && pEntry)
{
if(!m_pCategoryBox->GetParent(pEntry))
2000-09-18 16:15:01 +00:00
{
GroupUserData* pGroupData = (GroupUserData*)pEntry->GetUserData();
String sGroup = pGroupData->sGroupName;
sGroup += GLOS_DELIM;
sGroup += OUString::number(pGroupData->nPathIdx);
2000-09-18 16:15:01 +00:00
if(sGroup == sNewGroup)
{
m_pCategoryBox->Select(pEntry);
m_pCategoryBox->MakeVisible(pEntry);
GrpSelect(m_pCategoryBox);
2000-09-18 16:15:01 +00:00
break;
}
}
pEntry = m_pCategoryBox->Next(pEntry);
2000-09-18 16:15:01 +00:00
}
}
delete pDlg;
}
else
{
QueryBox aBox(this, WB_YES_NO, sReadonlyPath);
if(RET_YES == aBox.Execute())
PathHdl(m_pPathBtn);
2000-09-18 16:15:01 +00:00
}
}
return 0;
}
/*------------------------------------------------------------------------
Description: initialisation; from Ctor and after editing regions
2000-09-18 16:15:01 +00:00
------------------------------------------------------------------------*/
void SwGlossaryDlg::Init()
{
m_pCategoryBox->SetUpdateMode( sal_False );
m_pCategoryBox->Clear();
// display text block regions
2000-09-18 16:15:01 +00:00
const sal_uInt16 nCnt = pGlossaryHdl->GetGroupCnt();
SvTreeListEntry* pSelEntry = 0;
const String sSelStr(::GetCurrGlosGroup()->GetToken(0, GLOS_DELIM));
const sal_uInt16 nSelPath = static_cast< sal_uInt16 >(::GetCurrGlosGroup()->GetToken(1, GLOS_DELIM).ToInt32());
// #i66304# - "My AutoText" comes from mytexts.bau, but should be translated
const String sMyAutoTextEnglish(RTL_CONSTASCII_USTRINGPARAM("My AutoText"));
const String sMyAutoTextTranslated(SW_RESSTR(STR_MY_AUTOTEXT));
2000-09-18 16:15:01 +00:00
for(sal_uInt16 nId = 0; nId < nCnt; ++nId )
{
String sTitle;
String sGroupName(pGlossaryHdl->GetGroupName(nId, &sTitle));
2001-03-08 14:39:01 +00:00
if(!sGroupName.Len())
continue;
2000-09-18 16:15:01 +00:00
if(!sTitle.Len())
sTitle = sGroupName.GetToken( 0, GLOS_DELIM );
if(sTitle == sMyAutoTextEnglish)
sTitle = sMyAutoTextTranslated;
SvTreeListEntry* pEntry = m_pCategoryBox->InsertEntry( sTitle );
sal_uInt16 nPath = static_cast< sal_uInt16 >(sGroupName.GetToken( 1, GLOS_DELIM ).ToInt32());
2000-09-18 16:15:01 +00:00
GroupUserData* pData = new GroupUserData;
pData->sGroupName = sGroupName.GetToken(0, GLOS_DELIM);
pData->nPathIdx = nPath;
pData->bReadonly = pGlossaryHdl->IsReadOnly(&sGroupName);
pEntry->SetUserData(pData);
if(sSelStr == pData->sGroupName && nSelPath == nPath)
pSelEntry = pEntry;
// fill entries for the groups
2000-09-18 16:15:01 +00:00
{
pGlossaryHdl->SetCurGroup(sGroupName, sal_False, sal_True);
const sal_uInt16 nCount = pGlossaryHdl->GetGlossaryCnt();
for(sal_uInt16 i = 0; i < nCount; ++i)
{
String sGroupTitle(pGlossaryHdl->GetGlossaryName(i));
SvTreeListEntry* pChild = m_pCategoryBox->InsertEntry(
sGroupTitle, pEntry);
2000-09-18 16:15:01 +00:00
pChild->SetUserData(new String(pGlossaryHdl->GetGlossaryShortName(i)));
}
}
}
// set current group and display text blocks
2000-09-18 16:15:01 +00:00
if(!pSelEntry)
{
//find a non-readonly group
SvTreeListEntry* pSearch = m_pCategoryBox->First();
2000-09-18 16:15:01 +00:00
while(pSearch)
{
if(!m_pCategoryBox->GetParent(pSearch))
2000-09-18 16:15:01 +00:00
{
GroupUserData* pData = (GroupUserData*)pSearch->GetUserData();
if(!pData->bReadonly)
{
pSelEntry = pSearch;
break;
}
}
pSearch = m_pCategoryBox->Next(pSearch);
2000-09-18 16:15:01 +00:00
}
if(!pSelEntry)
pSelEntry = m_pCategoryBox->GetEntry(0);
2000-09-18 16:15:01 +00:00
}
if(pSelEntry)
{
m_pCategoryBox->Expand(pSelEntry);
m_pCategoryBox->Select(pSelEntry);
m_pCategoryBox->MakeVisible(pSelEntry);
GrpSelect(m_pCategoryBox);
2000-09-18 16:15:01 +00:00
}
//JP 16.11.99: the SvxTreeListBox has a Bug. The Box dont recalc the
// outputsize, when all entries are insertet. The result is, that
// the Focus/Highlight rectangle is to large and paintet over the
// HScrollbar. -> Fix: call the resize
m_pCategoryBox->Resize();
2000-09-18 16:15:01 +00:00
m_pCategoryBox->GetModel()->Resort();
m_pCategoryBox->SetUpdateMode( sal_True );
m_pCategoryBox->Update();
2000-09-18 16:15:01 +00:00
2011-05-20 09:06:56 +01:00
const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
m_pFileRelCB->Check( rCfg.IsSaveRelFile() );
m_pFileRelCB->SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
m_pNetRelCB->Check( rCfg.IsSaveRelNet() );
m_pNetRelCB->SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
m_pInsertTipCB->Check( rCfg.IsAutoTextTip() );
m_pInsertTipCB->SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
2000-09-18 16:15:01 +00:00
}
IMPL_LINK_NOARG_INLINE_START(SwGlossaryDlg, EditHdl)
2000-09-18 16:15:01 +00:00
{
// EndDialog must not be called in MenuHdl
if (m_pEditBtn->GetCurItemIdent() == "edit")
{
2001-05-28 14:03:34 +00:00
SwTextBlocks *pGroup = ::GetGlossaries()->GetGroupDoc ( GetCurrGrpName () );
sal_Bool bRet = pGlossaryHdl->ConvertToNew ( *pGroup );
delete pGroup;
if ( bRet )
EndDialog(RET_EDIT);
}
2000-09-18 16:15:01 +00:00
return 0;
}
IMPL_LINK_NOARG_INLINE_END(SwGlossaryDlg, EditHdl)
2000-09-18 16:15:01 +00:00
/*------------------------------------------------------------------------
Description: KeyInput for ShortName - Edits without Spaces
2000-09-18 16:15:01 +00:00
------------------------------------------------------------------------*/
IMPL_LINK( SwNewGlosNameDlg, Modify, Edit *, pBox )
{
OUString aName(aNewName.GetText());
2000-09-18 16:15:01 +00:00
SwGlossaryDlg* pDlg = (SwGlossaryDlg*)GetParent();
if( pBox == &aNewName )
aNewShort.SetText( lcl_GetValidShortCut( aName ) );
2000-09-18 16:15:01 +00:00
sal_Bool bEnable = !aName.isEmpty() && !aNewShort.GetText().isEmpty() &&
2000-09-18 16:15:01 +00:00
(!pDlg->DoesBlockExist(aName, aNewShort.GetText())
|| aName == aOldName.GetText());
aOk.Enable(bEnable);
return 0;
}
IMPL_LINK_NOARG(SwNewGlosNameDlg, Rename)
2000-09-18 16:15:01 +00:00
{
SwGlossaryDlg* pDlg = (SwGlossaryDlg*)GetParent();
OUString sNew = GetAppCharClass().uppercase(aNewShort.GetText());
2000-09-18 16:15:01 +00:00
if( pDlg->pGlossaryHdl->HasShortName(aNewShort.GetText())
&& sNew != aOldShort.GetText() )
{
InfoBox(this, SW_RES(MSG_DOUBLE_SHORTNAME)).Execute();
aNewShort.GrabFocus();
}
else
EndDialog(sal_True);
return 0;
}
IMPL_LINK( SwGlossaryDlg, CheckBoxHdl, CheckBox *, pBox )
{
2011-05-20 09:06:56 +01:00
SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
bool bCheck = pBox->IsChecked();
if (pBox == m_pInsertTipCB)
2011-05-20 09:06:56 +01:00
rCfg.SetAutoTextTip(bCheck);
else if(pBox == m_pFileRelCB)
2011-05-20 09:06:56 +01:00
rCfg.SetSaveRelFile(bCheck);
2000-09-18 16:15:01 +00:00
else
2011-05-20 09:06:56 +01:00
rCfg.SetSaveRelNet(bCheck);
2000-09-18 16:15:01 +00:00
return 0;
}
/* --------------------------------------------------
* TreeListBox for groups and blocks
2000-09-18 16:15:01 +00:00
* --------------------------------------------------*/
SwGlTreeListBox::SwGlTreeListBox(Window* pParent, WinBits nBits)
: SvTreeListBox(pParent, nBits)
, sReadonly(SW_RESSTR(SW_STR_READONLY)),
pDragEntry(0)
{
SetDragDropMode( SV_DRAGDROP_CTRL_MOVE|SV_DRAGDROP_CTRL_COPY );
}
Size SwGlTreeListBox::GetOptimalSize() const
{
return LogicToPixel(Size(212, 84), MapMode(MAP_APPFONT));
}
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwGlTreeListBox(Window *pParent, VclBuilder::stringmap &)
{
return new SwGlTreeListBox(pParent, WB_BORDER | WB_TABSTOP);
}
2000-09-18 16:15:01 +00:00
void SwGlTreeListBox::Clear()
{
SvTreeListEntry* pEntry = First();
2000-09-18 16:15:01 +00:00
while(pEntry)
{
if(GetParent(pEntry))
delete (String*)pEntry->GetUserData();
else
delete (GroupUserData*)pEntry->GetUserData();
pEntry = Next(pEntry);
}
SvTreeListBox::Clear();
}
void SwGlTreeListBox::RequestHelp( const HelpEvent& rHEvt )
{
Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
SvTreeListEntry* pEntry = GetEntry( aPos );
// there's only help for groups' names
2000-09-18 16:15:01 +00:00
if(pEntry)
{
SvLBoxTab* pTab;
SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
if(pItem)
{
aPos = GetEntryPosition( pEntry );
2000-09-18 16:15:01 +00:00
Size aSize(pItem->GetSize( this, pEntry ));
aPos.X() = GetTabPos( pEntry, pTab );
if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
aSize.Width() = GetSizePixel().Width() - aPos.X();
aPos = OutputToScreenPixel(aPos);
Rectangle aItemRect( aPos, aSize );
String sMsg;
if(!GetParent(pEntry))
{
GroupUserData* pData = (GroupUserData*)pEntry->GetUserData();
2012-01-21 20:19:32 +01:00
const std::vector<String> & rPathArr = ::GetGlossaries()->GetPathArray();
if( !rPathArr.empty() )
2000-09-18 16:15:01 +00:00
{
2012-01-21 20:19:32 +01:00
sMsg = rPathArr[pData->nPathIdx];
2000-09-18 16:15:01 +00:00
sMsg += INET_PATH_TOKEN;
sMsg += pData->sGroupName;
sMsg += SwGlossaries::GetExtension();
INetURLObject aTmp(sMsg);
sMsg = aTmp.GetPath();
if(pData->bReadonly)
{
sMsg += ' ';
sMsg += '(';
sMsg += sReadonly;
sMsg += ')';
}
}
}
else
sMsg = *(String*)pEntry->GetUserData();
Help::ShowQuickHelp( this, aItemRect, sMsg,
QUICKHELP_LEFT|QUICKHELP_VCENTER );
}
}
}
2010-10-12 17:05:15 +01:00
DragDropMode SwGlTreeListBox::NotifyStartDrag(
TransferDataContainer& /*rContainer*/,
SvTreeListEntry* pEntry )
2000-09-18 16:15:01 +00:00
{
DragDropMode eRet;
pDragEntry = pEntry;
if(!GetParent(pEntry))
eRet = SV_DRAGDROP_NONE;
else
{
SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
SvTreeListEntry* pParent = GetParent(pEntry);
2000-09-18 16:15:01 +00:00
GroupUserData* pGroupData = (GroupUserData*)pParent->GetUserData();
String sEntry(pGroupData->sGroupName);
sEntry += GLOS_DELIM;
sEntry += OUString::number(pGroupData->nPathIdx);
sal_Int8 nDragOption = DND_ACTION_COPY;
2000-09-18 16:15:01 +00:00
eRet = SV_DRAGDROP_CTRL_COPY;
if(!pDlg->pGlossaryHdl->IsReadOnly(&sEntry))
{
eRet |= SV_DRAGDROP_CTRL_MOVE;
nDragOption |= DND_ACTION_MOVE;
2000-09-18 16:15:01 +00:00
}
SetDragOptions( nDragOption );
2000-09-18 16:15:01 +00:00
}
return eRet;
}
2010-10-12 17:05:15 +01:00
sal_Bool SwGlTreeListBox::NotifyAcceptDrop( SvTreeListEntry* pEntry)
2000-09-18 16:15:01 +00:00
{
// TODO: Readonly - check still missing!
SvTreeListEntry* pSrcParent = GetParent(pEntry) ? GetParent(pEntry) : pEntry;
SvTreeListEntry* pDestParent =
2000-09-18 16:15:01 +00:00
GetParent(pDragEntry ) ? GetParent(pDragEntry ) : pDragEntry ;
return pDestParent != pSrcParent;
}
2010-10-12 17:05:15 +01:00
sal_Bool SwGlTreeListBox::NotifyMoving( SvTreeListEntry* pTarget,
SvTreeListEntry* pEntry,
SvTreeListEntry*& /*rpNewParent*/,
sal_uLong& /*rNewChildPos*/
2000-09-18 16:15:01 +00:00
)
{
pDragEntry = 0;
if(!pTarget) // move to the beginning
2000-09-18 16:15:01 +00:00
{
pTarget = GetEntry(0);
}
// 1. move to different groups?
// 2. allowed to write in both groups?
SvTreeListEntry* pSrcParent = GetParent(pEntry);
SvTreeListEntry* pDestParent =
2000-09-18 16:15:01 +00:00
GetParent(pTarget) ? GetParent(pTarget) : pTarget;
sal_Bool bRet = sal_False;
if(pDestParent != pSrcParent)
{
SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
SwWait aWait( *pDlg->pSh->GetView().GetDocShell(), sal_True );
GroupUserData* pGroupData = (GroupUserData*)pSrcParent->GetUserData();
String sSourceGroup(pGroupData->sGroupName);
sSourceGroup += GLOS_DELIM;
sSourceGroup += OUString::number(pGroupData->nPathIdx);
2000-09-18 16:15:01 +00:00
pDlg->pGlossaryHdl->SetCurGroup(sSourceGroup);
String sTitle(GetEntryText(pEntry));
String sShortName(*(String*)pEntry->GetUserData());
GroupUserData* pDestData = (GroupUserData*)pDestParent->GetUserData();
String sDestName = pDestData->sGroupName;
sDestName += GLOS_DELIM;
sDestName += OUString::number(pDestData->nPathIdx);
2000-09-18 16:15:01 +00:00
bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup, sShortName,
sDestName, sTitle, sal_True );
if(bRet)
{
SvTreeListEntry* pChild = InsertEntry(sTitle, pDestParent);
2000-09-18 16:15:01 +00:00
pChild->SetUserData(new String(sShortName));
GetModel()->Remove(pEntry);
}
}
return sal_False; // otherwise the entry is being set automatically
2000-09-18 16:15:01 +00:00
}
2010-10-12 17:05:15 +01:00
sal_Bool SwGlTreeListBox::NotifyCopying( SvTreeListEntry* pTarget,
SvTreeListEntry* pEntry,
SvTreeListEntry*& /*rpNewParent*/,
sal_uLong& /*rNewChildPos*/
2000-09-18 16:15:01 +00:00
)
{
pDragEntry = 0;
// 1. move in different groups?
// 2. allowed to write to both groups?
if(!pTarget) // move to the beginning
2000-09-18 16:15:01 +00:00
{
pTarget = GetEntry(0);
}
SvTreeListEntry* pSrcParent = GetParent(pEntry);
SvTreeListEntry* pDestParent =
2000-09-18 16:15:01 +00:00
GetParent(pTarget) ? GetParent(pTarget) : pTarget;
sal_Bool bRet = sal_False;
if(pDestParent != pSrcParent)
{
SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
SwWait aWait( *pDlg->pSh->GetView().GetDocShell(), sal_True );
GroupUserData* pGroupData = (GroupUserData*)pSrcParent->GetUserData();
String sSourceGroup(pGroupData->sGroupName);
sSourceGroup += GLOS_DELIM;
sSourceGroup += OUString::number(pGroupData->nPathIdx);
2000-09-18 16:15:01 +00:00
pDlg->pGlossaryHdl->SetCurGroup(sSourceGroup);
String sTitle(GetEntryText(pEntry));
String sShortName(*(String*)pEntry->GetUserData());
GroupUserData* pDestData = (GroupUserData*)pDestParent->GetUserData();
String sDestName = pDestData->sGroupName;
sDestName += GLOS_DELIM;
sDestName += OUString::number(pDestData->nPathIdx);
2000-09-18 16:15:01 +00:00
bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup, sShortName,
sDestName, sTitle, sal_False );
if(bRet)
{
SvTreeListEntry* pChild = InsertEntry(sTitle, pDestParent);
2000-09-18 16:15:01 +00:00
pChild->SetUserData(new String(sShortName));
}
}
return sal_False; // otherwise the entry is being set automatically
2000-09-18 16:15:01 +00:00
}
String SwGlossaryDlg::GetCurrGrpName() const
{
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
2000-09-18 16:15:01 +00:00
String sRet;
if(pEntry)
{
pEntry =
m_pCategoryBox->GetParent(pEntry) ? m_pCategoryBox->GetParent(pEntry) : pEntry;
2000-09-18 16:15:01 +00:00
GroupUserData* pGroupData = (GroupUserData*)pEntry->GetUserData();
sRet = pGroupData->sGroupName;
sRet += GLOS_DELIM;
sRet += OUString::number(pGroupData->nPathIdx);
2000-09-18 16:15:01 +00:00
}
return sRet;
}
IMPL_LINK( SwGlossaryDlg, PathHdl, Button *, pBtn )
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
if(pFact)
2000-09-18 16:15:01 +00:00
{
AbstractSvxMultiPathDialog* pDlg = pFact->CreateSvxMultiPathDialog( pBtn );
OSL_ENSURE(pDlg, "Dialogdiet fail!");
SvtPathOptions aPathOpt;
String sGlosPath( aPathOpt.GetAutoTextPath() );
pDlg->SetPath(sGlosPath);
if(RET_OK == pDlg->Execute())
2000-09-18 16:15:01 +00:00
{
String sTmp(pDlg->GetPath());
if(sTmp != sGlosPath)
{
aPathOpt.SetAutoTextPath( sTmp );
::GetGlossaries()->UpdateGlosPath( sal_True );
Init();
}
2000-09-18 16:15:01 +00:00
}
delete pDlg;
2000-09-18 16:15:01 +00:00
}
return 0;
}
IMPL_LINK_NOARG(SwGlossaryDlg, InsertHdl)
{
EndDialog(true);
return 0;
}
void SwGlossaryDlg::ShowPreview()
2000-09-18 16:15:01 +00:00
{
//create example
if (!pExampleFrame)
2000-09-18 16:15:01 +00:00
{
Link aLink(LINK(this, SwGlossaryDlg, PreviewLoadedHdl));
pExampleFrame = new SwOneExampleFrame( *m_pExampleWIN,
EX_SHOW_ONLINE_LAYOUT, &aLink );
2000-09-18 16:15:01 +00:00
}
if (::GetCurrGlosGroup())
ShowAutoText(*::GetCurrGlosGroup(), m_pShortNameEdit->GetText());
2000-09-18 16:15:01 +00:00
};
IMPL_LINK_NOARG(SwGlossaryDlg, PreviewLoadedHdl)
2000-09-18 16:15:01 +00:00
{
ResumeShowAutoText();
2000-09-18 16:15:01 +00:00
return 0;
}
2000-09-18 16:15:01 +00:00
void SwGlossaryDlg::ShowAutoText(const String& rGroup, const String& rShortName)
{
if(m_pExampleWIN->IsVisible())
2000-09-18 16:15:01 +00:00
{
SetResumeData(rGroup, rShortName);
//try to make an Undo()
pExampleFrame->ClearDocument( sal_True );
2000-09-18 16:15:01 +00:00
}
}
void SwGlossaryDlg::ResumeShowAutoText()
{
String sGroup, sShortName;
if(GetResumeData(sGroup, sShortName) && m_pExampleWIN->IsVisible())
{
if(!m_xAutoText.is())
{
uno::Reference< lang::XMultiServiceFactory > xMgr = getProcessServiceFactory();
//now the AutoText ListBoxes have to be filled
m_xAutoText = text::AutoTextContainer::create( comphelper::getComponentContext(xMgr) );
}
uno::Reference< XTextCursor > & xCrsr = pExampleFrame->GetTextCursor();
if(xCrsr.is())
{
if(sShortName.Len())
{
uno::Any aGroup = m_xAutoText->getByName(sGroup);
2001-09-28 06:16:50 +00:00
uno::Reference< XAutoTextGroup > xGroup;
OUString uShortName(sShortName);
2001-09-28 06:16:50 +00:00
if((aGroup >>= xGroup) && xGroup->hasByName(uShortName))
{
uno::Any aEntry(xGroup->getByName(uShortName));
2001-09-28 06:16:50 +00:00
uno::Reference< XAutoTextEntry > xEntry;
aEntry >>= xEntry;
uno::Reference< XTextRange > xRange(xCrsr, uno::UNO_QUERY);
xEntry->applyTo(xRange);
}
}
}
}
ResetResumeData();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */