• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pl_ListenerCoupleCloser.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 2011 Ben Martin
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 #ifndef PL_LISTENERCOUPLECLOSER_H
00021 #define PL_LISTENERCOUPLECLOSER_H
00022 
00023 #include "ut_types.h"
00024 #include "pt_Types.h"
00025 class PX_ChangeRecord;
00026 #include "pl_Listener.h"
00027 
00028 #include <list>
00029 #include <string>
00030 
00031 class fl_ContainerLayout;
00032 
00039 struct ABI_EXPORT PL_FinishingListener : public PL_Listener
00040 {
00041     virtual bool isFinished() = 0;
00042 
00043     virtual bool        change(fl_ContainerLayout* /*sfh*/,
00044                                const PX_ChangeRecord * /*pcr*/)
00045     {return true;}
00046     virtual bool        insertStrux(fl_ContainerLayout* /*sfh*/,
00047                                     const PX_ChangeRecord * /*pcr*/,
00048                                     pf_Frag_Strux* /*sdhNew*/,
00049                                     PL_ListenerId /*lid*/,
00050                                     void (* /*pfnBindHandles*/)(pf_Frag_Strux* sdhNew,
00051                                                                 PL_ListenerId lid,
00052                                                                 fl_ContainerLayout* sfhNew))
00053     { return true;}
00054     virtual bool        signal(UT_uint32 /*iSignal*/)
00055     { return true;}
00056 };
00057 
00058 
00124 class ABI_EXPORT PL_ListenerCoupleCloser : public PL_Listener
00125 {
00126   protected:
00127     PD_Document* m_pDocument;
00128     PL_Listener* m_delegate;
00129     typedef std::list< std::string > stringlist_t;
00130     stringlist_t m_rdfUnclosedAnchorStack;
00131     stringlist_t m_rdfUnopenedAnchorStack;
00132     stringlist_t m_bookmarkUnclosedStack;
00133     stringlist_t m_bookmarkUnopenedStack;
00134 
00135     bool shouldClose( const std::string& id, bool isEnd, stringlist_t& sl );
00136     bool shouldOpen( const std::string& id,  bool isEnd, stringlist_t& sl );
00137     void trackOpenClose( const std::string& id, bool isEnd,
00138                          stringlist_t& unclosed, stringlist_t& unopened );
00139 
00140 
00141     struct ABI_EXPORT AfterContentListener : public PL_FinishingListener
00142     {
00143         PL_ListenerCoupleCloser* m_self;
00144         AfterContentListener( PL_ListenerCoupleCloser* self )
00145             : m_self(self)
00146         {}
00147 
00148         virtual bool isFinished();
00149         virtual bool populate( fl_ContainerLayout* sfh,
00150                                const PX_ChangeRecord * pcr );
00151         virtual bool populateStrux( pf_Frag_Strux* sdh,
00152                                     const PX_ChangeRecord * pcr,
00153                                     fl_ContainerLayout* * psfh);
00154     };
00155     AfterContentListener m_AfterContentListener;
00156 
00157     struct ABI_EXPORT BeforeContentListener : public PL_FinishingListener
00158     {
00159         PL_ListenerCoupleCloser* m_self;
00160         BeforeContentListener( PL_ListenerCoupleCloser* self )
00161             : m_self(self)
00162         {}
00163 
00164         virtual bool isFinished();
00165         virtual bool populate( fl_ContainerLayout* sfh,
00166                                const PX_ChangeRecord * pcr );
00167         virtual bool populateStrux( pf_Frag_Strux* sdh,
00168                                     const PX_ChangeRecord * pcr,
00169                                     fl_ContainerLayout* * psfh);
00170     };
00171     BeforeContentListener m_BeforeContentListener;
00172 
00173     struct ABI_EXPORT NullContentListener : public PL_FinishingListener
00174     {
00175         PL_ListenerCoupleCloser* m_self;
00176         NullContentListener( PL_ListenerCoupleCloser* self )
00177             : m_self(self)
00178         {}
00179 
00180         virtual bool isFinished()
00181         {
00182             return true;
00183         }
00184         virtual bool populate( fl_ContainerLayout*,
00185                                const PX_ChangeRecord* )
00186         {
00187             return false;
00188         }
00189         virtual bool populateStrux( pf_Frag_Strux*,
00190                                     const PX_ChangeRecord*,
00191                                     fl_ContainerLayout**)
00192         {
00193             return false;
00194         }
00195     };
00196     NullContentListener m_NullContentListener;
00197 
00198 
00199   public:
00200     PL_ListenerCoupleCloser();
00201     virtual ~PL_ListenerCoupleCloser();
00202     void setDelegate( PL_Listener* delegate );
00203     PD_Document*  getDocument(void);
00204     void          setDocument(PD_Document * pDoc);
00205     void          reset();
00206 
00207     virtual bool populate( fl_ContainerLayout* sfh,
00208                            const PX_ChangeRecord * pcr );
00209     virtual bool populateStrux( pf_Frag_Strux* sdh,
00210                                 const PX_ChangeRecord * pcr,
00211                                 fl_ContainerLayout* * psfh);
00212 
00213     PL_FinishingListener* getAfterContentListener();
00214     PL_FinishingListener* getBeforeContentListener();
00215     PL_FinishingListener* getNullContentListener();
00216 
00217 
00218     virtual bool        change(fl_ContainerLayout* /*sfh*/,
00219                                const PX_ChangeRecord * /*pcr*/)
00220     {return true;}
00221 
00222     virtual bool        insertStrux(fl_ContainerLayout* /*sfh*/,
00223                                     const PX_ChangeRecord * /*pcr*/,
00224                                     pf_Frag_Strux* /*sdhNew*/,
00225                                     PL_ListenerId /*lid*/,
00226                                     void (* /*pfnBindHandles*/)(pf_Frag_Strux* sdhNew,
00227                                                                 PL_ListenerId lid,
00228                                                                 fl_ContainerLayout* sfhNew))
00229     { return true;}
00230 
00231     virtual bool        signal(UT_uint32 /*iSignal*/)
00232     { return true;}
00233 
00234   private:
00235 
00236     virtual bool populateAfter( fl_ContainerLayout* sfh,
00237                                 const PX_ChangeRecord * pcr );
00238     virtual bool populateStruxAfter( pf_Frag_Strux* sdh,
00239                                      const PX_ChangeRecord * pcr,
00240                                      fl_ContainerLayout* * psfh);
00241 
00242 
00243     virtual bool populateBefore( fl_ContainerLayout* sfh,
00244                                  const PX_ChangeRecord * pcr );
00245     virtual bool populateStruxBefore( pf_Frag_Strux* sdh,
00246                                       const PX_ChangeRecord * pcr,
00247                                       fl_ContainerLayout* * psfh);
00248 
00249 
00250 
00251 };
00252 
00253 #endif

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1