Files
libreoffice/sw/source/core/tox/tox.cxx

943 lines
28 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 23:08:29 +00:00
#include <hintids.hxx>
#include <swtypes.hxx>
#include <txtatr.hxx>
#include <ndtxt.hxx>
#include <txttxmrk.hxx>
#include <tox.hxx>
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
#include <strings.hrc>
2000-09-18 23:08:29 +00:00
#include <doc.hxx>
#include <docary.hxx>
#include <paratr.hxx>
#include <editeng/tstpitem.hxx>
#include <SwStyleNameMapper.hxx>
#include <hints.hxx>
#include <functional>
#include <calbck.hxx>
#include <boost/optional.hpp>
#include <algorithm>
using namespace std;
const sal_Unicode C_NUM_REPL = '@';
const sal_Unicode C_END_PAGE_NUM = '~';
const OUString S_PAGE_DELI(", ");
namespace
{
2000-09-18 23:08:29 +00:00
void lcl_FillAuthPattern(SwFormTokens &rAuthTokens, sal_uInt16 nTypeId)
2000-09-18 23:08:29 +00:00
{
rAuthTokens.reserve(9); // Worst case: Start+Sep1+Auth+3*(Sep2+Auth)
SwFormToken aStartToken( TOKEN_AUTHORITY );
aStartToken.nAuthorityField = AUTH_FIELD_IDENTIFIER;
rAuthTokens.push_back( aStartToken );
SwFormToken aSeparatorToken( TOKEN_TEXT );
aSeparatorToken.sText = ": ";
rAuthTokens.push_back( aSeparatorToken );
--nTypeId; // compensate +1 offset introduced by caller
SwFormToken aTextToken( TOKEN_TEXT );
aTextToken.sText = ", ";
const ToxAuthorityField nVals[4] = {
AUTH_FIELD_AUTHOR,
AUTH_FIELD_TITLE,
AUTH_FIELD_YEAR,
nTypeId == AUTH_TYPE_WWW ? AUTH_FIELD_URL : AUTH_FIELD_END
};
for(size_t i = 0; i < SAL_N_ELEMENTS(nVals); ++i)
2000-09-18 23:08:29 +00:00
{
if(nVals[i] == AUTH_FIELD_END)
2000-09-18 23:08:29 +00:00
break;
if( i > 0 )
rAuthTokens.push_back( aTextToken );
// -> #i21237#
SwFormToken aToken(TOKEN_AUTHORITY);
aToken.nAuthorityField = nVals[i];
rAuthTokens.push_back(aToken);
// <- #i21237#
2000-09-18 23:08:29 +00:00
}
}
}
/// pool default constructor
2000-09-18 23:08:29 +00:00
SwTOXMark::SwTOXMark()
: SfxPoolItem( RES_TXTATR_TOXMARK )
, SwModify( nullptr )
,
m_pTextAttr( nullptr ), m_nLevel( 0 ),
m_bAutoGenerated(false),
m_bMainEntry(false)
2000-09-18 23:08:29 +00:00
{
}
SwTOXMark::SwTOXMark( const SwTOXType* pTyp )
: SfxPoolItem( RES_TXTATR_TOXMARK )
, SwModify( const_cast<SwTOXType*>(pTyp) )
,
m_pTextAttr( nullptr ), m_nLevel( 0 ),
m_bAutoGenerated(false),
m_bMainEntry(false)
2000-09-18 23:08:29 +00:00
{
}
SwTOXMark::SwTOXMark( const SwTOXMark& rCopy )
: SfxPoolItem( RES_TXTATR_TOXMARK )
, SwModify(rCopy.GetRegisteredInNonConst())
,
m_aPrimaryKey( rCopy.m_aPrimaryKey ), m_aSecondaryKey( rCopy.m_aSecondaryKey ),
m_aTextReading( rCopy.m_aTextReading ),
m_aPrimaryKeyReading( rCopy.m_aPrimaryKeyReading ),
m_aSecondaryKeyReading( rCopy.m_aSecondaryKeyReading ),
m_pTextAttr( nullptr ), m_nLevel( rCopy.m_nLevel ),
m_bAutoGenerated( rCopy.m_bAutoGenerated),
m_bMainEntry(rCopy.m_bMainEntry)
2000-09-18 23:08:29 +00:00
{
// Copy AlternativString
m_aAltText = rCopy.m_aAltText;
2000-09-18 23:08:29 +00:00
}
SwTOXMark::~SwTOXMark()
{
}
void SwTOXMark::RegisterToTOXType(SwTOXType& rType)
{
rType.Add(this);
}
bool SwTOXMark::operator==( const SfxPoolItem& rAttr ) const
2000-09-18 23:08:29 +00:00
{
assert(SfxPoolItem::operator==(rAttr));
return GetRegisteredIn() == static_cast<const SwTOXMark&>(rAttr).GetRegisteredIn();
2000-09-18 23:08:29 +00:00
}
SfxPoolItem* SwTOXMark::Clone( SfxItemPool* ) const
{
return new SwTOXMark( *this );
}
void SwTOXMark::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew)
{
NotifyClients(pOld, pNew);
if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
{ // invalidate cached uno object
SetXTOXMark(css::uno::Reference<css::text::XDocumentIndexMark>(nullptr));
}
}
void SwTOXMark::InvalidateTOXMark()
{
SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT,
&static_cast<SwModify&>(*this) ); // cast to base class!
NotifyClients(&aMsgHint, &aMsgHint);
}
2000-09-18 23:08:29 +00:00
OUString SwTOXMark::GetText() const
2000-09-18 23:08:29 +00:00
{
if( !m_aAltText.isEmpty() )
return m_aAltText;
if( m_pTextAttr && m_pTextAttr->GetpTextNd() )
2000-09-18 23:08:29 +00:00
{
const sal_Int32* pEndIdx = m_pTextAttr->GetEnd();
OSL_ENSURE( pEndIdx, "TOXMark without mark!");
2000-09-18 23:08:29 +00:00
if( pEndIdx )
{
const sal_Int32 nStt = m_pTextAttr->GetStart();
return m_pTextAttr->GetpTextNd()->GetExpandText( nStt, *pEndIdx-nStt );
2000-09-18 23:08:29 +00:00
}
}
return OUString();
2000-09-18 23:08:29 +00:00
}
void SwTOXMark::InsertTOXMarks( SwTOXMarks& aMarks, const SwTOXType& rType )
{
SwIterator<SwTOXMark,SwTOXType> aIter(rType);
SwTOXMark* pMark = aIter.First();
while( pMark )
{
if(pMark->GetTextTOXMark())
aMarks.push_back(pMark);
pMark = aIter.Next();
}
}
// Manage types of TOX
SwTOXType::SwTOXType( TOXTypes eTyp, const OUString& rName )
: SwModify(nullptr),
m_aName(rName),
m_eType(eTyp)
2000-09-18 23:08:29 +00:00
{
}
SwTOXType::SwTOXType(const SwTOXType& rCopy)
: SwModify( const_cast<SwModify*>(rCopy.GetRegisteredIn()) ),
m_aName(rCopy.m_aName),
m_eType(rCopy.m_eType)
2000-09-18 23:08:29 +00:00
{
}
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
static const char* STR_POOLCOLL_TOX_ARY[] =
{
// Subcategory Index-Directories
STR_POOLCOLL_TOX_IDXH,
STR_POOLCOLL_TOX_IDX1,
STR_POOLCOLL_TOX_IDX2,
STR_POOLCOLL_TOX_IDX3,
STR_POOLCOLL_TOX_IDXBREAK
};
static const char* STR_POOLCOLL_TOX_CNTNT_ARY[] =
{
// Subcategory Tables of Contents
STR_POOLCOLL_TOX_CNTNTH,
STR_POOLCOLL_TOX_CNTNT1,
STR_POOLCOLL_TOX_CNTNT2,
STR_POOLCOLL_TOX_CNTNT3,
STR_POOLCOLL_TOX_CNTNT4,
STR_POOLCOLL_TOX_CNTNT5
};
static const char* STR_POOLCOLL_TOX_CNTNT_EXTRA_ARY[] =
{
// Subcategory Table of Contents more Levels 5 - 10
STR_POOLCOLL_TOX_CNTNT6,
STR_POOLCOLL_TOX_CNTNT7,
STR_POOLCOLL_TOX_CNTNT8,
STR_POOLCOLL_TOX_CNTNT9,
STR_POOLCOLL_TOX_CNTNT10
};
static const char* STR_POOLCOLL_TOX_USER_ARY[] =
{
// Subcategory User-Directories:
STR_POOLCOLL_TOX_USERH,
STR_POOLCOLL_TOX_USER1,
STR_POOLCOLL_TOX_USER2,
STR_POOLCOLL_TOX_USER3,
STR_POOLCOLL_TOX_USER4,
STR_POOLCOLL_TOX_USER5
};
static const char* STR_POOLCOLL_TOX_USER_EXTRA_ARY[] =
{
// Subcategory User-Directories more Levels 5 - 10
STR_POOLCOLL_TOX_USER6,
STR_POOLCOLL_TOX_USER7,
STR_POOLCOLL_TOX_USER8,
STR_POOLCOLL_TOX_USER9,
STR_POOLCOLL_TOX_USER10
};
static const char* STR_POOLCOLL_TOX_ILLUS_ARY[] =
{
// Illustrations Index
STR_POOLCOLL_TOX_ILLUSH,
STR_POOLCOLL_TOX_ILLUS1
};
static const char* STR_POOLCOLL_TOX_OBJECT_ARY[] =
{
// Object Index
STR_POOLCOLL_TOX_OBJECTH,
STR_POOLCOLL_TOX_OBJECT1
};
static const char* STR_POOLCOLL_TOX_TABLES_ARY[] =
{
// Tables Index
STR_POOLCOLL_TOX_TABLESH,
STR_POOLCOLL_TOX_TABLES1
};
static const char* STR_POOLCOLL_TOX_AUTHORITIES_ARY[] =
{
// Index of Authorities
STR_POOLCOLL_TOX_AUTHORITIESH,
STR_POOLCOLL_TOX_AUTHORITIES1
};
static const char* STR_POOLCOLL_TOX_CITATION_ARY[] =
{
STR_POOLCOLL_TOX_CITATION
};
// Edit forms
SwForm::SwForm( TOXTypes eTyp ) // #i21237#
: m_eType( eTyp ), m_nFormMaxLevel( SwForm::GetFormMaxLevel( eTyp )),
2000-09-18 23:08:29 +00:00
// nFirstTabPos( lNumIndent ),
m_bCommaSeparated(false)
2000-09-18 23:08:29 +00:00
{
//bHasFirstTabPos =
m_bIsRelTabPos = true;
2000-09-18 23:08:29 +00:00
// The table of contents has a certain number of headlines + headings
// The user has 10 levels + headings
// Keyword has 3 levels + headings+ separator
// Indexes of tables, object illustrations and authorities consist of a heading and one level
2000-09-18 23:08:29 +00:00
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
const char** pPoolId;
switch( m_eType )
2000-09-18 23:08:29 +00:00
{
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
case TOX_INDEX: pPoolId = STR_POOLCOLL_TOX_ARY; break;
case TOX_USER: pPoolId = STR_POOLCOLL_TOX_USER_ARY; break;
case TOX_CONTENT: pPoolId = STR_POOLCOLL_TOX_CNTNT_ARY; break;
case TOX_ILLUSTRATIONS: pPoolId = STR_POOLCOLL_TOX_ILLUS_ARY; break;
case TOX_OBJECTS : pPoolId = STR_POOLCOLL_TOX_OBJECT_ARY; break;
case TOX_TABLES : pPoolId = STR_POOLCOLL_TOX_TABLES_ARY; break;
case TOX_AUTHORITIES : pPoolId = STR_POOLCOLL_TOX_AUTHORITIES_ARY; break;
case TOX_CITATION : pPoolId = STR_POOLCOLL_TOX_CITATION_ARY; break;
2000-09-18 23:08:29 +00:00
default:
OSL_ENSURE( false, "invalid TOXTyp");
2000-09-18 23:08:29 +00:00
return ;
}
SwFormTokens aTokens;
if (TOX_CONTENT == m_eType || TOX_ILLUSTRATIONS == m_eType )
2000-09-18 23:08:29 +00:00
{
SwFormToken aLinkStt (TOKEN_LINK_START);
aLinkStt.sCharStyleName = SwResId(STR_POOLCHR_TOXJUMP);
aTokens.push_back(aLinkStt);
}
if (TOX_CONTENT == m_eType)
{
aTokens.emplace_back(TOKEN_ENTRY_NO);
aTokens.emplace_back(TOKEN_ENTRY_TEXT);
}
else
aTokens.emplace_back(TOKEN_ENTRY);
if (TOX_AUTHORITIES != m_eType)
{
SwFormToken aToken(TOKEN_TAB_STOP);
aToken.nTabStopPosition = 0;
// #i36870# right aligned tab for all
aToken.cTabFillChar = '.';
aToken.eTabAlign = SvxTabAdjust::End;
aTokens.push_back(aToken);
aTokens.emplace_back(TOKEN_PAGE_NUMS);
2000-09-18 23:08:29 +00:00
}
if (TOX_CONTENT == m_eType || TOX_ILLUSTRATIONS == m_eType)
aTokens.emplace_back(TOKEN_LINK_END);
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
SetTemplate(0, SwResId(*pPoolId++));
2000-09-18 23:08:29 +00:00
if(TOX_INDEX == m_eType)
2000-09-18 23:08:29 +00:00
{
for( sal_uInt16 i = 1; i < 5; ++i )
2000-09-18 23:08:29 +00:00
{
if(1 == i)
{
SwFormTokens aTmpTokens;
SwFormToken aTmpToken(TOKEN_ENTRY);
aTmpTokens.push_back(aTmpToken);
SetPattern( i, aTmpTokens );
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
SetTemplate(i, SwResId(STR_POOLCOLL_TOX_IDXBREAK));
2000-09-18 23:08:29 +00:00
}
else
{
SetPattern( i, aTokens );
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
SetTemplate(i, SwResId(STR_POOLCOLL_TOX_ARY[i - 1]));
2000-09-18 23:08:29 +00:00
}
}
}
else
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
{
for (sal_uInt16 i = 1; i < GetFormMax(); ++i, ++pPoolId) // Number 0 is the title
2000-09-18 23:08:29 +00:00
{
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
if (TOX_AUTHORITIES == m_eType)
{
SwFormTokens aAuthTokens;
lcl_FillAuthPattern(aAuthTokens, i);
SetPattern(i, aAuthTokens);
}
2000-09-18 23:08:29 +00:00
else
SetPattern( i, aTokens );
2000-09-18 23:08:29 +00:00
if( TOX_CONTENT == m_eType && 6 == i )
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
pPoolId = STR_POOLCOLL_TOX_CNTNT_EXTRA_ARY;
else if( TOX_USER == m_eType && 6 == i )
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
pPoolId = STR_POOLCOLL_TOX_USER_EXTRA_ARY;
else if( TOX_AUTHORITIES == m_eType ) //reuse the same STR_POOLCOLL_TOX_AUTHORITIES1 id each time
pPoolId = STR_POOLCOLL_TOX_AUTHORITIES_ARY + 1;
SetTemplate(i, SwResId(*pPoolId));
2000-09-18 23:08:29 +00:00
}
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
}
2000-09-18 23:08:29 +00:00
}
SwForm::SwForm(const SwForm& rForm)
: m_eType( rForm.m_eType )
2000-09-18 23:08:29 +00:00
{
*this = rForm;
}
SwForm& SwForm::operator=(const SwForm& rForm)
{
m_eType = rForm.m_eType;
m_nFormMaxLevel = rForm.m_nFormMaxLevel;
2000-09-18 23:08:29 +00:00
// nFirstTabPos = rForm.nFirstTabPos;
// bHasFirstTabPos = rForm.bHasFirstTabPos;
m_bIsRelTabPos = rForm.m_bIsRelTabPos;
m_bCommaSeparated = rForm.m_bCommaSeparated;
for(sal_uInt16 i=0; i < m_nFormMaxLevel; ++i)
2000-09-18 23:08:29 +00:00
{
m_aPattern[i] = rForm.m_aPattern[i];
m_aTemplate[i] = rForm.m_aTemplate[i];
2000-09-18 23:08:29 +00:00
}
return *this;
}
sal_uInt16 SwForm::GetFormMaxLevel( TOXTypes eTOXType )
2000-09-18 23:08:29 +00:00
{
switch( eTOXType )
2000-09-18 23:08:29 +00:00
{
case TOX_INDEX:
return 5;
case TOX_USER:
case TOX_CONTENT:
return MAXLEVEL + 1;
2000-09-18 23:08:29 +00:00
case TOX_ILLUSTRATIONS:
case TOX_OBJECTS:
case TOX_TABLES:
return 2;
case TOX_BIBLIOGRAPHY:
case TOX_CITATION:
case TOX_AUTHORITIES:
return AUTH_TYPE_END + 1;
2000-09-18 23:08:29 +00:00
}
return 0;
2000-09-18 23:08:29 +00:00
}
void SwForm::AdjustTabStops( SwDoc const & rDoc ) // #i21237#
2000-09-18 23:08:29 +00:00
{
const sal_uInt16 nFormMax = GetFormMax();
for ( sal_uInt16 nLevel = 1; nLevel < nFormMax; ++nLevel )
2000-09-18 23:08:29 +00:00
{
SwTextFormatColl* pColl = rDoc.FindTextFormatCollByName( GetTemplate(nLevel) );
if( pColl == nullptr )
2000-09-18 23:08:29 +00:00
{
// Paragraph Style for this level has not been created.
// --> No need to propagate default values
continue;
2000-09-18 23:08:29 +00:00
}
const SvxTabStopItem& rTabStops = pColl->GetTabStops(false);
const sal_uInt16 nTabCount = rTabStops.Count();
if (nTabCount != 0)
2000-09-18 23:08:29 +00:00
{
SwFormTokens aCurrentPattern = GetPattern(nLevel);
SwFormTokens::iterator aIt = aCurrentPattern.begin();
bool bChanged = false;
for(sal_uInt16 nTab = 0; nTab < nTabCount; ++nTab)
2000-09-18 23:08:29 +00:00
{
const SvxTabStop& rTab = rTabStops[nTab];
if ( rTab.GetAdjustment() == SvxTabAdjust::Default )
continue; // ignore the default tab stop
aIt = find_if( aIt, aCurrentPattern.end(), SwFormTokenEqualToFormTokenType(TOKEN_TAB_STOP) );
if ( aIt != aCurrentPattern.end() )
{
bChanged = true;
aIt->nTabStopPosition = rTab.GetTabPos();
aIt->eTabAlign =
( nTab == nTabCount - 1
&& rTab.GetAdjustment() == SvxTabAdjust::Right )
? SvxTabAdjust::End
: rTab.GetAdjustment();
aIt->cTabFillChar = rTab.GetFill();
++aIt;
}
else
break; // no more tokens to replace
2000-09-18 23:08:29 +00:00
}
if ( bChanged )
SetPattern( nLevel, aCurrentPattern );
2000-09-18 23:08:29 +00:00
}
}
}
OUString SwForm::GetFormEntry() {return OUString("<E>");}
OUString SwForm::GetFormTab() {return OUString("<T>");}
OUString SwForm::GetFormPageNums() {return OUString("<#>");}
OUString SwForm::GetFormLinkStt() {return OUString("<LS>");}
OUString SwForm::GetFormLinkEnd() {return OUString("<LE>");}
OUString SwForm::GetFormEntryNum() {return OUString("<E#>");}
OUString SwForm::GetFormEntryText() {return OUString("<ET>");}
OUString SwForm::GetFormChapterMark() {return OUString("<C>");}
OUString SwForm::GetFormText() {return OUString("<X>");}
OUString SwForm::GetFormAuth() {return OUString("<A>");}
2000-09-18 23:08:29 +00:00
SwTOXBase::SwTOXBase(const SwTOXType* pTyp, const SwForm& rForm,
SwTOXElement nCreaType, const OUString& rTitle )
: SwClient(const_cast<SwModify*>(static_cast<SwModify const *>(pTyp)))
, m_aForm(rForm)
, m_aTitle(rTitle)
, m_eLanguage(::GetAppLanguage())
, m_nCreateType(nCreaType)
, m_nOLEOptions(SwTOOElements::NONE)
, m_eCaptionDisplay(CAPTION_COMPLETE)
, m_bProtected( true )
, m_bFromChapter(false)
, m_bFromObjectNames(false)
, m_bLevelFromChapter(false)
, maMSTOCExpression()
, mbKeepExpression(true)
2000-09-18 23:08:29 +00:00
{
m_aData.nOptions = SwTOIOptions::NONE;
2000-09-18 23:08:29 +00:00
}
SwTOXBase::SwTOXBase( const SwTOXBase& rSource, SwDoc* pDoc )
: SwClient( rSource.GetRegisteredInNonConst() )
, mbKeepExpression(true)
2000-09-18 23:08:29 +00:00
{
CopyTOXBase( pDoc, rSource );
}
void SwTOXBase::RegisterToTOXType( SwTOXType& rType )
{
rType.Add( this );
}
void SwTOXBase::CopyTOXBase( SwDoc* pDoc, const SwTOXBase& rSource )
2000-09-18 23:08:29 +00:00
{
maMSTOCExpression = rSource.maMSTOCExpression;
SwTOXType* pType = const_cast<SwTOXType*>(rSource.GetTOXType());
if( pDoc && !pDoc->GetTOXTypes().IsAlive(pType))
2000-09-18 23:08:29 +00:00
{
// type not in pDoc, so create it now
const SwTOXTypes& rTypes = pDoc->GetTOXTypes();
bool bFound = false;
for( size_t n = rTypes.size(); n; )
2000-09-18 23:08:29 +00:00
{
const SwTOXType* pCmp = rTypes[ --n ];
if( pCmp->GetType() == pType->GetType() &&
pCmp->GetTypeName() == pType->GetTypeName() )
{
pType = const_cast<SwTOXType*>(pCmp);
bFound = true;
2000-09-18 23:08:29 +00:00
break;
}
}
if( !bFound )
pType = const_cast<SwTOXType*>(pDoc->InsertTOXType( *pType ));
2000-09-18 23:08:29 +00:00
}
pType->Add( this );
m_nCreateType = rSource.m_nCreateType;
m_aTitle = rSource.m_aTitle;
m_aForm = rSource.m_aForm;
m_aBookmarkName = rSource.m_aBookmarkName;
m_aEntryTypeName = rSource.m_aEntryTypeName ;
m_bProtected = rSource.m_bProtected;
m_bFromChapter = rSource.m_bFromChapter;
m_bFromObjectNames = rSource.m_bFromObjectNames;
m_sMainEntryCharStyle = rSource.m_sMainEntryCharStyle;
m_sSequenceName = rSource.m_sSequenceName;
m_eCaptionDisplay = rSource.m_eCaptionDisplay;
m_nOLEOptions = rSource.m_nOLEOptions;
m_eLanguage = rSource.m_eLanguage;
m_sSortAlgorithm = rSource.m_sSortAlgorithm;
m_bLevelFromChapter = rSource.m_bLevelFromChapter;
2000-09-18 23:08:29 +00:00
for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
m_aStyleNames[i] = rSource.m_aStyleNames[i];
2000-09-18 23:08:29 +00:00
// it's the same data type!
m_aData.nOptions = rSource.m_aData.nOptions;
2000-09-18 23:08:29 +00:00
if( !pDoc || pDoc->IsCopyIsMove() )
m_aName = rSource.GetTOXName();
2000-09-18 23:08:29 +00:00
else
m_aName = pDoc->GetUniqueTOXBaseName( *pType, rSource.GetTOXName() );
2000-09-18 23:08:29 +00:00
}
// TOX specific functions
2000-09-18 23:08:29 +00:00
SwTOXBase::~SwTOXBase()
{
// if( GetTOXType()->GetType() == TOX_USER )
// delete aData.pTemplateName;
}
void SwTOXBase::SetTitle(const OUString& rTitle)
{ m_aTitle = rTitle; }
void SwTOXBase::SetBookmarkName(const OUString& bName)
{
m_aBookmarkName = bName;
}
void SwTOXBase::SetEntryTypeName(const OUString& sName)
{
m_aEntryTypeName = sName ;
}
SwTOXBase & SwTOXBase::operator = (const SwTOXBase & rSource)
{
m_aForm = rSource.m_aForm;
m_aName = rSource.m_aName;
m_aTitle = rSource.m_aTitle;
m_aBookmarkName = rSource.m_aBookmarkName;
m_aEntryTypeName = rSource.m_aEntryTypeName ;
m_sMainEntryCharStyle = rSource.m_sMainEntryCharStyle;
for(sal_uInt16 nLevel = 0; nLevel < MAXLEVEL; nLevel++)
m_aStyleNames[nLevel] = rSource.m_aStyleNames[nLevel];
m_sSequenceName = rSource.m_sSequenceName;
m_eLanguage = rSource.m_eLanguage;
m_sSortAlgorithm = rSource.m_sSortAlgorithm;
m_aData = rSource.m_aData;
m_nCreateType = rSource.m_nCreateType;
m_nOLEOptions = rSource.m_nOLEOptions;
m_eCaptionDisplay = rSource.m_eCaptionDisplay;
m_bProtected = rSource.m_bProtected;
m_bFromChapter = rSource.m_bFromChapter;
m_bFromObjectNames = rSource.m_bFromObjectNames;
m_bLevelFromChapter = rSource.m_bLevelFromChapter;
if (rSource.GetAttrSet())
SetAttrSet(*rSource.GetAttrSet());
return *this;
}
OUString SwFormToken::GetString() const
2000-09-18 23:08:29 +00:00
{
OUString sToken;
2000-09-18 23:08:29 +00:00
switch( eTokenType )
2000-09-18 23:08:29 +00:00
{
case TOKEN_ENTRY_NO:
sToken = SwForm::GetFormEntryNum();
break;
case TOKEN_ENTRY_TEXT:
sToken = SwForm::GetFormEntryText();
break;
case TOKEN_ENTRY:
sToken = SwForm::GetFormEntry();
break;
case TOKEN_TAB_STOP:
sToken = SwForm::GetFormTab();
break;
case TOKEN_TEXT:
// Return a Token only if Text is not empty!
if( sText.isEmpty() )
{
return OUString();
}
sToken = SwForm::GetFormText();
break;
case TOKEN_PAGE_NUMS:
sToken = SwForm::GetFormPageNums();
break;
case TOKEN_CHAPTER_INFO:
sToken = SwForm::GetFormChapterMark();
break;
case TOKEN_LINK_START:
sToken = SwForm::GetFormLinkStt();
break;
case TOKEN_LINK_END:
sToken = SwForm::GetFormLinkEnd();
break;
case TOKEN_AUTHORITY:
{
sToken = SwForm::GetFormAuth();
}
break;
case TOKEN_END:
break;
2000-09-18 23:08:29 +00:00
}
OUString sData = " " + sCharStyleName + "," + OUString::number( nPoolId ) + ",";
// TabStopPosition and TabAlign or ChapterInfoFormat
switch (eTokenType)
{
case TOKEN_TAB_STOP:
sData += OUString::number( nTabStopPosition ) + ","
+ OUString::number( static_cast< sal_Int32 >(eTabAlign) ) + ","
+ OUStringLiteral1(cTabFillChar) + ","
+ OUString::number( bWithTab ? 1 : 0 );
break;
case TOKEN_CHAPTER_INFO:
case TOKEN_ENTRY_NO:
// add also maximum permitted level
sData += OUString::number( nChapterFormat ) + ","
+ OUString::number( nOutlineLevel );
break;
case TOKEN_TEXT:
sData += OUStringLiteral1(TOX_STYLE_DELIMITER)
+ sText.replaceAll(OUStringLiteral1(TOX_STYLE_DELIMITER), "")
+ OUStringLiteral1(TOX_STYLE_DELIMITER);
break;
case TOKEN_AUTHORITY:
if (nAuthorityField<10)
{
sData = "0" + OUString::number( nAuthorityField ) + sData;
}
else
{
sData = OUString::number( nAuthorityField ) + sData;
}
break;
default:
break;
}
2000-09-18 23:08:29 +00:00
return sToken.copy(0, sToken.getLength()-1) + sData + sToken.copy(sToken.getLength()-1);
2000-09-18 23:08:29 +00:00
}
// -> #i21237#
/**
Returns the type of a token.
@param sToken the string representation of the token
@param pTokenLen return parameter the length of the head of the token
If pTokenLen is non-NULL the length of the token's head is
written to *pTokenLen
@return the type of the token
*/
static FormTokenType lcl_GetTokenType(const OUString & sToken,
sal_Int32 *const pTokenLen)
2000-09-18 23:08:29 +00:00
{
static struct
{
OUString sNm;
sal_uInt16 nOffset;
FormTokenType eToken;
} const aTokenArr[] = {
{ SwForm::GetFormTab(), 1, TOKEN_TAB_STOP },
{ SwForm::GetFormPageNums(), 1, TOKEN_PAGE_NUMS },
{ SwForm::GetFormLinkStt(), 1, TOKEN_LINK_START },
{ SwForm::GetFormLinkEnd(), 1, TOKEN_LINK_END },
{ SwForm::GetFormEntryNum(), 1, TOKEN_ENTRY_NO },
{ SwForm::GetFormEntryText(), 1, TOKEN_ENTRY_TEXT },
{ SwForm::GetFormChapterMark(), 1, TOKEN_CHAPTER_INFO },
{ SwForm::GetFormText(), 1, TOKEN_TEXT },
{ SwForm::GetFormEntry(), 1, TOKEN_ENTRY },
{ SwForm::GetFormAuth(), 3, TOKEN_AUTHORITY }
};
for(const auto & i : aTokenArr)
{
const sal_Int32 nLen(i.sNm.getLength());
if( sToken.startsWith( i.sNm.copy(0, nLen - i.nOffset) ))
{
if (pTokenLen)
*pTokenLen = nLen;
return i.eToken;
}
}
SAL_WARN("sw.core", "SwFormTokensHelper: invalid token");
return TOKEN_END;
2000-09-18 23:08:29 +00:00
}
/**
Returns the string of a token.
@param sPattern the whole pattern
@param nStt starting position of the token
@return the string representation of the token
*/
static OUString
lcl_SearchNextToken(const OUString & sPattern, sal_Int32 const nStt)
2000-09-18 23:08:29 +00:00
{
sal_Int32 nEnd = sPattern.indexOf( '>', nStt );
if (nEnd >= 0)
{
// apparently the TOX_STYLE_DELIMITER act as a bracketing for
// TOKEN_TEXT tokens so that the user can have '>' inside the text...
const sal_Int32 nTextSeparatorFirst = sPattern.indexOf( TOX_STYLE_DELIMITER, nStt );
if ( nTextSeparatorFirst >= 0
&& nTextSeparatorFirst + 1 < sPattern.getLength()
&& nTextSeparatorFirst < nEnd)
{
const sal_Int32 nTextSeparatorSecond = sPattern.indexOf( TOX_STYLE_DELIMITER,
nTextSeparatorFirst + 1 );
// Since nEnd>=0 we don't need to check if nTextSeparatorSecond<0!
if( nEnd < nTextSeparatorSecond )
nEnd = sPattern.indexOf( '>', nTextSeparatorSecond );
// FIXME: No check to verify that nEnd is still >=0?
assert(nEnd >= 0);
}
++nEnd;
return sPattern.copy( nStt, nEnd - nStt );
}
return OUString();
}
/**
Builds a token from its string representation.
@sPattern the whole pattern
@nCurPatternPos starting position of the token
@return the token
*/
static boost::optional<SwFormToken>
lcl_BuildToken(const OUString & sPattern, sal_Int32 & nCurPatternPos)
{
OUString sToken( lcl_SearchNextToken(sPattern, nCurPatternPos) );
nCurPatternPos += sToken.getLength();
sal_Int32 nTokenLen = 0;
FormTokenType const eTokenType = lcl_GetTokenType(sToken, &nTokenLen);
if (TOKEN_END == eTokenType) // invalid input? skip it
{
nCurPatternPos = sPattern.getLength();
return boost::optional<SwFormToken>();
}
2000-09-18 23:08:29 +00:00
// at this point sPattern contains the
// character style name, the PoolId, tab stop position, tab stop alignment, chapter info format
// the form is: CharStyleName, PoolId[, TabStopPosition|ChapterInfoFormat[, TabStopAlignment[, TabFillChar]]]
// in text tokens the form differs from the others: CharStyleName, PoolId[,\0xffinserted text\0xff]
SwFormToken eRet( eTokenType );
const OUString sAuthFieldEnum = sToken.copy( 2, 2 );
sToken = sToken.copy( nTokenLen, sToken.getLength() - nTokenLen - 1);
2000-09-18 23:08:29 +00:00
eRet.sCharStyleName = sToken.getToken( 0, ',');
OUString sTmp( sToken.getToken( 1, ',' ));
if( !sTmp.isEmpty() )
eRet.nPoolId = static_cast<sal_uInt16>(sTmp.toInt32());
2000-09-18 23:08:29 +00:00
switch( eTokenType )
{
//i53420
case TOKEN_CHAPTER_INFO:
//i53420
case TOKEN_ENTRY_NO:
sTmp = sToken.getToken( 2, ',' );
if( !sTmp.isEmpty() )
eRet.nChapterFormat = static_cast<sal_uInt16>(sTmp.toInt32());
sTmp = sToken.getToken( 3, ',' );
if( !sTmp.isEmpty() )
eRet.nOutlineLevel = static_cast<sal_uInt16>(sTmp.toInt32()); //the maximum outline level to examine
break;
2000-09-18 23:08:29 +00:00
case TOKEN_TEXT:
{
const sal_Int32 nStartText = sToken.indexOf( TOX_STYLE_DELIMITER );
if( nStartText>=0 && nStartText+1<sToken.getLength())
2000-09-18 23:08:29 +00:00
{
const sal_Int32 nEndText = sToken.indexOf( TOX_STYLE_DELIMITER,
nStartText + 1);
if( nEndText>=0 )
2000-09-18 23:08:29 +00:00
{
eRet.sText = sToken.copy( nStartText + 1,
2000-09-18 23:08:29 +00:00
nEndText - nStartText - 1);
}
}
}
break;
case TOKEN_TAB_STOP:
sTmp = sToken.getToken( 2, ',' );
if( !sTmp.isEmpty() )
eRet.nTabStopPosition = sTmp.toInt32();
2000-09-18 23:08:29 +00:00
sTmp = sToken.getToken( 3, ',' );
if( !sTmp.isEmpty() )
eRet.eTabAlign = static_cast<SvxTabAdjust>(sTmp.toInt32());
sTmp = sToken.getToken( 4, ',' );
if( !sTmp.isEmpty() )
eRet.cTabFillChar = sTmp[0];
sTmp = sToken.getToken( 5, ',' );
if( !sTmp.isEmpty() )
eRet.bWithTab = 0 != sTmp.toInt32();
2000-09-18 23:08:29 +00:00
break;
case TOKEN_AUTHORITY:
eRet.nAuthorityField = static_cast<sal_uInt16>(sAuthFieldEnum.toInt32());
2000-09-18 23:08:29 +00:00
break;
default: break;
2000-09-18 23:08:29 +00:00
}
return eRet;
}
SwFormTokensHelper::SwFormTokensHelper(const OUString & rPattern)
{
sal_Int32 nCurPatternPos = 0;
2000-09-18 23:08:29 +00:00
while (nCurPatternPos < rPattern.getLength())
{
boost::optional<SwFormToken> const oToken(
lcl_BuildToken(rPattern, nCurPatternPos));
if (oToken)
m_Tokens.push_back(oToken.get());
}
2000-09-18 23:08:29 +00:00
}
// <- #i21237#
void SwForm::SetPattern(sal_uInt16 nLevel, const SwFormTokens& rTokens)
{
OSL_ENSURE(nLevel < GetFormMax(), "Index >= FORM_MAX");
m_aPattern[nLevel] = rTokens;
}
void SwForm::SetPattern(sal_uInt16 nLevel, const OUString & rStr)
{
OSL_ENSURE(nLevel < GetFormMax(), "Index >= FORM_MAX");
SwFormTokensHelper aHelper(rStr);
m_aPattern[nLevel] = aHelper.GetTokens();
}
const SwFormTokens& SwForm::GetPattern(sal_uInt16 nLevel) const
{
OSL_ENSURE(nLevel < GetFormMax(), "Index >= FORM_MAX");
return m_aPattern[nLevel];
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */