2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
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 .
|
|
|
|
*/
|
2006-09-16 22:07:03 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <hintids.hxx>
|
|
|
|
|
|
|
|
#include <vcl/menu.hxx>
|
2014-08-22 09:33:44 +01:00
|
|
|
#include <vcl/layout.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <vcl/help.hxx>
|
2015-05-11 13:42:10 +01:00
|
|
|
#include <vcl/builderfactory.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/stritem.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/pathoptions.hxx>
|
|
|
|
#include <unotools/lingucfg.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <sfx2/request.hxx>
|
|
|
|
#include <sfx2/fcontnr.hxx>
|
2007-09-27 11:20:19 +00:00
|
|
|
|
|
|
|
#include <svx/svxdlg.hxx>
|
|
|
|
#include <svx/dialogs.hrc>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/acorrcfg.hxx>
|
2004-10-04 18:28:56 +00:00
|
|
|
#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>
|
2012-01-02 10:55:27 +00:00
|
|
|
#include <comphelper/string.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <ucbhelper/content.hxx>
|
2013-03-19 15:36:11 +02:00
|
|
|
#include <com/sun/star/text/AutoTextContainer.hpp>
|
2015-10-05 23:27:44 +02:00
|
|
|
#include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
|
2001-06-15 13:12:36 +00:00
|
|
|
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
|
2002-10-25 09:08:30 +00:00
|
|
|
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/urihelper.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <unotools/charclass.hxx>
|
2014-04-15 19:05:01 +02:00
|
|
|
#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>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <initui.hxx>
|
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 <swmodule.hxx>
|
2001-08-09 11:46:23 +00:00
|
|
|
#include <sfx2/filedlghelper.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-09-17 11:30:13 +01:00
|
|
|
#include <memory>
|
2014-01-21 10:18:02 +09:00
|
|
|
|
2011-01-22 13:31:45 +01:00
|
|
|
#include "access.hrc"
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
using namespace ::com::sun::star;
|
2015-11-09 08:35:35 +02:00
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
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;
|
2007-06-05 16:43:26 +00:00
|
|
|
using namespace ::ucbhelper;
|
2001-08-09 11:46:23 +00:00
|
|
|
using namespace ::sfx2;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-09-22 02:10:24 +02:00
|
|
|
static OUString lcl_GetValidShortCut( const OUString& rName )
|
2007-09-27 11:20:19 +00:00
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
const sal_Int32 nSz = rName.getLength();
|
2007-09-27 11:20:19 +00:00
|
|
|
|
|
|
|
if ( 0 == nSz )
|
|
|
|
return rName;
|
|
|
|
|
2013-09-22 02:10:24 +02:00
|
|
|
sal_Int32 nStart = 1;
|
|
|
|
while( rName[nStart-1]==' ' && nStart < nSz )
|
2007-09-27 11:20:19 +00:00
|
|
|
nStart++;
|
|
|
|
|
2013-09-22 02:10:24 +02:00
|
|
|
OUString aBuf = OUString(rName[nStart-1]);
|
2007-09-27 11:20:19 +00:00
|
|
|
|
|
|
|
for( ; nStart < nSz; ++nStart )
|
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
if( rName[nStart-1]==' ' && rName[nStart]!=' ')
|
|
|
|
aBuf += OUString(rName[nStart]);
|
2007-09-27 11:20:19 +00:00
|
|
|
}
|
|
|
|
return aBuf;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
struct GroupUserData
|
|
|
|
{
|
2013-10-11 16:34:04 +02:00
|
|
|
OUString sGroupName;
|
2000-09-18 16:15:01 +00:00
|
|
|
sal_uInt16 nPathIdx;
|
2013-02-10 21:13:43 +09:00
|
|
|
bool bReadonly;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
GroupUserData()
|
|
|
|
: nPathIdx(0),
|
2013-02-10 21:13:43 +09:00
|
|
|
bReadonly(false) {}
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
2014-05-25 21:26:51 -04:00
|
|
|
// dialog for new block name
|
2000-09-18 16:15:01 +00:00
|
|
|
class SwNewGlosNameDlg : public ModalDialog
|
|
|
|
{
|
2015-03-09 14:29:30 +02:00
|
|
|
VclPtr<Edit> m_pNewName;
|
|
|
|
TextFilter m_aNoSpaceFilter;
|
|
|
|
VclPtr<Edit> m_pNewShort;
|
|
|
|
VclPtr<OKButton> m_pOk;
|
|
|
|
VclPtr<Edit> m_pOldName;
|
|
|
|
VclPtr<Edit> m_pOldShort;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
protected:
|
2015-10-15 08:13:49 +02:00
|
|
|
DECL_LINK_TYPED( Modify, Edit&, void );
|
2015-08-19 09:11:34 +02:00
|
|
|
DECL_LINK_TYPED(Rename, Button*, void);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
public:
|
2014-09-23 11:20:40 +02:00
|
|
|
SwNewGlosNameDlg( vcl::Window* pParent,
|
2013-10-11 16:34:04 +02:00
|
|
|
const OUString& rOldName,
|
|
|
|
const OUString& rOldShort );
|
2015-03-09 14:29:30 +02:00
|
|
|
virtual ~SwNewGlosNameDlg();
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void dispose() override;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-10-11 16:34:04 +02:00
|
|
|
OUString GetNewName() const { return m_pNewName->GetText(); }
|
|
|
|
OUString GetNewShort() const { return m_pNewShort->GetText(); }
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
SwNewGlosNameDlg::SwNewGlosNameDlg(vcl::Window* pParent,
|
2013-10-11 16:34:04 +02:00
|
|
|
const OUString& rOldName,
|
|
|
|
const OUString& rOldShort )
|
2013-04-26 15:37:22 +01:00
|
|
|
: ModalDialog(pParent, "RenameAutoTextDialog",
|
|
|
|
"modules/swriter/ui/renameautotextdialog.ui")
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-04-26 15:37:22 +01:00
|
|
|
get(m_pNewName, "newname");
|
|
|
|
get(m_pNewShort, "newsc");
|
2014-06-16 15:08:31 +01:00
|
|
|
m_pNewShort->SetTextFilter(&m_aNoSpaceFilter);
|
2013-04-26 15:37:22 +01:00
|
|
|
get(m_pOk, "ok");
|
|
|
|
get(m_pOldName, "oldname");
|
|
|
|
get(m_pOldShort, "oldsc");
|
|
|
|
|
|
|
|
m_pOldName->SetText( rOldName );
|
|
|
|
m_pOldShort->SetText( rOldShort );
|
|
|
|
m_pNewName->SetModifyHdl(LINK(this, SwNewGlosNameDlg, Modify ));
|
|
|
|
m_pNewShort->SetModifyHdl(LINK(this, SwNewGlosNameDlg, Modify ));
|
|
|
|
m_pOk->SetClickHdl(LINK(this, SwNewGlosNameDlg, Rename ));
|
|
|
|
m_pNewName->GrabFocus();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
SwNewGlosNameDlg::~SwNewGlosNameDlg()
|
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2015-03-09 14:29:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwNewGlosNameDlg::dispose()
|
|
|
|
{
|
|
|
|
m_pNewName.clear();
|
|
|
|
m_pNewShort.clear();
|
|
|
|
m_pOk.clear();
|
|
|
|
m_pOldName.clear();
|
|
|
|
m_pOldShort.clear();
|
|
|
|
ModalDialog::dispose();
|
|
|
|
}
|
|
|
|
|
2014-05-25 21:26:51 -04:00
|
|
|
// query / set currently set group
|
2013-09-17 15:43:21 +02:00
|
|
|
OUString SwGlossaryDlg::GetCurrGroup()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-08-24 14:22:58 +02:00
|
|
|
if( !::GetCurrGlosGroup().isEmpty() )
|
|
|
|
return ::GetCurrGlosGroup();
|
2000-09-18 16:15:01 +00:00
|
|
|
return SwGlossaries::GetDefName();
|
|
|
|
}
|
|
|
|
|
2013-09-17 15:43:21 +02:00
|
|
|
void SwGlossaryDlg::SetActGroup(const OUString &rGrp)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-08-24 14:22:58 +02:00
|
|
|
::SetCurrGlosGroup(rGrp);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame,
|
2013-01-07 16:58:29 +00:00
|
|
|
SwGlossaryHdl * pGlosHdl, SwWrtShell *pWrtShell)
|
|
|
|
: SvxStandardDialog(&pViewFrame->GetWindow(), "AutoTextDialog",
|
|
|
|
"modules/swriter/ui/autotext.ui")
|
|
|
|
, sReadonlyPath(SW_RESSTR(STR_READONLY_PATH))
|
2015-11-10 10:25:48 +01:00
|
|
|
, pExampleFrame(nullptr)
|
2013-01-07 16:58:29 +00:00
|
|
|
, pGlossaryHdl(pGlosHdl)
|
|
|
|
, bResume(false)
|
|
|
|
, bSelection(pWrtShell->IsSelection())
|
|
|
|
, bReadOnly(false)
|
|
|
|
, bIsOld(false)
|
|
|
|
, bIsDocReadOnly(false)
|
|
|
|
, pSh(pWrtShell)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
get(m_pInsertTipCB, "inserttip");
|
|
|
|
get(m_pNameED, "name");
|
|
|
|
get(m_pShortNameLbl, "shortnameft");
|
|
|
|
get(m_pShortNameEdit, "shortname");
|
2014-06-16 15:08:31 +01:00
|
|
|
m_pShortNameEdit->SetTextFilter(&m_aNoSpaceFilter);
|
2013-01-07 16:58:29 +00:00
|
|
|
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;
|
2003-04-08 14:34:23 +00:00
|
|
|
|
2013-01-07 16:58:29 +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));
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pEditBtn->SetSelectHdl(LINK(this,SwGlossaryDlg,EditHdl));
|
|
|
|
m_pPathBtn->SetClickHdl(LINK(this, SwGlossaryDlg, PathHdl));
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pNameED->SetModifyHdl(LINK(this,SwGlossaryDlg,NameModify));
|
|
|
|
m_pShortNameEdit->SetModifyHdl(LINK(this,SwGlossaryDlg,NameModify));
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-01-07 16:58:29 +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
|
|
|
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pInsertBtn->SetClickHdl(LINK(this,SwGlossaryDlg,InsertHdl));
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-01-09 11:27:34 +00:00
|
|
|
ShowPreview();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
bIsDocReadOnly = pSh->GetView().GetDocShell()->IsReadOnly() ||
|
|
|
|
pSh->HasReadonlySel();
|
|
|
|
if( bIsDocReadOnly )
|
2014-01-28 19:59:54 +01:00
|
|
|
m_pInsertBtn->Enable(false);
|
2013-01-07 16:58:29 +00:00
|
|
|
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()
|
2015-01-26 13:23:37 +02:00
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2015-01-26 13:23:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwGlossaryDlg::dispose()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pCategoryBox->Clear();
|
2000-09-18 16:15:01 +00:00
|
|
|
delete pExampleFrame;
|
2015-03-09 14:29:30 +02:00
|
|
|
m_pInsertTipCB.clear();
|
|
|
|
m_pNameED.clear();
|
|
|
|
m_pShortNameLbl.clear();
|
|
|
|
m_pShortNameEdit.clear();
|
|
|
|
m_pCategoryBox.clear();
|
|
|
|
m_pFileRelCB.clear();
|
|
|
|
m_pNetRelCB.clear();
|
|
|
|
m_pExampleWIN.clear();
|
|
|
|
m_pInsertBtn.clear();
|
|
|
|
m_pEditBtn.clear();
|
|
|
|
m_pBibBtn.clear();
|
|
|
|
m_pPathBtn.clear();
|
2015-01-26 13:23:37 +02:00
|
|
|
SvxStandardDialog::dispose();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2010-10-12 17:05:15 +01:00
|
|
|
|
2014-05-25 21:26:51 -04:00
|
|
|
// select new group
|
2015-09-07 09:35:04 +02:00
|
|
|
IMPL_LINK_TYPED( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox, void )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = pBox->FirstSelected();
|
2000-09-18 16:15:01 +00:00
|
|
|
if(!pEntry)
|
2015-09-07 09:35:04 +02:00
|
|
|
return;
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pParent = pBox->GetParent(pEntry) ? pBox->GetParent(pEntry) : pEntry;
|
2015-03-28 19:07:45 +01:00
|
|
|
GroupUserData* pGroupData = static_cast<GroupUserData*>(pParent->GetUserData());
|
2013-08-24 14:22:58 +02:00
|
|
|
::SetCurrGlosGroup(pGroupData->sGroupName
|
2014-12-17 15:47:01 +01:00
|
|
|
+ OUStringLiteral1<GLOS_DELIM>()
|
2013-08-24 14:22:58 +02:00
|
|
|
+ OUString::number(pGroupData->nPathIdx));
|
|
|
|
pGlossaryHdl->SetCurGroup(::GetCurrGlosGroup());
|
2011-06-05 15:35:28 +02:00
|
|
|
// set current text block
|
2000-09-18 16:15:01 +00:00
|
|
|
bReadOnly = pGlossaryHdl->IsReadOnly();
|
|
|
|
EnableShortName( !bReadOnly );
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pEditBtn->Enable(!bReadOnly);
|
2000-09-18 16:15:01 +00:00
|
|
|
bIsOld = pGlossaryHdl->IsOld();
|
|
|
|
if( pParent != pEntry)
|
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
OUString aName(pBox->GetEntryText(pEntry));
|
|
|
|
m_pNameED->SetText(aName);
|
2015-03-31 13:17:08 +02:00
|
|
|
m_pShortNameEdit->SetText(*static_cast<OUString*>(pEntry->GetUserData()));
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pInsertBtn->Enable( !bIsDocReadOnly);
|
2013-08-24 14:22:58 +02:00
|
|
|
ShowAutoText(::GetCurrGlosGroup(), m_pShortNameEdit->GetText());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
2014-05-18 14:51:45 +00:00
|
|
|
{
|
|
|
|
m_pNameED->SetText("");
|
|
|
|
m_pShortNameEdit->SetText("");
|
|
|
|
m_pShortNameEdit->Enable(false);
|
|
|
|
ShowAutoText("", "");
|
|
|
|
}
|
2011-06-05 15:35:28 +02:00
|
|
|
// update controls
|
2015-10-15 08:13:49 +02:00
|
|
|
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 );
|
2013-08-24 14:22:58 +02:00
|
|
|
OUString sTemp(::GetCurrGlosGroup());
|
2011-06-05 15:35:28 +02:00
|
|
|
// the zeroth path is not being recorded!
|
2013-08-24 14:22:58 +02:00
|
|
|
if (sTemp.getToken(1, GLOS_DELIM).startsWith("0"))
|
|
|
|
sTemp = sTemp.getToken(0, GLOS_DELIM);
|
2002-06-27 07:47:17 +00:00
|
|
|
aReq.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY, sTemp));
|
|
|
|
aReq.Done();
|
|
|
|
}
|
2016-06-01 16:03:29 +02:00
|
|
|
Invalidate(InvalidateFlags::Update);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwGlossaryDlg::Apply()
|
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString aGlosName(m_pShortNameEdit->GetText());
|
|
|
|
if (!aGlosName.isEmpty())
|
|
|
|
{
|
|
|
|
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 );
|
2013-08-24 14:22:58 +02:00
|
|
|
OUString sTemp(::GetCurrGlosGroup());
|
2011-06-05 15:35:28 +02:00
|
|
|
// the zeroth path is not being recorded!
|
2013-08-24 14:22:58 +02:00
|
|
|
if (sTemp.getToken(1, GLOS_DELIM).startsWith("0"))
|
|
|
|
sTemp = sTemp.getToken(0, GLOS_DELIM);
|
2002-06-27 07:47:17 +00:00
|
|
|
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
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
void SwGlossaryDlg::EnableShortName(bool bOn)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pShortNameLbl->Enable(bOn);
|
|
|
|
m_pShortNameEdit->Enable(bOn);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2014-05-25 21:26:51 -04:00
|
|
|
// does the title exist in the selected group?
|
2013-09-22 02:10:24 +02:00
|
|
|
SvTreeListEntry* SwGlossaryDlg::DoesBlockExist(const OUString& rBlock,
|
|
|
|
const OUString& rShort)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2011-06-05 15:35:28 +02:00
|
|
|
// look for possible entry in TreeListBox
|
2013-01-07 16:58:29 +00:00
|
|
|
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
|
2001-10-30 09:10:36 +00:00
|
|
|
if(pEntry)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
if(m_pCategoryBox->GetParent(pEntry))
|
|
|
|
pEntry = m_pCategoryBox->GetParent(pEntry);
|
|
|
|
sal_uInt32 nChildCount = m_pCategoryBox->GetChildCount( pEntry );
|
2001-10-30 09:10:36 +00:00
|
|
|
for(sal_uInt32 i = 0; i < nChildCount; i++)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
SvTreeListEntry* pChild = m_pCategoryBox->GetEntry( pEntry, i );
|
2013-09-22 02:10:24 +02:00
|
|
|
if (rBlock == m_pCategoryBox->GetEntryText(pChild) &&
|
|
|
|
(rShort.isEmpty() ||
|
2015-03-31 13:17:08 +02:00
|
|
|
rShort==*static_cast<OUString*>(pChild->GetUserData()))
|
2013-09-22 02:10:24 +02:00
|
|
|
)
|
2001-10-30 09:10:36 +00:00
|
|
|
{
|
|
|
|
return pChild;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-10 10:25:48 +01:00
|
|
|
return nullptr;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2015-10-15 08:13:49 +02:00
|
|
|
IMPL_LINK_TYPED( SwGlossaryDlg, NameModify, Edit&, rEdit, void )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString aName(m_pNameED->GetText());
|
2015-10-15 08:13:49 +02:00
|
|
|
bool bNameED = &rEdit == m_pNameED;
|
2013-09-22 02:10:24 +02:00
|
|
|
if( aName.isEmpty() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
if(bNameED)
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pShortNameEdit->SetText(aName);
|
2014-01-28 19:59:54 +01:00
|
|
|
m_pInsertBtn->Enable(false);
|
2015-10-15 08:13:49 +02:00
|
|
|
return;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2015-10-15 08:13:49 +02:00
|
|
|
const bool bNotFound = !DoesBlockExist(aName, bNameED ? OUString() : rEdit.GetText());
|
2000-09-18 16:15:01 +00:00
|
|
|
if(bNameED)
|
|
|
|
{
|
2016-01-09 22:55:28 +01:00
|
|
|
// did the text get in to the Listbox in the Edit with a click?
|
2000-09-18 16:15:01 +00:00
|
|
|
if(bNotFound)
|
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pShortNameEdit->SetText( lcl_GetValidShortCut( aName ) );
|
2000-09-18 16:15:01 +00:00
|
|
|
EnableShortName();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pShortNameEdit->SetText(pGlossaryHdl->GetGlossaryShortName(aName));
|
2000-09-18 16:15:01 +00:00
|
|
|
EnableShortName(!bReadOnly);
|
|
|
|
}
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pInsertBtn->Enable(!bNotFound && !bIsDocReadOnly);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//ShortNameEdit
|
|
|
|
if(!bNotFound)
|
|
|
|
{
|
2014-01-22 14:58:57 +01:00
|
|
|
bool bEnable = !bNotFound;
|
2000-09-18 16:15:01 +00:00
|
|
|
bEnable &= !bIsDocReadOnly;
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pInsertBtn->Enable(bEnable);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-10 14:39:17 +02:00
|
|
|
IMPL_LINK_TYPED( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, pBox, bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = pBox->FirstSelected();
|
2000-09-18 16:15:01 +00:00
|
|
|
if(pBox->GetParent(pEntry) && !bIsDocReadOnly)
|
|
|
|
EndDialog( RET_OK );
|
2015-09-10 14:39:17 +02:00
|
|
|
return false;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2015-05-08 07:49:35 +02:00
|
|
|
IMPL_LINK_TYPED( SwGlossaryDlg, EnableHdl, Menu *, pMn, bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
|
|
|
|
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString aEditText(m_pNameED->GetText());
|
|
|
|
const bool bHasEntry = !aEditText.isEmpty() && !m_pShortNameEdit->GetText().isEmpty();
|
2015-11-10 10:25:48 +01:00
|
|
|
const bool bExists = nullptr != DoesBlockExist(aEditText, m_pShortNameEdit->GetText());
|
2013-02-10 21:13:43 +09:00
|
|
|
const bool bIsGroup = pEntry && !m_pCategoryBox->GetParent(pEntry);
|
2013-01-07 16:58:29 +00:00
|
|
|
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() );
|
2013-01-07 16:58:29 +00:00
|
|
|
pMn->EnableItem("import", bIsGroup && !bIsOld && !pGlossaryHdl->IsReadOnly() );
|
2015-05-08 07:49:35 +02:00
|
|
|
return true;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2015-09-06 12:05:08 +02:00
|
|
|
IMPL_LINK_TYPED( SwGlossaryDlg, MenuHdl, Menu *, pMn, bool )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
OString sItemIdent(pMn->GetCurItemIdent());
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-01-07 16:58:29 +00:00
|
|
|
if (sItemIdent == "replace")
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
pGlossaryHdl->NewGlossary(m_pNameED->GetText(),
|
2015-10-19 17:51:46 +02:00
|
|
|
m_pShortNameEdit->GetText());
|
2013-01-07 16:58:29 +00:00
|
|
|
}
|
|
|
|
else if (sItemIdent == "replacetext")
|
|
|
|
{
|
|
|
|
pGlossaryHdl->NewGlossary(m_pNameED->GetText(),
|
|
|
|
m_pShortNameEdit->GetText(),
|
|
|
|
false, true);
|
|
|
|
}
|
|
|
|
else if (sItemIdent == "new" || sItemIdent == "newtext")
|
|
|
|
{
|
|
|
|
bool bNoAttr = sItemIdent == "newtext";
|
|
|
|
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString aStr(m_pNameED->GetText());
|
|
|
|
const OUString aShortName(m_pShortNameEdit->GetText());
|
2013-01-07 16:58:29 +00:00
|
|
|
if(pGlossaryHdl->HasShortName(aShortName))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2016-05-31 14:25:11 +02:00
|
|
|
ScopedVclPtrInstance<MessageDialog>::Create(this, SW_RES(STR_DOUBLE_SHORTNAME), VclMessageType::Info)->Execute();
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pShortNameEdit->SetSelection(Selection(0, SELECTION_MAX));
|
|
|
|
m_pShortNameEdit->GrabFocus();
|
2015-09-06 12:05:08 +02:00
|
|
|
return true;
|
2013-01-07 16:58:29 +00:00
|
|
|
}
|
2014-04-25 14:00:35 +02:00
|
|
|
if(pGlossaryHdl->NewGlossary(aStr, aShortName, false, bNoAttr ))
|
2013-01-07 16:58:29 +00:00
|
|
|
{
|
|
|
|
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
|
|
|
|
if(m_pCategoryBox->GetParent(pEntry))
|
|
|
|
pEntry = m_pCategoryBox->GetParent(pEntry);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-01-07 16:58:29 +00:00
|
|
|
SvTreeListEntry* pChild = m_pCategoryBox->InsertEntry(aStr, pEntry);
|
2013-09-22 02:10:24 +02:00
|
|
|
pChild->SetUserData(new OUString(aShortName));
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pNameED->SetText(aStr);
|
|
|
|
m_pShortNameEdit->SetText(aShortName);
|
2015-10-15 08:13:49 +02:00
|
|
|
NameModify(*m_pNameED); // for toggling the buttons
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-01-07 16:58:29 +00:00
|
|
|
if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
|
|
|
|
{
|
|
|
|
SfxRequest aReq(pSh->GetView().GetViewFrame(), FN_NEW_GLOSSARY);
|
2013-08-24 14:22:58 +02:00
|
|
|
OUString sTemp(::GetCurrGlosGroup());
|
2013-01-07 16:58:29 +00:00
|
|
|
// the zeroth path is not being recorded!
|
2013-08-24 14:22:58 +02:00
|
|
|
if (sTemp.getToken(1, GLOS_DELIM).startsWith("0"))
|
|
|
|
sTemp = sTemp.getToken(0, GLOS_DELIM);
|
2013-01-07 16:58:29 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2013-01-07 16:58:29 +00:00
|
|
|
}
|
|
|
|
else if (sItemIdent == "copy")
|
|
|
|
{
|
|
|
|
pGlossaryHdl->CopyToClipboard(*pSh, m_pShortNameEdit->GetText());
|
|
|
|
}
|
|
|
|
else if (sItemIdent == "rename")
|
|
|
|
{
|
|
|
|
m_pShortNameEdit->SetText(pGlossaryHdl->GetGlossaryShortName(m_pNameED->GetText()));
|
2015-03-31 21:06:51 +01:00
|
|
|
ScopedVclPtrInstance<SwNewGlosNameDlg> pNewNameDlg(this, m_pNameED->GetText(),
|
|
|
|
m_pShortNameEdit->GetText());
|
2013-01-07 16:58:29 +00:00
|
|
|
if( RET_OK == pNewNameDlg->Execute() &&
|
|
|
|
pGlossaryHdl->Rename( m_pShortNameEdit->GetText(),
|
|
|
|
pNewNameDlg->GetNewShort(),
|
|
|
|
pNewNameDlg->GetNewName()))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
|
|
|
|
SvTreeListEntry* pNewEntry = m_pCategoryBox->InsertEntry(
|
|
|
|
pNewNameDlg->GetNewName(), m_pCategoryBox->GetParent(pEntry));
|
2013-09-22 02:10:24 +02:00
|
|
|
pNewEntry->SetUserData(new OUString(pNewNameDlg->GetNewShort()));
|
2015-03-31 13:17:08 +02:00
|
|
|
delete static_cast<OUString*>(pEntry->GetUserData());
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pCategoryBox->GetModel()->Remove(pEntry);
|
|
|
|
m_pCategoryBox->Select(pNewEntry);
|
|
|
|
m_pCategoryBox->MakeVisible(pNewEntry);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2013-01-07 16:58:29 +00:00
|
|
|
GrpSelect(m_pCategoryBox);
|
|
|
|
}
|
|
|
|
else if (sItemIdent == "delete")
|
|
|
|
{
|
2016-05-31 14:25:11 +02:00
|
|
|
ScopedVclPtrInstance< MessageDialog > aQuery(this, SW_RES(STR_QUERY_DELETE), VclMessageType::Question, VCL_BUTTONS_YES_NO);
|
2015-02-11 14:42:23 +02:00
|
|
|
if (RET_YES == aQuery->Execute())
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString aShortName(m_pShortNameEdit->GetText());
|
|
|
|
const OUString aTitle(m_pNameED->GetText());
|
|
|
|
if (!aTitle.isEmpty() && pGlossaryHdl->DelGlossary(aShortName))
|
2001-07-31 07:41:06 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
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());
|
2015-10-15 08:13:49 +02:00
|
|
|
NameModify(*m_pNameED);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-07 16:58:29 +00:00
|
|
|
}
|
|
|
|
else if (sItemIdent == "macro")
|
|
|
|
{
|
|
|
|
SfxItemSet aSet( pSh->GetAttrPool(), RES_FRMMACRO, RES_FRMMACRO, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );
|
|
|
|
|
2013-10-16 11:18:56 +02:00
|
|
|
SvxMacro aStart(aEmptyOUStr, aEmptyOUStr, STARBASIC);
|
|
|
|
SvxMacro aEnd(aEmptyOUStr, aEmptyOUStr, STARBASIC);
|
2013-01-07 16:58:29 +00:00
|
|
|
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();
|
2015-09-17 11:30:13 +01:00
|
|
|
std::unique_ptr<SfxAbstractDialog> pMacroDlg(pFact->CreateSfxDialog( this, aSet,
|
2014-06-04 04:11:15 +09:00
|
|
|
pSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(), SID_EVENTCONFIG ));
|
2013-01-07 16:58:29 +00:00
|
|
|
if ( pMacroDlg && pMacroDlg->Execute() == RET_OK &&
|
2014-09-10 17:53:41 +02:00
|
|
|
SfxItemState::SET == pMacroDlg->GetOutputItemSet()->GetItemState( RES_FRMMACRO, false, &pItem ) )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
const SvxMacroTableDtor& rTable = static_cast<const SvxMacroItem*>(pItem)->GetMacroTable();
|
2013-01-07 16:58:29 +00:00
|
|
|
pGlossaryHdl->SetMacros( m_pShortNameEdit->GetText(),
|
2015-05-20 13:05:49 +02:00
|
|
|
rTable.Get( SW_EVENT_START_INS_GLOSSARY ),
|
|
|
|
rTable.Get( SW_EVENT_END_INS_GLOSSARY ) );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2013-01-07 16:58:29 +00:00
|
|
|
}
|
|
|
|
else if (sItemIdent == "import")
|
|
|
|
{
|
|
|
|
// call the FileOpenDialog do find WinWord - Files with templates
|
2016-05-11 13:07:30 +02:00
|
|
|
FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE );
|
2015-10-05 23:27:44 +02:00
|
|
|
uno::Reference < XFilePicker2 > xFP = aDlgHelper.GetFilePicker();
|
2013-01-07 16:58:29 +00:00
|
|
|
|
|
|
|
SvtPathOptions aPathOpt;
|
|
|
|
xFP->setDisplayDirectory(aPathOpt.GetWorkPath() );
|
|
|
|
|
|
|
|
uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
|
2013-04-07 12:06:47 +02:00
|
|
|
SfxFilterMatcher aMatcher( OUString::createFromAscii(SwDocShell::Factory().GetShortName()) );
|
2013-01-07 16:58:29 +00:00
|
|
|
SfxFilterMatcherIter aIter( aMatcher );
|
2016-03-11 06:43:06 +01:00
|
|
|
std::shared_ptr<const SfxFilter> pFilter = aIter.First();
|
2013-01-07 16:58:29 +00:00
|
|
|
while ( pFilter )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
if( pFilter->GetUserData() == FILTER_WW8 )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
xFltMgr->appendFilter( pFilter->GetUIName(),
|
|
|
|
pFilter->GetWildcard().getGlob() );
|
|
|
|
xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2009-05-06 10:59:57 +00:00
|
|
|
|
2013-01-07 16:58:29 +00:00
|
|
|
pFilter = aIter.Next();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-01-07 16:58:29 +00:00
|
|
|
if( aDlgHelper.Execute() == ERRCODE_NONE )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2015-10-05 23:27:44 +02:00
|
|
|
if( pGlossaryHdl->ImportGlossaries( xFP->getSelectedFiles().getConstArray()[0] ))
|
2013-01-07 16:58:29 +00:00
|
|
|
Init();
|
|
|
|
else
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2016-05-31 14:25:11 +02:00
|
|
|
ScopedVclPtrInstance<MessageDialog>::Create(this, SW_RES( STR_NO_GLOSSARIES ), VclMessageType::Info)->Execute();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-07 16:58:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-06 12:05:08 +02:00
|
|
|
return false;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2015-09-06 12:05:08 +02:00
|
|
|
return true;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2010-10-12 17:05:15 +01:00
|
|
|
|
2014-05-25 21:26:51 -04:00
|
|
|
// dialog manage regions
|
2015-08-19 09:11:34 +02:00
|
|
|
IMPL_LINK_NOARG_TYPED(SwGlossaryDlg, BibHdl, Button*, void)
|
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;
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString sGlosPath( aPathOpt.GetAutoTextPath() );
|
2014-03-22 18:28:14 +01:00
|
|
|
const sal_Int32 nPaths = comphelper::string::getTokenCount(sGlosPath, ';');
|
2013-02-10 21:13:43 +09:00
|
|
|
bool bIsWritable = false;
|
2014-03-22 18:28:14 +01:00
|
|
|
for(sal_Int32 nPath = 0; nPath < nPaths; nPath++)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString sPath = URIHelper::SmartRel2Abs(
|
|
|
|
INetURLObject(), sGlosPath.getToken(nPath, ';'),
|
2005-01-11 11:42:33 +00:00
|
|
|
URIHelper::GetMaybeFileHdl());
|
2000-09-18 16:15:01 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Content aTestContent( sPath,
|
2012-09-14 18:08:57 +02:00
|
|
|
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())
|
|
|
|
{
|
2015-03-28 19:07:45 +01:00
|
|
|
bIsWritable = !*static_cast<sal_Bool const *>(aAny.getValue());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-22 09:06:06 +00:00
|
|
|
catch (const Exception&)
|
|
|
|
{
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
if(bIsWritable)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(bIsWritable)
|
|
|
|
{
|
|
|
|
|
2015-03-31 23:04:14 +01:00
|
|
|
ScopedVclPtrInstance< SwGlossaryGroupDlg > pDlg( this, pGloss->GetPathArray(), pGlossaryHdl );
|
2000-09-18 16:15:01 +00:00
|
|
|
if ( RET_OK == pDlg->Execute() )
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
//if new groups were created - select one of them
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString sNewGroup = pDlg->GetCreatedGroupName();
|
2013-01-07 16:58:29 +00:00
|
|
|
SvTreeListEntry* pEntry = m_pCategoryBox->First();
|
2013-09-22 02:10:24 +02:00
|
|
|
while (!sNewGroup.isEmpty() && pEntry)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
if(!m_pCategoryBox->GetParent(pEntry))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2015-03-28 19:07:45 +01:00
|
|
|
GroupUserData* pGroupData = static_cast<GroupUserData*>(pEntry->GetUserData());
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString sGroup = pGroupData->sGroupName
|
2014-12-17 15:47:01 +01:00
|
|
|
+ OUStringLiteral1<GLOS_DELIM>()
|
2013-09-22 02:10:24 +02:00
|
|
|
+ OUString::number(pGroupData->nPathIdx);
|
2000-09-18 16:15:01 +00:00
|
|
|
if(sGroup == sNewGroup)
|
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pCategoryBox->Select(pEntry);
|
|
|
|
m_pCategoryBox->MakeVisible(pEntry);
|
|
|
|
GrpSelect(m_pCategoryBox);
|
2000-09-18 16:15:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-07 16:58:29 +00:00
|
|
|
pEntry = m_pCategoryBox->Next(pEntry);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-31 14:25:11 +02:00
|
|
|
ScopedVclPtrInstance< MessageDialog > aBox(this, sReadonlyPath, VclMessageType::Question, VCL_BUTTONS_YES_NO);
|
2014-08-22 09:33:44 +01:00
|
|
|
|
2015-02-11 14:42:23 +02:00
|
|
|
if(RET_YES == aBox->Execute())
|
2013-01-07 16:58:29 +00:00
|
|
|
PathHdl(m_pPathBtn);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-25 21:26:51 -04:00
|
|
|
// initialisation; from Ctor and after editing regions
|
2000-09-18 16:15:01 +00:00
|
|
|
void SwGlossaryDlg::Init()
|
|
|
|
{
|
2014-03-24 15:42:28 +02:00
|
|
|
m_pCategoryBox->SetUpdateMode( false );
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pCategoryBox->Clear();
|
2011-06-05 15:35:28 +02:00
|
|
|
// display text block regions
|
2014-06-29 13:35:45 +02:00
|
|
|
const size_t nCnt = pGlossaryHdl->GetGroupCnt();
|
2015-11-10 10:25:48 +01:00
|
|
|
SvTreeListEntry* pSelEntry = nullptr;
|
2013-08-24 14:22:58 +02:00
|
|
|
const OUString sSelStr(::GetCurrGlosGroup().getToken(0, GLOS_DELIM));
|
2014-03-22 18:28:14 +01:00
|
|
|
const sal_Int32 nSelPath = ::GetCurrGlosGroup().getToken(1, GLOS_DELIM).toInt32();
|
2010-11-14 23:44:41 +01:00
|
|
|
// #i66304# - "My AutoText" comes from mytexts.bau, but should be translated
|
2013-07-25 19:42:17 +02:00
|
|
|
const OUString sMyAutoTextEnglish("My AutoText");
|
|
|
|
const OUString sMyAutoTextTranslated(SW_RES(STR_MY_AUTOTEXT));
|
2014-06-29 13:35:45 +02:00
|
|
|
for(size_t nId = 0; nId < nCnt; ++nId )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-07-25 19:42:17 +02:00
|
|
|
OUString sTitle;
|
|
|
|
OUString sGroupName(pGlossaryHdl->GetGroupName(nId, &sTitle));
|
|
|
|
if(sGroupName.isEmpty())
|
2001-03-08 14:39:01 +00:00
|
|
|
continue;
|
2013-07-25 19:42:17 +02:00
|
|
|
if(sTitle.isEmpty())
|
|
|
|
sTitle = sGroupName.getToken( 0, GLOS_DELIM );
|
2010-11-14 23:44:41 +01:00
|
|
|
if(sTitle == sMyAutoTextEnglish)
|
|
|
|
sTitle = sMyAutoTextTranslated;
|
2013-01-07 16:58:29 +00:00
|
|
|
SvTreeListEntry* pEntry = m_pCategoryBox->InsertEntry( sTitle );
|
2014-03-22 18:28:14 +01:00
|
|
|
const sal_Int32 nPath = sGroupName.getToken( 1, GLOS_DELIM ).toInt32();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
GroupUserData* pData = new GroupUserData;
|
2013-07-25 19:42:17 +02:00
|
|
|
pData->sGroupName = sGroupName.getToken(0, GLOS_DELIM);
|
2014-03-22 18:28:14 +01:00
|
|
|
pData->nPathIdx = static_cast< sal_uInt16 >(nPath);
|
2000-09-18 16:15:01 +00:00
|
|
|
pData->bReadonly = pGlossaryHdl->IsReadOnly(&sGroupName);
|
|
|
|
|
|
|
|
pEntry->SetUserData(pData);
|
|
|
|
if(sSelStr == pData->sGroupName && nSelPath == nPath)
|
|
|
|
pSelEntry = pEntry;
|
|
|
|
|
2011-06-05 15:35:28 +02:00
|
|
|
// fill entries for the groups
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
pGlossaryHdl->SetCurGroup(sGroupName, false, true);
|
2000-09-18 16:15:01 +00:00
|
|
|
const sal_uInt16 nCount = pGlossaryHdl->GetGlossaryCnt();
|
|
|
|
for(sal_uInt16 i = 0; i < nCount; ++i)
|
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
SvTreeListEntry* pChild = m_pCategoryBox->InsertEntry(
|
2013-09-22 02:10:24 +02:00
|
|
|
pGlossaryHdl->GetGlossaryName(i), pEntry);
|
|
|
|
pChild->SetUserData(new OUString(pGlossaryHdl->GetGlossaryShortName(i)));
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-05 15:35:28 +02:00
|
|
|
// set current group and display text blocks
|
2000-09-18 16:15:01 +00:00
|
|
|
if(!pSelEntry)
|
|
|
|
{
|
|
|
|
//find a non-readonly group
|
2013-01-07 16:58:29 +00:00
|
|
|
SvTreeListEntry* pSearch = m_pCategoryBox->First();
|
2000-09-18 16:15:01 +00:00
|
|
|
while(pSearch)
|
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
if(!m_pCategoryBox->GetParent(pSearch))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2015-03-28 19:07:45 +01:00
|
|
|
GroupUserData* pData = static_cast<GroupUserData*>(pSearch->GetUserData());
|
2000-09-18 16:15:01 +00:00
|
|
|
if(!pData->bReadonly)
|
|
|
|
{
|
|
|
|
pSelEntry = pSearch;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-07 16:58:29 +00:00
|
|
|
pSearch = m_pCategoryBox->Next(pSearch);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
if(!pSelEntry)
|
2013-01-07 16:58:29 +00:00
|
|
|
pSelEntry = m_pCategoryBox->GetEntry(0);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
if(pSelEntry)
|
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pCategoryBox->Expand(pSelEntry);
|
|
|
|
m_pCategoryBox->Select(pSelEntry);
|
|
|
|
m_pCategoryBox->MakeVisible(pSelEntry);
|
|
|
|
GrpSelect(m_pCategoryBox);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2015-09-29 18:12:15 +02:00
|
|
|
//JP 16.11.99: the SvxTreeListBox has a Bug. The Box don't recalc the
|
2000-09-18 16:15:01 +00:00
|
|
|
// 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
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pCategoryBox->Resize();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pCategoryBox->GetModel()->Resort();
|
2014-03-24 15:42:28 +02:00
|
|
|
m_pCategoryBox->SetUpdateMode( true );
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pCategoryBox->Update();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-05-20 09:06:56 +01:00
|
|
|
const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
|
2013-01-07 16:58:29 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-04-30 16:58:33 +02:00
|
|
|
IMPL_LINK_NOARG_TYPED(SwGlossaryDlg, EditHdl, MenuButton *, void)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2011-06-05 15:35:28 +02:00
|
|
|
// EndDialog must not be called in MenuHdl
|
2013-01-07 16:58:29 +00:00
|
|
|
if (m_pEditBtn->GetCurItemIdent() == "edit")
|
2001-05-28 13:25:16 +00:00
|
|
|
{
|
2001-05-28 14:03:34 +00:00
|
|
|
SwTextBlocks *pGroup = ::GetGlossaries()->GetGroupDoc ( GetCurrGrpName () );
|
2001-05-28 13:25:16 +00:00
|
|
|
delete pGroup;
|
2015-03-19 11:23:19 +02:00
|
|
|
EndDialog(RET_EDIT);
|
2001-05-28 13:25:16 +00:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2014-05-25 21:26:51 -04:00
|
|
|
// KeyInput for ShortName - Edits without Spaces
|
2015-10-15 08:13:49 +02:00
|
|
|
IMPL_LINK_TYPED( SwNewGlosNameDlg, Modify, Edit&, rBox, void )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-04-26 15:37:22 +01:00
|
|
|
OUString aName(m_pNewName->GetText());
|
2014-12-04 09:07:52 +02:00
|
|
|
SwGlossaryDlg* pDlg = static_cast<SwGlossaryDlg*>(GetParent());
|
2015-10-15 08:13:49 +02:00
|
|
|
if (&rBox == m_pNewName)
|
2013-04-26 15:37:22 +01:00
|
|
|
m_pNewShort->SetText( lcl_GetValidShortCut( aName ) );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bEnable = !aName.isEmpty() && !m_pNewShort->GetText().isEmpty() &&
|
2013-04-26 15:37:22 +01:00
|
|
|
(!pDlg->DoesBlockExist(aName, m_pNewShort->GetText())
|
|
|
|
|| aName == m_pOldName->GetText());
|
|
|
|
m_pOk->Enable(bEnable);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2015-08-19 09:11:34 +02:00
|
|
|
IMPL_LINK_NOARG_TYPED(SwNewGlosNameDlg, Rename, Button*, void)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2014-12-04 09:07:52 +02:00
|
|
|
SwGlossaryDlg* pDlg = static_cast<SwGlossaryDlg*>(GetParent());
|
2013-04-26 15:37:22 +01:00
|
|
|
OUString sNew = GetAppCharClass().uppercase(m_pNewShort->GetText());
|
|
|
|
if( pDlg->pGlossaryHdl->HasShortName(m_pNewShort->GetText())
|
|
|
|
&& sNew != m_pOldShort->GetText() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2016-05-31 14:25:11 +02:00
|
|
|
ScopedVclPtrInstance<MessageDialog>::Create(this, SW_RES(STR_DOUBLE_SHORTNAME), VclMessageType::Info)->Execute();
|
2013-04-26 15:37:22 +01:00
|
|
|
m_pNewShort->GrabFocus();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
2014-11-09 22:24:50 +01:00
|
|
|
EndDialog(RET_OK);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2015-08-19 09:11:34 +02:00
|
|
|
IMPL_LINK_TYPED( SwGlossaryDlg, CheckBoxHdl, Button *, pBox, void )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2011-05-20 09:06:56 +01:00
|
|
|
SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
|
2015-08-19 09:11:34 +02:00
|
|
|
bool bCheck = static_cast<CheckBox*>(pBox)->IsChecked();
|
2013-01-07 16:58:29 +00:00
|
|
|
if (pBox == m_pInsertTipCB)
|
2011-05-20 09:06:56 +01:00
|
|
|
rCfg.SetAutoTextTip(bCheck);
|
2013-01-07 16:58:29 +00:00
|
|
|
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);
|
2015-04-07 13:20:57 +02:00
|
|
|
rCfg.Commit();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2014-05-25 21:26:51 -04:00
|
|
|
// TreeListBox for groups and blocks
|
2014-09-23 11:20:40 +02:00
|
|
|
SwGlTreeListBox::SwGlTreeListBox(vcl::Window* pParent, WinBits nBits)
|
2013-01-07 16:58:29 +00:00
|
|
|
: SvTreeListBox(pParent, nBits)
|
|
|
|
, sReadonly(SW_RESSTR(SW_STR_READONLY)),
|
2015-11-10 10:25:48 +01:00
|
|
|
pDragEntry(nullptr)
|
2013-01-07 16:58:29 +00:00
|
|
|
{
|
2015-04-21 15:33:43 +02:00
|
|
|
SetDragDropMode( DragDropMode::CTRL_MOVE|DragDropMode::CTRL_COPY );
|
2013-01-07 16:58:29 +00:00
|
|
|
}
|
|
|
|
|
2013-01-14 10:40:11 +00:00
|
|
|
Size SwGlTreeListBox::GetOptimalSize() const
|
2013-01-07 16:58:29 +00:00
|
|
|
{
|
2013-01-14 10:40:11 +00:00
|
|
|
return LogicToPixel(Size(212, 84), MapMode(MAP_APPFONT));
|
2013-01-07 16:58:29 +00:00
|
|
|
}
|
|
|
|
|
2015-05-11 13:42:10 +01:00
|
|
|
VCL_BUILDER_FACTORY_ARGS(SwGlTreeListBox, WB_BORDER | WB_TABSTOP)
|
2013-01-07 16:58:29 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
void SwGlTreeListBox::Clear()
|
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = First();
|
2000-09-18 16:15:01 +00:00
|
|
|
while(pEntry)
|
|
|
|
{
|
|
|
|
if(GetParent(pEntry))
|
2015-03-31 13:17:08 +02:00
|
|
|
delete static_cast<OUString*>(pEntry->GetUserData());
|
2000-09-18 16:15:01 +00:00
|
|
|
else
|
2015-03-28 19:07:45 +01:00
|
|
|
delete static_cast<GroupUserData*>(pEntry->GetUserData());
|
2000-09-18 16:15:01 +00:00
|
|
|
pEntry = Next(pEntry);
|
|
|
|
}
|
|
|
|
SvTreeListBox::Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwGlTreeListBox::RequestHelp( const HelpEvent& rHEvt )
|
|
|
|
{
|
|
|
|
Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = GetEntry( aPos );
|
2011-06-05 15:35:28 +02:00
|
|
|
// 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)
|
|
|
|
{
|
2006-06-19 11:43:45 +00:00
|
|
|
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 );
|
2013-09-22 02:10:24 +02:00
|
|
|
OUString sMsg;
|
2000-09-18 16:15:01 +00:00
|
|
|
if(!GetParent(pEntry))
|
|
|
|
{
|
2015-03-28 19:07:45 +01:00
|
|
|
GroupUserData* pData = static_cast<GroupUserData*>(pEntry->GetUserData());
|
2013-08-23 07:58:18 +02:00
|
|
|
const std::vector<OUString> & rPathArr = ::GetGlossaries()->GetPathArray();
|
2012-01-21 20:19:32 +01:00
|
|
|
if( !rPathArr.empty() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
INetURLObject aTmp(rPathArr[pData->nPathIdx]
|
2014-04-01 08:40:44 +03:00
|
|
|
+ "/"
|
2013-09-22 02:10:24 +02:00
|
|
|
+ pData->sGroupName
|
|
|
|
+ SwGlossaries::GetExtension());
|
2000-09-18 16:15:01 +00:00
|
|
|
sMsg = aTmp.GetPath();
|
|
|
|
|
|
|
|
if(pData->bReadonly)
|
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
sMsg += " (" + sReadonly + ")";
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2015-03-31 13:17:08 +02:00
|
|
|
sMsg = *static_cast<OUString*>(pEntry->GetUserData());
|
2000-09-18 16:15:01 +00:00
|
|
|
Help::ShowQuickHelp( this, aItemRect, sMsg,
|
2015-05-14 10:39:01 +02:00
|
|
|
QuickHelpFlags::Left|QuickHelpFlags::VCenter );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 17:05:15 +01:00
|
|
|
|
2001-05-07 07:55:56 +00:00
|
|
|
DragDropMode SwGlTreeListBox::NotifyStartDrag(
|
2007-09-27 11:20:19 +00:00
|
|
|
TransferDataContainer& /*rContainer*/,
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
DragDropMode eRet;
|
|
|
|
pDragEntry = pEntry;
|
|
|
|
if(!GetParent(pEntry))
|
2015-04-21 15:33:43 +02:00
|
|
|
eRet = DragDropMode::NONE;
|
2000-09-18 16:15:01 +00:00
|
|
|
else
|
|
|
|
{
|
2014-12-04 09:07:52 +02:00
|
|
|
SwGlossaryDlg* pDlg = static_cast<SwGlossaryDlg*>(GetParentDialog());
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pParent = GetParent(pEntry);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-03-28 19:07:45 +01:00
|
|
|
GroupUserData* pGroupData = static_cast<GroupUserData*>(pParent->GetUserData());
|
2013-07-25 19:42:17 +02:00
|
|
|
OUString sEntry = pGroupData->sGroupName
|
2014-12-17 15:47:01 +01:00
|
|
|
+ OUStringLiteral1<GLOS_DELIM>()
|
2013-07-25 19:42:17 +02:00
|
|
|
+ OUString::number(pGroupData->nPathIdx);
|
2007-09-27 11:20:19 +00:00
|
|
|
sal_Int8 nDragOption = DND_ACTION_COPY;
|
2015-04-21 15:33:43 +02:00
|
|
|
eRet = DragDropMode::CTRL_COPY;
|
2000-09-18 16:15:01 +00:00
|
|
|
if(!pDlg->pGlossaryHdl->IsReadOnly(&sEntry))
|
|
|
|
{
|
2015-04-21 15:33:43 +02:00
|
|
|
eRet |= DragDropMode::CTRL_MOVE;
|
2007-09-27 11:20:19 +00:00
|
|
|
nDragOption |= DND_ACTION_MOVE;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2007-09-27 11:20:19 +00:00
|
|
|
SetDragOptions( nDragOption );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
return eRet;
|
|
|
|
}
|
2010-10-12 17:05:15 +01:00
|
|
|
|
2014-03-24 15:42:28 +02:00
|
|
|
bool SwGlTreeListBox::NotifyAcceptDrop( SvTreeListEntry* pEntry)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2011-06-05 15:35:28 +02:00
|
|
|
// TODO: Readonly - check still missing!
|
2012-10-18 16:28:20 +02:00
|
|
|
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
|
|
|
|
2014-04-07 17:04:46 +01:00
|
|
|
TriState SwGlTreeListBox::NotifyMoving( SvTreeListEntry* pTarget,
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry,
|
|
|
|
SvTreeListEntry*& /*rpNewParent*/,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong& /*rNewChildPos*/
|
2000-09-18 16:15:01 +00:00
|
|
|
)
|
|
|
|
{
|
2013-08-23 23:30:22 +02:00
|
|
|
return NotifyCopyingOrMoving(pTarget, pEntry, true);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2010-10-12 17:05:15 +01:00
|
|
|
|
2014-04-07 17:04:46 +01:00
|
|
|
TriState SwGlTreeListBox::NotifyCopying( SvTreeListEntry* pTarget,
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry,
|
|
|
|
SvTreeListEntry*& /*rpNewParent*/,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong& /*rNewChildPos*/
|
2000-09-18 16:15:01 +00:00
|
|
|
)
|
2013-08-23 23:30:22 +02:00
|
|
|
{
|
|
|
|
return NotifyCopyingOrMoving(pTarget, pEntry, false);
|
|
|
|
}
|
|
|
|
|
2014-04-07 17:04:46 +01:00
|
|
|
TriState SwGlTreeListBox::NotifyCopyingOrMoving(
|
2013-08-23 23:30:22 +02:00
|
|
|
SvTreeListEntry* pTarget,
|
|
|
|
SvTreeListEntry* pEntry,
|
|
|
|
bool bIsMove)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2015-11-10 10:25:48 +01:00
|
|
|
pDragEntry = nullptr;
|
2011-06-05 15:35:28 +02:00
|
|
|
// 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);
|
|
|
|
}
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pSrcParent = GetParent(pEntry);
|
|
|
|
SvTreeListEntry* pDestParent =
|
2000-09-18 16:15:01 +00:00
|
|
|
GetParent(pTarget) ? GetParent(pTarget) : pTarget;
|
|
|
|
if(pDestParent != pSrcParent)
|
|
|
|
{
|
2014-12-04 09:07:52 +02:00
|
|
|
SwGlossaryDlg* pDlg = static_cast<SwGlossaryDlg*>(GetParentDialog());
|
2014-01-16 07:33:02 +09:00
|
|
|
SwWait aWait( *pDlg->pSh->GetView().GetDocShell(), true );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-03-28 19:07:45 +01:00
|
|
|
GroupUserData* pGroupData = static_cast<GroupUserData*>(pSrcParent->GetUserData());
|
2013-07-25 19:42:17 +02:00
|
|
|
OUString sSourceGroup = pGroupData->sGroupName
|
2014-12-17 15:47:01 +01:00
|
|
|
+ OUStringLiteral1<GLOS_DELIM>()
|
2013-07-25 19:42:17 +02:00
|
|
|
+ OUString::number(pGroupData->nPathIdx);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
pDlg->pGlossaryHdl->SetCurGroup(sSourceGroup);
|
2013-07-25 19:42:17 +02:00
|
|
|
OUString sTitle(GetEntryText(pEntry));
|
2015-03-31 13:17:08 +02:00
|
|
|
OUString sShortName(*static_cast<OUString*>(pEntry->GetUserData()));
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-03-28 19:07:45 +01:00
|
|
|
GroupUserData* pDestData = static_cast<GroupUserData*>(pDestParent->GetUserData());
|
2013-07-25 19:42:17 +02:00
|
|
|
OUString sDestName = pDestData->sGroupName
|
2014-12-17 15:47:01 +01:00
|
|
|
+ OUStringLiteral1<GLOS_DELIM>()
|
2013-07-25 19:42:17 +02:00
|
|
|
+ OUString::number(pDestData->nPathIdx);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-01-16 22:59:20 +01:00
|
|
|
const bool bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup, sShortName,
|
2013-08-23 23:30:22 +02:00
|
|
|
sDestName, sTitle, bIsMove );
|
2000-09-18 16:15:01 +00:00
|
|
|
if(bRet)
|
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pChild = InsertEntry(sTitle, pDestParent);
|
2013-09-22 02:10:24 +02:00
|
|
|
pChild->SetUserData(new OUString(sShortName));
|
2013-08-23 23:30:22 +02:00
|
|
|
if (bIsMove)
|
|
|
|
{
|
|
|
|
GetModel()->Remove(pEntry);
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-07 17:04:46 +01:00
|
|
|
return TRISTATE_FALSE; // otherwise the entry is being set automatically
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 16:03:29 +02:00
|
|
|
void SwGlTreeListBox::ExpandedHdl()
|
|
|
|
{
|
|
|
|
Invalidate(InvalidateFlags::Update);
|
|
|
|
SvTreeListBox::ExpandedHdl();
|
|
|
|
}
|
|
|
|
|
2013-09-22 02:10:24 +02:00
|
|
|
OUString SwGlossaryDlg::GetCurrGrpName() const
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
|
2000-09-18 16:15:01 +00:00
|
|
|
if(pEntry)
|
|
|
|
{
|
|
|
|
pEntry =
|
2013-01-07 16:58:29 +00:00
|
|
|
m_pCategoryBox->GetParent(pEntry) ? m_pCategoryBox->GetParent(pEntry) : pEntry;
|
2015-03-28 19:07:45 +01:00
|
|
|
GroupUserData* pGroupData = static_cast<GroupUserData*>(pEntry->GetUserData());
|
2014-12-17 15:47:01 +01:00
|
|
|
return pGroupData->sGroupName + OUStringLiteral1<GLOS_DELIM>() + OUString::number(pGroupData->nPathIdx);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2013-09-22 02:10:24 +02:00
|
|
|
return OUString();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2015-08-19 09:11:34 +02:00
|
|
|
IMPL_LINK_TYPED( SwGlossaryDlg, PathHdl, Button *, pBtn, void )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-02-03 15:44:51 +00:00
|
|
|
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
|
|
|
|
if(pFact)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2015-09-17 11:30:13 +01:00
|
|
|
std::unique_ptr<AbstractSvxMultiPathDialog> pDlg(pFact->CreateSvxPathSelectDialog(pBtn));
|
2014-07-26 14:23:59 +02:00
|
|
|
OSL_ENSURE(pDlg, "Dialog creation failed!");
|
2004-02-03 15:44:51 +00:00
|
|
|
SvtPathOptions aPathOpt;
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString sGlosPath( aPathOpt.GetAutoTextPath() );
|
2004-02-03 15:44:51 +00:00
|
|
|
pDlg->SetPath(sGlosPath);
|
|
|
|
if(RET_OK == pDlg->Execute())
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
const OUString sTmp(pDlg->GetPath());
|
2004-02-03 15:44:51 +00:00
|
|
|
if(sTmp != sGlosPath)
|
|
|
|
{
|
|
|
|
aPathOpt.SetAutoTextPath( sTmp );
|
2014-04-25 14:00:35 +02:00
|
|
|
::GetGlossaries()->UpdateGlosPath( true );
|
2004-02-03 15:44:51 +00:00
|
|
|
Init();
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-19 09:11:34 +02:00
|
|
|
IMPL_LINK_NOARG_TYPED(SwGlossaryDlg, InsertHdl, Button*, void)
|
2013-01-07 16:58:29 +00:00
|
|
|
{
|
2014-01-17 16:35:03 +01:00
|
|
|
EndDialog(RET_OK);
|
2013-01-07 16:58:29 +00:00
|
|
|
}
|
|
|
|
|
2013-01-09 11:27:34 +00:00
|
|
|
void SwGlossaryDlg::ShowPreview()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-09 11:27:34 +00:00
|
|
|
//create example
|
|
|
|
if (!pExampleFrame)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2015-09-22 22:00:22 +02:00
|
|
|
Link<SwOneExampleFrame&,void> aLink(LINK(this, SwGlossaryDlg, PreviewLoadedHdl));
|
2013-01-09 11:27:34 +00:00
|
|
|
pExampleFrame = new SwOneExampleFrame( *m_pExampleWIN,
|
|
|
|
EX_SHOW_ONLINE_LAYOUT, &aLink );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2013-08-24 14:22:58 +02:00
|
|
|
ShowAutoText(::GetCurrGlosGroup(), m_pShortNameEdit->GetText());
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
2015-09-22 22:00:22 +02:00
|
|
|
IMPL_LINK_NOARG_TYPED(SwGlossaryDlg, PreviewLoadedHdl, SwOneExampleFrame&, void)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2000-12-21 11:12:43 +00:00
|
|
|
ResumeShowAutoText();
|
2001-04-26 18:36:02 +00:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-09-22 02:10:24 +02:00
|
|
|
void SwGlossaryDlg::ShowAutoText(const OUString& rGroup, const OUString& rShortName)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-07 16:58:29 +00:00
|
|
|
if(m_pExampleWIN->IsVisible())
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2000-12-21 11:12:43 +00:00
|
|
|
SetResumeData(rGroup, rShortName);
|
|
|
|
//try to make an Undo()
|
2016-03-08 13:13:59 +02:00
|
|
|
pExampleFrame->ClearDocument();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
2000-12-21 11:12:43 +00:00
|
|
|
|
2013-03-19 15:36:11 +02:00
|
|
|
void SwGlossaryDlg::ResumeShowAutoText()
|
2000-12-21 11:12:43 +00:00
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
OUString sGroup;
|
|
|
|
OUString sShortName;
|
2013-01-07 16:58:29 +00:00
|
|
|
if(GetResumeData(sGroup, sShortName) && m_pExampleWIN->IsVisible())
|
2000-12-21 11:12:43 +00:00
|
|
|
{
|
2013-03-19 15:36:11 +02:00
|
|
|
if(!m_xAutoText.is())
|
2000-12-21 11:12:43 +00:00
|
|
|
{
|
|
|
|
//now the AutoText ListBoxes have to be filled
|
2013-03-14 12:54:48 +02:00
|
|
|
m_xAutoText = text::AutoTextContainer::create( comphelper::getProcessComponentContext() );
|
2000-12-21 11:12:43 +00:00
|
|
|
}
|
|
|
|
|
2015-11-25 06:03:10 -05:00
|
|
|
uno::Reference< XTextCursor > & xCursor = pExampleFrame->GetTextCursor();
|
|
|
|
if(xCursor.is())
|
2000-12-21 11:12:43 +00:00
|
|
|
{
|
2013-09-22 02:10:24 +02:00
|
|
|
if (!sShortName.isEmpty())
|
2000-12-21 11:12:43 +00:00
|
|
|
{
|
2013-03-19 15:36:11 +02:00
|
|
|
uno::Any aGroup = m_xAutoText->getByName(sGroup);
|
2001-09-28 06:16:50 +00:00
|
|
|
uno::Reference< XAutoTextGroup > xGroup;
|
2016-04-12 16:39:03 +02:00
|
|
|
if((aGroup >>= xGroup) && xGroup->hasByName(sShortName))
|
2000-12-21 11:12:43 +00:00
|
|
|
{
|
2016-04-12 16:39:03 +02:00
|
|
|
uno::Any aEntry(xGroup->getByName(sShortName));
|
2001-09-28 06:16:50 +00:00
|
|
|
uno::Reference< XAutoTextEntry > xEntry;
|
|
|
|
aEntry >>= xEntry;
|
2015-11-25 06:03:10 -05:00
|
|
|
uno::Reference< XTextRange > xRange(xCursor, uno::UNO_QUERY);
|
2000-12-21 11:12:43 +00:00
|
|
|
xEntry->applyTo(xRange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ResetResumeData();
|
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|