1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_FILLER_HXX 25 #define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_FILLER_HXX 26 27 #include "MasterPageContainer.hxx" 28 #include "MasterPageDescriptor.hxx" 29 #include "tools/AsynchronousTask.hxx" 30 31 namespace sd { 32 class TemplateScanner; 33 class TemplateEntry; 34 } 35 36 namespace sd { namespace toolpanel { namespace controls { 37 38 /** Fill a MasterPageContainer with information about the available master 39 pages. These are provided by one default page and from the existing 40 Impress templates. This is done asynchronously. 41 */ 42 class MasterPageContainerFiller 43 : public ::sd::tools::AsynchronousTask 44 { 45 public: 46 class ContainerAdapter 47 { 48 public: 49 virtual MasterPageContainer::Token PutMasterPage ( 50 const SharedMasterPageDescriptor& rpDescriptor) = 0; 51 /** This method is called when all Impress templates have been added 52 to the container via the PutMasterPage() method. 53 */ 54 virtual void FillingDone (void) = 0; 55 }; 56 57 MasterPageContainerFiller (ContainerAdapter& rContainerAdapter); 58 virtual ~MasterPageContainerFiller (void); 59 60 /** Run the next step of the task. After HasNextStep() returns false 61 this method should ignore further calls. 62 */ 63 virtual void RunNextStep (void); 64 65 /** Return <TRUE/> when there is at least one more step to execute. 66 When the task has been executed completely then <FALSE/> is 67 returned. 68 */ 69 virtual bool HasNextStep (void); 70 71 private: 72 ContainerAdapter& mrContainerAdapter; 73 // Remember what the next step has to do. 74 enum State { 75 INITIALIZE_TEMPLATE_SCANNER, 76 SCAN_TEMPLATE, 77 ADD_TEMPLATE, 78 ERROR, 79 DONE 80 } meState; 81 ::std::auto_ptr<TemplateScanner> mpScannerTask; 82 const TemplateEntry* mpLastAddedEntry; 83 int mnIndex; 84 85 State ScanTemplate (void); 86 State AddTemplate (void); 87 }; 88 89 } } } // end of namespace ::sd::toolpanel::controls 90 91 #endif 92