diff options
Diffstat (limited to 'sd/source/ui/toolpanel/controls')
35 files changed, 0 insertions, 8752 deletions
diff --git a/sd/source/ui/toolpanel/controls/AllMasterPagesSelector.cxx b/sd/source/ui/toolpanel/controls/AllMasterPagesSelector.cxx deleted file mode 100644 index 99a13e145..000000000 --- a/sd/source/ui/toolpanel/controls/AllMasterPagesSelector.cxx +++ /dev/null @@ -1,211 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "AllMasterPagesSelector.hxx" -#include "PreviewValueSet.hxx" -#include "app.hrc" -#include "MasterPageContainer.hxx" -#include "MasterPageDescriptor.hxx" -#include <tools/link.hxx> -#include <set> - -namespace { - -using namespace sd::toolpanel::controls; - -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 sd::toolpanel::controls::SharedMasterPageDescriptor& rp1, - const sd::toolpanel::controls::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 toolpanel { namespace controls { - -class AllMasterPagesSelector::SortedMasterPageDescriptorList - : public ::std::set<SharedMasterPageDescriptor,MasterPageDescriptorOrder> -{ -public: - SortedMasterPageDescriptorList (void) {} -}; - - - - -AllMasterPagesSelector::AllMasterPagesSelector ( - TreeNode* pParent, - SdDrawDocument& rDocument, - ViewShellBase& rBase, - DrawViewShell& rViewShell, - const ::boost::shared_ptr<MasterPageContainer>& rpContainer) - : MasterPagesSelector(pParent, rDocument, rBase, rpContainer), - mrViewShell(rViewShell), - mpSortedMasterPages(new SortedMasterPageDescriptorList()) -{ - SetName (String(RTL_CONSTASCII_USTRINGPARAM("AllMasterPagesSelector"))); - 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::toolpanel::control - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/AllMasterPagesSelector.hxx b/sd/source/ui/toolpanel/controls/AllMasterPagesSelector.hxx deleted file mode 100644 index 7e6c84602..000000000 --- a/sd/source/ui/toolpanel/controls/AllMasterPagesSelector.hxx +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_ALL_MASTER_PAGES_SELECTOR_HXX -#define SD_TOOLPANEL_CONTROLS_ALL_MASTER_PAGES_SELECTOR_HXX - -#include "MasterPagesSelector.hxx" - -#include <memory> - -namespace sd { namespace toolpanel { namespace controls { - - -/** Show a list of all available master pages so that the user can assign - them to the document. -*/ -class AllMasterPagesSelector - : public MasterPagesSelector -{ -public: - AllMasterPagesSelector ( - TreeNode* pParent, - SdDrawDocument& rDocument, - ViewShellBase& rBase, - DrawViewShell& rViewShell, - const ::boost::shared_ptr<MasterPageContainer>& rpContainer); - virtual ~AllMasterPagesSelector (void); - - /** 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: - DrawViewShell& mrViewShell; - - /** The list of master pages displayed by this class. - */ - class SortedMasterPageDescriptorList; - ::std::auto_ptr<SortedMasterPageDescriptorList> mpSortedMasterPages; - - 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 sd::toolpanel::controls::MasterPagesSelector::Fill; -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/AnimationSchemesPanel.cxx b/sd/source/ui/toolpanel/controls/AnimationSchemesPanel.cxx deleted file mode 100644 index fd1eaa354..000000000 --- a/sd/source/ui/toolpanel/controls/AnimationSchemesPanel.cxx +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" -#include "AnimationSchemesPanel.hxx" - -#include "strings.hrc" -#include "sdresid.hxx" -#include <com/sun/star/frame/XModel.hpp> - -namespace sd -{ - - class ViewShellBase; - extern ::Window * createAnimationSchemesPanel( ::Window* pParent, ViewShellBase& rBase ); - -namespace toolpanel { namespace controls { - - -AnimationSchemesPanel::AnimationSchemesPanel(TreeNode* pParent, ViewShellBase& rBase) - : SubToolPanel (pParent), - maPreferredSize( 100, 200 ) -{ - mpWrappedControl = createAnimationSchemesPanel( pParent->GetWindow(), rBase ); - mpWrappedControl->Show(); -} - -AnimationSchemesPanel::~AnimationSchemesPanel() -{ - delete mpWrappedControl; -} - -Size AnimationSchemesPanel::GetPreferredSize() -{ - return maPreferredSize; -} -sal_Int32 AnimationSchemesPanel::GetPreferredWidth(sal_Int32 ) -{ - return maPreferredSize.Width(); -} -sal_Int32 AnimationSchemesPanel::GetPreferredHeight(sal_Int32 ) -{ - return maPreferredSize.Height(); -} -::Window* AnimationSchemesPanel::GetWindow() -{ - return mpWrappedControl; -} -bool AnimationSchemesPanel::IsResizable() -{ - return true; -} -bool AnimationSchemesPanel::IsExpandable() const -{ - return true; -} - - -} } } // end of namespace ::sd::toolpanel::controls -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" -#include "AnimationSchemesPanel.hxx" - -#include "strings.hrc" -#include "sdresid.hxx" -#include <com/sun/star/frame/XModel.hpp> - -namespace sd -{ - - class ViewShellBase; - extern ::Window * createAnimationSchemesPanel( ::Window* pParent, ViewShellBase& rBase ); - -namespace toolpanel { namespace controls { - - -AnimationSchemesPanel::AnimationSchemesPanel(TreeNode* pParent, ViewShellBase& rBase) - : SubToolPanel (pParent), - maPreferredSize( 100, 200 ) -{ - mpWrappedControl = createAnimationSchemesPanel( pParent->GetWindow(), rBase ); - mpWrappedControl->Show(); -} - -AnimationSchemesPanel::~AnimationSchemesPanel() -{ - delete mpWrappedControl; -} - -Size AnimationSchemesPanel::GetPreferredSize() -{ - return maPreferredSize; -} -sal_Int32 AnimationSchemesPanel::GetPreferredWidth(sal_Int32 ) -{ - return maPreferredSize.Width(); -} -sal_Int32 AnimationSchemesPanel::GetPreferredHeight(sal_Int32 ) -{ - return maPreferredSize.Height(); -} -::Window* AnimationSchemesPanel::GetWindow() -{ - return mpWrappedControl; -} -bool AnimationSchemesPanel::IsResizable() -{ - return true; -} -bool AnimationSchemesPanel::IsExpandable() const -{ - return true; -} - - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/AnimationSchemesPanel.hxx b/sd/source/ui/toolpanel/controls/AnimationSchemesPanel.hxx deleted file mode 100644 index 05347ccb4..000000000 --- a/sd/source/ui/toolpanel/controls/AnimationSchemesPanel.hxx +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TASKPANE_CONTROLS_ANIMATION_SCHEMES_PANEL_HXX -#define SD_TASKPANE_CONTROLS_ANIMATION_SCHEMES_PANEL_HXX - -#include "taskpane/SubToolPanel.hxx" - -namespace sd { -class ViewShellBase; -} - -namespace sd { namespace toolpanel { -class TreeNode; -} } - -namespace sd { namespace toolpanel { namespace controls { - -class AnimationSchemesPanel - : public SubToolPanel -{ -public: - AnimationSchemesPanel ( - TreeNode* pParent, - ViewShellBase& rBase); - virtual ~AnimationSchemesPanel (void); - - virtual Size GetPreferredSize (void); - virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeigh); - virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); - virtual ::Window* GetWindow (void); - virtual bool IsResizable (void); - virtual bool IsExpandable (void) const; - - using Window::GetWindow; - -private: - Size maPreferredSize; - ::Window* mpWrappedControl; -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif -#ifndef SD_TASKPANE_CONTROLS_ANIMATION_SCHEMES_PANEL_HXX -#define SD_TASKPANE_CONTROLS_ANIMATION_SCHEMES_PANEL_HXX - -#include "taskpane/SubToolPanel.hxx" - -namespace sd { -class ViewShellBase; -} - -namespace sd { namespace toolpanel { -class TreeNode; -} } - -namespace sd { namespace toolpanel { namespace controls { - -class AnimationSchemesPanel - : public SubToolPanel -{ -public: - AnimationSchemesPanel ( - TreeNode* pParent, - ViewShellBase& rBase); - virtual ~AnimationSchemesPanel (void); - - virtual Size GetPreferredSize (void); - virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeigh); - virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); - virtual ::Window* GetWindow (void); - virtual bool IsResizable (void); - virtual bool IsExpandable (void) const; - - using Window::GetWindow; - -private: - Size maPreferredSize; - ::Window* mpWrappedControl; -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/CurrentMasterPagesSelector.cxx b/sd/source/ui/toolpanel/controls/CurrentMasterPagesSelector.cxx deleted file mode 100644 index b0c85922e..000000000 --- a/sd/source/ui/toolpanel/controls/CurrentMasterPagesSelector.cxx +++ /dev/null @@ -1,346 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "CurrentMasterPagesSelector.hxx" -#include "PreviewValueSet.hxx" -#include "ViewShellBase.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 <vcl/image.hxx> -#include <svx/svdmodel.hxx> -#include <sfx2/request.hxx> - -#include <set> - - -using namespace ::com::sun::star; - -namespace sd { namespace toolpanel { namespace controls { - - -CurrentMasterPagesSelector::CurrentMasterPagesSelector ( - TreeNode* pParent, - SdDrawDocument& rDocument, - ViewShellBase& rBase, - const ::boost::shared_ptr<MasterPageContainer>& rpContainer) - : MasterPagesSelector (pParent, rDocument, rBase, rpContainer) -{ - SetName(String(RTL_CONSTASCII_USTRINGPARAM("CurrentMasterPagesSelector"))); - - // 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 (mpPageSet->GetItemCount()); - for (nIndex=1; nIndex<=nItemCount && bLoop; nIndex++) - { - String sName (mpPageSet->GetItemText (nIndex)); - if (aNames.find(sName) != aNames.end()) - { - mpPageSet->SelectItem (nIndex); - } - } -} - - - - -void CurrentMasterPagesSelector::Execute (SfxRequest& rRequest) -{ - switch (rRequest.GetSlot()) - { - case 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); - } - } - break; - - default: - MasterPagesSelector::Execute(rRequest); - break; - } -} - - - - -void CurrentMasterPagesSelector::GetState (SfxItemSet& rItemSet) -{ - // Disable the SID_DELTE_MASTER slot when there is only one master page. - if (rItemSet.GetItemState(SID_DELETE_MASTER_PAGE) == SFX_ITEM_AVAILABLE - && mrDocument.GetMasterPageUserCount(GetSelectedMasterPage()) > 0) - { - rItemSet.DisableItem(SID_DELETE_MASTER_PAGE); - } - - ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( - ::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell())); - if (rItemSet.GetItemState(SID_TP_EDIT_MASTER) == SFX_ITEM_AVAILABLE - && pDrawViewShell - && pDrawViewShell->GetEditMode() == EM_MASTERPAGE) - { - rItemSet.DisableItem (SID_TP_EDIT_MASTER); - } - - MasterPagesSelector::GetState(rItemSet); -} - - - - - - -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::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/CurrentMasterPagesSelector.hxx b/sd/source/ui/toolpanel/controls/CurrentMasterPagesSelector.hxx deleted file mode 100644 index 393e8b0e7..000000000 --- a/sd/source/ui/toolpanel/controls/CurrentMasterPagesSelector.hxx +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_CURRENT_MASTER_PAGES_SELECTOR_HXX -#define SD_TOOLPANEL_CONTROLS_CURRENT_MASTER_PAGES_SELECTOR_HXX - -#include "MasterPagesSelector.hxx" -#include <com/sun/star/lang/XComponent.hpp> - -namespace sd { namespace tools { class EventMultiplexerEvent; } } - - -namespace sd { namespace toolpanel { namespace controls { - - -/** Show the master pages currently used by a SdDrawDocument. -*/ -class CurrentMasterPagesSelector - : public MasterPagesSelector, - public SfxListener -{ -public: - CurrentMasterPagesSelector ( - TreeNode* pParent, - SdDrawDocument& rDocument, - ViewShellBase& rBase, - const ::boost::shared_ptr<MasterPageContainer>& rpContainer); - virtual ~CurrentMasterPagesSelector (void); - - virtual void LateInit (void); - - /** 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 sd::toolpanel::controls::MasterPagesSelector::Fill; - -protected: - virtual ResId GetContextMenuResId (void) const; - virtual void Execute (SfxRequest& rRequest); - virtual void GetState (SfxItemSet& rItemSet); - -private: - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> - mxListener; - - DECL_LINK(EventMultiplexerListener,sd::tools::EventMultiplexerEvent*); - void Notify (SfxBroadcaster&, const SfxHint& rHint); -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/CustomAnimationPanel.cxx b/sd/source/ui/toolpanel/controls/CustomAnimationPanel.cxx deleted file mode 100644 index 470dd63ea..000000000 --- a/sd/source/ui/toolpanel/controls/CustomAnimationPanel.cxx +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "CustomAnimationPanel.hxx" - -#include "taskpane/TaskPaneControlFactory.hxx" -#include "taskpane/ToolPanelViewShell.hxx" - -#include "strings.hrc" -#include "sdresid.hxx" - -namespace sd -{ - - class ViewShellBase; - extern ::Window * createCustomAnimationPanel( ::Window* pParent, ViewShellBase& rBase ); - -namespace toolpanel { namespace controls { - - -CustomAnimationPanel::CustomAnimationPanel(Window& i_rParentWindow, ToolPanelViewShell& i_rPanelViewShell) - :SubToolPanel( i_rParentWindow ) - ,m_pPanelViewShell( &i_rPanelViewShell ) -{ - mpWrappedControl = createCustomAnimationPanel( &i_rParentWindow, i_rPanelViewShell.GetViewShellBase() ); - mpWrappedControl->Show(); -} - -CustomAnimationPanel::~CustomAnimationPanel() -{ - delete mpWrappedControl; -} - -std::auto_ptr< ControlFactory > CustomAnimationPanel::CreateControlFactory( ToolPanelViewShell& i_rToolPanelShell ) -{ - return std::auto_ptr< ControlFactory >( - new RootControlFactoryWithArg< CustomAnimationPanel, ToolPanelViewShell >( i_rToolPanelShell ) ); -} - -TaskPaneShellManager* CustomAnimationPanel::GetShellManager() -{ - if ( m_pPanelViewShell ) - return &m_pPanelViewShell->GetSubShellManager(); - return SubToolPanel::GetShellManager(); -} - -Size CustomAnimationPanel::GetPreferredSize() -{ - return maPreferredSize; -} -sal_Int32 CustomAnimationPanel::GetPreferredWidth(sal_Int32 ) -{ - return maPreferredSize.Width(); -} -sal_Int32 CustomAnimationPanel::GetPreferredHeight(sal_Int32 ) -{ - return maPreferredSize.Height(); -} -::Window* CustomAnimationPanel::GetWindow() -{ - return mpWrappedControl; -} -bool CustomAnimationPanel::IsResizable() -{ - return true; -} -bool CustomAnimationPanel::IsExpandable() const -{ - return true; -} - - - - -::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible> CustomAnimationPanel::CreateAccessibleObject ( - const ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible>& ) -{ - if (GetWindow() != NULL) - return GetWindow()->GetAccessible(); - else - return NULL; -} - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/CustomAnimationPanel.hxx b/sd/source/ui/toolpanel/controls/CustomAnimationPanel.hxx deleted file mode 100644 index d9ee13dab..000000000 --- a/sd/source/ui/toolpanel/controls/CustomAnimationPanel.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_CUSTOM_ANIMATION_PANEL_HXX -#define SD_TOOLPANEL_CONTROLS_CUSTOM_ANIMATION_PANEL_HXX - -#include "taskpane/SubToolPanel.hxx" - -namespace sd { -class ViewShellBase; -} - -namespace sd { namespace toolpanel { -class TreeNode; -class ControlFactory; -class ToolPanelViewShell; -} } - -namespace sd { namespace toolpanel { namespace controls { - -class CustomAnimationPanel - : public SubToolPanel -{ -public: - CustomAnimationPanel ( - Window& i_rParentWindow, - ToolPanelViewShell& i_rPanelViewShell); - virtual ~CustomAnimationPanel (void); - - static std::auto_ptr<ControlFactory> CreateControlFactory (ToolPanelViewShell& i_rPanelViewShell); - - // TreeNode overridables - virtual TaskPaneShellManager* GetShellManager(); - - // ILayoutableWindow overridables - virtual Size GetPreferredSize (void); - virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeigh); - virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); - virtual ::Window* GetWindow (void); - virtual bool IsResizable (void); - virtual bool IsExpandable (void) const; - - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible > CreateAccessibleObject ( - const ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible>& rxParent); - - using Window::GetWindow; -private: - Size maPreferredSize; - ::Window* mpWrappedControl; - ToolPanelViewShell* m_pPanelViewShell; -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx b/sd/source/ui/toolpanel/controls/DocumentHelper.cxx deleted file mode 100644 index ff42e8264..000000000 --- a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx +++ /dev/null @@ -1,584 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#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 toolpanel { namespace controls { - -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(const uno::Exception&) - { - pClonedMasterPage = NULL; - DBG_UNHANDLED_EXCEPTION(); - } - catch(const ::std::exception&) - { - 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) -{ - if (pMasterPage == NULL || !pMasterPage->IsMasterPage()) - return; - - // 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()) - return; - - // 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.size() == 0) - return; - - ::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) - return; - - // 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(); -} - - - - -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::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/DocumentHelper.hxx b/sd/source/ui/toolpanel/controls/DocumentHelper.hxx deleted file mode 100644 index 046a164fb..000000000 --- a/sd/source/ui/toolpanel/controls/DocumentHelper.hxx +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_DCUMENT_HELPER_HXX -#define SD_TOOLPANEL_CONTROLS_DCUMENT_HELPER_HXX - -#include <tools/solar.h> -#include <boost/shared_ptr.hpp> -#include <vector> - -class SdDrawDocument; -class SdPage; -class String; - -namespace sd { namespace toolpanel { namespace controls { - -/** 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::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainer.cxx b/sd/source/ui/toolpanel/controls/MasterPageContainer.cxx deleted file mode 100644 index 101528212..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageContainer.cxx +++ /dev/null @@ -1,1226 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "MasterPageContainer.hxx" - -#include "MasterPageDescriptor.hxx" -#include "MasterPageContainerFiller.hxx" -#include "MasterPageContainerQueue.hxx" -#include "TemplateScanner.hxx" -#include "tools/AsynchronousTask.hxx" -#include "strings.hrc" -#include <algorithm> -#include <list> -#include <set> - -#include "unomodel.hxx" -#include <com/sun/star/frame/XComponentLoader.hpp> -#include <com/sun/star/io/XStream.hpp> -#include <com/sun/star/io/XInputStream.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/util/XCloseable.hpp> -#include <comphelper/processfactory.hxx> -#include <tools/urlobj.hxx> -#include <sfx2/app.hxx> -#include <svx/svdpage.hxx> -#include "DrawDocShell.hxx" -#include "drawdoc.hxx" -#include "sdpage.hxx" -#include <svl/itemset.hxx> -#include <svl/eitem.hxx> -#include "sdresid.hxx" -#include "tools/TimerBasedTaskExecution.hxx" -#include "pres.hxx" -#include <osl/mutex.hxx> -#include <boost/weak_ptr.hpp> - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::sd::toolpanel::controls; - -namespace { - -typedef ::std::vector<SharedMasterPageDescriptor> MasterPageContainerType; - -} // end of anonymous namespace - - -namespace sd { namespace toolpanel { namespace controls { - - -/** Inner implementation class of the MasterPageContainer. -*/ -class MasterPageContainer::Implementation - : public SdGlobalResource, - public MasterPageContainerFiller::ContainerAdapter, - public MasterPageContainerQueue::ContainerAdapter -{ -public: - mutable ::osl::Mutex maMutex; - - static ::boost::weak_ptr<Implementation> mpInstance; - MasterPageContainerType maContainer; - - static ::boost::shared_ptr<Implementation> Instance (void); - - void LateInit (void); - void AddChangeListener (const Link& rLink); - void RemoveChangeListener (const Link& rLink); - void UpdatePreviewSizePixel (void); - Size GetPreviewSizePixel (PreviewSize eSize) const; - - bool HasToken (Token aToken) const; - const SharedMasterPageDescriptor GetDescriptor (MasterPageContainer::Token aToken) const; - SharedMasterPageDescriptor GetDescriptor (MasterPageContainer::Token aToken); - virtual Token PutMasterPage (const SharedMasterPageDescriptor& rDescriptor); - void InvalidatePreview (Token aToken); - Image GetPreviewForToken ( - Token aToken, - PreviewSize ePreviewSize); - PreviewState GetPreviewState (Token aToken) const; - bool RequestPreview (Token aToken); - - Reference<frame::XModel> GetModel (void); - SdDrawDocument* GetDocument (void); - - void FireContainerChange ( - MasterPageContainerChangeEvent::EventType eType, - Token aToken, - bool bNotifyAsynchronously = false); - - virtual bool UpdateDescriptor ( - const SharedMasterPageDescriptor& rpDescriptor, - bool bForcePageObject, - bool bForcePreview, - bool bSendEvents); - - void ReleaseDescriptor (Token aToken); - - /** Called by the MasterPageContainerFiller to notify that all master - pages from template documents have been added. - */ - virtual void FillingDone (void); - -private: - Implementation (void); - virtual ~Implementation (void); - - class Deleter { public: - void operator() (Implementation* pObject) { delete pObject; } - }; - friend class Deleter; - - enum InitializationState { NOT_INITIALIZED, INITIALIZING, INITIALIZED } meInitializationState; - - ::boost::scoped_ptr<MasterPageContainerQueue> mpRequestQueue; - ::com::sun::star::uno::Reference<com::sun::star::frame::XModel> mxModel; - SdDrawDocument* mpDocument; - PreviewRenderer maPreviewRenderer; - /** Remember whether the first page object has already been used to - determine the correct size ratio. - */ - bool mbFirstPageObjectSeen; - - // The widths for the previews contain two pixels for the border that is - // painted arround the preview. - static const int SMALL_PREVIEW_WIDTH = 72 + 2; - static const int LARGE_PREVIEW_WIDTH = 2*72 + 2; - - /** This substition of page preview shows "Preparing preview" and is - shown as long as the actual previews are not being present. - */ - Image maLargePreviewBeingCreated; - Image maSmallPreviewBeingCreated; - - /** This substition of page preview is shown when a preview can not be - created and thus is not available. - */ - Image maLargePreviewNotAvailable; - Image maSmallPreviewNotAvailable; - - ::std::vector<Link> maChangeListeners; - - // We have to remember the tasks for initialization and filling in case - // a MasterPageContainer object is destroyed before these tasks have - // been completed. - ::boost::weak_ptr<sd::tools::TimerBasedTaskExecution> mpFillerTask; - - Size maSmallPreviewSizePixel; - Size maLargePreviewSizePixel; - bool mbPageRatioKnown; - - bool mbContainerCleaningPending; - - typedef ::std::pair<MasterPageContainerChangeEvent::EventType,Token> EventData; - DECL_LINK(AsynchronousNotifyCallback, EventData*); - ::sd::DrawDocShell* LoadDocument ( - const String& sFileName, - SfxObjectShellLock& rxDocumentShell); - - Image GetPreviewSubstitution (sal_uInt16 nId, PreviewSize ePreviewSize); - - void CleanContainer (void); -}; - - - - -//===== MasterPageContainer =================================================== - -::boost::weak_ptr<MasterPageContainer::Implementation> - MasterPageContainer::Implementation::mpInstance; -static const MasterPageContainer::Token NIL_TOKEN (-1); - - - - -::boost::shared_ptr<MasterPageContainer::Implementation> - MasterPageContainer::Implementation::Instance (void) -{ - ::boost::shared_ptr<MasterPageContainer::Implementation> pInstance; - - if (Implementation::mpInstance.expired()) - { - ::osl::GetGlobalMutex aMutexFunctor; - ::osl::MutexGuard aGuard (aMutexFunctor()); - if (Implementation::mpInstance.expired()) - { - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - pInstance = ::boost::shared_ptr<MasterPageContainer::Implementation>( - new MasterPageContainer::Implementation(), - MasterPageContainer::Implementation::Deleter()); - SdGlobalResourceContainer::Instance().AddResource(pInstance); - Implementation::mpInstance = pInstance; - } - else - pInstance = ::boost::shared_ptr<MasterPageContainer::Implementation>( - Implementation::mpInstance); - } - else - { - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - pInstance = ::boost::shared_ptr<MasterPageContainer::Implementation>( - Implementation::mpInstance); - } - - DBG_ASSERT (pInstance.get()!=NULL, - "MasterPageContainer::Implementation::Instance(): instance is NULL"); - return pInstance; -} - - - - -MasterPageContainer::MasterPageContainer (void) - : mpImpl(Implementation::Instance()), - mePreviewSize(SMALL) -{ - mpImpl->LateInit(); -} - - - - -MasterPageContainer::~MasterPageContainer (void) -{ -} - - - - -void MasterPageContainer::AddChangeListener (const Link& rLink) -{ - mpImpl->AddChangeListener(rLink); -} - - - - -void MasterPageContainer::RemoveChangeListener (const Link& rLink) -{ - mpImpl->RemoveChangeListener(rLink); -} - - - - -void MasterPageContainer::SetPreviewSize (PreviewSize eSize) -{ - mePreviewSize = eSize; - mpImpl->FireContainerChange( - MasterPageContainerChangeEvent::SIZE_CHANGED, - NIL_TOKEN); -} - - - - -MasterPageContainer::PreviewSize MasterPageContainer::GetPreviewSize (void) const -{ - return mePreviewSize; -} - - - - -Size MasterPageContainer::GetPreviewSizePixel (void) const -{ - return mpImpl->GetPreviewSizePixel(mePreviewSize); -} - - - - -MasterPageContainer::Token MasterPageContainer::PutMasterPage ( - const SharedMasterPageDescriptor& rDescriptor) -{ - return mpImpl->PutMasterPage(rDescriptor); -} - - - - -void MasterPageContainer::AcquireToken (Token aToken) -{ - SharedMasterPageDescriptor pDescriptor = mpImpl->GetDescriptor(aToken); - if (pDescriptor.get() != NULL) - { - ++pDescriptor->mnUseCount; - } -} - - - - -void MasterPageContainer::ReleaseToken (Token aToken) -{ - SharedMasterPageDescriptor pDescriptor = mpImpl->GetDescriptor(aToken); - if (pDescriptor.get() != NULL) - { - OSL_ASSERT(pDescriptor->mnUseCount>0); - --pDescriptor->mnUseCount; - if (pDescriptor->mnUseCount <= 0) - { - switch (pDescriptor->meOrigin) - { - case DEFAULT: - case TEMPLATE: - default: - break; - - case MASTERPAGE: - mpImpl->ReleaseDescriptor(aToken); - break; - } - } - } -} - - - - -int MasterPageContainer::GetTokenCount (void) const -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - return mpImpl->maContainer.size(); -} - - - - -bool MasterPageContainer::HasToken (Token aToken) const -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - return mpImpl->HasToken(aToken); -} - - - - -MasterPageContainer::Token MasterPageContainer::GetTokenForIndex (int nIndex) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - Token aResult (NIL_TOKEN); - if (HasToken(nIndex)) - aResult = mpImpl->maContainer[nIndex]->maToken; - return aResult; -} - - - - -MasterPageContainer::Token MasterPageContainer::GetTokenForURL ( - const String& sURL) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - Token aResult (NIL_TOKEN); - if (sURL.Len() > 0) - { - MasterPageContainerType::iterator iEntry ( - ::std::find_if ( - mpImpl->maContainer.begin(), - mpImpl->maContainer.end(), - MasterPageDescriptor::URLComparator(sURL))); - if (iEntry != mpImpl->maContainer.end()) - aResult = (*iEntry)->maToken; - } - return aResult; -} - - - - -MasterPageContainer::Token MasterPageContainer::GetTokenForStyleName (const String& sStyleName) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - Token aResult (NIL_TOKEN); - if (sStyleName.Len() > 0) - { - MasterPageContainerType::iterator iEntry ( - ::std::find_if ( - mpImpl->maContainer.begin(), - mpImpl->maContainer.end(), - MasterPageDescriptor::StyleNameComparator(sStyleName))); - if (iEntry != mpImpl->maContainer.end()) - aResult = (*iEntry)->maToken; - } - return aResult; -} - - - - -MasterPageContainer::Token MasterPageContainer::GetTokenForPageObject ( - const SdPage* pPage) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - Token aResult (NIL_TOKEN); - if (pPage != NULL) - { - MasterPageContainerType::iterator iEntry ( - ::std::find_if ( - mpImpl->maContainer.begin(), - mpImpl->maContainer.end(), - MasterPageDescriptor::PageObjectComparator(pPage))); - if (iEntry != mpImpl->maContainer.end()) - aResult = (*iEntry)->maToken; - } - return aResult; -} - - - - -String MasterPageContainer::GetURLForToken ( - MasterPageContainer::Token aToken) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - SharedMasterPageDescriptor pDescriptor = mpImpl->GetDescriptor(aToken); - if (pDescriptor.get() != NULL) - return pDescriptor->msURL; - else - return String(); -} - - - - -String MasterPageContainer::GetPageNameForToken ( - MasterPageContainer::Token aToken) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - SharedMasterPageDescriptor pDescriptor = mpImpl->GetDescriptor(aToken); - if (pDescriptor.get() != NULL) - return pDescriptor->msPageName; - else - return String(); -} - - - - -String MasterPageContainer::GetStyleNameForToken ( - MasterPageContainer::Token aToken) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - SharedMasterPageDescriptor pDescriptor = mpImpl->GetDescriptor(aToken); - if (pDescriptor.get() != NULL) - return pDescriptor->msStyleName; - else - return String(); -} - - - - -SdPage* MasterPageContainer::GetPageObjectForToken ( - MasterPageContainer::Token aToken, - bool bLoad) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - SdPage* pPageObject = NULL; - SharedMasterPageDescriptor pDescriptor = mpImpl->GetDescriptor(aToken); - if (pDescriptor.get() != NULL) - { - pPageObject = pDescriptor->mpMasterPage; - if (pPageObject == NULL) - { - // The page object is not (yet) present. Call - // UpdateDescriptor() to trigger the PageObjectProvider() to - // provide it. - if (bLoad) - mpImpl->GetModel(); - if (mpImpl->UpdateDescriptor(pDescriptor,bLoad,false, true)) - pPageObject = pDescriptor->mpMasterPage; - } - } - return pPageObject; -} - - - - -MasterPageContainer::Origin MasterPageContainer::GetOriginForToken (Token aToken) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - SharedMasterPageDescriptor pDescriptor = mpImpl->GetDescriptor(aToken); - if (pDescriptor.get() != NULL) - return pDescriptor->meOrigin; - else - return UNKNOWN; -} - - - - -sal_Int32 MasterPageContainer::GetTemplateIndexForToken (Token aToken) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - SharedMasterPageDescriptor pDescriptor = mpImpl->GetDescriptor(aToken); - if (pDescriptor.get() != NULL) - return pDescriptor->mnTemplateIndex; - else - return -1; -} - - - - -SharedMasterPageDescriptor MasterPageContainer::GetDescriptorForToken ( - MasterPageContainer::Token aToken) -{ - const ::osl::MutexGuard aGuard (mpImpl->maMutex); - - return mpImpl->GetDescriptor(aToken); -} - - - -void MasterPageContainer::InvalidatePreview (MasterPageContainer::Token aToken) -{ - mpImpl->InvalidatePreview(aToken); -} - - - - -Image MasterPageContainer::GetPreviewForToken (MasterPageContainer::Token aToken) -{ - return mpImpl->GetPreviewForToken(aToken,mePreviewSize); -} - - - - -MasterPageContainer::PreviewState MasterPageContainer::GetPreviewState (Token aToken) -{ - return mpImpl->GetPreviewState(aToken); -} - - - - -bool MasterPageContainer::RequestPreview (Token aToken) -{ - return mpImpl->RequestPreview(aToken); -} - - - - -//==== Implementation ================================================ - -MasterPageContainer::Implementation::Implementation (void) - : maMutex(), - maContainer(), - meInitializationState(NOT_INITIALIZED), - mpRequestQueue(NULL), - mxModel(NULL), - mpDocument(NULL), - maPreviewRenderer(), - mbFirstPageObjectSeen(false), - maLargePreviewBeingCreated(), - maSmallPreviewBeingCreated(), - maLargePreviewNotAvailable(), - maSmallPreviewNotAvailable(), - maChangeListeners(), - maSmallPreviewSizePixel(), - maLargePreviewSizePixel(), - mbPageRatioKnown(false), - mbContainerCleaningPending(true) - -{ - UpdatePreviewSizePixel(); -} - - - - -MasterPageContainer::Implementation::~Implementation (void) -{ - // When the initializer or filler tasks are still running then we have - // to stop them now in order to prevent them from calling us back. - tools::TimerBasedTaskExecution::ReleaseTask(mpFillerTask); - - mpRequestQueue.reset(); - - uno::Reference<util::XCloseable> xCloseable (mxModel, uno::UNO_QUERY); - if (xCloseable.is()) - { - try - { - xCloseable->close(true); - } - catch (const ::com::sun::star::util::CloseVetoException&) - { - } - } - mxModel = NULL; -} - - - - -void MasterPageContainer::Implementation::LateInit (void) -{ - const ::osl::MutexGuard aGuard (maMutex); - - if (meInitializationState == NOT_INITIALIZED) - { - meInitializationState = INITIALIZING; - - OSL_ASSERT(Instance().get()==this); - mpRequestQueue.reset(MasterPageContainerQueue::Create( - ::boost::shared_ptr<MasterPageContainerQueue::ContainerAdapter>(Instance()))); - - mpFillerTask = ::sd::tools::TimerBasedTaskExecution::Create( - ::boost::shared_ptr<tools::AsynchronousTask>(new MasterPageContainerFiller(*this)), - 5, - 50); - - meInitializationState = INITIALIZED; - } -} - - - - -void MasterPageContainer::Implementation::AddChangeListener (const Link& rLink) -{ - const ::osl::MutexGuard aGuard (maMutex); - - ::std::vector<Link>::iterator iListener ( - ::std::find(maChangeListeners.begin(),maChangeListeners.end(),rLink)); - if (iListener == maChangeListeners.end()) - maChangeListeners.push_back(rLink); - -} - - - - -void MasterPageContainer::Implementation::RemoveChangeListener (const Link& rLink) -{ - const ::osl::MutexGuard aGuard (maMutex); - - ::std::vector<Link>::iterator iListener ( - ::std::find(maChangeListeners.begin(),maChangeListeners.end(),rLink)); - if (iListener != maChangeListeners.end()) - maChangeListeners.erase(iListener); -} - - - - -void MasterPageContainer::Implementation::UpdatePreviewSizePixel (void) -{ - const ::osl::MutexGuard aGuard (maMutex); - - // The default aspect ratio is 4:3 - int nWidth (4); - int nHeight (3); - - // Search for the first entry with an existing master page. - MasterPageContainerType::const_iterator iDescriptor; - MasterPageContainerType::const_iterator iContainerEnd(maContainer.end()); - for (iDescriptor=maContainer.begin(); iDescriptor!=iContainerEnd; ++iDescriptor) - if (*iDescriptor!=NULL && (*iDescriptor)->mpMasterPage != NULL) - { - Size aPageSize ((*iDescriptor)->mpMasterPage->GetSize()); - OSL_ASSERT(aPageSize.Width() > 0 && aPageSize.Height() > 0); - if (aPageSize.Width() > 0) - nWidth = aPageSize.Width(); - if (aPageSize.Height() > 0) - nHeight = aPageSize.Height(); - mbFirstPageObjectSeen = true; - break; - } - - maSmallPreviewSizePixel.Width() = SMALL_PREVIEW_WIDTH; - maLargePreviewSizePixel.Width() = LARGE_PREVIEW_WIDTH; - - int nNewSmallHeight ((maSmallPreviewSizePixel.Width()-2) * nHeight / nWidth + 2); - int nNewLargeHeight ((maLargePreviewSizePixel.Width()-2) * nHeight / nWidth + 2); - - if (nNewSmallHeight!=maSmallPreviewSizePixel.Height() - || nNewLargeHeight!=maLargePreviewSizePixel.Height()) - { - maSmallPreviewSizePixel.Height() = nNewSmallHeight; - maLargePreviewSizePixel.Height() = nNewLargeHeight; - FireContainerChange( - MasterPageContainerChangeEvent::SIZE_CHANGED, - NIL_TOKEN); - } -} - - - - -Size MasterPageContainer::Implementation::GetPreviewSizePixel (PreviewSize eSize) const -{ - if (eSize == SMALL) - return maSmallPreviewSizePixel; - else - return maLargePreviewSizePixel; -} - - - - -IMPL_LINK(MasterPageContainer::Implementation,AsynchronousNotifyCallback, EventData*, pData) -{ - const ::osl::MutexGuard aGuard (maMutex); - - if (pData != NULL) - { - FireContainerChange(pData->first, pData->second, false); - delete pData; - } - - return 0; -} - - - - -MasterPageContainer::Token MasterPageContainer::Implementation::PutMasterPage ( - const SharedMasterPageDescriptor& rpDescriptor) -{ - const ::osl::MutexGuard aGuard (maMutex); - - Token aResult (NIL_TOKEN); - - // Get page object and preview when that is inexpensive. - UpdateDescriptor(rpDescriptor,false,false, false); - - // Look up the new MasterPageDescriptor and either insert it or update - // an already existing one. - MasterPageContainerType::iterator aEntry ( - ::std::find_if ( - maContainer.begin(), - maContainer.end(), - MasterPageDescriptor::AllComparator(rpDescriptor))); - if (aEntry == maContainer.end()) - { - // Insert a new MasterPageDescriptor. - bool bIgnore (rpDescriptor->mpPageObjectProvider.get()==NULL - && rpDescriptor->msURL.getLength()==0); - - if ( ! bIgnore) - { - if (mbContainerCleaningPending) - CleanContainer(); - - aResult = maContainer.size(); - rpDescriptor->SetToken(aResult); - - // Templates are precious, i.e. we lock them so that they will - // not be destroyed when (temporarily) no one references them. - // They will only be deleted when the container is destroyed. - switch (rpDescriptor->meOrigin) - { - case TEMPLATE: - case DEFAULT: - ++rpDescriptor->mnUseCount; - break; - - default: - break; - } - - maContainer.push_back(rpDescriptor); - aEntry = maContainer.end()-1; - - FireContainerChange(MasterPageContainerChangeEvent::CHILD_ADDED,aResult); - } - } - else - { - // Update an existing MasterPageDescriptor. - aResult = (*aEntry)->maToken; - ::std::auto_ptr<std::vector<MasterPageContainerChangeEvent::EventType> > pEventTypes( - (*aEntry)->Update(*rpDescriptor)); - if (pEventTypes.get()!=NULL && pEventTypes->size()>0) - { - // One or more aspects of the descriptor have changed. Send - // appropriate events to the listeners. - UpdateDescriptor(*aEntry,false,false, true); - - std::vector<MasterPageContainerChangeEvent::EventType>::const_iterator iEventType; - for (iEventType=pEventTypes->begin(); iEventType!=pEventTypes->end(); ++iEventType) - { - FireContainerChange( - *iEventType, - (*aEntry)->maToken, - false); - } - } - } - - return aResult; -} - - - - -bool MasterPageContainer::Implementation::HasToken (Token aToken) const -{ - return aToken>=0 - && (unsigned)aToken<maContainer.size() - && maContainer[aToken].get()!=NULL; -} - - - - -const SharedMasterPageDescriptor MasterPageContainer::Implementation::GetDescriptor ( - Token aToken) const -{ - if (aToken>=0 && (unsigned)aToken<maContainer.size()) - return maContainer[aToken]; - else - return SharedMasterPageDescriptor(); -} - - - - -SharedMasterPageDescriptor MasterPageContainer::Implementation::GetDescriptor (Token aToken) -{ - if (aToken>=0 && (unsigned)aToken<maContainer.size()) - return maContainer[aToken]; - else - return SharedMasterPageDescriptor(); -} - - - - -void MasterPageContainer::Implementation::InvalidatePreview (Token aToken) -{ - const ::osl::MutexGuard aGuard (maMutex); - - SharedMasterPageDescriptor pDescriptor (GetDescriptor(aToken)); - if (pDescriptor.get() != NULL) - { - pDescriptor->maSmallPreview = Image(); - pDescriptor->maLargePreview = Image(); - RequestPreview(aToken); - } -} - - - - -Image MasterPageContainer::Implementation::GetPreviewForToken ( - MasterPageContainer::Token aToken, - PreviewSize ePreviewSize) -{ - const ::osl::MutexGuard aGuard (maMutex); - - Image aPreview; - PreviewState ePreviewState (GetPreviewState(aToken)); - - SharedMasterPageDescriptor pDescriptor = GetDescriptor(aToken); - - // When the preview is missing but inexpensively creatable then do that - // now. - if (pDescriptor.get()!=NULL) - { - if (ePreviewState == PS_CREATABLE) - if (UpdateDescriptor(pDescriptor, false,false, true)) - if (pDescriptor->maLargePreview.GetSizePixel().Width() != 0) - ePreviewState = PS_AVAILABLE; - - switch (ePreviewState) - { - case PS_AVAILABLE: - aPreview = pDescriptor->GetPreview(ePreviewSize); - break; - - case PS_PREPARING: - aPreview = GetPreviewSubstitution( - STR_TASKPANEL_PREPARING_PREVIEW_SUBSTITUTION, - ePreviewSize); - break; - - case PS_CREATABLE: - aPreview = GetPreviewSubstitution( - STR_TASKPANEL_PREPARING_PREVIEW_SUBSTITUTION, - ePreviewSize); - break; - - case PS_NOT_AVAILABLE: - aPreview = GetPreviewSubstitution( - STR_TASKPANEL_NOT_AVAILABLE_SUBSTITUTION, - ePreviewSize); - if (ePreviewSize == SMALL) - pDescriptor->maSmallPreview = aPreview; - else - pDescriptor->maLargePreview = aPreview; - break; - } - } - - return aPreview; -} - - - - -MasterPageContainer::PreviewState MasterPageContainer::Implementation::GetPreviewState ( - Token aToken) const -{ - const ::osl::MutexGuard aGuard (maMutex); - - PreviewState eState (PS_NOT_AVAILABLE); - - SharedMasterPageDescriptor pDescriptor = GetDescriptor(aToken); - if (pDescriptor.get() != NULL) - { - if (pDescriptor->maLargePreview.GetSizePixel().Width() != 0) - eState = PS_AVAILABLE; - else if (pDescriptor->mpPreviewProvider.get() != NULL) - { - // The preview does not exist but can be created. When that is - // not expensive then do it at once. - if (mpRequestQueue->HasRequest(aToken)) - eState = PS_PREPARING; - else - eState = PS_CREATABLE; - } - else - eState = PS_NOT_AVAILABLE; - } - - return eState; -} - - - - -bool MasterPageContainer::Implementation::RequestPreview (Token aToken) -{ - SharedMasterPageDescriptor pDescriptor = GetDescriptor(aToken); - if (pDescriptor.get() != NULL) - return mpRequestQueue->RequestPreview(pDescriptor); - else - return false; -} - - - - -Reference<frame::XModel> MasterPageContainer::Implementation::GetModel (void) -{ - const ::osl::MutexGuard aGuard (maMutex); - - if ( ! mxModel.is()) - { - // Get the desktop a s service factory. - ::rtl::OUString sDesktopServiceName ( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")); - uno::Reference<frame::XComponentLoader> xDesktop ( - ::comphelper::getProcessServiceFactory()->createInstance( - sDesktopServiceName), - uno::UNO_QUERY); - - // Create a new model. - ::rtl::OUString sModelServiceName ( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.presentation.PresentationDocument")); - mxModel = uno::Reference<frame::XModel>( - ::comphelper::getProcessServiceFactory()->createInstance( - sModelServiceName), - uno::UNO_QUERY); - - // Initialize the model. - uno::Reference<frame::XLoadable> xLoadable (mxModel,uno::UNO_QUERY); - if (xLoadable.is()) - xLoadable->initNew(); - - // Use its tunnel to get a pointer to its core implementation. - uno::Reference<lang::XUnoTunnel> xUnoTunnel (mxModel, uno::UNO_QUERY); - if (xUnoTunnel.is()) - { - mpDocument = reinterpret_cast<SdXImpressDocument*>( - xUnoTunnel->getSomething( - SdXImpressDocument::getUnoTunnelId()))->GetDoc(); - } - - // Create a default page. - uno::Reference<drawing::XDrawPagesSupplier> xSlideSupplier (mxModel, uno::UNO_QUERY); - if (xSlideSupplier.is()) - { - uno::Reference<drawing::XDrawPages> xSlides ( - xSlideSupplier->getDrawPages(), uno::UNO_QUERY); - if (xSlides.is()) - { - sal_Int32 nIndex (0); - uno::Reference<drawing::XDrawPage> xNewPage (xSlides->insertNewByIndex(nIndex)); - uno::Reference<beans::XPropertySet> xProperties(xNewPage, uno::UNO_QUERY); - if (xProperties.is()) - xProperties->setPropertyValue( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Layout")), - makeAny((sal_Int16)AUTOLAYOUT_TITLE)); - } - } - } - return mxModel; -} - - - - -SdDrawDocument* MasterPageContainer::Implementation::GetDocument (void) -{ - GetModel(); - return mpDocument; -} - - - - -Image MasterPageContainer::Implementation::GetPreviewSubstitution ( - sal_uInt16 nId, - PreviewSize ePreviewSize) -{ - const ::osl::MutexGuard aGuard (maMutex); - - Image aPreview; - - switch (nId) - { - case STR_TASKPANEL_PREPARING_PREVIEW_SUBSTITUTION: - { - Image& rPreview (ePreviewSize==SMALL - ? maSmallPreviewBeingCreated - : maLargePreviewBeingCreated); - if (rPreview.GetSizePixel().Width() == 0) - { - rPreview = maPreviewRenderer.RenderSubstitution( - ePreviewSize==SMALL ? maSmallPreviewSizePixel : maLargePreviewSizePixel, - SdResId(STR_TASKPANEL_PREPARING_PREVIEW_SUBSTITUTION)); - } - aPreview = rPreview; - } - break; - - case STR_TASKPANEL_NOT_AVAILABLE_SUBSTITUTION: - { - Image& rPreview (ePreviewSize==SMALL - ? maSmallPreviewNotAvailable - : maLargePreviewNotAvailable); - if (rPreview.GetSizePixel().Width() == 0) - { - rPreview = maPreviewRenderer.RenderSubstitution( - ePreviewSize==SMALL ? maSmallPreviewSizePixel : maLargePreviewSizePixel, - SdResId(STR_TASKPANEL_NOT_AVAILABLE_SUBSTITUTION)); - } - aPreview = rPreview; - } - break; - } - - return aPreview; -} - - - - -void MasterPageContainer::Implementation::CleanContainer (void) -{ - // Remove the empty elements at the end of the container. The empty - // elements in the middle can not be removed because that would - // invalidate the references still held by others. - int nIndex (maContainer.size()-1); - while (nIndex>=0 && maContainer[nIndex].get()==NULL) - --nIndex; - maContainer.resize(++nIndex); -} - - - - -void MasterPageContainer::Implementation::FireContainerChange ( - MasterPageContainerChangeEvent::EventType eType, - Token aToken, - bool bNotifyAsynchronously) -{ - if (bNotifyAsynchronously) - { - Application::PostUserEvent( - LINK(this,Implementation,AsynchronousNotifyCallback), - new EventData(eType,aToken)); - } - else - { - ::std::vector<Link> aCopy(maChangeListeners.begin(),maChangeListeners.end()); - ::std::vector<Link>::iterator iListener; - MasterPageContainerChangeEvent aEvent; - aEvent.meEventType = eType; - aEvent.maChildToken = aToken; - for (iListener=aCopy.begin(); iListener!=aCopy.end(); ++iListener) - iListener->Call(&aEvent); - } -} - - - - -bool MasterPageContainer::Implementation::UpdateDescriptor ( - const SharedMasterPageDescriptor& rpDescriptor, - bool bForcePageObject, - bool bForcePreview, - bool bSendEvents) -{ - const ::osl::MutexGuard aGuard (maMutex); - - // We have to create the page object when the preview provider needs it - // and the caller needs the preview. - bForcePageObject |= (bForcePreview - && rpDescriptor->mpPreviewProvider->NeedsPageObject() - && rpDescriptor->mpMasterPage==NULL); - - // Define a cost threshold so that an update or page object or preview - // that is at least this cost are made at once. Updates with higher cost - // are scheduled for later. - sal_Int32 nCostThreshold (mpRequestQueue->IsEmpty() ? 5 : 0); - - // Update the page object (which may be used for the preview update). - if (bForcePageObject) - GetDocument(); - bool bPageObjectModified (rpDescriptor->UpdatePageObject( - (bForcePageObject ? -1 : nCostThreshold), - mpDocument)); - if (bPageObjectModified && bSendEvents) - FireContainerChange( - MasterPageContainerChangeEvent::DATA_CHANGED, - rpDescriptor->maToken); - if (bPageObjectModified && ! mbFirstPageObjectSeen) - UpdatePreviewSizePixel(); - - // Update the preview. - bool bPreviewModified (rpDescriptor->UpdatePreview( - (bForcePreview ? -1 : nCostThreshold), - maSmallPreviewSizePixel, - maLargePreviewSizePixel, - maPreviewRenderer)); - - if (bPreviewModified && bSendEvents) - FireContainerChange( - MasterPageContainerChangeEvent::PREVIEW_CHANGED, - rpDescriptor->maToken); - - return bPageObjectModified || bPreviewModified; -} - - - - -void MasterPageContainer::Implementation::ReleaseDescriptor (Token aToken) -{ - if (aToken>=0 && (unsigned)aToken<maContainer.size()) - { - maContainer[aToken].reset(); - mbContainerCleaningPending = true; - } -} - - - - -void MasterPageContainer::Implementation::FillingDone (void) -{ - mpRequestQueue->ProcessAllRequests(); -} - - - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainer.hxx b/sd/source/ui/toolpanel/controls/MasterPageContainer.hxx deleted file mode 100644 index 6a7d5ecaf..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageContainer.hxx +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_HXX -#define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_HXX - -#include "MasterPageContainerProviders.hxx" - -#include <osl/mutex.hxx> -#include <tools/string.hxx> -#include <vcl/image.hxx> -#include <memory> -#include "PreviewRenderer.hxx" -#include <com/sun/star/frame/XModel.hpp> -#include <vcl/timer.hxx> -#include "tools/SdGlobalResourceContainer.hxx" - -#include <boost/shared_ptr.hpp> - -class SdPage; -class SdDrawDocument; -class SfxObjectShellLock; - -namespace sd { -class DrawDocShell; -} - -namespace sd { namespace toolpanel { namespace controls { - -class MasterPageDescriptor; - -/** This container manages the master pages used by the MasterPagesSelector - controls. It uses internally a singleton implementation object. - Therefore, all MasterPageContainer object operator on the same set of - master pages. Each MasterPageContainer, however, has its own - PreviewSize value and thus can independantly switch between large and - small previews. - - The container maintains its own document to store master page objects. - - For each master page container stores its URL, preview bitmap, page - name, and, if available, the page object. - - Entries are accessed via a Token, which is mostly a numerical index but - whose values do not neccessarily have to be consecutive. -*/ -class MasterPageContainer -{ -public: - typedef int Token; - static const Token NIL_TOKEN = -1; - - MasterPageContainer (void); - virtual ~MasterPageContainer (void); - - void AddChangeListener (const Link& rLink); - void RemoveChangeListener (const Link& rLink); - - enum PreviewSize { SMALL, LARGE }; - /** There are two different preview sizes, a small one and a large one. - Which one is used by the called container can be changed with this - method. - When the preview size is changed then all change listeners are - notified of this. - */ - void SetPreviewSize (PreviewSize eSize); - - /** Returns the preview size. - */ - PreviewSize GetPreviewSize (void) const; - - /** Return the preview size in pixels. - */ - Size GetPreviewSizePixel (void) const; - - enum PreviewState { PS_AVAILABLE, PS_CREATABLE, PS_PREPARING, PS_NOT_AVAILABLE }; - PreviewState GetPreviewState (Token aToken); - - /** This method is typically called for entries in the container for - which GetPreviewState() returns OS_CREATABLE. The creation of the - preview is then scheduled to be executed asynchronously at a later - point in time. When the preview is available the change listeners - will be notified. - */ - bool RequestPreview (Token aToken); - - /** Each entry of the container is either the first page of a template - document or is a master page of an Impress document. - */ - enum Origin { - MASTERPAGE, // Master page of a document. - TEMPLATE, // First page of a template file. - DEFAULT, // Empty master page with default style. - UNKNOWN - }; - - /** Put the master page identified and described by the given parameters - into the container. When there already is a master page with the - given URL, page name, or object pointer (when that is not NULL) then - the existing entry is replaced/updated by the given one. Otherwise - a new entry is inserted. - */ - Token PutMasterPage (const ::boost::shared_ptr<MasterPageDescriptor>& rDescriptor); - void AcquireToken (Token aToken); - void ReleaseToken (Token aToken); - - /** This and the GetTokenForIndex() methods can be used to iterate over - all members of the container. - */ - int GetTokenCount (void) const; - - /** Determine whether the container has a member for the given token. - */ - bool HasToken (Token aToken) const; - - /** Return a token for an index in the range - 0 <= index < GetTokenCount(). - */ - Token GetTokenForIndex (int nIndex); - - Token GetTokenForURL (const String& sURL); - Token GetTokenForStyleName (const String& sStyleName); - Token GetTokenForPageObject (const SdPage* pPage); - - String GetURLForToken (Token aToken); - String GetPageNameForToken (Token aToken); - String GetStyleNameForToken (Token aToken); - SdPage* GetPageObjectForToken (Token aToken, bool bLoad=true); - Origin GetOriginForToken (Token aToken); - sal_Int32 GetTemplateIndexForToken (Token aToken); - ::boost::shared_ptr<MasterPageDescriptor> GetDescriptorForToken (Token aToken); - - void InvalidatePreview (Token aToken); - - /** Return a preview for the specified token. When the preview is not - present then the PreviewProvider associated with the token is - executed only when that is not expensive. It is the responsibility - of the caller to call RequestPreview() to do the same - (asynchronously) for expensive PreviewProviders. - Call GetPreviewState() to find out if that is necessary. - @param aToken - This token specifies for which master page to return the prview. - Tokens are returned for example by the GetTokenFor...() methods. - @return - The returned image is the requested preview or a substitution. - */ - Image GetPreviewForToken (Token aToken); - -private: - class Implementation; - ::boost::shared_ptr<Implementation> mpImpl; - PreviewSize mePreviewSize; - - /** Retrieve the preview of the document specified by the given URL. - */ - static BitmapEx LoadPreviewFromURL (const ::rtl::OUString& aURL); -}; - - - - -/** For some changes to the set of master pages in a MasterPageContainer or - to the data stored for each master page one or more events are sent to - registered listeners. - Each event has an event type and a token that tells the listener where - the change took place. -*/ -class MasterPageContainerChangeEvent -{ -public: - enum EventType { - // A master page was added to the container. - CHILD_ADDED, - // A master page was removed from the container. - CHILD_REMOVED, - // The preview of a master page has changed. - PREVIEW_CHANGED, - // The size of a preview has changed. - SIZE_CHANGED, - // Some of the data stored for a master page has changed. - DATA_CHANGED, - // The TemplateIndex of a master page has changed. - INDEX_CHANGED, - // More than one entries changed their TemplateIndex - INDEXES_CHANGED - } meEventType; - - // Token of the container entry whose data changed or which was added or - // removed. - MasterPageContainer::Token maChildToken; -}; - - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainerFiller.cxx b/sd/source/ui/toolpanel/controls/MasterPageContainerFiller.cxx deleted file mode 100644 index 164c39e41..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageContainerFiller.cxx +++ /dev/null @@ -1,202 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "MasterPageContainerFiller.hxx" - -#include "MasterPageDescriptor.hxx" -#include "MasterPageContainerProviders.hxx" -#include "TemplateScanner.hxx" - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::sd::toolpanel::controls; - - -namespace sd { namespace toolpanel { namespace controls { - -MasterPageContainerFiller::MasterPageContainerFiller (ContainerAdapter& rpAdapter) - : mrContainerAdapter(rpAdapter), - meState(INITIALIZE_TEMPLATE_SCANNER), - mpScannerTask(), - mpLastAddedEntry(NULL), - mnIndex(1) -{ - // Add one entry for the default master page. We use temporarily the - // DefaultPagePreviewProvider to prevent the rendering (and the - // expensive creation) of the default page. It is replaced later on by - // another. - SharedMasterPageDescriptor pDescriptor (new MasterPageDescriptor( - MasterPageContainer::DEFAULT, - 0, - String(), - String(), - String(), - false, - ::boost::shared_ptr<PageObjectProvider>(new DefaultPageObjectProvider()), - ::boost::shared_ptr<PreviewProvider>(new PagePreviewProvider()))); - mrContainerAdapter.PutMasterPage(pDescriptor); -} - - - - -MasterPageContainerFiller::~MasterPageContainerFiller (void) -{ -} - - - - -void MasterPageContainerFiller::RunNextStep (void) -{ - switch (meState) - { - case INITIALIZE_TEMPLATE_SCANNER: - mpScannerTask.reset(new TemplateScanner()); - meState = SCAN_TEMPLATE; - break; - - case SCAN_TEMPLATE: - meState = ScanTemplate(); - break; - - case ADD_TEMPLATE: - meState = AddTemplate(); - break; - - case DONE: - case ERROR: - default: - break; - } - - // When the state has just been set to DONE or ERROR then tell the - // container that no more templates will be coming and stop the - // scanning. - switch (meState) - { - case DONE: - case ERROR: - if (mpScannerTask.get() != NULL) - { - mrContainerAdapter.FillingDone(); - mpScannerTask.reset(); - } - default: - break; - } -} - - - - -bool MasterPageContainerFiller::HasNextStep (void) -{ - switch (meState) - { - case DONE: - case ERROR: - return false; - - default: - return true; - } -} - - - - -MasterPageContainerFiller::State MasterPageContainerFiller::ScanTemplate (void) -{ - State eState (ERROR); - - if (mpScannerTask.get() != NULL) - { - if (mpScannerTask->HasNextStep()) - { - mpScannerTask->RunNextStep(); - if (mpScannerTask->GetLastAddedEntry() != mpLastAddedEntry) - { - mpLastAddedEntry = mpScannerTask->GetLastAddedEntry(); - if (mpLastAddedEntry != NULL) - eState = ADD_TEMPLATE; - else - eState = SCAN_TEMPLATE; - } - else - eState = SCAN_TEMPLATE; - } - else - eState = DONE; - } - - return eState; -} - - - - -MasterPageContainerFiller::State MasterPageContainerFiller::AddTemplate (void) -{ - if (mpLastAddedEntry != NULL) - { - SharedMasterPageDescriptor pDescriptor (new MasterPageDescriptor( - MasterPageContainer::TEMPLATE, - mnIndex, - mpLastAddedEntry->msPath, - mpLastAddedEntry->msTitle, - String(), - false, - ::boost::shared_ptr<PageObjectProvider>( - new TemplatePageObjectProvider(mpLastAddedEntry->msPath)), - ::boost::shared_ptr<PreviewProvider>( - new TemplatePreviewProvider(mpLastAddedEntry->msPath)))); - // For user supplied templates we use a different preview provider: - // The preview in the document shows not only shapes on the master - // page but also shapes on the foreground. This is misleading and - // therefore these previews are discarded and created directly from - // the page objects. - if (pDescriptor->GetURLClassification() == MasterPageDescriptor::URLCLASS_USER) - pDescriptor->mpPreviewProvider = ::boost::shared_ptr<PreviewProvider>( - new PagePreviewProvider()); - - mrContainerAdapter.PutMasterPage(pDescriptor); - ++mnIndex; - } - - return SCAN_TEMPLATE; -} - - - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainerFiller.hxx b/sd/source/ui/toolpanel/controls/MasterPageContainerFiller.hxx deleted file mode 100644 index f83db4b59..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageContainerFiller.hxx +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_FILLER_HXX -#define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_FILLER_HXX - -#include "MasterPageContainer.hxx" -#include "MasterPageDescriptor.hxx" -#include "tools/AsynchronousTask.hxx" - -namespace sd { -class TemplateScanner; -class TemplateEntry; -} - -namespace sd { namespace toolpanel { namespace controls { - -/** Fill a MasterPageContainer with information about the available master - pages. These are provided by one default page and from the existing - Impress templates. This is done asynchronously. -*/ -class MasterPageContainerFiller - : public ::sd::tools::AsynchronousTask -{ -public: - class ContainerAdapter - { - public: - virtual MasterPageContainer::Token PutMasterPage ( - const SharedMasterPageDescriptor& rpDescriptor) = 0; - /** This method is called when all Impress templates have been added - to the container via the PutMasterPage() method. - */ - virtual void FillingDone (void) = 0; - }; - - MasterPageContainerFiller (ContainerAdapter& rContainerAdapter); - virtual ~MasterPageContainerFiller (void); - - /** Run the next step of the task. After HasNextStep() returns false - this method should ignore further calls. - */ - virtual void RunNextStep (void); - - /** Return <TRUE/> when there is at least one more step to execute. - When the task has been executed completely then <FALSE/> is - returned. - */ - virtual bool HasNextStep (void); - -private: - ContainerAdapter& mrContainerAdapter; - // Remember what the next step has to do. - enum State { - INITIALIZE_TEMPLATE_SCANNER, - SCAN_TEMPLATE, - ADD_TEMPLATE, - ERROR, - DONE - } meState; - ::std::auto_ptr<TemplateScanner> mpScannerTask; - const TemplateEntry* mpLastAddedEntry; - int mnIndex; - - State ScanTemplate (void); - State AddTemplate (void); -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx b/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx deleted file mode 100644 index 59c989ee6..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx +++ /dev/null @@ -1,432 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "MasterPageContainerProviders.hxx" - -#include "DrawDocShell.hxx" -#include "drawdoc.hxx" -#include "PreviewRenderer.hxx" -#include <comphelper/processfactory.hxx> -#include <sfx2/app.hxx> -#include <sfx2/sfxsids.hrc> -#include <unotools/ucbstreamhelper.hxx> -#include <vcl/image.hxx> -#include <vcl/pngread.hxx> -#include <com/sun/star/embed/ElementModes.hpp> -#include <tools/diagnose_ex.h> - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::sd::toolpanel::controls; - - -namespace sd { namespace toolpanel { namespace controls { - - -//===== PagePreviewProvider =================================================== - -PagePreviewProvider::PagePreviewProvider (void) -{ -} - - - - -Image PagePreviewProvider::operator () ( - int nWidth, - SdPage* pPage, - ::sd::PreviewRenderer& rRenderer) -{ - Image aPreview; - - if (pPage != NULL) - { - // Use the given renderer to create a preview of the given page - // object. - aPreview = rRenderer.RenderPage( - pPage, - nWidth, - String::CreateFromAscii(""), - false); - } - - return aPreview; -} - - - - -int PagePreviewProvider::GetCostIndex (void) -{ - return 5; -} - - - - -bool PagePreviewProvider::NeedsPageObject (void) -{ - return true; -} - - - - -//===== TemplatePreviewProvider =============================================== - -TemplatePreviewProvider::TemplatePreviewProvider (const ::rtl::OUString& rsURL) - : msURL(rsURL) -{ -} - - - - -Image TemplatePreviewProvider::operator() ( - int nWidth, - SdPage* pPage, - ::sd::PreviewRenderer& rRenderer) -{ - // Unused parameters. - (void)nWidth; - (void)pPage; - (void)rRenderer; - - // Load the thumbnail from a template document. - uno::Reference<io::XInputStream> xIStream; - - uno::Reference< lang::XMultiServiceFactory > xServiceManager ( - ::comphelper::getProcessServiceFactory()); - if (xServiceManager.is()) - { - try - { - uno::Reference<lang::XSingleServiceFactory> xStorageFactory( - xServiceManager->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.embed.StorageFactory"))), - uno::UNO_QUERY); - - if (xStorageFactory.is()) - { - uno::Sequence<uno::Any> aArgs (2); - aArgs[0] <<= msURL; - aArgs[1] <<= embed::ElementModes::READ; - uno::Reference<embed::XStorage> xDocStorage ( - xStorageFactory->createInstanceWithArguments(aArgs), - uno::UNO_QUERY); - - try - { - if (xDocStorage.is()) - { - uno::Reference<embed::XStorage> xStorage ( - xDocStorage->openStorageElement( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Thumbnails")), - embed::ElementModes::READ)); - if (xStorage.is()) - { - uno::Reference<io::XStream> xThumbnailCopy ( - xStorage->cloneStreamElement( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "thumbnail.png")))); - if (xThumbnailCopy.is()) - xIStream = xThumbnailCopy->getInputStream(); - } - } - } - catch (const uno::Exception& rException) - { - OSL_TRACE ( - "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s", - ::rtl::OUStringToOString(msURL, - RTL_TEXTENCODING_UTF8).getStr(), - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); - } - - try - { - // An (older) implementation had a bug - The storage - // name was "Thumbnail" instead of "Thumbnails". The - // old name is still used as fallback but this code can - // be removed soon. - if ( ! xIStream.is()) - { - uno::Reference<embed::XStorage> xStorage ( - xDocStorage->openStorageElement( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Thumbnail")), - embed::ElementModes::READ)); - if (xStorage.is()) - { - uno::Reference<io::XStream> xThumbnailCopy ( - xStorage->cloneStreamElement( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "thumbnail.png")))); - if (xThumbnailCopy.is()) - xIStream = xThumbnailCopy->getInputStream(); - } - } - } - catch (const uno::Exception& rException) - { - OSL_TRACE ( - "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s", - ::rtl::OUStringToOString(msURL, - RTL_TEXTENCODING_UTF8).getStr(), - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); - } - } - } - catch (const uno::Exception& rException) - { - OSL_TRACE ( - "caught exception while trying to access tuhmbnail of %s: %s", - ::rtl::OUStringToOString(msURL, - RTL_TEXTENCODING_UTF8).getStr(), - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); - } - } - - // Extract the image from the stream. - BitmapEx aThumbnail; - if (xIStream.is()) - { - ::std::auto_ptr<SvStream> pStream ( - ::utl::UcbStreamHelper::CreateStream (xIStream)); - ::vcl::PNGReader aReader (*pStream); - aThumbnail = aReader.Read (); - } - - // Note that the preview is returned without scaling it to the desired - // width. This gives the caller the chance to take advantage of a - // possibly larger resolution then was asked for. - return aThumbnail; -} - - - - -int TemplatePreviewProvider::GetCostIndex (void) -{ - return 10; -} - - - - -bool TemplatePreviewProvider::NeedsPageObject (void) -{ - return false; -} - - - - -//===== TemplatePageObjectProvider ============================================= - -TemplatePageObjectProvider::TemplatePageObjectProvider (const ::rtl::OUString& rsURL) - : msURL(rsURL), - mxDocumentShell() -{ -} - - - - -SdPage* TemplatePageObjectProvider::operator() (SdDrawDocument* pContainerDocument) -{ - // Unused parameters. - (void)pContainerDocument; - - SdPage* pPage = NULL; - - mxDocumentShell = NULL; - ::sd::DrawDocShell* pDocumentShell = NULL; - try - { - // Load the template document and return its first page. - pDocumentShell = LoadDocument (msURL); - if (pDocumentShell != NULL) - { - SdDrawDocument* pDocument = pDocumentShell->GetDoc(); - if (pDocument != NULL) - { - pPage = pDocument->GetMasterSdPage(0, PK_STANDARD); - // In order to make the newly loaded master page deletable - // when copied into documents it is marked as no "precious". - // When it is modified then it is marked as "precious". - if (pPage != NULL) - pPage->SetPrecious(false); - } - } - } - catch (const uno::RuntimeException&) - { - DBG_UNHANDLED_EXCEPTION(); - pPage = NULL; - } - - return pPage; -} - - - - -::sd::DrawDocShell* TemplatePageObjectProvider::LoadDocument (const ::rtl::OUString& sFileName) -{ - SfxApplication* pSfxApp = SFX_APP(); - SfxItemSet* pSet = new SfxAllItemSet (pSfxApp->GetPool()); - pSet->Put (SfxBoolItem (SID_TEMPLATE, sal_True)); - pSet->Put (SfxBoolItem (SID_PREVIEW, sal_True)); - if (pSfxApp->LoadTemplate (mxDocumentShell, sFileName, sal_True, pSet)) - { - mxDocumentShell = NULL; - } - SfxObjectShell* pShell = mxDocumentShell; - return PTR_CAST(::sd::DrawDocShell,pShell); -} - - - - -int TemplatePageObjectProvider::GetCostIndex (void) -{ - return 20; -} - - - - -bool TemplatePageObjectProvider::operator== (const PageObjectProvider& rProvider) -{ - const TemplatePageObjectProvider* pTemplatePageObjectProvider - = dynamic_cast<const TemplatePageObjectProvider*>(&rProvider); - if (pTemplatePageObjectProvider != NULL) - return (msURL == pTemplatePageObjectProvider->msURL); - else - return false; -} - - - - -//===== DefaultPageObjectProvider ============================================== - -DefaultPageObjectProvider::DefaultPageObjectProvider (void) -{ -} - - - - -SdPage* DefaultPageObjectProvider::operator () (SdDrawDocument* pContainerDocument) -{ - SdPage* pLocalMasterPage = NULL; - if (pContainerDocument != NULL) - { - sal_Int32 nIndex (0); - SdPage* pLocalSlide = pContainerDocument->GetSdPage((sal_uInt16)nIndex, PK_STANDARD); - if (pLocalSlide!=NULL && pLocalSlide->TRG_HasMasterPage()) - pLocalMasterPage = dynamic_cast<SdPage*>(&pLocalSlide->TRG_GetMasterPage()); - } - - if (pLocalMasterPage == NULL) - { - DBG_ASSERT(false, "can not create master page for slide"); - } - - return pLocalMasterPage; -} - - - - -int DefaultPageObjectProvider::GetCostIndex (void) -{ - return 15; -} - - - - -bool DefaultPageObjectProvider::operator== (const PageObjectProvider& rProvider) -{ - return (dynamic_cast<const DefaultPageObjectProvider*>(&rProvider) != NULL); -} - - - - -//===== ExistingPageProvider ================================================== - -ExistingPageProvider::ExistingPageProvider (SdPage* pPage) - : mpPage(pPage) -{ -} - - - - -SdPage* ExistingPageProvider::operator() (SdDrawDocument* pDocument) -{ - (void)pDocument; // Unused parameter. - - return mpPage; -} - - - - -int ExistingPageProvider::GetCostIndex (void) -{ - return 0; -} - - - - -bool ExistingPageProvider::operator== (const PageObjectProvider& rProvider) -{ - const ExistingPageProvider* pExistingPageProvider - = dynamic_cast<const ExistingPageProvider*>(&rProvider); - if (pExistingPageProvider != NULL) - return (mpPage == pExistingPageProvider->mpPage); - else - return false; -} - - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.hxx b/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.hxx deleted file mode 100644 index e07879693..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.hxx +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_PROVIDERS_HXX -#define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_PROVIDERS_HXX - -#include <rtl/ustring.hxx> -#include <sfx2/objsh.hxx> - -class Image; -class SdDrawDocument; -class SdPage; -namespace sd { class PreviewRenderer; } -namespace sd { class DrawDocShell; } - - -namespace sd { namespace toolpanel { namespace controls { - - -/** Interface for a provider of page objects. It is used by the - MasterPageDescriptor to create master page objects on demand. -*/ -class PageObjectProvider -{ -public: - /** Return a master page either by returning an already existing one, by - creating a new page, or by loading a document. - @param pDocument - The document of the MasterPageContainer. It may be used to - create new pages. - */ - virtual SdPage* operator() (SdDrawDocument* pDocument) = 0; - - /** An abstract value for the expected cost of providing a master page - object. - @return - A value of 0 represents for the lowest cost, i.e. an almost - immediate return. Positive values stand for higher costs. - Negative values are not supported. - */ - virtual int GetCostIndex (void) = 0; - - virtual bool operator== (const PageObjectProvider& rProvider) = 0; -}; - - - - -class PreviewProvider -{ -public: - /** Create a preview image in the specified width. - @param nWidth - Requested width of the preview. The calling method can cope - with other sizes as well but the resulting image quality is - better when the returned image has the requested size. - @param pPage - Page object for which a preview is requested. This may be NULL - when the page object is expensive to get and the PreviewProvider - does not need this object (NeedsPageObject() returns false.) - @param rRenderer - This PreviewRenderer may be used by the PreviewProvider to - create a preview image. - */ - virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer) = 0; - - /** Return a value that indicates how expensive the creation of a - preview image is. The higher the returned value the more expensive - is the preview creation. Return 0 when the preview is already - present and can be returned immediately. - */ - virtual int GetCostIndex (void) = 0; - - /** Return whether the page object passed is necessary to create a - preview. - */ - virtual bool NeedsPageObject (void) = 0; -}; - - - - -/** Provide previews of existing page objects by rendering them. -*/ -class PagePreviewProvider : public PreviewProvider -{ -public: - PagePreviewProvider (void); - virtual Image operator () (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer); - virtual int GetCostIndex (void); - virtual bool NeedsPageObject (void); -private: -}; - - - - -/** Provide master page objects for template documents for which only the - URL is given. -*/ -class TemplatePageObjectProvider : public PageObjectProvider -{ -public: - TemplatePageObjectProvider (const ::rtl::OUString& rsURL); - virtual ~TemplatePageObjectProvider (void) {}; - virtual SdPage* operator () (SdDrawDocument* pDocument); - virtual int GetCostIndex (void); - virtual bool operator== (const PageObjectProvider& rProvider); -private: - ::rtl::OUString msURL; - SfxObjectShellLock mxDocumentShell; - ::sd::DrawDocShell* LoadDocument (const ::rtl::OUString& sFileName); -}; - - - - -/** Provide previews for template documents by loading the thumbnails from - the documents. -*/ -class TemplatePreviewProvider : public PreviewProvider -{ -public: - TemplatePreviewProvider (const ::rtl::OUString& rsURL); - virtual ~TemplatePreviewProvider (void) {}; - virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer); - virtual int GetCostIndex (void); - virtual bool NeedsPageObject (void); -private: - ::rtl::OUString msURL; -}; - - - - -/** Create an empty default master page. -*/ -class DefaultPageObjectProvider : public PageObjectProvider -{ -public: - DefaultPageObjectProvider (void); - virtual SdPage* operator () (SdDrawDocument* pDocument); - virtual int GetCostIndex (void); - virtual bool operator== (const PageObjectProvider& rProvider); -}; - - - -/** This implementation of the PageObjectProvider simply returns an already - existing master page object. -*/ -class ExistingPageProvider : public ::sd::toolpanel::controls::PageObjectProvider -{ -public: - ExistingPageProvider (SdPage* pPage); - virtual SdPage* operator() (SdDrawDocument* pDocument); - virtual int GetCostIndex (void); - virtual bool operator== (const PageObjectProvider& rProvider); -private: - SdPage* mpPage; -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainerQueue.cxx b/sd/source/ui/toolpanel/controls/MasterPageContainerQueue.cxx deleted file mode 100644 index 895c6edbe..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageContainerQueue.cxx +++ /dev/null @@ -1,311 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "MasterPageContainerQueue.hxx" - -#include "tools/IdleDetection.hxx" - -#include <set> - -namespace sd { namespace toolpanel { namespace controls { - -const sal_Int32 MasterPageContainerQueue::snDelayedCreationTimeout (15); -const sal_Int32 MasterPageContainerQueue::snDelayedCreationTimeoutWhenNotIdle (100); -const sal_Int32 MasterPageContainerQueue::snMasterPagePriorityBoost (5); -const sal_Int32 MasterPageContainerQueue::snWaitForMoreRequestsPriorityThreshold (-10); -sal_uInt32 MasterPageContainerQueue::snWaitForMoreRequestsCount(15); - -//===== MasterPageContainerQueue::PreviewCreationRequest ====================== - -class MasterPageContainerQueue::PreviewCreationRequest -{ -public: - PreviewCreationRequest (const SharedMasterPageDescriptor& rpDescriptor, int nPriority) - : mpDescriptor(rpDescriptor), - mnPriority(nPriority) - {} - SharedMasterPageDescriptor mpDescriptor; - int mnPriority; - class Compare - { - public: - bool operator() (const PreviewCreationRequest& r1,const PreviewCreationRequest& r2) const - { - if (r1.mnPriority != r2.mnPriority) - { - // Prefer requests with higher priority. - return r1.mnPriority > r2.mnPriority; - } - else - { - // Prefer tokens that have been earlier created (those with lower - // value). - return r1.mpDescriptor->maToken < r2.mpDescriptor->maToken; - } - } - }; - class CompareToken - { - public: - MasterPageContainer::Token maToken; - CompareToken(MasterPageContainer::Token aToken) : maToken(aToken) {} - bool operator() (const PreviewCreationRequest& rRequest) const - { return maToken==rRequest.mpDescriptor->maToken; } - }; -}; - - - - -//===== MasterPageContainerQueue::RequestQueue ================================ - -class MasterPageContainerQueue::RequestQueue - : public ::std::set<PreviewCreationRequest,PreviewCreationRequest::Compare> -{ -public: - RequestQueue (void) {} -}; - - - - -//===== MasterPageContainerQueue ============================================== - -MasterPageContainerQueue* MasterPageContainerQueue::Create ( - const ::boost::weak_ptr<ContainerAdapter>& rpContainer) -{ - MasterPageContainerQueue* pQueue = new MasterPageContainerQueue(rpContainer); - pQueue->LateInit(); - return pQueue; -} - - - - -MasterPageContainerQueue::MasterPageContainerQueue ( - const ::boost::weak_ptr<ContainerAdapter>& rpContainer) - : mpWeakContainer(rpContainer), - mpRequestQueue(new RequestQueue()), - maDelayedPreviewCreationTimer(), - mnRequestsServedCount(0) -{ -} - - - - -MasterPageContainerQueue::~MasterPageContainerQueue (void) -{ - maDelayedPreviewCreationTimer.Stop(); - while ( ! mpRequestQueue->empty()) - mpRequestQueue->erase(mpRequestQueue->begin()); -} - - - - -void MasterPageContainerQueue::LateInit (void) -{ - // Set up the timer for the delayed creation of preview bitmaps. - maDelayedPreviewCreationTimer.SetTimeout (snDelayedCreationTimeout); - Link aLink (LINK(this,MasterPageContainerQueue,DelayedPreviewCreation)); - maDelayedPreviewCreationTimer.SetTimeoutHdl(aLink); -} - - - - -bool MasterPageContainerQueue::RequestPreview (const SharedMasterPageDescriptor& rpDescriptor) -{ - bool bSuccess (false); - if (rpDescriptor.get() != NULL - && rpDescriptor->maLargePreview.GetSizePixel().Width() == 0) - { - sal_Int32 nPriority (CalculatePriority(rpDescriptor)); - - // Add a new or replace an existing request. - RequestQueue::iterator iRequest (::std::find_if( - mpRequestQueue->begin(), - mpRequestQueue->end(), - PreviewCreationRequest::CompareToken(rpDescriptor->maToken))); - // When a request for the same token exists then the lowest of the - // two priorities is used. - if (iRequest != mpRequestQueue->end()) - if (iRequest->mnPriority < nPriority) - { - mpRequestQueue->erase(iRequest); - iRequest = mpRequestQueue->end(); - } - - // Add a new request when none exists (or has just been erased). - if (iRequest == mpRequestQueue->end()) - { - mpRequestQueue->insert(PreviewCreationRequest(rpDescriptor,nPriority)); - maDelayedPreviewCreationTimer.Start(); - bSuccess = true; - } - } - return bSuccess; -} - - - - -sal_Int32 MasterPageContainerQueue::CalculatePriority ( - const SharedMasterPageDescriptor& rpDescriptor) const -{ - sal_Int32 nPriority; - - // The cost is used as a starting value. - int nCost (0); - if (rpDescriptor->mpPreviewProvider.get() != NULL) - { - nCost = rpDescriptor->mpPreviewProvider->GetCostIndex(); - if (rpDescriptor->mpPreviewProvider->NeedsPageObject()) - if (rpDescriptor->mpPageObjectProvider.get() != NULL) - nCost += rpDescriptor->mpPageObjectProvider->GetCostIndex(); - } - - // Its negative value is used so that requests with a low cost are - // preferred over those with high costs. - nPriority = -nCost; - - // Add a term that introduces an order based on the appearance in the - // AllMasterPagesSelector. - nPriority -= rpDescriptor->maToken / 3; - - // Process requests for the CurrentMasterPagesSelector first. - if (rpDescriptor->meOrigin == MasterPageContainer::MASTERPAGE) - nPriority += snMasterPagePriorityBoost; - - return nPriority; -} - - - - -IMPL_LINK(MasterPageContainerQueue, DelayedPreviewCreation, Timer*, pTimer) -{ - bool bIsShowingFullScreenShow (false); - bool bWaitForMoreRequests (false); - - do - { - if (mpRequestQueue->size() == 0) - break; - - // First check whether the system is idle. - sal_Int32 nIdleState (tools::IdleDetection::GetIdleState()); - if (nIdleState != tools::IdleDetection::IDET_IDLE) - { - if ((nIdleState&tools::IdleDetection::IDET_FULL_SCREEN_SHOW_ACTIVE) != 0) - bIsShowingFullScreenShow = true; - break; - } - - PreviewCreationRequest aRequest (*mpRequestQueue->begin()); - - // Check if the request should really be processed right now. - // Reasons to not do it are when its cost is high and not many other - // requests have been inserted into the queue that would otherwise - // be processed first. - if (aRequest.mnPriority < snWaitForMoreRequestsPriorityThreshold - && (mnRequestsServedCount+mpRequestQueue->size() < snWaitForMoreRequestsCount)) - { - // Wait for more requests before this one is processed. Note - // that the queue processing is not started anew when this - // method is left. That is done when the next request is - // inserted. - bWaitForMoreRequests = true; - break; - } - - mpRequestQueue->erase(mpRequestQueue->begin()); - - if (aRequest.mpDescriptor.get() != NULL) - { - mnRequestsServedCount += 1; - if ( ! mpWeakContainer.expired()) - { - ::boost::shared_ptr<ContainerAdapter> pContainer (mpWeakContainer); - if (pContainer.get() != NULL) - pContainer->UpdateDescriptor(aRequest.mpDescriptor,false,true,true); - } - } - } - while (false); - - if (mpRequestQueue->size() > 0 && ! bWaitForMoreRequests) - { - int nTimeout (snDelayedCreationTimeout); - if (bIsShowingFullScreenShow) - nTimeout = snDelayedCreationTimeoutWhenNotIdle; - maDelayedPreviewCreationTimer.SetTimeout(nTimeout); - pTimer->Start(); - } - - return 0; -} - - - - -bool MasterPageContainerQueue::HasRequest (MasterPageContainer::Token aToken) const -{ - RequestQueue::iterator iRequest (::std::find_if( - mpRequestQueue->begin(), - mpRequestQueue->end(), - PreviewCreationRequest::CompareToken(aToken))); - return (iRequest != mpRequestQueue->end()); -} - - - - -bool MasterPageContainerQueue::IsEmpty (void) const -{ - return mpRequestQueue->empty(); -} - - - - -void MasterPageContainerQueue::ProcessAllRequests (void) -{ - snWaitForMoreRequestsCount = 0; - if (mpRequestQueue->size() > 0) - maDelayedPreviewCreationTimer.Start(); -} - - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainerQueue.hxx b/sd/source/ui/toolpanel/controls/MasterPageContainerQueue.hxx deleted file mode 100644 index e4251e48d..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageContainerQueue.hxx +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_QUEUE_HXX -#define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_QUEUE_HXX - -#include "MasterPageContainer.hxx" -#include "MasterPageDescriptor.hxx" - -#include <boost/scoped_ptr.hpp> -#include <boost/weak_ptr.hpp> - -namespace sd { namespace toolpanel { namespace controls { - - -/** The queue stores and processes all requests from a MasterPageContainer - for the creation of previews. - The order of request processing and its timing is controlled by a - heuristic that uses values given with each request and which is - controlled by various parameters that are described below. -*/ -class MasterPageContainerQueue -{ -public: - class ContainerAdapter { public: - virtual bool UpdateDescriptor ( - const SharedMasterPageDescriptor& rpDescriptor, - bool bForcePageObject, - bool bForcePreview, - bool bSendEvents) = 0; - }; - - static MasterPageContainerQueue* Create ( - const ::boost::weak_ptr<ContainerAdapter>& rpContainer); - virtual ~MasterPageContainerQueue (void); - - /** This method is typically called for entries in the container for - which GetPreviewState() returns OS_CREATABLE. The creation of the - preview is then scheduled to be executed asynchronously at a later - point in time. When the preview is available the change listeners - will be notified. - */ - bool RequestPreview (const SharedMasterPageDescriptor& rDescriptor); - - /** Return <TRUE/> when there is a request currently in the queue for - the given token. - */ - bool HasRequest (MasterPageContainer::Token aToken) const; - - /** Return <TRUE/> when there is at least one request in the queue. - */ - bool IsEmpty (void) const; - - /** After this call the queue does not wait anymore for requests with - higher priority when only a small number of requests with lower - priority are present. This method should be called when all - templates are inserted into the MasterPageContainer. - */ - void ProcessAllRequests (void); - -private: - ::boost::weak_ptr<ContainerAdapter> mpWeakContainer; - class PreviewCreationRequest; - class RequestQueue; - ::boost::scoped_ptr<RequestQueue> mpRequestQueue; - Timer maDelayedPreviewCreationTimer; - sal_uInt32 mnRequestsServedCount; - - // There are a couple of values that define various aspects of the - // heuristic that defines the order and timing in which requests for - // preview creation are processed. - - /** The time to wait (in milliseconds) between the creation of previews. - */ - static const sal_Int32 snDelayedCreationTimeout; - - /** The time to wait when the system is not idle. - */ - static const sal_Int32 snDelayedCreationTimeoutWhenNotIdle; - - /** Requests for previews of master pages in a document have their - priority increased by this value. - */ - static const sal_Int32 snMasterPagePriorityBoost; - - /** When only requests which a priority lower than this threshold exist - and not many requests have been made yet then wait with processing - them until more requests are present. - */ - static const sal_Int32 snWaitForMoreRequestsPriorityThreshold; - - /** When only requests which a priority lower than a threshold exist - and not more requests than this number have been made or already - processed then wait with processing them until more requests are - present. - */ - static sal_uInt32 snWaitForMoreRequestsCount; - - MasterPageContainerQueue (const ::boost::weak_ptr<ContainerAdapter>& rpContainer); - void LateInit (void); - - /** Calculate the priority that defines the order in which requests - are processed. - */ - sal_Int32 CalculatePriority (const SharedMasterPageDescriptor& rDescriptor) const; - - DECL_LINK(DelayedPreviewCreation, Timer *); -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageDescriptor.cxx b/sd/source/ui/toolpanel/controls/MasterPageDescriptor.cxx deleted file mode 100644 index c891878d4..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageDescriptor.cxx +++ /dev/null @@ -1,426 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "MasterPageDescriptor.hxx" - -#include "DocumentHelper.hxx" -#include "sdpage.hxx" -#include <tools/urlobj.hxx> - -namespace sd { namespace toolpanel { namespace controls { - - -//===== MasterPageDescriptor ================================================== - -MasterPageDescriptor::MasterPageDescriptor ( - MasterPageContainer::Origin eOrigin, - const sal_Int32 nTemplateIndex, - const String& rsURL, - const String& rsPageName, - const String& rsStyleName, - const bool bIsPrecious, - const ::boost::shared_ptr<PageObjectProvider>& rpPageObjectProvider, - const ::boost::shared_ptr<PreviewProvider>& rpPreviewProvider) - : maToken(MasterPageContainer::NIL_TOKEN), - meOrigin(eOrigin), - msURL(INetURLObject(rsURL).GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS)), - msPageName(rsPageName), - msStyleName(rsStyleName), - mbIsPrecious(bIsPrecious), - mpMasterPage(NULL), - mpSlide(NULL), - maSmallPreview(), - maLargePreview(), - mpPreviewProvider(rpPreviewProvider), - mpPageObjectProvider(rpPageObjectProvider), - mnTemplateIndex(nTemplateIndex), - meURLClassification(URLCLASS_UNDETERMINED), - mnUseCount(0) -{ -} - - - - -MasterPageDescriptor::MasterPageDescriptor (const MasterPageDescriptor& rDescriptor) - : maToken(rDescriptor.maToken), - meOrigin(rDescriptor.meOrigin), - msURL(rDescriptor.msURL), - msPageName(rDescriptor.msPageName), - msStyleName(rDescriptor.msStyleName), - mbIsPrecious(rDescriptor.mbIsPrecious), - mpMasterPage(rDescriptor.mpMasterPage), - mpSlide(rDescriptor.mpSlide), - maSmallPreview(rDescriptor.maSmallPreview), - maLargePreview(rDescriptor.maLargePreview), - mpPreviewProvider(rDescriptor.mpPreviewProvider), - mpPageObjectProvider(rDescriptor.mpPageObjectProvider), - mnTemplateIndex(rDescriptor.mnTemplateIndex), - meURLClassification(rDescriptor.meURLClassification), - mnUseCount(rDescriptor.mnUseCount) -{ -} - - - - -MasterPageDescriptor::~MasterPageDescriptor (void) -{ -} - - - - -void MasterPageDescriptor::SetToken (MasterPageContainer::Token aToken) -{ - maToken = aToken; -} - - - - -Image MasterPageDescriptor::GetPreview (MasterPageContainer::PreviewSize eSize) const -{ - if (eSize == MasterPageContainer::SMALL) - return maSmallPreview; - else - return maLargePreview; -} - - - - -::std::auto_ptr<std::vector<MasterPageContainerChangeEvent::EventType> > - MasterPageDescriptor::Update ( - const MasterPageDescriptor& rDescriptor) -{ - bool bDataChanged (false); - bool bIndexChanged (false); - bool bPreviewChanged (false); - - if (meOrigin==MasterPageContainer::UNKNOWN - && rDescriptor.meOrigin!=MasterPageContainer::UNKNOWN) - { - meOrigin = rDescriptor.meOrigin; - bIndexChanged = true; - } - - if (msURL.getLength()==0 && rDescriptor.msURL.getLength()!=0) - { - msURL = rDescriptor.msURL; - bDataChanged = true; - } - - if (msPageName.getLength()==0 && rDescriptor.msPageName.getLength()!=0) - { - msPageName = rDescriptor.msPageName; - bDataChanged = true; - } - - if (msStyleName.getLength()==0 && rDescriptor.msStyleName.getLength()!=0) - { - msStyleName = rDescriptor.msStyleName; - bDataChanged = true; - } - - if (mpPageObjectProvider.get()==NULL && rDescriptor.mpPageObjectProvider.get()!=NULL) - { - mpPageObjectProvider = rDescriptor.mpPageObjectProvider; - bDataChanged = true; - } - - if (mpPreviewProvider.get()==NULL && rDescriptor.mpPreviewProvider.get()!=NULL) - { - mpPreviewProvider = rDescriptor.mpPreviewProvider; - bPreviewChanged = true; - } - - if (mnTemplateIndex<0 && rDescriptor.mnTemplateIndex>=0) - { - mnTemplateIndex = rDescriptor.mnTemplateIndex; - bIndexChanged = true; - } - - // Prepare the list of event types that will be returned. - ::std::auto_ptr<std::vector<MasterPageContainerChangeEvent::EventType> > pResult; - if (bDataChanged || bIndexChanged || bPreviewChanged) - { - pResult.reset(new std::vector<MasterPageContainerChangeEvent::EventType>()); - if (bDataChanged) - pResult->push_back(MasterPageContainerChangeEvent::DATA_CHANGED); - if (bIndexChanged) - pResult->push_back(MasterPageContainerChangeEvent::INDEX_CHANGED); - if (bPreviewChanged) - pResult->push_back(MasterPageContainerChangeEvent::PREVIEW_CHANGED); - } - - return pResult; -} - - - - -bool MasterPageDescriptor::UpdatePageObject ( - sal_Int32 nCostThreshold, - SdDrawDocument* pDocument) -{ - bool bModified (false); - - // Update the page object when that is not yet known. - if (mpMasterPage == NULL - && mpPageObjectProvider.get()!=NULL - && (nCostThreshold<0 || mpPageObjectProvider->GetCostIndex()<=nCostThreshold)) - { - // Note that pDocument may be NULL. - - SdPage* pPage = (*mpPageObjectProvider)(pDocument); - if (meOrigin == MasterPageContainer::MASTERPAGE) - { - mpMasterPage = pPage; - if (mpMasterPage != NULL) - mpMasterPage->SetPrecious(mbIsPrecious); - } - else - { - // Master pages from templates are copied into the local document. - if (pDocument != NULL) - mpMasterPage = DocumentHelper::CopyMasterPageToLocalDocument(*pDocument,pPage); - mpSlide = DocumentHelper::GetSlideForMasterPage(mpMasterPage); - } - - if (mpMasterPage != NULL) - { - // Update page name and style name. - if (msPageName.getLength() == 0) - msPageName = mpMasterPage->GetName(); - msStyleName = mpMasterPage->GetName(); - - // Delete an existing substitution. The next request for a preview - // will create the real one. - maSmallPreview = Image(); - maLargePreview = Image(); - mpPreviewProvider = ::boost::shared_ptr<PreviewProvider>(new PagePreviewProvider()); - } - else - { - DBG_ASSERT(false, "UpdatePageObject: master page is NULL"); - } - - bModified = true; - } - - return bModified; -} - - - - -bool MasterPageDescriptor::UpdatePreview ( - sal_Int32 nCostThreshold, - const Size& rSmallSize, - const Size& rLargeSize, - ::sd::PreviewRenderer& rRenderer) -{ - bool bModified (false); - - // Update the preview when that is not yet known. - if (maLargePreview.GetSizePixel().Width()==0 - && mpPreviewProvider.get()!=NULL - && (nCostThreshold<0 || mpPreviewProvider->GetCostIndex()<=nCostThreshold)) - { - SdPage* pPage = mpSlide; - if (pPage == NULL) - { - pPage = mpMasterPage; - } - maLargePreview = (*mpPreviewProvider)( - rLargeSize.Width(), - pPage, - rRenderer); - if (maLargePreview.GetSizePixel().Width() > 0) - { - // Create the small preview by scaling the large one down. - maSmallPreview = rRenderer.ScaleBitmap( - maLargePreview.GetBitmapEx(), - rSmallSize.Width()); - // The large preview may not have the desired width. Scale it - // accrodingly. - if (maLargePreview.GetSizePixel().Width() != rLargeSize.Width()) - maLargePreview = rRenderer.ScaleBitmap( - maLargePreview.GetBitmapEx(), - rLargeSize.Width()); - bModified = true; - } - } - - return bModified; -} - - - - -MasterPageDescriptor::URLClassification MasterPageDescriptor::GetURLClassification (void) -{ - if (meURLClassification == URLCLASS_UNDETERMINED) - { - if (msURL.getLength() == 0) - meURLClassification = URLCLASS_UNKNOWN; - else if (msURL.indexOf(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("presnt")))>=0) - { - meURLClassification = URLCLASS_PRESENTATION; - } - else if (msURL.indexOf(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("layout")))>=0) - { - meURLClassification = URLCLASS_LAYOUT; - } - else if (msURL.indexOf(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("educate")))>=0) - { - meURLClassification = URLCLASS_OTHER; - } - else - { - meURLClassification = URLCLASS_USER; - } - } - - return meURLClassification; -} - - - -//===== URLComparator ========================================================= - -MasterPageDescriptor::URLComparator::URLComparator (const ::rtl::OUString& sURL) - : msURL(sURL) -{ -} - - - - -bool MasterPageDescriptor::URLComparator::operator() ( - const SharedMasterPageDescriptor& rDescriptor) -{ - if (rDescriptor.get() == NULL) - return false; - else - return rDescriptor->msURL.equals(msURL); -} - - - - -// ===== StyleNameComparator ================================================== - -MasterPageDescriptor::StyleNameComparator::StyleNameComparator (const ::rtl::OUString& sStyleName) - : msStyleName(sStyleName) -{ -} - - - - -bool MasterPageDescriptor::StyleNameComparator::operator() ( - const SharedMasterPageDescriptor& rDescriptor) -{ - if (rDescriptor.get() == NULL) - return false; - else - return rDescriptor->msStyleName.equals(msStyleName); -} - - - - -//===== PageObjectComparator ================================================== - -MasterPageDescriptor::PageObjectComparator::PageObjectComparator (const SdPage* pPageObject) - : mpMasterPage(pPageObject) -{ -} - - - - -bool MasterPageDescriptor::PageObjectComparator::operator() ( - const SharedMasterPageDescriptor& rDescriptor) -{ - if (rDescriptor.get() == NULL) - return false; - else - return rDescriptor->mpMasterPage==mpMasterPage; -} - - - - -//===== AllComparator ========================================================= - -MasterPageDescriptor::AllComparator::AllComparator(const SharedMasterPageDescriptor& rDescriptor) - : mpDescriptor(rDescriptor) -{ -} - - - - -bool MasterPageDescriptor::AllComparator::operator() (const SharedMasterPageDescriptor&rDescriptor) -{ - if (rDescriptor.get() == NULL) - return false; - else - { - // Take URL, page name, style name, and page object into account - // when comparing two descriptors. When two descriptors are - // identical in any of these values then their are thought of as - // equivalent. Only the Origin has to be the same in both - // descriptors. - return - mpDescriptor->meOrigin == rDescriptor->meOrigin - && ( - (mpDescriptor->msURL.getLength()>0 - && mpDescriptor->msURL.equals(rDescriptor->msURL)) - || (mpDescriptor->msPageName.getLength()>0 - && mpDescriptor->msPageName.equals(rDescriptor->msPageName)) - || (mpDescriptor->msStyleName.getLength()>0 - && mpDescriptor->msStyleName.equals(rDescriptor->msStyleName)) - || (mpDescriptor->mpMasterPage!=NULL - && mpDescriptor->mpMasterPage==rDescriptor->mpMasterPage) - || (mpDescriptor->mpPageObjectProvider.get()!=NULL - && rDescriptor->mpPageObjectProvider.get()!=NULL - && mpDescriptor->mpPageObjectProvider==rDescriptor->mpPageObjectProvider)); - } -} - - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageDescriptor.hxx b/sd/source/ui/toolpanel/controls/MasterPageDescriptor.hxx deleted file mode 100644 index 0761d4959..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageDescriptor.hxx +++ /dev/null @@ -1,243 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_MASTER_PAGE_DESCRIPTOR_HXX -#define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_DESCRIPTOR_HXX - -#include "MasterPageContainer.hxx" -#include <boost/shared_ptr.hpp> - -namespace sd { namespace toolpanel { namespace controls { - -class PageObjectProvider; -class PreviewProvider; - -class MasterPageDescriptor; -typedef ::boost::shared_ptr<MasterPageDescriptor> SharedMasterPageDescriptor; - -/** A collection of data that is stored for every master page in the - MasterpageContainer. -*/ -class MasterPageDescriptor -{ -public: - MasterPageDescriptor ( - MasterPageContainer::Origin eOrigin, - const sal_Int32 nTemplateIndex, - const String& rURL, - const String& rPageName, - const String& rStyleName, - const bool bIsPrecious, - const ::boost::shared_ptr<PageObjectProvider>& rpPageObjectProvider, - const ::boost::shared_ptr<PreviewProvider>& rpPreviewProvider); - MasterPageDescriptor (const MasterPageDescriptor& rDescriptor); - ~MasterPageDescriptor (void); - - void SetToken (MasterPageContainer::Token aToken); - - /** Update the called MasterPageDescriptor object with values from the - given one. Only those values are updated that have default values - in the called object and that have non-default values in the given - one. - @return - Returns a list of event types for which event notifications have - to be sent to listeners. The list may be empty or NULL. - */ - ::std::auto_ptr<std::vector<MasterPageContainerChangeEvent::EventType> > - Update ( - const MasterPageDescriptor& rDescriptor); - - /** This convenience method returns either a small or a large preview, - depending on the given size specifier. - Note that the previews are not created when they are not present. - @return - The returned preview may be empty. - */ - Image GetPreview (MasterPageContainer::PreviewSize ePreviewSize) const; - - /** Use the PreviewProvider to get access to a preview of the master - page. - - Note that this is only done, when either bForce is <TRUE/> or - the PreviewProvider::GetCostIndex() returns 0. - - The small preview is created by scaling the large one, not by - calling PreviewProvider::operator() a second time. - - It is the responsibility of the caller to call UpdatePageObject() - before calling this method when the PreviewProvider can only work - when the master page object is present, i.e. its NeedsPageObject() - method returns <TRUE/>. - - @param nCostThreshold - When this is zero or positive then the preview is created only - when the preview provider has a cost equal to or smaller than - this threshold. A negative value forces the preview to be - created, regardless of the cost. - @param rSmallSize - Size of the small preview. - @param rLargeSize - Size of the large preview. - @param rRenderer - A PreviewRenderer object that may be used to create a preview. - @return - When the previews are successfully provided then <TRUE/> is - returned. - */ - bool UpdatePreview ( - sal_Int32 nCostThreshold, - const Size& rSmallSize, - const Size& rLargeSize, - ::sd::PreviewRenderer& rRenderer); - - /** Use the PageObjectProvider to get access to the master page object. - - Note that this is only done, when either bForce is <TRUE/> or the - PreviewProvider::GetCostIndex() returns 0. - - @param nCostThreshold - When this is zero or positive then the page object is created - only when the page object provider has a cost equal to or - smaller than this threshold. A negative value forces the - page object be created, regardless of the cost. - @param pDocument - This document of the MasterPageContainer may be used to create - a page object with or store one in. - @return - When the master page object is successfully provided then - <TRUE/> is returned. - */ - bool UpdatePageObject ( - sal_Int32 nCostThreshold, - SdDrawDocument* pDocument); - - enum URLClassification { - URLCLASS_USER, - URLCLASS_LAYOUT, - URLCLASS_PRESENTATION, - URLCLASS_OTHER, - URLCLASS_UNKNOWN, - URLCLASS_UNDETERMINED - }; - - URLClassification GetURLClassification (void); - - /** The Token under which the MasterPageContainer gives access to the - object. - */ - MasterPageContainer::Token maToken; - - /** A rough specification of the origin of the master page. - */ - MasterPageContainer::Origin meOrigin; - - /** The URL is not empty for master pages loaded from a template - document. - */ - ::rtl::OUString msURL; - - /** Taken from the title of the template file. - */ - ::rtl::OUString msPageName; - - /** Taken from the master page object. - */ - ::rtl::OUString msStyleName; - - const bool mbIsPrecious; - - /** The actual master page. - */ - SdPage* mpMasterPage; - - /** A slide that uses the master page. - */ - SdPage* mpSlide; - - /** A small (the default size) preview of the master page. May be - empty. When this smaller preview is not empty then the larger one - is not empty, too. - */ - Image maSmallPreview; - - /** A large preview of the master page. May be empty. When this larger - preview is not empty then the smaller one is not empty, too. - */ - Image maLargePreview; - - /** The prewview provider. May be empty. May be replaced during the - lifetime of a MasterPageDescriptor object. - */ - ::boost::shared_ptr<PreviewProvider> mpPreviewProvider; - - /** The master page provider. May be empty. May be replaced during - the lifetime of a MasterPageDescriptor object. - */ - ::boost::shared_ptr<PageObjectProvider> mpPageObjectProvider; - - /** This index represents the order in which templates are provided via - the TemplateScanner. It defines the order in which the entries in - the AllMasterPagesSelector are displayed. The default value is -1. - */ - sal_Int32 mnTemplateIndex; - - URLClassification meURLClassification; - - sal_Int32 mnUseCount; - - class URLComparator { public: - ::rtl::OUString msURL; - URLComparator (const ::rtl::OUString& sURL); - bool operator() (const SharedMasterPageDescriptor& rDescriptor); - }; - class StyleNameComparator { public: - ::rtl::OUString msStyleName; - StyleNameComparator (const ::rtl::OUString& sStyleName); - bool operator() (const SharedMasterPageDescriptor& rDescriptor); - }; - class PageObjectComparator { public: - const SdPage* mpMasterPage; - PageObjectComparator (const SdPage* pPageObject); - bool operator() (const SharedMasterPageDescriptor& rDescriptor); - }; - class AllComparator { public: - AllComparator(const SharedMasterPageDescriptor& rDescriptor); - bool operator() (const SharedMasterPageDescriptor& rDescriptor); - private: - SharedMasterPageDescriptor mpDescriptor; - }; - - -}; - - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPageObserver.cxx b/sd/source/ui/toolpanel/controls/MasterPageObserver.cxx deleted file mode 100644 index f16f6876e..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPageObserver.cxx +++ /dev/null @@ -1,429 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "MasterPageObserver.hxx" - -#include <algorithm> -#include "drawdoc.hxx" -#include "sdpage.hxx" -#include <boost/unordered_map.hpp> -#include <set> -#include <vector> -#include <svl/lstner.hxx> -#include <osl/doublecheckedlocking.h> -#include <osl/getglobalmutex.hxx> - - -namespace sd { - -class MasterPageObserver::Implementation - : public SfxListener -{ -public: - /** The single instance of this class. It is created on demand when - Instance() is called for the first time. - */ - static MasterPageObserver* mpInstance; - - /** The master page observer will listen to events of this document and - detect changes of the use of master pages. - */ - void RegisterDocument (SdDrawDocument& rDocument); - - /** The master page observer will stop to listen to events of this - document. - */ - void UnregisterDocument (SdDrawDocument& rDocument); - - /** Add a listener that is informed of master pages that are newly - assigned to slides or become unassigned. - @param rEventListener - The event listener to call for future events. Call - RemoveEventListener() before the listener is destroyed. - */ - void AddEventListener (const Link& rEventListener); - - /** Remove the given listener from the list of listeners. - @param rEventListener - After this method returns the given listener is not called back - from this object. Passing a listener that has not - been registered before is safe and is silently ignored. - */ - void RemoveEventListener (const Link& rEventListener); - - /** Return a set of the names of master pages for the given document. - This convenience method exists because this set is part of the - internal data structure and thus takes no time to create. - */ - inline MasterPageObserver::MasterPageNameSet GetMasterPageNames ( - SdDrawDocument& rDocument); - -private: - ::std::vector<Link> maListeners; - - struct DrawDocHash { - size_t operator()(SdDrawDocument* argument) const - { return reinterpret_cast<unsigned long>(argument); } - }; - typedef ::boost::unordered_map<SdDrawDocument*, - MasterPageObserver::MasterPageNameSet, - DrawDocHash> - MasterPageContainer; - MasterPageContainer maUsedMasterPages; - - virtual void Notify( - SfxBroadcaster& rBroadcaster, - const SfxHint& rHint); - - void AnalyzeUsedMasterPages (SdDrawDocument& rDocument); - - void SendEvent (MasterPageObserverEvent& rEvent); -}; - -MasterPageObserver* MasterPageObserver::Implementation::mpInstance = NULL; - - - -//===== MasterPageObserver ==================================================== - -MasterPageObserver& MasterPageObserver::Instance (void) -{ - if (Implementation::mpInstance == NULL) - { - ::osl::GetGlobalMutex aMutexFunctor; - ::osl::MutexGuard aGuard (aMutexFunctor()); - if (Implementation::mpInstance == NULL) - { - MasterPageObserver* pInstance = new MasterPageObserver (); - SdGlobalResourceContainer::Instance().AddResource ( - ::std::auto_ptr<SdGlobalResource>(pInstance)); - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - Implementation::mpInstance = pInstance; - } - } - else - { - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - } - - DBG_ASSERT(Implementation::mpInstance!=NULL, - "MasterPageObserver::Instance(): instance is NULL"); - return *Implementation::mpInstance; -} - - - - -void MasterPageObserver::RegisterDocument (SdDrawDocument& rDocument) -{ - mpImpl->RegisterDocument (rDocument); -} - - - - -void MasterPageObserver::UnregisterDocument (SdDrawDocument& rDocument) -{ - mpImpl->UnregisterDocument (rDocument); -} - - - - -void MasterPageObserver::AddEventListener (const Link& rEventListener) -{ - - mpImpl->AddEventListener (rEventListener); -} - - - - -void MasterPageObserver::RemoveEventListener (const Link& rEventListener) -{ - mpImpl->RemoveEventListener (rEventListener); -} - - - - -MasterPageObserver::MasterPageObserver (void) - : mpImpl (new Implementation()) -{} - - - - -MasterPageObserver::~MasterPageObserver (void) -{} - - - - -//===== MasterPageObserver::Implementation ==================================== - -void MasterPageObserver::Implementation::RegisterDocument ( - SdDrawDocument& rDocument) -{ - // Gather the names of all the master pages in the given document. - MasterPageContainer::mapped_type aMasterPageSet; - sal_uInt16 nMasterPageCount = rDocument.GetMasterSdPageCount(PK_STANDARD); - for (sal_uInt16 nIndex=0; nIndex<nMasterPageCount; nIndex++) - { - SdPage* pMasterPage = rDocument.GetMasterSdPage (nIndex, PK_STANDARD); - if (pMasterPage != NULL) - aMasterPageSet.insert (pMasterPage->GetName()); - } - - maUsedMasterPages[&rDocument] = aMasterPageSet; - - StartListening (rDocument); -} - - - - -void MasterPageObserver::Implementation::UnregisterDocument ( - SdDrawDocument& rDocument) -{ - EndListening (rDocument); - - MasterPageContainer::iterator aMasterPageDescriptor(maUsedMasterPages.find(&rDocument)); - if(aMasterPageDescriptor != maUsedMasterPages.end()) - maUsedMasterPages.erase(aMasterPageDescriptor); -} - - - - -void MasterPageObserver::Implementation::AddEventListener ( - const Link& rEventListener) -{ - if (::std::find ( - maListeners.begin(), - maListeners.end(), - rEventListener) == maListeners.end()) - { - maListeners.push_back (rEventListener); - - // Tell the new listener about all the master pages that are - // currently in use. - typedef ::std::vector<String> StringList; - StringList aNewMasterPages; - StringList aRemovedMasterPages; - MasterPageContainer::iterator aDocumentIterator; - for (aDocumentIterator=maUsedMasterPages.begin(); - aDocumentIterator!=maUsedMasterPages.end(); - ++aDocumentIterator) - { - ::std::set<String>::reverse_iterator aNameIterator; - for (aNameIterator=aDocumentIterator->second.rbegin(); - aNameIterator!=aDocumentIterator->second.rend(); - ++aNameIterator) - { - MasterPageObserverEvent aEvent ( - MasterPageObserverEvent::ET_MASTER_PAGE_EXISTS, - *aDocumentIterator->first, - *aNameIterator); - SendEvent (aEvent); - } - } - } -} - - - - -void MasterPageObserver::Implementation::RemoveEventListener ( - const Link& rEventListener) -{ - maListeners.erase ( - ::std::find ( - maListeners.begin(), - maListeners.end(), - rEventListener)); -} - - - - -MasterPageObserver::MasterPageNameSet - MasterPageObserver::Implementation::GetMasterPageNames ( - SdDrawDocument& rDocument) -{ - MasterPageContainer::iterator aMasterPageDescriptor ( - maUsedMasterPages.find(&rDocument)); - if (aMasterPageDescriptor != maUsedMasterPages.end()) - return aMasterPageDescriptor->second; - else - // Not found so return an empty set. - return MasterPageObserver::MasterPageNameSet(); -} - - - - -void MasterPageObserver::Implementation::Notify( - SfxBroadcaster& rBroadcaster, - const SfxHint& rHint) -{ - if (rHint.ISA(SdrHint)) - { - SdrHint& rSdrHint (*PTR_CAST(SdrHint,&rHint)); - switch (rSdrHint.GetKind()) - { - case HINT_PAGEORDERCHG: - // Process the modified set of pages only when the number of - // standard and notes master pages are equal. This test - // filters out events that are sent in between the insertion - // of a new standard master page and a new notes master - // page. - if (rBroadcaster.ISA(SdDrawDocument)) - { - SdDrawDocument& rDocument ( - static_cast<SdDrawDocument&>(rBroadcaster)); - if (rDocument.GetMasterSdPageCount(PK_STANDARD) - == rDocument.GetMasterSdPageCount(PK_NOTES)) - { - AnalyzeUsedMasterPages (rDocument); - } - } - break; - - default: - break; - } - } -} - - - - -void MasterPageObserver::Implementation::AnalyzeUsedMasterPages ( - SdDrawDocument& rDocument) -{ - // Create a set of names of the master pages used by the given document. - sal_uInt16 nMasterPageCount = rDocument.GetMasterSdPageCount(PK_STANDARD); - ::std::set<String> aCurrentMasterPages; - for (sal_uInt16 nIndex=0; nIndex<nMasterPageCount; nIndex++) - { - SdPage* pMasterPage = rDocument.GetMasterSdPage (nIndex, PK_STANDARD); - if (pMasterPage != NULL) - aCurrentMasterPages.insert (pMasterPage->GetName()); - OSL_TRACE("currently used master page %d is %s", - nIndex, - ::rtl::OUStringToOString(pMasterPage->GetName(), - RTL_TEXTENCODING_UTF8).getStr()); - } - - typedef ::std::vector<String> StringList; - StringList aNewMasterPages; - StringList aRemovedMasterPages; - MasterPageContainer::iterator aOldMasterPagesDescriptor ( - maUsedMasterPages.find(&rDocument)); - if (aOldMasterPagesDescriptor != maUsedMasterPages.end()) - { - StringList::iterator I; - - ::std::set<String>::iterator J; - int i=0; - for (J=aOldMasterPagesDescriptor->second.begin(); - J!=aOldMasterPagesDescriptor->second.end(); - ++J) - OSL_TRACE("old used master page %d is %s", - i++, - ::rtl::OUStringToOString(*J, - RTL_TEXTENCODING_UTF8).getStr()); - - // Send events about the newly used master pages. - ::std::set_difference ( - aCurrentMasterPages.begin(), - aCurrentMasterPages.end(), - aOldMasterPagesDescriptor->second.begin(), - aOldMasterPagesDescriptor->second.end(), - ::std::back_insert_iterator<StringList>(aNewMasterPages)); - for (I=aNewMasterPages.begin(); I!=aNewMasterPages.end(); ++I) - { - OSL_TRACE(" added master page %s", - ::rtl::OUStringToOString(*I, - RTL_TEXTENCODING_UTF8).getStr()); - - MasterPageObserverEvent aEvent ( - MasterPageObserverEvent::ET_MASTER_PAGE_ADDED, - rDocument, - *I); - SendEvent (aEvent); - } - - // Send events about master pages that are not used any longer. - ::std::set_difference ( - aOldMasterPagesDescriptor->second.begin(), - aOldMasterPagesDescriptor->second.end(), - aCurrentMasterPages.begin(), - aCurrentMasterPages.end(), - ::std::back_insert_iterator<StringList>(aRemovedMasterPages)); - for (I=aRemovedMasterPages.begin(); I!=aRemovedMasterPages.end(); ++I) - { - OSL_TRACE(" removed master page %s", - ::rtl::OUStringToOString(*I, - RTL_TEXTENCODING_UTF8).getStr()); - - MasterPageObserverEvent aEvent ( - MasterPageObserverEvent::ET_MASTER_PAGE_REMOVED, - rDocument, - *I); - SendEvent (aEvent); - } - - // Store the new list of master pages. - aOldMasterPagesDescriptor->second = aCurrentMasterPages; - } -} - - - - -void MasterPageObserver::Implementation::SendEvent ( - MasterPageObserverEvent& rEvent) -{ - ::std::vector<Link>::iterator aLink (maListeners.begin()); - ::std::vector<Link>::iterator aEnd (maListeners.end()); - while (aLink!=aEnd) - { - aLink->Call (&rEvent); - ++aLink; - } -} - - -} // end of namespace sd - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPagesPanel.cxx b/sd/source/ui/toolpanel/controls/MasterPagesPanel.cxx deleted file mode 100644 index d23b48c38..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPagesPanel.cxx +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "MasterPagesPanel.hxx" -#include "taskpane/ScrollPanel.hxx" -#include "CurrentMasterPagesSelector.hxx" -#include "RecentMasterPagesSelector.hxx" -#include "AllMasterPagesSelector.hxx" -#include "taskpane/ToolPanelViewShell.hxx" -#include "taskpane/TaskPaneControlFactory.hxx" -#include "taskpane/TitledControl.hxx" -#include "../TaskPaneShellManager.hxx" - -#include "DrawViewShell.hxx" -#include "ViewShellBase.hxx" - -#include "strings.hrc" -#include "sdresid.hxx" -#include "helpids.h" -#include <svtools/valueset.hxx> -#include "app.hrc" - -namespace sd { namespace toolpanel { namespace controls { - - -MasterPagesPanel::MasterPagesPanel (::Window& i_rParentWindow, ToolPanelViewShell& i_rPanelViewShell) - :ScrollPanel (i_rParentWindow) - ,m_pPanelViewShell( &i_rPanelViewShell ) -{ - impl_construct( m_pPanelViewShell->GetViewShellBase() ); -} - -void MasterPagesPanel::impl_construct( ViewShellBase& rBase ) -{ - SdDrawDocument* pDocument = rBase.GetDocument(); - ::std::auto_ptr<controls::MasterPagesSelector> pSelector; - - ::boost::shared_ptr<MasterPageContainer> pContainer (new MasterPageContainer()); - - // Create a panel with the master pages that are in use by the currently - // edited document. - DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(rBase.GetMainViewShell().get()); - pSelector.reset(new controls::CurrentMasterPagesSelector ( - this, - *pDocument, - rBase, - pContainer)); - pSelector->LateInit(); - pSelector->SetHelpId( HID_SD_TASK_PANE_PREVIEW_CURRENT ); - GetShellManager()->AddSubShell( - SHELLID_SD_TASK_PANE_PREVIEW_CURRENT, - pSelector.get(), - pSelector->GetWindow()); - AddControl ( - ::std::auto_ptr<TreeNode>(pSelector.release()), - SdResId(STR_TASKPANEL_CURRENT_MASTER_PAGES_TITLE), - HID_SD_CURRENT_MASTERS); - - // Create a panel with the most recently used master pages. - pSelector.reset(new controls::RecentMasterPagesSelector ( - this, - *pDocument, - rBase, - pContainer)); - pSelector->LateInit(); - pSelector->SetHelpId( HID_SD_TASK_PANE_PREVIEW_RECENT ); - GetShellManager()->AddSubShell( - SHELLID_SD_TASK_PANE_PREVIEW_RECENT, - pSelector.get(), - pSelector->GetWindow()); - AddControl ( - ::std::auto_ptr<TreeNode>(pSelector.release()), - SdResId(STR_TASKPANEL_RECENT_MASTER_PAGES_TITLE), - HID_SD_RECENT_MASTERS); - - // Create a panel with all available master pages. - pSelector.reset(new controls::AllMasterPagesSelector ( - this, - *pDocument, - rBase, - *pDrawViewShell, - pContainer)); - pSelector->LateInit(); - pSelector->SetHelpId( HID_SD_TASK_PANE_PREVIEW_ALL ); - GetShellManager()->AddSubShell( - SHELLID_SD_TASK_PANE_PREVIEW_ALL, - pSelector.get(), - pSelector->GetWindow()); - AddControl ( - ::std::auto_ptr<TreeNode>(pSelector.release()), - SdResId(STR_TASKPANEL_ALL_MASTER_PAGES_TITLE), - HID_SD_ALL_MASTERS); -} - - - - - -MasterPagesPanel::~MasterPagesPanel (void) -{ - TaskPaneShellManager* pShellManager( GetShellManager() ); - OSL_ENSURE( pShellManager, "MasterPagesPanel::~MasterPagesPanel: no shell manager anymore - cannot remove sub shells!" ); - if ( pShellManager ) - { - pShellManager->RemoveSubShell( SHELLID_SD_TASK_PANE_PREVIEW_CURRENT ); - pShellManager->RemoveSubShell( SHELLID_SD_TASK_PANE_PREVIEW_RECENT ); - pShellManager->RemoveSubShell( SHELLID_SD_TASK_PANE_PREVIEW_ALL ); - } -} - - - - -TaskPaneShellManager* MasterPagesPanel::GetShellManager() -{ - if ( m_pPanelViewShell ) - return &m_pPanelViewShell->GetSubShellManager(); - return TreeNode::GetShellManager(); -} - - - - -std::auto_ptr< ControlFactory > MasterPagesPanel::CreateControlFactory( ToolPanelViewShell& i_rToolPanelShell ) -{ - return std::auto_ptr< ControlFactory >( - new RootControlFactoryWithArg< MasterPagesPanel, ToolPanelViewShell >( i_rToolPanelShell ) ); -} - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPagesPanel.hxx b/sd/source/ui/toolpanel/controls/MasterPagesPanel.hxx deleted file mode 100644 index 8c886d007..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPagesPanel.hxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TASKPANE_CONTROLS_MASTER_PAGES_PANEL_HXX -#define SD_TASKPANE_CONTROLS_MASTER_PAGES_PANEL_HXX - -#include "taskpane/ScrollPanel.hxx" - -namespace sd { -class ViewShellBase; -} - -namespace sd { namespace toolpanel { -class ControlFactory; -class TreeNode; -class ToolPanelViewShell; -} } - -namespace sd { namespace toolpanel { namespace controls { - -/** The master pages panel combines three master page related panels into - one. This has the benefit that creation of the task pane becomes a - little bit simpler and that common scroll bars can be displayed. -*/ -class MasterPagesPanel - : public ScrollPanel -{ -public: - MasterPagesPanel ( - ::Window& i_rParentWindow, - ToolPanelViewShell& i_rPanelViewShell); - virtual ~MasterPagesPanel (void); - - // TreeNode overridables - virtual TaskPaneShellManager* GetShellManager (void); - - static std::auto_ptr<ControlFactory> CreateControlFactory (ToolPanelViewShell& i_rToolPanelShell); - -private: - void impl_construct( ViewShellBase& rBase ); - -private: - ToolPanelViewShell* m_pPanelViewShell; -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPagesSelector.cxx b/sd/source/ui/toolpanel/controls/MasterPagesSelector.cxx deleted file mode 100644 index ca0243d64..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPagesSelector.cxx +++ /dev/null @@ -1,846 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "MasterPagesSelector.hxx" - -#include "MasterPageContainer.hxx" -#include "DocumentHelper.hxx" -#include "pres.hxx" -#include "drawdoc.hxx" -#include "DrawDocShell.hxx" -#include "sdpage.hxx" -#include "glob.hxx" -#include "glob.hrc" -#include "app.hrc" -#include "res_bmp.hrc" -#include "strings.hrc" -#include "DrawViewShell.hxx" -#include "DrawController.hxx" -#include "SlideSorterViewShell.hxx" -#include "PreviewValueSet.hxx" -#include "ViewShellBase.hxx" -#include "../TaskPaneShellManager.hxx" -#include "taskpane/TitledControl.hxx" -#include "taskpane/ControlContainer.hxx" -#include "controller/SlideSorterController.hxx" -#include "controller/SlsPageSelector.hxx" -#include <sfx2/objface.hxx> -#include "sdresid.hxx" -#include "TemplateScanner.hxx" -#include "drawview.hxx" -#include <vcl/image.hxx> -#include <svl/languageoptions.hxx> -#include <sfx2/app.hxx> -#include <sfx2/dispatch.hxx> -#include <sfx2/mnumgr.hxx> -#include <svl/itemset.hxx> -#include <svl/eitem.hxx> -#include <svx/dlgutil.hxx> -#include <svx/svdpagv.hxx> -#include <svx/svxids.hrc> -#include "FrameView.hxx" -#include "sdpage.hxx" -#include "stlpool.hxx" -#include "unmovss.hxx" -#include <sfx2/request.hxx> -#include <svl/itempool.hxx> - -using namespace ::sd::toolpanel::controls; -#define MasterPagesSelector -#include "sdslots.hxx" - -using namespace ::com::sun::star::text; - - - -namespace sd { namespace toolpanel { namespace controls { - - -SFX_IMPL_INTERFACE(MasterPagesSelector, SfxShell, - SdResId(STR_MASTERPAGESSELECTOR)) -{ - SFX_POPUPMENU_REGISTRATION( SdResId(RID_TASKPANE_MASTERPAGESSELECTOR_POPUP) ); -} - -TYPEINIT1(MasterPagesSelector, SfxShell); - - - -MasterPagesSelector::MasterPagesSelector ( - TreeNode* pParent, - SdDrawDocument& rDocument, - ViewShellBase& rBase, - const ::boost::shared_ptr<MasterPageContainer>& rpContainer) - : TreeNode (pParent), - SfxShell(), - maMutex(), - mpContainer(rpContainer), - mrDocument(rDocument), - mpPageSet (new PreviewValueSet(pParent)), - mrBase(rBase), - mnDefaultClickAction(SID_TP_APPLY_TO_ALL_SLIDES), - maPreviewUpdateQueue(), - maCurrentItemList(), - maTokenToValueSetIndex(), - maLockedMasterPages() -{ - SetPool (&rDocument.GetPool()); - - mpPageSet->SetSelectHdl ( - LINK(this, MasterPagesSelector, ClickHandler)); - mpPageSet->SetRightMouseClickHandler ( - LINK(this, MasterPagesSelector, RightClickHandler)); - mpPageSet->SetContextMenuCallback ( - LINK(this, MasterPagesSelector, ContextMenuCallback)); - mpPageSet->SetStyle(mpPageSet->GetStyle() | WB_NO_DIRECTSELECT); - mpPageSet->SetPreviewSize(mpContainer->GetPreviewSizePixel()); - mpPageSet->Show(); - - Link aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener)); - mpContainer->AddChangeListener(aChangeListener); -} - - - - -MasterPagesSelector::~MasterPagesSelector (void) -{ - Clear(); - mpPageSet.reset(); - UpdateLocks(ItemList()); - - if (GetShellManager() != NULL) - GetShellManager()->RemoveSubShell (this); - - Link aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener)); - mpContainer->RemoveChangeListener(aChangeListener); -} - - - - -void MasterPagesSelector::LateInit (void) -{ -} - - - - -sal_Int32 MasterPagesSelector::GetPreferredWidth (sal_Int32 nHeight) -{ - const ::osl::MutexGuard aGuard (maMutex); - - return mpPageSet->GetPreferredWidth (nHeight); -} - - - - -sal_Int32 MasterPagesSelector::GetPreferredHeight (sal_Int32 nWidth) -{ - const ::osl::MutexGuard aGuard (maMutex); - - return mpPageSet->GetPreferredHeight (nWidth); -} - - - - -Size MasterPagesSelector::GetPreferredSize (void) -{ - int nPreferredWidth = GetPreferredWidth( - mpPageSet->GetOutputSizePixel().Height()); - int nPreferredHeight = GetPreferredHeight(nPreferredWidth); - return Size (nPreferredWidth, nPreferredHeight); - -} - - - - -void MasterPagesSelector::UpdateLocks (const ItemList& rItemList) -{ - ItemList aNewLockList; - - // In here we first lock the master pages in the given list and then - // release the locks acquired in a previous call to this method. When - // this were done the other way round the lock count of some master - // pages might drop temporarily to 0 and would lead to unnecessary - // deletion and re-creation of MasterPageDescriptor objects. - - // Lock the master pages in the given list. - ItemList::const_iterator iItem; - for (iItem=rItemList.begin(); iItem!=rItemList.end(); ++iItem) - { - mpContainer->AcquireToken(*iItem); - aNewLockList.push_back(*iItem); - } - - // Release the previously locked master pages. - ItemList::const_iterator iPage; - ItemList::const_iterator iEnd (maLockedMasterPages.end()); - for (iPage=maLockedMasterPages.begin(); iPage!=iEnd; ++iPage) - mpContainer->ReleaseToken(*iPage); - - maLockedMasterPages.swap(aNewLockList); -} - - - - -void MasterPagesSelector::Fill (void) -{ - ::std::auto_ptr<ItemList> pItemList (new ItemList()); - - Fill(*pItemList); - - UpdateLocks(*pItemList); - UpdateItemList(pItemList); -} - - - - -ResId MasterPagesSelector::GetContextMenuResId (void) const -{ - return SdResId(RID_TASKPANE_MASTERPAGESSELECTOR_POPUP); -} - - - - -IMPL_LINK(MasterPagesSelector, ClickHandler, PreviewValueSet*, EMPTYARG) -{ - // We use the framework to assign the clicked-on master page because we - // so use the same mechanism as the context menu does (where we do not - // have the option to call the assignment method directly.) - if (GetShellManager() != NULL) - GetShellManager()->MoveToTop (this); - - SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); - if (pViewFrame != NULL) - { - SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); - if (pDispatcher != NULL) - pDispatcher->Execute(mnDefaultClickAction); - } - - return 0; -} - - - - -IMPL_LINK(MasterPagesSelector, RightClickHandler, MouseEvent*, pEvent) -{ - // Here we only prepare the display of the context menu: the item under - // the mouse is selected. The actual display of the context menu is - // done in ContextMenuCallback which is called indirectly through - // PreviewValueSet::Command(). - mpPageSet->GrabFocus (); - mpPageSet->ReleaseMouse(); - if (GetDispatcher() != NULL && pEvent != NULL) - { - sal_uInt16 nIndex = mpPageSet->GetItemId (pEvent->GetPosPixel()); - if (nIndex > 0) - mpPageSet->SelectItem (nIndex); - } - return 0; -} - - - - -IMPL_LINK(MasterPagesSelector, ContextMenuCallback, CommandEvent*, pEvent) -{ - // Use the currently selected item and show the popup menu in its - // center. - if (GetShellManager() != NULL) - GetShellManager()->MoveToTop (this); - const sal_uInt16 nIndex = mpPageSet->GetSelectItemId(); - if (nIndex > 0 && pEvent!=NULL) - { - // The position of the upper left corner of the context menu is - // taken either from the mouse position (when the command was sent - // as reaction to a right click) or in the center of the selected - // item (when the command was sent as reaction to Shift+F10.) - Point aPosition (pEvent->GetMousePosPixel()); - if ( ! pEvent->IsMouseEvent()) - { - Rectangle aBBox (mpPageSet->GetItemRect(nIndex)); - aPosition = aBBox.Center(); - } - - const ResId aPopupResId (GetContextMenuResId()); - mrBase.GetViewFrame()->GetDispatcher()->ExecutePopup( - aPopupResId, - mpPageSet.get(), - &aPosition); - } - - return 0; -} - - - - -IMPL_LINK(MasterPagesSelector, ContainerChangeListener, MasterPageContainerChangeEvent*, pEvent) -{ - if (pEvent) - NotifyContainerChangeEvent(*pEvent); - return 0; -} - - - - -SdPage* MasterPagesSelector::GetSelectedMasterPage (void) -{ - const ::osl::MutexGuard aGuard (maMutex); - - SdPage* pMasterPage = NULL; - sal_uInt16 nIndex = mpPageSet->GetSelectItemId(); - UserData* pData = GetUserData(nIndex); - if (pData != NULL) - { - pMasterPage = mpContainer->GetPageObjectForToken(pData->second); - } - return pMasterPage; -} - - - - -/** Assemble a list of all slides of the document and pass it to - AssignMasterPageToPageList(). -*/ -void MasterPagesSelector::AssignMasterPageToAllSlides (SdPage* pMasterPage) -{ - if (pMasterPage == NULL) - return; - - sal_uInt16 nPageCount = mrDocument.GetSdPageCount(PK_STANDARD); - if (nPageCount == 0) - return; - - // Get a list of all pages. As a little optimization we only - // include pages that do not already have the given master page - // assigned. - String sFullLayoutName (pMasterPage->GetLayoutName()); - ::sd::slidesorter::SharedPageSelection pPageList ( - new ::sd::slidesorter::SlideSorterViewShell::PageSelection()); - for (sal_uInt16 nPageIndex=0; nPageIndex<nPageCount; nPageIndex++) - { - SdPage* pPage = mrDocument.GetSdPage (nPageIndex, PK_STANDARD); - if (pPage != NULL - && pPage->GetLayoutName().CompareTo(sFullLayoutName)!=0) - { - pPageList->push_back (pPage); - } - } - - AssignMasterPageToPageList(pMasterPage, pPageList); -} - - - - -/** Assemble a list of the currently selected slides (selected in a visible - slide sorter) and pass it to AssignMasterPageToPageList(). -*/ -void MasterPagesSelector::AssignMasterPageToSelectedSlides ( - SdPage* pMasterPage) -{ - using namespace ::sd::slidesorter; - using namespace ::sd::slidesorter::controller; - - if (pMasterPage == NULL) - return; - - // Find a visible slide sorter. - SlideSorterViewShell* pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase); - if (pSlideSorter == NULL) - return; - - // Get a list of selected pages. - SharedPageSelection pPageSelection = pSlideSorter->GetPageSelection(); - if (pPageSelection->empty()) - return; - - AssignMasterPageToPageList(pMasterPage, pPageSelection); - - // Restore the previous selection. - pSlideSorter->SetPageSelection(pPageSelection); -} - - - - -void MasterPagesSelector::AssignMasterPageToPageList ( - SdPage* pMasterPage, - const ::sd::slidesorter::SharedPageSelection& rPageList) -{ - DocumentHelper::AssignMasterPageToPageList(mrDocument, pMasterPage, rPageList); -} - - - - -void MasterPagesSelector::NotifyContainerChangeEvent (const MasterPageContainerChangeEvent& rEvent) -{ - const ::osl::MutexGuard aGuard (maMutex); - - switch (rEvent.meEventType) - { - case MasterPageContainerChangeEvent::SIZE_CHANGED: - mpPageSet->SetPreviewSize(mpContainer->GetPreviewSizePixel()); - UpdateAllPreviews(); - break; - - case MasterPageContainerChangeEvent::PREVIEW_CHANGED: - { - int nIndex (GetIndexForToken(rEvent.maChildToken)); - if (nIndex >= 0) - { - mpPageSet->SetItemImage ( - (sal_uInt16)nIndex, - mpContainer->GetPreviewForToken(rEvent.maChildToken)); - mpPageSet->Invalidate(mpPageSet->GetItemRect((sal_uInt16)nIndex)); - } - } - break; - - case MasterPageContainerChangeEvent::DATA_CHANGED: - { - InvalidateItem(rEvent.maChildToken); - Fill(); - } - break; - - default: - break; - } -} - - - - -MasterPagesSelector::UserData* MasterPagesSelector::CreateUserData ( - int nIndex, - MasterPageContainer::Token aToken) const -{ - return new UserData(nIndex,aToken); -} - - - - -MasterPagesSelector::UserData* MasterPagesSelector::GetUserData (int nIndex) const -{ - const ::osl::MutexGuard aGuard (maMutex); - - if (nIndex>0 && static_cast<unsigned int>(nIndex)<=mpPageSet->GetItemCount()) - return reinterpret_cast<UserData*>(mpPageSet->GetItemData((sal_uInt16)nIndex)); - else - return NULL; -} - - - - -void MasterPagesSelector::SetUserData (int nIndex, UserData* pData) -{ - const ::osl::MutexGuard aGuard (maMutex); - - if (nIndex>0 && static_cast<unsigned int>(nIndex)<=mpPageSet->GetItemCount()) - { - UserData* pOldData = GetUserData(nIndex); - if (pOldData!=NULL && pOldData!=pData) - delete pOldData; - mpPageSet->SetItemData((sal_uInt16)nIndex, pData); - } -} - - - - -bool MasterPagesSelector::IsResizable (void) -{ - return false; -} - - - - -::Window* MasterPagesSelector::GetWindow (void) -{ - return mpPageSet.get(); -} - - - - -sal_Int32 MasterPagesSelector::GetMinimumWidth (void) -{ - return mpContainer->GetPreviewSizePixel().Width() + 2*3; -} - - - - -void MasterPagesSelector::UpdateSelection (void) -{ -} - - - - -void MasterPagesSelector::Execute (SfxRequest& rRequest) -{ - switch (rRequest.GetSlot()) - { - case SID_TP_APPLY_TO_ALL_SLIDES: - mrBase.SetBusyState (true); - AssignMasterPageToAllSlides (GetSelectedMasterPage()); - mrBase.SetBusyState (false); - break; - - case SID_TP_APPLY_TO_SELECTED_SLIDES: - mrBase.SetBusyState (true); - AssignMasterPageToSelectedSlides (GetSelectedMasterPage()); - mrBase.SetBusyState (false); - break; - - case SID_TP_USE_FOR_NEW_PRESENTATIONS: - DBG_ASSERT (false, - "Using slides as default for new presentations" - " is not yet implemented"); - break; - - case SID_TP_SHOW_SMALL_PREVIEW: - case SID_TP_SHOW_LARGE_PREVIEW: - { - mrBase.SetBusyState (true); - mpContainer->SetPreviewSize( - rRequest.GetSlot()==SID_TP_SHOW_SMALL_PREVIEW - ? MasterPageContainer::SMALL - : MasterPageContainer::LARGE); - mrBase.SetBusyState (false); - break; - } - - case SID_TP_EDIT_MASTER: - { - using namespace ::com::sun::star; - uno::Reference<drawing::XDrawPage> xSelectedMaster ( - GetSelectedMasterPage()->getUnoPage(), uno::UNO_QUERY); - SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); - if (pViewFrame != NULL && xSelectedMaster.is()) - { - SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); - if (pDispatcher != NULL) - { - sal_uInt16 nIndex = mpPageSet->GetSelectItemId(); - pDispatcher->Execute(SID_MASTERPAGE, SFX_CALLMODE_SYNCHRON); - mpPageSet->SelectItem (nIndex); - mrBase.GetDrawController().setCurrentPage(xSelectedMaster); - } - } - break; - } - - case SID_CUT: - case SID_COPY: - case SID_PASTE: - // Cut, copy, and paste are not supported and thus are ignored. - break; - } -} - - - - -void MasterPagesSelector::GetState (SfxItemSet& rItemSet) -{ - if (mpContainer->GetPreviewSize() == MasterPageContainer::SMALL) - rItemSet.DisableItem (SID_TP_SHOW_SMALL_PREVIEW); - else - rItemSet.DisableItem (SID_TP_SHOW_LARGE_PREVIEW); - - // Cut and paste is not supported so do not show the menu entries. - rItemSet.DisableItem (SID_CUT); - rItemSet.DisableItem (SID_COPY); - rItemSet.DisableItem (SID_PASTE); -} - - - - -void MasterPagesSelector::SetItem ( - sal_uInt16 nIndex, - MasterPageContainer::Token aToken) -{ - const ::osl::MutexGuard aGuard (maMutex); - - RemoveTokenToIndexEntry(nIndex,aToken); - - if (nIndex > 0) - { - if (aToken != MasterPageContainer::NIL_TOKEN) - { - Image aPreview (mpContainer->GetPreviewForToken(aToken)); - MasterPageContainer::PreviewState eState (mpContainer->GetPreviewState(aToken)); - - if (aPreview.GetSizePixel().Width()>0) - { - if (mpPageSet->GetItemPos(nIndex) != VALUESET_ITEM_NOTFOUND) - { - mpPageSet->SetItemImage(nIndex,aPreview); - mpPageSet->SetItemText(nIndex, mpContainer->GetPageNameForToken(aToken)); - } - else - { - mpPageSet->InsertItem ( - nIndex, - aPreview, - mpContainer->GetPageNameForToken(aToken), - nIndex); - } - SetUserData(nIndex, CreateUserData(nIndex,aToken)); - - AddTokenToIndexEntry(nIndex,aToken); - } - - if (eState == MasterPageContainer::PS_CREATABLE) - mpContainer->RequestPreview(aToken); - } - else - { - mpPageSet->RemoveItem(nIndex); - } - } - -} - - - - -void MasterPagesSelector::AddTokenToIndexEntry ( - sal_uInt16 nIndex, - MasterPageContainer::Token aToken) -{ - const ::osl::MutexGuard aGuard (maMutex); - - maTokenToValueSetIndex[aToken] = nIndex; -} - - - - -void MasterPagesSelector::RemoveTokenToIndexEntry ( - sal_uInt16 nIndex, - MasterPageContainer::Token aNewToken) -{ - const ::osl::MutexGuard aGuard (maMutex); - - UserData* pData = GetUserData(nIndex); - if (pData != NULL) - { - // Get the token that the index pointed to previously. - MasterPageContainer::Token aOldToken (pData->second); - - if (aNewToken != aOldToken - && nIndex == GetIndexForToken(aOldToken)) - { - maTokenToValueSetIndex[aOldToken] = 0; - } - } -} - - - - -void MasterPagesSelector::InvalidatePreview (const SdPage* pPage) -{ - const ::osl::MutexGuard aGuard (maMutex); - - for (sal_uInt16 nIndex=1; nIndex<=mpPageSet->GetItemCount(); nIndex++) - { - UserData* pData = GetUserData(nIndex); - if (pData != NULL) - { - MasterPageContainer::Token aToken (pData->second); - if (pPage == mpContainer->GetPageObjectForToken(aToken,false)) - { - mpContainer->InvalidatePreview(aToken); - mpContainer->RequestPreview(aToken); - break; - } - } - } -} - -void MasterPagesSelector::UpdateAllPreviews (void) -{ - const ::osl::MutexGuard aGuard (maMutex); - - for (sal_uInt16 nIndex=1; nIndex<=mpPageSet->GetItemCount(); nIndex++) - { - UserData* pData = GetUserData(nIndex); - if (pData != NULL) - { - MasterPageContainer::Token aToken (pData->second); - mpPageSet->SetItemImage( - nIndex, - mpContainer->GetPreviewForToken(aToken)); - if (mpContainer->GetPreviewState(aToken) == MasterPageContainer::PS_CREATABLE) - mpContainer->RequestPreview(aToken); - } - } - mpPageSet->Rearrange(true); -} - - - - -void MasterPagesSelector::ClearPageSet (void) -{ - const ::osl::MutexGuard aGuard (maMutex); - - for (sal_uInt16 nIndex=1; nIndex<=mpPageSet->GetItemCount(); nIndex++) - { - UserData* pData = GetUserData(nIndex); - if (pData != NULL) - delete pData; - } - mpPageSet->Clear(); -} - - - - -void MasterPagesSelector::SetHelpId( const rtl::OString& aId ) -{ - const ::osl::MutexGuard aGuard (maMutex); - - mpPageSet->SetHelpId( aId ); -} - - - - -sal_Int32 MasterPagesSelector::GetIndexForToken (MasterPageContainer::Token aToken) const -{ - const ::osl::MutexGuard aGuard (maMutex); - - TokenToValueSetIndex::const_iterator iIndex (maTokenToValueSetIndex.find(aToken)); - if (iIndex != maTokenToValueSetIndex.end()) - return iIndex->second; - else - return -1; -} - - - - -void MasterPagesSelector::Clear (void) -{ - const ::osl::MutexGuard aGuard (maMutex); - - ClearPageSet(); -} - - - - -void MasterPagesSelector::InvalidateItem (MasterPageContainer::Token aToken) -{ - const ::osl::MutexGuard aGuard (maMutex); - - ItemList::iterator iItem; - for (iItem=maCurrentItemList.begin(); iItem!=maCurrentItemList.end(); ++iItem) - { - if (*iItem == aToken) - { - *iItem = MasterPageContainer::NIL_TOKEN; - break; - } - } -} - - - - -void MasterPagesSelector::UpdateItemList (::std::auto_ptr<ItemList> pNewItemList) -{ - const ::osl::MutexGuard aGuard (maMutex); - - ItemList::const_iterator iNewItem (pNewItemList->begin()); - ItemList::const_iterator iCurrentItem (maCurrentItemList.begin()); - ItemList::const_iterator iNewEnd (pNewItemList->end()); - ItemList::const_iterator iCurrentEnd (maCurrentItemList.end()); - sal_uInt16 nIndex (1); - - // Update existing items. - for ( ; iNewItem!=iNewEnd && iCurrentItem!=iCurrentEnd; ++iNewItem, ++iCurrentItem,++nIndex) - { - if (*iNewItem != *iCurrentItem) - { - SetItem(nIndex,*iNewItem); - } - } - - // Append new items. - for ( ; iNewItem!=iNewEnd; ++iNewItem,++nIndex) - { - SetItem(nIndex,*iNewItem); - } - - // Remove trailing items. - for ( ; iCurrentItem!=iCurrentEnd; ++iCurrentItem,++nIndex) - { - SetItem(nIndex,MasterPageContainer::NIL_TOKEN); - } - - maCurrentItemList.swap(*pNewItemList); - - mpPageSet->Rearrange(); - if (GetParentNode() != NULL) - GetParentNode()->RequestResize(); -} - - - - - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/MasterPagesSelector.hxx b/sd/source/ui/toolpanel/controls/MasterPagesSelector.hxx deleted file mode 100644 index 52bc25a7c..000000000 --- a/sd/source/ui/toolpanel/controls/MasterPagesSelector.hxx +++ /dev/null @@ -1,239 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TASKPANE_CONTROLS_MASTER_PAGES_SELECTOR_HXX -#define SD_TASKPANE_CONTROLS_MASTER_PAGES_SELECTOR_HXX - -#include "taskpane/TaskPaneTreeNode.hxx" -#include "MasterPageContainer.hxx" -#include "SlideSorterViewShell.hxx" - -#include "pres.hxx" -#include <sfx2/shell.hxx> -#include <vcl/image.hxx> -#include "glob.hxx" -#include <osl/mutex.hxx> - -#include <queue> - -class MouseEvent; -class SdDrawDocument; -class SdPage; -class SfxModule; - -namespace sd { -class DrawViewShell; -class TemplateEntry; -class TemplateDir; -class ViewShellBase; -} - -namespace sd { namespace toolpanel { namespace controls { - -class PreviewValueSet; - -/** Base class of a menu that lets the user select from a list of - templates or designs that are loaded from files. -*/ -class MasterPagesSelector - : public TreeNode, - public SfxShell -{ -public: - TYPEINFO(); - SFX_DECL_INTERFACE(SD_IF_SDMASTERPAGESSELECTOR) - - MasterPagesSelector ( - TreeNode* pParent, - SdDrawDocument& rDocument, - ViewShellBase& rBase, - const ::boost::shared_ptr<MasterPageContainer>& rpContainer); - virtual ~MasterPagesSelector (void); - - virtual void LateInit (void); - - /** Return the height that this control needs to show all of its lines. - */ - long GetRequiredHeight (int nWidth) const; - - /** The given master page, either the master page of a slide or a notes - page, is cloned and inserted into mrDocument. The necessary styles - are copied as well. - */ - static SdPage* AddMasterPage ( - SdDrawDocument* pTargetDocument, - SdPage* pMasterPage, - sal_uInt16 nInsertionIndex); - - virtual Size GetPreferredSize (void); - virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight); - virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); - virtual bool IsResizable (void); - virtual ::Window* GetWindow (void); - virtual sal_Int32 GetMinimumWidth (void); - - virtual void Execute (SfxRequest& rRequest); - virtual void GetState (SfxItemSet& rItemSet); - - /** Update the selection of previews according to whatever - influences them appart from mouse and keyboard. If, for - example, the current page of the main pane changes, then call - this method at the CurrentMasterPagesSelector to select the - previews of the master pages that are assigned to the new - current page. - - The default implementation of this method ignores the call. This is - used by e.g. the RecentMasterPagesSelector because it does not show - the currently used master pages by default and thus is not - influenced by its changes. - */ - virtual void UpdateSelection (void); - - void FillPageSet (void); - - /** Make the selector empty. This method clear the value set from any - entries. Overload this method to add functionality, especially to - destroy objects set as data items at the value set. - */ - void ClearPageSet (void); - - using SfxShell::SetHelpId; - void SetHelpId( const rtl::OString& aId ); - - /** Mark the preview that belongs to the given index as not up-to-date - anymore with respect to page content or preview size. - The implementation of this method will either sunchronously or - asynchronously call UpdatePreview(). - @param nIndex - Index into the value set control that is used for displaying the - previews. - */ - void InvalidatePreview (const SdPage* pPage); - - void UpdateAllPreviews (void); - -protected: - mutable ::osl::Mutex maMutex; - ::boost::shared_ptr<MasterPageContainer> mpContainer; - - SdDrawDocument& mrDocument; - ::std::auto_ptr<PreviewValueSet> mpPageSet; - bool mbSmallPreviewSize; - ViewShellBase& mrBase; - /** Slot that is executed as default action when the left mouse button is - clicked over a master page. - */ - sal_uInt16 mnDefaultClickAction; - /** Pages with pointers in this queue have their previews updated - eventually. Filled by InvalidatePreview() and operated upon by - UpdatePreviews(). - */ - ::std::queue<sal_uInt16> maPreviewUpdateQueue; - - virtual SdPage* GetSelectedMasterPage (void); - - /** Assign the given master page to all slides of the document. - @param pMasterPage - The master page to assign to all slides. - */ - void AssignMasterPageToAllSlides (SdPage* pMasterPage); - - /** Assign the given master page to all slides that are selected in a - slide sorter that is displayed in the lef or center pane. When both - panes display a slide sorter then the one in the center pane is - used. - */ - void AssignMasterPageToSelectedSlides (SdPage* pMasterPage); - - virtual void AssignMasterPageToPageList ( - SdPage* pMasterPage, - const ::sd::slidesorter::SharedPageSelection& rPageList); - - virtual void NotifyContainerChangeEvent (const MasterPageContainerChangeEvent& rEvent); - - typedef ::std::pair<int, MasterPageContainer::Token> UserData; - UserData* CreateUserData (int nIndex, MasterPageContainer::Token aToken) const; - UserData* GetUserData (int nIndex) const; - void SetUserData (int nIndex, UserData* pData); - - virtual sal_Int32 GetIndexForToken (MasterPageContainer::Token aToken) const; - typedef ::std::vector<MasterPageContainer::Token> ItemList; - void UpdateItemList (::std::auto_ptr<ItemList> pList); - void Clear (void); - /** Invalidate the specified item so that on the next Fill() this item - is updated. - */ - void InvalidateItem (MasterPageContainer::Token aToken); - - // For every item in the ValueSet we store its associated token. This - // allows a faster access and easier change tracking. - ItemList maCurrentItemList; - typedef ::std::map<MasterPageContainer::Token,sal_Int32> TokenToValueSetIndex; - TokenToValueSetIndex maTokenToValueSetIndex; - - ItemList maLockedMasterPages; - /** Lock master pages in the given list and release locks that where - previously aquired. - */ - void UpdateLocks (const ItemList& rItemList); - - void Fill (void); - virtual void Fill (ItemList& rItemList) = 0; - - /** Give derived classes the oportunity to provide their own context - menu. If they do then they probably have to provide their own - Execute() and GetState() methods as well. - */ - virtual ResId GetContextMenuResId (void) const; - -private: - /** The offset between ValueSet index and MasterPageContainer::Token - last seen. This value is used heuristically to speed up the lookup - of an index for a token. - */ - DECL_LINK(ClickHandler, PreviewValueSet*); - DECL_LINK(RightClickHandler, MouseEvent*); - DECL_LINK(ContextMenuCallback, CommandEvent*); - DECL_LINK(ContainerChangeListener, MasterPageContainerChangeEvent*); - - void SetItem ( - sal_uInt16 nIndex, - MasterPageContainer::Token aToken); - void AddTokenToIndexEntry ( - sal_uInt16 nIndex, - MasterPageContainer::Token aToken); - void RemoveTokenToIndexEntry ( - sal_uInt16 nIndex, - MasterPageContainer::Token aToken); -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/PreviewValueSet.cxx b/sd/source/ui/toolpanel/controls/PreviewValueSet.cxx deleted file mode 100644 index b3870512d..000000000 --- a/sd/source/ui/toolpanel/controls/PreviewValueSet.cxx +++ /dev/null @@ -1,243 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "PreviewValueSet.hxx" -#include <vcl/image.hxx> -#include "taskpane/TaskPaneTreeNode.hxx" - -namespace sd { namespace toolpanel { namespace controls { - - -PreviewValueSet::PreviewValueSet (TreeNode* pParent) - : ValueSet (pParent->GetWindow(), WB_TABSTOP), - mpParent(pParent), - maPreviewSize(10,10), - mnBorderWidth(3), - mnBorderHeight(3), - mnMaxColumnCount(-1) -{ - SetStyle ( - GetStyle() - & ~(WB_ITEMBORDER)// | WB_MENUSTYLEVALUESET) - // | WB_FLATVALUESET); - ); - - SetColCount(2); - // SetLineCount(1); - SetExtraSpacing (2); -} - - - - -PreviewValueSet::~PreviewValueSet (void) -{ -} - - - - -void PreviewValueSet::SetPreviewSize (const Size& rSize) -{ - maPreviewSize = rSize; -} - - - - -void PreviewValueSet::SetRightMouseClickHandler (const Link& rLink) -{ - maRightMouseClickHandler = rLink; -} - - - - -void PreviewValueSet::MouseButtonDown (const MouseEvent& rEvent) -{ - if (rEvent.IsRight()) - maRightMouseClickHandler.Call(reinterpret_cast<void*>( - &const_cast<MouseEvent&>(rEvent))); - else - ValueSet::MouseButtonDown (rEvent); - -} - - - - -void PreviewValueSet::Paint (const Rectangle& rRect) -{ - SetBackground (GetSettings().GetStyleSettings().GetWindowColor()); - - ValueSet::Paint (rRect); - - SetBackground (Wallpaper()); -} - - - - -void PreviewValueSet::Resize (void) -{ - ValueSet::Resize (); - - Size aWindowSize (GetOutputSizePixel()); - if (aWindowSize.Width()>0 && aWindowSize.Height()>0) - { - Rearrange(); - } -} - - - - -void PreviewValueSet::Command (const CommandEvent& rEvent) -{ - switch (rEvent.GetCommand()) - { - case COMMAND_CONTEXTMENU: - { - CommandEvent aNonConstEventCopy (rEvent); - maContextMenuCallback.Call(&aNonConstEventCopy); - } - break; - - default: - ValueSet::Command(rEvent); - break; - } -} - - - - -void PreviewValueSet::Rearrange (bool bForceRequestResize) -{ - sal_uInt16 nOldColumnCount (GetColCount()); - sal_uInt16 nOldRowCount (GetLineCount()); - - sal_uInt16 nNewColumnCount (CalculateColumnCount ( - GetOutputSizePixel().Width())); - sal_uInt16 nNewRowCount (CalculateRowCount (nNewColumnCount)); - - SetColCount(nNewColumnCount); - SetLineCount(nNewRowCount); - - if (bForceRequestResize - || nOldColumnCount != nNewColumnCount - || nOldRowCount != nNewRowCount) - mpParent->RequestResize(); -} - - - - -void PreviewValueSet::SetContextMenuCallback (const Link& rLink) -{ - maContextMenuCallback = rLink; -} - - - - -sal_uInt16 PreviewValueSet::CalculateColumnCount (int nWidth) const -{ - int nColumnCount = 0; - if (nWidth > 0) - { - nColumnCount = nWidth / (maPreviewSize.Width() + 2*mnBorderWidth); - if (nColumnCount < 1) - nColumnCount = 1; - else if (mnMaxColumnCount>0 && nColumnCount>mnMaxColumnCount) - nColumnCount = mnMaxColumnCount; - } - return (sal_uInt16)nColumnCount; -} - - - - -sal_uInt16 PreviewValueSet::CalculateRowCount (sal_uInt16 nColumnCount) const -{ - int nRowCount = 0; - int nItemCount = GetItemCount(); - if (nColumnCount > 0) - { - nRowCount = (nItemCount+nColumnCount-1) / nColumnCount; - if (nRowCount < 1) - nRowCount = 1; - } - - return (sal_uInt16)nRowCount; -} - - - - -sal_Int32 PreviewValueSet::GetPreferredWidth (sal_Int32 nHeight) -{ - int nPreferredWidth (maPreviewSize.Width() + 2*mnBorderWidth); - - // Get height of each row. - int nItemHeight (maPreviewSize.Height() + 2*mnBorderHeight); - - // Calculate the row- and column count and from the later the preferred - // width. - int nRowCount = nHeight / nItemHeight; - if (nRowCount > 0) - { - int nColumnCount = (GetItemCount()+nRowCount-1) / nRowCount; - if (nColumnCount > 0) - nPreferredWidth = (maPreviewSize.Width() + 2*mnBorderWidth) - * nColumnCount; - } - - return nPreferredWidth; -} - - - - -sal_Int32 PreviewValueSet::GetPreferredHeight (sal_Int32 nWidth) -{ - int nRowCount (CalculateRowCount(CalculateColumnCount(nWidth))); - int nItemHeight (maPreviewSize.Height()); - - return nRowCount * (nItemHeight + 2*mnBorderHeight); -} - - - - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/PreviewValueSet.hxx b/sd/source/ui/toolpanel/controls/PreviewValueSet.hxx deleted file mode 100644 index 986a061a3..000000000 --- a/sd/source/ui/toolpanel/controls/PreviewValueSet.hxx +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_PREVIEW_VALUE_SET_HXX -#define SD_TOOLPANEL_PREVIEW_VALUE_SET_HXX - -#include <svtools/valueset.hxx> - - -namespace sd { namespace toolpanel { -class TreeNode; -} } - -namespace sd { namespace toolpanel { namespace controls { - - -/** Adapt the svtools valueset to the needs of the master page controlls. -*/ -class PreviewValueSet - : public ValueSet -{ -public: - PreviewValueSet (TreeNode* pParent); - ~PreviewValueSet (void); - - void SetRightMouseClickHandler (const Link& rLink); - virtual void Paint (const Rectangle& rRect); - virtual void Resize (void); - - /** When a request for the display of a context menu is made to this - method then that request is forwarded via the ContextMenuCallback. - This way the owning class can handle the context menu without having - to be derived from this class. - Use SetContextMenuCallback to set or rest the handler. - */ - virtual void Command (const CommandEvent& rEvent); - - void SetPreviewSize (const Size& rSize); - - sal_Int32 GetPreferredWidth (sal_Int32 nHeight); - sal_Int32 GetPreferredHeight (sal_Int32 nWidth); - - /** Set the number of rows and columns according to the current number - of items. Call this method when new items have been inserted. - */ - void Rearrange (bool bForceRequestResize = false); - - /** Set the callback function to which requests for context menus are - forewarded. Call with an empty Link to reset the callback - function. - */ - void SetContextMenuCallback (const Link& rLink); - -protected: - virtual void MouseButtonDown (const MouseEvent& rEvent); - -private: - Link maRightMouseClickHandler; - Link maContextMenuCallback; - TreeNode* mpParent; - Size maPreviewSize; - const int mnBorderWidth; - const int mnBorderHeight; - const int mnMaxColumnCount; - - sal_uInt16 CalculateColumnCount (int nWidth) const; - sal_uInt16 CalculateRowCount (sal_uInt16 nColumnCount) const; -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/RecentMasterPagesSelector.cxx b/sd/source/ui/toolpanel/controls/RecentMasterPagesSelector.cxx deleted file mode 100644 index 450aa7423..000000000 --- a/sd/source/ui/toolpanel/controls/RecentMasterPagesSelector.cxx +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "RecentMasterPagesSelector.hxx" -#include "PreviewValueSet.hxx" - -#include "RecentlyUsedMasterPages.hxx" -#include "MasterPageContainerProviders.hxx" -#include "MasterPageObserver.hxx" -#include "sdpage.hxx" -#include "drawdoc.hxx" -#include "app.hrc" -#include <vcl/bitmap.hxx> -#include <tools/color.hxx> - -namespace sd { namespace toolpanel { namespace controls { - - -RecentMasterPagesSelector::RecentMasterPagesSelector ( - TreeNode* pParent, - SdDrawDocument& rDocument, - ViewShellBase& rBase, - const ::boost::shared_ptr<MasterPageContainer>& rpContainer) - : MasterPagesSelector (pParent, rDocument, rBase, rpContainer) -{ - SetName (String(RTL_CONSTASCII_USTRINGPARAM("RecentMasterPagesSelector"))); -} - - - - -RecentMasterPagesSelector::~RecentMasterPagesSelector (void) -{ - RecentlyUsedMasterPages::Instance().RemoveEventListener ( - LINK(this,RecentMasterPagesSelector,MasterPageListListener)); -} - - - - -void RecentMasterPagesSelector::LateInit (void) -{ - MasterPagesSelector::LateInit(); - - MasterPagesSelector::Fill(); - RecentlyUsedMasterPages::Instance().AddEventListener ( - LINK(this,RecentMasterPagesSelector,MasterPageListListener)); -} - - - - -IMPL_LINK(RecentMasterPagesSelector,MasterPageListListener, void*, EMPTYARG) -{ - MasterPagesSelector::Fill(); - return 0; -} - - - - -void RecentMasterPagesSelector::Fill (ItemList& rItemList) -{ - // Create a set of names of the master pages used by the document. - MasterPageObserver::MasterPageNameSet aCurrentNames; - sal_uInt16 nMasterPageCount = mrDocument.GetMasterSdPageCount(PK_STANDARD); - sal_uInt16 nIndex; - for (nIndex=0; nIndex<nMasterPageCount; nIndex++) - { - SdPage* pMasterPage = mrDocument.GetMasterSdPage (nIndex, PK_STANDARD); - if (pMasterPage != NULL) - aCurrentNames.insert (pMasterPage->GetName()); - } - MasterPageObserver::MasterPageNameSet::iterator aI; - - // Insert the recently used master pages that are currently not used. - RecentlyUsedMasterPages& rInstance (RecentlyUsedMasterPages::Instance()); - int nPageCount = rInstance.GetMasterPageCount(); - for (nIndex=0; nIndex<nPageCount; nIndex++) - { - // Add an entry when a) the page is already known to the - // MasterPageContainer, b) the style name is empty, i.e. it has not yet - // been loaded (and thus can not be in use) or otherwise c) the - // style name is not currently in use. - MasterPageContainer::Token aToken (rInstance.GetTokenForIndex(nIndex)); - if (aToken != MasterPageContainer::NIL_TOKEN) - { - String sStyleName (mpContainer->GetStyleNameForToken(aToken)); - if (sStyleName.Len()==0 - || aCurrentNames.find(sStyleName) == aCurrentNames.end()) - { - rItemList.push_back(aToken); - } - } - } -} - - - - -void RecentMasterPagesSelector::AssignMasterPageToPageList ( - SdPage* pMasterPage, - const ::boost::shared_ptr<std::vector<SdPage*> >& rpPageList) -{ - sal_uInt16 nSelectedItemId = mpPageSet->GetSelectItemId(); - - MasterPagesSelector::AssignMasterPageToPageList(pMasterPage, rpPageList); - - // Restore the selection. - if (mpPageSet->GetItemCount() > 0) - { - if (mpPageSet->GetItemCount() >= nSelectedItemId) - mpPageSet->SelectItem(nSelectedItemId); - else - mpPageSet->SelectItem(mpPageSet->GetItemCount()); - } -} - - - - -void RecentMasterPagesSelector::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::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/RecentMasterPagesSelector.hxx b/sd/source/ui/toolpanel/controls/RecentMasterPagesSelector.hxx deleted file mode 100644 index 108aa24b2..000000000 --- a/sd/source/ui/toolpanel/controls/RecentMasterPagesSelector.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_RECENT_MASTER_PAGES_SELECTOR_HXX -#define SD_TOOLPANEL_CONTROLS_RECENT_MASTER_PAGES_SELECTOR_HXX - -#include "MasterPagesSelector.hxx" - -namespace sd { namespace toolpanel { namespace controls { - - -/** Show the recently used master pages (that are not currently used). -*/ -class RecentMasterPagesSelector - : public MasterPagesSelector -{ -public: - RecentMasterPagesSelector ( - TreeNode* pParent, - SdDrawDocument& rDocument, - ViewShellBase& rBase, - const ::boost::shared_ptr<MasterPageContainer>& rpContainer); - virtual ~RecentMasterPagesSelector (void); - - virtual void LateInit (void); - - virtual void GetState (SfxItemSet& rItemSet); - -protected: - DECL_LINK(MasterPageListListener, void*); - virtual void Fill (ItemList& rItemList); - - using sd::toolpanel::controls::MasterPagesSelector::Fill; - - /** Forward this call to the base class but save and restore the - currently selected item. - Assign the given master page to the list of pages. - @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. - */ - virtual void AssignMasterPageToPageList ( - SdPage* pMasterPage, - const ::boost::shared_ptr<std::vector<SdPage*> >& rpPageList); -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.cxx b/sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.cxx deleted file mode 100644 index 558cfd69f..000000000 --- a/sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.cxx +++ /dev/null @@ -1,498 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "RecentlyUsedMasterPages.hxx" -#include "MasterPageObserver.hxx" -#include "MasterPagesSelector.hxx" -#include "MasterPageDescriptor.hxx" -#include "tools/ConfigurationAccess.hxx" -#include "drawdoc.hxx" -#include "sdpage.hxx" - -#include <algorithm> -#include <vector> - -#include <comphelper/processfactory.hxx> -#include "unomodel.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/XNameAccess.hpp> -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/PropertyState.hpp> -#include <tools/urlobj.hxx> -#include <unotools/confignode.hxx> -#include <osl/doublecheckedlocking.h> -#include <osl/getglobalmutex.hxx> - -using namespace ::std; -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; - - -namespace { - -static const OUString& GetPathToImpressConfigurationRoot (void) -{ - static const OUString sPathToImpressConfigurationRoot ( - RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Impress/")); - return sPathToImpressConfigurationRoot; -} -static const OUString& GetPathToSetNode (void) -{ - static const OUString sPathToSetNode( - RTL_CONSTASCII_USTRINGPARAM( - "MultiPaneGUI/ToolPanel/RecentlyUsedMasterPages")); - return sPathToSetNode; -} - - -class Descriptor -{ -public: - ::rtl::OUString msURL; - ::rtl::OUString msName; - ::sd::toolpanel::controls::MasterPageContainer::Token maToken; - Descriptor (const ::rtl::OUString& rsURL, const ::rtl::OUString& rsName) - : msURL(rsURL), - msName(rsName), - maToken(::sd::toolpanel::controls::MasterPageContainer::NIL_TOKEN) - {} - Descriptor (::sd::toolpanel::controls::MasterPageContainer::Token aToken, - const ::rtl::OUString& rsURL, const ::rtl::OUString& rsName) - : msURL(rsURL), - msName(rsName), - maToken(aToken) - {} - class TokenComparator - { - public: - TokenComparator(::sd::toolpanel::controls::MasterPageContainer::Token aToken) - : maToken(aToken) {} - bool operator () (const Descriptor& rDescriptor) const - { return maToken==rDescriptor.maToken; } - private: - ::sd::toolpanel::controls::MasterPageContainer::Token maToken; - }; -}; - -} // end of anonymous namespace - - - - -namespace sd { namespace toolpanel { namespace controls { - -class RecentlyUsedMasterPages::MasterPageList : public ::std::vector<Descriptor> -{ -public: - MasterPageList (void) {} -}; - - -RecentlyUsedMasterPages* RecentlyUsedMasterPages::mpInstance = NULL; - - -RecentlyUsedMasterPages& RecentlyUsedMasterPages::Instance (void) -{ - if (mpInstance == NULL) - { - ::osl::GetGlobalMutex aMutexFunctor; - ::osl::MutexGuard aGuard (aMutexFunctor()); - if (mpInstance == NULL) - { - RecentlyUsedMasterPages* pInstance = new RecentlyUsedMasterPages(); - pInstance->LateInit(); - SdGlobalResourceContainer::Instance().AddResource ( - ::std::auto_ptr<SdGlobalResource>(pInstance)); - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - mpInstance = pInstance; - } - } - else { - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - } - - return *mpInstance; -} - - - - -RecentlyUsedMasterPages::RecentlyUsedMasterPages (void) - : maListeners(), - mpMasterPages(new MasterPageList()), - mnMaxListSize(8), - mpContainer(new MasterPageContainer()) -{ -} - - - - -RecentlyUsedMasterPages::~RecentlyUsedMasterPages (void) -{ - Link aLink (LINK(this,RecentlyUsedMasterPages,MasterPageContainerChangeListener)); - mpContainer->RemoveChangeListener(aLink); - - MasterPageObserver::Instance().RemoveEventListener( - LINK(this,RecentlyUsedMasterPages,MasterPageChangeListener)); -} - - - - -void RecentlyUsedMasterPages::LateInit (void) -{ - Link aLink (LINK(this,RecentlyUsedMasterPages,MasterPageContainerChangeListener)); - mpContainer->AddChangeListener(aLink); - - LoadPersistentValues (); - MasterPageObserver::Instance().AddEventListener( - LINK(this,RecentlyUsedMasterPages,MasterPageChangeListener)); -} - - - - -void RecentlyUsedMasterPages::LoadPersistentValues (void) -{ - try - { - tools::ConfigurationAccess aConfiguration ( - GetPathToImpressConfigurationRoot(), - tools::ConfigurationAccess::READ_ONLY); - Reference<container::XNameAccess> xSet ( - aConfiguration.GetConfigurationNode(GetPathToSetNode()), - UNO_QUERY); - if ( ! xSet.is()) - return; - - const String sURLMemberName (RTL_CONSTASCII_USTRINGPARAM("URL")); - const String sNameMemberName (RTL_CONSTASCII_USTRINGPARAM("Name")); - OUString sURL; - OUString sName; - - // Read the names and URLs of the master pages. - Sequence<OUString> aKeys (xSet->getElementNames()); - mpMasterPages->clear(); - mpMasterPages->reserve(aKeys.getLength()); - for (int i=0; i<aKeys.getLength(); i++) - { - Reference<container::XNameAccess> xSetItem ( - xSet->getByName(aKeys[i]), UNO_QUERY); - if (xSetItem.is()) - { - Any aURL (xSetItem->getByName(sURLMemberName)); - Any aName (xSetItem->getByName(sNameMemberName)); - aURL >>= sURL; - aName >>= sName; - SharedMasterPageDescriptor pDescriptor (new MasterPageDescriptor( - MasterPageContainer::TEMPLATE, - -1, - sURL, - String(), - sName, - false, - ::boost::shared_ptr<PageObjectProvider>( - new TemplatePageObjectProvider(sURL)), - ::boost::shared_ptr<PreviewProvider>( - new TemplatePreviewProvider(sURL)))); - // For user supplied templates we use a different - // preview provider: The preview in the document shows - // not only shapes on the master page but also shapes on - // the foreground. This is misleading and therefore - // these previews are discarded and created directly - // from the page objects. - if (pDescriptor->GetURLClassification() == MasterPageDescriptor::URLCLASS_USER) - pDescriptor->mpPreviewProvider = ::boost::shared_ptr<PreviewProvider>( - new PagePreviewProvider()); - MasterPageContainer::Token aToken (mpContainer->PutMasterPage(pDescriptor)); - mpMasterPages->push_back(Descriptor(aToken,sURL,sName)); - } - } - - ResolveList(); - } - catch (Exception&) - { - // Ignore exception. - } -} - - - - -void RecentlyUsedMasterPages::SavePersistentValues (void) -{ - try - { - tools::ConfigurationAccess aConfiguration ( - GetPathToImpressConfigurationRoot(), - tools::ConfigurationAccess::READ_WRITE); - Reference<container::XNameContainer> xSet ( - aConfiguration.GetConfigurationNode(GetPathToSetNode()), - UNO_QUERY); - if ( ! xSet.is()) - return; - - // Clear the set. - Sequence<OUString> aKeys (xSet->getElementNames()); - sal_Int32 i; - for (i=0; i<aKeys.getLength(); i++) - xSet->removeByName (aKeys[i]); - - // Fill it with the URLs of this object. - const String sURLMemberName (RTL_CONSTASCII_USTRINGPARAM("URL")); - const String sNameMemberName (RTL_CONSTASCII_USTRINGPARAM("Name")); - Any aValue; - Reference<lang::XSingleServiceFactory> xChildFactory ( - xSet, UNO_QUERY); - if ( ! xChildFactory.is()) - return; - MasterPageList::const_iterator iDescriptor; - sal_Int32 nIndex(0); - for (iDescriptor=mpMasterPages->begin(); - iDescriptor!=mpMasterPages->end(); - ++iDescriptor,++nIndex) - { - // Create new child. - OUString sKey (RTL_CONSTASCII_USTRINGPARAM("index_")); - sKey += OUString::valueOf(nIndex); - Reference<container::XNameReplace> xChild( - xChildFactory->createInstance(), UNO_QUERY); - if (xChild.is()) - { - xSet->insertByName (sKey, makeAny(xChild)); - - aValue <<= OUString(iDescriptor->msURL); - xChild->replaceByName (sURLMemberName, aValue); - - aValue <<= OUString(iDescriptor->msName); - xChild->replaceByName (sNameMemberName, aValue); - } - } - - // Write the data back to disk. - aConfiguration.CommitChanges(); - } - catch (Exception&) - { - // Ignore exception. - } -} - - - - -void RecentlyUsedMasterPages::AddEventListener (const Link& rEventListener) -{ - if (::std::find ( - maListeners.begin(), - maListeners.end(), - rEventListener) == maListeners.end()) - { - maListeners.push_back (rEventListener); - } -} - - - - -void RecentlyUsedMasterPages::RemoveEventListener (const Link& rEventListener) -{ - maListeners.erase ( - ::std::find ( - maListeners.begin(), - maListeners.end(), - rEventListener)); -} - - - - -int RecentlyUsedMasterPages::GetMasterPageCount (void) const -{ - return mpMasterPages->size(); -} - - - - -MasterPageContainer::Token RecentlyUsedMasterPages::GetTokenForIndex (sal_uInt32 nIndex) const -{ - if(nIndex<mpMasterPages->size()) - return (*mpMasterPages)[nIndex].maToken; - else - return MasterPageContainer::NIL_TOKEN; -} - - - - -void RecentlyUsedMasterPages::SendEvent (void) -{ - ::std::vector<Link>::iterator aLink (maListeners.begin()); - ::std::vector<Link>::iterator aEnd (maListeners.end()); - while (aLink!=aEnd) - { - aLink->Call (NULL); - ++aLink; - } -} - - - - -IMPL_LINK(RecentlyUsedMasterPages, MasterPageChangeListener, - MasterPageObserverEvent*, pEvent) -{ - switch (pEvent->meType) - { - case MasterPageObserverEvent::ET_MASTER_PAGE_ADDED: - case MasterPageObserverEvent::ET_MASTER_PAGE_EXISTS: - AddMasterPage( - mpContainer->GetTokenForStyleName(pEvent->mrMasterPageName)); - break; - - case MasterPageObserverEvent::ET_MASTER_PAGE_REMOVED: - // Do not change the list of recently master pages (the deleted - // page was recently used) but tell the listeners. They may want - // to update their lists. - SendEvent(); - break; - } - return 0; -} - - - - -IMPL_LINK(RecentlyUsedMasterPages, MasterPageContainerChangeListener, - MasterPageContainerChangeEvent*, pEvent) -{ - if (pEvent != NULL) - switch (pEvent->meEventType) - { - case MasterPageContainerChangeEvent::CHILD_ADDED: - case MasterPageContainerChangeEvent::CHILD_REMOVED: - case MasterPageContainerChangeEvent::INDEX_CHANGED: - case MasterPageContainerChangeEvent::INDEXES_CHANGED: - ResolveList(); - break; - - default: - // Ignored. - break; - } - return 0; -} - - - - -void RecentlyUsedMasterPages::AddMasterPage ( - MasterPageContainer::Token aToken, - bool bMakePersistent) -{ - // For the page to be inserted the token has to be valid and the page - // has to have a valid URL. This excludes master pages that do not come - // from template files. - if (aToken != MasterPageContainer::NIL_TOKEN - && mpContainer->GetURLForToken(aToken).Len()>0) - { - - MasterPageList::iterator aIterator ( - ::std::find_if(mpMasterPages->begin(),mpMasterPages->end(), - Descriptor::TokenComparator(aToken))); - if (aIterator != mpMasterPages->end()) - { - // When an entry for the given token already exists then remove - // it now and insert it later at the head of the list. - mpMasterPages->erase (aIterator); - } - - mpMasterPages->insert(mpMasterPages->begin(), - Descriptor( - aToken, - mpContainer->GetURLForToken(aToken), - mpContainer->GetStyleNameForToken(aToken))); - - // Shorten list to maximal size. - while (mpMasterPages->size() > mnMaxListSize) - { - mpMasterPages->pop_back (); - } - - if (bMakePersistent) - SavePersistentValues (); - SendEvent(); - } -} - - - - -void RecentlyUsedMasterPages::ResolveList (void) -{ - bool bNotify (false); - - MasterPageList::iterator iDescriptor; - for (iDescriptor=mpMasterPages->begin(); iDescriptor!=mpMasterPages->end(); ++iDescriptor) - { - if (iDescriptor->maToken == MasterPageContainer::NIL_TOKEN) - { - MasterPageContainer::Token aToken (mpContainer->GetTokenForURL(iDescriptor->msURL)); - iDescriptor->maToken = aToken; - if (aToken != MasterPageContainer::NIL_TOKEN) - bNotify = true; - } - else - { - if ( ! mpContainer->HasToken(iDescriptor->maToken)) - { - iDescriptor->maToken = MasterPageContainer::NIL_TOKEN; - bNotify = true; - } - } - } - - if (bNotify) - SendEvent(); -} - - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.hxx b/sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.hxx deleted file mode 100644 index 1e1536259..000000000 --- a/sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.hxx +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_RECENTLY_USED_MASTER_PAGES_HXX -#define SD_TOOLPANEL_CONTROLS_RECENTLY_USED_MASTER_PAGES_HXX - -#include "tools/SdGlobalResourceContainer.hxx" -#include <osl/mutex.hxx> -#include <tools/link.hxx> -#include <vcl/image.hxx> -#include <vector> -#include <tools/string.hxx> - -#include "DrawDocShell.hxx" -#include "MasterPageContainer.hxx" -#include <com/sun/star/uno/XInterface.hpp> - -class SdPage; - -namespace sd { -class MasterPageObserverEvent; -} - - -namespace sd { namespace toolpanel { namespace controls { - -/** This singleton holds a list of the most recently used master pages. -*/ -class RecentlyUsedMasterPages - : public SdGlobalResource -{ -public: - /** Return the single instance of this class. - */ - static RecentlyUsedMasterPages& Instance (void); - - void AddEventListener (const Link& rEventListener); - void RemoveEventListener (const Link& rEventListener); - - int GetMasterPageCount (void) const; - MasterPageContainer::Token GetTokenForIndex (sal_uInt32 nIndex) const; - -private: - /** The single instance of this class. It is created on demand when - Instance() is called for the first time. - */ - static RecentlyUsedMasterPages* mpInstance; - - ::std::vector<Link> maListeners; - - class MasterPageList; - ::std::auto_ptr<MasterPageList> mpMasterPages; - unsigned long int mnMaxListSize; - ::boost::shared_ptr<MasterPageContainer> mpContainer; - - RecentlyUsedMasterPages (void); - virtual ~RecentlyUsedMasterPages (void); - - /** Call this method after a new object has been created. - */ - void LateInit (void); - - /// The copy constructor is not implemented. Do not use! - RecentlyUsedMasterPages (const RecentlyUsedMasterPages&); - - /// The assignment operator is not implemented. Do not use! - RecentlyUsedMasterPages& operator= (const RecentlyUsedMasterPages&); - - void SendEvent (void); - DECL_LINK(MasterPageChangeListener, MasterPageObserverEvent*); - DECL_LINK(MasterPageContainerChangeListener, MasterPageContainerChangeEvent*); - - /** Add a descriptor for the specified master page to the end of the - list of most recently used master pages. When the page is already a - member of that list the associated descriptor is moved to the end of - the list to make it the most recently used entry. - @param bMakePersistent - When <TRUE/> is given then the new list of recently used master - pages is written back into the configuration to make it - persistent. Giving <FALSE/> to ommit this is used while loading - the persistent list from the configuration. - */ - void AddMasterPage ( - MasterPageContainer::Token aToken, - bool bMakePersistent = true); - - /** Load the list of recently used master pages from the registry where - it was saved to make it persistent. - */ - void LoadPersistentValues (void); - - /** Save the list of recently used master pages to the registry to make - it presistent. - */ - void SavePersistentValues (void); - - void ResolveList (void); -}; - - - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/SlideTransitionPanel.cxx b/sd/source/ui/toolpanel/controls/SlideTransitionPanel.cxx deleted file mode 100644 index d0d5ef0cd..000000000 --- a/sd/source/ui/toolpanel/controls/SlideTransitionPanel.cxx +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" -#include "SlideTransitionPanel.hxx" - -#include "taskpane/TaskPaneControlFactory.hxx" -#include "taskpane/ToolPanelViewShell.hxx" - -#include "strings.hrc" -#include "sdresid.hxx" -#include <com/sun/star/frame/XModel.hpp> - -namespace sd -{ - - class ViewShellBase; - extern ::Window * createSlideTransitionPanel( ::Window* pParent, ViewShellBase& rBase ); - -namespace toolpanel { namespace controls { - - - -SlideTransitionPanel::SlideTransitionPanel(Window& i_rParentWindow, ToolPanelViewShell& i_rToolPanelShell) - :SubToolPanel( i_rParentWindow ) - ,maPreferredSize( 100, 200 ) - ,m_pPanelViewShell( &i_rToolPanelShell ) -{ - mpWrappedControl = createSlideTransitionPanel( &i_rParentWindow, i_rToolPanelShell.GetViewShellBase() ); - mpWrappedControl->Show(); -} - -SlideTransitionPanel::~SlideTransitionPanel() -{ - delete mpWrappedControl; -} - -std::auto_ptr< ControlFactory > SlideTransitionPanel::CreateControlFactory( ToolPanelViewShell& i_rToolPanelShell ) -{ - return std::auto_ptr< ControlFactory >( - new RootControlFactoryWithArg< SlideTransitionPanel, ToolPanelViewShell >( i_rToolPanelShell ) ); -} - -TaskPaneShellManager* SlideTransitionPanel::GetShellManager() -{ - if ( m_pPanelViewShell ) - return &m_pPanelViewShell->GetSubShellManager(); - return SubToolPanel::GetShellManager(); -} - -Size SlideTransitionPanel::GetPreferredSize() -{ - return maPreferredSize; -} -sal_Int32 SlideTransitionPanel::GetPreferredWidth(sal_Int32 ) -{ - return maPreferredSize.Width(); -} -sal_Int32 SlideTransitionPanel::GetPreferredHeight(sal_Int32 ) -{ - return maPreferredSize.Height(); -} -::Window* SlideTransitionPanel::GetWindow() -{ - return mpWrappedControl; -} -bool SlideTransitionPanel::IsResizable() -{ - return true; -} -bool SlideTransitionPanel::IsExpandable() const -{ - return true; -} - - - - -::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible> SlideTransitionPanel::CreateAccessibleObject ( - const ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible>& ) -{ - if (GetWindow() != NULL) - return GetWindow()->GetAccessible(); - else - return NULL; -} - - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/SlideTransitionPanel.hxx b/sd/source/ui/toolpanel/controls/SlideTransitionPanel.hxx deleted file mode 100644 index 48e29ebbd..000000000 --- a/sd/source/ui/toolpanel/controls/SlideTransitionPanel.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SD_TOOLPANEL_CONTROLS_SLIDE_TRANSITION_PANEL_HXX -#define SD_TOOLPANEL_CONTROLS_SLIDE_TRANSITION_PANEL_HXX - -#include "taskpane/SubToolPanel.hxx" - -namespace sd { -class ViewShellBase; -} - -namespace sd { namespace toolpanel { -class ControlFactory; -class TreeNode; -class ToolPanelViewShell; -} } - -namespace sd { namespace toolpanel { namespace controls { - -class SlideTransitionPanel - : public SubToolPanel -{ -public: - SlideTransitionPanel ( - Window& i_rParentWindow, - ToolPanelViewShell& i_rToolPanelShell); - virtual ~SlideTransitionPanel (void); - - static std::auto_ptr<ControlFactory> CreateControlFactory (ToolPanelViewShell& i_rToolPanelShell); - - // TreeNode overridables - virtual TaskPaneShellManager* GetShellManager(); - - // ILayoutableWindow overridables - virtual Size GetPreferredSize (void); - virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeigh); - virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); - virtual ::Window* GetWindow (void); - virtual bool IsResizable (void); - virtual bool IsExpandable (void) const; - - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible > CreateAccessibleObject ( - const ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible>& rxParent); - - using Window::GetWindow; - -private: - Size maPreferredSize; - ::Window* mpWrappedControl; - ToolPanelViewShell* m_pPanelViewShell; -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/TableDesignPanel.cxx b/sd/source/ui/toolpanel/controls/TableDesignPanel.cxx deleted file mode 100644 index 61b35ae9b..000000000 --- a/sd/source/ui/toolpanel/controls/TableDesignPanel.cxx +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "TableDesignPanel.hxx" - -#include "taskpane/TaskPaneControlFactory.hxx" -#include "taskpane/ToolPanelViewShell.hxx" - -#include "strings.hrc" -#include "sdresid.hxx" - -namespace sd -{ - - class ViewShellBase; - extern ::Window * createTableDesignPanel( ::Window* pParent, ViewShellBase& rBase ); - -namespace toolpanel { namespace controls { - - -TableDesignPanel::TableDesignPanel( ::Window& i_rParentWindow, ToolPanelViewShell& i_rPanelViewShell ) - :SubToolPanel( i_rParentWindow ) - ,m_pPanelViewShell( &i_rPanelViewShell ) -{ - mpWrappedControl = createTableDesignPanel( &i_rParentWindow, i_rPanelViewShell.GetViewShellBase() ); - mpWrappedControl->Show(); -} - -TableDesignPanel::~TableDesignPanel() -{ - delete mpWrappedControl; -} - -std::auto_ptr< ControlFactory > TableDesignPanel::CreateControlFactory( ToolPanelViewShell& i_rToolPanelShell ) -{ - return std::auto_ptr< ControlFactory >( - new RootControlFactoryWithArg< TableDesignPanel, ToolPanelViewShell >( i_rToolPanelShell ) ); -} - -TaskPaneShellManager* TableDesignPanel::GetShellManager() -{ - if ( m_pPanelViewShell ) - return &m_pPanelViewShell->GetSubShellManager(); - return SubToolPanel::GetShellManager(); -} - -Size TableDesignPanel::GetPreferredSize() -{ - return maPreferredSize; -} -sal_Int32 TableDesignPanel::GetPreferredWidth(sal_Int32 ) -{ - return maPreferredSize.Width(); -} -sal_Int32 TableDesignPanel::GetPreferredHeight(sal_Int32 ) -{ - return maPreferredSize.Height(); -} -::Window* TableDesignPanel::GetWindow() -{ - return mpWrappedControl; -} -bool TableDesignPanel::IsResizable() -{ - return true; -} -bool TableDesignPanel::IsExpandable() const -{ - return true; -} - -::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible> TableDesignPanel::CreateAccessibleObject ( - const ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible>& ) -{ - if (GetWindow() != NULL) - return GetWindow()->GetAccessible(); - else - return NULL; -} - -} } } // end of namespace ::sd::toolpanel::controls - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/toolpanel/controls/TableDesignPanel.hxx b/sd/source/ui/toolpanel/controls/TableDesignPanel.hxx deleted file mode 100644 index 6ed358bd4..000000000 --- a/sd/source/ui/toolpanel/controls/TableDesignPanel.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_CONTROLS_TABLE_DESIGN_PANEL_HXX -#define SD_TOOLPANEL_CONTROLS_TABLE_DESIGN_PANEL_HXX - -#include "taskpane/SubToolPanel.hxx" - -namespace sd { -class ViewShellBase; -} - -namespace sd { namespace toolpanel { -class TreeNode; -class ControlFactory; -class ToolPanelViewShell; -} } - -namespace sd { namespace toolpanel { namespace controls { - -class TableDesignPanel - : public SubToolPanel -{ -public: - TableDesignPanel ( - ::Window& i_rParentWindow, - ToolPanelViewShell& i_rPanelViewShell); - virtual ~TableDesignPanel (void); - - static std::auto_ptr<ControlFactory> CreateControlFactory (ToolPanelViewShell& i_rToolPanelShell); - - // TreeNode overridables - virtual TaskPaneShellManager* GetShellManager(); - - // ILayoutableWindow overridables - virtual Size GetPreferredSize (void); - virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeigh); - virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); - virtual ::Window* GetWindow (void); - virtual bool IsResizable (void); - virtual bool IsExpandable (void) const; - - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible > CreateAccessibleObject ( - const ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible>& rxParent); - - using Window::GetWindow; -private: - Size maPreferredSize; - ::Window* mpWrappedControl; - ToolPanelViewShell* m_pPanelViewShell; -}; - -} } } // end of namespace ::sd::toolpanel::controls - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |