2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 19:51:51 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 19:51:51 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 19:51:51 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 19:51:51 +00:00
|
|
|
* $RCSfile: toxmgr.cxx,v $
|
|
|
|
* $Revision: 1.17 $
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 19:51:51 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 19:51:51 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 19:51:51 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 19:51:51 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-16 22:04:46 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <wrtsh.hxx>
|
|
|
|
#include <shellres.hxx>
|
|
|
|
#include <swwait.hxx>
|
|
|
|
#include <view.hxx>
|
|
|
|
#include <toxmgr.hxx>
|
2002-02-01 11:51:13 +00:00
|
|
|
#include <crsskip.hxx>
|
2004-05-18 13:11:41 +00:00
|
|
|
#include <doc.hxx>
|
|
|
|
#include <swundo.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#ifndef _GLOBALS_HRC
|
|
|
|
#include <globals.hrc>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Handhabung der Verzeichnisse durch TOXMgr
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
SwTOXMgr::SwTOXMgr(SwWrtShell* pShell):
|
|
|
|
pSh(pShell)
|
|
|
|
{
|
|
|
|
GetTOXMarks();
|
|
|
|
SetCurTOXMark(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Aktuelle TOXMarks behandeln
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
USHORT SwTOXMgr::GetTOXMarks()
|
|
|
|
{
|
|
|
|
return pSh->GetCurTOXMarks(aCurMarks);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SwTOXMark* SwTOXMgr::GetTOXMark(USHORT nId)
|
|
|
|
{
|
|
|
|
if(aCurMarks.Count() > 0)
|
|
|
|
return aCurMarks[nId];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SwTOXMgr::DeleteTOXMark()
|
|
|
|
{
|
|
|
|
SwTOXMark* pNext = 0;
|
|
|
|
if( pCurTOXMark )
|
|
|
|
{
|
|
|
|
pNext = (SwTOXMark*)&pSh->GotoTOXMark( *pCurTOXMark, TOX_NXT );
|
|
|
|
if( pNext == pCurTOXMark )
|
|
|
|
pNext = 0;
|
|
|
|
|
|
|
|
pSh->DeleteTOXMark( pCurTOXMark );
|
|
|
|
pSh->SetModified();
|
|
|
|
}
|
|
|
|
// zur naechsten wandern
|
|
|
|
pCurTOXMark = pNext;
|
|
|
|
}
|
|
|
|
/* -----------------20.08.99 10:48-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void SwTOXMgr::InsertTOXMark(const SwTOXMarkDescription& rDesc)
|
|
|
|
{
|
|
|
|
SwTOXMark* pMark = 0;
|
|
|
|
switch(rDesc.GetTOXType())
|
|
|
|
{
|
|
|
|
case TOX_CONTENT:
|
|
|
|
{
|
|
|
|
ASSERT(rDesc.GetLevel() > 0 && rDesc.GetLevel() <= MAXLEVEL,
|
|
|
|
ungueltiger Level InsertTOCMark);
|
|
|
|
pMark = new SwTOXMark(pSh->GetTOXType(TOX_CONTENT, 0));
|
2007-09-27 11:18:10 +00:00
|
|
|
pMark->SetLevel( static_cast< USHORT >(rDesc.GetLevel()) );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if(rDesc.GetAltStr())
|
|
|
|
pMark->SetAlternativeText(*rDesc.GetAltStr());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TOX_INDEX:
|
|
|
|
{
|
|
|
|
pMark = new SwTOXMark(pSh->GetTOXType(TOX_INDEX, 0));
|
|
|
|
|
|
|
|
if( rDesc.GetPrimKey() && rDesc.GetPrimKey()->Len() )
|
|
|
|
{
|
|
|
|
pMark->SetPrimaryKey( *rDesc.GetPrimKey() );
|
2002-08-08 12:14:10 +00:00
|
|
|
if(rDesc.GetPhoneticReadingOfPrimKey())
|
|
|
|
pMark->SetPrimaryKeyReading( *rDesc.GetPhoneticReadingOfPrimKey() );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if( rDesc.GetSecKey() && rDesc.GetSecKey()->Len() )
|
2002-08-08 12:14:10 +00:00
|
|
|
{
|
2000-09-18 16:15:01 +00:00
|
|
|
pMark->SetSecondaryKey( *rDesc.GetSecKey() );
|
2002-08-08 12:14:10 +00:00
|
|
|
if(rDesc.GetPhoneticReadingOfSecKey())
|
|
|
|
pMark->SetSecondaryKeyReading( *rDesc.GetPhoneticReadingOfSecKey() );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
if(rDesc.GetAltStr())
|
|
|
|
pMark->SetAlternativeText(*rDesc.GetAltStr());
|
2002-08-08 12:14:10 +00:00
|
|
|
if(rDesc.GetPhoneticReadingOfAltStr())
|
|
|
|
pMark->SetTextReading( *rDesc.GetPhoneticReadingOfAltStr() );
|
2000-09-18 16:15:01 +00:00
|
|
|
pMark->SetMainEntry(rDesc.IsMainEntry());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TOX_USER:
|
|
|
|
{
|
|
|
|
ASSERT(rDesc.GetLevel() > 0 && rDesc.GetLevel() <= MAXLEVEL,
|
|
|
|
ungueltiger Level InsertTOCMark);
|
|
|
|
USHORT nId = rDesc.GetTOUName() ?
|
|
|
|
GetUserTypeID(*rDesc.GetTOUName()) : 0;
|
|
|
|
pMark = new SwTOXMark(pSh->GetTOXType(TOX_USER, nId));
|
2007-09-27 11:18:10 +00:00
|
|
|
pMark->SetLevel( static_cast< USHORT >(rDesc.GetLevel()) );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if(rDesc.GetAltStr())
|
|
|
|
pMark->SetAlternativeText(*rDesc.GetAltStr());
|
|
|
|
}
|
|
|
|
break;
|
2007-09-27 11:18:10 +00:00
|
|
|
default:; //prevent warning
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
pSh->StartAllAction();
|
|
|
|
pSh->SwEditShell::Insert(*pMark);
|
|
|
|
pSh->EndAllAction();
|
|
|
|
}
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Update eines TOXMarks
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
void SwTOXMgr::UpdateTOXMark(const SwTOXMarkDescription& rDesc)
|
|
|
|
{
|
|
|
|
ASSERT(pCurTOXMark, "kein aktuelles TOXMark");
|
|
|
|
|
|
|
|
pSh->StartAllAction();
|
|
|
|
if(pCurTOXMark->GetTOXType()->GetType() == TOX_INDEX)
|
|
|
|
{
|
|
|
|
if(rDesc.GetPrimKey() && rDesc.GetPrimKey()->Len() )
|
|
|
|
{
|
|
|
|
pCurTOXMark->SetPrimaryKey( *rDesc.GetPrimKey() );
|
2002-08-08 12:14:10 +00:00
|
|
|
if(rDesc.GetPhoneticReadingOfPrimKey())
|
|
|
|
pCurTOXMark->SetPrimaryKeyReading( *rDesc.GetPhoneticReadingOfPrimKey() );
|
|
|
|
else
|
|
|
|
pCurTOXMark->SetPrimaryKeyReading( aEmptyStr );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if( rDesc.GetSecKey() && rDesc.GetSecKey()->Len() )
|
2002-08-08 12:14:10 +00:00
|
|
|
{
|
2000-09-18 16:15:01 +00:00
|
|
|
pCurTOXMark->SetSecondaryKey( *rDesc.GetSecKey() );
|
2002-08-08 12:14:10 +00:00
|
|
|
if(rDesc.GetPhoneticReadingOfSecKey())
|
|
|
|
pCurTOXMark->SetSecondaryKeyReading( *rDesc.GetPhoneticReadingOfSecKey() );
|
|
|
|
else
|
|
|
|
pCurTOXMark->SetSecondaryKeyReading( aEmptyStr );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
else
|
2002-08-08 12:14:10 +00:00
|
|
|
{
|
2000-09-18 16:15:01 +00:00
|
|
|
pCurTOXMark->SetSecondaryKey( aEmptyStr );
|
2002-08-08 12:14:10 +00:00
|
|
|
pCurTOXMark->SetSecondaryKeyReading( aEmptyStr );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
2002-08-08 12:14:10 +00:00
|
|
|
{
|
2000-09-18 16:15:01 +00:00
|
|
|
pCurTOXMark->SetPrimaryKey( aEmptyStr );
|
2002-08-08 12:14:10 +00:00
|
|
|
pCurTOXMark->SetPrimaryKeyReading( aEmptyStr );
|
|
|
|
pCurTOXMark->SetSecondaryKey( aEmptyStr );
|
|
|
|
pCurTOXMark->SetSecondaryKeyReading( aEmptyStr );
|
|
|
|
}
|
|
|
|
if(rDesc.GetPhoneticReadingOfAltStr())
|
|
|
|
pCurTOXMark->SetTextReading( *rDesc.GetPhoneticReadingOfAltStr() );
|
|
|
|
else
|
|
|
|
pCurTOXMark->SetTextReading( aEmptyStr );
|
2000-09-18 16:15:01 +00:00
|
|
|
pCurTOXMark->SetMainEntry(rDesc.IsMainEntry());
|
|
|
|
}
|
|
|
|
else
|
2007-09-27 11:18:10 +00:00
|
|
|
pCurTOXMark->SetLevel( static_cast< USHORT >(rDesc.GetLevel()) );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if(rDesc.GetAltStr())
|
|
|
|
{
|
|
|
|
// JP 26.08.96: Bug 30344 - entweder der Text aus dem Doc oder
|
|
|
|
// ein Alternativ-Text, beides gibts nicht!
|
|
|
|
BOOL bReplace = pCurTOXMark->IsAlternativeText();
|
2000-11-20 21:07:04 +00:00
|
|
|
if( bReplace )
|
|
|
|
pCurTOXMark->SetAlternativeText( *rDesc.GetAltStr() );
|
|
|
|
else
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
SwTOXMark aCpy( *pCurTOXMark );
|
|
|
|
aCurMarks.Remove(0, aCurMarks.Count());
|
|
|
|
pSh->DeleteTOXMark(pCurTOXMark);
|
2000-11-20 21:07:04 +00:00
|
|
|
aCpy.SetAlternativeText( *rDesc.GetAltStr() );
|
2000-09-18 16:15:01 +00:00
|
|
|
pSh->SwEditShell::Insert( aCpy );
|
|
|
|
pCurTOXMark = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pSh->SetModified();
|
|
|
|
pSh->EndAllAction();
|
|
|
|
// Bug 36207 pCurTOXMark zeigt hier in den Wald!
|
|
|
|
if(!pCurTOXMark)
|
|
|
|
{
|
2002-02-01 11:51:13 +00:00
|
|
|
pSh->Left(CRSR_SKIP_CHARS, FALSE, 1, FALSE );
|
2000-09-18 16:15:01 +00:00
|
|
|
pSh->GetCurTOXMarks(aCurMarks);
|
|
|
|
SetCurTOXMark(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: UserTypeID ermitteln
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
USHORT SwTOXMgr::GetUserTypeID(const String& rStr)
|
|
|
|
{
|
|
|
|
USHORT nSize = pSh->GetTOXTypeCount(TOX_USER);
|
|
|
|
for(USHORT i=0; i < nSize; ++i)
|
|
|
|
{
|
|
|
|
const SwTOXType* pTmp = pSh->GetTOXType(TOX_USER, i);
|
|
|
|
if(pTmp && pTmp->GetTypeName() == rStr)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
SwTOXType aUserType(TOX_USER, rStr);
|
|
|
|
pSh->InsertTOXType(aUserType);
|
|
|
|
return nSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Traveling zwischen den TOXMarks
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
void SwTOXMgr::NextTOXMark(BOOL bSame)
|
|
|
|
{
|
|
|
|
ASSERT(pCurTOXMark, "kein aktuelles TOXMark");
|
|
|
|
if( pCurTOXMark )
|
|
|
|
{
|
|
|
|
SwTOXSearch eDir = bSame ? TOX_SAME_NXT : TOX_NXT;
|
|
|
|
pCurTOXMark = (SwTOXMark*)&pSh->GotoTOXMark( *pCurTOXMark, eDir );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SwTOXMgr::PrevTOXMark(BOOL bSame)
|
|
|
|
{
|
|
|
|
ASSERT(pCurTOXMark, "kein aktuelles TOXMark");
|
|
|
|
if( pCurTOXMark )
|
|
|
|
{
|
|
|
|
SwTOXSearch eDir = bSame ? TOX_SAME_PRV : TOX_PRV;
|
|
|
|
pCurTOXMark = (SwTOXMark*)&pSh->GotoTOXMark(*pCurTOXMark, eDir );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Stichwortverzeichnis einfuegen
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
const SwTOXBase* SwTOXMgr::GetCurTOX()
|
|
|
|
{
|
|
|
|
return pSh->GetCurTOX();
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwTOXType* SwTOXMgr::GetTOXType(TOXTypes eTyp, USHORT nId) const
|
|
|
|
{
|
|
|
|
return pSh->GetTOXType(eTyp, nId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTOXMgr::SetCurTOXMark(USHORT nId)
|
|
|
|
{
|
|
|
|
pCurTOXMark = (nId < aCurMarks.Count()) ? aCurMarks[nId] : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------01.07.99 16:23-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
|
|
|
|
BOOL SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc,
|
|
|
|
SwTOXBase** ppBase,
|
|
|
|
const SfxItemSet* pSet)
|
|
|
|
{
|
|
|
|
SwWait aWait( *pSh->GetView().GetDocShell(), TRUE );
|
|
|
|
BOOL bRet = TRUE;
|
2000-11-03 10:32:31 +00:00
|
|
|
const SwTOXBase* pCurTOX = ppBase && *ppBase ? *ppBase : GetCurTOX();
|
2000-09-18 16:15:01 +00:00
|
|
|
SwTOXBase* pTOX = (SwTOXBase*)pCurTOX;
|
2004-05-18 13:11:41 +00:00
|
|
|
|
|
|
|
SwTOXBase * pNewTOX = NULL;
|
|
|
|
|
|
|
|
if (pTOX)
|
|
|
|
pNewTOX = new SwTOXBase(*pTOX);
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
TOXTypes eCurTOXType = rDesc.GetTOXType();
|
|
|
|
if(pCurTOX && !ppBase && pSh->HasSelection())
|
|
|
|
pSh->DelRight();
|
|
|
|
|
|
|
|
switch(eCurTOXType)
|
|
|
|
{
|
|
|
|
case TOX_INDEX :
|
|
|
|
{
|
2000-11-03 10:32:31 +00:00
|
|
|
if(!pCurTOX || (ppBase && !(*ppBase)))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, 0);
|
|
|
|
SwForm aForm(eCurTOXType);
|
2007-09-27 11:18:10 +00:00
|
|
|
pNewTOX = new SwTOXBase(pType, aForm, nsSwTOXElement::TOX_MARK, pType->GetTypeName());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX->SetOptions(rDesc.GetIndexOptions());
|
|
|
|
pNewTOX->SetMainEntryCharStyle(rDesc.GetMainEntryCharStyle());
|
2000-09-18 16:15:01 +00:00
|
|
|
pSh->SetTOIAutoMarkURL(rDesc.GetAutoMarkURL());
|
|
|
|
pSh->ApplyAutoMark();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TOX_CONTENT :
|
|
|
|
{
|
2000-11-03 10:32:31 +00:00
|
|
|
if(!pCurTOX || (ppBase && !(*ppBase)))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, 0);
|
|
|
|
SwForm aForm(eCurTOXType);
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX = new SwTOXBase(pType, aForm, rDesc.GetContentOptions(), pType->GetTypeName());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX->SetCreate(rDesc.GetContentOptions());
|
|
|
|
pNewTOX->SetLevel(rDesc.GetLevel());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TOX_USER :
|
|
|
|
{
|
2000-11-03 10:32:31 +00:00
|
|
|
if(!pCurTOX || (ppBase && !(*ppBase)))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
USHORT nPos = 0;
|
|
|
|
USHORT nSize = pSh->GetTOXTypeCount(eCurTOXType);
|
|
|
|
for(USHORT i=0; rDesc.GetTOUName() && i < nSize; ++i)
|
|
|
|
{ const SwTOXType* pType = pSh->GetTOXType(TOX_USER, i);
|
|
|
|
if(pType->GetTypeName() == *rDesc.GetTOUName())
|
|
|
|
{ nPos = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, nPos);
|
|
|
|
|
|
|
|
SwForm aForm(eCurTOXType);
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX = new SwTOXBase(pType, aForm, rDesc.GetContentOptions(), pType->GetTypeName());
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-27 11:18:10 +00:00
|
|
|
const_cast<SwTOXBase*>( pCurTOX )->SetCreate(rDesc.GetContentOptions());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX->SetLevelFromChapter(rDesc.IsLevelFromChapter());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TOX_OBJECTS:
|
|
|
|
case TOX_TABLES:
|
|
|
|
case TOX_AUTHORITIES:
|
|
|
|
case TOX_ILLUSTRATIONS:
|
|
|
|
{
|
|
|
|
//Special handling for TOX_AUTHORITY
|
|
|
|
if(TOX_AUTHORITIES == eCurTOXType)
|
|
|
|
{
|
|
|
|
SwAuthorityFieldType* pFType = (SwAuthorityFieldType*)
|
|
|
|
pSh->GetFldType(RES_AUTHORITY, aEmptyStr);
|
2002-10-30 09:41:06 +00:00
|
|
|
if(!pFType)
|
|
|
|
pFType = (SwAuthorityFieldType*)pSh->InsertFldType(
|
|
|
|
SwAuthorityFieldType(pSh->GetDoc()));
|
|
|
|
pFType->SetPreSuffix(rDesc.GetAuthBrackets().GetChar(0),
|
|
|
|
rDesc.GetAuthBrackets().GetChar(1));
|
|
|
|
pFType->SetSequence(rDesc.IsAuthSequence());
|
|
|
|
SwTOXSortKey rArr[3];
|
|
|
|
rArr[0] = rDesc.GetSortKey1();
|
|
|
|
rArr[1] = rDesc.GetSortKey2();
|
|
|
|
rArr[2] = rDesc.GetSortKey3();
|
|
|
|
pFType->SetSortKeys(3, rArr);
|
|
|
|
pFType->SetSortByDocument(rDesc.IsSortByDocument());
|
|
|
|
pFType->SetLanguage(rDesc.GetLanguage());
|
|
|
|
pFType->SetSortAlgorithm(rDesc.GetSortAlgorithm());
|
|
|
|
|
|
|
|
pFType->UpdateFlds();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
// TODO: consider properties of the current TOXType
|
2000-11-03 10:32:31 +00:00
|
|
|
if(!pCurTOX || (ppBase && !(*ppBase)))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
const SwTOXType* pType = pSh->GetTOXType(eCurTOXType, 0);
|
|
|
|
SwForm aForm(eCurTOXType);
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX = new SwTOXBase(
|
2000-09-18 16:15:01 +00:00
|
|
|
pType, aForm,
|
2007-09-27 11:18:10 +00:00
|
|
|
TOX_AUTHORITIES == eCurTOXType ? nsSwTOXElement::TOX_MARK : 0, pType->GetTypeName());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-11-03 10:32:31 +00:00
|
|
|
if((!ppBase || !(*ppBase)) && pSh->HasSelection())
|
2000-09-18 16:15:01 +00:00
|
|
|
pSh->DelRight();
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX = (SwTOXBase*)pCurTOX;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
// pTOX->SetOptions(rDesc.GetIndexOptions());
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX->SetFromObjectNames(rDesc.IsCreateFromObjectNames());
|
|
|
|
pNewTOX->SetOLEOptions(rDesc.GetOLEOptions());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-10 15:06:12 +00:00
|
|
|
DBG_ASSERT(pNewTOX, "no TOXBase created!" );
|
2004-05-18 13:11:41 +00:00
|
|
|
if(!pNewTOX)
|
2000-09-18 16:15:01 +00:00
|
|
|
return FALSE;
|
2004-05-18 13:11:41 +00:00
|
|
|
|
|
|
|
pNewTOX->SetFromChapter(rDesc.IsFromChapter());
|
|
|
|
pNewTOX->SetSequenceName(rDesc.GetSequenceName());
|
|
|
|
pNewTOX->SetCaptionDisplay(rDesc.GetCaptionDisplay());
|
|
|
|
pNewTOX->SetProtected(rDesc.IsReadonly());
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
for(USHORT nLevel = 0; nLevel < MAXLEVEL; nLevel++)
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX->SetStyleNames(rDesc.GetStyleNames(nLevel), nLevel);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if(rDesc.GetTitle())
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX->SetTitle(*rDesc.GetTitle());
|
2000-09-18 16:15:01 +00:00
|
|
|
if(rDesc.GetForm())
|
2004-05-18 13:11:41 +00:00
|
|
|
pNewTOX->SetTOXForm(*rDesc.GetForm());
|
|
|
|
pNewTOX->SetLanguage(rDesc.GetLanguage());
|
|
|
|
pNewTOX->SetSortAlgorithm(rDesc.GetSortAlgorithm());
|
2001-06-06 09:41:26 +00:00
|
|
|
|
2000-11-03 10:32:31 +00:00
|
|
|
if(!pCurTOX || (ppBase && !(*ppBase)) )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
// wird ppBase uebergeben, dann wird das TOXBase hier nur erzeugt
|
|
|
|
// und dann ueber den Dialog in ein Globaldokument eingefuegt
|
|
|
|
if(ppBase)
|
2004-05-18 13:11:41 +00:00
|
|
|
(*ppBase) = pNewTOX;
|
2000-09-18 16:15:01 +00:00
|
|
|
else
|
|
|
|
{
|
2004-05-18 13:11:41 +00:00
|
|
|
pSh->InsertTableOf(*pNewTOX, pSet);
|
|
|
|
delete pNewTOX;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2004-05-18 13:11:41 +00:00
|
|
|
{
|
|
|
|
SwDoc * pDoc = pSh->GetDoc();
|
|
|
|
|
|
|
|
if (pDoc->DoesUndo())
|
2005-03-29 13:39:43 +00:00
|
|
|
{
|
|
|
|
if (pNewTOX != NULL)
|
|
|
|
pDoc->DelAllUndoObj();
|
|
|
|
|
2006-08-14 16:47:53 +00:00
|
|
|
pDoc->StartUndo(UNDO_TOXCHANGE, NULL);
|
2005-03-29 13:39:43 +00:00
|
|
|
}
|
2004-05-18 13:11:41 +00:00
|
|
|
|
|
|
|
if (pNewTOX != NULL) // => pTOX != NULL
|
|
|
|
pDoc->ChgTOX(*pTOX, *pNewTOX);
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
bRet = pSh->UpdateTableOf(*pTOX, pSet);
|
|
|
|
|
2004-05-18 13:11:41 +00:00
|
|
|
if (pDoc->DoesUndo())
|
2005-03-29 13:39:43 +00:00
|
|
|
{
|
2006-08-14 16:47:53 +00:00
|
|
|
pDoc->EndUndo(UNDO_TOXCHANGE, NULL);
|
2004-05-18 13:11:41 +00:00
|
|
|
|
2005-03-29 13:39:43 +00:00
|
|
|
if (pNewTOX == NULL)
|
|
|
|
pDoc->DelAllUndoObj();
|
|
|
|
}
|
2004-05-18 13:11:41 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
/* -----------------20.10.99 14:11-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void SwTOXDescription::SetSortKeys(SwTOXSortKey eKey1,
|
|
|
|
SwTOXSortKey eKey2,
|
|
|
|
SwTOXSortKey eKey3)
|
|
|
|
{
|
|
|
|
SwTOXSortKey aArr[3];
|
|
|
|
USHORT nPos = 0;
|
|
|
|
if(AUTH_FIELD_END > eKey1.eField)
|
|
|
|
aArr[nPos++] = eKey1;
|
|
|
|
if(AUTH_FIELD_END > eKey2.eField)
|
|
|
|
aArr[nPos++] = eKey2;
|
|
|
|
if(AUTH_FIELD_END > eKey3.eField)
|
|
|
|
aArr[nPos++] = eKey3;
|
|
|
|
|
|
|
|
eSortKey1 = aArr[0];
|
|
|
|
eSortKey2 = aArr[1];
|
|
|
|
eSortKey3 = aArr[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------10.09.99 10:02-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void SwTOXDescription::ApplyTo(SwTOXBase& rTOXBase)
|
|
|
|
{
|
|
|
|
for(USHORT i = 0; i < MAXLEVEL; i++)
|
|
|
|
rTOXBase.SetStyleNames(GetStyleNames(i), i);
|
|
|
|
rTOXBase.SetTitle(GetTitle() ? *GetTitle() : aEmptyStr);
|
|
|
|
rTOXBase.SetCreate(GetContentOptions());
|
|
|
|
|
|
|
|
if(GetTOXType() == TOX_INDEX)
|
|
|
|
rTOXBase.SetOptions(GetIndexOptions());
|
|
|
|
if(GetTOXType() != TOX_INDEX)
|
|
|
|
rTOXBase.SetLevel(GetLevel());
|
|
|
|
rTOXBase.SetFromObjectNames(IsCreateFromObjectNames());
|
|
|
|
rTOXBase.SetSequenceName(GetSequenceName());
|
|
|
|
rTOXBase.SetCaptionDisplay(GetCaptionDisplay());
|
|
|
|
rTOXBase.SetFromChapter(IsFromChapter());
|
|
|
|
rTOXBase.SetProtected(IsReadonly());
|
|
|
|
rTOXBase.SetOLEOptions(GetOLEOptions());
|
|
|
|
rTOXBase.SetLevelFromChapter(IsLevelFromChapter());
|
2001-06-06 09:41:26 +00:00
|
|
|
rTOXBase.SetLanguage(eLanguage);
|
|
|
|
rTOXBase.SetSortAlgorithm(sSortAlgorithm);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|