---
title: "对话框工厂"
author: "rollstone"
date: "2011-10-14T18:00:52Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2011-10-18T17:30:55Z"
id: 1196423
url: "https://rollstone.iteye.com/blog/1196423"
---

1.对于工厂我的理解：
良好的封装性。使用和创建，初始化分开。
创建和初始化的工作交给工厂类，这样，不必在使用的地方完成大量复杂的初始化工作。
http://hi.baidu.com/wuweihi/blog/item/456a723f7bdd01c77c1e7156.html
http://blog.csai.cn/user1/25929/archives/2009/35622.html
openoffice中的对话框工厂。
对话框工厂：
F:\DEV300-hg\sd\inc\sdabstdlg.hxx
先定义好类
class AbstractAnimationDlg : public VclAbstractDialog
{
public:
//virtual void Apply(TabPage* pPage) = 0;
virtual const SfxItemSet* GetOutputItemSet() const =0;
};

1.在工厂类SdAbstractDialogFactory里定义一个纯虚函数，例如：
virtual AbstractAnimationDlg* CreateAnimationDlg( ::Window* pParent, const SfxItemSet* pAttr, ::sd::View* pView )=0;

SdAbstractDialogFactory：：create（）创建一个工厂对象。（怎么实现的？有纯虚的类能不能有实例？？？？？）
=====================================================================
class SdAbstractDialogFactory_Impl : public SdAbstractDialogFactory实现了虚基类。
============================================================================================================
SdAbstractDialogFactory_Impl实现了AbstractAnimationDlg
class AbstractAnimationDlg_Impl: public AbstractAnimationDlg
{
DECL_ABSTDLG_BASE(AbstractAnimationDlg_Impl,::sd::AnimationDlg)//定义一个构造函数和虚构函数。构造函数的参数为：::sd::AnimationDlg *p，并初始化了其对象成员pDlg
//virtual void Apply( TabPage* pPage );
virtual const SfxItemSet* GetOutputItemSet() const;
};


DECL_ABSTDLG_BASE(AbstractAnimationDlg_Impl,::sd::AnimationDlg) 
展开： 
::sd::AnimationDlg *pDlg;
public:
AbstractAnimationDlg_Impl(::sd::AnimationDlg *p):pDlg(p)
{
}
virtual ~Class();

 = 0x117b3f80 SdAbstractDialogFactory_Impl::CreateBreakDlg(Window *, sd::DrawView *, sd::DrawDocShell *, unsigned long, unsigned long)