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 .
|
|
|
|
*/
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2008-02-19 12:42:36 +00:00
|
|
|
#include <textapi.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#include <hintids.hxx>
|
2008-02-19 12:42:36 +00:00
|
|
|
#include <com/sun/star/text/XText.hpp>
|
2012-08-21 08:07:58 +02:00
|
|
|
#include <com/sun/star/script/Converter.hpp>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <com/sun/star/text/SetVariableType.hpp>
|
|
|
|
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
|
|
|
|
#include <com/sun/star/text/UserDataPart.hpp>
|
|
|
|
#include <com/sun/star/text/ChapterFormat.hpp>
|
|
|
|
#include <com/sun/star/text/XTextField.hpp>
|
|
|
|
#include <com/sun/star/text/PlaceholderType.hpp>
|
|
|
|
#include <com/sun/star/text/TemplateDisplayFormat.hpp>
|
|
|
|
#include <com/sun/star/text/UserFieldFormat.hpp>
|
|
|
|
#include <com/sun/star/text/PageNumberType.hpp>
|
|
|
|
#include <com/sun/star/text/ReferenceFieldPart.hpp>
|
|
|
|
#include <com/sun/star/text/FilenameDisplayFormat.hpp>
|
|
|
|
#include <com/sun/star/text/XDependentTextField.hpp>
|
|
|
|
#include <com/sun/star/text/DocumentStatistic.hpp>
|
2008-02-26 13:10:15 +00:00
|
|
|
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
|
|
|
#include <com/sun/star/document/XDocumentProperties.hpp>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <com/sun/star/util/Date.hpp>
|
2009-11-26 12:52:39 +01:00
|
|
|
#include <com/sun/star/util/Duration.hpp>
|
2001-02-14 08:58:47 +00:00
|
|
|
#include <unotools/localedatawrapper.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/unolingu.hxx>
|
2001-02-14 08:58:47 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2001-04-23 12:13:11 +00:00
|
|
|
#include <comphelper/types.hxx>
|
2008-02-26 13:10:15 +00:00
|
|
|
#include <comphelper/string.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <tools/urlobj.hxx>
|
2000-10-06 12:11:18 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2009-12-17 12:17:52 +01:00
|
|
|
#include <svl/urihelper.hxx>
|
|
|
|
#include <unotools/useroptions.hxx>
|
|
|
|
#include <unotools/syslocale.hxx>
|
|
|
|
#include <svl/zforlist.hxx>
|
2001-10-24 17:56:14 +00:00
|
|
|
|
2008-02-26 13:10:15 +00:00
|
|
|
#include <tools/time.hxx>
|
|
|
|
#include <tools/datetime.hxx>
|
2007-07-17 12:07:24 +00:00
|
|
|
|
2008-04-03 15:51:46 +00:00
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
2009-10-08 16:15:40 +02:00
|
|
|
#include <com/sun/star/util/DateTime.hpp>
|
|
|
|
#include <com/sun/star/util/Time.hpp>
|
2008-04-03 15:51:46 +00:00
|
|
|
|
2004-04-29 15:54:32 +00:00
|
|
|
#include <tools/shl.hxx>
|
|
|
|
#include <swmodule.hxx>
|
2000-10-06 12:11:18 +00:00
|
|
|
#include <sfx2/app.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#include <sfx2/doctempl.hxx>
|
|
|
|
#include <fmtfld.hxx>
|
|
|
|
#include <txtfld.hxx>
|
|
|
|
#include <charfmt.hxx>
|
|
|
|
#include <docstat.hxx>
|
|
|
|
#include <pagedesc.hxx>
|
|
|
|
#include <fmtpdsc.hxx>
|
|
|
|
#include <doc.hxx>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <rootfrm.hxx>
|
|
|
|
#include <pagefrm.hxx>
|
|
|
|
#include <cntfrm.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <pam.hxx>
|
|
|
|
#include <viewsh.hxx>
|
|
|
|
#include <dbmgr.hxx>
|
|
|
|
#include <shellres.hxx>
|
|
|
|
#include <docufld.hxx>
|
|
|
|
#include <flddat.hxx>
|
|
|
|
#include <docfld.hxx>
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
#include <expfld.hxx>
|
|
|
|
#include <poolfmt.hxx>
|
|
|
|
#include <docsh.hxx>
|
2001-10-24 17:56:14 +00:00
|
|
|
#include <unofldmid.h>
|
2001-10-18 11:27:55 +00:00
|
|
|
#include <swunohelper.hxx>
|
2004-09-08 13:55:20 +00:00
|
|
|
#include <comcore.hrc>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/outliner.hxx>
|
|
|
|
#include <editeng/outlobj.hxx>
|
2010-12-17 09:02:23 +01:00
|
|
|
#include <switerator.hxx>
|
2013-03-27 16:08:37 +01:00
|
|
|
#include <docary.hxx>
|
2008-02-19 12:42:36 +00:00
|
|
|
|
2000-10-20 12:46:39 +00:00
|
|
|
#define URL_DECODE INetURLObject::DECODE_UNAMBIGUOUS
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
2001-04-23 12:13:11 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
2007-09-27 07:48:37 +00:00
|
|
|
using namespace nsSwDocInfoSubType;
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// SwPageNumberFieldType
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwPageNumberFieldType::SwPageNumberFieldType()
|
|
|
|
: SwFieldType( RES_PAGENUMBERFLD ),
|
2001-02-23 11:45:30 +00:00
|
|
|
nNumberingType( SVX_NUM_ARABIC ),
|
2012-11-07 10:56:27 +09:00
|
|
|
bVirtuell( false )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwPageNumberFieldType::Expand( sal_uInt32 nFmt, short nOff,
|
2013-01-09 01:17:26 +01:00
|
|
|
sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage,
|
2013-07-14 15:21:18 +02:00
|
|
|
const OUString& rUserStr ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-02-23 11:45:30 +00:00
|
|
|
sal_uInt32 nTmpFmt = (SVX_NUM_PAGEDESC == nFmt) ? (sal_uInt32)nNumberingType : nFmt;
|
2013-01-09 01:17:26 +01:00
|
|
|
int const nTmp = nPageNumber + nOff;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-08-29 17:16:44 +03:00
|
|
|
if (0 > nTmp || SVX_NUM_NUMBER_NONE == nTmpFmt || (!bVirtuell && nTmp > nMaxPage))
|
2013-07-14 15:21:18 +02:00
|
|
|
return OUString();
|
|
|
|
|
|
|
|
if( SVX_NUM_CHAR_SPECIAL == nTmpFmt )
|
|
|
|
return rUserStr;
|
|
|
|
|
|
|
|
return FormatNumber( (sal_uInt16)nTmp, nTmpFmt );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwPageNumberFieldType::Copy() const
|
|
|
|
{
|
|
|
|
SwPageNumberFieldType *pTmp = new SwPageNumberFieldType();
|
|
|
|
|
2001-02-23 11:45:30 +00:00
|
|
|
pTmp->nNumberingType = nNumberingType;
|
2000-09-18 23:08:29 +00:00
|
|
|
pTmp->bVirtuell = bVirtuell;
|
|
|
|
|
|
|
|
return pTmp;
|
|
|
|
}
|
|
|
|
|
2013-01-09 01:17:26 +01:00
|
|
|
void SwPageNumberFieldType::ChangeExpansion( SwDoc* pDoc,
|
|
|
|
sal_Bool bVirt,
|
2001-02-23 11:45:30 +00:00
|
|
|
const sal_Int16* pNumFmt )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( pNumFmt )
|
2001-02-23 11:45:30 +00:00
|
|
|
nNumberingType = *pNumFmt;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-11-07 10:56:27 +09:00
|
|
|
bVirtuell = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( bVirt )
|
|
|
|
{
|
2013-06-10 21:54:04 +02:00
|
|
|
// check the flag since the layout NEVER sets it back
|
2000-09-18 23:08:29 +00:00
|
|
|
const SfxItemPool &rPool = pDoc->GetAttrPool();
|
|
|
|
const SwFmtPageDesc *pDesc;
|
2010-10-18 22:00:21 +02:00
|
|
|
sal_uInt32 nMaxItems = rPool.GetItemCount2( RES_PAGEDESC );
|
|
|
|
for( sal_uInt32 n = 0; n < nMaxItems; ++n )
|
|
|
|
if( 0 != (pDesc = (SwFmtPageDesc*)rPool.GetItem2( RES_PAGEDESC, n ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
&& pDesc->GetNumOffset() && pDesc->GetDefinedIn() )
|
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
SwCntntNode* pNd = PTR_CAST( SwCntntNode, pDesc->GetDefinedIn() );
|
|
|
|
if( pNd )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
if ( SwIterator<SwFrm,SwCntntNode>::FirstElement(*pNd) )
|
2012-11-07 10:56:27 +09:00
|
|
|
bVirtuell = true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else if( pDesc->GetDefinedIn()->ISA( SwFmt ))
|
|
|
|
{
|
|
|
|
SwAutoFmtGetDocNode aGetHt( &pDoc->GetNodes() );
|
|
|
|
bVirtuell = !pDesc->GetDefinedIn()->GetInfo( aGetHt );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// SwPageNumberField
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwPageNumberField::SwPageNumberField(SwPageNumberFieldType* pTyp,
|
2013-01-09 01:17:26 +01:00
|
|
|
sal_uInt16 nSub, sal_uInt32 nFmt, short nOff,
|
|
|
|
sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage)
|
2007-09-27 07:48:37 +00:00
|
|
|
: SwField(pTyp, nFmt), nSubType(nSub), nOffset(nOff)
|
2013-01-09 01:17:26 +01:00
|
|
|
, m_nPageNumber(nPageNumber)
|
|
|
|
, m_nMaxPage(nMaxPage)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-09 01:17:26 +01:00
|
|
|
void SwPageNumberField::ChangeExpansion(sal_uInt16 const nPageNumber,
|
|
|
|
sal_uInt16 const nMaxPage)
|
|
|
|
{
|
|
|
|
m_nPageNumber = nPageNumber;
|
|
|
|
m_nMaxPage = nMaxPage;
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwPageNumberField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString sRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
SwPageNumberFieldType* pFldType = (SwPageNumberFieldType*)GetTyp();
|
|
|
|
|
|
|
|
if( PG_NEXT == nSubType && 1 != nOffset )
|
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
sRet = pFldType->Expand(GetFormat(), 1, m_nPageNumber, m_nMaxPage, sUserStr);
|
|
|
|
if (!sRet.isEmpty())
|
2013-01-09 01:17:26 +01:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
sRet = pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, sUserStr);
|
2013-01-09 01:17:26 +01:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else if( PG_PREV == nSubType && -1 != nOffset )
|
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
sRet = pFldType->Expand(GetFormat(), -1, m_nPageNumber, m_nMaxPage, sUserStr);
|
|
|
|
if (!sRet.isEmpty())
|
2013-01-09 01:17:26 +01:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
sRet = pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, sUserStr);
|
2013-01-09 01:17:26 +01:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
2013-07-14 15:21:18 +02:00
|
|
|
sRet = pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, sUserStr);
|
2000-09-18 23:08:29 +00:00
|
|
|
return sRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwPageNumberField::Copy() const
|
|
|
|
{
|
2013-01-09 01:17:26 +01:00
|
|
|
SwPageNumberField *pTmp = new SwPageNumberField(
|
|
|
|
static_cast<SwPageNumberFieldType*>(GetTyp()), nSubType,
|
|
|
|
GetFormat(), nOffset, m_nPageNumber, m_nMaxPage);
|
2000-09-18 23:08:29 +00:00
|
|
|
pTmp->SetLanguage( GetLanguage() );
|
|
|
|
pTmp->SetUserString( sUserStr );
|
|
|
|
return pTmp;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString SwPageNumberField::GetPar2() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-01-20 13:55:09 +01:00
|
|
|
return OUString::number(nOffset);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwPageNumberField::SetPar2(const OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-07 16:52:06 +00:00
|
|
|
nOffset = (short)rStr.toInt32();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_uInt16 SwPageNumberField::GetSubType() const
|
|
|
|
{
|
|
|
|
return nSubType;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwPageNumberField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_FORMAT:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= (sal_Int16)GetFormat();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_USHORT1:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= nOffset;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_SUBTYPE:
|
|
|
|
{
|
|
|
|
text::PageNumberType eType;
|
|
|
|
eType = text::PageNumberType_CURRENT;
|
|
|
|
if(nSubType == PG_PREV)
|
|
|
|
eType = text::PageNumberType_PREV;
|
|
|
|
else if(nSubType == PG_NEXT)
|
|
|
|
eType = text::PageNumberType_NEXT;
|
|
|
|
rAny.setValue(&eType, ::getCppuType((const text::PageNumberType*)0));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= sUserStr;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwPageNumberField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-10-04 15:23:52 +01:00
|
|
|
bool bRet = true;
|
2007-11-12 15:23:31 +00:00
|
|
|
sal_Int16 nSet = 0;
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_FORMAT:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny >>= nSet;
|
|
|
|
|
|
|
|
// TODO: woher kommen die defines?
|
|
|
|
if(nSet <= SVX_NUM_PAGEDESC )
|
|
|
|
SetFormat(nSet);
|
2008-04-22 13:58:09 +00:00
|
|
|
else {
|
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_USHORT1:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny >>= nSet;
|
|
|
|
nOffset = nSet;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_SUBTYPE:
|
2001-10-18 11:27:55 +00:00
|
|
|
switch( SWUnoHelper::GetEnumAsInt32( rAny ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
case text::PageNumberType_CURRENT:
|
|
|
|
nSubType = PG_RANDOM;
|
|
|
|
break;
|
|
|
|
case text::PageNumberType_PREV:
|
|
|
|
nSubType = PG_PREV;
|
|
|
|
break;
|
2001-04-23 12:13:11 +00:00
|
|
|
case text::PageNumberType_NEXT:
|
2000-09-18 23:08:29 +00:00
|
|
|
nSubType = PG_NEXT;
|
2001-04-23 12:13:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
2010-10-04 15:23:52 +01:00
|
|
|
bRet = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny >>= sUserStr;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-04-23 12:13:11 +00:00
|
|
|
return bRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2013-06-10 21:54:04 +02:00
|
|
|
// SwAuthorFieldType
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-01-18 13:08:36 +00:00
|
|
|
SwAuthorFieldType::SwAuthorFieldType()
|
2000-09-18 23:08:29 +00:00
|
|
|
: SwFieldType( RES_AUTHORFLD )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwAuthorFieldType::Expand(sal_uLong nFmt) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-04-29 15:54:32 +00:00
|
|
|
SvtUserOptions& rOpt = SW_MOD()->GetUserOptions();
|
2000-09-18 23:08:29 +00:00
|
|
|
if((nFmt & 0xff) == AF_NAME)
|
2013-07-14 15:21:18 +02:00
|
|
|
return rOpt.GetFullName();
|
|
|
|
|
|
|
|
return rOpt.GetID();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwAuthorFieldType::Copy() const
|
|
|
|
{
|
2001-01-18 13:08:36 +00:00
|
|
|
return new SwAuthorFieldType;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// SwAuthorField
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwAuthorField::SwAuthorField(SwAuthorFieldType* pTyp, sal_uInt32 nFmt)
|
|
|
|
: SwField(pTyp, nFmt)
|
|
|
|
{
|
|
|
|
aContent = ((SwAuthorFieldType*)GetTyp())->Expand(GetFormat());
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwAuthorField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if (!IsFixed())
|
2001-01-18 13:08:36 +00:00
|
|
|
((SwAuthorField*)this)->aContent =
|
|
|
|
((SwAuthorFieldType*)GetTyp())->Expand(GetFormat());
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
return aContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwAuthorField::Copy() const
|
|
|
|
{
|
2001-01-18 13:08:36 +00:00
|
|
|
SwAuthorField *pTmp = new SwAuthorField( (SwAuthorFieldType*)GetTyp(),
|
|
|
|
GetFormat());
|
2000-09-18 23:08:29 +00:00
|
|
|
pTmp->SetExpansion(aContent);
|
|
|
|
return pTmp;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwAuthorField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-10-04 15:23:52 +01:00
|
|
|
bool bVal;
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_BOOL1:
|
2003-08-19 11:27:34 +00:00
|
|
|
bVal = (GetFormat() & 0xff) == AF_NAME;
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny.setValue(&bVal, ::getBooleanCppuType());
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
bVal = IsFixed();
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny.setValue(&bVal, ::getBooleanCppuType());
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= GetContent();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwAuthorField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
SetFormat( *(sal_Bool*)rAny.getValue() ? AF_NAME : AF_SHORTCUT );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
if( *(sal_Bool*)rAny.getValue() )
|
2000-09-18 23:08:29 +00:00
|
|
|
SetFormat( GetFormat() | AF_FIXED);
|
|
|
|
else
|
|
|
|
SetFormat( GetFormat() & ~AF_FIXED);
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny >>= aContent;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// SwFileNameFieldType
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwFileNameFieldType::SwFileNameFieldType(SwDoc *pDocument)
|
|
|
|
: SwFieldType( RES_FILENAMEFLD )
|
|
|
|
{
|
|
|
|
pDoc = pDocument;
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwFileNameFieldType::Expand(sal_uLong nFmt) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString aRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwDocShell* pDShell = pDoc->GetDocShell();
|
|
|
|
if( pDShell && pDShell->HasName() )
|
|
|
|
{
|
|
|
|
const INetURLObject& rURLObj = pDShell->GetMedium()->GetURLObject();
|
|
|
|
switch( nFmt & ~FF_FIXED )
|
|
|
|
{
|
|
|
|
case FF_PATH:
|
|
|
|
{
|
|
|
|
if( INET_PROT_FILE == rURLObj.GetProtocol() )
|
|
|
|
{
|
|
|
|
INetURLObject aTemp(rURLObj);
|
|
|
|
aTemp.removeSegment();
|
2011-02-08 08:51:51 +01:00
|
|
|
// last slash should belong to the pathname
|
|
|
|
aRet = aTemp.PathToFileName();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-31 10:13:43 +00:00
|
|
|
aRet = URIHelper::removePassword(
|
|
|
|
rURLObj.GetMainURL( INetURLObject::NO_DECODE ),
|
2000-09-18 23:08:29 +00:00
|
|
|
INetURLObject::WAS_ENCODED, URL_DECODE );
|
2013-07-14 15:21:18 +02:00
|
|
|
const sal_Int32 nPos = aRet.indexOf(rURLObj.GetLastName( URL_DECODE ));
|
|
|
|
if (nPos>=0)
|
|
|
|
{
|
|
|
|
aRet = aRet.copy(0, nPos);
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FF_NAME:
|
2010-12-30 00:56:21 +02:00
|
|
|
aRet = rURLObj.GetLastName( INetURLObject::DECODE_WITH_CHARSET );
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FF_NAME_NOEXT:
|
|
|
|
aRet = rURLObj.GetBase();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if( INET_PROT_FILE == rURLObj.GetProtocol() )
|
|
|
|
aRet = rURLObj.GetFull();
|
|
|
|
else
|
2001-08-31 10:13:43 +00:00
|
|
|
aRet = URIHelper::removePassword(
|
|
|
|
rURLObj.GetMainURL( INetURLObject::NO_DECODE ),
|
2000-09-18 23:08:29 +00:00
|
|
|
INetURLObject::WAS_ENCODED, URL_DECODE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwFileNameFieldType::Copy() const
|
|
|
|
{
|
|
|
|
SwFieldType *pTmp = new SwFileNameFieldType(pDoc);
|
|
|
|
return pTmp;
|
|
|
|
}
|
2013-06-10 21:54:04 +02:00
|
|
|
|
|
|
|
// SwFileNameField
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwFileNameField::SwFileNameField(SwFileNameFieldType* pTyp, sal_uInt32 nFmt)
|
|
|
|
: SwField(pTyp, nFmt)
|
|
|
|
{
|
|
|
|
aContent = ((SwFileNameFieldType*)GetTyp())->Expand(GetFormat());
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwFileNameField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if (!IsFixed())
|
|
|
|
((SwFileNameField*)this)->aContent = ((SwFileNameFieldType*)GetTyp())->Expand(GetFormat());
|
|
|
|
|
|
|
|
return aContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwFileNameField::Copy() const
|
|
|
|
{
|
|
|
|
SwFileNameField *pTmp =
|
|
|
|
new SwFileNameField((SwFileNameFieldType*)GetTyp(), GetFormat());
|
|
|
|
pTmp->SetExpansion(aContent);
|
|
|
|
|
|
|
|
return pTmp;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwFileNameField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_FORMAT:
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
sal_Int16 nRet;
|
|
|
|
switch( GetFormat() &(~FF_FIXED) )
|
|
|
|
{
|
|
|
|
case FF_PATH:
|
|
|
|
nRet = text::FilenameDisplayFormat::PATH;
|
|
|
|
break;
|
|
|
|
case FF_NAME_NOEXT:
|
|
|
|
nRet = text::FilenameDisplayFormat::NAME;
|
|
|
|
break;
|
|
|
|
case FF_NAME:
|
|
|
|
nRet = text::FilenameDisplayFormat::NAME_AND_EXT;
|
|
|
|
break;
|
|
|
|
default: nRet = text::FilenameDisplayFormat::FULL;
|
|
|
|
}
|
|
|
|
rAny <<= nRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bVal = IsFixed();
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny.setValue(&bVal, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_PAR3:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= GetContent();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwFileNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_FORMAT:
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
//JP 24.10.2001: int32 because in UnoField.cxx a putvalue is
|
|
|
|
// called with a int32 value! But normally we need
|
|
|
|
// here only a int16
|
2007-11-12 15:23:31 +00:00
|
|
|
sal_Int32 nType = 0;
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny >>= nType;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bFixed = IsFixed();
|
2001-10-24 17:56:14 +00:00
|
|
|
switch( nType )
|
|
|
|
{
|
|
|
|
case text::FilenameDisplayFormat::PATH:
|
|
|
|
nType = FF_PATH;
|
|
|
|
break;
|
|
|
|
case text::FilenameDisplayFormat::NAME:
|
|
|
|
nType = FF_NAME_NOEXT;
|
|
|
|
break;
|
|
|
|
case text::FilenameDisplayFormat::NAME_AND_EXT:
|
|
|
|
nType = FF_NAME;
|
|
|
|
break;
|
|
|
|
default: nType = FF_PATHNAME;
|
|
|
|
}
|
|
|
|
if(bFixed)
|
|
|
|
nType |= FF_FIXED;
|
|
|
|
SetFormat(nType);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
if( *(sal_Bool*)rAny.getValue() )
|
2000-09-18 23:08:29 +00:00
|
|
|
SetFormat( GetFormat() | FF_FIXED);
|
|
|
|
else
|
|
|
|
SetFormat( GetFormat() & ~FF_FIXED);
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_PAR3:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny >>= aContent;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2013-06-10 21:54:04 +02:00
|
|
|
|
|
|
|
// SwTemplNameFieldType
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwTemplNameFieldType::SwTemplNameFieldType(SwDoc *pDocument)
|
|
|
|
: SwFieldType( RES_TEMPLNAMEFLD )
|
|
|
|
{
|
|
|
|
pDoc = pDocument;
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwTemplNameFieldType::Expand(sal_uLong nFmt) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( nFmt < FF_END, "Expand: kein guelt. Fmt!" );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString aRet;
|
2008-02-26 13:10:15 +00:00
|
|
|
SwDocShell *pDocShell(pDoc->GetDocShell());
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE(pDocShell, "no SwDocShell");
|
2008-02-26 13:10:15 +00:00
|
|
|
if (pDocShell) {
|
|
|
|
uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
|
|
|
|
pDocShell->GetModel(), uno::UNO_QUERY_THROW);
|
|
|
|
uno::Reference<document::XDocumentProperties> xDocProps(
|
|
|
|
xDPS->getDocumentProperties());
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE(xDocProps.is(), "Doc has no DocumentProperties");
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
if( FF_UI_NAME == nFmt )
|
2008-02-26 13:10:15 +00:00
|
|
|
aRet = xDocProps->getTemplateName();
|
2012-01-17 17:47:34 -02:00
|
|
|
else if( !xDocProps->getTemplateURL().isEmpty() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( FF_UI_RANGE == nFmt )
|
|
|
|
{
|
|
|
|
// fuers besorgen vom RegionNamen !!
|
|
|
|
SfxDocumentTemplates aFac;
|
|
|
|
aFac.Construct();
|
2013-08-27 13:31:45 +02:00
|
|
|
OUString sTmp;
|
|
|
|
OUString sRegion;
|
2013-07-14 15:21:18 +02:00
|
|
|
aFac.GetLogicNames( xDocProps->getTemplateURL(), sRegion, sTmp );
|
|
|
|
aRet = sRegion;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-26 13:10:15 +00:00
|
|
|
INetURLObject aPathName( xDocProps->getTemplateURL() );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( FF_NAME == nFmt )
|
|
|
|
aRet = aPathName.GetName(URL_DECODE);
|
|
|
|
else if( FF_NAME_NOEXT == nFmt )
|
|
|
|
aRet = aPathName.GetBase();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( FF_PATH == nFmt )
|
|
|
|
{
|
|
|
|
aPathName.removeSegment();
|
|
|
|
aRet = aPathName.GetFull();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aRet = aPathName.GetFull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwTemplNameFieldType::Copy() const
|
|
|
|
{
|
|
|
|
SwFieldType *pTmp = new SwTemplNameFieldType(pDoc);
|
|
|
|
return pTmp;
|
|
|
|
}
|
2013-06-10 21:54:04 +02:00
|
|
|
// SwTemplNameField
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwTemplNameField::SwTemplNameField(SwTemplNameFieldType* pTyp, sal_uInt32 nFmt)
|
|
|
|
: SwField(pTyp, nFmt)
|
|
|
|
{}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwTemplNameField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return((SwTemplNameFieldType*)GetTyp())->Expand(GetFormat());
|
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwTemplNameField::Copy() const
|
|
|
|
{
|
|
|
|
SwTemplNameField *pTmp =
|
|
|
|
new SwTemplNameField((SwTemplNameFieldType*)GetTyp(), GetFormat());
|
|
|
|
return pTmp;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwTemplNameField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch ( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_FORMAT:
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
sal_Int16 nRet;
|
|
|
|
switch( GetFormat() )
|
|
|
|
{
|
|
|
|
case FF_PATH: nRet = text::FilenameDisplayFormat::PATH; break;
|
|
|
|
case FF_NAME_NOEXT: nRet = text::FilenameDisplayFormat::NAME; break;
|
|
|
|
case FF_NAME: nRet = text::FilenameDisplayFormat::NAME_AND_EXT; break;
|
|
|
|
case FF_UI_RANGE: nRet = text::TemplateDisplayFormat::AREA; break;
|
|
|
|
case FF_UI_NAME: nRet = text::TemplateDisplayFormat::TITLE; break;
|
|
|
|
default: nRet = text::FilenameDisplayFormat::FULL;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
rAny <<= nRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwTemplNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch ( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_FORMAT:
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
//JP 24.10.2001: int32 because in UnoField.cxx a putvalue is
|
|
|
|
// called with a int32 value! But normally we need
|
|
|
|
// here only a int16
|
2007-11-12 15:23:31 +00:00
|
|
|
sal_Int32 nType = 0;
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny >>= nType;
|
|
|
|
switch( nType )
|
|
|
|
{
|
2000-09-18 23:08:29 +00:00
|
|
|
case text::FilenameDisplayFormat::PATH:
|
|
|
|
SetFormat(FF_PATH);
|
|
|
|
break;
|
|
|
|
case text::FilenameDisplayFormat::NAME:
|
|
|
|
SetFormat(FF_NAME_NOEXT);
|
|
|
|
break;
|
|
|
|
case text::FilenameDisplayFormat::NAME_AND_EXT:
|
|
|
|
SetFormat(FF_NAME);
|
|
|
|
break;
|
|
|
|
case text::TemplateDisplayFormat::AREA :
|
|
|
|
SetFormat(FF_UI_RANGE);
|
|
|
|
break;
|
|
|
|
case text::TemplateDisplayFormat::TITLE :
|
|
|
|
SetFormat(FF_UI_NAME);
|
|
|
|
break;
|
|
|
|
default: SetFormat(FF_PATHNAME);
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2013-06-10 21:54:04 +02:00
|
|
|
|
|
|
|
// SwDocStatFieldType
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwDocStatFieldType::SwDocStatFieldType(SwDoc* pDocument)
|
2001-02-23 11:45:30 +00:00
|
|
|
: SwFieldType( RES_DOCSTATFLD ), nNumberingType( SVX_NUM_ARABIC )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
pDoc = pDocument;
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwDocStatFieldType::Expand(sal_uInt16 nSubType, sal_uInt32 nFmt) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
sal_uInt32 nVal = 0;
|
|
|
|
const SwDocStat& rDStat = pDoc->GetDocStat();
|
|
|
|
switch( nSubType )
|
|
|
|
{
|
|
|
|
case DS_TBL: nVal = rDStat.nTbl; break;
|
|
|
|
case DS_GRF: nVal = rDStat.nGrf; break;
|
|
|
|
case DS_OLE: nVal = rDStat.nOLE; break;
|
|
|
|
case DS_PARA: nVal = rDStat.nPara; break;
|
|
|
|
case DS_WORD: nVal = rDStat.nWord; break;
|
|
|
|
case DS_CHAR: nVal = rDStat.nChar; break;
|
|
|
|
case DS_PAGE:
|
2013-10-22 15:14:13 +03:00
|
|
|
if( pDoc->GetCurrentLayout() )
|
|
|
|
((SwDocStat &)rDStat).nPage = pDoc->GetCurrentLayout()->GetPageNum();
|
2000-09-18 23:08:29 +00:00
|
|
|
nVal = rDStat.nPage;
|
|
|
|
if( SVX_NUM_PAGEDESC == nFmt )
|
2001-02-23 11:45:30 +00:00
|
|
|
nFmt = (sal_uInt32)nNumberingType;
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-19 14:13:18 +01:00
|
|
|
OSL_FAIL( "SwDocStatFieldType::Expand: unbekannter SubType" );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( nVal <= SHRT_MAX )
|
2013-07-14 15:21:18 +02:00
|
|
|
return FormatNumber( (sal_uInt16)nVal, nFmt );
|
|
|
|
|
|
|
|
return OUString::number( nVal );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwDocStatFieldType::Copy() const
|
|
|
|
{
|
|
|
|
SwDocStatFieldType *pTmp = new SwDocStatFieldType(pDoc);
|
|
|
|
return pTmp;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/**
|
|
|
|
* @param pTyp
|
|
|
|
* @param nSub SubType
|
|
|
|
* @param nFmt
|
|
|
|
*/
|
2000-09-18 23:08:29 +00:00
|
|
|
SwDocStatField::SwDocStatField(SwDocStatFieldType* pTyp, sal_uInt16 nSub, sal_uInt32 nFmt)
|
|
|
|
: SwField(pTyp, nFmt),
|
|
|
|
nSubType(nSub)
|
|
|
|
{}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwDocStatField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return((SwDocStatFieldType*)GetTyp())->Expand(nSubType, GetFormat());
|
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwDocStatField::Copy() const
|
|
|
|
{
|
|
|
|
SwDocStatField *pTmp = new SwDocStatField(
|
|
|
|
(SwDocStatFieldType*)GetTyp(), nSubType, GetFormat() );
|
|
|
|
return pTmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_uInt16 SwDocStatField::GetSubType() const
|
|
|
|
{
|
|
|
|
return nSubType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwDocStatField::SetSubType(sal_uInt16 nSub)
|
|
|
|
{
|
|
|
|
nSubType = nSub;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwDocStatField::ChangeExpansion( const SwFrm* pFrm )
|
|
|
|
{
|
|
|
|
if( DS_PAGE == nSubType && SVX_NUM_PAGEDESC == GetFormat() )
|
|
|
|
((SwDocStatFieldType*)GetTyp())->SetNumFormat(
|
2001-02-23 11:45:30 +00:00
|
|
|
pFrm->FindPageFrm()->GetPageDesc()->GetNumType().GetNumberingType() );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwDocStatField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch ( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_USHORT2:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= (sal_Int16)GetFormat();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwDocStatField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-10-04 15:23:52 +01:00
|
|
|
bool bRet = false;
|
2007-09-27 07:48:37 +00:00
|
|
|
switch ( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_USHORT2:
|
|
|
|
{
|
2007-11-12 15:23:31 +00:00
|
|
|
sal_Int16 nSet = 0;
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny >>= nSet;
|
|
|
|
if(nSet <= SVX_NUM_CHARS_LOWER_LETTER_N &&
|
|
|
|
nSet != SVX_NUM_CHAR_SPECIAL &&
|
|
|
|
nSet != SVX_NUM_BITMAP)
|
|
|
|
{
|
|
|
|
SetFormat(nSet);
|
2010-10-04 15:23:52 +01:00
|
|
|
bRet = true;
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
return bRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// Document info field type
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwDocInfoFieldType::SwDocInfoFieldType(SwDoc* pDc)
|
|
|
|
: SwValueFieldType( pDc, RES_DOCINFOFLD )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwDocInfoFieldType::Copy() const
|
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
SwDocInfoFieldType* pTyp = new SwDocInfoFieldType(GetDoc());
|
|
|
|
return pTyp;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_GetLocalDataWrapper( sal_uLong nLang,
|
2009-09-08 04:57:32 +00:00
|
|
|
const LocaleDataWrapper **ppAppLocalData,
|
|
|
|
const LocaleDataWrapper **ppLocalData )
|
2001-02-14 08:58:47 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
SvtSysLocale aLocale;
|
|
|
|
*ppAppLocalData = &aLocale.GetLocaleData();
|
2001-02-14 08:58:47 +00:00
|
|
|
*ppLocalData = *ppAppLocalData;
|
2012-11-24 18:54:09 +01:00
|
|
|
if( nLang != (*ppLocalData)->getLanguageTag().getLanguageType() )
|
2001-02-14 08:58:47 +00:00
|
|
|
*ppLocalData = new LocaleDataWrapper(
|
2012-11-24 18:54:09 +01:00
|
|
|
LanguageTag( static_cast<LanguageType>(nLang) ));
|
2001-02-14 08:58:47 +00:00
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat,
|
|
|
|
sal_uInt16 nLang, const OUString& rName ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2009-09-08 04:57:32 +00:00
|
|
|
const LocaleDataWrapper *pAppLocalData = 0, *pLocalData = 0;
|
2008-02-26 13:10:15 +00:00
|
|
|
SwDocShell *pDocShell(GetDoc()->GetDocShell());
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE(pDocShell, "no SwDocShell");
|
2013-07-14 15:21:18 +02:00
|
|
|
if (!pDocShell) { return OUString(); }
|
2008-02-26 13:10:15 +00:00
|
|
|
|
|
|
|
uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
|
|
|
|
pDocShell->GetModel(), uno::UNO_QUERY_THROW);
|
|
|
|
uno::Reference<document::XDocumentProperties> xDocProps(
|
|
|
|
xDPS->getDocumentProperties());
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE(xDocProps.is(), "Doc has no DocumentProperties");
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
sal_uInt16 nExtSub = nSub & 0xff00;
|
|
|
|
nSub &= 0xff; // ExtendedSubTypes nicht beachten
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString aStr;
|
2000-09-18 23:08:29 +00:00
|
|
|
switch(nSub)
|
|
|
|
{
|
2008-02-26 13:10:15 +00:00
|
|
|
case DI_TITEL: aStr = xDocProps->getTitle(); break;
|
|
|
|
case DI_THEMA: aStr = xDocProps->getSubject(); break;
|
|
|
|
case DI_KEYS: aStr = ::comphelper::string::convertCommaSeparated(
|
|
|
|
xDocProps->getKeywords());
|
|
|
|
break;
|
|
|
|
case DI_COMMENT:aStr = xDocProps->getDescription(); break;
|
2013-02-20 00:18:07 +01:00
|
|
|
case DI_DOCNO: aStr = OUString::number(
|
2008-02-26 13:10:15 +00:00
|
|
|
xDocProps->getEditingCycles() );
|
2001-02-14 08:58:47 +00:00
|
|
|
break;
|
|
|
|
case DI_EDIT:
|
|
|
|
if ( !nFormat )
|
|
|
|
{
|
|
|
|
lcl_GetLocalDataWrapper( nLang, &pAppLocalData, &pLocalData );
|
2008-02-26 13:10:15 +00:00
|
|
|
sal_Int32 dur = xDocProps->getEditingDuration();
|
|
|
|
aStr = pLocalData->getTime( Time(dur/3600, (dur%3600)/60, dur%60),
|
|
|
|
sal_False, sal_False);
|
2001-02-14 08:58:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-26 13:10:15 +00:00
|
|
|
sal_Int32 dur = xDocProps->getEditingDuration();
|
|
|
|
double fVal = Time(dur/3600, (dur%3600)/60, dur%60).GetTimeInDays();
|
2001-02-14 08:58:47 +00:00
|
|
|
aStr = ExpandValue(fVal, nFormat, nLang);
|
|
|
|
}
|
|
|
|
break;
|
2007-11-26 14:29:04 +00:00
|
|
|
case DI_CUSTOM:
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sVal;
|
2007-11-26 14:29:04 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Any aAny;
|
2008-02-26 13:10:15 +00:00
|
|
|
uno::Reference < beans::XPropertySet > xSet(
|
|
|
|
xDocProps->getUserDefinedProperties(),
|
|
|
|
uno::UNO_QUERY_THROW);
|
2007-11-26 14:29:04 +00:00
|
|
|
aAny = xSet->getPropertyValue( rName );
|
|
|
|
|
2012-08-21 08:07:58 +02:00
|
|
|
uno::Reference < script::XTypeConverter > xConverter( script::Converter::create(comphelper::getProcessComponentContext()) );
|
2007-11-26 14:29:04 +00:00
|
|
|
uno::Any aNew;
|
|
|
|
aNew = xConverter->convertToSimpleType( aAny, uno::TypeClass_STRING );
|
|
|
|
aNew >>= sVal;
|
|
|
|
}
|
|
|
|
catch (uno::Exception&) {}
|
|
|
|
return sVal;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-02-14 08:58:47 +00:00
|
|
|
default:
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString aName( xDocProps->getAuthor() );
|
2008-02-26 13:10:15 +00:00
|
|
|
util::DateTime uDT( xDocProps->getCreationDate() );
|
|
|
|
Date aD(uDT.Day, uDT.Month, uDT.Year);
|
2013-03-17 08:36:26 +01:00
|
|
|
Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
2008-02-26 13:10:15 +00:00
|
|
|
DateTime aDate(aD,aT);
|
2000-09-18 23:08:29 +00:00
|
|
|
if( nSub == DI_CREATE )
|
|
|
|
; // das wars schon!!
|
2008-02-26 13:10:15 +00:00
|
|
|
else if( nSub == DI_CHANGE )
|
2007-07-17 12:07:24 +00:00
|
|
|
{
|
2008-02-26 13:10:15 +00:00
|
|
|
aName = xDocProps->getModifiedBy();
|
|
|
|
uDT = xDocProps->getModificationDate();
|
|
|
|
Date bD(uDT.Day, uDT.Month, uDT.Year);
|
2013-03-17 08:36:26 +01:00
|
|
|
Time bT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
2008-02-26 13:10:15 +00:00
|
|
|
DateTime bDate(bD,bT);
|
|
|
|
aDate = bDate;
|
2007-07-17 12:07:24 +00:00
|
|
|
}
|
2008-02-26 13:10:15 +00:00
|
|
|
else if( nSub == DI_PRINT )
|
2007-07-17 12:07:24 +00:00
|
|
|
{
|
2008-02-26 13:10:15 +00:00
|
|
|
aName = xDocProps->getPrintedBy();
|
|
|
|
uDT = xDocProps->getPrintDate();
|
|
|
|
Date bD(uDT.Day, uDT.Month, uDT.Year);
|
2013-03-17 08:36:26 +01:00
|
|
|
Time bT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
2008-02-26 13:10:15 +00:00
|
|
|
DateTime bDate(bD,bT);
|
|
|
|
aDate = bDate;
|
2007-07-17 12:07:24 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2001-02-14 08:58:47 +00:00
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2011-11-30 02:05:22 +01:00
|
|
|
if (aDate.IsValidAndGregorian())
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
switch (nExtSub & ~DI_SUB_FIXED)
|
|
|
|
{
|
2001-02-14 08:58:47 +00:00
|
|
|
case DI_SUB_AUTHOR:
|
2007-07-17 12:07:24 +00:00
|
|
|
aStr = aName;
|
2001-02-14 08:58:47 +00:00
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-02-14 08:58:47 +00:00
|
|
|
case DI_SUB_TIME:
|
|
|
|
if (!nFormat)
|
|
|
|
{
|
|
|
|
lcl_GetLocalDataWrapper( nLang, &pAppLocalData,
|
|
|
|
&pLocalData );
|
2007-07-17 12:07:24 +00:00
|
|
|
aStr = pLocalData->getTime( aDate,
|
2001-02-14 08:58:47 +00:00
|
|
|
sal_False, sal_False);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Numberformatter anwerfen!
|
|
|
|
double fVal = SwDateTimeField::GetDateTime( GetDoc(),
|
2007-07-17 12:07:24 +00:00
|
|
|
aDate);
|
2001-02-14 08:58:47 +00:00
|
|
|
aStr = ExpandValue(fVal, nFormat, nLang);
|
|
|
|
}
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-02-14 08:58:47 +00:00
|
|
|
case DI_SUB_DATE:
|
|
|
|
if (!nFormat)
|
|
|
|
{
|
|
|
|
lcl_GetLocalDataWrapper( nLang, &pAppLocalData,
|
|
|
|
&pLocalData );
|
2007-07-17 12:07:24 +00:00
|
|
|
aStr = pLocalData->getDate( aDate );
|
2001-02-14 08:58:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Numberformatter anwerfen!
|
|
|
|
double fVal = SwDateTimeField::GetDateTime( GetDoc(),
|
2007-07-17 12:07:24 +00:00
|
|
|
aDate);
|
2001-02-14 08:58:47 +00:00
|
|
|
aStr = ExpandValue(fVal, nFormat, nLang);
|
|
|
|
}
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-14 08:58:47 +00:00
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-02-14 08:58:47 +00:00
|
|
|
|
|
|
|
if( pAppLocalData != pLocalData )
|
|
|
|
delete pLocalData;
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
return aStr;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// document info field
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const OUString& rName, sal_uInt32 nFmt) :
|
2007-09-27 07:48:37 +00:00
|
|
|
SwValueField(pTyp, nFmt), nSubType(nSub)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-11-26 14:29:04 +00:00
|
|
|
aName = rName;
|
|
|
|
aContent = ((SwDocInfoFieldType*)GetTyp())->Expand(nSubType, nFmt, GetLanguage(), aName);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2007-11-26 14:29:04 +00:00
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFmt) :
|
2008-04-03 15:51:46 +00:00
|
|
|
SwValueField(pTyp, nFmt), nSubType(nSub)
|
|
|
|
{
|
|
|
|
aName = rName;
|
|
|
|
aContent = rValue;
|
|
|
|
}
|
|
|
|
|
2009-10-08 16:15:40 +02:00
|
|
|
template<class T>
|
2012-10-12 16:49:40 +02:00
|
|
|
static double lcl_TimeToDouble( const T& rTime )
|
2009-10-08 16:15:40 +02:00
|
|
|
{
|
2013-03-17 08:36:26 +01:00
|
|
|
const double fNanoSecondsPerDay = 86400000000000.0;
|
|
|
|
return ((rTime.Hours*3600000)+(rTime.Minutes*60000)+(rTime.Seconds*1000)+(rTime.NanoSeconds)) / fNanoSecondsPerDay;
|
2009-10-08 16:15:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class D>
|
2012-10-12 16:49:40 +02:00
|
|
|
static double lcl_DateToDouble( const D& rDate, const Date& rNullDate )
|
2009-10-08 16:15:40 +02:00
|
|
|
{
|
|
|
|
long nDate = Date::DateToDays( rDate.Day, rDate.Month, rDate.Year );
|
|
|
|
long nNullDate = Date::DateToDays( rNullDate.GetDay(), rNullDate.GetMonth(), rNullDate.GetYear() );
|
|
|
|
return double( nDate - nNullDate );
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwDocInfoField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2008-04-03 15:51:46 +00:00
|
|
|
if ( ( nSubType & 0xFF ) == DI_CUSTOM )
|
|
|
|
{
|
2013-06-10 21:58:09 +02:00
|
|
|
// custom properties currently need special treatment
|
|
|
|
// We don't have a secure way to detect "real" custom properties in Word import of text
|
|
|
|
// fields, so we treat *every* unknown property as a custom property, even the "built-in"
|
|
|
|
// section in Word's document summary information stream as these properties have not been
|
|
|
|
// inserted when the document summary information was imported, we do it here.
|
|
|
|
// This approach is still a lot better than the old one to import such fields as
|
|
|
|
// "user fields" and simple text
|
2008-07-01 10:25:55 +00:00
|
|
|
SwDocShell* pDocShell = GetDoc()->GetDocShell();
|
|
|
|
if( !pDocShell )
|
|
|
|
return aContent;
|
2008-04-03 15:51:46 +00:00
|
|
|
try
|
|
|
|
{
|
2008-07-01 10:25:55 +00:00
|
|
|
uno::Reference<document::XDocumentPropertiesSupplier> xDPS( pDocShell->GetModel(), uno::UNO_QUERY_THROW);
|
2008-04-03 15:51:46 +00:00
|
|
|
uno::Reference<document::XDocumentProperties> xDocProps( xDPS->getDocumentProperties());
|
|
|
|
uno::Reference < beans::XPropertySet > xSet( xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
|
2008-07-01 10:25:55 +00:00
|
|
|
uno::Reference < beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo();
|
|
|
|
|
|
|
|
uno::Any aAny;
|
|
|
|
if( xSetInfo->hasPropertyByName( aName ) )
|
|
|
|
aAny = xSet->getPropertyValue( aName );
|
2008-04-03 15:51:46 +00:00
|
|
|
if ( aAny.getValueType() != ::getVoidCppuType() )
|
|
|
|
{
|
|
|
|
// "void" type means that the property has not been inserted until now
|
|
|
|
if ( !IsFixed() )
|
|
|
|
{
|
|
|
|
// if the field is "fixed" we don't update it from the property
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sVal;
|
2012-08-21 08:07:58 +02:00
|
|
|
uno::Reference < script::XTypeConverter > xConverter( script::Converter::create(comphelper::getProcessComponentContext()) );
|
2009-10-08 16:15:40 +02:00
|
|
|
util::Date aDate;
|
|
|
|
util::DateTime aDateTime;
|
2009-11-26 12:52:39 +01:00
|
|
|
util::Duration aDuration;
|
2009-10-08 16:15:40 +02:00
|
|
|
if( aAny >>= aDate)
|
|
|
|
{
|
|
|
|
SvNumberFormatter* pFormatter = pDocShell->GetDoc()->GetNumberFormatter();
|
|
|
|
Date* pNullDate = pFormatter->GetNullDate();
|
|
|
|
sVal = ExpandValue( lcl_DateToDouble<util::Date>( aDate, *pNullDate ), GetFormat(), GetLanguage());
|
|
|
|
}
|
|
|
|
else if( aAny >>= aDateTime )
|
|
|
|
{
|
|
|
|
double fDateTime = lcl_TimeToDouble<util::DateTime>( aDateTime );
|
|
|
|
SvNumberFormatter* pFormatter = pDocShell->GetDoc()->GetNumberFormatter();
|
|
|
|
Date* pNullDate = pFormatter->GetNullDate();
|
|
|
|
fDateTime += lcl_DateToDouble<util::DateTime>( aDateTime, *pNullDate );
|
|
|
|
sVal = ExpandValue( fDateTime, GetFormat(), GetLanguage());
|
|
|
|
}
|
2009-11-26 12:52:39 +01:00
|
|
|
else if( aAny >>= aDuration )
|
2009-10-08 16:15:40 +02:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
sVal = OUString(aDuration.Negative ? '-' : '+')
|
2013-10-26 19:50:13 +02:00
|
|
|
+ SwViewShell::GetShellRes()->sDurationFormat;
|
2013-07-14 15:21:18 +02:00
|
|
|
sVal = sVal.replaceFirst("%1", OUString::number( aDuration.Years ) );
|
|
|
|
sVal = sVal.replaceFirst("%2", OUString::number( aDuration.Months ) );
|
|
|
|
sVal = sVal.replaceFirst("%3", OUString::number( aDuration.Days ) );
|
|
|
|
sVal = sVal.replaceFirst("%4", OUString::number( aDuration.Hours ) );
|
|
|
|
sVal = sVal.replaceFirst("%5", OUString::number( aDuration.Minutes) );
|
|
|
|
sVal = sVal.replaceFirst("%6", OUString::number( aDuration.Seconds) );
|
2009-10-08 16:15:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
uno::Any aNew = xConverter->convertToSimpleType( aAny, uno::TypeClass_STRING );
|
|
|
|
aNew >>= sVal;
|
|
|
|
}
|
2008-04-03 15:51:46 +00:00
|
|
|
((SwDocInfoField*)this)->aContent = sVal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (uno::Exception&) {}
|
|
|
|
}
|
|
|
|
else if ( !IsFixed() )
|
2007-11-26 14:29:04 +00:00
|
|
|
((SwDocInfoField*)this)->aContent = ((SwDocInfoFieldType*)GetTyp())->Expand(nSubType, GetFormat(), GetLanguage(), aName);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
return aContent;
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwDocInfoField::GetFieldName() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString aStr(SwFieldType::GetTypeStr(GetTypeId()) + ":");
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2010-10-04 17:14:34 +02:00
|
|
|
sal_uInt16 const nSub = nSubType & 0xff;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2010-10-04 17:14:34 +02:00
|
|
|
switch (nSub)
|
|
|
|
{
|
|
|
|
case DI_CUSTOM:
|
|
|
|
aStr += aName;
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2010-10-04 17:14:34 +02:00
|
|
|
default:
|
2013-10-26 19:50:13 +02:00
|
|
|
aStr += SwViewShell::GetShellRes()
|
2012-01-13 18:14:36 -05:00
|
|
|
->aDocInfoLst[ nSub - DI_SUBTYPE_BEGIN ];
|
2010-10-04 17:14:34 +02:00
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 17:14:34 +02:00
|
|
|
if (IsFixed())
|
|
|
|
{
|
2013-10-26 19:50:13 +02:00
|
|
|
aStr += " " + OUString(SwViewShell::GetShellRes()->aFixedStr);
|
2010-10-04 17:14:34 +02:00
|
|
|
}
|
|
|
|
return aStr;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwDocInfoField::Copy() const
|
|
|
|
{
|
2007-11-26 14:29:04 +00:00
|
|
|
SwDocInfoField* pFld = new SwDocInfoField((SwDocInfoFieldType*)GetTyp(), nSubType, aName, GetFormat());
|
2002-11-15 10:17:38 +00:00
|
|
|
pFld->SetAutomaticLanguage(IsAutomaticLanguage());
|
2000-09-18 23:08:29 +00:00
|
|
|
pFld->aContent = aContent;
|
|
|
|
|
|
|
|
return pFld;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_uInt16 SwDocInfoField::GetSubType() const
|
|
|
|
{
|
|
|
|
return nSubType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwDocInfoField::SetSubType(sal_uInt16 nSub)
|
|
|
|
{
|
|
|
|
nSubType = nSub;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwDocInfoField::SetLanguage(sal_uInt16 nLng)
|
|
|
|
{
|
|
|
|
if (!GetFormat())
|
|
|
|
SwField::SetLanguage(nLng);
|
|
|
|
else
|
|
|
|
SwValueField::SetLanguage(nLng);
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwDocInfoField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= aContent;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
2007-11-26 14:29:04 +00:00
|
|
|
case FIELD_PROP_PAR4:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= aName;
|
2007-11-26 14:29:04 +00:00
|
|
|
break;
|
|
|
|
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_USHORT1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= (sal_Int16)aContent.toInt32();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
{
|
|
|
|
sal_Bool bVal = 0 != (nSubType & DI_SUB_FIXED);
|
|
|
|
rAny.setValue(&bVal, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_FORMAT:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= (sal_Int32)GetFormat();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_DOUBLE:
|
|
|
|
{
|
|
|
|
double fVal = GetValue();
|
|
|
|
rAny.setValue(&fVal, ::getCppuType(&fVal));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR3:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= Expand();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
{
|
|
|
|
sal_uInt16 nExtSub = (nSubType & 0xff00) & ~DI_SUB_FIXED;
|
|
|
|
sal_Bool bVal = (nExtSub == DI_SUB_DATE);
|
|
|
|
rAny.setValue(&bVal, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2007-09-27 07:48:37 +00:00
|
|
|
return SwField::QueryValue(rAny, nWhichId);
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwDocInfoField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-11-12 15:23:31 +00:00
|
|
|
sal_Int32 nValue = 0;
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
|
|
|
if( nSubType & DI_SUB_FIXED )
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny >>= aContent;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_USHORT1:
|
|
|
|
if( nSubType & DI_SUB_FIXED )
|
|
|
|
{
|
|
|
|
rAny >>= nValue;
|
2013-02-20 00:18:07 +01:00
|
|
|
aContent = OUString::number(nValue);
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
if(*(sal_Bool*)rAny.getValue())
|
2000-09-18 23:08:29 +00:00
|
|
|
nSubType |= DI_SUB_FIXED;
|
|
|
|
else
|
|
|
|
nSubType &= ~DI_SUB_FIXED;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_FORMAT:
|
|
|
|
{
|
|
|
|
rAny >>= nValue;
|
|
|
|
if( nValue >= 0)
|
|
|
|
SetFormat(nValue);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_PAR3:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny >>= aContent;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL2:
|
2000-11-22 15:49:00 +00:00
|
|
|
nSubType &= 0xf0ff;
|
2000-09-18 23:08:29 +00:00
|
|
|
if(*(sal_Bool*)rAny.getValue())
|
|
|
|
nSubType |= DI_SUB_DATE;
|
|
|
|
else
|
|
|
|
nSubType |= DI_SUB_TIME;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-09-27 07:48:37 +00:00
|
|
|
return SwField::PutValue(rAny, nWhichId);
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// SwHiddenTxtFieldType
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwHiddenTxtFieldType::SwHiddenTxtFieldType( sal_Bool bSetHidden )
|
|
|
|
: SwFieldType( RES_HIDDENTXTFLD ), bHidden( bSetHidden )
|
2009-12-03 15:25:10 +01:00
|
|
|
{
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwFieldType* SwHiddenTxtFieldType::Copy() const
|
|
|
|
{
|
|
|
|
return new SwHiddenTxtFieldType( bHidden );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwHiddenTxtFieldType::SetHiddenFlag( sal_Bool bSetHidden )
|
|
|
|
{
|
|
|
|
if( bHidden != bSetHidden )
|
|
|
|
{
|
|
|
|
bHidden = bSetHidden;
|
2013-06-10 21:54:04 +02:00
|
|
|
UpdateFlds(); // notify all HiddenTexts
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType* pFldType,
|
|
|
|
sal_Bool bConditional,
|
2013-07-14 15:21:18 +02:00
|
|
|
const OUString& rCond,
|
|
|
|
const OUString& rStr,
|
2000-09-18 23:08:29 +00:00
|
|
|
sal_Bool bHidden,
|
|
|
|
sal_uInt16 nSub) :
|
2007-09-27 07:48:37 +00:00
|
|
|
SwField( pFldType ), aCond(rCond), nSubType(nSub),
|
|
|
|
bCanToggle(bConditional), bIsHidden(bHidden), bValid(sal_False)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if(nSubType == TYP_CONDTXTFLD)
|
|
|
|
{
|
2013-03-07 19:35:49 +05:30
|
|
|
sal_Int32 nPos = 0;
|
2013-07-14 15:21:18 +02:00
|
|
|
aTRUETxt = rStr.getToken(0, '|', nPos);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-03-07 19:35:49 +05:30
|
|
|
if(nPos != -1)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
aFALSETxt = rStr.getToken(0, '|', nPos);
|
2013-03-07 19:35:49 +05:30
|
|
|
if(nPos != -1)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
aContent = rStr.getToken(0, '|', nPos);
|
2000-09-18 23:08:29 +00:00
|
|
|
bValid = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aTRUETxt = rStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType* pFldType,
|
2013-07-14 15:21:18 +02:00
|
|
|
const OUString& rCond,
|
|
|
|
const OUString& rTrue,
|
|
|
|
const OUString& rFalse,
|
2000-09-18 23:08:29 +00:00
|
|
|
sal_uInt16 nSub)
|
2007-09-27 07:48:37 +00:00
|
|
|
: SwField( pFldType ), aTRUETxt(rTrue), aFALSETxt(rFalse), aCond(rCond), nSubType(nSub),
|
|
|
|
bIsHidden(sal_True), bValid(sal_False)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
bCanToggle = !aCond.isEmpty();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwHiddenTxtField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-06-10 21:54:04 +02:00
|
|
|
// Type: !Hidden -> show always
|
|
|
|
// Hide -> evaluate condition
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
if( TYP_CONDTXTFLD == nSubType )
|
|
|
|
{
|
|
|
|
if( bValid )
|
|
|
|
return aContent;
|
|
|
|
|
|
|
|
if( bCanToggle && !bIsHidden )
|
|
|
|
return aTRUETxt;
|
|
|
|
}
|
|
|
|
else if( !((SwHiddenTxtFieldType*)GetTyp())->GetHiddenFlag() ||
|
|
|
|
( bCanToggle && bIsHidden ))
|
|
|
|
return aTRUETxt;
|
|
|
|
|
|
|
|
return aFALSETxt;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// get current field value and cache it
|
2000-09-18 23:08:29 +00:00
|
|
|
void SwHiddenTxtField::Evaluate(SwDoc* pDoc)
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE(pDoc, "Wo ist das Dokument Seniore");
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
if( TYP_CONDTXTFLD == nSubType )
|
|
|
|
{
|
|
|
|
SwNewDBMgr* pMgr = pDoc->GetNewDBMgr();
|
|
|
|
|
|
|
|
bValid = sal_False;
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString sTmpName = (bCanToggle && !bIsHidden) ? aTRUETxt : aFALSETxt;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
// Database expressions need to be different from normal text. Therefore, normal text is set
|
2013-06-10 21:54:04 +02:00
|
|
|
// in quotes. If the latter exist they will be removed. If not, check if potential DB name.
|
|
|
|
// Only if there are two or more dots and no quotes, we assume a database.
|
2013-07-14 15:21:18 +02:00
|
|
|
if (sTmpName.getLength()>1 &&
|
|
|
|
sTmpName.startsWith("\"") &&
|
|
|
|
sTmpName.endsWith("\""))
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
aContent = sTmpName.copy(1, sTmpName.getLength() - 2);
|
2000-09-18 23:08:29 +00:00
|
|
|
bValid = sal_True;
|
|
|
|
}
|
2013-07-14 15:21:18 +02:00
|
|
|
else if(sTmpName.indexOf('\"')<0 &&
|
2012-01-02 10:55:27 +00:00
|
|
|
comphelper::string::getTokenCount(sTmpName, '.') > 2)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
sTmpName = ::ReplacePoint(sTmpName);
|
|
|
|
if(sTmpName.startsWith("[") && sTmpName.endsWith("]"))
|
2013-06-10 21:54:04 +02:00
|
|
|
{ // remove brackets
|
2013-07-14 15:21:18 +02:00
|
|
|
sTmpName = sTmpName.copy(1, sTmpName.getLength() - 2);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( pMgr)
|
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString sDBName( GetDBName( sTmpName, pDoc ));
|
|
|
|
OUString sDataSource(sDBName.getToken(0, DB_DELIM));
|
|
|
|
OUString sDataTableOrQuery(sDBName.getToken(1, DB_DELIM));
|
|
|
|
if( pMgr->IsInMerge() && !sDBName.isEmpty() &&
|
2001-08-20 09:21:48 +00:00
|
|
|
pMgr->IsDataSourceOpen( sDataSource,
|
|
|
|
sDataTableOrQuery, sal_False))
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-08-20 09:21:48 +00:00
|
|
|
double fNumber;
|
2007-09-27 07:48:37 +00:00
|
|
|
sal_uInt32 nTmpFormat;
|
2001-08-20 09:21:48 +00:00
|
|
|
pMgr->GetMergeColumnCnt(GetColumnName( sTmpName ),
|
2007-09-27 07:48:37 +00:00
|
|
|
GetLanguage(), aContent, &fNumber, &nTmpFormat );
|
2001-08-20 09:21:48 +00:00
|
|
|
bValid = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2013-07-14 15:21:18 +02:00
|
|
|
else if( !sDBName.isEmpty() && !sDataSource.isEmpty() &&
|
|
|
|
!sDataTableOrQuery.isEmpty() )
|
2000-09-18 23:08:29 +00:00
|
|
|
bValid = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwHiddenTxtField::GetFieldName() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString aStr = SwFieldType::GetTypeStr(nSubType) +
|
|
|
|
" " + aCond + " " + aTRUETxt;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2010-10-04 17:14:34 +02:00
|
|
|
if (nSubType == TYP_CONDTXTFLD)
|
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
aStr += " : " + aFALSETxt;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 17:14:34 +02:00
|
|
|
return aStr;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwHiddenTxtField::Copy() const
|
|
|
|
{
|
|
|
|
SwHiddenTxtField* pFld =
|
|
|
|
new SwHiddenTxtField((SwHiddenTxtFieldType*)GetTyp(), aCond,
|
|
|
|
aTRUETxt, aFALSETxt);
|
|
|
|
pFld->bIsHidden = bIsHidden;
|
|
|
|
pFld->bValid = bValid;
|
|
|
|
pFld->aContent = aContent;
|
|
|
|
pFld->SetFormat(GetFormat());
|
|
|
|
pFld->nSubType = nSubType;
|
|
|
|
return pFld;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// set condition
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwHiddenTxtField::SetPar1(const OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
aCond = rStr;
|
2013-07-14 15:21:18 +02:00
|
|
|
bCanToggle = !aCond.isEmpty();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwHiddenTxtField::GetPar1() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return aCond;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// set True/False text
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwHiddenTxtField::SetPar2(const OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-07 16:52:06 +00:00
|
|
|
if (nSubType == TYP_CONDTXTFLD)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-07 16:52:06 +00:00
|
|
|
sal_Int32 nPos = rStr.indexOf('|');
|
2013-03-07 19:35:49 +05:30
|
|
|
if (nPos == -1)
|
2012-03-07 16:52:06 +00:00
|
|
|
aTRUETxt = rStr;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aTRUETxt = rStr.copy(0, nPos);
|
|
|
|
aFALSETxt = rStr.copy(nPos + 1);
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aTRUETxt = rStr;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// get True/False text
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString SwHiddenTxtField::GetPar2() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
if(nSubType != TYP_CONDTXTFLD)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
return aTRUETxt;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2013-07-14 15:21:18 +02:00
|
|
|
return aTRUETxt + "|" + aFALSETxt;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_uInt16 SwHiddenTxtField::GetSubType() const
|
|
|
|
{
|
|
|
|
return nSubType;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwHiddenTxtField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= aCond;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= aTRUETxt;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR3:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= aFALSETxt;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
2003-08-19 10:57:03 +00:00
|
|
|
case FIELD_PROP_PAR4 :
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= aContent;
|
2003-08-19 10:57:03 +00:00
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
{
|
|
|
|
sal_Bool bHidden = bIsHidden;
|
|
|
|
rAny.setValue(&bHidden, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2001-03-13 09:43:01 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwHiddenTxtField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2001-10-24 17:56:14 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2001-03-13 09:43:01 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sVal;
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= sVal;
|
|
|
|
SetPar1(sVal);
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2:
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= aTRUETxt;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR3:
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= aFALSETxt;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL1:
|
2001-03-13 09:43:01 +00:00
|
|
|
bIsHidden = *(sal_Bool*)rAny.getValue();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
2003-08-19 10:57:03 +00:00
|
|
|
case FIELD_PROP_PAR4:
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= aContent;
|
2011-01-17 15:06:54 +01:00
|
|
|
bValid = sal_True;
|
2003-08-19 10:57:03 +00:00
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2001-03-13 09:43:01 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwHiddenTxtField::GetColumnName(const OUString& rName)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
sal_Int32 nPos = rName.indexOf(DB_DELIM);
|
|
|
|
if( nPos>=0 )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
nPos = rName.indexOf(DB_DELIM, nPos + 1);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
if( nPos>=0 )
|
|
|
|
return rName.copy(nPos + 1);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return rName;
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwHiddenTxtField::GetDBName(const OUString& rName, SwDoc *pDoc)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
sal_Int32 nPos = rName.indexOf(DB_DELIM);
|
|
|
|
if( nPos>=0 )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
nPos = rName.indexOf(DB_DELIM, nPos + 1);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
if( nPos>=0 )
|
|
|
|
return rName.copy(0, nPos);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2013-07-14 15:21:18 +02:00
|
|
|
|
2001-02-21 11:45:25 +00:00
|
|
|
SwDBData aData = pDoc->GetDBData();
|
2013-07-14 15:21:18 +02:00
|
|
|
return aData.sDataSource + OUString(DB_DELIM) + aData.sCommand;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// field type for line height 0
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwHiddenParaFieldType::SwHiddenParaFieldType()
|
|
|
|
: SwFieldType( RES_HIDDENPARAFLD )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwHiddenParaFieldType::Copy() const
|
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
SwHiddenParaFieldType* pTyp = new SwHiddenParaFieldType();
|
|
|
|
return pTyp;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// field for line height 0
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
SwHiddenParaField::SwHiddenParaField(SwHiddenParaFieldType* pTyp, const OUString& rStr)
|
2007-09-27 07:48:37 +00:00
|
|
|
: SwField(pTyp), aCond(rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
bIsHidden = sal_False;
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwHiddenParaField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
return OUString();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwHiddenParaField::Copy() const
|
|
|
|
{
|
|
|
|
SwHiddenParaField* pFld = new SwHiddenParaField((SwHiddenParaFieldType*)GetTyp(), aCond);
|
|
|
|
pFld->bIsHidden = bIsHidden;
|
|
|
|
|
|
|
|
return pFld;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwHiddenParaField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch ( nWhichId )
|
2001-03-13 09:43:01 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= aCond;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
{
|
|
|
|
sal_Bool bHidden = bIsHidden;
|
|
|
|
rAny.setValue(&bHidden, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2001-03-13 09:43:01 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwHiddenParaField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch ( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= aCond;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL1:
|
2001-03-13 09:43:01 +00:00
|
|
|
bIsHidden = *(sal_Bool*)rAny.getValue();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// set condition
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwHiddenParaField::SetPar1(const OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
aCond = rStr;
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwHiddenParaField::GetPar1() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return aCond;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// PostIt field type
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2008-02-19 12:42:36 +00:00
|
|
|
SwPostItFieldType::SwPostItFieldType(SwDoc *pDoc)
|
|
|
|
: SwFieldType( RES_POSTITFLD ),mpDoc(pDoc)
|
2000-09-18 23:08:29 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
SwFieldType* SwPostItFieldType::Copy() const
|
|
|
|
{
|
2008-02-19 12:42:36 +00:00
|
|
|
return new SwPostItFieldType(mpDoc);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// PostIt field
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2008-02-19 12:42:36 +00:00
|
|
|
SwPostItField::SwPostItField( SwPostItFieldType* pT,
|
2013-07-14 15:21:18 +02:00
|
|
|
const OUString& rAuthor,
|
|
|
|
const OUString& rTxt,
|
|
|
|
const OUString& rInitials,
|
|
|
|
const OUString& rName,
|
|
|
|
const DateTime& rDateTime )
|
|
|
|
: SwField( pT )
|
|
|
|
, sTxt( rTxt )
|
|
|
|
, sAuthor( rAuthor )
|
|
|
|
, sInitials( rInitials )
|
|
|
|
, sName( rName )
|
|
|
|
, aDateTime( rDateTime )
|
|
|
|
, mpText(0)
|
|
|
|
, m_pTextObject(0)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
2008-02-19 12:42:36 +00:00
|
|
|
|
|
|
|
SwPostItField::~SwPostItField()
|
|
|
|
{
|
|
|
|
if ( m_pTextObject )
|
|
|
|
{
|
|
|
|
m_pTextObject->DisposeEditSource();
|
|
|
|
m_pTextObject->release();
|
|
|
|
}
|
2012-09-04 04:19:55 +00:00
|
|
|
|
|
|
|
delete mpText;
|
2008-02-19 12:42:36 +00:00
|
|
|
}
|
|
|
|
|
2013-03-27 16:08:37 +01:00
|
|
|
const SwFmtFld* SwPostItField::GetByName(SwDoc* pDoc, const OUString& rName)
|
|
|
|
{
|
|
|
|
const SwFldTypes* pFldTypes = pDoc->GetFldTypes();
|
|
|
|
sal_uInt16 nCount = pFldTypes->size();
|
|
|
|
for (sal_uInt16 nType = 0; nType < nCount; ++nType)
|
|
|
|
{
|
|
|
|
const SwFieldType *pCurType = (*pFldTypes)[nType];
|
|
|
|
SwIterator<SwFmtFld, SwFieldType> aIter(*pCurType);
|
|
|
|
for (const SwFmtFld* pCurFldFmt = aIter.First(); pCurFldFmt; pCurFldFmt = aIter.Next())
|
|
|
|
{
|
|
|
|
// Ignore the field if it's not an annotation or it doesn't have an anchor.
|
2013-09-24 15:03:38 +00:00
|
|
|
if (pCurFldFmt->GetField()->GetTyp()->Which() != RES_POSTITFLD || !pCurFldFmt->GetTxtFld())
|
2013-03-27 16:08:37 +01:00
|
|
|
continue;
|
|
|
|
|
2013-09-24 15:03:38 +00:00
|
|
|
const SwPostItField* pField = dynamic_cast<const SwPostItField*>(pCurFldFmt->GetField());
|
2013-03-27 16:08:37 +01:00
|
|
|
if (pField->GetName() == rName)
|
|
|
|
return pCurFldFmt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwPostItField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
return OUString();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2004-09-08 13:55:20 +00:00
|
|
|
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwPostItField::GetDescription() const
|
2004-09-08 13:55:20 +00:00
|
|
|
{
|
|
|
|
return SW_RES(STR_NOTE);
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
SwField* SwPostItField::Copy() const
|
|
|
|
{
|
2012-07-19 13:28:30 +02:00
|
|
|
SwPostItField* pRet = new SwPostItField( (SwPostItFieldType*)GetTyp(), sAuthor, sTxt, sInitials, sName,
|
|
|
|
aDateTime);
|
2008-02-19 12:42:36 +00:00
|
|
|
if (mpText)
|
CWS-TOOLING: integrate CWS aw063
2009-02-12 13:10:24 +0100 aw r267649 : #i99123# when a primitive is invisible, it is not sufficient to produce no output when decomposing, but to add invisible data using HitTestPrimitive2D. This is needed for the slideshow which relies on geometry data in MetaFiles when painting invisible objects
2009-02-12 13:08:39 +0100 aw r267648 : #i99123# do not ignore HitTestPrimitive2D, but draw empty rectangles instead. This is needed since Slideshow is based on getting MetaFile content when painting invisible objects
2009-02-11 16:04:28 +0100 aw r267620 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:04:10 +0100 aw r267619 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:03:56 +0100 aw r267618 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:03:39 +0100 aw r267617 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:03:21 +0100 aw r267615 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:02:48 +0100 aw r267614 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:02:24 +0100 aw r267613 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:02:01 +0100 aw r267612 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:01:32 +0100 aw r267611 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:01:05 +0100 aw r267610 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:00:15 +0100 aw r267608 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 11:27:33 +0100 aw r267585 : #i98788# added missing include for STL
2009-02-10 17:46:50 +0100 aw r267570 : #i98788# added reaction on pool destruction
2009-02-10 17:11:58 +0100 aw r267562 : #i98788# added messaging mechanism to register for pool destruction
2009-02-10 13:35:35 +0100 aw r267549 : #i98788# removing changes, too complicated and risky for 3.1
2009-02-10 12:13:48 +0100 aw r267546 : #i98788# 4th round
2009-02-10 12:13:37 +0100 aw r267545 : #i98788# 4th round
2009-02-10 12:13:26 +0100 aw r267544 : #i98788# 4th round
2009-02-10 12:13:14 +0100 aw r267543 : #i98788# 4th round
2009-02-10 12:13:03 +0100 aw r267542 : #i98788# 4th round
2009-02-10 12:12:50 +0100 aw r267541 : #i98788# 4th round
2009-02-10 12:12:37 +0100 aw r267540 : #i98788# 4th round
2009-02-08 14:38:22 +0100 aw r267495 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:38:06 +0100 aw r267494 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:37:48 +0100 aw r267493 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:37:17 +0100 aw r267492 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:56 +0100 aw r267491 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:44 +0100 aw r267490 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:29 +0100 aw r267489 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:16 +0100 aw r267488 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:02 +0100 aw r267487 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:35:46 +0100 aw r267486 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-05 12:20:39 +0100 aw r267415 : #i98788# 2nd batch of adaptions for SfxItemPoolHolder addition
2009-02-04 15:12:54 +0100 aw r267385 : #i98788# added newline at EOF
2009-02-04 13:26:04 +0100 aw r267379 : #i98788# make SfxItemPool holdable
2009-02-04 13:25:40 +0100 aw r267378 : #i98788# make SfxItemPool holdable
2009-02-04 13:25:08 +0100 aw r267377 : #i98788# make SfxItemPool holdable
2009-02-04 13:24:42 +0100 aw r267376 : #i98788# make SfxItemPool holdable
2009-02-04 13:23:14 +0100 aw r267375 : #i98788# make SfxItemPool holdable
2009-02-04 13:23:02 +0100 aw r267374 : #i98788# make SfxItemPool holdable
2009-01-29 17:08:31 +0100 aw r267159 : #i97628# completed the fix
2009-01-29 17:08:15 +0100 aw r267158 : #i97628# completed the fix
2009-01-29 14:09:07 +0100 aw r267132 : #i97628# Corrected usage of ParagraphData in headers
2009-01-29 14:06:58 +0100 iha r267131 : #i98344# incorrect font size in charts
2009-01-29 12:13:46 +0100 aw r267115 : #i97628# back to old state; triggers too many errors in other modules
2009-01-29 12:03:51 +0100 aw r267114 : #i97628# enabled exceptions due to STL vector include
2009-01-29 11:21:37 +0100 aw r267107 : #i97628# added needed include
2009-01-28 17:58:29 +0100 aw r267077 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-28 17:58:12 +0100 aw r267076 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-28 17:57:51 +0100 aw r267074 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-28 17:57:21 +0100 aw r267073 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-27 17:07:33 +0100 aw r267011 : #i98402# added support for ViewRange when exporting MetaFiles in ObjectContactOfPageView::DoProcessDisplay to avoid to paint too much
2009-01-27 11:45:48 +0100 aw r266973 : #i98404# Added a warning to a place where a conversion to rectangle should not be copied from
2009-01-26 21:44:36 +0100 iha r266949 : #i98497# 3D charts are rendered with wrong size
2009-01-26 20:47:07 +0100 aw r266947 : #i98404# handle BackgroundColorPrimitive2D directly in PixelRenderers and avoid AA under all circumstances
2009-01-26 14:50:36 +0100 aw r266926 : #i98386# secured cloning of SdrObject in IMapUserData by boost::shared_prt usage
2009-01-26 12:51:30 +0100 aw r266916 : #i96581# added separated FontStretching and fallback for small X!=Y scale differences
2009-01-23 16:14:55 +0100 aw r266834 : #i96475# added missing implementation of TextDecoratedPortionPrimitive2D::getB2DRange
2009-01-23 15:24:34 +0100 aw r266826 : #i98405# fixed fallback to DrawAlphaRect to use the correctly sized rectangle
2009-01-23 13:34:43 +0100 aw r266813 : #i96474# fixed impSplitSingleWords for an unexpected case
2009-01-23 10:47:31 +0100 aw r266786 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:47:20 +0100 aw r266785 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:47:09 +0100 aw r266783 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:46:58 +0100 aw r266782 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:46:48 +0100 aw r266781 : #i98289#,#i96474# tooling and new flags for tasks
2009-03-04 14:16:02 +00:00
|
|
|
pRet->SetTextObject( new OutlinerParaObject(*mpText) );
|
2008-02-19 12:42:36 +00:00
|
|
|
return pRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// set author
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwPostItField::SetPar1(const OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
sAuthor = rStr;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// get author
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwPostItField::GetPar1() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return sAuthor;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// set the PostIt's text
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwPostItField::SetPar2(const OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
sTxt = rStr;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// get the PostIt's text
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString SwPostItField::GetPar2() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-06-10 21:58:09 +02:00
|
|
|
return sTxt;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwPostItField::GetInitials() const
|
2012-07-13 21:42:28 +02:00
|
|
|
{
|
|
|
|
return sInitials;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwPostItField::SetName(const OUString& rName)
|
2012-07-19 13:28:30 +02:00
|
|
|
{
|
|
|
|
sName = rName;
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwPostItField::GetName() const
|
2012-07-19 13:28:30 +02:00
|
|
|
{
|
|
|
|
return sName;
|
|
|
|
}
|
|
|
|
|
2008-02-19 12:42:36 +00:00
|
|
|
const OutlinerParaObject* SwPostItField::GetTextObject() const
|
|
|
|
{
|
|
|
|
return mpText;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwPostItField::SetTextObject( OutlinerParaObject* pText )
|
|
|
|
{
|
|
|
|
delete mpText;
|
|
|
|
mpText = pText;
|
|
|
|
}
|
|
|
|
|
2013-05-08 18:12:32 +02:00
|
|
|
sal_Int32 SwPostItField::GetNumberOfParagraphs() const
|
2009-10-20 19:25:59 +02:00
|
|
|
{
|
|
|
|
return (mpText) ? mpText->Count() : 1;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2001-10-24 17:56:14 +00:00
|
|
|
{
|
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= sAuthor;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2:
|
2008-02-19 12:42:36 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= sTxt;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
2008-02-19 12:42:36 +00:00
|
|
|
}
|
2012-07-13 17:52:04 +02:00
|
|
|
case FIELD_PROP_PAR3:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= sInitials;
|
2012-07-13 17:52:04 +02:00
|
|
|
break;
|
2012-07-19 13:28:30 +02:00
|
|
|
case FIELD_PROP_PAR4:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= sName;
|
2012-07-19 13:28:30 +02:00
|
|
|
break;
|
2008-02-19 12:42:36 +00:00
|
|
|
case FIELD_PROP_TEXT:
|
|
|
|
{
|
|
|
|
if ( !m_pTextObject )
|
|
|
|
{
|
|
|
|
SwPostItFieldType* pGetType = (SwPostItFieldType*)GetTyp();
|
|
|
|
SwDoc* pDoc = pGetType->GetDoc();
|
2008-07-01 13:33:53 +00:00
|
|
|
SwTextAPIEditSource* pObj = new SwTextAPIEditSource( pDoc );
|
2008-02-19 12:42:36 +00:00
|
|
|
const_cast <SwPostItField*> (this)->m_pTextObject = new SwTextAPIObject( pObj );
|
|
|
|
m_pTextObject->acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( mpText )
|
|
|
|
m_pTextObject->SetText( *mpText );
|
2008-07-01 13:33:53 +00:00
|
|
|
else
|
|
|
|
m_pTextObject->SetString( sTxt );
|
2008-02-19 12:42:36 +00:00
|
|
|
|
|
|
|
uno::Reference < text::XText > xText( m_pTextObject );
|
|
|
|
rAny <<= xText;
|
|
|
|
break;
|
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_DATE:
|
|
|
|
{
|
|
|
|
util::Date aSetDate;
|
2008-02-19 12:42:36 +00:00
|
|
|
aSetDate.Day = aDateTime.GetDay();
|
|
|
|
aSetDate.Month = aDateTime.GetMonth();
|
|
|
|
aSetDate.Year = aDateTime.GetYear();
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny.setValue(&aSetDate, ::getCppuType((util::Date*)0));
|
|
|
|
}
|
|
|
|
break;
|
2008-02-19 12:42:36 +00:00
|
|
|
case FIELD_PROP_DATE_TIME:
|
|
|
|
{
|
|
|
|
util::DateTime DateTimeValue;
|
2013-03-17 08:36:26 +01:00
|
|
|
DateTimeValue.NanoSeconds = aDateTime.GetNanoSec();
|
2008-02-19 12:42:36 +00:00
|
|
|
DateTimeValue.Seconds = aDateTime.GetSec();
|
|
|
|
DateTimeValue.Minutes = aDateTime.GetMin();
|
|
|
|
DateTimeValue.Hours = aDateTime.GetHour();
|
|
|
|
DateTimeValue.Day = aDateTime.GetDay();
|
|
|
|
DateTimeValue.Month = aDateTime.GetMonth();
|
|
|
|
DateTimeValue.Year = aDateTime.GetYear();
|
|
|
|
rAny <<= DateTimeValue;
|
|
|
|
}
|
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2008-02-19 12:42:36 +00:00
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwPostItField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= sAuthor;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2:
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= sTxt;
|
2009-05-07 13:54:35 +00:00
|
|
|
//#i100374# new string via api, delete complex text object so SwPostItNote picks up the new string
|
|
|
|
if (mpText)
|
|
|
|
{
|
|
|
|
delete mpText;
|
|
|
|
mpText = 0;
|
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
2012-07-13 17:52:04 +02:00
|
|
|
case FIELD_PROP_PAR3:
|
|
|
|
rAny >>= sInitials;
|
|
|
|
break;
|
2012-07-19 13:28:30 +02:00
|
|
|
case FIELD_PROP_PAR4:
|
|
|
|
rAny >>= sName;
|
|
|
|
break;
|
2008-02-19 12:42:36 +00:00
|
|
|
case FIELD_PROP_TEXT:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("Not implemented!");
|
2008-02-19 12:42:36 +00:00
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_DATE:
|
|
|
|
if( rAny.getValueType() == ::getCppuType((util::Date*)0) )
|
|
|
|
{
|
|
|
|
util::Date aSetDate = *(util::Date*)rAny.getValue();
|
2008-02-19 12:42:36 +00:00
|
|
|
aDateTime = Date(aSetDate.Day, aSetDate.Month, aSetDate.Year);
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-02-19 12:42:36 +00:00
|
|
|
case FIELD_PROP_DATE_TIME:
|
|
|
|
{
|
|
|
|
util::DateTime aDateTimeValue;
|
|
|
|
if(!(rAny >>= aDateTimeValue))
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2013-03-17 08:36:26 +01:00
|
|
|
aDateTime.SetNanoSec(aDateTimeValue.NanoSeconds);
|
2008-02-19 12:42:36 +00:00
|
|
|
aDateTime.SetSec(aDateTimeValue.Seconds);
|
|
|
|
aDateTime.SetMin(aDateTimeValue.Minutes);
|
|
|
|
aDateTime.SetHour(aDateTimeValue.Hours);
|
|
|
|
aDateTime.SetDay(aDateTimeValue.Day);
|
|
|
|
aDateTime.SetMonth(aDateTimeValue.Month);
|
|
|
|
aDateTime.SetYear(aDateTimeValue.Year);
|
|
|
|
}
|
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2013-06-10 21:54:04 +02:00
|
|
|
|
|
|
|
// extended user information field type
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwExtUserFieldType::SwExtUserFieldType()
|
|
|
|
: SwFieldType( RES_EXTUSERFLD )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwExtUserFieldType::Copy() const
|
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
SwExtUserFieldType* pTyp = new SwExtUserFieldType;
|
|
|
|
return pTyp;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwExtUserFieldType::Expand(sal_uInt16 nSub, sal_uInt32 ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
sal_uInt16 nRet = USHRT_MAX;
|
|
|
|
switch(nSub)
|
|
|
|
{
|
2004-09-20 14:14:22 +00:00
|
|
|
case EU_FIRSTNAME: nRet = USER_OPT_FIRSTNAME; break;
|
|
|
|
case EU_NAME: nRet = USER_OPT_LASTNAME; break;
|
|
|
|
case EU_SHORTCUT: nRet = USER_OPT_ID; break;
|
2004-04-29 15:54:32 +00:00
|
|
|
|
|
|
|
case EU_COMPANY: nRet = USER_OPT_COMPANY; break;
|
|
|
|
case EU_STREET: nRet = USER_OPT_STREET; break;
|
|
|
|
case EU_TITLE: nRet = USER_OPT_TITLE; break;
|
|
|
|
case EU_POSITION: nRet = USER_OPT_POSITION; break;
|
|
|
|
case EU_PHONE_PRIVATE: nRet = USER_OPT_TELEPHONEHOME; break;
|
|
|
|
case EU_PHONE_COMPANY: nRet = USER_OPT_TELEPHONEWORK; break;
|
|
|
|
case EU_FAX: nRet = USER_OPT_FAX; break;
|
|
|
|
case EU_EMAIL: nRet = USER_OPT_EMAIL; break;
|
|
|
|
case EU_COUNTRY: nRet = USER_OPT_COUNTRY; break;
|
|
|
|
case EU_ZIP: nRet = USER_OPT_ZIP; break;
|
|
|
|
case EU_CITY: nRet = USER_OPT_CITY; break;
|
|
|
|
case EU_STATE: nRet = USER_OPT_STATE; break;
|
|
|
|
case EU_FATHERSNAME: nRet = USER_OPT_FATHERSNAME; break;
|
|
|
|
case EU_APARTMENT: nRet = USER_OPT_APARTMENT; break;
|
2010-11-25 17:08:45 +01:00
|
|
|
default: OSL_ENSURE( !this, "Field unknown");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
if( USHRT_MAX != nRet )
|
2004-04-29 15:54:32 +00:00
|
|
|
{
|
|
|
|
SvtUserOptions& rUserOpt = SW_MOD()->GetUserOptions();
|
2013-07-14 15:21:18 +02:00
|
|
|
return rUserOpt.GetToken( nRet );
|
2004-04-29 15:54:32 +00:00
|
|
|
}
|
2013-07-14 15:21:18 +02:00
|
|
|
return OUString();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// extended user information field
|
|
|
|
|
2007-09-27 07:48:37 +00:00
|
|
|
SwExtUserField::SwExtUserField(SwExtUserFieldType* pTyp, sal_uInt16 nSubTyp, sal_uInt32 nFmt) :
|
|
|
|
SwField(pTyp, nFmt), nType(nSubTyp)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
aContent = ((SwExtUserFieldType*)GetTyp())->Expand(nType, GetFormat());
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwExtUserField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if (!IsFixed())
|
|
|
|
((SwExtUserField*)this)->aContent = ((SwExtUserFieldType*)GetTyp())->Expand(nType, GetFormat());
|
|
|
|
|
|
|
|
return aContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwExtUserField::Copy() const
|
|
|
|
{
|
|
|
|
SwExtUserField* pFld = new SwExtUserField((SwExtUserFieldType*)GetTyp(), nType, GetFormat());
|
|
|
|
pFld->SetExpansion(aContent);
|
|
|
|
|
|
|
|
return pFld;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_uInt16 SwExtUserField::GetSubType() const
|
|
|
|
{
|
|
|
|
return nType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwExtUserField::SetSubType(sal_uInt16 nSub)
|
|
|
|
{
|
|
|
|
nType = nSub;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwExtUserField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= aContent;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_USHORT1:
|
|
|
|
{
|
|
|
|
sal_Int16 nTmp = nType;
|
|
|
|
rAny <<= nTmp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
{
|
|
|
|
sal_Bool bTmp = IsFixed();
|
|
|
|
rAny.setValue(&bTmp, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwExtUserField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny >>= aContent;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_USHORT1:
|
|
|
|
{
|
2007-11-12 15:23:31 +00:00
|
|
|
sal_Int16 nTmp = 0;
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny >>= nTmp;
|
|
|
|
nType = nTmp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
if( *(sal_Bool*)rAny.getValue() )
|
2000-09-18 23:08:29 +00:00
|
|
|
SetFormat(GetFormat() | AF_FIXED);
|
|
|
|
else
|
|
|
|
SetFormat(GetFormat() & ~AF_FIXED);
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// field type for relative page numbers
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwRefPageSetFieldType::SwRefPageSetFieldType()
|
|
|
|
: SwFieldType( RES_REFPAGESETFLD )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwRefPageSetFieldType::Copy() const
|
|
|
|
{
|
|
|
|
return new SwRefPageSetFieldType;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// overridden since there is nothing to update
|
2010-12-17 09:02:23 +01:00
|
|
|
void SwRefPageSetFieldType::Modify( const SfxPoolItem*, const SfxPoolItem * )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// field for relative page numbers
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2007-09-27 07:48:37 +00:00
|
|
|
SwRefPageSetField::SwRefPageSetField( SwRefPageSetFieldType* pTyp,
|
2000-09-18 23:08:29 +00:00
|
|
|
short nOff, sal_Bool bFlag )
|
2007-09-27 07:48:37 +00:00
|
|
|
: SwField( pTyp ), nOffset( nOff ), bOn( bFlag )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwRefPageSetField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
return OUString();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwRefPageSetField::Copy() const
|
|
|
|
{
|
|
|
|
return new SwRefPageSetField( (SwRefPageSetFieldType*)GetTyp(), nOffset, bOn );
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString SwRefPageSetField::GetPar2() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-01-20 13:55:09 +01:00
|
|
|
return OUString::number(GetOffset());
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwRefPageSetField::SetPar2(const OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-07 16:52:06 +00:00
|
|
|
SetOffset( (short) rStr.toInt32() );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwRefPageSetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2001-10-24 17:56:14 +00:00
|
|
|
{
|
|
|
|
case FIELD_PROP_BOOL1:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny.setValue(&bOn, ::getBooleanCppuType());
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_USHORT1:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= (sal_Int16)nOffset;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwRefPageSetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2001-10-24 17:56:14 +00:00
|
|
|
{
|
|
|
|
case FIELD_PROP_BOOL1:
|
2000-09-18 23:08:29 +00:00
|
|
|
bOn = *(sal_Bool*)rAny.getValue();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_USHORT1:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny >>=nOffset;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2013-06-10 21:54:04 +02:00
|
|
|
|
|
|
|
// relative page numbers - query field
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwRefPageGetFieldType::SwRefPageGetFieldType( SwDoc* pDc )
|
2007-09-27 07:48:37 +00:00
|
|
|
: SwFieldType( RES_REFPAGEGETFLD ), pDoc( pDc ), nNumberingType( SVX_NUM_ARABIC )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwRefPageGetFieldType::Copy() const
|
|
|
|
{
|
|
|
|
SwRefPageGetFieldType* pNew = new SwRefPageGetFieldType( pDoc );
|
2001-02-23 11:45:30 +00:00
|
|
|
pNew->nNumberingType = nNumberingType;
|
2000-09-18 23:08:29 +00:00
|
|
|
return pNew;
|
|
|
|
}
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
void SwRefPageGetFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-06-10 21:54:04 +02:00
|
|
|
// update all GetReference fields
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !pNew && !pOld && GetDepends() )
|
|
|
|
{
|
2013-06-10 21:54:04 +02:00
|
|
|
// first collect all SetPageRefFields
|
2012-07-13 15:42:51 +02:00
|
|
|
_SetGetExpFlds aTmpLst;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( MakeSetList( aTmpLst ) )
|
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwFmtFld,SwFieldType> aIter( *this );
|
|
|
|
for ( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
|
2013-06-10 21:54:04 +02:00
|
|
|
// update only the GetRef fields
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pFmtFld->GetTxtFld() )
|
|
|
|
UpdateField( pFmtFld->GetTxtFld(), aTmpLst );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// forward to text fields, they "expand" the text
|
2010-12-17 09:02:23 +01:00
|
|
|
NotifyClients( pOld, pNew );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_uInt16 SwRefPageGetFieldType::MakeSetList( _SetGetExpFlds& rTmpLst )
|
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwFmtFld,SwFieldType> aIter(*pDoc->GetSysFldType( RES_REFPAGESETFLD));
|
|
|
|
for ( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
|
|
|
|
{
|
2013-06-10 21:54:04 +02:00
|
|
|
// update only the GetRef fields
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwTxtFld* pTFld = pFmtFld->GetTxtFld();
|
|
|
|
if( pTFld )
|
|
|
|
{
|
|
|
|
const SwTxtNode& rTxtNd = pTFld->GetTxtNode();
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// Always the first! (in Tab-Headline, header/footer )
|
2000-09-18 23:08:29 +00:00
|
|
|
Point aPt;
|
2010-06-13 15:22:56 +02:00
|
|
|
const SwCntntFrm* pFrm = rTxtNd.getLayoutFrm( rTxtNd.GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
_SetGetExpFld* pNew;
|
|
|
|
|
2004-09-20 14:14:22 +00:00
|
|
|
if( !pFrm ||
|
|
|
|
pFrm->IsInDocBody() ||
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i31868#
|
2004-09-20 14:14:22 +00:00
|
|
|
// Check if pFrm is not yet connected to the layout.
|
|
|
|
!pFrm->FindPageFrm() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-06-10 21:54:04 +02:00
|
|
|
// create index for determination of the TextNode
|
2000-09-18 23:08:29 +00:00
|
|
|
SwNodeIndex aIdx( rTxtNd );
|
|
|
|
pNew = new _SetGetExpFld( aIdx, pTFld );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-10 21:54:04 +02:00
|
|
|
// create index for determination of the TextNode
|
2000-09-18 23:08:29 +00:00
|
|
|
SwPosition aPos( pDoc->GetNodes().GetEndOfPostIts() );
|
2011-11-24 00:52:07 +01:00
|
|
|
bool const bResult = GetBodyTxtNode( *pDoc, aPos, *pFrm );
|
|
|
|
OSL_ENSURE(bResult, "where is the Field?");
|
|
|
|
(void) bResult; // unused in non-debug
|
2000-09-18 23:08:29 +00:00
|
|
|
pNew = new _SetGetExpFld( aPos.nNode, pTFld,
|
|
|
|
&aPos.nContent );
|
|
|
|
}
|
|
|
|
|
2012-07-13 15:42:51 +02:00
|
|
|
if( !rTmpLst.insert( pNew ).second)
|
2000-09-18 23:08:29 +00:00
|
|
|
delete pNew;
|
|
|
|
}
|
2010-12-17 09:02:23 +01:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-07-13 15:42:51 +02:00
|
|
|
return rTmpLst.size();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwRefPageGetFieldType::UpdateField( SwTxtFld* pTxtFld,
|
|
|
|
_SetGetExpFlds& rSetList )
|
|
|
|
{
|
2013-09-24 15:03:38 +00:00
|
|
|
SwRefPageGetField* pGetFld = (SwRefPageGetField*)pTxtFld->GetFmtFld().GetField();
|
2013-07-14 15:21:18 +02:00
|
|
|
pGetFld->SetText( OUString() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// then search the correct RefPageSet field
|
2000-09-18 23:08:29 +00:00
|
|
|
SwTxtNode* pTxtNode = (SwTxtNode*)&pTxtFld->GetTxtNode();
|
|
|
|
if( pTxtNode->StartOfSectionIndex() >
|
|
|
|
pDoc->GetNodes().GetEndOfExtras().GetIndex() )
|
|
|
|
{
|
|
|
|
SwNodeIndex aIdx( *pTxtNode );
|
|
|
|
_SetGetExpFld aEndFld( aIdx, pTxtFld );
|
|
|
|
|
2012-07-13 15:42:51 +02:00
|
|
|
_SetGetExpFlds::const_iterator itLast = rSetList.lower_bound( &aEndFld );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-07-13 15:42:51 +02:00
|
|
|
if( itLast != rSetList.begin() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-08-10 22:35:46 +02:00
|
|
|
--itLast;
|
2013-09-24 15:03:38 +00:00
|
|
|
const SwTxtFld* pRefTxtFld = (*itLast)->GetTxtFld();
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwRefPageSetField* pSetFld =
|
2013-09-24 15:03:38 +00:00
|
|
|
(SwRefPageSetField*)pRefTxtFld->GetFmtFld().GetField();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pSetFld->IsOn() )
|
|
|
|
{
|
2013-06-10 21:54:04 +02:00
|
|
|
// determine the correct offset
|
2000-09-18 23:08:29 +00:00
|
|
|
Point aPt;
|
2010-06-13 15:22:56 +02:00
|
|
|
const SwCntntFrm* pFrm = pTxtNode->getLayoutFrm( pTxtNode->GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False );
|
|
|
|
const SwCntntFrm* pRefFrm = pRefTxtFld->GetTxtNode().getLayoutFrm( pRefTxtFld->GetTxtNode().GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False );
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwPageFrm* pPgFrm = 0;
|
|
|
|
sal_uInt16 nDiff = ( pFrm && pRefFrm )
|
|
|
|
? (pPgFrm = pFrm->FindPageFrm())->GetPhyPageNum() -
|
|
|
|
pRefFrm->FindPageFrm()->GetPhyPageNum() + 1
|
|
|
|
: 1;
|
|
|
|
|
|
|
|
sal_uInt32 nTmpFmt = SVX_NUM_PAGEDESC == pGetFld->GetFormat()
|
|
|
|
? ( !pPgFrm
|
2007-09-27 07:48:37 +00:00
|
|
|
? (sal_uInt32)SVX_NUM_ARABIC
|
2001-02-23 11:45:30 +00:00
|
|
|
: pPgFrm->GetPageDesc()->GetNumType().GetNumberingType() )
|
2000-09-18 23:08:29 +00:00
|
|
|
: pGetFld->GetFormat();
|
2013-04-11 00:21:40 -03:00
|
|
|
short nPageNum = static_cast<short>(std::max(0, pSetFld->GetOffset() + (short)nDiff));
|
2000-09-18 23:08:29 +00:00
|
|
|
pGetFld->SetText( FormatNumber( nPageNum, nTmpFmt ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-10 21:54:04 +02:00
|
|
|
// start formatting
|
2013-09-24 15:03:38 +00:00
|
|
|
((SwFmtFld&)pTxtFld->GetFmtFld()).ModifyNotification( 0, 0 );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// queries for relative page numbering
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2007-09-27 07:48:37 +00:00
|
|
|
SwRefPageGetField::SwRefPageGetField( SwRefPageGetFieldType* pTyp,
|
2000-09-18 23:08:29 +00:00
|
|
|
sal_uInt32 nFmt )
|
2007-09-27 07:48:37 +00:00
|
|
|
: SwField( pTyp, nFmt )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwRefPageGetField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return sTxt;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwRefPageGetField::Copy() const
|
|
|
|
{
|
|
|
|
SwRefPageGetField* pCpy = new SwRefPageGetField(
|
|
|
|
(SwRefPageGetFieldType*)GetTyp(), GetFormat() );
|
|
|
|
pCpy->SetText( sTxt );
|
|
|
|
return pCpy;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwRefPageGetField::ChangeExpansion( const SwFrm* pFrm,
|
|
|
|
const SwTxtFld* pFld )
|
|
|
|
{
|
2013-06-10 21:54:04 +02:00
|
|
|
// only fields in Footer, Header, FootNote, Flys
|
2000-09-18 23:08:29 +00:00
|
|
|
SwTxtNode* pTxtNode = (SwTxtNode*)&pFld->GetTxtNode();
|
|
|
|
SwRefPageGetFieldType* pGetType = (SwRefPageGetFieldType*)GetTyp();
|
|
|
|
SwDoc* pDoc = pGetType->GetDoc();
|
|
|
|
if( pFld->GetTxtNode().StartOfSectionIndex() >
|
|
|
|
pDoc->GetNodes().GetEndOfExtras().GetIndex() )
|
|
|
|
return;
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
sTxt = OUString();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
OSL_ENSURE( !pFrm->IsInDocBody(), "Flag incorrect, frame is in DocBody" );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// collect all SetPageRefFields
|
2012-07-13 15:42:51 +02:00
|
|
|
_SetGetExpFlds aTmpLst;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !pGetType->MakeSetList( aTmpLst ) )
|
|
|
|
return ;
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// create index for determination of the TextNode
|
2000-09-18 23:08:29 +00:00
|
|
|
SwPosition aPos( SwNodeIndex( pDoc->GetNodes() ) );
|
|
|
|
pTxtNode = (SwTxtNode*) GetBodyTxtNode( *pDoc, aPos, *pFrm );
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// If no layout exists, ChangeExpansion is called for header and
|
|
|
|
// footer lines via layout formatting without existing TxtNode.
|
2000-09-18 23:08:29 +00:00
|
|
|
if(!pTxtNode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_SetGetExpFld aEndFld( aPos.nNode, pFld, &aPos.nContent );
|
|
|
|
|
2012-07-13 15:42:51 +02:00
|
|
|
_SetGetExpFlds::const_iterator itLast = aTmpLst.lower_bound( &aEndFld );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-07-13 15:42:51 +02:00
|
|
|
if( itLast == aTmpLst.begin() )
|
2013-06-10 21:54:04 +02:00
|
|
|
return; // there is no corresponding set-field in front
|
2012-08-10 22:35:46 +02:00
|
|
|
--itLast;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-09-24 15:03:38 +00:00
|
|
|
const SwTxtFld* pRefTxtFld = (*itLast)->GetTxtFld();
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwRefPageSetField* pSetFld =
|
2013-09-24 15:03:38 +00:00
|
|
|
(SwRefPageSetField*)pRefTxtFld->GetFmtFld().GetField();
|
2003-04-28 14:17:09 +00:00
|
|
|
Point aPt;
|
2010-06-13 15:22:56 +02:00
|
|
|
const SwCntntFrm* pRefFrm = pRefTxtFld ? pRefTxtFld->GetTxtNode().getLayoutFrm( pFrm->getRootFrm(), &aPt, 0, sal_False ) : 0;
|
2003-04-28 14:17:09 +00:00
|
|
|
if( pSetFld->IsOn() && pRefFrm )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-06-10 21:54:04 +02:00
|
|
|
// determine the correct offset
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwPageFrm* pPgFrm = pFrm->FindPageFrm();
|
|
|
|
sal_uInt16 nDiff = pPgFrm->GetPhyPageNum() -
|
|
|
|
pRefFrm->FindPageFrm()->GetPhyPageNum() + 1;
|
|
|
|
|
2013-09-24 15:03:38 +00:00
|
|
|
SwRefPageGetField* pGetFld = (SwRefPageGetField*)pFld->GetFmtFld().GetField();
|
2000-09-18 23:08:29 +00:00
|
|
|
sal_uInt32 nTmpFmt = SVX_NUM_PAGEDESC == pGetFld->GetFormat()
|
2001-02-23 11:45:30 +00:00
|
|
|
? pPgFrm->GetPageDesc()->GetNumType().GetNumberingType()
|
2000-09-18 23:08:29 +00:00
|
|
|
: pGetFld->GetFormat();
|
2013-04-11 00:21:40 -03:00
|
|
|
short nPageNum = static_cast<short>(std::max(0, pSetFld->GetOffset() + (short)nDiff ));
|
2000-09-18 23:08:29 +00:00
|
|
|
pGetFld->SetText( FormatNumber( nPageNum, nTmpFmt ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwRefPageGetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2002-01-18 08:45:31 +00:00
|
|
|
case FIELD_PROP_USHORT1:
|
|
|
|
rAny <<= (sal_Int16)GetFormat();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
2002-01-18 08:45:31 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= sTxt;
|
2002-01-18 08:45:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwRefPageGetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2002-01-18 08:45:31 +00:00
|
|
|
case FIELD_PROP_USHORT1:
|
2001-10-24 17:56:14 +00:00
|
|
|
{
|
2007-11-12 15:23:31 +00:00
|
|
|
sal_Int16 nSet = 0;
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny >>= nSet;
|
|
|
|
if(nSet <= SVX_NUM_PAGEDESC )
|
|
|
|
SetFormat(nSet);
|
2008-04-22 13:58:09 +00:00
|
|
|
else {
|
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-01-18 08:45:31 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny >>= sTxt;
|
2002-01-18 08:45:31 +00:00
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// field type to jump to and edit
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwJumpEditFieldType::SwJumpEditFieldType( SwDoc* pD )
|
|
|
|
: SwFieldType( RES_JUMPEDITFLD ), pDoc( pD ), aDep( this, 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwJumpEditFieldType::Copy() const
|
|
|
|
{
|
|
|
|
return new SwJumpEditFieldType( pDoc );
|
|
|
|
}
|
|
|
|
|
|
|
|
SwCharFmt* SwJumpEditFieldType::GetCharFmt()
|
|
|
|
{
|
|
|
|
SwCharFmt* pFmt = pDoc->GetCharFmtFromPool( RES_POOLCHR_JUMPEDIT );
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// not registered yet?
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !aDep.GetRegisteredIn() )
|
2013-06-10 21:54:04 +02:00
|
|
|
pFmt->Add( &aDep ); // register
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
return pFmt;
|
|
|
|
}
|
|
|
|
|
2007-09-27 07:48:37 +00:00
|
|
|
SwJumpEditField::SwJumpEditField( SwJumpEditFieldType* pTyp, sal_uInt32 nForm,
|
2013-07-14 15:21:18 +02:00
|
|
|
const OUString& rTxt, const OUString& rHelp )
|
2007-09-27 07:48:37 +00:00
|
|
|
: SwField( pTyp, nForm ), sTxt( rTxt ), sHelp( rHelp )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwJumpEditField::Expand() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-07-14 15:21:18 +02:00
|
|
|
return "<" + sTxt + ">";
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwJumpEditField::Copy() const
|
|
|
|
{
|
|
|
|
return new SwJumpEditField( (SwJumpEditFieldType*)GetTyp(), GetFormat(),
|
|
|
|
sTxt, sHelp );
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// get place holder text
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwJumpEditField::GetPar1() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return sTxt;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// set place holder text
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwJumpEditField::SetPar1(const OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
sTxt = rStr;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// get hint text
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString SwJumpEditField::GetPar2() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return sHelp;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
/// set hint text
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwJumpEditField::SetPar2(const OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
sHelp = rStr;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwJumpEditField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_USHORT1:
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
sal_Int16 nRet;
|
|
|
|
switch( GetFormat() )
|
|
|
|
{
|
2000-09-18 23:08:29 +00:00
|
|
|
case JE_FMT_TABLE: nRet = text::PlaceholderType::TABLE; break;
|
|
|
|
case JE_FMT_FRAME: nRet = text::PlaceholderType::TEXTFRAME; break;
|
|
|
|
case JE_FMT_GRAPHIC:nRet = text::PlaceholderType::GRAPHIC; break;
|
2001-10-24 17:56:14 +00:00
|
|
|
case JE_FMT_OLE: nRet = text::PlaceholderType::OBJECT; break;
|
|
|
|
default:
|
|
|
|
nRet = text::PlaceholderType::TEXT; break;
|
|
|
|
}
|
|
|
|
rAny <<= nRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR1 :
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= sHelp;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2 :
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= sTxt;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwJumpEditField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_USHORT1:
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
//JP 24.10.2001: int32 because in UnoField.cxx a putvalue is
|
|
|
|
// called with a int32 value! But normally we need
|
|
|
|
// here only a int16
|
2007-11-12 15:23:31 +00:00
|
|
|
sal_Int32 nSet = 0;
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny >>= nSet;
|
|
|
|
switch( nSet )
|
|
|
|
{
|
|
|
|
case text::PlaceholderType::TEXT : SetFormat(JE_FMT_TEXT); break;
|
|
|
|
case text::PlaceholderType::TABLE : SetFormat(JE_FMT_TABLE); break;
|
|
|
|
case text::PlaceholderType::TEXTFRAME: SetFormat(JE_FMT_FRAME); break;
|
|
|
|
case text::PlaceholderType::GRAPHIC : SetFormat(JE_FMT_GRAPHIC); break;
|
|
|
|
case text::PlaceholderType::OBJECT : SetFormat(JE_FMT_OLE); break;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR1 :
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= sHelp;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2 :
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= sTxt;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-01-18 13:08:36 +00:00
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// combined character field type
|
2001-01-18 13:08:36 +00:00
|
|
|
|
|
|
|
SwCombinedCharFieldType::SwCombinedCharFieldType()
|
|
|
|
: SwFieldType( RES_COMBINED_CHARS )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwCombinedCharFieldType::Copy() const
|
|
|
|
{
|
|
|
|
return new SwCombinedCharFieldType;
|
|
|
|
}
|
|
|
|
|
2013-06-10 21:54:04 +02:00
|
|
|
// combined character field
|
2001-01-18 13:08:36 +00:00
|
|
|
|
|
|
|
SwCombinedCharField::SwCombinedCharField( SwCombinedCharFieldType* pFTyp,
|
2013-07-14 15:21:18 +02:00
|
|
|
const OUString& rChars )
|
2001-01-18 13:08:36 +00:00
|
|
|
: SwField( pFTyp, 0 ),
|
2013-07-25 10:06:19 +03:00
|
|
|
sCharacters( rChars.copy( 0, std::min<sal_Int32>(rChars.getLength(), MAX_COMBINED_CHARACTERS) ))
|
2001-01-18 13:08:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwCombinedCharField::Expand() const
|
2001-01-18 13:08:36 +00:00
|
|
|
{
|
|
|
|
return sCharacters;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwCombinedCharField::Copy() const
|
|
|
|
{
|
|
|
|
return new SwCombinedCharField( (SwCombinedCharFieldType*)GetTyp(),
|
|
|
|
sCharacters );
|
|
|
|
}
|
|
|
|
|
2013-07-14 15:21:18 +02:00
|
|
|
OUString SwCombinedCharField::GetPar1() const
|
2001-01-18 13:08:36 +00:00
|
|
|
{
|
|
|
|
return sCharacters;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SwCombinedCharField::SetPar1(const OUString& rStr)
|
2001-01-18 13:08:36 +00:00
|
|
|
{
|
2012-03-08 16:01:09 +00:00
|
|
|
sCharacters = rStr.copy(0, std::min<sal_Int32>(rStr.getLength(), MAX_COMBINED_CHARACTERS));
|
2001-01-18 13:08:36 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 15:23:52 +01:00
|
|
|
bool SwCombinedCharField::QueryValue( uno::Any& rAny,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nWhichId ) const
|
2001-01-18 13:08:36 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2001-10-24 17:56:14 +00:00
|
|
|
{
|
|
|
|
case FIELD_PROP_PAR1:
|
2013-07-14 15:21:18 +02:00
|
|
|
rAny <<= sCharacters;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2001-01-18 13:08:36 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 15:23:52 +01:00
|
|
|
bool SwCombinedCharField::PutValue( const uno::Any& rAny,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nWhichId )
|
2001-01-18 13:08:36 +00:00
|
|
|
{
|
2007-09-27 07:48:37 +00:00
|
|
|
switch( nWhichId )
|
2001-01-18 13:08:36 +00:00
|
|
|
{
|
2012-03-07 16:52:06 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sTmp;
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= sTmp;
|
|
|
|
SetPar1(sTmp);
|
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
2012-03-07 16:52:06 +00:00
|
|
|
default:
|
|
|
|
OSL_FAIL("illegal property");
|
2001-01-18 13:08:36 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2001-01-18 13:08:36 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|