2004/07/04 16:43:17 af 1.1.2.13: #i22705# Workaround for compiler problem. 2004/07/04 13:39:00 af 1.1.2.12: #i22705# Listening is done by MasterPagesSelectorListener. 2004/07/03 13:18:46 af 1.1.2.11: #i22705# Removed unnecessary if statement. 2004/07/02 12:22:58 af 1.1.2.10: #i22705# ValueSet is cleared before it is filled again. Finished implementation of UpdateSelection. 2004/07/01 11:36:13 af 1.1.2.9: #i22705# Added a listener member that initiates updates of both the selection as well as the set of master pages. 2004/06/28 07:42:35 af 1.1.2.8: #i22705# Fill() now includes every master page only one time. 2004/06/15 09:32:24 af 1.1.2.7: #i22705# Setting internal sub-shell name. 2004/06/09 13:46:16 af 1.1.2.6: #i22705# Moved initialization code to LateInit() method. 2004/06/04 06:07:37 af 1.1.2.5: #i22705# Adaption to new base class TreeNode. 2004/05/23 13:58:02 af 1.1.2.4: #i22705# mpPageSet is now an auto pointer. 2004/05/19 13:51:35 af 1.1.2.3: #i22705# Using ILayout interface of owner. Moved some code to base class. 2004/05/10 08:59:23 af 1.1.2.2: #i22705# Using the PreviewRenderer to render previews. 2004/05/05 12:35:46 af 1.1.2.1: #i22705# Initial revision.
184 lines
5.6 KiB
C++
184 lines
5.6 KiB
C++
/*************************************************************************
|
|
*
|
|
* $RCSfile: CurrentMasterPagesSelector.cxx,v $
|
|
*
|
|
* $Revision: 1.2 $
|
|
*
|
|
* last change: $Author: rt $ $Date: 2004-07-13 14:43:09 $
|
|
*
|
|
* The Contents of this file are made available subject to the terms of
|
|
* either of the following licenses
|
|
*
|
|
* - GNU Lesser General Public License Version 2.1
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
*
|
|
* Sun Microsystems Inc., October, 2000
|
|
*
|
|
* GNU Lesser General Public License Version 2.1
|
|
* =============================================
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
*
|
|
* This library 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 for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
* MA 02111-1307 USA
|
|
*
|
|
*
|
|
* Sun Industry Standards Source License Version 1.1
|
|
* =================================================
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
* Source License Version 1.1 (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.openoffice.org/license.html.
|
|
*
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
* See the License for the specific provisions governing your rights and
|
|
* obligations concerning the Software.
|
|
*
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
*
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
*
|
|
* All Rights Reserved.
|
|
*
|
|
* Contributor(s): _______________________________________
|
|
*
|
|
*
|
|
************************************************************************/
|
|
|
|
#include "CurrentMasterPagesSelector.hxx"
|
|
#include "MasterPagesSelectorListener.hxx"
|
|
#include "PreviewValueSet.hxx"
|
|
#include "drawdoc.hxx"
|
|
#include "sdpage.hxx"
|
|
#include <vcl/image.hxx>
|
|
#include "MasterPageContainer.hxx"
|
|
#include <svx/svdmodel.hxx>
|
|
#include <set>
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
namespace sd { namespace toolpanel { namespace controls {
|
|
|
|
|
|
CurrentMasterPagesSelector::CurrentMasterPagesSelector (
|
|
TreeNode* pParent,
|
|
SdDrawDocument& rDocument,
|
|
ViewShellBase& rBase,
|
|
DrawViewShell& rViewShell)
|
|
: MasterPagesSelector (pParent, rDocument, rBase),
|
|
mxListener(NULL)
|
|
{
|
|
SetName(String(RTL_CONSTASCII_USTRINGPARAM("CurrentMasterPagesSelector")));
|
|
}
|
|
|
|
|
|
|
|
|
|
CurrentMasterPagesSelector::~CurrentMasterPagesSelector (void)
|
|
{
|
|
if (mxListener.is())
|
|
{
|
|
mxListener->dispose();
|
|
mxListener = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void CurrentMasterPagesSelector::LateInit (void)
|
|
{
|
|
MasterPagesSelector::LateInit ();
|
|
Fill ();
|
|
// The selection listener is reference counted and thus takes care
|
|
// of its own lifetime.
|
|
mxListener = uno::Reference<lang::XComponent>(
|
|
static_cast<uno::XWeak*>(
|
|
new MasterPagesSelectorListener (mrBase, *this)),
|
|
uno::UNO_QUERY);
|
|
}
|
|
|
|
|
|
|
|
|
|
void CurrentMasterPagesSelector::Fill (void)
|
|
{
|
|
Clear();
|
|
USHORT nPageCount = mrDocument.GetMasterSdPageCount(PK_STANDARD);
|
|
SdPage* pMasterPage;
|
|
// Remember the names of the master pages that have been inserted to
|
|
// avoid double insertion.
|
|
::std::set<String> aMasterPageNames;
|
|
for (USHORT nIndex=0; nIndex<nPageCount; nIndex++)
|
|
{
|
|
pMasterPage = mrDocument.GetMasterSdPage (nIndex, PK_STANDARD);
|
|
if (pMasterPage != NULL)
|
|
{
|
|
String sName (pMasterPage->GetName());
|
|
if (aMasterPageNames.find(sName)==aMasterPageNames.end())
|
|
{
|
|
aMasterPageNames.insert (sName);
|
|
AddItemForPage (String(),sName,pMasterPage,Image());
|
|
}
|
|
}
|
|
}
|
|
GetParentNode()->RequestResize();
|
|
}
|
|
|
|
|
|
|
|
|
|
void CurrentMasterPagesSelector::UpdateSelection (void)
|
|
{
|
|
// Iterate over all pages and for the selected ones put the name of
|
|
// their master page into a set.
|
|
USHORT nPageCount = mrDocument.GetSdPageCount(PK_STANDARD);
|
|
SdPage* pPage;
|
|
::std::set<String> aNames;
|
|
USHORT nIndex;
|
|
for (nIndex=0; nIndex<nPageCount; nIndex++)
|
|
{
|
|
pPage = mrDocument.GetSdPage (nIndex, PK_STANDARD);
|
|
if (pPage != NULL && pPage->IsSelected())
|
|
{
|
|
USHORT nMasterPageCount (pPage->GetMasterPageCount());
|
|
for (USHORT nIndex=0; nIndex<nMasterPageCount; nIndex++)
|
|
{
|
|
SdPage* pMasterPage = static_cast<SdPage*>(
|
|
pPage->GetMasterPage(nIndex));
|
|
if (pMasterPage != NULL)
|
|
aNames.insert (pMasterPage->GetName());
|
|
}
|
|
}
|
|
}
|
|
|
|
// Find the items for the master pages in the set.
|
|
USHORT nItemCount (mpPageSet->GetItemCount());
|
|
for (nIndex=1; nIndex<=nItemCount; nIndex++)
|
|
{
|
|
String sName (mpPageSet->GetItemText (nIndex));
|
|
if (aNames.find(sName) != aNames.end())
|
|
{
|
|
mpPageSet->SelectItem (nIndex);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
} } } // end of namespace ::sd::toolpanel::controls
|