INTEGRATION: CWS impress2 (1.1.2); FILE ADDED

2004/07/12 18:04:58 af 1.1.2.6: #i22705# Added RemoveCallback() method.
2004/07/11 14:53:30 af 1.1.2.5: #i22705# Introduced reference counting.  Moved some methods to the inner Implementation class.
2004/07/04 13:41:19 af 1.1.2.4: #i22705# Moved code for reading templates here from AllMasterPagesSelector.
2004/06/09 13:48:31 af 1.1.2.3: #i22705# Renamed the inner implementation class to Implementation.
2004/06/04 06:11:29 af 1.1.2.2: #i22705# Extended documentation of some functions.
2004/05/19 13:19:50 af 1.1.2.1: #i22705# Initial revision.
This commit is contained in:
Rüdiger Timm 2004-07-13 13:43:52 +00:00
parent 87b0d66b13
commit c716469ef5

View file

@ -0,0 +1,202 @@
/*************************************************************************
*
* $RCSfile: MasterPageContainer.hxx,v $
*
* $Revision: 1.2 $
*
* last change: $Author: rt $ $Date: 2004-07-13 14:43:52 $
*
* 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): _______________________________________
*
*
************************************************************************/
#ifndef SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_HXX
#define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_HXX
#include <osl/mutex.hxx>
#include <tools/string.hxx>
#include <vcl/image.hxx>
#include <memory>
#include "PreviewRenderer.hxx"
#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
#include <com/sun/star/frame/XModel.hpp>
#endif
#ifndef _SV_TIMER_HXX
#include <vcl/timer.hxx>
#endif
class SdPage;
class SdDrawDocument;
class SfxObjectShellLock;
namespace sd {
class DrawDocShell;
}
namespace sd { namespace toolpanel { namespace controls {
/** This singleton container manages the master pages of the master page
selector controls of the tool panel. It maintains its own document to
store master page objects. For each master page container stores its
URL, preview bitmap, page name, and, if available, the page object.
The lifetime is reference count controlled. After Unregister() has been
called as many times as Register() the instance is destroyed. A call to
Instance() after that creates a new one.
*/
class MasterPageContainer
{
public:
typedef int Token;
static const Token NIL_TOKEN = -1;
static MasterPageContainer& Instance (void);
static void Register (void);
static void Unregister (void);
/** Put the master page identified and described by the given parameters
into the container. When there already is a master page with the
given URL, page name, or object pointer (when that is not NULL) then
the existing entry is replaced/updated by the given one. Otherwise
a new entry is inserted.
*/
Token PutMasterPage (
const String& sURL,
const String& sPageName,
SdPage* pMasterPage,
Image aPreview);
int GetTokenCount (void);
/** Return a token for an index in the range
0 <= index < GetTokenCount().
*/
Token GetTokenForIndex (int nIndex);
Token GetTokenForURL (const String& sURL);
Token GetTokenForPageName (const String& sPageName);
Token GetTokenForPageObject (const SdPage* pPage);
String GetURLForToken (Token aToken);
String GetPageNameForToken (Token aToken);
SdPage* GetSlideForToken (Token aToken, bool bLoad=true);
SdPage* GetPageObjectForToken (Token aToken, bool bLoad=true);
/** This version of GetPreviewForToken() does not load a template when
the preview in the requested size does not exist and the template
has not been loaded previously.
@param aToken
This token specifies for which master page to return the
prview. The token is returned by one of the GetTokenFor...()
functions.
@param nWidth
The width of the requested preview.
@return
The returned image is the requested preview if a) it has been
created in the right size previously or b) the template has been
loaded and the preview can be created. Otherwise an empty
substitution is returned.
*/
Image GetPreviewForToken (
Token aToken,
int nWidth);
/** This version of GetPreviewForToken() creates the requested preview
bitmap if it does not yet exist. As this is done asynchronously the
caller has to supply callback funtion and user data that is passed
to that function when the preview is available. The preview can
then be obtained by the two argument version of this method.
@param aToken
This token specifies for which master page to return the
prview. The token is returned by one of the GetTokenFor...()
functions.
@param nWidth
The width of the requested preview.
@param rCallback
This callback is called when the preview is created
asynchronously and the creation is completed. When the preview
is not created asynchronously, because it is already available,
the callback is not called.
@param pUserData
This data is stored unaltered and passed to the callback.
*/
Image GetPreviewForToken (
Token aToken,
int nWidth,
const Link& rCallback,
void* pUserData);
/** The specified listener is not available anymore and must not
be called back. All requests for preview creation for this
callback are removed.
*/
void RemoveCallback (const Link& rCallback);
private:
static MasterPageContainer* mpInstance;
static ::osl::Mutex maMutex;
static int mnReferenceCount;
class Implementation;
::std::auto_ptr<Implementation> mpImpl;
MasterPageContainer (void);
~MasterPageContainer (void);
void LateInit (void);
};
} } } // end of namespace ::sd::toolpanel::controls
#endif