2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-27 16:10:40 +00: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:16:46 +00:00
|
|
|
|
2011-03-04 07:38:16 -08:00
|
|
|
#include <vector>
|
|
|
|
#include <boost/ptr_container/ptr_vector.hpp>
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/outliner.hxx>
|
2010-01-13 22:25:07 +01:00
|
|
|
#include <sfx2/linkmgr.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <svx/svdotext.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/outlobj.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/urihelper.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/xmlcnitm.hxx>
|
2002-10-31 12:27:11 +00:00
|
|
|
#include <svx/svditer.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2014-04-14 17:55:19 +02:00
|
|
|
#include "Annotation.hxx"
|
|
|
|
#include "notifydocumentevent.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "sdpage.hxx"
|
|
|
|
#include "glob.hxx"
|
|
|
|
#include "glob.hrc"
|
|
|
|
#include "drawdoc.hxx"
|
|
|
|
#include "stlpool.hxx"
|
|
|
|
#include "pglink.hxx"
|
2002-10-31 12:27:11 +00:00
|
|
|
#include "anminfo.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
#include "../ui/inc/strings.hrc"
|
2004-01-20 09:28:24 +00:00
|
|
|
#include "../ui/inc/DrawDocShell.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-08-06 07:34:08 +00:00
|
|
|
#include <tools/tenccvt.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/itemset.hxx>
|
2013-12-10 17:20:34 +05:30
|
|
|
#include <rtl/strbuf.hxx>
|
2001-08-06 07:34:08 +00:00
|
|
|
|
2004-03-30 14:44:57 +00:00
|
|
|
using namespace ::sd;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::com::sun::star;
|
2009-09-16 13:55:36 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::office;
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
2013-03-01 10:54:57 +01:00
|
|
|
|* Sets: names of layout, master page links and templates for presentation
|
|
|
|
|* objects
|
2000-09-18 23:16:46 +00:00
|
|
|
|*
|
2013-03-01 10:54:57 +01:00
|
|
|
|* Preconditions: - The page has to know the correct model!
|
|
|
|
|* - The corresponding master page has to be in the model.
|
|
|
|
|* - The corresponding style sheets have to be in the style sheet
|
|
|
|
|* pool.
|
2000-09-18 23:16:46 +00:00
|
|
|
|*
|
2013-03-01 10:54:57 +01:00
|
|
|
|* bReplaceStyleSheets = sal_True : Named style sheets are replaced
|
|
|
|
|* sal_False: All style sheets are reassigned
|
2000-09-18 23:16:46 +00:00
|
|
|
|*
|
2013-03-01 10:54:57 +01:00
|
|
|
|* bSetMasterPage = sal_True : search and assign master page
|
2000-09-18 23:16:46 +00:00
|
|
|
|*
|
2013-03-01 10:54:57 +01:00
|
|
|
|* bReverseOrder = sal_False: search master page from head to tail
|
|
|
|
|* sal_True : search master page from tail to head
|
|
|
|
|* (for undo operations)
|
2000-09-18 23:16:46 +00:00
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2013-09-05 14:22:12 +02:00
|
|
|
void SdPage::SetPresentationLayout(const OUString& rLayoutName,
|
2014-04-24 10:52:02 +02:00
|
|
|
bool bReplaceStyleSheets,
|
|
|
|
bool bSetMasterPage,
|
|
|
|
bool bReverseOrder)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
/*********************************************************************
|
2013-03-01 10:54:57 +01:00
|
|
|
|* Name of the layout of the page
|
2000-09-18 23:16:46 +00:00
|
|
|
\********************************************************************/
|
2012-09-10 23:42:29 +01:00
|
|
|
OUString aOldLayoutName(maLayoutName); // merken
|
|
|
|
OUStringBuffer aBuf(rLayoutName);
|
|
|
|
aBuf.append(SD_LT_SEPARATOR).append(SdResId(STR_LAYOUT_OUTLINE).toString());
|
|
|
|
maLayoutName = aBuf.makeStringAndClear();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
2013-03-01 10:54:57 +01:00
|
|
|
|* search and replace master page if necessary
|
2000-09-18 23:16:46 +00:00
|
|
|
\********************************************************************/
|
|
|
|
if (bSetMasterPage && !IsMasterPage())
|
|
|
|
{
|
|
|
|
SdPage* pMaster;
|
2004-08-31 12:48:34 +00:00
|
|
|
SdPage* pFoundMaster = 0;
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 nMaster = 0;
|
|
|
|
sal_uInt16 nMasterCount = pModel->GetMasterPageCount();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if( !bReverseOrder )
|
|
|
|
{
|
|
|
|
for ( nMaster = 0; nMaster < nMasterCount; nMaster++ )
|
|
|
|
{
|
2004-08-31 12:48:34 +00:00
|
|
|
pMaster = static_cast<SdPage*>(pModel->GetMasterPage(nMaster));
|
2006-12-12 15:33:34 +00:00
|
|
|
if (pMaster->GetPageKind() == mePageKind && pMaster->GetLayoutName() == maLayoutName)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-08-31 12:48:34 +00:00
|
|
|
pFoundMaster = pMaster;
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-07-12 13:56:30 +00:00
|
|
|
for ( nMaster = nMasterCount; nMaster > 0; nMaster-- )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-08-31 12:48:34 +00:00
|
|
|
pMaster = static_cast<SdPage*>(pModel->GetMasterPage(nMaster - 1));
|
2006-12-12 15:33:34 +00:00
|
|
|
if (pMaster->GetPageKind() == mePageKind && pMaster->GetLayoutName() == maLayoutName)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-08-31 12:48:34 +00:00
|
|
|
pFoundMaster = pMaster;
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-31 12:48:34 +00:00
|
|
|
DBG_ASSERT(pFoundMaster, "Masterpage for presentation layout not found!");
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-08-31 12:48:34 +00:00
|
|
|
// this should never happen, but we play failsafe here
|
|
|
|
if( pFoundMaster == 0 )
|
2006-12-12 15:33:34 +00:00
|
|
|
pFoundMaster = static_cast< SdDrawDocument *>(pModel)->GetSdPage( 0, mePageKind );
|
2004-08-31 12:48:34 +00:00
|
|
|
|
|
|
|
if( pFoundMaster )
|
|
|
|
TRG_SetMasterPage(*pFoundMaster);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2013-03-01 10:54:57 +01:00
|
|
|
|* templates for presentation objects
|
2000-09-18 23:16:46 +00:00
|
|
|
\********************************************************************/
|
2013-03-01 10:54:57 +01:00
|
|
|
// list with:
|
|
|
|
// - pointer to templates for outline text object (old and new templates)
|
|
|
|
// - replace-data for OutlinerParaObject
|
2011-03-04 07:38:16 -08:00
|
|
|
std::vector<SfxStyleSheetBase*> aOutlineStyles;
|
|
|
|
std::vector<SfxStyleSheetBase*> aOldOutlineStyles;
|
|
|
|
boost::ptr_vector<StyleReplaceData> aReplList;
|
|
|
|
bool bListsFilled = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2014-08-16 12:59:11 +02:00
|
|
|
const size_t nObjCount = GetObjCount();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2014-08-16 12:59:11 +02:00
|
|
|
for (size_t nObj = 0; nObj < nObjCount; ++nObj)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2014-11-11 07:52:45 +02:00
|
|
|
SdrTextObj* pObj = static_cast<SdrTextObj*>( GetObj(nObj) );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (pObj->GetObjInventor() == SdrInventor &&
|
|
|
|
pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
|
|
|
|
{
|
|
|
|
if (!bListsFilled || !bReplaceStyleSheets)
|
|
|
|
{
|
2013-09-18 15:50:00 +02:00
|
|
|
OUString aFullName;
|
|
|
|
OUString aOldFullName;
|
2000-09-18 23:16:46 +00:00
|
|
|
SfxStyleSheetBase* pSheet = NULL;
|
|
|
|
SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
|
|
|
|
|
2008-06-06 10:57:39 +00:00
|
|
|
for (sal_Int16 i = -1; i < 9; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2013-09-19 10:37:30 +01:00
|
|
|
aOldFullName = aOldLayoutName + " " +
|
2014-01-29 13:24:31 +01:00
|
|
|
OUString::number( (i <= 0 ) ? 1 : i + 1 );
|
2013-09-19 10:37:30 +01:00
|
|
|
aFullName = maLayoutName + " " +
|
2014-01-29 13:24:31 +01:00
|
|
|
OUString::number( (i <= 0 ) ? 1 : i + 1);
|
2008-03-12 10:27:53 +00:00
|
|
|
pSheet = pStShPool->Find(aOldFullName, SD_STYLE_FAMILY_MASTERPAGE);
|
2013-03-11 22:51:42 +01:00
|
|
|
DBG_ASSERT(pSheet, "Old outline style sheet not found");
|
2011-03-04 07:38:16 -08:00
|
|
|
aOldOutlineStyles.push_back(pSheet);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2008-03-12 10:27:53 +00:00
|
|
|
pSheet = pStShPool->Find(aFullName, SD_STYLE_FAMILY_MASTERPAGE);
|
2013-03-11 22:51:42 +01:00
|
|
|
DBG_ASSERT(pSheet, "New outline style sheet not found");
|
2011-03-04 07:38:16 -08:00
|
|
|
aOutlineStyles.push_back(pSheet);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (bReplaceStyleSheets && pSheet)
|
|
|
|
{
|
2013-03-01 10:54:57 +01:00
|
|
|
// Replace instead Set
|
2000-09-18 23:16:46 +00:00
|
|
|
StyleReplaceData* pReplData = new StyleReplaceData;
|
|
|
|
pReplData->nNewFamily = pSheet->GetFamily();
|
|
|
|
pReplData->nFamily = pSheet->GetFamily();
|
|
|
|
pReplData->aNewName = aFullName;
|
|
|
|
pReplData->aName = aOldFullName;
|
2011-03-04 07:38:16 -08:00
|
|
|
aReplList.push_back(pReplData);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-07-19 07:53:08 +00:00
|
|
|
OutlinerParaObject* pOPO = ((SdrTextObj*)pObj)->GetOutlinerParaObject();
|
|
|
|
|
|
|
|
if( pOPO )
|
2008-03-12 10:27:53 +00:00
|
|
|
pOPO->SetStyleSheets( i, aFullName, SD_STYLE_FAMILY_MASTERPAGE );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-04 07:38:16 -08:00
|
|
|
bListsFilled = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-03-04 07:38:16 -08:00
|
|
|
SfxStyleSheet* pSheet = NULL;
|
|
|
|
SfxStyleSheet* pOldSheet = NULL;
|
|
|
|
|
|
|
|
std::vector<SfxStyleSheetBase*>::iterator iterOut = aOutlineStyles.begin();
|
|
|
|
std::vector<SfxStyleSheetBase*>::iterator iterOldOut = aOldOutlineStyles.begin();
|
|
|
|
|
|
|
|
while (iterOut != aOutlineStyles.end())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-10-26 15:05:27 +03:00
|
|
|
pSheet = static_cast<SfxStyleSheet*>(*iterOut);
|
|
|
|
pOldSheet = static_cast<SfxStyleSheet*>(*iterOldOut);
|
2011-03-04 07:38:16 -08:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
if (pSheet != pOldSheet)
|
|
|
|
{
|
2014-08-19 20:49:17 +01:00
|
|
|
if (pOldSheet)
|
|
|
|
pObj->EndListening(*pOldSheet);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2014-08-19 20:49:17 +01:00
|
|
|
if (pSheet && !pObj->IsListening(*pSheet))
|
2000-09-18 23:16:46 +00:00
|
|
|
pObj->StartListening(*pSheet);
|
|
|
|
}
|
|
|
|
|
2011-03-04 07:38:16 -08:00
|
|
|
++iterOut;
|
|
|
|
++iterOldOut;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OutlinerParaObject* pOPO = ((SdrTextObj*)pObj)->GetOutlinerParaObject();
|
|
|
|
if ( bReplaceStyleSheets && pOPO )
|
|
|
|
{
|
2011-03-04 07:38:16 -08:00
|
|
|
boost::ptr_vector<StyleReplaceData>::const_iterator it = aReplList.begin();
|
|
|
|
while (it != aReplList.end())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-03-04 07:38:16 -08:00
|
|
|
pOPO->ChangeStyleSheets( it->aName, it->nFamily, it->aNewName, it->nNewFamily );
|
|
|
|
++it;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pObj->GetObjInventor() == SdrInventor &&
|
|
|
|
pObj->GetObjIdentifier() == OBJ_TITLETEXT)
|
|
|
|
{
|
2013-03-01 10:54:57 +01:00
|
|
|
// We do net get PresObjKind via GetPresObjKind() since there are
|
|
|
|
// only PresObjListe considered. But we want to consider all "Title
|
|
|
|
// objects" here (paste from clipboard etc.)
|
2000-09-18 23:16:46 +00:00
|
|
|
SfxStyleSheet* pSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE);
|
|
|
|
|
|
|
|
if (pSheet)
|
2014-01-28 20:00:21 +01:00
|
|
|
pObj->SetStyleSheet(pSheet, true);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SfxStyleSheet* pSheet = GetStyleSheetForPresObj(GetPresObjKind(pObj));
|
|
|
|
|
|
|
|
if (pSheet)
|
2014-01-28 20:00:21 +01:00
|
|
|
pObj->SetStyleSheet(pSheet, true);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-04-26 16:11:09 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
2013-03-01 10:54:57 +01:00
|
|
|
|* disconnect outline text object from templates for outline levels
|
2000-09-18 23:16:46 +00:00
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
void SdPage::EndListenOutlineText()
|
|
|
|
{
|
|
|
|
SdrObject* pOutlineTextObj = GetPresObj(PRESOBJ_OUTLINE);
|
|
|
|
|
|
|
|
if (pOutlineTextObj)
|
|
|
|
{
|
2014-11-11 07:52:45 +02:00
|
|
|
SdStyleSheetPool* pSPool = static_cast<SdStyleSheetPool*>(pModel->GetStyleSheetPool());
|
2013-03-11 22:51:42 +01:00
|
|
|
DBG_ASSERT(pSPool, "StyleSheetPool missing");
|
2013-09-18 15:50:00 +02:00
|
|
|
OUString aTrueLayoutName(maLayoutName);
|
2013-09-19 13:23:24 +02:00
|
|
|
sal_Int32 nIndex = aTrueLayoutName.indexOf( SD_LT_SEPARATOR );
|
|
|
|
if( nIndex != -1 )
|
|
|
|
aTrueLayoutName = aTrueLayoutName.copy(0, nIndex);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-03-04 21:49:59 -08:00
|
|
|
SfxStyleSheet *pSheet = NULL;
|
|
|
|
std::vector<SfxStyleSheetBase*> aOutlineStyles;
|
|
|
|
pSPool->CreateOutlineSheetList(aTrueLayoutName,aOutlineStyles);
|
|
|
|
|
|
|
|
std::vector<SfxStyleSheetBase*>::iterator iter;
|
|
|
|
for (iter = aOutlineStyles.begin(); iter != aOutlineStyles.end(); ++iter)
|
|
|
|
{
|
2011-10-26 15:05:27 +03:00
|
|
|
pSheet = static_cast<SfxStyleSheet*>(*iter);
|
2011-03-04 21:49:59 -08:00
|
|
|
pOutlineTextObj->EndListening(*pSheet);
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-11 11:09:53 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
2013-03-01 10:54:57 +01:00
|
|
|
|* Set new model
|
2000-09-18 23:16:46 +00:00
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2001-10-22 12:36:57 +00:00
|
|
|
void SdPage::SetModel(SdrModel* pNewModel)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
DisconnectLink();
|
|
|
|
|
2013-03-01 10:54:57 +01:00
|
|
|
// assign model
|
2000-09-18 23:16:46 +00:00
|
|
|
FmFormPage::SetModel(pNewModel);
|
|
|
|
|
|
|
|
ConnectLink();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
2013-03-01 10:54:57 +01:00
|
|
|
|* Is this page read-only?
|
2000-09-18 23:16:46 +00:00
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2010-10-05 07:57:51 -05:00
|
|
|
bool SdPage::IsReadOnly() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-05 07:57:51 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
2013-03-01 10:54:57 +01:00
|
|
|
|* Connect to sfx2::LinkManager
|
2000-09-18 23:16:46 +00:00
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
void SdPage::ConnectLink()
|
|
|
|
{
|
2010-01-13 22:25:07 +01:00
|
|
|
sfx2::LinkManager* pLinkManager = pModel!=NULL ? pModel->GetLinkManager() : NULL;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2013-08-26 15:22:55 +02:00
|
|
|
if (pLinkManager && !mpPageLink && !maFileName.isEmpty() && !maBookmarkName.isEmpty() &&
|
2006-12-12 15:33:34 +00:00
|
|
|
mePageKind==PK_STANDARD && !IsMasterPage() &&
|
2014-11-11 07:52:45 +02:00
|
|
|
static_cast<SdDrawDocument*>(pModel)->IsNewOrLoadCompleted())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
/**********************************************************************
|
2013-03-01 10:54:57 +01:00
|
|
|
* Connect
|
|
|
|
* Only standard pages are allowed to be linked
|
2000-09-18 23:16:46 +00:00
|
|
|
**********************************************************************/
|
2014-11-11 07:52:45 +02:00
|
|
|
::sd::DrawDocShell* pDocSh = static_cast<SdDrawDocument*>(pModel)->GetDocSh();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-07-25 09:31:59 -04:00
|
|
|
if (!pDocSh || !pDocSh->GetMedium()->GetOrigURL().equals(maFileName))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2013-03-01 10:54:57 +01:00
|
|
|
// No links to document owned pages!
|
2006-12-12 15:33:34 +00:00
|
|
|
mpPageLink = new SdPageLink(this, maFileName, maBookmarkName);
|
2013-08-26 15:22:55 +02:00
|
|
|
OUString aFilterName(SdResId(STR_IMPRESS));
|
2006-12-12 15:33:34 +00:00
|
|
|
pLinkManager->InsertFileLink(*mpPageLink, OBJECT_CLIENT_FILE,
|
|
|
|
maFileName, &aFilterName, &maBookmarkName);
|
|
|
|
mpPageLink->Connect();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
2013-03-01 10:54:57 +01:00
|
|
|
|* Disconnect from sfx2::LinkManager
|
2000-09-18 23:16:46 +00:00
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
void SdPage::DisconnectLink()
|
|
|
|
{
|
2010-01-13 22:25:07 +01:00
|
|
|
sfx2::LinkManager* pLinkManager = pModel!=NULL ? pModel->GetLinkManager() : NULL;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2006-12-12 15:33:34 +00:00
|
|
|
if (pLinkManager && mpPageLink)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
/**********************************************************************
|
2013-03-01 10:54:57 +01:00
|
|
|
* Disconnect
|
|
|
|
* (remove deletes *pGraphicLink implicit)
|
2000-09-18 23:16:46 +00:00
|
|
|
**********************************************************************/
|
2006-12-12 15:33:34 +00:00
|
|
|
pLinkManager->Remove(mpPageLink);
|
|
|
|
mpPageLink=NULL;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Copy-Ctor
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2006-12-12 15:33:34 +00:00
|
|
|
SdPage::SdPage(const SdPage& rSrcPage)
|
|
|
|
: FmFormPage(rSrcPage)
|
|
|
|
, SdrObjUserCall()
|
|
|
|
, mpItems(NULL)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-12-12 15:33:34 +00:00
|
|
|
mePageKind = rSrcPage.mePageKind;
|
|
|
|
meAutoLayout = rSrcPage.meAutoLayout;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2014-04-24 10:52:02 +02:00
|
|
|
mbSelected = false;
|
2004-11-26 18:47:40 +00:00
|
|
|
mnTransitionType = rSrcPage.mnTransitionType;
|
|
|
|
mnTransitionSubtype = rSrcPage.mnTransitionSubtype;
|
|
|
|
mbTransitionDirection = rSrcPage.mbTransitionDirection;
|
|
|
|
mnTransitionFadeColor = rSrcPage.mnTransitionFadeColor;
|
|
|
|
mfTransitionDuration = rSrcPage.mfTransitionDuration;
|
2006-12-12 15:33:34 +00:00
|
|
|
mePresChange = rSrcPage.mePresChange;
|
2013-04-02 18:37:00 +02:00
|
|
|
mfTime = rSrcPage.mfTime;
|
2006-12-12 15:33:34 +00:00
|
|
|
mbSoundOn = rSrcPage.mbSoundOn;
|
|
|
|
mbExcluded = rSrcPage.mbExcluded;
|
|
|
|
|
|
|
|
maLayoutName = rSrcPage.maLayoutName;
|
|
|
|
maSoundFile = rSrcPage.maSoundFile;
|
2007-06-27 14:37:47 +00:00
|
|
|
mbLoopSound = rSrcPage.mbLoopSound;
|
|
|
|
mbStopSound = rSrcPage.mbStopSound;
|
2014-12-18 13:30:26 +01:00
|
|
|
maCreatedPageName.clear();
|
2006-12-12 15:33:34 +00:00
|
|
|
maFileName = rSrcPage.maFileName;
|
|
|
|
maBookmarkName = rSrcPage.maBookmarkName;
|
|
|
|
mbScaleObjects = rSrcPage.mbScaleObjects;
|
|
|
|
mbBackgroundFullSize = rSrcPage.mbBackgroundFullSize;
|
|
|
|
meCharSet = rSrcPage.meCharSet;
|
|
|
|
mnPaperBin = rSrcPage.mnPaperBin;
|
|
|
|
meOrientation = rSrcPage.meOrientation;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2014-12-03 22:01:57 +01:00
|
|
|
mpPageLink = NULL; // is set when inserting via ConnectLink()
|
2014-12-08 13:43:56 +00:00
|
|
|
|
|
|
|
mbIsPrecious = false;
|
2014-12-03 22:01:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SdPage::lateInit(const SdPage& rSrcPage)
|
|
|
|
{
|
|
|
|
FmFormPage::lateInit(rSrcPage);
|
|
|
|
|
|
|
|
// use shape list directly to preserve constness of rSrcPage
|
|
|
|
const std::list< SdrObject* >& rShapeList = rSrcPage.maPresentationShapeList.getList();
|
|
|
|
for( std::list< SdrObject* >::const_iterator aIter = rShapeList.begin();
|
|
|
|
aIter != rShapeList.end(); ++aIter )
|
|
|
|
{
|
|
|
|
SdrObject* pObj = *aIter;
|
|
|
|
InsertPresObj(GetObj(pObj->GetOrdNum()), rSrcPage.GetPresObjKind(pObj));
|
|
|
|
}
|
|
|
|
|
2005-07-14 09:43:59 +00:00
|
|
|
// header footer
|
|
|
|
setHeaderFooterSettings( rSrcPage.getHeaderFooterSettings() );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Clone
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
SdrPage* SdPage::Clone() const
|
|
|
|
{
|
2006-12-12 15:33:34 +00:00
|
|
|
return Clone(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
SdrPage* SdPage::Clone(SdrModel* pNewModel) const
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pNewModel == 0, "sd::SdPage::Clone(), new page ignored, please check code! CL" );
|
|
|
|
(void)pNewModel;
|
|
|
|
|
|
|
|
SdPage* pNewPage = new SdPage(*this);
|
2014-12-03 22:01:57 +01:00
|
|
|
pNewPage->lateInit( *this );
|
2005-07-14 09:43:59 +00:00
|
|
|
|
2006-12-12 15:33:34 +00:00
|
|
|
cloneAnimations( *pNewPage );
|
2005-07-14 09:43:59 +00:00
|
|
|
|
2005-09-23 09:42:48 +00:00
|
|
|
// fix user calls for duplicated slide
|
|
|
|
SdrObjListIter aSourceIter( *this, IM_DEEPWITHGROUPS );
|
2006-12-12 15:33:34 +00:00
|
|
|
SdrObjListIter aTargetIter( *pNewPage, IM_DEEPWITHGROUPS );
|
2005-09-23 09:42:48 +00:00
|
|
|
|
|
|
|
while( aSourceIter.IsMore() && aTargetIter.IsMore() )
|
|
|
|
{
|
|
|
|
SdrObject* pSource = aSourceIter.Next();
|
|
|
|
SdrObject* pTarget = aTargetIter.Next();
|
|
|
|
|
|
|
|
if( pSource->GetUserCall() )
|
2006-12-12 15:33:34 +00:00
|
|
|
pTarget->SetUserCall( pNewPage );
|
2005-09-23 09:42:48 +00:00
|
|
|
}
|
|
|
|
|
2006-12-12 15:33:34 +00:00
|
|
|
return pNewPage;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2001-01-28 14:59:13 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* GetTextStyleSheetForObject
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-01-28 14:59:13 +00:00
|
|
|
SfxStyleSheet* SdPage::GetTextStyleSheetForObject( SdrObject* pObj ) const
|
|
|
|
{
|
|
|
|
const PresObjKind eKind = ((SdPage*)this)->GetPresObjKind(pObj);
|
|
|
|
if( eKind != PRESOBJ_NONE )
|
|
|
|
{
|
|
|
|
return ((SdPage*)this)->GetStyleSheetForPresObj(eKind);
|
|
|
|
}
|
2001-01-30 14:25:02 +00:00
|
|
|
|
|
|
|
return FmFormPage::GetTextStyleSheetForObject( pObj );
|
2001-01-28 14:59:13 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-10-12 15:19:53 +00:00
|
|
|
SfxItemSet* SdPage::getOrCreateItems()
|
|
|
|
{
|
|
|
|
if( mpItems == NULL )
|
|
|
|
mpItems = new SfxItemSet( pModel->GetItemPool(), SDRATTR_XMLATTRIBUTES, SDRATTR_XMLATTRIBUTES );
|
|
|
|
|
|
|
|
return mpItems;
|
|
|
|
}
|
|
|
|
|
2014-04-24 10:52:02 +02:00
|
|
|
bool SdPage::setAlienAttributes( const com::sun::star::uno::Any& rAttributes )
|
2001-10-12 15:19:53 +00:00
|
|
|
{
|
|
|
|
SfxItemSet* pSet = getOrCreateItems();
|
|
|
|
|
|
|
|
SvXMLAttrContainerItem aAlienAttributes( SDRATTR_XMLATTRIBUTES );
|
|
|
|
if( aAlienAttributes.PutValue( rAttributes, 0 ) )
|
|
|
|
{
|
|
|
|
pSet->Put( aAlienAttributes );
|
2014-04-24 10:52:02 +02:00
|
|
|
return true;
|
2001-10-12 15:19:53 +00:00
|
|
|
}
|
|
|
|
|
2014-04-24 10:52:02 +02:00
|
|
|
return false;
|
2001-10-12 15:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SdPage::getAlienAttributes( com::sun::star::uno::Any& rAttributes )
|
|
|
|
{
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
|
2014-09-10 17:53:41 +02:00
|
|
|
if( (mpItems == NULL) || ( SfxItemState::SET != mpItems->GetItemState( SDRATTR_XMLATTRIBUTES, false, &pItem ) ) )
|
2001-10-12 15:19:53 +00:00
|
|
|
{
|
|
|
|
SvXMLAttrContainerItem aAlienAttributes;
|
|
|
|
aAlienAttributes.QueryValue( rAttributes, 0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-11 07:52:45 +02:00
|
|
|
static_cast<const SvXMLAttrContainerItem*>(pItem)->QueryValue( rAttributes, 0 );
|
2001-10-12 15:19:53 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-07 12:34:33 +00:00
|
|
|
|
2005-09-23 09:42:48 +00:00
|
|
|
void SdPage::RemoveEmptyPresentationObjects()
|
|
|
|
{
|
|
|
|
SdrObjListIter aShapeIter( *this, IM_DEEPWITHGROUPS );
|
2005-07-07 12:34:33 +00:00
|
|
|
|
2005-09-23 09:42:48 +00:00
|
|
|
SdrObject* pShape;
|
|
|
|
for( pShape = aShapeIter.Next(); pShape; pShape = aShapeIter.Next() )
|
|
|
|
{
|
|
|
|
if( pShape && pShape->IsEmptyPresObj() )
|
2007-07-06 08:47:46 +00:00
|
|
|
{
|
|
|
|
RemoveObject( pShape->GetOrdNum() );
|
|
|
|
SdrObject::Free( pShape );
|
|
|
|
}
|
2005-07-07 12:34:33 +00:00
|
|
|
|
2005-09-23 09:42:48 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-07 12:34:33 +00:00
|
|
|
|
|
|
|
void SdPage::setTransitionType( sal_Int16 nTransitionType )
|
|
|
|
{
|
|
|
|
mnTransitionType = nTransitionType;
|
|
|
|
ActionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SdPage::setTransitionSubtype ( sal_Int16 nTransitionSubtype )
|
|
|
|
{
|
|
|
|
mnTransitionSubtype = nTransitionSubtype;
|
|
|
|
ActionChanged();
|
|
|
|
}
|
|
|
|
|
2014-04-24 10:52:02 +02:00
|
|
|
void SdPage::setTransitionDirection ( bool bTransitionbDirection )
|
2005-07-07 12:34:33 +00:00
|
|
|
{
|
|
|
|
mbTransitionDirection = bTransitionbDirection;
|
|
|
|
ActionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SdPage::setTransitionFadeColor ( sal_Int32 nTransitionFadeColor )
|
|
|
|
{
|
|
|
|
mnTransitionFadeColor = nTransitionFadeColor;
|
|
|
|
ActionChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SdPage::setTransitionDuration ( double fTranstionDuration )
|
|
|
|
{
|
|
|
|
mfTransitionDuration = fTranstionDuration;
|
|
|
|
ActionChanged();
|
|
|
|
}
|
2009-09-16 13:55:36 +00:00
|
|
|
|
2013-12-10 17:20:34 +05:30
|
|
|
OString SdPage::stringify() const
|
|
|
|
{
|
|
|
|
OStringBuffer aString(100);
|
2013-12-10 19:09:01 +05:30
|
|
|
aString.append((sal_Int32)mePageKind).append((sal_Int32)meAutoLayout).append(mbSelected).append((sal_Int32)mePresChange).append(mfTime).append(mbSoundOn).append(mbExcluded).
|
2013-12-10 17:20:34 +05:30
|
|
|
append(OUStringToOString( maLayoutName, RTL_TEXTENCODING_UTF8 )).
|
|
|
|
append(OUStringToOString(maSoundFile, RTL_TEXTENCODING_UTF8 )).
|
|
|
|
append(mbLoopSound).append(mbStopSound).
|
|
|
|
/*append(OUStringToOString(maCreatedPageName, RTL_TEXTENCODING_UTF8)).
|
|
|
|
append(OUStringToOString(maFileName, RTL_TEXTENCODING_UTF8)).*/
|
|
|
|
append(OUStringToOString(maBookmarkName, RTL_TEXTENCODING_UTF8)).
|
2013-12-10 20:53:55 +05:30
|
|
|
append(mbScaleObjects).append(mbBackgroundFullSize).append((sal_Int32)meCharSet).append((sal_Int32)mnPaperBin).
|
|
|
|
append((sal_Int32)meOrientation).append((sal_Int32)mnTransitionType).append((sal_Int32)mnTransitionSubtype).append(mbTransitionDirection).
|
2013-12-10 17:20:34 +05:30
|
|
|
append(mnTransitionFadeColor).append(mfTransitionDuration);//.append(mbIsPrecious);
|
|
|
|
|
2014-08-16 12:59:11 +02:00
|
|
|
const size_t n = GetObjCount();
|
|
|
|
for(size_t i = 0; i < n; ++i)
|
2013-12-10 17:20:34 +05:30
|
|
|
aString.append(GetObj(i)->stringify());
|
|
|
|
return aString.makeStringAndClear();
|
|
|
|
}
|
|
|
|
|
Stick to a single O[U]String hash function
8f8bc0dcf3bc253ae49159d52db049767f476ced "Move string hash function into String
class" had introduced a new getHash64 that, besides returning sal_uInt64 instead
of just sal_Int32, didn't do sampling of only a handful of characters, but
always computed the hash over all characters (as the usage in SfxItemSet and
SdPage appears to require for either performance or approximated correctness).
However, it would be advantageous to keep the stable URE interface as small as
possible. Now, O(1) sampling was apparently considered state of the art when
the rtl string classes were first created, closely copying java.lang.String,
which at that time demanded sampling for hashCode(), too---but never sampling
more than 15 characters, with the obvious (in hindsight, at least) performance
catastrophes, so they changed it to O(n) somewhere along the way.
Based on that, this commit changes the existing hash functions to not do
sampling any more, and removes the newly introduced -64 variants again. (Where
the extended value range of sal_uInt64 compared to sal_Int32 was hopefully not
vital to the existing uses.)
The old implementation used sampling only for strings of length >= 256, so I did
a "make check" build with an instrumented hash function that flagged all uses
with inputs of length >= 256, and grepped workdir/{Cppunit,Junit,Python}Test for
hits. Of the 2849 hits encountered, 2845 where in the range from 256 to 295
characters, and only the remaining four where of 2472 characters. Those four
were from CppunitTest_sc_subsequent_filters_test, importing long text into a
cell, causing ScDocumentImport::setStringCell to call
svl::SharedStringPool::intern, which internally uses an unordered_set. These
results appear to justify the change.
Change-Id: I78fcc3b0f07389bdf36a21701b95a1ff0a0d970f
2014-02-18 12:49:50 +01:00
|
|
|
sal_Int32 SdPage::getHash() const
|
2013-12-10 17:20:34 +05:30
|
|
|
{
|
Stick to a single O[U]String hash function
8f8bc0dcf3bc253ae49159d52db049767f476ced "Move string hash function into String
class" had introduced a new getHash64 that, besides returning sal_uInt64 instead
of just sal_Int32, didn't do sampling of only a handful of characters, but
always computed the hash over all characters (as the usage in SfxItemSet and
SdPage appears to require for either performance or approximated correctness).
However, it would be advantageous to keep the stable URE interface as small as
possible. Now, O(1) sampling was apparently considered state of the art when
the rtl string classes were first created, closely copying java.lang.String,
which at that time demanded sampling for hashCode(), too---but never sampling
more than 15 characters, with the obvious (in hindsight, at least) performance
catastrophes, so they changed it to O(n) somewhere along the way.
Based on that, this commit changes the existing hash functions to not do
sampling any more, and removes the newly introduced -64 variants again. (Where
the extended value range of sal_uInt64 compared to sal_Int32 was hopefully not
vital to the existing uses.)
The old implementation used sampling only for strings of length >= 256, so I did
a "make check" build with an instrumented hash function that flagged all uses
with inputs of length >= 256, and grepped workdir/{Cppunit,Junit,Python}Test for
hits. Of the 2849 hits encountered, 2845 where in the range from 256 to 295
characters, and only the remaining four where of 2472 characters. Those four
were from CppunitTest_sc_subsequent_filters_test, importing long text into a
cell, causing ScDocumentImport::setStringCell to call
svl::SharedStringPool::intern, which internally uses an unordered_set. These
results appear to justify the change.
Change-Id: I78fcc3b0f07389bdf36a21701b95a1ff0a0d970f
2014-02-18 12:49:50 +01:00
|
|
|
return stringify().hashCode();
|
2013-12-10 17:20:34 +05:30
|
|
|
}
|
|
|
|
|
2009-09-16 13:55:36 +00:00
|
|
|
void SdPage::createAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation )
|
|
|
|
{
|
|
|
|
sd::createAnnotation( xAnnotation, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SdPage::addAnnotation( const Reference< XAnnotation >& xAnnotation, int nIndex )
|
|
|
|
{
|
|
|
|
if( (nIndex == -1) || (nIndex > (int)maAnnotations.size()) )
|
|
|
|
{
|
|
|
|
maAnnotations.push_back( xAnnotation );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maAnnotations.insert( maAnnotations.begin() + nIndex, xAnnotation );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pModel && pModel->IsUndoEnabled() )
|
|
|
|
{
|
|
|
|
SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, true );
|
|
|
|
if( pAction )
|
|
|
|
pModel->AddUndo( pAction );
|
|
|
|
}
|
|
|
|
|
|
|
|
SetChanged();
|
|
|
|
|
|
|
|
if( pModel )
|
|
|
|
{
|
|
|
|
pModel->SetChanged();
|
2014-06-25 08:43:20 +02:00
|
|
|
NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), "OnAnnotationInserted", Reference<XInterface>( xAnnotation, UNO_QUERY ) );
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation )
|
|
|
|
{
|
|
|
|
if( pModel && pModel->IsUndoEnabled() )
|
|
|
|
{
|
|
|
|
SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, false );
|
|
|
|
if( pAction )
|
|
|
|
pModel->AddUndo( pAction );
|
|
|
|
}
|
|
|
|
|
|
|
|
AnnotationVector::iterator iter = std::find( maAnnotations.begin(), maAnnotations.end(), xAnnotation );
|
|
|
|
if( iter != maAnnotations.end() )
|
|
|
|
maAnnotations.erase( iter );
|
|
|
|
|
|
|
|
if( pModel )
|
|
|
|
{
|
|
|
|
pModel->SetChanged();
|
2014-06-25 08:43:20 +02:00
|
|
|
NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), "OnAnnotationRemoved", Reference<XInterface>( xAnnotation, UNO_QUERY ) );
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|