You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by af...@apache.org on 2013/02/22 14:50:46 UTC

svn commit: r1449041 [1/5] - in /openoffice/branches/sidebar/main: officecfg/registry/data/org/openoffice/Office/UI/ sd/prj/ sd/sdi/ sd/source/ui/app/ sd/source/ui/framework/factories/ sd/source/ui/framework/module/ sd/source/ui/func/ sd/source/ui/inc/...

Author: af
Date: Fri Feb 22 13:50:42 2013
New Revision: 1449041

URL: http://svn.apache.org/r1449041
Log:
i121420: Impress panels do not use the drawing framework anymore.

Added:
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/AllMasterPagesSelector.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/AllMasterPagesSelector.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/CustomAnimationPanel.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/CustomAnimationPanel.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/DocumentHelper.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/DocumentHelper.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/IDisposable.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/ISidebarReceiver.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/LayoutMenu.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/LayoutMenu.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageContainer.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageContainer.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageContainerFiller.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageContainerFiller.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageContainerProviders.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageContainerProviders.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageContainerQueue.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageContainerQueue.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageDescriptor.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageDescriptor.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPageObserver.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPagesSelector.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/MasterPagesSelector.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/PanelBase.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/PanelBase.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/PreviewValueSet.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/PreviewValueSet.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/RecentMasterPagesSelector.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/RecentlyUsedMasterPages.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/RecentlyUsedMasterPages.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/SidebarShellManager.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/SidebarShellManager.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/SlideTransitionPanel.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/SlideTransitionPanel.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/TableDesignPanel.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/TableDesignPanel.hxx
    openoffice/branches/sidebar/main/sfx2/inc/sfx2/sidebar/ILayoutableWindow.hxx
    openoffice/branches/sidebar/main/svx/inc/GalleryControl.hxx
    openoffice/branches/sidebar/main/svx/source/gallery2/GalleryControl.cxx
    openoffice/branches/sidebar/main/svx/source/gallery2/GallerySplitter.cxx
    openoffice/branches/sidebar/main/svx/source/gallery2/GallerySplitter.hxx
    openoffice/branches/sidebar/main/svx/source/sidebar/gallery/
    openoffice/branches/sidebar/main/svx/source/sidebar/gallery/GalleryControl.hxx
    openoffice/branches/sidebar/main/svx/source/sidebar/gallery/GalleryPanel.hxx
Removed:
    openoffice/branches/sidebar/main/sd/sdi/SidebarViewShell.sdi
    openoffice/branches/sidebar/main/sd/source/ui/inc/SidebarViewShell.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/SidebarViewShell.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/UIElementWrapper.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/UIElementWrapper.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/panels/
Modified:
    openoffice/branches/sidebar/main/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
    openoffice/branches/sidebar/main/sd/prj/build.lst
    openoffice/branches/sidebar/main/sd/sdi/makefile.mk
    openoffice/branches/sidebar/main/sd/sdi/sdslots.sdi
    openoffice/branches/sidebar/main/sd/source/ui/app/sddll1.cxx
    openoffice/branches/sidebar/main/sd/source/ui/framework/factories/BasicViewFactory.cxx
    openoffice/branches/sidebar/main/sd/source/ui/framework/factories/TaskPanelResource.cxx
    openoffice/branches/sidebar/main/sd/source/ui/framework/factories/makefile.mk
    openoffice/branches/sidebar/main/sd/source/ui/framework/module/ModuleController.cxx
    openoffice/branches/sidebar/main/sd/source/ui/func/futext.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/SidebarFactory.cxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/SidebarFactory.hxx
    openoffice/branches/sidebar/main/sd/source/ui/sidebar/makefile.mk
    openoffice/branches/sidebar/main/sd/source/ui/unoidl/facreg.cxx
    openoffice/branches/sidebar/main/sd/source/ui/view/sdview.cxx
    openoffice/branches/sidebar/main/sd/util/makefile.mk
    openoffice/branches/sidebar/main/sfx2/Package_inc.mk
    openoffice/branches/sidebar/main/sfx2/inc/sfx2/sidebar/SidebarPanelBase.hxx
    openoffice/branches/sidebar/main/sfx2/source/sidebar/Panel.cxx
    openoffice/branches/sidebar/main/sfx2/source/sidebar/Panel.hxx
    openoffice/branches/sidebar/main/sfx2/source/sidebar/PanelTitleBar.cxx
    openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarController.cxx
    openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarController.hxx
    openoffice/branches/sidebar/main/sfx2/source/sidebar/SidebarPanelBase.cxx
    openoffice/branches/sidebar/main/svx/Library_svxcore.mk
    openoffice/branches/sidebar/main/svx/inc/galbrws2.hxx
    openoffice/branches/sidebar/main/svx/inc/svx/galbrws.hxx
    openoffice/branches/sidebar/main/svx/source/gallery2/galbrws.cxx
    openoffice/branches/sidebar/main/svx/source/gallery2/galbrws1.cxx
    openoffice/branches/sidebar/main/svx/source/gallery2/galbrws1.hxx
    openoffice/branches/sidebar/main/svx/source/gallery2/galbrws2.cxx
    openoffice/branches/sidebar/main/svx/source/gallery2/gallery1.cxx
    openoffice/branches/sidebar/main/svx/source/sidebar/PanelFactory.cxx
    openoffice/branches/sidebar/main/svx/source/sidebar/geometry/AreaPropertyPanel.cxx
    openoffice/branches/sidebar/main/svx/source/sidebar/geometry/AreaPropertyPanel.hxx
    openoffice/branches/sidebar/main/svx/source/sidebar/geometry/AreaPropertyPanel.src
    openoffice/branches/sidebar/main/svx/source/sidebar/geometry/GraphicPropertyPanel.src
    openoffice/branches/sidebar/main/svx/source/sidebar/geometry/LinePropertyPanel.src
    openoffice/branches/sidebar/main/svx/source/sidebar/geometry/TransformationPropertyPanel.src

Modified: openoffice/branches/sidebar/main/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu?rev=1449041&r1=1449040&r2=1449041&view=diff
==============================================================================
Binary files - no diff available.

Modified: openoffice/branches/sidebar/main/sd/prj/build.lst
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/prj/build.lst?rev=1449041&r1=1449040&r2=1449041&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/prj/build.lst (original)
+++ openoffice/branches/sidebar/main/sd/prj/build.lst Fri Feb 22 13:50:42 2013
@@ -20,7 +20,6 @@ sd	sd\source\ui\unoidl						nmake	-	all	
 sd	sd\source\ui\accessibility				nmake	-	all	sd_accessibility sd_inc NULL
 sd	sd\source\ui\tools      				nmake	-	all	sd_tools sd_inc NULL
 sd	sd\source\ui\sidebar         			nmake	-	all	sd_sidebar sd_sdi sd_inc NULL
-sd	sd\source\ui\sidebar\panels  			nmake	-	all	sd_sidebar_panels sd_sdi sd_inc NULL
 sd	sd\source\ui\slidesorter\shell			nmake	-	all	sd_slsshell sd_sdi sd_inc NULL
 sd	sd\source\ui\slidesorter\model			nmake	-	all	sd_slsmodel sd_inc NULL
 sd	sd\source\ui\slidesorter\view			nmake	-	all	sd_slsview sd_inc NULL
@@ -44,5 +43,5 @@ sd	sd\source\ui\framework\module       	
 sd	sd\source\ui\framework\factories       	nmake	-	all sd_framework_factories sd_inc NULL
 sd	sd\source\ui\framework\tools           	nmake	-	all sd_framework_tools sd_inc NULL
 sd	sd\source\ui\annotations				nmake	-	all sd_uiannotations sd_inc NULL
-sd	sd\util									nmake	-	all	sd_util sd_app sd_cgm sd_core sd_dlg sd_docsh sd_eppt sd_filt sd_func sd_grf sd_unid sd_view sd_xml sd_html sd_ppt sd_accessibility sd_animations sd_tools sd_slsshell sd_slsmodel sd_slsview sd_slscontroller sd_slscache sd_notes sd_controller sd_table sd_slideshow sd_presenter sd_undo sd_helper sd_framework_configuration sd_framework_module sd_framework_tools sd_framework_factories sd_text sd_annotations sd_uiannotations sd_sidebar sd_sidebar_panels NULL
+sd	sd\util									nmake	-	all	sd_util sd_app sd_cgm sd_core sd_dlg sd_docsh sd_eppt sd_filt sd_func sd_grf sd_unid sd_view sd_xml sd_html sd_ppt sd_accessibility sd_animations sd_tools sd_slsshell sd_slsmodel sd_slsview sd_slscontroller sd_slscache sd_notes sd_controller sd_table sd_slideshow sd_presenter sd_undo sd_helper sd_framework_configuration sd_framework_module sd_framework_tools sd_framework_factories sd_text sd_annotations sd_uiannotations sd_sidebar NULL
 sd sd\qa\unoapi nmake - all sd_qa_unoapi NULL

Modified: openoffice/branches/sidebar/main/sd/sdi/makefile.mk
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/sdi/makefile.mk?rev=1449041&r1=1449040&r2=1449041&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/sdi/makefile.mk (original)
+++ openoffice/branches/sidebar/main/sd/sdi/makefile.mk Fri Feb 22 13:50:42 2013
@@ -61,7 +61,6 @@ SVSDI1DEPEND= \
         tables.sdi\
 	outlnvsh.sdi \
 	SlideSorterController.sdi \
-	SidebarViewShell.sdi \
 	ViewShellBase.sdi \
 	sdslots.hrc \
 	$(PRJ)$/inc$/app.hrc
@@ -84,7 +83,6 @@ SVSDI2DEPEND= \
         mediaob.sdi \
 	outlnvsh.sdi \
 	ViewShellBase.sdi \
-	SidebarViewShell.sdi \
 	sdslots.hrc \
 	$(PRJ)$/inc$/app.hrc
 

Modified: openoffice/branches/sidebar/main/sd/sdi/sdslots.sdi
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/sdi/sdslots.sdi?rev=1449041&r1=1449040&r2=1449041&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/sdi/sdslots.sdi (original)
+++ openoffice/branches/sidebar/main/sd/sdi/sdslots.sdi Fri Feb 22 13:50:42 2013
@@ -100,5 +100,4 @@ ModulePrefix( "Sd" )
         include "ViewShellBase.sdi"
 		include "mediaob.sdi"
 		include "tables.sdi"	
-        include "SidebarViewShell.sdi"
-}
+        }

Modified: openoffice/branches/sidebar/main/sd/source/ui/app/sddll1.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/app/sddll1.cxx?rev=1449041&r1=1449040&r2=1449041&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/app/sddll1.cxx (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/app/sddll1.cxx Fri Feb 22 13:50:42 2013
@@ -45,7 +45,6 @@
 #include "DrawDocShell.hxx"
 #include "GraphicDocShell.hxx"
 #include "SlideSorterViewShell.hxx"
-#include "SidebarViewShell.hxx"
 #include "FactoryIds.hxx"
 #include "sdmod.hxx"
 #include "app.hrc"
@@ -123,8 +122,4 @@ void SdDLL::RegisterInterfaces()
 
     // View shells for the side panes.
     ::sd::slidesorter::SlideSorterViewShell::RegisterInterface (pMod);
-	::sd::sidebar::SidebarViewShell::RegisterInterface(pMod);
-    // Tell the tool panel view shell to register the interfaces of its
-    // controls.
-	::sd::sidebar::SidebarViewShell::RegisterControls();
 }

Modified: openoffice/branches/sidebar/main/sd/source/ui/framework/factories/BasicViewFactory.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/framework/factories/BasicViewFactory.cxx?rev=1449041&r1=1449040&r2=1449041&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/framework/factories/BasicViewFactory.cxx (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/framework/factories/BasicViewFactory.cxx Fri Feb 22 13:50:42 2013
@@ -38,7 +38,6 @@
 #include "DrawViewShell.hxx"
 #include "GraphicViewShell.hxx"
 #include "OutlineViewShell.hxx"
-#include "SidebarViewShell.hxx"
 #include "PresentationViewShell.hxx"
 #include "SlideSorterViewShell.hxx"
 #include "FrameView.hxx"
@@ -327,7 +326,6 @@ void SAL_CALL BasicViewFactory::initiali
             mxConfigurationController->addResourceFactory(FrameworkHelper::msNotesViewURL, this);
             mxConfigurationController->addResourceFactory(FrameworkHelper::msHandoutViewURL, this);
             mxConfigurationController->addResourceFactory(FrameworkHelper::msPresentationViewURL, this);
-            mxConfigurationController->addResourceFactory(FrameworkHelper::msSidebarViewURL, this);
             mxConfigurationController->addResourceFactory(FrameworkHelper::msSlideSorterURL, this);
         }
         catch (RuntimeException&)
@@ -445,15 +443,6 @@ void SAL_CALL BasicViewFactory::initiali
                 &rWindow,
                 pFrameView));
     }
-    else if (rsViewURL.equals(FrameworkHelper::msSidebarViewURL))
-    {
-        pViewShell.reset(
-            new ::sd::sidebar::SidebarViewShell(
-                &rFrame,
-                *mpBase,
-                &rWindow,
-                pFrameView));
-    }
     else if (rsViewURL.equals(FrameworkHelper::msSlideSorterURL))
     {
         pViewShell = ::sd::slidesorter::SlideSorterViewShell::Create (

Modified: openoffice/branches/sidebar/main/sd/source/ui/framework/factories/TaskPanelResource.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/framework/factories/TaskPanelResource.cxx?rev=1449041&r1=1449040&r2=1449041&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/framework/factories/TaskPanelResource.cxx (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/framework/factories/TaskPanelResource.cxx Fri Feb 22 13:50:42 2013
@@ -21,8 +21,6 @@
 
 #include "precompiled_sd.hxx"
 
-#include "SidebarViewShell.hxx"
-
 #include "framework/TaskPanelResource.hxx"
 
 #include <vcl/window.hxx>

Modified: openoffice/branches/sidebar/main/sd/source/ui/framework/factories/makefile.mk
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/framework/factories/makefile.mk?rev=1449041&r1=1449040&r2=1449041&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/framework/factories/makefile.mk (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/framework/factories/makefile.mk Fri Feb 22 13:50:42 2013
@@ -47,8 +47,6 @@ SLOFILES =      							\
 	$(SLO)$/FullScreenPane.obj				\
 	$(SLO)$/Pane.obj						\
 	$(SLO)$/PresentationFactory.obj			\
-	$(SLO)$/TaskPanelFactory.obj			\
-	$(SLO)$/TaskPanelResource.obj			\
 	$(SLO)$/ViewShellWrapper.obj
 
 # --- Tagets -------------------------------------------------------

Modified: openoffice/branches/sidebar/main/sd/source/ui/framework/module/ModuleController.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/framework/module/ModuleController.cxx?rev=1449041&r1=1449040&r2=1449041&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/framework/module/ModuleController.cxx (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/framework/module/ModuleController.cxx Fri Feb 22 13:50:42 2013
@@ -304,9 +304,18 @@ void SAL_CALL ModuleController::requestR
                 // Create the factory service.
                 Sequence<Any> aArguments(1);
                 aArguments[0] <<= mxController;
-                xFactory = xGlobalFactory->createInstanceWithArguments(
-                    iFactory->second,
-                    aArguments);
+                OSL_TRACE("creating resource %s",
+                    OUStringToOString(iFactory->second, RTL_TEXTENCODING_ASCII_US).getStr());
+                try
+                {
+                    xFactory = xGlobalFactory->createInstanceWithArguments(
+                        iFactory->second,
+                        aArguments);
+                }
+                catch(Exception&e)
+                {
+                    OSL_TRACE("caught exception while creating factory.");
+                }
 
                 // Remember that this factory has been instanced.
                 (*mpLoadedFactories)[iFactory->second] = xFactory;

Modified: openoffice/branches/sidebar/main/sd/source/ui/func/futext.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/func/futext.cxx?rev=1449041&r1=1449040&r2=1449041&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/func/futext.cxx (original)
+++ openoffice/branches/sidebar/main/sd/source/ui/func/futext.cxx Fri Feb 22 13:50:42 2013
@@ -1185,7 +1185,8 @@ void FuText::SetInEditMode(const MouseEv
 						{
 							// #98198# Move cursor to end of text
 							ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
-							pOLV->SetSelection(aNewSelection);
+							if (pOLV != NULL)
+								pOLV->SetSelection(aNewSelection);
 						}
 					}
 					else

Added: openoffice/branches/sidebar/main/sd/source/ui/sidebar/AllMasterPagesSelector.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/AllMasterPagesSelector.cxx?rev=1449041&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/AllMasterPagesSelector.cxx (added)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/AllMasterPagesSelector.cxx Fri Feb 22 13:50:42 2013
@@ -0,0 +1,231 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "AllMasterPagesSelector.hxx"
+#include "PreviewValueSet.hxx"
+#include "ViewShellBase.hxx"
+#include "SidebarShellManager.hxx"
+#include "MasterPageContainer.hxx"
+#include "MasterPageDescriptor.hxx"
+#include "app.hrc"
+#include "helpids.h"
+
+#include <tools/link.hxx>
+#include <set>
+
+namespace {
+
+using namespace sd::sidebar;
+
+int GetURLPriority (const SharedMasterPageDescriptor& rpDescriptor)
+{
+    int nPriority (0);
+    switch (rpDescriptor->GetURLClassification())
+    {
+        case MasterPageDescriptor::URLCLASS_USER:         nPriority = 0; break;
+        case MasterPageDescriptor::URLCLASS_LAYOUT:       nPriority = 1; break;
+        case MasterPageDescriptor::URLCLASS_PRESENTATION: nPriority = 2; break;
+        case MasterPageDescriptor::URLCLASS_OTHER:        nPriority = 3; break;
+        case MasterPageDescriptor::URLCLASS_UNKNOWN:      nPriority = 4; break;
+        default:
+        case MasterPageDescriptor::URLCLASS_UNDETERMINED: nPriority = 5; break;
+    }
+    return nPriority;
+}
+
+
+class MasterPageDescriptorOrder
+{
+public:
+    bool operator() (
+        const SharedMasterPageDescriptor& rp1,
+        const SharedMasterPageDescriptor& rp2)
+    {
+        if (rp1->meOrigin == MasterPageContainer::DEFAULT)
+            return true;
+        else if (rp2->meOrigin == MasterPageContainer::DEFAULT)
+            return false;
+        else if (rp1->GetURLClassification() == rp2->GetURLClassification())
+            return rp1->mnTemplateIndex < rp2->mnTemplateIndex;
+        else
+            return GetURLPriority(rp1) < GetURLPriority(rp2);
+    }
+};
+
+} // end of anonymous namespace
+
+
+
+namespace sd { namespace sidebar {
+
+class AllMasterPagesSelector::SortedMasterPageDescriptorList
+    : public ::std::set<SharedMasterPageDescriptor,MasterPageDescriptorOrder>
+{
+public:
+    SortedMasterPageDescriptorList (void) {}
+};
+
+
+
+
+MasterPagesSelector* AllMasterPagesSelector::Create (
+    ::Window* pParent,
+    ViewShellBase& rViewShellBase,
+    const cssu::Reference<css::ui::XSidebar>& rxSidebar)
+{
+    SdDrawDocument* pDocument = rViewShellBase.GetDocument();
+    if (pDocument == NULL)
+        return NULL;
+
+    ::boost::shared_ptr<MasterPageContainer> pContainer (new MasterPageContainer());
+    
+    MasterPagesSelector* pSelector(
+        new AllMasterPagesSelector (
+            pParent, 
+            *pDocument,
+            rViewShellBase,
+            pContainer,
+            rxSidebar));
+    pSelector->LateInit();
+    pSelector->SetHelpId(HID_SD_TASK_PANE_PREVIEW_ALL);
+
+    return pSelector;
+}
+
+
+
+
+AllMasterPagesSelector::AllMasterPagesSelector (
+    ::Window* pParent,
+    SdDrawDocument& rDocument,
+    ViewShellBase& rBase,
+    const ::boost::shared_ptr<MasterPageContainer>& rpContainer,
+    const cssu::Reference<css::ui::XSidebar>& rxSidebar)
+    : MasterPagesSelector(pParent, rDocument, rBase, rpContainer, rxSidebar),
+      mpSortedMasterPages(new SortedMasterPageDescriptorList())
+{
+    MasterPagesSelector::Fill();
+}
+
+
+
+
+AllMasterPagesSelector::~AllMasterPagesSelector (void)
+{
+}
+
+
+
+
+void AllMasterPagesSelector::Fill (ItemList& rItemList)
+{
+    if (mpSortedMasterPages->empty())
+        UpdateMasterPageList();
+    UpdatePageSet(rItemList);
+}
+
+
+
+
+void AllMasterPagesSelector::NotifyContainerChangeEvent (
+    const MasterPageContainerChangeEvent& rEvent)
+{
+    switch (rEvent.meEventType)
+    {
+        case MasterPageContainerChangeEvent::CHILD_ADDED:
+            AddItem(rEvent.maChildToken);
+            MasterPagesSelector::Fill();
+            break;
+            
+        case MasterPageContainerChangeEvent::INDEX_CHANGED:
+        case MasterPageContainerChangeEvent::INDEXES_CHANGED:
+            mpSortedMasterPages->clear();
+            MasterPagesSelector::Fill();
+            break;
+
+        default:
+            MasterPagesSelector::NotifyContainerChangeEvent(rEvent);
+            break;
+    }
+}
+
+
+
+
+void AllMasterPagesSelector::UpdateMasterPageList (void)
+{
+    mpSortedMasterPages->clear();
+    int nTokenCount = mpContainer->GetTokenCount();
+    for (int i=0; i<nTokenCount; i++)
+        AddItem(mpContainer->GetTokenForIndex(i));
+}
+
+
+
+
+void AllMasterPagesSelector::AddItem (MasterPageContainer::Token aToken)
+{
+    switch (mpContainer->GetOriginForToken(aToken))
+    {
+        case MasterPageContainer::DEFAULT:
+        case MasterPageContainer::TEMPLATE:
+            // Templates are added only when coming from the
+            // MasterPageContainerFiller so that they have an id which
+            // defines their place in the list.  Templates (pre) loaded from
+            // RecentlyUsedMasterPages are ignored (they will be loaded
+            // later by the MasterPageContainerFiller.)
+            if (mpContainer->GetTemplateIndexForToken(aToken) >= 0)
+                mpSortedMasterPages->insert(mpContainer->GetDescriptorForToken(aToken));
+            break;
+
+        default:
+            break;
+    }
+}
+
+
+
+
+void AllMasterPagesSelector::UpdatePageSet (ItemList& rItemList)
+{
+    SortedMasterPageDescriptorList::const_iterator iDescriptor;
+    SortedMasterPageDescriptorList::const_iterator iEnd (mpSortedMasterPages->end());
+    for (iDescriptor=mpSortedMasterPages->begin(); iDescriptor!=iEnd; ++iDescriptor)
+        rItemList.push_back((*iDescriptor)->maToken);
+}
+
+
+
+
+void AllMasterPagesSelector::GetState (SfxItemSet& rItemSet)
+{
+    //    MasterPagesSelector::GetState(rItemSet);
+
+	if (rItemSet.GetItemState(SID_TP_EDIT_MASTER) == SFX_ITEM_AVAILABLE)
+        rItemSet.DisableItem(SID_TP_EDIT_MASTER);
+}
+
+
+
+
+} } // end of namespace sd::sidebar

Added: openoffice/branches/sidebar/main/sd/source/ui/sidebar/AllMasterPagesSelector.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/AllMasterPagesSelector.hxx?rev=1449041&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/AllMasterPagesSelector.hxx (added)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/AllMasterPagesSelector.hxx Fri Feb 22 13:50:42 2013
@@ -0,0 +1,91 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#ifndef SD_SIDEBAR_PANELS_ALL_MASTER_PAGES_SELECTOR_HXX
+#define SD_SIDEBAR_PANELS_ALL_MASTER_PAGES_SELECTOR_HXX
+
+#include "MasterPagesSelector.hxx"
+
+#include <memory>
+
+namespace sd { namespace sidebar {
+
+
+/** Show a list of all available master pages so that the user can assign
+    them to the document.
+*/
+class AllMasterPagesSelector
+    : public MasterPagesSelector
+{
+public:
+    static MasterPagesSelector* Create (
+        ::Window* pParent,
+        ViewShellBase& rViewShellBase,
+        const cssu::Reference<css::ui::XSidebar>& rxSidebar);
+    
+    /** Scan the set of templates for the ones whose first master pages are
+        shown by this control and store them in the MasterPageContainer.
+    */
+    virtual void Fill (ItemList& rItemList);
+
+    virtual void GetState (SfxItemSet& rItemSet);
+
+protected:
+    virtual void NotifyContainerChangeEvent (const MasterPageContainerChangeEvent& rEvent);
+
+private:
+    /** The list of master pages displayed by this class.
+    */
+    class SortedMasterPageDescriptorList;
+    ::std::auto_ptr<SortedMasterPageDescriptorList> mpSortedMasterPages;
+
+    AllMasterPagesSelector (
+        ::Window* pParent, 
+        SdDrawDocument& rDocument,
+        ViewShellBase& rBase,
+        const ::boost::shared_ptr<MasterPageContainer>& rpContainer,
+        const cssu::Reference<css::ui::XSidebar>& rxSidebar);
+    virtual ~AllMasterPagesSelector (void);
+
+    void AddTemplate (const TemplateEntry& rEntry);
+
+    /** This filter returns <TRUE/> when the master page specified by the
+        given file name belongs to the set of Impress master pages.
+    */
+    bool FileFilter (const String& sFileName);
+
+    void AddItem (MasterPageContainer::Token aToken);
+
+    /** Add all items in the internal master page list into the given list.
+    */
+    void UpdatePageSet (ItemList& rItemList);
+
+    /** Update the internal list of master pages that are to show in the
+        control.
+    */
+    void UpdateMasterPageList (void);
+
+	using MasterPagesSelector::Fill;
+};
+
+} } // end of namespace sd::sidebar
+
+#endif

Added: openoffice/branches/sidebar/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx?rev=1449041&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx (added)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx Fri Feb 22 13:50:42 2013
@@ -0,0 +1,355 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "CurrentMasterPagesSelector.hxx"
+#include "PreviewValueSet.hxx"
+#include "ViewShellBase.hxx"
+#include "SidebarShellManager.hxx"
+#include "DrawViewShell.hxx"
+#include "drawdoc.hxx"
+#include "sdpage.hxx"
+#include "MasterPageContainer.hxx"
+#include "MasterPageDescriptor.hxx"
+#include "EventMultiplexer.hxx"
+#include "app.hrc"
+#include "DrawDocShell.hxx"
+#include "DrawViewShell.hxx"
+#include "res_bmp.hrc"
+#include "sdresid.hxx"
+#include "helpids.h"
+
+#include <vcl/image.hxx>
+#include <svx/svdmodel.hxx>
+#include <sfx2/request.hxx>
+
+#include <set>
+
+
+using namespace ::com::sun::star;
+
+namespace sd { namespace sidebar {
+
+MasterPagesSelector* CurrentMasterPagesSelector::Create (
+    ::Window* pParent,
+    ViewShellBase& rViewShellBase,
+    const cssu::Reference<css::ui::XSidebar>& rxSidebar)
+{
+    SdDrawDocument* pDocument = rViewShellBase.GetDocument();
+    if (pDocument == NULL)
+        return NULL;
+
+    ::boost::shared_ptr<MasterPageContainer> pContainer (new MasterPageContainer());
+    
+    MasterPagesSelector* pSelector(
+        new CurrentMasterPagesSelector (
+            pParent, 
+            *pDocument,
+            rViewShellBase,
+            pContainer,
+            rxSidebar));
+    pSelector->LateInit();
+    pSelector->SetHelpId( HID_SD_TASK_PANE_PREVIEW_CURRENT );
+
+    return pSelector;
+}
+
+
+
+
+CurrentMasterPagesSelector::CurrentMasterPagesSelector (
+    ::Window* pParent,
+    SdDrawDocument& rDocument,
+    ViewShellBase& rBase,
+    const ::boost::shared_ptr<MasterPageContainer>& rpContainer,
+    const cssu::Reference<css::ui::XSidebar>& rxSidebar)
+    : MasterPagesSelector (pParent, rDocument, rBase, rpContainer, rxSidebar)
+{
+    // For this master page selector only we change the default action for
+    // left clicks.
+    mnDefaultClickAction = SID_TP_APPLY_TO_SELECTED_SLIDES;
+
+    Link aLink (LINK(this,CurrentMasterPagesSelector,EventMultiplexerListener));
+    rBase.GetEventMultiplexer()->AddEventListener(aLink,
+        sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE
+        | sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL
+        | sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER
+        | sd::tools::EventMultiplexerEvent::EID_PAGE_ORDER
+        | sd::tools::EventMultiplexerEvent::EID_SHAPE_CHANGED
+        | sd::tools::EventMultiplexerEvent::EID_SHAPE_INSERTED
+        | sd::tools::EventMultiplexerEvent::EID_SHAPE_REMOVED);
+}
+
+
+
+
+CurrentMasterPagesSelector::~CurrentMasterPagesSelector (void)
+{
+    if (mrDocument.GetDocSh() != NULL)
+    {
+        EndListening(*mrDocument.GetDocSh());
+    }
+    else
+    {
+        OSL_ASSERT(mrDocument.GetDocSh() != NULL);
+    }
+    
+    Link aLink (LINK(this,CurrentMasterPagesSelector,EventMultiplexerListener));
+    mrBase.GetEventMultiplexer()->RemoveEventListener(aLink);
+}
+
+
+
+
+void CurrentMasterPagesSelector::LateInit (void)
+{
+    MasterPagesSelector::LateInit();
+    MasterPagesSelector::Fill();
+    if (mrDocument.GetDocSh() != NULL)
+    {
+        StartListening(*mrDocument.GetDocSh());
+    }
+    else
+    {
+        OSL_ASSERT(mrDocument.GetDocSh() != NULL);
+    }
+}
+
+
+
+
+void CurrentMasterPagesSelector::Fill (ItemList& rItemList)
+{
+	sal_uInt16 nPageCount = mrDocument.GetMasterSdPageCount(PK_STANDARD);
+    SdPage* pMasterPage;
+    // Remember the names of the master pages that have been inserted to
+    // avoid double insertion.
+    ::std::set<String> aMasterPageNames;
+    for (sal_uInt16 nIndex=0; nIndex<nPageCount; nIndex++)
+    {
+        pMasterPage = mrDocument.GetMasterSdPage (nIndex, PK_STANDARD);
+        if (pMasterPage == NULL)
+            continue;
+
+        // Use the name of the master page to avoid duplicate entries.
+        String sName (pMasterPage->GetName());
+        if (aMasterPageNames.find(sName)!=aMasterPageNames.end())
+            continue;
+        aMasterPageNames.insert (sName);
+
+        // Look up the master page in the container and, when it is not yet
+        // in it, insert it.
+        MasterPageContainer::Token aToken = mpContainer->GetTokenForPageObject(pMasterPage);
+        if (aToken == MasterPageContainer::NIL_TOKEN)
+        {
+            SharedMasterPageDescriptor pDescriptor (new MasterPageDescriptor(
+                MasterPageContainer::MASTERPAGE,
+                nIndex,
+                String(),
+                pMasterPage->GetName(),
+                String(),
+                pMasterPage->IsPrecious(),
+                ::boost::shared_ptr<PageObjectProvider>(new ExistingPageProvider(pMasterPage)),
+                ::boost::shared_ptr<PreviewProvider>(new PagePreviewProvider())));
+            aToken = mpContainer->PutMasterPage(pDescriptor);
+        }
+
+        rItemList.push_back(aToken);
+    }
+}
+
+
+
+
+ResId CurrentMasterPagesSelector::GetContextMenuResId (void) const
+{
+    return SdResId(RID_TASKPANE_CURRENT_MASTERPAGESSELECTOR_POPUP);
+}
+
+
+
+
+void CurrentMasterPagesSelector::UpdateSelection (void)
+{
+    // Iterate over all pages and for the selected ones put the name of
+    // their master page into a set.
+	sal_uInt16 nPageCount = mrDocument.GetSdPageCount(PK_STANDARD);
+    SdPage* pPage;
+    ::std::set<String> aNames;
+    sal_uInt16 nIndex;
+    bool bLoop (true);
+    for (nIndex=0; nIndex<nPageCount && bLoop; nIndex++)
+    {
+        pPage = mrDocument.GetSdPage (nIndex, PK_STANDARD);
+        if (pPage != NULL && pPage->IsSelected())
+        {
+            if ( ! pPage->TRG_HasMasterPage())
+            {
+                // One of the pages has no master page.  This is an
+                // indicator for that this method is called in the middle of
+                // a document change and that the model is not in a valid
+                // state.  Therefore we stop update the selection and wait
+                // for another call to UpdateSelection when the model is
+                // valid again.
+                bLoop = false;
+            }
+            else
+            {
+                SdrPage& rMasterPage (pPage->TRG_GetMasterPage());
+                SdPage* pMasterPage = static_cast<SdPage*>(&rMasterPage);
+                if (pMasterPage != NULL)
+                    aNames.insert (pMasterPage->GetName());
+            }
+        }
+    }
+
+    // Find the items for the master pages in the set.
+    sal_uInt16 nItemCount (PreviewValueSet::GetItemCount());
+    for (nIndex=1; nIndex<=nItemCount && bLoop; nIndex++)
+    {
+        String sName (PreviewValueSet::GetItemText (nIndex));
+        if (aNames.find(sName) != aNames.end())
+        {
+            PreviewValueSet::SelectItem (nIndex);
+        }
+    }
+}
+
+
+
+
+void CurrentMasterPagesSelector::ExecuteCommand (const sal_Int32 nCommandId)
+{
+	if (nCommandId == SID_DELETE_MASTER_PAGE)
+    {
+        // Check once again that the master page can safely be deleted,
+        // i.e. is not used.
+        SdPage* pMasterPage = GetSelectedMasterPage();
+        if (pMasterPage != NULL
+            && mrDocument.GetMasterPageUserCount(pMasterPage) == 0)
+        {
+            // Removing the precious flag so that the following call to
+            // RemoveUnnessesaryMasterPages() will remove this master page.
+            pMasterPage->SetPrecious(false);
+            mrDocument.RemoveUnnecessaryMasterPages(pMasterPage, sal_False, sal_True);
+        }
+    }
+    else
+        MasterPagesSelector::ExecuteCommand(nCommandId);
+}
+
+
+
+
+void CurrentMasterPagesSelector::ProcessPopupMenu (Menu& rMenu)
+{
+    // Disable the SID_DELTE_MASTER slot when there is only one master page.
+    if (mrDocument.GetMasterPageUserCount(GetSelectedMasterPage()) > 0)
+    {
+        if (rMenu.GetItemPos(SID_DELETE_MASTER_PAGE) != MENU_ITEM_NOTFOUND)
+            rMenu.EnableItem(SID_DELETE_MASTER_PAGE, sal_False);
+    }
+
+    ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
+        ::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell()));
+	if (pDrawViewShell
+        && pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
+    {
+        if (rMenu.GetItemPos(SID_TP_EDIT_MASTER) != MENU_ITEM_NOTFOUND)
+            rMenu.EnableItem(SID_TP_EDIT_MASTER, sal_False);
+    }
+
+    MasterPagesSelector::ProcessPopupMenu(rMenu);
+}
+
+
+
+
+
+
+IMPL_LINK(CurrentMasterPagesSelector,EventMultiplexerListener,
+    sd::tools::EventMultiplexerEvent*,pEvent)
+{
+    if (pEvent != NULL)
+    {
+        switch (pEvent->meEventId)
+        {
+            case sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
+            case sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL:
+            case sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER:
+            case sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION:
+                UpdateSelection();
+                break;
+
+            case sd::tools::EventMultiplexerEvent::EID_PAGE_ORDER:
+				// This is tricky.  If a master page is removed, moved, or
+				// added we have to wait until both the notes master page
+				// and the standard master page have been removed, moved,
+				// or added.  We do this by looking at the number of master
+				// pages which has to be odd in the consistent state (the
+				// handout master page is always present).  If the number is
+				// even we ignore the hint.
+                if (mrBase.GetDocument()->GetMasterPageCount()%2 == 1)
+                    MasterPagesSelector::Fill();
+                break;
+
+            case sd::tools::EventMultiplexerEvent::EID_SHAPE_CHANGED:
+            case sd::tools::EventMultiplexerEvent::EID_SHAPE_INSERTED:
+            case sd::tools::EventMultiplexerEvent::EID_SHAPE_REMOVED:
+                InvalidatePreview((const SdPage*)pEvent->mpUserData);
+                break;
+        }
+    }
+    
+    return 0;
+}
+
+
+
+
+void CurrentMasterPagesSelector::Notify (SfxBroadcaster&, const SfxHint& rHint)
+{
+    const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
+    if (pSimpleHint != NULL)
+    {
+        if (pSimpleHint->GetId() == SFX_HINT_DOCCHANGED)
+        {
+            // Is the edit view visible in the center pane?
+            ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
+                ::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell()));
+            if (pDrawViewShell.get() != NULL)
+            {
+                // Is the edit view in master page mode?
+            	if (pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
+                {
+                    // Mark the currently edited master page as precious.
+                    SdPage* pCurrentMasterPage = pDrawViewShell->getCurrentPage();
+                    if (pCurrentMasterPage != NULL)
+                        pCurrentMasterPage->SetPrecious(true);
+                }
+            }
+        }
+    }
+}
+
+
+} } // end of namespace sd::sidebar

Added: openoffice/branches/sidebar/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx?rev=1449041&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx (added)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx Fri Feb 22 13:50:42 2013
@@ -0,0 +1,88 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#ifndef SD_SIDEBAR_PANELS_CURRENT_MASTER_PAGES_SELECTOR_HXX
+#define SD_SIDEBAR_PANELS_CURRENT_MASTER_PAGES_SELECTOR_HXX
+
+#include "MasterPagesSelector.hxx"
+#include <com/sun/star/lang/XComponent.hpp>
+
+
+namespace css = ::com::sun::star;
+namespace cssu = ::com::sun::star::uno;
+
+
+namespace sd { namespace tools { class EventMultiplexerEvent; } }
+
+
+namespace sd { namespace sidebar {
+
+
+/** Show the master pages currently used by a SdDrawDocument.
+*/
+class CurrentMasterPagesSelector
+    : public MasterPagesSelector,
+      public SfxListener
+{
+public:
+    static MasterPagesSelector* Create (
+        ::Window* pParent,
+        ViewShellBase& rViewShellBase,
+        const cssu::Reference<css::ui::XSidebar>& rxSidebar);
+
+    /** Set the selection so that the master page is selected that is
+        used by the currently selected page of the document in the
+        center pane.
+    */
+    virtual void UpdateSelection (void);
+
+    /** Copy all master pages that are to be shown into the given list.
+    */
+    virtual void Fill (ItemList& rItemList);
+
+	using MasterPagesSelector::Fill;
+
+protected:
+    virtual ResId GetContextMenuResId (void) const;
+
+    virtual void ProcessPopupMenu (Menu& rMenu);
+    virtual void ExecuteCommand (const sal_Int32 nCommandId);
+
+private:
+    cssu::Reference<css::lang::XComponent> mxListener;
+
+    CurrentMasterPagesSelector (
+        ::Window* pParent, 
+        SdDrawDocument& rDocument,
+        ViewShellBase& rBase,
+        const ::boost::shared_ptr<MasterPageContainer>& rpContainer,
+        const cssu::Reference<css::ui::XSidebar>& rxSidebar);
+    virtual ~CurrentMasterPagesSelector (void);
+
+    virtual void LateInit (void);
+
+    DECL_LINK(EventMultiplexerListener,sd::tools::EventMultiplexerEvent*);
+    void Notify (SfxBroadcaster&, const SfxHint& rHint);
+};
+
+} } // end of namespace sd::sidebar
+
+#endif

Added: openoffice/branches/sidebar/main/sd/source/ui/sidebar/CustomAnimationPanel.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/CustomAnimationPanel.cxx?rev=1449041&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/CustomAnimationPanel.cxx (added)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/CustomAnimationPanel.cxx Fri Feb 22 13:50:42 2013
@@ -0,0 +1,79 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "CustomAnimationPanel.hxx"
+
+#include "ViewShellBase.hxx"
+
+
+namespace sd {
+    extern ::Window * createCustomAnimationPanel (::Window* pParent, ViewShellBase& rBase);
+    extern sal_Int32 getCustomAnimationPanelMinimumHeight (::Window* pParent);
+}
+
+
+
+
+namespace sd { namespace sidebar {
+
+
+CustomAnimationPanel::CustomAnimationPanel (
+    ::Window* pParentWindow,
+    ViewShellBase& rViewShellBase)
+    : PanelBase(
+        pParentWindow,
+        rViewShellBase)
+{
+#ifdef DEBUG
+    SetText(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sd:CustomAnimationPanel")));
+#endif
+}
+
+
+
+
+CustomAnimationPanel::~CustomAnimationPanel (void)
+{
+}
+
+
+
+
+::Window* CustomAnimationPanel::CreateWrappedControl (
+    ::Window* pParentWindow,
+    ViewShellBase& rViewShellBase)
+{
+    return createCustomAnimationPanel(pParentWindow, rViewShellBase);
+}
+
+
+
+
+css::ui::LayoutSize CustomAnimationPanel::GetHeightForWidth (const sal_Int32 nWidth)
+{
+    const sal_Int32 nMinimumHeight(getCustomAnimationPanelMinimumHeight(mpWrappedControl.get()));
+    return css::ui::LayoutSize(nMinimumHeight,-1, nMinimumHeight);
+}
+
+
+} } // end of namespace sd::sidebar

Added: openoffice/branches/sidebar/main/sd/source/ui/sidebar/CustomAnimationPanel.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/CustomAnimationPanel.hxx?rev=1449041&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/CustomAnimationPanel.hxx (added)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/CustomAnimationPanel.hxx Fri Feb 22 13:50:42 2013
@@ -0,0 +1,50 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#ifndef SD_SIDEBAR_CUSTOM_ANIMATION_PANEL_HXX
+#define SD_SIDEBAR_CUSTOM_ANIMATION_PANEL_HXX
+
+#include "PanelBase.hxx"
+
+
+namespace sd { namespace sidebar {
+
+class CustomAnimationPanel
+    : public PanelBase
+{
+public:
+    CustomAnimationPanel (
+        ::Window* pParentWindow, 
+        ViewShellBase& rViewShellBase);
+    virtual ~CustomAnimationPanel (void);
+
+    // ILayoutableWindow
+    virtual css::ui::LayoutSize GetHeightForWidth (const sal_Int32 nWidth);
+
+protected:
+    virtual ::Window* CreateWrappedControl (
+        ::Window* pParentWindow,
+        ViewShellBase& rViewShellBase);
+};
+
+} } // end of namespace sd::sidebar
+
+#endif

Added: openoffice/branches/sidebar/main/sd/source/ui/sidebar/DocumentHelper.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/DocumentHelper.cxx?rev=1449041&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/DocumentHelper.cxx (added)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/DocumentHelper.cxx Fri Feb 22 13:50:42 2013
@@ -0,0 +1,578 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "DocumentHelper.hxx"
+
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "sdpage.hxx"
+#include "glob.hxx"
+#include "unmovss.hxx"
+#include "strings.hrc"
+#include "sdresid.hxx"
+#include "undoback.hxx"
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPages.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include "stlpool.hxx"
+#include <svx/xfillit0.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+
+namespace sd { namespace sidebar {
+
+SdPage* DocumentHelper::CopyMasterPageToLocalDocument (
+    SdDrawDocument& rTargetDocument,
+    SdPage* pMasterPage)
+{
+    SdPage* pNewMasterPage = NULL;
+
+    do
+    {
+        if (pMasterPage == NULL)
+            break;
+
+        // Check the presence of the source document.
+        SdDrawDocument* pSourceDocument = static_cast<SdDrawDocument*>(
+            pMasterPage->GetModel());
+        if (pSourceDocument == NULL)
+            break;
+
+        // When the given master page already belongs to the target document
+        // then there is nothing more to do.
+        if (pSourceDocument == &rTargetDocument)
+        {
+            pNewMasterPage = pMasterPage;
+            break;
+        }
+
+        // Test if the master pages of both the slide and its notes page are
+        // present.  This is not the case when we are called during the
+        // creation of the slide master page because then the notes master
+        // page is not there.
+        sal_uInt16 nSourceMasterPageCount = pSourceDocument->GetMasterPageCount();
+        if (nSourceMasterPageCount%2 == 0)
+            // There should be 1 handout page + n slide masters + n notes
+            // masters = 2*n+1.  An even value indicates that a new slide
+            // master but not yet the notes master has been inserted.
+            break;
+        sal_uInt16 nIndex = pMasterPage->GetPageNum();
+        if (nSourceMasterPageCount <= nIndex+1)
+            break;
+        // Get the slide master page.
+        if (pMasterPage != static_cast<SdPage*>(
+            pSourceDocument->GetMasterPage(nIndex)))
+            break;
+        // Get the notes master page.
+        SdPage* pNotesMasterPage = static_cast<SdPage*>(
+            pSourceDocument->GetMasterPage(nIndex+1));
+        if (pNotesMasterPage == NULL)
+            break;
+
+
+        // Check if a master page with the same name as that of the given
+        // master page already exists.
+        bool bPageExists (false);
+        sal_uInt16 nMasterPageCount(rTargetDocument.GetMasterSdPageCount(PK_STANDARD));
+        for (sal_uInt16 nMaster=0; nMaster<nMasterPageCount; nMaster++)
+        {
+            SdPage* pCandidate = static_cast<SdPage*>(
+                rTargetDocument.GetMasterSdPage (nMaster, PK_STANDARD));
+            if (pMasterPage!=NULL
+                && pCandidate->GetName().CompareTo(pMasterPage->GetName())==0)
+            {
+                bPageExists = true;
+                pNewMasterPage = pCandidate;
+                break;
+            }
+        }
+        if (bPageExists)
+            break;
+        
+        // Create a new slide (and its notes page.)
+        uno::Reference<drawing::XDrawPagesSupplier> xSlideSupplier (
+            rTargetDocument.getUnoModel(), uno::UNO_QUERY);
+        if ( ! xSlideSupplier.is())
+            break;
+        uno::Reference<drawing::XDrawPages> xSlides (
+            xSlideSupplier->getDrawPages(), uno::UNO_QUERY);
+        if ( ! xSlides.is())
+            break;
+        xSlides->insertNewByIndex (xSlides->getCount());
+
+        // Set a layout.
+        SdPage* pSlide = rTargetDocument.GetSdPage(
+            rTargetDocument.GetSdPageCount(PK_STANDARD)-1,
+            PK_STANDARD);
+        if (pSlide == NULL)
+            break;
+        pSlide->SetAutoLayout(AUTOLAYOUT_TITLE, sal_True);
+
+        // Create a copy of the master page and the associated notes
+        // master page and insert them into our document.
+        pNewMasterPage = AddMasterPage(rTargetDocument, pMasterPage);
+        if (pNewMasterPage==NULL)
+            break;
+        SdPage* pNewNotesMasterPage 
+            = AddMasterPage(rTargetDocument, pNotesMasterPage);
+        if (pNewNotesMasterPage==NULL)
+            break;
+
+        // Make the connection from the new slide to the master page
+        // (and do the same for the notes page.)
+        rTargetDocument.SetMasterPage (
+            rTargetDocument.GetSdPageCount(PK_STANDARD)-1,
+            pNewMasterPage->GetName(),
+            &rTargetDocument,
+            sal_False, // Connect the new master page with the new slide but
+                   // do not modify other (master) pages.
+            sal_True);
+    }
+    while (false);
+
+    // We are not interested in any automatisms for our modified internal
+    // document.
+    rTargetDocument.SetChanged (sal_False);
+
+    return pNewMasterPage;
+}
+
+
+
+
+SdPage* DocumentHelper::GetSlideForMasterPage (SdPage* pMasterPage)
+{
+    SdPage* pCandidate = NULL;
+
+    SdDrawDocument* pDocument = NULL;
+    if (pMasterPage != NULL)
+        pDocument = dynamic_cast<SdDrawDocument*>(pMasterPage->GetModel());
+
+    // Iterate over all pages and check if it references the given master
+    // page.
+    if (pDocument!=NULL && pDocument->GetSdPageCount(PK_STANDARD) > 0)
+    {
+        // In most cases a new slide has just been inserted so start with
+        // the last page.
+        sal_uInt16 nPageIndex (pDocument->GetSdPageCount(PK_STANDARD)-1);
+        bool bFound (false);
+        while ( ! bFound)
+        {
+            pCandidate = pDocument->GetSdPage(
+                nPageIndex,
+                PK_STANDARD);
+            if (pCandidate != NULL)
+            {
+                if (static_cast<SdPage*>(&pCandidate->TRG_GetMasterPage())
+                    == pMasterPage)
+                {
+                    bFound = true;
+                    break;
+                }
+            }
+
+            if (nPageIndex == 0)
+                break;
+            else
+                nPageIndex --;
+        }
+
+        // If no page was found that refernced the given master page reset
+        // the pointer that is returned.
+        if ( ! bFound)
+            pCandidate = NULL;
+    }
+
+    return pCandidate;
+}
+
+
+
+
+SdPage* DocumentHelper::AddMasterPage (
+    SdDrawDocument& rTargetDocument,
+    SdPage* pMasterPage)
+{
+    SdPage* pClonedMasterPage = NULL;
+
+    if (pMasterPage!=NULL)
+    {
+        try
+        {
+            // Duplicate the master page.
+            pClonedMasterPage = static_cast<SdPage*>(pMasterPage->Clone());
+
+            // Copy the necessary styles.
+            SdDrawDocument* pSourceDocument
+                = static_cast<SdDrawDocument*>(pMasterPage->GetModel());
+            if (pSourceDocument != NULL)
+                ProvideStyles (*pSourceDocument, rTargetDocument, pClonedMasterPage);
+
+            // Copy the precious flag.
+            pClonedMasterPage->SetPrecious(pMasterPage->IsPrecious());
+            
+            // Now that the styles are available we can insert the cloned
+            // master page.
+            rTargetDocument.InsertMasterPage (pClonedMasterPage);
+        }
+        catch (uno::Exception& rException)
+        {
+            pClonedMasterPage = NULL;
+            DBG_UNHANDLED_EXCEPTION();
+        }
+        catch (::std::exception rException)
+        {
+            pClonedMasterPage = NULL;
+            OSL_TRACE ("caught general exception");
+        }
+        catch (...)
+        {
+            pClonedMasterPage = NULL;
+            OSL_TRACE ("caught general exception");
+        }
+    }
+
+    return pClonedMasterPage;
+}
+
+
+
+
+void DocumentHelper::ProvideStyles (
+    SdDrawDocument& rSourceDocument,
+    SdDrawDocument& rTargetDocument,
+    SdPage* pPage)
+{
+    // Get the layout name of the given page.
+    String sLayoutName (pPage->GetLayoutName());
+    sLayoutName.Erase (sLayoutName.SearchAscii (SD_LT_SEPARATOR));
+
+    // Copy the style sheet from source to target document.
+	SdStyleSheetPool* pSourceStyleSheetPool =
+        static_cast<SdStyleSheetPool*>(rSourceDocument.GetStyleSheetPool());
+	SdStyleSheetPool* pTargetStyleSheetPool =
+        static_cast<SdStyleSheetPool*>(rTargetDocument.GetStyleSheetPool());
+    SdStyleSheetVector aCreatedStyles;
+    pTargetStyleSheetPool->CopyLayoutSheets (
+        sLayoutName, 
+        *pSourceStyleSheetPool, 
+        aCreatedStyles);
+
+    // Add an undo action for the copied style sheets.
+    if( !aCreatedStyles.empty() )
+    {
+     	::svl::IUndoManager* pUndoManager = rTargetDocument.GetDocSh()->GetUndoManager();
+       if (pUndoManager != NULL)
+       {
+           SdMoveStyleSheetsUndoAction* pMovStyles =
+               new SdMoveStyleSheetsUndoAction (
+                   &rTargetDocument, 
+                   aCreatedStyles, 
+                   sal_True);
+           pUndoManager->AddUndoAction (pMovStyles);
+       }
+    }
+}
+
+
+
+
+void DocumentHelper::AssignMasterPageToPageList (
+    SdDrawDocument& rTargetDocument,
+    SdPage* pMasterPage,
+    const ::boost::shared_ptr<std::vector<SdPage*> >& rpPageList)
+{
+    do
+    {
+        if (pMasterPage == NULL && pMasterPage->IsMasterPage())
+            break;
+
+        // Make the layout name by stripping ouf the layout postfix from the
+        // layout name of the given master page.
+        String sFullLayoutName (pMasterPage->GetLayoutName());
+        String sBaseLayoutName (sFullLayoutName);
+        sBaseLayoutName.Erase (sBaseLayoutName.SearchAscii (SD_LT_SEPARATOR));
+
+        if (rpPageList->empty())
+            break;
+
+        // Create a second list that contains only the valid pointers to
+        // pages for which an assignment is necessary.
+        ::std::vector<SdPage*>::const_iterator iPage;
+        ::std::vector<SdPage*> aCleanedList;
+        for (iPage=rpPageList->begin(); iPage!=rpPageList->end(); ++iPage)
+        {
+            OSL_ASSERT(*iPage!=NULL && (*iPage)->GetModel() == &rTargetDocument);
+            if (*iPage != NULL
+                && (*iPage)->GetLayoutName().CompareTo(sFullLayoutName)!=0)
+            {
+                aCleanedList.push_back(*iPage);
+            }
+        }
+        if (aCleanedList.empty() )
+            break;
+
+		::svl::IUndoManager* pUndoMgr = rTargetDocument.GetDocSh()->GetUndoManager();
+		if( pUndoMgr )
+			pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_SET_PRESLAYOUT)), String());
+
+        SdPage* pMasterPageInDocument = ProvideMasterPage(rTargetDocument,pMasterPage,rpPageList);
+        if (pMasterPageInDocument == NULL)
+            break;
+
+        // Assign the master pages to the given list of pages.
+        for (iPage=aCleanedList.begin(); 
+             iPage!=aCleanedList.end(); 
+             ++iPage)
+        {
+            AssignMasterPageToPage (
+                pMasterPageInDocument,
+                sBaseLayoutName,
+                *iPage);
+        }
+
+		if( pUndoMgr )
+			pUndoMgr->LeaveListAction();
+    }
+    while (false);
+}
+
+
+
+
+SdPage* DocumentHelper::AddMasterPage (
+    SdDrawDocument& rTargetDocument,
+    SdPage* pMasterPage,
+    sal_uInt16 nInsertionIndex)
+{
+    SdPage* pClonedMasterPage = NULL;
+
+    if (pMasterPage!=NULL)
+    {
+        // Duplicate the master page.
+        pClonedMasterPage = static_cast<SdPage*>(pMasterPage->Clone());
+
+        // Copy the precious flag.
+        pClonedMasterPage->SetPrecious(pMasterPage->IsPrecious());
+        
+        // Copy the necessary styles.
+        SdDrawDocument* pSourceDocument
+            = static_cast<SdDrawDocument*>(pMasterPage->GetModel());
+        if (pSourceDocument != NULL)
+        {
+            ProvideStyles (*pSourceDocument, rTargetDocument, pClonedMasterPage);
+
+            // Now that the styles are available we can insert the cloned
+            // master page.
+            rTargetDocument.InsertMasterPage (pClonedMasterPage, nInsertionIndex);
+
+            // Adapt the size of the new master page to that of the pages in
+            // the document.
+            Size aNewSize (rTargetDocument.GetSdPage(0, pMasterPage->GetPageKind())->GetSize());
+            Rectangle aBorders (
+                pClonedMasterPage->GetLftBorder(),
+                pClonedMasterPage->GetUppBorder(),
+                pClonedMasterPage->GetRgtBorder(),
+                pClonedMasterPage->GetLwrBorder());
+            pClonedMasterPage->ScaleObjects(aNewSize, aBorders, sal_True);
+            pClonedMasterPage->SetSize(aNewSize);
+            pClonedMasterPage->CreateTitleAndLayout(sal_True);
+        }
+    }
+
+    return pClonedMasterPage;
+}
+
+
+
+
+/** In here we have to handle three cases:
+    1. pPage is a normal slide.  We can use SetMasterPage to assign the
+    master pages to it.
+    2. pPage is a master page that is used by at least one slide.  We can
+    assign the master page to these slides.
+    3. pPage is a master page that is currently not used by any slide.
+    We can delete that page and add copies of the given master pages
+    instead.
+
+    For points 2 and 3 where one master page A is assigned to another B we have
+    to keep in mind that the master page that page A has already been
+    inserted into the target document.
+*/
+void DocumentHelper::AssignMasterPageToPage (
+    SdPage* pMasterPage,
+    const String& rsBaseLayoutName,
+    SdPage* pPage)
+{
+    // Leave early when the parameters are invalid.
+    if (pPage == NULL || pMasterPage == NULL)
+        return;
+    SdDrawDocument* pDocument = dynamic_cast<SdDrawDocument*>(pPage->GetModel());
+    if (pDocument == NULL)
+        return;
+    
+    if ( ! pPage->IsMasterPage())
+    {
+        // 1. Remove the background object (so that that, if it exists, does
+        // not override the new master page) and assign the master page to
+        // the regular slide.
+        pDocument->GetDocSh()->GetUndoManager()->AddUndoAction(
+            new SdBackgroundObjUndoAction(
+                *pDocument, *pPage, pPage->getSdrPageProperties().GetItemSet()),
+            sal_True);
+        pPage->getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE));
+          
+        pDocument->SetMasterPage (
+            (pPage->GetPageNum()-1)/2,
+            rsBaseLayoutName,
+            pDocument,
+            sal_False,
+            sal_False);
+    }
+    else
+    {
+        // Find first slide that uses the master page.
+        SdPage* pSlide = NULL;
+        sal_uInt16 nPageCount = pDocument->GetSdPageCount(PK_STANDARD);
+        for (sal_uInt16 nPage=0; nPage<nPageCount&&pSlide==NULL; nPage++)
+        {
+            SdrPage* pCandidate = pDocument->GetSdPage(nPage,PK_STANDARD);
+            if (pCandidate != NULL
+                && pCandidate->TRG_HasMasterPage()
+                && &(pCandidate->TRG_GetMasterPage()) == pPage)
+            {
+                pSlide = static_cast<SdPage*>(pCandidate);
+            }
+        }
+
+        if (pSlide != NULL)
+        {
+            // 2. Assign the given master pages to the first slide that was
+            // found above that uses the master page.
+            pDocument->SetMasterPage (
+                (pSlide->GetPageNum()-1)/2,
+                rsBaseLayoutName,
+                pDocument,
+                sal_False,
+                sal_False);
+        }
+        else
+        {
+            // 3. Replace the master page A by a copy of the given master
+            // page B.
+            pDocument->RemoveUnnecessaryMasterPages (
+                pPage, sal_False);
+        }
+    }
+}
+
+
+
+
+SdPage* DocumentHelper::ProvideMasterPage (
+    SdDrawDocument& rTargetDocument,
+    SdPage* pMasterPage,
+    const ::boost::shared_ptr<std::vector<SdPage*> >& rpPageList)
+{
+    // Make sure that both the master page and its notes master exist
+    // in the source document.  If one is missing then return without
+    // making any changes.
+    if (pMasterPage == NULL)
+    {
+        // The caller should make sure that the master page is valid.
+        OSL_ASSERT(pMasterPage != NULL);
+        return NULL;
+    }
+    SdDrawDocument* pSourceDocument = static_cast<SdDrawDocument*>(pMasterPage->GetModel());
+    if (pSourceDocument == NULL)
+        return NULL;
+    SdPage* pNotesMasterPage = static_cast<SdPage*>(
+        pSourceDocument->GetMasterPage(pMasterPage->GetPageNum()+1));
+    if (pNotesMasterPage == NULL)
+    {
+        // The model is not in a valid state.  Maybe a new master page
+        // is being (not finished yet) created?  Return without making
+        // any changes.
+        return NULL;
+    }
+
+    SdPage* pMasterPageInDocument = NULL;
+    // Search for a master page with the same name as the given one in
+    // the target document.
+    const XubString sMasterPageLayoutName (pMasterPage->GetLayoutName());
+    for (sal_uInt16 nIndex=0,nCount=rTargetDocument.GetMasterPageCount(); nIndex<nCount; ++nIndex)
+    {
+        SdPage* pCandidate = static_cast<SdPage*>(rTargetDocument.GetMasterPage(nIndex));
+        if (pCandidate!=NULL 
+            && sMasterPageLayoutName==pCandidate->GetLayoutName())
+        {
+            // The requested master page does already exist in the
+            // target document, return it.
+            return pCandidate;
+        }
+    }
+    
+    // The given master page does not already belong to the target
+    // document so we have to create copies and insert them into the
+    // targer document.
+
+    // Determine the position where the new master pages are inserted.
+    // By default they are inserted at the end.  When we assign to a
+    // master page then insert after the last of the (selected) pages.
+    sal_uInt16 nInsertionIndex = rTargetDocument.GetMasterPageCount();
+    if (rpPageList->front()->IsMasterPage())
+    {
+        nInsertionIndex = rpPageList->back()->GetPageNum();
+    }
+
+    // Clone the master page.
+    if (pMasterPage->GetModel() != &rTargetDocument)
+    {
+        pMasterPageInDocument = AddMasterPage (rTargetDocument, pMasterPage, nInsertionIndex);
+        if( rTargetDocument.IsUndoEnabled() )
+				rTargetDocument.AddUndo(
+					rTargetDocument.GetSdrUndoFactory().CreateUndoNewPage(*pMasterPageInDocument));
+    }
+    else
+        pMasterPageInDocument = pMasterPage;
+
+    // Clone the notes master.
+    if (pNotesMasterPage->GetModel() != &rTargetDocument)
+    {
+        SdPage* pClonedNotesMasterPage 
+            = AddMasterPage (rTargetDocument, pNotesMasterPage, nInsertionIndex+1);
+        if( rTargetDocument.IsUndoEnabled() )
+            rTargetDocument.AddUndo(
+                rTargetDocument.GetSdrUndoFactory().CreateUndoNewPage(*pClonedNotesMasterPage));
+    }
+
+    return pMasterPageInDocument;
+}
+
+
+
+
+
+} } // end of namespace sd::sidebar

Added: openoffice/branches/sidebar/main/sd/source/ui/sidebar/DocumentHelper.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/DocumentHelper.hxx?rev=1449041&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/DocumentHelper.hxx (added)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/DocumentHelper.hxx Fri Feb 22 13:50:42 2013
@@ -0,0 +1,110 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#ifndef SD_SIDEBAR_PANELS_DCUMENT_HELPER_HXX
+#define SD_SIDEBAR_PANELS_DCUMENT_HELPER_HXX
+
+#include <tools/solar.h>
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+class SdDrawDocument;
+class SdPage;
+class String;
+
+namespace sd { namespace sidebar {
+
+/** A collection of methods supporting the handling of master pages.
+*/
+class DocumentHelper
+{
+public:
+    /** Return a copy of the given master page in the given document.
+    */
+    static SdPage* CopyMasterPageToLocalDocument (
+        SdDrawDocument& rTargetDocument,
+        SdPage* pMasterPage);
+
+    /** Return and, when not yet present, create a slide that uses the given
+        masster page.
+    */
+    static SdPage* GetSlideForMasterPage (SdPage* pMasterPage);
+
+    /** Copy the styles used by the given page from the source document to
+        the target document.
+    */
+    static void ProvideStyles (
+        SdDrawDocument& rSourceDocument,
+        SdDrawDocument& rTargetDocument,
+        SdPage* pPage);
+
+    /** Assign the given master page to the list of pages.
+        @param rTargetDocument
+            The document that is the owner of the pages in rPageList.
+        @param pMasterPage
+            This master page will usually be a member of the list of all
+            available master pages as provided by the MasterPageContainer.
+        @param rPageList
+            The pages to which to assign the master page.  These pages may
+            be slides or master pages themselves.
+    */
+    static void AssignMasterPageToPageList (
+        SdDrawDocument& rTargetDocument,
+        SdPage* pMasterPage,
+        const ::boost::shared_ptr<std::vector<SdPage*> >& rPageList);
+
+private:
+    static SdPage* AddMasterPage (
+        SdDrawDocument& rTargetDocument,
+        SdPage* pMasterPage);
+    static SdPage* AddMasterPage (
+        SdDrawDocument& rTargetDocument,
+        SdPage* pMasterPage,
+        sal_uInt16 nInsertionIndex);
+    static SdPage* ProvideMasterPage (
+        SdDrawDocument& rTargetDocument,
+        SdPage* pMasterPage,
+        const ::boost::shared_ptr<std::vector<SdPage*> >& rpPageList);
+    
+    /** Assign the given master page to the given page.
+        @param pMasterPage
+            In contrast to AssignMasterPageToPageList() this page is assumed
+            to be in the target document, i.e. the same document that pPage
+            is in.  The caller will usually call AddMasterPage() to create a
+            clone of a master page in a another document to create it.
+        @param rsBaseLayoutName
+            The layout name of the given master page.  It is given so that
+            it has not to be created on every call.  It could be generated
+            from the given master page, though.
+        @param pPage
+            The page to which to assign the master page.  It can be a slide
+            or a master page itself.
+    */
+    static void AssignMasterPageToPage (
+        SdPage* pMasterPage,
+        const String& rsBaseLayoutName,
+        SdPage* pPage);
+};
+
+
+} } // end of namespace sd::sidebar
+
+#endif

Added: openoffice/branches/sidebar/main/sd/source/ui/sidebar/IDisposable.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/IDisposable.hxx?rev=1449041&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/IDisposable.hxx (added)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/IDisposable.hxx Fri Feb 22 13:50:42 2013
@@ -0,0 +1,44 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+
+#ifndef SD_SIDEBAR_DISPOSABLE_INTERFACE_HXX
+#define SD_SIDEBAR_DISPOSABLE_INTERFACE_HXX
+
+#include <tools/gen.hxx>
+#include <sal/types.h>
+
+class Window;
+
+namespace sd { namespace sidebar {
+
+
+class IDisposable
+{
+public:
+    virtual void Dispose (void) = 0;
+};
+
+
+} } // end of namespace ::sd::sidebar
+
+#endif

Added: openoffice/branches/sidebar/main/sd/source/ui/sidebar/ISidebarReceiver.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sd/source/ui/sidebar/ISidebarReceiver.hxx?rev=1449041&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sd/source/ui/sidebar/ISidebarReceiver.hxx (added)
+++ openoffice/branches/sidebar/main/sd/source/ui/sidebar/ISidebarReceiver.hxx Fri Feb 22 13:50:42 2013
@@ -0,0 +1,40 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#ifndef SD_SIDEBAR_RECEIVER_INTERFACE_HXX
+#define SD_SIDEBAR_RECEIVER_INTERFACE_HXX
+
+#include <com/sun/star/ui/XSidebar.hpp>
+
+namespace sd { namespace sidebar {
+
+
+class ISidebarReceiver
+{
+public:
+    virtual void SetSidebar (const ::com::sun::star::uno::Reference<
+        ::com::sun::star::ui::XSidebar>& rxSidebar) = 0;
+};
+
+
+} } // end of namespace ::sd::sidebar
+
+#endif