1*02c50d82SAndre Fischer /************************************************************** 2*02c50d82SAndre Fischer * 3*02c50d82SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4*02c50d82SAndre Fischer * or more contributor license agreements. See the NOTICE file 5*02c50d82SAndre Fischer * distributed with this work for additional information 6*02c50d82SAndre Fischer * regarding copyright ownership. The ASF licenses this file 7*02c50d82SAndre Fischer * to you under the Apache License, Version 2.0 (the 8*02c50d82SAndre Fischer * "License"); you may not use this file except in compliance 9*02c50d82SAndre Fischer * with the License. You may obtain a copy of the License at 10*02c50d82SAndre Fischer * 11*02c50d82SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12*02c50d82SAndre Fischer * 13*02c50d82SAndre Fischer * Unless required by applicable law or agreed to in writing, 14*02c50d82SAndre Fischer * software distributed under the License is distributed on an 15*02c50d82SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*02c50d82SAndre Fischer * KIND, either express or implied. See the License for the 17*02c50d82SAndre Fischer * specific language governing permissions and limitations 18*02c50d82SAndre Fischer * under the License. 19*02c50d82SAndre Fischer * 20*02c50d82SAndre Fischer *************************************************************/ 21*02c50d82SAndre Fischer 22*02c50d82SAndre Fischer #include "precompiled_sd.hxx" 23*02c50d82SAndre Fischer 24*02c50d82SAndre Fischer #include "MasterPageObserver.hxx" 25*02c50d82SAndre Fischer 26*02c50d82SAndre Fischer #include <algorithm> 27*02c50d82SAndre Fischer #include "drawdoc.hxx" 28*02c50d82SAndre Fischer #include "sdpage.hxx" 29*02c50d82SAndre Fischer #include <hash_map> 30*02c50d82SAndre Fischer #include <set> 31*02c50d82SAndre Fischer #include <vector> 32*02c50d82SAndre Fischer #include <svl/lstner.hxx> 33*02c50d82SAndre Fischer #include <osl/doublecheckedlocking.h> 34*02c50d82SAndre Fischer #include <osl/getglobalmutex.hxx> 35*02c50d82SAndre Fischer 36*02c50d82SAndre Fischer 37*02c50d82SAndre Fischer namespace sd { 38*02c50d82SAndre Fischer 39*02c50d82SAndre Fischer class MasterPageObserver::Implementation 40*02c50d82SAndre Fischer : public SfxListener 41*02c50d82SAndre Fischer { 42*02c50d82SAndre Fischer public: 43*02c50d82SAndre Fischer /** The single instance of this class. It is created on demand when 44*02c50d82SAndre Fischer Instance() is called for the first time. 45*02c50d82SAndre Fischer */ 46*02c50d82SAndre Fischer static MasterPageObserver* mpInstance; 47*02c50d82SAndre Fischer 48*02c50d82SAndre Fischer /** The master page observer will listen to events of this document and 49*02c50d82SAndre Fischer detect changes of the use of master pages. 50*02c50d82SAndre Fischer */ 51*02c50d82SAndre Fischer void RegisterDocument (SdDrawDocument& rDocument); 52*02c50d82SAndre Fischer 53*02c50d82SAndre Fischer /** The master page observer will stop to listen to events of this 54*02c50d82SAndre Fischer document. 55*02c50d82SAndre Fischer */ 56*02c50d82SAndre Fischer void UnregisterDocument (SdDrawDocument& rDocument); 57*02c50d82SAndre Fischer 58*02c50d82SAndre Fischer /** Add a listener that is informed of master pages that are newly 59*02c50d82SAndre Fischer assigned to slides or become unassigned. 60*02c50d82SAndre Fischer @param rEventListener 61*02c50d82SAndre Fischer The event listener to call for future events. Call 62*02c50d82SAndre Fischer RemoveEventListener() before the listener is destroyed. 63*02c50d82SAndre Fischer */ 64*02c50d82SAndre Fischer void AddEventListener (const Link& rEventListener); 65*02c50d82SAndre Fischer 66*02c50d82SAndre Fischer /** Remove the given listener from the list of listeners. 67*02c50d82SAndre Fischer @param rEventListener 68*02c50d82SAndre Fischer After this method returns the given listener is not called back 69*02c50d82SAndre Fischer from this object. Passing a listener that has not 70*02c50d82SAndre Fischer been registered before is safe and is silently ignored. 71*02c50d82SAndre Fischer */ 72*02c50d82SAndre Fischer void RemoveEventListener (const Link& rEventListener); 73*02c50d82SAndre Fischer 74*02c50d82SAndre Fischer /** Return a set of the names of master pages for the given document. 75*02c50d82SAndre Fischer This convenience method exists because this set is part of the 76*02c50d82SAndre Fischer internal data structure and thus takes no time to create. 77*02c50d82SAndre Fischer */ 78*02c50d82SAndre Fischer inline MasterPageObserver::MasterPageNameSet GetMasterPageNames ( 79*02c50d82SAndre Fischer SdDrawDocument& rDocument); 80*02c50d82SAndre Fischer 81*02c50d82SAndre Fischer private: 82*02c50d82SAndre Fischer ::std::vector<Link> maListeners; 83*02c50d82SAndre Fischer 84*02c50d82SAndre Fischer struct DrawDocHash { 85*02c50d82SAndre Fischer size_t operator()(SdDrawDocument* argument) const 86*02c50d82SAndre Fischer { return reinterpret_cast<unsigned long>(argument); } 87*02c50d82SAndre Fischer }; 88*02c50d82SAndre Fischer typedef ::std::hash_map<SdDrawDocument*, 89*02c50d82SAndre Fischer MasterPageObserver::MasterPageNameSet, 90*02c50d82SAndre Fischer DrawDocHash> 91*02c50d82SAndre Fischer MasterPageContainer; 92*02c50d82SAndre Fischer MasterPageContainer maUsedMasterPages; 93*02c50d82SAndre Fischer 94*02c50d82SAndre Fischer virtual void Notify( 95*02c50d82SAndre Fischer SfxBroadcaster& rBroadcaster, 96*02c50d82SAndre Fischer const SfxHint& rHint); 97*02c50d82SAndre Fischer 98*02c50d82SAndre Fischer void AnalyzeUsedMasterPages (SdDrawDocument& rDocument); 99*02c50d82SAndre Fischer 100*02c50d82SAndre Fischer void SendEvent (MasterPageObserverEvent& rEvent); 101*02c50d82SAndre Fischer }; 102*02c50d82SAndre Fischer 103*02c50d82SAndre Fischer MasterPageObserver* MasterPageObserver::Implementation::mpInstance = NULL; 104*02c50d82SAndre Fischer 105*02c50d82SAndre Fischer 106*02c50d82SAndre Fischer 107*02c50d82SAndre Fischer //===== MasterPageObserver ==================================================== 108*02c50d82SAndre Fischer 109*02c50d82SAndre Fischer MasterPageObserver& MasterPageObserver::Instance (void) 110*02c50d82SAndre Fischer { 111*02c50d82SAndre Fischer if (Implementation::mpInstance == NULL) 112*02c50d82SAndre Fischer { 113*02c50d82SAndre Fischer ::osl::GetGlobalMutex aMutexFunctor; 114*02c50d82SAndre Fischer ::osl::MutexGuard aGuard (aMutexFunctor()); 115*02c50d82SAndre Fischer if (Implementation::mpInstance == NULL) 116*02c50d82SAndre Fischer { 117*02c50d82SAndre Fischer MasterPageObserver* pInstance = new MasterPageObserver (); 118*02c50d82SAndre Fischer SdGlobalResourceContainer::Instance().AddResource ( 119*02c50d82SAndre Fischer ::std::auto_ptr<SdGlobalResource>(pInstance)); 120*02c50d82SAndre Fischer OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 121*02c50d82SAndre Fischer Implementation::mpInstance = pInstance; 122*02c50d82SAndre Fischer } 123*02c50d82SAndre Fischer } 124*02c50d82SAndre Fischer else 125*02c50d82SAndre Fischer { 126*02c50d82SAndre Fischer OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 127*02c50d82SAndre Fischer } 128*02c50d82SAndre Fischer 129*02c50d82SAndre Fischer DBG_ASSERT(Implementation::mpInstance!=NULL, 130*02c50d82SAndre Fischer "MasterPageObserver::Instance(): instance is NULL"); 131*02c50d82SAndre Fischer return *Implementation::mpInstance; 132*02c50d82SAndre Fischer } 133*02c50d82SAndre Fischer 134*02c50d82SAndre Fischer 135*02c50d82SAndre Fischer 136*02c50d82SAndre Fischer 137*02c50d82SAndre Fischer void MasterPageObserver::RegisterDocument (SdDrawDocument& rDocument) 138*02c50d82SAndre Fischer { 139*02c50d82SAndre Fischer mpImpl->RegisterDocument (rDocument); 140*02c50d82SAndre Fischer } 141*02c50d82SAndre Fischer 142*02c50d82SAndre Fischer 143*02c50d82SAndre Fischer 144*02c50d82SAndre Fischer 145*02c50d82SAndre Fischer void MasterPageObserver::UnregisterDocument (SdDrawDocument& rDocument) 146*02c50d82SAndre Fischer { 147*02c50d82SAndre Fischer mpImpl->UnregisterDocument (rDocument); 148*02c50d82SAndre Fischer } 149*02c50d82SAndre Fischer 150*02c50d82SAndre Fischer 151*02c50d82SAndre Fischer 152*02c50d82SAndre Fischer 153*02c50d82SAndre Fischer void MasterPageObserver::AddEventListener (const Link& rEventListener) 154*02c50d82SAndre Fischer { 155*02c50d82SAndre Fischer 156*02c50d82SAndre Fischer mpImpl->AddEventListener (rEventListener); 157*02c50d82SAndre Fischer } 158*02c50d82SAndre Fischer 159*02c50d82SAndre Fischer 160*02c50d82SAndre Fischer 161*02c50d82SAndre Fischer 162*02c50d82SAndre Fischer void MasterPageObserver::RemoveEventListener (const Link& rEventListener) 163*02c50d82SAndre Fischer { 164*02c50d82SAndre Fischer mpImpl->RemoveEventListener (rEventListener); 165*02c50d82SAndre Fischer } 166*02c50d82SAndre Fischer 167*02c50d82SAndre Fischer 168*02c50d82SAndre Fischer 169*02c50d82SAndre Fischer 170*02c50d82SAndre Fischer MasterPageObserver::MasterPageObserver (void) 171*02c50d82SAndre Fischer : mpImpl (new Implementation()) 172*02c50d82SAndre Fischer {} 173*02c50d82SAndre Fischer 174*02c50d82SAndre Fischer 175*02c50d82SAndre Fischer 176*02c50d82SAndre Fischer 177*02c50d82SAndre Fischer MasterPageObserver::~MasterPageObserver (void) 178*02c50d82SAndre Fischer {} 179*02c50d82SAndre Fischer 180*02c50d82SAndre Fischer 181*02c50d82SAndre Fischer 182*02c50d82SAndre Fischer 183*02c50d82SAndre Fischer //===== MasterPageObserver::Implementation ==================================== 184*02c50d82SAndre Fischer 185*02c50d82SAndre Fischer void MasterPageObserver::Implementation::RegisterDocument ( 186*02c50d82SAndre Fischer SdDrawDocument& rDocument) 187*02c50d82SAndre Fischer { 188*02c50d82SAndre Fischer // Gather the names of all the master pages in the given document. 189*02c50d82SAndre Fischer MasterPageContainer::data_type aMasterPageSet; 190*02c50d82SAndre Fischer sal_uInt16 nMasterPageCount = rDocument.GetMasterSdPageCount(PK_STANDARD); 191*02c50d82SAndre Fischer for (sal_uInt16 nIndex=0; nIndex<nMasterPageCount; nIndex++) 192*02c50d82SAndre Fischer { 193*02c50d82SAndre Fischer SdPage* pMasterPage = rDocument.GetMasterSdPage (nIndex, PK_STANDARD); 194*02c50d82SAndre Fischer if (pMasterPage != NULL) 195*02c50d82SAndre Fischer aMasterPageSet.insert (pMasterPage->GetName()); 196*02c50d82SAndre Fischer } 197*02c50d82SAndre Fischer 198*02c50d82SAndre Fischer maUsedMasterPages[&rDocument] = aMasterPageSet; 199*02c50d82SAndre Fischer 200*02c50d82SAndre Fischer StartListening (rDocument); 201*02c50d82SAndre Fischer } 202*02c50d82SAndre Fischer 203*02c50d82SAndre Fischer 204*02c50d82SAndre Fischer 205*02c50d82SAndre Fischer 206*02c50d82SAndre Fischer void MasterPageObserver::Implementation::UnregisterDocument ( 207*02c50d82SAndre Fischer SdDrawDocument& rDocument) 208*02c50d82SAndre Fischer { 209*02c50d82SAndre Fischer EndListening (rDocument); 210*02c50d82SAndre Fischer 211*02c50d82SAndre Fischer MasterPageContainer::iterator aMasterPageDescriptor(maUsedMasterPages.find(&rDocument)); 212*02c50d82SAndre Fischer if(aMasterPageDescriptor != maUsedMasterPages.end()) 213*02c50d82SAndre Fischer maUsedMasterPages.erase(aMasterPageDescriptor); 214*02c50d82SAndre Fischer } 215*02c50d82SAndre Fischer 216*02c50d82SAndre Fischer 217*02c50d82SAndre Fischer 218*02c50d82SAndre Fischer 219*02c50d82SAndre Fischer void MasterPageObserver::Implementation::AddEventListener ( 220*02c50d82SAndre Fischer const Link& rEventListener) 221*02c50d82SAndre Fischer { 222*02c50d82SAndre Fischer if (::std::find ( 223*02c50d82SAndre Fischer maListeners.begin(), 224*02c50d82SAndre Fischer maListeners.end(), 225*02c50d82SAndre Fischer rEventListener) == maListeners.end()) 226*02c50d82SAndre Fischer { 227*02c50d82SAndre Fischer maListeners.push_back (rEventListener); 228*02c50d82SAndre Fischer 229*02c50d82SAndre Fischer // Tell the new listener about all the master pages that are 230*02c50d82SAndre Fischer // currently in use. 231*02c50d82SAndre Fischer typedef ::std::vector<String> StringList; 232*02c50d82SAndre Fischer StringList aNewMasterPages; 233*02c50d82SAndre Fischer StringList aRemovedMasterPages; 234*02c50d82SAndre Fischer MasterPageContainer::iterator aDocumentIterator; 235*02c50d82SAndre Fischer for (aDocumentIterator=maUsedMasterPages.begin(); 236*02c50d82SAndre Fischer aDocumentIterator!=maUsedMasterPages.end(); 237*02c50d82SAndre Fischer ++aDocumentIterator) 238*02c50d82SAndre Fischer { 239*02c50d82SAndre Fischer ::std::set<String>::reverse_iterator aNameIterator; 240*02c50d82SAndre Fischer for (aNameIterator=aDocumentIterator->second.rbegin(); 241*02c50d82SAndre Fischer aNameIterator!=aDocumentIterator->second.rend(); 242*02c50d82SAndre Fischer ++aNameIterator) 243*02c50d82SAndre Fischer { 244*02c50d82SAndre Fischer MasterPageObserverEvent aEvent ( 245*02c50d82SAndre Fischer MasterPageObserverEvent::ET_MASTER_PAGE_EXISTS, 246*02c50d82SAndre Fischer *aDocumentIterator->first, 247*02c50d82SAndre Fischer *aNameIterator); 248*02c50d82SAndre Fischer SendEvent (aEvent); 249*02c50d82SAndre Fischer } 250*02c50d82SAndre Fischer } 251*02c50d82SAndre Fischer } 252*02c50d82SAndre Fischer } 253*02c50d82SAndre Fischer 254*02c50d82SAndre Fischer 255*02c50d82SAndre Fischer 256*02c50d82SAndre Fischer 257*02c50d82SAndre Fischer void MasterPageObserver::Implementation::RemoveEventListener ( 258*02c50d82SAndre Fischer const Link& rEventListener) 259*02c50d82SAndre Fischer { 260*02c50d82SAndre Fischer maListeners.erase ( 261*02c50d82SAndre Fischer ::std::find ( 262*02c50d82SAndre Fischer maListeners.begin(), 263*02c50d82SAndre Fischer maListeners.end(), 264*02c50d82SAndre Fischer rEventListener)); 265*02c50d82SAndre Fischer } 266*02c50d82SAndre Fischer 267*02c50d82SAndre Fischer 268*02c50d82SAndre Fischer 269*02c50d82SAndre Fischer 270*02c50d82SAndre Fischer MasterPageObserver::MasterPageNameSet 271*02c50d82SAndre Fischer MasterPageObserver::Implementation::GetMasterPageNames ( 272*02c50d82SAndre Fischer SdDrawDocument& rDocument) 273*02c50d82SAndre Fischer { 274*02c50d82SAndre Fischer MasterPageContainer::iterator aMasterPageDescriptor ( 275*02c50d82SAndre Fischer maUsedMasterPages.find(&rDocument)); 276*02c50d82SAndre Fischer if (aMasterPageDescriptor != maUsedMasterPages.end()) 277*02c50d82SAndre Fischer return aMasterPageDescriptor->second; 278*02c50d82SAndre Fischer else 279*02c50d82SAndre Fischer // Not found so return an empty set. 280*02c50d82SAndre Fischer return MasterPageObserver::MasterPageNameSet(); 281*02c50d82SAndre Fischer } 282*02c50d82SAndre Fischer 283*02c50d82SAndre Fischer 284*02c50d82SAndre Fischer 285*02c50d82SAndre Fischer 286*02c50d82SAndre Fischer void MasterPageObserver::Implementation::Notify( 287*02c50d82SAndre Fischer SfxBroadcaster& rBroadcaster, 288*02c50d82SAndre Fischer const SfxHint& rHint) 289*02c50d82SAndre Fischer { 290*02c50d82SAndre Fischer if (rHint.ISA(SdrHint)) 291*02c50d82SAndre Fischer { 292*02c50d82SAndre Fischer SdrHint& rSdrHint (*PTR_CAST(SdrHint,&rHint)); 293*02c50d82SAndre Fischer switch (rSdrHint.GetKind()) 294*02c50d82SAndre Fischer { 295*02c50d82SAndre Fischer case HINT_PAGEORDERCHG: 296*02c50d82SAndre Fischer // Process the modified set of pages only when the number of 297*02c50d82SAndre Fischer // standard and notes master pages are equal. This test 298*02c50d82SAndre Fischer // filters out events that are sent in between the insertion 299*02c50d82SAndre Fischer // of a new standard master page and a new notes master 300*02c50d82SAndre Fischer // page. 301*02c50d82SAndre Fischer if (rBroadcaster.ISA(SdDrawDocument)) 302*02c50d82SAndre Fischer { 303*02c50d82SAndre Fischer SdDrawDocument& rDocument ( 304*02c50d82SAndre Fischer static_cast<SdDrawDocument&>(rBroadcaster)); 305*02c50d82SAndre Fischer if (rDocument.GetMasterSdPageCount(PK_STANDARD) 306*02c50d82SAndre Fischer == rDocument.GetMasterSdPageCount(PK_NOTES)) 307*02c50d82SAndre Fischer { 308*02c50d82SAndre Fischer AnalyzeUsedMasterPages (rDocument); 309*02c50d82SAndre Fischer } 310*02c50d82SAndre Fischer } 311*02c50d82SAndre Fischer break; 312*02c50d82SAndre Fischer 313*02c50d82SAndre Fischer default: 314*02c50d82SAndre Fischer break; 315*02c50d82SAndre Fischer } 316*02c50d82SAndre Fischer } 317*02c50d82SAndre Fischer } 318*02c50d82SAndre Fischer 319*02c50d82SAndre Fischer 320*02c50d82SAndre Fischer 321*02c50d82SAndre Fischer 322*02c50d82SAndre Fischer void MasterPageObserver::Implementation::AnalyzeUsedMasterPages ( 323*02c50d82SAndre Fischer SdDrawDocument& rDocument) 324*02c50d82SAndre Fischer { 325*02c50d82SAndre Fischer // Create a set of names of the master pages used by the given document. 326*02c50d82SAndre Fischer sal_uInt16 nMasterPageCount = rDocument.GetMasterSdPageCount(PK_STANDARD); 327*02c50d82SAndre Fischer ::std::set<String> aCurrentMasterPages; 328*02c50d82SAndre Fischer for (sal_uInt16 nIndex=0; nIndex<nMasterPageCount; nIndex++) 329*02c50d82SAndre Fischer { 330*02c50d82SAndre Fischer SdPage* pMasterPage = rDocument.GetMasterSdPage (nIndex, PK_STANDARD); 331*02c50d82SAndre Fischer if (pMasterPage != NULL) 332*02c50d82SAndre Fischer aCurrentMasterPages.insert (pMasterPage->GetName()); 333*02c50d82SAndre Fischer OSL_TRACE("currently used master page %d is %s", 334*02c50d82SAndre Fischer nIndex, 335*02c50d82SAndre Fischer ::rtl::OUStringToOString(pMasterPage->GetName(), 336*02c50d82SAndre Fischer RTL_TEXTENCODING_UTF8).getStr()); 337*02c50d82SAndre Fischer } 338*02c50d82SAndre Fischer 339*02c50d82SAndre Fischer typedef ::std::vector<String> StringList; 340*02c50d82SAndre Fischer StringList aNewMasterPages; 341*02c50d82SAndre Fischer StringList aRemovedMasterPages; 342*02c50d82SAndre Fischer MasterPageContainer::iterator aOldMasterPagesDescriptor ( 343*02c50d82SAndre Fischer maUsedMasterPages.find(&rDocument)); 344*02c50d82SAndre Fischer if (aOldMasterPagesDescriptor != maUsedMasterPages.end()) 345*02c50d82SAndre Fischer { 346*02c50d82SAndre Fischer StringList::iterator I; 347*02c50d82SAndre Fischer 348*02c50d82SAndre Fischer ::std::set<String>::iterator J; 349*02c50d82SAndre Fischer int i=0; 350*02c50d82SAndre Fischer for (J=aOldMasterPagesDescriptor->second.begin(); 351*02c50d82SAndre Fischer J!=aOldMasterPagesDescriptor->second.end(); 352*02c50d82SAndre Fischer ++J) 353*02c50d82SAndre Fischer OSL_TRACE("old used master page %d is %s", 354*02c50d82SAndre Fischer i++, 355*02c50d82SAndre Fischer ::rtl::OUStringToOString(*J, 356*02c50d82SAndre Fischer RTL_TEXTENCODING_UTF8).getStr()); 357*02c50d82SAndre Fischer 358*02c50d82SAndre Fischer // Send events about the newly used master pages. 359*02c50d82SAndre Fischer ::std::set_difference ( 360*02c50d82SAndre Fischer aCurrentMasterPages.begin(), 361*02c50d82SAndre Fischer aCurrentMasterPages.end(), 362*02c50d82SAndre Fischer aOldMasterPagesDescriptor->second.begin(), 363*02c50d82SAndre Fischer aOldMasterPagesDescriptor->second.end(), 364*02c50d82SAndre Fischer ::std::back_insert_iterator<StringList>(aNewMasterPages)); 365*02c50d82SAndre Fischer for (I=aNewMasterPages.begin(); I!=aNewMasterPages.end(); ++I) 366*02c50d82SAndre Fischer { 367*02c50d82SAndre Fischer OSL_TRACE(" added master page %s", 368*02c50d82SAndre Fischer ::rtl::OUStringToOString(*I, 369*02c50d82SAndre Fischer RTL_TEXTENCODING_UTF8).getStr()); 370*02c50d82SAndre Fischer 371*02c50d82SAndre Fischer MasterPageObserverEvent aEvent ( 372*02c50d82SAndre Fischer MasterPageObserverEvent::ET_MASTER_PAGE_ADDED, 373*02c50d82SAndre Fischer rDocument, 374*02c50d82SAndre Fischer *I); 375*02c50d82SAndre Fischer SendEvent (aEvent); 376*02c50d82SAndre Fischer } 377*02c50d82SAndre Fischer 378*02c50d82SAndre Fischer // Send events about master pages that are not used any longer. 379*02c50d82SAndre Fischer ::std::set_difference ( 380*02c50d82SAndre Fischer aOldMasterPagesDescriptor->second.begin(), 381*02c50d82SAndre Fischer aOldMasterPagesDescriptor->second.end(), 382*02c50d82SAndre Fischer aCurrentMasterPages.begin(), 383*02c50d82SAndre Fischer aCurrentMasterPages.end(), 384*02c50d82SAndre Fischer ::std::back_insert_iterator<StringList>(aRemovedMasterPages)); 385*02c50d82SAndre Fischer for (I=aRemovedMasterPages.begin(); I!=aRemovedMasterPages.end(); ++I) 386*02c50d82SAndre Fischer { 387*02c50d82SAndre Fischer OSL_TRACE(" removed master page %s", 388*02c50d82SAndre Fischer ::rtl::OUStringToOString(*I, 389*02c50d82SAndre Fischer RTL_TEXTENCODING_UTF8).getStr()); 390*02c50d82SAndre Fischer 391*02c50d82SAndre Fischer MasterPageObserverEvent aEvent ( 392*02c50d82SAndre Fischer MasterPageObserverEvent::ET_MASTER_PAGE_REMOVED, 393*02c50d82SAndre Fischer rDocument, 394*02c50d82SAndre Fischer *I); 395*02c50d82SAndre Fischer SendEvent (aEvent); 396*02c50d82SAndre Fischer } 397*02c50d82SAndre Fischer 398*02c50d82SAndre Fischer // Store the new list of master pages. 399*02c50d82SAndre Fischer aOldMasterPagesDescriptor->second = aCurrentMasterPages; 400*02c50d82SAndre Fischer } 401*02c50d82SAndre Fischer } 402*02c50d82SAndre Fischer 403*02c50d82SAndre Fischer 404*02c50d82SAndre Fischer 405*02c50d82SAndre Fischer 406*02c50d82SAndre Fischer void MasterPageObserver::Implementation::SendEvent ( 407*02c50d82SAndre Fischer MasterPageObserverEvent& rEvent) 408*02c50d82SAndre Fischer { 409*02c50d82SAndre Fischer ::std::vector<Link>::iterator aLink (maListeners.begin()); 410*02c50d82SAndre Fischer ::std::vector<Link>::iterator aEnd (maListeners.end()); 411*02c50d82SAndre Fischer while (aLink!=aEnd) 412*02c50d82SAndre Fischer { 413*02c50d82SAndre Fischer aLink->Call (&rEvent); 414*02c50d82SAndre Fischer ++aLink; 415*02c50d82SAndre Fischer } 416*02c50d82SAndre Fischer } 417*02c50d82SAndre Fischer 418*02c50d82SAndre Fischer 419*02c50d82SAndre Fischer } // end of namespace sd 420