2004-07-13 08:47:07 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 16:38:20 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-07-13 08:47:07 -05:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-07-13 08:47:07 -05:00
|
|
|
*
|
2008-04-10 16:38:20 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-07-13 08:47:07 -05:00
|
|
|
*
|
2008-04-10 16:38:20 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-07-13 08:47:07 -05:00
|
|
|
*
|
2008-04-10 16:38:20 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-07-13 08:47:07 -05:00
|
|
|
*
|
2008-04-10 16:38:20 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-07-13 08:47:07 -05:00
|
|
|
*
|
2008-04-10 16:38:20 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-07-13 08:47:07 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 13:20:29 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
2004-07-13 08:47:07 -05:00
|
|
|
#include "RecentMasterPagesSelector.hxx"
|
|
|
|
#include "PreviewValueSet.hxx"
|
|
|
|
|
|
|
|
#include "RecentlyUsedMasterPages.hxx"
|
2006-04-26 14:52:32 -05:00
|
|
|
#include "MasterPageContainerProviders.hxx"
|
2004-07-13 08:47:07 -05:00
|
|
|
#include "MasterPageObserver.hxx"
|
|
|
|
#include "sdpage.hxx"
|
|
|
|
#include "drawdoc.hxx"
|
2009-05-07 07:38:03 -05:00
|
|
|
#include "app.hrc"
|
2004-07-13 08:47:07 -05:00
|
|
|
#include <vcl/bitmap.hxx>
|
|
|
|
#include <tools/color.hxx>
|
|
|
|
|
|
|
|
namespace sd { namespace toolpanel { namespace controls {
|
|
|
|
|
|
|
|
|
|
|
|
RecentMasterPagesSelector::RecentMasterPagesSelector (
|
|
|
|
TreeNode* pParent,
|
|
|
|
SdDrawDocument& rDocument,
|
2006-04-26 14:52:32 -05:00
|
|
|
ViewShellBase& rBase,
|
|
|
|
const ::boost::shared_ptr<MasterPageContainer>& rpContainer)
|
|
|
|
: MasterPagesSelector (pParent, rDocument, rBase, rpContainer)
|
2004-07-13 08:47:07 -05:00
|
|
|
{
|
|
|
|
SetName (String(RTL_CONSTASCII_USTRINGPARAM("RecentMasterPagesSelector")));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RecentMasterPagesSelector::~RecentMasterPagesSelector (void)
|
|
|
|
{
|
|
|
|
RecentlyUsedMasterPages::Instance().RemoveEventListener (
|
|
|
|
LINK(this,RecentMasterPagesSelector,MasterPageListListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RecentMasterPagesSelector::LateInit (void)
|
|
|
|
{
|
|
|
|
MasterPagesSelector::LateInit();
|
|
|
|
|
2006-04-26 14:52:32 -05:00
|
|
|
MasterPagesSelector::Fill();
|
2004-07-13 08:47:07 -05:00
|
|
|
RecentlyUsedMasterPages::Instance().AddEventListener (
|
|
|
|
LINK(this,RecentMasterPagesSelector,MasterPageListListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-12-12 11:50:59 -06:00
|
|
|
IMPL_LINK(RecentMasterPagesSelector,MasterPageListListener, void*, EMPTYARG)
|
2004-07-13 08:47:07 -05:00
|
|
|
{
|
2006-04-26 14:52:32 -05:00
|
|
|
MasterPagesSelector::Fill();
|
2004-07-13 08:47:07 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-26 14:52:32 -05:00
|
|
|
void RecentMasterPagesSelector::Fill (ItemList& rItemList)
|
2004-07-13 08:47:07 -05:00
|
|
|
{
|
2006-04-26 14:52:32 -05:00
|
|
|
// Create a set of names of the master pages used by the document.
|
2005-02-16 10:00:54 -06:00
|
|
|
MasterPageObserver::MasterPageNameSet aCurrentNames;
|
2004-07-13 08:47:07 -05:00
|
|
|
USHORT nMasterPageCount = mrDocument.GetMasterSdPageCount(PK_STANDARD);
|
|
|
|
USHORT nIndex;
|
|
|
|
for (nIndex=0; nIndex<nMasterPageCount; nIndex++)
|
|
|
|
{
|
|
|
|
SdPage* pMasterPage = mrDocument.GetMasterSdPage (nIndex, PK_STANDARD);
|
|
|
|
if (pMasterPage != NULL)
|
|
|
|
aCurrentNames.insert (pMasterPage->GetName());
|
|
|
|
}
|
|
|
|
MasterPageObserver::MasterPageNameSet::iterator aI;
|
|
|
|
|
2006-04-26 14:52:32 -05:00
|
|
|
// Insert the recently used master pages that are currently not used.
|
|
|
|
RecentlyUsedMasterPages& rInstance (RecentlyUsedMasterPages::Instance());
|
|
|
|
int nPageCount = rInstance.GetMasterPageCount();
|
2004-07-13 08:47:07 -05:00
|
|
|
for (nIndex=0; nIndex<nPageCount; nIndex++)
|
|
|
|
{
|
2006-04-26 14:52:32 -05:00
|
|
|
// Add an entry when a) the page is already known to the
|
|
|
|
// MasterPageContainer, b) the style name is empty, i.e. it has not yet
|
|
|
|
// been loaded (and thus can not be in use) or otherwise c) the
|
2005-02-16 10:00:54 -06:00
|
|
|
// style name is not currently in use.
|
2006-04-26 14:52:32 -05:00
|
|
|
MasterPageContainer::Token aToken (rInstance.GetTokenForIndex(nIndex));
|
|
|
|
if (aToken != MasterPageContainer::NIL_TOKEN)
|
2004-07-13 08:47:07 -05:00
|
|
|
{
|
2006-04-26 14:52:32 -05:00
|
|
|
String sStyleName (mpContainer->GetStyleNameForToken(aToken));
|
|
|
|
if (sStyleName.Len()==0
|
|
|
|
|| aCurrentNames.find(sStyleName) == aCurrentNames.end())
|
|
|
|
{
|
|
|
|
rItemList.push_back(aToken);
|
|
|
|
}
|
2004-07-13 08:47:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-07-14 04:26:37 -05:00
|
|
|
void RecentMasterPagesSelector::AssignMasterPageToPageList (
|
|
|
|
SdPage* pMasterPage,
|
2008-04-03 08:50:52 -05:00
|
|
|
const ::boost::shared_ptr<std::vector<SdPage*> >& rpPageList)
|
2005-07-14 04:26:37 -05:00
|
|
|
{
|
|
|
|
USHORT nSelectedItemId = mpPageSet->GetSelectItemId();
|
|
|
|
|
2008-04-03 08:50:52 -05:00
|
|
|
MasterPagesSelector::AssignMasterPageToPageList(pMasterPage, rpPageList);
|
2005-07-14 04:26:37 -05:00
|
|
|
|
|
|
|
// Restore the selection.
|
|
|
|
if (mpPageSet->GetItemCount() > 0)
|
|
|
|
{
|
|
|
|
if (mpPageSet->GetItemCount() >= nSelectedItemId)
|
|
|
|
mpPageSet->SelectItem(nSelectedItemId);
|
|
|
|
else
|
|
|
|
mpPageSet->SelectItem(mpPageSet->GetItemCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-07 07:38:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RecentMasterPagesSelector::GetState (SfxItemSet& rItemSet)
|
|
|
|
{
|
|
|
|
MasterPagesSelector::GetState (rItemSet);
|
|
|
|
if (rItemSet.GetItemState(SID_TP_EDIT_MASTER) == SFX_ITEM_AVAILABLE)
|
|
|
|
rItemSet.DisableItem (SID_TP_EDIT_MASTER);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-13 08:47:07 -05:00
|
|
|
} } } // end of namespace ::sd::toolpanel::controls
|