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 19:57:47 +00:00
|
|
|
|
2017-04-14 08:42:15 +10:00
|
|
|
#include <memory>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <hintids.hxx>
|
2013-04-05 18:40:39 +02:00
|
|
|
#include <i18nlangtag/mslangid.hxx>
|
2000-11-20 08:16:31 +00:00
|
|
|
#include <unotools/localedatawrapper.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/paperinf.hxx>
|
|
|
|
#include <editeng/wghtitem.hxx>
|
|
|
|
#include <editeng/fontitem.hxx>
|
|
|
|
#include <editeng/fhgtitem.hxx>
|
|
|
|
#include <editeng/tstpitem.hxx>
|
|
|
|
#include <editeng/lrspitem.hxx>
|
|
|
|
#include <editeng/ulspitem.hxx>
|
2013-11-17 23:10:13 +03:00
|
|
|
#include <editeng/lspcitem.hxx>
|
2013-02-12 13:41:53 -05:00
|
|
|
#include <editeng/adjustitem.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/postitem.hxx>
|
|
|
|
#include <editeng/keepitem.hxx>
|
|
|
|
#include <editeng/opaqitem.hxx>
|
|
|
|
#include <editeng/boxitem.hxx>
|
|
|
|
#include <editeng/cmapitem.hxx>
|
|
|
|
#include <editeng/udlnitem.hxx>
|
|
|
|
#include <editeng/colritem.hxx>
|
|
|
|
#include <editeng/protitem.hxx>
|
2013-02-12 13:41:53 -05:00
|
|
|
#include <editeng/escapementitem.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/langitem.hxx>
|
|
|
|
#include <editeng/charrotateitem.hxx>
|
|
|
|
#include <editeng/frmdiritem.hxx>
|
2013-02-12 13:41:53 -05:00
|
|
|
#include <editeng/emphasismarkitem.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/scriptspaceitem.hxx>
|
2002-04-25 13:00:16 +00:00
|
|
|
#include <viewopt.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <doc.hxx>
|
2010-11-25 14:31:08 +01:00
|
|
|
#include <IDocumentUndoRedo.hxx>
|
2014-05-25 14:10:13 +02:00
|
|
|
#include <DocumentSettingManager.hxx>
|
2014-08-01 17:09:54 +02:00
|
|
|
#include <IDocumentState.hxx>
|
2014-08-08 19:16:38 +02:00
|
|
|
#include <IDocumentStylePoolAccess.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <fmtanchr.hxx>
|
|
|
|
#include <fmtornt.hxx>
|
|
|
|
#include <fmtsrnd.hxx>
|
|
|
|
#include <fmtfsize.hxx>
|
|
|
|
#include <poolfmt.hxx>
|
|
|
|
#include <paratr.hxx>
|
|
|
|
#include <pagedesc.hxx>
|
|
|
|
#include <frmtool.hxx>
|
|
|
|
#include <charfmt.hxx>
|
|
|
|
#include <docary.hxx>
|
|
|
|
#include <fmtcol.hxx>
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
#include <fmtline.hxx>
|
2017-06-11 20:56:30 +01:00
|
|
|
#include <strings.hrc>
|
2001-10-24 16:21:04 +00:00
|
|
|
#include <GetMetricVal.hxx>
|
2008-03-05 15:55:27 +00:00
|
|
|
#include <numrule.hxx>
|
2016-07-28 15:33:17 +02:00
|
|
|
#include <swtable.hxx>
|
|
|
|
#include <tblafmt.hxx>
|
2014-03-19 16:17:02 +00:00
|
|
|
#include <svx/xdef.hxx>
|
2014-06-02 15:00:50 +00:00
|
|
|
#include <svx/xfillit0.hxx>
|
|
|
|
|
2011-03-25 15:51:54 +01:00
|
|
|
using namespace ::editeng;
|
2007-09-27 07:39:13 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2002-02-22 11:00:10 +00:00
|
|
|
void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem )
|
2001-06-01 09:44:11 +00:00
|
|
|
{
|
|
|
|
rSet.Put( rItem );
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nWhCJK = 0, nWhCTL = 0;
|
2001-06-01 09:44:11 +00:00
|
|
|
switch( rItem.Which() )
|
|
|
|
{
|
|
|
|
case RES_CHRATR_FONTSIZE:
|
2016-02-22 16:04:08 +02:00
|
|
|
nWhCJK = RES_CHRATR_CJK_FONTSIZE;
|
|
|
|
nWhCTL = RES_CHRATR_CTL_FONTSIZE;
|
2001-06-01 09:44:11 +00:00
|
|
|
break;
|
|
|
|
case RES_CHRATR_FONT:
|
2016-02-22 16:04:08 +02:00
|
|
|
nWhCJK = RES_CHRATR_CJK_FONT;
|
|
|
|
nWhCTL = RES_CHRATR_CTL_FONT;
|
2001-06-01 09:44:11 +00:00
|
|
|
break;
|
|
|
|
case RES_CHRATR_LANGUAGE:
|
2016-02-22 16:04:08 +02:00
|
|
|
nWhCJK = RES_CHRATR_CJK_LANGUAGE;
|
|
|
|
nWhCTL = RES_CHRATR_CTL_LANGUAGE;
|
2001-06-01 09:44:11 +00:00
|
|
|
break;
|
|
|
|
case RES_CHRATR_POSTURE:
|
2016-02-22 16:04:08 +02:00
|
|
|
nWhCJK = RES_CHRATR_CJK_POSTURE;
|
|
|
|
nWhCTL = RES_CHRATR_CTL_POSTURE;
|
2001-06-01 09:44:11 +00:00
|
|
|
break;
|
|
|
|
case RES_CHRATR_WEIGHT:
|
2016-02-22 16:04:08 +02:00
|
|
|
nWhCJK = RES_CHRATR_CJK_WEIGHT;
|
|
|
|
nWhCTL = RES_CHRATR_CTL_WEIGHT;
|
2001-06-01 09:44:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nWhCJK )
|
2016-04-23 20:23:29 +02:00
|
|
|
{
|
|
|
|
std::unique_ptr<SfxPoolItem> pNewItem(rItem.CloneSetWhich(nWhCJK));
|
|
|
|
rSet.Put( *pNewItem );
|
|
|
|
}
|
2001-06-01 09:44:11 +00:00
|
|
|
if( nWhCTL )
|
2016-04-23 20:23:29 +02:00
|
|
|
{
|
|
|
|
std::unique_ptr<SfxPoolItem> pNewItem(rItem.CloneSetWhich(nWhCTL));
|
|
|
|
rSet.Put( *pNewItem );
|
|
|
|
}
|
2001-06-01 09:44:11 +00:00
|
|
|
}
|
|
|
|
|
2016-01-09 22:55:28 +01:00
|
|
|
/// Return the AutoCollection by its Id. If it doesn't
|
2013-04-07 21:11:09 +02:00
|
|
|
/// exist yet, create it.
|
|
|
|
/// If the String pointer is defined, then only query for
|
|
|
|
/// the Attribute descriptions. It doesn't create a style!
|
2017-04-17 21:35:35 +02:00
|
|
|
SvxFrameDirection GetDefaultFrameDirection(LanguageType nLanguage)
|
2002-12-04 13:38:05 +00:00
|
|
|
{
|
2017-04-17 21:35:35 +02:00
|
|
|
return MsLangId::isRightToLeft(nLanguage) ?
|
|
|
|
SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB;
|
2002-12-04 13:38:05 +00:00
|
|
|
}
|
|
|
|
|
2012-10-13 22:20:33 +02:00
|
|
|
// See if the Paragraph/Character/Frame/Page style is in use
|
2012-11-15 00:01:03 +09:00
|
|
|
bool SwDoc::IsUsed( const SwModify& rModify ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-01-11 16:07:29 +01:00
|
|
|
// Check if we have dependent ContentNodes in the Nodes array
|
|
|
|
// (also indirect ones for derived Formats)
|
2015-05-20 13:05:49 +02:00
|
|
|
SwAutoFormatGetDocNode aGetHt( &GetNodes() );
|
2000-09-18 23:08:29 +00:00
|
|
|
return !rModify.GetInfo( aGetHt );
|
|
|
|
}
|
|
|
|
|
2016-07-28 15:33:17 +02:00
|
|
|
// See if Table style is in use
|
|
|
|
bool SwDoc::IsUsed( const SwTableAutoFormat& rTableAutoFormat) const
|
|
|
|
{
|
|
|
|
size_t nTableCount = GetTableFrameFormatCount(true);
|
|
|
|
for (size_t i=0; i < nTableCount; ++i)
|
|
|
|
{
|
|
|
|
SwFrameFormat* pFrameFormat = &GetTableFrameFormat(i, true);
|
|
|
|
SwTable* pTable = SwTable::FindTable(pFrameFormat);
|
|
|
|
if (pTable->GetTableStyleName() == rTableAutoFormat.GetName())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-11 16:07:29 +01:00
|
|
|
// See if the NumRule is used
|
2015-05-04 10:29:18 +02:00
|
|
|
bool SwDoc::IsUsed( const SwNumRule& rRule )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
bool bUsed = rRule.GetTextNodeListSize() > 0 ||
|
2008-06-13 08:38:37 +00:00
|
|
|
rRule.GetParagraphStyleListSize() > 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
return bUsed;
|
|
|
|
}
|
|
|
|
|
2015-07-10 18:44:56 +02:00
|
|
|
const OUString* SwDoc::GetDocPattern(size_t const nPos) const
|
|
|
|
{
|
|
|
|
if (nPos >= m_PatternNames.size())
|
|
|
|
return nullptr;
|
|
|
|
return &m_PatternNames[nPos];
|
|
|
|
}
|
|
|
|
|
2012-10-13 22:20:33 +02:00
|
|
|
// Look for the style name's position. If it doesn't exist,
|
2012-01-11 16:07:29 +01:00
|
|
|
// insert a anew
|
2015-07-10 18:44:56 +02:00
|
|
|
size_t SwDoc::SetDocPattern(const OUString& rPatternName)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-10-11 14:39:49 +02:00
|
|
|
OSL_ENSURE( !rPatternName.isEmpty(), "no Document style name" );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-07-10 18:44:56 +02:00
|
|
|
auto const iter(
|
|
|
|
std::find(m_PatternNames.begin(), m_PatternNames.end(), rPatternName));
|
|
|
|
if (iter != m_PatternNames.end())
|
|
|
|
{
|
|
|
|
return std::distance(m_PatternNames.begin(), iter);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_PatternNames.push_back(rPatternName);
|
|
|
|
getIDocumentState().SetModified();
|
|
|
|
return m_PatternNames.size() - 1;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 GetPoolParent( sal_uInt16 nId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nRet = USHRT_MAX;
|
2012-01-11 16:07:29 +01:00
|
|
|
if( POOLGRP_NOCOLLID & nId ) // 1 == Formats / 0 == Collections
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
switch( ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID ) & nId )
|
|
|
|
{
|
|
|
|
case POOLGRP_CHARFMT:
|
|
|
|
case POOLGRP_FRAMEFMT:
|
2012-01-11 16:07:29 +01:00
|
|
|
nRet = 0; // derived from the default
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
|
|
|
case POOLGRP_PAGEDESC:
|
|
|
|
case POOLGRP_NUMRULE:
|
2012-01-11 16:07:29 +01:00
|
|
|
break; // there are no derivations
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( COLL_GET_RANGE_BITS & nId )
|
|
|
|
{
|
|
|
|
case COLL_TEXT_BITS:
|
|
|
|
switch( nId )
|
|
|
|
{
|
|
|
|
case RES_POOLCOLL_STANDARD:
|
|
|
|
nRet = 0; break;
|
|
|
|
case RES_POOLCOLL_TEXT_IDENT:
|
|
|
|
case RES_POOLCOLL_TEXT_NEGIDENT:
|
|
|
|
case RES_POOLCOLL_TEXT_MOVE:
|
|
|
|
case RES_POOLCOLL_CONFRONTATION:
|
|
|
|
case RES_POOLCOLL_MARGINAL:
|
|
|
|
nRet = RES_POOLCOLL_TEXT; break;
|
|
|
|
|
|
|
|
case RES_POOLCOLL_TEXT:
|
|
|
|
case RES_POOLCOLL_GREETING:
|
|
|
|
case RES_POOLCOLL_SIGNATURE:
|
|
|
|
case RES_POOLCOLL_HEADLINE_BASE:
|
|
|
|
nRet = RES_POOLCOLL_STANDARD; break;
|
|
|
|
|
|
|
|
case RES_POOLCOLL_HEADLINE1:
|
|
|
|
case RES_POOLCOLL_HEADLINE2:
|
|
|
|
case RES_POOLCOLL_HEADLINE3:
|
|
|
|
case RES_POOLCOLL_HEADLINE4:
|
|
|
|
case RES_POOLCOLL_HEADLINE5:
|
|
|
|
case RES_POOLCOLL_HEADLINE6:
|
|
|
|
case RES_POOLCOLL_HEADLINE7:
|
|
|
|
case RES_POOLCOLL_HEADLINE8:
|
|
|
|
case RES_POOLCOLL_HEADLINE9:
|
|
|
|
case RES_POOLCOLL_HEADLINE10:
|
|
|
|
nRet = RES_POOLCOLL_HEADLINE_BASE; break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLL_LISTS_BITS:
|
|
|
|
switch( nId )
|
|
|
|
{
|
|
|
|
case RES_POOLCOLL_NUMBUL_BASE:
|
|
|
|
nRet = RES_POOLCOLL_TEXT; break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
nRet = RES_POOLCOLL_NUMBUL_BASE; break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLL_EXTRA_BITS:
|
|
|
|
switch( nId )
|
|
|
|
{
|
|
|
|
case RES_POOLCOLL_TABLE_HDLN:
|
|
|
|
nRet = RES_POOLCOLL_TABLE; break;
|
|
|
|
|
make parent style for 'frame contents' be 'standard' rather than 'text'
The actual reason for this change is a .docx document, which has a textframe
and a modified 'text' style. The textframe in MSO has 'normal' style
(which is like our 'standard') and so the style is not written to the docx.
LO however uses 'frame contents' for the textframe, and since it was
based on 'text', it used the modified style, unlike in MSO.
But even on its own, this change seems to make sense. It's similar
to 4014d40c96b9d70796a154f0ac48cf5b685cf187, and I see no particular
reason why contents of textframes should be the same style like the main
text of the document, while footnotes, footers, headers, tables, etc.
are different.
Change-Id: Ibe7bfd6a2820cff5cf29c669fd60b575c63500b0
Reviewed-on: https://gerrit.libreoffice.org/3697
Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Tested-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
2013-04-30 16:22:48 +02:00
|
|
|
case RES_POOLCOLL_FRAME:
|
2004-11-15 13:46:05 +00:00
|
|
|
case RES_POOLCOLL_TABLE:
|
2000-09-18 23:08:29 +00:00
|
|
|
case RES_POOLCOLL_FOOTNOTE:
|
|
|
|
case RES_POOLCOLL_ENDNOTE:
|
|
|
|
case RES_POOLCOLL_JAKETADRESS:
|
|
|
|
case RES_POOLCOLL_SENDADRESS:
|
|
|
|
case RES_POOLCOLL_HEADER:
|
|
|
|
case RES_POOLCOLL_HEADERL:
|
|
|
|
case RES_POOLCOLL_HEADERR:
|
|
|
|
case RES_POOLCOLL_FOOTER:
|
|
|
|
case RES_POOLCOLL_FOOTERL:
|
|
|
|
case RES_POOLCOLL_FOOTERR:
|
|
|
|
case RES_POOLCOLL_LABEL:
|
|
|
|
nRet = RES_POOLCOLL_STANDARD; break;
|
|
|
|
|
|
|
|
case RES_POOLCOLL_LABEL_ABB:
|
|
|
|
case RES_POOLCOLL_LABEL_TABLE:
|
|
|
|
case RES_POOLCOLL_LABEL_FRAME:
|
|
|
|
case RES_POOLCOLL_LABEL_DRAWING:
|
|
|
|
nRet = RES_POOLCOLL_LABEL; break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLL_REGISTER_BITS:
|
|
|
|
switch( nId )
|
|
|
|
{
|
|
|
|
case RES_POOLCOLL_REGISTER_BASE:
|
|
|
|
nRet = RES_POOLCOLL_STANDARD; break;
|
|
|
|
|
|
|
|
case RES_POOLCOLL_TOX_USERH:
|
|
|
|
case RES_POOLCOLL_TOX_CNTNTH:
|
|
|
|
case RES_POOLCOLL_TOX_IDXH:
|
|
|
|
case RES_POOLCOLL_TOX_ILLUSH:
|
|
|
|
case RES_POOLCOLL_TOX_OBJECTH:
|
|
|
|
case RES_POOLCOLL_TOX_TABLESH:
|
|
|
|
case RES_POOLCOLL_TOX_AUTHORITIESH:
|
|
|
|
nRet = RES_POOLCOLL_HEADLINE_BASE; break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
nRet = RES_POOLCOLL_REGISTER_BASE; break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLL_DOC_BITS:
|
|
|
|
nRet = RES_POOLCOLL_HEADLINE_BASE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLL_HTML_BITS:
|
|
|
|
nRet = RES_POOLCOLL_STANDARD;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nRet;
|
|
|
|
}
|
2003-06-10 12:17:42 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
void SwDoc::RemoveAllFormatLanguageDependencies()
|
2003-06-10 12:17:42 +00:00
|
|
|
{
|
2011-02-07 20:21:18 +01:00
|
|
|
/* Restore the language independ pool defaults and styles. */
|
2003-06-10 12:17:42 +00:00
|
|
|
GetAttrPool().ResetPoolDefaultItem( RES_PARATR_ADJUST );
|
2003-09-04 10:46:25 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
SwTextFormatColl * pTextFormatColl = getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD );
|
2003-09-04 10:46:25 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
pTextFormatColl->ResetFormatAttr( RES_PARATR_ADJUST );
|
2011-02-07 20:21:18 +01:00
|
|
|
/* koreans do not like SvxScriptItem(TRUE) */
|
2015-05-20 13:05:49 +02:00
|
|
|
pTextFormatColl->ResetFormatAttr( RES_PARATR_SCRIPTSPACE );
|
2003-06-10 12:17:42 +00:00
|
|
|
|
2017-03-14 08:39:55 +02:00
|
|
|
SvxFrameDirectionItem aFrameDir( SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR );
|
2003-06-10 12:17:42 +00:00
|
|
|
|
2015-05-13 09:54:50 +02:00
|
|
|
size_t nCount = GetPageDescCnt();
|
|
|
|
for( size_t i=0; i<nCount; ++i )
|
2003-06-10 12:17:42 +00:00
|
|
|
{
|
2012-06-21 13:40:06 +02:00
|
|
|
SwPageDesc& rDesc = GetPageDesc( i );
|
2015-05-20 13:05:49 +02:00
|
|
|
rDesc.GetMaster().SetFormatAttr( aFrameDir );
|
|
|
|
rDesc.GetLeft().SetFormatAttr( aFrameDir );
|
2003-06-10 12:17:42 +00:00
|
|
|
}
|
2004-02-02 17:17:20 +00:00
|
|
|
|
2006-12-19 12:01:38 +00:00
|
|
|
//#i16874# AutoKerning as default for new documents
|
|
|
|
GetAttrPool().ResetPoolDefaultItem( RES_CHRATR_AUTOKERN );
|
2003-06-10 12:17:42 +00:00
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|